mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-11 15:12:47 +09:00
Update todolist, and readme
Add binaries to readme and a screenshot of micro.
This commit is contained in:
@@ -29,7 +29,7 @@ type Buffer struct {
|
||||
|
||||
// Syntax highlighting rules
|
||||
rules []SyntaxRule
|
||||
// File type of the buffer
|
||||
// The buffer's filetype
|
||||
filetype string
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ func ParseColorscheme(text string) Colorscheme {
|
||||
// The 'extra' can be bold, reverse, or underline
|
||||
func StringToStyle(str string) tcell.Style {
|
||||
var fg string
|
||||
var bg string
|
||||
bg := "default"
|
||||
split := strings.Split(str, ",")
|
||||
if len(split) > 1 {
|
||||
fg, bg = split[0], split[1]
|
||||
|
||||
@@ -16,6 +16,8 @@ Ctrl-o: Open file
|
||||
Ctrl-z: Undo
|
||||
Ctrl-y: Redo
|
||||
|
||||
Ctrl-f: Find
|
||||
|
||||
Ctrl-a: Select all
|
||||
|
||||
Ctrl-c: Copy
|
||||
@@ -35,6 +37,11 @@ Possible commands:
|
||||
|
||||
'quit': Quits micro
|
||||
'save': saves the current buffer
|
||||
|
||||
'replace "search" "value"': This will replace 'search' with 'value'.
|
||||
Note that 'search' must be a valid regex. If one of the arguments
|
||||
does not have any spaces in it, you may omit the quotes.
|
||||
|
||||
'set option value': sets the option to value. Please see the next section for a list of options you can set
|
||||
|
||||
Micro options:
|
||||
@@ -66,7 +73,7 @@ func DisplayHelp() {
|
||||
lines := totalLines[topline:lineEnd]
|
||||
for y, line := range lines {
|
||||
for x, ch := range line {
|
||||
st := tcell.StyleDefault
|
||||
st := defStyle
|
||||
screen.SetContent(x, y, ch, nil, st)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ func LoadSyntaxFile(filename string) {
|
||||
// The user could give us a "color" that is really a part of the colorscheme
|
||||
// in which case we should look that up in the colorscheme
|
||||
// They can also just give us a straight up color
|
||||
st := tcell.StyleDefault
|
||||
st := defStyle
|
||||
if _, ok := colorscheme[color]; ok {
|
||||
st = colorscheme[color]
|
||||
} else {
|
||||
@@ -201,7 +201,7 @@ func LoadSyntaxFile(filename string) {
|
||||
// The user could give us a "color" that is really a part of the colorscheme
|
||||
// in which case we should look that up in the colorscheme
|
||||
// They can also just give us a straight up color
|
||||
st := tcell.StyleDefault
|
||||
st := defStyle
|
||||
if _, ok := colorscheme[color]; ok {
|
||||
st = colorscheme[color]
|
||||
} else {
|
||||
|
||||
@@ -50,7 +50,7 @@ type Messenger struct {
|
||||
// Message sends a message to the user
|
||||
func (m *Messenger) Message(msg string) {
|
||||
m.message = msg
|
||||
m.style = tcell.StyleDefault
|
||||
m.style = defStyle
|
||||
|
||||
if _, ok := colorscheme["message"]; ok {
|
||||
m.style = colorscheme["message"]
|
||||
@@ -61,7 +61,7 @@ func (m *Messenger) Message(msg string) {
|
||||
// Error sends an error message to the user
|
||||
func (m *Messenger) Error(msg string) {
|
||||
m.message = msg
|
||||
m.style = tcell.StyleDefault.
|
||||
m.style = defStyle.
|
||||
Foreground(tcell.ColorBlack).
|
||||
Background(tcell.ColorMaroon)
|
||||
|
||||
@@ -172,7 +172,7 @@ func (m *Messenger) Reset() {
|
||||
func (m *Messenger) Clear() {
|
||||
w, h := screen.Size()
|
||||
for x := 0; x < w; x++ {
|
||||
screen.SetContent(x, h-1, ' ', nil, tcell.StyleDefault)
|
||||
screen.SetContent(x, h-1, ' ', nil, defStyle)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
15
src/micro.go
15
src/micro.go
@@ -23,8 +23,11 @@ var (
|
||||
// Object to send messages and prompts to the user
|
||||
messenger *Messenger
|
||||
|
||||
redrawStatus int
|
||||
searching bool
|
||||
// Is there currently a search in progress
|
||||
searching bool
|
||||
|
||||
// The default style
|
||||
defStyle tcell.Style
|
||||
)
|
||||
|
||||
// LoadInput loads the file input for the editor
|
||||
@@ -72,6 +75,9 @@ func main() {
|
||||
|
||||
InitSettings()
|
||||
|
||||
// Load the syntax files, including the colorscheme
|
||||
LoadSyntaxFiles()
|
||||
|
||||
// Should we enable true color?
|
||||
truecolor := os.Getenv("MICRO_TRUECOLOR") == "1"
|
||||
|
||||
@@ -82,9 +88,6 @@ func main() {
|
||||
os.Setenv("TERM", "xterm-truecolor")
|
||||
}
|
||||
|
||||
// Load the syntax files, including the colorscheme
|
||||
LoadSyntaxFiles()
|
||||
|
||||
// Initilize tcell
|
||||
screen, err = tcell.NewScreen()
|
||||
if err != nil {
|
||||
@@ -114,7 +117,7 @@ func main() {
|
||||
}()
|
||||
|
||||
// Default style
|
||||
defStyle := tcell.StyleDefault.
|
||||
defStyle = tcell.StyleDefault.
|
||||
Foreground(tcell.ColorDefault).
|
||||
Background(tcell.ColorDefault)
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gdamore/tcell"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
@@ -43,7 +42,7 @@ func (sline *Statusline) Display() {
|
||||
|
||||
centerText := "Press Ctrl-h for help"
|
||||
|
||||
statusLineStyle := tcell.StyleDefault.Reverse(true)
|
||||
statusLineStyle := defStyle.Reverse(true)
|
||||
if style, ok := colorscheme["statusline"]; ok {
|
||||
statusLineStyle = style
|
||||
}
|
||||
|
||||
28
src/view.go
28
src/view.go
@@ -10,8 +10,8 @@ import (
|
||||
)
|
||||
|
||||
// The View struct stores information about a view into a buffer.
|
||||
// It has a value for the cursor, and the window that the user sees
|
||||
// the buffer from.
|
||||
// It has a stores information about the cursor, and the viewport
|
||||
// that the user sees the buffer from.
|
||||
type View struct {
|
||||
cursor Cursor
|
||||
|
||||
@@ -356,18 +356,26 @@ func (v *View) HandleEvent(event tcell.Event) {
|
||||
switch e.Key() {
|
||||
case tcell.KeyUp:
|
||||
// Cursor up
|
||||
v.cursor.ResetSelection()
|
||||
v.cursor.Up()
|
||||
case tcell.KeyDown:
|
||||
// Cursor down
|
||||
v.cursor.ResetSelection()
|
||||
v.cursor.Down()
|
||||
case tcell.KeyLeft:
|
||||
// Cursor left
|
||||
v.cursor.ResetSelection()
|
||||
v.cursor.Left()
|
||||
case tcell.KeyRight:
|
||||
// Cursor right
|
||||
v.cursor.ResetSelection()
|
||||
v.cursor.Right()
|
||||
case tcell.KeyEnter:
|
||||
// Insert a newline
|
||||
if v.cursor.HasSelection() {
|
||||
v.cursor.DeleteSelection()
|
||||
v.cursor.ResetSelection()
|
||||
}
|
||||
v.eh.Insert(v.cursor.Loc(), "\n")
|
||||
v.cursor.Right()
|
||||
// Rehighlight the entire buffer
|
||||
@@ -376,6 +384,10 @@ func (v *View) HandleEvent(event tcell.Event) {
|
||||
// v.UpdateLines(v.cursor.y-1, v.cursor.y)
|
||||
case tcell.KeySpace:
|
||||
// Insert a space
|
||||
if v.cursor.HasSelection() {
|
||||
v.cursor.DeleteSelection()
|
||||
v.cursor.ResetSelection()
|
||||
}
|
||||
v.eh.Insert(v.cursor.Loc(), " ")
|
||||
v.cursor.Right()
|
||||
v.UpdateLines(v.cursor.y, v.cursor.y)
|
||||
@@ -405,6 +417,10 @@ func (v *View) HandleEvent(event tcell.Event) {
|
||||
v.cursor.lastVisualX = v.cursor.GetVisualX()
|
||||
case tcell.KeyTab:
|
||||
// Insert a tab
|
||||
if v.cursor.HasSelection() {
|
||||
v.cursor.DeleteSelection()
|
||||
v.cursor.ResetSelection()
|
||||
}
|
||||
v.eh.Insert(v.cursor.Loc(), "\t")
|
||||
v.cursor.Right()
|
||||
v.UpdateLines(v.cursor.y, v.cursor.y)
|
||||
@@ -600,7 +616,7 @@ func (v *View) DisplayView() {
|
||||
line := v.buf.lines[lineN+v.topline]
|
||||
|
||||
// Write the line number
|
||||
lineNumStyle := tcell.StyleDefault
|
||||
lineNumStyle := defStyle
|
||||
if style, ok := colorscheme["line-number"]; ok {
|
||||
lineNumStyle = style
|
||||
}
|
||||
@@ -637,14 +653,14 @@ func (v *View) DisplayView() {
|
||||
// } else if lineN < len(v.lastMatches) && colN < len(v.lastMatches[lineN]) {
|
||||
// highlightStyle = v.lastMatches[lineN][colN]
|
||||
// } else {
|
||||
// highlightStyle = tcell.StyleDefault
|
||||
// highlightStyle = defStyle
|
||||
// }
|
||||
|
||||
if v.cursor.HasSelection() &&
|
||||
(charNum >= v.cursor.curSelection[0] && charNum < v.cursor.curSelection[1] ||
|
||||
charNum < v.cursor.curSelection[0] && charNum >= v.cursor.curSelection[1]) {
|
||||
|
||||
lineStyle = tcell.StyleDefault.Reverse(true)
|
||||
lineStyle = defStyle.Reverse(true)
|
||||
|
||||
if style, ok := colorscheme["selection"]; ok {
|
||||
lineStyle = style
|
||||
@@ -679,7 +695,7 @@ func (v *View) DisplayView() {
|
||||
(charNum >= v.cursor.curSelection[0] && charNum < v.cursor.curSelection[1] ||
|
||||
charNum < v.cursor.curSelection[0] && charNum >= v.cursor.curSelection[1]) {
|
||||
|
||||
selectStyle := tcell.StyleDefault.Reverse(true)
|
||||
selectStyle := defStyle.Reverse(true)
|
||||
|
||||
if style, ok := colorscheme["selection"]; ok {
|
||||
selectStyle = style
|
||||
|
||||
Reference in New Issue
Block a user