Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

<wiggy> bwah, vodka in my mouse


devel / comp.lang.tcl / Roomy fonts won't fit in text widget

SubjectAuthor
* Roomy fonts won't fit in text widgetLuc
`* Re: Roomy fonts won't fit in text widgetRich
 `* Re: Roomy fonts won't fit in text widgetLuc
  `* Re: Roomy fonts won't fit in text widgetLuc
   `* Re: Roomy fonts won't fit in text widgetRich
    `* Re: Roomy fonts won't fit in text widgetLuc
     `* Re: Roomy fonts won't fit in text widgetRich
      `* Re: Roomy fonts won't fit in text widgetLuc
       `- Re: Roomy fonts won't fit in text widgetRich

1
Roomy fonts won't fit in text widget

<20240301171707.40c240ef@lud1.home>

  copy mid

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

  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: Roomy fonts won't fit in text widget
Date: Fri, 1 Mar 2024 17:17:07 -0300
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <20240301171707.40c240ef@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="b4f70ea7b13d384e5c6bb9cafa715926";
logging-data="1497111"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19l3qmFMbIWtVRDINbTJA93drrpcL5UgSM="
Cancel-Lock: sha1:XABIZu7FEaMwPLNe1GlfkqDfKng=
 by: Luc - Fri, 1 Mar 2024 20:17 UTC

I have a series of small text widgets inside a large text widget.

Each small text widget has exactly two lines.

text $::t1.smallbox_$x -width 200 -height 2

The problem is, the first line in those boxes is a certain font,
likely a very boring one, and the second line can be any font at all
including some pretty wild ones whose actual size is unpredictable in
spite of nominal font size.

So the first line fits fine but the second one very often doesn't.
In my vain philosophy, I expected the text widget to "stretch" to make
both lines fit because heck, I specified two lines of height, didn't I?
The widget should give me as tall a line as necessary for the text to
fit in. But that is not happening.

Setting the small widgets height to 3 fixes it for some fonts, but
not all. Setting it to 4 fixes some others, but one is still left.
How much do I need then? How much will I need if I install some other
"roomy" font? It's uncertain.

What is the correct way of handling this?

--
Luc
>>

Re: Roomy fonts won't fit in text widget

<urtlsf$1fmu5$2@dont-email.me>

  copy mid

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

  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: Roomy fonts won't fit in text widget
Date: Fri, 1 Mar 2024 22:46:39 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <urtlsf$1fmu5$2@dont-email.me>
References: <20240301171707.40c240ef@lud1.home>
Injection-Date: Fri, 1 Mar 2024 22:46:39 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8ef4264d65e4b5af98262fada3f3b2a6";
logging-data="1563589"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Qc+YpXG+2AJ+JZrk6rj70"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:Q3HkosWjqRumQX+YKd3Q+ORwHS4=
 by: Rich - Fri, 1 Mar 2024 22:46 UTC

Luc <luc@sep.invalid> wrote:
> In my vain philosophy, I expected the text widget to "stretch" to
> make both lines fit because heck, I specified two lines of height,
> didn't I?

Whether a widget "stretches" later, after it has been laid out on
screen, is also dependent upon the options given to the geometry
manager that is managing that widget on the screen.

So your lack of 'resizing' might just be that the geometry manager is
allocating enough for two lines, and then not allowing the widget to
grow later when it needs more.

A very minimal example showing how you are placing/packing/gridding it
would prove helpful.

Re: Roomy fonts won't fit in text widget

<20240301195131.0e9da74d@lud1.home>

  copy mid

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

  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: Roomy fonts won't fit in text widget
Date: Fri, 1 Mar 2024 19:51:31 -0300
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <20240301195131.0e9da74d@lud1.home>
References: <20240301171707.40c240ef@lud1.home>
<urtlsf$1fmu5$2@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="b4f70ea7b13d384e5c6bb9cafa715926";
logging-data="1568265"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/J+yfUfc8d3mig6S1iFSEKrmKWWdOGedM="
Cancel-Lock: sha1:nOwg/Zdg4+sNPG2zWAlX+RCI6Vw=
 by: Luc - Fri, 1 Mar 2024 22:51 UTC

On Fri, 1 Mar 2024 22:46:39 -0000 (UTC), Rich wrote:

>Luc <luc@sep.invalid> wrote:
>> In my vain philosophy, I expected the text widget to "stretch" to
>> make both lines fit because heck, I specified two lines of height,
>> didn't I?
>
>Whether a widget "stretches" later, after it has been laid out on
>screen, is also dependent upon the options given to the geometry
>manager that is managing that widget on the screen.
>
>So your lack of 'resizing' might just be that the geometry manager is
>allocating enough for two lines, and then not allowing the widget to
>grow later when it needs more.
>
>A very minimal example showing how you are placing/packing/gridding it
>would prove helpful.
>
**************************

I'm using pack, which is not necessary with 'create' but I added it
anyway, and it doesn't make any difference.

pack $::t1.smallbox_$x -fill both -expand 1
$::t1 window create end -window $::t1.smallbox_$x -stretch 1

--
Luc
>>

Re: Roomy fonts won't fit in text widget

<20240301204309.7f42e3de@lud1.home>

  copy mid

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

  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: Roomy fonts won't fit in text widget
Date: Fri, 1 Mar 2024 20:43:09 -0300
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <20240301204309.7f42e3de@lud1.home>
References: <20240301171707.40c240ef@lud1.home>
<urtlsf$1fmu5$2@dont-email.me>
<20240301195131.0e9da74d@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="a474d9336ff53749be56e5d2e9387c78";
logging-data="1588437"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/D5E12ReTS/zOGJgKHJ9zcCH7FgtS0iG4="
Cancel-Lock: sha1:Hgy35BmJKmaYAipgYKHR2LOvng8=
 by: Luc - Fri, 1 Mar 2024 23:43 UTC

On Fri, 1 Mar 2024 19:51:31 -0300, Luc wrote:

>I'm using pack, which is not necessary with 'create' but I added it
>anyway, and it doesn't make any difference.
>
>
>pack $::t1.smallbox_$x -fill both -expand 1
>$::t1 window create end -window $::t1.smallbox_$x -stretch 1
**************************

I've also tried inserting the content first and doing pack/create
later. No worky.

--
Luc
>>

Re: Roomy fonts won't fit in text widget

<urue8o$1nsr6$1@dont-email.me>

  copy mid

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

  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: Roomy fonts won't fit in text widget
Date: Sat, 2 Mar 2024 05:42:48 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <urue8o$1nsr6$1@dont-email.me>
References: <20240301171707.40c240ef@lud1.home> <urtlsf$1fmu5$2@dont-email.me> <20240301195131.0e9da74d@lud1.home> <20240301204309.7f42e3de@lud1.home>
Injection-Date: Sat, 2 Mar 2024 05:42:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d3ebb0a86cc1c2ad2af4dbd735b35c97";
logging-data="1831782"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1979Q7IV1zsLDPS0d1oYrtT"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:ajOhhEXHBNKzgvx2aA0bCHmoeL0=
 by: Rich - Sat, 2 Mar 2024 05:42 UTC

Luc <luc@sep.invalid> wrote:
> On Fri, 1 Mar 2024 19:51:31 -0300, Luc wrote:
>
>>I'm using pack, which is not necessary with 'create' but I added it
>>anyway, and it doesn't make any difference.
>>
>>
>>pack $::t1.smallbox_$x -fill both -expand 1
>>$::t1 window create end -window $::t1.smallbox_$x -stretch 1
> **************************
>
> I've also tried inserting the content first and doing pack/create
> later. No worky.

I missed that you indeed said "text widget inside text widget" in your
original post. In which case what I said about geometry managers does
not apply.

The "height" of a text widget is computed from the "line height" of the
"-font" for the text widget, times the numerical value given for
"-height". This is documented in the manpage:

Command-Line Name:-height
Database Name: height
Database Class: Height

Specifies the desired height for the window, in units of
characters in the font given by the -font option. Must be at
least one.

Note the "units of characters in the font given by the -font option".

So your solution here is to set the "-font" option for the embedded
text widget to whichever of the two fonts is "taller" than the other
font. Then you will get two lines of the taller font worth of room.
Which will allow enough room for one line of a shorter font plus one
line of the taller font. And, if the font assiged to "-font" is
resized (or changed) the widget will change its size automatically.

