Deutsch English Français Italiano |
<v6l62u$1pbbd$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: et99 <et99@rocketship1.me> Newsgroups: comp.lang.tcl Subject: Re: Operate only on the visible lines in a text window Date: Tue, 9 Jul 2024 22:26:54 -0700 Organization: A noiseless patient Spider Lines: 39 Message-ID: <v6l62u$1pbbd$1@dont-email.me> References: <v6kmal$1jhpc$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 10 Jul 2024 07:26:55 +0200 (CEST) Injection-Info: dont-email.me; posting-host="7ce27fdf532a3aad608f7e71b5318448"; logging-data="1879405"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1SISLNGhZaLRRmjdsm0Hk" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Cancel-Lock: sha1:svzs6ZIkInLarE4YksJBvP8mylQ= In-Reply-To: <v6kmal$1jhpc$1@dont-email.me> Content-Language: en-US Bytes: 3015 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