Package com.aptana.interactive_console.console.ui

Examples of com.aptana.interactive_console.console.ui.ScriptConsolePartitioner


    protected void tearDown() throws Exception {
        super.tearDown();
    }

    public void testJoinPartitions() throws Exception {
        ScriptConsolePartitioner partitioner = new ScriptConsolePartitioner();
        partitioner.addRange(new ScriptStyleRange(0, 1, null, null, ScriptStyleRange.STDIN));
        assertEquals(1, partitioner.getStyleRanges(0, 1).length);

        partitioner.addRange(new ScriptStyleRange(1, 1, null, null, ScriptStyleRange.STDIN));
        assertEquals(1, partitioner.getStyleRanges(0, 2).length);

        partitioner.addRange(new ScriptStyleRange(1, 1, null, null, ScriptStyleRange.STDOUT));
        assertEquals(2, partitioner.getStyleRanges(0, 2).length);

        partitioner.addRange(new ScriptStyleRange(1, 1, null, null, ScriptStyleRange.STDIN));
        assertEquals(1, partitioner.getStyleRanges(0, 2).length);

    }
View Full Code Here


        assertEquals(1, partitioner.getStyleRanges(0, 2).length);

    }

    public void testPartitioning() throws Exception {
        ScriptConsolePartitioner partitioner = new ScriptConsolePartitioner();
        partitioner.addRange(new ScriptStyleRange(0, 1, null, null, ScriptStyleRange.STDIN));
        assertEquals(1, partitioner.getStyleRanges(0, 1).length);

        partitioner.addRange(new ScriptStyleRange(0, 1, null, null, ScriptStyleRange.STDERR));
        assertEquals(1, partitioner.getStyleRanges(0, 1).length);

        partitioner.addRange(new ScriptStyleRange(0, 3, null, null, ScriptStyleRange.STDOUT));
        assertEquals(1, partitioner.getStyleRanges(0, 1).length);

        partitioner.addRange(new ScriptStyleRange(2, 1, null, null, ScriptStyleRange.PROMPT));
        assertEquals(1, partitioner.getStyleRanges(0, 1).length);

        StyleRange[] styleRanges = partitioner.getStyleRanges(0, 3);
        assertEquals(2, styleRanges.length);
        assertEquals(0, styleRanges[0].start);
        assertEquals(2, styleRanges[0].length);
        assertEquals(2, styleRanges[1].start);
        assertEquals(1, styleRanges[1].length);

        styleRanges = partitioner.getStyleRanges(0, 50);
        assertEquals(3, styleRanges.length);
        assertEquals(0, styleRanges[0].start);
        assertEquals(2, styleRanges[0].length);
        assertEquals(2, styleRanges[1].start);
        assertEquals(1, styleRanges[1].length);
        assertEquals(3, styleRanges[2].start);
        assertEquals(47, styleRanges[2].length);

        styleRanges = partitioner.getStyleRanges(1, 50);
        assertEquals(3, styleRanges.length);
        assertEquals(0, styleRanges[0].start);
        assertEquals(2, styleRanges[0].length);
        assertEquals(2, styleRanges[1].start);
        assertEquals(1, styleRanges[1].length);
View Full Code Here

     * @return the text in the given range that's related to actual code / output (but not the prompt)
     */
    public String getPlainText(IDocument doc, Point selectedRange) {
        StringBuffer plainText = new StringBuffer();

        ScriptConsolePartitioner scriptConsolePartitioner = (ScriptConsolePartitioner) doc.getDocumentPartitioner();
        ScriptStyleRange[] ranges = scriptConsolePartitioner.getStyleRanges(selectedRange.x, selectedRange.y);
        if (ranges.length == 0) {
            return "";
        }

        try {
View Full Code Here

     * @param style the style to be added.
     */
    private void addToPartitioner(ScriptStyleRange style) {
        IDocumentPartitioner partitioner = this.doc.getDocumentPartitioner();
        if (partitioner instanceof ScriptConsolePartitioner) {
            ScriptConsolePartitioner scriptConsolePartitioner = (ScriptConsolePartitioner) partitioner;
            scriptConsolePartitioner.addRange(style);
        }
    }
View Full Code Here

        try {
            TextSelectionUtils ps = new TextSelectionUtils(doc, caretOffset);
            int lineOffset = ps.getLineOffset();

            int promptEndOffset = lineOffset;
            ScriptConsolePartitioner partitioner = (ScriptConsolePartitioner) doc.getDocumentPartitioner();
            int docLen = doc.getLength();

            for (; promptEndOffset < docLen; promptEndOffset++) {
                ScriptStyleRange[] range = partitioner.getStyleRanges(promptEndOffset, 1);
                if (range.length >= 1) {
                    if (range[0].scriptType != ScriptStyleRange.PROMPT) {
                        break;
                    }
                }
View Full Code Here

TOP

Related Classes of com.aptana.interactive_console.console.ui.ScriptConsolePartitioner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.