Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Commit

Permalink
Implement Bare mode on Ctrl+B by default. Fixes #213
Browse files Browse the repository at this point in the history
  • Loading branch information
Bios-Marcel committed Nov 15, 2019
1 parent 62a678e commit 83b43c2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions shortcuts/shortcuts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions ui/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 83b43c2

Please sign in to comment.