Better usage of custom pretty library

This commit is contained in:
Dmitrii Kovanikov 2024-02-04 14:42:37 +00:00
parent 64e9a9f1f9
commit 3ea427ead8
2 changed files with 39 additions and 27 deletions

View File

@ -6,8 +6,13 @@ type doc =
| Vertical of doc * doc | Vertical of doc * doc
| Horizontal of doc * doc | Horizontal of doc * doc
let (---) t b = Vertical (t, b) let row = function
let (<|>) l r = Horizontal (l, r) | [] -> Empty
| hd :: tl -> List.fold_left (fun l r -> Horizontal (l, r)) hd tl
let col = function
| [] -> Empty
| hd :: tl -> List.fold_left (fun l r -> Vertical (l, r)) hd tl
let zip_lines l r = let zip_lines l r =
let max_len_l = List.map String_extra.graphemes_len l |> List.fold_left max 0 in let max_len_l = List.map String_extra.graphemes_len l |> List.fold_left max 0 in

View File

@ -8,34 +8,41 @@ let fmt_selected =
fmt ANSITerminal.([Bold; green]) fmt ANSITerminal.([Bold; green])
let tabs_section cur_tab = let tabs_section cur_tab =
let open Pretty in
let p_tab tab txt = let p_tab tab txt =
if cur_tab = tab if cur_tab = tab
then Pretty.Str (fmt_selected txt) then Str (fmt_selected txt)
else Pretty.Str txt else Str txt
in in
Pretty.(render ( let sep = col
(p_tab Model.Code "╭──────╮" --- [
p_tab Model.Code "│ Code │" --- Str " ";
p_tab Model.Code "└──────┴" Str " ";
) <|> Str "";
(Str " " --- ]
Str " " --- in
Str "" render @@ row
) <|> [ col
(p_tab Model.Issues "╭────────╮" --- [
p_tab Model.Issues "│ Issues │" --- p_tab Model.Code "╭──────╮";
p_tab Model.Issues "┴────────┴" p_tab Model.Code "│ Code │";
) <|> p_tab Model.Code "└──────┴";
(Str " " --- ];
Str " " --- sep;
Str "" col
) <|> [
(p_tab Model.PullRequests "╭───────────────╮" --- p_tab Model.Issues "╭────────╮";
p_tab Model.PullRequests "│ Pull Requests │" --- p_tab Model.Issues "│ Issues │";
p_tab Model.PullRequests "┴───────────────┴" p_tab Model.Issues "┴────────┴";
) ];
) sep;
) col
[
p_tab Model.PullRequests "╭───────────────╮";
p_tab Model.PullRequests "│ Pull Requests │";
p_tab Model.PullRequests "┴───────────────┴";
];
]
let file_widget ~max_name_len ~selected files = let file_widget ~max_name_len ~selected files =
(* Add two spaces for padding before and end of the file name *) (* Add two spaces for padding before and end of the file name *)