The good editor for writing C++ programs on the Ubuntu platform

Somehow I noticed after writing the answer, that it was not about Ubuntu Touch platform, I must have misread it
The good editor for writing C++ programs on the Ubuntu platform

Somehow I noticed after writing the answer, that it was not about Ubuntu Touch platform, I must have misread it. I will try to move this answer or create a new question specific to UT. However I will keep this answer as Geany is also valid for any Ubuntu flavor.
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:
  1. fullscreen=true
  2. 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:
  1. sudo mount -o remount,rw /
  2. sudo apt-get update
  3. sudo apt-get install gcc build-essential
  4. sudo apt-get install maliit-inputcontext-gtk3 maliit-inputcontext-gtk2
  5. sudo apt-get install geany
  6. #the last command might throw some errors due to unmet dependencies
  7. #in which case the next command will take care of that:
  8. sudo apt-get -f install
  9. 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:
  1. cd ~/Downloads
  2. apt-get download geany
  3. 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:
  1. [Desktop Entry]
  2. Name=Geany Portable
  3. Comment=Geany Portable
  4. Exec=/home/phablet/.local/OpenSoftwareHub/geany-portable/usr/bin/geany
  5. Icon=/home/phablet/.local/OpenSoftwareHub/geany-portable/usr/share/icons/hicolor/scalable/apps/geany.svg
  6. Type=Application
  7. Terminal=false
  8. X-Ubuntu-Touch=true
  9. 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:
  1. 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.

>> Also you can read: How can you learn C and C++


أضف تعليق: