Commit graph

90 commits

Author SHA1 Message Date
Craig Barnes
22f25a9e4f Print stack trace on assert() failure or when calling fatal_error()
Note: this uses the __sanitizer_print_stack_trace() function from the
AddressSanitizer runtime, so it only works when AddressSanitizer is
in use.
2021-01-16 19:56:33 +00:00
Daniel Eklöf
3a9172342f
selection: combine enum selection_kind with selection_semantic 2021-01-06 10:53:27 +01:00
Daniel Eklöf
3afc5a723e
selection: use selection_start() to initialize word/row-based selection
This removes the selection_mark_word() and selection_mark_row()
functions. To start a word/row-based selection, use selection_start()
with SELECTION_SEMANTIC_{WORD,ROW}
2021-01-04 19:48:41 +01:00
Daniel Eklöf
30de262d29
selection: wip: update selection word-wise when initial selection was by word 2021-01-04 19:48:26 +01:00
Daniel Eklöf
fc2bcf9bc0
search: reset IME state when entering/exiting search mode 2020-12-07 20:44:15 +01:00
Daniel Eklöf
b4a0f5b13b
render: search: glyph_offset is in *cells*, cursor position in *characters*
When calculating the offset into the search string, from where to
start rendering, take into account that the cursor position is
in *characters*, and the glyph-offset is in *cells*.
2020-12-07 20:44:13 +01:00
Daniel Eklöf
f51ce34753
search: new function: search_add_chars()
This function inserts a string into the search buffer, at the current
insertion point (i.e. where the cursor is).
2020-12-07 20:44:12 +01:00
Daniel Eklöf
f3e6941c9a
search: add {clipboard,primary}-paste key bindings
These bindings copy from the clipboard or primary selection into the
search buffer.

Default bindings:

* clipboard-paste: ctrl+v, ctrl+y
* primary-paste: shift+insert
2020-11-01 12:39:57 +01:00
Daniel Eklöf
49f4b3da64
config: add ‘[default].word-delimiters’
This option lets the user configure which characters act as word
delimiters when selecting text.

This affects both “double clicking”, and ‘ctrl-w’ in scrollback search
mode.

Closes #156
2020-10-09 19:44:23 +02:00
Daniel Eklöf
dabdffafa5
don't use empty struct initializers 2020-08-23 10:07:00 +02:00
Daniel Eklöf
8626b4bc1a
search: don't update/refresh match when modifier keys are pressed 2020-08-12 19:40:50 +02:00
Daniel Eklöf
b01431e38f
search: fix viewport not moving if we tried to move it past the scrollback start
If the match was somewhere near the scrollback beginning, and if the
entire scrollback hadn't yet been filled, we ended up trying to move
the viewport past the beginning of the scrollback, which we then
adjusted in the wrong direction, causing the viewport to not move at
all.

Besides being a bad user experience, since the new match wasn't
visible, foot would also crash if you manually scrolled up to the
match.
2020-08-12 19:40:40 +02:00
Daniel Eklöf
019b6bc039
fix printf-format errors in 32-bit builds 2020-08-06 23:20:46 +02:00
Daniel Eklöf
9f82cbaa49
search: fix crash when searching the scrollback history
search_update_selection() was changed in 1.4.x to *first* update the
selection, *then* move the viewport.

This leads to a crash if the new match (selection) is outside the
current viewport; the selection code assumes the updated selection
endpoint is in the visible viewport.

Changing back to *first* move the viewport, *then* update the
selection solves this.
2020-07-25 11:23:54 +02:00
Daniel Eklöf
8d81dde5b8
search: improve viewport movements
* Don't move the viewport if the new match is already fully visible
* When we do have to move the viewport, position it such that the new
  match ends up roughly in the middle.
2020-07-24 17:49:50 +02:00
Daniel Eklöf
ac7b229f7c
search: re-enable search-commit action
This was disabled while implementing multi-seat support, and I forgot
to fix and re-enable before that feature was merged.
2020-07-22 17:51:27 +02:00
Daniel Eklöf
04e566492c
multi-seat: re-enable scrollback search support 2020-07-08 18:20:34 +02:00
Daniel Eklöf
c470825067
wip: multi-seat support
Compiles and runs, but mouse, clipboard and other things have been
disabled.
2020-07-08 16:45:26 +02:00
Daniel Eklöf
69c3e74498
util.h: new header file defining commonly used macros 2020-05-01 11:46:24 +02:00
Daniel Eklöf
c96a0b3b3c
misc: replace all explicit zero-initializers with empty initializers 2020-04-13 12:03:11 +02:00
Daniel Eklöf
d67f437458
mbstate: fix compile warning on systems where mbstate_t isn't an integral
An empty initializer still ensures the entire object is
zero-initialized.
2020-04-13 11:58:38 +02:00
Daniel Eklöf
0419156494
search: replace hard-coded key bindings with "user configurable" ones
They aren't really user configurable. At least not yet.

However, with this, we now handle raw key codes just like the normal
key bindings. Meaning, e.g. ctrl+g, ctrl+a, ctrl+e etc now works while
searching with e.g. a russian layout.
2020-03-18 15:30:14 +01:00
Daniel Eklöf
a69b818a62
input: bindings: don't match raw key code alone - mods must also match 2020-03-18 14:52:39 +01:00
Daniel Eklöf
6d30e7d15d
input: bind key bindings to raw key codes too
Before, when looking for a matching user key binding, we only
matched *symbols*.

This means that the physical keys that generate a specific key binding
is layout dependent. What's worse, it may not even be possible to
generate the key binding at all.

Russian is one such layout, where all the "normal" (us) symbols are
replaced.

By using raw key codes, we can get around this - the key code has a
direct mapping to the physical key.

However, matching raw key codes **only** doesn't always make sense
either. For now, match **both** symbols _and_ key codes. Symbols take
precedence.

TODO: we might have to make this configurable _per binding_.

