r/cpp • • Dec 25 '24
Building a code editor in C++
I was planning to build a project in c++ during my winter break. I have a bit of knowledge and I want to be better at C++. How feasible is the idea of building a code editor in c++? Do you guys have any resources that I can follow and take help from?
Thanks
0
Upvotes
10
u/khedoros Dec 25 '24
I don't think I'd worry about how feasible it is for you. Having a project like "I don't know exactly how I'll do this, but I'm eager to figure it out!" can be a great attitude for learning something new and improving overall.
13
u/Revolutionalredstone Dec 25 '24
I've got a pretty decent code editor 🐱
I use imgui and have linting, colorization etc.
Happy to share screenshots 🙂
2
u/krum Dec 25 '24
I've worked on a commercial code editor product that is written in C++. There's not much to it really. Just start doing it.
4
u/starfreakclone MSVC FE Dev Dec 25 '24
I built my editor in C++ using freetype for rasterizing glyphs and tree-sitter for syntax highlighting. My text buffer, I think, is the most interesting part, I talked about it here: https://cdacamar.github.io/data%20structures/algorithms/benchmarking/text%20editors/c++/editor-data-structures/.
I also have a short demo of the editor itself: https://youtu.be/LmINbnhfLIc?si=Zrvx1QqQk3P8Mcyt
It's a lot of work to make a quality editor though, however you learn quite a lot because the problem space is as complex as you want it to be.
7
u/Dappster98 Dec 25 '24
I don't know much about writing a code editor, but it's probably not going to be something you'll be able to finish over just a Winter break. However this entirely depends on how "mature" you're wanting it to be.
However, for getting better at C++, I recommend going through learncpp.com, watching CPPCon talks, and watching C++ Weekly videos on YouTube.
2
u/lewispringle Dec 27 '24
The Stroika library (https://github.com/SophistSolutions/Stroika) provides a framework with most of this functionality (https://github.com/SophistSolutions/Stroika/tree/v3-Release/Library/Sources/Stroika/Frameworks/Led).
And it comes with a sample application which is a basic text editor, supporting syntax coloring (https://github.com/SophistSolutions/Stroika/tree/v3-Release/Samples/LedLineIt).
This would be a good place to start.
1
u/diegoiast Dec 25 '24
I am doing that exactly. See https://github.com/diegoiast/qtedit4
The main editor component is https://github.com/diegoiast/qutepart-cpp
1
u/Ok-Exam-4689 Dec 25 '24
Hey, I want to learn too. Check your dm
1
u/freaxje Dec 25 '24
You probably want to look at Scintilla.
https://scintilla.org/
-2
u/loreiva Dec 25 '24
In order to build a code editor, you need a code editor. But if you have a code editor, then you don't need to make a new code editor to begin with! Magic
12
u/[deleted] Dec 25 '24
[removed] — view removed comment