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"
#include "printtext.h"
#include "gui-windows.h"
-#include "textbuffer-reformat.h"
-#ifdef HAVE_CUIX
-#include "cuix.h"
-#endif
/* SYNTAX: CLEAR [-all] [<refnum>] */
static void cmd_clear(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') {
cmd_params_free(free_arg);
}
+/* SYNTAX: SCROLLBACK LEVELCLEAR [-all] [-level <level>] [<refnum>] */
+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;
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)
}
}
-#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);
}
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);
}