mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-29 06:12:35 +09:00
Add options
This commit is contained in:
15
src/micro.go
15
src/micro.go
@@ -10,7 +10,6 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
tabSize = 4 // This should be configurable
|
||||
synLinesUp = 75 // How many lines up to look to do syntax highlighting
|
||||
synLinesDown = 75 // How many lines down to look to do syntax highlighting
|
||||
)
|
||||
@@ -18,6 +17,9 @@ const (
|
||||
// The main screen
|
||||
var screen tcell.Screen
|
||||
|
||||
// Object to send messages and prompts to the user
|
||||
var messenger *Messenger
|
||||
|
||||
// LoadInput loads the file input for the editor
|
||||
func LoadInput() (string, []byte, error) {
|
||||
// There are a number of ways micro should start given its input
|
||||
@@ -61,6 +63,8 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
InitOptions()
|
||||
|
||||
// Should we enable true color?
|
||||
truecolor := os.Getenv("MICRO_TRUECOLOR") == "1"
|
||||
|
||||
@@ -115,8 +119,8 @@ func main() {
|
||||
screen.SetStyle(defStyle)
|
||||
screen.EnableMouse()
|
||||
|
||||
messenger := new(Messenger)
|
||||
view := NewView(NewBuffer(string(input), filename), messenger)
|
||||
messenger = new(Messenger)
|
||||
view := NewView(NewBuffer(string(input), filename))
|
||||
|
||||
for {
|
||||
// Display everything
|
||||
@@ -133,12 +137,15 @@ func main() {
|
||||
// Check if we should quit
|
||||
switch e := event.(type) {
|
||||
case *tcell.EventKey:
|
||||
if e.Key() == tcell.KeyCtrlQ {
|
||||
switch e.Key() {
|
||||
case tcell.KeyCtrlQ:
|
||||
// Make sure not to quit if there are unsaved changes
|
||||
if view.CanClose("Quit anyway? ") {
|
||||
screen.Fini()
|
||||
os.Exit(0)
|
||||
}
|
||||
case tcell.KeyCtrlE:
|
||||
SetOption(view)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user