コード例 #1
0
ファイル: project_tree.go プロジェクト: gitter-badger/vidar
func (d *ProjectTree) OnComplete(onComplete func(commands.Command)) {
	cmd := commands.NewFileOpener(d.driver, d.theme)
	d.files.OnSelectionChanged(func(selected gxui.AdapterItem) {
		cmd.SetPath(selected.(string))
		onComplete(cmd)
	})
}
コード例 #2
0
ファイル: toc_tree.go プロジェクト: nelsam/vidar
func (n *Name) OnSelected(exec func(controller.Executor)) {
	// OnSelected will often be called in non-UI goroutines because
	// it's called by resource intensive tasks that shouldn't be
	// holding up the UI.  However, creating the FileOpener and
	// setting its location needs to be done on the UI goroutine.
	var cmd *commands.FileOpener
	n.driver.CallSync(func() {
		cmd = commands.NewFileOpener(n.driver, n.theme.(*basic.Theme))
		cmd.SetLocation(n.File(), n.Position())
	})
	n.button.OnClick(func(gxui.MouseEvent) {
		exec(cmd)
	})
}
コード例 #3
0
ファイル: commander.go プロジェクト: gitter-badger/vidar
// Init resets c's state.
func (c *Commander) Init(driver gxui.Driver, theme *basic.Theme, font gxui.Font) {
	c.LinearLayout.Init(c, theme)
	c.bindings = make(map[gxui.KeyboardEvent]commands.Command)
	c.driver = driver
	c.theme = theme
	c.font = font
	c.SetDirection(gxui.BottomToTop)
	c.SetSize(math.MaxSize)

	c.controller = controller.New(c.driver, c.theme, c.font)
	c.box = NewCommandBox(c.theme, c.controller)

	c.AddChild(c.box)
	c.AddChild(c.controller)

	// TODO: Store these in a config file or something
	openFile := commands.NewFileOpener(c.driver, c.theme)
	c.commands = append(c.commands, openFile)
	ctrlO := gxui.KeyboardEvent{
		Key:      gxui.KeyO,
		Modifier: gxui.ModControl,
	}
	supO := gxui.KeyboardEvent{
		Key:      gxui.KeyO,
		Modifier: gxui.ModSuper,
	}
	c.bindings[ctrlO] = openFile
	c.bindings[supO] = openFile

	addProject := commands.NewProjectAdder(c.driver, c.theme)
	c.commands = append(c.commands, addProject)
	ctrlShiftN := gxui.KeyboardEvent{
		Key:      gxui.KeyN,
		Modifier: gxui.ModControl | gxui.ModShift,
	}
	supShiftN := gxui.KeyboardEvent{
		Key:      gxui.KeyN,
		Modifier: gxui.ModSuper | gxui.ModShift,
	}
	c.bindings[ctrlShiftN] = addProject
	c.bindings[supShiftN] = addProject
}