tree_nav :3
This commit is contained in:
File diff suppressed because one or more lines are too long
@ -89,13 +89,13 @@ let _ =
|
|||||||
let gravity_pad = Gravity.make ~h:`Negative ~v:`Negative in
|
let gravity_pad = Gravity.make ~h:`Negative ~v:`Negative in
|
||||||
let gravity_crop = Gravity.make ~h:`Positive ~v:`Negative in
|
let gravity_crop = Gravity.make ~h:`Positive ~v:`Negative in
|
||||||
let body = Lwd.var (Lwd.pure Ui.empty) in
|
let body = Lwd.var (Lwd.pure Ui.empty) in
|
||||||
let wm = Nottui_widgets.window_manager (Lwd.join (Lwd.get body)) in
|
let wm = Widgets.window_manager (Lwd.join (Lwd.get body)) in
|
||||||
Nav.test_pull () >>= fun test_tree ->
|
Nav.test_pull () >>= fun test_tree ->
|
||||||
Nottui_widgets.(tree_nav test_tree []) >>= fun ui ->
|
Widgets.(tree_nav test_tree []) >>= fun ui ->
|
||||||
let root =
|
let root =
|
||||||
Lwd.set body
|
Lwd.set body
|
||||||
(Lwd.map ~f:(Ui.resize ~pad:gravity_pad ~crop:gravity_crop) ui);
|
(Lwd.map ~f:(Ui.resize ~pad:gravity_pad ~crop:gravity_crop) ui);
|
||||||
Nottui_widgets.window_manager_view wm
|
Widgets.window_manager_view wm
|
||||||
in
|
in
|
||||||
|
|
||||||
let events, push_event = Lwt_stream.create () in
|
let events, push_event = Lwt_stream.create () in
|
||||||
|
|||||||
59
human.ml
59
human.ml
@ -2345,7 +2345,9 @@ module Nottui_lwt = struct
|
|||||||
(fun () -> Term.release term) *)
|
(fun () -> Term.release term) *)
|
||||||
end
|
end
|
||||||
|
|
||||||
module Nottui_widgets = struct
|
module Widgets = struct
|
||||||
|
(* Majority of this was adapted from Nottui_widgets *)
|
||||||
|
|
||||||
open Nottui
|
open Nottui
|
||||||
|
|
||||||
let string ?(attr = A.empty) str = Ui.atom (I.string ~attr str)
|
let string ?(attr = A.empty) str = Ui.atom (I.string ~attr str)
|
||||||
@ -2941,6 +2943,55 @@ module Nottui_widgets = struct
|
|||||||
Option.iter (fun (f, _) -> Focus.request f)
|
Option.iter (fun (f, _) -> Focus.request f)
|
||||||
@@ Lwd_table.get cursor)
|
@@ Lwd_table.get cursor)
|
||||||
(Lwd.peek cursor);
|
(Lwd.peek cursor);
|
||||||
|
|
||||||
|
(* Lwd.observe ~on_invalidate:(fun _ ->
|
||||||
|
Lwd.set cursorview (Lwd.quick_sample (root ()))); *)
|
||||||
|
let cursorview =
|
||||||
|
Lwd.var @@ Lwd.pure @@ string "initializing..."
|
||||||
|
in
|
||||||
|
let cv, push_cv = Lwt_stream.create () in
|
||||||
|
let cvroot =
|
||||||
|
Lwd.observe ~on_invalidate:(fun _ ->
|
||||||
|
Log.info (fun m ->
|
||||||
|
m
|
||||||
|
"tree_nav cursorviewroot on_invalidate push_cv \
|
||||||
|
triggered??");
|
||||||
|
push_cv (Some ()))
|
||||||
|
@@ Lwd.map (Lwd.get cursor) ~f:(function
|
||||||
|
| Some cursor_row -> (
|
||||||
|
match Lwd_table.get cursor_row with
|
||||||
|
| Some (_focus, (step, tree)) -> (
|
||||||
|
Nav.S.Tree.kind tree [] >>= function
|
||||||
|
| Some `Node ->
|
||||||
|
Lwt.return @@ Lwd.pure @@ string "Sub-node??"
|
||||||
|
| Some `Contents -> (
|
||||||
|
Nav.S.Tree.find_all tree [] >>= function
|
||||||
|
| Some (contents, _metadata) ->
|
||||||
|
Lwt.return
|
||||||
|
(edit_area
|
||||||
|
~table:(edit_area_of_string contents)
|
||||||
|
())
|
||||||
|
| None ->
|
||||||
|
Lwt.return @@ Lwd.pure
|
||||||
|
@@ string ("could not find path: " ^ step))
|
||||||
|
| None -> Lwt.return @@ Lwd.pure @@ string step)
|
||||||
|
| None ->
|
||||||
|
Lwt.return @@ Lwd.pure
|
||||||
|
@@ string "cursor table row doesn't exist")
|
||||||
|
| None ->
|
||||||
|
Lwt.return @@ Lwd.pure @@ string "cursor doesn't exist")
|
||||||
|
in
|
||||||
|
Lwt.async (fun () ->
|
||||||
|
Lwt_stream.iter_s
|
||||||
|
(fun _ ->
|
||||||
|
Lwd.quick_sample cvroot >>= fun cursorview'' ->
|
||||||
|
Log.info (fun m ->
|
||||||
|
m
|
||||||
|
"tree_nav cursorviewroot on_invalidate Lwt.async \
|
||||||
|
(Lwd.set cursorview) triggered??");
|
||||||
|
Lwt.return (Lwd.set cursorview cursorview''))
|
||||||
|
cv);
|
||||||
|
push_cv (Some ());
|
||||||
Lwt.return
|
Lwt.return
|
||||||
(Lwd_table.map_reduce
|
(Lwd_table.map_reduce
|
||||||
(fun _ (f, (s, _)) ->
|
(fun _ (f, (s, _)) ->
|
||||||
@ -2976,7 +3027,11 @@ module Nottui_widgets = struct
|
|||||||
| `Backspace, [] -> `Unhandled
|
| `Backspace, [] -> `Unhandled
|
||||||
| `Uchar u, [ `Ctrl ] when eq_uc_c u 'k' -> `Handled
|
| `Uchar u, [ `Ctrl ] when eq_uc_c u 'k' -> `Handled
|
||||||
| _ -> `Unhandled))
|
| _ -> `Unhandled))
|
||||||
(Focus.status focus))
|
(Focus.status focus)
|
||||||
|
|> Lwd.map2
|
||||||
|
~f:(fun cursorview' tree_view ->
|
||||||
|
Ui.join_x tree_view cursorview')
|
||||||
|
(Lwd.join @@ Lwd.get cursorview))
|
||||||
|
|
||||||
(** Tab view, where exactly one element of [l] is shown at a time. *)
|
(** Tab view, where exactly one element of [l] is shown at a time. *)
|
||||||
let tabs (tabs : (string * (unit -> Ui.t Lwd.t)) list) : Ui.t Lwd.t
|
let tabs (tabs : (string * (unit -> Ui.t Lwd.t)) list) : Ui.t Lwd.t
|
||||||
|
|||||||
Reference in New Issue
Block a user