You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to share something I came up with, in case you were interested in adding it to the library. I tried to create a pull request, but even though I had it in a new branch, it kept on trying to include several other non-related commits.
I came up with this: which I put into textutil.go, line 235 - to the end of the function. The purpose of the code is, if you add term.SetOutputMode(term.Output256) ( I added it just after init like so):
This tells the terminal to run in 256 color mode. The code I added below allows you to take advantage of the extra colors in a theme, at the same time as using the original specification, so you can have a mix of named colors as well as integer code. It also has a check to make sure your integer codes are between 0-255, and it only accepts the integers if it detects you have enabled Output256 mode. Otherwise it will just continue to use the normal template specifications.If you try to use an integer color code without first enabling, it gives you a specific error that you need to add it.
varclr term.Attribute// ---- original codefor_, item:=rangeparts {
item=strings.Trim(item, " ")
item=strings.ToLower(item) // ---- original codeifterm.SetOutputMode(term.OutputCurrent) ==term.Output256 { // --------------- Newly addedifc, err:=strconv.Atoi(item); err==nil {
if (c>=0) && (c<=255) {
clr=term.Attribute(c)
returnclr
} else {
panic(fmt.Sprintf("Color integer must be between 0-255. Current value: %v", c))
}
}
}
if_, err:=strconv.Atoi(item); err==nil {
{
panic(fmt.Sprintf("To use 0-255 integer color you must set terminal output mode: 'term.SetOutputMode(term.Output256)'"))
}
} else {
c, ok:=colorMap[item]
ifok {
clr|=creturnclr
}
}
} // -------------- Newly addedreturnclr
}
I was not sure if you were interested in adding more colors or not, but this is how I did it to make my GUI I showed in one of my other posts.
Thanks!
-MH
The text was updated successfully, but these errors were encountered:
Thank you! I am sorry I missed you issue. I do not remember github sending me notifications about new issue maybe since the early 2019. Whether it was github trouble, or I overlooked all new issues but only after a new issue was added last week, I manually check the list of issues and found a few ones I have not replied to.
On the one hand, support 256 colors looks great. On the other hand, being on Windows 7 that has a console limited to 16 colors, I cannot test and debug 256-color mode effectively. It also means that I cannot include standard themes with 256-colors since they fail on Windows 7. I know, Windows 7 is unsupported by Microsoft since this year. But there are still a lot of people who keep using it.
I wanted to share something I came up with, in case you were interested in adding it to the library. I tried to create a pull request, but even though I had it in a new branch, it kept on trying to include several other non-related commits.
I came up with this: which I put into textutil.go, line 235 - to the end of the function. The purpose of the code is, if you add
term.SetOutputMode(term.Output256)
( I added it just after init like so):This tells the terminal to run in 256 color mode. The code I added below allows you to take advantage of the extra colors in a theme, at the same time as using the original specification, so you can have a mix of named colors as well as integer code. It also has a check to make sure your integer codes are between 0-255, and it only accepts the integers if it detects you have enabled Output256 mode. Otherwise it will just continue to use the normal template specifications.If you try to use an integer color code without first enabling, it gives you a specific error that you need to add it.
I was not sure if you were interested in adding more colors or not, but this is how I did it to make my GUI I showed in one of my other posts.
Thanks!
-MH
The text was updated successfully, but these errors were encountered: