use of com.google.gwt.dom.client.SpanElement in project rstudio by rstudio.
the class DomUtilsStandardImpl method getCursorBounds.
public Rectangle getCursorBounds(Document doc) {
Selection sel = Selection.get(NativeWindow.get(doc));
Range selRng = sel.getRangeAt(0);
if (selRng == null)
return null;
sel.removeAllRanges();
SpanElement span = doc.createSpanElement();
Range rng = selRng.cloneRange();
rng.collapse(true);
rng.insertNode(span);
int x = span.getAbsoluteLeft();
int y = span.getAbsoluteTop();
int w = 0;
int h = span.getOffsetHeight();
Rectangle result = new Rectangle(x, y, w, h);
ElementEx parent = (ElementEx) span.getParentElement();
parent.removeChild(span);
parent.normalize();
sel.setRange(selRng);
return result;
}
use of com.google.gwt.dom.client.SpanElement in project rstudio by rstudio.
the class ShellWidget method processCommandEntry.
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();
String[] lines = StringUtil.notNull(commandText).split("\n");
String firstLine = lines.length > 0 ? lines[0] : "";
pendingInput.setInnerText(firstLine + "\n");
pendingInput.setClassName(styles_.command() + " " + KEYWORD_CLASS_NAME);
pendingInput_.getElement().appendChild(pendingPrompt);
pendingInput_.getElement().appendChild(pendingInput);
pendingInput_.setVisible(true);
}
ensureInputVisible();
return commandText;
}
Aggregations