more utf-8 improvements

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2009-06-12 10:53:32 -04:00
parent 28e41343c8
commit 1d1f26e8c2
1 changed files with 14 additions and 1 deletions

View File

@ -111,6 +111,7 @@ class Utf8Describe(Method):
format = '''
Glyph %s
Name %s
Code %s
Category %s
Bidirectional %s
@ -138,6 +139,7 @@ Numeric %s'''
c = unicodeget(u, 'combining', '?')
d = unicodeget(u, 'east_asian_width', '?')
code = repr(u)[2:-1]
name = unicodeget(u, 'name', 'Unnamed')
category = category_map.get(a, 'No Category') + ' (%s)' % a
bidirect = bidirect_map.get(b, 'No Directional Info') + ' (%s)' % b
@ -153,7 +155,7 @@ Numeric %s'''
normalize = unicodeget(u, 'normalize', 'n/a')
numeric = unicodeget(u, 'numeric', 'n/a')
data = self.format % (u, name, category, bidirect, combine, width,
data = self.format % (u, name, code, category, bidirect, combine, width,
mirror, decomposition, decimal, digit, lookup,
normalize, numeric)
w.application.data_buffer('*Utf8-Info*', data.strip(), switch_to=True)
@ -166,6 +168,17 @@ class Utf8DescribeChar(Utf8Describe):
u = w.buffer.get_substring(p, p.add(1, 0))
Utf8Describe._execute(self, w, code=u)
class Utf8Query(Method):
'''insert UTF-8 data into the buffer'''
args = [arg("name", t=type(""), p="Glpyh Name: ", h="the name of the UTF-8 Glpyh")]
def _execute(self, w, **vargs):
name = vargs['name']
try:
u = unicodedata.lookup(name)
w.set_error("glyph %s (%s)" % (u, repr(u)[2:-1]))
except KeyError:
w.set_error("glpyh %r was not found" % name)
class Utf8Insert(Method):
'''insert UTF-8 data into the buffer'''
args = [arg("data", t=type(""), p="UTF-8 Data: ", h="the UTF-8 data to use")]