Updated wxSTC in 2.4 branch to Scintilla 1.54.

Also includes patches from ABX and new sample from Otto Wyss


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@23683 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-09-18 18:14:34 +00:00
parent 3bfecd48e0
commit c7b539b354
70 changed files with 1516 additions and 579 deletions

View File

@@ -166,6 +166,7 @@
#define wxSTC_INDIC_TT 2 #define wxSTC_INDIC_TT 2
#define wxSTC_INDIC_DIAGONAL 3 #define wxSTC_INDIC_DIAGONAL 3
#define wxSTC_INDIC_STRIKE 4 #define wxSTC_INDIC_STRIKE 4
#define wxSTC_INDIC_HIDDEN 5
#define wxSTC_INDIC0_MASK 0x20 #define wxSTC_INDIC0_MASK 0x20
#define wxSTC_INDIC1_MASK 0x40 #define wxSTC_INDIC1_MASK 0x40
#define wxSTC_INDIC2_MASK 0x80 #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. // where most code reside, and the lines after the caret, eg. the body of a function.
#define wxSTC_CARET_EVEN 0x08 #define wxSTC_CARET_EVEN 0x08
// Maximum value of keywordSet parameter of SetKeyWords.
#define wxSTC_KEYWORDSET_MAX 8
// Notifications // Notifications
// Type of modification and the action which caused the modification. // 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. // These are defined as a bit mask to make it easy to specify which notifications are wanted.
@@ -331,6 +335,9 @@
#define wxSTC_LEX_POV 39 #define wxSTC_LEX_POV 39
#define wxSTC_LEX_LOUT 40 #define wxSTC_LEX_LOUT 40
#define wxSTC_LEX_ESCRIPT 41 #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 // When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
// value assigned in sequence from SCLEX_AUTOMATIC+1. // value assigned in sequence from SCLEX_AUTOMATIC+1.
@@ -584,6 +591,8 @@
#define wxSTC_LUA_WORD4 15 #define wxSTC_LUA_WORD4 15
#define wxSTC_LUA_WORD5 16 #define wxSTC_LUA_WORD5 16
#define wxSTC_LUA_WORD6 17 #define wxSTC_LUA_WORD6 17
#define wxSTC_LUA_WORD7 18
#define wxSTC_LUA_WORD8 19
// Lexical states for SCLEX_ERRORLIST // Lexical states for SCLEX_ERRORLIST
#define wxSTC_ERR_DEFAULT 0 #define wxSTC_ERR_DEFAULT 0
@@ -805,14 +814,20 @@
#define wxSTC_POV_DEFAULT 0 #define wxSTC_POV_DEFAULT 0
#define wxSTC_POV_COMMENT 1 #define wxSTC_POV_COMMENT 1
#define wxSTC_POV_COMMENTLINE 2 #define wxSTC_POV_COMMENTLINE 2
#define wxSTC_POV_COMMENTDOC 3 #define wxSTC_POV_NUMBER 3
#define wxSTC_POV_NUMBER 4 #define wxSTC_POV_OPERATOR 4
#define wxSTC_POV_WORD 5 #define wxSTC_POV_IDENTIFIER 5
#define wxSTC_POV_STRING 6 #define wxSTC_POV_STRING 6
#define wxSTC_POV_OPERATOR 7 #define wxSTC_POV_STRINGEOL 7
#define wxSTC_POV_IDENTIFIER 8 #define wxSTC_POV_DIRECTIVE 8
#define wxSTC_POV_BRACE 9 #define wxSTC_POV_BADDIRECTIVE 9
#define wxSTC_POV_WORD2 10 #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 // Lexical states for SCLEX_LOUT
#define wxSTC_LOUT_DEFAULT 0 #define wxSTC_LOUT_DEFAULT 0
@@ -841,10 +856,65 @@
#define wxSTC_ESCRIPT_WORD2 10 #define wxSTC_ESCRIPT_WORD2 10
#define wxSTC_ESCRIPT_WORD3 11 #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 // Commands that can be bound to keystrokes
// Redoes the next action on the undo history. // Redoes the next action on the undo history.
#define wxSTC_CMD_REDO 2011 #define wxSTC_CMD_REDO 2011
@@ -2023,10 +2093,10 @@ public:
bool GetMouseDownCaptures(); bool GetMouseDownCaptures();
// Sets the cursor to one of the SC_CURSOR* values. // Sets the cursor to one of the SC_CURSOR* values.
void SetCursor(int cursorType); void SetSTCCursor(int cursorType);
// Get cursor type. // Get cursor type.
int GetCursor(); int GetSTCCursor();
// Change the way control characters are displayed: // Change the way control characters are displayed:
// If symbol is < 32, keep the drawn way, else, use the given character. // If symbol is < 32, keep the drawn way, else, use the given character.

View File

@@ -11,7 +11,7 @@ program_dir = contrib/samples/stc
PROGRAM=stctest 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@ APPEXTRALIBS=$(top_builddir)/lib/lib@WX_LIBRARY_BASENAME@_stc-@WX_RELEASE@.@WX_TARGET_LIBRARY_TYPE@
APPEXTRADEFS=-I$(top_srcdir)/contrib/include APPEXTRADEFS=-I$(top_srcdir)/contrib/include

View File

@@ -1,6 +1,6 @@
#Makefile from wxHatch for Symantec/Digital Mars compiler #Makefile from wxHatch for Symantec/Digital Mars compiler
WXDIR=..\..\.. WXDIR=..\..\..
TARGET=stctest TARGET=stctest
OBJECTS = $(TARGET).obj OBJECTS = $(TARGET).obj edit.obj prefs.obj
EXTRALIBS=$(WXDIR)\lib\stc_sc.lib EXTRALIBS=$(WXDIR)\lib\stc_sc.lib
include $(WXDIR)\src\makeprog.sc include $(WXDIR)\src\makeprog.sc

View File

@@ -167,6 +167,14 @@ SOURCE=.\stctest.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\edit.cpp
# End Source File
# Begin Source File
SOURCE=.\prefs.cpp
# End Source File
# Begin Source File
SOURCE=.\stctest.rc SOURCE=.\stctest.rc
# ADD BASE RSC /l 0x809 # ADD BASE RSC /l 0x809
# ADD RSC /l 0x809 /i "../../../include" /i "../../../contrib/include" # ADD RSC /l 0x809 /i "../../../include" /i "../../../contrib/include"

View File

@@ -12,7 +12,7 @@ WXDIR = $(WXWIN)
TARGET=stctest TARGET=stctest
EXTRALIBS=$(WXDIR)\lib\stc.lib EXTRALIBS=$(WXDIR)\lib\stc.lib
OBJECTS = $(TARGET).obj OBJECTS = $(TARGET).obj edit.obj prefs.obj
!include $(WXDIR)\src\makeprog.b32 !include $(WXDIR)\src\makeprog.b32

View File

@@ -6,7 +6,7 @@
WXDIR = ../../.. WXDIR = ../../..
TARGET = stctest TARGET = stctest
OBJECTS = $(TARGET).o OBJECTS = $(TARGET).o edit.o prefs.o
EXTRAINC = -I$(WXDIR)/contrib/include EXTRAINC = -I$(WXDIR)/contrib/include
EXTRALIBS = -lstc EXTRALIBS = -lstc

View File

@@ -6,7 +6,7 @@
WXDIR = $(WXWIN) WXDIR = $(WXWIN)
PROGRAM = stctest PROGRAM = stctest
OBJECTS = $(PROGRAM).obj OBJECTS = $(PROGRAM).obj edit.obj prefs.obj
EXTRALIBS = $(WXDIR)\lib\stc$(LIBEXT).lib EXTRALIBS = $(WXDIR)\lib\stc$(LIBEXT).lib
EXTRAINC = -I$(WXDIR)\contrib\include EXTRAINC = -I$(WXDIR)\contrib\include

View File

@@ -6,7 +6,7 @@ WXDIR = $(%WXWIN)
EXTRACPPFLAGS = -I$(WXDIR)\contrib\include EXTRACPPFLAGS = -I$(WXDIR)\contrib\include
PROGRAM = stctest PROGRAM = stctest
EXTRALIBS = $(WXDIR)\lib\stc_w.lib 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 !include $(WXDIR)\src\makeprog.wat

View File

@@ -1,252 +1,660 @@
///////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Name: stctest.cpp // File: app.cpp
// Purpose: sample of using wxStyledTextCtrl // Purpose: STC test application
// Author: Robin Dunn // Maintainer: Otto Wyss
// Modified by: // Created: 2003-09-01
// Created: 3-Feb-2000
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) 2000 by Total Control Software // Copyright: (c) wxGuide
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(__APPLE__) //----------------------------------------------------------------------------
#pragma implementation "stctest.cpp" // headers
#pragma interface "stctest.cpp" //----------------------------------------------------------------------------
#endif
// For compilers that support precompilation, includes "wx/wx.h". // For compilers that support precompilation, includes <wx/wx.h>.
#include "wx/wxprec.h" #include <wx/wxprec.h>
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#pragma hdrstop #pragma hdrstop
#endif #endif
// for all others, include the necessary headers (this file is usually all you // 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 #ifndef WX_PRECOMP
#include "wx/wx.h" #include <wx/wx.h>
#endif #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/indexedit.html")
#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: public:
virtual bool OnInit(); //! the main function called durning application start
}; virtual bool OnInit ();
//---------------------------------------------------------------------- //! application exit function
// Make an editor class virtual int OnExit ();
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);
private: 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() DECLARE_EVENT_TABLE()
}; };
BEGIN_EVENT_TABLE(MySTC, wxStyledTextCtrl) //----------------------------------------------------------------------------
EVT_KEY_DOWN(MySTC::OnKeyPressed) //! about box of the application APP_VENDOR-APP_NAME
END_EVENT_TABLE() class AppAbout: public wxDialog {
//----------------------------------------------------------------------
// Define a new frame type: this is going to be our main frame
class MyFrame : public wxFrame
{
public: 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); //! destructor
void OnAbout(wxCommandEvent& event); ~AppAbout ();
// event handlers
void OnTimerEvent (wxTimerEvent &event);
private: private:
MySTC* ed; // timer
wxTimer *m_timer;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
// IDs for the controls and the menu commands //============================================================================
enum // implementation
{ //============================================================================
// menu items
ID_Quit = 1,
ID_About,
ID_ED
};
BEGIN_EVENT_TABLE(MyFrame, wxFrame) IMPLEMENT_APP (App)
EVT_MENU (ID_Quit, MyFrame::OnQuit)
EVT_MENU (ID_About, MyFrame::OnAbout)
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp) //----------------------------------------------------------------------------
// App
//----------------------------------------------------------------------------
//---------------------------------------------------------------------- bool App::OnInit () {
// `Main program' equivalent: the program execution "starts" here
bool MyApp::OnInit() wxInitAllImageHandlers();
{
MyFrame *frame = new MyFrame(_T("Testing wxStyledTextCtrl"), // set application and vendor name
wxPoint(5, 5), wxSize(600, 600)); 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); // initialize print data and setup
return TRUE; 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 // delete global appname
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) delete g_appname;
: 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 print data and setup
if (g_printData) delete g_printData;
if (g_pageSetupData) delete g_pageSetupData;
// create a menu bar return 0;
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);
} }
//----------------------------------------------------------------------------
// 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 ()
AppFrame::AppFrame (const wxString &title)
: wxFrame ((wxFrame *)NULL, -1, title, wxDefaultPosition, wxSize(600,400),
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();
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
// TRUE is to force the frame to close
Close(TRUE);
} }
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) AppFrame::~AppFrame () {
{
wxString msg;
msg.Printf( _T("Testing wxStyledTextCtrl...\n"));
wxMessageBox(msg, _T("About This Test"), wxOK | wxICON_INFORMATION, this);
} }
// common event handlers
//---------------------------------------------------------------------- void AppFrame::OnClose (wxCloseEvent &event) {
wxCommandEvent evt;
wxChar* keywords = OnFileClose (evt);
_T("asm auto bool break case catch char class const \ if (m_edit && m_edit->Modified()) {
const_cast continue default delete do double \ if (event.CanVeto()) event.Veto (true);
dynamic_cast else enum explicit export extern \ return;
false float for friend goto if inline int long \ }
mutable namespace new operator private protected \ Destroy();
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);
} }
void MySTC::OnKeyPressed(wxKeyEvent& evt) void AppFrame::OnAbout (wxCommandEvent &WXUNUSED(event)) {
{ AppAbout (this);
if (CallTipActive()) }
CallTipCancel();
int key = evt.GetKeyCode(); void AppFrame::OnExit (wxCommandEvent &WXUNUSED(event)) {
if ( key == WXK_SPACE && evt.ControlDown()) { Close (true);
int pos = GetCurrentPos(); }
if (evt.ShiftDown()) { // file event handlers
// show how to do CallTips void AppFrame::OnFileOpen (wxCommandEvent &WXUNUSED(event)) {
CallTipSetBackground(wxColour(_T("YELLOW"))); if (!m_edit) return;
CallTipShow(pos, _T("lots of of text: blah, blah, blah\n\nshow some suff, maybe parameters..\n\nfubar(param1, param2)")); wxString fname;
} wxFileDialog dlg (this, _T("Open file"), _T(""), _T(""), _T("Any file (*)|*"),
else { wxOPEN | wxFILE_MUST_EXIST | wxCHANGE_DIR);
// show how to do AutoComplete if (dlg.ShowModal() != wxID_OK) return;
AutoCompSetIgnoreCase(false); fname = dlg.GetPath ();
AutoCompShow(0, keywords); // reuse the keyword list here FileOpen (fname);
// normally you would build a string of completion texts... }
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
evt.Skip();
} }
// 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;
}
}
(*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);
}

View File

@@ -1 +1,5 @@
mondrian ICON "mondrian.ico"
#include "wx/msw/wx.rc" #include "wx/msw/wx.rc"
print BITMAP "bitmaps/print.bmp"

View File

@@ -59,6 +59,10 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
LexRuby.o \ LexRuby.o \
LexSQL.o \ LexSQL.o \
LexVB.o \ LexVB.o \
LexMMIXAL.o \
LexNsis.o \
LexPS.o \
LexScriptol.o \
LineMarker.o \ LineMarker.o \
PropSet.o \ PropSet.o \
RESearch.o \ RESearch.o \

View File

