aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-01-12 21:52:11 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-01-12 21:52:11 +0300
commit189a34d24326d2838c3dcd9ec7e9915c480e8873 (patch)
treee2d4889a8479723ed0db07752caadab4e9797b05
parentc339ed4def5854b8daa0cbf2733c00d54b672078 (diff)
downloadapplause2-189a34d24326d2838c3dcd9ec7e9915c480e8873.tar.gz
Stream:gnuplot() supports plotting into Kitty terminals now
-rw-r--r--TODO2
-rw-r--r--applause.lua13
2 files changed, 15 insertions, 0 deletions
diff --git a/TODO b/TODO
index db193d4..64fc6ce 100644
--- a/TODO
+++ b/TODO
@@ -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