@@ -382,64 +382,53 @@ def check_action(self, action: str, parameters: tuple[object, ...]) -> bool | No
382
382
return self .query_one (Viewer ).location is not None
383
383
return True
384
384
385
- @on (Reload )
386
385
def action_reload_command (self ) -> None :
387
386
"""Reload the current document."""
388
387
self .query_one (Viewer ).reload ()
389
388
390
- @on (SearchBookmarks )
391
389
def action_search_bookmarks_command (self ) -> None :
392
390
"""Search the bookmarks in the command palette."""
393
391
self .show_palette (BookmarkCommands )
394
392
395
- @on (SearchHistory )
396
393
def action_search_history_command (self ) -> None :
397
394
"""search the history in the command palette."""
398
395
self .show_palette (HistoryCommands )
399
396
400
- @on (ToggleNavigation )
401
397
def action_toggle_navigation_command (self ) -> None :
402
398
"""Toggle the display of the navigation panel."""
403
399
self .navigation_visible = not self .navigation_visible
404
400
405
- @on (ChangeNavigationSide )
406
401
def action_change_navigation_side_command (self ) -> None :
407
402
"""Change the side that the navigation panel lives on."""
408
403
navigation = self .query_one (Navigation )
409
404
navigation .dock_right = not navigation .dock_right
410
405
with update_configuration () as config :
411
406
config .navigation_on_right = navigation .dock_right
412
407
413
- @on (ChangeCommandLineLocation )
414
408
def action_change_command_line_location_command (self ) -> None :
415
409
"""Change the location of the command line."""
416
410
command_line = self .query_one (CommandLine )
417
411
command_line .dock_top = not command_line .dock_top
418
412
with update_configuration () as config :
419
413
config .command_line_on_top = command_line .dock_top
420
414
421
- @on (JumpToCommandLine )
422
415
def action_jump_to_command_line_command (self ) -> None :
423
416
"""Jump to the command line."""
424
417
if self .AUTO_FOCUS :
425
418
self .query_one (self .AUTO_FOCUS ).focus ()
426
419
427
- @on (JumpToDocument )
428
420
def action_jump_to_document_command (self ) -> None :
429
421
"""Jump to the document."""
430
422
self .query_one (Viewer ).focus ()
431
423
432
- @on (Backward )
433
424
def action_backward_command (self ) -> None :
434
425
"""Move backward through history."""
435
426
self .query_one (Viewer ).backward ()
436
427
437
- @on (Forward )
438
428
def action_forward_command (self ) -> None :
439
429
"""Move forward through history."""
440
430
self .query_one (Viewer ).forward ()
441
431
442
- @on (BookmarkLocation )
443
432
@work
444
433
async def action_bookmark_location_command (self ) -> None :
445
434
"""Add the current location to the bookmarks."""
@@ -468,42 +457,34 @@ def _with_navigation_visible(self) -> Navigation:
468
457
self .navigation_visible = True
469
458
return self .query_one (Navigation )
470
459
471
- @on (JumpToTableOfContents )
472
460
def action_jump_to_table_of_contents_command (self ) -> None :
473
461
"""Jump to the table of contents."""
474
462
self ._with_navigation_visible ().jump_to_content ()
475
463
476
- @on (JumpToLocalBrowser )
477
464
def action_jump_to_local_browser_command (self ) -> None :
478
465
"""Jump to the local browser."""
479
466
self ._with_navigation_visible ().jump_to_local ()
480
467
481
- @on (JumpToBookmarks )
482
468
def action_jump_to_bookmarks_command (self ) -> None :
483
469
"""Jump to the bookmarks."""
484
470
self ._with_navigation_visible ().jump_to_bookmarks ()
485
471
486
- @on (JumpToHistory )
487
472
def action_jump_to_history_command (self ) -> None :
488
473
"""Jump to the history."""
489
474
self ._with_navigation_visible ().jump_to_history ()
490
475
491
- @on (CopyLocationToClipboard )
492
476
def action_copy_location_to_clipboard_command (self ) -> None :
493
477
"""Copy the current location to the clipboard."""
494
478
self .post_message (CopyToClipboard (str (self .query_one (Viewer ).location )))
495
479
496
- @on (CopyMarkdownToClipboard )
497
480
def action_copy_markdown_to_clipboard_command (self ) -> None :
498
481
"""Copy the current markdown to the clipboard."""
499
482
self .post_message (CopyToClipboard (self .query_one (Viewer ).source ))
500
483
501
- @on (Edit )
502
484
def action_edit_command (self ) -> None :
503
485
"""Edit the current markdown document, if possible."""
504
486
self .query_one (Viewer ).edit ()
505
487
506
- @on (SaveCopy )
507
488
@work
508
489
async def action_save_copy_command (self ) -> None :
509
490
"""Save a copy of the current document to a new file."""
0 commit comments