예제 #1
0
func tagMessages(mb *MessageBase) {
	tagged := currentlyTagged(mb)
	done := false
	cursor := 0
	m := len(mb.msgs)

	for !done {
		drawTagMenu(mb, tagged, cursor)
		sel := console.WaitAscii()
		switch sel {
		case 'X', 'x':
			done = true
		case 'W', 'w':
			done = true
			mb.tagged = tagged
		case 'J', 'j':
			if (cursor + 1) < m {
				cursor++
			}
		case 'K', 'k':
			if cursor > 0 {
				cursor--
			}
		case ' ':
			s := mb.msgs[cursor]
			tagged[s] = !tagged[s]
		}
	}
}
예제 #2
0
func editMessage(title, appTitle string, m *Message) (commit bool) {
	t := new(Message)
	*t = *m
	done := false
	for !done {
		drawEditMenu(title, appTitle, t)
		sel := console.WaitAscii()
		switch sel {
		case 'N', 'n':
			t.Name = editName(t.Name)
		case 'D', 'd':
			t.Description = editDesc(t.Description)
		case 'X', 'x':
			done = true
		case 'W', 'w':
			if strings.TrimSpace(t.Name) != "" {
				done = true
				*m = *t
				commit = true
			}
		case 'G', 'g':
			t.Globals = editTextArea(t.Globals)
		case 'P', 'p':
			t.Procedure = editTextArea(t.Procedure)
		}
	}
	return
}
예제 #3
0
func messageList(title, appTitle string, mb *MessageBase) {
	done := false
	for !done {
		drawListMenu(title+" List", appTitle, mb)
		sel := console.WaitAscii()
		switch sel {
		case 'X', 'x':
			done = true
		case 'C', 'c':
			createMessage(title, appTitle, mb)
		case 'U', 'u':
			mb.tagged = make(map[*Message]bool)
		case 'T', 't':
			tagMessages(mb)
		case 'D', 'd':
			deleteTagged(mb)
		case 'E', 'e':
			for m, _ := range mb.tagged {
				editMessage(title, appTitle, m)
			}
		}
	}
}
예제 #4
0
func main() {
	err := termbox.Init()
	if err != nil {
		panic(err)
	}
	defer termbox.Close()

	stimuli = NewBase()
	responses = NewBase()

	done := false
	for !done {
		drawMainMenu()
		sel := console.WaitAscii()
		switch sel {
		case 'X', 'x':
			done = true
		case 'S', 's':
			messageList("Stimulus", kAppTitle, stimuli)
		case 'R', 'r':
			messageList("Response", kAppTitle, responses)
		}
	}
}