Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

All science is either physics or stamp collecting. -- Ernest Rutherford


devel / comp.lang.tcl / Re: <<Clear>> and <<Selection>> behavior

SubjectAuthor
* <<Clear>> and <<Selection>> behaviorLuc
`* <<Clear>> and <<Selection>> behaviorRich
 `* <<Clear>> and <<Selection>> behaviorLuc
  +- <<Clear>> and <<Selection>> behaviorRich
  `* <<Clear>> and <<Selection>> behavioret99
   +- <<Clear>> and <<Selection>> behavioret99
   `* <<Clear>> and <<Selection>> behaviorLuc
    `* <<Clear>> and <<Selection>> behavioret99
     `- <<Clear>> and <<Selection>> behavioret99

1
<<Clear>> and <<Selection>> behavior

<20231130011918.7f0afc8f@lud1.home>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12508&group=comp.lang.tcl#12508

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc...@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: <<Clear>> and <<Selection>> behavior
Date: Thu, 30 Nov 2023 01:19:18 -0300
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <20231130011918.7f0afc8f@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="4d2c278a3f9365ec5f8f6b0c1977542a";
logging-data="1287935"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Vau2WYA3fwhdVAJcKCwmpaSPNfDBcTVM="
Cancel-Lock: sha1:5ELIWpIzpTdMLwR8rZFhv5wtQV8=
 by: Luc - Thu, 30 Nov 2023 04:19 UTC

Experiments:

bind $::text <<Selection>> {p.playwav "/home/tcl/sounds/tick.wav"}
bind $::text <<Clear>> {p.playwav "/home/tcl/sounds/tock.wav"}

I hear the tick whenever I select some text, but I can't figure out what
triggers <<Clear>> to play tock.wav.

The friendly manual says about <<Clear>>:
"Delete the currently selected widget contents."
So I thought that deleting text would trigger it. But it doesn't.

Question 1:
So what is the effect of creating a binding to <<Clear>>?

Question 2:
Why do I hear the tick twice when text is already selected and I extend
the selection to include more text?

--
Luc
>>

Re: <<Clear>> and <<Selection>> behavior

<uka74g$1d4q8$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12510&group=comp.lang.tcl#12510

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: <<Clear>> and <<Selection>> behavior
Date: Thu, 30 Nov 2023 14:44:32 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <uka74g$1d4q8$1@dont-email.me>
References: <20231130011918.7f0afc8f@lud1.home>
Injection-Date: Thu, 30 Nov 2023 14:44:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d0334ebad83d57104bc1388ce65b792e";
logging-data="1479496"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX190s0Ae0cxtmdjWpVaIY4g6"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.117 (x86_64))
Cancel-Lock: sha1:WGEG6xGRNYJ+lqdI+L3nf1iAndI=
 by: Rich - Thu, 30 Nov 2023 14:44 UTC

Luc <luc@sep.invalid> wrote:
> Experiments:
>
> bind $::text <<Selection>> {p.playwav "/home/tcl/sounds/tick.wav"}
> bind $::text <<Clear>> {p.playwav "/home/tcl/sounds/tock.wav"}
>
> I hear the tick whenever I select some text, but I can't figure out what
> triggers <<Clear>> to play tock.wav.
>
> The friendly manual says about <<Clear>>:
> "Delete the currently selected widget contents."
> So I thought that deleting text would trigger it. But it doesn't.
>
>
> Question 1:
> So what is the effect of creating a binding to <<Clear>>?

The text widget is not documented (at least in 8.6.12) as generating
<<Clear>>. In what manual did you find this event? Because what you
quote above is not typical wording for virtual events. They are
usually worded as: "generated when X occurs"

> Question 2:
> Why do I hear the tick twice when text is already selected and I extend
> the selection to include more text?

man n text:

[4] Whenever the sel tag range changes a virtual event
<<Selection>> is generated.

"Extending" the selection is a "change" to the "tag range" -- so it
triggers the event as documented.

Re: <<Clear>> and <<Selection>> behavior

