840fe976ce80 — Arne Babenhauserheide 14 years ago
get_all_keys_in_layout can now return all positions up to a max_layer.
1 files changed, 4 insertions(+), 2 deletions(-)

M layout_base.py
M layout_base.py +4 -2
@@ 349,16 349,18 @@ def get_all_positions_in_layout(layout):
     return positions
 
 
-def get_all_keys_in_layout(layout):
+def get_all_keys_in_layout(layout, max_layer=0):
     """Get all keys which are in the layout. Sorted the same way as the positions from get_all_positions_in_layout(). 
 
     >>> get_all_keys_in_layout(TEST_LAYOUT)
+    ['^', '⇥', 'u', '\\n', ' ', '⇙']
+    >>> get_all_keys_in_layout(TEST_LAYOUT, max_layer=5)
     ['^', 'ˇ', '↻', '⇥', 'u', 'U', '\\\\', '⇱', '⊂', '\\n', ' ', '⇙']
     """
     keys = []
     for line in layout[:5]:
         for key in line:
-            for letter in key:
+            for letter in key[:max_layer+1]:
                 if letter: 
                     keys.append(letter)
     return keys