text editor
i am creating an awesome AI for my game, and i want to have one program where you would design the enemy.
part of this is writing the the actual brains in a scripting language, so i want the program to allow you to do this ... so i need a text editor.
my problems:
1) lets say i have a buffer 5K big, and the users cursor is in the 3487th position of the buffer, and they hit the letter "L", well, this should add the letter "L" to the 3487th position, and push everything after it back one space in the buffer ... whats the fastest way to do this?
2) user hits backspace, this should remove the character where the cursor is at, and pull everything after it forward one space in the buffer ... whats the fastest way to do this?
3) is having a buffer the best way to do this? any other better method?
http://fakemind.com
If your looking for a good script editor look on CodeGuru.com for Crystal Edit, it gives you a text editor with syntax hilighting, and the source is included for free.
When I find my code in tons of trouble,Friends and colleages come to me,Speaking words of wisdom:"Write in C."My Web Site
quote:
1) lets say i have a buffer 5K big, and the users cursor is in the 3487th position of the buffer, and they hit the letter "L", well, this should add the letter "L" to the 3487th position, and push everything after it back one space in the buffer ... whats the fastest way to do this?
...user hits backspace, this should remove the character where the cursor is at...
If you''re talking about the ability of text insetion as apposed to just typing a single line, why not try an array of strings, you could set a maximum line length (256, for example).Every time you go to a new line, add another string to the array.This is not the most memory effeciant way to do it, but it would be faster (way faster) then copying a block of text, which might be huge, one character ahead for every keystroke.
Or possibly not, I never tried to create an editor before.
----------
meh
----------meh
July 06, 2000 05:27 PM
How big are the files you''re talking about? Shifting 3487 characters, using memcpy in C or the equivalent in another language, takes *microseconds* on a 386 or better. It will take longer to update the display than to do ths shift. If you''re looking at files that are modestly sized, then this technique is just fine.
Don''t worry about micro-optimzing until you have working code and discover there''s a performance problem.
Don''t worry about micro-optimzing until you have working code and discover there''s a performance problem.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement