|
Post by bigbass on Jun 27, 2022 3:09:53 GMT 1
Hello This was more involved to put as a simple demo so here it is a real but small text editor added tool tips qt5-editor-1.1.tar.gz (69.43 KB) bacon with Qt5 are working nicely together! it is a start many things we could add in later hopefully bacon syntax highlighting ... but not tonight Joe
|
|
|
Post by Pjot on Jun 27, 2022 15:34:36 GMT 1
Wow! That looks really good. I am going to give it a try shortly.
Thanks Joe, Peter
|
|
|
Post by Pjot on Jun 27, 2022 18:19:39 GMT 1
Hi Joe, Well, I had to change only one line of code: PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -I/usr/include/x86_64-linux-gnu/qt5 -fPIC
...and then it compiled without problems. All functionality works, and its just amazing how small the code is. The only thing left for BaCon would be the syntax highlighting. As you know, I have implemented this before manually for the FLTK editor. Looking into how it works for Qt... BR Peter
|
|
|
Post by bigbass on Jun 27, 2022 23:00:11 GMT 1
Hello Peter
thanks for the x86 line I added it and commented it out in the main code just now
a minor bump 1.1 has tool tips
if you want to add the bacon highlighting manually perfect!
I was taking the easy way of thinking and was going to add kate's syntax highlighter but still sorting out the how to go about it then the next step would be to add bacon syntax to kate's options
Joe
|
|
|
Post by vovchik on Jun 28, 2022 15:16:01 GMT 1
Dear Joe (and Peter), Ain't that a little beauty! Thanks. And the binary is also tiny. Well done!!! I have added 18 little svg images to replace the original pngs. They work. images.tar.gz (2.83 KB) And a similar (but slightly prettier) set: To use them, simply change the *.png extensions in the source to *.svg. The names are the same. images-vov.tar.gz (4.46 KB) With kind regards, vovchik
|
|
|
Post by bigbass on Jun 29, 2022 18:13:17 GMT 1
Hello vovchik Thanks! they look good and are smaller in size and svg format there are still some figuring out things with the Qt world to do but the good part is it does work with bacon and a lot of documentation and demo examples to keep anyone busy for some time I got about 95% of the syntax highlighting for the Kf5 (from kate) backend working with bacon via recycling the FreeBasic.xml this should work with anything that uses kate as the backend or Qt apps there is a readme there also sourceforge.net/projects/bacon-qt5/files/syntax/ sudo apt-get install libkf5syntaxhighlighting*
that will pull in these apt-cache search KF5SyntaxHighlighting libkf5syntaxhighlighting-data - Syntax highlighting Engine - translations libkf5syntaxhighlighting-dev - Syntax highlighting Engine libkf5syntaxhighlighting-doc - Syntax highlighting Engine (documentation) libkf5syntaxhighlighting-tools - Syntax highlighting Engine libkf5syntaxhighlighting5 - Syntax highlighting Engine if you want to manually change all default qt themes and make thing look really good and fast install some qt themes then sudo apt-get install qt5-style-kvantum* export QT_STYLE_OVERRIDE=kvantum default gtk2 export QT_STYLE_OVERRIDE=gtk2
or maybe export QT_STYLE_OVERRIDE=adwaita joe
|
|
|
Post by bigbass on Jul 1, 2022 19:20:40 GMT 1
Hello I updated the freebasic.xml with all the functions$ for example LEFT$, CHOP$.... got kate working with bacon and changed directories for the freebasic.xml file to use KF5 I updated the readme and the freebasic.xml in the above post P.S I compiled the baconized freebasic,xml into the KF5/KSyntaxHighlighting source code now kate reads *.bac with color .... Joe
|
|
|
Post by Pjot on Jul 2, 2022 14:52:57 GMT 1
Thanks Joe, The 'bacon.xml' file looks strikingly similar to the GtkSourceView definition. But indeed, the QT5 way of setting syntax highlighting is much more complex. Programmatically, it need a QTextDocument and not a QTextEdit, for example. It's a whole new API and it is going to take some time to get used to... BR Peter
|
|
|
Post by bigbass on Jul 2, 2022 18:20:33 GMT 1
Hello Peter Yes exactly in the end we need to get the highlighted text into a Qt widget somehow but there are some presteps needed to get there I got a minimum cli syntax text highlighter working with bacon code I think a working demo expresses the idea better there is a lot of code to sort though I re used your bacon keywords list and adapted them to the kate xml format they are very close in idea one advantage is we can use the DOLLAR SIGN $ with the keywords and added the bacon language name="BaCon" version="5" kateversion="5.1" section="Sources" extensions="*.bac" mimetype="text/x-bacon" now bacon has a text/x-bacon the first step to get there using kate KF5SyntaxHighlighting the code gets compiled into an "indexer" then all the xml files are compiled into that indexer at the low level I wrote the bacon.xml without using freebasic (the second attempt using v5.60.0) and added it into the official source code compiled the indexer (we dont get an option for BaCon because that part is in the kate GUI code) but the *.bac mime type works but it is a hidden feature at the moment just for us compile this then ./highlight bacon.bac with bacon.bac in the same folder for testing here it is in action UPDATED CODE TO COMPILE without edits to source code headers Joe
PRAGMA INCLUDE <QtWidgets/QApplication> <QtWidgets/QLabel> <QtGui/QHoverEvent> PRAGMA INCLUDE <QtWidgets/QMainWindow> <QtWidgets/QPushButton> <QtWidgets/QFileDialog> PRAGMA INCLUDE <QtCore/QVariant> <QtWidgets/QAction> <QtCore/QDir> <QtWidgets/QMessageBox> PRAGMA INCLUDE <QtWidgets/QMenu> <QtWidgets/QMenuBar> <QtWidgets/QStatusBar> <QtCore/QTextStream> PRAGMA INCLUDE <QtWidgets/QTextEdit> <QtWidgets/QToolBar> <QtWidgets/QWidget> <QtWidgets/QFontDialog> PRAGMA INCLUDE <QtWidgets/QAction> <QtWidgets/QMenuBar> <QtWidgets/QStatusBar> PRAGMA INCLUDE <QtWidgets/QMenu> <QtWidgets/QTextEdit> <QtWidgets/QToolBar> <QtWidgets/QVBoxLayout> '--- this part of the code communicates with the KSyntaxHighlighting at the low level directly '--- the libkf5syntaxhighlighting5 - Syntax highlighting Engine PRAGMA INCLUDE <QtCore/QCommandLineParser> <QtWidgets/QPlainTextEdit> <QtGui/QSyntaxHighlighter> <QtGui/QColor> PRAGMA INCLUDE <QtCore/QTypeInfo> <QtCore/QProcess> PRAGMA INCLUDE <KF5/KSyntaxHighlighting/definition.h> PRAGMA INCLUDE <KF5/KSyntaxHighlighting/foldingregion.h> PRAGMA INCLUDE <KF5/KSyntaxHighlighting/repository.h> PRAGMA INCLUDE <KF5/KSyntaxHighlighting/syntaxhighlighter.h> PRAGMA INCLUDE <KF5/KSyntaxHighlighting/theme.h>
'---added syntax highlighting from kate PRAGMA LDFLAGS -lQt5Widgets -lKF5SyntaxHighlighting -lQt5Gui -lQt5Core -lGLESv2 -lpthread -latomic PRAGMA COMPILER g++
'---raspberry pi 3 or 4 PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -I/usr/include/arm-linux-gnueabihf/qt5 -I/usr/include/arm-linux-gnueabihf/qt5/QtCore -I/usr/include/KF5/KSyntaxHighlighting -I/usr/include/arm-linux-gnueabihf/qt5/QtGui -fPIC '---x86 'PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I/usr/include/KF5/KSyntaxHighlighting -I/usr/include/x86_64-linux-gnu/qt5/QtGui -fPIC
OPTION PARSE FALSE
DECLARE win TYPE QMainWindow* DECLARE app TYPE QApplication* DECLARE centralWidget TYPE QWidget* DECLARE view TYPE QPlainTextEdit*
app = new QApplication(argc, argv) win = new QMainWindow() win->resize(800, 400) actionNew = new QAction(win) 'imortant to note 'since the app used new on the bacon side it now became a pointer (*app) 'in the C++ side of the code USEC QCommandLineParser parser; parser.addHelpOption(); parser.addPositionalArgument(QStringLiteral("source"), QStringLiteral("The source file to highlight.")); parser.process(*app);
KSyntaxHighlighting::Repository repository; for (const QString &file : parser.positionalArguments()) { const auto url = QUrl::fromUserInput(file, {}, QUrl::UserInputResolutionOption::AssumeLocalFile); QFile f(url.toLocalFile()); if (!f.open(QIODevice::ReadOnly)) continue;
auto view = new QPlainTextEdit(); view->setPlainText(QString::fromUtf8(f.readAll())); view->resize(500, 500);
auto highlighter = new KSyntaxHighlighting::SyntaxHighlighter(view->document()); highlighter->setTheme((view->palette().color(QPalette::Base).lightness() < 128) ? repository.defaultTheme(KSyntaxHighlighting::Repository::DarkTheme) : repository.defaultTheme(KSyntaxHighlighting::Repository::LightTheme));
const auto def = repository.definitionForFileName(url.toLocalFile()); highlighter->setDefinition(def); view->show(); } END USEC ' win->show() return app->exec()
|
|
|
Post by vovchik on Jul 3, 2022 0:32:15 GMT 1
Dear Joe and Peter, I found notepadqq a few days ago. The source is here: sourceIt uses qt5 and looks rather like geany. With kind regards, vovchik
|
|
|
Post by bigbass on Jul 3, 2022 23:42:31 GMT 1
Hello vovchik Thanks for this and any other qt based text editors there is a lot of working code we could use I had some big troubles with qt chrome web engine tried to build it from source using git and it ran my system full and locked up ! well I decided to start with a new bullseye rpi os and this time document what is needed for qt better so I am in the process of starting again clean Joe ------------------------clean---------------------------------------- #I keep the latest bacon syntax for kate here sourceforge.net/projects/bacon-qt5/files/syntax/#you have to recreate those folders if you dont have them mkdir -p $HOME/.local/share/KF5/syntax-highlighting/syntax mkdir -p $HOME/.local/share/org.kde.syntax-highlighting/syntax #then place the freebasic.xml inside the syntax folders cp freebasic.xml $HOME/.local/share/org.kde.syntax-highlighting/syntax cp freebasic.xml $HOME/.local/share/KF5/syntax-highlighting/syntax #for KATE sudo apt-get install kate sudo apt-get install libkf5syntaxhighlighting* now kate will automatically add the correct syntax highlighting for bacon.bac files select freebasic from Tools->Highlighting->Sources->FreeBASIC #just in case you are missing some deps for Qt these will pull in almost all sudo apt-get install qtbase5-dev sudo apt-get install qtcreator ====================advanced use======================================== #advanced use if you compile from source kf5syntaxhighlighting and drop in bacon.xml into the data/syntax folder then complile and install bacon *.bac will work without selecting freebasic from the menu in kate but it can be built into the indexer ======================================================================= --
|
|
|
Post by bigbass on Jul 6, 2022 14:42:30 GMT 1
Hello Peter and vovchik some good news I updated to debian bullseye and that gave me the needed Qt version of 5.15.2 now a lot of source code will compile correctly! and it has qmake 3.1 I am still going to avoid compiling chromium web enginefor awhile more good news I updated this code basic-converter.proboards.com/post/14480*I now realized I made changes to the source code headers to get the demo to compile but didnt remember that until I started on a clean box with the default headers again now it should work out of the box with no compiling source code packages Just a tip to remember if this happens to me again I had to add to the PRAGMA OPTIONS and give it the path to look for Joe
|
|
|
Post by bigbass on Jul 12, 2022 14:39:25 GMT 1
Kate now has bacon syntax highlighting working basic-converter.proboards.com/post/14482 but in the freebasic.xml file you can't or shouldn't set colors if you follow the rules because kate has a very nice GUI that allows you to customize the color theme well I got used to my color picks for geany with bacon syntax highlighting so I tried to clone the overall feel of that and created a style.theme called Bacon Geany feel.themeBacon Geany feel.theme (5.13 KB) it shows up as a compressed icon but it is NOT it is just a plain text file you can even open it and read it now all you have to do is in the main window menu of kate Settings---->configure kate---->color themes----> IMPORT then select the Bacon Geany feel.theme and a preview of the look its very easy now to make it look however you prefer by using the kate GUI color themes tool and you can share themes with very little effort needed Joe
|
|
|
Post by Pjot on Jul 12, 2022 17:24:14 GMT 1
Thanks Joe,
Looks really good!
BR, Peter
|
|
|
Post by bigbass on Jul 13, 2022 5:55:10 GMT 1
Hello Peter
thanks we should be able to add syntax highlighting to our qt projects I'll try to do it in just qt first and if all goes well there then port it to bacon
this is an ongoing work in progress little by little
Joe
|
|