summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2017-10-17 00:28:56 +0000
committerGreg Ercolano <erco@seriss.com>2017-10-17 00:28:56 +0000
commit68f07db58aab37dac7f9eb9445f5632b1b09741a (patch)
tree581d421cc70a971035ed4bd76ecadce4843341b0 /examples
parent93ef00cca6655c7a07aca11c53788d957097ef8f (diff)
Added Fl_Simple_Terminal widget, and mods to test+example programs (STR #3411).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12506 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile1
-rw-r--r--examples/simple-terminal.cxx60
2 files changed, 61 insertions, 0 deletions
diff --git a/examples/Makefile b/examples/Makefile
index 4bd44c838..166086995 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -26,6 +26,7 @@ ALL = clipboard$(EXEEXT) \
table-spreadsheet-with-keyboard-nav$(EXEEXT) \
table-with-keynav$(EXEEXT) \
tabs-simple$(EXEEXT) \
+ simple-terminal$(EXEEXT) \
textdisplay-with-colors$(EXEEXT) \
texteditor-simple$(EXEEXT) \
tree-simple$(EXEEXT) \
diff --git a/examples/simple-terminal.cxx b/examples/simple-terminal.cxx
new file mode 100644
index 000000000..5e14cf7b9
--- /dev/null
+++ b/examples/simple-terminal.cxx
@@ -0,0 +1,60 @@
+//
+// "$Id$"
+//
+// Simple Example app using Fl_Simple_Terminal. - erco 10/12/2017
+//
+// Copyright 2017 Greg Ercolano.
+// Copyright 1998-2016 by Bill Spitzak and others.
+//
+// This library is free software. Distribution and use rights are outlined in
+// the file "COPYING" which should have been included with this file. If this
+// file is missing or damaged, see the license at:
+//
+// http://www.fltk.org/COPYING.php
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+#include <time.h> //START
+#include <FL/Fl_Double_Window.H>
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Simple_Terminal.H>
+
+#define TERMINAL_HEIGHT 120
+
+// Globals
+Fl_Double_Window *G_win = 0;
+Fl_Box *G_box = 0;
+Fl_Simple_Terminal *G_tty = 0;
+
+// Append a date/time message to the terminal every 2 seconds
+void tick_cb(void *data) {
+ time_t lt = time(NULL);
+ G_tty->printf("Timer tick: \033[32m%s\033[0m\n", ctime(&lt));
+ Fl::repeat_timeout(2.0, tick_cb, data);
+}
+
+int main(int argc, char **argv) {
+ G_win = new Fl_Double_Window(500, 200+TERMINAL_HEIGHT, "Your App");
+ G_win->begin();
+
+ G_box = new Fl_Box(0, 0, G_win->w(), 200,
+ "Your app GUI in this area.\n\n"
+ "Your app's debugging output in tty below");
+
+ // Add simple terminal to bottom of app window for scrolling history of status messages.
+ G_tty = new Fl_Simple_Terminal(0,200,G_win->w(),TERMINAL_HEIGHT);
+ G_tty->ansi(true); // enable use of "\033[32m"
+
+ G_win->end();
+ G_win->resizable(G_win);
+ G_win->show();
+ Fl::add_timeout(0.5, tick_cb);
+ return Fl::run();
+} //END
+
+//
+// End of "$Id$".
+//