Note: 'search' mode still uses mostly hardcoded shortcuts that still
have this problem (i.e. ctrl+g doesn't work with a russian layout).
2020-03-18 14:29:34 +01:00
Daniel Eklöf
0d188895c3
search: add support for user configurable key bindings
No default bindings defined yet, though.
2020-03-08 15:28:47 +01:00
Daniel Eklöf
c5a1af4e53
render: never render CSD and/or search box "immediately"
Handle the CSDs and the search box the same way we handle the main
grid; when we need to redraw them, call
render_refresh_{csd,search}(). This sets a flag that is checked after
each FDM iteration. All actual rendering is done here.

This also ties the commits of the Wayland sub-surfaces to the commit
of the main surface.
2020-03-06 19:16:54 +01:00
Daniel Eklöf
7b3fffc6ec
search: don't mark the entire sub-surface as opaque 2020-03-01 13:06:30 +01:00
Daniel Eklöf
b6f8a2e422
search: enable/disable weston sub-surface desync quirk when rendering search box 2020-03-01 13:06:00 +01:00
Daniel Eklöf
3ec50369ce
search: update search box before we update the main grid 2020-03-01 12:24:37 +01:00
Daniel Eklöf
43c0551806
wayland: store pointer to window instance in all surfaces 2020-02-29 12:09:28 +01:00
Daniel Eklöf
ea97a0dc87
wayland: instantiate sub-surfaces on-demand
While most compositors handle instantiated but not-yet-mapped
sub-surfaces correctly, e.g. kwin does not.

For example, it will incorrectly offset the main surface both
horizontally and vertically with a couple of pixels, leaving two
transparent areas at the top and left, between the SSDs and the main
surface.

Note that a workaround is to position the sub-surfaces inside the main
surface while they're unmapped. However, since the surfaces may be
larger than the main surface (the CSDs, for examples, always are),
this doesn't quite work since kwin, at least, resizes the window to
include the sub-surfaces, even when unmapped.

So, instead we instantiate all sub-surfaces on demand, when we know
where to position them, and when they should be mapped.
2020-02-26 12:22:16 +01:00
Daniel Eklöf
7e178d6337
search: rename render.search_offset -> render.search_glyph_offset 2020-01-05 15:25:24 +01:00
Daniel Eklöf
5a89520274
render: ensure cursor is always visible in the search box
Maintain a view 'offset' (which glyph from the search string to start
rendering at).

This defines the start of the viewable area. The end is the offset +
the search box size (which is limited to the window size).

Adjust this offset whenever the cursor moves outside the viewable
area. For now, this is always done in the same way: set the offset to
the cursor position.

This means that when we're entering text at the end of the search
criteria (i.e. the normal case; we're simply typing), and the search
box reaches the window size, the cursor will jump to the start of the
search box, which will be empty. This could be confusing, but let's go
with for now.
2020-01-05 15:16:40 +01:00
Daniel Eklöf
d706e68280
selection: track selection type; normal or block selection 2020-01-03 23:29:45 +01:00
Daniel Eklöf
a17ce10c03
search: match_to_end_of_word: reset end_col when done with a row 2019-12-03 20:26:32 +01:00
Daniel Eklöf
0f98101bbc
search: match_to_end_of_word: bug: reset end-col when bumping end-row
When we calculate the end coords, we must reset end-col when we reach
the end of the line and bump the end-row.

This fixes an issue where bumping the row once lead to the end row
being bumped for *each* remaining match character.
2019-12-03 20:25:22 +01:00
Daniel Eklöf
6cfb3216c3
search: bug: restore end-col/end-row adjustment
Turns out end_col *can* be exactly 0. In this case, we need to adjust
the end-row too.
2019-12-03 20:24:41 +01:00
Daniel Eklöf
008281757b
search: bug: re-initialize start-row when attempting a new match
When we've already found a partial match (but *not* a complete match),
and that match spanned multiple lines, then when we continued with the
next start-column we re-used a know-wrong row pointer.
2019-12-03 20:00:38 +01:00
Daniel Eklöf
0982210af2
search: map ctrl+shift+w to match to end of word, spaces only
This works just like ctrl+w, except that the only space separating
characters are whitespaces.
2019-12-03 19:43:45 +01:00
Daniel Eklöf
867cac4207
search: search_match_to_end_of_word: rename start_{row,col} -> end_{row,col} 2019-12-03 19:43:11 +01:00
Daniel Eklöf
2a5da66e4e
search: split up search_update() into two
* search_find_next() searches the scrollback, continuing from the last
  match. The assumption is that the search buffer has changed.

* search_update_selection() updates the selection and moves the view
  to ensure the selection is visible. Note that it doesn't verify the
  selection actually matches the search buffer.
2019-12-03 19:40:22 +01:00
Daniel Eklöf
e003736e11
search: rename search_update() -> search_find_next() 2019-12-03 19:24:33 +01:00
Daniel Eklöf
b5a04dcaae
search: map ctrl+w to 'extend current selection to end of word'
If the user has started a scrollback search and have some matching
text, he can now press ctrl+w to extend that selection (and thus the
search criteria too) to the end of the current word, or to the end of
the next word if currently at a word separating character.
2019-12-03 19:22:47 +01:00
Daniel Eklöf
694d84a9e9
search: discard canceled compose sequences 2019-12-03 19:21:16 +01:00
Daniel Eklöf
a34deabcc9
Revert "search: discard canceled compose sequences"
This reverts commit f67733c0e3.
2019-12-03 19:21:03 +01:00
Daniel Eklöf
f67733c0e3
search: discard canceled compose sequences 2019-12-03 19:19:55 +01:00
Daniel Eklöf
ac2eda885a
search: remove debug log 2019-12-03 19:19:26 +01:00
Daniel Eklöf
10cf722617
search: don't line-wrap unless we actually have a match on the next row
When matching characters, we moved on to next row directly after
matching the last character in a row.

This was wrong since if that last character was the last matching
character, we tried to create a selection that was on the wrong row.
2019-12-03 19:17:51 +01:00
Daniel Eklöf
d94fc80966
search: break out search buffer resize code to a new function 2019-12-03 19:17:34 +01:00
Daniel Eklöf
b5780e735e
Add missing includes 2019-12-01 19:22:45 +01:00