Commit Graph

3060 Commits

Author SHA1 Message Date
Massimo Mund
bbf6ec292e Implemented 'ResetSearch' to allow a search to be resetted
Added ResetSearch to the list of bindable actions in keybindings.md
2024-07-04 15:44:36 +02:00
Massimo Mund
f4d576b6e0 Allow action chaining of 'FindNext' and 'FindPrevious' 2024-06-08 11:06:54 +02:00
Dmytro Maluka
9eb8782ff2
Rework FindMatchingBrace() interface and implementation (#3319)
Instead of passing a single brace pair to FindMatchingBrace(), make it
traverse all brace pairs in buffer.BracePairs on its own.

This has the following advantages:

1. Makes FindMatchingBrace() easier to use, in particular much easier
   to use from Lua.

2. Lets FindMatchingBrace() ensure that we use just one matching brace -
   the higher-priority one. This fixes the following issues:

    ([foo]bar)
     ^

when the cursor is on `[`:

- Both `[]` and `()` pairs are highlighted, whereas the expected
  behavior is that only one pair is highlighted - the one that the
  JumpToMatchingBrace action would jump to.

- JumpToMatchingBrace action incorrectly jumps to `)` instead of
  `]` (which should take higher priority in this case).

In contrast, with `((foo)bar)` it works correctly.
2024-06-05 00:56:19 +02:00
Massimo Mund
46e55c8e91
Fixed trailing line spaces being ignored by word- or subword-jumps (#3321) 2024-06-04 21:10:09 +02:00
Neko Box Coder
dd913df9e9
Reordered prompt done callback to avoid accessing out of bound history (#3318)
* Reordered prompt done callback to avoid accessing out of bound history

* Formatting
2024-06-02 20:00:13 +02:00
Jöran Karl
e9bd1b35f4
Merge pull request #3270 from niten94/sh-break-continue
Add, move commands in shell syntax file
2024-05-22 22:21:06 +02:00
niten94
4911a56181 Add commands in shell syntax file
Add `break`, `command`, `continue`, `eval`, `exec`, `getopt`, `getopts`,
`trap` and `wait` command in shell syntax file.
2024-05-23 00:59:58 +08:00
niten94
343812bd2e Change color of commands in shell syntax file
Move `local`, `read`, `shift` and `time` to "Shell commands" in shell
syntax file.
2024-05-23 00:49:13 +08:00
Jöran Karl
35630aa736
Merge pull request #2665 from masmu/feature/sub-words
Implemented sub-word cursor movement
2024-05-22 06:24:19 +02:00
Massimo Mund
78fcf2fc31 Updated WordLeft() and WordRight() behavior to be in line with SubWordLeft() and SubWordRight() 2024-05-20 23:23:33 +02:00
Massimo Mund
5dbdf8c0e8 Implemented SubWordRight, SubWordLeft, SelectSubWordRight, SelectSubWordLeft and DeleteSubWordRight, DeleteSubWordLeft 2024-05-20 23:23:33 +02:00
Massimo Mund
889a841575 Replaced IsNonAlphaNumeric() with IsNonWordChar() 2024-05-20 23:23:33 +02:00
Dmytro Maluka
917650826a
Merge pull request #3291 from dmaluka/diffgutter-cleanup
Diffgutter: simplify + fix race
2024-05-14 18:03:07 +02:00
Dmytro Maluka
b70f0eb113
Add onAnyEvent callback (#3244)
Implement a radical approach to improving abilities of plugins to detect
and handle various changes of micro's state: add onAnyEvent callback
which is called, literally, after any event. A plugin can use this
callback to compare a state after the previous event and after the
current event, and thus is able to catch various events that cannot be
detected using other callbacks.

Some examples of such events:

- change of current working directory
- switching cursor focus between a bufpane and the command bar
- change of message text in the status bar
2024-05-14 18:01:15 +02:00
Dmytro Maluka
5a159ce444 updateDiffSync(): fix potential race
When updateDiffSync() is called asynchronously, it should lock the
line array when calling Bytes(), to prevent race if the line array is
being modified by the main goroutine in the meantime.
2024-05-12 21:07:12 +02:00
Dmytro Maluka
bca35a5939 Simplify UpdateDiff() interface
The callback passed to UpdateDiff() is superfluous: in the synchronous
case screen.Redraw() is not needed anyway (since the screen is redrawn
at every iteration of the main loop), and in the asynchronous case
UpdateDiff() can just call screen.Redraw() directly.
2024-05-12 20:05:14 +02:00
Jöran Karl
1f51d0b9e2
Merge pull request #3271 from JoeKar/fix/inactive-mouse-release
Fix lost mouse release events in case the pane becomes inactive
2024-04-27 23:22:57 +02:00
Jöran Karl
0a1447b688 action: tab: Stop resize in case of mouse release while not pressed 2024-04-27 21:38:02 +02:00
Jöran Karl
2ecdac8405 action: tab: Release mouse press in case of mouse release while not pressed 2024-04-27 21:37:59 +02:00
Jöran Karl
385437d400
Merge pull request #3266 from JoeKar/fix/keysequence-comparison
bindings: Correct `KeySequenceEvent` comparison (fix crash)
2024-04-26 17:37:19 +02:00
Jöran Karl
1c35f3dc39
Merge pull request #3261 from JoeKar/fix/command-term
action: Stop processing chained actions/commands in the moment the current `Pane` is not a `BufPane` (fix crash)
2024-04-26 17:36:12 +02:00
Jöran Karl
07cda68795 initlua: Correct return type of CurPane() to be of type *BufPane 2024-04-25 23:34:39 +02:00
Jöran Karl
3919cf399f action: Provide Name() to treat TermPane as Pane
This will add the capability to address the `TermPane` within the tabs, since
the tab list only stores panes.
2024-04-25 23:34:39 +02:00
Jöran Karl
b05df07df2 bindings: Small refactoring of TryBindKey() for better readability 2024-04-25 23:21:52 +02:00
Jöran Karl
8af890a0a3 bindings: Correct KeySequenceEvent comparison
We've to iterate over the included elements,
since slices can't be simply compared with the comparison operators.
2024-04-25 23:20:30 +02:00
Dmytro Maluka
ff5b147639
Merge pull request #3267 from dmaluka/dokeyevent-improvements
Small fixes and improvements for InfoPane's key event handling
2024-04-25 21:59:44 +02:00
Dmytro Maluka
3f810c24d2
Fix Deselect() after mouse selection (#3268)
Ensure that the selection start is always before the selection end,
regardless of the direction of a mouse selection, to make
h.Cursor.Deselect() handle its `start` argument correctly.

This makes the cursor behavior after mouse selections consistent with
the cursor behavior after keyboard selections.

Fixes #3055
2024-04-25 21:58:40 +02:00
Jöran Karl
26fa15c147 action: Stop action iteration in the moment the current pane isn't a BufPane 2024-04-25 18:07:03 +02:00
Yevhen Babiichuk (DustDFG)
147943837d
Fix cursor moving down when selection exist. Solves (#3087) (#3091)
Previously `CursorDown` function called `Deselect` with a wrong
argument which lead to the situation when cursor was moved to the
start instead of the end of the selection

Signed-off-by: Yevhen Babiichuk (DustDFG) <dfgdust@gmail.com>
2024-04-25 02:27:41 +02:00
Dmytro Maluka
24406a5ae8 Comment plugin: doc: fix incorrect keybinding 2024-04-25 01:28:34 +02:00
Dmytro Maluka
8632b82cbe infopane: DoKeyEvent: it is buggy, let's add a TODO for now 2024-04-25 00:30:41 +02:00
Dmytro Maluka
fade304667 infopane: HandleEvent: refactor y/n prompt handling 2024-04-25 00:13:37 +02:00
Dmytro Maluka
5b3737fb2a infopane: HandleEvent: reset key sequence when handling y/n prompt
Fix the following buggy behavior:

1. bind "<n><a>" to the Paste action in the command bar
2. open a split pane, type some text and press Ctrl-q to close it
3. answer "n" to the "Save changes before closing?" prompt
4. press Ctrl-e to open the command prompt and press "a"

-> result: instead of inserting the "a" letter, clipboard is pasted.
2024-04-25 00:05:27 +02:00
Dmytro Maluka
36bf3f6619 DoKeyEvent: document return value
The return value of DoKeyEvent() has a dual meaning, which makes the
code not obvious and confusing. So at least document it.
2024-04-24 23:21:28 +02:00
Dmytro Maluka
8c7f63ac15 infopane: DoKeyEvent: ignore action return value
It is not really defined what is the meaning of this return value.
Currently this value is always true. And even if this value actually
meant something (for example, the result of the last executed action
in the chain), we should not use this value in HandleEvent(). The key
event handling logic should behave the same regardless of whether the
action triggered by this key succeeded or not.
2024-04-24 22:51:27 +02:00
Dmytro Maluka
18f3e1bf89
Merge pull request #3245 from dmaluka/onsetactive-fix
Fix issues with `onSetActive` callback
2024-04-23 21:28:03 +02:00
Dmytro Maluka
e48575f349
Add onBufPaneOpen error checking (#3246)
If onBufPaneOpen callback execution fails (e.g. due to a Lua runtime
error), report this error to the user, like we do for all other Lua
callbacks, rather than silently continue working as if nothing
happened.
2024-04-23 21:23:25 +02:00
Dmytro Maluka
eec068a4fc
help/colors: syntax: document default.yaml (#3262) 2024-04-23 21:21:51 +02:00
Dmytro Maluka
5510317942
Relocate buffer view when reloading file (#3250)
After reloading a file that has been externally modified, the buffer
view may become invalid: the displayed subset of lines of the file may
no longer exist, since the file may have been truncated. So relocate the
buffer view in this case.

In particular, this fixes crashes caused by out of bounds accesses to
the line array by displayBuffer() trying to display no longer existing
lines.
2024-04-21 22:49:01 +02:00
Dmytro Maluka
169a9a65fa
Merge pull request #3259 from dmaluka/default-syntax-followup
Follow-ups after adding `default.yaml` support
2024-04-21 22:48:33 +02:00
Jöran Karl
c3052b491f
parser: Check and prompt for empty patterns and region properties (fix crash) (#3256)
* parser: Precise error message for missing `start` & `end` in region

* parser: Check and prompt for empty patterns and region properties

* syntax: Remove empty identifier pattern from log definition
2024-04-21 20:13:28 +02:00
Dmytro Maluka
b929c61228 help/colors: syntax: document that nested includes are not supported 2024-04-21 15:41:49 +02:00
Dmytro Maluka
08c516c730 UpdateRules: optimize out HasIncludes() usage 2024-04-21 15:14:21 +02:00
Dmytro Maluka
1bddc8d03e UpdateRules: move include logic to a helper function 2024-04-21 15:13:03 +02:00
Jöran Karl
f9cad2e448
action: Fix the duplication of the unknown filetype (#3258) 2024-04-19 06:01:27 +02:00
Dmytro Maluka
3aed20fde9 UpdateRules: correct the comments
The "runtime" term is ambiguous: it refers to both built-in and user's
custom ("real runtime") files.
2024-04-19 00:10:58 +02:00
Dmytro Maluka
a436dae587 UpdateRules: allow includes in default.yaml 2024-04-18 23:29:33 +02:00
Dmytro Maluka
5610d01e08 UpdateRules: fix set filetype unknown
Fix `set filetype unknown` not working as expected in the following
scenario:

1. open foo.txt (no filetype detected) -> ft is `unknown`, highlighted
   with default.yaml, as expected

2. `set filetype go` -> ft is `go`, highlighted with go.yaml as expected

3. `set filetype unknown` -> ft is still `go`, still highlighted with
   go.yaml (whereas expected behavior is: ft is `unknown`, highlighted
   with default.yaml)

Fix that by always updating b.SyntaxDef value, not reusing the old one.

This also makes the code simpler and easier to understand.
2024-04-18 22:39:16 +02:00
Jöran Karl
0806addbd7
Merge pull request #2933 from JoeKar/feature/default-syntax
syntax: Provide default.yaml as fallback definition
2024-04-18 19:38:35 +02:00
Jöran Karl
6cd39efddc buffer: Refactor UpdateRules() by creating further helper functions
- `findRealRuntimeSyntaxDef()`
- `findRuntimeSyntaxDef()`

This will reduce the length of this function again and thus improves the
readability.
2024-04-18 18:33:00 +02:00