open-shell bugs

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-10-29 15:43:15 +00:00
parent 2953f52068
commit 09123ab192
4 changed files with 23 additions and 25 deletions

View File

@ -84,8 +84,7 @@ class PipeBuffer(Buffer):
self._lock.release()
if efd:
raise Exception, "exception is ready: %s" % repr(efd)
except OSError, e:
# read error means we're done
except (OSError, TypeError):
pass
os.close(fd)

View File

@ -1,4 +1,4 @@
import glob, os, pwd
import glob, os, pwd, sets
import method, util
def find_common_string(candidates):
@ -78,7 +78,7 @@ class CommandCompleter(Completer):
def get_candidates(self, s, w=None):
path = os.getenv('PATH')
path_dirs = path.split(':')
candidates = []
candidates = sets.Set()
for d in path_dirs:
if (not os.path.isdir(d) or not os.access(d, os.R_OK)):
continue
@ -88,8 +88,8 @@ class CommandCompleter(Completer):
elif not p.startswith(s):
continue
else:
candidates.append(p)
return candidates
candidates.add(p)
return sorted(candidates)
class ShellCompleter(Completer):
def __init__(self, application):

View File

@ -6,6 +6,13 @@ from point import Point
from method import Method
from subprocess import Popen, PIPE, STDOUT
class ShellMiniGrammar(Grammar):
rules = [
PatternRule('word', r'(?:(?:\\.|[^\n\\\'" ])+|"(?:\\.|[^\\\"])*"|\'(?:\\.|[^\\\'])*\')+'),
PatternRule('spaces', r' +'),
PatternRule('eol', r'\n'),
]
class ShellExec(Method):
def _execute(self, w, **vargs):
a = w.application
@ -76,27 +83,17 @@ class ShellTab(Method):
if curr_t is None:
return
if(i == 0) and '/' not in curr_t.string:
# we are completing a command
candidates = []
s1 = curr_t.string
if(curr_i == 0) and '/' not in s1:
completer = method.DATATYPES['command']
else:
# we are completing a path
cwd = os.getcwd()
if not cwd.endswith('/'):
cwd += '/'
path = cwd + curr_t.string
(d, name) = os.path.split(path)
names = []
for x in os.listdir(d):
if os.path.isdir(os.path.join(d, x)):
names.append(x + '/')
else:
names.append(x)
candidates = [x for x in names if x.startswith(name)]
completer = method.DATATYPES['path']
s = completer.find_common_string(candidates)[len(name):]
w.insert_string_at_cursor(s)
mode.mini.use_completion_window(a, name, candidates)
s2, exists, complete = completer.tab_string(s1, w)
w.delete(Point(curr_t.x, curr_t.y), Point(curr_t.end_x(), curr_t.y))
w.insert_string_at_cursor(s2)
candidates = completer.get_candidates(s1, w)
mode.mini.use_completion_window(a, s2, candidates)
class ShellBaseMethod(Method):
subcls = Method

View File

@ -523,6 +523,8 @@ class Window(object):
self.buffer.delete_char(cursor)
else:
pass
def delete(self, p1, p2):
self.buffer.delete(p1, p2)
# killing
def kill_line(self):