<20231130121056.653eb41d@lud1.home>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12511&group=comp.lang.tcl#12511

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc...@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: <<Clear>> and <<Selection>> behavior
Date: Thu, 30 Nov 2023 12:10:56 -0300
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <20231130121056.653eb41d@lud1.home>
References: <20231130011918.7f0afc8f@lud1.home>
<uka74g$1d4q8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: dont-email.me; posting-host="4135809de22dd1d6f913a6f5ca405cb7";
logging-data="1490011"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+MxWBwxpswUGtOLyTsCYERBQUx4wzrfjs="
Cancel-Lock: sha1:mNhNC+QXHCMpq/EBLqXeSl2P2v0=
 by: Luc - Thu, 30 Nov 2023 15:10 UTC

On Thu, 30 Nov 2023 14:44:32 -0000 (UTC), Rich wrote:

>The text widget is not documented (at least in 8.6.12) as generating
><<Clear>>. In what manual did you find this event? Because what you
>quote above is not typical wording for virtual events. They are
>usually worded as: "generated when X occurs"

It's the 'event' page on a CHM file I downloaded some time ago, about
two years ago I think. It has this identification:

Tcl Windows Help (V 2019.01.09)
Copyright © 2019 Ashok P. Nadkarni (Compilation only)

I just noticed this:

"Tk defines the following virtual events for the purposes of unifying
bindings across multiple platforms. Users expect them to behave in the
following way:"

A list of events ensue, <<Clear>> is the first one.

Now, it occurs to me that "for the purposes of unifying bindings
across multiple platforms" might indicate that <<Clear>> belongs to
some other platform. Windows or Mac, I suppose.

>> Question 2:
>> Why do I hear the tick twice when text is already selected and I extend
>> the selection to include more text?
>
>man n text:
>
> [4] Whenever the sel tag range changes a virtual event
> <<Selection>> is generated.
>
>"Extending" the selection is a "change" to the "tag range" -- so it
>triggers the event as documented.

Thanks, but I still don't understand why it's triggered twice. Actually,
sometimes it is triggered twice and sometimes it's triggered once.
I tested it and got a consistently inconsistent behavior. Once or twice
on some pattern I definitely can't understand. I could post a link to
a video demonstrating it, but I know people here hate videos.

--
Luc
>>

Re: <<Clear>> and <<Selection>> behavior

<uka9k6$1dgcm$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12512&group=comp.lang.tcl#12512

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: <<Clear>> and <<Selection>> behavior
Date: Thu, 30 Nov 2023 15:27:02 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 85
Message-ID: <uka9k6$1dgcm$1@dont-email.me>
References: <20231130011918.7f0afc8f@lud1.home> <uka74g$1d4q8$1@dont-email.me> <20231130121056.653eb41d@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 30 Nov 2023 15:27:02 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d0334ebad83d57104bc1388ce65b792e";
logging-data="1491350"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184fzmNJE6Yw2pJy7FbEDrx"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.117 (x86_64))
Cancel-Lock: sha1:6tBubSaOrbundWg3ILixWgir3a4=
 by: Rich - Thu, 30 Nov 2023 15:27 UTC

Luc <luc@sep.invalid> wrote:
> On Thu, 30 Nov 2023 14:44:32 -0000 (UTC), Rich wrote:
>
>>The text widget is not documented (at least in 8.6.12) as generating
>><<Clear>>. In what manual did you find this event? Because what you
>>quote above is not typical wording for virtual events. They are
>>usually worded as: "generated when X occurs"
>
> It's the 'event' page on a CHM file I downloaded some time ago, about
> two years ago I think. It has this identification:
>
> Tcl Windows Help (V 2019.01.09)
> Copyright © 2019 Ashok P. Nadkarni (Compilation only)
>
> I just noticed this:
>
> "Tk defines the following virtual events for the purposes of unifying
> bindings across multiple platforms. Users expect them to behave in the
> following way:"
>
> A list of events ensue, <<Clear>> is the first one.
>
> Now, it occurs to me that "for the purposes of unifying bindings
> across multiple platforms" might indicate that <<Clear>> belongs to
> some other platform. Windows or Mac, I suppose.

Ah, yes, it is in the 'event' man page:

Tk defines the following virtual events for the purposes of
unifying bindings across multiple platforms. Users expect them
to behave in the following way:

<<Clear>>
Delete the currently selected widget contents.

When do you find that the text widget generates this event? The single
sentence implies it would only occur when all of the contents were
deleted.

