diff --git a/hinting.js b/hinting.js index 0ceeb2b..b7ae5f8 100644 --- a/hinting.js +++ b/hinting.js @@ -28,7 +28,7 @@ THE SOFTWARE. function Hints() { var config = { maxAllowedHints: 500, - hintCss: "z-index:100000;font-family:monospace;font-size:10px;" + hintCss: "z-index:100000;font-family:monospace;font-size:%%%HINTING_FONT_SIZE_PLACEHOLDER%%%px;" + "font-weight:bold;color:white;background-color:red;" + "padding:0px 1px;position:absolute;", hintClass: "hinting_mode_hint", diff --git a/settings.c b/settings.c index 9267d69..65a5a19 100644 --- a/settings.c +++ b/settings.c @@ -65,6 +65,7 @@ int edit_mode = XT_EM_HYBRID; char *include_config = NULL; int anonymize_headers = 0; int tabless = 0; /* allow only 1 tab */ +int hinting_font_size = 10; /* 10 px by default */ /* runtime settings */ int show_tabs = XT_DS_SHOW_TABS; /* show tabs on notebook */ @@ -293,6 +294,7 @@ int check_statusbar_font(char **); int check_statusbar_style(char **); int check_tab_style(char **); int check_tabless(char **); +int check_hinting_font_size(char **); int check_tabbar_font(char **); int check_url_regex(char **); int check_userstyle(char **); @@ -577,6 +579,7 @@ struct settings rs[] = { { "tab_style", XT_S_STR, 0, NULL, NULL,&s_tab_style, NULL, set_tab_style_rt, check_tab_style, TT_TAB_STYLE }, { "tabbar_font", XT_S_STR, 0, NULL, &tabbar_font_name, NULL, NULL, set_tabbar_font, check_tabbar_font, TT_TABBAR_FONT }, { "tabless", XT_S_BOOL, 0, &tabless, NULL, NULL, NULL, NULL, check_tabless, TT_TABLESS }, + { "hinting_font_size", XT_S_INT, 0, &hinting_font_size, NULL, NULL, NULL, NULL, check_hinting_font_size, TT_HINTING_FONT_SIZE }, { "url_regex", XT_S_STR, 0, NULL, &url_regex, NULL, NULL, set_url_regex, check_url_regex, TT_URL_REGEX }, { "userstyle", XT_S_STR, 0, NULL, NULL,&s_userstyle, NULL, set_userstyle_rt, check_userstyle, TT_USERSTYLE }, { "userstyle_global", XT_S_BOOL, 0, &userstyle_global, NULL, NULL, NULL, set_userstyle_global, check_userstyle_global, TT_USERSTYLE_GLOBAL }, @@ -3444,6 +3447,15 @@ check_window_width(char **tt) return (window_width != 1024); } + +int +check_hinting_font_size(char **tt) +{ + *tt = g_strdup_printf("Default: %d", 10); + return (hinting_font_size != 10); +} + + int check_work_dir(char **tt) { diff --git a/xombrero.1 b/xombrero.1 index b9b25da..3699805 100644 --- a/xombrero.1 +++ b/xombrero.1 @@ -1689,6 +1689,9 @@ Set the work directory where all scratch files are stored. Default is .Cm ~/.xombrero . +.It Cm hinting_font_size +Sets the size, in pixels, of font used for numbers prefixing the +links when hinting is active. Default is 10. .El .Sh HISTORY .Nm diff --git a/xombrero.c b/xombrero.c index 39ccf32..bb723ca 100644 --- a/xombrero.c +++ b/xombrero.c @@ -1079,6 +1079,9 @@ js_ref_to_string(JSContextRef context, JSValueRef ref) #define XT_JS_INSERT ("insert;") #define XT_JS_INSERT_LEN (strlen(XT_JS_INSERT)) +static char *JS_HINTING_PARSED = NULL; +#define JS_HINTING_ACTUAL (JS_HINTING_PARSED?JS_HINTING_PARSED:JS_HINTING) + int run_script(struct tab *t, char *s) { @@ -1089,7 +1092,7 @@ run_script(struct tab *t, char *s) char *es; DNPRINTF(XT_D_JS, "%s: tab %d %s\n", __func__, - t->tab_id, s == (char *)JS_HINTING ? "JS_HINTING" : s); + t->tab_id, s == (char *)JS_HINTING_ACTUAL ? "JS_HINTING" : s); frame = webkit_web_view_get_main_frame(t->wv); ctx = webkit_web_frame_get_global_context(frame); @@ -4250,7 +4253,9 @@ notify_load_status_cb(WebKitWebView* wview, GParamSpec* pspec, struct tab *t) } show_ca_status(t, uri); - run_script(t, JS_HINTING); + + + run_script(t, JS_HINTING_ACTUAL); if (enable_autoscroll) run_script(t, JS_AUTOSCROLL); break; @@ -8477,6 +8482,25 @@ welcome(void) "wiki page

"); } + +void +setup_hinting(void) +{ + const char *magic = "%%%HINTING_FONT_SIZE_PLACEHOLDER%%%"; + size_t n_magic = strlen(magic); + size_t n_max = 0; + + if(!(JS_HINTING)) return; + + char *magic_ptr = strstr(JS_HINTING, magic); + if(!magic_ptr) return; + + JS_HINTING_PARSED = malloc((n_max = strlen(JS_HINTING))+1); + char *rest = stpncpy(JS_HINTING_PARSED, JS_HINTING, magic_ptr-JS_HINTING); + snprintf(rest, n_max - (rest-JS_HINTING_PARSED), "%d%s", + hinting_font_size, magic_ptr + n_magic); +} + int main(int argc, char **argv) { @@ -8914,6 +8938,8 @@ main(int argc, char **argv) setup_css(); #endif + setup_hinting(); + gtk_main(); gnutls_global_deinit(); diff --git a/xombrero.h b/xombrero.h index 303ef1c..2aad0c1 100644 --- a/xombrero.h +++ b/xombrero.h @@ -882,6 +882,8 @@ extern int browser_mode; extern int enable_localstorage; extern char *statusbar_elems; +extern int hinting_font_size; + #if SOUP_CHECK_VERSION(2, 42, 2) extern GProxyResolver *proxy_uri; extern gchar *proxy_exclude[];