Esempio n. 1
0
File: tui.go Progetto: ymomoi/vuls
// RunTui execute main logic
func RunTui(history models.ScanHistory) subcommands.ExitStatus {
	scanHistory = history

	g, err := gocui.NewGui(gocui.OutputNormal)
	if err != nil {
		log.Errorf("%s", err)
		return subcommands.ExitFailure
	}
	defer g.Close()

	g.SetManagerFunc(layout)
	if err := keybindings(g); err != nil {
		log.Errorf("%s", err)
		return subcommands.ExitFailure
	}
	g.SelBgColor = gocui.ColorGreen
	g.SelFgColor = gocui.ColorBlack
	g.Cursor = true

	if err := g.MainLoop(); err != nil {
		g.Close()
		log.Errorf("%s", err)
		os.Exit(1)
	}
	return subcommands.ExitSuccess
}
Esempio n. 2
0
func main() {
	g, err := gocui.NewGui(gocui.OutputNormal)
	if err != nil {
		log.Panicln(err)
	}
	defer g.Close()

	g.Highlight = true
	g.SelFgColor = gocui.ColorRed

	help := NewHelpWidget("help", 1, 1, helpText)
	status := NewStatusbarWidget("status", 1, 7, 50)
	butdown := NewButtonWidget("butdown", 52, 7, "DOWN", statusDown(status))
	butup := NewButtonWidget("butup", 58, 7, "UP", statusUp(status))
	g.SetManager(help, status, butdown, butup)

	if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
		log.Panicln(err)
	}
	if err := g.SetKeybinding("", gocui.KeyTab, gocui.ModNone, toggleButton); err != nil {
		log.Panicln(err)
	}

	if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
		log.Panicln(err)
	}
}
Esempio n. 3
0
func main() {
	var err error

	proj, err = project.OpenProject("testprj/test.gop")
	if err != nil {
		log.Println(err)
		return
	}
	codecomplete.Init(proj)

	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Panicln(err)
	}
	defer g.Close()

	g.SetLayout(layout)
	if err := keybindings(g); err != nil {
		log.Panicln(err)
	}
	g.SelBgColor = gocui.ColorGreen
	g.SelFgColor = gocui.ColorBlack
	g.ShowCursor = true

	err = g.MainLoop()
	if err != nil && err != gocui.Quit {
		log.Panicln(err)
	}
}
Esempio n. 4
0
func main() {
	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Panicln(err)
	}

	g.SetLayout(layout)
	if err := g.SetKeybinding("main", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
		log.Panicln(err)
	}
	g.SetLayout(layout)
	if err := g.SetKeybinding("main", gocui.KeyCtrlI, gocui.ModNone, overwrite); err != nil {
		log.Panicln(err)
	}
	g.Cursor = true
	g.Mouse = true

	if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
		log.Panicln(err)
	}

	g.Close()

	fmt.Printf("VBUF:\n%s\n", vbuf)
	fmt.Printf("BUF:\n%s\n", buf)
}
Esempio n. 5
0
func main() {
	login()

	g = ui.NewGui()
	if err := g.Init(); err != nil {
		log.Panicln(err)
	}
	current = "cursor"
	defer g.Close()

	if err := keybindings(g); err != nil {
		log.Fatal(err)
	}

	g.Editor = ui.EditorFunc(commands)
	current = "nodes-cursor"
	g.SetLayout(layout)
	g.Cursor = true

	if err := g.MainLoop(); err != nil {
		if err != ui.ErrQuit {
			log.Fatal(err)
		}
	}
}
Esempio n. 6
0
File: gui.go Progetto: hojgr/cook
func (gui *GUI) Setup(callback func(g *GUI)) {

	var err error

	g := gocui.NewGui()
	g.ShowCursor = true

	if err = g.Init(); err != nil {
		log.Panicln(err)
	}

	defer g.Close()

	g.SetLayout(layout)

	gui.Gocui = g

	registerKeybindings(gui)

	go func() {
		waitForMainLoop := time.NewTimer(time.Millisecond * 10)
		<-waitForMainLoop.C
		callback(gui)
	}()

	err = gui.Gocui.MainLoop()

	if err != nil && err != gocui.Quit {
		log.Panicln(err)
	}
}
Esempio n. 7
0
func main() {
	flag.Parse()

	if *showVersion {
		fmt.Printf("statsdaemon v%s (built w/%s)\n", VERSION, runtime.Version())
		return
	}

	signalchan = make(chan os.Signal, 1)
	signal.Notify(signalchan, syscall.SIGTERM)
	*persistCountKeys = -1 * (*persistCountKeys)

	go udpListener()

	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Panicln(err)
	}
	defer g.Close()

	g.SetLayout(layout)
	if err := g.SetKeybinding("", gocui.KeyCtrlC, 0, quit); err != nil {
		log.Panicln(err)
	}

	go updateViews(g)
	go monitor()

	err := g.MainLoop()
	if err != nil && err != gocui.ErrorQuit {
		log.Panicln(err)
	}
}
Esempio n. 8
0
func main() {

	log.Println("This is a test")

	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Panicln(err)
	}
	defer g.Close()

	g.SetLayout(layout)

	if err := keybindings(g); err != nil {
		log.Panicln(err)
	}

	if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
		log.Panicln(err)
	}

	//g.SelBgColor = gocui.ColorGreen
	//g.SelFgColor = gocui.ColorBlack
	g.Cursor = true

	g.FgColor = gocui.ColorGreen

	if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
		log.Panicln(err)
	}
}
Esempio n. 9
0
File: tui.go Progetto: Rompei/vuls
// RunTui execute main logic
func RunTui(historyID string) subcommands.ExitStatus {
	var err error
	scanHistory, err = selectScanHistory(historyID)
	if err != nil {
		log.Fatal(err)
		return subcommands.ExitFailure
	}

	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Panicln(err)
	}
	defer g.Close()

	g.SetLayout(layout)
	if err := keybindings(g); err != nil {
		log.Panicln(err)
	}
	g.SelBgColor = gocui.ColorGreen
	g.SelFgColor = gocui.ColorBlack
	g.Cursor = true

	if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
		log.Panicln(err)
		return subcommands.ExitFailure
	}

	return subcommands.ExitSuccess
}
Esempio n. 10
0
func main() {
	var err error

	if _, err := os.Stat(projFile); os.IsNotExist(err) {
		projects = Projects{}
	} else {
		projects = read(projFile)
	}

	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Panicln(err)
	}
	defer g.Close()

	g.SetLayout(layout)
	if err := keybindings(g); err != nil {
		log.Panicln(err)
	}
	g.SelBgColor = gocui.ColorGreen
	g.SelFgColor = gocui.ColorBlack
	//g.ShowCursor = true

	err = g.MainLoop()
	if err != nil && err != gocui.Quit {
		log.Panicln(err)
	}
}
Esempio n. 11
0
func main() {
	flag.Parse()
	capnslog.SetFormatter(capnslog.NewGlogFormatter(os.Stderr))

	client := startClient()
	client.MustDetectRemote()

	c := NewController(client)
	c.RefreshColumns()
	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Fatal(err)
	}

	g.SetLayout(c.layout)

	if err := initKeybindings(g, c); err != nil {
		log.Fatal(err)
	}

	err := g.MainLoop()
	if err != nil && err != gocui.Quit {
		g.Close()
		log.Fatal(err)
	}
	g.Close()

}
Esempio n. 12
0
func main() {
	var user, pass string

	flag.StringVar(&user, "u", "", "Username on stockfighter.io (or env SFJB_USER")
	flag.StringVar(&pass, "p", "", "Password on stockfighter.io (or env SFJB_PASS")
	flag.Parse()

	if user == "" {
		user = os.Getenv("SFJB_USER")
	}
	if pass == "" {
		pass = os.Getenv("SFJB_PASS")
	}

	if user == "" || pass == "" {
		fmt.Fprintf(os.Stderr, "provide -u user -p password\n")
		return
	}

	Session.URL = "https://www.stockfighter.io/trainer"
	if err := Session.login(user, pass); err != nil {
		fmt.Fprintf(os.Stderr, "login failed: %s\n", err)
		return
	}

	g = gocui.NewGui()
	if err := g.Init(); err != nil {
		return
	}
	defer g.Close()

	g.SelBgColor = gocui.ColorGreen
	g.SelFgColor = gocui.ColorBlack
	g.Cursor = true

	boot()

	setBindings()

	// gocui takes over our keyboard, so listen for SIGHUP to panic
	// the process if it hangs

	c := make(chan os.Signal)

	go func() {
		_ = <-c
		panic("signal")
	}()

	signal.Notify(c, syscall.SIGHUP)

	if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
		return
	}
}
Esempio n. 13
0
func main() {
	flag.Parse()

	g = gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Exitf("gocui init error: %v", err)
	}
	defer g.Close()
	g.SelBgColor = gocui.ColorGreen
	g.SelFgColor = gocui.ColorBlack
	g.ShowCursor = true
	g.SetLayout(layout)
	g.MainLoop()
}
Esempio n. 14
0
func main() {

	if len(os.Args) < 2 {
		fmt.Printf("Usage : %s </path/to/apache/access_log> \n ", os.Args[0])
		os.Exit(1)
	}

	g := gocui.NewGui()
	g.ShowCursor = true

	if err := g.Init(); err != nil {
		log.Panicln(err)
	}
	defer g.Close()

	g.SetLayout(layout)

	if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
		log.Panicln(err)
	}

	rawlog_output = make(chan RawLogEvent)
	alerts_output = make(chan string)
	averages_output = make(chan string)
	logdump_output = make(chan string)
	main_output = make(chan string)
	sparks_output = make(chan string)
	status_output = make(chan string)
	alert_state_chan = make(chan bool)

	ts = make([]*Bucket, 0)

	go updateTimeView(g)
	go updateMainView(g)
	go updateLogDumpView(g)
	go updateAlertsView(g)
	go updateStatusView(g)
	go updateSparksView(g)
	go updateAveragesView(g)
	go readLog()
	go bucketize()

	err := g.MainLoop()
	if err != nil && err != gocui.Quit {
		log.Panicln(err)
	}

}
Esempio n. 15
0
func main() {
	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Panicln(err)
	}
	defer g.Close()

	g.SetLayout(layout)
	if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
		log.Panicln(err)
	}

	if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
		log.Panicln(err)
	}
}
Esempio n. 16
0
func main() {
	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Panicln(err)
	}
	defer g.Close()

	g.SetLayout(layout)
	if err := keybindings(g); err != nil {
		log.Panicln(err)
	}

	if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
		log.Panicln(err)
	}
}
Esempio n. 17
0
func main() {
	g, err := gocui.NewGui(gocui.OutputNormal)
	if err != nil {
		log.Panicln(err)
	}
	defer g.Close()

	g.SetManagerFunc(layout)

	if err := keybindings(g); err != nil {
		log.Panicln(err)
	}

	if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
		log.Panicln(err)
	}
}
Esempio n. 18
0
func main() {
	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Fatalln(err)
	}
	defer g.Close()

	g.SetLayout(layout)
	if err := initKeybindings(g); err != nil {
		log.Fatalln(err)
	}
	g.Cursor = true

	if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
		log.Fatalln(err)
	}
}
Esempio n. 19
0
func main() {
	g, err := gocui.NewGui(gocui.OutputNormal)
	if err != nil {
		log.Panicln(err)
	}
	defer g.Close()

	g.SetManagerFunc(layout)

	if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
		log.Panicln(err)
	}

	if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
		log.Panicln(err)
	}
}
Esempio n. 20
0
func main() {
	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Panicln(err)
	}
	defer g.Close()

	g.SetLayout(layout)
	if err := keybindings(g); err != nil {
		log.Panicln(err)
	}
	g.SelBgColor = gocui.ColorGreen
	g.SelFgColor = gocui.ColorBlack
	g.Cursor = true
	if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
		log.Panicln(err)
	}
}
Esempio n. 21
0
func runGUI() error {
	g = gocui.NewGui()
	if err := g.Init(); err != nil {
		return err
	}
	defer g.Close()
	g.SetLayout(layout)
	if err := keybindings(g); err != nil {
		return err
	}
	g.SelBgColor = gocui.ColorGreen
	g.SelFgColor = gocui.ColorBlack
	err := g.MainLoop()
	if err != nil && err != gocui.Quit {
		return err
	}
	return nil
}
Esempio n. 22
0
func main() {
	g, err := gocui.NewGui()
	if err != nil {
		log.Fatalln(err)
	}
	defer g.Close()

	g.Cursor = true

	g.SetManagerFunc(layout)

	if err := initKeybindings(g); err != nil {
		log.Fatalln(err)
	}

	if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
		log.Fatalln(err)
	}
}
Esempio n. 23
0
func (gc *GuiClient) Run() {
	gui := gocui.NewGui()
	if err := gui.Init(); err != nil {
		log.Panicln(err)
	}
	defer gui.Close()
	gc.gui = gui

	if err := gui.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
		log.Panicln(err)
	}
	if err := gui.SetKeybinding("input", gocui.KeyEnter, gocui.ModNone, gc.readLine); err != nil {
		log.Panicln(err)
	}
	gui.ShowCursor = true
	gui.BgColor = gocui.ColorDefault
	gui.FgColor = gocui.ColorDefault
	gui.SetLayout(gc.layout)

	gc.conversations = make(map[string]*Conversation)
	gc.switchConversation(gc.myName)

	gc.dialer = &Dialer{
		gui:          gc,
		pki:          gc.pki,
		myPublicKey:  gc.myPublicKey,
		myPrivateKey: gc.myPrivateKey,
	}
	gc.dialer.Init()

	go func() {
		time.Sleep(500 * time.Millisecond)
		if err := gc.Connect(); err != nil {
			gc.Warnf("Failed to connect: %s\n", err)
		}
		gc.Warnf("Connected: %s\n", gc.pki.EntryServer)
	}()

	err := gui.MainLoop()
	if err != nil && err != gocui.Quit {
		log.Panicln(err)
	}
}
Esempio n. 24
0
func main() {
	var err error

	logWriter, err = syslog.New(syslog.LOG_INFO, "bsw")
	if err != nil {
		log.Fatal(err)
	}
	log.SetOutput(logWriter)

	flag.Parse()

	if conn, err = beanstalk.Dial("tcp", *host); err != nil {
		log.Fatal(err)
	}
	debugLog("Connected to beanstalk")

	//Use all tubes by default
	cTubes.UseAll()

	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Fatal(err)
	}
	defer g.Close()

	if err := setKeyBindings(g); err != nil {
		log.Fatal(err)
	}
	debugLog("Set keybindings")

	g.SetLayout(setLayout)
	debugLog("Set layout")
	g.Editor = gocui.EditorFunc(cmdEditor)
	debugLog("Set editor")
	g.Cursor = true
	go watchTubes(g)

	debugLog("Starting main loop")

	if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
		log.Fatal(err)
	}
}
Esempio n. 25
0
func (gui *Gui) startGui() {
	gui.g = gocui.NewGui()
	if err := gui.g.Init(); err != nil {
		log.Panicln(err)
	}
	defer gui.g.Close()

	gui.g.SetLayout(layout)
	if err := keybindings(); err != nil {
		log.Panicln(err)
	}
	gui.g.SelBgColor = gocui.ColorGreen
	gui.g.SelFgColor = gocui.ColorBlack
	gui.g.Cursor = true

	if err := gui.g.MainLoop(); err != nil && err != gocui.ErrQuit {
		log.Panicln(err)
	}
}
Esempio n. 26
0
func main() {
	runtime.LockOSThread()

	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Fatalln(err)
	}
	defer g.Close()

	g.SetLayout(layout)
	if err := initKeybindings(g); err != nil {
		log.Fatalln(err)
	}
	g.ShowCursor = true

	err := g.MainLoop()
	if err != nil && err != gocui.Quit {
		log.Fatalln(err)
	}
}
Esempio n. 27
0
func main() {
	var err error
	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Panicln(err)
	}
	defer g.Close()

	renderState := render.NewConnectedRenderState(g.Flush)
	g.SetLayout(makeLayout(renderState))
	if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
		log.Panicln(err)
	}

	g.MainLoop()

	if err != nil && err != gocui.Quit {
		log.Panicln(err)
	}

}
Esempio n. 28
0
func main() {
	var err error

	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Panicln(err)
	}
	defer g.Close()

	g.SetLayout(layout)
	if err := initKeybindings(g); err != nil {
		log.Panicln(err)
	}
	if err := newView(g); err != nil {
		log.Panicln(err)
	}

	err = g.MainLoop()
	if err != nil && err != gocui.Quit {
		log.Panicln(err)
	}
}
Esempio n. 29
0
func main() {
	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Panicln(err)
	}
	defer g.Close()

	g.SetLayout(layout)
	g.Highlight = true
	g.SelFgColor = gocui.ColorRed

	if err := initKeybindings(g); err != nil {
		log.Panicln(err)
	}
	if err := newView(g); err != nil {
		log.Panicln(err)
	}

	if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
		log.Panicln(err)
	}
}
Esempio n. 30
0
func main() {
	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Panicln(err)
	}
	defer g.Close()

	g.Highlight = true
	g.SelFgColor = gocui.ColorGreen
	g.SetLayout(layout)

	if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
		log.Panicln(err)
	}
	if err := g.SetKeybinding("", gocui.KeyTab, gocui.ModNone, nextView); err != nil {
		log.Panicln(err)
	}

	if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
		log.Panicln(err)
	}
}