From: Pasi Kallinen Date: Fri, 14 Dec 2012 23:17:20 +0000 (+0200) Subject: Add default_term configuration option. X-Git-Tag: v1.6.1-roc-dev~71 X-Git-Url: https://skyeroc.xyz/gitweb/?a=commitdiff_plain;h=9bd76d6c15199fa1a3948dae29faa989b4861b99;p=dgamelaunch Add default_term configuration option. If the user's TERM is something unknown, dgl will use the default_term instead. --- diff --git a/README b/README index 2b261db..2c1a60d 100644 --- 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 diff --git a/config.l b/config.l index 9f797ca..b1e01f3 100644 --- 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; } diff --git a/config.y b/config.y index 58466f0..1d38578 100644 --- 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 TYPE_VALUE %token TYPE_NUMBER TYPE_CMDQUEUENAME %type 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(); diff --git a/dgamelaunch.c b/dgamelaunch.c index bbc41bc..b7881ab 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -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 (); diff --git a/dgamelaunch.h b/dgamelaunch.h index e7886fe..9fdee30 100644 --- a/dgamelaunch.h +++ b/dgamelaunch.h @@ -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]; diff --git a/dgl-common.c b/dgl-common.c index 795be39..0a7b1b6 100644 --- a/dgl-common.c +++ b/dgl-common.c @@ -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; diff --git a/examples/dgamelaunch.conf b/examples/dgamelaunch.conf index 6df268b..1d9bf54 100644 --- a/examples/dgamelaunch.conf +++ b/examples/dgamelaunch.conf @@ -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