copyright statements
[apps/madtty.git] / inject_csi.c
index e2b6430..4c3a52e 100644 (file)
@@ -1,42 +1,33 @@
 /*
-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.
+    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.
+    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.
+    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
+    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
-*/
+    Copyright © 2004 Bruno T. C. de Oliveira
+    Copyright © 2006 Pierre Habouzit
+ */
 
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
 
 #include "inject_csi.h"
 #include "roteprivate.h"
-#include <stdlib.h>
-#include <string.h>
 
 #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;
@@ -328,6 +319,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 */
@@ -356,10 +355,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;
    }
 }