>>> Question 2:
>>> Why do I hear the tick twice when text is already selected and I extend
>>> the selection to include more text?
>>
>>man n text:
>>
>> [4] Whenever the sel tag range changes a virtual event
>> <<Selection>> is generated.
>>
>>"Extending" the selection is a "change" to the "tag range" -- so it
>>triggers the event as documented.
>
>
> Thanks, but I still don't understand why it's triggered twice.

Given the small bit of docs, one explanation could be that the
triggering code is noticing two "changes" that differ in some subtle
way such that the author of the triggering code generated the event for
separately for both changes.

You could 'shim' the text widget so you can see what commands are being
called that might be the cause:

text .t
rename .t .t-original
proc .t {args} {
puts stderr "args='$args'"
.t-original {*}$args
}

And, change your <<Selection>> event to "puts" a message to stderr as
well (so timing remains consistent).

Then look at the stderr output to see what widget commands are being
called as the pair of events is being generated.

> Actually, sometimes it is triggered twice and sometimes it's
> triggered once. I tested it and got a consistently inconsistent
> behavior. Once or twice on some pattern I definitely can't
> understand. I could post a link to a video demonstrating it, but I
> know people here hate videos.

Well, the hatred is more for those who post a single short sentence
artice that says little more than: "see this video:
http://example.com/video.mkv".

Re: <<Clear>> and <<Selection>> behavior

<ukb0vm$1hgma$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12514&group=comp.lang.tcl#12514

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et9...@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: <<Clear>> and <<Selection>> behavior
Date: Thu, 30 Nov 2023 14:05:42 -0800
Organization: A noiseless patient Spider
Lines: 81
Message-ID: <ukb0vm$1hgma$1@dont-email.me>
References: <20231130011918.7f0afc8f@lud1.home> <uka74g$1d4q8$1@dont-email.me>
<20231130121056.653eb41d@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 30 Nov 2023 22:05:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="dc245acaf868fdd4b5147db819c95333";
logging-data="1622730"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wnfP3/suCZBEg6/oW5Egz"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:lmPJXDVVNvuor/eVN1lrxciwd3U=
Content-Language: en-US
In-Reply-To: <20231130121056.653eb41d@lud1.home>
 by: et99 - Thu, 30 Nov 2023 22:05 UTC

On 11/30/2023 7:10 AM, Luc wrote:
> On Thu, 30 Nov 2023 14:44:32 -0000 (UTC), Rich wrote:
>
>> The text widget is not documented (at least in 8.6.12) as generating
>> <<Clear>>. In what manual did you find this event? Because what you
>> quote above is not typical wording for virtual events. They are
>> usually worded as: "generated when X occurs"
>
> It's the 'event' page on a CHM file I downloaded some time ago, about
> two years ago I think. It has this identification:
>
> Tcl Windows Help (V 2019.01.09)
> Copyright © 2019 Ashok P. Nadkarni (Compilation only)
>
> I just noticed this:
>
> "Tk defines the following virtual events for the purposes of unifying
> bindings across multiple platforms. Users expect them to behave in the
> following way:"
>
> A list of events ensue, <<Clear>> is the first one.
>
> Now, it occurs to me that "for the purposes of unifying bindings
> across multiple platforms" might indicate that <<Clear>> belongs to
> some other platform. Windows or Mac, I suppose.
>
>
>
>>> Question 2:
>>> Why do I hear the tick twice when text is already selected and I extend
>>> the selection to include more text?
>>
>> man n text:
>>
>> [4] Whenever the sel tag range changes a virtual event
>> <<Selection>> is generated.
>>
>> "Extending" the selection is a "change" to the "tag range" -- so it
>> triggers the event as documented.
>
>
> Thanks, but I still don't understand why it's triggered twice. Actually,
> sometimes it is triggered twice and sometimes it's triggered once.
> I tested it and got a consistently inconsistent behavior. Once or twice
> on some pattern I definitely can't understand. I could post a link to
> a video demonstrating it, but I know people here hate videos.
>
>

Looking at the bindings sometimes helps:

% text .t
..t
% bindtags .t
..t Text . all
% join [lsort [bind Text]] \n
<<Clear>>
<<Copy>>
<<Cut>>
<<LineEnd>>
<<LineStart>>
..... snip ....
<Shift-Key-Tab>
<Shift-MouseWheel>
<Triple-Button-1>
<Triple-Shift-Button-1>

% bind Text <<Clear>>

