i am awesome

--HG--
branch : pmacs2
This commit is contained in:
moculus 2007-07-19 18:37:39 +00:00
parent 3bb9e6b7a6
commit 0b4cd8dc7b
4 changed files with 23 additions and 8 deletions

View File

@ -601,7 +601,10 @@ class Application(object):
line = lines[y] line = lines[y]
s = line[x:x + slot.width] s = line[x:x + slot.width]
try:
self.win.addstr(slot.offset + count, 0, s) self.win.addstr(slot.offset + count, 0, s)
except:
self.set_error("addstr(%r + %r, %r, %r)" % (slot.offset, count, 0, s))
if x + slot.width >= len(line): if x + slot.width >= len(line):
x = 0 x = 0
y += 1 y += 1
@ -735,12 +738,18 @@ class Application(object):
self.win.addnstr(self.y-1, 0, util.pad('', l), l) self.win.addnstr(self.y-1, 0, util.pad('', l), l)
def open_aes_file(path, nl, name=None): def open_aes_file(path, nl, name=None):
if os.path.isfile(path):
p = getpass.getpass("Please enter the AES password: ") p = getpass.getpass("Please enter the AES password: ")
b = buffer2.AesBuffer(path, p, nl, name) return buffer2.AesBuffer(path, p, nl, name)
return b else:
raise Exception, "can't open %r; unsupported file type" % path
def open_plain_file(path, nl, name=None): def open_plain_file(path, nl, name=None):
b = buffer2.FileBuffer(path, nl, name) if os.path.isfile(path):
return b return buffer2.FileBuffer(path, nl, name)
elif os.path.isdir(path):
return buffer2.DirBuffer(path, nl, name)
else:
raise Exception, "can't open %r; unsupported file type" % path
if __name__ == "__main__": if __name__ == "__main__":
ciphers = { 'none': open_plain_file, 'aes': open_aes_file } ciphers = { 'none': open_plain_file, 'aes': open_aes_file }

View File

@ -417,6 +417,9 @@ class FileBuffer(Buffer):
self.store_checksum(data) self.store_checksum(data)
else: else:
data = '' data = ''
for i in range(0, 8):
if ord(data[i]) > 127:
raise Exception, "editing binary files is not supported"
data = self.read_filter(data) data = self.read_filter(data)
#FIXME: this is horrible...but maybe not as horrible as using tabs?? #FIXME: this is horrible...but maybe not as horrible as using tabs??
data = data.replace("\t", " ") data = data.replace("\t", " ")

View File

@ -6,6 +6,7 @@ class MiniBufferError(Exception):
# minibuffer is a singleton # minibuffer is a singleton
mini = None mini = None
class MiniBuffer(buffer2.Buffer): class MiniBuffer(buffer2.Buffer):
btype = 'mini'
def __new__(cls, *args, **kwargs): def __new__(cls, *args, **kwargs):
global mini global mini
if mini is None: if mini is None:

View File

@ -32,10 +32,12 @@ class Window(object):
pass pass
elif hasattr(self.buffer, 'modename') and self.buffer.modename is not None: elif hasattr(self.buffer, 'modename') and self.buffer.modename is not None:
mode_name = self.buffer.modename mode_name = self.buffer.modename
elif self.buffer.name() == "*Minibuffer*": elif self.buffer.btype == 'mini':
mode_name = 'mini' mode_name = 'mini'
elif self.buffer.name() == "*Console*": elif self.buffer.btype == 'console':
mode_name = "fundamental" mode_name = "fundamental"
elif self.buffer.btype == 'dir':
mode_name = 'dir'
elif hasattr(self.buffer, 'path'): elif hasattr(self.buffer, 'path'):
path = self.buffer.path path = self.buffer.path
basename = os.path.basename(path) basename = os.path.basename(path)