71b9d42924f386b07b47ebbe0950b02839a5ce4e
[nikiroo-utils.git] / src / jexer / backend / Backend.java
1 /*
2 * Jexer - Java Text User Interface
3 *
4 * License: LGPLv3 or later
5 *
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.
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
27 *
28 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
29 * @version 1
30 */
31 package jexer.backend;
32
33 import java.util.List;
34
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 /**
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.
62 */
63 protected Screen screen;
64
65 /**
66 * Getter for screen.
67 *
68 * @return the Screen
69 */
70 public final Screen getScreen() {
71 return screen;
72 }
73
74 /**
75 * Subclasses must provide an implementation that syncs the logical
76 * screen to the physical device.
77 */
78 public abstract void flushScreen();
79
80 /**
81 * Subclasses must provide an implementation to get keyboard, mouse, and
82 * screen resize events.
83 *
84 * @param queue list to append new events to
85 */
86 public abstract void getEvents(List<TInputEvent> queue);
87
88 /**
89 * Subclasses must provide an implementation that closes sockets,
90 * restores console, etc.
91 */
92 public abstract void shutdown();
93
94 }