Commit Graph

1252 Commits

Author SHA1 Message Date
Dmytro Maluka
baca0e5cb2 Add param to InitRuntimeFiles() to init built-in files only 2024-04-03 03:41:06 +02:00
Jöran Karl
a57d29ada9
command: Fix reload command to correctly initialize and reload all runtime files (#3062)
* rtfiles: Initialize all-/realFiles and Plugins in InitRuntimeFiles

* command: Reload plugins at ReloadCmd too

* command: Don't reload plugins in case of ReloadConfig()

* rtfiles: Split InitRuntimeFiles() into one func for assets and one for plugins

* rtfiles: Remove the unnecessary init function

With this modification the InitRuntimeFiles() and InitPlugins() (if needed)
must be called first, otherwise uninitialized runtime file variables are most
likely.
2024-03-22 20:47:30 +01:00
Dmytro Maluka
9ab9f8bc1c
Forward resize event to both TabList and InfoBar (#3179)
InfoBar should really receive the resize event, to know the window width
in order to do horizontal scrolling of the command line when it doesn't
fit in the screen. Although currently it doesn't scroll the command line
at all (see issue #2527) and just ignores the resize event, but we
should fix that anyway, so let's forward the resize event to it.
2024-03-21 21:40:22 +01:00
Suhaas Joshi
16e38b988c
cmd: Fix typo in the plugin line of "micro --help" (#2594)
fixes #2582
2024-03-17 16:48:41 +01:00
Jöran Karl
4a53419c62
option: Don't apply rmtrailingws in case of timed autosave (#2850) 2024-03-15 18:46:51 +01:00
Dmytro Maluka
cb903f414c
Remove unused autosave channel leftover (#3024)
config.Autosave channel is used instead.
2024-03-14 04:58:45 +01:00
Dmytro Maluka
0a69cc68dc
Merge pull request #3023 from dmaluka/timerchan
Rework lua timers and remove lua.Lock
2024-03-14 04:58:19 +01:00
Dmytro Maluka
1d1b363fa7 Remove lua.Lock
Exposing locking primitives to lua plugins is tricky and may lead to
deadlocks. Instead, if possible, it's better to ensure all the needed
synchonization in micro itself, without leaving this burden to lua code.

Since we've added micro.After() timer API and removed exposing Go timers
directly to lua, now we (probably?) have no cases of lua code possibly
running asynchronously without micro controlling when it is running. So
now we can remove lua.Lock.

This means breaking compatibility, but, until recently lua.Lock wasn't
workable at all (see #2945), which suggests that it has never been
really used by anyone. So it should be safe to remove it.
2024-03-14 04:53:56 +01:00
Dmytro Maluka
9089e9ec83 Add micro's own lua timer function micro.After()
Directly using Go's time.AfterFunc() from lua is tricky. First, it
requires the lua timer callback to explicitly lock ulua.Lock to prevent
races. Second, it requires the lua timer callback to explicitly redraw
the screen if the callback changes the screen contents (see #2923).

So instead provide micro's own timer API which ensures both
synchronization and redrawing on its own, instead of leaving this burden
to lua code. In fact, its implementation runs the lua timer callback in
the main micro's goroutine (i.e. from micro's perspective it is
synchronous, not asynchronous), so both redrawing and synchronization
are ensured automatically.

Fixes #2923
2024-03-14 04:52:59 +01:00
Dmytro Maluka
c24604d1ab
Fix overwriting persistent non-default settings with temporary default settings (#3010)
Passing options via micro -option=value in the command line should only
temporarily override the option value for the current micro session,
not change it permanently in settings.json. But currently it wrongly
writes it to settings.json in the case when the value passed via command
line is the default value of this option, while the current permanent
setting in settings.json is a non-default value.

Fixes #3005
2024-03-14 04:43:40 +01:00
Jöran Karl
321322af31
micro: DoEvent: Don't forward the resize event into the InfoBar (#3035) 2024-03-12 18:49:24 +01:00
Jöran Karl
0de16334d3
micro: Don't forward nil events into the sub event handler (#2992) 2024-03-12 18:35:33 +01:00
Zachary Yedidia
9da6af91c8 Handle SIGABRT properly 2023-10-20 08:51:17 +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
Zachary Yedidia
5739daffc8 Exit application if input terminal has closed
Bump tcell to get access to event error information, and to propagate
input EOF errors as event errors.

Fixes #2569
Fixes #2148
2023-03-20 16:17:43 -04:00
Alan Hamlett
0500cc234d
util.HttpRequest helper to make requests with headers (#2678) 2023-01-30 01:29:06 -08:00
Dmitry Maluka
e31f5ed26e
Add -profile flag for CPU profiling (#2715)
There is already a commented-out code in main() for enabling CPU
profiling of micro, which is often useful. Adjust it to allow enabling
it just by providing -profile flag on the command line, without
modifying and recompiling the code.
2023-01-29 18:10:57 -08:00
Zachary Yedidia
810133d5a8 Use shell job for terminal callback
Fixes #2529
2022-08-19 15:46:01 -07:00
Zachary Yedidia
3d6b0c6dd6 Ensure screen cannot draw during a term prompt
Fixes #2528
2022-08-16 22:07:41 -07:00
Abirdcfly
ee6688eb74
delete minor unreachable code caused by log.Fatal (#2507)
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
2022-07-24 13:56:02 -07:00
Zachary Yedidia
fe3186ba9d Ignore tool files 2021-08-21 18:07:43 -04:00
Andrew Clarke
dcf94816fb
remove carriage return from -clean prompt and fix broken logic (#2186) 2021-08-21 00:30:16 -04:00
Zachary Yedidia
c315a91fc6 Allow aborting while opening a file with backup
Also fixes an issue where the abort prompt consumes interrupt signals.

Fixes #2151
2021-08-02 21:05:22 -04:00
Zachary Yedidia
0b0c99f1f5 Warn for readonly instead of setting option
Fixes #2106
2021-05-19 14:58:00 -04:00
Zachary Yedidia
86df9ad3b0 Merge 2021-04-20 21:28:37 -04:00
Zachary Yedidia
0851499130 Handle SIGHUP properly
Fixes #2085

Not the nicest solution but it will do for now.
2021-04-20 21:27:59 -04:00
Dmitry Maluka
c5798b5b8c
Fix softwrap scrolling issues (#1981)
Softwrap implementation enhanced to fix various issues with scrolling,
centering, relocating etc.

The main idea is simple: work not with simple line numbers but
with (Line, Row) pairs, where Line is a line number in the buffer
and Row is a visual line (a row) number within this line.
The logic remains mostly the same, but simple arithmetic operations
on line numbers are replaced with corresponding operations on
(Line, Row) pairs.

Fixes #632, #1657
2021-04-07 16:18:51 -04:00
Zachary Yedidia
4c21808c6c Remove clipboard error message 2020-12-16 21:35:07 -05:00
Carlos Henrique Guardão Gandarez
7a5f7e443a
Make more libraries available (#1917)
* Make more libraries available to plugin dvelopment

* Add Unzip function to util
2020-11-21 01:46:17 -05:00
Zachary Yedidia
a424a0dca1 Fix autosave not running by default 2020-10-08 23:33:34 -04:00
Sourya Vatsyayan
fc3dd9a62f
Fix quality issues (#1856)
* Add .deepsource.toml

* Remove unnecessary comparison with bool

* Remove unnecessary use of slice

* Replace multiple `append`s with one

* Remove unnecessary wrapping of function call

* Fix check for empty string

* Simplify error creation with `fmt.Errorf`

* Fix defers before error check

Signed-off-by: sourya_deepsource <sourya@deepsource.io>

* Remove untrappable `os.Kill` signal

Signed-off-by: sourya_deepsource <sourya@deepsource.io>

* Remove empty else branch

Signed-off-by: sourya_deepsource <sourya@deepsource.io>

* Add missing error check

Signed-off-by: sourya_deepsource <sourya@deepsource.io>

* Merge variable declaration and assignment

Signed-off-by: sourya_deepsource <sourya@deepsource.io>

* Remove unnecessary `nil` check

Signed-off-by: sourya_deepsource <sourya@deepsource.io>

* Revert changes to generated files

Signed-off-by: sourya_deepsource <sourya@deepsource.io>

* Remove .deepsource.toml

Signed-off-by: sourya_deepsource <sourya@deepsource.io>

Co-authored-by: DeepSource Bot <bot@deepsource.io>
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-16 00:08:01 -04:00
Zachary Yedidia
11104fd093 Update to tcell v2 2020-09-05 14:52:35 -04:00
Zachary Yedidia
548bb98641 Properly close unmodified buffers on sigterm 2020-08-30 15:46:11 -04:00
Zachary Yedidia
b507cd26f4 Exit gracefully when SIGTERM is received
Ref #779
2020-08-01 20:18:07 -04:00
Zachary Yedidia
781a2dd826 Add flake8 linter, postinit and preinit
Closes #1768
2020-07-13 13:28:26 -04:00
Zachary Yedidia
d8596919a6 Fix reading clipboard internally for OSC52 2020-07-04 20:54:27 -04:00
Zachary Yedidia
f143418267 Add support for copy-paste via OSC 52
Ref #1754
2020-07-04 20:00:39 -04:00
Zachary Yedidia
b8fbbf5c83 Only lock event handling 2020-06-28 16:34:01 -04:00
Zachary Yedidia
253281ae5e Add a lock for plugins to use if using async code
Ref #1539
2020-06-28 16:29:32 -04:00
Zachary Yedidia
be4d186a46 Close file properly in clean and update makefile 2020-06-27 17:55:01 -04:00
Zachary Yedidia
9cc7c9be2d Fix backup call in test 2020-06-22 18:20:01 -04:00
Zachary Yedidia
a8332fd316 Improve backup system
This commit introduces several improvements to the backup system.

* Backups are made every 8 seconds for buffers that have been modified
  since the last backup.

* The `permbackup` option allows users to specify that backups should
  be kept permanently.

* `The backupdir` option allows users to store backups in a custom
   directory.

Fixes #1641
Fixes #1536
Ref #1539 (removes possibility of race condition for backups)
2020-06-22 17:54:56 -04:00
Zachary Yedidia
d0b75bc09f Add simulation screen tests 2020-06-20 18:24:12 -04:00
Zachary Yedidia
a9ca57af6e Improve message in micro -clean
Ref #1736
2020-06-20 13:44:52 -04:00
Zachary Yedidia
fb258dd57a Clean default settings in micro -clean 2020-06-18 17:22:21 -04:00
Zachary Yedidia
ead07e0b60 Expose ConfigDir and Tabs to plugins
Access with `micro.ConfigDir` (constant value) and `micro.Tabs()`.
2020-06-07 18:21:46 -04:00
Zachary Yedidia
140662f1ec Verify that all settings have correct type
This prevents crashes that occur when the user has put the wrong
type for a setting manually in the settings.json file.
2020-06-07 17:31:16 -04:00
Zachary Yedidia
afeb07a024 More fixes for parsecursor
Fixes #1695
Fixes #1696
2020-05-30 12:23:29 -04:00
Zachary Yedidia
3fc9a8ad9e Fix handling of +LINE:COL syntax
Fixes #1685
2020-05-29 22:48:23 -04:00
Dmitry Maluka
c5b0c2d41f
Fix dropped redraw events (#1675)
If screen.Redraw() is called very quickly after a key or mouse event,
it may send the redraw event while micro is not waiting for it but
still processing the key or mouse event. Since drawChan is non-buffered
and at the same time non-blocking, this redraw event will be simply lost,
so the screen content will not be up-to-date.
2020-05-23 14:59:23 -04:00