Mercurial > hg
changeset 108:7fb72bc13732
[/trunk] Changeset 122 by mikael
* Add /clear command.
author | mikael |
---|---|
date | Fri, 22 Apr 2005 22:06:53 +0000 |
parents | 57daf8da91d1 |
children | 96d239239c7a |
files | mcabber/src/commands.c mcabber/src/screen.c mcabber/src/screen.h |
diffstat | 3 files changed, 55 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mcabber/src/commands.c Fri Apr 22 21:43:25 2005 +0000 +++ b/mcabber/src/commands.c Fri Apr 22 22:06:53 2005 +0000 @@ -31,6 +31,7 @@ // Commands callbacks void do_roster(char *arg); +void do_clear(char *arg); // Global variable for the commands list static GSList *Commands; @@ -57,9 +58,10 @@ void cmd_init(void) { //cmd_add("add"); - //cmd_add("clear"); + cmd_add("clear", "Clear the dialog window", 0, 0, &do_clear); //cmd_add("del"); //cmd_add("group"); + //cmd_add("help"); //cmd_add("info"); //cmd_add("move"); //cmd_add("nick"); @@ -217,3 +219,9 @@ } else scr_LogPrint("Unrecognized parameter!"); } + +void do_clear(char *arg) +{ + scr_Clear(); +} +
--- a/mcabber/src/screen.c Fri Apr 22 21:43:25 2005 +0000 +++ b/mcabber/src/screen.c Fri Apr 22 22:06:53 2005 +0000 @@ -24,10 +24,11 @@ typedef struct _window_entry_t { WINDOW *win; - PANEL *panel; - char *name; - GList *hbuf; - GList *top; // If top is not specified (NULL), we'll display the last lines + PANEL *panel; + char *name; + GList *hbuf; + GList *top; // If top is not specified (NULL), we'll display the last lines + char cleared; // For ex, user has issued a /clear command... struct list_head list; } window_entry_t; @@ -226,6 +227,14 @@ char **lines; GList *hbuf_head; + width = scr_WindowWidth(win_entry->win); + + // Should the window be empty? + if (win_entry->cleared) { + scr_clear_box(win_entry->win, 0, 0, CHAT_WIN_HEIGHT, width, COLOR_GENERAL); + return; + } + // win_entry->top is the top message of the screen. If it set to NULL, we // are displaying the last messages. @@ -249,7 +258,6 @@ lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT); // Display these lines - width = scr_WindowWidth(win_entry->win); wmove(win_entry->win, 0, 0); for (n = 0; n < CHAT_WIN_HEIGHT; n++) { int r = width; @@ -347,6 +355,11 @@ maxX - scr_WindowWidth(rosterWnd) - 14); free(fullprefix); + if (win_entry->cleared) { + win_entry->cleared = 0; // The message must be displayed + win_entry->top = g_list_last(win_entry->hbuf); + } + if (!dont_show) { // Show and refresh the window top_panel(win_entry->panel); @@ -674,6 +687,31 @@ doupdate(); } +void scr_Clear(void) +{ + const gchar *jid; + window_entry_t *win_entry; + + // Get win_entry + if (!current_buddy) + return; + jid = CURRENT_JID; + if (!jid) + return; + win_entry = scr_SearchWindow(jid); + if (!win_entry) + return; + + win_entry->cleared = TRUE; + + // Refresh the window + scr_UpdateWindow(win_entry); + + // Finished :) + update_panels(); + doupdate(); +} + // scr_LogPrint(...) // Display a message in the log window. void scr_LogPrint(const char *fmt, ...)
--- a/mcabber/src/screen.h Fri Apr 22 21:43:25 2005 +0000 +++ b/mcabber/src/screen.h Fri Apr 22 22:06:53 2005 +0000 @@ -34,7 +34,8 @@ int process_key(int); // For commands... -void scr_RosterTop(); -void scr_RosterBottom(); +void scr_RosterTop(void); +void scr_RosterBottom(void); +void scr_Clear(void); #endif