Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to write a text editor in c++ [closed]

Tags:

c++

I learned c++ on and off for several times but never write a real apps using it . long time I've been thinking that writing a text editor will be something very interesting , now I am looking for a simple but decent text editor written in c or c++ from which I can get inspiration and learn how to write a text editor by myself.

Could you guys recommend a "simple but decent" text editor written in c or c++ to me ?

like image 238
Haiyuan Zhang Avatar asked Oct 05 '09 13:10

Haiyuan Zhang


People also ask

What is text editor in C?

A text editor is a computer program that lets a user enter, change, store, and usually print text (characters and numbers, each encoded by the computer and its input and output devices, arranged to have meaning to users or to other programs).

Which editor should I use for C?

Atom. Atom is a modern, powerful IDE, which can be used for many computer programming languages including C . It is one of the highly configurable text editors. Atom is a desktop application built using web technologies.

What does editor do in C?

Editors and Its types in System Programming in C++ Editors are basically computer programs that are utilised to edit files on a computer. The provide environment to a programmer to create, edit, update, format a document in any order he/she wants to.


8 Answers

You might want to look at Zile or nvi. Both are fairly simple; Zile is Emacs-like, and nvi is the Berkeley vi. Another to look at would be Nano, a simple text editor that is designed to be easy for new users. I don't know how clean the code is on any of these, though.

I would also recommend reading The Craft of Text Editing: Emacs for the Modern World. This book surveys many of the specific problems that have to be dealt with in writing a text editor along with approaches, strategies, and algorithms for solving them. Its content should be relevant and useful even if your editor isn't going to look much like Emacs at all.

like image 145
Michael Ekstrand Avatar answered Oct 24 '22 19:10

Michael Ekstrand


Well what you want to see sounds more like a tutorial than an actual application (I think applications like Notepad++ will be a lot to dive into in the beginning). Since you don't mention any environment you want to program in, you could check out the QT Text Editor Demo. QT is a cross platform GUI Toolkit so you are not bound to a specific operating system but probably harder to setup then a Visual Studio environment in Windows.

For Windows only you might want to think about digging more into the .NET platform (e.g. C#) as suggested in this question. It doesn't help learning C++ but it makes GUI development a hell of a lot easier.

like image 26
Daff Avatar answered Oct 24 '22 18:10

Daff


Get the vi. There is a big lack of true editors like vi/vim ;) I mean there is a plenty of editors like notepad/notepad++, but few editors which have separate command/control mode. So You could look at the vi sources to inspire yourself and introduce something revolutionary.

like image 44
bua Avatar answered Oct 24 '22 19:10

bua


Notepad++ is an excellent open source editor written in C++.

like image 31
luke Avatar answered Oct 24 '22 17:10

luke


Notepad++ for some definitions of "simple".

like image 40
Dominic Rodger Avatar answered Oct 24 '22 18:10

Dominic Rodger


You may also check out Scintilla editing component.

like image 26
Nick Dandoulakis Avatar answered Oct 24 '22 18:10

Nick Dandoulakis


JuffEd. It is written in C++, cross platform due to usage of Qt and QScintilla. Notepad++ uses also Scintilla text editor component, but its limited only to Windows platform.

like image 40
Cristian Adam Avatar answered Oct 24 '22 19:10

Cristian Adam


What sort of text editor would you like to make?

First question is will this be GUI or Console based?

GUI based, do you want to make something like Notepad? And on what platform? If it's MS Windows based, might I recommend picking up on MFC?

If it's text based, there are many open source solutions you can get into. My recommendation is to look at the simplest of editors like ed or something.

like image 35
Daniel Avatar answered Oct 24 '22 17:10

Daniel