|
3 | 3 | ##############################################################################
|
4 | 4 | # Python imports.
|
5 | 5 | from argparse import Namespace
|
| 6 | +from functools import partial |
6 | 7 |
|
7 | 8 | ##############################################################################
|
8 | 9 | # Pyperclip imports.
|
|
22 | 23 | from textual_enhanced.commands import ChangeTheme, Command, Help, Quit
|
23 | 24 | from textual_enhanced.dialogs import ModalInput
|
24 | 25 | from textual_enhanced.screen import EnhancedScreen
|
| 26 | +from textual_enhanced.tools import add_key |
25 | 27 |
|
26 | 28 | ##############################################################################
|
27 | 29 | # Textual fspicker imports.
|
@@ -259,6 +261,7 @@ async def _browse_for_file(self, message: OpenFrom) -> None:
|
259 | 261 | ),
|
260 | 262 | ("All files", lambda _: True),
|
261 | 263 | ),
|
| 264 | + cancel_button=partial(add_key, key="Esc", context=self), |
262 | 265 | )
|
263 | 266 | ):
|
264 | 267 | self.post_message(OpenLocation(chosen))
|
@@ -488,7 +491,12 @@ async def action_save_copy_command(self) -> None:
|
488 | 491 | """Save a copy of the current document to a new file."""
|
489 | 492 | if (suggested := self.query_one(Viewer).filename) is None:
|
490 | 493 | return
|
491 |
| - if save_to := await self.app.push_screen_wait(FileSave(default_file=suggested)): |
| 494 | + if save_to := await self.app.push_screen_wait( |
| 495 | + FileSave( |
| 496 | + default_file=suggested, |
| 497 | + cancel_button=partial(add_key, key="Esc", context=self), |
| 498 | + ) |
| 499 | + ): |
492 | 500 | try:
|
493 | 501 | save_to.write_text(self.query_one(Viewer).source, encoding="utf-8")
|
494 | 502 | except IOError as error:
|
|
0 commit comments