diff -r 8a7e51bd3ddb -r a778386e297f src/main/java/org/vaadin/console/client/ui/TextConsole.java --- a/src/main/java/org/vaadin/console/client/ui/TextConsole.java Wed May 18 15:04:22 2011 +0400 +++ b/src/main/java/org/vaadin/console/client/ui/TextConsole.java Wed May 18 22:18:43 2011 +0400 @@ -529,6 +529,41 @@ reducePrompt(linesAdded); } + + public void print(String string, String className) { + if (isPromptActive()) { + setPromtActive(false); + if (!bufferIsEmpty() && !bufferEndsWithNewLine()) { + newLine(); + reducePrompt(-1); + } + string = getCurrentPromptContent() + string; + } + final boolean doWrap = config.isWrap(); + // _log("print original: '" + string + "' (" + doWrap + ")"); + String str = string.replaceAll("\t", tabs); + int linesAdded = 0; + + Element classedChild = Document.get().createElement("span"); + classedChild.addClassName(className); + buffer.appendChild(classedChild); + // Split by the newlines anyway + int s = 0, e = str.indexOf('\n'); + while (e >= s) { + final String line = str.substring(s, e); + linesAdded += appendLine(classedChild, line, doWrap ? cols : -1); + classedChild.appendChild(createBr()); + s = e + 1; + e = str.indexOf('\n', s); + } + + // Print the remaining string + if (s < str.length()) { + linesAdded += appendLine(classedChild, str.substring(s), doWrap ? cols : -1); + } + + reducePrompt(linesAdded); + } public void append(String string) { if (isPromptActive()) { @@ -566,6 +601,36 @@ reducePrompt(linesAdded); } + public void append(String string, String className) { + if (isPromptActive()) { + setPromtActive(false); + } + final boolean doWrap = config.isWrap(); +// _log("print original: '" + string + "' (" + doWrap + ")"); + String str = string.replaceAll("\t", tabs); + int linesAdded = 0; + + Element classedChild = Document.get().createElement("span"); + classedChild.addClassName(className); + buffer.appendChild(classedChild); + // Split by the newlines anyway + int s = 0, e = str.indexOf('\n'); + while (e >= s) { + final String line = str.substring(s, e); + linesAdded += appendLine(classedChild, line, doWrap ? cols : -1); + classedChild.appendChild(createBr()); + s = e + 1; + e = str.indexOf('\n', s); + } + + // Print the remaining string + if (s < str.length()) { + linesAdded += appendLine(classedChild, str.substring(s), doWrap ? cols : -1); + } + + reducePrompt(linesAdded); + } + private String getCurrentPromptContent() { return prompt.getInnerText() + getInput(); } @@ -648,6 +713,10 @@ print(string + "\n"); } + public void println(final String string, final String className) { + print(string + "\n", className); + } + @Override public void setHeight(final String height) { final int oldh = term.getClientHeight();