Esempio n. 1
0
func (ui *UserInterface) SetInputField(prompt, deftext, endevent string, show_rem bool) {
	pos := strconv.Itoa(utf8.RuneCountInString(deftext))
	buf := bytes.NewBufferString("{hbox[lastline] @style_normal[style_input]: .expand:0 ")
	if show_rem {
		buf.WriteString("{label .tie:r .expand:0 text[remaining]:\"\" style_normal[remaining_style]:fg=white}{label .expand:0 text:\"| \"}")
	}
	buf.WriteString("{label .expand:0 text[prompt]:")
	buf.WriteString(stfl.Quote(prompt))
	buf.WriteString("}{!input[tweetinput] on_ESC:cancel-input on_ENTER:")
	buf.WriteString(endevent)
	buf.WriteString(" modal:1 .expand:h text[inputfield]:")
	buf.WriteString(stfl.Quote(deftext))
	buf.WriteString(" pos[inputpos]:0 offset:0}}")

	ui.form.Modify("lastline", "replace", string(buf.Bytes()))
	ui.form.Run(-1)
	ui.form.Set("inputpos", pos)
	ui.UpdateRemaining()
}
Esempio n. 2
0
func (ui *UserInterface) addTweets(tweets []*Tweet) {
	buf := bytes.NewBufferString("{list")

	for _, t := range tweets {
		tweetline := fmt.Sprintf("[%16s] %s", "@"+*t.User.Screen_name, html.UnescapeString(strings.Replace(strings.Replace(*t.Text, "\n", " ", -1), "\r", " ", -1)))
		tweetline = strings.Replace(tweetline, "<", "<>", -1)
		tweetline = ui.highlight(tweetline)
		buf.WriteString(fmt.Sprintf("{listitem[%d] text:%v}", *t.Id, stfl.Quote(tweetline)))
	}

	buf.WriteString("}")
	ui.form.Modify("tweets", "insert_inner", string(buf.Bytes()))
}