3f748036ff670ab45339b09689bc6f22da02e7d8
2 * Jexer - Java Text User Interface - demonstration program
6 * Author: Kevin Lamonte, <a href="mailto:kevin.lamonte@gmail.com">kevin.lamonte@gmail.com</a>
8 * License: LGPLv3 or later
10 * Copyright: This module is licensed under the GNU Lesser General
11 * Public License Version 3. Please see the file "COPYING" in this
12 * directory for more information about the GNU Lesser General Public
15 * Copyright (C) 2015 Kevin Lamonte
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public License
19 * as published by the Free Software Foundation; either version 3 of
20 * the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful, but
23 * WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * General Public License for more details.
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with this program; if not, see
29 * http://www.gnu.org/licenses/, or write to the Free Software
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
36 * TApplication sets up a full Text User Interface application.
38 public class TApplication
{
41 * Run this application until it exits, using stdin and stdout
43 final public void run() {
46 while (quit == false) {
48 // Timeout is in milliseconds, so default timeout after 1
49 // second of inactivity.
50 uint timeout = getSleepTime(1000);
51 // std.stdio.stderr.writefln("poll() timeout: %d", timeout);
53 if (eventQueue.length > 0) {
54 // Do not wait if there are definitely events waiting to be
55 // processed or a screen redraw to do.
59 // Pull any pending input events
60 TInputEvent [] events = backend.getEvents(timeout);
61 metaHandleEvents(events);
63 // Process timers and call doIdle()'s
70 // Shutdown the fibers
71 eventQueue.length = 0;
72 if (secondaryEventFiber !is null) {
73 assert(secondaryEventReceiver !is null);
74 secondaryEventReceiver = null;
75 if (secondaryEventFiber.state == Fiber.State.HOLD) {
76 // Wake up the secondary handler so that it can exit.
77 secondaryEventFiber.call();
81 if (primaryEventFiber.state == Fiber.State.HOLD) {
82 // Wake up the primary handler so that it can exit.
83 primaryEventFiber.call();
89 System
.out
.println("Hello");