Changed the default config to array of chars instead of structs.
authorDaniel Carl <danielcarl@gmx.de>
Sun, 7 Apr 2013 13:27:29 +0000 (15:27 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Sun, 7 Apr 2013 13:27:29 +0000 (15:27 +0200)
src/config.h
src/main.c

index 1d22019..d6e0e16 100644 (file)
@@ -34,123 +34,121 @@ const unsigned int SETTING_MAX_CONNS_PER_HOST = 5;
 const unsigned int INPUT_LENGTH  = 120;
 const unsigned int MAXIMUM_HINTS = 500;
 
-const struct {
-    char *command;
-} default_config[] = {
-    {"nmap gf=source"},
-    {"nmap gF=inspect"},
-    {"nmap <shift-:>=input"},
-    {"nmap <shift-/>=input /"},
-    {"nmap <shift-?>=input ?"},
-    {"smap n=search-forward"},
-    {"smap N=search-backward"},
-    {"nmap o=input :open "},
-    {"nmap t=input :tabopen "},
-    {"nmap O=inputuri :open "},
-    {"nmap T=inputuri :tabopen "},
-    {"nmap gh=open"},
-    {"nmap gH=tabopen"},
-    {"nmap u=open-closed"},
-    {"nmap U=tabopen-closed"},
-    {"nmap d=quit"},
-    {"nmap <ctrl-o>=back"},
-    {"nmap <ctrl-i>=forward"},
-    {"nmap r=reload"},
-    {"nmap R=reload!"},
-    {"nmap C=stop"},
-    {"nmap <ctrl-f>=pagedown"},
-    {"nmap <ctrl-b>=pageup"},
-    {"nmap <ctrl-d>=halfpagedown"},
-    {"nmap <ctrl-u>=halfpageup"},
-    {"nmap gg=jumptop"},
-    {"nmap G=jumpbottom"},
-    {"nmap 0=jumpleft"},
-    {"nmap $=jumpright"},
-    {"nmap h=scrollleft"},
-    {"nmap l=scrollright"},
-    {"nmap k=scrollup"},
-    {"nmap j=scrolldown"},
-    {"nmap f=hint-link"},
-    {"nmap F=hint-link-new"},
-    {"nmap ;o=hint-input-open"},
-    {"nmap ;t=hint-input-tabopen"},
-    {"nmap ;y=hint-yank"},
-    {"nmap ;i=hint-image-open"},
-    {"nmap ;I=hint-image-tabopen"},
-    {"nmap y=yank-uri"},
-    {"nmap Y=yank-selection"},
-    {"nmap p=open-clipboard"},
-    {"nmap P=tabopen-clipboard"},
-    {"nmap zi=zoomin"},
-    {"nmap zI=zoominfull"},
-    {"nmap zo=zoomout"},
-    {"nmap zO=zoomoutfull"},
-    {"nmap zz=zoomreset"},
-    {"cmap <tab>=complete"},
-    {"cmap <shift-tab>=complete-back"},
-    {"cmap <ctrl-p>=hist-prev"},
-    {"cmap <up>=hist-prev"},
-    {"cmap <ctrl-n>=hist-next"},
-    {"cmap <down>=hist-next"},
-    {"hmap <tab>=hint-focus-next"},
-    {"hmap <shift-tab>=hint-focus-prev"},
-    {"searchengine-add dl=https://duckduckgo.com/lite/?q=%s"},
-    {"searchengine-add dd=https://duckduckgo.com/?q=%s"},
-    {"searchengine-default dl"},
-    {"set images=on"},
-    {"set cursivfont=serif"},
-    {"set defaultencondig=utf-8"},
-    {"set defaultfont=sans-serif"},
-    {"set fontsize=11"},
-    {"set monofontsize=11"},
-    {"set caret=off"},
-    {"set webinspector=off"},
-    {"set offlinecache=on"},
-    {"set pagecache=on"},
-    {"set plugins=on"},
-    {"set scripts=on"},
-    {"set xssauditor=on"},
-    {"set minimumfontsize=5"},
-    {"set monofont=monospace"},
-    {"set backgrounds=on"},
-    {"set sansfont=sens-serif"},
-    {"set seriffont=serif"},
-    {"set useragent=vimb/" VERSION " (X11; Linux i686) AppleWebKit/535.22+ Compatible (Safari)"},
-    {"set stylesheet=on"},
-    {"set proxy=on"},
-    {"set cookie-timeout=4800"},
-    {"set strict-ssl=on"},
-    {"set scrollstep=40"},
-    {"set status-color-bg=#000"},
-    {"set status-color-fg=#fff"},
-    {"set status-font=monospace bold 8"},
-    {"set status-ssl-color-bg=#95e454"},
-    {"set status-ssl-color-fg=#000"},
-    {"set status-ssl-font=monospace bold 8"},
-    {"set status-sslinvalid-color-bg=#f08080"},
-    {"set status-sslinvalid-color-fg=#000"},
-    {"set status-sslinvalid-font=monospace bold 8"},
-    {"set input-bg-normal=#fff"},
-    {"set input-bg-error=#f00"},
-    {"set input-fg-normal=#000"},
-    {"set input-fg-error=#000"},
-    {"set input-font-normal=monospace normal 8"},
-    {"set input-font-error=monospace bold 8"},
-    {"set completion-font=monospace normal 8"},
-    {"set completion-fg-normal=#f6f3e8"},
-    {"set completion-fg-active=#fff"},
-    {"set completion-bg-normal=#656565"},
-    {"set completion-bg-active=#777"},
-    {"set max-completion-items=15"},
-    {"set hint-bg=#ff0"},
-    {"set hint-bg-focus=#8f0"},
-    {"set hint-fg=#000"},
-    {"set hint-style=position:absolute;z-index:100000;font-family:monospace;font-weight:bold;font-size:10px;color:#000;background-color:#fff;margin:0;padding:0px 1px;border:1px solid #444;opacity:0.7;"},
-    {"set ca-bundle=/etc/ssl/certs/ca-certificates.crt"},
-    {"set home-page=https://github.com/fanglingsu/vimb"},
-    {"set download-path=/tmp/vimb"},
-    {"set history-max-items=2000"},
-    {NULL}
+const char *default_config[] = {
+    "nmap gf=source",
+    "nmap gF=inspect",
+    "nmap <shift-:>=input",
+    "nmap <shift-/>=input /",
+    "nmap <shift-?>=input ?",
+    "smap n=search-forward",
+    "smap N=search-backward",
+    "nmap o=input :open ",
+    "nmap t=input :tabopen ",
+    "nmap O=inputuri :open ",
+    "nmap T=inputuri :tabopen ",
+    "nmap gh=open",
+    "nmap gH=tabopen",
+    "nmap u=open-closed",
+    "nmap U=tabopen-closed",
+    "nmap d=quit",
+    "nmap <ctrl-o>=back",
+    "nmap <ctrl-i>=forward",
+    "nmap r=reload",
+    "nmap R=reload!",
+    "nmap C=stop",
+    "nmap <ctrl-f>=pagedown",
+    "nmap <ctrl-b>=pageup",
+    "nmap <ctrl-d>=halfpagedown",
+    "nmap <ctrl-u>=halfpageup",
+    "nmap gg=jumptop",
+    "nmap G=jumpbottom",
+    "nmap 0=jumpleft",
+    "nmap $=jumpright",
+    "nmap h=scrollleft",
+    "nmap l=scrollright",
+    "nmap k=scrollup",
+    "nmap j=scrolldown",
+    "nmap f=hint-link",
+    "nmap F=hint-link-new",
+    "nmap ;o=hint-input-open",
+    "nmap ;t=hint-input-tabopen",
+    "nmap ;y=hint-yank",
+    "nmap ;i=hint-image-open",
+    "nmap ;I=hint-image-tabopen",
+    "nmap y=yank-uri",
+    "nmap Y=yank-selection",
+    "nmap p=open-clipboard",
+    "nmap P=tabopen-clipboard",
+    "nmap zi=zoomin",
+    "nmap zI=zoominfull",
+    "nmap zo=zoomout",
+    "nmap zO=zoomoutfull",
+    "nmap zz=zoomreset",
+    "cmap <tab>=complete",
+    "cmap <shift-tab>=complete-back",
+    "cmap <ctrl-p>=hist-prev",
+    "cmap <up>=hist-prev",
+    "cmap <ctrl-n>=hist-next",
+    "cmap <down>=hist-next",
+    "hmap <tab>=hint-focus-next",
+    "hmap <shift-tab>=hint-focus-prev",
+    "searchengine-add dl=https://duckduckgo.com/lite/?q=%s",
+    "searchengine-add dd=https://duckduckgo.com/?q=%s",
+    "searchengine-default dl",
+    "set images=on",
+    "set cursivfont=serif",
+    "set defaultencondig=utf-8",
+    "set defaultfont=sans-serif",
+    "set fontsize=11",
+    "set monofontsize=11",
+    "set caret=off",
+    "set webinspector=off",
+    "set offlinecache=on",
+    "set pagecache=on",
+    "set plugins=on",
+    "set scripts=on",
+    "set xssauditor=on",
+    "set minimumfontsize=5",
+    "set monofont=monospace",
+    "set backgrounds=on",
+    "set sansfont=sens-serif",
+    "set seriffont=serif",
+    "set useragent=vimb/" VERSION " (X11; Linux i686) AppleWebKit/535.22+ Compatible (Safari)",
+    "set stylesheet=on",
+    "set proxy=on",
+    "set cookie-timeout=4800",
+    "set strict-ssl=on",
+    "set scrollstep=40",
+    "set status-color-bg=#000",
+    "set status-color-fg=#fff",
+    "set status-font=monospace bold 8",
+    "set status-ssl-color-bg=#95e454",
+    "set status-ssl-color-fg=#000",
+    "set status-ssl-font=monospace bold 8",
+    "set status-sslinvalid-color-bg=#f08080",
+    "set status-sslinvalid-color-fg=#000",
+    "set status-sslinvalid-font=monospace bold 8",
+    "set input-bg-normal=#fff",
+    "set input-bg-error=#f00",
+    "set input-fg-normal=#000",
+    "set input-fg-error=#000",
+    "set input-font-normal=monospace normal 8",
+    "set input-font-error=monospace bold 8",
+    "set completion-font=monospace normal 8",
+    "set completion-fg-normal=#f6f3e8",
+    "set completion-fg-active=#fff",
+    "set completion-bg-normal=#656565",
+    "set completion-bg-active=#777",
+    "set max-completion-items=15",
+    "set hint-bg=#ff0",
+    "set hint-bg-focus=#8f0",
+    "set hint-fg=#000",
+    "set hint-style=position:absolute;z-index:100000;font-family:monospace;font-weight:bold;font-size:10px;color:#000;background-color:#fff;margin:0;padding:0px 1px;border:1px solid #444;opacity:0.7;",
+    "set ca-bundle=/etc/ssl/certs/ca-certificates.crt",
+    "set home-page=https://github.com/fanglingsu/vimb",
+    "set download-path=/tmp/vimb",
+    "set history-max-items=2000",
+    NULL
 };
 
 #endif /* end of include guard: _CONFIG_H */
index 38b9565..3bd1321 100644 (file)
@@ -681,9 +681,9 @@ static void read_config(void)
     char *line, **lines;
 
     /* load default config */
-    for (guint i = 0; default_config[i].command != NULL; i++) {
-        if (!command_run_string(default_config[i].command)) {
-            fprintf(stderr, "Invalid default config: %s\n", default_config[i].command);
+    for (guint i = 0; default_config[i] != NULL; i++) {
+        if (!command_run_string(default_config[i])) {
+            fprintf(stderr, "Invalid default config: %s\n", default_config[i]);
         }
     }
 
@@ -995,8 +995,8 @@ int main(int argc, char *argv[])
     }
     if (dump) {
         /* load default config */
-        for (guint i = 0; default_config[i].command != NULL; i++) {
-            fprintf(stdout, "%s\n", default_config[i].command);
+        for (guint i = 0; default_config[i] != NULL; i++) {
+            fprintf(stdout, "%s\n", default_config[i]);
         }
         return EXIT_SUCCESS;
     }