Commit Graph

2876 Commits

Author SHA1 Message Date
juha
9e808832f1 add next/prev split/tab support for terminal pane 2024-03-05 17:27:16 +02:00
Jöran Karl
c15abea64c
rtfiles: Give user defined runtime files precedence over asset files (#3066) 2024-03-04 13:24:40 -08:00
Dmytro Maluka
9fdea82542
Fix various issues with SpawnMultiCursor{Up,Down} (#3145)
* SpawnMultiCursorUp/Down: change order of adding cursors

SpawnMultiCursor{Up,Down} currently works in a tricky way: instead of
creating a new cursor above or below, it moves the current "primary"
cursor above or below, and then creates a new cursor below or above the
new position of the current cursor (i.e. at its previous position),
creating an illusion for the user that the current (top-most or
bottom-most) cursor is a newly spawned cursor.

This trick causes at least the following issues:

- When the line above or below, where we spawn a new cursor, is shorter
  than the current cursor position in the current line, the new cursor
  is placed at the end of this short line (which is expected), but also
  the current cursor unexpectedly changes its x position and moves
  below/above the new cursor.

- When removing a cursor in RemoveMultiCursor (default Alt-p key), it
  non-intuitively removes the cursor which, from the user point of view,
  is not the last but the last-but-one cursor.

Fix these issues by replacing the trick with a straightforward logic:
just create the new cursor above or below the last one.

Note that this fix has a user-visible side effect: the last cursor is
no longer the "primary" one (since it is now the last in the list, not
the first), so e.g. when the user clears multicursors via Esc key, the
remaining cursor is the first one, not the last one. I assume it's ok.

* SpawnMultiCursorUp/Down: move common code to a helper fn

* SpawnMultiCursorUp/Down: honor visual width and LastVisualX

Make spawning multicursors up/down behave more similarly to cursor
movements up/down. This change fixes 2 issues at once:

- SpawnMultiCursorUp/Down doesn't take into account the visual width of
  the text before the cursor, which may be different from its character
  width (e.g. if it contains tabs). So e.g. if the number of tabs before
  the cursor in the current line is not the same as in the new line, the
  new cursor is placed at an unexpected location.

- SpawnMultiCursorUp/Down doesn't take into account the cursor's
  remembered x position (LastVisualX) when e.g. spawning a new cursor
  in the below line which is short than the current cursor position, and
  then spawning yet another cursor in the next below line which is
  longer than this short line.

* SpawnMultiCursorUp/Down: honor softwrap

When softwrap is enabled and the current line is wrapped, make
SpawnMultiCursor{Up,Down} spawn cursor in the next visual line within
this wrapped line, similarly to how we handle cursor movements up/down
within wrapped lines.

* SpawnMultiCursorUp/Down: deselect when spawning cursors

To avoid weird user experience (spawned cursors messing with selections
of existing cursors).
2024-03-04 13:23:50 -08:00
Jöran Karl
eedebd80d4
util: Fix opening filenames including colons with parsecursor (#3119)
The regex pattern shall search for the end of the filename first as it does
while opening with +LINE:COL.
2024-03-04 13:22:47 -08:00
Dmytro Maluka
e5026ef3fa
Make MouseMultiCursor toggle cursors (#3146)
It is useful to be able to use mouse not only for adding new cursors
but also for removing them. So let's modify MouseMultiCursor behavior:
if a cursor already exists at the mouse click location, remove it.
2024-03-04 13:21:50 -08:00
Dmytro Maluka
af2ec9d540
Make default fileformat value suited to the OS (#3141)
Set fileformat by default to `dos` on Windows.
2024-03-04 13:20:02 -08:00
Dmytro Maluka
59dda01cb7
Make plugins in ~/.config/micro/plug dir override built-in plugins (#3031)
If ~/.config/micro/plug directory contains a plugin with the same name
as a built-in plugin, the expected behavior is that the user-defined
plugin in ~/.config/micro/plug is loaded instead of the built-in one.

Whereas the existing behavior is that the built-in plugin is used
instead of the user-defined one. Even worse, it is buggy: in this case
the plugin is registered twice, so its callbacks are executed twice
(e.g. with the autoclose plugin, a bracket is autoclosed with two
closing brackets instead of one).

Fix this by ensuring that if a plugin with the same name exists in the
~/.config/micro/plug directory, the built-in one is ignored.

Fixes #3029
2024-01-17 00:09:33 -08:00
Yevhen Babiichuk (DustDFG)
fce8db80de
Add go.mod syntax support (#3061)
Signed-off-by: Yevhen Babiichuk (DustDFG) <dfgdust@gmail.com>
2024-01-17 00:07:51 -08:00
Jöran Karl
e5a9b906f3
infocomplete: Complete filetypes (#3090) 2024-01-17 00:06:45 -08:00
niten94
422305af99
Set bits in mode used when opening files (#3095)
Set write permission bits of group and other users in mode used when
opening files.
2024-01-17 00:06:14 -08:00
Yevhen Babiichuk (DustDFG)
4e383dd110
Do correct cursor right with storing visual X in CursorRight action (#3103)
Signed-off-by: Yevhen Babiichuk (DustDFG) <dfgdust@gmail.com>
2024-01-17 00:04:18 -08:00
Jöran Karl
2d82362a66
actions: saveas: Fix crash at access without permission (#3082) 2023-12-10 13:52:22 -08:00
Zachary Yedidia
d8e9d61a95 Build arm32 binaries with GOARM=6
Ref #2986
2023-10-22 22:50:27 +02:00
Zachary Yedidia
68d88b571d Bump tcell 2023-10-22 00:35:11 +02:00
Jöran Karl
041ee002dd
syntax: sh: Add here document as string region (#2953) 2023-10-22 00:19:59 +02:00
Jöran Karl
f7244d09c6
Add reload setting - finalization of #2627 (#2845)
* Add reload setting

Can be set to:

* auto - Automatically reload files that changed
* disabled - Do not reload files
* prompt - Prompt the user about reloading the file.

* option: Add default value for reload option and documentation

---------

Co-authored-by: Wilberto Morales <wilbertomorales777@gmail.com>
2023-10-22 00:18:41 +02:00
Zachary Yedidia
9da6af91c8 Handle SIGABRT properly 2023-10-20 08:51:17 +02:00
Andrew Geng
2a9a5afbb2
Fix python decorator syntax. (#2827)
1. Python decorators begin a compound statement, so they only appear
   at the start of a line. So match at the line start to avoid giving
   decorator colors to matrix multiplication (@) expressions. Source:
   https://docs.python.org/3/reference/compound_stmts.html#function-definitions

2. Python decorators go to the end of the line and might not include
   parentheses (for example @functools.cache). So instead of matching
   everything until an `(`, just match as many non-`(` characters
   as possible---which both catches the @functools.cache example and
   allows decorator parameters to fall back to the default color.

3. Instead of hardcoding `brightgreen` (which railscast.micro also
   complains about), color decorators as `preproc` (otherwise unused
   by the python syntax files, and arguably the right colorscheme
   group to be using for syntactic sugars anyway). Note this will
   change decorator colors---for example from bright green to kinda
   brown on monokai, and from yellow to more of a light orange on
   railscast.
2023-10-16 11:08:37 +02:00
Jeffrey Smith
c55fb3329f
Fixed newline format detection for files not ending with a newline (#2875)
* Fixed newline format detection for files not ending with a newline

Files with Windows-style line endings were being converted to
Unix-style if the file did not end with a newline

* Updated file format detection fix for consistency
2023-10-16 11:03:03 +02:00
John Veness
c27593c163
Fix typos in README (#2919) 2023-10-16 10:48:22 +02:00
maddes8cht
fe89df1d4e
fix: recognize .cmd as batch files (#2922) 2023-10-16 10:47:44 +02:00
Mikko
9b81589fba
help: fix incorrect instructions for disabling key binding (#2943) 2023-10-16 10:46:01 +02:00
Dmitry Maluka
dc6a275e04
Fix non-working lua Lock (#2945)
The lock provided to lua as micro.Lock does not really work: an attempt
to use it via micro.Lock:Lock() results in an error:

Plugin initlua: init:260: attempt to call a non-function object
stack traceback:
	init:260: in main chunk
	[G]: ?

The reason is that the value that is provided to lua is a copy of the
mutex, not the mutex itself.

Ref #1539
2023-10-16 10:45:37 +02:00
Jöran Karl
db5fcf11a9
save: Restore the screen before overwriteFile() is left (#2967)
...otherwise there is no screen anymore to draw a possible error message.
2023-10-16 10:44:35 +02:00
Dmitry Maluka
db6d4f5461
save: Restore the screen if failed to start sudo (#2971)
Similarly to the crash fixed by #2967, which happens if sudo failed,
a crash also happens when sudo even fails to start. The reason for
the crash is also similar: nil dereference of screen.Screen caused by
the fact that we do not restore temporarily disabled screen.

To reproduce this crash, set the `sucmd` option to some non-existing
command, e.g. `aaa`, and try to save a file with root privileges.
2023-10-16 10:44:05 +02:00
Jöran Karl
1231d24279
syntax: Fix include of patch in git-commit (#2917) 2023-09-14 13:26:51 -07:00
Alexander Wilms
d8abfd3999
Improve metainfo file (#2910) 2023-09-09 19:17:37 -07:00
Dmitry Maluka
9fabffc880
Fix issues with handling invalid regex in syntax files (#2913)
* Fix panic due to invalid regex in a syntax file

When a user's custom syntax file has a malformed filename regex or
header regex, MakeHeaderYaml() returns error but we do not properly
handle it, which results in a panic due to a dereference of the `header`
pointer which is nil:

Micro encountered an error: runtime.errorString runtime error: invalid memory address or nil pointer dereference
runtime/panic.go:221 (0x44c367)
runtime/panic.go:220 (0x44c337)
github.com/zyedidia/micro/v2/internal/buffer/buffer.go:709 (0x82bc0f)
github.com/zyedidia/micro/v2/internal/buffer/buffer.go:392 (0x828292)
github.com/zyedidia/micro/v2/internal/buffer/buffer.go:261 (0x8278c8)
github.com/zyedidia/micro/v2/cmd/micro/micro.go:203 (0x8b9e7b)
github.com/zyedidia/micro/v2/cmd/micro/micro.go:331 (0x8ba9e5)
runtime/proc.go:255 (0x4386a7)
runtime/asm_amd64.s:1581 (0x467941)

* Do not ignore invalid filename regex error in a syntax file

When the filename regex in a syntax file is malformed but the subsequent
header regex is correct, the filename regex error gets silently ignored,
since the `err` value is overwritten by the subsequent successful header
regex result.
2023-09-09 19:17:23 -07:00
Zachary Yedidia
630b3229ee Fix term output capturing
Fixes #2912
2023-09-08 23:27:39 -07:00
Zachary Yedidia
fbce241753 Docs for fakecursor option
Fixes #2908
2023-09-07 08:17:12 -04:00
Zachary Yedidia
ffc7118af0 Reset snapcraft to standard config 2023-09-06 17:02:29 -04:00
Zachary Yedidia
1ab390e1a2 Set snap grade/version to allow release 2023-09-06 16:50:04 -04:00
Zachary Yedidia
909c1a2dda Update snapcraft 2023-09-06 16:31:21 -04:00
Zachary Yedidia
c2cebaa3d1 Bump tcell for windows update 2023-09-02 13:32:09 +01:00
taconi
75b9a6cefe
Add onSetActive callback (#2885)
Co-authored-by: taconi <igor.tacoi@protonmail.com>
2023-08-31 17:29:07 +01:00
Nobleman
1cbe1441aa
Update micro.desktop (#2864)
Add `NoDisplay=true` to avoid showing up in applications menu
2023-08-31 17:26:19 +01:00
Zachary Yedidia
d0f0b95e45 Fix for capturing internal terminal pty output
Fixes #2879
2023-08-31 07:11:00 -07:00
Jöran Karl
a78c2c3509
actions: Fix the iteration over a slice under modification in QuitAll() (#2898) 2023-08-31 12:53:33 +01:00
Jöran Karl
ceaa143c62
highlighter: Fix regions and patterns inside regions (#2840)
* highlighter: Fix regions and patterns inside regions

* highlighting: Remove 2nd recursive highlightRegion() call

...and add limitGroup checks to pattern search.

* yaml: Add TODO type highlighting

* highlighting: Don't stop in highlightRegion() at empty lines

...because possible region line end pattern must be detected.

* syntax/sh: Correct string handling due to additional pattern handling

* syntax/sh: Remove slash in variables

* highlighter: Accept nested region only in case it's within the current reagion

* highlighter: Accept nested patterns only in case it's within the current reagion

* highlighter: Don't search for nesting in case the region end was found at start
2023-07-11 13:49:12 -07:00
rilysh
cb260bf6bf
add new types for zig (#2861) 2023-07-10 23:11:07 -07:00
Mathias Lohne
0c28fbf7a5
Add support for Jenkinsfile syntax (#2750)
Build pipelines for the Jenkins build system are configured in Groovy,
however since their filename is always `Jenkinsfile`, micro doesn't
recognize them as Groovy, and doesn't add syntax highlighting.

This small commit simply adds `Jenkinsfile` and `jenkinsfile` as file
names recognized as Groovy.
2023-07-08 14:08:34 -07:00
Jan Katins
b02afb1116
Update copypaste.md (#2826)
Status page: https://wezfurlong.org/wezterm/escape-sequences.html#operating-system-command-sequences

Status at 20230521:

> Requests to query the clipboard are ignored. Allows setting or clearing the clipboard

Issue to support querying: https://github.com/wez/wezterm/issues/2050
2023-07-08 14:08:15 -07:00
Jöran Karl
e5bbeff8ac
plugins.md: Add (on|pre)Rune documentation (#2837) 2023-07-08 14:07:56 -07:00
William Etheredge
7e64a43af6
Treat Containerfiles as Dockerfiles (#2846)
Containerfiles should be fully compatible with Dockerfiles:
https://github.com/containers/buildah/discussions/3170
2023-07-08 14:07:19 -07:00
Shreyas A S
51022e6162
Fixed a typo in keybindings.md (#2852)
A 'to' was missing. I noticed it while reading through the documentation.
2023-07-08 14:07:06 -07:00
Zachary Yedidia
5cb9d5eaaf Resolve merge conflict with scrollbarchar 2023-07-08 14:06:41 -07:00
Christian Muehlhaeuser
ffa7f987b6
Add 'scrollbarchar' option (#2342)
This lets you specify a character that will get used for rendering the
scrollbar.

Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-07-08 14:02:01 -07:00
Dmitry Maluka
9593c2a720
Add HistorySearchUp and HistorySearchDown actions (#1829)
Add HistorySearchUp and HistorySearchDown actions which are similar to
HistoryUp and HistoryDown but search for the prev/next history item
whose beginning matches the currently entered text in the infobuffer
(more precisely, the text before cursor).

Also fixed the following issue: if we scrolled to an older history item
and then edit the infobuffer, this older item gets modified.
We should not edit old history entries. So in this case set HistoryNum
to the last (newly added) item and modify the last item.
2023-07-08 14:00:22 -07:00
guangwu
d7c8daad0d
chore: os.SEEK_CUR os.SEEK_END os.SEEK_SET has been deprecated since Go 1.7 (#2856) 2023-07-04 12:13:41 -07:00
Jöran Karl
0859f4aa36
Fix: Syntax highlighting for various issues (#2810)
* highlighter: Fix region & pattern detection

* syntax/sh: Highlight upper case options too

* syntax/c(pp): Try to synchronize the rules to lower the maintenance effort

* syntax/ruby: Fix explicit filename detection in directories

* highlighter: Respect skip rules in regions

* syntax/sh: Fix parameter expansion, cond. flags and generalize filename via ""

* syntax/php|vi: Correct strings in comments to comments only

Additionally improve vimscript comment handling.

* highlighter: Remove problematic start|end check in find(all)Index()

...and additionally remove recursive region end detection
2023-06-05 17:39:12 -07:00