summaryrefslogtreecommitdiffstats
path: root/src/intrfn.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2012-01-27 08:42:14 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2012-01-27 08:42:14 +0100
commitd256adb14719ae0b31890da4bcad312021882022 (patch)
tree9f6e3f91480b32beaf7022b32bc9842a7be5de90 /src/intrfn.c
parent9998392d2127737982e10c01a515649328329196 (diff)
move ask_int_ncurses() and ask_string_ncurses() to src/intrfn.c
add a minimalist find in file listing
Diffstat (limited to 'src/intrfn.c')
-rw-r--r--src/intrfn.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/intrfn.c b/src/intrfn.c
index 365d9de..e5a2018 100644
--- a/src/intrfn.c
+++ b/src/intrfn.c
@@ -1426,6 +1426,61 @@ void display_message(const char*msg)
#endif
}
+uint64_t ask_int_ncurses(const char *string)
+{
+ WINDOW *local_win;
+ int startx, starty, width, height;
+ uint64_t min_size=0;
+ char response[128];
+ height = 3;
+ width = 40;
+ starty = (LINES - height) / 2; /* Calculating for a center placement */
+ startx = (COLS - width) / 2; /* of the window */
+
+ local_win = newwin(height, width, starty, startx);
+ keypad(local_win, TRUE); /* Need it to get arrow key */
+ box(local_win, 0 , 0); /* 0, 0 gives default characters
+ * for the vertical and horizontal
+ * lines */
+ wmove(local_win,1,1);
+ waddstr(local_win, string);
+ wrefresh(local_win); /* Show that box */
+ if (get_string(local_win, response, 16, NULL) > 0)
+ {
+ min_size = strtoull(response, NULL, 10);
+ }
+ wborder(local_win, ' ', ' ', ' ',' ',' ',' ',' ',' ');
+ wrefresh(local_win);
+ delwin(local_win);
+ return min_size;
+}
+
+const char *ask_string_ncurses(const char *string)
+{
+ WINDOW *local_win;
+ int startx, starty, width, height;
+ static char response[128];
+ height = 3;
+ width = 60;
+ starty = (LINES - height) / 2; /* Calculating for a center placement */
+ startx = (COLS - width) / 2; /* of the window */
+
+ local_win = newwin(height, width, starty, startx);
+ keypad(local_win, TRUE); /* Need it to get arrow key */
+ box(local_win, 0 , 0); /* 0, 0 gives default characters
+ * for the vertical and horizontal
+ * lines */
+ wmove(local_win,1,1);
+ waddstr(local_win, string);
+ wrefresh(local_win); /* Show that box */
+ get_string(local_win, response, 40, NULL);
+ wborder(local_win, ' ', ' ', ' ',' ',' ',' ',' ',' ');
+ wrefresh(local_win);
+ delwin(local_win);
+ return &response[0];
+}
+
+
#else
#include "log.h"
#include "intrfn.h"