Пример #1
0
func SendBoxEvents(p *ui.Par) {

	ui.Handle("/sys/kbd/<enter>", func(e ui.Event) {
		Input <- p.Text
		p.Text = ""
		ui.Render(ui.Body)
	})

	ui.Handle("/sys/kbd/<space>", func(e ui.Event) {
		p.Text += " "
		ui.Render(ui.Body)
	})

	ui.Handle("/sys/kbd/C-8", func(e ui.Event) {
		if len(p.Text) > 0 {
			p.Text = p.Text[:len(p.Text)-1]
			ui.Render(ui.Body)
		}
	})

	ui.Handle("/sys/kbd", func(e ui.Event) {
		char := e.Data.(ui.EvtKbd).KeyStr
		p.Text += char
		ui.Render(ui.Body)
	})

}
Пример #2
0
// updateFooter updates the footer contents based on any encountered errors.
func updateFooter(ctx *cli.Context, err error, footer *termui.Par) {
	// Generate the basic footer
	refresh := time.Duration(ctx.Int(monitorCommandRefreshFlag.Name)) * time.Second
	footer.Text = fmt.Sprintf("Press Ctrl+C to quit. Refresh interval: %v.", refresh)
	footer.TextFgColor = termui.Theme().ParTextFg | termui.AttrBold

	// Append any encountered errors
	if err != nil {
		footer.Text = fmt.Sprintf("Error: %v.", err)
		footer.TextFgColor = termui.ColorRed | termui.AttrBold
	}
}
Пример #3
0
func updateUptime(p *ui.Par) {
	for {
		<-time.After(2 * daemon.Delay)
		ut, _ := daemon.Uptime()
		p.Text = ut.String()
		ui.Render(ui.Body)
	}
}
Пример #4
0
func ReadReceives(p *ui.Par) {
  for {
    NItems += 1
    if NItems >= ReceiveBoxHeight {
      ScrollReceiveBox(p)
    }
    msg := <-Display
    if msg.Type == SENDING {
      p.Text += fmt.Sprintf(" -> %v\n", msg.Message)
    } else if msg.Type == RECEIVING {
      p.Text += fmt.Sprintf(" <- %v\n", msg.Message)
    } else if msg.Type == ERROR {
      p.Text += fmt.Sprintf(" !! %v\n", msg.Message)
    } else if msg.Type == COMMAND {
      p.Text += fmt.Sprintf(" <> %v\n", msg.Message)
    }
    ui.Render(ui.Body)
  }
}
func jenkinsPoll(jenkins *gojenkins.Jenkins, infobox *ui.Par, ls *ui.List, redbox *ui.Par, yellowbox *ui.Par, greenbox *ui.Par) {
	defer func() {
		if r := recover(); r != nil {
			infobox.Border.FgColor = ui.ColorRed
			//err := fmt.Errorf("%v", r)
			infobox.Text += " : /!\\ Jenkins is currently unreachable"
		}
	}()
	const layout = "Mon Jan 2 15:04:05"
	infobox.Border.FgColor = ui.ColorWhite
	infobox.Text = "Refresh at " + time.Now().Format(layout)
	jenkins.Poll()
	jobs, err := jenkins.GetAllJobs()
	if err != nil {
		infobox.Text = "Error with getAllJobs " + fmt.Sprintf("%s", err)
	}
	for _, k := range jobs {
		addJob(ls, k, redbox, yellowbox, greenbox)
	}
}
Пример #6
0
func ScrollReceiveBox(p *ui.Par) {
  sp := strings.Split(p.Text, "\n")
  p.Text = strings.Join(sp[1:], "\n")
}