2024-04-23 14:15:28 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-04-23 22:10:40 -06:00
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
"syscall"
|
2024-04-23 14:15:28 -06:00
|
|
|
|
|
|
|
"git.metznet.ca/MetzNet/go-ncurses"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2024-04-23 22:10:40 -06:00
|
|
|
ncurses.SetLocale(0, "")
|
|
|
|
input, input_active := ncurses.UTF8Listener(100, os.Stdin)
|
2024-04-23 14:15:28 -06:00
|
|
|
|
2024-04-23 22:10:40 -06:00
|
|
|
os_sigs := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(os_sigs, syscall.SIGINT, syscall.SIGABRT)
|
2024-04-23 14:15:28 -06:00
|
|
|
|
2024-04-23 22:10:40 -06:00
|
|
|
window := ncurses.InitScr()
|
|
|
|
ret := ncurses.IdlOK(window, true)
|
|
|
|
if ret != 0 {
|
|
|
|
panic(ret)
|
|
|
|
}
|
|
|
|
ret = ncurses.ScrollOk(window, true)
|
|
|
|
if ret != 0 {
|
|
|
|
panic(ret)
|
|
|
|
}
|
|
|
|
ncurses.WRefresh(window)
|
2024-04-23 14:15:28 -06:00
|
|
|
|
2024-04-23 22:10:40 -06:00
|
|
|
active := true
|
|
|
|
for active {
|
|
|
|
select {
|
|
|
|
case bytes := <-input:
|
|
|
|
ncurses.WAddStr(window, string(bytes))
|
|
|
|
ncurses.WRefresh(window)
|
|
|
|
case <-os_sigs:
|
|
|
|
active = false
|
|
|
|
}
|
|
|
|
}
|
2024-04-23 14:15:28 -06:00
|
|
|
|
2024-04-23 22:10:40 -06:00
|
|
|
ncurses.EndWin()
|
|
|
|
input_active.Store(false)
|
|
|
|
close(input)
|
2024-04-23 14:15:28 -06:00
|
|
|
}
|