mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-03 07:15:29 -04:00
commit
4c1846f11b
9 changed files with 57 additions and 22 deletions
|
|
@ -275,8 +275,8 @@ be changed with the `url-launch` option.
|
||||||
what activating an URL _does_; instead of opening it, it copies it to
|
what activating an URL _does_; instead of opening it, it copies it to
|
||||||
the clipboard. It is unbound by default.
|
the clipboard. It is unbound by default.
|
||||||
|
|
||||||
Both the jump label colors, and the URL underline color can be
|
Jump label colors, the URL underline color, and the letters used in
|
||||||
configured, independently.
|
the jump label key sequences can be configured.
|
||||||
|
|
||||||
|
|
||||||
## Alt/meta
|
## Alt/meta
|
||||||
|
|
|
||||||
44
config.c
44
config.c
|
|
@ -397,6 +397,25 @@ str_to_double(const char *s, double *res)
|
||||||
return errno == 0 && *end == '\0';
|
return errno == 0 && *end == '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
str_to_wchars(const char *s, wchar_t **res, struct config *conf,
|
||||||
|
const char *path, int lineno,
|
||||||
|
const char *section, const char *key)
|
||||||
|
{
|
||||||
|
*res = NULL;
|
||||||
|
|
||||||
|
size_t chars = mbstowcs(NULL, s, 0);
|
||||||
|
if (chars == (size_t)-1) {
|
||||||
|
LOG_AND_NOTIFY_ERR("%s:%d: [%s]: %s: invalid string: %s",
|
||||||
|
path, lineno, section, key, s);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*res = xmalloc((chars + 1) * sizeof(wchar_t));
|
||||||
|
mbstowcs(*res, s, chars + 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
str_to_color(const char *s, uint32_t *color, bool allow_alpha,
|
str_to_color(const char *s, uint32_t *color, bool allow_alpha,
|
||||||
struct config *conf, const char *path, int lineno,
|
struct config *conf, const char *path, int lineno,
|
||||||
|
|
@ -712,18 +731,25 @@ parse_section_main(const char *key, const char *value, struct config *conf,
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (strcmp(key, "word-delimiters") == 0) {
|
else if (strcmp(key, "word-delimiters") == 0) {
|
||||||
size_t chars = mbstowcs(NULL, value, 0);
|
wchar_t *word_delimiters;
|
||||||
if (chars == (size_t)-1) {
|
if (!str_to_wchars(value, &word_delimiters, conf, path, lineno,
|
||||||
LOG_AND_NOTIFY_ERR(
|
"default", "word-delimiters"))
|
||||||
"%s:%d: [default]: word-delimiters: invalid string: %s",
|
{
|
||||||
path, lineno, value);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(conf->word_delimiters);
|
free(conf->word_delimiters);
|
||||||
|
conf->word_delimiters = word_delimiters;
|
||||||
|
}
|
||||||
|
|
||||||
conf->word_delimiters = xmalloc((chars + 1) * sizeof(wchar_t));
|
else if (strcmp(key, "jump-label-letters") == 0) {
|
||||||
mbstowcs(conf->word_delimiters, value, chars + 1);
|
wchar_t *letters;
|
||||||
|
if (!str_to_wchars(value, &letters, conf, path, lineno,
|
||||||
|
"default", "jump-label-letters"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
free(conf->jump_label_letters);
|
||||||
|
conf->jump_label_letters = letters;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (strcmp(key, "notify") == 0) {
|
else if (strcmp(key, "notify") == 0) {
|
||||||
|
|
@ -2126,6 +2152,7 @@ config_load(struct config *conf, const char *conf_path,
|
||||||
.title = xstrdup("foot"),
|
.title = xstrdup("foot"),
|
||||||
.app_id = xstrdup("foot"),
|
.app_id = xstrdup("foot"),
|
||||||
.word_delimiters = xwcsdup(L",│`|:\"'()[]{}<>"),
|
.word_delimiters = xwcsdup(L",│`|:\"'()[]{}<>"),
|
||||||
|
.jump_label_letters = xwcsdup(L"sadfjklewcmpgh"),
|
||||||
.size = {
|
.size = {
|
||||||
.type = CONF_SIZE_PX,
|
.type = CONF_SIZE_PX,
|
||||||
.width = 700,
|
.width = 700,
|
||||||
|
|
@ -2340,6 +2367,7 @@ config_free(struct config conf)
|
||||||
free(conf.title);
|
free(conf.title);
|
||||||
free(conf.app_id);
|
free(conf.app_id);
|
||||||
free(conf.word_delimiters);
|
free(conf.word_delimiters);
|
||||||
|
free(conf.jump_label_letters);
|
||||||
free(conf.scrollback.indicator.text);
|
free(conf.scrollback.indicator.text);
|
||||||
free_spawn_template(&conf.notify);
|
free_spawn_template(&conf.notify);
|
||||||
free_spawn_template(&conf.url_launch);
|
free_spawn_template(&conf.url_launch);
|
||||||
|
|
|
||||||
1
config.h
1
config.h
|
|
@ -64,6 +64,7 @@ struct config {
|
||||||
char *title;
|
char *title;
|
||||||
char *app_id;
|
char *app_id;
|
||||||
wchar_t *word_delimiters;
|
wchar_t *word_delimiters;
|
||||||
|
wchar_t *jump_label_letters;
|
||||||
bool login_shell;
|
bool login_shell;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
|
||||||
|
|
@ -262,8 +262,8 @@ be changed with the *url-launch* option.
|
||||||
what activating an URL _does_; instead of opening it, it copies it to
|
what activating an URL _does_; instead of opening it, it copies it to
|
||||||
the clipboard. It is unbound by default.
|
the clipboard. It is unbound by default.
|
||||||
|
|
||||||
Both the jump label colors, and the URL underline color can be
|
Jump label colors, the URL underline color, and the letters used in
|
||||||
configured, independently.
|
the jump label key sequences can be configured.
|
||||||
|
|
||||||
# ALT/META CHARACTERS
|
# ALT/META CHARACTERS
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,10 @@ in this order:
|
||||||
text. Note that whitespace characters are _always_ word
|
text. Note that whitespace characters are _always_ word
|
||||||
delimiters, regardless of this setting. Default: _,│`|:"'()[]{}<>_
|
delimiters, regardless of this setting. Default: _,│`|:"'()[]{}<>_
|
||||||
|
|
||||||
|
*jump-label-letters*
|
||||||
|
String of characters that will be when generating key sequences
|
||||||
|
for URL jump labels. Default: _sadfjklewcmpgh_.
|
||||||
|
|
||||||
*notify*
|
*notify*
|
||||||
Command to execute to display a notification. _${title}_ and
|
Command to execute to display a notification. _${title}_ and
|
||||||
_${body}_ will be replaced with the notification's actual _title_
|
_${body}_ will be replaced with the notification's actual _title_
|
||||||
|
|
|
||||||
1
foot.ini
1
foot.ini
|
|
@ -26,6 +26,7 @@
|
||||||
# bold-text-in-bright=no
|
# bold-text-in-bright=no
|
||||||
# bell=none
|
# bell=none
|
||||||
# word-delimiters=,│`|:"'()[]{}<>
|
# word-delimiters=,│`|:"'()[]{}<>
|
||||||
|
# jump-label-letters=sadfjklewcmpgh
|
||||||
# selection-target=primary
|
# selection-target=primary
|
||||||
# workers=<number of logical CPUs>
|
# workers=<number of logical CPUs>
|
||||||
|
|
||||||
|
|
|
||||||
2
input.c
2
input.c
|
|
@ -281,7 +281,7 @@ execute_binding(struct seat *seat, struct terminal *term,
|
||||||
: URL_ACTION_LAUNCH;
|
: URL_ACTION_LAUNCH;
|
||||||
|
|
||||||
urls_collect(term, url_action, &term->urls);
|
urls_collect(term, url_action, &term->urls);
|
||||||
urls_assign_key_combos(&term->urls);
|
urls_assign_key_combos(term->conf, &term->urls);
|
||||||
urls_render(term);
|
urls_render(term);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
url-mode.c
16
url-mode.c
|
|
@ -125,8 +125,8 @@ urls_input(struct seat *seat, struct terminal *term, uint32_t key,
|
||||||
const size_t key_len = wcslen(it->item.key);
|
const size_t key_len = wcslen(it->item.key);
|
||||||
|
|
||||||
if (key_len >= seq_len + 1 &&
|
if (key_len >= seq_len + 1 &&
|
||||||
wcsncmp(url->key, term->url_keys, seq_len) == 0 &&
|
wcsncasecmp(url->key, term->url_keys, seq_len) == 0 &&
|
||||||
url->key[seq_len] == wc)
|
towlower(url->key[seq_len]) == towlower(wc))
|
||||||
{
|
{
|
||||||
is_valid = true;
|
is_valid = true;
|
||||||
if (key_len == seq_len + 1) {
|
if (key_len == seq_len + 1) {
|
||||||
|
|
@ -353,11 +353,11 @@ wcscmp_qsort_wrapper(const void *_a, const void *_b)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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 */
|
const wchar_t *alphabet = conf->jump_label_letters;
|
||||||
static const wchar_t alphabet[] = L"sadfjklewcmpgh";
|
const size_t alphabet_len = wcslen(alphabet);
|
||||||
static const size_t alphabet_len = ALEN(alphabet) - 1;
|
|
||||||
|
|
||||||
size_t hints_count = 1;
|
size_t hints_count = 1;
|
||||||
wchar_t **hints = xmalloc(hints_count * sizeof(hints[0]));
|
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
|
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);
|
const size_t count = tll_length(*urls);
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wchar_t *combos[count];
|
wchar_t *combos[count];
|
||||||
generate_key_combos(count, combos);
|
generate_key_combos(conf, count, combos);
|
||||||
|
|
||||||
size_t idx = 0;
|
size_t idx = 0;
|
||||||
tll_foreach(*urls, it)
|
tll_foreach(*urls, it)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
#include <tllist.h>
|
#include <tllist.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
|
||||||
static inline bool urls_mode_is_active(const struct terminal *term)
|
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(
|
void urls_collect(
|
||||||
const struct terminal *term, enum url_action action, url_list_t *urls);
|
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_render(struct terminal *term);
|
||||||
void urls_reset(struct terminal *term);
|
void urls_reset(struct terminal *term);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue