Skip to content

Commit

Permalink
Make sending select-utf8-charset escape code configurable.
Browse files Browse the repository at this point in the history
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@611 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
  • Loading branch information
paxed committed Oct 5, 2011
1 parent 1d7ceb5 commit 3c51941
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions config.l
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
7 changes: 6 additions & 1 deletion config.y
Original file line number Diff line number Diff line change
Expand Up @@ -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 <s> TYPE_VALUE
%token <i> TYPE_NUMBER TYPE_CMDQUEUENAME
%type <kt> KeyType
Expand Down Expand Up @@ -226,6 +226,9 @@ KeyPair: TYPE_CMDQUEUE '[' TYPE_CMDQUEUENAME ']'
case TYPE_ALLOW_REGISTRATION:
globalconfig.allow_registration = $<i>3;
break;
case TYPE_UTF8ESC:
globalconfig.utf8esc = $<i>3;
break;
default:
fprintf(stderr, "%s:%d: token %s does not take a boolean, bailing out\n",
config, line, lookup_token($1));
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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();
}
}
Expand Down
8 changes: 4 additions & 4 deletions dgamelaunch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -1099,7 +1099,7 @@ inprogressmenu (int gameid)
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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions dgamelaunch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
1 change: 1 addition & 0 deletions dgl-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ create_config ()
globalconfig.shed_gid = (gid_t)-1;

globalconfig.sortmode = SORTMODE_USERNAME;
globalconfig.utf8esc = 0;

if (config)
{
Expand Down
4 changes: 4 additions & 0 deletions examples/dgamelaunch.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 3c51941

Please sign in to comment.