2024-04-23 14:15:28 -06:00
|
|
|
package ncurses
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ebitengine/purego"
|
|
|
|
)
|
|
|
|
|
2024-04-23 22:10:40 -06:00
|
|
|
var ncurses uintptr = 0
|
2024-04-23 15:05:01 -06:00
|
|
|
func ncursesFunction[T any](name string) T {
|
2024-04-23 22:10:40 -06:00
|
|
|
if ncurses == 0 {
|
|
|
|
var err error
|
|
|
|
ncurses, err = purego.Dlopen(LIBRARY_PATH, purego.RTLD_GLOBAL | purego.RTLD_LAZY)
|
2024-04-23 14:15:28 -06:00
|
|
|
if err != nil {
|
2024-04-23 15:05:01 -06:00
|
|
|
panic(err)
|
2024-04-23 14:15:28 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-23 15:05:01 -06:00
|
|
|
var tmp = new(T)
|
2024-04-23 22:10:40 -06:00
|
|
|
purego.RegisterLibFunc(tmp, ncurses, name)
|
2024-04-23 15:05:01 -06:00
|
|
|
return *tmp
|
2024-04-23 14:15:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
type Window uintptr
|
|
|
|
|
|
|
|
type voidFP func() int
|
|
|
|
type winFP func(window Window) int
|
|
|
|
|
|
|
|
type initscrFP func() Window
|
2024-04-23 15:05:01 -06:00
|
|
|
var InitScr = ncursesFunction[initscrFP]("initscr")
|
|
|
|
var EndWin = ncursesFunction[voidFP]("endwin")
|
2024-04-23 14:15:28 -06:00
|
|
|
|
|
|
|
type newwinFP func(nlines, ncols, begin_x, begin_y int) Window
|
2024-04-23 15:05:01 -06:00
|
|
|
var NewWin = ncursesFunction[newwinFP]("newwin")
|
|
|
|
var DelWin = ncursesFunction[winFP]("delwin")
|
2024-04-23 14:15:28 -06:00
|
|
|
type dupwinFP func(window Window) Window
|
2024-04-23 15:05:01 -06:00
|
|
|
var DupWin = ncursesFunction[dupwinFP]("dupwin")
|
2024-04-23 14:15:28 -06:00
|
|
|
|
2024-04-23 15:05:01 -06:00
|
|
|
var Refresh = ncursesFunction[voidFP]("refresh")
|
|
|
|
var WRefresh = ncursesFunction[winFP]("wrefresh")
|
|
|
|
var WNOutRefresh = ncursesFunction[winFP]("wnoutrefresh")
|
|
|
|
var DoUpdate = ncursesFunction[voidFP]("doupdate")
|
2024-04-23 14:15:28 -06:00
|
|
|
|
|
|
|
type waddstrFP func(window Window, str string) int
|
2024-04-23 15:05:01 -06:00
|
|
|
var WAddStr = ncursesFunction[waddstrFP]("waddstr")
|
2024-04-23 14:15:28 -06:00
|
|
|
|
|
|
|
type waddnstrFP func(window Window, str string, n int) int
|
2024-04-23 15:05:01 -06:00
|
|
|
var WAddNStr = ncursesFunction[waddstrFP]("waddnstr")
|
2024-04-23 14:15:28 -06:00
|
|
|
|
2024-04-23 15:05:01 -06:00
|
|
|
var GetMaxY = ncursesFunction[winFP]("getmaxy")
|
|
|
|
var GetMaxX = ncursesFunction[winFP]("getmaxx")
|
2024-04-23 14:15:28 -06:00
|
|
|
|
2024-04-23 22:10:40 -06:00
|
|
|
type mvwaddstrFP func(window Window, y, x int, str string) int
|
2024-04-23 15:05:01 -06:00
|
|
|
var MvWAddStr = ncursesFunction[mvwaddstrFP]("mvwaddstr")
|
2024-04-23 22:10:40 -06:00
|
|
|
|
|
|
|
type mvwaddchFP func(window Window, y, x int, char rune) int
|
|
|
|
var MvWAddCh = ncursesFunction[mvwaddchFP]("mvwaddch")
|
|
|
|
|
|
|
|
type waddchFP func(window Window, char rune) int
|
|
|
|
var WAddCh = ncursesFunction[waddchFP]("waddch")
|
|
|
|
|
|
|
|
type init_colorFP func(color, r, g, b int16) int
|
|
|
|
var InitColor = ncursesFunction[init_colorFP]("init_color")
|
|
|
|
|
|
|
|
type init_pairFP func(pair, fg, bg int16) int
|
|
|
|
var InitPair = ncursesFunction[init_pairFP]("init_pair")
|
|
|
|
|
|
|
|
var StartColor = ncursesFunction[voidFP]("start_color")
|
|
|
|
|
|
|
|
type checkFP func() bool
|
|
|
|
var HasColors = ncursesFunction[checkFP]("has_colors")
|
|
|
|
|
|
|
|
type setflagFP func(window Window, bf bool) int
|
|
|
|
var ClearOK = ncursesFunction[setflagFP]("clearok")
|
|
|
|
var IdlOK = ncursesFunction[setflagFP]("idlok")
|
|
|
|
var ScrollOk = ncursesFunction[setflagFP]("scrollok")
|
|
|
|
|
|
|
|
type wscrlFP func(window Window, n int) int
|
|
|
|
var WScrl = ncursesFunction[wscrlFP]("wscrl")
|
|
|
|
|