2 * Sixth 3D engine. Author: Svjatoslav Agejenko.
3 * This project is released under Creative Commons Zero (CC0) license.
5 package eu.svjatoslav.sixth.e3d.gui.textEditorComponent;
7 import java.util.ArrayList;
12 public List<TextLine> lines = new ArrayList<>();
14 public void ensureMaxTextLine(final int row) {
15 while (lines.size() <= row)
16 lines.add(new TextLine());
19 public char getChar(final int row, final int column) {
20 if (lines.size() <= row)
22 return lines.get(row).getCharForLocation(column);
25 public TextLine getLine(final int row) {
26 ensureMaxTextLine(row);
27 return lines.get(row);
30 public int getLineLength(final int row) {
31 if (lines.size() <= row)
33 return lines.get(row).getLength();
36 public int getLinesCount() {
41 public String getText() {
44 final StringBuilder result = new StringBuilder();
45 for (final TextLine textLine : lines) {
46 if (result.length() > 0)
48 result.append(textLine.toString());
50 return result.toString();
53 public void insertCharacter(final int row, final int col, final char value) {
54 getLine(row).insertCharacter(col, value);
57 public void insertLine(final int row, final TextLine textLine) {
58 lines.add(row, textLine);
64 for (int i = lines.size() - 1; i >= 0; i--)
65 if (!lines.get(i).isEmpty()) {
70 if (newLength == lines.size())
73 lines = lines.subList(0, newLength);
76 public void removeCharacter(final int row, final int col) {
77 if (lines.size() <= row)
79 getLine(row).removeCharacter(col);
82 public void removeLine(final int row) {
83 if (lines.size() <= row)