/*
- * Sixth 3D engine. Copyright ©2012-2020, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 3 of the GNU Lesser General Public License
- * or later as published by the Free Software Foundation.
- *
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * This project is released under Creative Commons Zero (CC0) license.
*/
-
package eu.svjatoslav.sixth.e3d.gui.textEditorComponent;
import java.util.ArrayList;
public class Page {
- public List<TextLine> lines = new ArrayList<>();
+ public List<TextLine> rows = new ArrayList<>();
public void ensureMaxTextLine(final int row) {
- while (lines.size() <= row)
- lines.add(new TextLine());
+ while (rows.size() <= row)
+ rows.add(new TextLine());
}
public char getChar(final int row, final int column) {
- if (lines.size() <= row)
+ if (rows.size() <= row)
return ' ';
- return lines.get(row).getCharForLocation(column);
+ return rows.get(row).getCharForLocation(column);
}
public TextLine getLine(final int row) {
ensureMaxTextLine(row);
- return lines.get(row);
+ return rows.get(row);
}
public int getLineLength(final int row) {
- if (lines.size() <= row)
+ if (rows.size() <= row)
return 0;
- return lines.get(row).getLength();
+ return rows.get(row).getLength();
}
public int getLinesCount() {
pack();
- return lines.size();
+ return rows.size();
}
public String getText() {
pack();
final StringBuilder result = new StringBuilder();
- for (final TextLine textLine : lines) {
+ for (final TextLine textLine : rows) {
if (result.length() > 0)
result.append("\n");
result.append(textLine.toString());
}
public void insertLine(final int row, final TextLine textLine) {
- lines.add(row, textLine);
+ rows.add(row, textLine);
}
private void pack() {
int newLength = 0;
- for (int i = lines.size() - 1; i >= 0; i--)
- if (!lines.get(i).isEmpty()) {
+ for (int i = rows.size() - 1; i >= 0; i--)
+ if (!rows.get(i).isEmpty()) {
newLength = i + 1;
break;
}
- if (newLength == lines.size())
+ if (newLength == rows.size())
return;
- lines = lines.subList(0, newLength);
+ rows = rows.subList(0, newLength);
}
public void removeCharacter(final int row, final int col) {
- if (lines.size() <= row)
+ if (rows.size() <= row)
return;
getLine(row).removeCharacter(col);
}
public void removeLine(final int row) {
- if (lines.size() <= row)
+ if (rows.size() <= row)
return;
- lines.remove(row);
+ rows.remove(row);
}
}