@@ -288,7 +288,7 @@ void SurfaceImpl::Init(SurfaceID hdc_, WindowID) {
hdc = (wxDC*)hdc_; 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(); Release();
hdc = new wxMemoryDC(); hdc = new wxMemoryDC();
hdcOwned = true; hdcOwned = true;
@@ -542,7 +542,7 @@ int SurfaceImpl::Descent(Font &font) {
return d; return d;
} }
int SurfaceImpl::InternalLeading(Font &font) { int SurfaceImpl::InternalLeading(Font &WXUNUSED(font)) {
return 0; return 0;
} }
@@ -563,7 +563,7 @@ int SurfaceImpl::AverageCharWidth(Font &font) {
return hdc->GetCharWidth(); return hdc->GetCharWidth();
} }
int SurfaceImpl::SetPalette(Palette *pal, bool inBackGround) { int SurfaceImpl::SetPalette(Palette *WXUNUSED(pal), bool WXUNUSED(inBackGround)) {
return 0; return 0;
} }
@@ -578,7 +578,7 @@ void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) {
unicodeMode=unicodeMode_; unicodeMode=unicodeMode_;
} }
void SurfaceImpl::SetDBCSMode(int codePage) { void SurfaceImpl::SetDBCSMode(int WXUNUSED(codePage)) {
// dbcsMode = codePage == SC_CP_DBCS; // dbcsMode = codePage == SC_CP_DBCS;
} }
@@ -969,7 +969,7 @@ int ListBoxImpl::GetSelection() {
} }
int ListBoxImpl::Find(const char *prefix) { int ListBoxImpl::Find(const char *WXUNUSED(prefix)) {
// No longer used // No longer used
return -1; return -1;
} }
@@ -1003,7 +1003,7 @@ void ListBoxImpl::RegisterImage(int type, const char *xpm_data) {
// do we need to extend the mapping array? // do we need to extend the mapping array?
wxArrayInt& itm = *imgTypeMap; wxArrayInt& itm = *imgTypeMap;
if ( itm.GetCount() < type+1) if ( itm.GetCount() < (size_t)type+1)
itm.Add(-1, type - itm.GetCount() + 1); itm.Add(-1, type - itm.GetCount() + 1);
// Add an item that maps type to the image index // Add an item that maps type to the image index
@@ -1063,7 +1063,7 @@ void Menu::Show(Point pt, Window &w) {
//---------------------------------------------------------------------- //----------------------------------------------------------------------
DynamicLibrary *DynamicLibrary::Load(const char *modulePath) { DynamicLibrary *DynamicLibrary::Load(const char *WXUNUSED(modulePath)) {
wxFAIL_MSG(wxT("Dynamic lexer loading not implemented yet")); wxFAIL_MSG(wxT("Dynamic lexer loading not implemented yet"));
return NULL; return NULL;
} }
@@ -1103,7 +1103,7 @@ void Platform::DebugDisplay(const char *s) {
wxLogDebug(stc2wx(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. return false; // I don't think we'll need this.
} }
@@ -1196,11 +1196,11 @@ 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; return false;
} }
int Platform::DBCSCharLength(int codePage, const char *s) { int Platform::DBCSCharLength(int WXUNUSED(codePage), const char *WXUNUSED(s)) {
return 1; return 1;
} }

View File

@@ -383,7 +383,8 @@ bool ScintillaWX::CanPaste() {
bool didOpen; bool didOpen;
if (Editor::CanPaste()) { if (Editor::CanPaste()) {
if ( (didOpen = !wxTheClipboard->IsOpened()) ) didOpen = !wxTheClipboard->IsOpened();
if ( didOpen )
wxTheClipboard->Open(); wxTheClipboard->Open();
if (wxTheClipboard->IsOpened()) { if (wxTheClipboard->IsOpened()) {
@@ -597,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); // PRectangle rcClient(0,0,width,height);
// SetScrollBarsTo(rcClient); // SetScrollBarsTo(rcClient);
// DropGraphics(); // DropGraphics();
@@ -628,8 +629,8 @@ void ScintillaWX::DoLeftButtonMove(Point pt) {
ButtonMove(pt); ButtonMove(pt);
} }
void ScintillaWX::DoMiddleButtonUp(Point pt) {
#ifdef __WXGTK__ #ifdef __WXGTK__
void ScintillaWX::DoMiddleButtonUp(Point pt) {
// Set the current position to the mouse click point and // Set the current position to the mouse click point and
// then paste in the PRIMARY selection, if any. wxGTK only. // then paste in the PRIMARY selection, if any. wxGTK only.
int newPos = PositionFromLocation(pt); int newPos = PositionFromLocation(pt);
@@ -656,8 +657,11 @@ void ScintillaWX::DoMiddleButtonUp(Point pt) {
ShowCaretAtCurrentPosition(); ShowCaretAtCurrentPosition();
EnsureCaretVisible(); EnsureCaretVisible();
#endif
} }
#else
void ScintillaWX::DoMiddleButtonUp(Point WXUNUSED(pt)) {
}
#endif
void ScintillaWX::DoAddChar(int key) { void ScintillaWX::DoAddChar(int key) {
@@ -673,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__) #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) if (ctrl && key >= 1 && key <= 26)
key += 'A' - 1; key += 'A' - 1;
#endif #endif
@@ -709,6 +718,21 @@ int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* cons
case WXK_MENU: key = 0; break; 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); int rv = KeyDown(key, shift, ctrl, alt, consumed);
if (key) if (key)
@@ -760,7 +784,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; dragResult = def;
return dragResult; return dragResult;
} }
@@ -817,8 +841,8 @@ void ScintillaWX::DoScrollToColumn(int column) {
HorizontalScrollTo(column * vs.spaceWidth); HorizontalScrollTo(column * vs.spaceWidth);
} }
void ScintillaWX::ClipChildren(wxDC& dc, PRectangle rect) {
#ifdef __WXGTK__ #ifdef __WXGTK__
void ScintillaWX::ClipChildren(wxDC& dc, PRectangle rect) {
wxRegion rgn(wxRectFromPRectangle(rect)); wxRegion rgn(wxRectFromPRectangle(rect));
if (ac.Active()) { if (ac.Active()) {
wxRect childRect = ((wxWindow*)ac.lb->GetID())->GetRect(); wxRect childRect = ((wxWindow*)ac.lb->GetID())->GetRect();
@@ -830,9 +854,11 @@ void ScintillaWX::ClipChildren(wxDC& dc, PRectangle rect) {
} }
dc.SetClippingRegion(rgn); dc.SetClippingRegion(rgn);
#endif
} }
#else
void ScintillaWX::ClipChildren(wxDC& WXUNUSED(dc), PRectangle WXUNUSED(rect)) {
}
#endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@@ -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; class ScintillaWX;
@@ -131,7 +139,7 @@ public:
void DoMiddleButtonUp(Point pt); void DoMiddleButtonUp(Point pt);
void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll); void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll);
void DoAddChar(int key); 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(); } void DoTick() { Tick(); }
#if wxUSE_DRAG_AND_DROP #if wxUSE_DRAG_AND_DROP

View File

