2 * Sixth 3D engine. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 3 of the GNU Lesser General Public License
6 * or later as published by the Free Software Foundation.
10 package eu.svjatoslav.sixth.e3d.gui.textEditorComponent;
12 import java.util.ArrayList;
13 import java.util.List;
17 public List<TextLine> lines = new ArrayList<>();
19 public void ensureMaxTextLine(final int row) {
20 while (lines.size() <= row)
21 lines.add(new TextLine());
24 public char getChar(final int row, final int column) {
25 if (lines.size() <= row)
27 return lines.get(row).getCharForLocation(column);
30 public TextLine getLine(final int row) {
31 ensureMaxTextLine(row);
32 return lines.get(row);
35 public int getLineLength(final int row) {
36 if (lines.size() <= row)
38 return lines.get(row).getLength();
41 public int getLinesCount() {
46 public String getText() {
49 final StringBuilder result = new StringBuilder();
50 for (final TextLine textLine : lines) {
51 if (result.length() > 0)
53 result.append(textLine.toString());
55 return result.toString();
58 public void insertCharacter(final int row, final int col, final char value) {
59 getLine(row).insertCharacter(col, value);
62 public void insertLine(final int row, final TextLine textLine) {
63 lines.add(row, textLine);
69 for (int i = lines.size() - 1; i >= 0; i--)
70 if (!lines.get(i).isEmpty()) {
75 if (newLength == lines.size())
78 lines = lines.subList(0, newLength);
81 public void removeCharacter(final int row, final int col) {
82 if (lines.size() <= row)
84 getLine(row).removeCharacter(col);
87 public void removeLine(final int row) {
88 if (lines.size() <= row)