code wiki / _hdl_build / nx_editor_canvas.nx

nx_editor_canvas.nx

buildroot/runtime/_hdl_build/nx_editor_canvas.nx

14791 B287 linesdepth 3pulls 4 transitivereach 7 importersview sourcekind librarytopic editor
docsdependenciesstructsconstsfunctions

about

nx_editor_canvas.nx -- the EDITOR engine: the sovereign, gateable CORE of a visual editor, as data+logic so it can be PROVEN without a browser. A canvas is a flat i64 array of N elements, 5 fields each: [kind, x, y, w, h]. Operations: snap-all-to-grid, align (L/R/T/B/center-h/middle-v), distribute-horizontally (even left edges), nudge, and one-deep undo (snapshot/restore). The surface is rendered NO-JS (ec_render); editing = server ops (apply an op, re-render), never a client-side JS canvas -- a JS drag-drop canvas is the JS-heavy approach the Nishi ecosystem REJECTS, not a maturity bar to chase. SOVEREIGN + no-JS + governed. REUSE: nx_brand_snap (bs_snap). license_tier: ORIGINAL

dependencies 3 imports · 5 importers

nx_syscalls.nx nx_brand_snap.nx nx_editstack_lib.nx nx_editor_canvas.nx nx_editor_canvas_gate.nx nx_editor_loop.nx nx_editor_render_gate.nx nx_editor_validate.nx nx_exceed_standard_gate.nx

imports: nx_syscalls.nxnx_brand_snap.nxnx_editstack_lib.nx

imported by: nx_editor_canvas_gate.nxnx_editor_loop.nxnx_editor_render_gate.nxnx_editor_validate.nxnx_exceed_standard_gate.nx

structs

none

consts

12const EC_STRIDE: i64 = 5 // [kind, x, y, w, h]
142const ECS_OP_SNAP: i64 = 1024 // a0 = grid
143const ECS_OP_ALIGN: i64 = 1025 // a0 = mode 0..5, exactly ec_align's mode
144const ECS_OP_DISTH: i64 = 1026 // no arguments
145const ECS_OP_NUDGE: i64 = 1027 // a0 = element index, a1 = dx, a2 = dy
150const ECS_ALIGN_MODE_MAX: i64 = 5
154const ECS_OK: i64 = 0
155const ECS_E_KIND: i64 = 0 - 33
156const ECS_E_MODE: i64 = 0 - 34
157const ECS_E_GRID: i64 = 0 - 35
158const ECS_E_IDX: i64 = 0 - 36
159const ECS_E_ARGS: i64 = 0 - 37

functions

15func ec_snap_all(c: *i64, n: i64, grid: i64) -> i64
called by 3: ecs_apply_opmainel_apply calls 1: bs_snap
26func ec_align(c: *i64, n: i64, mode: i64) -> i64
53func ec_distribute_h(c: *i64, n: i64) -> i64
64func ec_nudge(c: *i64, idx: i64, dx: i64, dy: i64) -> i64
called by 2: ecs_apply_opmain
70func ec_save(c: *i64, n: i64, hist: *i64) -> i64 { var i: i64 = 0; while i < n*EC_STRIDE { hist[i] = c[i]; i = i + 1 } return 0 }
called by 1: main
71func ec_undo(c: *i64, n: i64, hist: *i64) -> i64 { var i: i64 = 0; while i < n*EC_STRIDE { c[i] = hist[i]; i = i + 1 } return 0 }
called by 1: main
76func ec_w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 }
77func ec_wn(fd: i64, v: i64) -> i64
called by 1: ec_render calls 2: sys_writesys_mmap
86func ec_kindlabel(k: i64) -> *u8 { if k==1 { return "heading" as *u8 } if k==2 { return "text" as *u8 } if k==3 { return "button" as *u8 } if k==4 { return "image" as *u8 } return "block" as *u8 }
called by 1: ec_render
88func ec_render(c: *i64, n: i64, fd: i64) -> i64
161func ecs_code_name(c: i64) -> *u8
called by 1: main calls 1: es_err_name
174func ecs_apply_op(c: *i64, n: i64, kind: i64, a0: i64, a1: i64, a2: i64) -> i64
201func ecs_new(cap_ops: i64, n: i64) -> *i64
called by 2: mainmain calls 1: es_new
206func ecs_nelem(st: *i64) -> i64 { return es_ncells(st) / EC_STRIDE }
207func ecs_canvas(st: *i64) -> *i64 { return es_live_ptr(st) }
called by 2: mainmain calls 1: es_live_ptr
208func ecs_digest(st: *i64) -> i64 { return es_digest(st) }
called by 2: mainmain calls 1: es_digest
212func ecs_seed(st: *i64, c: *i64, n: i64) -> i64
called by 2: mainmain calls 2: es_ncellses_base_set
225func ecs_replay(st: *i64) -> i64
242func ecs_push(st: *i64, kind: i64, a0: i64, a1: i64, a2: i64) -> i64
257func ecs_undo(st: *i64) -> i64
264func ecs_redo(st: *i64) -> i64
273func ecs_reeval(st: *i64, idx: i64, a0: i64, a1: i64, a2: i64) -> i64
called by 1: main calls 2: es_op_args_setecs_replay
280func ecs_snap(st: *i64, grid: i64) -> i64 { return ecs_push(st, ECS_OP_SNAP, grid, 0, 0) }
called by 2: mainel_apply_st calls 1: ecs_push
281func ecs_align(st: *i64, mode: i64) -> i64 { return ecs_push(st, ECS_OP_ALIGN, mode, 0, 0) }
called by 2: mainel_apply_st calls 1: ecs_push
282func ecs_distribute_h(st: *i64) -> i64 { return ecs_push(st, ECS_OP_DISTH, 0, 0, 0) }
called by 2: mainel_apply_st calls 1: ecs_push
283func ecs_nudge(st: *i64, idx: i64, dx: i64, dy: i64) -> i64 { return ecs_push(st, ECS_OP_NUDGE, idx, dx, dy) }
called by 1: main calls 1: ecs_push
286func ecs_render(st: *i64, fd: i64) -> i64 { return ec_render(es_live_ptr(st), ecs_nelem(st), fd) }