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

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
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 ?

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.

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.

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.

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

Notepad++ for some definitions of "simple".

You may also check out Scintilla editing component.

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.

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.

loot to the QT this is cross platform,HAVE RICHTEXT COMPONENT(widget).Writing first app in QT will give you actual knowledge.I recommend to learn QT by book

Related

C++ Code Autoformatting [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
After years of using Visual Studio for C++ programming, I am just now making the switch to linux for work. Everything is going great so far with one minor exception - gedit. After writing some code in a basic text editor, I am really starting to miss the auto formatting features that I have grown accustomed to.
Is there some type of "programmer's notepad" which would help with on-the-fly auto formatting or would I have to use a standard IDE for this functionality? Do most linux developers format their code manually using a basic text editor?
I am not looking for a full blown IDE, just something that will automatically format my C++ code as I type.
There is a pretty wide spectrum of text editors to IDEs on Linux. Here are a few that come to mind, from most "notepad-like" to most "VS-like".
In the "text editor" department (meaning no integrated compilation, build configs, debugger, etc.. just editing text / code):
gedit (most basic notepad-like app, IMO)
Kate (enhanced notepad but without "commands", and with nice auto-formatting and highlighting)
Emacs (enhanced notepad, with commands and advanced options, can be hard to use)
VIM (same category as emacs, can be hard to use, I don't like it)
Sublime-text (cool enhanced text editor, lots of neat features, but also a bit hard to master)
In the IDE department (meaning some build tools integration, and usually some code-completion and semantics analysis of code (detect variables, classes, etc.., can link to dox for them)):
Geany (lightweight IDE, not much more than an enhanced text editor with a "build" button)
NetBeans (average-sized IDE, quality is so-so, IMO)
Eclipse (average-sized IDE, easy to use, i.e., good for small projects, e.g., school assignments)
Qt Creator (average-to-large IDE, mainly aimed at working with Qt)
Code::Blocks (average-sized IDE, quality is so-so but OK, IMO)
KDevelop (an IDE a bit on the heavy side, but great features overall, and has the best code completion I have ever seen, beats Intellisense for C++ like a rented mule)
Of course, this is just a partial list, including only those I've been exposed to or have heard a lot about. There are probably many others out there.
Is there some type of "programmer's notepad" which would help with on-the-fly auto formatting or would I have to use a standard IDE for this functionality?
All the applications I've listed above in the "text editor" department all support this kind of feature (but I'm not 100% sure on Gedit, because it's kind of basic and I don't use it much, cause I don't like it). The only main jump you get as far as writing code from a text editor to an IDE is the code-completion / background-parser, i.e., the "Intellisense" type of features, including tooltip documentation on classes or functions. You cannot get that in a text editor because it would have to be aware of your build configuration (e.g., your cmake files or equivalent) to know where to pull headers from to be able to "understand" your code beyond trivial syntax rules, keywords and indentation.
Do most linux developers format their code manually using a basic text editor?
No. But it's a diverse world. Some like basic text editors where auto-indentation is about as much as you get, while others prefer feature-rich IDEs, and then, there are those who choose their text editor by how cool-looking the color themes are. ;)
And btw, there are also pretty powerful command-line code formatters, like clang-format, which can re-format your code in a much smarter way because it has an actual full-blown C++ compiler front-end parsing your code.
As far as I know, gedit have auto indent support, Try Edit -> Preferences -> Editor and check "Enable automatic indentation".
However, personally, I recommend you to use VIM, a professional text editor, although is not for everybody. Vim is not an IDE, just a text editor, but it's very powerful.
If vim seems too much by the moment, I think that kate is better than gedit.

Extracting page dimensions from a PDF with a C++ program [duplicate]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I want to be able to generate PDF output from my (native) C++ Windows application. Are there any free/open source libraries available to do this?
I looked at the answers to this question, but they mostly relate to .Net.
LibHaru
Haru is a free, cross platform,
open-sourced software library for
generating PDF written in ANSI-C. It
can work as both a static-library (.a,
.lib) and a shared-library (.so,
.dll).
Didn't try it myself, but maybe it can help you
I worked on a project that required a pdf report. After searching for online I found the PoDoFo library. Seemed very robust. I did not need all the features, so I created a wrapper to abstract away some of the complexity. Wasn't too difficult. You can find the library here:
http://podofo.sourceforge.net/
Enjoy!
If you're brave and willing to roll your own, you could start with a PostScript library and augment it to deal with PDF, taking advantage of Adobe's free online PDF reference.
jagpdf seems to be one of them. It is written in C++ but provides a C API.
It depends a bit on your needs. Some toolkits are better at drawing, others are better for writing text. Cairo has a pretty good for drawing (it support a wide range of screen and file types, including pdf), but it may not be ideal for good typography.
PDF Hummus.
see for http://pdfhummus.com/ - contains all required features for manipulation with PDF files except rendering.
LibHaru seems to be used by many.
A non-open source approach is: PDF Creator Pilot which provides more language options including C++, C#, Delphi, ASP, ASP.NET, VB, VB.NET, VBScript, PHP and Python
muPdf library looks very promising: http://mupdf.com/
There is also an open source viewer: http://blog.kowalczyk.info/software/sumatrapdf/free-pdf-reader.html
Try wkhtmltopdf
Software features
Cross platform.
Open source.
Convert any web pages into PDF documents using webkit.
You can add headers and footers.
TOC generation.
Batch mode conversions.
Can run on Linux server with an XServer (the X11 client libs must be installed).
Can be directly used by PHP or Python via bindings to libwkhtmltox.
http://wxcode.sourceforge.net/docs/wxpdfdoc/
Works with the wxWidgets library.

I want to make my own source code editor, what are the good choices to make? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I've had it of those dozens of editors which never provides simple things like:
distinguish type keywords and instruction keywords so I can put different colors on them.
being cross platform using a standard GUI lib like qt gtk etc (notepad++, yes, I almost hate you).
enough keyboard shortcut like duplicate line, comment selection, and a decent find-replace.
Decent task-easing features like single-click-on-the-number-line-margin to select the entire line.
Scintilla or another good-enough lexer that highlights enough different things, because brain-compiling code is one thing, quickly identify with the eyes what is what is something I find important.
I just want to support very basic languages like C, C++, maybe Python, not HTML or CSS.
Is Scintilla a good choice to just highlight those languages, and is a lexer really necessary ?
Isn't QT enough to program a text editor such as the one I want to do ? I know there is QScintilla, but is there a reason I shouldn't use a lib that integrates a lexer ? Why is Scintilla such a good lib ?
Is QT a good choice for such an editor ? (I also want to hard embed ProFont in the editor to kill any reluctant font problem between OSes).
EDIT:
In short, I want to make an editor, only with the same syntax highlight features of notepad++. That's my main goal, and the use of QScintilla might be a little harder than I thought...
EDIT2:
Well I found textadept, it's not so known but is quite awesome. I didn't manage to make my lexer, since I have other to do which I do under windows, unfortunately it's slow on the mac. Apparently there isn't any Scite official build for the mac.
C++ is not a "very basic language" by any stretch of the imagination.
Why do you really want to do this? There are SOOO many open source code editors out there.
If you must write your own editor, I suggest looking at the other open source editors and examine which pieces you port to your editor.
Porting pieces of existing working and tested code is usually much better than writing your own code and debugging it.
After perusing a couple serious open source editors: Emacs, Eclips, CodeBlocks, CodeLight, etc., I believe you will start changing your mind about writing an editor from scratch.
-- Thomas Matthews
My Info
If you really want to do this (and it sounds like a lot of work) I would look at ANTLR for parsing the code. You may get some ideas from their ANTLRWorks display.
To link the parse tree to a display could be a fair amount of work so I'd see what an IDE platform such as Eclipse has to offer
Are you OK with Java?
If so, go for Eclipse technologies: SWT and JFace. The latter provides you with org.eclipse.jface.text package with a lot of features. Then you can roll own editor easily basing on that. (I prefer Eclipse-based editors to Scintilla-based, I believe they tend to be more advanced and feature-rich, but that's my personal opinion.)
But then, you might want to go a step further and use the Eclipse RCP framework for you application... But then why not use the Eclipse IDE itself and just add whatever you want as plug-ins.
The Eclipse codebase is huge and it's up to you how much you want to reuse.
I would expend some effort experimenting with the emacs colour theme package and the various langauge modes; see if you can bend the lisp to do what you want. You almost certainly can. to my mind emacs and a bit of effort on your part will get you your ultimate editor (remember emacs is really just a DIY editor toolkit). If you cant bend emacs into the shape you want you will be well placed to expend the effort in writing your own.
I have tried to do something similar myself for a project I'm working on at the moment, I looked into the QScintilla and had to remove it from my project because when you embedded inside a QGraphicsView I can't control the resolution of the widgets image, it seems to paint the text as an image and that's what we see, I played with increasing the smoothness of the QFont and that improved it but still a no-go.
So I found a simple code editor inside QT's code base it comes with every installation of QT if you look
into:
C:\Qt\4.7.3\src\scripttools\debugging\qscriptedit.h
C:\Qt\4.7.3\src\scripttools\debugging\qscriptedit.cpp
If you go to the source code of OpenShapeFactory where I'm trying to embed a Code Editor: check how I got the syntax Highlighter and the autocomplete :
this widget uses the qscriptedit widget that ships with qt, you can add your own keywords to the syntax hightlighter from a file as well as for the auto-complete dropdownlist.
this is the header, scriptwidget.h and the implementation scriptwidget.cpp are available as part of the whole project code.
the next stage is to look into the QTCreator and see the code they already have all if not most of these features after you get to compile their version, just find where to add your little mods and you might be getting closer to the simple code editor.
I wish you the best of luck on this direction and if you find a solution please send it over, :)
heads-up keep a lookout for the repository link above, if I find a way of making it first, I might chase you to the answer.
Like everyone else is saying, it's probably more trouble than it's worth, but if you really want to do it, Qt's a good choice since it's cross platform. Use QSyntaxHighlighter to do your keyword/type highlighting, and take full advantage Qt's support for keyboard shortcuts.
use something like C, QT and Lua for the scripting engine.

C++ Library to Convert HTML to PDF? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am looking for a C/C++ library to convert HTML (Actually XHTML + CSS) documents to PDF.
It is for commercial use and source would be nice but not essential.
Anybody have any recommendations or experience doing this?
UPDATE: To clarify, I am targeting the Windows platform only. I am developing with Borland C++ Builder 2006, but the library does not have to be a VCL component.
Many thanks in advance.
Steve.
To do that I have successfully used wkhtmltopdf.
Uses webkit and can be called from command line or as a static library. It's great and simply to use.
wkhtmltopdf website
OpensSource (LGPL) and free!
Hope it can help
Wouuld CLI applications do? If memory fails me not, GNU Ghostscript had utilities html2ps and ps2pdf. Source should be available too.
This is probably overkill, but WebKit for rendering, with Cairo for the backend could do it. WebKit is a pretty big library, though.
If you are looking for something pre-made, I found wkhtmltopdf after some quick searching. It uses WebKit and Qt for rendering, which is and even larger combination of libraries.
Just to bump this, I have evaluated both VisPDF and PDFDoc Scout and will probably go with PDFDoc Scout as it can format HTML input.
Thanks for everybody else's input.
I tried HotPDF library, it is easy to use and good enough.
CutePDF is a free PDF writer that works as a virtual printer. I guess you could use this in conjunction with anything that could render your HTML.
Have a look at PrinceXML.
It's definately the best HTML/CSS to PDF converter out there, although it's not free (But hey, your programming is not free either, so if it saves you 10 hours of work, you're home free.)
Oh yeah, did i mention that this is the first (and probably only) HTML2PDF solution that does full ACID2!?!?!
http://princexml.com/samples/

Open source PDF library for C/C++ application? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I want to be able to generate PDF output from my (native) C++ Windows application. Are there any free/open source libraries available to do this?
I looked at the answers to this question, but they mostly relate to .Net.
LibHaru
Haru is a free, cross platform,
open-sourced software library for
generating PDF written in ANSI-C. It
can work as both a static-library (.a,
.lib) and a shared-library (.so,
.dll).
Didn't try it myself, but maybe it can help you
I worked on a project that required a pdf report. After searching for online I found the PoDoFo library. Seemed very robust. I did not need all the features, so I created a wrapper to abstract away some of the complexity. Wasn't too difficult. You can find the library here:
http://podofo.sourceforge.net/
Enjoy!
If you're brave and willing to roll your own, you could start with a PostScript library and augment it to deal with PDF, taking advantage of Adobe's free online PDF reference.
jagpdf seems to be one of them. It is written in C++ but provides a C API.
It depends a bit on your needs. Some toolkits are better at drawing, others are better for writing text. Cairo has a pretty good for drawing (it support a wide range of screen and file types, including pdf), but it may not be ideal for good typography.
PDF Hummus.
see for http://pdfhummus.com/ - contains all required features for manipulation with PDF files except rendering.
LibHaru seems to be used by many.
A non-open source approach is: PDF Creator Pilot which provides more language options including C++, C#, Delphi, ASP, ASP.NET, VB, VB.NET, VBScript, PHP and Python
muPdf library looks very promising: http://mupdf.com/
There is also an open source viewer: http://blog.kowalczyk.info/software/sumatrapdf/free-pdf-reader.html
Try wkhtmltopdf
Software features
Cross platform.
Open source.
Convert any web pages into PDF documents using webkit.
You can add headers and footers.
TOC generation.
Batch mode conversions.
Can run on Linux server with an XServer (the X11 client libs must be installed).
Can be directly used by PHP or Python via bindings to libwkhtmltox.
http://wxcode.sourceforge.net/docs/wxpdfdoc/
Works with the wxWidgets library.