47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
import string
|
|
import buffer, method, mode, window
|
|
|
|
class MiniCallback(method.Method):
|
|
def execute(self, w, **vargs):
|
|
app = w.application
|
|
if app.completion_window_is_open():
|
|
app.close_completion_buffer()
|
|
w.buffer.do_callback()
|
|
|
|
class MiniTabComplete(method.Method):
|
|
def execute(self, w, **vargs):
|
|
app = w.application
|
|
b = w.buffer
|
|
if b.tabber is None:
|
|
w.application.set_error("No tab completion")
|
|
return
|
|
s1 = b.make_string()
|
|
s2, exists, complete = b.tabber.tab_string(s1, w)
|
|
b.set_data(s2)
|
|
|
|
if app.completion_window_is_open():
|
|
w2 = app.get_completion_window()
|
|
if w2.buffer._completion != s2:
|
|
app.close_completion_buffer()
|
|
|
|
if app.completion_window_is_open():
|
|
w2 = app.get_completion_window()
|
|
if w2.last_is_visible():
|
|
w2.goto_beginning()
|
|
else:
|
|
w2.page_down()
|
|
else:
|
|
candidates = sorted(b.tabber.get_candidates(s1, w))
|
|
if len(candidates) > 1:
|
|
app.open_completion_buffer(s2, candidates)
|
|
|
|
class Mini(mode.Fundamental):
|
|
modename = 'Mini'
|
|
actions = [MiniCallback, MiniTabComplete]
|
|
def __init__(self, w):
|
|
mode.Fundamental.__init__(self, w)
|
|
self.add_bindings('mini-callback', ('RETURN',))
|
|
self.add_bindings('mini-tab-complete', ('TAB',))
|
|
|
|
install = Mini.install
|