aboutsummaryrefslogtreecommitdiff
path: root/config.def.h
diff options
context:
space:
mode:
authorArslaan Pathan <[email protected]>2026-04-11 20:33:56 +1200
committerArslaan Pathan <[email protected]>2026-04-11 20:33:56 +1200
commit806bc568ad3b650fe056e48f694c46d4b3e284cd (patch)
treeb0aba789429298964641404edd01a7e931647c85 /config.def.h
parent4ee685b0a70acfeacf3f462d9ac88c55990e7414 (diff)
downloadcinnamon-browser-806bc568ad3b650fe056e48f694c46d4b3e284cd.tar.xz
cinnamon-browser-806bc568ad3b650fe056e48f694c46d4b3e284cd.zip
Finally, hints!
Diffstat (limited to 'config.def.h')
-rw-r--r--config.def.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h
index 16102aa..505d064 100644
--- a/config.def.h
+++ b/config.def.h
@@ -11,6 +11,7 @@
extern void tabopen(Cinnamon* cinnamon);
extern void tabclose(Cinnamon* cinnamon);
extern void set_mode(Cinnamon* cinnamon, int new_mode);
+extern void inject_hint_mode(Cinnamon* cinnamon, void (*callback)(Cinnamon*, char hint_buffer[16]));
/* guard ensures config exists/enables brower */
#define CINNAMON_ENABLED
@@ -31,6 +32,16 @@ extern void set_mode(Cinnamon* cinnamon, int new_mode);
/* Keybind definitions */
/* we use the _kbd prefix here just because, idk, good practice to keep keybinds isolated? in practice use whatever the hell you want as long as it doesnt interfere with builtin functions */
+
+static void _conf_hint_callback(Cinnamon* cinnamon, char hint_buffer[16]) {
+ if (strlen(hint_buffer) > 0) {
+ GtkWidget *webview = gtk_notebook_get_nth_page(GTK_NOTEBOOK(cinnamon->notebook), gtk_notebook_get_current_page(GTK_NOTEBOOK(cinnamon->notebook)));
+ char js[512];
+ snprintf(js, sizeof(js), "(function() {if (window.__cinnamon_link_map && window.__cinnamon_link_map['%s']) { let el = window.__cinnamon_link_map['%s']; let tag = el.tagName.toLowerCase(); if (tag === 'input' || tag === 'textarea' || tag === 'select') { el.focus(); } else { el.click(); } }})();", hint_buffer, hint_buffer);
+ webkit_web_view_run_javascript(WEBKIT_WEB_VIEW(webview), js, NULL, NULL, NULL);
+ }
+}
+
extern bool cmdbar_focused;
static void _kbd_insmode(Cinnamon* cinnamon, void* arg) {
set_mode(cinnamon, 1);
@@ -110,6 +121,10 @@ static void _kbd_forward(Cinnamon* cinnamon, void* arg) {
webkit_web_view_go_forward(WEBKIT_WEB_VIEW(webview));
}
+static void _kbd_follow(Cinnamon* cinnamon, void* arg) {
+ inject_hint_mode(cinnamon, &_conf_hint_callback);
+}
+
static const Keybind keybinds[] = {
{ "t", &_kbd_tabopen, NULL },
{ "d", &_kbd_tabclose, NULL },
@@ -122,6 +137,7 @@ static const Keybind keybinds[] = {
{ "h", &_kbd_scroll, "left" },
{ "l", &_kbd_scroll, "right" },
{ "r", &_kbd_reload, NULL },
+ { "f", &_kbd_follow, NULL },
{ "<S-h>", &_kbd_back, NULL },
{ "<S-l>", &_kbd_forward, NULL },
{ "<S-r>", &_kbd_hardreload, NULL },