Check-in [959e085353]
Not logged in

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

Overview
Comment:merge with trunk
Timelines: family | ancestors | descendants | both | wtf-8-experiment
Files: files | file ages | folders
SHA1: 959e0853538bc71a75e6ae7fe919f33bf8ecba97
User & Date: chw 2019-06-18 05:54:39
Context
2019-06-18
09:08
merge with trunk check-in: d58b116c55 user: chw tags: wtf-8-experiment
05:54
merge with trunk check-in: 959e085353 user: chw tags: wtf-8-experiment
05:40
fix encoding issues in twv check-in: 028e69dc34 user: chw tags: trunk
2019-06-17
16:24
merge with trunk check-in: 3d3b2386ea user: chw tags: wtf-8-experiment
Changes

Changes to undroid/build-vanilla-linux32.sh.

1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
  if pkg-config --exists webkit2gtk-4.0 ; then
    make TCL_CFLAGS="-I${PFX_HERE}/include -DUSE_TCL_STUBS=1" \
      TCL_LDFLAGS="-L${PFX_HERE}/lib -ltclstub8.6" || exit 1
    install -d ${PFX_HERE}/lib/twv0.1
    install -m 755 libtwv.so ${PFX_HERE}/lib/twv0.1
  else
    install -d ${PFX_HERE}/lib/twv0.1
    install -m 755 prebuilt/i386/libtwv.so ${PFX_HERE}/lib/twv0.1
  fi
  install -m 644 pkgIndex.tcl ${PFX_HERE}/lib/twv0.1
  touch build-stamp
  echo >&3 "done"
) || fail

echo -n "strip binaries ... "







|







1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
  if pkg-config --exists webkit2gtk-4.0 ; then
    make TCL_CFLAGS="-I${PFX_HERE}/include -DUSE_TCL_STUBS=1" \
      TCL_LDFLAGS="-L${PFX_HERE}/lib -ltclstub8.6" || exit 1
    install -d ${PFX_HERE}/lib/twv0.1
    install -m 755 libtwv.so ${PFX_HERE}/lib/twv0.1
  else
    install -d ${PFX_HERE}/lib/twv0.1
    install -m 755 prebuilt/Linux/i386/libtwv.so ${PFX_HERE}/lib/twv0.1
  fi
  install -m 644 pkgIndex.tcl ${PFX_HERE}/lib/twv0.1
  touch build-stamp
  echo >&3 "done"
) || fail

echo -n "strip binaries ... "

Changes to undroid/build-vanilla-linux64.sh.

1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
  if pkg-config --exists webkit2gtk-4.0 ; then
    make TCL_CFLAGS="-I${PFX_HERE}/include -DUSE_TCL_STUBS=1" \
      TCL_LDFLAGS="-L${PFX_HERE}/lib -ltclstub8.6" || exit 1
    install -d ${PFX_HERE}/lib/twv0.1
    install -m 755 libtwv.so ${PFX_HERE}/lib/twv0.1
  else
    install -d ${PFX_HERE}/lib/twv0.1
    install -m 755 prebuilt/x86_64/libtwv.so ${PFX_HERE}/lib/twv0.1
  fi
  install -m 644 pkgIndex.tcl ${PFX_HERE}/lib/twv0.1
  touch build-stamp
  echo >&3 "done"
) || fail

echo -n "strip binaries ... "







|







1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
  if pkg-config --exists webkit2gtk-4.0 ; then
    make TCL_CFLAGS="-I${PFX_HERE}/include -DUSE_TCL_STUBS=1" \
      TCL_LDFLAGS="-L${PFX_HERE}/lib -ltclstub8.6" || exit 1
    install -d ${PFX_HERE}/lib/twv0.1
    install -m 755 libtwv.so ${PFX_HERE}/lib/twv0.1
  else
    install -d ${PFX_HERE}/lib/twv0.1
    install -m 755 prebuilt/Linux/x86_64/libtwv.so ${PFX_HERE}/lib/twv0.1
  fi
  install -m 644 pkgIndex.tcl ${PFX_HERE}/lib/twv0.1
  touch build-stamp
  echo >&3 "done"
) || fail

