Add default_term configuration option.

If the user's TERM is something unknown, dgl will use the default_term instead.
This commit is contained in:
Pasi Kallinen 2012-12-15 01:17:20 +02:00
parent 7a565e5e14
commit 9bd76d6c15
7 changed files with 23 additions and 2 deletions

1
README
View File

@ -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

View File

@ -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; }

View File

@ -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();

View 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 ();

View 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];

View 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;

View 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