Now, next question. If you are inserting two text lines, why are you
using an embedded text widget to do so, instead of simply inserting
those two lines in the outer text widget, and tagging each with a
different tag if you want them to be a different font than the outer
widget's default?

Re: Roomy fonts won't fit in text widget

<20240302032138.3f7071b2@lud1.home>

  copy mid

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

  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: Roomy fonts won't fit in text widget
Date: Sat, 2 Mar 2024 03:21:37 -0300
Organization: A noiseless patient Spider
Lines: 65
Message-ID: <20240302032138.3f7071b2@lud1.home>
References: <20240301171707.40c240ef@lud1.home>
<urtlsf$1fmu5$2@dont-email.me>
<20240301195131.0e9da74d@lud1.home>
<20240301204309.7f42e3de@lud1.home>
<urue8o$1nsr6$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="158f804debb728c0b19e08acea332458";
logging-data="1834822"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+86zAd5hAF2twcxyc9C3h8/PHREbwOyCQ="
Cancel-Lock: sha1:iXD6DsUiIOxDJM2A1ErRsGlBa9c=
 by: Luc - Sat, 2 Mar 2024 06:21 UTC

On Sat, 2 Mar 2024 05:42:48 -0000 (UTC), Rich wrote:

>I missed that you indeed said "text widget inside text widget" in your
>original post. In which case what I said about geometry managers does
>not apply.
>
>The "height" of a text widget is computed from the "line height" of the
>"-font" for the text widget, times the numerical value given for
>"-height". This is documented in the manpage:
>
> Command-Line Name:-height
> Database Name: height
> Database Class: Height
>
> Specifies the desired height for the window, in units of
> characters in the font given by the -font option. Must be at
> least one.
>
>Note the "units of characters in the font given by the -font option".

I have determined without any doubt that it's the font size of the
larger text widget which contains the small text widgets that defines
the height of the small widgets' lines.

But...

>So your solution here is to set the "-font" option for the embedded
>text widget to whichever of the two fonts is "taller" than the other
>font.

Your solution is better. Just set -font to the largest font. Duh!
I was doing something stupid, no -font definition at all and tags
to define the font of each line.

I followed your suggestion and yes, it works better.

But there is a bizarre odd case here and there that doesn't quite
look right and is hard to understand. I will have a hard time debugging
that. I thought this was going to be a ridiculously easy project but
it has turned out to be a little challenging after all.

There is also an unwanted side effect: the width of the text boxes
now varies and I really didn't want that. :-(

>Now, next question. If you are inserting two text lines, why are you
>using an embedded text widget to do so, instead of simply inserting
>those two lines in the outer text widget, and tagging each with a
>different tag if you want them to be a different font than the outer
>widget's default?

Control. I want to be very, very sure of what is selected. The idea
is that the user will be able to select and remove unwanted boxes at
leisure. I began with one big widget and keeping track of line numbers,
but that was very unreliable. Unusable really. So now I'm going with
individual "boxes" of text.

--
Luc
>>

Re: Roomy fonts won't fit in text widget

<uruhsd$1od7s$1@dont-email.me>

  copy mid

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

  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: Roomy fonts won't fit in text widget
Date: Sat, 2 Mar 2024 06:44:29 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 77
Message-ID: <uruhsd$1od7s$1@dont-email.me>
References: <20240301171707.40c240ef@lud1.home> <urtlsf$1fmu5$2@dont-email.me> <20240301195131.0e9da74d@lud1.home> <20240301204309.7f42e3de@lud1.home> <urue8o$1nsr6$1@dont-email.me> <20240302032138.3f7071b2@lud1.home>
Injection-Date: Sat, 2 Mar 2024 06:44:29 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d3ebb0a86cc1c2ad2af4dbd735b35c97";
logging-data="1848572"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19m9hgjNrQHgqkN7RWbFIZq"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:0CBREOExyuzSM2a7Rp12YBO0CYY=
 by: Rich - Sat, 2 Mar 2024 06:44 UTC

