more better mini-buffer/completion buffer
--HG-- branch : pmacs2
This commit is contained in:
parent
dddfa7a347
commit
bb90c03408
1
BUGS
1
BUGS
|
@ -15,6 +15,5 @@ known deficiencies:
|
|||
1. a single action (global search and replace) may produce N actions that
|
||||
need to be individually "undone". This is annoying.
|
||||
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
|
||||
(usually you just need to start hammering C-] to cancel whatever is happening).
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/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
|
||||
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.
|
||||
buffers = []
|
||||
names = sets.Set()
|
||||
paths = sets.Set()
|
||||
names = set()
|
||||
paths = set()
|
||||
|
||||
for path in args:
|
||||
path = os.path.abspath(os.path.realpath(util.expand_tilde(path)))
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import sets
|
||||
import window
|
||||
|
||||
class Slot(object):
|
||||
|
@ -30,7 +29,7 @@ class BufferList(object):
|
|||
def __init__(self, height, width, buffers=()):
|
||||
self.height = height
|
||||
self.width = width
|
||||
self.buffers = sets.Set()
|
||||
self.buffers = set()
|
||||
self.buffer_names = {}
|
||||
self.hidden_buffers = []
|
||||
self.slots = []
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import math, os, sets, string
|
||||
import math, os, string
|
||||
import color, method
|
||||
from lex import Lexer
|
||||
from point import Point
|
||||
|
@ -11,7 +11,7 @@ class ActionError(Exception):
|
|||
|
||||
class Handler(object):
|
||||
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.curr_tokens = []
|
||||
self.bindings = {}
|
||||
|
|
|
@ -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
|
||||
from lex import Grammar, PatternRule
|
||||
from mode.python import PythonGrammar
|
||||
|
@ -151,7 +151,7 @@ class ConsoleTab(method.Method):
|
|||
if obj is not None:
|
||||
newnames = dir(obj)
|
||||
else:
|
||||
newnames = sets.Set()
|
||||
newnames = set()
|
||||
newnames.update(__builtins__)
|
||||
newnames.update(w.mode.locals)
|
||||
newnames.update(w.mode.globals)
|
||||
|
|
36
mode/mini.py
36
mode/mini.py
|
@ -1,30 +1,6 @@
|
|||
import string
|
||||
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):
|
||||
def execute(self, w, **vargs):
|
||||
app = w.application
|
||||
|
@ -43,6 +19,11 @@ class MiniTabComplete(method.Method):
|
|||
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():
|
||||
|
@ -56,15 +37,10 @@ class MiniTabComplete(method.Method):
|
|||
|
||||
class Mini(mode.Fundamental):
|
||||
modename = 'Mini'
|
||||
actions = [MiniCallback, MiniTabComplete, MiniInsertSpace]
|
||||
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',))
|
||||
|
||||
# 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
|
||||
|
|
Loading…
Reference in New Issue