Add options

This commit is contained in:
Zachary Yedidia
2016-03-26 10:54:18 -04:00
parent 70590d5e28
commit b32f0eb94f
8 changed files with 88 additions and 33 deletions

View File

@@ -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)
}
}