flat assembler
Message board for the users of flat assembler.

Index > Windows > pointer to buffer

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 05 Jul 2010, 00:17
If the font size is fixed then just compute:

row = (y-verticaloffset)/characterheight

column = (x-horizontaloffset)/characterwidth
Post 05 Jul 2010, 00:17
View user's profile Send private message Visit poster's website Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 05 Jul 2010, 01:07
whats x and y? if its width and height of view:
Code:
;32*8 = 256 = X
;4*8 = 32 = horizontaloffset
;8 = characterwidth
(256-32)/8 = 28 ; column
;Y:
(192-48)/16= 9 ; row    

?
something is wrong.

to get row and col is easy the problem is to map that to char id.

The [t] char:
Code:
the book\
is on\
the [t]able    

has same row and col of:
Code:
the book\
is on blablablabla\
the [t]able    

however, they have differents char ids.
Post 05 Jul 2010, 01:07
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 05 Jul 2010, 02:31
What do you mean by "char id". Do you mean the offset into some memory buffer?

If your memory buffer is the raw text with CR and LF etc. then you can scan and count the LFs to find the row. And then move forward to find the column. Make sure your column counter does not pass a CR and move into the next line.
Post 05 Jul 2010, 02:31
View user's profile Send private message Visit poster's website Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 05 Jul 2010, 11:03
yep, offset.

I will need to count? there is not a math way to do that? Sad
Post 05 Jul 2010, 11:03
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 05 Jul 2010, 13:35
Well if your text buffer is free form with CR/LF in random places then no simple mathematics can help you.
Post 05 Jul 2010, 13:35
View user's profile Send private message Visit poster's website Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 05 Jul 2010, 13:44
i was wondering about make each line with 128 characters in max, so i can calc each position easily. However i don't know if its a good limitation and it will take too many memory space. So i think the way is to count. (although this seems slow).
Post 05 Jul 2010, 13:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 05 Jul 2010, 13:52
There are a few things you can do to enhance it.

Starting with your basic linear buffer you can create a table of line lengths for fast line indexing. Of course it requires you to update the index also when updating the text.

However, perhaps the basic rule is appropriate here. Get it working, then get it fast. If, once it is working, you find that the speed is a non-issue then forget about making it faster and instead make more code for other things.
Post 05 Jul 2010, 13:52
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.