Skip to content

Commit 16601d6

Browse files
Nick Ing-Simmonseserte
authored andcommitted
import Tk 804.025_beta10 from CPAN
git-cpan-module: Tk git-cpan-version: 804.025_beta10 git-cpan-authorid: NI-S git-cpan-file: authors/id/N/NI/NI-S/Tk-804.025_beta10.tar.gz
1 parent e1d05f6 commit 16601d6

36 files changed

+600
-133
lines changed

Change.log

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
Change 3042 on 2003/12/14 by nick@llama
2+
3+
Switch $VERSION stuff to new style when file
4+
has been touched.
5+
6+
Change 3040 on 2003/12/14 by nick@llama
7+
8+
Slaven's Entry more like Tcl patch. Nick is not entierly
9+
convinced by the Selection hackery here is an improvement.
10+
11+
Change 3039 on 2003/12/13 by nick@llama
12+
13+
Slaven's ToDo additions and listbox test
14+
15+
Change 3038 on 2003/12/13 by nick@llama
16+
17+
MANIFEST cleanup
18+
19+
Change 3037 on 2003/12/13 by nick@llama
20+
21+
Heuristics for command line parse - ignore things
22+
after -unknown - and no croaks only warn
23+
24+
Change 3036 on 2003/12/13 by nick@llama
25+
26+
Slaven's Listbox patches
27+
28+
Change 3035 on 2003/12/13 by nick@llama
29+
30+
Slaven's FBox patches
31+
32+
Change 3034 on 2003/12/13 by nick@llama
33+
34+
Avoid a core dump if tkUnixFont cannot find (e.g.) Korean
35+
glyph.
36+
37+
Change 3033 on 2003/12/13 by nick@llama
38+
39+
Fixup beta9 MANIFEST issues etc.
40+
141
Change 3032 on 2003/12/10 by nick@llama
242

343
Makefile generation tweaks:

DragDrop/DragDrop.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ require Tk::Toplevel;
44
require Tk::Label;
55

66
use vars qw($VERSION);
7-
$VERSION = '4.012'; # $Id: //depot/Tkutf8/DragDrop/DragDrop.pm#13 $
7+
$VERSION = sprintf '4.%03d', q$Revision: #14 $ =~ /\D(\d+)\s*$/;
88

99
use base qw(Tk::DragDrop::Common Tk::Toplevel);
1010

DragDrop/DragDrop/Rect.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use Carp;
44
# Proxy class which represents sites to the dropping side
55

66
use vars qw($VERSION);
7-
$VERSION = '4.004'; # $Id: //depot/Tkutf8/DragDrop/DragDrop/Rect.pm#5 $
7+
$VERSION = sprintf '4.%03d', q$Revision: #6 $ =~ /\D(\d+)\s*$/;
88

