Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add terminal256color option #93

Merged
merged 1 commit into from
Dec 31, 2017
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