diff options
author | martin_r <martin_r@b9310e46-f624-0410-8ea1-cfbb3a30dc96> | 2009-01-30 11:59:37 +0000 |
---|---|---|
committer | martin_r <martin_r@b9310e46-f624-0410-8ea1-cfbb3a30dc96> | 2009-01-30 11:59:37 +0000 |
commit | 774d57a68f53ab23a2f04ceb471c3e90369699ee (patch) | |
tree | 830e3b320fa91b5f3416c230b45a462b9b400cd9 /yaml | |
parent | 20d432c383a938baca002e6a84f0f6a3ec20b4fa (diff) | |
download | neo-layout-774d57a68f53ab23a2f04ceb471c3e90369699ee.tar.gz neo-layout-774d57a68f53ab23a2f04ceb471c3e90369699ee.tar.bz2 neo-layout-774d57a68f53ab23a2f04ceb471c3e90369699ee.zip |
Bugfix: Ebenen werden jetzt richtig sortiert
Dokumentation: Bilder aufgenommen
git-svn-id: https://svn.neo-layout.org@1580 b9310e46-f624-0410-8ea1-cfbb3a30dc96
Diffstat (limited to 'yaml')
-rw-r--r-- | yaml/parse_neo.py | 62 | ||||
-rw-r--r-- | yaml/readme.txt | 13 |
2 files changed, 42 insertions, 33 deletions
diff --git a/yaml/parse_neo.py b/yaml/parse_neo.py index 264a4e9..01f8854 100644 --- a/yaml/parse_neo.py +++ b/yaml/parse_neo.py @@ -49,7 +49,8 @@ options = OptionParser(usage = 'example: %prog -ti -astest', description = 'YAML make_option('-W', '--key-level-delimiter-width', type = 'int', metavar = 'int', default = 1, help = 'default = %default'), make_option('-f', '--key-level-delimiter-filler', metavar = 'char',default = " ", help = 'default = %default'), make_option('-D', '--key-level-delimiter', metavar = 'char'), - make_option('-l', '--key-levels-per-line', type = 'int', metavar = 'int', default = 3, help = 'default = %default') + make_option('-l', '--key-levels-per-line', type = 'int', metavar = 'int', default = 3, help = 'default = %default'), + make_option('-L', '--no-level-disorder',dest = 'level_disorder', action = 'store_false', default = True, help = 'Level 4 and 5 are not swapped') ]).parse_args()[0] if options.destination_file == None: options.destination_file = options.source_file.rsplit(file_name_standard_extension)[0] @@ -79,39 +80,46 @@ def parse_key_panel(key_panel, key_width = 5): ''' return_model = []; return_view = []; key_row = []; key_row_index = 0 # initialization - for row in [row[:key_panel.index(box_drawings[3])] for row in key_panel.splitlines()[1:]]: # omit beginning and ending box drawings - if row[0] in (box_drawings[12], box_drawings[14]): # if row begins with ├ or │, - return_model.append([]); return_view.append([]) # create key row list - key_lines = [] + for row in [row[:key_panel.index(box_drawings[3])] for row in key_panel.splitlines()[1:]]: # omit the first line and from closing box drawings + if row[0] not in (box_drawings[12], box_drawings[14]): # if row begins not with “├” or “└”: + key_lines = []; key_row.append(row) # push line (sic) + else: + return_model.append([]); return_view.append([]) # create key row lists for key_line_index, key_line in enumerate(key_row[:: - 1]): # reverse lines - for key_index, key in enumerate(key_line[1:].split(box_drawings[10])): # split key line into keys + for key_index, key in enumerate(key_line[1:].split(box_drawings[10])): # omit beginning key delimiter and split key line into key lines: if key_line_index == 0: # if bottom line, - return_model[key_row_index].append([]); key_lines.append([]); return_view[key_row_index].append([]) # create key list - if len(key) == key_width: # if default key, parse line levels: - if options.key_level_width == 1 and key_width == 7: # if Neo 2 keypad key: - if key[1] == key[5] == options.key_level_delimiter: - key_lines[key_index].extend([key[0], key[2:5], key[6]]) - elif key[::2] == options.key_level_delimiter * 4: - key_lines[key_index].extend(key[1::2]) + if key_width == 5 or key_width == 7: + key_lines.append([]) + return_model[key_row_index].append([]); return_view[key_row_index].append([]) # create key lists + if len(key) == key_width: # if standard key, parse line levels: + if key_width == options.key_level_width * options.key_levels_per_line + (options.key_levels_per_line - 1) * options.key_level_delimiter_width and key[1::options.key_level_width + options.key_level_delimiter_width] == options.key_level_delimiter * (options.key_levels_per_line - 1): # else if standard key: + key_lines[key_index].append([key[key_level_start:key_level_start + options.key_level_width] for key_level_start in range(0, len(key), options.key_level_width + options.key_level_delimiter_width)]) + elif key_width == options.key_level_width: # else if standard miniature key: + return_model[key_row_index][key_index].append(key) + elif options.key_level_width == 1 and key_width == 7: # if Neo 2 keypad key: + if key[1] == key[5] == options.key_level_delimiter: # if long middle line level: + key_lines[key_index].append([key[0], key[2:5], key[6]]) + elif key[::2] == options.key_level_delimiter * 4: # else if spaced levels: + key_lines[key_index].append(list(key[1::2])) else: return_view[key_row_index][key_index].append(key) - elif key_width == options.key_level_width * options.key_levels_per_line + (options.key_levels_per_line - 1) * options.key_level_delimiter_width: - key_lines[key_index].extend([key[:options.key_level_width] for key in key[:key_width:options.key_level_width + options.key_level_delimiter_width]]) - elif key_width == options.key_level_width: - key_lines[key_index].append(key) - else: + else: # else non-standard key: if options.key_level_width == 1 and key_width == 7 and len(key) == 15: # if Neo 2 keypad key: - key_lines[key_index].extend([key[2], key[6:9], key[12]]) - else: + key_lines[key_index].append([key[2], key[6:9], key[12]]) + else: # else special key: return_view[key_row_index][key_index].append(key) - if key_lines != []: - for key_level_index, level in enumerate(key_lines[0]): - for key_line_index, line_index in enumerate(key_lines): - return_model[key_row_index][key_index].append(key_lines[key_line_index][key_level_index]) + if key_lines != []: + for key_index, key in enumerate(key_lines): #sort key levels: + if key_lines[key_index] != []: + for key_level_index, level in enumerate(key_lines[key_index][0]): + for key_line_index, line_index in enumerate(key_lines[key_index]): + if len(key_lines[key_index]) != 0: + return_model[key_row_index][key_index].append(key_lines[key_index][key_line_index][key_level_index]) + if options.level_disorder and len(return_model[key_row_index][key_index]) == 6: + return_model[key_row_index][key_index].insert(3, return_model[key_row_index][key_index].pop(4)) key_row_index += 1; key_row = [] - else: - key_row.append(row) return return_model, return_view + def compare_model(model, miniature_model): ''' @@ -140,7 +148,7 @@ if options.without_legend == False: model = [parse_key_panel(key_panels[9]), parse_key_panel(key_panels[20], 7)] miniature_models = [] for miniature_models_index in range(6): - miniature_models.append([parse_key_panel(key_panels[10 + miniature_models_index], 1), parse_key_panel(key_panels[21 + miniature_models_index], 7)]) + miniature_models.append([parse_key_panel(key_panels[10 + miniature_models_index], 1), parse_key_panel(key_panels[21 + miniature_models_index], 3)]) view = compare_model(model, miniature_models) # complete views via comparing key widths model = [model[0] for model in model] # strip views diff --git a/yaml/readme.txt b/yaml/readme.txt index 9c31e47..d2cded2 100644 --- a/yaml/readme.txt +++ b/yaml/readme.txt @@ -38,15 +38,16 @@ Zur Zeit entwickele ich einen Parser für die Referenz. Danach möchte ich ein Skript für die Erstellung der neo20.txt aus der maschinenlesbaren Referenz schreiben. Dann soll ein Skript zur Umwandlung des Models in xkbmap, xmodmap, ahk und kbdneo folgen, unter berücksichtigung der verwendeten Tastatur (Qwertz, -Qwerty, Plum, Kbdneo). +Qwerty, Plum, Kbdneo). Danach nehme ich die Erzeugung der svgs und odss in +Angriff. Abriss: neo_import.py -neo_parse.py -neo_edit.py -neo_make.py -ahk_make.py -ahk_parse.py +parse_neo.py +edit_neo.py +make_neo.py +make_ahk.py +parse_ahk.py hex_parse.py kbd_parse.py kbd_make.py |