Skip to content
Browse files

FIx text transfer (a bit) and unselect line after history match

  • Loading branch information...
1 parent 7485533 commit 760d4d8b3edfc12465ad6ec048252918565c6606 @wuub wuub committed Sep 20, 2012
Showing with 11 additions and 24 deletions.
  1. +2 −15 sublimerepl.py
  2. +9 −9 text_transfer.py
View
17 sublimerepl.py
@@ -341,28 +341,15 @@ def ensure_history_match(self):
def replace_current_input(self, edit, cmd):
if cmd:
self._view.replace(edit, self.input_region, cmd)
+ self._view.sel().clear()
+ self._view.sel().add(sublime.Region(self._view.size()))
def run(self, edit, code):
self.replace_current_input(edit, code)
self.enter()
self._view.show(self.input_region)
self._window.focus_view(self._view)
- def view_previous_command(self, edit):
- self.ensure_history_match()
- self.replace_current_with_history(edit, self._history_match.prev_command())
-
- def view_next_command(self, edit):
- self.ensure_history_match()
- self.replace_current_with_history(edit, self._history_match.next_command())
-
- def replace_current_with_history(self, edit, cmd):
- if not cmd:
- return # don't replace if no match
- user_region = sublime.Region(self._output_end, self._view.size())
- self._view.erase(edit, user_region)
- self._view.insert(edit, user_region.begin(), cmd)
-
@property
def input_region(self):
return sublime.Region(self._output_end, self._view.size())
View
18 text_transfer.py
@@ -1,12 +1,12 @@
-from sublimerepl import find_repl
+from sublimerepl import manager
import sublime_plugin
import sublime
from collections import defaultdict
import tempfile
"""This is a bit stupid, but it's really difficult to create a temporary file with
-a persistent name that can be passed to external process using this name, and then
+a persistent name that can be passed to external process using this name, and then
delete it reliably..."""
TEMP_FILE = None
@@ -37,7 +37,7 @@ def wrap(func):
return wrap
@sender("python")
-def python_sender(repl, text, file_name=None):
+def python_sender(repl, text, file_name=None):
import codecs
tfile = temp_file()
with codecs.open(tfile.name, "w", "utf-8") as tmp:
@@ -47,17 +47,17 @@ def python_sender(repl, text, file_name=None):
class ReplViewWrite(sublime_plugin.WindowCommand):
def run(self, external_id, text, file_name=None):
- rv = find_repl(external_id)
+ rv = manager.find_repl(external_id)
if not rv:
- return
+ return
rv.append_input_text(text)
class ReplSend(sublime_plugin.WindowCommand):
def run(self, external_id, text, with_auto_postfix=True, file_name=None):
- rv = find_repl(external_id)
+ rv = manager.find_repl(external_id)
if not rv:
- return
+ return
cmd = text
if with_auto_postfix:
cmd += rv.repl.cmd_postfix
@@ -92,7 +92,7 @@ def selected_blocks(self):
# TODO: Clojure only for now
v = self.view
strs = []
- old_sel = list(v.sel())
+ old_sel = list(v.sel())
v.run_command("expand_selection", {"to": "brackets"})
v.run_command("expand_selection", {"to": "brackets"})
for s in v.sel():
@@ -112,4 +112,4 @@ def selected_lines(self):
def selected_file(self):
v = self.view
- return v.substr(sublime.Region(0, v.size()))
+ return v.substr(sublime.Region(0, v.size()))

0 comments on commit 760d4d8

Please sign in to comment.
Something went wrong with that request. Please try again.