Пример #1
0
func update(s *state, stdscr *gc.Window) {
	stdscr.Clear()
	var last_found *section
	var ascii rune
	for i := 0; i < len(s.content); i++ {
		found := s.matches[i]
		if found != nil {
			last_found = found
			// Print the associated key instead of the real letter
			stdscr.AttrOn(gc.A_BOLD)
			for k, v := range s.index {
				if found == v {
					ascii = k
					break
				}
			}
			stdscr.Print(string(ascii))
			stdscr.AttrOff(gc.A_BOLD)
		} else {
			// Print the real letter, in bold if selected
			if last_found != nil && i >= last_found.begin && i <= last_found.end && strings.Contains(s.selected, string(ascii)) {
				stdscr.AttrOn(gc.A_BOLD)
			}
			ch := string(s.content[i])
			//			if (s.content[i] != '\n' ) {
			stdscr.Print(ch)
			//			}
			stdscr.AttrOff(gc.A_BOLD)
		}
	}

	//	row, _ := stdscr.MaxYX()
	//	stdscr.MovePrint(row - 1, 0, "selected = " + s.selected + "] >> ")
	stdscr.Refresh()
}
Пример #2
0
func printmenu(w *gc.Window, menu []string, active int) {
	y, x := 2, 2
	w.Box(0, 0)
	for i, s := range menu {
		if i == active {
			w.AttrOn(gc.A_REVERSE)
			w.MovePrint(y+i, x, s)
			w.AttrOff(gc.A_REVERSE)
		} else {
			w.MovePrint(y+i, x, s)
		}
	}
	w.Refresh()
}