code wiki / _hdl_build / nx_editor_canvas.nx
nx_editor_canvas.nx
buildroot/runtime/_hdl_build/nx_editor_canvas.nx
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
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
| 12 | const EC_STRIDE: i64 = 5 // [kind, x, y, w, h] |
| 142 | const ECS_OP_SNAP: i64 = 1024 // a0 = grid |
| 143 | const ECS_OP_ALIGN: i64 = 1025 // a0 = mode 0..5, exactly ec_align's mode |
| 144 | const ECS_OP_DISTH: i64 = 1026 // no arguments |
| 145 | const ECS_OP_NUDGE: i64 = 1027 // a0 = element index, a1 = dx, a2 = dy |
| 150 | const ECS_ALIGN_MODE_MAX: i64 = 5 |
| 154 | const ECS_OK: i64 = 0 |
| 155 | const ECS_E_KIND: i64 = 0 - 33 |
| 156 | const ECS_E_MODE: i64 = 0 - 34 |
| 157 | const ECS_E_GRID: i64 = 0 - 35 |
| 158 | const ECS_E_IDX: i64 = 0 - 36 |
| 159 | const ECS_E_ARGS: i64 = 0 - 37 |
functions
| 15 | func ec_snap_all(c: *i64, n: i64, grid: i64) -> i64 |
| 26 | func ec_align(c: *i64, n: i64, mode: i64) -> i64 |
| 53 | func ec_distribute_h(c: *i64, n: i64) -> i64 |
| 64 | func ec_nudge(c: *i64, idx: i64, dx: i64, dy: i64) -> i64 |
| 70 | func 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 |
| 71 | func 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 |
| 76 | func 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 } |
| 77 | func ec_wn(fd: i64, v: i64) -> i64 |
| 86 | func 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 |
| 88 | func ec_render(c: *i64, n: i64, fd: i64) -> i64 |
| 161 | func ecs_code_name(c: i64) -> *u8 |
| 174 | func ecs_apply_op(c: *i64, n: i64, kind: i64, a0: i64, a1: i64, a2: i64) -> i64 |
| 201 | func ecs_new(cap_ops: i64, n: i64) -> *i64 |
| 206 | func ecs_nelem(st: *i64) -> i64 { return es_ncells(st) / EC_STRIDE } |
| 207 | func ecs_canvas(st: *i64) -> *i64 { return es_live_ptr(st) } |
| 208 | func ecs_digest(st: *i64) -> i64 { return es_digest(st) } |
| 212 | func ecs_seed(st: *i64, c: *i64, n: i64) -> i64 |
| 225 | func ecs_replay(st: *i64) -> i64 |
| 242 | func ecs_push(st: *i64, kind: i64, a0: i64, a1: i64, a2: i64) -> i64 called by 4: ecs_snapecs_alignecs_distribute_hecs_nudge calls 7: es_heades_capecs_apply_opes_live_ptrecs_nelemes_push_raw+1 |
| 257 | func ecs_undo(st: *i64) -> i64 |
| 264 | func ecs_redo(st: *i64) -> i64 |
| 273 | func ecs_reeval(st: *i64, idx: i64, a0: i64, a1: i64, a2: i64) -> i64 |
| 280 | func ecs_snap(st: *i64, grid: i64) -> i64 { return ecs_push(st, ECS_OP_SNAP, grid, 0, 0) } |
| 281 | func ecs_align(st: *i64, mode: i64) -> i64 { return ecs_push(st, ECS_OP_ALIGN, mode, 0, 0) } |
| 282 | func ecs_distribute_h(st: *i64) -> i64 { return ecs_push(st, ECS_OP_DISTH, 0, 0, 0) } |
| 283 | func ecs_nudge(st: *i64, idx: i64, dx: i64, dy: i64) -> i64 { return ecs_push(st, ECS_OP_NUDGE, idx, dx, dy) } |
| 286 | func ecs_render(st: *i64, fd: i64) -> i64 { return ec_render(es_live_ptr(st), ecs_nelem(st), fd) } |