more better mini-buffer/completion buffer

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-05-04 06:40:30 +00:00
parent dddfa7a347
commit bb90c03408
6 changed files with 14 additions and 40 deletions

1
BUGS
View File

@ -15,6 +15,5 @@ known deficiencies:
1. a single action (global search and replace) may produce N actions that 1. a single action (global search and replace) may produce N actions that
need to be individually "undone". This is annoying. need to be individually "undone". This is annoying.
3. opening files larger than 5-10k lines can be very slow 3. opening files larger than 5-10k lines can be very slow
5. tab completion, etc doesn't pop-open a completion buffer like it might
6. if you get confused in the mini buffer it can be annoying 6. if you get confused in the mini buffer it can be annoying
(usually you just need to start hammering C-] to cancel whatever is happening). (usually you just need to start hammering C-] to cancel whatever is happening).

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
import curses, curses.ascii, getpass, os, re, string, sets, sys, termios, time import curses, curses.ascii, getpass, os, re, string, sys, termios, time
import traceback import traceback
from subprocess import Popen, PIPE, STDOUT from subprocess import Popen, PIPE, STDOUT
@ -956,8 +956,8 @@ if __name__ == "__main__":
# open each path using our callback to get a buffer, open that buffer, etc. # open each path using our callback to get a buffer, open that buffer, etc.
buffers = [] buffers = []
names = sets.Set() names = set()
paths = sets.Set() paths = set()
for path in args: for path in args:
path = os.path.abspath(os.path.realpath(util.expand_tilde(path))) path = os.path.abspath(os.path.realpath(util.expand_tilde(path)))

View File

@ -1,4 +1,3 @@
import sets
import window import window
class Slot(object): class Slot(object):
@ -30,7 +29,7 @@ class BufferList(object):
def __init__(self, height, width, buffers=()): def __init__(self, height, width, buffers=()):
self.height = height self.height = height
self.width = width self.width = width
self.buffers = sets.Set() self.buffers = set()
self.buffer_names = {} self.buffer_names = {}
self.hidden_buffers = [] self.hidden_buffers = []
self.slots = [] self.slots = []

View File

@ -1,4 +1,4 @@
import math, os, sets, string import math, os, string
import color, method import color, method
from lex import Lexer from lex import Lexer
from point import Point from point import Point
@ -11,7 +11,7 @@ class ActionError(Exception):
class Handler(object): class Handler(object):
def __init__(self): def __init__(self):
self.prefixes = sets.Set(["C-x", "C-c", "C-u"]) self.prefixes = set(["C-x", "C-c", "C-u"])
self.last_sequence = '' self.last_sequence = ''
self.curr_tokens = [] self.curr_tokens = []
self.bindings = {} self.bindings = {}

View File

@ -1,4 +1,4 @@
import code, re, string, StringIO, sets, sys, traceback import code, re, string, StringIO, sys, traceback
import color, completer, lex, method, mode import color, completer, lex, method, mode
from lex import Grammar, PatternRule from lex import Grammar, PatternRule
from mode.python import PythonGrammar from mode.python import PythonGrammar
@ -151,7 +151,7 @@ class ConsoleTab(method.Method):
if obj is not None: if obj is not None:
newnames = dir(obj) newnames = dir(obj)
else: else:
newnames = sets.Set() newnames = set()
newnames.update(__builtins__) newnames.update(__builtins__)
newnames.update(w.mode.locals) newnames.update(w.mode.locals)
newnames.update(w.mode.globals) newnames.update(w.mode.globals)

View File

@ -1,30 +1,6 @@
import string import string
import buffer, method, mode, window import buffer, method, mode, window
class MiniInsertString(method.InsertString):
_is_method = False
def __init__(self, s):
method.InsertString.__init__(self, s)
self.name = "mini-insert-string-%s" % s
def _execute(self, w, **vargs):
try:
app = w.application
w.insert_string_at_cursor(self.string)
if app.completion_window_is_open():
app.close_completion_buffer()
except buffer.ReadOnlyError:
w.set_error('Buffer is read-only')
class MiniInsertSpace(method.Method):
def _execute(self, w, **vargs):
try:
app = w.application
w.insert_string_at_cursor(' ')
if app.completion_window_is_open():
app.close_completion_buffer()
except buffer.ReadOnlyError:
w.set_error('Buffer is read-only')
class MiniCallback(method.Method): class MiniCallback(method.Method):
def execute(self, w, **vargs): def execute(self, w, **vargs):
app = w.application app = w.application
@ -43,6 +19,11 @@ class MiniTabComplete(method.Method):
s2, exists, complete = b.tabber.tab_string(s1, w) s2, exists, complete = b.tabber.tab_string(s1, w)
b.set_data(s2) 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(): if app.completion_window_is_open():
w2 = app.get_completion_window() w2 = app.get_completion_window()
if w2.last_is_visible(): if w2.last_is_visible():
@ -56,15 +37,10 @@ class MiniTabComplete(method.Method):
class Mini(mode.Fundamental): class Mini(mode.Fundamental):
modename = 'Mini' modename = 'Mini'
actions = [MiniCallback, MiniTabComplete, MiniInsertSpace] actions = [MiniCallback, MiniTabComplete]
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)
self.add_bindings('mini-callback', ('RETURN',)) self.add_bindings('mini-callback', ('RETURN',))
self.add_bindings('mini-tab-complete', ('TAB',)) self.add_bindings('mini-tab-complete', ('TAB',))
# create all the insert actions for the basic text input
for c in string.letters + string.digits + string.punctuation:
self.add_action_and_bindings(MiniInsertString(c), (c,))
self.add_bindings('mini-insert-space', ('SPACE',))
install = Mini.install install = Mini.install