Skip to content

Commit

Permalink
prepare for 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
c-cube committed Nov 19, 2019
1 parent 634f111 commit 5f685da
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 28 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changes

## 0.3

- improve code readability in text rendering
- add `align` and `center`
- add basic styling for text (ansi codes/html styles)
- add `printbox_unicode` for setting up proper unicode printing
- add `grid_l`, `grid_text_l`, and `record` helpers

- use a more accurate length estimate for unicode, add test
- remove mdx as a test dep
- fix rendering bugs related to align right, and padding

## 0.2

- make the box type opaque, with a view function
Expand Down
1 change: 1 addition & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
(lang dune 1.1)
(name printbox)
4 changes: 1 addition & 3 deletions printbox.opam
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
opam-version: "2.0"
name: "printbox"
version: "0.2"
authors: ["Simon Cruanes" "Guillaume Bury"]
maintainer: "[email protected]"
synopsis: "Allows to print nested boxes, lists, arrays, tables in several formats"
Expand All @@ -10,7 +8,7 @@ build: [
["dune" "build" "@doc" "-p" name "-j" jobs] {with-doc}
]
depends: [
"dune" {build}
"dune" { >= "1.1" }
"base-bytes"
"odoc" {with-doc}
"ocaml" { >= "4.03" }
Expand Down
38 changes: 19 additions & 19 deletions src/PrintBox.mli
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
]}
Since NEXT_RELEASE there is also basic support for coloring text:
Since 0.3 there is also basic support for coloring text:
{[
# let b = PrintBox.(
Expand All @@ -61,7 +61,7 @@ type position = { x:int ; y: int }

(** {2 Style}
@since NEXT_RELEASE *)
@since 0.3 *)
module Style : sig
type color =
| Black
Expand All @@ -79,7 +79,7 @@ module Style : sig
fg_color: color option; (** foreground color *)
}
(** Basic styling (color, bold).
@since NEXT_RELEASE *)
@since 0.3 *)

val default : t

Expand All @@ -105,7 +105,7 @@ type t
(** The type [view] can be used to observe the inside of the box,
now that [t] is opaque.
@since NEXT_RELEASE added [Align]
@since 0.3 added [Align]
*)
type view = private
| Empty
Expand Down Expand Up @@ -185,31 +185,31 @@ val align : h:[`Left | `Right | `Center] -> v:[`Top | `Bottom | `Center] -> t ->
(** Control alignment of the given box wrt its surrounding box, if any.
@param h horizontal alignment
@param v vertical alignment
@since NEXT_RELEASE *)
@since 0.3 *)

val align_right : t -> t
(** Left-pad to the size of the surrounding box, as in [align ~h:`Right ~v:`Top]
@since NEXT_RELEASE *)
@since 0.3 *)

val align_bottom : t -> t
(** Align to the bottom, as in [align ~h:`Left ~v:`Bottom]
@since NEXT_RELEASE *)
@since 0.3 *)

val align_bottom_right : t -> t
(** Align to the right and to the bottom, as in [align ~h:`Right ~v:`Bottom]
@since NEXT_RELEASE *)
@since 0.3 *)

val center_h : t -> t
(** Horizontal center, as in .
@since NEXT_RELEASE *)
@since 0.3 *)

val center_v : t -> t
(** Vertical center.
@since NEXT_RELEASE *)
@since 0.3 *)

val center_hv : t -> t
(** Try to center within the surrounding box, as in [align ~h:`Center ~v:`Center]
@since NEXT_RELEASE *)
@since 0.3 *)

val grid :
?pad:(t -> t) ->
Expand Down Expand Up @@ -240,14 +240,14 @@ val grid_l :
?bars:bool ->
t list list -> t
(** Same as {!grid} but from lists.
@since NEXT_RELEASE *)
@since 0.3 *)

val grid_text_l :
?pad:(t -> t) ->
?bars:bool ->
string list list -> t
(** Same as {!grid_text} but from lists.
@since NEXT_RELEASE *)
@since 0.3 *)

val record :
?pad:(t -> t) ->
Expand All @@ -262,7 +262,7 @@ val record :
|1|3.14|true|
+-----------+
]}
@since NEXT_RELEASE *)
@since 0.3 *)

val vlist : ?pad:(t -> t) -> ?bars:bool -> t list -> t
(** Vertical list of boxes *)
Expand All @@ -287,23 +287,23 @@ val mk_tree : ?indent:int -> ('a -> t * 'a list) -> 'a -> t

val line_with_style : Style.t -> string -> t
(** Like {!line} but with additional styling.
@since NEXT_RELEASE *)
@since 0.3 *)

val lines_with_style : Style.t -> string list -> t
(** Like {!lines} but with additional styling.
@since NEXT_RELEASE *)
@since 0.3 *)

val text_with_style : Style.t -> string -> t
(** Like {!text} but with additional styling.
@since NEXT_RELEASE *)
@since 0.3 *)

val sprintf_with_style : Style.t -> ('a, Buffer.t, unit, t) format4 -> 'a
(** Formatting for {!text}, with style
@since NEXT_RELEASE *)
@since 0.3 *)

val asprintf_with_style : Style.t -> ('a, Format.formatter, unit, t) format4 -> 'a
(** Formatting for {!text}, with style.
@since NEXT_RELEASE *)
@since 0.3 *)

(** {2 Simple Structural Interface} *)

Expand Down
10 changes: 5 additions & 5 deletions src/PrintBox_text.mli
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ val set_string_len : (String.t -> int -> int -> int) -> unit
]}
Note that this function assumes there is no newline character in the given string.
@since NEXT_RELEASE, this is also used in [printbox_unicode] to basically install the code above
@since 0.3, this is also used in [printbox_unicode] to basically install the code above
*)

val to_string : PrintBox.t -> string
(** Returns a string representation of the given structure.
@param style if true, emit ANSI codes for styling (default true) (@since NEXT_RELEASE) *)
@param style if true, emit ANSI codes for styling (default true) (@since 0.3) *)

val to_string_with : style:bool -> PrintBox.t -> string
(** Returns a string representation of the given structure, with style.
@param style if true, emit ANSI codes for styling
@since NEXT_RELEASE
@since 0.3
*)

val output : ?style:bool -> ?indent:int -> out_channel -> PrintBox.t -> unit
(** Outputs the given structure on the channel.
@param indent initial indentation to use
@param style if true, emit ANSI codes for styling (default true) (@since NEXT_RELEASE)
@param style if true, emit ANSI codes for styling (default true) (@since 0.3)
*)

val pp : Format.formatter -> PrintBox.t -> unit
Expand All @@ -43,5 +43,5 @@ val pp : Format.formatter -> PrintBox.t -> unit
val pp_with : style:bool -> Format.formatter -> PrintBox.t -> unit
(** Pretty-print the box into this formatter, with style.
@param style if true, emit ANSI codes for styling
@since NEXT_RELEASE
@since 0.3
*)
2 changes: 1 addition & 1 deletion src/unicode/PrintBox_unicode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
It depends on Uucp and Uutf.
@since NEXT_RELEASE
@since 0.3
*)

let string_len s i len =
Expand Down

0 comments on commit 5f685da

Please sign in to comment.