diff options
-rw-r--r-- | CHANGES | 7 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | TODO | 6 | ||||
-rw-r--r-- | cmd-list-clients.c | 6 | ||||
-rw-r--r-- | cmd-server-info.c | 115 | ||||
-rw-r--r-- | cmd.c | 3 | ||||
-rw-r--r-- | server.c | 4 | ||||
-rw-r--r-- | tmux.c | 3 | ||||
-rw-r--r-- | tmux.h | 21 | ||||
-rw-r--r-- | tty-term.c | 24 |
10 files changed, 167 insertions, 26 deletions
@@ -1,3 +1,8 @@ +10 January 2009 + +* New command, server-info, to show some server information and terminal + details. + 09 January 2009 * Stop using ncurses variables and instead build a table of the codes we want @@ -833,7 +838,7 @@ (including mutt, emacs). No status bar yet and no key remapping or other customisation. -$Id: CHANGES,v 1.185 2009-01-09 23:57:42 nicm Exp $ +$Id: CHANGES,v 1.186 2009-01-10 01:30:38 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 @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.82 2009-01-09 23:57:42 nicm Exp $ +# $Id: Makefile,v 1.83 2009-01-10 01:30:38 nicm Exp $ .SUFFIXES: .c .o .y .h .PHONY: clean update-index.html upload-index.html @@ -35,7 +35,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \ cmd-show-window-options.c cmd-command-prompt.c cmd-set-buffer.c \ cmd-show-buffer.c cmd-list-buffers.c cmd-delete-buffer.c \ cmd-list-commands.c cmd-move-window.c cmd-select-prompt.c \ - cmd-respawn-window.c cmd-source-file.c \ + cmd-respawn-window.c cmd-source-file.c cmd-server-info.c \ window-scroll.c window-more.c window-copy.c options.c paste.c \ tty.c tty-term.c tty-keys.c tty-write.c colour.c utf8.c options-cmd.c @@ -53,11 +53,13 @@ unwrapping - OPTIONS section in man page with description of new option handling - update set/setw in man page with -g and -u flags -- document status line options, title bits -- document window options changes - more # commands in status-left,right eg #H for hostname. others? - input.c is too complicated. simplify? - try change from pass-though model to redraw model (use updated screen data). maybe too slow though? - use a better termcap internally instead of screen, perhaps xterm - tty.c is a bit ugly +- document xterm-keys +- document server-info +- document status line options, title bits +- document window options changes diff --git a/cmd-list-clients.c b/cmd-list-clients.c index c9ab802d..bef421e6 100644 --- a/cmd-list-clients.c +++ b/cmd-list-clients.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-clients.c,v 1.10 2009-01-09 16:45:58 nicm Exp $ */ +/* $Id: cmd-list-clients.c,v 1.11 2009-01-10 01:30:38 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -53,8 +53,8 @@ cmd_list_clients_exec(unused struct cmd *self, struct cmd_ctx *ctx) if (c == NULL || c->session == NULL) continue; - ctx->print(ctx, "%s: %s [%ux%u]", - c->tty.path, c->session->name, c->sx, c->sy); + ctx->print(ctx, "%s: %s [%ux%u %s]", c->tty.path, + c->session->name, c->sx, c->sy, c->tty.termname); } if (ctx->cmdclient != NULL) diff --git a/cmd-server-info.c b/cmd-server-info.c new file mode 100644 index 00000000..3f53d35c --- /dev/null +++ b/cmd-server-info.c @@ -0,0 +1,115 @@ +/* $Id: cmd-server-info.c,v 1.1 2009-01-10 01:30:38 nicm Exp $ */ + +/* + * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> + * + * 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 <sys/types.h> + +#include <stdlib.h> +#include <unistd.h> +#include <vis.h> + +#include "tmux.h" + +/* + * Show various information about server. + */ + +void cmd_server_info_exec(struct cmd *, struct cmd_ctx *); + +const struct cmd_entry cmd_server_info_entry = { + "server-info", "info", + "", + 0, + NULL, + NULL, + cmd_server_info_exec, + NULL, + NULL, + NULL, + NULL +}; + +void +cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx) +{ + struct tty_term *term; + struct client *cmdclient; + struct tty_code *code; + struct tty_term_code_entry *ent; + u_int i; + char s[BUFSIZ]; + + ctx->print(ctx, "tmux " BUILD + ", pid %ld, started %s", (long) getpid(), ctime(&start_time)); + ctx->print(ctx, "socket path %s, debug level %d%s", + socket_path, debug_level, be_quiet ? ", quiet" : ""); + if (cfg_file != NULL) + ctx->print(ctx, "configuration file %s", cfg_file); + else + ctx->print(ctx, "configuration file not specified"); + ctx->print(ctx, "%u clients, %u sessions", + ARRAY_LENGTH(&clients), ARRAY_LENGTH(&sessions)); + ctx->print(ctx, ""); + + cmdclient = ctx->cmdclient; + ctx->cmdclient = NULL; + + ctx->print(ctx, "Clients:"); + cmd_list_clients_entry.exec(self, ctx); + ctx->print(ctx, ""); + + ctx->print(ctx, "Sessions:"); + cmd_list_sessions_entry.exec(self, ctx); + ctx->print(ctx, ""); + + ctx->print(ctx, "Terminals:"); + SLIST_FOREACH(term, &tty_terms, entry) { + ctx->print(ctx, "%s [references=%u, flags=0x%x]:", + term->name, term->references, term->flags); + for (i = 0; i < NTTYCODE; i++) { + ent = &tty_term_codes[i]; + code = &term->codes[ent->code]; + switch (code->type) { + case TTYCODE_NONE: + ctx->print(ctx, " %d,%s: [missing]", + ent->code, ent->name); + break; + case TTYCODE_STRING: + strnvis( + s, code->value.string, sizeof s, VIS_OCTAL); + s[(sizeof s) - 1] = '\0'; + + ctx->print(ctx, " %d,%s: (string) %s", + ent->code, ent->name, s); + break; + case TTYCODE_NUMBER: + ctx->print(ctx, " %d,%s: (number) %d", + ent->code, ent->name, code->value.number); + break; + case TTYCODE_FLAG: + ctx->print(ctx, " %d,%s: (flag) %s", + ent->code, ent->name, + code->value.flag ? "true" : "false"); + break; + } + } + } + ctx->print(ctx, ""); + + if (cmdclient != NULL) + server_write_client(cmdclient, MSG_EXIT, NULL, 0); +} @@ -1,4 +1,4 @@ -/* $Id: cmd.c,v 1.68 2009-01-06 17:04:56 nicm Exp $ */ +/* $Id: cmd.c,v 1.69 2009-01-10 01:30:38 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -59,6 +59,7 @@ const struct cmd_entry *cmd_table[] = { &cmd_select_window_entry, &cmd_send_keys_entry, &cmd_send_prefix_entry, + &cmd_server_info_entry, &cmd_set_buffer_entry, &cmd_set_option_entry, &cmd_set_window_option_entry, @@ -1,4 +1,4 @@ -/* $Id: server.c,v 1.89 2009-01-07 22:57:03 nicm Exp $ */ +/* $Id: server.c,v 1.90 2009-01-10 01:30:38 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -118,6 +118,8 @@ server_start(const char *path) setproctitle("server (%s)", path); #endif log_debug("server started, pid %ld", (long) getpid()); + start_time = time(NULL); + socket_path = path; memset(&sa, 0, sizeof sa); sa.sun_family = AF_UNIX; @@ -1,4 +1,4 @@ -/* $Id: tmux.c,v 1.86 2009-01-09 23:57:42 nicm Exp $ */ +/* $Id: tmux.c,v 1.87 2009-01-10 01:30:38 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -53,6 +53,7 @@ struct options global_window_options; int debug_level; int be_quiet; time_t start_time; +const char *socket_path; void sighandler(int); __dead void usage(void); @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.212 2009-01-09 23:57:42 nicm Exp $ */ +/* $Id: tmux.h,v 1.213 2009-01-10 01:30:38 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -296,9 +296,8 @@ enum tty_code_code { TTYC_SMKX, /* keypad_xmit, ks */ TTYC_SMSO, /* enter_standout_mode, so */ TTYC_SMUL, /* enter_underline_mode, us */ - - NTTYCODE }; +#define NTTYCODE (TTYC_SMUL + 1) /* Termcap types. */ enum tty_code_type { @@ -317,7 +316,14 @@ struct tty_code { int flag; } value; }; - + +/* Entry in terminal code table. */ +struct tty_term_code_entry { + enum tty_code_code code; + enum tty_code_type type; + const char *name; +}; + /* Output commands. */ enum tty_cmd { TTY_BELL, @@ -678,6 +684,7 @@ struct tty_term { SLIST_ENTRY(tty_term) entry; }; +SLIST_HEAD(tty_terms, tty_term); struct tty { char *path; @@ -925,6 +932,7 @@ extern char *cfg_file; extern int debug_level; extern int be_quiet; extern time_t start_time; +extern const char *socket_path; void logfile(const char *); void siginit(void); void sigreset(void); @@ -960,7 +968,9 @@ void tty_vwrite( struct tty *, struct screen *s, enum tty_cmd, va_list); /* tty-term.c */ -struct tty_term *tty_term_find(char *, int,char **); +extern struct tty_terms tty_terms; +extern struct tty_term_code_entry tty_term_codes[NTTYCODE]; +struct tty_term *tty_term_find(char *, int, char **); void tty_term_free(struct tty_term *); int tty_term_has(struct tty_term *, enum tty_code_code); const char *tty_term_string(struct tty_term *, enum tty_code_code); @@ -1061,6 +1071,7 @@ extern const struct cmd_entry cmd_scroll_mode_entry; extern const struct cmd_entry cmd_select_window_entry; extern const struct cmd_entry cmd_send_keys_entry; extern const struct cmd_entry cmd_send_prefix_entry; +extern const struct cmd_entry cmd_server_info_entry; extern const struct cmd_entry cmd_select_prompt_entry; extern const struct cmd_entry cmd_set_buffer_entry; extern const struct cmd_entry cmd_set_option_entry; @@ -1,4 +1,4 @@ -/* $Id: tty-term.c,v 1.1 2009-01-09 23:57:42 nicm Exp $ */ +/* $Id: tty-term.c,v 1.2 2009-01-10 01:30:38 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -27,15 +27,9 @@ void tty_term_quirks(struct tty_term *); char *tty_term_strip(const char *); -SLIST_HEAD(, tty_term) tty_terms = SLIST_HEAD_INITIALIZER(tty_terms); +struct tty_terms tty_terms = SLIST_HEAD_INITIALIZER(tty_terms); -struct tty_term_code_entry { - enum tty_code_code code; - enum tty_code_type type; - const char *name; -}; - -struct tty_term_code_entry tty_term_codes[] = { +struct tty_term_code_entry tty_term_codes[NTTYCODE] = { { TTYC_AX, TTYCODE_FLAG, "AX" }, { TTYC_ACSC, TTYCODE_STRING, "acsc" }, { TTYC_BEL, TTYCODE_STRING, "bel" }, @@ -57,6 +51,7 @@ struct tty_term_code_entry tty_term_codes[] = { { TTYC_CUU, TTYCODE_STRING, "cuu" }, { TTYC_CUU1, TTYCODE_STRING, "cuu1" }, { TTYC_DCH, TTYCODE_STRING, "dch" }, + { TTYC_DCH1, TTYCODE_STRING, "dch1" }, { TTYC_DIM, TTYCODE_STRING, "dim" }, { TTYC_DL, TTYCODE_STRING, "dl" }, { TTYC_DL1, TTYCODE_STRING, "dl1" }, @@ -150,6 +145,14 @@ tty_term_quirks(struct tty_term *term) term->codes[TTYC_DCH1].value.string = xstrdup("\033[P"); } } + + if (strncmp(term->name, "xterm", 5) == 0) { + /* xterm supports ich1 but some termcaps omit it. */ + if (!tty_term_has(term, TTYC_ICH1)) { + term->codes[TTYC_ICH1].type = TTYCODE_STRING; + term->codes[TTYC_ICH1].value.string = xstrdup("\033[@"); + } + } } struct tty_term * @@ -173,6 +176,7 @@ tty_term_find(char *name, int fd, char **cause) term = xmalloc(sizeof *term); term->name = xstrdup(name); term->references = 1; + term->flags = 0; SLIST_INSERT_HEAD(&tty_terms, term, entry); /* Set up ncurses terminal. */ @@ -196,7 +200,7 @@ tty_term_find(char *name, int fd, char **cause) /* Fill in codes. */ memset(&term->codes, 0, sizeof term->codes); - for (i = 0; i < nitems(tty_term_codes); i++) { + for (i = 0; i < NTTYCODE; i++) { ent = &tty_term_codes[i]; code = &term->codes[ent->code]; |