aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-02-13 10:43:28 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-02-13 10:43:28 +0000
commitc7006661f5edc55cf235a647da67e0e26e7fe594 (patch)
tree1a8df05cc5fc9f12fb5359448aa8af7a6a4ad532
parentdoc: foot.ini.5: document jump-label-letters (diff)
url-mode: use ‘jump-label-letters’ as the alphabet for key sequences
Instead of hard coding the alphabet to “sadfjklewcmpgh”, use the letters from ‘jump-label-letters’. Closes #355
-rw-r--r--input.c2
-rw-r--r--url-mode.c12
-rw-r--r--url-mode.h3
3 files changed, 9 insertions, 8 deletions
diff --git a/input.c b/input.c
index 64ab2065..b7b2d290 100644
--- a/input.c
+++ b/input.c
@@ -281,7 +281,7 @@ execute_binding(struct seat *seat, struct terminal *term,
: URL_ACTION_LAUNCH;
urls_collect(term, url_action, &term->urls);
- urls_assign_key_combos(&term->urls);
+ urls_assign_key_combos(term->conf, &term->urls);
urls_render(term);
return true;
}
diff --git a/url-mode.c b/url-mode.c
index 6aa7b4b8..df0f8fb8 100644
--- a/url-mode.c
+++ b/url-mode.c
@@ -353,11 +353,11 @@ wcscmp_qsort_wrapper(const void *_a, const void *_b)
}
static void
-generate_key_combos(size_t count, wchar_t *combos[static count])
+generate_key_combos(const struct config *conf,
+ size_t count, wchar_t *combos[static count])
{
- /* vimium default */
- static const wchar_t alphabet[] = L"sadfjklewcmpgh";
- static const size_t alphabet_len = ALEN(alphabet) - 1;
+ const wchar_t *alphabet = conf->jump_label_letters;
+ const size_t alphabet_len = wcslen(alphabet);
size_t hints_count = 1;
wchar_t **hints = xmalloc(hints_count * sizeof(hints[0]));
@@ -410,14 +410,14 @@ generate_key_combos(size_t count, wchar_t *combos[static count])
}
void
-urls_assign_key_combos(url_list_t *urls)
+urls_assign_key_combos(const struct config *conf, url_list_t *urls)
{
const size_t count = tll_length(*urls);
if (count == 0)
return;
wchar_t *combos[count];
- generate_key_combos(count, combos);
+ generate_key_combos(conf, count, combos);
size_t idx = 0;
tll_foreach(*urls, it)
diff --git a/url-mode.h b/url-mode.h
index 12d20192..28abde18 100644
--- a/url-mode.h
+++ b/url-mode.h
@@ -4,6 +4,7 @@
#include <xkbcommon/xkbcommon.h>
#include <tllist.h>
+#include "config.h"
#include "terminal.h"
static inline bool urls_mode_is_active(const struct terminal *term)
@@ -13,7 +14,7 @@ static inline bool urls_mode_is_active(const struct terminal *term)
void urls_collect(
const struct terminal *term, enum url_action action, url_list_t *urls);
-void urls_assign_key_combos(url_list_t *urls);
+void urls_assign_key_combos(const struct config *conf, url_list_t *urls);
void urls_render(struct terminal *term);
void urls_reset(struct terminal *term);