Commit Graph

5386 Commits

Author SHA1 Message Date
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