From 3ae49a8fdb7d21c065fcf2b1f7459a32f963c087 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sun, 5 Oct 2014 14:53:18 +0200 Subject: terminal/screen: save state in separate object Terminal state can be saved/restored by applications. To simplify our internal handling, put all affected state into a separate object. Especially with alternate screen buffers, this will simplify our code significantly. --- src/libsystemd-terminal/term-internal.h | 41 +++++++++++++++------------------ 1 file changed, 19 insertions(+), 22 deletions(-) (limited to 'src/libsystemd-terminal/term-internal.h') diff --git a/src/libsystemd-terminal/term-internal.h b/src/libsystemd-terminal/term-internal.h index a023498b53..c78b9aa70a 100644 --- a/src/libsystemd-terminal/term-internal.h +++ b/src/libsystemd-terminal/term-internal.h @@ -37,6 +37,7 @@ typedef struct term_page term_page; typedef struct term_history term_history; typedef uint32_t term_charset[96]; +typedef struct term_state term_state; /* * Miscellaneous @@ -586,11 +587,9 @@ enum { TERM_FLAG_HIDE_CURSOR = (1U << 1), /* hide cursor caret (default: off) */ TERM_FLAG_INHIBIT_TPARM = (1U << 2), /* do not send TPARM unrequested (default: off) */ TERM_FLAG_NEWLINE_MODE = (1U << 3), /* perform carriage-return on line-feeds (default: off) */ - TERM_FLAG_ORIGIN_MODE = (1U << 4), /* in origin mode, the cursor is bound by the margins (default: off) */ - TERM_FLAG_PENDING_WRAP = (1U << 5), /* wrap-around is pending */ - TERM_FLAG_AUTO_WRAP = (1U << 6), /* auto-wrap mode causes line-wraps at line-ends (default: off) */ - TERM_FLAG_KEYPAD_MODE = (1U << 7), /* application-keypad mode (default: off) */ - TERM_FLAG_CURSOR_KEYS = (1U << 8), /* enable application cursor-keys (default: off) */ + TERM_FLAG_PENDING_WRAP = (1U << 4), /* wrap-around is pending */ + TERM_FLAG_KEYPAD_MODE = (1U << 5), /* application-keypad mode (default: off) */ + TERM_FLAG_CURSOR_KEYS = (1U << 6), /* enable application cursor-keys (default: off) */ }; enum { @@ -600,6 +599,19 @@ enum { TERM_CONFORMANCE_LEVEL_CNT, }; +struct term_state { + unsigned int cursor_x; + unsigned int cursor_y; + term_attr attr; + term_charset **gl; + term_charset **gr; + term_charset **glt; + term_charset **grt; + + bool auto_wrap : 1; + bool origin_mode : 1; +}; + struct term_screen { unsigned long ref; term_age_t age; @@ -623,15 +635,8 @@ struct term_screen { unsigned int flags; unsigned int conformance_level; - unsigned int cursor_x; - unsigned int cursor_y; - term_attr attr; term_attr default_attr; - term_charset **gl; - term_charset **gr; - term_charset **glt; - term_charset **grt; term_charset *g0; term_charset *g1; term_charset *g2; @@ -639,14 +644,6 @@ struct term_screen { char *answerback; - struct { - unsigned int cursor_x; - unsigned int cursor_y; - term_attr attr; - term_charset **gl; - term_charset **gr; - term_charset **glt; - term_charset **grt; - unsigned int flags; - } saved; + term_state state; + term_state saved; }; -- cgit v1.2.3-54-g00ecf