@@ -370,6 +370,22 @@ SOURCE=.\scintilla\src\LexVB.cxx
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\scintilla\src\LexMMIXAL.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexNsis.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexPS.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexScriptol.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LineMarker.cxx SOURCE=.\scintilla\src\LineMarker.cxx
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@@ -547,9 +547,12 @@ methodOverrideMap = {
'GrabFocus' : (None, 0, 0, 0), 'GrabFocus' : (None, 0, 0, 0),
# Rename some that woudl otherwise hid the wxWindow methods
'SetFocus' : ('SetSTCFocus', 0, 0, 0), 'SetFocus' : ('SetSTCFocus', 0, 0, 0),
'GetFocus' : ('GetSTCFocus', 0, 0, 0), 'GetFocus' : ('GetSTCFocus', 0, 0, 0),
'SetCursor' : ('SetSTCCursor', 0, 0, 0),
'GetCursor' : ('GetSTCCursor', 0, 0, 0),
'LoadLexerLibrary' : (None, 0,0,0), 'LoadLexerLibrary' : (None, 0,0,0),

View File

@@ -58,6 +58,10 @@ OBJECTS = \
LexRuby.obj \ LexRuby.obj \
LexSQL.obj \ LexSQL.obj \
LexVB.obj \ LexVB.obj \
LexMMIXAL.obj \
LexNsis.obj \
LexPS.obj \
LexScriptol.obj \
LineMarker.obj \ LineMarker.obj \
PropSet.obj \ PropSet.obj \
RESearch.obj \ RESearch.obj \
@@ -68,7 +72,6 @@ OBJECTS = \
ViewStyle.obj \ ViewStyle.obj \
WindowAccessor.obj \ WindowAccessor.obj \
XPM.obj \ XPM.obj \
\
PlatWX.obj \ PlatWX.obj \
ScintillaWX.obj \ ScintillaWX.obj \
stc.obj \ stc.obj \

View File

@@ -46,6 +46,10 @@ OBJECTS = \
$(S)/LexRuby.$(OBJSUFF) \ $(S)/LexRuby.$(OBJSUFF) \
$(S)/LexSQL.$(OBJSUFF) \ $(S)/LexSQL.$(OBJSUFF) \
$(S)/LexVB.$(OBJSUFF) \ $(S)/LexVB.$(OBJSUFF) \
$(S)/LexMMIXAL.$(OBJSUFF) \
$(S)/LexNsis.$(OBJSUFF) \
$(S)/LexPS.$(OBJSUFF) \
$(S)/LexScriptol.$(OBJSUFF) \
$(S)/LineMarker.$(OBJSUFF) \ $(S)/LineMarker.$(OBJSUFF) \
$(S)/PropSet.$(OBJSUFF) \ $(S)/PropSet.$(OBJSUFF) \
$(S)/RESearch.$(OBJSUFF) \ $(S)/RESearch.$(OBJSUFF) \

View File

@@ -5,7 +5,7 @@ S=$(SCINTILLA)\src
EXTRASTCCPPFLAGS = -D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(SCINTILLA)/include -I$(S) EXTRASTCCPPFLAGS = -D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(SCINTILLA)/include -I$(S)
EXTRACPPFLAGS=$(EXTRACPPFLAGS) $(EXTRASTCCPPFLAGS) EXTRACPPFLAGS=$(EXTRACPPFLAGS) $(EXTRASTCCPPFLAGS)
STCCPPFLAGS=$(DLL_FLAGS) $(EXTRACPPFLAGS) STCCPPFLAGS=$(DLL_FLAGS) $(EXTRACPPFLAGS)
include $(WXDIR)\src\makesc.env include $(WXDIR)\src\makesc.env
LIBTARGET=$(WXDIR)\lib\stc$(SC_SUFFIX).lib LIBTARGET=$(WXDIR)\lib\stc$(SC_SUFFIX).lib
@@ -52,6 +52,10 @@ OBJECTS = \
$(S)\LexRuby.obj \ $(S)\LexRuby.obj \
$(S)\LexSQL.obj \ $(S)\LexSQL.obj \
$(S)\LexVB.obj \ $(S)\LexVB.obj \
$(S)\LexMMIXAL.obj \
$(S)\LexNsis.obj \
$(S)\LexPS.obj \
$(S)\LexScriptol.obj \
$(S)\LineMarker.obj \ $(S)\LineMarker.obj \
$(S)\PropSet.obj \ $(S)\PropSet.obj \
$(S)\RESearch.obj \ $(S)\RESearch.obj \

View File

@@ -51,6 +51,10 @@ OBJECTS = \
$(D)\LexRuby.obj \ $(D)\LexRuby.obj \
$(D)\LexSQL.obj \ $(D)\LexSQL.obj \
$(D)\LexVB.obj \ $(D)\LexVB.obj \
$(D)\LexMMIXAL.obj \
$(D)\LexNsis.obj \
$(D)\LexPS.obj \
$(D)\LexScriptol.obj \
$(D)\LineMarker.obj \ $(D)\LineMarker.obj \
$(D)\PropSet.obj \ $(D)\PropSet.obj \
$(D)\RESearch.obj \ $(D)\RESearch.obj \

View File

@@ -55,6 +55,10 @@ OBJECTS = &
LexRuby.obj & LexRuby.obj &
LexSQL.obj & LexSQL.obj &
LexVB.obj & LexVB.obj &
LexMMIXAL.obj &
LexNsis.obj &
LexPS.obj &
LexScriptol.obj &
LineMarker.obj & LineMarker.obj &
PropSet.obj & PropSet.obj &
RESearch.obj & RESearch.obj &

View File

@@ -3,4 +3,4 @@ scintilla/include directories from the Scintilla/SCiTE source
distribution. All other code needed to implement Scintilla on top of distribution. All other code needed to implement Scintilla on top of
wxWindows is located in the directory above this one. wxWindows is located in the directory above this one.
The current version of the Scintilla code is 1.53 The current version of the Scintilla code is 1.54

View File

@@ -25,7 +25,7 @@ protected:
char buf[bufferSize+1]; char buf[bufferSize+1];
int startPos; int startPos;
int endPos; int endPos;
int codePage; int codePage;
virtual bool InternalIsLeadByte(char ch)=0; virtual bool InternalIsLeadByte(char ch)=0;
virtual void Fill(int position)=0; virtual void Fill(int position)=0;
@@ -44,7 +44,7 @@ public:
if (position < startPos || position >= endPos) { if (position < startPos || position >= endPos) {
Fill(position); Fill(position);
if (position < startPos || position >= endPos) { if (position < startPos || position >= endPos) {
// Position is outside range of document // Position is outside range of document
return chDefault; return chDefault;
} }
} }

View File

@@ -7,7 +7,7 @@
typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle, typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler); WordList *keywordlists[], Accessor &styler);
/** /**
* A LexerModule is responsible for lexing and folding a particular language. * 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 * The class maintains a list of LexerModules which can be searched to find a
@@ -26,7 +26,7 @@ protected:
public: public:
const char *languageName; const char *languageName;
LexerModule(int language_, LexerFunction fnLexer_, LexerModule(int language_, LexerFunction fnLexer_,
const char *languageName_=0, LexerFunction fnFolder_=0, const char *languageName_=0, LexerFunction fnFolder_=0,
const char * const wordListDescriptions_[] = NULL); const char * const wordListDescriptions_[] = NULL);
int GetLanguage() const { return language; } int GetLanguage() const { return language; }

View File

@@ -24,11 +24,21 @@ struct Property {
/** /**
*/ */
class PropSet { class PropSet {
private: protected:
enum { hashRoots=31 }; enum { hashRoots=31 };
Property *props[hashRoots]; Property *props[hashRoots];
Property *enumnext; Property *enumnext;
int enumhash; 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: public:
PropSet *superPS; PropSet *superPS;
PropSet(); PropSet();

View File

@@ -56,6 +56,9 @@
#define SCLEX_POV 39 #define SCLEX_POV 39
#define SCLEX_LOUT 40 #define SCLEX_LOUT 40
#define SCLEX_ESCRIPT 41 #define SCLEX_ESCRIPT 41
#define SCLEX_PS 42
#define SCLEX_NSIS 43
#define SCLEX_MMIXAL 44
#define SCLEX_AUTOMATIC 1000 #define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0 #define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1 #define SCE_P_COMMENTLINE 1
@@ -268,6 +271,8 @@
#define SCE_LUA_WORD4 15 #define SCE_LUA_WORD4 15
#define SCE_LUA_WORD5 16 #define SCE_LUA_WORD5 16
#define SCE_LUA_WORD6 17 #define SCE_LUA_WORD6 17
#define SCE_LUA_WORD7 18
#define SCE_LUA_WORD8 19
#define SCE_ERR_DEFAULT 0 #define SCE_ERR_DEFAULT 0
#define SCE_ERR_PYTHON 1 #define SCE_ERR_PYTHON 1
#define SCE_ERR_GCC 2 #define SCE_ERR_GCC 2
@@ -455,14 +460,20 @@
#define SCE_POV_DEFAULT 0 #define SCE_POV_DEFAULT 0
#define SCE_POV_COMMENT 1 #define SCE_POV_COMMENT 1
#define SCE_POV_COMMENTLINE 2 #define SCE_POV_COMMENTLINE 2
#define SCE_POV_COMMENTDOC 3 #define SCE_POV_NUMBER 3
#define SCE_POV_NUMBER 4 #define SCE_POV_OPERATOR 4
#define SCE_POV_WORD 5 #define SCE_POV_IDENTIFIER 5
#define SCE_POV_STRING 6 #define SCE_POV_STRING 6
#define SCE_POV_OPERATOR 7 #define SCE_POV_STRINGEOL 7
#define SCE_POV_IDENTIFIER 8 #define SCE_POV_DIRECTIVE 8
#define SCE_POV_BRACE 9 #define SCE_POV_BADDIRECTIVE 9
#define SCE_POV_WORD2 10 #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_DEFAULT 0
#define SCE_LOUT_COMMENT 1 #define SCE_LOUT_COMMENT 1
#define SCE_LOUT_NUMBER 2 #define SCE_LOUT_NUMBER 2
@@ -486,6 +497,54 @@
#define SCE_ESCRIPT_BRACE 9 #define SCE_ESCRIPT_BRACE 9
#define SCE_ESCRIPT_WORD2 10 #define SCE_ESCRIPT_WORD2 10
#define SCE_ESCRIPT_WORD3 11 #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 //--Autogenerated -- end of section automatically generated from Scintilla.iface
#endif #endif

View File

@@ -204,6 +204,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define INDIC_TT 2 #define INDIC_TT 2
#define INDIC_DIAGONAL 3 #define INDIC_DIAGONAL 3
#define INDIC_STRIKE 4 #define INDIC_STRIKE 4
#define INDIC_HIDDEN 5
#define INDIC0_MASK 0x20 #define INDIC0_MASK 0x20
#define INDIC1_MASK 0x40 #define INDIC1_MASK 0x40
#define INDIC2_MASK 0x80 #define INDIC2_MASK 0x80
@@ -546,6 +547,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_GETLEXER 4002 #define SCI_GETLEXER 4002
#define SCI_COLOURISE 4003 #define SCI_COLOURISE 4003
#define SCI_SETPROPERTY 4004 #define SCI_SETPROPERTY 4004
#define KEYWORDSET_MAX 8
#define SCI_SETKEYWORDS 4005 #define SCI_SETKEYWORDS 4005
#define SCI_SETLEXERLANGUAGE 4006 #define SCI_SETLEXERLANGUAGE 4006
#define SCI_LOADLEXERLIBRARY 4007 #define SCI_LOADLEXERLIBRARY 4007

View File

@@ -462,6 +462,7 @@ val INDIC_SQUIGGLE=1
val INDIC_TT=2 val INDIC_TT=2
val INDIC_DIAGONAL=3 val INDIC_DIAGONAL=3
val INDIC_STRIKE=4 val INDIC_STRIKE=4
val INDIC_HIDDEN=5
val INDIC0_MASK=0x20 val INDIC0_MASK=0x20
val INDIC1_MASK=0x40 val INDIC1_MASK=0x40
val INDIC2_MASK=0x80 val INDIC2_MASK=0x80
@@ -1476,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 up a value that may be used by a lexer for some optional feature.
set void SetProperty=4004(string key, string value) 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 up the key words used by the lexer.
set void SetKeyWords=4005(int keywordSet, string keyWords) set void SetKeyWords=4005(int keywordSet, string keyWords)
@@ -1584,6 +1588,9 @@ val SCLEX_CSS=38
val SCLEX_POV=39 val SCLEX_POV=39
val SCLEX_LOUT=40 val SCLEX_LOUT=40
val SCLEX_ESCRIPT=41 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 # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1. # value assigned in sequence from SCLEX_AUTOMATIC+1.
@@ -1835,6 +1842,8 @@ val SCE_LUA_WORD3=14
val SCE_LUA_WORD4=15 val SCE_LUA_WORD4=15
val SCE_LUA_WORD5=16 val SCE_LUA_WORD5=16
val SCE_LUA_WORD6=17 val SCE_LUA_WORD6=17
val SCE_LUA_WORD7=18
val SCE_LUA_WORD8=19
# Lexical states for SCLEX_ERRORLIST # Lexical states for SCLEX_ERRORLIST
lex ErrorList=SCLEX_ERRORLIST SCE_ERR_ lex ErrorList=SCLEX_ERRORLIST SCE_ERR_
val SCE_ERR_DEFAULT=0 val SCE_ERR_DEFAULT=0
@@ -2058,14 +2067,20 @@ lex POV=SCLEX_POV SCE_POV_
val SCE_POV_DEFAULT=0 val SCE_POV_DEFAULT=0
val SCE_POV_COMMENT=1 val SCE_POV_COMMENT=1
val SCE_POV_COMMENTLINE=2 val SCE_POV_COMMENTLINE=2
val SCE_POV_COMMENTDOC=3 val SCE_POV_NUMBER=3
val SCE_POV_NUMBER=4 val SCE_POV_OPERATOR=4
val SCE_POV_WORD=5 val SCE_POV_IDENTIFIER=5
val SCE_POV_STRING=6 val SCE_POV_STRING=6
val SCE_POV_OPERATOR=7 val SCE_POV_STRINGEOL=7
val SCE_POV_IDENTIFIER=8 val SCE_POV_DIRECTIVE=8
val SCE_POV_BRACE=9 val SCE_POV_BADDIRECTIVE=9
val SCE_POV_WORD2=10 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 # Lexical states for SCLEX_LOUT
lex LOUT=SCLEX_LOUT SCE_LOUT_ lex LOUT=SCLEX_LOUT SCE_LOUT_
val SCE_LOUT_DEFAULT=0 val SCE_LOUT_DEFAULT=0
@@ -2093,6 +2108,60 @@ val SCE_ESCRIPT_IDENTIFIER=8
val SCE_ESCRIPT_BRACE=9 val SCE_ESCRIPT_BRACE=9
val SCE_ESCRIPT_WORD2=10 val SCE_ESCRIPT_WORD2=10
val SCE_ESCRIPT_WORD3=11 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 # Events

View File

@@ -26,8 +26,8 @@ protected:
bool InternalIsLeadByte(char ch); bool InternalIsLeadByte(char ch);
void Fill(int position); void Fill(int position);
public: public:
WindowAccessor(WindowID id_, PropSet &props_) : WindowAccessor(WindowID id_, PropSet &props_) :
Accessor(), id(id_), props(props_), Accessor(), id(id_), props(props_),
lenDoc(-1), validLen(0), chFlags(0), chWhile(0) { lenDoc(-1), validLen(0), chFlags(0), chWhile(0) {
} }
~WindowAccessor(); ~WindowAccessor();
@@ -40,8 +40,8 @@ public:
void Flush(); void Flush();
int GetLineState(int line); int GetLineState(int line);
int SetLineState(int line, int state); int SetLineState(int line, int state);
int GetPropertyInt(const char *key, int defaultValue=0) { int GetPropertyInt(const char *key, int defaultValue=0) {
return props.GetInt(key, defaultValue); return props.GetInt(key, defaultValue);
} }
char *GetProperties() { char *GetProperties() {
return props.ToString(); return props.ToString();

View File

@@ -103,9 +103,9 @@ void MarkerHandleSet::RemoveNumber(int markerNum) {
if (mhn->number == markerNum) { if (mhn->number == markerNum) {
*pmhn = mhn->next; *pmhn = mhn->next;
delete mhn; delete mhn;
return ; } else {
pmhn = &((*pmhn)->next);
} }
pmhn = &((*pmhn)->next);
} }
} }

View File

@@ -212,7 +212,7 @@ public:
int GetMark(int line); int GetMark(int line);
void DeleteAllMarks(int markerNum); void DeleteAllMarks(int markerNum);
int LineFromHandle(int markerHandle); int LineFromHandle(int markerHandle);
/// Actions without undo /// Actions without undo
void BasicInsertString(int position, char *s, int insertLength); void BasicInsertString(int position, char *s, int insertLength);
void BasicDeleteChars(int position, int deleteLength); void BasicDeleteChars(int position, int deleteLength);

View File

@@ -394,7 +394,7 @@ bool Document::InsertStyledString(int position, char *s, int insertLength) {
DocModification( DocModification(
SC_MOD_BEFOREINSERT | SC_PERFORMED_USER, SC_MOD_BEFOREINSERT | SC_PERFORMED_USER,
position / 2, insertLength / 2, position / 2, insertLength / 2,
0, 0)); 0, s));
int prevLinesTotal = LinesTotal(); int prevLinesTotal = LinesTotal();
bool startSavePoint = cb.IsSavePoint(); bool startSavePoint = cb.IsSavePoint();
const char *text = cb.InsertString(position, s, insertLength); const char *text = cb.InsertString(position, s, insertLength);
@@ -926,7 +926,7 @@ long Document::FindText(int minPos, int maxPos, const char *s,
if (line == lineRangeStart) { if (line == lineRangeStart) {
if ((startPos != endOfLine) && (searchEnd == '$')) if ((startPos != endOfLine) && (searchEnd == '$'))
continue; // Can't match end of line if start position before end of line continue; // Can't match end of line if start position before end of line
endOfLine = startPos; endOfLine = startPos+1;
} }
} }
@@ -938,10 +938,10 @@ long Document::FindText(int minPos, int maxPos, const char *s,
if (increment == -1) { if (increment == -1) {
// Check for the last match on this line. // Check for the last match on this line.
int repetitions = 1000; // Break out of infinite loop int repetitions = 1000; // Break out of infinite loop
while (success && (pre->eopat[0] < endOfLine) && (repetitions--)) { while (success && (pre->eopat[0] <= (endOfLine+1)) && (repetitions--)) {
success = pre->Execute(di, pre->eopat[0], endOfLine); success = pre->Execute(di, pos+1, endOfLine+1);
if (success) { if (success) {
if (pre->eopat[0] <= minPos) { if (pre->eopat[0] <= (minPos+1)) {
pos = pre->bopat[0]; pos = pre->bopat[0];
lenRet = pre->eopat[0] - pre->bopat[0]; lenRet = pre->eopat[0] - pre->bopat[0];
} else { } else {

View File

@@ -130,8 +130,8 @@ void DocumentAccessor::Flush() {
lenDoc = -1; lenDoc = -1;
if (validLen > 0) { if (validLen > 0) {
pdoc->SetStyles(validLen, styleBuf); pdoc->SetStyles(validLen, styleBuf);
validLen = 0;
startPosStyling += validLen; startPosStyling += validLen;
validLen = 0;
} }
} }

View File

@@ -32,9 +32,9 @@ protected:
void Fill(int position); void Fill(int position);
public: public:
DocumentAccessor(Document *pdoc_, PropSet &props_, WindowID id_=0) : DocumentAccessor(Document *pdoc_, PropSet &props_, WindowID id_=0) :
Accessor(), pdoc(pdoc_), props(props_), id(id_), 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) { startSeg(0), startPosStyling(0) {
} }
~DocumentAccessor(); ~DocumentAccessor();
@@ -47,8 +47,8 @@ public:
void Flush(); void Flush();
int GetLineState(int line); int GetLineState(int line);
int SetLineState(int line, int state); int SetLineState(int line, int state);
int GetPropertyInt(const char *key, int defaultValue=0) { int GetPropertyInt(const char *key, int defaultValue=0) {
return props.GetInt(key, defaultValue); return props.GetInt(key, defaultValue);
} }
char *GetProperties() { char *GetProperties() {
return props.ToString(); return props.ToString();

View File

@@ -1414,7 +1414,7 @@ void Editor::LinesSplit(int pixelWidth) {
for (int subLine = 1; subLine < ll->lines; subLine++) { for (int subLine = 1; subLine < ll->lines; subLine++) {
pdoc->InsertString(posLineStart + (subLine - 1) * strlen(eol) + pdoc->InsertString(posLineStart + (subLine - 1) * strlen(eol) +
ll->LineStart(subLine), eol); ll->LineStart(subLine), eol);
targetEnd += strlen(eol); targetEnd += static_cast<int>(strlen(eol));
} }
} }
} }
@@ -1428,6 +1428,12 @@ int Editor::SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) {
return markerCheck; 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) { void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
if (vs.fixedColumnWidth == 0) if (vs.fixedColumnWidth == 0)
return; return;
@@ -1589,11 +1595,11 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
} }
PRectangle rcNumber = rcMarker; PRectangle rcNumber = rcMarker;
// Right justify // 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; int xpos = rcNumber.right - width - 3;
rcNumber.left = xpos; rcNumber.left = xpos;
surface->DrawTextNoClip(rcNumber, vs.styles[STYLE_LINENUMBER].font, 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].fore.allocated,
vs.styles[STYLE_LINENUMBER].back.allocated); vs.styles[STYLE_LINENUMBER].back.allocated);
} }
@@ -1770,7 +1776,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
} else if (controlCharSymbol < 32) { } else if (controlCharSymbol < 32) {
const char *ctrlChar = ControlCharacterString(ll->chars[charInLine]); const char *ctrlChar = ControlCharacterString(ll->chars[charInLine]);
// +3 For a blank on front and rounded edge each side: // +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 { } else {
char cc[2] = { static_cast<char>(controlCharSymbol), '\0' }; char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
surface->MeasureWidths(ctrlCharsFont, cc, 1, surface->MeasureWidths(ctrlCharsFont, cc, 1,
@@ -2135,7 +2141,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
rcChar.left++; rcChar.left++;
rcChar.right--; rcChar.right--;
surface->DrawTextClipped(rcChar, ctrlCharsFont, surface->DrawTextClipped(rcChar, ctrlCharsFont,
rcSegment.top + vsDraw.maxAscent, ctrlChar, strlen(ctrlChar), rcSegment.top + vsDraw.maxAscent, ctrlChar, istrlen(ctrlChar),
textBack, textFore); textBack, textFore);
} else { } else {
char cc[2] = { static_cast<char>(controlCharSymbol), '\0' }; char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
@@ -2360,7 +2366,9 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
if (AbandonPaint()) { if (AbandonPaint()) {
return; return;
} }
RefreshPixMaps(surfaceWindow); // In case pixmaps invalidated by scrollbar change
} }
PLATFORM_ASSERT(pixmapSelPattern->Initialised());
PRectangle rcRightMargin = rcClient; PRectangle rcRightMargin = rcClient;
rcRightMargin.left = rcRightMargin.right - vs.rightMarginWidth; rcRightMargin.left = rcRightMargin.right - vs.rightMarginWidth;
@@ -2389,6 +2397,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
Surface *surface = surfaceWindow; Surface *surface = surfaceWindow;
if (bufferedDraw) { if (bufferedDraw) {
surface = pixmapLine; surface = pixmapLine;
PLATFORM_ASSERT(pixmapLine->Initialised());
} }
surface->SetUnicodeMode(IsUnicodeMode()); surface->SetUnicodeMode(IsUnicodeMode());
surface->SetDBCSMode(CodePage()); surface->SetDBCSMode(CodePage());
@@ -2680,7 +2689,7 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) {
int lineNumberWidth = 0; int lineNumberWidth = 0;
if (lineNumberIndex >= 0) { if (lineNumberIndex >= 0) {
lineNumberWidth = surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, lineNumberWidth = surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font,
"99999" lineNumberPrintSpace, 5 + strlen(lineNumberPrintSpace)); "99999" lineNumberPrintSpace, 5 + istrlen(lineNumberPrintSpace));
vsPrint.ms[lineNumberIndex].width = lineNumberWidth; vsPrint.ms[lineNumberIndex].width = lineNumberWidth;
} }
@@ -2760,10 +2769,10 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) {
rcNumber.right = rcNumber.left + lineNumberWidth; rcNumber.right = rcNumber.left + lineNumberWidth;
// Right justify // Right justify
rcNumber.left -= surfaceMeasure->WidthText( rcNumber.left -= surfaceMeasure->WidthText(
vsPrint.styles[STYLE_LINENUMBER].font, number, strlen(number)); vsPrint.styles[STYLE_LINENUMBER].font, number, istrlen(number));
surface->FlushCachedState(); surface->FlushCachedState();
surface->DrawTextNoClip(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font, 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].fore.allocated,
vsPrint.styles[STYLE_LINENUMBER].back.allocated); vsPrint.styles[STYLE_LINENUMBER].back.allocated);
} }
@@ -2799,7 +2808,7 @@ int Editor::TextWidth(int style, const char *text) {
RefreshStyleData(); RefreshStyleData();
AutoSurface surface(this); AutoSurface surface(this);
if (surface) { if (surface) {
return surface->WidthText(vs.styles[style].font, text, strlen(text)); return surface->WidthText(vs.styles[style].font, text, istrlen(text));
} else { } else {
return 1; return 1;
} }
@@ -3553,7 +3562,7 @@ void Editor::LineDuplicate() {
char *thisLine = CopyRange(start, end); char *thisLine = CopyRange(start, end);
const char *eol = StringFromEOLMode(pdoc->eolMode); const char *eol = StringFromEOLMode(pdoc->eolMode);
pdoc->InsertString(end, eol); pdoc->InsertString(end, eol);
pdoc->InsertString(end + strlen(eol), thisLine, end - start); pdoc->InsertString(end + istrlen(eol), thisLine, end - start);
delete []thisLine; delete []thisLine;
} }
@@ -3568,7 +3577,7 @@ void Editor::NewLine() {
eol = "\r"; eol = "\r";
} // else SC_EOL_LF -> "\n" already set } // else SC_EOL_LF -> "\n" already set
if (pdoc->InsertString(currentPos, eol)) { if (pdoc->InsertString(currentPos, eol)) {
SetEmptySelection(currentPos + strlen(eol)); SetEmptySelection(currentPos + istrlen(eol));
while (*eol) { while (*eol) {
NotifyChar(*eol); NotifyChar(*eol);
eol++; eol++;
@@ -4069,7 +4078,7 @@ long Editor::FindText(
sptr_t lParam) { ///< @c TextToFind structure: The text to search for in the given range. sptr_t lParam) { ///< @c TextToFind structure: The text to search for in the given range.
TextToFind *ft = reinterpret_cast<TextToFind *>(lParam); 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, int pos = pdoc->FindText(ft->chrg.cpMin, ft->chrg.cpMax, ft->lpstrText,
(wParam & SCFIND_MATCHCASE) != 0, (wParam & SCFIND_MATCHCASE) != 0,
(wParam & SCFIND_WHOLEWORD) != 0, (wParam & SCFIND_WHOLEWORD) != 0,
@@ -4112,7 +4121,7 @@ long Editor::SearchText(
const char *txt = reinterpret_cast<char *>(lParam); const char *txt = reinterpret_cast<char *>(lParam);
int pos; int pos;
int lengthFound = strlen(txt); int lengthFound = istrlen(txt);
if (iMessage == SCI_SEARCHNEXT) { if (iMessage == SCI_SEARCHNEXT) {
pos = pdoc->FindText(searchAnchor, pdoc->Length(), txt, pos = pdoc->FindText(searchAnchor, pdoc->Length(), txt,
(wParam & SCFIND_MATCHCASE) != 0, (wParam & SCFIND_MATCHCASE) != 0,
@@ -4315,14 +4324,14 @@ void Editor::DropAt(int position, const char *value, bool moving, bool rectangul
position = positionAfterDeletion; position = positionAfterDeletion;
if (rectangular) { if (rectangular) {
PasteRectangular(position, value, strlen(value)); PasteRectangular(position, value, istrlen(value));
pdoc->EndUndoAction(); pdoc->EndUndoAction();
// Should try to select new rectangle but it may not be a rectangle now so just select the drop position // Should try to select new rectangle but it may not be a rectangle now so just select the drop position
SetSelection(position, position); SetSelection(position, position);
} else { } else {
position = MovePositionOutsideChar(position, currentPos - position); position = MovePositionOutsideChar(position, currentPos - position);
if (pdoc->InsertString(position, value)) { if (pdoc->InsertString(position, value)) {
SetSelection(position + strlen(value), position); SetSelection(position + istrlen(value), position);
} }
pdoc->EndUndoAction(); pdoc->EndUndoAction();
} }
@@ -4990,7 +4999,7 @@ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) {
int Editor::ReplaceTarget(bool replacePatterns, const char *text, int length) { int Editor::ReplaceTarget(bool replacePatterns, const char *text, int length) {
pdoc->BeginUndoAction(); pdoc->BeginUndoAction();
if (length == -1) if (length == -1)
length = strlen(text); length = istrlen(text);
if (replacePatterns) { if (replacePatterns) {
text = pdoc->SubstituteByPosition(text, &length); text = pdoc->SubstituteByPosition(text, &length);
if (!text) if (!text)
@@ -5186,7 +5195,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
char *replacement = CharPtrFromSPtr(lParam); char *replacement = CharPtrFromSPtr(lParam);
pdoc->InsertString(currentPos, replacement); pdoc->InsertString(currentPos, replacement);
pdoc->EndUndoAction(); pdoc->EndUndoAction();
SetEmptySelection(currentPos + strlen(replacement)); SetEmptySelection(currentPos + istrlen(replacement));
EnsureCaretVisible(); EnsureCaretVisible();
} }
break; break;
@@ -5357,7 +5366,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
char *sz = CharPtrFromSPtr(lParam); char *sz = CharPtrFromSPtr(lParam);
pdoc->InsertString(insertPos, sz); pdoc->InsertString(insertPos, sz);
if (newCurrent > insertPos) if (newCurrent > insertPos)
newCurrent += strlen(sz); newCurrent += istrlen(sz);
SetEmptySelection(newCurrent); SetEmptySelection(newCurrent);
return 0; return 0;
} }

View File

@@ -10,16 +10,8 @@
#if PLAT_WIN #if PLAT_WIN
#define EXT_LEXER_DECL __stdcall #define EXT_LEXER_DECL __stdcall
#elif PLAT_GTK
#define EXT_LEXER_DECL
#endif
#if PLAT_WX
#ifdef __WXMSW__
#define EXT_LEXER_DECL __stdcall
#else #else
#define EXT_LEXER_DECL #define EXT_LEXER_DECL
#endif
#endif #endif
// External Lexer function definitions... // External Lexer function definitions...
@@ -41,7 +33,7 @@ protected:
int externalLanguage; int externalLanguage;
char name[100]; char name[100];
public: public:
ExternalLexerModule(int language_, LexerFunction fnLexer_, ExternalLexerModule(int language_, LexerFunction fnLexer_,
const char *languageName_=0, LexerFunction fnFolder_=0) : LexerModule(language_, fnLexer_, 0, fnFolder_){ const char *languageName_=0, LexerFunction fnFolder_=0) : LexerModule(language_, fnLexer_, 0, fnFolder_){
strncpy(name, languageName_, sizeof(name)); strncpy(name, languageName_, sizeof(name));
languageName = name; languageName = name;
@@ -70,7 +62,7 @@ public:
LexerLibrary(const char* ModuleName); LexerLibrary(const char* ModuleName);
~LexerLibrary(); ~LexerLibrary();
void Release(); void Release();
LexerLibrary *next; LexerLibrary *next;
SString m_sModuleName; SString m_sModuleName;
}; };
@@ -79,10 +71,10 @@ public:
class LexerManager { class LexerManager {
public: public:
~LexerManager(); ~LexerManager();
static LexerManager *GetInstance(); static LexerManager *GetInstance();
static void DeleteInstance(); static void DeleteInstance();
void Load(const char* path); void Load(const char* path);
void Clear(); void Clear();

View File

@@ -55,6 +55,8 @@ void Indicator::Draw(Surface *surface, PRectangle &rc) {
} else if (style == INDIC_STRIKE) { } else if (style == INDIC_STRIKE) {
surface->MoveTo(rc.left, rc.top - 4); surface->MoveTo(rc.left, rc.top - 4);
surface->LineTo(rc.right, rc.top - 4); surface->LineTo(rc.right, rc.top - 4);
} else if (style == INDIC_HIDDEN) {
// Draw nothing
} else { // Either INDIC_PLAIN or unknown } else { // Either INDIC_PLAIN or unknown
surface->MoveTo(rc.left, ymid); surface->MoveTo(rc.left, ymid);
surface->LineTo(rc.right, ymid); surface->LineTo(rc.right, ymid);

View File

@@ -153,6 +153,8 @@ int Scintilla_LinkLexers() {
LINK_LEXER(lmLout); LINK_LEXER(lmLout);
LINK_LEXER(lmLua); LINK_LEXER(lmLua);
LINK_LEXER(lmMatlab); LINK_LEXER(lmMatlab);
LINK_LEXER(lmMMIXAL);
LINK_LEXER(lmNsis);
LINK_LEXER(lmBatch); LINK_LEXER(lmBatch);
LINK_LEXER(lmDiff); LINK_LEXER(lmDiff);
LINK_LEXER(lmProps); LINK_LEXER(lmProps);
@@ -163,8 +165,10 @@ int Scintilla_LinkLexers() {
LINK_LEXER(lmPascal); LINK_LEXER(lmPascal);
LINK_LEXER(lmPerl); LINK_LEXER(lmPerl);
LINK_LEXER(lmPOV); LINK_LEXER(lmPOV);
LINK_LEXER(lmPS);
LINK_LEXER(lmPython); LINK_LEXER(lmPython);
LINK_LEXER(lmRuby); LINK_LEXER(lmRuby);
LINK_LEXER(lmScriptol);
LINK_LEXER(lmSQL); LINK_LEXER(lmSQL);
LINK_LEXER(lmVB); LINK_LEXER(lmVB);
LINK_LEXER(lmVBScript); LINK_LEXER(lmVBScript);

View File

@@ -321,7 +321,7 @@ static bool IsValidIdentifier(const SString& identifier) {
// First character can't be '_', so initialize the flag to true // First character can't be '_', so initialize the flag to true
bool lastWasUnderscore = true; bool lastWasUnderscore = true;
int length = identifier.length(); size_t length = identifier.length();
// Zero-length identifiers are not valid (these can occur inside labels) // Zero-length identifiers are not valid (these can occur inside labels)
if (length == 0) { if (length == 0) {
@@ -334,7 +334,7 @@ static bool IsValidIdentifier(const SString& identifier) {
} }
// Check for only valid characters and no double underscores // 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]) || if (!IsWordCharacter(identifier[i]) ||
(identifier[i] == '_' && lastWasUnderscore)) { (identifier[i] == '_' && lastWasUnderscore)) {
return false; return false;
@@ -355,8 +355,8 @@ static bool IsValidNumber(const SString& number) {
int hashPos = number.search("#"); int hashPos = number.search("#");
bool seenDot = false; bool seenDot = false;
int i = 0; size_t i = 0;
int length = number.length(); size_t length = number.length();
if (length == 0) if (length == 0)
return false; // Just in case return false; // Just in case

View File

@@ -108,7 +108,8 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
sc.SetState(SCE_CSS_DEFAULT); sc.SetState(SCE_CSS_DEFAULT);
break; break;
case ':': 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); sc.SetState(SCE_CSS_PSEUDOCLASS);
else if (lastState == SCE_CSS_IDENTIFIER || lastState == SCE_CSS_UNKNOWN_IDENTIFIER) else if (lastState == SCE_CSS_IDENTIFIER || lastState == SCE_CSS_UNKNOWN_IDENTIFIER)
sc.SetState(SCE_CSS_VALUE); sc.SetState(SCE_CSS_VALUE);

View File

@@ -195,7 +195,7 @@ static void FoldESCRIPTDoc(unsigned int startPos, int length, int initStyle, Wor
styleNext = styler.StyleAt(i + 1); styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (foldComment && IsStreamCommentStyle(style)) { if (foldComment && IsStreamCommentStyle(style)) {
if (!IsStreamCommentStyle(stylePrev)) { if (!IsStreamCommentStyle(stylePrev)) {
levelCurrent++; levelCurrent++;

View File

@@ -127,7 +127,7 @@ static int stateForPrintState(int StateToPrint) {
} }
static inline bool IsNumber(unsigned int start, Accessor &styler) { 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] == '#'); (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, static void classifyWordHTJS(unsigned int start, unsigned int end,
WordList &keywords, Accessor &styler, script_mode inScriptType) { WordList &keywords, Accessor &styler, script_mode inScriptType) {
char chAttr = SCE_HJ_WORD; char chAttr = SCE_HJ_WORD;
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.'); bool wordIsNumber = IsADigit(styler[start]) || (styler[start] == '.');
if (wordIsNumber) if (wordIsNumber)
chAttr = SCE_HJ_NUMBER; chAttr = SCE_HJ_NUMBER;
else { 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) { static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, script_mode inScriptType) {
char chAttr = SCE_HB_IDENTIFIER; char chAttr = SCE_HB_IDENTIFIER;
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.'); bool wordIsNumber = IsADigit(styler[start]) || (styler[start] == '.');
if (wordIsNumber) if (wordIsNumber)
chAttr = SCE_HB_NUMBER; chAttr = SCE_HB_NUMBER;
else { 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) { 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]; char s[30 + 1];
unsigned int i = 0; unsigned int i = 0;
for (; i < end - start + 1 && i < 30; i++) { 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 // Called when in a PHP word
static void classifyWordHTPHP(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { static void classifyWordHTPHP(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
char chAttr = SCE_HPHP_DEFAULT; char chAttr = SCE_HPHP_DEFAULT;
bool wordIsNumber = isdigit(styler[start]) != 0; bool wordIsNumber = IsADigit(styler[start]);
if (wordIsNumber) if (wordIsNumber)
chAttr = SCE_HPHP_NUMBER; chAttr = SCE_HPHP_NUMBER;
else { else {
@@ -375,19 +375,21 @@ static int StateForScript(script_type scriptLanguage) {
} }
static inline bool ishtmlwordchar(char ch) { 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) { 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) { 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) { static inline bool IsPhpWordChar(char ch) {
return isdigit(ch) || IsPhpWordStart(ch); return IsADigit(ch) || IsPhpWordStart(ch);
} }
static bool InTagState(int state) { static bool InTagState(int state) {
@@ -787,7 +789,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} else if ((ch == '-') && (chPrev == '-')) { } else if ((ch == '-') && (chPrev == '-')) {
styler.ColourTo(i - 2, StateToPrint); styler.ColourTo(i - 2, StateToPrint);
state = SCE_H_SGML_COMMENT; state = SCE_H_SGML_COMMENT;
} else if (isalpha(ch) && (chPrev == '%')) { } else if (isascii(ch) && isalpha(ch) && (chPrev == '%')) {
styler.ColourTo(i - 2, StateToPrint); styler.ColourTo(i - 2, StateToPrint);
state = SCE_H_SGML_ENTITY; state = SCE_H_SGML_ENTITY;
} else if (ch == '#') { } else if (ch == '#') {
@@ -905,7 +907,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} }
break; break;
case SCE_H_SGML_SPECIAL: case SCE_H_SGML_SPECIAL:
if (!isupper(ch)) { if (!(isascii(ch) && isupper(ch))) {
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
if (isalnum(ch)) { if (isalnum(ch)) {
state = SCE_H_SGML_ERROR; state = SCE_H_SGML_ERROR;
@@ -918,7 +920,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
if (ch == ';') { if (ch == ';') {
styler.ColourTo(i, StateToPrint); styler.ColourTo(i, StateToPrint);
state = SCE_H_SGML_DEFAULT; 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); styler.ColourTo(i, SCE_H_SGML_ERROR);
state = SCE_H_SGML_DEFAULT; state = SCE_H_SGML_DEFAULT;
} }
@@ -928,7 +930,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.ColourTo(i, StateToPrint); styler.ColourTo(i, StateToPrint);
state = SCE_H_DEFAULT; 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); styler.ColourTo(i, SCE_H_TAGUNKNOWN);
state = SCE_H_DEFAULT; state = SCE_H_DEFAULT;
} }
@@ -1464,7 +1466,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} }
break; break;
case SCE_HPHP_NUMBER: case SCE_HPHP_NUMBER:
if (!isdigit(ch)) { if (!IsADigit(ch)) {
styler.ColourTo(i - 1, SCE_HPHP_NUMBER); styler.ColourTo(i - 1, SCE_HPHP_NUMBER);
if (isoperator(ch)) if (isoperator(ch))
state = SCE_HPHP_OPERATOR; 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_OPERATOR:
case SCE_HPHP_DEFAULT: case SCE_HPHP_DEFAULT:
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
if (isdigit(ch)) { if (IsADigit(ch)) {
state = SCE_HPHP_NUMBER; state = SCE_HPHP_NUMBER;
} else if (iswordstart(ch)) { } else if (iswordstart(ch)) {
state = SCE_HPHP_WORD; state = SCE_HPHP_WORD;

View File

@@ -24,7 +24,7 @@
#include "SciLexer.h" #include "SciLexer.h"
static inline bool IsAWordChar(const int ch) { 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) { inline bool IsAWordStart(const int ch) {
@@ -58,6 +58,8 @@ static void ColouriseLuaDoc(
WordList &keywords4 = *keywordlists[3]; WordList &keywords4 = *keywordlists[3];
WordList &keywords5 = *keywordlists[4]; WordList &keywords5 = *keywordlists[4];
WordList &keywords6 = *keywordlists[5]; WordList &keywords6 = *keywordlists[5];
WordList &keywords7 = *keywordlists[6];
WordList &keywords8 = *keywordlists[7];
int currentLine = styler.GetLine(startPos); int currentLine = styler.GetLine(startPos);
// Initialize the literal string [[ ... ]] nesting level, if we are inside such a string. // 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) { if (sc.state == SCE_LUA_OPERATOR) {
sc.SetState(SCE_LUA_DEFAULT); sc.SetState(SCE_LUA_DEFAULT);
} else if (sc.state == SCE_LUA_NUMBER) { } else if (sc.state == SCE_LUA_NUMBER) {
if (!IsAWordChar(sc.ch)) { // We stop the number definition on non-numerical non-dot non-eE non-sign char
sc.SetState(SCE_LUA_DEFAULT); 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) { } else if (sc.state == SCE_LUA_IDENTIFIER) {
if (!IsAWordChar(sc.ch) || (sc.ch == '.')) { if (!IsAWordChar(sc.ch)) {
char s[100]; char s[100];
sc.GetCurrent(s, sizeof(s)); sc.GetCurrent(s, sizeof(s));
if (keywords.InList(s)) { if (keywords.InList(s)) {
@@ -140,6 +146,12 @@ static void ColouriseLuaDoc(
sc.ChangeState(SCE_LUA_WORD5); sc.ChangeState(SCE_LUA_WORD5);
} else if (keywords6.InList(s)) { } else if (keywords6.InList(s)) {
sc.ChangeState(SCE_LUA_WORD6); 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); 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[] = { static const char * const luaWordListDesc[] = {
"Keywords", "Keywords",
"Basic functions", "Basic functions",
"String & math functions", "String, (table) & math functions",
"I/O & system facilities", "(coroutines), I/O & system facilities",
"XXX", "XXX",
"XXX", "XXX",
0 0

View File

@@ -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( static void ColouriseMakeLine(
char *lineBuffer, char *lineBuffer,
unsigned int lengthLine, unsigned int lengthLine,
@@ -638,7 +691,7 @@ static void ColouriseNullDoc(unsigned int startPos, int length, int, WordList *[
LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc, "batch", 0, batchWordListDesc); LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc, "batch", 0, batchWordListDesc);
LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc, "diff", 0, emptyWordListDesc); 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 lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc, "makefile", 0, emptyWordListDesc);
LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc, "errorlist", 0, emptyWordListDesc); LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc, "errorlist", 0, emptyWordListDesc);
LexerModule lmLatex(SCLEX_LATEX, ColouriseLatexDoc, "latex", 0, emptyWordListDesc); LexerModule lmLatex(SCLEX_LATEX, ColouriseLatexDoc, "latex", 0, emptyWordListDesc);

View File

@@ -1,10 +1,19 @@
// Scintilla source code edit control // Scintilla source code edit control
/** @file LexPOV.cxx /** @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. // 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 <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
@@ -20,101 +29,152 @@
#include "Scintilla.h" #include "Scintilla.h"
#include "SciLexer.h" #include "SciLexer.h"
#define KEYWORD_BOXHEADER 1
#define KEYWORD_FOLDCONTRACTED 2
static inline bool IsAWordChar(const int ch) { 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) { inline bool IsAWordStart(const int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '_'); return ch < 0x80 && isalpha(ch);
} }
static inline bool IsStateComment(const int state) { static void ColourisePovDoc(
return ((state == SCE_POV_COMMENT) || unsigned int startPos,
(state == SCE_POV_COMMENTLINE) || int length,
(state == SCE_POV_COMMENTDOC)); int initStyle,
} WordList *keywordlists[],
Accessor &styler) {
static inline bool IsStateString(const int state) { WordList &keywords1 = *keywordlists[0];
return ((state == SCE_POV_STRING));
}
static void ColourisePOVDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
WordList &keywords = *keywordlists[0];
WordList &keywords2 = *keywordlists[1]; 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 // Do not leak onto next line
/*if (initStyle == SCE_POV_STRINGEOL) if (initStyle == SCE_POV_STRINGEOL) {
initStyle = SCE_POV_DEFAULT;*/ initStyle = SCE_POV_DEFAULT;
}
StyleContext sc(startPos, length, initStyle, styler); StyleContext sc(startPos, length, initStyle, styler);
short stringLen = 0;
bool caseSensitive = styler.GetPropertyInt("pov.case.sensitive", 1) != 0;
for (; sc.More(); sc.Forward()) { for (; sc.More(); sc.Forward()) {
if (sc.atLineEnd) {
/*if (sc.atLineStart && (sc.state == SCE_POV_STRING)) { // Update the line state, so it can be seen by next line
// Prevent SCE_POV_STRINGEOL from leaking back to previous line currentLine = styler.GetLine(sc.currentPos);
sc.SetState(SCE_POV_STRING); if (sc.state == SCE_POV_COMMENT) {
}*/ // Inside a block comment, we set the line state
styler.SetLineState(currentLine, blockCommentLevel);
// Handle line continuation generically. } else {
if (sc.ch == '\\') { // Reset the line state
if (sc.chNext == '\n' || sc.chNext == '\r') { styler.SetLineState(currentLine, 0);
sc.Forward();
if (sc.ch == '\r' && sc.chNext == '\n') {
sc.Forward();
}
continue;
} }
} }
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. // 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); sc.SetState(SCE_POV_DEFAULT);
} else if (sc.state == SCE_POV_NUMBER) { } else if (sc.state == SCE_POV_NUMBER) {
if (!IsADigit(sc.ch) || sc.ch != '.') { // We stop the number definition on non-numerical non-dot non-eE non-sign char
sc.SetState(SCE_POV_DEFAULT); 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) { } else if (sc.state == SCE_POV_IDENTIFIER) {
if (!IsAWordChar(sc.ch) || (sc.ch == '.')) { if (!IsAWordChar(sc.ch)) {
char s[100]; char s[100];
if (caseSensitive) { sc.GetCurrent(s, sizeof(s));
sc.GetCurrent(s, sizeof(s)); if (keywords2.InList(s)) {
} else {
sc.GetCurrentLowered(s, sizeof(s));
}
if (keywords.InList(s)) {
sc.ChangeState(SCE_POV_WORD);
} else if (keywords2.InList(s)) {
sc.ChangeState(SCE_POV_WORD2); 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); sc.SetState(SCE_POV_DEFAULT);
} }
} else if (sc.state == SCE_POV_COMMENT) { } else if (sc.state == SCE_POV_COMMENT) {
if (sc.Match('*', '/')) { if (sc.Match('/', '*')) {
blockCommentLevel++;
sc.Forward(); sc.Forward();
sc.ForwardSetState(SCE_POV_DEFAULT); } else if (sc.Match('*', '/') && blockCommentLevel > 0) {
} blockCommentLevel--;
} else if (sc.state == SCE_POV_COMMENTDOC) {
if (sc.Match('*', '/')) {
sc.Forward(); sc.Forward();
sc.ForwardSetState(SCE_POV_DEFAULT); if (blockCommentLevel == 0) {
sc.ForwardSetState(SCE_POV_DEFAULT);
}
} }
} else if (sc.state == SCE_POV_COMMENTLINE) { } else if (sc.state == SCE_POV_COMMENTLINE) {
if (sc.atLineEnd) { if (sc.atLineEnd) {
sc.SetState(SCE_POV_DEFAULT); sc.SetState(SCE_POV_DEFAULT);
} }
} else if (sc.state == SCE_POV_STRING) { } 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.ch == '\\') {
if (sc.chNext == '\"' || sc.chNext == '\\') { if (sc.chNext == '\"' || sc.chNext == '\\') {
sc.Forward(); sc.Forward();
} }
} else if (sc.ch == '\"') { } else if (sc.ch == '\"') {
sc.ForwardSetState(SCE_C_DEFAULT);
} else if (sc.atLineEnd) {
sc.ForwardSetState(SCE_POV_DEFAULT); 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 (sc.state == SCE_POV_DEFAULT) {
if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
sc.SetState(SCE_POV_NUMBER); sc.SetState(SCE_POV_NUMBER);
} else if (IsAWordStart(sc.ch) || (sc.ch == '#')) { } else if (IsAWordStart(sc.ch)) {
sc.SetState(SCE_POV_IDENTIFIER); sc.SetState(SCE_POV_IDENTIFIER);
} else if (sc.Match('/', '*')) { } else if (sc.Match('/', '*')) {
blockCommentLevel = 1;
sc.SetState(SCE_POV_COMMENT); sc.SetState(SCE_POV_COMMENT);
sc.Forward(); // Eat the * so it isn't used for the end of the comment sc.Forward(); // Eat the * so it isn't used for the end of the comment
} else if (sc.Match('/', '/')) { } else if (sc.Match('/', '/')) {
sc.SetState(SCE_POV_COMMENTLINE); sc.SetState(SCE_POV_COMMENTLINE);
} else if (sc.ch == '\"') { } else if (sc.ch == '\"') {
sc.SetState(SCE_POV_STRING); sc.SetState(SCE_POV_STRING);
//} else if (isoperator(static_cast<char>(sc.ch))) { stringLen = 0;
} 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 == ':') { } 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); sc.SetState(SCE_POV_OPERATOR);
} else if (sc.ch == '{' || sc.ch == '}') {
sc.SetState(SCE_POV_BRACE);
} }
} }
} }
sc.Complete(); sc.Complete();
} }
static bool IsStreamCommentStyle(int style) { static void FoldPovDoc(
return style == SCE_POV_COMMENT || unsigned int startPos,
style == SCE_POV_COMMENTDOC; int length,
} int initStyle,
WordList *[],
Accessor &styler) {
static void FoldNoBoxPOVDoc(unsigned int startPos, int length, int initStyle, bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
Accessor &styler) { bool foldDirective = styler.GetPropertyInt("fold.directive") != 0;
bool foldComment = styler.GetPropertyInt("fold.comment", 1) != 0;
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
unsigned int endPos = startPos + length; unsigned int endPos = startPos + length;
int visibleChars = 0; int visibleChars = 0;
@@ -168,15 +236,33 @@ static void FoldNoBoxPOVDoc(unsigned int startPos, int length, int initStyle,
style = styleNext; style = styleNext;
styleNext = styler.StyleAt(i + 1); styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (foldComment && IsStreamCommentStyle(style)) { if (foldComment && (style == SCE_POV_COMMENT)) {
if (!IsStreamCommentStyle(stylePrev)) { if (stylePrev != SCE_POV_COMMENT) {
levelCurrent++; 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. // Comments don't end at end of line and the next character may be unstyled.
levelCurrent--; 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 == '{') { if (ch == '{') {
levelCurrent++; levelCurrent++;
} else if (ch == '}') { } else if (ch == '}') {
@@ -204,19 +290,16 @@ static void FoldNoBoxPOVDoc(unsigned int startPos, int length, int initStyle,
styler.SetLevel(lineCurrent, levelPrev | flagsNext); styler.SetLevel(lineCurrent, levelPrev | flagsNext);
} }
static void FoldPOVDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { static const char * const povWordLists[] = {
FoldNoBoxPOVDoc(startPos, length, initStyle, styler); "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[] = { LexerModule lmPOV(SCLEX_POV, ColourisePovDoc, "pov", FoldPovDoc, 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);

View File

@@ -3,6 +3,7 @@
** Lexer for Pascal. ** Lexer for Pascal.
** Written by Laurent le Tynevez ** Written by Laurent le Tynevez
** Updated by Simon Steele <s.steele@pnotepad.org> September 2002 ** Updated by Simon Steele <s.steele@pnotepad.org> September 2002
** Updated by Mathias Rauen <scite@madshi.net> May 2003 (Delphi adjustments)
**/ **/
#include <stdlib.h> #include <stdlib.h>
@@ -40,12 +41,15 @@ static bool IsStreamCommentStyle(int style) {
style == SCE_C_COMMENTDOCKEYWORDERROR; style == SCE_C_COMMENTDOCKEYWORDERROR;
} }
static inline bool IsAWordChar(const int ch) { static void ColourTo(Accessor &styler, unsigned int end, unsigned int attr, bool bInAsm) {
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_'); 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". // 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) { static int classifyWordPascal(unsigned int start, unsigned int end, /*WordList &keywords*/WordList *keywordlists[], Accessor &styler, bool bInClass, bool bInAsm) {
int ret = 0; int ret = 0;
WordList& keywords = *keywordlists[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)); getRange(start, end, styler, s, sizeof(s));
char chAttr = SCE_C_IDENTIFIER; char chAttr = SCE_C_IDENTIFIER;
if (isdigit(s[0]) || (s[0] == '.')) { if (isdigit(s[0]) || (s[0] == '.') ||(s[0] == '$')) {
chAttr = SCE_C_NUMBER; chAttr = SCE_C_NUMBER;
} }
else { else {
if (keywords.InList(s)) { if (s[0] == '#') {
chAttr = SCE_C_WORD; chAttr = SCE_C_CHARACTER;
}
if(strcmp(s, "class") == 0) else {
ret = 1; if (keywords.InList(s)) {
else if(strcmp(s, "end") == 0)
ret = -1;
} else if (bInClass) {
if (classwords.InList(s)) {
chAttr = SCE_C_WORD; 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; return ret;
} }
@@ -99,14 +113,14 @@ static void ColourisePascalDoc(unsigned int startPos, int length, int initStyle,
styler.StartAt(startPos); styler.StartAt(startPos);
int state = initStyle; 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; state = SCE_C_DEFAULT;
char chPrev = ' '; char chPrev = ' ';
char chNext = styler[startPos]; char chNext = styler[startPos];
unsigned int lengthDoc = startPos + length; unsigned int lengthDoc = startPos + length;
int visibleChars = 0;
bool bInClassDefinition; bool bInClassDefinition;
int currentLine = styler.GetLine(startPos); int currentLine = styler.GetLine(startPos);
if (currentLine > 0) { if (currentLine > 0) {
styler.SetLineState(currentLine, styler.GetLineState(currentLine-1)); styler.SetLineState(currentLine, styler.GetLineState(currentLine-1));
@@ -116,6 +130,10 @@ static void ColourisePascalDoc(unsigned int startPos, int length, int initStyle,
bInClassDefinition = false; bInClassDefinition = false;
} }
bool bInAsm = (state == SCE_C_REGEX);
if (bInAsm)
state = SCE_C_DEFAULT;
styler.StartSegment(startPos); styler.StartSegment(startPos);
for (unsigned int i = startPos; i < lengthDoc; i++) { for (unsigned int i = startPos; i < lengthDoc; i++) {
char ch = chNext; 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) // 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 // Avoid triggering two times on Dos/Win
// End of line // End of line
if (state == SCE_C_STRINGEOL) { if (state == SCE_C_CHARACTER) {
styler.ColourTo(i, state); ColourTo(styler, i, state, bInAsm);
state = SCE_C_DEFAULT; state = SCE_C_DEFAULT;
} }
visibleChars = 0;
currentLine++; currentLine++;
styler.SetLineState(currentLine, (bInClassDefinition ? 1 : 0)); styler.SetLineState(currentLine, (bInClassDefinition ? 1 : 0));
} }
if (!isspacechar(ch))
visibleChars++;
if (styler.IsLeadByte(ch)) { if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2); 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 (state == SCE_C_DEFAULT) {
if (iswordstart(ch) || (ch == '@')) { if (iswordstart(ch) || ch == '#' || ch == '$' || (ch == '@' && bInAsm)) {
styler.ColourTo(i-1, state); ColourTo(styler, i-1, state, bInAsm);
state = SCE_C_IDENTIFIER; state = SCE_C_IDENTIFIER;
} else if (ch == '{' && chNext != '$' && chNext != '&') { } else if (ch == '{' && chNext != '$' && chNext != '&') {
styler.ColourTo(i-1, state); ColourTo(styler, i-1, state, bInAsm);
state = SCE_C_COMMENT; state = SCE_C_COMMENT;
} else if (ch == '(' && chNext == '*' } else if (ch == '(' && chNext == '*'
&& styler.SafeGetCharAt(i + 2) != '$' && styler.SafeGetCharAt(i + 2) != '$'
&& styler.SafeGetCharAt(i + 2) != '&') { && styler.SafeGetCharAt(i + 2) != '&') {
styler.ColourTo(i-1, state); ColourTo(styler, i-1, state, bInAsm);
state = SCE_C_COMMENTDOC; state = SCE_C_COMMENTDOC;
} else if (ch == '/' && chNext == '/') { } else if (ch == '/' && chNext == '/') {
styler.ColourTo(i-1, state); ColourTo(styler, i-1, state, bInAsm);
state = SCE_C_COMMENTLINE; state = SCE_C_COMMENTLINE;
} else if (ch == '\'') { } else if (ch == '\'') {
styler.ColourTo(i-1, state); ColourTo(styler, i-1, state, bInAsm);
state = SCE_C_CHARACTER; state = SCE_C_CHARACTER;
} else if (ch == '{' && (chNext == '$' || chNext=='&') && visibleChars == 1) { } else if (ch == '{' && (chNext == '$' || chNext=='&')) {
styler.ColourTo(i-1, state); ColourTo(styler, i-1, state, bInAsm);
state = SCE_C_PREPROCESSOR; state = SCE_C_PREPROCESSOR;
} else if (isoperator(ch)) { } else if (isoperator(ch)) {
styler.ColourTo(i-1, state); ColourTo(styler, i-1, state, bInAsm);
styler.ColourTo(i, SCE_C_OPERATOR); ColourTo(styler, i, SCE_C_OPERATOR, bInAsm);
} }
} else if (state == SCE_C_IDENTIFIER) { } else if (state == SCE_C_IDENTIFIER) {
if (!iswordchar(ch)) { bool bDoublePoint = ((ch == '.') && (chPrev == '.'));
int lStateChange = classifyWordPascal(styler.GetStartSegment(), i - 1, keywordlists, styler, bInClassDefinition); 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) { if(lStateChange == 1) {
styler.SetLineState(currentLine, 1); styler.SetLineState(currentLine, 1);
bInClassDefinition = true; bInClassDefinition = true;
} else if(lStateChange == 2) {
bInAsm = true;
} else if(lStateChange == -1) { } else if(lStateChange == -1) {
styler.SetLineState(currentLine, 0); styler.SetLineState(currentLine, 0);
bInClassDefinition = false; bInClassDefinition = false;
bInAsm = false;
}
if (bDoublePoint) {
i++;
ColourTo(styler, i-1, SCE_C_DEFAULT, bInAsm);
} }
state = SCE_C_DEFAULT; state = SCE_C_DEFAULT;
@@ -189,30 +213,30 @@ static void ColourisePascalDoc(unsigned int startPos, int length, int initStyle,
} else if (ch == '(' && chNext == '*' } else if (ch == '(' && chNext == '*'
&& styler.SafeGetCharAt(i + 2) != '$' && styler.SafeGetCharAt(i + 2) != '$'
&& styler.SafeGetCharAt(i + 2) != '&') { && styler.SafeGetCharAt(i + 2) != '&') {
styler.ColourTo(i-1, state); ColourTo(styler, i-1, state, bInAsm);
state = SCE_C_COMMENTDOC; state = SCE_C_COMMENTDOC;
} else if (ch == '/' && chNext == '/') { } else if (ch == '/' && chNext == '/') {
state = SCE_C_COMMENTLINE; state = SCE_C_COMMENTLINE;
} else if (ch == '\'') { } else if (ch == '\'') {
state = SCE_C_CHARACTER; state = SCE_C_CHARACTER;
} else if (isoperator(ch)) { } else if (isoperator(ch)) {
styler.ColourTo(i, SCE_C_OPERATOR); ColourTo(styler, i, SCE_C_OPERATOR, bInAsm);
} }
} }
} else { } else {
if (state == SCE_C_PREPROCESSOR) { if (state == SCE_C_PREPROCESSOR) {
if (ch=='}'){ if (ch=='}'){
styler.ColourTo(i, state); ColourTo(styler, i, state, bInAsm);
state = SCE_C_DEFAULT; state = SCE_C_DEFAULT;
} else { } else {
if ((ch == '\r' || ch == '\n') && !(chPrev == '\\' || chPrev == '\r')) { if ((ch == '\r' || ch == '\n') && !(chPrev == '\\' || chPrev == '\r')) {
styler.ColourTo(i-1, state); ColourTo(styler, i-1, state, bInAsm);
state = SCE_C_DEFAULT; state = SCE_C_DEFAULT;
} }
} }
} else if (state == SCE_C_COMMENT) { } else if (state == SCE_C_COMMENT) {
if (ch == '}' ) { if (ch == '}' ) {
styler.ColourTo(i, state); ColourTo(styler, i, state, bInAsm);
state = SCE_C_DEFAULT; state = SCE_C_DEFAULT;
} }
} else if (state == SCE_C_COMMENTDOC) { } 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) || ( if (((i > styler.GetStartSegment() + 2) || (
(initStyle == SCE_C_COMMENTDOC) && (initStyle == SCE_C_COMMENTDOC) &&
(styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) { (styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
styler.ColourTo(i, state); ColourTo(styler, i, state, bInAsm);
state = SCE_C_DEFAULT; state = SCE_C_DEFAULT;
} }
} }
} else if (state == SCE_C_COMMENTLINE) { } else if (state == SCE_C_COMMENTLINE) {
if (ch == '\r' || ch == '\n') { if (ch == '\r' || ch == '\n') {
styler.ColourTo(i-1, state); ColourTo(styler, i-1, state, bInAsm);
state = SCE_C_DEFAULT; state = SCE_C_DEFAULT;
} }
} else if (state == SCE_C_CHARACTER) { } else if (state == SCE_C_CHARACTER) {
if ((ch == '\r' || ch == '\n')) { if (ch == '\'') {
styler.ColourTo(i-1, SCE_C_STRINGEOL); ColourTo(styler, i, state, bInAsm);
state = SCE_C_STRINGEOL;
} else if (ch == '\'') {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT; state = SCE_C_DEFAULT;
} }
} }
} }
chPrev = ch; chPrev = ch;
} }
styler.ColourTo(lengthDoc - 1, state); ColourTo(styler, lengthDoc - 1, state, bInAsm);
} }
static void FoldPascalDoc(unsigned int startPos, int length, int initStyle, WordList *[], static void FoldPascalDoc(unsigned int startPos, int length, int initStyle, WordList *[],

View File

@@ -23,7 +23,7 @@ static void classifyWordSQL(unsigned int start, unsigned int end, WordList &keyw
char s[100]; char s[100];
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.'); bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) { 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'; s[i + 1] = '\0';
} }
char chAttr = SCE_C_IDENTIFIER; char chAttr = SCE_C_IDENTIFIER;
@@ -88,7 +88,7 @@ static void ColouriseSQLDoc(unsigned int startPos, int length,
} else if (ch == '-' && chNext == '-') { } else if (ch == '-' && chNext == '-') {
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
state = SCE_C_COMMENTLINE; state = SCE_C_COMMENTLINE;
} else if (ch == '\'') { } else if ((ch == '\'') || (ch == '"')) {
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
state = SCE_C_STRING; state = SCE_C_STRING;
} else if (isoperator(ch)) { } else if (isoperator(ch)) {
@@ -103,7 +103,7 @@ static void ColouriseSQLDoc(unsigned int startPos, int length,
state = SCE_C_COMMENT; state = SCE_C_COMMENT;
} else if (ch == '-' && chNext == '-') { } else if (ch == '-' && chNext == '-') {
state = SCE_C_COMMENTLINE; state = SCE_C_COMMENTLINE;
} else if (ch == '\'') { } else if ((ch == '\'') || (ch == '"')) {
state = SCE_C_STRING; state = SCE_C_STRING;
} else if (isoperator(ch)) { } else if (isoperator(ch)) {
styler.ColourTo(i, SCE_C_OPERATOR); styler.ColourTo(i, SCE_C_OPERATOR);
@@ -134,6 +134,16 @@ static void ColouriseSQLDoc(unsigned int startPos, int length,
} }
ch = chNext; ch = chNext;
chNext = styler.SafeGetCharAt(i + 1); 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 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; state = SCE_C_COMMENT;
} else if (ch == '-' && chNext == '-') { } else if (ch == '-' && chNext == '-') {
state = SCE_C_COMMENTLINE; state = SCE_C_COMMENTLINE;
} else if (ch == '\'') { } else if ((ch == '\'') || (ch == '"')) {
state = SCE_C_STRING; state = SCE_C_STRING;
} else if (iswordstart(ch)) { } else if (iswordstart(ch)) {
state = SCE_C_WORD; state = SCE_C_WORD;

View File

@@ -71,16 +71,6 @@ bool EqualCaseInsensitive(const char *a, const char *b) {
return 0 == CompareCaseInsensitive(a, 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() { PropSet::PropSet() {
superPS = 0; superPS = 0;
for (int root = 0; root < hashRoots; root++) for (int root = 0; root < hashRoots; root++)
@@ -160,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, "$("); const char *var = strstr(value, "$(");
while (var) { while (var) {
if (isprefix(var + 2, key) && (var[2 + strlen(key)] == ')')) { if (isprefix(var + 2, key) && (var[2 + strlen(key)] == ')')) {

View File

@@ -10,11 +10,11 @@
* Dept. of Computer Science * Dept. of Computer Science
* York University * 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 * Translation to C++ by Neil Hodgson neilh@scintilla.org
* Removed all use of register. * Removed all use of register.
* Converted to modern function prototypes. * 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. * used from multiple threads etc.
* *
* These routines are the PUBLIC DOMAIN equivalents of regex * These routines are the PUBLIC DOMAIN equivalents of regex
@@ -30,8 +30,14 @@
* Modification history: * Modification history:
* *
* $Log$ * $Log$
* Revision 1.5.2.3 2003/07/18 06:35:14 RD * Revision 1.5.2.4 2003/09/18 18:14:11 RD
* Update to Scintilla 1.53 * 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 * Revision 1.9 2003/03/21 10:36:08 nyamatongwe
* Detect patterns too long in regular expression search. * Detect patterns too long in regular expression search.
@@ -82,17 +88,17 @@
* *
* Revision 1.2 88/08/28 15:36:04 oz * Revision 1.2 88/08/28 15:36:04 oz
* Use a complement bitmap to represent NCL. * Use a complement bitmap to represent NCL.
* This removes the need to have seperate * This removes the need to have seperate
* code in the PMatch case block - it is * code in the PMatch case block - it is
* just CCL code now. * just CCL code now.
* *
* Use the actual CCL code in the CLO * Use the actual CCL code in the CLO
* section of PMatch. No need for a recursive * section of PMatch. No need for a recursive
* PMatch call. * PMatch call.
* *
* Use a bitmap table to set char bits in an * Use a bitmap table to set char bits in an
* 8-bit chunk. * 8-bit chunk.
* *
* Interfaces: * Interfaces:
* RESearch::Compile: compile a regular expression into a NFA. * RESearch::Compile: compile a regular expression into a NFA.
* *
@@ -122,7 +128,7 @@
* void re_fail(msg, op) * void re_fail(msg, op)
* char *msg; * char *msg;
* char op; * char op;
* *
* Regular Expressions: * Regular Expressions:
* *
* [1] char matches itself, unless it is a special * [1] char matches itself, unless it is a special
@@ -132,20 +138,20 @@
* *
* [3] \ matches the character following it, except * [3] \ matches the character following it, except
* when followed by a left or right round bracket, * 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]) * (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 * other meta-characters, and itself. When used
* in a set ([4]), it is treated as an ordinary * in a set ([4]), it is treated as an ordinary
* character. * character.
* *
* [4] [set] matches one of the characters in the set. * [4] [set] matches one of the characters in the set.
* If the first character in the set is "^", * If the first character in the set is "^",
* it matches a character NOT in the set, i.e. * it matches a character NOT in the set, i.e.
* complements the set. A shorthand S-E is * complements the set. A shorthand S-E is
* used to specify a set of characters S upto * used to specify a set of characters S upto
* E, inclusive. The special characters "]" and * E, inclusive. The special characters "]" and
* "-" have no special meaning if they appear * "-" have no special meaning if they appear
* as the first chars in the set. * as the first chars in the set.
* examples: match: * examples: match:
* *
@@ -210,8 +216,8 @@
* Notes: * Notes:
* *
* This implementation uses a bit-set representation for character * This implementation uses a bit-set representation for character
* classes for speed and compactness. Each character is represented * classes for speed and compactness. Each character is represented
* by one bit in a 128-bit block. Thus, CCL always takes a * 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 * constant 16 bytes in the internal nfa, and RESearch::Execute does a single
* bit comparison to locate the character in the set. * 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 * compile: CHR f CHR o CLO CHR o END CLO ANY END END
* matches: fo foo fooo foobar fobar foxx ... * 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 * compile: CHR f CHR o CCL bitset CHR a CCL bitset END
* matches: fobar fooar fobaz fooaz * matches: fobar fooar fobaz fooaz
* *
@@ -269,7 +275,7 @@
const char bitarr[] = {1,2,4,8,16,32,64,'\200'}; const char bitarr[] = {1,2,4,8,16,32,64,'\200'};
#define badpat(x) (*nfa = END, x) #define badpat(x) (*nfa = END, x)
RESearch::RESearch() { RESearch::RESearch() {
Init(); Init();
} }
@@ -359,7 +365,7 @@ const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, b
int n; int n;
char mask; /* xor mask -CCL/NCL */ char mask; /* xor mask -CCL/NCL */
int c1, c2; int c1, c2;
if (!pat || !length) if (!pat || !length)
if (sta) if (sta)
return 0; return 0;
@@ -401,7 +407,7 @@ const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, b
i++; i++;
if (*++p == '^') { if (*++p == '^') {
mask = '\377'; mask = '\377';
i++; i++;
p++; p++;
} else } 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) for (n = 0; n < BITBLK; bittab[n++] = (char) 0)
*mp++ = static_cast<char>(mask ^ bittab[n]); *mp++ = static_cast<char>(mask ^ bittab[n]);
break; break;
case '*': /* match 0 or more.. */ case '*': /* match 0 or more.. */
@@ -590,7 +596,7 @@ const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, b
* RESearch::Execute: * RESearch::Execute:
* execute nfa to find a match. * execute nfa to find a match.
* *
* special cases: (nfa[0]) * special cases: (nfa[0])
* BOL * BOL
* Match only once, starting from the * Match only once, starting from the
* beginning. * beginning.
@@ -615,7 +621,7 @@ int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) {
bol = lp; bol = lp;
failure = 0; failure = 0;
Clear(); Clear();
switch(*ap) { switch(*ap) {
@@ -656,7 +662,7 @@ int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) {
return 1; return 1;
} }
/* /*
* PMatch: internal routine for the hard part * PMatch: internal routine for the hard part
* *
* This code is partly snarfed from an early grep written by * 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] * At the end of a successful match, bopat[n] and eopat[n]
* are set to the beginning and end of subpatterns matched * 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 * 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 * 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 * 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 _ * TRUE for 0-9 A-Z a-z _
*/ */
static char chrtyp[MAXCHR] = { 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 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, 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, 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, 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 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] * the compact bitset representation for the default table]
*/ */
static char deftab[16] = { static char deftab[16] = {
0, 0, 0, 0, 0, 0, '\377', 003, '\376', '\377', '\377', '\207', 0, 0, 0, 0, 0, 0, '\377', 003, '\376', '\377', '\377', '\207',
'\376', '\377', '\377', 007 '\376', '\377', '\377', 007
}; };
void RESearch::ModifyWord(char *s) { void RESearch::ModifyWord(char *s) {
int i; int i;
@@ -881,7 +887,7 @@ int RESearch::Substitute(CharacterIndexer &ci, char *src, char *dst) {
pin = c - '0'; pin = c - '0';
break; break;
} }
default: default:
*dst++ = c; *dst++ = c;
continue; continue;

View File

@@ -18,7 +18,7 @@
#define BITBLK MAXCHR/CHRBIT #define BITBLK MAXCHR/CHRBIT
class CharacterIndexer { class CharacterIndexer {
public: public:
virtual char CharAt(int index)=0; virtual char CharAt(int index)=0;
}; };

View File

@@ -15,18 +15,18 @@
*/ */
class SVector { class SVector {
enum { allocSize = 4000 }; enum { allocSize = 4000 };
int *v; ///< The vector int *v; ///< The vector
unsigned int size; ///< Number of elements allocated unsigned int size; ///< Number of elements allocated
unsigned int len; ///< Number of elements used in vector unsigned int len; ///< Number of elements used in vector
bool allocFailure; ///< A memory allocation call has failed bool allocFailure; ///< A memory allocation call has failed
/** Internally allocate more elements than the user wants /** Internally allocate more elements than the user wants
* to avoid thrashing the memory allocator. */ * to avoid thrashing the memory allocator. */
void SizeTo(int newSize) { void SizeTo(int newSize) {
if (newSize < allocSize) if (newSize < allocSize)
newSize += allocSize; newSize += allocSize;
else else
newSize = (newSize * 3) / 2; newSize = (newSize * 3) / 2;
int* newv = new int[newSize]; int* newv = new int[newSize];
if (!newv) { if (!newv) {
@@ -44,7 +44,7 @@ class SVector {
delete []v; delete []v;
v = newv; v = newv;
} }
public: public:
SVector() { SVector() {
allocFailure = false; allocFailure = false;

View File

@@ -203,11 +203,11 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
pdoc->DeleteChars(currentPos, lenEntered); pdoc->DeleteChars(currentPos, lenEntered);
SetEmptySelection(currentPos); SetEmptySelection(currentPos);
pdoc->InsertString(currentPos, list); pdoc->InsertString(currentPos, list);
SetEmptySelection(currentPos + strlen(list)); SetEmptySelection(currentPos + static_cast<int>(strlen(list)));
} else { } else {
SetEmptySelection(currentPos); SetEmptySelection(currentPos);
pdoc->InsertString(currentPos, list + lenEntered); pdoc->InsertString(currentPos, list + lenEntered);
SetEmptySelection(currentPos + strlen(list + lenEntered)); SetEmptySelection(currentPos + static_cast<int>(strlen(list + lenEntered)));
} }
return; return;
} }
@@ -340,7 +340,7 @@ void ScintillaBase::AutoCompleteCompleted() {
if (item != -1) { if (item != -1) {
SString piece = selected; SString piece = selected;
pdoc->InsertString(firstPos, piece.c_str()); pdoc->InsertString(firstPos, piece.c_str());
SetEmptySelection(firstPos + piece.length()); SetEmptySelection(firstPos + static_cast<int>(piece.length()));
} }
pdoc->EndUndoAction(); pdoc->EndUndoAction();
} }
@@ -557,7 +557,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
return ac.GetTypesep(); return ac.GetTypesep();
case SCI_CALLTIPSHOW: case SCI_CALLTIPSHOW:
CallTipShow(LocationFromPosition(wParam), CallTipShow(LocationFromPosition(wParam),
reinterpret_cast<const char *>(lParam)); reinterpret_cast<const char *>(lParam));
break; break;

View File

@@ -43,7 +43,7 @@ protected:
int lexLanguage; int lexLanguage;
const LexerModule *lexCurrent; const LexerModule *lexCurrent;
PropSet props; PropSet props;
enum {numWordLists=9}; enum {numWordLists=KEYWORDSET_MAX+1};
WordList *keyWordLists[numWordLists+1]; WordList *keyWordLists[numWordLists+1];
void SetLexer(uptr_t wParam); void SetLexer(uptr_t wParam);
void SetLexerLanguage(const char *languageName); void SetLexerLanguage(const char *languageName);

View File

@@ -67,8 +67,8 @@ Style &Style::operator=(const Style &source) {
void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_, void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
const char *fontName_, int characterSet_, const char *fontName_, int characterSet_,
bool bold_, bool italic_, bool eolFilled_, bool bold_, bool italic_, bool eolFilled_,
bool underline_, ecaseForced caseForce_, bool underline_, ecaseForced caseForce_,
bool visible_, bool changeable_, bool hotspot_) { bool visible_, bool changeable_, bool hotspot_) {
fore.desired = fore_; fore.desired = fore_;
back.desired = back_; back.desired = back_;
@@ -102,7 +102,7 @@ void Style::ClearTo(const Style &source) {
source.eolFilled, source.eolFilled,
source.underline, source.underline,
source.caseForce, source.caseForce,
source.visible, source.visible,
source.changeable, source.changeable,
source.hotspot); source.hotspot);
} }

View File

@@ -44,8 +44,8 @@ public:
void Clear(ColourDesired fore_, ColourDesired back_, void Clear(ColourDesired fore_, ColourDesired back_,
int size_, int size_,
const char *fontName_, int characterSet_, const char *fontName_, int characterSet_,
bool bold_, bool italic_, bool eolFilled_, bool bold_, bool italic_, bool eolFilled_,
bool underline_, ecaseForced caseForce_, bool underline_, ecaseForced caseForce_,
bool visible_, bool changeable_, bool hotspot_); bool visible_, bool changeable_, bool hotspot_);
void ClearTo(const Style &source); void ClearTo(const Style &source);
bool EquivalentFontTo(const Style *other) const; bool EquivalentFontTo(const Style *other) const;

View File

@@ -7,7 +7,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include "Platform.h" #include "Platform.h"
@@ -24,7 +24,7 @@ bool WindowAccessor::InternalIsLeadByte(char ch) {
if (SC_CP_UTF8 == codePage) if (SC_CP_UTF8 == codePage)
// For lexing, all characters >= 0x80 are treated the // For lexing, all characters >= 0x80 are treated the
// same so none is considered a lead byte. // same so none is considered a lead byte.
return false; return false;
else else
return Platform::IsDBCSLeadByte(codePage, ch); return Platform::IsDBCSLeadByte(codePage, ch);
} }
@@ -71,10 +71,10 @@ int WindowAccessor::LevelAt(int line) {
return Platform::SendScintilla(id, SCI_GETFOLDLEVEL, line, 0); return Platform::SendScintilla(id, SCI_GETFOLDLEVEL, line, 0);
} }
int WindowAccessor::Length() { int WindowAccessor::Length() {
if (lenDoc == -1) if (lenDoc == -1)
lenDoc = Platform::SendScintilla(id, SCI_GETTEXTLENGTH, 0, 0); lenDoc = Platform::SendScintilla(id, SCI_GETTEXTLENGTH, 0, 0);
return lenDoc; return lenDoc;
} }
int WindowAccessor::GetLineState(int line) { int WindowAccessor::GetLineState(int line) {
@@ -125,7 +125,7 @@ void WindowAccessor::Flush() {
startPos = extremePosition; startPos = extremePosition;
lenDoc = -1; lenDoc = -1;
if (validLen > 0) { if (validLen > 0) {
Platform::SendScintillaPointer(id, SCI_SETSTYLINGEX, validLen, Platform::SendScintillaPointer(id, SCI_SETSTYLINGEX, validLen,
styleBuf); styleBuf);
validLen = 0; validLen = 0;
} }
@@ -134,12 +134,12 @@ void WindowAccessor::Flush() {
int WindowAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) { int WindowAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) {
int end = Length(); int end = Length();
int spaceFlags = 0; 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 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. // the same or the indentation of one line is a prefix of the other.
int pos = LineStart(line); int pos = LineStart(line);
char ch = (*this)[pos]; char ch = (*this)[pos];
int indent = 0; int indent = 0;
@@ -166,7 +166,7 @@ int WindowAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsC
} }
ch = (*this)[++pos]; ch = (*this)[++pos];
} }
*flags = spaceFlags; *flags = spaceFlags;
indent += SC_FOLDLEVELBASE; indent += SC_FOLDLEVELBASE;
// if completely empty line or the start of a comment... // if completely empty line or the start of a comment...

View File

@@ -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) { data(0), codes(0), colours(0), lines(0) {
Init(textForm); Init(textForm);
} }
@@ -102,7 +102,7 @@ void XPM::Init(const char * const *linesForm) {
int strings = 1+height+nColours; int strings = 1+height+nColours;
lines = new char *[strings]; lines = new char *[strings];
int allocation = 0; size_t allocation = 0;
for (int i=0; i<strings; i++) { for (int i=0; i<strings; i++) {
allocation += MeasureLength(linesForm[i]) + 1; allocation += MeasureLength(linesForm[i]) + 1;
} }

View File

@@ -475,7 +475,7 @@ void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp)
buff[len] = 0; buff[len] = 0;
SendMsg(2049, markerNumber, (long)buff); SendMsg(2049, markerNumber, (long)buff);
delete [] buff; delete [] buff;
} }
// Set a margin to be either numeric or symbolic. // Set a margin to be either numeric or symbolic.
@@ -858,7 +858,7 @@ void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) {
buff[len] = 0; buff[len] = 0;
SendMsg(2405, type, (long)buff); SendMsg(2405, type, (long)buff);
delete [] buff; delete [] buff;
} }
// Clear all the registered images. // Clear all the registered images.
@@ -1802,12 +1802,12 @@ bool wxStyledTextCtrl::GetMouseDownCaptures() {
} }
// Sets the cursor to one of the SC_CURSOR* values. // Sets the cursor to one of the SC_CURSOR* values.
void wxStyledTextCtrl::SetCursor(int cursorType) { void wxStyledTextCtrl::SetSTCCursor(int cursorType) {
SendMsg(2386, cursorType, 0); SendMsg(2386, cursorType, 0);
} }
// Get cursor type. // Get cursor type.
int wxStyledTextCtrl::GetCursor() { int wxStyledTextCtrl::GetSTCCursor() {
return SendMsg(2387, 0, 0); return SendMsg(2387, 0, 0);
} }
@@ -2157,7 +2157,7 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Event handlers // Event handlers
void wxStyledTextCtrl::OnPaint(wxPaintEvent& evt) { void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
wxPaintDC dc(this); wxPaintDC dc(this);
m_swx->DoPaint(&dc, GetUpdateRegion().GetBox()); m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
} }
@@ -2179,7 +2179,7 @@ void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
} }
} }
void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) { void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) {
wxSize sz = GetClientSize(); wxSize sz = GetClientSize();
m_swx->DoSize(sz.x, sz.y); m_swx->DoSize(sz.x, sz.y);
} }
@@ -2257,9 +2257,10 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
int key = evt.GetKeyCode(); int key = evt.GetKeyCode();
bool shift = evt.ShiftDown(), bool shift = evt.ShiftDown(),
ctrl = evt.ControlDown(), 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", // printf("KeyDn key:%d shift:%d ctrl:%d alt:%d processed:%d consumed:%d\n",
// key, shift, ctrl, alt, processed, m_lastKeyDownConsumed); // key, shift, ctrl, alt, processed, m_lastKeyDownConsumed);
@@ -2269,22 +2270,22 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
} }
void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) { void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& WXUNUSED(evt)) {
m_swx->DoLoseFocus(); m_swx->DoLoseFocus();
} }
void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) { void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& WXUNUSED(evt)) {
m_swx->DoGainFocus(); m_swx->DoGainFocus();
} }
void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& evt) { void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) {
m_swx->DoSysColourChange(); m_swx->DoSysColourChange();
} }
void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& evt) { void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) {
// do nothing to help avoid flashing // do nothing to help avoid flashing
} }
@@ -2295,7 +2296,7 @@ void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
} }
void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) { void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) {
m_swx->DoOnListBox(); m_swx->DoOnListBox();
} }

View File

@@ -362,7 +362,7 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Event handlers // Event handlers
void wxStyledTextCtrl::OnPaint(wxPaintEvent& evt) { void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
wxPaintDC dc(this); wxPaintDC dc(this);
m_swx->DoPaint(&dc, GetUpdateRegion().GetBox()); m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
} }
@@ -384,7 +384,7 @@ void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
} }
} }
void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) { void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) {
wxSize sz = GetClientSize(); wxSize sz = GetClientSize();
m_swx->DoSize(sz.x, sz.y); m_swx->DoSize(sz.x, sz.y);
} }
@@ -462,9 +462,10 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
int key = evt.GetKeyCode(); int key = evt.GetKeyCode();
bool shift = evt.ShiftDown(), bool shift = evt.ShiftDown(),
ctrl = evt.ControlDown(), 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", // printf("KeyDn key:%%d shift:%%d ctrl:%%d alt:%%d processed:%%d consumed:%%d\n",
// key, shift, ctrl, alt, processed, m_lastKeyDownConsumed); // key, shift, ctrl, alt, processed, m_lastKeyDownConsumed);
@@ -474,22 +475,22 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
} }
void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) { void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& WXUNUSED(evt)) {
m_swx->DoLoseFocus(); m_swx->DoLoseFocus();
} }
void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) { void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& WXUNUSED(evt)) {
m_swx->DoGainFocus(); m_swx->DoGainFocus();
} }
void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& evt) { void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) {
m_swx->DoSysColourChange(); m_swx->DoSysColourChange();
} }
void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& evt) { void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) {
// do nothing to help avoid flashing // do nothing to help avoid flashing
} }
@@ -500,7 +501,7 @@ void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
} }
void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) { void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) {
m_swx->DoOnListBox(); m_swx->DoOnListBox();
} }

