MCPcopy Index your code
hub / github.com/bpython/bpython / StatusBar

Class StatusBar

bpython/curtsiesfrontend/interaction.py:11–174  ·  view source on GitHub ↗

StatusBar and Interaction for Repl Passing of control back and forth between calls that use interact api (notify, confirm, file_prompt) like bpython.Repl.write2file and events on the main thread happens via those calls and self.wait_for_request_or_notify. Calling one of these t

Source from the content-addressed store, hash-verified

9
10
11class StatusBar(Interaction):
12 """StatusBar and Interaction for Repl
13
14 Passing of control back and forth between calls that use interact api
15 (notify, confirm, file_prompt) like bpython.Repl.write2file and events on
16 the main thread happens via those calls and
17 self.wait_for_request_or_notify.
18
19 Calling one of these three is required for the main thread to regain
20 control!
21
22 This is probably a terrible idea, and better would be rewriting this
23 functionality in a evented or callback style, but trying to integrate
24 bpython.Repl code.
25 """
26
27 def __init__(
28 self,
29 config,
30 permanent_text="",
31 request_refresh=lambda: None,
32 schedule_refresh=lambda when: None,
33 ):
34 self._current_line = ""
35 self.cursor_offset_in_line = 0
36 self.in_prompt = False
37 self.in_confirm = False
38 self.waiting_for_refresh = False
39 self.prompt = ""
40 self._message = ""
41 self.message_start_time = time.time()
42 self.message_time = 3.0
43 self.permanent_stack = []
44 if permanent_text:
45 self.permanent_stack.append(permanent_text)
46 self.main_context = greenlet.getcurrent()
47 self.request_context = None
48 self.request_refresh = request_refresh
49 self.schedule_refresh = schedule_refresh
50
51 super().__init__(config)
52
53 def push_permanent_message(self, msg):
54 self._message = ""
55 self.permanent_stack.append(msg)
56
57 def pop_permanent_message(self, msg):
58 if msg in self.permanent_stack:
59 self.permanent_stack.remove(msg)
60 else:
61 raise ValueError("Message %r was not in permanent_stack" % msg)
62
63 @property
64 def has_focus(self):
65 return self.in_prompt or self.in_confirm or self.waiting_for_refresh
66
67 def message(self, msg, schedule_refresh=True):
68 """Sets a temporary message"""

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected