]> diplodocus.org Git - nmh/blobdiff - sbr/terminal.c
Fix flex 2.6.1's output regarding signed/unsigned comparisons.
[nmh] / sbr / terminal.c
index fe7619be71e4eddf58cf860c942ee9bc6b8caa36..cf71de03ade036dd7a50e6b115fe787c19d66d20 100644 (file)
 #include <h/mh.h>
 #include <h/utils.h>
 
 #include <h/mh.h>
 #include <h/utils.h>
 
-#include <termios.h>
 #include <sys/ioctl.h>
 
 #include <curses.h>
 #include <term.h>
 #include <sys/ioctl.h>
 
 #include <curses.h>
 #include <term.h>
+#include <termios.h>
 
 #ifdef WINSIZE_IN_PTEM
 # include <sys/stream.h>
 
 #ifdef WINSIZE_IN_PTEM
 # include <sys/stream.h>
@@ -54,9 +54,8 @@ initialize_terminfo(void)
     if (rc != 0 || errret != 1) {
        termstatus = -1;
        return;
     if (rc != 0 || errret != 1) {
        termstatus = -1;
        return;
-    } else {
-       termstatus = 1;
     }
     }
+    termstatus = 1;
 
     if (!initCO && (CO = tigetnum ("cols")) <= 0)
        CO = 80;
 
     if (!initCO && (CO = tigetnum ("cols")) <= 0)
        CO = 80;
@@ -120,7 +119,7 @@ nmh_clear_screen (void)
     if (ti_clear)
        tputs (ti_clear, LI, outc);
     else {
     if (ti_clear)
        tputs (ti_clear, LI, outc);
     else {
-       printf ("\f");
+       putchar('\f');
     }
 
     fflush (stdout);
     }
 
     fflush (stdout);
@@ -175,11 +174,57 @@ get_term_stringcap(char *capability)
 
     tputs(parm, 1, termbytes);
 
 
     tputs(parm, 1, termbytes);
 
-    termcbufp = '\0';
+    *termcbufp = '\0';
+
+    return termcbuf;
+}
+
+/*
+ * Return a parameterized terminfo capability
+ */
+
+char *
+get_term_stringparm(char *capability, long arg1, long arg2)
+{
+    char *parm;
+
+    initialize_terminfo();
+
+    if (termstatus == -1)
+       return NULL;
+
+    termcbufp = termcbuf;
+
+    parm = tigetstr(capability);
+
+    if (parm == (char *) -1 || parm == NULL) {
+       return NULL;
+    }
+
+    parm = tparm(parm, arg1, arg2, 0, 0, 0, 0, 0, 0, 0);
+
+    tputs(parm, 1, termbytes);
+
+    *termcbufp = '\0';
 
     return termcbuf;
 }
 
 
     return termcbuf;
 }
 
+/*
+ * Return the value of the specified numeric capability
+ */
+
+int
+get_term_numcap(char *capability)
+{
+    initialize_terminfo();
+
+    if (termstatus == -1)
+       return -1;
+
+    return tigetnum(capability);
+}
+
 /*
  * Store a sequence of characters in our local buffer
  */
 /*
  * Store a sequence of characters in our local buffer
  */