summaryrefslogtreecommitdiff
path: root/eventsHandler.go
blob: a443431d07f99621f092a0434fe3a605f9e821b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// WIT.COM Inc. 2017-2025 GPL 3.0

package main

import (
	"github.com/awesome-gocui/gocui"
)

// tells 'gocui' what to call based on what key was pressed
func registerHandlers(g *gocui.Gui) {
	g.SetKeybinding("", '?', gocui.ModNone, theHelp)            // 'h' toggles on and off the help menu
	g.SetKeybinding("", 'r', gocui.ModNone, widgetRefresh)      // screen refresh
	g.SetKeybinding("", 'w', gocui.ModNone, doWindow)           // close all windows
	g.SetKeybinding("", 'q', gocui.ModNone, doExit)             // exit
	g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, doExit)  // exit
	g.SetKeybinding("", gocui.KeyCtrlV, gocui.ModNone, doPanic) // forced panic

	// debugging
	g.SetKeybinding("", 'd', gocui.ModNone, theLetterD)               // 'd' toggles on and off debugging buttons
	g.SetKeybinding("", gocui.KeyCtrlD, gocui.ModNone, openDebuggger) // open the debugger
	g.SetKeybinding("", 'L', gocui.ModNone, dumpWidgets)              // list all widgets
	g.SetKeybinding("", 'M', gocui.ModNone, dumpWidgetPlacement)      // list all widgets with positions

}

func doExit(g *gocui.Gui, v *gocui.View) error {
	return nil
}

func doPanic(g *gocui.Gui, v *gocui.View) error {
	return nil
}

func dumpWidgets(g *gocui.Gui, v *gocui.View) error {
	return nil
}

func dumpWidgetPlacement(g *gocui.Gui, v *gocui.View) error {
	return nil
}

func openDebuggger(g *gocui.Gui, v *gocui.View) error {
	return nil
}

// is run whenever anyone hits 'd' (in an open space)
func theLetterD(g *gocui.Gui, v *gocui.View) error {
	// widgets that don't have physical existance in
	// a display toolkit are hidden. In the case
	// of gocui, they are set as not 'visible' and put offscreen
	// or have the size set to zero
	// (hopefully anyway) lots of things with the toolkit
	// still don't work

	fakeStartWidth = me.FakeW
	fakeStartHeight = me.TabH + me.FramePadH
	if showDebug {
		showFake()
		showDebug = false
	} else {
		hideFake()
		showDebug = true
	}
	return nil
}

func theHelp(g *gocui.Gui, v *gocui.View) error {
	if showHelp {
		helplayout()
		showHelp = false
		if me.dropdownV == nil {
			me.dropdownV = makeDropdownView("addWidget() ddview")
		}
		me.dropdownV.Show()
	} else {
		me.baseGui.DeleteView("help")
		showHelp = true
		me.dropdownV.Hide()
	}
	return nil
}

func widgetRefresh(g *gocui.Gui, v *gocui.View) error {
	return nil
}

func doWindow(g *gocui.Gui, v *gocui.View) error {
	return nil
}