public void onSendToConsole(final SendToConsoleEvent event) { final InputEditorDisplay display = view_.getInputEditorDisplay(); // get anything already at the console final String previousInput = StringUtil.notNull(display.getText()); // define code block we execute at finish Command finishSendToConsole = new Command() { @Override public void execute() { if (event.shouldExecute()) { processCommandEntry(); if (previousInput.length() > 0) display.setText(previousInput); } if (!event.shouldExecute() || event.shouldFocus()) { display.setFocus(true); display.collapseSelection(false); } } }; // do standrd finish if we aren't animating if (!event.shouldAnimate()) { display.clear(); display.setText(event.getCode()); finishSendToConsole.execute(); } else { inputAnimator_.enque(event.getCode(), finishSendToConsole); } }
public String processCommandEntry() { // parse out the command text String promptText = prompt_.getElement().getInnerText(); String commandText = input_.getCode(); input_.setText(""); // Force render to avoid subtle command movement in the console, caused // by the prompt disappearing before the input line does input_.forceImmediateRender(); prompt_.setHTML(""); SpanElement pendingPrompt = Document.get().createSpanElement(); pendingPrompt.setInnerText(promptText); pendingPrompt.setClassName(styles_.prompt() + " " + KEYWORD_CLASS_NAME); if (!suppressPendingInput_ && !input_.isPasswordMode()) { SpanElement pendingInput = Document.get().createSpanElement(); pendingInput.setInnerText(StringUtil.notNull(commandText).split("\n")[0] + "\n"); pendingInput.setClassName(styles_.command() + " " + KEYWORD_CLASS_NAME); pendingInput_.getElement().appendChild(pendingPrompt); pendingInput_.getElement().appendChild(pendingInput); pendingInput_.setVisible(true); } ensureInputVisible(); return commandText; }
public void consolePrompt(String prompt, boolean showInput) { if (prompt != null) prompt = VirtualConsole.consolify(prompt); prompt_.getElement().setInnerText(prompt); // input_.clear() ; ensureInputVisible(); // Deal gracefully with multi-line prompts int promptLines = StringUtil.notNull(prompt).split("\\n").length; input_.asWidget().getElement().getStyle().setPaddingTop((promptLines - 1) * 15, Unit.PX); input_.setPasswordMode(!showInput); }
public String getText() { return StringUtil.notNull(label_.getInnerText()); }
public String getPromptText() { return StringUtil.notNull(prompt_.getText()); }