mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Add crapbuster-like "scrollback levelclear" command.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4420 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
541fa72f46
commit
d446ee2f6f
@ -3,10 +3,17 @@
|
||||
|
||||
/SCROLLBACK, or the default alias /SB:
|
||||
|
||||
/SB CLEAR - Clear screen, free all memory used by texts in window.
|
||||
/SB HOME - Jump to start of the buffer
|
||||
/SB END - Jump to end of the buffer
|
||||
/SB GOTO [[-|+]line#|time] - Jump to specified line or timestamp.
|
||||
/SB LEVELCLEAR
|
||||
- Remove lines with level matching one of those
|
||||
specified in scrollback_levelclear_levels.
|
||||
/SB CLEAR
|
||||
- Clear screen, free all memory used by texts in window.
|
||||
/SB HOME
|
||||
- Jump to start of the buffer.
|
||||
/SB END
|
||||
- Jump to end of the buffer.
|
||||
/SB GOTO [[-|+]line#|time]
|
||||
- Jump to specified line or timestamp.
|
||||
|
||||
See also: SET SCROLL
|
||||
|
||||
|
@ -132,6 +132,46 @@ static void cmd_scrollback_clear(const char *data)
|
||||
cmd_params_free(free_arg);
|
||||
}
|
||||
|
||||
/* SYNTAX: SCROLLBACK LEVELCLEAR [-all] [<refnum>] */
|
||||
static void cmd_scrollback_levelclear(const char *data)
|
||||
{
|
||||
WINDOW_REC *window;
|
||||
GHashTable *optlist;
|
||||
char *refnum;
|
||||
void *free_arg;
|
||||
GSList *tmp;
|
||||
int level;
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
|
||||
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS,
|
||||
"scrollback levelclear", &optlist, &refnum)) return;
|
||||
|
||||
level = settings_get_level("scrollback_levelclear_levels");
|
||||
if (level == 0) {
|
||||
cmd_params_free(free_arg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_hash_table_lookup(optlist, "all") != NULL) {
|
||||
/* clear all windows */
|
||||
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
||||
window = tmp->data;
|
||||
textbuffer_view_remove_lines_by_level(WINDOW_GUI(window)->view, level);
|
||||
}
|
||||
} else if (*refnum != '\0') {
|
||||
/* clear specified window */
|
||||
window = window_find_refnum(atoi(refnum));
|
||||
if (window != NULL)
|
||||
textbuffer_view_remove_lines_by_level(WINDOW_GUI(window)->view, level);
|
||||
} else {
|
||||
/* clear active window */
|
||||
textbuffer_view_remove_lines_by_level(WINDOW_GUI(active_win)->view, level);
|
||||
}
|
||||
|
||||
cmd_params_free(free_arg);
|
||||
}
|
||||
|
||||
static void scrollback_goto_line(int linenum)
|
||||
{
|
||||
TEXT_BUFFER_VIEW_REC *view;
|
||||
@ -351,10 +391,12 @@ static void cmd_cuix(void)
|
||||
|
||||
void textbuffer_commands_init(void)
|
||||
{
|
||||
settings_add_level("misc", "scrollback_levelclear_levels", "crap clientcrap");
|
||||
command_bind("clear", NULL, (SIGNAL_FUNC) cmd_clear);
|
||||
command_bind("window scroll", NULL, (SIGNAL_FUNC) cmd_window_scroll);
|
||||
command_bind("scrollback", NULL, (SIGNAL_FUNC) cmd_scrollback);
|
||||
command_bind("scrollback clear", NULL, (SIGNAL_FUNC) cmd_scrollback_clear);
|
||||
command_bind("scrollback levelclear", NULL, (SIGNAL_FUNC) cmd_scrollback_levelclear);
|
||||
command_bind("scrollback goto", NULL, (SIGNAL_FUNC) cmd_scrollback_goto);
|
||||
command_bind("scrollback home", NULL, (SIGNAL_FUNC) cmd_scrollback_home);
|
||||
command_bind("scrollback end", NULL, (SIGNAL_FUNC) cmd_scrollback_end);
|
||||
@ -366,6 +408,7 @@ void textbuffer_commands_init(void)
|
||||
|
||||
command_set_options("clear", "all");
|
||||
command_set_options("scrollback clear", "all");
|
||||
command_set_options("scrollback levelclear", "all");
|
||||
|
||||
signal_add("away mode changed", (SIGNAL_FUNC) sig_away_changed);
|
||||
}
|
||||
@ -376,6 +419,7 @@ void textbuffer_commands_deinit(void)
|
||||
command_unbind("window scroll", (SIGNAL_FUNC) cmd_window_scroll);
|
||||
command_unbind("scrollback", (SIGNAL_FUNC) cmd_scrollback);
|
||||
command_unbind("scrollback clear", (SIGNAL_FUNC) cmd_scrollback_clear);
|
||||
command_unbind("scrollback levelclear", (SIGNAL_FUNC) cmd_scrollback_levelclear);
|
||||
command_unbind("scrollback goto", (SIGNAL_FUNC) cmd_scrollback_goto);
|
||||
command_unbind("scrollback home", (SIGNAL_FUNC) cmd_scrollback_home);
|
||||
command_unbind("scrollback end", (SIGNAL_FUNC) cmd_scrollback_end);
|
||||
|
Loading…
Reference in New Issue
Block a user