aboutsummaryrefslogtreecommitdiff
path: root/tty.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-01-27 21:39:15 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-01-27 21:39:15 +0000
commitc1726281c925cbc0b6828a4cf41f7a300afc5901 (patch)
tree2025cffae566f7a883a38cc9b4eccbe13f65a8ee /tty.c
parenteafc1693aeb41c22fa7980711f3a89ff2d098cdb (diff)
downloadrtmux-c1726281c925cbc0b6828a4cf41f7a300afc5901.tar.gz
rtmux-c1726281c925cbc0b6828a4cf41f7a300afc5901.tar.bz2
rtmux-c1726281c925cbc0b6828a4cf41f7a300afc5901.zip
Handle cursor on/off better.
Diffstat (limited to 'tty.c')
-rw-r--r--tty.c70
1 files changed, 25 insertions, 45 deletions
diff --git a/tty.c b/tty.c
index 0aee1016..cd0a68c7 100644
--- a/tty.c
+++ b/tty.c
@@ -1,4 +1,4 @@
-/* $Id: tty.c,v 1.62 2009-01-19 19:01:11 nicm Exp $ */
+/* $Id: tty.c,v 1.63 2009-01-27 21:39:15 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -50,14 +50,11 @@ void tty_cmd_clearline(struct tty *, struct screen *, u_int, va_list);
void tty_cmd_clearscreen(struct tty *, struct screen *, u_int, va_list);
void tty_cmd_clearstartofline(struct tty *, struct screen *, u_int, va_list);
void tty_cmd_clearstartofscreen(struct tty *, struct screen *, u_int, va_list);
-void tty_cmd_cursormode(struct tty *, struct screen *, u_int, va_list);
void tty_cmd_deletecharacter(struct tty *, struct screen *, u_int, va_list);
void tty_cmd_deleteline(struct tty *, struct screen *, u_int, va_list);
void tty_cmd_insertcharacter(struct tty *, struct screen *, u_int, va_list);
void tty_cmd_insertline(struct tty *, struct screen *, u_int, va_list);
void tty_cmd_insertmode(struct tty *, struct screen *, u_int, va_list);
-void tty_cmd_kcursormode(struct tty *, struct screen *, u_int, va_list);
-void tty_cmd_kkeypadmode(struct tty *, struct screen *, u_int, va_list);
void tty_cmd_linefeed(struct tty *, struct screen *, u_int, va_list);
void tty_cmd_mousemode(struct tty *, struct screen *, u_int, va_list);
void tty_cmd_reverseindex(struct tty *, struct screen *, u_int, va_list);
@@ -70,14 +67,11 @@ void (*tty_cmds[])(struct tty *, struct screen *, u_int, va_list) = {
tty_cmd_clearscreen,
tty_cmd_clearstartofline,
tty_cmd_clearstartofscreen,
- tty_cmd_cursormode,
tty_cmd_deletecharacter,
tty_cmd_deleteline,
tty_cmd_insertcharacter,
tty_cmd_insertline,
tty_cmd_insertmode,
- tty_cmd_kcursormode,
- tty_cmd_kkeypadmode,
tty_cmd_linefeed,
tty_cmd_mousemode,
tty_cmd_reverseindex,
@@ -174,6 +168,8 @@ tty_start_tty(struct tty *tty)
tty_putcode(tty, TTYC_SMKX);
tty_putcode(tty, TTYC_ENACS);
tty_putcode(tty, TTYC_CLEAR);
+
+ tty_putcode(tty, TTYC_CNORM);
memcpy(&tty->cell, &grid_default_cell, sizeof tty->cell);
@@ -182,6 +178,8 @@ tty_start_tty(struct tty *tty)
tty->rlower = UINT_MAX;
tty->rupper = UINT_MAX;
+
+ tty->cursor = 1;
}
void
@@ -496,24 +494,6 @@ tty_cmd_clearstartofline(
}
void
-tty_cmd_cursormode(
- struct tty *tty, unused struct screen *s, unused u_int oy, va_list ap)
-{
- int ua;
-
- ua = va_arg(ap, int);
-
- if (tty->cursor == ua)
- return;
- tty->cursor = ua;
-
- if (ua && !(tty->flags & TTY_NOCURSOR))
- tty_putcode(tty, TTYC_CNORM);
- else
- tty_putcode(tty, TTYC_CIVIS);
-}
-
-void
tty_cmd_reverseindex(
struct tty *tty, struct screen *s, u_int oy, unused va_list ap)
{
@@ -531,14 +511,6 @@ tty_cmd_insertmode(unused struct tty *tty,
int ua;
ua = va_arg(ap, int);
-
-#if 0
- /* XXX */
- if (ua)
- tty_puts(tty, enter_insert_mode);
- else
- tty_puts(tty, exit_insert_mode);
-#endif
}
void
@@ -559,18 +531,6 @@ tty_cmd_mousemode(
}
void
-tty_cmd_kcursormode(unused struct tty *tty,
- unused struct screen *s, unused u_int oy, unused va_list ap)
-{
-}
-
-void
-tty_cmd_kkeypadmode(unused struct tty *tty,
- unused struct screen *s, unused u_int oy, unused va_list ap)
-{
-}
-
-void
tty_cmd_linefeed(struct tty *tty, struct screen *s, u_int oy, unused va_list ap)
{
tty_reset(tty);
@@ -749,6 +709,26 @@ tty_cursor(struct tty *tty, u_int cx, u_int cy, u_int oy)
}
void
+tty_cursor_off(struct tty *tty)
+{
+ if (!tty->cursor)
+ return;
+ tty->cursor = 0;
+
+ tty_putcode(tty, TTYC_CIVIS);
+}
+
+void
+tty_cursor_on(struct tty *tty)
+{
+ if (tty->cursor || tty->flags & TTY_NOCURSOR)
+ return;
+ tty->cursor = 1;
+
+ tty_putcode(tty, TTYC_CNORM);
+}
+
+void
tty_attributes(struct tty *tty, const struct grid_cell *gc)
{
struct grid_cell *tc = &tty->cell;