My agentic slop goes here. Not intended for anyone else!
at main 2.5 kB view raw
1(* Example demonstrating the textsize library *) 2 3let () = 4 print_endline "=== Kitty Text Sizing Protocol Demo ===\n"; 5 6 (* Simple convenience functions *) 7 print_string (Termext.Textsize.double "Double sized text"); 8 print_endline "\n"; 9 10 print_string (Termext.Textsize.triple "Triple sized text"); 11 print_endline "\n\n"; 12 13 print_string (Termext.Textsize.quadruple "Quadruple sized text"); 14 print_endline "\n\n\n"; 15 16 (* Scaled text *) 17 print_string (Termext.Textsize.scaled 5 "Scale 5 text"); 18 print_endline "\n\n\n\n"; 19 20 (* Fractional scaling *) 21 print_string (Termext.Textsize.half "Half sized text"); 22 print_newline (); 23 24 (* Superscripts and subscripts *) 25 print_string "E=mc"; 26 print_string (Termext.Textsize.superscript "2"); 27 print_newline (); 28 29 print_string "H"; 30 print_string (Termext.Textsize.subscript "2"); 31 print_string "O"; 32 print_newline (); 33 34 (* Custom metadata *) 35 print_newline (); 36 let custom = Termext.Textsize.v ~scale:3 ~width:5 () in 37 print_string (Termext.Textsize.render custom "Custom sized text"); 38 print_endline "\n\n"; 39 40 (* Fractional with alignment *) 41 let aligned = Termext.Textsize.v ~fraction:(1, 3) ~vertical:`Center ~horizontal:`Center () in 42 print_string (Termext.Textsize.render aligned "Centered 1/3 size text"); 43 print_newline (); 44 45 (* Fmt-style combinators *) 46 print_endline "\n=== Fmt-style Examples ===\n"; 47 48 (* Basic pp formatter *) 49 Fmt.pr "This is %a text\n" Termext.Textsize.pp_double "double-sized"; 50 Fmt.pr "This is %a text\n" Termext.Textsize.pp_triple "triple-sized"; 51 52 (* Superscripts and subscripts with Fmt *) 53 Fmt.pr "E=mc%a\n" Termext.Textsize.pp_superscript "2"; 54 Fmt.pr "H%aO\n" Termext.Textsize.pp_subscript "2"; 55 56 (* Styled combinators wrapping other formatters *) 57 Fmt.pr "The answer is %a\n" (Termext.Textsize.styled_double Fmt.int) 42; 58 Fmt.pr "Pi is approximately %a\n" (Termext.Textsize.styled_triple Fmt.float) 3.14159; 59 60 (* Complex formatting with Fmt *) 61 Fmt.pr "Temperature: %a°C (that's %a°F)\n" 62 (Termext.Textsize.styled_superscript Fmt.int) 25 63 (Termext.Textsize.styled_subscript Fmt.int) 77; 64 65 (* Custom metadata with Fmt *) 66 let custom_meta = Termext.Textsize.v ~scale:4 () in 67 Fmt.pr "\n%a\n" (Termext.Textsize.pp custom_meta) "Custom Fmt-styled text"; 68 69 (* Composing with other Fmt combinators *) 70 Fmt.pr "\nList items: %a\n" 71 (Fmt.list ~sep:(Fmt.any ", ") (Termext.Textsize.styled_double Fmt.string)) 72 ["apple"; "banana"; "cherry"]; 73 74 print_endline "\n=== Demo Complete ===";