Commit | Line | Data |
---|---|---|
a3b510ab NR |
1 | /* |
2 | * This file is part of lanterna (http://code.google.com/p/lanterna/). | |
3 | * | |
4 | * lanterna is free software: you can redistribute it and/or modify | |
5 | * it under the terms of the GNU Lesser General Public License as published by | |
6 | * the Free Software Foundation, either version 3 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU Lesser General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU Lesser General Public License | |
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | * | |
17 | * Copyright (C) 2010-2015 Martin | |
18 | */ | |
19 | package com.googlecode.lanterna.terminal.swing; | |
20 | ||
21 | /** | |
22 | * This interface can be used to control the backlog scrolling of a SwingTerminal. It's used as a callback by the | |
23 | * {@code SwingTerminal} when it needs to fetch the scroll position and also used whenever the backlog changes to that | |
24 | * some view class, like a scrollbar for example, can update its view accordingly. | |
25 | * @author Martin | |
26 | */ | |
27 | public interface TerminalScrollController { | |
28 | /** | |
29 | * Called by the SwingTerminal when the terminal has changed or more lines are entered into the terminal | |
30 | * @param totalSize Total number of lines in the backlog currently | |
31 | * @param screenSize Number of lines covered by the terminal window at its current size | |
32 | */ | |
33 | void updateModel(int totalSize, int screenSize); | |
34 | ||
35 | /** | |
36 | * Called by the SwingTerminal to know the 'offset' into the backlog. Returning 0 here will always draw the latest | |
37 | * lines; if you return 5, it will draw from five lines into the backlog and skip the 5 most recent lines. | |
38 | * @return According to this scroll controller, how far back into the backlog are we? | |
39 | */ | |
40 | int getScrollingOffset(); | |
41 | ||
42 | final class Null implements TerminalScrollController { | |
43 | @Override | |
44 | public void updateModel(int totalSize, int screenSize) { | |
45 | } | |
46 | ||
47 | @Override | |
48 | public int getScrollingOffset() { | |
49 | return 0; | |
50 | } | |
51 | } | |
52 | } |