From 1d44d3da1a383121318ac64fe76fb741d3b85375 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 23 May 2018 00:44:29 +0300 Subject: Add real bare view --- ui/view-main.go | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'ui/view-main.go') diff --git a/ui/view-main.go b/ui/view-main.go index bda5d80..fd9d606 100644 --- a/ui/view-main.go +++ b/ui/view-main.go @@ -33,6 +33,8 @@ import ( "maunium.net/go/gomuks/ui/widget" "maunium.net/go/tcell" "maunium.net/go/tview" + "bufio" + "os" ) type MainView struct { @@ -51,15 +53,7 @@ type MainView struct { hideUserList bool hideRoomList bool - bareDisplay bool -} - -func (view *MainView) ShowRoomList() bool { - return !view.bareDisplay && !view.hideRoomList -} - -func (view *MainView) ShowUserList() bool { - return !view.bareDisplay && !view.hideUserList + bareMessages bool } func (ui *GomuksUI) NewMainView() tview.Primitive { @@ -88,7 +82,7 @@ func (ui *GomuksUI) NewMainView() tview.Primitive { } func (view *MainView) Draw(screen tcell.Screen) { - if !view.ShowRoomList() { + if view.hideRoomList { view.roomView.SetRect(view.GetRect()) view.roomView.Draw(screen) } else { @@ -213,6 +207,21 @@ func (view *MainView) HandleCommand(roomView *RoomView, command string, args []s } } +func (view *MainView) ShowBare(roomView *RoomView) { + _, height := view.parent.app.GetScreen().Size() + view.parent.app.Suspend(func() { + print("\033[2J\033[0;0H") + // We don't know how much space there exactly is. Too few messages looks weird, + // and too many messages shouldn't cause any problems, so we just show too many. + height *= 2 + fmt.Println(roomView.MessageView().CapturePlaintext(height)) + fmt.Println("Press enter to return to normal mode.") + reader := bufio.NewReader(os.Stdin) + reader.ReadRune() + print("\033[2J\033[0;0H") + }) +} + func (view *MainView) KeyEventHandler(roomView *RoomView, key *tcell.EventKey) *tcell.EventKey { view.BumpFocus(roomView) @@ -229,8 +238,7 @@ func (view *MainView) KeyEventHandler(roomView *RoomView, key *tcell.EventKey) * view.parent.views.AddPage("fuzzy-search-modal", searchModal, true, true) view.parent.app.SetFocus(searchModal) case c == 'l': - view.bareDisplay = !view.bareDisplay - view.parent.Render() + view.ShowBare(roomView) default: return key } -- cgit v1.2.3