PageRenderTime 25ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/macros/Editing/Emacs_Next_Line.bsh

#
Unknown | 43 lines | 37 code | 6 blank | 0 comment | 0 complexity | 0f632ed0ee4fb6cc96a5270dbb13d985 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /*
  2. * Emacs_Next_Line.bsh - Beanshell macro for jEdit that provides
  3. * 'Emacs-like scrolling. If the caret is at the bottom of the
  4. * screen the next line is centered on the screen rather than
  5. * scrolling the whole text area by one line. For machines with
  6. * slow painting, this can increase scrolling speed.
  7. *
  8. * Copyright (C) 2002-2004, Ollie Rutherfurd <oliver@rutherfurd.net>
  9. *
  10. * $Id: Emacs_Next_Line.bsh 4995 2004-03-19 15:58:00Z spestov $
  11. */
  12. void emacsNextLine(View view){
  13. // need access to textArea.lastLinePartial
  14. setAccessibility(true);
  15. int first = textArea.getFirstLine();
  16. int caretLine = textArea.getScreenLineOfOffset(textArea.getCaretPosition());
  17. int visibleLines = textArea.getVisibleLines();
  18. int electricScroll = textArea.getElectricScroll();
  19. if(caretLine != -1 && caretLine+1 >=
  20. (visibleLines - (electricScroll + (textArea.lastLinePartial ? 1 : 0))))
  21. {
  22. int newFirst = (first + (visibleLines - electricScroll) / 2);
  23. textArea.setFirstLine(newFirst);
  24. }
  25. textArea.goToNextLine(false);
  26. }
  27. emacsNextLine(view);
  28. /*
  29. <listitem>
  30. <para><filename>Emacs_Next_Line.bsh</filename></para>
  31. <abstract><para>
  32. Moves the cursor to the next line, centering
  33. the current line in the middle of the text area
  34. if the cursor is at the bottom of the text area.
  35. </para></abstract>
  36. </listitem>
  37. */