about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-04-24 01:39:23 +0100
committerJames Booth <boothj5@gmail.com>2012-04-24 01:39:23 +0100
commit1b7d9e9e26e63afc660d7f8f8827be637f0655a4 (patch)
tree4db3d1b78cd2457aca7c541a25257da04f08a529
parentb3ae1a7d12bdcffc50701db1e1886c1016042d4b (diff)
downloadprofani-tty-1b7d9e9e26e63afc660d7f8f8827be637f0655a4.tar.gz
Added flash notification and option
-rw-r--r--command.c20
-rw-r--r--status_bar.c11
-rw-r--r--windows.c1
-rw-r--r--windows.h1
4 files changed, 33 insertions, 0 deletions
diff --git a/command.c b/command.c
index 3b80732f..caa6a11d 100644
--- a/command.c
+++ b/command.c
@@ -39,6 +39,7 @@ static int _cmd_connect(const char * const inp);
 static int _cmd_msg(const char * const inp);
 static int _cmd_close(const char * const inp);
 static int _cmd_set_beep(const char * const inp);
+static int _cmd_set_flash(const char * const inp);
 static int _cmd_default(const char * const inp);
 
 int process_input(char *inp)
@@ -87,6 +88,8 @@ static int _handle_command(const char * const command, const char * const inp)
         result = _cmd_connect(inp);
     } else if (strcmp(command, "/beep") == 0) {
         result = _cmd_set_beep(inp);
+    } else if (strcmp(command, "/flash") == 0) {
+        result = _cmd_set_flash(inp);
     } else {
         result = _cmd_default(inp);
     }
@@ -210,8 +213,10 @@ static int _cmd_close(const char * const inp)
 static int _cmd_set_beep(const char * const inp)
 {
     if (strcmp(inp, "/beep on") == 0) {
+        cons_show("Sound enabled.");
         win_set_beep(TRUE);
     } else if (strcmp(inp, "/beep off") == 0) {
+        cons_show("Sound disabled.");
         win_set_beep(FALSE);
     } else {
         cons_show("Usage: /beep <on/off>");
@@ -220,6 +225,21 @@ static int _cmd_set_beep(const char * const inp)
     return TRUE;
 }
 
+static int _cmd_set_flash(const char * const inp)
+{
+    if (strcmp(inp, "/flash on") == 0) {
+        cons_show("Screen flash enabled.");
+        status_bar_set_flash(TRUE);
+    } else if (strcmp(inp, "/flash off") == 0) {
+        cons_show("Screen flash disabled.");
+        status_bar_set_flash(FALSE);
+    } else {
+        cons_show("Usage: /flash <on/off>");
+    }        
+
+    return TRUE;
+}
+
 static int _cmd_default(const char * const inp)
 {
     if (win_in_chat()) {
diff --git a/status_bar.c b/status_bar.c
index bbdb3b9f..2101f8b0 100644
--- a/status_bar.c
+++ b/status_bar.c
@@ -35,6 +35,9 @@ static int is_new[9];
 static int dirty;
 static char curr_time[80];
 
+// allow flash?
+static int do_flash = FALSE;
+
 static void _status_bar_update_time(void);
 
 void create_status_bar(void)
@@ -158,9 +161,17 @@ void status_bar_new(const int win)
     wattroff(status_bar, COLOR_PAIR(3));
     wattroff(status_bar, A_BLINK);
 
+    if (do_flash == TRUE)
+        flash();
+
     dirty = TRUE;
 }
 
+void status_bar_set_flash(int val)
+{
+    do_flash = val;
+}
+
 void status_bar_get_password(void)
 {
     status_bar_print_message("Enter password:");
diff --git a/windows.c b/windows.c
index 9d9b832e..6b3355c4 100644
--- a/windows.c
+++ b/windows.c
@@ -274,6 +274,7 @@ void cons_help(void)
     cons_show("/who                 : Find out who is online.");
     cons_show("/ros                 : List all contacts.");
     cons_show("/beep <on/off>       : Enable/disable sound notification");
+    cons_show("/flash <on/off>      : Enable/disable screen flash notification");
     cons_show("/close               : Close a chat window.");
     cons_show("/quit                : Quit Profanity.");
     cons_show("");
diff --git a/windows.h b/windows.h
index 636997a7..ee051783 100644
--- a/windows.h
+++ b/windows.h
@@ -91,6 +91,7 @@ void status_bar_inactive(const int win);
 void status_bar_active(const int win);
 void status_bar_new(const int win);
 void status_bar_update_time(void);
+void status_bar_set_flash(int val);
 
 // input window actions
 void inp_get_char(int *ch, char *input, int *size);