Mercurial > hg > nnchat
comparison nnchat.c @ 385:bbd5edbf1143
Cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 29 Dec 2011 00:34:46 +0200 |
parents | 7c28f38cb6dd |
children | f45673fe6b23 |
comparison
equal
deleted
inserted
replaced
384:40b95d677f68 | 385:bbd5edbf1143 |
---|---|
534 | 534 |
535 char *errorMessages = NULL; | 535 char *errorMessages = NULL; |
536 | 536 |
537 void errorMsgV(const char *fmt, va_list ap) | 537 void errorMsgV(const char *fmt, va_list ap) |
538 { | 538 { |
539 char *tmp; | 539 char *tmp = th_strdup_vprintf(fmt, ap); |
540 | |
541 tmp = th_strdup_vprintf(fmt, ap); | |
542 | 540 |
543 printMsg(NULL, "%s", tmp); | 541 printMsg(NULL, "%s", tmp); |
544 | 542 |
545 if (errorMessages != NULL) { | 543 if (errorMessages != NULL) { |
546 char *tmp2 = th_strdup_printf("%s%s", errorMessages, tmp); | 544 char *tmp2 = th_strdup_printf("%s%s", errorMessages, tmp); |
1545 char *ptr = conn->buf; | 1543 char *ptr = conn->buf; |
1546 do { | 1544 do { |
1547 size_t bufLen = strlen(ptr) + 1; | 1545 size_t bufLen = strlen(ptr) + 1; |
1548 int result = handleProtocol(conn, ptr, bufLen); | 1546 int result = handleProtocol(conn, ptr, bufLen); |
1549 | 1547 |
1550 if (result > 0) { | 1548 if (result > 0) |
1549 { | |
1551 /* Couldn't handle the message for some reason */ | 1550 /* Couldn't handle the message for some reason */ |
1552 printMsg(currWin, "Could not handle: %s\n", ptr); | 1551 printMsg(currWin, "Could not handle: %s\n", ptr); |
1553 } else if (result < 0) { | 1552 } |
1553 else if (result < 0) | |
1554 { | |
1554 /* Fatal error, quit */ | 1555 /* Fatal error, quit */ |
1555 errorMsg("Fatal error with message: %s\n", ptr); | 1556 errorMsg("Fatal error with message: %s\n", ptr); |
1556 isError = TRUE; | 1557 isError = TRUE; |
1557 } | 1558 } |
1558 | 1559 |
1647 case KEY_RESIZE: | 1648 case KEY_RESIZE: |
1648 resize_term(0, 0); | 1649 resize_term(0, 0); |
1649 erase(); | 1650 erase(); |
1650 timeout(SET_DELAY); | 1651 timeout(SET_DELAY); |
1651 | 1652 |
1652 if (!initializeWindows()) { | 1653 if (!initializeWindows()) |
1654 { | |
1653 errorMsg("Error resizing curses chatWindows\n"); | 1655 errorMsg("Error resizing curses chatWindows\n"); |
1654 isError = TRUE; | 1656 isError = TRUE; |
1655 } | 1657 } |
1656 update = updateMain = TRUE; | 1658 update = updateMain = TRUE; |
1657 break; | 1659 break; |
1677 nn_editbuf_insert(editBuf, editBuf->len, 0); | 1679 nn_editbuf_insert(editBuf, editBuf->len, 0); |
1678 result = handleUserInput(conn, editBuf->data, editBuf->len); | 1680 result = handleUserInput(conn, editBuf->data, editBuf->len); |
1679 | 1681 |
1680 nn_editbuf_clear(editBuf); | 1682 nn_editbuf_clear(editBuf); |
1681 | 1683 |
1682 if (result < 0) { | 1684 if (result < 0) |
1685 { | |
1683 errorMsg("Fatal error handling user input: %s\n", editBuf->data); | 1686 errorMsg("Fatal error handling user input: %s\n", editBuf->data); |
1684 isError = TRUE; | 1687 isError = TRUE; |
1685 } else { | 1688 } else { |
1686 /* Update time value of last sent message for unidle timeouts */ | 1689 /* Update time value of last sent message for unidle timeouts */ |
1687 prevTime = time(NULL); | 1690 prevTime = time(NULL); |
1777 break; | 1780 break; |
1778 #endif | 1781 #endif |
1779 | 1782 |
1780 case 0x03: /* ^C = quit */ | 1783 case 0x03: /* ^C = quit */ |
1781 case KEY_F(9): /* F9 = Quit */ | 1784 case KEY_F(9): /* F9 = Quit */ |
1782 printMsg(currWin, "Quitting per user request.\n"); | 1785 printMsg(currWin, "Quitting per user request (%d/0x%x).\n", c, c); |
1783 exitProg = TRUE; | 1786 exitProg = TRUE; |
1784 break; | 1787 break; |
1785 | 1788 |
1786 case 0x09: /* Tab = complete username */ | 1789 case 0x09: /* Tab = complete username */ |
1787 performTabCompletion(editBuf); | 1790 performTabCompletion(editBuf); |