View File

@@ -65,6 +65,7 @@
//----------------------------------------- //-----------------------------------------
// Commands that can be bound to keystrokes // Commands that can be bound to keystrokes
%(CMDS)s %(CMDS)s

View File

@@ -1,6 +1,6 @@
#Makefile from wxHatch for Symantec/Digital Mars compiler #Makefile from wxHatch for Symantec/Digital Mars compiler
WXDIR=..\..\.. WXDIR=..\..\..
TARGET=stctest TARGET=stctest
OBJECTS = $(TARGET).obj OBJECTS = $(TARGET).obj edit.obj prefs.obj
EXTRALIBS=$(WXDIR)\lib\stc_sc.lib EXTRALIBS=$(WXDIR)\lib\stc_sc.lib
include $(WXDIR)\src\makeprog.sc include $(WXDIR)\src\makeprog.sc

View File

@@ -167,6 +167,14 @@ SOURCE=.\stctest.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\edit.cpp
# End Source File
# Begin Source File
SOURCE=.\prefs.cpp
# End Source File
# Begin Source File
SOURCE=.\stctest.rc SOURCE=.\stctest.rc
# ADD BASE RSC /l 0x809 # ADD BASE RSC /l 0x809
# ADD RSC /l 0x809 /i "../../../include" /i "../../../contrib/include" # ADD RSC /l 0x809 /i "../../../include" /i "../../../contrib/include"

