Commit Graph

4484 Commits

Author SHA1 Message Date
Maxime Coste
665d3fa196 Fix edit -fifo without -scroll when the buffer is already opened
Scrolling was taking place in that case even though it was not
desired.
2018-06-13 07:11:03 +10:00
Maxime Coste
ee19497d37 Fix crash when adapting window position post buffer modifications 2018-06-13 05:00:35 +10:00
Maxime Coste
0bdde991ea Remove unneeded Window::m_range post refactoring 2018-06-12 06:48:48 +10:00
Maxime Coste
0d3a1b5955 Try to keep window position fixed when buffer gets modified
Adapt window position to the changes that happened in the buffer
since last redraw.

Fixes #1989
2018-06-11 15:10:30 +10:00
Maxime Coste
df90ba5984 Extract update_ranges_ifn as a general utility function 2018-06-11 15:10:30 +10:00
Maxime Coste
539832bf29 Add position offset to Window to limit moves with search menu style
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-11 15:10:30 +10:00
Maxime Coste
60cf71bc24 Pass DisplaySetup through the HighlightContext 2018-06-11 15:10:30 +10:00
Maxime Coste
97af2ffc84 Merge remote-tracking branch 'alyssais/patch-2' 2018-06-03 12:19:09 +10:00
Maxime Coste
310e5e3bcd NCursesUI: Use only 3 line menu for MenuStyle::Search 2018-06-03 12:17:38 +10:00
Maxime Coste
2bdbf7e379 Add MenuStyle::Search that prevents the menu from hiding buffer text
Fixes #2042
2018-06-03 12:17:38 +10:00
Maxime Coste
56e5322b45 EventManager: Never block if a forced file descriptor is present 2018-06-03 12:17:38 +10:00
Maxime Coste
c63502c7c6 Code cleanup and slight refactor in NCursesUI menu code 2018-06-03 12:17:38 +10:00
Alyssa Ross
7685a657ca
Fix grammar in highlight error message 2018-06-01 13:02:38 +02:00
Delapouite
b60ed6ca53 docs: fix missing ] in wrap hl -marker switch docstring
Also add the related changelog entry
2018-05-30 18:11:19 +02:00
Alyssa Ross
2deb2c0294
Fix typos in add-highlighter range help 2018-05-28 13:19:12 +02:00
Maxime Coste
f06badcfd3 Fix clang compilation 2018-05-28 08:26:19 +10:00
Maxime Coste
b5693c6253 Refactor option_from_string to return directly the option value 2018-05-27 13:00:50 +10:00
Maxime Coste
2617f5e022 Add unit test for option parsing 2018-05-27 13:00:48 +10:00
Maxime Coste
f1c1de834a Add a -marker <marker_text> switch support to the wrap highlighter
This makes wrapped lines very explicit.

