Check-in [59100d7e0c]
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: 59100d7e0c6e4029f85578a622408b34f3d491cf
User & Date: chw 2019-06-16 08:20:42
Context
2019-06-17
16:24
merge with trunk check-in: 3d3b2386ea user: chw tags: wtf-8-experiment
2019-06-16
08:20
merge with trunk check-in: 59100d7e0c user: chw tags: wtf-8-experiment
08:19
some fixes in undroidwish/vanilla build scripts check-in: ff246e49df user: chw tags: trunk
2019-06-15
06:11
merge with trunk check-in: 9c76ebe46f user: chw tags: wtf-8-experiment
Changes

Changes to jni/sdl2tk/doc/tk_mac.n.

18
19
20
21
22
23
24



25
26
27
28
29
30
31
...
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
...
137
138
139
140
141
142
143
144


















































145
146
147
148
149
150
151
\fB::tk::mac::ReopenApplication\fR
\fB::tk::mac::OpenDocument \fIfile...\fR
\fB::tk::mac::PrintDocument \fIfile...\fR
\fB::tk::mac::Quit\fR
\fB::tk::mac::OnHide\fR
\fB::tk::mac::OnShow\fR
\fB::tk::mac::ShowHelp\fR




\fB::tk::mac::standardAboutPanel\fR

\fB::tk::mac::useCompatibilityMetrics \fIboolean\fR
\fB::tk::mac::CGAntialiasLimit \fIlimit\fR
\fB::tk::mac::antialiasedtext \fInumber\fR
\fB::tk::mac::useThemedToplevel \fIboolean\fR
................................................................................
.RE
.TP
\fB::tk::mac::PrintDocument \fIfile...\fR
.
If a proc of this name is defined it is the default Apple Event handler for
kAEPrintDocuments,
.QW pdoc ,
the Apple Event sent when your application is asked to print one or more
documents (e.g., via the Print menu item in the Finder).  It works the same
way as \fBtk::mac::OpenDocument\fR in terms of arguments.
.TP
\fB::tk::mac::Quit\fR
.
If a proc of this name is defined it is the default Apple Event handler for
kAEQuitApplication,
.QW quit ,
the Apple Event sent when your application is asked to be quit, e.g. via the
................................................................................
.TP
\fB::tk::mac::ShowHelp\fR
.
Customizes behavior of Apple Help menu; if this procedure is not defined, the
platform-specific standard Help menu item
.QW "YourApp Help"
performs the default Cocoa action of showing the Help Book configured in the
application's Info.plist (or displaying an alert if no Help Book is set).


















































.SH "ADDITIONAL DIALOGS"
.PP
The Aqua/Mac OS X defines additional dialogs that applications should
support.
.TP
\fB::tk::mac::standardAboutPanel\fR
.







>
>
>







 







|
|
<







 







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







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
...
109
110
111
112
113
114
115
116
117

118
119
120
121
122
123
124
...
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
\fB::tk::mac::ReopenApplication\fR
\fB::tk::mac::OpenDocument \fIfile...\fR
\fB::tk::mac::PrintDocument \fIfile...\fR
\fB::tk::mac::Quit\fR
\fB::tk::mac::OnHide\fR
\fB::tk::mac::OnShow\fR
\fB::tk::mac::ShowHelp\fR
\fB::tk::mac::PerformService\fR
\fB::tk::mac::LaunchURL \fIURL...\fR
\fB::tk::mac::GetAppPath\fR

\fB::tk::mac::standardAboutPanel\fR

\fB::tk::mac::useCompatibilityMetrics \fIboolean\fR
\fB::tk::mac::CGAntialiasLimit \fIlimit\fR
\fB::tk::mac::antialiasedtext \fInumber\fR
\fB::tk::mac::useThemedToplevel \fIboolean\fR
................................................................................
.RE
.TP
\fB::tk::mac::PrintDocument \fIfile...\fR
.
If a proc of this name is defined it is the default Apple Event handler for
kAEPrintDocuments,
.QW pdoc ,
the Apple Event sent when your application is asked to print a
document.  It takes a single absolute file path as an argument.

.TP
\fB::tk::mac::Quit\fR
.
If a proc of this name is defined it is the default Apple Event handler for
kAEQuitApplication,
.QW quit ,
the Apple Event sent when your application is asked to be quit, e.g. via the
................................................................................
.TP
\fB::tk::mac::ShowHelp\fR
.
Customizes behavior of Apple Help menu; if this procedure is not defined, the
platform-specific standard Help menu item
.QW "YourApp Help"
performs the default Cocoa action of showing the Help Book configured in the
application's Info.plist (or displaying an alert if no Help Book is
set).
.TP
\fB::tk::mac::PerformService\fR
.
Executes a Tcl procedure called from the macOS 
.QW Services 
menu in the Application menu item. The
.QW Services
menu item allows for inter-application communication; data from one
application, such as selected text, can be sent to another application
for processing, for example to Safari as a search item for Google, or
to TextEdit to be appended to a file. An example of the proc is below,
and should be rewritten in an application script for customization: 
.RS
.PP
.CS
proc ::tk::mac::PerformService {} {
    set data [clipboard get]
    $w insert end $data
}
.CE
.RE
Note that the mechanism for retrieving the data is from the clipboard;
there is no other supported way to obtain the data.  If the Services 
process is not desired, the NSServices keys can be deleted from
the application's Info.plist file. The underlying code supporting this
command also allows the text, entry and ttk::entry widgets to access
services from other applications via the Services menu. The NSPortName
key in Wish's Info.plist file is currently set as
.QW "Wish"
; if a developer changes the name of the Wish executable to something
  else, this key should be modified with the same name.
.TP
\fB::tk::mac::LaunchURL \fIURL...\fR
.
If defined, launches a URL within Tk. This would be used if a Tk
application wants to handle a URL itself, such as displaying data from
an RSS feed, rather than launching a default application to handle the
URL, although it can defined as such. Wish includes a stub URL scheme
of
.QW foo://
in the CFBundleURLSchemes key of its Info.plist file; this should be customized for the specific URL
scheme the developer wants to support. 
.TP
\fB::tk::mac::GetAppPath\fR
.
Returns the current applications's file path.
.TP


.SH "ADDITIONAL DIALOGS"
.PP
The Aqua/Mac OS X defines additional dialogs that applications should
support.
.TP
\fB::tk::mac::standardAboutPanel\fR
.

Changes to jni/sdl2tk/generic/tk.h.

262
263
264
265
266
267
268
269
270

271
272
273
274
275
276
277
278
279
} Tk_ObjCustomOption;

/*
 * Macro to use to fill in "offset" fields of the Tk_OptionSpec structure.
 * Computes number of bytes from beginning of structure to a given field.
 */

#ifdef offsetof
#define Tk_Offset(type, field) ((int) offsetof(type, field))

#else
#define Tk_Offset(type, field) ((int) ((char *) &((type *) 0)->field))
#endif

/*
 * The following two structures are used for error handling. When config
 * options are being modified, the old values are saved in a Tk_SavedOptions
 * structure. If an error occurs, then the contents of the structure can be
 * used to restore all of the old values. The contents of this structure are







<

>
|
|







262
263
264
265
266
267
268

269
270
271
272
273
274
275
276
277
278
279
} Tk_ObjCustomOption;

/*
 * Macro to use to fill in "offset" fields of the Tk_OptionSpec structure.
 * Computes number of bytes from beginning of structure to a given field.
 */


#define Tk_Offset(type, field) ((int) offsetof(type, field))
/* Workaround for platforms missing offsetof(), e.g. VC++ 6.0 */
#ifndef offsetof
#   define offsetof(type, field) ((size_t) ((char *) &((type *) 0)->field))
#endif

/*
 * The following two structures are used for error handling. When config
 * options are being modified, the old values are saved in a Tk_SavedOptions
 * structure. If an error occurs, then the contents of the structure can be
 * used to restore all of the old values. The contents of this structure are

Changes to jni/sdl2tk/generic/tkGrab.c.

888
889
890
891
892
893
894

895
896
897
898
899
900
901
902
903
			}
		    }
		}
		dispPtr->buttonWinPtr = winPtr;
		return 1;
	    }
	} else {

	    if ((eventPtr->xbutton.state & ALL_BUTTONS)
		    == buttonStates[eventPtr->xbutton.button - Button1]) {
		ReleaseButtonGrab(dispPtr);			/* Note 4. */
	    }
	}
	if (winPtr2 != winPtr) {
	    TkChangeEventWindow(eventPtr, winPtr2);
	    Tk_QueueWindowEvent(eventPtr, TCL_QUEUE_HEAD);
	    return 0;						/* Note 3. */







>
|
|







888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
			}
		    }
		}
		dispPtr->buttonWinPtr = winPtr;
		return 1;
	    }
	} else {
	    if (eventPtr->xbutton.button != AnyButton &&
		    ((eventPtr->xbutton.state & ALL_BUTTONS)
		    == buttonStates[eventPtr->xbutton.button - Button1])) {
		ReleaseButtonGrab(dispPtr);			/* Note 4. */
	    }
	}
	if (winPtr2 != winPtr) {
	    TkChangeEventWindow(eventPtr, winPtr2);
	    Tk_QueueWindowEvent(eventPtr, TCL_QUEUE_HEAD);
	    return 0;						/* Note 3. */

Changes to jni/sdl2tk/library/entry.tcl.

70
71
72
73
74
75
76





77
78
79
80
81
82
83
bind Entry <<TraverseIn>> {
    %W selection range 0 end
    %W icursor end
}

# Standard Motif bindings:






bind Entry <1> {
    tk::EntryButton1 %W %x
    %W selection clear
}
bind Entry <B1-Motion> {
    set tk::Priv(x) %x
    tk::EntryMouseSelect %W %x







>
>
>
>
>







70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
bind Entry <<TraverseIn>> {
    %W selection range 0 end
    %W icursor end
}

# Standard Motif bindings:

bind Entry <Map> {
    if {[tk windowingsystem] eq "aqua"} {
    	::tk::RegisterServiceWidget %W
    }
}
bind Entry <1> {
    tk::EntryButton1 %W %x
    %W selection clear
}
bind Entry <B1-Motion> {
    set tk::Priv(x) %x
    tk::EntryMouseSelect %W %x

Changes to jni/sdl2tk/library/text.tcl.

35
36
37
38
39
40
41






42
43
44
45
46
47
48
#-------------------------------------------------------------------------

#-------------------------------------------------------------------------
# The code below creates the default class bindings for text widgets.
#-------------------------------------------------------------------------

# Standard Motif bindings:







bind Text <1> {
    tk::TextButton1 %W %x %y
    %W tag remove sel 0.0 end
}
bind Text <B1-Motion> {
    set tk::Priv(x) %x







>
>
>
>
>
>







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#-------------------------------------------------------------------------

#-------------------------------------------------------------------------
# The code below creates the default class bindings for text widgets.
#-------------------------------------------------------------------------

# Standard Motif bindings:

bind Text <Map> {
    if {[tk windowingsystem] eq "aqua"} {
    	::tk::RegisterServiceWidget %W
    }
}

bind Text <1> {
    tk::TextButton1 %W %x %y
    %W tag remove sel 0.0 end
}
bind Text <B1-Motion> {
    set tk::Priv(x) %x

Changes to jni/sdl2tk/library/tk.tcl.

706
707
708
709
710
711
712
713
714
715
716
717
718
719







720
721
722
723
724
725
726
	if {$length > $maxlen} {
	    set maxlen $length
	}
    }
    return $maxlen
}
 
# For now, turn off the custom mdef proc for the mac:

if {[tk windowingsystem] eq "aqua"} {
    namespace eval ::tk::mac {
	set useCustomMDEF 0
    }
}








if {$::tk::sdltk} {
    # Android hardware keyboard handling
    if {$::tk::android} {
	if {[package versions Borg] ne {}} {
	    package require Borg
	}







|






>
>
>
>
>
>
>







706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
	if {$length > $maxlen} {
	    set maxlen $length
	}
    }
    return $maxlen
}
 
# For now, turn off the custom mdef proc for the Mac:

if {[tk windowingsystem] eq "aqua"} {
    namespace eval ::tk::mac {
	set useCustomMDEF 0
    }
}

# Register to send data to macOS Services
if {[tk windowingsystem] eq "aqua"} {
proc ::tk::RegisterServiceWidget {w} {
    ::tk::mac::registerServiceWidget $w
  }
}

if {$::tk::sdltk} {
    # Android hardware keyboard handling
    if {$::tk::android} {
	if {[package versions Borg] ne {}} {
	    package require Borg
	}

Changes to jni/sdl2tk/library/ttk/entry.tcl.

53
54
55
56
57
58
59







60
61
62
63
64
65
66
#	Judgment call.  If <Meta> happens to be assigned to the Alt key,
#	these could conflict with application accelerators.
#	(Plus, who has a Meta key these days?)
# <Control-Key-t>:
#	Another judgment call.  If anyone misses this, let me know
#	and I'll put it back.
#








## Clipboard events:
#
bind TEntry <<Cut>> 			{ ttk::entry::Cut %W }
bind TEntry <<Copy>> 			{ ttk::entry::Copy %W }
bind TEntry <<Paste>> 			{ ttk::entry::Paste %W }
bind TEntry <<Clear>> 			{ ttk::entry::Clear %W }







>
>
>
>
>
>
>







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#	Judgment call.  If <Meta> happens to be assigned to the Alt key,
#	these could conflict with application accelerators.
#	(Plus, who has a Meta key these days?)
# <Control-Key-t>:
#	Another judgment call.  If anyone misses this, let me know
#	and I'll put it back.
#

## Bindings to register with macOS Services API.
bind T.Entry <Map> {
    if {[tk windowingsystem] eq "aqua"} {
    	::tk::RegisterServiceWidget %W
    }
}

## Clipboard events:
#
bind TEntry <<Cut>> 			{ ttk::entry::Cut %W }
bind TEntry <<Copy>> 			{ ttk::entry::Copy %W }
bind TEntry <<Paste>> 			{ ttk::entry::Paste %W }
bind TEntry <<Clear>> 			{ ttk::entry::Clear %W }

Changes to jni/sdl2tk/macosx/README.

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
..
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
...
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
...
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
...
708
709
710
711
712
713
714



















































	$HOME/Library/Frameworks /Library/Frameworks /System/Library/Frameworks
	(searched in that order).
Given a potential package directory $pkg, Tcl on OSX checks for the file
$pkg/Resources/Scripts/pkgIndex.tcl as well as the usual $pkg/pkgIndex.tcl.
This allows building extensions as frameworks with all script files contained in
the Resources/Scripts directory of the framework.

- [load]able binary extensions can linked as either ordinary shared libraries
(.dylib) or as MachO bundles (since 8.4.10/8.5a3); bundles have the advantage
that they are [load]ed more efficiently from a tcl VFS (no temporary copy to the
native filesystem required).

- The 'deploy' target of macosx/GNUmakefile installs the html manpages into the
standard documentation location in the Tcl/Tk frameworks:
	Tcl.framework/Resources/Documentation/Reference/Tcl
	Tk.framework/Resources/Documentation/Reference/Tk
No nroff manpages are installed by default by the GNUmakefile.

- The Tcl and Tk frameworks can be installed in any of the system's standard
................................................................................

- the env array is different when Wish is started from the Finder (i.e. via
LaunchServices) than when it (or tclsh) is invoked from the Terminal, in
particular PATH may not be what you expect. (Wish started by LaunchServices
inherits loginwindow's environment variables, which are essentially those set in
$HOME/.MacOSX/environment.plist, and are unrelated to those set in your shell).

- TkAqua drawing is antialiased by default, but (outline) linewidth can be used
to control whether a line/shape is drawn antialiased. The antialiasing threshold
is 0 by default (i.e. antialias everything), it can be changed by setting
	set tk::mac::CGAntialiasLimit <limit>
in your script before drawing, in which case lines (or shapes with outlines)
thinner than <limit> pixels will not be antialiased.

- Text antialiasing by default uses the standard OS antialising settings.
Setting the global variable '::tk::mac::antialiasedtext' allows to control text
antialiasing from Tcl: a value of 1 enables AA, 0 disables AA and -1 restores
the default behaviour of respecting the OS settings.

- Scrollbars: There are two scrollbar variants in Aqua, normal & small. The
normal scrollbar has a small dimension of 15, the small variant 11.
Access to the small variant was added in Tk 8.4.2.

- The default metrics of native buttons, radiobuttons, checkboxes and
menubuttons in the Cocoa-based Tk 8.5.7 and later preserve compatibility with
the older Carbon-based implementation, you can turn off the compatibility
metrics to get more native-looking spacing by setting:
	set tk::mac::useCompatibilityMetrics 0

- TkAqua provides access to native OS X images via the Tk native bitmap facility
(including any image file readable by NSImage). A native bitmap name is
interpreted as follows (in order):
    - predefined builtin 32x32 icon name (stop, caution, document, etc)
    - name defined by [tk::mac::iconBitmap]
    - NSImage named image name
    - NSImage url string
................................................................................
dialog window and the others match the contrasting background colors
used in ttk::notebooks and ttk::labelframes which are nested to the
corresponding depth.

5. Building Tcl/Tk on macOS
------------------------------

- At least macOS 10.3 is required to build Tcl and TkX11, and macOS 10.6
is required to build TkAqua.  The XCode application provides everything
needed to build Tk, but it is not necessary to install the full XCode.
It suffices to install the Command Line Tools package, which can be done
by running the command:
xcode-select --install

- Tcl/Tk are most easily built as macOS frameworks via GNUmakefile in
tcl/macosx and tk/macosx (see below for details), but can also be built with the
standard unix configure and make buildsystem in tcl/unix resp. tk/unix as on any
................................................................................
the TCL_SRCROOT and TK_SRCROOT user build settings, by default these are set to
the project-relative paths '../../tcl' and '../../tk', if your source
directories are named differently, e.g. '../../tcl8.6' and '../../tk8.6', you
need to manually change the TCL_SRCROOT and TK_SRCROOT settings by editing your
${USER}.pbxuser file (located inside the Tk.xcodeproj bundle directory) with a
text editor.

- To build universal binaries outside of the Xcode IDE, set CFLAGS as follows:
	export CFLAGS="-arch i386 -arch x86_64 -arch ppc"
This requires macOS 10.4 and Xcode 2.4 (or Xcode 2.2 if -arch x86_64 is
omitted, but _not_ Xcode 2.1) and will work on any architecture (on PowerPC
Tiger you need to add "-isysroot /Developer/SDKs/MacOSX10.4u.sdk").
Note that configure requires CFLAGS to contain a least one architecture that can
be run on the build machine (i.e. ppc on G3/G4, ppc or ppc64 on G5, ppc or i386
on Core and ppc, i386 or x86_64 on Core2/Xeon).
Universal builds of Tcl TEA extensions are also possible with CFLAGS set as
above, they will be [load]able by universal as well as thin binaries of Tcl.

- To enable weak-linking, set the MACOSX_DEPLOYMENT_TARGET environment variable
to the minimal OS version the binaries should be able to run on, e.g:
	export MACOSX_DEPLOYMENT_TARGET=10.6
This requires at least gcc 3.1; with gcc 4 or later, set/add to CFLAGS instead:
	export CFLAGS="-mmacosx-version-min=10.6"
Support for weak-linking was added with 8.4.14/8.5a5.

................................................................................

10.14 supports system appearance changes, and has added a "Dark Mode"
that casts all window frames and menus as black. Tk 8.6.9 has added two
virtual events, <<LightAqua>> and <<DarkAqua>>, to allow you to update
your Tk app's appearance when the system appearance changes. Just bind
your appearance-updating code to these virtual events and you will see
it triggered when the system appearance toggles between dark and light.


























































<
<
<
<
<







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







<
<
|







 







<
<
<
<
<
<
<
<
<
<
<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
55
56
57
58
59
60
61





62
63
64
65
66
67
68
..
78
79
80
81
82
83
84






















85
86
87
88
89
90
91
...
305
306
307
308
309
310
311


312
313
314
315
316
317
318
319
...
364
365
366
367
368
369
370











371
372
373
374
375
376
377
...
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
	$HOME/Library/Frameworks /Library/Frameworks /System/Library/Frameworks
	(searched in that order).
Given a potential package directory $pkg, Tcl on OSX checks for the file
$pkg/Resources/Scripts/pkgIndex.tcl as well as the usual $pkg/pkgIndex.tcl.
This allows building extensions as frameworks with all script files contained in
the Resources/Scripts directory of the framework.






- The 'deploy' target of macosx/GNUmakefile installs the html manpages into the
standard documentation location in the Tcl/Tk frameworks:
	Tcl.framework/Resources/Documentation/Reference/Tcl
	Tk.framework/Resources/Documentation/Reference/Tk
No nroff manpages are installed by default by the GNUmakefile.

- The Tcl and Tk frameworks can be installed in any of the system's standard
................................................................................

- the env array is different when Wish is started from the Finder (i.e. via
LaunchServices) than when it (or tclsh) is invoked from the Terminal, in
particular PATH may not be what you expect. (Wish started by LaunchServices
inherits loginwindow's environment variables, which are essentially those set in
$HOME/.MacOSX/environment.plist, and are unrelated to those set in your shell).























- TkAqua provides access to native OS X images via the Tk native bitmap facility
(including any image file readable by NSImage). A native bitmap name is
interpreted as follows (in order):
    - predefined builtin 32x32 icon name (stop, caution, document, etc)
    - name defined by [tk::mac::iconBitmap]
    - NSImage named image name
    - NSImage url string
................................................................................
dialog window and the others match the contrasting background colors
used in ttk::notebooks and ttk::labelframes which are nested to the
corresponding depth.

5. Building Tcl/Tk on macOS
------------------------------



- macOS 10.6 is required to build TkAqua and TkX11.  The XCode application provides everything needed to build Tk, but it is not necessary to install the full XCode.
It suffices to install the Command Line Tools package, which can be done
by running the command:
xcode-select --install

- Tcl/Tk are most easily built as macOS frameworks via GNUmakefile in
tcl/macosx and tk/macosx (see below for details), but can also be built with the
standard unix configure and make buildsystem in tcl/unix resp. tk/unix as on any
................................................................................
the TCL_SRCROOT and TK_SRCROOT user build settings, by default these are set to
the project-relative paths '../../tcl' and '../../tk', if your source
directories are named differently, e.g. '../../tcl8.6' and '../../tk8.6', you
need to manually change the TCL_SRCROOT and TK_SRCROOT settings by editing your
${USER}.pbxuser file (located inside the Tk.xcodeproj bundle directory) with a
text editor.












- To enable weak-linking, set the MACOSX_DEPLOYMENT_TARGET environment variable
to the minimal OS version the binaries should be able to run on, e.g:
	export MACOSX_DEPLOYMENT_TARGET=10.6
This requires at least gcc 3.1; with gcc 4 or later, set/add to CFLAGS instead:
	export CFLAGS="-mmacosx-version-min=10.6"
Support for weak-linking was added with 8.4.14/8.5a5.

................................................................................

10.14 supports system appearance changes, and has added a "Dark Mode"
that casts all window frames and menus as black. Tk 8.6.9 has added two
virtual events, <<LightAqua>> and <<DarkAqua>>, to allow you to update
your Tk app's appearance when the system appearance changes. Just bind
your appearance-updating code to these virtual events and you will see
it triggered when the system appearance toggles between dark and light.

7.0 Mac Services
~~~~~~~~~~~~~~~~~~~~~~~~~~~

With 8.6.10, Tk supports the Mac's NSServices API, documented at
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/SysServices/introduction.html#//apple_ref/doc/uid/10000101-SW1
and in TIP 536 and Tk's man page. Tk presents a simple,
straightforward API to implement the Services functionality.

The Tk implementation of the NSServices API is intended for standalone
applications, such as one wrapped by the standalone version of Wish
and re-named into a different application.  In particular such an
application would specify its own unique CFBundleIdentifier in its
Info.plist file.  During development, however, if Wish itself is being
used as the receiver, it may be necessary to take some care to ensure
that the correct version of Wish.app is available as a receiver of
NSServices data.

When one macOS app uses NSServices to send data to another app that is
not running, LaunchServices will launch the receiver.  LaunchServices
assumes that the CFBundleIdentifier uniquely identifies an app among
all of the apps installed on a system.  But this may not be the case
for Wish.app if, for example, you have compiled Tk from source at some
time in the past.  In that case the Tk build directory will contain
its own copy of Wish.app that will be visible to LaunchServices.  It
may be necessary when testing your app to take some steps to ensure
that LaunchServices is launching the correct Wish.app.  Instructions
for doing this are provided below.

The command line tool which manages the LaunchServices database has
an amazingly unwieldy path name.  So, first, run this command: 

alias lsregister='/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister'

Then you can reset the LaunchServices database like this:

$ lsregister -kill
$ lsregister -seed

To find out which versions of Wish.app have been located by
LaunchServices, run:

$ lsregister -dump | grep path | grep Wish

If more than one version of Wish is showing up in this list, eliminate
all of the unintended targets by running

lsregister -u /path/to/bad/Wish.app

Continue this until only the correct version of Wish shows up in the
list.

Changes to jni/sdl2tk/macosx/Wish-Info.plist.in.

32
33
34
35
36
37
38













39
40
41
42
43
44
45
..
74
75
76
77
78
79
80







81














82
				<string>TEXT</string>
				<string>****</string>
			</array>
			<key>CFBundleTypeRole</key>
			<string>Viewer</string>
		</dict>
	</array>













	<key>CFBundleExecutable</key>
	<string>Wish</string>
	<key>CFBundleGetInfoString</key>
	<string>Wish Shell @TK_VERSION@@TK_PATCH_LEVEL@,
	Copyright © 1989-@TK_YEAR@ Tcl Core Team,
	Copyright © 1989-@TK_YEAR@ Contributors,
	Copyright © 2011-@TK_YEAR@ Kevin Walzer/WordTech
................................................................................
	<true/>
	<key>NSAppleScriptEnabled</key>
	<true/>
	<key>OSAScriptingDefinition</key>
	<string>Wish.sdef</string>
	<key>NSHighResolutionCapable</key>
	<string>True</string>







</dict>














</plist>







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







 







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

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
..
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
				<string>TEXT</string>
				<string>****</string>
			</array>
			<key>CFBundleTypeRole</key>
			<string>Viewer</string>
		</dict>
	</array>
 <key>CFBundleURLTypes</key>
  <array>
    <dict>
     <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>foo</string>
        </array>
        <key>CFBundleURLName</key>
        <string>Get Foo</string>
    </dict>
  </array>
	<key>CFBundleExecutable</key>
	<string>Wish</string>
	<key>CFBundleGetInfoString</key>
	<string>Wish Shell @TK_VERSION@@TK_PATCH_LEVEL@,
	Copyright © 1989-@TK_YEAR@ Tcl Core Team,
	Copyright © 1989-@TK_YEAR@ Contributors,
	Copyright © 2011-@TK_YEAR@ Kevin Walzer/WordTech
................................................................................
	<true/>
	<key>NSAppleScriptEnabled</key>
	<true/>
	<key>OSAScriptingDefinition</key>
	<string>Wish.sdef</string>
	<key>NSHighResolutionCapable</key>
	<string>True</string>
	 <key>NSServices</key>
	 <array>
	   <dict>
            <key>NSMenuItem</key>
            <dict>
                <key>default</key>
                <string>Wish: Display Test Data</string>
            </dict>
            <key>NSMessage</key>
            <string>provideService</string>
            <key>NSPortName</key>
            <string>Wish</string>

            <key>NSSendTypes</key>
            <array>
                <string>NSStringPboardType</string>
                <string>NSPasteboardTypeString</string>
            </array>
        </dict>
    </array>

</dict>
</plist>

Changes to jni/sdl2tk/macosx/Wish.sdef.

28
29
30
31
32
33
34








35
36
37
		<command name="do script" code="miscdosc" description="Execute a Tcl script.">
			<direct-parameter description="Script to execute" type="text">
				<type type="text"/>
			</direct-parameter>
			<result description="Result">
				<type type="text"/>
			</result>








		</command>
	</suite>
</dictionary>







>
>
>
>
>
>
>
>



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
		<command name="do script" code="miscdosc" description="Execute a Tcl script.">
			<direct-parameter description="Script to execute" type="text">
				<type type="text"/>
			</direct-parameter>
			<result description="Result">
				<type type="text"/>
			</result>
		</command>
		<command name="open location" code="GURLGURL" description="Open a URL.">
		<direct-parameter description="URL" type="text">
			<type type="text"/>
		</direct-parameter>
		<result description="Result">
			<type type="text"/>
		</result>
		</command>
	</suite>
</dictionary>

Changes to jni/sdl2tk/macosx/tkMacOSXHLEvents.c.

122
123
124
125
126
127
128






129

130








131
132
133
134
135
136
137
...
242
243
244
245
246
247
248




















249
250
251
252
253
254
255
...
405
406
407
408
409
410
411
412
413
414
415
416
417





418
419
420
421
422
423
424
{
    tkMacOSXProcessFiles(event, replyEvent, _eventInterp, "::tk::mac::OpenDocument");
}

- (void) handlePrintDocumentsEvent: (NSAppleEventDescriptor *)event
    withReplyEvent: (NSAppleEventDescriptor *)replyEvent
{






    tkMacOSXProcessFiles(event, replyEvent, _eventInterp, "::tk::mac::PrintDocument");

}









- (void) handleDoScriptEvent: (NSAppleEventDescriptor *)event
    withReplyEvent: (NSAppleEventDescriptor *)replyEvent
{
    OSStatus err;
    const AEDesc *theDesc = nil;
    DescType type = 0, initialType = 0;
................................................................................
			  result, reslen);
	    AEPutParamPtr((AppleEvent*)[replyEvent aeDesc], keyErrorNumber, typeSInt32,
			  (Ptr) &tclErr,sizeof(int));
	}
    }
    return;
}




















@end

#pragma mark -

/*
 *----------------------------------------------------------------------
 *
................................................................................
	    forEventClass:kCoreEventClass andEventID:kAEShowPreferences];

	[aeManager setEventHandler:NSApp
	    andSelector:@selector(handleOpenDocumentsEvent:withReplyEvent:)
	    forEventClass:kCoreEventClass andEventID:kAEOpenDocuments];

	[aeManager setEventHandler:NSApp
	    andSelector:@selector(handleOpenDocumentsEvent:withReplyEvent:)
	    forEventClass:kCoreEventClass andEventID:kAEPrintDocuments];

	[aeManager setEventHandler:NSApp
	    andSelector:@selector(handleDoScriptEvent:withReplyEvent:)
	    forEventClass:kAEMiscStandards andEventID:kAEDoScript];





    }
}
 
/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXDoHLEvent --







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







 







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







 







|





>
>
>
>
>







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
...
257
258
259
260
261
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
...
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
{
    tkMacOSXProcessFiles(event, replyEvent, _eventInterp, "::tk::mac::OpenDocument");
}

- (void) handlePrintDocumentsEvent: (NSAppleEventDescriptor *)event
    withReplyEvent: (NSAppleEventDescriptor *)replyEvent
{
    
    NSString* file = [[event paramDescriptorForKeyword:keyDirectObject]
			 stringValue];
    const char *printFile=[file UTF8String];
    Tcl_DString print;
    Tcl_DStringInit(&print);
    if (Tcl_FindCommand(_eventInterp, "::tk::mac::PrintDocument", NULL, 0)) {
	Tcl_DStringAppend(&print, "::tk::mac::PrintDocument", -1);
    } 
    Tcl_DStringAppendElement(&print, printFile);
    int  tclErr = Tcl_EvalEx(_eventInterp, Tcl_DStringValue(&print),
			     Tcl_DStringLength(&print), TCL_EVAL_GLOBAL);
    if (tclErr!= TCL_OK) {
	Tcl_BackgroundException(_eventInterp, tclErr);
    }
}


- (void) handleDoScriptEvent: (NSAppleEventDescriptor *)event
    withReplyEvent: (NSAppleEventDescriptor *)replyEvent
{
    OSStatus err;
    const AEDesc *theDesc = nil;
    DescType type = 0, initialType = 0;
................................................................................
			  result, reslen);
	    AEPutParamPtr((AppleEvent*)[replyEvent aeDesc], keyErrorNumber, typeSInt32,
			  (Ptr) &tclErr,sizeof(int));
	}
    }
    return;
}

- (void)handleURLEvent:(NSAppleEventDescriptor*)event
        withReplyEvent:(NSAppleEventDescriptor*)replyEvent
{
    NSString* url = [[event paramDescriptorForKeyword:keyDirectObject]
                        stringValue];
    const char *cURL=[url UTF8String];
    Tcl_DString launch;
    Tcl_DStringInit(&launch);
    if (Tcl_FindCommand(_eventInterp, "::tk::mac::LaunchURL", NULL, 0)) {
	Tcl_DStringAppend(&launch, "::tk::mac::LaunchURL", -1);
    } 
    Tcl_DStringAppendElement(&launch, cURL);
    int  tclErr = Tcl_EvalEx(_eventInterp, Tcl_DStringValue(&launch),
			     Tcl_DStringLength(&launch), TCL_EVAL_GLOBAL);
    if (tclErr!= TCL_OK) {
	Tcl_BackgroundException(_eventInterp, tclErr);
         }
    }

@end

#pragma mark -

/*
 *----------------------------------------------------------------------
 *
................................................................................
	    forEventClass:kCoreEventClass andEventID:kAEShowPreferences];

	[aeManager setEventHandler:NSApp
	    andSelector:@selector(handleOpenDocumentsEvent:withReplyEvent:)
	    forEventClass:kCoreEventClass andEventID:kAEOpenDocuments];

	[aeManager setEventHandler:NSApp
	    andSelector:@selector(handlePrintDocumentsEvent:withReplyEvent:)
	    forEventClass:kCoreEventClass andEventID:kAEPrintDocuments];

	[aeManager setEventHandler:NSApp
	    andSelector:@selector(handleDoScriptEvent:withReplyEvent:)
	    forEventClass:kAEMiscStandards andEventID:kAEDoScript];

	[aeManager setEventHandler:NSApp
	    andSelector:@selector(handleURLEvent:withReplyEvent:)
	    forEventClass:kInternetEventClass andEventID:kAEGetURL];
	
    }
}
 
/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXDoHLEvent --

Changes to jni/sdl2tk/macosx/tkMacOSXInit.c.

112
113
114
115
116
117
118

119
120
121
122
123
124
125
...
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
...
389
390
391
392
393
394
395


396
397









398
399
400
401
402
403
404
...
431
432
433
434
435
436
437


















































438
439
440
441
442
443
444
     */
    TkMacOSXUseAntialiasedText(_eventInterp, -1);
    TkMacOSXInitCGDrawing(_eventInterp, TRUE, 0);
}

-(void)applicationDidFinishLaunching:(NSNotification *)notification
{

    /*
     * It is not safe to force activation of the NSApp until this method is
     * called. Activating too early can cause the menu bar to be unresponsive.
     */

    [NSApp activateIgnoringOtherApps: YES];

................................................................................
	 * If the root window is mapped before the App has finished launching
	 * it will open off screen (see ticket 56a1823c73).  To avoid this we
	 * ask Tk to process an event with no wait.  We expect Tcl_DoOneEvent
	 * to wait until the Mac event loop has been created and then return
	 * immediately since the queue is empty.
	 */

	Tcl_DoOneEvent(TCL_WINDOW_EVENTS| TCL_DONT_WAIT);

	/*
	 * If we don't have a TTY and stdin is a special character file of
	 * length 0, (e.g. /dev/null, which is what Finder sets when double
	 * clicking Wish) then use the Tk based console interpreter.
	 */

................................................................................
    if (scriptPath[0] != '\0') {
	Tcl_SetVar2(interp, "auto_path", NULL, scriptPath,
		TCL_GLOBAL_ONLY|TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
    }

    Tcl_CreateObjCommand(interp, "::tk::mac::standardAboutPanel",
	    TkMacOSXStandardAboutPanelObjCmd, NULL, NULL);


    Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap",
	    TkMacOSXIconBitmapObjCmd, NULL, NULL);










    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------
 *
................................................................................
	p = strrchr(name, '/');
	if (p != NULL) {
	    name = p+1;
	}
    }
    Tcl_DStringAppend(namePtr, name, -1);
}


















































 
/*
 *----------------------------------------------------------------------
 *
 * TkpDisplayWarning --
 *
 *	This routines is called from Tk_Main to display warning messages that







>







 







|







 







>
>


>
>
>
>
>
>
>
>
>







 







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







112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
...
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
...
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
...
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
     */
    TkMacOSXUseAntialiasedText(_eventInterp, -1);
    TkMacOSXInitCGDrawing(_eventInterp, TRUE, 0);
}

