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]
s = line[x:x + slot.width]
try:
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):
x = 0
y += 1
@ -735,12 +738,18 @@ class Application(object):
self.win.addnstr(self.y-1, 0, util.pad('', l), l)
def open_aes_file(path, nl, name=None):
if os.path.isfile(path):
p = getpass.getpass("Please enter the AES password: ")
b = buffer2.AesBuffer(path, p, nl, name)
return b
return buffer2.AesBuffer(path, p, nl, name)
else:
raise Exception, "can't open %r; unsupported file type" % path
def open_plain_file(path, nl, name=None):
b = buffer2.FileBuffer(path, nl, name)
return b
if os.path.isfile(path):
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__":
ciphers = { 'none': open_plain_file, 'aes': open_aes_file }

View File

@ -417,6 +417,9 @@ class FileBuffer(Buffer):
self.store_checksum(data)
else:
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)
#FIXME: this is horrible...but maybe not as horrible as using tabs??
data = data.replace("\t", " ")

View File

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

View File

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