Fixes #2065
2018-05-26 22:22:00 +10:00
Maxime Coste
68fb3ba88f Rework fail command not to display command call stack
`fail` triggers "expected" errors, and hence should just display
the provided message.
2018-05-26 21:31:17 +10:00
Maxime Coste
54b62cbef7 Do not expose C++ typeid().name to user facing errors on wrong option type
Fixes #2079
2018-05-26 10:01:26 +10:00
Maxime Coste
9b89652b0b Fix potential assert on itersel selection restoration
We cannot guarantee after an itersel that selections are going to
still be in ascending order, but we were calling a SelectionList
constructor that was assuming this was the case.
2018-05-24 08:08:51 +10:00
Maxime Coste
4ef5c80724 Fix Kakoune client busy looping on SIGHUP
Pure clients never quitted when they got SIGHUP after recent changes
to add is_ok to UserInterface. run_client now tracks the UI state as
well and quits if the UI gets killed.
2018-05-23 08:16:35 +10:00
Maxime Coste
56e2174cf6 Do not reuse m_buffer_trash to store dying buffers in ~BufferManager
Doing that clears m_buffer_trash, deleting buffers contained there,
but we are not ready to have Buffer destructors running yet as we
did not clear the ClientManager, meaning we might have free windows
pointing to buffers in the buffer trash.
2018-05-21 20:30:24 +10:00
Maxime Coste
d4e36958f8 Gather options in a vector when running Buffer::on_option_changed
on_option_changed might trigger hooks that will mutate the option
managers, invalidating the iterators we use.
2018-05-21 20:07:25 +10:00
Maxime Coste
919b7ce645 Fix also the implementation of to_string(size_t) change 2018-05-21 20:01:19 +10:00
Maxime Coste
edc53de8cc Small code cleanup 2018-05-21 07:55:07 +10:00
Maxime Coste
b7dabf11f2 Fix incompatible to_string function declaration when size_t is unsigned int 2018-05-21 07:53:21 +10:00
Maxime Coste
ec0f8fe574 Extend try command to support multiple catches.
If a catch command fails, and another catch is availabe following
it, that following catch gets executed.
2018-05-19 14:15:16 +10:00
Maxime Coste
243cfbc4ae Fix behaviour of extending to next match when wrapping
If the search wraps to get to next match, drop that selection when
extending.
2018-05-19 14:15:16 +10:00
Maxime Coste
14d12fac04 Rename -allow-override switch to -override
Closes #2057
2018-05-19 14:15:16 +10:00
Maxime Coste
c9a8658671 Fix assert with window small enough so that no part of buffer is displayed
Fixes #2056
2018-05-19 14:15:16 +10:00
Maxime Coste
79b60f69a9 Small code cleanups 2018-05-17 22:55:53 +10:00
Maxime Coste
b22c8ad8c7 Fix potential missed redraws 2018-05-17 22:50:11 +10:00
Maxime Coste
b0577d07f6 Merge remote-tracking branch 'Screwtapello/newlines-after-json-errors' 2018-05-17 07:47:34 +10:00
Maxime Coste
9bd3231d9b Avoid needless constant allocation in StaticRegister::set 2018-05-17 07:41:32 +10:00
Maxime Coste
4cc9c9997e compute_line_modifications: avoid potentially long iteration 2018-05-17 07:41:32 +10:00
Maxime Coste
fcce76ba57 Handle all pending events before redrawing
If new events happen while handling events, take care of those
new events as well before redrawing.
2018-05-17 07:41:32 +10:00
Tim Allen
0af53fb0dc Print a newline after errors in the JSON UI.
This makes them just a little easier to read.
2018-05-16 23:26:05 +10:00
Maxime Coste
75eb293f98 Rename Context::Flags::Transient to Context::Flags::Draft
Draft is well establish and all draft context are transient.
2018-05-14 08:23:00 +10:00
Maxime Coste
b204e773d4 Do not push jumps implicitely in transient contexts
This should improve performance in draft contexts.
2018-05-14 08:23:00 +10:00
Maxime Coste
288cf6de73 Fix performance problem when generating many values for # register
Fixes #2008
2018-05-09 23:02:53 +10:00
Maxime Coste
327d8ad759 Mark Client, Window, Buffer and OptionManager as final
Avoids warning about non virtual destructor calls on them,
as they have a vtable due to OptionManagerWatcher.
2018-05-09 23:01:40 +10:00
Maxime Coste
e8c648b7b7 Store the timestamp at which a display buffer was generated
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-05-08 21:56:44 +10:00
Maxime Coste
148d6c205b Fix wrong behaviour in select surrounding
Fixes #2030
2018-05-07 22:17:57 +10:00
Maxime Coste
7a841dcca7 Remove out of date noexcept(false) on MessageWriter destructor
This made sense when the writer was trying to send the message
in its destructor, but this is not the case anymore.
2018-05-05 07:59:13 +10:00
Maxime Coste
da1d78a3c2 Do not let exception propagate out of register restoring lambda
It is called during a std::vector destruction, which is noexcept,
leading to terminate being called.
2018-05-05 07:57:37 +10:00
Maxime Coste
7325ad216c Add support for explicit menu selection from the UI
the JsonUI now supports a "menu_select(int)" RPC call that should
trigger explicit selection of the provided item index.

