aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-05-23 00:44:08 +0300
committerTulir Asokan <tulir@maunium.net>2018-05-23 00:44:08 +0300
commitbedb9979a9b65dad9d72dcbdb3174508d3714f36 (patch)
treebc5adfadfac2f58fbfe198aec9d93d96cd84656f
parent14903e0cdcd3ba78face2cbe0ad0287da269a1ea (diff)
Update some dependencies
-rw-r--r--Gopkg.lock8
-rw-r--r--vendor/github.com/lucasb-eyer/go-colorful/README.md2
-rw-r--r--vendor/maunium.net/go/gomatrix/events.go1
-rw-r--r--vendor/maunium.net/go/tcell/tscreen.go6
-rw-r--r--vendor/maunium.net/go/tview/application.go1
-rw-r--r--vendor/maunium.net/go/tview/dropdown.go2
-rw-r--r--vendor/maunium.net/go/tview/inputfield.go44
-rw-r--r--vendor/maunium.net/go/tview/list.go18
-rw-r--r--vendor/maunium.net/go/tview/table.go24
-rw-r--r--vendor/maunium.net/go/tview/textview.go106
-rw-r--r--vendor/maunium.net/go/tview/util.go73
11 files changed, 182 insertions, 103 deletions
diff --git a/Gopkg.lock b/Gopkg.lock
index 6c2ff68..b3fe680 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -29,7 +29,7 @@
branch = "master"
name = "github.com/lucasb-eyer/go-colorful"
packages = ["."]
- revision = "231272389856c976b7500c4fffcc52ddf06ff4eb"
+ revision = "fa0f842f26263fb2ace6d6118309c8481e029fc1"
[[projects]]
name = "github.com/mattn/go-runewidth"
@@ -88,7 +88,7 @@
"html",
"html/atom"
]
- revision = "f73e4c9ed3b7ebdd5f699a16a880c2b1994e50dd"
+ revision = "9ef9f5bb98a1fdc41f8cf6c250a4404b4085e389"
[[projects]]
name = "golang.org/x/text"
@@ -124,7 +124,7 @@
branch = "master"
name = "maunium.net/go/gomatrix"
packages = ["."]
- revision = "4ddf8d780ff6a0434a52c256015f7fcd2ca67dc9"
+ revision = "b491397f18b90e34ef54b8b3598666564b90b01a"
[[projects]]
branch = "master"
@@ -139,7 +139,7 @@
branch = "master"
name = "maunium.net/go/tview"
packages = ["."]
- revision = "7eabba90a261a481d36ace89daa79c56582238d7"
+ revision = "8b261597bbdb95dcaef03854aaa0cc192f56b1ff"
[solve-meta]
analyzer-name = "dep"
diff --git a/vendor/github.com/lucasb-eyer/go-colorful/README.md b/vendor/github.com/lucasb-eyer/go-colorful/README.md
index 4744873..c170435 100644
--- a/vendor/github.com/lucasb-eyer/go-colorful/README.md
+++ b/vendor/github.com/lucasb-eyer/go-colorful/README.md
@@ -308,7 +308,7 @@ second is the fast one.
![Warm, fast warm, happy and fast happy random colors, respectively.](doc/colorgens/colorgens.png)
Don't forget to initialize the random seed! You can see the code used for
-generating this picture in `doc/colorgens/golorgens.go`.
+generating this picture in `doc/colorgens/colorgens.go`.
### Getting random palettes
As soon as you need to generate more than one random color, you probably want
diff --git a/vendor/maunium.net/go/gomatrix/events.go b/vendor/maunium.net/go/gomatrix/events.go
index 231dbdd..7233c7c 100644
--- a/vendor/maunium.net/go/gomatrix/events.go
+++ b/vendor/maunium.net/go/gomatrix/events.go
@@ -14,6 +14,7 @@ type Event struct {
ID string `json:"event_id"` // The unique ID of this event
RoomID string `json:"room_id"` // The room the event was sent to. May be nil (e.g. for presence)
Content map[string]interface{} `json:"content"` // The JSON content of the event.
+ Redacts string `json:"redacts,omitempty"` // The event ID that was redacted if a m.room.redaction event
Unsigned Unsigned `json:"unsigned,omitempty"` // Unsigned content set by own homeserver.
}
diff --git a/vendor/maunium.net/go/tcell/tscreen.go b/vendor/maunium.net/go/tcell/tscreen.go
index d8e62b2..dd49814 100644
--- a/vendor/maunium.net/go/tcell/tscreen.go
+++ b/vendor/maunium.net/go/tcell/tscreen.go
@@ -444,8 +444,8 @@ func (t *tScreen) ResetTitle() {
func (t *tScreen) Fini() {
t.Lock()
defer t.Unlock()
-
- ti := t.ti
+
+ ti := t.ti
t.cells.Resize(0, 0)
t.TPuts(ti.ShowCursor)
t.TPuts(ti.AttrOff)
@@ -467,7 +467,7 @@ func (t *tScreen) Fini() {
default:
close(t.quit)
}
-
+
t.termioFini()
}
diff --git a/vendor/maunium.net/go/tview/application.go b/vendor/maunium.net/go/tview/application.go
index 387c4c4..7e6da3a 100644
--- a/vendor/maunium.net/go/tview/application.go
+++ b/vendor/maunium.net/go/tview/application.go
@@ -277,6 +277,7 @@ func (a *Application) Suspend(f func()) bool {
a.Unlock()
panic(err)
}
+ a.screen.EnableMouse()
a.Unlock()
a.Draw()
diff --git a/vendor/maunium.net/go/tview/dropdown.go b/vendor/maunium.net/go/tview/dropdown.go
index 515f978..4e4d888 100644
--- a/vendor/maunium.net/go/tview/dropdown.go
+++ b/vendor/maunium.net/go/tview/dropdown.go
@@ -190,7 +190,7 @@ func (d *DropDown) GetFieldWidth() int {
// callback is called when this option was selected. It may be nil.
func (d *DropDown) AddOption(text string, selected func()) *DropDown {
d.options = append(d.options, &dropDownOption{Text: text, Selected: selected})
- d.list.AddItem(text, "", 0, selected)
+ d.list.AddItem(text, "", 0, nil)
return d
}
diff --git a/vendor/maunium.net/go/tview/inputfield.go b/vendor/maunium.net/go/tview/inputfield.go
index 2c92a93..73224f2 100644
--- a/vendor/maunium.net/go/tview/inputfield.go
+++ b/vendor/maunium.net/go/tview/inputfield.go
@@ -248,40 +248,18 @@ func (i *InputField) Draw(screen tcell.Screen) {
text := i.text
if text == "" && i.placeholder != "" {
Print(screen, i.placeholder, x, y, fieldWidth, AlignLeft, i.placeholderTextColor)
- }
-
- // Draw entered text.
- if i.maskCharacter > 0 {
- text = strings.Repeat(string(i.maskCharacter), utf8.RuneCountInString(i.text))
- }
- fieldWidth-- // We need one cell for the cursor.
- if fieldWidth < runewidth.StringWidth(text) {
- runes := []rune(text)
- for pos := len(runes) - 1; pos >= 0; pos-- {
- ch := runes[pos]
- w := runewidth.RuneWidth(ch)
- if fieldWidth-w < 0 {
- break
- }
- _, _, style, _ := screen.GetContent(x+fieldWidth-w, y)
- style = style.Foreground(i.fieldTextColor)
- for w > 0 {
- fieldWidth--
- screen.SetContent(x+fieldWidth, y, ch, nil, style)
- w--
- }
- }
} else {
- pos := 0
- for _, ch := range text {
- w := runewidth.RuneWidth(ch)
- _, _, style, _ := screen.GetContent(x+pos, y)
- style = style.Foreground(i.fieldTextColor)
- for w > 0 {
- screen.SetContent(x+pos, y, ch, nil, style)
- pos++
- w--
- }
+ // Draw entered text.
+ if i.maskCharacter > 0 {
+ text = strings.Repeat(string(i.maskCharacter), utf8.RuneCountInString(i.text))
+ } else {
+ text = Escape(text)
+ }
+ fieldWidth-- // We need one cell for the cursor.
+ if fieldWidth < runewidth.StringWidth(text) {
+ Print(screen, text, x, y, fieldWidth, AlignRight, i.fieldTextColor)
+ } else {
+ Print(screen, text, x, y, fieldWidth, AlignLeft, i.fieldTextColor)
}
}
diff --git a/vendor/maunium.net/go/tview/list.go b/vendor/maunium.net/go/tview/list.go
index cc25262..bc5be85 100644
--- a/vendor/maunium.net/go/tview/list.go
+++ b/vendor/maunium.net/go/tview/list.go
@@ -222,8 +222,8 @@ func (l *List) Draw(screen tcell.Screen) {
// We want to keep the current selection in view. What is our offset?
var offset int
if l.showSecondaryText {
- if l.currentItem >= height/2 {
- offset = l.currentItem + 1 - (height / 2)
+ if 2*l.currentItem >= height {
+ offset = (2*l.currentItem + 2 - height) / 2
}
} else {
if l.currentItem >= height {
@@ -296,12 +296,14 @@ func (l *List) InputHandler() func(event *tcell.EventKey, setFocus func(p Primit
case tcell.KeyPgUp:
l.currentItem -= 5
case tcell.KeyEnter:
- item := l.items[l.currentItem]
- if item.Selected != nil {
- item.Selected()
- }
- if l.selected != nil {
- l.selected(l.currentItem, item.MainText, item.SecondaryText, item.Shortcut)
+ if l.currentItem >= 0 && l.currentItem < len(l.items) {
+ item := l.items[l.currentItem]
+ if item.Selected != nil {
+ item.Selected()
+ }
+ if l.selected != nil {
+ l.selected(l.currentItem, item.MainText, item.SecondaryText, item.Shortcut)
+ }
}
case tcell.KeyEscape:
if l.done != nil {
diff --git a/vendor/maunium.net/go/tview/table.go b/vendor/maunium.net/go/tview/table.go
index 0446c6a..2491ec7 100644
--- a/vendor/maunium.net/go/tview/table.go
+++ b/vendor/maunium.net/go/tview/table.go
@@ -33,6 +33,9 @@ type TableCell struct {
// The background color of the cell.
BackgroundColor tcell.Color
+ // The style attributes of the cell.
+ Attributes tcell.AttrMask
+
// If set to true, this cell cannot be selected.
NotSelectable bool
@@ -107,6 +110,22 @@ func (c *TableCell) SetBackgroundColor(color tcell.Color) *TableCell {
return c
}
+// SetAttributes sets the cell's text attributes. You can combine different
+// attributes using bitmask operations:
+//
+// cell.SetAttributes(tcell.AttrUnderline | tcell.AttrBold)
+func (c *TableCell) SetAttributes(attr tcell.AttrMask) *TableCell {
+ c.Attributes = attr
+ return c
+}
+
+// SetStyle sets the cell's style (foreground color, background color, and
+// attributes) all at once.
+func (c *TableCell) SetStyle(style tcell.Style) *TableCell {
+ c.Color, c.BackgroundColor, c.Attributes = style.Decompose()
+ return c
+}
+
// SetSelectable sets whether or not this cell can be selected by the user.
func (c *TableCell) SetSelectable(selectable bool) *TableCell {
c.NotSelectable = !selectable
@@ -684,11 +703,10 @@ ColumnLoop:
finalWidth = width - columnX - 1
}
cell.x, cell.y, cell.width = x+columnX+1, y+rowY, finalWidth
- _, printed := Print(screen, cell.Text, x+columnX+1, y+rowY, finalWidth, cell.Align, cell.Color)
+ _, printed := printWithStyle(screen, cell.Text, x+columnX+1, y+rowY, finalWidth, cell.Align, tcell.StyleDefault.Foreground(cell.Color)|tcell.Style(cell.Attributes))
if StringWidth(cell.Text)-printed > 0 && printed > 0 {
_, _, style, _ := screen.GetContent(x+columnX+1+finalWidth-1, y+rowY)
- fg, _, _ := style.Decompose()
- Print(screen, string(GraphicsEllipsis), x+columnX+1+finalWidth-1, y+rowY, 1, AlignLeft, fg)
+ printWithStyle(screen, string(GraphicsEllipsis), x+columnX+1+finalWidth-1, y+rowY, 1, AlignLeft, style)
}
}
diff --git a/vendor/maunium.net/go/tview/textview.go b/vendor/maunium.net/go/tview/textview.go
index 16b9dfb..44aeb1e 100644
--- a/vendor/maunium.net/go/tview/textview.go
+++ b/vendor/maunium.net/go/tview/textview.go
@@ -769,10 +769,60 @@ func (t *TextView) Draw(screen tcell.Screen) {
}
// Print the line.
- var currentTag, currentRegion, currentEscapeTag, skipped int
+ var currentTag, currentRegion, currentEscapeTag, skipped, runeSeqWidth int
+ runeSequence := make([]rune, 0, 10)
+ flush := func() {
+ if len(runeSequence) == 0 {
+ return
+ }
+
+ // Mix the existing style with the new style.
+ _, _, existingStyle, _ := screen.GetContent(x+posX, y+line-t.lineOffset)
+ _, background, _ := existingStyle.Decompose()
+ style := overlayStyle(background, defaultStyle, foregroundColor, backgroundColor, attributes)
+
+ // Do we highlight this character?
+ var highlighted bool
+ if len(regionID) > 0 {
+ if _, ok := t.highlights[regionID]; ok {
+ highlighted = true
+ }
+ }
+ if highlighted {
+ fg, bg, _ := style.Decompose()
+ if bg == tcell.ColorDefault {
+ r, g, b := fg.RGB()
+ c := colorful.Color{R: float64(r) / 255, G: float64(g) / 255, B: float64(b) / 255}
+ _, _, li := c.Hcl()
+ if li < .5 {
+ bg = tcell.ColorWhite
+ } else {
+ bg = tcell.ColorBlack
+ }
+ }
+ style = style.Background(fg).Foreground(bg)
+ }
+
+ // Draw the character.
+ var comb []rune
+ if len(runeSequence) > 1 {
+ // Allocate space for the combining characters only when necessary.
+ comb = make([]rune, len(runeSequence)-1)
+ copy(comb, runeSequence[1:])
+ }
+ for offset := 0; offset < runeSeqWidth; offset++ {
+ screen.SetContent(x+posX+offset, y+line-t.lineOffset, runeSequence[0], comb, style)
+ }
+
+ // Advance.
+ posX += runeSeqWidth
+ runeSequence = runeSequence[:0]
+ runeSeqWidth = 0
+ }
for pos, ch := range text {
// Get the color.
if currentTag < len(colorTags) && pos >= colorTagIndices[currentTag][0] && pos < colorTagIndices[currentTag][1] {
+ flush()
if pos == colorTagIndices[currentTag][1]-1 {
foregroundColor, backgroundColor, attributes = styleFromTag(foregroundColor, backgroundColor, attributes, colorTags[currentTag])
currentTag++
@@ -782,6 +832,7 @@ func (t *TextView) Draw(screen tcell.Screen) {
// Get the region.
if currentRegion < len(regionIndices) && pos >= regionIndices[currentRegion][0] && pos < regionIndices[currentRegion][1] {
+ flush()
if pos == regionIndices[currentRegion][1]-1 {
regionID = regions[currentRegion][1]
currentRegion++
@@ -791,6 +842,7 @@ func (t *TextView) Draw(screen tcell.Screen) {
// Skip the second-to-last character of an escape tag.
if currentEscapeTag < len(escapeIndices) && pos >= escapeIndices[currentEscapeTag][0] && pos < escapeIndices[currentEscapeTag][1] {
+ flush()
if pos == escapeIndices[currentEscapeTag][1]-1 {
currentEscapeTag++
} else if pos == escapeIndices[currentEscapeTag][1]-2 {
@@ -801,7 +853,14 @@ func (t *TextView) Draw(screen tcell.Screen) {
// Determine the width of this rune.
chWidth := runewidth.RuneWidth(ch)
if chWidth == 0 {
- continue
+ // If this is not a modifier, we treat it as a space character.
+ if len(runeSequence) == 0 {
+ ch = ' '
+ chWidth = 1
+ } else {
+ runeSequence = append(runeSequence, ch)
+ continue
+ }
}
// Skip to the right.
@@ -811,44 +870,19 @@ func (t *TextView) Draw(screen tcell.Screen) {
}
// Stop at the right border.
- if posX+chWidth > width {
+ if posX+runeSeqWidth+chWidth > width {
break
}
- // Mix the existing style with the new style.
- _, _, existingStyle, _ := screen.GetContent(x+posX, y+line-t.lineOffset)
- _, background, _ := existingStyle.Decompose()
- style := overlayStyle(background, defaultStyle, foregroundColor, backgroundColor, attributes)
+ // Flush the rune sequence.
+ flush()
- // Do we highlight this character?
- var highlighted bool
- if len(regionID) > 0 {
- if _, ok := t.highlights[regionID]; ok {
- highlighted = true
- }
- }
- if highlighted {
- fg, bg, _ := style.Decompose()
- if bg == tcell.ColorDefault {
- r, g, b := fg.RGB()
- c := colorful.Color{R: float64(r) / 255, G: float64(g) / 255, B: float64(b) / 255}
- _, _, li := c.Hcl()
- if li < .5 {
- bg = tcell.ColorWhite
- } else {
- bg = tcell.ColorBlack
- }
- }
- style = style.Background(fg).Foreground(bg)
- }
-
- // Draw the character.
- for offset := 0; offset < chWidth; offset++ {
- screen.SetContent(x+posX+offset, y+line-t.lineOffset, ch, nil, style)
- }
-
- // Advance.
- posX += chWidth
+ // Queue this rune.
+ runeSequence = append(runeSequence, ch)
+ runeSeqWidth += chWidth
+ }
+ if posX+runeSeqWidth <= width {
+ flush()
}
}
diff --git a/vendor/maunium.net/go/tview/util.go b/vendor/maunium.net/go/tview/util.go
index 2b3a544..41e52dd 100644
--- a/vendor/maunium.net/go/tview/util.go
+++ b/vendor/maunium.net/go/tview/util.go
@@ -297,7 +297,7 @@ func Print(screen tcell.Screen, text string, x, y, maxWidth, align int, color tc
// printWithStyle works like Print() but it takes a style instead of just a
// foreground color.
func printWithStyle(screen tcell.Screen, text string, x, y, maxWidth, align int, style tcell.Style) (int, int) {
- if maxWidth < 0 {
+ if maxWidth <= 0 || len(text) == 0 {
return 0, 0
}
@@ -315,6 +315,9 @@ func printWithStyle(screen tcell.Screen, text string, x, y, maxWidth, align int,
colorPos, escapePos, runePos, startPos int
foregroundColor, backgroundColor, attributes string
)
+ if from >= len(runes) {
+ return ""
+ }
for pos := range text {
// Handle color tags.
if colorPos < len(colorIndices) && pos >= colorIndices[colorPos][0] && pos < colorIndices[colorPos][1] {
@@ -361,6 +364,9 @@ func printWithStyle(screen tcell.Screen, text string, x, y, maxWidth, align int,
width += w
start = index
}
+ for start < len(runes) && runewidth.RuneWidth(runes[start]) == 0 {
+ start++
+ }
return printWithStyle(screen, substring(start, len(runes)), x+maxWidth-width, y, width, AlignLeft, style)
} else if align == AlignCenter {
width := runewidth.StringWidth(strippedText)
@@ -376,12 +382,15 @@ func printWithStyle(screen tcell.Screen, text string, x, y, maxWidth, align int,
var choppedLeft, choppedRight, leftIndex, rightIndex int
rightIndex = len(runes) - 1
for rightIndex > leftIndex && width-choppedLeft-choppedRight > maxWidth {
- leftWidth := runewidth.RuneWidth(runes[leftIndex])
- rightWidth := runewidth.RuneWidth(runes[rightIndex])
if choppedLeft < choppedRight {
+ leftWidth := runewidth.RuneWidth(runes[leftIndex])
choppedLeft += leftWidth
leftIndex++
+ for leftIndex < len(runes) && leftIndex < rightIndex && runewidth.RuneWidth(runes[leftIndex]) == 0 {
+ leftIndex++
+ }
} else {
+ rightWidth := runewidth.RuneWidth(runes[rightIndex])
choppedRight += rightWidth
rightIndex--
}
@@ -397,9 +406,39 @@ func printWithStyle(screen tcell.Screen, text string, x, y, maxWidth, align int,
colorPos, escapePos int
foregroundColor, backgroundColor, attributes string
)
+ runeSequence := make([]rune, 0, 10)
+ runeSeqWidth := 0
+ flush := func() {
+ if len(runeSequence) == 0 {
+ return // Nothing to flush.
+ }
+
+ // Print the rune sequence.
+ finalX := x + drawnWidth
+ _, _, finalStyle, _ := screen.GetContent(finalX, y)
+ _, background, _ := finalStyle.Decompose()
+ finalStyle = overlayStyle(background, style, foregroundColor, backgroundColor, attributes)
+ var comb []rune
+ if len(runeSequence) > 1 {
+ // Allocate space for the combining characters only when necessary.
+ comb = make([]rune, len(runeSequence)-1)
+ copy(comb, runeSequence[1:])
+ }
+ for offset := 0; offset < runeSeqWidth; offset++ {
+ // To avoid undesired effects, we place the same character in all cells.
+ screen.SetContent(finalX+offset, y, runeSequence[0], comb, finalStyle)
+ }
+
+ // Advance and reset.
+ drawn += len(runeSequence)
+ drawnWidth += runeSeqWidth
+ runeSequence = runeSequence[:0]
+ runeSeqWidth = 0
+ }
for pos, ch := range text {
// Handle color tags.
if colorPos < len(colorIndices) && pos >= colorIndices[colorPos][0] && pos < colorIndices[colorPos][1] {
+ flush()
if pos == colorIndices[colorPos][1]-1 {
foregroundColor, backgroundColor, attributes = styleFromTag(foregroundColor, backgroundColor, attributes, colors[colorPos])
colorPos++
@@ -409,6 +448,7 @@ func printWithStyle(screen tcell.Screen, text string, x, y, maxWidth, align int,
// Handle escape tags.
if escapePos < len(escapeIndices) && pos >= escapeIndices[escapePos][0] && pos < escapeIndices[escapePos][1] {
+ flush()
if pos == escapeIndices[escapePos][1]-1 {
escapePos++
} else if pos == escapeIndices[escapePos][1]-2 {
@@ -419,21 +459,26 @@ func printWithStyle(screen tcell.Screen, text string, x, y, maxWidth, align int,
// Check if we have enough space for this rune.
chWidth := runewidth.RuneWidth(ch)
if drawnWidth+chWidth > maxWidth {
- break
+ break // No. We're done then.
}
- finalX := x + drawnWidth
- // Print the rune.
- _, _, finalStyle, _ := screen.GetContent(finalX, y)
- _, background, _ := finalStyle.Decompose()
- finalStyle = overlayStyle(background, style, foregroundColor, backgroundColor, attributes)
- for offset := 0; offset < chWidth; offset++ {
- // To avoid undesired effects, we place the same character in all cells.
- screen.SetContent(finalX+offset, y, ch, nil, finalStyle)
+ // Put this rune in the queue.
+ if chWidth == 0 {
+ // If this is not a modifier, we treat it as a space character.
+ if len(runeSequence) == 0 {
+ ch = ' '
+ chWidth = 1
+ }
+ } else {
+ // We have a character. Flush all previous runes.
+ flush()
}
+ runeSequence = append(runeSequence, ch)
+ runeSeqWidth += chWidth
- drawn++
- drawnWidth += chWidth
+ }
+ if drawnWidth+runeSeqWidth <= maxWidth {
+ flush()
}
return drawn, drawnWidth