Skip to content

Commit

Permalink
multi-select
Browse files Browse the repository at this point in the history
  • Loading branch information
faldor20 committed Sep 30, 2024
1 parent c886c9f commit a529037
Show file tree
Hide file tree
Showing 12 changed files with 477 additions and 131 deletions.
14 changes: 6 additions & 8 deletions forks/nottui/lib/nottui/widgets/overlays.ml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ let text_prompt
type 'a selection_list_prompt_data =
{ label : string
; items : 'a Selection_list.selectable_item list Lwd.t
; items : 'a Selection_list.multi_selectable_item list Lwd.t
; on_exit : [ `Closed | `Finished of 'a ] -> unit
}
Expand Down Expand Up @@ -177,8 +177,8 @@ let selection_list_prompt
type 'a filterable_selection_list_prompt_data =
{ label : string
; items : 'a Selection_list.selectable_item list Lwd.t
;filter_predicate:(string-> 'a-> bool)
; items : 'a Selection_list.multi_selectable_item list Lwd.t
; filter_predicate : string -> 'a -> bool
; on_exit : [ `Closed | `Finished of 'a ] -> unit
}
Expand All @@ -195,7 +195,7 @@ let selection_list_prompt_filterable
let$ show_prompt_val = Lwd.get show_prompt_var in
show_prompt_val
|> Option.map
@@ fun { label; items;filter_predicate; on_exit } ->
@@ fun { label; items; filter_predicate; on_exit } ->
let on_exit result =
Focus.release_reversable focus;
show_prompt_var $= None;
Expand All @@ -206,9 +206,7 @@ let selection_list_prompt_filterable
Selection_list.filterable_selection_list
~filter_predicate
~focus
~on_confirm:(fun item ->
(`Finished item) |> on_exit;
)
~on_confirm:(fun item -> `Finished item |> on_exit)
items
|> modify_body
in
Expand All @@ -227,7 +225,7 @@ let popup ~show_popup_var ui =
match show_popup with
| Some (content, label) ->
let prompt_field = content in
prompt_field |>$ Ui.resize ~w:5 ~sw:1 |> BB.box ~label_top:label |> clear_bg
prompt_field |>$ Ui.resize ~w:5 ~sw:1 |> BB.box ~label_top:label |> clear_bg
| None -> Ui.empty |> Lwd.pure
in
W.zbox [ ui; popup_ui |>$ Ui.resize ~crop:neutral_grav ~pad:neutral_grav ]
Expand Down
12 changes: 6 additions & 6 deletions forks/nottui/lib/nottui/widgets/overlays.mli
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type text_prompt_data = {
on_exit : [ `Closed | `Finished of string ] -> unit;
}

(** Text box prompt that takes user input then calls [on_exit] with the result.
(** Text box prompt that takes user input then calls [on_exit] with the result.
This will display ontop of any ui it is passed when show_prompt_var is [Some].*)

Expand All @@ -35,14 +35,14 @@ val text_prompt :
(** Config for a selection_list_prompt*)
type 'a selection_list_prompt_data = {
label : string;
items : 'a Selection_list.selectable_item list Lwd.t;
items : 'a Selection_list.multi_selectable_item list Lwd.t;
on_exit : [ `Closed | `Finished of 'a ] -> unit;
}

(** Selection_list prompt.
This will display ontop of any ui it is passed when show_prompt_var is [Some].
@param modify_body Function that takes the completed body of the prompt, incase you want to resize it or otherwise change it
@param modify_body Function that takes the completed body of the prompt, incase you want to resize it or otherwise change it
*)
val selection_list_prompt :
?pad_w:int ->
Expand All @@ -55,14 +55,14 @@ val selection_list_prompt :

type 'a filterable_selection_list_prompt_data =
{ label : string
; items : 'a Selection_list.selectable_item list Lwd.t
; items : 'a Selection_list.multi_selectable_item list Lwd.t
;filter_predicate:(string-> 'a-> bool)
; on_exit : [ `Closed | `Finished of 'a ] -> unit
}
(** Selection_list prompt that is filterable.
This will display ontop of any ui it is passed when show_prompt_var is [Some].
@param modify_body Function that takes the completed body of the prompt, incase you want to resize it or otherwise change it
@param modify_body Function that takes the completed body of the prompt, incase you want to resize it or otherwise change it
*)
val selection_list_prompt_filterable :
?pad_w:int ->
Expand All @@ -71,7 +71,7 @@ val selection_list_prompt_filterable :
?focus:Nottui_main.Focus.handle ->
show_prompt_var:'a filterable_selection_list_prompt_data option Lwd.var ->
Nottui_main.ui Lwd.t -> Nottui_main.ui Lwd.t


(**This is a simple popup that can show ontop of other ui elements *)
val popup :
Expand Down
Loading

0 comments on commit a529037

Please sign in to comment.