-(void)applicationDidFinishLaunching:(NSNotification *)notification
{

    /*
     * It is not safe to force activation of the NSApp until this method is
     * called. Activating too early can cause the menu bar to be unresponsive.
     */

    [NSApp activateIgnoringOtherApps: YES];

................................................................................
	 * If the root window is mapped before the App has finished launching
	 * it will open off screen (see ticket 56a1823c73).  To avoid this we
	 * ask Tk to process an event with no wait.  We expect Tcl_DoOneEvent
	 * to wait until the Mac event loop has been created and then return
	 * immediately since the queue is empty.
	 */

	Tcl_DoOneEvent(TCL_WINDOW_EVENTS | TCL_DONT_WAIT);

	/*
	 * If we don't have a TTY and stdin is a special character file of
	 * length 0, (e.g. /dev/null, which is what Finder sets when double
	 * clicking Wish) then use the Tk based console interpreter.
	 */

................................................................................
    if (scriptPath[0] != '\0') {
	Tcl_SetVar2(interp, "auto_path", NULL, scriptPath,
		TCL_GLOBAL_ONLY|TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
    }

    Tcl_CreateObjCommand(interp, "::tk::mac::standardAboutPanel",
	    TkMacOSXStandardAboutPanelObjCmd, NULL, NULL);
    Tcl_CreateObjCommand(interp, "::tk::mac::registerServiceWidget",
	    TkMacOSXRegisterServiceWidgetObjCmd, NULL, NULL);
    Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap",
	    TkMacOSXIconBitmapObjCmd, NULL, NULL);
    Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath", TkMacOSXGetAppPath,(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);

    /*
     * Initialize the NSServices object here. Apple's docs say to do this
     * in applicationDidFinishLaunching, but the Tcl interpreter is not 
     * initialized until this function call. 
     */
    
    TkMacOSXServices_Init(interp);

    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------
 *
................................................................................
	p = strrchr(name, '/');
	if (p != NULL) {
	    name = p+1;
	}
    }
    Tcl_DStringAppend(namePtr, name, -1);
}