# Make <<Clear>> an atomic operation on the Undo stack,
# i.e. separate it from other delete operations on either side
if {[%W cget -autoseparators]} {
%W edit separator
}
catch {%W delete sel.first sel.last}
if {[%W cget -autoseparators]} {
%W edit separator
}

Re: <<Clear>> and <<Selection>> behavior

<ukb3jv$1hv11$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12515&group=comp.lang.tcl#12515

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et9...@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: <<Clear>> and <<Selection>> behavior
Date: Thu, 30 Nov 2023 14:50:37 -0800
Organization: A noiseless patient Spider
Lines: 146
Message-ID: <ukb3jv$1hv11$1@dont-email.me>
References: <20231130011918.7f0afc8f@lud1.home> <uka74g$1d4q8$1@dont-email.me>
<20231130121056.653eb41d@lud1.home> <ukb0vm$1hgma$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 30 Nov 2023 22:50:39 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="dc245acaf868fdd4b5147db819c95333";
logging-data="1637409"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+11XS/t4YdxN5gY/xuGW5q"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:UCLV49ghaTP6DxT6JOXElG0mRHk=
In-Reply-To: <ukb0vm$1hgma$1@dont-email.me>
Content-Language: en-US
 by: et99 - Thu, 30 Nov 2023 22:50 UTC

On 11/30/2023 2:05 PM, et99 wrote:
> On 11/30/2023 7:10 AM, Luc wrote:
>> On Thu, 30 Nov 2023 14:44:32 -0000 (UTC), Rich wrote:
>>
>>> The text widget is not documented (at least in 8.6.12) as generating
>>> <<Clear>>.  In what manual did you find this event?  Because what you
>>> quote above is not typical wording for virtual events.  They are
>>> usually worded as: "generated when X occurs"
>>
>> It's the 'event' page on a CHM file I downloaded some time ago, about
>> two years ago I think. It has this identification:
>>
>> Tcl Windows Help (V 2019.01.09)
>> Copyright © 2019 Ashok P. Nadkarni (Compilation only)
>>
>> I just noticed this:
>>
>> "Tk defines the following virtual events for the purposes of unifying
>> bindings across multiple platforms. Users expect them to behave in the
>> following way:"
>>
>> A list of events ensue, <<Clear>> is the first one.
>>
>> Now, it occurs to me that "for the purposes of unifying bindings
>> across multiple platforms" might indicate that <<Clear>> belongs to
>> some other platform. Windows or Mac, I suppose.
>>
>>
>>
>>>> Question 2:
>>>> Why do I hear the tick twice when text is already selected and I extend
>>>> the selection to include more text?
>>>
>>> man n text:
>>>
>>>        [4]    Whenever the sel tag range changes a virtual event
>>>               <<Selection>> is generated.
>>>
>>> "Extending" the selection is a "change" to the "tag range" -- so it
>>> triggers the event as documented.
>>
>>
>> Thanks, but I still don't understand why it's triggered twice. Actually,
>> sometimes it is triggered twice and sometimes it's triggered once.
>> I tested it and got a consistently inconsistent behavior. Once or twice
>> on some pattern I definitely can't understand. I could post a link to
>> a video demonstrating it, but I know people here hate videos.
>>
>>
>
> Looking at the bindings sometimes helps:
>
> % text .t
> .t
> % bindtags .t
> .t Text . all
> % join [lsort [bind Text]] \n
> <<Clear>>
> <<Copy>>
> <<Cut>>
> <<LineEnd>>
> <<LineStart>>
> .... snip ....
> <Shift-Key-Tab>
> <Shift-MouseWheel>
> <Triple-Button-1>
> <Triple-Shift-Button-1>
>
> % bind Text <<Clear>>
>
>     # Make <<Clear>> an atomic operation on the Undo stack,
>     # i.e. separate it from other delete operations on either side
>     if {[%W cget -autoseparators]} {
>     %W edit separator
>     }
>     catch {%W delete sel.first sel.last}
>     if {[%W cget -autoseparators]} {
>     %W edit separator
>     }
>
>
>

Strangely, I can't locate the virtual event <<Clear>> itself:

% event info <<Clear>>
% join [lsort [event info]] \n
<<ContextMenu>>
<<Copy>>
<<Cut>>
<<LineEnd>>
<<LineStart>>
<<NextChar>>
<<NextLine>>
<<NextPara>>
<<NextWindow>>
<<NextWord>>
<<Paste>>
<<PasteSelection>>
<<PrevChar>>
<<PrevLine>>
<<PrevPara>>
<<PrevWindow>>
<<PrevWord>>
<<Redo>>
<<SelectAll>>
<<SelectLineEnd>>
<<SelectLineStart>>
<<SelectNextChar>>
<<SelectNextLine>>
<<SelectNextPara>>
<<SelectNextWord>>
<<SelectNone>>
<<SelectPrevChar>>
<<SelectPrevLine>>
<<SelectPrevPara>>
<<SelectPrevWord>>
<<ToggleSelection>>
<<Undo>>

But for the above, say, <<Paste>>

% event info <<Paste>>
<Control-Key-v> <Shift-Key-Insert> <Control-Lock-Key-V>

And the above list is the same on windows and linux.

But... there's no binding to <<Paste>> in Text, but there is in Entry:

% bind Text <<Paste>>
% bind Entry <<Paste>>

catch {
if {[tk windowingsystem] ne "x11"} {
catch {
%W delete sel.first sel.last
}
}
%W insert insert [::tk::GetSelection %W CLIPBOARD]
tk::EntrySeeInsert %W
}

Re: <<Clear>> and <<Selection>> behavior

<20231130211000.4930aeff@lud1.home>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12516&group=comp.lang.tcl#12516

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc...@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: <<Clear>> and <<Selection>> behavior
Date: Thu, 30 Nov 2023 21:10:00 -0300
Organization: A noiseless patient Spider
Lines: 83
Message-ID: <20231130211000.4930aeff@lud1.home>
References: <20231130011918.7f0afc8f@lud1.home>
<uka74g$1d4q8$1@dont-email.me>
<20231130121056.653eb41d@lud1.home>
<ukb0vm$1hgma$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="f35f579cc063ad829087e2409352cb38";
logging-data="1655492"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18iZaLtPoKkHBBo0/uJmXUurmD9J91UjL8="
Cancel-Lock: sha1:+jwbflU9WQSd8rjHqhlg6iVk818=
 by: Luc - Fri, 1 Dec 2023 00:10 UTC

On Thu, 30 Nov 2023 14:05:42 -0800, et99 wrote:

>Looking at the bindings sometimes helps:
>
>% text .t
>.t
>% bindtags .t
>.t Text . all
>% join [lsort [bind Text]] \n
><<Clear>>
><<Copy>>
><<Cut>>
><<LineEnd>>
><<LineStart>>
>.... snip ....
><Shift-Key-Tab>
><Shift-MouseWheel>
><Triple-Button-1>
><Triple-Shift-Button-1>
>
>% bind Text <<Clear>>
>
> # Make <<Clear>> an atomic operation on the Undo stack,
> # i.e. separate it from other delete operations on either side
> if {[%W cget -autoseparators]} {
> %W edit separator
> }
> catch {%W delete sel.first sel.last}
> if {[%W cget -autoseparators]} {
> %W edit separator
> }
**************************

I was about to find out something like that.

I have another app with text widgets and a problem: when pasting text
over existing test, the new text would be pasted next to it, or rather
it would be pasted where the old text was and the old text would be
pushed to the right. I never wanted that to happen.
My text editor doesn't do that.

Both apps had this:

bind $::text <Shift_L><Insert> {p.paste %W; break;}
bind $::text <Control-v> {p.paste %W; break;}

But they had slightly different paste procs:

proc p.paste {argWidget} {
event generate $argWidget <<Paste>>
$argWidget see insert

;# this one has the overwriting flaw
}

proc p.paste {argWidget} {
if {[tk windowingsystem] eq "x11"} {
event generate $argWidget <<Clear>>
# For other windowing systems, this operation is explicitly
# built into the <<Paste>> binding
}
event generate $argWidget <<Paste>>
$argWidget see insert

;# this one doesn't have the overwriting flaw
}

I don't remember where that comment regarding windowing systems
comes from. I may have stolen it from here, the wiki or the
manual.

Either way, I can't detect it with bind. I can detect the use of
the Delete key, but there are many ways that text can be deleted.

--
Luc
>>

Re: <<Clear>> and <<Selection>> behavior

