aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ui/types/message.go2
-rw-r--r--ui/view-main.go2
-rw-r--r--ui/widget/message-view.go2
-rw-r--r--ui/widget/room-view.go49
4 files changed, 44 insertions, 11 deletions
diff --git a/ui/types/message.go b/ui/types/message.go
index 7b96193..6775597 100644
--- a/ui/types/message.go
+++ b/ui/types/message.go
@@ -61,7 +61,7 @@ func (message *Message) CopyTo(to *Message) {
}
func (message *Message) CalculateBuffer(width int) {
- if width < 1 {
+ if width < 2 {
return
}
message.Buffer = []string{}
diff --git a/ui/view-main.go b/ui/view-main.go
index 6f3689c..0c3b0a4 100644
--- a/ui/view-main.go
+++ b/ui/view-main.go
@@ -70,7 +70,7 @@ func (ui *GomuksUI) NewMainView() tview.Primitive {
SetBorderPadding(0, 0, 1, 0)
mainView.SetDirection(tview.FlexColumn)
- mainView.AddItem(mainView.roomList, 30, 0, false)
+ mainView.AddItem(mainView.roomList, 25, 0, false)
mainView.AddItem(widget.NewBorder(), 1, 0, false)
mainView.AddItem(mainView.roomView, 0, 1, true)
diff --git a/ui/widget/message-view.go b/ui/widget/message-view.go
index 941b987..f263350 100644
--- a/ui/widget/message-view.go
+++ b/ui/widget/message-view.go
@@ -53,7 +53,7 @@ type MessageView struct {
func NewMessageView() *MessageView {
return &MessageView{
Box: tview.NewBox(),
- MaxSenderWidth: 20,
+ MaxSenderWidth: 15,
DateFormat: "January _2, 2006",
TimestampFormat: "15:04:05",
TimestampWidth: 8,
diff --git a/ui/widget/room-view.go b/ui/widget/room-view.go
index a194054..433d5dd 100644
--- a/ui/widget/room-view.go
+++ b/ui/widget/room-view.go
@@ -114,17 +114,50 @@ 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) Draw(screen tcell.Screen) {
- view.Box.Draw(screen)
+ x, y, width, height := view.GetInnerRect()
+ if width <= 0 || height <= 0 {
+ return
+ }
- x, y, width, height := view.GetRect()
- view.topic.SetRect(x, y, width, 1)
- view.content.SetRect(x, y+1, width-30, height-3)
- view.status.SetRect(x, y+height-2, width, 1)
- view.userList.SetRect(x+width-29, y+1, 29, height-3)
- view.ulBorder.SetRect(x+width-30, y+1, 1, height-3)
- view.input.SetRect(x, y+height-1, width, 1)
+ // Calculate actual grid based on view rectangle and constants defined above.
+ var (
+ contentHeight = height - StaticVerticalSpace
+ contentWidth = width - StaticHorizontalSpace
+
+ userListBorderColumn = x + contentWidth
+ userListColumn = userListBorderColumn + UserListBorderWidth
+
+ topicRow = y
+ contentRow = topicRow + TopicBarHeight
+ statusRow = contentRow + contentHeight
+ inputRow = statusRow + StatusBarHeight
+ )
+
+ // 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 {
+ view.userList.SetRect(userListColumn, contentRow, UserListWidth, contentHeight)
+ view.ulBorder.SetRect(userListBorderColumn, contentRow, UserListBorderWidth, contentHeight)
+ }
+ view.input.SetRect(x, inputRow, width, InputBarHeight)
+ // Draw everything
+ view.Box.Draw(screen)
view.topic.Draw(screen)
view.content.Draw(screen)
view.status.Draw(screen)