diff ui.h @ 513:ef5a2aa8382b

Refactor input handling.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 05 Jun 2012 22:16:42 +0300
parents 942eea564b15
children 44f67ec5e945
line wrap: on
line diff
--- a/ui.h	Tue Jun 05 19:56:57 2012 +0300
+++ b/ui.h	Tue Jun 05 22:16:42 2012 +0300
@@ -7,9 +7,13 @@
 #define LIBNNUI_H
 
 #ifdef __WIN32
+#define SET_DELAY          (0)
 // Undefine because both windows.h and curses.h #define it
 #undef MOUSE_MOVED
+#else
+#define SET_DELAY          (5)
 #endif
+
 #ifdef HAVE_NCURSES_H
 #include <ncurses.h>
 #else
@@ -17,7 +21,7 @@
 #endif
 #include "th_types.h"
 #include "th_string.h"
-
+#include "network.h"
 
 #define SET_MAX_WINDOWS   (32)
 #define NN_BACKBUF_LEN    (512)       // Backbuffer size (in lines)
@@ -43,6 +47,15 @@
 } nn_window_t;
 
 
+typedef struct
+{
+    time_t prevKeepAlive;
+    BOOL insertMode, exitProg, isError, update, mask, done;
+    nn_conn_t *conn;
+    void (*debugMsg)(const char *fmt, ...);
+} nn_editstate_t;
+
+
 extern nn_window_t *currWin;
 extern BOOL cursesInit;
 extern int scrHeight, scrWidth;
@@ -51,7 +64,7 @@
 void           nnwin_shutdown();
 void           nnwin_reset(void);
 
-void           nnwin_update(BOOL force, nn_editbuf_t *ebuf, char *optUserName, int optUserColor);
+void           nnwin_update(BOOL force, BOOL mask, nn_editbuf_t *ebuf, char *optUserName, int optUserColor);
 
 nn_window_t *  nnwin_main_window();
 nn_window_t *  nnwin_get(const int index);
@@ -62,6 +75,12 @@
 void           nnwin_close(nn_window_t *win);
 
 int            nnwin_print(nn_window_t *win, const char *fmt);
-char *         nnwin_prompt_requester(const char *info, BOOL allowEmpty);
+
+void nnwin_input_process(nn_editbuf_t *editBuf, nn_editstate_t *editState,
+    BOOL (*callback)(int, nn_editbuf_t *, nn_editstate_t *));
+
+char *         nnwin_prompt_requester(BOOL allowEmpty, nn_editstate_t *,
+    BOOL (*callback)(int, nn_editbuf_t *, nn_editstate_t *),
+    void (*update)(nn_editbuf_t *, nn_editstate_t *));
 
 #endif