Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions vendor/notty/src-unix/native/winsize.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <caml/mlvalues.h>

#ifdef _WIN32
#include <caml/fail.h>
#include <windows.h>
#else
#include <sys/ioctl.h>
#include <signal.h>
Expand All @@ -15,7 +15,16 @@
CAMLprim value caml_notty_winsize (value vfd) {
#ifdef _WIN32
(void) vfd;
caml_failwith("not implemented on windows");
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
if (hConsole == INVALID_HANDLE_VALUE) return Val_int (0);

CONSOLE_SCREEN_BUFFER_INFO csbi;
if (GetConsoleScreenBufferInfo(hConsole, &csbi)) {
int columns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
int rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
return Val_int ((columns << 16) + ((rows & 0x7fff) << 1));
}
return Val_int (0);
#else
int fd = Int_val (vfd);
struct winsize w;
Expand Down
24 changes: 16 additions & 8 deletions vendor/notty/src/notty.ml
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,12 @@ module A = struct
and b x = x land 0xff

let bold = 1
and italic = 2
and dim = 3
and underline = 4
and blink = 8
and reverse = 16
and dim = 2
and faint = 2
and italic = 4
and underline = 8
and blink = 16
and reverse = 32

let empty = { fg = 0; bg = 0; st = 0 }

Expand Down Expand Up @@ -384,7 +385,12 @@ module I = struct

let create () =
let img, line, attr = ref empty, ref empty, ref [] in
let fmt = formatter_of_out_functions {
(* OCaml 5.4 added a new record field so to keep compatibility, get and
update the record, even if warning 23 "useless-record-with" is
triggered, about all fields being updated in <5.4. *)
let formatter_out_functions = get_formatter_out_functions () in
let[@warning "-23"] formatter_out_functions = {
formatter_out_functions with
out_flush = (fun () ->
img := !img <-> !line; line := empty; attr := [])
; out_newline = (fun () ->
Expand All @@ -394,7 +400,9 @@ module I = struct
(* Not entirely clear; either or both could be void: *)
; out_spaces = (fun w -> line := !line <|> char (top_a attr) ' ' w 1)
; out_indent = (fun w -> line := !line <|> char (top_a attr) ' ' w 1)
} in
}
in
let fmt = formatter_of_out_functions formatter_out_functions in
pp_set_formatter_stag_functions fmt {
(pp_get_formatter_stag_functions fmt ()) with
mark_open_stag =
Expand Down Expand Up @@ -511,7 +519,7 @@ module Cap = struct

let ((<|), (<.), (<!)) = Buffer.(add_string, add_char, add_decimal)

let sts = [ ";1"; ";3"; ";4"; ";5"; ";7" ]
let sts = [ ";1"; ";2"; ";3"; ";4"; ";5"; ";7" ]

let sgr { A.fg; bg; st } buf =
buf <| "\x1b[0";
Expand Down
3 changes: 2 additions & 1 deletion vendor/notty/src/notty.mli
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ module A : sig
(** Additional text properties. *)

val bold : style
val italic : style
val dim : style
val faint : style
val italic : style
val underline : style
val blink : style
val reverse : style
Expand Down
2 changes: 1 addition & 1 deletion vendor/update-notty.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

version=cb7221c73f8009a904fa249fdeb5558c83043b8f
version=83aad282853bc35564114db72b65a087acf82ccf

set -e -o pipefail

Expand Down
Loading