code wiki / _hdl_build / nx_deck.nx
nx_deck.nx source
↩ module page · 41 lines · 2568 B
1// nx_deck.nx -- LIB: sovereign PRESENTATION generator -- the first organ of the Nishi office suite. Builds a deck
2// (slides: a title + bullets) from DATA and emits TWO formats: (1) our SUPERIOR SOVEREIGN .ndeck -- line-based,
3// deterministic, human-readable, diffable, tiny (no XML/ZIP bloat) -- and (2) a PowerPoint-COMPATIBLE OOXML
4// presentationml slide (the exact XML PowerPoint uses inside a .pptx; single-quoted attrs = valid XML, no escaping).
5// Sovereign-native + interop-export, exactly like Gerber: our format is the real one, .pptx is the bridge. never-brick
6// #26: pure file writes, deterministic. license_tier: ORIGINAL
7import "nx_syscalls.nx"
8
9func dk_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
10func dk_wf(fd: i64, s: *u8) -> i64 { sys_write(fd, s, dk_strlen(s)); return 0 }
11
12// emit our sovereign .ndeck format.
13func deck_write_ndeck(fd: i64, deck_title: *u8, titles: *i64, nslides: i64, bullets: *i64, boff: *i64, bcnt: *i64) -> i64 {
14 dk_wf(fd, "DECK " as *u8); dk_wf(fd, deck_title); dk_wf(fd, "\n" as *u8)
15 var s: i64 = 0
16 while s < nslides {
17 dk_wf(fd, "SLIDE\n" as *u8)
18 dk_wf(fd, "TITLE " as *u8); dk_wf(fd, titles[s] as *u8); dk_wf(fd, "\n" as *u8)
19 var b: i64 = 0
20 while b < bcnt[s] { dk_wf(fd, "BULLET " as *u8); dk_wf(fd, bullets[boff[s]+b] as *u8); dk_wf(fd, "\n" as *u8); b=b+1 }
21 s=s+1
22 }
23 return 0
24}
25
26// emit a PowerPoint-compatible OOXML presentationml slide (one slide). Single-quoted attributes = valid XML, no escaping.
27func deck_write_pptx_slide(fd: i64, title: *u8, bullets: *i64, boff_s: i64, bcnt_s: i64) -> i64 {
28 dk_wf(fd, "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>\n" as *u8)
29 dk_wf(fd, "<p:sld xmlns:p='http://schemas.openxmlformats.org/presentationml/2006/main' xmlns:a='http://schemas.openxmlformats.org/drawingml/2006/main'><p:cSld><p:spTree>\n" as *u8)
30 dk_wf(fd, "<p:sp><p:nvSpPr><p:cNvPr id='1' name='Title'/><p:nvPr><p:ph type='title'/></p:nvPr></p:nvSpPr><p:txBody><a:bodyPr/><a:p><a:r><a:t>" as *u8)
31 dk_wf(fd, title)
32 dk_wf(fd, "</a:t></a:r></a:p></p:txBody></p:sp>\n" as *u8)
33 dk_wf(fd, "<p:sp><p:nvSpPr><p:cNvPr id='2' name='Body'/><p:nvPr><p:ph type='body' idx='1'/></p:nvPr></p:nvSpPr><p:txBody><a:bodyPr/>" as *u8)
34 var b: i64 = 0
35 while b < bcnt_s {
36 dk_wf(fd, "<a:p><a:r><a:t>" as *u8); dk_wf(fd, bullets[boff_s+b] as *u8); dk_wf(fd, "</a:t></a:r></a:p>" as *u8)
37 b=b+1
38 }
39 dk_wf(fd, "</p:txBody></p:sp>\n</p:spTree></p:cSld></p:sld>\n" as *u8)
40 return 0
41}