mirror of
https://github.com/chshersh/github-tui.git
synced 2024-08-16 14:00:30 +03:00
Better usage of custom pretty library
This commit is contained in:
parent
64e9a9f1f9
commit
3ea427ead8
@ -6,8 +6,13 @@ type doc =
|
||||
| Vertical of doc * doc
|
||||
| Horizontal of doc * doc
|
||||
|
||||
let (---) t b = Vertical (t, b)
|
||||
let (<|>) l r = Horizontal (l, r)
|
||||
let row = function
|
||||
| [] -> 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 max_len_l = List.map String_extra.graphemes_len l |> List.fold_left max 0 in
|
||||
|
@ -8,34 +8,41 @@ let fmt_selected =
|
||||
fmt ANSITerminal.([Bold; green])
|
||||
|
||||
let tabs_section cur_tab =
|
||||
let open Pretty in
|
||||
let p_tab tab txt =
|
||||
if cur_tab = tab
|
||||
then Pretty.Str (fmt_selected txt)
|
||||
else Pretty.Str txt
|
||||
then Str (fmt_selected txt)
|
||||
else Str txt
|
||||
in
|
||||
Pretty.(render (
|
||||
(p_tab Model.Code "╭──────╮" ---
|
||||
p_tab Model.Code "│ Code │" ---
|
||||
p_tab Model.Code "└──────┴"
|
||||
) <|>
|
||||
(Str " " ---
|
||||
Str " " ---
|
||||
Str "─"
|
||||
) <|>
|
||||
(p_tab Model.Issues "╭────────╮" ---
|
||||
p_tab Model.Issues "│ Issues │" ---
|
||||
p_tab Model.Issues "┴────────┴"
|
||||
) <|>
|
||||
(Str " " ---
|
||||
Str " " ---
|
||||
Str "─"
|
||||
) <|>
|
||||
(p_tab Model.PullRequests "╭───────────────╮" ---
|
||||
p_tab Model.PullRequests "│ Pull Requests │" ---
|
||||
p_tab Model.PullRequests "┴───────────────┴"
|
||||
)
|
||||
)
|
||||
)
|
||||
let sep = col
|
||||
[
|
||||
Str " ";
|
||||
Str " ";
|
||||
Str "─";
|
||||
]
|
||||
in
|
||||
render @@ row
|
||||
[ col
|
||||
[
|
||||
p_tab Model.Code "╭──────╮";
|
||||
p_tab Model.Code "│ Code │";
|
||||
p_tab Model.Code "└──────┴";
|
||||
];
|
||||
sep;
|
||||
col
|
||||
[
|
||||
p_tab Model.Issues "╭────────╮";
|
||||
p_tab Model.Issues "│ Issues │";
|
||||
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 =
|
||||
(* Add two spaces for padding before and end of the file name *)
|
||||
|
Loading…
Reference in New Issue
Block a user