terminfo capabilities.
*
* Arguments:
*
- * capability - The name of a terminfo capability (see terminfo(5)).
+ * capability - The name of the terminfo capability (see terminfo(5)).
*
* Returns a tputs-processed string, or NULL if terminal initialization failed
* or the capability wasn't found.
*/
char *get_term_stringcap(char *capability);
+/*
+ * Get a parameterized string from the terminfo database for the current
+ * terminal.
+ *
+ * We don't yet have a standardized tparm() that will take a stdarg
+ * argument. Right now we don't want many parameters, so we only
+ * take two. Everything gets passed to tparm() as-is. If we need
+ * a capability with more arguments, we'll just add more later.
+ *
+ * Arguments:
+ *
+ * capability - The name of the terminfo capability (see terminfo(5)).
+ * arg1..argN - Arguments 1-N.
+ *
+ * Returns a tparm and tputs-processed string, or NULL if there was a problem
+ * initializating the terminal or retrieving the capability.
+ */
+char *get_term_stringparm(char *capability, long arg1, long arg2);
+
+/*
+ * Get a number from the terminfo database for the current terminal.
+ *
+ * Retrieve the specified terminfo capability and return the numeric
+ * value of that capability from the terminfo database.
+ *
+ * Arguments:
+ *
+ * capability - The name of the terminfo capability (see terminfo(5)).
+ *
+ * Returns the output of tigetnum() for that capability, or -1 if it was
+ * unable to initialize the terminfo database.
+ */
+int get_term_numcap(char *capability);
+
/*
* Lock open/close routines.
*
#define TF_UNDERLN 13 /* special - enter underline mode */
#define TF_STNDOUT 14 /* special - enter underline mode */
#define TF_RESET 15 /* special - reset terminal modes */
+#define TF_HASCLR 16 /* special - terminal have color? */
/* ftable->flags */
/* NB that TFL_PUTS is also used to decide whether the test
{ "underline", TF_UNDERLN,FT_LS_LIT, 0, TFL_PUTS },
{ "standout", TF_STNDOUT,FT_LS_LIT, 0, TFL_PUTS },
{ "resetterm", TF_RESET, FT_LS_LIT, 0, TFL_PUTS },
+ { "hascolor", TF_HASCLR, FT_LV_LIT, 0, 0 },
{ NULL, 0, 0, 0, 0 }
};
LS(t->f_type, get_term_stringcap("sgr0"));
break;
+ case TF_HASCLR:
+ LV(t->f_type, get_term_numcap("colors") > 1);
+ break;
+
case TF_NOW:
LV(t->f_type, time((time_t *) 0));
break;
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 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
*/