small refactor to console/about buffers

--HG--
branch : pmacs2
This commit is contained in:
moculus 2007-11-07 02:51:57 +00:00
parent e1973910ca
commit a71d36a183
3 changed files with 49 additions and 30 deletions

View File

@ -82,11 +82,12 @@ class Application(object):
# ok, now let's load all the "standard" modes
mode.install(self)
for name in ('about', 'blame', 'c', 'console', 'consolemini', 'css', 'diff',
'dir', 'elisp', 'hex', 'html', 'java', 'javascript',
'lisp', 'make', 'mini', 'mutt', 'nasm', 'ocaml', 'perl',
'python', 'replace', 'rst', 'scheme', 'search', 'sh',
'sql', 'tt', 'text', 'text2', 'which', 'xml'):
names = ('about', 'blame', 'c', 'console', 'consolemini', 'css', 'diff',
'dir', 'elisp', 'hex', 'html', 'java', 'javascript', 'lisp',
'make', 'mini', 'mutt', 'nasm', 'ocaml', 'perl', 'python',
'replace', 'rst', 'scheme', 'search', 'sh', 'sql', 'tt',
'text', 'text2', 'which', 'xml')
for name in names:
exec("import mode.%s; mode.%s.install(self)" % (name, name))
# initialize our methods
@ -113,8 +114,10 @@ class Application(object):
# initialize our buffers
# note that the first buffer in buffers will be initially visible
buffers.append(buffer.AboutBuffer())
buffers.append(buffer.ScratchBuffer())
buffers.append(buffer.ConsoleBuffer())
if self.rcerror:
buffers.insert(0, buffer.DataBuffer('*RcError*', self.rcerror))
@ -124,9 +127,9 @@ class Application(object):
# build windows for our buffers
for b in buffers:
if b.name() == '*Console*':
window.Window(b, self, height, width, mode_name='console')
window.Window(b, self)
else:
window.Window(b, self, height, width, mode_name=init_mode)
window.Window(b, self, mode_name=init_mode)
self.bufferlist.add_buffer(b)
self.bufferlist.set_slot(0, buffers[0])
@ -813,8 +816,8 @@ if __name__ == "__main__":
buffers = []
names = sets.Set()
paths = sets.Set()
if not args:
args = ['.']
#if not args:
# args = ['.']
for path in args:
path = os.path.abspath(os.path.realpath(util.expand_tilde(path)))
if path in paths:

View File

@ -340,6 +340,7 @@ class DataBuffer(Buffer):
console = None
class ConsoleBuffer(Buffer):
btype = 'console'
modename = 'console'
def __new__(cls, *args, **kwargs):
global console
if console is None:
@ -613,3 +614,28 @@ class PathListBuffer(DirBuffer):
return name
def name(self):
return self._name
class AboutBuffer(DataBuffer):
btype = 'about'
data = '''
================================================================================
************ ********** ****** ****** **** ******** *********
************** ****************** ************* ********** ***********
******* ***** ****** ***** **** **** ****** **** **** ***** ****
*** *** *** *** *** **** **** **** *******
*** *** *** *** *** **** **** **** *******
***** ***** ***** ***** **** **** ****** **** **** **** *****
************ ***** ***** **** ************* ********** ***********
********** ***** ***** **** ****** **** ******** *********
***
*** pmacs is a python-based text editor by Erik Osheim, (c) 2005-2007
***** pmacs is available to you under the GNU General Public License v2
*****
***** to see all available commands use: C-c M-h (show-bindings-buffer)
================================================================================
'''
modename = 'about'
def __init__(self):
DataBuffer.__init__(self, '*About*', self.data)

View File

@ -107,27 +107,15 @@ class Method:
class AboutPmacs(Method):
'''print some information about pmacs'''
data = '''
================================================================================
************ ********** ****** ****** **** ******** *********
************** ****************** ************* ********** ***********
******* ***** ****** ***** **** **** ****** **** **** ***** ****
*** *** *** *** *** **** **** **** *******
*** *** *** *** *** **** **** **** *******
***** ***** ***** ***** **** **** ****** **** **** **** *****
************ ***** ***** **** ************* ********** ***********
********** ***** ***** **** ****** **** ******** *********
***
*** pmacs is a python-based text editor by Erik Osheim, (c) 2005-2007
***** pmacs is available to you under the GNU General Public License v2
*****
***** to see all available commands use: C-c M-h (show-bindings-buffer)
================================================================================
'''
def _execute(self, w, **vargs):
w.application.data_buffer("*About*", self.data, switch_to=True, modename='about')
a = w.application
if not a.has_buffer_name('*About*'):
b = buffer.AboutBuffer()
a.add_buffer(b)
window.Window(b, w.application)
b = a.bufferlist.get_buffer_by_name('*About*')
if a.window().buffer is not b:
a.switch_buffer(b)
class GotoChar(Method):
'''Jump to the specified character'''
@ -966,7 +954,9 @@ class OpenConsole(Method):
def execute(self, w, **vargs):
a = w.application
if not a.has_buffer_name('*Console*'):
a.add_buffer(buffer.ConsoleBuffer())
b = buffer.ConsoleBuffer()
a.add_buffer(b)
window.Window(b, a)
b = a.bufferlist.get_buffer_by_name('*Console*')
if a.window().buffer is not b:
a.switch_buffer(b)