From bb59771d9962dcd69c29b008031fd4ae9002915d Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 1 Aug 2013 20:17:12 +0200 Subject: Fix #2049 (get the current completed argument) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- doc/source/dev/overview.rst | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'doc/source/dev') diff --git a/doc/source/dev/overview.rst b/doc/source/dev/overview.rst index 452938e6..f0eef18a 100644 --- a/doc/source/dev/overview.rst +++ b/doc/source/dev/overview.rst @@ -91,24 +91,27 @@ Completions are a bit tricky, but it’s easy once you get used to it: They take an **Input** (a _windows_ class) as a parameter, named the_input everywhere in the sources. To effectively have a completion, you have to call -**the_input.auto_completion()** at the end of the function. +**the_input.auto_completion()** or **the_input.new_completion()** at the end +of the function. .. code-block:: python class Input(Win): # … - def auto_completion(completion_list, after='', quote=True): + def auto_completion(completion_list, after='', quotify=True): + # … + + def new_completion(completion_list, argument_position, after='', quotify=True): # … Set the input to iterate over _completion_list_ when the user hits tab, insert **after** after the completed item, and surround the item with double quotes or not. -There is no method to find the current argument in the input (although the -feature is planned), so you have to assume the current argument is the last, -and guess it by splitting the string an checking for end-space. +To find the current completed argument, use the **input.get_argument_position()** +method. You can then use new_completion() to select the argument to be completed. You can look for examples in the sources, all the possible cases are covered (single-argument, complex arguments with spaces, several arguments, -etc…) +etc…). -- cgit v1.2.3