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 ./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) =
|
||||
if res != 0:
|
||||
|
@ -136,7 +139,7 @@ proc main() =
|
|||
connectUnix(turn, "/run/syndicate/ds", cap) do (turn: var Turn; a: Assertion) -> TurnAction:
|
||||
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:
|
||||
app.panes.del(hash svg)
|
||||
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,
|
||||
syndicate/[actors, capabilities, relay]
|
||||
|
||||
import ../src/zua/protocol
|
||||
|
||||
proc quitHook() {.noconv.} =
|
||||
quit()
|
||||
import svui
|
||||
type Svui = svui.Svui[Ref]
|
||||
|
||||
proc main() =
|
||||
proc quitHook() {.noconv.} = quit()
|
||||
setControlCHook(quitHook)
|
||||
|
||||
waitFor runActor("client") do (turn: var Turn):
|
||||
|
@ -31,7 +30,7 @@ proc main() =
|
|||
if xml.tag != "svg":
|
||||
stderr.writeLine arg, " not recognized as SVG"
|
||||
else:
|
||||
discard publish(turn, ds, Pane(svg: $xml))
|
||||
discard publish(turn, ds, Svui(svg: $xml))
|
||||
|
||||
stderr.writeLine "done"
|
||||
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# SPDX-FileCopyrightText: ☭ 2021 Emery Hemingway
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
import std/[asyncdispatch, os, parseopt, strutils, xmltree]
|
||||
import std/[asyncdispatch, os, parseopt, strutils, tables, xmltree]
|
||||
import preserves, preserves/xmlhooks
|
||||
import syndicate, syndicate/[actors, capabilities, relay]
|
||||
import parsegemini
|
||||
import gemclient
|
||||
import nimsvg
|
||||
import svui
|
||||
import eris
|
||||
|
||||
import ../src/zua/protocol
|
||||
|
||||
proc quitHook() {.noconv.} =
|
||||
quit()
|
||||
type Svui = svui.Svui[Ref]
|
||||
|
||||
proc main() =
|
||||
proc quitHook() {.noconv.} = quit()
|
||||
setControlCHook(quitHook)
|
||||
|
||||
waitFor runActor("client") do (turn: var Turn):
|
||||
|
@ -44,11 +44,14 @@ proc main() =
|
|||
close(p)
|
||||
let doc = buildSvg:
|
||||
svg(viewBox="0 0 600 800", `font-family` = "Gentium Plus", `font-size`="20"):
|
||||
text:
|
||||
for n in nodes: embed n
|
||||
let buf = render doc
|
||||
stdout.writeLine buf
|
||||
discard publish(turn, ds, Pane(svg: buf))
|
||||
g(fill="white"):
|
||||
text(fill="black"):
|
||||
for n in nodes: embed n
|
||||
let
|
||||
buf = render doc
|
||||
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"
|
||||
|
||||
|
|
Loading…
Reference in New Issue