ismail-yilmaz / upp-components

A collection of packages for U++ framework.
Other
35 stars 2 forks source link

Add SVG support to Terminal widget as a compile-time option. #9

Open ismail-yilmaz opened 3 years ago

ismail-yilmaz commented 3 years ago

Given the increasing popularity of inline images support in virtual terminal emulators, and the usage of SVG in general, the SVG rendering support can be added to TerminalCtrl as a compile-time option, since U++ already provides the necessary and easy-to-use SVG rendering functions.

As for the required changes in the wire protocols: This option doesn't necessarily require any modification of supported/existing wire protocols (DECSIXEL/jexer/iterm2), since TerminalCtrl already uses a generic infrastructure to identify and decode images.

ismail-yilmaz commented 3 years ago

A sort of proof of concept implemention, using the existing jexer protocol:

TerminalCtrl-inline-sgv-test (using jexer protocol)

Works just fine with images.

It uses Upp::RenderSVGImage to render the svg into a raster image that can be displayed as usual. (Currently requires only three more lines of code + 2 lines of code change to the renderer.)

Still, a simple yet fine-grained implementation seems to require at least a few options to the wire protocol (such as default bkg color, custom size, etc.).

@klamonte, would you be okay if I attempt to extend the jexer protocol a little bit to include SVG rendering? (a possible TerminalCtrl-variant?)

ghost commented 2 years ago

@ismail-yilmaz I have no objection. Do you think SVG would make the most sense to be like PNG/JPG, where dimensions are picked up from the image data, or more like RGB where height/width are specified exactly?