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);
// Set an highlighter:
auto langInfo = Qutepart::chooseLanguage(QString(), QString(), filePath);
if (langInfo.isValid()) {
qutepart->setHighlighter(langInfo.id);
qutepart->setIndentAlgorithm(langInfo.indentAlg);
}
// Load text to the editor
auto file = QFile(filePath);
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). Including ARM64.
- Good Unicode support: Supports BIDI (Arabic, Farsi, Hebrew), CJK and Hindu languages.
- Integration is a simple as adding a few lines in your CMake file.
- Uses Kate syntax highlighter, 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.
- Matching brackets are highlighted side 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.
- Visible white-space: white-space 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 white-space) 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).
- Soft word wrap can be enabled at the margin (when you type after that line - text continues on the next line.
- Shows indentation markers.
- Multiple cursors (selection, copy, paste, moving).
- 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 ending (CR, CR/LN), but can be overwritten.
- Zoom document (change font size on the fly).
- Change indentation of text (tab/shift+tab).
- Preview side mini-map.
- Toogle folding.
- Smart toggle folding - when folding a nested fold, parent level will get folded.
auto f() { while (){ if... - assume you are onif, this will get folded, thenwhilethenf(), all with the same shortcut key - Top level folding. On Java, will fold all classes, keeping first level open (same for XML, top level fold will be open, but the first childs gets folded).
Planned features
- Spell check.
- Inline marking (linter warnings, debugger hints etc).
- Markdown specific indentator.
To see the API in action, see editor.
- C++17 compiler (tested under MSVC 2022, GCC 13, Clang17 or newer versions)
- CMake
- Qt 6.8
Add this to your CMakeLists.txt
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 ...)Or if you are using CPM:
CPMAddPackage("gh:diegoiast/qutepart-cpp#main")
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
