Commit Graph

4737 Commits

Author SHA1 Message Date
Frank LENORMAND
e84dcf72c0 src: Allow hooks to be run only once
This commit implements the -once flag on the `:hook` command, which
automatically removes a hook after it was run, to avoid having to
declare a group and remove it in the hook implementation.

Closes #2277
2018-08-06 15:14:20 +03:00
Maxime Coste
472a5732e2 An empty string is not a valid number
Fixes #2284
2018-08-04 11:10:19 +01:00
Maxime Coste
3b77398c5b Add an assert to catch newpad returning a nullptr 2018-07-31 13:15:39 +01:00
Maxime Coste
075d1048ab Avoid invalid access to Optional
If the UI is not ok, the exit status of the client might not be
available. Return -1 in that case.
2018-07-30 10:32:38 +01:00
Maxime Coste
d2509e54f2 Fix compilation with gcc-5
Gcc-5 seems to have a bug in its handling of template variable.

Fixes #2267
2018-07-30 07:15:17 +01:00
Maxime Coste
2c9daf2378 Merge remote-tracking branch 'Delapouite/map-key-completer' 2018-07-28 19:48:24 +10:00
Maxime Coste
eef2ea5136 Lazily iterate over words instead of gathering them in a vector 2018-07-26 23:05:00 +10:00
Maxime Coste
eefe26b48b Fix shared string registry ref count stats 2018-07-26 22:20:19 +10:00
Maxime Coste
7cf3cbde8e Cleanup some trailing whitespaces and double semicolon 2018-07-26 21:56:34 +10:00
Maxime Coste
737807dde2 Replace a few loops with ranges 2018-07-26 21:23:06 +10:00
Maxime Coste
0919679e0d Make TransformView iterator's category match its underlying's
In particular, this make gathering a transformed range to a vector
faster because we can use the random access nature of underlying
iterator to get the size to allocate in the vector upfront.
2018-07-26 20:58:55 +10:00
Maxime Coste
62fa783bfd Fix missing override specifier 2018-07-26 20:16:48 +10:00
Maxime Coste
7905382b74 Obtain a new window for a client before releasing the current one
Creating a window potentially runs hooks, which themselves could
trigger shell evaluation, which could handle urgent input events
such as a resize, while waiting for the shell to finish. When that
happens, the client had a temporarily null window as it had already
released its own window.

Fixes #2225
2018-07-25 21:23:22 +10:00
Maxime Coste
a5f53dccb7 Micro optimize command parsing by avoiding utf8 decoding
Balanced quoted parsing does not need to decode utf8, neither does
unquoted word parsing. This improves startup time a bit, helping
for issue #2152
2018-07-25 20:58:07 +10:00
Maxime Coste
918fe6ddd8 Fix uninitialized context flags 2018-07-25 20:57:47 +10:00
Maxime Coste
0d6e04257b Fix memory leak in regex execution 2018-07-25 20:57:11 +10:00
Maxime Coste
b1187cf91d Quote every option type but integral types
Opt-in quoting was a bad choice, lets default to opt-out with
all integral types non quoted.
2018-07-24 20:26:24 +10:00
Maxime Coste
5f825cf0f5 Merge remote-tracking branch 'lenormf/fix-C-skip-empty-lines' 2018-07-23 21:14:23 +10:00
Maxime Coste
bbb508634e Support setting registers to empty lists
Note that empty registers still act as-if they contained a single
empty string.

Fixes #2228
2018-07-23 08:35:13 +10:00
Maxime Coste
f27700cc53 Restore SIGPIPE handler to default before spawning shell
Fixes #2238
2018-07-23 08:32:17 +10:00
Maxime Coste
6270ce4a80 Merge remote-tracking branch 'lenormf/fix-face-name-format' 2018-07-22 21:13:48 +10:00
Maxime Coste
3c51da4488 Merge remote-tracking branch 'lenormf/fix-development-version' 2018-07-22 15:58:41 +10:00
Maxime Coste
7b9f162e7d Opt-in types for quoting of option lists
This avoid quoting ints in int-lists for example, as they do not
risk containing whitespaces.

Fixes #2223
2018-07-22 15:51:32 +10:00
Frank LENORMAND
a2f9c68a7c src: Change the bullet point symbols in the version notes 2018-07-20 13:55:16 +03:00
Frank LENORMAND
60bd8df3c2 src: Don't print a number for the development version 2018-07-20 13:49:36 +03:00
Frank LENORMAND
2b0c143808 src: Allow face names to contain an underscore
Closes #2229
2018-07-20 09:47:30 +03:00
Frank LENORMAND
0b8899d1d4 src: Rename auto_complete to autocomplete
Removing the underscore seems to make the option name more
in line with the others (even though some do use a separator,
e.g. `disabled_hooks`).
2018-07-19 18:57:33 +03:00
Maxime Coste
7195100609 Re-introduce kill_session::exit_status, @lenormf was right
As discussed in #2186, in the end we need the exit status for the
case where the local client exited first (the server forked to
background) then another client trigger the kill command.
2018-07-19 19:27:56 +10:00
Maxime Coste
56a5dc66ff Merge remote-tracking branch 'lenormf/kill-clients-exit-code' 2018-07-19 18:42:22 +10:00
Maxime Coste
40a91b1120 Add a -debug '...' switch to Kakoune startup that sets the debug option
This gives an easy way to profile startup by running with -debug profile.
2018-07-19 18:36:49 +10:00
Maxime Coste
7ed5d53fe6 Fix RegexCompileFlags::Backwards having the same value as Optimize
That means every Optimized regex had the Backwards version
compiled as well, which doubled the time it took to compile them
and doubled the memory usage of regex.

This should improve #2152
2018-07-19 18:34:40 +10:00
Frank LENORMAND
5543a4d58c src: Propagate to clients the kill exit code
Fixes #2177
2018-07-19 10:54:49 +03:00
Maxime Coste
56912dd22c Merge remote-tracking branch 'icetan/buffer-reload-hook' 2018-07-19 08:29:22 +10:00
Maxime Coste
b1d5fda960 Reduce confusion in add-highlighter docstring
Closes #2222
2018-07-19 08:26:25 +10:00
Maxime Coste
c58457a3c0 Fix manual insert completion menu not getting automatically hidden
Fixes #2208
2018-07-15 11:46:02 +10:00
Maxime Coste
d23ac09fc1 Add support for <a-;> in prompt mode
Fixes #2096
Closes #2060
2018-07-15 11:17:16 +10:00
Maxime Coste
bde726d034 Change autoshowcompl to auto_complete with insert|prompt possible values 2018-07-15 11:10:32 +10:00
Maxime Coste
2f815511da Merge remote-tracking branch 'Screwtapello/fix-info-docstring' 2018-07-14 23:17:10 +10:00
Maxim Baz
3ca424d10f
Fix description of ui_options 2018-07-13 22:46:24 +02:00
Tim Allen
591a9ab093 The info command only takes one content string, not one-or-more. 2018-07-10 17:51:57 +10:00
Christopher Fredén
ae6c214f52
Add BufReload hook which is triggered on buffer reload 2018-07-09 14:20:52 +02:00
Maxime Coste
79ec8d0010 Rename highlighters that used an underscore to use a dash
For example `show_matching` is now `show-matching`.
2018-07-08 19:14:15 +10:00
Maxime Coste
1b5f665664 Refactor WrapHighlighter::next_split_pos to avoid non-linear complexity
Previous Implementation was constantly computing byte/column count
from the begining of the line, leading to a non-linear complexity
with respect to the length of a line.

Fixes #2146
2018-07-08 18:51:11 +10:00
Maxime Coste
51ec1194f1 Use a memory mapped file for sourcing 2018-07-08 17:25:12 +10:00
Maxime Coste
cde0c51cd6 Tweak comment to make it less ambiguous 2018-07-08 16:58:19 +10:00
Maxime Coste
b6933a2bdb Fix infinite loop on SIGHUP with the NCursesUI
Fixes #2126
2018-07-08 15:54:01 +10:00
Maxime Coste
f89ea657ef Fix asserts with -sync flag handling and slight code cleanup 2018-07-05 08:30:57 +10:00
Maxime Coste
63d4c8c311 Change a on end of line behaviour to be consistent
`a` will just jump on next line, `a` on last end of line opens a new
line beneath it.

