After a long time of constant distraction by my daily work, I finally found again a bit time to take care of KTextEditor/Kate/… issues.
One thing that really started to be an itch I wanted to scratch is some rendering fault that occur with ‘special’ font sizes.
Given I wanted to do again a bit work on the macOS port, I was really annoyed that on my screen the only application with text rendering issues was “my” one :/
I assume a lot of people have sometimes seen stuff like that in KTextEditor based applications like Kate or KDevelop:
These small white lines really stick out like a sore thumb 🙁 It looked like some off-by-one rounding issue, surely one should be able to find it…
I tried to track down where in our rendering in KTextEditor we do create these artifacts, but I never found any place that looks like a possible cause.
After a bit more tinkering it became obvious that actually it would be more or less impossible for the KTextEditor code to mess up the painting in such a way, as we normally draw one line more or less as one thing using QTextLayout that handles the painting of the selection background, too.
Using QtCreator as an non-KTextEditor based application that uses the Qt layouting & rendering it was possible to get similar effects on macOS (or X11):
:=) Good thing that Qt is open source. A quick look into the qtextlayout.cpp and a qt5 compile later, I was able to trace the issue down to some qFloor calls for painting the selections.
At least for the syntaxhighlighter example shipped with Qt I was able to reproduce the issue before my patch but not afterwards.
Would Qt not be open-source, I would have been at the end of the line after seeing no “error” in our codebase in KTextEditor.
With Qt as some open-source project, it is a completely different story.
Besides, the Qt documentation for “how to build it” and “how to contribute” on the Qt Wiki are well enough to understand that I was able to nicely compile the stuff from scratch on macOS and provide the Gerrit review request in no time.
By default, the terminal looks as follows on my Linux distribution:
However, if you are working a lot on the terminal, there are a lot of scripts and tricks available in the net that improve the information displayed in the terminal in many ways. For instance, since many many years, I have the following at the end of my ~/.bashrc:
# use a fancy prompt PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]" PS1="$PS1 \`if [ \$? = 0 ]; then echo -e '\[\033[01;32m\]:-)';" PS1="$PS1 else echo -e '\[\033[01;31m\]:-(' \$?; fi\`\[\033[00m\]" PS1="$PS1 \$(__git_ps1 \"(%s)\") \$ "
Once you open a new terminal, then the appearance is as follows:
As you can see, now I have nice colors: The hostname is green, the folder is blue, the return value of the last executed command is a green 🙂 in case of success (exit code = 0), and a red 🙁 in case of errors (exit code != 0). In addition, the last part shows the current git branch (master). Showing the git branch is very useful especially if you are using arc a lot and work with many branches.
I am sure there are many more cool additions to the terminal. If you have some nice additions, please share – maybe also as a new blog?
Recently, the KSyntaxHighlighting framework was added to the KDE Frameworks 5.29 release. And starting with KDE Frameworks 5.29, KTextEditor depends on KSyntaxHighlighting. This also means that KTextEditor now queries KSyntaxHighlighting for available xml highlighting files. As such, the location for syntax highlighting files changed from $HOME/.local/share/katepart5/syntax to
So if you want to add your own syntax highlighting files to Kate/KDevelop, then you have to use the new location.
By the way, in former times, all syntax highlighting files were located somewhere in /usr/share/. However, since some time, there are no xml highlighting files anymore, since all xml files are compiled into the KSyntaxHighlighting library by default. This leads to much faster startup times for KTextEditor-based applications.
Running Unit Tests
If you build Kate (or KTextEditor, or KSyntaxHighlighting) from sources and run the unit tests (`
make test`), then the location typically is /$HOME/.qttest/share/org.kde.syntax-highlighting/syntax.