/jEdit/tags/after_bsh-2-0b4/macros/Editing/Go_to_Column.bsh

# · Unknown · 51 lines · 46 code · 5 blank · 0 comment · 0 complexity · dcaf9f1c255c8892d20c3250f64620ef MD5 · raw file

  1. /*
  2. * Go_to_Column.bsh - a BeanShell macro for the jEdit text
  3. * editor - Prompts the user for a column position on the
  4. * current line, then moves the caret there.
  5. *
  6. * Copyright (C) 2003 Ollie Rutherfurd <oliver@rutherfurd.net>
  7. *
  8. * $Id: Go_to_Column.bsh 4995 2004-03-19 15:58:00Z spestov $
  9. */
  10. goToColumn()
  11. {
  12. line = textArea.getCaretLine();
  13. len = textArea.getLineLength(line) + 1;
  14. while(true)
  15. {
  16. col = Macros.input(view, "Column (between 1 and " + len + "):");
  17. if(col == null)
  18. return;
  19. else
  20. {
  21. try
  22. {
  23. col = Integer.parseInt(col);
  24. if(col >= 1 && col <= len)
  25. {
  26. lineStartOffset = textArea.getLineStartOffset(line);
  27. textArea.setCaretPosition(lineStartOffset + (col-1));
  28. textArea.requestFocus();
  29. return;
  30. }
  31. }catch(NumberFormatException e){
  32. }
  33. }
  34. }
  35. }
  36. goToColumn();
  37. /*
  38. Macro index data (in DocBook format)
  39. <listitem>
  40. <para><filename>Go_to_Column.bsh</filename></para>
  41. <abstract><para>
  42. Prompts the user for a column position on the
  43. current line, then moves the caret there.
  44. </para></abstract>
  45. </listitem>
  46. */