Kitty Graphics Protocol in OCaml
terminal graphics ocaml

headers

+210
+5
example/example.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (* Kitty Graphics Protocol Demo - Matching kgp/examples/demo *) 2 7 3 8 module K = Kgp
+5
example/tiny_anim.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (* Tiny animation test - no chunking needed *) 2 7 (* Uses 20x20 images which are ~1067 bytes base64 (well under 4096) *) 3 8
+5
lib-cli/kgp_cli.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (* Cmdliner Support for Kitty Graphics Protocol *) 2 7 3 8 open Cmdliner
+5
lib-cli/kgp_cli.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Cmdliner Support for Kitty Graphics Protocol 2 7 3 8 This module provides Cmdliner terms for configuring graphics output mode
+5
lib/kgp.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (* Type modules *) 2 7 module Format = Kgp_format 3 8 module Transmission = Kgp_transmission
+5
lib/kgp.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Kitty Terminal Graphics Protocol 2 7 3 8 This library implements the Kitty terminal graphics protocol, allowing
+5
lib/kgp_animation.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 type t = 2 7 [ `Set_state of Kgp_animation_state.t * int option 3 8 | `Set_gap of int * int
+5
lib/kgp_animation.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Animation Control 2 7 3 8 Operations for controlling animation playback. The protocol supports
+5
lib/kgp_animation_state.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 type t = [ `Stop | `Loading | `Run ] 2 7 3 8 let to_int : t -> int = function
+5
lib/kgp_animation_state.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Animation Playback State 2 7 3 8 Controls the playback state of animated images.
+5
lib/kgp_command.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 type action = 2 7 [ `Transmit 3 8 | `Transmit_and_display
+5
lib/kgp_command.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Kitty Graphics Protocol Commands 2 7 3 8 This module provides functions for building and serializing graphics
+5
lib/kgp_compose.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 type t = { 2 7 source_frame : int; 3 8 dest_frame : int;
+5
lib/kgp_compose.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Frame Composition 2 7 3 8 Operations for compositing rectangular regions between animation frames.
+5
lib/kgp_composition.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 type t = [ `Alpha_blend | `Overwrite ] 2 7 3 8 let to_int : t -> int = function
+5
lib/kgp_composition.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Pixel Composition Mode 2 7 3 8 Controls how pixels are blended when compositing images or animation frames.
+5
lib/kgp_compression.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 type t = [ `None | `Zlib ] 2 7 3 8 let to_char : t -> char option = function
+5
lib/kgp_compression.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Data Compression 2 7 3 8 Specifies compression applied to image data before transmission.
+5
lib/kgp_cursor.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 type t = [ `Move | `Static ] 2 7 3 8 let to_int : t -> int = function
+5
lib/kgp_cursor.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Cursor Movement Behavior 2 7 3 8 Controls cursor position after displaying an image.
+5
lib/kgp_delete.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 type t = 2 7 [ `All_visible 3 8 | `By_id of int * int option
+5
lib/kgp_delete.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Image Deletion Target 2 7 3 8 Specifies which images or placements to delete.
+5
lib/kgp_detect.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (* Kitty Graphics Protocol Detection - Implementation *) 2 7 3 8 let make_query () =
+5
lib/kgp_detect.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Kitty Graphics Protocol Detection 2 7 3 8 Detect terminal graphics support capabilities. *)
+5
lib/kgp_format.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 type t = [ `Rgba32 | `Rgb24 | `Png ] 2 7 3 8 let to_int : t -> int = function
+5
lib/kgp_format.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Image Data Format 2 7 3 8 Specifies the pixel format of image data being transmitted to the terminal.
+5
lib/kgp_frame.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 type t = { 2 7 x : int option; 3 8 y : int option;
+5
lib/kgp_frame.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Animation Frame Configuration 2 7 3 8 Configuration for adding or editing animation frames. Frames can be
+5
lib/kgp_placement.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 type t = { 2 7 source_x : int option; 3 8 source_y : int option;
+5
lib/kgp_placement.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Image Placement Configuration 2 7 3 8 Configuration for where and how to display images. Placements control
+5
lib/kgp_quiet.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 type t = [ `Noisy | `Errors_only | `Silent ] 2 7 3 8 let to_int : t -> int = function
+5
lib/kgp_quiet.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Response Suppression Level 2 7 3 8 Controls which terminal responses are sent back to the application.
+5
lib/kgp_response.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (* Kitty Graphics Protocol Response - Implementation *) 2 7 3 8 type t = {
+5
lib/kgp_response.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Kitty Graphics Protocol Response 2 7 3 8 Parse and interpret terminal responses to graphics commands. *)
+5
lib/kgp_terminal.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (* Terminal Environment Detection *) 2 7 3 8 type graphics_mode = [ `Auto | `Enabled | `Disabled | `Tmux ]
+5
lib/kgp_terminal.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Terminal Environment Detection 2 7 3 8 Detect terminal capabilities and environment for graphics protocol support.
+5
lib/kgp_tmux.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (* Tmux Passthrough Support - Implementation *) 2 7 3 8 let is_active () =
+5
lib/kgp_tmux.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Tmux Passthrough Support 2 7 3 8 Support for passing graphics protocol escape sequences through tmux
+5
lib/kgp_transmission.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 type t = [ `Direct | `File | `Tempfile ] 2 7 3 8 let to_char : t -> char = function
+5
lib/kgp_transmission.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Data Transmission Method 2 7 3 8 Specifies how image data is transmitted to the terminal.
+5
lib/kgp_unicode.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (* Kitty Graphics Protocol Unicode Placeholders - Implementation *) 2 7 3 8 let placeholder_char = Uchar.of_int 0x10EEEE
+5
lib/kgp_unicode.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Kitty Graphics Protocol Unicode Placeholders 2 7 3 8 Support for invisible Unicode placeholder characters that encode