Kitty Graphics Protocol in OCaml
terminal graphics ocaml

headers

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