forked from bpython/bpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevents.py
More file actions
49 lines (30 loc) · 1.33 KB
/
events.py
File metadata and controls
49 lines (30 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""Non-keyboard events used in bpython curtsies REPL"""
import time
from collections.abc import Sequence
import curtsies.events
class ReloadEvent(curtsies.events.Event):
"""Request to rerun REPL session ASAP because imported modules changed"""
def __init__(self, files_modified: Sequence[str] = ("?",)) -> None:
self.files_modified = files_modified
def __repr__(self) -> str:
return "<ReloadEvent from {}>".format(" & ".join(self.files_modified))
class RefreshRequestEvent(curtsies.events.Event):
"""Request to refresh REPL display ASAP"""
def __repr__(self) -> str:
return "<RefreshRequestEvent for now>"
class ScheduledRefreshRequestEvent(curtsies.events.ScheduledEvent):
"""Request to refresh the REPL display at some point in the future
Used to schedule the disappearance of status bar message that only shows
for a few seconds"""
def __init__(self, when: float) -> None:
super().__init__(when)
def __repr__(self) -> str:
return "<RefreshRequestEvent for {} seconds from now>".format(
self.when - time.time()
)
class RunStartupFileEvent(curtsies.events.Event):
"""Request to run the startup file."""
class UndoEvent(curtsies.events.Event):
"""Request to undo."""
def __init__(self, n: int = 1) -> None:
self.n = n