package quickterface

  1. Overview
  2. Docs
Quick-to-program app interfaces in OCaml for terminal and web

Install

dune-project
 Dependency

Authors

Maintainers

Sources

quickterface-0.1.0.tbz
sha256=8261e3819564fb5d05f1f313e62b73382152591d7a4349ae5b1b08a4fc2469f3
sha512=e739a971bb0e696ab716c168419c59a3d195922d2d1e4963106a845e3442ffa085b05106f36cceeec9b806bf7d6ef2c31e98db04911fbf73c5ac0ce626449d0f

doc/src/quickterface.terminal_app/title_bar.ml.html

Source file title_bar.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
open! Core

type t = { text : string }

let make ~text () =
  let filtered_text =
    let open String in
    text
    |> substr_replace_all ~pattern:"\r" ~with_:""
    |> substr_replace_all ~pattern:"\n" ~with_:""
  in
  { text = filtered_text }

let render ~render_info:{ Render_info.screen_width; _ } { text } =
  let open Notty.I in
  if String.is_empty text then empty
  else
    let padding_top = 1 in
    let padding_bottom = 1 in
    let padding_left = 1 in
    let text_img = string Theme.title_text text in
    let background =
      char Theme.title_background ' ' screen_width
        (height text_img + padding_top + padding_bottom)
    in
    pad ~l:padding_left ~t:padding_top text_img </> background