Luc <luc@sep.invalid> wrote:
> On Sat, 2 Mar 2024 05:42:48 -0000 (UTC), Rich wrote:
>
>>I missed that you indeed said "text widget inside text widget" in your
>>original post. In which case what I said about geometry managers does
>>not apply.
>>
>>The "height" of a text widget is computed from the "line height" of the
>>"-font" for the text widget, times the numerical value given for
>>"-height". This is documented in the manpage:
>>
>> Command-Line Name:-height
>> Database Name: height
>> Database Class: Height
>>
>> Specifies the desired height for the window, in units of
>> characters in the font given by the -font option. Must be at
>> least one.
>>
>>Note the "units of characters in the font given by the -font option".
>
>
> I have determined without any doubt that it's the font size of the
> larger text widget which contains the small text widgets that defines
> the height of the small widgets' lines.

Nope, it is the font set as the "-font" for the small widgets.

Now, if that happens to be the same font used by the container, it will
seem as if the container's font is impacting the small ones as well.

>>So your solution here is to set the "-font" option for the embedded
>>text widget to whichever of the two fonts is "taller" than the other
>>font.
>
> Your solution is better. Just set -font to the largest font. Duh!
> I was doing something stupid, no -font definition at all and tags
> to define the font of each line.

There's *always* a font, even if you don't explicitly give one:

$ rlwrap wish
% text .t
.t
% .t cget -font
TkFixedFont
%

> I followed your suggestion and yes, it works better.
>
> There is also an unwanted side effect: the width of the text boxes
> now varies and I really didn't want that. :-(

Font "-size" impacts both height *and* width of the font, which impacts
the pixel width of the widget when it computes the font character width
times the "-width" option value.

>>Now, next question. If you are inserting two text lines, why are you
>>using an embedded text widget to do so, instead of simply inserting
>>those two lines in the outer text widget, and tagging each with a
>>different tag if you want them to be a different font than the outer
>>widget's default?
>
> Control. I want to be very, very sure of what is selected.

The text widget already tells you, with perfect accuracy, what text is
selected. And you not only get lines, but character position within
line accuracy (of the start and end) for the text widget selection
data.

> The idea is that the user will be able to select and remove unwanted
> boxes at leisure. I began with one big widget and keeping track of
> line numbers, but that was very unreliable.

If you were trying to track it yourself, yes, that can be a pain. But
why did the widget's built in tracking not work for you?

Re: Roomy fonts won't fit in text widget

<20240302041938.3b1bab73@lud1.home>

  copy mid

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

  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: Roomy fonts won't fit in text widget
Date: Sat, 2 Mar 2024 04:19:38 -0300
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <20240302041938.3b1bab73@lud1.home>
References: <20240301171707.40c240ef@lud1.home>
<urtlsf$1fmu5$2@dont-email.me>
<20240301195131.0e9da74d@lud1.home>
<20240301204309.7f42e3de@lud1.home>
<urue8o$1nsr6$1@dont-email.me>
<20240302032138.3f7071b2@lud1.home>
<uruhsd$1od7s$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="158f804debb728c0b19e08acea332458";
logging-data="1858437"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+AVP6LZjKrgBNsu1S4UwGX4pVAzJocBeE="
Cancel-Lock: sha1:oXheakEl7hoxSx+L8fJIhavZFjk=
 by: Luc - Sat, 2 Mar 2024 07:19 UTC

On Sat, 2 Mar 2024 06:44:29 -0000 (UTC), Rich wrote:

>The text widget already tells you, with perfect accuracy, what text is
>selected. And you not only get lines, but character position within
>line accuracy (of the start and end) for the text widget selection
>data.

>If you were trying to track it yourself, yes, that can be a pain. But
>why did the widget's built in tracking not work for you?

Yes, of course. I didn't provide you with enough details so you don't
really understand what is going on. My fault. Sorry.

It's a series of pairs. I want to keep track of what pair is selected.
And I can't afford to make the text widget editable. The user could
delete one, two, God knows how many lines, and I would no longer know
what is what and what is where.

So I have to "disable" the text widget. The user thus cannot select
any text in the most obvious way. And I can no longer keep track of
cursor position because there is no cursor in a disabled text widget.
I have to provide a very controlled method for selecting a pair.

I am no longer using text widgets. Now the big text widget contains
a series of labels. The whole thing looks and behaves a lot better
now. I thought it would be cool to let the user edit the boxes at
leisure, but I've decided that idea is not very viable. It may be
possible, but too much work and not really necessary.

This is going to be a pretty neat application.