As discussed for issue #2019.
2018-05-03 22:28:20 +10:00
Maxime Coste
c2637f08d9 JsonUI: Add support for a "mouse" RPC calls from the UI
As discussed on issue #2019
2018-05-03 22:27:59 +10:00
Maxime Coste
a19ce37634 Tweak the way register restorers are created to try to fix OSX compilation 2018-05-03 08:14:15 +10:00
Maxime Coste
74f90c1fc5 Refactor buffer undo tree
Store the undo tree as an array of undo nodes, instead of as a
pointer based tree.
2018-05-02 22:34:55 +10:00
Maxime Coste
4288f0fb3a Move ScopedEdition to context_wrap
No need to create it both in context_wrap and in the called function.
2018-05-01 22:49:01 +10:00
Maxime Coste
286a244aa2 Replace RegisterRestorer with a on_scope_end + lambda 2018-05-01 22:48:14 +10:00
Maxime Coste
6777c14697 Make OnScopeEnd valid even when non-copy elided
OnScopeEnd was relying on copy elision to avoid temporary destructor
calls that would run the scope end function too soon.
2018-05-01 22:47:06 +10:00
Maxime Coste
1fb53ca712 Fix wrong use of constexpr 2018-04-30 07:41:31 +10:00
Maxime Coste
e4f90e5ed2 Fix tests after changes to json_ui output 2018-04-29 23:06:24 +10:00
Maxime Coste
bcecb2f877 Fix crash on quitting 2018-04-29 22:59:20 +10:00
Maxime Coste
178d2d3cd3 Rework the way UI can trigger a client quitting
Add a UserInterface::is_ok method and return false on
SIGHUP/stdin closing/socket dropping

This should be cleaner and more robust than the previous SIGHUP
handling code.

Fixes #1594
2018-04-29 22:31:57 +10:00
Maxime Coste
57112b0845 Rename move to move_cursor
move is pretty ambiguous and hard to find due to std::move.
2018-04-29 22:31:57 +10:00
Maxime Coste
8e555cb992 JsonUI: add support for set_ui_options RPC call
As discussed on #2019
2018-04-29 20:45:53 +10:00
Maxime Coste
2fa553e728 Remove implicit conversion from String to DisplayAtom/DisplayLine 2018-04-29 20:45:53 +10:00
Maxime Coste
787ca7f19b Regex: small code style tweak 2018-04-29 19:58:18 +10:00
Maxime Coste
1e8026f143 Regex: Use only 128 characters in start desc and encode others as 0
Using 257 was using lots of memory for no good reason, as > 127
codepoint are not common enough to be treated specially.
2018-04-29 19:58:18 +10:00
Maxime Coste
528ecb7417 Regex: Use a custom 'DualThreadStack' structure to hold thread info
Instead of using two vectors, we can hold both current and next
threads in a single buffer, with stacks growing on each end.

Benchmarking shows this to be slightly faster, and should use less memory.
2018-04-29 19:58:18 +10:00
Delapouite
8b00d763e0 Docs: add exhaustive list of scoped objects 2018-04-28 17:41:24 +02:00
Maxime Coste
3afa32935f Merge remote-tracking branch 'Delapouite/unnamed-client' into HEAD 2018-04-28 09:30:35 +10:00
Maxime Coste
a1b8864c77 Merge remote-tracking branch 'lenormf/regex-format-string' into HEAD 2018-04-28 09:29:57 +10:00
Maxime Coste
2b9ec411d3 fix potential overflow in dump_regex 2018-04-28 09:29:15 +10:00
Frank LENORMAND
9bac04d35f regex_impl: Fix a potential format string flaw 2018-04-27 09:24:22 +03:00
Maxime Coste
8438b33175 Add a debug regex command to dump regex instructions 2018-04-27 08:35:09 +10:00
Maxime Coste
f10eb9faa3 Use indices instead of pointers for saves/instruction in ThreadedRegexVM
Performance seems unaffacted, but memory usage should be lowered
as the Thread struct is 4 bytes instead of 16.
2018-04-27 08:35:09 +10:00
Maxime Coste
4eb6740794 Add a -always switch to hook command to ignore hooks disabled
Hooks specified as always will run regardless of the hook disabled
status.
2018-04-26 08:28:11 +10:00
Maxime Coste
2d96fbed7c Reserve data for # register 2018-04-25 21:19:04 +10:00
Maxime Coste
2fc5a0317c Refactor RegexIterator::next to directly use a ThreadedRegexVM 2018-04-25 21:20:32 +10:00
Maxime Coste
fa17c46653 Regex: Refactor ThreadedRegexVM state handling
Remove ExecState to store threads inside the ThreadedRegexVM so that
memory buffers can be reused between executions. Extract an ExecConfig
struct with all the data thats execution specific to avoid storing
it needlessly inside the ThreadedRegexVM.
2018-04-25 21:19:04 +10:00
Delapouite
746b9acb96 Change client default name: "unnamed0" → "client0" 2018-04-23 11:42:11 +02:00
Stephen Hassard
eca53db2bf remove dragonflybsd specific logic since pkg-config works perfectly fine now 2018-04-22 09:12:45 -07:00
Maxime Coste
0b773ac26c Complete word from the current buffer in regex_prompt
This allows to use Kakoune fuzzy matching to get the words we
are looking for.
2018-04-19 07:58:42 +10:00
Maxime Coste
f545ff7727 Move get_word_db to word_db.cc 2018-04-19 07:58:42 +10:00
Maxime Coste
e207bd30d4 Extract a for_n_best algorithm from completion function
Provide the heap based n-best algorithm through a nice interface.
2018-04-19 07:58:42 +10:00
Maxime Coste
c2759ac526 Fix handling of local client quitting during its creation
If the local client was quitted during its creation (using -e quit
for example), we could have been accessing a null pointer afterwards.

