cmd-clear-history.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* $OpenBSD$ */
  2. /*
  3. * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
  4. *
  5. * Permission to use, copy, modify, and distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
  14. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  15. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #include <sys/types.h>
  18. #include "tmux.h"
  19. /*
  20. * Clear pane history.
  21. */
  22. enum cmd_retval cmd_clear_history_exec(struct cmd *, struct cmd_q *);
  23. const struct cmd_entry cmd_clear_history_entry = {
  24. .name = "clear-history",
  25. .alias = "clearhist",
  26. .args = { "t:", 0, 0 },
  27. .usage = CMD_TARGET_PANE_USAGE,
  28. .tflag = CMD_PANE,
  29. .flags = 0,
  30. .exec = cmd_clear_history_exec
  31. };
  32. enum cmd_retval
  33. cmd_clear_history_exec(__unused struct cmd *self, struct cmd_q *cmdq)
  34. {
  35. struct window_pane *wp = cmdq->state.tflag.wp;
  36. struct grid *gd;
  37. gd = cmdq->state.tflag.wp->base.grid;
  38. if (wp->mode == &window_copy_mode)
  39. window_pane_reset_mode(wp);
  40. grid_clear_history(gd);
  41. return (CMD_RETURN_NORMAL);
  42. }