[PyCrust-cvs] PyCrust frame.py,NONE,1.1 editor.py,1.4,1.5 base.py,NONE,1.1 PyAlaMode.py,NONE,1.1 she
Brought to you by:
pobrien
Update of /cvsroot/pycrust/PyCrust In directory sc8-pr-cvs1:/tmp/cvs-serv5691 Modified Files: shell.py filling.py crust.py CHANGES.txt Added Files: frame.py editor.py base.py PyAlaMode.py Log Message: PyAlaMode... Yummm! --- NEW FILE: frame.py --- """Base frame with menu.""" __author__ = "Patrick K. O'Brien <po...@or...>" __cvsid__ = "$Id: frame.py,v 1.1 2003/03/29 02:42:01 pobrien Exp $" __revision__ = "$Revision: 1.1 $"[11:-2] from wxPython import wx from version import VERSION try: True except NameError: True = 1==1 False = 1==0 ID_AUTOCOMP = wx.wxNewId() ID_AUTOCOMP_SHOW = wx.wxNewId() ID_AUTOCOMP_INCLUDE_MAGIC = wx.wxNewId() ID_AUTOCOMP_INCLUDE_SINGLE = wx.wxNewId() ID_AUTOCOMP_INCLUDE_DOUBLE = wx.wxNewId() ID_CALLTIPS = wx.wxNewId() ID_CALLTIPS_SHOW = wx.wxNewId() ID_COPY_PLUS = wx.wxNewId() ID_PASTE_PLUS = wx.wxNewId() ID_WRAP = wx.wxNewId() class Frame(wx.wxFrame): """Frame with standard menu items.""" revision = __revision__ def __init__(self, parent=None, id=-1, title='Editor', pos=wx.wxDefaultPosition, size=wx.wxDefaultSize, style=wx.wxDEFAULT_FRAME_STYLE): """Create a Frame instance.""" wx.wxFrame.__init__(self, parent, id, title, pos, size, style) self.CreateStatusBar() self.SetStatusText('Frame') import images self.SetIcon(images.getPyCrustIcon()) self.__createMenus() wx.EVT_CLOSE(self, self.OnCloseWindow) def OnCloseWindow(self, event): """Event handler for closing.""" self.Destroy() def __createMenus(self): m = self.fileMenu = wx.wxMenu() m.AppendSeparator() m.Append(wx.wxID_EXIT, 'E&xit', 'Exit Program') m = self.editMenu = wx.wxMenu() m.Append(wx.wxID_UNDO, '&Undo \tCtrl+Z', 'Undo the last action') m.Append(wx.wxID_REDO, '&Redo \tCtrl+Y', 'Redo the last undone action') m.AppendSeparator() m.Append(wx.wxID_CUT, 'Cu&t \tCtrl+X', 'Cut the selection') m.Append(wx.wxID_COPY, '&Copy \tCtrl+C', 'Copy the selection') m.Append(ID_COPY_PLUS, 'Cop&y Plus \tCtrl+Shift+C', 'Copy the selection - retaining prompts') m.Append(wx.wxID_PASTE, '&Paste \tCtrl+V', 'Paste from clipboard') m.Append(ID_PASTE_PLUS, 'Past&e Plus \tCtrl+Shift+V', 'Paste and run commands') m.AppendSeparator() m.Append(wx.wxID_CLEAR, 'Cle&ar', 'Delete the selection') m.Append(wx.wxID_SELECTALL, 'Select A&ll \tCtrl+A', 'Select all text') m = self.autocompMenu = wx.wxMenu() m.Append(ID_AUTOCOMP_SHOW, 'Show Auto Completion', 'Show auto completion list', 1) m.Append(ID_AUTOCOMP_INCLUDE_MAGIC, 'Include Magic Attributes', 'Include attributes visible to __getattr__ and __setattr__', 1) m.Append(ID_AUTOCOMP_INCLUDE_SINGLE, 'Include Single Underscores', 'Include attibutes prefixed by a single underscore', 1) m.Append(ID_AUTOCOMP_INCLUDE_DOUBLE, 'Include Double Underscores', 'Include attibutes prefixed by a double underscore', 1) m = self.calltipsMenu = wx.wxMenu() m.Append(ID_CALLTIPS_SHOW, 'Show Call Tips', 'Show call tips with argument signature and docstring', 1) m = self.optionsMenu = wx.wxMenu() m.AppendMenu(ID_AUTOCOMP, '&Auto Completion', self.autocompMenu, 'Auto Completion Options') m.AppendMenu(ID_CALLTIPS, '&Call Tips', self.calltipsMenu, 'Call Tip Options') m.Append(ID_WRAP, '&Wrap Lines', 'Wrap lines at right edge', 1) m = self.helpMenu = wx.wxMenu() m.AppendSeparator() m.Append(wx.wxID_ABOUT, '&About...', 'About this program') b = self.menuBar = wx.wxMenuBar() b.Append(self.fileMenu, '&File') b.Append(self.editMenu, '&Edit') b.Append(self.optionsMenu, '&Options') b.Append(self.helpMenu, '&Help') self.SetMenuBar(b) wx.EVT_MENU(self, wx.wxID_EXIT, self.OnExit) wx.EVT_MENU(self, wx.wxID_UNDO, self.OnUndo) wx.EVT_MENU(self, wx.wxID_REDO, self.OnRedo) wx.EVT_MENU(self, wx.wxID_CUT, self.OnCut) wx.EVT_MENU(self, wx.wxID_COPY, self.OnCopy) wx.EVT_MENU(self, ID_COPY_PLUS, self.OnCopyPlus) wx.EVT_MENU(self, wx.wxID_PASTE, self.OnPaste) wx.EVT_MENU(self, ID_PASTE_PLUS, self.OnPastePlus) wx.EVT_MENU(self, wx.wxID_CLEAR, self.OnClear) wx.EVT_MENU(self, wx.wxID_SELECTALL, self.OnSelectAll) wx.EVT_MENU(self, wx.wxID_ABOUT, self.OnAbout) wx.EVT_MENU(self, ID_AUTOCOMP_SHOW, self.OnAutoCompleteShow) wx.EVT_MENU(self, ID_AUTOCOMP_INCLUDE_MAGIC, self.OnAutoCompleteIncludeMagic) wx.EVT_MENU(self, ID_AUTOCOMP_INCLUDE_SINGLE, self.OnAutoCompleteIncludeSingle) wx.EVT_MENU(self, ID_AUTOCOMP_INCLUDE_DOUBLE, self.OnAutoCompleteIncludeDouble) wx.EVT_MENU(self, ID_CALLTIPS_SHOW, self.OnCallTipsShow) wx.EVT_MENU(self, ID_WRAP, self.OnWrap) wx.EVT_UPDATE_UI(self, wx.wxID_UNDO, self.OnUpdateMenu) wx.EVT_UPDATE_UI(self, wx.wxID_REDO, self.OnUpdateMenu) wx.EVT_UPDATE_UI(self, wx.wxID_CUT, self.OnUpdateMenu) wx.EVT_UPDATE_UI(self, wx.wxID_COPY, self.OnUpdateMenu) wx.EVT_UPDATE_UI(self, ID_COPY_PLUS, self.OnUpdateMenu) wx.EVT_UPDATE_UI(self, wx.wxID_PASTE, self.OnUpdateMenu) wx.EVT_UPDATE_UI(self, ID_PASTE_PLUS, self.OnUpdateMenu) wx.EVT_UPDATE_UI(self, wx.wxID_CLEAR, self.OnUpdateMenu) wx.EVT_UPDATE_UI(self, wx.wxID_SELECTALL, self.OnUpdateMenu) wx.EVT_UPDATE_UI(self, ID_AUTOCOMP_SHOW, self.OnUpdateMenu) wx.EVT_UPDATE_UI(self, ID_AUTOCOMP_INCLUDE_MAGIC, self.OnUpdateMenu) wx.EVT_UPDATE_UI(self, ID_AUTOCOMP_INCLUDE_SINGLE, self.OnUpdateMenu) wx.EVT_UPDATE_UI(self, ID_AUTOCOMP_INCLUDE_DOUBLE, self.OnUpdateMenu) wx.EVT_UPDATE_UI(self, ID_CALLTIPS_SHOW, self.OnUpdateMenu) wx.EVT_UPDATE_UI(self, ID_WRAP, self.OnUpdateMenu) def OnExit(self, event): self.Close(True) def OnUndo(self, event): win = wx.wxWindow_FindFocus() win.Undo() def OnRedo(self, event): win = wx.wxWindow_FindFocus() win.Redo() def OnCut(self, event): win = wx.wxWindow_FindFocus() win.Cut() def OnCopy(self, event): win = wx.wxWindow_FindFocus() win.Copy() def OnCopyPlus(self, event): win = wx.wxWindow_FindFocus() win.CopyWithPrompts() def OnPaste(self, event): win = wx.wxWindow_FindFocus() win.Paste() def OnPastePlus(self, event): win = wx.wxWindow_FindFocus() win.PasteAndRun() def OnClear(self, event): win = wx.wxWindow_FindFocus() win.Clear() def OnSelectAll(self, event): win = wx.wxWindow_FindFocus() win.SelectAll() def OnAbout(self, event): """Display an About window.""" title = 'About' text = 'Your message here.' dialog = wx.wxMessageDialog(self, text, title, wx.wxOK | wx.wxICON_INFORMATION) dialog.ShowModal() dialog.Destroy() def OnAutoCompleteShow(self, event): win = wx.wxWindow_FindFocus() win.autoComplete = event.IsChecked() def OnAutoCompleteIncludeMagic(self, event): win = wx.wxWindow_FindFocus() win.autoCompleteIncludeMagic = event.IsChecked() def OnAutoCompleteIncludeSingle(self, event): win = wx.wxWindow_FindFocus() win.autoCompleteIncludeSingle = event.IsChecked() def OnAutoCompleteIncludeDouble(self, event): win = wx.wxWindow_FindFocus() win.autoCompleteIncludeDouble = event.IsChecked() def OnCallTipsShow(self, event): win = wx.wxWindow_FindFocus() win.autoCallTip = event.IsChecked() def OnWrap(self, event): win = wx.wxWindow_FindFocus() win.SetWrapMode(event.IsChecked()) def OnUpdateMenu(self, event): """Update menu items based on current status.""" win = wx.wxWindow_FindFocus() id = event.GetId() event.Enable(True) try: if id == wx.wxID_UNDO: event.Enable(win.CanUndo()) elif id == wx.wxID_REDO: event.Enable(win.CanRedo()) elif id == wx.wxID_CUT: event.Enable(win.CanCut()) elif id == wx.wxID_COPY: event.Enable(win.CanCopy()) elif id == ID_COPY_PLUS: event.Enable(win.CanCopy() and hasattr(win, 'CopyWithPrompts')) elif id == wx.wxID_PASTE: event.Enable(win.CanPaste()) elif id == ID_PASTE_PLUS: event.Enable(win.CanPaste() and hasattr(win, 'PasteAndRun')) elif id == wx.wxID_CLEAR: event.Enable(win.CanCut()) elif id == wx.wxID_SELECTALL: event.Enable(hasattr(win, 'SelectAll')) elif id == ID_AUTOCOMP_SHOW: event.Check(win.autoComplete) elif id == ID_AUTOCOMP_INCLUDE_MAGIC: event.Check(win.autoCompleteIncludeMagic) elif id == ID_AUTOCOMP_INCLUDE_SINGLE: event.Check(win.autoCompleteIncludeSingle) elif id == ID_AUTOCOMP_INCLUDE_DOUBLE: event.Check(win.autoCompleteIncludeDouble) elif id == ID_CALLTIPS_SHOW: event.Check(win.autoCallTip) elif id == ID_WRAP: event.Check(win.GetWrapMode()) except AttributeError: # object with keyboard focus doesn't support this menu option. event.Enable(False) --- NEW FILE: base.py --- """Base editor.""" __author__ = "Patrick K. O'Brien <po...@or...>" __cvsid__ = "$Id: base.py,v 1.1 2003/03/29 02:42:04 pobrien Exp $" __revision__ = "$Revision: 1.1 $"[11:-2] from wxPython import wx from wxPython import stc import keyword import os import sys import time import dispatcher from version import VERSION try: True except NameError: True = 1==1 False = 1==0 if wx.wxPlatform == '__WXMSW__': FACES = { 'times' : 'Times New Roman', 'mono' : 'Courier New', 'helv' : 'Lucida Console', 'lucida' : 'Lucida Console', 'other' : 'Comic Sans MS', 'size' : 10, 'lnsize' : 9, 'backcol': '#FFFFFF', } else: # GTK FACES = { 'times' : 'Times', 'mono' : 'Courier', 'helv' : 'Helvetica', 'other' : 'new century schoolbook', 'size' : 12, 'lnsize' : 10, 'backcol': '#FFFFFF', } class Editor(stc.wxStyledTextCtrl): """Editor based on StyledTextCtrl.""" revision = __revision__ def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition, size=wx.wxDefaultSize, style=wx.wxCLIP_CHILDREN): """Create an Editor instance.""" stc.wxStyledTextCtrl.__init__(self, parent, id, pos, size, style) # Assign handlers for wxSTC events. stc.EVT_STC_UPDATEUI(self, id, self.OnUpdateUI) dispatcher.connect(receiver=self._fontsizer, signal='FontIncrease') dispatcher.connect(receiver=self._fontsizer, signal='FontDecrease') dispatcher.connect(receiver=self._fontsizer, signal='FontDefault') # Configure various defaults and user preferences. self.__config() def _fontsizer(self, signal): """Receiver for Font* signals.""" size = self.GetZoom() if signal == 'FontIncrease': size += 1 elif signal == 'FontDecrease': size -= 1 elif signal == 'FontDefault': size = 0 self.SetZoom(size) def __config(self): """Configure shell based on user preferences.""" self.SetMarginType(1, stc.wxSTC_MARGIN_NUMBER) self.SetMarginWidth(1, 40) self.SetLexer(stc.wxSTC_LEX_PYTHON) self.SetKeyWords(0, ' '.join(keyword.kwlist)) self.setStyles(FACES) self.SetViewWhiteSpace(False) self.SetTabWidth(4) self.SetUseTabs(False) # Do we want to automatically pop up command completion options? self.autoComplete = True self.autoCompleteIncludeMagic = True self.autoCompleteIncludeSingle = True self.autoCompleteIncludeDouble = True self.autoCompleteCaseInsensitive = True self.AutoCompSetIgnoreCase(self.autoCompleteCaseInsensitive) self.AutoCompSetAutoHide(False) self.AutoCompStops(' .,;:([)]}\'"\\<>%^&+-=*/|`') # Do we want to automatically pop up command argument help? self.autoCallTip = True self.CallTipSetBackground(wx.wxColour(255, 255, 232)) self.SetWrapMode(False) try: self.SetEndAtLastLine(False) except AttributeError: pass def setStyles(self, faces): """Configure font size, typeface and color for lexer.""" # Default style self.StyleSetSpec(stc.wxSTC_STYLE_DEFAULT, "face:%(mono)s,size:%(size)d,back:%(backcol)s" % \ faces) self.StyleClearAll() # Built in styles self.StyleSetSpec(stc.wxSTC_STYLE_LINENUMBER, "back:#C0C0C0,face:%(mono)s,size:%(lnsize)d" % faces) self.StyleSetSpec(stc.wxSTC_STYLE_CONTROLCHAR, "face:%(mono)s" % faces) self.StyleSetSpec(stc.wxSTC_STYLE_BRACELIGHT, "fore:#0000FF,back:#FFFF88") self.StyleSetSpec(stc.wxSTC_STYLE_BRACEBAD, "fore:#FF0000,back:#FFFF88") # Python styles self.StyleSetSpec(stc.wxSTC_P_DEFAULT, "face:%(mono)s" % faces) self.StyleSetSpec(stc.wxSTC_P_COMMENTLINE, "fore:#007F00,face:%(mono)s" % faces) self.StyleSetSpec(stc.wxSTC_P_NUMBER, "") self.StyleSetSpec(stc.wxSTC_P_STRING, "fore:#7F007F,face:%(mono)s" % faces) self.StyleSetSpec(stc.wxSTC_P_CHARACTER, "fore:#7F007F,face:%(mono)s" % faces) self.StyleSetSpec(stc.wxSTC_P_WORD, "fore:#00007F,bold") self.StyleSetSpec(stc.wxSTC_P_TRIPLE, "fore:#7F0000") self.StyleSetSpec(stc.wxSTC_P_TRIPLEDOUBLE, "fore:#000033,back:#FFFFE8") self.StyleSetSpec(stc.wxSTC_P_CLASSNAME, "fore:#0000FF,bold") self.StyleSetSpec(stc.wxSTC_P_DEFNAME, "fore:#007F7F,bold") self.StyleSetSpec(stc.wxSTC_P_OPERATOR, "") self.StyleSetSpec(stc.wxSTC_P_IDENTIFIER, "") self.StyleSetSpec(stc.wxSTC_P_COMMENTBLOCK, "fore:#7F7F7F") self.StyleSetSpec(stc.wxSTC_P_STRINGEOL, "fore:#000000,face:%(mono)s,back:#E0C0E0,eolfilled" % faces) def OnUpdateUI(self, event): """Check for matching braces.""" # If the auto-complete window is up let it do its thing. if self.AutoCompActive(): return braceAtCaret = -1 braceOpposite = -1 charBefore = None caretPos = self.GetCurrentPos() if caretPos > 0: charBefore = self.GetCharAt(caretPos - 1) styleBefore = self.GetStyleAt(caretPos - 1) # Check before. if charBefore and chr(charBefore) in '[]{}()' \ and styleBefore == stc.wxSTC_P_OPERATOR: braceAtCaret = caretPos - 1 # Check after. if braceAtCaret < 0: charAfter = self.GetCharAt(caretPos) styleAfter = self.GetStyleAt(caretPos) if charAfter and chr(charAfter) in '[]{}()' \ and styleAfter == stc.wxSTC_P_OPERATOR: braceAtCaret = caretPos if braceAtCaret >= 0: braceOpposite = self.BraceMatch(braceAtCaret) if braceAtCaret != -1 and braceOpposite == -1: self.BraceBadLight(braceAtCaret) else: self.BraceHighlight(braceAtCaret, braceOpposite) def CanCut(self): """Return true if text is selected and can be cut.""" return self.CanCopy() def CanCopy(self): """Return true if text is selected and can be copied.""" return self.GetSelectionStart() != self.GetSelectionEnd() def CanEdit(self): """Return true if editing should succeed.""" return True ## def Cut(self): ## """Remove selection and place it on the clipboard.""" ## if self.CanCut() and self.CanCopy(): ## if self.AutoCompActive(): ## self.AutoCompCancel() ## if self.CallTipActive(): ## self.CallTipCancel() ## self.Copy() ## self.ReplaceSelection('') ## def Copy(self): ## """Copy selection and place it on the clipboard.""" ## if self.CanCopy(): ## ps1 = str(sys.ps1) ## ps2 = str(sys.ps2) ## command = self.GetSelectedText() ## command = command.replace(os.linesep + ps2, os.linesep) ## command = command.replace(os.linesep + ps1, os.linesep) ## command = self.lstripPrompt(text=command) ## data = wx.wxTextDataObject(command) ## self._clip(data) ## def _clip(self, data): ## if wx.wxTheClipboard.Open(): ## wx.wxTheClipboard.UsePrimarySelection(False) ## wx.wxTheClipboard.SetData(data) ## wx.wxTheClipboard.Flush() ## wx.wxTheClipboard.Close() --- NEW FILE: PyAlaMode.py --- #!/usr/bin/env python """PyAlaMode is a programmer's editor.""" __author__ = "Patrick K. O'Brien <po...@or...>" __cvsid__ = "$Id: PyAlaMode.py,v 1.1 2003/03/29 02:42:04 pobrien Exp $" __revision__ = "$Revision: 1.1 $"[11:-2] import os import sys import wx from editor import EditorFrame try: True except NameError: True = 1==1 False = 1==0 class App(wx.App): """PyAlaMode standalone application.""" def __init__(self, flag, filename=None): self.filename = filename wx.App.__init__(self, flag) def OnInit(self): wx.InitAllImageHandlers() self.frame = EditorFrame() self.frame.FileOpen(self.filename) self.frame.Show() self.SetTopWindow(self.frame) return True def main(filename=None): app = App(False, filename) app.MainLoop() if __name__ == '__main__': sys.path.insert(0, os.curdir) filename = None if len(sys.argv) > 1: filename = os.path.realpath(sys.argv[1]) main(filename) Index: shell.py =================================================================== RCS file: /cvsroot/pycrust/PyCrust/shell.py,v retrieving revision 1.117 retrieving revision 1.118 diff -C2 -d -r1.117 -r1.118 *** shell.py 18 Mar 2003 17:14:35 -0000 1.117 --- shell.py 29 Mar 2003 02:42:01 -0000 1.118 *************** *** 11,38 **** __revision__ = "$Revision$"[11:-2] import keyword import os import sys import time from pseudo import PseudoFileIn from pseudo import PseudoFileOut from pseudo import PseudoFileErr - from shellmenu import ShellMenu from version import VERSION - import dispatcher - - try: - import wxd.d_wx - except ImportError: - from wxPython import wx - else: - from wxd.d_wx import wx - - try: - import wxd.d_stc - except ImportError: - from wxPython import stc - else: - from wxd.d_stc import stc try: --- 11,29 ---- __revision__ = "$Revision$"[11:-2] + from wxd.d_wx import wx + from wxd.d_stc import stc + import keyword import os import sys import time + + import base + import dispatcher + import frame from pseudo import PseudoFileIn from pseudo import PseudoFileOut from pseudo import PseudoFileErr from version import VERSION try: *************** *** 44,72 **** sys.ps3 = '<-- ' # Input prompt. ! NAVKEYS = (wx.WXK_END, wx.WXK_LEFT, wx.WXK_RIGHT, wx.WXK_UP, wx.WXK_DOWN, wx.WXK_PRIOR, wx.WXK_NEXT) - if wx.wxPlatform == '__WXMSW__': - faces = { 'times' : 'Times New Roman', - 'mono' : 'Courier New', - 'helv' : 'Lucida Console', - 'lucida' : 'Lucida Console', - 'other' : 'Comic Sans MS', - 'size' : 10, - 'lnsize' : 9, - 'backcol': '#FFFFFF', - } - else: # GTK - faces = { 'times' : 'Times', - 'mono' : 'Courier', - 'helv' : 'Helvetica', - 'other' : 'new century schoolbook', - 'size' : 12, - 'lnsize' : 10, - 'backcol': '#FFFFFF', - } - ! class ShellFrame(wx.wxFrame, ShellMenu): """Frame containing the PyCrust shell component.""" --- 35,43 ---- sys.ps3 = '<-- ' # Input prompt. ! NAVKEYS = (wx.WXK_END, wx.WXK_LEFT, wx.WXK_RIGHT, wx.WXK_UP, wx.WXK_DOWN, wx.WXK_PRIOR, wx.WXK_NEXT) ! class ShellFrame(frame.Frame): """Frame containing the PyCrust shell component.""" *************** *** 79,90 **** InterpClass=None, *args, **kwds): """Create a PyCrust ShellFrame instance.""" ! wx.wxFrame.__init__(self, parent, id, title, pos, size, style) intro = 'PyCrust %s - The Flakiest Python Shell' % VERSION intro += '\nSponsored by Orbtech - ' + \ 'Your source for Python programming expertise.' - self.CreateStatusBar() self.SetStatusText(intro.replace('\n', ', ')) - import images - self.SetIcon(images.getPyCrustIcon()) self.shell = Shell(parent=self, id=-1, introText=intro, locals=locals, InterpClass=InterpClass, --- 50,58 ---- InterpClass=None, *args, **kwds): """Create a PyCrust ShellFrame instance.""" ! frame.Frame.__init__(self, parent, id, title, pos, size, style) intro = 'PyCrust %s - The Flakiest Python Shell' % VERSION intro += '\nSponsored by Orbtech - ' + \ 'Your source for Python programming expertise.' self.SetStatusText(intro.replace('\n', ', ')) self.shell = Shell(parent=self, id=-1, introText=intro, locals=locals, InterpClass=InterpClass, *************** *** 92,97 **** # Override the shell so that status messages go to the status bar. self.shell.setStatusText = self.SetStatusText - self.createMenus() - wx.EVT_CLOSE(self, self.OnCloseWindow) def OnCloseWindow(self, event): --- 60,63 ---- *************** *** 192,197 **** ! class Shell(stc.wxStyledTextCtrl): ! """PyCrust Shell based on wxStyledTextCtrl.""" name = 'PyCrust Shell' --- 158,163 ---- ! class Shell(base.Editor): ! """PyCrust Shell based on StyledTextCtrl.""" name = 'PyCrust Shell' *************** *** 202,206 **** introText='', locals=None, InterpClass=None, *args, **kwds): """Create a PyCrust Shell instance.""" ! stc.wxStyledTextCtrl.__init__(self, parent, id, pos, size, style) if locals is None: locals = {} --- 168,173 ---- introText='', locals=None, InterpClass=None, *args, **kwds): """Create a PyCrust Shell instance.""" ! base.Editor.__init__(self, parent, id, pos, size, style) ! self.wrap() if locals is None: locals = {} *************** *** 219,223 **** self.reader = PseudoFileIn(self.readline, self.readlines) self.reader.input = '' ! self.reader.isreading = 0 # Set up the interpreter. self.interp = Interpreter(locals=locals, --- 186,190 ---- self.reader = PseudoFileIn(self.readline, self.readlines) self.reader.input = '' ! self.reader.isreading = False # Set up the interpreter. self.interp = Interpreter(locals=locals, *************** *** 233,237 **** self.promptPosEnd = 0 # Keep track of multi-line commands. ! self.more = 0 # Create the command history. Commands are added into the # front of the list (ie. at index 0) as they are entered. --- 200,204 ---- self.promptPosEnd = 0 # Keep track of multi-line commands. ! self.more = False # Create the command history. Commands are added into the # front of the list (ie. at index 0) as they are entered. *************** *** 244,259 **** self.historyIndex = -1 # Assign handlers for keyboard events. - wx.EVT_KEY_DOWN(self, self.OnKeyDown) wx.EVT_CHAR(self, self.OnChar) ! # Assign handlers for wxSTC events. ! stc.EVT_STC_UPDATEUI(self, id, self.OnUpdateUI) # Assign handler for idle time. self.waiting = False wx.EVT_IDLE(self, self.OnIdle) - dispatcher.connect(receiver=self.fontsizer, signal='FontIncrease') - dispatcher.connect(receiver=self.fontsizer, signal='FontDecrease') - dispatcher.connect(receiver=self.fontsizer, signal='FontDefault') - # Configure various defaults and user preferences. - self.config() # Display the introductory banner information. self.showIntro(introText) --- 211,219 ---- self.historyIndex = -1 # Assign handlers for keyboard events. wx.EVT_CHAR(self, self.OnChar) ! wx.EVT_KEY_DOWN(self, self.OnKeyDown) # Assign handler for idle time. self.waiting = False wx.EVT_IDLE(self, self.OnIdle) # Display the introductory banner information. self.showIntro(introText) *************** *** 267,314 **** wx.wxCallAfter(self.ScrollToLine, 0) - def fontsizer(self, signal): - """Receiver for Font* signals.""" - size = self.GetZoom() - if signal == 'FontIncrease': - size += 1 - elif signal == 'FontDecrease': - size -= 1 - elif signal == 'FontDefault': - size = 0 - self.SetZoom(size) - def destroy(self): del self.interp - pass - - def config(self): - """Configure shell based on user preferences.""" - self.SetMarginType(1, stc.wxSTC_MARGIN_NUMBER) - self.SetMarginWidth(1, 40) - - self.SetLexer(stc.wxSTC_LEX_PYTHON) - self.SetKeyWords(0, ' '.join(keyword.kwlist)) ! self.setStyles(faces) ! self.SetViewWhiteSpace(0) ! self.SetTabWidth(4) ! self.SetUseTabs(0) ! # Do we want to automatically pop up command completion options? ! self.autoComplete = 1 ! self.autoCompleteIncludeMagic = 1 ! self.autoCompleteIncludeSingle = 1 ! self.autoCompleteIncludeDouble = 1 ! self.autoCompleteCaseInsensitive = 1 ! self.AutoCompSetIgnoreCase(self.autoCompleteCaseInsensitive) ! self.AutoCompSetAutoHide(False) ! self.AutoCompStops(' .,;:([)]}\'"\\<>%^&+-=*/|`') ! # Do we want to automatically pop up command argument help? ! self.autoCallTip = 1 ! self.CallTipSetBackground(wx.wxColour(255, 255, 232)) ! self.wrap() ! try: ! self.SetEndAtLastLine(False) ! except AttributeError: ! pass def showIntro(self, text=''): --- 227,237 ---- wx.wxCallAfter(self.ScrollToLine, 0) def destroy(self): del self.interp ! def OnIdle(self, event): ! """Free the CPU to do other things.""" ! if self.waiting: ! time.sleep(0.05) def showIntro(self, text=''): *************** *** 355,408 **** self.push('') - def setStyles(self, faces): - """Configure font size, typeface and color for lexer.""" - - # Default style - self.StyleSetSpec(stc.wxSTC_STYLE_DEFAULT, - "face:%(mono)s,size:%(size)d,back:%(backcol)s" % \ - faces) - - self.StyleClearAll() - - # Built in styles - self.StyleSetSpec(stc.wxSTC_STYLE_LINENUMBER, - "back:#C0C0C0,face:%(mono)s,size:%(lnsize)d" % faces) - self.StyleSetSpec(stc.wxSTC_STYLE_CONTROLCHAR, - "face:%(mono)s" % faces) - self.StyleSetSpec(stc.wxSTC_STYLE_BRACELIGHT, - "fore:#0000FF,back:#FFFF88") - self.StyleSetSpec(stc.wxSTC_STYLE_BRACEBAD, - "fore:#FF0000,back:#FFFF88") - - # Python styles - self.StyleSetSpec(stc.wxSTC_P_DEFAULT, - "face:%(mono)s" % faces) - self.StyleSetSpec(stc.wxSTC_P_COMMENTLINE, - "fore:#007F00,face:%(mono)s" % faces) - self.StyleSetSpec(stc.wxSTC_P_NUMBER, - "") - self.StyleSetSpec(stc.wxSTC_P_STRING, - "fore:#7F007F,face:%(mono)s" % faces) - self.StyleSetSpec(stc.wxSTC_P_CHARACTER, - "fore:#7F007F,face:%(mono)s" % faces) - self.StyleSetSpec(stc.wxSTC_P_WORD, - "fore:#00007F,bold") - self.StyleSetSpec(stc.wxSTC_P_TRIPLE, - "fore:#7F0000") - self.StyleSetSpec(stc.wxSTC_P_TRIPLEDOUBLE, - "fore:#000033,back:#FFFFE8") - self.StyleSetSpec(stc.wxSTC_P_CLASSNAME, - "fore:#0000FF,bold") - self.StyleSetSpec(stc.wxSTC_P_DEFNAME, - "fore:#007F7F,bold") - self.StyleSetSpec(stc.wxSTC_P_OPERATOR, - "") - self.StyleSetSpec(stc.wxSTC_P_IDENTIFIER, - "") - self.StyleSetSpec(stc.wxSTC_P_COMMENTBLOCK, - "fore:#7F7F7F") - self.StyleSetSpec(stc.wxSTC_P_STRINGEOL, - "fore:#000000,face:%(mono)s,back:#E0C0E0,eolfilled" % faces) - def about(self): """Display information about PyCrust.""" --- 278,281 ---- *************** *** 419,461 **** self.write(text.strip()) - def OnIdle(self, event): - """Free the CPU to do other things.""" - if self.waiting: - time.sleep(0.05) - - def OnUpdateUI(self, event): - """Check for matching braces.""" - # If the auto-complete window is up let it do its thing. - if self.AutoCompActive(): - return - braceAtCaret = -1 - braceOpposite = -1 - charBefore = None - caretPos = self.GetCurrentPos() - if caretPos > 0: - charBefore = self.GetCharAt(caretPos - 1) - styleBefore = self.GetStyleAt(caretPos - 1) - - # Check before. - if charBefore and chr(charBefore) in '[]{}()' \ - and styleBefore == stc.wxSTC_P_OPERATOR: - braceAtCaret = caretPos - 1 - - # Check after. - if braceAtCaret < 0: - charAfter = self.GetCharAt(caretPos) - styleAfter = self.GetStyleAt(caretPos) - if charAfter and chr(charAfter) in '[]{}()' \ - and styleAfter == stc.wxSTC_P_OPERATOR: - braceAtCaret = caretPos - - if braceAtCaret >= 0: - braceOpposite = self.BraceMatch(braceAtCaret) - - if braceAtCaret != -1 and braceOpposite == -1: - self.BraceBadLight(braceAtCaret) - else: - self.BraceHighlight(braceAtCaret, braceOpposite) - def OnChar(self, event): """Keypress event handler. --- 292,295 ---- *************** *** 639,643 **** self.SetSelection(startpos, endpos) self.ReplaceSelection('') ! self.more = 0 def OnHistoryReplace(self, step): --- 473,477 ---- self.SetSelection(startpos, endpos) self.ReplaceSelection('') ! self.more = False def OnHistoryReplace(self, step): *************** *** 674,678 **** # The text up to the cursor is what we search for. numCharsAfterCursor = self.GetTextLength() - startpos ! searchText = self.getCommand(rstrip=0) if numCharsAfterCursor > 0: searchText = searchText[:-numCharsAfterCursor] --- 508,512 ---- # The text up to the cursor is what we search for. numCharsAfterCursor = self.GetTextLength() - startpos ! searchText = self.getCommand(rstrip=False) if numCharsAfterCursor > 0: searchText = searchText[:-numCharsAfterCursor] *************** *** 709,713 **** if self.CanEdit(): self.write(os.linesep) ! self.more = 1 self.prompt() --- 543,547 ---- if self.CanEdit(): self.write(os.linesep) ! self.more = True self.prompt() *************** *** 726,730 **** if self.CanEdit(): self.SetCurrentPos(endpos) ! self.interp.more = 0 command = self.GetTextRange(startpos, endpos) lines = command.split(os.linesep + ps2) --- 560,564 ---- if self.CanEdit(): self.SetCurrentPos(endpos) ! self.interp.more = False command = self.GetTextRange(startpos, endpos) lines = command.split(os.linesep + ps2) *************** *** 744,748 **** else: # If the line contains a command (even an invalid one). ! if self.getCommand(rstrip=0): command = self.getMultilineCommand() self.clearCommand() --- 578,582 ---- else: # If the line contains a command (even an invalid one). ! if self.getCommand(rstrip=False): command = self.getMultilineCommand() self.clearCommand() *************** *** 753,757 **** self.SetAnchor(thepos) ! def getMultilineCommand(self, rstrip=1): """Extract a multi-line command from the editor. --- 587,591 ---- self.SetAnchor(thepos) ! def getMultilineCommand(self, rstrip=True): """Extract a multi-line command from the editor. *************** *** 790,794 **** return command ! def getCommand(self, text=None, rstrip=1): """Extract a command from text which may include a shell prompt. --- 624,628 ---- return command ! def getCommand(self, text=None, rstrip=True): """Extract a command from text which may include a shell prompt. *************** *** 863,867 **** If this is a continuation line, autoindent as necessary.""" isreading = self.reader.isreading ! skip = 0 if isreading: prompt = str(sys.ps3) --- 697,701 ---- If this is a continuation line, autoindent as necessary.""" isreading = self.reader.isreading ! skip = False if isreading: prompt = str(sys.ps3) *************** *** 873,877 **** if pos > 0: if isreading: ! skip = 1 else: self.write(os.linesep) --- 707,711 ---- if pos > 0: if isreading: ! skip = True else: self.write(os.linesep) *************** *** 894,898 **** input = '' reader = self.reader ! reader.isreading = 1 self.prompt() try: --- 728,732 ---- input = '' reader = self.reader ! reader.isreading = True self.prompt() try: *************** *** 902,906 **** finally: reader.input = '' ! reader.isreading = 0 input = str(input) # In case of Unicode. return input --- 736,740 ---- finally: reader.input = '' ! reader.isreading = False input = str(input) # In case of Unicode. return input *************** *** 939,943 **** self.ClearAll() ! def run(self, command, prompt=1, verbose=1): """Execute command as if it was typed in directly. >>> shell.run('print "this"') --- 773,777 ---- self.ClearAll() ! def run(self, command, prompt=True, verbose=True): """Execute command as if it was typed in directly. >>> shell.run('print "this"') *************** *** 963,969 **** if command[:6] == 'shell.': # Run shell methods silently. ! self.run(command, prompt=0, verbose=0) else: ! self.run(command, prompt=0, verbose=1) finally: file.close() --- 797,803 ---- if command[:6] == 'shell.': # Run shell methods silently. ! self.run(command, prompt=False, verbose=False) else: ! self.run(command, prompt=False, verbose=True) finally: file.close() *************** *** 1008,1012 **** self.write(text) ! def redirectStdin(self, redirect=1): """If redirect is true then sys.stdin will come from the shell.""" if redirect: --- 842,846 ---- self.write(text) ! def redirectStdin(self, redirect=True): """If redirect is true then sys.stdin will come from the shell.""" if redirect: *************** *** 1015,1019 **** sys.stdin = self.stdin ! def redirectStdout(self, redirect=1): """If redirect is true then sys.stdout will go to the shell.""" if redirect: --- 849,853 ---- sys.stdin = self.stdin ! def redirectStdout(self, redirect=True): """If redirect is true then sys.stdout will go to the shell.""" if redirect: *************** *** 1022,1026 **** sys.stdout = self.stdout ! def redirectStderr(self, redirect=1): """If redirect is true then sys.stderr will go to the shell.""" if redirect: --- 856,860 ---- sys.stdout = self.stdout ! def redirectStderr(self, redirect=True): """If redirect is true then sys.stderr will go to the shell.""" if redirect: *************** *** 1034,1051 **** and self.GetSelectionStart() >= self.promptPosEnd \ and self.GetSelectionEnd() >= self.promptPosEnd: ! return 1 else: ! return 0 ! ! def CanCopy(self): ! """Return true if text is selected and can be copied.""" ! return self.GetSelectionStart() != self.GetSelectionEnd() def CanPaste(self): """Return true if a paste should succeed.""" ! if self.CanEdit() and stc.wxStyledTextCtrl.CanPaste(self): ! return 1 else: ! return 0 def CanEdit(self): --- 868,881 ---- and self.GetSelectionStart() >= self.promptPosEnd \ and self.GetSelectionEnd() >= self.promptPosEnd: ! return True else: ! return False def CanPaste(self): """Return true if a paste should succeed.""" ! if self.CanEdit() and base.Editor.CanPaste(self): ! return True else: ! return False def CanEdit(self): *************** *** 1054,1060 **** if self.GetSelectionStart() >= self.promptPosEnd \ and self.GetSelectionEnd() >= self.promptPosEnd: ! return 1 else: ! return 0 else: return self.GetCurrentPos() >= self.promptPosEnd --- 884,890 ---- if self.GetSelectionStart() >= self.promptPosEnd \ and self.GetSelectionEnd() >= self.promptPosEnd: ! return True else: ! return False else: return self.GetCurrentPos() >= self.promptPosEnd *************** *** 1172,1176 **** wx.wxTheClipboard.Close() ! def wrap(self, wrap=1): """Sets whether text is word wrapped.""" try: --- 1002,1006 ---- wx.wxTheClipboard.Close() ! def wrap(self, wrap=True): """Sets whether text is word wrapped.""" try: *************** *** 1181,1187 **** def zoom(self, points=0): """Set the zoom level. ! This number of points is added to the size of all fonts. It may be positive to magnify or negative to reduce.""" self.SetZoom(points) - --- 1011,1016 ---- def zoom(self, points=0): """Set the zoom level. ! This number of points is added to the size of all fonts. It may be positive to magnify or negative to reduce.""" self.SetZoom(points) Index: filling.py =================================================================== RCS file: /cvsroot/pycrust/PyCrust/filling.py,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** filling.py 19 Mar 2003 02:42:17 -0000 1.54 --- filling.py 29 Mar 2003 02:42:01 -0000 1.55 *************** *** 7,12 **** from wxPython import wx ! from wxPython import stc ! from version import VERSION import dispatcher import inspect --- 7,12 ---- from wxPython import wx ! ! import base import dispatcher import inspect *************** *** 15,18 **** --- 15,19 ---- import sys import types + from version import VERSION try: *************** *** 46,52 **** revision = __revision__ ! def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition, ! size=wx.wxDefaultSize, style=wx.wxTR_DEFAULT_STYLE, ! rootObject=None, rootLabel=None, rootIsNamespace=0, static=False): """Create a PyCrust FillingTree instance.""" --- 47,53 ---- revision = __revision__ ! def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition, ! size=wx.wxDefaultSize, style=wx.wxTR_DEFAULT_STYLE, ! rootObject=None, rootLabel=None, rootIsNamespace=False, static=False): """Create a PyCrust FillingTree instance.""" *************** *** 56,60 **** if rootObject is None: rootObject = __main__.__dict__ ! self.rootIsNamespace = 1 if rootObject is __main__.__dict__ and rootLabel is None: rootLabel = 'locals()' --- 57,61 ---- if rootObject is None: rootObject = __main__.__dict__ ! self.rootIsNamespace = True if rootObject is __main__.__dict__ and rootLabel is None: rootLabel = 'locals()' *************** *** 238,242 **** def setStatusText(self, text): """Display status information.""" ! # This method will likely be replaced by the enclosing app to # do something more interesting, like write to a status bar. --- 239,243 ---- def setStatusText(self, text): """Display status information.""" ! # This method will likely be replaced by the enclosing app to # do something more interesting, like write to a status bar. *************** *** 244,284 **** ! if wx.wxPlatform == '__WXMSW__': ! faces = { 'times' : 'Times New Roman', ! 'mono' : 'Courier New', ! 'helv' : 'Lucida Console', ! 'lucida' : 'Lucida Console', ! 'other' : 'Comic Sans MS', ! 'size' : 10, ! 'lnsize' : 9, ! 'backcol': '#FFFFFF', ! } ! else: # GTK ! faces = { 'times' : 'Times', ! 'mono' : 'Courier', ! 'helv' : 'Helvetica', ! 'other' : 'new century schoolbook', ! 'size' : 12, ! 'lnsize' : 10, ! 'backcol': '#FFFFFF', ! } ! ! class FillingText(stc.wxStyledTextCtrl): ! """PyCrust FillingText based on wxStyledTextCtrl.""" ! ! name = 'PyCrust Filling Text' revision = __revision__ ! def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition, size=wx.wxDefaultSize, style=wx.wxCLIP_CHILDREN, static=False): ! """Create a PyCrust FillingText instance.""" ! stc.wxStyledTextCtrl.__init__(self, parent, id, pos, size, style) # Configure various defaults and user preferences. ! self.config() ! dispatcher.connect(receiver=self.fontsizer, signal='FontIncrease') ! dispatcher.connect(receiver=self.fontsizer, signal='FontDecrease') ! dispatcher.connect(receiver=self.fontsizer, signal='FontDefault') if not static: dispatcher.connect(receiver=self.push, signal='Interpreter.push') --- 245,263 ---- ! class FillingText(base.Editor): ! """FillingText based on StyledTextCtrl.""" ! name = 'PyFilling Text' revision = __revision__ ! def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition, size=wx.wxDefaultSize, style=wx.wxCLIP_CHILDREN, static=False): ! """Create a FillingText instance.""" ! base.Editor.__init__(self, parent, id, pos, size, style) # Configure various defaults and user preferences. ! self.SetReadOnly(True) ! self.SetWrapMode(True) ! self.SetMarginWidth(1, 0) if not static: dispatcher.connect(receiver=self.push, signal='Interpreter.push') *************** *** 288,387 **** self.Refresh() - def fontsizer(self, signal): - """Receiver for Font* signals.""" - size = self.GetZoom() - if signal == 'FontIncrease': - size += 1 - elif signal == 'FontDecrease': - size -= 1 - elif signal == 'FontDefault': - size = 0 - self.SetZoom(size) - - def config(self): - """Configure shell based on user preferences.""" - self.SetMarginWidth(1, 0) - - self.SetLexer(stc.wxSTC_LEX_PYTHON) - self.SetKeyWords(0, ' '.join(keyword.kwlist)) - - self.setStyles(faces) - self.SetViewWhiteSpace(0) - self.SetTabWidth(4) - self.SetUseTabs(0) - self.SetReadOnly(1) - try: - self.SetWrapMode(1) - except AttributeError: - pass - - def setStyles(self, faces): - """Configure font size, typeface and color for lexer.""" - - # Default style - self.StyleSetSpec(stc.wxSTC_STYLE_DEFAULT, - "face:%(mono)s,size:%(size)d" % faces) - - self.StyleClearAll() - - # Built in styles - self.StyleSetSpec(stc.wxSTC_STYLE_LINENUMBER, - "back:#C0C0C0,face:%(mono)s,size:%(lnsize)d" % faces) - self.StyleSetSpec(stc.wxSTC_STYLE_CONTROLCHAR, - "face:%(mono)s" % faces) - self.StyleSetSpec(stc.wxSTC_STYLE_BRACELIGHT, - "fore:#0000FF,back:#FFFF88") - self.StyleSetSpec(stc.wxSTC_STYLE_BRACEBAD, - "fore:#FF0000,back:#FFFF88") - - # Python styles - self.StyleSetSpec(stc.wxSTC_P_DEFAULT, - "face:%(mono)s" % faces) - self.StyleSetSpec(stc.wxSTC_P_COMMENTLINE, - "fore:#007F00,face:%(mono)s" % faces) - self.StyleSetSpec(stc.wxSTC_P_NUMBER, - "") - self.StyleSetSpec(stc.wxSTC_P_STRING, - "fore:#7F007F,face:%(mono)s" % faces) - self.StyleSetSpec(stc.wxSTC_P_CHARACTER, - "fore:#7F007F,face:%(mono)s" % faces) - self.StyleSetSpec(stc.wxSTC_P_WORD, - "fore:#00007F,bold") - self.StyleSetSpec(stc.wxSTC_P_TRIPLE, - "fore:#7F0000") - self.StyleSetSpec(stc.wxSTC_P_TRIPLEDOUBLE, - "fore:#000033,back:#FFFFE8") - self.StyleSetSpec(stc.wxSTC_P_CLASSNAME, - "fore:#0000FF,bold") - self.StyleSetSpec(stc.wxSTC_P_DEFNAME, - "fore:#007F7F,bold") - self.StyleSetSpec(stc.wxSTC_P_OPERATOR, - "") - self.StyleSetSpec(stc.wxSTC_P_IDENTIFIER, - "") - self.StyleSetSpec(stc.wxSTC_P_COMMENTBLOCK, - "fore:#7F7F7F") - self.StyleSetSpec(stc.wxSTC_P_STRINGEOL, - "fore:#000000,face:%(mono)s,back:#E0C0E0,eolfilled" % faces) - def SetText(self, *args, **kwds): ! self.SetReadOnly(0) ! stc.wxStyledTextCtrl.SetText(self, *args, **kwds) ! self.SetReadOnly(1) class Filling(wx.wxSplitterWindow): ! """PyCrust Filling based on wxSplitterWindow.""" ! ! name = 'PyCrust Filling' revision = __revision__ ! ! def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition, size=wx.wxDefaultSize, style=wx.wxSP_3D, name='Filling Window', rootObject=None, ! rootLabel=None, rootIsNamespace=0, static=False): ! """Create a PyCrust Filling instance.""" wx.wxSplitterWindow.__init__(self, parent, id, pos, size, style, name) ! self.tree = FillingTree(parent=self, rootObject=rootObject, rootLabel=rootLabel, rootIsNamespace=rootIsNamespace, --- 267,289 ---- self.Refresh() def SetText(self, *args, **kwds): ! self.SetReadOnly(False) ! base.Editor.SetText(self, *args, **kwds) ! self.SetReadOnly(True) class Filling(wx.wxSplitterWindow): ! """Filling based on wxSplitterWindow.""" ! ! name = 'PyFilling' revision = __revision__ ! ! def __init__(self, parent, id=-1, pos=wx.wxDefaultPosition, size=wx.wxDefaultSize, style=wx.wxSP_3D, name='Filling Window', rootObject=None, ! rootLabel=None, rootIsNamespace=False, static=False): ! """Create a Filling instance.""" wx.wxSplitterWindow.__init__(self, parent, id, pos, size, style, name) ! self.tree = FillingTree(parent=self, rootObject=rootObject, rootLabel=rootLabel, rootIsNamespace=rootIsNamespace, *************** *** 398,411 **** class FillingFrame(wx.wxFrame): ! """Frame containing the PyCrust filling, or namespace tree component.""" ! ! name = 'PyCrust Filling Frame' revision = __revision__ ! ! def __init__(self, parent=None, id=-1, title='PyFilling', ! pos=wx.wxDefaultPosition, size=wx.wxDefaultSize, ! style=wx.wxDEFAULT_FRAME_STYLE, rootObject=None, ! rootLabel=None, rootIsNamespace=0, static=False): ! """Create a PyCrust FillingFrame instance.""" wx.wxFrame.__init__(self, parent, id, title, pos, size, style) intro = 'PyFilling - The Tastiest Namespace Inspector' --- 300,313 ---- class FillingFrame(wx.wxFrame): ! """Frame containing the namespace tree component.""" ! ! name = 'PyFilling Frame' revision = __revision__ ! ! def __init__(self, parent=None, id=-1, title='PyFilling', ! pos=wx.wxDefaultPosition, size=(600, 400), ! style=wx.wxDEFAULT_FRAME_STYLE, rootObject=None, ! rootLabel=None, rootIsNamespace=False, static=False): ! """Create a FillingFrame instance.""" wx.wxFrame.__init__(self, parent, id, title, pos, size, style) intro = 'PyFilling - The Tastiest Namespace Inspector' *************** *** 414,419 **** import images self.SetIcon(images.getPyCrustIcon()) ! self.filling = Filling(parent=self, rootObject=rootObject, ! rootLabel=rootLabel, rootIsNamespace=rootIsNamespace, static=static) --- 316,321 ---- import images self.SetIcon(images.getPyCrustIcon()) ! self.filling = Filling(parent=self, rootObject=rootObject, ! rootLabel=rootLabel, rootIsNamespace=rootIsNamespace, static=static) *************** *** 424,428 **** class App(wx.wxApp): """PyFilling standalone application.""" ! def OnInit(self): wx.wxInitAllImageHandlers() --- 326,330 ---- class App(wx.wxApp): """PyFilling standalone application.""" ! def OnInit(self): wx.wxInitAllImageHandlers() *************** *** 431,436 **** self.SetTopWindow(self.fillingFrame) return True - - - - --- 333,334 ---- Index: crust.py =================================================================== RCS file: /cvsroot/pycrust/PyCrust/crust.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** crust.py 18 Mar 2003 17:14:38 -0000 1.36 --- crust.py 29 Mar 2003 02:42:04 -0000 1.37 *************** *** 6,13 **** from wxPython import wx ! from filling import Filling import os from shell import Shell - from shellmenu import ShellMenu from version import VERSION --- 6,17 ---- from wxPython import wx ! import os + import sys + + import dispatcher + from filling import Filling + import frame from shell import Shell from version import VERSION *************** *** 74,78 **** def __init__(self, parent=None, id=-1): - import dispatcher style = wx.wxTE_MULTILINE | wx.wxTE_READONLY | wx.wxTE_RICH2 wx.wxTextCtrl.__init__(self, parent=parent, id=id, style=style) --- 78,81 ---- *************** *** 89,93 **** def __init__(self, parent=None, id=-1): - import dispatcher style = wx.wxTE_MULTILINE | wx.wxTE_READONLY | \ wx.wxTE_RICH2 | wx.wxTE_DONTWRAP --- 92,95 ---- *************** *** 109,113 **** def __init__(self, parent=None, id=-1): - import dispatcher style = wx.wxTE_MULTILINE | wx.wxTE_READONLY | \ wx.wxTE_RICH2 | wx.wxTE_DONTWRAP --- 111,114 ---- *************** *** 125,129 **** ! class CrustFrame(wx.wxFrame, ShellMenu): """Frame containing all the PyCrust components.""" --- 126,130 ---- ! class CrustFrame(frame.Frame): """Frame containing all the PyCrust components.""" *************** *** 131,169 **** revision = __revision__ ! def __init__(self, parent=None, id=-1, title='PyCrust', ! pos=wx.wxDefaultPosition, size=wx.wxDefaultSize, ! style=wx.wxDEFAULT_FRAME_STYLE, ! rootObject=None, rootLabel=None, rootIsNamespace=True, locals=None, InterpClass=None, *args, **kwds): """Create a PyCrust CrustFrame instance.""" ! wx.wxFrame.__init__(self, parent, id, title, pos, size, style) intro = 'PyCrust %s - The Flakiest Python Shell' % VERSION intro += '\nSponsored by Orbtech - ' intro += 'Your source for Python programming expertise.' - self.CreateStatusBar() self.SetStatusText(intro.replace('\n', ', ')) ! import images ! self.SetIcon(images.getPyCrustIcon()) ! self.crust = Crust(parent=self, intro=intro, ! rootObject=rootObject, ! rootLabel=rootLabel, ! rootIsNamespace=rootIsNamespace, ! locals=locals, InterpClass=InterpClass, *args, **kwds) # Override the filling so that status messages go to the status bar. self.crust.filling.tree.setStatusText = self.SetStatusText # Override the shell so that status messages go to the status bar. ! self.crust.shell.setStatusText = self.SetStatusText # Fix a problem with the sash shrinking to nothing. self.crust.filling.SetSashPosition(200) - self.shell = self.crust.shell - self.createMenus() - wx.EVT_CLOSE(self, self.OnCloseWindow) # Set focus to the shell editor. ! self.crust.shell.SetFocus() def OnCloseWindow(self, event): self.crust.shell.destroy() self.Destroy() ! --- 132,181 ---- revision = __revision__ ! def __init__(self, parent=None, id=-1, title='PyCrust', ! pos=wx.wxDefaultPosition, size=wx.wxDefaultSize, ! style=wx.wxDEFAULT_FRAME_STYLE, ! rootObject=None, rootLabel=None, rootIsNamespace=True, locals=None, InterpClass=None, *args, **kwds): """Create a PyCrust CrustFrame instance.""" ! frame.Frame.__init__(self, parent, id, title, pos, size, style) intro = 'PyCrust %s - The Flakiest Python Shell' % VERSION intro += '\nSponsored by Orbtech - ' intro += 'Your source for Python programming expertise.' self.SetStatusText(intro.replace('\n', ', ')) ! self.crust = Crust(parent=self, intro=intro, ! rootObject=rootObject, ! rootLabel=rootLabel, ! rootIsNamespace=rootIsNamespace, ! locals=locals, InterpClass=InterpClass, *args, **kwds) + self.shell = self.crust.shell # Override the filling so that status messages go to the status bar. self.crust.filling.tree.setStatusText = self.SetStatusText # Override the shell so that status messages go to the status bar. ! self.shell.setStatusText = self.SetStatusText # Fix a problem with the sash shrinking to nothing. self.crust.filling.SetSashPosition(200) # Set focus to the shell editor. ! self.shell.SetFocus() def OnCloseWindow(self, event): + """Event handler for closing.""" self.crust.shell.destroy() self.Destroy() ! def OnAbout(self, event): ! """Display an About window.""" ! title = 'About PyCrust' ! text = 'PyCrust %s\n\n' % VERSION + \ ! 'Yet another Python shell, only flakier.\n\n' + \ ! 'Half-baked by Patrick K. O\'Brien,\n' + \ ! 'the other half is still in the oven.\n\n' + \ ! 'Shell Revision: %s\n' % self.shell.revision + \ ! 'Interpreter Revision: %s\n\n' % self.shell.interp.revision + \ ! 'Python Version: %s\n' % sys.version.split()[0] + \ ! 'wxPython Version: %s\n' % wx.__version__ + \ ! 'Platform: %s\n' % sys.platform ! dialog = wx.wxMessageDialog(self, text, title, ! wx.wxOK | wx.wxICON_INFORMATION) ! dialog.ShowModal() ! dialog.Destroy() Index: CHANGES.txt =================================================================== RCS file: /cvsroot/pycrust/PyCrust/CHANGES.txt,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** CHANGES.txt 24 Mar 2003 15:07:57 -0000 1.29 --- CHANGES.txt 29 Mar 2003 02:42:04 -0000 1.30 *************** *** 25,28 **** --- 25,32 ---- * examples.txt (in wx/examples) + Added PyAlaMode.py code editor. + + Major refactoring to support editor and shell from the same base. + |