View File

@@ -12,7 +12,7 @@ WXDIR = $(WXWIN)
TARGET=stctest TARGET=stctest
EXTRALIBS=$(WXDIR)\lib\stc.lib EXTRALIBS=$(WXDIR)\lib\stc.lib
OBJECTS = $(TARGET).obj OBJECTS = $(TARGET).obj edit.obj prefs.obj
!include $(WXDIR)\src\makeprog.b32 !include $(WXDIR)\src\makeprog.b32

View File

@@ -6,7 +6,7 @@
WXDIR = ../../.. WXDIR = ../../..
TARGET = stctest TARGET = stctest
OBJECTS = $(TARGET).o OBJECTS = $(TARGET).o edit.o prefs.o
EXTRAINC = -I$(WXDIR)/contrib/include EXTRAINC = -I$(WXDIR)/contrib/include
EXTRALIBS = -lstc EXTRALIBS = -lstc

View File

@@ -370,6 +370,22 @@ SOURCE=.\scintilla\src\LexVB.cxx
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\scintilla\src\LexMMIXAL.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexNsis.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexPS.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexScriptol.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LineMarker.cxx SOURCE=.\scintilla\src\LineMarker.cxx
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@@ -58,6 +58,10 @@ OBJECTS = \
LexRuby.obj \ LexRuby.obj \
LexSQL.obj \ LexSQL.obj \
LexVB.obj \ LexVB.obj \
LexMMIXAL.obj \
LexNsis.obj \
LexPS.obj \
LexScriptol.obj \
LineMarker.obj \ LineMarker.obj \
PropSet.obj \ PropSet.obj \
RESearch.obj \ RESearch.obj \
@@ -68,7 +72,6 @@ OBJECTS = \
ViewStyle.obj \ ViewStyle.obj \
WindowAccessor.obj \ WindowAccessor.obj \
XPM.obj \ XPM.obj \
\
PlatWX.obj \ PlatWX.obj \
ScintillaWX.obj \ ScintillaWX.obj \
stc.obj \ stc.obj \

