aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debug.go8
-rw-r--r--gomuks.go2
-rw-r--r--ui.go2
-rw-r--r--uiutil.go2
-rw-r--r--view-login.go7
-rw-r--r--view-main.go33
6 files changed, 23 insertions, 31 deletions
diff --git a/debug.go b/debug.go
index 2498f9d..b91ef60 100644
--- a/debug.go
+++ b/debug.go
@@ -19,7 +19,7 @@ package main
import (
"fmt"
- "github.com/rivo/tview"
+ "maunium.net/go/tview"
)
const DebugPaneHeight = 40
@@ -54,17 +54,17 @@ func NewDebugPane(gmx Gomuks) *DebugPane {
}
func (db *DebugPane) Printf(text string, args ...interface{}) {
- db.Write(fmt.Sprintf(text, args...))
+ db.Write(fmt.Sprintf(text, args...) + "\n")
}
func (db *DebugPane) Print(text ...interface{}) {
- db.Write(fmt.Sprint(text...))
+ db.Write(fmt.Sprintln(text...))
}
func (db *DebugPane) Write(text string) {
if db.pane != nil {
db.num++
- fmt.Fprintf(db.pane, "[%d] %s\n", db.num, text)
+ fmt.Fprintf(db.pane, "[%d] %s", db.num, text)
}
}
diff --git a/gomuks.go b/gomuks.go
index ac7d534..6af5997 100644
--- a/gomuks.go
+++ b/gomuks.go
@@ -21,7 +21,7 @@ import (
"path/filepath"
"github.com/matrix-org/gomatrix"
- "github.com/rivo/tview"
+ "maunium.net/go/tview"
)
type Gomuks interface {
diff --git a/ui.go b/ui.go
index 99c64eb..8eec7fe 100644
--- a/ui.go
+++ b/ui.go
@@ -17,7 +17,7 @@
package main
import (
- "github.com/rivo/tview"
+ "maunium.net/go/tview"
)
// Allowed views in GomuksUI
diff --git a/uiutil.go b/uiutil.go
index 1b29ebf..0ba37ef 100644
--- a/uiutil.go
+++ b/uiutil.go
@@ -18,7 +18,7 @@ package main
import (
"github.com/gdamore/tcell"
- "github.com/rivo/tview"
+ "maunium.net/go/tview"
)
func Center(width, height int, p tview.Primitive) tview.Primitive {
diff --git a/view-login.go b/view-login.go
index 78981a9..9b46102 100644
--- a/view-login.go
+++ b/view-login.go
@@ -17,7 +17,7 @@
package main
import (
- "github.com/rivo/tview"
+ "maunium.net/go/tview"
)
func (ui *GomuksUI) MakeLoginUI() tview.Primitive {
@@ -26,6 +26,11 @@ func (ui *GomuksUI) MakeLoginUI() tview.Primitive {
if len(hs) == 0 {
hs = "https://matrix.org"
}
+// homeserver := tview.NewInputField().SetLabel("Homeserver").SetText(hs).SetFieldWidth(30)
+// username := tview.NewInputField().SetLabel("Username").SetText(ui.config.MXID).SetFieldWidth(30)
+// password := tview.NewInputField().SetLabel("Password").SetMaskCharacter('*').SetFieldWidth(30)
+// form.AddFormItem(homeserver).AddFormItem(username).AddFormItem(password)
+
form.
AddInputField("Homeserver", hs, 30, nil, nil).
AddInputField("Username", ui.config.MXID, 30, nil, nil).
diff --git a/view-main.go b/view-main.go
index acacddb..d36160e 100644
--- a/view-main.go
+++ b/view-main.go
@@ -21,30 +21,17 @@ import (
"strings"
"github.com/gdamore/tcell"
- "github.com/rivo/tview"
+ "maunium.net/go/tview"
)
type RoomView struct {
- *tview.Grid
-
- sender, message *tview.TextView
+ *tview.TextView
}
func NewRoomView() *RoomView {
view := &RoomView{
- tview.NewGrid(),
- tview.NewTextView(),
tview.NewTextView(),
}
- view.SetColumns(30, 0).SetRows(0)
-
- view.sender.SetTextAlign(tview.AlignRight)
- view.sender.SetScrollable(true)
- view.message.SetScrollable(true)
-
- view.AddItem(view.sender, 0, 0, 1, 1, 1, 1, false)
- view.AddItem(view.message, 0, 1, 1, 1, 1, 1, false)
-
return view
}
@@ -53,11 +40,11 @@ func (ui *GomuksUI) MakeMainUI() tview.Primitive {
ui.mainViewRoomList = tview.NewList().ShowSecondaryText(false)
ui.mainViewRoomList.SetBorderPadding(1, 1, 1, 1)
- ui.mainView.AddItem(ui.mainViewRoomList, 0, 0, 2, 1, 2, 1, false)
+ ui.mainView.AddItem(ui.mainViewRoomList, 0, 0, 2, 1, 2, 2, false)
ui.mainViewRoomView = tview.NewPages()
ui.mainViewRoomView.SetChangedFunc(ui.Render)
- ui.mainView.AddItem(ui.mainViewRoomView, 0, 1, 1, 1, 1, 1, false)
+ ui.mainView.AddItem(ui.mainViewRoomView, 0, 1, 1, 1, 2, 2, false)
ui.mainViewInput = tview.NewInputField()
ui.mainViewInput.SetDoneFunc(func(key tcell.Key) {
@@ -76,7 +63,7 @@ func (ui *GomuksUI) MakeMainUI() tview.Primitive {
ui.mainViewInput.SetText("")
}
})
- ui.mainView.AddItem(ui.mainViewInput, 1, 1, 1, 1, 1, 1, true)
+ ui.mainView.AddItem(ui.mainViewInput, 1, 1, 1, 1, 2, 2, true)
ui.debug.Print(ui.mainViewInput.SetInputCapture(ui.MainUIKeyHandler))
@@ -104,7 +91,7 @@ func (ui *GomuksUI) HandleCommand(room, command string, args []string) {
}
func (ui *GomuksUI) MainUIKeyHandler(key *tcell.EventKey) *tcell.EventKey {
- ui.debug.Print(key)
+ ui.debug.Print("Main UI keypress:", key.Key(), key.Modifiers())
if key.Modifiers() == tcell.ModCtrl {
if key.Key() == tcell.KeyDown {
ui.SwitchRoom(ui.currentRoomIndex + 1)
@@ -112,10 +99,11 @@ func (ui *GomuksUI) MainUIKeyHandler(key *tcell.EventKey) *tcell.EventKey {
} else if key.Key() == tcell.KeyUp {
ui.SwitchRoom(ui.currentRoomIndex - 1)
ui.mainViewRoomList.SetCurrentItem(ui.currentRoomIndex)
+ } else {
+ return key
}
} else if key.Key() == tcell.KeyPgUp || key.Key() == tcell.KeyPgDn {
- ui.mainViewRooms[ui.currentRoom()].sender.InputHandler()(key, nil)
- ui.mainViewRooms[ui.currentRoom()].message.InputHandler()(key, nil)
+ ui.mainViewRooms[ui.currentRoom()].InputHandler()(key, nil)
} else {
return key
}
@@ -157,8 +145,7 @@ func (ui *GomuksUI) SwitchRoom(roomIndex int) {
func (ui *GomuksUI) Append(room, sender, message string) {
roomView, ok := ui.mainViewRooms[room]
if ok {
- fmt.Fprintf(roomView.sender, sender)
- fmt.Fprintf(roomView.message, sender)
+ fmt.Fprintf(roomView, "<%s> %s\n", sender, message)
ui.Render()
}
}