Skip to content

Commit

Permalink
small example program
Browse files Browse the repository at this point in the history
  • Loading branch information
Armael committed Jan 23, 2023
1 parent 3408729 commit a413252
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 6 deletions.
9 changes: 9 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Kitty's terminal graphics protocol -- client-side OCaml implementation

![demo screenshot](demo.png)

See [https://sw.kovidgoyal.net/kitty/graphics-protocol/](https://sw.kovidgoyal.net/kitty/graphics-protocol/).

This is WIP but should be enough for basic tasks. Support for "advanced" uses of
the protocols (using images/pattern ids) probably needs more work. Contributions
welcome!
4 changes: 0 additions & 4 deletions bin/dune

This file was deleted.

2 changes: 0 additions & 2 deletions bin/main.ml

This file was deleted.

Binary file added demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(executable
(name icat)
(libraries kittyimg stb_image))
15 changes: 15 additions & 0 deletions examples/icat.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
let icat filename =
let img = Result.get_ok (Stb_image.load ~channels:4 filename) in
let img_s = Kittyimg.string_of_bytes_ba img.Stb_image.data in
print_newline ();
Kittyimg.send_image
~w:img.Stb_image.width ~h:img.Stb_image.height
~format:`RGBA ~mode:(`Display (Kittyimg.display_opts ()))
img_s;
print_newline ()

let () =
match Array.to_list Sys.argv |> List.tl with
| [ filename ] -> icat filename
| _ ->
Printf.eprintf "usage: %s <imagefile>\n" Sys.argv.(0); exit 1
Binary file added examples/ocaml.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a413252

Please sign in to comment.