Skip to content

Commit e51078e

Browse files
committed
Remove unused async_refresh_prompt and need_prompt_refresh methods
1 parent eda97d3 commit e51078e

File tree

4 files changed

+4
-30
lines changed

4 files changed

+4
-30
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ shell, and the option for a persistent bottom bar that can display realtime stat
2323
utilities
2424
- Async specific: `prompt-toolkit` starts its own `asyncio` event loop in every `cmd2`
2525
application
26-
- Removed `cmd2.Cmd.terminal_lock` as it is no longer required to support things like
27-
`cmd2.Cmd.async_alert`
26+
- Removed `cmd2.Cmd.terminal_lock` as it is no longer required to support things like
27+
`cmd2.Cmd.async_alert`
28+
- Removed `cmd2.Cmd.async_refresh_prompt` and `cmd2.Cmd.need_prompt_refresh` as they are no
29+
longer needed
2830
- Enhancements
2931
- New optional persistent **bottom toolbar** capable of displaying realtime status information,
3032
see the `bottom_toolbar` optional argument to the initializer for `cmd2.Cmd` and the

cmd2/cmd2.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5523,29 +5523,6 @@ def async_update_prompt(self, new_prompt: str) -> None: # pragma: no cover
55235523
"""
55245524
self.async_alert('', new_prompt)
55255525

5526-
def async_refresh_prompt(self) -> None: # pragma: no cover
5527-
"""Refresh the oncreen prompt to match self.prompt.
5528-
5529-
One case where the onscreen prompt and self.prompt can get out of sync is
5530-
when async_alert() is called while a user is in search mode (e.g. Ctrl-r).
5531-
To prevent overwriting prompt-toolkit's onscreen search prompt, self.prompt is updated
5532-
but prompt-toolkit's saved prompt isn't.
5533-
5534-
Therefore when a user aborts a search, the old prompt is still on screen until they
5535-
press Enter or this method is called. Call need_prompt_refresh() in an async print
5536-
thread to know when a refresh is needed.
5537-
5538-
:raises RuntimeError: if called from the main thread.
5539-
:raises RuntimeError: if main thread is not currently at the prompt.
5540-
"""
5541-
self.async_alert('')
5542-
5543-
def need_prompt_refresh(self) -> bool: # pragma: no cover
5544-
"""Check whether the onscreen prompt needs to be asynchronously refreshed to match self.prompt."""
5545-
# With prompt_toolkit, refresh is handled via invalidation.
5546-
# This method is kept for API compatibility.
5547-
return False
5548-
55495526
@staticmethod
55505527
def set_window_title(title: str) -> None: # pragma: no cover
55515528
"""Set the terminal window title.

docs/features/prompt.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ and greater all support these.
3636

3737
- [cmd2.Cmd.async_alert][]
3838
- [cmd2.Cmd.async_update_prompt][]
39-
- [cmd2.Cmd.async_refresh_prompt][]
40-
- [cmd2.Cmd.need_prompt_refresh][]
4139

4240
`cmd2` also provides a function to change the title of the terminal window. This feature requires
4341
the application be running in a terminal that supports VT100 control characters. Linux, Mac, and

examples/async_printing.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,6 @@ async def _alerter(self) -> None:
189189
self.prompt = new_prompt
190190
self.session.app.invalidate()
191191

192-
elif self.need_prompt_refresh():
193-
self.session.app.invalidate()
194-
195192
await asyncio.sleep(0.5)
196193
except asyncio.CancelledError:
197194
pass

0 commit comments

Comments
 (0)