├── scrot.png ├── sqriptor256.png ├── colors ├── README ├── tex.cpp ├── properties.cpp ├── makefile.cpp ├── spice.cpp ├── batch.cpp ├── matlab.cpp ├── yaml.cpp ├── edifact.cpp ├── diff.cpp ├── bash.cpp ├── avs.cpp ├── json.cpp ├── cmake.cpp ├── pascal.cpp ├── vhdl.cpp ├── po.cpp ├── fortran77.cpp ├── pov.cpp ├── postscript.cpp ├── lua.cpp ├── verilog.cpp ├── d.cpp ├── tcl.cpp ├── sql.cpp ├── python.cpp ├── css.cpp ├── coffeescript.cpp ├── ruby.cpp ├── cpp.cpp ├── markdown.cpp ├── perl.cpp └── html.cpp ├── sqriptor.desktop ├── sqriptor.pro ├── PKGBUILD ├── PKGBUILD.aur ├── scrollbar.h ├── lexer ├── journal.h ├── xorglog.h ├── awk.h ├── markdown2.h ├── nim.h ├── glsl.h ├── rust.h ├── cppqt.h ├── qtpro.h ├── fontconfig.h ├── xorg.h ├── nim.cpp ├── pkgbuild.h ├── lisp.h ├── rust.cpp ├── awk.cpp ├── pkgbuild.cpp ├── fontconfig.cpp ├── glsl.cpp ├── xorglog.cpp ├── cppqt.cpp ├── qtpro.cpp ├── journal.cpp ├── lisp.cpp ├── xorg.cpp └── markdown2.cpp ├── scrollbar.cpp ├── sqriptor.svg ├── README.md ├── sqriptor.h ├── filetype.cpp ├── settings.cpp ├── LICENSE └── syntax.cpp /scrot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luebking/sqriptor/HEAD/scrot.png -------------------------------------------------------------------------------- /sqriptor256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luebking/sqriptor/HEAD/sqriptor256.png -------------------------------------------------------------------------------- /colors/README: -------------------------------------------------------------------------------- 1 | COLOR_BACKGROUND 2 | COLOR_FOREGROUND 3 | COLOR_STRING 4 | COLOR_CHAR 5 | COLOR_COMMENT 6 | COLOR_PREPROC 7 | COLOR_NUMBER 8 | COLOR_OPERATOR 9 | COLOR_KEYWORD 10 | COLOR_ERROR -------------------------------------------------------------------------------- /sqriptor.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Name=sqriptor 4 | Comment=The greatest and best TextEditor in the world (tribute) 5 | GenericName=Text Editor 6 | Type=Application 7 | Exec=sqriptor %F 8 | Icon=sqriptor 9 | Terminal=false 10 | StartupNotify=false 11 | Categories=TextEditor;Development;Qt; 12 | MimeType=text/plain; 13 | -------------------------------------------------------------------------------- /colors/tex.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsTeX(QsciLexerTeX *lexer) 2 | { 3 | QColor c = COLOR_FOREGROUND; 4 | lexer->setColor(c, QsciLexerTeX::Default); 5 | lexer->setColor(c, QsciLexerTeX::Text); 6 | lexer->setColor(COLOR_KEYWORD, QsciLexerTeX::Command); 7 | lexer->setColor(COLOR_STRING, QsciLexerTeX::Group); 8 | lexer->setColor(COLOR_NUMBER, QsciLexerTeX::Symbol); 9 | lexer->setColor(COLOR_PREPROC, QsciLexerTeX::Special); 10 | } 11 | -------------------------------------------------------------------------------- /colors/properties.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsProperties(QsciLexerProperties *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerProperties::Default); 4 | lexer->setColor(COLOR_COMMENT, QsciLexerProperties::Comment); 5 | lexer->setColor(COLOR_NUMBER, QsciLexerProperties::Key); 6 | lexer->setColor(COLOR_STRING, QsciLexerProperties::DefaultValue); 7 | lexer->setColor(COLOR_OPERATOR, QsciLexerProperties::Assignment); 8 | lexer->setColor(COLOR_PREPROC, QsciLexerProperties::Section); 9 | } 10 | -------------------------------------------------------------------------------- /colors/makefile.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsMakefile(QsciLexerMakefile *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerMakefile::Default); 4 | lexer->setColor(COLOR_COMMENT, QsciLexerMakefile::Comment); 5 | lexer->setColor(COLOR_PREPROC, QsciLexerMakefile::Preprocessor); 6 | lexer->setColor(COLOR_NUMBER, QsciLexerMakefile::Variable); 7 | lexer->setColor(COLOR_OPERATOR, QsciLexerMakefile::Operator); 8 | lexer->setColor(COLOR_CHAR, QsciLexerMakefile::Target); 9 | lexer->setColor(COLOR_ERROR, QsciLexerMakefile::Error); 10 | } -------------------------------------------------------------------------------- /colors/spice.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsSpice(QsciLexerSpice *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerSpice::Default); 4 | lexer->setColor(COLOR_COMMENT, QsciLexerSpice::Comment); 5 | lexer->setColor(COLOR_NUMBER, QsciLexerSpice::Number); 6 | lexer->setColor(COLOR_OPERATOR, QsciLexerSpice::Command); 7 | lexer->setColor(COLOR_PREPROC, QsciLexerSpice::Delimiter); 8 | lexer->setColor(COLOR_KEYWORD, QsciLexerSpice::Function); 9 | lexer->setColor(COLOR_CHAR, QsciLexerSpice::Parameter); 10 | lexer->setColor(COLOR_STRING, QsciLexerSpice::Value); 11 | // Identifier 12 | } 13 | -------------------------------------------------------------------------------- /colors/batch.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsBatch(QsciLexerBatch *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerBatch::Default); 4 | lexer->setColor(COLOR_COMMENT, QsciLexerBatch::Comment); 5 | QColor c = COLOR_KEYWORD; 6 | lexer->setColor(COLOR_KEYWORD, QsciLexerBatch::Keyword); 7 | lexer->setColor(COLOR_KEYWORD, QsciLexerBatch::ExternalCommand); 8 | lexer->setColor(COLOR_OPERATOR, QsciLexerBatch::Operator); 9 | c = COLOR_PREPROC; 10 | lexer->setColor(c, QsciLexerBatch::Label); 11 | lexer->setColor(c, QsciLexerBatch::HideCommandChar); 12 | lexer->setColor(COLOR_STRING, QsciLexerBatch::Variable); 13 | } 14 | -------------------------------------------------------------------------------- /colors/matlab.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsMatlab(QsciLexerMatlab *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerMatlab::Default); 4 | lexer->setColor(COLOR_COMMENT, QsciLexerMatlab::Comment); 5 | lexer->setColor(COLOR_STRING, QsciLexerMatlab::DoubleQuotedString); 6 | lexer->setColor(COLOR_CHAR, QsciLexerMatlab::SingleQuotedString); 7 | lexer->setColor(COLOR_NUMBER, QsciLexerMatlab::Number); 8 | lexer->setColor(COLOR_OPERATOR, QsciLexerMatlab::Operator); 9 | lexer->setColor(COLOR_KEYWORD, QsciLexerMatlab::Keyword); 10 | lexer->setColor(COLOR_PREPROC, QsciLexerMatlab::Command); 11 | // Identifier 12 | } 13 | -------------------------------------------------------------------------------- /colors/yaml.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsYAML(QsciLexerYAML *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerYAML::Default); 4 | lexer->setColor(COLOR_COMMENT, QsciLexerYAML::Comment); 5 | lexer->setColor(COLOR_KEYWORD, QsciLexerYAML::Keyword); 6 | lexer->setColor(COLOR_PREPROC, QsciLexerYAML::DocumentDelimiter); 7 | lexer->setColor(COLOR_NUMBER, QsciLexerYAML::Number); 8 | lexer->setColor(COLOR_OPERATOR, QsciLexerYAML::Operator); 9 | lexer->setColor(COLOR_STRING, QsciLexerYAML::TextBlockMarker); 10 | lexer->setColor(COLOR_CHAR, QsciLexerYAML::Reference); 11 | lexer->setColor(COLOR_ERROR, QsciLexerYAML::SyntaxErrorMarker); 12 | // Identifier 13 | } 14 | -------------------------------------------------------------------------------- /colors/edifact.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsEDIFACT(QsciLexerEDIFACT *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerEDIFACT::Default); 4 | lexer->setColor(COLOR_ERROR, QsciLexerEDIFACT::BadSegment); 5 | lexer->setColor(COLOR_COMMENT, QsciLexerEDIFACT::UNASegmentHeader); 6 | QColor c = COLOR_STRING; 7 | lexer->setColor(c, QsciLexerEDIFACT::SegmentStart); 8 | lexer->setColor(c, QsciLexerEDIFACT::SegmentEnd); 9 | c = COLOR_OPERATOR; 10 | lexer->setColor(c, QsciLexerEDIFACT::ElementSeparator); 11 | lexer->setColor(c, QsciLexerEDIFACT::CompositeSeparator); 12 | lexer->setColor(c, QsciLexerEDIFACT::ReleaseSeparator); 13 | lexer->setColor(COLOR_PREPROC, QsciLexerEDIFACT::UNASegmentHeader); 14 | } 15 | -------------------------------------------------------------------------------- /sqriptor.pro: -------------------------------------------------------------------------------- 1 | CONFIG += qscintilla2 2 | QT += gui widgets 3 | HEADERS = sqriptor.h scrollbar.h \ 4 | lexer/awk.h lexer/journal.h lexer/markdown2.h lexer/xorg.h \ 5 | lexer/pkgbuild.h lexer/xorglog.h lexer/nim.h lexer/lisp.h lexer/fontconfig.h \ 6 | lexer/cppqt.h lexer/qtpro.h lexer/glsl.h lexer/rust.h 7 | SOURCES = sqriptor.cpp createui.cpp syntax.cpp filetype.cpp settings.cpp scrollbar.cpp \ 8 | lexer/awk.cpp lexer/journal.cpp lexer/markdown2.cpp lexer/xorg.cpp \ 9 | lexer/pkgbuild.cpp lexer/xorglog.cpp lexer/nim.cpp lexer/lisp.cpp lexer/fontconfig.cpp \ 10 | lexer/cppqt.cpp lexer/qtpro.cpp lexer/glsl.cpp lexer/rust.cpp 11 | FORMS = settings.ui -------------------------------------------------------------------------------- /colors/diff.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsDiff(QsciLexerDiff *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerDiff::Default); 4 | 5 | QColor c = COLOR_COMMENT; 6 | lexer->setColor(c, QsciLexerDiff::Comment); 7 | lexer->setColor(c, QsciLexerDiff::Header); 8 | 9 | lexer->setColor(COLOR_NUMBER, QsciLexerDiff::Position); 10 | 11 | lexer->setColor(COLOR_KEYWORD, QsciLexerDiff::Command); 12 | 13 | lexer->setColor(COLOR_OPERATOR, QsciLexerDiff::LineChanged); 14 | 15 | c = COLOR_STRING; 16 | lexer->setColor(c, QsciLexerDiff::LineAdded); 17 | lexer->setColor(c, QsciLexerDiff::AddingPatchAdded); 18 | lexer->setColor(c, QsciLexerDiff::RemovingPatchAdded); 19 | 20 | c = COLOR_ERROR; 21 | lexer->setColor(c, QsciLexerDiff::LineRemoved); 22 | lexer->setColor(c, QsciLexerDiff::AddingPatchRemoved); 23 | lexer->setColor(c, QsciLexerDiff::RemovingPatchRemoved); 24 | } 25 | -------------------------------------------------------------------------------- /colors/bash.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsBash(QsciLexerBash *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerBash::Default); 4 | lexer->setColor(COLOR_ERROR, QsciLexerBash::Error); 5 | lexer->setColor(COLOR_COMMENT, QsciLexerBash::Comment); 6 | lexer->setColor(COLOR_NUMBER, QsciLexerBash::Number); 7 | lexer->setColor(COLOR_KEYWORD, QsciLexerBash::Keyword); 8 | QColor c = COLOR_STRING; 9 | lexer->setColor(c, QsciLexerBash::DoubleQuotedString); 10 | lexer->setColor(c, QsciLexerBash::SingleQuotedHereDocument); 11 | c = COLOR_CHAR; 12 | lexer->setColor(c, QsciLexerBash::SingleQuotedString); 13 | lexer->setColor(c, QsciLexerBash::HereDocumentDelimiter); 14 | lexer->setColor(COLOR_OPERATOR, QsciLexerBash::Operator); 15 | c = COLOR_PREPROC; 16 | lexer->setColor(c, QsciLexerBash::Scalar); 17 | lexer->setColor(c, QsciLexerBash::ParameterExpansion); 18 | lexer->setColor(c, QsciLexerBash::Backticks); 19 | } 20 | -------------------------------------------------------------------------------- /PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Thomas Lübking 2 | 3 | pkgname=sqriptor 4 | pkgver=r147.5b1a194 5 | pkgrel=1 6 | pkgdesc="Greatest and best TextEditor in the World. Tribute." 7 | arch=('i686' 'x86_64') 8 | url="https://github.com/luebking/sqriptor" 9 | license=('GPL') 10 | depends=(qt6-base qscintilla-qt6) 11 | makedepends=('gcc') 12 | license=('GPL') 13 | provides=(sqriptor) 14 | conflicts=(sqriptor-git) 15 | 16 | pkgver() { 17 | cd .. 18 | printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" 19 | } 20 | 21 | build() 22 | { 23 | qmake6 .. 24 | make 25 | } 26 | 27 | package() 28 | { 29 | install -Dm755 sqriptor -t "${pkgdir}/usr/bin" 30 | install -Dm644 "../sqriptor.svg" -t "${pkgdir}/usr/share/icons/hicolor/scalable/apps" 31 | install -Dm644 "../sqriptor256.png" "${pkgdir}/usr/share/pixmaps/sqriptor.png" 32 | install -Dm644 "../sqriptor.desktop" -t "${pkgdir}/usr/share/applications" 33 | } 34 | 35 | # vim:set ts=4 sw=4 et: 36 | -------------------------------------------------------------------------------- /colors/avs.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsAVS(QsciLexerAVS *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerAVS::Default); 4 | QColor c = COLOR_COMMENT; 5 | lexer->setColor(c, QsciLexerAVS::BlockComment); 6 | lexer->setColor(c, QsciLexerAVS::NestedBlockComment); 7 | lexer->setColor(c, QsciLexerAVS::LineComment); 8 | lexer->setColor(COLOR_NUMBER, QsciLexerAVS::Number); 9 | lexer->setColor(COLOR_OPERATOR, QsciLexerAVS::Operator); 10 | // Identifier 11 | c = COLOR_STRING; 12 | lexer->setColor(c, QsciLexerAVS::String); 13 | lexer->setColor(c, QsciLexerAVS::TripleString); 14 | c = COLOR_KEYWORD; 15 | lexer->setColor(c, QsciLexerAVS::Keyword); 16 | lexer->setColor(c, QsciLexerAVS::Function); 17 | lexer->setColor(c, QsciLexerAVS::KeywordSet6); 18 | c = COLOR_PREPROC; 19 | lexer->setColor(c, QsciLexerAVS::Filter); 20 | lexer->setColor(c, QsciLexerAVS::Plugin); 21 | lexer->setColor(COLOR_CHAR, QsciLexerAVS::ClipProperty); 22 | } 23 | -------------------------------------------------------------------------------- /colors/json.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsJSON(QsciLexerJSON *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerJSON::Default); 4 | QColor c = COLOR_COMMENT; 5 | lexer->setColor(c, QsciLexerJSON::CommentBlock); 6 | lexer->setColor(c, QsciLexerJSON::CommentLine); 7 | lexer->setColor(COLOR_STRING, QsciLexerJSON::String); 8 | c = COLOR_CHAR; 9 | lexer->setColor(c, QsciLexerJSON::IRI); 10 | lexer->setColor(c, QsciLexerJSON::IRICompact); 11 | lexer->setColor(c, QsciLexerJSON::Property); 12 | lexer->setColor(COLOR_PREPROC, QsciLexerJSON::EscapeSequence); 13 | lexer->setColor(COLOR_NUMBER, QsciLexerJSON::Number); 14 | c = COLOR_OPERATOR; 15 | lexer->setColor(c, QsciLexerJSON::Operator); 16 | c = COLOR_KEYWORD; 17 | lexer->setColor(c, QsciLexerJSON::Keyword); 18 | lexer->setColor(c, QsciLexerJSON::KeywordLD); 19 | c = COLOR_ERROR; 20 | lexer->setColor(c, QsciLexerJSON::Error); 21 | lexer->setColor(c, QsciLexerJSON::UnclosedString); 22 | } 23 | -------------------------------------------------------------------------------- /colors/cmake.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsCMake(QsciLexerCMake *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerCMake::Default); 4 | lexer->setColor(COLOR_COMMENT, QsciLexerCMake::Comment); 5 | QColor c = COLOR_KEYWORD; 6 | lexer->setColor(c, QsciLexerCMake::Function); 7 | lexer->setColor(c, QsciLexerCMake::KeywordSet3); 8 | c = COLOR_STRING; 9 | lexer->setColor(c, QsciLexerCMake::String); 10 | lexer->setColor(c, QsciLexerCMake::StringVariable); 11 | // Variable 12 | c = COLOR_PREPROC; 13 | lexer->setColor(c, QsciLexerCMake::Label); 14 | lexer->setColor(c, QsciLexerCMake::BlockWhile); 15 | lexer->setColor(c, QsciLexerCMake::BlockForeach); 16 | lexer->setColor(c, QsciLexerCMake::BlockIf); 17 | lexer->setColor(c, QsciLexerCMake::BlockMacro); 18 | lexer->setColor(COLOR_NUMBER, QsciLexerCMake::Number); 19 | lexer->setColor(COLOR_OPERATOR, QsciLexerCMake::StringLeftQuote); 20 | lexer->setColor(COLOR_CHAR, QsciLexerCMake::StringRightQuote); 21 | } 22 | -------------------------------------------------------------------------------- /PKGBUILD.aur: -------------------------------------------------------------------------------- 1 | # Maintainer: Thomas Lübking 2 | 3 | pkgname=sqriptor-git 4 | _gitname=sqriptor 5 | pkgver=r151.c0599eb 6 | pkgrel=1 7 | pkgdesc="QScintilla based text editor" 8 | arch=(i686 x86_64) 9 | url="https://github.com/luebking/sqriptor" 10 | license=(GPL) 11 | depends=(qt6-base qscintilla-qt6) 12 | makedepends=(git) 13 | provides=(sqriptor) 14 | conflicts=(sqriptor) 15 | source=("git+https://github.com/luebking/sqriptor.git") 16 | sha256sums=("SKIP") 17 | 18 | pkgver() { 19 | cd "${_gitname}" 20 | printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" 21 | } 22 | 23 | build() { 24 | cd "${_gitname}" 25 | qmake6 26 | make 27 | } 28 | 29 | package() { 30 | cd "${_gitname}" 31 | install -Dm755 sqriptor -t "${pkgdir}/usr/bin" 32 | install -Dm644 "sqriptor.svg" -t "${pkgdir}/usr/share/icons/hicolor/scalable/apps" 33 | install -Dm644 "sqriptor256.png" "${pkgdir}/usr/share/pixmaps/sqriptor.png" 34 | install -Dm644 "sqriptor.desktop" -t "${pkgdir}/usr/share/applications" 35 | } 36 | -------------------------------------------------------------------------------- /colors/pascal.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsPascal(QsciLexerPascal *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerPascal::Default); 4 | QColor c = COLOR_COMMENT; 5 | lexer->setColor(c, QsciLexerPascal::Comment); 6 | lexer->setColor(c, QsciLexerPascal::CommentLine); 7 | lexer->setColor(c, QsciLexerPascal::CommentParenthesis); 8 | c = COLOR_PREPROC; 9 | lexer->setColor(c, QsciLexerPascal::PreProcessor); 10 | lexer->setColor(c, QsciLexerPascal::PreProcessorParenthesis); 11 | lexer->setColor(c, QsciLexerPascal::Asm); 12 | c = COLOR_NUMBER; 13 | lexer->setColor(c, QsciLexerPascal::Number); 14 | lexer->setColor(c, QsciLexerPascal::HexNumber); 15 | lexer->setColor(COLOR_STRING, QsciLexerPascal::SingleQuotedString); 16 | lexer->setColor(COLOR_CHAR, QsciLexerPascal::Character); 17 | c = COLOR_OPERATOR; 18 | lexer->setColor(c, QsciLexerPascal::Operator); 19 | lexer->setColor(COLOR_ERROR, QsciLexerPascal::UnclosedString); 20 | lexer->setColor(COLOR_KEYWORD, QsciLexerPascal::Keyword); 21 | // Identifier 22 | } 23 | -------------------------------------------------------------------------------- /colors/vhdl.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsVHDL(QsciLexerVHDL *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerVHDL::Default); 4 | QColor c = COLOR_COMMENT; 5 | lexer->setColor(c, QsciLexerVHDL::Comment); 6 | lexer->setColor(c, QsciLexerVHDL::CommentLine); 7 | lexer->setColor(c, QsciLexerVHDL::CommentBlock); 8 | c = COLOR_KEYWORD; 9 | lexer->setColor(c, QsciLexerVHDL::Keyword); 10 | lexer->setColor(c, QsciLexerVHDL::StandardFunction); 11 | lexer->setColor(c, QsciLexerVHDL::StandardType); 12 | lexer->setColor(c, QsciLexerVHDL::KeywordSet7); 13 | lexer->setColor(COLOR_PREPROC, QsciLexerVHDL::StandardPackage); 14 | lexer->setColor(COLOR_NUMBER, QsciLexerVHDL::Number); 15 | c = COLOR_OPERATOR; 16 | lexer->setColor(c, QsciLexerVHDL::Operator); 17 | lexer->setColor(c, QsciLexerVHDL::StandardOperator); 18 | lexer->setColor(COLOR_ERROR, QsciLexerVHDL::UnclosedString); 19 | lexer->setColor(COLOR_STRING, QsciLexerVHDL::String); 20 | lexer->setColor(COLOR_CHAR, QsciLexerVHDL::Attribute); 21 | // Identifier 22 | } 23 | -------------------------------------------------------------------------------- /colors/po.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsPO(QsciLexerPO *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerPO::Default); 4 | QColor c = COLOR_COMMENT; 5 | lexer->setColor(c, QsciLexerPO::Comment); 6 | lexer->setColor(c, QsciLexerPO::ProgrammerComment); 7 | c = COLOR_NUMBER; 8 | lexer->setColor(c, QsciLexerPO::MessageId); 9 | lexer->setColor(c, QsciLexerPO::MessageIdText); 10 | c = COLOR_STRING; 11 | lexer->setColor(c, QsciLexerPO::MessageString); 12 | lexer->setColor(c, QsciLexerPO::MessageStringText); 13 | c = COLOR_CHAR; 14 | lexer->setColor(c, QsciLexerPO::MessageContext); 15 | lexer->setColor(c, QsciLexerPO::MessageContextText); 16 | lexer->setColor(COLOR_KEYWORD, QsciLexerPO::Reference); 17 | lexer->setColor(COLOR_OPERATOR, QsciLexerPO::Flags); 18 | c = COLOR_PREPROC; 19 | lexer->setColor(c, QsciLexerPO::MessageIdTextEOL); 20 | lexer->setColor(c, QsciLexerPO::MessageStringTextEOL); 21 | lexer->setColor(c, QsciLexerPO::MessageContextTextEOL); 22 | lexer->setColor(COLOR_ERROR, QsciLexerPO::Fuzzy); 23 | } 24 | -------------------------------------------------------------------------------- /colors/fortran77.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsFortran77(QsciLexerFortran77 *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerFortran77::Default); 4 | lexer->setColor(COLOR_COMMENT, QsciLexerFortran77::Comment); 5 | lexer->setColor(COLOR_STRING, QsciLexerFortran77::DoubleQuotedString); 6 | lexer->setColor(COLOR_CHAR, QsciLexerFortran77::SingleQuotedString); 7 | QColor c = COLOR_PREPROC; 8 | lexer->setColor(c, QsciLexerFortran77::PreProcessor); 9 | lexer->setColor(c, QsciLexerFortran77::Label); 10 | lexer->setColor(COLOR_NUMBER, QsciLexerFortran77::Number); 11 | c = COLOR_OPERATOR; 12 | lexer->setColor(c, QsciLexerFortran77::Operator); 13 | lexer->setColor(c, QsciLexerFortran77::DottedOperator); 14 | lexer->setColor(c, QsciLexerFortran77::Continuation); 15 | c = COLOR_KEYWORD; 16 | lexer->setColor(c, QsciLexerFortran77::Keyword); 17 | lexer->setColor(c, QsciLexerFortran77::IntrinsicFunction); 18 | lexer->setColor(c, QsciLexerFortran77::ExtendedFunction); 19 | lexer->setColor(COLOR_ERROR, QsciLexerFortran77::UnclosedString); 20 | // Identifier 21 | } 22 | -------------------------------------------------------------------------------- /colors/pov.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsPOV(QsciLexerPOV *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerPOV::Default); 4 | QColor c = COLOR_COMMENT; 5 | lexer->setColor(c, QsciLexerPOV::Comment); 6 | lexer->setColor(c, QsciLexerPOV::CommentLine); 7 | 8 | c = COLOR_KEYWORD; 9 | lexer->setColor(c, QsciLexerPOV::PredefinedIdentifiers); 10 | lexer->setColor(c, QsciLexerPOV::PredefinedFunctions); 11 | lexer->setColor(c, QsciLexerPOV::KeywordSet6); 12 | lexer->setColor(c, QsciLexerPOV::KeywordSet7); 13 | lexer->setColor(c, QsciLexerPOV::KeywordSet8); 14 | 15 | lexer->setColor(COLOR_PREPROC, QsciLexerPOV::Directive); 16 | 17 | lexer->setColor(COLOR_NUMBER, QsciLexerPOV::Number); 18 | 19 | c = COLOR_OPERATOR; 20 | lexer->setColor(c, QsciLexerPOV::Operator); 21 | 22 | lexer->setColor(COLOR_STRING, QsciLexerPOV::String); 23 | 24 | c = COLOR_CHAR; 25 | lexer->setColor(c, QsciLexerPOV::ObjectsCSGAppearance); 26 | lexer->setColor(c, QsciLexerPOV::TypesModifiersItems); 27 | 28 | c = COLOR_ERROR; 29 | lexer->setColor(c, QsciLexerPOV::BadDirective); 30 | lexer->setColor(c, QsciLexerPOV::UnclosedString); 31 | 32 | // Identifier 33 | } -------------------------------------------------------------------------------- /colors/postscript.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsPostScript(QsciLexerPostScript *lexer) 2 | { 3 | QColor c = COLOR_FOREGROUND; 4 | lexer->setColor(c, QsciLexerPostScript::Default); 5 | lexer->setColor(c, QsciLexerPostScript::Text); 6 | c = COLOR_COMMENT; 7 | lexer->setColor(c, QsciLexerPostScript::Comment); 8 | lexer->setColor(c, QsciLexerPostScript::DSCComment); 9 | lexer->setColor(COLOR_CHAR, QsciLexerPostScript::DSCCommentValue); 10 | c = COLOR_NUMBER; 11 | lexer->setColor(c, QsciLexerPostScript::Number); 12 | lexer->setColor(c, QsciLexerPostScript::HexString); 13 | lexer->setColor(c, QsciLexerPostScript::Base85String); 14 | lexer->setColor(COLOR_STRING, QsciLexerPostScript::Literal); 15 | lexer->setColor(COLOR_KEYWORD, QsciLexerPostScript::Keyword); 16 | c = COLOR_OPERATOR; 17 | lexer->setColor(c, QsciLexerPostScript::ArrayParenthesis); 18 | lexer->setColor(c, QsciLexerPostScript::DictionaryParenthesis); 19 | lexer->setColor(c, QsciLexerPostScript::ProcedureParenthesis); 20 | c = COLOR_PREPROC; 21 | lexer->setColor(c, QsciLexerPostScript::Name); 22 | lexer->setColor(c, QsciLexerPostScript::ImmediateEvalLiteral); 23 | lexer->setColor(COLOR_ERROR, QsciLexerPostScript::BadStringCharacter); 24 | } 25 | -------------------------------------------------------------------------------- /scrollbar.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef SCROLLBAR_H 20 | #define SCROLLBAR_H 21 | 22 | #include 23 | #include 24 | 25 | class QPaintEvent; 26 | 27 | class ScrollBar : public QScrollBar 28 | { 29 | Q_OBJECT 30 | 31 | public: 32 | ScrollBar(); 33 | void setMarkers(const QList &markers) { 34 | m_markers = markers; 35 | update(); 36 | } 37 | protected: 38 | void paintEvent(QPaintEvent *event); 39 | private: 40 | QList m_markers; 41 | }; 42 | 43 | #endif // SCROLLBAR_H 44 | -------------------------------------------------------------------------------- /lexer/journal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef QSCILEXERJOURNAL_H 20 | #define QSCILEXERJOURNAL_H 21 | 22 | #include 23 | 24 | class QsciLexerJournal : public QsciLexerCustom { 25 | Q_OBJECT 26 | public: 27 | QsciLexerJournal(QObject *parent); 28 | void updateColors(); 29 | virtual void styleText (int start, int end); 30 | virtual const char *language () const { return "Journal"; } 31 | virtual QString description(int style) const {Q_UNUSED(style); return "Journal"; } 32 | }; 33 | 34 | #endif // QSCILEXERJOURNAL_H -------------------------------------------------------------------------------- /lexer/xorglog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef QSCILEXERXORGLOG_H 20 | #define QSCILEXERXORGLOG_H 21 | 22 | #include 23 | 24 | class QsciLexerXorgLog : public QsciLexerCustom { 25 | Q_OBJECT 26 | public: 27 | QsciLexerXorgLog(QObject *parent); 28 | void updateColors(); 29 | virtual void styleText (int start, int end); 30 | virtual const char *language () const { return "Xorg.log"; } 31 | virtual QString description(int style) const {Q_UNUSED(style); return "Xorg.log"; } 32 | }; 33 | 34 | #endif // QSCILEXERXORGLOG_H -------------------------------------------------------------------------------- /lexer/awk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef QSCILEXERAWK_H 20 | #define QSCILEXERAWK_H 21 | 22 | #include 23 | 24 | class QsciLexerAWK : public QsciLexerBash { 25 | Q_OBJECT 26 | public: 27 | QsciLexerAWK(QObject *parent); 28 | const char *keywords(int set) const; 29 | // void updateColors(); 30 | // virtual void styleText (int start, int end); 31 | virtual const char *language () const { return "AWK"; } 32 | virtual QString description(int style) const {Q_UNUSED(style); return "AWK"; } 33 | }; 34 | 35 | #endif // QSCILEXERAWK_H -------------------------------------------------------------------------------- /lexer/markdown2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef QSCILEXERMARKDOWN2_H 20 | #define QSCILEXERMARKDOWN2_H 21 | 22 | #include 23 | 24 | class QsciLexerMarkdown2 : public QsciLexerCustom { 25 | Q_OBJECT 26 | public: 27 | QsciLexerMarkdown2(QObject *parent); 28 | void updateColors(); 29 | virtual void styleText (int start, int end); 30 | virtual const char *language () const { return "Markdown2"; } 31 | virtual QString description(int style) const {Q_UNUSED(style); return "Markdown2"; } 32 | }; 33 | 34 | #endif // QSCILEXERMARKDOWN2_H -------------------------------------------------------------------------------- /lexer/nim.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef QSCILEXERNIM_H 20 | #define QSCILEXERNIM_H 21 | 22 | #include 23 | 24 | class QsciLexerNIM : public QsciLexerPython { 25 | Q_OBJECT 26 | public: 27 | QsciLexerNIM(QObject *parent); 28 | const char *keywords(int set) const; 29 | // void updateColors(); 30 | // virtual void styleText (int start, int end); 31 | virtual const char *language () const { return "NIM"; } 32 | virtual QString description(int style) const {Q_UNUSED(style); return "NIM"; } 33 | }; 34 | 35 | #endif // QSCILEXERNIM_H -------------------------------------------------------------------------------- /lexer/glsl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2025 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef QSCILEXERGLSL_H 20 | #define QSCILEXERGLSL_H 21 | 22 | #include 23 | 24 | class QsciLexerGLSL: public QsciLexerCPP { 25 | Q_OBJECT 26 | public: 27 | QsciLexerGLSL(QObject *parent); 28 | const char *keywords(int set) const; 29 | // void updateColors(); 30 | // virtual void styleText (int start, int end); 31 | // virtual const char *language () const { return "CPP"; } 32 | // virtual QString description(int style) const {Q_UNUSED(style); return "CPP"; } 33 | }; 34 | 35 | #endif // QSCILEXERGLSL_H -------------------------------------------------------------------------------- /lexer/rust.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2025 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef QSCILEXERRUST_H 20 | #define QSCILEXERRUST_H 21 | 22 | #include 23 | 24 | class QsciLexerRust: public QsciLexerCPP { 25 | Q_OBJECT 26 | public: 27 | QsciLexerRust(QObject *parent); 28 | const char *keywords(int set) const; 29 | // void updateColors(); 30 | // virtual void styleText (int start, int end); 31 | virtual const char *language () const { return "Rust"; } 32 | virtual QString description(int style) const {Q_UNUSED(style); return "Rust"; } 33 | }; 34 | 35 | #endif // QSCILEXERRUST_H -------------------------------------------------------------------------------- /lexer/cppqt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2025 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef QSCILEXERCPPQT_H 20 | #define QSCILEXERCPPQT_H 21 | 22 | #include 23 | 24 | class QsciLexerCPPQt: public QsciLexerCPP { 25 | Q_OBJECT 26 | public: 27 | QsciLexerCPPQt(QObject *parent); 28 | const char *keywords(int set) const; 29 | // void updateColors(); 30 | // virtual void styleText (int start, int end); 31 | // virtual const char *language () const { return "CPP"; } 32 | // virtual QString description(int style) const {Q_UNUSED(style); return "CPP"; } 33 | }; 34 | 35 | #endif // QSCILEXERCPPQT_H -------------------------------------------------------------------------------- /lexer/qtpro.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2025 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef QSCILEXERQTPRO_H 20 | #define QSCILEXERQTPRO_H 21 | 22 | #include 23 | 24 | class QsciLexerQtPro : public QsciLexerBash { 25 | Q_OBJECT 26 | public: 27 | QsciLexerQtPro(QObject *parent); 28 | const char *keywords(int set) const; 29 | // void updateColors(); 30 | // virtual void styleText (int start, int end); 31 | virtual const char *language () const { return "QtPro"; } 32 | virtual QString description(int style) const {Q_UNUSED(style); return "Qt Project"; } 33 | }; 34 | 35 | #endif // QSCILEXERQTPRO_H -------------------------------------------------------------------------------- /colors/lua.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsLua(QsciLexerLua *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerLua::Default); 4 | QColor c = COLOR_COMMENT; 5 | lexer->setColor(c, QsciLexerLua::Comment); 6 | lexer->setColor(c, QsciLexerLua::LineComment); 7 | c = COLOR_STRING; 8 | lexer->setColor(c, QsciLexerLua::String); 9 | c = COLOR_CHAR; 10 | lexer->setColor(c, QsciLexerLua::LiteralString); 11 | lexer->setColor(c, QsciLexerLua::Character); 12 | c = COLOR_PREPROC; 13 | lexer->setColor(c, QsciLexerLua::Preprocessor); 14 | lexer->setColor(c, QsciLexerLua::Label); 15 | lexer->setColor(c, QsciLexerLua::BasicFunctions); 16 | lexer->setColor(c, QsciLexerLua::StringTableMathsFunctions); 17 | lexer->setColor(c, QsciLexerLua::CoroutinesIOSystemFacilities); 18 | c = COLOR_NUMBER; 19 | lexer->setColor(c, QsciLexerLua::Number); 20 | lexer->setColor(c, QsciLexerCPP::UUID); 21 | c = COLOR_OPERATOR; 22 | lexer->setColor(c, QsciLexerLua::Operator); 23 | lexer->setColor(COLOR_ERROR, QsciLexerLua::UnclosedString); 24 | c = COLOR_KEYWORD; 25 | lexer->setColor(c, QsciLexerLua::Keyword); 26 | lexer->setColor(c, QsciLexerLua::KeywordSet5); 27 | lexer->setColor(c, QsciLexerLua::KeywordSet6); 28 | lexer->setColor(c, QsciLexerLua::KeywordSet7); 29 | lexer->setColor(c, QsciLexerLua::KeywordSet8); 30 | // Identifier 31 | } -------------------------------------------------------------------------------- /lexer/fontconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef QSCILEXERFONTCONFIG_H 20 | #define QSCILEXERFONTCONFIG_H 21 | 22 | #include 23 | 24 | class QsciLexerFontConfig : public QsciLexerXML { 25 | Q_OBJECT 26 | public: 27 | QsciLexerFontConfig(QObject *parent); 28 | const char *keywords(int set) const; 29 | // void updateColors(); 30 | // virtual void styleText (int start, int end); 31 | virtual const char *language () const { return "FontConfig"; } 32 | virtual QString description(int style) const {Q_UNUSED(style); return "FontConfig"; } 33 | }; 34 | 35 | #endif // QSCILEXERFONTCONFIG_H -------------------------------------------------------------------------------- /colors/verilog.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsVerilog(QsciLexerVerilog *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerVerilog::Default); 4 | 5 | QColor c = COLOR_COMMENT; 6 | lexer->setColor(c, QsciLexerVerilog::Comment); 7 | lexer->setColor(c, QsciLexerVerilog::CommentLine); 8 | lexer->setColor(c, QsciLexerVerilog::CommentBang); 9 | lexer->setColor(c, QsciLexerVerilog::CommentKeyword); 10 | 11 | lexer->setColor(COLOR_STRING, QsciLexerVerilog::String); 12 | 13 | lexer->setColor(COLOR_CHAR, QsciLexerVerilog::DeclareInputPort); 14 | 15 | c = COLOR_PREPROC; 16 | lexer->setColor(c, QsciLexerVerilog::Preprocessor); 17 | lexer->setColor(c, QsciLexerVerilog::PortConnection); 18 | 19 | lexer->setColor(COLOR_NUMBER, QsciLexerVerilog::Number); 20 | 21 | c = COLOR_OPERATOR; 22 | lexer->setColor(c, QsciLexerVerilog::Operator); 23 | lexer->setColor(c, QsciLexerVerilog::SystemTask); 24 | 25 | c = COLOR_KEYWORD; 26 | lexer->setColor(c, QsciLexerVerilog::Keyword); 27 | lexer->setColor(c, QsciLexerVerilog::KeywordSet2); 28 | lexer->setColor(c, QsciLexerVerilog::UserKeywordSet); 29 | 30 | c = COLOR_ERROR; 31 | lexer->setColor(c, QsciLexerVerilog::DeclareInputOutputPort); 32 | lexer->setColor(c, QsciLexerVerilog::DeclareOutputPort); 33 | lexer->setColor(c, QsciLexerVerilog::UnclosedString); 34 | 35 | // Identifier 36 | } 37 | -------------------------------------------------------------------------------- /colors/d.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsD(QsciLexerD *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerD::Default); 4 | QColor c = COLOR_COMMENT; 5 | lexer->setColor(c, QsciLexerD::Comment); 6 | lexer->setColor(c, QsciLexerD::CommentLine); 7 | lexer->setColor(c, QsciLexerD::CommentDoc); 8 | lexer->setColor(c, QsciLexerD::CommentLineDoc); 9 | lexer->setColor(c, QsciLexerD::CommentNested); 10 | c = COLOR_STRING; 11 | lexer->setColor(c, QsciLexerD::String); 12 | lexer->setColor(c, QsciLexerD::RawString); 13 | lexer->setColor(c, QsciLexerD::BackquoteString); 14 | lexer->setColor(COLOR_CHAR, QsciLexerD::Character); 15 | lexer->setColor(COLOR_PREPROC, QsciLexerD::Typedefs); 16 | lexer->setColor(COLOR_NUMBER, QsciLexerD::Number); 17 | c = COLOR_OPERATOR; 18 | lexer->setColor(c, QsciLexerD::Operator); 19 | lexer->setColor(c, QsciLexerD::CommentDocKeyword); 20 | c = COLOR_ERROR; 21 | lexer->setColor(c, QsciLexerD::UnclosedString); 22 | lexer->setColor(c, QsciLexerD::CommentDocKeywordError); 23 | c = COLOR_KEYWORD; 24 | lexer->setColor(c, QsciLexerD::Keyword); 25 | lexer->setColor(c, QsciLexerD::KeywordSecondary); 26 | lexer->setColor(c, QsciLexerD::KeywordDoc); 27 | lexer->setColor(c, QsciLexerD::KeywordSet5); 28 | lexer->setColor(c, QsciLexerD::KeywordSet6); 29 | lexer->setColor(c, QsciLexerD::KeywordSet7); 30 | // Identifier 31 | } 32 | -------------------------------------------------------------------------------- /colors/tcl.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsTCL(QsciLexerTCL *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerTCL::Default); 4 | QColor c = COLOR_COMMENT; 5 | lexer->setColor(c, QsciLexerTCL::Comment); 6 | lexer->setColor(c, QsciLexerTCL::CommentLine); 7 | lexer->setColor(c, QsciLexerTCL::CommentBox); 8 | lexer->setColor(c, QsciLexerTCL::CommentBlock); 9 | 10 | c = COLOR_KEYWORD; 11 | lexer->setColor(c, QsciLexerTCL::ExpandKeyword); 12 | lexer->setColor(c, QsciLexerTCL::TCLKeyword); 13 | lexer->setColor(c, QsciLexerTCL::TkKeyword); 14 | lexer->setColor(c, QsciLexerTCL::ITCLKeyword); 15 | lexer->setColor(c, QsciLexerTCL::KeywordSet6); 16 | lexer->setColor(c, QsciLexerTCL::KeywordSet7); 17 | lexer->setColor(c, QsciLexerTCL::KeywordSet8); 18 | lexer->setColor(c, QsciLexerTCL::KeywordSet9); 19 | lexer->setColor(c, QsciLexerTCL::QuotedKeyword); 20 | 21 | c = COLOR_PREPROC; 22 | lexer->setColor(c, QsciLexerTCL::Substitution); 23 | lexer->setColor(c, QsciLexerTCL::SubstitutionBrace); 24 | lexer->setColor(c, QsciLexerTCL::Modifier); 25 | 26 | lexer->setColor(COLOR_NUMBER, QsciLexerTCL::Number); 27 | 28 | c= COLOR_OPERATOR; 29 | lexer->setColor(c, QsciLexerTCL::Operator); 30 | lexer->setColor(c, QsciLexerTCL::TkCommand); 31 | 32 | lexer->setColor(COLOR_STRING, QsciLexerTCL::QuotedString); 33 | 34 | // Identifier 35 | } -------------------------------------------------------------------------------- /colors/sql.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsSQL(QsciLexerSQL *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerSQL::Default); 4 | QColor c = COLOR_COMMENT; 5 | lexer->setColor(c, QsciLexerSQL::Comment); 6 | lexer->setColor(c, QsciLexerSQL::CommentLine); 7 | lexer->setColor(c, QsciLexerSQL::CommentDoc); 8 | lexer->setColor(c, QsciLexerSQL::PlusComment); 9 | lexer->setColor(c, QsciLexerSQL::CommentLineHash); 10 | c = COLOR_STRING; 11 | lexer->setColor(c, QsciLexerSQL::DoubleQuotedString); 12 | c = COLOR_CHAR; 13 | lexer->setColor(c, QsciLexerSQL::SingleQuotedString); 14 | // c = COLOR_PREPROC; 15 | lexer->setColor(COLOR_NUMBER, QsciLexerSQL::Number); 16 | c = COLOR_OPERATOR; 17 | lexer->setColor(c, QsciLexerSQL::Operator); 18 | lexer->setColor(c, QsciLexerSQL::PlusPrompt); 19 | lexer->setColor(c, QsciLexerSQL::QuotedOperator); 20 | lexer->setColor(c, QsciLexerSQL::CommentDocKeyword); 21 | c = COLOR_KEYWORD; 22 | lexer->setColor(c, QsciLexerSQL::Keyword); 23 | lexer->setColor(c, QsciLexerSQL::KeywordSet5); 24 | lexer->setColor(c, QsciLexerSQL::KeywordSet6); 25 | lexer->setColor(c, QsciLexerSQL::KeywordSet7); 26 | lexer->setColor(c, QsciLexerSQL::KeywordSet8); 27 | lexer->setColor(c, QsciLexerSQL::PlusKeyword); 28 | c = COLOR_ERROR; 29 | lexer->setColor(c, QsciLexerSQL::CommentDocKeywordError); 30 | // Identifier 31 | // QuotedIdentifier 32 | } 33 | -------------------------------------------------------------------------------- /colors/python.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsPython(QsciLexerPython *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerPython::Default); 4 | QColor c = COLOR_COMMENT; 5 | lexer->setColor(c, QsciLexerPython::Comment); 6 | lexer->setColor(c, QsciLexerPython::CommentBlock); 7 | c = COLOR_STRING; 8 | lexer->setColor(c, QsciLexerPython::DoubleQuotedString); 9 | lexer->setColor(c, QsciLexerPython::TripleDoubleQuotedString); 10 | c = COLOR_CHAR; 11 | lexer->setColor(c, QsciLexerPython::SingleQuotedString); 12 | lexer->setColor(c, QsciLexerPython::TripleSingleQuotedString); 13 | c = COLOR_PREPROC; 14 | lexer->setColor(c, QsciLexerPython::HighlightedIdentifier); 15 | lexer->setColor(c, QsciLexerPython::Decorator); 16 | lexer->setColor(c, QsciLexerPython::Keyword); // yeah, it's odd 17 | lexer->setColor(COLOR_NUMBER, QsciLexerPython::Number); 18 | c = COLOR_OPERATOR; 19 | lexer->setColor(c, QsciLexerPython::Operator); 20 | lexer->setColor(c, QsciLexerPython::UnclosedString); 21 | c = COLOR_KEYWORD; 22 | lexer->setColor(c, QsciLexerPython::ClassName); 23 | lexer->setColor(c, QsciLexerPython::FunctionMethodName); 24 | c = COLOR_ERROR; 25 | lexer->setColor(c, QsciLexerPython::DoubleQuotedFString); 26 | lexer->setColor(c, QsciLexerPython::SingleQuotedFString); 27 | lexer->setColor(c, QsciLexerPython::TripleSingleQuotedFString); 28 | lexer->setColor(c, QsciLexerPython::TripleDoubleQuotedFString); 29 | // Identifier 30 | } 31 | -------------------------------------------------------------------------------- /lexer/xorg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef QSCILEXERXORG_H 20 | #define QSCILEXERXORG_H 21 | 22 | #include 23 | 24 | class QsciLexerXorg : public QsciLexerCustom { 25 | Q_OBJECT 26 | public: 27 | QsciLexerXorg(QObject *parent); 28 | // const char *keywords(int set) const; 29 | void updateColors(); 30 | virtual void styleText (int start, int end); 31 | virtual const char *language () const { return "Xorg"; } 32 | virtual QString description(int style) const {Q_UNUSED(style); return "Xorg"; } 33 | /* const char* blockEnd(int *style = 0) const; 34 | const char* blockStart(int *style = 0) const; 35 | const char* blockStartKeyword(int *style = 0) const;*/ 36 | 37 | }; 38 | 39 | #endif // QSCILEXERXORG_H -------------------------------------------------------------------------------- /lexer/nim.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #include "lexer/nim.h" 21 | 22 | 23 | QsciLexerNIM::QsciLexerNIM(QObject *parent) : QsciLexerPython(parent) 24 | { 25 | } 26 | 27 | 28 | const char *QsciLexerNIM::keywords(int set) const 29 | { 30 | if (set == 1) 31 | return "addr and as asm bind block break case cast concept" 32 | "const continue converter defer discard distinct div do elif else end enum " 33 | "except export finally for from func if import in include interface is " 34 | "isnot iterator let macro method mixin mod nil not notin object of or out " 35 | "proc ptr raise ref return shl shr static template try tuple type " 36 | "using var when while xor yield"; 37 | return nullptr; 38 | } 39 | -------------------------------------------------------------------------------- /lexer/pkgbuild.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef QSCILEXERPKGBUILD_H 20 | #define QSCILEXERPKGBUILD_H 21 | 22 | #include 23 | #include 24 | 25 | class PkgBuildAPI : public QsciAbstractAPIs { 26 | public: 27 | PkgBuildAPI(QsciLexer *lexer); 28 | void updateAutoCompletionList(const QStringList &context, QStringList &list); 29 | QStringList callTips(const QStringList &context, int commas, QsciScintilla::CallTipsStyle style, QList &shifts); 30 | }; 31 | 32 | class QsciLexerPkgBuild : public QsciLexerBash { 33 | Q_OBJECT 34 | public: 35 | QsciLexerPkgBuild(QObject *parent); 36 | virtual const char *language () const { return "PkgBuild"; } 37 | virtual QString description(int style) const {Q_UNUSED(style); return "PkgBuild"; } 38 | }; 39 | 40 | #endif // QSCILEXERPKGBUILD_H -------------------------------------------------------------------------------- /colors/css.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsCSS(QsciLexerCSS *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerCSS::Default); 4 | lexer->setColor(COLOR_COMMENT, QsciLexerCSS::Comment); 5 | 6 | 7 | QColor c = COLOR_NUMBER; 8 | lexer->setColor(c, QsciLexerCSS::CSS1Property); 9 | lexer->setColor(c, QsciLexerCSS::CSS2Property); 10 | lexer->setColor(c, QsciLexerCSS::CSS3Property); 11 | lexer->setColor(c, QsciLexerCSS::ExtendedCSSProperty); 12 | 13 | c = COLOR_CHAR; 14 | lexer->setColor(c, QsciLexerCSS::ClassSelector); 15 | lexer->setColor(c, QsciLexerCSS::IDSelector); 16 | 17 | c = COLOR_OPERATOR; 18 | lexer->setColor(c, QsciLexerCSS::Operator); 19 | lexer->setColor(c, QsciLexerCSS::Tag); 20 | 21 | c = COLOR_KEYWORD; 22 | lexer->setColor(c, QsciLexerCSS::PseudoClass); 23 | lexer->setColor(c, QsciLexerCSS::ExtendedPseudoClass); 24 | lexer->setColor(c, QsciLexerCSS::PseudoElement); 25 | lexer->setColor(c, QsciLexerCSS::ExtendedPseudoElement); 26 | 27 | c = COLOR_PREPROC; 28 | lexer->setColor(c, QsciLexerCSS::MediaRule); 29 | lexer->setColor(c, QsciLexerCSS::AtRule); 30 | 31 | 32 | c = COLOR_STRING; 33 | lexer->setColor(c, QsciLexerCSS::DoubleQuotedString); 34 | lexer->setColor(c, QsciLexerCSS::SingleQuotedString); 35 | lexer->setColor(c, QsciLexerCSS::Attribute); 36 | 37 | c = COLOR_ERROR; 38 | lexer->setColor(c, QsciLexerCSS::UnknownPseudoClass); 39 | lexer->setColor(c, QsciLexerCSS::UnknownProperty); 40 | lexer->setColor(c, QsciLexerCSS::Important); 41 | 42 | // Value 43 | // Variable 44 | } 45 | -------------------------------------------------------------------------------- /lexer/lisp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2022 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef QSCILEXERLISP_H 20 | #define QSCILEXERLISP_H 21 | 22 | // class QStringList; 23 | 24 | #include 25 | 26 | class QsciLexerLISP : public QsciLexerCustom { 27 | Q_OBJECT 28 | public: 29 | QsciLexerLISP(QObject *parent); 30 | void updateColors(); 31 | void setKeywords(const char *keywords); 32 | virtual void styleText (int start, int end); 33 | virtual const char *language () const { return "LISP"; } 34 | virtual QString description(int style) const {Q_UNUSED(style); return "LISP"; } 35 | // virtual int blockLookback() const 36 | // virtual const char *blockStartKeyword(int *style = 0) const { return "("; } 37 | // virtual const char *blockStart(int *style = 0) const { return "("; } 38 | // virtual const char *blockEnd(int *style = 0) const { return ")"; } 39 | private: 40 | QStringList m_keywords; 41 | }; 42 | 43 | #endif // QSCILEXERMARKDOWN2_H -------------------------------------------------------------------------------- /colors/coffeescript.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsCoffeeScript(QsciLexerCoffeeScript *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerCoffeeScript::Default); 4 | QColor c = COLOR_COMMENT; 5 | lexer->setColor(c, QsciLexerCoffeeScript::Comment); 6 | lexer->setColor(c, QsciLexerCoffeeScript::CommentLine); 7 | lexer->setColor(c, QsciLexerCoffeeScript::CommentDoc); 8 | lexer->setColor(c, QsciLexerCoffeeScript::CommentBlock); 9 | lexer->setColor(c, QsciLexerCoffeeScript::BlockRegexComment); 10 | c = COLOR_STRING; 11 | lexer->setColor(c, QsciLexerCoffeeScript::DoubleQuotedString); 12 | lexer->setColor(c, QsciLexerCoffeeScript::VerbatimString); 13 | lexer->setColor(COLOR_CHAR, QsciLexerCoffeeScript::SingleQuotedString); 14 | c = COLOR_PREPROC; 15 | lexer->setColor(c, QsciLexerCoffeeScript::PreProcessor); 16 | lexer->setColor(c, QsciLexerCoffeeScript::Regex); 17 | lexer->setColor(c, QsciLexerCoffeeScript::BlockRegex); 18 | lexer->setColor(c, QsciLexerCoffeeScript::InstanceProperty); 19 | c = COLOR_NUMBER; 20 | lexer->setColor(c, QsciLexerCoffeeScript::Number); 21 | lexer->setColor(c, QsciLexerCoffeeScript::UUID); 22 | c = COLOR_OPERATOR; 23 | lexer->setColor(c, QsciLexerCoffeeScript::Operator); 24 | lexer->setColor(c, QsciLexerCoffeeScript::CommentDocKeyword); 25 | c = COLOR_KEYWORD; 26 | lexer->setColor(c, QsciLexerCoffeeScript::Keyword); 27 | lexer->setColor(c, QsciLexerCoffeeScript::KeywordSet2); 28 | lexer->setColor(c, QsciLexerCoffeeScript::GlobalClass); 29 | c = COLOR_ERROR; 30 | lexer->setColor(c, QsciLexerCoffeeScript::CommentDocKeywordError); 31 | lexer->setColor(c, QsciLexerCoffeeScript::UnclosedString); 32 | // Identifier 33 | } 34 | -------------------------------------------------------------------------------- /scrollbar.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "scrollbar.h" 25 | 26 | #include 27 | 28 | ScrollBar::ScrollBar() : QScrollBar() {} 29 | 30 | void ScrollBar::paintEvent(QPaintEvent *event) 31 | { 32 | QScrollBar::paintEvent(event); 33 | if (maximum() < 1) 34 | return; 35 | QPainter p(this); 36 | p.setPen(Qt::white); 37 | p.setCompositionMode(QPainter::RasterOp_SourceXorDestination); 38 | QStyleOptionSlider opt; 39 | initStyleOption(&opt); 40 | opt.subControls = QStyle::SC_All; 41 | QRect groove = style()->subControlRect(QStyle::CC_ScrollBar, &opt, QStyle::SC_ScrollBarGroove, this); 42 | groove.adjust(groove.width()/3, 0, -groove.width()/3, 0); 43 | foreach (int marker, m_markers) { 44 | int y = groove.y() + groove.height()*marker/maximum(); 45 | p.drawLine(groove.left(), y, groove.right(), y); 46 | } 47 | } -------------------------------------------------------------------------------- /lexer/rust.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2025 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #include 20 | #include "lexer/rust.h" 21 | 22 | 23 | QsciLexerRust::QsciLexerRust(QObject *parent) : QsciLexerCPP(parent) 24 | { 25 | } 26 | 27 | const char *QsciLexerRust::keywords(int set) const 28 | { 29 | if (set == 1) { 30 | return 31 | "as break const continue crate else enum extern false fn for " 32 | "if impl in let loop match mod move mut pub ref " 33 | "self Self static struct super trait true type use where while " 34 | "async await dyn " 35 | "bool integer float char str None " 36 | "String OsStr OsString Path PathBuf CStr CString Vec Option " 37 | "Result Box Rc Arc Cell Mutex RwLock Condvar Duration HashMap " 38 | "BTreeMap"; 39 | } 40 | if (set == 2) { 41 | return 42 | "return unsafe println! i8 u8 i32 u32 i64 u64 f32 f64 isize usize"; 43 | } 44 | /* 45 | if (set == 3) { 46 | } 47 | */ 48 | /* if (set == 4) { // operator 49 | } 50 | */ 51 | return QsciLexerCPP::keywords(set); 52 | } 53 | -------------------------------------------------------------------------------- /lexer/awk.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #include "lexer/awk.h" 21 | 22 | 23 | QsciLexerAWK::QsciLexerAWK(QObject *parent) : QsciLexerBash(parent) 24 | { 25 | } 26 | 27 | 28 | const char *QsciLexerAWK::keywords(int set) const 29 | { 30 | if (set == 1) 31 | return "break case continue default do else exit function for if in " 32 | "next return switch while @include delete nextfile print printf " 33 | "BEGIN BEGINFILE END atan2 cos exp int log rand sin sqrt srand " 34 | "asort asorti gensub gsub index length match patsplit split " 35 | "sprintf strtonum sub substr tolower toupper close fflush " 36 | "system mktime strftime systime and compl lshift rshift xor " 37 | "isarray bindtextdomain dcgettext dcngettext" //; 38 | // if (set == 2) 39 | " ARGC ARGIND ARGV FILENAME FNR FS NF NR OFMT OFS ORS RLENGTH RS" 40 | "RSTART SUBSEP TEXTDOMAIN BINMODE CONVFMT FIELDWIDTHS FPAT " 41 | "IGNORECASE LINT TEXTDOMAIN ENVIRON ERRNO PROCINFO RT"; 42 | return nullptr; 43 | } 44 | -------------------------------------------------------------------------------- /colors/ruby.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsRuby(QsciLexerRuby *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerRuby::Default); 4 | QColor c = COLOR_COMMENT; 5 | lexer->setColor(c, QsciLexerRuby::Comment); 6 | lexer->setColor(c, QsciLexerRuby::ModuleName); 7 | c = COLOR_STRING; 8 | lexer->setColor(c, QsciLexerRuby::DoubleQuotedString); 9 | lexer->setColor(c, QsciLexerRuby::PercentStringQ); 10 | lexer->setColor(c, QsciLexerRuby::Stdin); 11 | lexer->setColor(c, QsciLexerRuby::HereDocument); 12 | c = COLOR_CHAR; 13 | lexer->setColor(c, QsciLexerRuby::SingleQuotedString); 14 | lexer->setColor(c, QsciLexerRuby::PercentStringq); 15 | c = COLOR_PREPROC; 16 | lexer->setColor(c, QsciLexerRuby::DataSection); 17 | lexer->setColor(c, QsciLexerRuby::Keyword); // yeah, it's odd 18 | lexer->setColor(c, QsciLexerRuby::Regex); 19 | lexer->setColor(c, QsciLexerRuby::PercentStringr); 20 | lexer->setColor(c, QsciLexerRuby::Symbol); 21 | c = COLOR_NUMBER; 22 | lexer->setColor(c, QsciLexerRuby::Number); 23 | lexer->setColor(c, QsciLexerRuby::PercentStringw); 24 | lexer->setColor(c, QsciLexerRuby::POD); 25 | c = COLOR_OPERATOR; 26 | lexer->setColor(c, QsciLexerRuby::Operator); 27 | lexer->setColor(c, QsciLexerRuby::HereDocumentDelimiter); 28 | lexer->setColor(c, QsciLexerRuby::Backticks); 29 | lexer->setColor(c, QsciLexerRuby::PercentStringx); 30 | c = COLOR_KEYWORD; 31 | lexer->setColor(c, QsciLexerRuby::ClassName); 32 | lexer->setColor(c, QsciLexerRuby::FunctionMethodName); 33 | lexer->setColor(c, QsciLexerRuby::DemotedKeyword); 34 | lexer->setColor(c, QsciLexerRuby::Global); 35 | c = COLOR_ERROR; 36 | lexer->setColor(c, QsciLexerRuby::Error); 37 | lexer->setColor(c, QsciLexerRuby::Stderr); 38 | lexer->setColor(c, QsciLexerRuby::ClassVariable); 39 | // Identifier 40 | // Stdout 41 | // InstanceVariable 42 | } 43 | -------------------------------------------------------------------------------- /colors/cpp.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsCPP(QsciLexerCPP *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerCPP::Default); 4 | QColor c = COLOR_COMMENT; 5 | lexer->setColor(c, QsciLexerCPP::Comment); 6 | lexer->setColor(c, QsciLexerCPP::CommentLine); 7 | lexer->setColor(c, QsciLexerCPP::CommentDoc); 8 | lexer->setColor(c, QsciLexerCPP::CommentLineDoc); 9 | lexer->setColor(c, QsciLexerCPP::PreProcessorComment); 10 | lexer->setColor(c, QsciLexerCPP::PreProcessorCommentLineDoc); 11 | c = COLOR_STRING; 12 | lexer->setColor(c, QsciLexerCPP::DoubleQuotedString); 13 | lexer->setColor(c, QsciLexerCPP::VerbatimString); 14 | lexer->setColor(c, QsciLexerCPP::RawString); 15 | lexer->setColor(c, QsciLexerCPP::TripleQuotedVerbatimString); 16 | lexer->setColor(c, QsciLexerCPP::HashQuotedString); 17 | c = COLOR_CHAR; 18 | lexer->setColor(c, QsciLexerCPP::SingleQuotedString); 19 | lexer->setColor(c, QsciLexerCPP::EscapeSequence); 20 | c = COLOR_PREPROC; 21 | lexer->setColor(c, QsciLexerCPP::PreProcessor); 22 | lexer->setColor(c, QsciLexerCPP::Regex); 23 | lexer->setColor(c, QsciLexerCPP::TaskMarker); 24 | lexer->setColor(c, QsciLexerCPP::UserLiteral); 25 | lexer->setColor(c, QsciLexerCPP::KeywordSet2); // we use that for Qt macros 26 | //lexer->setColor(c, QsciLexerCPP::Identifier); // everything is an identifier… 27 | c = COLOR_NUMBER; 28 | lexer->setColor(c, QsciLexerCPP::Number); 29 | lexer->setColor(c, QsciLexerCPP::UUID); 30 | c = COLOR_OPERATOR; 31 | lexer->setColor(c, QsciLexerCPP::Operator); 32 | lexer->setColor(c, QsciLexerCPP::CommentDocKeyword); 33 | lexer->setColor(c, QsciLexerCPP::GlobalClass); // type isn't used by QsciLexerCPP, we use it for more ops 34 | c = COLOR_KEYWORD; 35 | lexer->setColor(c, QsciLexerCPP::Keyword); 36 | c = COLOR_ERROR; 37 | lexer->setColor(c, QsciLexerCPP::CommentDocKeywordError); 38 | lexer->setColor(c, QsciLexerCPP::UnclosedString); 39 | } 40 | -------------------------------------------------------------------------------- /sqriptor.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 33 | 35 | 39 | 45 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /colors/markdown.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | markdown is special and different from other code highlight. 3 | 1. we'll default to sans-serif 4 | 2. we operate on font size and weight and slant and whatnot 5 | */ 6 | 7 | 8 | static void setColorsMarkdown(QsciLexerMarkdown *lexer) 9 | { 10 | QFont dafont("sans-serif", 9); 11 | lexer->setFont(dafont, QsciLexerMarkdown::Default); 12 | QFont font = dafont; 13 | font.setBold(true); 14 | lexer->setFont(font, QsciLexerMarkdown::EmphasisAsterisks); 15 | lexer->setFont(font, QsciLexerMarkdown::Header6); 16 | font.setStretch(110); 17 | lexer->setFont(font, QsciLexerMarkdown::Header5); 18 | font.setStretch(120); 19 | lexer->setFont(font, QsciLexerMarkdown::Header4); 20 | font.setStretch(130); 21 | lexer->setFont(font, QsciLexerMarkdown::Header3); 22 | font.setStretch(140); 23 | lexer->setFont(font, QsciLexerMarkdown::Header2); 24 | font.setStretch(150); 25 | lexer->setFont(font, QsciLexerMarkdown::Header1); 26 | 27 | QColor c = COLOR_NUMBER; 28 | font = dafont; font.setItalic(true); 29 | lexer->setFont(font, QsciLexerMarkdown::UnorderedListItem); 30 | lexer->setFont(font, QsciLexerMarkdown::OrderedListItem); 31 | lexer->setColor(c, QsciLexerMarkdown::UnorderedListItem); 32 | lexer->setColor(c, QsciLexerMarkdown::OrderedListItem); 33 | 34 | font.setBold(true); 35 | lexer->setFont(font, QsciLexerMarkdown::StrongEmphasisAsterisks); 36 | lexer->setFont(font, QsciLexerMarkdown::StrongEmphasisUnderscores); 37 | 38 | font = dafont; font.setItalic(true); 39 | lexer->setFont(font, QsciLexerMarkdown::EmphasisUnderscores); 40 | 41 | font = dafont; font.setFamily("monospace"); 42 | lexer->setFont(font, QsciLexerMarkdown::Prechar); 43 | lexer->setFont(font, QsciLexerMarkdown::CodeBlock); 44 | lexer->setFont(font, QsciLexerMarkdown::CodeBackticks); 45 | lexer->setFont(font, QsciLexerMarkdown::CodeDoubleBackticks); 46 | 47 | font = dafont; font.setStrikeOut(true); 48 | lexer->setFont(font, QsciLexerMarkdown::StrikeOut); 49 | 50 | lexer->setColor(qApp->palette().color(QPalette::Link), QsciLexerMarkdown::Link); 51 | lexer->setColor(COLOR_STRING, QsciLexerMarkdown::BlockQuote); 52 | lexer->setColor(COLOR_PREPROC, QsciLexerMarkdown::Special); 53 | lexer->setColor(COLOR_COMMENT, QsciLexerMarkdown::HorizontalRule); 54 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sqriptor ![Sqriptor Logo](sqriptor256.png) 2 | #### QScintilla based text editor 3 | 4 | > "Every man should plant a tree, have a son and write a TextEditor"
5 | >                          --- Proverb 6 | 7 | > "The best TextEditor I've ever used!"
8 | >      --- Undisclosed user, 2021 9 | 10 | > "Testimonials are useless, just try whether you like it."
11 | >                  --- Common sense 12 | 13 | 14 | #### Obligatory screenshot: 15 | (spoiler, it's mostly text… nicely blurred by github) 16 | ![Screenshot](scrot.png) 17 | 18 | ## NAQ 19 | ##### Never Asked Questions 20 | * Q: What about _random webengine/blink/electron based editor_? 21 | * A: I'm not using a WebBrowser as a TextEditor. Are you nuts? Also performance, frankly. 22 | * Q: What about Scite, it's scintilla - do you hate gtk? 23 | * A: Somewhat. But more importantly scite exposes all scintilla configurations directly to the user. The html lexer alone has a trillion… ok, that's exaggerated: half a trillion syntax items. It's very configurable. Through text files. It's not configurable at all. 24 | * Q: What about vim? 25 | * A: I like vim. It's a great text editor. And in the hands of average humans an even better entropy generator. 26 | * Q: KWrite/Kate? 27 | * A: Very good editor. And half a Desktop Environment on its tail :( 28 | * Q: There're _feature rich IDEs and EMacs_ … 29 | * A: Yes. And here is a text editor. Your point being? 30 | * Q: If it can't read from stdin, it's not real POSIX! Can sqriptor read from stdin? 31 | * A: Yes :) 32 | * Q: Your TextEditor sucks! Sqriptor sucks! 33 | * A: Your opinion sucks. But if you can structure your criticism into a coherent bug report, feel free to issue it [–> here](https://github.com/luebking/sqriptor/issues) 34 | 35 | ## Build/requirements 36 | * Qt5 (feel free to try Qt6) 37 | * QScintilla 38 | * Most distros: **don't forget the \*-dev packages** 39 | * Ubuntu / Debian: *libqscintilla2-qt5-dev* 40 | * Fedora: tba (fedora doesn't have a web-database for their packages) 41 | * SuSE: *libqscintilla_qt5-devel* (warning: the library package is *libqscintilla**2**\_qt5-\** because … reasons) & *libQt5Core-devel* & *libQt5Widgets-devel* 42 | * ```qmake && make && ./sqriptor``` 43 | -------------------------------------------------------------------------------- /lexer/pkgbuild.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #include 20 | 21 | #include "lexer/pkgbuild.h" 22 | 23 | PkgBuildAPI::PkgBuildAPI(QsciLexer *lexer) : QsciAbstractAPIs(lexer) { } 24 | 25 | void PkgBuildAPI::updateAutoCompletionList(const QStringList &context, QStringList &list) 26 | { 27 | static QStringList api = { "pkgname=()", "pkgver=", "pkgrel=", "epoch=", "pkgdesc=", 28 | "url=", "license=()", "install=", "changelog=", "source=()", "validpgpkeys=()", 29 | "noextract=()", "cksums=()", "md5sums=()", "sha1sums=()", "sha224sums=()", 30 | "sha256sums=()", "sha384sums=()", "sha512sums=()", "b2sums=()", "groups=()", 31 | "arch=()", "backup=()", "depends=()", "makedepends=()", "checkdepends=()", 32 | "optdepends=()", "conflicts=()", "provides=()", "replaces=()", "options=()", 33 | "package(){}", "prepare(){}", "build(){}", "check(){}", "srcdir=", "pkgdir=", 34 | "pkgbase=" }; 35 | 36 | const QString &token = context.last(); 37 | foreach (const QString &str, api) { 38 | if (str.startsWith(token)) 39 | list << str; 40 | } 41 | } 42 | 43 | QStringList PkgBuildAPI::callTips(const QStringList &context, int commas, QsciScintilla::CallTipsStyle style, QList &shifts) 44 | { 45 | Q_UNUSED(context); Q_UNUSED(commas); Q_UNUSED(style); Q_UNUSED(shifts); 46 | static QStringList opts = { "strip", "docs", "libtool", "staticlibs", "emptydirs", 47 | "zipman", "ccache", "distcc", "buildflags", "makeflags", "debug", "lto" }; 48 | // qDebug() << context << commas << shifts; 49 | return QStringList(); 50 | } 51 | 52 | 53 | QsciLexerPkgBuild::QsciLexerPkgBuild(QObject *parent) : QsciLexerBash(parent) 54 | { 55 | setAPIs(new PkgBuildAPI(this)); 56 | } 57 | -------------------------------------------------------------------------------- /colors/perl.cpp: -------------------------------------------------------------------------------- 1 | static void setColorsPerl(QsciLexerPerl *lexer) 2 | { 3 | lexer->setColor(COLOR_FOREGROUND, QsciLexerPerl::Default); 4 | QColor c = COLOR_COMMENT; 5 | lexer->setColor(c, QsciLexerPerl::Comment); 6 | lexer->setColor(c, QsciLexerPerl::POD); 7 | lexer->setColor(c, QsciLexerPerl::PODVerbatim); 8 | lexer->setColor(c, QsciLexerPerl::Translation); 9 | lexer->setColor(c, QsciLexerPerl::DataSection); 10 | 11 | c = COLOR_STRING; 12 | lexer->setColor(c, QsciLexerPerl::DoubleQuotedString); 13 | lexer->setColor(c, QsciLexerPerl::QuotedStringQQ); 14 | lexer->setColor(c, QsciLexerPerl::QuotedStringQQVar); 15 | lexer->setColor(c, QsciLexerPerl::DoubleQuotedStringVar); 16 | lexer->setColor(c, QsciLexerPerl::SubstitutionVar); 17 | lexer->setColor(c, QsciLexerPerl::DoubleQuotedHereDocument); 18 | lexer->setColor(c, QsciLexerPerl::DoubleQuotedHereDocumentVar); 19 | 20 | c = COLOR_CHAR; 21 | lexer->setColor(c, QsciLexerPerl::SingleQuotedString); 22 | lexer->setColor(c, QsciLexerPerl::QuotedStringQ); 23 | lexer->setColor(c, QsciLexerPerl::SingleQuotedHereDocument); 24 | 25 | c = COLOR_PREPROC; 26 | lexer->setColor(c, QsciLexerPerl::Regex); 27 | lexer->setColor(c, QsciLexerPerl::RegexVar); 28 | lexer->setColor(c, QsciLexerPerl::QuotedStringQR); 29 | lexer->setColor(c, QsciLexerPerl::QuotedStringQRVar); 30 | lexer->setColor(c, QsciLexerPerl::SymbolTable); 31 | lexer->setColor(c, QsciLexerPerl::FormatIdentifier); 32 | lexer->setColor(c, QsciLexerPerl::QuotedStringQW); 33 | 34 | c = COLOR_NUMBER; 35 | lexer->setColor(c, QsciLexerPerl::Number); 36 | lexer->setColor(c, QsciLexerPerl::Scalar); 37 | lexer->setColor(c, QsciLexerPerl::Array); 38 | lexer->setColor(c, QsciLexerPerl::Hash); 39 | 40 | c = COLOR_OPERATOR; 41 | lexer->setColor(c, QsciLexerPerl::Operator); 42 | lexer->setColor(c, QsciLexerPerl::QuotedStringQXVar); 43 | lexer->setColor(c, QsciLexerPerl::QuotedStringQX); 44 | lexer->setColor(c, QsciLexerPerl::Backticks); 45 | lexer->setColor(c, QsciLexerPerl::BackticksVar); 46 | lexer->setColor(c, QsciLexerPerl::HereDocumentDelimiter); 47 | lexer->setColor(c, QsciLexerPerl::BacktickHereDocument); 48 | lexer->setColor(c, QsciLexerPerl::BacktickHereDocumentVar); 49 | 50 | c = COLOR_KEYWORD; 51 | lexer->setColor(c, QsciLexerPerl::Keyword); 52 | lexer->setColor(c, QsciLexerPerl::SubroutinePrototype); 53 | lexer->setColor(c, QsciLexerPerl::Substitution); 54 | 55 | lexer->setColor(COLOR_ERROR, QsciLexerPerl::Error); 56 | // Identifier 57 | // FormatBody 58 | } 59 | -------------------------------------------------------------------------------- /lexer/fontconfig.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #include 20 | #include "lexer/fontconfig.h" 21 | 22 | 23 | QsciLexerFontConfig::QsciLexerFontConfig(QObject *parent) : QsciLexerXML(parent) 24 | { 25 | } 26 | 27 | 28 | const char *QsciLexerFontConfig::keywords(int set) const 29 | { 30 | // qDebug() << "queried set " << set; 31 | if (set == 1) 32 | return "fontconfig dir cachedir include match alias config blank rescan selectfont " 33 | "acceptfont rejectfont glob pattern patelt match test edit int double string bool " 34 | "matrix range charset langset name const or and plus minus times divide " 35 | "eq not_eq less less_eq more more_eq contains not_contains not if family prefer " 36 | "accept default xml description" // elements 37 | "family familylang style stylelang fullname fullnamelang slant weight size width " 38 | "aspect pixelsize spacing foundry antialias hinting hintstyle verticallayout " 39 | "autohint globaladvance file index ftface rasterizer outline scalable scale " 40 | "dpi rgba lcdfilter minspace charset lang fontversion capability embolden " 41 | "fontfeatures prgname target mode qual binding compare ignore-blanks version"; // attributes 42 | if (set == 2) /// JS keyword abuse, @todo doesn't work… 43 | return "thin extralight ultralight light book regular normal medium demibold semibold " 44 | "bold extrabold black heavy roman italic oblique ultracondensed extracondensed " 45 | "condensed semicondensed normal semiexpanded expanded extraexpanded ultraexpanded " 46 | "proportional dual mono charcell unknown rgb bgr vrgb vbgr none lcdnone lcddefault " 47 | "lcdlight lcdlegacy hintnone hintslight hintmedium hintfull"; // consts 48 | if (set == 6) 49 | return QsciLexerXML::keywords(set); 50 | return nullptr; 51 | } 52 | -------------------------------------------------------------------------------- /lexer/glsl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2025 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #include 20 | #include "lexer/glsl.h" 21 | 22 | 23 | QsciLexerGLSL::QsciLexerGLSL(QObject *parent) : QsciLexerCPP(parent) 24 | { 25 | } 26 | 27 | const char *QsciLexerGLSL::keywords(int set) const 28 | { 29 | if (set == 1) { 30 | return 31 | "auto if break int case long char register continue default short do sizeof " 32 | "double static else struct entry switch extern typedef float union for unsigned " 33 | "goto while enum void const signed volatile " 34 | "mat2 mat3 mat4 dmat2 dmat3 dmat4 mat2x2 mat2x3 mat2x4 " 35 | "dmat2x2 dmat2x3 dmat2x4 mat3x2 mat3x3 mat3x4 dmat3x2 dmat3x3 " 36 | "dmat3x4 mat4x2 mat4x3 mat4x4 dmat4x2 dmat4x3 dmat4x4 " 37 | "vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 dvec2 dvec3 dvec4 " 38 | "uvec2 uvec3 uvec4 lowp mediump highp precision " 39 | "sampler1D sampler2D sampler3D samplerCube " 40 | "sampler1DShadow sampler2DShadow samplerCubeShadow " 41 | "sampler1DArray sampler2DArray sampler1DArrayShadow sampler2DArrayShadow " 42 | "isampler1D isampler2D isampler3D isamplerCube isampler1DArray isampler2DArray " 43 | "usampler1D usampler2D usampler3D usamplerCube usampler1DArray " 44 | "usampler2DArray sampler2DRect sampler2DRectShadow isampler2DRect usampler2DRect " 45 | "samplerBuffer isamplerBuffer usamplerBuffer sampler2DMS isampler2DMS " 46 | "usampler2DMS sampler2DMSArray isampler2DMSArray usampler2DMSArray samplerCubeArray " 47 | "samplerCubeArrayShadow isamplerCubeArray usamplerCubeArray"; 48 | } 49 | if (set == 2) { 50 | // qDebug() << QsciLexerCPP::keywords(set); 51 | return 52 | "return attribute uniform varying layout centroid flat smooth " 53 | "noperspective patch sample subroutine in out inout invariant discard"; 54 | } 55 | /* 56 | if (set == 3) { 57 | } 58 | */ 59 | 60 | if (set == 4) { // reserved 61 | return 62 | "common partition active asm class union enum typedef template this " 63 | "packed goto inline noinline volatile public static extern external " 64 | "interface long short half fixed unsigned superp input output " 65 | "hvec2 hvec3 hvec4 fvec2 fvec3 fvec4 sampler3DRect filter " 66 | "image1D image2D image3D imageCube iimage1D iimage2D iimage3D " 67 | "iimageCube uimage1D uimage2D uimage3D uimageCube image1DArray " 68 | "image2DArray iimage1DArray iimage2DArray uimage1DArray " 69 | "uimage2DArray image1DShadow image2DShadow image1DArrayShadow " 70 | "image2DArrayShadow imageBuffer iimageBuffer uimageBuffer " 71 | "sizeof cast namespace using row_major"; 72 | } 73 | 74 | return QsciLexerCPP::keywords(set); 75 | } 76 | -------------------------------------------------------------------------------- /lexer/xorglog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "../sqriptor.h" 26 | #include "lexer/xorglog.h" 27 | 28 | namespace Style { 29 | enum Type { 30 | Default = 0, Probed, Config, ServerDefault, Commandline, Notice, 31 | Info, Warning, Error, Unimplemented, Unknown, Count 32 | }; 33 | }; 34 | 35 | QsciLexerXorgLog::QsciLexerXorgLog(QObject *parent) : QsciLexerCustom(parent) 36 | { 37 | } 38 | 39 | void QsciLexerXorgLog::updateColors() 40 | { 41 | setPaper(Sqriptor::config.color.bg); 42 | setColor(Sqriptor::config.color.comment); 43 | setColor(Sqriptor::config.color.comment, Style::Default); 44 | setColor(Sqriptor::config.color.string, Style::Config); 45 | setColor(Sqriptor::config.color.number, Style::Probed); 46 | setColor(Sqriptor::config.color.preproc, Style::ServerDefault); 47 | setColor(Sqriptor::config.color.character, Style::Commandline); 48 | setColor(Sqriptor::config.color.operateur, Style::Notice); 49 | setColor(Sqriptor::config.color.fg, Style::Info); 50 | setColor(Sqriptor::config.color.operateur, Style::Warning); 51 | setColor(Sqriptor::config.color.error, Style::Error); 52 | setColor(Sqriptor::config.color.error, Style::Unimplemented); 53 | setColor(Sqriptor::config.color.error, Style::Unknown); 54 | // keyword 55 | } 56 | 57 | static inline void testToken(char byte, int *indicator, const char *lower) 58 | { 59 | int idx = *indicator; 60 | if (idx >= 4) 61 | return; 62 | if (byte == lower[idx]) 63 | ++(*indicator); 64 | else 65 | *indicator = 0; 66 | } 67 | 68 | void QsciLexerXorgLog::styleText (int start, int end) 69 | { 70 | int length = 0; 71 | int type[Style::Count] = {0}; 72 | 73 | QByteArray text = editor()->bytes(start, end); 74 | startStyling(start); 75 | for (int i = 0; i < end - start; ++i) { 76 | ++length; 77 | if (text.at(i) == '\n') { 78 | Style::Type style = Style::Default; 79 | for (int i = 1; i < Style::Count; ++i) { 80 | if (type[i] >= 4) { 81 | if (style != Style::Default) { 82 | style = Style::Default; 83 | break; // 84 | } 85 | style = static_cast(i); 86 | } 87 | } 88 | setStyling(length, style); 89 | length = 0; 90 | for (int i = 0; i < Style::Count; ++i) type[i] = 0; 91 | continue; 92 | } 93 | testToken(text.at(i), &type[Style::Probed], "(--)"); 94 | testToken(text.at(i), &type[Style::Config], "(**)"); 95 | testToken(text.at(i), &type[Style::ServerDefault], "(==)"); 96 | testToken(text.at(i), &type[Style::Commandline], "(++)"); 97 | testToken(text.at(i), &type[Style::Notice], "(!!)"); 98 | testToken(text.at(i), &type[Style::Info], "(II)"); 99 | testToken(text.at(i), &type[Style::Warning], "(WW)"); 100 | testToken(text.at(i), &type[Style::Error], "(EE)"); 101 | testToken(text.at(i), &type[Style::Unimplemented], "(NI)"); 102 | testToken(text.at(i), &type[Style::Unknown], "(?""?)"); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /lexer/cppqt.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2025 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #include 20 | #include "lexer/cppqt.h" 21 | 22 | 23 | QsciLexerCPPQt::QsciLexerCPPQt(QObject *parent) : QsciLexerCPP(parent) 24 | { 25 | } 26 | 27 | /* 28 | https://en.cppreference.com/w/cpp/keyword 29 | 30 | alignas (C++11) 31 | alignof (C++11) 32 | char8_t (C++20) 33 | char16_t (C++11) 34 | char32_t (C++11) 35 | concept (C++20) 36 | consteval (C++20) (5) 37 | constexpr (C++11) (3) 38 | constinit (C++20) 39 | co_await (C++20) 40 | co_return (C++20) 41 | co_yield (C++20) 42 | decltype (C++11) 43 | noexcept (C++11) 44 | nullptr (C++11) 45 | requires (C++20) 46 | static_assert (C++11) 47 | thread_local (C++11) 48 | 49 | In addition to keywords, there are identifiers with special meaning, which may be used as names 50 | of objects or functions, but have special meaning in certain contexts. 51 | ---------------------------- 52 | final (C++11) 53 | override (C++11) 54 | import (C++20) 55 | module (C++20) 56 | */ 57 | 58 | 59 | const char *QsciLexerCPPQt::keywords(int set) const 60 | { 61 | if (set == 1) { 62 | return // extended from QSciScintilla - not eager to sprintf here 63 | "and and_eq asm auto bitand bitor bool break case " 64 | "catch char class compl const const_cast continue " 65 | "default delete do double dynamic_cast else enum " 66 | "explicit export extern false float for friend goto if " 67 | "inline int long mutable namespace new " 68 | "operator or or_eq private protected public register " 69 | "reinterpret_cast short signed sizeof static " 70 | "static_cast struct switch template this throw true " 71 | "try typedef typeid typename union unsigned using " 72 | "virtual void volatile wchar_t while " 73 | // extra stuff 74 | "char8_t char16_t char32_t constexpr decltype noexcept override final " 75 | // Qt stuff 76 | "foreach qobject_cast " 77 | "qint8 qint16 qint32 qint64 qint128 qintptr qlonglong " 78 | "qptrdiff qreal qsizetype quint8 quint16 quint32 quint64 " 79 | "quint128 quintptr qulonglong uchar uint ulong ushort"; 80 | } 81 | if (set == 2) { 82 | // qDebug() << QsciLexerCPP::keywords(set); 83 | return 84 | "return nullptr alignas alignof import module " 85 | "connect disconnect emit SIGNAL signals SLOT slots tr " 86 | "Q_ARG Q_ENUM Q_OBJECT Q_RETURN_ARG Q_FLAG Q_UNUSED qDebug"; 87 | } 88 | /* 89 | if (set == 3) { 90 | return 91 | "a addindex addtogroup anchor arg attention author b " 92 | "brief bug c class code date def defgroup deprecated " 93 | "dontinclude e em endcode endhtmlonly endif " 94 | "endlatexonly endlink endverbatim enum example " 95 | "exception f$ f[ f] file fn hideinitializer " 96 | "htmlinclude htmlonly if image include ingroup " 97 | "internal invariant interface latexonly li line link " 98 | "mainpage name namespace nosubgrouping note overload " 99 | "p page par param post pre ref relates remarks return " 100 | "retval sa section see showinitializer since skip " 101 | "skipline struct subsection test throw todo typedef " 102 | "union until var verbatim verbinclude version warning " 103 | "weakgroup $ @ \\ & < > # { }"; 104 | } 105 | */ 106 | if (set == 4) { 107 | return "xor xor_eq not not_eq"; 108 | } 109 | return QsciLexerCPP::keywords(set); 110 | } 111 | -------------------------------------------------------------------------------- /sqriptor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef SQRIPTOR_H 20 | #define SQRIPTOR_H 21 | 22 | #include 23 | 24 | class QAction; 25 | class QActionGroup; 26 | class QLineEdit; 27 | class QMenu; 28 | class QTabWidget; 29 | class QsciScintilla; 30 | 31 | namespace Syntax { 32 | enum Lexer { 33 | None = 0, Auto, AVS, AWK, Bash, Batch, CMake, CoffeeScript, CPP, CSS, 34 | D, Diff, EDIFACT, Fortran77, HTML, JSON, Lua, Makefile, 35 | Markdown2, Matlab, Pascal, Perl, PO, PostScript, POV, Properties, 36 | Python, Ruby, Spice, SQL, TCL, TeX, Verilog, VHDL, YAML, 37 | CSharp, IDL, Java, JavaScript, Fortran, XML, Octave, Xorg, Journal, 38 | XorgLog, PkgBuild, NIM, LISP, FontConfig, QtPro, GLSL, Rust, Count 39 | }; 40 | }; 41 | 42 | namespace Size { enum Mode { Relative = 0, Absolute, Remember }; }; 43 | 44 | typedef struct Config 45 | { 46 | Size::Mode sizeMode; 47 | QSize size; 48 | QFont font; 49 | struct wrap { 50 | bool words; 51 | bool indicator; 52 | int indicatorPos; 53 | } wrap; 54 | struct tab { 55 | bool isTab; 56 | int width; 57 | } tab; 58 | struct color { 59 | QColor bg, fg, string, character, comment, preproc, 60 | number, operateur, keyword, error; 61 | } color; 62 | bool changed; 63 | QStringList recentFiles; 64 | QString markdownProcessor; 65 | QString previewCSS; 66 | } Config; 67 | 68 | 69 | class Sqriptor : public QMainWindow 70 | { 71 | Q_OBJECT 72 | 73 | public: 74 | Sqriptor(); 75 | void open(QString fileName, bool forceNewTab = false); 76 | QsciScintilla *textEdit(int idx = -1) const; 77 | void newFile(QString name = QString(), bool forceNewTab = false); 78 | void readStdin(); 79 | typedef Syntax::Lexer Syntax; 80 | static Config config; 81 | 82 | protected: 83 | void closeEvent(QCloseEvent *event); 84 | 85 | signals: 86 | void copyAvailable(bool); 87 | 88 | private slots: 89 | bool save(); 90 | bool saveAs(); 91 | void toggleBookmark(); 92 | void nextBookmark(); 93 | void prevBookmark(); 94 | void setSyntax(Syntax syntax = Syntax::Auto, QsciScintilla *document = nullptr, bool updateColorsOnly = false); 95 | int addTab(); 96 | bool closeTab(int idx = -1); 97 | bool toggleComment(); 98 | void showSettings(); 99 | void checkTimestamp(); 100 | void analyzeSyntaxOnce(); 101 | void copy(); 102 | void togglePreview(int idx = -1, Qt::CheckState state = Qt::PartiallyChecked); 103 | 104 | private: 105 | QRect availableGeometry() const; 106 | QMap bookmarks() const; 107 | void createUI(); 108 | void readSettings(); 109 | void writeSettings(); 110 | bool maybeSave(int idx = -1); 111 | void loadFile(const QString &fileName); 112 | bool saveFile(const QString &fileName); 113 | void setCurrentFile(const QString &fileName); 114 | Syntax syntax(QString suffix) const; 115 | void indicateCurrentSyntax(); 116 | void indicateCurrentEOL(); 117 | void updateTimestamp(QObject *o); 118 | void updatePalette(); 119 | void renderIcon(QPixmap &pix); 120 | void findAll(QString text, bool rx, bool cs, bool wo); 121 | QString ask4Codec(const QString &codec, const QString &fileName); 122 | 123 | QTabWidget *m_documents; 124 | QActionGroup *m_syntaxActions; 125 | QMenu *m_eolMenu; 126 | QAction *m_tabMenu; 127 | QAction *m_EolVis, *m_wrapped, *m_folds, *m_filterBookmarks, *m_previewAction; 128 | QLineEdit *m_filterLine; 129 | }; 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /filetype.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "sqriptor.h" 25 | 26 | /* 27 | None, AVS, Bash, Batch, CMake, CoffeeScript, CPP, CSS, 28 | D, Diff, EDIFACT, Fortran77, HTML, JSON, Lua, Makefile, 29 | Markdown2, Matlab, Pascal, Perl, PO, PostScript, POV, Properties, 30 | Python, Ruby, Spice, SQL, TCL, TeX, Verilog, VHDL, YAML, 31 | CSharp, IDL, Java, JavaScript, Fortran, XML, Octave 32 | */ 33 | 34 | Sqriptor::Syntax Sqriptor::syntax(QString suffix) const { 35 | static QRegularExpression whitespace("\\s"); 36 | suffix = suffix.section('/', -1).section(whitespace, 0, 0); 37 | if (suffix == "CMakeLists.txt") 38 | return Syntax::CMake; 39 | static QRegularExpression xorg_n_log("^xorg\\.[0-9\\.]*log\(\\.old)*$", QRegularExpression::CaseInsensitiveOption); 40 | if (xorg_n_log.match(suffix).hasMatch()) 41 | return Syntax::XorgLog; 42 | suffix = suffix.section('.', -1); 43 | static QHash suffixes; 44 | if (!suffixes.isEmpty()) 45 | return suffixes.value(suffix, Syntax::Auto); 46 | suffixes.reserve(100); 47 | suffixes["cpp"] = Syntax::CPP; 48 | suffixes["c++"] = Syntax::CPP; 49 | suffixes["cxx"] = Syntax::CPP; 50 | suffixes["cc"] = Syntax::CPP; 51 | suffixes["c"] = Syntax::CPP; 52 | suffixes["C"] = Syntax::CPP; 53 | suffixes["h"] = Syntax::CPP; 54 | suffixes["hh"] = Syntax::CPP; 55 | suffixes["cs"] = Syntax::CSharp; 56 | suffixes["html"] = Syntax::HTML; 57 | suffixes["htm"] = Syntax::HTML; 58 | suffixes["php"] = Syntax::HTML; 59 | suffixes["php3"] = Syntax::HTML; 60 | suffixes["php4"] = Syntax::HTML; 61 | suffixes["php5"] = Syntax::HTML; 62 | suffixes["phps"] = Syntax::HTML; 63 | suffixes["phtml"] = Syntax::HTML; 64 | suffixes["xml"] = Syntax::XML; 65 | suffixes["sh"] = Syntax::Bash; 66 | suffixes["bash"] = Syntax::Bash; // shebang 67 | suffixes["zsh"] = Syntax::Bash; // dto. 68 | suffixes["fish"] = Syntax::Bash; // you're welcome… 69 | suffixes["PKGBUILD"] = Syntax::PkgBuild; 70 | suffixes["md"] = Syntax::Markdown2; 71 | suffixes["pl"] = Syntax::Perl; 72 | suffixes["plx"] = Syntax::Perl; 73 | suffixes["pm"] = Syntax::Perl; 74 | suffixes["perl"] = Syntax::Perl; 75 | suffixes["py"] = Syntax::Python; 76 | suffixes["python"] = Syntax::Python; 77 | suffixes["python2"] = Syntax::Python; // shebang 78 | suffixes["python3"] = Syntax::Python; // dto. 79 | suffixes["ps"] = Syntax::PostScript; 80 | suffixes["rb"] = Syntax::Ruby; 81 | suffixes["java"] = Syntax::Java; 82 | suffixes["js"] = Syntax::JavaScript; 83 | suffixes["f77"] = Syntax::Fortran77; 84 | suffixes["f"] = Syntax::Fortran; 85 | suffixes["F"] = Syntax::Fortran; 86 | suffixes["f03"] = Syntax::Fortran; 87 | suffixes["F03"] = Syntax::Fortran; 88 | suffixes["f08"] = Syntax::Fortran; 89 | suffixes["F08"] = Syntax::Fortran; 90 | suffixes["f18"] = Syntax::Fortran; 91 | suffixes["F18"] = Syntax::Fortran; 92 | suffixes["f90"] = Syntax::Fortran; 93 | suffixes["F90"] = Syntax::Fortran; 94 | suffixes["f95"] = Syntax::Fortran; 95 | suffixes["F95"] = Syntax::Fortran; 96 | suffixes["pas"] = Syntax::Pascal; 97 | suffixes["pp"] = Syntax::Pascal; 98 | suffixes["json"] = Syntax::JSON; 99 | suffixes["bat"] = Syntax::Batch; 100 | suffixes["lua"] = Syntax::Lua; 101 | suffixes["css"] = Syntax::CSS; 102 | suffixes["tex"] = Syntax::TeX; 103 | suffixes["diff"] = Syntax::Diff; 104 | suffixes["patch"] = Syntax::Diff; 105 | suffixes["txt"] = Syntax::None; 106 | suffixes["m"] = Syntax::Matlab; 107 | suffixes["sql"] = Syntax::SQL; 108 | suffixes["yaml"] = Syntax::YAML; 109 | suffixes["yml"] = Syntax::YAML; 110 | suffixes["vhd"] = Syntax::VHDL; 111 | suffixes["tcl"] = Syntax::TCL; 112 | suffixes["tclsh"] = Syntax::TCL; // shebang 113 | suffixes["coffee"] = Syntax::CoffeeScript; 114 | suffixes["avs"] = Syntax::AVS; 115 | suffixes["ini"] = Syntax::Properties; 116 | suffixes["conf"] = Syntax::Properties; 117 | suffixes["awk"] = Syntax::AWK; 118 | suffixes["nim"] = Syntax::NIM; 119 | suffixes["lsp"] = Syntax::LISP; 120 | suffixes["lisp"] = Syntax::LISP; 121 | suffixes["el"] = Syntax::LISP; 122 | suffixes["pro"] = Syntax::QtPro; 123 | suffixes["qrc"] = Syntax::XML; 124 | suffixes["glsl"] = Syntax::GLSL; 125 | suffixes["rs"] = Syntax::Rust; 126 | 127 | suffixes["Makefile"] = Syntax::Makefile; 128 | 129 | return suffixes.value(suffix, Syntax::Auto); 130 | } -------------------------------------------------------------------------------- /lexer/qtpro.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2025 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #include "lexer/qtpro.h" 21 | //#include 22 | 23 | QsciLexerQtPro::QsciLexerQtPro(QObject *parent) : QsciLexerBash(parent) 24 | { 25 | } 26 | 27 | 28 | const char *QsciLexerQtPro::keywords(int set) const 29 | { 30 | // qDebug() << "queried set" << set; 31 | if (set == 1) return 32 | "ANDROID_ABIS ANDROID_API_VERSION ANDROID_APPLICATION_ARGUMENTS ANDROID_BUNDLED_JAR_DEPENDENCIES " 33 | "ANDROID_DEPLOYMENT_DEPENDENCIES ANDROID_DEPLOYMENT_SETTINGS_FILE ANDROID_EXTRA_LIBS ANDROID_EXTRA_PLUGINS " 34 | "ANDROID_FEATURES ANDROID_LIB_DEPENDENCIES ANDROID_MIN_SDK_VERSION ANDROID_PACKAGE_SOURCE_DIR " 35 | "ANDROID_PERMISSIONS ANDROID_TARGET_SDK_VERSION ANDROID_VERSION_CODE ANDROID_VERSION_NAME CONFIG " 36 | "DEFINES DEFINES_DEBUG DEFINES_RELEASE DEF_FILE DEPENDPATH DESTDIR DISTFILES DLLDESTDIR EXTRA_TRANSLATIONS " 37 | "FORMS GUID HEADERS ICON IDLSOURCES INCLUDEPATH INSTALLS JAVA_HOME LEXIMPLS LEXOBJECTS LEXSOURCES " 38 | "LIBS LIBS_PRIVATE LITERAL_HASH MAKEFILE MAKEFILE_GENERATOR MSVCPROJ_* MOC_DIR OBJECTIVE_HEADERS " 39 | "OBJECTIVE_SOURCES OBJECTS OBJECTS_DIR POST_TARGETDEPS PRE_TARGETDEPS PRECOMPILED_HEADER PWD OUT_PWD " 40 | "QM_FILES_RESOURCE_PREFIX QM_FILES_INSTALL_PATH QML_IMPORT_PATH QMLPATHS QMAKE QMAKESPEC QMAKE_APPLE_DEVICE_ARCHS " 41 | "QMAKE_AR_CMD QMAKE_BUNDLE_DATA QMAKE_BUNDLE_EXTENSION QMAKE_CC QMAKE_CFLAGS QMAKE_CFLAGS_DEBUG QMAKE_CFLAGS_RELEASE " 42 | "QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO QMAKE_CFLAGS_SHLIB QMAKE_CFLAGS_THREAD QMAKE_CFLAGS_WARN_OFF " 43 | "QMAKE_CFLAGS_WARN_ON QMAKE_CLEAN QMAKE_CXX QMAKE_CXXFLAGS QMAKE_CXXFLAGS_DEBUG QMAKE_CXXFLAGS_RELEASE " 44 | "QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO QMAKE_CXXFLAGS_SHLIB QMAKE_CXXFLAGS_THREAD QMAKE_CXXFLAGS_WARN_OFF " 45 | "QMAKE_CXXFLAGS_WARN_ON QMAKE_DEVELOPMENT_TEAM QMAKE_DISTCLEAN QMAKE_EXTENSION_SHLIB QMAKE_EXTENSION_STATICLIB " 46 | "QMAKE_EXT_MOC QMAKE_EXT_UI QMAKE_EXT_PRL QMAKE_EXT_LEX QMAKE_EXT_YACC QMAKE_EXT_OBJ QMAKE_EXT_CPP " 47 | "QMAKE_EXT_H QMAKE_EXTRA_COMPILERS QMAKE_EXTRA_TARGETS QMAKE_FAILED_REQUIREMENTS QMAKE_FRAMEWORK_BUNDLE_NAME " 48 | "QMAKE_FRAMEWORK_VERSION QMAKE_HOST QMAKE_INCDIR QMAKE_INCDIR_EGL QMAKE_INCDIR_OPENGL QMAKE_INCDIR_OPENGL_ES2 " 49 | "QMAKE_INCDIR_OPENVG QMAKE_INCDIR_X11 QMAKE_INFO_PLIST QMAKE_IOS_DEPLOYMENT_TARGET QMAKE_IOS_LAUNCH_SCREEN " 50 | "QMAKE_LFLAGS QMAKE_LFLAGS_CONSOLE QMAKE_LFLAGS_DEBUG QMAKE_LFLAGS_PLUGIN QMAKE_LFLAGS_RPATH QMAKE_LFLAGS_REL_RPATH " 51 | "QMAKE_REL_RPATH_BASE QMAKE_LFLAGS_RPATHLINK QMAKE_LFLAGS_RELEASE QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO " 52 | "QMAKE_LFLAGS_APP QMAKE_LFLAGS_SHLIB QMAKE_LFLAGS_SONAME QMAKE_LFLAGS_THREAD QMAKE_LFLAGS_WINDOWS " 53 | "QMAKE_LIBDIR QMAKE_LIBDIR_POST QMAKE_LIBDIR_FLAGS QMAKE_LIBDIR_EGL QMAKE_LIBDIR_OPENGL QMAKE_LIBDIR_OPENVG " 54 | "QMAKE_LIBDIR_X11 QMAKE_LIBS QMAKE_LIBS_PRIVATE QMAKE_LIBS_EGL QMAKE_LIBS_OPENGL QMAKE_LIBS_OPENGL_ES1 " 55 | "QMAKE_LIBS_OPENGL_ES2 QMAKE_LIBS_OPENVG QMAKE_LIBS_THREAD QMAKE_LIBS_X11 QMAKE_LIB_FLAG QMAKE_LINK " 56 | "QMAKE_LINK_SHLIB_CMD QMAKE_LN_SHLIB QMAKE_LRELEASE_FLAGS QMAKE_OBJECTIVE_CFLAGS QMAKE_POST_LINK QMAKE_PRE_LINK " 57 | "QMAKE_PROJECT_NAME QMAKE_PROVISIONING_PROFILE QMAKE_MAC_SDK QMAKE_MACOSX_DEPLOYMENT_TARGET QMAKE_MAKEFILE " 58 | "QMAKE_QMAKE QMAKE_RESOURCE_FLAGS QMAKE_RPATHDIR QMAKE_RPATHLINKDIR QMAKE_RUN_CC QMAKE_RUN_CC_IMP " 59 | "QMAKE_RUN_CXX QMAKE_RUN_CXX_IMP QMAKE_SONAME_PREFIX QMAKE_TARGET QMAKE_TARGET_COMPANY QMAKE_TARGET_DESCRIPTION" 60 | "QMAKE_TARGET_COPYRIGHT QMAKE_TARGET_PRODUCT QMAKE_TARGET_ORIGINAL_FILENAME QMAKE_TARGET_INTERNALNAME " 61 | "QMAKE_TARGET_COMMENTS QMAKE_TARGET_TRADEMARKS QMAKE_MANIFEST QMAKE_TVOS_DEPLOYMENT_TARGET QMAKE_UIC_FLAGS " 62 | "QMAKE_WATCHOS_DEPLOYMENT_TARGET QML_IMPORT_MAJOR_VERSION QML_IMPORT_MINOR_VERSION QML_IMPORT_VERSION " 63 | "QML_IMPORT_NAME QML_FOREIGN_METATYPES QT QTPLUGIN QT_VERSION QT_MAJOR_VERSION QT_MINOR_VERSION " 64 | "QT_PATCH_VERSION RC_FILE RC_CODEPAGE RC_DEFINES RC_ICONS RC_LANG RC_INCLUDEPATH RCC_DIR REQUIRES " 65 | "RESOURCES RES_FILE SOURCES SUBDIRS TARGET TARGET_EXT TEMPLATE TRANSLATIONS " 66 | "TR_EXCLUDE UI_DIR VERSION VERSION_PE_HEADER VER_MAJ VER_MIN VER_PAT VPATH WINDOWS_TARGET_PLATFORM_VERSION " 67 | "WINDOWS_TARGET_PLATFORM_MIN_VERSION YACCSOURCES _PRO_FILE_ _PRO_FILE_PWD_ " 68 | 69 | "macx unix win32 " 70 | 71 | // Built-in Replace Functions 72 | "absolute_path basename cat clean_path dirname enumerate_vars escape_expand find files first " 73 | "format_number fromfile getenv join last list lower member num_add prompt quote re_escape read_registry " 74 | "relative_path replace resolve_depends reverse section shadowed shell_path shell_quote size sort_depends " 75 | "sorted split sprintf str_member str_size system system_path system_quote take_first take_last unique upper val_escape " 76 | 77 | // Built-in Test Functions 78 | "cache CONFIG contains count debug defined equals error eval exists export for greaterThan if " 79 | "include infile isActiveConfig isEmpty isEqual lessThan load log message mkpath requires system " 80 | "touch unset versionAtLeast versionAtMost warning write_file " 81 | 82 | //Test Function Library 83 | "packagesExist prepareRecursiveTarget qtCompileTest qtHaveModule"; 84 | 85 | return nullptr; 86 | } 87 | -------------------------------------------------------------------------------- /colors/html.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This is sheer insanity. 3 | There're not enough colors in the fucking rainbow for this stuff. 4 | *sigh* 5 | */ 6 | 7 | static void setColorsHTML(QsciLexerHTML *lexer) 8 | { 9 | QColor c = COLOR_FOREGROUND; 10 | lexer->setColor(c, QsciLexerHTML::Default); 11 | lexer->setColor(c, QsciLexerHTML::SGMLDefault); 12 | lexer->setColor(c, QsciLexerHTML::SGMLBlockDefault); 13 | lexer->setColor(c, QsciLexerHTML::JavaScriptDefault); 14 | lexer->setColor(c, QsciLexerHTML::ASPJavaScriptDefault); 15 | lexer->setColor(c, QsciLexerHTML::VBScriptDefault); 16 | lexer->setColor(c, QsciLexerHTML::ASPVBScriptDefault); 17 | lexer->setColor(c, QsciLexerHTML::PythonDefault); 18 | lexer->setColor(c, QsciLexerHTML::ASPPythonDefault); 19 | lexer->setColor(c, QsciLexerHTML::ASPPythonDefault); 20 | lexer->setColor(c, QsciLexerHTML::PHPDefault); 21 | lexer->setColor(c, QsciLexerHTML::PHPVariable); 22 | lexer->setColor(c, QsciLexerHTML::PHPDoubleQuotedVariable); 23 | lexer->setColor(c, QsciLexerHTML::Script); 24 | lexer->setColor(c, QsciLexerHTML::JavaScriptWord); 25 | lexer->setColor(c, QsciLexerHTML::ASPJavaScriptWord); 26 | lexer->setColor(c, QsciLexerHTML::OtherInTag); 27 | lexer->setColor(c, QsciLexerHTML::SGMLParameter); 28 | 29 | c = COLOR_COMMENT; 30 | lexer->setColor(c, QsciLexerHTML::HTMLComment); 31 | lexer->setColor(c, QsciLexerHTML::ASPXCComment); 32 | lexer->setColor(c, QsciLexerHTML::SGMLComment); 33 | lexer->setColor(c, QsciLexerHTML::SGMLParameterComment); 34 | lexer->setColor(c, QsciLexerHTML::JavaScriptComment); 35 | lexer->setColor(c, QsciLexerHTML::JavaScriptCommentLine); 36 | lexer->setColor(c, QsciLexerHTML::JavaScriptCommentDoc); 37 | lexer->setColor(c, QsciLexerHTML::ASPJavaScriptComment); 38 | lexer->setColor(c, QsciLexerHTML::ASPJavaScriptCommentLine); 39 | lexer->setColor(c, QsciLexerHTML::ASPJavaScriptCommentDoc); 40 | lexer->setColor(c, QsciLexerHTML::VBScriptComment); 41 | lexer->setColor(c, QsciLexerHTML::ASPVBScriptComment); 42 | lexer->setColor(c, QsciLexerHTML::PythonComment); 43 | lexer->setColor(c, QsciLexerHTML::ASPPythonComment); 44 | lexer->setColor(c, QsciLexerHTML::PHPComment); 45 | lexer->setColor(c, QsciLexerHTML::PHPCommentLine); 46 | lexer->setColor(c, QsciLexerHTML::CDATA); 47 | 48 | c = COLOR_STRING; 49 | lexer->setColor(c, QsciLexerHTML::HTMLDoubleQuotedString); 50 | lexer->setColor(c, QsciLexerHTML::SGMLDoubleQuotedString); 51 | lexer->setColor(c, QsciLexerHTML::JavaScriptDoubleQuotedString); 52 | lexer->setColor(c, QsciLexerHTML::ASPJavaScriptDoubleQuotedString); 53 | lexer->setColor(c, QsciLexerHTML::PythonDoubleQuotedString); 54 | lexer->setColor(c, QsciLexerHTML::PythonTripleDoubleQuotedString); 55 | lexer->setColor(c, QsciLexerHTML::ASPPythonDoubleQuotedString); 56 | lexer->setColor(c, QsciLexerHTML::ASPPythonTripleDoubleQuotedString); 57 | lexer->setColor(c, QsciLexerHTML::PHPDoubleQuotedString); 58 | lexer->setColor(c, QsciLexerHTML::HTMLValue); 59 | lexer->setColor(c, QsciLexerHTML::VBScriptString); 60 | lexer->setColor(c, QsciLexerHTML::ASPVBScriptString); 61 | 62 | c = COLOR_CHAR; 63 | lexer->setColor(c, QsciLexerHTML::HTMLSingleQuotedString); 64 | lexer->setColor(c, QsciLexerHTML::SGMLSingleQuotedString); 65 | lexer->setColor(c, QsciLexerHTML::JavaScriptSingleQuotedString); 66 | lexer->setColor(c, QsciLexerHTML::ASPJavaScriptSingleQuotedString); 67 | lexer->setColor(c, QsciLexerHTML::PythonSingleQuotedString); 68 | lexer->setColor(c, QsciLexerHTML::PythonTripleSingleQuotedString); 69 | lexer->setColor(c, QsciLexerHTML::ASPPythonSingleQuotedString); 70 | lexer->setColor(c, QsciLexerHTML::ASPPythonTripleSingleQuotedString); 71 | lexer->setColor(c, QsciLexerHTML::PHPSingleQuotedString); 72 | 73 | c = COLOR_PREPROC; 74 | lexer->setColor(c, QsciLexerHTML::XMLStart); 75 | lexer->setColor(c, QsciLexerHTML::XMLEnd); 76 | lexer->setColor(c, QsciLexerHTML::ASPAtStart); 77 | lexer->setColor(c, QsciLexerHTML::ASPStart); 78 | lexer->setColor(c, QsciLexerHTML::PHPStart); 79 | lexer->setColor(c, QsciLexerHTML::JavaScriptStart); 80 | lexer->setColor(c, QsciLexerHTML::ASPJavaScriptStart); 81 | lexer->setColor(c, QsciLexerHTML::VBScriptStart); 82 | lexer->setColor(c, QsciLexerHTML::ASPVBScriptStart); 83 | lexer->setColor(c, QsciLexerHTML::PythonStart); 84 | lexer->setColor(c, QsciLexerHTML::ASPPythonStart); 85 | lexer->setColor(c, QsciLexerHTML::JavaScriptRegex); 86 | lexer->setColor(c, QsciLexerHTML::ASPJavaScriptRegex); 87 | lexer->setColor(c, QsciLexerHTML::SGMLSpecial); 88 | 89 | //lexer->setColor(c, QsciLexerCPP::Identifier); // everything is an identifier… 90 | c = COLOR_NUMBER; 91 | lexer->setColor(c, QsciLexerHTML::HTMLNumber); 92 | lexer->setColor(c, QsciLexerHTML::JavaScriptNumber); 93 | lexer->setColor(c, QsciLexerHTML::ASPJavaScriptNumber); 94 | lexer->setColor(c, QsciLexerHTML::VBScriptNumber); 95 | lexer->setColor(c, QsciLexerHTML::ASPVBScriptNumber); 96 | lexer->setColor(c, QsciLexerHTML::PythonNumber); 97 | lexer->setColor(c, QsciLexerHTML::ASPPythonNumber); 98 | lexer->setColor(c, QsciLexerHTML::PHPNumber); 99 | lexer->setColor(c, QsciLexerHTML::Entity); 100 | lexer->setColor(c, QsciLexerHTML::SGMLEntity); 101 | 102 | c = COLOR_OPERATOR; 103 | lexer->setColor(c, QsciLexerHTML::PythonOperator); 104 | lexer->setColor(c, QsciLexerHTML::ASPPythonOperator); 105 | lexer->setColor(c, QsciLexerHTML::PHPOperator); 106 | lexer->setColor(c, QsciLexerHTML::Tag); 107 | lexer->setColor(c, QsciLexerHTML::XMLTagEnd); 108 | lexer->setColor(c, QsciLexerHTML::JavaScriptSymbol); 109 | lexer->setColor(c, QsciLexerHTML::ASPJavaScriptSymbol); 110 | 111 | c = COLOR_KEYWORD; 112 | lexer->setColor(c, QsciLexerHTML::JavaScriptKeyword); 113 | lexer->setColor(c, QsciLexerHTML::ASPJavaScriptKeyword); 114 | lexer->setColor(c, QsciLexerHTML::VBScriptKeyword); 115 | lexer->setColor(c, QsciLexerHTML::ASPVBScriptKeyword); 116 | lexer->setColor(c, QsciLexerHTML::PythonKeyword); 117 | lexer->setColor(c, QsciLexerHTML::ASPPythonKeyword); 118 | lexer->setColor(c, QsciLexerHTML::PHPKeyword); 119 | lexer->setColor(c, QsciLexerHTML::PHPKeyword); 120 | lexer->setColor(c, QsciLexerHTML::PythonClassName); 121 | lexer->setColor(c, QsciLexerHTML::PythonFunctionMethodName); 122 | lexer->setColor(c, QsciLexerHTML::ASPPythonClassName); 123 | lexer->setColor(c, QsciLexerHTML::ASPPythonFunctionMethodName); 124 | lexer->setColor(c, QsciLexerHTML::SGMLCommand); 125 | lexer->setColor(c, QsciLexerHTML::Attribute); 126 | 127 | c = COLOR_ERROR; 128 | lexer->setColor(c, QsciLexerHTML::SGMLError); 129 | lexer->setColor(c, QsciLexerHTML::UnknownTag); 130 | lexer->setColor(c, QsciLexerHTML::UnknownAttribute); 131 | lexer->setColor(c, QsciLexerHTML::JavaScriptUnclosedString); 132 | lexer->setColor(c, QsciLexerHTML::ASPJavaScriptUnclosedString); 133 | lexer->setColor(c, QsciLexerHTML::VBScriptUnclosedString); 134 | lexer->setColor(c, QsciLexerHTML::ASPVBScriptUnclosedString); 135 | 136 | // VBScriptIdentifier 137 | // ASPVBScriptIdentifier 138 | // PythonIdentifier 139 | // ASPPythonIdentifier 140 | } 141 | -------------------------------------------------------------------------------- /lexer/journal.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "../sqriptor.h" 26 | #include "lexer/journal.h" 27 | 28 | 29 | namespace Style { 30 | enum Type { 31 | Default = 0, Date, Host, Process, Number, Error, Comment = Date 32 | }; 33 | }; 34 | 35 | QsciLexerJournal::QsciLexerJournal(QObject *parent) : QsciLexerCustom(parent) 36 | { 37 | } 38 | 39 | void QsciLexerJournal::updateColors() 40 | { 41 | QColor bg = Sqriptor::config.color.bg; 42 | QColor fg = Sqriptor::config.color.fg; 43 | setPaper(bg); 44 | setColor(fg); 45 | setColor(fg, Style::Default); 46 | setColor(Sqriptor::config.color.comment, Style::Date); 47 | setColor(Sqriptor::config.color.operateur, Style::Process); 48 | setColor(Sqriptor::config.color.number, Style::Number); 49 | setColor(Sqriptor::config.color.error, Style::Error); 50 | setColor(Sqriptor::config.color.string, Style::Host); 51 | } 52 | 53 | static inline void testToken(char byte, int *indicator, const char *lower, const char *upper, int length) 54 | { 55 | int idx = *indicator; 56 | if (idx >= length) 57 | return; 58 | if (byte == lower[idx] || byte == upper[idx]) 59 | ++(*indicator); 60 | else 61 | *indicator = 0; 62 | } 63 | 64 | void QsciLexerJournal::styleText (int start, int end) 65 | { 66 | int length = 0; 67 | bool newline = true, comment = false; 68 | int error = 0, crash = 0, warning = 0, failed = 0; 69 | 70 | QByteArray text = editor()->bytes(start, end); 71 | startStyling(start); 72 | for (int i = 0; i < end - start; ++i) { 73 | ++length; 74 | if (text.at(i) == '\n') { 75 | Style::Type style = comment ? Style::Comment : Style::Default; 76 | if (error > 4 || crash > 4 || warning > 6 || failed > 5) 77 | style = Style::Error; 78 | setStyling(length, style); 79 | length = 0; 80 | error = crash = warning = failed = 0; 81 | newline = true; comment = false; 82 | continue; 83 | } 84 | if (!newline) { 85 | testToken(text.at(i), &error, "error", "ERROR", 5); 86 | testToken(text.at(i), &crash, "crash", "CRASH", 5); 87 | testToken(text.at(i), &warning, "warning", "WARNING", 7); 88 | testToken(text.at(i), &failed, "failed", "FAILED", 6); 89 | /* 90 | switch (error) { 91 | case 0: if (text.at(i) == 'e' || text.at(i) == 'E') ++error; 92 | break; 93 | case 1: case 2: case 4: 94 | (text.at(i) == 'r' || text.at(i) == 'R') ? ++error : error = 0; 95 | break; 96 | case 3: (text.at(i) == 'o' || text.at(i) == 'O') ? ++error : error = 0; 97 | break; 98 | default: break; 99 | } 100 | switch (crash) { 101 | case 0: if (text.at(i) == 'c' || text.at(i) == 'C') ++crash; 102 | break; 103 | case 1: (text.at(i) == 'r' || text.at(i) == 'R') ? ++crash : crash = 0; 104 | break; 105 | case 2: (text.at(i) == 'a' || text.at(i) == 'A') ? ++crash : crash = 0; 106 | break; 107 | case 3: (text.at(i) == 's' || text.at(i) == 'S') ? ++crash : crash = 0; 108 | break; 109 | case 4: (text.at(i) == 'h' || text.at(i) == 'H') ? ++crash : crash = 0; 110 | break; 111 | default: break; 112 | } 113 | switch (warning) { 114 | case 0: if (text.at(i) == 'w' || text.at(i) == 'W') ++warning; 115 | break; 116 | case 1: (text.at(i) == 'a' || text.at(i) == 'A') ? ++warning : warning = 0; 117 | break; 118 | case 2: (text.at(i) == 'r' || text.at(i) == 'R') ? ++warning : warning = 0; 119 | break; 120 | case 3: case 5: (text.at(i) == 'n' || text.at(i) == 'N') ? ++warning : warning = 0; 121 | break; 122 | case 4: (text.at(i) == 'i' || text.at(i) == 'I') ? ++warning : warning = 0; 123 | break; 124 | case 6: (text.at(i) == 'g' || text.at(i) == 'G') ? ++warning : warning = 0; 125 | break; 126 | default: break; 127 | } 128 | */ 129 | continue; 130 | } 131 | if (text.at(i) == '-' || text.at(i) == -30 || text.at(i) == '#') { // ░ 132 | newline = false; 133 | comment = true; 134 | continue; 135 | } 136 | 137 | auto nextWord = [&]() { 138 | while (i < end - start && text.at(i) != ' ') { 139 | if (text.at(i) == '\n') { // error, jump to next line 140 | // qDebug() << "unexpected newline" << i; 141 | --i; 142 | return false; 143 | } 144 | ++i; 145 | if (i >= end - start) { // error and out 146 | qDebug() << "error > size" << i << int(end - start); 147 | setStyling(length-1, Style::Error); 148 | length = 0; 149 | return false; 150 | } 151 | ++length; 152 | } 153 | if (i < end - start) { 154 | ++length; ++i; 155 | } 156 | return true; 157 | }; 158 | 159 | newline = false; 160 | 161 | --length; 162 | if (!nextWord()) 163 | continue; 164 | if (!nextWord()) 165 | continue; 166 | if (!nextWord()) 167 | continue; 168 | 169 | setStyling(length, Style::Comment); 170 | length = 0; 171 | if (!nextWord()) 172 | continue; 173 | setStyling(length, Style::Host); 174 | length = 0; 175 | int pstart = i; 176 | if (!nextWord()) 177 | continue; 178 | int pend = i; 179 | if (text.at(i-3) == ']') { 180 | i -= 3; length -= 3; 181 | while (i >= pstart && text.at(i) != '[') { 182 | --i; --length; 183 | } 184 | } else if (text.at(i-2) == ':') { 185 | length -= 2; 186 | i -= 2; 187 | pend = i; 188 | } 189 | setStyling(length, Style::Process); 190 | 191 | if (i != pend) { 192 | setStyling(pend - i - 2, Style::Number); 193 | i = pend - 2; 194 | } 195 | length = 1; 196 | if (i < end - start && text.at(i) == '\n') { 197 | --i; --length; 198 | } 199 | } 200 | // if (length) 201 | // setStyling(length, comment ? Style::Comment : Style::Default); 202 | } 203 | -------------------------------------------------------------------------------- /lexer/lisp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2022 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | #include "../sqriptor.h" 27 | #include "lexer/lisp.h" 28 | 29 | 30 | namespace Style { 31 | enum Type { 32 | Default = 0, Operator, Number, Keyword, Literal, QuasiLiteral, String, Comment, Error 33 | }; 34 | }; 35 | 36 | QsciLexerLISP::QsciLexerLISP(QObject *parent) : QsciLexerCustom(parent) 37 | { 38 | // setAutoIndentStyle(QsciScintilla::AiOpening|QsciScintilla::AiClosing); // this somehow does nothing... 39 | updateColors(); 40 | setKeywords("not defun + - * / = < > <= >= princ eval apply funcall quote identity function " 41 | "complement backquote lambda set setq setf defun defmacro gensym make symbol " 42 | "intern symbol name symbol value symbol plist get getf putprop remprop hash make " 43 | "array aref car cdr caar cadr cdar cddr caaar caadr cadar caddr cdaar cdadr cddar " 44 | "cdddr caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr cdaaar cdaadr " 45 | "cdadar cdaddr cddaar cddadr cdddar cddddr cons list append reverse last nth " 46 | "nthcdr member assoc subst sublis nsubst nsublis remove length list length " 47 | "mapc mapcar mapl maplist mapcan mapcon rplaca rplacd nconc delete atom symbolp " 48 | "numberp boundp null listp consp minusp zerop plusp evenp oddp eq eql equal cond " 49 | "case and or let l if print prog prog1 prog2 progn go return do dolist dotimes catch " 50 | "throw error cerror break continue errset baktrace evalhook truncate float rem min " 51 | "max abs sin cos tan expt exp sqrt random logand logior logxor lognot bignums " 52 | "logeqv lognand lognor logorc2 logtest logbitp logcount integer length nil"); 53 | } 54 | 55 | void QsciLexerLISP::setKeywords(const char *keywords) 56 | { 57 | m_keywords = (QString(keywords).split(" ", Qt::SkipEmptyParts)); 58 | } 59 | 60 | void QsciLexerLISP::updateColors() 61 | { 62 | QColor bg = Sqriptor::config.color.bg; 63 | QColor fg = Sqriptor::config.color.fg; 64 | setPaper(bg); 65 | setColor(fg); 66 | setColor(fg, Style::Default); 67 | setColor(Sqriptor::config.color.number, Style::Number); 68 | setColor(Sqriptor::config.color.operateur, Style::Operator); 69 | setColor(Sqriptor::config.color.keyword, Style::Keyword); 70 | setColor(Sqriptor::config.color.character, Style::Literal); 71 | setColor(Sqriptor::config.color.preproc, Style::QuasiLiteral); 72 | setColor(Sqriptor::config.color.string, Style::String); 73 | setColor(Sqriptor::config.color.comment, Style::Comment); 74 | setColor(Sqriptor::config.color.error, Style::Error); 75 | setFont(Sqriptor::config.font); 76 | setFont(Sqriptor::config.font, Style::Default); 77 | } 78 | 79 | //static bool operator==(const QStringView&view, const char* string) { 80 | // return !view.compare(QLatin1String(string)); 81 | //} 82 | 83 | #if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) 84 | #define MATCH_VIEW matchView 85 | #else 86 | #define MATCH_VIEW match 87 | #endif 88 | 89 | void QsciLexerLISP::styleText(int start, int end) 90 | { 91 | static const QRegularExpression tokenizer(";|\\(|\\)|\\\"|#'|,@|,|\\s+|['`]*[A-Za-z\\d_#\\+@$%\\.\\^&=\\*-?\\!<>]+|'|`|\\W"); 92 | static const QRegularExpression linebreak("\\s*(\\n|\\r)+\\s*"); 93 | 94 | QString text = editor()->text(start, end); 95 | QRegularExpressionMatchIterator i = tokenizer.globalMatch(text/*, 0, QRegularExpression::PartialPreferFirstMatch*/); 96 | 97 | bool comment = false, 98 | string = (start > 0) ? editor()->SendScintilla(QsciScintillaBase::SCI_GETSTYLEAT, start - 1) == Style::String : false, 99 | isNum; 100 | 101 | int length = 0; 102 | auto finishStyle = [&]() { 103 | setStyling(length, Style::Default); 104 | length = 0; 105 | }; 106 | startStyling(start); 107 | QRegularExpressionMatch match, prev; 108 | while (i.hasNext()) { 109 | prev = match; 110 | match = i.next(); 111 | QStringView token = match.capturedView(0); 112 | // qDebug() << token; 113 | if (comment) { 114 | length += token.toUtf8().length(); // match.capturedLength(0); - this sucks 115 | if (linebreak.MATCH_VIEW(token).hasMatch()) { 116 | setStyling(length, Style::Comment); length = 0; comment = false; 117 | } 118 | continue; 119 | } 120 | if (token == "\"") { 121 | if (string) { 122 | setStyling(length + 1, Style::String); string = false; length = 0; 123 | } else { 124 | finishStyle(); string = true; length = 1; 125 | } 126 | continue; 127 | } 128 | if (string) { 129 | length += token.toUtf8().length(); // match.capturedLength(0); - this sucks 130 | if (linebreak.MATCH_VIEW(token).hasMatch()) { 131 | setStyling(length, Style::String); length = 0; // we assume that the string continues in the next line 132 | } 133 | continue; 134 | } 135 | if (token == ";") { 136 | finishStyle(); length = 1; comment = true; 137 | continue; 138 | } 139 | if (token == "(" || token == ")" || 140 | token == ",") { // unquote operator 141 | finishStyle(); setStyling(1, Style::Operator); 142 | continue; 143 | } 144 | if (token == "#'" || // abbreviation for function special operator, returning a function object. 145 | token == ",@") { // splice operator 146 | finishStyle(); setStyling(2, Style::Operator); 147 | continue; 148 | } 149 | if (token.startsWith('\'')) { 150 | finishStyle(); setStyling(token.toUtf8().length(), Style::Literal);// match.capturedLength(0); - this sucks 151 | continue; 152 | } 153 | if (token.startsWith('`')) { 154 | finishStyle(); setStyling(token.toUtf8().length(), Style::QuasiLiteral);// match.capturedLength(0); - this sucks 155 | continue; 156 | } 157 | if (m_keywords.contains(token, Qt::CaseInsensitive)) { 158 | finishStyle(); setStyling(token.toUtf8().length(), Style::Keyword);// match.capturedLength(0); - this sucks 159 | continue; 160 | } 161 | Q_UNUSED(token.toInt(&isNum)); 162 | if (!isNum) 163 | Q_UNUSED(token.toDouble(&isNum)); 164 | if (isNum) { 165 | finishStyle(); setStyling(token.toUtf8().length(), Style::Number);// match.capturedLength(0); - this sucks 166 | continue; 167 | } 168 | length += token.toUtf8().length(); // match.capturedLength(0); - this sucks 169 | } 170 | if (length) { 171 | setStyling(length, comment ? Style::Comment : (string ? Style::Error : Style::Default)); 172 | length = 0; 173 | } 174 | } -------------------------------------------------------------------------------- /lexer/xorg.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "../sqriptor.h" 26 | #include "lexer/xorg.h" 27 | 28 | 29 | namespace Style { 30 | enum Type { 31 | Default = 0, Keyword, Option, Number, Quote, Comment 32 | }; 33 | }; 34 | 35 | QsciLexerXorg::QsciLexerXorg(QObject *parent) : QsciLexerCustom(parent) 36 | { 37 | } 38 | 39 | void QsciLexerXorg::updateColors() 40 | { 41 | QColor bg = Sqriptor::config.color.bg; 42 | QColor fg = Sqriptor::config.color.fg; 43 | setPaper(bg); 44 | setColor(fg); 45 | setColor(fg, Style::Default); 46 | setColor(Sqriptor::config.color.keyword, Style::Keyword); 47 | setColor(Sqriptor::config.color.operateur, Style::Option); 48 | setColor(Sqriptor::config.color.number, Style::Number); 49 | setColor(Sqriptor::config.color.comment, Style::Comment); 50 | setColor(Sqriptor::config.color.string, Style::Quote); 51 | } 52 | 53 | //static bool operator==(const QStringView&view, const char* string) { 54 | // return !view.compare(QLatin1String(string)); 55 | //} 56 | 57 | void QsciLexerXorg::styleText (int start, int end) 58 | { 59 | static const QRegularExpression tokenizer("\"|#|\\s+|\\w+|\\W+"); 60 | static const QRegularExpression linebreak("\\s*(\\n|\\r)+\\s*"); 61 | static const QStringList keywords = 62 | QString("Section SubSection Mode EndSection EndSubSection EndMode " 63 | "Files ServerFlags Module Extensions InputDevice InputClass " 64 | "OutputClass Device VideoAdaptor Monitor Modes Screen " 65 | "ServerLayout DRI Vendor " // Sections 66 | "FontPath ModulePath XkbDir " // ... 67 | "Option Load Disable Identifier Driver " // --- 68 | "MatchProduct MatchVendor MatchDevicePath MatchOS MatchPnPID " 69 | "MatchUSBID MatchDriver MatchTag MatchLayout MatchIsKeyboard " 70 | "MatchIsPointer MatchIsJoystick MatchIsTablet MatchIsTabletPad " 71 | "MatchIsTouchpad MatchIsTouchscreen " // matches... 72 | "BusID Screen Chipset Ramdac DacSpeed Clocks ClockChip " 73 | "VideoRam MemBase IOBase ChipID ChipRev MatchSeat " // Device 74 | "VendorName ModelName HorizSync VertRefresh DisplaySize " 75 | "Gamma UseModes ModeLine " // Monitor 76 | "GPUDevice DefaultDepth DefaultFbBpp " // Screen 77 | "Depth FbBpp Weight Virtual ViewPort Modes Visual Black White " // Display 78 | "Absolute RightOf LeftOf Above Below Relative").split(" "); //Screen 79 | static const QStringList options = 80 | QString("Files ServerFlags Module Extensions InputDevice InputClass " 81 | "OutputClass Device VideoAdaptor Monitor Modes Screen " 82 | "Debug DefaultServerLayout NoTrapSignals DontVTSwitch DontZap " 83 | "DontZoom DisableVidModeExtension AllowNonLocalXvidtune " 84 | "AllowMouseOpenFail BlankTime StandbyTime SuspendTime " 85 | "OffTime MaxClients NoPM Xinerama IndirectGLX DRI2 " 86 | "GlxVisuals UseDefaultFontPath IgnoreABI AutoAddDevices " 87 | "AutoEnableDevices AutoAddGPU AutoBindGPU Log AutoServerLayout " 88 | "Floating TransformationMatrix AccelerationProfile " 89 | "ConstantDeceleration AdaptiveDeceleration " 90 | "AccelerationScheme AccelerationNumerator " 91 | "AccelerationDenominator AccelerationThreshold " 92 | "Ignore PrimaryGPU ModeDebug PreferCloneMode " 93 | "DPMS SyncOnGreen Primary PreferredMode ZoomModes " 94 | "Position LeftOf RightOf Above Below Enable DefaultModes " 95 | "MinClock MaxClock Ignore Rotate Accel GlxVendorLibrary " 96 | "InitPrimary NoInt10 IsolateDevice SingleCard " 97 | "XkbLayout XkbVariant XkbModel XkbOptions XkbRules " 98 | "XkbKeycodes AutoRepeat").split(" "); 99 | 100 | static const QStringList symbols = 101 | QString("TRUE on true yes FALSE off false no " // yeah, guess what 102 | "StaticGray GrayScale StaticColor PseudoColor TrueColor DirectColor").split(" "); 103 | 104 | /* QStringList unitstuff = "Hz k kHz M MHz" */ 105 | 106 | int length = 0; 107 | bool haveKey = false, quote = false, comment = false, isInt; 108 | 109 | auto finishStyle = [&]() { 110 | if (quote) 111 | setStyling(length, Style::Quote); 112 | else 113 | setStyling(length, Style::Default); 114 | length = 0; 115 | }; 116 | 117 | QString text = editor()->text(start, end); 118 | QRegularExpressionMatchIterator i = tokenizer.globalMatch(text/*, 0, QRegularExpression::PartialPreferFirstMatch*/); 119 | startStyling(start); 120 | QRegularExpressionMatch match; 121 | while (i.hasNext()) { 122 | match = i.next(); 123 | QStringView token = match.capturedView(0); 124 | #if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) 125 | if (linebreak.matchView(token).hasMatch()) { 126 | #else 127 | if (linebreak.match(token).hasMatch()) { 128 | #endif 129 | haveKey = false; 130 | if (comment) { 131 | setStyling(length, Style::Comment); 132 | comment = false; 133 | length = 0; 134 | } 135 | length += match.capturedLength(0); 136 | continue; 137 | } 138 | if (comment) { 139 | length += match.capturedLength(0); 140 | continue; 141 | } 142 | if (!haveKey && keywords.contains(token)) { 143 | haveKey = true; 144 | finishStyle(); 145 | setStyling(match.capturedLength(0), Style::Keyword); 146 | continue; 147 | } 148 | if (options.contains(token)) { 149 | finishStyle(); 150 | setStyling(match.capturedLength(0), Style::Option); 151 | continue; 152 | } 153 | if (symbols.contains(token)) { 154 | finishStyle(); 155 | setStyling(match.capturedLength(0), Style::Number); 156 | continue; 157 | } 158 | if (token == "#") { 159 | finishStyle(); 160 | comment = true; 161 | length += 1; 162 | continue; 163 | } 164 | if (token == "\"") { 165 | if (quote) 166 | length += 1; 167 | finishStyle(); 168 | quote = !quote; 169 | if (quote) 170 | length += 1; 171 | continue; 172 | } 173 | Q_UNUSED(token.toInt(&isInt)); 174 | if (isInt) { 175 | finishStyle(); 176 | setStyling(match.capturedLength(0), Style::Number); 177 | continue; 178 | } 179 | length += match.capturedLength(0); 180 | } 181 | finishStyle(); 182 | } 183 | 184 | /* 185 | 186 | "CorePointer" 187 | Deprecated, see Floating 188 | "CoreKeyboard" 189 | Deprecated, see Floating 190 | "AlwaysCore" "boolean" 191 | Deprecated, see Floating 192 | "SendCoreEvents" "boolean" 193 | Deprecated, see Floating 194 | 195 | Mode "name" 196 | DotClock clock 197 | HTimings hdisp hsyncstart hsyncend htotal 198 | VTimings vdisp vsyncstart vsyncend vtotal 199 | Flags "flag" ... 200 | HSkew hskew 201 | VScan vscan 202 | EndMode 203 | 204 | */ -------------------------------------------------------------------------------- /settings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include "sqriptor.h" 12 | #include "ui_settings.h" 13 | 14 | static Ui::Settings *gs_ui = nullptr; 15 | static QDialog *gs_dlg = nullptr; 16 | static Config config_bak; 17 | 18 | static void updateTiles() 19 | { 20 | QPalette pal; 21 | pal = gs_ui->c_background->palette(); 22 | pal.setColor(gs_ui->c_background->backgroundRole(), config_bak.color.bg); 23 | pal.setColor(gs_ui->c_background->foregroundRole(), config_bak.color.fg); 24 | gs_ui->c_background->setPalette(pal); 25 | gs_ui->c_foreground->setPalette(pal); 26 | #define SETPAL(_TILE_, _KEY_) pal.setColor(gs_ui->_TILE_->foregroundRole(), config_bak.color._KEY_); gs_ui->_TILE_->setPalette(pal) 27 | SETPAL(c_string, string); 28 | SETPAL(c_char, character); 29 | SETPAL(c_comment, comment); 30 | SETPAL(c_preproc, preproc); 31 | SETPAL(c_number, number); 32 | SETPAL(c_operator, operateur); 33 | SETPAL(c_keyword, keyword); 34 | SETPAL(c_error, error); 35 | } 36 | 37 | 38 | class ColorDropper : public QObject { 39 | public: 40 | ColorDropper(QObject *o) : QObject(o) {} 41 | protected: 42 | bool eventFilter(QObject *o, QEvent *e) { 43 | if (e->type() == QEvent::DragEnter) { 44 | QDropEvent *de = static_cast(e); 45 | de->mimeData()->hasColor() ? de->accept() : de->ignore(); 46 | return false; 47 | } 48 | if (e->type() == QEvent::Drop) { 49 | QDropEvent *de = static_cast(e); 50 | if (de->mimeData()->hasColor()) { 51 | QColor c = qvariant_cast(de->mimeData()->colorData()); 52 | if (o == gs_ui->c_background) config_bak.color.bg = c; 53 | else if (o == gs_ui->c_foreground) config_bak.color.fg = c; 54 | else if (o == gs_ui->c_string) config_bak.color.string = c; 55 | else if (o == gs_ui->c_char) config_bak.color.character = c; 56 | else if (o == gs_ui->c_comment) config_bak.color.comment = c; 57 | else if (o == gs_ui->c_preproc) config_bak.color.preproc = c; 58 | else if (o == gs_ui->c_number) config_bak.color.number = c; 59 | else if (o == gs_ui->c_operator) config_bak.color.operateur = c; 60 | else if (o == gs_ui->c_keyword) config_bak.color.keyword = c; 61 | else if (o == gs_ui->c_error) config_bak.color.error = c; 62 | 63 | updateTiles(); 64 | } 65 | return false; 66 | } 67 | return false; 68 | } 69 | }; 70 | 71 | void Sqriptor::updatePalette() 72 | { 73 | // todo: update syntax lexers w/ new palette 74 | for (int syntax = Syntax::Auto + 1; syntax < Syntax::Count; ++syntax) 75 | setSyntax(static_cast(syntax), nullptr, true); // updateColorsOnly 76 | for (int i = 0; i < m_documents->count(); ++i) { 77 | QsciScintilla *doc = textEdit(i); 78 | doc->setIndentationsUseTabs(config.tab.isTab); 79 | doc->setTabWidth(config.tab.width); 80 | int syntax = doc->property("sqriptor_syntax").toInt(); 81 | setSyntax(static_cast(syntax), doc); 82 | doc->setMarginsFont(config.font); 83 | doc->setMarginWidth(0, "14444"); 84 | } 85 | QPalette pal = palette(); // qApp->palette(); 86 | pal.setColor(QPalette::Window, config.color.bg); 87 | pal.setColor(QPalette::Base, config.color.bg); 88 | pal.setColor(QPalette::Button, config.color.bg); 89 | pal.setColor(QPalette::WindowText, config.color.fg); 90 | pal.setColor(QPalette::Text, config.color.fg); 91 | pal.setColor(QPalette::ButtonText, config.color.fg); 92 | setPalette(pal); 93 | } 94 | 95 | void Sqriptor::showSettings() 96 | { 97 | if (!gs_ui) { 98 | delete gs_dlg; // safe > sorry 99 | gs_dlg = new QDialog(this); 100 | gs_ui = new Ui::Settings; 101 | gs_ui->setupUi(gs_dlg); 102 | ColorDropper *dropper = new ColorDropper(gs_dlg); 103 | gs_ui->c_background->installEventFilter(dropper); 104 | gs_ui->c_foreground->installEventFilter(dropper); 105 | gs_ui->c_string->installEventFilter(dropper); 106 | gs_ui->c_char->installEventFilter(dropper); 107 | gs_ui->c_comment->installEventFilter(dropper); 108 | gs_ui->c_preproc->installEventFilter(dropper); 109 | gs_ui->c_number->installEventFilter(dropper); 110 | gs_ui->c_operator->installEventFilter(dropper); 111 | gs_ui->c_keyword->installEventFilter(dropper); 112 | gs_ui->c_error->installEventFilter(dropper); 113 | QColorDialog *cd = new QColorDialog(gs_dlg); 114 | cd->hide(); 115 | connect (gs_ui->colorbutton, SIGNAL(clicked()), cd, SLOT(show())); 116 | connect (gs_ui->colorbutton, SIGNAL(clicked()), cd, SLOT(raise())); 117 | connect (gs_dlg, &QDialog::finished, [=](int result) { 118 | cd->hide(); 119 | if (result == QDialog::Accepted) { 120 | config = config_bak; 121 | config.changed = true; 122 | updatePalette(); 123 | QSize size = config.size; 124 | if (config.sizeMode == Size::Relative && size.width() < 101 && size.height() < 101) { 125 | QRect geo = availableGeometry(); 126 | size.setWidth(qRound(geo.width()*size.width()/100.0f)); 127 | size.setHeight(qRound(geo.height()*size.height()/100.0f)); 128 | } 129 | resize(size); 130 | } 131 | }); 132 | connect (gs_ui->windowSizeMode, QOverload::of(&QComboBox::currentIndexChanged), 133 | [=](const int index) { 134 | config_bak.sizeMode = Size::Mode(index); 135 | gs_ui->windowSizeX->setRange(0, 8194); 136 | gs_ui->windowSizeY->setRange(0, 8194); 137 | if (index == Size::Relative) { 138 | gs_ui->windowSizeX->setSuffix(" %"); 139 | gs_ui->windowSizeY->setSuffix(" %"); 140 | if (gs_ui->windowSizeX->value() > 100) { // comes from relative 141 | QRect geo = availableGeometry(); 142 | gs_ui->windowSizeX->setValue(qRound(gs_ui->windowSizeX->value()*100.0f/geo.width())); 143 | gs_ui->windowSizeY->setValue(qRound(gs_ui->windowSizeY->value()*100.0f/geo.height())); 144 | } 145 | gs_ui->windowSizeX->setRange(0, 100); 146 | gs_ui->windowSizeY->setRange(0, 100); 147 | } else if (index == Size::Absolute) { 148 | gs_ui->windowSizeX->setSuffix(" px"); 149 | gs_ui->windowSizeY->setSuffix(" px"); 150 | if (gs_ui->windowSizeX->value() < 101) { // comes from relative 151 | QRect geo = availableGeometry(); 152 | gs_ui->windowSizeX->setValue(qRound(geo.width()*gs_ui->windowSizeX->value()/100.0f)); 153 | gs_ui->windowSizeY->setValue(qRound(geo.height()*gs_ui->windowSizeY->value()/100.0f)); 154 | } 155 | gs_ui->windowSizeX->setRange(101, 8194); 156 | gs_ui->windowSizeY->setRange(101, 8194); 157 | } else if (index == Size::Remember) { 158 | gs_ui->windowSizeX->setSuffix(" px"); 159 | gs_ui->windowSizeY->setSuffix(" px"); 160 | } 161 | gs_ui->windowSizeX->setEnabled(index != Size::Remember); 162 | gs_ui->windowSizeY->setEnabled(index != Size::Remember); 163 | }); 164 | gs_ui->windowSizeX->setValue(config.sizeMode == Size::Remember ? width() : config.size.width()); 165 | connect (gs_ui->windowSizeX, QOverload::of(&QSpinBox::valueChanged), 166 | [=](int v) {config_bak.size.setWidth(v);}); 167 | gs_ui->windowSizeY->setValue(config.sizeMode == Size::Remember ? height() : config.size.height()); 168 | connect (gs_ui->windowSizeY, QOverload::of(&QSpinBox::valueChanged), 169 | [=](int v) {config_bak.size.setHeight(v);}); 170 | connect (gs_ui->markdownProcessor, &QLineEdit::textEdited, 171 | [=](const QString &t) { config_bak.markdownProcessor = t; }); 172 | connect (gs_ui->previewCSS, &QPlainTextEdit::textChanged, 173 | [=]() { config_bak.previewCSS = gs_ui->previewCSS->toPlainText(); }); 174 | // apply... 175 | gs_ui->windowSizeMode->setCurrentIndex(config.sizeMode); 176 | 177 | gs_ui->markdownProcessor->setText(config.markdownProcessor); 178 | gs_ui->previewCSS->setPlainText(config.previewCSS); 179 | 180 | gs_ui->wrapWords->setChecked(config.wrap.words); 181 | connect (gs_ui->wrapWords, &QCheckBox::stateChanged, 182 | [=](int s) {config_bak.wrap.words = s;}); 183 | gs_ui->wrapIndicator->setChecked(config.wrap.indicator); 184 | connect (gs_ui->wrapIndicator, &QCheckBox::stateChanged, 185 | [=](int s) {config_bak.wrap.indicator = s;}); 186 | gs_ui->wrapIndicatorPos->setValue(config.wrap.indicatorPos); 187 | connect (gs_ui->wrapIndicatorPos, QOverload::of(&QSpinBox::valueChanged), 188 | [=](int v) {config_bak.wrap.indicatorPos = v;}); 189 | 190 | gs_ui->tabIsTab->setChecked(config.tab.isTab); 191 | connect (gs_ui->tabIsTab, &QCheckBox::stateChanged, 192 | [=](int s) {config_bak.tab.isTab = s;}); 193 | gs_ui->tabWidth->setValue(config.tab.width); 194 | connect (gs_ui->tabWidth, QOverload::of(&QSpinBox::valueChanged), 195 | [=](int v) {config_bak.tab.width = v;}); 196 | gs_ui->font->setCurrentFont(config.font); 197 | connect (gs_ui->font, &QFontComboBox::currentFontChanged, 198 | [=](const QFont &font) {config_bak.font.setFamily(font.family());}); 199 | gs_ui->fontSize->setValue(config.font.pointSize()); 200 | connect (gs_ui->fontSize, QOverload::of(&QSpinBox::valueChanged), 201 | [=](int v) {config_bak.font.setPointSize(v);}); 202 | } 203 | config_bak = config; 204 | updateTiles(); 205 | gs_dlg->show(); 206 | } 207 | 208 | -------------------------------------------------------------------------------- /lexer/markdown2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | #include "../sqriptor.h" 27 | #include "lexer/markdown2.h" 28 | 29 | 30 | namespace Style { 31 | enum Type { 32 | Default = 0, Header1, Header2, Header3, Header4, Header5, Header6, 33 | Monospace, StrikeMono, List, Ruler, 34 | // this is fun… 35 | Bold, Italic, Strike, BoldItalic, StrikeBold, StrikeItalic, StrikeBoldItalic, 36 | // same - hopefully 37 | Quote, 38 | BoldQuote, ItalicQuote, StrikeQuote, BoldItalicQuote, StrikeBoldQuote, 39 | StrikeItalicQuote, StrikeBoldItalicQuote, 40 | Bracket, Brace = Quote, Tag = Bracket 41 | }; 42 | }; 43 | 44 | QsciLexerMarkdown2::QsciLexerMarkdown2(QObject *parent) : QsciLexerCustom(parent) 45 | { 46 | updateColors(); 47 | } 48 | 49 | void QsciLexerMarkdown2::updateColors() 50 | { 51 | QColor bg = Sqriptor::config.color.bg; 52 | QColor fg = Sqriptor::config.color.fg; 53 | QColor mid = QColor((2*bg.red()+fg.red())/3, (2*bg.green()+fg.green())/3, (2*bg.green()+fg.green())/3); 54 | setPaper(bg); 55 | setColor(fg); 56 | setColor(fg, Style::Default); 57 | setColor(Sqriptor::config.color.number, Style::List); 58 | setColor(Sqriptor::config.color.operateur, Style::Bracket); 59 | for (int i = Style::Quote; i <= Style::StrikeBoldItalicQuote; ++i) 60 | setColor(Sqriptor::config.color.string, i); 61 | setColor(mid, Style::Ruler); 62 | 63 | QFont font; 64 | font.setPointSize(12); 65 | setFont(font); 66 | setFont(font, Style::Default); 67 | 68 | QFont bold = font; bold.setBold(true); 69 | setFont(bold, Style::Bold); 70 | setFont(bold, Style::BoldQuote); 71 | 72 | QFont italic = font; italic.setItalic(true); 73 | setFont(italic, Style::Italic); 74 | setFont(italic, Style::ItalicQuote); 75 | 76 | QFont boldItalic = font; boldItalic.setBold(true); boldItalic.setItalic(true); 77 | setFont(boldItalic, Style::BoldItalic); 78 | setFont(boldItalic, Style::BoldItalicQuote); 79 | 80 | QFont mono = Sqriptor::config.font; 81 | setFont(mono, Style::Monospace); 82 | setColor(Sqriptor::config.color.keyword, Style::Monospace); 83 | mono.setStrikeOut(true); 84 | setFont(mono, Style::StrikeMono); 85 | setColor(Sqriptor::config.color.keyword, Style::StrikeMono); 86 | 87 | QFont header = font; 88 | float factor = 1.4; 89 | header.setBold(true); 90 | for (int i = Style::Header1; i <= Style::Header6; ++i) { 91 | header.setPointSize(qCeil(factor*font.pointSize())); 92 | setFont(header, i); 93 | if (i % 2) { 94 | header.setBold(false); 95 | } else { 96 | header.setBold(true); 97 | factor -= 0.1; 98 | } 99 | } 100 | 101 | setColor(mid, Style::Strike); 102 | setColor(mid, Style::StrikeBold); 103 | setColor(mid, Style::StrikeItalic); 104 | setColor(mid, Style::StrikeBoldItalic); 105 | 106 | fg = Sqriptor::config.color.string; 107 | mid = QColor((2*bg.red()+fg.red())/3, (2*bg.green()+fg.green())/3, (2*bg.green()+fg.green())/3); 108 | setColor(mid, Style::StrikeQuote); 109 | setColor(mid, Style::StrikeBoldQuote); 110 | setColor(mid, Style::StrikeItalicQuote); 111 | setColor(mid, Style::StrikeBoldItalicQuote); 112 | } 113 | 114 | //static bool operator==(const QStringView&view, const char* string) { 115 | // return !view.compare(QLatin1String(string)); 116 | //} 117 | 118 | #if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) 119 | #define MATCH_VIEW matchView 120 | #else 121 | #define MATCH_VIEW match 122 | #endif 123 | 124 | void QsciLexerMarkdown2::styleText(int start, int end) 125 | { 126 | static const QRegularExpression tokenizer("######|#####|####|###|##|---+|====+|~~|" 127 | "\\*\\*\\*|\\*\\*|\\*|" 128 | "___|__|_|`+|" 129 | "\\s+|[A-Za-z\\d]+|\\W"); 130 | static const QRegularExpression nonWS("[^\\s]"); // \\W? 131 | static const QRegularExpression word("\\W"); 132 | static const QRegularExpression linebreak("\\s*(\\n|\\r)+\\s*"); 133 | static const QRegularExpression header1("====+"); 134 | static const QRegularExpression header2("----+"); 135 | 136 | QString text = editor()->text(start, end); 137 | QRegularExpressionMatchIterator i = tokenizer.globalMatch(text/*, 0, QRegularExpression::PartialPreferFirstMatch*/); 138 | 139 | bool newline = true, quote = false, tag = false, bracket = false, brace = false, isInt, maybeBracket = false; 140 | int header = 0, length = 0, style = 0; 141 | enum FontStyle { I1 = 0, B1, BI1, I2, B2, BI2, S, Mono1, Mono2, Mono3, FontStyleCount }; 142 | static const char *fsIndicator[FontStyleCount] = {"*", "**", "***", "_", "__", "___", "~~", "`", "``", "```"}; 143 | auto finishStyle = [&]() { 144 | if (header) { 145 | setStyling(length, header); 146 | } else { 147 | if (style & (1<") { 222 | if (length) 223 | setStyling(length, Style::Quote); 224 | setStyling(1, Style::Tag); length = 0; tag = false; 225 | continue; 226 | } 227 | if (i.hasNext() && i.peekNext().capturedView(0) == "=") { 228 | setStyling(length, Style::Quote); // value? 229 | setStyling(token.toUtf8().length(), Style::List); // attribute 230 | setStyling(1, Style::Default); // "=" 231 | length = 0; 232 | i.next(); // skip 233 | continue; 234 | } 235 | length += token.toUtf8().length(); // match.capturedLength(0); - this sucks 236 | continue; 237 | } 238 | if (newline && !quote) { 239 | if (token == "######" && NEXT_IS_WS) { 240 | finishStyle(); newline = false; header = 6; 241 | } else if (token == "#####" && NEXT_IS_WS) { 242 | finishStyle(); newline = false; header = 5; 243 | } else if (token == "####" && NEXT_IS_WS) { 244 | finishStyle(); newline = false; header = 4; 245 | } else if (token == "###" && NEXT_IS_WS) { 246 | finishStyle(); newline = false; header = 3; 247 | } else if (token == "##" && NEXT_IS_WS) { 248 | finishStyle(); newline = false; header = 2; 249 | } else if (token == "#" && NEXT_IS_WS) { 250 | finishStyle(); newline = false; header = 1; 251 | } else if (token == ">" && NEXT_IS_WS) { 252 | finishStyle(); newline = false; quote = true; 253 | } else if (token == "---" && NEXT_IS_WS) { // TODO: not entirely accurate, ---foobar is not a ruler, quotes? 254 | finishStyle(); newline = false; setStyling(3, Style::Ruler); 255 | continue; 256 | } else if ((token == "*" || token == "-" || token == "+") && NEXT_IS_WS) { 257 | finishStyle(); newline = false; setStyling(1, Style::List); 258 | continue; 259 | } else if ((header1.MATCH_VIEW(token).hasMatch() || header2.MATCH_VIEW(token).hasMatch()) && 260 | i.hasNext() && linebreak.MATCH_VIEW(i.peekNext().capturedView(0)).hasMatch()) { 261 | finishStyle(); newline = false; setStyling(match.capturedLength(0), Style::BoldQuote); 262 | continue; 263 | } else { 264 | Q_UNUSED(token.toInt(&isInt)); 265 | if (isInt && i.hasNext() && i.peekNext().capturedView(0) == ".") { // ordered list item 266 | finishStyle(); newline = false; setStyling(match.capturedLength(0) + 1, Style::List); 267 | i.next(); // skip 268 | continue; 269 | } 270 | } 271 | } 272 | 273 | if (newline && nonWS.MATCH_VIEW(token).hasMatch()) 274 | newline = false; 275 | 276 | if (token == "[") { 277 | finishStyle(); 278 | maybeBracket = true; 279 | if (!bracket) 280 | bracket = prev.capturedView() == "!" || (i.hasNext() && i.peekNext().capturedView(0) == "!"); 281 | } else if (token == "(" && !length && prev.capturedView() == "]") { 282 | // !length because we just closed a bracket! 283 | // we therefore also don't need to finishStyle(); 284 | brace = true; 285 | } else if (token == "<" && !(NEXT_IS_WS)) { 286 | finishStyle(); 287 | length = 1; 288 | tag = true; 289 | while (i.hasNext() && !(NEXT_IS_WS)) { 290 | token = i.next().capturedView(0); 291 | if (token == ">") { 292 | ++length; 293 | tag = false; 294 | break; 295 | } 296 | length += token.toUtf8().length(); // match.capturedLength(0); - this sucks 297 | } 298 | setStyling(length, Style::Tag); 299 | length = 0; 300 | continue; 301 | } else if (!prev.capturedView().endsWith('\\')) { 302 | for (int fs = 0; fs < FontStyleCount; ++fs) { 303 | if (token == fsIndicator[fs]) { 304 | const bool nexWS = i.hasNext() && word.MATCH_VIEW(i.peekNext().capturedView(0)).hasMatch(); // NEXT_IS_WS; 305 | if ((style & (1<= Mono1 || (nexWS && nonWS.MATCH_VIEW(prev.capturedView()).hasMatch()))) { 306 | length += match.capturedLength(0); // capture indicator 307 | finishStyle(); 308 | length -= match.capturedLength(0); // sanitized below! 309 | if (fs >= Mono1) 310 | style &= ~(1<= Mono1 || (!nexWS && !nonWS.MATCH_VIEW(prev.capturedView()).hasMatch()))) { 314 | finishStyle(); 315 | style |= (1< 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /syntax.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Sqriptor text editor for Qt5 3 | * Copyright 2021 by Thomas Lübking 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | //#include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | #include 65 | #include 66 | #include 67 | #include 68 | 69 | #include "lexer/awk.h" 70 | #include "lexer/cppqt.h" 71 | #include "lexer/fontconfig.h" 72 | #include "lexer/glsl.h" 73 | #include "lexer/journal.h" 74 | #include "lexer/lisp.h" 75 | #include "lexer/markdown2.h" 76 | #include "lexer/nim.h" 77 | #include "lexer/pkgbuild.h" 78 | #include "lexer/qtpro.h" 79 | #include "lexer/rust.h" 80 | #include "lexer/xorg.h" 81 | #include "lexer/xorglog.h" 82 | 83 | 84 | #include "sqriptor.h" 85 | 86 | static QsciLexer *syntaxDict[Syntax::Count] = {nullptr}; 87 | 88 | #define COLOR_BACKGROUND Sqriptor::config.color.bg 89 | #define COLOR_FOREGROUND Sqriptor::config.color.fg 90 | #define COLOR_STRING Sqriptor::config.color.string 91 | #define COLOR_CHAR Sqriptor::config.color.character 92 | #define COLOR_COMMENT Sqriptor::config.color.comment 93 | #define COLOR_PREPROC Sqriptor::config.color.preproc 94 | #define COLOR_NUMBER Sqriptor::config.color.number 95 | #define COLOR_OPERATOR Sqriptor::config.color.operateur 96 | #define COLOR_KEYWORD Sqriptor::config.color.keyword 97 | #define COLOR_ERROR Sqriptor::config.color.error 98 | 99 | #include "colors/avs.cpp" 100 | #include "colors/bash.cpp" 101 | #include "colors/batch.cpp" 102 | #include "colors/cmake.cpp" 103 | #include "colors/coffeescript.cpp" 104 | #include "colors/cpp.cpp" 105 | #include "colors/css.cpp" 106 | #include "colors/d.cpp" 107 | #include "colors/diff.cpp" 108 | #include "colors/edifact.cpp" 109 | #include "colors/fortran77.cpp" 110 | #include "colors/html.cpp" 111 | #include "colors/json.cpp" 112 | #include "colors/lua.cpp" 113 | #include "colors/makefile.cpp" 114 | //#include "colors/markdown.cpp" 115 | #include "colors/matlab.cpp" 116 | #include "colors/pascal.cpp" 117 | #include "colors/perl.cpp" 118 | #include "colors/po.cpp" 119 | #include "colors/postscript.cpp" 120 | #include "colors/pov.cpp" 121 | #include "colors/properties.cpp" 122 | #include "colors/python.cpp" 123 | #include "colors/ruby.cpp" 124 | #include "colors/spice.cpp" 125 | #include "colors/sql.cpp" 126 | #include "colors/tcl.cpp" 127 | #include "colors/tex.cpp" 128 | #include "colors/verilog.cpp" 129 | #include "colors/vhdl.cpp" 130 | #include "colors/yaml.cpp" 131 | 132 | static void setColorsAWK(QsciLexerAWK *lexer) { setColorsBash(lexer); } 133 | static void setColorsFontConfig(QsciLexerFontConfig *lexer) { setColorsHTML(lexer); } 134 | static void setColorsGLSL(QsciLexerGLSL *lexer) { setColorsCPP(lexer); } 135 | static void setColorsJournal(QsciLexerJournal *lexer) { lexer->updateColors(); } 136 | static void setColorsLISP(QsciLexerLISP *lexer) { lexer->updateColors(); } 137 | static void setColorsMarkdown2(QsciLexerMarkdown2 *lexer) { lexer->updateColors(); } 138 | static void setColorsNIM(QsciLexerNIM *lexer) { setColorsPython(lexer); } 139 | static void setColorsPkgBuild(QsciLexerPkgBuild *lexer) { setColorsBash(lexer); } 140 | static void setColorsQtPro(QsciLexerQtPro *lexer) { setColorsBash(lexer); } 141 | static void setColorsRust(QsciLexerRust *lexer) { setColorsCPP(lexer); } 142 | static void setColorsXorg(QsciLexerXorg *lexer) { lexer->updateColors(); } 143 | static void setColorsXorgLog(QsciLexerXorgLog *lexer) { lexer->updateColors(); } 144 | 145 | static void resetColors(QsciScintilla *document, Syntax::Lexer syntax) { 146 | document->setFont(Sqriptor::config.font); 147 | QColor bg = COLOR_BACKGROUND; 148 | QColor fg = COLOR_FOREGROUND; 149 | document->setPaper(bg); 150 | document->setColor(fg); 151 | // document->setCaretForegroundColor(fg); 152 | document->setCaretLineVisible(true); 153 | document->SendScintilla(QsciScintilla::SCI_SETCARETLINEVISIBLEALWAYS, true); 154 | document->setMatchedBraceBackgroundColor(bg.value() < fg.value() ? COLOR_OPERATOR.darker(200) : COLOR_OPERATOR.lighter(200)); 155 | document->setMatchedBraceForegroundColor(COLOR_OPERATOR); 156 | document->setUnmatchedBraceForegroundColor(COLOR_OPERATOR); 157 | // accentuate background color 158 | bg = bg.value() < fg.value() ? bg.darker(120) : bg.lighter(120); 159 | document->setMarginsBackgroundColor(bg); 160 | document->setCaretLineBackgroundColor(bg); 161 | document->setFoldMarginColors(bg, bg); 162 | fg = QColor((bg.red()+fg.red())/2, (bg.green()+fg.green())/2, (bg.green()+fg.green())/2); 163 | document->setMarginsForegroundColor(fg); 164 | document->setCaretForegroundColor(fg); 165 | document->setCaretWidth(qMax(1,qRound(document->physicalDpiX()/96.0f))); 166 | fg = QColor((2*bg.red()+fg.red())/3, (2*bg.green()+fg.green())/3, (2*bg.green()+fg.green())/3); 167 | document->setIndentationGuidesBackgroundColor(fg); 168 | document->setIndentationGuidesForegroundColor(fg); 169 | document->setEdgeColor(fg); 170 | document->setWhitespaceForegroundColor(fg); 171 | QsciScintilla::EdgeMode mode = QsciScintilla::EdgeNone; 172 | if (Sqriptor::config.wrap.indicator) { 173 | mode = QsciScintilla::EdgeLine; 174 | if (syntax == Syntax::Markdown2) 175 | mode = QsciScintilla::EdgeNone; //Background; 176 | else if (syntax == Syntax::Fortran77) { 177 | mode = QsciScintilla::EdgeMultipleLines; 178 | document->clearEdgeColumns(); 179 | document->addEdgeColumn(6, fg); 180 | fg = COLOR_ERROR; 181 | fg = QColor((bg.red()+fg.red())/2, (bg.green()+fg.green())/2, (bg.green()+fg.green())/2); 182 | document->addEdgeColumn(72, fg); 183 | } 184 | if (mode != QsciScintilla::EdgeMultipleLines) 185 | document->setEdgeColumn(Sqriptor::config.wrap.indicatorPos); 186 | } 187 | document->setEdgeMode(mode); 188 | document->setMarginsFont(Sqriptor::config.font); 189 | 190 | int asc = 0, dsc = 0; 191 | if (syntax == Syntax::Markdown2 && syntaxDict[syntax]) { 192 | QFont fnt = syntaxDict[syntax]->font(0); 193 | QFontMetrics fm(fnt); 194 | asc = fm.ascent(); 195 | dsc = fm.descent(); 196 | fnt.setPointSize(fnt.pointSize()*1.4); 197 | fm = QFontMetrics(fnt); 198 | asc -= fm.ascent(); 199 | asc = 3*asc/2 + 3; 200 | dsc -= fm.descent(); 201 | dsc = 3*dsc/2 + 1; 202 | } 203 | document->setExtraAscent(asc); 204 | document->setExtraDescent(dsc); 205 | } 206 | 207 | #define TRICK_QSCINTILLA_DETACHLEXER document->setLexer(nullptr); resetColors(document, syntax); document->SendScintilla(QsciScintilla::SCI_STYLECLEARALL); 208 | 209 | void Sqriptor::setSyntax(Syntax syntax, QsciScintilla *document, bool updateColorsOnly) 210 | { 211 | if (!document && !updateColorsOnly) 212 | document = textEdit(); 213 | 214 | if (syntax == Syntax::Auto && !updateColorsOnly) { 215 | if (!document->lexer()) { // don't use the filename to override an explicit/content detected lexer 216 | const QString filename = document->property("sqriptor_filename").toString(); 217 | syntax = Sqriptor::syntax(filename); 218 | if (syntax == Syntax::Properties && filename.contains("xorg.conf")) 219 | syntax = Syntax::Xorg; 220 | if (syntax == Syntax::Auto && (filename.endsWith("git-rebase-todo") || 221 | filename.endsWith("COMMIT_EDITMSG"))) 222 | syntax = Syntax::Bash; 223 | } 224 | if (syntax == Syntax::Auto) { 225 | QString shebang = document->text(0).section("\n",0,0); 226 | if (shebang.startsWith("#!") || shebang.contains("mime/")) 227 | syntax = Sqriptor::syntax(shebang); 228 | else if (shebang.startsWith("diff --git")) 229 | syntax = Syntax::Diff; 230 | else if (shebang.startsWith("-- Journal begins at") || 231 | shebang.contains(" kernel: Linux version ") || 232 | shebang.contains(" kernel: microcode: updated early: ")) 233 | syntax = Syntax::Journal; 234 | else if (shebang.startsWith("text(1).section("\n",0,0); 240 | if (shebang.startsWith("text(1).section("\n",0,0); 249 | if (shebang.contains("X.Org X Server")) 250 | syntax = Syntax::XorgLog; 251 | } 252 | if (syntax == Syntax::Auto) 253 | return; 254 | } 255 | 256 | if ((syntaxDict[syntax] || syntax == Syntax::None) && !updateColorsOnly) { 257 | QsciLexer *oldLexer = document->lexer(); 258 | TRICK_QSCINTILLA_DETACHLEXER 259 | document->setLexer(syntaxDict[syntax]); 260 | document->setProperty("sqriptor_syntax", syntax); 261 | if (!syntaxDict[syntax] && oldLexer) { 262 | document->SendScintilla(QsciScintilla::SCI_STYLESETFORE, QsciScintilla::STYLE_DEFAULT, COLOR_FOREGROUND); 263 | document->SendScintilla(QsciScintilla::SCI_STYLECLEARALL); 264 | } 265 | resetColors(document, syntax); 266 | if (document == textEdit()) 267 | indicateCurrentSyntax(); 268 | return; 269 | } 270 | 271 | #define MAKE_LEXER_2(_TYPE_,_CLASS_) case Syntax::_TYPE_ : \ 272 | if (!hook) syntaxDict[syntax] = new QsciLexer##_CLASS_(this); \ 273 | syntaxDict[syntax]->setDefaultFont(config.font);\ 274 | syntaxDict[syntax]->setFont(config.font);\ 275 | syntaxDict[syntax]->setDefaultPaper(COLOR_BACKGROUND);\ 276 | syntaxDict[syntax]->setPaper(COLOR_BACKGROUND);\ 277 | syntaxDict[syntax]->setDefaultColor(COLOR_FOREGROUND);\ 278 | syntaxDict[syntax]->setColor(COLOR_FOREGROUND);\ 279 | setColors##_TYPE_(static_cast(syntaxDict[syntax])); \ 280 | break; 281 | 282 | #define MAKE_LEXER(_TYPE_) MAKE_LEXER_2(_TYPE_,_TYPE_) 283 | 284 | QsciLexer *hook = syntaxDict[syntax]; 285 | if (updateColorsOnly && !hook) 286 | return; // don't pre-fab lexers... 287 | switch (syntax) { 288 | case Syntax::None: 289 | break; 290 | MAKE_LEXER(AVS) 291 | MAKE_LEXER(AWK) 292 | MAKE_LEXER(Bash) 293 | MAKE_LEXER(Batch) 294 | MAKE_LEXER(CMake) 295 | MAKE_LEXER(CoffeeScript) 296 | 297 | case Syntax::CSharp: 298 | if (!hook) hook = syntaxDict[syntax] = new QsciLexerCSharp(this); 299 | [[fallthrough]]; 300 | case Syntax::IDL: 301 | if (!hook) hook = syntaxDict[syntax] = new QsciLexerIDL(this); 302 | [[fallthrough]]; 303 | case Syntax::Java: 304 | if (!hook) hook = syntaxDict[syntax] = new QsciLexerJava(this); 305 | [[fallthrough]]; 306 | case Syntax::JavaScript: 307 | if (!hook) hook = syntaxDict[syntax] = new QsciLexerJavaScript(this); 308 | [[fallthrough]]; 309 | MAKE_LEXER_2(CPP,CPPQt) 310 | MAKE_LEXER(CSS) 311 | MAKE_LEXER(D) 312 | MAKE_LEXER(Diff) 313 | MAKE_LEXER(EDIFACT) 314 | MAKE_LEXER(FontConfig) 315 | 316 | case Syntax::Fortran: 317 | if (!hook) hook = syntaxDict[syntax] = new QsciLexerFortran(this); 318 | [[fallthrough]]; 319 | MAKE_LEXER(Fortran77) 320 | 321 | case Syntax::XML: 322 | if (!hook) hook = syntaxDict[syntax] = new QsciLexerHTML(this); 323 | [[fallthrough]]; 324 | MAKE_LEXER(HTML) 325 | 326 | MAKE_LEXER(GLSL) 327 | MAKE_LEXER(Journal) 328 | MAKE_LEXER(JSON) 329 | MAKE_LEXER(LISP) 330 | MAKE_LEXER(Lua) 331 | MAKE_LEXER(Makefile) 332 | MAKE_LEXER(Markdown2) 333 | 334 | MAKE_LEXER(NIM) 335 | 336 | case Syntax::Octave: 337 | if (!hook) hook = syntaxDict[syntax] = new QsciLexerMatlab(this); 338 | [[fallthrough]]; 339 | MAKE_LEXER(Matlab) 340 | 341 | MAKE_LEXER(Pascal) 342 | MAKE_LEXER(Perl) 343 | MAKE_LEXER(PkgBuild) 344 | MAKE_LEXER(PO) 345 | MAKE_LEXER(PostScript) 346 | MAKE_LEXER(POV) 347 | MAKE_LEXER(Properties) 348 | MAKE_LEXER(Python) 349 | MAKE_LEXER(QtPro) 350 | MAKE_LEXER(Ruby) 351 | MAKE_LEXER(Rust) 352 | MAKE_LEXER(Spice) 353 | MAKE_LEXER(SQL) 354 | MAKE_LEXER(TCL) 355 | MAKE_LEXER(TeX) 356 | MAKE_LEXER(Verilog) 357 | MAKE_LEXER(VHDL) 358 | MAKE_LEXER(Xorg) 359 | MAKE_LEXER(XorgLog) 360 | MAKE_LEXER(YAML) 361 | break; 362 | default: 363 | break; 364 | } 365 | if (syntax == Syntax::YAML) 366 | document->setIndentationsUseTabs(false); // they're illegal 367 | if (updateColorsOnly) 368 | return; // we're not touching the document here at all 369 | TRICK_QSCINTILLA_DETACHLEXER 370 | document->setLexer(syntaxDict[syntax]); 371 | document->setProperty("sqriptor_syntax", syntax); 372 | if (document == textEdit()) { 373 | indicateCurrentSyntax(); 374 | m_filterLine->setText(m_filterLine->text()); 375 | } 376 | resetColors(document, syntax); 377 | } 378 | 379 | void Sqriptor::indicateCurrentSyntax() 380 | { 381 | const int syntax = textEdit()->property("sqriptor_syntax").toInt(); 382 | m_previewAction->setVisible(syntax == Syntax::Markdown2 || syntax == Syntax::HTML); 383 | const QsciLexer *lexer = textEdit()->lexer(); 384 | QString name = "None"; 385 | if (lexer) { 386 | name = lexer->metaObject()->className(); 387 | name.remove("QsciLexer"); 388 | } 389 | foreach (QAction *act, m_syntaxActions->actions()) { 390 | if (act->data().toString() == name) { 391 | act->setChecked(true); 392 | return; 393 | } 394 | } 395 | } 396 | 397 | // php: # = //, /**/ - todo: the html lexer does php, but we need different brace treatment 398 | // cmake: # and #[[ ]] 399 | // pascal: //, {}, (**) - lol… boobies 400 | 401 | bool Sqriptor::toggleComment() 402 | { 403 | QsciScintilla *doc = textEdit(); 404 | const QsciLexer *lexer = doc->lexer(); 405 | if (!lexer) 406 | return false; 407 | QString name = lexer->metaObject()->className(); 408 | name.remove("QsciLexer"); 409 | bool isHtml = false; 410 | if (name == "CPPQt" || name == "CSharp" || name == "Java" || name == "CSS" || 411 | name == "JavaScript" || name == "D" || /* D also supports /++/ */ name == "Lua" || 412 | (isHtml = (name == "HTML")) || name == "XML" || name == "Pascal" || name == "FontConfig") { 413 | if (isHtml) { 414 | // QString suffix = doc->property("sqriptor_filename").toString().section('.', -1); 415 | // isHtml = !(suffix.startsWith("php") || suffix == "phtml"); 416 | // And what do we do with hybrids that are mostly html with some php code inside? 417 | } 418 | QString head = "/*", tail = "*/"; 419 | if (isHtml || name == "XML" || name == "FontConfig") { 420 | head = ""; 421 | } else if (name == "Pascal") { 422 | head = "{"; tail = "}"; 423 | } else if (name == "Lua") { 424 | head = "--[["; tail = "--]]"; 425 | } 426 | #define COMMENT_SEGMENT head.length(), text.length() - (head.length() + tail.length()) 427 | QString text = doc->selectedText(); 428 | if (!text.isEmpty()) { 429 | if (text.startsWith(head) && text.endsWith(tail)) 430 | doc->replaceSelectedText(text.mid(COMMENT_SEGMENT).trimmed()); 431 | else 432 | doc->replaceSelectedText(head + " " + text + " " + tail); 433 | return true; 434 | } 435 | int line, index; 436 | doc->getCursorPosition(&line, &index); 437 | text = doc->text(line); 438 | int begin, end; 439 | if ((begin = text.lastIndexOf(head, index)) > -1 && (end = text.indexOf(tail, index)) > -1) { 440 | doc->setSelection(line, begin, line, end + tail.length()); 441 | text = doc->selectedText(); 442 | text = text.mid(COMMENT_SEGMENT); 443 | if (begin > 0) // clumsy line comment, only option for css, html & xml 444 | text = text.trimmed(); // unconditionally, we'd likely nuke indention 445 | doc->replaceSelectedText(text); 446 | return true; 447 | } 448 | 449 | if (isHtml || name == "CSS" || name == "XML" || name == "FontConfig") { 450 | // only supports /**/, syntax 451 | doc->insertAt(tail, line, text.length()-1); 452 | doc->insertAt(head, line, 0); 453 | return true; 454 | } 455 | 456 | // Not "pascal", but delphi supports this style 457 | QString bangs = "//"; 458 | if (name == "Lua") 459 | bangs = "--"; 460 | if (QStringView(text).mid(index, 2).toString() == bangs) { 461 | doc->setSelection(line, index, line, index + 2); 462 | doc->removeSelectedText(); 463 | } else if (QStringView(text).mid(0, 2).toString() == bangs) { 464 | doc->setSelection(line, 0, line, 2); 465 | doc->removeSelectedText(); 466 | doc->setCursorPosition(line, index - 2); 467 | } else { 468 | doc->insertAt(bangs, line, 0); 469 | } 470 | return true; 471 | } 472 | 473 | if (name == "Bash" || name == "NIM" || name == "Python" || name == "Ruby" || name == "Perl" || 474 | name == "Makefile" || name == "CMake" || name.startsWith("Fortran") || name.contains("LISP") || 475 | name == "TCL" || name == "AWK" || name == "Xorg" || name == "PkgBuild" || name == "YAML" || 476 | name == "Properties" || name == "QtPro") { 477 | // tcltk might or not require ";#" inline 478 | const QChar bang = name.startsWith("Fortran") ? '!' : name.contains("LISP") ? ';' : '#'; 479 | QString text = doc->selectedText(); 480 | if (!text.isEmpty()) { 481 | if (text.startsWith(bang)) 482 | doc->replaceSelectedText(text.mid(1,text.length()-1)); 483 | else 484 | doc->replaceSelectedText(bang + text); 485 | return true; 486 | } 487 | int line, index; 488 | doc->getCursorPosition(&line, &index); 489 | text = doc->text(line); 490 | int begin = text.lastIndexOf(bang, index >= text.size() ? -1 : index); 491 | if (begin > 2) // full line has better cursor management 492 | index = begin; // caught next line 493 | if (QStringView(text).mid(index, 1).toString() == bang) { 494 | doc->setSelection(line, index, line, index + 1); 495 | doc->removeSelectedText(); 496 | } else if (QStringView(text).mid(0, 1).toString() == bang) { 497 | doc->setSelection(line, 0, line, 1); 498 | doc->removeSelectedText(); 499 | doc->setCursorPosition(line, index - 1); 500 | } else { 501 | doc->insertAt(bang, line, 0); 502 | } 503 | return true; 504 | } 505 | 506 | return false; 507 | } 508 | --------------------------------------------------------------------------------