File indexing completed on 2024-05-05 03:58:10

0001 // kate-script
0002 // If you select some text before running the script, this line will be overwritten.
0003 if ( view.hasSelection() )
0004 {
0005     document.removeText( 0, 0, 0, document.lineLength(0) );
0006     document.insertText( 0, 0, "// initial selection: " + view.selectionStartLine + "," + view.selectionStartColumn + " - " + view.selectionEndLine + "," + view.selectionEndColumn );
0007 }
0008 // test selection interface
0009 view.selectAll();
0010 view.setSelection( 0, 0, 0, 20 );
0011 view.clearSelection();
0012 
0013 // insert some text and select that
0014 var line = document.lines();
0015 document.insertLine( line, "foo" );
0016 document.insertText( line, 0, "// This is a new line" );
0017 view.setSelection( line, 0, line, document.lineLength(line) );
0018 // Delete that text
0019 view.removeSelectedText();
0020 
0021 // insert some text and select that
0022 var line = document.lines();
0023 document.insertLine( line, "bar" );
0024 document.insertText( line, 0, "// This is a new line" );
0025 view.setSelection( line, 0, line, document.lineLength(line) );
0026 
0027 document.insertText( line, document.lineLength( line ), " Selection is " + view.selectionStartLine + "," + view.selectionStartColumn + " - " + view.selectionEndLine + "," + view.selectionEndColumn );