Re: Text Editor RIGHT-->LEFT
- Posted by David Cuny <HW1.DCUNY at HW1.CAHWNET.GOV> Jan 24, 1997
- 1288 views
*** Reply to note of 01/24/97 08:55 the editor's complex because there are a lot of little things that an editor needs to do. for example, do you want to wrap words to the next line when the user reaches the end of a line? this is complex: you read the text one word at a time, and wrap to the next line if the current word does not fit on the line. but if the word is longer than the line, you have to break it. it's hard to write an example that does not get complex *very* fast. here are some hints, though: first, decide how you will internally represent the information. will it be line based, word based, character based, or somthing else. make sure the way you represent the information will allow you to do things you will want to do in the editor: cut and paste, search, etc. for example, storing text as a sequence of lines is fine for a editor if it's going to be used for writing computer programs. but if it's going to be used for word processing, you probably need a better level of granularity. next, write the display routine. put some data in the structure, and display it on the screen. then position the cursor. now you can write the cursor positioning routines: move the cursor up a line, down a line, forward and backwards. the key loop is simple: while not QUIT_PROGRAM do char = wait_key() -- wait for a key if char = UP_ARROW then -- up arrow code elsif char = DOWN_ARROW then -- down arrow code ... end if end while that's all there is to it. you just need to keep adding commands to the key loop. good luck! -- david cuny