/** * Shows how many lines, characters are currently selected * BeanShell macro for jEdit * * version: 1.0 released: 02/02/2007 * * by Stickman -- http://the-stickman.com */ // Get an array of selections selection_list = textArea.getSelection(); // Is anything selected? if ( selection_list.length > 0 ) { total_lines = 0; // For each selection for( i=0; i < selection_list.length; i++ ) { selection = selection_list[ i ]; total_lines += ( selection.getEndLine() - selection.getStartLine() ) + 1; } // How many total_lines? output = new StringBuffer(); output.append( total_lines.toString() ); output.append( " line" ); // Plural? output.append( ( total_lines > 1 ) ? "s" : "" ); output.append( ", " ); // How many characters? selection_length = textArea.getSelectedText("").length(); output.append( selection_length.toString() ); output.append( " character" ); // Plural? output.append( ( selection_length > 1 ) ? "s" : "" ); output.append( " selected" ); // Multiple selections if( selection_list.length > 1 ) { output.append( " (in " ); output.append( selection_list.length ); output.append( " selections)" ); } // Result message = output.toString(); } else { // No selections message = "Nothing selected"; } // Show result in status bar statusBar = view.getStatus(); statusBar.setMessageAndClear( message );