PageRenderTime 28439ms CodeModel.GetById 28407ms app.highlight 3ms RepoModel.GetById 19ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/org/gjt/sp/jedit/textarea/ScrollLineCount.java

#
Java | 65 lines | 32 code | 7 blank | 26 comment | 4 complexity | afd38de1cb82976341d808f67e73063a MD5 | raw file
 1/*
 2 * ScrollLineCount.java
 3 * :tabSize=8:indentSize=8:noTabs=false:
 4 * :folding=explicit:collapseFolds=1:
 5 *
 6 * Copyright (C) 2005 Slava Pestov
 7 *
 8 * This program is free software; you can redistribute it and/or
 9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 */
22
23package org.gjt.sp.jedit.textarea;
24
25import org.gjt.sp.jedit.Debug;
26import org.gjt.sp.util.Log;
27
28/**
29 * Maintains the vertical scrollbar.
30 */
31class ScrollLineCount extends Anchor
32{
33	//{{{ ScrollLineCount constructor
34	ScrollLineCount(DisplayManager displayManager,
35		JEditTextArea textArea)
36	{
37		super(displayManager,textArea);
38	} //}}}
39
40	public void changed() {}
41
42	//{{{ reset() method
43	public void reset()
44	{
45		if(Debug.SCROLL_DEBUG)
46			Log.log(Log.DEBUG,this,"reset()");
47
48		physicalLine = displayManager.getFirstVisibleLine();
49		int scrollLine = 0;
50		while(physicalLine != -1)
51		{
52			int before = scrollLine;
53			displayManager.updateScreenLineCount(physicalLine);
54			if(before != scrollLine)
55				throw new RuntimeException(this + " nudged");
56			scrollLine += displayManager
57				.getScreenLineCount(physicalLine);
58			physicalLine = displayManager
59				.getNextVisibleLine(physicalLine);
60		}
61
62		this.scrollLine = scrollLine;
63		physicalLine = displayManager.getBuffer().getLineCount();
64	} //}}}
65}