99
sub Over
1010
{

DragDrop/DragDrop/SunSite.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package Tk::DragDrop::SunSite;
22
require Tk::DropSite;
33

44
use vars qw($VERSION);
5-
$VERSION = '4.004'; # $Id: //depot/Tkutf8/DragDrop/DragDrop/SunSite.pm#5 $
5+
$VERSION = sprintf '4.%03d', q$Revision: #6 $ =~ /\D(\d+)\s*$/;
66

77
use Tk::DragDrop::SunConst;
88
use base qw(Tk::DropSite);

DragDrop/DragDrop/XDNDDrop.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package Tk::DragDrop::XDNDDrop;
22
use strict;
33
use vars qw($VERSION);
4-
$VERSION = '4.004'; # $Id: //depot/Tkutf8/DragDrop/DragDrop/XDNDDrop.pm#5 $
4+
$VERSION = sprintf '4.%03d', q$Revision: #6 $ =~ /\D(\d+)\s*$/;
55
use base qw(Tk::DragDrop::Rect);
66

77
sub XDND_PROTOCOL_VERSION () { 4 }

DragDrop/Win32Site/Win32Site.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package Tk::DragDrop::Win32Site;
22

33
use vars qw($VERSION);
4-
$VERSION = '4.004'; # $Id: //depot/Tkutf8/DragDrop/Win32Site/Win32Site.pm#5 $
4+
$VERSION = sprintf '4.%03d', q$Revision: #6 $ =~ /\D(\d+)\s*$/;
55

66
use Tk qw($XS_VERSION);
77
require DynaLoader;

Entry/Entry.pm

Lines changed: 97 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ package Tk::Entry;
1212
# This program is free software; you can redistribute it and/or
1313

1414
use vars qw($VERSION);
15-
$VERSION = sprintf '4.%03d',q$Revision: #16 $ =~ /#(\d+)/;
15+
use strict;
16+
$VERSION = sprintf '4.%03d',q$Revision: #17 $ =~ /#(\d+)/;
1617

1718
# modify it under the same terms as Perl itself, subject
1819
# to additional disclaimer in license.terms due to partial
@@ -79,7 +80,21 @@ sub ClassInit
7980

8081
$class->SUPER::ClassInit($mw);
8182

83+
# <<Cut>>, <<Copy>> and <<Paste>> defined in Tk::Clipboard
84+
$mw->bind($class,'<<Clear>>' => sub {
85+
my $w = shift;
86+
$w->delete("sel.first", "sel.last");
87+
});
88+
$mw->bind($class,'<<PasteSelection>>' => [sub {
89+
my($w, $x) = @_;
90+
# XXX logic in Tcl/Tk version screwed up?
91+
if (!$Tk::strictMotif && !$Tk::mouseMoved) {
92+
$w->Paste($x);
93+
}
94+
}, Ev('x')]);
95+
8296
# Standard Motif bindings:
97+
# The <Escape> binding is different from the Tcl/Tk version:
8398
$mw->bind($class,'<Escape>','selectionClear');
8499

85100
$mw->bind($class,'<1>',['Button1',Ev('x'),Ev('y')]);
@@ -136,8 +151,18 @@ sub ClassInit
136151
$mw->bind($class,'<Return>' ,'NoOp');
137152
$mw->bind($class,'<KP_Enter>' ,'NoOp');
138153
$mw->bind($class,'<Tab>' ,'NoOp');
154+
if ($mw->windowingsystem =~ /^(?:classic|aqua)$/)
155+
{
156+
$mw->bind($class,'<Command-KeyPress>', 'NoOp');
157+
}
158+
159+
# On Windows, paste is done using Shift-Insert. Shift-Insert already
160+
# generates the <<Paste>> event, so we don't need to do anything here.
161+
if ($Tk::platform ne 'MSWin32')
162+
{
163+
$mw->bind($class,'<Insert>','InsertSelection');
164+
}
139165

140-
$mw->bind($class,'<Insert>','InsertSelection');
141166
if (!$Tk::strictMotif)
142167
{
143168
# Additional emacs-like bindings:
@@ -151,20 +176,23 @@ sub ClassInit
151176

152177
$mw->bind($class,'<Control-t>','Transpose');
153178

179+
# XXX The original Tcl/Tk bindings use NextWord/PreviousWord instead
154180
$mw->bind($class,'<Meta-b>',['SetCursor',Ev(['wordstart'])]);
155181
$mw->bind($class,'<Meta-d>',['delete','insert',Ev(['wordend'])]);
156182
$mw->bind($class,'<Meta-f>',['SetCursor',Ev(['wordend'])]);
157183
$mw->bind($class,'<Meta-BackSpace>',['delete',Ev(['wordstart']),'insert']);
184+
$mw->bind($class,'<Meta-Delete>',['delete',Ev(['wordstart']),'insert']);
158185

159186
# A few additional bindings from John Ousterhout.
160-
$mw->bind($class,'<Control-w>',['delete',Ev(['wordstart']),'insert']);
187+
# XXX conflicts with <<Copy>>: $mw->bind($class,'<Control-w>',['delete',Ev(['wordstart']),'insert']);
161188
$mw->bind($class,'<2>','Button_2');
162189
$mw->bind($class,'<B2-Motion>','B2_Motion');
163-
$mw->bind($class,'<ButtonRelease-2>','ButtonRelease_2');
190+
# XXX superseded by <<PasteSelection>>: $mw->bind($class,'<ButtonRelease-2>','ButtonRelease_2');
164191
}
165192
return $class;
166193
}
167194

