From 3c5194125653cfdca622909b0258d150bd06a6b1 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 5 Oct 2011 13:57:32 +0000 Subject: [PATCH] Make sending select-utf8-charset escape code configurable. git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@611 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- config.l | 1 + config.y | 7 ++++++- dgamelaunch.c | 8 ++++---- dgamelaunch.h | 1 + dgl-common.c | 1 + examples/dgamelaunch.conf | 4 ++++ 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/config.l b/config.l index 0779001..358b3c6 100644 --- a/config.l +++ b/config.l @@ -94,6 +94,7 @@ commands { return TYPE_CMDQUEUE; } postcommands { return TYPE_POSTCMDQUEUE; } encoding { return TYPE_ENCODING; } locale { return TYPE_LOCALE; } +utf8esc { return TYPE_UTF8ESC; } yes { yylval.i = 1; return TYPE_BOOL; } no { yylval.i = 0; return TYPE_BOOL; } dglstart { yylval.i = DGLTIME_DGLSTART; return TYPE_CMDQUEUENAME; } diff --git a/config.y b/config.y index 436bf67..a81d5dc 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 %token TYPE_MAX_IDLE_TIME TYPE_MENU_MAX_IDLE_TIME TYPE_EXTRA_INFO_FILE -%token TYPE_ENCODING TYPE_LOCALE +%token TYPE_ENCODING TYPE_LOCALE TYPE_UTF8ESC %token TYPE_VALUE %token TYPE_NUMBER TYPE_CMDQUEUENAME %type KeyType @@ -226,6 +226,9 @@ KeyPair: TYPE_CMDQUEUE '[' TYPE_CMDQUEUENAME ']' case TYPE_ALLOW_REGISTRATION: globalconfig.allow_registration = $3; break; + case TYPE_UTF8ESC: + globalconfig.utf8esc = $3; + break; default: fprintf(stderr, "%s:%d: token %s does not take a boolean, bailing out\n", config, line, lookup_token($1)); @@ -628,6 +631,7 @@ KeyType : TYPE_SUSER { $$ = TYPE_SUSER; } | TYPE_PATH_INPROGRESS { $$ = TYPE_PATH_INPROGRESS; } | TYPE_ENCODING { $$ = TYPE_ENCODING; } | TYPE_LOCALE { $$ = TYPE_LOCALE; } + | TYPE_UTF8ESC { $$ = TYPE_UTF8ESC; } | TYPE_RC_FMT { $$ = TYPE_RC_FMT; } | TYPE_WATCH_SORTMODE { $$ = TYPE_WATCH_SORTMODE; } | TYPE_SERVER_ID { $$ = TYPE_SERVER_ID; } @@ -664,6 +668,7 @@ const char* lookup_token (int t) case TYPE_WATCH_COLUMNS: return "watch_columns"; case TYPE_SERVER_ID: return "server_id"; case TYPE_LOCALE: return "locale"; + case TYPE_UTF8ESC: return "utf8esc"; default: abort(); } } diff --git a/dgamelaunch.c b/dgamelaunch.c index 10c5cee..623754f 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -1061,7 +1061,7 @@ inprogressmenu (int gameid) break; case 12: case 18: /* ^L, ^R */ - write(1, "\033%G", 3); + if (globalconfig.utf8esc) write(1, "\033%G", 3); clear (); break; @@ -1099,7 +1099,7 @@ watchgame: clear (); refresh (); endwin (); - write(1, "\033%G", 3); + if (globalconfig.utf8esc) write(1, "\033%G", 3); #ifdef USE_SHMEM signals_block(); if (games[idx]->is_in_shm) { @@ -1610,7 +1610,7 @@ initcurses () use_default_colors(); init_pair(1, -1, -1); init_pair(2, COLOR_RED, -1); - write(1, "\033%G", 3); + if (globalconfig.utf8esc) write(1, "\033%G", 3); #endif clear(); refresh(); @@ -2457,7 +2457,7 @@ runmenuloop(struct dg_menu *menu) term_resize_check(); if (doclear) { doclear = 0; - write(1, "\033%G", 3); + if (globalconfig.utf8esc) write(1, "\033%G", 3); clear(); } drawbanner(&ban, 1, 0); diff --git a/dgamelaunch.h b/dgamelaunch.h index 7f7daec..23a54f5 100644 --- a/dgamelaunch.h +++ b/dgamelaunch.h @@ -226,6 +226,7 @@ struct dg_globalconfig int sortmode; /* default watching-screen sortmode */ char *server_id; /* string for the server name or whatever */ char *locale; + int utf8esc; /* send select-utf8-charset escape code */ struct dg_cmdpart *cmdqueue[NUM_DGLTIMES]; diff --git a/dgl-common.c b/dgl-common.c index a3c7e42..0b197f6 100644 --- a/dgl-common.c +++ b/dgl-common.c @@ -744,6 +744,7 @@ create_config () globalconfig.shed_gid = (gid_t)-1; globalconfig.sortmode = SORTMODE_USERNAME; + globalconfig.utf8esc = 0; if (config) { diff --git a/examples/dgamelaunch.conf b/examples/dgamelaunch.conf index bd98683..374502c 100644 --- a/examples/dgamelaunch.conf +++ b/examples/dgamelaunch.conf @@ -77,6 +77,10 @@ shed_gid = 60 # Locale. Leaving this out, dgamelaunch will not explicitly set locale. locale = "en_US.UTF-8" +# Should dgl send select-UTF8-charset escape code? (that is: ESC % G) +# default is no. +#utf8esc = yes + # Maximum time in seconds user can idle in the dgamelaunch menus # before dgl exits. Default value is 0, which disables the idling timer. # Does not apply to external programs or config editors.