summaryrefslogtreecommitdiff
path: root/src/decorators.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2013-08-01 20:17:12 +0200
committermathieui <mathieui@mathieui.net>2013-08-01 20:17:12 +0200
commitbb59771d9962dcd69c29b008031fd4ae9002915d (patch)
tree4ce52e3e5fc99837ecc97113de299d5e142c12cd /src/decorators.py
parent2744234d52016ae06f4c72193c5b1faebc57ddd1 (diff)
downloadpoezio-bb59771d9962dcd69c29b008031fd4ae9002915d.tar.gz
poezio-bb59771d9962dcd69c29b008031fd4ae9002915d.tar.bz2
poezio-bb59771d9962dcd69c29b008031fd4ae9002915d.tar.xz
poezio-bb59771d9962dcd69c29b008031fd4ae9002915d.zip
Fix #2049 (get the current completed argument)
A command argument can now be completed even if it isn’t the last one in the input. - Add a new method Input.new_completion Almost like the old auto_completion method, except taht it takes another argument: argument_position, which is the argument to be completed. - Methods using the old completion method still work - All completion methods in poezio now use the new one if necessary - Further details can be found in the docstring of new_completion
Diffstat (limited to 'src/decorators.py')
-rw-r--r--src/decorators.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/decorators.py b/src/decorators.py
index ab987701..3cb967b3 100644
--- a/src/decorators.py
+++ b/src/decorators.py
@@ -1,7 +1,9 @@
"""
-Module containing the decorators
+Module containing various decorators
"""
+from functools import partial
+
class RefreshWrapper(object):
def __init__(self):
self.core = None
@@ -40,5 +42,14 @@ class RefreshWrapper(object):
return ret
return wrap
+def __completion(quoted, func):
+ class Completion(object):
+ quoted = quoted
+ def __new__(cls, *args, **kwargs):
+ return func(*args, **kwargs)
+ return Completion
+
+completion_quotes = partial(__completion, True)
+completion_raw = partial(__completion, False)
refresh_wrapper = RefreshWrapper()