]> gitweb.factorcode.org Git - factor.git/commitdiff
file-picker.operations: new vocab with save-as operation for byte-arrays
authorAlexander Iljin <ajsoft@yandex.ru>
Fri, 26 May 2017 10:18:48 +0000 (13:18 +0300)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 29 May 2017 15:05:59 +0000 (08:05 -0700)
extra/file-picker/operations/authors.txt [new file with mode: 0644]
extra/file-picker/operations/operations.factor [new file with mode: 0644]

diff --git a/extra/file-picker/operations/authors.txt b/extra/file-picker/operations/authors.txt
new file mode 100644 (file)
index 0000000..8e1955f
--- /dev/null
@@ -0,0 +1 @@
+Alexander Ilin
diff --git a/extra/file-picker/operations/operations.factor b/extra/file-picker/operations/operations.factor
new file mode 100644 (file)
index 0000000..16a4f25
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2017 Alexander Ilin.
+! See http://factorcode.org/license.txt for BSD license.
+USING: byte-arrays file-picker io io.encodings.binary io.files
+kernel locals ui.commands ui.operations ;
+IN: file-picker.operations
+
+:: save-as ( data -- )
+    "" save-file-dialog [ binary [ data write ] with-file-writer ] when* ;
+
+! Right-click a byte-array presentation to open the Save As window.
+[ byte-array? ] \ save-as H{
+    { +description+ "Save the binary data to a file" }
+} define-operation