Re: Operate only on the visible lines in a text window

Liste des GroupesRevenir à cl tcl 
Sujet : Re: Operate only on the visible lines in a text window
De : et99 (at) *nospam* rocketship1.me (et99)
Groupes : comp.lang.tcl
Date : 10. Jul 2024, 06:26:54
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v6l62u$1pbbd$1@dont-email.me>
References : 1
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1
On 7/9/2024 5:57 PM, Shaun Deacon wrote:
My application uses a text widget to display chip 'test vectors' from a loaded file. Each vector occupies a line - for example :
 0011010XXLLLHH
0100110XXLHHLH
...
0110110XXHHHHH
 A highlighting operation colors specified values (for example all 1's) for all lines of text in the widget. For small and medium sized files this is fine. However, test files can often be large (over 500,000 vectors). The highlight operation applied to all lines is too slow in this case - the vectors are much longer strings in real life too.
 The obvious solution to me is to just highlight the currently visible lines (or a range of lines spanning the current view - say 1000 or so) and when the user scrolls the window, highlight the new set of lines.
 Suggestions on the best way to find the indexes for the currently visible lines when the widget has been scrolled would be great.
 Can someone please point me in the right direction ?
 For some reason, I can't seem to find what I'm looking for in CLT, the wiki or the man pages.
 thanks
Shaun
 
Can't you use the current cursor position? How is it scrolled, mouse wheel? scroll bar? The current cursor is at,
.textwidget index insert
You could likely estimate it using scrollbar info. But if there are 500k lines, how might someone get to the middle, by some sort of search?
The only way I know to find what lines in a text widget are on screen without any other info is using the bbox method. You can test if any particular $line is visible by using
.textwidget bbox $line.0
which will return a null list if not on screen, otherwise a list of numbers.
This could involve a large search to find the first and last line on-screen. I don't know how fast or slow that would be. You could likely test every Nth line if you know how many lines fit on screen.
et

Date Sujet#  Auteur
10 Jul 24 * Operate only on the visible lines in a text window5Shaun Deacon
10 Jul 24 +- Re: Operate only on the visible lines in a text window1et99
10 Jul 24 +- Operate only on the visible lines in a text window1clt.to.davebr
10 Jul 24 `* Re: Operate only on the visible lines in a text window2Ralf Fassel
10 Jul 24  `- Re: Operate only on the visible lines in a text window1Shaun Deacon

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal