im fiddling around with parsing text that is in a richedit control, just trimming the spaces for now. currently im getting each line of text with EM_GETLINE and then parsing it.
the problem{maybe not) is that i would need to write the parsed text back to the same line and overwrite the orginal line and do this all the way till end of text/lines. is this an efficient way to do this or is there a better method to do such a thing? should i read all the text into a single buffer, parsing the info and then write it back into the richedit control?
not sure if this post is clear enough. if not just say so.
the problem{maybe not) is that i would need to write the parsed text back to the same line and overwrite the orginal line and do this all the way till end of text/lines. is this an efficient way to do this or is there a better method to do such a thing? should i read all the text into a single buffer, parsing the info and then write it back into the richedit control?
not sure if this post is clear enough. if not just say so.
Sounds like a trim-trailing spaces feature...I can't think of better methods other than reading a line of text, parse, write it back. Putting the whole entire text of an edit control into a buffer would cost a lot of memory space...
Reading a line, parse... is much slower but would compensate for less memory usage.
Reading a line, parse... is much slower but would compensate for less memory usage.
Hi smurf
What about allocating a memory buffer and put the parsed text into it, line for line. Then when done parsing, replace the richedit content with the content of the memory buffer.
KetilO
What about allocating a memory buffer and put the parsed text into it, line for line. Then when done parsing, replace the richedit content with the content of the memory buffer.
KetilO
I'm working on a project which needs to do the same thing.
I find it's quicker and simpler to have all the text in a buffer do the operations on it then write it to the edit window...
I find it's quicker and simpler to have all the text in a buffer do the operations on it then write it to the edit window...
I have a similar routine in my mail client.
I read the whole text into a buffer first, then delete every occurence of a space after a space (in fact: doublespaces) and every space after / before a 0Ah / 0Dh.
Of course, you can switch this off :)
I read the whole text into a buffer first, then delete every occurence of a space after a space (in fact: doublespaces) and every space after / before a 0Ah / 0Dh.
Of course, you can switch this off :)
thanks for the suggestions. im gonna do some testing to see which is gonna work best. i can see where very large files can pose a memory problem when filling a single buffer.
another question:
to remove a space i would just put a zero into the address of the space?
another question:
to remove a space i would just put a zero into the address of the space?
That's what I do but the edit control loads data upto the first encountered NULL. so you'll have to filter out the extraneous NULLs which you added...
to remove a space i would just put a zero into the address of the space?
Use two buffers. Adding a 0h will, like MC said, terminate the string where you dont want it to be terminated :)
Smurf this won't by any chance have anything to do with converting header files would it?
no it doesnt MArtial_Code. if your interested though i have the commctrl.h, commdlg.h, winbase.h, winerror.h, wingdi.h, winuser.h and accctrl.h header files converted so far. im giving myself a break though from converting them because it takes alot of time. i left out the unicode crap though.
thanks bazik for clearing that up i was slightly confused on what i should do. now i realize that i just need to move anything i want over to the new buffer and leave out anything i dont want.
thanks bazik for clearing that up i was slightly confused on what i should do. now i realize that i just need to move anything i want over to the new buffer and leave out anything i dont want.