Commit Graph

5740 Commits

Author SHA1 Message Date
Johannes Altmanninger
e6d0ff1bc8 Filter duplicate completions only if they have the same select cmd
Given a completer option with two applicable completions

	text|select-cmd1|menu-text1
	text|select-cmd2|menu-text2

Kakoune will only show one of them, because they will insert the
same text.

Some language servers send completions like this, for example if
two different importable modules provide the same name. This can be
reproduced using intelephense in this PHP file (cursor is %())

	<?php
	namespace namespace1;
	class sometype {}
	?>
	<?php
	namespace namespace2;
	class sometype {}
	?>

	<?php
	namespace test;
	some%()
	?>

Both completions insert "sometype". The import statement will be
added in an InsertCompletionHide hook by kak-lsp (it uses select-cmd
to determine which completion was selected).

To support this use case, refine the duplicate detection to not filter
out completions with different select-cmd values.
2022-02-11 16:51:29 +01:00
Qeole
3abf2b8260 Faces: Check that underline colour comes before base/attributes markers
Parsing a (non-valid) font with a comma in the name of the base colour
makes Kakoune crash. It is not a valid face, but Kakoune should just
return an error message instead.

Reproducer:

    :set-face global foo ,red@,blue

Note the comma "," after the "@". This is not a valid base name, and it
leads to a crash. Let's see what happens.

At the beginning of parse_face(), we have the following code:

    auto bg_it = find(facedesc, ',');
    auto underline_it = bg_it == facedesc.end() ? bg_it : std::find(bg_it+1, facedesc.end(), ',');
    auto attr_it = find(facedesc, '+');
    auto base_it = find(facedesc, '@');
    [...]
    auto colors_end = std::min(attr_it, base_it);

After this:

- bg_it points to ",red@,blue"
- bg_it != facedesc.end(), so we have underline_it pointing to the first
  comma after bg_it. This means that underline_it points to ",blue"
- base_it points to "@,blue"
- attr_it points to the end of facedesc (no "+" marker), so colors_end
  points to base_it, "@,blue"

Later in the code, just after parsing the foreground and background
colours, we have:

    if (underline_it != facedesc.end())
        face.underline = parse_color({underline_it+1, colors_end});

When passing {underline_it+1, colors_end} to parse_color(), we pass in
fact iterators pointing to {",blue", "@,blue"}. Because the second one
starts _before_ the first one in the string, this means that the
resulting string is considered to have a _negative_ length.
parse_color() passes the string to str_to_color(), who fails to turn up
the colour, and attempts to throw:

    throw runtime_error(format("unable to parse color: '{}'", color));

The variable "color" still has this negative length, and this goes all
the way down to an assert in src/units.hh where we expect that string to
be >= 0, and we crash on the assertion failure.

For similar reasons, we also get a crash if the comma comes after the
marker for the face attributes:

    :set-face global foo ,red+,a

To fix both cases, let's add a check to make sure that the underline_it,
marked with a comma, never gets detected as present and pointing after
colors_end, be it "@" or "+".
2022-02-11 09:35:49 +00:00
Johannes Altmanninger
43fc5b0078 Make <c-n> show completion menu again when autocomplete is off
As pointed out in [1], when insert mode autocomplete is disabled,
<c-n> could be used to activate insert mode completions temporarily
[2].  This regressed in 6f7c5aed (Do not show custom completions when
autocomplete is off, 2022-01-03). Fix this by enabling completions
on <c-n>/<c-p>. This allows us to remove a special case for explicit
completers.

Alternative behavior (future?): make <c-n> toggle completion like
<c-o>.  This can be done today, as suggested by Screwtape on IRC:

	map global insert <c-n> %{<c-o><c-n><a-;>:toggle-ctrl-n<ret>}
	define-command toggle-ctrl-n %{
		hook global InsertCompletionShow .* %{ map window insert <c-n> <c-n> }
		hook global InsertCompletionHide .* %{ unmap window insert <c-n> <c-n> }
	}

[1] https://github.com/mawww/kakoune/pull/4493#issuecomment-1031189823
[2] <c-n> completion only lives for the lifetime of the completion
    menu, whereas <c-o> lasts until you exit insert mode. This means
    that autocompletion is much more convenient than <c-n> or <c-x>f,
    because those require an explicit completion request for each
    path component.
2022-02-07 14:52:51 +01:00
Maxime Coste
33e81af0f3 Fix regex alternation execution priority
The ThreadedRegexVM implementation does not execute split opcodes as
expected: on split the pending thread is pushed on top of the thread
stack, which means that when multiple splits are executed in a row
(such as with a disjunction with 3 or more branches) the last split
target gets on top of the thread stack and gets executed next (when the
thread from the first split target would be the expected one)

Fixing this in the ThreadedRegexVM would have a performance impact as
we would not be able to use a plain stack for current threads, so the
best solution at the moment is to reverse the order of splits generated
by a disjunction.

Fixes #4519
2022-02-02 14:51:17 +11:00
Maxime Coste
4bd34caf4f Fix modified keys not being mappable in goto mode
The test was invalid, non-codepoint keys should be considered mappable.

Fixes #4521
2022-02-01 13:36:36 +11:00
Maxime Coste
bfbce2a1c1 Merge remote-tracking branch 'Screwtapello/fix-session-name-error' 2022-01-24 22:11:50 +11:00
Maxime Coste
f8a86149e5 Use strerror to display execve failures
Fixes #4501
2022-01-24 21:59:16 +11:00
Maxime Coste
6f135c0c8e Do not insert any end-of-line when piping data out
This will unfortunately break some use case which will require
using wrapper scripts to add the necessary newline. It is however
harder to do the contrary, and it makes a lot of other use case
possible, such as checksuming.

Fixes #3669
2022-01-24 21:53:33 +11:00
Maxime Coste
f4ff59f8b2 Restore goto case insensitiveness, refuse to map upper case
After a while it seems clear changing this is much more ergonomic
and restoring it with pure config is impractical as we need to map
all lower case keys.
2022-01-23 21:00:45 +11:00
Tim Allen
4bfb0c6b93 When reporting an invalid session name, report the correct name.
At this point, the session name has already been moved from the `session_name`
parameter to the `m_session` member variable.
2022-01-18 14:44:09 +11:00
Johannes Altmanninger
6f7c5aed10 Do not show custom completions when autocomplete is off
As reported in [1], completions provided by "set global completers
option=my_completion" activate insert mode autocompletion, even when
the autocomplete option does not have the insert mode flag.

This happens because InsertCompleter::on_option_changed() calls
InsertCompleter::setup_ifn(), which shows the completion pager.
Fix this by computing whether the completion pager is enabled;
otherwise we can return early from setup_ifn().
The completion pager is enabled if the autocompletion bit is set,
or if the user has requested explicit completion.

[1]: https://github.com/kak-lsp/kak-lsp/issues/585
2022-01-09 20:23:51 +01:00
Maxime Coste
f68e8313b2 Fix invalid line joining logic with multiple selection per line
Fixes #4476
2021-12-20 09:13:53 +11:00
Sidharth Kshatriya
02f9db616c Bug fix: use only iswlower() in RankedMatch::is_word_boundary() 2021-12-14 15:10:01 +05:30
Chris Webb
4a10220db8 Fix mode line inconsistency between normal and insert modes
In normal mode, the mode line contains "1 sel" or "n sels (k)" when n > 1,
whereas in insert mode, it contains "n sels (k)" even for n == 1. Change
the contents in insert mode to match normal mode.
2021-12-11 12:11:08 +00:00
Maxime Coste
6029ee9815 Fix explicit line completion
trim_indent call was incorrect, trim_indent is intended to work
on multi-line strings and trims trailing whitespace as well (could
benefit from a better name).

Fixes #4378
2021-12-11 09:34:51 +11:00
Maxime Coste
7648d56fc3 Fix parsing nul bytes in regex
Fixes #4460
2021-12-11 09:01:03 +11:00
Maxime Coste
b65df4bebf Fix spurious warning likely due to String::Data not being std compliant 2021-12-11 08:44:19 +11:00
Maxime Coste
658b6b0f1a Make space a named key to correctly handle shift modifier 2021-12-11 08:12:08 +11:00
Maxime Coste
716f1f967a Clang is still unhappy, trying another approach with defining my own concept 2021-11-25 22:32:10 +11:00
Maxime Coste
4122b64ecd Avoid using standard concepts
Turns out those are unimplemented in clang < 13, use custom code
instead.
2021-11-25 22:09:01 +11:00
Maxime Coste
28ac8adbfc Templatize parse_quoted to avoid utf8 decoding with ascii delimiter 2021-11-25 13:23:56 +11:00
Maxime Coste
16493a99bb small regex impl code style tweak 2021-11-25 09:59:45 +11:00
Maxime Coste
860b20ef0a Try to fix more CI failures related to C++20 2021-11-21 20:16:58 +11:00
Maxime Coste
532a7d7a9e Fix clang C++20 compilation issues 2021-11-21 20:06:14 +11:00
Maxime Coste
91550639bb More C++20 refactorings
Use CTAD instead of make functions, requires instead of enable_if
2021-11-21 11:41:50 +11:00
Maxime Coste
bea23c6bf2 Use std::remove_cvref instead of std::decay 2021-11-21 09:44:57 +11:00
Maxime Coste
ab9d78f50d Convert comparisons to spaceship operator 2021-11-21 09:44:56 +11:00
Maxime Coste
fb4cef5b61 Replace std::enable_if with requires
Introduce some concepts for enum and flags handling, goodbye and
thanks for all the fish std::enable_if.
2021-11-21 09:44:56 +11:00
Maxime Coste
ba379cba52 Micro-optimize regex character class/type matching
Also force-inline step_thread as function call overhead has a
mesurable impact.
2021-11-21 09:44:22 +11:00
Maxime Coste
8566ae14a0 Reduce the amount of Regex VM Instruction code
Merge all lookarounds into the same instruction, merge splits, merge
literal ignore case with literal...

Besides reducing the amount of almost duplicated code, this improves
performance by reducing pressure on the (often failing) branch target
prediction for instruction dispatching by moving branches into the
instruction code themselves where they are more likely to be well
predicted.
2021-11-21 09:44:18 +11:00
Maxime Coste
6a204c31ed Merge remote-tracking branch 'lenormf/debug_mode-gdb_script' 2021-11-21 09:36:25 +11:00
Maxime Coste
da3ddbf4fe Merge branch 'doc_highlighter_switch' of http://github.com/fennewald/kakoune 2021-11-21 09:35:14 +11:00
Carson
336c1d29b5 Documented -override switch for add-highlighter 2021-11-16 00:45:47 -05:00
Sidharth Kshatriya
dd92391036 Fixes #4432: JSON UI only shows stdin when connecting to an existing session
Only ui type Terminal is intended to be a user interactive session.
If your ui type is not Terminal, don't worry about making
the tty your stdin if fd 0 is not a tty.

