Added italics and strikethrough to style attributes. Resolves #457

pull/663/head
Oliver 3 years ago
parent ee97a7ab39
commit 5508f4b002

@ -7,7 +7,7 @@ import (
"github.com/rivo/tview"
)
const colorsText = `You can use color tags almost everywhere to partially change the color of a string. Simply put a color name or hex string in square brackets to change the following characters' color. H[green]er[white]e i[yellow]s a[darkcyan]n ex[red]amp[white]le. The [black:red]tags [black:green]look [black:yellow]like [::u]this: [blue:yellow:u[] [#00ff00[]`
const colorsText = `You can use color tags almost everywhere to partially change the color of a string. Simply put a color name or hex string in square brackets to change [::s]all[::-]the following characters' color. H[green]er[white]e i[yellow]s a[darkcyan]n ex[red]amp[white]le. [::i]The [black:red]tags [black:green]look [black:yellow]like [::u]this: [blue:yellow:u[] [#00ff00[]`
// Colors demonstrates how to use colors.
func Colors(nextSlide func()) (title string, content tview.Primitive) {

@ -96,9 +96,11 @@ terminal):
l: blink
b: bold
i: italic
d: dim
r: reverse (switch foreground and background color)
u: underline
s: strike-through
Examples:

@ -637,7 +637,7 @@ func (t *Table) GetOffset() (row, column int) {
// are evaluated. When true, all rows in the table are evaluated.
//
// Set this flag to true to avoid shifting column widths when the table is
// scrolled. (May be slower for large tables.)
// scrolled. (May come with a performance penalty for large tables.)
//
// Use with caution on very large tables, especially those not backed by the
// default TableContent data structure.

@ -20,7 +20,7 @@ const (
// Common regular expressions.
var (
colorPattern = regexp.MustCompile(`\[([a-zA-Z]+|#[0-9a-zA-Z]{6}|\-)?(:([a-zA-Z]+|#[0-9a-zA-Z]{6}|\-)?(:([lbdru]+|\-)?)?)?\]`)
colorPattern = regexp.MustCompile(`\[([a-zA-Z]+|#[0-9a-zA-Z]{6}|\-)?(:([a-zA-Z]+|#[0-9a-zA-Z]{6}|\-)?(:([lbidrus]+|\-)?)?)?\]`)
regionPattern = regexp.MustCompile(`\["([a-zA-Z0-9_,;: \-\.]*)"\]`)
escapePattern = regexp.MustCompile(`\[([a-zA-Z0-9_,;: \-\."#]+)\[(\[*)\]`)
nonEscapePattern = regexp.MustCompile(`(\[[a-zA-Z0-9_,;: \-\."#]+\[*)\]`)
@ -124,11 +124,12 @@ func overlayStyle(style tcell.Style, fgColor, bgColor, attributes string) tcell.
}
if attributes == "-" {
style = style.Bold(defAttr&tcell.AttrBold > 0)
style = style.Blink(defAttr&tcell.AttrBlink > 0)
style = style.Reverse(defAttr&tcell.AttrReverse > 0)
style = style.Underline(defAttr&tcell.AttrUnderline > 0)
style = style.Dim(defAttr&tcell.AttrDim > 0)
style = style.Bold(defAttr&tcell.AttrBold > 0).
Italic(defAttr&tcell.AttrItalic > 0).
Blink(defAttr&tcell.AttrBlink > 0).
Reverse(defAttr&tcell.AttrReverse > 0).
Underline(defAttr&tcell.AttrUnderline > 0).
Dim(defAttr&tcell.AttrDim > 0)
} else if attributes != "" {
style = style.Normal()
for _, flag := range attributes {
@ -137,12 +138,16 @@ func overlayStyle(style tcell.Style, fgColor, bgColor, attributes string) tcell.
style = style.Blink(true)
case 'b':
style = style.Bold(true)
case 'i':
style = style.Italic(true)
case 'd':
style = style.Dim(true)
case 'r':
style = style.Reverse(true)
case 'u':
style = style.Underline(true)
case 's':
style = style.StrikeThrough(true)
}
}
}

Loading…
Cancel
Save