]> git.lizzy.rs Git - micro.git/blob - cmd/micro/util/message.go
More actions and window organization
[micro.git] / cmd / micro / util / message.go
1 package util
2
3 import (
4         "bufio"
5         "fmt"
6         "os"
7         "strconv"
8
9         "github.com/zyedidia/micro/cmd/micro/screen"
10 )
11
12 // TermMessage sends a message to the user in the terminal. This usually occurs before
13 // micro has been fully initialized -- ie if there is an error in the syntax highlighting
14 // regular expressions
15 // The function must be called when the Screen is not initialized
16 // This will write the message, and wait for the user
17 // to press and key to continue
18 func TermMessage(msg ...interface{}) {
19         screen.TempFini()
20
21         fmt.Println(msg...)
22         fmt.Print("\nPress enter to continue")
23
24         reader := bufio.NewReader(os.Stdin)
25         reader.ReadString('\n')
26
27         screen.TempStart()
28 }
29
30 // TermError sends an error to the user in the terminal. Like TermMessage except formatted
31 // as an error
32 func TermError(filename string, lineNum int, err string) {
33         TermMessage(filename + ", " + strconv.Itoa(lineNum) + ": " + err)
34 }