Refactoring. Ability to specify look and feel for text editor.
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / gui / textEditorComponent / Page.java
index 4b251c0..c52fbd7 100644 (file)
@@ -9,40 +9,40 @@ import java.util.List;
 
 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());
@@ -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);
     }
 
 }