I was getting caught up on some old items from the mailing list when I
came across this old thread:
https://www.mail-archive.com/[email protected]/msg00234.html
I agreed with Karryana's idea that a way of showing a link destination
without having to switch to the mouse or yank to the clipboard would
be useful, as I know how irritated I was when the status bar
disappeared from my primary browser.
So, I've went ahead and implemented this, using the ";l" shortcut.
This included a minor refactoring to share code with the mouse hover
handling. Please see the attached simple patch and let me know if you
have any concerns or better suggestions.
Morgan
From d72570ec269425a11017ef6f82d2983cf10a1cb3 Mon Sep 17 00:00:00 2001
From: Morgan Howe <[email protected]>
Date: Fri, 19 Sep 2014 15:38:24 +0800
Subject: [PATCH] Add support for ";l" to show a link destination in the status
bar.
---
hinting.js | 1 +
keymap.h | 1 +
main.c | 35 ++++++++++++++++++++++++++++-------
3 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/hinting.js b/hinting.js
index 4997cae..ffeb20a 100644
--- a/hinting.js
+++ b/hinting.js
@@ -262,6 +262,7 @@ function Hints() {
case "F": result = _openNewWindow(el); break;
case "i": result = "open;" + _getElemtSource(el); break;
case "I": result = "tabopen;" + _getElemtSource(el); break;
+ case "l": result = "show_link;" + _getElemtSource(el); break;
case "s": result = "save;" + _getElemtSource(el); break;
case "y": result = "yank;" + _getElemtSource(el); break;
case "O": result = "colon;" + _getElemtSource(el); break;
diff --git a/keymap.h b/keymap.h
index 86aea55..0dda914 100644
--- a/keymap.h
+++ b/keymap.h
@@ -104,6 +104,7 @@ Key keys[] = {
{ 0, 0, GDK_period, input, {.s = "."} },
{ 0, 0, GDK_comma, input, {.s = ","} },
{ 0, GDK_semicolon, GDK_i, input, {.s = ";i"} },
+ { 0, GDK_semicolon, GDK_l, input, {.s = ";l"} },
{ 0, GDK_semicolon, GDK_s, input, {.s = ";s"} },
{ 0, GDK_semicolon, GDK_y, input, {.s = ";y"} },
{ 0, GDK_semicolon, GDK_o, input, {.s = ";o"} },
diff --git a/main.c b/main.c
index d70f88a..7131b0c 100644
--- a/main.c
+++ b/main.c
@@ -105,6 +105,7 @@ static void download_progress(WebKitDownload *d, GParamSpec *pspec);
static void set_widget_font_and_color(GtkWidget *widget, const char *font_str,
const char *bg_color_str, const char *fg_color_str);
static void scripts_run_user_file(void);
+static void show_link(const char *link);
static gboolean history(void);
static gboolean process_set_line(char *line);
@@ -459,18 +460,24 @@ set_widget_font_and_color(GtkWidget *widget, const char *font_str, const char *b
return;
}
+static void
+show_link(const char *link) {
+ char *markup;
+
+ markup = g_markup_printf_escaped("<span font=\"%s\">Link: %s</span>", statusfont, link);
+ gtk_label_set_markup(GTK_LABEL(client.gui.status_url), markup);
+ strncpy(client.state.rememberedURI, link, BUF_SIZE);
+ g_free(markup);
+}
+
void
webview_hoverlink_cb(WebKitWebView *webview, char *title, char *link, gpointer data) {
const char *uri = webkit_web_view_get_uri(webview);
- char *markup;
memset(client.state.rememberedURI, 0, BUF_SIZE);
- if (link) {
- markup = g_markup_printf_escaped("<span font=\"%s\">Link: %s</span>", statusfont, link);
- gtk_label_set_markup(GTK_LABEL(client.gui.status_url), markup);
- strncpy(client.state.rememberedURI, link, BUF_SIZE);
- g_free(markup);
- } else
+ if (link)
+ show_link(link);
+ else
update_url(uri);
}
@@ -747,6 +754,9 @@ static gboolean inputbox_changed_cb(GtkEditable *entry, gpointer user_data) {
case 'I':
a.s = g_strconcat("hints.createHints('", text + 2, "', 'I');", NULL);
break;
+ case 'l':
+ a.s = g_strconcat("hints.createHints('", text + 2, "', 'l');", NULL);
+ break;
}
break;
}
@@ -1150,6 +1160,9 @@ input(const Arg *arg) {
case 'I':
a.s = g_strdup("hints.createHints('', 'I');");
break;
+ case 'l':
+ a.s = g_strdup("hints.createHints('', 'l');");
+ break;
}
}
break;
@@ -1622,6 +1635,14 @@ script(const Arg *arg) {
a.i = TargetNew;
a.s = (strchr(value, ';') + 1);
open_arg(&a);
+ } else if (strncmp(value, "show_link;", 10) == 0) {
+ a.i = ModeNormal;
+ set(&a);
+ char *link = strchr(value, ';') + 1;
+ if (link) {
+ memset(client.state.rememberedURI, 0, BUF_SIZE);
+ show_link(link);
+ }
} else if (strncmp(value, "error;", 6) == 0) {
a.i = Error;
set(&a);
--
2.0.4
------------------------------------------------------------------------------
Slashdot TV. Video for Nerds. Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
Vimprobable-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vimprobable-users