A code editor component for Qt6/C++. Easy to embed into your build system, packed with features.
Does your application need a code editor component? Display source code? This library is easy to integrate, easy to use.
auto qutepart = new Qutepart::Qutepart(window);
// optionally - set a theme
auto theme = new Qutepart::Theme;
theme->loadTheme(":/qutepart/themes/github-light.theme");
qutepart.setTheme(theme);
// It's a normal QPlainTextEditor - all known methods exist
auto font = qutepart.font();
font.setPointSize(12);
font.setFamily("Monospace");
qutepart.setFont(font);
// load text, and set an highlighter:
auto file = QFile(filePath);
auto langInfo = Qutepart::chooseLanguage(QString(), QString(), filePath);
if (langInfo.isValid()) {
qutepart->setHighlighter(langInfo.id);
qutepart->setIndentAlgorithm(langInfo.indentAlg);
}
file.open(QIODevice::ReadOnly);
auto data = file.readAll();
auto text = QString::fromUtf8(data);
qutepart->setPlainText(text);
All features are configurable
- C++ native (needs a compiler with C++17 support).
- Uses Qt6, no 3rd parties.
- MIT licensed (can be used in closed source applications).
- Derives QPlainTextEdit.
- Follows dark themes.
- Supported on Windows, Linux and OSX (probably BSD, untested - basically all platforms supported by Qt6).
- Good unicode support:sSupports BIDI (Arabic, Farsi, Hebrew), CJK and Hindu lanaguages.
- Integration is a simple as adding a few lines in your CMake file.
- Uses Kate syntax highligher, with more than 380 supported languages.
- Theme support, again using the Kate themes.
- Syntax/themes baked into the library (no need to install files on your app).
- Undo/redo stack.
- Insert/override text (defaults to insert, modify by pressing "Insert" key)
- Copy/paste/cut/del (selection and current word/line).
- Selection of current word: when the cursor is on a word, this word will be marked on all the document.
- ... with a timeout. Only after 300 msec you move to a word, not to spam the CPU with useless tasks.
- Matchin brackets are highlighedside panel .
- Auto brackets: when you press any of
[({
the corresponding closing bracket is added. - Mark the current line with a different background.
- Line numbers side panel.
- Current line in side panel is marked in bold.
- ... and if you have some selection - that selection will be wrapped with the corresponding bracket.
- Visibile whitepsace: whitespace is visible only at the end or beginning or a line, and in the middle - only if you have more than 2 spaces.
- Smart end/home: if you have spaces at the end of a line, you can navigate to the logical end (ignoring the whitepsace) or the last character of a line.
- Move line/selection up/down - without clipboard (alt+up, alt+down).
- Duplicate selection, or current line (alt+d).
- Can display margin (at line 80 by default).
- Shows indentation markers.
- Markers for long lines.
- Bookmarks (you can bookmark lines, and then move to them).
- Join lines (control+j).
- Change word/selection to UPPER CASE/lower case (or toggle).
- Toggle comment (for supported languages) (control+]).
- Text completion (from language keywords, and document).
- When saving, honors original line edningq (CR, CR/LN), but can be overritten.
- Zoom document (change font size on the fly).
- Change indentation of text (tab/shift+tab).
- Preview side mini-map.
Planned fetatures
- Multiple cursors.
- Toggle folding sections of code/text.
- Markdown specific intentator.
- Spell check.
To see the API in action, see editor.
- C++17 compiler (tested under MSVC 2022, GCC 13, Clang17)
- CMake
- Qt 6.7
Add this to your CMakeLists.txt
CPMAddPackage("gh:diegoiast/qutepart-cpp#main")
add_executable(app ...)
target_link_libraries(app PUBLIC ... qutepart ...)
If you are not using CPM, you can use directly fetch content:
include(FetchContent)
FetchContent_Declare(
qutepart
GIT_REPOSITORY https://github.com/diegoiast/qutepart-cpp.git
GIT_TAG main
)
FetchContent_MakeAvailable(qutepart)
add_executable(app ...)
target_link_libraries(app PUBLIC ... qutepart ...)
Andrei Kopats Diego Iastrubni [email protected]
Kate and Katepart (an editor component) is really cool software. The Kate authors and community have created, probably, the biggest set of highlighters and indenters for programming languages.
- Qutepart uses Kate syntax highlighters (XML files) and themes.
- Qutepart contains a port from Javascript to C++ of Kate indenters
- Qutepart doesn't contain Katepart code.
Nothing is wrong with Katepart. Qutepart has been created to enable reusing highlighters and indenters in projects where a KDE dependency is not acceptable.
Why not using the syntax highlighter from kate? Because alternatives are better. Now Kate has another implementation. This project's goal is to make a full blown editor component, not only a syntax highlighter.
MIT