Skip to content

Commit

Permalink
Allow clear screen
Browse files Browse the repository at this point in the history
  • Loading branch information
aisk committed Apr 25, 2024
1 parent 359ac33 commit e18ede3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/pick/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Picker(Generic[OPTION_T]):
index: int = field(init=False, default=0)
screen: Optional["curses._CursesWindow"] = None
position: Position = Position(0, 0)
clear_screen: bool = True

def __post_init__(self) -> None:
if len(self.options) == 0:
Expand Down Expand Up @@ -136,6 +137,9 @@ def get_description_lines(self, description: str, length: int) -> List[str]:

def draw(self, screen: "curses._CursesWindow") -> None:
"""draw the curses ui on the screen, handle scroll if needed"""
if self.clear_screen:
screen.clear()

y, x = self.position # start point

max_y, max_x = screen.getmaxyx()
Expand Down Expand Up @@ -226,7 +230,8 @@ def pick(
multiselect: bool = False,
min_selection_count: int = 0,
screen: Optional["curses._CursesWindow"] = None,
position: Position = Position(0, 0)
position: Position = Position(0, 0),
clear_screen = True,
):
picker: Picker = Picker(
options,
Expand All @@ -237,5 +242,6 @@ def pick(
min_selection_count,
screen,
position,
clear_screen,
)
return picker.start()

0 comments on commit e18ede3

Please sign in to comment.