webview

Check-in [92945aef40]
Login

Check-in [92945aef40]

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

Overview
Comment:API Documentation
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 92945aef40e60ada51c743b922791c682975c2b38f3062635657ca1d76d0b0b6
User & Date: murphy 2018-08-31 10:59:29.327
Context
2018-08-31
14:08
Green threads support check-in: b7e378098a user: murphy tags: trunk
10:59
API Documentation check-in: 92945aef40 user: murphy tags: trunk
09:22
Primary module check-in: c46caad7e9 user: murphy tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Added webview.wiki.




























































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<h1>Web View API</h1>

<h3><tt><nowiki>
  (import webview)
</nowiki></tt></h3>

This multi-platform library for [https://www.call-cc.org/|CHICKEN]
allows you to show HTML user interfaces in a window, inject JavaScript
code and HTML content into the page and receive messages from JavaScript
on the page.

<h2>Web View</h2>

<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>.

<h3><tt><nowiki>
  (webview-title-set! WEBVIEW TITLE) ⇒ VOID
</nowiki></tt></h3>

Sets the <tt>TITLE</tt> of the given <tt>WEBVIEW</tt> window.

<h3><tt><nowiki>
  (webview-fullscreen-set! WEBVIEW FULLSCREEN) ⇒ VOID
</nowiki></tt></h3>

Changes the <tt>FULLSCREEN</tt> state of the given <tt>WEBVIEW</tt>
window.

<h3><tt><nowiki>
  (webview-eval WEBVIEW SCRIPT) ⇒ VOID
</nowiki></tt></h3>

Asynchronously triggers evaluation of the given <tt>SCRIPT</tt> code in
the context of the page displayed by the given <tt>WEBVIEW</tt>.

<h3><tt><nowiki>
  (webview-inject WEBVIEW ID HTML) ⇒ VOID
</nowiki></tt></h3>

Asynchronously triggers replacement of the DOM element with the given
<tt>ID</tt> on the page displayed by the given <tt>WEBVIEW</tt> with the
given <tt>HTML</tt> content.

<tt>HTML</tt> content is specified in the form accepted by
<tt>write-html</tt>.

<h2>Dialogs</h2>

<h3><tt><nowiki>
  (webview-dialog WEBVIEW TITLE [VALUE] [#:open | #:save | #:error | #:warning] [#:directory]) ⇒ VALUE
</nowiki></tt></h3>

Shows a modal dialog with the given <tt>TITLE</tt> in the context of the
given <tt>WEBVIEW</tt>.

If the <tt>#:open</tt> or <tt>#:save</tt> flags are given, a file
selection dialog is shown and <tt>VALUE</tt> may be the path to a file
that will be pre-selected. The <tt>#:directory</tt> flag indicates that
directories rather than regular files should be selected. The procedure
will return the path to a selected file or <tt>#f</tt> in case the
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>

Outputs a message using a platform-specific logging mechanism.

<h2>Content Generation</h2>

<h3><tt><nowiki>
  char-set:no-js-escape
</nowiki></tt></h3>

A SRFI-14 set of characters that do not need to be escaped inside a
JavaScript string.

<h3><tt><nowiki>
  (write-js STRING [PORT] [QUOTES]) ⇒ VOID
</nowiki></tt></h3>

Writes a <tt>STRING</tt> to the given <tt>PORT</tt> or the current
output port using JavaScript escaping rules. If <tt>QUOTES</tt> is given
and not <tt>#f</tt>, its content is printed before and after the
<tt>STRING</tt> contents. If <tt>QUOTES</tt> is not given, double quotes
are put around the string.

<h3><tt><nowiki>
  (html-tag-rule TAG) ⇒ RULE
</nowiki></tt></h3>
<h3><tt><nowiki>
  (html-tag-rule TAG RULE) ⇒ VOID
</nowiki></tt></h3>

Retrieves or sets the content rule for HTML elements named <tt>TAG</tt>.
The <tt>RULE</tt> can be one of the symbols <tt>normal</tt>,
<tt>raw</tt> or <tt>void</tt>.

<h3><tt><nowiki>
  (write-html ELEMENT [PORT]) ⇒ VOID
</nowiki></tt></h3>

Writes an HTML5 rendering of the X-expression <tt>ELEMENT</tt> to the
given <tt>PORT</tt> or the current output port.

<tt>ELEMENT</tt> must conform to the following grammar:
<verbatim>
  X-EXPR  = ELEMENT
          | CONTENT
  ELEMENT = (SYMBOL ((SYMBOL CONTENT ...) ...) X-EXPR ...) ;; element with optional attributes
          | (SYMBOL X-EXPR ...)                            ;; element without attributes
  CONTENT = STRING                                         ;; character data
          | SYMBOL                                         ;; symbolic entity reference
          | INTEGER                                        ;; numeric entity reference
</verbatim>

If the tag symbol of the element is <tt>html</tt>, an HTML5 document
type declaration is written before the element itself.