projects
/
sixth-3d.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed git clone URL
[sixth-3d.git]
/
src
/
main
/
java
/
eu
/
svjatoslav
/
sixth
/
e3d
/
gui
/
textEditorComponent
/
Page.java
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
c52fbd7
..
47c898f
100644
(file)
--- a/
src/main/java/eu/svjatoslav/sixth/e3d/gui/textEditorComponent/Page.java
+++ b/
src/main/java/eu/svjatoslav/sixth/e3d/gui/textEditorComponent/Page.java
@@
-1,5
+1,5
@@
/*
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui.textEditorComponent;
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui.textEditorComponent;
@@
-7,8
+7,14
@@
package eu.svjatoslav.sixth.e3d.gui.textEditorComponent;
import java.util.ArrayList;
import java.util.List;
import java.util.ArrayList;
import java.util.List;
+/**
+ * A page in a text editor.
+ */
public class Page {
public class Page {
+ /**
+ * The text lines.
+ */
public List<TextLine> rows = new ArrayList<>();
public void ensureMaxTextLine(final int row) {
public List<TextLine> rows = new ArrayList<>();
public void ensureMaxTextLine(final int row) {
@@
-16,28
+22,56
@@
public class Page {
rows.add(new TextLine());
}
rows.add(new TextLine());
}
+ /**
+ * Returns the character at the specified location.
+ * If the location is out of bounds, returns a space.
+ *
+ * @return The character at the specified location.
+ */
public char getChar(final int row, final int column) {
if (rows.size() <= row)
return ' ';
return rows.get(row).getCharForLocation(column);
}
public char getChar(final int row, final int column) {
if (rows.size() <= row)
return ' ';
return rows.get(row).getCharForLocation(column);
}
+ /**
+ * Returns the specified line.
+ *
+ * @param row The line number.
+ * @return The line.
+ */
public TextLine getLine(final int row) {
ensureMaxTextLine(row);
return rows.get(row);
}
public TextLine getLine(final int row) {
ensureMaxTextLine(row);
return rows.get(row);
}
+ /**
+ * Returns the length of the specified line.
+ *
+ * @param row The line number.
+ * @return The length of the line.
+ */
public int getLineLength(final int row) {
if (rows.size() <= row)
return 0;
return rows.get(row).getLength();
}
public int getLineLength(final int row) {
if (rows.size() <= row)
return 0;
return rows.get(row).getLength();
}
+ /**
+ * Returns the number of lines in the page.
+ *
+ * @return The number of lines in the page.
+ */
public int getLinesCount() {
pack();
return rows.size();
}
public int getLinesCount() {
pack();
return rows.size();
}
+ /**
+ * Returns the text of the page.
+ *
+ * @return The text of the page.
+ */
public String getText() {
pack();
public String getText() {
pack();
@@
-58,6
+92,9
@@
public class Page {
rows.add(row, textLine);
}
rows.add(row, textLine);
}
+ /**
+ * Removes empty lines from the end of the page.
+ */
private void pack() {
int newLength = 0;
private void pack() {
int newLength = 0;
@@
-73,12
+110,23
@@
public class Page {
rows = rows.subList(0, newLength);
}
rows = rows.subList(0, newLength);
}
+ /**
+ * Removes the specified character from the page.
+ *
+ * @param row The line number.
+ * @param col The character number.
+ */
public void removeCharacter(final int row, final int col) {
if (rows.size() <= row)
return;
getLine(row).removeCharacter(col);
}
public void removeCharacter(final int row, final int col) {
if (rows.size() <= row)
return;
getLine(row).removeCharacter(col);
}
+ /**
+ * Removes the specified line from the page.
+ *
+ * @param row The line number.
+ */
public void removeLine(final int row) {
if (rows.size() <= row)
return;
public void removeLine(final int row) {
if (rows.size() <= row)
return;