X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fteditor%2FDocument.java;h=e94950371af02507ad1abaad4f305983e8260274;hb=bff0df27562e1cca8e6be47e7ace9bd5bb1adbfa;hp=ffbe0816bd1e80b2c4639e7253b8b4dc3f50b8eb;hpb=b2efac6ed4525f77cbcb717a082d3a2884c91936;p=fanfix.git diff --git a/src/jexer/teditor/Document.java b/src/jexer/teditor/Document.java index ffbe081..e949503 100644 --- a/src/jexer/teditor/Document.java +++ b/src/jexer/teditor/Document.java @@ -89,7 +89,8 @@ public class Document { 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"); @@ -120,6 +121,13 @@ public class Document { return dirty; } + /** + * Unset the dirty flag. + */ + public void setNotDirty() { + dirty = false; + } + /** * Save contents to file. * @@ -637,4 +645,18 @@ public class Document { 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(); + } + }