Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/screen.c @ 336:eb994ee40029
Make some functions static
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Mon, 18 Jul 2005 21:27:08 +0100 |
parents | a1901741890e |
children | e4ed1aec2988 |
comparison
equal
deleted
inserted
replaced
335:3ec329a1c621 | 336:eb994ee40029 |
---|---|
40 #include "utils.h" | 40 #include "utils.h" |
41 #include "list.h" | 41 #include "list.h" |
42 | 42 |
43 #define window_entry(n) list_entry(n, window_entry_t, list) | 43 #define window_entry(n) list_entry(n, window_entry_t, list) |
44 | 44 |
45 inline void check_offset(int); | 45 static inline void check_offset(int); |
46 | 46 |
47 LIST_HEAD(window_list); | 47 LIST_HEAD(window_list); |
48 | 48 |
49 typedef struct _window_entry_t { | 49 typedef struct _window_entry_t { |
50 WINDOW *win; | 50 WINDOW *win; |
81 static char cmdhisto_backup[INPUTLINE_LENGTH+1]; | 81 static char cmdhisto_backup[INPUTLINE_LENGTH+1]; |
82 | 82 |
83 | 83 |
84 /* Functions */ | 84 /* Functions */ |
85 | 85 |
86 int scr_WindowWidth(WINDOW * win) | 86 static int scr_WindowWidth(WINDOW * win) |
87 { | 87 { |
88 int x, y; | 88 int x, y; |
89 getmaxyx(win, y, x); | 89 getmaxyx(win, y, x); |
90 return x; | 90 return x; |
91 } | 91 } |
92 | 92 |
93 void scr_clear_box(WINDOW *win, int y, int x, int height, int width, int Color) | 93 static void scr_draw_box(WINDOW * win, int y, int x, int height, int width, |
94 { | 94 int Color, chtype box, chtype border) |
95 int i, j; | |
96 | |
97 wattrset(win, COLOR_PAIR(Color)); | |
98 for (i = 0; i < height; i++) { | |
99 wmove(win, y + i, x); | |
100 for (j = 0; j < width; j++) | |
101 wprintw(win, " "); | |
102 } | |
103 } | |
104 | |
105 void scr_draw_box(WINDOW * win, int y, int x, int height, int width, | |
106 int Color, chtype box, chtype border) | |
107 { | 95 { |
108 int i, j; | 96 int i, j; |
109 | 97 |
110 wattrset(win, COLOR_PAIR(Color)); | 98 wattrset(win, COLOR_PAIR(Color)); |
111 for (i = 0; i < height; i++) { | 99 for (i = 0; i < height; i++) { |
130 else | 118 else |
131 waddch(win, box | ' '); | 119 waddch(win, box | ' '); |
132 } | 120 } |
133 } | 121 } |
134 | 122 |
135 int FindColor(const char *name) | 123 static int FindColor(const char *name) |
136 { | 124 { |
137 if (!strcmp(name, "default")) | 125 if (!strcmp(name, "default")) |
138 return -1; | 126 return -1; |
139 if (!strcmp(name, "black")) | 127 if (!strcmp(name, "black")) |
140 return COLOR_BLACK; | 128 return COLOR_BLACK; |
154 return COLOR_WHITE; | 142 return COLOR_WHITE; |
155 | 143 |
156 return -1; | 144 return -1; |
157 } | 145 } |
158 | 146 |
159 void ParseColors(void) | 147 static void ParseColors(void) |
160 { | 148 { |
161 const char *colors[8] = { | 149 const char *colors[8] = { |
162 "", "", | 150 "", "", |
163 "general", | 151 "general", |
164 "newmsg", | 152 "newmsg", |
207 } | 195 } |
208 i++; | 196 i++; |
209 } | 197 } |
210 } | 198 } |
211 | 199 |
212 | 200 static window_entry_t *scr_CreateBuddyPanel(const char *title, int dont_show) |
213 window_entry_t *scr_CreateBuddyPanel(const char *title, int dont_show) | |
214 { | 201 { |
215 int x; | 202 int x; |
216 int y; | 203 int y; |
217 int lines; | 204 int lines; |
218 int cols; | 205 int cols; |
254 list_add_tail(&tmp->list, &window_list); | 241 list_add_tail(&tmp->list, &window_list); |
255 | 242 |
256 return tmp; | 243 return tmp; |
257 } | 244 } |
258 | 245 |
259 window_entry_t *scr_SearchWindow(const char *winId) | 246 static window_entry_t *scr_SearchWindow(const char *winId) |
260 { | 247 { |
261 struct list_head *pos, *n; | 248 struct list_head *pos, *n; |
262 window_entry_t *search_entry = NULL; | 249 window_entry_t *search_entry = NULL; |
263 | 250 |
264 list_for_each_safe(pos, n, &window_list) { | 251 list_for_each_safe(pos, n, &window_list) { |
272 return NULL; | 259 return NULL; |
273 } | 260 } |
274 | 261 |
275 // scr_UpdateWindow() | 262 // scr_UpdateWindow() |
276 // (Re-)Display the given chat window. | 263 // (Re-)Display the given chat window. |
277 void scr_UpdateWindow(window_entry_t *win_entry) | 264 static void scr_UpdateWindow(window_entry_t *win_entry) |
278 { | 265 { |
279 int n; | 266 int n; |
280 int width; | 267 int width; |
281 hbb_line **lines, *line; | 268 hbb_line **lines, *line; |
282 GList *hbuf_head; | 269 GList *hbuf_head; |
355 g_free(lines); | 342 g_free(lines); |
356 } | 343 } |
357 | 344 |
358 // scr_ShowWindow() | 345 // scr_ShowWindow() |
359 // Display the chat window with the given identifier. | 346 // Display the chat window with the given identifier. |
360 void scr_ShowWindow(const char *winId) | 347 static void scr_ShowWindow(const char *winId) |
361 { | 348 { |
362 window_entry_t *win_entry = scr_SearchWindow(winId); | 349 window_entry_t *win_entry = scr_SearchWindow(winId); |
363 | 350 |
364 if (!win_entry) | 351 if (!win_entry) |
365 win_entry = scr_CreateBuddyPanel(winId, FALSE); | 352 win_entry = scr_CreateBuddyPanel(winId, FALSE); |
793 int ch; | 780 int ch; |
794 ch = wgetch(inputWnd); | 781 ch = wgetch(inputWnd); |
795 return ch; | 782 return ch; |
796 } | 783 } |
797 | 784 |
798 WINDOW *scr_GetRosterWindow(void) | |
799 { | |
800 return rosterWnd; | |
801 } | |
802 | |
803 WINDOW *scr_GetStatusWindow(void) | |
804 { | |
805 return chatWnd; | |
806 } | |
807 | |
808 WINDOW *scr_GetInputWindow(void) | |
809 { | |
810 return inputWnd; | |
811 } | |
812 | |
813 // set_current_buddy(newbuddy) | 785 // set_current_buddy(newbuddy) |
814 // Set the current_buddy to newbuddy (if not NULL) | 786 // Set the current_buddy to newbuddy (if not NULL) |
815 // Lock the newbuddy, and unlock the previous current_buddy | 787 // Lock the newbuddy, and unlock the previous current_buddy |
816 static void set_current_buddy(GList *newbuddy) | 788 static void set_current_buddy(GList *newbuddy) |
817 { | 789 { |
1040 // Finished :) | 1012 // Finished :) |
1041 update_panels(); | 1013 update_panels(); |
1042 doupdate(); | 1014 doupdate(); |
1043 } | 1015 } |
1044 | 1016 |
1017 // TODO Merge BufferTop & BufferBottom | |
1045 // scr_BufferTop() | 1018 // scr_BufferTop() |
1046 // Jump to the head of the current buddy window | 1019 // Jump to the head of the current buddy window |
1047 void scr_BufferTop(void) | 1020 void scr_BufferTop(void) |
1048 { | 1021 { |
1049 const gchar *jid; | 1022 const gchar *jid; |
1220 } | 1193 } |
1221 | 1194 |
1222 // scr_cmdhisto_prev() | 1195 // scr_cmdhisto_prev() |
1223 // Look for previous line beginning w/ the given mask in the inputLine history | 1196 // Look for previous line beginning w/ the given mask in the inputLine history |
1224 // Returns NULL if none found | 1197 // Returns NULL if none found |
1225 const char *scr_cmdhisto_prev(char *mask, guint len) | 1198 static const char *scr_cmdhisto_prev(char *mask, guint len) |
1226 { | 1199 { |
1227 GList *hl; | 1200 GList *hl; |
1228 if (!cmdhisto_cur) { | 1201 if (!cmdhisto_cur) { |
1229 hl = g_list_last(cmdhisto); | 1202 hl = g_list_last(cmdhisto); |
1230 if (hl) { // backup current line | 1203 if (hl) { // backup current line |
1245 } | 1218 } |
1246 | 1219 |
1247 // scr_cmdhisto_next() | 1220 // scr_cmdhisto_next() |
1248 // Look for next line beginning w/ the given mask in the inputLine history | 1221 // Look for next line beginning w/ the given mask in the inputLine history |
1249 // Returns NULL if none found | 1222 // Returns NULL if none found |
1250 const char *scr_cmdhisto_next(char *mask, guint len) | 1223 static const char *scr_cmdhisto_next(char *mask, guint len) |
1251 { | 1224 { |
1252 GList *hl; | 1225 GList *hl; |
1253 if (!cmdhisto_cur) return NULL; | 1226 if (!cmdhisto_cur) return NULL; |
1254 hl = cmdhisto_cur; | 1227 hl = cmdhisto_cur; |
1255 while ((hl = g_list_next(hl)) != NULL) | 1228 while ((hl = g_list_next(hl)) != NULL) |
1322 // Tells which row our cursor is in, in the command line. | 1295 // Tells which row our cursor is in, in the command line. |
1323 // -1 -> normal text | 1296 // -1 -> normal text |
1324 // 0 -> command | 1297 // 0 -> command |
1325 // 1 -> parameter 1 (etc.) | 1298 // 1 -> parameter 1 (etc.) |
1326 // If > 0, then *p_row is set to the beginning of the row | 1299 // If > 0, then *p_row is set to the beginning of the row |
1327 int which_row(char **p_row) | 1300 static int which_row(char **p_row) |
1328 { | 1301 { |
1329 int row = -1; | 1302 int row = -1; |
1330 char *p; | 1303 char *p; |
1331 int quote = FALSE; | 1304 int quote = FALSE; |
1332 | 1305 |
1355 | 1328 |
1356 // scr_insert_text() | 1329 // scr_insert_text() |
1357 // Insert the given text at the current cursor position. | 1330 // Insert the given text at the current cursor position. |
1358 // The cursor is moved. We don't check if the cursor still is in the screen | 1331 // The cursor is moved. We don't check if the cursor still is in the screen |
1359 // after, the caller should do that. | 1332 // after, the caller should do that. |
1360 void scr_insert_text(const char *text) | 1333 static void scr_insert_text(const char *text) |
1361 { | 1334 { |
1362 char tmpLine[INPUTLINE_LENGTH+1]; | 1335 char tmpLine[INPUTLINE_LENGTH+1]; |
1363 int len = strlen(text); | 1336 int len = strlen(text); |
1364 // Check the line isn't too long | 1337 // Check the line isn't too long |
1365 if (strlen(inputLine) + len >= INPUTLINE_LENGTH) { | 1338 if (strlen(inputLine) + len >= INPUTLINE_LENGTH) { |
1373 } | 1346 } |
1374 | 1347 |
1375 // scr_handle_tab() | 1348 // scr_handle_tab() |
1376 // Function called when tab is pressed. | 1349 // Function called when tab is pressed. |
1377 // Initiate or continue a completion... | 1350 // Initiate or continue a completion... |
1378 void scr_handle_tab(void) | 1351 static void scr_handle_tab(void) |
1379 { | 1352 { |
1380 int nrow; | 1353 int nrow; |
1381 char *row; | 1354 char *row; |
1382 const char *cchar; | 1355 const char *cchar; |
1383 guint compl_categ; | 1356 guint compl_categ; |
1437 if (cchar) | 1410 if (cchar) |
1438 scr_insert_text(cchar); | 1411 scr_insert_text(cchar); |
1439 } | 1412 } |
1440 } | 1413 } |
1441 | 1414 |
1442 void scr_cancel_current_completion(void) | 1415 static void scr_cancel_current_completion(void) |
1443 { | 1416 { |
1444 char *c; | 1417 char *c; |
1445 guint back = cancel_completion(); | 1418 guint back = cancel_completion(); |
1446 // Remove $back chars | 1419 // Remove $back chars |
1447 ptr_inputline -= back; | 1420 ptr_inputline -= back; |
1448 c = ptr_inputline; | 1421 c = ptr_inputline; |
1449 for ( ; *c ; c++) | 1422 for ( ; *c ; c++) |
1450 *c = *(c+back); | 1423 *c = *(c+back); |
1451 } | 1424 } |
1452 | 1425 |
1453 void scr_end_current_completion(void) | 1426 static void scr_end_current_completion(void) |
1454 { | 1427 { |
1455 done_completion(); | 1428 done_completion(); |
1456 completion_started = FALSE; | 1429 completion_started = FALSE; |
1457 } | 1430 } |
1458 | 1431 |
1459 // check_offset(int direction) | 1432 // check_offset(int direction) |
1460 // Check inputline_offset value, and make sure the cursor is inside the | 1433 // Check inputline_offset value, and make sure the cursor is inside the |
1461 // screen. | 1434 // screen. |
1462 inline void check_offset(int direction) | 1435 static inline void check_offset(int direction) |
1463 { | 1436 { |
1464 // Left side | 1437 // Left side |
1465 if (inputline_offset && direction <= 0) { | 1438 if (inputline_offset && direction <= 0) { |
1466 while (ptr_inputline <= (char*)&inputLine + inputline_offset) { | 1439 while (ptr_inputline <= (char*)&inputLine + inputline_offset) { |
1467 if (inputline_offset) { | 1440 if (inputline_offset) { |
1476 while (ptr_inputline >= inputline_offset + (char*)&inputLine + maxX) | 1449 while (ptr_inputline >= inputline_offset + (char*)&inputLine + maxX) |
1477 inputline_offset += 5; | 1450 inputline_offset += 5; |
1478 } | 1451 } |
1479 } | 1452 } |
1480 | 1453 |
1481 inline void refresh_inputline(void) | 1454 static inline void refresh_inputline(void) |
1482 { | 1455 { |
1483 mvwprintw(inputWnd, 0,0, "%s", inputLine + inputline_offset); | 1456 mvwprintw(inputWnd, 0,0, "%s", inputLine + inputline_offset); |
1484 wclrtoeol(inputWnd); | 1457 wclrtoeol(inputWnd); |
1485 if (*ptr_inputline) | 1458 if (*ptr_inputline) |
1486 wmove(inputWnd, 0, ptr_inputline - (char*)&inputLine - inputline_offset); | 1459 wmove(inputWnd, 0, ptr_inputline - (char*)&inputLine - inputline_offset); |