aboutsummaryrefslogtreecommitdiff
path: root/search.c (follow)
Commit message (Collapse)AuthorAgeLines
* search: when matching cell content, treat empty cells as spacesDaniel Eklöf2021-03-28-0/+3
|
* input: rewrite of how we match foot’s own key bindingsDaniel Eklöf2021-03-04-8/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bindings are matched in one out of three ways: * By translated (by XKB) symbols * By untranslated symbols * By raw key codes A translated symbol is affected by pressed modifiers, some of which can be “consumed”. Consumed modifiers to not partake in the comparison with the binding’s modifiers. In this mode, ctrl+shift+2 maps to ctrl+@ on a US layout. Untranslated symbols, or un-shifted symbols refer to the “base” symbol of the pressed key, i.e. it’s unaffected by modifiers. In this mode, consumed modifiers *do* partake in the comparison with the binding’s modifiers, and ctrl+shift+2 maps to ctrl+shift+2 on a US layout. More examples: ctrl+shift+u maps to ctrl+U in the translated lookup, while ctrl+shift+u maps to ctrl+shift+u in the untranslated lookup. Finally, we also match raw key codes. This allows our bindings to work using the same physical keys when the user switches between latin and non-latin layouts. This means key bindings in foot.ini *must* not include both +shift+ and a *shifted* key. I.e. ctrl+shift+U is not a valid combo as it cannot be triggered. Unfortunately, this was how you were supposed to write bindings up until now... so, we try to detect such bindings, log a deprecation warning and then “fix” the binding for the user. When specifying bindings in foot.ini, both ctrl+U and ctrl+shift+u are valid, and will work. The latter is preferred though, since we cannot detect the raw key code for the former variant. Personally, I also prefer the latter one because it is more explicit; it’s more obvious which keys are involved. However, in some cases it makes more sense to use the other variant. Typically for non-letter combos.
* wayland: drop ‘_surface’ suffix from subsurface struct instancesDaniel Eklöf2021-02-17-3/+2
|
* search: use wayl_win_subsurface_new/destroy()Daniel Eklöf2021-02-17-15/+4
|
* Convert some more uses of xassert(false) to BUG("...")Craig Barnes2021-02-09-2/+2
|
* key-bindings: refactor: use a single type for all key bindingsDaniel Eklöf2021-02-08-3/+3
| | | | | | | | | | | | | | | | Up until now, the various key binding modes (“normal”, “search” and “url”) have used their own struct definitions for their key bindings. The only reason for this was to have a properly typed “action” (using the appropriate “action” enum). This caused lots of duplicated code. This patch refactors this to use a single struct definition for the “unparsed” key bindings handled by the configuration, and another single definition for “parsed” bindings used while handling input. This allows us to implement configuration parsing, keymap translation and so on using one set of functions, regardless of key binding mode.
* search: match composed characters when extending the search string to the next word boundaryDaniel Eklöf2021-01-26-0/+13
|
* search: fix matching of multi-column charactersDaniel Eklöf2021-01-26-3/+13
| | | | | We were matching the sub-sequence SPACERs as if they were regular characters, which obviously failed.
* search: don’t re-scan the scrollback unless the search string actually has changedDaniel Eklöf2021-01-26-36/+82
|
* Merge branch 'search-match-composed-characters'Daniel Eklöf2021-01-26-3/+37
|\
| * search: fix matching against composed charactersDaniel Eklöf2021-01-24-3/+37
| |
* | search: filter out non-printable charactersDaniel Eklöf2021-01-24-4/+16
|/ | | | Don’t allow non-printable characters in the search input string.
* debug: rename assert() to xassert(), to avoid clashing with <assert.h>Craig Barnes2021-01-16-16/+16
|
* Print stack trace on assert() failure or when calling fatal_error()Craig Barnes2021-01-16-2/+0
| | | | | | Note: this uses the __sanitizer_print_stack_trace() function from the AddressSanitizer runtime, so it only works when AddressSanitizer is in use.
* selection: combine enum selection_kind with selection_semanticDaniel Eklöf2021-01-06-2/+2
|
* selection: use selection_start() to initialize word/row-based selectionDaniel Eklöf2021-01-04-1/+1
| | | | | | 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}
* selection: wip: update selection word-wise when initial selection was by wordDaniel Eklöf2021-01-04-1/+2
|
* search: reset IME state when entering/exiting search modeDaniel Eklöf2020-12-07-0/+12
|
* render: search: glyph_offset is in *cells*, cursor position in *characters*Daniel Eklöf2020-12-07-0/+6
| | | | | | 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*.
* search: new function: search_add_chars()Daniel Eklöf2020-12-07-4/+4
| | | | | This function inserts a string into the search buffer, at the current insertion point (i.e. where the cursor is).
* search: add {clipboard,primary}-paste key bindingsDaniel Eklöf2020-11-01-25/+57
| | | | | | | | | | 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
* config: add ‘[default].word-delimiters’Daniel Eklöf2020-10-09-1/+2
| | | | | | | | | | 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
* don't use empty struct initializersDaniel Eklöf2020-08-23-2/+2
|
* search: don't update/refresh match when modifier keys are pressedDaniel Eklöf2020-08-12-0/+3
|
* search: fix viewport not moving if we tried to move it past the scrollback startDaniel Eklöf2020-08-12-21/+54
| | | | | | | | | | | | 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.
* fix printf-format errors in 32-bit buildsDaniel Eklöf2020-08-06-1/+1
|
* search: fix crash when searching the scrollback historyDaniel Eklöf2020-07-25-48/+52
| | | | | | | | | | | | 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.
* search: improve viewport movementsDaniel Eklöf2020-07-24-32/+46
| | | | | | * 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.
* search: re-enable search-commit actionDaniel Eklöf2020-07-22-7/+5
| | | | | This was disabled while implementing multi-seat support, and I forgot to fix and re-enable before that feature was merged.
* multi-seat: re-enable scrollback search supportDaniel Eklöf2020-07-08-23/+12
|
* wip: multi-seat supportDaniel Eklöf2020-07-08-5/+18
| | | | | Compiles and runs, but mouse, clipboard and other things have been disabled.
* util.h: new header file defining commonly used macrosDaniel Eklöf2020-05-01-2/+1
|
* misc: replace all explicit zero-initializers with empty initializersDaniel Eklöf2020-04-13-1/+1
|
* mbstate: fix compile warning on systems where mbstate_t isn't an integralDaniel Eklöf2020-04-13-1/+1
| | | | | An empty initializer still ensures the entire object is zero-initialized.
* search: replace hard-coded key bindings with "user configurable" onesDaniel Eklöf2020-03-18-113/+115
| | | | | | | | 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.
* input: bindings: don't match raw key code alone - mods must also matchDaniel Eklöf2020-03-18-1/+4
|
* input: bind key bindings to raw key codes tooDaniel Eklöf2020-03-18-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | 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).
* search: add support for user configurable key bindingsDaniel Eklöf2020-03-08-1/+13
| | | | No default bindings defined yet, though.
* render: never render CSD and/or search box "immediately"Daniel Eklöf2020-03-06-4/+2
| | | | | | | | | | 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.
* search: don't mark the entire sub-surface as opaqueDaniel Eklöf2020-03-01-5/+0
|
* search: enable/disable weston sub-surface desync quirk when rendering search boxDaniel Eklöf2020-03-01-1/+1
|
* search: update search box before we update the main gridDaniel Eklöf2020-03-01-1/+1
|
* wayland: store pointer to window instance in all surfacesDaniel Eklöf2020-02-29-0/+2
|
* wayland: instantiate sub-surfaces on-demandDaniel Eklöf2020-02-26-2/+21
| | | | | | | | | | | | | | | | | | | 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.
* search: rename render.search_offset -> render.search_glyph_offsetDaniel Eklöf2020-01-05-1/+1
|
* render: ensure cursor is always visible in the search boxDaniel Eklöf2020-01-05-0/+1
| | | | | | | | | | | | | | | | | | 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.
* selection: track selection type; normal or block selectionDaniel Eklöf2020-01-03-1/+1
|
* search: match_to_end_of_word: reset end_col when done with a rowDaniel Eklöf2019-12-03-0/+2
|
* search: match_to_end_of_word: bug: reset end-col when bumping end-rowDaniel Eklöf2019-12-03-1/+3
| | | | | | | | 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.
* search: bug: restore end-col/end-row adjustmentDaniel Eklöf2019-12-03-2/+4
| | | | | Turns out end_col *can* be exactly 0. In this case, we need to adjust the end-row too.
* search: bug: re-initialize start-row when attempting a new matchDaniel Eklöf2019-12-03-4/+4
| | | | | | 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.
* search: map ctrl+shift+w to match to end of word, spaces onlyDaniel Eklöf2019-12-03-4/+7
| | | | | This works just like ctrl+w, except that the only space separating characters are whitespaces.
* search: search_match_to_end_of_word: rename start_{row,col} -> end_{row,col}Daniel Eklöf2019-12-03-8/+10
|
* search: split up search_update() into twoDaniel Eklöf2019-12-03-68/+71
| | | | | | | | | * 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.
* search: rename search_update() -> search_find_next()Daniel Eklöf2019-12-03-3/+3
|
* search: map ctrl+w to 'extend current selection to end of word'Daniel Eklöf2019-12-03-0/+75
| | | | | | | 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.
* search: discard canceled compose sequencesDaniel Eklöf2019-12-03-0/+2
|
* Revert "search: discard canceled compose sequences"Daniel Eklöf2019-12-03-4/+0
| | | | This reverts commit f67733c0e3a4e4ba19e1c70bc36ee78af762868f.
* search: discard canceled compose sequencesDaniel Eklöf2019-12-03-0/+4
|
* search: remove debug logDaniel Eklöf2019-12-03-1/+0
|
* search: don't line-wrap unless we actually have a match on the next rowDaniel Eklöf2019-12-03-4/+6
| | | | | | | | 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.
* search: break out search buffer resize code to a new functionDaniel Eklöf2019-12-03-12/+21
|
* Add missing includesDaniel Eklöf2019-12-01-0/+1
|
* search: update xcursor when starting and ending a searchDaniel Eklöf2019-11-29-0/+2
|
* wayland: implement wayl_init()Daniel Eklöf2019-10-27-2/+2
| | | | Wayland instantiation is now done by the wayland backend, not in main.
* term: wayland struct is now not a part of the terminal structDaniel Eklöf2019-10-27-9/+9
| | | | | | We do however need access to it, so provide a pointer. The difference is that now we can have a *single* wayland instance, but multiple terminal instances.
* wayland: change all wayland callbacks to take a wayland pointerDaniel Eklöf2019-10-27-1/+1
| | | | | Instead of passing the terminal to the wayland callbacks, pass a 'struct wayland' pointer.
* kbd: move into waylandDaniel Eklöf2019-10-27-8/+8
|
* term: move per-window wayland objects from wayland struct to terminal structDaniel Eklöf2019-10-27-2/+2
| | | | | | | | Short term, we want to break out the wayland backend from the terminal struct. Long term, we might want to support multiple windows. One step towards both the above is separating global wayland objects from per-window objects.
* search: map ctrl+b/f to move cursor single character backward/forwardDaniel Eklöf2019-08-30-2/+6
|
* search: ctrl+s searches forwardDaniel Eklöf2019-08-30-0/+18
|
* search: make search-direction configurableDaniel Eklöf2019-08-30-7/+23
|
* search: fix distance to prev word calculation when final cursor was 0Daniel Eklöf2019-08-30-1/+1
|
* search: implement move cursor word backward/forwardDaniel Eklöf2019-08-30-0/+18
|
* search: implement delete word backward/forwardDaniel Eklöf2019-08-30-2/+18
|
* search: utility functions distance_{next,prev}_word()Daniel Eklöf2019-08-30-0/+56
| | | | | These functions calculate the distance from the current cursor to the next/previous word.
* Revert "search: for now, reset search match state whenever the buffer changes"Daniel Eklöf2019-08-29-9/+0
| | | | This reverts commit 9c6ece747ed328b0e922597ec52646c00bb68c8c.
* search: for now, reset search match state whenever the buffer changesDaniel Eklöf2019-08-29-0/+9
|
* search: call render_search_box() from search_inptu()Daniel Eklöf2019-08-29-3/+1
|
* search: add basic cursor navigation supportDaniel Eklöf2019-08-29-2/+45
|
* search: insert new characters at cursor, not at the end of the bufferDaniel Eklöf2019-08-29-2/+7
|
* search: search_cancel: reset cursor positionDaniel Eklöf2019-08-29-0/+1
|
* search: turn info log to a debug logDaniel Eklöf2019-08-29-1/+1
|
* search: remove INFO log (that really was a debug log)Daniel Eklöf2019-08-29-1/+0
|
* search: don't destroy/recreate search (sub)surfaceDaniel Eklöf2019-08-29-27/+2
| | | | | | Create the sub-surface once, at startup. Then, instead of destroying it when committing/cancelling a search, unmap it (by attaching a NULL buffer to it).
* search: move render() function to the 'render' moduleDaniel Eklöf2019-08-29-80/+4
|
* search: move wayland surface variables into the term structDaniel Eklöf2019-08-29-24/+23
|
* search: use a sub-surface to render the search bufferDaniel Eklöf2019-08-29-14/+135
|
* search: cancel existing selection when starting a new searchDaniel Eklöf2019-08-28-0/+1
|
* search: log search buffer at INFO levelDaniel Eklöf2019-08-28-1/+1
| | | | ... until we actually render the search buffer somehow
* search: fix start/end row in selectionDaniel Eklöf2019-08-28-2/+16
|
* search: start search in current view, rather than from end-of-outputDaniel Eklöf2019-08-28-2/+4
|
* search: match case insensitiveDaniel Eklöf2019-08-27-2/+2
|
* search: sort includesDaniel Eklöf2019-08-27-1/+1
|
* search: disable log outputDaniel Eklöf2019-08-27-1/+1
|
* search: loop through the *entire* scrollback bufferDaniel Eklöf2019-08-27-2/+7
|
* search: cancel selection and clear match stats when we don't matchDaniel Eklöf2019-08-27-0/+5
|
* search: 'len' is unused in release builds (it's only used in an assert)Daniel Eklöf2019-08-27-1/+1
|
* search: return early after committing a searchDaniel Eklöf2019-08-27-0/+1
| | | | | This fixes an issue where the selection was finalized, but then cleared.
* search: search_update() is always called at end of search_input()Daniel Eklöf2019-08-27-1/+0
|