mirror of
https://github.com/ksherlock/prez.git
synced 2025-02-19 16:30:32 +00:00
formatting "chars"
This commit is contained in:
parent
bfb1d296cc
commit
e7e86e8a36
18
menu.py
18
menu.py
@ -33,13 +33,13 @@ _menu_item_ids = {}
|
||||
|
||||
|
||||
|
||||
def _to_char_string(x):
|
||||
if not x: return '""'
|
||||
if x == 0x0d: return "\\n" # intentionally backwards
|
||||
if x == 0x0a: return "\\r" #
|
||||
if chr(x) in "\\\\'" : return "\\" + x
|
||||
if x >= 32 and x < 0x7e: return '"' + chr(x) + '"'
|
||||
return "\\${:02x}".format(x)
|
||||
# def _to_char_string(x):
|
||||
# if not x: return '""'
|
||||
# if x == 0x0d: return "\\n" # intentionally backwards
|
||||
# if x == 0x0a: return "\\r" #
|
||||
# if chr(x) in "\\\\'" : return "\\" + x
|
||||
# if x >= 32 and x < 0x7e: return '"' + chr(x) + '"'
|
||||
# return "\\${:02x}".format(x)
|
||||
|
||||
class rMenuBar(rObject):
|
||||
rName = "rMenuBar"
|
||||
@ -237,8 +237,8 @@ class rMenuItem(rObject):
|
||||
"\t0x{:04x} /* title ref (rPString) */"
|
||||
).format(
|
||||
itemID,
|
||||
_to_char_string(self.itemChar),
|
||||
_to_char_string(self.altItemChar),
|
||||
format_char(self.itemChar),
|
||||
format_char(self.altItemChar),
|
||||
self.checkMark,
|
||||
self.flags,
|
||||
self.title.get_id()
|
||||
|
4
utils.py
4
utils.py
@ -42,9 +42,11 @@ def format_string(bstring, quote=True):
|
||||
if quote: return '"' + s + '"'
|
||||
return s
|
||||
|
||||
# rez "char" is a string of length 1.
|
||||
# 'x' is character literal which is a number.
|
||||
def format_char(x):
|
||||
c = _map.get(x, chr(x))
|
||||
return "'" + c + "'"
|
||||
return '"' + c + '"'
|
||||
|
||||
def multi_format_string(bstring, indent=""):
|
||||
q = '"'
|
||||
|
Loading…
x
Reference in New Issue
Block a user