This allows json-rpc commands sent via stdin to be acted up rather
than sent to a fifo (which is the default behavior for kakoune).

Does not change the behavior for Terminal ui sessions
2021-11-15 11:11:28 +05:30
Maxime Coste
e7100dc874 Recognize both <tab> and <c-i> as forward jump
Now that Kakoune opts into extended key reporting, <c-i> is correctly
reported and hence needs to be mapped to forward jump.

We still need to keep <tab> mapped to it for legacy terminals.

Should fix #4333
2021-11-11 13:29:42 +11:00
Frank LENORMAND
36166d8b0f src makefile: Install GDB types in debug mode 2021-11-08 13:39:55 +03:00
Maxime Coste
1b8574449f Kakoune 2021.11.08 2021-11-07 16:51:39 +11:00
Frank LENORMAND
6cadffa090 src highlighters: Factorise docstrings
Fixes #4367.
2021-11-05 11:30:35 +03:00
Frank LENORMAND
4eb8a100a8 src highlighters: Sort instantiations 2021-11-04 07:38:13 +03:00
Jason Felice
a70dbda54c use shifted key codes on kitty 2021-11-02 08:26:39 -04:00
Maxime Coste
19e2225153 Keep command_fifo read fd open instead of closing/reopening
Closing/reopening the read side seems to sometimes lead to
end-of-file not being received, leaving some extra data unexecuted.

The FDWatcher stays disabled during the executing of the fifo
commands so this should not enable any more commands to be executed
until we get back from the CommandManager and reset the FDWatcher
fd to to fifo read end.

Fixes #4410
2021-11-02 21:50:37 +11:00
Maxime Coste
e7adb01316 Merge remote-tracking branch 'sidkshatriya/remove-kak-history-file' 2021-11-02 21:09:25 +11:00
Maxime Coste
0f688656a4 Fix DECRPM parsing for 2026
As discovered in #4320 the previous code was buggy and would enable
synchronized output on any response.
2021-11-02 19:43:16 +11:00
Maxime Coste
8299d1da1f Fix pasting all from empty register
Raise an error if the register is empty for paste-all

Fixes #4414
2021-11-01 09:05:57 +11:00
Maxime Coste
d2e2caaae6 Fix incorrect reading logic and EAGAIN handling
This is one of the issues raised by #4410
2021-10-29 22:34:19 +11:00
Maxime Coste
be4659097c Complete alias command with existing alias names 2021-10-29 08:20:08 +11:00
Maxime Coste
874f3e0764 Fix terminal underline color not being properly reset 2021-10-29 07:51:29 +11:00
Maxime Coste
da10ce817e Kakoune 2021.10.28 2021-10-28 09:13:34 +11:00
Robert Clausecker
120e4b5a5d src/main.cc: Fix inline assembly syntax error on ARM
ARM uses @ as a comment character, so %progbits must be
used in place of @progbits here.  This change fixes the
build on armv7 FreeBSD 13.0.

Fixes		mawww/kakoune/issues#4385
See also	https://bugs.freebsd.org/259434
2021-10-25 15:17:49 +02:00
Maxime Coste
6e635ea301 Merge remote-tracking branch 'lenormf/fix-2164' 2021-10-24 18:42:37 +11:00
Frank LENORMAND
16dfe977b2 src: Make gf open all selected paths
The buffer whose path is under the main selection will be focused
after all others have been opened.

Closes #2164
2021-10-24 09:01:24 +02:00
Maxime Coste
502e3f6857 Fallback to basic path on platforms where _CS_PATH is not defined
This happens on termux for example.
2021-10-24 09:37:59 +11:00
Maxime Coste
7c6f111d5f Ensure rename-buffer uses a filename for file buffers
Fixes #4391
2021-10-24 09:30:31 +11:00
Maxime Coste
5c1e10decb Merge remote-tracking branch 'lenormf/fix-4340' 2021-10-24 09:04:14 +11:00
Frank LENORMAND
c57a86ce62 src: Fix undefined behaviour
Cppcheck produces the following warnings:

```
shared_string.hh:27:49: portability: Shifting signed 32-bit value by 31 bits is implementation-defined behaviour
shared_string.hh:27:49: error: Signed integer overflow for expression '1<<31'.
```

Fixes #4340
2021-10-23 10:36:37 +02:00
Frank LENORMAND
367879ddcf src: Use pre-increment iterator syntax
Cppcheck produces the following warning:

```
string_utils.cc:24:9: performance: Prefer prefix ++/-- operators for non-primitive types.
```

Fixes #4340
2021-10-23 10:34:27 +02:00
Frank LENORMAND
aff303190d src: Fix the API of KeymapManager::add_user_mode()
Cppcheck produces the following warning:

```
keymap_manager.hh:54:37: performance: Function parameter 'user_mode_name' should be passed by const reference.
```

Fixes #4340
2021-10-23 10:34:27 +02:00
Maxime Coste
60165bacf9 Use DECRQM/DECRPM to detect support for synchronized output
Enable it if supported by default, let the user override it with
the existing terminal_synchronized ui option.

This should finalize work discussed on #4317
2021-10-23 09:42:31 +11:00
Frank LENORMAND
0af234a329 src: Implement the enumerate() range filter 2021-10-21 10:58:46 +02:00
Maxime Coste
689553c2e9 Split InsertMode into InsertMode and PasteMode
They are quite different use cases, and this allow moving InsertMode
to input_handler.hh which is what uses it.

This also cleans up the code as we can get rid of get_insert_pos and
rely more on SelectionList::for_each.
2021-10-10 11:02:09 +11:00
Maxime Coste
b609adc84c Merge http://github.com/Jonta/kakoune 2021-10-09 15:44:43 +11:00
Maxime Coste
ddcfa0f0e5 Merge remote-tracking branch 'lenormf/fix-1840' 2021-10-09 15:43:43 +11:00
Jonta
e93ebbca78
Grammar 2021-10-07 04:59:03 +02:00
Jonta
123a264894
Merge pull request #1 from Jonta/Jonta-grammar-an-highlighter-1
Grammar
2021-10-07 04:57:53 +02:00
Jonta
4a34ae9c2d
Grammar 2021-10-07 04:57:29 +02:00
Jonta
caea620229
Grammar 2021-10-07 04:54:55 +02:00
Frank LENORMAND
0d87d70bd1 src: Remove spurious break 2021-10-06 08:44:47 +02:00
Frank LENORMAND
a5dd8a7935 src: Allow ga to skip removed buffers
This commit prevents `ga` from returning a “no last buffer” error
when the previously displayed buffer was removed.

Since the jumps list keeps track of the order in which buffers were
displayed already, handling arbitrary `delete-buffer`s as well,
cycle through it to implement `ga` instead of storing a pointer.

Note that this commit doesn't take into account buffer flags that
might exclude some buffers from being cycled over by commands.

Fixes #1840
2021-10-06 08:44:47 +02:00
Maxime Coste
21494e5d78 Merge remote-tracking branch 'lenormf/fix-3976' 2021-10-06 09:00:21 +11:00
Maxime Coste
09f4ef0917 Merge remote-tracking branch 'lenormf/fix-4353' 2021-09-30 20:43:02 +10:00
Maxime Coste
5f8753caec rework selection insert/replace using a for_each method
expose that method so that various commands can take advantage of
it for performance or simplicity purposes.
2021-09-30 20:12:58 +10:00
Maxime Coste
e3bcd6a74b Merge remote-tracking branch 'lenormf/modeline_readonly_status' 2021-09-26 11:09:34 +10:00
Maxime Coste
2eb6b14b14 Merge remote-tracking branch 'lenormf/patch-15' 2021-09-26 11:03:51 +10:00
Maxime Coste
3acf85f267 Restore diff based terminal output optimization when synchronized
terminal_synchronized ui_option now also controls this behaviour,
update out of date documentation for ui_options as well.

As discussed in #4317
2021-09-26 11:03:50 +10:00
Maxime Coste
1456431951 Merge remote-tracking branch 'Screwtapello/add-diagnostic-faces' 2021-09-21 21:11:56 +10:00
Maxime Coste
9ea1d82135 Merge remote-tracking branch 'lenormf/drop-travis' 2021-09-21 21:08:59 +10:00
Frank LENORMAND
e4d6952d8c src: Show a readonly modeline tag when relevant 2021-09-21 12:59:30 +03:00
Frank LENORMAND
b3c62c3e08 src: Error out on unmapped key in g and v
Fixes #4353.
2021-09-15 09:20:53 +03:00
Frank LENORMAND
4afe923945 src: Make g and v case sensitive
The current implementation allows users to declare mappings in the
`goto` and `view` modes with uppercase letters, but doesn't consider
case to be meaningful.

This quirk is also inconsistent as hitting an unmapped key will quit
the mode menu without complaints, but hitting a key that isn't in it
will work if it has a lowercase mapping equivalent.

Fixes #3976
2021-09-14 19:00:50 +03:00
Frank LENORMAND
4b77d011e9
src: Fix on-key usage docstring 2021-09-09 08:22:43 +03:00
Maxime Coste
b3a1017a26 Remove scrolling detection/optimization in terminal output
Just validate if line changed or not. This should avoid flickering
on terminals such as the linux console that eagerly redraw on line
deletions. Unfortunately this means drawing will use more data and
might add a bit of latency on slow links.

Fixes #4317
Fixes #4320
2021-09-09 09:01:42 +10:00
Frank LENORMAND
9f0b241e09
src: Uninstall libexec properly 2021-09-08 14:26:48 +03:00
Maxime Coste
3d8061b975 Fix set-face docstring to include underline color 2021-09-08 08:23:16 +10:00
Tim Allen
dc07c649de Add standard DiagnosticError and DiagnosticWarning faces.
kak-lsp uses these faces to mark errors inside the buffer, instead of the Error
face which is much more jarring, and which does not have an associated warning
face. Since the :spell command marks errors inside the buffer, it's also updated
to use this new face.

Adding these faces to Kakoune makes it more likely that colorschemes will
automatically do the right thing when used with kak-lsp, and makes it possible
to use a subtle appearance (like curly underlines) for in-buffer errors while
keeping Kakoune errors bold and jarring as they should be.
2021-09-07 17:46:50 +10:00
Maxime Coste
3fc8e29d10 Add support for curly underline and separate underline color
Add support for a third color in face definition that controls
the underline and a 'c' attribute for curly underline (that takes
precedence over 'u' if both are specified)

