This commit is contained in:
Zachary Yedidia
2017-08-24 13:15:01 -04:00
8 changed files with 95 additions and 22 deletions

View File

@@ -4,6 +4,7 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/zyedidia/micro)](https://goreportcard.com/report/github.com/zyedidia/micro)
[![Join the chat at https://gitter.im/zyedidia/micro](https://badges.gitter.im/zyedidia/micro.svg)](https://gitter.im/zyedidia/micro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/zyedidia/micro/blob/master/LICENSE)
[![Snap Status](https://build.snapcraft.io/badge/zyedidia/micro.svg)](https://build.snapcraft.io/user/zyedidia/micro)
Micro is a terminal-based text editor that aims to be easy to use and intuitive, while also taking advantage of the full capabilities
of modern terminals. It comes as one single, batteries-included, static binary with no dependencies, and you can download and use it right now.

View File

@@ -249,7 +249,7 @@ func (v *View) CursorRight(usePlugin bool) bool {
}
if v.Cursor.HasSelection() {
v.Cursor.Loc = v.Cursor.CurSelection[1].Move(-1, v.Buf)
v.Cursor.Loc = v.Cursor.CurSelection[1]
v.Cursor.ResetSelection()
v.Cursor.StoreVisualX()
} else {
@@ -347,7 +347,7 @@ func (v *View) SelectLeft(usePlugin bool) bool {
}
loc := v.Cursor.Loc
count := v.Buf.End().Move(-1, v.Buf)
count := v.Buf.End()
if loc.GreaterThan(count) {
loc = count
}
@@ -370,7 +370,7 @@ func (v *View) SelectRight(usePlugin bool) bool {
}
loc := v.Cursor.Loc
count := v.Buf.End().Move(-1, v.Buf)
count := v.Buf.End()
if loc.GreaterThan(count) {
loc = count
}

View File

@@ -249,20 +249,20 @@ func (c *Cursor) RuneUnder(x int) rune {
func (c *Cursor) UpN(amount int) {
proposedY := c.Y - amount
if proposedY < 0 {
proposedY = 0
c.X = 0 // first line: X moved before the first character
return
} else if proposedY >= c.buf.NumLines {
proposedY = c.buf.NumLines - 1
}
if proposedY == c.Y {
return
runes := []rune(c.buf.Line(c.Y))
c.X = c.GetCharPosInLine(proposedY, c.LastVisualX)
if c.X > len(runes) || proposedY == c.Y {
c.X = len(runes)
}
c.Y = proposedY
runes := []rune(c.buf.Line(c.Y))
c.X = c.GetCharPosInLine(c.Y, c.LastVisualX)
if c.X > len(runes) {
c.X = len(runes)
}
}
// DownN moves the cursor down N lines (if possible)

File diff suppressed because one or more lines are too long

41
runtime/syntax/julia.yaml Normal file
View File

@@ -0,0 +1,41 @@
filetype: julia
detect:
filename: "\\.jl$"
header: "^#!.*/(env +)?julia( |$)"
rules:
# built-in objects
- constant.bool: "\\b(true|false)\\b"
# built-in attributes
- constant: "__[A-Za-z0-9_]+__"
# definitions
- identifier: "[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[(]"
# keywords
- statement: "\\b(begin|break|catch|continue|function|elseif|else|end|finally|for|global|local|if|include|using|require|macro|println|return|try|type|while|module)\\b"
# decorators
- identifier.macro: "@[A-Za-z0-9_]+"
# operators
- symbol.operator: "[-+*/|=%<>&~^]|\\b(and|not|or|is|in)\\b"
# parentheses
- symbol.brackets: "([(){}]|\\[|\\])"
# numbers
- constant.number: "\\b[0-9]+\\b"
- constant.string: "\"(\\\\.|[^\"])*\"|'(\\\\.|[^'])*'"
- constant.string:
start: "\"\"\""
end: "\"\"\""
rules: []
- constant.string:
start: "'''"
end: "'''"
rules: []
- comment:
start: "#"
end: "$"
rules: []

View File

@@ -1,7 +1,7 @@
filetype: ledger
detect:
filename: "(^|\\.|/)ledger|ldgr|beancount|bnct$"
filename: "(^|\\.|/)(ledger|ldgr|beancount|bnct)$"
rules:
- special: "^([0-9]{4}(/|-)[0-9]{2}(/|-)[0-9]{2}|[=~]) .*"

View File

@@ -15,16 +15,24 @@ func main() {
for _, f := range files {
if strings.HasSuffix(f.Name(), ".yaml") {
input, _ := ioutil.ReadFile(f.Name())
_, err := highlight.ParseDef(input)
//fmt.Println("Checking file -> ", f.Name())
file, err := highlight.ParseFile(input)
if err != nil {
hadErr = true
fmt.Printf("%s:\n", f.Name())
fmt.Printf("Could not parse file -> %s:\n", f.Name())
fmt.Println(err)
continue
}
_, err1 := highlight.ParseDef(file, nil)
if err1 != nil {
hadErr = true
fmt.Printf("Could not parse input file using highlight.ParseDef(%s):\n", f.Name())
fmt.Println(err1)
continue
}
}
}
if !hadErr {
fmt.Println("No issues!")
fmt.Println("No issues found!")
}
}

View File

@@ -15,16 +15,16 @@ rules:
- special: "(^---|^\\.\\.\\.|^%YAML|^%TAG)"
- constant.string:
start: "\""
start: "(^| )\""
end: "\""
skip: "\\\\."
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
start: "(^| )'"
end: "'"
skip: "\\\\."
skip: "(\\\\.)|('')"
rules:
- constant.specialChar: "\\\\."