<ukbpbs$1ogur$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12517&group=comp.lang.tcl#12517

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!nntp.comgw.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et9...@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: <<Clear>> and <<Selection>> behavior
Date: Thu, 30 Nov 2023 21:01:48 -0800
Organization: A noiseless patient Spider
Lines: 109
Message-ID: <ukbpbs$1ogur$1@dont-email.me>
References: <20231130011918.7f0afc8f@lud1.home> <uka74g$1d4q8$1@dont-email.me>
<20231130121056.653eb41d@lud1.home> <ukb0vm$1hgma$1@dont-email.me>
<20231130211000.4930aeff@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 1 Dec 2023 05:01:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4600b58c8751879b2d472a51acc80e73";
logging-data="1852379"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX188AfC8YKMezZF8+gRq96cW"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:UJHTDpKcAso2gCMBoCoGSkbS5q8=
In-Reply-To: <20231130211000.4930aeff@lud1.home>
Content-Language: en-US
 by: et99 - Fri, 1 Dec 2023 05:01 UTC

On 11/30/2023 4:10 PM, Luc wrote:
> On Thu, 30 Nov 2023 14:05:42 -0800, et99 wrote:
>
>> Looking at the bindings sometimes helps:
>>
>> % text .t
>> .t
>> % bindtags .t
>> .t Text . all
>> % join [lsort [bind Text]] \n
>> <<Clear>>
>> <<Copy>>
>> <<Cut>>
>> <<LineEnd>>
>> <<LineStart>>
>> .... snip ....
>> <Shift-Key-Tab>
>> <Shift-MouseWheel>
>> <Triple-Button-1>
>> <Triple-Shift-Button-1>
>>
>> % bind Text <<Clear>>
>>
>> # Make <<Clear>> an atomic operation on the Undo stack,
>> # i.e. separate it from other delete operations on either side
>> if {[%W cget -autoseparators]} {
>> %W edit separator
>> }
>> catch {%W delete sel.first sel.last}
>> if {[%W cget -autoseparators]} {
>> %W edit separator
>> }
> **************************
>
>
> I was about to find out something like that.
>
> I have another app with text widgets and a problem: when pasting text
> over existing test, the new text would be pasted next to it, or rather
> it would be pasted where the old text was and the old text would be
> pushed to the right. I never wanted that to happen.
> My text editor doesn't do that.
>
> Both apps had this:
>
> bind $::text <Shift_L><Insert> {p.paste %W; break;}
> bind $::text <Control-v> {p.paste %W; break;}
>
>
> But they had slightly different paste procs:
>
> proc p.paste {argWidget} {
> event generate $argWidget <<Paste>>
> $argWidget see insert
>
> ;# this one has the overwriting flaw
> }
>
>
> proc p.paste {argWidget} {
> if {[tk windowingsystem] eq "x11"} {
> event generate $argWidget <<Clear>>
> # For other windowing systems, this operation is explicitly
> # built into the <<Paste>> binding
> }
> event generate $argWidget <<Paste>>
> $argWidget see insert
>
> ;# this one doesn't have the overwriting flaw
> }
>
>
> I don't remember where that comment regarding windowing systems
> comes from. I may have stolen it from here, the wiki or the
> manual.
>
> Either way, I can't detect it with bind. I can detect the use of
> the Delete key, but there are many ways that text can be deleted.
>

I discovered that same problem with entry widgets being different on linux and windows. A paste on linux doesn't replace the selection as I expected.

And here is why that happens with the entry:

% bind Entry <<Paste>>

catch {
if {[tk windowingsystem] ne "x11"} {
catch {
%W delete sel.first sel.last
}
}
%W insert insert [::tk::GetSelection %W CLIPBOARD]
tk::EntrySeeInsert %W
}

I don't know why they don't do the delete of the selection on x11 systems

On my linux I get:

% tk windowingsystem
x11

vs. this on windows:

% tk windowingsystem
win32

Re: <<Clear>> and <<Selection>> behavior

