summaryrefslogtreecommitdiff
path: root/src/window.cc
AgeCommit message (Collapse)Author
2025-06-25Introduce a Replace HighlightPass that runs before WrapMaxime Coste
For WrapHighlighter to be able to take ReplaceRangesHighlighter into account, it needs to run afterwards, moreover, moving TabulationHighlighter to the replace pass means we should be able to remove any tabulation specific handling from WrapHighlighter Also move ShowWhitespaceHighlighter to this pass as it is designed to replace TabulationHighlighter by running before (as builtin highlighters run after non builtin ones for each passes)
2025-06-25Rework highlighting management of cursor positionMaxime Coste
Move the whole responsibility of making the cursor visible to the window, removing cursor_pos from the display setup and resolving the cursor location by finding it in the display buffer afterwards. This simplifies hightlighters' do_compute_display_setup as they do not need to compute the cursor location. Highlighting may run on more lines than necessary after this change but this should be a minor performance hit.
2024-09-16Rename Window::display_position to display_coordMaxime Coste
2024-09-16Do not return beginning of buffer whenever display to buffer coord failsMaxime Coste
Use an empty Optional to show that resolution failed and just do not do anything in the mouse event handler in that case.
2024-08-16include headers cleanupAdriĆ  Arrufat
2024-08-12Move debug utils to debug.hh/debug.ccMaxime Coste
Lots of code includes buffer_utils.hh just for write_to_debug_buffer which pulls many unnecessary dependencies. Reorganise to reduce compile times.
2024-03-22Do not generate more lines to display than window sizeMaxime Coste
The wrap highlighter was pulling all lines until the cursor, regardless of whether the cursor was going to be made visible, this could lead to a display buffer containing much more lines than the actual viewport which eventually could lead to menu being anchored out of view that was leading to past-the-end buffer accesses. Fix the wrap higlighter not to pull lines up to the cursor when it is not tasked with making the cursor visible, and always trim the eventual extra lines after highlighting. Fixes #5118
2023-11-01Always ensure we do not scroll past the last lineMaxime Coste
An assert fails from time to time after reloading fifo buffers due to being scrolled past the last line of the buffer. A repro case was not found but this should fix the underlying issue.
2023-09-08Use last display setup instead of recomputing for window_rangeMaxime Coste
Fixes #4964
2023-09-02Do not make cursor visible after mouse scrolling and view commandsMaxime Coste
ensure cursor is visible after user input except if the command implementation opted-out. Hooks and timers should not enforce visible cursor. PageUp/PageDown and `<c-f>` / `<c-b>` commands still move the cursor as this seemed a desired behaviour.
2023-08-27Remove Window::force_redraw()Maxime Coste
This was mostly redundant with Client::force_redraw.
2023-08-27Small code cleanup in winow.cc/hhMaxime Coste
2023-08-23Revert "Only make cursor visible after buffer or selection change"Maxime Coste
This is currently broken on various corner cases and breaks the "master branch should be good for day to day work" implicit rule, ongoing work to stabilize this feature will take place on the no-cursor-move-on-scroll branch until its deemed ready. This reverts commit 1e38045d702ec6eb2425016d9b02636270ab1b1e. Closes #4963
2023-08-16Only make cursor visible after buffer or selection changeMaxime Coste
Kakoune now does not touch cursors when scrolling. It checks if either the buffer or selections has been modified since last redraw. Fixes #4124 Fixes #2844
2023-08-13Add a ProfileScope helper class to replace most profiling usesMaxime Coste
2023-06-12Trim display lines before the colorize passMaxime Coste
Colorizing long lines can be costly, remove all the invisible atoms earlier. Also optimize ForwardHighlighterApplier further by trimming empty lines.
2022-10-17Fix splitting of display atoms accross multi-columns codepointMaxime Coste
Honor the split request by inserting an empty atom to make sure client code can assume splitting does replace one atom with two Fixes #4753
2022-07-13Re-work line trimming to fix issues with column highightersMaxime Coste
Instead of triming only buffer ranges, add a trim_from method to display line to keep the initial N columns, we know how many columns are used by non-trimable widgets in DisplaySetup::widget_columns so we can just pass this. Also restore the previous logic for face merging Fixes #4670
2022-07-10Refactor highlighting logicMaxime Coste
Always start with full buffer lines and trim the display buffer at the very end, treat non-range display atoms as non-trimable in that case and keep track of how many columns are occupied by "widgets" such as line numbers or flags. Fixes #4659
2021-10-07GrammarJonta
2020-06-09Do not include non-primitive option value in *SetOption hook filterMaxime Coste
Only include the value for int/str/bool options, for the rest just write '<option name>=...'. This should reduce the cost of some patterns such as repeatedly adding a value inside a list option. It seems very unlikely that the actual value would be matched by a hook regex string for non primitive types.
2019-12-16Fix WinResize hook getting triggered during urgent event processingMaxime Coste
WinResize hooks could be triggered during shell evaluation, leading to any state potentially getting mutated after a shell evaluation call.
2019-11-22Add support for markup in info boxesMaxime Coste
Fixes #2552
2019-11-09Add static or const where usefulJason Felice
2019-06-19Refactor option_to_string quoting support, introduce Quoting::RawMaxime Coste
2019-04-23Change faces alias to be a base that can be modifiedMaxime Coste
Using <fg>,<bg>+<attr>@<base> will apply the given fg color, bg color and attributes on top of base dynamically. Simply giving <base> is a shorthand for default,default@<base>. Inspired by the discussion in #2862
2019-02-17Run WinClose hook before putting the window into trashMaxime Coste
2019-01-24Header and dependency cleanupMaxime Coste
2018-11-14Fix spurious redrawMaxime Coste
m_last_setup was not storing the actual position that was used to redraw the window, but the previous one, leading to an additional spurious redraw immediatly after (triggered by window position not believed to be the one at last redraw). Fixes #2562
2018-10-23Refactor Hook management to have a well defined list of hooksMaxime Coste
Hooks are now an enum class instead of passing strings around.
2018-10-06Small style tweakMaxime Coste
2018-08-29Use shell specific quoting for env varsMaxime Coste
Add a test case to validate roundtrips between Kakoune and the shell.
2018-06-19Change Search completion to display on top of the modelineMaxime Coste
2018-06-13Fix crash when adapting window position post buffer modificationsMaxime Coste
2018-06-12Remove unneeded Window::m_range post refactoringMaxime Coste
2018-06-11Try to keep window position fixed when buffer gets modifiedMaxime Coste
Adapt window position to the changes that happened in the buffer since last redraw. Fixes #1989
2018-06-11Add position offset to Window to limit moves with search menu styleMaxime Coste
Window can be resized with an "offset_pos" flag, which means that the resize took place on the top left corner of the window, leading to a change in current window position. This is treated as temporary and the position change is stored in a m_position_offset field. That allows the ncurses UI to offset the position when it displays a Search menu, so that the window does not constantly scroll when the search menu open/closes. The window will only scroll if it needs to in order to keep the main selectin visible.
2018-06-11Pass DisplaySetup through the HighlightContextMaxime Coste
2018-05-26Do not expose C++ typeid().name to user facing errors on wrong option typeMaxime Coste
Fixes #2079
2018-05-19Fix assert with window small enough so that no part of buffer is displayedMaxime Coste
Fixes #2056
2018-05-14Rename Context::Flags::Transient to Context::Flags::DraftMaxime Coste
Draft is well establish and all draft context are transient.
2018-05-08Store the timestamp at which a display buffer was generatedMaxime Coste
Coordinates inside a display buffer are only valid for a certain buffer content, they cannot be used once the buffer has been modified. Fixes #2034
2018-04-10Redraw window when the face definition changedMaxime Coste
Hash the current face state and store that hash to check for changes.
2018-04-06Make compute_display_setup methods constMaxime Coste
2018-02-21Fix crash when iterating through options on window creationMaxime Coste
Window::on_option_changed calls hooks, which can do anything including adding/removing options in the various option managers Fixes #1863
2017-12-15Window: avoid positionning window on a negative columnMaxime Coste
Fixes #1741
2017-11-25Highlighters: Introduce unique highlighter supportMaxime Coste
Some highlighters, such as wrap or line numbers, are not intended to be used multiple times on the same display. Add support for unique ids that are used by highlighters to disable themselves if another unique highlighter with the same id is supposed to override them. The usual highlighter "precedence" takes, place, that it, that most nested highlighter will the the one to run (window in priority to buffer in priority to global).
2017-11-24Window: fix buffer_coord when a line buffer range is emptyMaxime Coste
Fixes #1711
2017-10-31Highlighters does not need to inherit from HighlighterGroupMaxime Coste
Just compose, to avoid coupling Highlighters with the Highlighter interface. And yeah, that naming is a bit confusing.
2017-10-28Move highlighters into ScopesMaxime Coste
That means we can now have highlighters active at global, buffer, and window scope. The add-highlighter and remove-highlighter syntax changed to take the parent path (scope/group/...) as a mandatory argument, superseeding the previous -group switch.