Mercurial > hg > nnchat
changeset 297:d34910f1b1e1
Print messages about user leaving or joining the chat in the specific buffer, too.
Also, disable unhandled key warnings unless debug mode has been enabled.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 11 Jun 2011 03:56:01 +0300 |
parents | 786205414e34 |
children | 0119bcc15f15 |
files | nnchat.c |
diffstat | 1 files changed, 16 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/nnchat.c Sat Jun 11 03:55:22 2011 +0300 +++ b/nnchat.c Sat Jun 11 03:56:01 2011 +0300 @@ -693,6 +693,7 @@ int handleAddUser(nn_conn_t *conn, const char *str) { char *p, *s = strstr(str, "</ADD_USER>"); + nn_window_t *win; (void) conn; @@ -702,9 +703,13 @@ p = nn_dbldecode_str(str); if (!p) return -1; + win = nn_find_window(p); nn_userhash_insert(nnUsers, nn_username_encode(p)); printMsg(NULL, "! ½3½%s½0½ ½2½ADDED.½0½\n", p); + if (win != NULL) + printMsg(win, "! ½3½%s½0½ ½2½joined the chat.½0½\n", p); + th_free(p); return 0; } @@ -713,6 +718,7 @@ int handleDeleteUser(nn_conn_t *conn, const char *str) { char *p, *s = strstr(str, "</DELETE_USER>"); + nn_window_t *win; (void) conn; @@ -722,9 +728,13 @@ p = nn_dbldecode_str(str); if (!p) return -1; + win = nn_find_window(p); nn_userhash_delete(nnUsers, nn_username_encode(p)); printMsg(NULL, "! ½3½%s½0½ ½1½DELETED.½0½\n", p); + if (win != NULL) + printMsg(win, "! ½3½%s½0½ ½1½left the chat.½0½\n", p); + th_free(p); return 0; } @@ -1497,7 +1507,8 @@ case 'd': c = 0x204; break; case 'c': c = 0x206; break; default: - printMsg(currWin, "Unhandled ESC-O key sequence 0x%02x\n", c); + if (optDebug) + printMsg(currWin, "Unhandled ESC-O key sequence 0x%02x\n", c); break; } } else @@ -1522,7 +1533,8 @@ case 0x38: c = KEY_END; break; default: - printMsg(currWin, "Unhandled ESC-[*~ key sequence 0x%02x\n", c); + if (optDebug) + printMsg(currWin, "Unhandled ESC-[*~ key sequence 0x%02x\n", c); c = ERR; break; } @@ -1540,7 +1552,8 @@ c = ERR; } else { - printMsg(currWin, "Unhandled ESC key sequence 0x%02x\n", c); + if (optDebug) + printMsg(currWin, "Unhandled ESC key sequence 0x%02x\n", c); continue; } }