Fixes #1164
2018-07-05 08:00:14 +10:00
Maxime Coste
55a5ec3bbd Tweak how highlighter names are auto-generated 2018-07-05 07:54:28 +10:00
Maxime Coste
2e0e206951 Make recurse regex opt-in with a -recurse switch instead of opt-out 2018-07-05 07:54:28 +10:00
Maxime Coste
f9fda70de6 Fix add-highlighter docstring 2018-07-05 07:54:28 +10:00
Maxime Coste
63d7984b89 Fix bug in recursive region highlighting 2018-07-05 07:54:28 +10:00
Maxime Coste
6993b0f347 Fix region highlighters validation that the delegate type exists 2018-07-05 07:54:28 +10:00
Maxime Coste
96c9718144 Parse unknown switches as positional for region highlighters 2018-07-05 07:54:28 +10:00
Maxime Coste
073b630e7a Prevent adding region/default-region highlighters to non-regions parents 2018-07-05 07:54:28 +10:00
Maxime Coste
711150f4ac Allow removing region from regions highlighter 2018-07-05 07:54:28 +10:00
Maxime Coste
1574748d4e Invalidate cache when RegionsHighlighter subregions are modified 2018-07-05 07:54:28 +10:00
Maxime Coste
64d0fd91ae Auto-generate highlighter name if only path is given 2018-07-05 07:54:28 +10:00
Maxime Coste
b0ccf97b44 Refactor RegionsHighlighters to define each region as a separate command 2018-07-05 07:54:28 +10:00
Maxime Coste
c9cdae4364 Add HashMap::items to access item list 2018-07-05 07:54:28 +10:00
Maxime Coste
d6b0297ac8 Fix ParameterParser::position_from with arbitrary indices 2018-07-05 07:54:28 +10:00
Maxime Coste
b4b335155e Refactor add-highlighter to make naming explicit
The highlighter name must be given as part of the path of the
highlighter, as the last element.

