aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/messages/tstring/string.go3
-rw-r--r--ui/room-view.go54
-rw-r--r--ui/view-main.go3
-rw-r--r--ui/widget/util.go2
4 files changed, 34 insertions, 28 deletions
diff --git a/ui/messages/tstring/string.go b/ui/messages/tstring/string.go
index b14dc8e..bd6798d 100644
--- a/ui/messages/tstring/string.go
+++ b/ui/messages/tstring/string.go
@@ -183,9 +183,8 @@ func (str TString) AdjustStyleFull(fn func(tcell.Style) tcell.Style) {
}
func (str TString) Draw(screen mauview.Screen, x, y int) {
- offsetX := 0
for _, cell := range str {
- offsetX += cell.Draw(screen, x+offsetX, y)
+ x += cell.Draw(screen, x, y)
}
}
diff --git a/ui/room-view.go b/ui/room-view.go
index 2931372..78ace59 100644
--- a/ui/room-view.go
+++ b/ui/room-view.go
@@ -26,6 +26,8 @@ import (
"github.com/mattn/go-runewidth"
+ "maunium.net/go/gomuks/debug"
+
"maunium.net/go/mauview"
"maunium.net/go/mautrix"
@@ -78,15 +80,15 @@ func NewRoomView(parent *MainView, room *rooms.Room) *RoomView {
input: mauview.NewInputArea(),
Room: room,
- topicScreen: &mauview.ProxyScreen{OffsetX: 0, OffsetY: 0, Height: TopicBarHeight},
- contentScreen: &mauview.ProxyScreen{OffsetX: 0, OffsetY: StatusBarHeight},
- statusScreen: &mauview.ProxyScreen{OffsetX: 0, Height: StatusBarHeight},
- inputScreen: &mauview.ProxyScreen{OffsetX: 0},
+ topicScreen: &mauview.ProxyScreen{OffsetX: 0, OffsetY: 0, Height: TopicBarHeight},
+ contentScreen: &mauview.ProxyScreen{OffsetX: 0, OffsetY: StatusBarHeight},
+ statusScreen: &mauview.ProxyScreen{OffsetX: 0, Height: StatusBarHeight},
+ inputScreen: &mauview.ProxyScreen{OffsetX: 0},
ulBorderScreen: &mauview.ProxyScreen{OffsetY: StatusBarHeight, Width: UserListBorderWidth},
- ulScreen: &mauview.ProxyScreen{OffsetY: StatusBarHeight, Width: UserListWidth},
+ ulScreen: &mauview.ProxyScreen{OffsetY: StatusBarHeight, Width: UserListWidth},
- parent: parent,
- config: parent.config,
+ parent: parent,
+ config: parent.config,
}
view.content = NewMessageView(view)
@@ -98,7 +100,8 @@ func NewRoomView(parent *MainView, room *rooms.Room) *RoomView {
view.topic.
SetText(strings.Replace(room.GetTopic(), "\n", " ", -1)).
- SetTextColor(tcell.ColorDarkGreen)
+ SetTextColor(tcell.ColorWhite).
+ SetBackgroundColor(tcell.ColorDarkGreen)
view.status.SetBackgroundColor(tcell.ColorDimGray)
@@ -185,12 +188,10 @@ const (
UserListWidth = 20
StaticHorizontalSpace = UserListBorderWidth + UserListWidth
- TopicBarHeight = 1
- StatusBarHeight = 1
- InputBarHeight = 1
- StaticVerticalSpace = TopicBarHeight + StatusBarHeight + InputBarHeight
+ TopicBarHeight = 1
+ StatusBarHeight = 1
- MaxInputHeight
+ MaxInputHeight = 5
)
func (view *RoomView) Draw(screen mauview.Screen) {
@@ -199,15 +200,6 @@ func (view *RoomView) Draw(screen mauview.Screen) {
return
}
- // Calculate actual grid based on view rectangle and constants defined above.
- var (
- contentHeight = height - StaticVerticalSpace
- contentWidth = width - StaticHorizontalSpace
- )
- if view.config.Preferences.HideUserList {
- contentWidth = width
- }
-
if view.prevScreen != screen {
view.topicScreen.Parent = screen
view.contentScreen.Parent = screen
@@ -218,6 +210,8 @@ func (view *RoomView) Draw(screen mauview.Screen) {
view.prevScreen = screen
}
+ debug.Print(screen)
+
view.input.PrepareDraw(width)
inputHeight := view.input.GetTextHeight()
if inputHeight > MaxInputHeight {
@@ -225,7 +219,11 @@ func (view *RoomView) Draw(screen mauview.Screen) {
} else if inputHeight < 1 {
inputHeight = 1
}
- contentHeight -= inputHeight
+ contentHeight := height - inputHeight - TopicBarHeight - StatusBarHeight
+ contentWidth := width - StaticHorizontalSpace
+ if view.config.Preferences.HideUserList {
+ contentWidth = width
+ }
view.topicScreen.Width = width
view.contentScreen.Width = contentWidth
@@ -261,7 +259,15 @@ func (view *RoomView) OnPasteEvent(event mauview.PasteEvent) bool {
}
func (view *RoomView) OnMouseEvent(event mauview.MouseEvent) bool {
- return view.content.OnMouseEvent(event)
+ switch {
+ case view.contentScreen.IsInArea(event.Position()):
+ return view.content.OnMouseEvent(view.contentScreen.OffsetMouseEvent(event))
+ case view.topicScreen.IsInArea(event.Position()):
+ return view.topic.OnMouseEvent(view.topicScreen.OffsetMouseEvent(event))
+ case view.inputScreen.IsInArea(event.Position()):
+ return view.input.OnMouseEvent(view.inputScreen.OffsetMouseEvent(event))
+ }
+ return false
}
func (view *RoomView) SetCompletions(completions []string) {
diff --git a/ui/view-main.go b/ui/view-main.go
index 8b2d895..2cbd203 100644
--- a/ui/view-main.go
+++ b/ui/view-main.go
@@ -155,6 +155,7 @@ func (view *MainView) InputSubmit(roomView *RoomView, text string) {
cmd := view.cmdProcessor.ParseCommand(roomView, text)
go view.cmdProcessor.HandleCommand(cmd)
} else {
+ debug.Print(text)
view.SendMessage(roomView, text)
}
roomView.SetInputText("")
@@ -175,7 +176,7 @@ func (view *MainView) sendTempMessage(roomView *RoomView, tempMessage ifc.Messag
if err != nil {
tempMessage.SetState(ifc.MessageStateFailed)
if httpErr, ok := err.(mautrix.HTTPError); ok {
- if respErr, ok := httpErr.WrappedError.(mautrix.RespError); ok {
+ if respErr := httpErr.RespError; respErr != nil {
// Show shorter version if available
err = respErr
}
diff --git a/ui/widget/util.go b/ui/widget/util.go
index 6a2173d..ae8c6b3 100644
--- a/ui/widget/util.go
+++ b/ui/widget/util.go
@@ -57,7 +57,7 @@ func WriteLine(screen mauview.Screen, align int, line string, x, y, maxWidth int
screen.SetContent(x+offsetX+localOffset, y, ch, nil, style)
}
offsetX += chWidth
- if offsetX > maxWidth {
+ if offsetX >= maxWidth {
break
}
}