Work around lack of dch.

pull/1/head
Nicholas Marriott 2008-12-13 17:41:49 +00:00
parent de0a3a0840
commit 75f043fedb
3 changed files with 50 additions and 5 deletions

View File

@ -1,3 +1,10 @@
13 December 2008
* Work around lack of dch. On Linux, the rxvt termcap doesn't have it (it is
lying, but we can't really start disbelieving termcaps...). This is a bit
horrible - I can see no way to do it without pretty much redrawing the whole
line, but it works...
10 December 2008
* glibc's getopt(3) is useless: it is not POSIX compliant without jumping
@ -772,7 +779,7 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
$Id: CHANGES,v 1.172 2008-12-10 20:26:41 nicm Exp $
$Id: CHANGES,v 1.173 2008-12-13 17:41:49 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

3
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.202 2008-12-10 20:25:41 nicm Exp $ */
/* $Id: tmux.h,v 1.203 2008-12-13 17:41:49 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -953,6 +953,7 @@ void tty_set_title(struct tty *, const char *);
int tty_open(struct tty *, char **);
void tty_close(struct tty *);
void tty_free(struct tty *);
void tty_write(struct tty *, struct screen *, int, ...);
void tty_vwrite(struct tty *, struct screen *s, int, va_list);
/* tty-keys.c */

43
tty.c
View File

@ -1,4 +1,4 @@
/* $Id: tty.c,v 1.53 2008-12-06 09:30:25 nicm Exp $ */
/* $Id: tty.c,v 1.54 2008-12-13 17:41:49 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -34,6 +34,8 @@ void tty_free_term(struct tty_term *);
void tty_fill_acs(struct tty *);
u_char tty_get_acs(struct tty *, u_char);
void tty_put_line(struct tty *, struct screen *, u_int, u_int, u_int);
const char *tty_strip(const char *);
void tty_raw(struct tty *, const char *);
void tty_puts(struct tty *, const char *);
@ -484,6 +486,16 @@ tty_set_title(struct tty *tty, const char *title)
tty_putc(tty, '\007');
}
void
tty_write(struct tty *tty, struct screen *s, int cmd, ...)
{
va_list ap;
va_start(ap, cmd);
tty_vwrite(tty, s, cmd, ap);
va_end(ap);
}
void
tty_vwrite(struct tty *tty, struct screen *s, int cmd, va_list ap)
{
@ -498,6 +510,24 @@ tty_vwrite(struct tty *tty, struct screen *s, int cmd, va_list ap)
tty_cmds[cmd](tty, s, ap);
}
void
tty_put_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx)
{
const struct grid_cell *gc;
struct grid_cell tc;
u_int xx;
for (xx = px; xx < px + nx; xx++) {
gc = grid_view_peek_cell(s->grid, xx, py);
if (screen_check_selection(s, xx, py)) {
memcpy(&tc, &s->sel.cell, sizeof tc);
tc.data = gc->data;
tty_write(tty, s, TTY_CELL, &tc);
} else
tty_write(tty, s, TTY_CELL, gc);
}
}
void
tty_cmd_cursorup(struct tty *tty, unused struct screen *s, va_list ap)
{
@ -596,8 +626,15 @@ tty_cmd_deletecharacter(struct tty *tty, unused struct screen *s, va_list ap)
while (ua-- > 0)
tty_puts(tty, delete_character);
} else {
while (ua-- > 0)
tty_putc(tty, '\010');
/*
* XXX assumes screen already updated! I hate this... stupid
* terms without dch...
*/
if (s->cx != screen_size_x(s) - 1) {
tty_put_line(tty, s,
s->cx, s->cy, screen_size_x(s) - s->cx);
}
tty_puts(tty, tparm(cursor_address, s->cy, s->cx));
}
}