First real program (text editor) 
Author Message
 First real program (text editor)

I'm working on a dos text editor in an attempt to increase my programing
skills and I have a problem. To be able to search through what has been
typed in, and to scroll, etc the characters have to be put into memory.
What is the best way to do this, I'm testing with an array now but that
has size limitations, would a linked list be a good alternative, it
seems like over kill to me. If has anyone has any ideas or knows a
source of information please let me know. Thank You



Thu, 24 Aug 2000 03:00:00 GMT  
 First real program (text editor)

: I'm working on a dos text editor in an attempt to increase my programing
: skills and I have a problem. To be able to search through what has been
: typed in, and to scroll, etc the characters have to be put into memory.
: What is the best way to do this, I'm testing with an array now but that
: has size limitations, would a linked list be a good alternative, it
: seems like over kill to me. If has anyone has any ideas or knows a
: source of information please let me know. Thank You

The simplest editor data structure is probably to keep the entire
file in memory, in an array either of lines of fixed maximum length
(which can wastes a lot of space) or of lines of specific size, with
memory handled by malloc and free.  The problem, of course, comes in
editing the lines since this may change their length.  Then you get
to fun stuff, shuffling strings between input buffers and the main
array.

A linked list is by no means overkill; probably a doubly-linked list
of structures containing eg. the line length, and one or more buffers
for line data, is the minimum you can get away with.  There are a
fair number of public domain editors around; take a look at their
code, and see what they do.

will



Fri, 25 Aug 2000 03:00:00 GMT  
 First real program (text editor)

Hi,
    I suppose u are trying to find out an effective way of actually storing
the typed text in the buffer. Well this is the basic structure u have to
settle down before u can actually write the program for the editor.

    One of the optimum ways for this is to have a linked list of arrays.
It goes like this

array
|
array
|
array
|
so on

where each row is an array and the rows are in a linked list.

This linked list should be doubly linked facilitating you in going up and
down easily.

Having a linked list horizontally increase memory usage leaps and bounds.
This seems to be a decent one.

The above approach is a simply way. U can actually have another approach
which is slightly more complex but space saving.
The rows(horizontal) can be actually a list of arrays of some size.(say
20).

array->array->array
|
array->array->array
|
array->array->array
|
so on

    The advantage of this approach is that u tend to save space on the
large arrays (say 256) which u would allocated for each row and allocate
only the amount which will be needed. The worst case space wastage will be
20 bytes/line whereas in the first case the worst case space wastage will
be 256

Hope this is of help

Vijay

Quote:

> I'm working on a dos text editor in an attempt to increase my programing
> skills and I have a problem. To be able to search through what has been
> typed in, and to scroll, etc the characters have to be put into memory.
> What is the best way to do this, I'm testing with an array now but that
> has size limitations, would a linked list be a good alternative, it
> seems like over kill to me. If has anyone has any ideas or knows a
> source of information please let me know. Thank You



Mon, 28 Aug 2000 03:00:00 GMT  
 First real program (text editor)



Quote:
>I'm working on a dos text editor in an attempt to increase my programing
>skills and I have a problem. To be able to search through what has been
>typed in, and to scroll, etc the characters have to be put into memory.
>What is the best way to do this, I'm testing with an array now but that
>has size limitations, would a linked list be a good alternative, it
>seems like over kill to me. If has anyone has any ideas or knows a
>source of information please let me know. Thank You

Try completing an easier project; it sounds like you need to acquire
more experience in the area of data representation techniques.


Tue, 29 Aug 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. C Text for the FIRST Programming Course

2. C Text for the FIRST Programming Course

3. Wtd: Text editor for C programming

4. Looking For Source Code For Small Text Editor Programs

5. Programming text editor in ANSI C

6. Programming a simple "text editor"

7. Programming a text editor with MFC, Please help

8. Text Editor (Justifying text)

9. How to Insert Text in Other Text Editor?

10. Associate custom data with text in a text editor

11. Static text real time change

12. How to create HTML Help Popup which contains real HTML text

 

 
Powered by phpBB® Forum Software