Cleanup generator code to handle \n in messages
This commit is contained in:
@@ -96,6 +96,8 @@ def getConstants():
|
|||||||
consants.append(('SymbolCellCount', 'S'))
|
consants.append(('SymbolCellCount', 'S'))
|
||||||
consants.append(('SymbolVersionNumber', 'V2.06'))
|
consants.append(('SymbolVersionNumber', 'V2.06'))
|
||||||
return consants
|
return consants
|
||||||
|
|
||||||
|
|
||||||
def getTipModelEnumTS80():
|
def getTipModelEnumTS80():
|
||||||
constants = []
|
constants = []
|
||||||
constants.append("B02")
|
constants.append("B02")
|
||||||
@@ -104,6 +106,7 @@ def getTipModelEnumTS80():
|
|||||||
constants.append("User") # User
|
constants.append("User") # User
|
||||||
return constants
|
return constants
|
||||||
|
|
||||||
|
|
||||||
def getTipModelEnumTS100():
|
def getTipModelEnumTS100():
|
||||||
constants = []
|
constants = []
|
||||||
constants.append("B02")
|
constants.append("B02")
|
||||||
@@ -116,6 +119,7 @@ def getTipModelEnumTS100():
|
|||||||
constants.append("User")
|
constants.append("User")
|
||||||
return constants
|
return constants
|
||||||
|
|
||||||
|
|
||||||
def getDebugMenu():
|
def getDebugMenu():
|
||||||
constants = []
|
constants = []
|
||||||
constants.append(datetime.today().strftime('%d-%m-%y'))
|
constants.append(datetime.today().strftime('%d-%m-%y'))
|
||||||
@@ -198,12 +202,11 @@ def getLetterCounts(defs, lang):
|
|||||||
return symbolCounts
|
return symbolCounts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getFontMapAndTable(textList):
|
def getFontMapAndTable(textList):
|
||||||
# the text list is sorted
|
# the text list is sorted
|
||||||
# allocate out these in their order as number codes
|
# allocate out these in their order as number codes
|
||||||
symbolMap = {}
|
symbolMap = {}
|
||||||
symbolMap['\n'] = '\\x01'
|
symbolMap['\n'] = '\\x01' # Force insert the newline char
|
||||||
index = 2 # start at 2, as 0= null terminator,1 = new line
|
index = 2 # start at 2, as 0= null terminator,1 = new line
|
||||||
forcedFirstSymbols = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
|
forcedFirstSymbols = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
|
||||||
# enforce numbers are first
|
# enforce numbers are first
|
||||||
@@ -229,12 +232,14 @@ def getFontMapAndTable(textList):
|
|||||||
print('Missing Large font element for {}'.format(sym))
|
print('Missing Large font element for {}'.format(sym))
|
||||||
exit(1)
|
exit(1)
|
||||||
fontLine = fontTable[sym]
|
fontLine = fontTable[sym]
|
||||||
fontTableStrings.append(fontLine + "//{} -> {}".format(symbolMap[sym],sym))
|
fontTableStrings.append(
|
||||||
|
fontLine + "//{} -> {}".format(symbolMap[sym], sym))
|
||||||
if sym not in fontSmallTable:
|
if sym not in fontSmallTable:
|
||||||
print('Missing Small font element for {}'.format(sym))
|
print('Missing Small font element for {}'.format(sym))
|
||||||
exit(1)
|
exit(1)
|
||||||
fontLine = fontSmallTable[sym]
|
fontLine = fontSmallTable[sym]
|
||||||
fontSmallTableStrings.append(fontLine + "//{} -> {}".format(symbolMap[sym],sym))
|
fontSmallTableStrings.append(
|
||||||
|
fontLine + "//{} -> {}".format(symbolMap[sym], sym))
|
||||||
|
|
||||||
for sym in textList:
|
for sym in textList:
|
||||||
if sym not in fontTable:
|
if sym not in fontTable:
|
||||||
@@ -242,12 +247,14 @@ def getFontMapAndTable(textList):
|
|||||||
exit(1)
|
exit(1)
|
||||||
if sym not in forcedFirstSymbols:
|
if sym not in forcedFirstSymbols:
|
||||||
fontLine = fontTable[sym]
|
fontLine = fontTable[sym]
|
||||||
fontTableStrings.append(fontLine + "//{} -> {}".format(symbolMap[sym],sym))
|
fontTableStrings.append(
|
||||||
|
fontLine + "//{} -> {}".format(symbolMap[sym], sym))
|
||||||
if sym not in fontSmallTable:
|
if sym not in fontSmallTable:
|
||||||
print('Missing Small font element for {}'.format(sym))
|
print('Missing Small font element for {}'.format(sym))
|
||||||
exit(1)
|
exit(1)
|
||||||
fontLine = fontSmallTable[sym]
|
fontLine = fontSmallTable[sym]
|
||||||
fontSmallTableStrings.append(fontLine + "//{} -> {}".format(symbolMap[sym],sym))
|
fontSmallTableStrings.append(
|
||||||
|
fontLine + "//{} -> {}".format(symbolMap[sym], sym))
|
||||||
outputTable = "const uint8_t USER_FONT_12[] = {" + to_unicode("\n")
|
outputTable = "const uint8_t USER_FONT_12[] = {" + to_unicode("\n")
|
||||||
for line in fontTableStrings:
|
for line in fontTableStrings:
|
||||||
# join font table int one large string
|
# join font table int one large string
|
||||||
@@ -290,7 +297,6 @@ def writeLanguage(languageCode, defs, f):
|
|||||||
|
|
||||||
f.write(to_unicode("// ---- " + langName + " ----\n\n"))
|
f.write(to_unicode("// ---- " + langName + " ----\n\n"))
|
||||||
|
|
||||||
|
|
||||||
# ----- Writing SettingsDescriptions
|
# ----- Writing SettingsDescriptions
|
||||||
obj = lang['menuOptions']
|
obj = lang['menuOptions']
|
||||||
f.write(to_unicode("const char* SettingsDescriptions[] = {\n"))
|
f.write(to_unicode("const char* SettingsDescriptions[] = {\n"))
|
||||||
@@ -316,14 +322,15 @@ def writeLanguage(languageCode, defs, f):
|
|||||||
|
|
||||||
for mod in defs['messages']:
|
for mod in defs['messages']:
|
||||||
eid = mod['id']
|
eid = mod['id']
|
||||||
if eid not in obj:
|
sourceText = ""
|
||||||
|
if 'default' in mod:
|
||||||
|
sourceText = (mod['default'])
|
||||||
|
if eid in obj:
|
||||||
|
sourceText = (obj[eid])
|
||||||
|
translatedText = convStr(symbolConversionTable, sourceText)
|
||||||
f.write(
|
f.write(
|
||||||
to_unicode("const char* " + eid + " = \"" +
|
to_unicode("const char* " + eid + " = \"" +
|
||||||
convStr(symbolConversionTable, (mod['default'])) + "\";"+ "//{} \n".format(mod['default'])))
|
translatedText + "\";" + "//{} \n".format(sourceText.replace('\n', '_'))))
|
||||||
else:
|
|
||||||
f.write(
|
|
||||||
to_unicode("const char* " + eid + " = \"" +
|
|
||||||
convStr(symbolConversionTable, (obj[eid])) + "\";"+ "//{} \n".format(obj[eid])))
|
|
||||||
|
|
||||||
f.write(to_unicode("\n"))
|
f.write(to_unicode("\n"))
|
||||||
|
|
||||||
@@ -352,10 +359,12 @@ def writeLanguage(languageCode, defs, f):
|
|||||||
f.write(to_unicode("const char* TipModelStrings[] = {\n"))
|
f.write(to_unicode("const char* TipModelStrings[] = {\n"))
|
||||||
f.write(to_unicode("#ifdef MODEL_TS100\n"))
|
f.write(to_unicode("#ifdef MODEL_TS100\n"))
|
||||||
for c in getTipModelEnumTS100():
|
for c in getTipModelEnumTS100():
|
||||||
f.write(to_unicode("\t \"" + convStr(symbolConversionTable, c) + "\","+ "//{} \n".format(c)))
|
f.write(to_unicode("\t \"" + convStr(symbolConversionTable,
|
||||||
|
c) + "\"," + "//{} \n".format(c)))
|
||||||
f.write(to_unicode("#else\n"))
|
f.write(to_unicode("#else\n"))
|
||||||
for c in getTipModelEnumTS80():
|
for c in getTipModelEnumTS80():
|
||||||
f.write(to_unicode("\t \"" + convStr(symbolConversionTable, c) + "\","+ "//{} \n".format(c)))
|
f.write(to_unicode("\t \"" + convStr(symbolConversionTable,
|
||||||
|
c) + "\"," + "//{} \n".format(c)))
|
||||||
f.write(to_unicode("#endif\n"))
|
f.write(to_unicode("#endif\n"))
|
||||||
|
|
||||||
f.write(to_unicode("};\n\n"))
|
f.write(to_unicode("};\n\n"))
|
||||||
@@ -364,7 +373,8 @@ def writeLanguage(languageCode, defs, f):
|
|||||||
f.write(to_unicode("const char* DebugMenu[] = {\n"))
|
f.write(to_unicode("const char* DebugMenu[] = {\n"))
|
||||||
|
|
||||||
for c in getDebugMenu():
|
for c in getDebugMenu():
|
||||||
f.write(to_unicode("\t \"" + convStr(symbolConversionTable, c) + "\","+ "//{} \n".format(c)))
|
f.write(to_unicode("\t \"" + convStr(symbolConversionTable,
|
||||||
|
c) + "\"," + "//{} \n".format(c)))
|
||||||
f.write(to_unicode("};\n\n"))
|
f.write(to_unicode("};\n\n"))
|
||||||
|
|
||||||
# ----- Menu Options
|
# ----- Menu Options
|
||||||
|
|||||||
Reference in New Issue
Block a user