Skip to main content
GameDev.net gamedev.net
🔒 Locked

text editor

Started by Jeremiah Jul 2, 2000 at 5:00 PM 2 replies 550+ views
Original Post
Jeremiah
Jeremiah
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
Steven
Steven
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
Bulbasaur
Bulbasaur
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.