<ukbq8b$1omeu$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12518&group=comp.lang.tcl#12518

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et9...@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: <<Clear>> and <<Selection>> behavior
Date: Thu, 30 Nov 2023 21:16:57 -0800
Organization: A noiseless patient Spider
Lines: 118
Message-ID: <ukbq8b$1omeu$1@dont-email.me>
References: <20231130011918.7f0afc8f@lud1.home> <uka74g$1d4q8$1@dont-email.me>
<20231130121056.653eb41d@lud1.home> <ukb0vm$1hgma$1@dont-email.me>
<20231130211000.4930aeff@lud1.home> <ukbpbs$1ogur$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 1 Dec 2023 05:16:59 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4600b58c8751879b2d472a51acc80e73";
logging-data="1858014"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19i/Nj6x3bj4vZZQkUrcH3C"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:b3HVLWnI7bz/ChMWeAZPm4DVaDY=
In-Reply-To: <ukbpbs$1ogur$1@dont-email.me>
Content-Language: en-US
 by: et99 - Fri, 1 Dec 2023 05:16 UTC

On 11/30/2023 9:01 PM, et99 wrote:
> On 11/30/2023 4:10 PM, Luc wrote:
>> On Thu, 30 Nov 2023 14:05:42 -0800, et99 wrote:
>>
>>> Looking at the bindings sometimes helps:
>>>
>>> % text .t
>>> .t
>>> % bindtags .t
>>> .t Text . all
>>> % join [lsort [bind Text]] \n
>>> <<Clear>>
>>> <<Copy>>
>>> <<Cut>>
>>> <<LineEnd>>
>>> <<LineStart>>
>>> .... snip ....
>>> <Shift-Key-Tab>
>>> <Shift-MouseWheel>
>>> <Triple-Button-1>
>>> <Triple-Shift-Button-1>
>>>
>>> % bind Text <<Clear>>
>>>
>>>      # Make <<Clear>> an atomic operation on the Undo stack,
>>>      # i.e. separate it from other delete operations on either side
>>>      if {[%W cget -autoseparators]} {
>>>     %W edit separator
>>>      }
>>>      catch {%W delete sel.first sel.last}
>>>      if {[%W cget -autoseparators]} {
>>>     %W edit separator
>>>      }
>> **************************
>>
>>
>> I was about to find out something like that.
>>
>> I have another app with text widgets and a problem: when pasting text
>> over existing test, the new text would be pasted next to it, or rather
>> it would be pasted where the old text was and the old text would be
>> pushed to the right. I never wanted that to happen.
>> My text editor doesn't do that.
>>
>> Both apps had this:
>>
>> bind $::text    <Shift_L><Insert>      {p.paste %W; break;}
>> bind $::text    <Control-v>         {p.paste %W; break;}
>>
>>
>> But they had slightly different paste procs:
>>
>> proc p.paste {argWidget}    {
>>     event generate $argWidget <<Paste>>
>>     $argWidget see insert
>>
>>     ;# this one has the overwriting flaw
>> }
>>
>>
>> proc p.paste {argWidget}    {
>>     if {[tk windowingsystem] eq "x11"} {
>>         event generate $argWidget <<Clear>>
>>         # For other windowing systems, this operation is explicitly
>>         # built into the <<Paste>> binding
>>     }
>>     event generate $argWidget <<Paste>>
>>     $argWidget see insert
>>
>>     ;# this one doesn't have the overwriting flaw
>> }
>>
>>
>> I don't remember where that comment regarding windowing systems
>> comes from. I may have stolen it from here, the wiki or the
>> manual.
>>
>> Either way, I can't detect it with bind. I can detect the use of
>> the Delete key, but there are many ways that text can be deleted.
>>
>
> I discovered that same problem with entry widgets being different on linux and windows. A paste on linux doesn't replace the selection as I expected.
>
> And here is why that happens with the entry:
>
> % bind Entry <<Paste>>
>
> catch {
>     if {[tk windowingsystem] ne "x11"} {
>         catch {
>             %W delete sel.first sel.last
>         }
>     }
>     %W insert insert [::tk::GetSelection %W CLIPBOARD]
>     tk::EntrySeeInsert %W
> }
>
>
> I don't know why they don't do the delete of the selection on x11 systems
>
> On my linux I get:
>
> % tk windowingsystem
> x11
>
> vs. this on windows:
>
> % tk windowingsystem
> win32
>

I just realized I had already posted the binding on <<Paste>> above. I was using that to show that Text and Entry were different and the second post to show it was the reason for the linux problem :)

But I think now the reason there's no direct bindings to <<Clear>> is that code must only use it via generate.

I think maybe I should write up a ticket for that (if I didn't already - need to check).

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor