I want to insert certain Unicode symbol at current cursor position when Control-L is pressed. How to achieve this in Geany? (symbol ロ for example)
Insert Unicode symbol in Geany at cursor position
1.5k Views Asked by exebook At
2
There are 2 best solutions below
0

Had a similar desire. Here is a solution that makes use of the GeanyPy plugin:
Install and enable GeanyPy plugin that allows you to write Python plugins for Geany (this is available as geany-plugin-py in Ubuntu 16.04).
Place the following in your plugin directory (for me this was
~/.config/geany/plugins/
):
# -*- coding: utf-8 -*-
import gtk
import geany
class InsertSymbols(geany.Plugin):
__plugin_name__ = "InsertSymbols"
__plugin_version__ = "0.1"
__plugin_description__ = "Insert symbols e.g. unicode"
__plugin_author__ = "klimaat"
chars = ['°', '×', '²', '³', '±', 'µ', '·', 'ロ']
def __init__(self):
self.symbol_menuitem = gtk.MenuItem("Insert Symbol")
self.symbol_menuitem.show()
symbol_submenu = gtk.Menu()
self.symbol_menuitem.set_submenu(symbol_submenu)
for char in self.chars:
char_item = gtk.MenuItem(char)
char_item.show()
char_item.connect("activate", self.on_insert_symbol_clicked)
symbol_submenu.append(char_item)
geany.main_widgets.tools_menu.append(self.symbol_menuitem)
def cleanup(self):
self.symbol_menuitem.destroy()
def on_insert_symbol_clicked(self, data):
char = data.get_label()
doc = geany.document.get_current()
if doc:
pos = doc.editor.scintilla.get_current_position()
doc.editor.scintilla.insert_text(char)
doc.editor.scintilla.set_current_position(pos+2)
You should now have a "Insert Symbol" item under "Tools".
Probably much better ways to do it...
Macros Plugin helped. It allows to assign a Control-L key, and it has a command to insert any text at cursor. Took some time to figure, but not difficult.