Adding *full* encoding support
taken from gnome-terminal's src/encoding.[ch]
This commit is contained in:
parent
54d7b5d669
commit
5001490021
204
terminator
204
terminator
@ -72,6 +72,164 @@ def openurl (url):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class Encoding:
|
||||||
|
TERMINAL_ENCODING_CURRENT_LOCALE,\
|
||||||
|
TERMINAL_ENCODING_ISO_8859_1,\
|
||||||
|
TERMINAL_ENCODING_ISO_8859_2,\
|
||||||
|
TERMINAL_ENCODING_ISO_8859_3,\
|
||||||
|
TERMINAL_ENCODING_ISO_8859_4,\
|
||||||
|
TERMINAL_ENCODING_ISO_8859_5,\
|
||||||
|
TERMINAL_ENCODING_ISO_8859_6,\
|
||||||
|
TERMINAL_ENCODING_ISO_8859_7,\
|
||||||
|
TERMINAL_ENCODING_ISO_8859_8,\
|
||||||
|
TERMINAL_ENCODING_ISO_8859_8_I,\
|
||||||
|
TERMINAL_ENCODING_ISO_8859_9,\
|
||||||
|
TERMINAL_ENCODING_ISO_8859_10,\
|
||||||
|
TERMINAL_ENCODING_ISO_8859_13,\
|
||||||
|
TERMINAL_ENCODING_ISO_8859_14,\
|
||||||
|
TERMINAL_ENCODING_ISO_8859_15,\
|
||||||
|
TERMINAL_ENCODING_ISO_8859_16,\
|
||||||
|
TERMINAL_ENCODING_UTF_7,\
|
||||||
|
TERMINAL_ENCODING_UTF_8,\
|
||||||
|
TERMINAL_ENCODING_UTF_16,\
|
||||||
|
TERMINAL_ENCODING_UCS_2,\
|
||||||
|
TERMINAL_ENCODING_UCS_4,\
|
||||||
|
TERMINAL_ENCODING_ARMSCII_8,\
|
||||||
|
TERMINAL_ENCODING_BIG5,\
|
||||||
|
TERMINAL_ENCODING_BIG5_HKSCS,\
|
||||||
|
TERMINAL_ENCODING_CP_866,\
|
||||||
|
TERMINAL_ENCODING_EUC_JP,\
|
||||||
|
TERMINAL_ENCODING_EUC_KR,\
|
||||||
|
TERMINAL_ENCODING_EUC_TW,\
|
||||||
|
TERMINAL_ENCODING_GB18030,\
|
||||||
|
TERMINAL_ENCODING_GB2312,\
|
||||||
|
TERMINAL_ENCODING_GBK,\
|
||||||
|
TERMINAL_ENCODING_GEOSTD8,\
|
||||||
|
TERMINAL_ENCODING_HZ,\
|
||||||
|
TERMINAL_ENCODING_IBM_850,\
|
||||||
|
TERMINAL_ENCODING_IBM_852,\
|
||||||
|
TERMINAL_ENCODING_IBM_855,\
|
||||||
|
TERMINAL_ENCODING_IBM_857,\
|
||||||
|
TERMINAL_ENCODING_IBM_862,\
|
||||||
|
TERMINAL_ENCODING_IBM_864,\
|
||||||
|
TERMINAL_ENCODING_ISO_2022_JP,\
|
||||||
|
TERMINAL_ENCODING_ISO_2022_KR,\
|
||||||
|
TERMINAL_ENCODING_ISO_IR_111,\
|
||||||
|
TERMINAL_ENCODING_JOHAB,\
|
||||||
|
TERMINAL_ENCODING_KOI8_R,\
|
||||||
|
TERMINAL_ENCODING_KOI8_U,\
|
||||||
|
TERMINAL_ENCODING_MAC_ARABIC,\
|
||||||
|
TERMINAL_ENCODING_MAC_CE,\
|
||||||
|
TERMINAL_ENCODING_MAC_CROATIAN,\
|
||||||
|
TERMINAL_ENCODING_MAC_CYRILLIC,\
|
||||||
|
TERMINAL_ENCODING_MAC_DEVANAGARI,\
|
||||||
|
TERMINAL_ENCODING_MAC_FARSI,\
|
||||||
|
TERMINAL_ENCODING_MAC_GREEK,\
|
||||||
|
TERMINAL_ENCODING_MAC_GUJARATI,\
|
||||||
|
TERMINAL_ENCODING_MAC_GURMUKHI,\
|
||||||
|
TERMINAL_ENCODING_MAC_HEBREW,\
|
||||||
|
TERMINAL_ENCODING_MAC_ICELANDIC,\
|
||||||
|
TERMINAL_ENCODING_MAC_ROMAN,\
|
||||||
|
TERMINAL_ENCODING_MAC_ROMANIAN,\
|
||||||
|
TERMINAL_ENCODING_MAC_TURKISH,\
|
||||||
|
TERMINAL_ENCODING_MAC_UKRAINIAN,\
|
||||||
|
TERMINAL_ENCODING_SHIFT_JIS,\
|
||||||
|
TERMINAL_ENCODING_TCVN,\
|
||||||
|
TERMINAL_ENCODING_TIS_620,\
|
||||||
|
TERMINAL_ENCODING_UHC,\
|
||||||
|
TERMINAL_ENCODING_VISCII,\
|
||||||
|
TERMINAL_ENCODING_WINDOWS_1250,\
|
||||||
|
TERMINAL_ENCODING_WINDOWS_1251,\
|
||||||
|
TERMINAL_ENCODING_WINDOWS_1252,\
|
||||||
|
TERMINAL_ENCODING_WINDOWS_1253,\
|
||||||
|
TERMINAL_ENCODING_WINDOWS_1254,\
|
||||||
|
TERMINAL_ENCODING_WINDOWS_1255,\
|
||||||
|
TERMINAL_ENCODING_WINDOWS_1256,\
|
||||||
|
TERMINAL_ENCODING_WINDOWS_1257,\
|
||||||
|
TERMINAL_ENCODING_WINDOWS_1258,\
|
||||||
|
TERMINAL_ENCODING_LAST = range(75)
|
||||||
|
|
||||||
|
encodings = [
|
||||||
|
[True, None, _("Current Locale")],
|
||||||
|
[False, "ISO-8859-1", _("Western")],
|
||||||
|
[False, "ISO-8859-2", _("Central European")],
|
||||||
|
[ False, "ISO-8859-3", _("South European") ],
|
||||||
|
[False, "ISO-8859-4", _("Baltic") ],
|
||||||
|
[False,"ISO-8859-5", _("Cyrillic") ],
|
||||||
|
[False, "ISO-8859-6", _("Arabic") ],
|
||||||
|
[False, "ISO-8859-7", _("Greek") ],
|
||||||
|
[False, "ISO-8859-8", _("Hebrew Visual") ],
|
||||||
|
[False, "ISO-8859-8-I", _("Hebrew") ],
|
||||||
|
[False, "ISO-8859-9", _("Turkish") ],
|
||||||
|
[False, "ISO-8859-10", _("Nordic") ],
|
||||||
|
[False, "ISO-8859-13", _("Baltic") ],
|
||||||
|
[False, "ISO-8859-14", _("Celtic") ],
|
||||||
|
[False, "ISO-8859-15", _("Western") ],
|
||||||
|
[False, "ISO-8859-16", _("Romanian") ],
|
||||||
|
[False, "UTF-7", _("Unicode") ],
|
||||||
|
[False, "UTF-8", _("Unicode") ],
|
||||||
|
[False, "UTF-16", _("Unicode") ],
|
||||||
|
[False, "UCS-2", _("Unicode") ],
|
||||||
|
[False, "UCS-4", _("Unicode") ],
|
||||||
|
[False, "ARMSCII-8", _("Armenian") ],
|
||||||
|
[False, "BIG5", _("Chinese Traditional") ],
|
||||||
|
[False, "BIG5-HKSCS", _("Chinese Traditional") ],
|
||||||
|
[False, "CP866", _("Cyrillic/Russian") ],
|
||||||
|
[False, "EUC-JP", _("Japanese") ],
|
||||||
|
[False, "EUC-KR", _("Korean") ],
|
||||||
|
[False, "EUC-TW", _("Chinese Traditional") ],
|
||||||
|
[False, "GB18030", _("Chinese Simplified") ],
|
||||||
|
[False, "GB2312", _("Chinese Simplified") ],
|
||||||
|
[False, "GBK", _("Chinese Simplified") ],
|
||||||
|
[False, "GEORGIAN-PS", _("Georgian") ],
|
||||||
|
[False, "HZ", _("Chinese Simplified") ],
|
||||||
|
[False, "IBM850", _("Western") ],
|
||||||
|
[False, "IBM852", _("Central European") ],
|
||||||
|
[False, "IBM855", _("Cyrillic") ],
|
||||||
|
[False, "IBM857", _("Turkish") ],
|
||||||
|
[False, "IBM862", _("Hebrew") ],
|
||||||
|
[False, "IBM864", _("Arabic") ],
|
||||||
|
[False, "ISO2022JP", _("Japanese") ],
|
||||||
|
[False, "ISO2022KR", _("Korean") ],
|
||||||
|
[False, "ISO-IR-111", _("Cyrillic") ],
|
||||||
|
[False, "JOHAB", _("Korean") ],
|
||||||
|
[False, "KOI8-R", _("Cyrillic") ],
|
||||||
|
[False, "KOI8-U", _("Cyrillic/Ukrainian") ],
|
||||||
|
[False, "MAC_ARABIC", _("Arabic") ],
|
||||||
|
[False, "MAC_CE", _("Central European") ],
|
||||||
|
[False, "MAC_CROATIAN", _("Croatian") ],
|
||||||
|
[False, "MAC-CYRILLIC", _("Cyrillic") ],
|
||||||
|
[False, "MAC_DEVANAGARI", _("Hindi") ],
|
||||||
|
[False, "MAC_FARSI", _("Persian") ],
|
||||||
|
[False, "MAC_GREEK", _("Greek") ],
|
||||||
|
[False, "MAC_GUJARATI", _("Gujarati") ],
|
||||||
|
[False, "MAC_GURMUKHI", _("Gurmukhi") ],
|
||||||
|
[False, "MAC_HEBREW", _("Hebrew") ],
|
||||||
|
[False, "MAC_ICELANDIC", _("Icelandic") ],
|
||||||
|
[False, "MAC_ROMAN", _("Western") ],
|
||||||
|
[False, "MAC_ROMANIAN", _("Romanian") ],
|
||||||
|
[False, "MAC_TURKISH", _("Turkish") ],
|
||||||
|
[False, "MAC_UKRAINIAN", _("Cyrillic/Ukrainian") ],
|
||||||
|
[False, "SHIFT-JIS", _("Japanese") ],
|
||||||
|
[False, "TCVN", _("Vietnamese") ],
|
||||||
|
[False, "TIS-620", _("Thai") ],
|
||||||
|
[False, "UHC", _("Korean") ],
|
||||||
|
[False, "VISCII", _("Vietnamese") ],
|
||||||
|
[False, "WINDOWS-1250", _("Central European") ],
|
||||||
|
[False, "WINDOWS-1251", _("Cyrillic") ],
|
||||||
|
[False, "WINDOWS-1252", _("Western") ],
|
||||||
|
[False, "WINDOWS-1253", _("Greek") ],
|
||||||
|
[False, "WINDOWS-1254", _("Turkish") ],
|
||||||
|
[False, "WINDOWS-1255", _("Hebrew") ],
|
||||||
|
[False, "WINDOWS-1256", _("Arabic") ],
|
||||||
|
[False, "WINDOWS-1257", _("Baltic") ],
|
||||||
|
[False, "WINDOWS-1258", _("Vietnamese") ]
|
||||||
|
]
|
||||||
|
|
||||||
|
def get_list():
|
||||||
|
return Encoding.encodings
|
||||||
|
get_list = staticmethod(get_list)
|
||||||
|
|
||||||
class TerminatorTerm:
|
class TerminatorTerm:
|
||||||
|
|
||||||
matches = {}
|
matches = {}
|
||||||
@ -312,12 +470,6 @@ class TerminatorTerm:
|
|||||||
# Set our sloppiness
|
# Set our sloppiness
|
||||||
self.focus = self.conf.focus
|
self.focus = self.conf.focus
|
||||||
|
|
||||||
def on_encoding_change (self, widget, encoding):
|
|
||||||
current = self._vte.get_encoding()
|
|
||||||
if current != encoding:
|
|
||||||
print ('Setting Encoding to ' + encoding)
|
|
||||||
self._vte.set_encoding(encoding)
|
|
||||||
|
|
||||||
def on_composited_changed (self, widget):
|
def on_composited_changed (self, widget):
|
||||||
self.reconfigure_vte ()
|
self.reconfigure_vte ()
|
||||||
|
|
||||||
@ -506,10 +658,17 @@ class TerminatorTerm:
|
|||||||
menu.show_all ()
|
menu.show_all ()
|
||||||
return menu
|
return menu
|
||||||
|
|
||||||
|
|
||||||
|
def on_encoding_change (self, widget, encoding):
|
||||||
|
current = self._vte.get_encoding()
|
||||||
|
if current != encoding:
|
||||||
|
print ('Setting Encoding to ' + encoding)
|
||||||
|
self._vte.set_encoding(encoding)
|
||||||
|
|
||||||
def _do_encoding_items(self, menu):
|
def _do_encoding_items(self, menu):
|
||||||
|
|
||||||
|
|
||||||
item = gtk.MenuItem (_("Encoding"))
|
item = gtk.MenuItem (_("Encodings"))
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
submenu = gtk.Menu()
|
submenu = gtk.Menu()
|
||||||
item.set_submenu(submenu)
|
item.set_submenu(submenu)
|
||||||
@ -528,6 +687,37 @@ class TerminatorTerm:
|
|||||||
radioitem.connect('activate', self.on_encoding_change, encoding)
|
radioitem.connect('activate', self.on_encoding_change, encoding)
|
||||||
submenu.append(radioitem)
|
submenu.append(radioitem)
|
||||||
|
|
||||||
|
item = gtk.MenuItem (_("Other Encodings"))
|
||||||
|
submenu.append(item)
|
||||||
|
#second level
|
||||||
|
|
||||||
|
submenu = gtk.Menu()
|
||||||
|
item.set_submenu(submenu)
|
||||||
|
encodings = Encoding().get_list()
|
||||||
|
encodings.sort(lambda x, y: cmp(x[2].lower(), y[2].lower()))
|
||||||
|
group = None
|
||||||
|
for encoding in encodings:
|
||||||
|
if encoding[1] in self.conf.active_encodings:
|
||||||
|
#already in active_encodings
|
||||||
|
continue
|
||||||
|
label = ""
|
||||||
|
if encoding[1] is None:
|
||||||
|
label = encoding[2]+" "+self._vte.get_encoding()
|
||||||
|
else:
|
||||||
|
label = encoding[2]+" "+encoding[1]
|
||||||
|
|
||||||
|
radioitem = gtk.RadioMenuItem(group, label)
|
||||||
|
if group is None:
|
||||||
|
group = radioitem
|
||||||
|
|
||||||
|
if encoding[1] == current_encoding:
|
||||||
|
radioitem.set_active(True)
|
||||||
|
|
||||||
|
radioitem.connect('activate', self.on_encoding_change, encoding[1])
|
||||||
|
submenu.append(radioitem)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def on_vte_title_change(self, vte):
|
def on_vte_title_change(self, vte):
|
||||||
if self.conf.titletips:
|
if self.conf.titletips:
|
||||||
vte.set_property ("has-tooltip", True)
|
vte.set_property ("has-tooltip", True)
|
||||||
|
Loading…
Reference in New Issue
Block a user