Metadata-Version: 2.4
Name: listpicker
Version: 0.3.2
Summary: Interactive list selection and multiselect for POSIX terminals (non-curses)
Project-URL: Homepage, https://github.com/guns/python-listpicker
Project-URL: Repository, https://github.com/guns/python-listpicker.git
Author-email: Sung Pae <self@sungpae.com>
License: The MIT License (MIT)
        
        Copyright © 2024 Sung Pae <self@sungpae.com>
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to
        deal in the Software without restriction, including without limitation the
        rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
        sell copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in
        all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
        THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
        FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
        IN THE SOFTWARE.
License-File: LICENSE
Keywords: list selection,multiple select,multiselect
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: User Interfaces
Classifier: Topic :: Terminals
Requires-Python: >=3.10
Requires-Dist: regex
Provides-Extra: dev
Requires-Dist: types-regex; extra == 'dev'
Description-Content-Type: text/markdown

python-listpicker
=================

Interactive list selection for POSIX terminals.

```python
pip install listpicker
```

Python 3.10+

Features
--------

- Single and multiple selection from a sequence of strings
- Interactive substring filtering
- Paging for long lists
- Common navigation keybindings (vi, emacs, arrow keys, Home/End, etc)
- Direct terminal manipulation with CSI commands (i.e. no curses)
- Draw to main screen buffer without clearing the screen
- Proper truncation of long lines with SGR color sequences
- Redraw on terminal resize (SIGWINCH)
- Help menu and multiselect confirmation prompt
- Preselected options in multiselect prompts

Screenshots
-----------

![timezones](https://github.com/guns/python-listpicker/assets/55776/f7e6629b-77ba-4f99-a9f6-0de15485c2dd)
![helpmenu](https://github.com/guns/python-listpicker/assets/55776/78a966e7-4023-4d52-bfa9-87acac89b73e)
![filtering](https://github.com/guns/python-listpicker/assets/55776/ae01150c-cead-42f3-898e-2d631d3ba83a)
![multiselect](https://github.com/guns/python-listpicker/assets/55776/4888a62c-a94b-41c8-8113-07fee8649648)
![multiselect-confirmation](https://github.com/guns/python-listpicker/assets/55776/81cb6432-7791-4439-b2cf-0f90d7e67cfe)

Examples
--------

### Basic usage

```python
import listpicker

pizza_styles = ("Thin crust", "Stuffed crust", "Deep dish")
style = listpicker.pick("Choose pizza style:", pizza_styles)

# User can abort input, so handle the case where "pick()" returns "None"
if style is None:
    style = pizza_styles[0]

pizza_toppings = ("Pepperoni", "Sausage", "Mushroom", "Pineapple")
toppings = listpicker.pick_multiple("Choose toppings:", pizza_toppings)
```

### Typical usage with dictionary

```python
import dataclasses

import listpicker


@dataclasses.dataclass
class Book:
    isbn: str
    title: str
    authors: list[str]
    publication_year: int


books = [
    Book(
        "0201038013",
        "The Art of Computer Programming, Volume 1: Fundamental Algorithms",
        ["Knuth, Donald"],
        1968,
    ),
    Book(
        "0262010771",
        "Structure and Interpretation of Computer Programs",
        ["Harold Abelson", "Gerald Jay Sussman", "Julie Sussman"],
        1984,
    ),
    Book(
        "032163537X",
        "Elements of Programming",
        ["Stepanov, Alexander A.", "McJones, Paul"],
        2009,
    ),
]

options = {f"{b.title} ({b.publication_year})": b for b in books}
choice = listpicker.pick("Pick a book:", list(options.keys()))

# Pick a book:
#   (filter with f, submit with Enter, F1 for keybindings)
# > 1. The Art of Computer Programming, Volume 1: Fundamental Algorithms (1968)
#   2. Structure and Interpretation of Computer Programs (1984)
#   3. Elements of Programming (2009)

if choice:
    book = options[choice]
```
