summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/clock.vala61
-rw-r--r--src/ui/curses-ui.vala68
-rw-r--r--src/ui/dialog.vala36
-rw-r--r--src/ui/logo.vala30
-rw-r--r--src/ui/message_box.vala45
-rw-r--r--src/ui/numbers.vala98
-rw-r--r--src/ui/status.vala24
7 files changed, 0 insertions, 362 deletions
diff --git a/src/ui/clock.vala b/src/ui/clock.vala
deleted file mode 100644
index e38ad9c..0000000
--- a/src/ui/clock.vala
+++ /dev/null
@@ -1,61 +0,0 @@
-using Curses;
-
-public class ClockWindow {
- AsciiNumbers ascii;
- Window win;
-
- public ClockWindow() {
- ascii = new AsciiNumbers();
- win = new Window(6, 18, 1, COLS-2-18);
- win.bkgdset(COLOR_PAIR(0) | Attribute.BOLD);
-
- win.clrtobot();
- win.box(0, 0);
-
- win.refresh();
- }
-
- public void update() {
- string[] x;
- var now = new DateTime.now_local();
-
- x = ascii.get('0' + (char) (now.get_hour() / 10));
- win.mvaddstr(1,1, x[0]);
- win.mvaddstr(2,1, x[1]);
- win.mvaddstr(3,1, x[2]);
-
- x = ascii.get('0' + (char) (now.get_hour() % 10));
- win.mvaddstr(1,4, x[0]);
- win.mvaddstr(2,4, x[1]);
- win.mvaddstr(3,4, x[2]);
-
- x = ascii.get(':');
- win.mvaddstr(1,7, x[0]);
- win.mvaddstr(2,7, x[1]);
- win.mvaddstr(3,7, x[2]);
-
- x = ascii.get('0' + (char) (now.get_minute() / 10));
- win.mvaddstr(1,10, x[0]);
- win.mvaddstr(2,10, x[1]);
- win.mvaddstr(3,10, x[2]);
-
- x = ascii.get('0' + (char) (now.get_minute() % 10));
- win.mvaddstr(1,13, x[0]);
- win.mvaddstr(2,13, x[1]);
- win.mvaddstr(3,13, x[2]);
-
-
- win.clrtobot();
- win.box(0, 0);
-
- win.mvaddstr(5,4, now.format("%Y-%m-%d"));
-
- win.refresh();
- }
-
- public void redraw() {
- win.touchwin();
- win.refresh();
- }
-
-}
diff --git a/src/ui/curses-ui.vala b/src/ui/curses-ui.vala
deleted file mode 100644
index 6676eea..0000000
--- a/src/ui/curses-ui.vala
+++ /dev/null
@@ -1,68 +0,0 @@
-public class CursesUI {
- MessageBox messages;
- Dialog dialog;
- Logo banner;
- ClockWindow clkwin;
- StatusPanel statuswin;
-
- public CursesUI() {
- /* unicode support */
- Intl.setlocale(LocaleCategory.CTYPE, "");
-
- /* initialize curses */
- Curses.initscr();
-
- /* disable cursor */
- Curses.curs_set(0);
-
- /* initialize color mode and define color pairs */
- Curses.start_color();
- Curses.init_pair(0, Curses.Color.WHITE, Curses.Color.BLACK);
- Curses.init_pair(1, Curses.Color.GREEN, Curses.Color.BLACK);
- Curses.init_pair(2, Curses.Color.WHITE, Curses.Color.RED);
-
- /* initialize widgets */
- banner = new Logo();
- statuswin = new StatusPanel();
- messages = new MessageBox();
- clkwin = new ClockWindow();
-
- clkwin.update();
-
- Timeout.add_seconds(10, update_time);
- }
-
- ~CursesUI() {
- exit();
- }
-
- public void exit() {
- /* Reset the terminal mode */
- Curses.endwin();
- }
-
- bool update_time() {
- clkwin.update();
- return true;
- }
-
- public void status(string message) {
- statuswin.set(message);
- }
-
- public void log(string message) {
- messages.add(message);
- }
-
- public void dialog_open(string title, string message) {
- dialog = new Dialog(message, title);
- }
-
- public void dialog_close() {
- dialog = null;
- messages.redraw();
- banner.redraw();
- clkwin.redraw();
- statuswin.redraw();
- }
-}
diff --git a/src/ui/dialog.vala b/src/ui/dialog.vala
deleted file mode 100644
index 29782e5..0000000
--- a/src/ui/dialog.vala
+++ /dev/null
@@ -1,36 +0,0 @@
-using Curses;
-
-public class Dialog {
- Window win;
- Window subwin;
-
- public Dialog(string message, string title = "KtT Shopsystem Error", int h=16, int w=60)
- requires (title.length <= w-4)
- {
- int y = LINES/2-h/2;
- int x = COLS/2-w/2;
-
- int title_x = (w-title.length)/2;
-
- win = new Window(h, w, y, x);
-
- /* make the dialog white on red */
- win.bkgdset(COLOR_PAIR(2) | Attribute.BOLD);
- win.clrtobot();
-
- /* message subwindow */
- subwin = win.derwin(h-4, w-4, 2, 2);
- subwin.clrtobot();
- subwin.printw(message);
- subwin.refresh();
-
- /* dialog title */
- win.box(0,0);
- win.mvaddstr(0, title_x, title);
- win.mvaddch(0, title_x-2, Acs.RTEE);
- win.mvaddch(0, title_x-1, ' ');
- win.mvaddch(0, title_x+title.length, ' ');
- win.mvaddch(0, title_x+title.length+1, Acs.LTEE);
- win.refresh();
- }
-}
diff --git a/src/ui/logo.vala b/src/ui/logo.vala
deleted file mode 100644
index 5a94422..0000000
--- a/src/ui/logo.vala
+++ /dev/null
@@ -1,30 +0,0 @@
-using Curses;
-
-public class Logo {
- Window win;
-
- public Logo() {
- win = new Window(8, COLS - 2, 0, 1);
- win.bkgdset(COLOR_PAIR(1) | Attribute.BOLD);
-
- win.addstr("\n");
- win.addstr(" _ ___ _____ ____ _ \n");
- win.addstr(" | |/ / ||_ _| / ___|| |__ ___ _ __ \n");
- win.addstr(" | ' /| __|| | \\___ \\| '_ \\ / _ \\| '_ \\ \n");
- win.addstr(" | . \\| |_ | | ___) | | | | (_) | |_) )\n");
- win.addstr(" |_|\\_\\\\__||_| |____/|_| |_|\\___/| .__/ \n");
- win.addstr(" |_| \n");
-
- win.clrtobot();
-
- win.box(0, 0);
-
- win.refresh();
- }
-
- public void redraw() {
- win.touchwin();
- win.refresh();
- }
-
-}
diff --git a/src/ui/message_box.vala b/src/ui/message_box.vala
deleted file mode 100644
index 4f9c3f6..0000000
--- a/src/ui/message_box.vala
+++ /dev/null
@@ -1,45 +0,0 @@
-using Curses;
-
-public class MessageBox {
- Window win;
- Window subwin;
- DateTime last;
-
- public MessageBox() {
- win = new Window(LINES-9, COLS - 2, 8, 1);
- win.bkgdset(COLOR_PAIR(0));
-
- win.clrtobot();
- win.box(0, 0);
- win.refresh();
-
- subwin = win.derwin(LINES-11, COLS-4, 1, 1);
- subwin.scrollok(true);
- subwin.clrtobot();
- subwin.refresh();
-
- last = new DateTime.from_unix_utc(0);
- }
-
- public void add(string msg) {
- var now = new DateTime.now_local();
-
- if(now.get_day_of_year() != last.get_day_of_year() || now.get_year() != last.get_year()) {
- string curtime = now.format("%Y-%m-%d");
- subwin.addstr("\nDate Changed: " + curtime);
- }
-
- last = now;
-
- string curtime = now.format("%H:%M:%S");
- subwin.addstr("\n[" + curtime + "] " + msg);
- subwin.refresh();
- }
-
- public void redraw() {
- win.touchwin();
- win.refresh();
- subwin.touchwin();
- subwin.refresh();
- }
-}
diff --git a/src/ui/numbers.vala b/src/ui/numbers.vala
deleted file mode 100644
index 8ee00d5..0000000
--- a/src/ui/numbers.vala
+++ /dev/null
@@ -1,98 +0,0 @@
-public class AsciiNumbers {
-
- public string[] zero = {
- " _ ",
- "/ \\",
- "\\_/"
- };
-
- public string[] one = {
- " ",
- " /|",
- " |"
- };
-
- public string[] two = {
- "__ ",
- " _)",
- "(__"
- };
-
- public string[] three = {
- "__ ",
- " _)",
- "__)"
- };
-
- public string[] four = {
- " ",
- "|_|",
- " |"
- };
-
- public string[] five = {
- " __",
- "|_ ",
- "__)"
- };
-
- public string[] six = {
- " _ ",
- "/_ ",
- "\\_)"
- };
-
- public string[] seven = {
- "___",
- " /",
- " / "
- };
-
- public string[] eight = {
- " _ ",
- "(_)",
- "(_)"
- };
-
- public string[] nine = {
- " _ ",
- "(_\\",
- " _/"
- };
-
- public string[] colon = {
- " ",
- " o ",
- " o "
- };
-
- public string[] get(char c) {
- switch(c) {
- case '0':
- return zero;
- case '1':
- return one;
- case '2':
- return two;
- case '3':
- return three;
- case '4':
- return four;
- case '5':
- return five;
- case '6':
- return six;
- case '7':
- return seven;
- case '8':
- return eight;
- case '9':
- return nine;
- case ':':
- return colon;
- default:
- return {};
- }
- }
-
-}
diff --git a/src/ui/status.vala b/src/ui/status.vala
deleted file mode 100644
index db33820..0000000
--- a/src/ui/status.vala
+++ /dev/null
@@ -1,24 +0,0 @@
-using Curses;
-
-public class StatusPanel {
- Window win;
-
- public StatusPanel() {
- win = new Window(1, COLS - 2, LINES-1, 1);
- win.bkgdset(COLOR_PAIR(2) | Attribute.BOLD);
-
- win.clrtobot();
- win.refresh();
- }
-
- public void set(string msg) {
- win.mvaddstr(0,1, msg);
- win.clrtobot();
- win.refresh();
- }
-
- public void redraw() {
- win.touchwin();
- win.refresh();
- }
-}