qt-widgets / qtsourceview Goto Github PK
View Code? Open in Web Editor NEWThis project forked from elcuco/qtsourceview
This source is a collection of libraries aimed for developing a text editor in Qt5
License: Other
This project forked from elcuco/qtsourceview
This source is a collection of libraries aimed for developing a text editor in Qt5
License: Other
This source is a collection of libraries aimed for developing a text editor. * QsvSyntaxHighlighter - a QSyntaxHighlighter implementation based on GtkSourceView * QsvTextEdit - a drop in replacement for Q{Plain}TextEdit aimed for developers * Qate - the next generation syntax highlighter based on Kate definitions QsvSyntaxHighlighter -------------------- This is a demo of a syntax highlighter done in C++/Qt. The code is extraeamly non optimized, but it does work most of the time. The class is very slow, so please don't use it on large files. The syntax highlighter definitions are the same ones used by the gtksourceview library for gtk. The difinitions are passed to a class which does the highligting. This means that the engine is not aware of what he is coloring, and adding new languages is as trivial as adding new XML to the langs directory. There are 2 abstract factories on this code: 1) highligh factory: Loads a directory which *.lang files, and you can query it later, and it will return you the languae definition for your language (you give it a file name and it returns a pointer to the language definition you need to apply to the syntax highliter) 2) colors factory: The language definition conatins class names for coloring, and not the actual style used on screen. To convert that name into color + font style we use this class. While this is not trully an abstract factory, in the future it may change. To use this code in your application: 1) Generate a colors definition class and load a file: QsvColorDefFactory *defaultColors = new QsvColorDefFactory( dataPath + "/data/colors/kate.xml" ); 2) Intiailize the highlight factory with a directory to load the language definitions from: QsvLangDefFactory::getInstanse()->loadDirectory( dataPath + "/data/langs/" ) 3) Query for a language definition: QsvLangDef *lang = QsvLangDefFactory::getInstanse()->getHighlight( fileName ); Another alternative, is to load the language definition yourself, in this case step (2) is not needed: QsvLangDef *lang = new QsvLangDef( dataPath + "/data/langs/cpp.lang" ); 4) Generate a QSyntaxHighliter: QSyntaxHighliter *highlight = new QsvSyntaxHighlighter( textEdit, defColors, langCpp ); QsvTextEdit ----------- The core of a text editor is an editor control. Using QTextEdit (or QPlainTextEdit) is not enough. You can use QsvTextEdit instead which consists: - line numbering - current line marking - marking lines with different background - bookmarks - find/replace/goto line - all as inline dialogs - display messages on the top of the editor - theme support Qate ---- The Kate project created a set of syntax highlight definitions for almost all languages. This library can load those definitions and you can use them on your Q{Plain}TextEdit of QsvTextEdit to get a powerful editor. The code was taken from the QtCreator and ported to be a standalone code. The code was forked from QtCreator's code may 2011 (!) and ported to Qt5 (quite easily I admit). All code is licensed under the terms of the LGPL. The tests available in this release are taken from the Kate project. The color definitions are self made, and released to the public domain (the syntax is part of the kate syntax definitions) The highlight definitions are part of the gtksourceview library: http://gtksourceview.sourceforge.net/ The idea for highliting the current line was discussed here: http://www.qtcentre.org/forum/showthread.php?t=456 The code does not contain anything from the GTK source view library. In fact, I have not still seen the code, nor used it once. I am planing of pikking inside when my library is stable and usable enough, to see how they did it, maybe I can get some better ideas, maybe they can :) Diego Iastrubni <[email protected]>, 4-2-2006, 22-7-2006 Diego Iastrubni <[email protected]>, 17-08-2018
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.