item#

Item is the basic building block of the terminal UI. It represents a single selectable item in the dropdown menu. User can move or scroll selector up and down to select an item, and then perform action.

class zelfred.item.Item(title: str, subtitle: ~typing.Optional[str] = None, uid: str = <factory>, arg: ~typing.Optional[str] = None, autocomplete: ~typing.Optional[str] = None, variables: ~typing.Dict[str, ~typing.Any] = <factory>)[source]#

Represent an item in the terminal UI. In the example below, the [x] Beautiful is better than ugly and subtitle 01 is one item.

(Query):
[x] Beautiful is better than ugly.
      subtitle 01
[ ] Explicit is better than implicit.
      subtitle 02
[ ] Simple is better than complex.
      subtitle 03
Parameters:
  • uid – item unique id. The UI use this to distinguish different items.

  • title – first line of the item. It has a checkbox in front of it to indicate whether it is selected.

  • subtitle – second line of the item.

  • arg – argument that will be passed to the action.

  • autocomplete – the text that will be filled in the input box when user hits TAB key.

  • variables – arbitrary dictionary object, it can be used in the action.

enter_handler(ui: UI)[source]#

This is the abstract method that will perform user defined action when user hits Enter on this item. Develop should inherit this class and override this method to perform user defined action.

Parameters:

ui – the UI object.

post_enter_handler(ui: UI)[source]#

This is the abstract method that will update the UI after taking user action.

Parameters:

ui – the UI object.

ctrl_a_handler(ui: UI)[source]#

This is the abstract method that will perform user defined action when user hits Ctrl + A on this item. Develop should inherit this class and override this method to perform user defined action.

Parameters:

ui – the UI object.

post_ctrl_a_handler(ui: UI)[source]#

This is the abstract method that will update the UI after taking user action.

Parameters:

ui – the UI object.

ctrl_w_handler(ui: UI)[source]#

This is the abstract method that will perform user defined action when user hits Ctrl + W on this item. Develop should inherit this class and override this method to perform user defined action.

Parameters:

ui – the UI object.

post_ctrl_w_handler(ui: UI)[source]#

This is the abstract method that will update the UI after taking user action.

Parameters:

ui – the UI object.

ctrl_u_handler(ui: UI)[source]#

This is the abstract method that will perform user defined action when user hits Ctrl + U on this item. Develop should inherit this class and override this method to perform user defined action.

Parameters:

ui – the UI object.

post_ctrl_u_handler(ui: UI)[source]#

This is the abstract method that will update the UI after taking user action.

Parameters:

ui – the UI object.

ctrl_p_handler(ui: UI)[source]#

This is the abstract method that will perform user defined action when user hits Ctrl + P on this item. Develop should inherit this class and override this method to perform user defined action.

Parameters:

ui – the UI object.

post_ctrl_p_handler(ui: UI)[source]#

This is the abstract method that will update the UI after taking user action.

Parameters:

ui – the UI object.