Restore window title handling.

This commit is contained in:
Nicholas Marriott 2007-10-01 17:37:41 +00:00
parent bfccbc67d1
commit 843779a3e0
5 changed files with 63 additions and 6 deletions

View File

@ -1,5 +1,6 @@
01 October 2007 01 October 2007
* (nicm) Restore window title handling.
* (nicm) Simple uncustomisable status line with window list. * (nicm) Simple uncustomisable status line with window list.
30 September 2007 30 September 2007
@ -84,5 +85,5 @@
(including mutt, emacs). No status bar yet and no key remapping or other (including mutt, emacs). No status bar yet and no key remapping or other
customisation. customisation.
$Id: CHANGES,v 1.19 2007-10-01 14:53:29 nicm Exp $ $Id: CHANGES,v 1.20 2007-10-01 17:37:41 nicm Exp $

2
NOTES
View File

@ -54,7 +54,7 @@ with "-s <path>" but it shouldn't normally be required.
You can set the window title (listed in -l), using the \e] escape sequence. For You can set the window title (listed in -l), using the \e] escape sequence. For
example: example:
$ echo -n \\033]0;My Title\\007 $ echo -n \\033]0\;My Title\\007
There is currently no method for setting the window name (what will eventually There is currently no method for setting the window name (what will eventually
be shown in the status bar). be shown in the status bar).

3
TODO
View File

@ -37,5 +37,6 @@
- store_attr/colr could be two-pass and avoid reverse_add/remove games - store_attr/colr could be two-pass and avoid reverse_add/remove games
- window creation/idle time - window creation/idle time
- attributes could be 8 not 16 bits - attributes could be 8 not 16 bits
- put title setting back
- profile/optimise, particularly (i suspect) input.c - profile/optimise, particularly (i suspect) input.c
- tidy up input.c a bit
- decide about customised status line

55
input.c
View File

@ -1,4 +1,4 @@
/* $Id: input.c,v 1.15 2007-10-01 14:18:42 nicm Exp $ */ /* $Id: input.c,v 1.16 2007-10-01 17:37:41 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -51,6 +51,9 @@ int input_add_argument(struct input_ctx *, u_char ch);
void *input_state_first(u_char, enum input_class, struct input_ctx *); void *input_state_first(u_char, enum input_class, struct input_ctx *);
void *input_state_escape(u_char, enum input_class, struct input_ctx *); void *input_state_escape(u_char, enum input_class, struct input_ctx *);
void *input_state_intermediate(u_char, enum input_class, struct input_ctx *); void *input_state_intermediate(u_char, enum input_class, struct input_ctx *);
void *input_state_title_first(u_char, enum input_class, struct input_ctx *);
void *input_state_title_second(u_char, enum input_class, struct input_ctx *);
void *input_state_title_next(u_char, enum input_class, struct input_ctx *);
void *input_state_sequence_first( void *input_state_sequence_first(
u_char, enum input_class, struct input_ctx *); u_char, enum input_class, struct input_ctx *);
void *input_state_sequence_next( void *input_state_sequence_next(
@ -213,6 +216,8 @@ input_state_first(u_char ch, enum input_class iclass, struct input_ctx *ictx)
ch -= 0x40; ch -= 0x40;
if (ch == '[') if (ch == '[')
return (input_state_sequence_first); return (input_state_sequence_first);
if (ch == ']')
return (input_state_title_first);
input_handle_c1_control(ch, ictx); input_handle_c1_control(ch, ictx);
break; break;
case INPUT_SPACE: case INPUT_SPACE:
@ -251,6 +256,8 @@ input_state_escape(u_char ch, enum input_class iclass, struct input_ctx *ictx)
case INPUT_UPPERCASE: case INPUT_UPPERCASE:
if (ch == '[') if (ch == '[')
return (input_state_sequence_first); return (input_state_sequence_first);
if (ch == ']')
return (input_state_title_first);
input_handle_c1_control(ch, ictx); input_handle_c1_control(ch, ictx);
break; break;
case INPUT_LOWERCASE: case INPUT_LOWERCASE:
@ -265,6 +272,51 @@ input_state_escape(u_char ch, enum input_class iclass, struct input_ctx *ictx)
return (input_state_first); return (input_state_first);
} }
void *
input_state_title_first(
u_char ch, unused enum input_class iclass, struct input_ctx *ictx)
{
if (ch >= '0' && ch <= '9') {
ictx->title_type = ch - '0';
return (input_state_title_second);
}
return (input_state_first);
}
void *
input_state_title_second(
u_char ch, unused enum input_class iclass, struct input_ctx *ictx)
{
if (ch == ';') {
ictx->title_len = 0;
return (input_state_title_next);
}
return (input_state_first);
}
void *
input_state_title_next(
u_char ch, unused enum input_class iclass, struct input_ctx *ictx)
{
if (ch == '\007') {
ictx->title_buf[ictx->title_len] = '\0';
switch (ictx->title_type) {
case 0:
strlcpy(ictx->s->title,
ictx->title_buf, sizeof ictx->s->title);
input_store_one(ictx->b, CODE_TITLE, ictx->title_len);
buffer_write(ictx->b, ictx->title_buf, ictx->title_len);
break;
}
} else if (ch >= 0x20) {
if (ictx->title_len < (sizeof ictx->title_buf) - 1) {
ictx->title_buf[ictx->title_len++] = ch;
return (input_state_title_next);
}
}
return (input_state_first);
}
void * void *
input_state_intermediate( input_state_intermediate(
u_char ch, enum input_class iclass, struct input_ctx *ictx) u_char ch, enum input_class iclass, struct input_ctx *ictx)
@ -423,7 +475,6 @@ input_handle_c1_control(u_char ch, struct input_ctx *ictx)
{ {
log_debug2("-- c1 %zu: %hhu (%c)", ictx->off, ch, ch); log_debug2("-- c1 %zu: %hhu (%c)", ictx->off, ch, ch);
/* XXX window title */
switch (ch) { switch (ch) {
case 'M': /* RI */ case 'M': /* RI */
screen_cursor_up_scroll(ictx->s); screen_cursor_up_scroll(ictx->s);

6
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.31 2007-10-01 14:53:29 nicm Exp $ */ /* $Id: tmux.h,v 1.32 2007-10-01 17:37:41 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -430,6 +430,10 @@ struct input_ctx {
struct buffer *b; struct buffer *b;
struct screen *s; struct screen *s;
u_char title_buf[MAXTITLELEN];
size_t title_len;
u_int title_type;
void *(*state)(u_char, enum input_class, struct input_ctx *); void *(*state)(u_char, enum input_class, struct input_ctx *);
u_char private; u_char private;