mirror of
https://github.com/tmux/tmux.git
synced 2025-01-05 23:38:48 +00:00
Strip padding from terminfo strings.
This commit is contained in:
parent
74e8d47cf1
commit
a65238e98c
8
CHANGES
8
CHANGES
@ -1,3 +1,9 @@
|
|||||||
|
21 June 2008
|
||||||
|
|
||||||
|
* Strip padding out of terminfo(5) strings. Currently the padding is just
|
||||||
|
ignored, this may need to be altered if there are any software terminals
|
||||||
|
out there that actually need it.
|
||||||
|
|
||||||
20 June 2008
|
20 June 2008
|
||||||
|
|
||||||
* buffer-limit option to set maximum size of buffer stack. Default is 9.
|
* buffer-limit option to set maximum size of buffer stack. Default is 9.
|
||||||
@ -529,4 +535,4 @@
|
|||||||
(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.132 2008-06-20 18:45:35 nicm Exp $
|
$Id: CHANGES,v 1.133 2008-06-21 12:41:04 nicm Exp $
|
||||||
|
69
tty.c
69
tty.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tty.c,v 1.30 2008-06-20 06:36:01 nicm Exp $ */
|
/* $Id: tty.c,v 1.31 2008-06-21 12:41:05 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -34,6 +34,7 @@ void tty_free_term(struct tty_term *);
|
|||||||
void tty_fill_acs(struct tty *);
|
void tty_fill_acs(struct tty *);
|
||||||
u_char tty_get_acs(struct tty *, u_char);
|
u_char tty_get_acs(struct tty *, u_char);
|
||||||
|
|
||||||
|
const char *tty_strip(const char *);
|
||||||
void tty_raw(struct tty *, const char *);
|
void tty_raw(struct tty *, const char *);
|
||||||
void tty_puts(struct tty *, const char *);
|
void tty_puts(struct tty *, const char *);
|
||||||
void tty_putc(struct tty *, char);
|
void tty_putc(struct tty *, char);
|
||||||
@ -64,7 +65,7 @@ tty_open(struct tty *tty, char **cause)
|
|||||||
xasprintf(cause, "%s: %s", tty->path, strerror(errno));
|
xasprintf(cause, "%s: %s", tty->path, strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mode = fcntl(tty->fd, F_GETFL)) == -1)
|
if ((mode = fcntl(tty->fd, F_GETFL)) == -1)
|
||||||
fatal("fcntl");
|
fatal("fcntl");
|
||||||
if (fcntl(tty->fd, F_SETFL, mode|O_NONBLOCK) == -1)
|
if (fcntl(tty->fd, F_SETFL, mode|O_NONBLOCK) == -1)
|
||||||
@ -81,10 +82,6 @@ tty_open(struct tty *tty, char **cause)
|
|||||||
|
|
||||||
tty->flags = 0;
|
tty->flags = 0;
|
||||||
|
|
||||||
tty_keys_init(tty);
|
|
||||||
|
|
||||||
tty_fill_acs(tty);
|
|
||||||
|
|
||||||
if (tcgetattr(tty->fd, &tty->tio) != 0)
|
if (tcgetattr(tty->fd, &tty->tio) != 0)
|
||||||
fatal("tcgetattr failed");
|
fatal("tcgetattr failed");
|
||||||
memcpy(&tio, &tty->tio, sizeof tio);
|
memcpy(&tio, &tty->tio, sizeof tio);
|
||||||
@ -103,13 +100,26 @@ tty_open(struct tty *tty, char **cause)
|
|||||||
fatal("ioctl(TIOCFLUSH)");
|
fatal("ioctl(TIOCFLUSH)");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (init_1string != NULL)
|
||||||
|
tty_raw(tty, init_1string);
|
||||||
|
if (init_2string != NULL)
|
||||||
|
tty_raw(tty, init_2string);
|
||||||
|
if (init_3string != NULL)
|
||||||
|
tty_raw(tty, init_3string);
|
||||||
|
|
||||||
if (enter_ca_mode != NULL)
|
if (enter_ca_mode != NULL)
|
||||||
tty_puts(tty, enter_ca_mode);
|
tty_raw(tty, enter_ca_mode);
|
||||||
if (keypad_xmit != NULL)
|
if (keypad_xmit != NULL)
|
||||||
tty_puts(tty, keypad_xmit);
|
tty_raw(tty, keypad_xmit);
|
||||||
if (ena_acs != NULL)
|
if (ena_acs != NULL)
|
||||||
tty_puts(tty, ena_acs);
|
tty_raw(tty, ena_acs);
|
||||||
tty_puts(tty, clear_screen);
|
tty_raw(tty, clear_screen);
|
||||||
|
|
||||||
|
abort();
|
||||||
|
|
||||||
|
tty_keys_init(tty);
|
||||||
|
|
||||||
|
tty_fill_acs(tty);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
@ -316,16 +326,51 @@ tty_get_acs(struct tty *tty, u_char ch)
|
|||||||
return (ch);
|
return (ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
tty_strip(const char *s)
|
||||||
|
{
|
||||||
|
const char *ptr;
|
||||||
|
static char buf[BUFSIZ];
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
/* Ignore strings with no padding. */
|
||||||
|
if (strchr(s, '$') == NULL)
|
||||||
|
return (s);
|
||||||
|
|
||||||
|
len = 0;
|
||||||
|
for (ptr = s; *ptr != '\0'; ptr++) {
|
||||||
|
if (*ptr == '$' && *(ptr + 1) == '<') {
|
||||||
|
while (*ptr != '\0' && *ptr != '>')
|
||||||
|
ptr++;
|
||||||
|
if (*ptr == '>')
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf[len++] = *ptr;
|
||||||
|
if (len == (sizeof buf) - 1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
buf[len] = '\0';
|
||||||
|
|
||||||
|
return (buf);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_raw(struct tty *tty, const char *s)
|
tty_raw(struct tty *tty, const char *s)
|
||||||
{
|
{
|
||||||
write(tty->fd, s, strlen(s));
|
const char *t;
|
||||||
|
|
||||||
|
t = tty_strip(s);
|
||||||
|
write(tty->fd, t, strlen(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_puts(struct tty *tty, const char *s)
|
tty_puts(struct tty *tty, const char *s)
|
||||||
{
|
{
|
||||||
buffer_write(tty->out, s, strlen(s));
|
const char *t;
|
||||||
|
|
||||||
|
t = tty_strip(s);
|
||||||
|
buffer_write(tty->out, t, strlen(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user