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> rows = new ArrayList<>();
14 public void ensureMaxTextLine(final int row) {
15 while (rows.size() <= row)
16 rows.add(new TextLine());
19 public char getChar(final int row, final int column) {
20 if (rows.size() <= row)
22 return rows.get(row).getCharForLocation(column);
25 public TextLine getLine(final int row) {
26 ensureMaxTextLine(row);
30 public int getLineLength(final int row) {
31 if (rows.size() <= row)
33 return rows.get(row).getLength();
36 public int getLinesCount() {
41 public String getText() {
44 final StringBuilder result = new StringBuilder();
45 for (final TextLine textLine : rows) {
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 rows.add(row, textLine);
64 for (int i = rows.size() - 1; i >= 0; i--)
65 if (!rows.get(i).isEmpty()) {
70 if (newLength == rows.size())
73 rows = rows.subList(0, newLength);
76 public void removeCharacter(final int row, final int col) {
77 if (rows.size() <= row)
79 getLine(row).removeCharacter(col);
82 public void removeLine(final int row) {
83 if (rows.size() <= row)