X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xaw%2Fxboard.c;h=a94431335283f0de951f65d4338cf911939bd054;hb=5d0f6311ab9e40e026d6ba26fa15e4ba6a5aead3;hp=d8f3df2fa7ab71848d6dc1d0488e52b6c1ba08f2;hpb=8baea05c6e9e63f8b1b57891b67b5ac0e1961b81;p=xboard.git diff --git a/xaw/xboard.c b/xaw/xboard.c index d8f3df2..a944313 100644 --- a/xaw/xboard.c +++ b/xaw/xboard.c @@ -5,7 +5,7 @@ * Massachusetts. * * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006, - * 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. + * 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc. * * The following terms apply to Digital Equipment Corporation's copyright * interest in XBoard: @@ -183,13 +183,6 @@ extern char *getenv(); // [HGM] bitmaps: put before incuding the bitmaps / pixmaps, to know how many piece types there are. #include "common.h" -#if HAVE_LIBXPM -#include -#define IMAGE_EXT "xpm" -#else -#define IMAGE_EXT "xim" -#endif - #include "bitmaps/icon_white.bm" #include "bitmaps/icon_black.bm" #include "bitmaps/checkmark.bm" @@ -210,6 +203,7 @@ extern char *getenv(); #include "gettext.h" #include "draw.h" +#define SLASH '/' #ifdef __EMX__ #ifndef HAVE_USLEEP @@ -317,6 +311,7 @@ WindowPlacement wpEvalGraph; WindowPlacement wpEngineOutput; WindowPlacement wpGameList; WindowPlacement wpTags; +WindowPlacement wpDualBoard; /* This magic number is the number of intermediate frames used @@ -386,60 +381,17 @@ XtActionsRec boardActions[] = { }; char globalTranslations[] = - ":F9: MenuItem(Actions.Resign) \n \ - :Ctrln: MenuItem(File.NewGame) \n \ - :MetaV: MenuItem(File.NewVariant) \n \ - :Ctrlo: MenuItem(File.LoadGame) \n \ - :MetaNext: MenuItem(LoadNextGameProc) \n \ + ":MetaNext: MenuItem(LoadNextGameProc) \n \ :MetaPrior: MenuItem(LoadPrevGameProc) \n \ :CtrlDown: LoadSelectedProc(3) \n \ :CtrlUp: LoadSelectedProc(-3) \n \ - :Ctrls: MenuItem(File.SaveGame) \n \ - :Ctrlc: MenuItem(Edit.CopyGame) \n \ - :Ctrlv: MenuItem(Edit.PasteGame) \n \ - :CtrlO: MenuItem(File.LoadPosition) \n \ :ShiftNext: MenuItem(LoadNextPositionProc) \n \ :ShiftPrior: MenuItem(LoadPrevPositionProc) \n \ - :CtrlS: MenuItem(File.SavePosition) \n \ - :CtrlC: MenuItem(Edit.CopyPosition) \n \ - :CtrlV: MenuItem(Edit.PastePosition) \n \ - :Ctrlq: MenuItem(File.Quit) \n \ - :Ctrlw: MenuItem(Mode.MachineWhite) \n \ - :Ctrlb: MenuItem(Mode.MachineBlack) \n \ - :Ctrlt: MenuItem(Mode.TwoMachines) \n \ - :Ctrla: MenuItem(Mode.AnalysisMode) \n \ - :Ctrlg: MenuItem(Mode.AnalyzeFile) \n \ - :Ctrle: MenuItem(Mode.EditGame) \n \ - :CtrlE: MenuItem(Mode.EditPosition) \n \ - :MetaO: MenuItem(View.EngineOutput) \n \ - :MetaE: MenuItem(View.EvaluationGraph) \n \ - :MetaG: MenuItem(View.GameList) \n \ - :MetaH: MenuItem(View.MoveHistory) \n \ :Pause: MenuItem(Mode.Pause) \n \ - :F3: MenuItem(Action.Accept) \n \ - :F4: MenuItem(Action.Decline) \n \ - :F12: MenuItem(Action.Rematch) \n \ - :F5: MenuItem(Action.CallFlag) \n \ - :F6: MenuItem(Action.Draw) \n \ - :F7: MenuItem(Action.Adjourn) \n \ - :F8: MenuItem(Action.Abort) \n \ - :F10: MenuItem(Action.StopObserving) \n \ - :F11: MenuItem(Action.StopExamining) \n \ :Ctrld: MenuItem(DebugProc) \n \ :Meta CtrlF12: MenuItem(DebugProc) \n \ - :MetaEnd: MenuItem(Edit.ForwardtoEnd) \n \ - :MetaRight: MenuItem(Edit.Forward) \n \ - :MetaHome: MenuItem(Edit.BacktoStart) \n \ - :MetaLeft: MenuItem(Edit.Backward) \n \ :Left: MenuItem(Edit.Backward) \n \ :Right: MenuItem(Edit.Forward) \n \ - :Home: MenuItem(Edit.Revert) \n \ - :End: MenuItem(Edit.TruncateGame) \n \ - :Ctrlm: MenuItem(Engine.MoveNow) \n \ - :Ctrlx: MenuItem(Engine.RetractMove) \n \ - :MetaJ: MenuItem(Options.Adjudications) \n \ - :MetaU: MenuItem(Options.CommonEngine) \n \ - :MetaT: MenuItem(Options.TimeControl) \n \ :CtrlP: MenuItem(PonderNextMove) \n " #ifndef OPTIONSDIALOG "\ @@ -450,8 +402,6 @@ char globalTranslations[] = :CtrlH: MenuItem(HideThinkingProc) \n " #endif "\ - :F1: MenuItem(Help.ManXBoard) \n \ - :F2: MenuItem(View.FlipView) \n \ :Return: TempBackwardProc() \n \ :Return: TempForwardProc() \n"; @@ -462,7 +412,7 @@ char ICSInputTranslations[] = // [HGM] vari: another hideous kludge: call extend-end first so we can be sure select-start works, // as the widget is destroyed before the up-click can call extend-end -char commentTranslations[] = ": extend-end() select-start() CommentClick() \n"; +char commentTranslations[] = ": extend-end(PRIMARY) select-start() CommentClick() \n"; String xboardResources[] = { "*Error*translations: #override\\n Return: ErrorPopDown()", @@ -473,128 +423,6 @@ String xboardResources[] = { /* Max possible square size */ #define MAXSQSIZE 256 -static int xpm_avail[MAXSQSIZE]; - -#ifdef HAVE_DIR_STRUCT - -/* Extract piece size from filename */ -static int -xpm_getsize (char *name, int len, char *ext) -{ - char *p, *d; - char buf[10]; - - if (len < 4) - return 0; - - if ((p=strchr(name, '.')) == NULL || - StrCaseCmp(p+1, ext) != 0) - return 0; - - p = name + 3; - d = buf; - - while (*p && isdigit(*p)) - *(d++) = *(p++); - - *d = 0; - return atoi(buf); -} - -/* Setup xpm_avail */ -static int -xpm_getavail (char *dirname, char *ext) -{ - DIR *dir; - struct dirent *ent; - int i; - - for (i=0; id_name, NAMLEN(ent), ext); - if (i > 0 && i < MAXSQSIZE) - xpm_avail[i] = 1; - } - - closedir(dir); - - return 0; -} - -void -xpm_print_avail (FILE *fp, char *ext) -{ - int i; - - fprintf(fp, _("Available `%s' sizes:\n"), ext); - for (i=1; i") ) ctrl = 1; + if( strstr(mi[j].accel, "") ) shift = 1; + if( strstr(mi[j].accel, "") ) alt = 1; + + /* remove all <...> */ + test = strrchr(mi[j].accel, '>'); + if ( test==NULL ) + key = strdup(mi[j].accel); + else + key = strdup(++test); // remove ">" + + /* instead of shift X11 uses the uppercase letter directly*/ + if (shift && strlen(key)==1 ) + { + *key = toupper(*key); + shift = 0; + } + + /* handle some special cases which have different names in X11 */ + if ( strncmp(key, "Page_Down", 9) == 0 ) + { + free(key); + key=strdup("Next"); + } + else if ( strncmp(key, "Page_Up", 7) == 0 ) + { + free(key); + key=strdup("Prior"); + }; + + /* create string of mods */ + if (ctrl) + mods = strdup("Ctrl "); + else + mods = strdup(""); + + if(alt) + { + mods = realloc(mods, strlen(mods) + strlen("Meta ")+1); + strncat(mods, "Meta ", 5); + }; + + if(shift) + { + mods = realloc(mods, strlen(mods) + strlen("Shift ")+1); + strncat(mods, "Shift ", 6); + }; + + // remove trailing space + if( isspace(mods[strlen(mods)-1]) ) + mods[strlen(mods)-1]='\0'; + + /* get the name for the callback, we can use MenuItem() here that will call KeyBindingProc */ + size_t namesize = snprintf(NULL, 0, "%s.%s", menuBar[i].ref, mi[j].ref); + char *name = malloc(namesize+1); + snprintf(name, namesize+1, "%s.%s", menuBar[i].ref, mi[j].ref); + + size_t buffersize = snprintf(NULL, 0, ":%s%s: MenuItem(%s) \n ", mods, key, name); + char *buffer = malloc(buffersize+1); + snprintf(buffer, buffersize+1, ":%s%s: MenuItem(%s) \n ", mods, key, name); + + /* add string to the output */ + output = realloc(output, strlen(output) + strlen(buffer)+1); + strncat(output, buffer, strlen(buffer)); + + /* clean up */ + free(key); + free(buffer); + free(name); + free(mods); + } + } + } + return output; +} + + void PrintOptions () { @@ -1025,6 +965,11 @@ PrintOptions () if(len) buf[len] = NULLCHAR, printf("%s\n", buf); } +void +SlaveResize (Option *opt) +{ +} + int main (int argc, char **argv) { @@ -1042,7 +987,7 @@ main (int argc, char **argv) debugFP = stderr; if(argc > 1 && (!strcmp(argv[1], "-v" ) || !strcmp(argv[1], "--version" ))) { - printf("%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION); + printf("%s version %s\n\n configure options: %s\n", PACKAGE_NAME, PACKAGE_VERSION, CONFIGURE_OPTIONS); exit(0); } @@ -1051,6 +996,23 @@ main (int argc, char **argv) exit(0); } + if(argc > 1 && !strcmp(argv[1], "--show-config")) { // [HGM] install: called to print config info + typedef struct {char *name, *value; } Config; + static Config configList[] = { + { "Datadir", DATADIR }, + { "Sysconfdir", SYSCONFDIR }, + { NULL } + }; + int i; + + for(i=0; configList[i].name; i++) { + if(argc > 2 && strcmp(argv[2], configList[i].name)) continue; + if(argc > 2) printf("%s", configList[i].value); + else printf("%-12s: %s\n", configList[i].name, configList[i].value); + } + exit(0); + } + programName = strrchr(argv[0], '/'); if (programName == NULL) programName = argv[0]; @@ -1323,8 +1285,13 @@ main (int argc, char **argv) if (appData.animate || appData.animateDragging) CreateAnimVars(); + + char *TranslationsTableMenus=GenerateGlobalTranslationTable (); + XtAugmentTranslations(formWidget, XtParseTranslationTable(globalTranslations)); + XtAugmentTranslations(formWidget, + XtParseTranslationTable(TranslationsTableMenus)); XtAddEventHandler(formWidget, KeyPressMask, False, (XtEventHandler) MoveTypeInProc, NULL); @@ -1559,7 +1526,7 @@ FindFont (char *pattern, int targetPxlSize) safeStrCpy(p, best, strlen(best)+1 ); } if (appData.debugMode) { - fprintf(debugFP, _("resolved %s at pixel size %d\n to %s\n"), + fprintf(debugFP, "resolved %s at pixel size %d\n to %s\n", pattern, targetPxlSize, p); } XFreeFontNames(fonts);