diff --git a/README.md b/README.md
index bfb29a7..cdf47f3 100644
--- a/README.md
+++ b/README.md
@@ -88,6 +88,11 @@ The layout exposes the following commands:
previous() |
Focus previous window. |
+
+ recent() |
+ Focus most recently focused window.
+(Toggles between the two latest active windows.) |
+
left() |
Focus window to the left. |
@@ -156,9 +161,8 @@ window.
size(val) |
- Change size of current window.
-
-(It's recommended to use `width()`/`height()` instead.) |
+ Change size of current window.
+(It's recommended to use width() /height() instead.) |
width(val) |
@@ -174,9 +178,8 @@ window.
grow(amt) |
- Grow size of current window.
-
-(It's recommended to use `grow_width()`/`grow_height()` instead.) |
+ Grow size of current window.
+(It's recommended to use grow_width() /grow_height() instead.) |
grow_width(amt) |
diff --git a/plasma/layout.py b/plasma/layout.py
index d80b577..b36744e 100644
--- a/plasma/layout.py
+++ b/plasma/layout.py
@@ -128,6 +128,15 @@ def cmd_previous(self):
"""Focus previous window."""
self.focus_node(self.focused_node.prev_leaf)
+ def cmd_recent(self):
+ """Focus most recently focused window.
+
+ (Toggles between the two latest active windows.)
+ """
+ nodes = [n for n in self.root.all_leafs if n is not self.focused_node]
+ most_recent = max(nodes, key=lambda n: n.last_accessed)
+ self.focus_node(most_recent)
+
def cmd_left(self):
"""Focus window to the left."""
self.focus_node(self.focused_node.close_left)
diff --git a/setup.py b/setup.py
index 5aae281..9618e8c 100644
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
setup(
name='qtile-plasma',
packages=['plasma'],
- version='1.2.0',
+ version='1.3.0',
description='An advanced, flexible layout for Qtile',
author='numirias',
author_email='numirias@users.noreply.github.com',
diff --git a/tests/test_layout.py b/tests/test_layout.py
index 749f59f..86839f8 100644
--- a/tests/test_layout.py
+++ b/tests/test_layout.py
@@ -202,3 +202,18 @@ def test_split_mode(self, qtile):
qtile.c.layout.mode_vertical_split()
qtile.testWindow('f')
assert qtile.c.window.info()['height'] == 100 - 2
+
+ @plasma_config
+ def test_recent(self, qtile):
+ qtile.testWindow('a')
+ qtile.testWindow('b')
+ qtile.testWindow('c')
+ assertFocused(qtile, 'c')
+ qtile.c.layout.recent()
+ assertFocused(qtile, 'b')
+ qtile.c.layout.recent()
+ assertFocused(qtile, 'c')
+ qtile.c.layout.next()
+ assertFocused(qtile, 'a')
+ qtile.c.layout.recent()
+ assertFocused(qtile, 'c')
diff --git a/tools/make_readme.py b/tools/make_readme.py
index 54437a7..9923e09 100644
--- a/tools/make_readme.py
+++ b/tools/make_readme.py
@@ -1,6 +1,14 @@
-"""Insert documentation for layout commands into readme file."""
+"""Update documentation in readme.
+
+This tool extracts the documentation (docstrings) for all layout commands
+(startings with "cmd_") from the layout class and inserts them as a table into
+the readme file, in the marked area.
+
+It should be run with every API change.
+"""
import ast
+import re
readme_path = 'README.md'
@@ -18,12 +26,15 @@ def row(text):
def col(text):
return ' %s | \n' % text
-def function(name, args):
- return '%s(%s)' % (name, ', '.join(args))
-
def code(text):
return '%s
' % text
+def function_name(name, args):
+ return '%s(%s)' % (name, ', '.join(args))
+
+def function_desc(text):
+ return re.sub('`([^`]*)`', code('\\1'), text.replace('\n\n', '
\n'))
+
def main():
with open(readme_path) as f:
text = f.read()
@@ -42,7 +53,10 @@ def main():
name = node.name[4:]
args = [a.arg for a in node.args.args[1:]]
docstring = ast.get_docstring(node)
- rows += row(col(code(function(name, args))) + col(docstring))
+ rows += row(
+ col(code(function_name(name, args))) +
+ col(function_desc(docstring))
+ )
text_table = table(rows)
with open(readme_path, 'w') as f: