Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ func run() {
}
defer termbox.Close()

termbox.SetOutputMode(termbox.Output256)

app := newApp()

if _, err := os.Stat(gConfigPath); !os.IsNotExist(err) {
Expand Down
14 changes: 14 additions & 0 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,20 @@ func applyAnsiCodes(s string, fg, bg termbox.Attribute) (termbox.Attribute, term
nums = append(nums, n)
}

// Parse 256 color terminal ansi codes
// termbox-go has a color offset of one, because of attributes
if len(nums) == 3 {
if nums[0] == 48 && nums[1] == 5 {
bg = termbox.Attribute(nums[2])
bg++
}
if nums[0] == 38 && nums[1] == 5 {
fg = termbox.Attribute(nums[2])
fg++
}
return fg, bg
}

for _, n := range nums {
attr, ok := gAnsiCodes[n]
if !ok {
Expand Down