flat assembler
Message board for the users of flat assembler.
Index
> Windows > pointer to buffer Goto page Previous 1, 2 |
Author |
|
revolution 05 Jul 2010, 00:17
If the font size is fixed then just compute:
row = (y-verticaloffset)/characterheight column = (x-horizontaloffset)/characterwidth |
|||
05 Jul 2010, 00:17 |
|
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. |
|||
05 Jul 2010, 02:31 |
|
Teehee 05 Jul 2010, 11:03
yep, offset.
I will need to count? there is not a math way to do that? |
|||
05 Jul 2010, 11:03 |
|
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.
|
|||
05 Jul 2010, 13:35 |
|
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).
|
|||
05 Jul 2010, 13:44 |
|
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. |
|||
05 Jul 2010, 13:52 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.