comparison mcabber/mcabber/screen.c @ 1942:3e39a336a992

Use guards for colors (Myhailo Danylenko) Merge patch from isbear's mcabber-experimental repository.
author Mikael Berthe <mikael@lilotux.net>
date Sun, 27 Feb 2011 18:15:27 +0100
parents a06d9eab14c5
children 518740bcd78b
comparison
equal deleted inserted replaced
1941:2256d0626730 1942:3e39a336a992
70 70
71 const char *LocaleCharSet = "C"; 71 const char *LocaleCharSet = "C";
72 72
73 static unsigned short int Log_Win_Height; 73 static unsigned short int Log_Win_Height;
74 static unsigned short int Roster_Width; 74 static unsigned short int Roster_Width;
75 static gboolean colors_stalled = FALSE;
75 76
76 // Default attention sign trigger levels 77 // Default attention sign trigger levels
77 static guint ui_attn_sign_prio_level_muc = ROSTER_UI_PRIO_MUC_HL_MESSAGE; 78 static guint ui_attn_sign_prio_level_muc = ROSTER_UI_PRIO_MUC_HL_MESSAGE;
78 static guint ui_attn_sign_prio_level = ROSTER_UI_PRIO_ATTENTION_MESSAGE; 79 static guint ui_attn_sign_prio_level = ROSTER_UI_PRIO_ATTENTION_MESSAGE;
79 80
558 *nickcols = g_new(ccolor, 1); 559 *nickcols = g_new(ccolor, 1);
559 (*nickcols)->color_pair = COLOR_GENERAL; 560 (*nickcols)->color_pair = COLOR_GENERAL;
560 (*nickcols)->color_attrib = A_NORMAL; 561 (*nickcols)->color_attrib = A_NORMAL;
561 } 562 }
562 } 563 }
564
565 colors_stalled = FALSE;
563 } 566 }
564 567
565 static void init_keycodes(void) 568 static void init_keycodes(void)
566 { 569 {
567 add_keyseq("O5A", MKEY_EQUIV, 521); // Ctrl-Up 570 add_keyseq("O5A", MKEY_EQUIV, 521); // Ctrl-Up
750 gboolean scr_curses_status(void) 753 gboolean scr_curses_status(void)
751 { 754 {
752 return Curses; 755 return Curses;
753 } 756 }
754 757
758 static gchar *scr_color_guard(const gchar *key, const gchar *new_value)
759 {
760 if (g_strcmp0(settings_opt_get(key), new_value))
761 colors_stalled = TRUE;
762 return g_strdup(new_value);
763 }
764
755 void scr_init_curses(void) 765 void scr_init_curses(void)
756 { 766 {
757 /* Key sequences initialization */ 767 /* Key sequences initialization */
758 init_keycodes(); 768 init_keycodes();
759 769
776 scr_LogPrint(LPRINT_LOGNORM, "ERROR: no ESCDELAY support."); 786 scr_LogPrint(LPRINT_LOGNORM, "ERROR: no ESCDELAY support.");
777 #endif 787 #endif
778 } 788 }
779 789
780 parse_colors(); 790 parse_colors();
791
792 settings_set_guard("color_background", scr_color_guard);
793 settings_set_guard("color_general", scr_color_guard);
794 settings_set_guard("color_info", scr_color_guard);
795 settings_set_guard("color_msgin", scr_color_guard);
796 settings_set_guard("color_msgout", scr_color_guard);
797 settings_set_guard("color_msghl", scr_color_guard);
798 settings_set_guard("color_bgstatus", scr_color_guard);
799 settings_set_guard("color_status", scr_color_guard);
800 settings_set_guard("color_roster", scr_color_guard);
801 settings_set_guard("color_bgrostersel", scr_color_guard);
802 settings_set_guard("color_rostersel", scr_color_guard);
803 settings_set_guard("color_rosterselmsg", scr_color_guard);
804 settings_set_guard("color_rosternewmsg", scr_color_guard);
781 805
782 getmaxyx(stdscr, maxY, maxX); 806 getmaxyx(stdscr, maxY, maxX);
783 Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT; 807 Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT;
784 // Note scr_draw_main_window() should be called early after scr_init_curses() 808 // Note scr_draw_main_window() should be called early after scr_init_curses()
785 // to update Log_Win_Height and set max{X,Y} 809 // to update Log_Win_Height and set max{X,Y}
3968 return; 3992 return;
3969 } 3993 }
3970 3994
3971 void scr_do_update(void) 3995 void scr_do_update(void)
3972 { 3996 {
3997 if (colors_stalled)
3998 parse_colors();
3973 doupdate(); 3999 doupdate();
3974 } 4000 }
3975 4001
3976 static int bindcommand(keycode kcode) 4002 static int bindcommand(keycode kcode)
3977 { 4003 {