From 14903e0cdcd3ba78face2cbe0ad0287da269a1ea Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 22 May 2018 22:06:48 +0300 Subject: Add bare mode and fix terminal resize bug. Fixes #48 --- ui/room-view.go | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'ui/room-view.go') diff --git a/ui/room-view.go b/ui/room-view.go index 5f9a8de..e39506a 100644 --- a/ui/room-view.go +++ b/ui/room-view.go @@ -147,23 +147,11 @@ func (view *RoomView) Focus(delegate func(p tview.Primitive)) { delegate(view.input) } -// Constants defining the size of the room view grid. -const ( - UserListBorderWidth = 1 - UserListWidth = 20 - StaticHorizontalSpace = UserListBorderWidth + UserListWidth - - TopicBarHeight = 1 - StatusBarHeight = 1 - InputBarHeight = 1 - StaticVerticalSpace = TopicBarHeight + StatusBarHeight + InputBarHeight -) - func (view *RoomView) GetStatus() string { var buf strings.Builder if len(view.completions.list) > 0 { - if view.completions.textCache != view.input.GetText() || view.completions.time.Add(10*time.Second).Before(time.Now()) { + if view.completions.textCache != view.input.GetText() || view.completions.time.Add(10 * time.Second).Before(time.Now()) { view.completions.list = []string{} } else { buf.WriteString(strings.Join(view.completions.list, ", ")) @@ -184,11 +172,23 @@ func (view *RoomView) GetStatus() string { } func (view *RoomView) Draw(screen tcell.Screen) { - x, y, width, height := view.GetInnerRect() + x, y, width, height := view.GetRect() if width <= 0 || height <= 0 { return } + // Constants defining the size of the room view grid. + const ( + UserListBorderWidth = 1 + UserListWidth = 20 + StaticHorizontalSpace = UserListBorderWidth + UserListWidth + + TopicBarHeight = 1 + StatusBarHeight = 1 + InputBarHeight = 1 + StaticVerticalSpace = TopicBarHeight + StatusBarHeight + InputBarHeight + ) + // Calculate actual grid based on view rectangle and constants defined above. var ( contentHeight = height - StaticVerticalSpace @@ -202,12 +202,15 @@ func (view *RoomView) Draw(screen tcell.Screen) { statusRow = contentRow + contentHeight inputRow = statusRow + StatusBarHeight ) + if !view.parent.ShowUserList() { + contentWidth = width + } // Update the rectangles of all the children. view.topic.SetRect(x, topicRow, width, TopicBarHeight) view.content.SetRect(x, contentRow, contentWidth, contentHeight) view.status.SetRect(x, statusRow, width, StatusBarHeight) - if userListColumn > x { + if view.parent.ShowUserList() && userListColumn > x { view.userList.SetRect(userListColumn, contentRow, UserListWidth, contentHeight) view.ulBorder.SetRect(userListBorderColumn, contentRow, UserListBorderWidth, contentHeight) } @@ -220,8 +223,10 @@ func (view *RoomView) Draw(screen tcell.Screen) { view.status.SetText(view.GetStatus()) view.status.Draw(screen) view.input.Draw(screen) - view.ulBorder.Draw(screen) - view.userList.Draw(screen) + if view.parent.ShowUserList() { + view.ulBorder.Draw(screen) + view.userList.Draw(screen) + } } func (view *RoomView) SetCompletions(completions []string) { -- cgit v1.2.3