Compare commits
1 Commits
SDL_1_2_11
...
B4_MAC
Author | SHA1 | Date | |
---|---|---|---|
|
09489675f9 |
@@ -1,181 +0,0 @@
|
|||||||
# Configure paths for SDL
|
|
||||||
# Sam Lantinga 9/21/99
|
|
||||||
# stolen from Manish Singh
|
|
||||||
# stolen back from Frank Belew
|
|
||||||
# stolen from Manish Singh
|
|
||||||
# Shamelessly stolen from Owen Taylor
|
|
||||||
|
|
||||||
dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
|
|
||||||
dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
|
|
||||||
dnl
|
|
||||||
AC_DEFUN([AM_PATH_SDL],
|
|
||||||
[dnl
|
|
||||||
dnl Get the cflags and libraries from the sdl-config script
|
|
||||||
dnl
|
|
||||||
AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
|
|
||||||
sdl_prefix="$withval", sdl_prefix="")
|
|
||||||
AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
|
|
||||||
sdl_exec_prefix="$withval", sdl_exec_prefix="")
|
|
||||||
AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
|
|
||||||
, enable_sdltest=yes)
|
|
||||||
|
|
||||||
if test x$sdl_exec_prefix != x ; then
|
|
||||||
sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
|
|
||||||
if test x${SDL_CONFIG+set} != xset ; then
|
|
||||||
SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if test x$sdl_prefix != x ; then
|
|
||||||
sdl_args="$sdl_args --prefix=$sdl_prefix"
|
|
||||||
if test x${SDL_CONFIG+set} != xset ; then
|
|
||||||
SDL_CONFIG=$sdl_prefix/bin/sdl-config
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "x$prefix" != xNONE; then
|
|
||||||
PATH="$prefix/bin:$prefix/usr/bin:$PATH"
|
|
||||||
fi
|
|
||||||
AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
|
|
||||||
min_sdl_version=ifelse([$1], ,0.11.0,$1)
|
|
||||||
AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
|
|
||||||
no_sdl=""
|
|
||||||
if test "$SDL_CONFIG" = "no" ; then
|
|
||||||
no_sdl=yes
|
|
||||||
else
|
|
||||||
SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
|
|
||||||
SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
|
|
||||||
|
|
||||||
sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
|
|
||||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
|
||||||
sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
|
|
||||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
|
||||||
sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
|
|
||||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
|
||||||
if test "x$enable_sdltest" = "xyes" ; then
|
|
||||||
ac_save_CFLAGS="$CFLAGS"
|
|
||||||
ac_save_CXXFLAGS="$CXXFLAGS"
|
|
||||||
ac_save_LIBS="$LIBS"
|
|
||||||
CFLAGS="$CFLAGS $SDL_CFLAGS"
|
|
||||||
CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
|
|
||||||
LIBS="$LIBS $SDL_LIBS"
|
|
||||||
dnl
|
|
||||||
dnl Now check if the installed SDL is sufficiently new. (Also sanity
|
|
||||||
dnl checks the results of sdl-config to some extent
|
|
||||||
dnl
|
|
||||||
rm -f conf.sdltest
|
|
||||||
AC_TRY_RUN([
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "SDL.h"
|
|
||||||
|
|
||||||
char*
|
|
||||||
my_strdup (char *str)
|
|
||||||
{
|
|
||||||
char *new_str;
|
|
||||||
|
|
||||||
if (str)
|
|
||||||
{
|
|
||||||
new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
|
|
||||||
strcpy (new_str, str);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
new_str = NULL;
|
|
||||||
|
|
||||||
return new_str;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
int major, minor, micro;
|
|
||||||
char *tmp_version;
|
|
||||||
|
|
||||||
/* This hangs on some systems (?)
|
|
||||||
system ("touch conf.sdltest");
|
|
||||||
*/
|
|
||||||
{ FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
|
|
||||||
|
|
||||||
/* HP/UX 9 (%@#!) writes to sscanf strings */
|
|
||||||
tmp_version = my_strdup("$min_sdl_version");
|
|
||||||
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
|
|
||||||
printf("%s, bad version string\n", "$min_sdl_version");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($sdl_major_version > major) ||
|
|
||||||
(($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
|
|
||||||
(($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
|
|
||||||
printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
|
|
||||||
printf("*** best to upgrade to the required version.\n");
|
|
||||||
printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
|
|
||||||
printf("*** to point to the correct copy of sdl-config, and remove the file\n");
|
|
||||||
printf("*** config.cache before re-running configure\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
|
|
||||||
CFLAGS="$ac_save_CFLAGS"
|
|
||||||
CXXFLAGS="$ac_save_CXXFLAGS"
|
|
||||||
LIBS="$ac_save_LIBS"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if test "x$no_sdl" = x ; then
|
|
||||||
AC_MSG_RESULT(yes)
|
|
||||||
ifelse([$2], , :, [$2])
|
|
||||||
else
|
|
||||||
AC_MSG_RESULT(no)
|
|
||||||
if test "$SDL_CONFIG" = "no" ; then
|
|
||||||
echo "*** The sdl-config script installed by SDL could not be found"
|
|
||||||
echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
|
|
||||||
echo "*** your path, or set the SDL_CONFIG environment variable to the"
|
|
||||||
echo "*** full path to sdl-config."
|
|
||||||
else
|
|
||||||
if test -f conf.sdltest ; then
|
|
||||||
:
|
|
||||||
else
|
|
||||||
echo "*** Could not run SDL test program, checking why..."
|
|
||||||
CFLAGS="$CFLAGS $SDL_CFLAGS"
|
|
||||||
CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
|
|
||||||
LIBS="$LIBS $SDL_LIBS"
|
|
||||||
AC_TRY_LINK([
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "SDL.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{ return 0; }
|
|
||||||
#undef main
|
|
||||||
#define main K_and_R_C_main
|
|
||||||
], [ return 0; ],
|
|
||||||
[ echo "*** The test program compiled, but did not run. This usually means"
|
|
||||||
echo "*** that the run-time linker is not finding SDL or finding the wrong"
|
|
||||||
echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
|
|
||||||
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
|
|
||||||
echo "*** to the installed location Also, make sure you have run ldconfig if that"
|
|
||||||
echo "*** is required on your system"
|
|
||||||
echo "***"
|
|
||||||
echo "*** If you have an old version installed, it is best to remove it, although"
|
|
||||||
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
|
|
||||||
[ echo "*** The test program failed to compile or link. See the file config.log for the"
|
|
||||||
echo "*** exact error that occured. This usually means SDL was incorrectly installed"
|
|
||||||
echo "*** or that you have moved SDL since it was installed. In the latter case, you"
|
|
||||||
echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
|
|
||||||
CFLAGS="$ac_save_CFLAGS"
|
|
||||||
CXXFLAGS="$ac_save_CXXFLAGS"
|
|
||||||
LIBS="$ac_save_LIBS"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
SDL_CFLAGS=""
|
|
||||||
SDL_LIBS=""
|
|
||||||
ifelse([$3], , :, [$3])
|
|
||||||
fi
|
|
||||||
AC_SUBST(SDL_CFLAGS)
|
|
||||||
AC_SUBST(SDL_LIBS)
|
|
||||||
rm -f conf.sdltest
|
|
||||||
])
|
|
9014
wxPython/contrib/stc/stc_.cpp
Normal file
9014
wxPython/contrib/stc/stc_.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1279
wxPython/contrib/stc/stc_.py
Normal file
1279
wxPython/contrib/stc/stc_.py
Normal file
File diff suppressed because it is too large
Load Diff
1396
wxPython/demo/data/stc.h
Normal file
1396
wxPython/demo/data/stc.h
Normal file
File diff suppressed because it is too large
Load Diff
216
wxPython/wxPython/lib/PyCrust/PyCrust.py
Normal file
216
wxPython/wxPython/lib/PyCrust/PyCrust.py
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
"""PyCrust is a python shell application.
|
||||||
|
"""
|
||||||
|
|
||||||
|
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
|
||||||
|
__cvsid__ = "$Id$"
|
||||||
|
__date__ = "July 1, 2001"
|
||||||
|
__version__ = "$Revision$"[11:-2]
|
||||||
|
|
||||||
|
from wxPython.wx import *
|
||||||
|
|
||||||
|
from version import VERSION
|
||||||
|
from shell import Shell
|
||||||
|
|
||||||
|
ID_AUTOCOMP = NewId()
|
||||||
|
ID_AUTOCOMP_SHOW = NewId()
|
||||||
|
ID_AUTOCOMP_INCLUDE_MAGIC = NewId()
|
||||||
|
ID_AUTOCOMP_INCLUDE_SINGLE = NewId()
|
||||||
|
ID_AUTOCOMP_INCLUDE_DOUBLE = NewId()
|
||||||
|
ID_CALLTIPS = NewId()
|
||||||
|
ID_CALLTIPS_SHOW = NewId()
|
||||||
|
|
||||||
|
|
||||||
|
class Frame(wxFrame):
|
||||||
|
"""Main window for the PyCrust application."""
|
||||||
|
def __init__(self, parent, id, title):
|
||||||
|
"""Create the main frame object for the application."""
|
||||||
|
wxFrame.__init__(self, parent, id, title)
|
||||||
|
intro = 'Welcome To PyCrust %s - The Flakiest Python Shell' % VERSION
|
||||||
|
self.CreateStatusBar()
|
||||||
|
self.SetStatusText(intro)
|
||||||
|
self.icon = wxIcon('PyCrust.ico', wxBITMAP_TYPE_ICO)
|
||||||
|
self.SetIcon(self.icon)
|
||||||
|
self.createMenus()
|
||||||
|
# Create the shell, which will create a default interpreter.
|
||||||
|
locals = {'__app__': 'PyCrust Application'}
|
||||||
|
self.shell = Shell(parent=self, id=-1, introText=intro, locals=locals)
|
||||||
|
# Override the shell so that status messages go to the status bar.
|
||||||
|
self.shell.setStatusText = self.SetStatusText
|
||||||
|
|
||||||
|
def createMenus(self):
|
||||||
|
m = self.fileMenu = wxMenu()
|
||||||
|
m.AppendSeparator()
|
||||||
|
m.Append(wxID_EXIT, 'E&xit', 'Exit PyCrust')
|
||||||
|
|
||||||
|
m = self.editMenu = wxMenu()
|
||||||
|
m.Append(wxID_UNDO, '&Undo \tCtrl+Z', 'Undo the last action')
|
||||||
|
m.Append(wxID_REDO, '&Redo \tCtrl+Y', 'Redo the last undone action')
|
||||||
|
m.AppendSeparator()
|
||||||
|
m.Append(wxID_CUT, 'Cu&t \tCtrl+X', 'Cut the selection')
|
||||||
|
m.Append(wxID_COPY, '&Copy \tCtrl+C', 'Copy the selection')
|
||||||
|
m.Append(wxID_PASTE, '&Paste \tCtrl+V', 'Paste')
|
||||||
|
m.AppendSeparator()
|
||||||
|
m.Append(wxID_CLEAR, 'Cle&ar \tDel', 'Delete the selection')
|
||||||
|
m.Append(wxID_SELECTALL, 'Select A&ll \tCtrl+A', 'Select all text')
|
||||||
|
|
||||||
|
m = self.autocompMenu = wxMenu()
|
||||||
|
m.Append(ID_AUTOCOMP_SHOW, 'Show Auto Completion', \
|
||||||
|
'Show auto completion during dot syntax', checkable=1)
|
||||||
|
m.Append(ID_AUTOCOMP_INCLUDE_MAGIC, 'Include Magic Attributes', \
|
||||||
|
'Include attributes visible to __getattr__ and __setattr__', checkable=1)
|
||||||
|
m.Append(ID_AUTOCOMP_INCLUDE_SINGLE, 'Include Single Underscores', \
|
||||||
|
'Include attibutes prefixed by a single underscore', checkable=1)
|
||||||
|
m.Append(ID_AUTOCOMP_INCLUDE_DOUBLE, 'Include Double Underscores', \
|
||||||
|
'Include attibutes prefixed by a double underscore', checkable=1)
|
||||||
|
|
||||||
|
m = self.calltipsMenu = wxMenu()
|
||||||
|
m.Append(ID_CALLTIPS_SHOW, 'Show Call Tips', \
|
||||||
|
'Show call tips with argument specifications', checkable=1)
|
||||||
|
|
||||||
|
m = self.optionsMenu = wxMenu()
|
||||||
|
m.AppendMenu(ID_AUTOCOMP, '&Auto Completion', self.autocompMenu, \
|
||||||
|
'Auto Completion Options')
|
||||||
|
m.AppendMenu(ID_CALLTIPS, '&Call Tips', self.calltipsMenu, \
|
||||||
|
'Call Tip Options')
|
||||||
|
|
||||||
|
m = self.helpMenu = wxMenu()
|
||||||
|
m.AppendSeparator()
|
||||||
|
m.Append(wxID_ABOUT, '&About...', 'About PyCrust')
|
||||||
|
|
||||||
|
b = self.menuBar = wxMenuBar()
|
||||||
|
b.Append(self.fileMenu, '&File')
|
||||||
|
b.Append(self.editMenu, '&Edit')
|
||||||
|
b.Append(self.optionsMenu, '&Options')
|
||||||
|
b.Append(self.helpMenu, '&Help')
|
||||||
|
self.SetMenuBar(b)
|
||||||
|
|
||||||
|
EVT_MENU(self, wxID_EXIT, self.OnExit)
|
||||||
|
EVT_MENU(self, wxID_UNDO, self.OnUndo)
|
||||||
|
EVT_MENU(self, wxID_REDO, self.OnRedo)
|
||||||
|
EVT_MENU(self, wxID_CUT, self.OnCut)
|
||||||
|
EVT_MENU(self, wxID_COPY, self.OnCopy)
|
||||||
|
EVT_MENU(self, wxID_PASTE, self.OnPaste)
|
||||||
|
EVT_MENU(self, wxID_CLEAR, self.OnClear)
|
||||||
|
EVT_MENU(self, wxID_SELECTALL, self.OnSelectAll)
|
||||||
|
EVT_MENU(self, wxID_ABOUT, self.OnAbout)
|
||||||
|
EVT_MENU(self, ID_AUTOCOMP_SHOW, self.OnAutoCompleteShow)
|
||||||
|
EVT_MENU(self, ID_AUTOCOMP_INCLUDE_MAGIC, self.OnAutoCompleteIncludeMagic)
|
||||||
|
EVT_MENU(self, ID_AUTOCOMP_INCLUDE_SINGLE, self.OnAutoCompleteIncludeSingle)
|
||||||
|
EVT_MENU(self, ID_AUTOCOMP_INCLUDE_DOUBLE, self.OnAutoCompleteIncludeDouble)
|
||||||
|
EVT_MENU(self, ID_CALLTIPS_SHOW, self.OnCallTipsShow)
|
||||||
|
|
||||||
|
EVT_UPDATE_UI(self, wxID_UNDO, self.OnUpdateMenu)
|
||||||
|
EVT_UPDATE_UI(self, wxID_REDO, self.OnUpdateMenu)
|
||||||
|
EVT_UPDATE_UI(self, wxID_CUT, self.OnUpdateMenu)
|
||||||
|
EVT_UPDATE_UI(self, wxID_COPY, self.OnUpdateMenu)
|
||||||
|
EVT_UPDATE_UI(self, wxID_PASTE, self.OnUpdateMenu)
|
||||||
|
EVT_UPDATE_UI(self, wxID_CLEAR, self.OnUpdateMenu)
|
||||||
|
EVT_UPDATE_UI(self, ID_AUTOCOMP_SHOW, self.OnUpdateMenu)
|
||||||
|
EVT_UPDATE_UI(self, ID_AUTOCOMP_INCLUDE_MAGIC, self.OnUpdateMenu)
|
||||||
|
EVT_UPDATE_UI(self, ID_AUTOCOMP_INCLUDE_SINGLE, self.OnUpdateMenu)
|
||||||
|
EVT_UPDATE_UI(self, ID_AUTOCOMP_INCLUDE_DOUBLE, self.OnUpdateMenu)
|
||||||
|
EVT_UPDATE_UI(self, ID_CALLTIPS_SHOW, self.OnUpdateMenu)
|
||||||
|
|
||||||
|
def OnExit(self, event):
|
||||||
|
self.Close(true)
|
||||||
|
|
||||||
|
def OnUndo(self, event):
|
||||||
|
self.shell.Undo()
|
||||||
|
|
||||||
|
def OnRedo(self, event):
|
||||||
|
self.shell.Redo()
|
||||||
|
|
||||||
|
def OnCut(self, event):
|
||||||
|
self.shell.Cut()
|
||||||
|
|
||||||
|
def OnCopy(self, event):
|
||||||
|
self.shell.Copy()
|
||||||
|
|
||||||
|
def OnPaste(self, event):
|
||||||
|
self.shell.Paste()
|
||||||
|
|
||||||
|
def OnClear(self, event):
|
||||||
|
self.shell.Clear()
|
||||||
|
|
||||||
|
def OnSelectAll(self, event):
|
||||||
|
self.shell.SelectAll()
|
||||||
|
|
||||||
|
def OnAbout(self, event):
|
||||||
|
"""Display an About PyCrust 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' % self.shell.interp.revision
|
||||||
|
dialog = wxMessageDialog(self, text, title, wxOK | wxICON_INFORMATION)
|
||||||
|
dialog.ShowModal()
|
||||||
|
dialog.Destroy()
|
||||||
|
|
||||||
|
def OnAutoCompleteShow(self, event):
|
||||||
|
self.shell.autoComplete = event.IsChecked()
|
||||||
|
|
||||||
|
def OnAutoCompleteIncludeMagic(self, event):
|
||||||
|
self.shell.autoCompleteIncludeMagic = event.IsChecked()
|
||||||
|
|
||||||
|
def OnAutoCompleteIncludeSingle(self, event):
|
||||||
|
self.shell.autoCompleteIncludeSingle = event.IsChecked()
|
||||||
|
|
||||||
|
def OnAutoCompleteIncludeDouble(self, event):
|
||||||
|
self.shell.autoCompleteIncludeDouble = event.IsChecked()
|
||||||
|
|
||||||
|
def OnCallTipsShow(self, event):
|
||||||
|
self.shell.autoCallTip = event.IsChecked()
|
||||||
|
|
||||||
|
def OnUpdateMenu(self, event):
|
||||||
|
"""Update menu items based on current status."""
|
||||||
|
id = event.GetId()
|
||||||
|
if id == wxID_UNDO:
|
||||||
|
event.Enable(self.shell.CanUndo())
|
||||||
|
elif id == wxID_REDO:
|
||||||
|
event.Enable(self.shell.CanRedo())
|
||||||
|
elif id == wxID_CUT:
|
||||||
|
event.Enable(self.shell.CanCut())
|
||||||
|
elif id == wxID_COPY:
|
||||||
|
event.Enable(self.shell.CanCopy())
|
||||||
|
elif id == wxID_PASTE:
|
||||||
|
event.Enable(self.shell.CanPaste())
|
||||||
|
elif id == wxID_CLEAR:
|
||||||
|
event.Enable(self.shell.CanCut())
|
||||||
|
elif id == ID_AUTOCOMP_SHOW:
|
||||||
|
event.Check(self.shell.autoComplete)
|
||||||
|
elif id == ID_AUTOCOMP_INCLUDE_MAGIC:
|
||||||
|
event.Check(self.shell.autoCompleteIncludeMagic)
|
||||||
|
elif id == ID_AUTOCOMP_INCLUDE_SINGLE:
|
||||||
|
event.Check(self.shell.autoCompleteIncludeSingle)
|
||||||
|
elif id == ID_AUTOCOMP_INCLUDE_DOUBLE:
|
||||||
|
event.Check(self.shell.autoCompleteIncludeDouble)
|
||||||
|
elif id == ID_CALLTIPS_SHOW:
|
||||||
|
event.Check(self.shell.autoCallTip)
|
||||||
|
|
||||||
|
|
||||||
|
class App(wxApp):
|
||||||
|
def OnInit(self):
|
||||||
|
parent = None
|
||||||
|
id = -1
|
||||||
|
title = 'PyCrust'
|
||||||
|
self.frame = Frame(parent, id, title)
|
||||||
|
self.frame.Show(true)
|
||||||
|
self.SetTopWindow(self.frame)
|
||||||
|
return true
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
import sys
|
||||||
|
application = App(0)
|
||||||
|
# Add the application object to the sys module's namespace.
|
||||||
|
# This allows a shell user to do:
|
||||||
|
# >>> import sys
|
||||||
|
# >>> sys.application.whatever
|
||||||
|
sys.application = application
|
||||||
|
application.MainLoop()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
211
wxPython/wxPython/lib/editor/py_editor.py
Normal file
211
wxPython/wxPython/lib/editor/py_editor.py
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
# (C)opyright by Dirk Holtwick, 1999
|
||||||
|
# ----------------------------------
|
||||||
|
# holtwick@spirito.de
|
||||||
|
# http://www.spirito.de/pyde
|
||||||
|
|
||||||
|
from editor import *
|
||||||
|
from string import *
|
||||||
|
from keyword import *
|
||||||
|
from tokenizer import *
|
||||||
|
|
||||||
|
"""
|
||||||
|
This module will be loaded by the main
|
||||||
|
window. It implements some methods that
|
||||||
|
are typical for Python sources.
|
||||||
|
"""
|
||||||
|
|
||||||
|
class wxPyEditor(wxEditor):
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
|
def __init__(self, parent, id,
|
||||||
|
pos=wxDefaultPosition, size=wxDefaultSize, style=0):
|
||||||
|
wxEditor.__init__(self, parent, id, pos, size, style)
|
||||||
|
self.SetFontTab([
|
||||||
|
wxNamedColour('black'),
|
||||||
|
wxNamedColour('blue'),
|
||||||
|
wxNamedColour('red'),
|
||||||
|
wxNamedColour('darkgreen'),
|
||||||
|
wxNamedColour('brown')
|
||||||
|
])
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
|
def OnUpdateHighlight(self, line = -1):
|
||||||
|
if line>=0:
|
||||||
|
t = self.text[line].text
|
||||||
|
syn = []
|
||||||
|
|
||||||
|
toks = Tokenizer(t).tokens()
|
||||||
|
for type, string, begin, end in toks:
|
||||||
|
if type == "KEY":
|
||||||
|
syn.append((begin, 1))
|
||||||
|
syn.append((end, 0))
|
||||||
|
elif type == "COMMENT":
|
||||||
|
syn.append((begin, 2))
|
||||||
|
elif type == "STRING":
|
||||||
|
syn.append((begin, 3))
|
||||||
|
syn.append((end, 0))
|
||||||
|
elif type == "NUMBER":
|
||||||
|
syn.append((begin, 4))
|
||||||
|
syn.append((end, 0))
|
||||||
|
elif type == "NAME":
|
||||||
|
if string=="self":
|
||||||
|
syn.append((begin, 4))
|
||||||
|
syn.append((end, 0))
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
self.text[line].syntax = syn
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
|
def OnUpdateSyntax(self, line = -1):
|
||||||
|
if line>=0:
|
||||||
|
"""
|
||||||
|
tx, syn, m = self.text[line]
|
||||||
|
pre = 0
|
||||||
|
for i in range(0,len(tx)):
|
||||||
|
if tx[i] != " ":
|
||||||
|
pre = i
|
||||||
|
break
|
||||||
|
t = tx[pre:]
|
||||||
|
|
||||||
|
t = Tokenizer(t).line()
|
||||||
|
|
||||||
|
t = tx[:pre] + t
|
||||||
|
self.text[line] = t, syn, m
|
||||||
|
"""
|
||||||
|
self.OnUpdateHighlight(line)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
|
def OnTabulator(self, event):
|
||||||
|
add = +1
|
||||||
|
if event.ShiftDown():
|
||||||
|
add = -1
|
||||||
|
t = self.GetTextLine(self.cy)
|
||||||
|
if strip(t):
|
||||||
|
indent = self.GetIndent(t)
|
||||||
|
# print indent
|
||||||
|
t = t[indent:]
|
||||||
|
tabs = indent / self.tabsize
|
||||||
|
# for i in range(0,tabs+add):
|
||||||
|
t = (" " * 4 * (tabs+add)) + t
|
||||||
|
self.SetTextLine(self.cy, t)
|
||||||
|
elif add>0:
|
||||||
|
self.InsertText(" ")
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
|
def FindQuote(self, lineno, quote_type='"""', direction=1):
|
||||||
|
"""find line containing the matching quote"""
|
||||||
|
l =lineno +direction
|
||||||
|
while (l < len(self.text)-1) and (l >= 0):
|
||||||
|
if find(self.text[l].text, quote_type) >=0: return l
|
||||||
|
l =l +direction
|
||||||
|
return None
|
||||||
|
|
||||||
|
def FindNextLine(self, lineno, direction=1):
|
||||||
|
"""get the next line of code (skipping comment lines and empty lines)"""
|
||||||
|
l =lineno +direction
|
||||||
|
while (l < len(self.text)-1) and (l >= 0):
|
||||||
|
str =lstrip(self.text[l].text)
|
||||||
|
if (len(str) >0) and (str[0] !="#"): return l
|
||||||
|
l =l +direction
|
||||||
|
return None
|
||||||
|
|
||||||
|
def Fold(self):
|
||||||
|
l = self.GetLine(self.cy)
|
||||||
|
line = self.text[l]
|
||||||
|
t = line.text
|
||||||
|
|
||||||
|
# fold ...
|
||||||
|
if line.editable:
|
||||||
|
|
||||||
|
# 3*quotes
|
||||||
|
qpos =find(t, '"""')
|
||||||
|
if qpos >=0: qtype ='"""'
|
||||||
|
else:
|
||||||
|
qpos =find(t, "'''")
|
||||||
|
if qpos >=0: qtype ="'''"
|
||||||
|
|
||||||
|
if (qpos >=0) and (find(t[qpos+3:], qtype) <0):
|
||||||
|
closing_quote =self.FindQuote(l, qtype)
|
||||||
|
if closing_quote !=None:
|
||||||
|
line.editable = not line.editable
|
||||||
|
l =l +1
|
||||||
|
while l <= closing_quote:
|
||||||
|
self.text[l].visible =self.text[l].visible +1
|
||||||
|
l =l +1
|
||||||
|
|
||||||
|
else: # try normal fold on leading whitespace
|
||||||
|
lim = self.GetIndent(t)
|
||||||
|
lnext =self.FindNextLine(l)
|
||||||
|
if (lnext !=None) \
|
||||||
|
and (self.GetIndent(self.text[lnext].text) >lim):
|
||||||
|
line.editable =FALSE
|
||||||
|
lstart =l +1
|
||||||
|
l =self.FindNextLine(l)
|
||||||
|
while (l !=None) \
|
||||||
|
and (self.GetIndent(self.text[l].text) >lim):
|
||||||
|
l =self.FindNextLine(l)
|
||||||
|
if l ==None:
|
||||||
|
# fold till the end
|
||||||
|
l =len(self.text)
|
||||||
|
for line in self.text[lstart:l]:
|
||||||
|
line.visible =line.visible +1
|
||||||
|
|
||||||
|
# ... or unfold
|
||||||
|
else:
|
||||||
|
lim = line.visible + 1
|
||||||
|
line.editable = not line.editable
|
||||||
|
|
||||||
|
l = l + 1
|
||||||
|
line = self.text[l]
|
||||||
|
while (l < (len(self.text) -1)) and (line.visible>=lim):
|
||||||
|
line.visible = line.visible - 1
|
||||||
|
l = l + 1
|
||||||
|
line = self.text[l]
|
||||||
|
|
||||||
|
def FoldAll(self):
|
||||||
|
self.CalcLines()
|
||||||
|
self.cx = 0
|
||||||
|
self.cy = len(self.lines) - 1
|
||||||
|
prev_indent =0
|
||||||
|
# following loop is exited in two cases:
|
||||||
|
# when self.cy becomes 0 (topmost level is not folded by FoldAll)
|
||||||
|
# or when FindNextLine() returns None (all remaining lines till
|
||||||
|
# the beginning of the text are empty or comments)
|
||||||
|
while self.cy:
|
||||||
|
t = self.GetTextLine(self.cy)
|
||||||
|
# indent-based folding
|
||||||
|
indent =self.GetIndent(t)
|
||||||
|
if indent <prev_indent:
|
||||||
|
self.Fold()
|
||||||
|
prev_indent =indent
|
||||||
|
# triple-quote folding
|
||||||
|
qpos =find(t, '"""')
|
||||||
|
if qpos >=0: qtype ='"""'
|
||||||
|
else:
|
||||||
|
qpos =find(t, "'''")
|
||||||
|
if qpos >=0: qtype ="'''"
|
||||||
|
if (qpos >=0) and (find(t[qpos+3:], qtype) <0):
|
||||||
|
closing_quote =self.FindQuote(self.cy, qtype, -1)
|
||||||
|
if closing_quote !=None:
|
||||||
|
# XXX potential bug: unmatched triple quotes
|
||||||
|
self.cy =closing_quote
|
||||||
|
self.Fold()
|
||||||
|
self.cy =self.FindNextLine(self.cy, -1)
|
||||||
|
if self.cy ==None: self.cy =0
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
|
def OnFold(self):
|
||||||
|
self.Fold()
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
|
def OnInit(self):
|
||||||
|
#self.FoldAll()
|
||||||
|
pass
|
||||||
|
|
60
wxPython/wxPython/lib/editor/tokenizer.py
Normal file
60
wxPython/wxPython/lib/editor/tokenizer.py
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
from tokenize import *
|
||||||
|
from keyword import *
|
||||||
|
from string import *
|
||||||
|
|
||||||
|
class Tokenizer:
|
||||||
|
"""
|
||||||
|
Simple class to create a list of token-tuples like:
|
||||||
|
|
||||||
|
(type, string, first, last)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
t = Tokenizer('def hallo(du): # juchee')
|
||||||
|
print t.tokens()
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, text):
|
||||||
|
self.text = text
|
||||||
|
self.toks = []
|
||||||
|
try:
|
||||||
|
tokenize(self.readline, self.get)
|
||||||
|
except TokenError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tokens(self):
|
||||||
|
return self.toks
|
||||||
|
|
||||||
|
def get(self, type, string, begin, end, l):
|
||||||
|
#print begin,end
|
||||||
|
h1, b = begin
|
||||||
|
h2, e = end
|
||||||
|
tname = tok_name[type]
|
||||||
|
if iskeyword(string):
|
||||||
|
tname = "KEY"
|
||||||
|
self.toks.append( (tname, string, b, e) )
|
||||||
|
|
||||||
|
def readline(self):
|
||||||
|
t = self.text
|
||||||
|
self.text = ""
|
||||||
|
return t
|
||||||
|
|
||||||
|
def line(self):
|
||||||
|
pre = ""
|
||||||
|
out = ""
|
||||||
|
for type, string, begin, end in self.toks:
|
||||||
|
if (pre in ["NAME","KEY"]) and (not string in [".",",","("]):
|
||||||
|
out = out + " "
|
||||||
|
|
||||||
|
if type in ["NAME","KEY"]:
|
||||||
|
out = out + string
|
||||||
|
elif type=="OP":
|
||||||
|
if string in [",",":"]:
|
||||||
|
out = out + string + " "
|
||||||
|
else:
|
||||||
|
out = out + string
|
||||||
|
else:
|
||||||
|
out = out + string
|
||||||
|
pre = type
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user