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