Esempio n. 1
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. 2
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. 3
0
func Run(build string, server *client.Server) {
	var err error

	logger.Start()

	ui.Name = Name
	ui.Logo = Logo()
	ui.VersionLine = fmt.Sprintf("  Version: %s%s  Source Code: %s\n",
		Version, build, Website)

	g, err := gocui.NewGui()

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

	// gocui.SetOutputMode(termbox.Output256)

	defer g.Close()

	server.Gui = g

	client.New(server)

	defer server.Client.Quit()

	Server = server
	ui.Server = server

	ui.Editor = gocui.EditorFunc(simpleEditor)
	g.SetManagerFunc(ui.Layout)

	command.Register(server)

	g.Cursor = true
	g.Mouse = false

	// if err := g.SetKeybinding("input", gocui.KeyEnter,
	// gocui.ModNone, GetLine); err != nil {
	// log.Panicln(err)
	// }

	// if err := g.SetKeybinding("input", gocui.MouseLeft,
	// gocui.ModNone, FocusInputView); err != nil {
	// log.Panicln(err)
	// }

	if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone,
		func(g *gocui.Gui, v *gocui.View) error {
			return gocui.ErrQuit
		}); err != nil {
		log.Panicln(err)
	}

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

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

	if err := g.SetKeybinding(client.StatusChannel,
		gocui.MouseLeft,
		gocui.ModNone, FocusAndResetAll); err != nil {
		log.Panicln(err)
	}

	if err := g.SetKeybinding("", gocui.KeyCtrlN,
		gocui.ModAlt, ScrollDown); err != nil {
		log.Panicln(err)
	}
	if err := g.SetKeybinding("", gocui.KeyCtrlP,
		gocui.ModAlt, ScrollUp); err != nil {
		log.Panicln(err)
	}

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

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

	if err := g.SetKeybinding("", gocui.KeyTab, gocui.ModNone,
		func(g *gocui.Gui, v *gocui.View) error {
			return tabComplete(g, v)
		}); err != nil {
		log.Panicln(err)
	}

	if err := g.SetKeybinding("input", gocui.KeyArrowRight, gocui.Modifier(termbox.ModAlt),
		func(g *gocui.Gui, v *gocui.View) error {
			return nextView(g, v)
		}); err != nil {
		log.Panicln(err)
	}

	if err := g.SetKeybinding("input", gocui.KeyArrowLeft, gocui.Modifier(termbox.ModAlt),
		func(g *gocui.Gui, v *gocui.View) error {
			return prevView(g, v)
		}); err != nil {
		log.Panicln(err)
	}

	err = g.MainLoop()

	if err != nil || err != gocui.ErrQuit {
		logger.Logger.Println(err)
		os.Exit(1)
	}
}