X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=apps%2Firssi%2Fsrc%2Ffe-text%2Ftextbuffer-commands.c;fp=apps%2Firssi%2Fsrc%2Ffe-text%2Ftextbuffer-commands.c;h=648862e7ff62e1d9a638141f82fba8beab769bae;hb=18d69a0a1fec438e241bb4f431506ed59a34066b;hp=3636510bb2ddd9fd7d92ede76324847f127a8472;hpb=f7be6adec0248118cddde9b04522c13cd90568cd;p=silc.git diff --git a/apps/irssi/src/fe-text/textbuffer-commands.c b/apps/irssi/src/fe-text/textbuffer-commands.c index 3636510b..648862e7 100644 --- a/apps/irssi/src/fe-text/textbuffer-commands.c +++ b/apps/irssi/src/fe-text/textbuffer-commands.c @@ -13,9 +13,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "module.h" @@ -29,10 +29,6 @@ #include "printtext.h" #include "gui-windows.h" -#include "textbuffer-reformat.h" -#ifdef HAVE_CUIX -#include "cuix.h" -#endif /* SYNTAX: CLEAR [-all] [] */ static void cmd_clear(const char *data) @@ -72,12 +68,12 @@ static void cmd_window_scroll(const char *data) GUI_WINDOW_REC *gui; gui = WINDOW_GUI(active_win); - if (g_strcasecmp(data, "default") == 0) { + if (g_ascii_strcasecmp(data, "default") == 0) { gui->use_scroll = FALSE; - } else if (g_strcasecmp(data, "on") == 0) { + } else if (g_ascii_strcasecmp(data, "on") == 0) { gui->use_scroll = TRUE; gui->scroll = TRUE; - } else if (g_strcasecmp(data, "off") == 0) { + } else if (g_ascii_strcasecmp(data, "off") == 0) { gui->use_scroll = TRUE; gui->scroll = FALSE; } else if (*data != '\0') { @@ -132,6 +128,49 @@ static void cmd_scrollback_clear(const char *data) cmd_params_free(free_arg); } +/* SYNTAX: SCROLLBACK LEVELCLEAR [-all] [-level ] [] */ +static void cmd_scrollback_levelclear(const char *data) +{ + WINDOW_REC *window; + GHashTable *optlist; + char *refnum; + void *free_arg; + GSList *tmp; + int level; + char *levelarg; + + g_return_if_fail(data != NULL); + + if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS, + "scrollback levelclear", &optlist, &refnum)) return; + + levelarg = g_hash_table_lookup(optlist, "level"); + level = (levelarg == NULL || *levelarg == '\0') ? 0 : + level2bits(replace_chars(levelarg, ',', ' '), NULL); + 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; @@ -270,51 +309,34 @@ static void cmd_scrollback_end(const char *data) gui_window_scroll(active_win, view->bottom_subline); } -/* SYNTAX: SCROLLBACK REDRAW */ -static void cmd_scrollback_redraw(void) -{ - GUI_WINDOW_REC *gui; - LINE_REC *line, *next; - - gui = WINDOW_GUI(active_win); - - term_refresh_freeze(); - line = textbuffer_view_get_lines(gui->view); - while (line != NULL) { - next = line->next; - textbuffer_reformat_line(active_win, line); - line = next; - } - - gui_window_redraw(active_win); - term_refresh_thaw(); -} - static void cmd_scrollback_status(void) { GSList *tmp; - int window_kb, total_lines, total_kb; + int total_lines; + size_t window_mem, total_mem; - total_lines = 0; total_kb = 0; + total_lines = 0; total_mem = 0; for (tmp = windows; tmp != NULL; tmp = tmp->next) { WINDOW_REC *window = tmp->data; TEXT_BUFFER_VIEW_REC *view; view = WINDOW_GUI(window)->view; - window_kb = g_slist_length(view->buffer->text_chunks)* - LINE_TEXT_CHUNK_SIZE/1024; + window_mem = sizeof(TEXT_BUFFER_REC); + window_mem += g_slist_length(view->buffer->text_chunks) * + sizeof(TEXT_CHUNK_REC); + window_mem += view->buffer->lines_count * sizeof(LINE_REC); total_lines += view->buffer->lines_count; - total_kb += window_kb; + total_mem += window_mem; printtext(NULL, NULL, MSGLEVEL_CLIENTCRAP, "Window %d: %d lines, %dkB of data", window->refnum, view->buffer->lines_count, - window_kb); + (int)(window_mem / 1024)); } printtext(NULL, NULL, MSGLEVEL_CLIENTCRAP, "Total: %d lines, %dkB of data", - total_lines, total_kb); + total_lines, (int)(total_mem / 1024)); } static void sig_away_changed(SERVER_REC *server) @@ -332,40 +354,21 @@ static void sig_away_changed(SERVER_REC *server) } } -#ifdef HAVE_CUIX -static void cmd_cuix(void) -{ - if (!cuix_active) - { - /* textbuffer_view_clear(WINDOW_GUI(active_win)->view); */ - cuix_active = 1; - cuix_create(); - } else { - /* should never been called */ - /* cuix_destroy (); */ - cuix_active = 0; - /* textbuffer_view_clear(WINDOW_GUI(active_win)->view); */ - } -} -#endif - void textbuffer_commands_init(void) { 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); - command_bind("scrollback redraw", NULL, (SIGNAL_FUNC) cmd_scrollback_redraw); command_bind("scrollback status", NULL, (SIGNAL_FUNC) cmd_scrollback_status); -#ifdef HAVE_CUIX - command_bind("cuix", NULL, (SIGNAL_FUNC) cmd_cuix); -#endif command_set_options("clear", "all"); command_set_options("scrollback clear", "all"); + command_set_options("scrollback levelclear", "all -level"); signal_add("away mode changed", (SIGNAL_FUNC) sig_away_changed); } @@ -376,14 +379,11 @@ 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); - command_unbind("scrollback redraw", (SIGNAL_FUNC) cmd_scrollback_redraw); command_unbind("scrollback status", (SIGNAL_FUNC) cmd_scrollback_status); -#ifdef HAVE_CUIX - command_unbind("cuix", (SIGNAL_FUNC) cmd_cuix); -#endif signal_remove("away mode changed", (SIGNAL_FUNC) sig_away_changed); }