Has anybody here written a text editor before?
I'm thinking of doing a simple one for the kids to use on an old PC. I need something relatively 'friendly' for small kids to use, and none of my favorite old DOS text editors are suitable. This machine doesn't have a hard disk so a full blow word processor is not feasible either.
In my mind I'm thinking that each paragraph is represented by a string in memory, and the paragraphs are linked together by a linked list. This breaks the problem down a lot:
The downside to this approach is memory management. Using malloc and free naively could cause lots of fragmentation in memory. (There are lots of solutions to avoid this though.)
So, does anybody have experience with something like this?
Mike
I'm thinking of doing a simple one for the kids to use on an old PC. I need something relatively 'friendly' for small kids to use, and none of my favorite old DOS text editors are suitable. This machine doesn't have a hard disk so a full blow word processor is not feasible either.
In my mind I'm thinking that each paragraph is represented by a string in memory, and the paragraphs are linked together by a linked list. This breaks the problem down a lot:
- When rendering the screen, you walk the linked list and display each paragraph until you are past the end of the screen.
- Editing is always done within a single paragraph. That makes operations like inserts feasible to do .. you are just adjusting that string, not the entire file.
- Features like 'word wrap' wind up being implemented by the display routines. The contents of the paragraph remain unaffected by word wrap.
The downside to this approach is memory management. Using malloc and free naively could cause lots of fragmentation in memory. (There are lots of solutions to avoid this though.)
So, does anybody have experience with something like this?
Mike