parent
9090a0f44a
commit
6ca089f3b7
|
@ -231,23 +231,28 @@ class Application(object):
|
||||||
return self.mini_buffer
|
return self.mini_buffer
|
||||||
def mini_buffer_is_open(self):
|
def mini_buffer_is_open(self):
|
||||||
return self.mini_buffer is not None
|
return self.mini_buffer is not None
|
||||||
def open_mini_buffer(self, prompt, callback, method=None, tabber=None,
|
def open_mini_buffer(self, prompt, callback, method=None, tabber=None, modename=None):
|
||||||
modename=None):
|
|
||||||
if self.mini_buffer_is_open():
|
if self.mini_buffer_is_open():
|
||||||
self.close_mini_buffer()
|
self.close_mini_buffer()
|
||||||
self.mini_prompt = prompt
|
self.mini_prompt = prompt
|
||||||
self.mini_buffer = minibuffer.MiniBuffer(callback, method, tabber, modename)
|
self.mini_buffer = minibuffer.MiniBuffer(callback, method, tabber, modename)
|
||||||
window2.Window(self.mini_buffer, self, height=1, width=self.x-1-len(self.mini_prompt)-1)
|
try:
|
||||||
|
window2.Window(self.mini_buffer, self, height=1,
|
||||||
|
width=self.x-1-len(self.mini_prompt)-1)
|
||||||
self.mini_active = True
|
self.mini_active = True
|
||||||
|
except minibuffer.MiniBufferError:
|
||||||
|
self.mini_buffer = None
|
||||||
|
self.mini_prompt = ''
|
||||||
def exec_mini_buffer(self):
|
def exec_mini_buffer(self):
|
||||||
self.mini_buffer.callback(self.mini_buffer.make_string())
|
self.mini_buffer.callback(self.mini_buffer.make_string())
|
||||||
self.close_mini_buffer()
|
self.close_mini_buffer()
|
||||||
def close_mini_buffer(self):
|
def close_mini_buffer(self):
|
||||||
|
self.mini_active = False
|
||||||
if self.mini_buffer_is_open():
|
if self.mini_buffer_is_open():
|
||||||
self.mini_buffer.close()
|
self.mini_buffer.close()
|
||||||
self.mini_buffer = None
|
self.mini_buffer = None
|
||||||
self.mini_prompt = ""
|
self.mini_prompt = ""
|
||||||
self.mini_active = False
|
assert not self.mini_active
|
||||||
def get_mini_buffer_prompt(self):
|
def get_mini_buffer_prompt(self):
|
||||||
return self.mini_prompt
|
return self.mini_prompt
|
||||||
def set_mini_buffer_prompt(self, p):
|
def set_mini_buffer_prompt(self, p):
|
||||||
|
|
|
@ -171,11 +171,7 @@ class Replace(Method):
|
||||||
a.last_replace_before = self.before = vargs['before']
|
a.last_replace_before = self.before = vargs['before']
|
||||||
a.last_replace_after = self.after = vargs['after']
|
a.last_replace_after = self.after = vargs['after']
|
||||||
self.old_window = w
|
self.old_window = w
|
||||||
a.open_mini_buffer('I-Replace: ',
|
a.open_mini_buffer('I-Replace: ', lambda x: None, self, None, 'replace')
|
||||||
lambda x: None,
|
|
||||||
self,
|
|
||||||
None,
|
|
||||||
'replace')
|
|
||||||
|
|
||||||
# navigating between buffers
|
# navigating between buffers
|
||||||
class OpenFile(Method):
|
class OpenFile(Method):
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
import buffer2
|
import buffer2
|
||||||
|
|
||||||
|
class MiniBufferError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
# minibuffer is a singleton
|
# minibuffer is a singleton
|
||||||
mini = None
|
mini = None
|
||||||
class MiniBuffer(buffer2.Buffer):
|
class MiniBuffer(buffer2.Buffer):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import commands, os.path, sets, string, sys
|
import commands, os.path, sets, string, sys
|
||||||
|
|
||||||
import color, completer, default, mode2, lex2, method, regex
|
import color, completer, default, mode2, lex2, method, regex, tab2
|
||||||
import ctag_python
|
import ctag_python
|
||||||
|
|
||||||
from point2 import Point
|
from point2 import Point
|
||||||
|
|
|
@ -26,6 +26,9 @@ class Replace(mode2.Fundamental):
|
||||||
self.add_action_and_bindings(action, sequences)
|
self.add_action_and_bindings(action, sequences)
|
||||||
|
|
||||||
_find_next(w, False)
|
_find_next(w, False)
|
||||||
|
if w.buffer.method.p1 is None:
|
||||||
|
w.application.set_error('%r was not found')
|
||||||
|
raise minibuffer.MiniBufferError
|
||||||
_set_prompt(w.buffer.method, w.buffer.method.old_window)
|
_set_prompt(w.buffer.method, w.buffer.method.old_window)
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
|
@ -62,6 +65,9 @@ class CancelReplace(method.Method):
|
||||||
w.application.set_error("Replace cancelled")
|
w.application.set_error("Replace cancelled")
|
||||||
|
|
||||||
def _set_prompt(m, w):
|
def _set_prompt(m, w):
|
||||||
|
if m.p1 is None:
|
||||||
|
w.application.mini_prompt = '%r was not found' % m.before
|
||||||
|
return
|
||||||
(x, y) = m.p1.xy()
|
(x, y) = m.p1.xy()
|
||||||
count = 0
|
count = 0
|
||||||
while y < len(w.buffer.lines):
|
while y < len(w.buffer.lines):
|
||||||
|
@ -128,3 +134,4 @@ def _end(w):
|
||||||
w.application.clear_highlighted_ranges()
|
w.application.clear_highlighted_ranges()
|
||||||
w.buffer.method.old_cursor = None
|
w.buffer.method.old_cursor = None
|
||||||
w.buffer.method.old_window = None
|
w.buffer.method.old_window = None
|
||||||
|
assert not w.application.mini_active
|
||||||
|
|
Loading…
Reference in New Issue