| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 52d2fd7 commit 94f569a
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -218,15 +218,19 @@ def message(self, s, n=3): | |||
| 218 | 218 | self.settext(s) | |
| 219 | 219 | self.timer = self.main_loop.set_alarm_in(n, self._check) | |
| 220 | 220 | ||
| 221 | + def _reset_timer(self): | ||
| 222 | + """Reset the timer from message.""" | ||
| 223 | + if self.timer is not None: | ||
| 224 | + self.main_loop.remove_alarm(self.timer) | ||
| 225 | + self.timer = None | ||
| 226 | + | ||
| 221 | 227 | def prompt(self, s=None, single=False): | |
| 222 | 228 | """Prompt the user for some input (with the optional prompt 's'). After | |
| 223 | 229 | the user hit enter the signal 'prompt_result' will be emited and the | |
| 224 | 230 | status bar will be reset. If single is True, the first keypress will be | |
| 225 | 231 | returned.""" | |
| 226 | 232 | ||
| 227 | - if self.timer is not None: | ||
| 228 | - self.main_loop.remove_alarm(self.timer) | ||
| 229 | - self.timer = None | ||
| 233 | + self._reset_timer() | ||
| 230 | 234 | ||
| 231 | 235 | self.edit.single = single | |
| 232 | 236 | self.edit.set_caption(('main', s or '?')) | |
@@ -243,9 +247,7 @@ def settext(self, s, permanent=False): | |||
| 243 | 247 | the new value will be permanent. If that status bar is in prompt mode, | |
| 244 | 248 | the prompt will be aborted. """ | |
| 245 | 249 | ||
| 246 | - if self.timer is not None: | ||
| 247 | - self.main_loop.remove_alarm(self.timer) | ||
| 248 | - self.timer = None | ||
| 250 | + self._reset_timer() | ||
| 249 | 251 | ||
| 250 | 252 | # hide the edit and display the text widget | |
| 251 | 253 | if self.edit in self.widget.widget_list: | |
@@ -533,7 +535,8 @@ def notify(self, s, n=10): | |||
| 533 | 535 | ||
| 534 | 536 | def prompt(self, s, callback=None, single=False): | |
| 535 | 537 | """Prompt the user for input. The result will be returned via calling | |
| 536 | - callback.""" | ||
| 538 | + callback. Note that there can only be one prompt active. But the | ||
| 539 | + callback can already start a new prompt.""" | ||
| 537 | 540 | ||
| 538 | 541 | if self.callback is not None: | |
| 539 | 542 | raise Exception('Prompt already in progress') | |
@@ -545,8 +548,11 @@ def prompt(self, s, callback=None, single=False): | |||
| 545 | 548 | def _prompt_result(self, text): | |
| 546 | 549 | self.frame.set_focus('body') | |
| 547 | 550 | if self.callback is not None: | |
| 548 | - self.callback(text) | ||
| 549 | - self.callback = None | ||
| 551 | + # The callback might want to start another prompt, so reset it | ||
| 552 | + # before calling the callback. | ||
| 553 | + callback = self.callback | ||
| 554 | + self.callback = None | ||
| 555 | + callback(text) | ||
| 550 | 556 | ||
| 551 | 557 | ||
| 552 | 558 | class URWIDRepl(repl.Repl): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments