Commit Graph

9968 Commits

Author SHA1 Message Date
Johannes Altmanninger
fb77f11351 gitignore sanitized binaries 2023-04-24 18:31:00 +02:00
Maxime Coste
a4918f934c Merge remote-tracking branch 'occivink/undo-history-as-plain-list' 2023-04-24 19:20:35 +10:00
Sidharth Kshatriya
7efcb94a5e Fix compile error: Compiler refuses to deduce alias template arguments on Darwin (clang 14.0.3)
input_handler.cc:1476:16: error: alias template 'ConstArrayView' requires template arguments; argument deduction only allowed for class templates
        insert(ConstArrayView{content});
               ^
input_handler.cc:1522:16: error: alias template 'ConstArrayView' requires template arguments; argument deduction only allowed for class templates
        insert(ConstArrayView{str});
               ^
2023-04-22 22:20:29 +05:30
Olivier Perret
e0d33f51b3 Switch undo storage from a tree to a plain list
Whenever a new history node is committed after some undo steps, instead
of creating a new branch in the undo graph, we first append the inverse
modifications starting from the end of the undo list up to the current
position before adding the new node.

For example let's assume that the undo history is A-B-C, that a single undo
has been done (bringing us to state B) and that a new change D is committed.
Instead of creating a new branch starting at B, we add the inverse of C
(noted ^C) at the end, and D afterwards. This results in the undo history
A-B-C-^C-D. Since C-^C collapses to a null change, this is equivalent to
A-B-D but without having lost the C branch of the history.

If a new change is committed while no undo has been done, the new history
node is simply appended to the list, as was the case previously.

This results in a simplification of the user interaction, as two bindings
are now sufficient to walk the entire undo history, as opposed to needing
extra bindings to switch branches whenever they occur.
The <a-u> and <a-U> bindings are now free.

It also simplifies the implementation, as the graph traversal and
branching code are not needed anymore. The parent and child of a node are
now respectively the previous and the next elements in the list, so there
is no need to store their ID as part of the node.
Only the committing of an undo group is slightly more complex, as inverse
history nodes need to be added depending on the current position in the
undo list.

The following article was the initial motivation for this change:
https://github.com/zaboople/klonk/blob/master/TheGURQ.md
2023-04-17 10:25:51 +02:00
Maxime Coste
019fbc5439 Cleanup and speed up test runner
Add a -end-of-line switch to echo command to make it possible
to use `echo -end-of-line -to-file <file>` to collect env-vars
2023-03-14 09:01:13 +11:00
Maxime Coste
1322abef64 Convert \r to \n in bracketed pastes
It seems many terminals emits \r for newlines in bracketed pastes,
manually convert this.
2023-03-14 04:48:11 +11:00
Maxime Coste
cb3512f01e Grow dual thread stack after pushing a thread on the next queue
The previous code was assuming it was fine to push_next without
growing, which used to be the case with the previous implementation
because we always have poped the current thread that we try to push.

However now that we use a ring-buffer, m_next_begin == m_next_end can
either mean full, or empty. We solve this by assuming it means empty
and never allowing the buffer to become full, which means we need
to grow after pushing to next if we get full.

Fixes #4859
2023-03-13 22:45:19 +11:00
Maxime Coste
81787792d0 Fix crash when pasting at buffer end
Fixes #4844
2023-03-13 21:49:45 +11:00
Maxime Coste
86dc4130e1 Merge branch 'fix/hare-comment-insert' of http://github.com/stacyharper/kakoune 2023-03-13 21:38:01 +11:00
Maxime Coste
c8f682f3ad Merge remote-tracking branch 'krobelus/perror-on-chmod-failure' 2023-03-13 21:34:13 +11:00
Maxime Coste
58ead47fb4 Merge remote-tracking branch 'krobelus/tmux' 2023-03-13 21:33:31 +11:00
Maxime Coste
81526e4253 Merge remote-tracking branch 'krobelus/fix-ci' 2023-03-13 21:30:36 +11:00
Maxime Coste
6548846950 Slight refactoring of bracketed paste feature
Handle begin/end paste directly in paste csi, manage paste buffer
out of get_char, filter Key::Invalid earlier.