echo -n "strip binaries ... "

Changes to undroid/tsb/examples/cheatsheet.tsb.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
..
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
..
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

1 {h3 "Taygete Scrap Book Cheat Sheet"} 2 {h4 "Important (internal) global variables"} 3 {table {{global variable}} [info global {[A-Z]*}]} 4 {#HTML
<dl>
 <dt><b>ID</b></dt>
 <dd>The current input field during evaluation, an integer number.</dd>
 <dt><b>W</b></dt>
 <dd>The Webview for displaying the page.</dd>
 <dt><b>H</b></dt>
 <dd>The history array of input fields, keys are integer numbers starting from 1.</dd>
</dl>} 5 {# current state of history array
table {key value} [array get H]} 6 {h4 "Useful procs in the global namespace"} 7 {lsort [info proc {[a-z]*}]} 8 {#HTML
<dl>
 <dt><code><b>gets</b></code>, <code><b>read</b></code></dt>
 <dd>Overriden, reading from <code>stdin</code> channel yields empty
     string.</dd><br>
 <dt><code><b>h1</b> string</code>, <code><b>h2..h5</b></code></dt>
 <dd>Format a HTML header after the correspondig input field, auto-hide
     the input field.</dd><br>
................................................................................
     channels outputs after the corresponding input field.</dd><br>
 <dt><code><b>table</b> colinfo data</code></dt>
 <dd>Format a HTML table, <code>colinfo</code> gives the number of
     columns, if it's an integer; if negative, the first
     <code>-colinfo</code> items are used in the header row.
     If <code>colinfo</code> is a list, it specifies the column
     headers directly.</dd>
</dl>} 9 {h4 "Useful procs in the tsb namespace"} 10 {lsort [info proc tsb::*]} 11 {#HTML
<dl>
 <dt><code><b>tsb::canvas</b> ?-width w -height h?</code></dt>
 <dd>Creates a <code>canvas</code> emulation implementing enough
     methods for Plotchart, returns a widget command.</dd><br>
 <dt><code><b>tsb::canvascmd</b> cmd ...</code></dt>
 <dd>Implementation of the canvas widget command, supports
     <code>create</code>, <code>delete</code> and other methods plus
................................................................................
     instead.</dd><br>
 <dt><code><b>tsb::save</b> ?filename?</code></dt>
 <dd>Save page to given <code>filename</code>, if file name omitted,
     present file selection.</dd><br>
 <dt><code><b>tsb::wrhtml</b> ?filename?</code></dt>
 <dd>Write page as HTML to given <code>filename</code>, if file name
     omitted, present file selection.</dd>
</dl>} 12 {h4 "Input Fields"} 13 {#HTML
<p>Input fields have a label of the form <code>in(&lt;number&gt;)</code>
where the number is the index in the history array. Arbitrary text can be
entered which however should be valid Tcl code, except the very first line
is <code>#HTML</code> or <code>#MARKDOWN</code>, in which case the
following lines should be valid HTML or Markdown text, respectively.
The input field is evaluated when <code>&lt;Shift-Return&gt;</code>
is pressed.</p>

<p>Depending on the command evaluation the input field is sometimes hidden.
A double click on the corresponding output field(s) makes the input field
visible and thus editable, again.</p>} 14 {h4 "Output Fields"} 15 {#HTML
<p>Each input field has two corresponding output fields which are
visible/non-empty depending on context. One output field receives
preformatted text, either the result or the error message of a
command evaluation. The other output field receives HTML, e.g.
for displaying an image or for the <code>#HTML</code> and
<code>#MARKDOWN</code> formats from the input field.</p>} 16 {tsb::save cheatsheet.tsb}
>
|








|







 







|







 







|










|






1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
..
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
..
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
1 {#HTML
<center><h2>Taygete Scrap Book Cheat Sheet<br><br></h2></center>} 2 {h3 "Important (internal) global variables"} 3 {table {{global variable}} [info global {[A-Z]*}]} 4 {#HTML
<dl>
 <dt><b>ID</b></dt>
 <dd>The current input field during evaluation, an integer number.</dd>
 <dt><b>W</b></dt>
 <dd>The Webview for displaying the page.</dd>
 <dt><b>H</b></dt>
 <dd>The history array of input fields, keys are integer numbers starting from 1.</dd>
</dl>} 5 {# current state of history array
table {key value} [array get H]} 6 {h3 "Useful procs in the global namespace"} 7 {lsort [info proc {[a-z]*}]} 8 {#HTML
<dl>
 <dt><code><b>gets</b></code>, <code><b>read</b></code></dt>
 <dd>Overriden, reading from <code>stdin</code> channel yields empty
     string.</dd><br>
 <dt><code><b>h1</b> string</code>, <code><b>h2..h5</b></code></dt>
 <dd>Format a HTML header after the correspondig input field, auto-hide
     the input field.</dd><br>
................................................................................
     channels outputs after the corresponding input field.</dd><br>
 <dt><code><b>table</b> colinfo data</code></dt>
 <dd>Format a HTML table, <code>colinfo</code> gives the number of
     columns, if it's an integer; if negative, the first
     <code>-colinfo</code> items are used in the header row.
     If <code>colinfo</code> is a list, it specifies the column
     headers directly.</dd>
</dl>} 9 {h3 "Useful procs in the tsb namespace"} 10 {lsort [info proc tsb::*]} 11 {#HTML
<dl>
 <dt><code><b>tsb::canvas</b> ?-width w -height h?</code></dt>
 <dd>Creates a <code>canvas</code> emulation implementing enough
     methods for Plotchart, returns a widget command.</dd><br>
 <dt><code><b>tsb::canvascmd</b> cmd ...</code></dt>
 <dd>Implementation of the canvas widget command, supports
     <code>create</code>, <code>delete</code> and other methods plus
................................................................................
     instead.</dd><br>
 <dt><code><b>tsb::save</b> ?filename?</code></dt>
 <dd>Save page to given <code>filename</code>, if file name omitted,
     present file selection.</dd><br>
 <dt><code><b>tsb::wrhtml</b> ?filename?</code></dt>
 <dd>Write page as HTML to given <code>filename</code>, if file name
     omitted, present file selection.</dd>
</dl>} 12 {h3 "Input Fields"} 13 {#HTML
<p>Input fields have a label of the form <code>in(&lt;number&gt;)</code>
where the number is the index in the history array. Arbitrary text can be
entered which however should be valid Tcl code, except the very first line
is <code>#HTML</code> or <code>#MARKDOWN</code>, in which case the
following lines should be valid HTML or Markdown text, respectively.
The input field is evaluated when <code>&lt;Shift-Return&gt;</code>
is pressed.</p>

<p>Depending on the command evaluation the input field is sometimes hidden.
A double click on the corresponding output field(s) makes the input field
visible and thus editable, again.</p>} 14 {h3 "Output Fields"} 15 {#HTML
<p>Each input field has two corresponding output fields which are
visible/non-empty depending on context. One output field receives
preformatted text, either the result or the error message of a
command evaluation. The other output field receives HTML, e.g.
for displaying an image or for the <code>#HTML</code> and
<code>#MARKDOWN</code> formats from the input field.</p>} 16 {tsb::save cheatsheet.tsb}

Changes to undroid/twv/Makefile.

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
	WEBVIEW_CFLAGS := -DWEBVIEW_GTK=1 -DWEBVIEW_GTK_DL=1 \
	    $(shell pkg-config --cflags gtk+-3.0 webkit2gtk-4.0)
	WEBVIEW_LDFLAGS := -lgtk-3 -lgdk-3 -lglib-2.0
endif

all:	$(TARGET)

$(TARGET): twv.c
	$(CC) -fPIC -shared $(CFLAGS) $(TCL_CFLAGS) $(WEBVIEW_CFLAGS) twv.c \
	    $(LDFLAGS) $(TCL_LDFLAGS) $(WEBVIEW_LDFLAGS) -o $@

clean:
	$(RM) $(TARGET) *~

distclean: clean

.PHONY: clean







|









27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
	WEBVIEW_CFLAGS := -DWEBVIEW_GTK=1 -DWEBVIEW_GTK_DL=1 \
	    $(shell pkg-config --cflags gtk+-3.0 webkit2gtk-4.0)
	WEBVIEW_LDFLAGS := -lgtk-3 -lgdk-3 -lglib-2.0
endif

all:	$(TARGET)

$(TARGET): twv.c webview.h webview_dl.h
	$(CC) -fPIC -shared $(CFLAGS) $(TCL_CFLAGS) $(WEBVIEW_CFLAGS) twv.c \
	    $(LDFLAGS) $(TCL_LDFLAGS) $(WEBVIEW_LDFLAGS) -o $@

clean:
	$(RM) $(TARGET) *~

distclean: clean

.PHONY: clean

Added undroid/twv/prebuilt/Linux/i386/libtwv.so.

cannot compute difference between binary files

Added undroid/twv/prebuilt/Linux/x86_64/libtwv.so.

cannot compute difference between binary files

Deleted undroid/twv/prebuilt/i386/libtwv.so.

cannot compute difference between binary files

Deleted undroid/twv/prebuilt/x86_64/libtwv.so.

cannot compute difference between binary files

Changes to undroid/twv/twv.c.

137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152

153
154
155
156
157
158
159

160
161















































162
163
164
165
166
167
168
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
...
262
263
264
265
266
267
268
269
270
271
272
273
274
275



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311



312
313
314
315
316
317
318
319
320
	int i, ch;
	char *p, *sep = "";

	if (objc < 3) {
	    Tcl_WrongNumArgs(interp, 2, objv, "func ?arg ...?");
            return TCL_ERROR;
        }
	Tcl_ExternalToUtfDString(tw->enc, Tcl_GetString(objv[2]), -1, &ds);
	Tcl_DStringAppend(&ds, "(", 1);
	for (i = 3; i < objc; i++) {
	    Tcl_DStringAppend(&ds, sep, -1);
	    Tcl_DStringAppend(&ds, "\"", 1);
	    Tcl_ExternalToUtfDString(tw->enc, Tcl_GetString(objv[i]), -1, &ds1);
	    p = Tcl_DStringValue(&ds1);
	    while (*p) {
		char buf[8];


		ch = *p & 0xFF;
		if ((ch >= 0x20) && (ch <= 0x80) &&
		    (strchr("<>\\'\"", ch) == NULL)) {
		    buf[0] = ch;
		    Tcl_DStringAppend(&ds, buf, 1);
		} else {

		    sprintf(buf, "\\x%02x", ch);
		    Tcl_DStringAppend(&ds, buf, 4);















































		}
		++p;
	    }
	    Tcl_DStringFree(&ds1);
	    Tcl_DStringAppend(&ds, "\"", 1);
	    sep = ",";
	}
................................................................................
		case AT_info:
		    flags = WEBVIEW_DIALOG_FLAG_INFO;
		    break;
		case AT_warning:
		    flags = WEBVIEW_DIALOG_FLAG_WARNING;
		    break;
		}
		Tcl_ExternalToUtfDString(tw->enc, Tcl_GetString(objv[3]), -1,
					 &ds1);
		Tcl_ExternalToUtfDString(tw->enc, Tcl_GetString(objv[5]), -1,
					 &ds);
	    } else {
		flags = WEBVIEW_DIALOG_FLAG_INFO;
		Tcl_ExternalToUtfDString(tw->enc, Tcl_GetString(objv[3]), -1,
					 &ds1);
		Tcl_ExternalToUtfDString(tw->enc, Tcl_GetString(objv[4]), -1,
					 &ds);
	    }
	    webview_dialog(&tw->w, WEBVIEW_DIALOG_TYPE_ALERT, flags,
			   Tcl_DStringValue(&ds1), Tcl_DStringValue(&ds),
			   NULL, 0);
	    Tcl_DStringFree(&ds1);
	    Tcl_DStringFree(&ds);
................................................................................
	case DLG_choosedir:
	    if (objc != 4) {
		Tcl_WrongNumArgs(interp, 2, objv, "choosedir title");
		return TCL_ERROR;
	    }
	    Tcl_DStringInit(&ds);
	    Tcl_DStringSetLength(&ds, 4096);
	    Tcl_ExternalToUtfDString(tw->enc, Tcl_GetString(objv[3]), -1, &ds1);
	    p = Tcl_DStringValue(&ds);
	    p[0] = '\0';
	    webview_dialog(&tw->w, WEBVIEW_DIALOG_TYPE_OPEN,
			   WEBVIEW_DIALOG_FLAG_DIRECTORY,
			   Tcl_DStringValue(&ds1), NULL, p, 4096);
	    Tcl_DStringFree(&ds1);



	    Tcl_SetResult(interp, p, TCL_VOLATILE);
	    Tcl_DStringFree(&ds);
	    break;

	case DLG_open:
	    if (objc != 4) {
		Tcl_WrongNumArgs(interp, 2, objv, "open title");
		return TCL_ERROR;
	    }
	    Tcl_DStringInit(&ds);
	    Tcl_DStringSetLength(&ds, 4096);
	    Tcl_ExternalToUtfDString(tw->enc, Tcl_GetString(objv[3]), -1, &ds1);
	    p = Tcl_DStringValue(&ds);
	    p[0] = '\0';
	    webview_dialog(&tw->w, WEBVIEW_DIALOG_TYPE_OPEN,
			   WEBVIEW_DIALOG_FLAG_FILE,
			   Tcl_DStringValue(&ds1), NULL, p, 4096);
	    Tcl_DStringFree(&ds1);



	    Tcl_SetResult(interp, p, TCL_VOLATILE);
	    Tcl_DStringFree(&ds);
	    break;

	case DLG_save:
	    if (objc != 4) {
		Tcl_WrongNumArgs(interp, 2, objv, "save title");
		return TCL_ERROR;
	    }
	    Tcl_DStringInit(&ds);
	    Tcl_DStringSetLength(&ds, 4096);
	    Tcl_ExternalToUtfDString(tw->enc, Tcl_GetString(objv[3]), -1, &ds1);
	    p = Tcl_DStringValue(&ds);
	    p[0] = '\0';
	    webview_dialog(&tw->w, WEBVIEW_DIALOG_TYPE_SAVE,
			   WEBVIEW_DIALOG_FLAG_FILE,
			   Tcl_DStringValue(&ds1), NULL, p, 4096);
	    Tcl_DStringFree(&ds1);



	    Tcl_SetResult(interp, p, TCL_VOLATILE);
	    Tcl_DStringFree(&ds);
	    break;
	}
	break;
    }

    case CMD_dispatch: {
	char *script, *p;







|




|



>






|
>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|

|



|

|







 







|






>
>
>

|









|






>
>
>

|









|






>
>
>

|







137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
...
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
...
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
	int i, ch;
	char *p, *sep = "";

	if (objc < 3) {
	    Tcl_WrongNumArgs(interp, 2, objv, "func ?arg ...?");
            return TCL_ERROR;
        }
	Tcl_UtfToExternalDString(tw->enc, Tcl_GetString(objv[2]), -1, &ds);
	Tcl_DStringAppend(&ds, "(", 1);
	for (i = 3; i < objc; i++) {
	    Tcl_DStringAppend(&ds, sep, -1);
	    Tcl_DStringAppend(&ds, "\"", 1);
	    Tcl_UtfToExternalDString(tw->enc, Tcl_GetString(objv[i]), -1, &ds1);
	    p = Tcl_DStringValue(&ds1);
	    while (*p) {
		char buf[8];
		int uch;

		ch = *p & 0xFF;
		if ((ch >= 0x20) && (ch <= 0x80) &&
		    (strchr("<>\\'\"", ch) == NULL)) {
		    buf[0] = ch;
		    Tcl_DStringAppend(&ds, buf, 1);
		} else if (ch < 0xC0) {
doXFmt:
		    sprintf(buf, "\\x%02x", ch);
		    Tcl_DStringAppend(&ds, buf, 4);
		} else if (ch < 0xE0) {
		    if ((p[1] & 0xC0) == 0x80) {
			uch = ((ch & 0x1F) << 6)
			    | (p[1] & 0x3F);
			if (uch <= 0x80) {
			    goto doXFmt;
			}
			p += 2;
			goto doUFmt;
		    }
		    goto doXFmt;
		} else if (ch < 0xF0) {
		    if (((p[1] & 0xC0) == 0x80) && ((p[2] & 0xC0) == 0x80)) {
			uch = ((ch & 0x0F) << 12)
			    | ((p[1] & 0x3F) << 6)
			    | (p[2] & 0x3F);
			if (uch <= 0x7FF) {
			    goto doXFmt;
			}
			p += 3;
			goto doUFmt;
		    }
		    goto doXFmt;
		} else if (ch < 0xF8) {
		    if (((p[1] & 0xC0) == 0x80) && ((p[2] & 0xC0) == 0x80) &&
			((p[3] & 0xC0) == 0x80)) {
			uch = ((ch & 0x07) << 18)
			    | ((p[1] & 0x3F) << 12)
			    | ((p[2] & 0x3F) << 6)
			    | (p[3] & 0x3F);
			if (uch > 0x10FFFF) {
			    goto doXFmt;
			}
			p += 4;
			goto doUFmt;
		    }
		    goto doXFmt;
doUFmt:
		    if (uch > 0xFFFF) {
			sprintf(buf, "\\u%04x",
				((uch - 0x10000) >> 10) | 0xD800);
			Tcl_DStringAppend(&ds, buf, 6);
			uch = ((uch - 0x10000) & 0x3FF) | 0xDC00;
		    }
		    sprintf(buf, "\\u%04x", uch);
		    Tcl_DStringAppend(&ds, buf, 6);
		    continue;
		}
		++p;
	    }
	    Tcl_DStringFree(&ds1);
	    Tcl_DStringAppend(&ds, "\"", 1);
	    sep = ",";
	}
................................................................................
		case AT_info:
		    flags = WEBVIEW_DIALOG_FLAG_INFO;
		    break;
		case AT_warning:
		    flags = WEBVIEW_DIALOG_FLAG_WARNING;
		    break;
		}
		Tcl_UtfToExternalDString(tw->enc, Tcl_GetString(objv[3]), -1,
					 &ds1);
		Tcl_UtfToExternalDString(tw->enc, Tcl_GetString(objv[5]), -1,
					 &ds);
	    } else {
		flags = WEBVIEW_DIALOG_FLAG_INFO;
		Tcl_UtfToExternalDString(tw->enc, Tcl_GetString(objv[3]), -1,
					 &ds1);
		Tcl_UtfToExternalDString(tw->enc, Tcl_GetString(objv[4]), -1,
					 &ds);
	    }
	    webview_dialog(&tw->w, WEBVIEW_DIALOG_TYPE_ALERT, flags,
			   Tcl_DStringValue(&ds1), Tcl_DStringValue(&ds),
			   NULL, 0);
	    Tcl_DStringFree(&ds1);
	    Tcl_DStringFree(&ds);
