X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=inject_csi.c;h=3942304ce2d9338c00e169c1f8750ddd76dad9e1;hb=8e5831e371def4903b232c4e91962d2053cc6ce1;hp=2d3ba6506b8ca6820b1ef9bf3519937584c7dc4b;hpb=93c516d8991c4b6935fc03a24317ea0785e78a93;p=apps%2Fmadtty.git diff --git a/inject_csi.c b/inject_csi.c index 2d3ba65..3942304 100644 --- a/inject_csi.c +++ b/inject_csi.c @@ -1,21 +1,32 @@ +/* +LICENSE INFORMATION: +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License (LGPL) as published by the Free Software Foundation. + +Please refer to the COPYING file for more information. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Copyright (c) 2004 Bruno T. C. de Oliveira +*/ + + #include "inject_csi.h" #include "roteprivate.h" #include #include +#include #define MAX_CSI_ES_PARAMS 32 -static inline void clamp_cursor_to_bounds(RoteTerm *rt) { - if (rt->crow < 0) rt->curpos_dirty = true, rt->crow = 0; - if (rt->ccol < 0) rt->curpos_dirty = true, rt->ccol = 0; - - if (rt->crow >= rt->rows) - rt->curpos_dirty = true, rt->crow = rt->rows - 1; - - if (rt->ccol >= rt->cols) - rt->curpos_dirty = true, rt->ccol = rt->cols - 1; -} - /* interprets a 'set attribute' (SGR) CSI escape sequence */ static void interpret_csi_SGR(RoteTerm *rt, int param[], int pcount) { int i; @@ -27,11 +38,46 @@ static void interpret_csi_SGR(RoteTerm *rt, int param[], int pcount) { } for (i = 0; i < pcount; i++) { + +// From http://vt100.net/docs/vt510-rm/SGR table 5-16 +// 0 All attributes off +// 1 Bold +// 4 Underline +// 5 Blinking +// 7 Negative image +// 8 Invisible image +// 10 The ASCII character set is the current 7-bit +// display character set (default) - SCO Console only. +// 11 Map Hex 00-7F of the PC character set codes +// to the current 7-bit display character set +// - SCO Console only. +// 12 Map Hex 80-FF of the current character set to +// the current 7-bit display character set - SCO +// Console only. +// 22 Bold off +// 24 Underline off +// 25 Blinking off +// 27 Negative image off +// 28 Invisible image off + if (param[i] == 0) rt->curattr = 0x70; else if (param[i] == 1 || param[i] == 2 || param[i] == 4) /* set bold */ - rt->curattr |= 0x80; - else if (param[i] == 5) rt->curattr |= 0x08; /* set blink */ - else if (param[i] == 7) rt->curattr = 0x07; /* reverse video */ + ROTE_ATTR_MOD_BOLD(rt->curattr,1); + else if (param[i] == 5) /* set blink */ + ROTE_ATTR_MOD_BLINK(rt->curattr,1); + else if (param[i] == 7 || param[i] == 27) { /* reverse video */ + int fg = ROTE_ATTR_FG(rt->curattr); + int bg = ROTE_ATTR_BG(rt->curattr); + ROTE_ATTR_MOD_FG(rt->curattr, bg); + ROTE_ATTR_MOD_BG(rt->curattr, fg); + } + else if (param[i] == 8) rt->curattr = 0x0; /* invisible */ + else if (param[i] == 22 || param[i] == 24) /* bold off */ + ROTE_ATTR_MOD_BOLD(rt->curattr,0); + else if (param[i] == 25) /* blink off */ + ROTE_ATTR_MOD_BLINK(rt->curattr,0); + else if (param[i] == 28) /* invisible off */ + rt->curattr = 0x70; else if (param[i] >= 30 && param[i] <= 37) /* set fg */ ROTE_ATTR_MOD_FG(rt->curattr, param[i] - 30); else if (param[i] >= 40 && param[i] <= 47) /* set bg */ @@ -272,6 +318,14 @@ void rote_es_interpret_csi(RoteTerm *rt) { /* delegate handling depending on command character (verb) */ switch (verb) { + case 'h': + if (param_count == 1 && csiparam[0] == 4) /* insert mode */ + rt->insert = true; + break; + case 'l': + if (param_count == 1 && csiparam[0] == 4) /* replace mode */ + rt->insert = false; + break; case 'm': /* it's a 'set attribute' sequence */ interpret_csi_SGR(rt, csiparam, param_count); break; case 'J': /* it's an 'erase display' sequence */ @@ -300,10 +354,12 @@ void rote_es_interpret_csi(RoteTerm *rt) { interpret_csi_SAVECUR(rt, csiparam, param_count); break; case 'u': /* restore cursor location */ interpret_csi_RESTORECUR(rt, csiparam, param_count); break; - #ifdef DEBUG default: - fprintf(stderr, "Unrecogized CSI: <%s>\n", rt->pd->esbuf); break; - #endif + #ifdef DEBUG + fprintf(stderr, "Unrecogized CSI: verb=%c <%s>\n", + verb, rt->pd->esbuf); + #endif + break; } }