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
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)