File: Emacs_Next_Line.bsh

package info (click to toggle)
jedit 5.3.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,252 kB
  • ctags: 11,190
  • sloc: java: 98,480; xml: 94,070; makefile: 52; sh: 42; cpp: 6; python: 6
file content (43 lines) | stat: -rw-r--r-- 1,330 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * Emacs_Next_Line.bsh - Beanshell macro for jEdit that provides
 * 'Emacs-like scrolling.  If the caret is at the bottom of the 
 * screen the next line is centered on the screen rather than 
 * scrolling the whole text area by one line.  For machines with
 * slow painting, this can increase scrolling speed.
 *
 * Copyright (C) 2002-2004, Ollie Rutherfurd <oliver@rutherfurd.net>
 *
 * $Id: Emacs_Next_Line.bsh 22257 2012-09-27 20:22:23Z ezust $
 */

void emacsNextLine(View view){

	// need access to textArea.lastLinePartial
	setAccessibility(true);

	int first = textArea.getFirstLine();
	int caretLine = textArea.getScreenLineOfOffset(textArea.getCaretPosition());
	int visibleLines = textArea.getVisibleLines();
	int electricScroll = textArea.getElectricScroll();

	if(caretLine != -1 && caretLine+1 >= 
			(visibleLines - (electricScroll + (textArea.lastLinePartial ? 1 : 0))))
	{
		int newFirst = (first + (visibleLines - electricScroll) / 2);
		textArea.setFirstLine(newFirst);
	}
	textArea.goToNextLine(false);
}

emacsNextLine(view);

/*
	<listitem>
		<para><filename>Emacs_Next_Line.bsh</filename></para>
		<abstract><para>
			Moves the cursor to the next line, centering 
			the current line in the middle of the text area
			if the cursor is at the bottom of the text area.
		</para></abstract>
	</listitem>
*/