From 363a0de8b9105a837484fed1f0d3da38063ab82c Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 29 Jul 2020 06:55:23 +0200 Subject: changelog: add 1.4.4 section --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 910944c8..117dbdc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +* [1.4.4](#1-4-4) * [1.4.3](#1-4-3) * [1.4.2](#1-4-2) * [1.4.1](#1-4-1) @@ -10,6 +11,9 @@ * [1.2.1](#1-2-1) * [1.2.0](#1-2-0) +## 1.4.4 + + ## 1.4.3 ### Added -- cgit v1.3 From d675cf872022e0e1bf2100211d7607773de1016c Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 26 Jul 2020 12:31:13 +0200 Subject: input: margins are not selectable * Fix col/row calculation in pointer-enter event; we did not take the margins into account. * seat->mouse.col,row are now set to -1 if the cursor is inside the margins. That is, col/row are only ever valid when the mouse is actually over the grid, and not in the margins. * Use regular 'left-ptr' mouse cursor when mouse is inside the margins, to not make the user think he/she can start a selection. Besides making things clearer, this also fixes a crash that occurred if you started a selection in e.g. the right margin. --- CHANGELOG.md | 9 +++++++++ input.c | 40 ++++++++++++++++++++++++++-------------- selection.c | 7 ++++--- 3 files changed, 39 insertions(+), 17 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 117dbdc5..eafaed22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,15 @@ * [1.2.0](#1-2-0) ## 1.4.4 +### Changed + +* Mouse cursor is now always a `left_ptr` when inside the margins, to + indicate it is not possible to start a selection. + + +### Fixed + +* Crash when starting a selection inside the margins. ## 1.4.3 diff --git a/input.c b/input.c index c7f4b073..7fa62570 100644 --- a/input.c +++ b/input.c @@ -1023,11 +1023,16 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, int y = wl_fixed_to_int(surface_y) * term->scale; switch ((term->active_surface = term_surface_kind(term, surface))) { - case TERM_SURF_GRID: - seat->mouse.col = x / term->cell_width; - seat->mouse.row = y / term->cell_height; + case TERM_SURF_GRID: { + int col = (x - term->margins.left) / term->cell_width; + int row = (y - term->margins.top) / term->cell_height; + + seat->mouse.col = col >= 0 && col < term->cols ? col : -1; + seat->mouse.row = row >= 0 && row < term->rows ? row : -1; + term_xcursor_update(term); break; + } case TERM_SURF_SEARCH: case TERM_SURF_TITLE: @@ -1165,26 +1170,31 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, break; case TERM_SURF_GRID: { + term_xcursor_update(term); + int col = (x - term->margins.left) / term->cell_width; int row = (y - term->margins.top) / term->cell_height; - if (col < 0 || row < 0 || col >= term->cols || row >= term->rows) - return; + int old_col = seat->mouse.col; + int old_row = seat->mouse.row; + + seat->mouse.col = col >= 0 && col < term->cols ? col : -1; + seat->mouse.row = row >= 0 && row < term->rows ? row : -1; + + if (seat->mouse.col < 0 || seat->mouse.row < 0) + break; bool update_selection = seat->mouse.button == BTN_LEFT || seat->mouse.button == BTN_RIGHT; bool update_selection_early = term->selection.end.row == -1; if (update_selection && update_selection_early) - selection_update(term, col, row); + selection_update(term, seat->mouse.col, seat->mouse.row); - if (col == seat->mouse.col && row == seat->mouse.row) + if (old_col == seat->mouse.col && old_row == seat->mouse.row) break; - seat->mouse.col = col; - seat->mouse.row = row; - if (update_selection && !update_selection_early) - selection_update(term, col, row); + selection_update(term, seat->mouse.col, seat->mouse.row); if (!term_mouse_grabbed(term, seat)) { term_mouse_motion( @@ -1360,9 +1370,11 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer, if (selection_enabled(term, seat)) { switch (seat->mouse.count) { case 1: - selection_start( - term, seat->mouse.col, seat->mouse.row, - seat->kbd.ctrl ? SELECTION_BLOCK : SELECTION_NORMAL); + if (seat->mouse.col >= 0 && seat->mouse.row >= 0) { + selection_start( + term, seat->mouse.col, seat->mouse.row, + seat->kbd.ctrl ? SELECTION_BLOCK : SELECTION_NORMAL); + } break; case 2: diff --git a/selection.c b/selection.c index 354f6f53..ffe06c27 100644 --- a/selection.c +++ b/selection.c @@ -25,9 +25,10 @@ bool selection_enabled(const struct terminal *term, struct seat *seat) { return - term->mouse_tracking == MOUSE_NONE || - term_mouse_grabbed(term, seat) || - term->is_searching; + seat->mouse.col >= 0 && seat->mouse.row >= 0 && + (term->mouse_tracking == MOUSE_NONE || + term_mouse_grabbed(term, seat) || + term->is_searching); } bool -- cgit v1.3 From 7eee2d715db20dfa5094148874dd77f7e3685052 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 28 Jul 2020 20:00:32 +0200 Subject: changelog: improved font size consistency across monitors with different DPI --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index eafaed22..560552cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ ### Fixed * Crash when starting a selection inside the margins. +* Improved font size consistency across multiple monitors with + different DPI (https://codeberg.org/dnkl/foot/issues/47). ## 1.4.3 -- cgit v1.3 From f8d9bf18e5b67eac5838923620a5b11adc3f6cc0 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 28 Jul 2020 19:55:09 +0200 Subject: config: handle trailing comments and empty values --- CHANGELOG.md | 1 + config.c | 48 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 16 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 560552cf..6b452aaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ * Crash when starting a selection inside the margins. * Improved font size consistency across multiple monitors with different DPI (https://codeberg.org/dnkl/foot/issues/47). +* Handle trailing comments in `footrc` ## 1.4.3 diff --git a/config.c b/config.c index 283a72ea..9b63375c 100644 --- a/config.c +++ b/config.c @@ -792,7 +792,7 @@ parse_config_file(FILE *f, struct config *conf, const char *path) break; } - /* Strip whitespace */ + /* Strip leading whitespace */ char *line = _line; { while (isspace(*line)) @@ -809,11 +809,15 @@ parse_config_file(FILE *f, struct config *conf, const char *path) if (line[0] == '\0' || line[0] == '#') continue; + /* Split up into key/value pair + trailing comment */ + char *key_value = strtok(line, "#"); + char *comment __attribute__((unused)) = strtok(NULL, "\n"); + /* Check for new section */ - if (line[0] == '[') { - char *end = strchr(line, ']'); + if (key_value[0] == '[') { + char *end = strchr(key_value, ']'); if (end == NULL) { - LOG_ERR("%s:%d: syntax error: %s", path, lineno, line); + LOG_ERR("%s:%d: syntax error: %s", path, lineno, key_value); goto err; } @@ -821,13 +825,13 @@ parse_config_file(FILE *f, struct config *conf, const char *path) section = SECTION_COUNT; for (enum section i = 0; i < SECTION_COUNT; i++) { - if (strcmp(&line[1], section_info[i].name) == 0) { + if (strcmp(&key_value[1], section_info[i].name) == 0) { section = i; } } if (section == SECTION_COUNT) { - LOG_ERR("%s:%d: invalid section name: %s", path, lineno, &line[1]); + LOG_ERR("%s:%d: invalid section name: %s", path, lineno, &key_value[1]); goto err; } @@ -835,11 +839,20 @@ parse_config_file(FILE *f, struct config *conf, const char *path) continue; } - char *key = strtok(line, "="); + char *key = strtok(key_value, "="); + if (key == NULL) { + LOG_ERR("%s:%d: syntax error: no key specified", path, lineno); + goto err; + } + char *value = strtok(NULL, "\n"); + if (value == NULL) { + /* Empty value, i.e. "key=" */ + value = key + strlen(key); + } /* Strip trailing whitespace from key (leading stripped earlier) */ - { + if (key[0] != '\0') { assert(!isspace(*key)); char *end = key + strlen(key) - 1; @@ -850,25 +863,28 @@ parse_config_file(FILE *f, struct config *conf, const char *path) if (value == NULL) { if (key != NULL && strlen(key) > 0 && key[0] != '#') { - LOG_ERR("%s:%d: syntax error: %s", path, lineno, line); + LOG_ERR("%s:%d: syntax error: %s", path, lineno, key_value); goto err; } continue; } - /* Strip leading whitespace from value (trailing stripped earlier) */ + /* Strip leading+trailing whitespace from value */ { while (isspace(*value)) value++; - assert(!isspace(*(value + strlen(value) - 1))); - } - if (key[0] == '#') - continue; + if (value[0] != '\0') { + char *end = value + strlen(value) - 1; + while (isspace(*end)) + end--; + *(end + 1) = '\0'; + } + } - LOG_DBG("section=%s, key='%s', value='%s'", - section_names[section], key, value); + LOG_DBG("section=%s, key='%s', value='%s', comment='%s'", + section_info[section].name, key, value, comment); parser_fun_t section_parser = section_info[section].fun; assert(section_parser != NULL); -- cgit v1.3 From a4d2a2bf28b0474400f451ca33444e2c9183bbcf Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 29 Jul 2020 07:01:44 +0200 Subject: changelog: add extra newline between index and first release --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b452aaa..ceb377fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * [1.2.1](#1-2-1) * [1.2.0](#1-2-0) + ## 1.4.4 ### Changed -- cgit v1.3