Repository navigation
Expand file tree
/
Copy pathexample-protocol.lisp
More file actions
42 lines (39 loc) · 1.99 KB
/
Copy pathexample-protocol.lisp
File metadata and controls
42 lines (39 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
;;;; SPDX-FileCopyrightText: Atlas Engineer LLC
;;;; SPDX-License-Identifier: BSD-3-Clause
(in-package :electron/examples)
(defun electron-protocol-example ()
(setf (electron:protocols electron:*interface*)
(list (make-instance 'electron:protocol
:scheme-name "test"
:privileges "{}")))
(electron:launch electron:*interface*)
(electron:handle (find "test" (electron:protocols electron:*interface*)
:key #'electron:scheme-name :test #'string-equal)
"() => {return new Response('Hello test scheme.')}")
(let ((win (make-instance 'electron:window))
(view1 (make-instance 'electron:view))
(view2 (make-instance 'electron:view)))
(electron:add-view win view1)
(electron:add-view win view2)
(electron:set-bounds view1 :x 0 :y 0 :width 400 :height 200)
(electron:set-bounds view2 :x 0 :y 200 :width 400 :height 200)
(electron:load-url view1 "test:dummy-var")
(electron:load-url view2 "test:dummy-var")))
(defun electron-protocol-example-callback ()
(setf (electron:protocols electron:*interface*)
(list (make-instance 'electron:protocol
:scheme-name "test"
:privileges "{}")))
(electron:launch electron:*interface*)
(electron:handle-callback (find "test" (electron:protocols electron:*interface*)
:key #'electron:scheme-name :test #'string-equal)
(lambda (xyz) (print xyz) "Text with UTF-8 ✈ encoding."))
(let ((win (make-instance 'electron:window))
(view1 (make-instance 'electron:view))
(view2 (make-instance 'electron:view)))
(electron:add-view win view1)
(electron:add-view win view2)
(electron:set-bounds view1 :x 0 :y 0 :width 400 :height 200)
(electron:set-bounds view2 :x 0 :y 200 :width 400 :height 200)
(electron:load-url view1 "test:dummy-var")
(electron:load-url view2 "test:dummy-var")))