Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
values. ([#11](https://github.com/davep/complexitty/issues/11))
- Changed the display of the X/Y location so that the precision adapts to
the zoom level. ([#14](https://github.com/davep/complexitty/issues/14))
- Added `CopyCommandLineToClipboard`.
([#20](https://github.com/davep/complexitty/pull/20))

## v0.2.0

Expand Down
3 changes: 2 additions & 1 deletion src/complexitty/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
SetColourToShadesOfGreen,
SetColourToShadesOfRed,
)
from .main import Quit
from .main import CopyCommandLineToClipboard, Quit
from .navigation import (
GoMiddle,
GoTo,
Expand Down Expand Up @@ -42,6 +42,7 @@
##############################################################################
# Exports.
__all__ = [
"CopyCommandLineToClipboard",
"DecreaseMaximumIteration",
"DecreaseMultibrot",
"GreatlyDecreaseMaximumIteration",
Expand Down
7 changes: 7 additions & 0 deletions src/complexitty/commands/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,11 @@ class Quit(Command):
SHOW_IN_FOOTER = True


##############################################################################
class CopyCommandLineToClipboard(Command):
"""Copy the command line for the current view to the clipboard"""

BINDING_KEY = "c"


### main.py ends here
2 changes: 2 additions & 0 deletions src/complexitty/providers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
##############################################################################
# Local imports.
from ..commands import (
CopyCommandLineToClipboard,
DecreaseMaximumIteration,
DecreaseMultibrot,
GoMiddle,
Expand Down Expand Up @@ -55,6 +56,7 @@ def commands(self) -> CommandHits:
Yields:
The commands for the command palette.
"""
yield CopyCommandLineToClipboard()
yield ChangeTheme()
yield DecreaseMaximumIteration()
yield DecreaseMultibrot()
Expand Down
17 changes: 17 additions & 0 deletions src/complexitty/screens/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
##############################################################################
# Local imports.
from ..commands import (
CopyCommandLineToClipboard,
DecreaseMaximumIteration,
DecreaseMultibrot,
GoMiddle,
Expand Down Expand Up @@ -75,6 +76,7 @@ class Main(EnhancedScreen[None]):
ChangeTheme,
Quit,
# Everything else.
CopyCommandLineToClipboard,
DecreaseMaximumIteration,
DecreaseMultibrot,
GoMiddle,
Expand Down Expand Up @@ -253,5 +255,20 @@ async def action_go_to_command(self) -> None:
severity="error",
)

def action_copy_command_line_to_clipboard_command(self) -> None:
"""Copy the current view as a command, to the clipboard."""
plot = self.query_one(Mandelbrot)
command = (
f"complexitty "
f"--x-position={plot.x_position} "
f"--y-position={plot.y_position} "
f"--zoom={plot.zoom} "
f"--max-iteration={plot.max_iteration} "
f"--multibrot={plot.multibrot} "
f"--colour-map={plot.colour_map.__name__}"
)
self.app.copy_to_clipboard(command)
self.notify(command, title="Copied")


### main.py ends here
Loading