webview

Check-in [b7e378098a]
Login

Check-in [b7e378098a]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Green threads support
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b7e378098ab2c25663ed8f077cd1e970b7dd3028091920c1e2867e4d19d18b71
User & Date: murphy 2018-08-31 14:08:59.139
Context
2018-08-31
14:42
Split content generation procedures into support module check-in: 082f8c0d5b user: murphy tags: trunk
14:08
Green threads support check-in: b7e378098a user: murphy tags: trunk
10:59
API Documentation check-in: 92945aef40 user: murphy tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to webview.scm.
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109





110
111
112
113
114
115
116
      (handle-exceptions
        exn (webview-log
             (string-trim
              (call-with-output-string
               (cut print-error-message exn <> "Callback Error"))))
        (proc view data)))))

(define (webview title proc #!key [url #f] [width 800] [height 600] [resizable? #t] [debug? #f])
  (letrec ([view
            ((foreign-lambda
              webview "webview_new"
              nonnull-c-string c-string int int bool bool)
             title url width height resizable? debug?)]
           [loop
            (lambda ()
              (when (zero?
                     ((foreign-safe-lambda
                       int "webview_loop"
                       nonnull-webview bool)
                      view #t))





                (loop)))])
    (if view
      (set-finalizer!
       view
       (foreign-lambda
        void "webview_destroy"
        nonnull-webview))







|











|
>
>
>
>
>







90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
      (handle-exceptions
        exn (webview-log
             (string-trim
              (call-with-output-string
               (cut print-error-message exn <> "Callback Error"))))
        (proc view data)))))

(define (webview title proc #!key [url #f] [width 800] [height 600] [resizable? #t] [debug? #f] [yield! #f])
  (letrec ([view
            ((foreign-lambda
              webview "webview_new"
              nonnull-c-string c-string int int bool bool)
             title url width height resizable? debug?)]
           [loop
            (lambda ()
              (when (zero?
                     ((foreign-safe-lambda
                       int "webview_loop"
                       nonnull-webview bool)
                      view (not yield!)))
                (cond
                  [(number? yield!)
                   (thread-sleep! yield!)]
                  [yield!
                   (thread-yield!)])
                (loop)))])
    (if view
      (set-finalizer!
       view
       (foreign-lambda
        void "webview_destroy"
        nonnull-webview))
Changes to webview.wiki.
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
43
44
45
46
47
<h3><tt><nowiki>
  (webview? VALUE) ⇒ BOOLEAN
</nowiki></tt></h3>

Predicate for the tagged pointer type representing a web view window.

<h3><tt><nowiki>
  (webview TITLE PROC [#:url URL] [#:width WIDTH] [#:height HEIGHT] [#:resizable? RESIZABLE] [#:debug? DEBUG]) ⇒ VOID
</nowiki></tt></h3>

Creates a web view window with the given <tt>TITLE</tt> and runs an
event loop until the user closes the window or termination is requested
using <tt>webview-terminate!</tt>.

The message callback is invoked as <tt>(PROC WEBVIEW STRING)</tt>
whenever a script on the web page calls <tt>window.external.invoke(STRING)</tt>.

If you specify a <tt>URL</tt> that is not <tt>#f</tt>, the page at that
location is loaded into the web view. Otherwise, a blank page is loaded
which sends a <tt>"load"</tt> message when ready and contains a
<tt>&lt;div id="app"&gt;</tt> element that you can fill with custom
content, for example using <tt>webview-inject</tt>.

Window properties may be specified using the <tt>WIDTH</tt>,
<tt>HEIGHT</tt> and <tt>RESIZABLE</tt> keyword arguments. When the
<tt>DEBUG</tt> keyword argument is not <tt>#f</tt>, the web view will
allow access to debugging tools, if the platform supports it.











<h3><tt><nowiki>
  (webview-terminate! WEBVIEW) ⇒ VOID
</nowiki></tt></h3>

Requests termination of the event loop for the given <tt>WEBVIEW</tt>.








|
















|
|
|
>
>
>
>
>
>
>
>
>
>







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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<h3><tt><nowiki>
  (webview? VALUE) ⇒ BOOLEAN
</nowiki></tt></h3>

Predicate for the tagged pointer type representing a web view window.

<h3><tt><nowiki>
  (webview TITLE PROC [#:url URL] [#:width WIDTH] [#:height HEIGHT] [#:resizable? RESIZABLE] [#:debug? DEBUG] [#:yield! YIELD]) ⇒ VOID
</nowiki></tt></h3>

Creates a web view window with the given <tt>TITLE</tt> and runs an
event loop until the user closes the window or termination is requested
using <tt>webview-terminate!</tt>.

The message callback is invoked as <tt>(PROC WEBVIEW STRING)</tt>
whenever a script on the web page calls <tt>window.external.invoke(STRING)</tt>.

If you specify a <tt>URL</tt> that is not <tt>#f</tt>, the page at that
location is loaded into the web view. Otherwise, a blank page is loaded
which sends a <tt>"load"</tt> message when ready and contains a
<tt>&lt;div id="app"&gt;</tt> element that you can fill with custom
content, for example using <tt>webview-inject</tt>.

Window properties may be specified using the <tt>WIDTH</tt>,
<tt>HEIGHT</tt> and <tt>RESIZABLE</tt> keyword arguments. If the
<tt>DEBUG</tt> keyword argument is not <tt>#f</tt> and the platform
supports it, the web view will allow access to debugging tools.

If <tt>YIELD</tt> is not given or <tt>#f</tt>, the event loop will block
the operating system thread when no events are pending. You can set
<tt>YIELD</tt> to a number of seconds sleep period between iterations of
the web view event loop; this reduces responsiveness of the user
interface but allows other CHICKEN threads to run and does not hog the
CPU. You can also set <tt>YIELD</tt> to <tt>#t</tt> to call
<tt>thread-yield!</tt> between iterations of the event loop; this allows
other CHICKEN threads to run without delaying user interface event
processing but will use a lot of CPU cycles.

<h3><tt><nowiki>
  (webview-terminate! WEBVIEW) ⇒ VOID
</nowiki></tt></h3>

Requests termination of the event loop for the given <tt>WEBVIEW</tt>.

93
94
95
96
97
98
99



100
101
102
103
104
105
106
dialog is cancelled.

Otherwise, a message dialog is shown and the <tt>#:error</tt> or
<tt>#:warning</tt> flags may be used to switch from an information icon
to a different look. In this case, <tt>VALUE</tt> is the message to
display in the dialog and the procedure will not return a meaningful
result.




<h2>Logging</h2>

<h3><tt><nowiki>
  (webview-log MESSAGE) ⇒ VOID
</nowiki></tt></h3>








>
>
>







103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
dialog is cancelled.

Otherwise, a message dialog is shown and the <tt>#:error</tt> or
<tt>#:warning</tt> flags may be used to switch from an information icon
to a different look. In this case, <tt>VALUE</tt> is the message to
display in the dialog and the procedure will not return a meaningful
result.

The running operating system thread will be blocked until the dialog is
dismissed.

<h2>Logging</h2>

<h3><tt><nowiki>
  (webview-log MESSAGE) ⇒ VOID
</nowiki></tt></h3>