GithubHelp home page GithubHelp logo

waqar144 / qsourcehighlite Goto Github PK

View Code? Open in Web Editor NEW
69.0 2.0 19.0 474 KB

Lightweight syntax highlighter written in Qt

License: MIT License

QMake 0.22% C++ 99.78%
qt qt5 qt5-gui qt5-applications syntax-highlighting syntax-highlighter parser cpp cxx cplusplus

qsourcehighlite's Introduction

Background

It started as an internal component of qmarkdowntextedit to provide syntax highlighting(kind of like highlight.js). Ithttps://github.com/pbek/qmarkdowntextedit is currently being used in QOwnNotes and you can test it there or run the demo here.

It doesn't use any regex because I want it to be fast. It can currently load a 100,000 lines of source code in ~0.4 seconds on my 4th Gen Intel Core i5 4300U.

Screenshot

Cpp

Usage

Add the .pri file to your project. Then initialize it like this:

highlighter = new QSourceHighliter(plainTextEdit->document());
highlighter->setCurrentLanguage(QSourceHighlighter::CodeCpp);

Themes

Currently there is only one theme 'Monokai' apart from the one that is created during highlighter initialization. More themes will be added soon. You can add more themes in QSourceHighlighterThemes.

Supported Languages

Currently the following languages are supported (more being added):

  • Bash script
  • C
  • C++
  • C#
  • CMake
  • CSS
  • Go
  • Html
  • INI
  • Java
  • Javascript
  • JSON
  • Make
  • PHP
  • Python
  • QML
  • Rust
  • SQL
  • Typescript
  • V lang
  • XML
  • YAML
  • Houdini Vex

Adding more languages

If you want to add a language, collect the language data like keywords and types and add it to the languagedata.h file. For some languages it may not work, so create an issue and I will write a separate parser for that language.

Dependencies

It has no dependency except Qt ofcourse. It should work with any Qt version > 5 but if it fails please create an issue.

Building

Load the project into Qt Creator and click run.

LICENSE

MIT License

qsourcehighlite's People

Contributors

alemariusnexus avatar ensisoft avatar waqar144 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

qsourcehighlite's Issues

Multiple block comments in same line cause infinite loop

A line like:
if (myid == 0 && rep == reps - 1 /* begin lobpcg */ && !lobpcgFlag /* end lobpcg */)
causes an infinite loop when highlighting comments.
As the end of the first comment is found when looking for the end of the second comment.

Question about the license

Hi, this looks great but the GPL license is bit of a downer. Any chance of LGPL or MIT ? If so I'd be interested to extend and contribute Lua support. Thanks

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.