Writing a text editor

This is a discussion on Writing a text editor within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by liqueur theForgers win32 API Tutorial But this is based on C instead of C++ I need classes. ...

  1. #16
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    Quote Originally Posted by liqueur View Post
    But this is based on C instead of C++ I need classes. although it was very nice tutorial thanks for that

  2. #17
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,888
    Quote Originally Posted by behzad_shabani
    But this is based on C instead of C++ I need classes.
    Write your own classes then

    Alternatively, choose some C++ GUI library, e.g., FLTK, FOX, Gtkmm, Qt and wxWidgets, to name a few.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #18
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    Quote Originally Posted by laserlight View Post
    Alternatively, choose some C++ GUI library, e.g., FLTK, FOX, Gtkmm, Qt and wxWidgets, to name a few.
    What's these?

    I'm still reading that tutorials, if I had any question ask it in this topic or start a new topic?

  4. #19
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    Is it possible to write this text editor in console environment?
    like something I see in linux terminal?!!!!!!!!!

  5. #20
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by behzad_shabani View Post
    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.

  6. #21
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    Something like nano or vim or emacs? They are not any simpler (and probably more complex than average) GUI editors.

  7. #22
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,738
    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.

  8. #23
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #24
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    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.

  10. #25
    Registered User
    Join Date
    Dec 2008
    Posts
    65

    Smile Qt example program

    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!

  11. #26
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    Quote Originally Posted by Phyxashun View Post
    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!
    thanks a lot

    only one question! can I find the resource of header files that in this example used?

  12. #27
    Registered User
    Join Date
    Dec 2008
    Posts
    65

    Smile Using Qt

    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!

  13. #28
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    In this link, in MainWindow class, there is private slots:. What's this?

  14. #29
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    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

  15. #30
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Page 2 of 5 FirstFirst 12345 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 19
    Last Post: 05-30-2007, 05:47 PM
  2. dtextp: a codeforming text editor
    By dwks in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 05-18-2007, 07:11 AM
  3. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 03:49 PM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Text editor with font color
    By KingoftheWorld in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 01-15-2003, 12:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21