term: add functions for detecting Sixel support + example (#21665)

This commit is contained in:
Larpon 2024-06-11 18:59:58 +02:00 committed by GitHub
parent dfdd752106
commit 47e93d1c39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 152 additions and 0 deletions

View file

@ -0,0 +1,24 @@
module main
import os
import term
fn main() {
println('If your terminal supports the sixel graphics format,')
println('you should see a small green "HI" and a V logo below this text.\n')
if term.supports_sixel() {
// Prints the original "HI" sixel image from the spec:
// https://www.digiater.nl/openvms/decus/vax90b1/krypton-nasa/all-about-sixels.text (See "V. EXAMPLE SIXEL IMAGE" section)
println('\ePq
#0;2;0;0;0#1;2;100;100;0#2;2;0;100;0
#1~~@@vv@@~~@@~~$
#2??}}GG}}??}}??-
#1!14@
\e\\')
// Prints a 128x128 pixels V logo
bytes := os.read_bytes(os.resource_abs_path('assets/v.six'))!
println(bytes.bytestr())
dump(term.supports_sixel())
dump(term.graphics_num_colors())
}
}