C
Chrisshia
i wanna build a text editor,and now idk how to editor a file when i open..for example..if i use cout to show the text's content..and ill cannot to move my cursor to the content and edit...
Sam said:It took me about a year to write a fully functional text
editor component
With regular expressions in C++11, it is more simple to
implement RE find and replace operations (I guess, I
have not tried C++11's regular expressions yet).
The better support for UTF-8 in C++11 also might help.
Chrisshia writes:
The answer to a question like that is going to be very different for every
platform in existence.
It does not take a year to write a text editor with an
interface that is akin to EDLIN of MS-DOS or ED/EX for
UNIX and only some basic fatures, it can even be written
in portable C++!
However, one needs at least a medium level of C++
competence.
One can start to write such an editor with a careful
separation of the model component (which I call the »edit
engine«) and the UI component.
The initial edit engine does not need to use fancy data
structures like gap buffers or ropes, just a single C++
::std::string. But it has an interface (a pure abstract
class in C++).
One can have a working editor in a day (a simple text
command UI for modifications to a single instance of
::std::string).
With regular expressions in C++11, it is more simple to
implement RE find and replace operations (I guess, I
have not tried C++11's regular expressions yet).
The better support for UTF-8 in C++11 also might help.
More operations can be added from day to day as seen fit.
Eventually, it is possible to add fancy editor data
structure like gap buffers (when ::std::string was observed
to be too slow) or a GUI, without changing the interface of
the edit engine.
Sam said:Sorry to be very blunt, and specific, but you will not be able to write
some kind of a text editor for a long, long time.
i wanna build a text editor,and now idk how to editor a file when i
open..for example..if i use cout to show the text's content..and ill
cannot to move my cursor to the content and edit...
In my experiments of training novices who learned object pascalThere's a simple editor at the end of _Programming Tools in
Pascal_, by Kernighan and Plauger. The book is very dated (as
one might suspect by Pascal), but the basic principles still
apply. Doing it in C++ would be even simpler---a month at the
most.
Here is how to write a simple text editor with FLTK:
That's more or less how *not* to write an editor. It starts at
the wrong end, and then gets lost in details before having
decided the generalities. (To be fair to the page: it looks to
me as though the "editor" was more of an excuse. That the
tutorial was about how to use FLTK, not how to write an editor
from scratch.)
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.