Write your own classes thenOriginally Posted by behzad_shabani
Alternatively, choose some C++ GUI library, e.g., FLTK, FOX, Gtkmm, Qt and wxWidgets, to name a few.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Is it possible to write this text editor in console environment?
like something I see in linux terminal?!!!!!!!!!
Of course you can. It's not as though there aren't a bunch of text editors that work in console environments.
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[10000]; 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" );
myEdit.saveFile( );
would in itself teach you a lot about text management and such like, which would be good stuff for your subsequent attempts.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
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:
http://trolltech.com/downloads/opensource/appdev
go here for the example:
http://doc.trolltech.com/4.4/mainwin...plication.html
Cheers!
There is a lot of information out there on using Qt:
Start with the Qt Documentation:
http://doc.trolltech.com/4.4/index.html
Then once you feel you understand the basics there is a great book available on Amazon:
http://www.amazon.com/Programming-Pr...0990251&sr=8-1
Start small and then work big!
Cheers!
In this link, in MainWindow class, there is private slots:. What's this?
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.
Kurt
I thought you wanted to try to write your own, rather than just configure someone else's "editor" template.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.