diff options
author | Minijackson <minijackson@riseup.net> | 2023-01-20 17:23:57 +0100 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2023-01-20 17:23:57 +0100 |
commit | 439620b2309c064f030ccc65947ea6ba9c10f795 (patch) | |
tree | 7197ebc6d92d2a2badaf53fcfadf40c11accd8a7 /examples/pygments.lua | |
parent | 11fd8dff580e726174c0da1096b4d580b91c2763 (diff) | |
download | diaphragm-439620b2309c064f030ccc65947ea6ba9c10f795.tar.gz diaphragm-439620b2309c064f030ccc65947ea6ba9c10f795.zip |
examples/pygments: init
Diffstat (limited to 'examples/pygments.lua')
-rw-r--r-- | examples/pygments.lua | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/pygments.lua b/examples/pygments.lua new file mode 100644 index 0000000..453f53f --- /dev/null +++ b/examples/pygments.lua | |||
@@ -0,0 +1,32 @@ | |||
1 | package.cpath = package.cpath .. ";../target/debug/?.so" | ||
2 | package.path = package.path .. ";../lua-bindings/?.lua" | ||
3 | |||
4 | local dia = require("diaphragm") | ||
5 | |||
6 | dia.draw({ | ||
7 | draw = function(self) | ||
8 | local p = io.popen("pygmentize -f pango -O style=nord ./pygments.lua") | ||
9 | local content = p:read("a") | ||
10 | |||
11 | if content == nil then | ||
12 | return | ||
13 | end | ||
14 | |||
15 | local font = dia.text.font({ family = "Fira Code" }) | ||
16 | local text = dia.text.new({ | ||
17 | content = string.sub(content, 5, -6), | ||
18 | font = font, | ||
19 | width = 1920, | ||
20 | }) | ||
21 | |||
22 | dia.rectangle | ||
23 | .surrounding(text, { | ||
24 | -- fill_color = "#282828" | ||
25 | fill_color = "#1e1e27", | ||
26 | }) | ||
27 | :draw() | ||
28 | text:draw() | ||
29 | dia.constraint.inset(text, self) | ||
30 | end, | ||
31 | output = {}, | ||
32 | }) | ||