195+
168196
sub Shift_1
169197
{
170198
my $w = shift;
@@ -199,10 +227,11 @@ sub Delete
199227
sub InsertSelection
200228
{
201229
my $w = shift;
202-
eval {local $SIG{__DIE__}; $w->Insert($w->SelectionGet)}
230+
eval {local $SIG{__DIE__}; $w->Insert($w->GetSelection)}
203231
}
204232

205233

234+
# Original is ::tk::EntryScanMark
206235
sub Button_2
207236
{
208237
my $w = shift;
@@ -214,10 +243,14 @@ sub Button_2
214243
}
215244

216245

246+
# Original is ::tk::EntryScanDrag
217247
sub B2_Motion
218248
{
219249
my $w = shift;
220250
my $Ev = $w->XEvent;
251+
# Make sure these exist, as some weird situations can trigger the
252+
# motion binding without the initial press. [Tcl/Tk Bug #220269]
253+
if (!defined $Tk::x) { $Tk::x = $Ev->x }
221254
if (abs(($Ev->x-$Tk::x)) > 2)
222255
{
223256
$Tk::mouseMoved = 1
@@ -226,6 +259,7 @@ sub B2_Motion
226259
}
227260

228261

262+
# XXX Not needed anymore
229263
sub ButtonRelease_2
230264
{
231265
my $w = shift;
@@ -245,6 +279,26 @@ sub Button1Release
245279
shift->CancelRepeat;
246280
}
247281

282+
# ::tk::EntryClosestGap --
283+
# Given x and y coordinates, this procedure finds the closest boundary
284+
# between characters to the given coordinates and returns the index
285+
# of the character just after the boundary.
286+
#
287+
# Arguments:
288+
# w - The entry window.
289+
# x - X-coordinate within the window.
290+
sub ClosestGap
291+
{
292+
my($w, $x) = @_;
293+
my $pos = $w->index('@'.$x);
294+
my @bbox = $w->bbox($pos);
295+
if ($x - $bbox[0] < $bbox[2] / 2)
296+
{
297+
return $pos;
298+
}
299+
$pos + 1;
300+
}
301+
248302
# Button1 --
249303
# This procedure is invoked to handle button-1 presses in entry
250304
# widgets. It moves the insertion cursor, sets the selection anchor,
@@ -257,14 +311,13 @@ sub Button1
257311
{
258312
my $w = shift;
259313
my $x = shift;
260-
my $y = shift;
261314
$Tk::selectMode = 'char';
262315
$Tk::mouseMoved = 0;
263316
$Tk::pressX = $x;
264-
$w->icursor('@' . $x);
265-
$w->selectionFrom('@' . $x);
317+
$w->icursor($w->ClosestGap($x));
318+
$w->selectionFrom('insert');
266319
$w->selectionClear;
267-
if ($w->cget('-state') eq 'normal')
320+
if ($w->cget('-state') ne 'disabled')
268321
{
269322
$w->focus()
270323
}
@@ -273,6 +326,7 @@ sub Button1
273326
sub Motion
274327
{
275328
my ($w,$x,$y) = @_;
329+
$Tk::x = $x; # XXX ?
276330
$w->MouseSelect($x);
277331
}
278332

@@ -291,13 +345,13 @@ sub MouseSelect
291345

292346
my $w = shift;
293347
my $x = shift;
294-
return if ref($w) eq 'Tk::Spinbox' and $w->{_element} ne 'entry';
348+
return if UNIVERSAL::isa($w, 'Tk::Spinbox') and $w->{_element} ne 'entry';
295349
$Tk::selectMode = shift if (@_);
296-
my $cur = $w->index('@' . $x);
350+
my $cur = $w->index($w->ClosestGap($x));
297351
return unless defined $cur;
298352
my $anchor = $w->index('anchor');
299353
return unless defined $anchor;
300-
$Tk::pressX ||= $x;
354+
$Tk::pressX ||= $x; # XXX Better use "if !defined $Tk::pressX"?
301355
if (($cur != $anchor) || (abs($Tk::pressX - $x) >= 3))
302356
{
303357
$Tk::mouseMoved = 1
@@ -306,6 +360,7 @@ sub MouseSelect
306360
return unless $mode;
307361
if ($mode eq 'char')
308362
{
363+
# The Tcl version uses selectionRange here XXX
309364
if ($Tk::mouseMoved)
310365
{
311366
if ($cur < $anchor)
@@ -320,6 +375,7 @@ sub MouseSelect
320375
}
321376
elsif ($mode eq 'word')
322377
{
378+
# The Tcl version uses tcl_wordBreakBefore/After here XXX
323379
if ($cur < $w->index('anchor'))
324380
{
325381
$w->selectionRange($w->wordstart($cur),$w->wordend($anchor-1))
@@ -340,6 +396,26 @@ sub MouseSelect
340396
}
341397
$w->idletasks;
342398
}
399+
# ::tk::EntryPaste --
400+
# This procedure sets the insertion cursor to the current mouse position,
401+
# pastes the selection there, and sets the focus to the window.
402+
#
403+
# Arguments:
404+
# w - The entry window.
405+
# x - X position of the mouse.
406+
sub Paste
407+
{
408+
my($w, $x) = @_;
409+
$w->icursor($w->ClosestGap($x));
410+
eval { local $SIG{__DIE__};
411+
$w->insert("insert", $w->GetSelection);
412+
$w->SeeInsert; # Perl/Tk extension
413+
};
414+
if ($w->cget(-state) ne 'disabled')
415+
{
416+
$w->focus;
417+
}
418+
}
343419
# AutoScan --
344420
# This procedure is invoked when the mouse leaves an entry window
345421
# with button 1 down. It scrolls the window left or right,
@@ -354,6 +430,7 @@ sub AutoScan
354430
{
355431
my $w = shift;
356432
my $x = shift;
433+
return if !Tk::Exists($w);
357434
if ($x >= $w->width)
358435
{
359436
$w->xview('scroll',2,'units')
@@ -434,6 +511,7 @@ sub Backspace
434511
{
435512
my $x = $w->index('insert')-1;
436513
$w->delete($x) if ($x >= 0);
514+
# XXX Missing repositioning part from Tcl/Tk source
437515
}
438516
}
439517
# SeeInsert
@@ -513,6 +591,12 @@ sub tabFocus
513591
$w->SUPER::tabFocus;
514592
}
515593

594+
# ::tk::EntryGetSelection --
595+
#
596+
# Returns the selected text of the entry with respect to the -show option.
597+
#
598+
# Arguments:
599+
# w - The entry window from which the text to get
516600
sub getSelected
517601
{
518602
my $w = shift;
@@ -525,8 +609,7 @@ sub getSelected
525609
return substr($str,$s,$e-$s);
526610
}
527611

612+
528613
1;
529614

530615
__END__
531-
532-

Listbox/Listbox.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ package Tk::Listbox;
3737

3838
use vars qw($VERSION @Selection $Prev);
3939
use strict;
40-
$VERSION = '4.012'; # $Id: //depot/Tkutf8/Listbox/Listbox.pm#13 $
40+
$VERSION = sprintf '4.%03d', q$Revision: #14 $ =~ /\D(\d+)\s*$/;
4141

4242
use Tk qw(Ev $XS_VERSION);
4343
use Tk::Clipboard ();

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,6 +1858,7 @@ t/progbar.t
18581858
t/regexp.t
18591859
t/Require.t
18601860
t/Trace.t
1861+
t/TkTest.pm
18611862
t/trace1.t
18621863
t/slaves.t
18631864
t/widget.t

MANIFEST.SKIP

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ doc/index\.html$
3131
doc/MANFILES$
3232
doc/.*\.htm$
3333
myConfig\.out
34+
JPEG/jpeg/testout*
35+
JPEG/jpeg/config\.(log|status)
36+
JPEG/jpeg/([cd]jpeg|jpegtran|(rd|wr)jpgcom)
3437
\.todo$
3538
\bswapm$
3639
bin/patchls$

0 commit comments

Comments
 (0)