This commit is contained in:
Tulir Asokan 2018-06-02 00:44:21 +03:00
parent 134604edce
commit b9079e22d2
16 changed files with 28 additions and 28 deletions

View File

@ -21,13 +21,13 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"encoding/json"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"maunium.net/go/gomatrix" "maunium.net/go/gomatrix"
"maunium.net/go/gomuks/debug" "maunium.net/go/gomuks/debug"
"maunium.net/go/gomuks/matrix/pushrules" "maunium.net/go/gomuks/matrix/pushrules"
"maunium.net/go/gomuks/matrix/rooms" "maunium.net/go/gomuks/matrix/rooms"
"strings" "strings"
"encoding/json"
) )
type AuthCache struct { type AuthCache struct {

View File

@ -30,6 +30,8 @@ import (
"strings" "strings"
"time" "time"
"crypto/tls"
"encoding/json"
"gopkg.in/russross/blackfriday.v2" "gopkg.in/russross/blackfriday.v2"
"maunium.net/go/gomatrix" "maunium.net/go/gomatrix"
"maunium.net/go/gomuks/config" "maunium.net/go/gomuks/config"
@ -38,8 +40,6 @@ import (
"maunium.net/go/gomuks/lib/bfhtml" "maunium.net/go/gomuks/lib/bfhtml"
"maunium.net/go/gomuks/matrix/pushrules" "maunium.net/go/gomuks/matrix/pushrules"
"maunium.net/go/gomuks/matrix/rooms" "maunium.net/go/gomuks/matrix/rooms"
"crypto/tls"
"encoding/json"
) )
// Container is a wrapper for a gomatrix Client and some other stuff. // Container is a wrapper for a gomatrix Client and some other stuff.

View File

@ -17,11 +17,11 @@
package ui package ui
import ( import (
"maunium.net/go/gomuks/interface" "fmt"
"strings"
"maunium.net/go/gomuks/config" "maunium.net/go/gomuks/config"
"maunium.net/go/gomuks/debug" "maunium.net/go/gomuks/debug"
"fmt" "maunium.net/go/gomuks/interface"
"strings"
) )
type gomuksPointerContainer struct { type gomuksPointerContainer struct {

View File

@ -17,9 +17,9 @@
package ui package ui
import ( import (
"encoding/json"
"maunium.net/go/gomuks/debug" "maunium.net/go/gomuks/debug"
"strings" "strings"
"encoding/json"
) )
func cmdMe(cmd *Command) { func cmdMe(cmd *Command) {

View File

@ -24,13 +24,13 @@ import (
"strings" "strings"
"github.com/mattn/go-runewidth" "github.com/mattn/go-runewidth"
"maunium.net/go/gomuks/config"
"maunium.net/go/gomuks/debug" "maunium.net/go/gomuks/debug"
"maunium.net/go/gomuks/interface" "maunium.net/go/gomuks/interface"
"maunium.net/go/gomuks/lib/open" "maunium.net/go/gomuks/lib/open"
"maunium.net/go/gomuks/ui/messages" "maunium.net/go/gomuks/ui/messages"
"maunium.net/go/gomuks/ui/messages/tstring" "maunium.net/go/gomuks/ui/messages/tstring"
"maunium.net/go/gomuks/ui/widget" "maunium.net/go/gomuks/ui/widget"
"maunium.net/go/gomuks/config"
"maunium.net/go/tcell" "maunium.net/go/tcell"
"maunium.net/go/tview" "maunium.net/go/tview"
) )

View File

@ -20,11 +20,11 @@ import (
"encoding/gob" "encoding/gob"
"time" "time"
"maunium.net/go/gomuks/config"
"maunium.net/go/gomuks/interface" "maunium.net/go/gomuks/interface"
"maunium.net/go/gomuks/ui/messages/tstring" "maunium.net/go/gomuks/ui/messages/tstring"
"maunium.net/go/gomuks/ui/widget" "maunium.net/go/gomuks/ui/widget"
"maunium.net/go/tcell" "maunium.net/go/tcell"
"maunium.net/go/gomuks/config"
) )
func init() { func init() {
@ -44,7 +44,7 @@ type BaseMessage struct {
buffer []tstring.TString buffer []tstring.TString
plainBuffer []tstring.TString plainBuffer []tstring.TString
prevBufferWidth int prevBufferWidth int
prevPrefs config.UserPreferences prevPrefs config.UserPreferences
} }
func newBaseMessage(id, sender, displayname, msgtype string, timestamp time.Time) BaseMessage { func newBaseMessage(id, sender, displayname, msgtype string, timestamp time.Time) BaseMessage {

View File

@ -20,8 +20,8 @@ import (
"encoding/gob" "encoding/gob"
"time" "time"
"maunium.net/go/gomuks/ui/messages/tstring"
"maunium.net/go/gomuks/config" "maunium.net/go/gomuks/config"
"maunium.net/go/gomuks/ui/messages/tstring"
) )
func init() { func init() {
@ -37,7 +37,7 @@ type ExpandedTextMessage struct {
func NewExpandedTextMessage(id, sender, displayname, msgtype string, text tstring.TString, timestamp time.Time) UIMessage { func NewExpandedTextMessage(id, sender, displayname, msgtype string, text tstring.TString, timestamp time.Time) UIMessage {
return &ExpandedTextMessage{ return &ExpandedTextMessage{
BaseMessage: newBaseMessage(id, sender, displayname, msgtype, timestamp), BaseMessage: newBaseMessage(id, sender, displayname, msgtype, timestamp),
MsgText: text, MsgText: text,
} }
} }

View File

@ -24,12 +24,12 @@ import (
"image/color" "image/color"
"maunium.net/go/gomuks/config"
"maunium.net/go/gomuks/debug" "maunium.net/go/gomuks/debug"
"maunium.net/go/gomuks/interface" "maunium.net/go/gomuks/interface"
"maunium.net/go/gomuks/lib/ansimage" "maunium.net/go/gomuks/lib/ansimage"
"maunium.net/go/gomuks/ui/messages/tstring" "maunium.net/go/gomuks/ui/messages/tstring"
"maunium.net/go/tcell" "maunium.net/go/tcell"
"maunium.net/go/gomuks/config"
) )
func init() { func init() {
@ -38,7 +38,7 @@ func init() {
type ImageMessage struct { type ImageMessage struct {
BaseMessage BaseMessage
Body string Body string
Homeserver string Homeserver string
FileID string FileID string
data []byte data []byte

View File

@ -17,9 +17,9 @@
package messages package messages
import ( import (
"maunium.net/go/gomuks/config"
"maunium.net/go/gomuks/interface" "maunium.net/go/gomuks/interface"
"maunium.net/go/gomuks/ui/messages/tstring" "maunium.net/go/gomuks/ui/messages/tstring"
"maunium.net/go/gomuks/config"
) )
// UIMessage is a wrapper for the content and metadata of a Matrix message intended to be displayed. // UIMessage is a wrapper for the content and metadata of a Matrix message intended to be displayed.

View File

@ -22,12 +22,12 @@ import (
"regexp" "regexp"
"strings" "strings"
"golang.org/x/net/html"
"maunium.net/go/gomatrix" "maunium.net/go/gomatrix"
"maunium.net/go/gomuks/matrix/rooms" "maunium.net/go/gomuks/matrix/rooms"
"maunium.net/go/gomuks/ui/messages/tstring" "maunium.net/go/gomuks/ui/messages/tstring"
"maunium.net/go/gomuks/ui/widget" "maunium.net/go/gomuks/ui/widget"
"maunium.net/go/tcell" "maunium.net/go/tcell"
"golang.org/x/net/html"
"strconv" "strconv"
) )
@ -68,7 +68,7 @@ func (parser *htmlParser) getAttribute(node *html.Node, attribute string) string
} }
func digits(num int) int { func digits(num int) int {
return int(math.Floor(math.Log10(float64(num)))+1) return int(math.Floor(math.Log10(float64(num))) + 1)
} }
func (parser *htmlParser) listToTString(node *html.Node, stripLinebreak bool) tstring.TString { func (parser *htmlParser) listToTString(node *html.Node, stripLinebreak bool) tstring.TString {

View File

@ -147,7 +147,7 @@ func getMembershipEventContent(room *rooms.Room, evt *gomatrix.Event) (sender st
text = tstring.NewColorTString(fmt.Sprintf("%s changed their display name to %s.", prevDisplayname, displayname), tcell.ColorGreen) text = tstring.NewColorTString(fmt.Sprintf("%s changed their display name to %s.", prevDisplayname, displayname), tcell.ColorGreen)
color := widget.GetHashColor(*evt.StateKey) color := widget.GetHashColor(*evt.StateKey)
text.Colorize(0, len(prevDisplayname), color) text.Colorize(0, len(prevDisplayname), color)
text.Colorize(len(prevDisplayname) + len(" changed their display name to "), len(displayname), color) text.Colorize(len(prevDisplayname)+len(" changed their display name to "), len(displayname), color)
} }
return return
} }

View File

@ -17,19 +17,19 @@
package messages package messages
import ( import (
"regexp"
"maunium.net/go/gomuks/ui/messages/tstring"
"fmt" "fmt"
"maunium.net/go/gomuks/config" "maunium.net/go/gomuks/config"
"maunium.net/go/gomuks/ui/messages/tstring"
"regexp"
) )
// Regular expressions used to split lines when calculating the buffer. // Regular expressions used to split lines when calculating the buffer.
// //
// From tview/textview.go // From tview/textview.go
var ( var (
boundaryPattern = regexp.MustCompile(`([[:punct:]]\s*|\s+)`) boundaryPattern = regexp.MustCompile(`([[:punct:]]\s*|\s+)`)
bareBoundaryPattern = regexp.MustCompile(`(\s+)`) bareBoundaryPattern = regexp.MustCompile(`(\s+)`)
spacePattern = regexp.MustCompile(`\s+`) spacePattern = regexp.MustCompile(`\s+`)
) )
func matchBoundaryPattern(bare bool, extract tstring.TString) tstring.TString { func matchBoundaryPattern(bare bool, extract tstring.TString) tstring.TString {

View File

@ -21,9 +21,9 @@ import (
"fmt" "fmt"
"time" "time"
"maunium.net/go/gomuks/config"
"maunium.net/go/gomuks/interface" "maunium.net/go/gomuks/interface"
"maunium.net/go/gomuks/ui/messages/tstring" "maunium.net/go/gomuks/ui/messages/tstring"
"maunium.net/go/gomuks/config"
) )
func init() { func init() {
@ -40,7 +40,7 @@ type TextMessage struct {
func NewTextMessage(id, sender, displayname, msgtype, text string, timestamp time.Time) UIMessage { func NewTextMessage(id, sender, displayname, msgtype, text string, timestamp time.Time) UIMessage {
return &TextMessage{ return &TextMessage{
BaseMessage: newBaseMessage(id, sender, displayname, msgtype, timestamp), BaseMessage: newBaseMessage(id, sender, displayname, msgtype, timestamp),
MsgText: text, MsgText: text,
} }
} }

View File

@ -108,7 +108,7 @@ func (str TString) TrimLeft(fn func(rune) bool) TString {
} }
func (str TString) TrimRight(fn func(rune) bool) TString { func (str TString) TrimRight(fn func(rune) bool) TString {
for i := len(str)-1; i >= 0; i-- { for i := len(str) - 1; i >= 0; i-- {
if !fn(str[i].Char) { if !fn(str[i].Char) {
return append(NewBlankTString(), str[:i+1]...) return append(NewBlankTString(), str[:i+1]...)
} }

View File

@ -25,6 +25,7 @@ import (
"time" "time"
"github.com/mattn/go-runewidth" "github.com/mattn/go-runewidth"
"maunium.net/go/gomuks/config"
"maunium.net/go/gomuks/interface" "maunium.net/go/gomuks/interface"
"maunium.net/go/gomuks/lib/util" "maunium.net/go/gomuks/lib/util"
"maunium.net/go/gomuks/matrix/rooms" "maunium.net/go/gomuks/matrix/rooms"
@ -32,7 +33,6 @@ import (
"maunium.net/go/gomuks/ui/widget" "maunium.net/go/gomuks/ui/widget"
"maunium.net/go/tcell" "maunium.net/go/tcell"
"maunium.net/go/tview" "maunium.net/go/tview"
"maunium.net/go/gomuks/config"
) )
type RoomView struct { type RoomView struct {
@ -154,7 +154,7 @@ func (view *RoomView) GetStatus() string {
var buf strings.Builder var buf strings.Builder
if len(view.completions.list) > 0 { 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{} view.completions.list = []string{}
} else { } else {
buf.WriteString(strings.Join(view.completions.list, ", ")) buf.WriteString(strings.Join(view.completions.list, ", "))

View File

@ -21,6 +21,7 @@ import (
"time" "time"
"unicode" "unicode"
"bufio"
"maunium.net/go/gomatrix" "maunium.net/go/gomatrix"
"maunium.net/go/gomuks/config" "maunium.net/go/gomuks/config"
"maunium.net/go/gomuks/debug" "maunium.net/go/gomuks/debug"
@ -32,7 +33,6 @@ import (
"maunium.net/go/gomuks/ui/widget" "maunium.net/go/gomuks/ui/widget"
"maunium.net/go/tcell" "maunium.net/go/tcell"
"maunium.net/go/tview" "maunium.net/go/tview"
"bufio"
"os" "os"
) )