/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXGetAppPath --
 *
 *	Returns the path of the Wish application bundle.
 *
 * Results:
 *	Returns the application path.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */
int TkMacOSXGetAppPath(
		       ClientData cd,
		       Tcl_Interp *ip,
		       int objc,
		       Tcl_Obj *CONST objv[])
{

    CFURLRef mainBundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle());

  
    /* 
     * Convert the URL reference into a string reference. 
     */
  
    CFStringRef appPath = CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle);
 
    /* 
     * Get the system encoding method. 
     */
  
    CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
 
    /* 
     * Convert the string reference into a C string. 
     */
  
    char *path = (char *) CFStringGetCStringPtr(appPath, encodingMethod);

    Tcl_SetResult(ip, path, NULL);

    CFRelease(mainBundleURL);
    CFRelease(appPath);
    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------
 *
 * TkpDisplayWarning --
 *
 *	This routines is called from Tk_Main to display warning messages that

Changes to jni/sdl2tk/macosx/tkMacOSXPrivate.h.

230
231
232
233
234
235
236
237




238
239
240
241
242
243
244
...
324
325
326
327
328
329
330


331
332
333
334
335
336
337
...
420
421
422
423
424
425
426


427
428
429
430
431
432
433
434
435
MODULE_SCOPE int	TkMacOSXStandardAboutPanelObjCmd(ClientData clientData,
			    Tcl_Interp *interp, int objc,
			    Tcl_Obj *const objv[]);
MODULE_SCOPE int	TkMacOSXIconBitmapObjCmd(ClientData clientData,
			    Tcl_Interp *interp, int objc,
			    Tcl_Obj *const objv[]);
MODULE_SCOPE void       TkMacOSXDrawSolidBorder(Tk_Window tkwin, GC gc,
						int inset, int thickness);





#pragma mark Private Objective-C Classes

#define VISIBILITY_HIDDEN __attribute__((visibility("hidden")))

enum { tkMainMenu = 1, tkApplicationMenu, tkWindowsMenu, tkHelpMenu};

................................................................................
		     withReplyEvent:   (NSAppleEventDescriptor *)replyEvent;
- (void) handleOpenDocumentsEvent:     (NSAppleEventDescriptor *)event
		   withReplyEvent:     (NSAppleEventDescriptor *)replyEvent;
- (void) handlePrintDocumentsEvent:    (NSAppleEventDescriptor *)event
		   withReplyEvent:     (NSAppleEventDescriptor *)replyEvent;
- (void) handleDoScriptEvent:          (NSAppleEventDescriptor *)event
		   withReplyEvent:     (NSAppleEventDescriptor *)replyEvent;


@end

