Is it possible to write this text editor in console environment?
like something I see in linux terminal?!!!!!!!!!
If you want something like "normal" editing (moving around, replacing characters, etc.) you may want to look at the curses library. Our edlin challenge that mats referred to earlier didn't have such, but of course that's rather limiting.
Something like nano or vim or emacs? They are not any simpler (and probably more complex than average) GUI editors.
Like I told you, yeah it is. Have you ever used something like vi before? You could make a stripped down version of that with files and strings basically (though it might end up closer to an ed clone...). Anyway, you need to decide how you want to edit the files.
I sound like a broken record, maybe, but vi has interactive modes and you can do things like text substitution, delete, and insert text line by line and across the whole file. You need to work out the input that the user should provide to make these things happen, and how to process the results before you begin writing anything in C code. vi, for example, has a lot of obscure commands.
If you want to write a console text editor you might wind up using something like ncurses for output, so the user can read the file.
Any inkling that this is nontrivial yet? Congratulations on starting your first project, you'll be learning a lot. Get working on the specification.
The first steps are to make sure you have the right data structures to support all the editing operations you need to perform.
char buff; may seem easy enough, but consider the amount of memory you need to move around when you say delete a line, or do a global search/replace.
Whether you end up using
gotoxy() from conio.h
moveto() from ncurses.h, or
setTextPosition() from some GUI toolkit should (if you've done the design properly) have no impact on your core editor.
Even getting as far as say being able to do
myEdit.loadFile( "test.txt" );
myEdit.insertLine( 3, "hello world" );
would in itself teach you a lot about text management and such like, which would be good stuff for your subsequent attempts.
thanks all for help and giving me hope, specially to whiteflags and Salem.
I've found several Tutorials about win32 API. but more of them was using some new and complex codes, I hope that with your helps I will able to do my first C++ project.
If download and install Qt, there is a simple text editor in the examples in the documentation:
go here to download Qt:
go here for the example:
There is a lot of information out there on using Qt:
Start with the Qt Documentation:
Then once you feel you understand the basics there is a great book available on Amazon:
Start small and then work big!
See, That's the reason that I don't like QT very much.
Source coude written for the Qt library is'nt real C++ code.
It gets preprocessed by some compiler that generates the actual c++ code.
'slots' is one of the additional keywords that this precompiler understands.
I thought you wanted to try to write your own, rather than just configure someone else's "editor" template.