- #1
Eus
- 94
- 0
Hi Ho! ^^
I'm still learning programming in C (I'm still on my first year in Information Technology faculty)
Well, I'm interested in making something from scratch.
Hehehe... right now I'm curious about efficient text handling technique used in a text editor.
When creating a simple text editor, I create a temporary array of char in C.
It is: char *charInput[ 1000 ];
I hope the user doesn't type longer than 999 characters.
Then when the user press ENTER, I'll copy the content of the charInput into a file.
That's my idea to handle the text. I know this is a bad one because:
1. If the user input a text longer than 1000 (e.g. DNA chain code), my charInput can't accommodate it.
2. Time consuming of IO operation when the user press ENTER or ARROW key to navigate the screen because my program always read the file from HD.
3. charInput is such a waste of space because it reserves 1000 bytes in memory although the user only type 3 characters.
From my data structures course, I've an idea to create a linklist for every character which is typed. But this is a bad idea because it will waste more space for the pointer.
Yesterday I browsed through the Internet searching an efficient method for this problem. Unfortunately, I didn't find it.
But I've had some information.
According to you, does Emacs has the most efficient text handling method?
I've read several articles on Emacs and downloaded the source code from FSF.
I wonder how Emacs handles text using its buffer. The structure for buffer in buffer.h only contain some int variables. So, where's the text if it is not written directly to the file? (I read that Emacs buffer is on the main memory, not in HD)
So, could you please give me an information about how actually Emacs handles the text using the buffer?
Do you have any suggestions where I must go to find out more about text handling technique?
Mmm... sorry if I'm not straight to the point but I just want to explain my situation.
Thank you very much for helping me, guys!
I'm still learning programming in C (I'm still on my first year in Information Technology faculty)
Well, I'm interested in making something from scratch.
Hehehe... right now I'm curious about efficient text handling technique used in a text editor.
When creating a simple text editor, I create a temporary array of char in C.
It is: char *charInput[ 1000 ];
I hope the user doesn't type longer than 999 characters.
Then when the user press ENTER, I'll copy the content of the charInput into a file.
That's my idea to handle the text. I know this is a bad one because:
1. If the user input a text longer than 1000 (e.g. DNA chain code), my charInput can't accommodate it.
2. Time consuming of IO operation when the user press ENTER or ARROW key to navigate the screen because my program always read the file from HD.
3. charInput is such a waste of space because it reserves 1000 bytes in memory although the user only type 3 characters.
From my data structures course, I've an idea to create a linklist for every character which is typed. But this is a bad idea because it will waste more space for the pointer.
Yesterday I browsed through the Internet searching an efficient method for this problem. Unfortunately, I didn't find it.
But I've had some information.
According to you, does Emacs has the most efficient text handling method?
I've read several articles on Emacs and downloaded the source code from FSF.
I wonder how Emacs handles text using its buffer. The structure for buffer in buffer.h only contain some int variables. So, where's the text if it is not written directly to the file? (I read that Emacs buffer is on the main memory, not in HD)
So, could you please give me an information about how actually Emacs handles the text using the buffer?
Do you have any suggestions where I must go to find out more about text handling technique?
Mmm... sorry if I'm not straight to the point but I just want to explain my situation.
Thank you very much for helping me, guys!
Last edited: