Geany on Ubuntu Touch device as text editor, source code editor, debugger and compiler for multiple languages
Just today I have commited an answer to Quora: Which is a good editor for writing C++ programs on the Ubuntu platform? after mistakenly reading that it was about Ubuntu Touch, when it was actually about Ubuntu in general.
So I decided to bring the content here, where it will not be an out-of-place content by mistake.
Geany is a GUI text editor which also supports multiple compilers including gcc or Free Pascal (fpc) which I use it mostly with. It also supports syntax highlighters for plethora of languages and formats. It is a GTK app, but you can get it up and running on your phone directly, without any container like Libertine. Without further do, below is the content I made on Quora.
So I decided to bring the content here, where it will not be an out-of-place content by mistake.
Geany is a GUI text editor which also supports multiple compilers including gcc or Free Pascal (fpc) which I use it mostly with. It also supports syntax highlighters for plethora of languages and formats. It is a GTK app, but you can get it up and running on your phone directly, without any container like Libertine. Without further do, below is the content I made on Quora.
Although I almost entirely write apps for UT devices in Pascal, but I did write a little in C++. I did not find any IDE as good as Lazarus IDE for Pascal, but at least for non GUI apps, I found Geany pretty convenient. It supporst many compilers, including gcc. Also it supports syntax highlighter for many languages, including C/C++.
When installed on the UT device, naturally it runs via Xmir. I tweak the settings in ~/.config/geany/geany.conf file, because when I use it on my phone I do not load any window manager. So I edit this portion of the config file:
- fullscreen=true
- geaometry=0;0;1100;1050;0;
I use it on Meizu MX4 Pro phone, and I fix the width of the editor to the width of the screen, but I make the height smaller, to fit the onscreen keyboard, because otherwise the OSK would overflow the editor and your text cursor may end up hidden behind it:
*above are screen captures from my Meizu MX4 Pro Ubuntu Edition
If you can connect a wireless keyboard/mouse dongle, like BT set, via USB to OTG adapter, then you can use geany on your UT device with a mouse pointer and keybouard, and you will not need OSK at all, in which case you can resize the window to entire working space. Also, with wireless keyboard you can use Ctrl+Scroll shortcut to resize font size, because by default due to high DPI on the device screen, the fonts will look very tiny.
Off course if you want to actually compile the program, you will need to install build-essential package on your phone, because is does not come included in the default system image, even now that Ubuntu Touch is continued by UB Ports. It contains thinks like linker etc., so install it along the gcc package.
Another crucial thing missing from the default image are maliit context packages maliit-inputcontext-gtk3 and maliit-inputcontext-gtk2. Without them, you won’t be able to use OSK with Geany, because it is GTK app running on your UT device via XMir, and only native Mir apps have maliit context package installed by default. Which is kind of weird for my, that Xmir is icluded by default, but if you want osk, then you need to install its context manually.
Anyways, to install these packages on your UT device, you can follow this routine, which accounts for the fact that by default the / partition on UT devices is mounted as read-only:
- sudo mount -o remount,rw /
- sudo apt-get update
- sudo apt-get install gcc build-essential
- sudo apt-get install maliit-inputcontext-gtk3 maliit-inputcontext-gtk2
- sudo apt-get install geany
- #the last command might throw some errors due to unmet dependencies
- #in which case the next command will take care of that:
- sudo apt-get -f install
- sudo moune -o remount,ro /
Also, if you use geany, then you can debug and run your programs directly from within it. You won’t need to go into terminal app to do it manually. And it is true not only for gcc, but any supported compiler. For example, if I don’t do GUI app, then I often use Geany with Free Pascal compiler as a lighter alternative to Lazarus IDE. Geany supports a number of compilers for plethora of languages.
Finally, I want to make a remark, that if you decide to install Geany directly into your phone - and by directly I mean notinto any container like Libertine, but pure straight into the phone itself - then along with it some dependencies will be installed and it will use up space on your limited / partition. If you’d like to save as much space as possible, you can manually try to install Geany somewhere in your home folder. This is somewhat of a hack, but not too difficult either. You need to download .deb packaged for geany from the default repo, then extrac tits content to some place in your home directory, and manually create some symlinks to your / partition. So that only the symlink leaves a tiny footprint, while actual data is stored in your user space. If you want to take that path, know that you need 2 packages: geany and geany-common:
- cd ~/Downloads
- apt-get download geany
- apt-get download geany-common
I found that you don’t even need all of the provided content to use geany. I only extracted binary from geany package’s usr/bin/geany, .desktop launcher from usr/share/applications/geany.desktop and icon file from usr/share/icons…(few options, I chose svg). Note that the paths are relative to the root of the deb archive, because deb files are just compressed archives.
Then from the geany-common package I only had to extract usr/share/geany folder and symlink it as /usr/share/geany.
Then last step was to tweak the original geany.desktop launcher to this:
- [Desktop Entry]
- Name=Geany Portable
- Comment=Geany Portable
- Exec=/home/phablet/.local/OpenSoftwareHub/geany-portable/usr/bin/geany
- Icon=/home/phablet/.local/OpenSoftwareHub/geany-portable/usr/share/icons/hicolor/scalable/apps/geany.svg
- Type=Application
- Terminal=false
- X-Ubuntu-Touch=true
- X-Ubuntu-XMir-Enable=true
This is to ensure that Xmir is used to run geany, which is a gtk app. Also, you need to fix your paths accordingly, because you might have extracted files to a different location. I covered some more info related to this in my blog post here: X applications on Ubuntu Phone. After this, you have a working Geany launcher on your Apps scope on your UT device:
*an actual screen capture from my Meizu MX4 Pro Ubuntu Edition
A bonus feature is, that when you now ssh into your UT device with X forwarding flag:
- ssh -Y (or ssh -X) user@address
then you can use geany to edit any files on your UT device including system config files, with the convenience of a GUI editor rather than some vi or nano (although I always use mcedit from mc package). That means, that after I ssh into the phone (remember to turn on X forwarding) I can run geany off my phone onto my desktop’s screen.
Comments
Post a Comment