From: Daniel Carl Date: Sat, 23 Mar 2013 10:00:28 +0000 (+0100) Subject: Put the default settings in config.h. X-Git-Url: https://git.owens.tech/git.owens.tech/git.owens.tech/git?a=commitdiff_plain;h=b8c4a0a3da6217f8f14ea7dd9d50c63d9f8d5591;p=vimb.git Put the default settings in config.h. Now the default settings are also put in the config.h so that it's easy to print all default settings and keybindings to stdout. Added new option to dump all default settings and keybindings to stdout (-D). Parsing from default config is only a little slower than the previous approach, but it more equal to the other configuration stuff. --- diff --git a/src/config.h b/src/config.h index 648aa43..7d3341b 100644 --- a/src/config.h +++ b/src/config.h @@ -92,6 +92,81 @@ const struct { {"hmap =hint-focus-prev"}, {"searchengine-add dl=https://duckduckgo.com/lite/?q=%s"}, {"searchengine-add dd=https://duckduckgo.com/?q=%s"}, + {"set images=on"}, + {"set shrinkimages=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 dnsprefetching=on"}, + {"set dompaste=off"}, + {"set frameflattening=off"}, + {"set enable-file-access-from-file-uris=off"}, + {"set enable-html5-database=off"}, + {"set enable-html5-local-storage=off"}, + {"set javaapplet=off"}, + {"set offlinecache=on"}, + {"set pagecache=on"}, + {"set plugins=on"}, + {"set scripts=on"}, + {"set enable-site-specific-quirks=off"}, + {"set enable-spatial-navigation=off"}, + {"set spell=off"}, + {"set enable-universal-access-from-file-uris=off"}, + {"set enable-webgl=off"}, + {"set xssauditor=on"}, + {"set enforce-96-dpi=off"}, + {"set fantasyfont=serif"}, + {"set javascript-can-access-clipboard=off"}, + {"set javascript-can-open-windows-automatically=off"}, + {"set minimumfontsize=5"}, + {"set minimum-logical-font-size=5"}, + {"set monofont=monospace"}, + {"set backgrounds=on"}, + {"set resizetextareas=on"}, + {"set sansfont=sens-serif"}, + {"set seriffont=serif"}, + {"set spelllang="}, + {"set tab-key-cycles-through-elements=on"}, + {"set useragent=vimb/" VERSION " (X11; Linux i686) AppleWebKit/535.22+ Compatible (Safari)"}, + {"set zoomstep=0.1"}, + {"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=500"}, {NULL} }; diff --git a/src/main.c b/src/main.c index 156b133..8461ec7 100644 --- a/src/main.c +++ b/src/main.c @@ -1012,10 +1012,12 @@ int main(int argc, char* argv[]) { static char* winid = NULL; static gboolean ver = false; + static gboolean print_config = false; static GError* err; static GOptionEntry opts[] = { {"version", 'v', 0, G_OPTION_ARG_NONE, &ver, "Print version", NULL}, {"embed", 'e', 0, G_OPTION_ARG_STRING, &winid, "Reparents to window specified by xid", NULL}, + {"print-config", 'D', 0, G_OPTION_ARG_NONE, &print_config, "Print the value of all configuration options to stdout", NULL}, {NULL} }; /* Initialize GTK+ */ @@ -1027,7 +1029,14 @@ int main(int argc, char* argv[]) } if (ver) { - fprintf(stderr, "%s/%s (build %s %s)\n", PROJECT, VERSION, __DATE__, __TIME__); + fprintf(stdout, "%s/%s (build %s %s)\n", PROJECT, VERSION, __DATE__, __TIME__); + return EXIT_SUCCESS; + } + if (print_config) { + /* load default config */ + for (guint i = 0; default_config[i].command != NULL; i++) { + fprintf(stdout, "%s\n", default_config[i].command); + } return EXIT_SUCCESS; } diff --git a/src/setting.c b/src/setting.c index a663baf..12cc7b5 100644 --- a/src/setting.c +++ b/src/setting.c @@ -129,14 +129,13 @@ static Setting default_settings[] = { void setting_init(void) { Setting* s; - guint i; + unsigned int i; vb.settings = g_hash_table_new(g_str_hash, g_str_equal); for (i = 0; i < LENGTH(default_settings); i++) { s = &default_settings[i]; /* use alias as key if available */ g_hash_table_insert(vb.settings, (gpointer)s->alias != NULL ? s->alias : s->name, s); - s->func(s, FALSE); } }