public Document(final String str, final CellAttributes defaultColor) {
this.defaultColor = defaultColor;
- // TODO: set different colors based on file extension
+ // Set colors to resemble the Borland IDE colors, but for Java
+ // language keywords.
highlighter.setJavaColors();
String [] rawLines = str.split("\n");
return dirty;
}
+ /**
+ * Unset the dirty flag.
+ */
+ public void setNotDirty() {
+ dirty = false;
+ }
+
/**
* Save contents to file.
*
return lines.get(lineNumber).getDisplayLength();
}
+ /**
+ * Get the entire contents of the document as one string.
+ *
+ * @return the document contents
+ */
+ public String getText() {
+ StringBuilder sb = new StringBuilder();
+ for (Line line: getLines()) {
+ sb.append(line.getRawString());
+ sb.append("\n");
+ }
+ return sb.toString();
+ }
+
}