A lightweight reactive document library.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

58 lines
2.3 KiB

  1. (**************************************************************************)
  2. (* *)
  3. (* Nottui_pretty, pretty-printer for Nottui *)
  4. (* Frédéric Bour, Tarides *)
  5. (* Copyright 2020 Tarides. All rights reserved. *)
  6. (* *)
  7. (* Based on PPrint *)
  8. (* François Pottier, Inria Paris *)
  9. (* Nicolas Pouillard *)
  10. (* *)
  11. (* Copyright 2007-2019 Inria. All rights reserved. This file is *)
  12. (* distributed under the terms of the GNU Library General Public *)
  13. (* License, with an exception, as described in the file LICENSE. *)
  14. (**************************************************************************)
  15. (* The type of documents *)
  16. type t
  17. (* The empty document *)
  18. val empty : t
  19. (* A document representing a UI widget *)
  20. val ui : Nottui.ui -> t
  21. (* Forced line break *)
  22. val hardline : t
  23. (* White space *)
  24. val blank : int -> t
  25. (* Choose between two documents based on whether we are in flat-mode or not.
  26. First document should not force any hardline, otherwise it will completely
  27. disable flat mode (... it is not possible to be flat and have hardlines).
  28. *)
  29. val if_flat : t -> t -> t
  30. (* [break n] behaves like [blank n] if flat or [hardline] if non-flat:
  31. If it fits on current line it displays [n] whitespaces, if not it breaks the
  32. current line. *)
  33. val break : int -> t
  34. (* Concatenate two documents *)
  35. val ( ^^ ) : t -> t -> t
  36. (* [nest n t] increases indentation level by [n] inside document [t]:
  37. if a new line has to be introduced in the layout [t], it will be shifted on
  38. the right by [n] columns. *)
  39. val nest : int -> t -> t
  40. (* [group t] introduces a choice point.
  41. If sub-documnet [t] fits on the current-line, it will be printed in flat
  42. mode.
  43. Otherwise [t] is printed as usual. *)
  44. val group : t -> t
  45. (* [pretty w t] renders document [t] targetting optimal width [w]. *)
  46. val pretty : int -> t -> Nottui.ui