aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c2
-rw-r--r--src/ui_elements.c32
-rw-r--r--src/ui_elements.h3
-rw-r--r--src/ui_txtwindow.c5
-rw-r--r--src/ui_txtwindow.h2
5 files changed, 28 insertions, 16 deletions
diff --git a/src/main.c b/src/main.c
index 523422f..3bdd096 100644
--- a/src/main.c
+++ b/src/main.c
@@ -74,7 +74,7 @@ run_cryptcreate(char *pass, char *crypt_cmd)
char *cmd;
if (crypt_cmd == NULL || pass == NULL) return (-1);
- asprintf(&cmd, "echo '%s' | %s >/devnull 2>/dev/null", pass, crypt_cmd);
+ asprintf(&cmd, "echo '%s' | %s >/dev/null 2>/dev/null", pass, crypt_cmd);
retval = system(cmd);
free(cmd);
return (retval);
diff --git a/src/ui_elements.c b/src/ui_elements.c
index f072d45..aa60573 100644
--- a/src/ui_elements.c
+++ b/src/ui_elements.c
@@ -59,6 +59,21 @@ infownd_update(WINDOW *win, struct txtwindow *tw, bool ui_timeout)
return DOUI_OK;
}
+void
+show_info_wnd(struct txtwindow *wnd, char *title, char *text, chtype fore, chtype back, bool activate, bool blink)
+{
+ ui_thrd_suspend();
+ set_txtwindow_color(wnd, fore, back);
+ set_txtwindow_title(wnd, title);
+ set_txtwindow_text(wnd, text);
+ if (activate)
+ set_txtwindow_active(wnd, true);
+ if (blink)
+ set_txtwindow_blink(wnd, true);
+ ui_thrd_resume();
+ ui_thrd_force_update();
+}
+
static int
passwd_input_cb(WINDOW *wnd, void *data, int key)
{
@@ -66,7 +81,6 @@ passwd_input_cb(WINDOW *wnd, void *data, int key)
char ipc_buf[IPC_MQSIZ+1];
memset(ipc_buf, '\0', IPC_MQSIZ+1);
-// wtimeout(stdscr, -1);
switch (key) {
case UIKEY_ENTER:
ui_ipc_msgsend(MQ_PW, a->input);
@@ -77,24 +91,13 @@ passwd_input_cb(WINDOW *wnd, void *data, int key)
ui_thrd_resume();
ui_ipc_msgrecv(MQ_IF, ipc_buf);
-
- ui_thrd_suspend();
- set_txtwindow_color(infownd, COLOR_PAIR(5), COLOR_PAIR(5));
- set_txtwindow_title(infownd, "BUSY");
- set_txtwindow_text(infownd, ipc_buf);
- set_txtwindow_active(infownd, true);
- ui_thrd_resume();
- ui_thrd_force_update();
+ show_info_wnd(infownd, "BUSY", ipc_buf, COLOR_PAIR(5), COLOR_PAIR(5), true, false);
sleep(2);
if (ui_ipc_msgcount(MQ_IF) > 0) {
ui_ipc_msgrecv(MQ_IF, ipc_buf);
- ui_thrd_suspend();
- set_txtwindow_color(infownd, COLOR_PAIR(4), COLOR_PAIR(4) | A_BOLD);
- set_txtwindow_title(infownd, "ERROR");
- set_txtwindow_text(infownd, ipc_buf);
- ui_thrd_resume();
+ show_info_wnd(infownd, "ERROR", ipc_buf, COLOR_PAIR(4), COLOR_PAIR(4) | A_BOLD, false, true);
while (wgetch(stdscr) != '\n') { };
}
@@ -130,7 +133,6 @@ passwd_input_cb(WINDOW *wnd, void *data, int key)
default:
add_input(wnd, a, key);
}
-// wtimeout(stdscr, 1000);
refresh();
return DOUI_OK;
}
diff --git a/src/ui_elements.h b/src/ui_elements.h
index 0cf8826..a4ee287 100644
--- a/src/ui_elements.h
+++ b/src/ui_elements.h
@@ -5,6 +5,9 @@
void
+show_info_wnd(struct txtwindow *wnd, char *title, char *text, chtype fore, chtype back, bool activate, bool blink);
+
+void
init_ui_elements(WINDOW *wnd_main, unsigned int max_x, unsigned int max_y);
void
diff --git a/src/ui_txtwindow.c b/src/ui_txtwindow.c
index 90d152d..736fde4 100644
--- a/src/ui_txtwindow.c
+++ b/src/ui_txtwindow.c
@@ -16,6 +16,7 @@ init_txtwindow(unsigned int x, unsigned int y, unsigned int width, unsigned int
a->active = false;
a->title_len = INITIAL_TITLE_LEN;
a->title = calloc(a->title_len+1, sizeof(char));
+ a->title_blink = false;
a->text = NULL;
a->attrs = 0;
a->text_attrs = 0;
@@ -78,7 +79,11 @@ print_wnd(struct txtwindow *a)
/* print window title */
attroff(a->attrs);
attron(a->text_attrs);
+ if (a->title_blink)
+ attron(A_BLINK);
mvprintw(y-2, x+(w/2)-((a->title_len+4)/2), "[ %s ]", a->title);
+ if (a->title_blink)
+ attroff(A_BLINK);
/* print windows text */
i = -1;
if (a->text) {
diff --git a/src/ui_txtwindow.h b/src/ui_txtwindow.h
index 1e1bc3f..5ebbd65 100644
--- a/src/ui_txtwindow.h
+++ b/src/ui_txtwindow.h
@@ -8,6 +8,7 @@
#define INITIAL_TITLE_LEN 32
#define set_txtwindow_active(wnd, activate) wnd->active = activate;
+#define set_txtwindow_blink(wnd, blink) wnd->title_blink = blink;
struct txtwindow {
unsigned int y;
@@ -16,6 +17,7 @@ struct txtwindow {
unsigned int height;
bool active;
char *title;
+ bool title_blink;
size_t title_len;
char **text;
int (*window_func)(WINDOW *, struct txtwindow *, bool);