Git Product home page Git Product logo

qt-widgets / qtsourceview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from elcuco/qtsourceview

0.0 1.0 0.0 970 KB

This source is a collection of libraries aimed for developing a text editor in Qt5

License: Other

CMake 1.35% Shell 1.08% QMake 0.97% C++ 92.81% C 0.81% VHDL 0.15% CSS 0.16% Pascal 0.08% PHP 0.10% Perl 0.15% Tcl 0.18% TeX 0.24% XSLT 0.74% MATLAB 0.43% JavaScript 0.74%

qtsourceview's Introduction

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

qtsourceview's People

Contributors

elcuco avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.