diff --git a/demos/presentation/colors.go b/demos/presentation/colors.go index 3b0ae81..d277750 100644 --- a/demos/presentation/colors.go +++ b/demos/presentation/colors.go @@ -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) { diff --git a/doc.go b/doc.go index 1e11412..d4e071e 100644 --- a/doc.go +++ b/doc.go @@ -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: diff --git a/table.go b/table.go index b45207f..2d7b1a2 100644 --- a/table.go +++ b/table.go @@ -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. diff --git a/util.go b/util.go index 440c7be..3c95203 100644 --- a/util.go +++ b/util.go @@ -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) } } }