From 76e5723516d8510005ef608575a6ee6b5848e2c2 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Tue, 10 May 2016 21:52:56 +0200 Subject: [PATCH] Abbreviate DATADIR to ~~ while saving XB themes The path name of theme files is typically quite long in XBoard, where installed data is very deep in the file-system tree. This path is now recognized, and replacend by its abbreviation ~~ when storing a theme in the -themeNames option. --- backend.c | 8 +++++--- dialogs.c | 8 ++++++++ winboard/winboard.c | 7 +++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/backend.c b/backend.c index 2e9e18d..c5d9e9a 100644 --- a/backend.c +++ b/backend.c @@ -19081,8 +19081,10 @@ LoadTheme () q = appData.themeNames; snprintf(buf, BUF_SIZ, "\"%s\"", nickName); if(appData.useBitmaps) { - snprintf(buf+strlen(buf), BUF_SIZ-strlen(buf), " -ubt true -lbtf \"%s\" -dbtf \"%s\" -lbtm %d -dbtm %d", - appData.liteBackTextureFile, appData.darkBackTextureFile, + snprintf(buf+strlen(buf), BUF_SIZ-strlen(buf), " -ubt true -lbtf \"%s\"", + Shorten(appData.liteBackTextureFile)); + snprintf(buf+strlen(buf), BUF_SIZ-strlen(buf), " -dbtf \"%s\" -lbtm %d -dbtm %d", + Shorten(appData.darkBackTextureFile), appData.liteBackTextureMode, appData.darkBackTextureMode ); } else { @@ -19109,7 +19111,7 @@ LoadTheme () } else { snprintf(buf+strlen(buf), BUF_SIZ-strlen(buf), " -upf false"); if(appData.pieceDirectory[0]) { - snprintf(buf+strlen(buf), BUF_SIZ-strlen(buf), " -pid \"%s\"", appData.pieceDirectory); + snprintf(buf+strlen(buf), BUF_SIZ-strlen(buf), " -pid \"%s\"", Shorten(appData.pieceDirectory)); if(appData.trueColors != 2) // 2 is a kludge to suppress this in WinBoard snprintf(buf+strlen(buf), BUF_SIZ-strlen(buf), " -trueColors %s", appData.trueColors ? "true" : "false"); } diff --git a/dialogs.c b/dialogs.c index 64001c2..9bab615 100644 --- a/dialogs.c +++ b/dialogs.c @@ -3395,3 +3395,11 @@ ActivateTheme (int col) DrawPosition(True, NULL); } +char * +Shorten (char *s) +{ + static char buf[MSG_SIZ]; + if(strstr(s, dataDir) != s) return s; + snprintf(buf, MSG_SIZ, "~~%s", s + strlen(dataDir)); + return buf; +} diff --git a/winboard/winboard.c b/winboard/winboard.c index e4b8692..2301293 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -3755,6 +3755,7 @@ void DrawSeekClose() + VOID HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) { @@ -6272,6 +6273,7 @@ InitComboStringsFromOption(HANDLE hwndCombo, char *str) str = buf1; } + SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0); for (;;) { @@ -8530,6 +8532,11 @@ DisplayInformation(char *str) (void) MessageBox(hwndMain, str, _("Information"), MB_OK|MB_ICONINFORMATION); } +char * +Shorten (char *s) +{ + return s; +} VOID DisplayNote(char *str) -- 1.7.0.4