diff options
author | toni <matzeton@googlemail.com> | 2014-12-07 23:27:08 +0100 |
---|---|---|
committer | toni <matzeton@googlemail.com> | 2014-12-08 02:55:07 +0100 |
commit | 94272da26e2bbb578b5f5e6b17080a0c1ce8df83 (patch) | |
tree | 4207b1df6248c51b10bdbedc2165fc4bdbcd8ee2 | |
parent | a6dafdecaafdc676ee5dcad8418aabcfb5a4c5c3 (diff) | |
parent | f648453f216897f4d018cb9c38d60692b4af51ac (diff) |
Merge branch 'master' of github.com:lnslbrty/naskpass
-rw-r--r-- | ui.c | 2 | ||||
-rw-r--r-- | ui_input.c | 26 |
2 files changed, 22 insertions, 6 deletions
@@ -196,7 +196,7 @@ process_key(int key, struct input *a, WINDOW *win) int main(int argc, char **argv) { - struct input *pw_input = init_input(1,7,20,"PASSWORD",128,COLOR_PAIR(3)); + struct input *pw_input = init_input(3,7,20,"PASSWORD",128,COLOR_PAIR(3)); struct anic *heartbeat = init_anic(2,2,A_BOLD | COLOR_PAIR(3)); struct anic *a = init_anic(4,4,0); struct anic *b = init_anic(6,6,COLOR_PAIR(1)); @@ -34,6 +34,20 @@ free_input(struct input *a) } static void +print_wnd(int x, int y, size_t len, size_t addwidth) +{ + mvhline(y-2, x-2, 0, len+addwidth+3); + mvhline(y+2, x-2, 0, len+addwidth+3); + mvvline(y-1, x-3, 0, 3); + mvvline(y-1, x+len+addwidth+1, 0, 3); + mvaddch(y-2, x-3, ACS_ULCORNER); + mvaddch(y+2, x-3, ACS_LLCORNER); + mvaddch(y-2, x+len+addwidth+1, ACS_URCORNER); + mvaddch(y+2, x+len+addwidth+1, ACS_LRCORNER); + mvprintw(12, 1, "(%d,%d),len:%lu,addw:%lu", x, y, len, addwidth); +} + +static void print_input_text(WINDOW *win, struct input *a) { size_t start = 0; @@ -60,6 +74,7 @@ print_input(WINDOW *win, struct input *a) size_t p_len = strlen(a->prompt); attron(a->attrs); + print_wnd(a->x, a->y, 10, 2); if (win == NULL) { mvprintw(a->y, a->x, a->prompt); tmp = calloc(a->width+1, sizeof(char)); @@ -97,8 +112,7 @@ add_input(WINDOW *win, struct input *a, int key) ++a->input_len; a->cur_pos = (a->cur_pos+1 < a->width ? a->cur_pos+1 : a->cur_pos); print_input(win, a); - - mvwprintw(win, 10, 1, "w:%d,cp:%d,im:%lu,il:%lu,ip:%lu,s:%s", a->width, a->cur_pos, a->input_max, a->input_len, a->input_pos, a->input); + //mvwprintw(win, 10, 1, "w:%d,cp:%d,im:%lu,il:%lu,ip:%lu,s:%s", a->width, a->cur_pos, a->input_max, a->input_len, a->input_pos, a->input); return (UICB_OK); } @@ -112,11 +126,13 @@ del_input(WINDOW *win, struct input *a) if (a->input_pos-1 == a->input_len) { --a->input_pos; } - a->cur_pos = (a->cur_pos+1 < a->width && a->cur_pos > 0 ? a->cur_pos-1 : a->cur_pos); + if (a->cur_pos+1 < a->width && a->cur_pos > 0) { + --a->cur_pos; + } else if (a->cur_pos-1 == a->input_pos) { + --a->cur_pos; + } mvwprintw(win, a->y, a->x + a->cur_pos + strlen(a->prompt), "_"); print_input(win, a); - - mvwprintw(win, 10, 1, "w:%d,cp:%d,im:%lu,il:%lu,ip:%lu,s:%s", a->width, a->cur_pos, a->input_max, a->input_len, a->input_pos, a->input); return (UICB_OK); } |