config: new option - trim-trailing-spaces-from-selection

When enabled, trailing spaces are trimmed from both regular and block
selections.
This commit is contained in:
Daniel Eklöf 2020-11-11 18:16:49 +01:00
parent 194cf1ce87
commit 20aab0871f
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 15 additions and 5 deletions

View file

@ -52,14 +52,15 @@
bindings. By default, they are bound to `ctrl+v ctrl+y` and bindings. By default, they are bound to `ctrl+v ctrl+y` and
`shift+insert` respectively, and lets you paste from the clipboard `shift+insert` respectively, and lets you paste from the clipboard
or primary selection into the search buffer. or primary selection into the search buffer.
* **trim-trailing-spaces-from-selection** option to `foot.init`. When
enabled, trailing spaces are trimmed from both regular and block
selections (https://codeberg.org/dnkl/foot/issues/181).
### Changed ### Changed
* Blinking text now uses the foreground color, but dimmed down in its * Blinking text now uses the foreground color, but dimmed down in its
off state, instead of the background color. off state, instead of the background color.
* Trailing spaces are trimmed when copying a block selection
(https://codeberg.org/dnkl/foot/issues/181).
### Deprecated ### Deprecated

View file

@ -601,6 +601,9 @@ parse_section_main(const char *key, const char *value, struct config *conf,
mbstowcs(conf->word_delimiters, value, chars + 1); mbstowcs(conf->word_delimiters, value, chars + 1);
} }
else if (strcmp(key, "trim-trailing-spaces-from-selection") == 0)
conf->trim_trailing_spaces_from_selection = str_to_bool(value);
else if (strcmp(key, "scrollback") == 0) { else if (strcmp(key, "scrollback") == 0) {
LOG_WARN("deprecated: %s:%d: [default]: scrollback: use 'scrollback.lines' instead'", path, lineno); LOG_WARN("deprecated: %s:%d: [default]: scrollback: use 'scrollback.lines' instead'", path, lineno);
@ -2081,6 +2084,7 @@ config_load(struct config *conf, const char *conf_path,
.server_socket_path = get_server_socket_path(), .server_socket_path = get_server_socket_path(),
.presentation_timings = false, .presentation_timings = false,
.hold_at_exit = false, .hold_at_exit = false,
.trim_trailing_spaces_from_selection = false,
.tweak = { .tweak = {
.fcft_filter = FCFT_SCALING_FILTER_LANCZOS3, .fcft_filter = FCFT_SCALING_FILTER_LANCZOS3,

View file

@ -168,6 +168,7 @@ struct config {
char *server_socket_path; char *server_socket_path;
bool presentation_timings; bool presentation_timings;
bool hold_at_exit; bool hold_at_exit;
bool trim_trailing_spaces_from_selection;
struct { struct {
enum fcft_scaling_filter fcft_filter; enum fcft_scaling_filter fcft_filter;

View file

@ -128,6 +128,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: _,│`|:"'()[]{}<>_
*trim-trailing-spaces-from-selection*
Boolean. If enabled, trailing spaces are trimmed from selections
(both regular and block selections). Default: _no_.
# SECTION: scrollback # SECTION: scrollback

View file

@ -14,6 +14,7 @@
# workers=<number of logical CPUs> # workers=<number of logical CPUs>
# bell=none # bell=none
# word-delimiters=,│`|:"'()[]{}<> # word-delimiters=,│`|:"'()[]{}<>
# trim-trailing-spaces-from-selection=no
[scrollback] [scrollback]
# lines=1000 # lines=1000

View file

@ -224,10 +224,9 @@ selection_to_text(const struct terminal *term)
if (term->selection.end.row == -1) if (term->selection.end.row == -1)
return NULL; return NULL;
const enum selection_kind kind = term->selection.kind; struct extraction_context *ctx = extract_begin(
const bool trim_trailing_spaces = kind == SELECTION_BLOCK; term->selection.kind, term->conf->trim_trailing_spaces_from_selection);
struct extraction_context *ctx = extract_begin(kind, trim_trailing_spaces);
if (ctx == NULL) if (ctx == NULL)
return NULL; return NULL;