Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/screen.c @ 1780:e4378fbab5d7
Major API cleanup - bump API to 4
Get rid of old CamelCase names in screen.h
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 14 Mar 2010 12:09:08 +0100 |
parents | 61f0482d3993 |
children | af3de54ef986 |
comparison
equal
deleted
inserted
replaced
1779:2911c950dcd1 | 1780:e4378fbab5d7 |
---|---|
77 static void scr_cancel_current_completion(void); | 77 static void scr_cancel_current_completion(void); |
78 static void scr_end_current_completion(void); | 78 static void scr_end_current_completion(void); |
79 static void scr_insert_text(const char*); | 79 static void scr_insert_text(const char*); |
80 static void scr_handle_tab(void); | 80 static void scr_handle_tab(void); |
81 | 81 |
82 #if defined XEP0022 || defined XEP0085 | |
83 static gboolean scr_chatstates_timeout(); | |
84 #endif | |
85 | |
82 #if defined(WITH_ENCHANT) || defined(WITH_ASPELL) | 86 #if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
83 static void spellcheck(char *, char *); | 87 static void spellcheck(char *, char *); |
84 #endif | 88 #endif |
85 | 89 |
86 static GHashTable *winbufhash; | 90 static GHashTable *winbufhash; |
116 | 120 |
117 static int roster_hidden; | 121 static int roster_hidden; |
118 static int chatmode; | 122 static int chatmode; |
119 static int multimode; | 123 static int multimode; |
120 static char *multiline, *multimode_subj; | 124 static char *multiline, *multimode_subj; |
121 int update_roster; | 125 |
122 int utf8_mode = 0; | |
123 static bool Curses; | 126 static bool Curses; |
124 static bool log_win_on_top; | 127 static bool log_win_on_top; |
125 static bool roster_win_on_right; | 128 static bool roster_win_on_right; |
126 static guint autoaway_source = 0; | 129 static guint autoaway_source = 0; |
127 | 130 |
139 | 142 |
140 static int chatstate; /* (0=active, 1=composing, 2=paused) */ | 143 static int chatstate; /* (0=active, 1=composing, 2=paused) */ |
141 static bool lock_chatstate; | 144 static bool lock_chatstate; |
142 static time_t chatstate_timestamp; | 145 static time_t chatstate_timestamp; |
143 static guint chatstate_timeout_id = 0; | 146 static guint chatstate_timeout_id = 0; |
144 int chatstates_disabled; | 147 |
148 int update_roster; | |
149 int utf8_mode; | |
150 gboolean chatstates_disabled; | |
151 gboolean Autoaway; | |
145 | 152 |
146 #define MAX_KEYSEQ_LENGTH 8 | 153 #define MAX_KEYSEQ_LENGTH 8 |
147 | 154 |
148 typedef struct { | 155 typedef struct { |
149 char *seqstr; | 156 char *seqstr; |
156 #endif | 163 #endif |
157 | 164 |
158 GSList *keyseqlist; | 165 GSList *keyseqlist; |
159 static void add_keyseq(char *seqstr, guint mkeycode, gint value); | 166 static void add_keyseq(char *seqstr, guint mkeycode, gint value); |
160 | 167 |
161 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp, | 168 static void scr_write_in_window(const char *winId, const char *text, |
162 unsigned int prefix_flags, int force_show, | 169 time_t timestamp, unsigned int prefix_flags, |
163 unsigned mucnicklen, gpointer xep184); | 170 int force_show, unsigned mucnicklen, |
164 | 171 gpointer xep184); |
165 void scr_WriteMessage(const char *bjid, const char *text, | 172 |
166 time_t timestamp, guint prefix_flags, | 173 static void scr_write_message(const char *bjid, const char *text, |
167 unsigned mucnicklen, gpointer xep184); | 174 time_t timestamp, guint prefix_flags, |
168 | 175 unsigned mucnicklen, gpointer xep184); |
169 inline void scr_UpdateBuddyWindow(void); | 176 |
177 inline void scr_update_buddy_window(void); | |
170 inline void scr_set_chatmode(int enable); | 178 inline void scr_set_chatmode(int enable); |
171 | 179 |
172 #define SPELLBADCHAR 5 | 180 #define SPELLBADCHAR 5 |
173 | 181 |
174 #ifdef WITH_ENCHANT | 182 #ifdef WITH_ENCHANT |
205 static ccolor ** nickcols = NULL; | 213 static ccolor ** nickcols = NULL; |
206 static muccoltype glob_muccol = MC_OFF; | 214 static muccoltype glob_muccol = MC_OFF; |
207 | 215 |
208 /* Functions */ | 216 /* Functions */ |
209 | 217 |
210 static int FindColor(const char *name) | 218 static int find_color(const char *name) |
211 { | 219 { |
212 int result; | 220 int result; |
213 | 221 |
214 if (!strcmp(name, "default")) | 222 if (!strcmp(name, "default")) |
215 return -1; | 223 return -1; |
246 ccolor *ccol; | 254 ccolor *ccol; |
247 if (!strncmp(color, "bright", 6)) { | 255 if (!strncmp(color, "bright", 6)) { |
248 isbright = TRUE; | 256 isbright = TRUE; |
249 color += 6; | 257 color += 6; |
250 } | 258 } |
251 cl = FindColor(color); | 259 cl = find_color(color); |
252 if (cl < 0) | 260 if (cl < 0) |
253 return NULL; | 261 return NULL; |
254 ccol = g_new0(ccolor, 1); | 262 ccol = g_new0(ccolor, 1); |
255 ccol->color_attrib = isbright ? A_BOLD : A_NORMAL; | 263 ccol->color_attrib = isbright ? A_BOLD : A_NORMAL; |
256 ccol->color_pair = cl + COLOR_max; // User colors come after the internal ones | 264 ccol->color_pair = cl + COLOR_max; // User colors come after the internal ones |
257 return ccol; | 265 return ccol; |
258 } | 266 } |
259 | 267 |
260 static void ensure_string_htable(GHashTable **table, | 268 static void ensure_string_htable(GHashTable **table, |
261 GDestroyNotify value_destroy_func) | 269 GDestroyNotify value_destroy_func) |
262 { | 270 { |
263 if (*table) // Have it already | 271 if (*table) // Have it already |
264 return; | 272 return; |
265 *table = g_hash_table_new_full(g_str_hash, g_str_equal, | 273 *table = g_hash_table_new_full(g_str_hash, g_str_equal, |
266 g_free, value_destroy_func); | 274 g_free, value_destroy_func); |
268 | 276 |
269 // Sets the coloring mode for given MUC | 277 // Sets the coloring mode for given MUC |
270 // The MUC room does not need to be in the roster at that time | 278 // The MUC room does not need to be in the roster at that time |
271 // muc - the JID of room | 279 // muc - the JID of room |
272 // type - the new type | 280 // type - the new type |
273 void scr_MucColor(const char *muc, muccoltype type) | 281 void scr_muc_color(const char *muc, muccoltype type) |
274 { | 282 { |
275 gchar *muclow = g_utf8_strdown(muc, -1); | 283 gchar *muclow = g_utf8_strdown(muc, -1); |
276 if (type == MC_REMOVE) { // Remove it | 284 if (type == MC_REMOVE) { // Remove it |
277 if (strcmp(muc, "*")) { | 285 if (strcmp(muc, "*")) { |
278 if (muccolors && g_hash_table_lookup(muccolors, muclow)) | 286 if (muccolors && g_hash_table_lookup(muccolors, muclow)) |
293 } | 301 } |
294 } | 302 } |
295 // Need to redraw? | 303 // Need to redraw? |
296 if (chatmode && | 304 if (chatmode && |
297 ((buddy_search_jid(muc) == current_buddy) || !strcmp(muc, "*"))) | 305 ((buddy_search_jid(muc) == current_buddy) || !strcmp(muc, "*"))) |
298 scr_UpdateBuddyWindow(); | 306 scr_update_buddy_window(); |
299 } | 307 } |
300 | 308 |
301 // Sets the color for nick in MUC | 309 // Sets the color for nick in MUC |
302 // If color is "-", the color is marked as automaticly assigned and is | 310 // If color is "-", the color is marked as automaticly assigned and is |
303 // not used if the room is in the "preset" mode | 311 // not used if the room is in the "preset" mode |
304 void scr_MucNickColor(const char *nick, const char *color) | 312 void scr_muc_nick_color(const char *nick, const char *color) |
305 { | 313 { |
306 char *snick, *mnick; | 314 char *snick, *mnick; |
307 bool need_update = FALSE; | 315 bool need_update = FALSE; |
308 snick = g_strdup_printf("<%s>", nick); | 316 snick = g_strdup_printf("<%s>", nick); |
309 mnick = g_strdup_printf("*%s ", nick); | 317 mnick = g_strdup_printf("*%s ", nick); |
339 need_update = TRUE; | 347 need_update = TRUE; |
340 } | 348 } |
341 } | 349 } |
342 if (need_update && chatmode && | 350 if (need_update && chatmode && |
343 (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_ROOM)) | 351 (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_ROOM)) |
344 scr_UpdateBuddyWindow(); | 352 scr_update_buddy_window(); |
345 } | 353 } |
346 | 354 |
347 static void free_rostercolrule(rostercolor *col) | 355 static void free_rostercolrule(rostercolor *col) |
348 { | 356 { |
349 g_free(col->status); | 357 g_free(col->status); |
352 g_pattern_spec_free(col->compiled); | 360 g_pattern_spec_free(col->compiled); |
353 g_free(col); | 361 g_free(col); |
354 } | 362 } |
355 | 363 |
356 // Removes all roster coloring rules | 364 // Removes all roster coloring rules |
357 void scr_RosterClearColor(void) | 365 void scr_roster_clear_color(void) |
358 { | 366 { |
359 GSList *head; | 367 GSList *head; |
360 for (head = rostercolrules; head; head = g_slist_next(head)) { | 368 for (head = rostercolrules; head; head = g_slist_next(head)) { |
361 free_rostercolrule(head->data); | 369 free_rostercolrule(head->data); |
362 } | 370 } |
369 // otherwise it is modified (if exists) or added | 377 // otherwise it is modified (if exists) or added |
370 // | 378 // |
371 // Returns weather it was successfull (therefore the roster should be | 379 // Returns weather it was successfull (therefore the roster should be |
372 // redrawed) or not. If it failed, for example because of invalid color | 380 // redrawed) or not. If it failed, for example because of invalid color |
373 // name, it also prints the error. | 381 // name, it also prints the error. |
374 bool scr_RosterColor(const char *status, const char *wildcard, | 382 bool scr_roster_color(const char *status, const char *wildcard, |
375 const char *color) | 383 const char *color) |
376 { | 384 { |
377 GSList *head; | 385 GSList *head; |
378 GSList *found = NULL; | 386 GSList *found = NULL; |
379 for (head = rostercolrules; head; head = g_slist_next(head)) { | 387 for (head = rostercolrules; head; head = g_slist_next(head)) { |
380 rostercolor *rc = head->data; | 388 rostercolor *rc = head->data; |
412 } | 420 } |
413 return TRUE; | 421 return TRUE; |
414 } | 422 } |
415 } | 423 } |
416 | 424 |
417 static void ParseColors(void) | 425 static void parse_colors(void) |
418 { | 426 { |
419 const char *colors[] = { | 427 const char *colors[] = { |
420 "", "", | 428 "", "", |
421 "general", | 429 "general", |
422 "msgout", | 430 "msgout", |
464 break; | 472 break; |
465 case 2: | 473 case 2: |
466 init_pair(2, COLOR_WHITE, COLOR_BLACK); | 474 init_pair(2, COLOR_WHITE, COLOR_BLACK); |
467 break; | 475 break; |
468 case COLOR_GENERAL: | 476 case COLOR_GENERAL: |
469 init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE), | 477 init_pair(i+1, ((color) ? find_color(color) : COLOR_WHITE), |
470 FindColor(background)); | 478 find_color(background)); |
471 break; | 479 break; |
472 case COLOR_MSGOUT: | 480 case COLOR_MSGOUT: |
473 init_pair(i+1, ((color) ? FindColor(color) : COLOR_CYAN), | 481 init_pair(i+1, ((color) ? find_color(color) : COLOR_CYAN), |
474 FindColor(background)); | 482 find_color(background)); |
475 break; | 483 break; |
476 case COLOR_MSGHL: | 484 case COLOR_MSGHL: |
477 init_pair(i+1, ((color) ? FindColor(color) : COLOR_YELLOW), | 485 init_pair(i+1, ((color) ? find_color(color) : COLOR_YELLOW), |
478 FindColor(background)); | 486 find_color(background)); |
479 break; | 487 break; |
480 case COLOR_STATUS: | 488 case COLOR_STATUS: |
481 init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE), | 489 init_pair(i+1, ((color) ? find_color(color) : COLOR_WHITE), |
482 FindColor(backstatus)); | 490 find_color(backstatus)); |
483 break; | 491 break; |
484 case COLOR_ROSTER: | 492 case COLOR_ROSTER: |
485 init_pair(i+1, ((color) ? FindColor(color) : COLOR_GREEN), | 493 init_pair(i+1, ((color) ? find_color(color) : COLOR_GREEN), |
486 FindColor(background)); | 494 find_color(background)); |
487 break; | 495 break; |
488 case COLOR_ROSTERSEL: | 496 case COLOR_ROSTERSEL: |
489 init_pair(i+1, ((color) ? FindColor(color) : COLOR_BLUE), | 497 init_pair(i+1, ((color) ? find_color(color) : COLOR_BLUE), |
490 FindColor(backselected)); | 498 find_color(backselected)); |
491 break; | 499 break; |
492 case COLOR_ROSTERSELNMSG: | 500 case COLOR_ROSTERSELNMSG: |
493 init_pair(i+1, ((color) ? FindColor(color) : COLOR_RED), | 501 init_pair(i+1, ((color) ? find_color(color) : COLOR_RED), |
494 FindColor(backselected)); | 502 find_color(backselected)); |
495 break; | 503 break; |
496 case COLOR_ROSTERNMSG: | 504 case COLOR_ROSTERNMSG: |
497 init_pair(i+1, ((color) ? FindColor(color) : COLOR_RED), | 505 init_pair(i+1, ((color) ? find_color(color) : COLOR_RED), |
498 FindColor(background)); | 506 find_color(background)); |
499 break; | 507 break; |
500 case COLOR_INFO: | 508 case COLOR_INFO: |
501 init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE), | 509 init_pair(i+1, ((color) ? find_color(color) : COLOR_WHITE), |
502 FindColor(background)); | 510 find_color(background)); |
503 break; | 511 break; |
504 case COLOR_MSGIN: | 512 case COLOR_MSGIN: |
505 init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE), | 513 init_pair(i+1, ((color) ? find_color(color) : COLOR_WHITE), |
506 FindColor(background)); | 514 find_color(background)); |
507 break; | 515 break; |
508 } | 516 } |
509 } | 517 } |
510 for (i = COLOR_max; i < (COLOR_max + COLORS); i++) | 518 for (i = COLOR_max; i < (COLOR_max + COLORS); i++) |
511 init_pair(i, i-COLOR_max, FindColor(background)); | 519 init_pair(i, i-COLOR_max, find_color(background)); |
512 | 520 |
513 if (!nickcols) { | 521 if (!nickcols) { |
514 char *ncolors = g_strdup(settings_opt_get("nick_colors")); | 522 char *ncolors = g_strdup(settings_opt_get("nick_colors")); |
515 if (ncolors) { | 523 if (ncolors) { |
516 char *ncolor_start, *ncolor_end; | 524 char *ncolor_start, *ncolor_end; |
722 return TRUE; | 730 return TRUE; |
723 | 731 |
724 return FALSE; | 732 return FALSE; |
725 } | 733 } |
726 | 734 |
727 void scr_InitLocaleCharSet(void) | 735 void scr_init_locale_charset(void) |
728 { | 736 { |
729 setlocale(LC_ALL, ""); | 737 setlocale(LC_ALL, ""); |
730 #ifdef HAVE_LOCALCHARSET_H | 738 #ifdef HAVE_LOCALCHARSET_H |
731 LocaleCharSet = locale_charset(); | 739 LocaleCharSet = locale_charset(); |
732 #else | 740 #else |
733 LocaleCharSet = nl_langinfo(CODESET); | 741 LocaleCharSet = nl_langinfo(CODESET); |
734 #endif | 742 #endif |
735 utf8_mode = (strcmp(LocaleCharSet, "UTF-8") == 0); | 743 utf8_mode = (strcmp(LocaleCharSet, "UTF-8") == 0); |
736 } | 744 } |
737 | 745 |
738 gboolean scr_CursesStatus(void) | 746 gboolean scr_curses_status(void) |
739 { | 747 { |
740 return Curses; | 748 return Curses; |
741 } | 749 } |
742 | 750 |
743 void scr_InitCurses(void) | 751 void scr_init_curses(void) |
744 { | 752 { |
745 /* Key sequences initialization */ | 753 /* Key sequences initialization */ |
746 init_keycodes(); | 754 init_keycodes(); |
747 | 755 |
748 initscr(); | 756 initscr(); |
763 #else | 771 #else |
764 scr_LogPrint(LPRINT_LOGNORM, "ERROR: no ESCDELAY support."); | 772 scr_LogPrint(LPRINT_LOGNORM, "ERROR: no ESCDELAY support."); |
765 #endif | 773 #endif |
766 } | 774 } |
767 | 775 |
768 ParseColors(); | 776 parse_colors(); |
769 | 777 |
770 getmaxyx(stdscr, maxY, maxX); | 778 getmaxyx(stdscr, maxY, maxX); |
771 Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT; | 779 Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT; |
772 // Note scr_DrawMainWindow() should be called early after scr_InitCurses() | 780 // Note scr_draw_main_window() should be called early after scr_init_curses() |
773 // to update Log_Win_Height and set max{X,Y} | 781 // to update Log_Win_Height and set max{X,Y} |
774 | 782 |
775 inputLine[0] = 0; | 783 inputLine[0] = 0; |
776 ptr_inputline = inputLine; | 784 ptr_inputline = inputLine; |
777 | 785 |
787 | 795 |
788 Curses = TRUE; | 796 Curses = TRUE; |
789 return; | 797 return; |
790 } | 798 } |
791 | 799 |
792 void scr_TerminateCurses(void) | 800 void scr_terminate_curses(void) |
793 { | 801 { |
794 if (!Curses) return; | 802 if (!Curses) return; |
795 clear(); | 803 clear(); |
796 refresh(); | 804 refresh(); |
797 endwin(); | 805 endwin(); |
801 #endif | 809 #endif |
802 Curses = FALSE; | 810 Curses = FALSE; |
803 return; | 811 return; |
804 } | 812 } |
805 | 813 |
806 void scr_Beep(void) | 814 void scr_beep(void) |
807 { | 815 { |
808 beep(); | 816 beep(); |
809 } | 817 } |
810 | 818 |
811 // This and following belongs to dynamic setting of time prefix | 819 // This and following belongs to dynamic setting of time prefix |
917 buf_specialwindow = btext; | 925 buf_specialwindow = btext; |
918 | 926 |
919 if (Curses) { | 927 if (Curses) { |
920 wprintw(logWnd, "\n%s", buffer_locale); | 928 wprintw(logWnd, "\n%s", buffer_locale); |
921 update_panels(); | 929 update_panels(); |
922 scr_WriteInWindow(NULL, buf_specialwindow, timestamp, | 930 scr_write_in_window(NULL, buf_specialwindow, timestamp, |
923 HBB_PREFIX_SPECIAL, FALSE, 0, NULL); | 931 HBB_PREFIX_SPECIAL, FALSE, 0, NULL); |
924 } else { | 932 } else { |
925 printf("%s\n", buffer_locale); | 933 printf("%s\n", buffer_locale); |
926 // ncurses are not initialized yet, so we call directly hbuf routine | 934 // ncurses are not initialized yet, so we call directly hbuf routine |
927 hbuf_add_line(&statushbuf, buf_specialwindow, timestamp, | 935 hbuf_add_line(&statushbuf, buf_specialwindow, timestamp, |
928 HBB_PREFIX_SPECIAL, 0, 0, 0, NULL); | 936 HBB_PREFIX_SPECIAL, 0, 0, 0, NULL); |
934 } | 942 } |
935 | 943 |
936 if (flag & (LPRINT_LOG|LPRINT_DEBUG)) { | 944 if (flag & (LPRINT_LOG|LPRINT_DEBUG)) { |
937 strftime(strtimestamp, 23, "[%Y-%m-%d %H:%M:%S]", localtime(×tamp)); | 945 strftime(strtimestamp, 23, "[%Y-%m-%d %H:%M:%S]", localtime(×tamp)); |
938 buffer = g_strdup_printf("%s %s\n", strtimestamp, btext); | 946 buffer = g_strdup_printf("%s %s\n", strtimestamp, btext); |
939 ut_WriteLog(flag, buffer); | 947 ut_write_log(flag, buffer); |
940 g_free(buffer); | 948 g_free(buffer); |
941 } | 949 } |
942 g_free(btext); | 950 g_free(btext); |
943 } | 951 } |
944 | 952 |
945 static winbuf *scr_SearchWindow(const char *winId, int special) | 953 static winbuf *scr_search_window(const char *winId, int special) |
946 { | 954 { |
947 char *id; | 955 char *id; |
948 winbuf *wbp; | 956 winbuf *wbp; |
949 | 957 |
950 if (special) | 958 if (special) |
958 wbp = g_hash_table_lookup(winbufhash, id); | 966 wbp = g_hash_table_lookup(winbufhash, id); |
959 g_free(id); | 967 g_free(id); |
960 return wbp; | 968 return wbp; |
961 } | 969 } |
962 | 970 |
963 int scr_BuddyBufferExists(const char *bjid) | 971 int scr_buddy_buffer_exists(const char *bjid) |
964 { | 972 { |
965 return (scr_SearchWindow(bjid, FALSE) != NULL); | 973 return (scr_search_window(bjid, FALSE) != NULL); |
966 } | 974 } |
967 | 975 |
968 // scr_new_buddy(title, dontshow) | 976 // scr_new_buddy(title, dontshow) |
969 // Note: title (aka winId/jid) can be NULL for special buffers | 977 // Note: title (aka winId/jid) can be NULL for special buffers |
970 static winbuf *scr_new_buddy(const char *title, int dont_show) | 978 static winbuf *scr_new_buddy(const char *title, int dont_show) |
989 // If title is NULL, this is a special buffer | 997 // If title is NULL, this is a special buffer |
990 if (title) { | 998 if (title) { |
991 char *id; | 999 char *id; |
992 id = hlog_get_log_jid(title); | 1000 id = hlog_get_log_jid(title); |
993 if (id) { | 1001 if (id) { |
994 winbuf *wb = scr_SearchWindow(id, FALSE); | 1002 winbuf *wb = scr_search_window(id, FALSE); |
995 if (!wb) | 1003 if (!wb) |
996 wb = scr_new_buddy(id, TRUE); | 1004 wb = scr_new_buddy(id, TRUE); |
997 tmp->bd=wb->bd; | 1005 tmp->bd=wb->bd; |
998 g_free(id); | 1006 g_free(id); |
999 } else { // Load buddy history from file (if enabled) | 1007 } else { // Load buddy history from file (if enabled) |
1070 } else { | 1078 } else { |
1071 g_snprintf(pref, preflen, " "); | 1079 g_snprintf(pref, preflen, " "); |
1072 } | 1080 } |
1073 } | 1081 } |
1074 | 1082 |
1075 // scr_UpdateWindow() | 1083 // scr_update_window() |
1076 // (Re-)Display the given chat window. | 1084 // (Re-)Display the given chat window. |
1077 static void scr_UpdateWindow(winbuf *win_entry) | 1085 static void scr_update_window(winbuf *win_entry) |
1078 { | 1086 { |
1079 int n; | 1087 int n; |
1080 guint prefixwidth; | 1088 guint prefixwidth; |
1081 char pref[96]; | 1089 char pref[96]; |
1082 hbb_line **lines, *line; | 1090 hbb_line **lines, *line; |
1214 } | 1222 } |
1215 } | 1223 } |
1216 g_free(lines); | 1224 g_free(lines); |
1217 } | 1225 } |
1218 | 1226 |
1219 static winbuf *scr_CreateWindow(const char *winId, int special, int dont_show) | 1227 static winbuf *scr_create_window(const char *winId, int special, int dont_show) |
1220 { | 1228 { |
1221 if (special) { | 1229 if (special) { |
1222 if (!statusWindow) { | 1230 if (!statusWindow) { |
1223 statusWindow = scr_new_buddy(NULL, dont_show); | 1231 statusWindow = scr_new_buddy(NULL, dont_show); |
1224 statusWindow->bd->hbuf = statushbuf; | 1232 statusWindow->bd->hbuf = statushbuf; |
1227 } else { | 1235 } else { |
1228 return scr_new_buddy(winId, dont_show); | 1236 return scr_new_buddy(winId, dont_show); |
1229 } | 1237 } |
1230 } | 1238 } |
1231 | 1239 |
1232 // scr_ShowWindow() | 1240 // scr_show_window() |
1233 // Display the chat window with the given identifier. | 1241 // Display the chat window with the given identifier. |
1234 // "special" must be true if this is a special buffer window. | 1242 // "special" must be true if this is a special buffer window. |
1235 static void scr_ShowWindow(const char *winId, int special) | 1243 static void scr_show_window(const char *winId, int special) |
1236 { | 1244 { |
1237 winbuf *win_entry; | 1245 winbuf *win_entry; |
1238 | 1246 |
1239 win_entry = scr_SearchWindow(winId, special); | 1247 win_entry = scr_search_window(winId, special); |
1240 | 1248 |
1241 if (!win_entry) { | 1249 if (!win_entry) { |
1242 win_entry = scr_CreateWindow(winId, special, FALSE); | 1250 win_entry = scr_create_window(winId, special, FALSE); |
1243 } | 1251 } |
1244 | 1252 |
1245 top_panel(win_entry->panel); | 1253 top_panel(win_entry->panel); |
1246 currentWindow = win_entry; | 1254 currentWindow = win_entry; |
1247 chatmode = TRUE; | 1255 chatmode = TRUE; |
1250 if (!special) | 1258 if (!special) |
1251 roster_setflags(winId, ROSTER_FLAG_LOCK, TRUE); | 1259 roster_setflags(winId, ROSTER_FLAG_LOCK, TRUE); |
1252 update_roster = TRUE; | 1260 update_roster = TRUE; |
1253 | 1261 |
1254 // Refresh the window | 1262 // Refresh the window |
1255 scr_UpdateWindow(win_entry); | 1263 scr_update_window(win_entry); |
1256 | 1264 |
1257 // Finished :) | 1265 // Finished :) |
1258 update_panels(); | 1266 update_panels(); |
1259 | 1267 |
1260 top_panel(inputPanel); | 1268 top_panel(inputPanel); |
1261 } | 1269 } |
1262 | 1270 |
1263 // scr_ShowBuddyWindow() | 1271 // scr_show_buddy_window() |
1264 // Display the chat window buffer for the current buddy. | 1272 // Display the chat window buffer for the current buddy. |
1265 void scr_ShowBuddyWindow(void) | 1273 void scr_show_buddy_window(void) |
1266 { | 1274 { |
1267 const gchar *bjid; | 1275 const gchar *bjid; |
1268 | 1276 |
1269 if (!current_buddy) { | 1277 if (!current_buddy) { |
1270 bjid = NULL; | 1278 bjid = NULL; |
1271 } else { | 1279 } else { |
1272 bjid = CURRENT_JID; | 1280 bjid = CURRENT_JID; |
1273 if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL) { | 1281 if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL) { |
1274 scr_ShowWindow(buddy_getname(BUDDATA(current_buddy)), TRUE); | 1282 scr_show_window(buddy_getname(BUDDATA(current_buddy)), TRUE); |
1275 return; | 1283 return; |
1276 } | 1284 } |
1277 } | 1285 } |
1278 | 1286 |
1279 if (!bjid) { | 1287 if (!bjid) { |
1281 top_panel(inputPanel); | 1289 top_panel(inputPanel); |
1282 currentWindow = NULL; | 1290 currentWindow = NULL; |
1283 return; | 1291 return; |
1284 } | 1292 } |
1285 | 1293 |
1286 scr_ShowWindow(bjid, FALSE); | 1294 scr_show_window(bjid, FALSE); |
1287 } | 1295 } |
1288 | 1296 |
1289 // scr_UpdateBuddyWindow() | 1297 // scr_update_buddy_window() |
1290 // (Re)Display the current window. | 1298 // (Re)Display the current window. |
1291 // If chatmode is enabled, call scr_ShowBuddyWindow(), | 1299 // If chatmode is enabled, call scr_show_buddy_window(), |
1292 // else display the chat window. | 1300 // else display the chat window. |
1293 inline void scr_UpdateBuddyWindow(void) | 1301 inline void scr_update_buddy_window(void) |
1294 { | 1302 { |
1295 if (chatmode) { | 1303 if (chatmode) { |
1296 scr_ShowBuddyWindow(); | 1304 scr_show_buddy_window(); |
1297 return; | 1305 return; |
1298 } | 1306 } |
1299 | 1307 |
1300 top_panel(chatPanel); | 1308 top_panel(chatPanel); |
1301 top_panel(inputPanel); | 1309 top_panel(inputPanel); |
1302 } | 1310 } |
1303 | 1311 |
1304 // scr_WriteInWindow() | 1312 // scr_write_in_window() |
1305 // Write some text in the winId window (this usually is a jid). | 1313 // Write some text in the winId window (this usually is a jid). |
1306 // Use winId == NULL for the special status buffer. | 1314 // Use winId == NULL for the special status buffer. |
1307 // Lines are splitted when they are too long to fit in the chat window. | 1315 // Lines are splitted when they are too long to fit in the chat window. |
1308 // If this window doesn't exist, it is created. | 1316 // If this window doesn't exist, it is created. |
1309 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp, | 1317 static void scr_write_in_window(const char *winId, const char *text, |
1310 unsigned int prefix_flags, int force_show, | 1318 time_t timestamp, unsigned int prefix_flags, |
1311 unsigned mucnicklen, gpointer xep184) | 1319 int force_show, unsigned mucnicklen, |
1320 gpointer xep184) | |
1312 { | 1321 { |
1313 winbuf *win_entry; | 1322 winbuf *win_entry; |
1314 char *text_locale; | 1323 char *text_locale; |
1315 int dont_show = FALSE; | 1324 int dont_show = FALSE; |
1316 int special; | 1325 int special; |
1318 bool setmsgflg = FALSE; | 1327 bool setmsgflg = FALSE; |
1319 char *nicktmp, *nicklocaltmp; | 1328 char *nicktmp, *nicklocaltmp; |
1320 | 1329 |
1321 // Look for the window entry. | 1330 // Look for the window entry. |
1322 special = (winId == NULL); | 1331 special = (winId == NULL); |
1323 win_entry = scr_SearchWindow(winId, special); | 1332 win_entry = scr_search_window(winId, special); |
1324 | 1333 |
1325 // Do we have to really show the window? | 1334 // Do we have to really show the window? |
1326 if (!chatmode) | 1335 if (!chatmode) |
1327 dont_show = TRUE; | 1336 dont_show = TRUE; |
1328 else if ((!force_show) && ((!currentWindow || (currentWindow != win_entry)))) | 1337 else if ((!force_show) && ((!currentWindow || (currentWindow != win_entry)))) |
1329 dont_show = TRUE; | 1338 dont_show = TRUE; |
1330 | 1339 |
1331 // If the window entry doesn't exist yet, let's create it. | 1340 // If the window entry doesn't exist yet, let's create it. |
1332 if (!win_entry) { | 1341 if (!win_entry) { |
1333 win_entry = scr_CreateWindow(winId, special, dont_show); | 1342 win_entry = scr_create_window(winId, special, dont_show); |
1334 } | 1343 } |
1335 | 1344 |
1336 // The message must be displayed -> update top pointer | 1345 // The message must be displayed -> update top pointer |
1337 if (win_entry->bd->cleared) | 1346 if (win_entry->bd->cleared) |
1338 win_entry->bd->top = g_list_last(win_entry->bd->hbuf); | 1347 win_entry->bd->top = g_list_last(win_entry->bd->hbuf); |
1377 if (!dont_show) { | 1386 if (!dont_show) { |
1378 if (win_entry->bd->lock) | 1387 if (win_entry->bd->lock) |
1379 setmsgflg = TRUE; | 1388 setmsgflg = TRUE; |
1380 // Show and refresh the window | 1389 // Show and refresh the window |
1381 top_panel(win_entry->panel); | 1390 top_panel(win_entry->panel); |
1382 scr_UpdateWindow(win_entry); | 1391 scr_update_window(win_entry); |
1383 top_panel(inputPanel); | 1392 top_panel(inputPanel); |
1384 update_panels(); | 1393 update_panels(); |
1385 } else if (!(prefix_flags & HBB_PREFIX_NOFLAG)) { | 1394 } else if (!(prefix_flags & HBB_PREFIX_NOFLAG)) { |
1386 setmsgflg = TRUE; | 1395 setmsgflg = TRUE; |
1387 } | 1396 } |
1391 roster_msg_setflag(winId, special, TRUE); | 1400 roster_msg_setflag(winId, special, TRUE); |
1392 update_roster = TRUE; | 1401 update_roster = TRUE; |
1393 } | 1402 } |
1394 } | 1403 } |
1395 | 1404 |
1396 // scr_UpdateMainStatus() | 1405 // scr_update_main_status(forceupdate) |
1397 // Redraw the main (bottom) status line. | 1406 // Redraw the main (bottom) status line. |
1398 void scr_UpdateMainStatus(int forceupdate) | 1407 // You can set forceupdate to FALSE in order to optimize screen refresh |
1408 // if you call top_panel()/update_panels() later. | |
1409 void scr_update_main_status(int forceupdate) | |
1399 { | 1410 { |
1400 char *sm = from_utf8(xmpp_getstatusmsg()); | 1411 char *sm = from_utf8(xmpp_getstatusmsg()); |
1401 const char *info = settings_opt_get("info"); | 1412 const char *info = settings_opt_get("info"); |
1402 | 1413 |
1403 werase(mainstatusWnd); | 1414 werase(mainstatusWnd); |
1417 update_panels(); | 1428 update_panels(); |
1418 } | 1429 } |
1419 g_free(sm); | 1430 g_free(sm); |
1420 } | 1431 } |
1421 | 1432 |
1422 // scr_DrawMainWindow() | 1433 // scr_draw_main_window() |
1423 // Set fullinit to TRUE to also create panels. Set it to FALSE for a resize. | 1434 // Set fullinit to TRUE to also create panels. Set it to FALSE for a resize. |
1424 // | 1435 // |
1425 // I think it could be improved a _lot_ but I'm really not an ncurses | 1436 // I think it could be improved a _lot_ but I'm really not an ncurses |
1426 // expert... :-\ Mikael. | 1437 // expert... :-\ Mikael. |
1427 // | 1438 // |
1428 void scr_DrawMainWindow(unsigned int fullinit) | 1439 void scr_draw_main_window(unsigned int fullinit) |
1429 { | 1440 { |
1430 int requested_size; | 1441 int requested_size; |
1431 gchar *ver, *message; | 1442 gchar *ver, *message; |
1432 int chat_y_pos, chatstatus_y_pos, log_y_pos; | 1443 int chat_y_pos, chatstatus_y_pos, log_y_pos; |
1433 int roster_x_pos, chat_x_pos; | 1444 int roster_x_pos, chat_x_pos; |
1497 logWnd = newwin(Log_Win_Height-2, maxX, log_y_pos, 0); | 1508 logWnd = newwin(Log_Win_Height-2, maxX, log_y_pos, 0); |
1498 chatstatusWnd = newwin(1, maxX, chatstatus_y_pos, 0); | 1509 chatstatusWnd = newwin(1, maxX, chatstatus_y_pos, 0); |
1499 mainstatusWnd = newwin(1, maxX, maxY-2, 0); | 1510 mainstatusWnd = newwin(1, maxX, maxY-2, 0); |
1500 inputWnd = newwin(1, maxX, maxY-1, 0); | 1511 inputWnd = newwin(1, maxX, maxY-1, 0); |
1501 if (!rosterWnd || !chatWnd || !logWnd || !inputWnd) { | 1512 if (!rosterWnd || !chatWnd || !logWnd || !inputWnd) { |
1502 scr_TerminateCurses(); | 1513 scr_terminate_curses(); |
1503 fprintf(stderr, "Cannot create windows!\n"); | 1514 fprintf(stderr, "Cannot create windows!\n"); |
1504 exit(EXIT_FAILURE); | 1515 exit(EXIT_FAILURE); |
1505 } | 1516 } |
1506 wbkgd(rosterWnd, get_color(COLOR_GENERAL)); | 1517 wbkgd(rosterWnd, get_color(COLOR_GENERAL)); |
1507 wbkgd(chatWnd, get_color(COLOR_GENERAL)); | 1518 wbkgd(chatWnd, get_color(COLOR_GENERAL)); |
1636 { | 1647 { |
1637 struct dimensions dim; | 1648 struct dimensions dim; |
1638 | 1649 |
1639 // First, update the global variables | 1650 // First, update the global variables |
1640 getmaxyx(stdscr, maxY, maxX); | 1651 getmaxyx(stdscr, maxY, maxX); |
1641 // scr_DrawMainWindow() will take care of maxY and Log_Win_Height | 1652 // scr_draw_main_window() will take care of maxY and Log_Win_Height |
1642 | 1653 |
1643 // Make sure the cursor stays inside the window | 1654 // Make sure the cursor stays inside the window |
1644 check_offset(0); | 1655 check_offset(0); |
1645 | 1656 |
1646 // Resize windows and update panels | 1657 // Resize windows and update panels |
1647 scr_DrawMainWindow(FALSE); | 1658 scr_draw_main_window(FALSE); |
1648 | 1659 |
1649 // Resize all buddy windows | 1660 // Resize all buddy windows |
1650 dim.l = CHAT_WIN_HEIGHT; | 1661 dim.l = CHAT_WIN_HEIGHT; |
1651 dim.c = maxX - Roster_Width; | 1662 dim.c = maxX - Roster_Width; |
1652 if (dim.c < 1) | 1663 if (dim.c < 1) |
1662 // Update prev_chatwidth, now that all buffers have been resized | 1673 // Update prev_chatwidth, now that all buffers have been resized |
1663 prev_chatwidth = maxX - Roster_Width - scr_getprefixwidth(); | 1674 prev_chatwidth = maxX - Roster_Width - scr_getprefixwidth(); |
1664 | 1675 |
1665 // Refresh current buddy window | 1676 // Refresh current buddy window |
1666 if (chatmode) | 1677 if (chatmode) |
1667 scr_ShowBuddyWindow(); | 1678 scr_show_buddy_window(); |
1668 } | 1679 } |
1669 | 1680 |
1670 // scr_UpdateChatStatus(forceupdate) | 1681 // scr_update_chat_status(forceupdate) |
1671 // Redraw the buddy status bar. | 1682 // Redraw the buddy status bar. |
1672 // Set forceupdate to TRUE if update_panels() must be called. | 1683 // Set forceupdate to TRUE if update_panels() must be called. |
1673 void scr_UpdateChatStatus(int forceupdate) | 1684 void scr_update_chat_status(int forceupdate) |
1674 { | 1685 { |
1675 unsigned short btype, isgrp, ismuc, isspe; | 1686 unsigned short btype, isgrp, ismuc, isspe; |
1676 const char *btypetext = "Unknown"; | 1687 const char *btypetext = "Unknown"; |
1677 const char *fullname; | 1688 const char *fullname; |
1678 const char *msg = NULL; | 1689 const char *msg = NULL; |
1679 char status; | 1690 char status; |
1680 char *buf, *buf_locale; | 1691 char *buf, *buf_locale; |
1681 | 1692 |
1682 // Usually we need to update the bottom status line too, | 1693 // Usually we need to update the bottom status line too, |
1683 // at least to refresh the pending message flag. | 1694 // at least to refresh the pending message flag. |
1684 scr_UpdateMainStatus(FALSE); | 1695 scr_update_main_status(FALSE); |
1685 | 1696 |
1686 // Clear the line | 1697 // Clear the line |
1687 werase(chatstatusWnd); | 1698 werase(chatstatusWnd); |
1688 | 1699 |
1689 if (!current_buddy) { | 1700 if (!current_buddy) { |
1722 } | 1733 } |
1723 } | 1734 } |
1724 | 1735 |
1725 if (chatmode && !isgrp) { | 1736 if (chatmode && !isgrp) { |
1726 winbuf *win_entry; | 1737 winbuf *win_entry; |
1727 win_entry = scr_SearchWindow(buddy_getjid(BUDDATA(current_buddy)), isspe); | 1738 win_entry = scr_search_window(buddy_getjid(BUDDATA(current_buddy)), isspe); |
1728 if (win_entry && win_entry->bd->lock) | 1739 if (win_entry && win_entry->bd->lock) |
1729 mvwprintw(chatstatusWnd, 0, 0, "*"); | 1740 mvwprintw(chatstatusWnd, 0, 0, "*"); |
1730 } | 1741 } |
1731 | 1742 |
1732 if (isgrp || isspe) { | 1743 if (isgrp || isspe) { |
1815 int *p = param; | 1826 int *p = param; |
1816 if (buddylist_is_status_filtered(buddy_getstatus(rosterdata, NULL))) | 1827 if (buddylist_is_status_filtered(buddy_getstatus(rosterdata, NULL))) |
1817 *p=*p+1; | 1828 *p=*p+1; |
1818 } | 1829 } |
1819 | 1830 |
1820 // scr_DrawRoster() | 1831 // scr_draw_roster() |
1821 // Display the buddylist (not really the roster) on the screen | 1832 // Display the buddylist (not really the roster) on the screen |
1822 void scr_DrawRoster(void) | 1833 void scr_draw_roster(void) |
1823 { | 1834 { |
1824 static int offset = 0; | 1835 static int offset = 0; |
1825 char *name, *rline; | 1836 char *name, *rline; |
1826 int maxx, maxy; | 1837 int maxx, maxy; |
1827 GList *buddy; | 1838 GList *buddy; |
1841 cursor_backup = curs_set(0); | 1852 cursor_backup = curs_set(0); |
1842 | 1853 |
1843 if (!buddylist) | 1854 if (!buddylist) |
1844 offset = 0; | 1855 offset = 0; |
1845 else | 1856 else |
1846 scr_UpdateChatStatus(FALSE); | 1857 scr_update_chat_status(FALSE); |
1847 | 1858 |
1848 // Cleanup of roster window | 1859 // Cleanup of roster window |
1849 werase(rosterWnd); | 1860 werase(rosterWnd); |
1850 | 1861 |
1851 if (Roster_Width) { | 1862 if (Roster_Width) { |
2022 top_panel(inputPanel); | 2033 top_panel(inputPanel); |
2023 update_panels(); | 2034 update_panels(); |
2024 curs_set(cursor_backup); | 2035 curs_set(cursor_backup); |
2025 } | 2036 } |
2026 | 2037 |
2027 // scr_RosterVisibility(status) | 2038 // scr_roster_visibility(status) |
2028 // Set the roster visibility: | 2039 // Set the roster visibility: |
2029 // status=1 Show roster | 2040 // status=1 Show roster |
2030 // status=0 Hide roster | 2041 // status=0 Hide roster |
2031 // status=-1 Toggle roster status | 2042 // status=-1 Toggle roster status |
2032 void scr_RosterVisibility(int status) | 2043 void scr_roster_visibility(int status) |
2033 { | 2044 { |
2034 int old_roster_status = roster_hidden; | 2045 int old_roster_status = roster_hidden; |
2035 | 2046 |
2036 if (status > 0) | 2047 if (status > 0) |
2037 roster_hidden = FALSE; | 2048 roster_hidden = FALSE; |
2046 redrawwin(stdscr); | 2057 redrawwin(stdscr); |
2047 } | 2058 } |
2048 } | 2059 } |
2049 | 2060 |
2050 #ifdef HAVE_GLIB_REGEX | 2061 #ifdef HAVE_GLIB_REGEX |
2051 static inline void scr_LogUrls(const gchar *string) | 2062 static inline void scr_log_urls(const gchar *string) |
2052 { | 2063 { |
2053 GMatchInfo *match_info; | 2064 GMatchInfo *match_info; |
2054 | 2065 |
2055 g_regex_match_full(url_regex, string, -1, 0, 0, &match_info, NULL); | 2066 g_regex_match_full(url_regex, string, -1, 0, 0, &match_info, NULL); |
2056 while (g_match_info_matches(match_info)) { | 2067 while (g_match_info_matches(match_info)) { |
2061 } | 2072 } |
2062 g_match_info_free(match_info); | 2073 g_match_info_free(match_info); |
2063 } | 2074 } |
2064 #endif | 2075 #endif |
2065 | 2076 |
2066 void scr_WriteMessage(const char *bjid, const char *text, | 2077 static void scr_write_message(const char *bjid, const char *text, |
2067 time_t timestamp, guint prefix_flags, | 2078 time_t timestamp, guint prefix_flags, |
2068 unsigned mucnicklen, gpointer xep184) | 2079 unsigned mucnicklen, gpointer xep184) |
2069 { | 2080 { |
2070 char *xtext; | 2081 char *xtext; |
2071 | 2082 |
2072 if (!timestamp) timestamp = time(NULL); | 2083 if (!timestamp) timestamp = time(NULL); |
2073 | 2084 |
2074 xtext = ut_expand_tabs(text); // Expand tabs and filter out some chars | 2085 xtext = ut_expand_tabs(text); // Expand tabs and filter out some chars |
2075 | 2086 |
2076 scr_WriteInWindow(bjid, xtext, timestamp, prefix_flags, FALSE, mucnicklen, | 2087 scr_write_in_window(bjid, xtext, timestamp, prefix_flags, FALSE, mucnicklen, |
2077 xep184); | 2088 xep184); |
2078 | 2089 |
2079 if (xtext != (char*)text) | 2090 if (xtext != (char*)text) |
2080 g_free(xtext); | 2091 g_free(xtext); |
2081 } | 2092 } |
2082 | 2093 |
2089 ~HBB_PREFIX_PGPCRYPT & ~HBB_PREFIX_OTRCRYPT)) | 2100 ~HBB_PREFIX_PGPCRYPT & ~HBB_PREFIX_OTRCRYPT)) |
2090 prefix |= HBB_PREFIX_IN; | 2101 prefix |= HBB_PREFIX_IN; |
2091 | 2102 |
2092 #ifdef HAVE_GLIB_REGEX | 2103 #ifdef HAVE_GLIB_REGEX |
2093 if (url_regex) | 2104 if (url_regex) |
2094 scr_LogUrls(text); | 2105 scr_log_urls(text); |
2095 #endif | 2106 #endif |
2096 scr_WriteMessage(jidfrom, text, timestamp, prefix, mucnicklen, NULL); | 2107 scr_write_message(jidfrom, text, timestamp, prefix, mucnicklen, NULL); |
2097 } | 2108 } |
2098 | 2109 |
2099 void scr_WriteOutgoingMessage(const char *jidto, const char *text, guint prefix, | 2110 void scr_WriteOutgoingMessage(const char *jidto, const char *text, guint prefix, |
2100 gpointer xep184) | 2111 gpointer xep184) |
2101 { | 2112 { |
2102 GSList *roster_elt; | 2113 GSList *roster_elt; |
2103 roster_elt = roster_find(jidto, jidsearch, | 2114 roster_elt = roster_find(jidto, jidsearch, |
2104 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); | 2115 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); |
2105 | 2116 |
2106 scr_WriteMessage(jidto, text, | 2117 scr_write_message(jidto, text, |
2107 0, prefix|HBB_PREFIX_OUT|HBB_PREFIX_HLIGHT_OUT, 0, xep184); | 2118 0, prefix|HBB_PREFIX_OUT|HBB_PREFIX_HLIGHT_OUT, 0, xep184); |
2108 | 2119 |
2109 // Show jidto's buffer unless the buddy is not in the buddylist | 2120 // Show jidto's buffer unless the buddy is not in the buddylist |
2110 if (roster_elt && g_list_position(buddylist, roster_elt->data) != -1) | 2121 if (roster_elt && g_list_position(buddylist, roster_elt->data) != -1) |
2111 scr_ShowWindow(jidto, FALSE); | 2122 scr_show_window(jidto, FALSE); |
2112 } | 2123 } |
2113 | 2124 |
2114 void scr_RemoveReceiptFlag(const char *bjid, gpointer xep184) | 2125 void scr_remove_receipt_flag(const char *bjid, gpointer xep184) |
2115 { | 2126 { |
2116 winbuf *win_entry = scr_SearchWindow(bjid, FALSE); | 2127 winbuf *win_entry = scr_search_window(bjid, FALSE); |
2117 if (win_entry) { | 2128 if (win_entry) { |
2118 hbuf_remove_receipt(win_entry->bd->hbuf, xep184); | 2129 hbuf_remove_receipt(win_entry->bd->hbuf, xep184); |
2119 if (chatmode && (buddy_search_jid(bjid) == current_buddy)) | 2130 if (chatmode && (buddy_search_jid(bjid) == current_buddy)) |
2120 scr_UpdateBuddyWindow(); | 2131 scr_update_buddy_window(); |
2121 } | 2132 } |
2122 } | 2133 } |
2123 | 2134 |
2124 static inline void set_autoaway(bool setaway) | 2135 static inline void set_autoaway(bool setaway) |
2125 { | 2136 { |
2152 } | 2163 } |
2153 | 2164 |
2154 // set_chatstate(state) | 2165 // set_chatstate(state) |
2155 // Set the current chat state (0=active, 1=composing, 2=paused) | 2166 // Set the current chat state (0=active, 1=composing, 2=paused) |
2156 // If the chat state has changed, call xmpp_send_chatstate() | 2167 // If the chat state has changed, call xmpp_send_chatstate() |
2157 static inline void set_chatstate(int state) | 2168 static void set_chatstate(int state) |
2158 { | 2169 { |
2159 #if defined XEP0022 || defined XEP0085 | 2170 #if defined XEP0022 || defined XEP0085 |
2160 if (chatstates_disabled) | 2171 if (chatstates_disabled) |
2161 return; | 2172 return; |
2162 if (!chatmode) | 2173 if (!chatmode) |
2167 buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_USER) { | 2178 buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_USER) { |
2168 guint jep_state; | 2179 guint jep_state; |
2169 if (chatstate == 1) { | 2180 if (chatstate == 1) { |
2170 if (chatstate_timeout_id == 0) | 2181 if (chatstate_timeout_id == 0) |
2171 chatstate_timeout_id = g_timeout_add_seconds(1, | 2182 chatstate_timeout_id = g_timeout_add_seconds(1, |
2172 scr_ChatStatesTimeout, | 2183 scr_chatstates_timeout, |
2173 NULL); | 2184 NULL); |
2174 jep_state = ROSTER_EVENT_COMPOSING; | 2185 jep_state = ROSTER_EVENT_COMPOSING; |
2175 } | 2186 } |
2176 else if (chatstate == 2) | 2187 else if (chatstate == 2) |
2177 jep_state = ROSTER_EVENT_PAUSED; | 2188 jep_state = ROSTER_EVENT_PAUSED; |
2184 } | 2195 } |
2185 #endif | 2196 #endif |
2186 } | 2197 } |
2187 | 2198 |
2188 #if defined XEP0022 || defined XEP0085 | 2199 #if defined XEP0022 || defined XEP0085 |
2189 gboolean scr_ChatStatesTimeout(void) | 2200 static gboolean scr_chatstates_timeout(void) |
2190 { | 2201 { |
2191 time_t now; | 2202 time_t now; |
2192 time(&now); | 2203 time(&now); |
2193 // Check if we're currently composing... | 2204 // Check if we're currently composing... |
2194 if (chatstate != 1 || !chatstate_timestamp) { | 2205 if (chatstate != 1 || !chatstate_timestamp) { |
2221 // source will be destroyed after return | 2232 // source will be destroyed after return |
2222 autoaway_source = 0; | 2233 autoaway_source = 0; |
2223 return FALSE; | 2234 return FALSE; |
2224 } | 2235 } |
2225 | 2236 |
2226 static void scr_ReinstallAutoAwayTimeout(void) | 2237 static void scr_reinstall_autoaway_timeout(void) |
2227 { | 2238 { |
2228 unsigned int autoaway_timeout = settings_opt_get_int("autoaway"); | 2239 unsigned int autoaway_timeout = settings_opt_get_int("autoaway"); |
2229 enum imstatus cur_st = xmpp_getstatus(); | 2240 enum imstatus cur_st = xmpp_getstatus(); |
2230 if (autoaway_source) { | 2241 if (autoaway_source) { |
2231 g_source_remove(autoaway_source); | 2242 g_source_remove(autoaway_source); |
2236 scr_autoaway_timeout_callback, | 2247 scr_autoaway_timeout_callback, |
2237 NULL); | 2248 NULL); |
2238 } | 2249 } |
2239 | 2250 |
2240 // Check if we should reset autoaway timeout source | 2251 // Check if we should reset autoaway timeout source |
2241 void scr_CheckAutoAway(int activity) | 2252 void scr_check_auto_away(int activity) |
2242 { | 2253 { |
2243 if (Autoaway && activity) { | 2254 if (Autoaway && activity) { |
2244 scr_ReinstallAutoAwayTimeout(); | 2255 scr_reinstall_autoaway_timeout(); |
2245 set_autoaway(FALSE); | 2256 set_autoaway(FALSE); |
2246 } else if (activity || !autoaway_source) | 2257 } else if (activity || !autoaway_source) |
2247 scr_ReinstallAutoAwayTimeout(); | 2258 scr_reinstall_autoaway_timeout(); |
2248 } | 2259 } |
2249 | 2260 |
2250 // set_current_buddy(newbuddy) | 2261 // set_current_buddy(newbuddy) |
2251 // Set the current_buddy to newbuddy (if not NULL) | 2262 // Set the current_buddy to newbuddy (if not NULL) |
2252 // Lock the newbuddy, and unlock the previous current_buddy | 2263 // Lock the newbuddy, and unlock the previous current_buddy |
2278 if (!(buddylist_get_filter() & 1<<prev_st)) | 2289 if (!(buddylist_get_filter() & 1<<prev_st)) |
2279 buddylist_build(); | 2290 buddylist_build(); |
2280 update_roster = TRUE; | 2291 update_roster = TRUE; |
2281 } | 2292 } |
2282 | 2293 |
2283 // scr_RosterTop() | 2294 // scr_roster_top() |
2284 // Go to the first buddy in the buddylist | 2295 // Go to the first buddy in the buddylist |
2285 void scr_RosterTop(void) | 2296 void scr_roster_top(void) |
2286 { | 2297 { |
2287 set_current_buddy(buddylist); | 2298 set_current_buddy(buddylist); |
2288 if (chatmode) | 2299 if (chatmode) |
2289 scr_ShowBuddyWindow(); | 2300 scr_show_buddy_window(); |
2290 } | 2301 } |
2291 | 2302 |
2292 // scr_RosterBottom() | 2303 // scr_roster_bottom() |
2293 // Go to the last buddy in the buddylist | 2304 // Go to the last buddy in the buddylist |
2294 void scr_RosterBottom(void) | 2305 void scr_roster_bottom(void) |
2295 { | 2306 { |
2296 set_current_buddy(g_list_last(buddylist)); | 2307 set_current_buddy(g_list_last(buddylist)); |
2297 if (chatmode) | 2308 if (chatmode) |
2298 scr_ShowBuddyWindow(); | 2309 scr_show_buddy_window(); |
2299 } | 2310 } |
2300 | 2311 |
2301 // scr_RosterUpDown(updown, n) | 2312 // scr_roster_up_down(updown, n) |
2302 // Go to the nth next buddy in the buddylist | 2313 // Go to the nth next buddy in the buddylist |
2303 // (up if updown == -1, down if updown == 1) | 2314 // (up if updown == -1, down if updown == 1) |
2304 void scr_RosterUpDown(int updown, unsigned int n) | 2315 void scr_roster_up_down(int updown, unsigned int n) |
2305 { | 2316 { |
2306 unsigned int i; | 2317 unsigned int i; |
2307 | 2318 |
2308 if (updown < 0) { | 2319 if (updown < 0) { |
2309 for (i = 0; i < n; i++) | 2320 for (i = 0; i < n; i++) |
2311 } else { | 2322 } else { |
2312 for (i = 0; i < n; i++) | 2323 for (i = 0; i < n; i++) |
2313 set_current_buddy(g_list_next(current_buddy)); | 2324 set_current_buddy(g_list_next(current_buddy)); |
2314 } | 2325 } |
2315 if (chatmode) | 2326 if (chatmode) |
2316 scr_ShowBuddyWindow(); | 2327 scr_show_buddy_window(); |
2317 } | 2328 } |
2318 | 2329 |
2319 // scr_RosterPrevGroup() | 2330 // scr_roster_prev_group() |
2320 // Go to the previous group in the buddylist | 2331 // Go to the previous group in the buddylist |
2321 void scr_RosterPrevGroup(void) | 2332 void scr_roster_prev_group(void) |
2322 { | 2333 { |
2323 GList *bud; | 2334 GList *bud; |
2324 | 2335 |
2325 for (bud = current_buddy ; bud ; ) { | 2336 for (bud = current_buddy ; bud ; ) { |
2326 bud = g_list_previous(bud); | 2337 bud = g_list_previous(bud); |
2327 if (!bud) | 2338 if (!bud) |
2328 break; | 2339 break; |
2329 if (buddy_gettype(BUDDATA(bud)) & ROSTER_TYPE_GROUP) { | 2340 if (buddy_gettype(BUDDATA(bud)) & ROSTER_TYPE_GROUP) { |
2330 set_current_buddy(bud); | 2341 set_current_buddy(bud); |
2331 if (chatmode) | 2342 if (chatmode) |
2332 scr_ShowBuddyWindow(); | 2343 scr_show_buddy_window(); |
2333 break; | 2344 break; |
2334 } | 2345 } |
2335 } | 2346 } |
2336 } | 2347 } |
2337 | 2348 |
2338 // scr_RosterNextGroup() | 2349 // scr_roster_next_group() |
2339 // Go to the next group in the buddylist | 2350 // Go to the next group in the buddylist |
2340 void scr_RosterNextGroup(void) | 2351 void scr_roster_next_group(void) |
2341 { | 2352 { |
2342 GList *bud; | 2353 GList *bud; |
2343 | 2354 |
2344 for (bud = current_buddy ; bud ; ) { | 2355 for (bud = current_buddy ; bud ; ) { |
2345 bud = g_list_next(bud); | 2356 bud = g_list_next(bud); |
2346 if (!bud) | 2357 if (!bud) |
2347 break; | 2358 break; |
2348 if (buddy_gettype(BUDDATA(bud)) & ROSTER_TYPE_GROUP) { | 2359 if (buddy_gettype(BUDDATA(bud)) & ROSTER_TYPE_GROUP) { |
2349 set_current_buddy(bud); | 2360 set_current_buddy(bud); |
2350 if (chatmode) | 2361 if (chatmode) |
2351 scr_ShowBuddyWindow(); | 2362 scr_show_buddy_window(); |
2352 break; | 2363 break; |
2353 } | 2364 } |
2354 } | 2365 } |
2355 } | 2366 } |
2356 | 2367 |
2357 // scr_RosterSearch(str) | 2368 // scr_roster_search(str) |
2358 // Look forward for a buddy with jid/name containing str. | 2369 // Look forward for a buddy with jid/name containing str. |
2359 void scr_RosterSearch(char *str) | 2370 void scr_roster_search(char *str) |
2360 { | 2371 { |
2361 set_current_buddy(buddy_search(str)); | 2372 set_current_buddy(buddy_search(str)); |
2362 if (chatmode) | 2373 if (chatmode) |
2363 scr_ShowBuddyWindow(); | 2374 scr_show_buddy_window(); |
2364 } | 2375 } |
2365 | 2376 |
2366 // scr_RosterJumpJid(bjid) | 2377 // scr_roster_jump_jid(bjid) |
2367 // Jump to buddy bjid. | 2378 // Jump to buddy bjid. |
2368 // NOTE: With this function, the buddy is added to the roster if doesn't exist. | 2379 // NOTE: With this function, the buddy is added to the roster if doesn't exist. |
2369 void scr_RosterJumpJid(char *barejid) | 2380 void scr_roster_jump_jid(char *barejid) |
2370 { | 2381 { |
2371 GSList *roster_elt; | 2382 GSList *roster_elt; |
2372 // Look for an existing buddy | 2383 // Look for an existing buddy |
2373 roster_elt = roster_find(barejid, jidsearch, | 2384 roster_elt = roster_find(barejid, jidsearch, |
2374 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); | 2385 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); |
2380 buddy_setflags(BUDDATA(roster_elt), ROSTER_FLAG_LOCK, TRUE); | 2391 buddy_setflags(BUDDATA(roster_elt), ROSTER_FLAG_LOCK, TRUE); |
2381 buddylist_build(); | 2392 buddylist_build(); |
2382 // Jump to the buddy | 2393 // Jump to the buddy |
2383 set_current_buddy(buddy_search_jid(barejid)); | 2394 set_current_buddy(buddy_search_jid(barejid)); |
2384 if (chatmode) | 2395 if (chatmode) |
2385 scr_ShowBuddyWindow(); | 2396 scr_show_buddy_window(); |
2386 } | 2397 } |
2387 | 2398 |
2388 // scr_RosterUnreadMessage(next) | 2399 // scr_roster_unread_message(next) |
2389 // Go to a new message. If next is not null, try to go to the next new | 2400 // Go to a new message. If next is not null, try to go to the next new |
2390 // message. If it is not possible or if next is NULL, go to the first new | 2401 // message. If it is not possible or if next is NULL, go to the first new |
2391 // message from unread_list. | 2402 // message from unread_list. |
2392 void scr_RosterUnreadMessage(int next) | 2403 void scr_roster_unread_message(int next) |
2393 { | 2404 { |
2394 gpointer unread_ptr; | 2405 gpointer unread_ptr; |
2395 gpointer refbuddata; | 2406 gpointer refbuddata; |
2396 GList *nbuddy; | 2407 GList *nbuddy; |
2397 | 2408 |
2414 } | 2425 } |
2415 | 2426 |
2416 nbuddy = g_list_find(buddylist, unread_ptr); | 2427 nbuddy = g_list_find(buddylist, unread_ptr); |
2417 if (nbuddy) { | 2428 if (nbuddy) { |
2418 set_current_buddy(nbuddy); | 2429 set_current_buddy(nbuddy); |
2419 if (chatmode) scr_ShowBuddyWindow(); | 2430 if (chatmode) scr_show_buddy_window(); |
2420 } else | 2431 } else |
2421 scr_LogPrint(LPRINT_LOGNORM, "Error: nbuddy == NULL"); // should not happen | 2432 scr_LogPrint(LPRINT_LOGNORM, "Error: nbuddy == NULL"); // should not happen |
2422 } | 2433 } |
2423 | 2434 |
2424 // scr_RosterJumpAlternate() | 2435 // scr_roster_jump_alternate() |
2425 // Try to jump to alternate (== previous) buddy | 2436 // Try to jump to alternate (== previous) buddy |
2426 void scr_RosterJumpAlternate(void) | 2437 void scr_roster_jump_alternate(void) |
2427 { | 2438 { |
2428 if (!alternate_buddy || g_list_position(buddylist, alternate_buddy) == -1) | 2439 if (!alternate_buddy || g_list_position(buddylist, alternate_buddy) == -1) |
2429 return; | 2440 return; |
2430 set_current_buddy(alternate_buddy); | 2441 set_current_buddy(alternate_buddy); |
2431 if (chatmode) | 2442 if (chatmode) |
2432 scr_ShowBuddyWindow(); | 2443 scr_show_buddy_window(); |
2433 } | 2444 } |
2434 | 2445 |
2435 // scr_RosterDisplay(filter) | 2446 // scr_roster_display(filter) |
2436 // Set the roster filter mask. If filter is null/empty, the current | 2447 // Set the roster filter mask. If filter is null/empty, the current |
2437 // mask is displayed. | 2448 // mask is displayed. |
2438 void scr_RosterDisplay(const char *filter) | 2449 void scr_roster_display(const char *filter) |
2439 { | 2450 { |
2440 guchar status; | 2451 guchar status; |
2441 enum imstatus budstate; | 2452 enum imstatus budstate; |
2442 char strfilter[imstatus_size+1]; | 2453 char strfilter[imstatus_size+1]; |
2443 char *psfilter; | 2454 char *psfilter; |
2462 *psfilter++ = imstatus2char[budstate]; | 2473 *psfilter++ = imstatus2char[budstate]; |
2463 *psfilter = '\0'; | 2474 *psfilter = '\0'; |
2464 scr_LogPrint(LPRINT_NORMAL, "Roster status filter: %s", strfilter); | 2475 scr_LogPrint(LPRINT_NORMAL, "Roster status filter: %s", strfilter); |
2465 } | 2476 } |
2466 | 2477 |
2467 // scr_BufferScrollUpDown() | 2478 // scr_buffer_scroll_up_down() |
2468 // Scroll up/down the current buddy window, | 2479 // Scroll up/down the current buddy window, |
2469 // - half a screen if nblines is 0, | 2480 // - half a screen if nblines is 0, |
2470 // - up if updown == -1, down if updown == 1 | 2481 // - up if updown == -1, down if updown == 1 |
2471 void scr_BufferScrollUpDown(int updown, unsigned int nblines) | 2482 void scr_buffer_scroll_up_down(int updown, unsigned int nblines) |
2472 { | 2483 { |
2473 winbuf *win_entry; | 2484 winbuf *win_entry; |
2474 int n, nbl; | 2485 int n, nbl; |
2475 GList *hbuf_top; | 2486 GList *hbuf_top; |
2476 guint isspe; | 2487 guint isspe; |
2477 | 2488 |
2478 // Get win_entry | 2489 // Get win_entry |
2479 if (!current_buddy) return; | 2490 if (!current_buddy) return; |
2480 | 2491 |
2481 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; | 2492 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
2482 win_entry = scr_SearchWindow(CURRENT_JID, isspe); | 2493 win_entry = scr_search_window(CURRENT_JID, isspe); |
2483 if (!win_entry) return; | 2494 if (!win_entry) return; |
2484 | 2495 |
2485 if (!nblines) { | 2496 if (!nblines) { |
2486 // Scroll half a screen (or less) | 2497 // Scroll half a screen (or less) |
2487 nbl = CHAT_WIN_HEIGHT/2; | 2498 nbl = CHAT_WIN_HEIGHT/2; |
2513 if (!hbuf_top) | 2524 if (!hbuf_top) |
2514 win_entry->bd->top = NULL; // End reached | 2525 win_entry->bd->top = NULL; // End reached |
2515 } | 2526 } |
2516 | 2527 |
2517 // Refresh the window | 2528 // Refresh the window |
2518 scr_UpdateWindow(win_entry); | 2529 scr_update_window(win_entry); |
2519 | 2530 |
2520 // Finished :) | 2531 // Finished :) |
2521 update_panels(); | 2532 update_panels(); |
2522 } | 2533 } |
2523 | 2534 |
2524 // scr_BufferClear() | 2535 // scr_buffer_clear() |
2525 // Clear the current buddy window (used for the /clear command) | 2536 // Clear the current buddy window (used for the /clear command) |
2526 void scr_BufferClear(void) | 2537 void scr_buffer_clear(void) |
2527 { | 2538 { |
2528 winbuf *win_entry; | 2539 winbuf *win_entry; |
2529 guint isspe; | 2540 guint isspe; |
2530 | 2541 |
2531 // Get win_entry | 2542 // Get win_entry |
2532 if (!current_buddy) return; | 2543 if (!current_buddy) return; |
2533 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; | 2544 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
2534 win_entry = scr_SearchWindow(CURRENT_JID, isspe); | 2545 win_entry = scr_search_window(CURRENT_JID, isspe); |
2535 if (!win_entry) return; | 2546 if (!win_entry) return; |
2536 | 2547 |
2537 win_entry->bd->cleared = TRUE; | 2548 win_entry->bd->cleared = TRUE; |
2538 win_entry->bd->top = NULL; | 2549 win_entry->bd->top = NULL; |
2539 | 2550 |
2540 // Refresh the window | 2551 // Refresh the window |
2541 scr_UpdateWindow(win_entry); | 2552 scr_update_window(win_entry); |
2542 | 2553 |
2543 // Finished :) | 2554 // Finished :) |
2544 update_panels(); | 2555 update_panels(); |
2545 } | 2556 } |
2546 | 2557 |
2563 win_entry->bd->cleared = FALSE; | 2574 win_entry->bd->cleared = FALSE; |
2564 win_entry->bd->top = NULL; | 2575 win_entry->bd->top = NULL; |
2565 } | 2576 } |
2566 } | 2577 } |
2567 | 2578 |
2568 // scr_BufferPurge(closebuf, jid) | 2579 // scr_buffer_purge(closebuf, jid) |
2569 // Purge/Drop the current buddy buffer or jid's buffer if jid != NULL. | 2580 // Purge/Drop the current buddy buffer or jid's buffer if jid != NULL. |
2570 // If closebuf is 1, close the buffer. | 2581 // If closebuf is 1, close the buffer. |
2571 void scr_BufferPurge(int closebuf, const char *jid) | 2582 void scr_buffer_purge(int closebuf, const char *jid) |
2572 { | 2583 { |
2573 winbuf *win_entry; | 2584 winbuf *win_entry; |
2574 guint isspe; | 2585 guint isspe; |
2575 guint *p_closebuf; | 2586 guint *p_closebuf; |
2576 const char *cjid; | 2587 const char *cjid; |
2590 // Get win_entry | 2601 // Get win_entry |
2591 if (!current_buddy) return; | 2602 if (!current_buddy) return; |
2592 cjid = CURRENT_JID; | 2603 cjid = CURRENT_JID; |
2593 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; | 2604 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
2594 } | 2605 } |
2595 win_entry = scr_SearchWindow(cjid, isspe); | 2606 win_entry = scr_search_window(cjid, isspe); |
2596 if (!win_entry) return; | 2607 if (!win_entry) return; |
2597 | 2608 |
2598 if (!isspe) { | 2609 if (!isspe) { |
2599 p_closebuf = g_new(guint, 1); | 2610 p_closebuf = g_new(guint, 1); |
2600 *p_closebuf = closebuf; | 2611 *p_closebuf = closebuf; |
2618 } | 2629 } |
2619 | 2630 |
2620 update_roster = TRUE; | 2631 update_roster = TRUE; |
2621 | 2632 |
2622 // Refresh the window | 2633 // Refresh the window |
2623 scr_UpdateBuddyWindow(); | 2634 scr_update_buddy_window(); |
2624 | 2635 |
2625 // Finished :) | 2636 // Finished :) |
2626 update_panels(); | 2637 update_panels(); |
2627 } | 2638 } |
2628 | 2639 |
2629 void scr_BufferPurgeAll(int closebuf) | 2640 // scr_buffer_purge_all(closebuf) |
2641 // Purge all existing buffers. | |
2642 // If closebuf is 1, the buffers are closed. | |
2643 void scr_buffer_purge_all(int closebuf) | |
2630 { | 2644 { |
2631 guint *p_closebuf; | 2645 guint *p_closebuf; |
2632 p_closebuf = g_new(guint, 1); | 2646 p_closebuf = g_new(guint, 1); |
2633 | 2647 |
2634 *p_closebuf = closebuf; | 2648 *p_closebuf = closebuf; |
2639 scr_set_chatmode(FALSE); | 2653 scr_set_chatmode(FALSE); |
2640 currentWindow = NULL; | 2654 currentWindow = NULL; |
2641 } | 2655 } |
2642 | 2656 |
2643 // Refresh the window | 2657 // Refresh the window |
2644 scr_UpdateBuddyWindow(); | 2658 scr_update_buddy_window(); |
2645 | 2659 |
2646 // Finished :) | 2660 // Finished :) |
2647 update_panels(); | 2661 update_panels(); |
2648 } | 2662 } |
2649 | 2663 |
2650 // scr_BufferScrollLock(lock) | 2664 // scr_buffer_scroll_lock(lock) |
2651 // Lock/unlock the current buddy buffer | 2665 // Lock/unlock the current buddy buffer |
2652 // lock = 1 : lock | 2666 // lock = 1 : lock |
2653 // lock = 0 : unlock | 2667 // lock = 0 : unlock |
2654 // lock = -1: toggle lock status | 2668 // lock = -1: toggle lock status |
2655 void scr_BufferScrollLock(int lock) | 2669 void scr_buffer_scroll_lock(int lock) |
2656 { | 2670 { |
2657 winbuf *win_entry; | 2671 winbuf *win_entry; |
2658 guint isspe; | 2672 guint isspe; |
2659 | 2673 |
2660 // Get win_entry | 2674 // Get win_entry |
2661 if (!current_buddy) return; | 2675 if (!current_buddy) return; |
2662 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; | 2676 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
2663 win_entry = scr_SearchWindow(CURRENT_JID, isspe); | 2677 win_entry = scr_search_window(CURRENT_JID, isspe); |
2664 if (!win_entry) return; | 2678 if (!win_entry) return; |
2665 | 2679 |
2666 if (lock == -1) | 2680 if (lock == -1) |
2667 lock = !win_entry->bd->lock; | 2681 lock = !win_entry->bd->lock; |
2668 | 2682 |
2673 if (isspe || (buddy_getflags(BUDDATA(current_buddy)) & ROSTER_FLAG_MSG)) | 2687 if (isspe || (buddy_getflags(BUDDATA(current_buddy)) & ROSTER_FLAG_MSG)) |
2674 win_entry->bd->top = NULL; | 2688 win_entry->bd->top = NULL; |
2675 } | 2689 } |
2676 | 2690 |
2677 // If chatmode is disabled and we're at the bottom of the buffer, | 2691 // If chatmode is disabled and we're at the bottom of the buffer, |
2678 // we need to set the "top" line, so we need to call scr_ShowBuddyWindow() | 2692 // we need to set the "top" line, so we need to call scr_show_buddy_window() |
2679 // at least once. (Maybe it will cause a double refresh...) | 2693 // at least once. (Maybe it will cause a double refresh...) |
2680 if (!chatmode && !win_entry->bd->top) { | 2694 if (!chatmode && !win_entry->bd->top) { |
2681 chatmode = TRUE; | 2695 chatmode = TRUE; |
2682 scr_ShowBuddyWindow(); | 2696 scr_show_buddy_window(); |
2683 chatmode = FALSE; | 2697 chatmode = FALSE; |
2684 } | 2698 } |
2685 | 2699 |
2686 // Refresh the window | 2700 // Refresh the window |
2687 scr_UpdateBuddyWindow(); | 2701 scr_update_buddy_window(); |
2688 | 2702 |
2689 // Finished :) | 2703 // Finished :) |
2690 update_panels(); | 2704 update_panels(); |
2691 } | 2705 } |
2692 | 2706 |
2693 // scr_BufferTopBottom() | 2707 // scr_buffer_top_bottom() |
2694 // Jump to the head/tail of the current buddy window | 2708 // Jump to the head/tail of the current buddy window |
2695 // (top if topbottom == -1, bottom topbottom == 1) | 2709 // (top if topbottom == -1, bottom topbottom == 1) |
2696 void scr_BufferTopBottom(int topbottom) | 2710 void scr_buffer_top_bottom(int topbottom) |
2697 { | 2711 { |
2698 winbuf *win_entry; | 2712 winbuf *win_entry; |
2699 guint isspe; | 2713 guint isspe; |
2700 | 2714 |
2701 // Get win_entry | 2715 // Get win_entry |
2702 if (!current_buddy) return; | 2716 if (!current_buddy) return; |
2703 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; | 2717 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
2704 win_entry = scr_SearchWindow(CURRENT_JID, isspe); | 2718 win_entry = scr_search_window(CURRENT_JID, isspe); |
2705 if (!win_entry) return; | 2719 if (!win_entry) return; |
2706 | 2720 |
2707 win_entry->bd->cleared = FALSE; | 2721 win_entry->bd->cleared = FALSE; |
2708 if (topbottom == 1) | 2722 if (topbottom == 1) |
2709 win_entry->bd->top = NULL; | 2723 win_entry->bd->top = NULL; |
2710 else | 2724 else |
2711 win_entry->bd->top = g_list_first(win_entry->bd->hbuf); | 2725 win_entry->bd->top = g_list_first(win_entry->bd->hbuf); |
2712 | 2726 |
2713 // Refresh the window | 2727 // Refresh the window |
2714 scr_UpdateWindow(win_entry); | 2728 scr_update_window(win_entry); |
2715 | 2729 |
2716 // Finished :) | 2730 // Finished :) |
2717 update_panels(); | 2731 update_panels(); |
2718 } | 2732 } |
2719 | 2733 |
2720 // scr_BufferSearch(direction, text) | 2734 // scr_buffer_search(direction, text) |
2721 // Jump to the next line containing text | 2735 // Jump to the next line containing text |
2722 // (backward search if direction == -1, forward if topbottom == 1) | 2736 // (backward search if direction == -1, forward if topbottom == 1) |
2723 void scr_BufferSearch(int direction, const char *text) | 2737 void scr_buffer_search(int direction, const char *text) |
2724 { | 2738 { |
2725 winbuf *win_entry; | 2739 winbuf *win_entry; |
2726 GList *current_line, *search_res; | 2740 GList *current_line, *search_res; |
2727 guint isspe; | 2741 guint isspe; |
2728 | 2742 |
2729 // Get win_entry | 2743 // Get win_entry |
2730 if (!current_buddy) return; | 2744 if (!current_buddy) return; |
2731 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; | 2745 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
2732 win_entry = scr_SearchWindow(CURRENT_JID, isspe); | 2746 win_entry = scr_search_window(CURRENT_JID, isspe); |
2733 if (!win_entry) return; | 2747 if (!win_entry) return; |
2734 | 2748 |
2735 if (win_entry->bd->top) | 2749 if (win_entry->bd->top) |
2736 current_line = win_entry->bd->top; | 2750 current_line = win_entry->bd->top; |
2737 else | 2751 else |
2742 if (search_res) { | 2756 if (search_res) { |
2743 win_entry->bd->cleared = FALSE; | 2757 win_entry->bd->cleared = FALSE; |
2744 win_entry->bd->top = search_res; | 2758 win_entry->bd->top = search_res; |
2745 | 2759 |
2746 // Refresh the window | 2760 // Refresh the window |
2747 scr_UpdateWindow(win_entry); | 2761 scr_update_window(win_entry); |
2748 | 2762 |
2749 // Finished :) | 2763 // Finished :) |
2750 update_panels(); | 2764 update_panels(); |
2751 } else | 2765 } else |
2752 scr_LogPrint(LPRINT_NORMAL, "Search string not found"); | 2766 scr_LogPrint(LPRINT_NORMAL, "Search string not found"); |
2753 } | 2767 } |
2754 | 2768 |
2755 // scr_BufferPercent(n) | 2769 // scr_buffer_percent(n) |
2756 // Jump to the specified position in the buffer, in % | 2770 // Jump to the specified position in the buffer, in % |
2757 void scr_BufferPercent(int pc) | 2771 void scr_buffer_percent(int pc) |
2758 { | 2772 { |
2759 winbuf *win_entry; | 2773 winbuf *win_entry; |
2760 GList *search_res; | 2774 GList *search_res; |
2761 guint isspe; | 2775 guint isspe; |
2762 | 2776 |
2763 // Get win_entry | 2777 // Get win_entry |
2764 if (!current_buddy) return; | 2778 if (!current_buddy) return; |
2765 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; | 2779 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
2766 win_entry = scr_SearchWindow(CURRENT_JID, isspe); | 2780 win_entry = scr_search_window(CURRENT_JID, isspe); |
2767 if (!win_entry) return; | 2781 if (!win_entry) return; |
2768 | 2782 |
2769 if (pc < 0 || pc > 100) { | 2783 if (pc < 0 || pc > 100) { |
2770 scr_LogPrint(LPRINT_NORMAL, "Bad %% value"); | 2784 scr_LogPrint(LPRINT_NORMAL, "Bad %% value"); |
2771 return; | 2785 return; |
2775 | 2789 |
2776 win_entry->bd->cleared = FALSE; | 2790 win_entry->bd->cleared = FALSE; |
2777 win_entry->bd->top = search_res; | 2791 win_entry->bd->top = search_res; |
2778 | 2792 |
2779 // Refresh the window | 2793 // Refresh the window |
2780 scr_UpdateWindow(win_entry); | 2794 scr_update_window(win_entry); |
2781 | 2795 |
2782 // Finished :) | 2796 // Finished :) |
2783 update_panels(); | 2797 update_panels(); |
2784 } | 2798 } |
2785 | 2799 |
2786 // scr_BufferDate(t) | 2800 // scr_buffer_date(t) |
2787 // Jump to the first line after date t in the buffer | 2801 // Jump to the first line after date t in the buffer |
2788 // t is a date in seconds since `00:00:00 1970-01-01 UTC' | 2802 // t is a date in seconds since `00:00:00 1970-01-01 UTC' |
2789 void scr_BufferDate(time_t t) | 2803 void scr_buffer_date(time_t t) |
2790 { | 2804 { |
2791 winbuf *win_entry; | 2805 winbuf *win_entry; |
2792 GList *search_res; | 2806 GList *search_res; |
2793 guint isspe; | 2807 guint isspe; |
2794 | 2808 |
2795 // Get win_entry | 2809 // Get win_entry |
2796 if (!current_buddy) return; | 2810 if (!current_buddy) return; |
2797 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; | 2811 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
2798 win_entry = scr_SearchWindow(CURRENT_JID, isspe); | 2812 win_entry = scr_search_window(CURRENT_JID, isspe); |
2799 if (!win_entry) return; | 2813 if (!win_entry) return; |
2800 | 2814 |
2801 search_res = hbuf_jump_date(win_entry->bd->hbuf, t); | 2815 search_res = hbuf_jump_date(win_entry->bd->hbuf, t); |
2802 | 2816 |
2803 win_entry->bd->cleared = FALSE; | 2817 win_entry->bd->cleared = FALSE; |
2804 win_entry->bd->top = search_res; | 2818 win_entry->bd->top = search_res; |
2805 | 2819 |
2806 // Refresh the window | 2820 // Refresh the window |
2807 scr_UpdateWindow(win_entry); | 2821 scr_update_window(win_entry); |
2808 | 2822 |
2809 // Finished :) | 2823 // Finished :) |
2810 update_panels(); | 2824 update_panels(); |
2811 } | 2825 } |
2812 | 2826 |
2813 void scr_BufferDump(const char *file) | 2827 // scr_buffer_dump(filename) |
2828 // Dump the current buffer content to the specified file. | |
2829 void scr_buffer_dump(const char *file) | |
2814 { | 2830 { |
2815 char *extfname; | 2831 char *extfname; |
2816 | 2832 |
2817 if (!currentWindow) { | 2833 if (!currentWindow) { |
2818 scr_LogPrint(LPRINT_NORMAL, "No current buffer!"); | 2834 scr_LogPrint(LPRINT_NORMAL, "No current buffer!"); |
2842 | 2858 |
2843 scr_LogPrint(LPRINT_NORMAL, " %s (%u/%u)", (const char *) key, | 2859 scr_LogPrint(LPRINT_NORMAL, " %s (%u/%u)", (const char *) key, |
2844 g_list_length(head), hbuf_get_blocks_number(head)); | 2860 g_list_length(head), hbuf_get_blocks_number(head)); |
2845 } | 2861 } |
2846 | 2862 |
2847 void scr_BufferList(void) | 2863 void scr_buffer_list(void) |
2848 { | 2864 { |
2849 scr_LogPrint(LPRINT_NORMAL, "Buffer list:"); | 2865 scr_LogPrint(LPRINT_NORMAL, "Buffer list:"); |
2850 buffer_list("[status]", statusWindow, NULL); | 2866 buffer_list("[status]", statusWindow, NULL); |
2851 g_hash_table_foreach(winbufhash, buffer_list, NULL); | 2867 g_hash_table_foreach(winbufhash, buffer_list, NULL); |
2852 scr_LogPrint(LPRINT_NORMAL, "End of buffer list."); | 2868 scr_LogPrint(LPRINT_NORMAL, "End of buffer list."); |
2857 // scr_set_chatmode() | 2873 // scr_set_chatmode() |
2858 // Public function to (un)set chatmode... | 2874 // Public function to (un)set chatmode... |
2859 inline void scr_set_chatmode(int enable) | 2875 inline void scr_set_chatmode(int enable) |
2860 { | 2876 { |
2861 chatmode = enable; | 2877 chatmode = enable; |
2862 scr_UpdateChatStatus(TRUE); | 2878 scr_update_chat_status(TRUE); |
2863 } | 2879 } |
2864 | 2880 |
2865 // scr_get_chatmode() | 2881 // scr_get_chatmode() |
2866 // Public function to get chatmode state. | 2882 // Public function to get chatmode state. |
2867 inline int scr_get_chatmode(void) | 2883 inline int scr_get_chatmode(void) |
2890 if (special) | 2906 if (special) |
2891 current_id = buddy_getname(BUDDATA(current_buddy)); | 2907 current_id = buddy_getname(BUDDATA(current_buddy)); |
2892 else | 2908 else |
2893 current_id = buddy_getjid(BUDDATA(current_buddy)); | 2909 current_id = buddy_getjid(BUDDATA(current_buddy)); |
2894 if (current_id) { | 2910 if (current_id) { |
2895 winbuf *win_entry = scr_SearchWindow(current_id, special); | 2911 winbuf *win_entry = scr_search_window(current_id, special); |
2896 if (!win_entry) return; | 2912 if (!win_entry) return; |
2897 iscurrentlocked = win_entry->bd->lock; | 2913 iscurrentlocked = win_entry->bd->lock; |
2898 } | 2914 } |
2899 } else { | 2915 } else { |
2900 current_id = NULL; | 2916 current_id = NULL; |
3247 // readline_accept_line(down_history) | 3263 // readline_accept_line(down_history) |
3248 // Validate current command line. | 3264 // Validate current command line. |
3249 // If down_history is true, load the next history line. | 3265 // If down_history is true, load the next history line. |
3250 int readline_accept_line(int down_history) | 3266 int readline_accept_line(int down_history) |
3251 { | 3267 { |
3252 scr_CheckAutoAway(TRUE); | 3268 scr_check_auto_away(TRUE); |
3253 if (process_line(inputLine)) | 3269 if (process_line(inputLine)) |
3254 return 255; | 3270 return 255; |
3255 // Add line to history | 3271 // Add line to history |
3256 scr_cmdhisto_addline(inputLine); | 3272 scr_cmdhisto_addline(inputLine); |
3257 // Reset the line | 3273 // Reset the line |
3298 check_offset(0); | 3314 check_offset(0); |
3299 } | 3315 } |
3300 | 3316 |
3301 void readline_refresh_screen(void) | 3317 void readline_refresh_screen(void) |
3302 { | 3318 { |
3303 scr_CheckAutoAway(TRUE); | 3319 scr_check_auto_away(TRUE); |
3304 ParseColors(); | 3320 parse_colors(); |
3305 scr_Resize(); | 3321 scr_Resize(); |
3306 redrawwin(stdscr); | 3322 redrawwin(stdscr); |
3307 } | 3323 } |
3308 | 3324 |
3309 void readline_disable_chat_mode(guint show_roster) | 3325 void readline_disable_chat_mode(guint show_roster) |
3310 { | 3326 { |
3311 scr_CheckAutoAway(TRUE); | 3327 scr_check_auto_away(TRUE); |
3312 currentWindow = NULL; | 3328 currentWindow = NULL; |
3313 chatmode = FALSE; | 3329 chatmode = FALSE; |
3314 if (current_buddy) | 3330 if (current_buddy) |
3315 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); | 3331 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
3316 if (show_roster) | 3332 if (show_roster) |
3317 scr_RosterVisibility(1); | 3333 scr_roster_visibility(1); |
3318 scr_UpdateChatStatus(FALSE); | 3334 scr_update_chat_status(FALSE); |
3319 top_panel(chatPanel); | 3335 top_panel(chatPanel); |
3320 top_panel(inputPanel); | 3336 top_panel(inputPanel); |
3321 update_panels(); | 3337 update_panels(); |
3322 } | 3338 } |
3323 | 3339 |
3779 if (len) | 3795 if (len) |
3780 return 0; | 3796 return 0; |
3781 return c; | 3797 return c; |
3782 } | 3798 } |
3783 | 3799 |
3784 void scr_Getch(keycode *kcode) | 3800 void scr_getch(keycode *kcode) |
3785 { | 3801 { |
3786 keyseq *mks = NULL; | 3802 keyseq *mks = NULL; |
3787 int ks[MAX_KEYSEQ_LENGTH+1]; | 3803 int ks[MAX_KEYSEQ_LENGTH+1]; |
3788 int i; | 3804 int i; |
3789 | 3805 |
3864 ungetch(ks[i]); | 3880 ungetch(ks[i]); |
3865 } | 3881 } |
3866 return; | 3882 return; |
3867 } | 3883 } |
3868 | 3884 |
3869 void scr_DoUpdate(void) | 3885 void scr_do_update(void) |
3870 { | 3886 { |
3871 doupdate(); | 3887 doupdate(); |
3872 } | 3888 } |
3873 | 3889 |
3874 static int bindcommand(keycode kcode) | 3890 static int bindcommand(keycode kcode) |
3892 | 3908 |
3893 boundcmd = settings_get(SETTINGS_TYPE_BINDING, asciikey); | 3909 boundcmd = settings_get(SETTINGS_TYPE_BINDING, asciikey); |
3894 | 3910 |
3895 if (boundcmd) { | 3911 if (boundcmd) { |
3896 gchar *cmdline = from_utf8(boundcmd); | 3912 gchar *cmdline = from_utf8(boundcmd); |
3897 scr_CheckAutoAway(TRUE); | 3913 scr_check_auto_away(TRUE); |
3898 if (process_command(cmdline, TRUE)) | 3914 if (process_command(cmdline, TRUE)) |
3899 return 255; // Quit | 3915 return 255; // Quit |
3900 g_free(cmdline); | 3916 g_free(cmdline); |
3901 return 0; | 3917 return 0; |
3902 } | 3918 } |
3908 "WARNING: Compiled without full UTF-8 support!"); | 3924 "WARNING: Compiled without full UTF-8 support!"); |
3909 #endif | 3925 #endif |
3910 return -1; | 3926 return -1; |
3911 } | 3927 } |
3912 | 3928 |
3913 // process_key(key) | 3929 // scr_process_key(key) |
3914 // Handle the pressed key, in the command line (bottom). | 3930 // Handle the pressed key, in the command line (bottom). |
3915 void process_key(keycode kcode) | 3931 void scr_process_key(keycode kcode) |
3916 { | 3932 { |
3917 int key = kcode.value; | 3933 int key = kcode.value; |
3918 int display_char = FALSE; | 3934 int display_char = FALSE; |
3919 | 3935 |
3920 lock_chatstate = FALSE; | 3936 lock_chatstate = FALSE; |