PageRenderTime 81ms CodeModel.GetById 79ms app.highlight 1ms 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
 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
13void emacsNextLine(View view){
14
15	// need access to textArea.lastLinePartial
16	setAccessibility(true);
17
18	int first = textArea.getFirstLine();
19	int caretLine = textArea.getScreenLineOfOffset(textArea.getCaretPosition());
20	int visibleLines = textArea.getVisibleLines();
21	int electricScroll = textArea.getElectricScroll();
22
23	if(caretLine != -1 && caretLine+1 >= 
24			(visibleLines - (electricScroll + (textArea.lastLinePartial ? 1 : 0))))
25	{
26		int newFirst = (first + (visibleLines - electricScroll) / 2);
27		textArea.setFirstLine(newFirst);
28	}
29	textArea.goToNextLine(false);
30}
31
32emacsNextLine(view);
33
34/*
35	<listitem>
36		<para><filename>Emacs_Next_Line.bsh</filename></para>
37		<abstract><para>
38			Moves the cursor to the next line, centering 
39			the current line in the middle of the text area
40			if the cursor is at the bottom of the text area.
41		</para></abstract>
42	</listitem>
43*/