src/main/java/org/vaadin/console/client/ui/TextConsole.java
changeset 3 3eab4f9f42a9
parent 1 9b9d2f4b4ce0
child 4 27bd1032a5c6
equal deleted inserted replaced
2:7226af94d262 3:3eab4f9f42a9
   443     }
   443     }
   444 
   444 
   445     protected void setPs(final String string) {
   445     protected void setPs(final String string) {
   446         cleanPs = Util.escapeHTML(string);
   446         cleanPs = Util.escapeHTML(string);
   447         cleanPs = cleanPs.replaceAll(" ", " ");
   447         cleanPs = cleanPs.replaceAll(" ", " ");
       
   448         ps.setInnerHTML(cleanPs);
   448     }
   449     }
   449 
   450 
   450     public void prompt(final String inputText) {
   451     public void prompt(final String inputText) {
   451         setPromtActive(true);
   452         setPromtActive(true);
   452         scrollToEnd();
   453         scrollToEnd();
   507                     : -1);
   508                     : -1);
   508         }
   509         }
   509 
   510 
   510         reducePrompt(linesAdded);
   511         reducePrompt(linesAdded);
   511     }
   512     }
       
   513     
       
   514 	public void append(String string) {
       
   515 		if (isPromptActive()) {
       
   516 			setPromtActive(false);
       
   517 		}
       
   518 		final boolean doWrap = config.isWrap();
       
   519 		// _log("print original: '" + string + "' (" + doWrap + ")");
       
   520 		String str = string.replaceAll("\t", tabs);
       
   521 
       
   522 		// Continue to the last text node if available
       
   523 		final Node last = getLastTextNode();
       
   524 		int linesAdded = 0;
       
   525 		if (last != null) {
       
   526 			// _log("print append to old node: '" + last.getNodeValue() + "'");
       
   527 			str = last.getNodeValue() + str;
       
   528 			buffer.removeChild(last);
       
   529 			linesAdded--;
       
   530 		}
       
   531 
       
   532 		// Split by the newlines anyway
       
   533 		int s = 0, e = str.indexOf('\n');
       
   534 		while (e >= s) {
       
   535 			final String line = str.substring(s, e);
       
   536 			linesAdded += appendLine(buffer, line, doWrap ? cols : -1);
       
   537 			buffer.appendChild(createBr());
       
   538 			s = e + 1;
       
   539 			e = str.indexOf('\n', s);
       
   540 		}
       
   541 
       
   542 		// Print the remaining string
       
   543 		if (s < str.length()) {
       
   544 			linesAdded += appendLine(buffer, str.substring(s), doWrap ? cols : -1);
       
   545 		}
       
   546 
       
   547 		reducePrompt(linesAdded);
       
   548 	}
   512 
   549 
   513     private String getCurrentPromptContent() {
   550     private String getCurrentPromptContent() {
   514         return prompt.getInnerText() + getInput();
   551         return prompt.getInnerText() + getInput();
   515     }
   552     }
   516 
   553