Compare commits

...

16 Commits

Author SHA1 Message Date
Peder Bergebakken Sundt
b1fd8fe4b4
Merge 8ec62ad2d2 into dc7759204b 2024-07-05 22:08:28 -07:00
Dmytro Maluka
dc7759204b
Merge pull request #3357 from niten94/shell-sigint-recv
Receive SIGINT only in RunInteractiveShell
2024-06-28 10:37:41 +02:00
niten94
a84aa225ab Return error with start in RunInteractiveShell
Print and return error with process start in RunInteractiveShell if
process was not able to be started. Wait until enter is pressed even if
`wait` is false.

Co-authored-by: Dmitry Maluka <dmitrymaluka@gmail.com>
2024-06-22 21:21:13 +08:00
mdom
882b98f3f1
Fix typo in README.md (#3361) 2024-06-21 16:53:25 +02:00
Jöran Karl
0fa4a3a8db
Merge pull request #3354 from JoeKar/feature/action-nightly
workflows: General improvements
2024-06-20 23:24:51 +02:00
Jöran Karl
531c7d88e2 workflow: Fetch with a fetch-depth of 0 and fetch-tags true
This will allow us to read the whole history especially all the tags.
2024-06-20 22:59:05 +02:00
Jöran Karl
c58ed0e51a workflows: Perform the setup uncached 2024-06-20 22:59:05 +02:00
Jöran Karl
f475220e67 workflows/test: Bump version of setup & checkout actions
This will correct the following warning:
"Node.js 16 actions are deprecated."
2024-06-20 22:59:05 +02:00
Jöran Karl
57375e0732 workflows/nightly: Allow manual trigger for better testability 2024-06-20 22:59:05 +02:00
Jöran Karl
d98fafd2f9 tools/build-version.go: Remove the git fetch step
build-version.go shall only provide information and not modify the repository
in which it runs.
2024-06-20 22:59:03 +02:00
Jöran Karl
f5a9744bde tools/build-version.go: Improve error verbosity 2024-06-20 22:30:00 +02:00
niten94
f05d3582b3 Receive SIGINT only in RunInteractiveShell
Temporarily reset SIGINT signal handlers and receive SIGINT in
RunInteractiveShell. Do not try to kill the process in micro when signal
is received.
2024-06-17 19:07:10 +08:00
niten94
26ae1b95cc Move sigterm channel to internal/util 2024-06-17 18:08:18 +08:00
Peder Bergebakken Sundt
8ec62ad2d2 syntax/markdown: Remove leftover 2020-08-28 17:48:54 +02:00
Peder Bergebakken Sundt
e601eb974f syntax/markdown: Add highlighting for html tags 2020-08-28 17:36:20 +02:00
Peder Bergebakken Sundt
2d1a7f5082 syntax/markdown: Include languages in codeblocks, make inline code work in titles 2020-08-28 17:35:17 +02:00
8 changed files with 142 additions and 31 deletions

View File

@ -1,7 +1,8 @@
name: Nightly builds
on:
workflow_dispatch: # Allows manual trigger
schedule:
- cron: '0 0 * * *'
- cron: '0 0 * * *'
jobs:
nightly:
strategy:
@ -14,11 +15,14 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: false
- name: Checkout
uses: actions/checkout@v4
with:
ref: master
fetch-depth: 0
fetch-tags: true
- name: Build
run: tools/cross-compile.sh

View File

@ -8,10 +8,15 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
cache: false
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Build
run: |

View File

@ -156,7 +156,7 @@ for other operating systems. These packages are not guaranteed to be up-to-date.
* `choco install micro`.
* `scoop install micro`.
* OpenBSD: Available in the ports tree and also available as a binary package.
* `pkd_add -v micro`.
* `pkg_add -v micro`.
* NetBSD, macOS, Linux, Illumos, etc. with [pkgsrc](http://www.pkgsrc.org/)-current:
* `pkg_add micro`
* macOS: Available in package managers.

View File

@ -40,8 +40,7 @@ var (
flagClean = flag.Bool("clean", false, "Clean configuration directory")
optionFlags map[string]*string
sigterm chan os.Signal
sighup chan os.Signal
sighup chan os.Signal
timerChan chan func()
)
@ -360,9 +359,9 @@ func main() {
screen.Events = make(chan tcell.Event)
sigterm = make(chan os.Signal, 1)
util.Sigterm = make(chan os.Signal, 1)
sighup = make(chan os.Signal, 1)
signal.Notify(sigterm, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGABRT)
signal.Notify(util.Sigterm, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGABRT)
signal.Notify(sighup, syscall.SIGHUP)
timerChan = make(chan func())
@ -437,7 +436,7 @@ func DoEvent() {
}
}
os.Exit(0)
case <-sigterm:
case <-util.Sigterm:
for _, b := range buffer.OpenBuffers {
if !b.Modified() {
b.Fini()

View File

@ -11,6 +11,7 @@ import (
shellquote "github.com/kballard/go-shellquote"
"github.com/zyedidia/micro/v2/internal/screen"
"github.com/zyedidia/micro/v2/internal/util"
)
// ExecCommand executes a command using exec
@ -95,28 +96,30 @@ func RunInteractiveShell(input string, wait bool, getOutput bool) (string, error
cmd.Stderr = os.Stderr
// This is a trap for Ctrl-C so that it doesn't kill micro
// Instead we trap Ctrl-C to kill the program we're running
// micro is killed if the signal is ignored only on Windows, so it is
// received
c := make(chan os.Signal, 1)
signal.Reset(os.Interrupt)
signal.Notify(c, os.Interrupt)
go func() {
for range c {
cmd.Process.Kill()
err = cmd.Start()
if err == nil {
err = cmd.Wait()
if wait {
// This is just so we don't return right away and let the user press enter to return
screen.TermMessage("")
}
}()
cmd.Start()
err = cmd.Wait()
} else {
screen.TermMessage(err)
}
output := outputBytes.String()
if wait {
// This is just so we don't return right away and let the user press enter to return
screen.TermMessage("")
}
// Start the screen back up
screen.TempStart(screenb)
signal.Notify(util.Sigterm, os.Interrupt)
signal.Stop(c)
return output, err
}

View File

@ -41,6 +41,8 @@ var (
// Stdout is a buffer that is written to stdout when micro closes
Stdout *bytes.Buffer
// Sigterm is a channel where micro exits when written
Sigterm chan os.Signal
)
func init() {

View File

@ -41,9 +41,103 @@ rules:
# urls
- underlined: "https?://[^ )>]+"
- special: "^```$"
# html tags
- identifier: "\\<[^!].*?\\>"
# inline code
- special: "`[^`]*(`|$)"
# import syntaxes for different code blocks
- default: {end: "^\\s*```\\s*$", start: "^\\s*```(c\\+\\+|cpp)\\s*$", rules: [{include: "c++"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```(sh|shell|bash)\\s*$", rules: [{include: "shell"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```apacheconf\\s*$", rules: [{include: "apacheconf"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```asm\\s*$", rules: [{include: "asm"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```awk\\s*$", rules: [{include: "awk"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```bat\\s*$", rules: [{include: "batch"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```make\\s*$", rules: [{include: "makefile"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```c\\s*$", rules: [{include: "c"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```clojure\\s*$", rules: [{include: "clojure"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```cmake\\s*$", rules: [{include: "cmake"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```coffeescript\\s*$", rules: [{include: "coffeescript"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```conf\\s*$", rules: [{include: "conf"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```crontab\\s*$", rules: [{include: "crontab"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```csharp\\s*$", rules: [{include: "csharp"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```css\\s*$", rules: [{include: "css"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```cython\\s*$", rules: [{include: "cython"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```d\\s*$", rules: [{include: "d"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```dart\\s*$", rules: [{include: "dart"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```dockerfile\\s*$", rules: [{include: "dockerfile"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```dogelang\\s*$", rules: [{include: "dogelang"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```dot\\s*$", rules: [{include: "dot"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```elixir\\s*$", rules: [{include: "elixir"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```elm\\s*$", rules: [{include: "elm"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```erb\\s*$", rules: [{include: "erb"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```erlang\\s*$", rules: [{include: "erlang"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```fish\\s*$", rules: [{include: "fish"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```forth\\s*$", rules: [{include: "forth"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```fortran\\s*$", rules: [{include: "fortran"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```fsharp\\s*$", rules: [{include: "fsharp"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```gdscript\\s*$", rules: [{include: "gdscript"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```glsl\\s*$", rules: [{include: "glsl"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```go\\s*$", rules: [{include: "go"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```golo\\s*$", rules: [{include: "golo"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```graphql\\s*$", rules: [{include: "graphql"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```groff\\s*$", rules: [{include: "groff"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```haml\\s*$", rules: [{include: "haml"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```haskell\\s*$", rules: [{include: "haskell"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```html\\s*$", rules: [{include: "html"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```ini\\s*$", rules: [{include: "ini"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```java\\s*$", rules: [{include: "java"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```javascript\\s*$", rules: [{include: "javascript"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```jinja2\\s*$", rules: [{include: "jinja2"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```json\\s*$", rules: [{include: "json"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```julia\\s*$", rules: [{include: "julia"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```kotlin\\s*$", rules: [{include: "kotlin"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```lisp\\s*$", rules: [{include: "lisp"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```lua\\s*$", rules: [{include: "lua"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```micro\\s*$", rules: [{include: "micro"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```mpdconf\\s*$", rules: [{include: "mpd"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```nanorc\\s*$", rules: [{include: "nanorc"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```nginx\\s*$", rules: [{include: "nginx"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```nim\\s*$", rules: [{include: "nim"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```objc\\s*$", rules: [{include: "objective-c"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```ocaml\\s*$", rules: [{include: "ocaml"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```pascal\\s*$", rules: [{include: "pascal"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```(diff|patch)\\s*$", rules: [{include: "patch"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```peg\\s*$", rules: [{include: "peg"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```perl6\\s*$", rules: [{include: "perl6"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```perl\\s*$", rules: [{include: "perl"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```php\\s*$", rules: [{include: "php"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```pkg-config\\s*$", rules: [{include: "pc"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```pony\\s*$", rules: [{include: "pony"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```puppet\\s*$", rules: [{include: "puppet"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```python2\\s*$", rules: [{include: "python2"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```python3?\\s*$", rules: [{include: "python"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```r\\s*$", rules: [{include: "r"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```ruby\\s*$", rules: [{include: "ruby"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```rust\\s*$", rules: [{include: "rust"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```scala\\s*$", rules: [{include: "scala"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```sed\\s*$", rules: [{include: "sed"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```sls\\s*$", rules: [{include: "salt"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```sql\\s*$", rules: [{include: "sql"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```swift\\s*$", rules: [{include: "swift"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```systemd\\s*$", rules: [{include: "systemd"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```tcl\\s*$", rules: [{include: "tcl"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```tex\\s*$", rules: [{include: "tex"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```toml\\s*$", rules: [{include: "toml"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```typescript\\s*$", rules: [{include: "typescript"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```v\\s*$", rules: [{include: "v"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```vala\\s*$", rules: [{include: "vala"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```verilog\\s*$", rules: [{include: "verilog"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```vhdl\\s*$", rules: [{include: "vhdl"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```vue\\s*$", rules: [{include: "vue"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```xml\\s*$", rules: [{include: "xml"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```yaml\\s*$", rules: [{include: "yaml"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```yum\\s*$", rules: [{include: "yum"}] }
- default: {end: "^\\s*```\\s*$", start: "^\\s*```zig\\s*$", rules: [{include: "zig"}] }
# the default code block:
- special:
start: "`"
end: "`"
start: "^\\s*```.*\\s*$"
end: "^\\s*```\\s*$"
rules: []

View File

@ -4,6 +4,7 @@ package main
import (
"fmt"
"log"
"os/exec"
"strings"
@ -19,13 +20,17 @@ func getTag(match ...string) (string, *semver.PRVersion) {
} else {
tagParts := strings.Split(string(tag), "-")
if len(tagParts) == 3 {
if ahead, err := semver.NewPRVersion(tagParts[1]); err == nil {
ahead, err := semver.NewPRVersion(tagParts[1])
if err == nil {
return tagParts[0], &ahead
}
log.Printf("semver.NewPRVersion(%s): %v", tagParts[1], err)
} else if len(tagParts) == 4 {
if ahead, err := semver.NewPRVersion(tagParts[2]); err == nil {
ahead, err := semver.NewPRVersion(tagParts[2])
if err == nil {
return tagParts[0] + "-" + tagParts[1], &ahead
}
log.Printf("semver.NewPRVersion(%s): %v", tagParts[2], err)
}
return string(tag), nil
@ -33,15 +38,12 @@ func getTag(match ...string) (string, *semver.PRVersion) {
}
func main() {
if tags, err := exec.Command("git", "tag").Output(); err != nil || len(tags) == 0 {
// no tags found -- fetch them
exec.Command("git", "fetch", "--tags").Run()
}
// Find the last vX.X.X Tag and get how many builds we are ahead of it.
versionStr, ahead := getTag("--match", "v*")
version, err := semver.ParseTolerant(versionStr)
if err != nil {
// no version tag found so just return what ever we can find.
log.Printf("semver.ParseTolerant(%s): %v", versionStr, err)
fmt.Println("0.0.0-unknown")
return
}
@ -66,6 +68,8 @@ func main() {
if pr, err := semver.NewPRVersion(tag); err == nil {
// append the tag as pre-release name
version.Pre = append(version.Pre, pr)
} else {
log.Printf("semver.NewPRVersion(%s): %v", tag, err)
}
if ahead != nil {