예제 #1
0
파일: termjt2.go 프로젝트: joetoth/termjt
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()
}