mirror of
https://github.com/mum4k/termdash.git
synced 2026-04-27 03:15:55 +03:00
[GH-ISSUE #249] Font modifier cell options (bold, italic, underline) #137
Labels
No labels
bug
cleanup
enhancement
enhancement
enhancement
good first issue
help wanted
help wanted
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/termdash#137
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @dyc3 on GitHub (Nov 7, 2020).
Original GitHub issue: https://github.com/mum4k/termdash/issues/249
Originally assigned to: @dyc3 on GitHub.
It's currently not possible to set text as bold, italic, underline, or strikethrough.
\e[1m\e[3m\e[4m\e[9m@mum4k commented on GitHub (Nov 10, 2020):
This is a good point. Looks like we are in luck and both of our terminal layer libraries support at least some of these attributes (details below). Looks like tcell supports more of them than termbox-go, so this may be a point where we start breaking away from termbox.
termbox-go:
github.com/nsf/termbox-go@9b52a5faed/api_common.go (L155-L159)tcell:
github.com/gdamore/tcell@7d87d8188c/style.go (L87-L127)@dyc3 please let me know if you are interested in implementing this feature in termdash. If you are, I can provide some pointers. Alternatively I could work on this in the near future.
@dyc3 commented on GitHub (Nov 10, 2020):
I could give it a shot. If you could point me in the right direction that would help a lot.
@mum4k commented on GitHub (Nov 11, 2020):
Thank you @dyc3 for the offer of help. I will compile some instructions and pointers and respond here once done.
@mum4k commented on GitHub (Nov 11, 2020):
Termdash has a core concept - a terminal is essentially a cell buffer, i.e. a 2D matrix of cells. Each cell is represented as the Cell object:
github.com/mum4k/termdash@2a7dafa3a8/private/canvas/buffer/buffer.go (L36-L43)Notice the cell.Options object which stores options for each cell instance:
github.com/mum4k/termdash@2a7dafa3a8/cell/cell.go (L25-L28)When Termdash draws the cell buffer onto a terminal, it accesses the terminal true this API:
github.com/mum4k/termdash@2a7dafa3a8/terminal/terminalapi/terminalapi.go (L25-L27)Which currently has two implementations, one for termbox-go and one for tcell. Notice that the
SetCellmethod directly takes a list of cell options that it applies using methods specific to the implementation:github.com/mum4k/termdash@2a7dafa3a8/terminal/terminalapi/terminalapi.go (L46)Hopefully this introduction helps, what we need to do is:
Note that termbox-go supports a smaller set of options, but we can still implement all of them in termdash. The
SetCellmethod on the terminalapi interface returns an error, so we can simply return an error if say termdash was started with termbox-go and an unsupported option was requested.Please feel free to let me know if I can provide more details and thanks again for your help.
@dyc3 commented on GitHub (Nov 11, 2020):
I've found that both termbox and tcell don't support italics or strikethrough. I'm guessing that it's because it's not supported by a decent number of terminal emulators, but most of the popular ones seem to support it. Should I just implement this for bold and underline for now until one of the backends supports it?
@mum4k commented on GitHub (Nov 11, 2020):
If having bold and underline helps you in the meantime, we can start with those. Note that it is also a possibility for us to contribute new functionality to
tcell. I would expect the author to accept new options assuming they work in the popular terminals.@dyc3 commented on GitHub (Nov 12, 2020):
It turns out tcell already supports italics and strikethrough. We just need to update tcell's version. Will send a PR shortly.
@mum4k commented on GitHub (Nov 13, 2020):
Thank you for pointing out that
tcellupgraded to 2.x. I have filed #254 to follow up. Reading their changelog - there are a few breaking changes that we will need to accomodate.@mum4k commented on GitHub (Nov 14, 2020):
What we are aiming for now is to perform the
tcellupgrade and add the italics and strikethrough functionality before we push the next release.However feel free to let me know if you would prefer if we release in the current state to make the changes you contributed available at master.
@mum4k commented on GitHub (Nov 16, 2020):
@dyc3 with
tcellupgraded, do you have the time to send a PR adding support for the remaining font attributes?@dyc3 commented on GitHub (Nov 16, 2020):
Yup! Will do
@mum4k commented on GitHub (Nov 16, 2020):
Great, thank you.
@mum4k commented on GitHub (Nov 17, 2020):
Thank you for your help on this feature and with upgrading
tcell@dyc3. I will push a new release to master shortly.@mum4k commented on GitHub (Nov 18, 2020):
Resolved by #266