Mercurial > hg > nnchat
comparison main.c @ 501:ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
to internally managing the screen as whole.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 01 Jun 2012 12:00:11 +0300 |
parents | cbbf502e4a70 |
children | 52da406caf54 |
comparison
equal
deleted
inserted
replaced
500:78447d70f9d3 | 501:ca88945d8eda |
---|---|
246 } | 246 } |
247 | 247 |
248 if (!optDaemon && (flags & LOG_WINDOW)) | 248 if (!optDaemon && (flags & LOG_WINDOW)) |
249 { | 249 { |
250 nn_window_t *tmp = (win != NULL) ? win : nnwin_main_window(); | 250 nn_window_t *tmp = (win != NULL) ? win : nnwin_main_window(); |
251 if (flags & LOG_STAMP) nnwin_print_buf(tmp, tmpStr); | 251 if (flags & LOG_STAMP) nnwin_print(tmp, tmpStr); |
252 nnwin_print_buf(tmp, buf); | 252 nnwin_print(tmp, buf); |
253 } | 253 } |
254 | 254 |
255 th_free(buf); | 255 th_free(buf); |
256 } | 256 } |
257 | 257 |
1343 nn_conn_t *conn = NULL; | 1343 nn_conn_t *conn = NULL; |
1344 int updateCount = 0; | 1344 int updateCount = 0; |
1345 BOOL argsOK, isError = FALSE, | 1345 BOOL argsOK, isError = FALSE, |
1346 exitProg = FALSE, | 1346 exitProg = FALSE, |
1347 colorSet = FALSE, | 1347 colorSet = FALSE, |
1348 insertMode = TRUE, | 1348 insertMode = TRUE; |
1349 firstUpdate = TRUE; | |
1350 time_t prevTime; | 1349 time_t prevTime; |
1351 char *tmpStr; | 1350 char *tmpStr; |
1352 nn_editbuf_t *editBuf = nn_editbuf_new(NN_TMPBUF_SIZE); | 1351 nn_editbuf_t *editBuf = nn_editbuf_new(NN_TMPBUF_SIZE); |
1353 nn_editbuf_t *histBuf[SET_MAX_HISTORY+2]; | 1352 nn_editbuf_t *histBuf[SET_MAX_HISTORY+2]; |
1354 int histPos = 0, histMax = 0, index; | 1353 int histPos = 0, histMax = 0, index; |
1485 // Initialize curses windowing | 1484 // Initialize curses windowing |
1486 if (!optDaemon && !nnwin_init(SET_DELAY)) | 1485 if (!optDaemon && !nnwin_init(SET_DELAY)) |
1487 goto err_exit; | 1486 goto err_exit; |
1488 | 1487 |
1489 if (cursesInit) | 1488 if (cursesInit) |
1490 nnwin_update_statusline(optUserName, optUserColor); | 1489 { |
1490 nnwin_update(TRUE, NULL, optUserName, optUserColor); | |
1491 } | |
1491 | 1492 |
1492 // Check if we have username and password | 1493 // Check if we have username and password |
1493 if (cursesInit && (optUserName == NULL || optPassword == NULL)) | 1494 if (cursesInit && (optUserName == NULL || optPassword == NULL)) |
1494 { | 1495 { |
1495 nnwin_print(editWin, "You can avoid this prompt by issuing '/save' after logging in.\n"); | 1496 optUserName = nnwin_prompt_requester("You can avoid this prompt by issuing '/save' after logging in.\nNN username: ", FALSE); |
1496 optUserName = nnwin_prompt_requester(editWin, "NN username: ", FALSE); | 1497 optPassword = nnwin_prompt_requester("NN password: ", TRUE); |
1497 optPassword = nnwin_prompt_requester(editWin, "NN password: ", TRUE); | |
1498 } | 1498 } |
1499 | 1499 |
1500 if (optUserName == NULL || optPassword == NULL) | 1500 if (optUserName == NULL || optPassword == NULL) |
1501 { | 1501 { |
1502 errorMsg("Username and/or password not specified.\n"); | 1502 errorMsg("Username and/or password not specified.\n"); |
1582 { | 1582 { |
1583 // Initialize rest of interactive UI code | 1583 // Initialize rest of interactive UI code |
1584 nn_editbuf_clear(editBuf); | 1584 nn_editbuf_clear(editBuf); |
1585 | 1585 |
1586 // First update of screen | 1586 // First update of screen |
1587 nnwin_update_editbuf(editBuf); | 1587 nnwin_update(TRUE, editBuf, optUserName, optUserColor); |
1588 nnwin_update_statusline(optUserName, optUserColor); | |
1589 | 1588 |
1590 printMsg(NULL, "%s v%s - %s\n", th_prog_name, th_prog_version, th_prog_fullname); | 1589 printMsg(NULL, "%s v%s - %s\n", th_prog_name, th_prog_version, th_prog_fullname); |
1591 printMsg(NULL, "%s\n", th_prog_author); | 1590 printMsg(NULL, "%s\n", th_prog_author); |
1592 printMsg(NULL, "%s\n", th_prog_license); | 1591 printMsg(NULL, "%s\n", th_prog_license); |
1593 } | 1592 } |
1747 #ifdef KEY_RESIZE | 1746 #ifdef KEY_RESIZE |
1748 case KEY_RESIZE: | 1747 case KEY_RESIZE: |
1749 resize_term(0, 0); | 1748 resize_term(0, 0); |
1750 erase(); | 1749 erase(); |
1751 timeout(SET_DELAY); | 1750 timeout(SET_DELAY); |
1752 | 1751 nnwin_reset(); |
1753 if (!nnwin_init_windows()) | |
1754 { | |
1755 errorMsg("Error resizing curses chatWindows\n"); | |
1756 isError = TRUE; | |
1757 } | |
1758 update = updateMain = TRUE; | 1752 update = updateMain = TRUE; |
1759 break; | 1753 break; |
1760 #endif | 1754 #endif |
1761 | 1755 |
1762 case KEY_ENTER: | 1756 case KEY_ENTER: |
1952 break; | 1946 break; |
1953 } | 1947 } |
1954 } | 1948 } |
1955 while (c != ERR && !exitProg && ++cnt < 10); | 1949 while (c != ERR && !exitProg && ++cnt < 10); |
1956 | 1950 |
1957 nnwin_update_main(updateMain); | 1951 nnwin_update(FALSE, editBuf, optUserName, optUserColor); |
1958 | |
1959 if (update || firstUpdate) | |
1960 { | |
1961 // Update edit line | |
1962 nnwin_update_statusline(optUserName, optUserColor); | |
1963 nnwin_update_editbuf(editBuf); | |
1964 firstUpdate = FALSE; // a nasty hack ... | |
1965 } | |
1966 | |
1967 } // cursesInit | 1952 } // cursesInit |
1968 | 1953 |
1969 if (++updateCount > 10) | 1954 if (++updateCount > 10) |
1970 { | 1955 { |
1971 time_t tmpTime = time(NULL); | 1956 time_t tmpTime = time(NULL); |
1981 { | 1966 { |
1982 colorSet = TRUE; | 1967 colorSet = TRUE; |
1983 nn_conn_send_msg_v(conn, optUserNameEnc, "%%2FSetFontColor%%20%%2Dcolor%%20%06X", optUserColor); | 1968 nn_conn_send_msg_v(conn, optUserNameEnc, "%%2FSetFontColor%%20%%2Dcolor%%20%06X", optUserColor); |
1984 } | 1969 } |
1985 | 1970 |
1986 nnwin_update_statusline(optUserName, optUserColor); | 1971 nnwin_update(FALSE, editBuf, optUserName, optUserColor); |
1987 nnwin_update_editbuf(editBuf); | |
1988 updateCount = 0; | 1972 updateCount = 0; |
1989 } | 1973 } |
1990 | 1974 |
1991 } | 1975 } |
1992 | 1976 |