cmd-refresh-client.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* $OpenBSD$ */
  2. /*
  3. * Copyright (c) 2007 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. * Refresh client.
  21. */
  22. enum cmd_retval cmd_refresh_client_exec(struct cmd *, struct cmd_q *);
  23. const struct cmd_entry cmd_refresh_client_entry = {
  24. .name = "refresh-client",
  25. .alias = "refresh",
  26. .args = { "C:St:", 0, 0 },
  27. .usage = "[-S] [-C size] " CMD_TARGET_CLIENT_USAGE,
  28. .tflag = CMD_CLIENT,
  29. .flags = 0,
  30. .exec = cmd_refresh_client_exec
  31. };
  32. enum cmd_retval
  33. cmd_refresh_client_exec(struct cmd *self, struct cmd_q *cmdq)
  34. {
  35. struct args *args = self->args;
  36. struct client *c = cmdq->state.c;
  37. const char *size;
  38. u_int w, h;
  39. if (args_has(args, 'C')) {
  40. if ((size = args_get(args, 'C')) == NULL) {
  41. cmdq_error(cmdq, "missing size");
  42. return (CMD_RETURN_ERROR);
  43. }
  44. if (sscanf(size, "%u,%u", &w, &h) != 2) {
  45. cmdq_error(cmdq, "bad size argument");
  46. return (CMD_RETURN_ERROR);
  47. }
  48. if (w < PANE_MINIMUM || w > 5000 ||
  49. h < PANE_MINIMUM || h > 5000) {
  50. cmdq_error(cmdq, "size too small or too big");
  51. return (CMD_RETURN_ERROR);
  52. }
  53. if (!(c->flags & CLIENT_CONTROL)) {
  54. cmdq_error(cmdq, "not a control client");
  55. return (CMD_RETURN_ERROR);
  56. }
  57. if (tty_set_size(&c->tty, w, h))
  58. recalculate_sizes();
  59. } else if (args_has(args, 'S')) {
  60. c->flags |= CLIENT_STATUSFORCE;
  61. server_status_client(c);
  62. } else {
  63. c->flags |= CLIENT_STATUSFORCE;
  64. server_redraw_client(c);
  65. }
  66. return (CMD_RETURN_NORMAL);
  67. }