Multi-cursors and multi-selection in Kate / KDevelop

Multi-cursors or multi-selection are one of those features you start loving once you first try. And you never want to come back to anything which doesn't support that. I think the first guys, who made these features really useful were the guys who developed SublimeText editor. Just look what it can do:


Just in case Sublime is available for Linux and I also heard the same features been supported by MS Visual Code studio, which is also available for Linux. But that's off course not an open-source.

Speaking of KDevelop and Kate editor. They're both built on a top of KTextEditor KDE component. There were number of attempts in the past to introduce this kind of advanced multi-cursor and multi-selection features support to what is already had (multi-cursor via block selection - https://kate-editor.org/2013/09/09/multi-line-text-editing-in-kate/):

Unfortunately none of them were eventually merged to a mainline.
So if you want to use one of these, you'll probably need to build it yourself or take an AppImage from Sven's page if you're running Linux on x86_64 platform - http://files.svenbrauch.de/kate-linux/multicursor/

But things has changed to a better just recently. From what I see in the recent news is that KDE dev team was advertising to support multi-cursors in KTextEditor starting from KDE Frameworks version 5.92 - https://kate-editor.org/post/2022/2022-03-10-ktexteditor-multicursor/  

I guess it will take another while for major distros to update their KDE packages up to that version, so everyone could start enjoying multi-cursor and multi-selection in Kate. If you want to use it earlier you need either to build it yourself again, find a flatpak/appimage/snap package or switch to KDE Neon :)

The world of Linux is tough one, yeah

Building Kate

So I decided to give it a try and build it. It was quite an interesting experience I need to tell you, but what impressed me the most you can reach out KDE/Kate guys on their IRC channel and they can help you. Hats off, gents. You've made me to love Linux and KDE community more and more every day.

KDE has quite a good document on how to start - https://community.kde.org/Get_Involved/development so start with reading it. It will tell you what you need to install and configure.

An older and wiser me from future suggests you to install these additional packages, to minimize your efforts of troubleshooting, on a top of what KDE page  tells you what to install:

sudo apt install qtdeclarative5-dev qtbase5-private-dev 
polkit-gobject-1-dev libpolkit-gobject-1-dev libpolkit-agent-1-dev 
libqt5x11extras5-dev libqt5waylandclient5-dev extra-cmake-modules 
qtwayland5-dev-tools libwayland-dev libkf5windowsystem-dev libxcb*-dev
sudo apt build-dep kconfig qml-module-org-kde-kwindowsystem libqt5svg5-dev

(Probably one day, when https://invent.kde.org/sdk/kdesrc-build/-/issues/9  will be completely done, everything would be automated by the kdesrc-build script, but it's bearable even in current state)

Then you follow https://kate-editor.org/build-it/#linux and be patient, as you'll have to deal with a lot of failing stuff, when you'll be finally running kdesrc-build --include-dependencies kate

I'll give you this short guidance, based on an example of one failure (out of many I had). What happened here is that kiconthemes module failed to be built during kdesrc-build --include-dependencies kate phase. When such failure happens, kdesrc-build gives us a favor and highlights that in its output with red font + gives you a location to a detailed log file. You need to examine  that log file carefully. I highlighted the important bit in red:

# kdesrc-build running: 'cmake' '-B' '.' '-S' '/home/pi/projects/kde/src/frameworks/kiconthemes' '-G' 'Kate - Ninja' '-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON' '-DCMAKE_CXX_FLAGS:STRING=-pipe' '-DCMAKE_INSTALL_PREFIX=/home/pi/projects/kde/usr'
# from directory: /home/pi/projects/kde/build/frameworks/kiconthemes
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- 

Installing in /home/pi/projects/kde/usr. Run /home/pi/projects/kde/build/frameworks/kiconthemes/prefix.sh to set the environment for KIconThemes.
-- Setting build type to 'Debug' as none was specified.
-- Looking for __GLIBC__
-- Looking for __GLIBC__ - found
-- Performing Test _OFFT_IS_64BIT
-- Performing Test _OFFT_IS_64BIT - Success
-- Performing Test HAVE_DATE_TIME
-- Performing Test HAVE_DATE_TIME - Success
-- Performing Test BSYMBOLICFUNCTIONS_AVAILABLE
-- Performing Test BSYMBOLICFUNCTIONS_AVAILABLE - Success
CMake Error at CMakeLists.txt:46 (find_package):
  Could not find a package configuration file provided by "Qt5Svg" (requested
  version 5.15.2) with any of the following names:

    Qt5SvgConfig.cmake
    qt5svg-config.cmake

  Add the installation prefix of "Qt5Svg" to CMAKE_PREFIX_PATH or set
  "Qt5Svg_DIR" to a directory containing one of the above files.  If "Qt5Svg"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!
See also "/home/pi/projects/kde/build/frameworks/kiconthemes/CMakeFiles/CMakeOutput.log".

Speaking plain English, in order to compile this KDE module, kdesrc-build needed to have specific files in your filesystem, which names I highlighted in red. But it didn't find those.

Usually such .cmake files (as well as .h files) are provided by special -dev packages in Debian/Ubuntu. Use the APT QUICK CHEAT to see how to use your package manager to find packages that are providing these files, then install them (hint: apt-file search <filename>)

Once that is installed, try to build the failing module again to ensure it's fine now:

kdesrc-build kiconthemes

Rinse and repeat for the next error you'll find. At the end of the day you'll be able to make it through all failures and you'll have a pretty green build. 

For my Orange PI 4 LTS aarch64 machine with 6 cores of RK3399 it took like 2-3 hours of compiling plus another couple of hours of troubleshooting. But it was worth it.



No comments:

Post a Comment

Start here

Disable Firefox from updating itself and flash those annoying "Restart to Keep Using Firefox" messages on you

I recently switched from Brave to Firefox. Just because Brave appeared to be some proprietary shit, even though they're masking themselv...