................................................................................
	case DLG_choosedir:
	    if (objc != 4) {
		Tcl_WrongNumArgs(interp, 2, objv, "choosedir title");
		return TCL_ERROR;
	    }
	    Tcl_DStringInit(&ds);
	    Tcl_DStringSetLength(&ds, 4096);
	    Tcl_UtfToExternalDString(tw->enc, Tcl_GetString(objv[3]), -1, &ds1);
	    p = Tcl_DStringValue(&ds);
	    p[0] = '\0';
	    webview_dialog(&tw->w, WEBVIEW_DIALOG_TYPE_OPEN,
			   WEBVIEW_DIALOG_FLAG_DIRECTORY,
			   Tcl_DStringValue(&ds1), NULL, p, 4096);
	    Tcl_DStringFree(&ds1);
	    Tcl_ExternalToUtfDString(tw->enc, p, -1, &ds1);
	    Tcl_DStringFree(&ds);
	    p = Tcl_DStringValue(&ds1);
	    Tcl_SetResult(interp, p, TCL_VOLATILE);
	    Tcl_DStringFree(&ds1);
	    break;

	case DLG_open:
	    if (objc != 4) {
		Tcl_WrongNumArgs(interp, 2, objv, "open title");
		return TCL_ERROR;
	    }
	    Tcl_DStringInit(&ds);
	    Tcl_DStringSetLength(&ds, 4096);
	    Tcl_UtfToExternalDString(tw->enc, Tcl_GetString(objv[3]), -1, &ds1);
	    p = Tcl_DStringValue(&ds);
	    p[0] = '\0';
	    webview_dialog(&tw->w, WEBVIEW_DIALOG_TYPE_OPEN,
			   WEBVIEW_DIALOG_FLAG_FILE,
			   Tcl_DStringValue(&ds1), NULL, p, 4096);
	    Tcl_DStringFree(&ds1);
	    Tcl_ExternalToUtfDString(tw->enc, p, -1, &ds1);
	    Tcl_DStringFree(&ds);
	    p = Tcl_DStringValue(&ds1);
	    Tcl_SetResult(interp, p, TCL_VOLATILE);
	    Tcl_DStringFree(&ds1);
	    break;

	case DLG_save:
	    if (objc != 4) {
		Tcl_WrongNumArgs(interp, 2, objv, "save title");
		return TCL_ERROR;
	    }
	    Tcl_DStringInit(&ds);
	    Tcl_DStringSetLength(&ds, 4096);
	    Tcl_UtfToExternalDString(tw->enc, Tcl_GetString(objv[3]), -1, &ds1);
	    p = Tcl_DStringValue(&ds);
	    p[0] = '\0';
	    webview_dialog(&tw->w, WEBVIEW_DIALOG_TYPE_SAVE,
			   WEBVIEW_DIALOG_FLAG_FILE,
			   Tcl_DStringValue(&ds1), NULL, p, 4096);
	    Tcl_DStringFree(&ds1);
	    Tcl_ExternalToUtfDString(tw->enc, p, -1, &ds1);
	    Tcl_DStringFree(&ds);
	    p = Tcl_DStringValue(&ds1);
	    Tcl_SetResult(interp, p, TCL_VOLATILE);
	    Tcl_DStringFree(&ds1);
	    break;
	}
	break;
    }

    case CMD_dispatch: {
	char *script, *p;

Changes to undroid/twv/webview.h.

1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646


1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664


1665
1666
1667
1668
1669
1670
1671
    CoTaskMemFree(ws);
  error_result:
    res->lpVtbl->Release(res);
  error_dlg:
    dlg->lpVtbl->Release(dlg);
    return;
  } else if (dlgtype == WEBVIEW_DIALOG_TYPE_ALERT) {
#if 0
    /* MinGW often doesn't contain TaskDialog, we'll use MessageBox for now */
    WCHAR *wtitle = webview_to_utf16(title);
    WCHAR *warg = webview_to_utf16(arg);


    TaskDialog(w->priv.hwnd, NULL, NULL, wtitle, warg, 0, NULL, NULL);
    GlobalFree(warg);
    GlobalFree(wtitle);
#else
    UINT type = MB_OK;
    switch (flags & WEBVIEW_DIALOG_FLAG_ALERT_MASK) {
    case WEBVIEW_DIALOG_FLAG_INFO:
      type |= MB_ICONINFORMATION;
      break;
    case WEBVIEW_DIALOG_FLAG_WARNING:
      type |= MB_ICONWARNING;
      break;
    case WEBVIEW_DIALOG_FLAG_ERROR:
      type |= MB_ICONERROR;
      break;
    }
    MessageBox(w->priv.hwnd, arg, title, type);
#endif


  }
}

