flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > Scrollbar update strategy?

Author
Thread Post new topic Reply to topic
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Hi all. Now I stuck with the following problem - how to properly update parameters of the horizontal scrollbar of the text editor and namely - the maximal value.
The problem is that it is impossible in all cases to know what is the maximal width of the lines of text, without scanning whole file.

Editing lines we may have two cases:
1. The new line length is greater than the current maximal length - in this case the all is clear - max limit of the scrollbar must be updated to the new max length.

2. The new line length is smaller than the current maximal length - in this case, the situation is unclear and nothing is known about the maximal length - it could be greater, less or unchanged. So, full scan of the file is needed.

I want to avoid full scan of the file, because on big files, it could be very very slow.
Any algorithmic ideas?
Post 19 Dec 2011, 20:10
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17625
Location: In your JS exploiting you and your system
revolution
At load time scan the file once and build a sorted tree of line lengths. As each line changes length update the tree. The last (or first) entry in the tree always has the length of the longest line. Something like a red-black tree would be suitable but check out other types of trees to see if another one looks like a better fit.
Post 19 Dec 2011, 20:46
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
revolution, I can't imagine what the tree structure will help me about this problem. What this tree will contain - only lengths or pointers to the text lines. Or text lines must contain pointers to the tree nodes?
Post 19 Dec 2011, 21:56
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7781
Location: Kraków, Poland
Tomasz Grysztar
fasmw's AsmEdit control does that by keeping an array of line counts for each length. Each time the line's length changes, the count for its earlier length is decreased, and count for the new length is increased - if it decreases the count for current maximum length and it becomes zero, it looks for the previous non-zero count in the array.
Post 19 Dec 2011, 22:05
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Hi Tomasz. This is exactly the solution I wanted to use at first glance. The only thing that makes me think again is that the length of the array makes some limit to the possible lengths of lines. So, even if we have one line 10000 chars, we must have array from 10000 elements. (filled mostly with zeroes).


Last edited by JohnFound on 19 Dec 2011, 22:29; edited 1 time in total
Post 19 Dec 2011, 22:18
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7781
Location: Kraków, Poland
Tomasz Grysztar
If you already have one line with 10000 chars, then the table would be only four times the length of that line. And since generally (because of its architecture) AsmEdit already uses few times more memory for text storage than the length of the pure text itself (in case when it consists of short lines - the longer lines you have, the less waste there is then), this seemed like not a problem for me. But of course it all depends on your design and priorities. revolution's tree proposal may be the right one for you if you don't like the idea of huge mostly-zero array happening sometimes.
Post 19 Dec 2011, 22:22
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17625
Location: In your JS exploiting you and your system
revolution
JohnFound wrote:
revolution, I can't imagine what the tree structure will help me about this problem. What this tree will contain - only lengths or pointers to the text lines. Or text lines must contain pointers to the tree nodes?
Each line can have the tree node either appended or prepended.
Post 19 Dec 2011, 22:33
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Also, I think about absolutely different approach - simply to not adjust the scrollbar related to the whole text, but only to the current displayed page. Or maybe to the three pages - previous, current and next.
This approach will make easy to simply search the maximum from the limited number of lines. Also, it could be even more convenient for the user, because it will allow scrolling of the lines that the user can see at the moment. For example, if there is a very long line at the begin of the text and the user drags the scrollbar to the end, he will end with totally useless blank screen.
Post 19 Dec 2011, 22:37
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17625
Location: In your JS exploiting you and your system
revolution
JohnFound wrote:
Also, I think about absolutely different approach - simply to not adjust the scrollbar related to the whole text, but only to the current displayed page. Or maybe to the three pages - previous, current and next.
This approach will make easy to simply search the maximum from the limited number of lines. Also, it could be even more convenient for the user, because it will allow scrolling of the lines that the user can see at the moment. For example, if there is a very long line at the begin of the text and the user drags the scrollbar to the end, he will end with totally useless blank screen.
Well for my usage this would not be nice. I often scroll vertically through files with my horizontal view far right looking for things that might exist way out in the distance. Also, forcing the horizontal view to a different position as the user scrolls vertically is uncomfortable and not very user-friendly.
Post 19 Dec 2011, 22:43
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
There will be no horizontal movement of the text when you scroll vertically. Only the position and size of the slider relative to the scrollbar will change, not the text itself.
Post 19 Dec 2011, 22:49
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17625
Location: In your JS exploiting you and your system
revolution
JohnFound wrote:
There will be no horizontal movement of the text when you scroll vertically. Only the position and size of the slider relative to the scrollbar will change, not the text itself.
Well that is my point. The H scrollbar give me the sense of position. If that changes then my sense of position has been lost.
Post 19 Dec 2011, 22:52
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1417
Location: Toronto, Canada
AsmGuru62
In Visual Studio editor - the scroll bar is set to some large value (like 1024) and it is never adjusted - a simplest solution. Practice shows that long lines of code are unreadable.
Post 20 Dec 2011, 04:31
View user's profile Send private message Send e-mail Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4240
Location: 2018
edfed
give a chance the asmedit.inc engine? or inspire yourself from it, it is a very powerfull and smart piece of code.
Post 05 Jan 2012, 17:01
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
edfed wrote:
give a chance the asmedit.inc engine? or inspire yourself from it, it is a very powerfull and smart piece of code.

Agree, the current editor of Fresh is based on FASMW, but in its current state it can't provide some features I want to implement (and almost implemented):

1. UNICODE support.
2. Code folding.
3. Full portability.
4. Word wrap.
5. Full GUI level portability.
6. Saveable bookmarks, breakpoints and other format info.
7. Line associated debug information.
Post 06 Jan 2012, 07:08
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
^^One man doing that ? Good luck. Do you work ?

UNICODE support IMO is more demanding than most of them.
Post 06 Jan 2012, 21:48
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
typedef, the engine it is almost done. Including UNICODE support for both Linux and Windows. There are some features that have to be finished.
You can see some (outdated) screenshots here.
Post 07 Jan 2012, 09:26
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
It's nice to see ppl stay devoted to open source even in times of economic turmoil.
Post 07 Jan 2012, 20:54
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.