]> skyeroc.xyz Git - dgamelaunch/commitdiff
Add default_term configuration option.
authorPasi Kallinen <paxed@alt.org>
Fri, 14 Dec 2012 23:17:20 +0000 (01:17 +0200)
committerPasi Kallinen <paxed@alt.org>
Fri, 14 Dec 2012 23:17:20 +0000 (01:17 +0200)
If the user's TERM is something unknown, dgl will use the default_term instead.

README
config.l
config.y
dgamelaunch.c
dgamelaunch.h
dgl-common.c
examples/dgamelaunch.conf

diff --git a/README b/README
index 2b261dbe082d92c8eba5f9f0d3aa35239396f751..2c1a60ded84a7fddf2e03eed5ad7853944b46786 100644 (file)
--- a/README
+++ b/README
@@ -192,6 +192,7 @@ ERROR CODES
   12   Config file has an unrecognized token
   13   Config file: Negative value not accepted
   20   No menu defined, or no banner found for menu
+  60   Cannot create a new terminal, or no termcap files.
   61   Cannot openpty()
   62   Cannot open /dev/ptmx
   65   Cannot open master ptsname
index 9f797ca5b15504069ca83a925f0c65fb423d0d8c..b1e01f3b11f8ec53f30d8534ab3b07df80f7376f 100644 (file)
--- a/config.l
+++ b/config.l
@@ -95,6 +95,7 @@ commands      { return TYPE_CMDQUEUE; }
 postcommands   { return TYPE_POSTCMDQUEUE; }
 encoding       { return TYPE_ENCODING; }
 locale         { return TYPE_LOCALE; }
+default_term   { return TYPE_DEFTERM; }
 utf8esc                { return TYPE_UTF8ESC; }
 filemode       { return TYPE_FILEMODE; }
 yes            { yylval.i = 1; return TYPE_BOOL; }
index 58466f015e4b152f048a68c64c726d6ba2611dc4..1d385780bf411a0b54f0a592ec12024ff805734b 100644 (file)
--- a/config.y
+++ b/config.y
@@ -59,7 +59,7 @@ static int sortmode_number(const char *sortmode_name) {
 %token TYPE_CMDQUEUE TYPE_DEFINE_MENU TYPE_BANNER_FILE TYPE_CURSOR
 %token TYPE_POSTCMDQUEUE TYPE_TIMEFORMAT
 %token TYPE_MAX_IDLE_TIME TYPE_MENU_MAX_IDLE_TIME TYPE_EXTRA_INFO_FILE
-%token TYPE_ENCODING TYPE_LOCALE TYPE_UTF8ESC TYPE_FILEMODE
+%token TYPE_ENCODING TYPE_LOCALE TYPE_UTF8ESC TYPE_FILEMODE TYPE_DEFTERM
 %token <s> TYPE_VALUE
 %token <i> TYPE_NUMBER TYPE_CMDQUEUENAME
 %type  <kt> KeyType
@@ -206,6 +206,11 @@ KeyPair: TYPE_CMDQUEUE '[' TYPE_CMDQUEUENAME ']'
       globalconfig.locale = strdup($3);
       break;
 
+    case TYPE_DEFTERM:
+      if (globalconfig.defterm) free(globalconfig.defterm);
+      globalconfig.defterm = strdup($3);
+      break;
+
     case TYPE_FILEMODE:
       default_fmode = strtoul($3, NULL, 8);
       break;
@@ -645,6 +650,7 @@ KeyType : TYPE_SUSER        { $$ = TYPE_SUSER; }
        | TYPE_PATH_INPROGRESS  { $$ = TYPE_PATH_INPROGRESS; }
        | TYPE_ENCODING         { $$ = TYPE_ENCODING; }
        | TYPE_LOCALE           { $$ = TYPE_LOCALE; }
+       | TYPE_DEFTERM          { $$ = TYPE_DEFTERM; }
        | TYPE_UTF8ESC          { $$ = TYPE_UTF8ESC; }
        | TYPE_RC_FMT           { $$ = TYPE_RC_FMT; }
        | TYPE_WATCH_SORTMODE   { $$ = TYPE_WATCH_SORTMODE; }
@@ -682,6 +688,7 @@ const char* lookup_token (int t)
     case TYPE_WATCH_COLUMNS: return "watch_columns";
     case TYPE_BANNERVARS: return "bannervars";
     case TYPE_LOCALE: return "locale";
+    case TYPE_DEFTERM: return "default_term";
     case TYPE_UTF8ESC: return "utf8esc";
     case TYPE_FILEMODE: return "filemode";
     default: abort();
index bbc41bc2a7263328b80d35bed9f7f41dee1a08af..b7881abc9bb4c65b6018ce3b8a182195dfb67f4e 100644 (file)
@@ -1754,7 +1754,13 @@ void
 initcurses ()
 {
   printf("\033[2J");
-  initscr ();
+  if (newterm(NULL, stdout, stdin) == NULL) {
+      if (!globalconfig.defterm || (newterm(globalconfig.defterm, stdout, stdin) == NULL)) {
+         debug_write("cannot create newterm");
+         graceful_exit(60);
+      }
+      mysetenv("TERM", globalconfig.defterm, 1);
+  }
   cbreak ();
   noecho ();
   nonl ();
index e7886fe6fecfe5dba3ffd6ca439de97010806fc1..9fdee3003e429625cf216e5fa5146b17c58c595e 100644 (file)
@@ -239,6 +239,7 @@ struct dg_globalconfig
     struct dg_banner_var *banner_var_list;
     char *locale;
     int utf8esc; /* send select-utf8-charset escape code */
+    char *defterm; /* default TERM in case user TERM is unknown  */
 
     struct dg_cmdpart *cmdqueue[NUM_DGLTIMES];
 
index 795be39f8c9e644de80ad17c2a0f1889eba1f8e2..0a7b1b6fb861e72617031bfa7c222cf2678057d3 100644 (file)
@@ -767,6 +767,7 @@ create_config ()
   globalconfig.menulist = NULL;
   globalconfig.banner_var_list = NULL;
   globalconfig.locale = NULL;
+  globalconfig.defterm = NULL;
 
   globalconfig.shed_uid = (uid_t)-1;
   globalconfig.shed_gid = (gid_t)-1;
index 6df268b287afac222e59a85189dd01c0ea8e81ad..1d9bf541a363b09b3f74e64ce40ce87a97aff64e 100644 (file)
@@ -86,6 +86,10 @@ shed_gid = 60
 # Locale. Leaving this out, dgamelaunch will not explicitly set locale.
 locale = "en_US.UTF-8"
 
+# Default TERM, used if the user's $TERM is unknown.
+# If undefined, dgamelaunch will just terminate in that case.
+default_term = "xterm"
+
 # Should dgl send select-UTF8-charset escape code? (that is: ESC % G)
 # default is no.
 #utf8esc = yes