mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-16 03:38:03 +01:00
Add --breakpoints option to asciinema play to opt-in for pausing on breakpoints
This commit is contained in:
@@ -196,6 +196,13 @@ For help on a specific command run:
|
||||
action="store_true",
|
||||
default=False,
|
||||
)
|
||||
parser_play.add_argument(
|
||||
"-b",
|
||||
"--breakpoints",
|
||||
help="automatically pause on breakpoints",
|
||||
action="store_true",
|
||||
default=False,
|
||||
)
|
||||
parser_play.add_argument(
|
||||
"--out-fmt",
|
||||
help="select output format",
|
||||
|
||||
@@ -21,6 +21,7 @@ class PlayCommand(Command):
|
||||
self.loop = args.loop
|
||||
self.out_fmt = args.out_fmt
|
||||
self.stream = args.stream
|
||||
self.breakpoints = args.breakpoints
|
||||
self.player = player if player is not None else Player()
|
||||
self.key_bindings = {
|
||||
"pause": config.play_pause_key,
|
||||
@@ -46,6 +47,7 @@ class PlayCommand(Command):
|
||||
key_bindings=self.key_bindings,
|
||||
out_fmt=self.out_fmt,
|
||||
stream=self.stream,
|
||||
pause_on_breakpoints=self.breakpoints,
|
||||
)
|
||||
|
||||
except asciicast.LoadError as e:
|
||||
|
||||
@@ -56,6 +56,7 @@ class Player: # pylint: disable=too-few-public-methods
|
||||
key_bindings: Optional[Dict[str, Any]] = None,
|
||||
out_fmt: str = "raw",
|
||||
stream: Optional[str] = None,
|
||||
pause_on_breakpoints: bool = False,
|
||||
) -> None:
|
||||
if key_bindings is None:
|
||||
key_bindings = {}
|
||||
@@ -74,6 +75,7 @@ class Player: # pylint: disable=too-few-public-methods
|
||||
stdin,
|
||||
key_bindings,
|
||||
output,
|
||||
pause_on_breakpoints,
|
||||
)
|
||||
except IOError:
|
||||
self._play(
|
||||
@@ -83,6 +85,7 @@ class Player: # pylint: disable=too-few-public-methods
|
||||
None,
|
||||
key_bindings,
|
||||
output,
|
||||
False,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
@@ -93,6 +96,7 @@ class Player: # pylint: disable=too-few-public-methods
|
||||
stdin: Optional[TextIO],
|
||||
key_bindings: Dict[str, Any],
|
||||
output: Output,
|
||||
pause_on_breakpoints: bool,
|
||||
) -> None:
|
||||
idle_time_limit = idle_time_limit or asciicast.idle_time_limit
|
||||
pause_key = key_bindings.get("pause")
|
||||
@@ -152,5 +156,5 @@ class Player: # pylint: disable=too-few-public-methods
|
||||
|
||||
output.write(time_, event_type, text)
|
||||
|
||||
if event_type == "b":
|
||||
if event_type == "b" and pause_on_breakpoints:
|
||||
pause_elapsed_time = time_
|
||||
|
||||
Reference in New Issue
Block a user