/****************************************************************************
- * Copyright (c) 2005-2011,2012 Free Software Foundation, Inc. *
+ * Copyright (c) 2005-2012,2013 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
/*
* Author: Thomas E. Dickey
*
- * $Id: demo_termcap.c,v 1.21 2012/06/30 22:02:56 tom Exp $
+ * $Id: demo_termcap.c,v 1.24 2013/06/08 16:58:49 tom Exp $
*
* A simple demo of the termcap interface.
*/
#define isCapName(c) (isgraph(c) && strchr("^#=:\\", c) == 0)
-#if NO_LEAKS && USE_CODE_LISTS
-
-#define MYSCR struct _myscr
-MYSCR {
- MYSCR *next;
- TERMINAL *term;
-};
-
-static MYSCR *my_screens;
-
-static void
-save_screen(void)
-{
- MYSCR *obj = malloc(sizeof(MYSCR));
- obj->next = my_screens;
- obj->term = cur_term;
- my_screens = obj;
-}
-#else
-#define save_screen() /* nothing */
-#endif
-
static char *
make_dbitem(char *p, char *q)
{
char *result = malloc(strlen(e_opt) + 2 + (size_t) (p - q));
- sprintf(result, "%s=%.*s", e_opt, p - q, q);
+ sprintf(result, "%s=%.*s", e_opt, (int) (p - q), q);
return result;
}
{
unsigned n;
NCURSES_CONST char *cap;
+ char buffer[1024];
if (db_list) {
putenv(next_dbitem());
}
printf("Terminal type \"%s\"\n", name);
-#if HAVE_SETUPTERM
- setupterm(name, 1, (int *) 0);
-#else
- setterm(name);
-#endif
- save_screen();
-
- if (b_opt) {
- for (n = 0;; ++n) {
- cap = boolcodes[n];
- if (cap == 0)
- break;
- dumpit(cap);
+ if (tgetent(buffer, name) >= 0) {
+
+ if (b_opt) {
+ for (n = 0;; ++n) {
+ cap = boolcodes[n];
+ if (cap == 0)
+ break;
+ dumpit(cap);
+ }
}
- }
- if (n_opt) {
- for (n = 0;; ++n) {
- cap = numcodes[n];
- if (cap == 0)
- break;
- dumpit(cap);
+ if (n_opt) {
+ for (n = 0;; ++n) {
+ cap = numcodes[n];
+ if (cap == 0)
+ break;
+ dumpit(cap);
+ }
}
- }
- if (s_opt) {
- for (n = 0;; ++n) {
- cap = strcodes[n];
- if (cap == 0)
- break;
- dumpit(cap);
+ if (s_opt) {
+ for (n = 0;; ++n) {
+ cap = strcodes[n];
+ if (cap == 0)
+ break;
+ dumpit(cap);
+ }
}
}
}
" -q quiet (prints only counts)",
" -r COUNT repeat for given count",
" -s print string-capabilities",
+#ifdef NCURSES_VERSION
+ " -y disable extended capabilities",
+#endif
};
unsigned n;
for (n = 0; n < SIZEOF(msg); ++n) {
int repeat;
int r_opt = 1;
- while ((n = getopt(argc, argv, "abd:e:nqr:s")) != -1) {
+ while ((n = getopt(argc, argv, "abd:e:nqr:sy")) != -1) {
switch (n) {
case 'a':
a_opt = TRUE;
case 's':
s_opt = TRUE;
break;
+#if NCURSES_XNAMES
+ case 'y':
+ use_extended_names(FALSE);
+ break;
+#endif
default:
usage();
break;
demo_termcap(dumb);
}
}
-#if NO_LEAKS
- /*
- * ncurses' tgetent() interface caches some entries and its no-leaks
- * code discards those. The calls to setupterm() on the other hand
- * are not cached, and each call allocates a chunk of memory, even
- * if the same terminal type is requested repeatedly.
- */
- while (my_screens != 0) {
- MYSCR *next = my_screens->next;
- del_curterm(my_screens->term);
- free(my_screens);
- my_screens = next;
- }
-#endif
}
#endif /* USE_CODE_LISTS */