Move protocol to svui repository
This commit is contained in:
parent
cf762d96c7
commit
638950be49
|
@ -1,3 +0,0 @@
|
||||||
version 1.
|
|
||||||
|
|
||||||
Pane = <svg @svg string>.
|
|
|
@ -12,9 +12,12 @@ import pixie, pixie/fileformats/svg
|
||||||
|
|
||||||
import math, sdl2, sdl2/gfx
|
import math, sdl2, sdl2/gfx
|
||||||
|
|
||||||
import ./zua/protocol
|
import svui
|
||||||
|
|
||||||
type SdlError = object of CatchableError
|
type
|
||||||
|
Svui = svui.Svui[Ref]
|
||||||
|
SdlError = object of CatchableError
|
||||||
|
Attrs = Table[string, Assertion]
|
||||||
|
|
||||||
template check(res: cint) =
|
template check(res: cint) =
|
||||||
if res != 0:
|
if res != 0:
|
||||||
|
@ -136,7 +139,7 @@ proc main() =
|
||||||
connectUnix(turn, "/run/syndicate/ds", cap) do (turn: var Turn; a: Assertion) -> TurnAction:
|
connectUnix(turn, "/run/syndicate/ds", cap) do (turn: var Turn; a: Assertion) -> TurnAction:
|
||||||
let ds = unembed a
|
let ds = unembed a
|
||||||
|
|
||||||
onPublish(turn, ds, protocol.Pane ? {0: `?*`()}) do (svg: string):
|
onPublish(turn, ds, Svui ? {0: drop(), 1: grab()}) do (svg: string):
|
||||||
onRetract:
|
onRetract:
|
||||||
app.panes.del(hash svg)
|
app.panes.del(hash svg)
|
||||||
app.update()
|
app.update()
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
: ../../protocol.prs |> preserves_schema_nim %f |> protocol.nim
|
|
|
@ -1,13 +0,0 @@
|
||||||
|
|
||||||
import
|
|
||||||
std/typetraits, preserves
|
|
||||||
|
|
||||||
type
|
|
||||||
Pane* {.preservesRecord: "svg".} = object
|
|
||||||
`svg`*: string
|
|
||||||
|
|
||||||
proc `$`*(x: Pane): string =
|
|
||||||
`$`(toPreserve(x))
|
|
||||||
|
|
||||||
proc encode*(x: Pane): seq[byte] =
|
|
||||||
encode(toPreserve(x))
|
|
|
@ -6,12 +6,11 @@ import preserves
|
||||||
import syndicate,
|
import syndicate,
|
||||||
syndicate/[actors, capabilities, relay]
|
syndicate/[actors, capabilities, relay]
|
||||||
|
|
||||||
import ../src/zua/protocol
|
import svui
|
||||||
|
type Svui = svui.Svui[Ref]
|
||||||
proc quitHook() {.noconv.} =
|
|
||||||
quit()
|
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
|
proc quitHook() {.noconv.} = quit()
|
||||||
setControlCHook(quitHook)
|
setControlCHook(quitHook)
|
||||||
|
|
||||||
waitFor runActor("client") do (turn: var Turn):
|
waitFor runActor("client") do (turn: var Turn):
|
||||||
|
@ -31,7 +30,7 @@ proc main() =
|
||||||
if xml.tag != "svg":
|
if xml.tag != "svg":
|
||||||
stderr.writeLine arg, " not recognized as SVG"
|
stderr.writeLine arg, " not recognized as SVG"
|
||||||
else:
|
else:
|
||||||
discard publish(turn, ds, Pane(svg: $xml))
|
discard publish(turn, ds, Svui(svg: $xml))
|
||||||
|
|
||||||
stderr.writeLine "done"
|
stderr.writeLine "done"
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
# SPDX-FileCopyrightText: ☭ 2021 Emery Hemingway
|
# SPDX-FileCopyrightText: ☭ 2021 Emery Hemingway
|
||||||
# SPDX-License-Identifier: Unlicense
|
# SPDX-License-Identifier: Unlicense
|
||||||
|
|
||||||
import std/[asyncdispatch, os, parseopt, strutils, xmltree]
|
import std/[asyncdispatch, os, parseopt, strutils, tables, xmltree]
|
||||||
import preserves, preserves/xmlhooks
|
import preserves, preserves/xmlhooks
|
||||||
import syndicate, syndicate/[actors, capabilities, relay]
|
import syndicate, syndicate/[actors, capabilities, relay]
|
||||||
import parsegemini
|
import parsegemini
|
||||||
import gemclient
|
import gemclient
|
||||||
import nimsvg
|
import nimsvg
|
||||||
|
import svui
|
||||||
|
import eris
|
||||||
|
|
||||||
import ../src/zua/protocol
|
type Svui = svui.Svui[Ref]
|
||||||
|
|
||||||
proc quitHook() {.noconv.} =
|
|
||||||
quit()
|
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
|
proc quitHook() {.noconv.} = quit()
|
||||||
setControlCHook(quitHook)
|
setControlCHook(quitHook)
|
||||||
|
|
||||||
waitFor runActor("client") do (turn: var Turn):
|
waitFor runActor("client") do (turn: var Turn):
|
||||||
|
@ -44,11 +44,14 @@ proc main() =
|
||||||
close(p)
|
close(p)
|
||||||
let doc = buildSvg:
|
let doc = buildSvg:
|
||||||
svg(viewBox="0 0 600 800", `font-family` = "Gentium Plus", `font-size`="20"):
|
svg(viewBox="0 0 600 800", `font-family` = "Gentium Plus", `font-size`="20"):
|
||||||
text:
|
g(fill="white"):
|
||||||
|
text(fill="black"):
|
||||||
for n in nodes: embed n
|
for n in nodes: embed n
|
||||||
let buf = render doc
|
let
|
||||||
stdout.writeLine buf
|
buf = render doc
|
||||||
discard publish(turn, ds, Pane(svg: buf))
|
bs = if buf.len < (16 shl 10): bs1k else: bs32k
|
||||||
|
capPr = toPreserve($erisCap(buf, bs), Ref)
|
||||||
|
discard publish(turn, ds, Svui(attrs: toTable {"urn": capPr}, svg: buf))
|
||||||
|
|
||||||
stderr.writeLine "done"
|
stderr.writeLine "done"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue