From dacc7fd6a310d3945bc61983ec218d083900a98d Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 17 Mar 2018 14:00:02 +0200 Subject: Fix wide characters in input field and prepare for tab completion --- view-main.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'view-main.go') diff --git a/view-main.go b/view-main.go index acd9576..5a3a70c 100644 --- a/view-main.go +++ b/view-main.go @@ -65,11 +65,14 @@ func (ui *GomuksUI) NewMainView() tview.Primitive { mainView.roomList. ShowSecondaryText(false). + SetSelectedBackgroundColor(tcell.ColorDarkGreen). + SetSelectedTextColor(tcell.ColorWhite). SetBorderPadding(0, 0, 1, 0) mainView.input. SetDoneFunc(mainView.InputDone). SetChangedFunc(mainView.InputChanged). + SetTabCompleteFunc(mainView.InputTabComplete). SetFieldBackgroundColor(tcell.ColorDefault). SetPlaceholder("Send a message..."). SetPlaceholderExtColor(tcell.ColorGray). @@ -93,6 +96,13 @@ func (view *MainView) InputChanged(text string) { } } +func (view *MainView) InputTabComplete(text string, cursorOffset int) { + roomView, _ := view.rooms[view.CurrentRoomID()] + if roomView != nil { + // text[0:cursorOffset] + } +} + func (view *MainView) InputDone(key tcell.Key) { if key == tcell.KeyEnter { room, text := view.CurrentRoomID(), view.input.GetText() @@ -128,7 +138,7 @@ func (view *MainView) HandleCommand(room, command string, args []string) { view.matrix.client.LeaveRoom(room) case "/join": if len(args) == 0 { - view.AddMessage(room, "Usage: /join ") + view.AddMessage(room, "Usage: /join ") break } view.debug.Print(view.matrix.JoinRoom(args[0])) @@ -207,7 +217,7 @@ func (view *MainView) AddRoom(room string) { return } view.roomIDs = append(view.roomIDs, room) - view.addRoom(len(view.roomIDs) - 1, room) + view.addRoom(len(view.roomIDs)-1, room) } func (view *MainView) RemoveRoom(room string) { -- cgit v1.2.3