diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-01-12 21:52:11 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-01-12 21:52:11 +0300 |
commit | 189a34d24326d2838c3dcd9ec7e9915c480e8873 (patch) | |
tree | e2d4889a8479723ed0db07752caadab4e9797b05 | |
parent | c339ed4def5854b8daa0cbf2733c00d54b672078 (diff) | |
download | applause2-189a34d24326d2838c3dcd9ec7e9915c480e8873.tar.gz |
Stream:gnuplot() supports plotting into Kitty terminals now
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | applause.lua | 13 |
2 files changed, 15 insertions, 0 deletions
@@ -98,3 +98,5 @@ * Per-class optimizations. * SndfileStream:sub() for seeking in sound files. * EvdevStream:evabs() for retrieving the minimum/maximum values automatically. +* More options for plotting into terminals via Stream:gnuplot(). + Theoretically we can support xterm and others via braille characters (gnuplot's block terminal). diff --git a/applause.lua b/applause.lua index 42b3cce..ddc5cb7 100644 --- a/applause.lua +++ b/applause.lua @@ -896,6 +896,8 @@ end --- Plot stream using [gnuplot](http://www.gnuplot.info/). -- This is not allowed for infinite streams. +-- Graphics will be displayed inline in Jupyter notebooks and when +-- using the [kitty](https://sw.kovidgoyal.net/kitty/) terminal emulator. -- @warning This requires the feedgnuplot script. -- @fixme gnuplot is not the ideal tool for plotting audio data. function Stream:gnuplot() @@ -912,6 +914,17 @@ function Stream:gnuplot() -- same time, so we must dump the file to disk. svg_file = os.tmpname() cmd = cmd.." --terminal svg >"..svg_file + elseif os.getenv("TERM") == "xterm-kitty" then + -- FIXME: This could be supported on other emulators like WezTerm and Konsole as well. + -- FIXME: This assumes a white on black terminal. + -- Perhaps it should be configurable via a gnuplot script. + cmd = cmd..[[ \ + --set 'border lc rgb "white"' \ + --set 'style line 1 lc rgb "white"' \ + --set 'style increment user' \ + --terminal 'pngcairo background rgb "black"' | \ + kitten icat --align left \ + ]] end -- NOTE: We're not using Stream:pipe() here, so we can |