mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-06 01:40:22 -05:00
config: add ‘none’ as a possible value for ‘selection-target’
When ‘selection-target’ is set to ‘none’, selecting text does not copy the text to _any_ clipboard. This patch also refactors the value parsing to be data driven.
This commit is contained in:
parent
07f6b3b1af
commit
4f578189cc
3 changed files with 22 additions and 12 deletions
30
config.c
30
config.c
|
|
@ -674,19 +674,25 @@ parse_section_main(const char *key, const char *value, struct config *conf,
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (strcmp(key, "selection-target") == 0) {
|
else if (strcmp(key, "selection-target") == 0) {
|
||||||
if (strcasecmp(value, "primary") == 0)
|
static const char *const values[] = {
|
||||||
conf->selection_target = SELECTION_TARGET_PRIMARY;
|
[SELECTION_TARGET_NONE] = "none",
|
||||||
else if (strcasecmp(value, "clipboard") == 0)
|
[SELECTION_TARGET_PRIMARY] = "primary",
|
||||||
conf->selection_target = SELECTION_TARGET_CLIPBOARD;
|
[SELECTION_TARGET_CLIPBOARD] = "clipboard",
|
||||||
else if (strcasecmp(value, "both") == 0)
|
[SELECTION_TARGET_BOTH] = "both",
|
||||||
conf->selection_target = SELECTION_TARGET_BOTH;
|
};
|
||||||
else {
|
|
||||||
LOG_AND_NOTIFY_ERR(
|
for (size_t i = 0; i < ALEN(values); i++) {
|
||||||
"%s:%d: [default]: %s: invalid 'selection-target'; "
|
if (strcasecmp(value, values[i]) == 0) {
|
||||||
"must be one of 'primary', 'clipboard' or 'both",
|
conf->selection_target = i;
|
||||||
path, lineno, value);
|
return true;
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_AND_NOTIFY_ERR(
|
||||||
|
"%s:%d: [default]: %s: invalid 'selection-target'; "
|
||||||
|
"must be one of 'none', 'primary', 'clipboard' or 'both",
|
||||||
|
path, lineno, value);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
1
config.h
1
config.h
|
|
@ -182,6 +182,7 @@ struct config {
|
||||||
bool presentation_timings;
|
bool presentation_timings;
|
||||||
bool hold_at_exit;
|
bool hold_at_exit;
|
||||||
enum {
|
enum {
|
||||||
|
SELECTION_TARGET_NONE,
|
||||||
SELECTION_TARGET_PRIMARY,
|
SELECTION_TARGET_PRIMARY,
|
||||||
SELECTION_TARGET_CLIPBOARD,
|
SELECTION_TARGET_CLIPBOARD,
|
||||||
SELECTION_TARGET_BOTH
|
SELECTION_TARGET_BOTH
|
||||||
|
|
|
||||||
|
|
@ -1019,6 +1019,9 @@ selection_finalize(struct seat *seat, struct terminal *term, uint32_t serial)
|
||||||
xassert(term->selection.start.row <= term->selection.end.row);
|
xassert(term->selection.start.row <= term->selection.end.row);
|
||||||
|
|
||||||
switch (term->conf->selection_target) {
|
switch (term->conf->selection_target) {
|
||||||
|
case SELECTION_TARGET_NONE:
|
||||||
|
break;
|
||||||
|
|
||||||
case SELECTION_TARGET_PRIMARY:
|
case SELECTION_TARGET_PRIMARY:
|
||||||
selection_to_primary(seat, term, serial);
|
selection_to_primary(seat, term, serial);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue