01: /*
02: * ScrollLineCount.java
03: * :tabSize=8:indentSize=8:noTabs=false:
04: * :folding=explicit:collapseFolds=1:
05: *
06: * Copyright (C) 2005 Slava Pestov
07: *
08: * This program is free software; you can redistribute it and/or
09: * 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:
23: package org.gjt.sp.jedit.textarea;
24:
25: import org.gjt.sp.jedit.Debug;
26: import org.gjt.sp.util.Log;
27:
28: /**
29: * Maintains the vertical scrollbar.
30: */
31: class ScrollLineCount extends Anchor {
32: //{{{ ScrollLineCount constructor
33: ScrollLineCount(DisplayManager displayManager, TextArea textArea) {
34: super (displayManager, textArea);
35: } //}}}
36:
37: public void changed() {
38: }
39:
40: //{{{ reset() method
41: public void reset() {
42: if (Debug.SCROLL_DEBUG)
43: Log.log(Log.DEBUG, this , "reset()");
44:
45: physicalLine = displayManager.getFirstVisibleLine();
46: int scrollLine = 0;
47: while (physicalLine != -1) {
48: int before = scrollLine;
49: displayManager.updateScreenLineCount(physicalLine);
50: if (before != scrollLine)
51: throw new RuntimeException(this + " nudged");
52: scrollLine += displayManager
53: .getScreenLineCount(physicalLine);
54: physicalLine = displayManager
55: .getNextVisibleLine(physicalLine);
56: }
57:
58: this .scrollLine = scrollLine;
59: physicalLine = displayManager.getBuffer().getLineCount();
60: } //}}}
61: }
|