Mercurial > hg > nnchat
annotate ui.c @ 508:f71c59cbc5a7
Remove useless check from nnwin_putch().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 03 Jun 2012 06:32:18 +0300 |
parents | e644d373afb9 |
children | ef5a2aa8382b |
rev | line source |
---|---|
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 * NNChat - Custom chat client for NewbieNudes.com chatrooms |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * Written by Matti 'ccr' Hämäläinen |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 * (C) Copyright 2008-2012 Tecnic Software productions (TNSP) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 */ |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 #include "util.h" |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 #include "ui.h" |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
9 #define STATUS_YPOS 0 |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
10 |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 nn_window_t *chatWindows[SET_MAX_WINDOWS], |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 *currWin = NULL; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 BOOL cursesInit = FALSE; |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
15 int cursorVisible = ERR, |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
16 scrWidth, scrHeight; |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 |
507 | 19 static void nn_line_free(void *ptr) |
20 { | |
21 nn_line_t *line = (nn_line_t *) ptr; | |
22 if (line != NULL) | |
23 { | |
24 th_free(line->buf); | |
25 th_free(line); | |
26 } | |
27 } | |
28 | |
29 | |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 static nn_window_t *nn_window_new(const char *id) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 nn_window_t *res = th_calloc(1, sizeof(nn_window_t)); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 if (res == NULL) return NULL; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 |
507 | 36 res->data = th_ringbuf_new(NN_BACKBUF_LEN, nn_line_free); |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 if (res->data == NULL) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 th_free(res); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 return NULL; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
43 res->id = th_strdup(id); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 return res; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 static void nn_window_free(nn_window_t *win) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 if (win != NULL) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 th_ringbuf_free(win->data); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 th_free(win->id); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 th_free(win); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
60 nn_window_t *nnwin_main_window() |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
62 return chatWindows[0]; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
64 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 nn_window_t *nnwin_get(const int index) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
67 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 if (index >= 1 && index <= SET_MAX_WINDOWS) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 return chatWindows[index - 1]; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 else |
495 | 71 return NULL; |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
73 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
74 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 BOOL nnwin_init(int delay) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 { |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
77 // Sanity check the terminal size |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
78 if (LINES < 0 || LINES > 1000) LINES = 24; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 if (COLS < 0 || COLS > 1000) COLS = 80; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
80 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
81 // Initialize (n)curses library and terminal settings |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
82 initscr(); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
83 raw(); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
84 keypad(stdscr, TRUE); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 noecho(); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 meta(stdscr, TRUE); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
87 timeout(delay); |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
88 scrollok(stdscr, FALSE); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
89 cursorVisible = curs_set(1); |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
90 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
91 if (has_colors()) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
92 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
93 start_color(); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
94 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
95 init_pair( 1, COLOR_RED, COLOR_BLACK); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
96 init_pair( 2, COLOR_GREEN, COLOR_BLACK); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
97 init_pair( 3, COLOR_YELLOW, COLOR_BLACK); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
98 init_pair( 4, COLOR_BLUE, COLOR_BLACK); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 init_pair( 5, COLOR_MAGENTA, COLOR_BLACK); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
100 init_pair( 6, COLOR_CYAN, COLOR_BLACK); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
101 init_pair( 7, COLOR_WHITE, COLOR_BLACK); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
102 init_pair( 8, COLOR_BLACK, COLOR_BLACK); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
103 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
104 init_pair(10, COLOR_BLACK, COLOR_RED); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 init_pair(11, COLOR_WHITE, COLOR_RED); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
106 init_pair(12, COLOR_GREEN, COLOR_RED); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
107 init_pair(13, COLOR_YELLOW, COLOR_RED); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
108 init_pair(14, COLOR_BLUE, COLOR_RED); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 init_pair(15, COLOR_MAGENTA, COLOR_RED); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
110 init_pair(16, COLOR_CYAN, COLOR_RED); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
111 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
112 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
113 cursesInit = TRUE; |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
114 nnwin_reset(); |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
115 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
116 #ifdef PDCURSES |
495 | 117 PDC_set_title("NNChat v" NN_VERSION); |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
118 #endif |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
119 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
120 memset(chatWindows, 0, sizeof(chatWindows)); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
121 chatWindows[0] = nn_window_new(NULL); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
122 currWin = chatWindows[0]; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
123 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
124 return TRUE; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
125 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
126 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
127 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
128 void nnwin_shutdown() |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
129 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
130 int i; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
131 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
132 for (i = 0; i < SET_MAX_WINDOWS; i++) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
133 nn_window_free(chatWindows[i]); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
134 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
135 if (cursesInit) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
136 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
137 if (cursorVisible != ERR) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
138 curs_set(cursorVisible); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
139 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
140 endwin(); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
141 THMSG(1, "NCurses deinitialized.\n"); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
142 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
143 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
144 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
145 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
146 void nnwin_reset(void) |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
147 { |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
148 getmaxyx(stdscr, scrHeight, scrWidth); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
149 } |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
150 |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
151 |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
152 nn_window_t *nnwin_find(const char *id) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
153 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
154 int i; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
155 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
156 for (i = 0; i < SET_MAX_WINDOWS; i++) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
157 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
158 if (chatWindows[i] != NULL && |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
159 chatWindows[i]->id != NULL && |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
160 th_strcasecmp(id, chatWindows[i]->id) == 0) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
161 return chatWindows[i]; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
162 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
163 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
164 return NULL; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
165 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
166 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
167 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
168 BOOL nnwin_open(const char *name, BOOL curwin) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
169 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
170 int i; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
171 nn_window_t *res; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
172 if (name == NULL) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
173 return FALSE; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
174 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
175 if ((res = nn_window_new(name)) == NULL) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
176 return FALSE; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
177 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
178 for (i = 1; i < SET_MAX_WINDOWS; i++) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
179 if (chatWindows[i] == NULL) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
180 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
181 res->num = i; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
182 chatWindows[i] = res; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
183 if (curwin) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
184 currWin = res; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
185 return TRUE; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
186 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
187 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
188 return FALSE; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
189 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
190 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
191 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
192 void nnwin_close(nn_window_t *win) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
193 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
194 int i; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
195 if (win == NULL) return; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
196 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
197 for (i = 1; i < SET_MAX_WINDOWS; i++) |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
198 { |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
199 if (chatWindows[i] == win) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
200 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
201 chatWindows[i] = NULL; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
202 nn_window_free(win); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
203 return; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
204 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
205 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
206 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
207 |
504
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
208 |
503
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
209 static BOOL nnwin_get_color(char const **s, int *col) |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
210 { |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
211 int val = 0; |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
212 |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
213 while (**s >= '0' && **s <= '9') |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
214 { |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
215 val *= 10; |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
216 val += (**s - '0'); |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
217 (*s)++; |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
218 } |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
219 if (**s != '½') |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
220 return FALSE; |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
221 |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
222 if (val < 9) |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
223 *col = A_DIM | COLOR_PAIR(val); |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
224 else if (val < 30) |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
225 *col = A_BOLD | COLOR_PAIR(val - 9); |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
226 |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
227 return TRUE; |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
228 } |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
229 |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
230 |
504
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
231 #define QPUTCH(ch) nnwin_putch(&(win->line->buf), &(win->line->bufsize), &(win->line->len), col, ch) |
508
f71c59cbc5a7
Remove useless check from nnwin_putch().
Matti Hamalainen <ccr@tnsp.org>
parents:
507
diff
changeset
|
232 |
504
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
233 static BOOL nnwin_putch(int **buf, size_t *bufsize, size_t *len, int color, char ch) |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
234 { |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
235 if (*buf == NULL || *len + 1 >= *bufsize) |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
236 { |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
237 *bufsize += TH_BUFGROW; |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
238 *buf = (int *) th_realloc(*buf, *bufsize * sizeof(int)); |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
239 if (*buf == NULL) |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
240 return FALSE; |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
241 } |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
242 |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
243 (*buf)[*len] = ((unsigned char) ch) | color; |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
244 (*len)++; |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
245 |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
246 return TRUE; |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
247 } |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
248 |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
249 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
250 int nnwin_print(nn_window_t *win, const char *fmt) |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
251 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
252 const char *s = fmt; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
253 int col = 0; |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
254 |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
255 while (*s) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
256 { |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
257 if (win->line == NULL) |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
258 { |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
259 win->line = th_calloc(1, sizeof(nn_line_t)); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
260 if (win->line == NULL) |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
261 return -15; |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
262 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
263 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
264 if (*s == '½') |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
265 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
266 s++; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
267 if (*s == '½') |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
268 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
269 QPUTCH(*s); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
270 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
271 else |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
272 { |
503
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
273 if (!nnwin_get_color(&s, &col)) |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
274 return -1; |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
275 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
276 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
277 else if (*s == '\n') |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
278 { |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
279 th_ringbuf_add(win->data, win->line); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
280 win->line = NULL; |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
281 win->dirty = TRUE; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
282 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
283 else if (*s != '\r') |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
284 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
285 QPUTCH((unsigned char) *s == 255 ? ' ' : *s); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
286 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
287 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
288 s++; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
289 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
290 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
291 return 0; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
292 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
293 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
294 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
295 char *nnwin_prompt_requester(const char *info, BOOL allowEmpty) |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
296 { |
506 | 297 char buf[512], *ptr; |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
298 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
299 echo(); |
506 | 300 wattrset(stdscr, A_NORMAL); |
301 wbkgdset(stdscr, COLOR_PAIR(0)); | |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
302 waddstr(stdscr, info); |
506 | 303 wgetnstr(stdscr, buf, sizeof(buf) - 1); |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
304 noecho(); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
305 |
506 | 306 str_trim_right(buf); |
307 ptr = str_trim_left(buf); | |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
308 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
309 if (allowEmpty || ptr[0]) |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
310 return th_strdup(ptr); |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
311 else |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
312 return NULL; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
313 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
314 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
315 |
503
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
316 static void nnwin_print_str(WINDOW *win, const char *fmt, BOOL clip) |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
317 { |
503
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
318 const char *s = fmt; |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
319 int col = 0; |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
320 while (*s) |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
321 { |
504
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
322 if (clip && getcurx(win) >= scrWidth) |
503
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
323 return; |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
324 |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
325 if (*s == '½') |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
326 { |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
327 s++; |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
328 if (*s == '½') |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
329 { |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
330 waddch(win, ((unsigned char) *s) | col); |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
331 s++; |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
332 } |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
333 else |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
334 { |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
335 if (!nnwin_get_color(&s, &col)) |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
336 return; |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
337 } |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
338 } |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
339 else |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
340 { |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
341 waddch(win, ((unsigned char) *s) | col); |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
342 s++; |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
343 } |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
344 } |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
345 } |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
346 |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
347 |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
348 void nnwin_update(BOOL force, nn_editbuf_t *ebuf, char *username, int usercolor) |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
349 { |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
350 int sx, sy; |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
351 |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
352 // Save cursor position |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
353 getyx(stdscr, sy, sx); |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
354 |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
355 // Clear screen if forced or main or editbuf are dirty |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
356 if (force || (currWin != NULL && currWin->dirty) || (ebuf != NULL && ebuf->dirty)) |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
357 { |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
358 wattrset(stdscr, A_NORMAL); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
359 wbkgdset(stdscr, COLOR_PAIR(0)); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
360 werase(stdscr); |
503
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
361 force = TRUE; |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
362 } |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
363 |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
364 // Check if update is forced or if the window is dirty |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
365 if (currWin != NULL && (force || currWin->dirty)) |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
366 { |
503
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
367 int y, offs; |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
368 qringbuf_t *buf = currWin->data; |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
369 |
503
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
370 for (y = scrHeight - 4, offs = buf->size - 1 - currWin->pos; offs >= 0 && y > 0; offs--) |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
371 { |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
372 nn_line_t *line = buf->data[offs]; |
503
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
373 if (line != NULL) |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
374 { |
504
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
375 const int *s = line->buf; |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
376 size_t pos; |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
377 |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
378 y -= (line->len / scrWidth); |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
379 if (line->len % scrWidth != 0) |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
380 y -= 1; |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
381 |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
382 if (y < 0) |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
383 { |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
384 size_t r; |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
385 int x; |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
386 for (r = -y, x = 0, pos = 0; r && pos < line->len; pos++) |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
387 { |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
388 if (++x >= scrWidth) |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
389 { |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
390 x = 0; |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
391 r++; |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
392 } |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
393 } |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
394 y = 0; |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
395 } |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
396 |
503
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
397 wmove(stdscr, y, 0); |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
398 |
504
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
399 for (pos = 0; pos < line->len; pos++) |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
400 waddch(stdscr, s[pos]); |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
401 } |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
402 } |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
403 |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
404 currWin->dirty = FALSE; |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
405 } |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
406 |
503
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
407 // Update statusline |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
408 { |
503
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
409 char tmpStamp[32], tmpStr[128]; |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
410 int i; |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
411 |
503
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
412 str_get_timestamp(tmpStamp, sizeof(tmpStamp), "%H:%M:%S"); |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
413 |
503
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
414 #if 0 |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
415 snprintf(tmpStr, sizeof(tmpStr), |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
416 " ½10½%s½13½ | ½16½%s½13½ | ½11½#%06x½13½ | WIN: %d: %s / %d | ½11½", |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
417 tmpStamp, |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
418 username, |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
419 usercolor, |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
420 currWin->num + 1, |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
421 currWin->id != NULL ? currWin->id : "MAIN", |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
422 currWin->pos); |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
423 #else |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
424 snprintf(tmpStr, sizeof(tmpStr), |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
425 " %s | %s | #%06x | WIN: %d: %s / %d | ", |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
426 tmpStamp, |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
427 username, |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
428 usercolor, |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
429 currWin->num + 1, |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
430 currWin->id != NULL ? currWin->id : "MAIN", |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
431 currWin->pos); |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
432 #endif |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
433 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
434 wmove(stdscr, scrHeight - 4, 0); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
435 wbkgdset(stdscr, COLOR_PAIR(10)); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
436 wclrtoeol(stdscr); |
503
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
437 nnwin_print_str(stdscr, tmpStr, TRUE); |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
438 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
439 for (i = 0; i < SET_MAX_WINDOWS; i++) |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
440 { |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
441 if (chatWindows[i] != NULL && chatWindows[i]->dirty) |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
442 { |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
443 snprintf(tmpStr, sizeof(tmpStr), "%d ", i + 1); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
444 waddstr(stdscr, tmpStr); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
445 } |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
446 } |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
447 } |
503
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
448 |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
449 // Restore cursor position |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
450 wmove(stdscr, sy, sx); |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
451 |
503
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
452 // Update editbuf if needed |
bac3f9af112c
More work on curses cleanup. Almost working now.
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
453 if (ebuf != NULL && (force || ebuf->dirty)) |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
454 { |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
455 int yoffs = ebuf->pos / scrWidth, |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
456 xoffs = ebuf->pos % scrWidth; |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
457 char *tmp; |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
458 |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
459 ebuf->dirty = FALSE; |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
460 ebuf->data[ebuf->len] = 0; |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
461 tmp = nn_username_decode(th_strdup(ebuf->data)); |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
462 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
463 wmove(stdscr, scrHeight - 3, 0); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
464 wattrset(stdscr, A_NORMAL); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
465 wbkgdset(stdscr, COLOR_PAIR(0)); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
466 waddnstr(stdscr, tmp, ebuf->len); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
467 wmove(stdscr, scrHeight - 3 + yoffs, xoffs); |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
468 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
469 th_free(tmp); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
470 } |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
471 |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
472 wrefresh(stdscr); |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
473 } |