Anonymous avatar Anonymous committed 840fe97

get_all_keys_in_layout can now return all positions up to a max_layer.

Comments (0)

Files changed (1)

     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: 
     return keys
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
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.