From 83b43c2cfb785e5ea1bd6647b1d9ff626f094c3b Mon Sep 17 00:00:00 2001 From: Marcel Schramm Date: Fri, 15 Nov 2019 23:51:44 +0100 Subject: [PATCH] Implement Bare mode on Ctrl+B by default. Fixes #213 --- shortcuts/shortcuts.go | 2 ++ ui/window.go | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/shortcuts/shortcuts.go b/shortcuts/shortcuts.go index 63ff3de0..6cc736b8 100644 --- a/shortcuts/shortcuts.go +++ b/shortcuts/shortcuts.go @@ -113,6 +113,8 @@ var ( globalScope, tcell.NewEventKey(tcell.KeyRune, 'U', tcell.ModAlt)) ToggleCommandView = addShortcut("toggle_command_view", "Toggle command view", globalScope, tcell.NewEventKey(tcell.KeyRune, '.', tcell.ModAlt)) + ToggleBareChat = addShortcut("toggle_bare_chat", "Toggle bare chat", + globalScope, tcell.NewEventKey(tcell.KeyCtrlB, rune(tcell.KeyCtrlB), tcell.ModCtrl)) scopes []*Scope Shortcuts []*Shortcut diff --git a/ui/window.go b/ui/window.go index 5d9d4907..ac3963ea 100644 --- a/ui/window.go +++ b/ui/window.go @@ -89,6 +89,8 @@ type Window struct { userActiveTimer *time.Timer doRestart chan bool + + bareChat bool } //NewWindow constructs the whole application window and also registers all @@ -1977,6 +1979,11 @@ func (window *Window) handleGlobalShortcuts(event *tcell.EventKey) *tcell.EventK return nil } + if shortcuts.ToggleBareChat.Equals(event) { + window.toggleBareChat() + return nil + } + // Maybe compare directly to table? if window.currentContainer != window.rootContainer { return event @@ -2055,6 +2062,19 @@ func (window *Window) handleGlobalShortcuts(event *tcell.EventKey) *tcell.EventK return nil } +func (window *Window) toggleBareChat() { + window.bareChat = !window.bareChat + if window.bareChat { + window.chatView.internalTextView.SetBorder(false) + window.currentContainer = window.chatView.GetPrimitive() + window.app.SetRoot(window.chatView.GetPrimitive(), true) + } else { + window.chatView.internalTextView.SetBorder(true) + window.currentContainer = window.rootContainer + window.app.SetRoot(window.rootContainer, true) + } +} + func (window *Window) FindCommand(name string) commands.Command { for _, cmd := range window.commands { if commands.CommandEquals(cmd, name) {