mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-08 01:04:06 +01:00
Handle DSR for resize(1).
This commit is contained in:
parent
e21587864a
commit
ebeb14211d
3
CHANGES
3
CHANGES
@ -1,5 +1,6 @@
|
||||
24 October 2007
|
||||
|
||||
* (nicm) Support for \e6n to request cursor position. resize(1) now works.
|
||||
* (nicm) Support for \e7, \e8 save/restore cursor and attribute sequences.
|
||||
Currently don't save mode (probably should). Also change some cases where
|
||||
out-of-bound values are ignored to limit them to within range (there are
|
||||
@ -158,5 +159,5 @@
|
||||
(including mutt, emacs). No status bar yet and no key remapping or other
|
||||
customisation.
|
||||
|
||||
$Id: CHANGES,v 1.49 2007-10-24 15:01:23 nicm Exp $
|
||||
$Id: CHANGES,v 1.50 2007-10-24 15:29:27 nicm Exp $
|
||||
|
||||
|
59
input.c
59
input.c
@ -1,4 +1,4 @@
|
||||
/* $Id: input.c,v 1.26 2007-10-24 15:01:25 nicm Exp $ */
|
||||
/* $Id: input.c,v 1.27 2007-10-24 15:29:28 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -73,6 +73,7 @@ void input_handle_sequence_sm(struct input_ctx *);
|
||||
void input_handle_sequence_rm(struct input_ctx *);
|
||||
void input_handle_sequence_decstbm(struct input_ctx *);
|
||||
void input_handle_sequence_sgr(struct input_ctx *);
|
||||
void input_handle_sequence_dsr(struct input_ctx *);
|
||||
|
||||
int
|
||||
input_new_argument(struct input_ctx *ictx)
|
||||
@ -124,32 +125,35 @@ input_get_argument(struct input_ctx *ictx, u_int i, uint16_t *n, uint16_t d)
|
||||
}
|
||||
|
||||
void
|
||||
input_init(struct input_ctx *ictx, struct screen *s)
|
||||
input_init(struct window *w)
|
||||
{
|
||||
ictx->s = s;
|
||||
ARRAY_INIT(&w->ictx.args);
|
||||
|
||||
ARRAY_INIT(&ictx->args);
|
||||
|
||||
ictx->state = input_state_first;
|
||||
w->ictx.state = input_state_first;
|
||||
}
|
||||
|
||||
void
|
||||
input_free(struct input_ctx *ictx)
|
||||
input_free(struct window *w)
|
||||
{
|
||||
ARRAY_FREE(&ictx->args);
|
||||
ARRAY_FREE(&w->ictx.args);
|
||||
}
|
||||
|
||||
void
|
||||
input_parse(struct input_ctx *ictx, u_char *buf, size_t len, struct buffer *b)
|
||||
input_parse(struct window *w, struct buffer *b)
|
||||
{
|
||||
u_char ch;
|
||||
struct input_ctx *ictx = &w->ictx;
|
||||
u_char ch;
|
||||
|
||||
ictx->buf = buf;
|
||||
ictx->len = len;
|
||||
if (BUFFER_USED(w->in) == 0)
|
||||
return;
|
||||
|
||||
ictx->buf = BUFFER_OUT(w->in);
|
||||
ictx->len = BUFFER_USED(w->in);
|
||||
ictx->off = 0;
|
||||
|
||||
ictx->w = w;
|
||||
ictx->s = &w->screen;
|
||||
ictx->b = b;
|
||||
ictx->flags = 0;
|
||||
|
||||
log_debug2("entry; buffer=%zu", ictx->len);
|
||||
|
||||
@ -157,6 +161,8 @@ input_parse(struct input_ctx *ictx, u_char *buf, size_t len, struct buffer *b)
|
||||
ch = ictx->buf[ictx->off++];
|
||||
ictx->state = ictx->state(ch, ictx);
|
||||
}
|
||||
|
||||
buffer_remove(w->in, ictx->len);
|
||||
}
|
||||
|
||||
void *
|
||||
@ -389,7 +395,7 @@ input_handle_c0_control(u_char ch, struct input_ctx *ictx)
|
||||
ictx->s->cx = 0;
|
||||
break;
|
||||
case '\007': /* BELL */
|
||||
ictx->flags |= INPUT_BELL;
|
||||
ictx->w->flags |= WINDOW_BELL;
|
||||
return;
|
||||
case '\010': /* BS */
|
||||
if (ictx->s->cx > 0)
|
||||
@ -493,6 +499,7 @@ input_handle_sequence(u_char ch, struct input_ctx *ictx)
|
||||
{ 'h', input_handle_sequence_sm },
|
||||
{ 'l', input_handle_sequence_rm },
|
||||
{ 'm', input_handle_sequence_sgr },
|
||||
{ 'n', input_handle_sequence_dsr },
|
||||
{ 'r', input_handle_sequence_decstbm },
|
||||
};
|
||||
u_int i;
|
||||
@ -929,6 +936,30 @@ input_handle_sequence_rm(struct input_ctx *ictx)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
input_handle_sequence_dsr(struct input_ctx *ictx)
|
||||
{
|
||||
uint16_t n;
|
||||
char reply[32];
|
||||
|
||||
if (ARRAY_LENGTH(&ictx->args) > 1)
|
||||
return;
|
||||
if (input_get_argument(ictx, 0, &n, 0) != 0)
|
||||
return;
|
||||
|
||||
if (ictx->private == '\0') {
|
||||
switch (n) {
|
||||
case 6: /* cursor position */
|
||||
xsnprintf(reply, sizeof reply,
|
||||
"\033[%u;%uR", ictx->s->cy + 1, ictx->s->cx + 1);
|
||||
log_debug("cursor request, reply: %s", reply);
|
||||
buffer_write(ictx->w->out, reply, strlen(reply));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
input_handle_sequence_decstbm(struct input_ctx *ictx)
|
||||
{
|
||||
|
18
tmux.h
18
tmux.h
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.h,v 1.67 2007-10-24 15:01:25 nicm Exp $ */
|
||||
/* $Id: tmux.h,v 1.68 2007-10-24 15:29:28 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -368,15 +368,15 @@ struct input_arg {
|
||||
|
||||
/* Input parser context. */
|
||||
struct input_ctx {
|
||||
struct window *w;
|
||||
struct buffer *b;
|
||||
struct screen *s;
|
||||
|
||||
u_char *buf;
|
||||
size_t len;
|
||||
size_t off;
|
||||
|
||||
int flags;
|
||||
#define INPUT_BELL 0x1
|
||||
|
||||
struct buffer *b;
|
||||
struct screen *s;
|
||||
struct buffer *replyb; /* replies to information requests */
|
||||
|
||||
u_char title_buf[MAXTITLELEN];
|
||||
size_t title_len;
|
||||
@ -616,9 +616,9 @@ void status_write(struct client *c);
|
||||
void recalculate_sizes(void);
|
||||
|
||||
/* input.c */
|
||||
void input_init(struct input_ctx *, struct screen *);
|
||||
void input_free(struct input_ctx *);
|
||||
void input_parse(struct input_ctx *, u_char *, size_t, struct buffer *);
|
||||
void input_init(struct window *);
|
||||
void input_free(struct window *);
|
||||
void input_parse(struct window *, struct buffer *);
|
||||
uint8_t input_extract8(struct buffer *);
|
||||
uint16_t input_extract16(struct buffer *);
|
||||
void input_store8(struct buffer *, uint8_t);
|
||||
|
28
window.c
28
window.c
@ -1,4 +1,4 @@
|
||||
/* $Id: window.c,v 1.22 2007-10-24 11:30:02 nicm Exp $ */
|
||||
/* $Id: window.c,v 1.23 2007-10-24 15:29:29 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -101,7 +101,7 @@ window_create(
|
||||
w->in = buffer_create(BUFSIZ);
|
||||
w->out = buffer_create(BUFSIZ);
|
||||
screen_create(&w->screen, sx, sy);
|
||||
input_init(&w->ictx, &w->screen);
|
||||
input_init(w);
|
||||
|
||||
if (name == NULL) {
|
||||
/* XXX */
|
||||
@ -182,7 +182,7 @@ window_destroy(struct window *w)
|
||||
{
|
||||
close(w->fd);
|
||||
|
||||
input_free(&w->ictx);
|
||||
input_free(w);
|
||||
|
||||
screen_destroy(&w->screen);
|
||||
|
||||
@ -303,27 +303,9 @@ window_key(struct window *w, int key)
|
||||
input_translate_key(w->out, key);
|
||||
}
|
||||
|
||||
/*
|
||||
* Process window output. Output is translated into a series of escape
|
||||
* sequences and strings and returned.
|
||||
*/
|
||||
/* Process output data from child process. */
|
||||
void
|
||||
window_data(struct window *w, struct buffer *b)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
if (BUFFER_USED(w->in) == 0)
|
||||
return;
|
||||
|
||||
if (debug_level > 2) {
|
||||
f = fopen("tmux-in.log", "a+");
|
||||
fwrite(BUFFER_OUT(w->in), BUFFER_USED(w->in), 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
input_parse(&w->ictx, BUFFER_OUT(w->in), BUFFER_USED(w->in), b);
|
||||
buffer_remove(w->in, BUFFER_USED(w->in));
|
||||
|
||||
if (INPUT_FLAGS(&w->ictx) & INPUT_BELL)
|
||||
w->flags |= WINDOW_BELL;
|
||||
input_parse(w, b);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user