19 Commits

Author SHA1 Message Date
cqc
f0c5556450 tree_nav :3 2023-01-22 23:16:15 -06:00
cqc
97730899c6 tree_nav cursor movement 2023-01-13 09:30:36 -06:00
cqc
18daf83c1c loads and displays teh git tree 2023-01-13 05:39:51 -06:00
cqc
dfef26fcf5 text_area basic nav 2023-01-07 07:24:29 -06:00
cqc
048ea0eab4 text_area improvements 2022-12-18 11:14:37 -06:00
cqc
3509930195 added Focus.releases for line_table 2022-12-15 12:05:15 -06:00
cqc
b1ac36ce3e text editor issue is a problem with focus resolution
might require Focus.release, but may be incorrect use of Focus.request.
2022-12-14 19:39:28 -06:00
cqc
a12db025e0 Backspace but there's a subtle/unusual issue with enter/backspace and the text insertion occuring on the wrong line after unknown sequence. 2022-12-14 13:23:16 -06:00
cqc
5c10f3860a basic text field edition 2022-12-14 09:46:09 -06:00
cqc
a64fcbb010 refactored resizing and stuff 2022-12-11 18:25:57 -06:00
cqc
7baa6f3648 compute ui.w and ui.h during update 2022-12-10 14:27:22 -06:00
cqc
af92f03706 moar 2022-12-08 20:12:56 -06:00
cqc
cb263b5758 edit field editsdune build -w ./boot_js.bc.js 2022-12-08 12:27:36 -06:00
cqc
44879eb947 another barely working text rendering scheme 2022-12-07 12:47:56 -06:00
cqc
49bddb6365 urgh... stuck with how to implement cursor/focus etc. Decided to try to integrate Nottui and Nottui_widgets directly istead of reinventing another wheel. 2022-12-04 12:25:00 -06:00
cqc
b5d846b35d re-arranged 2022-11-22 23:38:53 -06:00
cqc
60c83c608a looks like shit 2022-11-22 13:19:51 -06:00
cqc
58ec73972b lwd-ifying it 2022-11-22 02:21:45 -06:00
cqc
b705c598ff use main branch 2022-11-17 20:25:20 -06:00
7 changed files with 577318 additions and 1322 deletions

