mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 11:45:31 -05:00
add ?margin parameter to CCFormat.ksprintf
This commit is contained in:
parent
c578dd9583
commit
2c5cda7e3d
2 changed files with 4 additions and 1 deletions
|
|
@ -383,10 +383,11 @@ let fprintf_dyn_color ~colors out fmt =
|
||||||
assert_equal "yolo" (sprintf_no_color "@{<red>yolo@}");
|
assert_equal "yolo" (sprintf_no_color "@{<red>yolo@}");
|
||||||
*)
|
*)
|
||||||
|
|
||||||
let ksprintf ~f fmt =
|
let ksprintf ?margin ~f fmt =
|
||||||
let buf = Buffer.create 32 in
|
let buf = Buffer.create 32 in
|
||||||
let out = Format.formatter_of_buffer buf in
|
let out = Format.formatter_of_buffer buf in
|
||||||
if !color_enabled then set_color_tag_handling out;
|
if !color_enabled then set_color_tag_handling out;
|
||||||
|
begin match margin with None -> () | Some m -> pp_set_margin out m end;
|
||||||
Format.kfprintf
|
Format.kfprintf
|
||||||
(fun _ -> Format.pp_print_flush out (); f (Buffer.contents buf))
|
(fun _ -> Format.pp_print_flush out (); f (Buffer.contents buf))
|
||||||
out fmt
|
out fmt
|
||||||
|
|
|
||||||
|
|
@ -273,11 +273,13 @@ val fprintf_dyn_color : colors:bool -> t -> ('a, t, unit ) format -> 'a
|
||||||
@since 0.21 *)
|
@since 0.21 *)
|
||||||
|
|
||||||
val ksprintf :
|
val ksprintf :
|
||||||
|
?margin:int ->
|
||||||
f:(string -> 'b) ->
|
f:(string -> 'b) ->
|
||||||
('a, Format.formatter, unit, 'b) format4 ->
|
('a, Format.formatter, unit, 'b) format4 ->
|
||||||
'a
|
'a
|
||||||
(** [ksprintf fmt ~f] formats using [fmt], in a way similar to {!sprintf},
|
(** [ksprintf fmt ~f] formats using [fmt], in a way similar to {!sprintf},
|
||||||
and then calls [f] on the resulting string.
|
and then calls [f] on the resulting string.
|
||||||
|
@param margin set margin (since NEXT_RELEASE)
|
||||||
@since 0.14 *)
|
@since 0.14 *)
|
||||||
|
|
||||||
val to_file : string -> ('a, t, unit, unit) format4 -> 'a
|
val to_file : string -> ('a, t, unit, unit) format4 -> 'a
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue