Commit | Line | Data |
---|---|---|
df8de03f KL |
1 | /** |
2 | * Jexer - Java Text User Interface | |
3 | * | |
df8de03f KL |
4 | * License: LGPLv3 or later |
5 | * | |
7b5261bc KL |
6 | * This module is licensed under the GNU Lesser General Public License |
7 | * Version 3. Please see the file "COPYING" in this directory for more | |
8 | * information about the GNU Lesser General Public License Version 3. | |
df8de03f KL |
9 | * |
10 | * Copyright (C) 2015 Kevin Lamonte | |
11 | * | |
12 | * This program is free software; you can redistribute it and/or | |
13 | * modify it under the terms of the GNU Lesser General Public License | |
14 | * as published by the Free Software Foundation; either version 3 of | |
15 | * the License, or (at your option) any later version. | |
16 | * | |
17 | * This program is distributed in the hope that it will be useful, but | |
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 | * General Public License for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU Lesser General Public | |
23 | * License along with this program; if not, see | |
24 | * http://www.gnu.org/licenses/, or write to the Free Software | |
25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
26 | * 02110-1301 USA | |
7b5261bc KL |
27 | * |
28 | * @author Kevin Lamonte [kevin.lamonte@gmail.com] | |
29 | * @version 1 | |
df8de03f KL |
30 | */ |
31 | package jexer.backend; | |
32 | ||
b1589621 | 33 | import java.util.List; |
05dbb28d | 34 | |
df8de03f KL |
35 | import jexer.event.TInputEvent; |
36 | import jexer.io.Screen; | |
37 | import jexer.session.SessionInfo; | |
38 | ||
39 | /** | |
40 | * This abstract class provides a screen, keyboard, and mouse to | |
41 | * TApplication. It also exposes session information as gleaned from lower | |
42 | * levels of the communication stack. | |
43 | */ | |
44 | public abstract class Backend { | |
45 | ||
46 | /** | |
7b5261bc KL |
47 | * The session information. |
48 | */ | |
49 | protected SessionInfo sessionInfo; | |
50 | ||
51 | /** | |
52 | * Getter for sessionInfo. | |
53 | * | |
54 | * @return the SessionInfo | |
55 | */ | |
56 | public final SessionInfo getSessionInfo() { | |
57 | return sessionInfo; | |
58 | } | |
59 | ||
60 | /** | |
61 | * The screen to draw on. | |
df8de03f | 62 | */ |
7b5261bc | 63 | protected Screen screen; |
df8de03f KL |
64 | |
65 | /** | |
7b5261bc KL |
66 | * Getter for screen. |
67 | * | |
68 | * @return the Screen | |
df8de03f | 69 | */ |
7b5261bc KL |
70 | public final Screen getScreen() { |
71 | return screen; | |
72 | } | |
df8de03f KL |
73 | |
74 | /** | |
75 | * Subclasses must provide an implementation that syncs the logical | |
76 | * screen to the physical device. | |
77 | */ | |
7b5261bc | 78 | public abstract void flushScreen(); |
df8de03f KL |
79 | |
80 | /** | |
81 | * Subclasses must provide an implementation to get keyboard, mouse, and | |
82 | * screen resize events. | |
83 | * | |
623a1bd1 | 84 | * @param queue list to append new events to |
05dbb28d KL |
85 | * @param timeout maximum amount of time (in millis) to wait for an |
86 | * event. 0 means to return immediately, i.e. perform a poll. | |
df8de03f | 87 | */ |
7b5261bc | 88 | public abstract void getEvents(List<TInputEvent> queue, int timeout); |
df8de03f KL |
89 | |
90 | /** | |
91 | * Subclasses must provide an implementation that closes sockets, | |
92 | * restores console, etc. | |
93 | */ | |
7b5261bc | 94 | public abstract void shutdown(); |
df8de03f KL |
95 | |
96 | } |