574252
_build/default/boot_js.bc.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -4,8 +4,7 @@ module NVG = Graphv_webgl
let _ = let _ =
Logs.set_reporter (Human.Logs_reporter.console_reporter ()); Logs.set_reporter (Human.Logs_reporter.console_reporter ());
Logs.set_level (Some Debug); Logs.set_level (Some Debug)
Logs.debug (fun m -> m "hello")
module Log = (val Logs.src_log Logs.default : Logs.LOG) module Log = (val Logs.src_log Logs.default : Logs.LOG)
@ -27,12 +26,8 @@ let scale_canvas (canvas : Dom_html.canvasElement Js.t) =
canvas##.style##.width := width; canvas##.style##.width := width;
canvas##.style##.height := height canvas##.style##.height := height
let _ = let webgl_initialize canvas =
let canvas =
Js.Unsafe.coerce (Dom_html.getElementById_exn "canvas")
in
scale_canvas canvas; scale_canvas canvas;
let webgl_ctx =
(* Graphv requires a stencil buffer to work properly *) (* Graphv requires a stencil buffer to work properly *)
let attrs = WebGL.defaultContextAttributes in let attrs = WebGL.defaultContextAttributes in
attrs##.stencil := Js._true; attrs##.stencil := Js._true;
@ -43,7 +38,8 @@ let _ =
print_endline "Sorry your browser does not support WebGL"; print_endline "Sorry your browser does not support WebGL";
raise Exit raise Exit
| Some ctx -> ctx | Some ctx -> ctx
in
let graphv_initialize webgl_ctx =
let open NVG in let open NVG in
let vg = let vg =
create create
@ -53,57 +49,74 @@ let _ =
(* File in this case is actually the CSS font name *) (* File in this case is actually the CSS font name *)
Text.create vg ~name:"sans" ~file:"sans" |> ignore; Text.create vg ~name:"sans" ~file:"sans" |> ignore;
webgl_ctx##clearColor 0.3 0.3 0.32 1.; webgl_ctx##clearColor 0.3 0.3 0.32 1.;
vg
(* let request_animation_frame () =
let render ev = let t, s = Lwt.wait () in
webgl_ctx##clear let (_ : Dom_html.animation_frame_request_id) =
(webgl_ctx##._COLOR_BUFFER_BIT_
lor webgl_ctx##._DEPTH_BUFFER_BIT_
lor webgl_ctx##._STENCIL_BUFFER_BIT_);
let device_ratio = Dom_html.window##.devicePixelRatio in
begin_frame vg ~width:canvas##.width ~height:canvas##.height
~device_ratio;
Transform.scale vg ~x:device_ratio ~y:device_ratio;
ignore Human.Panel.Ui.(panel vg Gg.P2.o test ev);
(*
Path.begin_ vg ;
Path.rect vg ~x:40. ~y:40. ~w:320. ~h:320. ;
set_fill_color vg ~color:Color.(rgba ~r:154 ~g:203 ~b:255 ~a:200) ;
fill vg ;
Transform.translate vg ~x:200. ~y:200. ;
Transform.rotate vg ~angle:(time *. 0.0005) ;
Text.set_font_face vg ~name:"sans" ;
Text.set_size vg ~size:48. ;
Text.set_align vg ~align:Align.(center lor middle) ;
set_fill_color vg ~color:Color.white ;
Text.text vg ~x:0. ~y:0. "Hello World!" ; *)
NVG.end_frame vg
in
Dom_html.window##requestAnimationFrame Dom_html.window##requestAnimationFrame
(Js.wrap_callback (fun _ -> render Human.Event.empty)) (Js.wrap_callback (fun (time : float) -> Lwt.wakeup s time))
|> ignore;*) in
let open Js_of_ocaml_lwt.Lwt_js_events in t
async (fun () ->
buffered_loop (make_event Dom_html.Event.keydown) let render_stream canvas webgl_ctx vg
Dom_html.document (fun ev _ -> (render : NVG.t -> ?time:float -> Gg.p2 -> Human.I.t -> unit) :
Human.I.t Lwt_stream.t -> unit Lwt.t =
Lwt_stream.iter_n (fun i ->
request_animation_frame () >>= fun time ->
webgl_ctx##clear webgl_ctx##clear
(webgl_ctx##._COLOR_BUFFER_BIT_ (webgl_ctx##._COLOR_BUFFER_BIT_
lor webgl_ctx##._DEPTH_BUFFER_BIT_ lor webgl_ctx##._DEPTH_BUFFER_BIT_
lor webgl_ctx##._STENCIL_BUFFER_BIT_); lor webgl_ctx##._STENCIL_BUFFER_BIT_);
let device_ratio = Dom_html.window##.devicePixelRatio in let device_ratio = Dom_html.window##.devicePixelRatio in
begin_frame vg ~width:canvas##.width ~height:canvas##.height NVG.begin_frame vg ~width:canvas##.width ~height:canvas##.height
~device_ratio; ~device_ratio;
Transform.scale vg ~x:device_ratio ~y:device_ratio; NVG.Transform.scale vg ~x:device_ratio ~y:device_ratio;
Human.Panel.Ui.( render vg ~time Gg.P2.o i;
render_lwt vg Gg.P2.o
(Human.Event_js.evt_of_jskey `Press ev))
>>= fun p ->
Logs.debug (fun m ->
m "Drawing finished at point: %a" Gg.V2.pp p);
NVG.end_frame vg; NVG.end_frame vg;
Lwt.return_unit)) Lwt.return_unit)
(* Dom_html.document##.onkeydown open Human
:= Dom.handler (fun (evt : Dom_html.keyboardEvent Js.t) ->
render (Human.Event_js.evt_of_jskey `Press evt) ; let _ =
Js._false ) *) let canvas =
Js.Unsafe.coerce (Dom_html.getElementById_exn "canvas")
in
let webgl_ctx = webgl_initialize canvas in
let vg = graphv_initialize webgl_ctx in
let open Js_of_ocaml_lwt.Lwt_js_events in
let open Nottui in
let gravity_pad = Gravity.make ~h:`Negative ~v:`Negative in
let gravity_crop = Gravity.make ~h:`Positive ~v:`Negative in
let body = Lwd.var (Lwd.pure Ui.empty) in
let wm = Widgets.window_manager (Lwd.join (Lwd.get body)) in
Nav.test_pull () >>= fun test_tree ->
Widgets.(tree_nav test_tree []) >>= fun ui ->
let root =
Lwd.set body
(Lwd.map ~f:(Ui.resize ~pad:gravity_pad ~crop:gravity_crop) ui);
Widgets.window_manager_view wm
in
let events, push_event = Lwt_stream.create () in
let images =
Human.Nottui_lwt.render vg
~size:(Gg.P2.v canvas##.width canvas##.height)
events root
in
async (fun () ->
render_stream canvas webgl_ctx vg
(fun vg ?(time = 0.) p i ->
let _ = time in
Log.debug (fun m ->
m "Drawing image: p=%a n=%a" Gg.V2.pp p
(I.Draw.pp ~attr:A.dark)
i);
let p' = I.Draw.node vg A.dark p i in
Logs.debug (fun m ->
m "Drawing finished: p'=%a" Gg.V2.pp p'))
images);
buffered_loop (make_event Dom_html.Event.keydown) Dom_html.document
(fun ev _ ->
Lwt.return
@@ push_event (Some (`Key (Event_js.evt_of_jskey ev))))

View File

@ -4,4 +4,4 @@ if [ ! -f /tmp/key.pem ]; then
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout /tmp/key.pem -out /tmp/cert.pem -batch openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout /tmp/key.pem -out /tmp/cert.pem -batch
fi fi
npx http-server --cors -S -P https://github.com --log-ip -c-1 -C /tmp/cert.pem -K /tmp/key.pem npx http-server --cors -S -P https://gitea.departmentofinter.net --log-ip -c-1 -C /tmp/cert.pem -K /tmp/key.pem

3
dune
View File

@ -25,7 +25,6 @@
uri uri
zed zed
gg gg
wall lwd
)) ))

3944
human.ml

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
<!DOCTYPE> <!DOCTYPE html>
<html> <html>
<head> <head>
<style> <style>

44
notes.org Normal file
View File

@ -0,0 +1,44 @@
* mvp todo
** toplevel repl in js_of_ocaml
** git pull from gitea.departmentofinter.net/console/boot
** git push to gitea.departmentofinter.net/console/boot
** execute a git file execution in top level
** display arbitrary git file from pulled repo
** edit arbitrary file with common emacs bindings
*** move left and right by character
*** move up and down by line
* other todo
*** yank (to clipboard) next char
*** move left and right by word and sentance
*** region select
* principles?
an "anywhere" programming environment
* 221211
ok you got the scroll box mostly working so next:
** fix the scroll jump bugs
** setup better keybindings
** fix cursor and active focus indicators
* 221210 -
** need to resolve the issue with the ui.t Resize type.
this is an issue with the direction of the determination of the .height and .width fields of Ui.t
currently you were planning to combine update_sensors and update_size
in the original nottui.ml library, are Ui.t.w and Ui.t.h determined from the top down orbottom up?
the bottom up, becahse they are chars