diff options
author | Sven Schnelle <svens@linux.ibm.com> | 2022-11-28 22:22:01 +0100 |
---|---|---|
committer | Heiko Carstens <hca@linux.ibm.com> | 2023-01-09 14:33:58 +0100 |
commit | 94dbb0a76ce21878867210d1cf0b21725023b452 (patch) | |
tree | 566a39f3128aa55cb46d67cf212b2731cb966bde /drivers/s390/char/con3270.c | |
parent | 4043ea22535d00325b469c75cf4840612c09345b (diff) |
s390/tty3270: add support for graphic escape
Add support for ASCII S0/S1 to switch between character
charset and graphic charset.
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Tested-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Diffstat (limited to 'drivers/s390/char/con3270.c')
-rw-r--r-- | drivers/s390/char/con3270.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c index 3b0e69f02773..13e2b4cb74fc 100644 --- a/drivers/s390/char/con3270.c +++ b/drivers/s390/char/con3270.c @@ -42,6 +42,7 @@ static struct tty3270 *condev; static struct raw3270_fn tty3270_fn; struct tty3270_attribute { + unsigned char alternate_charset:1; /* Graphics charset */ unsigned char highlight; /* Blink/reverse/underscore */ unsigned char f_color; /* Foreground color */ unsigned char b_color; /* Background color */ @@ -1059,6 +1060,36 @@ static unsigned int tty3270_write_room(struct tty_struct *tty) return INT_MAX; } +static char tty3270_graphics_translate(struct tty3270 *tp, char ch) +{ + switch (ch) { + case 'q': /* - */ + return 0xa2; + case 'x': /* '|' */ + return 0x85; + case 'l': /* |- */ + return 0xc5; + case 't': /* |_ */ + return 0xc6; + case 'u': /* _| */ + return 0xd6; + case 'k': /* -| */ + return 0xd5; + case 'j': + return 0xd4; + case 'm': + return 0xc4; + case 'n': /* + */ + return 0xd3; + case 'v': + return 0xc7; + case 'w': + return 0xd7; + default: + return ch; + } +} + /* * Insert character into the screen at the current position with the * current color and highlight. This function does NOT do cursor movement. @@ -1079,7 +1110,10 @@ static void tty3270_put_character(struct tty3270 *tp, char ch) line->len++; } cell = line->cells + tp->cx; - cell->character = tp->view.ascebc[(unsigned int) ch]; + if (tp->attributes.alternate_charset) + cell->character = tty3270_graphics_translate(tp, ch); + else + cell->character = tp->view.ascebc[(unsigned int)ch]; cell->attributes = tp->attributes; } @@ -1116,6 +1150,8 @@ static void tty3270_convert_line(struct tty3270 *tp, int line_nr) flen += 3; /* TO_SA to switch color. */ b_color = cell->attributes.b_color; } + if (cell->attributes.alternate_charset) + flen += 1; /* TO_GE to switch to graphics extensions */ } if (highlight != TAX_RESET) flen += 3; /* TO_SA to reset hightlight. */ @@ -1173,6 +1209,8 @@ static void tty3270_convert_line(struct tty3270 *tp, int line_nr) *cp++ = cell->attributes.b_color; b_color = cell->attributes.b_color; } + if (cell->attributes.alternate_charset) + *cp++ = TO_GE; *cp++ = cell->character; } @@ -1706,7 +1744,11 @@ static void tty3270_do_write(struct tty3270 *tp, struct tty_struct *tty, case 0x0d: /* '\r' -- Carriage Return */ tp->cx = 0; break; + case 0x0e: + tp->attributes.alternate_charset = 1; + break; case 0x0f: /* SuSE "exit alternate mode" */ + tp->attributes.alternate_charset = 0; break; case 0x1b: /* Start escape sequence. */ tty3270_escape_sequence(tp, buf[i_msg]); |