int gui_color_buffer_input_cb (void *data, struct t_gui_buffer *buffer, const char *input_data) { /* make C compiler happy */ (void) data; if (string_strcasecmp (input_data, "e") == 0) { gui_color_buffer_extra_info ^= 1; gui_color_buffer_display (); } else if (string_strcasecmp (input_data, "r") == 0) { gui_color_buffer_display (); } else if (string_strcasecmp (input_data, "q") == 0) { gui_buffer_close (buffer); } else if (string_strcasecmp (input_data, "z") == 0) { gui_color_reset_pairs (); } return WEECHAT_RC_OK; }
void gui_main_loop () { struct t_hook *hook_fd_keyboard; /* catch SIGWINCH signal: redraw screen */ util_catch_signal (SIGWINCH, &gui_main_signal_sigwinch); /* hook stdin (read keyboard) */ hook_fd_keyboard = hook_fd (NULL, STDIN_FILENO, 1, 0, 0, &gui_key_read_cb, NULL); gui_window_ask_refresh (1); while (!dogechat_quit) { /* execute timer hooks */ hook_timer_exec (); /* auto reset of color pairs */ if (gui_color_pairs_auto_reset) { gui_color_reset_pairs (); gui_color_pairs_auto_reset_last = time (NULL); gui_color_pairs_auto_reset = 0; gui_color_pairs_auto_reset_pending = 1; } gui_main_refreshs (); if (gui_window_refresh_needed && !gui_window_bare_display) gui_main_refreshs (); if (gui_signal_sigwinch_received) { (void) hook_signal_send ("signal_sigwinch", DOGECHAT_HOOK_SIGNAL_STRING, NULL); gui_signal_sigwinch_received = 0; } gui_color_pairs_auto_reset_pending = 0; /* execute fd hooks */ hook_fd_exec (); } /* remove keyboard hook */ unhook (hook_fd_keyboard); }
void gui_main_loop () { struct t_hook *hook_fd_keyboard; struct timeval tv_timeout; fd_set read_fds, write_fds, except_fds; int max_fd; int ready; /* catch SIGTERM signal: quit program */ util_catch_signal (SIGTERM, &gui_main_signal_sigterm); util_catch_signal (SIGQUIT, &gui_main_signal_sigquit); /* catch SIGHUP signal: reload configuration */ util_catch_signal (SIGHUP, &gui_main_signal_sighup); /* catch SIGWINCH signal: redraw screen */ util_catch_signal (SIGWINCH, &gui_main_signal_sigwinch); /* hook stdin (read keyboard) */ hook_fd_keyboard = hook_fd (NULL, STDIN_FILENO, 1, 0, 0, &gui_key_read_cb, NULL); gui_window_ask_refresh (1); while (!weechat_quit) { /* reload config, if SIGHUP received */ if (gui_reload_config) { gui_reload_config = 0; log_printf (_("Signal SIGHUP received, reloading configuration " "files")); command_reload (NULL, NULL, 0, NULL, NULL); } /* execute hook timers */ hook_timer_exec (); /* auto reset of color pairs */ if (gui_color_pairs_auto_reset) { gui_color_reset_pairs (); gui_color_pairs_auto_reset_last = time (NULL); gui_color_pairs_auto_reset = 0; gui_color_pairs_auto_reset_pending = 1; } gui_main_refreshs (); if (gui_window_refresh_needed && !gui_window_bare_display) gui_main_refreshs (); if (gui_signal_sigwinch_received) { (void) hook_signal_send ("signal_sigwinch", WEECHAT_HOOK_SIGNAL_STRING, NULL); gui_signal_sigwinch_received = 0; } gui_color_pairs_auto_reset_pending = 0; /* wait for keyboard or network activity */ FD_ZERO (&read_fds); FD_ZERO (&write_fds); FD_ZERO (&except_fds); max_fd = hook_fd_set (&read_fds, &write_fds, &except_fds); hook_timer_time_to_next (&tv_timeout); ready = select (max_fd + 1, &read_fds, &write_fds, &except_fds, &tv_timeout); if (ready > 0) { hook_fd_exec (&read_fds, &write_fds, &except_fds); } } /* remove keyboard hook */ unhook (hook_fd_keyboard); }