Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Semper Fi, dude.


devel / comp.lang.tcl / Re: How do I select an entire line of text?

SubjectAuthor
* How do I select an entire line of text?Luc
`- Re: How do I select an entire line of text?Rich

1
How do I select an entire line of text?

<20221007185946.642a9fef@lud1.home>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!jIHeyQZ0TSfMjc7nxbxWiw.user.46.165.242.75.POSTED!not-for-mail
From: no@no.no (Luc)
Newsgroups: comp.lang.tcl
Subject: How do I select an entire line of text?
Date: Fri, 7 Oct 2022 18:59:46 -0300
Organization: Aioe.org NNTP Server
Message-ID: <20221007185946.642a9fef@lud1.home>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="32332"; posting-host="jIHeyQZ0TSfMjc7nxbxWiw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Newsreader: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu)
X-Notice: Filtered by postfilter v. 0.9.2
 by: Luc - Fri, 7 Oct 2022 21:59 UTC

I should be able to do this, but I am struggling and that is sucking the
fun out of my project.

How do I select entire lines in a text widget programatically?
I mean, the current line must be selected at all times.

I'm doing it like this:

--------------------
set ::currindex [[focus] index insert]
lassign [split $::currindex "."] ::CURRLINE ::CURRCOL

$::textw tag configure "selected" -foreground #ffffff -background #000000

$::textw tag remove "selected" $::oldline.0 "$::oldline.0 lineend"
$::textw tag add "selected" $::CURRLINE.0 "$::CURRLINE.0 lineend"
set ::oldline $::CURRLINE
--------------------

Great. The current line is always selected. Problems though:

1) The line is only "selected" (I probably should say "highlighted" because
that's what it really is) until the end of the text. I want the "selection"
or highlight to extend up to the end of the line, I mean, across the void
and into the "wall" of the text widget, as if the entire line were a single
cell in a table.

2) I want to be able to select multiple lines holding Shift. Even if I
use the "sel" tag, I'm not too sure of how to achieve that. I understand
the text widget will select and apply the "sel" tag by design, which
would do the job, but I don't know how to make the current line become
a selection automatically, without using the mouse or the Shift key.
I just want to have to use the Shift key when selecting multiple consecutive
lines.

3) Bonus if I can select multiple non-consecutive lines by holding the
Ctrl key.

Many thanks for any help.

--
Luc
>>

Re: How do I select an entire line of text?

<thqvdg$4dip$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: How do I select an entire line of text?
Date: Sat, 8 Oct 2022 04:47:44 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <thqvdg$4dip$1@dont-email.me>
References: <20221007185946.642a9fef@lud1.home>
Injection-Date: Sat, 8 Oct 2022 04:47:44 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="c6e3f7807d76f392a78ba3da3c6e77c9";
logging-data="144985"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18srOL8MuQ8MsBiqN4xF29n"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:vX4LXMBhL7GNT5G2I1dsUyKPSuQ=
 by: Rich - Sat, 8 Oct 2022 04:47 UTC

Luc <no@no.no> wrote:
> How do I select entire lines in a text widget programatically?

> ... I want the "selection" or highlight to extend up to the end of the
> line, I mean, across the void and into the "wall" of the text widget,
> as if the entire line were a single cell in a table.

$ rlwrap wish
% text .t
.t
% pack .t
% .t insert end "Mary had a little lamb\n"
% .t insert end "It's fleece was white as snow\n"
% .t insert end "The quick brown fox\n"
% .t tag add sel "2.5 linestart" "2.5 lineend + 1 chars"

> 2) I want to be able to select multiple lines holding Shift. Even if I
> use the "sel" tag, I'm not too sure of how to achieve that. I understand
> the text widget will select and apply the "sel" tag by design, which
> would do the job, but I don't know how to make the current line become
> a selection automatically, without using the mouse or the Shift key.

$ rlwrap wish
% text .t
.t
% pack .t
% .t insert end "Mary had a little lamb\n"
% .t insert end "It's fleece was white as snow\n"
% .t insert end "The quick brown fox\n"
% .t tag add sel "1.5 linestart" "1.5 lineend + 1 chars"
% .t tag add sel "3.5 linestart" "3.5 lineend + 1 chars"

Making all this work with various combinations of keys will likely
require you to replace the existing selection handling bindings for the
text with your own custom versions to do the "selection magic" you
want. Or use your own tag rather than the built in sel tag to do the
highlighting you want. Which will still require custom bindings, but
you won't have to override the existing sel bindings.


devel / comp.lang.tcl / Re: How do I select an entire line of text?

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor