From 96ca072482d56b91656b70adf4f5bde0567b53cc Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 14 May 2009 16:56:23 +0000 Subject: [PATCH] clear-history command. --- CHANGES | 3 +- TODO | 3 +- cmd-clear-history.c | 68 +++++++++++++++++++++++++++++++++++++++++++++ cmd.c | 3 +- tmux.h | 3 +- 5 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 cmd-clear-history.c diff --git a/CHANGES b/CHANGES index 4f3e3147..6388dd52 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,6 @@ 14 May 2009 +* clear-history command to clear a pane's history. * Don't force wrapping with \n when asked, let the cursor code figure it out. Should fix terminals which use this to detect line breaks. * Major cleanup and restructuring of build infrastructure. Still separate files @@ -1254,7 +1255,7 @@ (including mutt, emacs). No status bar yet and no key remapping or other customisation. -$Id: CHANGES,v 1.286 2009-05-14 16:21:54 nicm Exp $ +$Id: CHANGES,v 1.287 2009-05-14 16:56:23 nicm Exp $ LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms diff --git a/TODO b/TODO index e38da696..112f4e67 100644 --- a/TODO +++ b/TODO @@ -71,7 +71,6 @@ - a command to display the status line briefly when it is turned off - FAQ "Can I have some examples of cool things I can do with tmux?" -- linkw, more?? -- command to purge window history? or apply history-limit changes? - clone session command - make command sequences more usable: don't require space after ;, handle errors better @@ -88,3 +87,5 @@ better resizing of shells when changing layout hardcoded 81 for left-vertical is nasty - test bug sshing from freebsd console (tom iirc?) +- document clear-history + diff --git a/cmd-clear-history.c b/cmd-clear-history.c new file mode 100644 index 00000000..bf9d09de --- /dev/null +++ b/cmd-clear-history.c @@ -0,0 +1,68 @@ +/* $Id: cmd-clear-history.c,v 1.1 2009-05-14 16:56:23 nicm Exp $ */ + +/* + * Copyright (c) 2009 Nicholas Marriott + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include "tmux.h" + +/* + * Clear pane history. + */ + +void cmd_clear_history_init(struct cmd *, int); +int cmd_clear_history_exec(struct cmd *, struct cmd_ctx *); + +const struct cmd_entry cmd_clear_history_entry = { + "clear-history", "clearhist", + CMD_PANE_WINDOW_USAGE, + 0, + cmd_pane_init, + cmd_pane_parse, + cmd_clear_history_exec, + cmd_pane_send, + cmd_pane_recv, + cmd_pane_free, + cmd_pane_print +}; + +int +cmd_clear_history_exec(struct cmd *self, struct cmd_ctx *ctx) +{ + struct cmd_pane_data *data = self->data; + struct winlink *wl; + struct window_pane *wp; + struct grid *gd; + + if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) + return (-1); + if (data->pane == -1) + wp = wl->window->active; + else { + wp = window_pane_at_index(wl->window, data->pane); + if (wp == NULL) { + ctx->error(ctx, "no pane: %d", data->pane); + return (-1); + } + } + gd = wp->base.grid; + + grid_move_lines(gd, 0, gd->hsize, gd->sy); + gd->hsize = 0; + + return (0); +} diff --git a/cmd.c b/cmd.c index c9f7035f..45188cac 100644 --- a/cmd.c +++ b/cmd.c @@ -1,4 +1,4 @@ -/* $Id: cmd.c,v 1.93 2009-05-04 17:58:26 nicm Exp $ */ +/* $Id: cmd.c,v 1.94 2009-05-14 16:56:23 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -31,6 +31,7 @@ const struct cmd_entry *cmd_table[] = { &cmd_break_pane_entry, &cmd_choose_session_entry, &cmd_choose_window_entry, + &cmd_clear_history_entry, &cmd_clock_mode_entry, &cmd_command_prompt_entry, &cmd_confirm_before_entry, diff --git a/tmux.h b/tmux.h index aa637758..38e3a0f3 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.314 2009-05-13 23:27:00 nicm Exp $ */ +/* $Id: tmux.h,v 1.315 2009-05-14 16:56:23 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1205,6 +1205,7 @@ extern const struct cmd_entry cmd_bind_key_entry; extern const struct cmd_entry cmd_break_pane_entry; extern const struct cmd_entry cmd_choose_session_entry; extern const struct cmd_entry cmd_choose_window_entry; +extern const struct cmd_entry cmd_clear_history_entry; extern const struct cmd_entry cmd_clock_mode_entry; extern const struct cmd_entry cmd_command_prompt_entry; extern const struct cmd_entry cmd_confirm_before_entry;