Anonymous avatar Anonymous committed eb393cc

FIX: swtich keys got distracted by keys repeated on higher layers of Neo.

Comments (0)

Files changed (2)

     'q'
     >>> get_key((1, 10, 0), layout=lay)
     'w'
+    >>> get_key((1, 1, 1), layout=lay)
+    'L'
+    >>> get_key((1, 3, 1), layout=lay)
+    'X'
+    >>> get_key((1, 5, 1), layout=lay)
+    'Q'
+    >>> get_key((1, 10, 1), layout=lay)
+    'W'
     >>> find_key("l", layout=lay) == (1, 1, 0)
     True
+    >>> find_key("L", layout=lay) == (1, 1, 1)
+    True
     >>> NEO_LAYOUT_lxwq == lay[:5]
     True
     >>> lay = switch_keys(["lx"], layout = NEO_LAYOUT)
     >>> lay = switch_keys(["ab"], layout=lay)
     >>> a == find_key("b", layout=lay)
     True
+    >>> dot = find_key(".", layout=NEO_LAYOUT)
+    >>> d = find_key("d", layout=NEO_LAYOUT)
+    >>> lay = switch_keys([".d"], layout=NEO_LAYOUT)
+    >>> d == find_key(".", layout=lay)
+    True
+    >>> dot == find_key("d", layout=lay)
+    True
     """
     lay = deepcopy(layout)
     from pprint import pprint
     #pprint(lay)
     for pair in keypairs:
-        try: 
             pos0 = find_key(pair[0], layout=lay)
             pos1 = find_key(pair[1], layout=lay)
+            if None in lay[5].values():
+                print(prev, pos0, pos1, pair)
+                exit()
+
             if pair[1].upper() == pair[1]: 
                 tmp0 = (pair[1], ) + tuple(lay[pos0[0]][pos0[1]][1:])
             else:
             lay[pos0[0]][pos0[1]] = tmp0
             lay[pos1[0]][pos1[1]] = tmp1
             update_letter_to_key_cache_multiple(pair+pair.upper(), layout=lay)
-        except:
-            pprint(lay)
-            print(pair, tmp0, tmp1)
-            exit()
+            prev = pair
+        #except:
+        #    pprint(lay)
+        #    print(prev, pair, pos0, pos1, tmp0, tmp1)
+        #    exit()
     
     return lay
 
     [(), (), (), (" ", " ", " ", "0", " ", " "), (), (), (), ()] # Reihe 4 mit Leertaste
 ]
 NEO_LAYOUT_lx = [
-    [("^"),("1"),("2"),("3"),("4"),("5"),("6"),("7"),("8"),("9"),("0"),("-"),("`"),("←")], # Zahlenreihe (0)
-    [("⇥"),("l"),("v"),("x"),("c"),("w"),("k"),("h"),("g"),("f"),("q"),("ß"),("´"),()], # Reihe 1
-    [("⇩"),("u"),("i"),("a"),("e"),("o"),("s"),("n"),("r"),("t"),("d"),("y"),("⇘"),("\n")], # Reihe 2
-    [("⇧"),(),("ü"),("ö"),("ä"),("p"),("z"),("b"),("m"),(","),("."),("j"),("⇗")],        # Reihe 3
-    [(), (), (), (" "), (), (), (), ()] # Reihe 4 mit Leertaste
+    [("^", "ˇ", "↻", "˙", "˞", "̣"),("1", "°", "¹", "ª", "₁", "¬"),("2", "§", "²", "º", "₂", "∨"),("3", "ℓ", "³", "№", "₃", "∧"),
+     ("4", "»", "›", "", "♀", "⊥"),("5", "«", "‹", "·", "♂", "∡"),("6", "$", "¢", "£", "⚥", "∥"),("7", "€", "¥", "¤", "ϰ", "→"),
+     ("8", "„", "‚", "⇥", "⟨", "∞"),("9", "“", "‘", " /", "⟩", "∝"),("0", "”", "’", "*", "₀", "∅"),("-", "—", "-", "‑", "­"),
+     ("`", "¸", "°", "¨", "", "¯"),("←")], # Zahlenreihe (0)
+
+    [("⇥"),("l", "L", "…", "⇞", "ξ", "Ξ"),("v", "V", "_", "⌫", "", "√"),("x", "X", "[", "⇡", "", "λ", "Λ"),
+     ("c", "C", "]", "Entf", "χ", "ℂ"),("w", "W", "^", "⇟", "ω", "Ω"),("k", "K", "!", "¡", "κ", "×"),("h", "H", "<", "7", "ψ", "Ψ"),
+     ("g", "G", ">", "8", "γ", "Γ"),("f", "F", "=", "9", "φ", "Φ"),("q", "Q", "&", "+", "ϕ", "ℚ"),("ß", "ẞ", "ſ", "−", "ς", "∘"),
+     ("´", "~", "/", "˝", "", "˘"),()], # Reihe 1
+
+    [("⇩"),("u", "U", "\\", "⇱", "", "⊂"),("i", "I", "/", "⇠", "ι", "∫"),("a", "A", "{",  "⇣", "α", "∀"),
+     ("e", "E", "}", "⇢", "ε", "∃"),("o", "O", "*", "⇲", "ο", "∈"),("s", "S", "?", "¿", "σ", "Σ"),("n", "N", "(", "4", "ν", "ℕ"),
+     ("r", "R", ")", "5", "ρ", "ℝ"),("t", "T", "-", "6", "τ", "∂"),("d", "D", ":", ",", "δ", "Δ"),("y", "Y", "@", ".", "υ", "∇"),
+     ("⇘"),("\n")], # Reihe 2
+
+    [("⇧"),(),("ü", "Ü", "\#", "", "", "∪"),("ö", "Ö", "$", "", "ϵ", "∩"),("ä", "Ä", "|", "⎀", "η", "ℵ"),
+     ("p", "P", "~", "\n", "π", "Π"),("z", "Z", "`", "↶", "ζ", "ℤ"),("b", "B", "+", ":", "β", "⇐"),("m", "M", "%", "1", "μ", "⇔"),
+     (",", "–", '"', "2", "ϱ", "⇒"),(".", "•", "'", "3", "ϑ", "↦"),("j", "J", ";", ";", "θ", "Θ"),("⇗")],        # Reihe 3
+
+    [(), (), (), (" ", " ", " ", "0", " ", " "), (), (), (), ()] # Reihe 4 mit Leertaste
 ]
-NEO_LAYOUT_lxwq = [ # 25% weniger Fingerwiederholungen als Neo, fast 50% weniger als Qwertz
-    [("^"),("1"),("2"),("3"),("4"),("5"),("6"),("7"),("8"),("9"),("0"),("-"),("`"),("←")], # Zahlenreihe (0)
-    [("⇥"),("l"),("v"),("x"),("c"),("q"),("k"),("h"),("g"),("f"),("w"),("ß"),("´"),()], # Reihe 1
-    [("⇩"),("u"),("i"),("a"),("e"),("o"),("s"),("n"),("r"),("t"),("d"),("y"),("⇘"),("\n")], # Reihe 2
-    [("⇧"),(),("ü"),("ö"),("ä"),("p"),("z"),("b"),("m"),(","),("."),("j"),("⇗")],        # Reihe 3
-    [(), (), (), (" "), (), (), (), ()] # Reihe 4 mit Leertaste
+NEO_LAYOUT_lxwq = [
+    [("^", "ˇ", "↻", "˙", "˞", "̣"),("1", "°", "¹", "ª", "₁", "¬"),("2", "§", "²", "º", "₂", "∨"),("3", "ℓ", "³", "№", "₃", "∧"),
+     ("4", "»", "›", "", "♀", "⊥"),("5", "«", "‹", "·", "♂", "∡"),("6", "$", "¢", "£", "⚥", "∥"),("7", "€", "¥", "¤", "ϰ", "→"),
+     ("8", "„", "‚", "⇥", "⟨", "∞"),("9", "“", "‘", " /", "⟩", "∝"),("0", "”", "’", "*", "₀", "∅"),("-", "—", "-", "‑", "­"),
+     ("`", "¸", "°", "¨", "", "¯"),("←")], # Zahlenreihe (0)
+
+    [("⇥"),("l", "L", "…", "⇞", "ξ", "Ξ"),("v", "V", "_", "⌫", "", "√"),("x", "X", "[", "⇡", "", "λ", "Λ"),
+     ("c", "C", "]", "Entf", "χ", "ℂ"),("q", "Q", "^", "⇟", "ω", "Ω"),("k", "K", "!", "¡", "κ", "×"),("h", "H", "<", "7", "ψ", "Ψ"),
+     ("g", "G", ">", "8", "γ", "Γ"),("f", "F", "=", "9", "φ", "Φ"),("w", "W", "&", "+", "ϕ", "ℚ"),("ß", "ẞ", "ſ", "−", "ς", "∘"),
+     ("´", "~", "/", "˝", "", "˘"),()], # Reihe 1
+
+    [("⇩"),("u", "U", "\\", "⇱", "", "⊂"),("i", "I", "/", "⇠", "ι", "∫"),("a", "A", "{",  "⇣", "α", "∀"),
+     ("e", "E", "}", "⇢", "ε", "∃"),("o", "O", "*", "⇲", "ο", "∈"),("s", "S", "?", "¿", "σ", "Σ"),("n", "N", "(", "4", "ν", "ℕ"),
+     ("r", "R", ")", "5", "ρ", "ℝ"),("t", "T", "-", "6", "τ", "∂"),("d", "D", ":", ",", "δ", "Δ"),("y", "Y", "@", ".", "υ", "∇"),
+     ("⇘"),("\n")], # Reihe 2
+
+    [("⇧"),(),("ü", "Ü", "\#", "", "", "∪"),("ö", "Ö", "$", "", "ϵ", "∩"),("ä", "Ä", "|", "⎀", "η", "ℵ"),
+     ("p", "P", "~", "\n", "π", "Π"),("z", "Z", "`", "↶", "ζ", "ℤ"),("b", "B", "+", ":", "β", "⇐"),("m", "M", "%", "1", "μ", "⇔"),
+     (",", "–", '"', "2", "ϱ", "⇒"),(".", "•", "'", "3", "ϑ", "↦"),("j", "J", ";", ";", "θ", "Θ"),("⇗")],        # Reihe 3
+
+    [(), (), (), (" ", " ", " ", "0", " ", " "), (), (), (), ()] # Reihe 4 mit Leertaste
 ]
 
 # TODO: Add higher layers (shift for the numbers, …)
                     # make sure that the keys on lower levels always win agains those on higher levels.
                     # TODO (maybe someday): update the scheme to allow for multiple positions ⇒ only take the lowest cost.
                     idx_rev = key_num - idx -1
-                    if layout[row][col][idx] == key: 
-                        pos = (row, col, idx)
+                    if layout[row][col][idx_rev] == key:
+                        if pos and pos[2] < idx_rev:
+                            continue
+                        pos = (row, col, idx_rev)
     LETTER_TO_KEY_CACHE[key] = pos
     return pos
 
     (2, 3, 1)
     >>> find_key("e", NEO_LAYOUT)
     (2, 4, 0)
+    >>> find_key(",", NEO_LAYOUT)
+    (3, 9, 0)
     """
     # check, if the layout already has a cache. If not, create it.
     # this approach reduces the time to find a key by about 50%.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.