Esempio n. 1
0
func (v *CursesView) initCursesColors() (err error) {
	if v.colored = cur.HasColors(); !v.colored {
		return
	}
	if err := cur.StartColor(); err != nil {
		log.Print(err)
	}
	if err := cur.UseDefaultColors(); err != nil {
		log.Print(err)
	}

	colorMap := []int16{
		cur.C_WHITE,
		cur.C_BLUE,
		cur.C_GREEN,
		cur.C_YELLOW,
		cur.C_CYAN,
		cur.C_RED,
	}
	for i, c := range colorMap {

		if e := cur.InitPair(int16(i), c, cur.C_BLACK); e != nil {
			log.Printf("InitPair(%d, %v, %v) failed: %v", i, colorMap[i], cur.C_BLACK, e)
		}
		if e := cur.InitPair(int16(i+len(colorMap)), cur.C_BLACK, colorMap[i]); e != nil {
			log.Printf("InitPair(%d, %v, %v) failed: %v", i, colorMap[i], cur.C_BLACK, e)
		}
	}
	return
}
Esempio n. 2
0
func (ui *NcurseUi) initColors() {
	if goncurses.HasColors() {
		err := goncurses.StartColor()
		HandleErr(err)

		goncurses.UseDefaultColors()

		//Main window
		goncurses.InitPair(1, goncurses.C_WHITE, -1)
		goncurses.InitPair(2, goncurses.C_RED, -1)
		goncurses.InitPair(3, goncurses.C_GREEN, -1)
		goncurses.InitPair(4, goncurses.C_CYAN, -1)

		//Title colors
		goncurses.InitPair(10, goncurses.C_BLACK, goncurses.C_BLUE)

		//Menu colors
		goncurses.InitPair(20, goncurses.C_YELLOW, -1)
	}
}