View File

@@ -46,6 +46,10 @@ OBJECTS = \
$(S)/LexRuby.$(OBJSUFF) \ $(S)/LexRuby.$(OBJSUFF) \
$(S)/LexSQL.$(OBJSUFF) \ $(S)/LexSQL.$(OBJSUFF) \
$(S)/LexVB.$(OBJSUFF) \ $(S)/LexVB.$(OBJSUFF) \
$(S)/LexMMIXAL.$(OBJSUFF) \
$(S)/LexNsis.$(OBJSUFF) \
$(S)/LexPS.$(OBJSUFF) \
$(S)/LexScriptol.$(OBJSUFF) \
$(S)/LineMarker.$(OBJSUFF) \ $(S)/LineMarker.$(OBJSUFF) \
$(S)/PropSet.$(OBJSUFF) \ $(S)/PropSet.$(OBJSUFF) \
$(S)/RESearch.$(OBJSUFF) \ $(S)/RESearch.$(OBJSUFF) \

View File

@@ -5,7 +5,7 @@ S=$(SCINTILLA)\src
EXTRASTCCPPFLAGS = -D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(SCINTILLA)/include -I$(S) EXTRASTCCPPFLAGS = -D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(SCINTILLA)/include -I$(S)
EXTRACPPFLAGS=$(EXTRACPPFLAGS) $(EXTRASTCCPPFLAGS) EXTRACPPFLAGS=$(EXTRACPPFLAGS) $(EXTRASTCCPPFLAGS)
STCCPPFLAGS=$(DLL_FLAGS) $(EXTRACPPFLAGS) STCCPPFLAGS=$(DLL_FLAGS) $(EXTRACPPFLAGS)
include $(WXDIR)\src\makesc.env include $(WXDIR)\src\makesc.env
LIBTARGET=$(WXDIR)\lib\stc$(SC_SUFFIX).lib LIBTARGET=$(WXDIR)\lib\stc$(SC_SUFFIX).lib
@@ -52,6 +52,10 @@ OBJECTS = \
$(S)\LexRuby.obj \ $(S)\LexRuby.obj \
$(S)\LexSQL.obj \ $(S)\LexSQL.obj \
$(S)\LexVB.obj \ $(S)\LexVB.obj \
$(S)\LexMMIXAL.obj \
$(S)\LexNsis.obj \
$(S)\LexPS.obj \
$(S)\LexScriptol.obj \
$(S)\LineMarker.obj \ $(S)\LineMarker.obj \
$(S)\PropSet.obj \ $(S)\PropSet.obj \
$(S)\RESearch.obj \ $(S)\RESearch.obj \

View File

@@ -51,6 +51,10 @@ OBJECTS = \
$(D)\LexRuby.obj \ $(D)\LexRuby.obj \
$(D)\LexSQL.obj \ $(D)\LexSQL.obj \
$(D)\LexVB.obj \ $(D)\LexVB.obj \
$(D)\LexMMIXAL.obj \
$(D)\LexNsis.obj \
$(D)\LexPS.obj \
$(D)\LexScriptol.obj \
$(D)\LineMarker.obj \ $(D)\LineMarker.obj \
$(D)\PropSet.obj \ $(D)\PropSet.obj \
$(D)\RESearch.obj \ $(D)\RESearch.obj \

View File

@@ -55,6 +55,10 @@ OBJECTS = &
LexRuby.obj & LexRuby.obj &
LexSQL.obj & LexSQL.obj &
LexVB.obj & LexVB.obj &
LexMMIXAL.obj &
LexNsis.obj &
LexPS.obj &
LexScriptol.obj &
LineMarker.obj & LineMarker.obj &
PropSet.obj & PropSet.obj &
RESearch.obj & RESearch.obj &