Merge branch 'zyedidia:master' into master

This commit is contained in:
GabrielFrigo 2023-11-03 14:10:46 -03:00 committed by GitHub
commit 02e6dde56c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 77 additions and 29 deletions

View file

@ -53,7 +53,7 @@ You can also check out the website for Micro at https://micro-editor.github.io.
- Extremely good mouse support.
- This means mouse dragging to create a selection, double click to select by word, and triple click to select by line.
- Cross-platform (it should work on all the platforms Go runs on).
- Note that while Windows is supported Mingw/Cygwin is not (see below).
- Note that while Windows is supported, Mingw/Cygwin is not (see below).
- Plugin system (plugins are written in Lua).
- micro has a built-in plugin manager to automatically install, remove, and update plugins.
- Built-in diff gutter.
@ -83,7 +83,7 @@ A desktop entry file and man page can be found in the [assets/packaging](https:/
### Pre-built binaries
Pre-built binaries are distributed with [releases](https://github.com/zyedidia/micro/releases).
Pre-built binaries are distributed in [releases](https://github.com/zyedidia/micro/releases).
To uninstall micro, simply remove the binary, and the configuration directory at `~/.config/micro`.
@ -132,7 +132,7 @@ On Linux, you can install micro through [snap](https://snapcraft.io/docs/core/in
snap install micro --classic
```
Micro is also available through other package managers on Linux such dnf, AUR, Nix, and package managers
Micro is also available through other package managers on Linux such as dnf, AUR, Nix, and package managers
for other operating systems. These packages are not guaranteed to be up-to-date.
<!-- * `apt install micro` (Ubuntu 20.04 `focal`, and Debian `unstable | testing | buster-backports`). At the moment, this package (2.0.1-1) is outdated and has a known bug where debug mode is enabled. -->
@ -159,8 +159,8 @@ for other operating systems. These packages are not guaranteed to be up-to-date.
**Note for Linux desktop environments:**
For interfacing with the local system clipboard, the following tools need to be installed:
* For X11 `xclip` or `xsel`
* For [Wayland](https://wayland.freedesktop.org/) `wl-clipboard`
* For X11, `xclip` or `xsel`
* For [Wayland](https://wayland.freedesktop.org/), `wl-clipboard`
Without these tools installed, micro will use an internal clipboard for copy and paste, but it won't be accessible to external applications.
@ -221,7 +221,7 @@ If you open micro and it doesn't seem like syntax highlighting is working, this
you are using a terminal which does not support 256 color mode. Try changing the color scheme to `simple`
by pressing <kbd>Ctrl-e</kbd> in micro and typing `set colorscheme simple`.
If you are using the default Ubuntu terminal, to enable 256 make sure your `TERM` variable is set
If you are using the default Ubuntu terminal, to enable 256 color mode make sure your `TERM` variable is set
to `xterm-256color`.
Many of the Windows terminals don't support more than 16 colors, which means
@ -240,7 +240,7 @@ winpty micro.exe ...
Micro uses the amazing [tcell library](https://github.com/gdamore/tcell), but this
means that micro is restricted to the platforms tcell supports. As a result, micro does not support
Plan9, and Cygwin (although this may change in the future). Micro also doesn't support NaCl (which is deprecated anyway).
Plan9 or Cygwin (although this may change in the future). Micro also doesn't support NaCl (which is deprecated anyway).
## Usage

View file

@ -54,7 +54,7 @@ func luaImportMicro() *lua.LTable {
ulua.L.SetField(pkg, "Tabs", luar.New(ulua.L, func() *action.TabList {
return action.Tabs
}))
ulua.L.SetField(pkg, "Lock", luar.New(ulua.L, ulua.Lock))
ulua.L.SetField(pkg, "Lock", luar.New(ulua.L, &ulua.Lock))
return pkg
}

View file

@ -361,7 +361,7 @@ func main() {
sigterm = make(chan os.Signal, 1)
sighup = make(chan os.Signal, 1)
signal.Notify(sigterm, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT)
signal.Notify(sigterm, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGABRT)
signal.Notify(sighup, syscall.SIGHUP)
// Here is the event loop which runs in a separate thread

2
go.mod
View file

@ -14,7 +14,7 @@ require (
github.com/zyedidia/clipper v0.1.1
github.com/zyedidia/glob v0.0.0-20170209203856-dd4023a66dc3
github.com/zyedidia/json5 v0.0.0-20200102012142-2da050b1a98d
github.com/zyedidia/tcell/v2 v2.0.10-0.20230831153116-061c5b2c7260 // indirect
github.com/zyedidia/tcell/v2 v2.0.10 // indirect
github.com/zyedidia/terminal v0.0.0-20230315200948-4b3bcf6dddef
golang.org/x/text v0.3.8
gopkg.in/yaml.v2 v2.2.8

4
go.sum
View file

@ -54,12 +54,16 @@ github.com/zyedidia/json5 v0.0.0-20200102012142-2da050b1a98d h1:zmDMkh22zXOB7gz8
github.com/zyedidia/json5 v0.0.0-20200102012142-2da050b1a98d/go.mod h1:NDJSTTYWivnza6zkRapeX2/LwhKPEMQ7bJxqgDVT78I=
github.com/zyedidia/poller v1.0.1 h1:Tt9S3AxAjXwWGNiC2TUdRJkQDZSzCBNVQ4xXiQ7440s=
github.com/zyedidia/poller v1.0.1/go.mod h1:vZXJOHGDcuK08GXhF6IAY0ZFd2WcgOR5DOTp84Uk5eE=
github.com/zyedidia/tcell/v2 v2.0.9 h1:FxXRkE62N0GPHES7EMLtp2rteYqC9r1kVid8vJN1kOE=
github.com/zyedidia/tcell/v2 v2.0.9/go.mod h1:i4NNlquIQXFeNecrOgxDQQJdu+7LmTi3g62asvmwUws=
github.com/zyedidia/tcell/v2 v2.0.10-0.20221007181625-f562052bccb8 h1:53ULv4mmLyQDnqbjVxanckP57WSreWHwTmlLJrJEutY=
github.com/zyedidia/tcell/v2 v2.0.10-0.20221007181625-f562052bccb8/go.mod h1:i4NNlquIQXFeNecrOgxDQQJdu+7LmTi3g62asvmwUws=
github.com/zyedidia/tcell/v2 v2.0.10-0.20230320201625-54f6acdada4a h1:W4TWa++Wk6uRGxZoxr2nPX1TpIEl+Wxv0mTtocG4TYc=
github.com/zyedidia/tcell/v2 v2.0.10-0.20230320201625-54f6acdada4a/go.mod h1:i4NNlquIQXFeNecrOgxDQQJdu+7LmTi3g62asvmwUws=
github.com/zyedidia/tcell/v2 v2.0.10-0.20230831153116-061c5b2c7260 h1:SCAmAacT5BxZsmOFdFy5zwwi6nj1MjA60gydjKdTgXo=
github.com/zyedidia/tcell/v2 v2.0.10-0.20230831153116-061c5b2c7260/go.mod h1:i4NNlquIQXFeNecrOgxDQQJdu+7LmTi3g62asvmwUws=
github.com/zyedidia/tcell/v2 v2.0.10 h1:6fbbYAx/DYc9A//4jU1OeBrxtc9qJxYCZXCtGQbtTWU=
github.com/zyedidia/tcell/v2 v2.0.10/go.mod h1:i4NNlquIQXFeNecrOgxDQQJdu+7LmTi3g62asvmwUws=
github.com/zyedidia/terminal v0.0.0-20230315200948-4b3bcf6dddef h1:LeB4Qs0Tss4r/Qh8pfsTTqagDYHysfKJLYzAH3MVfu0=
github.com/zyedidia/terminal v0.0.0-20230315200948-4b3bcf6dddef/go.mod h1:zeb8MJdcCObFKVvur3n2B4BANIPuo2Q8r4iiNs9Enx0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

View file

@ -395,20 +395,34 @@ func (h *BufPane) Name() string {
return n
}
func (h *BufPane) getReloadSetting() string {
reloadSetting := h.Buf.Settings["reload"]
return reloadSetting.(string)
}
// HandleEvent executes the tcell event properly
func (h *BufPane) HandleEvent(event tcell.Event) {
if h.Buf.ExternallyModified() && !h.Buf.ReloadDisabled {
InfoBar.YNPrompt("The file on disk has changed. Reload file? (y,n,esc)", func(yes, canceled bool) {
if canceled {
h.Buf.DisableReload()
}
if !yes || canceled {
h.Buf.UpdateModTime()
} else {
h.Buf.ReOpen()
}
})
reload := h.getReloadSetting()
if reload == "prompt" {
InfoBar.YNPrompt("The file on disk has changed. Reload file? (y,n,esc)", func(yes, canceled bool) {
if canceled {
h.Buf.DisableReload()
}
if !yes || canceled {
h.Buf.UpdateModTime()
} else {
h.Buf.ReOpen()
}
})
} else if reload == "auto" {
h.Buf.ReOpen()
} else if reload == "disabled" {
h.Buf.DisableReload()
} else {
InfoBar.Message("Invalid reload setting")
}
}
switch e := event.(type) {

View file

@ -116,12 +116,12 @@ func NewLineArray(size uint64, endings FileFormat, reader io.Reader) *LineArray
dlen := len(data)
if dlen > 1 && data[dlen-2] == '\r' {
data = append(data[:dlen-2], '\n')
if endings == FFAuto {
if la.Endings == FFAuto {
la.Endings = FFDos
}
dlen = len(data)
} else if dlen > 0 {
if endings == FFAuto {
if la.Endings == FFAuto {
la.Endings = FFUnix
}
}

View file

@ -51,6 +51,7 @@ func overwriteFile(name string, enc encoding.Encoding, fn func(io.Writer) error,
// contents to its stdin it might hang because the kernel's pipe size
// is too small to handle the full file contents all at once
if e := cmd.Start(); e != nil && err == nil {
screen.TempStart(screenb)
return err
}
} else if writeCloser, err = os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644); err != nil {
@ -78,10 +79,10 @@ func overwriteFile(name string, enc encoding.Encoding, fn func(io.Writer) error,
if withSudo {
// wait for dd to finish and restart the screen if we used sudo
err := cmd.Wait()
screen.TempStart(screenb)
if err != nil {
return err
}
screen.TempStart(screenb)
}
return

View file

@ -52,6 +52,7 @@ var optionValidators = map[string]optionValidator{
"fileformat": validateLineEnding,
"encoding": validateEncoding,
"multiopen": validateMultiOpen,
"reload": validateReload,
}
func ReadSettings() error {
@ -294,6 +295,7 @@ var defaultCommonSettings = map[string]interface{}{
"mkparents": false,
"permbackup": false,
"readonly": false,
"reload": "prompt",
"rmtrailingws": false,
"ruler": true,
"relativeruler": false,
@ -526,3 +528,19 @@ func validateMultiOpen(option string, value interface{}) error {
return nil
}
func validateReload(option string, value interface{}) error {
val, ok := value.(string)
if !ok {
return errors.New("Expected string type for reload")
}
switch val {
case "prompt", "auto", "disabled":
default:
return errors.New(option + " must be 'prompt', 'auto' or 'disabled'")
}
return nil
}

View file

@ -206,7 +206,7 @@ Here are the available options:
* `keymenu`: display the nano-style key menu at the bottom of the screen. Note
that ToggleKeyMenu is bound to `Alt-g` by default and this is displayed in
the statusline. To disable this, simply by `Alt-g` to `UnbindKey`.
the statusline. To disable the key binding, bind `Alt-g` to `None`.
default value: `false`
@ -281,6 +281,11 @@ Here are the available options:
default value: `false`
* `reload`: controls the reload behavior of the current buffer in case the file
has changed. The available options are `prompt`, `auto` & `disabled`.
default value: `prompt`
* `rmtrailingws`: micro will automatically trim trailing whitespaces at ends of
lines. Note: This setting overrides `keepautoindent`

View file

@ -1,7 +1,7 @@
filetype: batch
detect:
filename: "(\\.bat$)"
filename: "(\\.bat$|\\.cmd$)"
# header: ""
rules:

View file

@ -21,7 +21,7 @@ rules:
# keywords
- statement: "\\b(and|as|assert|break|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|raise|return|try|while|with|yield)\\b"
# decorators
- brightgreen: "@.*[(]"
- preproc: "^\\s*@[^(]*"
# operators
- symbol.operator: "([.:;,+*|=!\\%@]|<|>|/|-|&)"
# parentheses

View file

@ -20,7 +20,7 @@ rules:
# keywords
- statement: "\\b(and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|raise|return|try|while|with|yield)\\b"
# decorators
- brightgreen: "@.*[(]"
- preproc: "^\\s*@[^(]*"
# operators
- symbol.operator: "([~^.:;,+*|=!\\%@]|<|>|/|-|&)"
# parentheses

View file

@ -56,6 +56,12 @@ rules:
skip: "\\\\."
rules: []
- constant.string:
start: "<<[^\\s]+[-~.]*[A-Za-z0-9]+$"
end: "^[^\\s]+[A-Za-z0-9]+$"
skip: "\\\\."
rules: []
- comment:
start: "(^|\\s)#"
end: "$"

View file

@ -21,7 +21,7 @@ GOOS=linux GOARCH=386 go build -ldflags "-s -w -X main.Version=$1 -X main.Commit
tar -czf micro-$1-linux32.tar.gz micro-$1
mv micro-$1-linux32.tar.gz binaries
echo "Linux arm 32"
GOOS=linux GOARCH=arm go build -ldflags "-s -w -X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$DATE'" -o micro-$1/micro ./cmd/micro
GOOS=linux GOARM=6 GOARCH=arm go build -ldflags "-s -w -X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$DATE'" -o micro-$1/micro ./cmd/micro
tar -czf micro-$1-linux-arm.tar.gz micro-$1
mv micro-$1-linux-arm.tar.gz binaries
echo "Linux arm 64"

View file

@ -52,7 +52,7 @@ tar -czf micro-$1-linux32.tar.gz micro-$1
mv micro-$1-linux32.tar.gz binaries
echo "Linux ARM 32"
GOOS=linux GOARCH=arm make build
GOOS=linux GOARM=6 GOARCH=arm make build
mv micro micro-$1
tar -czf micro-$1-linux-arm.tar.gz micro-$1
mv micro-$1-linux-arm.tar.gz binaries