Open larrykollar opened 4 years ago
Brr. XSLT... I still have nightmares...
WordGrinder should uses the terminal's italics capability to draw italics. If it's showing up as bold, then that's because your terminfo file either doesn't have it or you have an old ncurses which doesn't know about italics.
(Look for 'italic' in https://github.com/davidgiven/wordgrinder/blob/master/src/c/arch/unix/cursesw/dpy.c.)
Changing the fallback from bold to something else is very easy --- it just needs changing in two places. However I'm not sure there's anything more appropriate. Colour's a possibility but then it would need to be configurable and it opens up a huge can of worms with regard to the user's preferred terminal colours (bright background or dark background?).
Possibly the easiest option is to change your vt220 terminfo configuration to replace the sitm and ritm codes with your preferred colour escape sequence. Test it with:
echo `tput sitm`italics`tput ritm`
Haha, yeah, XSLT is a side-task at my day job right now. Our software guy quit in May, and we're trying to find someone who can let me focus on content work.
Back to the topic. Your echo command did display "italics" on my terminal (iTerm on OS X Catalina). I probably need to fix my environment.
% echo $TERM
xterm-256color
% tput -V
ncurses 6.1.20180127
Italics support went into ncurses in 5.1, and your version is later than that. You do need to check that WordGrinder is built with the same version that tput is using. You might be using homebrew's ncurses for WordGrinder and tput is using the system version.
Unfortunately I don't have a Mac and my knowledge of how it works is limited. It took an embarassingly long time to get the Mac CI setup done.
OK, 6.1 is coming from my MacPorts, and Wordgrinder was compiled with ncurses 5.4, the default on Catalina:
% objdump -macho -dylibs-used `which wordgrinder`
/usr/local/bin/wordgrinder:
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.0.0)
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
%
Now it turns out that tput I used came out of /opt/local/bin, which refers to the 6.1 version I installed there. When I used the version in /usr/bin, I got no highlighting at all. But adding /opt/local/lib and /opt/local/include to the search paths end up causing the link to fail, trying to find the Lua library. So maybe I should force it to link to the MacPorts-based ncurses in /opt/local/lib
? If I get this working right, I'll make sure I write it up properly so you can put it in the README.
This is helping me figure out how to deal with Tines (my ncurses-based outliner project). I'm leaning toward including ncursesw 6.1 in the source and static-linking it. This might solve the issues Arch Linux users are seeing with Tines as well.
As the start of a potential workaround, I've partially followed (though I'm not using iTerm, using builtin Terminal): https://medium.com/@dubistkomisch/how-to-actually-get-italics-and-true-colour-to-work-in-iterm-tmux-vim-9ebe55ebc2be
Before:
$ python3
...
>>> import curses; curses.setupterm(); curses.tigetstr("sitm")
>>>
After:
$ python3
Python 3.7.7 (default, Mar 10 2020, 15:43:33)
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import curses; curses.setupterm(); curses.tigetstr("sitm")
b'\x1b[3m'
>>>
This works for me:
$ echo
tput sitm
italicstput ritm
italics
But word grinder isn't picking up this capability as I'd expect here: https://github.com/davidgiven/wordgrinder/blob/master/src/c/arch/unix/cursesw/dpy.c#L38
I'm not using MacPorts, and my tput is /usr/bin/tput, that said these two have conflicting numbers, but both seem to be system vended:
$ tput -V
ncurses 5.7.20081102
$ which tput
/usr/bin/tput
$ objdump -macho -dylibs-used `which wordgrinder`
/usr/local/bin/wordgrinder:
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.0.0)
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
Homebrew seems to be using a specific bin
from the build: https://github.com/Homebrew/homebrew-core/blob/master/Formula/wordgrinder.rb#L22
Manual build has same result out of the box.
I was able to get it to work manually with a newer brew installed ncurses by the following:
brew install ncurses
export PKG_CONFIG_PATH=$(brew --prefix)/opt/ncurses/lib/pkgconfig/
CURSES_PACKAGE=ncursesw make
I'm sending in a corresponding fix in the homebrew formula in https://github.com/Homebrew/homebrew-core/pull/54234. Not sure what the corresponding MacPorts change would be. :)
Maybe use grey/lightweight text for italic. Seems like my old VT220 has light, normal, bold, underline, and reverse video choices, and 21st century computers (even in Terminal) have color available.
It looks like redraw.lua already has everything but color defined already. Granted, I have zero experience with Lua (I still reach for awk when I'm hammering on text, except for XML and then I use XSLT), but one can hope it's just a matter of hooking up a different call for bold or italic… and maybe it makes distinguishing inline code like <tt> possible as well. Please school me if I'm incorrect.