📜 ⬆️ ⬇️

The dark side of QScintilla

Recently, articles ( 1 , 2 ) about the wonderful QScintilla component began to appear on Habré.
I am one of the developers of the Monkey Studio project, and, for the last year and a half, mksv3 . We have been using QScintilla for 5 years now. We periodically make bug reports and patches for him. We decided to give it up. And we are painfully hurt for the years spent on it.
I am writing this post so that others do not happen the same way.

I share my experience. We are developing a free universal cross-platform text editor. What is critical for us may not be important to you. And vice versa. Analyze.
And so, our experience. What is bad in QScintilla ...

Binary lexers

In the terminology of Scintilla, Lexer is a class that parses, highlights, levels, etc. specific programming language.
For most components that allow editing code, you can create text files with a description of the syntax of the new language. For example, for katepart . For QScintilla, the lexer is only C ++ code. Respectively:


Lexer settings

QScintilla allows you to customize the lexer. You can choose which structures will collapse (code folding) and which ones will not in C ++, and whether the lexer will highlight inconsistent code alignment in Python. But, each lexer has its own set of parameters. Both the code and for setting up the lexer have to write unique.
If a programmer wants to know whether a line of a file Y is a X character comment (for example, to check spelling in comments, but not in code), you will again have to write a unique check for each of the lexers.
Even more, the problem is exacerbated by the fact that the set of lexers and their settings changes with each release. The fact that the settings have changed will periodically remind you of the bug reports “I’m not going to build a project on QScintilla version xxx”. And the design is very useful to you.
#if QSCINTILLA_VERSION >= ...

Color schemes

People are different, their tastes are different too. Someone likes dark text on a light background, someone light text on a dark background. QScintilla allows you to customize the font and background for each of the syntax elements (numbers, lines, keywords ...)
For example, here is the settings dialog from Monkey Studio (click on the image for full size):

But, you can only configure a specific lexer. The screenshot shows the C ++ configuration page. If the user wants to create his own color scheme, you will have to configure each of the languages ​​used in turn.
If the programmer wants to create a color scheme for users, the option is the same - you will have to configure each of several dozen languages, and do not forget to update the theme with the advent of new ones.
Very time consuming. Kate and some other editors allow you to customize all languages ​​at once. It's easier.
')
Bad rendering

QScintilla does not use QTextEdit + QSyntaxHighlighter, but draws everything on its own on QAbstractScrollArea. The bike turned out in places.


Own regular expression syntax

QScintilla supports text searching. It works, even regular expressions can be used. But here the syntax of regular expressions in some places differs from the generally accepted one (such as, for example, in QRegExp). And users will not like these minor differences. For the prototype - will fit, for a stable project - no.
We did a search on QScintilla, then we had to throw it away and write our own.

No open repository

For some reason, Phil Thomson does not open the public access to the QScintilla repository, but only uploads the archives.
Because of this:


Conclusion

I hope no one thought that I do not like QScintilla, or I consider it a bad component. It has a lot of useful functionality, it supports a large number of languages, in most cases, the author very quickly and adequately responds to patches and bug reports. For most Qt projects that need a code editor, QScintilla is the best solution. Moreover, there are not many alternatives. And it's great that namespace writes useful articles about QScintilla.
Just about the positive side is already written. And I told you about the shortcomings we found, which are not obvious in the initial stages of the project. I hope this will help to make a complete picture and objectively evaluate the component.

The list of deficiencies is our experience. Possibly we did not understand something and we are doing wrong. Comment on. Let's search for the truth.

If you decide to use QScintilla, useful examples can be found in Eric , JuffEd, and my projects, links to which are at the beginning.

Authors of new IDE

And yet, if you have read to the end, with some probability you are planning or have already begun to make your own text editor or IDE. And maybe at this stage it is not too late to stop you.
For five years I have seen at least a dozen projects that died a couple of years after the start. Fuse author dries out, and the functionality is not much more than what was in the first couple of months. Sadly
Sometimes new projects are worth starting. But, only if there are really serious reasons. First, review the existing ones and clearly state for yourself why it is impossible to join their team and continue working together. Better one good project than 10 bad ones. Links to several worthwhile projects on Qt, and so on. on qscintilla is here .

Good luck!

Source: https://habr.com/ru/post/144848/


All Articles