Search in sources :

Example 1 with VirtualConsole

use of org.rstudio.core.client.VirtualConsole in project rstudio by rstudio.

the class ShellWidget method output.

private boolean output(String text, String className, boolean addToTop) {
    if (text.indexOf('\f') >= 0)
        clearOutput();
    Element outEl = output_.getElement();
    if (addToTop) {
        SpanElement leading = Document.get().createSpanElement();
        outEl.insertFirst(leading);
        VirtualConsole console = new VirtualConsole(leading);
        console.submit(text, className);
        lines_ += DomUtils.countLines(leading, true);
    } else {
        // create trailing output console if it doesn't already exist 
        if (virtualConsole_ == null) {
            SpanElement trailing = Document.get().createSpanElement();
            outEl.appendChild(trailing);
            virtualConsole_ = new VirtualConsole(trailing);
        }
        int oldLineCount = DomUtils.countLines(virtualConsole_.getParent(), true);
        virtualConsole_.submit(text, className);
        int newLineCount = DomUtils.countLines(virtualConsole_.getParent(), true);
        lines_ += newLineCount - oldLineCount;
    }
    boolean result = !trimExcess();
    resizeCommand_.nudge();
    return result;
}
Also used : SpanElement(com.google.gwt.dom.client.SpanElement) VirtualConsole(org.rstudio.core.client.VirtualConsole) Element(com.google.gwt.dom.client.Element) SpanElement(com.google.gwt.dom.client.SpanElement)

Example 2 with VirtualConsole

use of org.rstudio.core.client.VirtualConsole in project rstudio by rstudio.

the class VirtualConsoleTests method testFormFeed.

public void testFormFeed() {
    PreElement ele = Document.get().createPreElement();
    VirtualConsole vc = new VirtualConsole(ele);
    vc.submit("Sample1\n");
    vc.submit("Sample2\n");
    vc.submit("Sample3\f");
    vc.submit("Sample4");
    Assert.assertEquals("<span>Sample4</span>", ele.getInnerHTML());
}
Also used : VirtualConsole(org.rstudio.core.client.VirtualConsole) PreElement(com.google.gwt.dom.client.PreElement)

Example 3 with VirtualConsole

use of org.rstudio.core.client.VirtualConsole in project rstudio by rstudio.

the class VirtualConsoleTests method testSimpleColor.

public void testSimpleColor() {
    PreElement ele = Document.get().createPreElement();
    VirtualConsole vc = new VirtualConsole(ele);
    vc.submit("Error", "error");
    Assert.assertEquals("<span class=\"error\">Error</span>", ele.getInnerHTML());
}
Also used : VirtualConsole(org.rstudio.core.client.VirtualConsole) PreElement(com.google.gwt.dom.client.PreElement)

Example 4 with VirtualConsole

use of org.rstudio.core.client.VirtualConsole in project rstudio by rstudio.

the class VirtualConsoleTests method testColorOverwrite.

public void testColorOverwrite() {
    PreElement ele = Document.get().createPreElement();
    VirtualConsole vc = new VirtualConsole(ele);
    vc.submit("XXXX\r", "X");
    vc.submit("YY", "Y");
    Assert.assertEquals("<span class=\"Y\">YY</span>" + "<span class=\"X\">XX</span>", ele.getInnerHTML());
}
Also used : VirtualConsole(org.rstudio.core.client.VirtualConsole) PreElement(com.google.gwt.dom.client.PreElement)

Example 5 with VirtualConsole

use of org.rstudio.core.client.VirtualConsole in project rstudio by rstudio.

the class CompileOutputBuffer method clear.

@Override
public void clear() {
    output_.setText("");
    virtualConsole_ = new VirtualConsole(output_.getElement());
}
Also used : VirtualConsole(org.rstudio.core.client.VirtualConsole)

Aggregations

VirtualConsole (org.rstudio.core.client.VirtualConsole)9 PreElement (com.google.gwt.dom.client.PreElement)6 Element (com.google.gwt.dom.client.Element)1 SpanElement (com.google.gwt.dom.client.SpanElement)1 PreWidget (org.rstudio.core.client.widget.PreWidget)1