]> gitweb.factorcode.org Git - factor.git/commitdiff
json: adding "Copy JSON" UI operation
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 25 Oct 2023 18:28:45 +0000 (11:28 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 25 Oct 2023 18:28:45 +0000 (11:28 -0700)
basis/json/json.factor
basis/json/ui/ui.factor [new file with mode: 0644]

index 77619cd85a5b38b5d3b703439c3b87430fb2b48f..021bfeb1f98262ba1fe6f50335832b4f4ed36360 100644 (file)
@@ -4,7 +4,7 @@ USING: accessors ascii assocs combinators formatting hashtables
 io io.encodings.utf16.private io.encodings.utf8 io.files
 io.streams.string kernel kernel.private linked-assocs make math
 math.order math.parser mirrors namespaces sbufs sequences
-sequences.private strings summary tr words ;
+sequences.private strings summary tr words vocabs.loader ;
 
 IN: json
 
@@ -355,3 +355,5 @@ M: string jsonlines>
 
 : rewrite-jsons-path ( path quot: ( jsons -- jsons' ) -- )
     [ [ path>jsons ] dip call ] keepd jsons>path ; inline
+
+{ "json" "ui.tools" } "json.ui" require-when
diff --git a/basis/json/ui/ui.factor b/basis/json/ui/ui.factor
new file mode 100644 (file)
index 0000000..3738bea
--- /dev/null
@@ -0,0 +1,7 @@
+USING: json kernel strings ui.clipboards ui.operations ;
+IN: json.ui
+
+: copy-json ( obj -- )
+    >json >clipboard ;
+
+[ string? not ] \ copy-json H{ } define-operation