VISIBILITY_HIDDEN
@interface TKContentView : NSView <NSTextInput>
{
@private
    NSString *privateWorkingText;
................................................................................
 */

@interface NSApplication(TKMenu)
- (void) setAppleMenu: (NSMenu *) menu;
@end

#endif /* _TKMACPRIV */



/*
 * Local Variables:
 * mode: objc
 * c-basic-offset: 4
 * fill-column: 79
 * coding: utf-8
 * End:
 */







|
>
>
>
>







 







>
>







 







>
>









230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
...
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
...
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
MODULE_SCOPE int	TkMacOSXStandardAboutPanelObjCmd(ClientData clientData,
			    Tcl_Interp *interp, int objc,
			    Tcl_Obj *const objv[]);
MODULE_SCOPE int	TkMacOSXIconBitmapObjCmd(ClientData clientData,
			    Tcl_Interp *interp, int objc,
			    Tcl_Obj *const objv[]);
MODULE_SCOPE void       TkMacOSXDrawSolidBorder(Tk_Window tkwin, GC gc,
			    int inset, int thickness);
MODULE_SCOPE int 	TkMacOSXServices_Init(Tcl_Interp *interp);
MODULE_SCOPE int	TkMacOSXRegisterServiceWidgetObjCmd(ClientData clientData,
			    Tcl_Interp *interp, int objc,
			    Tcl_Obj *const objv[]);

#pragma mark Private Objective-C Classes

#define VISIBILITY_HIDDEN __attribute__((visibility("hidden")))

enum { tkMainMenu = 1, tkApplicationMenu, tkWindowsMenu, tkHelpMenu};

................................................................................
		     withReplyEvent:   (NSAppleEventDescriptor *)replyEvent;
- (void) handleOpenDocumentsEvent:     (NSAppleEventDescriptor *)event
		   withReplyEvent:     (NSAppleEventDescriptor *)replyEvent;
- (void) handlePrintDocumentsEvent:    (NSAppleEventDescriptor *)event
		   withReplyEvent:     (NSAppleEventDescriptor *)replyEvent;
- (void) handleDoScriptEvent:          (NSAppleEventDescriptor *)event
		   withReplyEvent:     (NSAppleEventDescriptor *)replyEvent;
- (void)handleURLEvent:                (NSAppleEventDescriptor*)event
	           withReplyEvent:     (NSAppleEventDescriptor*)replyEvent;
@end

VISIBILITY_HIDDEN
@interface TKContentView : NSView <NSTextInput>
{
@private
    NSString *privateWorkingText;
................................................................................
 */

@interface NSApplication(TKMenu)
- (void) setAppleMenu: (NSMenu *) menu;
@end

#endif /* _TKMACPRIV */

int TkMacOSXGetAppPath(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]);

/*
 * Local Variables:
 * mode: objc
 * c-basic-offset: 4
 * fill-column: 79
 * coding: utf-8
 * End:
 */

Added jni/sdl2tk/macosx/tkMacOSXServices.c.



































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
/*
 * tkMacOSXServices.c --
 *
 *	This file allows the integration of Tk and the Cocoa NSServices API.
 *
 * Copyright (c) 2010-2019 Kevin Walzer/WordTech Communications LLC.
 * Copyright (c) 2010 Adrian Robert.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

#include <CoreServices/CoreServices.h>
#include <tkInt.h>
#include <tkMacOSXInt.h>

static Tcl_Interp *ServicesInterp;

/*
 * Event proc which calls the PerformService procedure
 */

static int
ServicesEventProc(
    Tcl_Event *event,
    int flags)
{
    Tcl_GlobalEval(ServicesInterp, "::tk::mac::PerformService");
    return 1;
}
 
/*
 * Class declarations for TkService class.
 */

@interface TkService : NSView {

}

+ (void) initialize;
- (void)provideService:(NSPasteboard *)pboard userData:(NSString *)data error:(NSString **)error;
- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType;
- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard  types:(NSArray *)types;

@end
 
/*
 * Class methods.
 */

@implementation TkService

+ (void) initialize {
    NSArray *sendTypes = [NSArray arrayWithObjects:@"NSStringPboardType",
				  @"NSPasteboardTypeString", nil];
    [NSApp registerServicesMenuSendTypes:sendTypes returnTypes:sendTypes];
    NSUpdateDynamicServices();
    return;
}


- (id)validRequestorForSendType:(NSString *)sendType
		     returnType:(NSString *)returnType
{
    if ([sendType isEqualToString:@"NSStringPboardType"] ||
	[sendType isEqualToString:@"NSPasteboardTypeString"]) {
	return self;
    }
    return [super validRequestorForSendType:sendType returnType:returnType];
}

/*
 * Make sure the view accepts events.
 */

- (BOOL)acceptsFirstResponder
{
    return YES;
}
- (BOOL)becomeFirstResponder
{
    return YES;
}

/*
 * Get selected text, copy to pasteboard.
 */

- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard
			     types:(NSArray *)types
{
    NSArray *typesDeclared = nil;
    NSString *pboardType = nil;

    for (NSString *typeString in types) {
	if ([typeString isEqualToString:@"NSStringPboardType"] ||
	    [typeString isEqualToString:@"NSPasteboardTypeString"]) {
	    typesDeclared = [NSArray arrayWithObject:typeString];
	    pboardType = typeString;
	    break;
	}
    }
    if (!typesDeclared) {
	return NO;
    }
    Tcl_Eval(ServicesInterp, "selection get");

    char *copystring = Tcl_GetString(Tcl_GetObjResult(ServicesInterp));
    NSString *writestring = [NSString stringWithUTF8String:copystring];

    [pboard declareTypes:typesDeclared owner:nil];
    return [pboard setString:writestring forType:pboardType];
}

/*
 * This is the method that actually calls the Tk service; this is the method
 * that must be defined in info.plist.
 */

- (void)provideService:(NSPasteboard *)pboard
	      userData:(NSString *)data
		 error:(NSString **)error
{
    NSString *pboardString, *pboardType;
    NSArray *types = [pboard types];
    Tcl_Event *event;

    /*
     * Get string from private pasteboard, write to general pasteboard to make
     * available to Tcl service.
     */

    for (NSString *typeString in types) {
	if ([typeString isEqualToString:@"NSStringPboardType"] ||
	    [typeString isEqualToString:@"NSPasteboardTypeString"]) {
	    pboardString = [pboard stringForType:typeString];
	    pboardType = typeString;
	    break;
	}
    }
    if (pboardString) {
	NSPasteboard *generalpasteboard = [NSPasteboard generalPasteboard];
	[generalpasteboard declareTypes:[NSArray arrayWithObjects:pboardType, nil]
				  owner:nil];
	[generalpasteboard setString:pboardString forType:pboardType];
	event = ckalloc(sizeof(Tcl_Event));
	event->proc = ServicesEventProc;
	Tcl_QueueEvent((Tcl_Event *)event, TCL_QUEUE_TAIL);
    }
}
@end
 
/*
 * Register a specific widget to access the Services menu.
 */

int
TkMacOSXRegisterServiceWidgetObjCmd(
    ClientData cd,
    Tcl_Interp *ip,
    int objc,
    Tcl_Obj *CONST objv[])
{
    /*
     * Need proper number of args.
     */

    if (objc != 2) {
	Tcl_WrongNumArgs(ip, 1, objv, "path?");
	return TCL_ERROR;
    }

    /*
     * Get the object that holds this Tk Window...
     */

    Rect bounds;
    NSRect frame;
    Tk_Window path =
	    Tk_NameToWindow(ip, Tcl_GetString(objv[1]), Tk_MainWindow(ip));

    if (path == NULL) {
	return TCL_ERROR;
    }

    Tk_MakeWindowExist(path);
    Tk_MapWindow(path);
    Drawable d = Tk_WindowId(path);

    /*
     * Get NSView from Tk window and add subview.
     */

    TkService *serviceview = [[TkService alloc] init];
    NSView *view = TkMacOSXGetRootControl(d);

    if ([serviceview superview] != view) {
	[view addSubview:serviceview];
    }
    TkMacOSXWinBounds((TkWindow*)path, &bounds);

    /*
     * Hack to make sure subview is set to take up entire geometry of window.
     */

    frame = NSMakeRect(bounds.left, bounds.top, 100000, 100000);
    frame.origin.y = 0;
    if (!NSEqualRects(frame, [serviceview frame])) {
    	[serviceview setFrame:frame];
    }
    [serviceview release];
    return TCL_OK;
}

/*
 * Initalize the package in the Tcl interpreter, create Tcl commands.
 */

int
TkMacOSXServices_Init(
    Tcl_Interp *interp)
{
    /*
     * Initialize instance of TclServices to provide service functionality.
     */

    TkService *service = [[TkService alloc] init];

    ServicesInterp = interp;
    [NSApp setServicesProvider:service];
    return TCL_OK;
}
 
/*
 * Local Variables:
 * mode: objc
 * c-basic-offset: 4
 * fill-column: 79
 * coding: utf-8
 * End:
 */

Changes to jni/sdl2tk/macosx/tkMacOSXWm.c.

2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812

2813
2814
2815
2816
2817
2818
2819
	Tk_UnmapWindow(frameWin);
	if (wmPtr == NULL) {
	    TkWmNewWindow(winPtr);
	    if (winPtr->window == None) {
		Tk_MakeWindowExist((Tk_Window) winPtr);
		macWin = (MacDrawable *) winPtr->window;
	    }
	    TkWmMapWindow(winPtr);
	    Tk_UnmapWindow(frameWin);
	}
	wmPtr = winPtr->wmInfoPtr;
	winPtr->flags &= ~TK_MAPPED;
	macWin->toplevel->referenceCount--;
	macWin->toplevel = macWin;
	macWin->toplevel->referenceCount++;
	RemapWindows(winPtr, macWin);
	winPtr->flags |=
		(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED);
	TkMapTopFrame(frameWin);

    } else if (Tk_IsTopLevel(frameWin)) {
	/* Already managed by wm - ignore it */
    }
    return TCL_OK;
}
 
/*







<
<










>







2794
2795
2796
2797
2798
2799
2800


2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
	Tk_UnmapWindow(frameWin);
	if (wmPtr == NULL) {
	    TkWmNewWindow(winPtr);
	    if (winPtr->window == None) {
		Tk_MakeWindowExist((Tk_Window) winPtr);
		macWin = (MacDrawable *) winPtr->window;
	    }


	}
	wmPtr = winPtr->wmInfoPtr;
	winPtr->flags &= ~TK_MAPPED;
	macWin->toplevel->referenceCount--;
	macWin->toplevel = macWin;
	macWin->toplevel->referenceCount++;
	RemapWindows(winPtr, macWin);
	winPtr->flags |=
		(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED);
	TkMapTopFrame(frameWin);
	TkWmMapWindow(winPtr);
    } else if (Tk_IsTopLevel(frameWin)) {
	/* Already managed by wm - ignore it */
    }
    return TCL_OK;
}
 