WEBVIEW_API void webview_terminate(struct webview *w) { PostQuitMessage(0); }

WEBVIEW_API void webview_exit(struct webview *w) {
  DestroyWindow(w->priv.hwnd);







<
<


>
>

<
<













|

>
>







1636
1637
1638
1639
1640
1641
1642


1643
1644
1645
1646
1647


1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
    CoTaskMemFree(ws);
  error_result:
    res->lpVtbl->Release(res);
  error_dlg:
    dlg->lpVtbl->Release(dlg);
    return;
  } else if (dlgtype == WEBVIEW_DIALOG_TYPE_ALERT) {


    WCHAR *wtitle = webview_to_utf16(title);
    WCHAR *warg = webview_to_utf16(arg);
#if 0
    /* MinGW often doesn't contain TaskDialog, we'll use MessageBox for now */
    TaskDialog(w->priv.hwnd, NULL, NULL, wtitle, warg, 0, NULL, NULL);


#else
    UINT type = MB_OK;
    switch (flags & WEBVIEW_DIALOG_FLAG_ALERT_MASK) {
    case WEBVIEW_DIALOG_FLAG_INFO:
      type |= MB_ICONINFORMATION;
      break;
    case WEBVIEW_DIALOG_FLAG_WARNING:
      type |= MB_ICONWARNING;
      break;
    case WEBVIEW_DIALOG_FLAG_ERROR:
      type |= MB_ICONERROR;
      break;
    }
    MessageBoxW(w->priv.hwnd, warg, wtitle, type);
#endif
    GlobalFree(warg);
    GlobalFree(wtitle);
  }
}

WEBVIEW_API void webview_terminate(struct webview *w) { PostQuitMessage(0); }

WEBVIEW_API void webview_exit(struct webview *w) {
  DestroyWindow(w->priv.hwnd);

Changes to undroid/twv/webview_dl.h.

50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#define WEBVIEW_API extern
extern struct wk_dl wk_dl = { 0 };
#endif

WEBVIEW_API int webview_dl_init(void) {
  static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER;
  static int initialized = 0;
  int i, result;
  static const char *libnames[2] = {
    "libwebkit2gtk-4.0.so.37",
    "libjavascriptcoregtk-4.0.so.18",
  };
  static void *libs[2] = { NULL, NULL };

  if (!initialized) {







|







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#define WEBVIEW_API extern
extern struct wk_dl wk_dl = { 0 };
#endif

WEBVIEW_API int webview_dl_init(void) {
  static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER;
  static int initialized = 0;
  int i;
  static const char *libnames[2] = {
    "libwebkit2gtk-4.0.so.37",
    "libjavascriptcoregtk-4.0.so.18",
  };
  static void *libs[2] = { NULL, NULL };

  if (!initialized) {