diff options
author | Tulir Asokan <tulir@maunium.net> | 2018-05-24 23:26:57 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-05-24 23:27:12 +0300 |
commit | b76c8d01478bcdeb8e0f0c00ca56f577a425674b (patch) | |
tree | a3e9761a05c556730846c5645f8d9afc7c6e052b /ui | |
parent | a4d07e9a81f3bf0018b4f1368d8b4d06992cadba (diff) |
Add UI preferences and simplify config save/load (ref #43)
Diffstat (limited to 'ui')
-rw-r--r-- | ui/message-view.go | 2 | ||||
-rw-r--r-- | ui/ui.go | 8 | ||||
-rw-r--r-- | ui/view-main.go | 27 |
3 files changed, 36 insertions, 1 deletions
diff --git a/ui/message-view.go b/ui/message-view.go index b6b7ee4..de8e412 100644 --- a/ui/message-view.go +++ b/ui/message-view.go @@ -491,7 +491,7 @@ func (view *MessageView) Draw(screen tcell.Screen) { bareMode := view.parent.parent.bareMessages if bareMode { - messageX = 0 + messageX = x } indexOffset := view.getIndexOffset(screen, height, messageX) @@ -86,6 +86,14 @@ func (ui *GomuksUI) OnLogout() { ui.app.SetFocus(ui.loginView) } +func (ui *GomuksUI) HandleNewPreferences() { + prefs := ui.gmx.Config().Preferences + ui.mainView.bareMessages = prefs.BareMessageView + ui.mainView.hideUserList = prefs.HideUserList + ui.mainView.hideRoomList = prefs.HideRoomList + ui.Render() +} + func (ui *GomuksUI) SetView(name View) { ui.views.SwitchToPage(string(name)) } diff --git a/ui/view-main.go b/ui/view-main.go index fd9d606..9f4f247 100644 --- a/ui/view-main.go +++ b/ui/view-main.go @@ -57,6 +57,7 @@ type MainView struct { } func (ui *GomuksUI) NewMainView() tview.Primitive { + prefs := ui.gmx.Config().Preferences mainView := &MainView{ Flex: tview.NewFlex(), roomList: NewRoomList(), @@ -67,6 +68,10 @@ func (ui *GomuksUI) NewMainView() tview.Primitive { gmx: ui.gmx, config: ui.gmx.Config(), parent: ui, + + hideUserList: prefs.HideUserList, + hideRoomList: prefs.HideRoomList, + bareMessages: prefs.BareMessageView, } mainView. @@ -185,6 +190,28 @@ func (view *MainView) HandleCommand(roomView *RoomView, command string, args []s if err == nil { view.RemoveRoom(roomView.Room) } + case "/uitoggle": + if len(args) == 0 { + roomView.AddServiceMessage("Usage: /uitoggle <rooms/users/baremessages>") + break + } + switch args[0] { + case "rooms": + view.hideRoomList = !view.hideRoomList + view.config.Preferences.HideRoomList = view.hideRoomList + case "users": + view.hideUserList = !view.hideUserList + view.config.Preferences.HideUserList = view.hideUserList + case "baremessages": + view.bareMessages = !view.bareMessages + view.config.Preferences.BareMessageView = view.bareMessages + default: + roomView.AddServiceMessage("Usage: /uitoggle <rooms/users/baremessages>") + return + } + view.parent.Render() + view.parent.Render() + go view.matrix.SendPreferencesToMatrix() case "/join": if len(args) == 0 { roomView.AddServiceMessage("Usage: /join <room>") |