/jEdit/tags/jedit-4-3-2/macros/Clipboard/Cut_Lines.bsh

#
Unknown | 41 lines | 34 code | 7 blank | 0 comment | 0 complexity | f1194ed0d0456c813bdf439555bc70d0 MD5 | raw file
  1. /*
  2. * Cut_Lines.bsh - a BeanShell macro for jEdit
  3. * which cuts either the selected text, or the current line
  4. * if no text is selected, to the clipboard.
  5. *
  6. * Copyright (C) 2003 Ollie Rutherfurd <oliver@jedit.org>
  7. * Copyright (c) 2008 encorejane@users.sourceforge.net
  8. *
  9. * $Id: Cut_Lines.bsh 11860 2008-02-24 23:43:28Z ezust $
  10. */
  11. cutLines(){
  12. selections = textArea.getSelectedLines();
  13. if(selections.length == 0){
  14. selections = new int [] {textArea.getCaretLine()};
  15. }
  16. start = textArea.getLineStartOffset(selections[0]);
  17. stop = textArea.getLineEndOffset(selections[selections.length-1]);
  18. textArea.setSelection(new Selection.Range(start,stop));
  19. Registers.cut(textArea,'$');
  20. }
  21. if(buffer.isReadOnly())
  22. Toolkit.getDefaultToolkit().beep();
  23. else
  24. cutLines();
  25. /*
  26. Macro index data (in DocBook format)
  27. <listitem>
  28. <para><filename>Cut_Selection_or_Line.bsh</filename>
  29. <abstract><para>
  30. If no text is selected, the current line is cut to the clipboard,
  31. otherwise, all lines that contain the selection are cut to the clipboard.
  32. </para></abstract>
  33. </listitem>
  34. */