Abbreviate DATADIR to ~~ while saving XB themes
authorH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 10 May 2016 19:52:56 +0000 (21:52 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 10 May 2016 19:52:56 +0000 (21:52 +0200)
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
dialogs.c
winboard/winboard.c

index 2e9e18d..c5d9e9a 100644 (file)
--- 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");
        }
index 64001c2..9bab615 100644 (file)
--- 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;
+}
index e4b8692..2301293 100644 (file)
@@ -3755,6 +3755,7 @@ void DrawSeekClose()
 \r
 \r
 \r
+\r
 VOID\r
 HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board)\r
 {\r
@@ -6272,6 +6273,7 @@ InitComboStringsFromOption(HANDLE hwndCombo, char *str)
     str = buf1;\r
   }\r
 \r
+\r
   SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0);\r
 \r
   for (;;) {\r
@@ -8530,6 +8532,11 @@ DisplayInformation(char *str)
   (void) MessageBox(hwndMain, str, _("Information"), MB_OK|MB_ICONINFORMATION);\r
 }\r
 \r
+char *\r
+Shorten (char *s)\r
+{\r
+  return s;\r
+}\r
 \r
 VOID\r
 DisplayNote(char *str)\r