Allow empty colors to mean default, so that `,,red+u` means the
same as `default,default,red+u`

Fixes #4138
2021-09-07 08:21:26 +10:00
Maxime Coste
a6644d3034 Fix strikethrough support in face to string conversion 2021-09-05 09:20:35 +10:00
Maxime Coste
e32b2156d9 Add missing strikethrough in set-face docstring 2021-09-04 13:54:18 +10:00
Maxime Coste
5c6c58ae22 Remove unnecessary c_str() calls 2021-09-02 21:19:21 +10:00
Maxime Coste
b841f3a214 Remove terminal_wheel_up/down_button UI option
It seems nobody uses it, and it is not plugged through anyway.

Closes #2642
2021-09-02 20:46:35 +10:00
Maxime Coste
2edabde919 Do not go through some temporary selections for indent/deindent
This does not seem necessary and simplifies the logic
2021-08-30 16:14:26 +10:00
Maxime Coste
33a80e644c Take a function SelectionList::insert to get string to insert
This makes it unnecessary to allocate Vector<String> to insert and
allows to remove the insert_pos pointer hack by passing it to the
callback.
2021-08-30 16:14:26 +10:00
Maxime Coste
bc11f972c5 Kakoune 2021.08.28 2021-08-28 14:07:42 +10:00
Maxime Coste
726bec4670 Support info markup spanning multiple lines
Preserve the active face accross lines

Fixes #4313
2021-08-28 13:53:23 +10:00
Maxime Coste
e454b393cf Fix readonly behaviour
Make readonly specified on startup only apply to files provided on
the command line, and use the correct scope in `edit -readonly`

Fixes #4278
2021-08-22 22:59:16 +10:00
Maxime Coste
c1e8f57bd6 Merge branch 'roam-hurd-exec-path' of http://github.com/ppentchev/kakoune into HEAD 2021-08-22 22:41:27 +10:00
Peter Pentchev
6eb56a97d2 Find the executable path on the GNU Hurd, too. 2021-08-21 17:14:21 +03:00
Peter Pentchev
aa88f459ff Use the [[gnu::packed]] C++ attribute.
Suggested by: Maxime Coste <mawww@kakoune.org>
2021-08-21 17:06:14 +03:00
Peter Pentchev
6e686af8b5 Do not break non-GCC/g++ compilers. 2021-08-20 17:21:26 +03:00
Peter Pentchev
0e9624f69f Make sure the ParsedRegex structure has the right size.
Some versions of GCC/g++ will not necessarily pad the structure to
a 32-bit boundary, so make the alignment and the filler explicit.

Detected on: Debian/m68k; https://buildd.debian.org/status/fetch.php?pkg=kakoune&arch=m68k&ver=2020.09.01-1&stamp=1629387444&raw=0
2021-08-20 17:13:34 +03:00
Maxime Coste
7187784936 Move control character escaping responsibility to the terminal UI
Fix atom text at display time, allow tabs/eol/etc... in display
atoms and escape them just-in-time

