diff --git a/cmd/micro/bindings.go b/cmd/micro/bindings.go index 39dc00a6..4e036453 100644 --- a/cmd/micro/bindings.go +++ b/cmd/micro/bindings.go @@ -48,6 +48,8 @@ func InitBindings() { "PageDown": PageDown, "HalfPageUp": HalfPageUp, "HalfPageDown": HalfPageDown, + "StartOfLine": StartOfLine, + "EndOfLine": EndOfLine, "ToggleRuler": ToggleRuler, } @@ -186,11 +188,14 @@ func InitBindings() { if _, e := os.Stat(filename); e == nil { input, err := ioutil.ReadFile(filename) if err != nil { - TermMessage("Error reading settings.json file: " + err.Error()) + TermMessage("Error reading bindings.json file: " + err.Error()) return } - json.Unmarshal(input, &parsed) + err = json.Unmarshal(input, &parsed) + if err != nil { + TermMessage("Error reading bindings.json:", err.Error()) + } } for k, v := range defaults { @@ -393,6 +398,8 @@ func Save(v *View) bool { return true } +// GoSave saves the current file (must be a go file) and runs goimports or gofmt +// depending on the user's configuration func GoSave(v *View) { if settings.GoImports == true { messenger.Message("Running goimports...") @@ -474,7 +481,7 @@ func Copy(v *View) bool { return true } -// AddCopy appends to the clipboard +// CutLine cuts the current line to the clipboard func CutLine(v *View) bool { v.cursor.SelectLine() if v.freshClip == true { @@ -622,6 +629,18 @@ func ToggleRuler(v *View) bool { return false } +// StartOfLine moves the cursor to the start of the line +func StartOfLine(v *View) bool { + v.cursor.Start() + return true +} + +// EndOfLine moves the cursor to the end of the line +func EndOfLine(v *View) bool { + v.cursor.End() + return true +} + // None is no action func None() bool { return false diff --git a/cmd/micro/messenger.go b/cmd/micro/messenger.go index 28b6431d..b66d4747 100644 --- a/cmd/micro/messenger.go +++ b/cmd/micro/messenger.go @@ -17,11 +17,20 @@ import ( // This will write the message, and wait for the user // to press and key to continue func TermMessage(msg ...interface{}) { + screenWasNil := screen == nil + if !screenWasNil { + screen.Fini() + } + fmt.Println(msg...) fmt.Print("\nPress enter to continue") reader := bufio.NewReader(os.Stdin) reader.ReadString('\n') + + if !screenWasNil { + InitScreen() + } } // TermError sends an error to the user in the terminal. Like TermMessage except formatted diff --git a/cmd/micro/settings.go b/cmd/micro/settings.go index 4f1a98b7..518083a0 100644 --- a/cmd/micro/settings.go +++ b/cmd/micro/settings.go @@ -36,7 +36,10 @@ func InitSettings() { return } - json.Unmarshal(input, &settings) + err = json.Unmarshal(input, &settings) + if err != nil { + TermMessage("Error reading settings.json:", err.Error()) + } } else { settings = DefaultSettings() err := WriteSettings(filename)