From 3bf8958a1e06dc33cd371de4e1e2f4a7404dc112 Mon Sep 17 00:00:00 2001 From: ryneeverett Date: Wed, 2 Dec 2015 23:39:39 -0500 Subject: [PATCH] Add clipboard configuration option. Resolve #43. --- examples/ptpython_config/config.py | 4 ++++ ptpython/python_input.py | 1 + 2 files changed, 5 insertions(+) diff --git a/examples/ptpython_config/config.py b/examples/ptpython_config/config.py index ddcda9bd..5bfe2a30 100644 --- a/examples/ptpython_config/config.py +++ b/examples/ptpython_config/config.py @@ -5,6 +5,7 @@ """ from __future__ import unicode_literals from prompt_toolkit.keys import Keys +from prompt_toolkit.clipboard.pyperclip import PyperclipClipboard from pygments.token import Token from ptpython.layout import CompletionVisualisation @@ -138,6 +139,9 @@ def _(event): b.insert_text(' ') """ + # Use system clipboard. + repl.clipboard = PyperclipClipboard() + # Custom colorscheme for the UI. See `ptpython/layout.py` and # `ptpython/style.py` for all possible tokens. diff --git a/ptpython/python_input.py b/ptpython/python_input.py index 98c0b939..55b61758 100644 --- a/ptpython/python_input.py +++ b/ptpython/python_input.py @@ -504,6 +504,7 @@ def create_application(self): buffers=buffers, key_bindings_registry=self.key_bindings_registry, paste_mode=Condition(lambda cli: self.paste_mode), + clipboard=getattr(self, 'clipboard', None), mouse_support=Condition(lambda cli: self.enable_mouse_support), on_abort=AbortAction.RETRY, on_exit=self._on_exit,