aboutsummaryrefslogtreecommitdiff
path: root/ui/view-main.go
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-05-23 00:44:29 +0300
committerTulir Asokan <tulir@maunium.net>2018-05-23 00:44:29 +0300
commit1d44d3da1a383121318ac64fe76fb741d3b85375 (patch)
tree86e160a481e44d8657ed537e50e2edc1afa69f78 /ui/view-main.go
parentbedb9979a9b65dad9d72dcbdb3174508d3714f36 (diff)
Add real bare view
Diffstat (limited to 'ui/view-main.go')
-rw-r--r--ui/view-main.go32
1 files changed, 20 insertions, 12 deletions
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
}