2021-03-18 16:30:04 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-03-30 18:29:23 -04:00
|
|
|
"os"
|
2021-04-07 13:10:40 -04:00
|
|
|
"timshome.page/gilo/editor"
|
|
|
|
"timshome.page/gilo/terminal"
|
2021-03-18 16:30:04 -04:00
|
|
|
)
|
|
|
|
|
2021-03-19 12:46:43 -04:00
|
|
|
func main() {
|
2021-03-19 16:39:49 -04:00
|
|
|
// Go to proper raw mode, but restore canonical mode at exit
|
|
|
|
oldState := terminal.RawOn()
|
2023-10-04 15:09:04 -04:00
|
|
|
defer terminal.RawOff(oldState)
|
2021-03-18 19:15:19 -04:00
|
|
|
|
2021-04-02 15:36:43 -04:00
|
|
|
e := editor.NewEditor()
|
2021-03-30 18:29:23 -04:00
|
|
|
|
|
|
|
// If there is an argument passed, open it as a file to edit
|
|
|
|
if len(os.Args) >= 2 && os.Args[1] != "" {
|
|
|
|
e.Open(os.Args[1])
|
|
|
|
}
|
2021-03-24 14:17:29 -04:00
|
|
|
|
2021-04-06 10:59:24 -04:00
|
|
|
e.SetStatusMessage("HELP: Ctrl-S = save | Ctrl-Q = quit | Ctrl-F = find")
|
2021-04-01 13:25:59 -04:00
|
|
|
|
2021-03-19 17:39:15 -04:00
|
|
|
// The input loop
|
2021-03-22 09:12:39 -04:00
|
|
|
for {
|
2021-03-24 14:17:29 -04:00
|
|
|
e.RefreshScreen()
|
2021-03-22 09:12:39 -04:00
|
|
|
|
2021-03-24 14:17:29 -04:00
|
|
|
if e.ProcessKeypress() == false {
|
2021-03-22 09:12:39 -04:00
|
|
|
break
|
|
|
|
}
|
2021-03-18 19:15:19 -04:00
|
|
|
}
|
2021-03-18 16:30:04 -04:00
|
|
|
}
|