/*

Changes to jni/sdl2tk/unix/Makefile.in.

394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
...
521
522
523
524
525
526
527

528
529
530
531
532
533
534
....
1313
1314
1315
1316
1317
1318
1319



1320
1321
1322
1323
1324
1325
1326
AQUA_OBJS = tkMacOSXBitmap.o tkMacOSXButton.o tkMacOSXClipboard.o \
	tkMacOSXColor.o tkMacOSXConfig.o tkMacOSXCursor.o tkMacOSXDebug.o \
	tkMacOSXDialog.o tkMacOSXDraw.o tkMacOSXEmbed.o tkMacOSXEntry.o \
	tkMacOSXEvent.o tkMacOSXFont.o tkMacOSXHLEvents.o tkMacOSXImage.o \
	tkMacOSXInit.o tkMacOSXKeyboard.o tkMacOSXKeyEvent.o tkMacOSXMenu.o \
	tkMacOSXMenubutton.o tkMacOSXMenus.o tkMacOSXMouseEvent.o \
	tkMacOSXNotify.o tkMacOSXRegion.o tkMacOSXScrlbr.o tkMacOSXSend.o \
	tkMacOSXSubwindows.o tkMacOSXWindowEvent.o \
	tkMacOSXWm.o tkMacOSXXStubs.o \
	tkFileFilter.o tkMacWinMenu.o tkPointer.o tkUnix3d.o tkUnixScale.o \
	xcolors.o xdraw.o xgc.o ximage.o xutil.o \
	ttkMacOSXTheme.o

AQUA_TKTEST_OBJS = tkMacOSXTest.o

................................................................................
	$(MAC_OSX_DIR)/tkMacOSXFont.c $(MAC_OSX_DIR)/tkMacOSXHLEvents.c \
	$(MAC_OSX_DIR)/tkMacOSXImage.c \
	$(MAC_OSX_DIR)/tkMacOSXInit.c $(MAC_OSX_DIR)/tkMacOSXKeyboard.c \
	$(MAC_OSX_DIR)/tkMacOSXKeyEvent.c $(MAC_OSX_DIR)/tkMacOSXMenu.c \
	$(MAC_OSX_DIR)/tkMacOSXMenubutton.c $(MAC_OSX_DIR)/tkMacOSXMenus.c \
	$(MAC_OSX_DIR)/tkMacOSXMouseEvent.c $(MAC_OSX_DIR)/tkMacOSXNotify.c \
	$(MAC_OSX_DIR)/tkMacOSXRegion.c $(MAC_OSX_DIR)/tkMacOSXScrlbr.c \

	$(MAC_OSX_DIR)/tkMacOSXSend.c $(MAC_OSX_DIR)/tkMacOSXSubwindows.c \
	$(MAC_OSX_DIR)/tkMacOSXTest.c $(MAC_OSX_DIR)/tkMacOSXWindowEvent.c \
	$(MAC_OSX_DIR)/tkMacOSXWm.c $(MAC_OSX_DIR)/tkMacOSXXStubs.c \
	$(GENERIC_DIR)/tkFileFilter.c $(GENERIC_DIR)/tkMacWinMenu.c \
	$(GENERIC_DIR)/tkPointer.c $(UNIX_DIR)/tkUnix3d.c \
	$(UNIX_DIR)/tkUnixScale.c $(XLIB_DIR)/xcolors.c $(XLIB_DIR)/xdraw.c \
	$(XLIB_DIR)/xgc.c $(XLIB_DIR)/ximage.c $(XLIB_DIR)/xutil.c \
................................................................................

tkMacOSXScrlbr.o: $(MAC_OSX_DIR)/tkMacOSXScrlbr.c
	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXScrlbr.c

tkMacOSXSend.o: $(MAC_OSX_DIR)/tkMacOSXSend.c
	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXSend.c




tkMacOSXSubwindows.o: $(MAC_OSX_DIR)/tkMacOSXSubwindows.c
	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXSubwindows.c

tkMacOSXTest.o: $(MAC_OSX_DIR)/tkMacOSXTest.c
	$(CC) -c $(APP_CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXTest.c

tkMacOSXWindowEvent.o: $(MAC_OSX_DIR)/tkMacOSXWindowEvent.c







|







 







>







 







>
>
>







394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
...
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
....
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
AQUA_OBJS = tkMacOSXBitmap.o tkMacOSXButton.o tkMacOSXClipboard.o \
	tkMacOSXColor.o tkMacOSXConfig.o tkMacOSXCursor.o tkMacOSXDebug.o \
	tkMacOSXDialog.o tkMacOSXDraw.o tkMacOSXEmbed.o tkMacOSXEntry.o \
	tkMacOSXEvent.o tkMacOSXFont.o tkMacOSXHLEvents.o tkMacOSXImage.o \
	tkMacOSXInit.o tkMacOSXKeyboard.o tkMacOSXKeyEvent.o tkMacOSXMenu.o \
	tkMacOSXMenubutton.o tkMacOSXMenus.o tkMacOSXMouseEvent.o \
	tkMacOSXNotify.o tkMacOSXRegion.o tkMacOSXScrlbr.o tkMacOSXSend.o \
	tkMacOSXServices.o tkMacOSXSubwindows.o tkMacOSXWindowEvent.o \
	tkMacOSXWm.o tkMacOSXXStubs.o \
	tkFileFilter.o tkMacWinMenu.o tkPointer.o tkUnix3d.o tkUnixScale.o \
	xcolors.o xdraw.o xgc.o ximage.o xutil.o \
	ttkMacOSXTheme.o

AQUA_TKTEST_OBJS = tkMacOSXTest.o

................................................................................
	$(MAC_OSX_DIR)/tkMacOSXFont.c $(MAC_OSX_DIR)/tkMacOSXHLEvents.c \
	$(MAC_OSX_DIR)/tkMacOSXImage.c \
	$(MAC_OSX_DIR)/tkMacOSXInit.c $(MAC_OSX_DIR)/tkMacOSXKeyboard.c \
	$(MAC_OSX_DIR)/tkMacOSXKeyEvent.c $(MAC_OSX_DIR)/tkMacOSXMenu.c \
	$(MAC_OSX_DIR)/tkMacOSXMenubutton.c $(MAC_OSX_DIR)/tkMacOSXMenus.c \
	$(MAC_OSX_DIR)/tkMacOSXMouseEvent.c $(MAC_OSX_DIR)/tkMacOSXNotify.c \
	$(MAC_OSX_DIR)/tkMacOSXRegion.c $(MAC_OSX_DIR)/tkMacOSXScrlbr.c \
	$(MAC_OSX_DIR)/tkMacOSXServices.c \
	$(MAC_OSX_DIR)/tkMacOSXSend.c $(MAC_OSX_DIR)/tkMacOSXSubwindows.c \
	$(MAC_OSX_DIR)/tkMacOSXTest.c $(MAC_OSX_DIR)/tkMacOSXWindowEvent.c \
	$(MAC_OSX_DIR)/tkMacOSXWm.c $(MAC_OSX_DIR)/tkMacOSXXStubs.c \
	$(GENERIC_DIR)/tkFileFilter.c $(GENERIC_DIR)/tkMacWinMenu.c \
	$(GENERIC_DIR)/tkPointer.c $(UNIX_DIR)/tkUnix3d.c \
	$(UNIX_DIR)/tkUnixScale.c $(XLIB_DIR)/xcolors.c $(XLIB_DIR)/xdraw.c \
	$(XLIB_DIR)/xgc.c $(XLIB_DIR)/ximage.c $(XLIB_DIR)/xutil.c \
................................................................................

tkMacOSXScrlbr.o: $(MAC_OSX_DIR)/tkMacOSXScrlbr.c
	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXScrlbr.c

tkMacOSXSend.o: $(MAC_OSX_DIR)/tkMacOSXSend.c
	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXSend.c

tkMacOSXServices.o: $(MAC_OSX_DIR)/tkMacOSXServices.c
	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXServices.c

tkMacOSXSubwindows.o: $(MAC_OSX_DIR)/tkMacOSXSubwindows.c
	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXSubwindows.c

tkMacOSXTest.o: $(MAC_OSX_DIR)/tkMacOSXTest.c
	$(CC) -c $(APP_CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXTest.c

tkMacOSXWindowEvent.o: $(MAC_OSX_DIR)/tkMacOSXWindowEvent.c

Changes to jni/tcl/generic/tclStrToD.c.

3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
....
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
....
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
....
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913

    /*
     * b = bw * 2**b2 * 5**b5
     * mminus = 5**m5
     */

    TclBNInitBignumFromWideUInt(&b, bw);
    mp_init_set_int(&mminus, 1);
    MulPow5(&b, b5, &b);
    mp_mul_2d(&b, b2, &b);

    /*
     * Adjust if the logarithm was guessed wrong.
     */

................................................................................
    /*
     * b = bw * 2**b2 * 5**b5
     * S = 2**s2 * 5*s5
     */

    TclBNInitBignumFromWideUInt(&b, bw);
    mp_mul_2d(&b, b2, &b);
    mp_init_set_int(&S, 1);
    MulPow5(&S, s5, &S); mp_mul_2d(&S, s2, &S);

    /*
     * Handle the case where we guess the position of the decimal point wrong.
     */

    if (mp_cmp_mag(&b, &S) == MP_LT) {
................................................................................
	--k;
    }

    /*
     * mminus = 2**m2minus * 5**m5
     */

    mp_init_set_int(&mminus, minit);
    mp_mul_2d(&mminus, m2minus, &mminus);
    if (m2plus > m2minus) {
	mp_init_copy(&mplus, &mminus);
	mp_mul_2d(&mplus, m2plus-m2minus, &mplus);
    }
    mp_init(&temp);

