Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
7096c4526a |
14
Makefile.in
14
Makefile.in
@@ -324,7 +324,7 @@ $(build_libdir)/@WX_LIBRARY_NAME_SHARED@: $(OBJECTS)
|
||||
# but this seems to result in problems with libwx_gtk being linked in twice
|
||||
$(build_libdir)/@WX_LIBRARY_NAME_SHARED_GL@: glcanvas.o $(build_libdir)/@WX_LIBRARY_NAME_SHARED@
|
||||
@$(INSTALL) -d $(build_libdir)
|
||||
$(SHARED_LD) $@ $(SONAME_FLAGS_GL) glcanvas.o $(EXTRALIBS) $(OPENGLLIBS)
|
||||
$(SHARED_LD) $@ $(SONAME_FLAGS_GL) glcanvas.o $(EXTRALIBS) $(LDFLAGS_GL) $(OPENGLLIBS)
|
||||
|
||||
$(build_libdir)/@WX_RESOURCES_MACOSX_DATA@: $(MACRESOURCES)
|
||||
@$(INSTALL) -d $(build_libdir)
|
||||
@@ -1362,6 +1362,7 @@ UTILS_DIST: ALL_GUI_DIST
|
||||
cp $(UTILSDIR)/emulator/src/*.in $(DISTDIR)/utils/emulator/src
|
||||
cp $(UTILSDIR)/emulator/src/*.cpp $(DISTDIR)/utils/emulator/src
|
||||
cp $(UTILSDIR)/emulator/src/*.jpg $(DISTDIR)/utils/emulator/src
|
||||
cp $(UTILSDIR)/emulator/src/*.xpm $(DISTDIR)/utils/emulator/src
|
||||
cp $(UTILSDIR)/emulator/src/*.wxe $(DISTDIR)/utils/emulator/src
|
||||
cp $(UTILSDIR)/emulator/docs/*.txt $(DISTDIR)/utils/emulator/docs
|
||||
cp $(UTILSDIR)/emulator/docs/*.jpg $(DISTDIR)/utils/emulator/docs
|
||||
@@ -1450,19 +1451,22 @@ PYTHON_DIST:
|
||||
wxPython/demo/bmp_source \
|
||||
wxPython/demo/data \
|
||||
wxPython/demo/dllwidget \
|
||||
wxPython/distrib \
|
||||
wxPython/distutils \
|
||||
wxPython/distutils/command \
|
||||
wxPython/docs \
|
||||
wxPython/docs/screenshots \
|
||||
wxPython/samples/StyleEditor \
|
||||
wxPython/samples/doodle \
|
||||
wxPython/samples/embedded \
|
||||
wxPython/samples/frogedit \
|
||||
wxPython/samples/hangman \
|
||||
wxPython/samples/pySketch \
|
||||
wxPython/samples/pySketch/images \
|
||||
wxPython/samples/wxProject \
|
||||
wxPython/samples/wx_examples \
|
||||
wxPython/samples/wx_examples/basic \
|
||||
wxPython/samples/wx_examples/hello \
|
||||
wxPython/samples/wx_examples/screenshots \
|
||||
wxPython/distutils \
|
||||
wxPython/distutils/command \
|
||||
wxPython/scripts \
|
||||
wxPython/src \
|
||||
wxPython/src/gtk \
|
||||
@@ -1472,6 +1476,8 @@ PYTHON_DIST:
|
||||
wxPython/wx/lib/editor \
|
||||
wxPython/wx/lib/mixins \
|
||||
wxPython/wx/py \
|
||||
wxPython/wx/tools \
|
||||
wxPython/wx/tools/XRCed \
|
||||
wxPython/wxPython \
|
||||
wxPython/wxPython/lib \
|
||||
wxPython/wxPython/lib/PyCrust \
|
||||
|
156
configure.in
156
configure.in
@@ -25,20 +25,12 @@ dnl When making releases do:
|
||||
dnl
|
||||
dnl WX_RELEASE_NUMBER += 1
|
||||
dnl
|
||||
dnl ..and update WX_CURRENT, WX_RELEASE and WX_AGE according to the
|
||||
dnl following rules:
|
||||
dnl
|
||||
dnl If any changes have been made to the public interface, that is if any
|
||||
dnl exported class, method, global or global type has been added, removed
|
||||
dnl or changed in any way, then do: WX_CURRENT += 1
|
||||
dnl
|
||||
dnl If source changes have been made that *do not* alter the public
|
||||
dnl interface then do: WX_REVISION += 1
|
||||
dnl If WX_CURRENT was incremented (as above) instead do: WX_REVISION = 0
|
||||
dnl
|
||||
dnl If any public interface was added, do: WX_AGE += 1
|
||||
dnl If any public interface was removed (or altered in a way effectively
|
||||
dnl removing the previous definition), instead do: WX_AGE = 0
|
||||
dnl In case of backwards incompatible change (shouldn't happen
|
||||
dnl but if it does, do change the soname here to avoid run-time
|
||||
dnl problems!), do WX_CURRENT++; WX_REVISION = WX_AGE = 0. Otherwise
|
||||
dnl (i.e. normal case), WX_CURRENT should be left unchanged, but you
|
||||
dnl should do WX_REVISION++ and, if any public methods were added to
|
||||
dnl the library, also WX_AGE++.
|
||||
dnl
|
||||
dnl When the major or minor version numbers are incremented, all the above
|
||||
dnl variables should be reset to 0.
|
||||
@@ -48,7 +40,7 @@ dnl libwx_$(TOOLKIT)-$(WX_RELEASE).so.$(WX_CURRENT).$(WX_REVISION).$(WX_AGE)
|
||||
|
||||
WX_MAJOR_VERSION_NUMBER=2
|
||||
WX_MINOR_VERSION_NUMBER=4
|
||||
WX_RELEASE_NUMBER=1
|
||||
WX_RELEASE_NUMBER=2
|
||||
|
||||
WX_VERSION=$WX_MAJOR_VERSION_NUMBER.$WX_MINOR_VERSION_NUMBER.$WX_RELEASE_NUMBER
|
||||
WX_RELEASE=$WX_MAJOR_VERSION_NUMBER.$WX_MINOR_VERSION_NUMBER
|
||||
@@ -56,8 +48,8 @@ WX_RELEASE=$WX_MAJOR_VERSION_NUMBER.$WX_MINOR_VERSION_NUMBER
|
||||
WX_MSW_VERSION=$WX_MAJOR_VERSION_NUMBER$WX_MINOR_VERSION_NUMBER$WX_RELEASE_NUMBER
|
||||
|
||||
WX_CURRENT=0
|
||||
WX_REVISION=0
|
||||
WX_AGE=0
|
||||
WX_REVISION=1
|
||||
WX_AGE=1
|
||||
|
||||
|
||||
dnl ------------------------------------------------------------------------
|
||||
@@ -66,12 +58,14 @@ dnl ------------------------------------------------------------------------
|
||||
|
||||
dnl assume Unix
|
||||
USE_UNIX=1
|
||||
USE_OS2=0
|
||||
USE_WIN32=0
|
||||
USE_DOS=0
|
||||
USE_BEOS=0
|
||||
USE_MAC=0
|
||||
|
||||
USE_LINUX=
|
||||
USE_GNU=
|
||||
USE_SGI=
|
||||
USE_HPUX=
|
||||
USE_SYSV=
|
||||
@@ -151,6 +145,16 @@ case "${host}" in
|
||||
fi
|
||||
DEFAULT_DEFAULT_wxUSE_GTK=1
|
||||
;;
|
||||
*-*-gnu* )
|
||||
USE_GNU=1
|
||||
AC_DEFINE(__GNU__)
|
||||
TMP=`uname -m`
|
||||
if test "x$TMP" = "xalpha"; then
|
||||
USE_ALPHA=1
|
||||
AC_DEFINE(__ALPHA__)
|
||||
fi
|
||||
DEFAULT_DEFAULT_wxUSE_GTK=1
|
||||
;;
|
||||
*-*-irix5* | *-*-irix6* )
|
||||
USE_SGI=1
|
||||
USE_SVR4=1
|
||||
@@ -257,9 +261,14 @@ case "${host}" in
|
||||
;;
|
||||
|
||||
*-pc-os2_emx | *-pc-os2-emx )
|
||||
USE_OS2=1
|
||||
dnl Now both USE_OS2 and USE_UNIX should be set to 1 !!
|
||||
AC_DEFINE(__EMX__)
|
||||
PROGRAM_EXT=".exe"
|
||||
DEFAULT_DEFAULT_wxUSE_PM=1
|
||||
dnl "c++" wrapper is not always available, so always use plain gcc.
|
||||
CXX=gcc
|
||||
LDFLAGS="$LDFLAGS -Zcrtdll -Zsysv-signals"
|
||||
;;
|
||||
|
||||
powerpc-*-darwin* )
|
||||
@@ -474,6 +483,8 @@ if test $DEBUG_CONFIGURE = 1; then
|
||||
DEFAULT_wxUSE_IFF=no
|
||||
DEFAULT_wxUSE_XPM=no
|
||||
DEFAULT_wxUSE_ICO_CUR=no
|
||||
DEFAULT_wxUSE_IMAGE_LOADING_IN_MSW=no
|
||||
DEFAULT_wxUSE_RESOURCE_LOADING_IN_MSW=no
|
||||
else
|
||||
DEFAULT_wxUSE_UNIVERSAL=no
|
||||
|
||||
@@ -649,6 +660,8 @@ else
|
||||
DEFAULT_wxUSE_PNM=yes
|
||||
DEFAULT_wxUSE_XPM=yes
|
||||
DEFAULT_wxUSE_ICO_CUR=yes
|
||||
DEFAULT_wxUSE_IMAGE_LOADING_IN_MSW=yes
|
||||
DEFAULT_wxUSE_RESOURCE_LOADING_IN_MSW=yes
|
||||
fi
|
||||
|
||||
dnl WX_ARG_WITH should be used to select whether an external package will be
|
||||
@@ -1035,6 +1048,8 @@ WX_ARG_ENABLE(iff, [ --enable-iff use iff images (IFF file f
|
||||
WX_ARG_ENABLE(pnm, [ --enable-pnm use pnm images (PNM file format)], wxUSE_PNM)
|
||||
WX_ARG_ENABLE(xpm, [ --enable-xpm use xpm images (XPM file format)], wxUSE_XPM)
|
||||
WX_ARG_ENABLE(ico_cur, [ --enable-icocur use Windows ICO and CUR formats], wxUSE_ICO_CUR)
|
||||
WX_ARG_ENABLE(dynamic_dib, [ --disable-dynamic_dib don't use dynamic DIB loading/saving code under MSW], wxUSE_IMAGE_LOADING_IN_MSW, disable)
|
||||
WX_ARG_ENABLE(dynamic_ico_cur, [ --disable-dynamic_ico_cur don't use dynamic icon/cursor loading/saving code under MSW], wxUSE_RESOURCE_LOADING_IN_MSW, disable)
|
||||
|
||||
fi
|
||||
|
||||
@@ -1345,6 +1360,8 @@ AC_PROG_LN_S
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl When we are using gcc on OS/2, we want to be either using resources (PM)
|
||||
dnl or a more complete POSIX emulation for Motif/GTK+/X11
|
||||
dnl Moreover we need to link explicitly against either stdcpp.a or stdcxx.a
|
||||
dnl (depending on compiler version), since we are using "gcc", not "g++/c++".
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl (OS/2-only piece)
|
||||
case "${host}" in
|
||||
@@ -1359,6 +1376,26 @@ case "${host}" in
|
||||
dnl Include resources for the "native" port (wxPM).
|
||||
RESPROGRAMOBJ="\${top_srcdir}/include/wx/os2/wx.res"
|
||||
fi
|
||||
AC_CACHE_CHECK([for gcc 3 or later], wx_cv_gcc3,[
|
||||
AC_TRY_COMPILE([#include <features.h>],
|
||||
[
|
||||
#if (__GNUC__ < 3)
|
||||
#error old gcc
|
||||
#endif
|
||||
],
|
||||
[
|
||||
wx_cv_gcc3=yes
|
||||
],
|
||||
[
|
||||
wx_cv_gcc3=no
|
||||
]
|
||||
)
|
||||
])
|
||||
if test "$wx_cv_gcc3" = "no"; then
|
||||
LIBS="$LIBS -lstdcpp"
|
||||
else
|
||||
LIBS="$LIBS -lstdcxx"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
dnl (end of OS/2-only piece)
|
||||
@@ -1410,7 +1447,7 @@ case "${host}" in
|
||||
esac
|
||||
|
||||
if test "$wxUSE_GUI" = "yes"; then
|
||||
if test "$wxUSE_UNIX" = "yes"; then
|
||||
if test "$wxUSE_UNIX" = "yes" -a "$wxUSE_PM" != 1; then
|
||||
dnl defines HAVE_X11_XKBLIB_H
|
||||
AC_CHECK_HEADERS(X11/XKBlib.h)
|
||||
fi
|
||||
@@ -1613,7 +1650,7 @@ dnl check for glibc version
|
||||
dnl
|
||||
dnl VZ: I have no idea why had this check been there originally, but now
|
||||
dnl we could probably do without it by just always adding _GNU_SOURCE
|
||||
if test "$USE_LINUX" = 1; then
|
||||
if test "$USE_LINUX" = 1 || test "$USE_GNU" = 1 ; then
|
||||
AC_CACHE_CHECK([for glibc 2.1 or later], wx_cv_lib_glibc21,[
|
||||
AC_TRY_COMPILE([#include <features.h>],
|
||||
[
|
||||
@@ -1928,11 +1965,13 @@ if test "$wxUSE_LIBTIFF" != "no" ; then
|
||||
TIFF_PREREQ_LINKS="$TIFF_PREREQ_LINKS $ZLIB_LINK"
|
||||
fi
|
||||
AC_CHECK_HEADER(tiffio.h,
|
||||
AC_CHECK_LIB(tiff, TIFFError,
|
||||
TIFF_LINK=" -ltiff",
|
||||
,
|
||||
$TIFF_PREREQ_LINKS)
|
||||
)
|
||||
[
|
||||
AC_CHECK_LIB(tiff, TIFFError,
|
||||
TIFF_LINK=" -ltiff",
|
||||
,
|
||||
$TIFF_PREREQ_LINKS)
|
||||
]
|
||||
)
|
||||
|
||||
if test "x$TIFF_LINK" = "x" ; then
|
||||
if test "$wxUSE_LIBTIFF" = "sys" ; then
|
||||
@@ -2337,7 +2376,7 @@ equivalent variable and GTK+ is version 1.2.3 or above.
|
||||
|
||||
if test "$wxUSE_NANOX" = "yes"; then
|
||||
TOOLKIT_INCLUDE="-I\$(top_srcdir)/include/wx/x11/nanox -I\$(MICROWIN)/src/include $TOOLKIT_INCLUDE"
|
||||
TOOLCHAIN_DEFS="${TOOLCHAIN_DEFS} -D__NANOX__ -DMWPIXEL_FORMAT=MWPF_TRUECOLOR0888 -DHAVE_FILEIO -DHAVE_BMP_SUPPORT=1 -DHAVE_GIF_SUPPORT=1 -DHAVE_PNM_SUPPORT=1 -DHAVE_XPM_SUPPORT=1 -DLINUX=1 -DUNIX=1 -DUSE_EXPOSURE -DSCREEN_HEIGHT=480 -DSCREEN_WIDTH=640 -DSCREEN_DEPTH=4 -DX11=1"
|
||||
TOOLCHAIN_DEFS="${TOOLCHAIN_DEFS} -D__NANOX__ -DMWPIXEL_FORMAT=MWPF_TRUECOLOR0888 -DHAVE_FILEIO -DHAVE_BMP_SUPPORT=1 -DHAVE_GIF_SUPPORT=1 -DHAVE_PNM_SUPPORT=1 -DHAVE_XPM_SUPPORT=1 -DUNIX=1 -DUSE_EXPOSURE -DSCREEN_HEIGHT=480 -DSCREEN_WIDTH=640 -DSCREEN_DEPTH=4 -DX11=1"
|
||||
GUI_TK_LIBRARY="$GUI_TK_LIBRARY \$(MICROWIN)/src/lib/libnano-X.a"
|
||||
else
|
||||
GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lX11$xpm_link"
|
||||
@@ -2568,8 +2607,6 @@ equivalent variable and GTK+ is version 1.2.3 or above.
|
||||
AC_MSG_WARN([OS/2 PM requires old resource format, re-enabled])
|
||||
wxUSE_PROLOGIO="yes"
|
||||
wxUSE_RESOURCES="yes"
|
||||
AC_MSG_WARN([OS/2 threads are not yet supported... disabled])
|
||||
wxUSE_THREADS="no"
|
||||
fi
|
||||
|
||||
dnl the name of the directory where the files for this toolkit live
|
||||
@@ -2888,7 +2925,7 @@ if test "$wxUSE_SHARED" = "yes"; then
|
||||
fi
|
||||
;;
|
||||
|
||||
*-*-linux* )
|
||||
*-*-linux* | *-*-gnu* )
|
||||
if test "$GCC" != "yes"; then
|
||||
AC_CACHE_CHECK([for Intel compiler], wx_cv_prog_icc,
|
||||
[
|
||||
@@ -3060,6 +3097,8 @@ if test "$wxUSE_MAC" = 1; then
|
||||
else
|
||||
if test "$wxUSE_PM" = 1; then
|
||||
LIBWXMACRESCOMP="emxbind -ep \$(BIN_PROGRAM)"
|
||||
else
|
||||
LIBWXMACRESCOMP="#"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -3460,12 +3499,16 @@ AC_CHECK_FUNCS(inet_addr,
|
||||
[
|
||||
AC_CHECK_LIB(nsl, inet_addr,
|
||||
INET_LINK="nsl",
|
||||
AC_CHECK_LIB(resolv, inet_addr,
|
||||
INET_LINK="resolv",
|
||||
AC_CHECK_LIB(socket, inet_addr,
|
||||
INET_LINK="socket"
|
||||
[
|
||||
AC_CHECK_LIB(resolv, inet_addr,
|
||||
INET_LINK="resolv",
|
||||
[
|
||||
AC_CHECK_LIB(socket, inet_addr,
|
||||
INET_LINK="socket"
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -3498,7 +3541,7 @@ dnl ---------------------------------------------------------------------------
|
||||
|
||||
dnl under MSW (except mingw32) we always have thread support
|
||||
CPP_MT_FLAG=
|
||||
if test "$TOOLKIT" != "MSW"; then
|
||||
if test "$TOOLKIT" != "MSW" -a "$TOOLKIT" != "PM"; then
|
||||
|
||||
dnl the code below:
|
||||
dnl
|
||||
@@ -3794,6 +3837,11 @@ else
|
||||
CFLAGS="$CFLAGS_OLD"
|
||||
fi
|
||||
;;
|
||||
*-pc-os2*emx )
|
||||
CFLAGS="$CFLAGS -Zmt -D__ST_MT_ERRNO__"
|
||||
CXXFLAGS="$CXXFLAGS -Zmt -D__ST_MT_ERRNO__"
|
||||
LDFLAGS="$LDFLAGS -Zmt"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
@@ -4257,15 +4305,17 @@ if test "$wxUSE_SOCKETS" = "yes"; then
|
||||
if test "$TOOLKIT" != "MSW"; then
|
||||
dnl under Solaris and OS/2, socket functions live in -lsocket
|
||||
AC_CHECK_FUNC(socket,,
|
||||
AC_CHECK_LIB(socket, socket,
|
||||
if test "$INET_LINK" != " -lsocket"; then
|
||||
INET_LINK="$INET_LINK -lsocket"
|
||||
fi,
|
||||
[
|
||||
AC_MSG_WARN([socket library not found - sockets will be disabled])
|
||||
wxUSE_SOCKETS=no
|
||||
]
|
||||
)
|
||||
[
|
||||
AC_CHECK_LIB(socket, socket,
|
||||
if test "$INET_LINK" != " -lsocket"; then
|
||||
INET_LINK="$INET_LINK -lsocket"
|
||||
fi,
|
||||
[
|
||||
AC_MSG_WARN([socket library not found - sockets will be disabled])
|
||||
wxUSE_SOCKETS=no
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
fi
|
||||
fi
|
||||
@@ -4375,8 +4425,9 @@ dnl ------------------------------------------------------------------------
|
||||
dnl DLL support
|
||||
dnl ------------------------------------------------------------------------
|
||||
|
||||
dnl under MSW we always have LoadLibrary/GetProcAddress
|
||||
if test "$TOOLKIT" != "MSW"; then
|
||||
dnl under MSW we always have LoadLibrary/GetProcAddress and
|
||||
dnl under OS/2 we always have DosLoadModule/DosQueryProcAddr
|
||||
if test "$TOOLKIT" != "MSW" -a "$USE_OS2" != 1; then
|
||||
|
||||
HAVE_DL_FUNCS=0
|
||||
HAVE_SHL_FUNCS=0
|
||||
@@ -4419,8 +4470,11 @@ if test "$TOOLKIT" != "MSW"; then
|
||||
dnl check also for dlerror()
|
||||
if test "$HAVE_DL_FUNCS" = 1; then
|
||||
AC_CHECK_FUNCS(dlerror,
|
||||
AC_DEFINE(HAVE_DLERROR),
|
||||
AC_CHECK_LIB(dl, dlerror, AC_DEFINE(HAVE_DLERROR)))
|
||||
AC_DEFINE(HAVE_DLERROR),
|
||||
[
|
||||
AC_CHECK_LIB(dl, dlerror, AC_DEFINE(HAVE_DLERROR))
|
||||
]
|
||||
)
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -5128,6 +5182,14 @@ if test "$wxUSE_ICO_CUR" = "yes" ; then
|
||||
AC_DEFINE(wxUSE_ICO_CUR)
|
||||
fi
|
||||
|
||||
if test "$wxUSE_IMAGE_LOADING_IN_MSW" = "yes"; then
|
||||
AC_DEFINE(wxUSE_IMAGE_LOADING_IN_MSW)
|
||||
fi
|
||||
|
||||
if test "$wxUSE_RESOURCE_LOADING_IN_MSW" = "yes"; then
|
||||
AC_DEFINE(wxUSE_RESOURCE_LOADING_IN_MSW)
|
||||
fi
|
||||
|
||||
if test "$wxUSE_UNICODE" = "yes" -a "$wxUSE_UNICODE_MSLU" = "yes" ; then
|
||||
dnl Must be done this late because -lunicows must be before all the other libs
|
||||
LIBS=" -lunicows $LIBS"
|
||||
|
@@ -166,6 +166,7 @@
|
||||
#define wxSTC_INDIC_TT 2
|
||||
#define wxSTC_INDIC_DIAGONAL 3
|
||||
#define wxSTC_INDIC_STRIKE 4
|
||||
#define wxSTC_INDIC_HIDDEN 5
|
||||
#define wxSTC_INDIC0_MASK 0x20
|
||||
#define wxSTC_INDIC1_MASK 0x40
|
||||
#define wxSTC_INDIC2_MASK 0x80
|
||||
@@ -247,6 +248,9 @@
|
||||
// where most code reside, and the lines after the caret, eg. the body of a function.
|
||||
#define wxSTC_CARET_EVEN 0x08
|
||||
|
||||
// Maximum value of keywordSet parameter of SetKeyWords.
|
||||
#define wxSTC_KEYWORDSET_MAX 8
|
||||
|
||||
// Notifications
|
||||
// Type of modification and the action which caused the modification.
|
||||
// These are defined as a bit mask to make it easy to specify which notifications are wanted.
|
||||
@@ -329,6 +333,11 @@
|
||||
#define wxSTC_LEX_F77 37
|
||||
#define wxSTC_LEX_CSS 38
|
||||
#define wxSTC_LEX_POV 39
|
||||
#define wxSTC_LEX_LOUT 40
|
||||
#define wxSTC_LEX_ESCRIPT 41
|
||||
#define wxSTC_LEX_PS 42
|
||||
#define wxSTC_LEX_NSIS 43
|
||||
#define wxSTC_LEX_MMIXAL 44
|
||||
|
||||
// When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
|
||||
// value assigned in sequence from SCLEX_AUTOMATIC+1.
|
||||
@@ -370,6 +379,7 @@
|
||||
#define wxSTC_C_WORD2 16
|
||||
#define wxSTC_C_COMMENTDOCKEYWORD 17
|
||||
#define wxSTC_C_COMMENTDOCKEYWORDERROR 18
|
||||
#define wxSTC_C_GLOBALCLASS 19
|
||||
|
||||
// Lexical states for SCLEX_HTML, SCLEX_XML
|
||||
#define wxSTC_H_DEFAULT 0
|
||||
@@ -581,6 +591,8 @@
|
||||
#define wxSTC_LUA_WORD4 15
|
||||
#define wxSTC_LUA_WORD5 16
|
||||
#define wxSTC_LUA_WORD6 17
|
||||
#define wxSTC_LUA_WORD7 18
|
||||
#define wxSTC_LUA_WORD8 19
|
||||
|
||||
// Lexical states for SCLEX_ERRORLIST
|
||||
#define wxSTC_ERR_DEFAULT 0
|
||||
@@ -802,19 +814,107 @@
|
||||
#define wxSTC_POV_DEFAULT 0
|
||||
#define wxSTC_POV_COMMENT 1
|
||||
#define wxSTC_POV_COMMENTLINE 2
|
||||
#define wxSTC_POV_COMMENTDOC 3
|
||||
#define wxSTC_POV_NUMBER 4
|
||||
#define wxSTC_POV_WORD 5
|
||||
#define wxSTC_POV_NUMBER 3
|
||||
#define wxSTC_POV_OPERATOR 4
|
||||
#define wxSTC_POV_IDENTIFIER 5
|
||||
#define wxSTC_POV_STRING 6
|
||||
#define wxSTC_POV_OPERATOR 7
|
||||
#define wxSTC_POV_IDENTIFIER 8
|
||||
#define wxSTC_POV_BRACE 9
|
||||
#define wxSTC_POV_STRINGEOL 7
|
||||
#define wxSTC_POV_DIRECTIVE 8
|
||||
#define wxSTC_POV_BADDIRECTIVE 9
|
||||
#define wxSTC_POV_WORD2 10
|
||||
#define wxSTC_POV_WORD3 11
|
||||
#define wxSTC_POV_WORD4 12
|
||||
#define wxSTC_POV_WORD5 13
|
||||
#define wxSTC_POV_WORD6 14
|
||||
#define wxSTC_POV_WORD7 15
|
||||
#define wxSTC_POV_WORD8 16
|
||||
|
||||
// Lexical states for SCLEX_LOUT
|
||||
#define wxSTC_LOUT_DEFAULT 0
|
||||
#define wxSTC_LOUT_COMMENT 1
|
||||
#define wxSTC_LOUT_NUMBER 2
|
||||
#define wxSTC_LOUT_WORD 3
|
||||
#define wxSTC_LOUT_WORD2 4
|
||||
#define wxSTC_LOUT_WORD3 5
|
||||
#define wxSTC_LOUT_WORD4 6
|
||||
#define wxSTC_LOUT_STRING 7
|
||||
#define wxSTC_LOUT_OPERATOR 8
|
||||
#define wxSTC_LOUT_IDENTIFIER 9
|
||||
#define wxSTC_LOUT_STRINGEOL 10
|
||||
|
||||
// Lexical states for SCLEX_ESCRIPT
|
||||
#define wxSTC_ESCRIPT_DEFAULT 0
|
||||
#define wxSTC_ESCRIPT_COMMENT 1
|
||||
#define wxSTC_ESCRIPT_COMMENTLINE 2
|
||||
#define wxSTC_ESCRIPT_COMMENTDOC 3
|
||||
#define wxSTC_ESCRIPT_NUMBER 4
|
||||
#define wxSTC_ESCRIPT_WORD 5
|
||||
#define wxSTC_ESCRIPT_STRING 6
|
||||
#define wxSTC_ESCRIPT_OPERATOR 7
|
||||
#define wxSTC_ESCRIPT_IDENTIFIER 8
|
||||
#define wxSTC_ESCRIPT_BRACE 9
|
||||
#define wxSTC_ESCRIPT_WORD2 10
|
||||
#define wxSTC_ESCRIPT_WORD3 11
|
||||
|
||||
// Lexical states for SCLEX_PS
|
||||
#define wxSTC_PS_DEFAULT 0
|
||||
#define wxSTC_PS_COMMENT 1
|
||||
#define wxSTC_PS_DSC_COMMENT 2
|
||||
#define wxSTC_PS_DSC_VALUE 3
|
||||
#define wxSTC_PS_NUMBER 4
|
||||
#define wxSTC_PS_NAME 5
|
||||
#define wxSTC_PS_KEYWORD 6
|
||||
#define wxSTC_PS_LITERAL 7
|
||||
#define wxSTC_PS_IMMEVAL 8
|
||||
#define wxSTC_PS_PAREN_ARRAY 9
|
||||
#define wxSTC_PS_PAREN_DICT 10
|
||||
#define wxSTC_PS_PAREN_PROC 11
|
||||
#define wxSTC_PS_TEXT 12
|
||||
#define wxSTC_PS_HEXSTRING 13
|
||||
#define wxSTC_PS_BASE85STRING 14
|
||||
#define wxSTC_PS_BADSTRINGCHAR 15
|
||||
|
||||
// Lexical states for SCLEX_NSIS
|
||||
#define wxSTC_NSIS_DEFAULT 0
|
||||
#define wxSTC_NSIS_COMMENT 1
|
||||
#define wxSTC_NSIS_STRINGDQ 2
|
||||
#define wxSTC_NSIS_STRINGLQ 3
|
||||
#define wxSTC_NSIS_STRINGRQ 4
|
||||
#define wxSTC_NSIS_FUNCTION 5
|
||||
#define wxSTC_NSIS_VARIABLE 6
|
||||
#define wxSTC_NSIS_LABEL 7
|
||||
#define wxSTC_NSIS_USERDEFINED 8
|
||||
#define wxSTC_NSIS_SECTIONDEF 9
|
||||
#define wxSTC_NSIS_SUBSECTIONDEF 10
|
||||
#define wxSTC_NSIS_IFDEFINEDEF 11
|
||||
#define wxSTC_NSIS_MACRODEF 12
|
||||
#define wxSTC_NSIS_STRINGVAR 13
|
||||
|
||||
// Lexical states for SCLEX_MMIXAL
|
||||
#define wxSTC_MMIXAL_LEADWS 0
|
||||
#define wxSTC_MMIXAL_COMMENT 1
|
||||
#define wxSTC_MMIXAL_LABEL 2
|
||||
#define wxSTC_MMIXAL_OPCODE 3
|
||||
#define wxSTC_MMIXAL_OPCODE_PRE 4
|
||||
#define wxSTC_MMIXAL_OPCODE_VALID 5
|
||||
#define wxSTC_MMIXAL_OPCODE_UNKNOWN 6
|
||||
#define wxSTC_MMIXAL_OPCODE_POST 7
|
||||
#define wxSTC_MMIXAL_OPERANDS 8
|
||||
#define wxSTC_MMIXAL_NUMBER 9
|
||||
#define wxSTC_MMIXAL_REF 10
|
||||
#define wxSTC_MMIXAL_CHAR 11
|
||||
#define wxSTC_MMIXAL_STRING 12
|
||||
#define wxSTC_MMIXAL_REGISTER 13
|
||||
#define wxSTC_MMIXAL_HEX 14
|
||||
#define wxSTC_MMIXAL_OPERATOR 15
|
||||
#define wxSTC_MMIXAL_SYMBOL 16
|
||||
#define wxSTC_MMIXAL_INCLUDE 17
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Commands that can be bound to keystrokes
|
||||
|
||||
|
||||
// Redoes the next action on the undo history.
|
||||
#define wxSTC_CMD_REDO 2011
|
||||
|
||||
@@ -1880,6 +1980,9 @@ public:
|
||||
// caret position.
|
||||
void LineEndDisplayExtend();
|
||||
|
||||
// Copy the line containing the caret.
|
||||
void LineCopy();
|
||||
|
||||
// Move the caret inside current view if it's not there already.
|
||||
void MoveCaretInsideView();
|
||||
|
||||
@@ -1990,10 +2093,10 @@ public:
|
||||
bool GetMouseDownCaptures();
|
||||
|
||||
// Sets the cursor to one of the SC_CURSOR* values.
|
||||
void SetCursor(int cursorType);
|
||||
void SetSTCCursor(int cursorType);
|
||||
|
||||
// Get cursor type.
|
||||
int GetCursor();
|
||||
int GetSTCCursor();
|
||||
|
||||
// Change the way control characters are displayed:
|
||||
// If symbol is < 32, keep the drawn way, else, use the given character.
|
||||
@@ -2056,6 +2159,20 @@ public:
|
||||
// Enable / Disable underlining active hotspots.
|
||||
void SetHotspotActiveUnderline(bool underline);
|
||||
|
||||
// Given a valid document position, return the previous position taking code
|
||||
// page into account. Returns 0 if passed 0.
|
||||
int PositionBefore(int pos);
|
||||
|
||||
// Given a valid document position, return the next position taking code
|
||||
// page into account. Maximum value returned is the last position in the document.
|
||||
int PositionAfter(int pos);
|
||||
|
||||
// Copy a range of text to the clipboard. Positions are clipped into the document.
|
||||
void CopyRange(int start, int end);
|
||||
|
||||
// Copy argument text to the clipboard.
|
||||
void CopyText(int length, const wxString& text);
|
||||
|
||||
// Start notifying the container of all key presses and commands.
|
||||
void StartRecord();
|
||||
|
||||
@@ -2167,6 +2284,12 @@ public:
|
||||
// Load the contents of filename into the editor
|
||||
bool LoadFile(const wxString& filename);
|
||||
|
||||
// Allow for simulating a DnD DragOver
|
||||
wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def);
|
||||
|
||||
// Allow for simulating a DnD DropText
|
||||
bool DoDropText(long x, long y, const wxString& data);
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@@ -2431,13 +2554,14 @@ inline wxString stc2wx(const char* str) {
|
||||
#endif
|
||||
}
|
||||
|
||||
inline wxString stc2wx(const char* str, size_t len) {
|
||||
#if wxUSE_UNICODE
|
||||
return wxString(str, wxConvUTF8, len);
|
||||
wxString stc2wx(const char* str, size_t len);
|
||||
#else
|
||||
inline wxString stc2wx(const char* str, size_t len) {
|
||||
return wxString(str, len);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
inline const wxWX2MBbuf wx2stc(const wxString& str) {
|
||||
|
@@ -17,10 +17,10 @@
|
||||
|
||||
#include "wx/xrc/xmlres.h"
|
||||
|
||||
class WXXMLDLLEXPORT wxCheckListXmlHandler : public wxXmlResourceHandler
|
||||
class WXXMLDLLEXPORT wxCheckListBoxXmlHandler : public wxXmlResourceHandler
|
||||
{
|
||||
public:
|
||||
wxCheckListXmlHandler();
|
||||
wxCheckListBoxXmlHandler();
|
||||
virtual wxObject *DoCreateResource();
|
||||
virtual bool CanHandle(wxXmlNode *node);
|
||||
private:
|
||||
|
@@ -11,7 +11,7 @@ program_dir = contrib/samples/stc
|
||||
|
||||
PROGRAM=stctest
|
||||
|
||||
OBJECTS=$(PROGRAM).o
|
||||
OBJECTS=$(PROGRAM).o edit.o prefs.o
|
||||
|
||||
APPEXTRALIBS=$(top_builddir)/lib/lib@WX_LIBRARY_BASENAME@_stc-@WX_RELEASE@.@WX_TARGET_LIBRARY_TYPE@
|
||||
APPEXTRADEFS=-I$(top_srcdir)/contrib/include
|
||||
|
6
contrib/samples/stc/Makefile.sc
Normal file
6
contrib/samples/stc/Makefile.sc
Normal file
@@ -0,0 +1,6 @@
|
||||
#Makefile from wxHatch for Symantec/Digital Mars compiler
|
||||
WXDIR=..\..\..
|
||||
TARGET=stctest
|
||||
OBJECTS = $(TARGET).obj edit.obj prefs.obj
|
||||
EXTRALIBS=$(WXDIR)\lib\stc_sc.lib
|
||||
include $(WXDIR)\src\makeprog.sc
|
@@ -147,6 +147,44 @@ LINK32=link.exe
|
||||
# Name "StcTestVC - Win32 Release DLL"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\edit.cpp
|
||||
|
||||
!IF "$(CFG)" == "StcTestVC - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "StcTestVC - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "StcTestVC - Win32 Debug DLL"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "StcTestVC - Win32 Release DLL"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\prefs.cpp
|
||||
|
||||
!IF "$(CFG)" == "StcTestVC - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "StcTestVC - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "StcTestVC - Win32 Debug DLL"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "StcTestVC - Win32 Release DLL"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\stctest.cpp
|
||||
|
||||
!IF "$(CFG)" == "StcTestVC - Win32 Release"
|
||||
|
104
contrib/samples/stc/defsext.h
Normal file
104
contrib/samples/stc/defsext.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: defsext.h extensions
|
||||
// Purpose: STC test declarations
|
||||
// Maintainer: Wyo
|
||||
// Created: 2003-09-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxGuide
|
||||
// Licence: wxWindows licence
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DEFSEXT_H_
|
||||
#define _WX_DEFSEXT_H_
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// headers
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//! wxWindows headers
|
||||
#include <wx/print.h> // printing support
|
||||
#include <wx/printdlg.h> // printing dialog
|
||||
|
||||
|
||||
//============================================================================
|
||||
// declarations
|
||||
//============================================================================
|
||||
|
||||
#define DEFAULT_LANGUAGE _("<default>")
|
||||
|
||||
#define PAGE_COMMON _("Common")
|
||||
#define PAGE_LANGUAGES _("Languages")
|
||||
#define PAGE_STYLE_TYPES _("Style types")
|
||||
|
||||
#define STYLE_TYPES_COUNT 32
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// standard IDs
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
enum {
|
||||
// menu IDs
|
||||
myID_PROPERTIES = wxID_HIGHEST,
|
||||
myID_INDENTINC,
|
||||
myID_INDENTRED,
|
||||
myID_FINDNEXT,
|
||||
myID_REPLACE,
|
||||
myID_REPLACENEXT,
|
||||
myID_BRACEMATCH,
|
||||
myID_GOTO,
|
||||
myID_PAGEACTIVE,
|
||||
myID_DISPLAYEOL,
|
||||
myID_INDENTGUIDE,
|
||||
myID_LINENUMBER,
|
||||
myID_LONGLINEON,
|
||||
myID_WHITESPACE,
|
||||
myID_FOLDTOGGLE,
|
||||
myID_OVERTYPE,
|
||||
myID_READONLY,
|
||||
myID_WRAPMODEON,
|
||||
myID_CHANGECASE,
|
||||
myID_CHANGELOWER,
|
||||
myID_CHANGEUPPER,
|
||||
myID_HILIGHTLANG,
|
||||
myID_HILIGHTFIRST,
|
||||
myID_HILIGHTLAST = myID_HILIGHTFIRST + 99,
|
||||
myID_CONVERTEOL,
|
||||
myID_CONVERTCR,
|
||||
myID_CONVERTCRLF,
|
||||
myID_CONVERTLF,
|
||||
myID_USECHARSET,
|
||||
myID_CHARSETANSI,
|
||||
myID_CHARSETMAC,
|
||||
myID_PAGEPREV,
|
||||
myID_PAGENEXT,
|
||||
myID_SELECTLINE,
|
||||
|
||||
// other IDs
|
||||
myID_STATUSBAR,
|
||||
myID_TITLEBAR,
|
||||
myID_ABOUTTIMER,
|
||||
myID_UPDATETIMER,
|
||||
|
||||
// dialog find IDs
|
||||
myID_DLG_FIND_TEXT,
|
||||
|
||||
// preferences IDs
|
||||
myID_PREFS_LANGUAGE,
|
||||
myID_PREFS_STYLETYPE,
|
||||
myID_PREFS_KEYWORDS,
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global items
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
//! global application name
|
||||
extern wxString *g_appname;
|
||||
|
||||
//! global print data, to remember settings during the session
|
||||
extern wxPrintData *g_printData;
|
||||
extern wxPageSetupData *g_pageSetupData;
|
||||
|
||||
#endif // _WX_DEFSEXT_H_
|
||||
|
824
contrib/samples/stc/edit.cpp
Normal file
824
contrib/samples/stc/edit.cpp
Normal file
@@ -0,0 +1,824 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// File: edit.cpp
|
||||
// Purpose: STC test module
|
||||
// Maintainer: Wyo
|
||||
// Created: 2003-09-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxGuide
|
||||
// Licence: wxWindows licence
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// informations
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// headers
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// For compilers that support precompilation, includes <wx/wx.h>.
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
// for all others, include the necessary headers (this file is usually all you
|
||||
// need because it includes almost all 'standard' wxWindows headers)
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
//! wxWindows headers
|
||||
#include <wx/file.h> // raw file io support
|
||||
#include <wx/filename.h> // filename support
|
||||
|
||||
//! application headers
|
||||
#include "defsext.h" // additional definitions
|
||||
|
||||
#include "edit.h" // edit module
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// resources
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//============================================================================
|
||||
// declarations
|
||||
//============================================================================
|
||||
|
||||
|
||||
//============================================================================
|
||||
// implementation
|
||||
//============================================================================
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Edit
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
BEGIN_EVENT_TABLE (Edit, wxStyledTextCtrl)
|
||||
// common
|
||||
EVT_SIZE ( Edit::OnSize)
|
||||
// edit
|
||||
EVT_MENU (wxID_CLEAR, Edit::OnEditClear)
|
||||
EVT_MENU (wxID_CUT, Edit::OnEditCut)
|
||||
EVT_MENU (wxID_COPY, Edit::OnEditCopy)
|
||||
EVT_MENU (wxID_PASTE, Edit::OnEditPaste)
|
||||
EVT_MENU (myID_INDENTINC, Edit::OnEditIndentInc)
|
||||
EVT_MENU (myID_INDENTRED, Edit::OnEditIndentRed)
|
||||
EVT_MENU (wxID_SELECTALL, Edit::OnEditSelectAll)
|
||||
EVT_MENU (myID_SELECTLINE, Edit::OnEditSelectLine)
|
||||
EVT_MENU (wxID_REDO, Edit::OnEditRedo)
|
||||
EVT_MENU (wxID_UNDO, Edit::OnEditUndo)
|
||||
// find
|
||||
EVT_MENU (wxID_FIND, Edit::OnFind)
|
||||
EVT_MENU (myID_FINDNEXT, Edit::OnFindNext)
|
||||
EVT_MENU (myID_REPLACE, Edit::OnReplace)
|
||||
EVT_MENU (myID_REPLACENEXT, Edit::OnReplaceNext)
|
||||
EVT_MENU (myID_BRACEMATCH, Edit::OnBraceMatch)
|
||||
EVT_MENU (myID_GOTO, Edit::OnGoto)
|
||||
// view
|
||||
EVT_MENU_RANGE (myID_HILIGHTFIRST, myID_HILIGHTLAST,
|
||||
Edit::OnHilightLang)
|
||||
EVT_MENU (myID_DISPLAYEOL, Edit::OnDisplayEOL)
|
||||
EVT_MENU (myID_INDENTGUIDE, Edit::OnIndentGuide)
|
||||
EVT_MENU (myID_LINENUMBER, Edit::OnLineNumber)
|
||||
EVT_MENU (myID_LONGLINEON, Edit::OnLongLineOn)
|
||||
EVT_MENU (myID_WHITESPACE, Edit::OnWhiteSpace)
|
||||
EVT_MENU (myID_FOLDTOGGLE, Edit::OnFoldToggle)
|
||||
EVT_MENU (myID_OVERTYPE, Edit::OnSetOverType)
|
||||
EVT_MENU (myID_READONLY, Edit::OnSetReadOnly)
|
||||
EVT_MENU (myID_WRAPMODEON, Edit::OnWrapmodeOn)
|
||||
EVT_MENU (myID_CHARSETANSI, Edit::OnUseCharset)
|
||||
EVT_MENU (myID_CHARSETMAC, Edit::OnUseCharset)
|
||||
// extra
|
||||
EVT_MENU (myID_CHANGELOWER, Edit::OnChangeCase)
|
||||
EVT_MENU (myID_CHANGEUPPER, Edit::OnChangeCase)
|
||||
EVT_MENU (myID_CONVERTCR, Edit::OnConvertEOL)
|
||||
EVT_MENU (myID_CONVERTCRLF, Edit::OnConvertEOL)
|
||||
EVT_MENU (myID_CONVERTLF, Edit::OnConvertEOL)
|
||||
// stc
|
||||
EVT_STC_MARGINCLICK (-1, Edit::OnMarginClick)
|
||||
EVT_STC_CHARADDED (-1, Edit::OnCharAdded)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
Edit::Edit (wxWindow *parent, wxWindowID id,
|
||||
const wxPoint &pos,
|
||||
const wxSize &size,
|
||||
long style)
|
||||
: wxStyledTextCtrl (parent, id, pos, size, style) {
|
||||
|
||||
m_filename = _T("");
|
||||
|
||||
m_LineNrID = 0;
|
||||
m_DividerID = 1;
|
||||
m_FoldingID = 2;
|
||||
|
||||
// initialize language
|
||||
m_language = NULL;
|
||||
|
||||
// default font for all styles
|
||||
SetViewEOL (g_CommonPrefs.displayEOLEnable);
|
||||
SetIndentationGuides (g_CommonPrefs.indentGuideEnable);
|
||||
SetEdgeMode (g_CommonPrefs.longLineOnEnable?
|
||||
wxSTC_EDGE_LINE: wxSTC_EDGE_NONE);
|
||||
SetViewWhiteSpace (g_CommonPrefs.whiteSpaceEnable?
|
||||
wxSTC_WS_VISIBLEALWAYS: wxSTC_WS_INVISIBLE);
|
||||
SetOvertype (g_CommonPrefs.overTypeInitial);
|
||||
SetReadOnly (g_CommonPrefs.readOnlyInitial);
|
||||
SetWrapMode (g_CommonPrefs.wrapModeInitial?
|
||||
wxSTC_WRAP_WORD: wxSTC_WRAP_NONE);
|
||||
wxFont font (10, wxMODERN, wxNORMAL, wxNORMAL);
|
||||
StyleSetFont (wxSTC_STYLE_DEFAULT, font);
|
||||
StyleSetForeground (wxSTC_STYLE_DEFAULT, wxColour (_T("BLACK")));
|
||||
StyleSetBackground (wxSTC_STYLE_DEFAULT, wxColour (_T("WHITE")));
|
||||
StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (_T("DARK GREY")));
|
||||
StyleSetBackground (wxSTC_STYLE_LINENUMBER, wxColour (_T("WHITE")));
|
||||
StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColour (_T("DARK GREY")));
|
||||
InitializePrefs (DEFAULT_LANGUAGE);
|
||||
|
||||
// set visibility
|
||||
SetVisiblePolicy (wxSTC_VISIBLE_STRICT|wxSTC_VISIBLE_SLOP, 1);
|
||||
SetXCaretPolicy (wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1);
|
||||
SetYCaretPolicy (wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1);
|
||||
|
||||
// markers
|
||||
MarkerDefine (wxSTC_MARKNUM_FOLDER, wxSTC_MARK_DOTDOTDOT, _T("BLACK"), _T("BLACK"));
|
||||
MarkerDefine (wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_ARROWDOWN, _T("BLACK"), _T("BLACK"));
|
||||
MarkerDefine (wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY, _T("BLACK"), _T("BLACK"));
|
||||
MarkerDefine (wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_DOTDOTDOT, _T("BLACK"), _T("WHITE"));
|
||||
MarkerDefine (wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_ARROWDOWN, _T("BLACK"), _T("WHITE"));
|
||||
MarkerDefine (wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY, _T("BLACK"), _T("BLACK"));
|
||||
MarkerDefine (wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY, _T("BLACK"), _T("BLACK"));
|
||||
|
||||
// miscelaneous
|
||||
m_LineNrMargin = TextWidth (wxSTC_STYLE_LINENUMBER, _T("_999999"));
|
||||
m_FoldingMargin = 16;
|
||||
SetMarginWidth (m_LineNrID,
|
||||
g_CommonPrefs.lineNumberEnable? m_LineNrMargin: 0);
|
||||
CmdKeyClear (wxSTC_KEY_TAB, 0); // this is done by the menu accelerator key
|
||||
SetLayoutCache (wxSTC_CACHE_PAGE);
|
||||
|
||||
}
|
||||
|
||||
Edit::~Edit () {}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// common event handlers
|
||||
void Edit::OnSize( wxSizeEvent& event ) {
|
||||
int x = GetClientSize().x +
|
||||
(g_CommonPrefs.lineNumberEnable? m_LineNrMargin: 0) +
|
||||
(g_CommonPrefs.foldEnable? m_FoldingMargin: 0);
|
||||
if (x > 0) SetScrollWidth (x);
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
// edit event handlers
|
||||
void Edit::OnEditRedo (wxCommandEvent &WXUNUSED(event)) {
|
||||
if (!CanRedo()) return;
|
||||
Redo ();
|
||||
}
|
||||
|
||||
void Edit::OnEditUndo (wxCommandEvent &WXUNUSED(event)) {
|
||||
if (!CanUndo()) return;
|
||||
Undo ();
|
||||
}
|
||||
|
||||
void Edit::OnEditClear (wxCommandEvent &WXUNUSED(event)) {
|
||||
if (GetReadOnly()) return;
|
||||
Clear ();
|
||||
}
|
||||
|
||||
void Edit::OnEditCut (wxCommandEvent &WXUNUSED(event)) {
|
||||
if (GetReadOnly() || (GetSelectionEnd()-GetSelectionStart() <= 0)) return;
|
||||
Cut ();
|
||||
}
|
||||
|
||||
void Edit::OnEditCopy (wxCommandEvent &WXUNUSED(event)) {
|
||||
if (GetSelectionEnd()-GetSelectionStart() <= 0) return;
|
||||
Copy ();
|
||||
}
|
||||
|
||||
void Edit::OnEditPaste (wxCommandEvent &WXUNUSED(event)) {
|
||||
if (!CanPaste()) return;
|
||||
Paste ();
|
||||
}
|
||||
|
||||
void Edit::OnFind (wxCommandEvent &WXUNUSED(event)) {
|
||||
}
|
||||
|
||||
void Edit::OnFindNext (wxCommandEvent &WXUNUSED(event)) {
|
||||
}
|
||||
|
||||
void Edit::OnReplace (wxCommandEvent &WXUNUSED(event)) {
|
||||
}
|
||||
|
||||
void Edit::OnReplaceNext (wxCommandEvent &WXUNUSED(event)) {
|
||||
}
|
||||
|
||||
void Edit::OnBraceMatch (wxCommandEvent &WXUNUSED(event)) {
|
||||
int min = GetCurrentPos ();
|
||||
int max = BraceMatch (min);
|
||||
if (max > (min+1)) {
|
||||
BraceHighlight (min+1, max);
|
||||
SetSelection (min+1, max);
|
||||
}else{
|
||||
BraceBadLight (min);
|
||||
}
|
||||
}
|
||||
|
||||
void Edit::OnGoto (wxCommandEvent &WXUNUSED(event)) {
|
||||
}
|
||||
|
||||
void Edit::OnEditIndentInc (wxCommandEvent &WXUNUSED(event)) {
|
||||
CmdKeyExecute (wxSTC_CMD_TAB);
|
||||
}
|
||||
|
||||
void Edit::OnEditIndentRed (wxCommandEvent &WXUNUSED(event)) {
|
||||
CmdKeyExecute (wxSTC_CMD_DELETEBACK);
|
||||
}
|
||||
|
||||
void Edit::OnEditSelectAll (wxCommandEvent &WXUNUSED(event)) {
|
||||
SetSelection (0, GetTextLength ());
|
||||
}
|
||||
|
||||
void Edit::OnEditSelectLine (wxCommandEvent &WXUNUSED(event)) {
|
||||
int lineStart = PositionFromLine (GetCurrentLine());
|
||||
int lineEnd = PositionFromLine (GetCurrentLine() + 1);
|
||||
SetSelection (lineStart, lineEnd);
|
||||
}
|
||||
|
||||
void Edit::OnHilightLang (wxCommandEvent &event) {
|
||||
InitializePrefs (g_LanguagePrefs [event.GetId() - myID_HILIGHTFIRST].name);
|
||||
}
|
||||
|
||||
void Edit::OnDisplayEOL (wxCommandEvent &WXUNUSED(event)) {
|
||||
SetViewEOL (!GetViewEOL());
|
||||
}
|
||||
|
||||
void Edit::OnIndentGuide (wxCommandEvent &WXUNUSED(event)) {
|
||||
SetIndentationGuides (!GetIndentationGuides());
|
||||
}
|
||||
|
||||
void Edit::OnLineNumber (wxCommandEvent &WXUNUSED(event)) {
|
||||
SetMarginWidth (m_LineNrID,
|
||||
GetMarginWidth (m_LineNrID) == 0? m_LineNrMargin: 0);
|
||||
}
|
||||
|
||||
void Edit::OnLongLineOn (wxCommandEvent &WXUNUSED(event)) {
|
||||
SetEdgeMode (GetEdgeMode() == 0? wxSTC_EDGE_LINE: wxSTC_EDGE_NONE);
|
||||
}
|
||||
|
||||
void Edit::OnWhiteSpace (wxCommandEvent &WXUNUSED(event)) {
|
||||
SetViewWhiteSpace (GetViewWhiteSpace() == 0?
|
||||
wxSTC_WS_VISIBLEALWAYS: wxSTC_WS_INVISIBLE);
|
||||
}
|
||||
|
||||
void Edit::OnFoldToggle (wxCommandEvent &WXUNUSED(event)) {
|
||||
ToggleFold (GetFoldParent(GetCurrentLine()));
|
||||
}
|
||||
|
||||
void Edit::OnSetOverType (wxCommandEvent &WXUNUSED(event)) {
|
||||
SetOvertype (!GetOvertype());
|
||||
}
|
||||
|
||||
void Edit::OnSetReadOnly (wxCommandEvent &WXUNUSED(event)) {
|
||||
SetReadOnly (!GetReadOnly());
|
||||
}
|
||||
|
||||
void Edit::OnWrapmodeOn (wxCommandEvent &WXUNUSED(event)) {
|
||||
SetWrapMode (GetWrapMode() == 0? wxSTC_WRAP_WORD: wxSTC_WRAP_NONE);
|
||||
}
|
||||
|
||||
void Edit::OnUseCharset (wxCommandEvent &event) {
|
||||
int Nr;
|
||||
int charset = GetCodePage();
|
||||
switch (event.GetId()) {
|
||||
case myID_CHARSETANSI: {charset = wxSTC_CHARSET_ANSI; break;}
|
||||
case myID_CHARSETMAC: {charset = wxSTC_CHARSET_ANSI; break;}
|
||||
}
|
||||
for (Nr = 0; Nr < wxSTC_STYLE_LASTPREDEFINED; Nr++) {
|
||||
StyleSetCharacterSet (Nr, charset);
|
||||
}
|
||||
SetCodePage (charset);
|
||||
}
|
||||
|
||||
void Edit::OnChangeCase (wxCommandEvent &event) {
|
||||
switch (event.GetId()) {
|
||||
case myID_CHANGELOWER: {
|
||||
CmdKeyExecute (wxSTC_CMD_LOWERCASE);
|
||||
break;
|
||||
}
|
||||
case myID_CHANGEUPPER: {
|
||||
CmdKeyExecute (wxSTC_CMD_UPPERCASE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Edit::OnConvertEOL (wxCommandEvent &event) {
|
||||
int eolMode = GetEOLMode();
|
||||
switch (event.GetId()) {
|
||||
case myID_CONVERTCR: { eolMode = wxSTC_EOL_CR; break;}
|
||||
case myID_CONVERTCRLF: { eolMode = wxSTC_EOL_CRLF; break;}
|
||||
case myID_CONVERTLF: { eolMode = wxSTC_EOL_LF; break;}
|
||||
}
|
||||
ConvertEOLs (eolMode);
|
||||
SetEOLMode (eolMode);
|
||||
}
|
||||
|
||||
//! misc
|
||||
void Edit::OnMarginClick (wxStyledTextEvent &event) {
|
||||
if (event.GetMargin() == 2) {
|
||||
int lineClick = LineFromPosition (event.GetPosition());
|
||||
int levelClick = GetFoldLevel (lineClick);
|
||||
if ((levelClick & wxSTC_FOLDLEVELHEADERFLAG) > 0) {
|
||||
ToggleFold (lineClick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Edit::OnCharAdded (wxStyledTextEvent &event) {
|
||||
char chr = event.GetKey();
|
||||
int currentLine = GetCurrentLine();
|
||||
// Change this if support for mac files with \r is needed
|
||||
if (chr == '\n') {
|
||||
int lineInd = 0;
|
||||
if (currentLine > 0) {
|
||||
lineInd = GetLineIndentation(currentLine - 1);
|
||||
}
|
||||
if (lineInd == 0) return;
|
||||
SetLineIndentation (currentLine, lineInd);
|
||||
GotoPos(PositionFromLine (currentLine) + lineInd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// private functions
|
||||
wxString Edit::DeterminePrefs (const wxString &filename) {
|
||||
|
||||
LanguageInfo const* curInfo;
|
||||
|
||||
// determine language from filepatterns
|
||||
int languageNr;
|
||||
for (languageNr = 0; languageNr < g_LanguagePrefsSize; languageNr++) {
|
||||
curInfo = &g_LanguagePrefs [languageNr];
|
||||
wxString filepattern = curInfo->filepattern;
|
||||
filepattern.Lower();
|
||||
while (!filepattern.IsEmpty()) {
|
||||
wxString cur = filepattern.BeforeFirst (';');
|
||||
if ((cur == filename) ||
|
||||
(cur == (filename.BeforeLast ('.') + _T(".*"))) ||
|
||||
(cur == (_T("*.") + filename.AfterLast ('.')))) {
|
||||
return curInfo->name;
|
||||
}
|
||||
filepattern = filepattern.AfterFirst (';');
|
||||
}
|
||||
}
|
||||
return wxEmptyString;
|
||||
|
||||
}
|
||||
|
||||
bool Edit::InitializePrefs (const wxString &name) {
|
||||
|
||||
// initialize styles
|
||||
StyleClearAll();
|
||||
LanguageInfo const* curInfo = NULL;
|
||||
|
||||
// determine language
|
||||
bool found = false;
|
||||
int languageNr;
|
||||
for (languageNr = 0; languageNr < g_LanguagePrefsSize; languageNr++) {
|
||||
curInfo = &g_LanguagePrefs [languageNr];
|
||||
if (curInfo->name == name) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) return false;
|
||||
|
||||
// set lexer and language
|
||||
SetLexer (curInfo->lexer);
|
||||
m_language = curInfo;
|
||||
|
||||
// set margin for line numbers
|
||||
SetMarginType (m_LineNrID, wxSTC_MARGIN_NUMBER);
|
||||
StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (_T("DARK GREY")));
|
||||
StyleSetBackground (wxSTC_STYLE_LINENUMBER, wxColour (_T("WHITE")));
|
||||
SetMarginWidth (m_LineNrID,
|
||||
g_CommonPrefs.lineNumberEnable? m_LineNrMargin: 0);
|
||||
|
||||
// default fonts for all styles!
|
||||
int Nr;
|
||||
for (Nr = 0; Nr < wxSTC_STYLE_LASTPREDEFINED; Nr++) {
|
||||
wxFont font (10, wxMODERN, wxNORMAL, wxNORMAL);
|
||||
StyleSetFont (Nr, font);
|
||||
}
|
||||
|
||||
// set common styles
|
||||
StyleSetForeground (wxSTC_STYLE_DEFAULT, wxColour (_T("DARK GREY")));
|
||||
StyleSetForeground (wxSTC_STYLE_INDENTGUIDE, wxColour (_T("DARK GREY")));
|
||||
|
||||
// initialize settings
|
||||
if (g_CommonPrefs.syntaxEnable) {
|
||||
int keywordnr = 0;
|
||||
for (Nr = 0; Nr < STYLE_TYPES_COUNT; Nr++) {
|
||||
if (curInfo->styles[Nr].type == -1) continue;
|
||||
const StyleInfo &curType = g_StylePrefs [curInfo->styles[Nr].type];
|
||||
wxFont font (curType.fontsize, wxMODERN, wxNORMAL, wxNORMAL, false,
|
||||
curType.fontname);
|
||||
StyleSetFont (Nr, font);
|
||||
if (curType.foreground) {
|
||||
StyleSetForeground (Nr, wxColour (curType.foreground));
|
||||
}
|
||||
if (curType.background) {
|
||||
StyleSetBackground (Nr, wxColour (curType.background));
|
||||
}
|
||||
StyleSetBold (Nr, (curType.fontstyle & mySTC_STYLE_BOLD) > 0);
|
||||
StyleSetItalic (Nr, (curType.fontstyle & mySTC_STYLE_ITALIC) > 0);
|
||||
StyleSetUnderline (Nr, (curType.fontstyle & mySTC_STYLE_UNDERL) > 0);
|
||||
StyleSetVisible (Nr, (curType.fontstyle & mySTC_STYLE_HIDDEN) == 0);
|
||||
StyleSetCase (Nr, curType.lettercase);
|
||||
const wxChar *pwords = curInfo->styles[Nr].words;
|
||||
if (pwords) {
|
||||
SetKeyWords (keywordnr, pwords);
|
||||
keywordnr += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set margin as unused
|
||||
SetMarginType (m_DividerID, wxSTC_MARGIN_SYMBOL);
|
||||
SetMarginWidth (m_DividerID, 0);
|
||||
SetMarginSensitive (m_DividerID, false);
|
||||
|
||||
// folding
|
||||
SetMarginType (m_FoldingID, wxSTC_MARGIN_SYMBOL);
|
||||
SetMarginMask (m_FoldingID, wxSTC_MASK_FOLDERS);
|
||||
StyleSetBackground (m_FoldingID, wxColour (_T("WHITE")));
|
||||
SetMarginWidth (m_FoldingID, 0);
|
||||
SetMarginSensitive (m_FoldingID, false);
|
||||
if (g_CommonPrefs.foldEnable) {
|
||||
SetMarginWidth (m_FoldingID, curInfo->folds != 0? m_FoldingMargin: 0);
|
||||
SetMarginSensitive (m_FoldingID, curInfo->folds != 0);
|
||||
SetProperty (_T("fold"), curInfo->folds != 0? _T("1"): _T("0"));
|
||||
SetProperty (_T("fold.comment"),
|
||||
(curInfo->folds & mySTC_FOLD_COMMENT) > 0? _T("1"): _T("0"));
|
||||
SetProperty (_T("fold.compact"),
|
||||
(curInfo->folds & mySTC_FOLD_COMPACT) > 0? _T("1"): _T("0"));
|
||||
SetProperty (_T("fold.preprocessor"),
|
||||
(curInfo->folds & mySTC_FOLD_PREPROC) > 0? _T("1"): _T("0"));
|
||||
SetProperty (_T("fold.html"),
|
||||
(curInfo->folds & mySTC_FOLD_HTML) > 0? _T("1"): _T("0"));
|
||||
SetProperty (_T("fold.html.preprocessor"),
|
||||
(curInfo->folds & mySTC_FOLD_HTMLPREP) > 0? _T("1"): _T("0"));
|
||||
SetProperty (_T("fold.comment.python"),
|
||||
(curInfo->folds & mySTC_FOLD_COMMENTPY) > 0? _T("1"): _T("0"));
|
||||
SetProperty (_T("fold.quotes.python"),
|
||||
(curInfo->folds & mySTC_FOLD_QUOTESPY) > 0? _T("1"): _T("0"));
|
||||
}
|
||||
SetFoldFlags (wxSTC_FOLDFLAG_LINEBEFORE_CONTRACTED |
|
||||
wxSTC_FOLDFLAG_LINEAFTER_CONTRACTED);
|
||||
|
||||
// set spaces and indention
|
||||
SetTabWidth (4);
|
||||
SetUseTabs (false);
|
||||
SetTabIndents (true);
|
||||
SetBackSpaceUnIndents (true);
|
||||
SetIndent (g_CommonPrefs.indentEnable? 4: 0);
|
||||
|
||||
// others
|
||||
SetViewEOL (g_CommonPrefs.displayEOLEnable);
|
||||
SetIndentationGuides (g_CommonPrefs.indentGuideEnable);
|
||||
SetEdgeColumn (80);
|
||||
SetEdgeMode (g_CommonPrefs.longLineOnEnable? wxSTC_EDGE_LINE: wxSTC_EDGE_NONE);
|
||||
SetViewWhiteSpace (g_CommonPrefs.whiteSpaceEnable?
|
||||
wxSTC_WS_VISIBLEALWAYS: wxSTC_WS_INVISIBLE);
|
||||
SetOvertype (g_CommonPrefs.overTypeInitial);
|
||||
SetReadOnly (g_CommonPrefs.readOnlyInitial);
|
||||
SetWrapMode (g_CommonPrefs.wrapModeInitial?
|
||||
wxSTC_WRAP_WORD: wxSTC_WRAP_NONE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Edit::LoadFile () {
|
||||
|
||||
// get filname
|
||||
if (!m_filename) {
|
||||
wxFileDialog dlg (this, _T("Open file"), _T(""), _T(""),
|
||||
_T("Any file (*)|*"), wxOPEN | wxFILE_MUST_EXIST | wxCHANGE_DIR);
|
||||
if (dlg.ShowModal() != wxID_OK) return false;
|
||||
m_filename = dlg.GetPath();
|
||||
}
|
||||
|
||||
// load file
|
||||
return LoadFile (m_filename);
|
||||
}
|
||||
|
||||
bool Edit::LoadFile (const wxString &filename) {
|
||||
|
||||
// load file in edit and clear undo
|
||||
if (!filename.IsEmpty()) m_filename = filename;
|
||||
// wxFile file (m_filename);
|
||||
// if (!file.IsOpened()) return false;
|
||||
ClearAll ();
|
||||
// long lng = file.Length ();
|
||||
// if (lng > 0) {
|
||||
// wxString buf;
|
||||
// wxChar *buff = buf.GetWriteBuf (lng);
|
||||
// file.Read (buff, lng);
|
||||
// buf.UngetWriteBuf ();
|
||||
// InsertText (0, buf);
|
||||
// }
|
||||
// file.Close();
|
||||
|
||||
wxStyledTextCtrl::LoadFile(m_filename);
|
||||
|
||||
EmptyUndoBuffer();
|
||||
|
||||
// determine lexer language
|
||||
wxFileName fname (m_filename);
|
||||
InitializePrefs (DeterminePrefs (fname.GetFullName()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Edit::SaveFile () {
|
||||
|
||||
// return if no change
|
||||
if (!Modified()) return true;
|
||||
|
||||
// get filname
|
||||
if (!m_filename) {
|
||||
wxFileDialog dlg (this, _T("Save file"), _T(""), _T(""), _T("Any file (*)|*"),
|
||||
wxSAVE | wxOVERWRITE_PROMPT);
|
||||
if (dlg.ShowModal() != wxID_OK) return false;
|
||||
m_filename = dlg.GetPath();
|
||||
}
|
||||
|
||||
// save file
|
||||
return SaveFile (m_filename);
|
||||
}
|
||||
|
||||
bool Edit::SaveFile (const wxString &filename) {
|
||||
|
||||
// return if no change
|
||||
if (!Modified()) return true;
|
||||
|
||||
// // save edit in file and clear undo
|
||||
// if (!filename.IsEmpty()) m_filename = filename;
|
||||
// wxFile file (m_filename, wxFile::write);
|
||||
// if (!file.IsOpened()) return false;
|
||||
// wxString buf = GetText();
|
||||
// bool okay = file.Write (buf);
|
||||
// file.Close();
|
||||
// if (!okay) return false;
|
||||
// EmptyUndoBuffer();
|
||||
// SetSavePoint();
|
||||
|
||||
// return true;
|
||||
|
||||
return wxStyledTextCtrl::SaveFile(filename);
|
||||
|
||||
}
|
||||
|
||||
bool Edit::Modified () {
|
||||
|
||||
// return modified state
|
||||
return (GetModify() && !GetReadOnly());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// EditProperties
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
EditProperties::EditProperties (Edit *edit,
|
||||
long style)
|
||||
: wxDialog (edit, -1, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
style | wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {
|
||||
|
||||
// sets the application title
|
||||
SetTitle (_("Properties"));
|
||||
wxString text;
|
||||
|
||||
// fullname
|
||||
wxBoxSizer *fullname = new wxBoxSizer (wxHORIZONTAL);
|
||||
fullname->Add (10, 0);
|
||||
fullname->Add (new wxStaticText (this, -1, _("Full filename"),
|
||||
wxDefaultPosition, wxSize(80, -1)),
|
||||
0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL);
|
||||
fullname->Add (new wxStaticText (this, -1, edit->GetFilename()),
|
||||
0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL);
|
||||
|
||||
// text info
|
||||
wxGridSizer *textinfo = new wxGridSizer (4, 0, 2);
|
||||
textinfo->Add (new wxStaticText (this, -1, _("Language"),
|
||||
wxDefaultPosition, wxSize(80, -1)),
|
||||
0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT, 4);
|
||||
textinfo->Add (new wxStaticText (this, -1, edit->m_language->name),
|
||||
0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 4);
|
||||
textinfo->Add (new wxStaticText (this, -1, _("Lexer-ID: "),
|
||||
wxDefaultPosition, wxSize(80, -1)),
|
||||
0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT, 4);
|
||||
text = wxString::Format (_T("%d"), edit->GetLexer());
|
||||
textinfo->Add (new wxStaticText (this, -1, text),
|
||||
0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 4);
|
||||
wxString EOLtype = _T("");
|
||||
switch (edit->GetEOLMode()) {
|
||||
case wxSTC_EOL_CR: {EOLtype = _T("CR (Unix)"); break; }
|
||||
case wxSTC_EOL_CRLF: {EOLtype = _T("CRLF (Windows)"); break; }
|
||||
case wxSTC_EOL_LF: {EOLtype = _T("CR (Macintosh)"); break; }
|
||||
}
|
||||
textinfo->Add (new wxStaticText (this, -1, _("Line endings"),
|
||||
wxDefaultPosition, wxSize(80, -1)),
|
||||
0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT, 4);
|
||||
textinfo->Add (new wxStaticText (this, -1, EOLtype),
|
||||
0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 4);
|
||||
|
||||
// text info box
|
||||
wxStaticBoxSizer *textinfos = new wxStaticBoxSizer (
|
||||
new wxStaticBox (this, -1, _("Informations")),
|
||||
wxVERTICAL);
|
||||
textinfos->Add (textinfo, 0, wxEXPAND);
|
||||
textinfos->Add (0, 6);
|
||||
|
||||
// statistic
|
||||
wxGridSizer *statistic = new wxGridSizer (4, 0, 2);
|
||||
statistic->Add (new wxStaticText (this, -1, _("Total lines"),
|
||||
wxDefaultPosition, wxSize(80, -1)),
|
||||
0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT, 4);
|
||||
text = wxString::Format (_T("%d"), edit->GetLineCount());
|
||||
statistic->Add (new wxStaticText (this, -1, text),
|
||||
0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 4);
|
||||
statistic->Add (new wxStaticText (this, -1, _("Total chars"),
|
||||
wxDefaultPosition, wxSize(80, -1)),
|
||||
0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT, 4);
|
||||
text = wxString::Format (_T("%d"), edit->GetTextLength());
|
||||
statistic->Add (new wxStaticText (this, -1, text),
|
||||
0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 4);
|
||||
statistic->Add (new wxStaticText (this, -1, _("Current line"),
|
||||
wxDefaultPosition, wxSize(80, -1)),
|
||||
0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT, 4);
|
||||
text = wxString::Format (_T("%d"), edit->GetCurrentLine());
|
||||
statistic->Add (new wxStaticText (this, -1, text),
|
||||
0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 4);
|
||||
statistic->Add (new wxStaticText (this, -1, _("Current pos"),
|
||||
wxDefaultPosition, wxSize(80, -1)),
|
||||
0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT, 4);
|
||||
text = wxString::Format (_T("%d"), edit->GetCurrentPos());
|
||||
statistic->Add (new wxStaticText (this, -1, text),
|
||||
0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 4);
|
||||
|
||||
// char/line statistics
|
||||
wxStaticBoxSizer *statistics = new wxStaticBoxSizer (
|
||||
new wxStaticBox (this, -1, _("Statistics")),
|
||||
wxVERTICAL);
|
||||
statistics->Add (statistic, 0, wxEXPAND);
|
||||
statistics->Add (0, 6);
|
||||
|
||||
// total pane
|
||||
wxBoxSizer *totalpane = new wxBoxSizer (wxVERTICAL);
|
||||
totalpane->Add (fullname, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 10);
|
||||
totalpane->Add (0, 6);
|
||||
totalpane->Add (textinfos, 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
|
||||
totalpane->Add (0, 10);
|
||||
totalpane->Add (statistics, 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
|
||||
totalpane->Add (0, 6);
|
||||
wxButton *okButton = new wxButton (this, wxID_OK, _("OK"));
|
||||
okButton->SetDefault();
|
||||
totalpane->Add (okButton, 0, wxALIGN_CENTER | wxALL, 10);
|
||||
|
||||
SetSizerAndFit (totalpane);
|
||||
|
||||
ShowModal();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// EditPrint
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
EditPrint::EditPrint (Edit *edit, wxChar *title)
|
||||
: wxPrintout(title) {
|
||||
m_edit = edit;
|
||||
m_printed = 0;
|
||||
|
||||
}
|
||||
|
||||
bool EditPrint::OnPrintPage (int page) {
|
||||
|
||||
wxDC *dc = GetDC();
|
||||
if (!dc) return false;
|
||||
|
||||
// scale DC
|
||||
PrintScaling (dc);
|
||||
|
||||
// print page
|
||||
if (page == 1) m_printed = 0;
|
||||
m_printed = m_edit->FormatRange (1, m_printed, m_edit->GetLength(),
|
||||
dc, dc, m_printRect, m_pageRect);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EditPrint::OnBeginDocument (int startPage, int endPage) {
|
||||
|
||||
if (!wxPrintout::OnBeginDocument (startPage, endPage)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EditPrint::GetPageInfo (int *minPage, int *maxPage, int *selPageFrom, int *selPageTo) {
|
||||
|
||||
// initialize values
|
||||
*minPage = 0;
|
||||
*maxPage = 0;
|
||||
*selPageFrom = 0;
|
||||
*selPageTo = 0;
|
||||
|
||||
// scale DC if possible
|
||||
wxDC *dc = GetDC();
|
||||
if (!dc) return;
|
||||
PrintScaling (dc);
|
||||
|
||||
// get print page informations and convert to printer pixels
|
||||
wxSize ppiScr;
|
||||
GetPPIScreen (&ppiScr.x, &ppiScr.y);
|
||||
wxSize page = g_pageSetupData->GetPaperSize();
|
||||
page.x = static_cast<int> (page.x * ppiScr.x / 25.4);
|
||||
page.y = static_cast<int> (page.y * ppiScr.y / 25.4);
|
||||
m_pageRect = wxRect (0,
|
||||
0,
|
||||
page.x,
|
||||
page.y);
|
||||
|
||||
// get margins informations and convert to printer pixels
|
||||
int top = 25; // default 25
|
||||
int bottom = 25; // default 25
|
||||
int left = 20; // default 20
|
||||
int right = 20; // default 20
|
||||
wxPoint (top, left) = g_pageSetupData->GetMarginTopLeft();
|
||||
wxPoint (bottom, right) = g_pageSetupData->GetMarginBottomRight();
|
||||
top = static_cast<int> (top * ppiScr.y / 25.4);
|
||||
bottom = static_cast<int> (bottom * ppiScr.y / 25.4);
|
||||
left = static_cast<int> (left * ppiScr.x / 25.4);
|
||||
right = static_cast<int> (right * ppiScr.x / 25.4);
|
||||
m_printRect = wxRect (left,
|
||||
top,
|
||||
page.x - (left + right),
|
||||
page.y - (top + bottom));
|
||||
|
||||
// count pages
|
||||
while (HasPage (*maxPage)) {
|
||||
m_printed = m_edit->FormatRange (0, m_printed, m_edit->GetLength(),
|
||||
dc, dc, m_printRect, m_pageRect);
|
||||
*maxPage += 1;
|
||||
}
|
||||
if (*maxPage > 0) *minPage = 1;
|
||||
*selPageFrom = *minPage;
|
||||
*selPageTo = *maxPage;
|
||||
}
|
||||
|
||||
bool EditPrint::HasPage (int WXUNUSED(page)) {
|
||||
|
||||
return (m_printed < m_edit->GetLength());
|
||||
}
|
||||
|
||||
bool EditPrint::PrintScaling (wxDC *dc){
|
||||
|
||||
// check for dc, return if none
|
||||
if (!dc) return false;
|
||||
|
||||
// get printer and screen sizing values
|
||||
wxSize ppiScr;
|
||||
GetPPIScreen (&ppiScr.x, &ppiScr.y);
|
||||
if (ppiScr.x == 0) { // most possible guess 96 dpi
|
||||
ppiScr.x = 96;
|
||||
ppiScr.y = 96;
|
||||
}
|
||||
wxSize ppiPrt;
|
||||
GetPPIPrinter (&ppiPrt.x, &ppiPrt.y);
|
||||
if (ppiPrt.x == 0) { // scaling factor to 1
|
||||
ppiPrt.x = ppiScr.x;
|
||||
ppiPrt.y = ppiScr.y;
|
||||
}
|
||||
wxSize dcSize = dc->GetSize();
|
||||
wxSize pageSize;
|
||||
GetPageSizePixels (&pageSize.x, &pageSize.y);
|
||||
|
||||
// set user scale
|
||||
float scale_x = (float)(ppiPrt.x * dcSize.x) /
|
||||
(float)(ppiScr.x * pageSize.x);
|
||||
float scale_y = (float)(ppiPrt.y * dcSize.y) /
|
||||
(float)(ppiScr.y * pageSize.y);
|
||||
dc->SetUserScale (scale_x, scale_y);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
169
contrib/samples/stc/edit.h
Normal file
169
contrib/samples/stc/edit.h
Normal file
@@ -0,0 +1,169 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// File: edit.h
|
||||
// Purpose: STC test module
|
||||
// Maintainer: Wyo
|
||||
// Created: 2003-09-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxGuide
|
||||
// Licence: wxWindows licence
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _EDIT_H_
|
||||
#define _EDIT_H_
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// informations
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// headers
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//! wxWindows headers
|
||||
|
||||
//! wxWindows/contrib headers
|
||||
#include <wx/stc/stc.h> // styled text control
|
||||
|
||||
//! application headers
|
||||
#include "prefs.h" // preferences
|
||||
|
||||
|
||||
//============================================================================
|
||||
// declarations
|
||||
//============================================================================
|
||||
|
||||
class EditPrint;
|
||||
class EditProperties;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//! Edit
|
||||
class Edit: public wxStyledTextCtrl {
|
||||
friend class EditProperties;
|
||||
friend class EditPrint;
|
||||
|
||||
public:
|
||||
//! constructor
|
||||
Edit (wxWindow *parent, wxWindowID id = -1,
|
||||
const wxPoint &pos = wxDefaultPosition,
|
||||
const wxSize &size = wxDefaultSize,
|
||||
long style = wxSUNKEN_BORDER|wxVSCROLL
|
||||
);
|
||||
|
||||
//! destructor
|
||||
~Edit ();
|
||||
|
||||
// event handlers
|
||||
// common
|
||||
void OnSize( wxSizeEvent &event );
|
||||
// edit
|
||||
void OnEditRedo (wxCommandEvent &event);
|
||||
void OnEditUndo (wxCommandEvent &event);
|
||||
void OnEditClear (wxCommandEvent &event);
|
||||
void OnEditCut (wxCommandEvent &event);
|
||||
void OnEditCopy (wxCommandEvent &event);
|
||||
void OnEditPaste (wxCommandEvent &event);
|
||||
// find
|
||||
void OnFind (wxCommandEvent &event);
|
||||
void OnFindNext (wxCommandEvent &event);
|
||||
void OnReplace (wxCommandEvent &event);
|
||||
void OnReplaceNext (wxCommandEvent &event);
|
||||
void OnBraceMatch (wxCommandEvent &event);
|
||||
void OnGoto (wxCommandEvent &event);
|
||||
void OnEditIndentInc (wxCommandEvent &event);
|
||||
void OnEditIndentRed (wxCommandEvent &event);
|
||||
void OnEditSelectAll (wxCommandEvent &event);
|
||||
void OnEditSelectLine (wxCommandEvent &event);
|
||||
//! view
|
||||
void OnHilightLang (wxCommandEvent &event);
|
||||
void OnDisplayEOL (wxCommandEvent &event);
|
||||
void OnIndentGuide (wxCommandEvent &event);
|
||||
void OnLineNumber (wxCommandEvent &event);
|
||||
void OnLongLineOn (wxCommandEvent &event);
|
||||
void OnWhiteSpace (wxCommandEvent &event);
|
||||
void OnFoldToggle (wxCommandEvent &event);
|
||||
void OnSetOverType (wxCommandEvent &event);
|
||||
void OnSetReadOnly (wxCommandEvent &event);
|
||||
void OnWrapmodeOn (wxCommandEvent &event);
|
||||
void OnUseCharset (wxCommandEvent &event);
|
||||
//! extra
|
||||
void OnChangeCase (wxCommandEvent &event);
|
||||
void OnConvertEOL (wxCommandEvent &event);
|
||||
// stc
|
||||
void OnMarginClick (wxStyledTextEvent &event);
|
||||
void OnCharAdded (wxStyledTextEvent &event);
|
||||
|
||||
//! language/lexer
|
||||
wxString DeterminePrefs (const wxString &filename);
|
||||
bool InitializePrefs (const wxString &filename);
|
||||
bool UserSettings (const wxString &filename);
|
||||
LanguageInfo const* GetLanguageInfo () {return m_language;};
|
||||
|
||||
//! load/save file
|
||||
bool LoadFile ();
|
||||
bool LoadFile (const wxString &filename);
|
||||
bool SaveFile ();
|
||||
bool SaveFile (const wxString &filename);
|
||||
bool Modified ();
|
||||
wxString GetFilename () {return m_filename;};
|
||||
void SetFilename (const wxString &filename) {m_filename = filename;};
|
||||
|
||||
private:
|
||||
// file
|
||||
wxString m_filename;
|
||||
|
||||
// lanugage properties
|
||||
LanguageInfo const* m_language;
|
||||
|
||||
// margin variables
|
||||
int m_LineNrID;
|
||||
int m_LineNrMargin;
|
||||
int m_FoldingID;
|
||||
int m_FoldingMargin;
|
||||
int m_DividerID;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//! EditProperties
|
||||
class EditProperties: public wxDialog {
|
||||
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
EditProperties (Edit *edit, long style = 0);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//! EditPrint
|
||||
class EditPrint: public wxPrintout {
|
||||
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
EditPrint (Edit *edit, wxChar *title = _T(""));
|
||||
|
||||
//! event handlers
|
||||
bool OnPrintPage (int page);
|
||||
bool OnBeginDocument (int startPage, int endPage);
|
||||
|
||||
//! print functions
|
||||
bool HasPage (int page);
|
||||
void GetPageInfo (int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
|
||||
|
||||
private:
|
||||
Edit *m_edit;
|
||||
int m_printed;
|
||||
wxRect m_pageRect;
|
||||
wxRect m_printRect;
|
||||
|
||||
bool PrintScaling (wxDC *dc);
|
||||
};
|
||||
|
||||
#endif // _EDIT_H_
|
||||
|
@@ -12,7 +12,7 @@ WXDIR = $(WXWIN)
|
||||
TARGET=stctest
|
||||
|
||||
EXTRALIBS=$(WXDIR)\lib\stc.lib
|
||||
OBJECTS = $(TARGET).obj
|
||||
OBJECTS = $(TARGET).obj edit.obj prefs.obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.b32
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
WXDIR = ../../..
|
||||
|
||||
TARGET = stctest
|
||||
OBJECTS = $(TARGET).o
|
||||
OBJECTS = $(TARGET).o edit.o prefs.o
|
||||
EXTRAINC = -I$(WXDIR)/contrib/include
|
||||
EXTRALIBS = -lstc
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
WXDIR = $(WXWIN)
|
||||
PROGRAM = stctest
|
||||
|
||||
OBJECTS = $(PROGRAM).obj
|
||||
OBJECTS = $(PROGRAM).obj edit.obj prefs.obj
|
||||
EXTRALIBS = $(WXDIR)\lib\stc$(LIBEXT).lib
|
||||
EXTRAINC = -I$(WXDIR)\contrib\include
|
||||
|
||||
|
@@ -6,7 +6,7 @@ WXDIR = $(%WXWIN)
|
||||
EXTRACPPFLAGS = -I$(WXDIR)\contrib\include
|
||||
PROGRAM = stctest
|
||||
EXTRALIBS = $(WXDIR)\lib\stc_w.lib
|
||||
OBJECTS = $(OUTPUTDIR)\$(PROGRAM).obj
|
||||
OBJECTS = $(OUTPUTDIR)\$(PROGRAM).obj $(OUTPUTDIR)\edit.obj $(OUTPUTDIR)\prefs.obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.wat
|
||||
|
||||
|
BIN
contrib/samples/stc/mondrian.ico
Normal file
BIN
contrib/samples/stc/mondrian.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 766 B |
44
contrib/samples/stc/mondrian.xpm
Normal file
44
contrib/samples/stc/mondrian.xpm
Normal file
@@ -0,0 +1,44 @@
|
||||
/* XPM */
|
||||
static char *mondrian_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"32 32 6 1",
|
||||
" c Black",
|
||||
". c Blue",
|
||||
"X c #00bf00",
|
||||
"o c Red",
|
||||
"O c Yellow",
|
||||
"+ c Gray100",
|
||||
/* pixels */
|
||||
" ",
|
||||
" oooooo +++++++++++++++++++++++ ",
|
||||
" oooooo +++++++++++++++++++++++ ",
|
||||
" oooooo +++++++++++++++++++++++ ",
|
||||
" oooooo +++++++++++++++++++++++ ",
|
||||
" oooooo +++++++++++++++++++++++ ",
|
||||
" oooooo +++++++++++++++++++++++ ",
|
||||
" oooooo +++++++++++++++++++++++ ",
|
||||
" ",
|
||||
" ++++++ ++++++++++++++++++ .... ",
|
||||
" ++++++ ++++++++++++++++++ .... ",
|
||||
" ++++++ ++++++++++++++++++ .... ",
|
||||
" ++++++ ++++++++++++++++++ .... ",
|
||||
" ++++++ ++++++++++++++++++ .... ",
|
||||
" ++++++ ++++++++++++++++++ ",
|
||||
" ++++++ ++++++++++++++++++ ++++ ",
|
||||
" ++++++ ++++++++++++++++++ ++++ ",
|
||||
" ++++++ ++++++++++++++++++ ++++ ",
|
||||
" ++++++ ++++++++++++++++++ ++++ ",
|
||||
" ++++++ ++++++++++++++++++ ++++ ",
|
||||
" ++++++ ++++++++++++++++++ ++++ ",
|
||||
" ++++++ ++++++++++++++++++ ++++ ",
|
||||
" ++++++ ++++++++++++++++++ ++++ ",
|
||||
" ++++++ ++++++++++++++++++ ++++ ",
|
||||
" ++++++ ++++ ",
|
||||
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
||||
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
||||
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
||||
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
||||
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
||||
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
||||
" "
|
||||
};
|
379
contrib/samples/stc/prefs.cpp
Normal file
379
contrib/samples/stc/prefs.cpp
Normal file
@@ -0,0 +1,379 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// File: prefs.cpp
|
||||
// Purpose: STC test Preferences initialization
|
||||
// Maintainer: Wyo
|
||||
// Created: 2003-09-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxGuide
|
||||
// Licence: wxWindows licence
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// headers
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// For compilers that support precompilation, includes <wx/wx.h>.
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
// for all others, include the necessary headers (this file is usually all you
|
||||
// need because it includes almost all 'standard' wxWindows headers)
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
//! wxWindows headers
|
||||
|
||||
//! wxWindows/contrib headers
|
||||
|
||||
//! application headers
|
||||
#include "defsext.h" // Additional definitions
|
||||
#include "prefs.h" // Preferences
|
||||
|
||||
|
||||
//============================================================================
|
||||
// declarations
|
||||
//============================================================================
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//! language types
|
||||
const CommonInfo g_CommonPrefs = {
|
||||
// editor functionality prefs
|
||||
true, // syntaxEnable
|
||||
true, // foldEnable
|
||||
true, // indentEnable
|
||||
// display defaults prefs
|
||||
false, // overTypeInitial
|
||||
false, // readOnlyInitial
|
||||
false, // wrapModeInitial
|
||||
false, // displayEOLEnable
|
||||
false, // IndentGuideEnable
|
||||
true, // lineNumberEnable
|
||||
false, // longLineOnEnable
|
||||
false, // whiteSpaceEnable
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// keywordlists
|
||||
// C++
|
||||
wxChar* CppWordlist1 =
|
||||
_T("asm auto bool break case catch char class const const_cast \
|
||||
continue default delete do double dynamic_cast else enum explicit \
|
||||
export extern false float for friend goto if inline int long \
|
||||
mutable namespace new operator private protected public register \
|
||||
reinterpret_cast return short signed sizeof static static_cast \
|
||||
struct switch template this throw true try typedef typeid \
|
||||
typename union unsigned using virtual void volatile wchar_t \
|
||||
while");
|
||||
wxChar* CppWordlist2 =
|
||||
_T("file");
|
||||
wxChar* CppWordlist3 =
|
||||
_T("a addindex addtogroup anchor arg attention author b brief bug c \
|
||||
class code date def defgroup deprecated dontinclude e em endcode \
|
||||
endhtmlonly endif endlatexonly endlink endverbatim enum example \
|
||||
exception f$ f[ f] file fn hideinitializer htmlinclude \
|
||||
htmlonly if image include ingroup internal invariant interface \
|
||||
latexonly li line link mainpage name namespace nosubgrouping note \
|
||||
overload p page par param post pre ref relates remarks return \
|
||||
retval sa section see showinitializer since skip skipline struct \
|
||||
subsection test throw todo typedef union until var verbatim \
|
||||
verbinclude version warning weakgroup $ @ "" & < > # { }");
|
||||
|
||||
// Python
|
||||
wxChar* PythonWordlist1 =
|
||||
_T("and assert break class continue def del elif else except exec \
|
||||
finally for from global if import in is lambda None not or pass \
|
||||
print raise return try while yield");
|
||||
wxChar* PythonWordlist2 =
|
||||
_T("ACCELERATORS ALT AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON BEGIN \
|
||||
BITMAP BLOCK BUTTON CAPTION CHARACTERISTICS CHECKBOX CLASS \
|
||||
COMBOBOX CONTROL CTEXT CURSOR DEFPUSHBUTTON DIALOG DIALOGEX \
|
||||
DISCARDABLE EDITTEXT END EXSTYLE FONT GROUPBOX ICON LANGUAGE \
|
||||
LISTBOX LTEXT MENU MENUEX MENUITEM MESSAGETABLE POPUP PUSHBUTTON \
|
||||
RADIOBUTTON RCDATA RTEXT SCROLLBAR SEPARATOR SHIFT STATE3 \
|
||||
STRINGTABLE STYLE TEXTINCLUDE VALUE VERSION VERSIONINFO VIRTKEY");
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//! languages
|
||||
const LanguageInfo g_LanguagePrefs [] = {
|
||||
// C++
|
||||
{_T("C++"),
|
||||
_T("*.c;*.cc;*.cpp;*.cxx;*.cs;*.h;*.hh;*.hpp;*.hxx;*.sma"),
|
||||
wxSTC_LEX_CPP,
|
||||
{{mySTC_TYPE_DEFAULT, NULL},
|
||||
{mySTC_TYPE_COMMENT, NULL},
|
||||
{mySTC_TYPE_COMMENT_LINE, NULL},
|
||||
{mySTC_TYPE_COMMENT_DOC, NULL},
|
||||
{mySTC_TYPE_NUMBER, NULL},
|
||||
{mySTC_TYPE_WORD1, CppWordlist1}, // KEYWORDS
|
||||
{mySTC_TYPE_STRING, NULL},
|
||||
{mySTC_TYPE_CHARACTER, NULL},
|
||||
{mySTC_TYPE_UUID, NULL},
|
||||
{mySTC_TYPE_PREPROCESSOR, NULL},
|
||||
{mySTC_TYPE_OPERATOR, NULL},
|
||||
{mySTC_TYPE_IDENTIFIER, NULL},
|
||||
{mySTC_TYPE_STRING_EOL, NULL},
|
||||
{mySTC_TYPE_DEFAULT, NULL}, // VERBATIM
|
||||
{mySTC_TYPE_REGEX, NULL},
|
||||
{mySTC_TYPE_COMMENT_SPECIAL, NULL}, // DOXY
|
||||
{mySTC_TYPE_WORD2, CppWordlist2}, // EXTRA WORDS
|
||||
{mySTC_TYPE_WORD3, CppWordlist3}, // DOXY KEYWORDS
|
||||
{mySTC_TYPE_ERROR, NULL}, // KEYWORDS ERROR
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL}},
|
||||
mySTC_FOLD_COMMENT | mySTC_FOLD_COMPACT | mySTC_FOLD_PREPROC},
|
||||
// Python
|
||||
{_T("Python"),
|
||||
_T("*.py;*.pyw"),
|
||||
wxSTC_LEX_PYTHON,
|
||||
{{mySTC_TYPE_DEFAULT, NULL},
|
||||
{mySTC_TYPE_COMMENT_LINE, NULL},
|
||||
{mySTC_TYPE_NUMBER, NULL},
|
||||
{mySTC_TYPE_STRING, NULL},
|
||||
{mySTC_TYPE_CHARACTER, NULL},
|
||||
{mySTC_TYPE_WORD1, PythonWordlist1}, // KEYWORDS
|
||||
{mySTC_TYPE_DEFAULT, NULL}, // TRIPLE
|
||||
{mySTC_TYPE_DEFAULT, NULL}, // TRIPLEDOUBLE
|
||||
{mySTC_TYPE_DEFAULT, NULL}, // CLASSNAME
|
||||
{mySTC_TYPE_DEFAULT, PythonWordlist2}, // DEFNAME
|
||||
{mySTC_TYPE_OPERATOR, NULL},
|
||||
{mySTC_TYPE_IDENTIFIER, NULL},
|
||||
{mySTC_TYPE_DEFAULT, NULL}, // COMMENT_BLOCK
|
||||
{mySTC_TYPE_STRING_EOL, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL}},
|
||||
mySTC_FOLD_COMMENTPY | mySTC_FOLD_QUOTESPY},
|
||||
// * (any)
|
||||
{(wxChar *)DEFAULT_LANGUAGE,
|
||||
_T("*.*"),
|
||||
wxSTC_LEX_PROPERTIES,
|
||||
{{mySTC_TYPE_DEFAULT, NULL},
|
||||
{mySTC_TYPE_DEFAULT, NULL},
|
||||
{mySTC_TYPE_DEFAULT, NULL},
|
||||
{mySTC_TYPE_DEFAULT, NULL},
|
||||
{mySTC_TYPE_DEFAULT, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL},
|
||||
{-1, NULL}},
|
||||
0},
|
||||
};
|
||||
|
||||
const int g_LanguagePrefsSize = WXSIZEOF(g_LanguagePrefs);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//! style types
|
||||
const StyleInfo g_StylePrefs [] = {
|
||||
// mySTC_TYPE_DEFAULT
|
||||
{_T("Default"),
|
||||
_T("BLACK"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_WORD1
|
||||
{_T("Keyword1"),
|
||||
_T("BLUE"), _T("WHITE"),
|
||||
_T(""), 10, mySTC_STYLE_BOLD, 0},
|
||||
|
||||
// mySTC_TYPE_WORD2
|
||||
{_T("Keyword2"),
|
||||
_T("DARK BLUE"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_WORD3
|
||||
{_T("Keyword3"),
|
||||
_T("CORNFLOWER BLUE"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_WORD4
|
||||
{_T("Keyword4"),
|
||||
_T("CYAN"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_WORD5
|
||||
{_T("Keyword5"),
|
||||
_T("DARK GREY"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_WORD6
|
||||
{_T("Keyword6"),
|
||||
_T("GREY"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_COMMENT
|
||||
{_T("Comment"),
|
||||
_T("FOREST GREEN"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_COMMENT_DOC
|
||||
{_T("Comment (Doc)"),
|
||||
_T("FOREST GREEN"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_COMMENT_LINE
|
||||
{_T("Comment line"),
|
||||
_T("FOREST GREEN"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_COMMENT_SPECIAL
|
||||
{_T("Special comment"),
|
||||
_T("FOREST GREEN"), _T("WHITE"),
|
||||
_T(""), 10, mySTC_STYLE_ITALIC, 0},
|
||||
|
||||
// mySTC_TYPE_CHARACTER
|
||||
{_T("Character"),
|
||||
_T("KHAKI"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_CHARACTER_EOL
|
||||
{_T("Character (EOL)"),
|
||||
_T("KHAKI"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_STRING
|
||||
{_T("String"),
|
||||
_T("BROWN"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_STRING_EOL
|
||||
{_T("String (EOL)"),
|
||||
_T("BROWN"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_DELIMITER
|
||||
{_T("Delimiter"),
|
||||
_T("ORANGE"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_PUNCTUATION
|
||||
{_T("Punctuation"),
|
||||
_T("ORANGE"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_OPERATOR
|
||||
{_T("Operator"),
|
||||
_T("BLACK"), _T("WHITE"),
|
||||
_T(""), 10, mySTC_STYLE_BOLD, 0},
|
||||
|
||||
// mySTC_TYPE_BRACE
|
||||
{_T("Label"),
|
||||
_T("VIOLET"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_COMMAND
|
||||
{_T("Command"),
|
||||
_T("BLUE"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_IDENTIFIER
|
||||
{_T("Identifier"),
|
||||
_T("BLACK"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_LABEL
|
||||
{_T("Label"),
|
||||
_T("VIOLET"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_NUMBER
|
||||
{_T("Number"),
|
||||
_T("SIENNA"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_PARAMETER
|
||||
{_T("Parameter"),
|
||||
_T("VIOLET"), _T("WHITE"),
|
||||
_T(""), 10, mySTC_STYLE_ITALIC, 0},
|
||||
|
||||
// mySTC_TYPE_REGEX
|
||||
{_T("Regular expression"),
|
||||
_T("ORCHID"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_UUID
|
||||
{_T("UUID"),
|
||||
_T("ORCHID"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_VALUE
|
||||
{_T("Value"),
|
||||
_T("ORCHID"), _T("WHITE"),
|
||||
_T(""), 10, mySTC_STYLE_ITALIC, 0},
|
||||
|
||||
// mySTC_TYPE_PREPROCESSOR
|
||||
{_T("Preprocessor"),
|
||||
_T("GREY"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_SCRIPT
|
||||
{_T("Script"),
|
||||
_T("DARK GREY"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_ERROR
|
||||
{_T("Error"),
|
||||
_T("RED"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0},
|
||||
|
||||
// mySTC_TYPE_UNDEFINED
|
||||
{_T("Undefined"),
|
||||
_T("ORANGE"), _T("WHITE"),
|
||||
_T(""), 10, 0, 0}
|
||||
|
||||
};
|
||||
|
||||
const int g_StylePrefsSize = WXSIZEOF(g_StylePrefs);
|
||||
|
153
contrib/samples/stc/prefs.h
Normal file
153
contrib/samples/stc/prefs.h
Normal file
@@ -0,0 +1,153 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// File: prefs.h
|
||||
// Purpose: STC test Preferences initialization
|
||||
// Maintainer: Wyo
|
||||
// Created: 2003-09-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxGuide
|
||||
// Licence: wxWindows licence
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _PREFS_H_
|
||||
#define _PREFS_H_
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// informations
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// headers
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//! wxWindows headers
|
||||
|
||||
//! wxWindows/contrib headers
|
||||
#include <wx/stc/stc.h> // styled text control
|
||||
|
||||
//! application headers
|
||||
|
||||
|
||||
//============================================================================
|
||||
// declarations
|
||||
//============================================================================
|
||||
|
||||
//! general style types
|
||||
#define mySTC_TYPE_DEFAULT 0
|
||||
|
||||
#define mySTC_TYPE_WORD1 1
|
||||
#define mySTC_TYPE_WORD2 2
|
||||
#define mySTC_TYPE_WORD3 3
|
||||
#define mySTC_TYPE_WORD4 4
|
||||
#define mySTC_TYPE_WORD5 5
|
||||
#define mySTC_TYPE_WORD6 6
|
||||
|
||||
#define mySTC_TYPE_COMMENT 7
|
||||
#define mySTC_TYPE_COMMENT_DOC 8
|
||||
#define mySTC_TYPE_COMMENT_LINE 9
|
||||
#define mySTC_TYPE_COMMENT_SPECIAL 10
|
||||
|
||||
#define mySTC_TYPE_CHARACTER 11
|
||||
#define mySTC_TYPE_CHARACTER_EOL 12
|
||||
#define mySTC_TYPE_STRING 13
|
||||
#define mySTC_TYPE_STRING_EOL 14
|
||||
|
||||
#define mySTC_TYPE_DELIMITER 15
|
||||
|
||||
#define mySTC_TYPE_PUNCTUATION 16
|
||||
|
||||
#define mySTC_TYPE_OPERATOR 17
|
||||
|
||||
#define mySTC_TYPE_BRACE 18
|
||||
|
||||
#define mySTC_TYPE_COMMAND 19
|
||||
#define mySTC_TYPE_IDENTIFIER 20
|
||||
#define mySTC_TYPE_LABEL 21
|
||||
#define mySTC_TYPE_NUMBER 22
|
||||
#define mySTC_TYPE_PARAMETER 23
|
||||
#define mySTC_TYPE_REGEX 24
|
||||
#define mySTC_TYPE_UUID 25
|
||||
#define mySTC_TYPE_VALUE 26
|
||||
|
||||
#define mySTC_TYPE_PREPROCESSOR 27
|
||||
#define mySTC_TYPE_SCRIPT 28
|
||||
|
||||
#define mySTC_TYPE_ERROR 29
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//! style bits types
|
||||
#define mySTC_STYLE_BOLD 1
|
||||
#define mySTC_STYLE_ITALIC 2
|
||||
#define mySTC_STYLE_UNDERL 4
|
||||
#define mySTC_STYLE_HIDDEN 8
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//! general folding types
|
||||
#define mySTC_FOLD_COMMENT 1
|
||||
#define mySTC_FOLD_COMPACT 2
|
||||
#define mySTC_FOLD_PREPROC 4
|
||||
|
||||
#define mySTC_FOLD_HTML 16
|
||||
#define mySTC_FOLD_HTMLPREP 32
|
||||
|
||||
#define mySTC_FOLD_COMMENTPY 64
|
||||
#define mySTC_FOLD_QUOTESPY 128
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//! flags
|
||||
#define mySTC_FLAG_WRAPMODE 16
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// CommonInfo
|
||||
|
||||
struct CommonInfo {
|
||||
// editor functionality prefs
|
||||
bool syntaxEnable;
|
||||
bool foldEnable;
|
||||
bool indentEnable;
|
||||
// display defaults prefs
|
||||
bool readOnlyInitial;
|
||||
bool overTypeInitial;
|
||||
bool wrapModeInitial;
|
||||
bool displayEOLEnable;
|
||||
bool indentGuideEnable;
|
||||
bool lineNumberEnable;
|
||||
bool longLineOnEnable;
|
||||
bool whiteSpaceEnable;
|
||||
};
|
||||
extern const CommonInfo g_CommonPrefs;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// LanguageInfo
|
||||
|
||||
struct LanguageInfo {
|
||||
wxChar *name;
|
||||
wxChar *filepattern;
|
||||
int lexer;
|
||||
struct {
|
||||
int type;
|
||||
const wxChar *words;
|
||||
} styles [STYLE_TYPES_COUNT];
|
||||
int folds;
|
||||
};
|
||||
|
||||
extern const LanguageInfo g_LanguagePrefs[];
|
||||
extern const int g_LanguagePrefsSize;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// StyleInfo
|
||||
struct StyleInfo {
|
||||
wxChar *name;
|
||||
wxChar *foreground;
|
||||
wxChar *background;
|
||||
wxChar *fontname;
|
||||
int fontsize;
|
||||
int fontstyle;
|
||||
int lettercase;
|
||||
};
|
||||
|
||||
extern const StyleInfo g_StylePrefs[];
|
||||
extern const int g_StylePrefsSize;
|
||||
|
||||
#endif // _PREFS_H_
|
||||
|
@@ -1,254 +1,662 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: stctest.cpp
|
||||
// Purpose: sample of using wxStyledTextCtrl
|
||||
// Author: Robin Dunn
|
||||
// Modified by:
|
||||
// Created: 3-Feb-2000
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// File: app.cpp
|
||||
// Purpose: STC test application
|
||||
// Maintainer: Otto Wyss
|
||||
// Created: 2003-09-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 by Total Control Software
|
||||
// Copyright: (c) wxGuide
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma implementation "stctest.cpp"
|
||||
#pragma interface "stctest.cpp"
|
||||
#endif
|
||||
//----------------------------------------------------------------------------
|
||||
// headers
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
// For compilers that support precompilation, includes <wx/wx.h>.
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
// for all others, include the necessary headers (this file is usually all you
|
||||
// need because it includes almost all "standard" wxWindows headers
|
||||
// need because it includes almost all 'standard' wxWindows headers)
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/wfstream.h>
|
||||
//! wxWindows headers
|
||||
#include <wx/config.h> // configuration support
|
||||
#include <wx/filedlg.h> // file dialog support
|
||||
#include <wx/filename.h> // filename support
|
||||
#include <wx/notebook.h> // notebook support
|
||||
#include <wx/settings.h> // system settings
|
||||
#include <wx/string.h> // strings support
|
||||
#include <wx/image.h> // images support
|
||||
|
||||
#include <wx/stc/stc.h>
|
||||
//! application headers
|
||||
#include "defsext.h" // Additional definitions
|
||||
#include "edit.h" // Edit module
|
||||
#include "prefs.h" // Prefs
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class MyApp : public wxApp
|
||||
{
|
||||
//----------------------------------------------------------------------------
|
||||
// resources
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// the application icon (under Windows and OS/2 it is in resources)
|
||||
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
|
||||
#include "mondrian.xpm"
|
||||
#endif
|
||||
|
||||
//============================================================================
|
||||
// declarations
|
||||
//============================================================================
|
||||
|
||||
#define APP_NAME _T("STC-Test")
|
||||
#define APP_DESCR _("See http://wxguide.sourceforge.net/")
|
||||
|
||||
#define APP_MAINT _T("Otto Wyss")
|
||||
#define APP_VENDOR _T("wxWindows")
|
||||
#define APP_COPYRIGTH _T("(C) 2003 Otto Wyss")
|
||||
#define APP_LICENCE _T("wxWindows")
|
||||
|
||||
#define APP_VERSION _T("0.1.alpha")
|
||||
#define APP_BUILD __DATE__
|
||||
|
||||
#define APP_WEBSITE _T("http://www.wxWindows.org")
|
||||
#define APP_MAIL _T("mailto://???")
|
||||
|
||||
#define NONAME _("<untitled>")
|
||||
|
||||
class AppBook;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//! global application name
|
||||
wxString *g_appname = NULL;
|
||||
|
||||
//! global print data, to remember settings during the session
|
||||
wxPrintData *g_printData = (wxPrintData*) NULL;
|
||||
wxPageSetupData *g_pageSetupData = (wxPageSetupData*) NULL;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//! application APP_VENDOR-APP_NAME.
|
||||
class App: public wxApp {
|
||||
friend class AppFrame;
|
||||
|
||||
public:
|
||||
virtual bool OnInit();
|
||||
};
|
||||
//! the main function called durning application start
|
||||
virtual bool OnInit ();
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Make an editor class
|
||||
|
||||
class MySTC : public wxStyledTextCtrl
|
||||
{
|
||||
public:
|
||||
MySTC(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0);
|
||||
|
||||
void OnKeyPressed(wxKeyEvent& evt);
|
||||
//! application exit function
|
||||
virtual int OnExit ();
|
||||
|
||||
private:
|
||||
//! frame window
|
||||
AppFrame* m_frame;
|
||||
|
||||
};
|
||||
|
||||
// created dynamically by wxWindows
|
||||
DECLARE_APP (App);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//! frame of the application APP_VENDOR-APP_NAME.
|
||||
class AppFrame: public wxFrame {
|
||||
friend class App;
|
||||
friend class AppBook;
|
||||
friend class AppAbout;
|
||||
|
||||
public:
|
||||
//! constructor
|
||||
AppFrame (const wxString &title);
|
||||
|
||||
//! destructor
|
||||
~AppFrame ();
|
||||
|
||||
//! event handlers
|
||||
//! common
|
||||
void OnClose (wxCloseEvent &event);
|
||||
void OnAbout (wxCommandEvent &event);
|
||||
void OnExit (wxCommandEvent &event);
|
||||
void OnTimerEvent (wxTimerEvent &event);
|
||||
//! file
|
||||
void OnFileNew (wxCommandEvent &event);
|
||||
void OnFileNewFrame (wxCommandEvent &event);
|
||||
void OnFileOpen (wxCommandEvent &event);
|
||||
void OnFileOpenFrame (wxCommandEvent &event);
|
||||
void OnFileSave (wxCommandEvent &event);
|
||||
void OnFileSaveAs (wxCommandEvent &event);
|
||||
void OnFileClose (wxCommandEvent &event);
|
||||
//! properties
|
||||
void OnProperties (wxCommandEvent &event);
|
||||
//! print
|
||||
void OnPrintSetup (wxCommandEvent &event);
|
||||
void OnPrintPreview (wxCommandEvent &event);
|
||||
void OnPrint (wxCommandEvent &event);
|
||||
//! edit events
|
||||
void OnEdit (wxCommandEvent &event);
|
||||
|
||||
private:
|
||||
// edit object
|
||||
Edit *m_edit;
|
||||
void FileOpen (wxString fname);
|
||||
|
||||
//! creates the application menu bar
|
||||
wxMenuBar *m_menuBar;
|
||||
void CreateMenu ();
|
||||
|
||||
// print preview position and size
|
||||
wxRect DeterminePrintSize ();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(MySTC, wxStyledTextCtrl)
|
||||
EVT_KEY_DOWN(MySTC::OnKeyPressed)
|
||||
END_EVENT_TABLE()
|
||||
//----------------------------------------------------------------------------
|
||||
//! about box of the application APP_VENDOR-APP_NAME
|
||||
class AppAbout: public wxDialog {
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Define a new frame type: this is going to be our main frame
|
||||
class MyFrame : public wxFrame
|
||||
{
|
||||
public:
|
||||
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
|
||||
//! constructor
|
||||
AppAbout (wxWindow *parent,
|
||||
int milliseconds = 0,
|
||||
long style = 0);
|
||||
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
//! destructor
|
||||
~AppAbout ();
|
||||
|
||||
// event handlers
|
||||
void OnTimerEvent (wxTimerEvent &event);
|
||||
|
||||
private:
|
||||
MySTC* ed;
|
||||
// timer
|
||||
wxTimer *m_timer;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
// IDs for the controls and the menu commands
|
||||
enum
|
||||
{
|
||||
// menu items
|
||||
ID_Quit = 1,
|
||||
ID_About,
|
||||
ID_ED
|
||||
};
|
||||
//============================================================================
|
||||
// implementation
|
||||
//============================================================================
|
||||
|
||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU (ID_Quit, MyFrame::OnQuit)
|
||||
EVT_MENU (ID_About, MyFrame::OnAbout)
|
||||
END_EVENT_TABLE()
|
||||
IMPLEMENT_APP (App)
|
||||
|
||||
IMPLEMENT_APP(MyApp)
|
||||
//----------------------------------------------------------------------------
|
||||
// App
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// `Main program' equivalent: the program execution "starts" here
|
||||
bool App::OnInit () {
|
||||
|
||||
bool MyApp::OnInit()
|
||||
{
|
||||
MyFrame *frame = new MyFrame(_T("Testing wxStyledTextCtrl"),
|
||||
wxPoint(5, 5), wxSize(600, 600));
|
||||
wxInitAllImageHandlers();
|
||||
|
||||
// set application and vendor name
|
||||
SetAppName (APP_NAME);
|
||||
SetVendorName (APP_VENDOR);
|
||||
g_appname = new wxString ();
|
||||
g_appname->Append (APP_VENDOR);
|
||||
g_appname->Append (_T("-"));
|
||||
g_appname->Append (APP_NAME);
|
||||
|
||||
frame->Show(TRUE);
|
||||
return TRUE;
|
||||
// initialize print data and setup
|
||||
g_printData = new wxPrintData;
|
||||
g_pageSetupData = new wxPageSetupDialogData;
|
||||
|
||||
// create application frame
|
||||
m_frame = new AppFrame (*g_appname);
|
||||
|
||||
// open application frame
|
||||
m_frame->Layout ();
|
||||
m_frame->Show (true);
|
||||
SetTopWindow (m_frame);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int App::OnExit () {
|
||||
|
||||
// frame constructor
|
||||
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
|
||||
{
|
||||
#ifdef __WXMAC__
|
||||
// we need this in order to allow the about menu relocation, since ABOUT is
|
||||
// not the default id of the about menu
|
||||
wxApp::s_macAboutMenuItemId = ID_About;
|
||||
#endif
|
||||
// delete global appname
|
||||
delete g_appname;
|
||||
|
||||
// delete global print data and setup
|
||||
if (g_printData) delete g_printData;
|
||||
if (g_pageSetupData) delete g_pageSetupData;
|
||||
|
||||
// create a menu bar
|
||||
wxMenu *menuFile = new wxMenu(wxEmptyString, wxMENU_TEAROFF);
|
||||
|
||||
// the "About" item should be in the help menu
|
||||
wxMenu *helpMenu = new wxMenu;
|
||||
helpMenu->Append(ID_About, _T("&About...\tCtrl-A"), _T("Show about dialog"));
|
||||
|
||||
menuFile->Append(ID_Quit, _T("E&xit\tAlt-X"), _T("Quit this program"));
|
||||
|
||||
// now append the freshly created menu to the menu bar...
|
||||
wxMenuBar *menuBar = new wxMenuBar();
|
||||
menuBar->Append(menuFile, _T("&File"));
|
||||
menuBar->Append(helpMenu, _T("&Help"));
|
||||
|
||||
// ... and attach this menu bar to the frame
|
||||
SetMenuBar(menuBar);
|
||||
|
||||
#if wxUSE_STATUSBAR
|
||||
CreateStatusBar(2);
|
||||
SetStatusText(_T("Testing wxStyledTextCtrl"));
|
||||
#endif // wxUSE_STATUSBAR
|
||||
|
||||
|
||||
//----------------------------------------
|
||||
// Setup the editor
|
||||
ed = new MySTC(this, ID_ED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// AppFrame
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// event handlers
|
||||
BEGIN_EVENT_TABLE (AppFrame, wxFrame)
|
||||
// common
|
||||
EVT_CLOSE ( AppFrame::OnClose)
|
||||
// file
|
||||
EVT_MENU (wxID_OPEN, AppFrame::OnFileOpen)
|
||||
EVT_MENU (wxID_SAVE, AppFrame::OnFileSave)
|
||||
EVT_MENU (wxID_SAVEAS, AppFrame::OnFileSaveAs)
|
||||
EVT_MENU (wxID_CLOSE, AppFrame::OnFileClose)
|
||||
// properties
|
||||
EVT_MENU (myID_PROPERTIES, AppFrame::OnProperties)
|
||||
// print and exit
|
||||
EVT_MENU (wxID_PRINT_SETUP, AppFrame::OnPrintSetup)
|
||||
EVT_MENU (wxID_PREVIEW, AppFrame::OnPrintPreview)
|
||||
EVT_MENU (wxID_PRINT, AppFrame::OnPrint)
|
||||
EVT_MENU (wxID_EXIT, AppFrame::OnExit)
|
||||
// edit
|
||||
EVT_MENU (wxID_CLEAR, AppFrame::OnEdit)
|
||||
EVT_MENU (wxID_CUT, AppFrame::OnEdit)
|
||||
EVT_MENU (wxID_COPY, AppFrame::OnEdit)
|
||||
EVT_MENU (wxID_PASTE, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_INDENTINC, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_INDENTRED, AppFrame::OnEdit)
|
||||
EVT_MENU (wxID_SELECTALL, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_SELECTLINE, AppFrame::OnEdit)
|
||||
EVT_MENU (wxID_REDO, AppFrame::OnEdit)
|
||||
EVT_MENU (wxID_UNDO, AppFrame::OnEdit)
|
||||
// find
|
||||
EVT_MENU (wxID_FIND, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_FINDNEXT, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_REPLACE, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_REPLACENEXT, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_BRACEMATCH, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_GOTO, AppFrame::OnEdit)
|
||||
// view
|
||||
EVT_MENU_RANGE (myID_HILIGHTFIRST, myID_HILIGHTLAST,
|
||||
AppFrame::OnEdit)
|
||||
EVT_MENU (myID_DISPLAYEOL, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_INDENTGUIDE, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_LINENUMBER, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_LONGLINEON, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_WHITESPACE, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_FOLDTOGGLE, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_OVERTYPE, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_READONLY, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_WRAPMODEON, AppFrame::OnEdit)
|
||||
// extra
|
||||
EVT_MENU (myID_CHANGELOWER, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_CHANGEUPPER, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_CONVERTCR, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_CONVERTCRLF, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_CONVERTLF, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_CHARSETANSI, AppFrame::OnEdit)
|
||||
EVT_MENU (myID_CHARSETMAC, AppFrame::OnEdit)
|
||||
// help
|
||||
EVT_MENU (wxID_ABOUT, AppFrame::OnAbout)
|
||||
END_EVENT_TABLE ()
|
||||
|
||||
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
// TRUE is to force the frame to close
|
||||
Close(TRUE);
|
||||
AppFrame::AppFrame (const wxString &title)
|
||||
: wxFrame ((wxFrame *)NULL, -1, title, wxDefaultPosition, wxDefaultSize,
|
||||
wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) {
|
||||
|
||||
// intitialize important variables
|
||||
m_edit = NULL;
|
||||
|
||||
// set icon and background
|
||||
SetTitle (*g_appname);
|
||||
SetIcon (wxICON (mondrian));
|
||||
SetBackgroundColour (_T("WHITE"));
|
||||
|
||||
// about box shown for 1 seconds
|
||||
AppAbout (this, 1000);
|
||||
|
||||
// create menu
|
||||
m_menuBar = new wxMenuBar;
|
||||
CreateMenu ();
|
||||
|
||||
// open first page
|
||||
m_edit = new Edit (this, -1);
|
||||
m_edit->SetFocus();
|
||||
|
||||
FileOpen (_T("stctest.cpp"));
|
||||
}
|
||||
|
||||
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _T("Testing wxStyledTextCtrl...\n"));
|
||||
|
||||
wxMessageBox(msg, _T("About This Test"), wxOK | wxICON_INFORMATION, this);
|
||||
AppFrame::~AppFrame () {
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
wxChar* keywords =
|
||||
_T("asm auto bool break case catch char class const \
|
||||
const_cast continue default delete do double \
|
||||
dynamic_cast else enum explicit export extern \
|
||||
false float for friend goto if inline int long \
|
||||
mutable namespace new operator private protected \
|
||||
public register reinterpret_cast return short signed \
|
||||
sizeof static static_cast struct switch template this \
|
||||
throw true try typedef typeid typename union unsigned \
|
||||
using virtual void volatile wchar_t while");
|
||||
|
||||
|
||||
|
||||
MySTC::MySTC(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size,
|
||||
long style)
|
||||
: wxStyledTextCtrl(parent, id, pos, size, style)
|
||||
{
|
||||
// Default font
|
||||
wxFont font(10, wxMODERN, wxNORMAL, wxNORMAL);
|
||||
StyleSetFont(wxSTC_STYLE_DEFAULT, font);
|
||||
StyleClearAll();
|
||||
|
||||
StyleSetForeground(0, wxColour(0x80, 0x80, 0x80));
|
||||
StyleSetForeground(1, wxColour(0x00, 0x7f, 0x00));
|
||||
//StyleSetForeground(2, wxColour(0x00, 0x7f, 0x00));
|
||||
StyleSetForeground(3, wxColour(0x7f, 0x7f, 0x7f));
|
||||
StyleSetForeground(4, wxColour(0x00, 0x7f, 0x7f));
|
||||
StyleSetForeground(5, wxColour(0x00, 0x00, 0x7f));
|
||||
StyleSetForeground(6, wxColour(0x7f, 0x00, 0x7f));
|
||||
StyleSetForeground(7, wxColour(0x7f, 0x00, 0x7f));
|
||||
StyleSetForeground(8, wxColour(0x00, 0x7f, 0x7f));
|
||||
StyleSetForeground(9, wxColour(0x7f, 0x7f, 0x7f));
|
||||
StyleSetForeground(10, wxColour(0x00, 0x00, 0x00));
|
||||
StyleSetForeground(11, wxColour(0x00, 0x00, 0x00));
|
||||
StyleSetBold(5, TRUE);
|
||||
StyleSetBold(10, TRUE);
|
||||
|
||||
#ifdef __WXMSW__
|
||||
StyleSetSpec(2, _T("fore:#007f00,bold,face:Arial,size:9"));
|
||||
#else
|
||||
StyleSetSpec(2, _T("fore:#007f00,bold,face:Helvetica,size:9"));
|
||||
#endif
|
||||
|
||||
// give it some text to play with
|
||||
wxString st;
|
||||
wxFileInputStream stream(wxT("stctest.cpp"));
|
||||
size_t sz = stream.GetSize();
|
||||
char* buf = new char[sz + 1];
|
||||
stream.Read((void*) buf, stream.GetSize());
|
||||
buf[sz] = 0;
|
||||
st = wxString::FromAscii(buf);
|
||||
delete[] buf;
|
||||
|
||||
InsertText(0, st);
|
||||
EmptyUndoBuffer();
|
||||
|
||||
SetLexer(wxSTC_LEX_CPP);
|
||||
SetKeyWords(0, keywords);
|
||||
// common event handlers
|
||||
void AppFrame::OnClose (wxCloseEvent &event) {
|
||||
wxCommandEvent evt;
|
||||
OnFileClose (evt);
|
||||
if (m_edit && m_edit->Modified()) {
|
||||
if (event.CanVeto()) event.Veto (true);
|
||||
return;
|
||||
}
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void MySTC::OnKeyPressed(wxKeyEvent& evt)
|
||||
{
|
||||
if (CallTipActive())
|
||||
CallTipCancel();
|
||||
void AppFrame::OnAbout (wxCommandEvent &WXUNUSED(event)) {
|
||||
AppAbout (this);
|
||||
}
|
||||
|
||||
int key = evt.GetKeyCode();
|
||||
if ( key == WXK_SPACE && evt.ControlDown()) {
|
||||
int pos = GetCurrentPos();
|
||||
void AppFrame::OnExit (wxCommandEvent &WXUNUSED(event)) {
|
||||
Close (true);
|
||||
}
|
||||
|
||||
if (evt.ShiftDown()) {
|
||||
// show how to do CallTips
|
||||
CallTipSetBackground(wxColour(_T("YELLOW")));
|
||||
CallTipShow(pos, _T("lots of of text: blah, blah, blah\n\n"
|
||||
"show some suff, maybe parameters..\n\n"
|
||||
"fubar(param1, param2)"));
|
||||
// file event handlers
|
||||
void AppFrame::OnFileOpen (wxCommandEvent &WXUNUSED(event)) {
|
||||
if (!m_edit) return;
|
||||
wxString fname;
|
||||
wxFileDialog dlg (this, _T("Open file"), _T(""), _T(""), _T("Any file (*)|*"),
|
||||
wxOPEN | wxFILE_MUST_EXIST | wxCHANGE_DIR);
|
||||
if (dlg.ShowModal() != wxID_OK) return;
|
||||
fname = dlg.GetPath ();
|
||||
FileOpen (fname);
|
||||
}
|
||||
|
||||
void AppFrame::OnFileSave (wxCommandEvent &WXUNUSED(event)) {
|
||||
if (!m_edit) return;
|
||||
if (!m_edit->Modified()) {
|
||||
wxMessageBox (_("There is nothing to save!"), _("Save file"),
|
||||
wxOK | wxICON_EXCLAMATION);
|
||||
return;
|
||||
}
|
||||
m_edit->SaveFile ();
|
||||
}
|
||||
|
||||
void AppFrame::OnFileSaveAs (wxCommandEvent &WXUNUSED(event)) {
|
||||
if (!m_edit) return;
|
||||
wxString filename = wxEmptyString;
|
||||
wxFileDialog dlg (this, _T("Save file"), _T(""), _T(""), _T("Any file (*)|*"), wxSAVE|wxOVERWRITE_PROMPT);
|
||||
if (dlg.ShowModal() != wxID_OK) return;
|
||||
filename = dlg.GetPath();
|
||||
m_edit->SaveFile (filename);
|
||||
}
|
||||
|
||||
void AppFrame::OnFileClose (wxCommandEvent &WXUNUSED(event)) {
|
||||
if (!m_edit) return;
|
||||
if (m_edit->Modified()) {
|
||||
if (wxMessageBox (_("Text is not saved, save before closing?"), _("Close"),
|
||||
wxYES_NO | wxICON_QUESTION) == wxYES) {
|
||||
m_edit->SaveFile();
|
||||
if (m_edit->Modified()) {
|
||||
wxMessageBox (_("Text could not be saved!"), _("Close abort"),
|
||||
wxOK | wxICON_EXCLAMATION);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// show how to do AutoComplete
|
||||
AutoCompSetIgnoreCase(false);
|
||||
AutoCompShow(0, keywords); // reuse the keyword list here
|
||||
// normally you would build a string of completion texts...
|
||||
Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
// properties event handlers
|
||||
void AppFrame::OnProperties (wxCommandEvent &WXUNUSED(event)) {
|
||||
if (!m_edit) return;
|
||||
EditProperties (m_edit, 0);
|
||||
}
|
||||
|
||||
// print event handlers
|
||||
void AppFrame::OnPrintSetup (wxCommandEvent &WXUNUSED(event)) {
|
||||
(*g_pageSetupData) = * g_printData;
|
||||
wxPageSetupDialog pageSetupDialog(this, g_pageSetupData);
|
||||
pageSetupDialog.ShowModal();
|
||||
(*g_printData) = pageSetupDialog.GetPageSetupData().GetPrintData();
|
||||
(*g_pageSetupData) = pageSetupDialog.GetPageSetupData();
|
||||
}
|
||||
|
||||
void AppFrame::OnPrintPreview (wxCommandEvent &WXUNUSED(event)) {
|
||||
wxPrintDialogData printDialogData( *g_printData);
|
||||
wxPrintPreview *preview =
|
||||
new wxPrintPreview (new EditPrint (m_edit),
|
||||
new EditPrint (m_edit),
|
||||
&printDialogData);
|
||||
if (!preview->Ok()) {
|
||||
delete preview;
|
||||
wxMessageBox (_("There was a problem with previewing.\n\
|
||||
Perhaps your current printer is not correctly?"),
|
||||
_("Previewing"), wxOK);
|
||||
return;
|
||||
}
|
||||
wxRect rect = DeterminePrintSize();
|
||||
wxPreviewFrame *frame = new wxPreviewFrame (preview, this, _("Print Preview"));
|
||||
frame->SetSize (rect);
|
||||
frame->Centre(wxBOTH);
|
||||
frame->Initialize();
|
||||
frame->Show(true);
|
||||
}
|
||||
|
||||
void AppFrame::OnPrint (wxCommandEvent &WXUNUSED(event)) {
|
||||
wxPrintDialogData printDialogData( *g_printData);
|
||||
wxPrinter printer (&printDialogData);
|
||||
EditPrint printout (m_edit);
|
||||
if (!printer.Print (this, &printout, true)) {
|
||||
if (wxPrinter::GetLastError() == wxPRINTER_ERROR) {
|
||||
wxMessageBox (_("There was a problem with printing.\n\
|
||||
Perhaps your current printer is not correctly?"),
|
||||
_("Previewing"), wxOK);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
evt.Skip();
|
||||
(*g_printData) = printer.GetPrintDialogData().GetPrintData();
|
||||
}
|
||||
|
||||
// edit events
|
||||
void AppFrame::OnEdit (wxCommandEvent &event) {
|
||||
if (m_edit) m_edit->ProcessEvent (event);
|
||||
}
|
||||
|
||||
// private functions
|
||||
void AppFrame::CreateMenu () {
|
||||
|
||||
// File menu
|
||||
wxMenu *menuFile = new wxMenu;
|
||||
menuFile->Append (wxID_OPEN, _("&Open ..\tCtrl+O"));
|
||||
menuFile->Append (wxID_SAVE, _("&Save\tCtrl+S"));
|
||||
menuFile->Append (wxID_SAVEAS, _("Save &as ..\tCtrl+Shift+S"));
|
||||
menuFile->Append (wxID_CLOSE, _("&Close\tCtrl+W"));
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append (myID_PROPERTIES, _("Proper&ties ..\tCtrl+I"));
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append (wxID_PRINT_SETUP, _("Print Set&up .."));
|
||||
menuFile->Append (wxID_PREVIEW, _("Print Pre&view\tCtrl+Shift+P"));
|
||||
menuFile->Append (wxID_PRINT, _("&Print ..\tCtrl+P"));
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append (wxID_EXIT, _("&Quit\tCtrl+Q"));
|
||||
|
||||
// Edit menu
|
||||
wxMenu *menuEdit = new wxMenu;
|
||||
menuEdit->Append (wxID_UNDO, _("&Undo\tCtrl+Z"));
|
||||
menuEdit->Append (wxID_REDO, _("&Redo\tCtrl+Shift+Z"));
|
||||
menuEdit->AppendSeparator();
|
||||
menuEdit->Append (wxID_CUT, _("Cu&t\tCtrl+X"));
|
||||
menuEdit->Append (wxID_COPY, _("&Copy\tCtrl+C"));
|
||||
menuEdit->Append (wxID_PASTE, _("&Paste\tCtrl+V"));
|
||||
menuEdit->Append (wxID_CLEAR, _("&Delete\tDel"));
|
||||
menuEdit->AppendSeparator();
|
||||
menuEdit->Append (wxID_FIND, _("&Find\tCtrl+F"));
|
||||
menuEdit->Enable (wxID_FIND, false);
|
||||
menuEdit->Append (myID_FINDNEXT, _("Find &next\tF3"));
|
||||
menuEdit->Enable (myID_FINDNEXT, false);
|
||||
menuEdit->Append (myID_REPLACE, _("&Replace\tCtrl+H"));
|
||||
menuEdit->Enable (myID_REPLACE, false);
|
||||
menuEdit->Append (myID_REPLACENEXT, _("Replace &again\tShift+F4"));
|
||||
menuEdit->Enable (myID_REPLACENEXT, false);
|
||||
menuEdit->AppendSeparator();
|
||||
menuEdit->Append (myID_BRACEMATCH, _("&Match brace\tCtrl+M"));
|
||||
menuEdit->Append (myID_GOTO, _("&Goto\tCtrl+G"));
|
||||
menuEdit->Enable (myID_GOTO, false);
|
||||
menuEdit->AppendSeparator();
|
||||
menuEdit->Append (myID_INDENTINC, _("&Indent increase\tTab"));
|
||||
menuEdit->Append (myID_INDENTRED, _("I&ndent reduce\tBksp"));
|
||||
menuEdit->AppendSeparator();
|
||||
menuEdit->Append (wxID_SELECTALL, _("&Select all\tCtrl+A"));
|
||||
menuEdit->Append (myID_SELECTLINE, _("Select &line\tCtrl+L"));
|
||||
|
||||
// hilight submenu
|
||||
wxMenu *menuHilight = new wxMenu;
|
||||
int Nr;
|
||||
for (Nr = 0; Nr < g_LanguagePrefsSize; Nr++) {
|
||||
menuHilight->Append (myID_HILIGHTFIRST + Nr,
|
||||
g_LanguagePrefs [Nr].name);
|
||||
}
|
||||
|
||||
// charset submenu
|
||||
wxMenu *menuCharset = new wxMenu;
|
||||
menuCharset->Append (myID_CHARSETANSI, _("&ANSI (Windows)"));
|
||||
menuCharset->Append (myID_CHARSETMAC, _("&MAC (Macintosh)"));
|
||||
|
||||
// View menu
|
||||
wxMenu *menuView = new wxMenu;
|
||||
menuView->Append (myID_HILIGHTLANG, _("&Hilight language .."), menuHilight);
|
||||
menuView->AppendSeparator();
|
||||
menuView->AppendCheckItem (myID_FOLDTOGGLE, _("&Toggle current fold\tCtrl+T"));
|
||||
menuView->AppendCheckItem (myID_OVERTYPE, _("&Overwrite mode\tIns"));
|
||||
menuView->AppendCheckItem (myID_WRAPMODEON, _("&Wrap mode\tCtrl+U"));
|
||||
menuView->AppendSeparator();
|
||||
menuView->AppendCheckItem (myID_DISPLAYEOL, _("Show line &endings"));
|
||||
menuView->AppendCheckItem (myID_INDENTGUIDE, _("Show &indent guides"));
|
||||
menuView->AppendCheckItem (myID_LINENUMBER, _("Show line &numbers"));
|
||||
menuView->AppendCheckItem (myID_LONGLINEON, _("Show &long line marker"));
|
||||
menuView->AppendCheckItem (myID_WHITESPACE, _("Show white&space"));
|
||||
menuView->AppendSeparator();
|
||||
menuView->Append (myID_USECHARSET, _("Use &code page of .."), menuCharset);
|
||||
|
||||
// change case submenu
|
||||
wxMenu *menuChangeCase = new wxMenu;
|
||||
menuChangeCase->Append (myID_CHANGEUPPER, _("&Upper case"));
|
||||
menuChangeCase->Append (myID_CHANGELOWER, _("&Lower case"));
|
||||
|
||||
// convert EOL submenu
|
||||
wxMenu *menuConvertEOL = new wxMenu;
|
||||
menuConvertEOL->Append (myID_CONVERTCR, _("CR (&Linux)"));
|
||||
menuConvertEOL->Append (myID_CONVERTCRLF, _("CR+LF (&Windows)"));
|
||||
menuConvertEOL->Append (myID_CONVERTLF, _("LF (&Macintosh)"));
|
||||
|
||||
// Extra menu
|
||||
wxMenu *menuExtra = new wxMenu;
|
||||
menuExtra->AppendCheckItem (myID_READONLY, _("&Readonly mode"));
|
||||
menuExtra->AppendSeparator();
|
||||
menuExtra->Append (myID_CHANGECASE, _("Change &case to .."), menuChangeCase);
|
||||
menuExtra->AppendSeparator();
|
||||
menuExtra->Append (myID_CONVERTEOL, _("Convert line &endings to .."), menuConvertEOL);
|
||||
|
||||
// Window menu
|
||||
wxMenu *menuWindow = new wxMenu;
|
||||
menuWindow->Append (myID_PAGEPREV, _("&Previous\tCtrl+Shift+Tab"));
|
||||
menuWindow->Append (myID_PAGENEXT, _("&Next\tCtrl+Tab"));
|
||||
|
||||
// Help menu
|
||||
wxMenu *menuHelp = new wxMenu;
|
||||
menuHelp->Append (wxID_ABOUT, _("&About ..\tShift+F1"));
|
||||
|
||||
// construct menu
|
||||
m_menuBar->Append (menuFile, _("&File"));
|
||||
m_menuBar->Append (menuEdit, _("&Edit"));
|
||||
m_menuBar->Append (menuView, _("&View"));
|
||||
m_menuBar->Append (menuExtra, _("E&xtra"));
|
||||
m_menuBar->Append (menuWindow, _("&Window"));
|
||||
m_menuBar->Append (menuHelp, _("&Help"));
|
||||
SetMenuBar (m_menuBar);
|
||||
|
||||
}
|
||||
|
||||
void AppFrame::FileOpen (wxString fname) {
|
||||
wxFileName w(fname); w.Normalize(); fname = w.GetFullPath();
|
||||
m_edit->LoadFile (fname);
|
||||
}
|
||||
|
||||
wxRect AppFrame::DeterminePrintSize () {
|
||||
|
||||
wxSize scr = wxGetDisplaySize();
|
||||
|
||||
// determine position and size (shifting 16 left and down)
|
||||
wxRect rect = GetRect();
|
||||
rect.x += 16;
|
||||
rect.y += 16;
|
||||
rect.width = wxMin (rect.width, (scr.x - rect.x));
|
||||
rect.height = wxMin (rect.height, (scr.x - rect.y));
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// AppAbout
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
BEGIN_EVENT_TABLE (AppAbout, wxDialog)
|
||||
EVT_TIMER (myID_ABOUTTIMER, AppAbout::OnTimerEvent)
|
||||
END_EVENT_TABLE ()
|
||||
|
||||
AppAbout::AppAbout (wxWindow *parent,
|
||||
int milliseconds,
|
||||
long style)
|
||||
: wxDialog (parent, -1, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
style | wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {
|
||||
|
||||
// set timer if any
|
||||
m_timer = NULL;
|
||||
if (milliseconds > 0) {
|
||||
m_timer = new wxTimer (this, myID_ABOUTTIMER);
|
||||
m_timer->Start (milliseconds, wxTIMER_ONE_SHOT);
|
||||
}
|
||||
|
||||
// sets the application title
|
||||
SetTitle (_("About .."));
|
||||
|
||||
// about info
|
||||
wxGridSizer *aboutinfo = new wxGridSizer (2, 0, 2);
|
||||
aboutinfo->Add (new wxStaticText(this, -1, _("Written by: ")),
|
||||
0, wxALIGN_LEFT);
|
||||
aboutinfo->Add (new wxStaticText(this, -1, APP_MAINT),
|
||||
1, wxEXPAND | wxALIGN_LEFT);
|
||||
aboutinfo->Add (new wxStaticText(this, -1, _("Version: ")),
|
||||
0, wxALIGN_LEFT);
|
||||
aboutinfo->Add (new wxStaticText(this, -1, APP_VERSION),
|
||||
1, wxEXPAND | wxALIGN_LEFT);
|
||||
aboutinfo->Add (new wxStaticText(this, -1, _("Licence type: ")),
|
||||
0, wxALIGN_LEFT);
|
||||
aboutinfo->Add (new wxStaticText(this, -1, APP_LICENCE),
|
||||
1, wxEXPAND | wxALIGN_LEFT);
|
||||
aboutinfo->Add (new wxStaticText(this, -1, _("Copyright: ")),
|
||||
0, wxALIGN_LEFT);
|
||||
aboutinfo->Add (new wxStaticText(this, -1, APP_COPYRIGTH),
|
||||
1, wxEXPAND | wxALIGN_LEFT);
|
||||
|
||||
// about icontitle//info
|
||||
wxBoxSizer *aboutpane = new wxBoxSizer (wxHORIZONTAL);
|
||||
wxBitmap bitmap = wxBitmap(wxICON (mondrian));
|
||||
aboutpane->Add (new wxStaticBitmap (this, -1, bitmap),
|
||||
0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 20);
|
||||
aboutpane->Add (aboutinfo, 1, wxEXPAND);
|
||||
aboutpane->Add (60, 0);
|
||||
|
||||
// about complete
|
||||
wxBoxSizer *totalpane = new wxBoxSizer (wxVERTICAL);
|
||||
totalpane->Add (0, 20);
|
||||
wxStaticText *appname = new wxStaticText(this, -1, *g_appname);
|
||||
appname->SetFont (wxFont (24, wxDEFAULT, wxNORMAL, wxBOLD));
|
||||
totalpane->Add (appname, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, 40);
|
||||
totalpane->Add (0, 10);
|
||||
totalpane->Add (aboutpane, 0, wxEXPAND | wxALL, 4);
|
||||
totalpane->Add (new wxStaticText(this, -1, APP_DESCR),
|
||||
0, wxALIGN_CENTER | wxALL, 10);
|
||||
wxButton *okButton = new wxButton (this, wxID_OK, _("OK"));
|
||||
okButton->SetDefault();
|
||||
totalpane->Add (okButton, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT | wxBOTTOM, 10);
|
||||
|
||||
SetSizerAndFit (totalpane);
|
||||
|
||||
CenterOnScreen();
|
||||
ShowModal();
|
||||
}
|
||||
|
||||
AppAbout::~AppAbout () {
|
||||
if (m_timer) {
|
||||
delete m_timer;
|
||||
m_timer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// event handlers
|
||||
void AppAbout::OnTimerEvent (wxTimerEvent &WXUNUSED(event)) {
|
||||
if (m_timer) delete m_timer;
|
||||
m_timer = NULL;
|
||||
EndModal (wxID_OK);
|
||||
}
|
||||
|
||||
|
@@ -1 +1,5 @@
|
||||
mondrian ICON "mondrian.ico"
|
||||
#include "wx/msw/wx.rc"
|
||||
|
||||
|
||||
|
||||
|
6
contrib/samples/svg/makefile.sc
Normal file
6
contrib/samples/svg/makefile.sc
Normal file
@@ -0,0 +1,6 @@
|
||||
#Digital Mars (was Symantec) C++ makefile
|
||||
WXDIR = ..\..\..
|
||||
EXTRALIBS=dcsvg_sc
|
||||
TARGET=svgtest
|
||||
OBJECTS = $(TARGET).obj
|
||||
include $(WXDIR)\src\makeprog.sc
|
@@ -130,7 +130,7 @@
|
||||
</object>
|
||||
</object>
|
||||
<object class="notebookpage">
|
||||
<label>wxCheckList</label>
|
||||
<label>wxCheckListBox</label>
|
||||
<object class="wxPanel" name="checklist">
|
||||
<object class="wxFlexGridSizer">
|
||||
<cols>1</cols>
|
||||
@@ -142,7 +142,7 @@
|
||||
<object class="sizeritem">
|
||||
<flag>wxALIGN_CENTRE|wxALL</flag>
|
||||
<border>5</border>
|
||||
<object class="wxCheckList" name="conrols_checklist">
|
||||
<object class="wxCheckListBox" name="conrols_checklist">
|
||||
<size>180,180</size>
|
||||
<content>
|
||||
<item checked="1">Download library</item>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# $Id$
|
||||
|
||||
CONTRIB_SUBDIRS=canvas fl gizmos mmedia net ogl plot stc svg xrc #applet
|
||||
CONTRIB_SUBDIRS=canvas fl gizmos mmedia net ogl plot stc svg xrc animate #applet
|
||||
|
||||
all:
|
||||
@for d in $(CONTRIB_SUBDIRS); do (cd $$d && $(MAKE)); done
|
||||
|
@@ -314,7 +314,7 @@ void wxRemotelyScrolledTreeCtrl::AdjustRemoteScrollbars()
|
||||
if (scrolledWindow)
|
||||
{
|
||||
wxRect itemRect;
|
||||
if (GetBoundingRect(GetRootItem(), itemRect))
|
||||
if (GetBoundingRect(GetFirstVisibleItem(), itemRect))
|
||||
{
|
||||
// Actually, the real height seems to be 1 less than reported
|
||||
// (e.g. 16 instead of 16)
|
||||
|
@@ -141,15 +141,12 @@ bool wxMapiSession::Logon(const wxString& sProfileName, const wxString& sPasswor
|
||||
|
||||
//Setup the ascii versions of the profile name and password
|
||||
int nProfileLength = sProfileName.Length();
|
||||
int nPasswordLength = sPassword.Length();
|
||||
|
||||
LPSTR pszProfileName = NULL;
|
||||
LPSTR pszPassword = NULL;
|
||||
wxCharBuffer cbProfile(1),cbPassword(1);
|
||||
if (nProfileLength)
|
||||
{
|
||||
// pszProfileName = T2A((LPTSTR) (LPCTSTR) sProfileName);
|
||||
// pszPassword = T2A((LPTSTR) (LPCTSTR) sPassword);
|
||||
#ifndef UNICODE
|
||||
pszProfileName = (LPSTR) sProfileName.c_str();
|
||||
pszPassword = (LPSTR) sPassword.c_str();
|
||||
@@ -197,7 +194,7 @@ bool wxMapiSession::Logon(const wxString& sProfileName, const wxString& sPasswor
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogDebug(_T("Failed to logon to MAPI using a shared session, Error:%d\n"), nError);
|
||||
wxLogDebug(_T("Failed to logon to MAPI using a shared session, Error:%ld\n"), nError);
|
||||
m_data->m_nLastError = nError;
|
||||
}
|
||||
}
|
||||
@@ -234,7 +231,7 @@ bool wxMapiSession::Logoff()
|
||||
ULONG nError = m_data->m_lpfnMAPILogoff(m_data->m_hSession, 0, 0, 0);
|
||||
if (nError != SUCCESS_SUCCESS)
|
||||
{
|
||||
wxLogDebug(_T("Failed in call to MapiLogoff, Error:%d"), nError);
|
||||
wxLogDebug(_T("Failed in call to MapiLogoff, Error:%ld"), nError);
|
||||
m_data->m_nLastError = nError;
|
||||
bSuccess = TRUE;
|
||||
}
|
||||
@@ -259,7 +256,6 @@ bool wxMapiSession::Resolve(const wxString& sName, void* lppRecip1)
|
||||
wxASSERT(m_data->m_hSession); //MAPI session handle must be valid
|
||||
|
||||
//Call the MAPIResolveName function
|
||||
// LPSTR lpszAsciiName = T2A((LPTSTR) (LPCTSTR) sName);
|
||||
#ifndef UNICODE
|
||||
LPSTR lpszAsciiName = (LPSTR) sName.c_str();
|
||||
#else
|
||||
@@ -270,7 +266,8 @@ bool wxMapiSession::Resolve(const wxString& sName, void* lppRecip1)
|
||||
ULONG nError = m_data->m_lpfnMAPIResolveName(m_data->m_hSession, 0, lpszAsciiName, 0, 0, lppRecip);
|
||||
if (nError != SUCCESS_SUCCESS)
|
||||
{
|
||||
wxLogDebug(_T("Failed to resolve the name: %s, Error:%d\n"), sName, nError);
|
||||
wxLogDebug(_T("Failed to resolve the name: %s, Error:%ld\n"),
|
||||
sName.c_str(), nError);
|
||||
m_data->m_nLastError = nError;
|
||||
}
|
||||
|
||||
@@ -301,8 +298,6 @@ bool wxMapiSession::Send(wxMailMessage& message)
|
||||
mapiMessage.lpszSubject = cbSubject.data();
|
||||
mapiMessage.lpszNoteText = cbBody.data();
|
||||
#endif
|
||||
// mapiMessage.lpszSubject = T2A((LPTSTR) (LPCTSTR) message.m_subject);
|
||||
// mapiMessage.lpszNoteText = T2A((LPTSTR) (LPCTSTR) message.m_body);
|
||||
mapiMessage.nRecipCount = message.m_to.GetCount() + message.m_cc.GetCount() + message.m_bcc.GetCount();
|
||||
wxASSERT(mapiMessage.nRecipCount); //Must have at least 1 recipient!
|
||||
|
||||
@@ -341,12 +336,11 @@ bool wxMapiSession::Send(wxMailMessage& message)
|
||||
if (Resolve(sName, (void*) &lpTempRecip))
|
||||
{
|
||||
//Resolve worked, put the resolved name back into the sName
|
||||
sName = wxString(lpTempRecip->lpszName,wxConvCurrent);
|
||||
sName = wxString(lpTempRecip->lpszName,*wxConvCurrent);
|
||||
|
||||
//Don't forget to free up the memory MAPI allocated for us
|
||||
m_data->m_lpfnMAPIFreeBuffer(lpTempRecip);
|
||||
}
|
||||
//recip.lpszName = T2A((LPTSTR) (LPCTSTR) sName);
|
||||
#ifndef UNICODE
|
||||
recip.lpszName = (LPSTR) sName.c_str();
|
||||
#else
|
||||
@@ -370,12 +364,11 @@ bool wxMapiSession::Send(wxMailMessage& message)
|
||||
if (Resolve(sName, (void*) &lpTempRecip))
|
||||
{
|
||||
//Resolve worked, put the resolved name back into the sName
|
||||
sName = wxString(lpTempRecip->lpszName,wxConvCurrent);
|
||||
sName = wxString(lpTempRecip->lpszName,*wxConvCurrent);
|
||||
|
||||
//Don't forget to free up the memory MAPI allocated for us
|
||||
m_data->m_lpfnMAPIFreeBuffer(lpTempRecip);
|
||||
}
|
||||
//recip.lpszName = T2A((LPTSTR) (LPCTSTR) sName);
|
||||
#ifndef UNICODE
|
||||
recip.lpszName = (LPSTR) sName.c_str();
|
||||
#else
|
||||
@@ -404,7 +397,6 @@ bool wxMapiSession::Send(wxMailMessage& message)
|
||||
//Don't forget to free up the memory MAPI allocated for us
|
||||
m_data->m_lpfnMAPIFreeBuffer(lpTempRecip);
|
||||
}
|
||||
//recip.lpszName = T2A((LPTSTR) (LPCTSTR) sName);
|
||||
#ifndef UNICODE
|
||||
recip.lpszName = (LPSTR) sName.c_str();
|
||||
#else
|
||||
@@ -432,7 +424,6 @@ bool wxMapiSession::Send(wxMailMessage& message)
|
||||
ZeroMemory(&file, sizeof(MapiFileDesc));
|
||||
file.nPosition = 0xFFFFFFFF;
|
||||
wxString& sFilename = message.m_attachments[i];
|
||||
//file.lpszPathName = T2A((LPTSTR) (LPCTSTR) sFilename);
|
||||
|
||||
#ifndef UNICODE
|
||||
file.lpszPathName = (LPSTR) sFilename.c_str();
|
||||
@@ -445,7 +436,6 @@ bool wxMapiSession::Send(wxMailMessage& message)
|
||||
if (nTitleSize && !message.m_attachmentTitles[i].IsEmpty())
|
||||
{
|
||||
wxString& sTitle = message.m_attachmentTitles[i];
|
||||
//file.lpszFileName = T2A((LPTSTR) (LPCTSTR) sTitle);
|
||||
#ifndef UNICODE
|
||||
file.lpszFileName = (LPSTR) sTitle.c_str();
|
||||
#else
|
||||
@@ -464,7 +454,7 @@ bool wxMapiSession::Send(wxMailMessage& message)
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogDebug(_T("Failed to send mail message, Error:%d\n"), nError);
|
||||
wxLogDebug(_T("Failed to send mail message, Error:%ld\n"), nError);
|
||||
m_data->m_nLastError = nError;
|
||||
}
|
||||
|
||||
@@ -472,7 +462,7 @@ bool wxMapiSession::Send(wxMailMessage& message)
|
||||
if (nAttachmentSize)
|
||||
{
|
||||
#ifdef UNICODE
|
||||
for (int i = 0;i < nAttachmentSize;i++)
|
||||
for (i = 0;i < nAttachmentSize;i++)
|
||||
{
|
||||
free(mapiMessage.lpFiles[i].lpszPathName);
|
||||
free(mapiMessage.lpFiles[i].lpszFileName);
|
||||
@@ -483,7 +473,7 @@ bool wxMapiSession::Send(wxMailMessage& message)
|
||||
|
||||
//Free up the Recipients and Originator memory
|
||||
#ifdef UNICODE
|
||||
for (int i = 0;i < nRecipIndex;i++)
|
||||
for (i = 0;i < nRecipIndex;i++)
|
||||
free(mapiMessage.lpRecips[i].lpszName);
|
||||
#endif
|
||||
delete [] mapiMessage.lpRecips;
|
||||
|
@@ -18,7 +18,7 @@ HEADERS=basic.h basicp.h bmpshape.h canvas.h composit.h constrnt.h \
|
||||
divided.h drawn.h drawnp.h lines.h linesp.h mfutils.h misc.h \
|
||||
ogl.h ogldiag.h
|
||||
|
||||
OBJECTS=basic.o bmpshape.o composit.o divided.o lines.o misc.o \
|
||||
OBJECTS=basic.o bmpshape.o composit.o divided.o lines.o oglmisc.o \
|
||||
basic2.o canvas.o constrnt.o drawn.o mfutils.o ogldiag.o
|
||||
DEPFILES=$(OBJECTS:.o=.d)
|
||||
|
||||
|
@@ -124,11 +124,11 @@ SOURCE=.\mfutils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\misc.cpp
|
||||
SOURCE=.\ogldiag.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ogldiag.cpp
|
||||
SOURCE=.\oglmisc.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
|
@@ -507,22 +507,23 @@ bool wxLineShape::HitTest(double x, double y, int *attachment, double *distance)
|
||||
wxRealPoint *point1 = (wxRealPoint *)node->Data();
|
||||
wxRealPoint *point2 = (wxRealPoint *)node->Next()->Data();
|
||||
|
||||
// Allow for inaccurate mousing or vert/horiz lines
|
||||
// For inaccurate mousing allow 8 pixel corridor
|
||||
int extra = 4;
|
||||
double left = wxMin(point1->x, point2->x) - extra;
|
||||
double right = wxMax(point1->x, point2->x) + extra;
|
||||
|
||||
double bottom = wxMin(point1->y, point2->y) - extra;
|
||||
double top = wxMax(point1->y, point2->y) + extra;
|
||||
|
||||
if ((x > left && x < right && y > bottom && y < top) || inLabelRegion)
|
||||
double dx = point2->x - point1->x;
|
||||
double dy = point2->y - point1->y;
|
||||
double seg_len = sqrt(dx*dx+dy*dy);
|
||||
double distance_from_seg =
|
||||
seg_len*((x-point1->x)*dy-(y-point1->y)*dx)/(dy*dy+dx*dx);
|
||||
double distance_from_prev =
|
||||
seg_len*((y-point1->y)*dy+(x-point1->x)*dx)/(dy*dy+dx*dx);
|
||||
|
||||
if ((fabs(distance_from_seg) < extra &&
|
||||
distance_from_prev >= 0 && distance_from_prev <= seg_len)
|
||||
|| inLabelRegion)
|
||||
{
|
||||
// Work out distance from centre of line
|
||||
double centre_x = (double)(left + (right - left)/2.0);
|
||||
double centre_y = (double)(bottom + (top - bottom)/2.0);
|
||||
|
||||
*attachment = 0;
|
||||
*distance = (double)sqrt((centre_x - x)*(centre_x - x) + (centre_y - y)*(centre_y - y));
|
||||
*distance = distance_from_seg;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ WXDIR = $(WXWIN)
|
||||
|
||||
LIBTARGET=$(WXDIR)\lib\ogl.lib
|
||||
|
||||
OBJECTS = basic.obj basic2.obj canvas.obj ogldiag.obj lines.obj misc.obj divided.obj constrnt.obj\
|
||||
OBJECTS = basic.obj basic2.obj canvas.obj ogldiag.obj lines.obj oglmisc.obj divided.obj constrnt.obj\
|
||||
composit.obj drawn.obj bmpshape.obj mfutils.obj
|
||||
|
||||
!include $(WXDIR)\src\makelib.b32
|
||||
|
@@ -27,7 +27,7 @@ INC = /I$(WXDIR)\include /I$(WXDIR)\contrib\include
|
||||
# to disable PROLOGIO-dependent code
|
||||
OPTIONS = -DPROLOGIO
|
||||
|
||||
OBJECTS = basic.obj basic2.obj canvas.obj ogldiag.obj lines.obj misc.obj divided.obj constrnt.obj\
|
||||
OBJECTS = basic.obj basic2.obj canvas.obj ogldiag.obj lines.obj oglmisc.obj divided.obj constrnt.obj\
|
||||
composit.obj drawn.obj bitmap.obj mfutils.obj
|
||||
|
||||
all: $(GRAPHICSLIB)
|
||||
|
@@ -10,7 +10,7 @@
|
||||
WXDIR = ../../..
|
||||
|
||||
LIBTARGET=$(WXDIR)/lib/libogl.a
|
||||
OBJECTS = basic.o basic2.o canvas.o ogldiag.o lines.o misc.o divided.o constrnt.o\
|
||||
OBJECTS = basic.o basic2.o canvas.o ogldiag.o lines.o oglmisc.o divided.o constrnt.o\
|
||||
composit.o drawn.o bmpshape.o mfutils.o
|
||||
|
||||
include $(WXDIR)/src/makelib.g95
|
||||
|
@@ -19,7 +19,7 @@ LIB_CPP_SRC=\
|
||||
canvas.o\
|
||||
ogldiag.o\
|
||||
lines.o\
|
||||
misc.o\
|
||||
oglmisc.o\
|
||||
divided.o\
|
||||
constrnt.o\
|
||||
composit.o\
|
||||
|
@@ -25,7 +25,7 @@ DOCSOURCEDIR=$(WXDIR)\contrib\docs\latex\ogl
|
||||
|
||||
PROGRAM=test
|
||||
|
||||
OBJECTS = $(D)\basic.obj $(D)\basic2.obj $(D)\canvas.obj $(D)\ogldiag.obj $(D)\lines.obj $(D)\misc.obj $(D)\divided.obj $(D)\constrnt.obj\
|
||||
OBJECTS = $(D)\basic.obj $(D)\basic2.obj $(D)\canvas.obj $(D)\ogldiag.obj $(D)\lines.obj $(D)\oglmisc.obj $(D)\divided.obj $(D)\constrnt.obj\
|
||||
$(D)\composit.obj $(D)\drawn.obj $(D)\bmpshape.obj $(D)\mfutils.obj
|
||||
|
||||
LIBTARGET=$(WXDIR)\lib\ogl$(LIBEXT).lib
|
||||
@@ -82,7 +82,7 @@ $(D)\lines.obj: lines.$(SRCSUFF) $(OGLINC)/basic.h $(OGLINC)/misc.h $(OGLIN
|
||||
$(CPPFLAGS) /c /Fo$@ /Tp $(*B).$(SRCSUFF)
|
||||
<<
|
||||
|
||||
$(D)\misc.obj: misc.$(SRCSUFF) $(OGLINC)/basic.h $(OGLINC)/misc.h $(OGLINC)/constrnt.h $(OGLINC)/basicp.h
|
||||
$(D)\oglmisc.obj: oglmisc.$(SRCSUFF) $(OGLINC)/basic.h $(OGLINC)/misc.h $(OGLINC)/constrnt.h $(OGLINC)/basicp.h
|
||||
cl @<<
|
||||
$(CPPFLAGS) /c /Fo$@ /Tp $(*B).$(SRCSUFF)
|
||||
<<
|
||||
|
@@ -1,862 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: misc.cpp
|
||||
// Purpose: Miscellaneous OGL support functions
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "misc.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/wxexpr.h>
|
||||
|
||||
#include <wx/types.h>
|
||||
|
||||
#ifdef new
|
||||
#undef new
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <wx/ogl/basic.h>
|
||||
#include <wx/ogl/basicp.h>
|
||||
#include <wx/ogl/misc.h>
|
||||
#include <wx/ogl/constrnt.h>
|
||||
#include <wx/ogl/composit.h>
|
||||
|
||||
wxFont* g_oglNormalFont;
|
||||
wxPen* g_oglBlackPen;
|
||||
wxPen* g_oglTransparentPen;
|
||||
wxPen* g_oglBlackForegroundPen;
|
||||
wxPen* g_oglWhiteBackgroundPen;
|
||||
wxBrush* g_oglWhiteBackgroundBrush;
|
||||
|
||||
char* oglBuffer = NULL;
|
||||
|
||||
wxList oglObjectCopyMapping(wxKEY_INTEGER);
|
||||
|
||||
|
||||
|
||||
void wxOGLInitialize()
|
||||
{
|
||||
g_oglNormalFont = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL);
|
||||
g_oglBlackPen = wxThePenList->FindOrCreatePen(wxT("BLACK"), 1, wxSOLID);
|
||||
g_oglTransparentPen = wxThePenList->FindOrCreatePen(wxT("WHITE"), 1, wxTRANSPARENT);
|
||||
g_oglBlackForegroundPen = wxThePenList->FindOrCreatePen(wxT("BLACK"), 1, wxSOLID);
|
||||
g_oglWhiteBackgroundPen = wxThePenList->FindOrCreatePen(wxT("WHITE"), 1, wxSOLID);
|
||||
g_oglWhiteBackgroundBrush = wxTheBrushList->FindOrCreateBrush(wxT("WHITE"), wxSOLID);
|
||||
|
||||
OGLInitializeConstraintTypes();
|
||||
|
||||
// Initialize big buffer used when writing images
|
||||
oglBuffer = new char[3000];
|
||||
|
||||
}
|
||||
|
||||
void wxOGLCleanUp()
|
||||
{
|
||||
if (oglBuffer)
|
||||
{
|
||||
delete[] oglBuffer;
|
||||
oglBuffer = NULL;
|
||||
}
|
||||
oglBuffer = NULL;
|
||||
|
||||
g_oglNormalFont = NULL; // These will be cleaned up by their GDI list
|
||||
g_oglBlackPen = NULL;
|
||||
g_oglTransparentPen = NULL;
|
||||
g_oglBlackForegroundPen = NULL;
|
||||
g_oglWhiteBackgroundPen = NULL;
|
||||
g_oglWhiteBackgroundBrush = NULL;
|
||||
|
||||
OGLCleanUpConstraintTypes();
|
||||
}
|
||||
|
||||
wxFont *oglMatchFont(int point_size)
|
||||
{
|
||||
wxFont *font = wxTheFontList->FindOrCreateFont(point_size, wxSWISS, wxNORMAL, wxNORMAL);
|
||||
#if 0
|
||||
switch (point_size)
|
||||
{
|
||||
case 4:
|
||||
font = swiss_font_4;
|
||||
break;
|
||||
case 6:
|
||||
font = swiss_font_6;
|
||||
break;
|
||||
case 8:
|
||||
font = swiss_font_8;
|
||||
break;
|
||||
case 12:
|
||||
font = swiss_font_12;
|
||||
break;
|
||||
case 14:
|
||||
font = swiss_font_14;
|
||||
break;
|
||||
case 18:
|
||||
font = swiss_font_18;
|
||||
break;
|
||||
case 24:
|
||||
font = swiss_font_24;
|
||||
break;
|
||||
default:
|
||||
case 10:
|
||||
font = swiss_font_10;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return font;
|
||||
}
|
||||
|
||||
int FontSizeDialog(wxFrame *parent, int old_size)
|
||||
{
|
||||
if (old_size <= 0)
|
||||
old_size = 10;
|
||||
wxString buf;
|
||||
buf << old_size;
|
||||
wxString ans = wxGetTextFromUser(wxT("Enter point size"), wxT("Font size"), buf, parent);
|
||||
if (ans.Length() == 0)
|
||||
return 0;
|
||||
|
||||
long new_size = 0;
|
||||
ans.ToLong(&new_size);
|
||||
if ((new_size <= 0) || (new_size > 40))
|
||||
{
|
||||
wxMessageBox(wxT("Invalid point size!"), wxT("Error"), wxOK);
|
||||
return 0;
|
||||
}
|
||||
return new_size;
|
||||
/*
|
||||
char *strings[8];
|
||||
strings[0] = "4";
|
||||
strings[1] = "6";
|
||||
strings[2] = "8";
|
||||
strings[3] = "10";
|
||||
strings[4] = "12";
|
||||
strings[5] = "14";
|
||||
strings[6] = "18";
|
||||
strings[7] = "24";
|
||||
char *ans = wxGetSingleChoice("Choose", "Choose a font size", 8, strings, parent);
|
||||
if (ans)
|
||||
{
|
||||
int size;
|
||||
sscanf(ans, "%d", &size);
|
||||
return oglMatchFont(size);
|
||||
}
|
||||
else return NULL;
|
||||
*/
|
||||
}
|
||||
|
||||
// Centre a list of strings in the given box. xOffset and yOffset are the
|
||||
// the positions that these lines should be relative to, and this might be
|
||||
// the same as m_xpos, m_ypos, but might be zero if formatting from left-justifying.
|
||||
void oglCentreText(wxDC& dc, wxList *text_list,
|
||||
double m_xpos, double m_ypos, double width, double height,
|
||||
int formatMode)
|
||||
{
|
||||
int n = text_list->Number();
|
||||
|
||||
if (!text_list || (n == 0))
|
||||
return;
|
||||
|
||||
// First, get maximum dimensions of box enclosing text
|
||||
|
||||
long char_height = 0;
|
||||
long max_width = 0;
|
||||
long current_width = 0;
|
||||
|
||||
// Store text extents for speed
|
||||
double *widths = new double[n];
|
||||
|
||||
wxNode *current = text_list->First();
|
||||
int i = 0;
|
||||
while (current)
|
||||
{
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->Data();
|
||||
dc.GetTextExtent(line->GetText(), ¤t_width, &char_height);
|
||||
widths[i] = current_width;
|
||||
|
||||
if (current_width > max_width)
|
||||
max_width = current_width;
|
||||
current = current->Next();
|
||||
i ++;
|
||||
}
|
||||
|
||||
double max_height = n*char_height;
|
||||
|
||||
double xoffset, yoffset, xOffset, yOffset;
|
||||
|
||||
if (formatMode & FORMAT_CENTRE_VERT)
|
||||
{
|
||||
if (max_height < height)
|
||||
yoffset = (double)(m_ypos - (height/2.0) + (height - max_height)/2.0);
|
||||
else
|
||||
yoffset = (double)(m_ypos - (height/2.0));
|
||||
yOffset = m_ypos;
|
||||
}
|
||||
else
|
||||
{
|
||||
yoffset = 0.0;
|
||||
yOffset = 0.0;
|
||||
}
|
||||
|
||||
if (formatMode & FORMAT_CENTRE_HORIZ)
|
||||
{
|
||||
xoffset = (double)(m_xpos - width/2.0);
|
||||
xOffset = m_xpos;
|
||||
}
|
||||
else
|
||||
{
|
||||
xoffset = 0.0;
|
||||
xOffset = 0.0;
|
||||
}
|
||||
|
||||
current = text_list->First();
|
||||
i = 0;
|
||||
|
||||
while (current)
|
||||
{
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->Data();
|
||||
|
||||
double x;
|
||||
if ((formatMode & FORMAT_CENTRE_HORIZ) && (widths[i] < width))
|
||||
x = (double)((width - widths[i])/2.0 + xoffset);
|
||||
else
|
||||
x = xoffset;
|
||||
double y = (double)(i*char_height + yoffset);
|
||||
|
||||
line->SetX( x - xOffset ); line->SetY( y - yOffset );
|
||||
current = current->Next();
|
||||
i ++;
|
||||
}
|
||||
|
||||
delete widths;
|
||||
}
|
||||
|
||||
// Centre a list of strings in the given box
|
||||
void oglCentreTextNoClipping(wxDC& dc, wxList *text_list,
|
||||
double m_xpos, double m_ypos, double width, double height)
|
||||
{
|
||||
int n = text_list->Number();
|
||||
|
||||
if (!text_list || (n == 0))
|
||||
return;
|
||||
|
||||
// First, get maximum dimensions of box enclosing text
|
||||
|
||||
long char_height = 0;
|
||||
long max_width = 0;
|
||||
long current_width = 0;
|
||||
|
||||
// Store text extents for speed
|
||||
double *widths = new double[n];
|
||||
|
||||
wxNode *current = text_list->First();
|
||||
int i = 0;
|
||||
while (current)
|
||||
{
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->Data();
|
||||
dc.GetTextExtent(line->GetText(), ¤t_width, &char_height);
|
||||
widths[i] = current_width;
|
||||
|
||||
if (current_width > max_width)
|
||||
max_width = current_width;
|
||||
current = current->Next();
|
||||
i ++;
|
||||
}
|
||||
|
||||
double max_height = n*char_height;
|
||||
|
||||
double yoffset = (double)(m_ypos - (height/2.0) + (height - max_height)/2.0);
|
||||
|
||||
double xoffset = (double)(m_xpos - width/2.0);
|
||||
|
||||
current = text_list->First();
|
||||
i = 0;
|
||||
|
||||
while (current)
|
||||
{
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->Data();
|
||||
|
||||
double x = (double)((width - widths[i])/2.0 + xoffset);
|
||||
double y = (double)(i*char_height + yoffset);
|
||||
|
||||
line->SetX( x - m_xpos ); line->SetY( y - m_ypos );
|
||||
current = current->Next();
|
||||
i ++;
|
||||
}
|
||||
delete widths;
|
||||
}
|
||||
|
||||
void oglGetCentredTextExtent(wxDC& dc, wxList *text_list,
|
||||
double m_xpos, double m_ypos, double width, double height,
|
||||
double *actual_width, double *actual_height)
|
||||
{
|
||||
int n = text_list->Number();
|
||||
|
||||
if (!text_list || (n == 0))
|
||||
{
|
||||
*actual_width = 0;
|
||||
*actual_height = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// First, get maximum dimensions of box enclosing text
|
||||
|
||||
long char_height = 0;
|
||||
long max_width = 0;
|
||||
long current_width = 0;
|
||||
|
||||
wxNode *current = text_list->First();
|
||||
int i = 0;
|
||||
while (current)
|
||||
{
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->Data();
|
||||
dc.GetTextExtent(line->GetText(), ¤t_width, &char_height);
|
||||
|
||||
if (current_width > max_width)
|
||||
max_width = current_width;
|
||||
current = current->Next();
|
||||
i ++;
|
||||
}
|
||||
|
||||
*actual_height = n*char_height;
|
||||
*actual_width = max_width;
|
||||
}
|
||||
|
||||
// Format a string to a list of strings that fit in the given box.
|
||||
// Interpret %n and 10 or 13 as a new line.
|
||||
wxStringList *oglFormatText(wxDC& dc, const wxString& text, double width, double height, int formatMode)
|
||||
{
|
||||
// First, parse the string into a list of words
|
||||
wxStringList word_list;
|
||||
|
||||
// Make new lines into NULL strings at this point
|
||||
int i = 0; int j = 0; int len = text.Length();
|
||||
wxChar word[200]; word[0] = 0;
|
||||
bool end_word = FALSE; bool new_line = FALSE;
|
||||
while (i < len)
|
||||
{
|
||||
switch (text[i])
|
||||
{
|
||||
case wxT('%'):
|
||||
{
|
||||
i ++;
|
||||
if (i == len)
|
||||
{ word[j] = wxT('%'); j ++; }
|
||||
else
|
||||
{
|
||||
if (text[i] == wxT('n'))
|
||||
{ new_line = TRUE; end_word = TRUE; i++; }
|
||||
else
|
||||
{ word[j] = wxT('%'); j ++; word[j] = text[i]; j ++; i ++; }
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 10:
|
||||
{
|
||||
new_line = TRUE; end_word = TRUE; i++;
|
||||
break;
|
||||
}
|
||||
case 13:
|
||||
{
|
||||
new_line = TRUE; end_word = TRUE; i++;
|
||||
}
|
||||
case wxT(' '):
|
||||
{
|
||||
end_word = TRUE;
|
||||
i ++;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
word[j] = text[i];
|
||||
j ++; i ++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == len) end_word = TRUE;
|
||||
if (end_word)
|
||||
{
|
||||
word[j] = 0;
|
||||
j = 0;
|
||||
word_list.Add(word);
|
||||
end_word = FALSE;
|
||||
}
|
||||
if (new_line)
|
||||
{
|
||||
word_list.Append(NULL);
|
||||
new_line = FALSE;
|
||||
}
|
||||
}
|
||||
// Now, make a list of strings which can fit in the box
|
||||
wxStringList *string_list = new wxStringList;
|
||||
|
||||
wxString buffer;
|
||||
wxNode *node = word_list.First();
|
||||
long x, y;
|
||||
|
||||
while (node)
|
||||
{
|
||||
wxString oldBuffer(buffer);
|
||||
|
||||
wxChar *s = (wxChar *)node->Data();
|
||||
if (!s)
|
||||
{
|
||||
// FORCE NEW LINE
|
||||
if (buffer.Length() > 0)
|
||||
string_list->Add(buffer);
|
||||
|
||||
buffer.Empty();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buffer.Length() != 0)
|
||||
buffer += wxT(" ");
|
||||
|
||||
buffer += s;
|
||||
dc.GetTextExtent(buffer, &x, &y);
|
||||
|
||||
// Don't fit within the bounding box if we're fitting shape to contents
|
||||
if ((x > width) && !(formatMode & FORMAT_SIZE_TO_CONTENTS))
|
||||
{
|
||||
// Deal with first word being wider than box
|
||||
if (oldBuffer.Length() > 0)
|
||||
string_list->Add(oldBuffer);
|
||||
|
||||
buffer.Empty();
|
||||
buffer += s;
|
||||
}
|
||||
}
|
||||
|
||||
node = node->Next();
|
||||
}
|
||||
if (buffer.Length() != 0)
|
||||
string_list->Add(buffer);
|
||||
|
||||
return string_list;
|
||||
}
|
||||
|
||||
void oglDrawFormattedText(wxDC& dc, wxList *text_list,
|
||||
double m_xpos, double m_ypos, double width, double height,
|
||||
int formatMode)
|
||||
{
|
||||
double xoffset, yoffset;
|
||||
if (formatMode & FORMAT_CENTRE_HORIZ)
|
||||
xoffset = m_xpos;
|
||||
else
|
||||
xoffset = (double)(m_xpos - (width / 2.0));
|
||||
|
||||
if (formatMode & FORMAT_CENTRE_VERT)
|
||||
yoffset = m_ypos;
|
||||
else
|
||||
yoffset = (double)(m_ypos - (height / 2.0));
|
||||
|
||||
dc.SetClippingRegion(
|
||||
(long)(m_xpos - width/2.0), (long)(m_ypos - height/2.0),
|
||||
(long)width, (long)height);
|
||||
|
||||
wxNode *current = text_list->First();
|
||||
while (current)
|
||||
{
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->Data();
|
||||
|
||||
dc.DrawText(line->GetText(), WXROUND(xoffset + line->GetX()), WXROUND(yoffset + line->GetY()));
|
||||
current = current->Next();
|
||||
}
|
||||
|
||||
dc.DestroyClippingRegion();
|
||||
}
|
||||
|
||||
/*
|
||||
* Find centroid given list of points comprising polyline
|
||||
*
|
||||
*/
|
||||
|
||||
void oglFindPolylineCentroid(wxList *points, double *x, double *y)
|
||||
{
|
||||
double xcount = 0;
|
||||
double ycount = 0;
|
||||
|
||||
wxNode *node = points->First();
|
||||
while (node)
|
||||
{
|
||||
wxRealPoint *point = (wxRealPoint *)node->Data();
|
||||
xcount += point->x;
|
||||
ycount += point->y;
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
*x = (xcount/points->Number());
|
||||
*y = (ycount/points->Number());
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that (x1, y1) -> (x2, y2) hits (x3, y3) -> (x4, y4).
|
||||
* If so, ratio1 gives the proportion along the first line
|
||||
* that the intersection occurs (or something like that).
|
||||
* Used by functions below.
|
||||
*
|
||||
*/
|
||||
void oglCheckLineIntersection(double x1, double y1, double x2, double y2,
|
||||
double x3, double y3, double x4, double y4,
|
||||
double *ratio1, double *ratio2)
|
||||
{
|
||||
double denominator_term = (y4 - y3)*(x2 - x1) - (y2 - y1)*(x4 - x3);
|
||||
double numerator_term = (x3 - x1)*(y4 - y3) + (x4 - x3)*(y1 - y3);
|
||||
|
||||
double line_constant;
|
||||
double length_ratio = 1.0;
|
||||
double k_line = 1.0;
|
||||
|
||||
// Check for parallel lines
|
||||
if ((denominator_term < 0.005) && (denominator_term > -0.005))
|
||||
line_constant = -1.0;
|
||||
else
|
||||
line_constant = numerator_term/denominator_term;
|
||||
|
||||
// Check for intersection
|
||||
if ((line_constant < 1.0) && (line_constant > 0.0))
|
||||
{
|
||||
// Now must check that other line hits
|
||||
if (((y4 - y3) < 0.005) && ((y4 - y3) > -0.005))
|
||||
k_line = ((x1 - x3) + line_constant*(x2 - x1))/(x4 - x3);
|
||||
else
|
||||
k_line = ((y1 - y3) + line_constant*(y2 - y1))/(y4 - y3);
|
||||
|
||||
if ((k_line >= 0.0) && (k_line < 1.0))
|
||||
length_ratio = line_constant;
|
||||
else
|
||||
k_line = 1.0;
|
||||
}
|
||||
*ratio1 = length_ratio;
|
||||
*ratio2 = k_line;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find where (x1, y1) -> (x2, y2) hits one of the lines in xvec, yvec.
|
||||
* (*x3, *y3) is the point where it hits.
|
||||
*
|
||||
*/
|
||||
void oglFindEndForPolyline(double n, double xvec[], double yvec[],
|
||||
double x1, double y1, double x2, double y2, double *x3, double *y3)
|
||||
{
|
||||
int i;
|
||||
double lastx = xvec[0];
|
||||
double lasty = yvec[0];
|
||||
|
||||
double min_ratio = 1.0;
|
||||
double line_ratio;
|
||||
double other_ratio;
|
||||
|
||||
for (i = 1; i < n; i++)
|
||||
{
|
||||
oglCheckLineIntersection(x1, y1, x2, y2, lastx, lasty, xvec[i], yvec[i],
|
||||
&line_ratio, &other_ratio);
|
||||
lastx = xvec[i];
|
||||
lasty = yvec[i];
|
||||
|
||||
if (line_ratio < min_ratio)
|
||||
min_ratio = line_ratio;
|
||||
}
|
||||
|
||||
// Do last (implicit) line if last and first doubles are not identical
|
||||
if (!(xvec[0] == lastx && yvec[0] == lasty))
|
||||
{
|
||||
oglCheckLineIntersection(x1, y1, x2, y2, lastx, lasty, xvec[0], yvec[0],
|
||||
&line_ratio, &other_ratio);
|
||||
|
||||
if (line_ratio < min_ratio)
|
||||
min_ratio = line_ratio;
|
||||
}
|
||||
|
||||
*x3 = (x1 + (x2 - x1)*min_ratio);
|
||||
*y3 = (y1 + (y2 - y1)*min_ratio);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Find where the line hits the box.
|
||||
*
|
||||
*/
|
||||
|
||||
void oglFindEndForBox(double width, double height,
|
||||
double x1, double y1, // Centre of box (possibly)
|
||||
double x2, double y2, // other end of line
|
||||
double *x3, double *y3) // End on box edge
|
||||
{
|
||||
double xvec[5];
|
||||
double yvec[5];
|
||||
|
||||
xvec[0] = (double)(x1 - width/2.0);
|
||||
yvec[0] = (double)(y1 - height/2.0);
|
||||
xvec[1] = (double)(x1 - width/2.0);
|
||||
yvec[1] = (double)(y1 + height/2.0);
|
||||
xvec[2] = (double)(x1 + width/2.0);
|
||||
yvec[2] = (double)(y1 + height/2.0);
|
||||
xvec[3] = (double)(x1 + width/2.0);
|
||||
yvec[3] = (double)(y1 - height/2.0);
|
||||
xvec[4] = (double)(x1 - width/2.0);
|
||||
yvec[4] = (double)(y1 - height/2.0);
|
||||
|
||||
oglFindEndForPolyline(5, xvec, yvec, x2, y2, x1, y1, x3, y3);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find where the line hits the circle.
|
||||
*
|
||||
*/
|
||||
|
||||
void oglFindEndForCircle(double radius,
|
||||
double x1, double y1, // Centre of circle
|
||||
double x2, double y2, // Other end of line
|
||||
double *x3, double *y3)
|
||||
{
|
||||
double H = (double)sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
|
||||
|
||||
if (H == 0.0)
|
||||
{
|
||||
*x3 = x1;
|
||||
*y3 = y1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*y3 = radius * (y2 - y1)/H + y1;
|
||||
*x3 = radius * (x2 - x1)/H + x1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Given the line (x1, y1) -> (x2, y2), and an arrow size of given length and width,
|
||||
* return the position of the tip of the arrow and the left and right vertices of the arrow.
|
||||
*
|
||||
*/
|
||||
|
||||
void oglGetArrowPoints(double x1, double y1, double x2, double y2,
|
||||
double length, double width,
|
||||
double *tip_x, double *tip_y,
|
||||
double *side1_x, double *side1_y,
|
||||
double *side2_x, double *side2_y)
|
||||
{
|
||||
double l = (double)sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
|
||||
|
||||
if (l < 0.01)
|
||||
l = (double) 0.01;
|
||||
|
||||
double i_bar = (x2 - x1)/l;
|
||||
double j_bar = (y2 - y1)/l;
|
||||
|
||||
double x3 = (- length*i_bar) + x2;
|
||||
double y3 = (- length*j_bar) + y2;
|
||||
|
||||
*side1_x = width*(-j_bar) + x3;
|
||||
*side1_y = width*i_bar + y3;
|
||||
|
||||
*side2_x = -width*(-j_bar) + x3;
|
||||
*side2_y = -width*i_bar + y3;
|
||||
|
||||
*tip_x = x2; *tip_y = y2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Given an ellipse and endpoints of a line, returns the point at which
|
||||
* the line touches the ellipse in values x4, y4.
|
||||
* This function assumes that the centre of the ellipse is at x1, y1, and the
|
||||
* ellipse has a width of width1 and a height of height1. It also assumes you are
|
||||
* wanting to draw an arc FROM point x2, y2 TOWARDS point x3, y3.
|
||||
* This function calculates the x,y coordinates of the intersection point of
|
||||
* the arc with the ellipse.
|
||||
* Author: Ian Harrison
|
||||
*/
|
||||
|
||||
void oglDrawArcToEllipse(double x1, double y1, double width1, double height1, double x2, double y2, double x3, double y3,
|
||||
double *x4, double *y4)
|
||||
{
|
||||
double a1 = (double)(width1/2.0);
|
||||
double b1 = (double)(height1/2.0);
|
||||
|
||||
// These are required to give top left x and y coordinates for DrawEllipse
|
||||
// double top_left_x1 = (double)(x1 - a1);
|
||||
// double top_left_y1 = (double)(y1 - b1);
|
||||
/*
|
||||
// Check for vertical line
|
||||
if (fabs(x2 - x3) < 0.05)
|
||||
{
|
||||
*x4 = x3;
|
||||
if (y2 < y3)
|
||||
*y4 = (double)(y1 - b1);
|
||||
else
|
||||
*y4 = (double)(y1 + b1);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
// Check that x2 != x3
|
||||
if (fabs(x2 - x3) < 0.05)
|
||||
{
|
||||
*x4 = x2;
|
||||
if (y3 > y2)
|
||||
*y4 = (double)(y1 - sqrt((b1*b1 - (((x2-x1)*(x2-x1))*(b1*b1)/(a1*a1)))));
|
||||
else
|
||||
*y4 = (double)(y1 + sqrt((b1*b1 - (((x2-x1)*(x2-x1))*(b1*b1)/(a1*a1)))));
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate the x and y coordinates of the point where arc intersects ellipse
|
||||
|
||||
double A, B, C, D, E, F, G, H, K;
|
||||
double ellipse1_x, ellipse1_y;
|
||||
|
||||
A = (double)(1/(a1 * a1));
|
||||
B = (double)((y3 - y2) * (y3 - y2)) / ((x3 - x2) * (x3 - x2) * b1 * b1);
|
||||
C = (double)(2 * (y3 - y2) * (y2 - y1)) / ((x3 - x2) * b1 * b1);
|
||||
D = (double)((y2 - y1) * (y2 - y1)) / (b1 * b1);
|
||||
E = (double)(A + B);
|
||||
F = (double)(C - (2 * A * x1) - (2 * B * x2));
|
||||
G = (double)((A * x1 * x1) + (B * x2 * x2) - (C * x2) + D - 1);
|
||||
H = (double)((y3 - y2) / (x3 - x2));
|
||||
K = (double)((F * F) - (4 * E * G));
|
||||
|
||||
if (K >= 0)
|
||||
// In this case the line intersects the ellipse, so calculate intersection
|
||||
{
|
||||
if(x2 >= x1)
|
||||
{
|
||||
ellipse1_x = (double)(((F * -1) + sqrt(K)) / (2 * E));
|
||||
ellipse1_y = (double)((H * (ellipse1_x - x2)) + y2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ellipse1_x = (double)(((F * -1) - sqrt(K)) / (2 * E));
|
||||
ellipse1_y = (double)((H * (ellipse1_x - x2)) + y2);
|
||||
}
|
||||
}
|
||||
else
|
||||
// in this case, arc does not intersect ellipse, so just draw arc
|
||||
{
|
||||
ellipse1_x = x3;
|
||||
ellipse1_y = y3;
|
||||
}
|
||||
*x4 = ellipse1_x;
|
||||
*y4 = ellipse1_y;
|
||||
|
||||
/*
|
||||
// Draw a little circle (radius = 2) at the end of the arc where it hits
|
||||
// the ellipse .
|
||||
|
||||
double circle_x = ellipse1_x - 2.0;
|
||||
double circle_y = ellipse1_y - 2.0;
|
||||
m_canvas->DrawEllipse(circle_x, circle_y, 4.0, 4.0);
|
||||
*/
|
||||
}
|
||||
|
||||
// Update a list item from a list of strings
|
||||
void UpdateListBox(wxListBox *item, wxList *list)
|
||||
{
|
||||
item->Clear();
|
||||
if (!list)
|
||||
return;
|
||||
|
||||
wxNode *node = list->First();
|
||||
while (node)
|
||||
{
|
||||
wxChar *s = (wxChar *)node->Data();
|
||||
item->Append(s);
|
||||
node = node->Next();
|
||||
}
|
||||
}
|
||||
|
||||
bool oglRoughlyEqual(double val1, double val2, double tol)
|
||||
{
|
||||
return ( (val1 < (val2 + tol)) && (val1 > (val2 - tol)) &&
|
||||
(val2 < (val1 + tol)) && (val2 > (val1 - tol)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Hex<->Dec conversion
|
||||
*/
|
||||
|
||||
// Array used in DecToHex conversion routine.
|
||||
static wxChar sg_HexArray[] = { wxT('0'), wxT('1'), wxT('2'), wxT('3'),
|
||||
wxT('4'), wxT('5'), wxT('6'), wxT('7'),
|
||||
wxT('8'), wxT('9'), wxT('A'), wxT('B'),
|
||||
wxT('C'), wxT('D'), wxT('E'), wxT('F')
|
||||
};
|
||||
|
||||
// Convert 2-digit hex number to decimal
|
||||
unsigned int oglHexToDec(wxChar* buf)
|
||||
{
|
||||
int firstDigit, secondDigit;
|
||||
|
||||
if (buf[0] >= wxT('A'))
|
||||
firstDigit = buf[0] - wxT('A') + 10;
|
||||
else
|
||||
firstDigit = buf[0] - wxT('0');
|
||||
|
||||
if (buf[1] >= wxT('A'))
|
||||
secondDigit = buf[1] - wxT('A') + 10;
|
||||
else
|
||||
secondDigit = buf[1] - wxT('0');
|
||||
|
||||
return firstDigit * 16 + secondDigit;
|
||||
}
|
||||
|
||||
// Convert decimal integer to 2-character hex string
|
||||
void oglDecToHex(unsigned int dec, wxChar *buf)
|
||||
{
|
||||
int firstDigit = (int)(dec/16.0);
|
||||
int secondDigit = (int)(dec - (firstDigit*16.0));
|
||||
buf[0] = sg_HexArray[firstDigit];
|
||||
buf[1] = sg_HexArray[secondDigit];
|
||||
buf[2] = 0;
|
||||
}
|
||||
|
||||
// 3-digit hex to wxColour
|
||||
wxColour oglHexToColour(const wxString& hex)
|
||||
{
|
||||
if (hex.Length() == 6)
|
||||
{
|
||||
long r, g, b;
|
||||
r = g = b = 0;
|
||||
hex.Mid(0,2).ToLong(&r, 16);
|
||||
hex.Mid(2,2).ToLong(&g, 16);
|
||||
hex.Mid(4,2).ToLong(&b, 16);
|
||||
return wxColour(r, g, b);
|
||||
}
|
||||
else
|
||||
return wxColour(0,0,0);
|
||||
}
|
||||
|
||||
// RGB to 3-digit hex
|
||||
wxString oglColourToHex(const wxColour& colour)
|
||||
{
|
||||
wxChar buf[7];
|
||||
unsigned int red = colour.Red();
|
||||
unsigned int green = colour.Green();
|
||||
unsigned int blue = colour.Blue();
|
||||
|
||||
oglDecToHex(red, buf);
|
||||
oglDecToHex(green, buf+2);
|
||||
oglDecToHex(blue, buf+4);
|
||||
|
||||
return wxString(buf);
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,6 @@
|
||||
#endif
|
||||
|
||||
#include <wx/wxexpr.h>
|
||||
|
||||
#include <wx/types.h>
|
||||
|
||||
#ifdef new
|
||||
@@ -62,12 +61,12 @@ void wxOGLInitialize()
|
||||
|
||||
g_oglNormalFont = new wxFont(10, wxSWISS, wxNORMAL, wxNORMAL);
|
||||
|
||||
g_oglBlackPen = new wxPen("BLACK", 1, wxSOLID);
|
||||
g_oglBlackPen = new wxPen(wxT("BLACK"), 1, wxSOLID);
|
||||
|
||||
g_oglWhiteBackgroundPen = new wxPen("WHITE", 1, wxSOLID);
|
||||
g_oglTransparentPen = new wxPen("WHITE", 1, wxTRANSPARENT);
|
||||
g_oglWhiteBackgroundBrush = new wxBrush("WHITE", wxSOLID);
|
||||
g_oglBlackForegroundPen = new wxPen("BLACK", 1, wxSOLID);
|
||||
g_oglWhiteBackgroundPen = new wxPen(wxT("WHITE"), 1, wxSOLID);
|
||||
g_oglTransparentPen = new wxPen(wxT("WHITE"), 1, wxTRANSPARENT);
|
||||
g_oglWhiteBackgroundBrush = new wxBrush(wxT("WHITE"), wxSOLID);
|
||||
g_oglBlackForegroundPen = new wxPen(wxT("BLACK"), 1, wxSOLID);
|
||||
|
||||
OGLInitializeConstraintTypes();
|
||||
|
||||
@@ -164,16 +163,17 @@ int FontSizeDialog(wxFrame *parent, int old_size)
|
||||
{
|
||||
if (old_size <= 0)
|
||||
old_size = 10;
|
||||
char buf[40];
|
||||
sprintf(buf, "%d", old_size);
|
||||
wxString ans = wxGetTextFromUser("Enter point size", "Font size", buf, parent);
|
||||
if (ans == "")
|
||||
wxString buf;
|
||||
buf << old_size;
|
||||
wxString ans = wxGetTextFromUser(wxT("Enter point size"), wxT("Font size"), buf, parent);
|
||||
if (ans.Length() == 0)
|
||||
return 0;
|
||||
|
||||
int new_size = atoi(ans);
|
||||
long new_size = 0;
|
||||
ans.ToLong(&new_size);
|
||||
if ((new_size <= 0) || (new_size > 40))
|
||||
{
|
||||
wxMessageBox("Invalid point size!", "Error", wxOK);
|
||||
wxMessageBox(wxT("Invalid point size!"), wxT("Error"), wxOK);
|
||||
return 0;
|
||||
}
|
||||
return new_size;
|
||||
@@ -205,7 +205,7 @@ void oglCentreText(wxDC& dc, wxList *text_list,
|
||||
double m_xpos, double m_ypos, double width, double height,
|
||||
int formatMode)
|
||||
{
|
||||
int n = text_list->Number();
|
||||
int n = text_list->GetCount();
|
||||
|
||||
if (!text_list || (n == 0))
|
||||
return;
|
||||
@@ -219,17 +219,17 @@ void oglCentreText(wxDC& dc, wxList *text_list,
|
||||
// Store text extents for speed
|
||||
double *widths = new double[n];
|
||||
|
||||
wxNode *current = text_list->First();
|
||||
wxNode *current = text_list->GetFirst();
|
||||
int i = 0;
|
||||
while (current)
|
||||
{
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->Data();
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->GetData();
|
||||
dc.GetTextExtent(line->GetText(), ¤t_width, &char_height);
|
||||
widths[i] = current_width;
|
||||
|
||||
if (current_width > max_width)
|
||||
max_width = current_width;
|
||||
current = current->Next();
|
||||
current = current->GetNext();
|
||||
i ++;
|
||||
}
|
||||
|
||||
@@ -262,12 +262,12 @@ void oglCentreText(wxDC& dc, wxList *text_list,
|
||||
xOffset = 0.0;
|
||||
}
|
||||
|
||||
current = text_list->First();
|
||||
current = text_list->GetFirst();
|
||||
i = 0;
|
||||
|
||||
while (current)
|
||||
{
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->Data();
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->GetData();
|
||||
|
||||
double x;
|
||||
if ((formatMode & FORMAT_CENTRE_HORIZ) && (widths[i] < width))
|
||||
@@ -277,7 +277,7 @@ void oglCentreText(wxDC& dc, wxList *text_list,
|
||||
double y = (double)(i*char_height + yoffset);
|
||||
|
||||
line->SetX( x - xOffset ); line->SetY( y - yOffset );
|
||||
current = current->Next();
|
||||
current = current->GetNext();
|
||||
i ++;
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ void oglCentreText(wxDC& dc, wxList *text_list,
|
||||
void oglCentreTextNoClipping(wxDC& dc, wxList *text_list,
|
||||
double m_xpos, double m_ypos, double width, double height)
|
||||
{
|
||||
int n = text_list->Number();
|
||||
int n = text_list->GetCount();
|
||||
|
||||
if (!text_list || (n == 0))
|
||||
return;
|
||||
@@ -302,17 +302,17 @@ void oglCentreTextNoClipping(wxDC& dc, wxList *text_list,
|
||||
// Store text extents for speed
|
||||
double *widths = new double[n];
|
||||
|
||||
wxNode *current = text_list->First();
|
||||
wxNode *current = text_list->GetFirst();
|
||||
int i = 0;
|
||||
while (current)
|
||||
{
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->Data();
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->GetData();
|
||||
dc.GetTextExtent(line->GetText(), ¤t_width, &char_height);
|
||||
widths[i] = current_width;
|
||||
|
||||
if (current_width > max_width)
|
||||
max_width = current_width;
|
||||
current = current->Next();
|
||||
current = current->GetNext();
|
||||
i ++;
|
||||
}
|
||||
|
||||
@@ -322,18 +322,18 @@ void oglCentreTextNoClipping(wxDC& dc, wxList *text_list,
|
||||
|
||||
double xoffset = (double)(m_xpos - width/2.0);
|
||||
|
||||
current = text_list->First();
|
||||
current = text_list->GetFirst();
|
||||
i = 0;
|
||||
|
||||
while (current)
|
||||
{
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->Data();
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->GetData();
|
||||
|
||||
double x = (double)((width - widths[i])/2.0 + xoffset);
|
||||
double y = (double)(i*char_height + yoffset);
|
||||
|
||||
line->SetX( x - m_xpos ); line->SetY( y - m_ypos );
|
||||
current = current->Next();
|
||||
current = current->GetNext();
|
||||
i ++;
|
||||
}
|
||||
delete widths;
|
||||
@@ -343,7 +343,7 @@ void oglGetCentredTextExtent(wxDC& dc, wxList *text_list,
|
||||
double m_xpos, double m_ypos, double width, double height,
|
||||
double *actual_width, double *actual_height)
|
||||
{
|
||||
int n = text_list->Number();
|
||||
int n = text_list->GetCount();
|
||||
|
||||
if (!text_list || (n == 0))
|
||||
{
|
||||
@@ -358,16 +358,16 @@ void oglGetCentredTextExtent(wxDC& dc, wxList *text_list,
|
||||
long max_width = 0;
|
||||
long current_width = 0;
|
||||
|
||||
wxNode *current = text_list->First();
|
||||
wxNode *current = text_list->GetFirst();
|
||||
int i = 0;
|
||||
while (current)
|
||||
{
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->Data();
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->GetData();
|
||||
dc.GetTextExtent(line->GetText(), ¤t_width, &char_height);
|
||||
|
||||
if (current_width > max_width)
|
||||
max_width = current_width;
|
||||
current = current->Next();
|
||||
current = current->GetNext();
|
||||
i ++;
|
||||
}
|
||||
|
||||
@@ -383,24 +383,24 @@ wxStringList *oglFormatText(wxDC& dc, const wxString& text, double width, double
|
||||
wxStringList word_list;
|
||||
|
||||
// Make new lines into NULL strings at this point
|
||||
int i = 0; int j = 0; int len = strlen(text);
|
||||
char word[200]; word[0] = 0;
|
||||
int i = 0; int j = 0; int len = text.Length();
|
||||
wxChar word[200]; word[0] = 0;
|
||||
bool end_word = FALSE; bool new_line = FALSE;
|
||||
while (i < len)
|
||||
{
|
||||
switch (text[i])
|
||||
{
|
||||
case '%':
|
||||
case wxT('%'):
|
||||
{
|
||||
i ++;
|
||||
if (i == len)
|
||||
{ word[j] = '%'; j ++; }
|
||||
{ word[j] = wxT('%'); j ++; }
|
||||
else
|
||||
{
|
||||
if (text[i] == 'n')
|
||||
if (text[i] == wxT('n'))
|
||||
{ new_line = TRUE; end_word = TRUE; i++; }
|
||||
else
|
||||
{ word[j] = '%'; j ++; word[j] = text[i]; j ++; i ++; }
|
||||
{ word[j] = wxT('%'); j ++; word[j] = text[i]; j ++; i ++; }
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -413,7 +413,7 @@ wxStringList *oglFormatText(wxDC& dc, const wxString& text, double width, double
|
||||
{
|
||||
new_line = TRUE; end_word = TRUE; i++;
|
||||
}
|
||||
case ' ':
|
||||
case wxT(' '):
|
||||
{
|
||||
end_word = TRUE;
|
||||
i ++;
|
||||
@@ -443,30 +443,29 @@ wxStringList *oglFormatText(wxDC& dc, const wxString& text, double width, double
|
||||
// Now, make a list of strings which can fit in the box
|
||||
wxStringList *string_list = new wxStringList;
|
||||
|
||||
char buffer[400];
|
||||
buffer[0] = 0;
|
||||
wxNode *node = word_list.First();
|
||||
wxString buffer;
|
||||
wxStringListNode *node = word_list.GetFirst();
|
||||
long x, y;
|
||||
|
||||
while (node)
|
||||
{
|
||||
wxString oldBuffer(buffer);
|
||||
|
||||
char *s = (char *)node->Data();
|
||||
wxChar *s = (wxChar *)node->GetData();
|
||||
if (!s)
|
||||
{
|
||||
// FORCE NEW LINE
|
||||
if (strlen(buffer) > 0)
|
||||
if (buffer.Length() > 0)
|
||||
string_list->Add(buffer);
|
||||
|
||||
buffer[0] = 0;
|
||||
buffer.Empty();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buffer[0] != 0)
|
||||
strcat(buffer, " ");
|
||||
if (buffer.Length() != 0)
|
||||
buffer += wxT(" ");
|
||||
|
||||
strcat(buffer, s);
|
||||
buffer += s;
|
||||
dc.GetTextExtent(buffer, &x, &y);
|
||||
|
||||
// Don't fit within the bounding box if we're fitting shape to contents
|
||||
@@ -476,14 +475,14 @@ wxStringList *oglFormatText(wxDC& dc, const wxString& text, double width, double
|
||||
if (oldBuffer.Length() > 0)
|
||||
string_list->Add(oldBuffer);
|
||||
|
||||
buffer[0] = 0;
|
||||
strcat(buffer, s);
|
||||
buffer.Empty();
|
||||
buffer += s;
|
||||
}
|
||||
}
|
||||
|
||||
node = node->Next();
|
||||
node = node->GetNext();
|
||||
}
|
||||
if (buffer[0] != 0)
|
||||
if (buffer.Length() != 0)
|
||||
string_list->Add(buffer);
|
||||
|
||||
return string_list;
|
||||
@@ -508,13 +507,13 @@ void oglDrawFormattedText(wxDC& dc, wxList *text_list,
|
||||
(long)(m_xpos - width/2.0), (long)(m_ypos - height/2.0),
|
||||
(long)width, (long)height);
|
||||
|
||||
wxNode *current = text_list->First();
|
||||
wxNode *current = text_list->GetFirst();
|
||||
while (current)
|
||||
{
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->Data();
|
||||
wxShapeTextLine *line = (wxShapeTextLine *)current->GetData();
|
||||
|
||||
dc.DrawText(line->GetText(), WXROUND(xoffset + line->GetX()), WXROUND(yoffset + line->GetY()));
|
||||
current = current->Next();
|
||||
current = current->GetNext();
|
||||
}
|
||||
|
||||
dc.DestroyClippingRegion();
|
||||
@@ -530,17 +529,17 @@ void oglFindPolylineCentroid(wxList *points, double *x, double *y)
|
||||
double xcount = 0;
|
||||
double ycount = 0;
|
||||
|
||||
wxNode *node = points->First();
|
||||
wxNode *node = points->GetFirst();
|
||||
while (node)
|
||||
{
|
||||
wxRealPoint *point = (wxRealPoint *)node->Data();
|
||||
wxRealPoint *point = (wxRealPoint *)node->GetData();
|
||||
xcount += point->x;
|
||||
ycount += point->y;
|
||||
node = node->Next();
|
||||
node = node->GetNext();
|
||||
}
|
||||
|
||||
*x = (xcount/points->Number());
|
||||
*y = (ycount/points->Number());
|
||||
*x = (xcount/points->GetCount());
|
||||
*y = (ycount/points->GetCount());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -808,12 +807,12 @@ void UpdateListBox(wxListBox *item, wxList *list)
|
||||
if (!list)
|
||||
return;
|
||||
|
||||
wxNode *node = list->First();
|
||||
wxNode *node = list->GetFirst();
|
||||
while (node)
|
||||
{
|
||||
char *s = (char *)node->Data();
|
||||
wxChar *s = (wxChar *)node->GetData();
|
||||
item->Append(s);
|
||||
node = node->Next();
|
||||
node = node->GetNext();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -828,29 +827,32 @@ bool oglRoughlyEqual(double val1, double val2, double tol)
|
||||
*/
|
||||
|
||||
// Array used in DecToHex conversion routine.
|
||||
static char sg_HexArray[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
|
||||
'C', 'D', 'E', 'F' };
|
||||
static wxChar sg_HexArray[] = { wxT('0'), wxT('1'), wxT('2'), wxT('3'),
|
||||
wxT('4'), wxT('5'), wxT('6'), wxT('7'),
|
||||
wxT('8'), wxT('9'), wxT('A'), wxT('B'),
|
||||
wxT('C'), wxT('D'), wxT('E'), wxT('F')
|
||||
};
|
||||
|
||||
// Convert 2-digit hex number to decimal
|
||||
unsigned int oglHexToDec(char* buf)
|
||||
unsigned int oglHexToDec(wxChar* buf)
|
||||
{
|
||||
int firstDigit, secondDigit;
|
||||
|
||||
if (buf[0] >= 'A')
|
||||
firstDigit = buf[0] - 'A' + 10;
|
||||
if (buf[0] >= wxT('A'))
|
||||
firstDigit = buf[0] - wxT('A') + 10;
|
||||
else
|
||||
firstDigit = buf[0] - '0';
|
||||
firstDigit = buf[0] - wxT('0');
|
||||
|
||||
if (buf[1] >= 'A')
|
||||
secondDigit = buf[1] - 'A' + 10;
|
||||
if (buf[1] >= wxT('A'))
|
||||
secondDigit = buf[1] - wxT('A') + 10;
|
||||
else
|
||||
secondDigit = buf[1] - '0';
|
||||
secondDigit = buf[1] - wxT('0');
|
||||
|
||||
return firstDigit * 16 + secondDigit;
|
||||
}
|
||||
|
||||
// Convert decimal integer to 2-character hex string
|
||||
void oglDecToHex(unsigned int dec, char *buf)
|
||||
void oglDecToHex(unsigned int dec, wxChar *buf)
|
||||
{
|
||||
int firstDigit = (int)(dec/16.0);
|
||||
int secondDigit = (int)(dec - (firstDigit*16.0));
|
||||
@@ -863,22 +865,22 @@ void oglDecToHex(unsigned int dec, char *buf)
|
||||
wxColour oglHexToColour(const wxString& hex)
|
||||
{
|
||||
if (hex.Length() == 6)
|
||||
{
|
||||
char buf[7];
|
||||
strncpy(buf, hex, 7);
|
||||
unsigned int r = oglHexToDec((char *)buf);
|
||||
unsigned int g = oglHexToDec((char *)(buf+2));
|
||||
unsigned int b = oglHexToDec((char *)(buf+4));
|
||||
{
|
||||
long r, g, b;
|
||||
r = g = b = 0;
|
||||
hex.Mid(0,2).ToLong(&r, 16);
|
||||
hex.Mid(2,2).ToLong(&g, 16);
|
||||
hex.Mid(4,2).ToLong(&b, 16);
|
||||
return wxColour(r, g, b);
|
||||
}
|
||||
else
|
||||
return wxColour(0,0,0);
|
||||
}
|
||||
else
|
||||
return wxColour(0,0,0);
|
||||
}
|
||||
|
||||
// RGB to 3-digit hex
|
||||
wxString oglColourToHex(const wxColour& colour)
|
||||
{
|
||||
char buf[7];
|
||||
wxChar buf[7];
|
||||
unsigned int red = colour.Red();
|
||||
unsigned int green = colour.Green();
|
||||
unsigned int blue = colour.Blue();
|
||||
|
@@ -30,6 +30,7 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
|
||||
Document.o \
|
||||
DocumentAccessor.o \
|
||||
Editor.o \
|
||||
ExternalLexer.o \
|
||||
Indicator.o \
|
||||
KeyMap.o \
|
||||
KeyWords.o \
|
||||
@@ -44,9 +45,11 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
|
||||
LexCrontab.o \
|
||||
LexCSS.o \
|
||||
LexEiffel.o \
|
||||
LexEScript.o \
|
||||
LexFortran.o \
|
||||
LexHTML.o \
|
||||
LexLisp.o \
|
||||
LexLout.o \
|
||||
LexLua.o \
|
||||
LexOthers.o \
|
||||
LexPOV.o \
|
||||
@@ -56,6 +59,10 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
|
||||
LexRuby.o \
|
||||
LexSQL.o \
|
||||
LexVB.o \
|
||||
LexMMIXAL.o \
|
||||
LexNsis.o \
|
||||
LexPS.o \
|
||||
LexScriptol.o \
|
||||
LineMarker.o \
|
||||
PropSet.o \
|
||||
RESearch.o \
|
||||
|
@@ -288,7 +288,7 @@ void SurfaceImpl::Init(SurfaceID hdc_, WindowID) {
|
||||
hdc = (wxDC*)hdc_;
|
||||
}
|
||||
|
||||
void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID) {
|
||||
void SurfaceImpl::InitPixMap(int width, int height, Surface *WXUNUSED(surface_), WindowID) {
|
||||
Release();
|
||||
hdc = new wxMemoryDC();
|
||||
hdcOwned = true;
|
||||
@@ -405,7 +405,7 @@ void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font, int ybase,
|
||||
SetFont(font);
|
||||
hdc->SetTextForeground(wxColourFromCA(fore));
|
||||
hdc->SetTextBackground(wxColourFromCA(back));
|
||||
//FillRectangle(rc, back);
|
||||
FillRectangle(rc, back);
|
||||
|
||||
// ybase is where the baseline should be, but wxWin uses the upper left
|
||||
// corner, so I need to calculate the real position for the text...
|
||||
@@ -418,11 +418,12 @@ void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, int ybase,
|
||||
SetFont(font);
|
||||
hdc->SetTextForeground(wxColourFromCA(fore));
|
||||
hdc->SetTextBackground(wxColourFromCA(back));
|
||||
//FillRectangle(rc, back);
|
||||
FillRectangle(rc, back);
|
||||
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
|
||||
|
||||
// see comments above
|
||||
hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent);
|
||||
hdc->DestroyClippingRegion();
|
||||
}
|
||||
|
||||
|
||||
@@ -450,7 +451,7 @@ void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, int *positio
|
||||
#ifndef __WXMAC__
|
||||
// Calculate the position of each character based on the widths of
|
||||
// the previous characters
|
||||
int* tpos = new int[len];
|
||||
int* tpos = new int[len+1];
|
||||
int totalWidth = 0;
|
||||
size_t i;
|
||||
for (i=0; i<str.Length(); i++) {
|
||||
@@ -465,7 +466,7 @@ void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, int *positio
|
||||
// on OS X widths can be fractions of pixels wide when more than one
|
||||
// are drawn together, so the sum of all character widths is not necessarily
|
||||
// (and probably not) the same as the whole string width.
|
||||
int* tpos = new int[len];
|
||||
int* tpos = new int[len+1];
|
||||
size_t i;
|
||||
for (i=0; i<str.Length(); i++) {
|
||||
int w, h;
|
||||
@@ -481,7 +482,7 @@ void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, int *positio
|
||||
// so figure it out and fix it!
|
||||
i = 0;
|
||||
size_t ui = 0;
|
||||
while (i < len) {
|
||||
while ((int)i < len) {
|
||||
unsigned char uch = (unsigned char)s[i];
|
||||
positions[i++] = tpos[ui];
|
||||
if (uch >= 0x80) {
|
||||
@@ -541,7 +542,7 @@ int SurfaceImpl::Descent(Font &font) {
|
||||
return d;
|
||||
}
|
||||
|
||||
int SurfaceImpl::InternalLeading(Font &font) {
|
||||
int SurfaceImpl::InternalLeading(Font &WXUNUSED(font)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -562,7 +563,7 @@ int SurfaceImpl::AverageCharWidth(Font &font) {
|
||||
return hdc->GetCharWidth();
|
||||
}
|
||||
|
||||
int SurfaceImpl::SetPalette(Palette *pal, bool inBackGround) {
|
||||
int SurfaceImpl::SetPalette(Palette *WXUNUSED(pal), bool WXUNUSED(inBackGround)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -577,7 +578,7 @@ void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) {
|
||||
unicodeMode=unicodeMode_;
|
||||
}
|
||||
|
||||
void SurfaceImpl::SetDBCSMode(int codePage) {
|
||||
void SurfaceImpl::SetDBCSMode(int WXUNUSED(codePage)) {
|
||||
// dbcsMode = codePage == SC_CP_DBCS;
|
||||
}
|
||||
|
||||
@@ -674,6 +675,7 @@ void Window::SetCursor(Cursor curs) {
|
||||
break;
|
||||
case cursorHand:
|
||||
cursorId = wxCURSOR_HAND;
|
||||
break;
|
||||
default:
|
||||
cursorId = wxCURSOR_ARROW;
|
||||
break;
|
||||
@@ -887,7 +889,7 @@ PRectangle ListBoxImpl::GetDesiredRect() {
|
||||
// wxListCtrl doesn't have a DoGetBestSize, so instead we kept track of
|
||||
// the max size in Append and calculate it here...
|
||||
int maxw = maxStrWidth;
|
||||
int maxh = 0;
|
||||
int maxh ;
|
||||
|
||||
// give it a default if there are no lines, and/or add a bit more
|
||||
if (maxw == 0) maxw = 100;
|
||||
@@ -968,7 +970,7 @@ int ListBoxImpl::GetSelection() {
|
||||
}
|
||||
|
||||
|
||||
int ListBoxImpl::Find(const char *prefix) {
|
||||
int ListBoxImpl::Find(const char *WXUNUSED(prefix)) {
|
||||
// No longer used
|
||||
return -1;
|
||||
}
|
||||
@@ -1002,7 +1004,7 @@ void ListBoxImpl::RegisterImage(int type, const char *xpm_data) {
|
||||
|
||||
// do we need to extend the mapping array?
|
||||
wxArrayInt& itm = *imgTypeMap;
|
||||
if ( itm.GetCount() < type+1)
|
||||
if ( itm.GetCount() < (size_t)type+1)
|
||||
itm.Add(-1, type - itm.GetCount() + 1);
|
||||
|
||||
// Add an item that maps type to the image index
|
||||
@@ -1062,6 +1064,13 @@ void Menu::Show(Point pt, Window &w) {
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
DynamicLibrary *DynamicLibrary::Load(const char *WXUNUSED(modulePath)) {
|
||||
wxFAIL_MSG(wxT("Dynamic lexer loading not implemented yet"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
ColourDesired Platform::Chrome() {
|
||||
wxColour c;
|
||||
c = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
|
||||
@@ -1095,7 +1104,7 @@ void Platform::DebugDisplay(const char *s) {
|
||||
wxLogDebug(stc2wx(s));
|
||||
}
|
||||
|
||||
bool Platform::IsKeyDown(int key) {
|
||||
bool Platform::IsKeyDown(int WXUNUSED(key)) {
|
||||
return false; // I don't think we'll need this.
|
||||
}
|
||||
|
||||
@@ -1188,16 +1197,16 @@ int Platform::Clamp(int val, int minVal, int maxVal) {
|
||||
}
|
||||
|
||||
|
||||
bool Platform::IsDBCSLeadByte(int codePage, char ch) {
|
||||
bool Platform::IsDBCSLeadByte(int WXUNUSED(codePage), char WXUNUSED(ch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int Platform::DBCSCharLength(int codePage, const char *s) {
|
||||
return 0;
|
||||
int Platform::DBCSCharLength(int WXUNUSED(codePage), const char *WXUNUSED(s)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Platform::DBCSCharMaxLength() {
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1216,6 +1225,22 @@ double ElapsedTime::Duration(bool reset) {
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
wxString stc2wx(const char* str, size_t len)
|
||||
{
|
||||
char *buffer=new char[len+1];
|
||||
strncpy(buffer, str, len);
|
||||
buffer[len]=0;
|
||||
|
||||
wxString cstr(buffer, wxConvUTF8);
|
||||
|
||||
delete[] buffer;
|
||||
return cstr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
|
||||
#include "ScintillaWX.h"
|
||||
#include "ExternalLexer.h"
|
||||
#include "wx/stc/stc.h"
|
||||
#include "PlatWX.h"
|
||||
|
||||
@@ -337,12 +338,7 @@ void ScintillaWX::Copy() {
|
||||
if (currentPos != anchor) {
|
||||
SelectionText st;
|
||||
CopySelectionRange(&st);
|
||||
if (wxTheClipboard->Open()) {
|
||||
wxTheClipboard->UsePrimarySelection(FALSE);
|
||||
wxString text = stc2wx(st.s, st.len);
|
||||
wxTheClipboard->SetData(new wxTextDataObject(text));
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
CopyToClipboard(st);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,12 +368,23 @@ void ScintillaWX::Paste() {
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::CopyToClipboard(const SelectionText& st) {
|
||||
if (wxTheClipboard->Open()) {
|
||||
wxTheClipboard->UsePrimarySelection(FALSE);
|
||||
wxString text = stc2wx(st.s, st.len);
|
||||
wxTheClipboard->SetData(new wxTextDataObject(text));
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool ScintillaWX::CanPaste() {
|
||||
bool canPaste = FALSE;
|
||||
bool didOpen;
|
||||
|
||||
if (Editor::CanPaste()) {
|
||||
if ( (didOpen = !wxTheClipboard->IsOpened()) )
|
||||
didOpen = !wxTheClipboard->IsOpened();
|
||||
if ( didOpen )
|
||||
wxTheClipboard->Open();
|
||||
|
||||
if (wxTheClipboard->IsOpened()) {
|
||||
@@ -402,7 +409,7 @@ void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) {
|
||||
if (!label[0])
|
||||
((wxMenu*)popup.GetID())->AppendSeparator();
|
||||
else
|
||||
((wxMenu*)popup.GetID())->Append(cmd, stc2wx(label));
|
||||
((wxMenu*)popup.GetID())->Append(cmd, wxGetTranslation(stc2wx(label)));
|
||||
|
||||
if (!enabled)
|
||||
((wxMenu*)popup.GetID())->Enable(cmd, enabled);
|
||||
@@ -474,6 +481,11 @@ long ScintillaWX::WndProc(unsigned int iMessage, unsigned long wParam, long lPar
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef SCI_LEXER
|
||||
case SCI_LOADLEXERLIBRARY:
|
||||
LexerManager::GetInstance()->Load((const char*)lParam);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return ScintillaBase::WndProc(iMessage, wParam, lParam);
|
||||
}
|
||||
@@ -586,7 +598,7 @@ void ScintillaWX::DoMouseWheel(int rotation, int delta,
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::DoSize(int width, int height) {
|
||||
void ScintillaWX::DoSize(int WXUNUSED(width), int WXUNUSED(height)) {
|
||||
// PRectangle rcClient(0,0,width,height);
|
||||
// SetScrollBarsTo(rcClient);
|
||||
// DropGraphics();
|
||||
@@ -617,8 +629,8 @@ void ScintillaWX::DoLeftButtonMove(Point pt) {
|
||||
ButtonMove(pt);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoMiddleButtonUp(Point pt) {
|
||||
#ifdef __WXGTK__
|
||||
void ScintillaWX::DoMiddleButtonUp(Point pt) {
|
||||
// Set the current position to the mouse click point and
|
||||
// then paste in the PRIMARY selection, if any. wxGTK only.
|
||||
int newPos = PositionFromLocation(pt);
|
||||
@@ -645,8 +657,11 @@ void ScintillaWX::DoMiddleButtonUp(Point pt) {
|
||||
|
||||
ShowCaretAtCurrentPosition();
|
||||
EnsureCaretVisible();
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
void ScintillaWX::DoMiddleButtonUp(Point WXUNUSED(pt)) {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void ScintillaWX::DoAddChar(int key) {
|
||||
@@ -662,9 +677,14 @@ void ScintillaWX::DoAddChar(int key) {
|
||||
}
|
||||
|
||||
|
||||
int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed) {
|
||||
#ifdef __WXMAC__
|
||||
int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool meta, bool* consumed) {
|
||||
#else
|
||||
int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool WXUNUSED(meta), bool* consumed) {
|
||||
#endif
|
||||
#if defined(__WXGTK__) || defined(__WXMAC__)
|
||||
// Ctrl chars (A-Z) end up with the wrong keycode on wxGTK...
|
||||
// Ctrl chars (A-Z) end up with the wrong keycode on wxGTK
|
||||
// TODO: Check this, it shouldn't be true any longer.
|
||||
if (ctrl && key >= 1 && key <= 26)
|
||||
key += 'A' - 1;
|
||||
#endif
|
||||
@@ -698,6 +718,22 @@ int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* cons
|
||||
case WXK_MENU: key = 0; break;
|
||||
}
|
||||
|
||||
#ifdef __WXMAC__
|
||||
if ( meta ) {
|
||||
// check for a few common Mac Meta-key combos and remap them to Ctrl
|
||||
// for Scintilla
|
||||
switch ( key ) {
|
||||
case 'Z': // Undo
|
||||
case 'X': // Cut
|
||||
case 'C': // Copy
|
||||
case 'V': // Paste
|
||||
case 'A': // Select All
|
||||
ctrl = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int rv = KeyDown(key, shift, ctrl, alt, consumed);
|
||||
|
||||
if (key)
|
||||
@@ -749,7 +785,7 @@ bool ScintillaWX::DoDropText(long x, long y, const wxString& data) {
|
||||
}
|
||||
|
||||
|
||||
wxDragResult ScintillaWX::DoDragEnter(wxCoord x, wxCoord y, wxDragResult def) {
|
||||
wxDragResult ScintillaWX::DoDragEnter(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxDragResult def) {
|
||||
dragResult = def;
|
||||
return dragResult;
|
||||
}
|
||||
@@ -806,8 +842,8 @@ void ScintillaWX::DoScrollToColumn(int column) {
|
||||
HorizontalScrollTo(column * vs.spaceWidth);
|
||||
}
|
||||
|
||||
void ScintillaWX::ClipChildren(wxDC& dc, PRectangle rect) {
|
||||
#ifdef __WXGTK__
|
||||
void ScintillaWX::ClipChildren(wxDC& dc, PRectangle rect) {
|
||||
wxRegion rgn(wxRectFromPRectangle(rect));
|
||||
if (ac.Active()) {
|
||||
wxRect childRect = ((wxWindow*)ac.lb->GetID())->GetRect();
|
||||
@@ -819,9 +855,11 @@ void ScintillaWX::ClipChildren(wxDC& dc, PRectangle rect) {
|
||||
}
|
||||
|
||||
dc.SetClippingRegion(rgn);
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
void ScintillaWX::ClipChildren(wxDC& WXUNUSED(dc), PRectangle WXUNUSED(rect)) {
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------
|
||||
|
@@ -55,7 +55,15 @@
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class wxStyledTextCtrl; // forward
|
||||
#ifdef WXMAKINGDLL_STC
|
||||
#define WXDLLIMPEXP_STC WXEXPORT
|
||||
#elif defined(WXUSINGDLL)
|
||||
#define WXDLLIMPEXP_STC WXIMPORT
|
||||
#else // not making nor using DLL
|
||||
#define WXDLLIMPEXP_STC
|
||||
#endif
|
||||
|
||||
class WXDLLIMPEXP_STC wxStyledTextCtrl; // forward
|
||||
class ScintillaWX;
|
||||
|
||||
|
||||
@@ -100,6 +108,8 @@ public:
|
||||
virtual bool ModifyScrollBars(int nMax, int nPage);
|
||||
virtual void Copy();
|
||||
virtual void Paste();
|
||||
virtual void CopyToClipboard(const SelectionText &selectedText);
|
||||
|
||||
virtual void CreateCallTipWindow(PRectangle rc);
|
||||
virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true);
|
||||
virtual void ClaimSelection();
|
||||
@@ -129,7 +139,7 @@ public:
|
||||
void DoMiddleButtonUp(Point pt);
|
||||
void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll);
|
||||
void DoAddChar(int key);
|
||||
int DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed);
|
||||
int DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool meta, bool* consumed);
|
||||
void DoTick() { Tick(); }
|
||||
|
||||
#if wxUSE_DRAG_AND_DROP
|
||||
|
@@ -8,21 +8,21 @@
|
||||
CFG=stcVC - Win32 Release DLL
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "StcVC.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "StcVC.mak" CFG="stcVC - Win32 Release DLL"
|
||||
!MESSAGE
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE
|
||||
!MESSAGE "stcVC - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "stcVC - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "stcVC - Win32 Debug DLL" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "stcVC - Win32 Release DLL" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
@@ -149,7 +149,7 @@ LINK32=link.exe
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib odbc32.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib winmm.lib wxmsw24.lib /nologo /version:1.0 /dll /machine:IX86 /out:"../../../lib/stcdll.dll" /libpath:"../../../lib"
|
||||
# SUBTRACT LINK32 /pdb:none /incremental:no /debug
|
||||
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
@@ -254,6 +254,10 @@ SOURCE=.\scintilla\src\Editor.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\ExternalLexer.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\Indicator.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -318,6 +322,10 @@ SOURCE=.\scintilla\src\LexEiffel.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexEScript.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexFortran.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -330,6 +338,10 @@ SOURCE=.\scintilla\src\LexLisp.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexLout.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexLua.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -338,11 +350,15 @@ SOURCE=.\scintilla\src\LexMatlab.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexOthers.cxx
|
||||
SOURCE=.\scintilla\src\LexMMIXAL.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexPOV.cxx
|
||||
SOURCE=.\scintilla\src\LexNsis.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexOthers.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -354,6 +370,14 @@ SOURCE=.\scintilla\src\LexPerl.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexPOV.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexPS.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexPython.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -362,6 +386,10 @@ SOURCE=.\scintilla\src\LexRuby.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexScriptol.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexSQL.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -462,11 +490,11 @@ SOURCE=.\scintilla\src\WindowAccessor.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\XPM.cxx
|
||||
SOURCE=.\scintilla\include\WindowAccessor.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\include\WindowAccessor.h
|
||||
SOURCE=.\scintilla\src\XPM.cxx
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
|
@@ -395,7 +395,7 @@ methodOverrideMap = {
|
||||
int len = end - start;
|
||||
if (!len) return wxEmptyString;
|
||||
|
||||
wxMemoryBuffer mbuf(len+1);
|
||||
wxMemoryBuffer mbuf(len+2);
|
||||
char* buf = (char*)mbuf.GetWriteBuf(len+1);
|
||||
SendMsg(%s, 0, (long)buf);
|
||||
mbuf.UngetWriteBuf(len);
|
||||
@@ -547,9 +547,12 @@ methodOverrideMap = {
|
||||
|
||||
|
||||
'GrabFocus' : (None, 0, 0, 0),
|
||||
|
||||
# Rename some that woudl otherwise hid the wxWindow methods
|
||||
'SetFocus' : ('SetSTCFocus', 0, 0, 0),
|
||||
'GetFocus' : ('GetSTCFocus', 0, 0, 0),
|
||||
|
||||
'SetCursor' : ('SetSTCCursor', 0, 0, 0),
|
||||
'GetCursor' : ('GetSTCCursor', 0, 0, 0),
|
||||
|
||||
'LoadLexerLibrary' : (None, 0,0,0),
|
||||
|
||||
|
@@ -29,6 +29,7 @@ OBJECTS = \
|
||||
Document.obj \
|
||||
DocumentAccessor.obj \
|
||||
Editor.obj \
|
||||
ExternalLexer.obj \
|
||||
Indicator.obj \
|
||||
KeyMap.obj \
|
||||
KeyWords.obj \
|
||||
@@ -43,9 +44,11 @@ OBJECTS = \
|
||||
LexCrontab.obj \
|
||||
LexCSS.obj \
|
||||
LexEiffel.obj \
|
||||
LexEScript.obj \
|
||||
LexFortran.obj \
|
||||
LexHTML.obj \
|
||||
LexLisp.obj \
|
||||
LexLout.obj \
|
||||
LexLua.obj \
|
||||
LexOthers.obj \
|
||||
LexPOV.obj \
|
||||
@@ -55,6 +58,10 @@ OBJECTS = \
|
||||
LexRuby.obj \
|
||||
LexSQL.obj \
|
||||
LexVB.obj \
|
||||
LexMMIXAL.obj \
|
||||
LexNsis.obj \
|
||||
LexPS.obj \
|
||||
LexScriptol.obj \
|
||||
LineMarker.obj \
|
||||
PropSet.obj \
|
||||
RESearch.obj \
|
||||
@@ -65,7 +72,6 @@ OBJECTS = \
|
||||
ViewStyle.obj \
|
||||
WindowAccessor.obj \
|
||||
XPM.obj \
|
||||
\
|
||||
PlatWX.obj \
|
||||
ScintillaWX.obj \
|
||||
stc.obj \
|
||||
|
@@ -17,6 +17,7 @@ OBJECTS = \
|
||||
$(S)/Document.$(OBJSUFF) \
|
||||
$(S)/DocumentAccessor.$(OBJSUFF) \
|
||||
$(S)/Editor.$(OBJSUFF) \
|
||||
$(S)/ExternalLexer.$(OBJSUFF) \
|
||||
$(S)/Indicator.$(OBJSUFF) \
|
||||
$(S)/KeyMap.$(OBJSUFF) \
|
||||
$(S)/KeyWords.$(OBJSUFF) \
|
||||
@@ -31,9 +32,11 @@ OBJECTS = \
|
||||
$(S)/LexCrontab.$(OBJSUFF) \
|
||||
$(S)/LexCSS.$(OBJSUFF) \
|
||||
$(S)/LexEiffel.$(OBJSUFF) \
|
||||
$(S)/LexEScript.$(OBJSUFF) \
|
||||
$(S)/LexFortran.$(OBJSUFF) \
|
||||
$(S)/LexHTML.$(OBJSUFF) \
|
||||
$(S)/LexLisp.$(OBJSUFF) \
|
||||
$(S)/LexLout.$(OBJSUFF) \
|
||||
$(S)/LexLua.$(OBJSUFF) \
|
||||
$(S)/LexOthers.$(OBJSUFF) \
|
||||
$(S)/LexPOV.$(OBJSUFF) \
|
||||
@@ -43,6 +46,10 @@ OBJECTS = \
|
||||
$(S)/LexRuby.$(OBJSUFF) \
|
||||
$(S)/LexSQL.$(OBJSUFF) \
|
||||
$(S)/LexVB.$(OBJSUFF) \
|
||||
$(S)/LexMMIXAL.$(OBJSUFF) \
|
||||
$(S)/LexNsis.$(OBJSUFF) \
|
||||
$(S)/LexPS.$(OBJSUFF) \
|
||||
$(S)/LexScriptol.$(OBJSUFF) \
|
||||
$(S)/LineMarker.$(OBJSUFF) \
|
||||
$(S)/PropSet.$(OBJSUFF) \
|
||||
$(S)/RESearch.$(OBJSUFF) \
|
||||
|
81
contrib/src/stc/makefile.sc
Normal file
81
contrib/src/stc/makefile.sc
Normal file
@@ -0,0 +1,81 @@
|
||||
WXDIR = ..\..\..
|
||||
|
||||
SCINTILLA=.\scintilla
|
||||
S=$(SCINTILLA)\src
|
||||
|
||||
EXTRASTCCPPFLAGS = -D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(SCINTILLA)/include -I$(S)
|
||||
EXTRACPPFLAGS=$(EXTRACPPFLAGS) $(EXTRASTCCPPFLAGS)
|
||||
STCCPPFLAGS=$(DLL_FLAGS) $(EXTRACPPFLAGS)
|
||||
|
||||
include $(WXDIR)\src\makesc.env
|
||||
LIBTARGET=$(WXDIR)\lib\stc$(SC_SUFFIX).lib
|
||||
THISDIR=$(WXDIR)\contrib\src\stc
|
||||
|
||||
|
||||
|
||||
|
||||
# variables
|
||||
OBJECTS = \
|
||||
$(S)\AutoComplete.obj \
|
||||
$(S)\CallTip.obj \
|
||||
$(S)\CellBuffer.obj \
|
||||
$(S)\ContractionState.obj \
|
||||
$(S)\Document.obj \
|
||||
$(S)\DocumentAccessor.obj \
|
||||
$(S)\Editor.obj \
|
||||
$(S)\ExternalLexer.obj \
|
||||
$(S)\Indicator.obj \
|
||||
$(S)\KeyMap.obj \
|
||||
$(S)\KeyWords.obj \
|
||||
$(S)\LexAVE.obj \
|
||||
$(S)\LexAda.obj \
|
||||
$(S)\LexAsm.obj \
|
||||
$(S)\LexBaan.obj \
|
||||
$(S)\LexBullant.obj \
|
||||
$(S)\LexMatlab.obj \
|
||||
$(S)\LexCPP.obj \
|
||||
$(S)\LexConf.obj \
|
||||
$(S)\LexCrontab.obj \
|
||||
$(S)\LexCSS.obj \
|
||||
$(S)\LexEiffel.obj \
|
||||
$(S)\LexEScript.obj \
|
||||
$(S)\LexFortran.obj \
|
||||
$(S)\LexHTML.obj \
|
||||
$(S)\LexLisp.obj \
|
||||
$(S)\LexLua.obj \
|
||||
$(S)\LexLout.obj \
|
||||
$(S)\LexOthers.obj \
|
||||
$(S)\LexPOV.obj \
|
||||
$(S)\LexPascal.obj \
|
||||
$(S)\LexPerl.obj \
|
||||
$(S)\LexPython.obj \
|
||||
$(S)\LexRuby.obj \
|
||||
$(S)\LexSQL.obj \
|
||||
$(S)\LexVB.obj \
|
||||
$(S)\LexMMIXAL.obj \
|
||||
$(S)\LexNsis.obj \
|
||||
$(S)\LexPS.obj \
|
||||
$(S)\LexScriptol.obj \
|
||||
$(S)\LineMarker.obj \
|
||||
$(S)\PropSet.obj \
|
||||
$(S)\RESearch.obj \
|
||||
$(S)\ScintillaBase.obj \
|
||||
$(S)\Style.obj \
|
||||
$(S)\StyleContext.obj \
|
||||
$(S)\UniConversion.obj \
|
||||
$(S)\ViewStyle.obj \
|
||||
$(S)\WindowAccessor.obj \
|
||||
$(S)\XPM.obj \
|
||||
\
|
||||
PlatWX.obj \
|
||||
ScintillaWX.obj \
|
||||
stc.obj \
|
||||
|
||||
|
||||
include $(WXDIR)\src\makelib.sc
|
||||
|
||||
|
||||
.cxx.obj:
|
||||
*$(CC) -c $(CFLAGS) $(STCCPPFLAGS) $(INCLUDE) $(OPTIONS) $< -o$@
|
||||
|
||||
|
@@ -22,6 +22,7 @@ OBJECTS = \
|
||||
$(D)\Document.obj \
|
||||
$(D)\DocumentAccessor.obj \
|
||||
$(D)\Editor.obj \
|
||||
$(D)\ExternalLexer.obj \
|
||||
$(D)\Indicator.obj \
|
||||
$(D)\KeyMap.obj \
|
||||
$(D)\KeyWords.obj \
|
||||
@@ -36,9 +37,11 @@ OBJECTS = \
|
||||
$(D)\LexCrontab.obj \
|
||||
$(D)\LexCSS.obj \
|
||||
$(D)\LexEiffel.obj \
|
||||
$(D)\LexEScript.obj \
|
||||
$(D)\LexFortran.obj \
|
||||
$(D)\LexHTML.obj \
|
||||
$(D)\LexLisp.obj \
|
||||
$(D)\LexLout.obj \
|
||||
$(D)\LexLua.obj \
|
||||
$(D)\LexOthers.obj \
|
||||
$(D)\LexPOV.obj \
|
||||
@@ -48,6 +51,10 @@ OBJECTS = \
|
||||
$(D)\LexRuby.obj \
|
||||
$(D)\LexSQL.obj \
|
||||
$(D)\LexVB.obj \
|
||||
$(D)\LexMMIXAL.obj \
|
||||
$(D)\LexNsis.obj \
|
||||
$(D)\LexPS.obj \
|
||||
$(D)\LexScriptol.obj \
|
||||
$(D)\LineMarker.obj \
|
||||
$(D)\PropSet.obj \
|
||||
$(D)\RESearch.obj \
|
||||
|
@@ -26,6 +26,7 @@ OBJECTS = &
|
||||
Document.obj &
|
||||
DocumentAccessor.obj &
|
||||
Editor.obj &
|
||||
ExternalLexer.obj &
|
||||
Indicator.obj &
|
||||
KeyMap.obj &
|
||||
KeyWords.obj &
|
||||
@@ -40,9 +41,11 @@ OBJECTS = &
|
||||
LexCrontab.obj &
|
||||
LexCSS.obj &
|
||||
LexEiffel.obj &
|
||||
LexEScript.obj &
|
||||
LexFortran.obj &
|
||||
LexHTML.obj &
|
||||
LexLisp.obj &
|
||||
LexLout.obj &
|
||||
LexLua.obj &
|
||||
LexOthers.obj &
|
||||
LexPOV.obj &
|
||||
@@ -52,6 +55,10 @@ OBJECTS = &
|
||||
LexRuby.obj &
|
||||
LexSQL.obj &
|
||||
LexVB.obj &
|
||||
LexMMIXAL.obj &
|
||||
LexNsis.obj &
|
||||
LexPS.obj &
|
||||
LexScriptol.obj &
|
||||
LineMarker.obj &
|
||||
PropSet.obj &
|
||||
RESearch.obj &
|
||||
|
@@ -3,4 +3,4 @@ scintilla/include directories from the Scintilla/SCiTE source
|
||||
distribution. All other code needed to implement Scintilla on top of
|
||||
wxWindows is located in the directory above this one.
|
||||
|
||||
The current version of the Scintilla code is 1.52
|
||||
The current version of the Scintilla code is 1.54
|
||||
|
@@ -25,7 +25,7 @@ protected:
|
||||
char buf[bufferSize+1];
|
||||
int startPos;
|
||||
int endPos;
|
||||
int codePage;
|
||||
int codePage;
|
||||
|
||||
virtual bool InternalIsLeadByte(char ch)=0;
|
||||
virtual void Fill(int position)=0;
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
if (position < startPos || position >= endPos) {
|
||||
Fill(position);
|
||||
if (position < startPos || position >= endPos) {
|
||||
// Position is outside range of document
|
||||
// Position is outside range of document
|
||||
return chDefault;
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler);
|
||||
|
||||
|
||||
/**
|
||||
* A LexerModule is responsible for lexing and folding a particular language.
|
||||
* The class maintains a list of LexerModules which can be searched to find a
|
||||
@@ -26,7 +26,7 @@ protected:
|
||||
|
||||
public:
|
||||
const char *languageName;
|
||||
LexerModule(int language_, LexerFunction fnLexer_,
|
||||
LexerModule(int language_, LexerFunction fnLexer_,
|
||||
const char *languageName_=0, LexerFunction fnFolder_=0,
|
||||
const char * const wordListDescriptions_[] = NULL);
|
||||
int GetLanguage() const { return language; }
|
||||
|
@@ -57,6 +57,7 @@ typedef void *SurfaceID;
|
||||
typedef void *WindowID;
|
||||
typedef void *MenuID;
|
||||
typedef void *TickerID;
|
||||
typedef void *Function;
|
||||
|
||||
/**
|
||||
* A geometric point class.
|
||||
@@ -434,6 +435,23 @@ public:
|
||||
double Duration(bool reset=false);
|
||||
};
|
||||
|
||||
/**
|
||||
* Dynamic Library (DLL/SO/...) loading
|
||||
*/
|
||||
class DynamicLibrary {
|
||||
public:
|
||||
virtual ~DynamicLibrary() {};
|
||||
|
||||
/// @return Pointer to function "name", or NULL on failure.
|
||||
virtual Function FindFunction(const char *name) = 0;
|
||||
|
||||
/// @return true if the library was loaded successfully.
|
||||
virtual bool IsValid() = 0;
|
||||
|
||||
/// @return An instance of a DynamicLibrary subclass with "modulePath" loaded.
|
||||
static DynamicLibrary *Load(const char *modulePath);
|
||||
};
|
||||
|
||||
/**
|
||||
* Platform class used to retrieve system wide parameters such as double click speed
|
||||
* and chrome colour. Not a creatable object, more of a module with several functions.
|
||||
|
@@ -24,11 +24,21 @@ struct Property {
|
||||
/**
|
||||
*/
|
||||
class PropSet {
|
||||
private:
|
||||
protected:
|
||||
enum { hashRoots=31 };
|
||||
Property *props[hashRoots];
|
||||
Property *enumnext;
|
||||
int enumhash;
|
||||
static unsigned int HashString(const char *s, size_t len) {
|
||||
unsigned int ret = 0;
|
||||
while (len--) {
|
||||
ret <<= 4;
|
||||
ret ^= *s;
|
||||
s++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
static bool IncludesVar(const char *value, const char *key);
|
||||
public:
|
||||
PropSet *superPS;
|
||||
PropSet();
|
||||
@@ -38,7 +48,7 @@ public:
|
||||
void SetMultiple(const char *s);
|
||||
SString Get(const char *key);
|
||||
SString GetExpanded(const char *key);
|
||||
SString Expand(const char *withVars);
|
||||
SString Expand(const char *withVars, int maxExpands=100);
|
||||
int GetInt(const char *key, int defaultValue=0);
|
||||
SString GetWild(const char *keybase, const char *filename);
|
||||
SString GetNewExpand(const char *keybase, const char *filename="");
|
||||
|
@@ -54,6 +54,11 @@
|
||||
#define SCLEX_F77 37
|
||||
#define SCLEX_CSS 38
|
||||
#define SCLEX_POV 39
|
||||
#define SCLEX_LOUT 40
|
||||
#define SCLEX_ESCRIPT 41
|
||||
#define SCLEX_PS 42
|
||||
#define SCLEX_NSIS 43
|
||||
#define SCLEX_MMIXAL 44
|
||||
#define SCLEX_AUTOMATIC 1000
|
||||
#define SCE_P_DEFAULT 0
|
||||
#define SCE_P_COMMENTLINE 1
|
||||
@@ -88,6 +93,7 @@
|
||||
#define SCE_C_WORD2 16
|
||||
#define SCE_C_COMMENTDOCKEYWORD 17
|
||||
#define SCE_C_COMMENTDOCKEYWORDERROR 18
|
||||
#define SCE_C_GLOBALCLASS 19
|
||||
#define SCE_H_DEFAULT 0
|
||||
#define SCE_H_TAG 1
|
||||
#define SCE_H_TAGUNKNOWN 2
|
||||
@@ -265,6 +271,8 @@
|
||||
#define SCE_LUA_WORD4 15
|
||||
#define SCE_LUA_WORD5 16
|
||||
#define SCE_LUA_WORD6 17
|
||||
#define SCE_LUA_WORD7 18
|
||||
#define SCE_LUA_WORD8 19
|
||||
#define SCE_ERR_DEFAULT 0
|
||||
#define SCE_ERR_PYTHON 1
|
||||
#define SCE_ERR_GCC 2
|
||||
@@ -452,14 +460,91 @@
|
||||
#define SCE_POV_DEFAULT 0
|
||||
#define SCE_POV_COMMENT 1
|
||||
#define SCE_POV_COMMENTLINE 2
|
||||
#define SCE_POV_COMMENTDOC 3
|
||||
#define SCE_POV_NUMBER 4
|
||||
#define SCE_POV_WORD 5
|
||||
#define SCE_POV_NUMBER 3
|
||||
#define SCE_POV_OPERATOR 4
|
||||
#define SCE_POV_IDENTIFIER 5
|
||||
#define SCE_POV_STRING 6
|
||||
#define SCE_POV_OPERATOR 7
|
||||
#define SCE_POV_IDENTIFIER 8
|
||||
#define SCE_POV_BRACE 9
|
||||
#define SCE_POV_STRINGEOL 7
|
||||
#define SCE_POV_DIRECTIVE 8
|
||||
#define SCE_POV_BADDIRECTIVE 9
|
||||
#define SCE_POV_WORD2 10
|
||||
#define SCE_POV_WORD3 11
|
||||
#define SCE_POV_WORD4 12
|
||||
#define SCE_POV_WORD5 13
|
||||
#define SCE_POV_WORD6 14
|
||||
#define SCE_POV_WORD7 15
|
||||
#define SCE_POV_WORD8 16
|
||||
#define SCE_LOUT_DEFAULT 0
|
||||
#define SCE_LOUT_COMMENT 1
|
||||
#define SCE_LOUT_NUMBER 2
|
||||
#define SCE_LOUT_WORD 3
|
||||
#define SCE_LOUT_WORD2 4
|
||||
#define SCE_LOUT_WORD3 5
|
||||
#define SCE_LOUT_WORD4 6
|
||||
#define SCE_LOUT_STRING 7
|
||||
#define SCE_LOUT_OPERATOR 8
|
||||
#define SCE_LOUT_IDENTIFIER 9
|
||||
#define SCE_LOUT_STRINGEOL 10
|
||||
#define SCE_ESCRIPT_DEFAULT 0
|
||||
#define SCE_ESCRIPT_COMMENT 1
|
||||
#define SCE_ESCRIPT_COMMENTLINE 2
|
||||
#define SCE_ESCRIPT_COMMENTDOC 3
|
||||
#define SCE_ESCRIPT_NUMBER 4
|
||||
#define SCE_ESCRIPT_WORD 5
|
||||
#define SCE_ESCRIPT_STRING 6
|
||||
#define SCE_ESCRIPT_OPERATOR 7
|
||||
#define SCE_ESCRIPT_IDENTIFIER 8
|
||||
#define SCE_ESCRIPT_BRACE 9
|
||||
#define SCE_ESCRIPT_WORD2 10
|
||||
#define SCE_ESCRIPT_WORD3 11
|
||||
#define SCE_PS_DEFAULT 0
|
||||
#define SCE_PS_COMMENT 1
|
||||
#define SCE_PS_DSC_COMMENT 2
|
||||
#define SCE_PS_DSC_VALUE 3
|
||||
#define SCE_PS_NUMBER 4
|
||||
#define SCE_PS_NAME 5
|
||||
#define SCE_PS_KEYWORD 6
|
||||
#define SCE_PS_LITERAL 7
|
||||
#define SCE_PS_IMMEVAL 8
|
||||
#define SCE_PS_PAREN_ARRAY 9
|
||||
#define SCE_PS_PAREN_DICT 10
|
||||
#define SCE_PS_PAREN_PROC 11
|
||||
#define SCE_PS_TEXT 12
|
||||
#define SCE_PS_HEXSTRING 13
|
||||
#define SCE_PS_BASE85STRING 14
|
||||
#define SCE_PS_BADSTRINGCHAR 15
|
||||
#define SCE_NSIS_DEFAULT 0
|
||||
#define SCE_NSIS_COMMENT 1
|
||||
#define SCE_NSIS_STRINGDQ 2
|
||||
#define SCE_NSIS_STRINGLQ 3
|
||||
#define SCE_NSIS_STRINGRQ 4
|
||||
#define SCE_NSIS_FUNCTION 5
|
||||
#define SCE_NSIS_VARIABLE 6
|
||||
#define SCE_NSIS_LABEL 7
|
||||
#define SCE_NSIS_USERDEFINED 8
|
||||
#define SCE_NSIS_SECTIONDEF 9
|
||||
#define SCE_NSIS_SUBSECTIONDEF 10
|
||||
#define SCE_NSIS_IFDEFINEDEF 11
|
||||
#define SCE_NSIS_MACRODEF 12
|
||||
#define SCE_NSIS_STRINGVAR 13
|
||||
#define SCE_MMIXAL_LEADWS 0
|
||||
#define SCE_MMIXAL_COMMENT 1
|
||||
#define SCE_MMIXAL_LABEL 2
|
||||
#define SCE_MMIXAL_OPCODE 3
|
||||
#define SCE_MMIXAL_OPCODE_PRE 4
|
||||
#define SCE_MMIXAL_OPCODE_VALID 5
|
||||
#define SCE_MMIXAL_OPCODE_UNKNOWN 6
|
||||
#define SCE_MMIXAL_OPCODE_POST 7
|
||||
#define SCE_MMIXAL_OPERANDS 8
|
||||
#define SCE_MMIXAL_NUMBER 9
|
||||
#define SCE_MMIXAL_REF 10
|
||||
#define SCE_MMIXAL_CHAR 11
|
||||
#define SCE_MMIXAL_STRING 12
|
||||
#define SCE_MMIXAL_REGISTER 13
|
||||
#define SCE_MMIXAL_HEX 14
|
||||
#define SCE_MMIXAL_OPERATOR 15
|
||||
#define SCE_MMIXAL_SYMBOL 16
|
||||
#define SCE_MMIXAL_INCLUDE 17
|
||||
//--Autogenerated -- end of section automatically generated from Scintilla.iface
|
||||
|
||||
#endif
|
||||
|
@@ -204,6 +204,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define INDIC_TT 2
|
||||
#define INDIC_DIAGONAL 3
|
||||
#define INDIC_STRIKE 4
|
||||
#define INDIC_HIDDEN 5
|
||||
#define INDIC0_MASK 0x20
|
||||
#define INDIC1_MASK 0x40
|
||||
#define INDIC2_MASK 0x80
|
||||
@@ -464,6 +465,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SCI_LINEENDWRAPEXTEND 2452
|
||||
#define SCI_VCHOMEWRAP 2453
|
||||
#define SCI_VCHOMEWRAPEXTEND 2454
|
||||
#define SCI_LINECOPY 2455
|
||||
#define SCI_MOVECARETINSIDEVIEW 2401
|
||||
#define SCI_LINELENGTH 2350
|
||||
#define SCI_BRACEHIGHLIGHT 2351
|
||||
@@ -535,12 +537,17 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SCI_PARADOWNEXTEND 2414
|
||||
#define SCI_PARAUP 2415
|
||||
#define SCI_PARAUPEXTEND 2416
|
||||
#define SCI_POSITIONBEFORE 2417
|
||||
#define SCI_POSITIONAFTER 2418
|
||||
#define SCI_COPYRANGE 2419
|
||||
#define SCI_COPYTEXT 2420
|
||||
#define SCI_STARTRECORD 3001
|
||||
#define SCI_STOPRECORD 3002
|
||||
#define SCI_SETLEXER 4001
|
||||
#define SCI_GETLEXER 4002
|
||||
#define SCI_COLOURISE 4003
|
||||
#define SCI_SETPROPERTY 4004
|
||||
#define KEYWORDSET_MAX 8
|
||||
#define SCI_SETKEYWORDS 4005
|
||||
#define SCI_SETLEXERLANGUAGE 4006
|
||||
#define SCI_LOADLEXERLIBRARY 4007
|
||||
|
@@ -462,6 +462,7 @@ val INDIC_SQUIGGLE=1
|
||||
val INDIC_TT=2
|
||||
val INDIC_DIAGONAL=3
|
||||
val INDIC_STRIKE=4
|
||||
val INDIC_HIDDEN=5
|
||||
val INDIC0_MASK=0x20
|
||||
val INDIC1_MASK=0x40
|
||||
val INDIC2_MASK=0x80
|
||||
@@ -1231,6 +1232,9 @@ fun void LineEndWrapExtend=2452(,)
|
||||
fun void VCHomeWrap=2453(,)
|
||||
fun void VCHomeWrapExtend=2454(,)
|
||||
|
||||
# Copy the line containing the caret.
|
||||
fun void LineCopy=2455(,)
|
||||
|
||||
# Move the caret inside current view if it's not there already.
|
||||
fun void MoveCaretInsideView=2401(,)
|
||||
|
||||
@@ -1441,6 +1445,20 @@ fun void ParaDownExtend=2414(,)
|
||||
fun void ParaUp=2415(,)
|
||||
fun void ParaUpExtend=2416(,)
|
||||
|
||||
# Given a valid document position, return the previous position taking code
|
||||
# page into account. Returns 0 if passed 0.
|
||||
fun position PositionBefore=2417(position pos,)
|
||||
|
||||
# Given a valid document position, return the next position taking code
|
||||
# page into account. Maximum value returned is the last position in the document.
|
||||
fun position PositionAfter=2418(position pos,)
|
||||
|
||||
# Copy a range of text to the clipboard. Positions are clipped into the document.
|
||||
fun void CopyRange=2419(position start, position end)
|
||||
|
||||
# Copy argument text to the clipboard.
|
||||
fun void CopyText=2420(int length, string text)
|
||||
|
||||
# Start notifying the container of all key presses and commands.
|
||||
fun void StartRecord=3001(,)
|
||||
|
||||
@@ -1459,6 +1477,9 @@ fun void Colourise=4003(position start, position end)
|
||||
# Set up a value that may be used by a lexer for some optional feature.
|
||||
set void SetProperty=4004(string key, string value)
|
||||
|
||||
# Maximum value of keywordSet parameter of SetKeyWords.
|
||||
val KEYWORDSET_MAX=8
|
||||
|
||||
# Set up the key words used by the lexer.
|
||||
set void SetKeyWords=4005(int keywordSet, string keyWords)
|
||||
|
||||
@@ -1466,7 +1487,6 @@ set void SetKeyWords=4005(int keywordSet, string keyWords)
|
||||
set void SetLexerLanguage=4006(, string language)
|
||||
|
||||
# Load a lexer library (dll / so)
|
||||
# NOT YET IMPLEMENTED
|
||||
fun void LoadLexerLibrary=4007(, string path)
|
||||
|
||||
# Notifications
|
||||
@@ -1566,6 +1586,11 @@ val SCLEX_FORTRAN=36
|
||||
val SCLEX_F77=37
|
||||
val SCLEX_CSS=38
|
||||
val SCLEX_POV=39
|
||||
val SCLEX_LOUT=40
|
||||
val SCLEX_ESCRIPT=41
|
||||
val SCLEX_PS=42
|
||||
val SCLEX_NSIS=43
|
||||
val SCLEX_MMIXAL=44
|
||||
|
||||
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
|
||||
# value assigned in sequence from SCLEX_AUTOMATIC+1.
|
||||
@@ -1612,6 +1637,7 @@ val SCE_C_COMMENTLINEDOC=15
|
||||
val SCE_C_WORD2=16
|
||||
val SCE_C_COMMENTDOCKEYWORD=17
|
||||
val SCE_C_COMMENTDOCKEYWORDERROR=18
|
||||
val SCE_C_GLOBALCLASS=19
|
||||
# Lexical states for SCLEX_HTML, SCLEX_XML
|
||||
lex HTML=SCLEX_HTML SCE_H
|
||||
lex XML=SCLEX_XML SCE_H
|
||||
@@ -1816,6 +1842,8 @@ val SCE_LUA_WORD3=14
|
||||
val SCE_LUA_WORD4=15
|
||||
val SCE_LUA_WORD5=16
|
||||
val SCE_LUA_WORD6=17
|
||||
val SCE_LUA_WORD7=18
|
||||
val SCE_LUA_WORD8=19
|
||||
# Lexical states for SCLEX_ERRORLIST
|
||||
lex ErrorList=SCLEX_ERRORLIST SCE_ERR_
|
||||
val SCE_ERR_DEFAULT=0
|
||||
@@ -2039,14 +2067,102 @@ lex POV=SCLEX_POV SCE_POV_
|
||||
val SCE_POV_DEFAULT=0
|
||||
val SCE_POV_COMMENT=1
|
||||
val SCE_POV_COMMENTLINE=2
|
||||
val SCE_POV_COMMENTDOC=3
|
||||
val SCE_POV_NUMBER=4
|
||||
val SCE_POV_WORD=5
|
||||
val SCE_POV_NUMBER=3
|
||||
val SCE_POV_OPERATOR=4
|
||||
val SCE_POV_IDENTIFIER=5
|
||||
val SCE_POV_STRING=6
|
||||
val SCE_POV_OPERATOR=7
|
||||
val SCE_POV_IDENTIFIER=8
|
||||
val SCE_POV_BRACE=9
|
||||
val SCE_POV_STRINGEOL=7
|
||||
val SCE_POV_DIRECTIVE=8
|
||||
val SCE_POV_BADDIRECTIVE=9
|
||||
val SCE_POV_WORD2=10
|
||||
val SCE_POV_WORD3=11
|
||||
val SCE_POV_WORD4=12
|
||||
val SCE_POV_WORD5=13
|
||||
val SCE_POV_WORD6=14
|
||||
val SCE_POV_WORD7=15
|
||||
val SCE_POV_WORD8=16
|
||||
# Lexical states for SCLEX_LOUT
|
||||
lex LOUT=SCLEX_LOUT SCE_LOUT_
|
||||
val SCE_LOUT_DEFAULT=0
|
||||
val SCE_LOUT_COMMENT=1
|
||||
val SCE_LOUT_NUMBER=2
|
||||
val SCE_LOUT_WORD=3
|
||||
val SCE_LOUT_WORD2=4
|
||||
val SCE_LOUT_WORD3=5
|
||||
val SCE_LOUT_WORD4=6
|
||||
val SCE_LOUT_STRING=7
|
||||
val SCE_LOUT_OPERATOR=8
|
||||
val SCE_LOUT_IDENTIFIER=9
|
||||
val SCE_LOUT_STRINGEOL=10
|
||||
# Lexical states for SCLEX_ESCRIPT
|
||||
lex ESCRIPT=SCLEX_ESCRIPT SCE_ESCRIPT_
|
||||
val SCE_ESCRIPT_DEFAULT=0
|
||||
val SCE_ESCRIPT_COMMENT=1
|
||||
val SCE_ESCRIPT_COMMENTLINE=2
|
||||
val SCE_ESCRIPT_COMMENTDOC=3
|
||||
val SCE_ESCRIPT_NUMBER=4
|
||||
val SCE_ESCRIPT_WORD=5
|
||||
val SCE_ESCRIPT_STRING=6
|
||||
val SCE_ESCRIPT_OPERATOR=7
|
||||
val SCE_ESCRIPT_IDENTIFIER=8
|
||||
val SCE_ESCRIPT_BRACE=9
|
||||
val SCE_ESCRIPT_WORD2=10
|
||||
val SCE_ESCRIPT_WORD3=11
|
||||
# Lexical states for SCLEX_PS
|
||||
lex PS=SCLEX_PS SCE_PS_
|
||||
val SCE_PS_DEFAULT=0
|
||||
val SCE_PS_COMMENT=1
|
||||
val SCE_PS_DSC_COMMENT=2
|
||||
val SCE_PS_DSC_VALUE=3
|
||||
val SCE_PS_NUMBER=4
|
||||
val SCE_PS_NAME=5
|
||||
val SCE_PS_KEYWORD=6
|
||||
val SCE_PS_LITERAL=7
|
||||
val SCE_PS_IMMEVAL=8
|
||||
val SCE_PS_PAREN_ARRAY=9
|
||||
val SCE_PS_PAREN_DICT=10
|
||||
val SCE_PS_PAREN_PROC=11
|
||||
val SCE_PS_TEXT=12
|
||||
val SCE_PS_HEXSTRING=13
|
||||
val SCE_PS_BASE85STRING=14
|
||||
val SCE_PS_BADSTRINGCHAR=15
|
||||
# Lexical states for SCLEX_NSIS
|
||||
lex NSIS=SCLEX_NSIS SCE_NSIS_
|
||||
val SCE_NSIS_DEFAULT=0
|
||||
val SCE_NSIS_COMMENT=1
|
||||
val SCE_NSIS_STRINGDQ=2
|
||||
val SCE_NSIS_STRINGLQ=3
|
||||
val SCE_NSIS_STRINGRQ=4
|
||||
val SCE_NSIS_FUNCTION=5
|
||||
val SCE_NSIS_VARIABLE=6
|
||||
val SCE_NSIS_LABEL=7
|
||||
val SCE_NSIS_USERDEFINED=8
|
||||
val SCE_NSIS_SECTIONDEF=9
|
||||
val SCE_NSIS_SUBSECTIONDEF=10
|
||||
val SCE_NSIS_IFDEFINEDEF=11
|
||||
val SCE_NSIS_MACRODEF=12
|
||||
val SCE_NSIS_STRINGVAR=13
|
||||
# Lexical states for SCLEX_MMIXAL
|
||||
lex MMIXAL=SCLEX_MMIXAL SCE_MMIXAL_
|
||||
val SCE_MMIXAL_LEADWS=0
|
||||
val SCE_MMIXAL_COMMENT=1
|
||||
val SCE_MMIXAL_LABEL=2
|
||||
val SCE_MMIXAL_OPCODE=3
|
||||
val SCE_MMIXAL_OPCODE_PRE=4
|
||||
val SCE_MMIXAL_OPCODE_VALID=5
|
||||
val SCE_MMIXAL_OPCODE_UNKNOWN=6
|
||||
val SCE_MMIXAL_OPCODE_POST=7
|
||||
val SCE_MMIXAL_OPERANDS=8
|
||||
val SCE_MMIXAL_NUMBER=9
|
||||
val SCE_MMIXAL_REF=10
|
||||
val SCE_MMIXAL_CHAR=11
|
||||
val SCE_MMIXAL_STRING=12
|
||||
val SCE_MMIXAL_REGISTER=13
|
||||
val SCE_MMIXAL_HEX=14
|
||||
val SCE_MMIXAL_OPERATOR=15
|
||||
val SCE_MMIXAL_SYMBOL=16
|
||||
val SCE_MMIXAL_INCLUDE=17
|
||||
|
||||
# Events
|
||||
|
||||
evt void StyleNeeded=2000(int position)
|
||||
|
@@ -26,8 +26,8 @@ protected:
|
||||
bool InternalIsLeadByte(char ch);
|
||||
void Fill(int position);
|
||||
public:
|
||||
WindowAccessor(WindowID id_, PropSet &props_) :
|
||||
Accessor(), id(id_), props(props_),
|
||||
WindowAccessor(WindowID id_, PropSet &props_) :
|
||||
Accessor(), id(id_), props(props_),
|
||||
lenDoc(-1), validLen(0), chFlags(0), chWhile(0) {
|
||||
}
|
||||
~WindowAccessor();
|
||||
@@ -40,8 +40,8 @@ public:
|
||||
void Flush();
|
||||
int GetLineState(int line);
|
||||
int SetLineState(int line, int state);
|
||||
int GetPropertyInt(const char *key, int defaultValue=0) {
|
||||
return props.GetInt(key, defaultValue);
|
||||
int GetPropertyInt(const char *key, int defaultValue=0) {
|
||||
return props.GetInt(key, defaultValue);
|
||||
}
|
||||
char *GetProperties() {
|
||||
return props.ToString();
|
||||
|
@@ -103,9 +103,9 @@ void MarkerHandleSet::RemoveNumber(int markerNum) {
|
||||
if (mhn->number == markerNum) {
|
||||
*pmhn = mhn->next;
|
||||
delete mhn;
|
||||
return ;
|
||||
} else {
|
||||
pmhn = &((*pmhn)->next);
|
||||
}
|
||||
pmhn = &((*pmhn)->next);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -212,7 +212,7 @@ public:
|
||||
int GetMark(int line);
|
||||
void DeleteAllMarks(int markerNum);
|
||||
int LineFromHandle(int markerHandle);
|
||||
|
||||
|
||||
/// Actions without undo
|
||||
void BasicInsertString(int position, char *s, int insertLength);
|
||||
void BasicDeleteChars(int position, int deleteLength);
|
||||
|
@@ -265,7 +265,7 @@ int Document::LenChar(int pos) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
#include <assert.h>
|
||||
// Normalise a position so that it is not halfway through a two byte character.
|
||||
// This can occur in two situations -
|
||||
// When lines are terminated with \r\n pairs which should be treated as one character.
|
||||
@@ -273,17 +273,11 @@ int Document::LenChar(int pos) {
|
||||
// If moving, move the position in the indicated direction.
|
||||
int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
|
||||
//Platform::DebugPrintf("NoCRLF %d %d\n", pos, moveDir);
|
||||
// If out of range, just return value - should be fixed up after
|
||||
if (pos < 0)
|
||||
return pos;
|
||||
if (pos > Length())
|
||||
return pos;
|
||||
|
||||
// Position 0 and Length() can not be between any two characters
|
||||
if (pos == 0)
|
||||
return pos;
|
||||
if (pos == Length())
|
||||
return pos;
|
||||
// If out of range, just return minimum/maximum value.
|
||||
if (pos <= 0)
|
||||
return 0;
|
||||
if (pos >= Length())
|
||||
return Length();
|
||||
|
||||
// assert pos > 0 && pos < Length()
|
||||
if (checkLineEnd && IsCrLf(pos - 1)) {
|
||||
@@ -309,29 +303,26 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
|
||||
} else {
|
||||
// Anchor DBCS calculations at start of line because start of line can
|
||||
// not be a DBCS trail byte.
|
||||
int startLine = pos;
|
||||
|
||||
while (startLine > 0 && cb.CharAt(startLine) != '\r' && cb.CharAt(startLine) != '\n')
|
||||
startLine--;
|
||||
while (startLine < pos) {
|
||||
int posCheck = LineStart(LineFromPosition(pos));
|
||||
while (posCheck < pos) {
|
||||
char mbstr[maxBytesInDBCSCharacter+1];
|
||||
int i;
|
||||
for(i=0;i<Platform::DBCSCharMaxLength();i++) {
|
||||
mbstr[i] = cb.CharAt(startLine+i);
|
||||
mbstr[i] = cb.CharAt(posCheck+i);
|
||||
}
|
||||
mbstr[i] = '\0';
|
||||
|
||||
int mbsize = Platform::DBCSCharLength(dbcsCodePage, mbstr);
|
||||
if (startLine + mbsize == pos) {
|
||||
if (posCheck + mbsize == pos) {
|
||||
return pos;
|
||||
} else if (startLine + mbsize > pos) {
|
||||
} else if (posCheck + mbsize > pos) {
|
||||
if (moveDir > 0) {
|
||||
return startLine + mbsize;
|
||||
return posCheck + mbsize;
|
||||
} else {
|
||||
return startLine;
|
||||
return posCheck;
|
||||
}
|
||||
}
|
||||
startLine += mbsize;
|
||||
posCheck += mbsize;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -403,7 +394,7 @@ bool Document::InsertStyledString(int position, char *s, int insertLength) {
|
||||
DocModification(
|
||||
SC_MOD_BEFOREINSERT | SC_PERFORMED_USER,
|
||||
position / 2, insertLength / 2,
|
||||
0, 0));
|
||||
0, s));
|
||||
int prevLinesTotal = LinesTotal();
|
||||
bool startSavePoint = cb.IsSavePoint();
|
||||
const char *text = cb.InsertString(position, s, insertLength);
|
||||
@@ -935,7 +926,7 @@ long Document::FindText(int minPos, int maxPos, const char *s,
|
||||
if (line == lineRangeStart) {
|
||||
if ((startPos != endOfLine) && (searchEnd == '$'))
|
||||
continue; // Can't match end of line if start position before end of line
|
||||
endOfLine = startPos;
|
||||
endOfLine = startPos+1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -947,10 +938,10 @@ long Document::FindText(int minPos, int maxPos, const char *s,
|
||||
if (increment == -1) {
|
||||
// Check for the last match on this line.
|
||||
int repetitions = 1000; // Break out of infinite loop
|
||||
while (success && (pre->eopat[0] < endOfLine) && (repetitions--)) {
|
||||
success = pre->Execute(di, pre->eopat[0], endOfLine);
|
||||
while (success && (pre->eopat[0] <= (endOfLine+1)) && (repetitions--)) {
|
||||
success = pre->Execute(di, pos+1, endOfLine+1);
|
||||
if (success) {
|
||||
if (pre->eopat[0] <= minPos) {
|
||||
if (pre->eopat[0] <= (minPos+1)) {
|
||||
pos = pre->bopat[0];
|
||||
lenRet = pre->eopat[0] - pre->bopat[0];
|
||||
} else {
|
||||
|
@@ -130,8 +130,8 @@ void DocumentAccessor::Flush() {
|
||||
lenDoc = -1;
|
||||
if (validLen > 0) {
|
||||
pdoc->SetStyles(validLen, styleBuf);
|
||||
validLen = 0;
|
||||
startPosStyling += validLen;
|
||||
validLen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -32,9 +32,9 @@ protected:
|
||||
void Fill(int position);
|
||||
|
||||
public:
|
||||
DocumentAccessor(Document *pdoc_, PropSet &props_, WindowID id_=0) :
|
||||
DocumentAccessor(Document *pdoc_, PropSet &props_, WindowID id_=0) :
|
||||
Accessor(), pdoc(pdoc_), props(props_), id(id_),
|
||||
lenDoc(-1), validLen(0), chFlags(0), chWhile(0),
|
||||
lenDoc(-1), validLen(0), chFlags(0), chWhile(0),
|
||||
startSeg(0), startPosStyling(0) {
|
||||
}
|
||||
~DocumentAccessor();
|
||||
@@ -47,8 +47,8 @@ public:
|
||||
void Flush();
|
||||
int GetLineState(int line);
|
||||
int SetLineState(int line, int state);
|
||||
int GetPropertyInt(const char *key, int defaultValue=0) {
|
||||
return props.GetInt(key, defaultValue);
|
||||
int GetPropertyInt(const char *key, int defaultValue=0) {
|
||||
return props.GetInt(key, defaultValue);
|
||||
}
|
||||
char *GetProperties() {
|
||||
return props.ToString();
|
||||
|
@@ -711,7 +711,9 @@ void Editor::RedrawRect(PRectangle rc) {
|
||||
|
||||
void Editor::Redraw() {
|
||||
//Platform::DebugPrintf("Redraw all\n");
|
||||
wMain.InvalidateAll();
|
||||
PRectangle rcClient = GetClientRectangle();
|
||||
wMain.InvalidateRectangle(rcClient);
|
||||
//wMain.InvalidateAll();
|
||||
}
|
||||
|
||||
void Editor::RedrawSelMargin() {
|
||||
@@ -1412,7 +1414,7 @@ void Editor::LinesSplit(int pixelWidth) {
|
||||
for (int subLine = 1; subLine < ll->lines; subLine++) {
|
||||
pdoc->InsertString(posLineStart + (subLine - 1) * strlen(eol) +
|
||||
ll->LineStart(subLine), eol);
|
||||
targetEnd += strlen(eol);
|
||||
targetEnd += static_cast<int>(strlen(eol));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1426,6 +1428,12 @@ int Editor::SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) {
|
||||
return markerCheck;
|
||||
}
|
||||
|
||||
// Avoid 64 bit compiler warnings.
|
||||
// Scintilla does not support text buffers larger than 2**31
|
||||
static int istrlen(const char *s) {
|
||||
return static_cast<int>(strlen(s));
|
||||
}
|
||||
|
||||
void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
|
||||
if (vs.fixedColumnWidth == 0)
|
||||
return;
|
||||
@@ -1576,15 +1584,22 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
|
||||
number[0] = '\0';
|
||||
if (firstSubLine)
|
||||
sprintf(number, "%d", lineDoc + 1);
|
||||
if (foldFlags & SC_FOLDFLAG_LEVELNUMBERS)
|
||||
sprintf(number, "%X", pdoc->GetLevel(lineDoc));
|
||||
if (foldFlags & SC_FOLDFLAG_LEVELNUMBERS) {
|
||||
int lev = pdoc->GetLevel(lineDoc);
|
||||
sprintf(number, "%c%c %03X %03X",
|
||||
(lev & SC_FOLDLEVELHEADERFLAG) ? 'H' : '_',
|
||||
(lev & SC_FOLDLEVELWHITEFLAG) ? 'W' : '_',
|
||||
lev & SC_FOLDLEVELNUMBERMASK,
|
||||
lev >> 16
|
||||
);
|
||||
}
|
||||
PRectangle rcNumber = rcMarker;
|
||||
// Right justify
|
||||
int width = surface->WidthText(vs.styles[STYLE_LINENUMBER].font, number, strlen(number));
|
||||
int width = surface->WidthText(vs.styles[STYLE_LINENUMBER].font, number, istrlen(number));
|
||||
int xpos = rcNumber.right - width - 3;
|
||||
rcNumber.left = xpos;
|
||||
surface->DrawTextNoClip(rcNumber, vs.styles[STYLE_LINENUMBER].font,
|
||||
rcNumber.top + vs.maxAscent, number, strlen(number),
|
||||
rcNumber.top + vs.maxAscent, number, istrlen(number),
|
||||
vs.styles[STYLE_LINENUMBER].fore.allocated,
|
||||
vs.styles[STYLE_LINENUMBER].back.allocated);
|
||||
}
|
||||
@@ -1761,7 +1776,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
|
||||
} else if (controlCharSymbol < 32) {
|
||||
const char *ctrlChar = ControlCharacterString(ll->chars[charInLine]);
|
||||
// +3 For a blank on front and rounded edge each side:
|
||||
ll->positions[charInLine + 1] = surface->WidthText(ctrlCharsFont, ctrlChar, strlen(ctrlChar)) + 3;
|
||||
ll->positions[charInLine + 1] = surface->WidthText(ctrlCharsFont, ctrlChar, istrlen(ctrlChar)) + 3;
|
||||
} else {
|
||||
char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
|
||||
surface->MeasureWidths(ctrlCharsFont, cc, 1,
|
||||
@@ -2126,7 +2141,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
|
||||
rcChar.left++;
|
||||
rcChar.right--;
|
||||
surface->DrawTextClipped(rcChar, ctrlCharsFont,
|
||||
rcSegment.top + vsDraw.maxAscent, ctrlChar, strlen(ctrlChar),
|
||||
rcSegment.top + vsDraw.maxAscent, ctrlChar, istrlen(ctrlChar),
|
||||
textBack, textFore);
|
||||
} else {
|
||||
char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
|
||||
@@ -2351,7 +2366,9 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
|
||||
if (AbandonPaint()) {
|
||||
return;
|
||||
}
|
||||
RefreshPixMaps(surfaceWindow); // In case pixmaps invalidated by scrollbar change
|
||||
}
|
||||
PLATFORM_ASSERT(pixmapSelPattern->Initialised());
|
||||
|
||||
PRectangle rcRightMargin = rcClient;
|
||||
rcRightMargin.left = rcRightMargin.right - vs.rightMarginWidth;
|
||||
@@ -2380,6 +2397,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
|
||||
Surface *surface = surfaceWindow;
|
||||
if (bufferedDraw) {
|
||||
surface = pixmapLine;
|
||||
PLATFORM_ASSERT(pixmapLine->Initialised());
|
||||
}
|
||||
surface->SetUnicodeMode(IsUnicodeMode());
|
||||
surface->SetDBCSMode(CodePage());
|
||||
@@ -2476,7 +2494,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
|
||||
} else {
|
||||
int FoldLevelCurr = (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELNUMBERMASK) - SC_FOLDLEVELBASE;
|
||||
int FoldLevelPrev = (pdoc->GetLevel(lineDoc - 1) & SC_FOLDLEVELNUMBERMASK) - SC_FOLDLEVELBASE;
|
||||
int FoldLevelFlags = (pdoc->GetLevel(lineDoc) & ~SC_FOLDLEVELNUMBERMASK);
|
||||
int FoldLevelFlags = (pdoc->GetLevel(lineDoc) & ~SC_FOLDLEVELNUMBERMASK) & ~(0xFFF0000);
|
||||
int indentationStep = (pdoc->indentInChars ? pdoc->indentInChars : pdoc->tabInChars);
|
||||
// Draw line above fold
|
||||
if ((FoldLevelPrev < FoldLevelCurr)
|
||||
@@ -2671,7 +2689,7 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) {
|
||||
int lineNumberWidth = 0;
|
||||
if (lineNumberIndex >= 0) {
|
||||
lineNumberWidth = surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font,
|
||||
"99999" lineNumberPrintSpace, 5 + strlen(lineNumberPrintSpace));
|
||||
"99999" lineNumberPrintSpace, 5 + istrlen(lineNumberPrintSpace));
|
||||
vsPrint.ms[lineNumberIndex].width = lineNumberWidth;
|
||||
}
|
||||
|
||||
@@ -2751,10 +2769,10 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) {
|
||||
rcNumber.right = rcNumber.left + lineNumberWidth;
|
||||
// Right justify
|
||||
rcNumber.left -= surfaceMeasure->WidthText(
|
||||
vsPrint.styles[STYLE_LINENUMBER].font, number, strlen(number));
|
||||
vsPrint.styles[STYLE_LINENUMBER].font, number, istrlen(number));
|
||||
surface->FlushCachedState();
|
||||
surface->DrawTextNoClip(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font,
|
||||
ypos + vsPrint.maxAscent, number, strlen(number),
|
||||
ypos + vsPrint.maxAscent, number, istrlen(number),
|
||||
vsPrint.styles[STYLE_LINENUMBER].fore.allocated,
|
||||
vsPrint.styles[STYLE_LINENUMBER].back.allocated);
|
||||
}
|
||||
@@ -2790,7 +2808,7 @@ int Editor::TextWidth(int style, const char *text) {
|
||||
RefreshStyleData();
|
||||
AutoSurface surface(this);
|
||||
if (surface) {
|
||||
return surface->WidthText(vs.styles[style].font, text, strlen(text));
|
||||
return surface->WidthText(vs.styles[style].font, text, istrlen(text));
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
@@ -3432,6 +3450,7 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long
|
||||
case SCI_DELWORDRIGHT:
|
||||
case SCI_DELLINELEFT:
|
||||
case SCI_DELLINERIGHT:
|
||||
case SCI_LINECOPY:
|
||||
case SCI_LINECUT:
|
||||
case SCI_LINEDELETE:
|
||||
case SCI_LINETRANSPOSE:
|
||||
@@ -3543,7 +3562,7 @@ void Editor::LineDuplicate() {
|
||||
char *thisLine = CopyRange(start, end);
|
||||
const char *eol = StringFromEOLMode(pdoc->eolMode);
|
||||
pdoc->InsertString(end, eol);
|
||||
pdoc->InsertString(end + strlen(eol), thisLine, end - start);
|
||||
pdoc->InsertString(end + istrlen(eol), thisLine, end - start);
|
||||
delete []thisLine;
|
||||
}
|
||||
|
||||
@@ -3558,7 +3577,7 @@ void Editor::NewLine() {
|
||||
eol = "\r";
|
||||
} // else SC_EOL_LF -> "\n" already set
|
||||
if (pdoc->InsertString(currentPos, eol)) {
|
||||
SetEmptySelection(currentPos + strlen(eol));
|
||||
SetEmptySelection(currentPos + istrlen(eol));
|
||||
while (*eol) {
|
||||
NotifyChar(*eol);
|
||||
eol++;
|
||||
@@ -3870,18 +3889,21 @@ int Editor::KeyCommand(unsigned int iMessage) {
|
||||
pdoc->DeleteChars(currentPos, end - currentPos);
|
||||
}
|
||||
break;
|
||||
case SCI_LINECOPY: {
|
||||
int lineStart = pdoc->LineFromPosition(SelectionStart());
|
||||
int lineEnd = pdoc->LineFromPosition(SelectionEnd());
|
||||
CopyRangeToClipboard(pdoc->LineStart(lineStart),
|
||||
pdoc->LineStart(lineEnd + 1));
|
||||
}
|
||||
break;
|
||||
case SCI_LINECUT: {
|
||||
int lineStart = pdoc->LineFromPosition(currentPos);
|
||||
int lineEnd = pdoc->LineFromPosition(anchor);
|
||||
if (lineStart > lineEnd) {
|
||||
int t = lineEnd;
|
||||
lineEnd = lineStart;
|
||||
lineStart = t;
|
||||
}
|
||||
int lineStart = pdoc->LineFromPosition(SelectionStart());
|
||||
int lineEnd = pdoc->LineFromPosition(SelectionEnd());
|
||||
int start = pdoc->LineStart(lineStart);
|
||||
int end = pdoc->LineStart(lineEnd + 1);
|
||||
SetSelection(start, end);
|
||||
Cut();
|
||||
SetLastXChosen();
|
||||
}
|
||||
break;
|
||||
case SCI_LINEDELETE: {
|
||||
@@ -4056,7 +4078,7 @@ long Editor::FindText(
|
||||
sptr_t lParam) { ///< @c TextToFind structure: The text to search for in the given range.
|
||||
|
||||
TextToFind *ft = reinterpret_cast<TextToFind *>(lParam);
|
||||
int lengthFound = strlen(ft->lpstrText);
|
||||
int lengthFound = istrlen(ft->lpstrText);
|
||||
int pos = pdoc->FindText(ft->chrg.cpMin, ft->chrg.cpMax, ft->lpstrText,
|
||||
(wParam & SCFIND_MATCHCASE) != 0,
|
||||
(wParam & SCFIND_WHOLEWORD) != 0,
|
||||
@@ -4099,7 +4121,7 @@ long Editor::SearchText(
|
||||
|
||||
const char *txt = reinterpret_cast<char *>(lParam);
|
||||
int pos;
|
||||
int lengthFound = strlen(txt);
|
||||
int lengthFound = istrlen(txt);
|
||||
if (iMessage == SCI_SEARCHNEXT) {
|
||||
pos = pdoc->FindText(searchAnchor, pdoc->Length(), txt,
|
||||
(wParam & SCFIND_MATCHCASE) != 0,
|
||||
@@ -4178,10 +4200,14 @@ char *Editor::CopyRange(int start, int end) {
|
||||
return text;
|
||||
}
|
||||
|
||||
void Editor::CopySelectionFromRange(SelectionText *ss, int start, int end) {
|
||||
ss->Set(CopyRange(start, end), end - start + 1, false);
|
||||
}
|
||||
|
||||
void Editor::CopySelectionRange(SelectionText *ss) {
|
||||
char *text = 0;
|
||||
int size = 0;
|
||||
if (selType == selRectangle) {
|
||||
char *text = 0;
|
||||
int size = 0;
|
||||
int lineStart = pdoc->LineFromPosition(SelectionStart());
|
||||
int lineEnd = pdoc->LineFromPosition(SelectionEnd());
|
||||
int line;
|
||||
@@ -4206,11 +4232,24 @@ void Editor::CopySelectionRange(SelectionText *ss) {
|
||||
text[size] = '\0';
|
||||
}
|
||||
}
|
||||
ss->Set(text, size + 1, true);
|
||||
} else {
|
||||
size = SelectionEnd() - SelectionStart();
|
||||
text = CopyRange(SelectionStart(), SelectionEnd());
|
||||
CopySelectionFromRange(ss, SelectionStart(), SelectionEnd());
|
||||
}
|
||||
ss->Set(text, size, selType == selRectangle);
|
||||
}
|
||||
|
||||
void Editor::CopyRangeToClipboard(int start, int end) {
|
||||
start = pdoc->ClampPositionIntoDocument(start);
|
||||
end = pdoc->ClampPositionIntoDocument(end);
|
||||
SelectionText selectedText;
|
||||
selectedText.Set(CopyRange(start, end), end - start + 1);
|
||||
CopyToClipboard(selectedText);
|
||||
}
|
||||
|
||||
void Editor::CopyText(int length, const char *text) {
|
||||
SelectionText selectedText;
|
||||
selectedText.Copy(text, length);
|
||||
CopyToClipboard(selectedText);
|
||||
}
|
||||
|
||||
void Editor::SetDragPosition(int newPos) {
|
||||
@@ -4285,14 +4324,14 @@ void Editor::DropAt(int position, const char *value, bool moving, bool rectangul
|
||||
position = positionAfterDeletion;
|
||||
|
||||
if (rectangular) {
|
||||
PasteRectangular(position, value, strlen(value));
|
||||
PasteRectangular(position, value, istrlen(value));
|
||||
pdoc->EndUndoAction();
|
||||
// Should try to select new rectangle but it may not be a rectangle now so just select the drop position
|
||||
SetSelection(position, position);
|
||||
} else {
|
||||
position = MovePositionOutsideChar(position, currentPos - position);
|
||||
if (pdoc->InsertString(position, value)) {
|
||||
SetSelection(position + strlen(value), position);
|
||||
SetSelection(position + istrlen(value), position);
|
||||
}
|
||||
pdoc->EndUndoAction();
|
||||
}
|
||||
@@ -4872,10 +4911,7 @@ void Editor::SetDocPointer(Document *document) {
|
||||
|
||||
pdoc->AddWatcher(this, 0);
|
||||
Redraw();
|
||||
// Removed because of reentrance problems of GTK+ 2.x
|
||||
// where changing a scroll bar position causes synchronous
|
||||
// painting before lexer and styling state is set up.
|
||||
//SetScrollBars();
|
||||
SetScrollBars();
|
||||
}
|
||||
|
||||
// Recursively expand a fold, making lines visible except where they have an unexpanded parent
|
||||
@@ -4963,7 +4999,7 @@ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) {
|
||||
int Editor::ReplaceTarget(bool replacePatterns, const char *text, int length) {
|
||||
pdoc->BeginUndoAction();
|
||||
if (length == -1)
|
||||
length = strlen(text);
|
||||
length = istrlen(text);
|
||||
if (replacePatterns) {
|
||||
text = pdoc->SubstituteByPosition(text, &length);
|
||||
if (!text)
|
||||
@@ -5040,6 +5076,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
Copy();
|
||||
break;
|
||||
|
||||
case SCI_COPYRANGE:
|
||||
CopyRangeToClipboard(wParam, lParam);
|
||||
break;
|
||||
|
||||
case SCI_COPYTEXT:
|
||||
CopyText(wParam, CharPtrFromSPtr(lParam));
|
||||
break;
|
||||
|
||||
case SCI_PASTE:
|
||||
Paste();
|
||||
SetLastXChosen();
|
||||
@@ -5151,7 +5195,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
char *replacement = CharPtrFromSPtr(lParam);
|
||||
pdoc->InsertString(currentPos, replacement);
|
||||
pdoc->EndUndoAction();
|
||||
SetEmptySelection(currentPos + strlen(replacement));
|
||||
SetEmptySelection(currentPos + istrlen(replacement));
|
||||
EnsureCaretVisible();
|
||||
}
|
||||
break;
|
||||
@@ -5199,6 +5243,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
case SCI_GETSEARCHFLAGS:
|
||||
return searchFlags;
|
||||
|
||||
case SCI_POSITIONBEFORE:
|
||||
return pdoc->MovePositionOutsideChar(wParam-1, -1, true);
|
||||
|
||||
case SCI_POSITIONAFTER:
|
||||
return pdoc->MovePositionOutsideChar(wParam+1, 1, true);
|
||||
|
||||
case SCI_LINESCROLL:
|
||||
ScrollTo(topLine + lParam);
|
||||
HorizontalScrollTo(xOffset + wParam * vs.spaceWidth);
|
||||
@@ -5316,7 +5366,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
char *sz = CharPtrFromSPtr(lParam);
|
||||
pdoc->InsertString(insertPos, sz);
|
||||
if (newCurrent > insertPos)
|
||||
newCurrent += strlen(sz);
|
||||
newCurrent += istrlen(sz);
|
||||
SetEmptySelection(newCurrent);
|
||||
return 0;
|
||||
}
|
||||
@@ -6175,6 +6225,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
case SCI_DELWORDRIGHT:
|
||||
case SCI_DELLINELEFT:
|
||||
case SCI_DELLINERIGHT:
|
||||
case SCI_LINECOPY:
|
||||
case SCI_LINECUT:
|
||||
case SCI_LINEDELETE:
|
||||
case SCI_LINETRANSPOSE:
|
||||
|
@@ -133,6 +133,19 @@ public:
|
||||
len = 0;
|
||||
rectangular = rectangular_;
|
||||
}
|
||||
void Copy(const char *s_, int len_, bool rectangular_=false) {
|
||||
delete []s;
|
||||
s = new char[len_];
|
||||
if (s) {
|
||||
len = len_;
|
||||
for (int i = 0; i < len_; i++) {
|
||||
s[i] = s_[i];
|
||||
}
|
||||
} else {
|
||||
len = 0;
|
||||
}
|
||||
rectangular = rectangular_;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -416,10 +429,14 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
long SearchInTarget(const char *text, int length);
|
||||
void GoToLine(int lineNo);
|
||||
|
||||
virtual void CopyToClipboard(const SelectionText &selectedText) = 0;
|
||||
char *CopyRange(int start, int end);
|
||||
void CopySelectionFromRange(SelectionText *ss, int start, int end);
|
||||
void CopySelectionRange(SelectionText *ss);
|
||||
void CopyRangeToClipboard(int start, int end);
|
||||
void CopyText(int length, const char *text);
|
||||
void SetDragPosition(int newPos);
|
||||
void DisplayCursor(Window::Cursor c);
|
||||
virtual void DisplayCursor(Window::Cursor c);
|
||||
virtual void StartDrag();
|
||||
void DropAt(int position, const char *value, bool moving, bool rectangular);
|
||||
/** PositionInSelection returns 0 if position in selection, -1 if position before selection, and 1 if after.
|
||||
|
256
contrib/src/stc/scintilla/src/ExternalLexer.cxx
Normal file
256
contrib/src/stc/scintilla/src/ExternalLexer.cxx
Normal file
@@ -0,0 +1,256 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file ExternalLexer.cxx
|
||||
** Support external lexers in DLLs.
|
||||
**/
|
||||
// Copyright 2001 Simon Steele <ss@pnotepad.org>, portions copyright Neil Hodgson.
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "SciLexer.h"
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "DocumentAccessor.h"
|
||||
#include "KeyWords.h"
|
||||
#include "ExternalLexer.h"
|
||||
|
||||
LexerManager *LexerManager::theInstance = NULL;
|
||||
|
||||
//------------------------------------------
|
||||
//
|
||||
// ExternalLexerModule
|
||||
//
|
||||
//------------------------------------------
|
||||
|
||||
char **WordListsToStrings(WordList *val[]) {
|
||||
int dim = 0;
|
||||
while (val[dim])
|
||||
dim++;
|
||||
char **wls = new char * [dim + 1];
|
||||
for (int i = 0;i < dim;i++) {
|
||||
SString words;
|
||||
words = "";
|
||||
for (int n = 0; n < val[i]->len; n++) {
|
||||
words += val[i]->words[n];
|
||||
if (n != val[i]->len - 1)
|
||||
words += " ";
|
||||
}
|
||||
wls[i] = new char[words.length() + 1];
|
||||
strcpy(wls[i], words.c_str());
|
||||
}
|
||||
wls[dim] = 0;
|
||||
return wls;
|
||||
}
|
||||
|
||||
void DeleteWLStrings(char *strs[]) {
|
||||
int dim = 0;
|
||||
while (strs[dim]) {
|
||||
delete strs[dim];
|
||||
dim++;
|
||||
}
|
||||
delete [] strs;
|
||||
}
|
||||
|
||||
void ExternalLexerModule::Lex(unsigned int startPos, int lengthDoc, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) const {
|
||||
if (!fneLexer)
|
||||
return ;
|
||||
|
||||
char **kwds = WordListsToStrings(keywordlists);
|
||||
char *ps = styler.GetProperties();
|
||||
|
||||
// The accessor passed in is always a DocumentAccessor so this cast and the subsequent
|
||||
// access will work. Can not use the stricter dynamic_cast as that requires RTTI.
|
||||
DocumentAccessor &da = static_cast<DocumentAccessor &>(styler);
|
||||
WindowID wID = da.GetWindow();
|
||||
|
||||
fneLexer(externalLanguage, startPos, lengthDoc, initStyle, kwds, wID, ps);
|
||||
|
||||
delete ps;
|
||||
DeleteWLStrings(kwds);
|
||||
}
|
||||
|
||||
void ExternalLexerModule::Fold(unsigned int startPos, int lengthDoc, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) const {
|
||||
if (!fneFolder)
|
||||
return ;
|
||||
|
||||
char **kwds = WordListsToStrings(keywordlists);
|
||||
char *ps = styler.GetProperties();
|
||||
|
||||
// The accessor passed in is always a DocumentAccessor so this cast and the subsequent
|
||||
// access will work. Can not use the stricter dynamic_cast as that requires RTTI.
|
||||
DocumentAccessor &da = static_cast<DocumentAccessor &>(styler);
|
||||
WindowID wID = da.GetWindow();
|
||||
|
||||
fneFolder(externalLanguage, startPos, lengthDoc, initStyle, kwds, wID, ps);
|
||||
|
||||
delete ps;
|
||||
DeleteWLStrings(kwds);
|
||||
}
|
||||
|
||||
void ExternalLexerModule::SetExternal(ExtLexerFunction fLexer, ExtFoldFunction fFolder, int index) {
|
||||
fneLexer = fLexer;
|
||||
fneFolder = fFolder;
|
||||
externalLanguage = index;
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
//
|
||||
// LexerLibrary
|
||||
//
|
||||
//------------------------------------------
|
||||
|
||||
LexerLibrary::LexerLibrary(const char* ModuleName) {
|
||||
// Initialise some members...
|
||||
first = NULL;
|
||||
last = NULL;
|
||||
|
||||
// Load the DLL
|
||||
lib = DynamicLibrary::Load(ModuleName);
|
||||
if (lib->IsValid()) {
|
||||
m_sModuleName = ModuleName;
|
||||
//Cannot use reinterpret_cast because: ANSI C++ forbids casting between pointers to functions and objects
|
||||
GetLexerCountFn GetLexerCount = (GetLexerCountFn)lib->FindFunction("GetLexerCount");
|
||||
|
||||
if (GetLexerCount) {
|
||||
ExternalLexerModule *lex;
|
||||
LexerMinder *lm;
|
||||
|
||||
// Find functions in the DLL
|
||||
GetLexerNameFn GetLexerName = (GetLexerNameFn)lib->FindFunction("GetLexerName");
|
||||
ExtLexerFunction Lexer = (ExtLexerFunction)lib->FindFunction("Lex");
|
||||
ExtFoldFunction Folder = (ExtFoldFunction)lib->FindFunction("Fold");
|
||||
|
||||
// Assign a buffer for the lexer name.
|
||||
char lexname[100];
|
||||
strcpy(lexname, "");
|
||||
|
||||
int nl = GetLexerCount();
|
||||
|
||||
for (int i = 0; i < nl; i++) {
|
||||
GetLexerName(i, lexname, 100);
|
||||
lex = new ExternalLexerModule(SCLEX_AUTOMATIC, NULL, lexname, NULL);
|
||||
|
||||
// Create a LexerMinder so we don't leak the ExternalLexerModule...
|
||||
lm = new LexerMinder;
|
||||
lm->self = lex;
|
||||
lm->next = NULL;
|
||||
if (first != NULL) {
|
||||
last->next = lm;
|
||||
last = lm;
|
||||
} else {
|
||||
first = lm;
|
||||
last = lm;
|
||||
}
|
||||
|
||||
// The external lexer needs to know how to call into its DLL to
|
||||
// do its lexing and folding, we tell it here. Folder may be null.
|
||||
lex->SetExternal(Lexer, Folder, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
next = NULL;
|
||||
}
|
||||
|
||||
LexerLibrary::~LexerLibrary() {
|
||||
Release();
|
||||
delete lib;
|
||||
}
|
||||
|
||||
void LexerLibrary::Release() {
|
||||
//TODO maintain a list of lexers created, and delete them!
|
||||
LexerMinder *lm;
|
||||
LexerMinder *next;
|
||||
lm = first;
|
||||
while (NULL != lm) {
|
||||
next = lm->next;
|
||||
delete lm->self;
|
||||
delete lm;
|
||||
lm = next;
|
||||
}
|
||||
|
||||
first = NULL;
|
||||
last = NULL;
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
//
|
||||
// LexerManager
|
||||
//
|
||||
//------------------------------------------
|
||||
|
||||
/// Return the single LexerManager instance...
|
||||
LexerManager *LexerManager::GetInstance() {
|
||||
if(!theInstance)
|
||||
theInstance = new LexerManager;
|
||||
return theInstance;
|
||||
}
|
||||
|
||||
/// Delete any LexerManager instance...
|
||||
void LexerManager::DeleteInstance()
|
||||
{
|
||||
if(theInstance) {
|
||||
delete theInstance;
|
||||
theInstance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/// protected constructor - this is a singleton...
|
||||
LexerManager::LexerManager() {
|
||||
first = NULL;
|
||||
last = NULL;
|
||||
}
|
||||
|
||||
LexerManager::~LexerManager() {
|
||||
Clear();
|
||||
}
|
||||
|
||||
void LexerManager::Load(const char* path)
|
||||
{
|
||||
LoadLexerLibrary(path);
|
||||
}
|
||||
|
||||
void LexerManager::LoadLexerLibrary(const char* module)
|
||||
{
|
||||
LexerLibrary *lib = new LexerLibrary(module);
|
||||
if (NULL != first) {
|
||||
last->next = lib;
|
||||
last = lib;
|
||||
} else {
|
||||
first = lib;
|
||||
last = lib;
|
||||
}
|
||||
}
|
||||
|
||||
void LexerManager::Clear()
|
||||
{
|
||||
if (NULL != first) {
|
||||
LexerLibrary *cur = first;
|
||||
LexerLibrary *next = first->next;
|
||||
while (cur) {
|
||||
delete cur;
|
||||
cur = next;
|
||||
}
|
||||
first = NULL;
|
||||
last = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
//
|
||||
// LexerManager
|
||||
//
|
||||
//------------------------------------------
|
||||
|
||||
LMMinder::~LMMinder()
|
||||
{
|
||||
LexerManager::DeleteInstance();
|
||||
}
|
||||
|
||||
LMMinder minder;
|
95
contrib/src/stc/scintilla/src/ExternalLexer.h
Normal file
95
contrib/src/stc/scintilla/src/ExternalLexer.h
Normal file
@@ -0,0 +1,95 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file ExternalLexer.h
|
||||
** Support external lexers in DLLs.
|
||||
**/
|
||||
// Copyright 2001 Simon Steele <ss@pnotepad.org>, portions copyright Neil Hodgson.
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef EXTERNALLEXER_H
|
||||
#define EXTERNALLEXER_H
|
||||
|
||||
#if PLAT_WIN
|
||||
#define EXT_LEXER_DECL __stdcall
|
||||
#else
|
||||
#define EXT_LEXER_DECL
|
||||
#endif
|
||||
|
||||
// External Lexer function definitions...
|
||||
typedef void (EXT_LEXER_DECL *ExtLexerFunction)(unsigned int lexer, unsigned int startPos, int length, int initStyle,
|
||||
char *words[], WindowID window, char *props);
|
||||
typedef void (EXT_LEXER_DECL *ExtFoldFunction)(unsigned int lexer, unsigned int startPos, int length, int initStyle,
|
||||
char *words[], WindowID window, char *props);
|
||||
typedef void* (EXT_LEXER_DECL *GetLexerFunction)(unsigned int Index);
|
||||
typedef int (EXT_LEXER_DECL *GetLexerCountFn)();
|
||||
typedef void (EXT_LEXER_DECL *GetLexerNameFn)(unsigned int Index, char *name, int buflength);
|
||||
|
||||
//class DynamicLibrary;
|
||||
|
||||
/// Sub-class of LexerModule to use an external lexer.
|
||||
class ExternalLexerModule : protected LexerModule {
|
||||
protected:
|
||||
ExtLexerFunction fneLexer;
|
||||
ExtFoldFunction fneFolder;
|
||||
int externalLanguage;
|
||||
char name[100];
|
||||
public:
|
||||
ExternalLexerModule(int language_, LexerFunction fnLexer_,
|
||||
const char *languageName_=0, LexerFunction fnFolder_=0) : LexerModule(language_, fnLexer_, 0, fnFolder_){
|
||||
strncpy(name, languageName_, sizeof(name));
|
||||
languageName = name;
|
||||
};
|
||||
virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) const;
|
||||
virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) const;
|
||||
virtual void SetExternal(ExtLexerFunction fLexer, ExtFoldFunction fFolder, int index);
|
||||
};
|
||||
|
||||
/// LexerMinder points to an ExternalLexerModule - so we don't leak them.
|
||||
class LexerMinder {
|
||||
public:
|
||||
ExternalLexerModule *self;
|
||||
LexerMinder *next;
|
||||
};
|
||||
|
||||
/// LexerLibrary exists for every External Lexer DLL, contains LexerMinders.
|
||||
class LexerLibrary {
|
||||
DynamicLibrary *lib;
|
||||
LexerMinder *first;
|
||||
LexerMinder *last;
|
||||
|
||||
public:
|
||||
LexerLibrary(const char* ModuleName);
|
||||
~LexerLibrary();
|
||||
void Release();
|
||||
|
||||
LexerLibrary *next;
|
||||
SString m_sModuleName;
|
||||
};
|
||||
|
||||
/// LexerManager manages external lexers, contains LexerLibrarys.
|
||||
class LexerManager {
|
||||
public:
|
||||
~LexerManager();
|
||||
|
||||
static LexerManager *GetInstance();
|
||||
static void DeleteInstance();
|
||||
|
||||
void Load(const char* path);
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
LexerManager();
|
||||
static LexerManager *theInstance;
|
||||
|
||||
void LoadLexerLibrary(const char* module);
|
||||
LexerLibrary *first;
|
||||
LexerLibrary *last;
|
||||
};
|
||||
|
||||
class LMMinder {
|
||||
public:
|
||||
~LMMinder();
|
||||
};
|
||||
|
||||
#endif
|
@@ -55,6 +55,8 @@ void Indicator::Draw(Surface *surface, PRectangle &rc) {
|
||||
} else if (style == INDIC_STRIKE) {
|
||||
surface->MoveTo(rc.left, rc.top - 4);
|
||||
surface->LineTo(rc.right, rc.top - 4);
|
||||
} else if (style == INDIC_HIDDEN) {
|
||||
// Draw nothing
|
||||
} else { // Either INDIC_PLAIN or unknown
|
||||
surface->MoveTo(rc.left, ymid);
|
||||
surface->LineTo(rc.right, ymid);
|
||||
|
@@ -130,6 +130,7 @@ const KeyToCommand KeyMap::MapDefault[] = {
|
||||
//'L', SCI_CTRL, SCI_FORMFEED,
|
||||
{'L', SCI_CTRL, SCI_LINECUT},
|
||||
{'L', SCI_CSHIFT, SCI_LINEDELETE},
|
||||
{'T', SCI_CSHIFT, SCI_LINECOPY},
|
||||
{'T', SCI_CTRL, SCI_LINETRANSPOSE},
|
||||
{'D', SCI_CTRL, SCI_LINEDUPLICATE},
|
||||
{'U', SCI_CTRL, SCI_LOWERCASE},
|
||||
|
@@ -112,18 +112,6 @@ void LexerModule::Fold(unsigned int startPos, int lengthDoc, int initStyle,
|
||||
}
|
||||
}
|
||||
|
||||
static void ColouriseNullDoc(unsigned int startPos, int length, int, WordList *[],
|
||||
Accessor &styler) {
|
||||
// Null language means all style bytes are 0 so just mark the end - no need to fill in.
|
||||
if (length > 0) {
|
||||
styler.StartAt(startPos + length - 1);
|
||||
styler.StartSegment(startPos + length - 1);
|
||||
styler.ColourTo(startPos + length - 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
LexerModule lmNull(SCLEX_NULL, ColouriseNullDoc, "null");
|
||||
|
||||
// Alternative historical name for Scintilla_LinkLexers
|
||||
int wxForceScintillaLexers(void) {
|
||||
return Scintilla_LinkLexers();
|
||||
@@ -154,6 +142,7 @@ int Scintilla_LinkLexers() {
|
||||
LINK_LEXER(lmCss);
|
||||
LINK_LEXER(lmEiffel);
|
||||
LINK_LEXER(lmEiffelkw);
|
||||
LINK_LEXER(lmESCRIPT);
|
||||
LINK_LEXER(lmFortran);
|
||||
LINK_LEXER(lmF77);
|
||||
LINK_LEXER(lmHTML);
|
||||
@@ -161,19 +150,25 @@ int Scintilla_LinkLexers() {
|
||||
LINK_LEXER(lmASP);
|
||||
LINK_LEXER(lmPHP);
|
||||
LINK_LEXER(lmLISP);
|
||||
LINK_LEXER(lmLout);
|
||||
LINK_LEXER(lmLua);
|
||||
LINK_LEXER(lmMatlab);
|
||||
LINK_LEXER(lmMMIXAL);
|
||||
LINK_LEXER(lmNsis);
|
||||
LINK_LEXER(lmBatch);
|
||||
LINK_LEXER(lmDiff);
|
||||
LINK_LEXER(lmProps);
|
||||
LINK_LEXER(lmMake);
|
||||
LINK_LEXER(lmErrorList);
|
||||
LINK_LEXER(lmLatex);
|
||||
LINK_LEXER(lmNull);
|
||||
LINK_LEXER(lmPascal);
|
||||
LINK_LEXER(lmPerl);
|
||||
LINK_LEXER(lmPOV);
|
||||
LINK_LEXER(lmPS);
|
||||
LINK_LEXER(lmPython);
|
||||
LINK_LEXER(lmRuby);
|
||||
LINK_LEXER(lmScriptol);
|
||||
LINK_LEXER(lmSQL);
|
||||
LINK_LEXER(lmVB);
|
||||
LINK_LEXER(lmVBScript);
|
||||
|
@@ -321,7 +321,7 @@ static bool IsValidIdentifier(const SString& identifier) {
|
||||
// First character can't be '_', so initialize the flag to true
|
||||
bool lastWasUnderscore = true;
|
||||
|
||||
int length = identifier.length();
|
||||
size_t length = identifier.length();
|
||||
|
||||
// Zero-length identifiers are not valid (these can occur inside labels)
|
||||
if (length == 0) {
|
||||
@@ -334,7 +334,7 @@ static bool IsValidIdentifier(const SString& identifier) {
|
||||
}
|
||||
|
||||
// Check for only valid characters and no double underscores
|
||||
for (int i = 0; i < length; i++) {
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
if (!IsWordCharacter(identifier[i]) ||
|
||||
(identifier[i] == '_' && lastWasUnderscore)) {
|
||||
return false;
|
||||
@@ -355,8 +355,8 @@ static bool IsValidNumber(const SString& number) {
|
||||
int hashPos = number.search("#");
|
||||
bool seenDot = false;
|
||||
|
||||
int i = 0;
|
||||
int length = number.length();
|
||||
size_t i = 0;
|
||||
size_t length = number.length();
|
||||
|
||||
if (length == 0)
|
||||
return false; // Just in case
|
||||
|
@@ -60,6 +60,7 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo
|
||||
WordList &keywords = *keywordlists[0];
|
||||
WordList &keywords2 = *keywordlists[1];
|
||||
WordList &keywords3 = *keywordlists[2];
|
||||
WordList &keywords4 = *keywordlists[3];
|
||||
|
||||
bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0;
|
||||
|
||||
@@ -111,6 +112,8 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo
|
||||
sc.ChangeState(SCE_C_WORD);
|
||||
} else if (keywords2.InList(s)) {
|
||||
sc.ChangeState(SCE_C_WORD2);
|
||||
} else if (keywords4.InList(s)) {
|
||||
sc.ChangeState(SCE_C_GLOBALCLASS);
|
||||
}
|
||||
sc.SetState(SCE_C_DEFAULT);
|
||||
}
|
||||
@@ -279,237 +282,23 @@ static bool IsStreamCommentStyle(int style) {
|
||||
style == SCE_C_COMMENTDOCKEYWORDERROR;
|
||||
}
|
||||
|
||||
static bool matchKeyword(unsigned int start, WordList &keywords, Accessor &styler, int keywordtype) {
|
||||
bool FoundKeyword = false;
|
||||
|
||||
for (unsigned int i = 0;
|
||||
strlen(keywords[i]) > 0 && !FoundKeyword;
|
||||
i++) {
|
||||
if (atoi(keywords[i]) == keywordtype) {
|
||||
FoundKeyword = styler.Match(start, ((char *)keywords[i]) + 2);
|
||||
}
|
||||
}
|
||||
return FoundKeyword;
|
||||
}
|
||||
|
||||
static bool IsCommentLine(int line, Accessor &styler) {
|
||||
unsigned int Pos = styler.LineStart(line);
|
||||
while (styler.GetLine(Pos) == line) {
|
||||
int PosStyle = styler.StyleAt(Pos);
|
||||
|
||||
if ( !IsStreamCommentStyle(PosStyle)
|
||||
&&
|
||||
PosStyle != SCE_C_COMMENTLINEDOC
|
||||
&&
|
||||
PosStyle != SCE_C_COMMENTLINE
|
||||
&&
|
||||
!IsASpace(styler.SafeGetCharAt(Pos))
|
||||
)
|
||||
return false;
|
||||
Pos++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void FoldBoxCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
|
||||
WordList &keywords4 = *keywordlists[3];
|
||||
|
||||
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
|
||||
bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0;
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
bool firstLine = true;
|
||||
unsigned int endPos = startPos + length;
|
||||
int visibleChars = 0;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
|
||||
int levelCurrent = levelPrev;
|
||||
int levelPrevPrev;
|
||||
int levelFlags = 0;
|
||||
int levelUnindent = 0;
|
||||
char chNext = styler[startPos];
|
||||
int styleNext = styler.StyleAt(startPos);
|
||||
int style = initStyle;
|
||||
|
||||
if (lineCurrent == 0) {
|
||||
levelPrevPrev = levelPrev;
|
||||
} else {
|
||||
levelPrevPrev = styler.LevelAt(lineCurrent - 1) & SC_FOLDLEVELNUMBERMASK;
|
||||
}
|
||||
|
||||
for (unsigned int i = startPos; i < endPos; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
int stylePrev = style;
|
||||
style = styleNext;
|
||||
styleNext = styler.StyleAt(i + 1);
|
||||
|
||||
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
|
||||
if (foldComment && IsStreamCommentStyle(style)) {
|
||||
if (!IsStreamCommentStyle(stylePrev)) {
|
||||
levelCurrent++;
|
||||
} else if (!IsStreamCommentStyle(styleNext) && !atEOL) {
|
||||
// Comments don't end at end of line and the next character may be unstyled.
|
||||
levelCurrent--;
|
||||
}
|
||||
}
|
||||
|
||||
if (foldComment && (style == SCE_C_COMMENTLINE)) {
|
||||
if ((ch == '/') && (chNext == '/')) {
|
||||
char chNext2 = styler.SafeGetCharAt(i + 2);
|
||||
if (chNext2 == '{') {
|
||||
levelCurrent++;
|
||||
} else if (chNext2 == '}') {
|
||||
levelCurrent--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foldPreprocessor && (style == SCE_C_PREPROCESSOR)) {
|
||||
if (ch == '#') {
|
||||
unsigned int j = i + 1;
|
||||
while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) {
|
||||
j++;
|
||||
}
|
||||
|
||||
if (styler.Match(j, "region") || styler.Match(j, "if")) {
|
||||
levelCurrent++;
|
||||
} else if (styler.Match(j, "end")) {
|
||||
levelCurrent--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (style == SCE_C_OPERATOR
|
||||
||
|
||||
style == SCE_C_COMMENT
|
||||
||
|
||||
style == SCE_C_COMMENTLINE) {
|
||||
|
||||
if (ch == '{') {
|
||||
levelCurrent++;
|
||||
// Special handling if line has closing brace followed by opening brace.
|
||||
if (levelCurrent == levelPrev) {
|
||||
if (firstLine)
|
||||
levelUnindent = 1;
|
||||
else
|
||||
levelUnindent = -1;
|
||||
}
|
||||
} else if (ch == '}') {
|
||||
levelCurrent--;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for fold header keyword at beginning of word */
|
||||
if ((style == SCE_C_WORD || style == SCE_C_COMMENT || style == SCE_C_COMMENTLINE)
|
||||
&&
|
||||
(style != stylePrev)) {
|
||||
if (matchKeyword(i, keywords4, styler, KEYWORD_BOXHEADER)) {
|
||||
int line;
|
||||
/* Loop backwards all empty or comment lines */
|
||||
for (line = lineCurrent - 1;
|
||||
line >= 0
|
||||
&&
|
||||
levelCurrent == (styler.LevelAt(line) & SC_FOLDLEVELNUMBERMASK)
|
||||
&&
|
||||
(styler.LevelAt(line) & SC_FOLDLEVELBOXFOOTERFLAG) == 0
|
||||
&&
|
||||
IsCommentLine(line, styler);
|
||||
line--) {
|
||||
/* just loop backwards */;
|
||||
}
|
||||
|
||||
line++;
|
||||
/* Set Box header flag (if the previous line has no footer line) */
|
||||
if ((styler.LevelAt(line) & SC_FOLDLEVELBOXFOOTERFLAG) == 0) {
|
||||
if (line == lineCurrent) {
|
||||
/* in current line */
|
||||
levelFlags |= SC_FOLDLEVELBOXHEADERFLAG;
|
||||
} else {
|
||||
/* at top of all preceding comment lines */
|
||||
styler.SetLevel(line, styler.LevelAt(line)
|
||||
| SC_FOLDLEVELBOXHEADERFLAG);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (matchKeyword(i, keywords4, styler, KEYWORD_FOLDCONTRACTED)) {
|
||||
levelFlags |= SC_FOLDLEVELCONTRACTED;
|
||||
}
|
||||
|
||||
if (atEOL) {
|
||||
int lev;
|
||||
// Compute level correction for special case: '} else {'
|
||||
if (levelUnindent < 0) {
|
||||
levelPrev += levelUnindent;
|
||||
} else {
|
||||
levelCurrent += levelUnindent;
|
||||
}
|
||||
|
||||
lev = levelPrev;
|
||||
if (visibleChars == 0 && foldCompact)
|
||||
lev |= SC_FOLDLEVELWHITEFLAG;
|
||||
// Produce additional footer line (e.g. after closed if)
|
||||
if (visibleChars == 0
|
||||
&&
|
||||
(levelPrev < levelPrevPrev))
|
||||
lev |= SC_FOLDLEVELBOXFOOTERFLAG;
|
||||
// Produce footer line at line before (special handling for '} else {'
|
||||
if (levelPrev < levelPrevPrev) {
|
||||
styler.SetLevel(lineCurrent - 1,
|
||||
styler.LevelAt(lineCurrent - 1) | SC_FOLDLEVELBOXFOOTERFLAG);
|
||||
}
|
||||
// Mark the fold header (the line that is always visible)
|
||||
if ((levelCurrent > levelPrev) && (visibleChars > 0))
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
// Show a footer line at end of fold
|
||||
if (levelCurrent < levelPrev)
|
||||
lev |= SC_FOLDLEVELBOXFOOTERFLAG;
|
||||
/* Show a footer line at the end of each procedure (level == SC_FOLDLEVELBASE) */
|
||||
if ((levelPrev == SC_FOLDLEVELBASE)
|
||||
&&
|
||||
(levelPrevPrev > SC_FOLDLEVELBASE)
|
||||
&&
|
||||
(visibleChars == 0)) {
|
||||
lev |= SC_FOLDLEVELBOXFOOTERFLAG;
|
||||
}
|
||||
|
||||
lev |= levelFlags;
|
||||
if (lev != styler.LevelAt(lineCurrent)) {
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
|
||||
lineCurrent++;
|
||||
levelPrevPrev = levelPrev;
|
||||
levelPrev = levelCurrent;
|
||||
levelUnindent = 0;
|
||||
visibleChars = 0;
|
||||
levelFlags = 0;
|
||||
firstLine = false;
|
||||
}
|
||||
|
||||
if (!isspacechar(ch))
|
||||
visibleChars++;
|
||||
}
|
||||
// Fill in the real level of the next line, keeping the current flags as they will be filled in later
|
||||
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
|
||||
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
|
||||
}
|
||||
|
||||
// Store both the current line's fold level and the next lines in the
|
||||
// level store to make it easy to pick up with each increment
|
||||
// and to make it possible to fiddle the current level for "} else {".
|
||||
static void FoldNoBoxCppDoc(unsigned int startPos, int length, int initStyle,
|
||||
Accessor &styler) {
|
||||
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
|
||||
bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0;
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0;
|
||||
unsigned int endPos = startPos + length;
|
||||
int visibleChars = 0;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
|
||||
int levelCurrent = levelPrev;
|
||||
int levelCurrent = SC_FOLDLEVELBASE;
|
||||
if (lineCurrent > 0)
|
||||
levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
|
||||
int levelMinCurrent = levelCurrent;
|
||||
int levelNext = levelCurrent;
|
||||
char chNext = styler[startPos];
|
||||
int styleNext = styler.StyleAt(startPos);
|
||||
int style = initStyle;
|
||||
@@ -522,19 +311,19 @@ static void FoldNoBoxCppDoc(unsigned int startPos, int length, int initStyle,
|
||||
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
if (foldComment && IsStreamCommentStyle(style)) {
|
||||
if (!IsStreamCommentStyle(stylePrev)) {
|
||||
levelCurrent++;
|
||||
levelNext++;
|
||||
} else if (!IsStreamCommentStyle(styleNext) && !atEOL) {
|
||||
// Comments don't end at end of line and the next character may be unstyled.
|
||||
levelCurrent--;
|
||||
levelNext--;
|
||||
}
|
||||
}
|
||||
if (foldComment && (style == SCE_C_COMMENTLINE)) {
|
||||
if ((ch == '/') && (chNext == '/')) {
|
||||
char chNext2 = styler.SafeGetCharAt(i + 2);
|
||||
if (chNext2 == '{') {
|
||||
levelCurrent++;
|
||||
levelNext++;
|
||||
} else if (chNext2 == '}') {
|
||||
levelCurrent--;
|
||||
levelNext--;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -545,58 +334,58 @@ static void FoldNoBoxCppDoc(unsigned int startPos, int length, int initStyle,
|
||||
j++;
|
||||
}
|
||||
if (styler.Match(j, "region") || styler.Match(j, "if")) {
|
||||
levelCurrent++;
|
||||
levelNext++;
|
||||
} else if (styler.Match(j, "end")) {
|
||||
levelCurrent--;
|
||||
levelNext--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (style == SCE_C_OPERATOR) {
|
||||
if (ch == '{') {
|
||||
levelCurrent++;
|
||||
// Measure the minimum before a '{' to allow
|
||||
// folding on "} else {"
|
||||
if (levelMinCurrent > levelNext) {
|
||||
levelMinCurrent = levelNext;
|
||||
}
|
||||
levelNext++;
|
||||
} else if (ch == '}') {
|
||||
levelCurrent--;
|
||||
levelNext--;
|
||||
}
|
||||
}
|
||||
if (atEOL) {
|
||||
int lev = levelPrev;
|
||||
int levelUse = levelCurrent;
|
||||
if (foldAtElse) {
|
||||
levelUse = levelMinCurrent;
|
||||
}
|
||||
int lev = levelUse | levelNext << 16;
|
||||
if (visibleChars == 0 && foldCompact)
|
||||
lev |= SC_FOLDLEVELWHITEFLAG;
|
||||
if ((levelCurrent > levelPrev) && (visibleChars > 0))
|
||||
if (levelUse < levelNext)
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
if (lev != styler.LevelAt(lineCurrent)) {
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
lineCurrent++;
|
||||
levelPrev = levelCurrent;
|
||||
levelCurrent = levelNext;
|
||||
levelMinCurrent = levelCurrent;
|
||||
visibleChars = 0;
|
||||
}
|
||||
if (!isspacechar(ch))
|
||||
visibleChars++;
|
||||
}
|
||||
// Fill in the real level of the next line, keeping the current flags as they will be filled in later
|
||||
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
|
||||
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
|
||||
}
|
||||
|
||||
static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||
static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordList *[],
|
||||
Accessor &styler) {
|
||||
|
||||
int foldFlags = styler.GetPropertyInt("fold.flags") ;
|
||||
bool foldBox = ((foldFlags & SC_FOLDFLAG_BOX) == SC_FOLDFLAG_BOX);
|
||||
|
||||
if (foldBox) {
|
||||
FoldBoxCppDoc(startPos, length, initStyle, keywordlists, styler);
|
||||
} else {
|
||||
FoldNoBoxCppDoc(startPos, length, initStyle, styler);
|
||||
}
|
||||
FoldNoBoxCppDoc(startPos, length, initStyle, styler);
|
||||
}
|
||||
|
||||
static const char * const cppWordLists[] = {
|
||||
"Primary keywords and identifiers",
|
||||
"Secondary keywords and identifiers",
|
||||
"Documentation comment keywords",
|
||||
"Fold header keywords",
|
||||
"Unused",
|
||||
"Global classes and typedefs",
|
||||
0,
|
||||
};
|
||||
|
||||
|
@@ -108,7 +108,8 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
|
||||
sc.SetState(SCE_CSS_DEFAULT);
|
||||
break;
|
||||
case ':':
|
||||
if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID)
|
||||
if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_DEFAULT ||
|
||||
lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS)
|
||||
sc.SetState(SCE_CSS_PSEUDOCLASS);
|
||||
else if (lastState == SCE_CSS_IDENTIFIER || lastState == SCE_CSS_UNKNOWN_IDENTIFIER)
|
||||
sc.SetState(SCE_CSS_VALUE);
|
||||
|
270
contrib/src/stc/scintilla/src/LexEScript.cxx
Normal file
270
contrib/src/stc/scintilla/src/LexEScript.cxx
Normal file
@@ -0,0 +1,270 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file LexESCRIPT.cxx
|
||||
** Lexer for ESCRIPT
|
||||
**/
|
||||
// Copyright 2003 by Patrizio Bekerle (patrizio@bekerle.com)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "StyleContext.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
|
||||
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
|
||||
}
|
||||
|
||||
static inline bool IsAWordStart(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_');
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void ColouriseESCRIPTDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
WordList &keywords2 = *keywordlists[1];
|
||||
WordList &keywords3 = *keywordlists[2];
|
||||
|
||||
// Do not leak onto next line
|
||||
/*if (initStyle == SCE_ESCRIPT_STRINGEOL)
|
||||
initStyle = SCE_ESCRIPT_DEFAULT;*/
|
||||
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
|
||||
bool caseSensitive = styler.GetPropertyInt("escript.case.sensitive", 0) != 0;
|
||||
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
|
||||
/*if (sc.atLineStart && (sc.state == SCE_ESCRIPT_STRING)) {
|
||||
// Prevent SCE_ESCRIPT_STRINGEOL from leaking back to previous line
|
||||
sc.SetState(SCE_ESCRIPT_STRING);
|
||||
}*/
|
||||
|
||||
// Handle line continuation generically.
|
||||
if (sc.ch == '\\') {
|
||||
if (sc.chNext == '\n' || sc.chNext == '\r') {
|
||||
sc.Forward();
|
||||
if (sc.ch == '\r' && sc.chNext == '\n') {
|
||||
sc.Forward();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if the current state should terminate.
|
||||
if (sc.state == SCE_ESCRIPT_OPERATOR || sc.state == SCE_ESCRIPT_BRACE) {
|
||||
sc.SetState(SCE_ESCRIPT_DEFAULT);
|
||||
} else if (sc.state == SCE_ESCRIPT_NUMBER) {
|
||||
if (!IsADigit(sc.ch) || sc.ch != '.') {
|
||||
sc.SetState(SCE_ESCRIPT_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_ESCRIPT_IDENTIFIER) {
|
||||
if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {
|
||||
char s[100];
|
||||
if (caseSensitive) {
|
||||
sc.GetCurrent(s, sizeof(s));
|
||||
} else {
|
||||
sc.GetCurrentLowered(s, sizeof(s));
|
||||
}
|
||||
|
||||
// sc.GetCurrentLowered(s, sizeof(s));
|
||||
|
||||
if (keywords.InList(s)) {
|
||||
sc.ChangeState(SCE_ESCRIPT_WORD);
|
||||
} else if (keywords2.InList(s)) {
|
||||
sc.ChangeState(SCE_ESCRIPT_WORD2);
|
||||
} else if (keywords3.InList(s)) {
|
||||
sc.ChangeState(SCE_ESCRIPT_WORD3);
|
||||
// sc.state = SCE_ESCRIPT_IDENTIFIER;
|
||||
}
|
||||
sc.SetState(SCE_ESCRIPT_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_ESCRIPT_COMMENT) {
|
||||
if (sc.Match('*', '/')) {
|
||||
sc.Forward();
|
||||
sc.ForwardSetState(SCE_ESCRIPT_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_ESCRIPT_COMMENTDOC) {
|
||||
if (sc.Match('*', '/')) {
|
||||
sc.Forward();
|
||||
sc.ForwardSetState(SCE_ESCRIPT_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_ESCRIPT_COMMENTLINE) {
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_ESCRIPT_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_ESCRIPT_STRING) {
|
||||
if (sc.ch == '\\') {
|
||||
if (sc.chNext == '\"' || sc.chNext == '\\') {
|
||||
sc.Forward();
|
||||
}
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.ForwardSetState(SCE_ESCRIPT_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if a new state should be entered.
|
||||
if (sc.state == SCE_ESCRIPT_DEFAULT) {
|
||||
if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
|
||||
sc.SetState(SCE_ESCRIPT_NUMBER);
|
||||
} else if (IsAWordStart(sc.ch) || (sc.ch == '#')) {
|
||||
sc.SetState(SCE_ESCRIPT_IDENTIFIER);
|
||||
} else if (sc.Match('/', '*')) {
|
||||
sc.SetState(SCE_ESCRIPT_COMMENT);
|
||||
sc.Forward(); // Eat the * so it isn't used for the end of the comment
|
||||
} else if (sc.Match('/', '/')) {
|
||||
sc.SetState(SCE_ESCRIPT_COMMENTLINE);
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.SetState(SCE_ESCRIPT_STRING);
|
||||
//} else if (isoperator(static_cast<char>(sc.ch))) {
|
||||
} else if (sc.ch == '+' || sc.ch == '-' || sc.ch == '*' || sc.ch == '/' || sc.ch == '=' || sc.ch == '<' || sc.ch == '>' || sc.ch == '&' || sc.ch == '|' || sc.ch == '!' || sc.ch == '?' || sc.ch == ':') {
|
||||
sc.SetState(SCE_ESCRIPT_OPERATOR);
|
||||
} else if (sc.ch == '{' || sc.ch == '}') {
|
||||
sc.SetState(SCE_ESCRIPT_BRACE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
|
||||
static int classifyFoldPointESCRIPT(const char* s, const char* prevWord) {
|
||||
int lev = 0;
|
||||
if (strcmp(prevWord, "end") == 0) return lev;
|
||||
if ((strcmp(prevWord, "else") == 0 && strcmp(s, "if") == 0) || strcmp(s, "elseif") == 0)
|
||||
return -1;
|
||||
|
||||
if (strcmp(s, "for") == 0 || strcmp(s, "foreach") == 0
|
||||
|| strcmp(s, "program") == 0 || strcmp(s, "function") == 0
|
||||
|| strcmp(s, "while") == 0 || strcmp(s, "case") == 0
|
||||
|| strcmp(s, "if") == 0 ) {
|
||||
lev = 1;
|
||||
} else if ( strcmp(s, "endfor") == 0 || strcmp(s, "endforeach") == 0
|
||||
|| strcmp(s, "endprogram") == 0 || strcmp(s, "endfunction") == 0
|
||||
|| strcmp(s, "endwhile") == 0 || strcmp(s, "endcase") == 0
|
||||
|| strcmp(s, "endif") == 0 ) {
|
||||
lev = -1;
|
||||
}
|
||||
|
||||
return lev;
|
||||
}
|
||||
|
||||
|
||||
static bool IsStreamCommentStyle(int style) {
|
||||
return style == SCE_ESCRIPT_COMMENT ||
|
||||
style == SCE_ESCRIPT_COMMENTDOC ||
|
||||
style == SCE_ESCRIPT_COMMENTLINE;
|
||||
}
|
||||
|
||||
static void FoldESCRIPTDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) {
|
||||
//~ bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
|
||||
// Do not know how to fold the comment at the moment.
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
bool foldComment = true;
|
||||
unsigned int endPos = startPos + length;
|
||||
int visibleChars = 0;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
|
||||
int levelCurrent = levelPrev;
|
||||
char chNext = styler[startPos];
|
||||
int styleNext = styler.StyleAt(startPos);
|
||||
int style = initStyle;
|
||||
|
||||
int lastStart = 0;
|
||||
char prevWord[32] = "";
|
||||
|
||||
for (unsigned int i = startPos; i < endPos; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
int stylePrev = style;
|
||||
style = styleNext;
|
||||
styleNext = styler.StyleAt(i + 1);
|
||||
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
|
||||
|
||||
if (foldComment && IsStreamCommentStyle(style)) {
|
||||
if (!IsStreamCommentStyle(stylePrev)) {
|
||||
levelCurrent++;
|
||||
} else if (!IsStreamCommentStyle(styleNext) && !atEOL) {
|
||||
// Comments don't end at end of line and the next character may be unstyled.
|
||||
levelCurrent--;
|
||||
}
|
||||
}
|
||||
|
||||
if (foldComment && (style == SCE_ESCRIPT_COMMENTLINE)) {
|
||||
if ((ch == '/') && (chNext == '/')) {
|
||||
char chNext2 = styler.SafeGetCharAt(i + 2);
|
||||
if (chNext2 == '{') {
|
||||
levelCurrent++;
|
||||
} else if (chNext2 == '}') {
|
||||
levelCurrent--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stylePrev == SCE_ESCRIPT_DEFAULT && style == SCE_ESCRIPT_WORD3)
|
||||
{
|
||||
// Store last word start point.
|
||||
lastStart = i;
|
||||
}
|
||||
|
||||
if (style == SCE_ESCRIPT_WORD3) {
|
||||
if(iswordchar(ch) && !iswordchar(chNext)) {
|
||||
char s[32];
|
||||
unsigned int j;
|
||||
for(j = 0; ( j < 31 ) && ( j < i-lastStart+1 ); j++) {
|
||||
s[j] = static_cast<char>(tolower(styler[lastStart + j]));
|
||||
}
|
||||
s[j] = '\0';
|
||||
levelCurrent += classifyFoldPointESCRIPT(s, prevWord);
|
||||
strcpy(prevWord, s);
|
||||
}
|
||||
}
|
||||
if (atEOL) {
|
||||
int lev = levelPrev;
|
||||
if (visibleChars == 0 && foldCompact)
|
||||
lev |= SC_FOLDLEVELWHITEFLAG;
|
||||
if ((levelCurrent > levelPrev) && (visibleChars > 0))
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
if (lev != styler.LevelAt(lineCurrent)) {
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
lineCurrent++;
|
||||
levelPrev = levelCurrent;
|
||||
visibleChars = 0;
|
||||
strcpy(prevWord, "");
|
||||
}
|
||||
|
||||
if (!isspacechar(ch))
|
||||
visibleChars++;
|
||||
}
|
||||
|
||||
// Fill in the real level of the next line, keeping the current flags as they will be filled in later
|
||||
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
|
||||
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const char * const ESCRIPTWordLists[] = {
|
||||
"Primary keywords and identifiers",
|
||||
"Intrinsic functions",
|
||||
"Extended and user defined functions",
|
||||
0,
|
||||
};
|
||||
|
||||
LexerModule lmESCRIPT(SCLEX_ESCRIPT, ColouriseESCRIPTDoc, "escript", FoldESCRIPTDoc, ESCRIPTWordLists);
|
@@ -127,7 +127,7 @@ static int stateForPrintState(int StateToPrint) {
|
||||
}
|
||||
|
||||
static inline bool IsNumber(unsigned int start, Accessor &styler) {
|
||||
return isdigit(styler[start]) || (styler[start] == '.') ||
|
||||
return IsADigit(styler[start]) || (styler[start] == '.') ||
|
||||
(styler[start] == '-') || (styler[start] == '#');
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ static int classifyTagHTML(unsigned int start, unsigned int end,
|
||||
static void classifyWordHTJS(unsigned int start, unsigned int end,
|
||||
WordList &keywords, Accessor &styler, script_mode inScriptType) {
|
||||
char chAttr = SCE_HJ_WORD;
|
||||
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
|
||||
bool wordIsNumber = IsADigit(styler[start]) || (styler[start] == '.');
|
||||
if (wordIsNumber)
|
||||
chAttr = SCE_HJ_NUMBER;
|
||||
else {
|
||||
@@ -264,7 +264,7 @@ static void classifyWordHTJS(unsigned int start, unsigned int end,
|
||||
|
||||
static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, script_mode inScriptType) {
|
||||
char chAttr = SCE_HB_IDENTIFIER;
|
||||
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
|
||||
bool wordIsNumber = IsADigit(styler[start]) || (styler[start] == '.');
|
||||
if (wordIsNumber)
|
||||
chAttr = SCE_HB_NUMBER;
|
||||
else {
|
||||
@@ -288,7 +288,7 @@ static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keyw
|
||||
}
|
||||
|
||||
static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, script_mode inScriptType) {
|
||||
bool wordIsNumber = isdigit(styler[start]) != 0;
|
||||
bool wordIsNumber = IsADigit(styler[start]);
|
||||
char s[30 + 1];
|
||||
unsigned int i = 0;
|
||||
for (; i < end - start + 1 && i < 30; i++) {
|
||||
@@ -312,7 +312,7 @@ static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &key
|
||||
// Called when in a PHP word
|
||||
static void classifyWordHTPHP(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
|
||||
char chAttr = SCE_HPHP_DEFAULT;
|
||||
bool wordIsNumber = isdigit(styler[start]) != 0;
|
||||
bool wordIsNumber = IsADigit(styler[start]);
|
||||
if (wordIsNumber)
|
||||
chAttr = SCE_HPHP_NUMBER;
|
||||
else {
|
||||
@@ -375,19 +375,21 @@ static int StateForScript(script_type scriptLanguage) {
|
||||
}
|
||||
|
||||
static inline bool ishtmlwordchar(char ch) {
|
||||
return isalnum(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':' || ch == '!' || ch == '#';
|
||||
return !isascii(ch) ||
|
||||
(isalnum(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':' || ch == '!' || ch == '#');
|
||||
}
|
||||
|
||||
static inline bool issgmlwordchar(char ch) {
|
||||
return isalnum(ch) || ch == '.' || ch == '_' || ch == ':' || ch == '!' || ch == '#' || ch == '[';
|
||||
return !isascii(ch) ||
|
||||
(isalnum(ch) || ch == '.' || ch == '_' || ch == ':' || ch == '!' || ch == '#' || ch == '[');
|
||||
}
|
||||
|
||||
static inline bool IsPhpWordStart(const unsigned char ch) {
|
||||
return isalpha(ch) || (ch == '_') || (ch >= 0x7f);
|
||||
return (isascii(ch) && (isalpha(ch) || (ch == '_'))) || (ch >= 0x7f);
|
||||
}
|
||||
|
||||
static inline bool IsPhpWordChar(char ch) {
|
||||
return isdigit(ch) || IsPhpWordStart(ch);
|
||||
return IsADigit(ch) || IsPhpWordStart(ch);
|
||||
}
|
||||
|
||||
static bool InTagState(int state) {
|
||||
@@ -787,7 +789,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
} else if ((ch == '-') && (chPrev == '-')) {
|
||||
styler.ColourTo(i - 2, StateToPrint);
|
||||
state = SCE_H_SGML_COMMENT;
|
||||
} else if (isalpha(ch) && (chPrev == '%')) {
|
||||
} else if (isascii(ch) && isalpha(ch) && (chPrev == '%')) {
|
||||
styler.ColourTo(i - 2, StateToPrint);
|
||||
state = SCE_H_SGML_ENTITY;
|
||||
} else if (ch == '#') {
|
||||
@@ -905,7 +907,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
}
|
||||
break;
|
||||
case SCE_H_SGML_SPECIAL:
|
||||
if (!isupper(ch)) {
|
||||
if (!(isascii(ch) && isupper(ch))) {
|
||||
styler.ColourTo(i - 1, StateToPrint);
|
||||
if (isalnum(ch)) {
|
||||
state = SCE_H_SGML_ERROR;
|
||||
@@ -918,7 +920,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
if (ch == ';') {
|
||||
styler.ColourTo(i, StateToPrint);
|
||||
state = SCE_H_SGML_DEFAULT;
|
||||
} else if (!isalnum(ch) && ch != '-' && ch != '.') {
|
||||
} else if (!(isascii(ch) && isalnum(ch)) && ch != '-' && ch != '.') {
|
||||
styler.ColourTo(i, SCE_H_SGML_ERROR);
|
||||
state = SCE_H_SGML_DEFAULT;
|
||||
}
|
||||
@@ -928,7 +930,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
styler.ColourTo(i, StateToPrint);
|
||||
state = SCE_H_DEFAULT;
|
||||
}
|
||||
if (ch != '#' && !isalnum(ch)) { // Should check that '#' follows '&', but it is unlikely anyway...
|
||||
if (ch != '#' && !(isascii(ch) && isalnum(ch))) { // Should check that '#' follows '&', but it is unlikely anyway...
|
||||
styler.ColourTo(i, SCE_H_TAGUNKNOWN);
|
||||
state = SCE_H_DEFAULT;
|
||||
}
|
||||
@@ -1464,7 +1466,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
}
|
||||
break;
|
||||
case SCE_HPHP_NUMBER:
|
||||
if (!isdigit(ch)) {
|
||||
if (!IsADigit(ch)) {
|
||||
styler.ColourTo(i - 1, SCE_HPHP_NUMBER);
|
||||
if (isoperator(ch))
|
||||
state = SCE_HPHP_OPERATOR;
|
||||
@@ -1524,7 +1526,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
case SCE_HPHP_OPERATOR:
|
||||
case SCE_HPHP_DEFAULT:
|
||||
styler.ColourTo(i - 1, StateToPrint);
|
||||
if (isdigit(ch)) {
|
||||
if (IsADigit(ch)) {
|
||||
state = SCE_HPHP_NUMBER;
|
||||
} else if (iswordstart(ch)) {
|
||||
state = SCE_HPHP_WORD;
|
||||
|
208
contrib/src/stc/scintilla/src/LexLout.cxx
Normal file
208
contrib/src/stc/scintilla/src/LexLout.cxx
Normal file
@@ -0,0 +1,208 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file LexLout.cxx
|
||||
** Lexer for the Basser Lout (>= version 3) typesetting language
|
||||
**/
|
||||
// Copyright 2003 by Kein-Hong Man <mkh@pl.jaring.my>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "StyleContext.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalpha(ch) || ch == '@' || ch == '_');
|
||||
}
|
||||
|
||||
static inline bool IsAnOther(const int ch) {
|
||||
return (ch < 0x80) && (ch == '{' || ch == '}' ||
|
||||
ch == '!' || ch == '$' || ch == '%' || ch == '&' || ch == '\'' ||
|
||||
ch == '(' || ch == ')' || ch == '*' || ch == '+' || ch == ',' ||
|
||||
ch == '-' || ch == '.' || ch == '/' || ch == ':' || ch == ';' ||
|
||||
ch == '<' || ch == '=' || ch == '>' || ch == '?' || ch == '[' ||
|
||||
ch == ']' || ch == '^' || ch == '`' || ch == '|' || ch == '~');
|
||||
}
|
||||
|
||||
static void ColouriseLoutDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
WordList &keywords2 = *keywordlists[1];
|
||||
WordList &keywords3 = *keywordlists[2];
|
||||
|
||||
int visibleChars = 0;
|
||||
int firstWordInLine = 0;
|
||||
int leadingAtSign = 0;
|
||||
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
|
||||
if (sc.atLineStart && (sc.state == SCE_LOUT_STRING)) {
|
||||
// Prevent SCE_LOUT_STRINGEOL from leaking back to previous line
|
||||
sc.SetState(SCE_LOUT_STRING);
|
||||
}
|
||||
|
||||
// Determine if the current state should terminate.
|
||||
if (sc.state == SCE_LOUT_COMMENT) {
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_LOUT_DEFAULT);
|
||||
visibleChars = 0;
|
||||
}
|
||||
} else if (sc.state == SCE_LOUT_NUMBER) {
|
||||
if (!IsADigit(sc.ch) && sc.ch != '.') {
|
||||
sc.SetState(SCE_LOUT_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_LOUT_STRING) {
|
||||
if (sc.ch == '\\') {
|
||||
if (sc.chNext == '\"' || sc.chNext == '\\') {
|
||||
sc.Forward();
|
||||
}
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.ForwardSetState(SCE_LOUT_DEFAULT);
|
||||
} else if (sc.atLineEnd) {
|
||||
sc.ChangeState(SCE_LOUT_STRINGEOL);
|
||||
sc.ForwardSetState(SCE_LOUT_DEFAULT);
|
||||
visibleChars = 0;
|
||||
}
|
||||
} else if (sc.state == SCE_LOUT_IDENTIFIER) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
char s[100];
|
||||
sc.GetCurrent(s, sizeof(s));
|
||||
|
||||
if (leadingAtSign) {
|
||||
if (keywords.InList(s)) {
|
||||
sc.ChangeState(SCE_LOUT_WORD);
|
||||
} else {
|
||||
sc.ChangeState(SCE_LOUT_WORD4);
|
||||
}
|
||||
} else if (firstWordInLine && keywords3.InList(s)) {
|
||||
sc.ChangeState(SCE_LOUT_WORD3);
|
||||
}
|
||||
sc.SetState(SCE_LOUT_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_LOUT_OPERATOR) {
|
||||
if (!IsAnOther(sc.ch)) {
|
||||
char s[100];
|
||||
sc.GetCurrent(s, sizeof(s));
|
||||
|
||||
if (keywords2.InList(s)) {
|
||||
sc.ChangeState(SCE_LOUT_WORD2);
|
||||
}
|
||||
sc.SetState(SCE_LOUT_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if a new state should be entered.
|
||||
if (sc.state == SCE_LOUT_DEFAULT) {
|
||||
if (sc.ch == '#') {
|
||||
sc.SetState(SCE_LOUT_COMMENT);
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.SetState(SCE_LOUT_STRING);
|
||||
} else if (IsADigit(sc.ch) ||
|
||||
(sc.ch == '.' && IsADigit(sc.chNext))) {
|
||||
sc.SetState(SCE_LOUT_NUMBER);
|
||||
} else if (IsAWordChar(sc.ch)) {
|
||||
firstWordInLine = (visibleChars == 0);
|
||||
leadingAtSign = (sc.ch == '@');
|
||||
sc.SetState(SCE_LOUT_IDENTIFIER);
|
||||
} else if (IsAnOther(sc.ch)) {
|
||||
sc.SetState(SCE_LOUT_OPERATOR);
|
||||
}
|
||||
}
|
||||
|
||||
if (sc.atLineEnd) {
|
||||
// Reset states to begining of colourise so no surprises
|
||||
// if different sets of lines lexed.
|
||||
visibleChars = 0;
|
||||
}
|
||||
if (!IsASpace(sc.ch)) {
|
||||
visibleChars++;
|
||||
}
|
||||
}
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
static void FoldLoutDoc(unsigned int startPos, int length, int, WordList *[],
|
||||
Accessor &styler) {
|
||||
|
||||
unsigned int endPos = startPos + length;
|
||||
int visibleChars = 0;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
|
||||
int levelCurrent = levelPrev;
|
||||
char chNext = styler[startPos];
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
int styleNext = styler.StyleAt(startPos);
|
||||
char s[10];
|
||||
|
||||
for (unsigned int i = startPos; i < endPos; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
int style = styleNext;
|
||||
styleNext = styler.StyleAt(i + 1);
|
||||
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
|
||||
if (style == SCE_LOUT_WORD) {
|
||||
if (ch == '@') {
|
||||
for (unsigned int j = 0; j < 8; j++) {
|
||||
if (!IsAWordChar(styler[i + j])) {
|
||||
break;
|
||||
}
|
||||
s[j] = styler[i + j];
|
||||
s[j + 1] = '\0';
|
||||
}
|
||||
if (strcmp(s, "@Begin") == 0) {
|
||||
levelCurrent++;
|
||||
} else if (strcmp(s, "@End") == 0) {
|
||||
levelCurrent--;
|
||||
}
|
||||
}
|
||||
} else if (style == SCE_LOUT_OPERATOR) {
|
||||
if (ch == '{') {
|
||||
levelCurrent++;
|
||||
} else if (ch == '}') {
|
||||
levelCurrent--;
|
||||
}
|
||||
}
|
||||
if (atEOL) {
|
||||
int lev = levelPrev;
|
||||
if (visibleChars == 0 && foldCompact) {
|
||||
lev |= SC_FOLDLEVELWHITEFLAG;
|
||||
}
|
||||
if ((levelCurrent > levelPrev) && (visibleChars > 0)) {
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
}
|
||||
if (lev != styler.LevelAt(lineCurrent)) {
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
lineCurrent++;
|
||||
levelPrev = levelCurrent;
|
||||
visibleChars = 0;
|
||||
}
|
||||
if (!isspacechar(ch))
|
||||
visibleChars++;
|
||||
}
|
||||
// Fill in the real level of the next line, keeping the current flags as they will be filled in later
|
||||
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
|
||||
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
|
||||
}
|
||||
|
||||
static const char * const loutWordLists[] = {
|
||||
"Predefined identifiers",
|
||||
"Predefined delimiters",
|
||||
"Predefined keywords",
|
||||
0,
|
||||
};
|
||||
|
||||
LexerModule lmLout(SCLEX_LOUT, ColouriseLoutDoc, "lout", FoldLoutDoc, loutWordLists);
|
@@ -24,7 +24,7 @@
|
||||
#include "SciLexer.h"
|
||||
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.');
|
||||
}
|
||||
|
||||
inline bool IsAWordStart(const int ch) {
|
||||
@@ -58,6 +58,8 @@ static void ColouriseLuaDoc(
|
||||
WordList &keywords4 = *keywordlists[3];
|
||||
WordList &keywords5 = *keywordlists[4];
|
||||
WordList &keywords6 = *keywordlists[5];
|
||||
WordList &keywords7 = *keywordlists[6];
|
||||
WordList &keywords8 = *keywordlists[7];
|
||||
|
||||
int currentLine = styler.GetLine(startPos);
|
||||
// Initialize the literal string [[ ... ]] nesting level, if we are inside such a string.
|
||||
@@ -121,11 +123,15 @@ static void ColouriseLuaDoc(
|
||||
if (sc.state == SCE_LUA_OPERATOR) {
|
||||
sc.SetState(SCE_LUA_DEFAULT);
|
||||
} else if (sc.state == SCE_LUA_NUMBER) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
sc.SetState(SCE_LUA_DEFAULT);
|
||||
// We stop the number definition on non-numerical non-dot non-eE non-sign char
|
||||
if (!(isdigit(sc.ch) || sc.ch == '.' ||
|
||||
toupper(sc.ch) == 'E' || sc.ch == '-' || sc.ch == '+')) {
|
||||
// Not exactly following number definition (several dots are seen as OK, etc.)
|
||||
// but probably enough in most cases.
|
||||
sc.SetState(SCE_LUA_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_LUA_IDENTIFIER) {
|
||||
if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
char s[100];
|
||||
sc.GetCurrent(s, sizeof(s));
|
||||
if (keywords.InList(s)) {
|
||||
@@ -140,6 +146,12 @@ static void ColouriseLuaDoc(
|
||||
sc.ChangeState(SCE_LUA_WORD5);
|
||||
} else if (keywords6.InList(s)) {
|
||||
sc.ChangeState(SCE_LUA_WORD6);
|
||||
} else if (keywords6.InList(s)) {
|
||||
sc.ChangeState(SCE_LUA_WORD6);
|
||||
} else if (keywords7.InList(s)) {
|
||||
sc.ChangeState(SCE_LUA_WORD7);
|
||||
} else if (keywords8.InList(s)) {
|
||||
sc.ChangeState(SCE_LUA_WORD8);
|
||||
}
|
||||
sc.SetState(SCE_LUA_DEFAULT);
|
||||
}
|
||||
@@ -300,8 +312,8 @@ static void FoldLuaDoc(unsigned int startPos, int length, int /* initStyle */, W
|
||||
static const char * const luaWordListDesc[] = {
|
||||
"Keywords",
|
||||
"Basic functions",
|
||||
"String & math functions",
|
||||
"I/O & system facilities",
|
||||
"String, (table) & math functions",
|
||||
"(coroutines), I/O & system facilities",
|
||||
"XXX",
|
||||
"XXX",
|
||||
0
|
||||
|
183
contrib/src/stc/scintilla/src/LexMMIXAL.cxx
Normal file
183
contrib/src/stc/scintilla/src/LexMMIXAL.cxx
Normal file
@@ -0,0 +1,183 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file LexMMIXAL.cxx
|
||||
** Lexer for MMIX Assembler Language.
|
||||
** Written by Christoph H<>sler <christoph.hoesler@student.uni-tuebingen.de>
|
||||
** For information about MMIX visit http://www-cs-faculty.stanford.edu/~knuth/mmix.html
|
||||
**/
|
||||
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "StyleContext.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
|
||||
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == ':' || ch == '_');
|
||||
}
|
||||
|
||||
inline bool isMMIXALOperator(char ch) {
|
||||
if (isalnum(ch))
|
||||
return false;
|
||||
if (ch == '+' || ch == '-' || ch == '|' || ch == '^' ||
|
||||
ch == '*' || ch == '/' || ch == '/' ||
|
||||
ch == '%' || ch == '<' || ch == '>' || ch == '&' ||
|
||||
ch == '~' || ch == '$' ||
|
||||
ch == ',' || ch == '(' || ch == ')' ||
|
||||
ch == '[' || ch == ']')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void ColouriseMMIXALDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
|
||||
WordList &opcodes = *keywordlists[0];
|
||||
WordList &special_register = *keywordlists[1];
|
||||
WordList &predef_symbols = *keywordlists[2];
|
||||
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
|
||||
for (; sc.More(); sc.Forward())
|
||||
{
|
||||
// No EOL continuation
|
||||
if (sc.atLineStart) {
|
||||
if (sc.ch == '@' && sc.chNext == 'i') {
|
||||
sc.SetState(SCE_MMIXAL_INCLUDE);
|
||||
} else {
|
||||
sc.SetState(SCE_MMIXAL_LEADWS);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if first non whitespace character in line is alphanumeric
|
||||
if (sc.state == SCE_MMIXAL_LEADWS && !isspace(sc.ch)) { // LEADWS
|
||||
if(!IsAWordChar(sc.ch)) {
|
||||
sc.SetState(SCE_MMIXAL_COMMENT);
|
||||
} else {
|
||||
if(sc.atLineStart) {
|
||||
sc.SetState(SCE_MMIXAL_LABEL);
|
||||
} else {
|
||||
sc.SetState(SCE_MMIXAL_OPCODE_PRE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if the current state should terminate.
|
||||
if (sc.state == SCE_MMIXAL_OPERATOR) { // OPERATOR
|
||||
sc.SetState(SCE_MMIXAL_OPERANDS);
|
||||
} else if (sc.state == SCE_MMIXAL_NUMBER) { // NUMBER
|
||||
if (!isdigit(sc.ch)) {
|
||||
if (IsAWordChar(sc.ch)) {
|
||||
char s[100];
|
||||
sc.GetCurrent(s, sizeof(s));
|
||||
sc.ChangeState(SCE_MMIXAL_REF);
|
||||
sc.SetState(SCE_MMIXAL_REF);
|
||||
} else {
|
||||
sc.SetState(SCE_MMIXAL_OPERANDS);
|
||||
}
|
||||
}
|
||||
} else if (sc.state == SCE_MMIXAL_LABEL) { // LABEL
|
||||
if (!IsAWordChar(sc.ch) ) {
|
||||
sc.SetState(SCE_MMIXAL_OPCODE_PRE);
|
||||
}
|
||||
} else if (sc.state == SCE_MMIXAL_REF) { // REF
|
||||
if (!IsAWordChar(sc.ch) ) {
|
||||
char s[100];
|
||||
sc.GetCurrent(s, sizeof(s));
|
||||
if (*s == ':') { // ignore base prefix for match
|
||||
for (size_t i = 0; i != sizeof(s); ++i) {
|
||||
*(s+i) = *(s+i+1);
|
||||
}
|
||||
}
|
||||
if (special_register.InList(s)) {
|
||||
sc.ChangeState(SCE_MMIXAL_REGISTER);
|
||||
} else if (predef_symbols.InList(s)) {
|
||||
sc.ChangeState(SCE_MMIXAL_SYMBOL);
|
||||
}
|
||||
sc.SetState(SCE_MMIXAL_OPERANDS);
|
||||
}
|
||||
} else if (sc.state == SCE_MMIXAL_OPCODE_PRE) { // OPCODE_PRE
|
||||
if (!isspace(sc.ch)) {
|
||||
sc.SetState(SCE_MMIXAL_OPCODE);
|
||||
}
|
||||
} else if (sc.state == SCE_MMIXAL_OPCODE) { // OPCODE
|
||||
if (!IsAWordChar(sc.ch) ) {
|
||||
char s[100];
|
||||
sc.GetCurrent(s, sizeof(s));
|
||||
if (opcodes.InList(s)) {
|
||||
sc.ChangeState(SCE_MMIXAL_OPCODE_VALID);
|
||||
} else {
|
||||
sc.ChangeState(SCE_MMIXAL_OPCODE_UNKNOWN);
|
||||
}
|
||||
sc.SetState(SCE_MMIXAL_OPCODE_POST);
|
||||
}
|
||||
} else if (sc.state == SCE_MMIXAL_STRING) { // STRING
|
||||
if (sc.ch == '\"') {
|
||||
sc.ForwardSetState(SCE_MMIXAL_OPERANDS);
|
||||
} else if (sc.atLineEnd) {
|
||||
sc.ForwardSetState(SCE_MMIXAL_OPERANDS);
|
||||
}
|
||||
} else if (sc.state == SCE_MMIXAL_CHAR) { // CHAR
|
||||
if (sc.ch == '\'') {
|
||||
sc.ForwardSetState(SCE_MMIXAL_OPERANDS);
|
||||
} else if (sc.atLineEnd) {
|
||||
sc.ForwardSetState(SCE_MMIXAL_OPERANDS);
|
||||
}
|
||||
} else if (sc.state == SCE_MMIXAL_REGISTER) { // REGISTER
|
||||
if (!isdigit(sc.ch)) {
|
||||
sc.SetState(SCE_MMIXAL_OPERANDS);
|
||||
}
|
||||
} else if (sc.state == SCE_MMIXAL_HEX) { // HEX
|
||||
if (!isxdigit(sc.ch)) {
|
||||
sc.SetState(SCE_MMIXAL_OPERANDS);
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if a new state should be entered.
|
||||
if (sc.state == SCE_MMIXAL_OPCODE_POST || // OPCODE_POST
|
||||
sc.state == SCE_MMIXAL_OPERANDS) { // OPERANDS
|
||||
if (sc.state == SCE_MMIXAL_OPERANDS && isspace(sc.ch)) {
|
||||
if (!sc.atLineEnd) {
|
||||
sc.SetState(SCE_MMIXAL_COMMENT);
|
||||
}
|
||||
} else if (isdigit(sc.ch)) {
|
||||
sc.SetState(SCE_MMIXAL_NUMBER);
|
||||
} else if (IsAWordChar(sc.ch) || sc.Match('@')) {
|
||||
sc.SetState(SCE_MMIXAL_REF);
|
||||
} else if (sc.Match('\"')) {
|
||||
sc.SetState(SCE_MMIXAL_STRING);
|
||||
} else if (sc.Match('\'')) {
|
||||
sc.SetState(SCE_MMIXAL_CHAR);
|
||||
} else if (sc.Match('$')) {
|
||||
sc.SetState(SCE_MMIXAL_REGISTER);
|
||||
} else if (sc.Match('#')) {
|
||||
sc.SetState(SCE_MMIXAL_HEX);
|
||||
} else if (isMMIXALOperator(static_cast<char>(sc.ch))) {
|
||||
sc.SetState(SCE_MMIXAL_OPERATOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
static const char * const MMIXALWordListDesc[] = {
|
||||
"Operation Codes",
|
||||
"Special Register",
|
||||
"Predefined Symbols",
|
||||
0
|
||||
};
|
||||
|
||||
LexerModule lmMMIXAL(SCLEX_MMIXAL, ColouriseMMIXALDoc, "mmixal", 0, MMIXALWordListDesc);
|
||||
|
346
contrib/src/stc/scintilla/src/LexNsis.cxx
Normal file
346
contrib/src/stc/scintilla/src/LexNsis.cxx
Normal file
@@ -0,0 +1,346 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file LexNsis.cxx
|
||||
** Lexer for NSIS
|
||||
**/
|
||||
// Copyright 2003 by Angelo Mandato <angelo@spaceblue.com>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
/*
|
||||
// Put in SciLexer.h
|
||||
#define SCLEX_NSIS 34
|
||||
|
||||
#define SCE_NSIS_DEFAULT 0
|
||||
#define SCE_NSIS_COMMENT 1
|
||||
#define SCE_NSIS_STRINGDQ 2
|
||||
#define SCE_NSIS_STRINGLQ 3
|
||||
#define SCE_NSIS_STRINGRQ 4
|
||||
#define SCE_NSIS_FUNCTION 5
|
||||
#define SCE_NSIS_VARIABLE 6
|
||||
#define SCE_NSIS_LABEL 7
|
||||
#define SCE_NSIS_USERDEFINED 8
|
||||
#define SCE_NSIS_SECTIONDEF 9
|
||||
#define SCE_NSIS_SUBSECTIONDEF 10
|
||||
#define SCE_NSIS_IFDEFINEDEF 11
|
||||
#define SCE_NSIS_MACRODEF 12
|
||||
#define SCE_NSIS_STRINGVAR 13
|
||||
*/
|
||||
|
||||
static int classifyWordNsis(unsigned int start, unsigned int end, WordList *keywordLists[], Accessor &styler)
|
||||
{
|
||||
char s[100];
|
||||
|
||||
WordList &Functions = *keywordLists[0];
|
||||
WordList &Variables = *keywordLists[1];
|
||||
WordList &Lables = *keywordLists[2];
|
||||
WordList &UserDefined = *keywordLists[3];
|
||||
|
||||
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++)
|
||||
{
|
||||
s[i] = static_cast<char>( styler[ start + i ] );
|
||||
s[i + 1] = '\0';
|
||||
}
|
||||
|
||||
// Check for special words...
|
||||
|
||||
if( strcmp(s, "!macro") == 0 || strcmp(s, "!macroend") == 0 ) // Covers !micro and !microend
|
||||
return SCE_NSIS_MACRODEF;
|
||||
|
||||
if( strcmp(s, "!ifdef") == 0 || strcmp(s, "!ifndef") == 0 || strcmp(s, "!endif") == 0 )
|
||||
return SCE_NSIS_IFDEFINEDEF;
|
||||
|
||||
if( strcmp(s, "Section") == 0 || strcmp(s, "SectionEnd") == 0 ) // Covers Section and SectionEnd
|
||||
return SCE_NSIS_SECTIONDEF;
|
||||
|
||||
if( strcmp(s, "SubSection") == 0 || strcmp(s, "SubSectionEnd") == 0 ) // Covers SubSection and SubSectionEnd
|
||||
return SCE_NSIS_SUBSECTIONDEF;
|
||||
|
||||
if( strcmp(s, "Function") == 0 || strcmp(s, "FunctionEnd") == 0 ) // Covers SubSection and SubSectionEnd
|
||||
return SCE_NSIS_FUNCTION;
|
||||
|
||||
if ( Functions.InList(s) )
|
||||
return SCE_NSIS_FUNCTION;
|
||||
|
||||
if ( Variables.InList(s) )
|
||||
return SCE_NSIS_VARIABLE;
|
||||
|
||||
if ( Lables.InList(s) )
|
||||
return SCE_NSIS_LABEL;
|
||||
|
||||
if( UserDefined.InList(s) )
|
||||
return SCE_NSIS_USERDEFINED;
|
||||
|
||||
if( strlen(s) > 2 )
|
||||
{
|
||||
if( s[1] == '{' && s[strlen(s)-1] == '}' )
|
||||
return SCE_NSIS_VARIABLE;
|
||||
}
|
||||
|
||||
return SCE_NSIS_DEFAULT;
|
||||
}
|
||||
|
||||
static void ColouriseNsisDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler)
|
||||
{
|
||||
int state = SCE_NSIS_DEFAULT;
|
||||
styler.StartAt( startPos );
|
||||
styler.GetLine( startPos );
|
||||
|
||||
unsigned int nLengthDoc = startPos + length;
|
||||
styler.StartSegment( startPos );
|
||||
|
||||
char cCurrChar;
|
||||
bool bVarInString = true;
|
||||
|
||||
unsigned int i;
|
||||
for( i = startPos; i < nLengthDoc; i++ )
|
||||
{
|
||||
cCurrChar = styler.SafeGetCharAt( i );
|
||||
char cNextChar = styler.SafeGetCharAt( i+1, EOF );
|
||||
|
||||
|
||||
|
||||
switch(state)
|
||||
{
|
||||
case SCE_NSIS_DEFAULT:
|
||||
if( cNextChar == EOF )
|
||||
{
|
||||
styler.ColourTo(i,SCE_NSIS_DEFAULT);
|
||||
break;
|
||||
}
|
||||
if( cCurrChar == ';' || cCurrChar == '#' ) // we have a comment line
|
||||
{
|
||||
styler.ColourTo(i-1, state );
|
||||
state = SCE_NSIS_COMMENT;
|
||||
break;
|
||||
}
|
||||
if( cCurrChar == '"' )
|
||||
{
|
||||
styler.ColourTo(i-1, state );
|
||||
state = SCE_NSIS_STRINGDQ;
|
||||
bVarInString = false;
|
||||
break;
|
||||
}
|
||||
if( cCurrChar == '\'' )
|
||||
{
|
||||
styler.ColourTo(i-1, state );
|
||||
state = SCE_NSIS_STRINGRQ;
|
||||
bVarInString = false;
|
||||
break;
|
||||
}
|
||||
if( cCurrChar == '`' )
|
||||
{
|
||||
styler.ColourTo(i-1, state );
|
||||
state = SCE_NSIS_STRINGLQ;
|
||||
bVarInString = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// NSIS KeyWord,Function, Variable, UserDefined:
|
||||
if( cCurrChar == '$' || iswordchar(cCurrChar) || cCurrChar == '!' )
|
||||
{
|
||||
styler.ColourTo(i-1,state);
|
||||
state = SCE_NSIS_FUNCTION;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SCE_NSIS_COMMENT:
|
||||
if( cNextChar == '\n' || cNextChar == '\r' || cNextChar == EOF )
|
||||
{
|
||||
styler.ColourTo(i,state);
|
||||
state = SCE_NSIS_DEFAULT;
|
||||
}
|
||||
break;
|
||||
case SCE_NSIS_STRINGDQ:
|
||||
if( cCurrChar == '"' || cNextChar == '\r' || cNextChar == '\n' )
|
||||
{
|
||||
styler.ColourTo(i,SCE_NSIS_STRINGDQ);
|
||||
state = SCE_NSIS_DEFAULT;
|
||||
}
|
||||
break;
|
||||
case SCE_NSIS_STRINGLQ:
|
||||
if( cCurrChar == '`' || cNextChar == '\r' || cNextChar == '\n' )
|
||||
{
|
||||
styler.ColourTo(i,SCE_NSIS_STRINGLQ);
|
||||
state = SCE_NSIS_DEFAULT;
|
||||
}
|
||||
break;
|
||||
case SCE_NSIS_STRINGRQ:
|
||||
if( cCurrChar == '\'' || cNextChar == '\r' || cNextChar == '\n' )
|
||||
{
|
||||
styler.ColourTo(i,SCE_NSIS_STRINGRQ);
|
||||
state = SCE_NSIS_DEFAULT;
|
||||
}
|
||||
break;
|
||||
case SCE_NSIS_FUNCTION:
|
||||
|
||||
// NSIS KeyWord:
|
||||
if( (iswordchar(cCurrChar) && !iswordchar( cNextChar) && cNextChar != '}') || cCurrChar == '}' )
|
||||
{
|
||||
state = classifyWordNsis( styler.GetStartSegment(), i, keywordLists, styler);
|
||||
styler.ColourTo( i, state);
|
||||
state = SCE_NSIS_DEFAULT; // Everything after goes back to the default state
|
||||
}
|
||||
else if( !iswordchar( cCurrChar ) && cCurrChar != '{' && cCurrChar != '}' )
|
||||
{
|
||||
state = SCE_NSIS_DEFAULT;
|
||||
|
||||
if( cCurrChar == '"' ) // Next
|
||||
{
|
||||
state = SCE_NSIS_STRINGDQ;
|
||||
bVarInString = false;
|
||||
}
|
||||
if( cCurrChar == '`' )
|
||||
{
|
||||
state = SCE_NSIS_STRINGLQ;
|
||||
bVarInString = false;
|
||||
}
|
||||
if( cCurrChar == '\'' )
|
||||
{
|
||||
state = SCE_NSIS_STRINGRQ;
|
||||
bVarInString = false;
|
||||
}
|
||||
if( cCurrChar == '#' || cCurrChar == ';' )
|
||||
state = SCE_NSIS_COMMENT;
|
||||
|
||||
styler.ColourTo( i, state);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if( state == SCE_NSIS_COMMENT )
|
||||
{
|
||||
styler.ColourTo(i,state);
|
||||
}
|
||||
else if( state == SCE_NSIS_STRINGDQ || state == SCE_NSIS_STRINGLQ || state == SCE_NSIS_STRINGRQ )
|
||||
{
|
||||
// Check for var in String..
|
||||
if( bVarInString && (iswordchar(cCurrChar) || cCurrChar == '}') ) // || cCurrChar == '{' ) )
|
||||
{
|
||||
int nWordState = classifyWordNsis( styler.GetStartSegment(), i, keywordLists, styler);
|
||||
if( nWordState == SCE_NSIS_VARIABLE )
|
||||
{
|
||||
styler.ColourTo( i, SCE_NSIS_STRINGVAR);
|
||||
bVarInString = false;
|
||||
}
|
||||
}
|
||||
if( cCurrChar == '$' )
|
||||
{
|
||||
styler.ColourTo( i-1, state);
|
||||
bVarInString = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void FoldNsisDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
|
||||
{
|
||||
// No folding enabled, no reason to continue...
|
||||
if( styler.GetPropertyInt("fold") == 0 )
|
||||
return;
|
||||
|
||||
unsigned int endPos = startPos + length;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int levelCurrent = SC_FOLDLEVELBASE;
|
||||
if (lineCurrent > 0)
|
||||
levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
|
||||
int levelNext = levelCurrent;
|
||||
char chNext = styler[startPos];
|
||||
int styleNext = styler.StyleAt(startPos);
|
||||
int style;
|
||||
|
||||
for (unsigned int i = startPos; i < endPos; i++)
|
||||
{
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
style = styleNext;
|
||||
styleNext = styler.StyleAt(i + 1);
|
||||
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
// Functions Start: Function, Section, SubSection
|
||||
// Functions End: FunctionEnd, SectionEnd, SubSectionEnd
|
||||
// Label Start: !ifdef, !ifndef
|
||||
// Label End: !endif
|
||||
|
||||
if( style == SCE_NSIS_FUNCTION )
|
||||
{
|
||||
if( styler.Match(i, "FunctionEnd") )
|
||||
levelNext--;
|
||||
else if( styler.Match(i, "Function") )
|
||||
levelNext++;
|
||||
}
|
||||
else if( style == SCE_NSIS_SECTIONDEF )
|
||||
{
|
||||
if( styler.Match(i, "SectionEnd") )
|
||||
levelNext--;
|
||||
else if( styler.Match(i, "Section") )
|
||||
levelNext++;
|
||||
}
|
||||
else if( style == SCE_NSIS_SUBSECTIONDEF )
|
||||
{
|
||||
if( styler.Match(i, "SubSectionEnd") )
|
||||
levelNext--;
|
||||
else if( styler.Match(i, "SubSection") )
|
||||
levelNext++;
|
||||
}
|
||||
else if( style == SCE_NSIS_IFDEFINEDEF )
|
||||
{
|
||||
if( styler.Match(i, "!endif") )
|
||||
levelNext--;
|
||||
else if( styler.Match(i, "!ifdef") || styler.Match(i, "!ifndef"))
|
||||
levelNext++;
|
||||
}
|
||||
else if( style == SCE_NSIS_MACRODEF )
|
||||
{
|
||||
if( styler.Match(i, "!macroend") )
|
||||
levelNext--;
|
||||
else if( styler.Match(i, "!macro") )
|
||||
levelNext++;
|
||||
}
|
||||
|
||||
if( atEOL )
|
||||
{
|
||||
int levelUse = levelCurrent;
|
||||
int lev = levelUse | levelNext << 16;
|
||||
if (levelUse < levelNext)
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
if (lev != styler.LevelAt(lineCurrent))
|
||||
{
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
lineCurrent++;
|
||||
levelCurrent = levelNext;
|
||||
}
|
||||
}
|
||||
|
||||
int levelUse = levelCurrent;
|
||||
int lev = levelUse | levelNext << 16;
|
||||
if (levelUse < levelNext)
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
if (lev != styler.LevelAt(lineCurrent))
|
||||
{
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
}
|
||||
|
||||
static const char * const nsisWordLists[] = {
|
||||
"Functions",
|
||||
"Variables",
|
||||
"Lables",
|
||||
"UserDefined",
|
||||
0, };
|
||||
|
||||
|
||||
LexerModule lmNsis(SCLEX_NSIS, ColouriseNsisDoc, "nsis", FoldNsisDoc, nsisWordLists);
|
@@ -268,6 +268,59 @@ static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList *
|
||||
}
|
||||
}
|
||||
|
||||
// adaption by ksc, using the "} else {" trick of 1.53
|
||||
// 030721
|
||||
static void FoldPropsDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
|
||||
unsigned int endPos = startPos + length;
|
||||
int visibleChars = 0;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
|
||||
char chNext = styler[startPos];
|
||||
int styleNext = styler.StyleAt(startPos);
|
||||
bool headerPoint = false;
|
||||
|
||||
for (unsigned int i = startPos; i < endPos; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler[i+1];
|
||||
|
||||
int style = styleNext;
|
||||
styleNext = styler.StyleAt(i + 1);
|
||||
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
|
||||
if (style==2) {
|
||||
headerPoint = true;
|
||||
}
|
||||
|
||||
if (atEOL) {
|
||||
int lev = SC_FOLDLEVELBASE+1;
|
||||
if (headerPoint)
|
||||
lev = SC_FOLDLEVELBASE;
|
||||
|
||||
if (visibleChars == 0 && foldCompact)
|
||||
lev |= SC_FOLDLEVELWHITEFLAG;
|
||||
|
||||
if (headerPoint)
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
|
||||
if (lev != styler.LevelAt(lineCurrent)) {
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
|
||||
lineCurrent++;
|
||||
visibleChars = 0;
|
||||
headerPoint=false;
|
||||
}
|
||||
if (!isspacechar(ch))
|
||||
visibleChars++;
|
||||
}
|
||||
|
||||
int lev = headerPoint ? SC_FOLDLEVELBASE : SC_FOLDLEVELBASE+1;
|
||||
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
|
||||
styler.SetLevel(lineCurrent, lev | flagsNext);
|
||||
}
|
||||
|
||||
static void ColouriseMakeLine(
|
||||
char *lineBuffer,
|
||||
unsigned int lengthLine,
|
||||
@@ -626,9 +679,20 @@ static const char * const emptyWordListDesc[] = {
|
||||
0
|
||||
};
|
||||
|
||||
static void ColouriseNullDoc(unsigned int startPos, int length, int, WordList *[],
|
||||
Accessor &styler) {
|
||||
// Null language means all style bytes are 0 so just mark the end - no need to fill in.
|
||||
if (length > 0) {
|
||||
styler.StartAt(startPos + length - 1);
|
||||
styler.StartSegment(startPos + length - 1);
|
||||
styler.ColourTo(startPos + length - 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc, "batch", 0, batchWordListDesc);
|
||||
LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc, "diff", 0, emptyWordListDesc);
|
||||
LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc, "props", 0, emptyWordListDesc);
|
||||
LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc, "props", FoldPropsDoc, emptyWordListDesc);
|
||||
LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc, "makefile", 0, emptyWordListDesc);
|
||||
LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc, "errorlist", 0, emptyWordListDesc);
|
||||
LexerModule lmLatex(SCLEX_LATEX, ColouriseLatexDoc, "latex", 0, emptyWordListDesc);
|
||||
LexerModule lmNull(SCLEX_NULL, ColouriseNullDoc, "null");
|
||||
|
@@ -1,10 +1,19 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file LexPOV.cxx
|
||||
** Lexer for POV-Ray, based on lexer for C++.
|
||||
** Lexer for POV-Ray SDL (Persistance of Vision Raytracer, Scene Description Language).
|
||||
** Written by Philippe Lhoste but this is mostly a derivative of LexCPP...
|
||||
**/
|
||||
// Copyright 2003 by Steven te Brinke <steven.t.b@zonnet.nl>
|
||||
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
// Some points that distinguish from a simple C lexer:
|
||||
// Identifiers start only by a character.
|
||||
// No line continuation character.
|
||||
// Strings are limited to 256 characters.
|
||||
// Directives are similar to preprocessor commands,
|
||||
// but we match directive keywords and colorize incorrect ones.
|
||||
// Block comments can be nested (code stolen from my code in LexLua).
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
@@ -20,101 +29,152 @@
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
#define KEYWORD_BOXHEADER 1
|
||||
#define KEYWORD_FOLDCONTRACTED 2
|
||||
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
|
||||
return ch < 0x80 && (isalnum(ch) || ch == '_');
|
||||
}
|
||||
|
||||
static inline bool IsAWordStart(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_');
|
||||
inline bool IsAWordStart(const int ch) {
|
||||
return ch < 0x80 && isalpha(ch);
|
||||
}
|
||||
|
||||
static inline bool IsStateComment(const int state) {
|
||||
return ((state == SCE_POV_COMMENT) ||
|
||||
(state == SCE_POV_COMMENTLINE) ||
|
||||
(state == SCE_POV_COMMENTDOC));
|
||||
}
|
||||
static void ColourisePovDoc(
|
||||
unsigned int startPos,
|
||||
int length,
|
||||
int initStyle,
|
||||
WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
|
||||
static inline bool IsStateString(const int state) {
|
||||
return ((state == SCE_POV_STRING));
|
||||
}
|
||||
|
||||
static void ColourisePOVDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
WordList &keywords1 = *keywordlists[0];
|
||||
WordList &keywords2 = *keywordlists[1];
|
||||
WordList &keywords3 = *keywordlists[2];
|
||||
WordList &keywords4 = *keywordlists[3];
|
||||
WordList &keywords5 = *keywordlists[4];
|
||||
WordList &keywords6 = *keywordlists[5];
|
||||
WordList &keywords7 = *keywordlists[6];
|
||||
WordList &keywords8 = *keywordlists[7];
|
||||
|
||||
int currentLine = styler.GetLine(startPos);
|
||||
// Initialize the block comment /* */ nesting level, if we are inside such a comment.
|
||||
int blockCommentLevel = 0;
|
||||
if (initStyle == SCE_POV_COMMENT) {
|
||||
blockCommentLevel = styler.GetLineState(currentLine - 1);
|
||||
}
|
||||
|
||||
// Do not leak onto next line
|
||||
/*if (initStyle == SCE_POV_STRINGEOL)
|
||||
initStyle = SCE_POV_DEFAULT;*/
|
||||
if (initStyle == SCE_POV_STRINGEOL) {
|
||||
initStyle = SCE_POV_DEFAULT;
|
||||
}
|
||||
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
|
||||
bool caseSensitive = styler.GetPropertyInt("pov.case.sensitive", 1) != 0;
|
||||
short stringLen = 0;
|
||||
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
|
||||
/*if (sc.atLineStart && (sc.state == SCE_POV_STRING)) {
|
||||
// Prevent SCE_POV_STRINGEOL from leaking back to previous line
|
||||
sc.SetState(SCE_POV_STRING);
|
||||
}*/
|
||||
|
||||
// Handle line continuation generically.
|
||||
if (sc.ch == '\\') {
|
||||
if (sc.chNext == '\n' || sc.chNext == '\r') {
|
||||
sc.Forward();
|
||||
if (sc.ch == '\r' && sc.chNext == '\n') {
|
||||
sc.Forward();
|
||||
}
|
||||
continue;
|
||||
if (sc.atLineEnd) {
|
||||
// Update the line state, so it can be seen by next line
|
||||
currentLine = styler.GetLine(sc.currentPos);
|
||||
if (sc.state == SCE_POV_COMMENT) {
|
||||
// Inside a block comment, we set the line state
|
||||
styler.SetLineState(currentLine, blockCommentLevel);
|
||||
} else {
|
||||
// Reset the line state
|
||||
styler.SetLineState(currentLine, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (sc.atLineStart && (sc.state == SCE_POV_STRING)) {
|
||||
// Prevent SCE_POV_STRINGEOL from leaking back to previous line
|
||||
sc.SetState(SCE_POV_STRING);
|
||||
}
|
||||
|
||||
// Determine if the current state should terminate.
|
||||
if (sc.state == SCE_POV_OPERATOR || sc.state == SCE_POV_BRACE) {
|
||||
if (sc.state == SCE_POV_OPERATOR) {
|
||||
sc.SetState(SCE_POV_DEFAULT);
|
||||
} else if (sc.state == SCE_POV_NUMBER) {
|
||||
if (!IsADigit(sc.ch) || sc.ch != '.') {
|
||||
sc.SetState(SCE_POV_DEFAULT);
|
||||
// We stop the number definition on non-numerical non-dot non-eE non-sign char
|
||||
if (!(isdigit(sc.ch) || sc.ch == '.' ||
|
||||
toupper(sc.ch) == 'E' || sc.ch == '-' || sc.ch == '+')) {
|
||||
// Not exactly following number definition (several dots are seen as OK, etc.)
|
||||
// but probably enough in most cases.
|
||||
sc.SetState(SCE_POV_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_POV_IDENTIFIER) {
|
||||
if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
char s[100];
|
||||
if (caseSensitive) {
|
||||
sc.GetCurrent(s, sizeof(s));
|
||||
} else {
|
||||
sc.GetCurrentLowered(s, sizeof(s));
|
||||
}
|
||||
if (keywords.InList(s)) {
|
||||
sc.ChangeState(SCE_POV_WORD);
|
||||
} else if (keywords2.InList(s)) {
|
||||
sc.GetCurrent(s, sizeof(s));
|
||||
if (keywords2.InList(s)) {
|
||||
sc.ChangeState(SCE_POV_WORD2);
|
||||
} else if (keywords3.InList(s)) {
|
||||
sc.ChangeState(SCE_POV_WORD3);
|
||||
} else if (keywords4.InList(s)) {
|
||||
sc.ChangeState(SCE_POV_WORD4);
|
||||
} else if (keywords5.InList(s)) {
|
||||
sc.ChangeState(SCE_POV_WORD5);
|
||||
} else if (keywords6.InList(s)) {
|
||||
sc.ChangeState(SCE_POV_WORD6);
|
||||
} else if (keywords7.InList(s)) {
|
||||
sc.ChangeState(SCE_POV_WORD7);
|
||||
} else if (keywords8.InList(s)) {
|
||||
sc.ChangeState(SCE_POV_WORD8);
|
||||
}
|
||||
sc.SetState(SCE_POV_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_POV_DIRECTIVE) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
char s[100], *p;
|
||||
sc.GetCurrent(s, sizeof(s));
|
||||
p = s;
|
||||
// Skip # and whitespace between # and directive word
|
||||
do {
|
||||
p++;
|
||||
} while ((*p == ' ' || *p == '\t') && *p != '\0');
|
||||
if (!keywords1.InList(p)) {
|
||||
sc.ChangeState(SCE_POV_BADDIRECTIVE);
|
||||
}
|
||||
sc.SetState(SCE_POV_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_POV_COMMENT) {
|
||||
if (sc.Match('*', '/')) {
|
||||
if (sc.Match('/', '*')) {
|
||||
blockCommentLevel++;
|
||||
sc.Forward();
|
||||
sc.ForwardSetState(SCE_POV_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_POV_COMMENTDOC) {
|
||||
if (sc.Match('*', '/')) {
|
||||
} else if (sc.Match('*', '/') && blockCommentLevel > 0) {
|
||||
blockCommentLevel--;
|
||||
sc.Forward();
|
||||
sc.ForwardSetState(SCE_POV_DEFAULT);
|
||||
if (blockCommentLevel == 0) {
|
||||
sc.ForwardSetState(SCE_POV_DEFAULT);
|
||||
}
|
||||
}
|
||||
} else if (sc.state == SCE_POV_COMMENTLINE) {
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_POV_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_POV_STRING) {
|
||||
if (sc.ch == '\\') {
|
||||
stringLen++;
|
||||
if (strchr("abfnrtuv0'\"", sc.chNext)) {
|
||||
// Compound characters are counted as one.
|
||||
// Note: for Unicode chars \u, we shouldn't count the next 4 digits...
|
||||
sc.Forward();
|
||||
}
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.ForwardSetState(SCE_POV_DEFAULT);
|
||||
} else if (sc.atLineEnd) {
|
||||
sc.ChangeState(SCE_POV_STRINGEOL);
|
||||
sc.ForwardSetState(SCE_POV_DEFAULT);
|
||||
} else {
|
||||
stringLen++;
|
||||
}
|
||||
if (stringLen > 256) {
|
||||
// Strings are limited to 256 chars
|
||||
sc.SetState(SCE_POV_STRINGEOL);
|
||||
}
|
||||
} else if (sc.state == SCE_POV_STRINGEOL) {
|
||||
if (sc.ch == '\\') {
|
||||
if (sc.chNext == '\"' || sc.chNext == '\\') {
|
||||
sc.Forward();
|
||||
}
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.ForwardSetState(SCE_C_DEFAULT);
|
||||
} else if (sc.atLineEnd) {
|
||||
sc.ForwardSetState(SCE_POV_DEFAULT);
|
||||
}
|
||||
}
|
||||
@@ -123,35 +183,43 @@ static void ColourisePOVDoc(unsigned int startPos, int length, int initStyle, Wo
|
||||
if (sc.state == SCE_POV_DEFAULT) {
|
||||
if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
|
||||
sc.SetState(SCE_POV_NUMBER);
|
||||
} else if (IsAWordStart(sc.ch) || (sc.ch == '#')) {
|
||||
} else if (IsAWordStart(sc.ch)) {
|
||||
sc.SetState(SCE_POV_IDENTIFIER);
|
||||
} else if (sc.Match('/', '*')) {
|
||||
blockCommentLevel = 1;
|
||||
sc.SetState(SCE_POV_COMMENT);
|
||||
sc.Forward(); // Eat the * so it isn't used for the end of the comment
|
||||
} else if (sc.Match('/', '/')) {
|
||||
sc.SetState(SCE_POV_COMMENTLINE);
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.SetState(SCE_POV_STRING);
|
||||
//} else if (isoperator(static_cast<char>(sc.ch))) {
|
||||
} else if (sc.ch == '+' || sc.ch == '-' || sc.ch == '*' || sc.ch == '/' || sc.ch == '=' || sc.ch == '<' || sc.ch == '>' || sc.ch == '&' || sc.ch == '|' || sc.ch == '!' || sc.ch == '?' || sc.ch == ':') {
|
||||
stringLen = 0;
|
||||
} else if (sc.ch == '#') {
|
||||
sc.SetState(SCE_POV_DIRECTIVE);
|
||||
// Skip whitespace between # and directive word
|
||||
do {
|
||||
sc.Forward();
|
||||
} while ((sc.ch == ' ' || sc.ch == '\t') && sc.More());
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_POV_DEFAULT);
|
||||
}
|
||||
} else if (isoperator(static_cast<char>(sc.ch))) {
|
||||
sc.SetState(SCE_POV_OPERATOR);
|
||||
} else if (sc.ch == '{' || sc.ch == '}') {
|
||||
sc.SetState(SCE_POV_BRACE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
static bool IsStreamCommentStyle(int style) {
|
||||
return style == SCE_POV_COMMENT ||
|
||||
style == SCE_POV_COMMENTDOC;
|
||||
}
|
||||
static void FoldPovDoc(
|
||||
unsigned int startPos,
|
||||
int length,
|
||||
int initStyle,
|
||||
WordList *[],
|
||||
Accessor &styler) {
|
||||
|
||||
static void FoldNoBoxPOVDoc(unsigned int startPos, int length, int initStyle,
|
||||
Accessor &styler) {
|
||||
bool foldComment = styler.GetPropertyInt("fold.comment", 1) != 0;
|
||||
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
|
||||
bool foldDirective = styler.GetPropertyInt("fold.directive") != 0;
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
unsigned int endPos = startPos + length;
|
||||
int visibleChars = 0;
|
||||
@@ -168,15 +236,33 @@ static void FoldNoBoxPOVDoc(unsigned int startPos, int length, int initStyle,
|
||||
style = styleNext;
|
||||
styleNext = styler.StyleAt(i + 1);
|
||||
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
if (foldComment && IsStreamCommentStyle(style)) {
|
||||
if (!IsStreamCommentStyle(stylePrev)) {
|
||||
if (foldComment && (style == SCE_POV_COMMENT)) {
|
||||
if (stylePrev != SCE_POV_COMMENT) {
|
||||
levelCurrent++;
|
||||
} else if (!IsStreamCommentStyle(styleNext) && !atEOL) {
|
||||
} else if ((styleNext != SCE_POV_COMMENT) && !atEOL) {
|
||||
// Comments don't end at end of line and the next character may be unstyled.
|
||||
levelCurrent--;
|
||||
}
|
||||
}
|
||||
if (style == SCE_POV_BRACE) {
|
||||
if (foldComment && (style == SCE_POV_COMMENTLINE)) {
|
||||
if ((ch == '/') && (chNext == '/')) {
|
||||
char chNext2 = styler.SafeGetCharAt(i + 2);
|
||||
if (chNext2 == '{') {
|
||||
levelCurrent++;
|
||||
} else if (chNext2 == '}') {
|
||||
levelCurrent--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (foldDirective && (style == SCE_POV_DIRECTIVE)) {
|
||||
if (ch == '#') {
|
||||
unsigned int j=i+1;
|
||||
while ((j<endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (style == SCE_POV_OPERATOR) {
|
||||
if (ch == '{') {
|
||||
levelCurrent++;
|
||||
} else if (ch == '}') {
|
||||
@@ -204,19 +290,16 @@ static void FoldNoBoxPOVDoc(unsigned int startPos, int length, int initStyle,
|
||||
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
|
||||
}
|
||||
|
||||
static void FoldPOVDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) {
|
||||
FoldNoBoxPOVDoc(startPos, length, initStyle, styler);
|
||||
}
|
||||
static const char * const povWordLists[] = {
|
||||
"Language directives",
|
||||
"Objects & CSG & Appearance",
|
||||
"Types & Modifiers & Items",
|
||||
"Predefined Identifiers",
|
||||
"Predefined Functions",
|
||||
"User defined 1",
|
||||
"User defined 2",
|
||||
"User defined 3",
|
||||
0,
|
||||
};
|
||||
|
||||
static const char * const POVWordLists[] = {
|
||||
"Primary keywords and identifiers",
|
||||
"Secondary keywords and identifiers",
|
||||
0,
|
||||
};
|
||||
|
||||
static void ColourisePOVDocSensitive(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
ColourisePOVDoc(startPos, length, initStyle, keywordlists, styler);
|
||||
}
|
||||
|
||||
LexerModule lmPOV(SCLEX_POV, ColourisePOVDocSensitive, "pov", FoldPOVDoc, POVWordLists);
|
||||
LexerModule lmPOV(SCLEX_POV, ColourisePovDoc, "pov", FoldPovDoc, povWordLists);
|
||||
|
344
contrib/src/stc/scintilla/src/LexPS.cxx
Normal file
344
contrib/src/stc/scintilla/src/LexPS.cxx
Normal file
@@ -0,0 +1,344 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file LexPS.cxx
|
||||
** Lexer for PostScript
|
||||
**
|
||||
** Written by Nigel Hathaway <nigel@bprj.co.uk>.
|
||||
** The License.txt file describes the conditions under which this software may be distributed.
|
||||
**/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "StyleContext.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
static inline bool IsASelfDelimitingChar(const int ch) {
|
||||
return (ch == '[' || ch == ']' || ch == '{' || ch == '}' ||
|
||||
ch == '/' || ch == '<' || ch == '>' ||
|
||||
ch == '(' || ch == ')' || ch == '%');
|
||||
}
|
||||
|
||||
static inline bool IsAWhitespaceChar(const int ch) {
|
||||
return (ch == ' ' || ch == '\t' || ch == '\r' ||
|
||||
ch == '\n' || ch == '\f' || ch == '\0');
|
||||
}
|
||||
|
||||
static bool IsABaseNDigit(const int ch, const int base) {
|
||||
int maxdig = '9';
|
||||
int letterext = -1;
|
||||
|
||||
if (base <= 10)
|
||||
maxdig = '0' + base - 1;
|
||||
else
|
||||
letterext = base - 11;
|
||||
|
||||
return ((ch >= '0' && ch <= maxdig) ||
|
||||
(ch >= 'A' && ch <= ('A' + letterext)) ||
|
||||
(ch >= 'a' && ch <= ('a' + letterext)));
|
||||
}
|
||||
|
||||
static inline bool IsABase85Char(const int ch) {
|
||||
return ((ch >= '!' && ch <= 'u') || ch == 'z');
|
||||
}
|
||||
|
||||
static void ColourisePSDoc(
|
||||
unsigned int startPos,
|
||||
int length,
|
||||
int initStyle,
|
||||
WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
|
||||
WordList &keywords1 = *keywordlists[0];
|
||||
WordList &keywords2 = *keywordlists[1];
|
||||
WordList &keywords3 = *keywordlists[2];
|
||||
WordList &keywords4 = *keywordlists[3];
|
||||
WordList &keywords5 = *keywordlists[4];
|
||||
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
|
||||
bool tokenizing = styler.GetPropertyInt("ps.tokenize") != 0;
|
||||
int pslevel = styler.GetPropertyInt("ps.level", 3);
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int nestTextCurrent = 0;
|
||||
if (lineCurrent > 0 && initStyle == SCE_PS_TEXT)
|
||||
nestTextCurrent = styler.GetLineState(lineCurrent - 1);
|
||||
int numRadix = 0;
|
||||
bool numHasPoint = false;
|
||||
bool numHasExponent = false;
|
||||
bool numHasSign = false;
|
||||
|
||||
// Clear out existing tokenization
|
||||
if (tokenizing && length > 0) {
|
||||
styler.StartAt(startPos, static_cast<char>(INDIC2_MASK));
|
||||
styler.ColourTo(startPos + length-1, 0);
|
||||
styler.Flush();
|
||||
styler.StartAt(startPos);
|
||||
styler.StartSegment(startPos);
|
||||
}
|
||||
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
if (sc.atLineStart)
|
||||
lineCurrent = styler.GetLine(sc.currentPos);
|
||||
|
||||
// Determine if the current state should terminate.
|
||||
if (sc.state == SCE_PS_COMMENT || sc.state == SCE_PS_DSC_VALUE) {
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_C_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_PS_DSC_COMMENT) {
|
||||
if (sc.ch == ':') {
|
||||
sc.Forward();
|
||||
if (!sc.atLineEnd)
|
||||
sc.SetState(SCE_PS_DSC_VALUE);
|
||||
else
|
||||
sc.SetState(SCE_C_DEFAULT);
|
||||
} else if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_C_DEFAULT);
|
||||
} else if (IsAWhitespaceChar(sc.ch)) {
|
||||
sc.ChangeState(SCE_PS_COMMENT);
|
||||
}
|
||||
} else if (sc.state == SCE_PS_NUMBER) {
|
||||
if (IsASelfDelimitingChar(sc.ch) || IsAWhitespaceChar(sc.ch)) {
|
||||
if ((sc.chPrev == '+' || sc.chPrev == '-' ||
|
||||
sc.chPrev == 'E' || sc.chPrev == 'e') && numRadix == 0)
|
||||
sc.ChangeState(SCE_PS_NAME);
|
||||
sc.SetState(SCE_C_DEFAULT);
|
||||
} else if (sc.ch == '#') {
|
||||
if (numHasPoint || numHasExponent || numHasSign || numRadix != 0) {
|
||||
sc.ChangeState(SCE_PS_NAME);
|
||||
} else {
|
||||
char szradix[5];
|
||||
sc.GetCurrent(szradix, 4);
|
||||
numRadix = atoi(szradix);
|
||||
if (numRadix < 2 || numRadix > 36)
|
||||
sc.ChangeState(SCE_PS_NAME);
|
||||
}
|
||||
} else if ((sc.ch == 'E' || sc.ch == 'e') && numRadix == 0) {
|
||||
if (numHasExponent) {
|
||||
sc.ChangeState(SCE_PS_NAME);
|
||||
} else {
|
||||
numHasExponent = true;
|
||||
if (sc.chNext == '+' || sc.chNext == '-')
|
||||
sc.Forward();
|
||||
}
|
||||
} else if (sc.ch == '.') {
|
||||
if (numHasPoint || numHasExponent || numRadix != 0) {
|
||||
sc.ChangeState(SCE_PS_NAME);
|
||||
} else {
|
||||
numHasPoint = true;
|
||||
}
|
||||
} else if (numRadix == 0) {
|
||||
if (!IsABaseNDigit(sc.ch, 10))
|
||||
sc.ChangeState(SCE_PS_NAME);
|
||||
} else {
|
||||
if (!IsABaseNDigit(sc.ch, numRadix))
|
||||
sc.ChangeState(SCE_PS_NAME);
|
||||
}
|
||||
} else if (sc.state == SCE_PS_NAME || sc.state == SCE_PS_KEYWORD) {
|
||||
if (IsASelfDelimitingChar(sc.ch) || IsAWhitespaceChar(sc.ch)) {
|
||||
char s[100];
|
||||
sc.GetCurrent(s, sizeof(s));
|
||||
if ((pslevel >= 1 && keywords1.InList(s)) ||
|
||||
(pslevel >= 2 && keywords2.InList(s)) ||
|
||||
(pslevel >= 3 && keywords3.InList(s)) ||
|
||||
keywords4.InList(s) || keywords5.InList(s)) {
|
||||
sc.ChangeState(SCE_PS_KEYWORD);
|
||||
}
|
||||
sc.SetState(SCE_C_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_PS_LITERAL || sc.state == SCE_PS_IMMEVAL) {
|
||||
if (IsASelfDelimitingChar(sc.ch) || IsAWhitespaceChar(sc.ch))
|
||||
sc.SetState(SCE_C_DEFAULT);
|
||||
} else if (sc.state == SCE_PS_PAREN_ARRAY || sc.state == SCE_PS_PAREN_DICT ||
|
||||
sc.state == SCE_PS_PAREN_PROC) {
|
||||
sc.SetState(SCE_C_DEFAULT);
|
||||
} else if (sc.state == SCE_PS_TEXT) {
|
||||
if (sc.ch == '(') {
|
||||
nestTextCurrent++;
|
||||
} else if (sc.ch == ')') {
|
||||
if (--nestTextCurrent == 0)
|
||||
sc.ForwardSetState(SCE_PS_DEFAULT);
|
||||
} else if (sc.ch == '\\') {
|
||||
sc.Forward();
|
||||
}
|
||||
} else if (sc.state == SCE_PS_HEXSTRING) {
|
||||
if (sc.ch == '>') {
|
||||
sc.ForwardSetState(SCE_PS_DEFAULT);
|
||||
} else if (!IsABaseNDigit(sc.ch, 16) && !IsAWhitespaceChar(sc.ch)) {
|
||||
sc.SetState(SCE_PS_HEXSTRING);
|
||||
styler.ColourTo(sc.currentPos, SCE_PS_BADSTRINGCHAR);
|
||||
}
|
||||
} else if (sc.state == SCE_PS_BASE85STRING) {
|
||||
if (sc.Match('~', '>')) {
|
||||
sc.Forward();
|
||||
sc.ForwardSetState(SCE_PS_DEFAULT);
|
||||
} else if (!IsABase85Char(sc.ch) && !IsAWhitespaceChar(sc.ch)) {
|
||||
sc.SetState(SCE_PS_BASE85STRING);
|
||||
styler.ColourTo(sc.currentPos, SCE_PS_BADSTRINGCHAR);
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if a new state should be entered.
|
||||
if (sc.state == SCE_C_DEFAULT) {
|
||||
unsigned int tokenpos = sc.currentPos;
|
||||
|
||||
if (sc.ch == '[' || sc.ch == ']') {
|
||||
sc.SetState(SCE_PS_PAREN_ARRAY);
|
||||
} else if (sc.ch == '{' || sc.ch == '}') {
|
||||
sc.SetState(SCE_PS_PAREN_PROC);
|
||||
} else if (sc.ch == '/') {
|
||||
if (sc.chNext == '/') {
|
||||
sc.SetState(SCE_PS_IMMEVAL);
|
||||
sc.Forward();
|
||||
} else {
|
||||
sc.SetState(SCE_PS_LITERAL);
|
||||
}
|
||||
} else if (sc.ch == '<') {
|
||||
if (sc.chNext == '<') {
|
||||
sc.SetState(SCE_PS_PAREN_DICT);
|
||||
sc.Forward();
|
||||
} else if (sc.chNext == '~') {
|
||||
sc.SetState(SCE_PS_BASE85STRING);
|
||||
sc.Forward();
|
||||
} else {
|
||||
sc.SetState(SCE_PS_HEXSTRING);
|
||||
}
|
||||
} else if (sc.ch == '>' && sc.chNext == '>') {
|
||||
sc.SetState(SCE_PS_PAREN_DICT);
|
||||
sc.Forward();
|
||||
} else if (sc.ch == '>' || sc.ch == ')') {
|
||||
sc.SetState(SCE_C_DEFAULT);
|
||||
styler.ColourTo(sc.currentPos, SCE_PS_BADSTRINGCHAR);
|
||||
} else if (sc.ch == '(') {
|
||||
sc.SetState(SCE_PS_TEXT);
|
||||
nestTextCurrent = 1;
|
||||
} else if (sc.ch == '%') {
|
||||
if (sc.chNext == '%' && sc.atLineStart) {
|
||||
sc.SetState(SCE_PS_DSC_COMMENT);
|
||||
sc.Forward();
|
||||
if (sc.chNext == '+') {
|
||||
sc.Forward();
|
||||
sc.ForwardSetState(SCE_PS_DSC_VALUE);
|
||||
}
|
||||
} else {
|
||||
sc.SetState(SCE_PS_COMMENT);
|
||||
}
|
||||
} else if ((sc.ch == '+' || sc.ch == '-' || sc.ch == '.') &&
|
||||
IsABaseNDigit(sc.chNext, 10)) {
|
||||
sc.SetState(SCE_PS_NUMBER);
|
||||
numRadix = 0;
|
||||
numHasPoint = (sc.ch == '.');
|
||||
numHasExponent = false;
|
||||
numHasSign = (sc.ch == '+' || sc.ch == '-');
|
||||
} else if ((sc.ch == '+' || sc.ch == '-') && sc.chNext == '.' &&
|
||||
IsABaseNDigit(sc.GetRelative(2), 10)) {
|
||||
sc.SetState(SCE_PS_NUMBER);
|
||||
numRadix = 0;
|
||||
numHasPoint = false;
|
||||
numHasExponent = false;
|
||||
numHasSign = true;
|
||||
} else if (IsABaseNDigit(sc.ch, 10)) {
|
||||
sc.SetState(SCE_PS_NUMBER);
|
||||
numRadix = 0;
|
||||
numHasPoint = false;
|
||||
numHasExponent = false;
|
||||
numHasSign = false;
|
||||
} else if (!IsAWhitespaceChar(sc.ch)) {
|
||||
sc.SetState(SCE_PS_NAME);
|
||||
}
|
||||
|
||||
// Mark the start of tokens
|
||||
if (tokenizing && sc.state != SCE_C_DEFAULT && sc.state != SCE_PS_COMMENT &&
|
||||
sc.state != SCE_PS_DSC_COMMENT && sc.state != SCE_PS_DSC_VALUE) {
|
||||
styler.Flush();
|
||||
styler.StartAt(tokenpos, static_cast<char>(INDIC2_MASK));
|
||||
styler.ColourTo(tokenpos, INDIC2_MASK);
|
||||
styler.Flush();
|
||||
styler.StartAt(tokenpos);
|
||||
styler.StartSegment(tokenpos);
|
||||
}
|
||||
}
|
||||
|
||||
if (sc.atLineEnd)
|
||||
styler.SetLineState(lineCurrent, nestTextCurrent);
|
||||
}
|
||||
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
static void FoldPSDoc(unsigned int startPos, int length, int, WordList *[],
|
||||
Accessor &styler) {
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0;
|
||||
unsigned int endPos = startPos + length;
|
||||
int visibleChars = 0;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int levelCurrent = SC_FOLDLEVELBASE;
|
||||
if (lineCurrent > 0)
|
||||
levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
|
||||
int levelMinCurrent = levelCurrent;
|
||||
int levelNext = levelCurrent;
|
||||
char chNext = styler[startPos];
|
||||
int styleNext = styler.StyleAt(startPos);
|
||||
int style;
|
||||
for (unsigned int i = startPos; i < endPos; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
style = styleNext;
|
||||
styleNext = styler.StyleAt(i + 1);
|
||||
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); //mac??
|
||||
if ((style & 31) == SCE_PS_PAREN_PROC) {
|
||||
if (ch == '{') {
|
||||
// Measure the minimum before a '{' to allow
|
||||
// folding on "} {"
|
||||
if (levelMinCurrent > levelNext) {
|
||||
levelMinCurrent = levelNext;
|
||||
}
|
||||
levelNext++;
|
||||
} else if (ch == '}') {
|
||||
levelNext--;
|
||||
}
|
||||
}
|
||||
if (atEOL) {
|
||||
int levelUse = levelCurrent;
|
||||
if (foldAtElse) {
|
||||
levelUse = levelMinCurrent;
|
||||
}
|
||||
int lev = levelUse | levelNext << 16;
|
||||
if (visibleChars == 0 && foldCompact)
|
||||
lev |= SC_FOLDLEVELWHITEFLAG;
|
||||
if (levelUse < levelNext)
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
if (lev != styler.LevelAt(lineCurrent)) {
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
}
|
||||
lineCurrent++;
|
||||
levelCurrent = levelNext;
|
||||
levelMinCurrent = levelCurrent;
|
||||
visibleChars = 0;
|
||||
}
|
||||
if (!isspacechar(ch))
|
||||
visibleChars++;
|
||||
}
|
||||
}
|
||||
|
||||
static const char * const psWordListDesc[] = {
|
||||
"PS Level 1 operators",
|
||||
"PS Level 2 operators",
|
||||
"PS Level 3 operators",
|
||||
"RIP-specific operators",
|
||||
"User-defined operators",
|
||||
0
|
||||
};
|
||||
|
||||
LexerModule lmPS(SCLEX_PS, ColourisePSDoc, "ps", FoldPSDoc, psWordListDesc);
|
@@ -3,6 +3,7 @@
|
||||
** Lexer for Pascal.
|
||||
** Written by Laurent le Tynevez
|
||||
** Updated by Simon Steele <s.steele@pnotepad.org> September 2002
|
||||
** Updated by Mathias Rauen <scite@madshi.net> May 2003 (Delphi adjustments)
|
||||
**/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -40,12 +41,15 @@ static bool IsStreamCommentStyle(int style) {
|
||||
style == SCE_C_COMMENTDOCKEYWORDERROR;
|
||||
}
|
||||
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
|
||||
static void ColourTo(Accessor &styler, unsigned int end, unsigned int attr, bool bInAsm) {
|
||||
if ((bInAsm) && (attr == SCE_C_OPERATOR || attr == SCE_C_NUMBER || attr == SCE_C_DEFAULT || attr == SCE_C_WORD || attr == SCE_C_IDENTIFIER)) {
|
||||
styler.ColourTo(end, SCE_C_REGEX);
|
||||
} else
|
||||
styler.ColourTo(end, attr);
|
||||
}
|
||||
|
||||
// returns 1 if the item starts a class definition, and -1 if the word is "end".
|
||||
static int classifyWordPascal(unsigned int start, unsigned int end, /*WordList &keywords*/WordList *keywordlists[], Accessor &styler, bool bInClass) {
|
||||
// returns 1 if the item starts a class definition, and -1 if the word is "end", and 2 if the word is "asm"
|
||||
static int classifyWordPascal(unsigned int start, unsigned int end, /*WordList &keywords*/WordList *keywordlists[], Accessor &styler, bool bInClass, bool bInAsm) {
|
||||
int ret = 0;
|
||||
|
||||
WordList& keywords = *keywordlists[0];
|
||||
@@ -55,24 +59,34 @@ static int classifyWordPascal(unsigned int start, unsigned int end, /*WordList &
|
||||
getRange(start, end, styler, s, sizeof(s));
|
||||
|
||||
char chAttr = SCE_C_IDENTIFIER;
|
||||
if (isdigit(s[0]) || (s[0] == '.')) {
|
||||
if (isdigit(s[0]) || (s[0] == '.') ||(s[0] == '$')) {
|
||||
chAttr = SCE_C_NUMBER;
|
||||
}
|
||||
else {
|
||||
if (keywords.InList(s)) {
|
||||
chAttr = SCE_C_WORD;
|
||||
|
||||
if(strcmp(s, "class") == 0)
|
||||
ret = 1;
|
||||
else if(strcmp(s, "end") == 0)
|
||||
ret = -1;
|
||||
} else if (bInClass) {
|
||||
if (classwords.InList(s)) {
|
||||
if (s[0] == '#') {
|
||||
chAttr = SCE_C_CHARACTER;
|
||||
}
|
||||
else {
|
||||
if (keywords.InList(s)) {
|
||||
chAttr = SCE_C_WORD;
|
||||
|
||||
if(strcmp(s, "class") == 0) {
|
||||
ret = 1;
|
||||
}
|
||||
else if (strcmp(s, "asm") == 0) {
|
||||
ret = 2;
|
||||
}
|
||||
else if (strcmp(s, "end") == 0) {
|
||||
ret = -1;
|
||||
}
|
||||
} else if (bInClass) {
|
||||
if (classwords.InList(s)) {
|
||||
chAttr = SCE_C_WORD;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
styler.ColourTo(end, chAttr);
|
||||
ColourTo(styler, end, chAttr, (bInAsm && ret != -1));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -99,14 +113,14 @@ static void ColourisePascalDoc(unsigned int startPos, int length, int initStyle,
|
||||
styler.StartAt(startPos);
|
||||
|
||||
int state = initStyle;
|
||||
if (state == SCE_C_STRINGEOL) // Does not leak onto next line
|
||||
if (state == SCE_C_CHARACTER) // Does not leak onto next line
|
||||
state = SCE_C_DEFAULT;
|
||||
char chPrev = ' ';
|
||||
char chNext = styler[startPos];
|
||||
unsigned int lengthDoc = startPos + length;
|
||||
int visibleChars = 0;
|
||||
|
||||
bool bInClassDefinition;
|
||||
|
||||
int currentLine = styler.GetLine(startPos);
|
||||
if (currentLine > 0) {
|
||||
styler.SetLineState(currentLine, styler.GetLineState(currentLine-1));
|
||||
@@ -116,6 +130,10 @@ static void ColourisePascalDoc(unsigned int startPos, int length, int initStyle,
|
||||
bInClassDefinition = false;
|
||||
}
|
||||
|
||||
bool bInAsm = (state == SCE_C_REGEX);
|
||||
if (bInAsm)
|
||||
state = SCE_C_DEFAULT;
|
||||
|
||||
styler.StartSegment(startPos);
|
||||
for (unsigned int i = startPos; i < lengthDoc; i++) {
|
||||
char ch = chNext;
|
||||
@@ -126,16 +144,13 @@ static void ColourisePascalDoc(unsigned int startPos, int length, int initStyle,
|
||||
// Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
|
||||
// Avoid triggering two times on Dos/Win
|
||||
// End of line
|
||||
if (state == SCE_C_STRINGEOL) {
|
||||
styler.ColourTo(i, state);
|
||||
if (state == SCE_C_CHARACTER) {
|
||||
ColourTo(styler, i, state, bInAsm);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
visibleChars = 0;
|
||||
currentLine++;
|
||||
styler.SetLineState(currentLine, (bInClassDefinition ? 1 : 0));
|
||||
}
|
||||
if (!isspacechar(ch))
|
||||
visibleChars++;
|
||||
|
||||
if (styler.IsLeadByte(ch)) {
|
||||
chNext = styler.SafeGetCharAt(i + 2);
|
||||
@@ -145,41 +160,50 @@ static void ColourisePascalDoc(unsigned int startPos, int length, int initStyle,
|
||||
}
|
||||
|
||||
if (state == SCE_C_DEFAULT) {
|
||||
if (iswordstart(ch) || (ch == '@')) {
|
||||
styler.ColourTo(i-1, state);
|
||||
if (iswordstart(ch) || ch == '#' || ch == '$' || (ch == '@' && bInAsm)) {
|
||||
ColourTo(styler, i-1, state, bInAsm);
|
||||
state = SCE_C_IDENTIFIER;
|
||||
} else if (ch == '{' && chNext != '$' && chNext != '&') {
|
||||
styler.ColourTo(i-1, state);
|
||||
ColourTo(styler, i-1, state, bInAsm);
|
||||
state = SCE_C_COMMENT;
|
||||
} else if (ch == '(' && chNext == '*'
|
||||
&& styler.SafeGetCharAt(i + 2) != '$'
|
||||
&& styler.SafeGetCharAt(i + 2) != '&') {
|
||||
styler.ColourTo(i-1, state);
|
||||
ColourTo(styler, i-1, state, bInAsm);
|
||||
state = SCE_C_COMMENTDOC;
|
||||
} else if (ch == '/' && chNext == '/') {
|
||||
styler.ColourTo(i-1, state);
|
||||
ColourTo(styler, i-1, state, bInAsm);
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '\'') {
|
||||
styler.ColourTo(i-1, state);
|
||||
ColourTo(styler, i-1, state, bInAsm);
|
||||
state = SCE_C_CHARACTER;
|
||||
} else if (ch == '{' && (chNext == '$' || chNext=='&') && visibleChars == 1) {
|
||||
styler.ColourTo(i-1, state);
|
||||
} else if (ch == '{' && (chNext == '$' || chNext=='&')) {
|
||||
ColourTo(styler, i-1, state, bInAsm);
|
||||
state = SCE_C_PREPROCESSOR;
|
||||
} else if (isoperator(ch)) {
|
||||
styler.ColourTo(i-1, state);
|
||||
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||
ColourTo(styler, i-1, state, bInAsm);
|
||||
ColourTo(styler, i, SCE_C_OPERATOR, bInAsm);
|
||||
|
||||
}
|
||||
} else if (state == SCE_C_IDENTIFIER) {
|
||||
if (!iswordchar(ch)) {
|
||||
int lStateChange = classifyWordPascal(styler.GetStartSegment(), i - 1, keywordlists, styler, bInClassDefinition);
|
||||
bool bDoublePoint = ((ch == '.') && (chPrev == '.'));
|
||||
if ((!iswordchar(ch) && ch != '$' && ch != '#' && (ch != '@' || !bInAsm)) || bDoublePoint) {
|
||||
if (bDoublePoint) i--;
|
||||
int lStateChange = classifyWordPascal(styler.GetStartSegment(), i - 1, keywordlists, styler, bInClassDefinition, bInAsm);
|
||||
|
||||
if(lStateChange == 1) {
|
||||
styler.SetLineState(currentLine, 1);
|
||||
bInClassDefinition = true;
|
||||
} else if(lStateChange == 2) {
|
||||
bInAsm = true;
|
||||
} else if(lStateChange == -1) {
|
||||
styler.SetLineState(currentLine, 0);
|
||||
bInClassDefinition = false;
|
||||
bInAsm = false;
|
||||
}
|
||||
if (bDoublePoint) {
|
||||
i++;
|
||||
ColourTo(styler, i-1, SCE_C_DEFAULT, bInAsm);
|
||||
}
|
||||
|
||||
state = SCE_C_DEFAULT;
|
||||
@@ -189,30 +213,30 @@ static void ColourisePascalDoc(unsigned int startPos, int length, int initStyle,
|
||||
} else if (ch == '(' && chNext == '*'
|
||||
&& styler.SafeGetCharAt(i + 2) != '$'
|
||||
&& styler.SafeGetCharAt(i + 2) != '&') {
|
||||
styler.ColourTo(i-1, state);
|
||||
ColourTo(styler, i-1, state, bInAsm);
|
||||
state = SCE_C_COMMENTDOC;
|
||||
} else if (ch == '/' && chNext == '/') {
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '\'') {
|
||||
state = SCE_C_CHARACTER;
|
||||
} else if (isoperator(ch)) {
|
||||
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||
ColourTo(styler, i, SCE_C_OPERATOR, bInAsm);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (state == SCE_C_PREPROCESSOR) {
|
||||
if (ch=='}'){
|
||||
styler.ColourTo(i, state);
|
||||
ColourTo(styler, i, state, bInAsm);
|
||||
state = SCE_C_DEFAULT;
|
||||
} else {
|
||||
if ((ch == '\r' || ch == '\n') && !(chPrev == '\\' || chPrev == '\r')) {
|
||||
styler.ColourTo(i-1, state);
|
||||
ColourTo(styler, i-1, state, bInAsm);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_C_COMMENT) {
|
||||
if (ch == '}' ) {
|
||||
styler.ColourTo(i, state);
|
||||
ColourTo(styler, i, state, bInAsm);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_C_COMMENTDOC) {
|
||||
@@ -220,28 +244,25 @@ static void ColourisePascalDoc(unsigned int startPos, int length, int initStyle,
|
||||
if (((i > styler.GetStartSegment() + 2) || (
|
||||
(initStyle == SCE_C_COMMENTDOC) &&
|
||||
(styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
|
||||
styler.ColourTo(i, state);
|
||||
ColourTo(styler, i, state, bInAsm);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_C_COMMENTLINE) {
|
||||
if (ch == '\r' || ch == '\n') {
|
||||
styler.ColourTo(i-1, state);
|
||||
ColourTo(styler, i-1, state, bInAsm);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
} else if (state == SCE_C_CHARACTER) {
|
||||
if ((ch == '\r' || ch == '\n')) {
|
||||
styler.ColourTo(i-1, SCE_C_STRINGEOL);
|
||||
state = SCE_C_STRINGEOL;
|
||||
} else if (ch == '\'') {
|
||||
styler.ColourTo(i, state);
|
||||
if (ch == '\'') {
|
||||
ColourTo(styler, i, state, bInAsm);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
chPrev = ch;
|
||||
}
|
||||
styler.ColourTo(lengthDoc - 1, state);
|
||||
ColourTo(styler, lengthDoc - 1, state, bInAsm);
|
||||
}
|
||||
|
||||
static void FoldPascalDoc(unsigned int startPos, int length, int initStyle, WordList *[],
|
||||
|
@@ -23,7 +23,7 @@ static void classifyWordSQL(unsigned int start, unsigned int end, WordList &keyw
|
||||
char s[100];
|
||||
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
|
||||
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
|
||||
s[i] = static_cast<char>(toupper(styler[start + i]));
|
||||
s[i] = static_cast<char>(tolower(styler[start + i]));
|
||||
s[i + 1] = '\0';
|
||||
}
|
||||
char chAttr = SCE_C_IDENTIFIER;
|
||||
@@ -88,7 +88,7 @@ static void ColouriseSQLDoc(unsigned int startPos, int length,
|
||||
} else if (ch == '-' && chNext == '-') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '\'') {
|
||||
} else if ((ch == '\'') || (ch == '"')) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_STRING;
|
||||
} else if (isoperator(ch)) {
|
||||
@@ -103,7 +103,7 @@ static void ColouriseSQLDoc(unsigned int startPos, int length,
|
||||
state = SCE_C_COMMENT;
|
||||
} else if (ch == '-' && chNext == '-') {
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '\'') {
|
||||
} else if ((ch == '\'') || (ch == '"')) {
|
||||
state = SCE_C_STRING;
|
||||
} else if (isoperator(ch)) {
|
||||
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||
@@ -134,6 +134,16 @@ static void ColouriseSQLDoc(unsigned int startPos, int length,
|
||||
}
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
} else if (ch == '"') {
|
||||
if (chNext == '"') {
|
||||
i++;
|
||||
} else {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
i++;
|
||||
}
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
}
|
||||
if (state == SCE_C_DEFAULT) { // One of the above succeeded
|
||||
@@ -141,7 +151,7 @@ static void ColouriseSQLDoc(unsigned int startPos, int length,
|
||||
state = SCE_C_COMMENT;
|
||||
} else if (ch == '-' && chNext == '-') {
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '\'') {
|
||||
} else if ((ch == '\'') || (ch == '"')) {
|
||||
state = SCE_C_STRING;
|
||||
} else if (iswordstart(ch)) {
|
||||
state = SCE_C_WORD;
|
||||
|
427
contrib/src/stc/scintilla/src/LexScriptol.cxx
Normal file
427
contrib/src/stc/scintilla/src/LexScriptol.cxx
Normal file
@@ -0,0 +1,427 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file LexScriptol.cxx
|
||||
** Lexer for Scriptol.
|
||||
**/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
static void ClassifyWordSol(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord)
|
||||
{
|
||||
char s[100];
|
||||
bool wordIsNumber = isdigit(styler[start]) != 0;
|
||||
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++)
|
||||
{
|
||||
s[i] = styler[start + i];
|
||||
s[i + 1] = '\0';
|
||||
}
|
||||
char chAttr = SCE_P_IDENTIFIER;
|
||||
if (0 == strcmp(prevWord, "class")) chAttr = SCE_P_CLASSNAME;
|
||||
else if (wordIsNumber) chAttr = SCE_P_NUMBER;
|
||||
else if (keywords.InList(s)) chAttr = SCE_P_WORD;
|
||||
else for (unsigned int i = 0; i < end - start + 1; i++) // test dotted idents
|
||||
{
|
||||
if (styler[start + i] == '.')
|
||||
{
|
||||
styler.ColourTo(start + i - 1, chAttr);
|
||||
styler.ColourTo(start + i, SCE_P_OPERATOR);
|
||||
}
|
||||
}
|
||||
styler.ColourTo(end, chAttr);
|
||||
strcpy(prevWord, s);
|
||||
}
|
||||
|
||||
static bool IsSolComment(Accessor &styler, int pos, int len)
|
||||
{
|
||||
// return len > 0 && styler[pos]=='`';
|
||||
char c;
|
||||
if(len > 0)
|
||||
{
|
||||
c = styler[pos];
|
||||
if(c == '`') return true;
|
||||
if(len > 1)
|
||||
{
|
||||
if(c == '/')
|
||||
{
|
||||
c = styler[pos + 1];
|
||||
if(c == '/') return true;
|
||||
if(c == '*') return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IsSolStringStart(char ch, char /*chNext*/)
|
||||
{
|
||||
if (ch == '\'' || ch == '"') return true;
|
||||
//chNext = chNext; // for future use
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IsSolWordStart(char ch, char chNext)
|
||||
{
|
||||
return (iswordchar(ch) && !IsSolStringStart(ch, chNext));
|
||||
}
|
||||
|
||||
/* Return the state to use for the string starting at i; *nextIndex will be set to the first index following the quote(s) */
|
||||
static int GetSolStringState(Accessor &styler, int i, int *nextIndex)
|
||||
{
|
||||
char ch = styler.SafeGetCharAt(i);
|
||||
char chNext = styler.SafeGetCharAt(i + 1);
|
||||
|
||||
if (ch != '"' && ch != '\'') {
|
||||
*nextIndex = i + 1;
|
||||
return SCE_P_DEFAULT;
|
||||
}
|
||||
|
||||
if (ch == chNext && ch == styler.SafeGetCharAt(i + 2))
|
||||
{
|
||||
*nextIndex = i + 3;
|
||||
if (ch == '"') return SCE_P_TRIPLEDOUBLE;
|
||||
else return SCE_P_TRIPLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
*nextIndex = i + 1;
|
||||
if (ch == '"') return SCE_P_STRING;
|
||||
else return SCE_P_CHARACTER;
|
||||
}
|
||||
}
|
||||
|
||||
static void ColouriseSolDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler)
|
||||
{
|
||||
|
||||
int lengthDoc = startPos + length;
|
||||
|
||||
// Backtrack to previous line in case need to fix its tab whinging
|
||||
if (startPos > 0)
|
||||
{
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
if (lineCurrent > 0)
|
||||
{
|
||||
startPos = styler.LineStart(lineCurrent-1);
|
||||
if (startPos == 0) initStyle = SCE_P_DEFAULT;
|
||||
else initStyle = styler.StyleAt(startPos-1);
|
||||
}
|
||||
}
|
||||
|
||||
styler.StartAt(startPos, 127);
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
|
||||
int whingeLevel = styler.GetPropertyInt("tab.timmy.whinge.level");
|
||||
char prevWord[200];
|
||||
prevWord[0] = '\0';
|
||||
if (length == 0) return ;
|
||||
|
||||
int state = initStyle & 31;
|
||||
|
||||
int nextIndex = 0;
|
||||
char chPrev = ' ';
|
||||
//char chPrev2 = ' ';
|
||||
char chNext = styler[startPos];
|
||||
styler.StartSegment(startPos);
|
||||
bool atStartLine = true;
|
||||
int spaceFlags = 0;
|
||||
for (int i = startPos; i < lengthDoc; i++)
|
||||
{
|
||||
|
||||
if (atStartLine)
|
||||
{
|
||||
char chBad = static_cast<char>(64);
|
||||
char chGood = static_cast<char>(0);
|
||||
char chFlags = chGood;
|
||||
|
||||
if (whingeLevel == 1)
|
||||
{
|
||||
chFlags = (spaceFlags & wsInconsistent) ? chBad : chGood;
|
||||
}
|
||||
else if (whingeLevel == 2)
|
||||
{
|
||||
chFlags = (spaceFlags & wsSpaceTab) ? chBad : chGood;
|
||||
}
|
||||
else if (whingeLevel == 3)
|
||||
{
|
||||
chFlags = (spaceFlags & wsSpace) ? chBad : chGood;
|
||||
}
|
||||
else if (whingeLevel == 4)
|
||||
{
|
||||
chFlags = (spaceFlags & wsTab) ? chBad : chGood;
|
||||
}
|
||||
styler.SetFlags(chFlags, static_cast<char>(state));
|
||||
atStartLine = false;
|
||||
}
|
||||
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
|
||||
if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc))
|
||||
{
|
||||
if ((state == SCE_P_DEFAULT) || (state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE))
|
||||
{
|
||||
styler.ColourTo(i, state);
|
||||
}
|
||||
atStartLine = true;
|
||||
}
|
||||
|
||||
if (styler.IsLeadByte(ch))
|
||||
{
|
||||
chNext = styler.SafeGetCharAt(i + 2);
|
||||
chPrev = ' ';
|
||||
//chPrev2 = ' ';
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (state == SCE_P_STRINGEOL)
|
||||
{
|
||||
if (ch != '\r' && ch != '\n')
|
||||
{
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_P_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
if (state == SCE_P_DEFAULT)
|
||||
{
|
||||
if (IsSolWordStart(ch, chNext))
|
||||
{
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_P_WORD;
|
||||
}
|
||||
else if (ch == '`')
|
||||
{
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_P_COMMENTLINE;
|
||||
}
|
||||
else if (ch == '/')
|
||||
{
|
||||
styler.ColourTo(i - 1, state);
|
||||
if(chNext == '/') state = SCE_P_COMMENTLINE;
|
||||
if(chNext == '*') state = SCE_P_COMMENTBLOCK;
|
||||
}
|
||||
|
||||
else if (ch == '=' && chNext == 'b')
|
||||
{
|
||||
// =begin indicates the start of a comment (doc) block
|
||||
if(styler.SafeGetCharAt(i + 2) == 'e' && styler.SafeGetCharAt(i + 3) == 'g' && styler.SafeGetCharAt(i + 4) == 'i' && styler.SafeGetCharAt(i + 5) == 'n')
|
||||
{
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_P_TRIPLEDOUBLE; //SCE_C_COMMENT;
|
||||
}
|
||||
}
|
||||
else if (IsSolStringStart(ch, chNext))
|
||||
{
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = GetSolStringState(styler, i, &nextIndex);
|
||||
if (nextIndex != i + 1)
|
||||
{
|
||||
i = nextIndex - 1;
|
||||
ch = ' ';
|
||||
//chPrev = ' ';
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
}
|
||||
else if (isoperator(ch))
|
||||
{
|
||||
styler.ColourTo(i - 1, state);
|
||||
styler.ColourTo(i, SCE_P_OPERATOR);
|
||||
}
|
||||
}
|
||||
else if (state == SCE_P_WORD)
|
||||
{
|
||||
if (!iswordchar(ch))
|
||||
{
|
||||
ClassifyWordSol(styler.GetStartSegment(), i - 1, keywords, styler, prevWord);
|
||||
state = SCE_P_DEFAULT;
|
||||
if (ch == '`')
|
||||
{
|
||||
state = chNext == '`' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
|
||||
}
|
||||
else if (IsSolStringStart(ch, chNext))
|
||||
{
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = GetSolStringState(styler, i, &nextIndex);
|
||||
if (nextIndex != i + 1)
|
||||
{
|
||||
i = nextIndex - 1;
|
||||
ch = ' ';
|
||||
//chPrev = ' ';
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
}
|
||||
else if (isoperator(ch))
|
||||
{
|
||||
styler.ColourTo(i, SCE_P_OPERATOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (state == SCE_P_COMMENTLINE)
|
||||
{
|
||||
if (ch == '\r' || ch == '\n')
|
||||
{
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_P_DEFAULT;
|
||||
}
|
||||
}
|
||||
else if(state == SCE_P_COMMENTBLOCK)
|
||||
{
|
||||
if(ch == '*' && chNext == '/') state = SCE_P_DEFAULT;
|
||||
}
|
||||
else if (state == SCE_P_STRING)
|
||||
{
|
||||
if ((ch == '\r' || ch == '\n') && (chPrev != '\\'))
|
||||
{
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_P_STRINGEOL;
|
||||
}
|
||||
else if (ch == '\\')
|
||||
{
|
||||
if (chNext == '\"' || chNext == '\'' || chNext == '\\')
|
||||
{
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
}
|
||||
else if (ch == '\"')
|
||||
{
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_P_DEFAULT;
|
||||
}
|
||||
}
|
||||
else if (state == SCE_P_CHARACTER)
|
||||
{
|
||||
if ((ch == '\r' || ch == '\n') && (chPrev != '\\'))
|
||||
{
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_P_STRINGEOL;
|
||||
}
|
||||
else if (ch == '\\')
|
||||
{
|
||||
if (chNext == '\"' || chNext == '\'' || chNext == '\\')
|
||||
{
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
}
|
||||
else if (ch == '\'')
|
||||
{
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_P_DEFAULT;
|
||||
}
|
||||
}
|
||||
/*
|
||||
else if (state == SCE_P_TRIPLE)
|
||||
{
|
||||
if (ch == '\'' && chPrev == '\'' && chPrev2 == '\'')
|
||||
{
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_P_DEFAULT;
|
||||
}
|
||||
}
|
||||
else if (state == SCE_P_TRIPLEDOUBLE)
|
||||
{
|
||||
// =end terminates the comment block
|
||||
if (ch == 'd' && chPrev == 'n' && chPrev2 == 'e')
|
||||
{
|
||||
if (styler.SafeGetCharAt(i - 3) == '=')
|
||||
{
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_P_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
//chPrev2 = chPrev;
|
||||
chPrev = ch;
|
||||
}
|
||||
if (state == SCE_P_WORD)
|
||||
{
|
||||
ClassifyWordSol(styler.GetStartSegment(), lengthDoc-1, keywords, styler, prevWord);
|
||||
}
|
||||
else
|
||||
{
|
||||
styler.ColourTo(lengthDoc-1, state);
|
||||
}
|
||||
}
|
||||
|
||||
static void FoldSolDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *[], Accessor &styler)
|
||||
{
|
||||
int lengthDoc = startPos + length;
|
||||
|
||||
// Backtrack to previous line in case need to fix its fold status
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
if (startPos > 0) {
|
||||
if (lineCurrent > 0)
|
||||
{
|
||||
lineCurrent--;
|
||||
startPos = styler.LineStart(lineCurrent);
|
||||
if (startPos == 0)
|
||||
initStyle = SCE_P_DEFAULT;
|
||||
else
|
||||
initStyle = styler.StyleAt(startPos-1);
|
||||
}
|
||||
}
|
||||
int state = initStyle & 31;
|
||||
int spaceFlags = 0;
|
||||
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsSolComment);
|
||||
if ((state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE))
|
||||
indentCurrent |= SC_FOLDLEVELWHITEFLAG;
|
||||
char chNext = styler[startPos];
|
||||
for (int i = startPos; i < lengthDoc; i++)
|
||||
{
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
int style = styler.StyleAt(i) & 31;
|
||||
|
||||
if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc))
|
||||
{
|
||||
int lev = indentCurrent;
|
||||
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsSolComment);
|
||||
if ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE))
|
||||
indentNext |= SC_FOLDLEVELWHITEFLAG;
|
||||
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG))
|
||||
{
|
||||
// Only non whitespace lines can be headers
|
||||
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK))
|
||||
{
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
} else if (indentNext & SC_FOLDLEVELWHITEFLAG)
|
||||
{
|
||||
// Line after is blank so check the next - maybe should continue further?
|
||||
int spaceFlags2 = 0;
|
||||
int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsSolComment);
|
||||
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK))
|
||||
{
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
}
|
||||
}
|
||||
}
|
||||
indentCurrent = indentNext;
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
lineCurrent++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LexerModule lmScriptol(SCLEX_SCRIPTOL, ColouriseSolDoc, "scriptol", FoldSolDoc);
|
@@ -9,7 +9,6 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
//#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Platform.h"
|
||||
@@ -72,16 +71,6 @@ bool EqualCaseInsensitive(const char *a, const char *b) {
|
||||
return 0 == CompareCaseInsensitive(a, b);
|
||||
}
|
||||
|
||||
inline unsigned int HashString(const char *s, size_t len) {
|
||||
unsigned int ret = 0;
|
||||
while (len--) {
|
||||
ret <<= 4;
|
||||
ret ^= *s;
|
||||
s++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
PropSet::PropSet() {
|
||||
superPS = 0;
|
||||
for (int root = 0; root < hashRoots; root++)
|
||||
@@ -161,7 +150,7 @@ SString PropSet::Get(const char *key) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool IncludesVar(const char *value, const char *key) {
|
||||
bool PropSet::IncludesVar(const char *value, const char *key) {
|
||||
const char *var = strstr(value, "$(");
|
||||
while (var) {
|
||||
if (isprefix(var + 2, key) && (var[2 + strlen(key)] == ')')) {
|
||||
@@ -182,25 +171,26 @@ SString PropSet::GetExpanded(const char *key) {
|
||||
return Expand(val.c_str());
|
||||
}
|
||||
|
||||
SString PropSet::Expand(const char *withVars) {
|
||||
SString PropSet::Expand(const char *withVars, int maxExpands) {
|
||||
char *base = StringDup(withVars);
|
||||
char *cpvar = strstr(base, "$(");
|
||||
int maxExpands = 1000; // Avoid infinite expansion of recursive definitions
|
||||
while (cpvar && (maxExpands > 0)) {
|
||||
char *cpendvar = strchr(cpvar, ')');
|
||||
if (cpendvar) {
|
||||
int lenvar = cpendvar - cpvar - 2; // Subtract the $()
|
||||
char *var = StringDup(cpvar + 2, lenvar);
|
||||
SString val = GetExpanded(var);
|
||||
size_t newlenbase = strlen(base) + val.length() - lenvar;
|
||||
char *newbase = new char[newlenbase];
|
||||
strncpy(newbase, base, cpvar - base);
|
||||
strcpy(newbase + (cpvar - base), val.c_str());
|
||||
strcpy(newbase + (cpvar - base) + val.length(), cpendvar + 1);
|
||||
delete []var;
|
||||
delete []base;
|
||||
base = newbase;
|
||||
}
|
||||
if (!cpendvar)
|
||||
break;
|
||||
int lenvar = cpendvar - cpvar - 2; // Subtract the $()
|
||||
char *var = StringDup(cpvar + 2, lenvar);
|
||||
SString val = Get(var);
|
||||
if (IncludesVar(val.c_str(), var))
|
||||
break;
|
||||
size_t newlenbase = strlen(base) + val.length() - lenvar;
|
||||
char *newbase = new char[newlenbase];
|
||||
strncpy(newbase, base, cpvar - base);
|
||||
strcpy(newbase + (cpvar - base), val.c_str());
|
||||
strcpy(newbase + (cpvar - base) + val.length(), cpendvar + 1);
|
||||
delete []var;
|
||||
delete []base;
|
||||
base = newbase;
|
||||
cpvar = strstr(base, "$(");
|
||||
maxExpands--;
|
||||
}
|
||||
|
@@ -10,11 +10,11 @@
|
||||
* Dept. of Computer Science
|
||||
* York University
|
||||
*
|
||||
* Original code available from http://www.cs.yorku.ca/~oz/
|
||||
* Original code available from http://www.cs.yorku.ca/~oz/
|
||||
* Translation to C++ by Neil Hodgson neilh@scintilla.org
|
||||
* Removed all use of register.
|
||||
* Converted to modern function prototypes.
|
||||
* Put all global/static variables into an object so this code can be
|
||||
* Put all global/static variables into an object so this code can be
|
||||
* used from multiple threads etc.
|
||||
*
|
||||
* These routines are the PUBLIC DOMAIN equivalents of regex
|
||||
@@ -30,8 +30,14 @@
|
||||
* Modification history:
|
||||
*
|
||||
* $Log$
|
||||
* Revision 1.5.2.2 2003/04/19 19:56:40 RD
|
||||
* Updated Scintilla to 1.52
|
||||
* Revision 1.5.2.4 2003/09/18 18:14:11 RD
|
||||
* Updated wxSTC in 2.4 branch to Scintilla 1.54.
|
||||
* Also includes patches from ABX and new sample from Otto Wyss
|
||||
*
|
||||
* Revision 1.8 2003/09/18 05:05:38 RD
|
||||
* Updated to Scintilla 1.54
|
||||
* Applied most of patch #806092
|
||||
* Added new wxSTC sample from Otto Wyss
|
||||
*
|
||||
* Revision 1.9 2003/03/21 10:36:08 nyamatongwe
|
||||
* Detect patterns too long in regular expression search.
|
||||
@@ -82,17 +88,17 @@
|
||||
*
|
||||
* Revision 1.2 88/08/28 15:36:04 oz
|
||||
* Use a complement bitmap to represent NCL.
|
||||
* This removes the need to have seperate
|
||||
* code in the PMatch case block - it is
|
||||
* This removes the need to have seperate
|
||||
* code in the PMatch case block - it is
|
||||
* just CCL code now.
|
||||
*
|
||||
*
|
||||
* Use the actual CCL code in the CLO
|
||||
* section of PMatch. No need for a recursive
|
||||
* PMatch call.
|
||||
*
|
||||
*
|
||||
* Use a bitmap table to set char bits in an
|
||||
* 8-bit chunk.
|
||||
*
|
||||
*
|
||||
* Interfaces:
|
||||
* RESearch::Compile: compile a regular expression into a NFA.
|
||||
*
|
||||
@@ -122,7 +128,7 @@
|
||||
* void re_fail(msg, op)
|
||||
* char *msg;
|
||||
* char op;
|
||||
*
|
||||
*
|
||||
* Regular Expressions:
|
||||
*
|
||||
* [1] char matches itself, unless it is a special
|
||||
@@ -132,20 +138,20 @@
|
||||
*
|
||||
* [3] \ matches the character following it, except
|
||||
* when followed by a left or right round bracket,
|
||||
* a digit 1 to 9 or a left or right angle bracket.
|
||||
* a digit 1 to 9 or a left or right angle bracket.
|
||||
* (see [7], [8] and [9])
|
||||
* It is used as an escape character for all
|
||||
* It is used as an escape character for all
|
||||
* other meta-characters, and itself. When used
|
||||
* in a set ([4]), it is treated as an ordinary
|
||||
* character.
|
||||
*
|
||||
* [4] [set] matches one of the characters in the set.
|
||||
* If the first character in the set is "^",
|
||||
* it matches a character NOT in the set, i.e.
|
||||
* complements the set. A shorthand S-E is
|
||||
* used to specify a set of characters S upto
|
||||
* E, inclusive. The special characters "]" and
|
||||
* "-" have no special meaning if they appear
|
||||
* it matches a character NOT in the set, i.e.
|
||||
* complements the set. A shorthand S-E is
|
||||
* used to specify a set of characters S upto
|
||||
* E, inclusive. The special characters "]" and
|
||||
* "-" have no special meaning if they appear
|
||||
* as the first chars in the set.
|
||||
* examples: match:
|
||||
*
|
||||
@@ -210,8 +216,8 @@
|
||||
* Notes:
|
||||
*
|
||||
* This implementation uses a bit-set representation for character
|
||||
* classes for speed and compactness. Each character is represented
|
||||
* by one bit in a 128-bit block. Thus, CCL always takes a
|
||||
* classes for speed and compactness. Each character is represented
|
||||
* by one bit in a 128-bit block. Thus, CCL always takes a
|
||||
* constant 16 bytes in the internal nfa, and RESearch::Execute does a single
|
||||
* bit comparison to locate the character in the set.
|
||||
*
|
||||
@@ -221,7 +227,7 @@
|
||||
* compile: CHR f CHR o CLO CHR o END CLO ANY END END
|
||||
* matches: fo foo fooo foobar fobar foxx ...
|
||||
*
|
||||
* pattern: fo[ob]a[rz]
|
||||
* pattern: fo[ob]a[rz]
|
||||
* compile: CHR f CHR o CCL bitset CHR a CCL bitset END
|
||||
* matches: fobar fooar fobaz fooaz
|
||||
*
|
||||
@@ -269,7 +275,7 @@
|
||||
const char bitarr[] = {1,2,4,8,16,32,64,'\200'};
|
||||
|
||||
#define badpat(x) (*nfa = END, x)
|
||||
|
||||
|
||||
RESearch::RESearch() {
|
||||
Init();
|
||||
}
|
||||
@@ -359,7 +365,7 @@ const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, b
|
||||
int n;
|
||||
char mask; /* xor mask -CCL/NCL */
|
||||
int c1, c2;
|
||||
|
||||
|
||||
if (!pat || !length)
|
||||
if (sta)
|
||||
return 0;
|
||||
@@ -401,7 +407,7 @@ const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, b
|
||||
|
||||
i++;
|
||||
if (*++p == '^') {
|
||||
mask = '\377';
|
||||
mask = '\377';
|
||||
i++;
|
||||
p++;
|
||||
} else
|
||||
@@ -445,7 +451,7 @@ const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, b
|
||||
|
||||
for (n = 0; n < BITBLK; bittab[n++] = (char) 0)
|
||||
*mp++ = static_cast<char>(mask ^ bittab[n]);
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case '*': /* match 0 or more.. */
|
||||
@@ -590,7 +596,7 @@ const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, b
|
||||
* RESearch::Execute:
|
||||
* execute nfa to find a match.
|
||||
*
|
||||
* special cases: (nfa[0])
|
||||
* special cases: (nfa[0])
|
||||
* BOL
|
||||
* Match only once, starting from the
|
||||
* beginning.
|
||||
@@ -615,7 +621,7 @@ int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) {
|
||||
|
||||
bol = lp;
|
||||
failure = 0;
|
||||
|
||||
|
||||
Clear();
|
||||
|
||||
switch(*ap) {
|
||||
@@ -656,7 +662,7 @@ int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* PMatch: internal routine for the hard part
|
||||
*
|
||||
* This code is partly snarfed from an early grep written by
|
||||
@@ -682,7 +688,7 @@ int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) {
|
||||
*
|
||||
* At the end of a successful match, bopat[n] and eopat[n]
|
||||
* are set to the beginning and end of subpatterns matched
|
||||
* by tagged expressions (n = 1 to 9).
|
||||
* by tagged expressions (n = 1 to 9).
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -693,23 +699,23 @@ extern void re_fail(char *,char);
|
||||
* and EOW. the reason for not using ctype macros is that we can
|
||||
* let the user add into our own table. see RESearch::ModifyWord. This table
|
||||
* is not in the bitset form, since we may wish to extend it in the
|
||||
* future for other character classifications.
|
||||
* future for other character classifications.
|
||||
*
|
||||
* TRUE for 0-9 A-Z a-z _
|
||||
*/
|
||||
static char chrtyp[MAXCHR] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 0, 0, 0, 0, 1, 0, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 0, 0, 0, 0, 1, 0, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
@@ -831,10 +837,10 @@ int RESearch::PMatch(CharacterIndexer &ci, int lp, int endp, char *ap) {
|
||||
* the compact bitset representation for the default table]
|
||||
*/
|
||||
|
||||
static char deftab[16] = {
|
||||
0, 0, 0, 0, 0, 0, '\377', 003, '\376', '\377', '\377', '\207',
|
||||
'\376', '\377', '\377', 007
|
||||
};
|
||||
static char deftab[16] = {
|
||||
0, 0, 0, 0, 0, 0, '\377', 003, '\376', '\377', '\377', '\207',
|
||||
'\376', '\377', '\377', 007
|
||||
};
|
||||
|
||||
void RESearch::ModifyWord(char *s) {
|
||||
int i;
|
||||
@@ -881,7 +887,7 @@ int RESearch::Substitute(CharacterIndexer &ci, char *src, char *dst) {
|
||||
pin = c - '0';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
*dst++ = c;
|
||||
continue;
|
||||
|
@@ -18,7 +18,7 @@
|
||||
#define BITBLK MAXCHR/CHRBIT
|
||||
|
||||
class CharacterIndexer {
|
||||
public:
|
||||
public:
|
||||
virtual char CharAt(int index)=0;
|
||||
};
|
||||
|
||||
|
@@ -15,18 +15,18 @@
|
||||
*/
|
||||
class SVector {
|
||||
enum { allocSize = 4000 };
|
||||
|
||||
|
||||
int *v; ///< The vector
|
||||
unsigned int size; ///< Number of elements allocated
|
||||
unsigned int len; ///< Number of elements used in vector
|
||||
bool allocFailure; ///< A memory allocation call has failed
|
||||
|
||||
|
||||
/** Internally allocate more elements than the user wants
|
||||
* to avoid thrashing the memory allocator. */
|
||||
void SizeTo(int newSize) {
|
||||
if (newSize < allocSize)
|
||||
newSize += allocSize;
|
||||
else
|
||||
else
|
||||
newSize = (newSize * 3) / 2;
|
||||
int* newv = new int[newSize];
|
||||
if (!newv) {
|
||||
@@ -44,7 +44,7 @@ class SVector {
|
||||
delete []v;
|
||||
v = newv;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
SVector() {
|
||||
allocFailure = false;
|
||||
|
@@ -203,11 +203,11 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
|
||||
pdoc->DeleteChars(currentPos, lenEntered);
|
||||
SetEmptySelection(currentPos);
|
||||
pdoc->InsertString(currentPos, list);
|
||||
SetEmptySelection(currentPos + strlen(list));
|
||||
SetEmptySelection(currentPos + static_cast<int>(strlen(list)));
|
||||
} else {
|
||||
SetEmptySelection(currentPos);
|
||||
pdoc->InsertString(currentPos, list + lenEntered);
|
||||
SetEmptySelection(currentPos + strlen(list + lenEntered));
|
||||
SetEmptySelection(currentPos + static_cast<int>(strlen(list + lenEntered)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -340,7 +340,7 @@ void ScintillaBase::AutoCompleteCompleted() {
|
||||
if (item != -1) {
|
||||
SString piece = selected;
|
||||
pdoc->InsertString(firstPos, piece.c_str());
|
||||
SetEmptySelection(firstPos + piece.length());
|
||||
SetEmptySelection(firstPos + static_cast<int>(piece.length()));
|
||||
}
|
||||
pdoc->EndUndoAction();
|
||||
}
|
||||
@@ -557,7 +557,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
|
||||
return ac.GetTypesep();
|
||||
|
||||
case SCI_CALLTIPSHOW:
|
||||
CallTipShow(LocationFromPosition(wParam),
|
||||
CallTipShow(LocationFromPosition(wParam),
|
||||
reinterpret_cast<const char *>(lParam));
|
||||
break;
|
||||
|
||||
|
@@ -43,7 +43,7 @@ protected:
|
||||
int lexLanguage;
|
||||
const LexerModule *lexCurrent;
|
||||
PropSet props;
|
||||
enum {numWordLists=9};
|
||||
enum {numWordLists=KEYWORDSET_MAX+1};
|
||||
WordList *keyWordLists[numWordLists+1];
|
||||
void SetLexer(uptr_t wParam);
|
||||
void SetLexerLanguage(const char *languageName);
|
||||
|
@@ -67,8 +67,8 @@ Style &Style::operator=(const Style &source) {
|
||||
|
||||
void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
|
||||
const char *fontName_, int characterSet_,
|
||||
bool bold_, bool italic_, bool eolFilled_,
|
||||
bool underline_, ecaseForced caseForce_,
|
||||
bool bold_, bool italic_, bool eolFilled_,
|
||||
bool underline_, ecaseForced caseForce_,
|
||||
bool visible_, bool changeable_, bool hotspot_) {
|
||||
fore.desired = fore_;
|
||||
back.desired = back_;
|
||||
@@ -102,7 +102,7 @@ void Style::ClearTo(const Style &source) {
|
||||
source.eolFilled,
|
||||
source.underline,
|
||||
source.caseForce,
|
||||
source.visible,
|
||||
source.visible,
|
||||
source.changeable,
|
||||
source.hotspot);
|
||||
}
|
||||
|
@@ -44,8 +44,8 @@ public:
|
||||
void Clear(ColourDesired fore_, ColourDesired back_,
|
||||
int size_,
|
||||
const char *fontName_, int characterSet_,
|
||||
bool bold_, bool italic_, bool eolFilled_,
|
||||
bool underline_, ecaseForced caseForce_,
|
||||
bool bold_, bool italic_, bool eolFilled_,
|
||||
bool underline_, ecaseForced caseForce_,
|
||||
bool visible_, bool changeable_, bool hotspot_);
|
||||
void ClearTo(const Style &source);
|
||||
bool EquivalentFontTo(const Style *other) const;
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Platform.h"
|
||||
@@ -24,7 +24,7 @@ bool WindowAccessor::InternalIsLeadByte(char ch) {
|
||||
if (SC_CP_UTF8 == codePage)
|
||||
// For lexing, all characters >= 0x80 are treated the
|
||||
// same so none is considered a lead byte.
|
||||
return false;
|
||||
return false;
|
||||
else
|
||||
return Platform::IsDBCSLeadByte(codePage, ch);
|
||||
}
|
||||
@@ -71,10 +71,10 @@ int WindowAccessor::LevelAt(int line) {
|
||||
return Platform::SendScintilla(id, SCI_GETFOLDLEVEL, line, 0);
|
||||
}
|
||||
|
||||
int WindowAccessor::Length() {
|
||||
if (lenDoc == -1)
|
||||
int WindowAccessor::Length() {
|
||||
if (lenDoc == -1)
|
||||
lenDoc = Platform::SendScintilla(id, SCI_GETTEXTLENGTH, 0, 0);
|
||||
return lenDoc;
|
||||
return lenDoc;
|
||||
}
|
||||
|
||||
int WindowAccessor::GetLineState(int line) {
|
||||
@@ -125,7 +125,7 @@ void WindowAccessor::Flush() {
|
||||
startPos = extremePosition;
|
||||
lenDoc = -1;
|
||||
if (validLen > 0) {
|
||||
Platform::SendScintillaPointer(id, SCI_SETSTYLINGEX, validLen,
|
||||
Platform::SendScintillaPointer(id, SCI_SETSTYLINGEX, validLen,
|
||||
styleBuf);
|
||||
validLen = 0;
|
||||
}
|
||||
@@ -134,12 +134,12 @@ void WindowAccessor::Flush() {
|
||||
int WindowAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) {
|
||||
int end = Length();
|
||||
int spaceFlags = 0;
|
||||
|
||||
// Determines the indentation level of the current line and also checks for consistent
|
||||
|
||||
// Determines the indentation level of the current line and also checks for consistent
|
||||
// indentation compared to the previous line.
|
||||
// Indentation is judged consistent when the indentation whitespace of each line lines
|
||||
// Indentation is judged consistent when the indentation whitespace of each line lines
|
||||
// the same or the indentation of one line is a prefix of the other.
|
||||
|
||||
|
||||
int pos = LineStart(line);
|
||||
char ch = (*this)[pos];
|
||||
int indent = 0;
|
||||
@@ -166,7 +166,7 @@ int WindowAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsC
|
||||
}
|
||||
ch = (*this)[++pos];
|
||||
}
|
||||
|
||||
|
||||
*flags = spaceFlags;
|
||||
indent += SC_FOLDLEVELBASE;
|
||||
// if completely empty line or the start of a comment...
|
||||
|
@@ -49,7 +49,7 @@ void XPM::FillRun(Surface *surface, int code, int startX, int y, int x) {
|
||||
}
|
||||
}
|
||||
|
||||
XPM::XPM(const char *textForm) :
|
||||
XPM::XPM(const char *textForm) :
|
||||
data(0), codes(0), colours(0), lines(0) {
|
||||
Init(textForm);
|
||||
}
|
||||
@@ -102,7 +102,7 @@ void XPM::Init(const char * const *linesForm) {
|
||||
|
||||
int strings = 1+height+nColours;
|
||||
lines = new char *[strings];
|
||||
int allocation = 0;
|
||||
size_t allocation = 0;
|
||||
for (int i=0; i<strings; i++) {
|
||||
allocation += MeasureLength(linesForm[i]) + 1;
|
||||
}
|
||||
|
@@ -1121,7 +1121,7 @@ wxString wxStyledTextCtrl::GetSelectedText() {
|
||||
int len = end - start;
|
||||
if (!len) return wxEmptyString;
|
||||
|
||||
wxMemoryBuffer mbuf(len+1);
|
||||
wxMemoryBuffer mbuf(len+2);
|
||||
char* buf = (char*)mbuf.GetWriteBuf(len+1);
|
||||
SendMsg(2161, 0, (long)buf);
|
||||
mbuf.UngetWriteBuf(len);
|
||||
@@ -1618,6 +1618,11 @@ void wxStyledTextCtrl::LineEndDisplayExtend() {
|
||||
SendMsg(2348, 0, 0);
|
||||
}
|
||||
|
||||
// Copy the line containing the caret.
|
||||
void wxStyledTextCtrl::LineCopy() {
|
||||
SendMsg(2455, 0, 0);
|
||||
}
|
||||
|
||||
// Move the caret inside current view if it's not there already.
|
||||
void wxStyledTextCtrl::MoveCaretInsideView() {
|
||||
SendMsg(2401, 0, 0);
|
||||
@@ -1797,12 +1802,12 @@ bool wxStyledTextCtrl::GetMouseDownCaptures() {
|
||||
}
|
||||
|
||||
// Sets the cursor to one of the SC_CURSOR* values.
|
||||
void wxStyledTextCtrl::SetCursor(int cursorType) {
|
||||
void wxStyledTextCtrl::SetSTCCursor(int cursorType) {
|
||||
SendMsg(2386, cursorType, 0);
|
||||
}
|
||||
|
||||
// Get cursor type.
|
||||
int wxStyledTextCtrl::GetCursor() {
|
||||
int wxStyledTextCtrl::GetSTCCursor() {
|
||||
return SendMsg(2387, 0, 0);
|
||||
}
|
||||
|
||||
@@ -1905,6 +1910,28 @@ void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline) {
|
||||
SendMsg(2412, underline, 0);
|
||||
}
|
||||
|
||||
// Given a valid document position, return the previous position taking code
|
||||
// page into account. Returns 0 if passed 0.
|
||||
int wxStyledTextCtrl::PositionBefore(int pos) {
|
||||
return SendMsg(2417, pos, 0);
|
||||
}
|
||||
|
||||
// Given a valid document position, return the next position taking code
|
||||
// page into account. Maximum value returned is the last position in the document.
|
||||
int wxStyledTextCtrl::PositionAfter(int pos) {
|
||||
return SendMsg(2418, pos, 0);
|
||||
}
|
||||
|
||||
// Copy a range of text to the clipboard. Positions are clipped into the document.
|
||||
void wxStyledTextCtrl::CopyRange(int start, int end) {
|
||||
SendMsg(2419, start, end);
|
||||
}
|
||||
|
||||
// Copy argument text to the clipboard.
|
||||
void wxStyledTextCtrl::CopyText(int length, const wxString& text) {
|
||||
SendMsg(2420, length, (long)(const char*)wx2stc(text));
|
||||
}
|
||||
|
||||
// Start notifying the container of all key presses and commands.
|
||||
void wxStyledTextCtrl::StartRecord() {
|
||||
SendMsg(3001, 0, 0);
|
||||
@@ -2010,6 +2037,11 @@ void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
|
||||
// Set style size, face, bold, italic, and underline attributes from
|
||||
// a wxFont's attributes.
|
||||
void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
|
||||
#ifdef __WXGTK__
|
||||
// Ensure that the native font is initialized
|
||||
int x, y;
|
||||
GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font);
|
||||
#endif
|
||||
int size = font.GetPointSize();
|
||||
wxString faceName = font.GetFaceName();
|
||||
bool bold = font.GetWeight() == wxBOLD;
|
||||
@@ -2083,7 +2115,7 @@ bool wxStyledTextCtrl::SaveFile(const wxString& filename)
|
||||
if (!file.IsOpened())
|
||||
return FALSE;
|
||||
|
||||
bool success = file.Write(GetText());
|
||||
bool success = file.Write(GetText(), *wxConvCurrent);
|
||||
|
||||
if (success)
|
||||
SetSavePoint();
|
||||
@@ -2093,33 +2125,58 @@ bool wxStyledTextCtrl::SaveFile(const wxString& filename)
|
||||
|
||||
bool wxStyledTextCtrl::LoadFile(const wxString& filename)
|
||||
{
|
||||
bool success = false;
|
||||
wxFile file(filename, wxFile::read);
|
||||
|
||||
if (!file.IsOpened())
|
||||
return FALSE;
|
||||
|
||||
wxString contents;
|
||||
off_t len = file.Length();
|
||||
|
||||
wxChar *buf = contents.GetWriteBuf(len);
|
||||
bool success = (file.Read(buf, len) == len);
|
||||
contents.UngetWriteBuf();
|
||||
|
||||
if (success)
|
||||
if (file.IsOpened())
|
||||
{
|
||||
SetText(contents);
|
||||
EmptyUndoBuffer();
|
||||
SetSavePoint();
|
||||
wxString contents;
|
||||
#if wxUSE_UNICODE
|
||||
wxMemoryBuffer buffer;
|
||||
#else
|
||||
wxString buffer;
|
||||
#endif
|
||||
off_t len = file.Length();
|
||||
if (len > 0)
|
||||
{
|
||||
void *bufptr = buffer.GetWriteBuf(len);
|
||||
success = (file.Read(bufptr, len) == len);
|
||||
buffer.UngetWriteBuf(len);
|
||||
#if wxUSE_UNICODE
|
||||
contents = wxString(buffer, *wxConvCurrent);
|
||||
#else
|
||||
contents = buffer;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
success = true; // empty file is ok
|
||||
|
||||
if (success)
|
||||
{
|
||||
SetText(contents);
|
||||
EmptyUndoBuffer();
|
||||
SetSavePoint();
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
|
||||
return m_swx->DoDragOver(x, y, def);
|
||||
}
|
||||
|
||||
|
||||
bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) {
|
||||
return m_swx->DoDropText(x, y, data);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Event handlers
|
||||
|
||||
void wxStyledTextCtrl::OnPaint(wxPaintEvent& evt) {
|
||||
void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
|
||||
wxPaintDC dc(this);
|
||||
m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
|
||||
}
|
||||
@@ -2141,7 +2198,7 @@ void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
|
||||
}
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) {
|
||||
void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) {
|
||||
wxSize sz = GetClientSize();
|
||||
m_swx->DoSize(sz.x, sz.y);
|
||||
}
|
||||
@@ -2219,9 +2276,10 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
|
||||
int key = evt.GetKeyCode();
|
||||
bool shift = evt.ShiftDown(),
|
||||
ctrl = evt.ControlDown(),
|
||||
alt = evt.AltDown();
|
||||
alt = evt.AltDown(),
|
||||
meta = evt.MetaDown();
|
||||
|
||||
int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed);
|
||||
int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, meta, &m_lastKeyDownConsumed);
|
||||
|
||||
// printf("KeyDn key:%d shift:%d ctrl:%d alt:%d processed:%d consumed:%d\n",
|
||||
// key, shift, ctrl, alt, processed, m_lastKeyDownConsumed);
|
||||
@@ -2231,22 +2289,22 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
|
||||
void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& WXUNUSED(evt)) {
|
||||
m_swx->DoLoseFocus();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
|
||||
void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& WXUNUSED(evt)) {
|
||||
m_swx->DoGainFocus();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& evt) {
|
||||
void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) {
|
||||
m_swx->DoSysColourChange();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& evt) {
|
||||
void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) {
|
||||
// do nothing to help avoid flashing
|
||||
}
|
||||
|
||||
@@ -2257,7 +2315,7 @@ void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) {
|
||||
void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) {
|
||||
m_swx->DoOnListBox();
|
||||
}
|
||||
|
||||
|
@@ -242,6 +242,11 @@ void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
|
||||
// Set style size, face, bold, italic, and underline attributes from
|
||||
// a wxFont's attributes.
|
||||
void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
|
||||
#ifdef __WXGTK__
|
||||
// Ensure that the native font is initialized
|
||||
int x, y;
|
||||
GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font);
|
||||
#endif
|
||||
int size = font.GetPointSize();
|
||||
wxString faceName = font.GetFaceName();
|
||||
bool bold = font.GetWeight() == wxBOLD;
|
||||
@@ -315,7 +320,7 @@ bool wxStyledTextCtrl::SaveFile(const wxString& filename)
|
||||
if (!file.IsOpened())
|
||||
return FALSE;
|
||||
|
||||
bool success = file.Write(GetText());
|
||||
bool success = file.Write(GetText(), *wxConvCurrent);
|
||||
|
||||
if (success)
|
||||
SetSavePoint();
|
||||
@@ -325,33 +330,58 @@ bool wxStyledTextCtrl::SaveFile(const wxString& filename)
|
||||
|
||||
bool wxStyledTextCtrl::LoadFile(const wxString& filename)
|
||||
{
|
||||
bool success = false;
|
||||
wxFile file(filename, wxFile::read);
|
||||
|
||||
if (!file.IsOpened())
|
||||
return FALSE;
|
||||
|
||||
wxString contents;
|
||||
off_t len = file.Length();
|
||||
|
||||
wxChar *buf = contents.GetWriteBuf(len);
|
||||
bool success = (file.Read(buf, len) == len);
|
||||
contents.UngetWriteBuf();
|
||||
|
||||
if (success)
|
||||
if (file.IsOpened())
|
||||
{
|
||||
SetText(contents);
|
||||
EmptyUndoBuffer();
|
||||
SetSavePoint();
|
||||
wxString contents;
|
||||
#if wxUSE_UNICODE
|
||||
wxMemoryBuffer buffer;
|
||||
#else
|
||||
wxString buffer;
|
||||
#endif
|
||||
off_t len = file.Length();
|
||||
if (len > 0)
|
||||
{
|
||||
void *bufptr = buffer.GetWriteBuf(len);
|
||||
success = (file.Read(bufptr, len) == len);
|
||||
buffer.UngetWriteBuf(len);
|
||||
#if wxUSE_UNICODE
|
||||
contents = wxString(buffer, *wxConvCurrent);
|
||||
#else
|
||||
contents = buffer;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
success = true; // empty file is ok
|
||||
|
||||
if (success)
|
||||
{
|
||||
SetText(contents);
|
||||
EmptyUndoBuffer();
|
||||
SetSavePoint();
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
|
||||
return m_swx->DoDragOver(x, y, def);
|
||||
}
|
||||
|
||||
|
||||
bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) {
|
||||
return m_swx->DoDropText(x, y, data);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Event handlers
|
||||
|
||||
void wxStyledTextCtrl::OnPaint(wxPaintEvent& evt) {
|
||||
void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
|
||||
wxPaintDC dc(this);
|
||||
m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
|
||||
}
|
||||
@@ -373,7 +403,7 @@ void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
|
||||
}
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) {
|
||||
void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) {
|
||||
wxSize sz = GetClientSize();
|
||||
m_swx->DoSize(sz.x, sz.y);
|
||||
}
|
||||
@@ -451,9 +481,10 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
|
||||
int key = evt.GetKeyCode();
|
||||
bool shift = evt.ShiftDown(),
|
||||
ctrl = evt.ControlDown(),
|
||||
alt = evt.AltDown();
|
||||
alt = evt.AltDown(),
|
||||
meta = evt.MetaDown();
|
||||
|
||||
int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed);
|
||||
int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, meta, &m_lastKeyDownConsumed);
|
||||
|
||||
// printf("KeyDn key:%%d shift:%%d ctrl:%%d alt:%%d processed:%%d consumed:%%d\n",
|
||||
// key, shift, ctrl, alt, processed, m_lastKeyDownConsumed);
|
||||
@@ -463,22 +494,22 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
|
||||
void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& WXUNUSED(evt)) {
|
||||
m_swx->DoLoseFocus();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
|
||||
void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& WXUNUSED(evt)) {
|
||||
m_swx->DoGainFocus();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& evt) {
|
||||
void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) {
|
||||
m_swx->DoSysColourChange();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& evt) {
|
||||
void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) {
|
||||
// do nothing to help avoid flashing
|
||||
}
|
||||
|
||||
@@ -489,7 +520,7 @@ void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) {
|
||||
void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) {
|
||||
m_swx->DoOnListBox();
|
||||
}
|
||||
|
||||
|
@@ -65,6 +65,7 @@
|
||||
|
||||
//-----------------------------------------
|
||||
// Commands that can be bound to keystrokes
|
||||
|
||||
%(CMDS)s
|
||||
|
||||
|
||||
@@ -199,6 +200,12 @@ public:
|
||||
// Load the contents of filename into the editor
|
||||
bool LoadFile(const wxString& filename);
|
||||
|
||||
// Allow for simulating a DnD DragOver
|
||||
wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def);
|
||||
|
||||
// Allow for simulating a DnD DropText
|
||||
bool DoDropText(long x, long y, const wxString& data);
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@@ -463,13 +470,14 @@ inline wxString stc2wx(const char* str) {
|
||||
#endif
|
||||
}
|
||||
|
||||
inline wxString stc2wx(const char* str, size_t len) {
|
||||
#if wxUSE_UNICODE
|
||||
return wxString(str, wxConvUTF8, len);
|
||||
wxString stc2wx(const char* str, size_t len);
|
||||
#else
|
||||
inline wxString stc2wx(const char* str, size_t len) {
|
||||
return wxString(str, len);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
inline const wxWX2MBbuf wx2stc(const wxString& str) {
|
||||
|
20
contrib/src/svg/makefile.sc
Normal file
20
contrib/src/svg/makefile.sc
Normal file
@@ -0,0 +1,20 @@
|
||||
##############################################################################
|
||||
# Name: src/zlib/makefile.sc
|
||||
# Purpose: build zlib Digital Mars 8.33 compiler
|
||||
# Author: Chris Elliott
|
||||
# Created: 21.01.03
|
||||
# RCS-ID: $Id$
|
||||
# Licence: wxWindows licence
|
||||
##############################################################################
|
||||
|
||||
WXDIR = ..\..\..
|
||||
include $(WXDIR)\src\makesc.env
|
||||
LIBTARGET=$(WXDIR)\lib\dcsvg$(SC_SUFFIX).lib
|
||||
THISDIR=$(WXDIR)\contrib\src\svg
|
||||
|
||||
# variables
|
||||
OBJECTS = \
|
||||
$(THISDIR)\dcsvg.obj
|
||||
|
||||
include $(WXDIR)\src\makelib.sc
|
||||
|
@@ -30,6 +30,7 @@ wxButtonXmlHandler::wxButtonXmlHandler()
|
||||
XRC_ADD_STYLE(wxBU_RIGHT);
|
||||
XRC_ADD_STYLE(wxBU_TOP);
|
||||
XRC_ADD_STYLE(wxBU_BOTTOM);
|
||||
XRC_ADD_STYLE(wxBU_EXACTFIT);
|
||||
AddWindowStyles();
|
||||
}
|
||||
|
||||
|
@@ -24,18 +24,22 @@
|
||||
#include "wx/xrc/xh_chckl.h"
|
||||
#include "wx/checklst.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/log.h"
|
||||
|
||||
wxCheckListXmlHandler::wxCheckListXmlHandler()
|
||||
wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler()
|
||||
: wxXmlResourceHandler(), m_insideBox(FALSE)
|
||||
{
|
||||
// no styles
|
||||
AddWindowStyles();
|
||||
}
|
||||
|
||||
wxObject *wxCheckListXmlHandler::DoCreateResource()
|
||||
wxObject *wxCheckListBoxXmlHandler::DoCreateResource()
|
||||
{
|
||||
if (m_class == wxT("wxCheckList"))
|
||||
if (m_class == wxT("wxCheckListBox") || m_class == wxT("wxCheckList"))
|
||||
{
|
||||
if (m_class == wxT("wxCheckList"))
|
||||
wxLogDebug(wxT("'wxCheckList' name is deprecated, use 'wxCheckListBox' instead."));
|
||||
|
||||
// need to build the list of strings from children
|
||||
m_insideBox = TRUE;
|
||||
CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
|
||||
@@ -101,10 +105,11 @@ wxObject *wxCheckListXmlHandler::DoCreateResource()
|
||||
}
|
||||
}
|
||||
|
||||
bool wxCheckListXmlHandler::CanHandle(wxXmlNode *node)
|
||||
bool wxCheckListBoxXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return (IsOfClass(node, wxT("wxCheckList")) ||
|
||||
return (IsOfClass(node, wxT("wxCheckListBox")) ||
|
||||
IsOfClass(node, wxT("wxCheckList")) /*backward compatibility*/ ||
|
||||
(m_insideBox && node->GetName() == wxT("item")));
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@@ -40,6 +40,7 @@ wxListCtrlXmlHandler::wxListCtrlXmlHandler()
|
||||
XRC_ADD_STYLE(wxLC_SINGLE_SEL);
|
||||
XRC_ADD_STYLE(wxLC_SORT_ASCENDING);
|
||||
XRC_ADD_STYLE(wxLC_SORT_DESCENDING);
|
||||
XRC_ADD_STYLE(wxLC_VIRTUAL);
|
||||
AddWindowStyles();
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user