1.1 --- a/src/main/java/org/vaadin/console/client/ui/TextConsole.java Mon May 16 14:34:42 2011 +0400
1.2 +++ b/src/main/java/org/vaadin/console/client/ui/TextConsole.java Tue May 17 03:27:01 2011 +0400
1.3 @@ -445,6 +445,7 @@
1.4 protected void setPs(final String string) {
1.5 cleanPs = Util.escapeHTML(string);
1.6 cleanPs = cleanPs.replaceAll(" ", " ");
1.7 + ps.setInnerHTML(cleanPs);
1.8 }
1.9
1.10 public void prompt(final String inputText) {
1.11 @@ -509,6 +510,42 @@
1.12
1.13 reducePrompt(linesAdded);
1.14 }
1.15 +
1.16 + public void append(String string) {
1.17 + if (isPromptActive()) {
1.18 + setPromtActive(false);
1.19 + }
1.20 + final boolean doWrap = config.isWrap();
1.21 + // _log("print original: '" + string + "' (" + doWrap + ")");
1.22 + String str = string.replaceAll("\t", tabs);
1.23 +
1.24 + // Continue to the last text node if available
1.25 + final Node last = getLastTextNode();
1.26 + int linesAdded = 0;
1.27 + if (last != null) {
1.28 + // _log("print append to old node: '" + last.getNodeValue() + "'");
1.29 + str = last.getNodeValue() + str;
1.30 + buffer.removeChild(last);
1.31 + linesAdded--;
1.32 + }
1.33 +
1.34 + // Split by the newlines anyway
1.35 + int s = 0, e = str.indexOf('\n');
1.36 + while (e >= s) {
1.37 + final String line = str.substring(s, e);
1.38 + linesAdded += appendLine(buffer, line, doWrap ? cols : -1);
1.39 + buffer.appendChild(createBr());
1.40 + s = e + 1;
1.41 + e = str.indexOf('\n', s);
1.42 + }
1.43 +
1.44 + // Print the remaining string
1.45 + if (s < str.length()) {
1.46 + linesAdded += appendLine(buffer, str.substring(s), doWrap ? cols : -1);
1.47 + }
1.48 +
1.49 + reducePrompt(linesAdded);
1.50 + }
1.51
1.52 private String getCurrentPromptContent() {
1.53 return prompt.getInnerText() + getInput();