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()
|
2024-04-23 22:24:38 -06:00
|
|
|
ret := ncurses.StartColor()
|
2024-04-23 22:10:40 -06:00
|
|
|
if ret != 0 {
|
|
|
|
panic(ret)
|
|
|
|
}
|
2024-04-23 22:24:38 -06:00
|
|
|
|
|
|
|
ret = ncurses.InitColor(1, 1000, 0, 0)
|
|
|
|
if ret != 0 {
|
|
|
|
panic(ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = ncurses.InitColor(2, 0, 1000, 0)
|
|
|
|
if ret != 0 {
|
|
|
|
panic(ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = ncurses.InitPair(1, 1, 2)
|
|
|
|
if ret != 0 {
|
|
|
|
panic(ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
ncurses.WBkgd(window, ncurses.COLOR_PAIR(1))
|
|
|
|
|
|
|
|
ret = ncurses.IdlOK(window, true)
|
|
|
|
if ret != 0 {
|
|
|
|
panic(ret)
|
|
|
|
}
|
|
|
|
|
2024-04-23 22:10:40 -06:00
|
|
|
ret = ncurses.ScrollOk(window, true)
|
|
|
|
if ret != 0 {
|
|
|
|
panic(ret)
|
|
|
|
}
|
2024-04-23 22:24:38 -06:00
|
|
|
|
2024-04-23 22:10:40 -06:00
|
|
|
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:
|
2024-04-23 22:24:38 -06:00
|
|
|
for _, b := range(bytes) {
|
|
|
|
ncurses.WAddCh(window, uint32(b))
|
|
|
|
}
|
2024-04-23 22:10:40 -06:00
|
|
|
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
|
|
|
}
|