|
|
@@ -16,15 +16,6 @@ var (
|
|
|
selectedMessage int = -1
|
|
|
)
|
|
|
|
|
|
-func newApp() *tview.Application {
|
|
|
- a := tview.NewApplication()
|
|
|
- a.
|
|
|
- EnableMouse(conf.Mouse).
|
|
|
- SetInputCapture(onAppInputCapture)
|
|
|
-
|
|
|
- return a
|
|
|
-}
|
|
|
-
|
|
|
func onAppInputCapture(e *tcell.EventKey) *tcell.EventKey {
|
|
|
switch e.Name() {
|
|
|
case conf.Keybindings.FocusChannelsTree:
|
|
|
@@ -41,19 +32,6 @@ func onAppInputCapture(e *tcell.EventKey) *tcell.EventKey {
|
|
|
return e
|
|
|
}
|
|
|
|
|
|
-func newChannelsTree() *tview.TreeView {
|
|
|
- treeView := tview.NewTreeView()
|
|
|
- treeView.
|
|
|
- SetSelectedFunc(onChannelsTreeSelected).
|
|
|
- SetTopLevel(1).
|
|
|
- SetRoot(tview.NewTreeNode("")).
|
|
|
- SetTitle("Channels").
|
|
|
- SetBorder(true).
|
|
|
- SetBorderPadding(0, 0, 1, 0)
|
|
|
-
|
|
|
- return treeView
|
|
|
-}
|
|
|
-
|
|
|
func onChannelsTreeSelected(n *tview.TreeNode) {
|
|
|
selectedChannel = nil
|
|
|
selectedMessage = 0
|
|
|
@@ -151,23 +129,6 @@ func onChannelsTreeSelected(n *tview.TreeNode) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func newMessagesView() *tview.TextView {
|
|
|
- textView := tview.NewTextView()
|
|
|
- textView.
|
|
|
- SetRegions(true).
|
|
|
- SetDynamicColors(true).
|
|
|
- SetWordWrap(true).
|
|
|
- SetChangedFunc(func() {
|
|
|
- app.Draw()
|
|
|
- }).
|
|
|
- SetInputCapture(onMessagesViewInputCapture).
|
|
|
- SetBorder(true).
|
|
|
- SetBorderPadding(0, 0, 1, 0).
|
|
|
- SetTitleAlign(tview.AlignLeft)
|
|
|
-
|
|
|
- return textView
|
|
|
-}
|
|
|
-
|
|
|
func onMessagesViewInputCapture(e *tcell.EventKey) *tcell.EventKey {
|
|
|
if selectedChannel == nil {
|
|
|
return nil
|
|
|
@@ -270,20 +231,6 @@ func onMessagesViewInputCapture(e *tcell.EventKey) *tcell.EventKey {
|
|
|
return e
|
|
|
}
|
|
|
|
|
|
-func newMessageInputField() *tview.InputField {
|
|
|
- inputField := tview.NewInputField()
|
|
|
- inputField.
|
|
|
- SetPlaceholder("Message...").
|
|
|
- SetPlaceholderTextColor(tcell.ColorWhite).
|
|
|
- SetFieldBackgroundColor(tview.Styles.PrimitiveBackgroundColor).
|
|
|
- SetInputCapture(onMessageInputFieldInputCapture).
|
|
|
- SetBorder(true).
|
|
|
- SetBorderPadding(0, 0, 1, 0).
|
|
|
- SetTitleAlign(tview.AlignLeft)
|
|
|
-
|
|
|
- return inputField
|
|
|
-}
|
|
|
-
|
|
|
func onMessageInputFieldInputCapture(e *tcell.EventKey) *tcell.EventKey {
|
|
|
switch e.Key() {
|
|
|
case tcell.KeyEnter:
|
|
|
@@ -333,22 +280,3 @@ func onMessageInputFieldInputCapture(e *tcell.EventKey) *tcell.EventKey {
|
|
|
|
|
|
return e
|
|
|
}
|
|
|
-
|
|
|
-func newLoginForm(onLoginFormLoginButtonSelected func(), mfa bool) *tview.Form {
|
|
|
- w := tview.NewForm()
|
|
|
- w.
|
|
|
- AddButton("Login", onLoginFormLoginButtonSelected).
|
|
|
- SetButtonsAlign(tview.AlignCenter).
|
|
|
- SetBorder(true).
|
|
|
- SetBorderPadding(0, 0, 1, 0)
|
|
|
-
|
|
|
- if mfa {
|
|
|
- w.AddPasswordField("Code", "", 0, 0, nil)
|
|
|
- } else {
|
|
|
- w.
|
|
|
- AddInputField("Email", "", 0, nil, nil).
|
|
|
- AddPasswordField("Password", "", 0, 0, nil)
|
|
|
- }
|
|
|
-
|
|
|
- return w
|
|
|
-}
|