diff --git a/server.py b/server.py index 315766e..c6fc6ea 100644 --- a/server.py +++ b/server.py @@ -7,7 +7,6 @@ import base64 NULL_CHAR = chr(0) -last_c = None colors = { "Z": ["a", "a"], @@ -30,11 +29,7 @@ def release_keys(): def printchar(c): - print(c) - if last_c == '§': - print('changing color') - change_color(c) - elif c.islower(): + if c.islower(): write_report(NULL_CHAR*2+chr(4 + ord(c) - ord('a'))+NULL_CHAR*5) elif c.isupper(): write_report(chr(32)+NULL_CHAR+chr(4 + ord(c) - ord('A'))+NULL_CHAR*5) @@ -43,8 +38,8 @@ def printchar(c): elif c == ' ': write_report(NULL_CHAR*2+chr(44)+NULL_CHAR*5) elif c == '\n': - write_report(NULL_CHAR*2+chr(40)+NULL_CHAR*5) - elif c != '§': + write_report(NULL_CHAR*2+chr(40)+NULL_CHAR*5) + else: write_report(chr(32)+NULL_CHAR+chr(0x38)+NULL_CHAR*5) release_keys() @@ -59,13 +54,17 @@ def change_color(c: str): write_report(NULL_CHAR*2+chr(4 + ord(colors[c][1]) - ord('a'))+NULL_CHAR*5) else: write_report(chr(32)+NULL_CHAR+chr(0x38)+NULL_CHAR*5) + release_keys() def printstring(s): + last_c = '' for c in s: - printchar(c) + if last_c == '§': + change_color(c) + else: + printchar(c) last_c = c - print('last_c=' + str(last_c == '§')) def reset_color():