From a95bbbe731c5aba2be2a41f7a8efd9044bcbbd67 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Fri, 28 Dec 2018 17:23:03 +0100 Subject: [PATCH] termptyesc: DECALN only reset margins and cursor position --- src/bin/termptyesc.c | 51 +++++++++++++++++++++++++++----------------- tests/decaln.sh | 44 ++++++++++++++++++++++++++++++++++++++ tests/tests.results | 1 + 3 files changed, 77 insertions(+), 19 deletions(-) create mode 100755 tests/decaln.sh diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c index 947d50cf..ab7a6f7f 100644 --- a/src/bin/termptyesc.c +++ b/src/bin/termptyesc.c @@ -2756,6 +2756,37 @@ end: return len; } +static void +_handle_decaln(Termpty *ty) +{ + int size; + Termcell *cells; + + DBG("DECALN - fill screen with E"); + ty->termstate.top_margin = 0; + ty->termstate.bottom_margin = 0; + ty->termstate.left_margin = 0; + ty->termstate.right_margin = 0; + ty->termstate.had_cr_x = 0; + ty->termstate.had_cr_y = 0; + ty->cursor_state.cx = 0; + ty->cursor_state.cy = 0; + ty->termstate.att.link_id = 0; + + termpty_clear_screen(ty, TERMPTY_CLR_ALL); + if (ty->cb.cancel_sel.func) + ty->cb.cancel_sel.func(ty->cb.cancel_sel.data); + cells = ty->screen; + size = ty->w * ty->h; + if (cells) + { + Termatt att; + + memset((&att), 0, sizeof(att)); + termpty_cell_codepoint_att_fill(ty, 'E', att, cells, size); + } +} + static int _handle_esc(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce) { @@ -2845,25 +2876,7 @@ _handle_esc(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce) case '#': // #8 == test mode -> fill screen with "E"; if (len < 2) return 0; if (c[1] == '8') - { - int size; - Termcell *cells; - - DBG("reset to init mode and clear then fill with E"); - termpty_reset_state(ty); - termpty_clear_screen(ty, TERMPTY_CLR_ALL); - if (ty->cb.cancel_sel.func) - ty->cb.cancel_sel.func(ty->cb.cancel_sel.data); - cells = ty->screen; - size = ty->w * ty->h; - if (cells) - { - Termatt att; - - memset((&att), 0, sizeof(att)); - termpty_cell_codepoint_att_fill(ty, 'E', att, cells, size); - } - } + _handle_decaln(ty); return 2; case '@': // just consume this plus next char if (len < 2) return 0; diff --git a/tests/decaln.sh b/tests/decaln.sh new file mode 100755 index 00000000..84a3782f --- /dev/null +++ b/tests/decaln.sh @@ -0,0 +1,44 @@ +#!/bin/sh +#set color +printf '\033[46;31;3m' + +# set top/bottom margins: +printf '\033[10;20r' +# allow left/right margins +printf '\033[?69h' +# set left/right margins: +printf '\033[5;15s' +# fill margin with @ +printf '\033[64;10;5;20;15$x' +# restrict cursor +printf '\033[?6h' +# reset wrap mode +printf '\033[?7l' + +# set tabs +printf '\033H\033H\033[3C\033H\033[4C\033H\033[5C\033H\033[6C\033H' +printf '\033[7C\033H\033[8C\033H\033[9C#' + +# set cursor shape +printf '\033[4 q' + +# fill space with E +printf '\033#8' + +printf 'start' +#move to 0;0 +printf '\033[HST' + +printf '\n#\t#\033[2I\033[3g@\t#\t#\t#\t#\t#\t#\t#\t#\t#\t#' + +# move to 1; 75 +printf '\033[1;75Habcdefghijkl' +# shall be no wrap and in color. also no margin + +#set margins again, cursor is still restricted +# set top/bottom margins: +printf '\033[10;20r' +# set left/right margins: +printf '\033[5;15s' +#move to 0;0 +printf '\033[22;22H2' diff --git a/tests/tests.results b/tests/tests.results index 1acd4aa1..d99ef850 100644 --- a/tests/tests.results +++ b/tests/tests.results @@ -35,3 +35,4 @@ dch.sh 40cf655681c098251f0dc3e7733c4db9 cnl.sh 1f1512179c8e47e4bd880142774a3c66 cpl.sh 9145c88adb762a6a59c5bf69191b949e cup.sh 11f5939a6cc990f6a7b9d1730ab3a8bf +decaln.sh 38ca494fb468752d510daff797f7c40c