Useful too! Let's not forget that. :-)

--
Luc
>>

Re: Roomy fonts won't fit in text widget

<urvk45$1va4h$1@dont-email.me>

  copy mid

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

  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: Roomy fonts won't fit in text widget
Date: Sat, 2 Mar 2024 16:28:53 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 91
Message-ID: <urvk45$1va4h$1@dont-email.me>
References: <20240301171707.40c240ef@lud1.home> <urtlsf$1fmu5$2@dont-email.me> <20240301195131.0e9da74d@lud1.home> <20240301204309.7f42e3de@lud1.home> <urue8o$1nsr6$1@dont-email.me> <20240302032138.3f7071b2@lud1.home> <uruhsd$1od7s$1@dont-email.me> <20240302041938.3b1bab73@lud1.home>
Injection-Date: Sat, 2 Mar 2024 16:28:53 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d3ebb0a86cc1c2ad2af4dbd735b35c97";
logging-data="2074769"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19AqSOT1Z+043n1vhAY3fDN"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:gCCCOPZx2kJvjTOYFmnd8BlzNqA=
 by: Rich - Sat, 2 Mar 2024 16:28 UTC

Luc <luc@sep.invalid> wrote:
> On Sat, 2 Mar 2024 06:44:29 -0000 (UTC), Rich wrote:
>
>>The text widget already tells you, with perfect accuracy, what text is
>>selected. And you not only get lines, but character position within
>>line accuracy (of the start and end) for the text widget selection
>>data.
>
>>If you were trying to track it yourself, yes, that can be a pain. But
>>why did the widget's built in tracking not work for you?
>
> Yes, of course. I didn't provide you with enough details so you don't
> really understand what is going on. My fault. Sorry.

Yep, that's *very* true.

> It's a series of pairs. I want to keep track of what pair is selected.
> And I can't afford to make the text widget editable. The user could
> delete one, two, God knows how many lines, and I would no longer know
> what is what and what is where.
>
> So I have to "disable" the text widget. The user thus cannot select
> any text in the most obvious way. And I can no longer keep track of
> cursor position because there is no cursor in a disabled text widget.
> I have to provide a very controlled method for selecting a pair.

So, create a 'read only' text widget instead. That way the user can't
make changes to the text, but all the normal text widget features still
work. See code example at end.

> I am no longer using text widgets. Now the big text widget contains
> a series of labels. The whole thing looks and behaves a lot better
> now. I thought it would be cool to let the user edit the boxes at
> leisure, but I've decided that idea is not very viable. It may be
> possible, but too much work and not really necessary.

Using tags to mark pairs, you could even extend the example below to
allow editing within a single pair by checking that the position being
edited is within the range of a tag attched to a given pair that is
meant to be editable at the moment.

Quick code example of a read only text widget:

#!/usr/bin/wish

text .text

.text insert end "Lorem ipsum dolor sit amet, consectetur\n"
.text insert end "adipiscing elit, sed do eiusmod tempor\n"
.text insert end "incididunt ut labore et dolore magna\n"
.text insert end "aliqua. Ut enim ad minim veniam,\n"
.text insert end "quis nostrud exercitation ullamco laboris\n"
.text insert end "nisi ut aliquip ex ea commodo consequat.\n"
.text insert end "Duis aute irure dolor in reprehenderit\n"
.text insert end "in voluptate velit esse cillum dolore\n"
.text insert end "eu fugiat nulla pariatur. Excepteur\n"
.text insert end "sint occaecat cupidatat non proident,\n"
.text insert end "sunt in culpa qui officia deserunt mollit\n"
.text insert end "anim id est laborum."

pack .text

# now, rename the text widget to a new name

rename .text .real-text-widget

# and create a proc to 'watch' for 'change content' commands and
# reject any attempts to change the contents

proc .text {subcommand args} {
switch -exact -- $subcommand {
delete -
insert -
replace {
# modification command - reject it
puts stderr "Refusing to edit text widget contents"
}
default {
# chain everything else to the real text widget
.real-text-widget $subcommand {*}$args
}
}
}

# also bind to <<Selection>> to show changes in the selection

bind .text <<Selection>> [list show-selection .text]

proc show-selection {w} {
puts stderr ".text selection is: [.text tag ranges sel]"
}

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor