some basic utf-8 support

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2009-06-11 18:52:57 -04:00
parent 2f23872896
commit 348e6eee2a
2 changed files with 30 additions and 1 deletions

View File

@ -104,7 +104,7 @@ class Application(object):
'method', 'method.svn', 'method.cvs', 'method.search',
'method.buffers', 'method.move', 'method.shell',
'method.introspect', 'method.help', 'method.numbers',
'method.spell', 'method.hg',
'method.spell', 'method.hg', 'method.utf8',
)
for name in names:
exec("import %s" % name)

29
method/utf8.py Normal file
View File

@ -0,0 +1,29 @@
import os, commands, re, tempfile
from subprocess import Popen, PIPE, STDOUT
import buffer, default, dirutil, lex, regex, util, window
from point import Point
from method import Method, Argument, arg
class Utf8Get(Method):
def _execute(self, w, **vargs):
p = w.logical_cursor()
c = w.buffer.get_substring(p, p.add(1, 0))
w.set_error(repr(c))
class Utf8Describe(Method):
def _execute(self, w, **vargs):
w.set_error("not implemented")
class Utf8Insert(Method):
'''insert the specified UTF-8 character into the buffer'''
args = [arg("data", t=type(""), p="Data: ",
h="the UTF-8 escaped data to use to use")]
def _execute(self, w, **vargs):
s = "u'" + vargs['data'] + "'"
try:
u = eval(s, {}, {})
w.insert_string_at_cursor(u)
except:
w.set_error("invalid: %s" % vargs['data'])