-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConnectScreen.go
124 lines (108 loc) · 2.21 KB
/
ConnectScreen.go
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package main
import (
"github.com/nsf/termbox-go"
"github.com/gabriel-comeau/tbuikit"
)
// Holds the event handler callbacks and rectangle calculation callbacks for
// the Connect Screen
//
// Event Handler Callbacks
//
// Switches between selectable widgets on the screen when fired.
func switchConnectScreenActiveWidget(uiElement interface{}, event interface{}) {
scr, ok := uiElement.(*tbuikit.Screen)
if ok {
scr.SelectNextWidget()
}
}
func doConnectButtonPress(uiElement interface{}, event interface{}) {
connect()
}
// When the quit button is pressed, cause the UI to shutdown.
func doQuitButtonPress(uiElement interface{}, event interface{}) {
chatUi.Shutdown()
}
//
// Rectangle Calculation Callbacks
//
// Message Box
func calcMsgWidgetRect() (x1, x2, y1, y2 int) {
w, h := termbox.Size()
x1 = w / 4
x2 = x1 + 60
y2 = h / 4
y1 = y2 - 6
return
}
// Hostname Input Field
func calcHostFieldRect() (x1, x2, y1, y2 int) {
w, h := termbox.Size()
x1 = w/2 - 10
x2 = w/2 + 10
y2 = h - h/3 //30
y1 = y2 - 2 // 28
return
}
// Port Input Field
func calcPortFieldRect() (x1, x2, y1, y2 int) {
w, h := termbox.Size()
x1 = w/2 - 10
x2 = w/2 + 10
y2 = h - h/3 - 4 // 24
y1 = y2 - 2 // 22
return
}
// Nickname Input Field
func calcNickFieldRect() (x1, x2, y1, y2 int) {
w, h := termbox.Size()
x1 = w/2 - 10
x2 = w/2 + 10
y2 = h - h/3 - 8 // 22
y1 = y2 - 2
return
}
// Hostname Label
func calcHostLabelRect() (x1, x2, y1, y2 int) {
w, h := termbox.Size()
x1 = w/2 - 20
x2 = x1 + 10
y2 = h - h/3 //30
y1 = y2 - 2 // 28
return
}
// Port Input Field
func calcPortLabelRect() (x1, x2, y1, y2 int) {
w, h := termbox.Size()
x1 = w/2 - 20
x2 = x1 + 10
y2 = h - h/3 - 4 // 24
y1 = y2 - 2 // 22
return
}
// Nickname Input Field
func calcNickLabelRect() (x1, x2, y1, y2 int) {
w, h := termbox.Size()
x1 = w/2 - 20
x2 = x1 + 10
y2 = h - h/3 - 8 // 22
y1 = y2 - 2
return
}
// Connect Button
func calConnectButtonRect() (x1, x2, y1, y2 int) {
w, h := termbox.Size()
x1 = w/2 - 40
x2 = w/2 - 20
y2 = h - h/3 + 6 //34
y1 = y2 - 4
return
}
// Quit Button
func calQuitButtonRect() (x1, x2, y1, y2 int) {
w, h := termbox.Size()
x1 = w/2 + 20
x2 = w/2 + 40
y2 = h - h/3 + 6 //34
y1 = y2 - 4
return
}