From 232110bd16d8515fe8fff5c2e82a975ead3eadcb Mon Sep 17 00:00:00 2001 From: Bernhard Guillon Date: Wed, 14 Mar 2012 18:51:56 +0100 Subject: [PATCH] antidote: add RAD ncurses prototype --- configure.ac | 4 +- src/Makefile.am | 2 +- src/main.vala | 148 +++++++++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 125 insertions(+), 29 deletions(-) diff --git a/configure.ac b/configure.ac index dcdcff2..2a6310f 100644 --- a/configure.ac +++ b/configure.ac @@ -12,7 +12,9 @@ AM_PROG_VALAC pkg_modules="glib-2.0 >= 2.24.1 gobject-2.0 >= 2.24.1 gio-2.0 >= 2.24.1 - gee-1.0 >= 0.5" + gee-1.0 >= 0.5 + ncurses >= 0.5 +" PKG_CHECK_MODULES(ANTIDOTE, [$pkg_modules]) AC_SUBST(ANTIDOTE_CFLAGS) AC_SUBST(ANTIDOTE_LIBS) diff --git a/src/Makefile.am b/src/Makefile.am index d150d41..b61bef2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,7 +5,7 @@ bin_PROGRAMS = antidote #FIXME: make libs antidote_SOURCES = main.vala imap.vala logger.vala antidote_LDADD = $(ANTIDOTE_LIBS) -antidote_VALAFLAGS = --pkg gio-2.0 --pkg gee-1.0 +antidote_VALAFLAGS = --pkg gio-2.0 --pkg gee-1.0 --pkg curses CLEANFILES = *.h *.c *.vapi *.stamp diff --git a/src/main.vala b/src/main.vala index 25100dc..05256ef 100644 --- a/src/main.vala +++ b/src/main.vala @@ -1,5 +1,8 @@ +/* FIXME: This file is RAD and needs a lot of refactoring ;) */ using Antidote; using Gee; +using Curses; + /* message token */ struct Token { @@ -33,9 +36,9 @@ string get_intending(LinkedList stack) { return intending; } -void parse_thread(string th,IMAP imap) { +ArrayList parse_thread(string th) { string thread = th.replace("* THREAD ",""); - ArrayList list = new ArrayList (); + ArrayList list = new ArrayList (); unichar c; int index=0; LinkedList stack = new LinkedList(); @@ -62,7 +65,7 @@ void parse_thread(string th,IMAP imap) { token_struct.intending = get_intending(stack)+"-"; token_struct.token = token; list.add(token_struct); - print(get_intending(stack) + "-" + token + "\n"); + //print(get_intending(stack) + "-" + token + "\n"); //add one level stack.offer_head(' '); token=""; @@ -72,23 +75,109 @@ void parse_thread(string th,IMAP imap) { token = token + c.to_string(); } } + return list; +} + +void init_curses() { + initscr (); + noecho(); + cbreak(); + stdscr.keypad(true); + start_color (); + init_pair(1, Color.GREEN, Color.BLUE); + init_pair(2, Color.YELLOW, Color.BLACK); + init_pair(3, Color.WHITE, Color.BLUE); + bkgd(COLOR_PAIR(2)); + refresh(); +} + +void draw_menu(Window win) { + win.clear(); + win.bkgd(COLOR_PAIR(2)); + win.box(0,0); + win.attron(Attribute.BOLD); + win.mvaddstr(1, 2, "F1:"); + win.attroff(Attribute.BOLD); + win.mvaddstr(1, 6, "messages"); + win.refresh(); +} - //print the list - print(list.size.to_string()); - //for (int i = 10; i<20;i++) { - foreach (Token? t in list) { -// Token t = list.get(i); - var msgs = imap.get_headers(t.token,t.token); - Message msg; - msg = msgs.get(t.token.to_int()); -// print(@"$(t.token)\t$(t.intending) $(msg.date) \t$(msg.from) \t$(msg.subject)\n"); - print(@"$(t.token)\t$(t.intending)$(msg.subject)\n"); - //print(@"$(delim) $(t.token)\n"); +void draw_folders(Window win) { + win.clear(); + win.bkgd(COLOR_PAIR(2)); + win.box(0,0); + win.attron(Attribute.BOLD); + win.mvaddstr(1, 2, "F1:"); + win.attroff(Attribute.BOLD); + win.mvaddstr(1, 6, "messages"); + win.refresh(); +} + +void draw_header(Window win) { + win.clear(); + win.bkgd(COLOR_PAIR(2)); + win.attron(Attribute.BOLD); + win.mvaddstr(0, 1, "Antidote version 0.1"); + win.refresh(); +} + +void draw_threads(Window win,ArrayList list,IMAP imap,int start_line) { + win.clear(); + win.bkgd(COLOR_PAIR(2)); + win.box(0,0); + + //FIME:out of bounds + for (int i = start_line; i list,IMAP imap) { +// //print the list +// print(list.size.to_string()); +// for (int i = 300; i