X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=sixth-3d.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Fgui%2FtextEditorComponent%2FPage.java;h=c52fbd7e2a5c201e8481927a4a630d02a4e62eb4;hp=4b251c03e121f97422166c19ba39ca8c61ca4efe;hb=d571801d69962883e194a306ee2b7110d6adc270;hpb=6d38211af83d15953f406f6a6e30f5fa5fc81591 diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/gui/textEditorComponent/Page.java b/src/main/java/eu/svjatoslav/sixth/e3d/gui/textEditorComponent/Page.java index 4b251c0..c52fbd7 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/gui/textEditorComponent/Page.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/gui/textEditorComponent/Page.java @@ -9,40 +9,40 @@ import java.util.List; public class Page { - public List lines = new ArrayList<>(); + public List 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()); @@ -55,34 +55,34 @@ public class Page { } 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); } }