##// END OF EJS Templates
Merge pull request #9614 from takluyver/win-paste-ctrlv...
Matthias Bussonnier -
r22548:699a38ae merge
parent child Browse files
Show More
@@ -14,7 +14,9 b' from IPython.utils.process import abbrev_cwd'
14 from traitlets import Bool, Unicode, Dict, Integer, observe, Instance, Type, default
14 from traitlets import Bool, Unicode, Dict, Integer, observe, Instance, Type, default
15
15
16 from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER, EditingMode
16 from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER, EditingMode
17 from prompt_toolkit.filters import HasFocus, HasSelection, Condition, ViInsertMode, EmacsInsertMode, IsDone, HasCompletions
17 from prompt_toolkit.filters import (HasFocus, HasSelection, Condition,
18 ViInsertMode, EmacsInsertMode, IsDone, HasCompletions)
19 from prompt_toolkit.filters.cli import ViMode
18 from prompt_toolkit.history import InMemoryHistory
20 from prompt_toolkit.history import InMemoryHistory
19 from prompt_toolkit.shortcuts import create_prompt_application, create_eventloop, create_prompt_layout
21 from prompt_toolkit.shortcuts import create_prompt_application, create_eventloop, create_prompt_layout
20 from prompt_toolkit.interface import CommandLineInterface
22 from prompt_toolkit.interface import CommandLineInterface
@@ -271,6 +273,23 b' class TerminalInteractiveShell(InteractiveShell):'
271 def _indent_buffer(event):
273 def _indent_buffer(event):
272 event.current_buffer.insert_text(' ' * 4)
274 event.current_buffer.insert_text(' ' * 4)
273
275
276 if sys.platform == 'win32':
277 from IPython.lib.clipboard import (ClipboardEmpty,
278 win32_clipboard_get, tkinter_clipboard_get)
279 @kbmanager.registry.add_binding(Keys.ControlV,
280 filter=(HasFocus(DEFAULT_BUFFER) & ~ViMode()))
281 def _paste(event):
282 try:
283 text = win32_clipboard_get()
284 except TryNext:
285 try:
286 text = tkinter_clipboard_get()
287 except (TryNext, ClipboardEmpty):
288 return
289 except ClipboardEmpty:
290 return
291 event.current_buffer.insert_text(text.replace('\t', ' ' * 4))
292
274 # Pre-populate history from IPython's history database
293 # Pre-populate history from IPython's history database
275 history = InMemoryHistory()
294 history = InMemoryHistory()
276 last_cell = u""
295 last_cell = u""
General Comments 0
You need to be logged in to leave comments. Login now