Make the rest of the code aware that local_client might be null.
2018-04-19 07:56:37 +10:00
Maxime Coste
0f38be544c Makefile: use git-describe to get the version string
That means we can just tag releases and the version will be taken
from the tag to generate the tarball.
2018-04-14 13:05:59 +10:00
Maxime Coste
7f6a6ab1d3 Update startup message and include released version in it
Having released version information in that message will be useful
to allow user to know which breaking changes apply to them.
2018-04-14 13:04:45 +10:00
Maxime Coste
5fa19f4d7f NCursesUI: Add support for shifted function keys
Shifted function keys are not well standardized around terminals,
Shift F(N) usually returns F(X) + N, with X=12 on xterm, X=10 on
rxvt-unicode... Default to X=12 and make it configuable through
the ncurses_shift_function_key ui_option.

This fixes what #1898 tried to.
2018-04-11 20:39:57 +10:00
Tim Allen
50e422659b Add support for the shift modifier.
Because keyboard layouts vary, the shift-modifier `<s-…>` is only supported
for special keys (like `<up>` and `<home>`) and for ASCII lowercase where
we assume the shift-modifier just produces the matching uppercase character.
Even that's not universally true, since in Turkish `i` and `I` are not an
uppercase/lowercase pair, but Kakoune's default keyboard mappings already
assume en-US mappings for mnemonic purposes.

Mappings of the form `<s-x>` are normalized to `<X>` when `x` is an ASCII
character. `<backtab>` is removed, since we can now say `<s-tab>`.
2018-04-11 15:15:45 +10:00
Maxime Coste
d846400279 Redraw window when the face definition changed
Hash the current face state and store that hash to check for changes.
2018-04-10 20:35:23 +10:00
Maxime Coste
9c82f6586c FaceRegistry: Support referencing a named face from a parent scope 2018-04-10 19:57:16 +10:00
Maxime Coste
a2978bff25 Makefile: formatting fix 2018-04-10 19:02:32 +10:00
Maxime Coste
d571c207e6 Make version available through $kak_version and debug info 2018-04-09 17:06:02 +10:00
Maxime Coste
fc86acd9f0 Makefile: add a dist target to generate a tarball 2018-04-09 16:57:15 +10:00
Maxime Coste
57baad4afd Make FaceRegistry scoped
set-face now takes a scope argument, and faces can be overridden on
a buffer or window basis.

colorscheme apply on global scope, which should be good enough for
now.

Fixes #1411
2018-04-07 16:27:50 +10:00
Maxime Coste
6adb28ec12 Ignore current buffer when completing the :buffer command
Closes #1901
Fixes #1782
2018-04-07 16:27:44 +10:00
Maxime Coste
6f58c278bf Merge remote-tracking branch 'Delapouite/no-such' 2018-04-07 12:33:15 +10:00
Maxime Coste
23853f499e Add some safety static_asserts to remote read/write functions 2018-04-07 12:32:31 +10:00
Delapouite
cb02186c77 Make error messages more consistent 2018-04-06 16:56:53 +02:00
Maxime Coste
3c03129c46 Make compute_display_setup methods const 2018-04-06 09:16:59 +10:00
Maxime Coste
21603983c5 Add new buffers at the back of the buffer list
This will be reverted if we discover why we were doing things the
over way around.

Fixes #1881
2018-04-05 10:31:41 +10:00
Maxime Coste
f018a29b58 Merge remote-tracking branch 'Delapouite/declare-option' 2018-04-05 09:23:33 +10:00
Maxime Coste
71a1893a5e Fix some trailing spaces and a tab that sneaked into the code base 2018-04-05 08:52:33 +10:00
Maxime Coste
2f799b1acf NCurses: Tolerate failure to open /dev/tty and to ioctl for resize
Not sure what to do when that happens, but asserting and quitting
is not necessarily the best option, try to tolerate it.

Fixes #1972
2018-04-04 14:01:24 +10:00