[GH-ISSUE #445] Some weird ANSI color issues #321

Closed
opened 2026-03-04 01:03:56 +03:00 by kerem · 2 comments
Owner

Originally created by @mjwhitta on GitHub (May 12, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/445

See #444. Apologies for creating the PR first. I should have read the contributing guide first.

Originally created by @mjwhitta on GitHub (May 12, 2020). Original GitHub issue: https://github.com/rivo/tview/issues/445 See #444. Apologies for creating the PR first. I should have read the contributing guide first.
kerem closed this issue 2026-03-04 01:03:57 +03:00
Author
Owner

@mjwhitta commented on GitHub (May 12, 2020):

Here's some sample code:

package main

import (
	"io"

	tviewfix "github.com/mjwhitta/tview"
	"github.com/rivo/tview"
	hl "gitlab.com/mjwhitta/hilighter"
)

var app *tview.Application

func createTV(title string) (tv *tview.TextView) {
	tv = tview.NewTextView()
	tv.SetBorder(true)
	tv.SetChangedFunc(
		func() {
			app.Draw()
		},
	)
	tv.SetDynamicColors(true)
	tv.SetScrollable(true)
	tv.SetTitle(title)
	tv.SetWordWrap(true)
	tv.SetWrap(true)

	return
}

func main() {
	var after *tview.TextView
	var before *tview.TextView
	var e error
	var layout *tview.Flex
	var newWriter io.Writer
	var oldWriter io.Writer
	var table []string = hl.Table()

	// Top widget
	before = createTV("BEFORE")
	oldWriter = tview.ANSIWriter(before)

	// Bottom widget
	after = createTV("AFTER")
	newWriter = tviewfix.ANSIWriter(after)

	// Layout
	layout = tview.NewFlex()
	layout.AddItem(before, 0, 1, false)
	layout.AddItem(after, 0, 1, false)
	layout.SetDirection(tview.FlexRow)

	// App
	app = tview.NewApplication()
	app.SetRoot(layout, true)

	// Add demo text
	hl.Fprintln(oldWriter, table[0])
	hl.Fprintln(oldWriter, table[1])
	hl.Fprintln(newWriter, table[0])
	hl.Fprintln(newWriter, table[1])

	if e = app.Run(); e != nil {
		hl.PrintlnRed("[!] " + e.Error())
	}
}
<!-- gh-comment-id:627447762 --> @mjwhitta commented on GitHub (May 12, 2020): Here's some sample code: ```go package main import ( "io" tviewfix "github.com/mjwhitta/tview" "github.com/rivo/tview" hl "gitlab.com/mjwhitta/hilighter" ) var app *tview.Application func createTV(title string) (tv *tview.TextView) { tv = tview.NewTextView() tv.SetBorder(true) tv.SetChangedFunc( func() { app.Draw() }, ) tv.SetDynamicColors(true) tv.SetScrollable(true) tv.SetTitle(title) tv.SetWordWrap(true) tv.SetWrap(true) return } func main() { var after *tview.TextView var before *tview.TextView var e error var layout *tview.Flex var newWriter io.Writer var oldWriter io.Writer var table []string = hl.Table() // Top widget before = createTV("BEFORE") oldWriter = tview.ANSIWriter(before) // Bottom widget after = createTV("AFTER") newWriter = tviewfix.ANSIWriter(after) // Layout layout = tview.NewFlex() layout.AddItem(before, 0, 1, false) layout.AddItem(after, 0, 1, false) layout.SetDirection(tview.FlexRow) // App app = tview.NewApplication() app.SetRoot(layout, true) // Add demo text hl.Fprintln(oldWriter, table[0]) hl.Fprintln(oldWriter, table[1]) hl.Fprintln(newWriter, table[0]) hl.Fprintln(newWriter, table[1]) if e = app.Run(); e != nil { hl.PrintlnRed("[!] " + e.Error()) } } ```
Author
Owner

@rivo commented on GitHub (May 28, 2020):

Thanks for noticing. Yes, your PR seems to be the correct solution to this. It's merged now.

<!-- gh-comment-id:635567213 --> @rivo commented on GitHub (May 28, 2020): Thanks for noticing. Yes, your PR seems to be the correct solution to this. It's merged now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#321
No description provided.