2 * Sixth 3D engine. Author: Svjatoslav Agejenko.
3 * This project is released under Creative Commons Zero (CC0) license.
8 package eu.svjatoslav.sixth.e3d.gui.textEditorComponent;
10 import java.util.ArrayList;
11 import java.util.List;
15 public List<TextLine> lines = new ArrayList<>();
17 public void ensureMaxTextLine(final int row) {
18 while (lines.size() <= row)
19 lines.add(new TextLine());
22 public char getChar(final int row, final int column) {
23 if (lines.size() <= row)
25 return lines.get(row).getCharForLocation(column);
28 public TextLine getLine(final int row) {
29 ensureMaxTextLine(row);
30 return lines.get(row);
33 public int getLineLength(final int row) {
34 if (lines.size() <= row)
36 return lines.get(row).getLength();
39 public int getLinesCount() {
44 public String getText() {
47 final StringBuilder result = new StringBuilder();
48 for (final TextLine textLine : lines) {
49 if (result.length() > 0)
51 result.append(textLine.toString());
53 return result.toString();
56 public void insertCharacter(final int row, final int col, final char value) {
57 getLine(row).insertCharacter(col, value);
60 public void insertLine(final int row, final TextLine textLine) {
61 lines.add(row, textLine);
67 for (int i = lines.size() - 1; i >= 0; i--)
68 if (!lines.get(i).isEmpty()) {
73 if (newLength == lines.size())
76 lines = lines.subList(0, newLength);
79 public void removeCharacter(final int row, final int col) {
80 if (lines.size() <= row)
82 getLine(row).removeCharacter(col);
85 public void removeLine(final int row) {
86 if (lines.size() <= row)