get_next_key returning Key::Invalid means there was some input but
it could not be represented as a Key. An empty optional means there
was no input at all.
2023-03-13 20:55:31 +11:00
Maxime Coste
f05ab99d4d Merge remote-tracking branch 'krobelus/bracketed-paste' 2023-03-13 20:37:45 +11:00
Johannes Altmanninger
1990a764e3 Make linewise bracketed paste match P behavior
This is experimental. Testing will reveal if this is the desired
behavior.
2023-03-11 16:21:57 +01:00
Johannes Altmanninger
b2cf74bb4a Implement bracketed paste
Text pasted into Kakoune's normal mode is interpreted as command
sequence, which is probably never what the user wants. Text
pasted during insert mode will be inserted fine but may trigger
auto-indentation hooks which is likely not what users want.

Bracketed paste is pair of escape codes sent by terminals that allow
applications to distinguish between pasted text and typed text.

Let's use this feature to always insert pasted text verbatim, skipping
keymap lookup and the InsertChar hook. In future, we could add a
dedicated Paste hook.

We need to make a decision on whether to paste before or after the
selection. I chose "before" because that's what I'm used to.

TerminalUI::set_on_key has

	EventManager::instance().force_signal(0);

I'm not sure if we want the same for TerminalUI::set_on_paste?
I assume it doesn't matter because they are always called in tandem.

Closes #2465
2023-03-11 16:21:57 +01:00
Johannes Altmanninger
ad36585b7a Make TerminalUI::get_next_key() helpers static
The only depend on the TerminalUI object which is a singleton, so we
can make them all static.
2023-03-11 16:21:57 +01:00
Maxime Coste
38077ca826 Merge remote-tracking branch 'potatoalienof13/master' 2023-03-09 21:09:43 +11:00
Maxime Coste
706e5bd215 Merge remote-tracking branch 'potatoalienof13/i-am-bad-at-git' 2023-03-09 21:08:03 +11:00
Johannes Altmanninger
0f55d21970 Add sleep to prevent mouse-during-insert test failure
The macOS CI manges to trigger this race.  When it happens the
"c" inserted by the last command is not seen by the test runner.
Let's fix this by adding yet another sleep.
2023-03-05 17:42:41 +01:00
Johannes Altmanninger
45d2d350f2 Disable trim-front-split-glyph test on platforms with broken Unicode support
AKA macOS.
2023-03-05 17:42:41 +01:00
Johannes Altmanninger
caabd06436 cirrus: fix path to Homebrew clang on macOS
Looks like this changed when they switched to M1.
2023-03-05 17:42:41 +01:00
Johannes Altmanninger
ecae85f8af cirrus: fix installation of gcc 10 on macOS
Cirrus CI switched macOS machines to M1 where "brew install gcc@10"
fails due to architecture mismatch.  I'm not sure if it's possible
to install gcc 10 natively for ARM. Let's work around this by
installing the x86_64 compatibility layer. Apparently we need
to install a x86_64 Homebrew to install x86_64 packages.
2023-03-05 17:42:41 +01:00
Johannes Altmanninger
e52f64229a cirrus: use Clang 11 instead of 10 on Linux
This fixes the CI failure where clang could not find <compare>.
Removing the include would not be enough, there are some other
failures.

Debian Stable ships Clang 11 so this seems accessible enough.
2023-03-05 17:28:37 +01:00
Maxime Coste
1479bf6f08 Merge remote-tracking branch 'inahga/aghani-info-width' 2023-03-01 19:50:53 +11:00
Maxime Coste
0a4c4a5de5 Merge remote-tracking branch 'mujo-hash/master' 2023-03-01 19:50:22 +11:00
Maxime Coste
f25fabdf2e Merge remote-tracking branch 'QiBaobin/master' 2023-03-01 19:49:14 +11:00
Maxime Coste
3b0d91c9c7 Merge remote-tracking branch 'krobelus/complete-using-param-spec' 2023-03-01 19:45:32 +11:00
ioh
894e44fdbf Fix new gcc errors for missing types.
Errors when building with gcc 13:
ranked_match.hh:10:21: error: ‘uint64_t’ does not name a type
   10 | using UsedLetters = uint64_t;
      |                     ^~~~~~~~
2023-02-28 19:36:44 -08:00
ioh
0989df35ed ioh Copyright Waiver
I dedicate any and all copyright interest in this software to the
public domain.  I make this dedication for the benefit of the public at
large and to the detriment of my heirs and successors.  I intend this
dedication to be an overt act of relinquishment in perpetuity of all
present and future rights to this software under copyright law.
2023-02-28 19:36:14 -08:00
Bob Qi
4f0334c476 add zellij-action command 2023-02-26 07:29:39 +08:00
Bob Qi
02bc786fb7 remove the option and provide session name explictly 2023-02-24 12:21:16 +08:00
Bob Qi
f33126c2a9 give up to wrap command into a shell to avoid conflict with connect.kak 2023-02-22 15:57:22 +08:00
Bob Qi
8aa144a548 Bob Qi Copyright Waiver
I dedicate any and all copyright interest in this software to the
public domain.  I make this dedication for the benefit of the public at
large and to the detriment of my heirs and successors.  I intend this
dedication to be an overt act of relinquishment in perpetuity of all
present and future rights to this software under copyright law.
2023-02-22 13:17:04 +08:00
Bob
4ff5de6273 Create zellij.kak 2023-02-22 13:17:04 +08:00
Maxime Coste
fa060c2a17 Fix fatal exception when checking if buffer needs to be reloaded
If, for example, the buffer path now is a directory, MappedFile will
throw on construction. Using a try block to explicitely allow errors
fixes the issue.
2023-02-21 16:59:16 +11:00
Maxime Coste
be49f36205 Only decode current codepoint once per step
Instead of potentially decoding for each thread, always decode as
its only slightly slower than finding next codepoint (which will
be necessary anyway) and pass the codepoint to each thread.
2023-02-19 12:15:33 +11:00
Maxime Coste
2b74cd4b59 Remove instructions from ExecConfig
We can just compute whenever we reset last_step, which does not happen
often and we know `forward` at compile time anyway
2023-02-19 11:46:17 +11:00
Maxime Coste
f115af7a57 Optimize Regex CharacterClass matching
Take advantage of ranges sorting to early out, make the logic
inline.
2023-02-19 11:16:14 +11:00
Johannes Altmanninger
213ea922b1 Complete arguments to "echo -to-file"
Including this here because grandparent parent commit broke completions
for "edit -fifo".
2023-02-17 20:50:58 +01:00
Johannes Altmanninger
9e0502a1ca Do not complete redundant switches 2023-02-17 20:50:58 +01:00
Johannes Altmanninger
64d4d29d43 Use parameter parser to skip switch args in completion
The command line "hook -group xyz " should get scope completions but
it actually gets hook completions because "xyz" is wrongly interpreted
as positional argument.

Fix this by using the parameters parser to compute positional
arguments.

Fixes #4840
2023-02-17 20:50:58 +01:00
Ameer Ghani
6acc18373d Add option to set maximum info box width
Some plugins (*cough* kak-lsp) and help texts tend to have immensely long content
in a single line. This generates info boxes that span the entire terminal width.
This is made especially worse on widescreen monitors or at small text size.

This grants user control over how wide these boxes are.

I deliberately avoid pushing this change to `kak-lsp` because it's not the only
plugin that this could help--see the `hook` help text for an example of this
problem in vanilla Kakoune. I would also suggest that since this is a rendering
concern, it be handled by the terminal rendering logic.
2023-02-15 21:17:22 -05:00
Maxime Coste
afaa47e93f Fix trimming of line front halfway through a double-width glyph
Insert a space to replace the half glyph and ensure the rest of the
line is correctly aligned.

Fixes #4843
2023-02-15 13:04:53 +11:00
Maxime Coste
0630b4f4f6 Fix scroll_window not ensuring cursor lies on a codepoint start
Fixes #4839
2023-02-14 22:00:12 +11:00
Maxime Coste
458e3ef20a Immediately execute ModuleLoaded hooks for already loaded modules
This is trickier than expected because ModuleLoaded hooks can (as
any other hooks) use arbitrary regular expressions for their filter.

Fixes #4841
2023-02-14 21:31:29 +11:00
Maxime Coste
85ceef29bd Fix broken corner cases in DualThreadStack::grow_ifn
We only grow when the ring buffer is full, which allows for a nice
simplification of the code.

Tell grow_ifn if we pushed in current or next so that we can
distinguish between filled by next or filled by current when
m_current == m_next_begin
2023-02-14 17:13:31 +11:00
Maxime Coste
d708b77186 Refactor DualThreadStack as a RingBuffer
Instead of two stacks growing from the two ends of a buffer, use
a ring buffer growing from the same mid spot.

This avoids the costly memory copy every step when we set next
threads as the current ones.
2023-02-14 07:04:54 +11:00
Maxime Coste
762064dc68 Remove scheduled optimization from ThreadedRegexVM
This does not seem to actually speed up execution as threads will
be dropped on next step anyway
2023-02-13 21:15:55 +11:00
Maxime Coste
3150e9b3cd Avoid extra indirection for storing FifoWatcher
By improving the Value interface we can avoid storing a unique_ptr
to a FifoWatcher and directly store the FifoWatcher.
2023-02-10 12:56:32 +11:00