Fixes #4293
2021-08-17 20:40:30 +10:00
Maxime Coste
94388dc51e Merge remote-tracking branch 'alexherbo2/fix-typos' 2021-08-17 08:48:47 +10:00
Maxime Coste
e8e535e1cf Merge remote-tracking branch 'krobelus/no-env-var' 2021-08-17 08:27:49 +10:00
Maxime Coste
cde67c25aa Merge remote-tracking branch 'krobelus/complete-at-percent-delimiter' 2021-08-17 08:27:37 +10:00
Johannes Altmanninger
c1bdafef48 Avoid "env var" in error message for unknown %val expansion
This meaning is only used in C++ sources. The docs use "env
var"/"environment variable" a few times for actual environment
variables.
2021-08-10 08:23:14 +02:00
Johannes Altmanninger
abd833e0dc Restore prompt completion for "%opt{"
Commit 2289f350 ("Remove command parsing Reader and just track a
ParserState") introduced a small regression in parse_percent_token()
because we failed to recognize a token like %val{ as percent-expansion.

I tried to add a test case but a UI test doesn't seem possible, e.g.

	kak -ui json -e "exec ':echo %opt{<tab>}<ret>'"

prints: 'exec': option not found: ''
2021-08-09 22:46:06 +02:00
Maxime Coste
73da47258d Reduce memory usage and allocations in terminal output code
Store data in unique_ptr instead of vectors as we have fixed sizes
Do not allocate new hashes, recompute them on-demand
2021-08-05 11:52:37 +10:00
Maxime Coste
24c23af341 Remove unnecessary fflush call 2021-08-05 10:57:35 +10:00
Maxime Coste
7b126704c7 Fallback to 80x24 terminal size when ioctl fails or returns 0x0
Fixes #4286
2021-08-04 20:51:50 +10:00
Maxime Coste
1b7616b3fc Use a BufferedWriter to output in the terminal ui instead of stdio
Clearer control of buffering and flushing
2021-08-01 20:07:20 +10:00
Maxime Coste
1728274803 Add a format_with format function that takes a FunctionRef append 2021-07-31 09:45:05 +10:00
Maxime Coste
a566a22cbc Expose BufferedWriter 2021-07-31 09:44:24 +10:00
Maxime Coste
914f4f8c19 Fix FunctionRef copy construction
The template constructor was mistaken as a copy constructor.
2021-07-31 09:43:49 +10:00
Maxime Coste
b57dc7c512 Code style tweak for Regex implementation TestVM 2021-07-31 08:55:52 +10:00
Maxime Coste
cf52379422 Do not run unit tests in release builds
They mostly rely on assertions that are disabled in those builds
anyway.
2021-07-26 16:57:07 +10:00
Maxime Coste
cbba348a83 always inline custom operator new/delete to avoid spurious warnings
GCC 11 warns incorrectly about mismatched new/delete because it auto
inlines one but not the other, force inline those function to fix that.
2021-07-26 16:55:36 +10:00
Maxime Coste
15aa4fe137 Document the new write behaviour 2021-07-20 22:45:33 +10:00
Maxime Coste
7f41a277a0 Merge remote-tracking branch 'occivink/nop-ignore-unknown-switches' 2021-07-20 22:37:09 +10:00
Maxime Coste
40e3614cf4 Prevent overwriting existing file in :write <explicit filename>
Add a -force (equivalent to w!) switch that enables overwriting.
2021-07-20 22:30:41 +10:00
Maxime Coste
4d99434ddd Remove unnecessary forward declaration 2021-07-20 22:30:41 +10:00
Maxime Coste
3c1199f665 Add missing new/delete overload in UseMemoryDomain 2021-07-20 22:30:41 +10:00
Maxime Coste
63b67d0f31 Remove some unnecessary string copies in TerminalUI 2021-07-20 22:30:41 +10:00
Maxime Coste
e3957bb24c Generate different parse_quoted_balanced for each quote pair
This seems to slightly improve parse speed which is where kakoune
spends most of its time during startup.
2021-07-20 22:30:41 +10:00
Maxime Coste
a4dd89f214 Improve code-generation for Strings
Make String::Data use trivial copy of the short/long union to avoid
unnecessary branching there, inline release() as it can be elided by
the compiler on moved-from Strings.
2021-07-20 22:30:41 +10:00
Olivier Perret
55f9a69465 nop: ignore unknown switches instead of failing 2021-07-19 11:47:07 +02:00
Maxime Coste
c643cd4467 Fix blitting of windows halfway through double-width codepoint
Display a whitespace in place of the uncovered half of the codepoint.

(I know this is incorrect and we should be considering grapheme clusters
instead of codepoints, but this is a far bigger refactoring and another
can of worms to handle with terminal emulators).

Fixes #4262
2021-07-14 20:51:25 +10:00
Maxime Coste
ac6420ee8d Refactor TerminalUI::set_ui_options
Take advantage of Optional monadic operations
2021-07-12 10:25:59 +10:00
Maxime Coste
428ddeb97b Add 'terminal_synchronized' ui_option to opt-in synchronized output
Synchronized output does not work well with various terminals
(including the linux console). It should also be unnecessary when
not going through a slow link.

This will eventually be removed if it is not proven to be useful
to some users.
2021-07-12 10:25:59 +10:00
Jason Felice
5d497dc46e src: Support strikethrough faces 2021-07-12 10:25:59 +10:00
Maxime Coste
cbd0dc571b Fix crash when displaying a menu on a too small terminal
The code could position the menu at a negative line leading to
invalid array accesses.
2021-07-12 10:25:59 +10:00
Maxime Coste
76e5d11c8b Small cleanups in terminal ui 2021-07-12 10:25:59 +10:00
Maxime Coste
44deaeb4eb Do not trust saved active face when force redrawing 2021-07-12 10:25:59 +10:00
Maxime Coste
7bbc057cd7 Slight code simplification 2021-07-12 10:25:58 +10:00
Maxime Coste
b3025b87d0 Fix race on resize in terminal ui 2021-07-12 10:25:58 +10:00
Maxime Coste
86025f88c4 Fix force redraw handling
Fixes #3559
2021-07-12 10:25:58 +10:00
Maxime Coste
cd613da050 Tolerate bliting window that overflow the target
Although we try to avoid those, ensuring it never happens is tricky,
and tolerating them avoids the crash.

Fixes #3498
2021-07-12 10:25:58 +10:00
Kylie McClain
89e0b4b830 terminal_ui.cc: fix build on musl libc 2021-07-12 10:25:58 +10:00
Tim Allen
de065dad2d terminal_ui: restore termios settings before suspending Kakoune.
TerminalUI::suspend() is responsible for undoing all Kakoune's modifications to
the terminal state, actually suspending the process, then re-applying all the
modifications after Kakoune wakes back up.

Previously, the "undo" and "reapply" steps for termios settings were both after
the suspend point, so on some platforms they were incorrect when the user
arrived back at the shell prompt.

Now, the termios "undo" step is back before the suspend point, and the undo and
reapply steps should be in exactly reversed order.

Fixes #3488.
2021-07-12 10:25:58 +10:00
Tim Allen
e760f2df6b Use iTerm2 "synchronised update" sequences around redraws.
In terminals that support it, this sequence causes the terminal to not redraw
*its* output until the application has finished, reducing redraw flickering.

The sequence is defined in:

    https://gitlab.com/gnachman/iterm2/-/wikis/synchronized-updates-spec

...and is apparently also supported by kitty and libVTE.

Fixes #3482.
2021-07-12 10:25:58 +10:00
Maxime Coste
72271ce529 Handle skipped characters with erase line (EL) instead of insert blank (ICH)
insert blank seems to behave differently between terminals and would
be less efficient because it still has to shift all following characters
(that we will overwrite anyway).

Fixes #3437
2021-07-12 10:25:58 +10:00
Maxime Coste
b0dcb07540 Reduce amount of SGR escapes emitted by tracking the active face 2021-07-12 10:25:58 +10:00
Maxime Coste
63310370f8 Remove explicit whitespace padding in menu/info
Rely on the backend to clear content to eol
2021-07-12 10:25:58 +10:00
Maxime Coste
484cfae9d1 Use CSI @ instead of emitting lots of spaces
This greatly reduces the amount of data written for a redraw especially
on big terminals where most of the data is trailing blanks
2021-07-12 10:25:58 +10:00
Maxime Coste
8e1b79b1b7 Remove the concept of cursor in TerminalUI::Window 2021-07-12 10:25:58 +10:00
Maxime Coste
65fbabcb86 Fix another display corruption issue in the terminal output code 2021-07-12 10:25:58 +10:00
Maxime Coste
5c3b0b7503 Fix another terminal update issue in the latest code change
Fixes #3426
2021-07-12 10:25:58 +10:00
Maxime Coste
e6801867c7 Fix bug in terminal output line delete logic 2021-07-12 10:25:58 +10:00
Maxime Coste
5a31b9f351 Fix tab character that got introduced by mistake 2021-07-12 10:25:58 +10:00
Maxime Coste
68f0bcce7c Reduce the number of added/removed lines when redrawing screen
This should reduce flickering.
2021-07-12 10:25:58 +10:00
Maxime Coste
0506de8443 Fix compute_pos behaviour not to overflow by one line
Thanks to eraserhd for debugging this and proposing an initial fix.

Fixes #3414
Close #3418
2021-07-12 10:25:58 +10:00
Maxime Coste
5466f63eeb Use insert/remove lines escapes to reduce terminal traffic
Diff against known state and insert/erase relevant lines.

Erase everything first to avoid insertion invalidating lines that
get out of the terminal at bottom.
2021-07-12 10:25:58 +10:00
Maxime Coste
9e8f555a82 Only redraw updated lines 2021-07-12 10:25:58 +10:00
Maxime Coste
07750656a8 Blit all window together before outputing them to the tty
This should reduce flicker, by avoiding transient states where
info/menu windows are not displayed, and paves the way for proper
diffing of the screen.
2021-07-12 10:25:58 +10:00
Maxime Coste
03563d51aa Fix crash on resize in TerminalUI 2021-07-12 10:25:58 +10:00
Maxime Coste
7e66846172 Rename NCursesUI to TerminalUI 2021-07-12 10:25:58 +10:00
Maxime Coste
3b4d2b63c6 Remove references to ncurses in Makefile 2021-07-12 10:25:58 +10:00
Maxime Coste
c12699d2e9 Replace ncurses with a naive custom terminal backend 2021-07-12 10:25:58 +10:00
Maxime Coste
7622ebcc92 Quit server on SIGINT when it was not signaled by Kakoune itself
Fixes #3974
2021-07-12 10:08:17 +10:00
Maxime Coste
c30a0e0ca2 Inline String::Data no-copy constructor 2021-07-09 17:03:22 +10:00
Maxime Coste
2289f350df Remove command parsing Reader and just track a ParserState
The Reader abstraction was leading to suboptimal code by encouraging
decoding utf8 separately from advancing to next codepoint.
2021-07-09 17:03:22 +10:00
Maxime Coste
86c5e8f75b Avoid temporary vector in expand_token
Instead of return a vector, take the target vector as a parameter
and push tokens to it.
2021-07-09 17:03:22 +10:00
Maxime Coste
cd67f2cf11 Avoid copying token content strings in expand_token
We can move that data instead of copying
2021-07-09 17:03:22 +10:00
Maxime Coste
64e306f64b Document command-fifo in changelog 2021-07-07 19:46:47 +10:00
Maxime Coste
5ed9e1b356 Catch errors while executing shell commands
Log error to debug buffer and Change the 'waiting for shell' face
to 'Error'.

Update the 'waiting for shell' message when the shell has exited
but Kakoune is still waiting on stdin/stdout/stderr to be closed.
2021-07-07 19:25:06 +10:00
Maxime Coste
3d7fb8ddbc Add support for $kak_command_fifo and $kak_response_fifo
Those fifos are accessible during %sh{...} blocks, the command fifo
executes commands written to it once the write end side is closed
(multiple open/write/close sequences are supported), the response
fifo is a simple helper fifo available to write response back to
the shell process

An example use of this feature is to request some list options
content from without being limited by the environment size:
```
%sh{
    echo "echo -to-file $kak_response_fifo -quoting shell -- %opt{some_list}" > $kak_command_fifo
    eval "set -- $(cat $kak_response_fifo)"
}
```
2021-07-07 19:25:06 +10:00
Maxime Coste
6215bff764 Decouple generate_env from actual ShellManager env var collection 2021-07-07 19:25:06 +10:00
Maxime Coste
0c92ec8a23 Merge remote-tracking branch 'Screwtapello/save-restore-window-title' 2021-07-07 19:16:07 +10:00
Dmitry Matveyev
dbfbb1b5a6 Restore terminal during suspend before changing alternate screen 2021-06-27 16:49:39 +06:00
Maxime Coste
c68f85659f Handle Ctrl+Z key later in the terminal input stack
The previous handling code was at a pretty random location and broke
terminals that could send <c-z> encoded in a non pure ascii way.

See #4238
2021-06-27 16:56:29 +10:00
Maxime Coste
f0f3c0f735 Merge remote-tracking branch 'SolitudeSF/mode' 2021-06-26 09:59:45 +10:00
Sidharth Kshatriya
c5a1ddeaff Better style 2021-06-24 19:53:38 +05:30
Sidharth Kshatriya
5244ecbe9b Also deal with variables named kak_quoted_* by using a more generic approach 2021-06-24 19:49:54 +05:30
Sidharth Kshatriya
0ca81e7cec Fix: Kakoune passed environment variables in shell invocations are repeated
If a %sh{} script refers to any variables multiple times they are all multiply
included in the environment. Example: if a %sh{} invocation refers to
${kak_buffile} 5 times, the environment will have "kak_buffile=..." repeated 5
times and so on. This repetition happens for each multiply used variable that
is passed into the environment.

The variable should, of course, be only passed into the environment once. This
commit should fix this issue.
2021-06-24 14:03:58 +05:30
Maxime Coste
be9b2de0ee Only compute command coordinates when necessary
Tracking the line/column of each token takes a surprising big part
of the command parsing logic runtime and is only necessary when we
hit an error.
2021-06-24 17:20:37 +10:00
Maxime Coste
49e2ecdcdb Fix invalid command profiling logic 2021-06-24 17:14:10 +10:00
SolitudeSF
9fff572aab
Restore terminal before switching from alternate screen 2021-06-18 08:22:59 +03:00
Tim Allen
7c48a72e11 src: Restore the window title when quitting or suspending Kakoune.
Fixes #4228.
2021-06-15 12:04:21 +10:00
Taupiqueur
ad1dc79789 Fix typos 2021-06-13 04:12:03 +02:00
Maxime Coste
95b0627e54 Fix focus_in/focus_out keys not having user friendly names 2021-05-28 20:32:12 +10:00
Maxime Coste
049b9a28d1 Fix File Buffer flag not being correctly applied 2021-05-28 20:31:28 +10:00
Maxime Coste
fb9dbfed2a Canonicalize <s-ascii> into uppercase in csi key parsing code
Fixes #4159
2021-05-28 20:15:56 +10:00
Maxime Coste
e4a23a64fa Support opening files bigger than 2 GiB
The real technical limit is with lines bigger than 2 GiB and buffers
with more than 2 Gi lines, refactor buffer loading to make it possible
to load those files.

Fix an overflow with the hash_data function at the same time
2021-05-28 17:03:41 +10:00
Maxime Coste
0cecea6593 Fix completion past explicitely closed tokens
This fixes an issue where completion would still be provided after
the closing character of a token, which could then get frustrating
combined with auto-insertion of completions.

For example, inserting `%{<newline>}` for a command-completed token
(such as the commands for a hook) would still trigger completion right
after the `}` and that completion would get auto-inserted **replacing**
that closing `}`.
2021-05-18 20:50:56 +10:00
Maxime Coste
47c0d20388 Request xterm 'modifyOtherKeys' mode to opt-in CSI u key reporting
Various terminal emulators now support this `CSI > 4 ; 1 m` sequence
to enable CSI u style reporting, opt into it on startup.

Closes #4103
2021-05-02 17:06:43 +10:00
Maxime Coste
db9ef82398 Rework session directory logic
Do not use a shared kakoune/ directory for all users to avoid the
complexity of having to set the sticky bit on that dir, resolve the
session directoy only once by using a static variable and an
immediately evaluated lambda.

This fixes an annoyance whenver using `su` and having Kakoune refuse
to start due to XDG_RUNTIME_DIR still being set.
2021-05-01 15:29:50 +10:00
Maxime Coste
2288be3257 Merge remote-tracking branch 'markus-oberhumer/ux-improve-prompt' 2021-05-01 14:37:54 +10:00
Markus F.X.J. Oberhumer
e57fe4fb90 Improve prompt handling
As a long time vi user I find it highly irritating that
you cannot backspace out of the command prompt.
2021-04-30 19:42:08 +02:00
Tim Allen
f78adeda49 src: Fix mouse modifier support in the ncurses UI.
For historical reasons, mouse events represent keyboard modifiers as a bitfield,
but keyboard events represent modifiers as a bitfield-plus-one. For example, a
mouse event with an Alt modifier will use the value 4, but a keyboard event will
use the value 5.

Previously, I refactored the parse_mask() helper to do the subtraction itself,
instead of requiring the caller to do it. This made keyboard-event decoding much
cleaner, but I didn't realise it broke mouse-event decoding. Now the subtraction
is done only for keyboard events.

Fixes #4176.
2021-04-30 14:48:37 +10:00
Maxime Coste
970a0b8997 Merge remote-tracking branch 'markus-oberhumer/ux-debug-buffer' 2021-04-28 08:11:57 +10:00
Maxime Coste
7394307a3d Merge remote-tracking branch 'nojhan/feat_padding-options' 2021-04-28 08:11:15 +10:00
nojhan
a9d33a8796 fix ncurses' padding option
- Use less iterations when drawing padding fill with multiple characters.
- Use column_length to handle null-width character as no character.
2021-04-27 15:27:57 +02:00
Markus F.X.J. Oberhumer
27d6361210 Improve UX: better error message about debug buffer on startup errors
Minuscule things like these can make a huge difference if you are
a first time user of a new text editor.
2021-04-27 12:52:10 +02:00
Ben Judd
272b70298e elif over "else if" 2021-04-19 11:53:19 -07:00
Maxime Coste
f7be47fb95 Merge remote-tracking branch 'Icantjuddle/fix_deprexated_mallinfo_call' 2021-04-19 20:56:55 +10:00
Maxime Coste
1683f7f5f5 Merge remote-tracking branch 'Icantjuddle/add_hash_unit_test' 2021-04-19 20:54:43 +10:00
Ben Judd
b09eb5e010 Comments 2021-04-18 16:28:11 -07:00
Ben Judd
56875088d4 comments 2021-04-18 16:06:05 -07:00
Maxime Coste
94c0162da7 Merge remote-tracking branch 'Screwtapello/support-keypad-keys' 2021-04-18 17:06:53 +10:00
Maxime Coste
b34bd239fa Merge remote-tracking branch 'alexherbo2/fix-edit-readonly' 2021-04-18 16:29:44 +10:00
Ben Judd
db3203fe59 mallinfo is deprecated in favor of mallinfo2 2021-04-17 13:49:21 -07:00
Ben Judd
161ca6d4d1 hash unit tests. 2021-04-17 13:19:35 -07:00
Taupiqueur
aa6ec5987c Fix edit -readonly command not setting readonly option 2021-04-14 02:36:25 +02:00
Tw
41833d7b7d fix line completion with prefix
There's a bug in current line completion, fix it.

Signed-off-by: Tw <tw19881113@gmail.com>
2021-04-11 11:54:48 +08:00
nojhan
daa63ba879 [feat] add ui_options: padding_char & padding_fill
In some cases, it may be difficult to easily spot the area out of the buffer
(bad color scheme, small font, superimposed windows).

This patch adds two ncurses ui_options to bypass this problem:
- `ncurses_padding_char`, to configure the padding character,
- `ncurses_padding_fill`, to indicate whether to fill the padding line
  (or to display a single character).

The default config is the legacy one (a single "~").
2021-04-05 20:21:48 +02:00
nojhan
ba344be51f fix show-whitespace: add missing NNBSP character
- Add the Narrow No-Break SPace (0x202F, NNBSP) to the list of handled
  spaces in the show-whitespace highlighter.
- Do not add an aditional option, just handle it like NBSP, with the same highlight character.
2021-03-31 15:28:23 +02:00
Maxime Coste
4be6df9d02 Parse more data at each fifo buffer read 2021-03-31 17:19:20 +11:00
Maxime Coste
da9a196fa0 Profile individual command runtime
Different approach than the one suggested by eraserhd

Closes $4095
2021-03-31 17:17:22 +11:00
Maxime Coste
d1e19727ff Tweak completion quoting behaviour once again
Quote by wrapping in quotes if we are replacing the whole token,
using backspaces if the completion only adds to it.

This ensure that the inserted completion will be correctly parsed
once validated.

Fixes #4121
2021-03-31 17:15:31 +11:00
Tim Allen
3aaf32f48f src/ncurses_ui: Teach Kakoune about all the numeric keypad keys.
Kakoune now knows about all the keypad keys listed in:

https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-PC-Style-Function-Keys
https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-VT220-Style-Function-Keys

The VT220-style encodings are used to for modified numeric keys when NumLock is
off. For example, consider the 8/Up key:

| Modifiers       | Sequence    | Notes             |
|-----------------|-------------|-------------------|
| Unmodified      | CSI A       | Ordinary up arrow |
| Shift           | SS3 2 x     | Shift-8           |
| NumLock         | 8           | Ordinary 8        |
| Shift + NumLock | CSI 1 ; 2 A | Shift-Up          |

Note that even though the terminal distinguishes between keypad and regular keys,
Kakoune maps keypad keys onto regular keys - keypad Enter is still <ret>, it
just supports more modifiers than the regular Enter key.
2021-03-26 15:43:42 +11:00
Tim Allen
f7c1702965 src/ncurses_ui: move the parse_mask() helper outside parse_csi().
It's useful for parsing modifier masks in all kinds of sequences, not just CSI
sequences. Also, since the modifier mask always has "1" as "no modifiers",
do the subtraction inside parse_mask() instead of when calling it.
2021-03-26 15:17:41 +11:00
hss
49f5917125 Rename separator-cursor to cursor-separator 2021-03-22 19:38:33 -04:00
hss
3e539c963e Don't use optionals for storing active separator string 2021-03-21 19:52:19 -04:00
hss
07e2b03c11 Only use separator-cursor for the first line number in a wrapped line 2021-03-20 21:53:31 -04:00
hss
73ecd3356f Compare column_length of line-number separators 2021-03-20 21:33:53 -04:00
hss
8df2bb8bd5 Use optionals more wisely in line-numbers 2021-03-20 02:48:33 -04:00
hss
f16783b0a8 line-number: Add option to use a different separator on the current line 2021-03-19 23:23:01 -04:00
Maxime Coste
545db22ae4 Fix typo in file.cc 2021-03-12 09:10:19 +11:00
Maxime Coste
8e463e63ea Do not use replace write method when writing to a non-regular file
Fixes #4098
2021-03-11 20:48:44 +11:00
Maxime Coste
d5282735f2 Always redraw after getting some user input 2021-03-11 09:08:35 +11:00
Maxime Coste
4a59018dcd Do not select on non-urgent fd when handling only urgent events
This avoids 100% CPU usage when we have pending fifo input while running
a shell process, as we will not end-up busy looping in pselect but not
reading the available data due to being only processing urgent events.
2021-03-11 09:02:02 +11:00
Maxime Coste
0b234f7f67 Merge remote-tracking branch 'eraserhd/fifo-performance-fixes' 2021-03-11 07:49:20 +11:00
Jason Felice
d3824f3211 Use inplace_merge() for ranges 2021-03-09 10:13:31 -05:00
Jason Felice
c9be6730f6 Binary search for first range to change 2021-03-08 16:55:43 -05:00
Maxime Coste
f6c8ebc4d0 Refactor pipe reader/writer 2021-03-04 20:59:15 +11:00
Maxime Coste
da80a8cf6a Raise ThreadedVM initial thread capacity to 16
Threads are 4 bytes, an initial capacity of 4 led to allocating 16
bytes, raising that to 64 bytes seems quite reasonable.
2021-03-03 20:51:24 +11:00
Maxime Coste
f4a639e078 Re-use the Regex VM when completing filenames to reduce allocations
By re-using the VM we avoid re-allocating the threads and saves
buffers over and over again. We can just re-use the ones from the
previous matching.
2021-03-03 20:33:02 +11:00
Maxime Coste
eb292f1f00 Re-tweak command name completion behaviour
It turns out the fix for #4061 was breaking auto-selection with
space of command names.
2021-03-02 20:20:58 +11:00
Jacob Collins
9dfab2f1fb Follow ECMA specification for regex whitespace
Changes the behaviour of the \s and \h character classes to include
all WhiteSpace and LineTerminator characters defined in the ECMA
specification.
 - <https://262.ecma-international.org/11.0/#sec-white-space>
 - <https://262.ecma-international.org/11.0/#sec-line-terminators>
 - <https://262.ecma-international.org/11.0/#sec-characterclassescape>

Fixes #4034
2021-02-25 11:03:18 -05:00
Maxime Coste
7c321e121d Tweak requoting behaviour
Only requote when completion is replacing the whole token

Do not requote command names as they should not require it, tag
them as quoted.

Fixes #4061
2021-02-25 21:04:06 +11:00
Maxime Coste
978dfe4bdf Fix splitting display line in front of a replaced range
When a replaced buffer range atom was starting exactly at the
location we wanted to split onto the code would split *after*
that atom instead of before.

Fixes #4052
2021-02-16 12:35:25 +11:00
Maxime Coste
fa3aa3c1a3 Add + key to duplicate selections and <a-+> to merge overlapping ones
This is an experiment and might get reverted if overlapping selections
prove too cumbersome.

Fixes #4041
2021-02-15 09:01:14 +11:00
Maxime Coste
e6905552cf Fix CSI u support for escape key 2021-02-11 20:23:08 +11:00
Maxime Coste
26cf5cd1dc Fix resizing strings to -1 length
Fixes #4042
2021-02-01 20:16:30 +11:00
Maxime Coste
7751c7e188 Check XDG_RUNTIME_DIR owner before creating session directory
This avoids an issue when using `su` and running Kakoune which creates
a session directory owned by root and prevents the user from creating
more sessions.
2021-01-26 09:28:24 +11:00
Maxime Coste
74fc52b3de Write to stderr if execve fails
This should be rare but should not happen silently, this way it will
show in the parent process debug buffer.
2021-01-22 17:22:15 +11:00
Maxime Coste
04a64e6e29 Fix performance issue in show-matching highlighter on big buffers
Stop searching for the matching character when getting out of view
instead of going until the buffer edge.
2021-01-22 17:21:59 +11:00
Maxime Coste
0fd5a9d995 Slight code cleanup in generate_env 2021-01-22 17:21:59 +11:00
Tim Allen
a7ed1f03fb Distinguish <c-h> and Backspace on terminals where that is possible.
Different terminals send different codes to indicate backspace, usually one of
\x08 or \x7f, so Kakoune blindly treated both as backspace. However, a given
terminal is only likely to use one of those, and mnemonic control codes like
<c-h> are a precious resource so we should endeavour to keep backspace and
<c-h> separate when we can. Luckily, termios tells us what code our terminal is
currently using, and Kakoune already reads the information at startup, so we can
just use that information.

Thanks to @krobelus for figuring out the C++ syntax required.

Fixes #3863.
2021-01-15 18:49:53 +11:00
Maxime Coste
df7b33bc7b Merge branch 'master' of http://github.com/Woolworths/kakoune 2021-01-04 09:50:45 +11:00
Maxime Coste
49d1d4666d Merge remote-tracking branch 'cole-h/trim-only-one-newline' 2021-01-04 09:45:53 +11:00
Cole Helbling
7cde146807
command_manager: only remove last eol in %sh{} expansions
This makes it possible to keep significant EOL in shell expansions (e.g.
for use with clipboard helpers).
2021-01-02 19:53:40 -08:00
Maxime Coste
f1e45579a6 Merge remote-tracking branch 'jimt/master' 2021-01-03 11:15:11 +11:00
Maxime Coste
a0c23ccb72 Add missing limits includes
Fixes #4003
2021-01-03 10:58:09 +11:00
Jim Tittsler
a7fb4c042a Fix message typo 2021-01-01 15:15:27 +09:00
Maxime Coste
958a943121 Avoid non-POSIX ln -r switch
Fixes #3985
2020-12-25 12:07:13 +11:00
Cole Helbling
266e388c6b
commands: add "registers" subcommand to :debug
This prints all non-empty registers and their value(s) to the `*debug*`
buffer.
2020-12-23 14:22:44 -08:00
Jean Abed
650a7143be remove unused variable changes_tracker 2020-12-22 21:31:11 +11:00
Maxime Coste
e50b5fe137 Add Timer::disable() to be more explicit than set_next_date(TimePoint::max()) 2020-12-20 11:32:15 +11:00
Maxime Coste
74c337df5d Add a libexec/ directory and use it to find the kak command
Add that libexec directory to the PATH instead of the current kak
binary directory to avoid impacting other commands.

The libexec directory currently only contains a symlink back to
the Kakoune binary.
2020-12-09 09:13:45 +11:00
Maxime Coste
489404befa Merge remote-tracking branch 'occivink/no-sel-remaining-alt-space' 2020-12-05 08:47:04 +11:00
Olivier Perret
f2fb5a3214 Throw no_selections_remaining when using <a-space>
This makes it possible to use the mechanism introduced by 91386a53
2020-12-03 21:42:14 +01:00
Maxime Coste
95606d2336 Avoid potential use after free of the mode name
This can be an issue with NextKey that now does not have a static
mode name.
2020-12-01 21:56:55 +11:00
Maxime Coste
586f79c30d Ensure InputModes are kept alive during their idle logic
Various paths can run arbitrary commands (callbacks, hooks) which
could lead to the InputMode being popped off the mode stack, but
contrarily to the on_key method, we had no guarantees to be kept
alive.

Add a keep_alive RefPtr to this to ensure the mode survives till
the end.

Fixes #3915
2020-12-01 20:00:38 +11:00
Maxime Coste
a8d43ce6ce Merge remote-tracking branch 'AndrewVos/ignore-indent-on-line-completion' 2020-11-22 16:52:37 +11:00
Andrew Vos
f3f3f80624
Ignore indent when completing lines
When doing line completion, we previously used to not complete the line
if it had different indent to the potential completion.

This commit changes the behaviour to ignore indentation when completing lines.
2020-11-20 20:00:46 +00:00
Maxime Coste
161aa918df Restore auto-select on return, add a flag to disable that for commands
Fixes #3849 Again
2020-11-18 19:56:05 +11:00
Maxime Coste
14dbe63b4f Revert "Auto-insert prompt menu completions on <ret> if any text was entered"
Unfortunately this breaks some pretty useful use cases, such as inserting a
command ending with a new-line (as it now leads to an addtional command being
auto-completed on validation)

This reverts commit aab0be529f.
2020-11-17 07:03:14 +11:00
Maxime Coste
b09a0f5779 Merge remote-tracking branch '6112/msys2-wcwidth' into master 2020-11-11 07:36:44 +11:00
Maxime Coste
3ae2a5c2f6 Fix performance issue with word completion
When pasting many words with <a-p> we can end-up with a huge
concatenated word and many selections, the previous code ended
up iterating from each selection cursor to that word start and
end to find the word under the cursor.

This could lead to performance issue as each selection would
trigger iteration on that huge word. This is unnecessary as
word completion has a word length limit, so we now take it into
account to avoid iterating to far from the cursor position.
2020-11-07 10:42:51 +11:00
Maxime Coste
b1745ee8d3 Fix performance issue when pasting many selection
The previous code was advancing from the general insertion point
for all selection, instead of iterating only once from insertion
point until the end of inserted text.
2020-11-07 10:14:18 +11:00
Maxime Coste
94ac3084e1 Handle reading from stdin returning 0
0 means stdin was closed, this is quite unexpected as we would usually
get a SIGHUP, but it looks like in some rare case this happens and
it leads to an infinite loop trying to handle stdin events (as it
will always be readable from now on).

Fixes #3557
2020-11-02 22:54:54 +11:00
Maxime Coste
aab0be529f Auto-insert prompt menu completions on <ret> if any text was entered
Previously we would only auto-insert if the current token had some
text, but this breaks auto-selection of the first match.

Fixes #3849
2020-11-01 10:32:44 +11:00
Tim Allen
c039879c82 src/ncurses_ui.cc: Teach Kakoune about ctrl-symbol keys.
Previously, Kakoune only handled ctrl-codes less than 27, representing them as
lower-case ASCII codes. For regular keys like <c-a>, that worked fine. However,
NUL became the unorthodox <c-`> and other ctrl-symbols (<c-\>, <c-]>, <c-_>)
weren't supported at all.

Now NUL is rendered as the more comfortable <c-space>, and the other ctrl-symbol
codes are properly decoded.

Fixes #2553.
2020-10-31 01:20:49 +11:00
Maxime Coste
90043e7df0 Replace write -atomic with write -method <method>
`-atomic` becomes `-method replace` and `-method overwrite` is now
supported explicitely instead of only available through the
writemethod option.

Fixes #3827
2020-10-27 20:20:18 +11:00
Maxime Coste
9a5cf2fc9f Support explicit register for :, |, ! and $ commands
Giving an explicit register uses its content for the default value
to use if the user does not enter anything. This enables:

`set-register a %{commands}; execute-keys '"a:<ret>'`
`set-register a %{shell script}; execute-keys '"a|<ret>'`
...

This provides a nice way to avoid the need to escape keys to use
those normal mode commands.

Fixes #3825
2020-10-20 21:56:51 +11:00
Maxime Coste
354cfd3b8f Disable auto-insertion of menu completion when no text was entered
This avoids a frustrating behaviour where Kakoune autoinserts the first
command name when hitting <space> after a ; in a command line. It also
fixes the empty prompt case that was auto-completed instead of executing
the default command.
2020-10-20 21:43:34 +11:00
Maxime Coste
4d22b405d6 Notify prompt completion changes in startup message 2020-10-20 21:05:26 +11:00
Nicolas Ouellet-payeur
4a59db1bd1 Fix wcwidth() compile error with MSYS2
We try to detect when compiling under Cygwin, so we can set the
_XOPEN_SOURCE define which lets us use wcwidth(). We look for the
string "CYGWIN" in the uname, which looks like:

    CYGWIN_NT-10.0

MSYS2 is also based on Cygwin, so all of the above should still work.
However, we detect Cygwin by looking for the string "CYGWIN" in the
uname. In MSYS2, the uname looks like:

    MSYS_NT-10.0-18362

This patch looks for the string "_NT" instead of the string "CYGWIN"
in the uname, since it's common to both environments. This fixes a
compilation error on MSYS2.
2020-10-19 09:36:25 -04:00
Maxime Coste
65587d1eee Auto-insert best completion on space for menu completions
The menu flag signifies that only the completions are valid arguments,
hence it makes sense to auto insert the best one on space.

Because full match is always considered the best match in completion
ranking, this should always have a reasonable behaviour.

This makes it harder to enter a hidden command, but completion can
always be disabled via <c-o> or by quoting in those rare cases.
2020-10-19 21:43:03 +11:00
Maxime Coste
2cd323b314 Allow quiting last client with unsaved buffer in daemon mode
Because the server will out-live that client's disconnection it
is still ok to have modified buffers, the server will complain
on `kill`.

Fixes #3801
2020-10-19 20:39:25 +11:00
Maxime Coste
97e88b6087 Remove the rename-client's nc alias
Closes #3789
2020-10-19 20:30:33 +11:00
Maxime Coste
def37a6ff4 Merge remote-tracking branch 'm-kru/vhdl' into master 2020-10-19 20:06:25 +11:00
Maxime Coste
f549190a98 Add support for explicit completion in prompt mode 2020-10-19 19:36:58 +11:00
Maxime Coste
f6c67f7831 Code cleanup in insert completer 2020-10-12 12:41:52 +11:00
Maxime Coste
246a32797a Fix region regexes incorrectly matching ^$ at end of line
Because no flags were set for regex matching, the regex engine was
assuming that the subject string past-the-end matched a end-of-line.
As the subject string already ended with a \n character, the regex
engine processing of the "past-the-end" position would match '^$'
as ^ matched past the existing \n and $ matched the assumed
end-of-line.

Fixes #3799
2020-10-12 12:41:21 +11:00
Maxime Coste
6a9b34e5c8 Merge branch 'add-illumos' of http://github.com/luka-devnull/kakoune into master 2020-09-30 19:38:52 +10:00
Maxime Coste
5d17e1132f Ensure that the capture group actually matched in select_matches
We were creating selections from default constructed iterators,
which happened to have 0,0 coords and led to out-of-order selection
lists.

Fixes #3757
2020-09-22 21:14:40 +10:00
luka null
1296922d66 Add illumos/Solaris support 2020-09-18 05:22:25 -05:00
Maxime Coste
ec3d7c3104 Add support for removing from options
`set -remove ...` will remove from the current option value, substracting
from int, removing elements from vectors and maps.
2020-09-09 21:00:30 +10:00
Maxime Coste
e0d2602e6a Kakoune 2020.09.01 2020-09-01 20:37:20 +10:00
Maxime Coste
1fd1a0052d Trigger InsertCompletionHide hook when switching to explicit completion
Previously we would just bypass that hook making it impossible to
act on the inserted text when triggering an explicit completion after
inserting text from the previous completer.
2020-08-30 10:35:15 +10:00
Maxime Coste
f56c1107e0 Fix face attributes to string conversion with F shorthand
Previously a `F` attribute would end up being converted to Ffga which
is confusing as F *means* fga.
2020-08-30 10:12:21 +10:00
Maxime Coste
1020438462 Clear inserted_ranges after updating insert completions candidates
They were getting out-of-sync with the stored timestamp, leading
to invalid ranges being computed and crashes.

Fixes #3666
Fixes #3571
2020-08-18 20:35:48 +10:00
Maxime Coste
40aa687601 Do not fork in daemon mode
Leave that to the shell or external service management tools

Fixes #3618
2020-08-17 19:56:00 +10:00
Maxime Coste
669048f458 Rename DefinedHighlighters to SharedHighlighters
Matches the user facing name and seems more correct.
2020-08-08 11:19:02 +10:00
Maxime Coste
5aa657b150 Merge remote-tracking branch 'eraserhd/runtime-var' 2020-08-06 20:15:38 +10:00
Jason Felice
a52822d965 Override runtime by setting $KAKOUNE_RUNTIME 2020-08-04 11:48:34 -04:00
Maxime Coste
2c437cfa02 Kakoune 2020.08.04 startup info 2020-08-04 19:40:43 +10:00
Johannes Altmanninger
266fe6f659 Support count argument for [s and ]s
Part of #795
2020-08-02 11:30:14 +02:00
Johannes Altmanninger
98a1afcab0 Support count argument for [p and ]p
Part of #795
2020-08-02 11:30:14 +02:00
Maxime Coste
39ad6a5bda Do not flush input buffer in UI creation
Fixes #3635
2020-08-02 16:19:13 +10:00
Maxime Coste
e3f3297334 Fix alpha of merged faces 2020-07-31 15:45:52 +10:00
Maxime Coste
c2516f02f6 Do not trigger RegisterModified hooks on register about to be restored
This greatly reduces the amount of hooks triggered.
2020-07-21 20:27:42 +10:00
Maxime Coste
47ba36c66e Add a RegisterModified hook
This one has been a long time coming, I am still concerned this could
impact performance a lot. This hook does *not* trigger for capture
registers (0-9) or any other dynamic registers (that are not writable).

Fixes #859
2020-07-19 12:56:55 +10:00
Maxime Coste
5df8073c3c Code style tweaks 2020-07-19 12:54:41 +10:00
Maxime Coste
60dda1a597 Handle SIGTERM as a graceful exit, similar to the :kill! command
Do not backup modified files, go through graceful destruction of
singletons.

Fixes #3528
2020-07-07 20:41:40 +10:00
Maxime Coste
8abf18209e Fix selections getting unsorted on scroll
Fixes #3478
2020-07-05 10:13:57 +10:00
Maxime Coste
f2cc7bc891 Add User hook support 2020-07-04 13:48:27 +10:00
Igor Böhm
d79b005323 Fix 'error: non-constant-expression cannot be narrowed...'
ncurses_ui.cc:759:59: error: non-constant-expression cannot be narrowed from type 'unsigned int' to 'Key::MouseButton' in initializer list [-Wc++11-narrowing]
                return mouse_button(mod, Key::MouseButton{code}, coord, c == 'm');
                                                          ^~~~
2020-06-28 23:32:12 +02:00
Maxime Coste
d3374e7e5f Refactor mouse press/release handling to support 3 buttons
Change button to be an additional parameter instead of having separate
events for left/right buttons.

Fixes #3471
2020-06-28 19:48:55 +10:00
Maxime Coste
fc3e5ea419 Refactor how InsetCompletionHide hook parameter is computed
Keep track of inserted ranges instead of trying to re-derive them.

Fixes #3556
2020-06-27 13:33:50 +10:00
Maxime Coste
f5127f8b22 Merge remote-tracking branch 'lenormf/key-percent' 2020-06-25 20:58:26 +10:00
Maxime Coste
d4487d3bfc A module is not loaded after failing during load
distinguish the loading from loaded state, detect recursive loading.
2020-06-16 19:08:10 +10:00
Maxime Coste
f75d49e9ef Do not include non-primitive option value in *SetOption hook filter
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.
2020-06-09 21:38:47 +10:00
Maxime Coste
66f15cf4ad Fix select wiping captures
It turns out `v = std::move(v)` with v a std::vector is not a no-op,
it clears the vector.
2020-06-07 14:12:54 +10:00
Frank LENORMAND
24c5169400 src: Introduce a <percent> named key
Similarly to the <semicolon> key, make it easier to write
`:execute-keys` commands by replacing <percent> with `%`.

Highlighters can keep escaping the sign when regular expressions are
not quoted, but built-in scripts that use `%` as an editing primitive
have been modified to use the named key, for clarity.
2020-06-03 15:42:38 +03:00
Maxime Coste
0fba373d1d Replace some tag dispatch with if constexpr 2020-06-01 20:46:48 +10:00
Maxime Coste
ec4980df34 Merge commit 'krobelus/05-highlight-replace-ranges-crash^' 2020-05-30 09:18:35 +10:00
Maxime Coste
08e0b663f7 Fix unintended interpretation of ranges length syntax
Ranges specified with a +<length> were inconsistent, with +0 meaning
an empty range, while +1 meant a two character long range (first character
+ the following one). Change that to mean a single character.

Fixes #3479
2020-05-29 12:25:57 +10:00
Maxime Coste
63371da8aa Avoid to_remove vector in select helper function
Remove the need to allocate anything when removing selections.
2020-05-29 12:00:02 +10:00
Maxime Coste
94f33bb638 Add a range based remove_if overload 2020-05-29 11:59:03 +10:00
Johannes Altmanninger
13a6aa2fbd refactor: remove extra semicolons 2020-05-28 20:04:32 +02:00
Maxime Coste
109abbeed4 Fix invalid regions with begin > end being generated
Fixes #3495
2020-05-28 20:58:46 +10:00
Maxime Coste
aad20f6576 Merge remote-tracking branch 'krobelus/paragraph-begin-oob' 2020-05-19 19:17:03 +10:00
Maxime Coste
af175d2e7e Output debug memory stats in a nice table 2020-05-19 17:16:37 +10:00
Johannes Altmanninger
fc63eef695 Fix crash when selecting previous paragraph at buffer begin
Fixes #3489

When there are multiple empty lines between a paragraph and the cursor
(C in the example below), <a-[>p skips over one of them. Prevent the
check for the extra newline from going out of bounds.

```
a paragraph

C	after <a-[>p, the first two lines will be selected
```
2020-05-17 14:15:48 +02:00
Johannes Altmanninger
08509cb408 Refactor: use is_eol() as elsewhere in this function 2020-05-17 14:11:45 +02:00
Maxime Coste
5fd548d5cf Fix use of unportable MSG_CMSG_CLOEXEC 2020-05-17 21:28:40 +10:00
Maxime Coste
151eb3299d Fix CSI u parsing of some special keys 2020-05-12 08:50:27 +10:00
Maxime Coste
60154300f9 Support piping data to client stdin
Pass the client stdin fd to the server and open a fifo buffer
from it.

Fixes #3394
2020-05-10 19:30:13 +10:00
Maxime Coste
2104af0771 Fix select_sentence going past the end of the buffer
Fixes #3472
2020-05-10 15:13:15 +10:00
Maxime Coste
f4efde7e08 Merge remote-tracking branch 'krobelus/kak-c-initial-buffer-pos' 2020-05-03 13:20:44 +10:00
Maxime Coste
2fca4e5643 Fix traling whitespaces 2020-05-02 13:02:10 +10:00
Maxime Coste
ccecd5bd8e Add support for alpha channel in colors
This makes it easier to define faces that lighten/darken whatever
they apply on.
2020-05-02 12:57:36 +10:00
Johannes Altmanninger
c010f14a7c Fix +line:col initial buffer position when connecting to session
A command line argument like +line[:column] can be used to specify a
target line and column for the first file.

This did not work when connecting to a session, because the client
opens its file parameter with `-e "edit file1; edit file2"` which is
executed after the initial buffer position is set. Work around this by
passing the position to the first file and avoid moving the cursor
in unrelated files.

Reproduce:

	kak -s foo
	kak -c foo +4:11 README.asciidoc
2020-05-01 10:05:37 +02:00
Maxime Coste
ceff2286af Fix clang compilation 2020-04-27 17:41:09 +10:00
Maxime Coste
35e8e12b12 Merge branch 'netbsd-1' of https://github.com/krytarowski/kakoune 2020-04-27 17:40:33 +10:00
Maxime Coste
954373d3cf Support multi-line replace-ranges
This likely has lots of rough edges, but should be an initial proof
of concept to support folding.
2020-04-27 17:39:21 +10:00
Maxime Coste
cb119251bc Do not replace partially selected ranges in replace-ranges highlighter
Partially selected ranges should not be replaced to make it possible
to see what is actually selected.
2020-04-27 17:39:21 +10:00
Maxime Coste
0fdfbdfd15 Fix highlighting empty ranges at end of line and begin of line 2020-04-27 14:31:26 +10:00
Maxime Coste
fde4c60dd9 Factor option based highlighters 2020-04-27 14:31:26 +10:00
Kamil Rytarowski
22931bdc1f Fix get_kak_binary_path() for NetBSD
Pass correct mib[] to sysctl(3).
2020-04-23 03:24:24 +02:00
Maxime Coste
a33b938652 Fix issue with select object and empty matches 2020-04-21 13:21:35 +10:00
Maxime Coste
562ee6143a Parse ascii newline/tab/escape as special keys instead of control keys
Fixes #3439
2020-04-13 12:44:15 +10:00
Maxime Coste
8000cd092f Fix internal command naming 2020-04-13 12:24:45 +10:00
Maxime Coste
91e3a58a3a Merge remote-tracking branch 'lenormf/fix-3410' 2020-04-13 11:09:08 +10:00
Maxime Coste
0fb479f0c2 Merge branch 'netbsd' of http://github.com/niacat/kakoune 2020-04-09 07:42:53 +10:00
Maxime Coste
f7a2ecfacb Support empty ranges in replace-ranges highlighter 2020-04-06 11:23:47 +10:00
Maxime Coste
c585107ab5 Add -override support to add-highlighter
This allow replacing a highlighter in place, not loosing its current
position in its parent.

Fixes #3436
2020-03-30 21:04:01 +11:00
Maxime Coste
b42885ef71 Fix empty strings not being zero terminated 2020-03-29 20:28:56 +11:00
Maxime Coste
8f30e37507 Untie focus reporting and mouse handling 2020-03-27 07:54:21 +11:00
nia
7d4a83a449 || -> or for consistency 2020-03-22 11:00:27 +00:00
nia
28982aae92 Fix build on NetBSD 2020-03-22 10:49:06 +00:00
Maxime Coste
3c265acd6c Remove posB from information given by the diff algorithm
posB is always the sum of previous add len and previous keep len,
so very easy to keep track of.
2020-03-20 20:27:50 +11:00
Maxime Coste
401ef84a4b Remove uses of reverse_iterator in diff implementation 2020-03-20 20:24:42 +11:00
Frank LENORMAND
07d702e419 src: Fix a compilation bug with g++-8
The Ubuntu Disco distribution comes with `g++` v8 installed by default,
which is not able to deduce the return type of a particular call to
`transform()`.

This commit explicitly declares the return type to mitigate that
problem, and allow the file to compile.

Fixes #3410
2020-03-17 09:00:29 +03:00
Maxime Coste
1b28a19058 Merge remote-tracking branch 'Anfid/scroll-test' 2020-03-15 12:32:54 +11:00
Maxime Coste
09375edf54 Merge remote-tracking branch 'occivink/arrange-buffers' 2020-03-15 12:18:04 +11:00
Maxime Coste
7545fa58ae Fix invalid access to deleted line when updating insert completion
The computation of the completion end position was taking place too
early, before we checked if the buffer did get modified.

Fixes #3349
2020-03-14 13:49:52 +11:00
Maxime Coste
31caae20eb Allow reading from fifo in readonly buffers
readonly is supposed to prevent the user from modifying the buffer
and it can be useful to generate a readonly fifo buffer.

Fixes #3398
2020-03-14 12:58:22 +11:00
Maxime Coste
8c2ef4965a Merge remote-tracking branch 'lenormf/fix-completion-escaping' 2020-03-13 08:08:17 +11:00
Maxime Coste
83a17227a5 Merge remote-tracking branch 'lenormf/fix-Makefile-compiler-string' 2020-03-13 08:06:42 +11:00
Maxime Coste
a53d501f7b Merge remote-tracking branch 'lenormf/fix-3399' 2020-03-13 08:05:04 +11:00
Maxime Coste
149da2064d Handle invalid utf8 in command line a bit better
Reduce the amount of decoding by working directly on
bytes.

Fixes #3388
2020-03-13 08:02:58 +11:00
Frank LENORMAND
7b28e68d6c src: Don't escape completion candidates with \
Completion candidates are currently escaped with a backslash `\`
character, which leads to ugly interactive commands on the prompt,
especially when they contain space characters.

This commit makes completion candidates be escaped by simple quoting.

Examples:

    candidate\ with\ spaces
    \%opt{foo}
    \"dquote
    \'quote

become:

    'candidate with spaces'
    '%opt{foo}'
    '"dquote'
    '''quote'
2020-03-12 22:24:44 +03:00
Frank LENORMAND
789caf89a3 rc Makefile: Fix the predicate to detect g++
Some distributions replace the expected "GCC" tag with their own name
and version, causing the Makefile not to include a compiler flag.
2020-03-12 17:04:34 +03:00
Joachim Henke
3881dc1e7a restore F1 key handling 2020-03-04 09:06:46 +01:00
Maxime Coste
610be9ac20 Fix invalid memory access in unit-tests 2020-03-04 12:08:16 +11:00
Maxime Coste
e3a5856284 Only replace chars >= 0 in fix_atom_text
If char is signed, the test was invalid

Fixes #3389
2020-03-03 20:16:31 +11:00
Maxime Coste
7a9292be58 Merge remote-tracking branch '6112/clippy-delay' 2020-03-03 07:49:02 +11:00
Maxime Coste
0a66eb9c47 Expand env vars as list of strings
This makes it possible to do :select `%val{selections_decs}` and to
correctly combine $kak_quoted with those.
2020-03-02 20:53:28 +11:00
Nicolas Ouellet-Payeur
10d887583f Make on_next_key_with_autoinfo() respect idle_timeout
The prompt and autocomplete normally wait for `idle_timeout` before showing
suggestions, however commands like `g`, `v`, or the lead-key show Clippy
instantly.

This fixes the issue by making `on_next_key_with_autoinfo()` wait for
`idle_timeout` before displaying suggestions.

Fixes mawww/kakoune#3365
Fixes mawww/kakoune#2066
2020-02-27 10:36:15 -05:00
Maxime Coste
b8eef27e04 Enable terminal application keypad mode 2020-02-26 17:45:52 +11:00
Maxime Coste
af6885c0c9 Control character end at 0x1F 2020-02-26 07:59:05 +11:00
Maxime Coste
df844c6243 Do not replace spaces in prompt text 2020-02-25 20:09:25 +11:00
Olivier Perret
5c116ab850 Add a new 'arrange-buffers' to let users change the order of the buflist 2020-02-24 09:41:46 +01:00
Maxime Coste
93a889bd44 Merge remote-tracking branch 'lenormf/complete-register-names' 2020-02-22 08:39:35 +11:00
Maxime Coste
bc8a9d82c3 Use Control Picture codepoints in prompt for all codepoints < 0x22
Fixes #3333
2020-02-22 08:39:21 +11:00
Maxime Coste
3ef8a6160d Small code style tweak in ranges.hh 2020-02-18 19:28:41 +11:00
Maxime Coste
60782b3dc9 Make diff implementation able to work on different iterator types 2020-02-18 19:26:01 +11:00
Maxime Coste
16e814d99e Merge remote-tracking branch 'lenormf/fix-makefile' 2020-02-16 10:40:45 +11:00
Maxime Coste
4438895cd5 Merge remote-tracking branch 'lenormf/startup_info-no_kakrc' 2020-02-16 10:40:12 +11:00
Maxime Coste
df4f71aaed Merge remote-tracking branch 'lenormf/fix-write-switches' 2020-02-15 18:34:18 +11:00
Maxime Coste
940b1b6175 Fix invalid memory access when getting the main entry of empty registers
Fixes #3370
2020-02-15 15:42:08 +11:00
Frank LENORMAND
744336ef2b src: Only remove objects and dependencies for the current target 2020-02-09 19:12:40 +01:00
Frank LENORMAND
e06d61a3e0 src: Allow :write-all to use -atomic, fix usage
It seems that when -atomic was implemented for `:write`, the usage
strings were not updated to reflect that a new flag was available.

The `write-all` command didn't benefit from the implementation of
the new flag despite also writing files - this commit fixes that.
2020-02-09 17:07:47 +01:00
Frank LENORMAND
c0cb5db6a4 src: Let :set-register complete register names
This commit allows the `set-register` command to suggest candidates
named after punctuated registers, similarly to %reg{…} expansions.
2020-02-09 15:31:08 +01:00
Frank LENORMAND
7790e31eb8 src: Don't show startup information when opening a file
Follow-up to #3317
2020-02-07 12:27:54 +01:00
Maxime Coste
e9cf0f23f2 Fix regex start desc computation for case insensitive ranges
Fixes #3345
2020-02-07 07:37:29 +11:00
Maxime Coste
fbd75d91ec Merge remote-tracking branch 'maximbaz/notes-formatting' 2020-02-07 07:02:32 +11:00
Maxime Coste
8b633aa79a Merge remote-tracking branch 'jo-he/master' 2020-02-07 07:01:17 +11:00
Maxime Coste
a105111593 Merge remote-tracking branch 'lenormf/startup_info-no_kakrc' 2020-02-07 07:00:25 +11:00
Frank LENORMAND
1ebab6c269 src: Show the startup information in no-load mode
This commit allows the changelog to be shown at startup even when
the editor was run with the -n flag.
2020-02-05 11:39:23 +01:00
Maxime Coste
e348219fee Merge remote-tracking branch 'omasanori/startup_info_version' 2020-02-05 20:51:17 +11:00
geppettodivacin
39a2ab84fa Use ReverseView to perform fewer allocations
The first attempt at a bug fix for @ symbols in selection buffer names
worked, but it was very inefficient. In particular, it allocated three
different vectors, and we really only needed the correct elements.
Manipulating iterators to give us the right slices of the existing
vector is far more efficient.

By reversing the original content and taking the last two, we're able to
get the number of selections and main selection without too much hassle.
The buffer name is everything from the start of the content to the
selection count. This gets us through with only one vector allocation.

Credit to @mawww for the optimization idea and for fixing my types.
2020-02-02 22:12:18 -06:00
geppettodivacin
5596b4b2b9 Add support for @ symbols in selection buffer
The selection descriptions use the format
`<buffer>@<timestamp>@<main_index>`. This fails when file paths have `@`
symbols in them: the parser splits on `@` symbols and finds more values
than it expects.

We here modify the behavior to require *at least* two @ symbols, using
the last two for `<timestamp>` and `<main_index>` and leaving the
remaining text for the <buffer>. This should work for any number of `@`
symbols, since `<timestamp>` and `<main_index>` are numbers and should
never contain `@` symbols.
2020-01-26 16:03:03 -06:00
Masanori Ogino
144380de8c Fix version comparison in show_startup_info.
The description of startup_info_version in the manual says "only messages
relating to a Kakoune version greater than this value will be displayed,"
but showed messages relating to the version equal to that value.

This change aligns the code with the manual and makes a workaround that set
startup_info_version next to the original version (ex. 20200117) unnecessary.

Signed-off-by: Masanori Ogino <masanori.ogino@gmail.com>
2020-01-21 14:51:18 +09:00
Joachim Henke
4914029712 fix several control key combinations in st 2020-01-20 12:51:06 +01:00
Maxim Baz
8f350ad5a9
Bring the italic formatting back 2020-01-20 09:46:11 +01:00
Joachim Henke
2deeb9df52 make the Insert key work in st 2020-01-19 16:22:34 +01:00
Maxim Baz
4dce836c5a
Fix version notes formatting 2020-01-16 13:23:13 +01:00
Maxime Coste
9ca479ed40 Kakoune v2020.10.16 2020-01-16 20:52:20 +11:00
Maxime Coste
b85365bff8 Reset SIGHUP handler on NCursesUI destruction
SIGHUP handler could trigger crashes if the EventManager was
already destructed when it was triggered.

Fixes #3288
2020-01-11 17:22:33 +11:00
Maxime Coste
6badd74790 Fix compilation on 32bit platforms
Fixes #3284
2020-01-09 20:13:02 +11:00
Maxime Coste
f808539dea Update inserted range when generating InsertCompletionHide hook param
The buffer might have been mutated in the mean time.

Fixes #3270
2020-01-08 20:33:26 +11:00
Maxime Coste
b37638dda4 Split RegexHighlighters matches per requested buffer ranges
When a region calls the regex highlighter, it is incorrect to share
the regex cache as it means we can get matches that span multiple
regions.

Fixes #3041
2020-01-05 18:58:32 +11:00
Maxime Coste
80ffc4d34f Merge remote-tracking branch 'fsub/rxvt' 2020-01-05 10:03:37 +11:00
Maxime Coste
b6f4985c10 Use markup for startup-info message 2020-01-04 12:12:38 +11:00
Maxime Coste
e6b98744c6 Restore support for line wrapping info boxes
Fixes #3280
2020-01-04 11:41:16 +11:00
Maxime Coste
8b6ed26e8c Few style changes on history exposition code 2020-01-02 22:36:26 +11:00
Maxime Coste
43dc494e5c Merge remote-tracking branch 'eraserhd/history-api' 2020-01-02 21:13:43 +11:00