Fixes #1712
2018-07-05 07:54:28 +10:00
Maxime Coste
18dfecfa9d Introduce a "double_up" function for doubling up escaping 2018-07-05 07:54:28 +10:00
Maxime Coste
6a31d0ebc7 Fix auto escaping of command argument completion 2018-07-05 07:54:28 +10:00
Maxime Coste
7abf04babd Improve highlighting of Kakrc string regions
Unfortunately Strings that start with a quoted quote (like '''str')
are still incorrectly highlighted, a deeper refactoring of the regions
highlighter will be necessary.
2018-07-05 07:54:28 +10:00
Maxime Coste
eab98c88bd Refactor handling of startup info to make it configurable
A new `status_info_version` option allows user to disable info
message regarding changes that happened at that version or
earlier.
2018-07-05 07:54:28 +10:00
Maxime Coste
74e4925de0 Expand %reg{} inside double quotes only to the main selection value 2018-07-05 07:54:28 +10:00
Maxime Coste
124a5d4905 Tolerate restoring invalid coordinates from register
Clamp those selection after updating them to the current timestamp

Fixes #2078
2018-07-05 07:54:28 +10:00
Maxime Coste
ed123a2cc9 Reference the big breaking refactoring in the startup message 2018-07-05 07:54:28 +10:00
Maxime Coste
27163106c7 Make register expansions expand to the full register content
Now that we have a nice standard way to express lists of strings,
registers can be fully exposed. An new $kak_main_reg_... env var
was added to provide the previous behaviour which is relied on by
doc.kak.
2018-07-05 07:54:28 +10:00
Maxime Coste
d6c6ed9bbf Store each selection as a separate element in a register
It makes more sense to use the list nature of the register to store
the selections instead of storing them as a single string separated
by spaces.
2018-07-05 07:54:28 +10:00
Maxime Coste
8aba0b3cb4 Change set-register command to take a list of values
Registers are lists of strings, so this make it possible to set
the whole list instead of forcing registers to a single element
when going through the set-register command.
2018-07-05 07:54:28 +10:00
Maxime Coste
183f32803b Fix selection save/restore from registers post selection list syntax change 2018-07-05 07:54:28 +10:00
Maxime Coste
087a940fbe Add 'skip(size_t)' range utility to skip a number of elements 2018-07-05 07:54:28 +10:00
Maxime Coste
76093f252c Change env vars that are lists to use the general list syntax 2018-07-05 07:54:28 +10:00
Maxime Coste
8b2e5ea862 Make selection lists use the option list syntax 2018-07-05 07:54:28 +10:00
Maxime Coste
b548dd3a6f Change option lists to be specified as separate arguments on commands line
Option lists and maps are specified using separate arguments, avoiding
the need for additional escaping of their separator and reusing the
existing command line spliting logic instead.

As discussed on #2087, this should make it much easier to work with
list options, and make the general option system feel cleaner.
2018-07-05 07:54:28 +10:00
Maxime Coste
5eeec8bd4d Make expansion of strings support quoting of % by doubling up 2018-07-05 07:54:28 +10:00
Maxime Coste
c829595d01 Refactor command line parsing
Command line parsing now works as follow:

* Quoted strings ('...', "..." and %~...~ with '~' non nestable)
  use 'doubling-up' for escaping their delimiter, if the delimiter
  appears twice in a row, it is considered as part of the string and
  represent one delimiter character. So 'abc''def' == "abc'def". No
  other escaping takes place in those strings.

* Balanced strings (%{...}) do not support any kind of escaping, but
  finds the matching closing delimiter by taking nesting into account.
  So %{abc{def}} == "abc{def}".

* Non quoted words support escaping of `;` and whitespaces with `\`,
  `%`, `'` and '"` can be escaped with `\` at the start of the word,
  they do not need escaping (and will not be escaped) else where in
  a word where they are treated literally. Any other use of '\' is a
  literal '\'. So \%abc%\;\ def == "%abc%; def"

As discussed in #2046 this should make our command line syntax more
robust, provide a simple programmatic way to escape a string content
(s/<delim>/<delim><delim>/g), be well defined instead of ad-hoc
undocumented behaviour, and interact nicely with other common
escaping by avoiding escaping hell (:grep <regex> can in most case
be written with the regex unquoted).
2018-07-05 07:54:28 +10:00
Maxime Coste
24d8a58b0d Add -with-hooks to execute-keys and make -no-hooks evaluate-commands specific 2018-07-05 07:54:28 +10:00
Maxime Coste
9082564ab7 Make -with-maps only available for execute-keys command
It does not make a lot of sense to have this switch for
evaluate-commands.
2018-07-05 07:54:28 +10:00
Maxime Coste
5902c7b790 Do not save any registers by default in evaluate-commands 2018-07-05 07:54:28 +10:00
Maxime Coste
ec16969609 Do not reparse %sh{...} strings
Automatic reparsing of %sh{...}, while convenient in many cases,
can be surprising as well, and can lead to security problems:

'echo %sh{ printf "foo\necho bar" }' runs 'echo foo', then 'echo bar'.
we make this danger explicit, and we fix the 'nop %sh{...}' pattern.

To reparse %sh{...} strings, they can be passed to evaluate-commands,
which has been fixed to work in every cases where %sh{...} reparsing
was used..
2018-07-05 07:54:28 +10:00
Maxime Coste
3b9818c10b Merge remote-tracking branch 'lenormf/edit-readonly-flag' 2018-07-04 19:47:05 +10:00
Maxime Coste
86616c207d Merge remote-tracking branch 'lenormf/synchronized-write' 2018-07-04 19:46:40 +10:00
Frank LENORMAND
5309b7b5e5 src: Add a -sync flag to the write commands 2018-07-04 09:49:53 +03:00
Frank LENORMAND
dd17b20bbf src: Allow the edit command to create readonly buffers 2018-07-03 14:34:48 +03:00
dahlbaek
2a509ba73f Mark unused variables with the [[gnu::unused]] attribute 2018-07-02 19:33:52 +02:00
Frank LENORMAND
266ce73de7 src: Make C skip empty lines
This commits changes the way `C` behaves when the next line is empty:
instead of stopping the selection, it will now jump to the next line
that can hold a selection as big as the current one.

The primitive's count parameter holds the maximum amount of selections
that should be added to the current one.

Closes #2061
2018-06-30 14:39:15 +03:00
Frank LENORMAND
1cb51cacb7 src: Fix cycle hogging when using C at EOF 2018-06-30 11:53:28 +03:00
Maxime Coste
43b72770ec Fix wrong logic for moving filedescriptors leading to closed stdin
With this fix, tests can now use /dev/null as stdin.

Fixes #2165
2018-06-28 22:56:50 +10:00
Olivier Perret
67655de947 Use a dedicated vm op for dot when match-newline is false 2018-06-24 12:41:50 +02:00
Olivier Perret
b5ee1db1c4 Use bit-flags for storing regex regex options 2018-06-24 12:41:50 +02:00
Olivier Perret
8edef8b3f1 Add support for regex flag to toggle dot-matches-newline 2018-06-24 12:41:50 +02:00
Maxime Coste
667777521b Refactor the way main selection is determined after rotating contents
Fixes #2133
2018-06-21 08:07:17 +10:00
dahlbaek
52a3e9a84d Pass in OpenBSD binary path using preprocessor option
Alternative to hard coding binary path for OpenBSD
2018-06-20 14:20:55 +02:00
Patrick Marchand
dc3e4823a5 Remove extraneous include for openbsd
Forgot to remove this before pushing.
2018-06-20 14:20:55 +02:00
Patrick Marchand
2789857f32 Adds openbsd support
Seems to work on openbsd 6.3-current but needs more testing. Had to
hardcode the binary path as openbsd considers getting the executable
path at runtime a security flaw.
2018-06-20 14:20:55 +02:00
Maxime Coste
3d4ee7d201 Tweak search style menu completion display 2018-06-20 20:20:11 +10:00
Maxime Coste
b82d31016b Do not draw menu if it would hide prompt content 2018-06-20 08:12:53 +10:00
Maxime Coste
226db75aeb Change Search completion to display on top of the modeline 2018-06-19 21:02:24 +10:00
Maxime Coste
6dca67c674 Fix two <s-tab> requiered to access last completion in prompt
A single <s-tab> should be enough.
2018-06-19 07:40:52 +10:00
Delapouite
0bfdaf7d3e Improve unmap command key-completer 2018-06-15 15:16:08 +02:00
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
Maxime Coste
6ee60ff9d7 Prompt: add <a-!> to expand the typed expansions in current line
Fixes #1952
2018-04-04 11:00:25 +10:00
Maxime Coste
ff073bcce1 Merge remote-tracking branch 'lenormf/fix-ncurses' 2018-04-01 14:42:44 +11:00
Maxime Coste
ea66465144 Restore previous status line after notifying wait for shell
Fixes prompt getting erased by the wait for shell message, and
having to manually trigger a redraw to see it again.
2018-04-01 10:08:54 +11:00
Frank LENORMAND
e06d048d2f src: Make code more readable, assert function calls that shouldn't fail
Should help clarify what the issue is in #1972.
2018-03-31 15:00:19 +03:00
Maxime Coste
0baf562c93 Support full redraws during shell execution and handle resize there
Fixes #1973
2018-03-30 09:58:18 +11:00
Maxime Coste
f6f2dafaf7 Make set -add replace existing value when applied to a map option 2018-03-30 09:26:39 +11:00
Delapouite
7f3a308b60 Add status message when commiting an undo group in insert mode 2018-03-29 22:54:03 +02:00
Maxime Coste
fab3dc642a Merge remote-tracking branch 'Delapouite/on-key' 2018-03-28 21:41:17 +11:00
Maxime Coste
ebc700ee17 Fix uninitialized m_empty_text StringView in LineEditor 2018-03-28 20:48:50 +11:00
Delapouite
1b7b3fea09 Fix typo in on-key command description 2018-03-28 07:33:43 +02:00
Delapouite
fc3f0f40b7 Give more hints in "option not found" error. 2018-03-27 19:14:41 +02:00
Maxime Coste
1f6c2b87ff Support count in <a-s> to split on groups of n lines
Fixes #1966
2018-03-27 22:33:58 +11:00
Maxime Coste
e8093a12a0 Simplify command debug code 2018-03-27 08:25:47 +11:00
Maxime Coste
0a833371ab Prompt: Do not call callback in on_enabled
Schedule it for later, when we get "idle". It currently can lead to
crashed because after the callback, the current mode might be different,
leading to a crash when doing the ModeChange hook call.
2018-03-27 07:40:44 +11:00
Maxime Coste
3d3a37a80c Fix 'O' not putting the cursor on the correct line 2018-03-27 07:28:25 +11:00
Maxime Coste
253790be51 Formatting fix 2018-03-26 19:50:51 +11:00
Maxime Coste
5ba27c18a4 Fix operator priority order error 2018-03-26 19:19:47 +11:00
Maxime Coste
59c883d02f Avoid visiting the same directory multiple times in insert filename completion 2018-03-25 20:28:26 +11:00
Maxime Coste
6d3fe30bf6 Allow explicit filename completion with empty prefix 2018-03-25 19:03:54 +11:00
Maxime Coste
a6b1d142fa Cleanup client name validation code 2018-03-25 16:53:27 +11:00
Maxime Coste
49c52b025f Remove contains_that and use any_of to be closer to the c++ stdlib 2018-03-25 16:47:19 +11:00
Maxime Coste
435b5b7ff9 Unify code that validates identifiers in Kakoune
Session/Client/User modes names are now requiered to be "identifiers"
they must be in [a-zA-Z0-9_-]. Option names are the same except they
do not allow '-' as they need to be made available through the env vars
and '-' is not supported there.

Fixes #1946
2018-03-25 16:35:33 +11:00
Maxime Coste
beb2cef7f9 Document rotate selection breaking change in startup message 2018-03-25 11:39:26 +11:00
Maxime Coste
ec7f3738ee Move rotate selection and rotate selection contents to ) and <a-)>
Backward rotation are supported with (.

Fixes #1210
2018-03-25 11:39:26 +11:00
Maxime Coste
683ce8e83b Use 1 and -1 for Forward/Backward Direction to simplify code 2018-03-25 11:25:55 +11:00
Maxime Coste
59e9108812 indent selector: When line is empty, find indent from surrounding lines
Look for the first non empty line preceeding the current line, or
if not found, the first non empty line following it.

Fixes #1904
2018-03-25 10:25:56 +11:00
Maxime Coste
81f605709c Remove parse_filename overload and use a default parameter 2018-03-25 07:55:39 +11:00
Maxime Coste
a732037b53 Support % in path option to mean current buffer directory
In the end, % is not that painful to work with as its only set seldomly,
and we usually dont need to use expansion at the same time. Moreover, it
just requires a single \ to be escaped.

Fixes #1562
2018-03-23 08:22:34 +11:00
Maxime Coste
db7b43acd5 Restore client name after converting to client
When Kakoune forked the sever to background, the newly converted
to client process (the original client/server process) was not
preserving its previous client name.
2018-03-23 07:36:18 +11:00
Maxime Coste
1cdeace128 Merge remote-tracking branch 'Delapouite/doc-commands' 2018-03-21 06:42:31 +11:00
Maxime Coste
5c1a5c6d15 Revert "Throw when trying to remove a child highlighter that does not exists"
This reverts commit 56237aa8f8.

Throwing seems more correct, but it breaks lots of existing scripts.
reverting for now until we have a nice solution.
2018-03-20 20:11:15 +11:00
Delapouite
00cb49438a Docs: add missing [<switches>] in commands signatures 2018-03-20 09:13:09 +01:00
Maxime Coste
bec849ae14 Tolerate empty filenames in real_path 2018-03-20 05:56:20 +11:00
Maxime Coste
f7f84b7402 NCursesUI: Rework menu_show to shrink menu height when needed
Closes #1886
2018-03-20 05:54:19 +11:00
Maxime Coste
826977eb1b Fix remove of highlighters with trailing / in their name
Fixes #1914
2018-03-20 05:35:37 +11:00
Maxime Coste
56237aa8f8 Throw when trying to remove a child highlighter that does not exists 2018-03-20 05:35:15 +11:00
Maxime Coste
b27d4afa8d Regex: Only allow SyntaxCharacter and - to be escaped in a character class
Letting any character to be escaped is error prone as it looks like
\l could mean [:lower:] (as it used to with boost) when it only means
literal l.

Fix the haskell.kak file as well.

Fixes #1945
2018-03-20 04:57:47 +11:00
Maxime Coste
6e695e37be Fix real_path again 2018-03-19 20:49:05 +11:00
Maxime Coste
6d8747b886 Fix introduced bug in real_path 2018-03-19 06:28:06 +11:00
Maxime Coste
9518f279fb Tweak option documentation helper to support -add
Fixes #1939
2018-03-19 03:04:50 +11:00
Maxime Coste
8a7e844207 NCursesUI: refactor info_show code
Show MenuDoc info on the left of the menu if necessary. Cleanup the
code.
2018-03-19 01:23:32 +11:00
Maxime Coste
cf37623f1a Refactor read_fd '\r' removal logic 2018-03-18 23:43:18 +11:00
Maxime Coste
ac91a79b12 Fix implementation of real_path to handle non-existing directories in /
Fixes #1937
2018-03-18 23:23:00 +11:00
Maxime Coste
7ba4ef897b Fix crash on expanding command line strings 2018-03-18 04:58:15 +11:00
Maxime Coste
0a2807e652 RangesHighlighter: a range that goes up to buffer end is not valid 2018-03-16 23:25:37 +11:00
Maxime Coste
08df409a53 RankedMatch: Do not compare word boundary match count on single word matches
As the computation of word boundary matches is separate from the
actual subsequence matching, we sometimes have candidate that match
as a single word while still having multiple word boundary matches.

For example, with query "expresins", candidate "expressionism's"
will match as single word ("expressins" is a subsequence of
"expressionism"), and will have two word boundaries match (it does
match the last "s", which is considered as a separate word).

This should not be taken into account when compared against
candidate "expresions", which should be considered a better
match.

Fixes #1925
2018-03-15 23:20:03 +11:00
Maxime Coste
6f2b093eec NCursesUI: Show full menu rather than triming to respect anchor 2018-03-13 15:18:06 +11:00