................................................................................
     * b = bw * 2**b2 * 5**b5
     * S = 2**s2 * 5*s5
     */

    mp_init_multi(&temp, &dig, NULL);
    TclBNInitBignumFromWideUInt(&b, bw);
    mp_mul_2d(&b, b2, &b);
    mp_init_set_int(&S, 1);
    MulPow5(&S, s5, &S); mp_mul_2d(&S, s2, &S);

    /*
     * Handle the case where we guess the position of the decimal point wrong.
     */

    if (mp_cmp_mag(&b, &S) == MP_LT) {







|







 







|







 







|







 







|







3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
....
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
....
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
....
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913

    /*
     * b = bw * 2**b2 * 5**b5
     * mminus = 5**m5
     */

    TclBNInitBignumFromWideUInt(&b, bw);
    mp_init_set(&mminus, 1);
    MulPow5(&b, b5, &b);
    mp_mul_2d(&b, b2, &b);

    /*
     * Adjust if the logarithm was guessed wrong.
     */

................................................................................
    /*
     * b = bw * 2**b2 * 5**b5
     * S = 2**s2 * 5*s5
     */

    TclBNInitBignumFromWideUInt(&b, bw);
    mp_mul_2d(&b, b2, &b);
    mp_init_set(&S, 1);
    MulPow5(&S, s5, &S); mp_mul_2d(&S, s2, &S);

    /*
     * Handle the case where we guess the position of the decimal point wrong.
     */

    if (mp_cmp_mag(&b, &S) == MP_LT) {
................................................................................
	--k;
    }

    /*
     * mminus = 2**m2minus * 5**m5
     */

    mp_init_set(&mminus, minit);
    mp_mul_2d(&mminus, m2minus, &mminus);
    if (m2plus > m2minus) {
	mp_init_copy(&mplus, &mminus);
	mp_mul_2d(&mplus, m2plus-m2minus, &mplus);
    }
    mp_init(&temp);

................................................................................
     * b = bw * 2**b2 * 5**b5
     * S = 2**s2 * 5*s5
     */

    mp_init_multi(&temp, &dig, NULL);
    TclBNInitBignumFromWideUInt(&b, bw);
    mp_mul_2d(&b, b2, &b);
    mp_init_set(&S, 1);
    MulPow5(&S, s5, &S); mp_mul_2d(&S, s2, &S);

    /*
     * Handle the case where we guess the position of the decimal point wrong.
     */

    if (mp_cmp_mag(&b, &S) == MP_LT) {

Changes to undroid/build-undroidwish-win32.sh.

1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178

echo -n "build nsf ... "
(
  exec 3>&1
  exec >> build.log 2>&1
  cd nsf
  test -e build-stamp && echo >&3 "already done" && exit 0
  ./configure --build=i386-windows-mingw32 --prefix=${PFX} \
    --with-tcl=${HERE}/tcl/win --enable-threads \
    --disable-rpath || exit 1
  make binaries libraries || exit 1
  make install-binaries install-libraries install-xotcl-libraries \
    DESTDIR=${HERE} || exit 1
  rm -f ${PFX_HERE}/lib/nsf*/*.a
  rm -f ${PFX_HERE}/lib/nsf*.sh ${PFX_HERE}/lib/nsf*.dll







|







1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178

echo -n "build nsf ... "
(
  exec 3>&1
  exec >> build.log 2>&1
  cd nsf
  test -e build-stamp && echo >&3 "already done" && exit 0
  ./configure --host=i386-windows-mingw32 --prefix=${PFX} \
    --with-tcl=${HERE}/tcl/win --enable-threads \
    --disable-rpath || exit 1
  make binaries libraries || exit 1
  make install-binaries install-libraries install-xotcl-libraries \
    DESTDIR=${HERE} || exit 1
  rm -f ${PFX_HERE}/lib/nsf*/*.a
  rm -f ${PFX_HERE}/lib/nsf*.sh ${PFX_HERE}/lib/nsf*.dll

Changes to undroid/build-undroidwish-win64.sh.

1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163

echo -n "build nsf ... "
(
  exec 3>&1
  exec >> build.log 2>&1
  cd nsf
  test -e build-stamp && echo >&3 "already done" && exit 0
  ./configure --build=x86_64-windows-mingw32 --prefix=${PFX} \
    --with-tcl=${HERE}/tcl/win --enable-threads \
    --disable-rpath || exit 1
  make binaries libraries || exit 1
  make install-binaries install-libraries install-xotcl-libraries \
    DESTDIR=${HERE} || exit 1
  rm -f ${PFX_HERE}/lib/nsf*/*.a
  rm -f ${PFX_HERE}/lib/nsf*.sh ${PFX_HERE}/lib/nsf*.dll







|







1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163

echo -n "build nsf ... "
(
  exec 3>&1
  exec >> build.log 2>&1
  cd nsf
  test -e build-stamp && echo >&3 "already done" && exit 0
  ./configure --host=x86_64-windows-mingw32 --prefix=${PFX} \
    --with-tcl=${HERE}/tcl/win --enable-threads \
    --disable-rpath || exit 1
  make binaries libraries || exit 1
  make install-binaries install-libraries install-xotcl-libraries \
    DESTDIR=${HERE} || exit 1
  rm -f ${PFX_HERE}/lib/nsf*/*.a
  rm -f ${PFX_HERE}/lib/nsf*.sh ${PFX_HERE}/lib/nsf*.dll

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

1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
  cp -rp ${PFX_HERE}/lib/tserialport* assets
  cp -rp ${PFX_HERE}/lib/topcua* assets
  cp -rp ${PFX_HERE}/lib/parse_args* assets
  cp -rp ${PFX_HERE}/lib/tkvlc* assets
  cp -rp ${PFX_HERE}/lib/tclJBlend* assets
  cp -rp ${AWDIR}/assets/tdbcjdbc* assets
  cp -rp ${PFX_HERE}/lib/twv* assets
  cp -rp ${AWDIR}/undroid/tsb assets/tsb1
  # add stripped down TDK
  cp -rp ${AWDIR}/undroid/TDK assets
  # add shortcuts providing builtin:widget, builtin:tksqlite, etc.
  (
    cd assets
    echo > widget \
      'source [file dirname [info script]]/'$(echo tk8*)'/demos/widget'







|







1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
  cp -rp ${PFX_HERE}/lib/tserialport* assets
  cp -rp ${PFX_HERE}/lib/topcua* assets
  cp -rp ${PFX_HERE}/lib/parse_args* assets
  cp -rp ${PFX_HERE}/lib/tkvlc* assets
  cp -rp ${PFX_HERE}/lib/tclJBlend* assets
  cp -rp ${AWDIR}/assets/tdbcjdbc* assets
  cp -rp ${PFX_HERE}/lib/twv* assets
  cp -rp ${AWDIR}/undroid/tsb assets/tsb0
  # add stripped down TDK
  cp -rp ${AWDIR}/undroid/TDK assets
  # add shortcuts providing builtin:widget, builtin:tksqlite, etc.
  (
    cd assets
    echo > widget \
      'source [file dirname [info script]]/'$(echo tk8*)'/demos/widget'

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

1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
....
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
....
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674

echo -n "build nsf ... "
(
  exec 3>&1
  exec >> build.log 2>&1
  cd nsf
  test -e build-stamp && echo >&3 "already done" && exit 0
  ./configure --build=i386-windows-mingw32 --prefix=${PFX} \
    --with-tcl=${HERE}/tcl/win --enable-threads \
    --disable-rpath || exit 1
  make binaries libraries || exit 1
  make install-binaries install-libraries install-xotcl-libraries \
    DESTDIR=${HERE} || exit 1
  rm -f ${PFX_HERE}/lib/nsf*/*.a
  rm -f ${PFX_HERE}/lib/nsf*.sh ${PFX_HERE}/lib/nsf*.dll
................................................................................
  cp -rp ${PFX_HERE}/lib/DiffUtil* assets
  cp -rp ${PFX_HERE}/lib/parser* assets
  cp -rp ${PFX_HERE}/lib/tclcompiler* assets
  cp -rp ${PFX_HERE}/lib/win32* assets
  cp -rp ${PFX_HERE}/lib/tclJBlend* assets
  cp -rp ${AWDIR}/assets/tdbcjdbc* assets
  cp -rp ${PFX_HERE}/lib/twv* assets
  cp -rp ${AWDIR}/undroid/tsb* assets
  # add stripped down TDK
  cp -rp ${AWDIR}/undroid/TDK assets
  # add shortcuts providing builtin:widget, builtin:tksqlite, etc.
  (
    cd assets
    echo > widget \
      'source [file dirname [info script]]/'$(echo tk8*)'/demos/widget'
................................................................................
  cp -rp ${PFX_HERE}/lib/tserialport* tassets
  cp -rp ${PFX_HERE}/lib/topcua* tassets
  cp -rp ${PFX_HERE}/lib/parse_args* tassets
  cp -rp ${PFX_HERE}/lib/tkvlc* tassets
  cp -rp ${PFX_HERE}/lib/tclJBlend* tassets
  cp -rp ${AWDIR}/assets/tdbcjdbc* tassets
  cp -rp ${PFX_HERE}/lib/twv* tassets
  cp -rp ${AWDIR}/undroid/tsb* tassets
  # add sdx
  cp -rp ${HERE}/tclkit/sdx/lib/app-sdx tassets/app-sdx2.0
  cp -rp ${HERE}/tclkit/sdx/lib/sdx tassets/sdx1.0
  cp -rp ${HERE}/tclkit/sdx/lib/starsync tassets/starsync1.0
  cp -rp ${HERE}/tclkit/sdx/lib/stringfileinfo tassets/stringfileinfo0.2
  echo > tassets/sdx 'package require starkit ; package require app-sdx'
  if test "$ACTION" = "ebuild" ; then







|







 







|







 







|







1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
....
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
....
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674

echo -n "build nsf ... "
(
  exec 3>&1
  exec >> build.log 2>&1
  cd nsf
  test -e build-stamp && echo >&3 "already done" && exit 0
  ./configure --host=i386-windows-mingw32 --prefix=${PFX} \
    --with-tcl=${HERE}/tcl/win --enable-threads \
    --disable-rpath || exit 1
  make binaries libraries || exit 1
  make install-binaries install-libraries install-xotcl-libraries \
    DESTDIR=${HERE} || exit 1
  rm -f ${PFX_HERE}/lib/nsf*/*.a
  rm -f ${PFX_HERE}/lib/nsf*.sh ${PFX_HERE}/lib/nsf*.dll
................................................................................
  cp -rp ${PFX_HERE}/lib/DiffUtil* assets
  cp -rp ${PFX_HERE}/lib/parser* assets
  cp -rp ${PFX_HERE}/lib/tclcompiler* assets
  cp -rp ${PFX_HERE}/lib/win32* assets
  cp -rp ${PFX_HERE}/lib/tclJBlend* assets
  cp -rp ${AWDIR}/assets/tdbcjdbc* assets
  cp -rp ${PFX_HERE}/lib/twv* assets
  cp -rp ${AWDIR}/undroid/tsb* assets/tsb0
  # add stripped down TDK
  cp -rp ${AWDIR}/undroid/TDK assets
  # add shortcuts providing builtin:widget, builtin:tksqlite, etc.
  (
    cd assets
    echo > widget \
      'source [file dirname [info script]]/'$(echo tk8*)'/demos/widget'
................................................................................
  cp -rp ${PFX_HERE}/lib/tserialport* tassets
  cp -rp ${PFX_HERE}/lib/topcua* tassets
  cp -rp ${PFX_HERE}/lib/parse_args* tassets
  cp -rp ${PFX_HERE}/lib/tkvlc* tassets
  cp -rp ${PFX_HERE}/lib/tclJBlend* tassets
  cp -rp ${AWDIR}/assets/tdbcjdbc* tassets
  cp -rp ${PFX_HERE}/lib/twv* tassets
  cp -rp ${AWDIR}/undroid/tsb* tassets/tsb0
  # add sdx
  cp -rp ${HERE}/tclkit/sdx/lib/app-sdx tassets/app-sdx2.0
  cp -rp ${HERE}/tclkit/sdx/lib/sdx tassets/sdx1.0
  cp -rp ${HERE}/tclkit/sdx/lib/starsync tassets/starsync1.0
  cp -rp ${HERE}/tclkit/sdx/lib/stringfileinfo tassets/stringfileinfo0.2
  echo > tassets/sdx 'package require starkit ; package require app-sdx'
  if test "$ACTION" = "ebuild" ; then

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

1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
....
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
....
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654

echo -n "build nsf ... "
(
  exec 3>&1
  exec >> build.log 2>&1
  cd nsf
  test -e build-stamp && echo >&3 "already done" && exit 0
  ./configure --build=x86_64-windows-mingw32 --prefix=${PFX} \
    --with-tcl=${HERE}/tcl/win --enable-threads \
    --disable-rpath || exit 1
  make binaries libraries || exit 1
  make install-binaries install-libraries install-xotcl-libraries \
    DESTDIR=${HERE} || exit 1
  rm -f ${PFX_HERE}/lib/nsf*/*.a
  rm -f ${PFX_HERE}/lib/nsf*.sh ${PFX_HERE}/lib/nsf*.dll
................................................................................
  cp -rp ${PFX_HERE}/lib/DiffUtil* assets
  cp -rp ${PFX_HERE}/lib/parser* assets
  cp -rp ${PFX_HERE}/lib/tclcompiler* assets
  cp -rp ${PFX_HERE}/lib/win32* assets
  cp -rp ${PFX_HERE}/lib/tclJBlend* assets
  cp -rp ${AWDIR}/assets/tdbcjdbc* assets
  cp -rp ${PFX_HERE}/lib/twv* assets
  cp -rp ${AWDIR}/undroid/tsb* assets
  # add stripped down TDK
  cp -rp ${AWDIR}/undroid/TDK assets
  # add shortcuts providing builtin:widget, builtin:tksqlite, etc.
  (
    cd assets
    echo > widget \
      'source [file dirname [info script]]/'$(echo tk8*)'/demos/widget'
................................................................................
  cp -rp ${PFX_HERE}/lib/tserialport* tassets
  cp -rp ${PFX_HERE}/lib/topcua* tassets
  cp -rp ${PFX_HERE}/lib/parse_args* tassets
  cp -rp ${PFX_HERE}/lib/tkvlc* tassets
  cp -rp ${PFX_HERE}/lib/tclJBlend* tassets
  cp -rp ${AWDIR}/assets/tdbcjdbc* tassets
  cp -rp ${PFX_HERE}/lib/twv* tassets
  cp -rp ${AWDIR}/undroid/tsb* tassets
  # add sdx
  cp -rp ${HERE}/tclkit/sdx/lib/app-sdx tassets/app-sdx2.0
  cp -rp ${HERE}/tclkit/sdx/lib/sdx tassets/sdx1.0
  cp -rp ${HERE}/tclkit/sdx/lib/starsync tassets/starsync1.0
  cp -rp ${HERE}/tclkit/sdx/lib/stringfileinfo tassets/stringfileinfo0.2
  echo > tassets/sdx 'package require starkit ; package require app-sdx'
  if test "$ACTION" = "ebuild" ; then







|







 







|







 







|







1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
....
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
....
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654

echo -n "build nsf ... "
(
  exec 3>&1
  exec >> build.log 2>&1
  cd nsf
  test -e build-stamp && echo >&3 "already done" && exit 0
  ./configure --host=x86_64-windows-mingw32 --prefix=${PFX} \
    --with-tcl=${HERE}/tcl/win --enable-threads \
    --disable-rpath || exit 1
  make binaries libraries || exit 1
  make install-binaries install-libraries install-xotcl-libraries \
    DESTDIR=${HERE} || exit 1
  rm -f ${PFX_HERE}/lib/nsf*/*.a
  rm -f ${PFX_HERE}/lib/nsf*.sh ${PFX_HERE}/lib/nsf*.dll
................................................................................
  cp -rp ${PFX_HERE}/lib/DiffUtil* assets
  cp -rp ${PFX_HERE}/lib/parser* assets
  cp -rp ${PFX_HERE}/lib/tclcompiler* assets
  cp -rp ${PFX_HERE}/lib/win32* assets
  cp -rp ${PFX_HERE}/lib/tclJBlend* assets
  cp -rp ${AWDIR}/assets/tdbcjdbc* assets
  cp -rp ${PFX_HERE}/lib/twv* assets
  cp -rp ${AWDIR}/undroid/tsb* assets/tsb0
  # add stripped down TDK
  cp -rp ${AWDIR}/undroid/TDK assets
  # add shortcuts providing builtin:widget, builtin:tksqlite, etc.
  (
    cd assets
    echo > widget \
      'source [file dirname [info script]]/'$(echo tk8*)'/demos/widget'
................................................................................
  cp -rp ${PFX_HERE}/lib/tserialport* tassets
  cp -rp ${PFX_HERE}/lib/topcua* tassets
  cp -rp ${PFX_HERE}/lib/parse_args* tassets
  cp -rp ${PFX_HERE}/lib/tkvlc* tassets
  cp -rp ${PFX_HERE}/lib/tclJBlend* tassets
  cp -rp ${AWDIR}/assets/tdbcjdbc* tassets
  cp -rp ${PFX_HERE}/lib/twv* tassets
  cp -rp ${AWDIR}/undroid/tsb* tassets/tsb0
  # add sdx
  cp -rp ${HERE}/tclkit/sdx/lib/app-sdx tassets/app-sdx2.0
  cp -rp ${HERE}/tclkit/sdx/lib/sdx tassets/sdx1.0
  cp -rp ${HERE}/tclkit/sdx/lib/starsync tassets/starsync1.0
  cp -rp ${HERE}/tclkit/sdx/lib/stringfileinfo tassets/stringfileinfo0.2
  echo > tassets/sdx 'package require starkit ; package require app-sdx'
  if test "$ACTION" = "ebuild" ; then

Changes to undroid/tsb/tsb.tcl.

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
...
801
802
803
804
805
806
807
808

809
810
811
812
813
814
815
...
817
818
819
820
821
822
823
824

825
826
827
828
829
830
831
...
840
841
842
843
844
845
846

















847
848
849
850
851
852
853
	set tdata $data
	set data $ncols
	set ncols [expr {0 - [llength $data]}]
    }
    if {$ncols == 0} {
	return
    }
    set ret "<table style='border: 1px solid;"
    append ret " margin-left: 1em; border-collapse: collapse; width: 90%'>"
    if {$ncols < 0} {
	set ncols [expr {0 - $ncols}]
	append ret "<tr>"
	for {set i 0} {$i < $ncols} {incr i} {
	    append ret "<th style='border: 1px solid;'>" \
		"<pre style='margin: 0.25em;'>" \

		[::tsb::htmlquote [lindex $data $i]] "</pre></th>"
	}
	append ret "</tr>"
	set data [lrange $data $ncols end]
    }
    if {[info exists tdata]} {
	set data $tdata
    }

    while {[llength $data]} {
	append ret "<tr>"
	for {set i 0} {$i < $ncols} {incr i} {
	    append ret "<td style='border: 1px solid;'>" \
		"<pre style='margin: 0.25em;'>" \
		[::tsb::htmlquote [lindex $data $i]] "</pre></td>"
	}
	append ret "</tr>"
	set data [lrange $data $ncols end]
    }
    append ret "</table><br>"
    htmlraw $ret
}

# Insert various headers (<h1>, <h2> ...) and rulers.

proc h1 {str} {
    htmlraw "<h1>[::tsb::htmlquote $str]</h1>" 1
................................................................................
    set D_style {
	<style>
	body {
	    font-family: sans-serif, Arial, Tahoma, Helvetica;
	    font-size: 90%;
	}
	textarea {
	    font-family: Consolas, monospace; font-size: 100%;

	}
	label {
	    font-family: Consolas, monospace;
	    margin: 1px;
	    padding: 1px;
	}
	pre {
................................................................................
	    white-space: pre-wrap;
	    white-space: -moz-pre-wrap;
	    white-space: -pre-wrap;
	    white-space: -o-pre-wrap;
	    word-wrap: break-word;
	}
	pre, code {
	    font-family: Consolas, monospace; font-size: 100%;

	}
	.infield * {
	    vertical-align: middle;
	}
	.tin {
	    width: 85%;
	    resize: none;
................................................................................
	    padding: 4px;
	}
	.tin:focus {
	    border: 3px solid rgba(81, 203, 238, 1);
	    margin: 2px;
	    padding: 4px;
	}

















	</style>
    }

    # SCRIPT
    set D_script {
	<script type="text/javascript">








|
<


|

<
<
>


|





>

|

<
|


|


|







 







|
>







 







|
>







 







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







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
...
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
...
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
...
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
	set tdata $data
	set data $ncols
	set ncols [expr {0 - [llength $data]}]
    }
    if {$ncols == 0} {
	return
    }
    set ret "\n<table class='tbl'>"

    if {$ncols < 0} {
	set ncols [expr {0 - $ncols}]
	append ret "\n <thead>\n  <tr>"
	for {set i 0} {$i < $ncols} {incr i} {


	    append ret "\n   <th><pre class='tdpre'>" \
		[::tsb::htmlquote [lindex $data $i]] "</pre></th>"
	}
	append ret "\n  </tr>\n </thead>"
	set data [lrange $data $ncols end]
    }
    if {[info exists tdata]} {
	set data $tdata
    }
    append ret "\n <tbody>"
    while {[llength $data]} {
	append ret "\n  <tr>"
	for {set i 0} {$i < $ncols} {incr i} {

	    append ret "\n   <td><pre class='tdpre'>" \
		[::tsb::htmlquote [lindex $data $i]] "</pre></td>"
	}
	append ret "\n  </tr>"
	set data [lrange $data $ncols end]
    }
    append ret "\n </tbody>\n</table><br>\n"
    htmlraw $ret
}

# Insert various headers (<h1>, <h2> ...) and rulers.

proc h1 {str} {
    htmlraw "<h1>[::tsb::htmlquote $str]</h1>" 1
................................................................................
    set D_style {
	<style>
	body {
	    font-family: sans-serif, Arial, Tahoma, Helvetica;
	    font-size: 90%;
	}
	textarea {
	    font-family: Consolas, monospace;
	    font-size: 100%;
	}
	label {
	    font-family: Consolas, monospace;
	    margin: 1px;
	    padding: 1px;
	}
	pre {
................................................................................
	    white-space: pre-wrap;
	    white-space: -moz-pre-wrap;
	    white-space: -pre-wrap;
	    white-space: -o-pre-wrap;
	    word-wrap: break-word;
	}
	pre, code {
	    font-family: Consolas, monospace;
	    font-size: 100%;
	}
	.infield * {
	    vertical-align: middle;
	}
	.tin {
	    width: 85%;
	    resize: none;
................................................................................
	    padding: 4px;
	}
	.tin:focus {
	    border: 3px solid rgba(81, 203, 238, 1);
	    margin: 2px;
	    padding: 4px;
	}
	.tbl {
	    border: 1px solid;
	    border-collapse: collapse;
	    margin-left: 1em;
	    width: 90%;
	}
	.tbl th {
	    border: 1px solid;
	    border-collapse: collapse;
	}
	.tbl td {
	    border: 1px solid;
	    border-collapse: collapse;
	}
	.tdpre {
	    margin: 0.25em;
	}
	</style>
    }

    # SCRIPT
    set D_script {
	<script type="text/javascript">