Ejemplo n.º 1
0
func NewUserInterface(cc chan<- interface{}, tc <-chan []*Tweet, lc chan<- TweetRequest, uac chan interface{}, cfg *goconf.ConfigFile) *UserInterface {
	stfl.Init()
	ui := &UserInterface{
		form: stfl.Create(`vbox[root]
  @style_normal[style_background]:
  hbox
    .expand:0
    label text[userlist]:"" .expand:h style_normal[style_userlist]:bg=blue,fg=yellow,attr=bold richtext:1 style_s_normal[style_userlist_active]:bg=white,fg=blue,attr=bold
  vbox
    .expand:vh
    list[tweets]
      ** just a place holder to be filled by constructTweetList()
  vbox
    .expand:0
    .display:1
    hbox
      @style_normal[style_infotext]:bg=blue,fg=yellow,attr=bold
      label text[infoline]:">> " .expand:h
      label text[program]:"" .expand:0
    label text[shorthelp]:"q:Quit ENTER:New Tweet ^R:Retweet r:Reply R:Public Reply ^F:Favorite D:Delete" .expand:h style_normal[style_shorthelp]:bg=blue,fg=white,attr=bold
  hbox[lastline]
    .expand:0
    label text[msg]:"" .expand:h
`),
		actionchan:            uac,
		tweetchan:             tc,
		cmdchan:               cc,
		in_reply_to_status_id: 0,
		lookupchan:            lc,
		cfg:                   cfg,
		highlight_rx:          []*regexp.Regexp{},
		users:                 []string{},
		cur_user:              0,
		confirm_quit:          false,
	}
	ui.constructTweetList()
	ui.setColors()
	ui.form.Set("program", " "+PROGRAM_NAME+" "+PROGRAM_VERSION)

	if ui.cfg != nil {
		if confirm_quit, err := ui.cfg.GetBool("default", "confirm_quit"); err == nil {
			ui.confirm_quit = confirm_quit
		}
	}

	return ui
}
Ejemplo n.º 2
0
func main() {
	f := stfl.Create("<example.stfl>")

	f.Set("value_a", "This is a little")
	f.Set("value_b", "test for STFL!")

	event := ""
	for event != "ESC" {
		event = f.Run(0)
	}

	stfl.Reset()

	fmt.Printf("A: %s\n", f.Get("value_a"))
	fmt.Printf("B: %s\n", f.Get("value_b"))
	fmt.Printf("C: %s\n", f.Get("value_c"))
}