Search in sources :

Example 11 with SpanElement

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;
}
Also used : SpanElement(com.google.gwt.dom.client.SpanElement) ElementEx(org.rstudio.core.client.dom.ElementEx) Rectangle(org.rstudio.core.client.Rectangle)

Example 12 with SpanElement

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;
}
Also used : SpanElement(com.google.gwt.dom.client.SpanElement)

Aggregations

SpanElement (com.google.gwt.dom.client.SpanElement)12 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)5 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)5 Event (com.google.gwt.user.client.Event)5 EventListener (com.google.gwt.user.client.EventListener)5 KeyboardEvent (elemental.events.KeyboardEvent)5 BlurEvent (com.google.gwt.event.dom.client.BlurEvent)4 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)4 Icon (org.eclipse.che.ide.api.icon.Icon)4 SVGImage (org.vectomatic.dom.svg.ui.SVGImage)3 Element (com.google.gwt.dom.client.Element)1 PreElement (com.google.gwt.dom.client.PreElement)1 GwtTestTest (com.googlecode.gwt.test.GwtTestTest)1 CommandType (org.eclipse.che.ide.api.command.CommandType)1 DebugConfigurationType (org.eclipse.che.ide.api.debug.DebugConfigurationType)1 Test (org.junit.Test)1 Rectangle (org.rstudio.core.client.Rectangle)1 VirtualConsole (org.rstudio.core.client.VirtualConsole)1 ElementEx (org.rstudio.core.client.dom.ElementEx)1