Wx-Scintilla-0.39000755001750001750 012021352777 14262 5ustar00azawawiazawawi000000000000Wx-Scintilla-0.39/wx_typemap.xsp000444001750001750 1223312021352776 17370 0ustar00azawawiazawawi000000000000############################################################################# ## Name: typemap.xsp ## Purpose: Main typemap file for xsubppp.pl ## Author: Mattia Barbon ## Modified by: ## Created: 01/03/2003 ## RCS-ID: $Id: typemap.xsp 2927 2010-06-06 08:06:10Z mbarbon $ ## Copyright: (c) 2003-2010 Mattia Barbon ## Licence: This program is free software; you can redistribute it and/or ## modify it under the same terms as Perl itself ############################################################################# %typemap{void}{simple}; %typemap{bool}{simple}; %typemap{char}{simple}; %typemap{short}{simple}; %typemap{int}{simple}; %typemap{long}{simple}; %typemap{unsigned short}{simple}; %typemap{unsigned}{simple}; %typemap{unsigned int}{simple}; %typemap{unsigned long}{simple}; %typemap{float}{simple}; %typemap{double}{simple}; %typemap{wxChar}{simple}; %typemap{SV*}{simple}; %typemap{wxDouble}{simple}; %typemap{size_t}{simple}; %typemap{time_t}{simple}; %typemap{wxUint32}{simple}; %typemap{wxByte}{simple}; %typemap{wxArrayString}{simple}; %typemap{wxArrayInt}{parsed}{ %output_list{% PUTBACK; wxPli_intarray_push( aTHX_ RETVAL ); SPAGAIN; %}; }; %typemap{const wxArrayString&}{parsed}{ %cpp_type{%wxArrayString%}; %output_list{% PUTBACK; wxPli_stringarray_push( aTHX_ RETVAL ); SPAGAIN; %}; }; %typemap{const wxArrayInt&}{parsed}{ %cpp_type{%wxArrayInt%}; %output_list{% PUTBACK; wxPli_intarray_push( aTHX_ RETVAL ); SPAGAIN; %}; }; %typemap{wxArrayInt&}{parsed}{%wxArrayInt%}; %typemap{wxWindowID}{simple}; %typemap{wxCoord}{simple}; %typemap{wxEventType}{simple}; %typemap{const wxChar*}{simple}; %typemap{PlClassName}{simple}; %typemap{wxPliUserDataCD*}{simple}; %typemap{wxPliUserDataCD**}{simple}; %typemap{wxString}{simple}; %typemap{wxString&}{parsed}{ %cpp_type{%wxString%}; }; %typemap{const wxString&}{parsed}{ %cpp_type{%wxString%}; }; %typemap{const wxRect&}{reference}; %typemap{const wxSize&}{parsed}{ %cpp_type{%wxSize%}; }; %typemap{const wxPoint&}{parsed}{ %cpp_type{%wxPoint%}; }; %typemap{const wxPosition&}{parsed}{ %cpp_type{%wxPosition%}; }; %typemap{wxSize}{parsed}{ %cpp_type{%wxSize%}; }; %typemap{wxPoint}{parsed}{ %cpp_type{%wxPoint%}; }; %typemap{wxPoint*}{simple}; %typemap{wxPosition}{parsed}{ %cpp_type{%wxPosition%}; }; %typemap{wxPosition*}{simple}; %typemap{const wxArtID&}{parsed}{ %cpp_type{%wxString%}; }; %typemap{const wxArtClient&}{parsed}{ %cpp_type{%wxString%}; }; %typemap{wxArtProvider*}{simple}; %typemap{wxArtProvider&}{reference}; %typemap{wxBitmap}{reference}; %typemap{const wxBitmap&}{reference}; %typemap{wxCursor}{reference}; %typemap{const wxCursor&}{reference}; %typemap{wxIcon}{reference}; %typemap{wxFont}{reference}; %typemap{wxFont*}{simple}; %typemap{wxAnimation*}{simple}; %typemap{wxAnimation&}{reference}; %typemap{const wxAnimation&}{reference}; %typemap{wxAnimationType}{simple}; %typemap{wxDC*}{simple}; %typemap{wxDC&}{reference}; %typemap{const wxDC&}{reference}; %typemap{wxWindowDC*}{simple}; %typemap{wxWindowDC&}{reference}; %typemap{const wxWindowDC&}{reference}; %typemap{wxMemoryDC*}{simple}; %typemap{wxMemoryDC&}{reference}; %typemap{const wxMemoryDC&}{reference}; %typemap{wxPrinterDC*}{simple}; %typemap{wxPrinterDC&}{reference}; %typemap{const wxPrinterDC&}{reference}; %typemap{const wxValidator&}{reference}; %typemap{const wxPen&}{reference}; %typemap{const wxBrush&}{reference}; %typemap{const wxFont&}{reference}; %typemap{wxDateTime*}{simple}; %typemap{wxDateTime&}{reference}; %typemap{const wxDateTime&}{reference}; %typemap{wxDateSpan*}{simple}; %typemap{wxDateSpan&}{reference}; %typemap{const wxDateSpan&}{reference}; %typemap{wxTimeSpan*}{simple}; %typemap{wxTimeSpan&}{reference}; %typemap{const wxTimeSpan&}{reference}; %typemap{wxObject*}{simple}; %typemap{wxEvtHandler*}{simple}; %typemap{wxSplitterWindow*}{simple}; %typemap{wxSplitterEvent*}{simple}; %typemap{wxWindow*}{simple}; %typemap{wxListView*}{simple}; %typemap{wxSizer*}{simple}; %typemap{wxIconBundle*}{simple}; %typemap{wxFrame*}{simple}; %typemap{wxDialog*}{simple}; %typemap{wxChoice*}{simple}; %typemap{wxTreeCtrl*}{simple}; %typemap{wxToolBarBase*}{simple}; %typemap{wxToolBar*}{simple}; %typemap{wxTextCtrl*}{simple}; %typemap{wxControl*}{simple}; %typemap{wxMenu*}{simple}; %typemap{wxKeyEvent&}{reference}; %typemap{wxColour}{reference}; %typemap{const wxColour&}{reference}; %typemap{const wxIcon&}{reference}; %typemap{const wxIconBundle&}{reference}; %typemap{const wxFont&}{reference}; %typemap{const wxRegion&}{reference}; %typemap{wxImageList*}{simple}; %typemap{wxImage*}{simple}; %typemap{wxImage&}{reference}; %typemap{wxPliInputStream}{simple}; %typemap{wxPliOutputStream}{simple}; %typemap{wxGraphicsContext*}{simple}; %typemap{wxGraphicsContext&}{reference}; %typemap{const wxGraphicsContext&}{reference}; %typemap{const wxGraphicsPath&}{reference}; %typemap{const wxGraphicsMatrix&}{reference}; %typemap{const wxGraphicsPen&}{reference}; %typemap{const wxGraphicsBrush&}{reference}; %typemap{const wxGraphicsFont&}{reference}; %typemap{wxVariant*}{simple}; %typemap{wxVariant&}{reference}; %typemap{const wxVariant&}{reference}; Wx-Scintilla-0.39/Scintilla_README000444001750001750 470012021352777 17302 0ustar00azawawiazawawi000000000000This contrib is the wxStyledTextCtrl, which is a wrapper around the Scintilla edit control. (See www.scintilla.org) There is still VERY MUCH to be done, most notable of which is a more advanced sample that exercises more of the code. (I havn't tested AutoComplete or CallTips, or most of the event types at all yet.) And also documentation, adding wrappers for some new scintilla functionality, building and testing on wxGTK, etc. Be patient, it all will get there soon. Let me describe a bit about the architecture I am implementing... Obviously there is the Platform layer which implements the varioius platform classes by using wxWindows classes and filling in where needed. Then there is a ScintillaWX class that is derived from ScintillaBase and implements the necessary virtual methods that Scintilla needs to fully funciton. This class however is not meant to ever be used directly by wx programmers. I call it one end of the bridge between the wx and Scintilla worlds. The other end of the bridge is a class called wxStyledTextCtrl that looks, feels and acts like other classes in wxWindows. Here is a diagram: +------------------+ +-------------------+ | wxStyledTextCtrl |--bridge--| ScintillaWX | +------------------+ +-------------------+ | ScintillaBase | +-------------------+ | Editor | +-------------------+ | PlatWX | +-------------------+ wxStyledTextCtrl derives from wxControl so it has a window that can be drawn upon. When a wxStyledTextCtrl is constructed it constructs a ScintillaWX for itself and passes itself to the scintilla object to be set as the wMain and wDraw attributes. All method calls on the STC are sent over the bridge in the form of calls to ScintiallWX::WndProc. All notifications are sent back over the bridge and turned into wxEvents. Robin [SOLARIS NOTE - ellers@iinet.net.au - June 2002] On sunos5 (sparc) the stc code breaks if optimisation is turned on (the default). If your release build breaks but the debug build is fine, try reconfiguring with --disable-optimise and rebuilding. If you are using wxPython you will also need to disable optimised compiling. To do this I had to hand modify the python makefile in (prefix)/lib/python2.2/config/Makefile to remove optimisation flags. Wx-Scintilla-0.39/README000444001750001750 302512021352777 15277 0ustar00azawawiazawawi000000000000Wx-Scintilla The README is used to introduce the module and provide instructions on how to install the module, any machine dependencies it may have (for example C compilers and installed libraries) and any other information that should be provided before the module is installed. A README file is required for CPAN modules since CPAN extracts the README file from a module distribution so that people browsing the archive can use it to get an idea of the module's uses. It is usually a good idea to provide version information here so that people can decide whether fixes for the module are worth downloading. INSTALLATION To install this module, run the following commands: perl Build.PL ./Build ./Build test ./Build install SUPPORT AND DOCUMENTATION After installing, you can find documentation for this module with the perldoc command. perldoc Wx::Scintilla You can also look for information at: RT, CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=Wx-Scintilla AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/Wx-Scintilla CPAN Ratings http://cpanratings.perl.org/d/Wx-Scintilla Search CPAN http://search.cpan.org/dist/Wx-Scintilla/ LICENSE AND COPYRIGHT Copyright (C) 2011 Ahmad M. Zawawi This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. Wx-Scintilla-0.39/wx_typemap000444001750001750 5546512021352777 16576 0ustar00azawawiazawawi000000000000############################################################################# ## Name: typemap ## Purpose: typemap template ## Author: Mattia Barbon ## Modified by: ## Created: 29/10/2000 ## RCS-ID: $Id: typemap 2952 2010-08-15 10:38:47Z mbarbon $ ## Copyright: (c) 2000-2010 Mattia Barbon ## Licence: This program is free software; you can redistribute it and/or ## modify it under the same terms as Perl itself ############################################################################# TYPEMAP wxFlexSizerGrowMode T_ENUM wxEdge T_ENUM wxRelationship T_ENUM wxWindowID T_WINDOWID wxStockCursor T_ENUM wxEventType T_ENUM wxCheckBoxState T_ENUM wxBitmapType T_ENUM const char * T_PV wxCoord T_IV float T_NV wxFontEncoding T_ENUM wxFontFamily T_ENUM wxFontStyle T_ENUM wxFontWeight T_ENUM wxRegionContain T_ENUM wxSashEdgePosition T_ENUM wxSashDragStatus T_ENUM wxListColumnFormat T_ENUM wxRasterOperationMode T_ENUM wxPolygonFillMode T_ENUM wxFloodFillStyle T_ENUM wxMappingMode T_ENUM off_t T_IV ResourceCat T_ENUM wxSeekMode T_ENUM WXCOLORREF T_IV EntryType T_ENUM wxKillError T_ENUM wxSignal T_ENUM wxItemKind T_ENUM wxLayoutDirection T_ENUM PlClassName T_CLASSNAME wxUint32 T_IV wxByte T_U_CHAR wxTextCtrlHitTestResult T_ENUM wxArrayString T_ARRAYSTRING wxPliUserDataCD ** T_ARRAYUSERDATA wxArrayInt T_ARRAYINT wxTextPos T_IV wxTextAttrAlignment T_ENUM wxIdleMode T_ENUM wxDouble T_DOUBLE wxAnimationType T_ENUM wxUpdateUIMode T_ENUM wxWindowVariant T_ENUM wxImageResizeQuality T_ENUM wxAlignment T_ENUM wxFindReplaceDialogStyles T_ENUM wxFindReplaceFlags T_ENUM wxBackgroundStyle T_ENUM wxSystemColour T_ENUM wxSystemFont T_ENUM wxSystemMetric T_ENUM wxSystemScreenType T_ENUM wxOrientation T_ENUM wxBatteryState T_ENUM wxPowerType T_ENUM wxDirection T_ENUM wxPenStyle T_ENUM wxPenCap T_ENUM wxPenJoin T_ENUM wxBrushStyle T_ENUM wxShowEffect T_ENUM wxDialogLayoutAdaptationMode T_ENUM wxLogTraceMask T_UV wxLogLevel T_UV wxTraceMask T_UV wxTreeItemIdValue T_UV wxTreeItemIcon T_UV wxKeyCode T_KEYCODE wxChar T_IV wxStockHelpStringClient T_ENUM wxDateTime * O_NON_WXOBJECT Wx_UserDataCD * O_USERDATACD wxPliUserDataCD * O_USERDATACD Wx_UserDataO * O_USERDATAO wxPliUserDataO * O_USERDATAO SV_null * T_SV_NULL wxClassInfo * O_NON_WXOBJECT wxPropertyInfo * O_NON_WXOBJECT const wxClassInfo * O_NON_WXOBJECT const wxPropertyInfo * O_NON_WXOBJECT const wxTypeInfo * O_NON_WXOBJECT wxTypeInfo * O_NON_WXOBJECT wxPropertyAccessor * O_NON_WXOBJECT wxTypeKind T_ENUM wxPropertyInfoFlags T_ENUM wxObject * O_WXOBJECT wxApp * O_WXOBJECT wxStandardPaths * O_NON_WXOBJECT wxWindow * O_WXOBJECT wxPlWindow * O_WXOBJECT wxPlControl * O_WXOBJECT wxFrame * O_WXOBJECT wxTopLevelWindow * O_WXOBJECT wxEvtHandler * O_WXOBJECT wxMiniFrame * O_WXOBJECT wxPopupWindow * O_WXOBJECT wxPopupTransientWindow * O_WXOBJECT wxPlPopupTransientWindow * O_WXOBJECT wxDisplay * O_NON_WXOBJECT_THR wxVideoMode * O_NON_WXOBJECT_THR wxEventBlocker * O_NON_WXOBJECT_THR wxWindowUpdateLocker * O_NON_WXOBJECT_THR wxMenuBar * O_WXOBJECT wxMenu * O_WXOBJECT wxMenuItem * O_WXOBJECT wxDirFilterListCtrl * O_WXEVTHANDLER wxDirCtrl * O_WXEVTHANDLER wxFileCtrl * O_WXEVTHANDLER wxGenericDirCtrl * O_WXEVTHANDLER wxAnimationCtrl * O_WXEVTHANDLER wxStatusBar * O_WXEVTHANDLER wxToolBar * O_WXEVTHANDLER wxToolBarBase * O_WXEVTHANDLER wxToolBarSimple * O_WXEVTHANDLER wxPanel * O_WXOBJECT wxDialog * O_WXOBJECT wxControl * O_WXOBJECT wxButton * O_WXEVTHANDLER wxStaticText * O_WXEVTHANDLER wxStaticLine * O_WXEVTHANDLER wxTextCtrl * O_WXOBJECT wxTextCtrlBase * O_WXOBJECT wxPropertySheetDialog * O_WXEVTHANDLER wxPlValidator * O_WXOBJECT wxValidator * O_WXOBJECT wxCheckBox * O_WXEVTHANDLER wxChoice * O_WXEVTHANDLER wxComboBox * O_WXEVTHANDLER wxComboCtrl * O_WXEVTHANDLER wxComboCtrlBase * O_WXEVTHANDLER wxComboPopup * O_NON_WXOBJECT wxPlComboPopup * O_NON_WXOBJECT wxOwnerDrawnComboBox * O_WXEVTHANDLER wxPlOwnerDrawnComboBox * O_WXEVTHANDLER wxControlWithItems * O_WXOBJECT wxEditableListBox * O_WXOBJECT wxListBox * O_WXEVTHANDLER wxStaticBox * O_WXEVTHANDLER wxRadioButton * O_WXEVTHANDLER wxRadioBox * O_WXEVTHANDLER wxScrollBar * O_WXEVTHANDLER wxNotebook * O_WXEVTHANDLER wxBookCtrl * O_WXEVTHANDLER wxBookCtrlBase * O_WXEVTHANDLER wxCheckListBox * O_WXEVTHANDLER wxGauge * O_WXEVTHANDLER wxBitmapButton * O_WXEVTHANDLER wxTreeCtrl * O_WXOBJECT wxListCtrl * O_WXOBJECT wxListView * O_WXEVTHANDLER wxStaticBitmap * O_WXEVTHANDLER wxSpinButton * O_WXEVTHANDLER wxSpinCtrl * O_WXEVTHANDLER wxSpinCtrlDouble * O_WXEVTHANDLER wxSlider * O_WXEVTHANDLER wxScrolledWindow * O_WXOBJECT wxVScrolledWindow * O_WXEVTHANDLER wxHScrolledWindow * O_WXEVTHANDLER wxHVScrolledWindow * O_WXEVTHANDLER wxPlVScrolledWindow * O_WXEVTHANDLER wxPlHScrolledWindow * O_WXEVTHANDLER wxPlHVScrolledWindow * O_WXEVTHANDLER wxVListBox * O_WXEVTHANDLER wxPlVListBox * O_WXEVTHANDLER wxSplitterWindow * O_WXEVTHANDLER wxSearchCtrl * O_WXEVTHANDLER wxSashWindow * O_WXEVTHANDLER wxToggleButton * O_WXEVTHANDLER wxBitmapToggleButton * O_WXEVTHANDLER wxSplashScreen * O_WXOBJECT wxSplashScreenWindow * O_WXOBJECT wxListbook * O_WXEVTHANDLER wxChoicebook * O_WXEVTHANDLER wxToolbook * O_WXEVTHANDLER wxTreebook * O_WXEVTHANDLER wxHyperlinkCtrl * O_WXEVTHANDLER wxPickerBase * O_WXEVTHANDLER wxColourPickerCtrl * O_WXEVTHANDLER wxFilePickerCtrl * O_WXEVTHANDLER wxDirPickerCtrl * O_WXEVTHANDLER wxFontPickerCtrl * O_WXEVTHANDLER wxCollapsiblePane * O_WXEVTHANDLER wxBitmapComboBox * O_WXEVTHANDLER wxInfoBar * O_WXEVTHANDLER wxHeaderCtrl * O_WXEVTHANDLER wxPlHeaderCtrl * O_WXEVTHANDLER wxHeaderCtrlSimple * O_WXEVTHANDLER wxHeaderColumn * O_NON_WXOBJECT_THR wxSettableHeaderColumn * O_NON_WXOBJECT_THR wxHeaderColumnSimple * O_NON_WXOBJECT_THR wxPlHeaderColumn * O_NON_WXOBJECT_SELF wxPlSettableHeaderColumn * O_NON_WXOBJECT_SELF wxWizard * O_WXOBJECT wxWizardPage * O_WXOBJECT wxWizardPageSimple * O_WXOBJECT wxColourDialog * O_WXOBJECT wxFileDialog * O_WXOBJECT wxDirDialog * O_NON_WXOBJECT wxNumberEntryDialog * O_WXOBJECT wxMultiChoiceDialog * O_WXOBJECT wxSingleChoiceDialog * O_WXOBJECT wxMultipleChoiceDialog* O_WXOBJECT wxTextEntryDialog * O_WXOBJECT wxPasswordEntryDialog * O_WXOBJECT wxFontDialog * O_WXOBJECT wxPageSetupDialog * O_WXOBJECT wxPrintDialog * O_WXOBJECT wxMessageDialog * O_WXOBJECT wxProgressDialog * O_WXOBJECT wxFindReplaceDialog * O_WXOBJECT wxPropertySheetDialog * O_WXOBJECT wxFindReplaceData * O_NON_WXOBJECT wxColourData * O_WXOBJECT_THR wxFontData * O_WXOBJECT_THR wxSizer * O_WXOBJECT wxPlSizer * O_WXOBJECT wxBoxSizer * O_WXOBJECT wxStaticBoxSizer * O_WXOBJECT wxNotebookSizer * O_WXOBJECT wxGridSizer * O_WXOBJECT wxFlexGridSizer * O_WXOBJECT wxSizerItem * O_WXOBJECT wxGridBagSizer * O_WXOBJECT wxGBPosition * O_NON_WXOBJECT wxGBSpan * O_NON_WXOBJECT wxGBPosition O_GBPOSITION wxGBSpan O_GBSPAN wxGBPosition & O_GBPOSITION wxGBSpan & O_GBSPAN wxGBSizerItem * O_WXOBJECT wxStdDialogButtonSizer * O_WXOBJECT wxWrapSizer * O_WXOBJECT wxDC * O_WXOBJECT_THR wxMemoryDC * O_WXOBJECT_THR wxPrinterDC * O_WXOBJECT_THR wxWindowDC * O_WXOBJECT_THR wxClientDC * O_WXOBJECT_THR wxPaintDC * O_WXOBJECT_THR wxScreenDC * O_WXOBJECT_THR wxBufferedDC * O_WXOBJECT_THR wxBufferedPaintDC * O_WXOBJECT_THR wxAutoBufferedPaintDC * O_WXOBJECT_THR wxMirrorDC * O_WXOBJECT_THR wxSVGFileDC * O_WXOBJECT_THR wxGCDC * O_WXOBJECT_THR wxOverlay * O_NON_WXOBJECT_THR wxDCOverlay * O_NON_WXOBJECT_THR wxDCClipper * O_NON_WXOBJECT_THR wxTaskBarIcon * O_WXOBJECT wxNotificationMessage * O_NON_WXOBJECT_THR wxTextAttr * O_NON_WXOBJECT_THR wxLog * O_NON_WXOBJECT wxLogTextCtrl * O_NON_WXOBJECT wxLogNull * O_NON_WXOBJECT_THR wxLogGui * O_NON_WXOBJECT wxLogWindow * O_NON_WXOBJECT wxLogChain * O_NON_WXOBJECT wxLogPassThrough * O_NON_WXOBJECT wxLogStderr * O_NON_WXOBJECT wxPlLog * O_NON_WXOBJECT wxPlLogPassThrough * O_NON_WXOBJECT wxLocale * O_NON_WXOBJECT_THR wxLanguageInfo * O_NON_WXOBJECT_THR const wxLanguageInfo * O_NON_WXOBJECT_THR wxStopWatch * O_NON_WXOBJECT_THR wxAboutDialogInfo * O_NON_WXOBJECT wxPoint O_POINT wxSize O_SIZE wxPosition O_POSITION wxColour O_NON_WXOBJECT_VAL wxPoint & O_POINT wxSize & O_SIZE wxPosition & O_POSITION wxColour & O_NON_WXOBJECT_VAL wxVariant* O_NON_WXOBJECT_THR wxVariant O_VARIANT wxProcess * O_WXOBJECT wxSound * O_NON_WXOBJECT_THR wxTipProvider * O_NON_WXOBJECT wxDrawObject * O_NON_WXOBJECT wxSize * O_NON_WXOBJECT_THR wxPoint * O_NON_WXOBJECT_THR wxRect * O_NON_WXOBJECT_THR wxPosition * O_NON_WXOBJECT_THR wxColour * O_NON_WXOBJECT_THR wxCaret * O_NON_WXOBJECT wxCaretSuspend * O_NON_WXOBJECT_THR wxWindowDisabler * O_NON_WXOBJECT_THR wxBusyCursor * O_NON_WXOBJECT_THR wxBusyInfo * O_NON_WXOBJECT_THR wxLayoutConstraints * O_WXOBJECT wxIndividualLayoutConstraint * O_WXOBJECT wxDropTarget * O_NON_WXOBJECT wxListItem * O_NON_WXOBJECT_THR wxListItemAttr * O_NON_WXOBJECT_THR wxPliTreeItemData * O_NON_WXOBJECT wxTreeItemData * O_NON_WXOBJECT wxTreeItemId * O_NON_WXOBJECT_THR wxAnimation * O_WXOBJECT_THR wxFontMapper * O_NON_WXOBJECT wxFontEnumerator * O_NON_WXOBJECT_THR wxNativeFontInfo * O_NON_WXOBJECT_THR wxFont * O_WXOBJECT_THR wxRegion * O_WXOBJECT_THR wxIcon * O_WXOBJECT_THR wxIconBundle * O_NON_WXOBJECT wxIconLocation * O_NON_WXOBJECT wxBitmap * O_WXOBJECT_THR wxCursor * O_WXOBJECT_THR const wxCursor * O_WXOBJECT_THR wxToolTip * O_WXOBJECT wxPen * O_WXOBJECT_THR wxMask * O_WXOBJECT wxBrush * O_WXOBJECT_THR wxBitmapHandler * O_WXOBJECT wxPalette * O_WXOBJECT_THR wxMimeTypesManager * O_NON_WXOBJECT_THR wxFileType * O_NON_WXOBJECT wxFileTypeInfo * O_NON_WXOBJECT wxImage * O_WXOBJECT_THR wxImageHandler * O_WXOBJECT wxBMPHandler * O_WXOBJECT wxGIFHandler * O_WXOBJECT wxPCXHandler * O_WXOBJECT wxPNMHandler * O_WXOBJECT wxTIFFHandler * O_WXOBJECT wxJPEGHandler * O_WXOBJECT wxPNGHandler * O_WXOBJECT wxXPMHandler * O_WXOBJECT wxIFFHandler * O_WXOBJECT wxICOHandler * O_WXOBJECT wxCURHandler * O_WXOBJECT wxANIHandler * O_WXOBJECT wxTGAHandler * O_WXOBJECT wxImageList * O_WXOBJECT_THR wxToolBarToolBase * O_NON_WXOBJECT wxAcceleratorEntry * O_NON_WXOBJECT_THR wxAcceleratorTable * O_WXOBJECT_THR wxTimer * O_WXOBJECT wxSingleInstanceChecker * O_NON_WXOBJECT_THR wxWave * O_NON_WXOBJECT wxGraphicsRenderer * O_WXOBJECT wxGraphicsBrush * O_WXOBJECT_THR wxGraphicsContext * O_WXOBJECT_THR wxGraphicsFont * O_WXOBJECT_THR wxGraphicsMatrix * O_WXOBJECT_THR wxGraphicsObject * O_WXOBJECT_THR wxGraphicsPath * O_WXOBJECT_THR wxGraphicsPen * O_WXOBJECT_THR wxGraphicsGradientStop * O_NON_WXOBJECT_THR wxGraphicsGradientStops * O_NON_WXOBJECT_THR # events wxEvent * O_WXOBJECT_THR wxActivateEvent * O_WXOBJECT_THR wxBookCtrlEvent * O_WXOBJECT_THR wxClipboardTextEvent * O_WXOBJECT_THR wxCloseEvent * O_WXOBJECT_THR wxCommandEvent * O_WXOBJECT_THR wxContextMenuEvent * O_WXOBJECT_THR wxEraseEvent * O_WXOBJECT_THR wxFindDialogEvent * O_WXOBJECT_THR wxFocusEvent * O_WXOBJECT_THR wxFileCtrlEvent * O_WXOBJECT_THR wxKeyEvent * O_WXOBJECT_THR wxHelpEvent * O_WXOBJECT_THR wxIconizeEvent * O_WXOBJECT_THR wxIdleEvent * O_WXOBJECT_THR wxInitDialogEvent * O_WXOBJECT_THR wxJoystickEvent * O_WXOBJECT_THR wxListbookEvent * O_WXOBJECT_THR wxListEvent * O_WXOBJECT_THR wxMaximizeEvent * O_WXOBJECT_THR wxMenuEvent * O_WXOBJECT_THR wxMouseCaptureChangedEvent * O_WXOBJECT_THR wxMouseCaptureLostEvent * O_WXOBJECT_THR wxMouseEvent * O_WXOBJECT_THR wxMoveEvent * O_WXOBJECT_THR wxNotebookEvent * O_WXOBJECT_THR wxNotifyEvent * O_WXOBJECT_THR wxPaintEvent * O_WXOBJECT_THR wxQueryLayoutInfo * O_WXOBJECT_THR wxSashEvent * O_WXOBJECT_THR wxSizeEvent * O_WXOBJECT_THR wxScrollEvent * O_WXOBJECT_THR wxScrollWinEvent * O_WXOBJECT_THR wxSpinEvent * O_WXOBJECT_THR wxSplitterEvent * O_WXOBJECT_THR wxSetCursorEvent * O_WXOBJECT_THR wxSysColourChangedEvent * O_WXOBJECT_THR wxTaskBarIconEvent * O_WXOBJECT_THR wxTimerEvent * O_WXOBJECT_THR wxTreeEvent * O_WXOBJECT_THR wxUpdateUIEvent * O_WXOBJECT_THR wxTextUrlEvent * O_WXOBJECT_THR wxProcessEvent * O_WXOBJECT_THR wxWizardEvent * O_WXOBJECT_THR wxTreebookEvent * O_WXOBJECT_THR wxNavigationKeyEvent * O_WXOBJECT_THR wxChildFocusEvent * O_WXOBJECT_THR wxHyperlinkEvent * O_WXOBJECT_THR wxPowerEvent * O_WXOBJECT_THR wxColourPickerEvent * O_WXOBJECT_THR wxFileDirPickerEvent * O_WXOBJECT_THR wxFontPickerEvent * O_WXOBJECT_THR wxWindowCreateEvent * O_WXOBJECT_THR wxWindowDestroyEvent * O_WXOBJECT_THR wxCollapsiblePaneEvent * O_WXOBJECT_THR wxHeaderCtrlEvent * O_WXOBJECT_THR wxPlEvent * O_WXOBJECT_THR wxPlCommandEvent * O_WXOBJECT_THR wxPlThreadEvent * O_WXOBJECT_THR wxConfigBase * O_NON_WXOBJECT wxConfig * O_NON_WXOBJECT wxFileConfig * O_NON_WXOBJECT wxArtProvider * O_WXOBJECT wxPlArtProvider * O_WXOBJECT OUTPUT O_WXOBJECT wxPli_object_2_sv( aTHX_ $arg, $var ); O_WXOBJECT_THR wxPli_object_2_sv( aTHX_ $arg, $var ); wxPli_thread_sv_register( aTHX_ ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt}, $var, $arg ); O_WXEVTHANDLER wxPli_evthandler_2_sv( aTHX_ $arg, $var ); O_WXCLIENTDATACONTAINER wxPli_clientdatacontainer_2_sv( aTHX_ $arg, $var, ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); O_WXCLIENTDATACONTAINER_THR_SV wxPli_clientdatacontainer_2_sv( aTHX_ $arg, $var, ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); wxPli_thread_sv_register( aTHX_ ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt}, SvRV( $arg ), $arg ); O_NON_WXOBJECT wxPli_non_object_2_sv( aTHX_ $arg, $var, ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); O_NON_WXOBJECT_THR wxPli_non_object_2_sv( aTHX_ $arg, $var, ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); wxPli_thread_sv_register( aTHX_ ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt}, $var, $arg ); O_NON_WXOBJECT_THR_SV wxPli_non_object_2_sv( aTHX_ $arg, $var, ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); wxPli_thread_sv_register( aTHX_ ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt}, SvRV( $arg ), $arg ); O_SIZE wxPli_non_object_2_sv( aTHX_ $arg, new $type($var), ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); O_GBPOSITION wxPli_non_object_2_sv( aTHX_ $arg, new $type($var), ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); O_GBSPAN wxPli_non_object_2_sv( aTHX_ $arg, new $type($var), ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); O_POINT wxPli_non_object_2_sv( aTHX_ $arg, new $type($var), ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); O_POSITION wxPli_non_object_2_sv( aTHX_ $arg, new $type($var), ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); T_KEYCODE sv_setiv( $arg, $var ); T_UV sv_setuv( $arg, (UV)$var ); INPUT O_WXOBJECT $var = (${(my $t=$type)=~s/^Wx_/wx/;\$t}) wxPli_sv_2_object( aTHX_ $arg, ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); O_WXOBJECT_THR $var = (${(my $t=$type)=~s/^Wx_/wx/;\$t}) wxPli_sv_2_object( aTHX_ $arg, ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); O_WXEVTHANDLER $var = (${(my $t=$type)=~s/^Wx_/wx/;\$t}) wxPli_sv_2_object( aTHX_ $arg, ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); O_WXCLIENTDATACONTAINER $var = (${(my $t=$type)=~s/^Wx_/wx/;\$t}) wxPli_sv_2_object( aTHX_ $arg, ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); O_WXCLIENTDATACONTAINER_THR_SV $var = (${(my $t=$type)=~s/^Wx_/wx/;\$t}) wxPli_sv_2_object( aTHX_ $arg, ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); O_NON_WXOBJECT $var = (${(my $t=$type)=~s/^Wx_/wx/;\$t}) wxPli_sv_2_object( aTHX_ $arg, ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); O_NON_WXOBJECT_VAL $var = *($type *) wxPli_sv_2_object( aTHX_ $arg, ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); O_NON_WXOBJECT_THR $var = (${(my $t=$type)=~s/^Wx_/wx/;\$t}) wxPli_sv_2_object( aTHX_ $arg, ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); O_NON_WXOBJECT_THR_SV $var = (${(my $t=$type)=~s/^Wx_/wx/;\$t}) wxPli_sv_2_object( aTHX_ $arg, ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); O_POINT $var = wxPli_sv_2_wxpoint( aTHX_ $arg ); O_SIZE $var = wxPli_sv_2_wxsize( aTHX_ $arg ); O_POSITION $var = wxPli_sv_2_wxposition( aTHX_ $arg ); O_GBPOSITION $var = wxPli_sv_2_wxgbposition( aTHX_ $arg ); O_GBSPAN $var = wxPli_sv_2_wxgbspan( aTHX_ $arg ); T_KEYCODE $var = wxPli_sv_2_keycode( aTHX_ $arg ); T_UV $var = ($type)SvUV( $arg ); T_CLASSNAME $var = wxPli_get_class( aTHX_ $arg ); O_VARIANT $var = wxPli_sv_2_wxvariant( aTHX_ $arg ); # # Wx_UserData* # INPUT O_USERDATACD if( SvOK( $arg ) ) { $var = new wxPliUserDataCD( $arg ); } else $var = 0; O_USERDATAO if( SvOK( $arg ) ) { $var = new wxPliUserDataO( $arg ); } else $var = 0; OUTPUT O_USERDATACD $arg = ( $var == 0 ) ? &PL_sv_undef : $var->GetData(); SvREFCNT_inc( $arg ); // xsubpp mortalizes it... O_USERDATAO $arg = ( $var == 0 ) ? &PL_sv_undef : $var->GetData(); SvREFCNT_inc( $arg ); // xsubpp mortalizes it... # # Objects with a self reference # INPUT O_NON_WXOBJECT_SELF $var = (${(my $t=$type)=~s/^Wx_/wx/;\$t}) wxPli_sv_2_object( aTHX_ $arg, ${(my $ntt=$ntype)=~s/^(?:const\s+)?(?:Wx_|wx)(.*?)(?:Ptr)?$/$1/g;$ntt=qq{\"Wx::$ntt\"};\$ntt} ); OUTPUT O_NON_WXOBJECT_SELF $arg = ( $var == 0 ) ? &PL_sv_undef : $var->GetSelf(); SvREFCNT_inc( $arg ); // xsubpp mortalizes it... # # SV_null # INPUT T_SV_NULL $var = SvOK( $arg ) ? $arg : 0; OUTPUT T_SV_NULL $arg = ( $var == 0 ) ? &PL_sv_undef : $var; SvREFCNT_inc( $arg ); // xsubpp mortalizes it... # # streams # TYPEMAP wxPliInputStream S_PL_ISTREAM wxPliOutputStream S_PL_OSTREAM wxInputStream * S_WX_ISTREAM wxOutputStream * S_WX_OSTREAM Wx_InputStream * O_NON_WXOBJECT Wx_OutputStream * O_NON_WXOBJECT INPUT S_PL_ISTREAM wxPli_sv_2_istream( aTHX_ $arg, $var ); S_PL_OSTREAM wxPli_sv_2_ostream( aTHX_ $arg, $var ); OUTPUT S_WX_ISTREAM wxPli_stream_2_sv( aTHX_ $arg, $var, "Wx::InputStream" ); S_WX_OSTREAM wxPli_stream_2_sv( aTHX_ $arg, $var, "Wx::OutputStream" ); # Unicode support TYPEMAP wxChar * T_WXCHAR const wxChar* T_CONST_WXCHAR wxString T_WXSTRING INPUT T_WXCHAR WXCHAR_INPUT( $var, wxChar*, $arg ); T_CONST_WXCHAR WXCHAR_INPUT( $var, wxChar*, $arg ); T_WXSTRING WXSTRING_INPUT( $var, $type, $arg ); OUTPUT T_WXCHAR WXCHAR_OUTPUT( $var, $arg ); T_CONST_WXCHAR WXCHAR_OUTPUT( $var, $arg ); T_WXSTRING WXSTRING_OUTPUT( $var, $arg ); # typemap for window ID INPUT T_WINDOWID $var = wxPli_get_wxwindowid( aTHX_ $arg ); OUTPUT T_WINDOWID sv_setiv($arg, (IV)$var); INPUT T_ARRAYSTRING wxPli_av_2_arraystring( aTHX_ $arg, & $var ); INPUT T_ARRAYINT wxPli_av_2_arrayint( aTHX_ $arg, & $var ); INPUT T_ARRAYUSERDATA wxPli_av_2_userdatacdarray( aTHX_ $arg, & $var ); wxPliArrayGuard guard_$var = $var;Wx-Scintilla-0.39/Build.PL000444001750001750 272012021352777 15714 0ustar00azawawiazawawi000000000000use 5.006; use strict; use lib 'inc'; require Module::Build::Scintilla; # Create build script Module::Build::Scintilla::stc_builderclass()->new( module_name => 'Wx::Scintilla', license => 'perl', dist_author => q{Ahmad M. Zawawi }, dist_version_from => 'lib/Wx/Scintilla.pm', configure_requires => { 'perl' => '5.006', 'Module::Build' => '0.36', }, build_requires => { 'Test::More' => 0, 'Alien::wxWidgets' => 0, 'Wx' => 0, 'ExtUtils::XSpp' => '0.1602', }, requires => { 'perl' => '5.008', }, needs_compiler => 0, # We will be doing our own XS compilation add_to_cleanup => [ 'Wx-Scintilla-*', 'wx-scintilla/src/*.o.d', 'wx-scintilla/src/*.o', 'wx-scintilla/src/*.obj', 'wx-scintilla/src/scintilla/src/*.o.d', 'wx-scintilla/src/scintilla/src/*.o', 'wx-scintilla/src/scintilla/src/*.obj', 'Scintilla.c', 'Scintilla.o', 'Scintilla.obj', 'Scintilla.bs', 'Scintilla.def', 'Scintilla_def.old', 'blib', '*.dll', '*.pdb', '*.obj', '*.a', '*.so', 'stc_checkdepends.out', ], meta_merge => { resources => { homepage => 'http://padre.perlide.org/', repository => 'http://svn.perlide.org/padre/trunk/Wx-Scintilla/', }, no_index => { directory => [qw], }, }, dist_abstract => 'Scintilla source code editing for wxWidgets', extra_linker_flags => '-lwxmsw28u_scintilla', )->create_build_script(); Wx-Scintilla-0.39/typemap000444001750001750 21312021352777 15775 0ustar00azawawiazawawi000000000000## Scintilla typemap TYPEMAP wxDragResult T_ENUM wxScintillaTextCtrl * O_WXOBJECT wxScintillaTextEvent * O_WXOBJECT Wx-Scintilla-0.39/META.json000444001750001750 375012021352777 16045 0ustar00azawawiazawawi000000000000{ "abstract" : "Scintilla source code editing for wxWidgets", "author" : [ "Ahmad M. Zawawi " ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.4003, CPAN::Meta::Converter version 2.120921", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Wx-Scintilla", "no_index" : { "directory" : [ "tools", "wx-scintilla", "cpp", "inc" ] }, "prereqs" : { "build" : { "requires" : { "Alien::wxWidgets" : "0", "ExtUtils::XSpp" : "0.1602", "Test::More" : "0", "Wx" : "0" } }, "configure" : { "requires" : { "Module::Build" : "0.36", "perl" : "5.006" } }, "runtime" : { "requires" : { "perl" : "5.008" } } }, "provides" : { "Wx::Scintilla" : { "file" : "lib/Wx/Scintilla.pm", "version" : "0.39" }, "Wx::Scintilla::Constant" : { "file" : "lib/Wx/Scintilla/Constant.pm", "version" : "0.39" }, "Wx::Scintilla::TextCtrl" : { "file" : "lib/Wx/Scintilla/TextCtrl.pm", "version" : "0.39" }, "Wx::Scintilla::TextEvent" : { "file" : "lib/Wx/Scintilla/TextEvent.pm", "version" : "0.39" }, "Wx::ScintillaTextCtrl" : { "file" : "lib/Wx/Scintilla.pm", "version" : "0.39" }, "Wx::ScintillaTextEvent" : { "file" : "lib/Wx/Scintilla.pm", "version" : "0.39" } }, "release_status" : "stable", "resources" : { "homepage" : "http://padre.perlide.org/", "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "url" : "http://svn.perlide.org/padre/trunk/Wx-Scintilla/" } }, "version" : "0.39" } Wx-Scintilla-0.39/META.yml000444001750001750 231012021352777 15664 0ustar00azawawiazawawi000000000000--- abstract: 'Scintilla source code editing for wxWidgets' author: - 'Ahmad M. Zawawi ' build_requires: Alien::wxWidgets: 0 ExtUtils::XSpp: 0.1602 Test::More: 0 Wx: 0 configure_requires: Module::Build: 0.36 perl: 5.006 dynamic_config: 1 generated_by: 'Module::Build version 0.4003, CPAN::Meta::Converter version 2.120921' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Wx-Scintilla no_index: directory: - tools - wx-scintilla - cpp - inc provides: Wx::Scintilla: file: lib/Wx/Scintilla.pm version: 0.39 Wx::Scintilla::Constant: file: lib/Wx/Scintilla/Constant.pm version: 0.39 Wx::Scintilla::TextCtrl: file: lib/Wx/Scintilla/TextCtrl.pm version: 0.39 Wx::Scintilla::TextEvent: file: lib/Wx/Scintilla/TextEvent.pm version: 0.39 Wx::ScintillaTextCtrl: file: lib/Wx/Scintilla.pm version: 0.39 Wx::ScintillaTextEvent: file: lib/Wx/Scintilla.pm version: 0.39 requires: perl: 5.008 resources: homepage: http://padre.perlide.org/ license: http://dev.perl.org/licenses/ repository: http://svn.perlide.org/padre/trunk/Wx-Scintilla/ version: 0.39 Wx-Scintilla-0.39/Changes000444001750001750 3527612021352776 15746 0ustar00azawawiazawawi000000000000Revision history for Wx-Scintilla 0.39 2012.9.4 - Build fixes for MSVC on Windows and OSX (MARKD) - Fix 2.9.4 build on Linux (MARKD) - Fixes for expanded Config values (MARKD) - Removed unused vars from inc/Module/Build/Scintilla.pm - build_xs (MARKD) 0.3801 2012.3.26 - Added MoveSelectedLinesUp and MoveSelectedLinesDown (AZAWAWI) 0.38 2012.3.12 - Released 0.37_06 as stable 0.38 (AZAWAWI) 0.37_06 2012.3.9 - Updated Wx::Scintilla::Constant (AZAWAWI) - In MacOSX, include CoreFoundation when doing a cocoa build (MARKD) - Better determination of wxWidgets architectures (MARKD) - Fix for Lion users who recently upgraded to Xcode 4.3 (MARKD) 0.37_05 2012.3.8 - Wrap STC specific implementations of LineUp / LineDown. This should move the caret one line up or down (MARKD). - Updated to Scintilla 3.0.4 (AZAWAWI): - ECL lexer added. - CPP lexer fixes styling after document comment keywords. - Pascal folder improves handling of some constructs. - XML lexer avoids entering a bad mode due to complex preprocessor instructions. - Duplicate command is always remembered as a distinct command for undo. - Fix bug where setting an indicator for the whole document would fail. - Crash fixed for SCI_MOVESELECTEDLINESDOWN with empty vertical selection. - Fractional widths used for line numbers, character markers and other situations. - RGBA markers are drawn centred when taller than line. - Image marker drawing problem fixed for markers taller than line. - Markers are drawn horizontally off-centre based on margin type instead of dimensions. - Fold tail markers drawn vertically centred. - Fixed problems with multiple clicks in margin and with mouse actions combined with virtual space. - Fixed bug with using page up and down and not returning to original line. - Down arrow with wrapped text no longer skips lines. - Fix problem with dwell ending immediately due to word wrap. - Wrapped lines are rewrapped more consistently while resizing window. - Selected line ends are highlighted more consistently. - Redrawing reduced for some marker calls. - No more CPAN indexing of inc directory (AZAWAWI) 0.37_04 2012.2.6 - Fixed linking issue with 0.37_03 (AZAWAWI) 0.37_03 2012.2.6 - Minor update to Wx::Scintilla::Constant (AZAWAWI) 0.37_02 2012.2.6 - Updated to Scintilla 3.0.3 (AZAWAWI): - Scintilla 3.0.3 is a minor bug fix release. - Fractional character positioning was extended to more areas. - Lexers were added for the AviSynth and Take Command languages and the CSS lexer was extended to support SCSS. 0.37_01 2011.12.22 - Updated wx-scintilla\src\scintilla\README.txt to fix packaging issues (AZAWAWI) 0.36 2011.12.21 - Released 0.33_05 as stable 0.36 (AZAWAWI) 0.35_05 2011.12.11 - Upgraded to Scintilla 3.0.2 (AZAWAWI) 0.35_04 2011.11.14 - Fix SurfaceImpl::Polygon drawing bug that caused some markers to not be drawn at all. This was introduced in 0.35_01 (AZAWAWI) 0.35_03 2011.11.13 - Updated Scintilla to 3.0.1 pre-release (AZAWAWI). Relevant changes are: - Highlight "else" as a keyword for TCL in the same way as other languages. - Ensure pixmaps allocated before painting as there was a crash when Scintilla drew without common initialisation calls. 0.35_02 2011.11.3 - Fixed bold font bug reported by Kevin Dawson [BOWTIE] (AZAWAWI) 0.35_01 2011.11.2 - Wx::ScintillaTextCtrl -> Wx::Scintilla::TextCtrl in tools/ (AZAWAWI) - Upgrade to Scintilla 3.0 (AZAWAWI). The following are the related changes: - Paletted display support removed. - New API to see if all lines are visible which can be used to optimize processing fold structure notifications. - Scrolling optimized by avoiding invalidation of fold margin when redrawing whole window. - Optimized SCI_MARKERNEXT. - C++ lexer supports Pike hash quoted strings when turned on with lexer.cpp.hashquoted.strings. - Fixed incorrect line height with annotations in wrapped mode when there are multiple views. Bug #3388159. - Calltips may be displayed above the text as well as below. Bug #3410830. 0.34 2011.11.2 - Released 0.33_03 as stable 0.34 (AZAWAWI) 0.33_03 2011.11.2 Fixed 0.33_02 regressions regarding Wx constants support (AZAWAWI) 0.33_02 2011.11.2 ** BAD RELEASE ** - Removed wxSTC_CMD_ internal constants and CmdKeyExecute method (AZAWAWI) - Removed unused st_constants.cpp (AZAWAWI) - Fixed tests, tools and SYNOPSIS to fully use Wx::Scintilla constants (AZAWAWI) 0.33_01 2011.11.2 - Moved Wx::ScintillaTextCtrl to Wx::Scintilla::TextCtrl (ADAMK) - Moved Wx::ScintillaTextEvent to Wx::Scintilla::TextEvent (ADAMK) - Moved Wx::Event::EVT_STC_XXXXXX to Wx::Scintilla::EVT_XXXXXX (ADAMK) - Generate Wx::Scintilla::Constant that contains the same Scintilla constant names along with their POD documentation from Scintilla.iface (AZAWAWI) - Add $VERSION to all modules (ADAMK) - Add use 5.008 to all modules (ADAMK) - Added 'Meta: no_index' for 'tools', 'cpp' and 'wx-scintilla' directories (DOLMEN) 0.32 2011.10.11 - Released 0.31_02 as stable 0.32 (AZAWAWI) 0.31_02 2011.10.11 - Wx::Scintilla contains now Wx::wxSTC_XYZ as Wx::Scintilla::XYZ constants (AZAWAWI) 0.31_01 2011.10.9 - Croak about deprecated EVT_STC_POSCHANGED (SUBMERSIBLE_TOASTER, AZAWAWI) - Fix ticket:1341 'Wx-Scintilla build fails on wxWidgets 2.8.10' (MARKD) 0.30 2011.9.18 - Released 0.29_03 as stable 0.30 (AZAWAWI) 0.29_03 2011.9.17 - Updated to Scintilla 2.29 released on 16th September 2011 (AZAWAWI): - LaTeX lexer improved with more states and fixes to most outstanding bugs. Bug #1493111. Bug #1856356. Bug #3081692. - Lua lexer updates for Lua 5.2 beta with goto labels and "\z" string escape. - Perl string styling highlights interpolated variables. - Perl lexer updated for Perl 5.14.0 with 0X and 0B numeric literal prefixes, break keyword and "+" supported in subroutine prototypes. - Perl bug fixed with CRLF line endings. - Markdown lexer fixed to not change state with "_" in middle of word. - Mouse pointer changes over selection to an arrow near start when scrolled horizontally. - Indicators that finish at the end of the document no longer expand when text is appended. - On Windows, autocompletion lists will scroll instead of document when mouse wheel spun. 0.29_02 2011.9.14 - More missing wxSTC indicator constants: wxSTC_INDIC_DASH, wxSTC_INDIC_DOTS, wxSTC_INDIC_DOTBOX, wxSTC_INDIC_STRAIGHTBOX (AZAWAWI) - Add missing SetEmptySelection to remove any selection and sets the caret at position without scrolling into view (AZAWAWI) 0.29_01 2011.9.11 - Updated to Scintilla 2.29 prerelease (AZAWAWI) 0.28 2011.9.10 - Released 0.27_01 as stable 0.28 (AZAWAWI) 0.27_01 2011.9.8 - Fixed ExtUtils::Parse 3.03_02+ warnings about missing 'OUTPUT: RETVAL' sections (AZAWAWI) 0.26 2011.9.8 - Released 0.23_01 as stable 0.24 (AZAWAWI) - Fix RT #70662: cpanm Wx::Scintilla fails on Ubuntu Lucid by requiring ExtUtils::XSpp 0.1602 (KAARE, AZAWAWI) - Drop Makefile.PL generation in Build.PL (AZAWAWI) 0.25_03 2011.9.7 - Removed stale yellowbrain.com parsed POD documentation (AZAWAWI) - wxSTC_ANNOTATION_BOXED border was not being drawn (AZAWAWI) 0.25_02 2011.9.6 - Exposed annotations API (AZAWAWI) 0.25_01 2011.8.29 - Exposed wxEVT_STC_INDICATOR_CLICK, wxEVT_STC_INDICATOR_RELEASE, wxEVT_STC_AUTOCOMP_CANCELLED and wxEVT_STC_AUTOCOMP_CHAR_DELETED events (AZAWAWI) - Cleaned up the source code from unused SWIG defines (AZAWAWI) - Expose Scintilla's modern indicator API (AZAWAWI) 0.24 2011.8.29 - Released 0.23_01 as stable 0.24 (AZAWAWI) 0.23_01 2011.8.21 - Updated the string variable interpolation Perl lexer to the latest (KHMAN, AZAWAWI) 0.22 2011.8.17 - 0.21_08 is now released as stable 0.22 to the *unsuspecting* world (AZAWAWI) 0.21_08 2011.8.17 - The following variable interpolation patterns are now highlighted correctly (KHMAN, AZAWAWI): ${word} @{word} and things like $${word} $#{word} @#{word} and things like $#${word} ${digit} @{digit} $$ and most special variables with operator characters $0 to $9 and things like $123 $^A and other control character special variables 0.21_07 2011.8.16 - Added variable interpolation for here-docs (KHMAN, AZAWAWI) 0.21_06 2011.8.15 - Added variable interpolation for: "" qq{} `` qx{} // m{} qr{} s{}{} (KHMAN, AZAWAWI) - Fix build failure on wxWidgets 2.8.10 (MARKD, AZAWAWI) 0.21_05 2011.8.12 - Integrated Perl variable interpolation patch by Kein-Hong Man from Scintilla interest group (KHMAN, AZAWAWI) 0.21_04 2011.8.9 - The rebirth of the experimental Perl 6 lexer (AZAWAWI) - Expose IndicatorSetAlpha, IndicatorGetAlpha, IndicatorSetUnder and IndicatorGetUnder (AZAWAWI) - Fixed a drawing bug for transparent boxed indicators (AZAWAWI,Reported by ADAMK) 0.21_03 2011.8.3 - Test and install Module::Build actions invoke build first (AZAWAWI) - Build or link like make *only* when one of the output files is not up to date (AZAWAWI) 0.21_02 2011.8.2 - Fix OSX compilation error (TOME++) - Updated editor.pl to include the perl 5.10 // scintilla test (AZAWAWI) 0.21_01 2011.8.2 - Upgraded to Scintilla 2.28 which was released on 1st August 2011 (AZAWAWI) - Switched to building Scintilla 2.x by default (AZAWAWI) - Removed Scintilla 1.79 support (AZAWAWI) 0.20 2011.8.1 - The editor doesn't need to be visible to pass tests (ADAMK) - Added 'perl Build.PL --stc2' to build experimental Scintilla 2.03 (AZAWAWI). This is a back port from wxWidgets 2.9.2 development branch for wxWidgets 2.8.10+. Please test and let me know if it works for you or not. 0.19 2011.7.4 - Handle MinGW link to MS style perl5xx.lib (MARKD) 0.18 2011.6.29 - Reformatted Changes file (AZAWAWI) - Fix RT #69176 Unrecognized command line option "-Wno-strict-overflow" (AZAWAWI) 0.17 2011.6.28 - Wx::Scintilla cannot exist with Wx::STC (MARKD) - More simplified user-friendly build logs (AZAWAWI) - Less warnings noise while compiling Scintilla on GTK, MSWgcc and OSX (AZAWAWI) 0.16 2011.6.28 - Show a simplified version of commands and show the actual command when it fails or interrupted with Ctrl-C unless perl Build.PL verbose=1 is used (AZAWAWI) - Fix RT #69115: Building Wx::Scintilla fails in relocatable perl (AZAWAWI) 0.15 2011.6.21 - Minor POD fix (AZAWAWI) 0.14 2011.6.21 - Ubuntu 11.04+ scrolling redraw fix http://trac.wxwidgets.org/ticket/13229 (MARKD) - Added initial version of Wx::Scintilla::Manual (AZAWAWI) - Removed File::ShareDir lookup as scintilla DLL is now side by side with the XS DLL (MARKD) - Fixed the bad soname in Linux GTK build (MARKD) - Stop linking libperl on non-MSWin32 platforms. Relative -rpath for GTK ensures the current scintilla dll is always loaded (MARKD) - Removed File::ShareDir dependency (AZAWAWI) 0.13 2011.6.20 - EVT_SCINTILLA* is now EVT_STC* for backward compatibility with Wx::STC (AZAWAWI) - POD updates (AZAWAWI) - Added Perl 6 lexer to linked lexers (AZAWAWI) 0.12 2011.6.17 - Updated POD (AZAWAWI) - Don't set global Wx::Event version (MARKD) - Pre-build check for GTK development library (MARKD) - Static Perl linking fix (MARKD) - Totally experimental Perl 6 syntax higlighting that is made only for the brave of heart (AZAWAWI) 0.11 2011.6.16 - OS compatibility patch (Big thanks to Mark Dootson++) (MARKD) CentOS 3 32 bit - custom built Perl CentOS 5 32/64 bit - custom built Perl Fedora 14 32 Bit - system Perl & Wx Ubuntu 10/11 32 Bit - system Perl & Wx Mac OS X Snow Leopard - 32 bit custom Perl Windows XP 32 bit custom Perl & Wx Windows Vista 32/64 bit custom Perl & Wx Windows 7 64 bit custom Perl & Wx 0.10 2011.6.15 - Added Makefile.PL support through Module::Build::Compat (AZAWAWI) 0.09 2011.6.13 - Experimental support 64-bit Ubuntu 10.10 (SZABGAB, AZAWAWI) - Defeat the indexer by splitting the package declaration on two lines for Wx::Event (MARKD, AZAWAWI) 0.08 2011.6.10 - Proper ActivePerl + MS VC Compiler support in Wx::Scintilla (AZAWAWI) - Updated POD documentation about supported platforms (AZAWAWI) 0.07 2011.6.10 - Removed the 'OS unsupported' test in Build.PL; i want it to fail on other platforms so i can learn more from failures (AZAWAWI) 0.06 2011.6.9 - Added t/03_editor.t to begin testing Scintilla editor functionality (AZAWAWI) - More POD updates (AZAWAWI) - Removed Makefile.PL because of weird compilation failures while using it (AZAWAWI) - Handled compilation failures and the user's control-c (AZAWAWI) - Removed a few Alien::wxWidgets dependencies in Build.PL which causes a lot of false UNKNOWNs in CPAN testers reports (AZAWAWI) - Reuse Module::Build API to use Config (AZAWAWI) - Fixed shared library loading problems on Linux by setting runtime link paths (AZAWAWI) 0.05 2011.6.8 - Updated POD documentation (AZAWAWI) - Experimental linux gtk support (AZAWAWI) 0.042 2011.6.6 - Quick version to handle packages with undefined versions 0.04 2011.6.6 - Better handling of File::ShareDir death (AZAWAWI) - Fixed XS loader version mismatch bug in Wx::boot by replacing it by XSLoader::load (AZAWAWI) - File::Sharedir is not used to locate shared libs when the test harness is active (AZAWAWI) - Updated POD documentation (AZAWAWI) - Added a minimal demo Perl editor application in the SYNOPSIS section (AZAWAWI) 0.03 2011.6.6 - The package version is extracted correctly to prevent test failures (AZAWAWI) - Wx::Event is no longer subclassed to prevent the permission error for now (AZAWAWI) - Include the important and missing Scintilla.xs (AZAWAWI) - More POD documentation (AZAWAWI) - Fixed missing dist_abstract warning in Build.PL (AZAWAWI, Reported by SZABGAB) 0.02 2011.6.5 - Attempt to fix the Wx::Event-subclass-upload-permission error (AZAWAWI) 0.01 2011.6.5 - First version, released on an unsuspecting world (AZAWAWI)Wx-Scintilla-0.39/MANIFEST000444001750001750 2036512021352777 15576 0ustar00azawawiazawawi000000000000Build.PL Changes cpp/st_constants.cpp inc/Module/Build/Scintilla.pm inc/Module/Build/Scintilla/GTK.pm inc/Module/Build/Scintilla/MSW.pm inc/Module/Build/Scintilla/MSWgcc.pm inc/Module/Build/Scintilla/OSX.pm lib/Wx/Scintilla.pm lib/Wx/Scintilla/Constant.pm lib/Wx/Scintilla/Manual.pod lib/Wx/Scintilla/TextCtrl.pm lib/Wx/Scintilla/TextEvent.pm MANIFEST This list of files README Scintilla.xs Scintilla_README t/01_load.t t/02_inheritance.t t/03_editor.t t/03_editor_child.t t/lib/Tests_Helper.pm tools/gen_scintilla_constants.pl tools/perl-test-interpolation.pl.txt tools/perl6_editor.pl tools/perl_editor.pl tools/perltidyrc typemap wx-scintilla/include/private.h wx-scintilla/include/WxScintilla.h wx-scintilla/src/PlatWX.cpp wx-scintilla/src/PlatWX.h wx-scintilla/src/scintilla.cpp wx-scintilla/src/scintilla/include/ILexer.h wx-scintilla/src/scintilla/include/Platform.h wx-scintilla/src/scintilla/include/SciLexer.h wx-scintilla/src/scintilla/include/Scintilla.h wx-scintilla/src/scintilla/include/Scintilla.iface wx-scintilla/src/scintilla/include/ScintillaWidget.h wx-scintilla/src/scintilla/License.txt wx-scintilla/src/scintilla/README.txt wx-scintilla/src/scintilla/src/Accessor.cxx wx-scintilla/src/scintilla/src/Accessor.h wx-scintilla/src/scintilla/src/AutoComplete.cxx wx-scintilla/src/scintilla/src/AutoComplete.h wx-scintilla/src/scintilla/src/CallTip.cxx wx-scintilla/src/scintilla/src/CallTip.h wx-scintilla/src/scintilla/src/Catalogue.cxx wx-scintilla/src/scintilla/src/Catalogue.h wx-scintilla/src/scintilla/src/CellBuffer.cxx wx-scintilla/src/scintilla/src/CellBuffer.h wx-scintilla/src/scintilla/src/CharacterSet.cxx wx-scintilla/src/scintilla/src/CharacterSet.h wx-scintilla/src/scintilla/src/CharClassify.cxx wx-scintilla/src/scintilla/src/CharClassify.h wx-scintilla/src/scintilla/src/ContractionState.cxx wx-scintilla/src/scintilla/src/ContractionState.h wx-scintilla/src/scintilla/src/Decoration.cxx wx-scintilla/src/scintilla/src/Decoration.h wx-scintilla/src/scintilla/src/Document.cxx wx-scintilla/src/scintilla/src/Document.h wx-scintilla/src/scintilla/src/Editor.cxx wx-scintilla/src/scintilla/src/Editor.h wx-scintilla/src/scintilla/src/ExternalLexer.cxx wx-scintilla/src/scintilla/src/ExternalLexer.h wx-scintilla/src/scintilla/src/FontQuality.h wx-scintilla/src/scintilla/src/Indicator.cxx wx-scintilla/src/scintilla/src/Indicator.h wx-scintilla/src/scintilla/src/KeyMap.cxx wx-scintilla/src/scintilla/src/KeyMap.h wx-scintilla/src/scintilla/src/LexA68k.cxx wx-scintilla/src/scintilla/src/LexAbaqus.cxx wx-scintilla/src/scintilla/src/LexAccessor.h wx-scintilla/src/scintilla/src/LexAda.cxx wx-scintilla/src/scintilla/src/LexAPDL.cxx wx-scintilla/src/scintilla/src/LexAsm.cxx wx-scintilla/src/scintilla/src/LexAsn1.cxx wx-scintilla/src/scintilla/src/LexASY.cxx wx-scintilla/src/scintilla/src/LexAU3.cxx wx-scintilla/src/scintilla/src/LexAVE.cxx wx-scintilla/src/scintilla/src/LexAVS.cxx wx-scintilla/src/scintilla/src/LexBaan.cxx wx-scintilla/src/scintilla/src/LexBash.cxx wx-scintilla/src/scintilla/src/LexBasic.cxx wx-scintilla/src/scintilla/src/LexBullant.cxx wx-scintilla/src/scintilla/src/LexCaml.cxx wx-scintilla/src/scintilla/src/LexCLW.cxx wx-scintilla/src/scintilla/src/LexCmake.cxx wx-scintilla/src/scintilla/src/LexCOBOL.cxx wx-scintilla/src/scintilla/src/LexCoffeeScript.cxx wx-scintilla/src/scintilla/src/LexConf.cxx wx-scintilla/src/scintilla/src/LexCPP.cxx wx-scintilla/src/scintilla/src/LexCrontab.cxx wx-scintilla/src/scintilla/src/LexCsound.cxx wx-scintilla/src/scintilla/src/LexCSS.cxx wx-scintilla/src/scintilla/src/LexD.cxx wx-scintilla/src/scintilla/src/LexECL.cxx wx-scintilla/src/scintilla/src/LexEiffel.cxx wx-scintilla/src/scintilla/src/LexerBase.cxx wx-scintilla/src/scintilla/src/LexerBase.h wx-scintilla/src/scintilla/src/LexErlang.cxx wx-scintilla/src/scintilla/src/LexerModule.cxx wx-scintilla/src/scintilla/src/LexerModule.h wx-scintilla/src/scintilla/src/LexerNoExceptions.cxx wx-scintilla/src/scintilla/src/LexerNoExceptions.h wx-scintilla/src/scintilla/src/LexerSimple.cxx wx-scintilla/src/scintilla/src/LexerSimple.h wx-scintilla/src/scintilla/src/LexEScript.cxx wx-scintilla/src/scintilla/src/LexFlagship.cxx wx-scintilla/src/scintilla/src/LexForth.cxx wx-scintilla/src/scintilla/src/LexFortran.cxx wx-scintilla/src/scintilla/src/LexGAP.cxx wx-scintilla/src/scintilla/src/LexGui4Cli.cxx wx-scintilla/src/scintilla/src/LexHaskell.cxx wx-scintilla/src/scintilla/src/LexHTML.cxx wx-scintilla/src/scintilla/src/LexInno.cxx wx-scintilla/src/scintilla/src/LexKix.cxx wx-scintilla/src/scintilla/src/LexLisp.cxx wx-scintilla/src/scintilla/src/LexLout.cxx wx-scintilla/src/scintilla/src/LexLua.cxx wx-scintilla/src/scintilla/src/LexMagik.cxx wx-scintilla/src/scintilla/src/LexMarkdown.cxx wx-scintilla/src/scintilla/src/LexMatlab.cxx wx-scintilla/src/scintilla/src/LexMetapost.cxx wx-scintilla/src/scintilla/src/LexMMIXAL.cxx wx-scintilla/src/scintilla/src/LexModula.cxx wx-scintilla/src/scintilla/src/LexMPT.cxx wx-scintilla/src/scintilla/src/LexMSSQL.cxx wx-scintilla/src/scintilla/src/LexMySQL.cxx wx-scintilla/src/scintilla/src/LexNimrod.cxx wx-scintilla/src/scintilla/src/LexNsis.cxx wx-scintilla/src/scintilla/src/LexOpal.cxx wx-scintilla/src/scintilla/src/LexOthers.cxx wx-scintilla/src/scintilla/src/LexPascal.cxx wx-scintilla/src/scintilla/src/LexPB.cxx wx-scintilla/src/scintilla/src/LexPerl.cxx wx-scintilla/src/scintilla/src/LexPerl6.cxx wx-scintilla/src/scintilla/src/LexPLM.cxx wx-scintilla/src/scintilla/src/LexPOV.cxx wx-scintilla/src/scintilla/src/LexPowerPro.cxx wx-scintilla/src/scintilla/src/LexPowerShell.cxx wx-scintilla/src/scintilla/src/LexProgress.cxx wx-scintilla/src/scintilla/src/LexPS.cxx wx-scintilla/src/scintilla/src/LexPython.cxx wx-scintilla/src/scintilla/src/LexR.cxx wx-scintilla/src/scintilla/src/LexRebol.cxx wx-scintilla/src/scintilla/src/LexRuby.cxx wx-scintilla/src/scintilla/src/LexScriptol.cxx wx-scintilla/src/scintilla/src/LexSmalltalk.cxx wx-scintilla/src/scintilla/src/LexSML.cxx wx-scintilla/src/scintilla/src/LexSorcus.cxx wx-scintilla/src/scintilla/src/LexSpecman.cxx wx-scintilla/src/scintilla/src/LexSpice.cxx wx-scintilla/src/scintilla/src/LexSQL.cxx wx-scintilla/src/scintilla/src/LexTACL.cxx wx-scintilla/src/scintilla/src/LexTADS3.cxx wx-scintilla/src/scintilla/src/LexTAL.cxx wx-scintilla/src/scintilla/src/LexTCL.cxx wx-scintilla/src/scintilla/src/LexTCMD.cxx wx-scintilla/src/scintilla/src/LexTeX.cxx wx-scintilla/src/scintilla/src/LexTxt2tags.cxx wx-scintilla/src/scintilla/src/LexVB.cxx wx-scintilla/src/scintilla/src/LexVerilog.cxx wx-scintilla/src/scintilla/src/LexVHDL.cxx wx-scintilla/src/scintilla/src/LexYAML.cxx wx-scintilla/src/scintilla/src/LineMarker.cxx wx-scintilla/src/scintilla/src/LineMarker.h wx-scintilla/src/scintilla/src/OptionSet.h wx-scintilla/src/scintilla/src/Partitioning.h wx-scintilla/src/scintilla/src/PerLine.cxx wx-scintilla/src/scintilla/src/PerLine.h wx-scintilla/src/scintilla/src/PositionCache.cxx wx-scintilla/src/scintilla/src/PositionCache.h wx-scintilla/src/scintilla/src/PropSetSimple.cxx wx-scintilla/src/scintilla/src/PropSetSimple.h wx-scintilla/src/scintilla/src/RESearch.cxx wx-scintilla/src/scintilla/src/RESearch.h wx-scintilla/src/scintilla/src/RunStyles.cxx wx-scintilla/src/scintilla/src/RunStyles.h wx-scintilla/src/scintilla/src/ScintillaBase.cxx wx-scintilla/src/scintilla/src/ScintillaBase.h wx-scintilla/src/scintilla/src/Selection.cxx wx-scintilla/src/scintilla/src/Selection.h wx-scintilla/src/scintilla/src/SparseState.h wx-scintilla/src/scintilla/src/SplitVector.h wx-scintilla/src/scintilla/src/Style.cxx wx-scintilla/src/scintilla/src/Style.h wx-scintilla/src/scintilla/src/StyleContext.cxx wx-scintilla/src/scintilla/src/StyleContext.h wx-scintilla/src/scintilla/src/SVector.h wx-scintilla/src/scintilla/src/UniConversion.cxx wx-scintilla/src/scintilla/src/UniConversion.h wx-scintilla/src/scintilla/src/ViewStyle.cxx wx-scintilla/src/scintilla/src/ViewStyle.h wx-scintilla/src/scintilla/src/WordList.cxx wx-scintilla/src/scintilla/src/WordList.h wx-scintilla/src/scintilla/src/XPM.cxx wx-scintilla/src/scintilla/src/XPM.h wx-scintilla/src/scintilla_cw.h wx-scintilla/src/scintilla_cw_d.h wx-scintilla/src/scintilla_cwc.h wx-scintilla/src/scintilla_cwc_d.h wx-scintilla/src/scintilla_i18n.cpp wx-scintilla/src/ScintillaWX.cpp wx-scintilla/src/ScintillaWX.h wx_typemap wx_typemap.xsp XS/ScintillaTextCtrl.xsp XS/ScintillaTextEvent.xsp META.yml META.json Wx-Scintilla-0.39/Scintilla.xs000444001750001750 100312021352777 16707 0ustar00azawawiazawawi000000000000/** XS bindings for Wx::Scintilla */ #define PERL_NO_GET_CONTEXT #include "cpp/wxapi.h" #undef THIS MODULE=Wx__Scintilla BOOT: INIT_PLI_HELPERS( wx_pli_helpers ); INCLUDE_COMMAND: $^X -MExtUtils::XSpp::Cmd -e xspp -- -t wx_typemap.xsp XS/ScintillaTextCtrl.xsp INCLUDE_COMMAND: $^X -MExtUtils::XSpp::Cmd -e xspp -- -t wx_typemap.xsp XS/ScintillaTextEvent.xsp #include "cpp/st_constants.cpp" # //FIXME//tricky #if defined(__WXMSW__) #undef XS #define XS( name ) WXXS( name ) #endif MODULE=Wx__Scintilla Wx-Scintilla-0.39/lib000755001750001750 012021352776 15027 5ustar00azawawiazawawi000000000000Wx-Scintilla-0.39/lib/Wx000755001750001750 012021352777 15426 5ustar00azawawiazawawi000000000000Wx-Scintilla-0.39/lib/Wx/Scintilla.pm000444001750001750 3521512021352777 20071 0ustar00azawawiazawawi000000000000package Wx::Scintilla; use 5.008; use strict; use warnings; use Carp (); use Exporter (); use XSLoader (); use Wx (); our $VERSION = '0.39'; # Check for loaded Wx::STC BEGIN { if ( exists $INC{'Wx/STC.pm'} ) { croak('Wx::Scintilla and Wx::STC and mutually exclusive'); } } # Import all of the constants use Wx::Scintilla::Constant; # Define Perl 6 lexer use constant { wxSCINTILLA_LEX_PERL6 => 102, wxSCINTILLA_P6_DEFAULT => 0, wxSCINTILLA_P6_COMMENT => 1, wxSCINTILLA_P6_STRING => 2, }; # Load the XS backend XSLoader::load 'Wx::Scintilla', $VERSION; # # properly setup inheritance tree # no strict; package Wx::ScintillaTextCtrl; our $VERSION = '0.39'; @ISA = qw(Wx::Control); package Wx::ScintillaTextEvent; our $VERSION = '0.39'; @ISA = qw(Wx::CommandEvent); use strict; # Load the renamespaced versions require Wx::Scintilla::TextCtrl; require Wx::Scintilla::TextEvent; # Set up all of the events SCOPE: { # Disable Wx::EVT_STC_* event warning redefinition no warnings 'redefine'; # SVN_XXXXXX notification messages sub Wx::Event::EVT_STC_STYLENEEDED($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_STYLENEEDED, $_[2] ); } sub Wx::Event::EVT_STC_CHARADDED($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_CHARADDED, $_[2] ); } sub Wx::Event::EVT_STC_SAVEPOINTREACHED($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_SAVEPOINTREACHED, $_[2] ); } sub Wx::Event::EVT_STC_SAVEPOINTLEFT($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_SAVEPOINTLEFT, $_[2] ); } sub Wx::Event::EVT_STC_ROMODIFYATTEMPT($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_ROMODIFYATTEMPT, $_[2] ); } sub Wx::Event::EVT_STC_KEY($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_KEY, $_[2] ); } sub Wx::Event::EVT_STC_DOUBLECLICK($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_DOUBLECLICK, $_[2] ); } sub Wx::Event::EVT_STC_UPDATEUI($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_UPDATEUI, $_[2] ); } sub Wx::Event::EVT_STC_MODIFIED($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_MODIFIED, $_[2] ); } sub Wx::Event::EVT_STC_MACRORECORD($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_MACRORECORD, $_[2] ); } sub Wx::Event::EVT_STC_MARGINCLICK($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_MARGINCLICK, $_[2] ); } sub Wx::Event::EVT_STC_NEEDSHOWN($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_NEEDSHOWN, $_[2] ); } sub Wx::Event::EVT_STC_PAINTED($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_PAINTED, $_[2] ); } sub Wx::Event::EVT_STC_USERLISTSELECTION($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_USERLISTSELECTION, $_[2] ); } sub Wx::Event::EVT_STC_URIDROPPED($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_URIDROPPED, $_[2] ); } sub Wx::Event::EVT_STC_DWELLSTART($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_DWELLSTART, $_[2] ); } sub Wx::Event::EVT_STC_DWELLEND($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_DWELLEND, $_[2] ); } sub Wx::Event::EVT_STC_ZOOM($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_ZOOM, $_[2] ); } sub Wx::Event::EVT_STC_HOTSPOT_CLICK($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_HOTSPOT_CLICK, $_[2] ); } sub Wx::Event::EVT_STC_HOTSPOT_DCLICK($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_HOTSPOT_DCLICK, $_[2] ); } sub Wx::Event::EVT_STC_INDICATOR_CLICK($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_INDICATOR_CLICK, $_[2] ); } sub Wx::Event::EVT_STC_INDICATOR_RELEASE($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_INDICATOR_RELEASE, $_[2] ); } sub Wx::Event::EVT_STC_CALLTIP_CLICK($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_CALLTIP_CLICK, $_[2] ); } sub Wx::Event::EVT_STC_AUTOCOMP_CANCELLED($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_AUTOCOMP_CANCELLED, $_[2] ); } sub Wx::Event::EVT_STC_AUTOCOMP_CHAR_DELETED($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_AUTOCOMP_CHAR_DELETED, $_[2] ); } # SCEN_XXXXXX notification messages sub Wx::Event::EVT_STC_CHANGE($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_CHANGE, $_[2] ); } # Events that do not seem to match the documentation sub Wx::Event::EVT_STC_START_DRAG($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_START_DRAG, $_[2] ); } sub Wx::Event::EVT_STC_DRAG_OVER($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_DRAG_OVER, $_[2] ); } sub Wx::Event::EVT_STC_DO_DROP($$$) { $_[0]->Connect( $_[1], -1, &Wx::wxEVT_STC_DO_DROP, $_[2] ); } # Deprecated notifications sub Wx::Event::EVT_STC_POSCHANGED($$$) { Carp::croak('EVT_STC_POSCHANGED is deprecated, use EVT_STC_UPDATEUI'); } sub Wx::Event::EVT_STC_CHECKBRACE($$$) { Carp::croak('EVT_STC_CHECKBRACE is deprecated, use EVT_STC_UPDATEUI'); } } # Create the aliases to the native versions. # The order here matches the order in the Scintilla documentation. BEGIN { # SCN_XXXXXX notifications *EVT_STYLENEEDED = *Wx::Event::EVT_STC_STYLENEEDED; *EVT_CHARADDED = *Wx::Event::EVT_STC_CHARADDED; *EVT_SAVEPOINTREACHED = *Wx::Event::EVT_STC_SAVEPOINTREACHED; *EVT_SAVEPOINTLEFT = *Wx::Event::EVT_STC_SAVEPOINTLEFT; *EVT_MODIFYATTEMPTRO = *Wx::Event::EVT_STC_ROMODIFYATTEMPT; *EVT_KEY = *Wx::Event::EVT_STC_KEY; *EVT_DOUBLECLICK = *Wx::Event::EVT_STC_DOUBLECLICK; *EVT_UPDATEUI = *Wx::Event::EVT_STC_UPDATEUI; *EVT_MODIFIED = *Wx::Event::EVT_STC_MODIFIED; *EVT_MACRORECORD = *Wx::Event::EVT_STC_MACRORECORD; *EVT_MARGINCLICK = *Wx::Event::EVT_STC_MARGINCLICK; *EVT_NEEDSHOWN = *Wx::Event::EVT_STC_NEEDSHOWN; *EVT_PAINTED = *Wx::Event::EVT_STC_PAINTED; *EVT_USERLISTSELECTION = *Wx::Event::EVT_STC_USERLISTSELECTION; *EVT_URIDROPPED = *Wx::Event::EVT_STC_URIDROPPED; *EVT_DWELLSTART = *Wx::Event::EVT_STC_DWELLSTART; *EVT_DWELLEND = *Wx::Event::EVT_STC_DWELLEND; *EVT_ZOOM = *Wx::Event::EVT_STC_ZOOM; *EVT_HOTSPOTCLICK = *Wx::Event::EVT_STC_HOTSPOT_CLICK; *EVT_HOTSPOTDOUBLECLICK = *Wx::Event::EVT_STC_HOTSPOT_DCLICK; # *EVT_HOTSPOTRELEASECLICK = *Wx::Event::EVT_STC_HOTSPOTRELEASECLICK; *EVT_INDICATORCLICK = *Wx::Event::EVT_STC_INDICATOR_CLICK; *EVT_INDICATORRELEASE = *Wx::Event::EVT_STC_INDICATOR_RELEASE; *EVT_CALLTIPCLICK = *Wx::Event::EVT_STC_CALLTIP_CLICK; # *EVT_AUTOCSELECTION = *Wx::Event::EVT_STC_AUTOCSELECTION; *EVT_AUTOCCANCELLED = *Wx::Event::EVT_STC_AUTOCOMP_CANCELLED; *EVT_AUTOCCHARDELETED = *Wx::Event::EVT_STC_AUTOCOMP_CHAR_DELETED; # SCEN_XXXXXX notifications *EVT_CHANGE = *Wx::Event::EVT_STC_CHANGE; # Deprecated notifications *EVT_POSCHANGED = *Wx::Event::EVT_STC_POSCHANGED; *EVT_CHECKBRACE = *Wx::Event::EVT_STC_CHECKBRACE; } 1; __END__ =pod =head1 NAME Wx::Scintilla - Scintilla source code editing component for wxWidgets =head1 SYNOPSIS #----> My first scintilla Wx editor :) package My::Scintilla::Editor; use strict; use warnings; # Load Wx::Scintilla use Wx::Scintilla (); # replaces use Wx::STC use base 'Wx::Scintilla::TextCtrl'; # replaces Wx::StyledTextCtrl use Wx qw(:everything); use Wx::Event; # Override the constructor to Enable Perl support in the editor sub new { my ( $class, $parent ) = @_; my $self = $class->SUPER::new( $parent, -1, [ -1, -1 ], [ 750, 700 ] ); # Set the font my $font = Wx::Font->new( 10, wxTELETYPE, wxNORMAL, wxNORMAL ); $self->SetFont($font); $self->StyleSetFont( Wx::Scintilla::STYLE_DEFAULT, $font ); $self->StyleClearAll(); # Set the various Perl lexer colors $self->StyleSetForeground( 0, Wx::Colour->new( 0x00, 0x00, 0x7f ) ); $self->StyleSetForeground( 1, Wx::Colour->new( 0xff, 0x00, 0x00 ) ); $self->StyleSetForeground( 2, Wx::Colour->new( 0x00, 0x7f, 0x00 ) ); $self->StyleSetForeground( 3, Wx::Colour->new( 0x7f, 0x7f, 0x7f ) ); $self->StyleSetForeground( 4, Wx::Colour->new( 0x00, 0x7f, 0x7f ) ); $self->StyleSetForeground( 5, Wx::Colour->new( 0x00, 0x00, 0x7f ) ); $self->StyleSetForeground( 6, Wx::Colour->new( 0xff, 0x7f, 0x00 ) ); $self->StyleSetForeground( 7, Wx::Colour->new( 0x7f, 0x00, 0x7f ) ); $self->StyleSetForeground( 8, Wx::Colour->new( 0x00, 0x00, 0x00 ) ); $self->StyleSetForeground( 9, Wx::Colour->new( 0x7f, 0x7f, 0x7f ) ); $self->StyleSetForeground( 10, Wx::Colour->new( 0x00, 0x00, 0x7f ) ); $self->StyleSetForeground( 11, Wx::Colour->new( 0x00, 0x00, 0xff ) ); $self->StyleSetForeground( 12, Wx::Colour->new( 0x7f, 0x00, 0x7f ) ); $self->StyleSetForeground( 13, Wx::Colour->new( 0x40, 0x80, 0xff ) ); $self->StyleSetForeground( 17, Wx::Colour->new( 0xff, 0x00, 0x7f ) ); $self->StyleSetForeground( 18, Wx::Colour->new( 0x7f, 0x7f, 0x00 ) ); $self->StyleSetBold( 12, 1 ); $self->StyleSetSpec( Wx::Scintilla::SCE_H_TAG, "fore:#0000ff" ); # set the lexer to Perl 5 $self->SetLexer(Wx::Scintilla::SCLEX_PERL); return $self; } #----> DEMO EDITOR APPLICATION # First, define an application object class to encapsulate the application itself package DemoEditorApp; use strict; use warnings; use Wx; use base 'Wx::App'; # We must override OnInit to build the window sub OnInit { my $self = shift; my $frame = Wx::Frame->new( undef, # no parent window -1, # no window id 'My First Scintilla Editor!', # Window title ); my $editor = My::Scintilla::Editor->new( $frame, # Parent window ); $frame->Show(1); return 1; } # Create the application object, and pass control to it. package main; my $app = DemoEditorApp->new; $app->MainLoop; =head1 DESCRIPTION While we already have a good scintilla editor component support via Wx::StyledTextCtrl in Perl, we already suffer from an older scintilla package and thus lagging Perl support in the popular Wx Scintilla component. wxWidgets L has a *very slow* release timeline. Scintilla is a contributed project which means it will not be the latest by the time a new wxWidgets distribution is released. And on the scintilla front, the Perl 5 lexer is not 100% bug free even and we do not have any kind of Perl 6 support in Scintilla. The ambitious goal of this project is to provide fresh Perl 5 and maybe 6 support in L while preserving compatibility with Wx::StyledTextCtrl and continually contribute it back to Scintilla project. Note: You cannot load Wx::STC and Wx::Scintilla in the same application. They are mutually exclusive. The wxSTC_... events are handled by one library or the other. Scintilla 2.28 is now bundled and enabled by default. =head1 MANUAL If you are looking for more API documentation, please consult L =head1 PLATFORMS At the moment, Linux (Debian, Ubuntu, Fedora, CentOS) and Windows (Strawberry and ActivePerl) are supported platforms. My next goal is to support more platforms. Please let me know if you can help out :) On Debian/Ubuntu, you need to install the following via: sudo apt-get install libgtk2.0-dev On MacOS 64-bit by default you need to install a 32-bit Perl in order to install wxWidgets 2.8.x. Please refer to L for more information. =head1 HISTORY wxWidgets 2.9.1 and development have Scintilla 2.03 so far. I searched for Perl lexer changes in scintilla history and here is what we will be getting when we upgrade to 2.26+. =over =item Release 2.26 Perl folding folds "here doc"s and adds options fold.perl.at.else and fold.perl.comment.explicit. Fold structure for Perl fixed. =item Release 2.20 Perl folder works for array blocks, adjacent package statements, nested PODs, and terminates package folding at DATA, D and Z. =item Release 1.79 Perl lexer bug fixed where previous lexical states persisted causing "/" special case styling and subroutine prototype styling to not be correct. =item Release 1.78 Perl lexer fixes problem with string matching caused by line endings. =item Release 1.77 Perl lexer update. =item Release 1.76 Perl lexer handles defined-or operator "". =item Release 1.75 Perl lexer enhanced for handling minus-prefixed barewords, underscores in numeric literals and vector/version strings, D and Z similar to END, subroutine prototypes as a new lexical class, formats and format blocks as new lexical classes, and '/' suffixed keywords and barewords. =item Release 1.71 Perl lexer allows UTF-8 identifiers and has some other small improvements. =back =head1 ACKNOWLEDGEMENTS Neil Hudgson for creating and maintaining the excellent Scintilla project L. Thanks! Robin Dunn L for the excellent scintilla contribution that he made to wxWidgets. This work is based on his codebase. Thanks! Mark dootson L for his big effort to make Wx::Scintilla compilable on various platforms. Big thanks! Heiko Jansen and Gabor Szabo L for the idea to backport Perl lexer for wxWidgets 2.8.10 L and all of #padre members for the continuous support and testing. Thanks! =head1 SUPPORT Bugs should always be submitted via the CPAN bug tracker L For other issues, contact the maintainer. =head1 AUTHOR Ahmad M. Zawawi Mark Dootson =head1 SEE ALSO Wx::Scintilla Manual L wxStyledTextCtrl Documentation L Scintilla edit control for Win32::GUI L =head1 COPYRIGHT AND LICENSE Copyright 2011 Ahmad M. Zawawi. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. License for Scintilla Included Scintilla source is copyrighted 1998-2011 by Neil Hodgson Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. NEIL HODGSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NEIL HODGSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. =cut Wx-Scintilla-0.39/lib/Wx/Scintilla000755001750001750 012021352777 17350 5ustar00azawawiazawawi000000000000Wx-Scintilla-0.39/lib/Wx/Scintilla/Constant.pm000444001750001750 51374412021352777 21712 0ustar00azawawiazawawi000000000000package Wx::Scintilla::Constant; ## ## Warning: This file is autogenerated from Scintilla.iface ## PLEASE DO NOT EDIT ## use 5.008; use strict; use warnings; require Exporter; our $VERSION = '0.39'; our @ISA = 'Exporter'; our @EXPORT = qw( INVALID_POSITION SCI_START SCI_OPTIONAL_START SCI_LEXER_START SCWS_INVISIBLE SCWS_VISIBLEALWAYS SCWS_VISIBLEAFTERINDENT SC_EOL_CRLF SC_EOL_CR SC_EOL_LF SC_CP_UTF8 MARKER_MAX SC_MARK_CIRCLE SC_MARK_ROUNDRECT SC_MARK_ARROW SC_MARK_SMALLRECT SC_MARK_SHORTARROW SC_MARK_EMPTY SC_MARK_ARROWDOWN SC_MARK_MINUS SC_MARK_PLUS SC_MARK_VLINE SC_MARK_LCORNER SC_MARK_TCORNER SC_MARK_BOXPLUS SC_MARK_BOXPLUSCONNECTED SC_MARK_BOXMINUS SC_MARK_BOXMINUSCONNECTED SC_MARK_LCORNERCURVE SC_MARK_TCORNERCURVE SC_MARK_CIRCLEPLUS SC_MARK_CIRCLEPLUSCONNECTED SC_MARK_CIRCLEMINUS SC_MARK_CIRCLEMINUSCONNECTED SC_MARK_BACKGROUND SC_MARK_DOTDOTDOT SC_MARK_ARROWS SC_MARK_PIXMAP SC_MARK_FULLRECT SC_MARK_LEFTRECT SC_MARK_AVAILABLE SC_MARK_UNDERLINE SC_MARK_RGBAIMAGE SC_MARK_CHARACTER SC_MARKNUM_FOLDEREND SC_MARKNUM_FOLDEROPENMID SC_MARKNUM_FOLDERMIDTAIL SC_MARKNUM_FOLDERTAIL SC_MARKNUM_FOLDERSUB SC_MARKNUM_FOLDER SC_MARKNUM_FOLDEROPEN SC_MASK_FOLDERS SC_MARGIN_SYMBOL SC_MARGIN_NUMBER SC_MARGIN_BACK SC_MARGIN_FORE SC_MARGIN_TEXT SC_MARGIN_RTEXT STYLE_DEFAULT STYLE_LINENUMBER STYLE_BRACELIGHT STYLE_BRACEBAD STYLE_CONTROLCHAR STYLE_INDENTGUIDE STYLE_CALLTIP STYLE_LASTPREDEFINED STYLE_MAX SC_CHARSET_ANSI SC_CHARSET_DEFAULT SC_CHARSET_BALTIC SC_CHARSET_CHINESEBIG5 SC_CHARSET_EASTEUROPE SC_CHARSET_GB2312 SC_CHARSET_GREEK SC_CHARSET_HANGUL SC_CHARSET_MAC SC_CHARSET_OEM SC_CHARSET_RUSSIAN SC_CHARSET_CYRILLIC SC_CHARSET_SHIFTJIS SC_CHARSET_SYMBOL SC_CHARSET_TURKISH SC_CHARSET_JOHAB SC_CHARSET_HEBREW SC_CHARSET_ARABIC SC_CHARSET_VIETNAMESE SC_CHARSET_THAI SC_CHARSET_8859_15 SC_CASE_MIXED SC_CASE_UPPER SC_CASE_LOWER SC_FONT_SIZE_MULTIPLIER SC_WEIGHT_NORMAL SC_WEIGHT_SEMIBOLD SC_WEIGHT_BOLD INDIC_PLAIN INDIC_SQUIGGLE INDIC_TT INDIC_DIAGONAL INDIC_STRIKE INDIC_HIDDEN INDIC_BOX INDIC_ROUNDBOX INDIC_STRAIGHTBOX INDIC_DASH INDIC_DOTS INDIC_SQUIGGLELOW INDIC_DOTBOX INDIC_MAX INDIC_CONTAINER INDIC0_MASK INDIC1_MASK INDIC2_MASK INDICS_MASK SC_IV_NONE SC_IV_REAL SC_IV_LOOKFORWARD SC_IV_LOOKBOTH SC_PRINT_NORMAL SC_PRINT_INVERTLIGHT SC_PRINT_BLACKONWHITE SC_PRINT_COLOURONWHITE SC_PRINT_COLOURONWHITEDEFAULTBG SCFIND_WHOLEWORD SCFIND_MATCHCASE SCFIND_WORDSTART SCFIND_REGEXP SCFIND_POSIX SC_FOLDLEVELBASE SC_FOLDLEVELWHITEFLAG SC_FOLDLEVELHEADERFLAG SC_FOLDLEVELNUMBERMASK SC_FOLDFLAG_LINEBEFORE_EXPANDED SC_FOLDFLAG_LINEBEFORE_CONTRACTED SC_FOLDFLAG_LINEAFTER_EXPANDED SC_FOLDFLAG_LINEAFTER_CONTRACTED SC_FOLDFLAG_LEVELNUMBERS SC_TIME_FOREVER SC_WRAP_NONE SC_WRAP_WORD SC_WRAP_CHAR SC_WRAPVISUALFLAG_NONE SC_WRAPVISUALFLAG_END SC_WRAPVISUALFLAG_START SC_WRAPVISUALFLAGLOC_DEFAULT SC_WRAPVISUALFLAGLOC_END_BY_TEXT SC_WRAPVISUALFLAGLOC_START_BY_TEXT SC_WRAPINDENT_FIXED SC_WRAPINDENT_SAME SC_WRAPINDENT_INDENT SC_CACHE_NONE SC_CACHE_CARET SC_CACHE_PAGE SC_CACHE_DOCUMENT SC_EFF_QUALITY_MASK SC_EFF_QUALITY_DEFAULT SC_EFF_QUALITY_NON_ANTIALIASED SC_EFF_QUALITY_ANTIALIASED SC_EFF_QUALITY_LCD_OPTIMIZED SC_MULTIPASTE_ONCE SC_MULTIPASTE_EACH EDGE_NONE EDGE_LINE EDGE_BACKGROUND SC_STATUS_OK SC_STATUS_FAILURE SC_STATUS_BADALLOC SC_CURSORNORMAL SC_CURSORARROW SC_CURSORWAIT SC_CURSORREVERSEARROW VISIBLE_SLOP VISIBLE_STRICT CARET_SLOP CARET_STRICT CARET_JUMPS CARET_EVEN SC_SEL_STREAM SC_SEL_RECTANGLE SC_SEL_LINES SC_SEL_THIN SC_CARETSTICKY_OFF SC_CARETSTICKY_ON SC_CARETSTICKY_WHITESPACE SC_ALPHA_TRANSPARENT SC_ALPHA_OPAQUE SC_ALPHA_NOALPHA CARETSTYLE_INVISIBLE CARETSTYLE_LINE CARETSTYLE_BLOCK SC_MARGINOPTION_NONE SC_MARGINOPTION_SUBLINESELECT ANNOTATION_HIDDEN ANNOTATION_STANDARD ANNOTATION_BOXED UNDO_MAY_COALESCE SCVS_NONE SCVS_RECTANGULARSELECTION SCVS_USERACCESSIBLE SC_TECHNOLOGY_DEFAULT SC_TECHNOLOGY_DIRECTWRITE KEYWORDSET_MAX SC_TYPE_BOOLEAN SC_TYPE_INTEGER SC_TYPE_STRING SC_MOD_INSERTTEXT SC_MOD_DELETETEXT SC_MOD_CHANGESTYLE SC_MOD_CHANGEFOLD SC_PERFORMED_USER SC_PERFORMED_UNDO SC_PERFORMED_REDO SC_MULTISTEPUNDOREDO SC_LASTSTEPINUNDOREDO SC_MOD_CHANGEMARKER SC_MOD_BEFOREINSERT SC_MOD_BEFOREDELETE SC_MULTILINEUNDOREDO SC_STARTACTION SC_MOD_CHANGEINDICATOR SC_MOD_CHANGELINESTATE SC_MOD_CHANGEMARGIN SC_MOD_CHANGEANNOTATION SC_MOD_CONTAINER SC_MOD_LEXERSTATE SC_MODEVENTMASKALL SC_UPDATE_CONTENT SC_UPDATE_SELECTION SC_UPDATE_V_SCROLL SC_UPDATE_H_SCROLL SCEN_CHANGE SCEN_SETFOCUS SCEN_KILLFOCUS SCK_DOWN SCK_UP SCK_LEFT SCK_RIGHT SCK_HOME SCK_END SCK_PRIOR SCK_NEXT SCK_DELETE SCK_INSERT SCK_ESCAPE SCK_BACK SCK_TAB SCK_RETURN SCK_ADD SCK_SUBTRACT SCK_DIVIDE SCK_WIN SCK_RWIN SCK_MENU SCMOD_NORM SCMOD_SHIFT SCMOD_CTRL SCMOD_ALT SCMOD_SUPER SCMOD_META SCLEX_CONTAINER SCLEX_NULL SCLEX_PYTHON SCLEX_CPP SCLEX_HTML SCLEX_XML SCLEX_PERL SCLEX_SQL SCLEX_VB SCLEX_PROPERTIES SCLEX_ERRORLIST SCLEX_MAKEFILE SCLEX_BATCH SCLEX_XCODE SCLEX_LATEX SCLEX_LUA SCLEX_DIFF SCLEX_CONF SCLEX_PASCAL SCLEX_AVE SCLEX_ADA SCLEX_LISP SCLEX_RUBY SCLEX_EIFFEL SCLEX_EIFFELKW SCLEX_TCL SCLEX_NNCRONTAB SCLEX_BULLANT SCLEX_VBSCRIPT SCLEX_BAAN SCLEX_MATLAB SCLEX_SCRIPTOL SCLEX_ASM SCLEX_CPPNOCASE SCLEX_FORTRAN SCLEX_F77 SCLEX_CSS SCLEX_POV SCLEX_LOUT SCLEX_ESCRIPT SCLEX_PS SCLEX_NSIS SCLEX_MMIXAL SCLEX_CLW SCLEX_CLWNOCASE SCLEX_LOT SCLEX_YAML SCLEX_TEX SCLEX_METAPOST SCLEX_POWERBASIC SCLEX_FORTH SCLEX_ERLANG SCLEX_OCTAVE SCLEX_MSSQL SCLEX_VERILOG SCLEX_KIX SCLEX_GUI4CLI SCLEX_SPECMAN SCLEX_AU3 SCLEX_APDL SCLEX_BASH SCLEX_ASN1 SCLEX_VHDL SCLEX_CAML SCLEX_BLITZBASIC SCLEX_PUREBASIC SCLEX_HASKELL SCLEX_PHPSCRIPT SCLEX_TADS3 SCLEX_REBOL SCLEX_SMALLTALK SCLEX_FLAGSHIP SCLEX_CSOUND SCLEX_FREEBASIC SCLEX_INNOSETUP SCLEX_OPAL SCLEX_SPICE SCLEX_D SCLEX_CMAKE SCLEX_GAP SCLEX_PLM SCLEX_PROGRESS SCLEX_ABAQUS SCLEX_ASYMPTOTE SCLEX_R SCLEX_MAGIK SCLEX_POWERSHELL SCLEX_MYSQL SCLEX_PO SCLEX_TAL SCLEX_COBOL SCLEX_TACL SCLEX_SORCUS SCLEX_POWERPRO SCLEX_NIMROD SCLEX_SML SCLEX_MARKDOWN SCLEX_TXT2TAGS SCLEX_A68K SCLEX_MODULA SCLEX_COFFEESCRIPT SCLEX_TCMD SCLEX_AVS SCLEX_ECL SCLEX_AUTOMATIC SCE_P_DEFAULT SCE_P_COMMENTLINE SCE_P_NUMBER SCE_P_STRING SCE_P_CHARACTER SCE_P_WORD SCE_P_TRIPLE SCE_P_TRIPLEDOUBLE SCE_P_CLASSNAME SCE_P_DEFNAME SCE_P_OPERATOR SCE_P_IDENTIFIER SCE_P_COMMENTBLOCK SCE_P_STRINGEOL SCE_P_WORD2 SCE_P_DECORATOR SCE_C_DEFAULT SCE_C_COMMENT SCE_C_COMMENTLINE SCE_C_COMMENTDOC SCE_C_NUMBER SCE_C_WORD SCE_C_STRING SCE_C_CHARACTER SCE_C_UUID SCE_C_PREPROCESSOR SCE_C_OPERATOR SCE_C_IDENTIFIER SCE_C_STRINGEOL SCE_C_VERBATIM SCE_C_REGEX SCE_C_COMMENTLINEDOC SCE_C_WORD2 SCE_C_COMMENTDOCKEYWORD SCE_C_COMMENTDOCKEYWORDERROR SCE_C_GLOBALCLASS SCE_C_STRINGRAW SCE_C_TRIPLEVERBATIM SCE_C_HASHQUOTEDSTRING SCE_D_DEFAULT SCE_D_COMMENT SCE_D_COMMENTLINE SCE_D_COMMENTDOC SCE_D_COMMENTNESTED SCE_D_NUMBER SCE_D_WORD SCE_D_WORD2 SCE_D_WORD3 SCE_D_TYPEDEF SCE_D_STRING SCE_D_STRINGEOL SCE_D_CHARACTER SCE_D_OPERATOR SCE_D_IDENTIFIER SCE_D_COMMENTLINEDOC SCE_D_COMMENTDOCKEYWORD SCE_D_COMMENTDOCKEYWORDERROR SCE_D_STRINGB SCE_D_STRINGR SCE_D_WORD5 SCE_D_WORD6 SCE_D_WORD7 SCE_TCL_DEFAULT SCE_TCL_COMMENT SCE_TCL_COMMENTLINE SCE_TCL_NUMBER SCE_TCL_WORD_IN_QUOTE SCE_TCL_IN_QUOTE SCE_TCL_OPERATOR SCE_TCL_IDENTIFIER SCE_TCL_SUBSTITUTION SCE_TCL_SUB_BRACE SCE_TCL_MODIFIER SCE_TCL_EXPAND SCE_TCL_WORD SCE_TCL_WORD2 SCE_TCL_WORD3 SCE_TCL_WORD4 SCE_TCL_WORD5 SCE_TCL_WORD6 SCE_TCL_WORD7 SCE_TCL_WORD8 SCE_TCL_COMMENT_BOX SCE_TCL_BLOCK_COMMENT SCE_H_DEFAULT SCE_H_TAG SCE_H_TAGUNKNOWN SCE_H_ATTRIBUTE SCE_H_ATTRIBUTEUNKNOWN SCE_H_NUMBER SCE_H_DOUBLESTRING SCE_H_SINGLESTRING SCE_H_OTHER SCE_H_COMMENT SCE_H_ENTITY SCE_H_TAGEND SCE_H_XMLSTART SCE_H_XMLEND SCE_H_SCRIPT SCE_H_ASP SCE_H_ASPAT SCE_H_CDATA SCE_H_QUESTION SCE_H_VALUE SCE_H_XCCOMMENT SCE_H_SGML_DEFAULT SCE_H_SGML_COMMAND SCE_H_SGML_1ST_PARAM SCE_H_SGML_DOUBLESTRING SCE_H_SGML_SIMPLESTRING SCE_H_SGML_ERROR SCE_H_SGML_SPECIAL SCE_H_SGML_ENTITY SCE_H_SGML_COMMENT SCE_H_SGML_1ST_PARAM_COMMENT SCE_H_SGML_BLOCK_DEFAULT SCE_HJ_START SCE_HJ_DEFAULT SCE_HJ_COMMENT SCE_HJ_COMMENTLINE SCE_HJ_COMMENTDOC SCE_HJ_NUMBER SCE_HJ_WORD SCE_HJ_KEYWORD SCE_HJ_DOUBLESTRING SCE_HJ_SINGLESTRING SCE_HJ_SYMBOLS SCE_HJ_STRINGEOL SCE_HJ_REGEX SCE_HJA_START SCE_HJA_DEFAULT SCE_HJA_COMMENT SCE_HJA_COMMENTLINE SCE_HJA_COMMENTDOC SCE_HJA_NUMBER SCE_HJA_WORD SCE_HJA_KEYWORD SCE_HJA_DOUBLESTRING SCE_HJA_SINGLESTRING SCE_HJA_SYMBOLS SCE_HJA_STRINGEOL SCE_HJA_REGEX SCE_HB_START SCE_HB_DEFAULT SCE_HB_COMMENTLINE SCE_HB_NUMBER SCE_HB_WORD SCE_HB_STRING SCE_HB_IDENTIFIER SCE_HB_STRINGEOL SCE_HBA_START SCE_HBA_DEFAULT SCE_HBA_COMMENTLINE SCE_HBA_NUMBER SCE_HBA_WORD SCE_HBA_STRING SCE_HBA_IDENTIFIER SCE_HBA_STRINGEOL SCE_HP_START SCE_HP_DEFAULT SCE_HP_COMMENTLINE SCE_HP_NUMBER SCE_HP_STRING SCE_HP_CHARACTER SCE_HP_WORD SCE_HP_TRIPLE SCE_HP_TRIPLEDOUBLE SCE_HP_CLASSNAME SCE_HP_DEFNAME SCE_HP_OPERATOR SCE_HP_IDENTIFIER SCE_HPHP_COMPLEX_VARIABLE SCE_HPA_START SCE_HPA_DEFAULT SCE_HPA_COMMENTLINE SCE_HPA_NUMBER SCE_HPA_STRING SCE_HPA_CHARACTER SCE_HPA_WORD SCE_HPA_TRIPLE SCE_HPA_TRIPLEDOUBLE SCE_HPA_CLASSNAME SCE_HPA_DEFNAME SCE_HPA_OPERATOR SCE_HPA_IDENTIFIER SCE_HPHP_DEFAULT SCE_HPHP_HSTRING SCE_HPHP_SIMPLESTRING SCE_HPHP_WORD SCE_HPHP_NUMBER SCE_HPHP_VARIABLE SCE_HPHP_COMMENT SCE_HPHP_COMMENTLINE SCE_HPHP_HSTRING_VARIABLE SCE_HPHP_OPERATOR SCE_PL_DEFAULT SCE_PL_ERROR SCE_PL_COMMENTLINE SCE_PL_POD SCE_PL_NUMBER SCE_PL_WORD SCE_PL_STRING SCE_PL_CHARACTER SCE_PL_PUNCTUATION SCE_PL_PREPROCESSOR SCE_PL_OPERATOR SCE_PL_IDENTIFIER SCE_PL_SCALAR SCE_PL_ARRAY SCE_PL_HASH SCE_PL_SYMBOLTABLE SCE_PL_VARIABLE_INDEXER SCE_PL_REGEX SCE_PL_REGSUBST SCE_PL_LONGQUOTE SCE_PL_BACKTICKS SCE_PL_DATASECTION SCE_PL_HERE_DELIM SCE_PL_HERE_Q SCE_PL_HERE_QQ SCE_PL_HERE_QX SCE_PL_STRING_Q SCE_PL_STRING_QQ SCE_PL_STRING_QX SCE_PL_STRING_QR SCE_PL_STRING_QW SCE_PL_POD_VERB SCE_PL_SUB_PROTOTYPE SCE_PL_FORMAT_IDENT SCE_PL_FORMAT SCE_PL_STRING_VAR SCE_PL_XLAT SCE_PL_REGEX_VAR SCE_PL_REGSUBST_VAR SCE_PL_BACKTICKS_VAR SCE_PL_HERE_QQ_VAR SCE_PL_HERE_QX_VAR SCE_PL_STRING_QQ_VAR SCE_PL_STRING_QX_VAR SCE_PL_STRING_QR_VAR SCE_RB_DEFAULT SCE_RB_ERROR SCE_RB_COMMENTLINE SCE_RB_POD SCE_RB_NUMBER SCE_RB_WORD SCE_RB_STRING SCE_RB_CHARACTER SCE_RB_CLASSNAME SCE_RB_DEFNAME SCE_RB_OPERATOR SCE_RB_IDENTIFIER SCE_RB_REGEX SCE_RB_GLOBAL SCE_RB_SYMBOL SCE_RB_MODULE_NAME SCE_RB_INSTANCE_VAR SCE_RB_CLASS_VAR SCE_RB_BACKTICKS SCE_RB_DATASECTION SCE_RB_HERE_DELIM SCE_RB_HERE_Q SCE_RB_HERE_QQ SCE_RB_HERE_QX SCE_RB_STRING_Q SCE_RB_STRING_QQ SCE_RB_STRING_QX SCE_RB_STRING_QR SCE_RB_STRING_QW SCE_RB_WORD_DEMOTED SCE_RB_STDIN SCE_RB_STDOUT SCE_RB_STDERR SCE_RB_UPPER_BOUND SCE_B_DEFAULT SCE_B_COMMENT SCE_B_NUMBER SCE_B_KEYWORD SCE_B_STRING SCE_B_PREPROCESSOR SCE_B_OPERATOR SCE_B_IDENTIFIER SCE_B_DATE SCE_B_STRINGEOL SCE_B_KEYWORD2 SCE_B_KEYWORD3 SCE_B_KEYWORD4 SCE_B_CONSTANT SCE_B_ASM SCE_B_LABEL SCE_B_ERROR SCE_B_HEXNUMBER SCE_B_BINNUMBER SCE_PROPS_DEFAULT SCE_PROPS_COMMENT SCE_PROPS_SECTION SCE_PROPS_ASSIGNMENT SCE_PROPS_DEFVAL SCE_PROPS_KEY SCE_L_DEFAULT SCE_L_COMMAND SCE_L_TAG SCE_L_MATH SCE_L_COMMENT SCE_L_TAG2 SCE_L_MATH2 SCE_L_COMMENT2 SCE_L_VERBATIM SCE_L_SHORTCMD SCE_L_SPECIAL SCE_L_CMDOPT SCE_L_ERROR SCE_LUA_DEFAULT SCE_LUA_COMMENT SCE_LUA_COMMENTLINE SCE_LUA_COMMENTDOC SCE_LUA_NUMBER SCE_LUA_WORD SCE_LUA_STRING SCE_LUA_CHARACTER SCE_LUA_LITERALSTRING SCE_LUA_PREPROCESSOR SCE_LUA_OPERATOR SCE_LUA_IDENTIFIER SCE_LUA_STRINGEOL SCE_LUA_WORD2 SCE_LUA_WORD3 SCE_LUA_WORD4 SCE_LUA_WORD5 SCE_LUA_WORD6 SCE_LUA_WORD7 SCE_LUA_WORD8 SCE_LUA_LABEL SCE_ERR_DEFAULT SCE_ERR_PYTHON SCE_ERR_GCC SCE_ERR_MS SCE_ERR_CMD SCE_ERR_BORLAND SCE_ERR_PERL SCE_ERR_NET SCE_ERR_LUA SCE_ERR_CTAG SCE_ERR_DIFF_CHANGED SCE_ERR_DIFF_ADDITION SCE_ERR_DIFF_DELETION SCE_ERR_DIFF_MESSAGE SCE_ERR_PHP SCE_ERR_ELF SCE_ERR_IFC SCE_ERR_IFORT SCE_ERR_ABSF SCE_ERR_TIDY SCE_ERR_JAVA_STACK SCE_ERR_VALUE SCE_BAT_DEFAULT SCE_BAT_COMMENT SCE_BAT_WORD SCE_BAT_LABEL SCE_BAT_HIDE SCE_BAT_COMMAND SCE_BAT_IDENTIFIER SCE_BAT_OPERATOR SCE_TCMD_DEFAULT SCE_TCMD_COMMENT SCE_TCMD_WORD SCE_TCMD_LABEL SCE_TCMD_HIDE SCE_TCMD_COMMAND SCE_TCMD_IDENTIFIER SCE_TCMD_OPERATOR SCE_TCMD_ENVIRONMENT SCE_TCMD_EXPANSION SCE_TCMD_CLABEL SCE_MAKE_DEFAULT SCE_MAKE_COMMENT SCE_MAKE_PREPROCESSOR SCE_MAKE_IDENTIFIER SCE_MAKE_OPERATOR SCE_MAKE_TARGET SCE_MAKE_IDEOL SCE_DIFF_DEFAULT SCE_DIFF_COMMENT SCE_DIFF_COMMAND SCE_DIFF_HEADER SCE_DIFF_POSITION SCE_DIFF_DELETED SCE_DIFF_ADDED SCE_DIFF_CHANGED SCE_CONF_DEFAULT SCE_CONF_COMMENT SCE_CONF_NUMBER SCE_CONF_IDENTIFIER SCE_CONF_EXTENSION SCE_CONF_PARAMETER SCE_CONF_STRING SCE_CONF_OPERATOR SCE_CONF_IP SCE_CONF_DIRECTIVE SCE_AVE_DEFAULT SCE_AVE_COMMENT SCE_AVE_NUMBER SCE_AVE_WORD SCE_AVE_STRING SCE_AVE_ENUM SCE_AVE_STRINGEOL SCE_AVE_IDENTIFIER SCE_AVE_OPERATOR SCE_AVE_WORD1 SCE_AVE_WORD2 SCE_AVE_WORD3 SCE_AVE_WORD4 SCE_AVE_WORD5 SCE_AVE_WORD6 SCE_ADA_DEFAULT SCE_ADA_WORD SCE_ADA_IDENTIFIER SCE_ADA_NUMBER SCE_ADA_DELIMITER SCE_ADA_CHARACTER SCE_ADA_CHARACTEREOL SCE_ADA_STRING SCE_ADA_STRINGEOL SCE_ADA_LABEL SCE_ADA_COMMENTLINE SCE_ADA_ILLEGAL SCE_BAAN_DEFAULT SCE_BAAN_COMMENT SCE_BAAN_COMMENTDOC SCE_BAAN_NUMBER SCE_BAAN_WORD SCE_BAAN_STRING SCE_BAAN_PREPROCESSOR SCE_BAAN_OPERATOR SCE_BAAN_IDENTIFIER SCE_BAAN_STRINGEOL SCE_BAAN_WORD2 SCE_LISP_DEFAULT SCE_LISP_COMMENT SCE_LISP_NUMBER SCE_LISP_KEYWORD SCE_LISP_KEYWORD_KW SCE_LISP_SYMBOL SCE_LISP_STRING SCE_LISP_STRINGEOL SCE_LISP_IDENTIFIER SCE_LISP_OPERATOR SCE_LISP_SPECIAL SCE_LISP_MULTI_COMMENT SCE_EIFFEL_DEFAULT SCE_EIFFEL_COMMENTLINE SCE_EIFFEL_NUMBER SCE_EIFFEL_WORD SCE_EIFFEL_STRING SCE_EIFFEL_CHARACTER SCE_EIFFEL_OPERATOR SCE_EIFFEL_IDENTIFIER SCE_EIFFEL_STRINGEOL SCE_NNCRONTAB_DEFAULT SCE_NNCRONTAB_COMMENT SCE_NNCRONTAB_TASK SCE_NNCRONTAB_SECTION SCE_NNCRONTAB_KEYWORD SCE_NNCRONTAB_MODIFIER SCE_NNCRONTAB_ASTERISK SCE_NNCRONTAB_NUMBER SCE_NNCRONTAB_STRING SCE_NNCRONTAB_ENVIRONMENT SCE_NNCRONTAB_IDENTIFIER SCE_FORTH_DEFAULT SCE_FORTH_COMMENT SCE_FORTH_COMMENT_ML SCE_FORTH_IDENTIFIER SCE_FORTH_CONTROL SCE_FORTH_KEYWORD SCE_FORTH_DEFWORD SCE_FORTH_PREWORD1 SCE_FORTH_PREWORD2 SCE_FORTH_NUMBER SCE_FORTH_STRING SCE_FORTH_LOCALE SCE_MATLAB_DEFAULT SCE_MATLAB_COMMENT SCE_MATLAB_COMMAND SCE_MATLAB_NUMBER SCE_MATLAB_KEYWORD SCE_MATLAB_STRING SCE_MATLAB_OPERATOR SCE_MATLAB_IDENTIFIER SCE_MATLAB_DOUBLEQUOTESTRING SCE_SCRIPTOL_DEFAULT SCE_SCRIPTOL_WHITE SCE_SCRIPTOL_COMMENTLINE SCE_SCRIPTOL_PERSISTENT SCE_SCRIPTOL_CSTYLE SCE_SCRIPTOL_COMMENTBLOCK SCE_SCRIPTOL_NUMBER SCE_SCRIPTOL_STRING SCE_SCRIPTOL_CHARACTER SCE_SCRIPTOL_STRINGEOL SCE_SCRIPTOL_KEYWORD SCE_SCRIPTOL_OPERATOR SCE_SCRIPTOL_IDENTIFIER SCE_SCRIPTOL_TRIPLE SCE_SCRIPTOL_CLASSNAME SCE_SCRIPTOL_PREPROCESSOR SCE_ASM_DEFAULT SCE_ASM_COMMENT SCE_ASM_NUMBER SCE_ASM_STRING SCE_ASM_OPERATOR SCE_ASM_IDENTIFIER SCE_ASM_CPUINSTRUCTION SCE_ASM_MATHINSTRUCTION SCE_ASM_REGISTER SCE_ASM_DIRECTIVE SCE_ASM_DIRECTIVEOPERAND SCE_ASM_COMMENTBLOCK SCE_ASM_CHARACTER SCE_ASM_STRINGEOL SCE_ASM_EXTINSTRUCTION SCE_ASM_COMMENTDIRECTIVE SCE_F_DEFAULT SCE_F_COMMENT SCE_F_NUMBER SCE_F_STRING1 SCE_F_STRING2 SCE_F_STRINGEOL SCE_F_OPERATOR SCE_F_IDENTIFIER SCE_F_WORD SCE_F_WORD2 SCE_F_WORD3 SCE_F_PREPROCESSOR SCE_F_OPERATOR2 SCE_F_LABEL SCE_F_CONTINUATION SCE_CSS_DEFAULT SCE_CSS_TAG SCE_CSS_CLASS SCE_CSS_PSEUDOCLASS SCE_CSS_UNKNOWN_PSEUDOCLASS SCE_CSS_OPERATOR SCE_CSS_IDENTIFIER SCE_CSS_UNKNOWN_IDENTIFIER SCE_CSS_VALUE SCE_CSS_COMMENT SCE_CSS_ID SCE_CSS_IMPORTANT SCE_CSS_DIRECTIVE SCE_CSS_DOUBLESTRING SCE_CSS_SINGLESTRING SCE_CSS_IDENTIFIER2 SCE_CSS_ATTRIBUTE SCE_CSS_IDENTIFIER3 SCE_CSS_PSEUDOELEMENT SCE_CSS_EXTENDED_IDENTIFIER SCE_CSS_EXTENDED_PSEUDOCLASS SCE_CSS_EXTENDED_PSEUDOELEMENT SCE_CSS_MEDIA SCE_CSS_VARIABLE SCE_POV_DEFAULT SCE_POV_COMMENT SCE_POV_COMMENTLINE SCE_POV_NUMBER SCE_POV_OPERATOR SCE_POV_IDENTIFIER SCE_POV_STRING SCE_POV_STRINGEOL SCE_POV_DIRECTIVE SCE_POV_BADDIRECTIVE SCE_POV_WORD2 SCE_POV_WORD3 SCE_POV_WORD4 SCE_POV_WORD5 SCE_POV_WORD6 SCE_POV_WORD7 SCE_POV_WORD8 SCE_LOUT_DEFAULT SCE_LOUT_COMMENT SCE_LOUT_NUMBER SCE_LOUT_WORD SCE_LOUT_WORD2 SCE_LOUT_WORD3 SCE_LOUT_WORD4 SCE_LOUT_STRING SCE_LOUT_OPERATOR SCE_LOUT_IDENTIFIER SCE_LOUT_STRINGEOL SCE_ESCRIPT_DEFAULT SCE_ESCRIPT_COMMENT SCE_ESCRIPT_COMMENTLINE SCE_ESCRIPT_COMMENTDOC SCE_ESCRIPT_NUMBER SCE_ESCRIPT_WORD SCE_ESCRIPT_STRING SCE_ESCRIPT_OPERATOR SCE_ESCRIPT_IDENTIFIER SCE_ESCRIPT_BRACE SCE_ESCRIPT_WORD2 SCE_ESCRIPT_WORD3 SCE_PS_DEFAULT SCE_PS_COMMENT SCE_PS_DSC_COMMENT SCE_PS_DSC_VALUE SCE_PS_NUMBER SCE_PS_NAME SCE_PS_KEYWORD SCE_PS_LITERAL SCE_PS_IMMEVAL SCE_PS_PAREN_ARRAY SCE_PS_PAREN_DICT SCE_PS_PAREN_PROC SCE_PS_TEXT SCE_PS_HEXSTRING SCE_PS_BASE85STRING SCE_PS_BADSTRINGCHAR SCE_NSIS_DEFAULT SCE_NSIS_COMMENT SCE_NSIS_STRINGDQ SCE_NSIS_STRINGLQ SCE_NSIS_STRINGRQ SCE_NSIS_FUNCTION SCE_NSIS_VARIABLE SCE_NSIS_LABEL SCE_NSIS_USERDEFINED SCE_NSIS_SECTIONDEF SCE_NSIS_SUBSECTIONDEF SCE_NSIS_IFDEFINEDEF SCE_NSIS_MACRODEF SCE_NSIS_STRINGVAR SCE_NSIS_NUMBER SCE_NSIS_SECTIONGROUP SCE_NSIS_PAGEEX SCE_NSIS_FUNCTIONDEF SCE_NSIS_COMMENTBOX SCE_MMIXAL_LEADWS SCE_MMIXAL_COMMENT SCE_MMIXAL_LABEL SCE_MMIXAL_OPCODE SCE_MMIXAL_OPCODE_PRE SCE_MMIXAL_OPCODE_VALID SCE_MMIXAL_OPCODE_UNKNOWN SCE_MMIXAL_OPCODE_POST SCE_MMIXAL_OPERANDS SCE_MMIXAL_NUMBER SCE_MMIXAL_REF SCE_MMIXAL_CHAR SCE_MMIXAL_STRING SCE_MMIXAL_REGISTER SCE_MMIXAL_HEX SCE_MMIXAL_OPERATOR SCE_MMIXAL_SYMBOL SCE_MMIXAL_INCLUDE SCE_CLW_DEFAULT SCE_CLW_LABEL SCE_CLW_COMMENT SCE_CLW_STRING SCE_CLW_USER_IDENTIFIER SCE_CLW_INTEGER_CONSTANT SCE_CLW_REAL_CONSTANT SCE_CLW_PICTURE_STRING SCE_CLW_KEYWORD SCE_CLW_COMPILER_DIRECTIVE SCE_CLW_RUNTIME_EXPRESSIONS SCE_CLW_BUILTIN_PROCEDURES_FUNCTION SCE_CLW_STRUCTURE_DATA_TYPE SCE_CLW_ATTRIBUTE SCE_CLW_STANDARD_EQUATE SCE_CLW_ERROR SCE_CLW_DEPRECATED SCE_LOT_DEFAULT SCE_LOT_HEADER SCE_LOT_BREAK SCE_LOT_SET SCE_LOT_PASS SCE_LOT_FAIL SCE_LOT_ABORT SCE_YAML_DEFAULT SCE_YAML_COMMENT SCE_YAML_IDENTIFIER SCE_YAML_KEYWORD SCE_YAML_NUMBER SCE_YAML_REFERENCE SCE_YAML_DOCUMENT SCE_YAML_TEXT SCE_YAML_ERROR SCE_YAML_OPERATOR SCE_TEX_DEFAULT SCE_TEX_SPECIAL SCE_TEX_GROUP SCE_TEX_SYMBOL SCE_TEX_COMMAND SCE_TEX_TEXT SCE_METAPOST_DEFAULT SCE_METAPOST_SPECIAL SCE_METAPOST_GROUP SCE_METAPOST_SYMBOL SCE_METAPOST_COMMAND SCE_METAPOST_TEXT SCE_METAPOST_EXTRA SCE_ERLANG_DEFAULT SCE_ERLANG_COMMENT SCE_ERLANG_VARIABLE SCE_ERLANG_NUMBER SCE_ERLANG_KEYWORD SCE_ERLANG_STRING SCE_ERLANG_OPERATOR SCE_ERLANG_ATOM SCE_ERLANG_FUNCTION_NAME SCE_ERLANG_CHARACTER SCE_ERLANG_MACRO SCE_ERLANG_RECORD SCE_ERLANG_PREPROC SCE_ERLANG_NODE_NAME SCE_ERLANG_COMMENT_FUNCTION SCE_ERLANG_COMMENT_MODULE SCE_ERLANG_COMMENT_DOC SCE_ERLANG_COMMENT_DOC_MACRO SCE_ERLANG_ATOM_QUOTED SCE_ERLANG_MACRO_QUOTED SCE_ERLANG_RECORD_QUOTED SCE_ERLANG_NODE_NAME_QUOTED SCE_ERLANG_BIFS SCE_ERLANG_MODULES SCE_ERLANG_MODULES_ATT SCE_ERLANG_UNKNOWN SCE_MSSQL_DEFAULT SCE_MSSQL_COMMENT SCE_MSSQL_LINE_COMMENT SCE_MSSQL_NUMBER SCE_MSSQL_STRING SCE_MSSQL_OPERATOR SCE_MSSQL_IDENTIFIER SCE_MSSQL_VARIABLE SCE_MSSQL_COLUMN_NAME SCE_MSSQL_STATEMENT SCE_MSSQL_DATATYPE SCE_MSSQL_SYSTABLE SCE_MSSQL_GLOBAL_VARIABLE SCE_MSSQL_FUNCTION SCE_MSSQL_STORED_PROCEDURE SCE_MSSQL_DEFAULT_PREF_DATATYPE SCE_MSSQL_COLUMN_NAME_2 SCE_V_DEFAULT SCE_V_COMMENT SCE_V_COMMENTLINE SCE_V_COMMENTLINEBANG SCE_V_NUMBER SCE_V_WORD SCE_V_STRING SCE_V_WORD2 SCE_V_WORD3 SCE_V_PREPROCESSOR SCE_V_OPERATOR SCE_V_IDENTIFIER SCE_V_STRINGEOL SCE_V_USER SCE_KIX_DEFAULT SCE_KIX_COMMENT SCE_KIX_STRING1 SCE_KIX_STRING2 SCE_KIX_NUMBER SCE_KIX_VAR SCE_KIX_MACRO SCE_KIX_KEYWORD SCE_KIX_FUNCTIONS SCE_KIX_OPERATOR SCE_KIX_IDENTIFIER SCE_GC_DEFAULT SCE_GC_COMMENTLINE SCE_GC_COMMENTBLOCK SCE_GC_GLOBAL SCE_GC_EVENT SCE_GC_ATTRIBUTE SCE_GC_CONTROL SCE_GC_COMMAND SCE_GC_STRING SCE_GC_OPERATOR SCE_SN_DEFAULT SCE_SN_CODE SCE_SN_COMMENTLINE SCE_SN_COMMENTLINEBANG SCE_SN_NUMBER SCE_SN_WORD SCE_SN_STRING SCE_SN_WORD2 SCE_SN_WORD3 SCE_SN_PREPROCESSOR SCE_SN_OPERATOR SCE_SN_IDENTIFIER SCE_SN_STRINGEOL SCE_SN_REGEXTAG SCE_SN_SIGNAL SCE_SN_USER SCE_AU3_DEFAULT SCE_AU3_COMMENT SCE_AU3_COMMENTBLOCK SCE_AU3_NUMBER SCE_AU3_FUNCTION SCE_AU3_KEYWORD SCE_AU3_MACRO SCE_AU3_STRING SCE_AU3_OPERATOR SCE_AU3_VARIABLE SCE_AU3_SENT SCE_AU3_PREPROCESSOR SCE_AU3_SPECIAL SCE_AU3_EXPAND SCE_AU3_COMOBJ SCE_AU3_UDF SCE_APDL_DEFAULT SCE_APDL_COMMENT SCE_APDL_COMMENTBLOCK SCE_APDL_NUMBER SCE_APDL_STRING SCE_APDL_OPERATOR SCE_APDL_WORD SCE_APDL_PROCESSOR SCE_APDL_COMMAND SCE_APDL_SLASHCOMMAND SCE_APDL_STARCOMMAND SCE_APDL_ARGUMENT SCE_APDL_FUNCTION SCE_SH_DEFAULT SCE_SH_ERROR SCE_SH_COMMENTLINE SCE_SH_NUMBER SCE_SH_WORD SCE_SH_STRING SCE_SH_CHARACTER SCE_SH_OPERATOR SCE_SH_IDENTIFIER SCE_SH_SCALAR SCE_SH_PARAM SCE_SH_BACKTICKS SCE_SH_HERE_DELIM SCE_SH_HERE_Q SCE_ASN1_DEFAULT SCE_ASN1_COMMENT SCE_ASN1_IDENTIFIER SCE_ASN1_STRING SCE_ASN1_OID SCE_ASN1_SCALAR SCE_ASN1_KEYWORD SCE_ASN1_ATTRIBUTE SCE_ASN1_DESCRIPTOR SCE_ASN1_TYPE SCE_ASN1_OPERATOR SCE_VHDL_DEFAULT SCE_VHDL_COMMENT SCE_VHDL_COMMENTLINEBANG SCE_VHDL_NUMBER SCE_VHDL_STRING SCE_VHDL_OPERATOR SCE_VHDL_IDENTIFIER SCE_VHDL_STRINGEOL SCE_VHDL_KEYWORD SCE_VHDL_STDOPERATOR SCE_VHDL_ATTRIBUTE SCE_VHDL_STDFUNCTION SCE_VHDL_STDPACKAGE SCE_VHDL_STDTYPE SCE_VHDL_USERWORD SCE_CAML_DEFAULT SCE_CAML_IDENTIFIER SCE_CAML_TAGNAME SCE_CAML_KEYWORD SCE_CAML_KEYWORD2 SCE_CAML_KEYWORD3 SCE_CAML_LINENUM SCE_CAML_OPERATOR SCE_CAML_NUMBER SCE_CAML_CHAR SCE_CAML_WHITE SCE_CAML_STRING SCE_CAML_COMMENT SCE_CAML_COMMENT1 SCE_CAML_COMMENT2 SCE_CAML_COMMENT3 SCE_HA_DEFAULT SCE_HA_IDENTIFIER SCE_HA_KEYWORD SCE_HA_NUMBER SCE_HA_STRING SCE_HA_CHARACTER SCE_HA_CLASS SCE_HA_MODULE SCE_HA_CAPITAL SCE_HA_DATA SCE_HA_IMPORT SCE_HA_OPERATOR SCE_HA_INSTANCE SCE_HA_COMMENTLINE SCE_HA_COMMENTBLOCK SCE_HA_COMMENTBLOCK2 SCE_HA_COMMENTBLOCK3 SCE_T3_DEFAULT SCE_T3_X_DEFAULT SCE_T3_PREPROCESSOR SCE_T3_BLOCK_COMMENT SCE_T3_LINE_COMMENT SCE_T3_OPERATOR SCE_T3_KEYWORD SCE_T3_NUMBER SCE_T3_IDENTIFIER SCE_T3_S_STRING SCE_T3_D_STRING SCE_T3_X_STRING SCE_T3_LIB_DIRECTIVE SCE_T3_MSG_PARAM SCE_T3_HTML_TAG SCE_T3_HTML_DEFAULT SCE_T3_HTML_STRING SCE_T3_USER1 SCE_T3_USER2 SCE_T3_USER3 SCE_T3_BRACE SCE_REBOL_DEFAULT SCE_REBOL_COMMENTLINE SCE_REBOL_COMMENTBLOCK SCE_REBOL_PREFACE SCE_REBOL_OPERATOR SCE_REBOL_CHARACTER SCE_REBOL_QUOTEDSTRING SCE_REBOL_BRACEDSTRING SCE_REBOL_NUMBER SCE_REBOL_PAIR SCE_REBOL_TUPLE SCE_REBOL_BINARY SCE_REBOL_MONEY SCE_REBOL_ISSUE SCE_REBOL_TAG SCE_REBOL_FILE SCE_REBOL_EMAIL SCE_REBOL_URL SCE_REBOL_DATE SCE_REBOL_TIME SCE_REBOL_IDENTIFIER SCE_REBOL_WORD SCE_REBOL_WORD2 SCE_REBOL_WORD3 SCE_REBOL_WORD4 SCE_REBOL_WORD5 SCE_REBOL_WORD6 SCE_REBOL_WORD7 SCE_REBOL_WORD8 SCE_SQL_DEFAULT SCE_SQL_COMMENT SCE_SQL_COMMENTLINE SCE_SQL_COMMENTDOC SCE_SQL_NUMBER SCE_SQL_WORD SCE_SQL_STRING SCE_SQL_CHARACTER SCE_SQL_SQLPLUS SCE_SQL_SQLPLUS_PROMPT SCE_SQL_OPERATOR SCE_SQL_IDENTIFIER SCE_SQL_SQLPLUS_COMMENT SCE_SQL_COMMENTLINEDOC SCE_SQL_WORD2 SCE_SQL_COMMENTDOCKEYWORD SCE_SQL_COMMENTDOCKEYWORDERROR SCE_SQL_USER1 SCE_SQL_USER2 SCE_SQL_USER3 SCE_SQL_USER4 SCE_SQL_QUOTEDIDENTIFIER SCE_ST_DEFAULT SCE_ST_STRING SCE_ST_NUMBER SCE_ST_COMMENT SCE_ST_SYMBOL SCE_ST_BINARY SCE_ST_BOOL SCE_ST_SELF SCE_ST_SUPER SCE_ST_NIL SCE_ST_GLOBAL SCE_ST_RETURN SCE_ST_SPECIAL SCE_ST_KWSEND SCE_ST_ASSIGN SCE_ST_CHARACTER SCE_ST_SPEC_SEL SCE_FS_DEFAULT SCE_FS_COMMENT SCE_FS_COMMENTLINE SCE_FS_COMMENTDOC SCE_FS_COMMENTLINEDOC SCE_FS_COMMENTDOCKEYWORD SCE_FS_COMMENTDOCKEYWORDERROR SCE_FS_KEYWORD SCE_FS_KEYWORD2 SCE_FS_KEYWORD3 SCE_FS_KEYWORD4 SCE_FS_NUMBER SCE_FS_STRING SCE_FS_PREPROCESSOR SCE_FS_OPERATOR SCE_FS_IDENTIFIER SCE_FS_DATE SCE_FS_STRINGEOL SCE_FS_CONSTANT SCE_FS_WORDOPERATOR SCE_FS_DISABLEDCODE SCE_FS_DEFAULT_C SCE_FS_COMMENTDOC_C SCE_FS_COMMENTLINEDOC_C SCE_FS_KEYWORD_C SCE_FS_KEYWORD2_C SCE_FS_NUMBER_C SCE_FS_STRING_C SCE_FS_PREPROCESSOR_C SCE_FS_OPERATOR_C SCE_FS_IDENTIFIER_C SCE_FS_STRINGEOL_C SCE_CSOUND_DEFAULT SCE_CSOUND_COMMENT SCE_CSOUND_NUMBER SCE_CSOUND_OPERATOR SCE_CSOUND_INSTR SCE_CSOUND_IDENTIFIER SCE_CSOUND_OPCODE SCE_CSOUND_HEADERSTMT SCE_CSOUND_USERKEYWORD SCE_CSOUND_COMMENTBLOCK SCE_CSOUND_PARAM SCE_CSOUND_ARATE_VAR SCE_CSOUND_KRATE_VAR SCE_CSOUND_IRATE_VAR SCE_CSOUND_GLOBAL_VAR SCE_CSOUND_STRINGEOL SCE_INNO_DEFAULT SCE_INNO_COMMENT SCE_INNO_KEYWORD SCE_INNO_PARAMETER SCE_INNO_SECTION SCE_INNO_PREPROC SCE_INNO_INLINE_EXPANSION SCE_INNO_COMMENT_PASCAL SCE_INNO_KEYWORD_PASCAL SCE_INNO_KEYWORD_USER SCE_INNO_STRING_DOUBLE SCE_INNO_STRING_SINGLE SCE_INNO_IDENTIFIER SCE_OPAL_SPACE SCE_OPAL_COMMENT_BLOCK SCE_OPAL_COMMENT_LINE SCE_OPAL_INTEGER SCE_OPAL_KEYWORD SCE_OPAL_SORT SCE_OPAL_STRING SCE_OPAL_PAR SCE_OPAL_BOOL_CONST SCE_OPAL_DEFAULT SCE_SPICE_DEFAULT SCE_SPICE_IDENTIFIER SCE_SPICE_KEYWORD SCE_SPICE_KEYWORD2 SCE_SPICE_KEYWORD3 SCE_SPICE_NUMBER SCE_SPICE_DELIMITER SCE_SPICE_VALUE SCE_SPICE_COMMENTLINE SCE_CMAKE_DEFAULT SCE_CMAKE_COMMENT SCE_CMAKE_STRINGDQ SCE_CMAKE_STRINGLQ SCE_CMAKE_STRINGRQ SCE_CMAKE_COMMANDS SCE_CMAKE_PARAMETERS SCE_CMAKE_VARIABLE SCE_CMAKE_USERDEFINED SCE_CMAKE_WHILEDEF SCE_CMAKE_FOREACHDEF SCE_CMAKE_IFDEFINEDEF SCE_CMAKE_MACRODEF SCE_CMAKE_STRINGVAR SCE_CMAKE_NUMBER SCE_GAP_DEFAULT SCE_GAP_IDENTIFIER SCE_GAP_KEYWORD SCE_GAP_KEYWORD2 SCE_GAP_KEYWORD3 SCE_GAP_KEYWORD4 SCE_GAP_STRING SCE_GAP_CHAR SCE_GAP_OPERATOR SCE_GAP_COMMENT SCE_GAP_NUMBER SCE_GAP_STRINGEOL SCE_PLM_DEFAULT SCE_PLM_COMMENT SCE_PLM_STRING SCE_PLM_NUMBER SCE_PLM_IDENTIFIER SCE_PLM_OPERATOR SCE_PLM_CONTROL SCE_PLM_KEYWORD SCE_4GL_DEFAULT SCE_4GL_NUMBER SCE_4GL_WORD SCE_4GL_STRING SCE_4GL_CHARACTER SCE_4GL_PREPROCESSOR SCE_4GL_OPERATOR SCE_4GL_IDENTIFIER SCE_4GL_BLOCK SCE_4GL_END SCE_4GL_COMMENT1 SCE_4GL_COMMENT2 SCE_4GL_COMMENT3 SCE_4GL_COMMENT4 SCE_4GL_COMMENT5 SCE_4GL_COMMENT6 SCE_4GL_DEFAULT_ SCE_4GL_NUMBER_ SCE_4GL_WORD_ SCE_4GL_STRING_ SCE_4GL_CHARACTER_ SCE_4GL_PREPROCESSOR_ SCE_4GL_OPERATOR_ SCE_4GL_IDENTIFIER_ SCE_4GL_BLOCK_ SCE_4GL_END_ SCE_4GL_COMMENT1_ SCE_4GL_COMMENT2_ SCE_4GL_COMMENT3_ SCE_4GL_COMMENT4_ SCE_4GL_COMMENT5_ SCE_4GL_COMMENT6_ SCE_ABAQUS_DEFAULT SCE_ABAQUS_COMMENT SCE_ABAQUS_COMMENTBLOCK SCE_ABAQUS_NUMBER SCE_ABAQUS_STRING SCE_ABAQUS_OPERATOR SCE_ABAQUS_WORD SCE_ABAQUS_PROCESSOR SCE_ABAQUS_COMMAND SCE_ABAQUS_SLASHCOMMAND SCE_ABAQUS_STARCOMMAND SCE_ABAQUS_ARGUMENT SCE_ABAQUS_FUNCTION SCE_ASY_DEFAULT SCE_ASY_COMMENT SCE_ASY_COMMENTLINE SCE_ASY_NUMBER SCE_ASY_WORD SCE_ASY_STRING SCE_ASY_CHARACTER SCE_ASY_OPERATOR SCE_ASY_IDENTIFIER SCE_ASY_STRINGEOL SCE_ASY_COMMENTLINEDOC SCE_ASY_WORD2 SCE_R_DEFAULT SCE_R_COMMENT SCE_R_KWORD SCE_R_BASEKWORD SCE_R_OTHERKWORD SCE_R_NUMBER SCE_R_STRING SCE_R_STRING2 SCE_R_OPERATOR SCE_R_IDENTIFIER SCE_R_INFIX SCE_R_INFIXEOL SCE_MAGIK_DEFAULT SCE_MAGIK_COMMENT SCE_MAGIK_HYPER_COMMENT SCE_MAGIK_STRING SCE_MAGIK_CHARACTER SCE_MAGIK_NUMBER SCE_MAGIK_IDENTIFIER SCE_MAGIK_OPERATOR SCE_MAGIK_FLOW SCE_MAGIK_CONTAINER SCE_MAGIK_BRACKET_BLOCK SCE_MAGIK_BRACE_BLOCK SCE_MAGIK_SQBRACKET_BLOCK SCE_MAGIK_UNKNOWN_KEYWORD SCE_MAGIK_KEYWORD SCE_MAGIK_PRAGMA SCE_MAGIK_SYMBOL SCE_POWERSHELL_DEFAULT SCE_POWERSHELL_COMMENT SCE_POWERSHELL_STRING SCE_POWERSHELL_CHARACTER SCE_POWERSHELL_NUMBER SCE_POWERSHELL_VARIABLE SCE_POWERSHELL_OPERATOR SCE_POWERSHELL_IDENTIFIER SCE_POWERSHELL_KEYWORD SCE_POWERSHELL_CMDLET SCE_POWERSHELL_ALIAS SCE_POWERSHELL_FUNCTION SCE_POWERSHELL_USER1 SCE_POWERSHELL_COMMENTSTREAM SCE_MYSQL_DEFAULT SCE_MYSQL_COMMENT SCE_MYSQL_COMMENTLINE SCE_MYSQL_VARIABLE SCE_MYSQL_SYSTEMVARIABLE SCE_MYSQL_KNOWNSYSTEMVARIABLE SCE_MYSQL_NUMBER SCE_MYSQL_MAJORKEYWORD SCE_MYSQL_KEYWORD SCE_MYSQL_DATABASEOBJECT SCE_MYSQL_PROCEDUREKEYWORD SCE_MYSQL_STRING SCE_MYSQL_SQSTRING SCE_MYSQL_DQSTRING SCE_MYSQL_OPERATOR SCE_MYSQL_FUNCTION SCE_MYSQL_IDENTIFIER SCE_MYSQL_QUOTEDIDENTIFIER SCE_MYSQL_USER1 SCE_MYSQL_USER2 SCE_MYSQL_USER3 SCE_MYSQL_HIDDENCOMMAND SCE_PO_DEFAULT SCE_PO_COMMENT SCE_PO_MSGID SCE_PO_MSGID_TEXT SCE_PO_MSGSTR SCE_PO_MSGSTR_TEXT SCE_PO_MSGCTXT SCE_PO_MSGCTXT_TEXT SCE_PO_FUZZY SCE_PAS_DEFAULT SCE_PAS_IDENTIFIER SCE_PAS_COMMENT SCE_PAS_COMMENT2 SCE_PAS_COMMENTLINE SCE_PAS_PREPROCESSOR SCE_PAS_PREPROCESSOR2 SCE_PAS_NUMBER SCE_PAS_HEXNUMBER SCE_PAS_WORD SCE_PAS_STRING SCE_PAS_STRINGEOL SCE_PAS_CHARACTER SCE_PAS_OPERATOR SCE_PAS_ASM SCE_SORCUS_DEFAULT SCE_SORCUS_COMMAND SCE_SORCUS_PARAMETER SCE_SORCUS_COMMENTLINE SCE_SORCUS_STRING SCE_SORCUS_STRINGEOL SCE_SORCUS_IDENTIFIER SCE_SORCUS_OPERATOR SCE_SORCUS_NUMBER SCE_SORCUS_CONSTANT SCE_POWERPRO_DEFAULT SCE_POWERPRO_COMMENTBLOCK SCE_POWERPRO_COMMENTLINE SCE_POWERPRO_NUMBER SCE_POWERPRO_WORD SCE_POWERPRO_WORD2 SCE_POWERPRO_WORD3 SCE_POWERPRO_WORD4 SCE_POWERPRO_DOUBLEQUOTEDSTRING SCE_POWERPRO_SINGLEQUOTEDSTRING SCE_POWERPRO_LINECONTINUE SCE_POWERPRO_OPERATOR SCE_POWERPRO_IDENTIFIER SCE_POWERPRO_STRINGEOL SCE_POWERPRO_VERBATIM SCE_POWERPRO_ALTQUOTE SCE_POWERPRO_FUNCTION SCE_SML_DEFAULT SCE_SML_IDENTIFIER SCE_SML_TAGNAME SCE_SML_KEYWORD SCE_SML_KEYWORD2 SCE_SML_KEYWORD3 SCE_SML_LINENUM SCE_SML_OPERATOR SCE_SML_NUMBER SCE_SML_CHAR SCE_SML_STRING SCE_SML_COMMENT SCE_SML_COMMENT1 SCE_SML_COMMENT2 SCE_SML_COMMENT3 SCE_MARKDOWN_DEFAULT SCE_MARKDOWN_LINE_BEGIN SCE_MARKDOWN_STRONG1 SCE_MARKDOWN_STRONG2 SCE_MARKDOWN_EM1 SCE_MARKDOWN_EM2 SCE_MARKDOWN_HEADER1 SCE_MARKDOWN_HEADER2 SCE_MARKDOWN_HEADER3 SCE_MARKDOWN_HEADER4 SCE_MARKDOWN_HEADER5 SCE_MARKDOWN_HEADER6 SCE_MARKDOWN_PRECHAR SCE_MARKDOWN_ULIST_ITEM SCE_MARKDOWN_OLIST_ITEM SCE_MARKDOWN_BLOCKQUOTE SCE_MARKDOWN_STRIKEOUT SCE_MARKDOWN_HRULE SCE_MARKDOWN_LINK SCE_MARKDOWN_CODE SCE_MARKDOWN_CODE2 SCE_MARKDOWN_CODEBK SCE_TXT2TAGS_DEFAULT SCE_TXT2TAGS_LINE_BEGIN SCE_TXT2TAGS_STRONG1 SCE_TXT2TAGS_STRONG2 SCE_TXT2TAGS_EM1 SCE_TXT2TAGS_EM2 SCE_TXT2TAGS_HEADER1 SCE_TXT2TAGS_HEADER2 SCE_TXT2TAGS_HEADER3 SCE_TXT2TAGS_HEADER4 SCE_TXT2TAGS_HEADER5 SCE_TXT2TAGS_HEADER6 SCE_TXT2TAGS_PRECHAR SCE_TXT2TAGS_ULIST_ITEM SCE_TXT2TAGS_OLIST_ITEM SCE_TXT2TAGS_BLOCKQUOTE SCE_TXT2TAGS_STRIKEOUT SCE_TXT2TAGS_HRULE SCE_TXT2TAGS_LINK SCE_TXT2TAGS_CODE SCE_TXT2TAGS_CODE2 SCE_TXT2TAGS_CODEBK SCE_TXT2TAGS_COMMENT SCE_TXT2TAGS_OPTION SCE_TXT2TAGS_PREPROC SCE_TXT2TAGS_POSTPROC SCE_A68K_DEFAULT SCE_A68K_COMMENT SCE_A68K_NUMBER_DEC SCE_A68K_NUMBER_BIN SCE_A68K_NUMBER_HEX SCE_A68K_STRING1 SCE_A68K_OPERATOR SCE_A68K_CPUINSTRUCTION SCE_A68K_EXTINSTRUCTION SCE_A68K_REGISTER SCE_A68K_DIRECTIVE SCE_A68K_MACRO_ARG SCE_A68K_LABEL SCE_A68K_STRING2 SCE_A68K_IDENTIFIER SCE_A68K_MACRO_DECLARATION SCE_A68K_COMMENT_WORD SCE_A68K_COMMENT_SPECIAL SCE_A68K_COMMENT_DOXYGEN SCE_MODULA_DEFAULT SCE_MODULA_COMMENT SCE_MODULA_DOXYCOMM SCE_MODULA_DOXYKEY SCE_MODULA_KEYWORD SCE_MODULA_RESERVED SCE_MODULA_NUMBER SCE_MODULA_BASENUM SCE_MODULA_FLOAT SCE_MODULA_STRING SCE_MODULA_STRSPEC SCE_MODULA_CHAR SCE_MODULA_CHARSPEC SCE_MODULA_PROC SCE_MODULA_PRAGMA SCE_MODULA_PRGKEY SCE_MODULA_OPERATOR SCE_MODULA_BADSTR SCE_COFFEESCRIPT_DEFAULT SCE_COFFEESCRIPT_COMMENT SCE_COFFEESCRIPT_COMMENTLINE SCE_COFFEESCRIPT_COMMENTDOC SCE_COFFEESCRIPT_NUMBER SCE_COFFEESCRIPT_WORD SCE_COFFEESCRIPT_STRING SCE_COFFEESCRIPT_CHARACTER SCE_COFFEESCRIPT_UUID SCE_COFFEESCRIPT_PREPROCESSOR SCE_COFFEESCRIPT_OPERATOR SCE_COFFEESCRIPT_IDENTIFIER SCE_COFFEESCRIPT_STRINGEOL SCE_COFFEESCRIPT_VERBATIM SCE_COFFEESCRIPT_REGEX SCE_COFFEESCRIPT_COMMENTLINEDOC SCE_COFFEESCRIPT_WORD2 SCE_COFFEESCRIPT_COMMENTDOCKEYWORD SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR SCE_COFFEESCRIPT_GLOBALCLASS SCE_COFFEESCRIPT_STRINGRAW SCE_COFFEESCRIPT_TRIPLEVERBATIM SCE_COFFEESCRIPT_HASHQUOTEDSTRING SCE_COFFEESCRIPT_COMMENTBLOCK SCE_COFFEESCRIPT_VERBOSE_REGEX SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT SCE_AVS_DEFAULT SCE_AVS_COMMENTBLOCK SCE_AVS_COMMENTBLOCKN SCE_AVS_COMMENTLINE SCE_AVS_NUMBER SCE_AVS_OPERATOR SCE_AVS_IDENTIFIER SCE_AVS_STRING SCE_AVS_TRIPLESTRING SCE_AVS_KEYWORD SCE_AVS_FILTER SCE_AVS_PLUGIN SCE_AVS_FUNCTION SCE_AVS_CLIPPROP SCE_AVS_USERDFN SCE_ECL_DEFAULT SCE_ECL_COMMENT SCE_ECL_COMMENTLINE SCE_ECL_NUMBER SCE_ECL_STRING SCE_ECL_WORD0 SCE_ECL_OPERATOR SCE_ECL_CHARACTER SCE_ECL_UUID SCE_ECL_PREPROCESSOR SCE_ECL_UNKNOWN SCE_ECL_IDENTIFIER SCE_ECL_STRINGEOL SCE_ECL_VERBATIM SCE_ECL_REGEX SCE_ECL_COMMENTLINEDOC SCE_ECL_WORD1 SCE_ECL_COMMENTDOCKEYWORD SCE_ECL_COMMENTDOCKEYWORDERROR SCE_ECL_WORD2 SCE_ECL_WORD3 SCE_ECL_WORD4 SCE_ECL_WORD5 SCE_ECL_COMMENTDOC SCE_ECL_ADDED SCE_ECL_DELETED SCE_ECL_CHANGED SCE_ECL_MOVED SC_CP_DBCS ); use constant { INVALID_POSITION => -1, # Define start of Scintilla messages to be greater than all Windows edit (EM_*) messages # as many EM_ messages can be used although that use is deprecated. SCI_START => 2000, SCI_OPTIONAL_START => 3000, SCI_LEXER_START => 4000, # WhiteSpace enumeration SCWS_INVISIBLE => 0, SCWS_VISIBLEALWAYS => 1, SCWS_VISIBLEAFTERINDENT => 2, # EndOfLine enumeration SC_EOL_CRLF => 0, SC_EOL_CR => 1, SC_EOL_LF => 2, # The SC_CP_UTF8 value can be used to enter Unicode mode. # This is the same value as CP_UTF8 in Windows SC_CP_UTF8 => 65001, # MarkerSymbol enumeration MARKER_MAX => 31, SC_MARK_CIRCLE => 0, SC_MARK_ROUNDRECT => 1, SC_MARK_ARROW => 2, SC_MARK_SMALLRECT => 3, SC_MARK_SHORTARROW => 4, SC_MARK_EMPTY => 5, SC_MARK_ARROWDOWN => 6, SC_MARK_MINUS => 7, SC_MARK_PLUS => 8, # Shapes used for outlining column. SC_MARK_VLINE => 9, SC_MARK_LCORNER => 10, SC_MARK_TCORNER => 11, SC_MARK_BOXPLUS => 12, SC_MARK_BOXPLUSCONNECTED => 13, SC_MARK_BOXMINUS => 14, SC_MARK_BOXMINUSCONNECTED => 15, SC_MARK_LCORNERCURVE => 16, SC_MARK_TCORNERCURVE => 17, SC_MARK_CIRCLEPLUS => 18, SC_MARK_CIRCLEPLUSCONNECTED => 19, SC_MARK_CIRCLEMINUS => 20, SC_MARK_CIRCLEMINUSCONNECTED => 21, # Invisible mark that only sets the line background colour. SC_MARK_BACKGROUND => 22, SC_MARK_DOTDOTDOT => 23, SC_MARK_ARROWS => 24, SC_MARK_PIXMAP => 25, SC_MARK_FULLRECT => 26, SC_MARK_LEFTRECT => 27, SC_MARK_AVAILABLE => 28, SC_MARK_UNDERLINE => 29, SC_MARK_RGBAIMAGE => 30, SC_MARK_CHARACTER => 10000, # MarkerOutline enumeration # Markers used for outlining column. SC_MARKNUM_FOLDEREND => 25, SC_MARKNUM_FOLDEROPENMID => 26, SC_MARKNUM_FOLDERMIDTAIL => 27, SC_MARKNUM_FOLDERTAIL => 28, SC_MARKNUM_FOLDERSUB => 29, SC_MARKNUM_FOLDER => 30, SC_MARKNUM_FOLDEROPEN => 31, SC_MASK_FOLDERS => 0xFE000000, # MarginType enumeration SC_MARGIN_SYMBOL => 0, SC_MARGIN_NUMBER => 1, SC_MARGIN_BACK => 2, SC_MARGIN_FORE => 3, SC_MARGIN_TEXT => 4, SC_MARGIN_RTEXT => 5, # StylesCommon enumeration STYLE_DEFAULT => 32, STYLE_LINENUMBER => 33, STYLE_BRACELIGHT => 34, STYLE_BRACEBAD => 35, STYLE_CONTROLCHAR => 36, STYLE_INDENTGUIDE => 37, STYLE_CALLTIP => 38, STYLE_LASTPREDEFINED => 39, STYLE_MAX => 255, # CharacterSet enumeration SC_CHARSET_ANSI => 0, SC_CHARSET_DEFAULT => 1, SC_CHARSET_BALTIC => 186, SC_CHARSET_CHINESEBIG5 => 136, SC_CHARSET_EASTEUROPE => 238, SC_CHARSET_GB2312 => 134, SC_CHARSET_GREEK => 161, SC_CHARSET_HANGUL => 129, SC_CHARSET_MAC => 77, SC_CHARSET_OEM => 255, SC_CHARSET_RUSSIAN => 204, SC_CHARSET_CYRILLIC => 1251, SC_CHARSET_SHIFTJIS => 128, SC_CHARSET_SYMBOL => 2, SC_CHARSET_TURKISH => 162, SC_CHARSET_JOHAB => 130, SC_CHARSET_HEBREW => 177, SC_CHARSET_ARABIC => 178, SC_CHARSET_VIETNAMESE => 163, SC_CHARSET_THAI => 222, SC_CHARSET_8859_15 => 1000, # CaseVisible enumeration SC_CASE_MIXED => 0, SC_CASE_UPPER => 1, SC_CASE_LOWER => 2, SC_FONT_SIZE_MULTIPLIER => 100, # FontWeight enumeration SC_WEIGHT_NORMAL => 400, SC_WEIGHT_SEMIBOLD => 600, SC_WEIGHT_BOLD => 700, # IndicatorStyle enumeration INDIC_PLAIN => 0, INDIC_SQUIGGLE => 1, INDIC_TT => 2, INDIC_DIAGONAL => 3, INDIC_STRIKE => 4, INDIC_HIDDEN => 5, INDIC_BOX => 6, INDIC_ROUNDBOX => 7, INDIC_STRAIGHTBOX => 8, INDIC_DASH => 9, INDIC_DOTS => 10, INDIC_SQUIGGLELOW => 11, INDIC_DOTBOX => 12, INDIC_MAX => 31, INDIC_CONTAINER => 8, INDIC0_MASK => 0x20, INDIC1_MASK => 0x40, INDIC2_MASK => 0x80, INDICS_MASK => 0xE0, # IndentView enumeration SC_IV_NONE => 0, SC_IV_REAL => 1, SC_IV_LOOKFORWARD => 2, SC_IV_LOOKBOTH => 3, # PrintOption enumeration # PrintColourMode - use same colours as screen. SC_PRINT_NORMAL => 0, # PrintColourMode - invert the light value of each style for printing. SC_PRINT_INVERTLIGHT => 1, # PrintColourMode - force black text on white background for printing. SC_PRINT_BLACKONWHITE => 2, # PrintColourMode - text stays coloured, but all background is forced to be white for printing. SC_PRINT_COLOURONWHITE => 3, # PrintColourMode - only the default-background is forced to be white for printing. SC_PRINT_COLOURONWHITEDEFAULTBG => 4, # FindOption enumeration SCFIND_WHOLEWORD => 2, SCFIND_MATCHCASE => 4, SCFIND_WORDSTART => 0x00100000, SCFIND_REGEXP => 0x00200000, SCFIND_POSIX => 0x00400000, # FoldLevel enumeration SC_FOLDLEVELBASE => 0x400, SC_FOLDLEVELWHITEFLAG => 0x1000, SC_FOLDLEVELHEADERFLAG => 0x2000, SC_FOLDLEVELNUMBERMASK => 0x0FFF, # FoldFlag enumeration SC_FOLDFLAG_LINEBEFORE_EXPANDED => 0x0002, SC_FOLDFLAG_LINEBEFORE_CONTRACTED => 0x0004, SC_FOLDFLAG_LINEAFTER_EXPANDED => 0x0008, SC_FOLDFLAG_LINEAFTER_CONTRACTED => 0x0010, SC_FOLDFLAG_LEVELNUMBERS => 0x0040, SC_TIME_FOREVER => 10000000, # Wrap enumeration SC_WRAP_NONE => 0, SC_WRAP_WORD => 1, SC_WRAP_CHAR => 2, # WrapVisualFlag enumeration SC_WRAPVISUALFLAG_NONE => 0x0000, SC_WRAPVISUALFLAG_END => 0x0001, SC_WRAPVISUALFLAG_START => 0x0002, # WrapVisualLocation enumeration SC_WRAPVISUALFLAGLOC_DEFAULT => 0x0000, SC_WRAPVISUALFLAGLOC_END_BY_TEXT => 0x0001, SC_WRAPVISUALFLAGLOC_START_BY_TEXT => 0x0002, # WrapIndentMode enumeration SC_WRAPINDENT_FIXED => 0, SC_WRAPINDENT_SAME => 1, SC_WRAPINDENT_INDENT => 2, # LineCache enumeration SC_CACHE_NONE => 0, SC_CACHE_CARET => 1, SC_CACHE_PAGE => 2, SC_CACHE_DOCUMENT => 3, # FontQuality enumeration SC_EFF_QUALITY_MASK => 0xF, SC_EFF_QUALITY_DEFAULT => 0, SC_EFF_QUALITY_NON_ANTIALIASED => 1, SC_EFF_QUALITY_ANTIALIASED => 2, SC_EFF_QUALITY_LCD_OPTIMIZED => 3, # MultiPaste enumeration SC_MULTIPASTE_ONCE => 0, SC_MULTIPASTE_EACH => 1, # EdgeVisualStyle enumeration EDGE_NONE => 0, EDGE_LINE => 1, EDGE_BACKGROUND => 2, # Status enumeration SC_STATUS_OK => 0, SC_STATUS_FAILURE => 1, SC_STATUS_BADALLOC => 2, # CursorShape enumeration SC_CURSORNORMAL => -1, SC_CURSORARROW => 2, SC_CURSORWAIT => 4, SC_CURSORREVERSEARROW => 7, # Constants for use with SetVisiblePolicy, similar to SetCaretPolicy. VISIBLE_SLOP => 0x01, VISIBLE_STRICT => 0x04, # CaretPolicy enumeration # Caret policy, used by SetXCaretPolicy and SetYCaretPolicy. # If CARET_SLOP is set, we can define a slop value: caretSlop. # This value defines an unwanted zone (UZ) where the caret is... unwanted. # This zone is defined as a number of pixels near the vertical margins, # and as a number of lines near the horizontal margins. # By keeping the caret away from the edges, it is seen within its context, # so it is likely that the identifier that the caret is on can be completely seen, # and that the current line is seen with some of the lines following it which are # often dependent on that line. CARET_SLOP => 0x01, # If CARET_STRICT is set, the policy is enforced... strictly. # The caret is centred on the display if slop is not set, # and cannot go in the UZ if slop is set. CARET_STRICT => 0x04, # If CARET_JUMPS is set, the display is moved more energetically # so the caret can move in the same direction longer before the policy is applied again. CARET_JUMPS => 0x10, # If CARET_EVEN is not set, instead of having symmetrical UZs, # the left and bottom UZs are extended up to right and top UZs respectively. # This way, we favour the displaying of useful information: the begining of lines, # where most code reside, and the lines after the caret, eg. the body of a function. CARET_EVEN => 0x08, # SelectionMode enumeration SC_SEL_STREAM => 0, SC_SEL_RECTANGLE => 1, SC_SEL_LINES => 2, SC_SEL_THIN => 3, # CaretSticky enumeration SC_CARETSTICKY_OFF => 0, SC_CARETSTICKY_ON => 1, SC_CARETSTICKY_WHITESPACE => 2, SC_ALPHA_TRANSPARENT => 0, SC_ALPHA_OPAQUE => 255, SC_ALPHA_NOALPHA => 256, # CaretStyle enumeration CARETSTYLE_INVISIBLE => 0, CARETSTYLE_LINE => 1, CARETSTYLE_BLOCK => 2, # MarginOption enumeration SC_MARGINOPTION_NONE => 0, SC_MARGINOPTION_SUBLINESELECT => 1, # AnnotationVisible enumeration ANNOTATION_HIDDEN => 0, ANNOTATION_STANDARD => 1, ANNOTATION_BOXED => 2, UNDO_MAY_COALESCE => 1, # VirtualSpace enumeration SCVS_NONE => 0, SCVS_RECTANGULARSELECTION => 1, SCVS_USERACCESSIBLE => 2, SC_TECHNOLOGY_DEFAULT => 0, SC_TECHNOLOGY_DIRECTWRITE => 1, # Maximum value of keywordSet parameter of SetKeyWords. KEYWORDSET_MAX => 8, # TypeProperty enumeration SC_TYPE_BOOLEAN => 0, SC_TYPE_INTEGER => 1, SC_TYPE_STRING => 2, # Notifications # Type of modification and the action which caused the modification. # These are defined as a bit mask to make it easy to specify which notifications are wanted. # One bit is set from each of SC_MOD_* and SC_PERFORMED_*. SC_MOD_INSERTTEXT => 0x1, SC_MOD_DELETETEXT => 0x2, SC_MOD_CHANGESTYLE => 0x4, SC_MOD_CHANGEFOLD => 0x8, SC_PERFORMED_USER => 0x10, SC_PERFORMED_UNDO => 0x20, SC_PERFORMED_REDO => 0x40, SC_MULTISTEPUNDOREDO => 0x80, SC_LASTSTEPINUNDOREDO => 0x100, SC_MOD_CHANGEMARKER => 0x200, SC_MOD_BEFOREINSERT => 0x400, SC_MOD_BEFOREDELETE => 0x800, SC_MULTILINEUNDOREDO => 0x1000, SC_STARTACTION => 0x2000, SC_MOD_CHANGEINDICATOR => 0x4000, SC_MOD_CHANGELINESTATE => 0x8000, SC_MOD_CHANGEMARGIN => 0x10000, SC_MOD_CHANGEANNOTATION => 0x20000, SC_MOD_CONTAINER => 0x40000, SC_MOD_LEXERSTATE => 0x80000, SC_MODEVENTMASKALL => 0xFFFFF, # Update enumeration SC_UPDATE_CONTENT => 0x1, SC_UPDATE_SELECTION => 0x2, SC_UPDATE_V_SCROLL => 0x4, SC_UPDATE_H_SCROLL => 0x8, # For compatibility, these go through the COMMAND notification rather than NOTIFY # and should have had exactly the same values as the EN_* constants. # Unfortunately the SETFOCUS and KILLFOCUS are flipped over from EN_* # As clients depend on these constants, this will not be changed. SCEN_CHANGE => 768, SCEN_SETFOCUS => 512, SCEN_KILLFOCUS => 256, # Keys enumeration SCK_DOWN => 300, SCK_UP => 301, SCK_LEFT => 302, SCK_RIGHT => 303, SCK_HOME => 304, SCK_END => 305, SCK_PRIOR => 306, SCK_NEXT => 307, SCK_DELETE => 308, SCK_INSERT => 309, SCK_ESCAPE => 7, SCK_BACK => 8, SCK_TAB => 9, SCK_RETURN => 13, SCK_ADD => 310, SCK_SUBTRACT => 311, SCK_DIVIDE => 312, SCK_WIN => 313, SCK_RWIN => 314, SCK_MENU => 315, # KeyMod enumeration SCMOD_NORM => 0, SCMOD_SHIFT => 1, SCMOD_CTRL => 2, SCMOD_ALT => 4, SCMOD_SUPER => 8, SCMOD_META => 16, # Lexer enumeration SCLEX_CONTAINER => 0, SCLEX_NULL => 1, SCLEX_PYTHON => 2, SCLEX_CPP => 3, SCLEX_HTML => 4, SCLEX_XML => 5, SCLEX_PERL => 6, SCLEX_SQL => 7, SCLEX_VB => 8, SCLEX_PROPERTIES => 9, SCLEX_ERRORLIST => 10, SCLEX_MAKEFILE => 11, SCLEX_BATCH => 12, SCLEX_XCODE => 13, SCLEX_LATEX => 14, SCLEX_LUA => 15, SCLEX_DIFF => 16, SCLEX_CONF => 17, SCLEX_PASCAL => 18, SCLEX_AVE => 19, SCLEX_ADA => 20, SCLEX_LISP => 21, SCLEX_RUBY => 22, SCLEX_EIFFEL => 23, SCLEX_EIFFELKW => 24, SCLEX_TCL => 25, SCLEX_NNCRONTAB => 26, SCLEX_BULLANT => 27, SCLEX_VBSCRIPT => 28, SCLEX_BAAN => 31, SCLEX_MATLAB => 32, SCLEX_SCRIPTOL => 33, SCLEX_ASM => 34, SCLEX_CPPNOCASE => 35, SCLEX_FORTRAN => 36, SCLEX_F77 => 37, SCLEX_CSS => 38, SCLEX_POV => 39, SCLEX_LOUT => 40, SCLEX_ESCRIPT => 41, SCLEX_PS => 42, SCLEX_NSIS => 43, SCLEX_MMIXAL => 44, SCLEX_CLW => 45, SCLEX_CLWNOCASE => 46, SCLEX_LOT => 47, SCLEX_YAML => 48, SCLEX_TEX => 49, SCLEX_METAPOST => 50, SCLEX_POWERBASIC => 51, SCLEX_FORTH => 52, SCLEX_ERLANG => 53, SCLEX_OCTAVE => 54, SCLEX_MSSQL => 55, SCLEX_VERILOG => 56, SCLEX_KIX => 57, SCLEX_GUI4CLI => 58, SCLEX_SPECMAN => 59, SCLEX_AU3 => 60, SCLEX_APDL => 61, SCLEX_BASH => 62, SCLEX_ASN1 => 63, SCLEX_VHDL => 64, SCLEX_CAML => 65, SCLEX_BLITZBASIC => 66, SCLEX_PUREBASIC => 67, SCLEX_HASKELL => 68, SCLEX_PHPSCRIPT => 69, SCLEX_TADS3 => 70, SCLEX_REBOL => 71, SCLEX_SMALLTALK => 72, SCLEX_FLAGSHIP => 73, SCLEX_CSOUND => 74, SCLEX_FREEBASIC => 75, SCLEX_INNOSETUP => 76, SCLEX_OPAL => 77, SCLEX_SPICE => 78, SCLEX_D => 79, SCLEX_CMAKE => 80, SCLEX_GAP => 81, SCLEX_PLM => 82, SCLEX_PROGRESS => 83, SCLEX_ABAQUS => 84, SCLEX_ASYMPTOTE => 85, SCLEX_R => 86, SCLEX_MAGIK => 87, SCLEX_POWERSHELL => 88, SCLEX_MYSQL => 89, SCLEX_PO => 90, SCLEX_TAL => 91, SCLEX_COBOL => 92, SCLEX_TACL => 93, SCLEX_SORCUS => 94, SCLEX_POWERPRO => 95, SCLEX_NIMROD => 96, SCLEX_SML => 97, SCLEX_MARKDOWN => 98, SCLEX_TXT2TAGS => 99, SCLEX_A68K => 100, SCLEX_MODULA => 101, SCLEX_COFFEESCRIPT => 102, SCLEX_TCMD => 103, SCLEX_AVS => 104, SCLEX_ECL => 105, # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a # value assigned in sequence from SCLEX_AUTOMATIC+1. SCLEX_AUTOMATIC => 1000, # Lexical states for SCLEX_PYTHON SCE_P_DEFAULT => 0, SCE_P_COMMENTLINE => 1, SCE_P_NUMBER => 2, SCE_P_STRING => 3, SCE_P_CHARACTER => 4, SCE_P_WORD => 5, SCE_P_TRIPLE => 6, SCE_P_TRIPLEDOUBLE => 7, SCE_P_CLASSNAME => 8, SCE_P_DEFNAME => 9, SCE_P_OPERATOR => 10, SCE_P_IDENTIFIER => 11, SCE_P_COMMENTBLOCK => 12, SCE_P_STRINGEOL => 13, SCE_P_WORD2 => 14, SCE_P_DECORATOR => 15, # Lexical states for SCLEX_CPP SCE_C_DEFAULT => 0, SCE_C_COMMENT => 1, SCE_C_COMMENTLINE => 2, SCE_C_COMMENTDOC => 3, SCE_C_NUMBER => 4, SCE_C_WORD => 5, SCE_C_STRING => 6, SCE_C_CHARACTER => 7, SCE_C_UUID => 8, SCE_C_PREPROCESSOR => 9, SCE_C_OPERATOR => 10, SCE_C_IDENTIFIER => 11, SCE_C_STRINGEOL => 12, SCE_C_VERBATIM => 13, SCE_C_REGEX => 14, SCE_C_COMMENTLINEDOC => 15, SCE_C_WORD2 => 16, SCE_C_COMMENTDOCKEYWORD => 17, SCE_C_COMMENTDOCKEYWORDERROR => 18, SCE_C_GLOBALCLASS => 19, SCE_C_STRINGRAW => 20, SCE_C_TRIPLEVERBATIM => 21, SCE_C_HASHQUOTEDSTRING => 22, # Lexical states for SCLEX_D SCE_D_DEFAULT => 0, SCE_D_COMMENT => 1, SCE_D_COMMENTLINE => 2, SCE_D_COMMENTDOC => 3, SCE_D_COMMENTNESTED => 4, SCE_D_NUMBER => 5, SCE_D_WORD => 6, SCE_D_WORD2 => 7, SCE_D_WORD3 => 8, SCE_D_TYPEDEF => 9, SCE_D_STRING => 10, SCE_D_STRINGEOL => 11, SCE_D_CHARACTER => 12, SCE_D_OPERATOR => 13, SCE_D_IDENTIFIER => 14, SCE_D_COMMENTLINEDOC => 15, SCE_D_COMMENTDOCKEYWORD => 16, SCE_D_COMMENTDOCKEYWORDERROR => 17, SCE_D_STRINGB => 18, SCE_D_STRINGR => 19, SCE_D_WORD5 => 20, SCE_D_WORD6 => 21, SCE_D_WORD7 => 22, # Lexical states for SCLEX_TCL SCE_TCL_DEFAULT => 0, SCE_TCL_COMMENT => 1, SCE_TCL_COMMENTLINE => 2, SCE_TCL_NUMBER => 3, SCE_TCL_WORD_IN_QUOTE => 4, SCE_TCL_IN_QUOTE => 5, SCE_TCL_OPERATOR => 6, SCE_TCL_IDENTIFIER => 7, SCE_TCL_SUBSTITUTION => 8, SCE_TCL_SUB_BRACE => 9, SCE_TCL_MODIFIER => 10, SCE_TCL_EXPAND => 11, SCE_TCL_WORD => 12, SCE_TCL_WORD2 => 13, SCE_TCL_WORD3 => 14, SCE_TCL_WORD4 => 15, SCE_TCL_WORD5 => 16, SCE_TCL_WORD6 => 17, SCE_TCL_WORD7 => 18, SCE_TCL_WORD8 => 19, SCE_TCL_COMMENT_BOX => 20, SCE_TCL_BLOCK_COMMENT => 21, # Lexical states for SCLEX_HTML, SCLEX_XML SCE_H_DEFAULT => 0, SCE_H_TAG => 1, SCE_H_TAGUNKNOWN => 2, SCE_H_ATTRIBUTE => 3, SCE_H_ATTRIBUTEUNKNOWN => 4, SCE_H_NUMBER => 5, SCE_H_DOUBLESTRING => 6, SCE_H_SINGLESTRING => 7, SCE_H_OTHER => 8, SCE_H_COMMENT => 9, SCE_H_ENTITY => 10, # XML and ASP SCE_H_TAGEND => 11, SCE_H_XMLSTART => 12, SCE_H_XMLEND => 13, SCE_H_SCRIPT => 14, SCE_H_ASP => 15, SCE_H_ASPAT => 16, SCE_H_CDATA => 17, SCE_H_QUESTION => 18, # More HTML SCE_H_VALUE => 19, # X-Code SCE_H_XCCOMMENT => 20, # SGML SCE_H_SGML_DEFAULT => 21, SCE_H_SGML_COMMAND => 22, SCE_H_SGML_1ST_PARAM => 23, SCE_H_SGML_DOUBLESTRING => 24, SCE_H_SGML_SIMPLESTRING => 25, SCE_H_SGML_ERROR => 26, SCE_H_SGML_SPECIAL => 27, SCE_H_SGML_ENTITY => 28, SCE_H_SGML_COMMENT => 29, SCE_H_SGML_1ST_PARAM_COMMENT => 30, SCE_H_SGML_BLOCK_DEFAULT => 31, # Embedded Javascript SCE_HJ_START => 40, SCE_HJ_DEFAULT => 41, SCE_HJ_COMMENT => 42, SCE_HJ_COMMENTLINE => 43, SCE_HJ_COMMENTDOC => 44, SCE_HJ_NUMBER => 45, SCE_HJ_WORD => 46, SCE_HJ_KEYWORD => 47, SCE_HJ_DOUBLESTRING => 48, SCE_HJ_SINGLESTRING => 49, SCE_HJ_SYMBOLS => 50, SCE_HJ_STRINGEOL => 51, SCE_HJ_REGEX => 52, # ASP Javascript SCE_HJA_START => 55, SCE_HJA_DEFAULT => 56, SCE_HJA_COMMENT => 57, SCE_HJA_COMMENTLINE => 58, SCE_HJA_COMMENTDOC => 59, SCE_HJA_NUMBER => 60, SCE_HJA_WORD => 61, SCE_HJA_KEYWORD => 62, SCE_HJA_DOUBLESTRING => 63, SCE_HJA_SINGLESTRING => 64, SCE_HJA_SYMBOLS => 65, SCE_HJA_STRINGEOL => 66, SCE_HJA_REGEX => 67, # Embedded VBScript SCE_HB_START => 70, SCE_HB_DEFAULT => 71, SCE_HB_COMMENTLINE => 72, SCE_HB_NUMBER => 73, SCE_HB_WORD => 74, SCE_HB_STRING => 75, SCE_HB_IDENTIFIER => 76, SCE_HB_STRINGEOL => 77, # ASP VBScript SCE_HBA_START => 80, SCE_HBA_DEFAULT => 81, SCE_HBA_COMMENTLINE => 82, SCE_HBA_NUMBER => 83, SCE_HBA_WORD => 84, SCE_HBA_STRING => 85, SCE_HBA_IDENTIFIER => 86, SCE_HBA_STRINGEOL => 87, # Embedded Python SCE_HP_START => 90, SCE_HP_DEFAULT => 91, SCE_HP_COMMENTLINE => 92, SCE_HP_NUMBER => 93, SCE_HP_STRING => 94, SCE_HP_CHARACTER => 95, SCE_HP_WORD => 96, SCE_HP_TRIPLE => 97, SCE_HP_TRIPLEDOUBLE => 98, SCE_HP_CLASSNAME => 99, SCE_HP_DEFNAME => 100, SCE_HP_OPERATOR => 101, SCE_HP_IDENTIFIER => 102, # PHP SCE_HPHP_COMPLEX_VARIABLE => 104, # ASP Python SCE_HPA_START => 105, SCE_HPA_DEFAULT => 106, SCE_HPA_COMMENTLINE => 107, SCE_HPA_NUMBER => 108, SCE_HPA_STRING => 109, SCE_HPA_CHARACTER => 110, SCE_HPA_WORD => 111, SCE_HPA_TRIPLE => 112, SCE_HPA_TRIPLEDOUBLE => 113, SCE_HPA_CLASSNAME => 114, SCE_HPA_DEFNAME => 115, SCE_HPA_OPERATOR => 116, SCE_HPA_IDENTIFIER => 117, # PHP SCE_HPHP_DEFAULT => 118, SCE_HPHP_HSTRING => 119, SCE_HPHP_SIMPLESTRING => 120, SCE_HPHP_WORD => 121, SCE_HPHP_NUMBER => 122, SCE_HPHP_VARIABLE => 123, SCE_HPHP_COMMENT => 124, SCE_HPHP_COMMENTLINE => 125, SCE_HPHP_HSTRING_VARIABLE => 126, SCE_HPHP_OPERATOR => 127, # Lexical states for SCLEX_PERL SCE_PL_DEFAULT => 0, SCE_PL_ERROR => 1, SCE_PL_COMMENTLINE => 2, SCE_PL_POD => 3, SCE_PL_NUMBER => 4, SCE_PL_WORD => 5, SCE_PL_STRING => 6, SCE_PL_CHARACTER => 7, SCE_PL_PUNCTUATION => 8, SCE_PL_PREPROCESSOR => 9, SCE_PL_OPERATOR => 10, SCE_PL_IDENTIFIER => 11, SCE_PL_SCALAR => 12, SCE_PL_ARRAY => 13, SCE_PL_HASH => 14, SCE_PL_SYMBOLTABLE => 15, SCE_PL_VARIABLE_INDEXER => 16, SCE_PL_REGEX => 17, SCE_PL_REGSUBST => 18, SCE_PL_LONGQUOTE => 19, SCE_PL_BACKTICKS => 20, SCE_PL_DATASECTION => 21, SCE_PL_HERE_DELIM => 22, SCE_PL_HERE_Q => 23, SCE_PL_HERE_QQ => 24, SCE_PL_HERE_QX => 25, SCE_PL_STRING_Q => 26, SCE_PL_STRING_QQ => 27, SCE_PL_STRING_QX => 28, SCE_PL_STRING_QR => 29, SCE_PL_STRING_QW => 30, SCE_PL_POD_VERB => 31, SCE_PL_SUB_PROTOTYPE => 40, SCE_PL_FORMAT_IDENT => 41, SCE_PL_FORMAT => 42, SCE_PL_STRING_VAR => 43, SCE_PL_XLAT => 44, SCE_PL_REGEX_VAR => 54, SCE_PL_REGSUBST_VAR => 55, SCE_PL_BACKTICKS_VAR => 57, SCE_PL_HERE_QQ_VAR => 61, SCE_PL_HERE_QX_VAR => 62, SCE_PL_STRING_QQ_VAR => 64, SCE_PL_STRING_QX_VAR => 65, SCE_PL_STRING_QR_VAR => 66, # Lexical states for SCLEX_RUBY SCE_RB_DEFAULT => 0, SCE_RB_ERROR => 1, SCE_RB_COMMENTLINE => 2, SCE_RB_POD => 3, SCE_RB_NUMBER => 4, SCE_RB_WORD => 5, SCE_RB_STRING => 6, SCE_RB_CHARACTER => 7, SCE_RB_CLASSNAME => 8, SCE_RB_DEFNAME => 9, SCE_RB_OPERATOR => 10, SCE_RB_IDENTIFIER => 11, SCE_RB_REGEX => 12, SCE_RB_GLOBAL => 13, SCE_RB_SYMBOL => 14, SCE_RB_MODULE_NAME => 15, SCE_RB_INSTANCE_VAR => 16, SCE_RB_CLASS_VAR => 17, SCE_RB_BACKTICKS => 18, SCE_RB_DATASECTION => 19, SCE_RB_HERE_DELIM => 20, SCE_RB_HERE_Q => 21, SCE_RB_HERE_QQ => 22, SCE_RB_HERE_QX => 23, SCE_RB_STRING_Q => 24, SCE_RB_STRING_QQ => 25, SCE_RB_STRING_QX => 26, SCE_RB_STRING_QR => 27, SCE_RB_STRING_QW => 28, SCE_RB_WORD_DEMOTED => 29, SCE_RB_STDIN => 30, SCE_RB_STDOUT => 31, SCE_RB_STDERR => 40, SCE_RB_UPPER_BOUND => 41, # Lexical states for SCLEX_VB, SCLEX_VBSCRIPT, SCLEX_POWERBASIC SCE_B_DEFAULT => 0, SCE_B_COMMENT => 1, SCE_B_NUMBER => 2, SCE_B_KEYWORD => 3, SCE_B_STRING => 4, SCE_B_PREPROCESSOR => 5, SCE_B_OPERATOR => 6, SCE_B_IDENTIFIER => 7, SCE_B_DATE => 8, SCE_B_STRINGEOL => 9, SCE_B_KEYWORD2 => 10, SCE_B_KEYWORD3 => 11, SCE_B_KEYWORD4 => 12, SCE_B_CONSTANT => 13, SCE_B_ASM => 14, SCE_B_LABEL => 15, SCE_B_ERROR => 16, SCE_B_HEXNUMBER => 17, SCE_B_BINNUMBER => 18, # Lexical states for SCLEX_PROPERTIES SCE_PROPS_DEFAULT => 0, SCE_PROPS_COMMENT => 1, SCE_PROPS_SECTION => 2, SCE_PROPS_ASSIGNMENT => 3, SCE_PROPS_DEFVAL => 4, SCE_PROPS_KEY => 5, # Lexical states for SCLEX_LATEX SCE_L_DEFAULT => 0, SCE_L_COMMAND => 1, SCE_L_TAG => 2, SCE_L_MATH => 3, SCE_L_COMMENT => 4, SCE_L_TAG2 => 5, SCE_L_MATH2 => 6, SCE_L_COMMENT2 => 7, SCE_L_VERBATIM => 8, SCE_L_SHORTCMD => 9, SCE_L_SPECIAL => 10, SCE_L_CMDOPT => 11, SCE_L_ERROR => 12, # Lexical states for SCLEX_LUA SCE_LUA_DEFAULT => 0, SCE_LUA_COMMENT => 1, SCE_LUA_COMMENTLINE => 2, SCE_LUA_COMMENTDOC => 3, SCE_LUA_NUMBER => 4, SCE_LUA_WORD => 5, SCE_LUA_STRING => 6, SCE_LUA_CHARACTER => 7, SCE_LUA_LITERALSTRING => 8, SCE_LUA_PREPROCESSOR => 9, SCE_LUA_OPERATOR => 10, SCE_LUA_IDENTIFIER => 11, SCE_LUA_STRINGEOL => 12, SCE_LUA_WORD2 => 13, SCE_LUA_WORD3 => 14, SCE_LUA_WORD4 => 15, SCE_LUA_WORD5 => 16, SCE_LUA_WORD6 => 17, SCE_LUA_WORD7 => 18, SCE_LUA_WORD8 => 19, SCE_LUA_LABEL => 20, # Lexical states for SCLEX_ERRORLIST SCE_ERR_DEFAULT => 0, SCE_ERR_PYTHON => 1, SCE_ERR_GCC => 2, SCE_ERR_MS => 3, SCE_ERR_CMD => 4, SCE_ERR_BORLAND => 5, SCE_ERR_PERL => 6, SCE_ERR_NET => 7, SCE_ERR_LUA => 8, SCE_ERR_CTAG => 9, SCE_ERR_DIFF_CHANGED => 10, SCE_ERR_DIFF_ADDITION => 11, SCE_ERR_DIFF_DELETION => 12, SCE_ERR_DIFF_MESSAGE => 13, SCE_ERR_PHP => 14, SCE_ERR_ELF => 15, SCE_ERR_IFC => 16, SCE_ERR_IFORT => 17, SCE_ERR_ABSF => 18, SCE_ERR_TIDY => 19, SCE_ERR_JAVA_STACK => 20, SCE_ERR_VALUE => 21, # Lexical states for SCLEX_BATCH SCE_BAT_DEFAULT => 0, SCE_BAT_COMMENT => 1, SCE_BAT_WORD => 2, SCE_BAT_LABEL => 3, SCE_BAT_HIDE => 4, SCE_BAT_COMMAND => 5, SCE_BAT_IDENTIFIER => 6, SCE_BAT_OPERATOR => 7, # Lexical states for SCLEX_TCMD SCE_TCMD_DEFAULT => 0, SCE_TCMD_COMMENT => 1, SCE_TCMD_WORD => 2, SCE_TCMD_LABEL => 3, SCE_TCMD_HIDE => 4, SCE_TCMD_COMMAND => 5, SCE_TCMD_IDENTIFIER => 6, SCE_TCMD_OPERATOR => 7, SCE_TCMD_ENVIRONMENT => 8, SCE_TCMD_EXPANSION => 9, SCE_TCMD_CLABEL => 10, # Lexical states for SCLEX_MAKEFILE SCE_MAKE_DEFAULT => 0, SCE_MAKE_COMMENT => 1, SCE_MAKE_PREPROCESSOR => 2, SCE_MAKE_IDENTIFIER => 3, SCE_MAKE_OPERATOR => 4, SCE_MAKE_TARGET => 5, SCE_MAKE_IDEOL => 9, # Lexical states for SCLEX_DIFF SCE_DIFF_DEFAULT => 0, SCE_DIFF_COMMENT => 1, SCE_DIFF_COMMAND => 2, SCE_DIFF_HEADER => 3, SCE_DIFF_POSITION => 4, SCE_DIFF_DELETED => 5, SCE_DIFF_ADDED => 6, SCE_DIFF_CHANGED => 7, # Lexical states for SCLEX_CONF (Apache Configuration Files Lexer) SCE_CONF_DEFAULT => 0, SCE_CONF_COMMENT => 1, SCE_CONF_NUMBER => 2, SCE_CONF_IDENTIFIER => 3, SCE_CONF_EXTENSION => 4, SCE_CONF_PARAMETER => 5, SCE_CONF_STRING => 6, SCE_CONF_OPERATOR => 7, SCE_CONF_IP => 8, SCE_CONF_DIRECTIVE => 9, # Lexical states for SCLEX_AVE, Avenue SCE_AVE_DEFAULT => 0, SCE_AVE_COMMENT => 1, SCE_AVE_NUMBER => 2, SCE_AVE_WORD => 3, SCE_AVE_STRING => 6, SCE_AVE_ENUM => 7, SCE_AVE_STRINGEOL => 8, SCE_AVE_IDENTIFIER => 9, SCE_AVE_OPERATOR => 10, SCE_AVE_WORD1 => 11, SCE_AVE_WORD2 => 12, SCE_AVE_WORD3 => 13, SCE_AVE_WORD4 => 14, SCE_AVE_WORD5 => 15, SCE_AVE_WORD6 => 16, # Lexical states for SCLEX_ADA SCE_ADA_DEFAULT => 0, SCE_ADA_WORD => 1, SCE_ADA_IDENTIFIER => 2, SCE_ADA_NUMBER => 3, SCE_ADA_DELIMITER => 4, SCE_ADA_CHARACTER => 5, SCE_ADA_CHARACTEREOL => 6, SCE_ADA_STRING => 7, SCE_ADA_STRINGEOL => 8, SCE_ADA_LABEL => 9, SCE_ADA_COMMENTLINE => 10, SCE_ADA_ILLEGAL => 11, # Lexical states for SCLEX_BAAN SCE_BAAN_DEFAULT => 0, SCE_BAAN_COMMENT => 1, SCE_BAAN_COMMENTDOC => 2, SCE_BAAN_NUMBER => 3, SCE_BAAN_WORD => 4, SCE_BAAN_STRING => 5, SCE_BAAN_PREPROCESSOR => 6, SCE_BAAN_OPERATOR => 7, SCE_BAAN_IDENTIFIER => 8, SCE_BAAN_STRINGEOL => 9, SCE_BAAN_WORD2 => 10, # Lexical states for SCLEX_LISP SCE_LISP_DEFAULT => 0, SCE_LISP_COMMENT => 1, SCE_LISP_NUMBER => 2, SCE_LISP_KEYWORD => 3, SCE_LISP_KEYWORD_KW => 4, SCE_LISP_SYMBOL => 5, SCE_LISP_STRING => 6, SCE_LISP_STRINGEOL => 8, SCE_LISP_IDENTIFIER => 9, SCE_LISP_OPERATOR => 10, SCE_LISP_SPECIAL => 11, SCE_LISP_MULTI_COMMENT => 12, # Lexical states for SCLEX_EIFFEL and SCLEX_EIFFELKW SCE_EIFFEL_DEFAULT => 0, SCE_EIFFEL_COMMENTLINE => 1, SCE_EIFFEL_NUMBER => 2, SCE_EIFFEL_WORD => 3, SCE_EIFFEL_STRING => 4, SCE_EIFFEL_CHARACTER => 5, SCE_EIFFEL_OPERATOR => 6, SCE_EIFFEL_IDENTIFIER => 7, SCE_EIFFEL_STRINGEOL => 8, # Lexical states for SCLEX_NNCRONTAB (nnCron crontab Lexer) SCE_NNCRONTAB_DEFAULT => 0, SCE_NNCRONTAB_COMMENT => 1, SCE_NNCRONTAB_TASK => 2, SCE_NNCRONTAB_SECTION => 3, SCE_NNCRONTAB_KEYWORD => 4, SCE_NNCRONTAB_MODIFIER => 5, SCE_NNCRONTAB_ASTERISK => 6, SCE_NNCRONTAB_NUMBER => 7, SCE_NNCRONTAB_STRING => 8, SCE_NNCRONTAB_ENVIRONMENT => 9, SCE_NNCRONTAB_IDENTIFIER => 10, # Lexical states for SCLEX_FORTH (Forth Lexer) SCE_FORTH_DEFAULT => 0, SCE_FORTH_COMMENT => 1, SCE_FORTH_COMMENT_ML => 2, SCE_FORTH_IDENTIFIER => 3, SCE_FORTH_CONTROL => 4, SCE_FORTH_KEYWORD => 5, SCE_FORTH_DEFWORD => 6, SCE_FORTH_PREWORD1 => 7, SCE_FORTH_PREWORD2 => 8, SCE_FORTH_NUMBER => 9, SCE_FORTH_STRING => 10, SCE_FORTH_LOCALE => 11, # Lexical states for SCLEX_MATLAB SCE_MATLAB_DEFAULT => 0, SCE_MATLAB_COMMENT => 1, SCE_MATLAB_COMMAND => 2, SCE_MATLAB_NUMBER => 3, SCE_MATLAB_KEYWORD => 4, # single quoted string SCE_MATLAB_STRING => 5, SCE_MATLAB_OPERATOR => 6, SCE_MATLAB_IDENTIFIER => 7, SCE_MATLAB_DOUBLEQUOTESTRING => 8, # Lexical states for SCLEX_SCRIPTOL SCE_SCRIPTOL_DEFAULT => 0, SCE_SCRIPTOL_WHITE => 1, SCE_SCRIPTOL_COMMENTLINE => 2, SCE_SCRIPTOL_PERSISTENT => 3, SCE_SCRIPTOL_CSTYLE => 4, SCE_SCRIPTOL_COMMENTBLOCK => 5, SCE_SCRIPTOL_NUMBER => 6, SCE_SCRIPTOL_STRING => 7, SCE_SCRIPTOL_CHARACTER => 8, SCE_SCRIPTOL_STRINGEOL => 9, SCE_SCRIPTOL_KEYWORD => 10, SCE_SCRIPTOL_OPERATOR => 11, SCE_SCRIPTOL_IDENTIFIER => 12, SCE_SCRIPTOL_TRIPLE => 13, SCE_SCRIPTOL_CLASSNAME => 14, SCE_SCRIPTOL_PREPROCESSOR => 15, # Lexical states for SCLEX_ASM SCE_ASM_DEFAULT => 0, SCE_ASM_COMMENT => 1, SCE_ASM_NUMBER => 2, SCE_ASM_STRING => 3, SCE_ASM_OPERATOR => 4, SCE_ASM_IDENTIFIER => 5, SCE_ASM_CPUINSTRUCTION => 6, SCE_ASM_MATHINSTRUCTION => 7, SCE_ASM_REGISTER => 8, SCE_ASM_DIRECTIVE => 9, SCE_ASM_DIRECTIVEOPERAND => 10, SCE_ASM_COMMENTBLOCK => 11, SCE_ASM_CHARACTER => 12, SCE_ASM_STRINGEOL => 13, SCE_ASM_EXTINSTRUCTION => 14, SCE_ASM_COMMENTDIRECTIVE => 15, # Lexical states for SCLEX_FORTRAN SCE_F_DEFAULT => 0, SCE_F_COMMENT => 1, SCE_F_NUMBER => 2, SCE_F_STRING1 => 3, SCE_F_STRING2 => 4, SCE_F_STRINGEOL => 5, SCE_F_OPERATOR => 6, SCE_F_IDENTIFIER => 7, SCE_F_WORD => 8, SCE_F_WORD2 => 9, SCE_F_WORD3 => 10, SCE_F_PREPROCESSOR => 11, SCE_F_OPERATOR2 => 12, SCE_F_LABEL => 13, SCE_F_CONTINUATION => 14, # Lexical states for SCLEX_CSS SCE_CSS_DEFAULT => 0, SCE_CSS_TAG => 1, SCE_CSS_CLASS => 2, SCE_CSS_PSEUDOCLASS => 3, SCE_CSS_UNKNOWN_PSEUDOCLASS => 4, SCE_CSS_OPERATOR => 5, SCE_CSS_IDENTIFIER => 6, SCE_CSS_UNKNOWN_IDENTIFIER => 7, SCE_CSS_VALUE => 8, SCE_CSS_COMMENT => 9, SCE_CSS_ID => 10, SCE_CSS_IMPORTANT => 11, SCE_CSS_DIRECTIVE => 12, SCE_CSS_DOUBLESTRING => 13, SCE_CSS_SINGLESTRING => 14, SCE_CSS_IDENTIFIER2 => 15, SCE_CSS_ATTRIBUTE => 16, SCE_CSS_IDENTIFIER3 => 17, SCE_CSS_PSEUDOELEMENT => 18, SCE_CSS_EXTENDED_IDENTIFIER => 19, SCE_CSS_EXTENDED_PSEUDOCLASS => 20, SCE_CSS_EXTENDED_PSEUDOELEMENT => 21, SCE_CSS_MEDIA => 22, SCE_CSS_VARIABLE => 23, # Lexical states for SCLEX_POV SCE_POV_DEFAULT => 0, SCE_POV_COMMENT => 1, SCE_POV_COMMENTLINE => 2, SCE_POV_NUMBER => 3, SCE_POV_OPERATOR => 4, SCE_POV_IDENTIFIER => 5, SCE_POV_STRING => 6, SCE_POV_STRINGEOL => 7, SCE_POV_DIRECTIVE => 8, SCE_POV_BADDIRECTIVE => 9, SCE_POV_WORD2 => 10, SCE_POV_WORD3 => 11, SCE_POV_WORD4 => 12, SCE_POV_WORD5 => 13, SCE_POV_WORD6 => 14, SCE_POV_WORD7 => 15, SCE_POV_WORD8 => 16, # Lexical states for SCLEX_LOUT SCE_LOUT_DEFAULT => 0, SCE_LOUT_COMMENT => 1, SCE_LOUT_NUMBER => 2, SCE_LOUT_WORD => 3, SCE_LOUT_WORD2 => 4, SCE_LOUT_WORD3 => 5, SCE_LOUT_WORD4 => 6, SCE_LOUT_STRING => 7, SCE_LOUT_OPERATOR => 8, SCE_LOUT_IDENTIFIER => 9, SCE_LOUT_STRINGEOL => 10, # Lexical states for SCLEX_ESCRIPT SCE_ESCRIPT_DEFAULT => 0, SCE_ESCRIPT_COMMENT => 1, SCE_ESCRIPT_COMMENTLINE => 2, SCE_ESCRIPT_COMMENTDOC => 3, SCE_ESCRIPT_NUMBER => 4, SCE_ESCRIPT_WORD => 5, SCE_ESCRIPT_STRING => 6, SCE_ESCRIPT_OPERATOR => 7, SCE_ESCRIPT_IDENTIFIER => 8, SCE_ESCRIPT_BRACE => 9, SCE_ESCRIPT_WORD2 => 10, SCE_ESCRIPT_WORD3 => 11, # Lexical states for SCLEX_PS SCE_PS_DEFAULT => 0, SCE_PS_COMMENT => 1, SCE_PS_DSC_COMMENT => 2, SCE_PS_DSC_VALUE => 3, SCE_PS_NUMBER => 4, SCE_PS_NAME => 5, SCE_PS_KEYWORD => 6, SCE_PS_LITERAL => 7, SCE_PS_IMMEVAL => 8, SCE_PS_PAREN_ARRAY => 9, SCE_PS_PAREN_DICT => 10, SCE_PS_PAREN_PROC => 11, SCE_PS_TEXT => 12, SCE_PS_HEXSTRING => 13, SCE_PS_BASE85STRING => 14, SCE_PS_BADSTRINGCHAR => 15, # Lexical states for SCLEX_NSIS SCE_NSIS_DEFAULT => 0, SCE_NSIS_COMMENT => 1, SCE_NSIS_STRINGDQ => 2, SCE_NSIS_STRINGLQ => 3, SCE_NSIS_STRINGRQ => 4, SCE_NSIS_FUNCTION => 5, SCE_NSIS_VARIABLE => 6, SCE_NSIS_LABEL => 7, SCE_NSIS_USERDEFINED => 8, SCE_NSIS_SECTIONDEF => 9, SCE_NSIS_SUBSECTIONDEF => 10, SCE_NSIS_IFDEFINEDEF => 11, SCE_NSIS_MACRODEF => 12, SCE_NSIS_STRINGVAR => 13, SCE_NSIS_NUMBER => 14, SCE_NSIS_SECTIONGROUP => 15, SCE_NSIS_PAGEEX => 16, SCE_NSIS_FUNCTIONDEF => 17, SCE_NSIS_COMMENTBOX => 18, # Lexical states for SCLEX_MMIXAL SCE_MMIXAL_LEADWS => 0, SCE_MMIXAL_COMMENT => 1, SCE_MMIXAL_LABEL => 2, SCE_MMIXAL_OPCODE => 3, SCE_MMIXAL_OPCODE_PRE => 4, SCE_MMIXAL_OPCODE_VALID => 5, SCE_MMIXAL_OPCODE_UNKNOWN => 6, SCE_MMIXAL_OPCODE_POST => 7, SCE_MMIXAL_OPERANDS => 8, SCE_MMIXAL_NUMBER => 9, SCE_MMIXAL_REF => 10, SCE_MMIXAL_CHAR => 11, SCE_MMIXAL_STRING => 12, SCE_MMIXAL_REGISTER => 13, SCE_MMIXAL_HEX => 14, SCE_MMIXAL_OPERATOR => 15, SCE_MMIXAL_SYMBOL => 16, SCE_MMIXAL_INCLUDE => 17, # Lexical states for SCLEX_CLW SCE_CLW_DEFAULT => 0, SCE_CLW_LABEL => 1, SCE_CLW_COMMENT => 2, SCE_CLW_STRING => 3, SCE_CLW_USER_IDENTIFIER => 4, SCE_CLW_INTEGER_CONSTANT => 5, SCE_CLW_REAL_CONSTANT => 6, SCE_CLW_PICTURE_STRING => 7, SCE_CLW_KEYWORD => 8, SCE_CLW_COMPILER_DIRECTIVE => 9, SCE_CLW_RUNTIME_EXPRESSIONS => 10, SCE_CLW_BUILTIN_PROCEDURES_FUNCTION => 11, SCE_CLW_STRUCTURE_DATA_TYPE => 12, SCE_CLW_ATTRIBUTE => 13, SCE_CLW_STANDARD_EQUATE => 14, SCE_CLW_ERROR => 15, SCE_CLW_DEPRECATED => 16, # Lexical states for SCLEX_LOT SCE_LOT_DEFAULT => 0, SCE_LOT_HEADER => 1, SCE_LOT_BREAK => 2, SCE_LOT_SET => 3, SCE_LOT_PASS => 4, SCE_LOT_FAIL => 5, SCE_LOT_ABORT => 6, # Lexical states for SCLEX_YAML SCE_YAML_DEFAULT => 0, SCE_YAML_COMMENT => 1, SCE_YAML_IDENTIFIER => 2, SCE_YAML_KEYWORD => 3, SCE_YAML_NUMBER => 4, SCE_YAML_REFERENCE => 5, SCE_YAML_DOCUMENT => 6, SCE_YAML_TEXT => 7, SCE_YAML_ERROR => 8, SCE_YAML_OPERATOR => 9, # Lexical states for SCLEX_TEX SCE_TEX_DEFAULT => 0, SCE_TEX_SPECIAL => 1, SCE_TEX_GROUP => 2, SCE_TEX_SYMBOL => 3, SCE_TEX_COMMAND => 4, SCE_TEX_TEXT => 5, SCE_METAPOST_DEFAULT => 0, SCE_METAPOST_SPECIAL => 1, SCE_METAPOST_GROUP => 2, SCE_METAPOST_SYMBOL => 3, SCE_METAPOST_COMMAND => 4, SCE_METAPOST_TEXT => 5, SCE_METAPOST_EXTRA => 6, # Lexical states for SCLEX_ERLANG SCE_ERLANG_DEFAULT => 0, SCE_ERLANG_COMMENT => 1, SCE_ERLANG_VARIABLE => 2, SCE_ERLANG_NUMBER => 3, SCE_ERLANG_KEYWORD => 4, SCE_ERLANG_STRING => 5, SCE_ERLANG_OPERATOR => 6, SCE_ERLANG_ATOM => 7, SCE_ERLANG_FUNCTION_NAME => 8, SCE_ERLANG_CHARACTER => 9, SCE_ERLANG_MACRO => 10, SCE_ERLANG_RECORD => 11, SCE_ERLANG_PREPROC => 12, SCE_ERLANG_NODE_NAME => 13, SCE_ERLANG_COMMENT_FUNCTION => 14, SCE_ERLANG_COMMENT_MODULE => 15, SCE_ERLANG_COMMENT_DOC => 16, SCE_ERLANG_COMMENT_DOC_MACRO => 17, SCE_ERLANG_ATOM_QUOTED => 18, SCE_ERLANG_MACRO_QUOTED => 19, SCE_ERLANG_RECORD_QUOTED => 20, SCE_ERLANG_NODE_NAME_QUOTED => 21, SCE_ERLANG_BIFS => 22, SCE_ERLANG_MODULES => 23, SCE_ERLANG_MODULES_ATT => 24, SCE_ERLANG_UNKNOWN => 31, # Lexical states for SCLEX_OCTAVE are identical to MatLab # Lexical states for SCLEX_MSSQL SCE_MSSQL_DEFAULT => 0, SCE_MSSQL_COMMENT => 1, SCE_MSSQL_LINE_COMMENT => 2, SCE_MSSQL_NUMBER => 3, SCE_MSSQL_STRING => 4, SCE_MSSQL_OPERATOR => 5, SCE_MSSQL_IDENTIFIER => 6, SCE_MSSQL_VARIABLE => 7, SCE_MSSQL_COLUMN_NAME => 8, SCE_MSSQL_STATEMENT => 9, SCE_MSSQL_DATATYPE => 10, SCE_MSSQL_SYSTABLE => 11, SCE_MSSQL_GLOBAL_VARIABLE => 12, SCE_MSSQL_FUNCTION => 13, SCE_MSSQL_STORED_PROCEDURE => 14, SCE_MSSQL_DEFAULT_PREF_DATATYPE => 15, SCE_MSSQL_COLUMN_NAME_2 => 16, # Lexical states for SCLEX_VERILOG SCE_V_DEFAULT => 0, SCE_V_COMMENT => 1, SCE_V_COMMENTLINE => 2, SCE_V_COMMENTLINEBANG => 3, SCE_V_NUMBER => 4, SCE_V_WORD => 5, SCE_V_STRING => 6, SCE_V_WORD2 => 7, SCE_V_WORD3 => 8, SCE_V_PREPROCESSOR => 9, SCE_V_OPERATOR => 10, SCE_V_IDENTIFIER => 11, SCE_V_STRINGEOL => 12, SCE_V_USER => 19, # Lexical states for SCLEX_KIX SCE_KIX_DEFAULT => 0, SCE_KIX_COMMENT => 1, SCE_KIX_STRING1 => 2, SCE_KIX_STRING2 => 3, SCE_KIX_NUMBER => 4, SCE_KIX_VAR => 5, SCE_KIX_MACRO => 6, SCE_KIX_KEYWORD => 7, SCE_KIX_FUNCTIONS => 8, SCE_KIX_OPERATOR => 9, SCE_KIX_IDENTIFIER => 31, # Lexical states for SCLEX_GUI4CLI SCE_GC_DEFAULT => 0, SCE_GC_COMMENTLINE => 1, SCE_GC_COMMENTBLOCK => 2, SCE_GC_GLOBAL => 3, SCE_GC_EVENT => 4, SCE_GC_ATTRIBUTE => 5, SCE_GC_CONTROL => 6, SCE_GC_COMMAND => 7, SCE_GC_STRING => 8, SCE_GC_OPERATOR => 9, # Lexical states for SCLEX_SPECMAN SCE_SN_DEFAULT => 0, SCE_SN_CODE => 1, SCE_SN_COMMENTLINE => 2, SCE_SN_COMMENTLINEBANG => 3, SCE_SN_NUMBER => 4, SCE_SN_WORD => 5, SCE_SN_STRING => 6, SCE_SN_WORD2 => 7, SCE_SN_WORD3 => 8, SCE_SN_PREPROCESSOR => 9, SCE_SN_OPERATOR => 10, SCE_SN_IDENTIFIER => 11, SCE_SN_STRINGEOL => 12, SCE_SN_REGEXTAG => 13, SCE_SN_SIGNAL => 14, SCE_SN_USER => 19, # Lexical states for SCLEX_AU3 SCE_AU3_DEFAULT => 0, SCE_AU3_COMMENT => 1, SCE_AU3_COMMENTBLOCK => 2, SCE_AU3_NUMBER => 3, SCE_AU3_FUNCTION => 4, SCE_AU3_KEYWORD => 5, SCE_AU3_MACRO => 6, SCE_AU3_STRING => 7, SCE_AU3_OPERATOR => 8, SCE_AU3_VARIABLE => 9, SCE_AU3_SENT => 10, SCE_AU3_PREPROCESSOR => 11, SCE_AU3_SPECIAL => 12, SCE_AU3_EXPAND => 13, SCE_AU3_COMOBJ => 14, SCE_AU3_UDF => 15, # Lexical states for SCLEX_APDL SCE_APDL_DEFAULT => 0, SCE_APDL_COMMENT => 1, SCE_APDL_COMMENTBLOCK => 2, SCE_APDL_NUMBER => 3, SCE_APDL_STRING => 4, SCE_APDL_OPERATOR => 5, SCE_APDL_WORD => 6, SCE_APDL_PROCESSOR => 7, SCE_APDL_COMMAND => 8, SCE_APDL_SLASHCOMMAND => 9, SCE_APDL_STARCOMMAND => 10, SCE_APDL_ARGUMENT => 11, SCE_APDL_FUNCTION => 12, # Lexical states for SCLEX_BASH SCE_SH_DEFAULT => 0, SCE_SH_ERROR => 1, SCE_SH_COMMENTLINE => 2, SCE_SH_NUMBER => 3, SCE_SH_WORD => 4, SCE_SH_STRING => 5, SCE_SH_CHARACTER => 6, SCE_SH_OPERATOR => 7, SCE_SH_IDENTIFIER => 8, SCE_SH_SCALAR => 9, SCE_SH_PARAM => 10, SCE_SH_BACKTICKS => 11, SCE_SH_HERE_DELIM => 12, SCE_SH_HERE_Q => 13, # Lexical states for SCLEX_ASN1 SCE_ASN1_DEFAULT => 0, SCE_ASN1_COMMENT => 1, SCE_ASN1_IDENTIFIER => 2, SCE_ASN1_STRING => 3, SCE_ASN1_OID => 4, SCE_ASN1_SCALAR => 5, SCE_ASN1_KEYWORD => 6, SCE_ASN1_ATTRIBUTE => 7, SCE_ASN1_DESCRIPTOR => 8, SCE_ASN1_TYPE => 9, SCE_ASN1_OPERATOR => 10, # Lexical states for SCLEX_VHDL SCE_VHDL_DEFAULT => 0, SCE_VHDL_COMMENT => 1, SCE_VHDL_COMMENTLINEBANG => 2, SCE_VHDL_NUMBER => 3, SCE_VHDL_STRING => 4, SCE_VHDL_OPERATOR => 5, SCE_VHDL_IDENTIFIER => 6, SCE_VHDL_STRINGEOL => 7, SCE_VHDL_KEYWORD => 8, SCE_VHDL_STDOPERATOR => 9, SCE_VHDL_ATTRIBUTE => 10, SCE_VHDL_STDFUNCTION => 11, SCE_VHDL_STDPACKAGE => 12, SCE_VHDL_STDTYPE => 13, SCE_VHDL_USERWORD => 14, # Lexical states for SCLEX_CAML SCE_CAML_DEFAULT => 0, SCE_CAML_IDENTIFIER => 1, SCE_CAML_TAGNAME => 2, SCE_CAML_KEYWORD => 3, SCE_CAML_KEYWORD2 => 4, SCE_CAML_KEYWORD3 => 5, SCE_CAML_LINENUM => 6, SCE_CAML_OPERATOR => 7, SCE_CAML_NUMBER => 8, SCE_CAML_CHAR => 9, SCE_CAML_WHITE => 10, SCE_CAML_STRING => 11, SCE_CAML_COMMENT => 12, SCE_CAML_COMMENT1 => 13, SCE_CAML_COMMENT2 => 14, SCE_CAML_COMMENT3 => 15, # Lexical states for SCLEX_HASKELL SCE_HA_DEFAULT => 0, SCE_HA_IDENTIFIER => 1, SCE_HA_KEYWORD => 2, SCE_HA_NUMBER => 3, SCE_HA_STRING => 4, SCE_HA_CHARACTER => 5, SCE_HA_CLASS => 6, SCE_HA_MODULE => 7, SCE_HA_CAPITAL => 8, SCE_HA_DATA => 9, SCE_HA_IMPORT => 10, SCE_HA_OPERATOR => 11, SCE_HA_INSTANCE => 12, SCE_HA_COMMENTLINE => 13, SCE_HA_COMMENTBLOCK => 14, SCE_HA_COMMENTBLOCK2 => 15, SCE_HA_COMMENTBLOCK3 => 16, # Lexical states of SCLEX_TADS3 SCE_T3_DEFAULT => 0, SCE_T3_X_DEFAULT => 1, SCE_T3_PREPROCESSOR => 2, SCE_T3_BLOCK_COMMENT => 3, SCE_T3_LINE_COMMENT => 4, SCE_T3_OPERATOR => 5, SCE_T3_KEYWORD => 6, SCE_T3_NUMBER => 7, SCE_T3_IDENTIFIER => 8, SCE_T3_S_STRING => 9, SCE_T3_D_STRING => 10, SCE_T3_X_STRING => 11, SCE_T3_LIB_DIRECTIVE => 12, SCE_T3_MSG_PARAM => 13, SCE_T3_HTML_TAG => 14, SCE_T3_HTML_DEFAULT => 15, SCE_T3_HTML_STRING => 16, SCE_T3_USER1 => 17, SCE_T3_USER2 => 18, SCE_T3_USER3 => 19, SCE_T3_BRACE => 20, # Lexical states for SCLEX_REBOL SCE_REBOL_DEFAULT => 0, SCE_REBOL_COMMENTLINE => 1, SCE_REBOL_COMMENTBLOCK => 2, SCE_REBOL_PREFACE => 3, SCE_REBOL_OPERATOR => 4, SCE_REBOL_CHARACTER => 5, SCE_REBOL_QUOTEDSTRING => 6, SCE_REBOL_BRACEDSTRING => 7, SCE_REBOL_NUMBER => 8, SCE_REBOL_PAIR => 9, SCE_REBOL_TUPLE => 10, SCE_REBOL_BINARY => 11, SCE_REBOL_MONEY => 12, SCE_REBOL_ISSUE => 13, SCE_REBOL_TAG => 14, SCE_REBOL_FILE => 15, SCE_REBOL_EMAIL => 16, SCE_REBOL_URL => 17, SCE_REBOL_DATE => 18, SCE_REBOL_TIME => 19, SCE_REBOL_IDENTIFIER => 20, SCE_REBOL_WORD => 21, SCE_REBOL_WORD2 => 22, SCE_REBOL_WORD3 => 23, SCE_REBOL_WORD4 => 24, SCE_REBOL_WORD5 => 25, SCE_REBOL_WORD6 => 26, SCE_REBOL_WORD7 => 27, SCE_REBOL_WORD8 => 28, # Lexical states for SCLEX_SQL SCE_SQL_DEFAULT => 0, SCE_SQL_COMMENT => 1, SCE_SQL_COMMENTLINE => 2, SCE_SQL_COMMENTDOC => 3, SCE_SQL_NUMBER => 4, SCE_SQL_WORD => 5, SCE_SQL_STRING => 6, SCE_SQL_CHARACTER => 7, SCE_SQL_SQLPLUS => 8, SCE_SQL_SQLPLUS_PROMPT => 9, SCE_SQL_OPERATOR => 10, SCE_SQL_IDENTIFIER => 11, SCE_SQL_SQLPLUS_COMMENT => 13, SCE_SQL_COMMENTLINEDOC => 15, SCE_SQL_WORD2 => 16, SCE_SQL_COMMENTDOCKEYWORD => 17, SCE_SQL_COMMENTDOCKEYWORDERROR => 18, SCE_SQL_USER1 => 19, SCE_SQL_USER2 => 20, SCE_SQL_USER3 => 21, SCE_SQL_USER4 => 22, SCE_SQL_QUOTEDIDENTIFIER => 23, # Lexical states for SCLEX_SMALLTALK SCE_ST_DEFAULT => 0, SCE_ST_STRING => 1, SCE_ST_NUMBER => 2, SCE_ST_COMMENT => 3, SCE_ST_SYMBOL => 4, SCE_ST_BINARY => 5, SCE_ST_BOOL => 6, SCE_ST_SELF => 7, SCE_ST_SUPER => 8, SCE_ST_NIL => 9, SCE_ST_GLOBAL => 10, SCE_ST_RETURN => 11, SCE_ST_SPECIAL => 12, SCE_ST_KWSEND => 13, SCE_ST_ASSIGN => 14, SCE_ST_CHARACTER => 15, SCE_ST_SPEC_SEL => 16, # Lexical states for SCLEX_FLAGSHIP (clipper) SCE_FS_DEFAULT => 0, SCE_FS_COMMENT => 1, SCE_FS_COMMENTLINE => 2, SCE_FS_COMMENTDOC => 3, SCE_FS_COMMENTLINEDOC => 4, SCE_FS_COMMENTDOCKEYWORD => 5, SCE_FS_COMMENTDOCKEYWORDERROR => 6, SCE_FS_KEYWORD => 7, SCE_FS_KEYWORD2 => 8, SCE_FS_KEYWORD3 => 9, SCE_FS_KEYWORD4 => 10, SCE_FS_NUMBER => 11, SCE_FS_STRING => 12, SCE_FS_PREPROCESSOR => 13, SCE_FS_OPERATOR => 14, SCE_FS_IDENTIFIER => 15, SCE_FS_DATE => 16, SCE_FS_STRINGEOL => 17, SCE_FS_CONSTANT => 18, SCE_FS_WORDOPERATOR => 19, SCE_FS_DISABLEDCODE => 20, SCE_FS_DEFAULT_C => 21, SCE_FS_COMMENTDOC_C => 22, SCE_FS_COMMENTLINEDOC_C => 23, SCE_FS_KEYWORD_C => 24, SCE_FS_KEYWORD2_C => 25, SCE_FS_NUMBER_C => 26, SCE_FS_STRING_C => 27, SCE_FS_PREPROCESSOR_C => 28, SCE_FS_OPERATOR_C => 29, SCE_FS_IDENTIFIER_C => 30, SCE_FS_STRINGEOL_C => 31, # Lexical states for SCLEX_CSOUND SCE_CSOUND_DEFAULT => 0, SCE_CSOUND_COMMENT => 1, SCE_CSOUND_NUMBER => 2, SCE_CSOUND_OPERATOR => 3, SCE_CSOUND_INSTR => 4, SCE_CSOUND_IDENTIFIER => 5, SCE_CSOUND_OPCODE => 6, SCE_CSOUND_HEADERSTMT => 7, SCE_CSOUND_USERKEYWORD => 8, SCE_CSOUND_COMMENTBLOCK => 9, SCE_CSOUND_PARAM => 10, SCE_CSOUND_ARATE_VAR => 11, SCE_CSOUND_KRATE_VAR => 12, SCE_CSOUND_IRATE_VAR => 13, SCE_CSOUND_GLOBAL_VAR => 14, SCE_CSOUND_STRINGEOL => 15, # Lexical states for SCLEX_INNOSETUP SCE_INNO_DEFAULT => 0, SCE_INNO_COMMENT => 1, SCE_INNO_KEYWORD => 2, SCE_INNO_PARAMETER => 3, SCE_INNO_SECTION => 4, SCE_INNO_PREPROC => 5, SCE_INNO_INLINE_EXPANSION => 6, SCE_INNO_COMMENT_PASCAL => 7, SCE_INNO_KEYWORD_PASCAL => 8, SCE_INNO_KEYWORD_USER => 9, SCE_INNO_STRING_DOUBLE => 10, SCE_INNO_STRING_SINGLE => 11, SCE_INNO_IDENTIFIER => 12, # Lexical states for SCLEX_OPAL SCE_OPAL_SPACE => 0, SCE_OPAL_COMMENT_BLOCK => 1, SCE_OPAL_COMMENT_LINE => 2, SCE_OPAL_INTEGER => 3, SCE_OPAL_KEYWORD => 4, SCE_OPAL_SORT => 5, SCE_OPAL_STRING => 6, SCE_OPAL_PAR => 7, SCE_OPAL_BOOL_CONST => 8, SCE_OPAL_DEFAULT => 32, # Lexical states for SCLEX_SPICE SCE_SPICE_DEFAULT => 0, SCE_SPICE_IDENTIFIER => 1, SCE_SPICE_KEYWORD => 2, SCE_SPICE_KEYWORD2 => 3, SCE_SPICE_KEYWORD3 => 4, SCE_SPICE_NUMBER => 5, SCE_SPICE_DELIMITER => 6, SCE_SPICE_VALUE => 7, SCE_SPICE_COMMENTLINE => 8, # Lexical states for SCLEX_CMAKE SCE_CMAKE_DEFAULT => 0, SCE_CMAKE_COMMENT => 1, SCE_CMAKE_STRINGDQ => 2, SCE_CMAKE_STRINGLQ => 3, SCE_CMAKE_STRINGRQ => 4, SCE_CMAKE_COMMANDS => 5, SCE_CMAKE_PARAMETERS => 6, SCE_CMAKE_VARIABLE => 7, SCE_CMAKE_USERDEFINED => 8, SCE_CMAKE_WHILEDEF => 9, SCE_CMAKE_FOREACHDEF => 10, SCE_CMAKE_IFDEFINEDEF => 11, SCE_CMAKE_MACRODEF => 12, SCE_CMAKE_STRINGVAR => 13, SCE_CMAKE_NUMBER => 14, # Lexical states for SCLEX_GAP SCE_GAP_DEFAULT => 0, SCE_GAP_IDENTIFIER => 1, SCE_GAP_KEYWORD => 2, SCE_GAP_KEYWORD2 => 3, SCE_GAP_KEYWORD3 => 4, SCE_GAP_KEYWORD4 => 5, SCE_GAP_STRING => 6, SCE_GAP_CHAR => 7, SCE_GAP_OPERATOR => 8, SCE_GAP_COMMENT => 9, SCE_GAP_NUMBER => 10, SCE_GAP_STRINGEOL => 11, # Lexical state for SCLEX_PLM SCE_PLM_DEFAULT => 0, SCE_PLM_COMMENT => 1, SCE_PLM_STRING => 2, SCE_PLM_NUMBER => 3, SCE_PLM_IDENTIFIER => 4, SCE_PLM_OPERATOR => 5, SCE_PLM_CONTROL => 6, SCE_PLM_KEYWORD => 7, # Lexical state for SCLEX_PROGRESS SCE_4GL_DEFAULT => 0, SCE_4GL_NUMBER => 1, SCE_4GL_WORD => 2, SCE_4GL_STRING => 3, SCE_4GL_CHARACTER => 4, SCE_4GL_PREPROCESSOR => 5, SCE_4GL_OPERATOR => 6, SCE_4GL_IDENTIFIER => 7, SCE_4GL_BLOCK => 8, SCE_4GL_END => 9, SCE_4GL_COMMENT1 => 10, SCE_4GL_COMMENT2 => 11, SCE_4GL_COMMENT3 => 12, SCE_4GL_COMMENT4 => 13, SCE_4GL_COMMENT5 => 14, SCE_4GL_COMMENT6 => 15, SCE_4GL_DEFAULT_ => 16, SCE_4GL_NUMBER_ => 17, SCE_4GL_WORD_ => 18, SCE_4GL_STRING_ => 19, SCE_4GL_CHARACTER_ => 20, SCE_4GL_PREPROCESSOR_ => 21, SCE_4GL_OPERATOR_ => 22, SCE_4GL_IDENTIFIER_ => 23, SCE_4GL_BLOCK_ => 24, SCE_4GL_END_ => 25, SCE_4GL_COMMENT1_ => 26, SCE_4GL_COMMENT2_ => 27, SCE_4GL_COMMENT3_ => 28, SCE_4GL_COMMENT4_ => 29, SCE_4GL_COMMENT5_ => 30, SCE_4GL_COMMENT6_ => 31, # Lexical states for SCLEX_ABAQUS SCE_ABAQUS_DEFAULT => 0, SCE_ABAQUS_COMMENT => 1, SCE_ABAQUS_COMMENTBLOCK => 2, SCE_ABAQUS_NUMBER => 3, SCE_ABAQUS_STRING => 4, SCE_ABAQUS_OPERATOR => 5, SCE_ABAQUS_WORD => 6, SCE_ABAQUS_PROCESSOR => 7, SCE_ABAQUS_COMMAND => 8, SCE_ABAQUS_SLASHCOMMAND => 9, SCE_ABAQUS_STARCOMMAND => 10, SCE_ABAQUS_ARGUMENT => 11, SCE_ABAQUS_FUNCTION => 12, # Lexical states for SCLEX_ASYMPTOTE SCE_ASY_DEFAULT => 0, SCE_ASY_COMMENT => 1, SCE_ASY_COMMENTLINE => 2, SCE_ASY_NUMBER => 3, SCE_ASY_WORD => 4, SCE_ASY_STRING => 5, SCE_ASY_CHARACTER => 6, SCE_ASY_OPERATOR => 7, SCE_ASY_IDENTIFIER => 8, SCE_ASY_STRINGEOL => 9, SCE_ASY_COMMENTLINEDOC => 10, SCE_ASY_WORD2 => 11, # Lexical states for SCLEX_R SCE_R_DEFAULT => 0, SCE_R_COMMENT => 1, SCE_R_KWORD => 2, SCE_R_BASEKWORD => 3, SCE_R_OTHERKWORD => 4, SCE_R_NUMBER => 5, SCE_R_STRING => 6, SCE_R_STRING2 => 7, SCE_R_OPERATOR => 8, SCE_R_IDENTIFIER => 9, SCE_R_INFIX => 10, SCE_R_INFIXEOL => 11, # Lexical state for SCLEX_MAGIKSF SCE_MAGIK_DEFAULT => 0, SCE_MAGIK_COMMENT => 1, SCE_MAGIK_HYPER_COMMENT => 16, SCE_MAGIK_STRING => 2, SCE_MAGIK_CHARACTER => 3, SCE_MAGIK_NUMBER => 4, SCE_MAGIK_IDENTIFIER => 5, SCE_MAGIK_OPERATOR => 6, SCE_MAGIK_FLOW => 7, SCE_MAGIK_CONTAINER => 8, SCE_MAGIK_BRACKET_BLOCK => 9, SCE_MAGIK_BRACE_BLOCK => 10, SCE_MAGIK_SQBRACKET_BLOCK => 11, SCE_MAGIK_UNKNOWN_KEYWORD => 12, SCE_MAGIK_KEYWORD => 13, SCE_MAGIK_PRAGMA => 14, SCE_MAGIK_SYMBOL => 15, # Lexical state for SCLEX_POWERSHELL SCE_POWERSHELL_DEFAULT => 0, SCE_POWERSHELL_COMMENT => 1, SCE_POWERSHELL_STRING => 2, SCE_POWERSHELL_CHARACTER => 3, SCE_POWERSHELL_NUMBER => 4, SCE_POWERSHELL_VARIABLE => 5, SCE_POWERSHELL_OPERATOR => 6, SCE_POWERSHELL_IDENTIFIER => 7, SCE_POWERSHELL_KEYWORD => 8, SCE_POWERSHELL_CMDLET => 9, SCE_POWERSHELL_ALIAS => 10, SCE_POWERSHELL_FUNCTION => 11, SCE_POWERSHELL_USER1 => 12, SCE_POWERSHELL_COMMENTSTREAM => 13, # Lexical state for SCLEX_MYSQL SCE_MYSQL_DEFAULT => 0, SCE_MYSQL_COMMENT => 1, SCE_MYSQL_COMMENTLINE => 2, SCE_MYSQL_VARIABLE => 3, SCE_MYSQL_SYSTEMVARIABLE => 4, SCE_MYSQL_KNOWNSYSTEMVARIABLE => 5, SCE_MYSQL_NUMBER => 6, SCE_MYSQL_MAJORKEYWORD => 7, SCE_MYSQL_KEYWORD => 8, SCE_MYSQL_DATABASEOBJECT => 9, SCE_MYSQL_PROCEDUREKEYWORD => 10, SCE_MYSQL_STRING => 11, SCE_MYSQL_SQSTRING => 12, SCE_MYSQL_DQSTRING => 13, SCE_MYSQL_OPERATOR => 14, SCE_MYSQL_FUNCTION => 15, SCE_MYSQL_IDENTIFIER => 16, SCE_MYSQL_QUOTEDIDENTIFIER => 17, SCE_MYSQL_USER1 => 18, SCE_MYSQL_USER2 => 19, SCE_MYSQL_USER3 => 20, SCE_MYSQL_HIDDENCOMMAND => 21, # Lexical state for SCLEX_PO SCE_PO_DEFAULT => 0, SCE_PO_COMMENT => 1, SCE_PO_MSGID => 2, SCE_PO_MSGID_TEXT => 3, SCE_PO_MSGSTR => 4, SCE_PO_MSGSTR_TEXT => 5, SCE_PO_MSGCTXT => 6, SCE_PO_MSGCTXT_TEXT => 7, SCE_PO_FUZZY => 8, # Lexical states for SCLEX_PASCAL SCE_PAS_DEFAULT => 0, SCE_PAS_IDENTIFIER => 1, SCE_PAS_COMMENT => 2, SCE_PAS_COMMENT2 => 3, SCE_PAS_COMMENTLINE => 4, SCE_PAS_PREPROCESSOR => 5, SCE_PAS_PREPROCESSOR2 => 6, SCE_PAS_NUMBER => 7, SCE_PAS_HEXNUMBER => 8, SCE_PAS_WORD => 9, SCE_PAS_STRING => 10, SCE_PAS_STRINGEOL => 11, SCE_PAS_CHARACTER => 12, SCE_PAS_OPERATOR => 13, SCE_PAS_ASM => 14, # Lexical state for SCLEX_SORCUS SCE_SORCUS_DEFAULT => 0, SCE_SORCUS_COMMAND => 1, SCE_SORCUS_PARAMETER => 2, SCE_SORCUS_COMMENTLINE => 3, SCE_SORCUS_STRING => 4, SCE_SORCUS_STRINGEOL => 5, SCE_SORCUS_IDENTIFIER => 6, SCE_SORCUS_OPERATOR => 7, SCE_SORCUS_NUMBER => 8, SCE_SORCUS_CONSTANT => 9, # Lexical state for SCLEX_POWERPRO SCE_POWERPRO_DEFAULT => 0, SCE_POWERPRO_COMMENTBLOCK => 1, SCE_POWERPRO_COMMENTLINE => 2, SCE_POWERPRO_NUMBER => 3, SCE_POWERPRO_WORD => 4, SCE_POWERPRO_WORD2 => 5, SCE_POWERPRO_WORD3 => 6, SCE_POWERPRO_WORD4 => 7, SCE_POWERPRO_DOUBLEQUOTEDSTRING => 8, SCE_POWERPRO_SINGLEQUOTEDSTRING => 9, SCE_POWERPRO_LINECONTINUE => 10, SCE_POWERPRO_OPERATOR => 11, SCE_POWERPRO_IDENTIFIER => 12, SCE_POWERPRO_STRINGEOL => 13, SCE_POWERPRO_VERBATIM => 14, SCE_POWERPRO_ALTQUOTE => 15, SCE_POWERPRO_FUNCTION => 16, # Lexical states for SCLEX_SML SCE_SML_DEFAULT => 0, SCE_SML_IDENTIFIER => 1, SCE_SML_TAGNAME => 2, SCE_SML_KEYWORD => 3, SCE_SML_KEYWORD2 => 4, SCE_SML_KEYWORD3 => 5, SCE_SML_LINENUM => 6, SCE_SML_OPERATOR => 7, SCE_SML_NUMBER => 8, SCE_SML_CHAR => 9, SCE_SML_STRING => 11, SCE_SML_COMMENT => 12, SCE_SML_COMMENT1 => 13, SCE_SML_COMMENT2 => 14, SCE_SML_COMMENT3 => 15, # Lexical state for SCLEX_MARKDOWN SCE_MARKDOWN_DEFAULT => 0, SCE_MARKDOWN_LINE_BEGIN => 1, SCE_MARKDOWN_STRONG1 => 2, SCE_MARKDOWN_STRONG2 => 3, SCE_MARKDOWN_EM1 => 4, SCE_MARKDOWN_EM2 => 5, SCE_MARKDOWN_HEADER1 => 6, SCE_MARKDOWN_HEADER2 => 7, SCE_MARKDOWN_HEADER3 => 8, SCE_MARKDOWN_HEADER4 => 9, SCE_MARKDOWN_HEADER5 => 10, SCE_MARKDOWN_HEADER6 => 11, SCE_MARKDOWN_PRECHAR => 12, SCE_MARKDOWN_ULIST_ITEM => 13, SCE_MARKDOWN_OLIST_ITEM => 14, SCE_MARKDOWN_BLOCKQUOTE => 15, SCE_MARKDOWN_STRIKEOUT => 16, SCE_MARKDOWN_HRULE => 17, SCE_MARKDOWN_LINK => 18, SCE_MARKDOWN_CODE => 19, SCE_MARKDOWN_CODE2 => 20, SCE_MARKDOWN_CODEBK => 21, # Lexical state for SCLEX_TXT2TAGS SCE_TXT2TAGS_DEFAULT => 0, SCE_TXT2TAGS_LINE_BEGIN => 1, SCE_TXT2TAGS_STRONG1 => 2, SCE_TXT2TAGS_STRONG2 => 3, SCE_TXT2TAGS_EM1 => 4, SCE_TXT2TAGS_EM2 => 5, SCE_TXT2TAGS_HEADER1 => 6, SCE_TXT2TAGS_HEADER2 => 7, SCE_TXT2TAGS_HEADER3 => 8, SCE_TXT2TAGS_HEADER4 => 9, SCE_TXT2TAGS_HEADER5 => 10, SCE_TXT2TAGS_HEADER6 => 11, SCE_TXT2TAGS_PRECHAR => 12, SCE_TXT2TAGS_ULIST_ITEM => 13, SCE_TXT2TAGS_OLIST_ITEM => 14, SCE_TXT2TAGS_BLOCKQUOTE => 15, SCE_TXT2TAGS_STRIKEOUT => 16, SCE_TXT2TAGS_HRULE => 17, SCE_TXT2TAGS_LINK => 18, SCE_TXT2TAGS_CODE => 19, SCE_TXT2TAGS_CODE2 => 20, SCE_TXT2TAGS_CODEBK => 21, SCE_TXT2TAGS_COMMENT => 22, SCE_TXT2TAGS_OPTION => 23, SCE_TXT2TAGS_PREPROC => 24, SCE_TXT2TAGS_POSTPROC => 25, # Lexical states for SCLEX_A68K SCE_A68K_DEFAULT => 0, SCE_A68K_COMMENT => 1, SCE_A68K_NUMBER_DEC => 2, SCE_A68K_NUMBER_BIN => 3, SCE_A68K_NUMBER_HEX => 4, SCE_A68K_STRING1 => 5, SCE_A68K_OPERATOR => 6, SCE_A68K_CPUINSTRUCTION => 7, SCE_A68K_EXTINSTRUCTION => 8, SCE_A68K_REGISTER => 9, SCE_A68K_DIRECTIVE => 10, SCE_A68K_MACRO_ARG => 11, SCE_A68K_LABEL => 12, SCE_A68K_STRING2 => 13, SCE_A68K_IDENTIFIER => 14, SCE_A68K_MACRO_DECLARATION => 15, SCE_A68K_COMMENT_WORD => 16, SCE_A68K_COMMENT_SPECIAL => 17, SCE_A68K_COMMENT_DOXYGEN => 18, # Lexical states for SCLEX_MODULA SCE_MODULA_DEFAULT => 0, SCE_MODULA_COMMENT => 1, SCE_MODULA_DOXYCOMM => 2, SCE_MODULA_DOXYKEY => 3, SCE_MODULA_KEYWORD => 4, SCE_MODULA_RESERVED => 5, SCE_MODULA_NUMBER => 6, SCE_MODULA_BASENUM => 7, SCE_MODULA_FLOAT => 8, SCE_MODULA_STRING => 9, SCE_MODULA_STRSPEC => 10, SCE_MODULA_CHAR => 11, SCE_MODULA_CHARSPEC => 12, SCE_MODULA_PROC => 13, SCE_MODULA_PRAGMA => 14, SCE_MODULA_PRGKEY => 15, SCE_MODULA_OPERATOR => 16, SCE_MODULA_BADSTR => 17, # Lexical states for SCLEX_COFFEESCRIPT SCE_COFFEESCRIPT_DEFAULT => 0, SCE_COFFEESCRIPT_COMMENT => 1, SCE_COFFEESCRIPT_COMMENTLINE => 2, SCE_COFFEESCRIPT_COMMENTDOC => 3, SCE_COFFEESCRIPT_NUMBER => 4, SCE_COFFEESCRIPT_WORD => 5, SCE_COFFEESCRIPT_STRING => 6, SCE_COFFEESCRIPT_CHARACTER => 7, SCE_COFFEESCRIPT_UUID => 8, SCE_COFFEESCRIPT_PREPROCESSOR => 9, SCE_COFFEESCRIPT_OPERATOR => 10, SCE_COFFEESCRIPT_IDENTIFIER => 11, SCE_COFFEESCRIPT_STRINGEOL => 12, SCE_COFFEESCRIPT_VERBATIM => 13, SCE_COFFEESCRIPT_REGEX => 14, SCE_COFFEESCRIPT_COMMENTLINEDOC => 15, SCE_COFFEESCRIPT_WORD2 => 16, SCE_COFFEESCRIPT_COMMENTDOCKEYWORD => 17, SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR => 18, SCE_COFFEESCRIPT_GLOBALCLASS => 19, SCE_COFFEESCRIPT_STRINGRAW => 20, SCE_COFFEESCRIPT_TRIPLEVERBATIM => 21, SCE_COFFEESCRIPT_HASHQUOTEDSTRING => 22, SCE_COFFEESCRIPT_COMMENTBLOCK => 22, SCE_COFFEESCRIPT_VERBOSE_REGEX => 23, SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT => 24, # Lexical states for SCLEX_AVS SCE_AVS_DEFAULT => 0, SCE_AVS_COMMENTBLOCK => 1, SCE_AVS_COMMENTBLOCKN => 2, SCE_AVS_COMMENTLINE => 3, SCE_AVS_NUMBER => 4, SCE_AVS_OPERATOR => 5, SCE_AVS_IDENTIFIER => 6, SCE_AVS_STRING => 7, SCE_AVS_TRIPLESTRING => 8, SCE_AVS_KEYWORD => 9, SCE_AVS_FILTER => 10, SCE_AVS_PLUGIN => 11, SCE_AVS_FUNCTION => 12, SCE_AVS_CLIPPROP => 13, SCE_AVS_USERDFN => 14, # Lexical states for SCLEX_ECL SCE_ECL_DEFAULT => 0, SCE_ECL_COMMENT => 1, SCE_ECL_COMMENTLINE => 2, SCE_ECL_NUMBER => 3, SCE_ECL_STRING => 4, SCE_ECL_WORD0 => 5, SCE_ECL_OPERATOR => 6, SCE_ECL_CHARACTER => 7, SCE_ECL_UUID => 8, SCE_ECL_PREPROCESSOR => 9, SCE_ECL_UNKNOWN => 10, SCE_ECL_IDENTIFIER => 11, SCE_ECL_STRINGEOL => 12, SCE_ECL_VERBATIM => 13, SCE_ECL_REGEX => 14, SCE_ECL_COMMENTLINEDOC => 15, SCE_ECL_WORD1 => 16, SCE_ECL_COMMENTDOCKEYWORD => 17, SCE_ECL_COMMENTDOCKEYWORDERROR => 18, SCE_ECL_WORD2 => 19, SCE_ECL_WORD3 => 20, SCE_ECL_WORD4 => 21, SCE_ECL_WORD5 => 22, SCE_ECL_COMMENTDOC => 23, SCE_ECL_ADDED => 24, SCE_ECL_DELETED => 25, SCE_ECL_CHANGED => 26, SCE_ECL_MOVED => 27, # Deprecated in 2.21 # The SC_CP_DBCS value can be used to indicate a DBCS mode for GTK+. SC_CP_DBCS => 1, }; 1; __END__ =pod =head1 NAME Wx::Scintilla::Constant - A list of Wx::Scintilla constants =head1 DESCRIPTION This is a list of auto-generated constants from Scintilla.iface. =head1 CONSTANTS INVALID_POSITION (-1) Define start of Scintilla messages to be greater than all Windows edit (EM_*) messagesas many EM_ messages can be used although that use is deprecated. SCI_START (2000) SCI_OPTIONAL_START (3000) SCI_LEXER_START (4000) =head2 WhiteSpace enumeration SCWS_INVISIBLE (0) SCWS_VISIBLEALWAYS (1) SCWS_VISIBLEAFTERINDENT (2) =head2 EndOfLine enumeration SC_EOL_CRLF (0) SC_EOL_CR (1) SC_EOL_LF (2) The SC_CP_UTF8 value can be used to enter Unicode mode.This is the same value as CP_UTF8 in Windows SC_CP_UTF8 (65001) =head2 MarkerSymbol enumeration MARKER_MAX (31) SC_MARK_CIRCLE (0) SC_MARK_ROUNDRECT (1) SC_MARK_ARROW (2) SC_MARK_SMALLRECT (3) SC_MARK_SHORTARROW (4) SC_MARK_EMPTY (5) SC_MARK_ARROWDOWN (6) SC_MARK_MINUS (7) SC_MARK_PLUS (8) Shapes used for outlining column. SC_MARK_VLINE (9) SC_MARK_LCORNER (10) SC_MARK_TCORNER (11) SC_MARK_BOXPLUS (12) SC_MARK_BOXPLUSCONNECTED (13) SC_MARK_BOXMINUS (14) SC_MARK_BOXMINUSCONNECTED (15) SC_MARK_LCORNERCURVE (16) SC_MARK_TCORNERCURVE (17) SC_MARK_CIRCLEPLUS (18) SC_MARK_CIRCLEPLUSCONNECTED (19) SC_MARK_CIRCLEMINUS (20) SC_MARK_CIRCLEMINUSCONNECTED (21) Invisible mark that only sets the line background colour. SC_MARK_BACKGROUND (22) SC_MARK_DOTDOTDOT (23) SC_MARK_ARROWS (24) SC_MARK_PIXMAP (25) SC_MARK_FULLRECT (26) SC_MARK_LEFTRECT (27) SC_MARK_AVAILABLE (28) SC_MARK_UNDERLINE (29) SC_MARK_RGBAIMAGE (30) SC_MARK_CHARACTER (10000) =head2 MarkerOutline enumeration SC_MARKNUM_FOLDEREND (25) SC_MARKNUM_FOLDEROPENMID (26) SC_MARKNUM_FOLDERMIDTAIL (27) SC_MARKNUM_FOLDERTAIL (28) SC_MARKNUM_FOLDERSUB (29) SC_MARKNUM_FOLDER (30) SC_MARKNUM_FOLDEROPEN (31) SC_MASK_FOLDERS (0xFE000000) =head2 MarginType enumeration SC_MARGIN_SYMBOL (0) SC_MARGIN_NUMBER (1) SC_MARGIN_BACK (2) SC_MARGIN_FORE (3) SC_MARGIN_TEXT (4) SC_MARGIN_RTEXT (5) =head2 StylesCommon enumeration STYLE_DEFAULT (32) STYLE_LINENUMBER (33) STYLE_BRACELIGHT (34) STYLE_BRACEBAD (35) STYLE_CONTROLCHAR (36) STYLE_INDENTGUIDE (37) STYLE_CALLTIP (38) STYLE_LASTPREDEFINED (39) STYLE_MAX (255) =head2 CharacterSet enumeration SC_CHARSET_ANSI (0) SC_CHARSET_DEFAULT (1) SC_CHARSET_BALTIC (186) SC_CHARSET_CHINESEBIG5 (136) SC_CHARSET_EASTEUROPE (238) SC_CHARSET_GB2312 (134) SC_CHARSET_GREEK (161) SC_CHARSET_HANGUL (129) SC_CHARSET_MAC (77) SC_CHARSET_OEM (255) SC_CHARSET_RUSSIAN (204) SC_CHARSET_CYRILLIC (1251) SC_CHARSET_SHIFTJIS (128) SC_CHARSET_SYMBOL (2) SC_CHARSET_TURKISH (162) SC_CHARSET_JOHAB (130) SC_CHARSET_HEBREW (177) SC_CHARSET_ARABIC (178) SC_CHARSET_VIETNAMESE (163) SC_CHARSET_THAI (222) SC_CHARSET_8859_15 (1000) =head2 CaseVisible enumeration SC_CASE_MIXED (0) SC_CASE_UPPER (1) SC_CASE_LOWER (2) SC_FONT_SIZE_MULTIPLIER (100) =head2 FontWeight enumeration SC_WEIGHT_NORMAL (400) SC_WEIGHT_SEMIBOLD (600) SC_WEIGHT_BOLD (700) =head2 IndicatorStyle enumeration INDIC_PLAIN (0) INDIC_SQUIGGLE (1) INDIC_TT (2) INDIC_DIAGONAL (3) INDIC_STRIKE (4) INDIC_HIDDEN (5) INDIC_BOX (6) INDIC_ROUNDBOX (7) INDIC_STRAIGHTBOX (8) INDIC_DASH (9) INDIC_DOTS (10) INDIC_SQUIGGLELOW (11) INDIC_DOTBOX (12) INDIC_MAX (31) INDIC_CONTAINER (8) INDIC0_MASK (0x20) INDIC1_MASK (0x40) INDIC2_MASK (0x80) INDICS_MASK (0xE0) =head2 IndentView enumeration SC_IV_NONE (0) SC_IV_REAL (1) SC_IV_LOOKFORWARD (2) SC_IV_LOOKBOTH (3) =head2 PrintOption enumeration SC_PRINT_NORMAL (0) PrintColourMode - invert the light value of each style for printing. SC_PRINT_INVERTLIGHT (1) PrintColourMode - force black text on white background for printing. SC_PRINT_BLACKONWHITE (2) PrintColourMode - text stays coloured, but all background is forced to be white for printing. SC_PRINT_COLOURONWHITE (3) PrintColourMode - only the default-background is forced to be white for printing. SC_PRINT_COLOURONWHITEDEFAULTBG (4) =head2 FindOption enumeration SCFIND_WHOLEWORD (2) SCFIND_MATCHCASE (4) SCFIND_WORDSTART (0x00100000) SCFIND_REGEXP (0x00200000) SCFIND_POSIX (0x00400000) =head2 FoldLevel enumeration SC_FOLDLEVELBASE (0x400) SC_FOLDLEVELWHITEFLAG (0x1000) SC_FOLDLEVELHEADERFLAG (0x2000) SC_FOLDLEVELNUMBERMASK (0x0FFF) =head2 FoldFlag enumeration SC_FOLDFLAG_LINEBEFORE_EXPANDED (0x0002) SC_FOLDFLAG_LINEBEFORE_CONTRACTED (0x0004) SC_FOLDFLAG_LINEAFTER_EXPANDED (0x0008) SC_FOLDFLAG_LINEAFTER_CONTRACTED (0x0010) SC_FOLDFLAG_LEVELNUMBERS (0x0040) SC_TIME_FOREVER (10000000) =head2 Wrap enumeration SC_WRAP_NONE (0) SC_WRAP_WORD (1) SC_WRAP_CHAR (2) =head2 WrapVisualFlag enumeration SC_WRAPVISUALFLAG_NONE (0x0000) SC_WRAPVISUALFLAG_END (0x0001) SC_WRAPVISUALFLAG_START (0x0002) =head2 WrapVisualLocation enumeration SC_WRAPVISUALFLAGLOC_DEFAULT (0x0000) SC_WRAPVISUALFLAGLOC_END_BY_TEXT (0x0001) SC_WRAPVISUALFLAGLOC_START_BY_TEXT (0x0002) =head2 WrapIndentMode enumeration SC_WRAPINDENT_FIXED (0) SC_WRAPINDENT_SAME (1) SC_WRAPINDENT_INDENT (2) =head2 LineCache enumeration SC_CACHE_NONE (0) SC_CACHE_CARET (1) SC_CACHE_PAGE (2) SC_CACHE_DOCUMENT (3) =head2 FontQuality enumeration SC_EFF_QUALITY_MASK (0xF) SC_EFF_QUALITY_DEFAULT (0) SC_EFF_QUALITY_NON_ANTIALIASED (1) SC_EFF_QUALITY_ANTIALIASED (2) SC_EFF_QUALITY_LCD_OPTIMIZED (3) =head2 MultiPaste enumeration SC_MULTIPASTE_ONCE (0) SC_MULTIPASTE_EACH (1) =head2 EdgeVisualStyle enumeration EDGE_NONE (0) EDGE_LINE (1) EDGE_BACKGROUND (2) =head2 Status enumeration SC_STATUS_OK (0) SC_STATUS_FAILURE (1) SC_STATUS_BADALLOC (2) =head2 CursorShape enumeration SC_CURSORNORMAL (-1) SC_CURSORARROW (2) SC_CURSORWAIT (4) SC_CURSORREVERSEARROW (7) Constants for use with SetVisiblePolicy, similar to SetCaretPolicy. VISIBLE_SLOP (0x01) VISIBLE_STRICT (0x04) =head2 CaretPolicy enumeration CARET_SLOP (0x01) If CARET_STRICT is set, the policy is enforced... strictly.The caret is centred on the display if slop is not set,and cannot go in the UZ if slop is set. CARET_STRICT (0x04) If CARET_JUMPS is set, the display is moved more energeticallyso the caret can move in the same direction longer before the policy is applied again. CARET_JUMPS (0x10) If CARET_EVEN is not set, instead of having symmetrical UZs,the left and bottom UZs are extended up to right and top UZs respectively.This way, we favour the displaying of useful information: the begining of lines,where most code reside, and the lines after the caret, eg. the body of a function. CARET_EVEN (0x08) =head2 SelectionMode enumeration SC_SEL_STREAM (0) SC_SEL_RECTANGLE (1) SC_SEL_LINES (2) SC_SEL_THIN (3) =head2 CaretSticky enumeration SC_CARETSTICKY_OFF (0) SC_CARETSTICKY_ON (1) SC_CARETSTICKY_WHITESPACE (2) SC_ALPHA_TRANSPARENT (0) SC_ALPHA_OPAQUE (255) SC_ALPHA_NOALPHA (256) =head2 CaretStyle enumeration CARETSTYLE_INVISIBLE (0) CARETSTYLE_LINE (1) CARETSTYLE_BLOCK (2) =head2 MarginOption enumeration SC_MARGINOPTION_NONE (0) SC_MARGINOPTION_SUBLINESELECT (1) =head2 AnnotationVisible enumeration ANNOTATION_HIDDEN (0) ANNOTATION_STANDARD (1) ANNOTATION_BOXED (2) UNDO_MAY_COALESCE (1) =head2 VirtualSpace enumeration SCVS_NONE (0) SCVS_RECTANGULARSELECTION (1) SCVS_USERACCESSIBLE (2) SC_TECHNOLOGY_DEFAULT (0) SC_TECHNOLOGY_DIRECTWRITE (1) Maximum value of keywordSet parameter of SetKeyWords. KEYWORDSET_MAX (8) =head2 TypeProperty enumeration SC_TYPE_BOOLEAN (0) SC_TYPE_INTEGER (1) SC_TYPE_STRING (2) NotificationsType 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.One bit is set from each of SC_MOD_* and SC_PERFORMED_*. SC_MOD_INSERTTEXT (0x1) SC_MOD_DELETETEXT (0x2) SC_MOD_CHANGESTYLE (0x4) SC_MOD_CHANGEFOLD (0x8) SC_PERFORMED_USER (0x10) SC_PERFORMED_UNDO (0x20) SC_PERFORMED_REDO (0x40) SC_MULTISTEPUNDOREDO (0x80) SC_LASTSTEPINUNDOREDO (0x100) SC_MOD_CHANGEMARKER (0x200) SC_MOD_BEFOREINSERT (0x400) SC_MOD_BEFOREDELETE (0x800) SC_MULTILINEUNDOREDO (0x1000) SC_STARTACTION (0x2000) SC_MOD_CHANGEINDICATOR (0x4000) SC_MOD_CHANGELINESTATE (0x8000) SC_MOD_CHANGEMARGIN (0x10000) SC_MOD_CHANGEANNOTATION (0x20000) SC_MOD_CONTAINER (0x40000) SC_MOD_LEXERSTATE (0x80000) SC_MODEVENTMASKALL (0xFFFFF) =head2 Update enumeration SC_UPDATE_CONTENT (0x1) SC_UPDATE_SELECTION (0x2) SC_UPDATE_V_SCROLL (0x4) SC_UPDATE_H_SCROLL (0x8) For compatibility, these go through the COMMAND notification rather than NOTIFYand should have had exactly the same values as the EN_* constants.Unfortunately the SETFOCUS and KILLFOCUS are flipped over from EN_*As clients depend on these constants, this will not be changed. SCEN_CHANGE (768) SCEN_SETFOCUS (512) SCEN_KILLFOCUS (256) =head2 Keys enumeration SCK_DOWN (300) SCK_UP (301) SCK_LEFT (302) SCK_RIGHT (303) SCK_HOME (304) SCK_END (305) SCK_PRIOR (306) SCK_NEXT (307) SCK_DELETE (308) SCK_INSERT (309) SCK_ESCAPE (7) SCK_BACK (8) SCK_TAB (9) SCK_RETURN (13) SCK_ADD (310) SCK_SUBTRACT (311) SCK_DIVIDE (312) SCK_WIN (313) SCK_RWIN (314) SCK_MENU (315) =head2 KeyMod enumeration SCMOD_NORM (0) SCMOD_SHIFT (1) SCMOD_CTRL (2) SCMOD_ALT (4) SCMOD_SUPER (8) SCMOD_META (16) =head2 Lexer enumeration SCLEX_CONTAINER (0) SCLEX_NULL (1) SCLEX_PYTHON (2) SCLEX_CPP (3) SCLEX_HTML (4) SCLEX_XML (5) SCLEX_PERL (6) SCLEX_SQL (7) SCLEX_VB (8) SCLEX_PROPERTIES (9) SCLEX_ERRORLIST (10) SCLEX_MAKEFILE (11) SCLEX_BATCH (12) SCLEX_XCODE (13) SCLEX_LATEX (14) SCLEX_LUA (15) SCLEX_DIFF (16) SCLEX_CONF (17) SCLEX_PASCAL (18) SCLEX_AVE (19) SCLEX_ADA (20) SCLEX_LISP (21) SCLEX_RUBY (22) SCLEX_EIFFEL (23) SCLEX_EIFFELKW (24) SCLEX_TCL (25) SCLEX_NNCRONTAB (26) SCLEX_BULLANT (27) SCLEX_VBSCRIPT (28) SCLEX_BAAN (31) SCLEX_MATLAB (32) SCLEX_SCRIPTOL (33) SCLEX_ASM (34) SCLEX_CPPNOCASE (35) SCLEX_FORTRAN (36) SCLEX_F77 (37) SCLEX_CSS (38) SCLEX_POV (39) SCLEX_LOUT (40) SCLEX_ESCRIPT (41) SCLEX_PS (42) SCLEX_NSIS (43) SCLEX_MMIXAL (44) SCLEX_CLW (45) SCLEX_CLWNOCASE (46) SCLEX_LOT (47) SCLEX_YAML (48) SCLEX_TEX (49) SCLEX_METAPOST (50) SCLEX_POWERBASIC (51) SCLEX_FORTH (52) SCLEX_ERLANG (53) SCLEX_OCTAVE (54) SCLEX_MSSQL (55) SCLEX_VERILOG (56) SCLEX_KIX (57) SCLEX_GUI4CLI (58) SCLEX_SPECMAN (59) SCLEX_AU3 (60) SCLEX_APDL (61) SCLEX_BASH (62) SCLEX_ASN1 (63) SCLEX_VHDL (64) SCLEX_CAML (65) SCLEX_BLITZBASIC (66) SCLEX_PUREBASIC (67) SCLEX_HASKELL (68) SCLEX_PHPSCRIPT (69) SCLEX_TADS3 (70) SCLEX_REBOL (71) SCLEX_SMALLTALK (72) SCLEX_FLAGSHIP (73) SCLEX_CSOUND (74) SCLEX_FREEBASIC (75) SCLEX_INNOSETUP (76) SCLEX_OPAL (77) SCLEX_SPICE (78) SCLEX_D (79) SCLEX_CMAKE (80) SCLEX_GAP (81) SCLEX_PLM (82) SCLEX_PROGRESS (83) SCLEX_ABAQUS (84) SCLEX_ASYMPTOTE (85) SCLEX_R (86) SCLEX_MAGIK (87) SCLEX_POWERSHELL (88) SCLEX_MYSQL (89) SCLEX_PO (90) SCLEX_TAL (91) SCLEX_COBOL (92) SCLEX_TACL (93) SCLEX_SORCUS (94) SCLEX_POWERPRO (95) SCLEX_NIMROD (96) SCLEX_SML (97) SCLEX_MARKDOWN (98) SCLEX_TXT2TAGS (99) SCLEX_A68K (100) SCLEX_MODULA (101) SCLEX_COFFEESCRIPT (102) SCLEX_TCMD (103) SCLEX_AVS (104) SCLEX_ECL (105) When a lexer specifies its language as SCLEX_AUTOMATIC it receives avalue assigned in sequence from SCLEX_AUTOMATIC+1. SCLEX_AUTOMATIC (1000) =head2 Lexical states for SCLEX_PYTHON SCE_P_DEFAULT (0) SCE_P_COMMENTLINE (1) SCE_P_NUMBER (2) SCE_P_STRING (3) SCE_P_CHARACTER (4) SCE_P_WORD (5) SCE_P_TRIPLE (6) SCE_P_TRIPLEDOUBLE (7) SCE_P_CLASSNAME (8) SCE_P_DEFNAME (9) SCE_P_OPERATOR (10) SCE_P_IDENTIFIER (11) SCE_P_COMMENTBLOCK (12) SCE_P_STRINGEOL (13) SCE_P_WORD2 (14) SCE_P_DECORATOR (15) =head2 Lexical states for SCLEX_CPP SCE_C_DEFAULT (0) SCE_C_COMMENT (1) SCE_C_COMMENTLINE (2) SCE_C_COMMENTDOC (3) SCE_C_NUMBER (4) SCE_C_WORD (5) SCE_C_STRING (6) SCE_C_CHARACTER (7) SCE_C_UUID (8) SCE_C_PREPROCESSOR (9) SCE_C_OPERATOR (10) SCE_C_IDENTIFIER (11) SCE_C_STRINGEOL (12) SCE_C_VERBATIM (13) SCE_C_REGEX (14) SCE_C_COMMENTLINEDOC (15) SCE_C_WORD2 (16) SCE_C_COMMENTDOCKEYWORD (17) SCE_C_COMMENTDOCKEYWORDERROR (18) SCE_C_GLOBALCLASS (19) SCE_C_STRINGRAW (20) SCE_C_TRIPLEVERBATIM (21) SCE_C_HASHQUOTEDSTRING (22) =head2 Lexical states for SCLEX_D SCE_D_DEFAULT (0) SCE_D_COMMENT (1) SCE_D_COMMENTLINE (2) SCE_D_COMMENTDOC (3) SCE_D_COMMENTNESTED (4) SCE_D_NUMBER (5) SCE_D_WORD (6) SCE_D_WORD2 (7) SCE_D_WORD3 (8) SCE_D_TYPEDEF (9) SCE_D_STRING (10) SCE_D_STRINGEOL (11) SCE_D_CHARACTER (12) SCE_D_OPERATOR (13) SCE_D_IDENTIFIER (14) SCE_D_COMMENTLINEDOC (15) SCE_D_COMMENTDOCKEYWORD (16) SCE_D_COMMENTDOCKEYWORDERROR (17) SCE_D_STRINGB (18) SCE_D_STRINGR (19) SCE_D_WORD5 (20) SCE_D_WORD6 (21) SCE_D_WORD7 (22) =head2 Lexical states for SCLEX_TCL SCE_TCL_DEFAULT (0) SCE_TCL_COMMENT (1) SCE_TCL_COMMENTLINE (2) SCE_TCL_NUMBER (3) SCE_TCL_WORD_IN_QUOTE (4) SCE_TCL_IN_QUOTE (5) SCE_TCL_OPERATOR (6) SCE_TCL_IDENTIFIER (7) SCE_TCL_SUBSTITUTION (8) SCE_TCL_SUB_BRACE (9) SCE_TCL_MODIFIER (10) SCE_TCL_EXPAND (11) SCE_TCL_WORD (12) SCE_TCL_WORD2 (13) SCE_TCL_WORD3 (14) SCE_TCL_WORD4 (15) SCE_TCL_WORD5 (16) SCE_TCL_WORD6 (17) SCE_TCL_WORD7 (18) SCE_TCL_WORD8 (19) SCE_TCL_COMMENT_BOX (20) SCE_TCL_BLOCK_COMMENT (21) =head2 Lexical states for SCLEX_HTML, SCLEX_XML SCE_H_DEFAULT (0) SCE_H_TAG (1) SCE_H_TAGUNKNOWN (2) SCE_H_ATTRIBUTE (3) SCE_H_ATTRIBUTEUNKNOWN (4) SCE_H_NUMBER (5) SCE_H_DOUBLESTRING (6) SCE_H_SINGLESTRING (7) SCE_H_OTHER (8) SCE_H_COMMENT (9) SCE_H_ENTITY (10) XML and ASP SCE_H_TAGEND (11) SCE_H_XMLSTART (12) SCE_H_XMLEND (13) SCE_H_SCRIPT (14) SCE_H_ASP (15) SCE_H_ASPAT (16) SCE_H_CDATA (17) SCE_H_QUESTION (18) More HTML SCE_H_VALUE (19) X-Code SCE_H_XCCOMMENT (20) SGML SCE_H_SGML_DEFAULT (21) SCE_H_SGML_COMMAND (22) SCE_H_SGML_1ST_PARAM (23) SCE_H_SGML_DOUBLESTRING (24) SCE_H_SGML_SIMPLESTRING (25) SCE_H_SGML_ERROR (26) SCE_H_SGML_SPECIAL (27) SCE_H_SGML_ENTITY (28) SCE_H_SGML_COMMENT (29) SCE_H_SGML_1ST_PARAM_COMMENT (30) SCE_H_SGML_BLOCK_DEFAULT (31) Embedded Javascript SCE_HJ_START (40) SCE_HJ_DEFAULT (41) SCE_HJ_COMMENT (42) SCE_HJ_COMMENTLINE (43) SCE_HJ_COMMENTDOC (44) SCE_HJ_NUMBER (45) SCE_HJ_WORD (46) SCE_HJ_KEYWORD (47) SCE_HJ_DOUBLESTRING (48) SCE_HJ_SINGLESTRING (49) SCE_HJ_SYMBOLS (50) SCE_HJ_STRINGEOL (51) SCE_HJ_REGEX (52) ASP Javascript SCE_HJA_START (55) SCE_HJA_DEFAULT (56) SCE_HJA_COMMENT (57) SCE_HJA_COMMENTLINE (58) SCE_HJA_COMMENTDOC (59) SCE_HJA_NUMBER (60) SCE_HJA_WORD (61) SCE_HJA_KEYWORD (62) SCE_HJA_DOUBLESTRING (63) SCE_HJA_SINGLESTRING (64) SCE_HJA_SYMBOLS (65) SCE_HJA_STRINGEOL (66) SCE_HJA_REGEX (67) Embedded VBScript SCE_HB_START (70) SCE_HB_DEFAULT (71) SCE_HB_COMMENTLINE (72) SCE_HB_NUMBER (73) SCE_HB_WORD (74) SCE_HB_STRING (75) SCE_HB_IDENTIFIER (76) SCE_HB_STRINGEOL (77) ASP VBScript SCE_HBA_START (80) SCE_HBA_DEFAULT (81) SCE_HBA_COMMENTLINE (82) SCE_HBA_NUMBER (83) SCE_HBA_WORD (84) SCE_HBA_STRING (85) SCE_HBA_IDENTIFIER (86) SCE_HBA_STRINGEOL (87) Embedded Python SCE_HP_START (90) SCE_HP_DEFAULT (91) SCE_HP_COMMENTLINE (92) SCE_HP_NUMBER (93) SCE_HP_STRING (94) SCE_HP_CHARACTER (95) SCE_HP_WORD (96) SCE_HP_TRIPLE (97) SCE_HP_TRIPLEDOUBLE (98) SCE_HP_CLASSNAME (99) SCE_HP_DEFNAME (100) SCE_HP_OPERATOR (101) SCE_HP_IDENTIFIER (102) PHP SCE_HPHP_COMPLEX_VARIABLE (104) ASP Python SCE_HPA_START (105) SCE_HPA_DEFAULT (106) SCE_HPA_COMMENTLINE (107) SCE_HPA_NUMBER (108) SCE_HPA_STRING (109) SCE_HPA_CHARACTER (110) SCE_HPA_WORD (111) SCE_HPA_TRIPLE (112) SCE_HPA_TRIPLEDOUBLE (113) SCE_HPA_CLASSNAME (114) SCE_HPA_DEFNAME (115) SCE_HPA_OPERATOR (116) SCE_HPA_IDENTIFIER (117) PHP SCE_HPHP_DEFAULT (118) SCE_HPHP_HSTRING (119) SCE_HPHP_SIMPLESTRING (120) SCE_HPHP_WORD (121) SCE_HPHP_NUMBER (122) SCE_HPHP_VARIABLE (123) SCE_HPHP_COMMENT (124) SCE_HPHP_COMMENTLINE (125) SCE_HPHP_HSTRING_VARIABLE (126) SCE_HPHP_OPERATOR (127) =head2 Lexical states for SCLEX_PERL SCE_PL_DEFAULT (0) SCE_PL_ERROR (1) SCE_PL_COMMENTLINE (2) SCE_PL_POD (3) SCE_PL_NUMBER (4) SCE_PL_WORD (5) SCE_PL_STRING (6) SCE_PL_CHARACTER (7) SCE_PL_PUNCTUATION (8) SCE_PL_PREPROCESSOR (9) SCE_PL_OPERATOR (10) SCE_PL_IDENTIFIER (11) SCE_PL_SCALAR (12) SCE_PL_ARRAY (13) SCE_PL_HASH (14) SCE_PL_SYMBOLTABLE (15) SCE_PL_VARIABLE_INDEXER (16) SCE_PL_REGEX (17) SCE_PL_REGSUBST (18) SCE_PL_LONGQUOTE (19) SCE_PL_BACKTICKS (20) SCE_PL_DATASECTION (21) SCE_PL_HERE_DELIM (22) SCE_PL_HERE_Q (23) SCE_PL_HERE_QQ (24) SCE_PL_HERE_QX (25) SCE_PL_STRING_Q (26) SCE_PL_STRING_QQ (27) SCE_PL_STRING_QX (28) SCE_PL_STRING_QR (29) SCE_PL_STRING_QW (30) SCE_PL_POD_VERB (31) SCE_PL_SUB_PROTOTYPE (40) SCE_PL_FORMAT_IDENT (41) SCE_PL_FORMAT (42) SCE_PL_STRING_VAR (43) SCE_PL_XLAT (44) SCE_PL_REGEX_VAR (54) SCE_PL_REGSUBST_VAR (55) SCE_PL_BACKTICKS_VAR (57) SCE_PL_HERE_QQ_VAR (61) SCE_PL_HERE_QX_VAR (62) SCE_PL_STRING_QQ_VAR (64) SCE_PL_STRING_QX_VAR (65) SCE_PL_STRING_QR_VAR (66) =head2 Lexical states for SCLEX_RUBY SCE_RB_DEFAULT (0) SCE_RB_ERROR (1) SCE_RB_COMMENTLINE (2) SCE_RB_POD (3) SCE_RB_NUMBER (4) SCE_RB_WORD (5) SCE_RB_STRING (6) SCE_RB_CHARACTER (7) SCE_RB_CLASSNAME (8) SCE_RB_DEFNAME (9) SCE_RB_OPERATOR (10) SCE_RB_IDENTIFIER (11) SCE_RB_REGEX (12) SCE_RB_GLOBAL (13) SCE_RB_SYMBOL (14) SCE_RB_MODULE_NAME (15) SCE_RB_INSTANCE_VAR (16) SCE_RB_CLASS_VAR (17) SCE_RB_BACKTICKS (18) SCE_RB_DATASECTION (19) SCE_RB_HERE_DELIM (20) SCE_RB_HERE_Q (21) SCE_RB_HERE_QQ (22) SCE_RB_HERE_QX (23) SCE_RB_STRING_Q (24) SCE_RB_STRING_QQ (25) SCE_RB_STRING_QX (26) SCE_RB_STRING_QR (27) SCE_RB_STRING_QW (28) SCE_RB_WORD_DEMOTED (29) SCE_RB_STDIN (30) SCE_RB_STDOUT (31) SCE_RB_STDERR (40) SCE_RB_UPPER_BOUND (41) =head2 Lexical states for SCLEX_VB, SCLEX_VBSCRIPT, SCLEX_POWERBASIC SCE_B_DEFAULT (0) SCE_B_COMMENT (1) SCE_B_NUMBER (2) SCE_B_KEYWORD (3) SCE_B_STRING (4) SCE_B_PREPROCESSOR (5) SCE_B_OPERATOR (6) SCE_B_IDENTIFIER (7) SCE_B_DATE (8) SCE_B_STRINGEOL (9) SCE_B_KEYWORD2 (10) SCE_B_KEYWORD3 (11) SCE_B_KEYWORD4 (12) SCE_B_CONSTANT (13) SCE_B_ASM (14) SCE_B_LABEL (15) SCE_B_ERROR (16) SCE_B_HEXNUMBER (17) SCE_B_BINNUMBER (18) =head2 Lexical states for SCLEX_PROPERTIES SCE_PROPS_DEFAULT (0) SCE_PROPS_COMMENT (1) SCE_PROPS_SECTION (2) SCE_PROPS_ASSIGNMENT (3) SCE_PROPS_DEFVAL (4) SCE_PROPS_KEY (5) =head2 Lexical states for SCLEX_LATEX SCE_L_DEFAULT (0) SCE_L_COMMAND (1) SCE_L_TAG (2) SCE_L_MATH (3) SCE_L_COMMENT (4) SCE_L_TAG2 (5) SCE_L_MATH2 (6) SCE_L_COMMENT2 (7) SCE_L_VERBATIM (8) SCE_L_SHORTCMD (9) SCE_L_SPECIAL (10) SCE_L_CMDOPT (11) SCE_L_ERROR (12) =head2 Lexical states for SCLEX_LUA SCE_LUA_DEFAULT (0) SCE_LUA_COMMENT (1) SCE_LUA_COMMENTLINE (2) SCE_LUA_COMMENTDOC (3) SCE_LUA_NUMBER (4) SCE_LUA_WORD (5) SCE_LUA_STRING (6) SCE_LUA_CHARACTER (7) SCE_LUA_LITERALSTRING (8) SCE_LUA_PREPROCESSOR (9) SCE_LUA_OPERATOR (10) SCE_LUA_IDENTIFIER (11) SCE_LUA_STRINGEOL (12) SCE_LUA_WORD2 (13) SCE_LUA_WORD3 (14) SCE_LUA_WORD4 (15) SCE_LUA_WORD5 (16) SCE_LUA_WORD6 (17) SCE_LUA_WORD7 (18) SCE_LUA_WORD8 (19) SCE_LUA_LABEL (20) =head2 Lexical states for SCLEX_ERRORLIST SCE_ERR_DEFAULT (0) SCE_ERR_PYTHON (1) SCE_ERR_GCC (2) SCE_ERR_MS (3) SCE_ERR_CMD (4) SCE_ERR_BORLAND (5) SCE_ERR_PERL (6) SCE_ERR_NET (7) SCE_ERR_LUA (8) SCE_ERR_CTAG (9) SCE_ERR_DIFF_CHANGED (10) SCE_ERR_DIFF_ADDITION (11) SCE_ERR_DIFF_DELETION (12) SCE_ERR_DIFF_MESSAGE (13) SCE_ERR_PHP (14) SCE_ERR_ELF (15) SCE_ERR_IFC (16) SCE_ERR_IFORT (17) SCE_ERR_ABSF (18) SCE_ERR_TIDY (19) SCE_ERR_JAVA_STACK (20) SCE_ERR_VALUE (21) =head2 Lexical states for SCLEX_BATCH SCE_BAT_DEFAULT (0) SCE_BAT_COMMENT (1) SCE_BAT_WORD (2) SCE_BAT_LABEL (3) SCE_BAT_HIDE (4) SCE_BAT_COMMAND (5) SCE_BAT_IDENTIFIER (6) SCE_BAT_OPERATOR (7) =head2 Lexical states for SCLEX_TCMD SCE_TCMD_DEFAULT (0) SCE_TCMD_COMMENT (1) SCE_TCMD_WORD (2) SCE_TCMD_LABEL (3) SCE_TCMD_HIDE (4) SCE_TCMD_COMMAND (5) SCE_TCMD_IDENTIFIER (6) SCE_TCMD_OPERATOR (7) SCE_TCMD_ENVIRONMENT (8) SCE_TCMD_EXPANSION (9) SCE_TCMD_CLABEL (10) =head2 Lexical states for SCLEX_MAKEFILE SCE_MAKE_DEFAULT (0) SCE_MAKE_COMMENT (1) SCE_MAKE_PREPROCESSOR (2) SCE_MAKE_IDENTIFIER (3) SCE_MAKE_OPERATOR (4) SCE_MAKE_TARGET (5) SCE_MAKE_IDEOL (9) =head2 Lexical states for SCLEX_DIFF SCE_DIFF_DEFAULT (0) SCE_DIFF_COMMENT (1) SCE_DIFF_COMMAND (2) SCE_DIFF_HEADER (3) SCE_DIFF_POSITION (4) SCE_DIFF_DELETED (5) SCE_DIFF_ADDED (6) SCE_DIFF_CHANGED (7) =head2 Lexical states for SCLEX_CONF (Apache Configuration Files Lexer) SCE_CONF_DEFAULT (0) SCE_CONF_COMMENT (1) SCE_CONF_NUMBER (2) SCE_CONF_IDENTIFIER (3) SCE_CONF_EXTENSION (4) SCE_CONF_PARAMETER (5) SCE_CONF_STRING (6) SCE_CONF_OPERATOR (7) SCE_CONF_IP (8) SCE_CONF_DIRECTIVE (9) =head2 Lexical states for SCLEX_AVE, Avenue SCE_AVE_DEFAULT (0) SCE_AVE_COMMENT (1) SCE_AVE_NUMBER (2) SCE_AVE_WORD (3) SCE_AVE_STRING (6) SCE_AVE_ENUM (7) SCE_AVE_STRINGEOL (8) SCE_AVE_IDENTIFIER (9) SCE_AVE_OPERATOR (10) SCE_AVE_WORD1 (11) SCE_AVE_WORD2 (12) SCE_AVE_WORD3 (13) SCE_AVE_WORD4 (14) SCE_AVE_WORD5 (15) SCE_AVE_WORD6 (16) =head2 Lexical states for SCLEX_ADA SCE_ADA_DEFAULT (0) SCE_ADA_WORD (1) SCE_ADA_IDENTIFIER (2) SCE_ADA_NUMBER (3) SCE_ADA_DELIMITER (4) SCE_ADA_CHARACTER (5) SCE_ADA_CHARACTEREOL (6) SCE_ADA_STRING (7) SCE_ADA_STRINGEOL (8) SCE_ADA_LABEL (9) SCE_ADA_COMMENTLINE (10) SCE_ADA_ILLEGAL (11) =head2 Lexical states for SCLEX_BAAN SCE_BAAN_DEFAULT (0) SCE_BAAN_COMMENT (1) SCE_BAAN_COMMENTDOC (2) SCE_BAAN_NUMBER (3) SCE_BAAN_WORD (4) SCE_BAAN_STRING (5) SCE_BAAN_PREPROCESSOR (6) SCE_BAAN_OPERATOR (7) SCE_BAAN_IDENTIFIER (8) SCE_BAAN_STRINGEOL (9) SCE_BAAN_WORD2 (10) =head2 Lexical states for SCLEX_LISP SCE_LISP_DEFAULT (0) SCE_LISP_COMMENT (1) SCE_LISP_NUMBER (2) SCE_LISP_KEYWORD (3) SCE_LISP_KEYWORD_KW (4) SCE_LISP_SYMBOL (5) SCE_LISP_STRING (6) SCE_LISP_STRINGEOL (8) SCE_LISP_IDENTIFIER (9) SCE_LISP_OPERATOR (10) SCE_LISP_SPECIAL (11) SCE_LISP_MULTI_COMMENT (12) =head2 Lexical states for SCLEX_EIFFEL and SCLEX_EIFFELKW SCE_EIFFEL_DEFAULT (0) SCE_EIFFEL_COMMENTLINE (1) SCE_EIFFEL_NUMBER (2) SCE_EIFFEL_WORD (3) SCE_EIFFEL_STRING (4) SCE_EIFFEL_CHARACTER (5) SCE_EIFFEL_OPERATOR (6) SCE_EIFFEL_IDENTIFIER (7) SCE_EIFFEL_STRINGEOL (8) =head2 Lexical states for SCLEX_NNCRONTAB (nnCron crontab Lexer) SCE_NNCRONTAB_DEFAULT (0) SCE_NNCRONTAB_COMMENT (1) SCE_NNCRONTAB_TASK (2) SCE_NNCRONTAB_SECTION (3) SCE_NNCRONTAB_KEYWORD (4) SCE_NNCRONTAB_MODIFIER (5) SCE_NNCRONTAB_ASTERISK (6) SCE_NNCRONTAB_NUMBER (7) SCE_NNCRONTAB_STRING (8) SCE_NNCRONTAB_ENVIRONMENT (9) SCE_NNCRONTAB_IDENTIFIER (10) =head2 Lexical states for SCLEX_FORTH (Forth Lexer) SCE_FORTH_DEFAULT (0) SCE_FORTH_COMMENT (1) SCE_FORTH_COMMENT_ML (2) SCE_FORTH_IDENTIFIER (3) SCE_FORTH_CONTROL (4) SCE_FORTH_KEYWORD (5) SCE_FORTH_DEFWORD (6) SCE_FORTH_PREWORD1 (7) SCE_FORTH_PREWORD2 (8) SCE_FORTH_NUMBER (9) SCE_FORTH_STRING (10) SCE_FORTH_LOCALE (11) =head2 Lexical states for SCLEX_MATLAB SCE_MATLAB_DEFAULT (0) SCE_MATLAB_COMMENT (1) SCE_MATLAB_COMMAND (2) SCE_MATLAB_NUMBER (3) SCE_MATLAB_KEYWORD (4) single quoted string SCE_MATLAB_STRING (5) SCE_MATLAB_OPERATOR (6) SCE_MATLAB_IDENTIFIER (7) SCE_MATLAB_DOUBLEQUOTESTRING (8) =head2 Lexical states for SCLEX_SCRIPTOL SCE_SCRIPTOL_DEFAULT (0) SCE_SCRIPTOL_WHITE (1) SCE_SCRIPTOL_COMMENTLINE (2) SCE_SCRIPTOL_PERSISTENT (3) SCE_SCRIPTOL_CSTYLE (4) SCE_SCRIPTOL_COMMENTBLOCK (5) SCE_SCRIPTOL_NUMBER (6) SCE_SCRIPTOL_STRING (7) SCE_SCRIPTOL_CHARACTER (8) SCE_SCRIPTOL_STRINGEOL (9) SCE_SCRIPTOL_KEYWORD (10) SCE_SCRIPTOL_OPERATOR (11) SCE_SCRIPTOL_IDENTIFIER (12) SCE_SCRIPTOL_TRIPLE (13) SCE_SCRIPTOL_CLASSNAME (14) SCE_SCRIPTOL_PREPROCESSOR (15) =head2 Lexical states for SCLEX_ASM SCE_ASM_DEFAULT (0) SCE_ASM_COMMENT (1) SCE_ASM_NUMBER (2) SCE_ASM_STRING (3) SCE_ASM_OPERATOR (4) SCE_ASM_IDENTIFIER (5) SCE_ASM_CPUINSTRUCTION (6) SCE_ASM_MATHINSTRUCTION (7) SCE_ASM_REGISTER (8) SCE_ASM_DIRECTIVE (9) SCE_ASM_DIRECTIVEOPERAND (10) SCE_ASM_COMMENTBLOCK (11) SCE_ASM_CHARACTER (12) SCE_ASM_STRINGEOL (13) SCE_ASM_EXTINSTRUCTION (14) SCE_ASM_COMMENTDIRECTIVE (15) =head2 Lexical states for SCLEX_FORTRAN SCE_F_DEFAULT (0) SCE_F_COMMENT (1) SCE_F_NUMBER (2) SCE_F_STRING1 (3) SCE_F_STRING2 (4) SCE_F_STRINGEOL (5) SCE_F_OPERATOR (6) SCE_F_IDENTIFIER (7) SCE_F_WORD (8) SCE_F_WORD2 (9) SCE_F_WORD3 (10) SCE_F_PREPROCESSOR (11) SCE_F_OPERATOR2 (12) SCE_F_LABEL (13) SCE_F_CONTINUATION (14) =head2 Lexical states for SCLEX_CSS SCE_CSS_DEFAULT (0) SCE_CSS_TAG (1) SCE_CSS_CLASS (2) SCE_CSS_PSEUDOCLASS (3) SCE_CSS_UNKNOWN_PSEUDOCLASS (4) SCE_CSS_OPERATOR (5) SCE_CSS_IDENTIFIER (6) SCE_CSS_UNKNOWN_IDENTIFIER (7) SCE_CSS_VALUE (8) SCE_CSS_COMMENT (9) SCE_CSS_ID (10) SCE_CSS_IMPORTANT (11) SCE_CSS_DIRECTIVE (12) SCE_CSS_DOUBLESTRING (13) SCE_CSS_SINGLESTRING (14) SCE_CSS_IDENTIFIER2 (15) SCE_CSS_ATTRIBUTE (16) SCE_CSS_IDENTIFIER3 (17) SCE_CSS_PSEUDOELEMENT (18) SCE_CSS_EXTENDED_IDENTIFIER (19) SCE_CSS_EXTENDED_PSEUDOCLASS (20) SCE_CSS_EXTENDED_PSEUDOELEMENT (21) SCE_CSS_MEDIA (22) SCE_CSS_VARIABLE (23) =head2 Lexical states for SCLEX_POV SCE_POV_DEFAULT (0) SCE_POV_COMMENT (1) SCE_POV_COMMENTLINE (2) SCE_POV_NUMBER (3) SCE_POV_OPERATOR (4) SCE_POV_IDENTIFIER (5) SCE_POV_STRING (6) SCE_POV_STRINGEOL (7) SCE_POV_DIRECTIVE (8) SCE_POV_BADDIRECTIVE (9) SCE_POV_WORD2 (10) SCE_POV_WORD3 (11) SCE_POV_WORD4 (12) SCE_POV_WORD5 (13) SCE_POV_WORD6 (14) SCE_POV_WORD7 (15) SCE_POV_WORD8 (16) =head2 Lexical states for SCLEX_LOUT SCE_LOUT_DEFAULT (0) SCE_LOUT_COMMENT (1) SCE_LOUT_NUMBER (2) SCE_LOUT_WORD (3) SCE_LOUT_WORD2 (4) SCE_LOUT_WORD3 (5) SCE_LOUT_WORD4 (6) SCE_LOUT_STRING (7) SCE_LOUT_OPERATOR (8) SCE_LOUT_IDENTIFIER (9) SCE_LOUT_STRINGEOL (10) =head2 Lexical states for SCLEX_ESCRIPT SCE_ESCRIPT_DEFAULT (0) SCE_ESCRIPT_COMMENT (1) SCE_ESCRIPT_COMMENTLINE (2) SCE_ESCRIPT_COMMENTDOC (3) SCE_ESCRIPT_NUMBER (4) SCE_ESCRIPT_WORD (5) SCE_ESCRIPT_STRING (6) SCE_ESCRIPT_OPERATOR (7) SCE_ESCRIPT_IDENTIFIER (8) SCE_ESCRIPT_BRACE (9) SCE_ESCRIPT_WORD2 (10) SCE_ESCRIPT_WORD3 (11) =head2 Lexical states for SCLEX_PS SCE_PS_DEFAULT (0) SCE_PS_COMMENT (1) SCE_PS_DSC_COMMENT (2) SCE_PS_DSC_VALUE (3) SCE_PS_NUMBER (4) SCE_PS_NAME (5) SCE_PS_KEYWORD (6) SCE_PS_LITERAL (7) SCE_PS_IMMEVAL (8) SCE_PS_PAREN_ARRAY (9) SCE_PS_PAREN_DICT (10) SCE_PS_PAREN_PROC (11) SCE_PS_TEXT (12) SCE_PS_HEXSTRING (13) SCE_PS_BASE85STRING (14) SCE_PS_BADSTRINGCHAR (15) =head2 Lexical states for SCLEX_NSIS SCE_NSIS_DEFAULT (0) SCE_NSIS_COMMENT (1) SCE_NSIS_STRINGDQ (2) SCE_NSIS_STRINGLQ (3) SCE_NSIS_STRINGRQ (4) SCE_NSIS_FUNCTION (5) SCE_NSIS_VARIABLE (6) SCE_NSIS_LABEL (7) SCE_NSIS_USERDEFINED (8) SCE_NSIS_SECTIONDEF (9) SCE_NSIS_SUBSECTIONDEF (10) SCE_NSIS_IFDEFINEDEF (11) SCE_NSIS_MACRODEF (12) SCE_NSIS_STRINGVAR (13) SCE_NSIS_NUMBER (14) SCE_NSIS_SECTIONGROUP (15) SCE_NSIS_PAGEEX (16) SCE_NSIS_FUNCTIONDEF (17) SCE_NSIS_COMMENTBOX (18) =head2 Lexical states for SCLEX_MMIXAL SCE_MMIXAL_LEADWS (0) SCE_MMIXAL_COMMENT (1) SCE_MMIXAL_LABEL (2) SCE_MMIXAL_OPCODE (3) SCE_MMIXAL_OPCODE_PRE (4) SCE_MMIXAL_OPCODE_VALID (5) SCE_MMIXAL_OPCODE_UNKNOWN (6) SCE_MMIXAL_OPCODE_POST (7) SCE_MMIXAL_OPERANDS (8) SCE_MMIXAL_NUMBER (9) SCE_MMIXAL_REF (10) SCE_MMIXAL_CHAR (11) SCE_MMIXAL_STRING (12) SCE_MMIXAL_REGISTER (13) SCE_MMIXAL_HEX (14) SCE_MMIXAL_OPERATOR (15) SCE_MMIXAL_SYMBOL (16) SCE_MMIXAL_INCLUDE (17) =head2 Lexical states for SCLEX_CLW SCE_CLW_DEFAULT (0) SCE_CLW_LABEL (1) SCE_CLW_COMMENT (2) SCE_CLW_STRING (3) SCE_CLW_USER_IDENTIFIER (4) SCE_CLW_INTEGER_CONSTANT (5) SCE_CLW_REAL_CONSTANT (6) SCE_CLW_PICTURE_STRING (7) SCE_CLW_KEYWORD (8) SCE_CLW_COMPILER_DIRECTIVE (9) SCE_CLW_RUNTIME_EXPRESSIONS (10) SCE_CLW_BUILTIN_PROCEDURES_FUNCTION (11) SCE_CLW_STRUCTURE_DATA_TYPE (12) SCE_CLW_ATTRIBUTE (13) SCE_CLW_STANDARD_EQUATE (14) SCE_CLW_ERROR (15) SCE_CLW_DEPRECATED (16) =head2 Lexical states for SCLEX_LOT SCE_LOT_DEFAULT (0) SCE_LOT_HEADER (1) SCE_LOT_BREAK (2) SCE_LOT_SET (3) SCE_LOT_PASS (4) SCE_LOT_FAIL (5) SCE_LOT_ABORT (6) =head2 Lexical states for SCLEX_YAML SCE_YAML_DEFAULT (0) SCE_YAML_COMMENT (1) SCE_YAML_IDENTIFIER (2) SCE_YAML_KEYWORD (3) SCE_YAML_NUMBER (4) SCE_YAML_REFERENCE (5) SCE_YAML_DOCUMENT (6) SCE_YAML_TEXT (7) SCE_YAML_ERROR (8) SCE_YAML_OPERATOR (9) =head2 Lexical states for SCLEX_TEX SCE_TEX_DEFAULT (0) SCE_TEX_SPECIAL (1) SCE_TEX_GROUP (2) SCE_TEX_SYMBOL (3) SCE_TEX_COMMAND (4) SCE_TEX_TEXT (5) SCE_METAPOST_DEFAULT (0) SCE_METAPOST_SPECIAL (1) SCE_METAPOST_GROUP (2) SCE_METAPOST_SYMBOL (3) SCE_METAPOST_COMMAND (4) SCE_METAPOST_TEXT (5) SCE_METAPOST_EXTRA (6) =head2 Lexical states for SCLEX_ERLANG SCE_ERLANG_DEFAULT (0) SCE_ERLANG_COMMENT (1) SCE_ERLANG_VARIABLE (2) SCE_ERLANG_NUMBER (3) SCE_ERLANG_KEYWORD (4) SCE_ERLANG_STRING (5) SCE_ERLANG_OPERATOR (6) SCE_ERLANG_ATOM (7) SCE_ERLANG_FUNCTION_NAME (8) SCE_ERLANG_CHARACTER (9) SCE_ERLANG_MACRO (10) SCE_ERLANG_RECORD (11) SCE_ERLANG_PREPROC (12) SCE_ERLANG_NODE_NAME (13) SCE_ERLANG_COMMENT_FUNCTION (14) SCE_ERLANG_COMMENT_MODULE (15) SCE_ERLANG_COMMENT_DOC (16) SCE_ERLANG_COMMENT_DOC_MACRO (17) SCE_ERLANG_ATOM_QUOTED (18) SCE_ERLANG_MACRO_QUOTED (19) SCE_ERLANG_RECORD_QUOTED (20) SCE_ERLANG_NODE_NAME_QUOTED (21) SCE_ERLANG_BIFS (22) SCE_ERLANG_MODULES (23) SCE_ERLANG_MODULES_ATT (24) SCE_ERLANG_UNKNOWN (31) =head2 Lexical states for SCLEX_MSSQL SCE_MSSQL_DEFAULT (0) SCE_MSSQL_COMMENT (1) SCE_MSSQL_LINE_COMMENT (2) SCE_MSSQL_NUMBER (3) SCE_MSSQL_STRING (4) SCE_MSSQL_OPERATOR (5) SCE_MSSQL_IDENTIFIER (6) SCE_MSSQL_VARIABLE (7) SCE_MSSQL_COLUMN_NAME (8) SCE_MSSQL_STATEMENT (9) SCE_MSSQL_DATATYPE (10) SCE_MSSQL_SYSTABLE (11) SCE_MSSQL_GLOBAL_VARIABLE (12) SCE_MSSQL_FUNCTION (13) SCE_MSSQL_STORED_PROCEDURE (14) SCE_MSSQL_DEFAULT_PREF_DATATYPE (15) SCE_MSSQL_COLUMN_NAME_2 (16) =head2 Lexical states for SCLEX_VERILOG SCE_V_DEFAULT (0) SCE_V_COMMENT (1) SCE_V_COMMENTLINE (2) SCE_V_COMMENTLINEBANG (3) SCE_V_NUMBER (4) SCE_V_WORD (5) SCE_V_STRING (6) SCE_V_WORD2 (7) SCE_V_WORD3 (8) SCE_V_PREPROCESSOR (9) SCE_V_OPERATOR (10) SCE_V_IDENTIFIER (11) SCE_V_STRINGEOL (12) SCE_V_USER (19) =head2 Lexical states for SCLEX_KIX SCE_KIX_DEFAULT (0) SCE_KIX_COMMENT (1) SCE_KIX_STRING1 (2) SCE_KIX_STRING2 (3) SCE_KIX_NUMBER (4) SCE_KIX_VAR (5) SCE_KIX_MACRO (6) SCE_KIX_KEYWORD (7) SCE_KIX_FUNCTIONS (8) SCE_KIX_OPERATOR (9) SCE_KIX_IDENTIFIER (31) =head2 Lexical states for SCLEX_GUI4CLI SCE_GC_DEFAULT (0) SCE_GC_COMMENTLINE (1) SCE_GC_COMMENTBLOCK (2) SCE_GC_GLOBAL (3) SCE_GC_EVENT (4) SCE_GC_ATTRIBUTE (5) SCE_GC_CONTROL (6) SCE_GC_COMMAND (7) SCE_GC_STRING (8) SCE_GC_OPERATOR (9) =head2 Lexical states for SCLEX_SPECMAN SCE_SN_DEFAULT (0) SCE_SN_CODE (1) SCE_SN_COMMENTLINE (2) SCE_SN_COMMENTLINEBANG (3) SCE_SN_NUMBER (4) SCE_SN_WORD (5) SCE_SN_STRING (6) SCE_SN_WORD2 (7) SCE_SN_WORD3 (8) SCE_SN_PREPROCESSOR (9) SCE_SN_OPERATOR (10) SCE_SN_IDENTIFIER (11) SCE_SN_STRINGEOL (12) SCE_SN_REGEXTAG (13) SCE_SN_SIGNAL (14) SCE_SN_USER (19) =head2 Lexical states for SCLEX_AU3 SCE_AU3_DEFAULT (0) SCE_AU3_COMMENT (1) SCE_AU3_COMMENTBLOCK (2) SCE_AU3_NUMBER (3) SCE_AU3_FUNCTION (4) SCE_AU3_KEYWORD (5) SCE_AU3_MACRO (6) SCE_AU3_STRING (7) SCE_AU3_OPERATOR (8) SCE_AU3_VARIABLE (9) SCE_AU3_SENT (10) SCE_AU3_PREPROCESSOR (11) SCE_AU3_SPECIAL (12) SCE_AU3_EXPAND (13) SCE_AU3_COMOBJ (14) SCE_AU3_UDF (15) =head2 Lexical states for SCLEX_APDL SCE_APDL_DEFAULT (0) SCE_APDL_COMMENT (1) SCE_APDL_COMMENTBLOCK (2) SCE_APDL_NUMBER (3) SCE_APDL_STRING (4) SCE_APDL_OPERATOR (5) SCE_APDL_WORD (6) SCE_APDL_PROCESSOR (7) SCE_APDL_COMMAND (8) SCE_APDL_SLASHCOMMAND (9) SCE_APDL_STARCOMMAND (10) SCE_APDL_ARGUMENT (11) SCE_APDL_FUNCTION (12) =head2 Lexical states for SCLEX_BASH SCE_SH_DEFAULT (0) SCE_SH_ERROR (1) SCE_SH_COMMENTLINE (2) SCE_SH_NUMBER (3) SCE_SH_WORD (4) SCE_SH_STRING (5) SCE_SH_CHARACTER (6) SCE_SH_OPERATOR (7) SCE_SH_IDENTIFIER (8) SCE_SH_SCALAR (9) SCE_SH_PARAM (10) SCE_SH_BACKTICKS (11) SCE_SH_HERE_DELIM (12) SCE_SH_HERE_Q (13) =head2 Lexical states for SCLEX_ASN1 SCE_ASN1_DEFAULT (0) SCE_ASN1_COMMENT (1) SCE_ASN1_IDENTIFIER (2) SCE_ASN1_STRING (3) SCE_ASN1_OID (4) SCE_ASN1_SCALAR (5) SCE_ASN1_KEYWORD (6) SCE_ASN1_ATTRIBUTE (7) SCE_ASN1_DESCRIPTOR (8) SCE_ASN1_TYPE (9) SCE_ASN1_OPERATOR (10) =head2 Lexical states for SCLEX_VHDL SCE_VHDL_DEFAULT (0) SCE_VHDL_COMMENT (1) SCE_VHDL_COMMENTLINEBANG (2) SCE_VHDL_NUMBER (3) SCE_VHDL_STRING (4) SCE_VHDL_OPERATOR (5) SCE_VHDL_IDENTIFIER (6) SCE_VHDL_STRINGEOL (7) SCE_VHDL_KEYWORD (8) SCE_VHDL_STDOPERATOR (9) SCE_VHDL_ATTRIBUTE (10) SCE_VHDL_STDFUNCTION (11) SCE_VHDL_STDPACKAGE (12) SCE_VHDL_STDTYPE (13) SCE_VHDL_USERWORD (14) =head2 Lexical states for SCLEX_CAML SCE_CAML_DEFAULT (0) SCE_CAML_IDENTIFIER (1) SCE_CAML_TAGNAME (2) SCE_CAML_KEYWORD (3) SCE_CAML_KEYWORD2 (4) SCE_CAML_KEYWORD3 (5) SCE_CAML_LINENUM (6) SCE_CAML_OPERATOR (7) SCE_CAML_NUMBER (8) SCE_CAML_CHAR (9) SCE_CAML_WHITE (10) SCE_CAML_STRING (11) SCE_CAML_COMMENT (12) SCE_CAML_COMMENT1 (13) SCE_CAML_COMMENT2 (14) SCE_CAML_COMMENT3 (15) =head2 Lexical states for SCLEX_HASKELL SCE_HA_DEFAULT (0) SCE_HA_IDENTIFIER (1) SCE_HA_KEYWORD (2) SCE_HA_NUMBER (3) SCE_HA_STRING (4) SCE_HA_CHARACTER (5) SCE_HA_CLASS (6) SCE_HA_MODULE (7) SCE_HA_CAPITAL (8) SCE_HA_DATA (9) SCE_HA_IMPORT (10) SCE_HA_OPERATOR (11) SCE_HA_INSTANCE (12) SCE_HA_COMMENTLINE (13) SCE_HA_COMMENTBLOCK (14) SCE_HA_COMMENTBLOCK2 (15) SCE_HA_COMMENTBLOCK3 (16) Lexical states of SCLEX_TADS3 SCE_T3_DEFAULT (0) SCE_T3_X_DEFAULT (1) SCE_T3_PREPROCESSOR (2) SCE_T3_BLOCK_COMMENT (3) SCE_T3_LINE_COMMENT (4) SCE_T3_OPERATOR (5) SCE_T3_KEYWORD (6) SCE_T3_NUMBER (7) SCE_T3_IDENTIFIER (8) SCE_T3_S_STRING (9) SCE_T3_D_STRING (10) SCE_T3_X_STRING (11) SCE_T3_LIB_DIRECTIVE (12) SCE_T3_MSG_PARAM (13) SCE_T3_HTML_TAG (14) SCE_T3_HTML_DEFAULT (15) SCE_T3_HTML_STRING (16) SCE_T3_USER1 (17) SCE_T3_USER2 (18) SCE_T3_USER3 (19) SCE_T3_BRACE (20) =head2 Lexical states for SCLEX_REBOL SCE_REBOL_DEFAULT (0) SCE_REBOL_COMMENTLINE (1) SCE_REBOL_COMMENTBLOCK (2) SCE_REBOL_PREFACE (3) SCE_REBOL_OPERATOR (4) SCE_REBOL_CHARACTER (5) SCE_REBOL_QUOTEDSTRING (6) SCE_REBOL_BRACEDSTRING (7) SCE_REBOL_NUMBER (8) SCE_REBOL_PAIR (9) SCE_REBOL_TUPLE (10) SCE_REBOL_BINARY (11) SCE_REBOL_MONEY (12) SCE_REBOL_ISSUE (13) SCE_REBOL_TAG (14) SCE_REBOL_FILE (15) SCE_REBOL_EMAIL (16) SCE_REBOL_URL (17) SCE_REBOL_DATE (18) SCE_REBOL_TIME (19) SCE_REBOL_IDENTIFIER (20) SCE_REBOL_WORD (21) SCE_REBOL_WORD2 (22) SCE_REBOL_WORD3 (23) SCE_REBOL_WORD4 (24) SCE_REBOL_WORD5 (25) SCE_REBOL_WORD6 (26) SCE_REBOL_WORD7 (27) SCE_REBOL_WORD8 (28) =head2 Lexical states for SCLEX_SQL SCE_SQL_DEFAULT (0) SCE_SQL_COMMENT (1) SCE_SQL_COMMENTLINE (2) SCE_SQL_COMMENTDOC (3) SCE_SQL_NUMBER (4) SCE_SQL_WORD (5) SCE_SQL_STRING (6) SCE_SQL_CHARACTER (7) SCE_SQL_SQLPLUS (8) SCE_SQL_SQLPLUS_PROMPT (9) SCE_SQL_OPERATOR (10) SCE_SQL_IDENTIFIER (11) SCE_SQL_SQLPLUS_COMMENT (13) SCE_SQL_COMMENTLINEDOC (15) SCE_SQL_WORD2 (16) SCE_SQL_COMMENTDOCKEYWORD (17) SCE_SQL_COMMENTDOCKEYWORDERROR (18) SCE_SQL_USER1 (19) SCE_SQL_USER2 (20) SCE_SQL_USER3 (21) SCE_SQL_USER4 (22) SCE_SQL_QUOTEDIDENTIFIER (23) =head2 Lexical states for SCLEX_SMALLTALK SCE_ST_DEFAULT (0) SCE_ST_STRING (1) SCE_ST_NUMBER (2) SCE_ST_COMMENT (3) SCE_ST_SYMBOL (4) SCE_ST_BINARY (5) SCE_ST_BOOL (6) SCE_ST_SELF (7) SCE_ST_SUPER (8) SCE_ST_NIL (9) SCE_ST_GLOBAL (10) SCE_ST_RETURN (11) SCE_ST_SPECIAL (12) SCE_ST_KWSEND (13) SCE_ST_ASSIGN (14) SCE_ST_CHARACTER (15) SCE_ST_SPEC_SEL (16) =head2 Lexical states for SCLEX_FLAGSHIP (clipper) SCE_FS_DEFAULT (0) SCE_FS_COMMENT (1) SCE_FS_COMMENTLINE (2) SCE_FS_COMMENTDOC (3) SCE_FS_COMMENTLINEDOC (4) SCE_FS_COMMENTDOCKEYWORD (5) SCE_FS_COMMENTDOCKEYWORDERROR (6) SCE_FS_KEYWORD (7) SCE_FS_KEYWORD2 (8) SCE_FS_KEYWORD3 (9) SCE_FS_KEYWORD4 (10) SCE_FS_NUMBER (11) SCE_FS_STRING (12) SCE_FS_PREPROCESSOR (13) SCE_FS_OPERATOR (14) SCE_FS_IDENTIFIER (15) SCE_FS_DATE (16) SCE_FS_STRINGEOL (17) SCE_FS_CONSTANT (18) SCE_FS_WORDOPERATOR (19) SCE_FS_DISABLEDCODE (20) SCE_FS_DEFAULT_C (21) SCE_FS_COMMENTDOC_C (22) SCE_FS_COMMENTLINEDOC_C (23) SCE_FS_KEYWORD_C (24) SCE_FS_KEYWORD2_C (25) SCE_FS_NUMBER_C (26) SCE_FS_STRING_C (27) SCE_FS_PREPROCESSOR_C (28) SCE_FS_OPERATOR_C (29) SCE_FS_IDENTIFIER_C (30) SCE_FS_STRINGEOL_C (31) =head2 Lexical states for SCLEX_CSOUND SCE_CSOUND_DEFAULT (0) SCE_CSOUND_COMMENT (1) SCE_CSOUND_NUMBER (2) SCE_CSOUND_OPERATOR (3) SCE_CSOUND_INSTR (4) SCE_CSOUND_IDENTIFIER (5) SCE_CSOUND_OPCODE (6) SCE_CSOUND_HEADERSTMT (7) SCE_CSOUND_USERKEYWORD (8) SCE_CSOUND_COMMENTBLOCK (9) SCE_CSOUND_PARAM (10) SCE_CSOUND_ARATE_VAR (11) SCE_CSOUND_KRATE_VAR (12) SCE_CSOUND_IRATE_VAR (13) SCE_CSOUND_GLOBAL_VAR (14) SCE_CSOUND_STRINGEOL (15) =head2 Lexical states for SCLEX_INNOSETUP SCE_INNO_DEFAULT (0) SCE_INNO_COMMENT (1) SCE_INNO_KEYWORD (2) SCE_INNO_PARAMETER (3) SCE_INNO_SECTION (4) SCE_INNO_PREPROC (5) SCE_INNO_INLINE_EXPANSION (6) SCE_INNO_COMMENT_PASCAL (7) SCE_INNO_KEYWORD_PASCAL (8) SCE_INNO_KEYWORD_USER (9) SCE_INNO_STRING_DOUBLE (10) SCE_INNO_STRING_SINGLE (11) SCE_INNO_IDENTIFIER (12) =head2 Lexical states for SCLEX_OPAL SCE_OPAL_SPACE (0) SCE_OPAL_COMMENT_BLOCK (1) SCE_OPAL_COMMENT_LINE (2) SCE_OPAL_INTEGER (3) SCE_OPAL_KEYWORD (4) SCE_OPAL_SORT (5) SCE_OPAL_STRING (6) SCE_OPAL_PAR (7) SCE_OPAL_BOOL_CONST (8) SCE_OPAL_DEFAULT (32) =head2 Lexical states for SCLEX_SPICE SCE_SPICE_DEFAULT (0) SCE_SPICE_IDENTIFIER (1) SCE_SPICE_KEYWORD (2) SCE_SPICE_KEYWORD2 (3) SCE_SPICE_KEYWORD3 (4) SCE_SPICE_NUMBER (5) SCE_SPICE_DELIMITER (6) SCE_SPICE_VALUE (7) SCE_SPICE_COMMENTLINE (8) =head2 Lexical states for SCLEX_CMAKE SCE_CMAKE_DEFAULT (0) SCE_CMAKE_COMMENT (1) SCE_CMAKE_STRINGDQ (2) SCE_CMAKE_STRINGLQ (3) SCE_CMAKE_STRINGRQ (4) SCE_CMAKE_COMMANDS (5) SCE_CMAKE_PARAMETERS (6) SCE_CMAKE_VARIABLE (7) SCE_CMAKE_USERDEFINED (8) SCE_CMAKE_WHILEDEF (9) SCE_CMAKE_FOREACHDEF (10) SCE_CMAKE_IFDEFINEDEF (11) SCE_CMAKE_MACRODEF (12) SCE_CMAKE_STRINGVAR (13) SCE_CMAKE_NUMBER (14) =head2 Lexical states for SCLEX_GAP SCE_GAP_DEFAULT (0) SCE_GAP_IDENTIFIER (1) SCE_GAP_KEYWORD (2) SCE_GAP_KEYWORD2 (3) SCE_GAP_KEYWORD3 (4) SCE_GAP_KEYWORD4 (5) SCE_GAP_STRING (6) SCE_GAP_CHAR (7) SCE_GAP_OPERATOR (8) SCE_GAP_COMMENT (9) SCE_GAP_NUMBER (10) SCE_GAP_STRINGEOL (11) =head2 Lexical state for SCLEX_PLM SCE_PLM_DEFAULT (0) SCE_PLM_COMMENT (1) SCE_PLM_STRING (2) SCE_PLM_NUMBER (3) SCE_PLM_IDENTIFIER (4) SCE_PLM_OPERATOR (5) SCE_PLM_CONTROL (6) SCE_PLM_KEYWORD (7) =head2 Lexical state for SCLEX_PROGRESS SCE_4GL_DEFAULT (0) SCE_4GL_NUMBER (1) SCE_4GL_WORD (2) SCE_4GL_STRING (3) SCE_4GL_CHARACTER (4) SCE_4GL_PREPROCESSOR (5) SCE_4GL_OPERATOR (6) SCE_4GL_IDENTIFIER (7) SCE_4GL_BLOCK (8) SCE_4GL_END (9) SCE_4GL_COMMENT1 (10) SCE_4GL_COMMENT2 (11) SCE_4GL_COMMENT3 (12) SCE_4GL_COMMENT4 (13) SCE_4GL_COMMENT5 (14) SCE_4GL_COMMENT6 (15) SCE_4GL_DEFAULT_ (16) SCE_4GL_NUMBER_ (17) SCE_4GL_WORD_ (18) SCE_4GL_STRING_ (19) SCE_4GL_CHARACTER_ (20) SCE_4GL_PREPROCESSOR_ (21) SCE_4GL_OPERATOR_ (22) SCE_4GL_IDENTIFIER_ (23) SCE_4GL_BLOCK_ (24) SCE_4GL_END_ (25) SCE_4GL_COMMENT1_ (26) SCE_4GL_COMMENT2_ (27) SCE_4GL_COMMENT3_ (28) SCE_4GL_COMMENT4_ (29) SCE_4GL_COMMENT5_ (30) SCE_4GL_COMMENT6_ (31) =head2 Lexical states for SCLEX_ABAQUS SCE_ABAQUS_DEFAULT (0) SCE_ABAQUS_COMMENT (1) SCE_ABAQUS_COMMENTBLOCK (2) SCE_ABAQUS_NUMBER (3) SCE_ABAQUS_STRING (4) SCE_ABAQUS_OPERATOR (5) SCE_ABAQUS_WORD (6) SCE_ABAQUS_PROCESSOR (7) SCE_ABAQUS_COMMAND (8) SCE_ABAQUS_SLASHCOMMAND (9) SCE_ABAQUS_STARCOMMAND (10) SCE_ABAQUS_ARGUMENT (11) SCE_ABAQUS_FUNCTION (12) =head2 Lexical states for SCLEX_ASYMPTOTE SCE_ASY_DEFAULT (0) SCE_ASY_COMMENT (1) SCE_ASY_COMMENTLINE (2) SCE_ASY_NUMBER (3) SCE_ASY_WORD (4) SCE_ASY_STRING (5) SCE_ASY_CHARACTER (6) SCE_ASY_OPERATOR (7) SCE_ASY_IDENTIFIER (8) SCE_ASY_STRINGEOL (9) SCE_ASY_COMMENTLINEDOC (10) SCE_ASY_WORD2 (11) =head2 Lexical states for SCLEX_R SCE_R_DEFAULT (0) SCE_R_COMMENT (1) SCE_R_KWORD (2) SCE_R_BASEKWORD (3) SCE_R_OTHERKWORD (4) SCE_R_NUMBER (5) SCE_R_STRING (6) SCE_R_STRING2 (7) SCE_R_OPERATOR (8) SCE_R_IDENTIFIER (9) SCE_R_INFIX (10) SCE_R_INFIXEOL (11) =head2 Lexical state for SCLEX_MAGIKSF SCE_MAGIK_DEFAULT (0) SCE_MAGIK_COMMENT (1) SCE_MAGIK_HYPER_COMMENT (16) SCE_MAGIK_STRING (2) SCE_MAGIK_CHARACTER (3) SCE_MAGIK_NUMBER (4) SCE_MAGIK_IDENTIFIER (5) SCE_MAGIK_OPERATOR (6) SCE_MAGIK_FLOW (7) SCE_MAGIK_CONTAINER (8) SCE_MAGIK_BRACKET_BLOCK (9) SCE_MAGIK_BRACE_BLOCK (10) SCE_MAGIK_SQBRACKET_BLOCK (11) SCE_MAGIK_UNKNOWN_KEYWORD (12) SCE_MAGIK_KEYWORD (13) SCE_MAGIK_PRAGMA (14) SCE_MAGIK_SYMBOL (15) =head2 Lexical state for SCLEX_POWERSHELL SCE_POWERSHELL_DEFAULT (0) SCE_POWERSHELL_COMMENT (1) SCE_POWERSHELL_STRING (2) SCE_POWERSHELL_CHARACTER (3) SCE_POWERSHELL_NUMBER (4) SCE_POWERSHELL_VARIABLE (5) SCE_POWERSHELL_OPERATOR (6) SCE_POWERSHELL_IDENTIFIER (7) SCE_POWERSHELL_KEYWORD (8) SCE_POWERSHELL_CMDLET (9) SCE_POWERSHELL_ALIAS (10) SCE_POWERSHELL_FUNCTION (11) SCE_POWERSHELL_USER1 (12) SCE_POWERSHELL_COMMENTSTREAM (13) =head2 Lexical state for SCLEX_MYSQL SCE_MYSQL_DEFAULT (0) SCE_MYSQL_COMMENT (1) SCE_MYSQL_COMMENTLINE (2) SCE_MYSQL_VARIABLE (3) SCE_MYSQL_SYSTEMVARIABLE (4) SCE_MYSQL_KNOWNSYSTEMVARIABLE (5) SCE_MYSQL_NUMBER (6) SCE_MYSQL_MAJORKEYWORD (7) SCE_MYSQL_KEYWORD (8) SCE_MYSQL_DATABASEOBJECT (9) SCE_MYSQL_PROCEDUREKEYWORD (10) SCE_MYSQL_STRING (11) SCE_MYSQL_SQSTRING (12) SCE_MYSQL_DQSTRING (13) SCE_MYSQL_OPERATOR (14) SCE_MYSQL_FUNCTION (15) SCE_MYSQL_IDENTIFIER (16) SCE_MYSQL_QUOTEDIDENTIFIER (17) SCE_MYSQL_USER1 (18) SCE_MYSQL_USER2 (19) SCE_MYSQL_USER3 (20) SCE_MYSQL_HIDDENCOMMAND (21) =head2 Lexical state for SCLEX_PO SCE_PO_DEFAULT (0) SCE_PO_COMMENT (1) SCE_PO_MSGID (2) SCE_PO_MSGID_TEXT (3) SCE_PO_MSGSTR (4) SCE_PO_MSGSTR_TEXT (5) SCE_PO_MSGCTXT (6) SCE_PO_MSGCTXT_TEXT (7) SCE_PO_FUZZY (8) =head2 Lexical states for SCLEX_PASCAL SCE_PAS_DEFAULT (0) SCE_PAS_IDENTIFIER (1) SCE_PAS_COMMENT (2) SCE_PAS_COMMENT2 (3) SCE_PAS_COMMENTLINE (4) SCE_PAS_PREPROCESSOR (5) SCE_PAS_PREPROCESSOR2 (6) SCE_PAS_NUMBER (7) SCE_PAS_HEXNUMBER (8) SCE_PAS_WORD (9) SCE_PAS_STRING (10) SCE_PAS_STRINGEOL (11) SCE_PAS_CHARACTER (12) SCE_PAS_OPERATOR (13) SCE_PAS_ASM (14) =head2 Lexical state for SCLEX_SORCUS SCE_SORCUS_DEFAULT (0) SCE_SORCUS_COMMAND (1) SCE_SORCUS_PARAMETER (2) SCE_SORCUS_COMMENTLINE (3) SCE_SORCUS_STRING (4) SCE_SORCUS_STRINGEOL (5) SCE_SORCUS_IDENTIFIER (6) SCE_SORCUS_OPERATOR (7) SCE_SORCUS_NUMBER (8) SCE_SORCUS_CONSTANT (9) =head2 Lexical state for SCLEX_POWERPRO SCE_POWERPRO_DEFAULT (0) SCE_POWERPRO_COMMENTBLOCK (1) SCE_POWERPRO_COMMENTLINE (2) SCE_POWERPRO_NUMBER (3) SCE_POWERPRO_WORD (4) SCE_POWERPRO_WORD2 (5) SCE_POWERPRO_WORD3 (6) SCE_POWERPRO_WORD4 (7) SCE_POWERPRO_DOUBLEQUOTEDSTRING (8) SCE_POWERPRO_SINGLEQUOTEDSTRING (9) SCE_POWERPRO_LINECONTINUE (10) SCE_POWERPRO_OPERATOR (11) SCE_POWERPRO_IDENTIFIER (12) SCE_POWERPRO_STRINGEOL (13) SCE_POWERPRO_VERBATIM (14) SCE_POWERPRO_ALTQUOTE (15) SCE_POWERPRO_FUNCTION (16) =head2 Lexical states for SCLEX_SML SCE_SML_DEFAULT (0) SCE_SML_IDENTIFIER (1) SCE_SML_TAGNAME (2) SCE_SML_KEYWORD (3) SCE_SML_KEYWORD2 (4) SCE_SML_KEYWORD3 (5) SCE_SML_LINENUM (6) SCE_SML_OPERATOR (7) SCE_SML_NUMBER (8) SCE_SML_CHAR (9) SCE_SML_STRING (11) SCE_SML_COMMENT (12) SCE_SML_COMMENT1 (13) SCE_SML_COMMENT2 (14) SCE_SML_COMMENT3 (15) =head2 Lexical state for SCLEX_MARKDOWN SCE_MARKDOWN_DEFAULT (0) SCE_MARKDOWN_LINE_BEGIN (1) SCE_MARKDOWN_STRONG1 (2) SCE_MARKDOWN_STRONG2 (3) SCE_MARKDOWN_EM1 (4) SCE_MARKDOWN_EM2 (5) SCE_MARKDOWN_HEADER1 (6) SCE_MARKDOWN_HEADER2 (7) SCE_MARKDOWN_HEADER3 (8) SCE_MARKDOWN_HEADER4 (9) SCE_MARKDOWN_HEADER5 (10) SCE_MARKDOWN_HEADER6 (11) SCE_MARKDOWN_PRECHAR (12) SCE_MARKDOWN_ULIST_ITEM (13) SCE_MARKDOWN_OLIST_ITEM (14) SCE_MARKDOWN_BLOCKQUOTE (15) SCE_MARKDOWN_STRIKEOUT (16) SCE_MARKDOWN_HRULE (17) SCE_MARKDOWN_LINK (18) SCE_MARKDOWN_CODE (19) SCE_MARKDOWN_CODE2 (20) SCE_MARKDOWN_CODEBK (21) =head2 Lexical state for SCLEX_TXT2TAGS SCE_TXT2TAGS_DEFAULT (0) SCE_TXT2TAGS_LINE_BEGIN (1) SCE_TXT2TAGS_STRONG1 (2) SCE_TXT2TAGS_STRONG2 (3) SCE_TXT2TAGS_EM1 (4) SCE_TXT2TAGS_EM2 (5) SCE_TXT2TAGS_HEADER1 (6) SCE_TXT2TAGS_HEADER2 (7) SCE_TXT2TAGS_HEADER3 (8) SCE_TXT2TAGS_HEADER4 (9) SCE_TXT2TAGS_HEADER5 (10) SCE_TXT2TAGS_HEADER6 (11) SCE_TXT2TAGS_PRECHAR (12) SCE_TXT2TAGS_ULIST_ITEM (13) SCE_TXT2TAGS_OLIST_ITEM (14) SCE_TXT2TAGS_BLOCKQUOTE (15) SCE_TXT2TAGS_STRIKEOUT (16) SCE_TXT2TAGS_HRULE (17) SCE_TXT2TAGS_LINK (18) SCE_TXT2TAGS_CODE (19) SCE_TXT2TAGS_CODE2 (20) SCE_TXT2TAGS_CODEBK (21) SCE_TXT2TAGS_COMMENT (22) SCE_TXT2TAGS_OPTION (23) SCE_TXT2TAGS_PREPROC (24) SCE_TXT2TAGS_POSTPROC (25) =head2 Lexical states for SCLEX_A68K SCE_A68K_DEFAULT (0) SCE_A68K_COMMENT (1) SCE_A68K_NUMBER_DEC (2) SCE_A68K_NUMBER_BIN (3) SCE_A68K_NUMBER_HEX (4) SCE_A68K_STRING1 (5) SCE_A68K_OPERATOR (6) SCE_A68K_CPUINSTRUCTION (7) SCE_A68K_EXTINSTRUCTION (8) SCE_A68K_REGISTER (9) SCE_A68K_DIRECTIVE (10) SCE_A68K_MACRO_ARG (11) SCE_A68K_LABEL (12) SCE_A68K_STRING2 (13) SCE_A68K_IDENTIFIER (14) SCE_A68K_MACRO_DECLARATION (15) SCE_A68K_COMMENT_WORD (16) SCE_A68K_COMMENT_SPECIAL (17) SCE_A68K_COMMENT_DOXYGEN (18) =head2 Lexical states for SCLEX_MODULA SCE_MODULA_DEFAULT (0) SCE_MODULA_COMMENT (1) SCE_MODULA_DOXYCOMM (2) SCE_MODULA_DOXYKEY (3) SCE_MODULA_KEYWORD (4) SCE_MODULA_RESERVED (5) SCE_MODULA_NUMBER (6) SCE_MODULA_BASENUM (7) SCE_MODULA_FLOAT (8) SCE_MODULA_STRING (9) SCE_MODULA_STRSPEC (10) SCE_MODULA_CHAR (11) SCE_MODULA_CHARSPEC (12) SCE_MODULA_PROC (13) SCE_MODULA_PRAGMA (14) SCE_MODULA_PRGKEY (15) SCE_MODULA_OPERATOR (16) SCE_MODULA_BADSTR (17) =head2 Lexical states for SCLEX_COFFEESCRIPT SCE_COFFEESCRIPT_DEFAULT (0) SCE_COFFEESCRIPT_COMMENT (1) SCE_COFFEESCRIPT_COMMENTLINE (2) SCE_COFFEESCRIPT_COMMENTDOC (3) SCE_COFFEESCRIPT_NUMBER (4) SCE_COFFEESCRIPT_WORD (5) SCE_COFFEESCRIPT_STRING (6) SCE_COFFEESCRIPT_CHARACTER (7) SCE_COFFEESCRIPT_UUID (8) SCE_COFFEESCRIPT_PREPROCESSOR (9) SCE_COFFEESCRIPT_OPERATOR (10) SCE_COFFEESCRIPT_IDENTIFIER (11) SCE_COFFEESCRIPT_STRINGEOL (12) SCE_COFFEESCRIPT_VERBATIM (13) SCE_COFFEESCRIPT_REGEX (14) SCE_COFFEESCRIPT_COMMENTLINEDOC (15) SCE_COFFEESCRIPT_WORD2 (16) SCE_COFFEESCRIPT_COMMENTDOCKEYWORD (17) SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR (18) SCE_COFFEESCRIPT_GLOBALCLASS (19) SCE_COFFEESCRIPT_STRINGRAW (20) SCE_COFFEESCRIPT_TRIPLEVERBATIM (21) SCE_COFFEESCRIPT_HASHQUOTEDSTRING (22) SCE_COFFEESCRIPT_COMMENTBLOCK (22) SCE_COFFEESCRIPT_VERBOSE_REGEX (23) SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT (24) =head2 Lexical states for SCLEX_AVS SCE_AVS_DEFAULT (0) SCE_AVS_COMMENTBLOCK (1) SCE_AVS_COMMENTBLOCKN (2) SCE_AVS_COMMENTLINE (3) SCE_AVS_NUMBER (4) SCE_AVS_OPERATOR (5) SCE_AVS_IDENTIFIER (6) SCE_AVS_STRING (7) SCE_AVS_TRIPLESTRING (8) SCE_AVS_KEYWORD (9) SCE_AVS_FILTER (10) SCE_AVS_PLUGIN (11) SCE_AVS_FUNCTION (12) SCE_AVS_CLIPPROP (13) SCE_AVS_USERDFN (14) =head2 Lexical states for SCLEX_ECL SCE_ECL_DEFAULT (0) SCE_ECL_COMMENT (1) SCE_ECL_COMMENTLINE (2) SCE_ECL_NUMBER (3) SCE_ECL_STRING (4) SCE_ECL_WORD0 (5) SCE_ECL_OPERATOR (6) SCE_ECL_CHARACTER (7) SCE_ECL_UUID (8) SCE_ECL_PREPROCESSOR (9) SCE_ECL_UNKNOWN (10) SCE_ECL_IDENTIFIER (11) SCE_ECL_STRINGEOL (12) SCE_ECL_VERBATIM (13) SCE_ECL_REGEX (14) SCE_ECL_COMMENTLINEDOC (15) SCE_ECL_WORD1 (16) SCE_ECL_COMMENTDOCKEYWORD (17) SCE_ECL_COMMENTDOCKEYWORDERROR (18) SCE_ECL_WORD2 (19) SCE_ECL_WORD3 (20) SCE_ECL_WORD4 (21) SCE_ECL_WORD5 (22) SCE_ECL_COMMENTDOC (23) SCE_ECL_ADDED (24) SCE_ECL_DELETED (25) SCE_ECL_CHANGED (26) SCE_ECL_MOVED (27) Deprecated in 2.21The SC_CP_DBCS value can be used to indicate a DBCS mode for GTK+. SC_CP_DBCS (1) =head1 AUTHOR Ahmad M. Zawawi =head1 COPYRIGHT Copyright 2011 Ahmad M. Zawawi. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Wx-Scintilla-0.39/lib/Wx/Scintilla/TextCtrl.pm000444001750001750 21312021352776 21567 0ustar00azawawiazawawi000000000000package Wx::Scintilla::TextCtrl; use 5.008; use strict; use warnings; our $VERSION = '0.39'; our @ISA = 'Wx::ScintillaTextCtrl'; 1; Wx-Scintilla-0.39/lib/Wx/Scintilla/TextEvent.pm000444001750001750 21512021352777 21747 0ustar00azawawiazawawi000000000000package Wx::Scintilla::TextEvent; use 5.008; use strict; use warnings; our $VERSION = '0.39'; our @ISA = 'Wx::ScintillaTextEvent'; 1; Wx-Scintilla-0.39/lib/Wx/Scintilla/Manual.pod000444001750001750 100512021352777 21422 0ustar00azawawiazawawi000000000000package Wx::Scintilla::Manual; # ABSTRACT: What is Wx::Scintilla, and how do I use it? =pod =head1 NAME Wx::Scintilla::Manual - What is Wx::Scintilla, and how do I use it? =head1 WHAT IS WX::SCINTILLA? =head2 Constants Scintilla constants can be here L =head1 AUTHOR Ahmad M. Zawawi =head1 COPYRIGHT Copyright 2011 Ahmad M. Zawawi. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut __END__Wx-Scintilla-0.39/wx-scintilla000755001750001750 012021352777 16700 5ustar00azawawiazawawi000000000000Wx-Scintilla-0.39/wx-scintilla/src000755001750001750 012021352777 17467 5ustar00azawawiazawawi000000000000Wx-Scintilla-0.39/wx-scintilla/src/scintilla_cwc_d.h000444001750001750 11512021352777 23073 0ustar00azawawiazawawi000000000000#define __WX__ #define SCI_LEXER #define LINK_LEXERS #include "wx/wx_cwc_d.h"Wx-Scintilla-0.39/wx-scintilla/src/scintilla_i18n.cpp000444001750001750 145012021352777 23151 0ustar00azawawiazawawi000000000000/////////////////////////////////////////////////////////////////////////////// // Name: src/stc/stc_i18n.cpp // Purpose: Dummy file containing translatable strings from Scintilla // Author: Vadim Zeitlin // Created: 2010-06-09 // RCS-ID: $Id: $ // Copyright: (c) 2010 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // This is just a collection of translatable strings defined in Scintilla // sources. It is used by locale/Makefile only and not supposed to be compiled. #error "This file is not supposed to be compiled." // These strings were manually extracted from ScintillaBase::ContextMenu(). _("Undo") _("Redo") _("Cut") _("Copy") _("Paste") _("Delete") _("Select All") Wx-Scintilla-0.39/wx-scintilla/src/scintilla_cw_d.h000444001750001750 11412021352777 22727 0ustar00azawawiazawawi000000000000#define __WX__ #define SCI_LEXER #define LINK_LEXERS #include "wx/wx_cw_d.h"Wx-Scintilla-0.39/wx-scintilla/src/scintilla_cw.h000444001750001750 11212021352777 22422 0ustar00azawawiazawawi000000000000#define __WX__ #define SCI_LEXER #define LINK_LEXERS #include "wx/wx_cw.h"Wx-Scintilla-0.39/wx-scintilla/src/ScintillaWX.h000444001750001750 1517612021352777 22230 0ustar00azawawiazawawi000000000000//////////////////////////////////////////////////////////////////////////// // Name: ScintillaWX.h // Purpose: A wxWidgets implementation of Scintilla. A class derived // from ScintillaBase that uses the "wx platform" defined in // PlatWX.cpp. This class is one end of a bridge between // the wx world and the Scintilla world. It needs a peer // object of type wxScintillaTextCtrl to function. // // Author: Robin Dunn // // Created: 13-Jan-2000 // RCS-ID: $Id$ // Copyright: (c) 2000 by Total Control Software // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef __ScintillaWX_h__ #define __ScintillaWX_h__ #include "wx/defs.h" //---------------------------------------------------------------------- #include #include #include #include #include #include #include #include "Platform.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" #include "Scintilla.h" #include "ScintillaWidget.h" #ifdef SCI_LEXER #include "ILexer.h" #include "SciLexer.h" #include "LexAccessor.h" #include "Accessor.h" #include "WordList.h" #endif #include "ContractionState.h" #include "SVector.h" #include "CellBuffer.h" #include "CallTip.h" #include "KeyMap.h" #include "Indicator.h" #include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "AutoComplete.h" #include "ViewStyle.h" #include "CharClassify.h" #include "Decoration.h" #include "Document.h" #include "Selection.h" #include "PositionCache.h" #include "Editor.h" #include "ScintillaBase.h" #ifdef __WXMSW__ #include "wx/msw/wrapwin.h" // HBITMAP #endif #if wxUSE_DRAG_AND_DROP #include "wx/timer.h" #endif //---------------------------------------------------------------------- /* Versions before 2.8.11 dont' have wxIntPtr defined */ #ifndef wxIntPtr #if SIZEOF_LONG >= SIZEOF_VOID_P && SIZEOF_LONG >= SIZEOF_SIZE_T /* normal case */ typedef unsigned long wxUIntPtr; typedef long wxIntPtr; #elif SIZEOF_SIZE_T >= SIZEOF_VOID_P /* Win64 case */ typedef size_t wxUIntPtr; #define wxIntPtr ssize_t #else /* This should never happen for the current architectures but if you're using one where it does, please contact wx-dev@lists.wxwidgets.org. */ #error "Pointers can't be stored inside integer types." #endif #endif //---------------------------------------------------------------------- #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_FWD_CORE wxDC; class WXDLLIMPEXP_FWD_STC wxScintillaTextCtrl; // forward class ScintillaWX; //---------------------------------------------------------------------- // Helper classes #if wxUSE_DRAG_AND_DROP class wxSTCDropTarget : public wxTextDropTarget { public: void SetScintilla(ScintillaWX* swx) { m_swx = swx; } bool OnDropText(wxCoord x, wxCoord y, const wxString& data); wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def); wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def); void OnLeave(); private: ScintillaWX* m_swx; }; #endif //---------------------------------------------------------------------- class ScintillaWX : public ScintillaBase { public: ScintillaWX(wxScintillaTextCtrl* win); ~ScintillaWX(); // base class virtuals virtual void Initialise(); virtual void Finalise(); virtual void StartDrag(); virtual bool SetIdle(bool on); virtual void SetTicking(bool on); virtual void SetMouseCapture(bool on); virtual bool HaveMouseCapture(); virtual void ScrollText(int linesToMove); virtual void SetVerticalScrollPos(); virtual void SetHorizontalScrollPos(); virtual bool ModifyScrollBars(int nMax, int nPage); virtual void Copy(); virtual void Paste(); virtual void CopyToClipboard(const SelectionText &selectedText); virtual void CreateCallTipWindow(PRectangle rc); virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true); virtual void ClaimSelection(); virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); virtual void NotifyChange(); virtual void NotifyParent(SCNotification scn); virtual void CancelModes(); virtual void UpdateSystemCaret(); // Event delegates void DoPaint(wxDC* dc, wxRect rect); void DoHScroll(int type, int pos); void DoVScroll(int type, int pos); void DoSize(int width, int height); void DoLoseFocus(); void DoGainFocus(); void DoSysColourChange(); void DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt); void DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl); void DoLeftButtonMove(Point pt); void DoMiddleButtonUp(Point pt); void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll); void DoAddChar(int key); int DoKeyDown(const wxKeyEvent& event, bool* consumed); void DoTick() { Tick(); } void DoOnIdle(wxIdleEvent& evt); #if wxUSE_DRAG_AND_DROP bool DoDropText(long x, long y, const wxString& data); wxDragResult DoDragEnter(wxCoord x, wxCoord y, wxDragResult def); wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def); void DoDragLeave(); #endif void DoCommand(int ID); void DoContextMenu(Point pt); void DoOnListBox(); // helpers void FullPaint(); bool CanPaste(); bool GetHideSelection() { return hideSelection; } void DoScrollToLine(int line); void DoScrollToColumn(int column); void ClipChildren(wxDC& dc, PRectangle rect); void SetUseAntiAliasing(bool useAA); bool GetUseAntiAliasing(); private: bool capturedMouse; bool focusEvent; wxScintillaTextCtrl* stc; #if wxUSE_DRAG_AND_DROP wxSTCDropTarget* dropTarget; wxDragResult dragResult; #endif int wheelRotation; // For use in creating a system caret bool HasCaretSizeChanged(); bool CreateSystemCaret(); bool DestroySystemCaret(); #ifdef __WXMSW__ HBITMAP sysCaretBitmap; int sysCaretWidth; int sysCaretHeight; #endif friend class wxSTCCallTip; }; //---------------------------------------------------------------------- #endif Wx-Scintilla-0.39/wx-scintilla/src/PlatWX.h000444001750001750 133412021352777 21155 0ustar00azawawiazawawi000000000000 /* Versions before 2.8.11 dont' have wxIntPtr defined */ #ifndef wxIntPtr #if SIZEOF_LONG >= SIZEOF_VOID_P && SIZEOF_LONG >= SIZEOF_SIZE_T /* normal case */ typedef unsigned long wxUIntPtr; typedef long wxIntPtr; #elif SIZEOF_SIZE_T >= SIZEOF_VOID_P /* Win64 case */ typedef size_t wxUIntPtr; #define wxIntPtr ssize_t #else /* This should never happen for the current architectures but if you're using one where it does, please contact wx-dev@lists.wxwidgets.org. */ #error "Pointers can't be stored inside integer types." #endif #endif wxRect wxRectFromPRectangle(PRectangle prc); PRectangle PRectangleFromwxRect(wxRect rc); wxColour wxColourFromCA(const ColourDesired& ca); Wx-Scintilla-0.39/wx-scintilla/src/ScintillaWX.cpp000444001750001750 7707012021352777 22564 0ustar00azawawiazawawi000000000000//////////////////////////////////////////////////////////////////////////// // Name: ScintillaWX.cxx // Purpose: A wxWidgets implementation of Scintilla. A class derived // from ScintillaBase that uses the "wx platform" defined in // PlatformWX.cxx This class is one end of a bridge between // the wx world and the Scintilla world. It needs a peer // object of type wxScintillaTextCtrl to function. // // Author: Robin Dunn // // Created: 13-Jan-2000 // RCS-ID: $Id$ // Copyright: (c) 2000 by Total Control Software // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include "wx/scrolbar.h" #include "wx/menu.h" #include "wx/timer.h" #endif // WX_PRECOMP #include "wx/textbuf.h" #include "wx/dataobj.h" #include "wx/clipbrd.h" #include "wx/dnd.h" #include "ScintillaWX.h" #include "LexerModule.h" #include "ExternalLexer.h" #include "WxScintilla.h" #include "private.h" #include "PlatWX.h" #ifdef __WXMSW__ // GetHwndOf() #include "wx/msw/private.h" #endif //---------------------------------------------------------------------- // Helper classes class wxSTCTimer : public wxTimer { public: wxSTCTimer(ScintillaWX* swx) { m_swx = swx; } void Notify() { m_swx->DoTick(); } private: ScintillaWX* m_swx; }; #if wxUSE_DRAG_AND_DROP bool wxSTCDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString& data) { return m_swx->DoDropText(x, y, data); } wxDragResult wxSTCDropTarget::OnEnter(wxCoord x, wxCoord y, wxDragResult def) { return m_swx->DoDragEnter(x, y, def); } wxDragResult wxSTCDropTarget::OnDragOver(wxCoord x, wxCoord y, wxDragResult def) { return m_swx->DoDragOver(x, y, def); } void wxSTCDropTarget::OnLeave() { m_swx->DoDragLeave(); } #endif // wxUSE_DRAG_AND_DROP #if wxUSE_POPUPWIN #include "wx/popupwin.h" #define wxSTCCallTipBase wxPopupWindow #else #include "wx/frame.h" #define wxSTCCallTipBase wxFrame #endif #include "wx/dcbuffer.h" class wxSTCCallTip : public wxSTCCallTipBase { public: wxSTCCallTip(wxWindow* parent, CallTip* ct, ScintillaWX* swx) : #if wxUSE_POPUPWIN wxSTCCallTipBase(parent, wxBORDER_NONE), #else wxSTCCallTipBase(parent, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxFRAME_NO_TASKBAR | wxFRAME_FLOAT_ON_PARENT | wxBORDER_NONE #ifdef __WXMAC__ | wxPOPUP_WINDOW #endif ), #endif m_ct(ct), m_swx(swx), m_cx(wxDefaultCoord), m_cy(wxDefaultCoord) { SetBackgroundStyle(wxBG_STYLE_CUSTOM); } ~wxSTCCallTip() { #if wxUSE_POPUPWIN && defined(__WXGTK__) wxRect rect = GetRect(); rect.x = m_cx; rect.y = m_cy; GetParent()->Refresh(false, &rect); #endif } bool AcceptsFocus() const { return false; } void OnPaint(wxPaintEvent& WXUNUSED(evt)) { wxAutoBufferedPaintDC dc(this); Surface* surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); surfaceWindow->Init(&dc, m_ct->wDraw.GetID()); m_ct->PaintCT(surfaceWindow); surfaceWindow->Release(); delete surfaceWindow; } void OnFocus(wxFocusEvent& event) { GetParent()->SetFocus(); event.Skip(); } void OnLeftDown(wxMouseEvent& event) { wxPoint pt = event.GetPosition(); Point p(pt.x, pt.y); m_ct->MouseClick(p); m_swx->CallTipClick(); } virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) { // convert coords to screen coords since we're a top-level window if (x != wxDefaultCoord) { m_cx = x; GetParent()->ClientToScreen(&x, NULL); } if (y != wxDefaultCoord) { m_cy = y; GetParent()->ClientToScreen(NULL, &y); } wxSTCCallTipBase::DoSetSize(x, y, width, height, sizeFlags); } #if wxUSE_POPUPWIN #else virtual bool Show( bool show = true ) { // Although we're a frame, we always want the parent to be active, so // raise it whenever we get shown. bool rv = wxSTCCallTipBase::Show(show); if (rv && show) { wxTopLevelWindow *frame = wxDynamicCast( wxGetTopLevelParent(GetParent()), wxTopLevelWindow); if (frame) frame->Raise(); } return rv; } #endif wxPoint GetMyPosition() { return wxPoint(m_cx, m_cy); } private: CallTip* m_ct; ScintillaWX* m_swx; int m_cx, m_cy; DECLARE_EVENT_TABLE() }; BEGIN_EVENT_TABLE(wxSTCCallTip, wxSTCCallTipBase) EVT_PAINT(wxSTCCallTip::OnPaint) EVT_SET_FOCUS(wxSTCCallTip::OnFocus) EVT_LEFT_DOWN(wxSTCCallTip::OnLeftDown) END_EVENT_TABLE() //---------------------------------------------------------------------- #if wxUSE_DATAOBJ static wxTextFileType wxConvertEOLMode(int scintillaMode) { wxTextFileType type; switch (scintillaMode) { case wxSTC_EOL_CRLF: type = wxTextFileType_Dos; break; case wxSTC_EOL_CR: type = wxTextFileType_Mac; break; case wxSTC_EOL_LF: type = wxTextFileType_Unix; break; default: type = wxTextBuffer::typeDefault; break; } return type; } #endif // wxUSE_DATAOBJ //---------------------------------------------------------------------- // Constructor/Destructor ScintillaWX::ScintillaWX(wxScintillaTextCtrl* win) { capturedMouse = false; focusEvent = false; wMain = win; stc = win; wheelRotation = 0; Initialise(); #ifdef __WXMSW__ sysCaretBitmap = 0; sysCaretWidth = 0; sysCaretHeight = 0; #endif } ScintillaWX::~ScintillaWX() { Finalise(); } //---------------------------------------------------------------------- // base class virtuals void ScintillaWX::Initialise() { //ScintillaBase::Initialise(); #if wxUSE_DRAG_AND_DROP dropTarget = new wxSTCDropTarget; dropTarget->SetScintilla(this); stc->SetDropTarget(dropTarget); #endif // wxUSE_DRAG_AND_DROP vs.extraFontFlag = true; // UseAntiAliasing } void ScintillaWX::Finalise() { ScintillaBase::Finalise(); SetTicking(false); SetIdle(false); DestroySystemCaret(); } void ScintillaWX::StartDrag() { #if wxUSE_DRAG_AND_DROP wxString dragText = stc2wx(drag.s, drag.len); // Send an event to allow the drag text to be changed wxScintillaTextEvent evt(wxEVT_STC_START_DRAG, stc->GetId()); evt.SetEventObject(stc); evt.SetDragText(dragText); evt.SetDragAllowMove(true); evt.SetPosition(wxMin(stc->GetSelectionStart(), stc->GetSelectionEnd())); stc->GetEventHandler()->ProcessEvent(evt); dragText = evt.GetDragText(); if (dragText.length()) { wxDropSource source(stc); wxTextDataObject data(dragText); wxDragResult result; source.SetData(data); dropWentOutside = true; inDragDrop = ddDragging; result = source.DoDragDrop(evt.GetDragAllowMove()); if (result == wxDragMove && dropWentOutside) ClearSelection(); inDragDrop = ddNone; SetDragPosition(SelectionPosition(invalidPosition)); } #endif // wxUSE_DRAG_AND_DROP } bool ScintillaWX::SetIdle(bool on) { if (idler.state != on) { // connect or disconnect the EVT_IDLE handler if (on) stc->Connect(wxID_ANY, wxEVT_IDLE, wxIdleEventHandler(wxScintillaTextCtrl::OnIdle)); else stc->Disconnect(wxID_ANY, wxEVT_IDLE, wxIdleEventHandler(wxScintillaTextCtrl::OnIdle)); idler.state = on; } return idler.state; } void ScintillaWX::SetTicking(bool on) { wxSTCTimer* steTimer; if (timer.ticking != on) { timer.ticking = on; if (timer.ticking) { steTimer = new wxSTCTimer(this); steTimer->Start(timer.tickSize); timer.tickerID = steTimer; } else { steTimer = (wxSTCTimer*)timer.tickerID; steTimer->Stop(); delete steTimer; timer.tickerID = 0; } } timer.ticksToWait = caret.period; } void ScintillaWX::SetMouseCapture(bool on) { if (mouseDownCaptures) { if (on && !capturedMouse) stc->CaptureMouse(); else if (!on && capturedMouse && stc->HasCapture()) stc->ReleaseMouse(); capturedMouse = on; } } bool ScintillaWX::HaveMouseCapture() { return capturedMouse; } void ScintillaWX::ScrollText(int linesToMove) { int dy = vs.lineHeight * (linesToMove); stc->ScrollWindow(0, dy); stc->Update(); } void ScintillaWX::SetVerticalScrollPos() { if (stc->m_vScrollBar == NULL) { // Use built-in scrollbar stc->SetScrollPos(wxVERTICAL, topLine); } else { // otherwise use the one that's been given to us stc->m_vScrollBar->SetThumbPosition(topLine); } } void ScintillaWX::SetHorizontalScrollPos() { if (stc->m_hScrollBar == NULL) { // Use built-in scrollbar stc->SetScrollPos(wxHORIZONTAL, xOffset); } else { // otherwise use the one that's been given to us stc->m_hScrollBar->SetThumbPosition(xOffset); } } const int H_SCROLL_STEP = 20; bool ScintillaWX::ModifyScrollBars(int nMax, int nPage) { bool modified = false; int vertEnd = nMax; if (!verticalScrollBarVisible) vertEnd = 0; // Check the vertical scrollbar if (stc->m_vScrollBar == NULL) { // Use built-in scrollbar int sbMax = stc->GetScrollRange(wxVERTICAL); int sbThumb = stc->GetScrollThumb(wxVERTICAL); int sbPos = stc->GetScrollPos(wxVERTICAL); if (sbMax != vertEnd || sbThumb != nPage) { stc->SetScrollbar(wxVERTICAL, sbPos, nPage, vertEnd+1); modified = true; } } else { // otherwise use the one that's been given to us int sbMax = stc->m_vScrollBar->GetRange(); int sbPage = stc->m_vScrollBar->GetPageSize(); int sbPos = stc->m_vScrollBar->GetThumbPosition(); if (sbMax != vertEnd || sbPage != nPage) { stc->m_vScrollBar->SetScrollbar(sbPos, nPage, vertEnd+1, nPage); modified = true; } } // Check the horizontal scrollbar PRectangle rcText = GetTextRectangle(); int horizEnd = scrollWidth; if (horizEnd < 0) horizEnd = 0; if (!horizontalScrollBarVisible || (wrapState != eWrapNone)) horizEnd = 0; int pageWidth = rcText.Width(); if (stc->m_hScrollBar == NULL) { // Use built-in scrollbar int sbMax = stc->GetScrollRange(wxHORIZONTAL); int sbThumb = stc->GetScrollThumb(wxHORIZONTAL); int sbPos = stc->GetScrollPos(wxHORIZONTAL); if ((sbMax != horizEnd) || (sbThumb != pageWidth) || (sbPos != 0)) { stc->SetScrollbar(wxHORIZONTAL, sbPos, pageWidth, horizEnd); modified = true; if (scrollWidth < pageWidth) { HorizontalScrollTo(0); } } } else { // otherwise use the one that's been given to us int sbMax = stc->m_hScrollBar->GetRange(); int sbThumb = stc->m_hScrollBar->GetPageSize(); int sbPos = stc->m_hScrollBar->GetThumbPosition(); if ((sbMax != horizEnd) || (sbThumb != pageWidth) || (sbPos != 0)) { stc->m_hScrollBar->SetScrollbar(sbPos, pageWidth, horizEnd, pageWidth); modified = true; if (scrollWidth < pageWidth) { HorizontalScrollTo(0); } } } return modified; } void ScintillaWX::NotifyChange() { stc->NotifyChange(); } void ScintillaWX::NotifyParent(SCNotification scn) { stc->NotifyParent(&scn); } // This method is overloaded from ScintillaBase in order to prevent the // AutoComplete window from being destroyed when it gets the focus. There is // a side effect that the AutoComp will also not be destroyed when switching // to another window, but I think that is okay. void ScintillaWX::CancelModes() { if (! focusEvent) AutoCompleteCancel(); ct.CallTipCancel(); Editor::CancelModes(); } void ScintillaWX::Copy() { if (!sel.Empty()) { SelectionText st; CopySelectionRange(&st); CopyToClipboard(st); } } void ScintillaWX::Paste() { pdoc->BeginUndoAction(); ClearSelection(); #if wxUSE_DATAOBJ wxTextDataObject data; bool gotData = false; wxTheClipboard->UsePrimarySelection(false); if (wxTheClipboard->Open()) { gotData = wxTheClipboard->GetData(data); wxTheClipboard->Close(); } if (gotData) { wxString text = wxTextBuffer::Translate(data.GetText(), wxConvertEOLMode(pdoc->eolMode)); wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); #if wxUSE_UNICODE // free up the old character buffer in case the text is real big data.SetText(wxEmptyString); text = wxEmptyString; #endif int len = strlen(buf); int caretMain = sel.MainCaret(); pdoc->InsertString(caretMain, buf, len); SetEmptySelection(caretMain + len); } #endif // wxUSE_DATAOBJ pdoc->EndUndoAction(); NotifyChange(); Redraw(); } void ScintillaWX::CopyToClipboard(const SelectionText& st) { #if wxUSE_CLIPBOARD if ( !st.len ) return; wxTheClipboard->UsePrimarySelection(false); if (wxTheClipboard->Open()) { wxString text = wxTextBuffer::Translate(stc2wx(st.s, st.len-1)); wxTheClipboard->SetData(new wxTextDataObject(text)); wxTheClipboard->Close(); } #else wxUnusedVar(st); #endif // wxUSE_CLIPBOARD } bool ScintillaWX::CanPaste() { #if wxUSE_CLIPBOARD bool canPaste = false; bool didOpen; if (Editor::CanPaste()) { wxTheClipboard->UsePrimarySelection(false); didOpen = !wxTheClipboard->IsOpened(); if ( didOpen ) wxTheClipboard->Open(); if (wxTheClipboard->IsOpened()) { canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT); if (didOpen) wxTheClipboard->Close(); } } return canPaste; #else return false; #endif // wxUSE_CLIPBOARD } void ScintillaWX::CreateCallTipWindow(PRectangle) { if (! ct.wCallTip.Created() ) { ct.wCallTip = new wxSTCCallTip(stc, &ct, this); ct.wDraw = ct.wCallTip; } } void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) { if (!label[0]) ((wxMenu*)popup.GetID())->AppendSeparator(); else ((wxMenu*)popup.GetID())->Append(cmd, wxGetTranslation(stc2wx(label))); if (!enabled) ((wxMenu*)popup.GetID())->Enable(cmd, enabled); } // This is called by the Editor base class whenever something is selected. // For wxGTK we can put this text in the primary selection and then other apps // can paste with the middle button. void ScintillaWX::ClaimSelection() { #ifdef __WXGTK__ // Put the selected text in the PRIMARY selection if (!sel.Empty()) { SelectionText st; CopySelectionRange(&st); wxTheClipboard->UsePrimarySelection(true); if (wxTheClipboard->Open()) { wxString text = stc2wx(st.s, st.len); wxTheClipboard->SetData(new wxTextDataObject(text)); wxTheClipboard->Close(); } wxTheClipboard->UsePrimarySelection(false); } #endif } void ScintillaWX::UpdateSystemCaret() { #ifdef __WXMSW__ if (hasFocus) { if (HasCaretSizeChanged()) { DestroySystemCaret(); CreateSystemCaret(); } Point pos = PointMainCaret(); ::SetCaretPos(pos.x, pos.y); } #endif } bool ScintillaWX::HasCaretSizeChanged() { #ifdef __WXMSW__ if ( (vs.caretWidth && (sysCaretWidth != vs.caretWidth)) || (vs.lineHeight && (sysCaretHeight != vs.lineHeight)) ) { return true; } #endif return false; } bool ScintillaWX::CreateSystemCaret() { #ifdef __WXMSW__ sysCaretWidth = vs.caretWidth; if (0 == sysCaretWidth) { sysCaretWidth = 1; } sysCaretHeight = vs.lineHeight; int bitmapSize = (((sysCaretWidth + 15) & ~15) >> 3) * sysCaretHeight; char *bits = new char[bitmapSize]; memset(bits, 0, bitmapSize); sysCaretBitmap = ::CreateBitmap(sysCaretWidth, sysCaretHeight, 1, 1, reinterpret_cast(bits)); delete [] bits; BOOL retval = ::CreateCaret(GetHwndOf(stc), sysCaretBitmap, sysCaretWidth, sysCaretHeight); ::ShowCaret(GetHwndOf(stc)); return retval != 0; #else return false; #endif } bool ScintillaWX::DestroySystemCaret() { #ifdef __WXMSW__ ::HideCaret(GetHwndOf(stc)); BOOL retval = ::DestroyCaret(); if (sysCaretBitmap) { ::DeleteObject(sysCaretBitmap); sysCaretBitmap = 0; } return retval != 0; #else return false; #endif } //---------------------------------------------------------------------- sptr_t ScintillaWX::DefWndProc(unsigned int /*iMessage*/, uptr_t /*wParam*/, sptr_t /*lParam*/) { return 0; } sptr_t ScintillaWX::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { switch (iMessage) { case SCI_CALLTIPSHOW: { // NOTE: This is copied here from scintilla/src/ScintillaBase.cxx // because of the little tweak that needs done below for wxGTK. // When updating new versions double check that this is still // needed, and that any new code there is copied here too. Point pt = LocationFromPosition(wParam); char* defn = reinterpret_cast(lParam); AutoCompleteCancel(); pt.y += vs.lineHeight; int ctStyle = ct.UseStyleCallTip() ? STYLE_CALLTIP : STYLE_DEFAULT; if (ct.UseStyleCallTip()) { ct.SetForeBack(vs.styles[STYLE_CALLTIP].fore, vs.styles[STYLE_CALLTIP].back); } int caretMain = sel.MainCaret(); PRectangle rc = ct.CallTipStart(caretMain, pt, vs.lineHeight, defn, vs.styles[ctStyle].fontName, vs.styles[ctStyle].sizeZoomed, CodePage(), vs.styles[ctStyle].characterSet, vs.technology, wMain); // If the call-tip window would be out of the client // space, adjust so it displays above the text. PRectangle rcClient = GetClientRectangle(); if (rc.bottom > rcClient.bottom) { #ifdef __WXGTK__ int offset = int(vs.lineHeight * 1.25) + rc.Height(); #else int offset = vs.lineHeight + rc.Height(); #endif rc.top -= offset; rc.bottom -= offset; } // Now display the window. CreateCallTipWindow(rc); ct.wCallTip.SetPositionRelative(rc, wMain); ct.wCallTip.Show(); break; } #ifdef SCI_LEXER case SCI_LOADLEXERLIBRARY: LexerManager::GetInstance()->Load((const char*)lParam); break; #endif default: return ScintillaBase::WndProc(iMessage, wParam, lParam); } return 0; } //---------------------------------------------------------------------- // Event delegates void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) { paintState = painting; Surface* surfaceWindow = Surface::Allocate(vs.technology); surfaceWindow->Init(dc, wMain.GetID()); rcPaint = PRectangleFromwxRect(rect); PRectangle rcClient = GetClientRectangle(); paintingAllText = rcPaint.Contains(rcClient); ClipChildren(*dc, rcPaint); Paint(surfaceWindow, rcPaint); delete surfaceWindow; if (paintState == paintAbandoned) { // Painting area was insufficient to cover new styling or brace // highlight positions FullPaint(); } paintState = notPainting; } void ScintillaWX::DoHScroll(int type, int pos) { int xPos = xOffset; PRectangle rcText = GetTextRectangle(); int pageWidth = rcText.Width() * 2 / 3; if (type == wxEVT_SCROLLWIN_LINEUP || type == wxEVT_SCROLL_LINEUP) xPos -= H_SCROLL_STEP; else if (type == wxEVT_SCROLLWIN_LINEDOWN || type == wxEVT_SCROLL_LINEDOWN) xPos += H_SCROLL_STEP; else if (type == wxEVT_SCROLLWIN_PAGEUP || type == wxEVT_SCROLL_PAGEUP) xPos -= pageWidth; else if (type == wxEVT_SCROLLWIN_PAGEDOWN || type == wxEVT_SCROLL_PAGEDOWN) { xPos += pageWidth; if (xPos > scrollWidth - rcText.Width()) { xPos = scrollWidth - rcText.Width(); } } else if (type == wxEVT_SCROLLWIN_TOP || type == wxEVT_SCROLL_TOP) xPos = 0; else if (type == wxEVT_SCROLLWIN_BOTTOM || type == wxEVT_SCROLL_BOTTOM) xPos = scrollWidth; else if (type == wxEVT_SCROLLWIN_THUMBTRACK || type == wxEVT_SCROLL_THUMBTRACK) xPos = pos; HorizontalScrollTo(xPos); } void ScintillaWX::DoVScroll(int type, int pos) { int topLineNew = topLine; if (type == wxEVT_SCROLLWIN_LINEUP || type == wxEVT_SCROLL_LINEUP) topLineNew -= 1; else if (type == wxEVT_SCROLLWIN_LINEDOWN || type == wxEVT_SCROLL_LINEDOWN) topLineNew += 1; else if (type == wxEVT_SCROLLWIN_PAGEUP || type == wxEVT_SCROLL_PAGEUP) topLineNew -= LinesToScroll(); else if (type == wxEVT_SCROLLWIN_PAGEDOWN || type == wxEVT_SCROLL_PAGEDOWN) topLineNew += LinesToScroll(); else if (type == wxEVT_SCROLLWIN_TOP || type == wxEVT_SCROLL_TOP) topLineNew = 0; else if (type == wxEVT_SCROLLWIN_BOTTOM || type == wxEVT_SCROLL_BOTTOM) topLineNew = MaxScrollPos(); else if (type == wxEVT_SCROLLWIN_THUMBTRACK || type == wxEVT_SCROLL_THUMBTRACK) topLineNew = pos; ScrollTo(topLineNew); } void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll ) { int topLineNew = topLine; int lines; if (ctrlDown) { // Zoom the fonts if Ctrl key down if (rotation < 0) { KeyCommand(SCI_ZOOMIN); } else { KeyCommand(SCI_ZOOMOUT); } } else { // otherwise just scroll the window if ( !delta ) delta = 120; wheelRotation += rotation; lines = wheelRotation / delta; wheelRotation -= lines * delta; if (lines != 0) { if (isPageScroll) lines = lines * LinesOnScreen(); // lines is either +1 or -1 else lines *= linesPerAction; topLineNew -= lines; ScrollTo(topLineNew); } } } void ScintillaWX::DoSize(int WXUNUSED(width), int WXUNUSED(height)) { ChangeSize(); } void ScintillaWX::DoLoseFocus(){ focusEvent = true; SetFocusState(false); focusEvent = false; DestroySystemCaret(); } void ScintillaWX::DoGainFocus(){ focusEvent = true; SetFocusState(true); focusEvent = false; DestroySystemCaret(); CreateSystemCaret(); } void ScintillaWX::DoSysColourChange() { InvalidateStyleData(); } void ScintillaWX::DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) { ButtonDown(pt, curTime, shift, ctrl, alt); } void ScintillaWX::DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl) { ButtonUp(pt, curTime, ctrl); } void ScintillaWX::DoLeftButtonMove(Point pt) { ButtonMove(pt); } #ifdef __WXGTK__ void ScintillaWX::DoMiddleButtonUp(Point pt) { // Set the current position to the mouse click point and // then paste in the PRIMARY selection, if any. wxGTK only. int newPos = PositionFromLocation(pt); MovePositionTo(newPos, Selection::noSel, true); pdoc->BeginUndoAction(); wxTextDataObject data; bool gotData = false; wxTheClipboard->UsePrimarySelection(true); if (wxTheClipboard->Open()) { gotData = wxTheClipboard->GetData(data); wxTheClipboard->Close(); } wxTheClipboard->UsePrimarySelection(false); if (gotData) { wxString text = wxTextBuffer::Translate(data.GetText(), wxConvertEOLMode(pdoc->eolMode)); wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); int len = strlen(buf); int caretMain = sel.MainCaret(); pdoc->InsertString(caretMain, buf, len); SetEmptySelection(caretMain + len); } pdoc->EndUndoAction(); NotifyChange(); Redraw(); ShowCaretAtCurrentPosition(); EnsureCaretVisible(); } #else void ScintillaWX::DoMiddleButtonUp(Point WXUNUSED(pt)) { } #endif void ScintillaWX::DoAddChar(int key) { #if wxUSE_UNICODE wxChar wszChars[2]; wszChars[0] = (wxChar)key; wszChars[1] = 0; wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(wszChars); AddCharUTF((char*)buf.data(), strlen(buf)); #else AddChar((char)key); #endif } int ScintillaWX::DoKeyDown(const wxKeyEvent& evt, bool* consumed) { int key = evt.GetKeyCode(); bool shift = evt.ShiftDown(), ctrl = evt.ControlDown(), alt = evt.AltDown(); if (ctrl && key >= 1 && key <= 26 && key != WXK_BACK) key += 'A' - 1; switch (key) { case WXK_DOWN: key = SCK_DOWN; break; case WXK_UP: key = SCK_UP; break; case WXK_LEFT: key = SCK_LEFT; break; case WXK_RIGHT: key = SCK_RIGHT; break; case WXK_HOME: key = SCK_HOME; break; case WXK_END: key = SCK_END; break; case WXK_PAGEUP: key = SCK_PRIOR; break; case WXK_PAGEDOWN: key = SCK_NEXT; break; case WXK_NUMPAD_DOWN: key = SCK_DOWN; break; case WXK_NUMPAD_UP: key = SCK_UP; break; case WXK_NUMPAD_LEFT: key = SCK_LEFT; break; case WXK_NUMPAD_RIGHT: key = SCK_RIGHT; break; case WXK_NUMPAD_HOME: key = SCK_HOME; break; case WXK_NUMPAD_END: key = SCK_END; break; case WXK_NUMPAD_PAGEUP: key = SCK_PRIOR; break; case WXK_NUMPAD_PAGEDOWN: key = SCK_NEXT; break; case WXK_NUMPAD_DELETE: key = SCK_DELETE; break; case WXK_NUMPAD_INSERT: key = SCK_INSERT; break; case WXK_DELETE: key = SCK_DELETE; break; case WXK_INSERT: key = SCK_INSERT; break; case WXK_ESCAPE: key = SCK_ESCAPE; break; case WXK_BACK: key = SCK_BACK; break; case WXK_TAB: key = SCK_TAB; break; case WXK_NUMPAD_ENTER: // fall through case WXK_RETURN: key = SCK_RETURN; break; case WXK_ADD: // fall through case WXK_NUMPAD_ADD: key = SCK_ADD; break; case WXK_SUBTRACT: // fall through case WXK_NUMPAD_SUBTRACT: key = SCK_SUBTRACT; break; case WXK_DIVIDE: // fall through case WXK_NUMPAD_DIVIDE: key = SCK_DIVIDE; break; case WXK_CONTROL: key = 0; break; case WXK_ALT: key = 0; break; case WXK_SHIFT: key = 0; break; case WXK_MENU: key = 0; break; } #ifdef __WXMAC__ if ( evt.MetaDown() ) { // check for a few common Mac Meta-key combos and remap them to Ctrl // for Scintilla switch ( key ) { case 'Z': // Undo case 'X': // Cut case 'C': // Copy case 'V': // Paste case 'A': // Select All ctrl = true; break; } } #endif int rv = KeyDown(key, shift, ctrl, alt, consumed); if (key) return rv; else return 1; } void ScintillaWX::DoCommand(int ID) { Command(ID); } void ScintillaWX::DoContextMenu(Point pt) { if (displayPopupMenu) ContextMenu(pt); } void ScintillaWX::DoOnListBox() { AutoCompleteCompleted(); } void ScintillaWX::DoOnIdle(wxIdleEvent& evt) { if ( Idle() ) evt.RequestMore(); else SetIdle(false); } //---------------------------------------------------------------------- #if wxUSE_DRAG_AND_DROP bool ScintillaWX::DoDropText(long x, long y, const wxString& data) { SetDragPosition(SelectionPosition(invalidPosition)); wxString text = wxTextBuffer::Translate(data, wxConvertEOLMode(pdoc->eolMode)); // Send an event to allow the drag details to be changed wxScintillaTextEvent evt(wxEVT_STC_DO_DROP, stc->GetId()); evt.SetEventObject(stc); evt.SetDragResult(dragResult); evt.SetX(x); evt.SetY(y); evt.SetPosition(PositionFromLocation(Point(x,y))); evt.SetDragText(text); stc->GetEventHandler()->ProcessEvent(evt); dragResult = evt.GetDragResult(); if (dragResult == wxDragMove || dragResult == wxDragCopy) { DropAt(SelectionPosition(evt.GetPosition()), wx2stc(evt.GetDragText()), dragResult == wxDragMove, false); // TODO: rectangular? return true; } return false; } wxDragResult ScintillaWX::DoDragEnter(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxDragResult def) { dragResult = def; return dragResult; } wxDragResult ScintillaWX::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { SetDragPosition(SelectionPosition(PositionFromLocation(Point(x, y)))); // Send an event to allow the drag result to be changed wxScintillaTextEvent evt(wxEVT_STC_DRAG_OVER, stc->GetId()); evt.SetEventObject(stc); evt.SetDragResult(def); evt.SetX(x); evt.SetY(y); evt.SetPosition(PositionFromLocation(Point(x,y))); stc->GetEventHandler()->ProcessEvent(evt); dragResult = evt.GetDragResult(); return dragResult; } void ScintillaWX::DoDragLeave() { SetDragPosition(SelectionPosition(invalidPosition)); } #endif // wxUSE_DRAG_AND_DROP //---------------------------------------------------------------------- // Force the whole window to be repainted void ScintillaWX::FullPaint() { #ifndef __WXMAC__ stc->Refresh(false); #endif stc->Update(); } void ScintillaWX::DoScrollToLine(int line) { ScrollTo(line); } void ScintillaWX::DoScrollToColumn(int column) { HorizontalScrollTo(column * vs.spaceWidth); } // wxGTK doesn't appear to need this explicit clipping code any longer, but I // will leave it here commented out for a while just in case... void ScintillaWX::ClipChildren(wxDC& WXUNUSED(dc), PRectangle WXUNUSED(rect)) { // wxRegion rgn(wxRectFromPRectangle(rect)); // if (ac.Active()) { // wxRect childRect = ((wxWindow*)ac.lb->GetID())->GetRect(); // rgn.Subtract(childRect); // } // if (ct.inCallTipMode) { // wxSTCCallTip* tip = (wxSTCCallTip*)ct.wCallTip.GetID(); // wxRect childRect = tip->GetRect(); // #if wxUSE_POPUPWIN // childRect.SetPosition(tip->GetMyPosition()); // #endif // rgn.Subtract(childRect); // } // dc.SetClippingRegion(rgn); } void ScintillaWX::SetUseAntiAliasing(bool useAA) { vs.extraFontFlag = useAA; InvalidateStyleRedraw(); } bool ScintillaWX::GetUseAntiAliasing() { return vs.extraFontFlag != 0; } //---------------------------------------------------------------------- //---------------------------------------------------------------------- Wx-Scintilla-0.39/wx-scintilla/src/PlatWX.cpp000444001750001750 12136212021352777 21554 0ustar00azawawiazawawi000000000000// Scintilla source code edit control // PlatWX.cxx - implementation of platform facilities on wxWidgets // Copyright 1998-1999 by Neil Hodgson // Robin Dunn // The License.txt file describes the conditions under which this software may be distributed. // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include "wx/menu.h" #include "wx/dcmemory.h" #include "wx/settings.h" #endif // WX_PRECOMP #include #include #if wxUSE_DISPLAY #include "wx/display.h" #endif #include "wx/encconv.h" #include "wx/listctrl.h" #include "wx/mstream.h" #include "wx/image.h" #include "wx/imaglist.h" #include "wx/tokenzr.h" #ifdef wxHAVE_RAW_BITMAP #include "wx/rawbmp.h" #endif #if wxUSE_GRAPHICS_CONTEXT #include "wx/dcgraph.h" #endif #include "Platform.h" #include "PlatWX.h" #include "WxScintilla.h" #include "private.h" Point Point::FromLong(long lpoint) { return Point(lpoint & 0xFFFF, lpoint >> 16); } wxRect wxRectFromPRectangle(PRectangle prc) { wxRect r(prc.left, prc.top, prc.Width(), prc.Height()); return r; } PRectangle PRectangleFromwxRect(wxRect rc) { return PRectangle(rc.GetLeft(), rc.GetTop(), rc.GetRight()+1, rc.GetBottom()+1); } wxColour wxColourFromCA(const ColourDesired& ca) { ColourDesired cd(ca.AsLong()); return wxColour((unsigned char)cd.GetRed(), (unsigned char)cd.GetGreen(), (unsigned char)cd.GetBlue()); } wxColour wxColourFromCAandAlpha(const ColourDesired& ca, int alpha) { ColourDesired cd(ca.AsLong()); return wxColour((unsigned char)cd.GetRed(), (unsigned char)cd.GetGreen(), (unsigned char)cd.GetBlue(), (unsigned char)alpha); } //---------------------------------------------------------------------- Font::Font() { fid = 0; ascent = 0; } Font::~Font() { } void Font::Create(const FontParameters &fp) { Release(); // The minus one is done because since Scintilla uses SC_SHARSET_DEFAULT // internally and we need to have wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT // so we adjust the encoding before passing it to Scintilla. See also // wxStyledTextCtrl::StyleSetCharacterSet wxFontEncoding encoding = (wxFontEncoding)(fp.characterSet-1); wxFontEncodingArray ea = wxEncodingConverter::GetPlatformEquivalents(encoding); if (ea.GetCount()) encoding = ea[0]; wxFont* font = new wxFont(fp.size, wxDEFAULT, fp.italic ? wxITALIC : wxNORMAL, (fp.weight == wxSTC_WEIGHT_BOLD) ? wxBOLD : wxNORMAL, false, stc2wx(fp.faceName), encoding); fid = font; } void Font::Release() { if (fid) delete (wxFont*)fid; fid = 0; } //---------------------------------------------------------------------- class SurfaceImpl : public Surface { private: wxDC* hdc; bool hdcOwned; wxBitmap* bitmap; int x; int y; bool unicodeMode; public: SurfaceImpl(); ~SurfaceImpl(); virtual void Init(WindowID wid); virtual void Init(SurfaceID sid, WindowID wid); virtual void InitPixMap(int width, int height, Surface *surface_, WindowID wid); virtual void Release(); virtual bool Initialised(); virtual void PenColour(ColourDesired fore); virtual int LogPixelsY(); virtual int DeviceHeightFont(int points); virtual void MoveTo(int x_, int y_); virtual void LineTo(int x_, int y_); virtual void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back); virtual void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back); virtual void FillRectangle(PRectangle rc, ColourDesired back); virtual void FillRectangle(PRectangle rc, Surface &surfacePattern); virtual void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back); virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, ColourDesired outline, int alphaOutline, int flags); virtual void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage); virtual void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back); virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource); virtual void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back); virtual void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back); virtual void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore); virtual void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions); virtual XYPOSITION WidthText(Font &font_, const char *s, int len); virtual XYPOSITION WidthChar(Font &font_, char ch); virtual XYPOSITION Ascent(Font &font_); virtual XYPOSITION Descent(Font &font_); virtual XYPOSITION InternalLeading(Font &font_); virtual XYPOSITION ExternalLeading(Font &font_); virtual XYPOSITION Height(Font &font_); virtual XYPOSITION AverageCharWidth(Font &font_); virtual void SetClip(PRectangle rc); virtual void FlushCachedState(); virtual void SetUnicodeMode(bool unicodeMode_); virtual void SetDBCSMode(int codePage); void BrushColour(ColourDesired back); void SetFont(Font &font_); }; SurfaceImpl::SurfaceImpl() : hdc(0), hdcOwned(0), bitmap(0), x(0), y(0), unicodeMode(0) {} SurfaceImpl::~SurfaceImpl() { Release(); } void SurfaceImpl::Init(WindowID wid) { #if 0 Release(); hdc = new wxMemoryDC(); hdcOwned = true; #else // On Mac and GTK the DC is not really valid until it has a bitmap // selected into it. So instead of just creating the DC with no bitmap, // go ahead and give it one. InitPixMap(1,1,NULL,wid); #endif } void SurfaceImpl::Init(SurfaceID hdc_, WindowID) { Release(); hdc = (wxDC*)hdc_; } void SurfaceImpl::InitPixMap(int width, int height, Surface *WXUNUSED(surface_), WindowID) { Release(); hdc = new wxMemoryDC(); hdcOwned = true; if (width < 1) width = 1; if (height < 1) height = 1; bitmap = new wxBitmap(width, height); ((wxMemoryDC*)hdc)->SelectObject(*bitmap); } void SurfaceImpl::Release() { if (bitmap) { ((wxMemoryDC*)hdc)->SelectObject(wxNullBitmap); delete bitmap; bitmap = 0; } if (hdcOwned) { delete hdc; hdc = 0; hdcOwned = false; } } bool SurfaceImpl::Initialised() { return hdc != 0; } void SurfaceImpl::PenColour(ColourDesired fore) { hdc->SetPen(wxPen(wxColourFromCA(fore))); } void SurfaceImpl::BrushColour(ColourDesired back) { hdc->SetBrush(wxBrush(wxColourFromCA(back))); } void SurfaceImpl::SetFont(Font &font_) { if (font_.GetID()) { hdc->SetFont(*((wxFont*)font_.GetID())); } } int SurfaceImpl::LogPixelsY() { return hdc->GetPPI().y; } int SurfaceImpl::DeviceHeightFont(int points) { return points; } void SurfaceImpl::MoveTo(int x_, int y_) { x = x_; y = y_; } void SurfaceImpl::LineTo(int x_, int y_) { hdc->DrawLine(x,y, x_,y_); x = x_; y = y_; } void SurfaceImpl::Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back) { PenColour(fore); BrushColour(back); std::vector points; for (int i=0; i< npts; i++) { points.push_back(wxPoint(pts[i].x, pts[i].y)); } hdc->DrawPolygon(npts, &points[0]); } void SurfaceImpl::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) { PenColour(fore); BrushColour(back); hdc->DrawRectangle(wxRectFromPRectangle(rc)); } void SurfaceImpl::FillRectangle(PRectangle rc, ColourDesired back) { const wxPen oldPen = hdc->GetPen(); BrushColour(back); hdc->SetPen(*wxTRANSPARENT_PEN); hdc->DrawRectangle(wxRectFromPRectangle(rc)); hdc->SetPen( oldPen ); } void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) { wxBrush br; if (((SurfaceImpl&)surfacePattern).bitmap) br = wxBrush(*((SurfaceImpl&)surfacePattern).bitmap); else // Something is wrong so display in red br = wxBrush(*wxRED); hdc->SetPen(*wxTRANSPARENT_PEN); hdc->SetBrush(br); hdc->DrawRectangle(wxRectFromPRectangle(rc)); } void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) { PenColour(fore); BrushColour(back); hdc->DrawRoundedRectangle(wxRectFromPRectangle(rc), 4); } #ifdef __WXMSW__ #define wxPy_premultiply(p, a) ((p) * (a) / 0xff) #else #define wxPy_premultiply(p, a) (p) #endif void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, ColourDesired outline, int alphaOutline, int /*flags*/) { #if wxUSE_GRAPHICS_CONTEXT wxGCDC dc(*(wxMemoryDC*)hdc); wxColour penColour(wxColourFromCAandAlpha(outline, alphaOutline)); wxColour brushColour(wxColourFromCAandAlpha(fill, alphaFill)); dc.SetPen(wxPen(penColour)); dc.SetBrush(wxBrush(brushColour)); dc.DrawRoundedRectangle(wxRectFromPRectangle(rc), cornerSize); return; #else #ifdef wxHAVE_RAW_BITMAP // TODO: do something with cornerSize wxUnusedVar(cornerSize); int x, y; wxRect r = wxRectFromPRectangle(rc); wxBitmap bmp(r.width, r.height, 32); wxAlphaPixelData pixData(bmp); pixData.UseAlpha(); // Set the fill pixels ColourDesired cdf(fill.AsLong()); int red = cdf.GetRed(); int green = cdf.GetGreen(); int blue = cdf.GetBlue(); wxAlphaPixelData::Iterator p(pixData); for (y=0; yDrawBitmap(bmp, r.x, r.y, true); #else wxUnusedVar(cornerSize); wxUnusedVar(alphaFill); wxUnusedVar(alphaOutline); RectangleDraw(rc, outline, fill); #endif #endif } //TODO implement SurfaceImpl::DrawRGBAImage void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) { printf("RegisterRGBAImage is not implemented! Please contact the author\n"); } void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) { PenColour(fore); BrushColour(back); hdc->DrawEllipse(wxRectFromPRectangle(rc)); } void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) { wxRect r = wxRectFromPRectangle(rc); hdc->Blit(r.x, r.y, r.width, r.height, ((SurfaceImpl&)surfaceSource).hdc, from.x, from.y, wxCOPY); } void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back) { SetFont(font); hdc->SetTextForeground(wxColourFromCA(fore)); hdc->SetTextBackground(wxColourFromCA(back)); FillRectangle(rc, back); // ybase is where the baseline should be, but wxWin uses the upper left // corner, so I need to calculate the real position for the text... hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent); } void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back) { SetFont(font); hdc->SetTextForeground(wxColourFromCA(fore)); hdc->SetTextBackground(wxColourFromCA(back)); FillRectangle(rc, back); hdc->SetClippingRegion(wxRectFromPRectangle(rc)); // see comments above hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent); hdc->DestroyClippingRegion(); } void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font, XYPOSITION ybase, const char *s, int len, ColourDesired fore) { SetFont(font); hdc->SetTextForeground(wxColourFromCA(fore)); hdc->SetBackgroundMode(wxTRANSPARENT); // ybase is where the baseline should be, but wxWin uses the upper left // corner, so I need to calculate the real position for the text... hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent); hdc->SetBackgroundMode(wxSOLID); } void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, XYPOSITION *positions) { wxString str = stc2wx(s, len); wxArrayInt tpos; SetFont(font); hdc->GetPartialTextExtents(str, tpos); #if wxUSE_UNICODE // Map the widths for UCS-2 characters back to the UTF-8 input string // NOTE: I don't think this is right for when sizeof(wxChar) > 2, ie wxGTK2 // so figure it out and fix it! size_t i = 0; size_t ui = 0; while ((int)i < len) { unsigned char uch = (unsigned char)s[i]; positions[i++] = tpos[ui]; if (uch >= 0x80) { if (uch < (0x80 + 0x40 + 0x20)) { positions[i++] = tpos[ui]; } else { positions[i++] = tpos[ui]; positions[i++] = tpos[ui]; } } ui++; } #else // If not unicode then just use the widths we have #if wxUSE_STL std::copy(tpos.begin(), tpos.end(), positions); #else memcpy(positions, tpos.begin(), len * sizeof(int)); #endif #endif } XYPOSITION SurfaceImpl::WidthText(Font &font, const char *s, int len) { SetFont(font); int w; int h; hdc->GetTextExtent(stc2wx(s, len), &w, &h); return w; } XYPOSITION SurfaceImpl::WidthChar(Font &font, char ch) { SetFont(font); int w; int h; char s[2] = { ch, 0 }; hdc->GetTextExtent(stc2wx(s, 1), &w, &h); return w; } #define EXTENT_TEST wxT(" `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") XYPOSITION SurfaceImpl::Ascent(Font &font) { SetFont(font); int w, h, d, e; hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e); font.ascent = h - d; return font.ascent; } XYPOSITION SurfaceImpl::Descent(Font &font) { SetFont(font); int w, h, d, e; hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e); return d; } XYPOSITION SurfaceImpl::InternalLeading(Font &WXUNUSED(font)) { return 0; } XYPOSITION SurfaceImpl::ExternalLeading(Font &font) { SetFont(font); int w, h, d, e; hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e); return e; } XYPOSITION SurfaceImpl::Height(Font &font) { SetFont(font); return hdc->GetCharHeight() + 1; } XYPOSITION SurfaceImpl::AverageCharWidth(Font &font) { SetFont(font); return hdc->GetCharWidth(); } void SurfaceImpl::SetClip(PRectangle rc) { hdc->SetClippingRegion(wxRectFromPRectangle(rc)); } void SurfaceImpl::FlushCachedState() { } void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) { unicodeMode=unicodeMode_; } void SurfaceImpl::SetDBCSMode(int WXUNUSED(codePage)) { // dbcsMode = codePage == SC_CP_DBCS; } Surface *Surface::Allocate(int technology) { return new SurfaceImpl; } //---------------------------------------------------------------------- inline wxWindow* GETWIN(WindowID id) { return (wxWindow*)id; } Window::~Window() { } void Window::Destroy() { if (wid) { Show(false); GETWIN(wid)->Destroy(); } wid = 0; } bool Window::HasFocus() { return wxWindow::FindFocus() == GETWIN(wid); } PRectangle Window::GetPosition() { if (! wid) return PRectangle(); wxRect rc(GETWIN(wid)->GetPosition(), GETWIN(wid)->GetSize()); return PRectangleFromwxRect(rc); } void Window::SetPosition(PRectangle rc) { wxRect r = wxRectFromPRectangle(rc); GETWIN(wid)->SetSize(r); } void Window::SetPositionRelative(PRectangle rc, Window) { SetPosition(rc); // ???? } PRectangle Window::GetClientPosition() { if (! wid) return PRectangle(); wxSize sz = GETWIN(wid)->GetClientSize(); return PRectangle(0, 0, sz.x, sz.y); } void Window::Show(bool show) { GETWIN(wid)->Show(show); } void Window::InvalidateAll() { GETWIN(wid)->Refresh(false); } void Window::InvalidateRectangle(PRectangle rc) { wxRect r = wxRectFromPRectangle(rc); GETWIN(wid)->Refresh(false, &r); } void Window::SetFont(Font &font) { GETWIN(wid)->SetFont(*((wxFont*)font.GetID())); } void Window::SetCursor(Cursor curs) { wxStockCursor cursorId; switch (curs) { case cursorText: cursorId = wxCURSOR_IBEAM; break; case cursorArrow: cursorId = wxCURSOR_ARROW; break; case cursorUp: cursorId = wxCURSOR_ARROW; // ** no up arrow... wxCURSOR_UPARROW; break; case cursorWait: cursorId = wxCURSOR_WAIT; break; case cursorHoriz: cursorId = wxCURSOR_SIZEWE; break; case cursorVert: cursorId = wxCURSOR_SIZENS; break; case cursorReverseArrow: cursorId = wxCURSOR_RIGHT_ARROW; break; case cursorHand: cursorId = wxCURSOR_HAND; break; default: cursorId = wxCURSOR_ARROW; break; } wxCursor wc = wxCursor(cursorId); if(curs != cursorLast) { GETWIN(wid)->SetCursor(wc); cursorLast = curs; } } void Window::SetTitle(const char *s) { GETWIN(wid)->SetLabel(stc2wx(s)); } // Returns rectangle of monitor pt is on PRectangle Window::GetMonitorRect(Point pt) { wxRect rect; if (! wid) return PRectangle(); #if wxUSE_DISPLAY // Get the display the point is found on int n = wxDisplay::GetFromPoint(wxPoint(pt.x, pt.y)); wxDisplay dpy(n == wxNOT_FOUND ? 0 : n); rect = dpy.GetGeometry(); #else wxUnusedVar(pt); #endif return PRectangleFromwxRect(rect); } //---------------------------------------------------------------------- // Helper classes for ListBox // This is a simple subclass of wxListView that just resets focus to the // parent when it gets it. class wxSTCListBox : public wxListView { public: wxSTCListBox(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : wxListView() { #ifdef __WXMSW__ Hide(); // don't flicker as we move it around... #endif Create(parent, id, pos, size, style); } void OnFocus(wxFocusEvent& event) { GetParent()->SetFocus(); event.Skip(); } void OnKillFocus(wxFocusEvent& WXUNUSED(event)) { // Do nothing. Prevents base class from resetting the colors... } #ifdef __WXMAC__ // For some reason I don't understand yet the focus doesn't really leave // the listbox like it should, so if we get any events feed them back to // the wxSTC void OnKeyDown(wxKeyEvent& event) { GetGrandParent()->GetEventHandler()->ProcessEvent(event); } void OnChar(wxKeyEvent& event) { GetGrandParent()->GetEventHandler()->ProcessEvent(event); } // And we need to force the focus back when being destroyed ~wxSTCListBox() { GetGrandParent()->SetFocus(); } #endif private: DECLARE_EVENT_TABLE() }; BEGIN_EVENT_TABLE(wxSTCListBox, wxListView) EVT_SET_FOCUS( wxSTCListBox::OnFocus) EVT_KILL_FOCUS(wxSTCListBox::OnKillFocus) #ifdef __WXMAC__ EVT_KEY_DOWN( wxSTCListBox::OnKeyDown) EVT_CHAR( wxSTCListBox::OnChar) #endif END_EVENT_TABLE() #if wxUSE_POPUPWIN //----------------------------------- #include "wx/popupwin.h" // A popup window to place the wxSTCListBox upon class wxSTCListBoxWin : public wxPopupWindow { private: wxListView* lv; CallBackAction doubleClickAction; void* doubleClickActionData; public: wxSTCListBoxWin(wxWindow* parent, wxWindowID id, Point WXUNUSED(location)) : wxPopupWindow(parent, wxBORDER_SIMPLE) { lv = new wxSTCListBox(parent, id, wxPoint(-50,-50), wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_NO_HEADER | wxBORDER_NONE); lv->SetCursor(wxCursor(wxCURSOR_ARROW)); lv->InsertColumn(0, wxEmptyString); lv->InsertColumn(1, wxEmptyString); // NOTE: We need to fool the wxListView into thinking that it has the // focus so it will use the normal selection colour and will look // "right" to the user. But since the wxPopupWindow or its children // can't receive focus then we have to pull a fast one and temporarily // parent the listctrl on the STC window and then call SetFocus and // then reparent it back to the popup. lv->SetFocus(); lv->Reparent(this); #ifdef __WXMSW__ lv->Show(); #endif } // Set position in client coords virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) { if (x != wxDefaultCoord) { GetParent()->ClientToScreen(&x, NULL); } if (y != wxDefaultCoord) { GetParent()->ClientToScreen(NULL, &y); } wxPopupWindow::DoSetSize(x, y, width, height, sizeFlags); } // return position as if it were in client coords virtual void DoGetPosition( int *x, int *y ) const { int sx, sy; wxPopupWindow::DoGetPosition(&sx, &sy); GetParent()->ScreenToClient(&sx, &sy); if (x) *x = sx; if (y) *y = sy; } bool Destroy() { if ( !wxPendingDelete.Member(this) ) wxPendingDelete.Append(this); return true; } int IconWidth() { wxImageList* il = lv->GetImageList(wxIMAGE_LIST_SMALL); if (il != NULL) { int w, h; il->GetSize(0, w, h); return w; } return 0; } void SetDoubleClickAction(CallBackAction action, void *data) { doubleClickAction = action; doubleClickActionData = data; } void OnFocus(wxFocusEvent& event) { GetParent()->SetFocus(); event.Skip(); } void OnSize(wxSizeEvent& event) { // resize the child to fill the popup wxSize sz = GetClientSize(); lv->SetSize(0, 0, sz.x, sz.y); // reset the column widths lv->SetColumnWidth(0, IconWidth()+4); lv->SetColumnWidth(1, sz.x - 2 - lv->GetColumnWidth(0) - wxSystemSettings::GetMetric(wxSYS_VSCROLL_X)); event.Skip(); } void OnActivate(wxListEvent& WXUNUSED(event)) { doubleClickAction(doubleClickActionData); } wxListView* GetLB() { return lv; } private: DECLARE_EVENT_TABLE() }; BEGIN_EVENT_TABLE(wxSTCListBoxWin, wxPopupWindow) EVT_SET_FOCUS ( wxSTCListBoxWin::OnFocus) EVT_SIZE ( wxSTCListBoxWin::OnSize) EVT_LIST_ITEM_ACTIVATED(wxID_ANY, wxSTCListBoxWin::OnActivate) END_EVENT_TABLE() #else // !wxUSE_POPUPWIN ----------------------------------- #include "wx/frame.h" // A normal window to place the wxSTCListBox upon, but make it behave as much // like a wxPopupWindow as possible class wxSTCListBoxWin : public wxFrame { private: wxListView* lv; CallBackAction doubleClickAction; void* doubleClickActionData; public: wxSTCListBoxWin(wxWindow* parent, wxWindowID id, Point location) : wxFrame(parent, id, wxEmptyString, wxPoint(location.x, location.y), wxSize(0,0), wxFRAME_NO_TASKBAR | wxFRAME_FLOAT_ON_PARENT #ifdef __WXMAC__ | wxPOPUP_WINDOW | wxNO_BORDER #else | wxSIMPLE_BORDER #endif ) { lv = new wxSTCListBox(this, id, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_NO_HEADER | wxNO_BORDER); lv->SetCursor(wxCursor(wxCURSOR_ARROW)); lv->InsertColumn(0, wxEmptyString); lv->InsertColumn(1, wxEmptyString); // Eventhough we immediately reset the focus to the parent, this helps // things to look right... lv->SetFocus(); Hide(); } // On OSX and (possibly others) there can still be pending // messages/events for the list control when Scintilla wants to // close it, so do a pending delete of it instead of destroying // immediately. bool Destroy() { #ifdef __WXMAC__ // The bottom edge of this window is not getting properly // refreshed upon deletion, so help it out... wxWindow* p = GetParent(); wxRect r(GetPosition(), GetSize()); r.SetHeight(r.GetHeight()+1); p->Refresh(false, &r); #endif if ( !wxPendingDelete.Member(this) ) wxPendingDelete.Append(this); return true; } int IconWidth() { wxImageList* il = lv->GetImageList(wxIMAGE_LIST_SMALL); if (il != NULL) { int w, h; il->GetSize(0, w, h); return w; } return 0; } void SetDoubleClickAction(CallBackAction action, void *data) { doubleClickAction = action; doubleClickActionData = data; } void OnFocus(wxFocusEvent& event) { ActivateParent(); GetParent()->SetFocus(); event.Skip(); } void OnSize(wxSizeEvent& event) { // resize the child wxSize sz = GetClientSize(); lv->SetSize(sz); // reset the column widths lv->SetColumnWidth(0, IconWidth()+4); lv->SetColumnWidth(1, sz.x - 2 - lv->GetColumnWidth(0) - wxSystemSettings::GetMetric(wxSYS_VSCROLL_X)); event.Skip(); } void ActivateParent() { // Although we're a frame, we always want the parent to be active, so // raise it whenever we get shown, focused, etc. wxTopLevelWindow *frame = wxDynamicCast( wxGetTopLevelParent(GetParent()), wxTopLevelWindow); if (frame) frame->Raise(); } virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) { // convert coords to screen coords since we're a top-level window if (x != wxDefaultCoord) { GetParent()->ClientToScreen(&x, NULL); } if (y != wxDefaultCoord) { GetParent()->ClientToScreen(NULL, &y); } wxFrame::DoSetSize(x, y, width, height, sizeFlags); } virtual bool Show(bool show = true) { bool rv = wxFrame::Show(show); if (rv && show) ActivateParent(); #ifdef __WXMAC__ GetParent()->Refresh(false); #endif return rv; } void OnActivate(wxListEvent& WXUNUSED(event)) { doubleClickAction(doubleClickActionData); } wxListView* GetLB() { return lv; } private: DECLARE_EVENT_TABLE() }; BEGIN_EVENT_TABLE(wxSTCListBoxWin, wxWindow) EVT_SET_FOCUS ( wxSTCListBoxWin::OnFocus) EVT_SIZE ( wxSTCListBoxWin::OnSize) EVT_LIST_ITEM_ACTIVATED(wxID_ANY, wxSTCListBoxWin::OnActivate) END_EVENT_TABLE() #endif // wxUSE_POPUPWIN ----------------------------------- inline wxSTCListBoxWin* GETLBW(WindowID win) { return ((wxSTCListBoxWin*)win); } inline wxListView* GETLB(WindowID win) { return GETLBW(win)->GetLB(); } //---------------------------------------------------------------------- class ListBoxImpl : public ListBox { private: int lineHeight; bool unicodeMode; int desiredVisibleRows; int aveCharWidth; size_t maxStrWidth; Point location; // Caret location at which the list is opened wxImageList* imgList; wxArrayInt* imgTypeMap; public: ListBoxImpl(); ~ListBoxImpl(); virtual void SetFont(Font &font); virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, int technology_); virtual void SetAverageCharWidth(int width); virtual void SetVisibleRows(int rows); virtual int GetVisibleRows() const; virtual PRectangle GetDesiredRect(); virtual int CaretFromEdge(); virtual void Clear(); virtual void Append(char *s, int type = -1); void Append(const wxString& text, int type); virtual int Length(); virtual void Select(int n); virtual int GetSelection(); virtual int Find(const char *prefix); virtual void GetValue(int n, char *value, int len); virtual void RegisterImage(int type, const char *xpm_data); virtual void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage); virtual void ClearRegisteredImages(); virtual void SetDoubleClickAction(CallBackAction, void *); virtual void SetList(const char* list, char separator, char typesep); }; ListBoxImpl::ListBoxImpl() : lineHeight(10), unicodeMode(false), desiredVisibleRows(5), aveCharWidth(8), maxStrWidth(0), imgList(NULL), imgTypeMap(NULL) { } ListBoxImpl::~ListBoxImpl() { wxDELETE(imgList); wxDELETE(imgTypeMap); } void ListBoxImpl::SetFont(Font &font) { GETLB(wid)->SetFont(*((wxFont*)font.GetID())); } void ListBoxImpl::Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, int technology_) { location = location_; lineHeight = lineHeight_; unicodeMode = unicodeMode_; maxStrWidth = 0; wid = new wxSTCListBoxWin(GETWIN(parent.GetID()), ctrlID, location); if (imgList != NULL) GETLB(wid)->SetImageList(imgList, wxIMAGE_LIST_SMALL); } void ListBoxImpl::SetAverageCharWidth(int width) { aveCharWidth = width; } void ListBoxImpl::SetVisibleRows(int rows) { desiredVisibleRows = rows; } int ListBoxImpl::GetVisibleRows() const { return desiredVisibleRows; } PRectangle ListBoxImpl::GetDesiredRect() { // wxListCtrl doesn't have a DoGetBestSize, so instead we kept track of // the max size in Append and calculate it here... int maxw = maxStrWidth * aveCharWidth; int maxh ; // give it a default if there are no lines, and/or add a bit more if (maxw == 0) maxw = 100; maxw += aveCharWidth * 3 + GETLBW(wid)->IconWidth() + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); if (maxw > 350) maxw = 350; // estimate a desired height int count = GETLB(wid)->GetItemCount(); if (count) { wxRect rect; GETLB(wid)->GetItemRect(0, rect); maxh = count * rect.GetHeight(); if (maxh > 140) // TODO: Use desiredVisibleRows?? maxh = 140; // Try to make the size an exact multiple of some number of lines int lines = maxh / rect.GetHeight(); maxh = (lines + 1) * rect.GetHeight() + 2; } else maxh = 100; PRectangle rc; rc.top = 0; rc.left = 0; rc.right = maxw; rc.bottom = maxh; return rc; } int ListBoxImpl::CaretFromEdge() { return 4 + GETLBW(wid)->IconWidth(); } void ListBoxImpl::Clear() { GETLB(wid)->DeleteAllItems(); } void ListBoxImpl::Append(char *s, int type) { Append(stc2wx(s), type); } void ListBoxImpl::Append(const wxString& text, int type) { long count = GETLB(wid)->GetItemCount(); long itemID = GETLB(wid)->InsertItem(count, wxEmptyString); long idx = -1; GETLB(wid)->SetItem(itemID, 1, text); maxStrWidth = wxMax(maxStrWidth, text.length()); if (type != -1) { wxCHECK_RET(imgTypeMap, wxT("Unexpected NULL imgTypeMap")); idx = imgTypeMap->Item(type); } GETLB(wid)->SetItemImage(itemID, idx, idx); } void ListBoxImpl::SetList(const char* list, char separator, char typesep) { GETLB(wid)->Freeze(); Clear(); wxStringTokenizer tkzr(stc2wx(list), (wxChar)separator); while ( tkzr.HasMoreTokens() ) { wxString token = tkzr.GetNextToken(); long type = -1; int pos = token.Find(typesep); if (pos != -1) { token.Mid(pos+1).ToLong(&type); token.Truncate(pos); } Append(token, (int)type); } GETLB(wid)->Thaw(); } int ListBoxImpl::Length() { return GETLB(wid)->GetItemCount(); } void ListBoxImpl::Select(int n) { bool select = true; if (n == -1) { n = 0; select = false; } GETLB(wid)->EnsureVisible(n); GETLB(wid)->Select(n, select); } int ListBoxImpl::GetSelection() { return GETLB(wid)->GetFirstSelected(); } int ListBoxImpl::Find(const char *WXUNUSED(prefix)) { // No longer used return wxNOT_FOUND; } void ListBoxImpl::GetValue(int n, char *value, int len) { wxListItem item; item.SetId(n); item.SetColumn(1); item.SetMask(wxLIST_MASK_TEXT); GETLB(wid)->GetItem(item); strncpy(value, wx2stc(item.GetText()), len); value[len-1] = '\0'; } void ListBoxImpl::RegisterImage(int type, const char *xpm_data) { wxMemoryInputStream stream(xpm_data, strlen(xpm_data)+1); wxImage img(stream, wxBITMAP_TYPE_XPM); wxBitmap bmp(img); if (! imgList) { // assumes all images are the same size imgList = new wxImageList(bmp.GetWidth(), bmp.GetHeight(), true); imgTypeMap = new wxArrayInt; } int idx = imgList->Add(bmp); // do we need to extend the mapping array? wxArrayInt& itm = *imgTypeMap; if ( itm.GetCount() < (size_t)type+1) itm.Add(-1, type - itm.GetCount() + 1); // Add an item that maps type to the image index itm[type] = idx; } //TODO implement ListBoxImpl::RegisterRGBAImage void ListBoxImpl::RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) { printf("RegisterRGBAImage is not implemented! Please contact the author\n"); } void ListBoxImpl::ClearRegisteredImages() { wxDELETE(imgList); wxDELETE(imgTypeMap); if (wid) GETLB(wid)->SetImageList(NULL, wxIMAGE_LIST_SMALL); } void ListBoxImpl::SetDoubleClickAction(CallBackAction action, void *data) { GETLBW(wid)->SetDoubleClickAction(action, data); } ListBox::ListBox() { } ListBox::~ListBox() { } ListBox *ListBox::Allocate() { return new ListBoxImpl(); } //---------------------------------------------------------------------- Menu::Menu() : mid(0) { } void Menu::CreatePopUp() { Destroy(); mid = new wxMenu(); } void Menu::Destroy() { if (mid) delete (wxMenu*)mid; mid = 0; } void Menu::Show(Point pt, Window &w) { GETWIN(w.GetID())->PopupMenu((wxMenu*)mid, pt.x - 4, pt.y); Destroy(); } //---------------------------------------------------------------------- DynamicLibrary *DynamicLibrary::Load(const char *WXUNUSED(modulePath)) { wxFAIL_MSG(wxT("Dynamic lexer loading not implemented yet")); return NULL; } //---------------------------------------------------------------------- ColourDesired Platform::Chrome() { wxColour c; c = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); return ColourDesired(c.Red(), c.Green(), c.Blue()); } ColourDesired Platform::ChromeHighlight() { wxColour c; c = wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT); return ColourDesired(c.Red(), c.Green(), c.Blue()); } const char *Platform::DefaultFont() { static char buf[128]; strcpy(buf, wxNORMAL_FONT->GetFaceName().mbc_str()); return buf; } int Platform::DefaultFontSize() { return wxNORMAL_FONT->GetPointSize(); } unsigned int Platform::DoubleClickTime() { return 500; // **** ::GetDoubleClickTime(); } bool Platform::MouseButtonBounce() { return false; } bool Platform::IsKeyDown(int WXUNUSED(key)) { return false; // I don't think we'll need this. } long Platform::SendScintilla(WindowID w, unsigned int msg, unsigned long wParam, long lParam) { wxScintillaTextCtrl* stc = (wxScintillaTextCtrl*)w; return stc->SendMsg(msg, wParam, lParam); } long Platform::SendScintillaPointer(WindowID w, unsigned int msg, unsigned long wParam, void *lParam) { wxScintillaTextCtrl* stc = (wxScintillaTextCtrl*)w; return stc->SendMsg(msg, wParam, (wxIntPtr)lParam); } // These are utility functions not really tied to a platform int Platform::Minimum(int a, int b) { if (a < b) return a; else return b; } int Platform::Maximum(int a, int b) { if (a > b) return a; else return b; } //#define TRACE void Platform::DebugDisplay(const char *s) { #ifdef TRACE wxLogDebug(stc2wx(s)); #else wxUnusedVar(s); #endif } void Platform::DebugPrintf(const char *format, ...) { #ifdef TRACE char buffer[2000]; va_list pArguments; va_start(pArguments, format); vsprintf(buffer,format,pArguments); va_end(pArguments); Platform::DebugDisplay(buffer); #else wxUnusedVar(format); #endif } static bool assertionPopUps = true; bool Platform::ShowAssertionPopUps(bool assertionPopUps_) { bool ret = assertionPopUps; assertionPopUps = assertionPopUps_; return ret; } void Platform::Assert(const char *c, const char *file, int line) { #ifdef TRACE char buffer[2000]; sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line); if (assertionPopUps) { /*int idButton = */ wxMessageBox(stc2wx(buffer), wxT("Assertion failure"), wxICON_HAND | wxOK); } else { strcat(buffer, "\r\n"); Platform::DebugDisplay(buffer); abort(); } #else wxUnusedVar(c); wxUnusedVar(file); wxUnusedVar(line); #endif } int Platform::Clamp(int val, int minVal, int maxVal) { if (val > maxVal) val = maxVal; if (val < minVal) val = minVal; return val; } bool Platform::IsDBCSLeadByte(int WXUNUSED(codePage), char WXUNUSED(ch)) { return false; } int Platform::DBCSCharLength(int WXUNUSED(codePage), const char *WXUNUSED(s)) { return 1; } int Platform::DBCSCharMaxLength() { return 1; } //---------------------------------------------------------------------- ElapsedTime::ElapsedTime() { wxLongLong localTime = wxGetLocalTimeMillis(); littleBit = localTime.GetLo(); bigBit = localTime.GetHi(); } double ElapsedTime::Duration(bool reset) { wxLongLong prevTime(bigBit, littleBit); wxLongLong localTime = wxGetLocalTimeMillis(); if(reset) { littleBit = localTime.GetLo(); bigBit = localTime.GetHi(); } wxLongLong duration = localTime - prevTime; double result = duration.ToDouble(); result /= 1000.0; return result; } //---------------------------------------------------------------------- #if wxUSE_UNICODE #include "UniConversion.h" // Convert using Scintilla's functions instead of wx's, Scintilla's are more // forgiving and won't assert... wxString stc2wx(const char* str, size_t len) { if (!len) return wxEmptyString; size_t wclen = UTF16Length(str, len); wxWCharBuffer buffer(wclen+1); size_t actualLen = UTF16FromUTF8(str, len, buffer.data(), wclen+1); return wxString(buffer.data(), actualLen); } wxString stc2wx(const char* str) { return stc2wx(str, strlen(str)); } const wxWX2MBbuf wx2stc(const wxString& str) { const wchar_t* wcstr = str.c_str(); size_t wclen = str.length(); size_t len = UTF8Length(wcstr, wclen); wxCharBuffer buffer(len+1); UTF8FromUTF16(wcstr, wclen, buffer.data(), len); // TODO check NULL termination!! return buffer; } #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla_cwc.h000444001750001750 11312021352777 22566 0ustar00azawawiazawawi000000000000#define __WX__ #define SCI_LEXER #define LINK_LEXERS #include "wx/wx_cwc.h"Wx-Scintilla-0.39/wx-scintilla/src/scintilla.cpp000444001750001750 36421212021352776 22361 0ustar00azawawiazawawi000000000000//////////////////////////////////////////////////////////////////////////// // Name: stc.cpp // Purpose: A wxWidgets implementation of Scintilla. This class is the // one meant to be used directly by wx applications. It does not // derive directly from the Scintilla classes, but instead // delegates most things to the real Scintilla class. // This allows the use of Scintilla without polluting the // namespace with all the classes and identifiers from Scintilla. // // Author: Robin Dunn // // Created: 13-Jan-2000 // RCS-ID: $Id$ // Copyright: (c) 2000 by Total Control Software // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// /* IMPORTANT: src/stc/stc.cpp is generated by src/stc/gen_iface.py from src/stc/stc.cpp.in, don't edit stc.cpp file as your changes will be lost after the next regeneration, edit stc.cpp.in and rerun the gen_iface.py script instead! Parts of this file generated by the script are found in between the special "{{{" and "}}}" markers, the rest of it is copied verbatim from src.h.in. */ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #include "WxScintilla.h" #include "private.h" #ifndef WX_PRECOMP #include "wx/wx.h" #endif // WX_PRECOMP #include #include "wx/tokenzr.h" #include "wx/mstream.h" #include "wx/image.h" #include "wx/ffile.h" #include "ScintillaWX.h" //---------------------------------------------------------------------- const wxChar* wxSTCNameStr = wxT("stcwindow"); #ifdef MAKELONG #undef MAKELONG #endif #define MAKELONG(a, b) ((a) | ((b) << 16)) static long wxColourAsLong(const wxColour& co) { return (((long)co.Blue() << 16) | ((long)co.Green() << 8) | ((long)co.Red())); } static wxColour wxColourFromLong(long c) { wxColour clr; clr.Set((unsigned char)(c & 0xff), (unsigned char)((c >> 8) & 0xff), (unsigned char)((c >> 16) & 0xff)); return clr; } static wxColour wxColourFromSpec(const wxString& spec) { // spec should be a colour name or "#RRGGBB" if (spec.GetChar(0) == wxT('#')) { long red, green, blue; red = green = blue = 0; spec.Mid(1,2).ToLong(&red, 16); spec.Mid(3,2).ToLong(&green, 16); spec.Mid(5,2).ToLong(&blue, 16); return wxColour((unsigned char)red, (unsigned char)green, (unsigned char)blue); } else return wxColour(spec); } //---------------------------------------------------------------------- DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE ); DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED ); DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED ); DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED ); DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT ); DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT ); DEFINE_EVENT_TYPE( wxEVT_STC_KEY ); DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK ); DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI ); DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED ); DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD ); DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK ); DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN ); DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED ); DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION ); DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED ); DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART ); DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND ); DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG ); DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER ); DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP ); DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM ); DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK ); DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK ); DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK ); DEFINE_EVENT_TYPE( wxEVT_STC_AUTOCOMP_SELECTION ); DEFINE_EVENT_TYPE( wxEVT_STC_INDICATOR_CLICK ); DEFINE_EVENT_TYPE( wxEVT_STC_INDICATOR_RELEASE ); DEFINE_EVENT_TYPE( wxEVT_STC_AUTOCOMP_CANCELLED ); DEFINE_EVENT_TYPE( wxEVT_STC_AUTOCOMP_CHAR_DELETED ); BEGIN_EVENT_TABLE(wxScintillaTextCtrl, wxControl) EVT_PAINT (wxScintillaTextCtrl::OnPaint) EVT_SCROLLWIN (wxScintillaTextCtrl::OnScrollWin) EVT_SCROLL (wxScintillaTextCtrl::OnScroll) EVT_SIZE (wxScintillaTextCtrl::OnSize) EVT_LEFT_DOWN (wxScintillaTextCtrl::OnMouseLeftDown) // Let Scintilla see the double click as a second click EVT_LEFT_DCLICK (wxScintillaTextCtrl::OnMouseLeftDown) EVT_MOTION (wxScintillaTextCtrl::OnMouseMove) EVT_LEFT_UP (wxScintillaTextCtrl::OnMouseLeftUp) #if defined(__WXGTK__) || defined(__WXMAC__) EVT_RIGHT_UP (wxScintillaTextCtrl::OnMouseRightUp) #else EVT_CONTEXT_MENU (wxScintillaTextCtrl::OnContextMenu) #endif EVT_MOUSEWHEEL (wxScintillaTextCtrl::OnMouseWheel) EVT_MIDDLE_UP (wxScintillaTextCtrl::OnMouseMiddleUp) EVT_CHAR (wxScintillaTextCtrl::OnChar) EVT_KEY_DOWN (wxScintillaTextCtrl::OnKeyDown) EVT_KILL_FOCUS (wxScintillaTextCtrl::OnLoseFocus) EVT_SET_FOCUS (wxScintillaTextCtrl::OnGainFocus) EVT_SYS_COLOUR_CHANGED (wxScintillaTextCtrl::OnSysColourChanged) EVT_ERASE_BACKGROUND (wxScintillaTextCtrl::OnEraseBackground) EVT_MENU_RANGE (10, 16, wxScintillaTextCtrl::OnMenu) EVT_LISTBOX_DCLICK (wxID_ANY, wxScintillaTextCtrl::OnListBox) END_EVENT_TABLE() IMPLEMENT_CLASS(wxScintillaTextCtrl, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxScintillaTextEvent, wxCommandEvent) #ifdef LINK_LEXERS // forces the linking of the lexer modules int Scintilla_LinkLexers(); #endif //---------------------------------------------------------------------- // Constructor and Destructor wxScintillaTextCtrl::wxScintillaTextCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { m_swx = NULL; Create(parent, id, pos, size, style, name); } bool wxScintillaTextCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { style |= wxVSCROLL | wxHSCROLL; if (!wxControl::Create(parent, id, pos, size, style | wxWANTS_CHARS | wxCLIP_CHILDREN, wxDefaultValidator, name)) return false; #ifdef LINK_LEXERS Scintilla_LinkLexers(); #endif m_swx = new ScintillaWX(this); m_stopWatch.Start(); m_lastKeyDownConsumed = false; m_lastWheelTimestamp = 0; m_vScrollBar = NULL; m_hScrollBar = NULL; #if wxUSE_UNICODE // Put Scintilla into unicode (UTF-8) mode SetCodePage(wxSTC_CP_UTF8); #endif SetInitialSize(size); // Reduces flicker on GTK+/X11 SetBackgroundStyle(wxBG_STYLE_CUSTOM); return true; } wxScintillaTextCtrl::~wxScintillaTextCtrl() { delete m_swx; } //---------------------------------------------------------------------- wxIntPtr wxScintillaTextCtrl::SendMsg(int msg, wxUIntPtr wp, wxIntPtr lp) { return m_swx->WndProc(msg, wp, lp); } //---------------------------------------------------------------------- // Set the vertical scrollbar to use instead of the ont that's built-in. void wxScintillaTextCtrl::SetVScrollBar(wxScrollBar* bar) { m_vScrollBar = bar; if (bar != NULL) { // ensure that the built-in scrollbar is not visible SetScrollbar(wxVERTICAL, 0, 0, 0); } } // Set the horizontal scrollbar to use instead of the ont that's built-in. void wxScintillaTextCtrl::SetHScrollBar(wxScrollBar* bar) { m_hScrollBar = bar; if (bar != NULL) { // ensure that the built-in scrollbar is not visible SetScrollbar(wxHORIZONTAL, 0, 0, 0); } } //---------------------------------------------------------------------- // Generated methods implementation section {{{ // Add text to the document at current position. void wxScintillaTextCtrl::AddText(const wxString& text) { wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); SendMsg(2001, strlen(buf), (sptr_t)(const char*)buf); } // Add array of cells to document. void wxScintillaTextCtrl::AddStyledText(const wxMemoryBuffer& data) { SendMsg(2002, data.GetDataLen(), (sptr_t)data.GetData()); } // Insert string at a position. void wxScintillaTextCtrl::InsertText(int pos, const wxString& text) { SendMsg(2003, pos, (sptr_t)(const char*)wx2stc(text)); } // Delete all text in the document. void wxScintillaTextCtrl::ClearAll() { SendMsg(2004, 0, 0); } // Set all style bytes to 0, remove all folding information. void wxScintillaTextCtrl::ClearDocumentStyle() { SendMsg(2005, 0, 0); } // Returns the number of bytes in the document. int wxScintillaTextCtrl::GetLength() { return SendMsg(2006, 0, 0); } // Returns the character byte at the position. int wxScintillaTextCtrl::GetCharAt(int pos) { return (unsigned char)SendMsg(2007, pos, 0); } // Returns the position of the caret. int wxScintillaTextCtrl::GetCurrentPos() { return SendMsg(2008, 0, 0); } // Returns the position of the opposite end of the selection to the caret. int wxScintillaTextCtrl::GetAnchor() { return SendMsg(2009, 0, 0); } // Returns the style byte at the position. int wxScintillaTextCtrl::GetStyleAt(int pos) { return (unsigned char)SendMsg(2010, pos, 0); } // Redoes the next action on the undo history. void wxScintillaTextCtrl::Redo() { SendMsg(2011, 0, 0); } // Choose between collecting actions into the undo // history and discarding them. void wxScintillaTextCtrl::SetUndoCollection(bool collectUndo) { SendMsg(2012, collectUndo, 0); } // Select all the text in the document. void wxScintillaTextCtrl::SelectAll() { SendMsg(2013, 0, 0); } // Remember the current position in the undo history as the position // at which the document was saved. void wxScintillaTextCtrl::SetSavePoint() { SendMsg(2014, 0, 0); } // Retrieve a buffer of cells. wxMemoryBuffer wxScintillaTextCtrl::GetStyledText(int startPos, int endPos) { wxMemoryBuffer buf; if (endPos < startPos) { int temp = startPos; startPos = endPos; endPos = temp; } int len = endPos - startPos; if (!len) return buf; TextRange tr; tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1); tr.chrg.cpMin = startPos; tr.chrg.cpMax = endPos; len = SendMsg(2015, 0, (sptr_t)&tr); buf.UngetWriteBuf(len); return buf; } // Are there any redoable actions in the undo history? bool wxScintillaTextCtrl::CanRedo() { return SendMsg(2016, 0, 0) != 0; } // Retrieve the line number at which a particular marker is located. int wxScintillaTextCtrl::MarkerLineFromHandle(int handle) { return SendMsg(2017, handle, 0); } // Delete a marker. void wxScintillaTextCtrl::MarkerDeleteHandle(int handle) { SendMsg(2018, handle, 0); } // Is undo history being collected? bool wxScintillaTextCtrl::GetUndoCollection() { return SendMsg(2019, 0, 0) != 0; } // Are white space characters currently visible? // Returns one of SCWS_* constants. int wxScintillaTextCtrl::GetViewWhiteSpace() { return SendMsg(2020, 0, 0); } // Make white space characters invisible, always visible or visible outside indentation. void wxScintillaTextCtrl::SetViewWhiteSpace(int viewWS) { SendMsg(2021, viewWS, 0); } // Find the position from a point within the window. int wxScintillaTextCtrl::PositionFromPoint(wxPoint pt) { return SendMsg(2022, pt.x, pt.y); } // Find the position from a point within the window but return // INVALID_POSITION if not close to text. int wxScintillaTextCtrl::PositionFromPointClose(int x, int y) { return SendMsg(2023, x, y); } // Set caret to start of a line and ensure it is visible. void wxScintillaTextCtrl::GotoLine(int line) { SendMsg(2024, line, 0); } // Set caret to a position and ensure it is visible. void wxScintillaTextCtrl::GotoPos(int pos) { SendMsg(2025, pos, 0); } // Set the selection anchor to a position. The anchor is the opposite // end of the selection from the caret. void wxScintillaTextCtrl::SetAnchor(int posAnchor) { SendMsg(2026, posAnchor, 0); } // Retrieve the text of the line containing the caret. // Returns the index of the caret on the line. wxString wxScintillaTextCtrl::GetCurLine(int* linePos) { int len = LineLength(GetCurrentLine()); if (!len) { if (linePos) *linePos = 0; return wxEmptyString; } wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len+1); int pos = SendMsg(2027, len+1, (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); if (linePos) *linePos = pos; return stc2wx(buf); } // Retrieve the position of the last correctly styled character. int wxScintillaTextCtrl::GetEndStyled() { return SendMsg(2028, 0, 0); } // Convert all line endings in the document to one mode. void wxScintillaTextCtrl::ConvertEOLs(int eolMode) { SendMsg(2029, eolMode, 0); } // Retrieve the current end of line mode - one of CRLF, CR, or LF. int wxScintillaTextCtrl::GetEOLMode() { return SendMsg(2030, 0, 0); } // Set the current end of line mode. void wxScintillaTextCtrl::SetEOLMode(int eolMode) { SendMsg(2031, eolMode, 0); } // Set the current styling position to pos and the styling mask to mask. // The styling mask can be used to protect some bits in each styling byte from modification. void wxScintillaTextCtrl::StartStyling(int pos, int mask) { SendMsg(2032, pos, mask); } // Change style from current styling position for length characters to a style // and move the current styling position to after this newly styled segment. void wxScintillaTextCtrl::SetStyling(int length, int style) { SendMsg(2033, length, style); } // Is drawing done first into a buffer or direct to the screen? bool wxScintillaTextCtrl::GetBufferedDraw() { return SendMsg(2034, 0, 0) != 0; } // If drawing is buffered then each line of text is drawn into a bitmap buffer // before drawing it to the screen to avoid flicker. void wxScintillaTextCtrl::SetBufferedDraw(bool buffered) { SendMsg(2035, buffered, 0); } // Change the visible size of a tab to be a multiple of the width of a space character. void wxScintillaTextCtrl::SetTabWidth(int tabWidth) { SendMsg(2036, tabWidth, 0); } // Retrieve the visible size of a tab. int wxScintillaTextCtrl::GetTabWidth() { return SendMsg(2121, 0, 0); } // Set the code page used to interpret the bytes of the document as characters. void wxScintillaTextCtrl::SetCodePage(int codePage) { #if wxUSE_UNICODE wxASSERT_MSG(codePage == wxSTC_CP_UTF8, wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on.")); #else wxASSERT_MSG(codePage != wxSTC_CP_UTF8, wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off.")); #endif SendMsg(2037, codePage); } // Set the symbol used for a particular marker number, // and optionally the fore and background colours. void wxScintillaTextCtrl::MarkerDefine(int markerNumber, int markerSymbol, const wxColour& foreground, const wxColour& background) { SendMsg(2040, markerNumber, markerSymbol); if (foreground.Ok()) MarkerSetForeground(markerNumber, foreground); if (background.Ok()) MarkerSetBackground(markerNumber, background); } // Set the foreground colour used for a particular marker number. void wxScintillaTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore) { SendMsg(2041, markerNumber, wxColourAsLong(fore)); } // Set the background colour used for a particular marker number. void wxScintillaTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back) { SendMsg(2042, markerNumber, wxColourAsLong(back)); } // Add a marker to a line, returning an ID which can be used to find or delete the marker. int wxScintillaTextCtrl::MarkerAdd(int line, int markerNumber) { return SendMsg(2043, line, markerNumber); } // Delete a marker from a line. void wxScintillaTextCtrl::MarkerDelete(int line, int markerNumber) { SendMsg(2044, line, markerNumber); } // Delete all markers with a particular number from all lines. void wxScintillaTextCtrl::MarkerDeleteAll(int markerNumber) { SendMsg(2045, markerNumber, 0); } // Get a bit mask of all the markers set on a line. int wxScintillaTextCtrl::MarkerGet(int line) { return SendMsg(2046, line, 0); } // Find the next line after lineStart that includes a marker in mask. int wxScintillaTextCtrl::MarkerNext(int lineStart, int markerMask) { return SendMsg(2047, lineStart, markerMask); } // Find the previous line before lineStart that includes a marker in mask. int wxScintillaTextCtrl::MarkerPrevious(int lineStart, int markerMask) { return SendMsg(2048, lineStart, markerMask); } // Define a marker from a bitmap void wxScintillaTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp) { // convert bmp to a xpm in a string wxMemoryOutputStream strm; wxImage img = bmp.ConvertToImage(); if (img.HasAlpha()) img.ConvertAlphaToMask(); img.SaveFile(strm, wxBITMAP_TYPE_XPM); size_t len = strm.GetSize(); char* buff = new char[len+1]; strm.CopyTo(buff, len); buff[len] = 0; SendMsg(2049, markerNumber, (sptr_t)buff); delete [] buff; } // Add a set of markers to a line. void wxScintillaTextCtrl::MarkerAddSet(int line, int set) { SendMsg(2466, line, set); } // Set the alpha used for a marker that is drawn in the text area, not the margin. void wxScintillaTextCtrl::MarkerSetAlpha(int markerNumber, int alpha) { SendMsg(2476, markerNumber, alpha); } // Set a margin to be either numeric or symbolic. void wxScintillaTextCtrl::SetMarginType(int margin, int marginType) { SendMsg(2240, margin, marginType); } // Retrieve the type of a margin. int wxScintillaTextCtrl::GetMarginType(int margin) { return SendMsg(2241, margin, 0); } // Set the width of a margin to a width expressed in pixels. void wxScintillaTextCtrl::SetMarginWidth(int margin, int pixelWidth) { SendMsg(2242, margin, pixelWidth); } // Retrieve the width of a margin in pixels. int wxScintillaTextCtrl::GetMarginWidth(int margin) { return SendMsg(2243, margin, 0); } // Set a mask that determines which markers are displayed in a margin. void wxScintillaTextCtrl::SetMarginMask(int margin, int mask) { SendMsg(2244, margin, mask); } // Retrieve the marker mask of a margin. int wxScintillaTextCtrl::GetMarginMask(int margin) { return SendMsg(2245, margin, 0); } // Make a margin sensitive or insensitive to mouse clicks. void wxScintillaTextCtrl::SetMarginSensitive(int margin, bool sensitive) { SendMsg(2246, margin, sensitive); } // Retrieve the mouse click sensitivity of a margin. bool wxScintillaTextCtrl::GetMarginSensitive(int margin) { return SendMsg(2247, margin, 0) != 0; } // Clear all the styles and make equivalent to the global default style. void wxScintillaTextCtrl::StyleClearAll() { SendMsg(2050, 0, 0); } // Set the foreground colour of a style. void wxScintillaTextCtrl::StyleSetForeground(int style, const wxColour& fore) { SendMsg(2051, style, wxColourAsLong(fore)); } // Set the background colour of a style. void wxScintillaTextCtrl::StyleSetBackground(int style, const wxColour& back) { SendMsg(2052, style, wxColourAsLong(back)); } // Set a style to be bold or not. void wxScintillaTextCtrl::StyleSetBold(int style, bool bold) { SendMsg(2053, style, bold); } // Set a style to be italic or not. void wxScintillaTextCtrl::StyleSetItalic(int style, bool italic) { SendMsg(2054, style, italic); } // Set the size of characters of a style. void wxScintillaTextCtrl::StyleSetSize(int style, int sizePoints) { SendMsg(2055, style, sizePoints); } // Set the font of a style. void wxScintillaTextCtrl::StyleSetFaceName(int style, const wxString& fontName) { SendMsg(2056, style, (sptr_t)(const char*)wx2stc(fontName)); } // Set a style to have its end of line filled or not. void wxScintillaTextCtrl::StyleSetEOLFilled(int style, bool filled) { SendMsg(2057, style, filled); } // Reset the default style to its state at startup void wxScintillaTextCtrl::StyleResetDefault() { SendMsg(2058, 0, 0); } // Set a style to be underlined or not. void wxScintillaTextCtrl::StyleSetUnderline(int style, bool underline) { SendMsg(2059, style, underline); } // Get the foreground colour of a style. wxColour wxScintillaTextCtrl::StyleGetForeground(int style) { long c = SendMsg(2481, style, 0); return wxColourFromLong(c); } // Get the background colour of a style. wxColour wxScintillaTextCtrl::StyleGetBackground(int style) { long c = SendMsg(2482, style, 0); return wxColourFromLong(c); } // Get is a style bold or not. bool wxScintillaTextCtrl::StyleGetBold(int style) { return SendMsg(2483, style, 0) != 0; } // Get is a style italic or not. bool wxScintillaTextCtrl::StyleGetItalic(int style) { return SendMsg(2484, style, 0) != 0; } // Get the size of characters of a style. int wxScintillaTextCtrl::StyleGetSize(int style) { return SendMsg(2485, style, 0); } // Get the font facename of a style wxString wxScintillaTextCtrl::StyleGetFaceName(int style) { long msg = 2486; long len = SendMsg(msg, style, 0); wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len+1); SendMsg(msg, style, (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); } // Get is a style to have its end of line filled or not. bool wxScintillaTextCtrl::StyleGetEOLFilled(int style) { return SendMsg(2487, style, 0) != 0; } // Get is a style underlined or not. bool wxScintillaTextCtrl::StyleGetUnderline(int style) { return SendMsg(2488, style, 0) != 0; } // Get is a style mixed case, or to force upper or lower case. int wxScintillaTextCtrl::StyleGetCase(int style) { return SendMsg(2489, style, 0); } // Get the character set of the font in a style. int wxScintillaTextCtrl::StyleGetCharacterSet(int style) { return SendMsg(2490, style, 0); } // Get is a style visible or not. bool wxScintillaTextCtrl::StyleGetVisible(int style) { return SendMsg(2491, style, 0) != 0; } // Get is a style changeable or not (read only). // Experimental feature, currently buggy. bool wxScintillaTextCtrl::StyleGetChangeable(int style) { return SendMsg(2492, style, 0) != 0; } // Get is a style a hotspot or not. bool wxScintillaTextCtrl::StyleGetHotSpot(int style) { return SendMsg(2493, style, 0) != 0; } // Set a style to be mixed case, or to force upper or lower case. void wxScintillaTextCtrl::StyleSetCase(int style, int caseForce) { SendMsg(2060, style, caseForce); } // Set a style to be a hotspot or not. void wxScintillaTextCtrl::StyleSetHotSpot(int style, bool hotspot) { SendMsg(2409, style, hotspot); } // Set the foreground colour of the main and additional selections and whether to use this setting. void wxScintillaTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) { SendMsg(2067, useSetting, wxColourAsLong(fore)); } // Set the background colour of the main and additional selections and whether to use this setting. void wxScintillaTextCtrl::SetSelBackground(bool useSetting, const wxColour& back) { SendMsg(2068, useSetting, wxColourAsLong(back)); } // Get the alpha of the selection. int wxScintillaTextCtrl::GetSelAlpha() { return SendMsg(2477, 0, 0); } // Set the alpha of the selection. void wxScintillaTextCtrl::SetSelAlpha(int alpha) { SendMsg(2478, alpha, 0); } // Is the selection end of line filled? bool wxScintillaTextCtrl::GetSelEOLFilled() { return SendMsg(2479, 0, 0) != 0; } // Set the selection to have its end of line filled or not. void wxScintillaTextCtrl::SetSelEOLFilled(bool filled) { SendMsg(2480, filled, 0); } // Set the foreground colour of the caret. void wxScintillaTextCtrl::SetCaretForeground(const wxColour& fore) { SendMsg(2069, wxColourAsLong(fore), 0); } // When key+modifier combination km is pressed perform msg. void wxScintillaTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) { SendMsg(2070, MAKELONG(key, modifiers), cmd); } // When key+modifier combination km is pressed do nothing. void wxScintillaTextCtrl::CmdKeyClear(int key, int modifiers) { SendMsg(2071, MAKELONG(key, modifiers)); } // Drop all key mappings. void wxScintillaTextCtrl::CmdKeyClearAll() { SendMsg(2072, 0, 0); } // Set the styles for a segment of the document. void wxScintillaTextCtrl::SetStyleBytes(int length, char* styleBytes) { SendMsg(2073, length, (sptr_t)styleBytes); } // Set a style to be visible or not. void wxScintillaTextCtrl::StyleSetVisible(int style, bool visible) { SendMsg(2074, style, visible); } // Get the time in milliseconds that the caret is on and off. int wxScintillaTextCtrl::GetCaretPeriod() { return SendMsg(2075, 0, 0); } // Get the time in milliseconds that the caret is on and off. 0 = steady on. void wxScintillaTextCtrl::SetCaretPeriod(int periodMilliseconds) { SendMsg(2076, periodMilliseconds, 0); } // Set the set of characters making up words for when moving or selecting by word. // First sets defaults like SetCharsDefault. void wxScintillaTextCtrl::SetWordChars(const wxString& characters) { SendMsg(2077, 0, (sptr_t)(const char*)wx2stc(characters)); } // Start a sequence of actions that is undone and redone as a unit. // May be nested. void wxScintillaTextCtrl::BeginUndoAction() { SendMsg(2078, 0, 0); } // End a sequence of actions that is undone and redone as a unit. void wxScintillaTextCtrl::EndUndoAction() { SendMsg(2079, 0, 0); } // Set an indicator to plain, squiggle or TT. void wxScintillaTextCtrl::IndicatorSetStyle(int indic, int style) { SendMsg(2080, indic, style); } // Retrieve the style of an indicator. int wxScintillaTextCtrl::IndicatorGetStyle(int indic) { return SendMsg(2081, indic, 0); } // Set the foreground colour of an indicator. void wxScintillaTextCtrl::IndicatorSetForeground(int indic, const wxColour& fore) { SendMsg(2082, indic, wxColourAsLong(fore)); } // Retrieve the foreground colour of an indicator. wxColour wxScintillaTextCtrl::IndicatorGetForeground(int indic) { long c = SendMsg(2083, indic, 0); return wxColourFromLong(c); } // Set an indicator to draw under text or over(default). void wxScintillaTextCtrl::IndicatorSetUnder(int indic, bool under) { SendMsg(2510, indic, under); } // Retrieve whether indicator drawn under or over text. bool wxScintillaTextCtrl::IndicatorGetUnder(int indic) { return SendMsg(2511, indic, 0) != 0; } // Set the foreground colour of all whitespace and whether to use this setting. void wxScintillaTextCtrl::SetWhitespaceForeground(bool useSetting, const wxColour& fore) { SendMsg(2084, useSetting, wxColourAsLong(fore)); } // Set the background colour of all whitespace and whether to use this setting. void wxScintillaTextCtrl::SetWhitespaceBackground(bool useSetting, const wxColour& back) { SendMsg(2085, useSetting, wxColourAsLong(back)); } // Set the size of the dots used to mark space characters. void wxScintillaTextCtrl::SetWhitespaceSize(int size) { SendMsg(2086, size, 0); } // Get the size of the dots used to mark space characters. int wxScintillaTextCtrl::GetWhitespaceSize() { return SendMsg(2087, 0, 0); } // Divide each styling byte into lexical class bits (default: 5) and indicator // bits (default: 3). If a lexer requires more than 32 lexical states, then this // is used to expand the possible states. void wxScintillaTextCtrl::SetStyleBits(int bits) { SendMsg(2090, bits, 0); } // Retrieve number of bits in style bytes used to hold the lexical state. int wxScintillaTextCtrl::GetStyleBits() { return SendMsg(2091, 0, 0); } // Used to hold extra styling information for each line. void wxScintillaTextCtrl::SetLineState(int line, int state) { SendMsg(2092, line, state); } // Retrieve the extra styling information for a line. int wxScintillaTextCtrl::GetLineState(int line) { return SendMsg(2093, line, 0); } // Retrieve the last line number that has line state. int wxScintillaTextCtrl::GetMaxLineState() { return SendMsg(2094, 0, 0); } // Is the background of the line containing the caret in a different colour? bool wxScintillaTextCtrl::GetCaretLineVisible() { return SendMsg(2095, 0, 0) != 0; } // Display the background of the line containing the caret in a different colour. void wxScintillaTextCtrl::SetCaretLineVisible(bool show) { SendMsg(2096, show, 0); } // Get the colour of the background of the line containing the caret. wxColour wxScintillaTextCtrl::GetCaretLineBackground() { long c = SendMsg(2097, 0, 0); return wxColourFromLong(c); } // Set the colour of the background of the line containing the caret. void wxScintillaTextCtrl::SetCaretLineBackground(const wxColour& back) { SendMsg(2098, wxColourAsLong(back), 0); } // Set a style to be changeable or not (read only). // Experimental feature, currently buggy. void wxScintillaTextCtrl::StyleSetChangeable(int style, bool changeable) { SendMsg(2099, style, changeable); } // Display a auto-completion list. // The lenEntered parameter indicates how many characters before // the caret should be used to provide context. void wxScintillaTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) { SendMsg(2100, lenEntered, (sptr_t)(const char*)wx2stc(itemList)); } // Remove the auto-completion list from the screen. void wxScintillaTextCtrl::AutoCompCancel() { SendMsg(2101, 0, 0); } // Is there an auto-completion list visible? bool wxScintillaTextCtrl::AutoCompActive() { return SendMsg(2102, 0, 0) != 0; } // Retrieve the position of the caret when the auto-completion list was displayed. int wxScintillaTextCtrl::AutoCompPosStart() { return SendMsg(2103, 0, 0); } // User has selected an item so remove the list and insert the selection. void wxScintillaTextCtrl::AutoCompComplete() { SendMsg(2104, 0, 0); } // Define a set of character that when typed cancel the auto-completion list. void wxScintillaTextCtrl::AutoCompStops(const wxString& characterSet) { SendMsg(2105, 0, (sptr_t)(const char*)wx2stc(characterSet)); } // Change the separator character in the string setting up an auto-completion list. // Default is space but can be changed if items contain space. void wxScintillaTextCtrl::AutoCompSetSeparator(int separatorCharacter) { SendMsg(2106, separatorCharacter, 0); } // Retrieve the auto-completion list separator character. int wxScintillaTextCtrl::AutoCompGetSeparator() { return SendMsg(2107, 0, 0); } // Select the item in the auto-completion list that starts with a string. void wxScintillaTextCtrl::AutoCompSelect(const wxString& text) { SendMsg(2108, 0, (sptr_t)(const char*)wx2stc(text)); } // Should the auto-completion list be cancelled if the user backspaces to a // position before where the box was created. void wxScintillaTextCtrl::AutoCompSetCancelAtStart(bool cancel) { SendMsg(2110, cancel, 0); } // Retrieve whether auto-completion cancelled by backspacing before start. bool wxScintillaTextCtrl::AutoCompGetCancelAtStart() { return SendMsg(2111, 0, 0) != 0; } // Define a set of characters that when typed will cause the autocompletion to // choose the selected item. void wxScintillaTextCtrl::AutoCompSetFillUps(const wxString& characterSet) { SendMsg(2112, 0, (sptr_t)(const char*)wx2stc(characterSet)); } // Should a single item auto-completion list automatically choose the item. void wxScintillaTextCtrl::AutoCompSetChooseSingle(bool chooseSingle) { SendMsg(2113, chooseSingle, 0); } // Retrieve whether a single item auto-completion list automatically choose the item. bool wxScintillaTextCtrl::AutoCompGetChooseSingle() { return SendMsg(2114, 0, 0) != 0; } // Set whether case is significant when performing auto-completion searches. void wxScintillaTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase) { SendMsg(2115, ignoreCase, 0); } // Retrieve state of ignore case flag. bool wxScintillaTextCtrl::AutoCompGetIgnoreCase() { return SendMsg(2116, 0, 0) != 0; } // Display a list of strings and send notification when user chooses one. void wxScintillaTextCtrl::UserListShow(int listType, const wxString& itemList) { SendMsg(2117, listType, (sptr_t)(const char*)wx2stc(itemList)); } // Set whether or not autocompletion is hidden automatically when nothing matches. void wxScintillaTextCtrl::AutoCompSetAutoHide(bool autoHide) { SendMsg(2118, autoHide, 0); } // Retrieve whether or not autocompletion is hidden automatically when nothing matches. bool wxScintillaTextCtrl::AutoCompGetAutoHide() { return SendMsg(2119, 0, 0) != 0; } // Set whether or not autocompletion deletes any word characters // after the inserted text upon completion. void wxScintillaTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord) { SendMsg(2270, dropRestOfWord, 0); } // Retrieve whether or not autocompletion deletes any word characters // after the inserted text upon completion. bool wxScintillaTextCtrl::AutoCompGetDropRestOfWord() { return SendMsg(2271, 0, 0) != 0; } // Register an image for use in autocompletion lists. void wxScintillaTextCtrl::RegisterImage(int type, const wxBitmap& bmp) { // convert bmp to a xpm in a string wxMemoryOutputStream strm; wxImage img = bmp.ConvertToImage(); if (img.HasAlpha()) img.ConvertAlphaToMask(); img.SaveFile(strm, wxBITMAP_TYPE_XPM); size_t len = strm.GetSize(); char* buff = new char[len+1]; strm.CopyTo(buff, len); buff[len] = 0; SendMsg(2405, type, (sptr_t)buff); delete [] buff; } // Clear all the registered images. void wxScintillaTextCtrl::ClearRegisteredImages() { SendMsg(2408, 0, 0); } // Retrieve the auto-completion list type-separator character. int wxScintillaTextCtrl::AutoCompGetTypeSeparator() { return SendMsg(2285, 0, 0); } // Change the type-separator character in the string setting up an auto-completion list. // Default is '?' but can be changed if items contain '?'. void wxScintillaTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter) { SendMsg(2286, separatorCharacter, 0); } // Set the maximum width, in characters, of auto-completion and user lists. // Set to 0 to autosize to fit longest item, which is the default. void wxScintillaTextCtrl::AutoCompSetMaxWidth(int characterCount) { SendMsg(2208, characterCount, 0); } // Get the maximum width, in characters, of auto-completion and user lists. int wxScintillaTextCtrl::AutoCompGetMaxWidth() { return SendMsg(2209, 0, 0); } // Set the maximum height, in rows, of auto-completion and user lists. // The default is 5 rows. void wxScintillaTextCtrl::AutoCompSetMaxHeight(int rowCount) { SendMsg(2210, rowCount, 0); } // Set the maximum height, in rows, of auto-completion and user lists. int wxScintillaTextCtrl::AutoCompGetMaxHeight() { return SendMsg(2211, 0, 0); } // Set the number of spaces used for one level of indentation. void wxScintillaTextCtrl::SetIndent(int indentSize) { SendMsg(2122, indentSize, 0); } // Retrieve indentation size. int wxScintillaTextCtrl::GetIndent() { return SendMsg(2123, 0, 0); } // Indentation will only use space characters if useTabs is false, otherwise // it will use a combination of tabs and spaces. void wxScintillaTextCtrl::SetUseTabs(bool useTabs) { SendMsg(2124, useTabs, 0); } // Retrieve whether tabs will be used in indentation. bool wxScintillaTextCtrl::GetUseTabs() { return SendMsg(2125, 0, 0) != 0; } // Change the indentation of a line to a number of columns. void wxScintillaTextCtrl::SetLineIndentation(int line, int indentSize) { SendMsg(2126, line, indentSize); } // Retrieve the number of columns that a line is indented. int wxScintillaTextCtrl::GetLineIndentation(int line) { return SendMsg(2127, line, 0); } // Retrieve the position before the first non indentation character on a line. int wxScintillaTextCtrl::GetLineIndentPosition(int line) { return SendMsg(2128, line, 0); } // Retrieve the column number of a position, taking tab width into account. int wxScintillaTextCtrl::GetColumn(int pos) { return SendMsg(2129, pos, 0); } // Show or hide the horizontal scroll bar. void wxScintillaTextCtrl::SetUseHorizontalScrollBar(bool show) { SendMsg(2130, show, 0); } // Is the horizontal scroll bar visible? bool wxScintillaTextCtrl::GetUseHorizontalScrollBar() { return SendMsg(2131, 0, 0) != 0; } // Show or hide indentation guides. void wxScintillaTextCtrl::SetIndentationGuides(int indentView) { SendMsg(2132, indentView, 0); } // Are the indentation guides visible? int wxScintillaTextCtrl::GetIndentationGuides() { return SendMsg(2133, 0, 0); } // Set the highlighted indentation guide column. // 0 = no highlighted guide. void wxScintillaTextCtrl::SetHighlightGuide(int column) { SendMsg(2134, column, 0); } // Get the highlighted indentation guide column. int wxScintillaTextCtrl::GetHighlightGuide() { return SendMsg(2135, 0, 0); } // Get the position after the last visible characters on a line. int wxScintillaTextCtrl::GetLineEndPosition(int line) { return SendMsg(2136, line, 0); } // Get the code page used to interpret the bytes of the document as characters. int wxScintillaTextCtrl::GetCodePage() { return SendMsg(2137, 0, 0); } // Get the foreground colour of the caret. wxColour wxScintillaTextCtrl::GetCaretForeground() { long c = SendMsg(2138, 0, 0); return wxColourFromLong(c); } // In read-only mode? bool wxScintillaTextCtrl::GetReadOnly() { return SendMsg(2140, 0, 0) != 0; } // Sets the position of the caret. void wxScintillaTextCtrl::SetCurrentPos(int pos) { SendMsg(2141, pos, 0); } // Sets the position that starts the selection - this becomes the anchor. void wxScintillaTextCtrl::SetSelectionStart(int pos) { SendMsg(2142, pos, 0); } // Returns the position at the start of the selection. int wxScintillaTextCtrl::GetSelectionStart() { return SendMsg(2143, 0, 0); } // Sets the position that ends the selection - this becomes the currentPosition. void wxScintillaTextCtrl::SetSelectionEnd(int pos) { SendMsg(2144, pos, 0); } // Returns the position at the end of the selection. int wxScintillaTextCtrl::GetSelectionEnd() { return SendMsg(2145, 0, 0); } // Sets the print magnification added to the point size of each style for printing. void wxScintillaTextCtrl::SetPrintMagnification(int magnification) { SendMsg(2146, magnification, 0); } // Returns the print magnification. int wxScintillaTextCtrl::GetPrintMagnification() { return SendMsg(2147, 0, 0); } // Modify colours when printing for clearer printed text. void wxScintillaTextCtrl::SetPrintColourMode(int mode) { SendMsg(2148, mode, 0); } // Returns the print colour mode. int wxScintillaTextCtrl::GetPrintColourMode() { return SendMsg(2149, 0, 0); } // Find some text in the document. int wxScintillaTextCtrl::FindText(int minPos, int maxPos, const wxString& text, int flags) { TextToFind ft; ft.chrg.cpMin = minPos; ft.chrg.cpMax = maxPos; wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); ft.lpstrText = (char*)(const char*)buf; return SendMsg(2150, flags, (sptr_t)&ft); } // On Windows, will draw the document into a display context such as a printer. int wxScintillaTextCtrl::FormatRange(bool doDraw, int startPos, int endPos, wxDC* draw, wxDC* target, wxRect renderRect, wxRect pageRect) { RangeToFormat fr; if (endPos < startPos) { int temp = startPos; startPos = endPos; endPos = temp; } fr.hdc = draw; fr.hdcTarget = target; fr.rc.top = renderRect.GetTop(); fr.rc.left = renderRect.GetLeft(); fr.rc.right = renderRect.GetRight(); fr.rc.bottom = renderRect.GetBottom(); fr.rcPage.top = pageRect.GetTop(); fr.rcPage.left = pageRect.GetLeft(); fr.rcPage.right = pageRect.GetRight(); fr.rcPage.bottom = pageRect.GetBottom(); fr.chrg.cpMin = startPos; fr.chrg.cpMax = endPos; return SendMsg(2151, doDraw, (sptr_t)&fr); } // Retrieve the display line at the top of the display. int wxScintillaTextCtrl::GetFirstVisibleLine() { return SendMsg(2152, 0, 0); } // Retrieve the contents of a line. wxString wxScintillaTextCtrl::GetLine(int line) { int len = LineLength(line); if (!len) return wxEmptyString; wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len+1); SendMsg(2153, line, (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); } // Returns the number of lines in the document. There is always at least one. int wxScintillaTextCtrl::GetLineCount() { return SendMsg(2154, 0, 0); } // Sets the size in pixels of the left margin. void wxScintillaTextCtrl::SetMarginLeft(int pixelWidth) { SendMsg(2155, 0, pixelWidth); } // Returns the size in pixels of the left margin. int wxScintillaTextCtrl::GetMarginLeft() { return SendMsg(2156, 0, 0); } // Sets the size in pixels of the right margin. void wxScintillaTextCtrl::SetMarginRight(int pixelWidth) { SendMsg(2157, 0, pixelWidth); } // Returns the size in pixels of the right margin. int wxScintillaTextCtrl::GetMarginRight() { return SendMsg(2158, 0, 0); } // Is the document different from when it was last saved? bool wxScintillaTextCtrl::GetModify() { return SendMsg(2159, 0, 0) != 0; } // Retrieve the selected text. wxString wxScintillaTextCtrl::GetSelectedText() { long start; long end; GetSelection(&start, &end); int len = end - start; if (!len) return wxEmptyString; wxMemoryBuffer mbuf(len+2); char* buf = (char*)mbuf.GetWriteBuf(len+1); SendMsg(2161, 0, (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); } // Retrieve a range of text. wxString wxScintillaTextCtrl::GetTextRange(int startPos, int endPos) { if (endPos < startPos) { int temp = startPos; startPos = endPos; endPos = temp; } int len = endPos - startPos; if (!len) return wxEmptyString; wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len); TextRange tr; tr.lpstrText = buf; tr.chrg.cpMin = startPos; tr.chrg.cpMax = endPos; SendMsg(2162, 0, (sptr_t)&tr); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); } // Draw the selection in normal style or with selection highlighted. void wxScintillaTextCtrl::HideSelection(bool normal) { SendMsg(2163, normal, 0); } // Retrieve the line containing a position. int wxScintillaTextCtrl::LineFromPosition(int pos) { return SendMsg(2166, pos, 0); } // Retrieve the position at the start of a line. int wxScintillaTextCtrl::PositionFromLine(int line) { return SendMsg(2167, line, 0); } // Scroll horizontally and vertically. void wxScintillaTextCtrl::LineScroll(int columns, int lines) { SendMsg(2168, columns, lines); } // Ensure the caret is visible. void wxScintillaTextCtrl::EnsureCaretVisible() { SendMsg(2169, 0, 0); } // Replace the selected text with the argument text. void wxScintillaTextCtrl::ReplaceSelection(const wxString& text) { SendMsg(2170, 0, (sptr_t)(const char*)wx2stc(text)); } // Set to read only or read write. void wxScintillaTextCtrl::SetReadOnly(bool readOnly) { SendMsg(2171, readOnly, 0); } // Will a paste succeed? bool wxScintillaTextCtrl::CanPaste() { return SendMsg(2173, 0, 0) != 0; } // Are there any undoable actions in the undo history? bool wxScintillaTextCtrl::CanUndo() { return SendMsg(2174, 0, 0) != 0; } // Delete the undo history. void wxScintillaTextCtrl::EmptyUndoBuffer() { SendMsg(2175, 0, 0); } // Undo one action in the undo history. void wxScintillaTextCtrl::Undo() { SendMsg(2176, 0, 0); } // Cut the selection to the clipboard. void wxScintillaTextCtrl::Cut() { SendMsg(2177, 0, 0); } // Copy the selection to the clipboard. void wxScintillaTextCtrl::Copy() { SendMsg(2178, 0, 0); } // Paste the contents of the clipboard into the document replacing the selection. void wxScintillaTextCtrl::Paste() { SendMsg(2179, 0, 0); } // Clear the selection. void wxScintillaTextCtrl::Clear() { SendMsg(2180, 0, 0); } // Replace the contents of the document with the argument text. void wxScintillaTextCtrl::SetText(const wxString& text) { SendMsg(2181, 0, (sptr_t)(const char*)wx2stc(text)); } // Retrieve all the text in the document. wxString wxScintillaTextCtrl::GetText() { int len = GetTextLength(); wxMemoryBuffer mbuf(len+1); // leave room for the null... char* buf = (char*)mbuf.GetWriteBuf(len+1); SendMsg(2182, len+1, (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); } // Retrieve the number of characters in the document. int wxScintillaTextCtrl::GetTextLength() { return SendMsg(2183, 0, 0); } // Set to overtype (true) or insert mode. void wxScintillaTextCtrl::SetOvertype(bool overtype) { SendMsg(2186, overtype, 0); } // Returns true if overtype mode is active otherwise false is returned. bool wxScintillaTextCtrl::GetOvertype() { return SendMsg(2187, 0, 0) != 0; } // Set the width of the insert mode caret. void wxScintillaTextCtrl::SetCaretWidth(int pixelWidth) { SendMsg(2188, pixelWidth, 0); } // Returns the width of the insert mode caret. int wxScintillaTextCtrl::GetCaretWidth() { return SendMsg(2189, 0, 0); } // Sets the position that starts the target which is used for updating the // document without affecting the scroll position. void wxScintillaTextCtrl::SetTargetStart(int pos) { SendMsg(2190, pos, 0); } // Get the position that starts the target. int wxScintillaTextCtrl::GetTargetStart() { return SendMsg(2191, 0, 0); } // Sets the position that ends the target which is used for updating the // document without affecting the scroll position. void wxScintillaTextCtrl::SetTargetEnd(int pos) { SendMsg(2192, pos, 0); } // Get the position that ends the target. int wxScintillaTextCtrl::GetTargetEnd() { return SendMsg(2193, 0, 0); } // Replace the target text with the argument text. // Text is counted so it can contain NULs. // Returns the length of the replacement text. int wxScintillaTextCtrl::ReplaceTarget(const wxString& text) { wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); return SendMsg(2194, strlen(buf), (sptr_t)(const char*)buf); } // Replace the target text with the argument text after \d processing. // Text is counted so it can contain NULs. // Looks for \d where d is between 1 and 9 and replaces these with the strings // matched in the last search operation which were surrounded by \( and \). // Returns the length of the replacement text including any change // caused by processing the \d patterns. int wxScintillaTextCtrl::ReplaceTargetRE(const wxString& text) { wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); return SendMsg(2195, strlen(buf), (sptr_t)(const char*)buf); } // Search for a counted string in the target and set the target to the found // range. Text is counted so it can contain NULs. // Returns length of range or -1 for failure in which case target is not moved. int wxScintillaTextCtrl::SearchInTarget(const wxString& text) { wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); return SendMsg(2197, strlen(buf), (sptr_t)(const char*)buf); } // Set the search flags used by SearchInTarget. void wxScintillaTextCtrl::SetSearchFlags(int flags) { SendMsg(2198, flags, 0); } // Get the search flags used by SearchInTarget. int wxScintillaTextCtrl::GetSearchFlags() { return SendMsg(2199, 0, 0); } // Show a call tip containing a definition near position pos. void wxScintillaTextCtrl::CallTipShow(int pos, const wxString& definition) { SendMsg(2200, pos, (sptr_t)(const char*)wx2stc(definition)); } // Remove the call tip from the screen. void wxScintillaTextCtrl::CallTipCancel() { SendMsg(2201, 0, 0); } // Is there an active call tip? bool wxScintillaTextCtrl::CallTipActive() { return SendMsg(2202, 0, 0) != 0; } // Retrieve the position where the caret was before displaying the call tip. int wxScintillaTextCtrl::CallTipPosAtStart() { return SendMsg(2203, 0, 0); } // Highlight a segment of the definition. void wxScintillaTextCtrl::CallTipSetHighlight(int start, int end) { SendMsg(2204, start, end); } // Set the background colour for the call tip. void wxScintillaTextCtrl::CallTipSetBackground(const wxColour& back) { SendMsg(2205, wxColourAsLong(back), 0); } // Set the foreground colour for the call tip. void wxScintillaTextCtrl::CallTipSetForeground(const wxColour& fore) { SendMsg(2206, wxColourAsLong(fore), 0); } // Set the foreground colour for the highlighted part of the call tip. void wxScintillaTextCtrl::CallTipSetForegroundHighlight(const wxColour& fore) { SendMsg(2207, wxColourAsLong(fore), 0); } // Enable use of STYLE_CALLTIP and set call tip tab size in pixels. void wxScintillaTextCtrl::CallTipUseStyle(int tabSize) { SendMsg(2212, tabSize, 0); } // Find the display line of a document line taking hidden lines into account. int wxScintillaTextCtrl::VisibleFromDocLine(int line) { return SendMsg(2220, line, 0); } // Find the document line of a display line taking hidden lines into account. int wxScintillaTextCtrl::DocLineFromVisible(int lineDisplay) { return SendMsg(2221, lineDisplay, 0); } // The number of display lines needed to wrap a document line int wxScintillaTextCtrl::WrapCount(int line) { return SendMsg(2235, line, 0); } // Set the fold level of a line. // This encodes an integer level along with flags indicating whether the // line is a header and whether it is effectively white space. void wxScintillaTextCtrl::SetFoldLevel(int line, int level) { SendMsg(2222, line, level); } // Retrieve the fold level of a line. int wxScintillaTextCtrl::GetFoldLevel(int line) { return SendMsg(2223, line, 0); } // Find the last child line of a header line. int wxScintillaTextCtrl::GetLastChild(int line, int level) { return SendMsg(2224, line, level); } // Find the parent line of a child line. int wxScintillaTextCtrl::GetFoldParent(int line) { return SendMsg(2225, line, 0); } // Make a range of lines visible. void wxScintillaTextCtrl::ShowLines(int lineStart, int lineEnd) { SendMsg(2226, lineStart, lineEnd); } // Make a range of lines invisible. void wxScintillaTextCtrl::HideLines(int lineStart, int lineEnd) { SendMsg(2227, lineStart, lineEnd); } // Is a line visible? bool wxScintillaTextCtrl::GetLineVisible(int line) { return SendMsg(2228, line, 0) != 0; } // Show the children of a header line. void wxScintillaTextCtrl::SetFoldExpanded(int line, bool expanded) { SendMsg(2229, line, expanded); } // Is a header line expanded? bool wxScintillaTextCtrl::GetFoldExpanded(int line) { return SendMsg(2230, line, 0) != 0; } // Switch a header line between expanded and contracted. void wxScintillaTextCtrl::ToggleFold(int line) { SendMsg(2231, line, 0); } // Ensure a particular line is visible by expanding any header line hiding it. void wxScintillaTextCtrl::EnsureVisible(int line) { SendMsg(2232, line, 0); } // Set some style options for folding. void wxScintillaTextCtrl::SetFoldFlags(int flags) { SendMsg(2233, flags, 0); } // Ensure a particular line is visible by expanding any header line hiding it. // Use the currently set visibility policy to determine which range to display. void wxScintillaTextCtrl::EnsureVisibleEnforcePolicy(int line) { SendMsg(2234, line, 0); } // Sets whether a tab pressed when caret is within indentation indents. void wxScintillaTextCtrl::SetTabIndents(bool tabIndents) { SendMsg(2260, tabIndents, 0); } // Does a tab pressed when caret is within indentation indent? bool wxScintillaTextCtrl::GetTabIndents() { return SendMsg(2261, 0, 0) != 0; } // Sets whether a backspace pressed when caret is within indentation unindents. void wxScintillaTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents) { SendMsg(2262, bsUnIndents, 0); } // Does a backspace pressed when caret is within indentation unindent? bool wxScintillaTextCtrl::GetBackSpaceUnIndents() { return SendMsg(2263, 0, 0) != 0; } // Sets the time the mouse must sit still to generate a mouse dwell event. void wxScintillaTextCtrl::SetMouseDwellTime(int periodMilliseconds) { SendMsg(2264, periodMilliseconds, 0); } // Retrieve the time the mouse must sit still to generate a mouse dwell event. int wxScintillaTextCtrl::GetMouseDwellTime() { return SendMsg(2265, 0, 0); } // Get position of start of word. int wxScintillaTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters) { return SendMsg(2266, pos, onlyWordCharacters); } // Get position of end of word. int wxScintillaTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters) { return SendMsg(2267, pos, onlyWordCharacters); } // Sets whether text is word wrapped. void wxScintillaTextCtrl::SetWrapMode(int mode) { SendMsg(2268, mode, 0); } // Retrieve whether text is word wrapped. int wxScintillaTextCtrl::GetWrapMode() { return SendMsg(2269, 0, 0); } // Set the display mode of visual flags for wrapped lines. void wxScintillaTextCtrl::SetWrapVisualFlags(int wrapVisualFlags) { SendMsg(2460, wrapVisualFlags, 0); } // Retrive the display mode of visual flags for wrapped lines. int wxScintillaTextCtrl::GetWrapVisualFlags() { return SendMsg(2461, 0, 0); } // Set the location of visual flags for wrapped lines. void wxScintillaTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation) { SendMsg(2462, wrapVisualFlagsLocation, 0); } // Retrive the location of visual flags for wrapped lines. int wxScintillaTextCtrl::GetWrapVisualFlagsLocation() { return SendMsg(2463, 0, 0); } // Set the start indent for wrapped lines. void wxScintillaTextCtrl::SetWrapStartIndent(int indent) { SendMsg(2464, indent, 0); } // Retrive the start indent for wrapped lines. int wxScintillaTextCtrl::GetWrapStartIndent() { return SendMsg(2465, 0, 0); } // Sets how wrapped sublines are placed. Default is fixed. void wxScintillaTextCtrl::SetWrapIndentMode(int mode) { SendMsg(2472, mode, 0); } // Retrieve how wrapped sublines are placed. Default is fixed. int wxScintillaTextCtrl::GetWrapIndentMode() { return SendMsg(2473, 0, 0); } // Sets the degree of caching of layout information. void wxScintillaTextCtrl::SetLayoutCache(int mode) { SendMsg(2272, mode, 0); } // Retrieve the degree of caching of layout information. int wxScintillaTextCtrl::GetLayoutCache() { return SendMsg(2273, 0, 0); } // Sets the document width assumed for scrolling. void wxScintillaTextCtrl::SetScrollWidth(int pixelWidth) { SendMsg(2274, pixelWidth, 0); } // Retrieve the document width assumed for scrolling. int wxScintillaTextCtrl::GetScrollWidth() { return SendMsg(2275, 0, 0); } // Sets whether the maximum width line displayed is used to set scroll width. void wxScintillaTextCtrl::SetScrollWidthTracking(bool tracking) { SendMsg(2516, tracking, 0); } // Retrieve whether the scroll width tracks wide lines. bool wxScintillaTextCtrl::GetScrollWidthTracking() { return SendMsg(2517, 0, 0) != 0; } // Measure the pixel width of some text in a particular style. // NUL terminated text argument. // Does not handle tab or control characters. int wxScintillaTextCtrl::TextWidth(int style, const wxString& text) { return SendMsg(2276, style, (sptr_t)(const char*)wx2stc(text)); } // Sets the scroll range so that maximum scroll position has // the last line at the bottom of the view (default). // Setting this to false allows scrolling one page below the last line. void wxScintillaTextCtrl::SetEndAtLastLine(bool endAtLastLine) { SendMsg(2277, endAtLastLine, 0); } // Retrieve whether the maximum scroll position has the last // line at the bottom of the view. bool wxScintillaTextCtrl::GetEndAtLastLine() { return SendMsg(2278, 0, 0) != 0; } // Retrieve the height of a particular line of text in pixels. int wxScintillaTextCtrl::TextHeight(int line) { return SendMsg(2279, line, 0); } // Show or hide the vertical scroll bar. void wxScintillaTextCtrl::SetUseVerticalScrollBar(bool show) { SendMsg(2280, show, 0); } // Is the vertical scroll bar visible? bool wxScintillaTextCtrl::GetUseVerticalScrollBar() { return SendMsg(2281, 0, 0) != 0; } // Append a string to the end of the document without changing the selection. void wxScintillaTextCtrl::AppendText(const wxString& text) { wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); SendMsg(2282, strlen(buf), (sptr_t)(const char*)buf); } // Is drawing done in two phases with backgrounds drawn before foregrounds? bool wxScintillaTextCtrl::GetTwoPhaseDraw() { return SendMsg(2283, 0, 0) != 0; } // In twoPhaseDraw mode, drawing is performed in two phases, first the background // and then the foreground. This avoids chopping off characters that overlap the next run. void wxScintillaTextCtrl::SetTwoPhaseDraw(bool twoPhase) { SendMsg(2284, twoPhase, 0); } // Scroll so that a display line is at the top of the display. void wxScintillaTextCtrl::SetFirstVisibleLine(int lineDisplay) { SendMsg(2613, lineDisplay, 0); } // Make the target range start and end be the same as the selection range start and end. void wxScintillaTextCtrl::TargetFromSelection() { SendMsg(2287, 0, 0); } // Join the lines in the target. void wxScintillaTextCtrl::LinesJoin() { SendMsg(2288, 0, 0); } // Split the lines in the target into lines that are less wide than pixelWidth // where possible. void wxScintillaTextCtrl::LinesSplit(int pixelWidth) { SendMsg(2289, pixelWidth, 0); } // Set the colours used as a chequerboard pattern in the fold margin void wxScintillaTextCtrl::SetFoldMarginColour(bool useSetting, const wxColour& back) { SendMsg(2290, useSetting, wxColourAsLong(back)); } void wxScintillaTextCtrl::SetFoldMarginHiColour(bool useSetting, const wxColour& fore) { SendMsg(2291, useSetting, wxColourAsLong(fore)); } // Move caret down one line. void wxScintillaTextCtrl::LineDown() { SendMsg(2300, 0, 0); } // Move caret down one line extending selection to new caret position. void wxScintillaTextCtrl::LineDownExtend() { SendMsg(2301, 0, 0); } // Move caret up one line. void wxScintillaTextCtrl::LineUp() { SendMsg(2302, 0, 0); } // Move caret up one line extending selection to new caret position. void wxScintillaTextCtrl::LineUpExtend() { SendMsg(2303, 0, 0); } // Move caret left one character. void wxScintillaTextCtrl::CharLeft() { SendMsg(2304, 0, 0); } // Move caret left one character extending selection to new caret position. void wxScintillaTextCtrl::CharLeftExtend() { SendMsg(2305, 0, 0); } // Move caret right one character. void wxScintillaTextCtrl::CharRight() { SendMsg(2306, 0, 0); } // Move caret right one character extending selection to new caret position. void wxScintillaTextCtrl::CharRightExtend() { SendMsg(2307, 0, 0); } // Move caret left one word. void wxScintillaTextCtrl::WordLeft() { SendMsg(2308, 0, 0); } // Move caret left one word extending selection to new caret position. void wxScintillaTextCtrl::WordLeftExtend() { SendMsg(2309, 0, 0); } // Move caret right one word. void wxScintillaTextCtrl::WordRight() { SendMsg(2310, 0, 0); } // Move caret right one word extending selection to new caret position. void wxScintillaTextCtrl::WordRightExtend() { SendMsg(2311, 0, 0); } // Move caret to first position on line. void wxScintillaTextCtrl::Home() { SendMsg(2312, 0, 0); } // Move caret to first position on line extending selection to new caret position. void wxScintillaTextCtrl::HomeExtend() { SendMsg(2313, 0, 0); } // Move caret to last position on line. void wxScintillaTextCtrl::LineEnd() { SendMsg(2314, 0, 0); } // Move caret to last position on line extending selection to new caret position. void wxScintillaTextCtrl::LineEndExtend() { SendMsg(2315, 0, 0); } // Move caret to first position in document. void wxScintillaTextCtrl::DocumentStart() { SendMsg(2316, 0, 0); } // Move caret to first position in document extending selection to new caret position. void wxScintillaTextCtrl::DocumentStartExtend() { SendMsg(2317, 0, 0); } // Move caret to last position in document. void wxScintillaTextCtrl::DocumentEnd() { SendMsg(2318, 0, 0); } // Move caret to last position in document extending selection to new caret position. void wxScintillaTextCtrl::DocumentEndExtend() { SendMsg(2319, 0, 0); } // Move caret one page up. void wxScintillaTextCtrl::PageUp() { SendMsg(2320, 0, 0); } // Move caret one page up extending selection to new caret position. void wxScintillaTextCtrl::PageUpExtend() { SendMsg(2321, 0, 0); } // Move caret one page down. void wxScintillaTextCtrl::PageDown() { SendMsg(2322, 0, 0); } // Move caret one page down extending selection to new caret position. void wxScintillaTextCtrl::PageDownExtend() { SendMsg(2323, 0, 0); } // Switch from insert to overtype mode or the reverse. void wxScintillaTextCtrl::EditToggleOvertype() { SendMsg(2324, 0, 0); } // Cancel any modes such as call tip or auto-completion list display. void wxScintillaTextCtrl::Cancel() { SendMsg(2325, 0, 0); } // Delete the selection or if no selection, the character before the caret. void wxScintillaTextCtrl::DeleteBack() { SendMsg(2326, 0, 0); } // If selection is empty or all on one line replace the selection with a tab character. // If more than one line selected, indent the lines. void wxScintillaTextCtrl::Tab() { SendMsg(2327, 0, 0); } // Dedent the selected lines. void wxScintillaTextCtrl::BackTab() { SendMsg(2328, 0, 0); } // Insert a new line, may use a CRLF, CR or LF depending on EOL mode. void wxScintillaTextCtrl::NewLine() { SendMsg(2329, 0, 0); } // Insert a Form Feed character. void wxScintillaTextCtrl::FormFeed() { SendMsg(2330, 0, 0); } // Move caret to before first visible character on line. // If already there move to first character on line. void wxScintillaTextCtrl::VCHome() { SendMsg(2331, 0, 0); } // Like VCHome but extending selection to new caret position. void wxScintillaTextCtrl::VCHomeExtend() { SendMsg(2332, 0, 0); } // Magnify the displayed text by increasing the sizes by 1 point. void wxScintillaTextCtrl::ZoomIn() { SendMsg(2333, 0, 0); } // Make the displayed text smaller by decreasing the sizes by 1 point. void wxScintillaTextCtrl::ZoomOut() { SendMsg(2334, 0, 0); } // Move the selected lines up one line, shifting the line above after the // selection. void wxScintillaTextCtrl::MoveSelectedLinesUp() { SendMsg(2620, 0, 0); } // Move the selected lines down one line, shifting the line below before the // selection. void wxScintillaTextCtrl::MoveSelectedLinesDown() { SendMsg(2621, 0, 0); } // Delete the word to the left of the caret. void wxScintillaTextCtrl::DelWordLeft() { SendMsg(2335, 0, 0); } // Delete the word to the right of the caret. void wxScintillaTextCtrl::DelWordRight() { SendMsg(2336, 0, 0); } // Delete the word to the right of the caret, but not the trailing non-word characters. void wxScintillaTextCtrl::DelWordRightEnd() { SendMsg(2518, 0, 0); } // Cut the line containing the caret. void wxScintillaTextCtrl::LineCut() { SendMsg(2337, 0, 0); } // Delete the line containing the caret. void wxScintillaTextCtrl::LineDelete() { SendMsg(2338, 0, 0); } // Switch the current line with the previous. void wxScintillaTextCtrl::LineTranspose() { SendMsg(2339, 0, 0); } // Duplicate the current line. void wxScintillaTextCtrl::LineDuplicate() { SendMsg(2404, 0, 0); } // Transform the selection to lower case. void wxScintillaTextCtrl::LowerCase() { SendMsg(2340, 0, 0); } // Transform the selection to upper case. void wxScintillaTextCtrl::UpperCase() { SendMsg(2341, 0, 0); } // Scroll the document down, keeping the caret visible. void wxScintillaTextCtrl::LineScrollDown() { SendMsg(2342, 0, 0); } // Scroll the document up, keeping the caret visible. void wxScintillaTextCtrl::LineScrollUp() { SendMsg(2343, 0, 0); } // Delete the selection or if no selection, the character before the caret. // Will not delete the character before at the start of a line. void wxScintillaTextCtrl::DeleteBackNotLine() { SendMsg(2344, 0, 0); } // Move caret to first position on display line. void wxScintillaTextCtrl::HomeDisplay() { SendMsg(2345, 0, 0); } // Move caret to first position on display line extending selection to // new caret position. void wxScintillaTextCtrl::HomeDisplayExtend() { SendMsg(2346, 0, 0); } // Move caret to last position on display line. void wxScintillaTextCtrl::LineEndDisplay() { SendMsg(2347, 0, 0); } // Move caret to last position on display line extending selection to new // caret position. void wxScintillaTextCtrl::LineEndDisplayExtend() { SendMsg(2348, 0, 0); } // These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)? // except they behave differently when word-wrap is enabled: // They go first to the start / end of the display line, like (Home|LineEnd)Display // The difference is that, the cursor is already at the point, it goes on to the start // or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?. void wxScintillaTextCtrl::HomeWrap() { SendMsg(2349, 0, 0); } void wxScintillaTextCtrl::HomeWrapExtend() { SendMsg(2450, 0, 0); } void wxScintillaTextCtrl::LineEndWrap() { SendMsg(2451, 0, 0); } void wxScintillaTextCtrl::LineEndWrapExtend() { SendMsg(2452, 0, 0); } void wxScintillaTextCtrl::VCHomeWrap() { SendMsg(2453, 0, 0); } void wxScintillaTextCtrl::VCHomeWrapExtend() { SendMsg(2454, 0, 0); } // Copy the line containing the caret. void wxScintillaTextCtrl::LineCopy() { SendMsg(2455, 0, 0); } // Move the caret inside current view if it's not there already. void wxScintillaTextCtrl::MoveCaretInsideView() { SendMsg(2401, 0, 0); } // How many characters are on a line, including end of line characters? int wxScintillaTextCtrl::LineLength(int line) { return SendMsg(2350, line, 0); } // Highlight the characters at two positions. void wxScintillaTextCtrl::BraceHighlight(int pos1, int pos2) { SendMsg(2351, pos1, pos2); } // Highlight the character at a position indicating there is no matching brace. void wxScintillaTextCtrl::BraceBadLight(int pos) { SendMsg(2352, pos, 0); } // Find the position of a matching brace or INVALID_POSITION if no match. int wxScintillaTextCtrl::BraceMatch(int pos) { return SendMsg(2353, pos, 0); } // Are the end of line characters visible? bool wxScintillaTextCtrl::GetViewEOL() { return SendMsg(2355, 0, 0) != 0; } // Make the end of line characters visible or invisible. void wxScintillaTextCtrl::SetViewEOL(bool visible) { SendMsg(2356, visible, 0); } // Retrieve a pointer to the document object. void* wxScintillaTextCtrl::GetDocPointer() { return (void*)SendMsg(2357); } // Change the document object used. void wxScintillaTextCtrl::SetDocPointer(void* docPointer) { SendMsg(2358, 0, (sptr_t)docPointer); } // Set which document modification events are sent to the container. void wxScintillaTextCtrl::SetModEventMask(int mask) { SendMsg(2359, mask, 0); } // Retrieve the column number which text should be kept within. int wxScintillaTextCtrl::GetEdgeColumn() { return SendMsg(2360, 0, 0); } // Set the column number of the edge. // If text goes past the edge then it is highlighted. void wxScintillaTextCtrl::SetEdgeColumn(int column) { SendMsg(2361, column, 0); } // Retrieve the edge highlight mode. int wxScintillaTextCtrl::GetEdgeMode() { return SendMsg(2362, 0, 0); } // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE). void wxScintillaTextCtrl::SetEdgeMode(int mode) { SendMsg(2363, mode, 0); } // Retrieve the colour used in edge indication. wxColour wxScintillaTextCtrl::GetEdgeColour() { long c = SendMsg(2364, 0, 0); return wxColourFromLong(c); } // Change the colour used in edge indication. void wxScintillaTextCtrl::SetEdgeColour(const wxColour& edgeColour) { SendMsg(2365, wxColourAsLong(edgeColour), 0); } // Sets the current caret position to be the search anchor. void wxScintillaTextCtrl::SearchAnchor() { SendMsg(2366, 0, 0); } // Find some text starting at the search anchor. // Does not ensure the selection is visible. int wxScintillaTextCtrl::SearchNext(int flags, const wxString& text) { return SendMsg(2367, flags, (sptr_t)(const char*)wx2stc(text)); } // Find some text starting at the search anchor and moving backwards. // Does not ensure the selection is visible. int wxScintillaTextCtrl::SearchPrev(int flags, const wxString& text) { return SendMsg(2368, flags, (sptr_t)(const char*)wx2stc(text)); } // Retrieves the number of lines completely visible. int wxScintillaTextCtrl::LinesOnScreen() { return SendMsg(2370, 0, 0); } // Set whether a pop up menu is displayed automatically when the user presses // the wrong mouse button. void wxScintillaTextCtrl::UsePopUp(bool allowPopUp) { SendMsg(2371, allowPopUp, 0); } // Is the selection rectangular? The alternative is the more common stream selection. bool wxScintillaTextCtrl::SelectionIsRectangle() { return SendMsg(2372, 0, 0) != 0; } // Set the zoom level. This number of points is added to the size of all fonts. // It may be positive to magnify or negative to reduce. void wxScintillaTextCtrl::SetZoom(int zoom) { SendMsg(2373, zoom, 0); } // Retrieve the zoom level. int wxScintillaTextCtrl::GetZoom() { return SendMsg(2374, 0, 0); } // Create a new document object. // Starts with reference count of 1 and not selected into editor. void* wxScintillaTextCtrl::CreateDocument() { return (void*)SendMsg(2375); } // Extend life of document. void wxScintillaTextCtrl::AddRefDocument(void* docPointer) { SendMsg(2376, 0, (sptr_t)docPointer); } // Release a reference to the document, deleting document if it fades to black. void wxScintillaTextCtrl::ReleaseDocument(void* docPointer) { SendMsg(2377, 0, (sptr_t)docPointer); } // Get which document modification events are sent to the container. int wxScintillaTextCtrl::GetModEventMask() { return SendMsg(2378, 0, 0); } // Change internal focus flag. void wxScintillaTextCtrl::SetSTCFocus(bool focus) { SendMsg(2380, focus, 0); } // Get internal focus flag. bool wxScintillaTextCtrl::GetSTCFocus() { return SendMsg(2381, 0, 0) != 0; } // Change error status - 0 = OK. void wxScintillaTextCtrl::SetStatus(int statusCode) { SendMsg(2382, statusCode, 0); } // Get error status. int wxScintillaTextCtrl::GetStatus() { return SendMsg(2383, 0, 0); } // Set whether the mouse is captured when its button is pressed. void wxScintillaTextCtrl::SetMouseDownCaptures(bool captures) { SendMsg(2384, captures, 0); } // Get whether mouse gets captured. bool wxScintillaTextCtrl::GetMouseDownCaptures() { return SendMsg(2385, 0, 0) != 0; } // Sets the cursor to one of the SC_CURSOR* values. void wxScintillaTextCtrl::SetSTCCursor(int cursorType) { SendMsg(2386, cursorType, 0); } // Get cursor type. int wxScintillaTextCtrl::GetSTCCursor() { return SendMsg(2387, 0, 0); } // Change the way control characters are displayed: // If symbol is < 32, keep the drawn way, else, use the given character. void wxScintillaTextCtrl::SetControlCharSymbol(int symbol) { SendMsg(2388, symbol, 0); } // Get the way control characters are displayed. int wxScintillaTextCtrl::GetControlCharSymbol() { return SendMsg(2389, 0, 0); } // Move to the previous change in capitalisation. void wxScintillaTextCtrl::WordPartLeft() { SendMsg(2390, 0, 0); } // Move to the previous change in capitalisation extending selection // to new caret position. void wxScintillaTextCtrl::WordPartLeftExtend() { SendMsg(2391, 0, 0); } // Move to the change next in capitalisation. void wxScintillaTextCtrl::WordPartRight() { SendMsg(2392, 0, 0); } // Move to the next change in capitalisation extending selection // to new caret position. void wxScintillaTextCtrl::WordPartRightExtend() { SendMsg(2393, 0, 0); } // Set the way the display area is determined when a particular line // is to be moved to by Find, FindNext, GotoLine, etc. void wxScintillaTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop) { SendMsg(2394, visiblePolicy, visibleSlop); } // Delete back from the current position to the start of the line. void wxScintillaTextCtrl::DelLineLeft() { SendMsg(2395, 0, 0); } // Delete forwards from the current position to the end of the line. void wxScintillaTextCtrl::DelLineRight() { SendMsg(2396, 0, 0); } // Get and Set the xOffset (ie, horizonal scroll position). void wxScintillaTextCtrl::SetXOffset(int newOffset) { SendMsg(2397, newOffset, 0); } int wxScintillaTextCtrl::GetXOffset() { return SendMsg(2398, 0, 0); } // Set the last x chosen value to be the caret x position. void wxScintillaTextCtrl::ChooseCaretX() { SendMsg(2399, 0, 0); } // Set the way the caret is kept visible when going sideway. // The exclusion zone is given in pixels. void wxScintillaTextCtrl::SetXCaretPolicy(int caretPolicy, int caretSlop) { SendMsg(2402, caretPolicy, caretSlop); } // Set the way the line the caret is on is kept visible. // The exclusion zone is given in lines. void wxScintillaTextCtrl::SetYCaretPolicy(int caretPolicy, int caretSlop) { SendMsg(2403, caretPolicy, caretSlop); } // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE). void wxScintillaTextCtrl::SetPrintWrapMode(int mode) { SendMsg(2406, mode, 0); } // Is printing line wrapped? int wxScintillaTextCtrl::GetPrintWrapMode() { return SendMsg(2407, 0, 0); } // Set a fore colour for active hotspots. void wxScintillaTextCtrl::SetHotspotActiveForeground(bool useSetting, const wxColour& fore) { SendMsg(2410, useSetting, wxColourAsLong(fore)); } // Get the fore colour for active hotspots. wxColour wxScintillaTextCtrl::GetHotspotActiveForeground() { long c = SendMsg(2494, 0, 0); return wxColourFromLong(c); } // Set a back colour for active hotspots. void wxScintillaTextCtrl::SetHotspotActiveBackground(bool useSetting, const wxColour& back) { SendMsg(2411, useSetting, wxColourAsLong(back)); } // Get the back colour for active hotspots. wxColour wxScintillaTextCtrl::GetHotspotActiveBackground() { long c = SendMsg(2495, 0, 0); return wxColourFromLong(c); } // Enable / Disable underlining active hotspots. void wxScintillaTextCtrl::SetHotspotActiveUnderline(bool underline) { SendMsg(2412, underline, 0); } // Get whether underlining for active hotspots. bool wxScintillaTextCtrl::GetHotspotActiveUnderline() { return SendMsg(2496, 0, 0) != 0; } // Limit hotspots to single line so hotspots on two lines don't merge. void wxScintillaTextCtrl::SetHotspotSingleLine(bool singleLine) { SendMsg(2421, singleLine, 0); } // Get the HotspotSingleLine property bool wxScintillaTextCtrl::GetHotspotSingleLine() { return SendMsg(2497, 0, 0) != 0; } // Move caret between paragraphs (delimited by empty lines). void wxScintillaTextCtrl::ParaDown() { SendMsg(2413, 0, 0); } void wxScintillaTextCtrl::ParaDownExtend() { SendMsg(2414, 0, 0); } void wxScintillaTextCtrl::ParaUp() { SendMsg(2415, 0, 0); } void wxScintillaTextCtrl::ParaUpExtend() { SendMsg(2416, 0, 0); } // Given a valid document position, return the previous position taking code // page into account. Returns 0 if passed 0. int wxScintillaTextCtrl::PositionBefore(int pos) { return SendMsg(2417, pos, 0); } // Given a valid document position, return the next position taking code // page into account. Maximum value returned is the last position in the document. int wxScintillaTextCtrl::PositionAfter(int pos) { return SendMsg(2418, pos, 0); } // Copy a range of text to the clipboard. Positions are clipped into the document. void wxScintillaTextCtrl::CopyRange(int start, int end) { SendMsg(2419, start, end); } // Copy argument text to the clipboard. void wxScintillaTextCtrl::CopyText(int length, const wxString& text) { SendMsg(2420, length, (sptr_t)(const char*)wx2stc(text)); } // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE/SC_SEL_THIN) or // by lines (SC_SEL_LINES). void wxScintillaTextCtrl::SetSelectionMode(int mode) { SendMsg(2422, mode, 0); } // Get the mode of the current selection. int wxScintillaTextCtrl::GetSelectionMode() { return SendMsg(2423, 0, 0); } // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line). int wxScintillaTextCtrl::GetLineSelStartPosition(int line) { return SendMsg(2424, line, 0); } // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line). int wxScintillaTextCtrl::GetLineSelEndPosition(int line) { return SendMsg(2425, line, 0); } // Move caret down one line, extending rectangular selection to new caret position. void wxScintillaTextCtrl::LineDownRectExtend() { SendMsg(2426, 0, 0); } // Move caret up one line, extending rectangular selection to new caret position. void wxScintillaTextCtrl::LineUpRectExtend() { SendMsg(2427, 0, 0); } // Move caret left one character, extending rectangular selection to new caret position. void wxScintillaTextCtrl::CharLeftRectExtend() { SendMsg(2428, 0, 0); } // Move caret right one character, extending rectangular selection to new caret position. void wxScintillaTextCtrl::CharRightRectExtend() { SendMsg(2429, 0, 0); } // Move caret to first position on line, extending rectangular selection to new caret position. void wxScintillaTextCtrl::HomeRectExtend() { SendMsg(2430, 0, 0); } // Move caret to before first visible character on line. // If already there move to first character on line. // In either case, extend rectangular selection to new caret position. void wxScintillaTextCtrl::VCHomeRectExtend() { SendMsg(2431, 0, 0); } // Move caret to last position on line, extending rectangular selection to new caret position. void wxScintillaTextCtrl::LineEndRectExtend() { SendMsg(2432, 0, 0); } // Move caret one page up, extending rectangular selection to new caret position. void wxScintillaTextCtrl::PageUpRectExtend() { SendMsg(2433, 0, 0); } // Move caret one page down, extending rectangular selection to new caret position. void wxScintillaTextCtrl::PageDownRectExtend() { SendMsg(2434, 0, 0); } // Move caret to top of page, or one page up if already at top of page. void wxScintillaTextCtrl::StutteredPageUp() { SendMsg(2435, 0, 0); } // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position. void wxScintillaTextCtrl::StutteredPageUpExtend() { SendMsg(2436, 0, 0); } // Move caret to bottom of page, or one page down if already at bottom of page. void wxScintillaTextCtrl::StutteredPageDown() { SendMsg(2437, 0, 0); } // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position. void wxScintillaTextCtrl::StutteredPageDownExtend() { SendMsg(2438, 0, 0); } // Move caret left one word, position cursor at end of word. void wxScintillaTextCtrl::WordLeftEnd() { SendMsg(2439, 0, 0); } // Move caret left one word, position cursor at end of word, extending selection to new caret position. void wxScintillaTextCtrl::WordLeftEndExtend() { SendMsg(2440, 0, 0); } // Move caret right one word, position cursor at end of word. void wxScintillaTextCtrl::WordRightEnd() { SendMsg(2441, 0, 0); } // Move caret right one word, position cursor at end of word, extending selection to new caret position. void wxScintillaTextCtrl::WordRightEndExtend() { SendMsg(2442, 0, 0); } // Set the set of characters making up whitespace for when moving or selecting by word. // Should be called after SetWordChars. void wxScintillaTextCtrl::SetWhitespaceChars(const wxString& characters) { SendMsg(2443, 0, (sptr_t)(const char*)wx2stc(characters)); } // Reset the set of characters for whitespace and word characters to the defaults. void wxScintillaTextCtrl::SetCharsDefault() { SendMsg(2444, 0, 0); } // Get currently selected item position in the auto-completion list int wxScintillaTextCtrl::AutoCompGetCurrent() { return SendMsg(2445, 0, 0); } // Enlarge the document to a particular size of text bytes. void wxScintillaTextCtrl::Allocate(int bytes) { SendMsg(2446, bytes, 0); } // Find the position of a column on a line taking into account tabs and // multi-byte characters. If beyond end of line, return line end position. int wxScintillaTextCtrl::FindColumn(int line, int column) { return SendMsg(2456, line, column); } // Can the caret preferred x position only be changed by explicit movement commands? bool wxScintillaTextCtrl::GetCaretSticky() { return SendMsg(2457, 0, 0) != 0; } // Stop the caret preferred x position changing when the user types. void wxScintillaTextCtrl::SetCaretSticky(bool useCaretStickyBehaviour) { SendMsg(2458, useCaretStickyBehaviour, 0); } // Switch between sticky and non-sticky: meant to be bound to a key. void wxScintillaTextCtrl::ToggleCaretSticky() { SendMsg(2459, 0, 0); } // Enable/Disable convert-on-paste for line endings void wxScintillaTextCtrl::SetPasteConvertEndings(bool convert) { SendMsg(2467, convert, 0); } // Get convert-on-paste setting bool wxScintillaTextCtrl::GetPasteConvertEndings() { return SendMsg(2468, 0, 0) != 0; } // Duplicate the selection. If selection empty duplicate the line containing the caret. void wxScintillaTextCtrl::SelectionDuplicate() { SendMsg(2469, 0, 0); } // Set background alpha of the caret line. void wxScintillaTextCtrl::SetCaretLineBackAlpha(int alpha) { SendMsg(2470, alpha, 0); } // Get the background alpha of the caret line. int wxScintillaTextCtrl::GetCaretLineBackAlpha() { return SendMsg(2471, 0, 0); } // Set the style of the caret to be drawn. void wxScintillaTextCtrl::SetCaretStyle(int caretStyle) { SendMsg(2512, caretStyle, 0); } // Returns the current style of the caret. int wxScintillaTextCtrl::GetCaretStyle() { return SendMsg(2513, 0, 0); } // Set the indicator used for IndicatorFillRange and IndicatorClearRange void wxScintillaTextCtrl::SetIndicatorCurrent(int indicator) { SendMsg(2500, indicator, 0); } // Get the current indicator int wxScintillaTextCtrl::GetIndicatorCurrent() { return SendMsg(2501, 0, 0); } // Set the value used for IndicatorFillRange void wxScintillaTextCtrl::SetIndicatorValue(int value) { SendMsg(2502, value, 0); } // Get the current indicator vaue int wxScintillaTextCtrl::GetIndicatorValue() { return SendMsg(2503, 0, 0); } // Turn a indicator on over a range. void wxScintillaTextCtrl::IndicatorFillRange(int position, int fillLength) { SendMsg(2504, position, fillLength); } // Turn a indicator off over a range. void wxScintillaTextCtrl::IndicatorClearRange(int position, int clearLength) { SendMsg(2505, position, clearLength); } // Are any indicators present at position? int wxScintillaTextCtrl::IndicatorAllOnFor(int position) { return SendMsg(2506, position, 0); } // What value does a particular indicator have at at a position? int wxScintillaTextCtrl::IndicatorValueAt(int indicator, int position) { return SendMsg(2507, indicator, position); } // Where does a particular indicator start? int wxScintillaTextCtrl::IndicatorStart(int indicator, int position) { return SendMsg(2508, indicator, position); } // Where does a particular indicator end? int wxScintillaTextCtrl::IndicatorEnd(int indicator, int position) { return SendMsg(2509, indicator, position); } // Set number of entries in position cache void wxScintillaTextCtrl::SetPositionCacheSize(int size) { SendMsg(2514, size, 0); } // How many entries are allocated to the position cache? int wxScintillaTextCtrl::GetPositionCacheSize() { return SendMsg(2515, 0, 0); } // Copy the selection, if selection empty copy the line with the caret void wxScintillaTextCtrl::CopyAllowLine() { SendMsg(2519, 0, 0); } // Compact the document buffer and return a read-only pointer to the // characters in the document. const char* wxScintillaTextCtrl::GetCharacterPointer() { return (const char*)SendMsg(2520, 0, 0); } // Always interpret keyboard input as Unicode void wxScintillaTextCtrl::SetKeysUnicode(bool keysUnicode) { SendMsg(2521, keysUnicode, 0); } // Are keys always interpreted as Unicode? bool wxScintillaTextCtrl::GetKeysUnicode() { return SendMsg(2522, 0, 0) != 0; } // Set the alpha fill colour of the given indicator. void wxScintillaTextCtrl::IndicatorSetAlpha(int indicator, int alpha) { SendMsg(2523, indicator, alpha); } // Get the alpha fill colour of the given indicator. int wxScintillaTextCtrl::IndicatorGetAlpha(int indicator) { return SendMsg(2524, indicator, 0); } // Set extra ascent for each line void wxScintillaTextCtrl::SetExtraAscent(int extraAscent) { SendMsg(2525, extraAscent, 0); } // Get extra ascent for each line int wxScintillaTextCtrl::GetExtraAscent() { return SendMsg(2526, 0, 0); } // Set extra descent for each line void wxScintillaTextCtrl::SetExtraDescent(int extraDescent) { SendMsg(2527, extraDescent, 0); } // Get extra descent for each line int wxScintillaTextCtrl::GetExtraDescent() { return SendMsg(2528, 0, 0); } // Which symbol was defined for markerNumber with MarkerDefine int wxScintillaTextCtrl::GetMarkerSymbolDefined(int markerNumber) { return SendMsg(2529, markerNumber, 0); } // Set the text in the text margin for a line void wxScintillaTextCtrl::MarginSetText(int line, const wxString& text) { SendMsg(2530, line, (sptr_t)(const char*)wx2stc(text)); } // Get the text in the text margin for a line wxString wxScintillaTextCtrl::MarginGetText(int line) { long msg = 2531; long len = SendMsg(msg, line, 0); wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len+1); SendMsg(msg, line, (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); } // Set the style number for the text margin for a line void wxScintillaTextCtrl::MarginSetStyle(int line, int style) { SendMsg(2532, line, style); } // Get the style number for the text margin for a line int wxScintillaTextCtrl::MarginGetStyle(int line) { return SendMsg(2533, line, 0); } // Set the style in the text margin for a line void wxScintillaTextCtrl::MarginSetStyles(int line, const wxString& styles) { SendMsg(2534, line, (sptr_t)(const char*)wx2stc(styles)); } // Get the styles in the text margin for a line wxString wxScintillaTextCtrl::MarginGetStyles(int line) { long msg = 2535; long len = SendMsg(msg, line, 0); wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len+1); SendMsg(msg, line, (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); } // Clear the margin text on all lines void wxScintillaTextCtrl::MarginTextClearAll() { SendMsg(2536, 0, 0); } // Get the start of the range of style numbers used for margin text void wxScintillaTextCtrl::MarginSetStyleOffset(int style) { SendMsg(2537, style, 0); } // Get the start of the range of style numbers used for margin text int wxScintillaTextCtrl::MarginGetStyleOffset() { return SendMsg(2538, 0, 0); } // Set the annotation text for a line void wxScintillaTextCtrl::AnnotationSetText(int line, const wxString& text) { SendMsg(2540, line, (sptr_t)(const char*)wx2stc(text)); } // Get the annotation text for a line wxString wxScintillaTextCtrl::AnnotationGetText(int line) { long msg = 2541; long len = SendMsg(msg, line, 0); wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len+1); SendMsg(msg, line, (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); } // Set the style number for the annotations for a line void wxScintillaTextCtrl::AnnotationSetStyle(int line, int style) { SendMsg(2542, line, style); } // Get the style number for the annotations for a line int wxScintillaTextCtrl::AnnotationGetStyle(int line) { return SendMsg(2543, line, 0); } // Set the annotation styles for a line void wxScintillaTextCtrl::AnnotationSetStyles(int line, const wxString& styles) { SendMsg(2544, line, (sptr_t)(const char*)wx2stc(styles)); } // Get the annotation styles for a line wxString wxScintillaTextCtrl::AnnotationGetStyles(int line) { long msg = 2545; long len = SendMsg(msg, line, 0); wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len+1); SendMsg(msg, line, (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); } // Get the number of annotation lines for a line int wxScintillaTextCtrl::AnnotationGetLines(int line) { return SendMsg(2546, line, 0); } // Clear the annotations from all lines void wxScintillaTextCtrl::AnnotationClearAll() { SendMsg(2547, 0, 0); } // Set the visibility for the annotations for a view void wxScintillaTextCtrl::AnnotationSetVisible(int visible) { SendMsg(2548, visible, 0); } // Get the visibility for the annotations for a view int wxScintillaTextCtrl::AnnotationGetVisible() { return SendMsg(2549, 0, 0); } // Get the start of the range of style numbers used for annotations void wxScintillaTextCtrl::AnnotationSetStyleOffset(int style) { SendMsg(2550, style, 0); } // Get the start of the range of style numbers used for annotations int wxScintillaTextCtrl::AnnotationGetStyleOffset() { return SendMsg(2551, 0, 0); } // Add a container action to the undo stack void wxScintillaTextCtrl::AddUndoAction(int token, int flags) { SendMsg(2560, token, flags); } // Find the position of a character from a point within the window. int wxScintillaTextCtrl::CharPositionFromPoint(int x, int y) { return SendMsg(2561, x, y); } // Find the position of a character from a point within the window. // Return INVALID_POSITION if not close to text. int wxScintillaTextCtrl::CharPositionFromPointClose(int x, int y) { return SendMsg(2562, x, y); } // Set whether multiple selections can be made void wxScintillaTextCtrl::SetMultipleSelection(bool multipleSelection) { SendMsg(2563, multipleSelection, 0); } // Whether multiple selections can be made bool wxScintillaTextCtrl::GetMultipleSelection() { return SendMsg(2564, 0, 0) != 0; } // Set whether typing can be performed into multiple selections void wxScintillaTextCtrl::SetAdditionalSelectionTyping(bool additionalSelectionTyping) { SendMsg(2565, additionalSelectionTyping, 0); } // Whether typing can be performed into multiple selections bool wxScintillaTextCtrl::GetAdditionalSelectionTyping() { return SendMsg(2566, 0, 0) != 0; } // Set whether additional carets will blink void wxScintillaTextCtrl::SetAdditionalCaretsBlink(bool additionalCaretsBlink) { SendMsg(2567, additionalCaretsBlink, 0); } // Whether additional carets will blink bool wxScintillaTextCtrl::GetAdditionalCaretsBlink() { return SendMsg(2568, 0, 0) != 0; } // Set whether additional carets are visible void wxScintillaTextCtrl::SetAdditionalCaretsVisible(bool additionalCaretsBlink) { SendMsg(2608, additionalCaretsBlink, 0); } // Whether additional carets are visible bool wxScintillaTextCtrl::GetAdditionalCaretsVisible() { return SendMsg(2609, 0, 0) != 0; } // How many selections are there? int wxScintillaTextCtrl::GetSelections() { return SendMsg(2570, 0, 0); } // Clear selections to a single empty stream selection void wxScintillaTextCtrl::ClearSelections() { SendMsg(2571, 0, 0); } // Add a selection int wxScintillaTextCtrl::AddSelection(int caret, int anchor) { return SendMsg(2573, caret, anchor); } // Set the main selection void wxScintillaTextCtrl::SetMainSelection(int selection) { SendMsg(2574, selection, 0); } // Which selection is the main selection int wxScintillaTextCtrl::GetMainSelection() { return SendMsg(2575, 0, 0); } void wxScintillaTextCtrl::SetSelectionNCaret(int selection, int pos) { SendMsg(2576, selection, pos); } int wxScintillaTextCtrl::GetSelectionNCaret(int selection) { return SendMsg(2577, selection, 0); } void wxScintillaTextCtrl::SetSelectionNAnchor(int selection, int posAnchor) { SendMsg(2578, selection, posAnchor); } int wxScintillaTextCtrl::GetSelectionNAnchor(int selection) { return SendMsg(2579, selection, 0); } void wxScintillaTextCtrl::SetSelectionNCaretVirtualSpace(int selection, int space) { SendMsg(2580, selection, space); } int wxScintillaTextCtrl::GetSelectionNCaretVirtualSpace(int selection) { return SendMsg(2581, selection, 0); } void wxScintillaTextCtrl::SetSelectionNAnchorVirtualSpace(int selection, int space) { SendMsg(2582, selection, space); } int wxScintillaTextCtrl::GetSelectionNAnchorVirtualSpace(int selection) { return SendMsg(2583, selection, 0); } // Sets the position that starts the selection - this becomes the anchor. void wxScintillaTextCtrl::SetSelectionNStart(int selection, int pos) { SendMsg(2584, selection, pos); } // Returns the position at the start of the selection. int wxScintillaTextCtrl::GetSelectionNStart(int selection) { return SendMsg(2585, selection, 0); } // Sets the position that ends the selection - this becomes the currentPosition. void wxScintillaTextCtrl::SetSelectionNEnd(int selection, int pos) { SendMsg(2586, selection, pos); } // Returns the position at the end of the selection. int wxScintillaTextCtrl::GetSelectionNEnd(int selection) { return SendMsg(2587, selection, 0); } void wxScintillaTextCtrl::SetRectangularSelectionCaret(int pos) { SendMsg(2588, pos, 0); } int wxScintillaTextCtrl::GetRectangularSelectionCaret() { return SendMsg(2589, 0, 0); } void wxScintillaTextCtrl::SetRectangularSelectionAnchor(int posAnchor) { SendMsg(2590, posAnchor, 0); } int wxScintillaTextCtrl::GetRectangularSelectionAnchor() { return SendMsg(2591, 0, 0); } void wxScintillaTextCtrl::SetRectangularSelectionCaretVirtualSpace(int space) { SendMsg(2592, space, 0); } int wxScintillaTextCtrl::GetRectangularSelectionCaretVirtualSpace() { return SendMsg(2593, 0, 0); } void wxScintillaTextCtrl::SetRectangularSelectionAnchorVirtualSpace(int space) { SendMsg(2594, space, 0); } int wxScintillaTextCtrl::GetRectangularSelectionAnchorVirtualSpace() { return SendMsg(2595, 0, 0); } void wxScintillaTextCtrl::SetVirtualSpaceOptions(int virtualSpaceOptions) { SendMsg(2596, virtualSpaceOptions, 0); } int wxScintillaTextCtrl::GetVirtualSpaceOptions() { return SendMsg(2597, 0, 0); } // On GTK+, allow selecting the modifier key to use for mouse-based // rectangular selection. Often the window manager requires Alt+Mouse Drag // for moving windows. // Valid values are SCMOD_CTRL(default), SCMOD_ALT, or SCMOD_SUPER. void wxScintillaTextCtrl::SetRectangularSelectionModifier(int modifier) { SendMsg(2598, modifier, 0); } // Get the modifier key used for rectangular selection. int wxScintillaTextCtrl::GetRectangularSelectionModifier() { return SendMsg(2599, 0, 0); } // Set the foreground colour of additional selections. // Must have previously called SetSelFore with non-zero first argument for this to have an effect. void wxScintillaTextCtrl::SetAdditionalSelForeground(const wxColour& fore) { SendMsg(2600, wxColourAsLong(fore), 0); } // Set the background colour of additional selections. // Must have previously called SetSelBack with non-zero first argument for this to have an effect. void wxScintillaTextCtrl::SetAdditionalSelBackground(const wxColour& back) { SendMsg(2601, wxColourAsLong(back), 0); } // Set the alpha of the selection. void wxScintillaTextCtrl::SetAdditionalSelAlpha(int alpha) { SendMsg(2602, alpha, 0); } // Get the alpha of the selection. int wxScintillaTextCtrl::GetAdditionalSelAlpha() { return SendMsg(2603, 0, 0); } // Set the foreground colour of additional carets. void wxScintillaTextCtrl::SetAdditionalCaretForeground(const wxColour& fore) { SendMsg(2604, wxColourAsLong(fore), 0); } // Get the foreground colour of additional carets. wxColour wxScintillaTextCtrl::GetAdditionalCaretForeground() { long c = SendMsg(2605, 0, 0); return wxColourFromLong(c); } // Set the main selection to the next selection. void wxScintillaTextCtrl::RotateSelection() { SendMsg(2606, 0, 0); } // Swap that caret and anchor of the main selection. void wxScintillaTextCtrl::SwapMainAnchorCaret() { SendMsg(2607, 0, 0); } // Start notifying the container of all key presses and commands. void wxScintillaTextCtrl::StartRecord() { SendMsg(3001, 0, 0); } // Stop notifying the container of all key presses and commands. void wxScintillaTextCtrl::StopRecord() { SendMsg(3002, 0, 0); } // Set the lexing language of the document. void wxScintillaTextCtrl::SetLexer(int lexer) { SendMsg(4001, lexer, 0); } // Retrieve the lexing language of the document. int wxScintillaTextCtrl::GetLexer() { return SendMsg(4002, 0, 0); } // Colourise a segment of the document using the current lexing language. void wxScintillaTextCtrl::Colourise(int start, int end) { SendMsg(4003, start, end); } // Set up a value that may be used by a lexer for some optional feature. void wxScintillaTextCtrl::SetProperty(const wxString& key, const wxString& value) { SendMsg(4004, (sptr_t)(const char*)wx2stc(key), (sptr_t)(const char*)wx2stc(value)); } // Set up the key words used by the lexer. void wxScintillaTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) { SendMsg(4005, keywordSet, (sptr_t)(const char*)wx2stc(keyWords)); } // Set the lexing language of the document based on string name. void wxScintillaTextCtrl::SetLexerLanguage(const wxString& language) { SendMsg(4006, 0, (sptr_t)(const char*)wx2stc(language)); } // Retrieve a 'property' value previously set with SetProperty. wxString wxScintillaTextCtrl::GetProperty(const wxString& key) { int len = SendMsg(SCI_GETPROPERTY, (sptr_t)(const char*)wx2stc(key), 0); if (!len) return wxEmptyString; wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len+1); SendMsg(4008, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); } // Retrieve a 'property' value previously set with SetProperty, // with '$()' variable replacement on returned buffer. wxString wxScintillaTextCtrl::GetPropertyExpanded(const wxString& key) { int len = SendMsg(SCI_GETPROPERTYEXPANDED, (uptr_t)(const char*)wx2stc(key), 0); if (!len) return wxEmptyString; wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len+1); SendMsg(4009, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); } // Retrieve a 'property' value previously set with SetProperty, // interpreted as an int AFTER any '$()' variable replacement. int wxScintillaTextCtrl::GetPropertyInt(const wxString& key) { return SendMsg(4010, (sptr_t)(const char*)wx2stc(key), 0); } // Retrieve the number of bits the current lexer needs for styling. int wxScintillaTextCtrl::GetStyleBitsNeeded() { return SendMsg(4011, 0, 0); } //}}} //---------------------------------------------------------------------- // Returns the line number of the line with the caret. int wxScintillaTextCtrl::GetCurrentLine() { int line = LineFromPosition(GetCurrentPos()); return line; } // Extract style settings from a spec-string which is composed of one or // more of the following comma separated elements: // // bold turns on bold // italic turns on italics // fore:[name or #RRGGBB] sets the foreground colour // back:[name or #RRGGBB] sets the background colour // face:[facename] sets the font face name to use // size:[num] sets the font size in points // eol turns on eol filling // underline turns on underlining // void wxScintillaTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) { wxStringTokenizer tkz(spec, wxT(",")); while (tkz.HasMoreTokens()) { wxString token = tkz.GetNextToken(); wxString option = token.BeforeFirst(':'); wxString val = token.AfterFirst(':'); if (option == wxT("bold")) StyleSetBold(styleNum, true); else if (option == wxT("italic")) StyleSetItalic(styleNum, true); else if (option == wxT("underline")) StyleSetUnderline(styleNum, true); else if (option == wxT("eol")) StyleSetEOLFilled(styleNum, true); else if (option == wxT("size")) { long points; if (val.ToLong(&points)) StyleSetSize(styleNum, points); } else if (option == wxT("face")) StyleSetFaceName(styleNum, val); else if (option == wxT("fore")) StyleSetForeground(styleNum, wxColourFromSpec(val)); else if (option == wxT("back")) StyleSetBackground(styleNum, wxColourFromSpec(val)); } } // Get the font of a style wxFont wxScintillaTextCtrl::StyleGetFont(int style) { wxFont font; font.SetPointSize(StyleGetSize(style)); font.SetFaceName(StyleGetFaceName(style)); if( StyleGetBold(style) ) font.SetWeight(wxFONTWEIGHT_BOLD); else font.SetWeight(wxFONTWEIGHT_NORMAL); if( StyleGetItalic(style) ) font.SetStyle(wxFONTSTYLE_ITALIC); else font.SetStyle(wxFONTSTYLE_NORMAL); return font; } // Set style size, face, bold, italic, and underline attributes from // a wxFont's attributes. void wxScintillaTextCtrl::StyleSetFont(int styleNum, wxFont& font) { #ifdef __WXGTK__ // Ensure that the native font is initialized int x, y; GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font); #endif int size = font.GetPointSize(); wxString faceName = font.GetFaceName(); bool bold = font.GetWeight() == wxBOLD; bool italic = font.GetStyle() != wxNORMAL; bool under = font.GetUnderlined(); wxFontEncoding encoding = font.GetEncoding(); StyleSetFontAttr(styleNum, size, faceName, bold, italic, under, encoding); } // Set all font style attributes at once. void wxScintillaTextCtrl::StyleSetFontAttr(int styleNum, int size, const wxString& faceName, bool bold, bool italic, bool underline, wxFontEncoding encoding) { StyleSetSize(styleNum, size); StyleSetFaceName(styleNum, faceName); StyleSetBold(styleNum, bold); StyleSetItalic(styleNum, italic); StyleSetUnderline(styleNum, underline); StyleSetFontEncoding(styleNum, encoding); } // Set the character set of the font in a style. Converts the Scintilla // character set values to a wxFontEncoding. void wxScintillaTextCtrl::StyleSetCharacterSet(int style, int characterSet) { wxFontEncoding encoding; // Translate the Scintilla characterSet to a wxFontEncoding switch (characterSet) { default: case wxSTC_CHARSET_ANSI: case wxSTC_CHARSET_DEFAULT: encoding = wxFONTENCODING_DEFAULT; break; case wxSTC_CHARSET_BALTIC: encoding = wxFONTENCODING_ISO8859_13; break; case wxSTC_CHARSET_CHINESEBIG5: encoding = wxFONTENCODING_CP950; break; case wxSTC_CHARSET_EASTEUROPE: encoding = wxFONTENCODING_ISO8859_2; break; case wxSTC_CHARSET_GB2312: encoding = wxFONTENCODING_CP936; break; case wxSTC_CHARSET_GREEK: encoding = wxFONTENCODING_ISO8859_7; break; case wxSTC_CHARSET_HANGUL: encoding = wxFONTENCODING_CP949; break; case wxSTC_CHARSET_MAC: encoding = wxFONTENCODING_DEFAULT; break; case wxSTC_CHARSET_OEM: encoding = wxFONTENCODING_DEFAULT; break; case wxSTC_CHARSET_RUSSIAN: encoding = wxFONTENCODING_KOI8; break; case wxSTC_CHARSET_SHIFTJIS: encoding = wxFONTENCODING_CP932; break; case wxSTC_CHARSET_SYMBOL: encoding = wxFONTENCODING_DEFAULT; break; case wxSTC_CHARSET_TURKISH: encoding = wxFONTENCODING_ISO8859_9; break; case wxSTC_CHARSET_JOHAB: encoding = wxFONTENCODING_DEFAULT; break; case wxSTC_CHARSET_HEBREW: encoding = wxFONTENCODING_ISO8859_8; break; case wxSTC_CHARSET_ARABIC: encoding = wxFONTENCODING_ISO8859_6; break; case wxSTC_CHARSET_VIETNAMESE: encoding = wxFONTENCODING_DEFAULT; break; case wxSTC_CHARSET_THAI: encoding = wxFONTENCODING_ISO8859_11; break; case wxSTC_CHARSET_CYRILLIC: encoding = wxFONTENCODING_ISO8859_5; break; case wxSTC_CHARSET_8859_15: encoding = wxFONTENCODING_ISO8859_15;; break; } // We just have Scintilla track the wxFontEncoding for us. It gets used // in Font::Create in PlatWX.cpp. We add one to the value so that the // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back // to wxFONENCODING_DEFAULT in Font::Create. SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1); } // Set the font encoding to be used by a style. void wxScintillaTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding) { SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1); } // Set the left and right margin in the edit area, measured in pixels. void wxScintillaTextCtrl::SetMargins(int left, int right) { SetMarginLeft(left); SetMarginRight(right); } // Retrieve the point in the window where a position is displayed. wxPoint wxScintillaTextCtrl::PointFromPosition(int pos) { int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos); int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos); return wxPoint(x, y); } // Remove any selection and sets the caret at position. The caret is not scrolled into view. void wxScintillaTextCtrl::SetEmptySelection(int pos) { SendMsg(SCI_SETEMPTYSELECTION, 0, pos); } // Scroll enough to make the given line visible void wxScintillaTextCtrl::ScrollToLine(int line) { m_swx->DoScrollToLine(line); } // Scroll enough to make the given column visible void wxScintillaTextCtrl::ScrollToColumn(int column) { m_swx->DoScrollToColumn(column); } bool wxScintillaTextCtrl::SaveFile(const wxString& filename) { #if wxUSE_FFILE wxFFile file(filename, wxT("w")); bool ok = file.IsOpened() && file.Write(GetText(), *wxConvCurrent); #else bool ok = false; #endif // wxUSE_FFILE if (ok) { SetSavePoint(); } return ok; } bool wxScintillaTextCtrl::LoadFile(const wxString& filename) { #if wxUSE_FFILE wxFFile file(filename); bool ok = file.IsOpened(); if (ok) { wxString text; ok = file.ReadAll(&text, *wxConvCurrent); if (ok) { SetText(text); } } #else bool ok = false; #endif // wxUSE_FFILE if (ok) { EmptyUndoBuffer(); SetSavePoint(); } return ok; } #if wxUSE_DRAG_AND_DROP wxDragResult wxScintillaTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { return m_swx->DoDragOver(x, y, def); } bool wxScintillaTextCtrl::DoDropText(long x, long y, const wxString& data) { return m_swx->DoDropText(x, y, data); } #endif void wxScintillaTextCtrl::SetUseAntiAliasing(bool useAA) { m_swx->SetUseAntiAliasing(useAA); } bool wxScintillaTextCtrl::GetUseAntiAliasing() { return m_swx->GetUseAntiAliasing(); } void wxScintillaTextCtrl::AddTextRaw(const char* text) { SendMsg(SCI_ADDTEXT, strlen(text), (sptr_t)text); } void wxScintillaTextCtrl::InsertTextRaw(int pos, const char* text) { SendMsg(SCI_INSERTTEXT, pos, (sptr_t)text); } wxCharBuffer wxScintillaTextCtrl::GetCurLineRaw(int* linePos) { int len = LineLength(GetCurrentLine()); if (!len) { if (linePos) *linePos = 0; wxCharBuffer empty; return empty; } wxCharBuffer buf(len); int pos = SendMsg(SCI_GETCURLINE, len, (sptr_t)buf.data()); if (linePos) *linePos = pos; return buf; } wxCharBuffer wxScintillaTextCtrl::GetLineRaw(int line) { int len = LineLength(line); if (!len) { wxCharBuffer empty; return empty; } wxCharBuffer buf(len); SendMsg(SCI_GETLINE, line, (sptr_t)buf.data()); return buf; } wxCharBuffer wxScintillaTextCtrl::GetSelectedTextRaw() { long start; long end; GetSelection(&start, &end); int len = end - start; if (!len) { wxCharBuffer empty; return empty; } wxCharBuffer buf(len); SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data()); return buf; } wxCharBuffer wxScintillaTextCtrl::GetTextRangeRaw(int startPos, int endPos) { if (endPos < startPos) { int temp = startPos; startPos = endPos; endPos = temp; } int len = endPos - startPos; if (!len) { wxCharBuffer empty; return empty; } wxCharBuffer buf(len); TextRange tr; tr.lpstrText = buf.data(); tr.chrg.cpMin = startPos; tr.chrg.cpMax = endPos; SendMsg(SCI_GETTEXTRANGE, 0, (sptr_t)&tr); return buf; } void wxScintillaTextCtrl::SetTextRaw(const char* text) { SendMsg(SCI_SETTEXT, 0, (sptr_t)text); } wxCharBuffer wxScintillaTextCtrl::GetTextRaw() { int len = GetTextLength(); wxCharBuffer buf(len); // adds 1 for NUL automatically SendMsg(SCI_GETTEXT, len + 1, (sptr_t)buf.data()); return buf; } void wxScintillaTextCtrl::AppendTextRaw(const char* text) { SendMsg(SCI_APPENDTEXT, strlen(text), (sptr_t)text); } //---------------------------------------------------------------------- // Event handlers void wxScintillaTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) { wxPaintDC dc(this); m_swx->DoPaint(&dc, GetUpdateRegion().GetBox()); } void wxScintillaTextCtrl::OnScrollWin(wxScrollWinEvent& evt) { if (evt.GetOrientation() == wxHORIZONTAL) m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition()); else m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition()); } void wxScintillaTextCtrl::OnScroll(wxScrollEvent& evt) { wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar); if (sb) { if (sb->IsVertical()) m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition()); else m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition()); } } void wxScintillaTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) { if (m_swx) { wxSize sz = GetClientSize(); m_swx->DoSize(sz.x, sz.y); } } void wxScintillaTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) { SetFocus(); wxPoint pt = evt.GetPosition(); m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(), evt.ShiftDown(), evt.ControlDown(), evt.AltDown()); } void wxScintillaTextCtrl::OnMouseMove(wxMouseEvent& evt) { wxPoint pt = evt.GetPosition(); m_swx->DoLeftButtonMove(Point(pt.x, pt.y)); } void wxScintillaTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) { wxPoint pt = evt.GetPosition(); m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(), evt.ControlDown()); } void wxScintillaTextCtrl::OnMouseRightUp(wxMouseEvent& evt) { wxPoint pt = evt.GetPosition(); m_swx->DoContextMenu(Point(pt.x, pt.y)); } void wxScintillaTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) { wxPoint pt = evt.GetPosition(); m_swx->DoMiddleButtonUp(Point(pt.x, pt.y)); } void wxScintillaTextCtrl::OnContextMenu(wxContextMenuEvent& evt) { wxPoint pt = evt.GetPosition(); ScreenToClient(&pt.x, &pt.y); /* Show context menu at event point if it's within the window, or at caret location if not */ wxHitTest ht = this->HitTest(pt); if (ht != wxHT_WINDOW_INSIDE) { pt = this->PointFromPosition(this->GetCurrentPos()); } m_swx->DoContextMenu(Point(pt.x, pt.y)); } void wxScintillaTextCtrl::OnMouseWheel(wxMouseEvent& evt) { // prevent having an event queue with wheel events that cannot be processed // reasonably fast (see ticket #9057) if ( m_lastWheelTimestamp <= evt.GetTimestamp() ) { m_lastWheelTimestamp = m_stopWatch.Time(); m_swx->DoMouseWheel(evt.GetWheelRotation(), evt.GetWheelDelta(), evt.GetLinesPerAction(), evt.ControlDown(), evt.IsPageScroll()); m_lastWheelTimestamp = m_stopWatch.Time() - m_lastWheelTimestamp; m_lastWheelTimestamp += evt.GetTimestamp(); } } void wxScintillaTextCtrl::OnChar(wxKeyEvent& evt) { // On (some?) non-US PC keyboards the AltGr key is required to enter some // common characters. It comes to us as both Alt and Ctrl down so we need // to let the char through in that case, otherwise if only ctrl or only // alt let's skip it. bool ctrl = evt.ControlDown(); #ifdef __WXMAC__ // On the Mac the Alt key is just a modifier key (like Shift) so we need // to allow the char events to be processed when Alt is pressed. // TODO: Should we check MetaDown instead in this case? bool alt = false; #else bool alt = evt.AltDown(); #endif bool skip = ((ctrl || alt) && ! (ctrl && alt)); #if wxUSE_UNICODE // apparently if we don't do this, Unicode keys pressed after non-char // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989) if (m_lastKeyDownConsumed && evt.GetUnicodeKey() > 255) m_lastKeyDownConsumed = false; #endif if (!m_lastKeyDownConsumed && !skip) { #if wxUSE_UNICODE int key = evt.GetUnicodeKey(); bool keyOk = true; // if the unicode key code is not really a unicode character (it may // be a function key or etc., the platforms appear to always give us a // small value in this case) then fallback to the ascii key code but // don't do anything for function keys or etc. if (key <= 127) { key = evt.GetKeyCode(); keyOk = (key <= 127); } if (keyOk) { m_swx->DoAddChar(key); return; } #else int key = evt.GetKeyCode(); if (key <= WXK_START || key > WXK_COMMAND) { m_swx->DoAddChar(key); return; } #endif } evt.Skip(); } void wxScintillaTextCtrl::OnKeyDown(wxKeyEvent& evt) { int processed = m_swx->DoKeyDown(evt, &m_lastKeyDownConsumed); if (!processed && !m_lastKeyDownConsumed) evt.Skip(); } void wxScintillaTextCtrl::OnLoseFocus(wxFocusEvent& evt) { m_swx->DoLoseFocus(); evt.Skip(); } void wxScintillaTextCtrl::OnGainFocus(wxFocusEvent& evt) { m_swx->DoGainFocus(); evt.Skip(); } void wxScintillaTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) { m_swx->DoSysColourChange(); } void wxScintillaTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) { // do nothing to help avoid flashing } void wxScintillaTextCtrl::OnMenu(wxCommandEvent& evt) { m_swx->DoCommand(evt.GetId()); } void wxScintillaTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) { m_swx->DoOnListBox(); } void wxScintillaTextCtrl::OnIdle(wxIdleEvent& evt) { m_swx->DoOnIdle(evt); } wxSize wxScintillaTextCtrl::DoGetBestSize() { // What would be the best size for a wxSTC? // Just give a reasonable minimum until something else can be figured out. return wxSize(200,100); } //---------------------------------------------------------------------- // Turn notifications from Scintilla into events void wxScintillaTextCtrl::NotifyChange() { wxScintillaTextEvent evt(wxEVT_STC_CHANGE, GetId()); evt.SetEventObject(this); GetEventHandler()->ProcessEvent(evt); } static void SetEventText(wxScintillaTextEvent& evt, const char* text, size_t length) { if(!text) return; evt.SetText(stc2wx(text, length)); } void wxScintillaTextCtrl::NotifyParent(SCNotification* _scn) { SCNotification& scn = *_scn; wxScintillaTextEvent evt(0, GetId()); evt.SetEventObject(this); evt.SetPosition(scn.position); evt.SetKey(scn.ch); evt.SetModifiers(scn.modifiers); switch (scn.nmhdr.code) { case SCN_STYLENEEDED: evt.SetEventType(wxEVT_STC_STYLENEEDED); break; case SCN_CHARADDED: evt.SetEventType(wxEVT_STC_CHARADDED); break; case SCN_SAVEPOINTREACHED: evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED); break; case SCN_SAVEPOINTLEFT: evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT); break; case SCN_MODIFYATTEMPTRO: evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT); break; case SCN_KEY: evt.SetEventType(wxEVT_STC_KEY); break; case SCN_DOUBLECLICK: evt.SetEventType(wxEVT_STC_DOUBLECLICK); break; case SCN_UPDATEUI: evt.SetEventType(wxEVT_STC_UPDATEUI); break; case SCN_MODIFIED: evt.SetEventType(wxEVT_STC_MODIFIED); evt.SetModificationType(scn.modificationType); SetEventText(evt, scn.text, scn.length); evt.SetLength(scn.length); evt.SetLinesAdded(scn.linesAdded); evt.SetLine(scn.line); evt.SetFoldLevelNow(scn.foldLevelNow); evt.SetFoldLevelPrev(scn.foldLevelPrev); break; case SCN_MACRORECORD: evt.SetEventType(wxEVT_STC_MACRORECORD); evt.SetMessage(scn.message); evt.SetWParam(scn.wParam); evt.SetLParam(scn.lParam); break; case SCN_MARGINCLICK: evt.SetEventType(wxEVT_STC_MARGINCLICK); evt.SetMargin(scn.margin); break; case SCN_NEEDSHOWN: evt.SetEventType(wxEVT_STC_NEEDSHOWN); evt.SetLength(scn.length); break; case SCN_PAINTED: evt.SetEventType(wxEVT_STC_PAINTED); break; case SCN_AUTOCSELECTION: evt.SetEventType(wxEVT_STC_AUTOCOMP_SELECTION); evt.SetListType(scn.listType); SetEventText(evt, scn.text, strlen(scn.text)); evt.SetPosition(scn.lParam); break; case SCN_USERLISTSELECTION: evt.SetEventType(wxEVT_STC_USERLISTSELECTION); evt.SetListType(scn.listType); SetEventText(evt, scn.text, strlen(scn.text)); evt.SetPosition(scn.lParam); break; case SCN_URIDROPPED: evt.SetEventType(wxEVT_STC_URIDROPPED); SetEventText(evt, scn.text, strlen(scn.text)); break; case SCN_DWELLSTART: evt.SetEventType(wxEVT_STC_DWELLSTART); evt.SetX(scn.x); evt.SetY(scn.y); break; case SCN_DWELLEND: evt.SetEventType(wxEVT_STC_DWELLEND); evt.SetX(scn.x); evt.SetY(scn.y); break; case SCN_ZOOM: evt.SetEventType(wxEVT_STC_ZOOM); break; case SCN_HOTSPOTCLICK: evt.SetEventType(wxEVT_STC_HOTSPOT_CLICK); break; case SCN_HOTSPOTDOUBLECLICK: evt.SetEventType(wxEVT_STC_HOTSPOT_DCLICK); break; case SCN_CALLTIPCLICK: evt.SetEventType(wxEVT_STC_CALLTIP_CLICK); break; case SCN_INDICATORCLICK: evt.SetEventType(wxEVT_STC_INDICATOR_CLICK); break; case SCN_INDICATORRELEASE: evt.SetEventType(wxEVT_STC_INDICATOR_RELEASE); break; case SCN_AUTOCCANCELLED: evt.SetEventType(wxEVT_STC_AUTOCOMP_CANCELLED); break; case SCN_AUTOCCHARDELETED: evt.SetEventType(wxEVT_STC_AUTOCOMP_CHAR_DELETED); break; default: return; } GetEventHandler()->ProcessEvent(evt); } //---------------------------------------------------------------------- //---------------------------------------------------------------------- //---------------------------------------------------------------------- wxScintillaTextEvent::wxScintillaTextEvent(wxEventType commandType, int id) : wxCommandEvent(commandType, id) { m_position = 0; m_key = 0; m_modifiers = 0; m_modificationType = 0; m_length = 0; m_linesAdded = 0; m_line = 0; m_foldLevelNow = 0; m_foldLevelPrev = 0; m_margin = 0; m_message = 0; m_wParam = 0; m_lParam = 0; m_listType = 0; m_x = 0; m_y = 0; m_dragAllowMove = false; #if wxUSE_DRAG_AND_DROP m_dragResult = wxDragNone; #endif } bool wxScintillaTextEvent::GetShift() { return (m_modifiers & SCI_SHIFT) != 0; } bool wxScintillaTextEvent::GetControl() { return (m_modifiers & SCI_CTRL) != 0; } bool wxScintillaTextEvent::GetAlt() { return (m_modifiers & SCI_ALT) != 0; } wxScintillaTextEvent::wxScintillaTextEvent(const wxScintillaTextEvent& event): wxCommandEvent(event) { m_position = event.m_position; m_key = event.m_key; m_modifiers = event.m_modifiers; m_modificationType = event.m_modificationType; m_text = event.m_text; m_length = event.m_length; m_linesAdded = event.m_linesAdded; m_line = event.m_line; m_foldLevelNow = event.m_foldLevelNow; m_foldLevelPrev = event.m_foldLevelPrev; m_margin = event.m_margin; m_message = event.m_message; m_wParam = event.m_wParam; m_lParam = event.m_lParam; m_listType = event.m_listType; m_x = event.m_x; m_y = event.m_y; m_dragText = event.m_dragText; m_dragAllowMove =event.m_dragAllowMove; #if wxUSE_DRAG_AND_DROP m_dragResult = event.m_dragResult; #endif } //---------------------------------------------------------------------- //---------------------------------------------------------------------- Wx-Scintilla-0.39/wx-scintilla/src/scintilla000755001750001750 012021352777 21451 5ustar00azawawiazawawi000000000000Wx-Scintilla-0.39/wx-scintilla/src/scintilla/License.txt000444001750001750 154412021352777 23735 0ustar00azawawiazawawi000000000000License for Scintilla and SciTE Copyright 1998-2003 by Neil Hodgson All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. NEIL HODGSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NEIL HODGSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Wx-Scintilla-0.39/wx-scintilla/src/scintilla/README.txt000444001750001750 142012021352777 23301 0ustar00azawawiazawawi000000000000This folder contains copies of the scintilla/src, scintilla/lexers and scintilla/include folders from the Scintilla source distribution. The source distribution is located in http://prdownloads.sourceforge.net/scintilla/scite304.zip?download Please note that 'scintilla/lexers' is currently copied into the scintilla/src folder. Unneeded *.py was removed. Why? We love Python :) Unneeded *.properties files are also removed. We also have the experimental LexPerl6.cxx and a modified scintilla/src/SciLexer.h to include the Perl 6 syntax highlighter (i.e. lexer). Once it is stable, we will push it upstream again. wxWidgets-specific code to embed Scintilla as a wxWidgets editor component is located in the parent folder. The current version of the Scintilla code is 3.0.2.Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src000755001750001750 012021352777 22240 5ustar00azawawiazawawi000000000000Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexMySQL.cxx000444001750001750 4157012021352777 24566 0ustar00azawawiazawawi000000000000/** * Scintilla source code edit control * @file LexMySQL.cxx * Lexer for MySQL * * Improved by Mike Lischke * Adopted from LexSQL.cxx by Anders Karlsson * Original work by Neil Hodgson * Copyright 1998-2005 by Neil Hodgson * The License.txt file describes the conditions under which this software may be distributed. */ #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static inline bool IsAWordChar(int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } static inline bool IsAWordStart(int ch) { return (ch < 0x80) && (isalpha(ch) || ch == '_'); } static inline bool IsADoxygenChar(int ch) { return (islower(ch) || ch == '$' || ch == '@' || ch == '\\' || ch == '&' || ch == '<' || ch == '>' || ch == '#' || ch == '{' || ch == '}' || ch == '[' || ch == ']'); } static inline bool IsANumberChar(int ch) { // Not exactly following number definition (several dots are seen as OK, etc.) // but probably enough in most cases. return (ch < 0x80) && (isdigit(ch) || toupper(ch) == 'E' || ch == '.' || ch == '-' || ch == '+'); } //-------------------------------------------------------------------------------------------------- /** * Check if the current content context represent a keyword and set the context state if so. */ static void CheckForKeyword(StyleContext& sc, WordList* keywordlists[]) { int length = sc.LengthCurrent() + 1; // +1 for the next char char* s = new char[length]; sc.GetCurrentLowered(s, length); if (keywordlists[0]->InList(s)) sc.ChangeState(SCE_MYSQL_MAJORKEYWORD); else if (keywordlists[1]->InList(s)) sc.ChangeState(SCE_MYSQL_KEYWORD); else if (keywordlists[2]->InList(s)) sc.ChangeState(SCE_MYSQL_DATABASEOBJECT); else if (keywordlists[3]->InList(s)) sc.ChangeState(SCE_MYSQL_FUNCTION); else if (keywordlists[5]->InList(s)) sc.ChangeState(SCE_MYSQL_PROCEDUREKEYWORD); else if (keywordlists[6]->InList(s)) sc.ChangeState(SCE_MYSQL_USER1); else if (keywordlists[7]->InList(s)) sc.ChangeState(SCE_MYSQL_USER2); else if (keywordlists[8]->InList(s)) sc.ChangeState(SCE_MYSQL_USER3); delete [] s; } //-------------------------------------------------------------------------------------------------- static void ColouriseMySQLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { // Determine if the current state should terminate. switch (sc.state) { case SCE_MYSQL_OPERATOR: sc.SetState(SCE_MYSQL_DEFAULT); break; case SCE_MYSQL_NUMBER: // We stop the number definition on non-numerical non-dot non-eE non-sign char. if (!IsANumberChar(sc.ch)) sc.SetState(SCE_MYSQL_DEFAULT); break; case SCE_MYSQL_IDENTIFIER: // Switch from identifier to keyword state and open a new state for the new char. if (!IsAWordChar(sc.ch)) { CheckForKeyword(sc, keywordlists); // Additional check for function keywords needed. // A function name must be followed by an opening parenthesis. if (sc.state == SCE_MYSQL_FUNCTION && sc.ch != '(') sc.ChangeState(SCE_MYSQL_DEFAULT); sc.SetState(SCE_MYSQL_DEFAULT); } break; case SCE_MYSQL_VARIABLE: if (!IsAWordChar(sc.ch)) sc.SetState(SCE_MYSQL_DEFAULT); break; case SCE_MYSQL_SYSTEMVARIABLE: if (!IsAWordChar(sc.ch)) { int length = sc.LengthCurrent() + 1; char* s = new char[length]; sc.GetCurrentLowered(s, length); // Check for known system variables here. if (keywordlists[4]->InList(&s[2])) sc.ChangeState(SCE_MYSQL_KNOWNSYSTEMVARIABLE); delete [] s; sc.SetState(SCE_MYSQL_DEFAULT); } break; case SCE_MYSQL_QUOTEDIDENTIFIER: if (sc.ch == '`') { if (sc.chNext == '`') sc.Forward(); // Ignore it else sc.ForwardSetState(SCE_MYSQL_DEFAULT); } break; case SCE_MYSQL_COMMENT: case SCE_MYSQL_HIDDENCOMMAND: if (sc.Match('*', '/')) { sc.Forward(); sc.ForwardSetState(SCE_MYSQL_DEFAULT); } break; case SCE_MYSQL_COMMENTLINE: if (sc.atLineStart) sc.SetState(SCE_MYSQL_DEFAULT); break; case SCE_MYSQL_SQSTRING: if (sc.ch == '\\') sc.Forward(); // Escape sequence else if (sc.ch == '\'') { // End of single quoted string reached? if (sc.chNext == '\'') sc.Forward(); else sc.ForwardSetState(SCE_MYSQL_DEFAULT); } break; case SCE_MYSQL_DQSTRING: if (sc.ch == '\\') sc.Forward(); // Escape sequence else if (sc.ch == '\"') { // End of single quoted string reached? if (sc.chNext == '\"') sc.Forward(); else sc.ForwardSetState(SCE_MYSQL_DEFAULT); } break; } // Determine if a new state should be entered. if (sc.state == SCE_MYSQL_DEFAULT) { switch (sc.ch) { case '@': if (sc.chNext == '@') { sc.SetState(SCE_MYSQL_SYSTEMVARIABLE); sc.Forward(2); // Skip past @@. } else if (IsAWordStart(sc.ch)) { sc.SetState(SCE_MYSQL_VARIABLE); sc.Forward(); // Skip past @. } else sc.SetState(SCE_MYSQL_OPERATOR); break; case '`': sc.SetState(SCE_MYSQL_QUOTEDIDENTIFIER); break; case '#': sc.SetState(SCE_MYSQL_COMMENTLINE); break; case '\'': sc.SetState(SCE_MYSQL_SQSTRING); break; case '\"': sc.SetState(SCE_MYSQL_DQSTRING); break; default: if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) sc.SetState(SCE_MYSQL_NUMBER); else if (IsAWordStart(sc.ch)) sc.SetState(SCE_MYSQL_IDENTIFIER); else if (sc.Match('/', '*')) { sc.SetState(SCE_MYSQL_COMMENT); // Skip comment introducer and check for hidden command. sc.Forward(2); if (sc.ch == '!') { sc.ChangeState(SCE_MYSQL_HIDDENCOMMAND); sc.Forward(); } } else if (sc.Match("--")) { // Special MySQL single line comment. sc.SetState(SCE_MYSQL_COMMENTLINE); sc.Forward(2); // Check the third character too. It must be a space or EOL. if (sc.ch != ' ' && sc.ch != '\n' && sc.ch != '\r') sc.ChangeState(SCE_MYSQL_OPERATOR); } else if (isoperator(static_cast(sc.ch))) sc.SetState(SCE_MYSQL_OPERATOR); } } } // Do a final check for keywords if we currently have an identifier, to highlight them // also at the end of a line. if (sc.state == SCE_MYSQL_IDENTIFIER) { CheckForKeyword(sc, keywordlists); // Additional check for function keywords needed. // A function name must be followed by an opening parenthesis. if (sc.state == SCE_MYSQL_FUNCTION && sc.ch != '(') sc.ChangeState(SCE_MYSQL_DEFAULT); } sc.Complete(); } //-------------------------------------------------------------------------------------------------- /** * Helper function to determine if we have a foldable comment currently. */ static bool IsStreamCommentStyle(int style) { return style == SCE_MYSQL_COMMENT; } //-------------------------------------------------------------------------------------------------- /** * Code copied from StyleContext and modified to work here. Should go into Accessor as a * companion to Match()... */ bool MatchIgnoreCase(Accessor &styler, int currentPos, const char *s) { for (int n = 0; *s; n++) { if (*s != tolower(styler.SafeGetCharAt(currentPos + n))) return false; s++; } return true; } //-------------------------------------------------------------------------------------------------- // Store both the current line's fold level and the next lines in the // level store to make it easy to pick up with each increment. static void FoldMySQLDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; bool foldOnlyBegin = styler.GetPropertyInt("fold.sql.only.begin", 0) != 0; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent - 1) >> 16; int levelNext = levelCurrent; int styleNext = styler.StyleAt(startPos); int style = initStyle; bool endPending = false; bool whenPending = false; bool elseIfPending = false; char nextChar = styler.SafeGetCharAt(startPos); for (unsigned int i = startPos; length > 0; i++, length--) { int stylePrev = style; style = styleNext; styleNext = styler.StyleAt(i + 1); char currentChar = nextChar; nextChar = styler.SafeGetCharAt(i + 1); bool atEOL = (currentChar == '\r' && nextChar != '\n') || (currentChar == '\n'); switch (style) { case SCE_MYSQL_COMMENT: if (foldComment) { // Multiline comment style /* .. */. if (IsStreamCommentStyle(style)) { // Increase level if we just start a foldable comment. if (!IsStreamCommentStyle(stylePrev)) levelNext++; else // If we are in the middle of a foldable comment check if it ends now. // Don't end at the line end, though. if (!IsStreamCommentStyle(styleNext) && !atEOL) levelNext--; } } break; case SCE_MYSQL_COMMENTLINE: if (foldComment) { // Not really a standard, but we add support for single line comments // with special curly braces syntax as foldable comments too. // MySQL needs -- comments to be followed by space or control char if (styler.Match(i, "--")) { char chNext2 = styler.SafeGetCharAt(i + 2); char chNext3 = styler.SafeGetCharAt(i + 3); if (chNext2 == '{' || chNext3 == '{') levelNext++; else if (chNext2 == '}' || chNext3 == '}') levelNext--; } } break; case SCE_MYSQL_HIDDENCOMMAND: if (endPending) { // A conditional command is not a white space so it should end the current block // before opening a new one. endPending = false; levelNext--; if (levelNext < SC_FOLDLEVELBASE) levelNext = SC_FOLDLEVELBASE; } if (style != stylePrev) levelNext++; else if (style != styleNext) { levelNext--; if (levelNext < SC_FOLDLEVELBASE) levelNext = SC_FOLDLEVELBASE; } break; case SCE_MYSQL_OPERATOR: if (endPending) { endPending = false; levelNext--; if (levelNext < SC_FOLDLEVELBASE) levelNext = SC_FOLDLEVELBASE; } if (currentChar == '(') levelNext++; else if (currentChar == ')') { levelNext--; if (levelNext < SC_FOLDLEVELBASE) levelNext = SC_FOLDLEVELBASE; } break; case SCE_MYSQL_MAJORKEYWORD: case SCE_MYSQL_KEYWORD: case SCE_MYSQL_FUNCTION: case SCE_MYSQL_PROCEDUREKEYWORD: // Reserved and other keywords. if (style != stylePrev) { // END decreases the folding level, regardless which keyword follows. bool endFound = MatchIgnoreCase(styler, i, "end"); if (endPending) { levelNext--; if (levelNext < SC_FOLDLEVELBASE) levelNext = SC_FOLDLEVELBASE; } else if (!endFound) { if (MatchIgnoreCase(styler, i, "begin")) levelNext++; else { if (!foldOnlyBegin) { bool whileFound = MatchIgnoreCase(styler, i, "while"); bool loopFound = MatchIgnoreCase(styler, i, "loop"); bool repeatFound = MatchIgnoreCase(styler, i, "repeat"); bool caseFound = MatchIgnoreCase(styler, i, "case"); if (whileFound || loopFound || repeatFound || caseFound) levelNext++; else { // IF alone does not increase the fold level as it is also used in non-block'ed // code like DROP PROCEDURE blah IF EXISTS. // Instead THEN opens the new level (if not part of an ELSEIF or WHEN (case) branch). if (MatchIgnoreCase(styler, i, "then")) { if (!elseIfPending && !whenPending) levelNext++; else { elseIfPending = false; whenPending = false; } } else { // Neither of if/then/while/loop/repeat/case, so check for // sub parts of IF and CASE. if (MatchIgnoreCase(styler, i, "elseif")) elseIfPending = true; if (MatchIgnoreCase(styler, i, "when")) whenPending = true; } } } } } // Keep the current end state for the next round. endPending = endFound; } break; default: if (!isspace(currentChar) && endPending) { // END followed by a non-whitespace character (not covered by other cases like identifiers) // also should end a folding block. Typical case: END followed by self defined delimiter. levelNext--; if (levelNext < SC_FOLDLEVELBASE) levelNext = SC_FOLDLEVELBASE; } break; } if (atEOL) { // Apply the new folding level to this line. // Leave pending states as they are otherwise a line break will de-sync // code folding and valid syntax. int levelUse = levelCurrent; int lev = levelUse | levelNext << 16; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if (levelUse < levelNext) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) styler.SetLevel(lineCurrent, lev); lineCurrent++; levelCurrent = levelNext; visibleChars = 0; } if (!isspacechar(currentChar)) visibleChars++; } } //-------------------------------------------------------------------------------------------------- static const char * const mysqlWordListDesc[] = { "Major Keywords", "Keywords", "Database Objects", "Functions", "System Variables", "Procedure keywords", "User Keywords 1", "User Keywords 2", "User Keywords 3", 0 }; LexerModule lmMySQL(SCLEX_MYSQL, ColouriseMySQLDoc, "mysql", FoldMySQLDoc, mysqlWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/AutoComplete.cxx000444001750001750 774612021352777 25540 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file AutoComplete.cxx ** Defines the auto completion list box. **/ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include "Platform.h" #include "CharacterSet.h" #include "AutoComplete.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif AutoComplete::AutoComplete() : active(false), separator(' '), typesep('?'), ignoreCase(false), chooseSingle(false), lb(0), posStart(0), startLen(0), cancelAtStartPos(true), autoHide(true), dropRestOfWord(false) { lb = ListBox::Allocate(); stopChars[0] = '\0'; fillUpChars[0] = '\0'; } AutoComplete::~AutoComplete() { if (lb) { lb->Destroy(); delete lb; lb = 0; } } bool AutoComplete::Active() const { return active; } void AutoComplete::Start(Window &parent, int ctrlID, int position, Point location, int startLen_, int lineHeight, bool unicodeMode, int technology) { if (active) { Cancel(); } lb->Create(parent, ctrlID, location, lineHeight, unicodeMode, technology); lb->Clear(); active = true; startLen = startLen_; posStart = position; } void AutoComplete::SetStopChars(const char *stopChars_) { strncpy(stopChars, stopChars_, sizeof(stopChars)); stopChars[sizeof(stopChars) - 1] = '\0'; } bool AutoComplete::IsStopChar(char ch) { return ch && strchr(stopChars, ch); } void AutoComplete::SetFillUpChars(const char *fillUpChars_) { strncpy(fillUpChars, fillUpChars_, sizeof(fillUpChars)); fillUpChars[sizeof(fillUpChars) - 1] = '\0'; } bool AutoComplete::IsFillUpChar(char ch) { return ch && strchr(fillUpChars, ch); } void AutoComplete::SetSeparator(char separator_) { separator = separator_; } char AutoComplete::GetSeparator() const { return separator; } void AutoComplete::SetTypesep(char separator_) { typesep = separator_; } char AutoComplete::GetTypesep() const { return typesep; } void AutoComplete::SetList(const char *list) { lb->SetList(list, separator, typesep); } void AutoComplete::Show(bool show) { lb->Show(show); if (show) lb->Select(0); } void AutoComplete::Cancel() { if (lb->Created()) { lb->Clear(); lb->Destroy(); active = false; } } void AutoComplete::Move(int delta) { int count = lb->Length(); int current = lb->GetSelection(); current += delta; if (current >= count) current = count - 1; if (current < 0) current = 0; lb->Select(current); } void AutoComplete::Select(const char *word) { size_t lenWord = strlen(word); int location = -1; const int maxItemLen=1000; int start = 0; // lower bound of the api array block to search int end = lb->Length() - 1; // upper bound of the api array block to search while ((start <= end) && (location == -1)) { // Binary searching loop int pivot = (start + end) / 2; char item[maxItemLen]; lb->GetValue(pivot, item, maxItemLen); int cond; if (ignoreCase) cond = CompareNCaseInsensitive(word, item, lenWord); else cond = strncmp(word, item, lenWord); if (!cond) { // Find first match while (pivot > start) { lb->GetValue(pivot-1, item, maxItemLen); if (ignoreCase) cond = CompareNCaseInsensitive(word, item, lenWord); else cond = strncmp(word, item, lenWord); if (0 != cond) break; --pivot; } location = pivot; if (ignoreCase) { // Check for exact-case match for (; pivot <= end; pivot++) { lb->GetValue(pivot, item, maxItemLen); if (!strncmp(word, item, lenWord)) { location = pivot; break; } if (CompareNCaseInsensitive(word, item, lenWord)) break; } } } else if (cond < 0) { end = pivot - 1; } else if (cond > 0) { start = pivot + 1; } } if (location == -1 && autoHide) Cancel(); else lb->Select(location); } Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexLisp.cxx000444001750001750 2060112021352776 24517 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexLisp.cxx ** Lexer for Lisp. ** Written by Alexey Yutkin. **/ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif #define SCE_LISP_CHARACTER 29 #define SCE_LISP_MACRO 30 #define SCE_LISP_MACRO_DISPATCH 31 static inline bool isLispoperator(char ch) { if (isascii(ch) && isalnum(ch)) return false; if (ch == '\'' || ch == '`' || ch == '(' || ch == ')' || ch == '[' || ch == ']' || ch == '{' || ch == '}') return true; return false; } static inline bool isLispwordstart(char ch) { return isascii(ch) && ch != ';' && !isspacechar(ch) && !isLispoperator(ch) && ch != '\n' && ch != '\r' && ch != '\"'; } static void classifyWordLisp(unsigned int start, unsigned int end, WordList &keywords, WordList &keywords_kw, Accessor &styler) { assert(end >= start); char s[100]; unsigned int i; bool digit_flag = true; for (i = 0; (i < end - start + 1) && (i < 99); i++) { s[i] = styler[start + i]; s[i + 1] = '\0'; if (!isdigit(s[i]) && (s[i] != '.')) digit_flag = false; } char chAttr = SCE_LISP_IDENTIFIER; if(digit_flag) chAttr = SCE_LISP_NUMBER; else { if (keywords.InList(s)) { chAttr = SCE_LISP_KEYWORD; } else if (keywords_kw.InList(s)) { chAttr = SCE_LISP_KEYWORD_KW; } else if ((s[0] == '*' && s[i-1] == '*') || (s[0] == '+' && s[i-1] == '+')) { chAttr = SCE_LISP_SPECIAL; } } styler.ColourTo(end, chAttr); return; } static void ColouriseLispDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; WordList &keywords_kw = *keywordlists[1]; styler.StartAt(startPos); int state = initStyle, radix = -1; char chNext = styler[startPos]; unsigned int lengthDoc = startPos + length; styler.StartSegment(startPos); for (unsigned int i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (styler.IsLeadByte(ch)) { chNext = styler.SafeGetCharAt(i + 2); i += 1; continue; } if (state == SCE_LISP_DEFAULT) { if (ch == '#') { styler.ColourTo(i - 1, state); radix = -1; state = SCE_LISP_MACRO_DISPATCH; } else if (ch == ':' && isLispwordstart(chNext)) { styler.ColourTo(i - 1, state); state = SCE_LISP_SYMBOL; } else if (isLispwordstart(ch)) { styler.ColourTo(i - 1, state); state = SCE_LISP_IDENTIFIER; } else if (ch == ';') { styler.ColourTo(i - 1, state); state = SCE_LISP_COMMENT; } else if (isLispoperator(ch) || ch=='\'') { styler.ColourTo(i - 1, state); styler.ColourTo(i, SCE_LISP_OPERATOR); if (ch=='\'' && isLispwordstart(chNext)) { state = SCE_LISP_SYMBOL; } } else if (ch == '\"') { styler.ColourTo(i - 1, state); state = SCE_LISP_STRING; } } else if (state == SCE_LISP_IDENTIFIER || state == SCE_LISP_SYMBOL) { if (!isLispwordstart(ch)) { if (state == SCE_LISP_IDENTIFIER) { classifyWordLisp(styler.GetStartSegment(), i - 1, keywords, keywords_kw, styler); } else { styler.ColourTo(i - 1, state); } state = SCE_LISP_DEFAULT; } /*else*/ if (isLispoperator(ch) || ch=='\'') { styler.ColourTo(i - 1, state); styler.ColourTo(i, SCE_LISP_OPERATOR); if (ch=='\'' && isLispwordstart(chNext)) { state = SCE_LISP_SYMBOL; } } } else if (state == SCE_LISP_MACRO_DISPATCH) { if (!(isascii(ch) && isdigit(ch))) { if (ch != 'r' && ch != 'R' && (i - styler.GetStartSegment()) > 1) { state = SCE_LISP_DEFAULT; } else { switch (ch) { case '|': state = SCE_LISP_MULTI_COMMENT; break; case 'o': case 'O': radix = 8; state = SCE_LISP_MACRO; break; case 'x': case 'X': radix = 16; state = SCE_LISP_MACRO; break; case 'b': case 'B': radix = 2; state = SCE_LISP_MACRO; break; case '\\': state = SCE_LISP_CHARACTER; break; case ':': case '-': case '+': state = SCE_LISP_MACRO; break; case '\'': if (isLispwordstart(chNext)) { state = SCE_LISP_SPECIAL; } else { styler.ColourTo(i - 1, SCE_LISP_DEFAULT); styler.ColourTo(i, SCE_LISP_OPERATOR); state = SCE_LISP_DEFAULT; } break; default: if (isLispoperator(ch)) { styler.ColourTo(i - 1, SCE_LISP_DEFAULT); styler.ColourTo(i, SCE_LISP_OPERATOR); } state = SCE_LISP_DEFAULT; break; } } } } else if (state == SCE_LISP_MACRO) { if (isLispwordstart(ch) && (radix == -1 || IsADigit(ch, radix))) { state = SCE_LISP_SPECIAL; } else { state = SCE_LISP_DEFAULT; } } else if (state == SCE_LISP_CHARACTER) { if (isLispoperator(ch)) { styler.ColourTo(i, SCE_LISP_SPECIAL); state = SCE_LISP_DEFAULT; } else if (isLispwordstart(ch)) { styler.ColourTo(i, SCE_LISP_SPECIAL); state = SCE_LISP_SPECIAL; } else { state = SCE_LISP_DEFAULT; } } else if (state == SCE_LISP_SPECIAL) { if (!isLispwordstart(ch) || (radix != -1 && !IsADigit(ch, radix))) { styler.ColourTo(i - 1, state); state = SCE_LISP_DEFAULT; } if (isLispoperator(ch) || ch=='\'') { styler.ColourTo(i - 1, state); styler.ColourTo(i, SCE_LISP_OPERATOR); if (ch=='\'' && isLispwordstart(chNext)) { state = SCE_LISP_SYMBOL; } } } else { if (state == SCE_LISP_COMMENT) { if (atEOL) { styler.ColourTo(i - 1, state); state = SCE_LISP_DEFAULT; } } else if (state == SCE_LISP_MULTI_COMMENT) { if (ch == '|' && chNext == '#') { i++; chNext = styler.SafeGetCharAt(i + 1); styler.ColourTo(i, state); state = SCE_LISP_DEFAULT; } } else if (state == SCE_LISP_STRING) { if (ch == '\\') { if (chNext == '\"' || chNext == '\'' || chNext == '\\') { i++; chNext = styler.SafeGetCharAt(i + 1); } } else if (ch == '\"') { styler.ColourTo(i, state); state = SCE_LISP_DEFAULT; } } } } styler.ColourTo(lengthDoc - 1, state); } static void FoldLispDoc(unsigned int startPos, int length, int /* initStyle */, WordList *[], Accessor &styler) { unsigned int lengthDoc = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); for (unsigned int i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (style == SCE_LISP_OPERATOR) { if (ch == '(' || ch == '[' || ch == '{') { levelCurrent++; } else if (ch == ')' || ch == ']' || ch == '}') { levelCurrent--; } } if (atEOL) { int lev = levelPrev; if (visibleChars == 0) lev |= SC_FOLDLEVELWHITEFLAG; if ((levelCurrent > levelPrev) && (visibleChars > 0)) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelPrev = levelCurrent; visibleChars = 0; } if (!isspacechar(ch)) visibleChars++; } // Fill in the real level of the next line, keeping the current flags as they will be filled in later int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, levelPrev | flagsNext); } static const char * const lispWordListDesc[] = { "Functions and special operators", "Keywords", 0 }; LexerModule lmLISP(SCLEX_LISP, ColouriseLispDoc, "lisp", FoldLispDoc, lispWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexMagik.cxx000444001750001750 3333412021352777 24650 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** * @file LexMagik.cxx * Lexer for GE(r) Smallworld(tm) MagikSF */ // Copyright 1998-2005 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif /** * Is it a core character (C isalpha(), exclamation and question mark) * * \param ch The character * \return True if ch is a character, False otherwise */ static inline bool IsAlphaCore(int ch) { return (isalpha(ch) || ch == '!' || ch == '?'); } /** * Is it a character (IsAlphaCore() and underscore) * * \param ch The character * \return True if ch is a character, False otherwise */ static inline bool IsAlpha(int ch) { return (IsAlphaCore(ch) || ch == '_'); } /** * Is it a symbolic character (IsAlpha() and colon) * * \param ch The character * \return True if ch is a character, False otherwise */ static inline bool IsAlphaSym(int ch) { return (IsAlpha(ch) || ch == ':'); } /** * Is it a numerical character (IsAlpha() and 0 - 9) * * \param ch The character * \return True if ch is a character, False otherwise */ static inline bool IsAlNum(int ch) { return ((ch >= '0' && ch <= '9') || IsAlpha(ch)); } /** * Is it a symbolic numerical character (IsAlNum() and colon) * * \param ch The character * \return True if ch is a character, False otherwise */ static inline bool IsAlNumSym(int ch) { return (IsAlNum(ch) || ch == ':'); } /** * The lexer function * * \param startPos Where to start scanning * \param length Where to scan to * \param initStyle The style at the initial point, not used in this folder * \param keywordslists The keywordslists, currently, number 5 is used * \param styler The styler */ static void ColouriseMagikDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { styler.StartAt(startPos); WordList &keywords = *keywordlists[0]; WordList &pragmatics = *keywordlists[1]; WordList &containers = *keywordlists[2]; WordList &flow = *keywordlists[3]; WordList &characters = *keywordlists[4]; StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { repeat: if(sc.ch == '#') { if (sc.chNext == '#') sc.SetState(SCE_MAGIK_HYPER_COMMENT); else sc.SetState(SCE_MAGIK_COMMENT); for(; sc.More() && !(sc.atLineEnd); sc.Forward()); sc.SetState(SCE_MAGIK_DEFAULT); goto repeat; } if(sc.ch == '"') { sc.SetState(SCE_MAGIK_STRING); if(sc.More()) { sc.Forward(); for(; sc.More() && sc.ch != '"'; sc.Forward()); } sc.ForwardSetState(SCE_MAGIK_DEFAULT); goto repeat; } // The default state if(sc.state == SCE_MAGIK_DEFAULT) { // A certain keyword has been detected if (sc.ch == '_' && ( sc.currentPos == 0 || !IsAlNum(sc.chPrev))) { char keyword[50]; memset(keyword, '\0', 50); for( int scanPosition = 0; scanPosition < 50; scanPosition++) { char keywordChar = static_cast( tolower(styler.SafeGetCharAt( scanPosition + static_cast(sc.currentPos+1), ' '))); if(IsAlpha(keywordChar)) { keyword[scanPosition] = keywordChar; } else { break; } } // It is a pragma if(pragmatics.InList(keyword)) { sc.SetState(SCE_MAGIK_PRAGMA); } // it is a normal keyword like _local, _self, etc. else if(keywords.InList(keyword)) { sc.SetState(SCE_MAGIK_KEYWORD); } // It is a container keyword, such as _method, _proc, etc. else if(containers.InList(keyword)) { sc.SetState(SCE_MAGIK_CONTAINER); } // It is a flow keyword, such as _for, _if, _try, etc. else if(flow.InList(keyword)) { sc.SetState(SCE_MAGIK_FLOW); } // Interpret as unknown keyword else { sc.SetState(SCE_MAGIK_UNKNOWN_KEYWORD); } } // Symbolic expression else if(sc.ch == ':' && !IsAlNum(sc.chPrev)) { sc.SetState(SCE_MAGIK_SYMBOL); bool firstTrip = true; for(sc.Forward(); sc.More(); sc.Forward()) { if(firstTrip && IsAlphaSym(sc.ch)); else if(!firstTrip && IsAlNumSym(sc.ch)); else if(sc.ch == '|') { for(sc.Forward(); sc.More() && sc.ch != '|'; sc.Forward()); } else break; firstTrip = false; } sc.SetState(SCE_MAGIK_DEFAULT); goto repeat; } // Identifier (label) expression else if(sc.ch == '@') { sc.SetState(SCE_MAGIK_IDENTIFIER); bool firstTrip = true; for(sc.Forward(); sc.More(); sc.Forward()) { if(firstTrip && IsAlphaCore(sc.ch)) { firstTrip = false; } else if(!firstTrip && IsAlpha(sc.ch)); else break; } sc.SetState(SCE_MAGIK_DEFAULT); goto repeat; } // Start of a character else if(sc.ch == '%') { sc.SetState(SCE_MAGIK_CHARACTER); sc.Forward(); char keyword[50]; memset(keyword, '\0', 50); for( int scanPosition = 0; scanPosition < 50; scanPosition++) { char keywordChar = static_cast( tolower(styler.SafeGetCharAt( scanPosition + static_cast(sc.currentPos), ' '))); if(IsAlpha(keywordChar)) { keyword[scanPosition] = keywordChar; } else { break; } } if(characters.InList(keyword)) { sc.Forward(static_cast(strlen(keyword))); } else { sc.Forward(); } sc.SetState(SCE_MAGIK_DEFAULT); goto repeat; } // Operators 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.SetState(SCE_MAGIK_OPERATOR); } // Braces else if(sc.ch == '(' || sc.ch == ')') { sc.SetState(SCE_MAGIK_BRACE_BLOCK); } // Brackets else if(sc.ch == '{' || sc.ch == '}') { sc.SetState(SCE_MAGIK_BRACKET_BLOCK); } // Square Brackets else if(sc.ch == '[' || sc.ch == ']') { sc.SetState(SCE_MAGIK_SQBRACKET_BLOCK); } } // It is an operator else if( sc.state == SCE_MAGIK_OPERATOR || sc.state == SCE_MAGIK_BRACE_BLOCK || sc.state == SCE_MAGIK_BRACKET_BLOCK || sc.state == SCE_MAGIK_SQBRACKET_BLOCK) { sc.SetState(SCE_MAGIK_DEFAULT); goto repeat; } // It is the pragma state else if(sc.state == SCE_MAGIK_PRAGMA) { if(!IsAlpha(sc.ch)) { sc.SetState(SCE_MAGIK_DEFAULT); goto repeat; } } // It is the keyword state else if( sc.state == SCE_MAGIK_KEYWORD || sc.state == SCE_MAGIK_CONTAINER || sc.state == SCE_MAGIK_FLOW || sc.state == SCE_MAGIK_UNKNOWN_KEYWORD) { if(!IsAlpha(sc.ch)) { sc.SetState(SCE_MAGIK_DEFAULT); goto repeat; } } } sc.Complete(); } /** * The word list description */ static const char * const magikWordListDesc[] = { "Accessors (local, global, self, super, thisthread)", "Pragmatic (pragma, private)", "Containers (method, block, proc)", "Flow (if, then, elif, else)", "Characters (space, tab, newline, return)", "Fold Containers (method, proc, block, if, loop)", 0}; /** * This function detects keywords which are able to have a body. Note that it * uses the Fold Containers word description, not the containers description. It * only works when the style at that particular position is set on Containers * or Flow (number 3 or 4). * * \param keywordslist The list of keywords that are scanned, they should only * contain the start keywords, not the end keywords * \param The actual keyword * \return 1 if it is a folding start-keyword, -1 if it is a folding end-keyword * 0 otherwise */ static inline int IsFoldingContainer(WordList &keywordslist, char * keyword) { if( strlen(keyword) > 3 && keyword[0] == 'e' && keyword[1] == 'n' && keyword[2] == 'd') { if (keywordslist.InList(keyword + 3)) { return -1; } } else { if(keywordslist.InList(keyword)) { return 1; } } return 0; } /** * The folding function * * \param startPos Where to start scanning * \param length Where to scan to * \param keywordslists The keywordslists, currently, number 5 is used * \param styler The styler */ static void FoldMagikDoc(unsigned int startPos, int length, int, WordList *keywordslists[], Accessor &styler) { bool compact = styler.GetPropertyInt("fold.compact") != 0; WordList &foldingElements = *keywordslists[5]; int endPos = startPos + length; int line = styler.GetLine(startPos); int level = styler.LevelAt(line) & SC_FOLDLEVELNUMBERMASK; int flags = styler.LevelAt(line) & ~SC_FOLDLEVELNUMBERMASK; for( int currentPos = startPos; currentPos < endPos; currentPos++) { char currentState = styler.StyleAt(currentPos); char c = styler.SafeGetCharAt(currentPos, ' '); int prevLine = styler.GetLine(currentPos - 1); line = styler.GetLine(currentPos); // Default situation if(prevLine < line) { styler.SetLevel(line, (level|flags) & ~SC_FOLDLEVELHEADERFLAG); flags = styler.LevelAt(line) & ~SC_FOLDLEVELNUMBERMASK; } if( ( currentState == SCE_MAGIK_CONTAINER || currentState == SCE_MAGIK_FLOW ) && c == '_') { char keyword[50]; memset(keyword, '\0', 50); for( int scanPosition = 0; scanPosition < 50; scanPosition++) { char keywordChar = static_cast( tolower(styler.SafeGetCharAt( scanPosition + currentPos + 1, ' '))); if(IsAlpha(keywordChar)) { keyword[scanPosition] = keywordChar; } else { break; } } if(IsFoldingContainer(foldingElements, keyword) > 0) { styler.SetLevel( line, styler.LevelAt(line) | SC_FOLDLEVELHEADERFLAG); level++; } else if(IsFoldingContainer(foldingElements, keyword) < 0) { styler.SetLevel(line, styler.LevelAt(line)); level--; } } if( compact && ( currentState == SCE_MAGIK_BRACE_BLOCK || currentState == SCE_MAGIK_BRACKET_BLOCK || currentState == SCE_MAGIK_SQBRACKET_BLOCK)) { if(c == '{' || c == '[' || c == '(') { styler.SetLevel( line, styler.LevelAt(line) | SC_FOLDLEVELHEADERFLAG); level++; } else if(c == '}' || c == ']' || c == ')') { styler.SetLevel(line, styler.LevelAt(line)); level--; } } } } /** * Injecting the module */ LexerModule lmMagikSF( SCLEX_MAGIK, ColouriseMagikDoc, "magiksf", FoldMagikDoc, magikWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/Catalogue.h000444001750001750 111312021352777 24446 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file Catalogue.h ** Lexer infrastructure. **/ // Copyright 1998-2010 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef CATALOGUE_H #define CATALOGUE_H #ifdef SCI_NAMESPACE namespace Scintilla { #endif class Catalogue { public: static const LexerModule *Find(int language); static const LexerModule *Find(const char *languageName); static void AddLexerModule(LexerModule *plm); }; #ifdef SCI_NAMESPACE } #endif #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexerNoExceptions.cxx000444001750001750 405112021352777 26537 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexerNoExceptions.cxx ** A simple lexer with no state which does not throw exceptions so can be used in an external lexer. **/ // Copyright 1998-2010 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "LexerModule.h" #include "LexerBase.h" #include "LexerNoExceptions.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif int SCI_METHOD LexerNoExceptions::PropertySet(const char *key, const char *val) { try { return LexerBase::PropertySet(key, val); } catch (...) { // Should not throw into caller as may be compiled with different compiler or options } return -1; } int SCI_METHOD LexerNoExceptions::WordListSet(int n, const char *wl) { try { return LexerBase::WordListSet(n, wl); } catch (...) { // Should not throw into caller as may be compiled with different compiler or options } return -1; } void SCI_METHOD LexerNoExceptions::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { try { Accessor astyler(pAccess, &props); Lexer(startPos, length, initStyle, pAccess, astyler); astyler.Flush(); } catch (...) { // Should not throw into caller as may be compiled with different compiler or options pAccess->SetErrorStatus(SC_STATUS_FAILURE); } } void SCI_METHOD LexerNoExceptions::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { try { Accessor astyler(pAccess, &props); Folder(startPos, length, initStyle, pAccess, astyler); astyler.Flush(); } catch (...) { // Should not throw into caller as may be compiled with different compiler or options pAccess->SetErrorStatus(SC_STATUS_FAILURE); } } Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/ContractionState.h000444001750001750 314012021352777 26030 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file ContractionState.h ** Manages visibility of lines for folding and wrapping. **/ // Copyright 1998-2007 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef CONTRACTIONSTATE_H #define CONTRACTIONSTATE_H #ifdef SCI_NAMESPACE namespace Scintilla { #endif /** */ class ContractionState { // These contain 1 element for every document line. RunStyles *visible; RunStyles *expanded; RunStyles *heights; Partitioning *displayLines; int linesInDocument; void EnsureData(); bool OneToOne() const { // True when each document line is exactly one display line so need for // complex data structures. return visible == 0; } public: ContractionState(); virtual ~ContractionState(); void Clear(); int LinesInDoc() const; int LinesDisplayed() const; int DisplayFromDoc(int lineDoc) const; int DocFromDisplay(int lineDisplay) const; void InsertLine(int lineDoc); void InsertLines(int lineDoc, int lineCount); void DeleteLine(int lineDoc); void DeleteLines(int lineDoc, int lineCount); bool GetVisible(int lineDoc) const; bool SetVisible(int lineDocStart, int lineDocEnd, bool visible); bool HiddenLines() const; bool GetExpanded(int lineDoc) const; bool SetExpanded(int lineDoc, bool expanded); int ContractedNext(int lineDocStart) const; int GetHeight(int lineDoc) const; bool SetHeight(int lineDoc, int height); void ShowAll(); void Check() const; }; #ifdef SCI_NAMESPACE } #endif #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexCOBOL.cxx000444001750001750 3076512021352777 24463 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexCOBOL.cxx ** Lexer for COBOL ** Based on LexPascal.cxx ** Written by Laurent le Tynevez ** Updated by Simon Steele September 2002 ** Updated by Mathias Rauen May 2003 (Delphi adjustments) ** Updated by Rod Falck, Aug 2006 Converted to COBOL **/ #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif #define IN_DIVISION 0x01 #define IN_DECLARATIVES 0x02 #define IN_SECTION 0x04 #define IN_PARAGRAPH 0x08 #define IN_FLAGS 0xF #define NOT_HEADER 0x10 inline bool isCOBOLoperator(char ch) { return isoperator(ch); } inline bool isCOBOLwordchar(char ch) { return isascii(ch) && (isalnum(ch) || ch == '-'); } inline bool isCOBOLwordstart(char ch) { return isascii(ch) && isalnum(ch); } static int CountBits(int nBits) { int count = 0; for (int i = 0; i < 32; ++i) { count += nBits & 1; nBits >>= 1; } return count; } static void getRange(unsigned int start, unsigned int end, Accessor &styler, char *s, unsigned int len) { unsigned int i = 0; while ((i < end - start + 1) && (i < len-1)) { s[i] = static_cast(tolower(styler[start + i])); i++; } s[i] = '\0'; } static void ColourTo(Accessor &styler, unsigned int end, unsigned int attr) { styler.ColourTo(end, attr); } static int classifyWordCOBOL(unsigned int start, unsigned int end, /*WordList &keywords*/WordList *keywordlists[], Accessor &styler, int nContainment, bool *bAarea) { int ret = 0; WordList& a_keywords = *keywordlists[0]; WordList& b_keywords = *keywordlists[1]; WordList& c_keywords = *keywordlists[2]; char s[100]; getRange(start, end, styler, s, sizeof(s)); char chAttr = SCE_C_IDENTIFIER; if (isdigit(s[0]) || (s[0] == '.') || (s[0] == 'v')) { chAttr = SCE_C_NUMBER; char *p = s + 1; while (*p) { if ((!isdigit(*p) && (*p) != 'v') && isCOBOLwordchar(*p)) { chAttr = SCE_C_IDENTIFIER; break; } ++p; } } else { if (a_keywords.InList(s)) { chAttr = SCE_C_WORD; } else if (b_keywords.InList(s)) { chAttr = SCE_C_WORD2; } else if (c_keywords.InList(s)) { chAttr = SCE_C_UUID; } } if (*bAarea) { if (strcmp(s, "division") == 0) { ret = IN_DIVISION; // we've determined the containment, anything else is just ignored for those purposes *bAarea = false; } else if (strcmp(s, "declaratives") == 0) { ret = IN_DIVISION | IN_DECLARATIVES; if (nContainment & IN_DECLARATIVES) ret |= NOT_HEADER | IN_SECTION; // we've determined the containment, anything else is just ignored for those purposes *bAarea = false; } else if (strcmp(s, "section") == 0) { ret = (nContainment &~ IN_PARAGRAPH) | IN_SECTION; // we've determined the containment, anything else is just ignored for those purposes *bAarea = false; } else if (strcmp(s, "end") == 0 && (nContainment & IN_DECLARATIVES)) { ret = IN_DIVISION | IN_DECLARATIVES | IN_SECTION | NOT_HEADER; } else { ret = nContainment | IN_PARAGRAPH; } } ColourTo(styler, end, chAttr); return ret; } static void ColouriseCOBOLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { styler.StartAt(startPos); int state = initStyle; if (state == SCE_C_CHARACTER) // Does not leak onto next line state = SCE_C_DEFAULT; char chPrev = ' '; char chNext = styler[startPos]; unsigned int lengthDoc = startPos + length; int nContainment; int currentLine = styler.GetLine(startPos); if (currentLine > 0) { styler.SetLineState(currentLine, styler.GetLineState(currentLine-1)); nContainment = styler.GetLineState(currentLine); nContainment &= ~NOT_HEADER; } else { styler.SetLineState(currentLine, 0); nContainment = 0; } styler.StartSegment(startPos); bool bNewLine = true; bool bAarea = !isspacechar(chNext); int column = 0; for (unsigned int i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); ++column; if (bNewLine) { column = 0; } if (column <= 1 && !bAarea) { bAarea = !isspacechar(ch); } bool bSetNewLine = false; if ((ch == '\r' && chNext != '\n') || (ch == '\n')) { // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix) // Avoid triggering two times on Dos/Win // End of line if (state == SCE_C_CHARACTER) { ColourTo(styler, i, state); state = SCE_C_DEFAULT; } styler.SetLineState(currentLine, nContainment); currentLine++; bSetNewLine = true; if (nContainment & NOT_HEADER) nContainment &= ~(NOT_HEADER | IN_DECLARATIVES | IN_SECTION); } if (styler.IsLeadByte(ch)) { chNext = styler.SafeGetCharAt(i + 2); chPrev = ' '; i += 1; continue; } if (state == SCE_C_DEFAULT) { if (isCOBOLwordstart(ch) || (ch == '$' && isascii(chNext) && isalpha(chNext))) { ColourTo(styler, i-1, state); state = SCE_C_IDENTIFIER; } else if (column == 6 && ch == '*') { // Cobol comment line: asterisk in column 7. ColourTo(styler, i-1, state); state = SCE_C_COMMENTLINE; } else if (ch == '*' && chNext == '>') { // Cobol inline comment: asterisk, followed by greater than. ColourTo(styler, i-1, state); state = SCE_C_COMMENTLINE; } else if (column == 0 && ch == '*' && chNext != '*') { ColourTo(styler, i-1, state); state = SCE_C_COMMENTLINE; } else if (column == 0 && ch == '/' && chNext != '*') { ColourTo(styler, i-1, state); state = SCE_C_COMMENTLINE; } else if (column == 0 && ch == '*' && chNext == '*') { ColourTo(styler, i-1, state); state = SCE_C_COMMENTDOC; } else if (column == 0 && ch == '/' && chNext == '*') { ColourTo(styler, i-1, state); state = SCE_C_COMMENTDOC; } else if (ch == '"') { ColourTo(styler, i-1, state); state = SCE_C_STRING; } else if (ch == '\'') { ColourTo(styler, i-1, state); state = SCE_C_CHARACTER; } else if (ch == '?' && column == 0) { ColourTo(styler, i-1, state); state = SCE_C_PREPROCESSOR; } else if (isCOBOLoperator(ch)) { ColourTo(styler, i-1, state); ColourTo(styler, i, SCE_C_OPERATOR); } } else if (state == SCE_C_IDENTIFIER) { if (!isCOBOLwordchar(ch)) { int lStateChange = classifyWordCOBOL(styler.GetStartSegment(), i - 1, keywordlists, styler, nContainment, &bAarea); if(lStateChange != 0) { styler.SetLineState(currentLine, lStateChange); nContainment = lStateChange; } state = SCE_C_DEFAULT; chNext = styler.SafeGetCharAt(i + 1); if (ch == '"') { state = SCE_C_STRING; } else if (ch == '\'') { state = SCE_C_CHARACTER; } else if (isCOBOLoperator(ch)) { ColourTo(styler, i, SCE_C_OPERATOR); } } } else { if (state == SCE_C_PREPROCESSOR) { if ((ch == '\r' || ch == '\n') && !(chPrev == '\\' || chPrev == '\r')) { ColourTo(styler, i-1, state); state = SCE_C_DEFAULT; } } else if (state == SCE_C_COMMENT) { if (ch == '\r' || ch == '\n') { ColourTo(styler, i, state); state = SCE_C_DEFAULT; } } else if (state == SCE_C_COMMENTDOC) { if (ch == '\r' || ch == '\n') { if (((i > styler.GetStartSegment() + 2) || ( (initStyle == SCE_C_COMMENTDOC) && (styler.GetStartSegment() == static_cast(startPos))))) { ColourTo(styler, i, state); state = SCE_C_DEFAULT; } } } else if (state == SCE_C_COMMENTLINE) { if (ch == '\r' || ch == '\n') { ColourTo(styler, i-1, state); state = SCE_C_DEFAULT; } } else if (state == SCE_C_STRING) { if (ch == '"') { ColourTo(styler, i, state); state = SCE_C_DEFAULT; } } else if (state == SCE_C_CHARACTER) { if (ch == '\'') { ColourTo(styler, i, state); state = SCE_C_DEFAULT; } } } chPrev = ch; bNewLine = bSetNewLine; if (bNewLine) { bAarea = false; } } ColourTo(styler, lengthDoc - 1, state); } static void FoldCOBOLDoc(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); int levelPrev = lineCurrent > 0 ? styler.LevelAt(lineCurrent - 1) & SC_FOLDLEVELNUMBERMASK : 0xFFF; char chNext = styler[startPos]; bool bNewLine = true; bool bAarea = !isspacechar(chNext); int column = 0; bool bComment = false; for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); ++column; if (bNewLine) { column = 0; bComment = (ch == '*' || ch == '/' || ch == '?'); } if (column <= 1 && !bAarea) { bAarea = !isspacechar(ch); } bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (atEOL) { int nContainment = styler.GetLineState(lineCurrent); int lev = CountBits(nContainment & IN_FLAGS) | SC_FOLDLEVELBASE; if (bAarea && !bComment) --lev; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if ((bAarea) && (visibleChars > 0) && !(nContainment & NOT_HEADER) && !bComment) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } if ((lev & SC_FOLDLEVELNUMBERMASK) <= (levelPrev & SC_FOLDLEVELNUMBERMASK)) { // this level is at the same level or less than the previous line // therefore these is nothing for the previous header to collapse, so remove the header styler.SetLevel(lineCurrent - 1, levelPrev & ~SC_FOLDLEVELHEADERFLAG); } levelPrev = lev; visibleChars = 0; bAarea = false; bNewLine = true; lineCurrent++; } else { bNewLine = false; } if (!isspacechar(ch)) visibleChars++; } // Fill in the real level of the next line, keeping the current flags as they will be filled in later int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, levelPrev | flagsNext); } static const char * const COBOLWordListDesc[] = { "A Keywords", "B Keywords", "Extended Keywords", 0 }; LexerModule lmCOBOL(SCLEX_COBOL, ColouriseCOBOLDoc, "COBOL", FoldCOBOLDoc, COBOLWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/StyleContext.h000444001750001750 1061212021352777 25233 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file StyleContext.cxx ** Lexer infrastructure. **/ // Copyright 1998-2004 by Neil Hodgson // This file is in the public domain. #ifndef STYLECONTEXT_H #define STYLECONTEXT_H #ifdef SCI_NAMESPACE namespace Scintilla { #endif static inline int MakeLowerCase(int ch) { if (ch < 'A' || ch > 'Z') return ch; else return ch - 'A' + 'a'; } // All languages handled so far can treat all characters >= 0x80 as one class // which just continues the current token or starts an identifier if in default. // DBCS treated specially as the second character can be < 0x80 and hence // syntactically significant. UTF-8 avoids this as all trail bytes are >= 0x80 class StyleContext { LexAccessor &styler; unsigned int endPos; StyleContext &operator=(const StyleContext &); void GetNextChar(unsigned int pos) { chNext = static_cast(styler.SafeGetCharAt(pos+1)); if (styler.IsLeadByte(static_cast(chNext))) { chNext = chNext << 8; chNext |= static_cast(styler.SafeGetCharAt(pos+2)); } // End of line? // 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. atLineEnd = (ch == '\r' && chNext != '\n') || (ch == '\n') || (currentPos >= endPos); } public: unsigned int currentPos; bool atLineStart; bool atLineEnd; int state; int chPrev; int ch; int chNext; StyleContext(unsigned int startPos, unsigned int length, int initStyle, LexAccessor &styler_, char chMask=31) : styler(styler_), endPos(startPos + length), currentPos(startPos), atLineEnd(false), state(initStyle & chMask), // Mask off all bits which aren't in the chMask. chPrev(0), ch(0), chNext(0) { styler.StartAt(startPos, chMask); styler.StartSegment(startPos); atLineStart = static_cast(styler.LineStart(styler.GetLine(startPos))) == startPos; unsigned int pos = currentPos; ch = static_cast(styler.SafeGetCharAt(pos)); if (styler.IsLeadByte(static_cast(ch))) { pos++; ch = ch << 8; ch |= static_cast(styler.SafeGetCharAt(pos)); } GetNextChar(pos); } void Complete() { styler.ColourTo(currentPos - 1, state); styler.Flush(); } bool More() const { return currentPos < endPos; } void Forward() { if (currentPos < endPos) { atLineStart = atLineEnd; chPrev = ch; currentPos++; if (ch >= 0x100) currentPos++; ch = chNext; GetNextChar(currentPos + ((ch >= 0x100) ? 1 : 0)); } else { atLineStart = false; chPrev = ' '; ch = ' '; chNext = ' '; atLineEnd = true; } } void Forward(int nb) { for (int i = 0; i < nb; i++) { Forward(); } } void ChangeState(int state_) { state = state_; } void SetState(int state_) { styler.ColourTo(currentPos - 1, state); state = state_; } void ForwardSetState(int state_) { Forward(); styler.ColourTo(currentPos - 1, state); state = state_; } int LengthCurrent() { return currentPos - styler.GetStartSegment(); } int GetRelative(int n) { return static_cast(styler.SafeGetCharAt(currentPos+n)); } bool Match(char ch0) const { return ch == static_cast(ch0); } bool Match(char ch0, char ch1) const { return (ch == static_cast(ch0)) && (chNext == static_cast(ch1)); } bool Match(const char *s) { if (ch != static_cast(*s)) return false; s++; if (!*s) return true; if (chNext != static_cast(*s)) return false; s++; for (int n=2; *s; n++) { if (*s != styler.SafeGetCharAt(currentPos+n)) return false; s++; } return true; } bool MatchIgnoreCase(const char *s) { if (MakeLowerCase(ch) != static_cast(*s)) return false; s++; if (MakeLowerCase(chNext) != static_cast(*s)) return false; s++; for (int n=2; *s; n++) { if (static_cast(*s) != MakeLowerCase(static_cast(styler.SafeGetCharAt(currentPos+n)))) return false; s++; } return true; } // Non-inline void GetCurrent(char *s, unsigned int len); void GetCurrentLowered(char *s, unsigned int len); }; #ifdef SCI_NAMESPACE } #endif #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexMMIXAL.cxx000444001750001750 1277712021352777 24617 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexMMIXAL.cxx ** Lexer for MMIX Assembler Language. ** Written by Christoph Hösler ** For information about MMIX visit http://www-cs-faculty.stanford.edu/~knuth/mmix.html **/ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == ':' || ch == '_'); } inline bool isMMIXALOperator(char ch) { if (isascii(ch) && isalnum(ch)) return false; if (ch == '+' || ch == '-' || ch == '|' || ch == '^' || ch == '*' || ch == '/' || ch == '%' || ch == '<' || ch == '>' || ch == '&' || ch == '~' || ch == '$' || ch == ',' || ch == '(' || ch == ')' || ch == '[' || ch == ']') return true; return false; } static void ColouriseMMIXALDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &opcodes = *keywordlists[0]; WordList &special_register = *keywordlists[1]; WordList &predef_symbols = *keywordlists[2]; StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { // No EOL continuation if (sc.atLineStart) { if (sc.ch == '@' && sc.chNext == 'i') { sc.SetState(SCE_MMIXAL_INCLUDE); } else { sc.SetState(SCE_MMIXAL_LEADWS); } } // Check if first non whitespace character in line is alphanumeric if (sc.state == SCE_MMIXAL_LEADWS && !isspace(sc.ch)) { // LEADWS if(!IsAWordChar(sc.ch)) { sc.SetState(SCE_MMIXAL_COMMENT); } else { if(sc.atLineStart) { sc.SetState(SCE_MMIXAL_LABEL); } else { sc.SetState(SCE_MMIXAL_OPCODE_PRE); } } } // Determine if the current state should terminate. if (sc.state == SCE_MMIXAL_OPERATOR) { // OPERATOR sc.SetState(SCE_MMIXAL_OPERANDS); } else if (sc.state == SCE_MMIXAL_NUMBER) { // NUMBER if (!isdigit(sc.ch)) { if (IsAWordChar(sc.ch)) { char s[100]; sc.GetCurrent(s, sizeof(s)); sc.ChangeState(SCE_MMIXAL_REF); sc.SetState(SCE_MMIXAL_REF); } else { sc.SetState(SCE_MMIXAL_OPERANDS); } } } else if (sc.state == SCE_MMIXAL_LABEL) { // LABEL if (!IsAWordChar(sc.ch) ) { sc.SetState(SCE_MMIXAL_OPCODE_PRE); } } else if (sc.state == SCE_MMIXAL_REF) { // REF if (!IsAWordChar(sc.ch) ) { char s[100]; sc.GetCurrent(s, sizeof(s)); if (*s == ':') { // ignore base prefix for match for (size_t i = 0; i != sizeof(s); ++i) { *(s+i) = *(s+i+1); } } if (special_register.InList(s)) { sc.ChangeState(SCE_MMIXAL_REGISTER); } else if (predef_symbols.InList(s)) { sc.ChangeState(SCE_MMIXAL_SYMBOL); } sc.SetState(SCE_MMIXAL_OPERANDS); } } else if (sc.state == SCE_MMIXAL_OPCODE_PRE) { // OPCODE_PRE if (!isspace(sc.ch)) { sc.SetState(SCE_MMIXAL_OPCODE); } } else if (sc.state == SCE_MMIXAL_OPCODE) { // OPCODE if (!IsAWordChar(sc.ch) ) { char s[100]; sc.GetCurrent(s, sizeof(s)); if (opcodes.InList(s)) { sc.ChangeState(SCE_MMIXAL_OPCODE_VALID); } else { sc.ChangeState(SCE_MMIXAL_OPCODE_UNKNOWN); } sc.SetState(SCE_MMIXAL_OPCODE_POST); } } else if (sc.state == SCE_MMIXAL_STRING) { // STRING if (sc.ch == '\"') { sc.ForwardSetState(SCE_MMIXAL_OPERANDS); } else if (sc.atLineEnd) { sc.ForwardSetState(SCE_MMIXAL_OPERANDS); } } else if (sc.state == SCE_MMIXAL_CHAR) { // CHAR if (sc.ch == '\'') { sc.ForwardSetState(SCE_MMIXAL_OPERANDS); } else if (sc.atLineEnd) { sc.ForwardSetState(SCE_MMIXAL_OPERANDS); } } else if (sc.state == SCE_MMIXAL_REGISTER) { // REGISTER if (!isdigit(sc.ch)) { sc.SetState(SCE_MMIXAL_OPERANDS); } } else if (sc.state == SCE_MMIXAL_HEX) { // HEX if (!isxdigit(sc.ch)) { sc.SetState(SCE_MMIXAL_OPERANDS); } } // Determine if a new state should be entered. if (sc.state == SCE_MMIXAL_OPCODE_POST || // OPCODE_POST sc.state == SCE_MMIXAL_OPERANDS) { // OPERANDS if (sc.state == SCE_MMIXAL_OPERANDS && isspace(sc.ch)) { if (!sc.atLineEnd) { sc.SetState(SCE_MMIXAL_COMMENT); } } else if (isdigit(sc.ch)) { sc.SetState(SCE_MMIXAL_NUMBER); } else if (IsAWordChar(sc.ch) || sc.Match('@')) { sc.SetState(SCE_MMIXAL_REF); } else if (sc.Match('\"')) { sc.SetState(SCE_MMIXAL_STRING); } else if (sc.Match('\'')) { sc.SetState(SCE_MMIXAL_CHAR); } else if (sc.Match('$')) { sc.SetState(SCE_MMIXAL_REGISTER); } else if (sc.Match('#')) { sc.SetState(SCE_MMIXAL_HEX); } else if (isMMIXALOperator(static_cast(sc.ch))) { sc.SetState(SCE_MMIXAL_OPERATOR); } } } sc.Complete(); } static const char * const MMIXALWordListDesc[] = { "Operation Codes", "Special Register", "Predefined Symbols", 0 }; LexerModule lmMMIXAL(SCLEX_MMIXAL, ColouriseMMIXALDoc, "mmixal", 0, MMIXALWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/XPM.h000444001750001750 652012021352777 23215 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file XPM.h ** Define a class that holds data in the X Pixmap (XPM) format. **/ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef XPM_H #define XPM_H #ifdef SCI_NAMESPACE namespace Scintilla { #endif /** * Hold a pixmap in XPM format. */ class XPM { int pid; // Assigned by container int height; int width; int nColours; char *data; char codeTransparent; char *codes; ColourDesired *colours; ColourDesired ColourDesiredFromCode(int ch) const; ColourDesired ColourFromCode(int ch) const; void FillRun(Surface *surface, int code, int startX, int y, int x); char **lines; ColourDesired *colourCodeTable[256]; public: XPM(const char *textForm); XPM(const char *const *linesForm); ~XPM(); void Init(const char *textForm); void Init(const char *const *linesForm); void Clear(); /// Decompose image into runs and use FillRectangle for each run void Draw(Surface *surface, PRectangle &rc); char **InLinesForm() { return lines; } void SetId(int pid_) { pid = pid_; } int GetId() const { return pid; } int GetHeight() const { return height; } int GetWidth() const { return width; } void PixelAt(int x, int y, ColourDesired &colour, bool &transparent) const; static const char **LinesFormFromTextForm(const char *textForm); }; /** * A collection of pixmaps indexed by integer id. */ class XPMSet { XPM **set; ///< The stored XPMs. int len; ///< Current number of XPMs. int maximum; ///< Current maximum number of XPMs, increased by steps if reached. int height; ///< Memorize largest height of the set. int width; ///< Memorize largest width of the set. public: XPMSet(); ~XPMSet(); /// Remove all XPMs. void Clear(); /// Add a XPM. void Add(int ident, const char *textForm); /// Get XPM by id. XPM *Get(int ident); /// Give the largest height of the set. int GetHeight(); /// Give the largest width of the set. int GetWidth(); }; /** * An translucent image stoed as a sequence of RGBA bytes. */ class RGBAImage { // Private so RGBAImage objects can not be copied RGBAImage(const RGBAImage &); RGBAImage &operator=(const RGBAImage &); int height; int width; std::vector pixelBytes; public: RGBAImage(int width_, int height_, const unsigned char *pixels_); RGBAImage(const XPM &xpm); virtual ~RGBAImage(); int GetHeight() const { return height; } int GetWidth() const { return width; } int CountBytes() const; const unsigned char *Pixels() const; void SetPixel(int x, int y, ColourDesired colour, int alpha=0xff); }; /** * A collection of RGBAImage pixmaps indexed by integer id. */ class RGBAImageSet { typedef std::map ImageMap; ImageMap images; mutable int height; ///< Memorize largest height of the set. mutable int width; ///< Memorize largest width of the set. public: RGBAImageSet(); ~RGBAImageSet(); /// Remove all images. void Clear(); /// Add an image. void Add(int ident, RGBAImage *image); /// Get image by id. RGBAImage *Get(int ident); /// Give the largest height of the set. int GetHeight() const; /// Give the largest width of the set. int GetWidth() const; }; #ifdef SCI_NAMESPACE } #endif #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexPowerPro.cxx000444001750001750 5076112021352777 25400 0ustar00azawawiazawawi000000000000// Scintilla source code edit control // @file LexPowerPro.cxx // PowerPro utility, written by Bruce Switzer, is available from http://powerpro.webeddie.com // PowerPro lexer is written by Christopher Bean (cbean@cb-software.net) // // Lexer code heavily borrowed from: // LexAU3.cxx by Jos van der Zande // LexCPP.cxx by Neil Hodgson // LexVB.cxx by Neil Hodgson // // Changes: // 2008-10-25 - Initial release // 2008-10-26 - Changed how is hilighted in 'function ' so that // local isFunction = "" and local functions = "" don't get falsely highlighted // 2008-12-14 - Added bounds checking for szFirstWord and szDo // - Replaced SetOfCharacters with CharacterSet // - Made sure that CharacterSet::Contains is passed only positive values // - Made sure that the return value of Accessor::SafeGetCharAt is positive before // passing to functions that require positive values like isspacechar() // - Removed unused visibleChars processing from ColourisePowerProDoc() // - Fixed bug with folding logic where line continuations didn't end where // they were supposed to // - Moved all helper functions to the top of the file // 2010-06-03 - Added onlySpaces variable to allow the @function and ;comment styles to be indented // - Modified HasFunction function to be a bit more robust // - Renamed HasFunction function to IsFunction // - Cleanup // Copyright 1998-2005 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static inline bool IsStreamCommentStyle(int style) { return style == SCE_POWERPRO_COMMENTBLOCK; } static inline bool IsLineEndChar(unsigned char ch) { return ch == 0x0a //LF || ch == 0x0c //FF || ch == 0x0d; //CR } static bool IsContinuationLine(unsigned int szLine, Accessor &styler) { int startPos = styler.LineStart(szLine); int endPos = styler.LineStart(szLine + 1) - 2; while (startPos < endPos) { char stylech = styler.StyleAt(startPos); if (!(stylech == SCE_POWERPRO_COMMENTBLOCK)) { char ch = styler.SafeGetCharAt(endPos); char chPrev = styler.SafeGetCharAt(endPos - 1); char chPrevPrev = styler.SafeGetCharAt(endPos - 2); if (ch > 0 && chPrev > 0 && chPrevPrev > 0 && !isspacechar(ch) && !isspacechar(chPrev) && !isspacechar(chPrevPrev) ) return (chPrevPrev == ';' && chPrev == ';' && ch == '+'); } endPos--; // skip to next char } return false; } // Routine to find first none space on the current line and return its Style // needed for comment lines not starting on pos 1 static int GetStyleFirstWord(int szLine, Accessor &styler) { int startPos = styler.LineStart(szLine); int endPos = styler.LineStart(szLine + 1) - 1; char ch = styler.SafeGetCharAt(startPos); while (ch > 0 && isspacechar(ch) && startPos < endPos) { startPos++; // skip to next char ch = styler.SafeGetCharAt(startPos); } return styler.StyleAt(startPos); } //returns true if there is a function to highlight //used to highlight in 'function ' //note: // sample line (without quotes): "\tfunction asdf() // currentPos will be the position of 'a' static bool IsFunction(Accessor &styler, unsigned int currentPos) { const char function[10] = "function "; //10 includes \0 unsigned int numberOfCharacters = sizeof(function) - 1; unsigned int position = currentPos - numberOfCharacters; //compare each character with the letters in the function array //return false if ALL don't match for (unsigned int i = 0; i < numberOfCharacters; i++) { char c = styler.SafeGetCharAt(position++); if (c != function[i]) return false; } //make sure that there are only spaces (or tabs) between the beginning //of the line and the function declaration position = currentPos - numberOfCharacters - 1; //-1 to move to char before 'function' for (unsigned int j = 0; j < 16; j++) { //check up to 16 preceeding characters char c = styler.SafeGetCharAt(position--, '\0'); //if can't read char, return NUL (past beginning of document) if (c <= 0) //reached beginning of document return true; if (c > 0 && IsLineEndChar(c)) return true; else if (c > 0 && !IsASpaceOrTab(c)) return false; } //fall-through return false; } static void ColourisePowerProDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler, bool caseSensitive) { WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; WordList &keywords3 = *keywordlists[2]; WordList &keywords4 = *keywordlists[3]; //define the character sets CharacterSet setWordStart(CharacterSet::setAlpha, "_@", 0x80, true); CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true); StyleContext sc(startPos, length, initStyle, styler); char s_save[100]; //for last line highlighting //are there only spaces between the first letter of the line and the beginning of the line bool onlySpaces = true; for (; sc.More(); sc.Forward()) { // save the total current word for eof processing char s[100]; sc.GetCurrentLowered(s, sizeof(s)); if ((sc.ch > 0) && setWord.Contains(sc.ch)) { strcpy(s_save,s); int tp = static_cast(strlen(s_save)); if (tp < 99) { s_save[tp] = static_cast(tolower(sc.ch)); s_save[tp+1] = '\0'; } } if (sc.atLineStart) { if (sc.state == SCE_POWERPRO_DOUBLEQUOTEDSTRING) { // Prevent SCE_POWERPRO_STRINGEOL from leaking back to previous line which // ends with a line continuation by locking in the state upto this position. sc.SetState(SCE_POWERPRO_DOUBLEQUOTEDSTRING); } } // Determine if the current state should terminate. switch (sc.state) { case SCE_POWERPRO_OPERATOR: sc.SetState(SCE_POWERPRO_DEFAULT); break; case SCE_POWERPRO_NUMBER: if (!IsADigit(sc.ch)) sc.SetState(SCE_POWERPRO_DEFAULT); break; case SCE_POWERPRO_IDENTIFIER: //if ((sc.ch > 0) && !setWord.Contains(sc.ch) || (sc.ch == '.')) { // use this line if don't want to match keywords with . in them. ie: win.debug will match both win and debug so win debug will also be colorized if ((sc.ch > 0) && !setWord.Contains(sc.ch)){ // || (sc.ch == '.')) { // use this line if you want to match keywords with a . ie: win.debug will only match win.debug neither win nor debug will be colorized separately char s[1000]; if (caseSensitive) { sc.GetCurrent(s, sizeof(s)); } else { sc.GetCurrentLowered(s, sizeof(s)); } if (keywords.InList(s)) { sc.ChangeState(SCE_POWERPRO_WORD); } else if (keywords2.InList(s)) { sc.ChangeState(SCE_POWERPRO_WORD2); } else if (keywords3.InList(s)) { sc.ChangeState(SCE_POWERPRO_WORD3); } else if (keywords4.InList(s)) { sc.ChangeState(SCE_POWERPRO_WORD4); } sc.SetState(SCE_POWERPRO_DEFAULT); } break; case SCE_POWERPRO_LINECONTINUE: if (sc.atLineStart) { sc.SetState(SCE_POWERPRO_DEFAULT); } else if (sc.Match('/', '*') || sc.Match('/', '/')) { sc.SetState(SCE_POWERPRO_DEFAULT); } break; case SCE_POWERPRO_COMMENTBLOCK: if (sc.Match('*', '/')) { sc.Forward(); sc.ForwardSetState(SCE_POWERPRO_DEFAULT); } break; case SCE_POWERPRO_COMMENTLINE: if (sc.atLineStart) { sc.SetState(SCE_POWERPRO_DEFAULT); } break; case SCE_POWERPRO_DOUBLEQUOTEDSTRING: if (sc.atLineEnd) { sc.ChangeState(SCE_POWERPRO_STRINGEOL); } else if (sc.ch == '\\') { if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { sc.Forward(); } } else if (sc.ch == '\"') { sc.ForwardSetState(SCE_POWERPRO_DEFAULT); } break; case SCE_POWERPRO_SINGLEQUOTEDSTRING: if (sc.atLineEnd) { sc.ChangeState(SCE_POWERPRO_STRINGEOL); } else if (sc.ch == '\\') { if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { sc.Forward(); } } else if (sc.ch == '\'') { sc.ForwardSetState(SCE_POWERPRO_DEFAULT); } break; case SCE_POWERPRO_STRINGEOL: if (sc.atLineStart) { sc.SetState(SCE_POWERPRO_DEFAULT); } break; case SCE_POWERPRO_VERBATIM: if (sc.ch == '\"') { if (sc.chNext == '\"') { sc.Forward(); } else { sc.ForwardSetState(SCE_POWERPRO_DEFAULT); } } break; case SCE_POWERPRO_ALTQUOTE: if (sc.ch == '#') { if (sc.chNext == '#') { sc.Forward(); } else { sc.ForwardSetState(SCE_POWERPRO_DEFAULT); } } break; case SCE_POWERPRO_FUNCTION: if (isspacechar(sc.ch) || sc.ch == '(') { sc.SetState(SCE_POWERPRO_DEFAULT); } break; } // Determine if a new state should be entered. if (sc.state == SCE_POWERPRO_DEFAULT) { if (sc.Match('?', '\"')) { sc.SetState(SCE_POWERPRO_VERBATIM); sc.Forward(); } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_POWERPRO_NUMBER); }else if (sc.Match('?','#')) { if (sc.ch == '?' && sc.chNext == '#') { sc.SetState(SCE_POWERPRO_ALTQUOTE); sc.Forward(); } } else if (IsFunction(styler, sc.currentPos)) { //highlight in 'function ' sc.SetState(SCE_POWERPRO_FUNCTION); } else if (onlySpaces && sc.ch == '@') { //alternate function definition [label] sc.SetState(SCE_POWERPRO_FUNCTION); } else if ((sc.ch > 0) && (setWordStart.Contains(sc.ch) || (sc.ch == '?'))) { sc.SetState(SCE_POWERPRO_IDENTIFIER); } else if (sc.Match(";;+")) { sc.SetState(SCE_POWERPRO_LINECONTINUE); } else if (sc.Match('/', '*')) { sc.SetState(SCE_POWERPRO_COMMENTBLOCK); sc.Forward(); // Eat the * so it isn't used for the end of the comment } else if (sc.Match('/', '/')) { sc.SetState(SCE_POWERPRO_COMMENTLINE); } else if (onlySpaces && sc.ch == ';') { //legacy comment that can only have blank space in front of it sc.SetState(SCE_POWERPRO_COMMENTLINE); } else if (sc.Match(";;")) { sc.SetState(SCE_POWERPRO_COMMENTLINE); } else if (sc.ch == '\"') { sc.SetState(SCE_POWERPRO_DOUBLEQUOTEDSTRING); } else if (sc.ch == '\'') { sc.SetState(SCE_POWERPRO_SINGLEQUOTEDSTRING); } else if (isoperator(static_cast(sc.ch))) { sc.SetState(SCE_POWERPRO_OPERATOR); } } //maintain a record of whether or not all the preceding characters on //a line are space characters if (onlySpaces && !IsASpaceOrTab(sc.ch)) onlySpaces = false; //reset when starting a new line if (sc.atLineEnd) onlySpaces = true; } //************************************* // Colourize the last word correctly //************************************* if (sc.state == SCE_POWERPRO_IDENTIFIER) { if (keywords.InList(s_save)) { sc.ChangeState(SCE_POWERPRO_WORD); sc.SetState(SCE_POWERPRO_DEFAULT); } else if (keywords2.InList(s_save)) { sc.ChangeState(SCE_POWERPRO_WORD2); sc.SetState(SCE_POWERPRO_DEFAULT); } else if (keywords3.InList(s_save)) { sc.ChangeState(SCE_POWERPRO_WORD3); sc.SetState(SCE_POWERPRO_DEFAULT); } else if (keywords4.InList(s_save)) { sc.ChangeState(SCE_POWERPRO_WORD4); sc.SetState(SCE_POWERPRO_DEFAULT); } else { sc.SetState(SCE_POWERPRO_DEFAULT); } } sc.Complete(); } static void FoldPowerProDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { //define the character sets CharacterSet setWordStart(CharacterSet::setAlpha, "_@", 0x80, true); CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true); //used to tell if we're recursively folding the whole document, or just a small piece (ie: if statement or 1 function) bool isFoldingAll = true; int endPos = startPos + length; int lastLine = styler.GetLine(styler.Length()); //used to help fold the last line correctly // get settings from the config files for folding comments and preprocessor lines bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldInComment = styler.GetPropertyInt("fold.comment") == 2; bool foldCompact = true; // Backtrack to previous line in case need to fix its fold status int lineCurrent = styler.GetLine(startPos); if (startPos > 0) { isFoldingAll = false; if (lineCurrent > 0) { lineCurrent--; startPos = styler.LineStart(lineCurrent); } } // vars for style of previous/current/next lines int style = GetStyleFirstWord(lineCurrent,styler); int stylePrev = 0; // find the first previous line without continuation character at the end while ((lineCurrent > 0 && IsContinuationLine(lineCurrent, styler)) || (lineCurrent > 1 && IsContinuationLine(lineCurrent - 1, styler))) { lineCurrent--; startPos = styler.LineStart(lineCurrent); } if (lineCurrent > 0) { stylePrev = GetStyleFirstWord(lineCurrent-1,styler); } // vars for getting first word to check for keywords bool isFirstWordStarted = false; bool isFirstWordEnded = false; const unsigned int FIRST_WORD_MAX_LEN = 10; char szFirstWord[FIRST_WORD_MAX_LEN] = ""; unsigned int firstWordLen = 0; char szDo[3]=""; int szDolen = 0; bool isDoLastWord = false; // var for indentlevel int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; int levelNext = levelCurrent; int visibleChars = 0; int functionCount = 0; char chNext = styler.SafeGetCharAt(startPos); char chPrev = '\0'; char chPrevPrev = '\0'; char chPrevPrevPrev = '\0'; for (int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); if ((ch > 0) && setWord.Contains(ch)) visibleChars++; // get the syle for the current character neede to check in comment int stylech = styler.StyleAt(i); // start the capture of the first word if (!isFirstWordStarted && (ch > 0)) { if (setWord.Contains(ch) || setWordStart.Contains(ch) || ch == ';' || ch == '/') { isFirstWordStarted = true; if (firstWordLen < FIRST_WORD_MAX_LEN - 1) { szFirstWord[firstWordLen++] = static_cast(tolower(ch)); szFirstWord[firstWordLen] = '\0'; } } } // continue capture of the first word on the line else if (isFirstWordStarted && !isFirstWordEnded && (ch > 0)) { if (!setWord.Contains(ch)) { isFirstWordEnded = true; } else if (firstWordLen < (FIRST_WORD_MAX_LEN - 1)) { szFirstWord[firstWordLen++] = static_cast(tolower(ch)); szFirstWord[firstWordLen] = '\0'; } } if (stylech != SCE_POWERPRO_COMMENTLINE) { //reset isDoLastWord if we find a character(ignoring spaces) after 'do' if (isDoLastWord && (ch > 0) && setWord.Contains(ch)) isDoLastWord = false; // --find out if the word "do" is the last on a "if" line-- // collect each letter and put it into a buffer 2 chars long // if we end up with "do" in the buffer when we reach the end of // the line, "do" was the last word on the line if ((ch > 0) && isFirstWordEnded && strcmp(szFirstWord, "if") == 0) { if (szDolen == 2) { szDo[0] = szDo[1]; szDo[1] = static_cast(tolower(ch)); szDo[2] = '\0'; if (strcmp(szDo, "do") == 0) isDoLastWord = true; } else if (szDolen < 2) { szDo[szDolen++] = static_cast(tolower(ch)); szDo[szDolen] = '\0'; } } } // End of Line found so process the information if ((ch == '\r' && chNext != '\n') // \r\n || ch == '\n' // \n || i == endPos) { // end of selection // ************************** // Folding logic for Keywords // ************************** // if a keyword is found on the current line and the line doesn't end with ;;+ (continuation) // and we are not inside a commentblock. if (firstWordLen > 0 && chPrev != '+' && chPrevPrev != ';' && chPrevPrevPrev !=';' && (!IsStreamCommentStyle(style) || foldInComment) ) { // only fold "if" last keyword is "then" (else its a one line if) if (strcmp(szFirstWord, "if") == 0 && isDoLastWord) levelNext++; // create new fold for these words if (strcmp(szFirstWord, "for") == 0) levelNext++; //handle folding for functions/labels //Note: Functions and labels don't have an explicit end like [end function] // 1. functions/labels end at the start of another function // 2. functions/labels end at the end of the file if ((strcmp(szFirstWord, "function") == 0) || (firstWordLen > 0 && szFirstWord[0] == '@')) { if (isFoldingAll) { //if we're folding the whole document (recursivly by lua script) if (functionCount > 0) { levelCurrent--; } else { levelNext++; } functionCount++; } else { //if just folding a small piece (by clicking on the minus sign next to the word) levelCurrent--; } } // end the fold for these words before the current line if (strcmp(szFirstWord, "endif") == 0 || strcmp(szFirstWord, "endfor") == 0) { levelNext--; levelCurrent--; } // end the fold for these words before the current line and Start new fold if (strcmp(szFirstWord, "else") == 0 || strcmp(szFirstWord, "elseif") == 0 ) levelCurrent--; } // Preprocessor and Comment folding int styleNext = GetStyleFirstWord(lineCurrent + 1,styler); // ********************************* // Folding logic for Comment blocks // ********************************* if (foldComment && IsStreamCommentStyle(style)) { // Start of a comment block if (stylePrev != style && IsStreamCommentStyle(styleNext) && styleNext == style) { levelNext++; } // fold till the last line for normal comment lines else if (IsStreamCommentStyle(stylePrev) && styleNext != SCE_POWERPRO_COMMENTLINE && stylePrev == SCE_POWERPRO_COMMENTLINE && style == SCE_POWERPRO_COMMENTLINE) { levelNext--; } // fold till the one but last line for Blockcomment lines else if (IsStreamCommentStyle(stylePrev) && styleNext != SCE_POWERPRO_COMMENTBLOCK && style == SCE_POWERPRO_COMMENTBLOCK) { levelNext--; levelCurrent--; } } int levelUse = levelCurrent; int lev = levelUse | levelNext << 16; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if (levelUse < levelNext) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) styler.SetLevel(lineCurrent, lev); // reset values for the next line lineCurrent++; stylePrev = style; style = styleNext; levelCurrent = levelNext; visibleChars = 0; // if the last characters are ;;+ then don't reset since the line continues on the next line. if (chPrev != '+' && chPrevPrev != ';' && chPrevPrevPrev != ';') { firstWordLen = 0; szDolen = 0; isFirstWordStarted = false; isFirstWordEnded = false; isDoLastWord = false; //blank out first word for (unsigned int i = 0; i < FIRST_WORD_MAX_LEN; i++) szFirstWord[i] = '\0'; } } // save the last processed characters if ((ch > 0) && !isspacechar(ch)) { chPrevPrevPrev = chPrevPrev; chPrevPrev = chPrev; chPrev = ch; } } //close folds on the last line - without this a 'phantom' //fold can appear when an open fold is on the last line //this can occur because functions and labels don't have an explicit end if (lineCurrent >= lastLine) { int lev = 0; lev |= SC_FOLDLEVELWHITEFLAG; styler.SetLevel(lineCurrent, lev); } } static const char * const powerProWordLists[] = { "Keyword list 1", "Keyword list 2", "Keyword list 3", "Keyword list 4", 0, }; static void ColourisePowerProDocWrapper(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { ColourisePowerProDoc(startPos, length, initStyle, keywordlists, styler, false); } LexerModule lmPowerPro(SCLEX_POWERPRO, ColourisePowerProDocWrapper, "powerpro", FoldPowerProDoc, powerProWordLists); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexHaskell.cxx000444001750001750 2625412021352776 25205 0ustar00azawawiazawawi000000000000/****************************************************************** * LexHaskell.cxx * * A haskell lexer for the scintilla code control. * Some stuff "lended" from LexPython.cxx and LexCPP.cxx. * External lexer stuff inspired from the caml external lexer. * * Written by Tobias Engvall - tumm at dtek dot chalmers dot se * * Several bug fixes by Krasimir Angelov - kr.angelov at gmail.com * * TODO: * * Implement a folder :) * * Nice Character-lexing (stuff inside '\''), LexPython has * this. * * *****************************************************************/ #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif #ifdef BUILD_AS_EXTERNAL_LEXER #include "ExternalLexer.h" #include "WindowAccessor.h" #define BUILD_EXTERNAL_LEXER 0 #endif #define HA_MODE_DEFAULT 0 #define HA_MODE_IMPORT1 1 #define HA_MODE_IMPORT2 2 #define HA_MODE_IMPORT3 3 #define HA_MODE_MODULE 4 #define HA_MODE_FFI 5 #define HA_MODE_TYPE 6 static inline bool IsNewline(const int ch) { return (ch == '\n' || ch == '\r'); } static inline bool IsWhitespace(const int ch) { return ( ch == ' ' || ch == '\t' || IsNewline(ch) ); } static inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '\''); } static void ColorizeHaskellDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; WordList &ffi = *keywordlists[1]; StyleContext sc(startPos, length, initStyle, styler); int lineCurrent = styler.GetLine(startPos); int state = lineCurrent ? styler.GetLineState(lineCurrent-1) : HA_MODE_DEFAULT; int mode = state & 0xF; int xmode = state >> 4; while (sc.More()) { // Check for state end // Operator if (sc.state == SCE_HA_OPERATOR) { if (isascii(sc.ch) && isoperator(static_cast(sc.ch))) { sc.Forward(); } else { styler.ColourTo(sc.currentPos - 1, sc.state); sc.ChangeState(SCE_HA_DEFAULT); } } // String else if (sc.state == SCE_HA_STRING) { if (sc.ch == '\"') { sc.Forward(); styler.ColourTo(sc.currentPos-1, sc.state); sc.ChangeState(SCE_HA_DEFAULT); } else if (sc.ch == '\\') { sc.Forward(2); } else if (sc.atLineEnd) { styler.ColourTo(sc.currentPos-1, sc.state); sc.ChangeState(SCE_HA_DEFAULT); } else { sc.Forward(); } } // Char else if (sc.state == SCE_HA_CHARACTER) { if (sc.ch == '\'') { sc.Forward(); styler.ColourTo(sc.currentPos-1, sc.state); sc.ChangeState(SCE_HA_DEFAULT); } else if (sc.ch == '\\') { sc.Forward(2); } else if (sc.atLineEnd) { styler.ColourTo(sc.currentPos-1, sc.state); sc.ChangeState(SCE_HA_DEFAULT); } else { sc.Forward(); } } // Number else if (sc.state == SCE_HA_NUMBER) { if (IsADigit(sc.ch, xmode)) { sc.Forward(); } else if ((xmode == 10) && (sc.ch == 'e' || sc.ch == 'E') && (IsADigit(sc.chNext) || sc.chNext == '+' || sc.chNext == '-')) { sc.Forward(); if (sc.ch == '+' || sc.ch == '-') sc.Forward(); } else { styler.ColourTo(sc.currentPos - 1, sc.state); sc.ChangeState(SCE_HA_DEFAULT); } } // Identifier else if (sc.state == SCE_HA_IDENTIFIER) { if (IsAWordChar(sc.ch)) { sc.Forward(); } else { char s[100]; sc.GetCurrent(s, sizeof(s)); int style = sc.state; int new_mode = 0; if (keywords.InList(s)) { style = SCE_HA_KEYWORD; } else if (isupper(s[0])) { if (mode >= HA_MODE_IMPORT1 && mode <= HA_MODE_IMPORT3) { style = SCE_HA_MODULE; new_mode = HA_MODE_IMPORT2; } else if (mode == HA_MODE_MODULE) style = SCE_HA_MODULE; else style = SCE_HA_CAPITAL; } else if (mode == HA_MODE_IMPORT1 && strcmp(s,"qualified") == 0) { style = SCE_HA_KEYWORD; new_mode = HA_MODE_IMPORT1; } else if (mode == HA_MODE_IMPORT2) { if (strcmp(s,"as") == 0) { style = SCE_HA_KEYWORD; new_mode = HA_MODE_IMPORT3; } else if (strcmp(s,"hiding") == 0) { style = SCE_HA_KEYWORD; } } else if (mode == HA_MODE_FFI) { if (ffi.InList(s)) { style = SCE_HA_KEYWORD; new_mode = HA_MODE_FFI; } } else if (mode == HA_MODE_TYPE) { if (strcmp(s,"family") == 0) style = SCE_HA_KEYWORD; } styler.ColourTo(sc.currentPos - 1, style); if (strcmp(s,"import") == 0 && mode != HA_MODE_FFI) new_mode = HA_MODE_IMPORT1; else if (strcmp(s,"module") == 0) new_mode = HA_MODE_MODULE; else if (strcmp(s,"foreign") == 0) new_mode = HA_MODE_FFI; else if (strcmp(s,"type") == 0) new_mode = HA_MODE_TYPE; sc.ChangeState(SCE_HA_DEFAULT); mode = new_mode; } } // Comments // Oneliner else if (sc.state == SCE_HA_COMMENTLINE) { if (sc.atLineEnd) { styler.ColourTo(sc.currentPos - 1, sc.state); sc.ChangeState(SCE_HA_DEFAULT); } else { sc.Forward(); } } // Nested else if (sc.state == SCE_HA_COMMENTBLOCK) { if (sc.Match("{-")) { sc.Forward(2); xmode++; } else if (sc.Match("-}")) { sc.Forward(2); xmode--; if (xmode == 0) { styler.ColourTo(sc.currentPos - 1, sc.state); sc.ChangeState(SCE_HA_DEFAULT); } } else { if (sc.atLineEnd) { // Remember the line state for future incremental lexing styler.SetLineState(lineCurrent, (xmode << 4) | mode); lineCurrent++; } sc.Forward(); } } // New state? if (sc.state == SCE_HA_DEFAULT) { // Digit if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext)) || (sc.ch == '-' && IsADigit(sc.chNext))) { styler.ColourTo(sc.currentPos - 1, sc.state); sc.ChangeState(SCE_HA_NUMBER); if (sc.ch == '0' && (sc.chNext == 'X' || sc.chNext == 'x')) { // Match anything starting with "0x" or "0X", too sc.Forward(2); xmode = 16; } else if (sc.ch == '0' && (sc.chNext == 'O' || sc.chNext == 'o')) { // Match anything starting with "0x" or "0X", too sc.Forward(2); xmode = 8; } else { sc.Forward(); xmode = 10; } mode = HA_MODE_DEFAULT; } // Comment line else if (sc.Match("--")) { styler.ColourTo(sc.currentPos - 1, sc.state); sc.Forward(2); sc.ChangeState(SCE_HA_COMMENTLINE); // Comment block } else if (sc.Match("{-")) { styler.ColourTo(sc.currentPos - 1, sc.state); sc.Forward(2); sc.ChangeState(SCE_HA_COMMENTBLOCK); xmode = 1; } // String else if (sc.Match('\"')) { styler.ColourTo(sc.currentPos - 1, sc.state); sc.Forward(); sc.ChangeState(SCE_HA_STRING); } // Character else if (sc.Match('\'')) { styler.ColourTo(sc.currentPos - 1, sc.state); sc.Forward(); sc.ChangeState(SCE_HA_CHARACTER); } else if (sc.ch == '(' || sc.ch == ')' || sc.ch == '{' || sc.ch == '}' || sc.ch == '[' || sc.ch == ']') { styler.ColourTo(sc.currentPos - 1, sc.state); sc.Forward(); styler.ColourTo(sc.currentPos - 1, SCE_HA_OPERATOR); mode = HA_MODE_DEFAULT; } // Operator else if (isascii(sc.ch) && isoperator(static_cast(sc.ch))) { styler.ColourTo(sc.currentPos - 1, sc.state); sc.Forward(); sc.ChangeState(SCE_HA_OPERATOR); mode = HA_MODE_DEFAULT; } // Keyword else if (IsAWordStart(sc.ch)) { styler.ColourTo(sc.currentPos - 1, sc.state); sc.Forward(); sc.ChangeState(SCE_HA_IDENTIFIER); } else { if (sc.atLineEnd) { // Remember the line state for future incremental lexing styler.SetLineState(lineCurrent, (xmode << 4) | mode); lineCurrent++; } sc.Forward(); } } } sc.Complete(); } // External stuff - used for dynamic-loading, not implemented in wxStyledTextCtrl yet. // Inspired by the caml external lexer - Credits to Robert Roessler - http://www.rftp.com #ifdef BUILD_EXTERNAL_LEXER static const char* LexerName = "haskell"; void EXT_LEXER_DECL Lex(unsigned int lexer, unsigned int startPos, int length, int initStyle, char *words[], WindowID window, char *props) { PropSetSimple ps; ps.SetMultiple(props); WindowAccessor wa(window, ps); int nWL = 0; for (; words[nWL]; nWL++) ; WordList** wl = new WordList* [nWL + 1]; int i = 0; for (; iSet(words[i]); } wl[i] = 0; ColorizeHaskellDoc(startPos, length, initStyle, wl, wa); wa.Flush(); for (i=nWL-1;i>=0;i--) delete wl[i]; delete [] wl; } void EXT_LEXER_DECL Fold (unsigned int lexer, unsigned int startPos, int length, int initStyle, char *words[], WindowID window, char *props) { } int EXT_LEXER_DECL GetLexerCount() { return 1; } void EXT_LEXER_DECL GetLexerName(unsigned int Index, char *name, int buflength) { if (buflength > 0) { buflength--; int n = strlen(LexerName); if (n > buflength) n = buflength; memcpy(name, LexerName, n), name[n] = '\0'; } } #endif LexerModule lmHaskell(SCLEX_HASKELL, ColorizeHaskellDoc, "haskell"); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/Decoration.h000444001750001750 270312021352777 24637 0ustar00azawawiazawawi000000000000/** @file Decoration.h ** Visual elements added over text. **/ // Copyright 1998-2007 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef DECORATION_H #define DECORATION_H #ifdef SCI_NAMESPACE namespace Scintilla { #endif class Decoration { public: Decoration *next; RunStyles rs; int indicator; Decoration(int indicator_); ~Decoration(); bool Empty(); }; class DecorationList { int currentIndicator; int currentValue; Decoration *current; int lengthDocument; Decoration *DecorationFromIndicator(int indicator); Decoration *Create(int indicator, int length); void Delete(int indicator); void DeleteAnyEmpty(); public: Decoration *root; bool clickNotified; DecorationList(); ~DecorationList(); void SetCurrentIndicator(int indicator); int GetCurrentIndicator() const { return currentIndicator; } void SetCurrentValue(int value); int GetCurrentValue() const { return currentValue; } // Returns true if some values may have changed bool FillRange(int &position, int value, int &fillLength); void InsertSpace(int position, int insertLength); void DeleteRange(int position, int deleteLength); int AllOnFor(int position); int ValueAt(int indicator, int position); int Start(int indicator, int position); int End(int indicator, int position); }; #ifdef SCI_NAMESPACE } #endif #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexerModule.h000444001750001750 431412021352777 24775 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexerModule.h ** Colourise for particular languages. **/ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef LEXERMODULE_H #define LEXERMODULE_H #ifdef SCI_NAMESPACE namespace Scintilla { #endif class Accessor; class WordList; typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle, WordList *keywordlists[], Accessor &styler); typedef ILexer *(*LexerFactoryFunction)(); /** * 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 * module appropriate to a particular language. */ class LexerModule { protected: int language; LexerFunction fnLexer; LexerFunction fnFolder; LexerFactoryFunction fnFactory; const char * const * wordListDescriptions; int styleBits; public: const char *languageName; LexerModule(int language_, LexerFunction fnLexer_, const char *languageName_=0, LexerFunction fnFolder_=0, const char * const wordListDescriptions_[] = NULL, int styleBits_=5); LexerModule(int language_, LexerFactoryFunction fnFactory_, const char *languageName_, const char * const wordListDescriptions_[] = NULL, int styleBits_=8); virtual ~LexerModule() { } int GetLanguage() const { return language; } // -1 is returned if no WordList information is available int GetNumWordLists() const; const char *GetWordListDescription(int index) const; int GetStyleBitsNeeded() const; ILexer *Create() const; virtual void Lex(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) const; virtual void Fold(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) const; friend class Catalogue; }; inline int Maximum(int a, int b) { return (a > b) ? a : b; } // Shut up annoying Visual C++ warnings: #ifdef _MSC_VER #pragma warning(disable: 4244 4309 4514 4710) #endif #ifdef SCI_NAMESPACE } #endif #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexBash.cxx000444001750001750 5112612021352777 24474 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexBash.cxx ** Lexer for Bash. **/ // Copyright 2004-2010 by Neil Hodgson // Adapted from LexPerl by Kein-Hong Man 2004 // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif #define HERE_DELIM_MAX 256 // define this if you want 'invalid octals' to be marked as errors // usually, this is not a good idea, permissive lexing is better #undef PEDANTIC_OCTAL #define BASH_BASE_ERROR 65 #define BASH_BASE_DECIMAL 66 #define BASH_BASE_HEX 67 #ifdef PEDANTIC_OCTAL #define BASH_BASE_OCTAL 68 #define BASH_BASE_OCTAL_ERROR 69 #endif // state constants for parts of a bash command segment #define BASH_CMD_BODY 0 #define BASH_CMD_START 1 #define BASH_CMD_WORD 2 #define BASH_CMD_TEST 3 #define BASH_CMD_ARITH 4 #define BASH_CMD_DELIM 5 static inline int translateBashDigit(int ch) { if (ch >= '0' && ch <= '9') { return ch - '0'; } else if (ch >= 'a' && ch <= 'z') { return ch - 'a' + 10; } else if (ch >= 'A' && ch <= 'Z') { return ch - 'A' + 36; } else if (ch == '@') { return 62; } else if (ch == '_') { return 63; } return BASH_BASE_ERROR; } static inline int getBashNumberBase(char *s) { int i = 0; int base = 0; while (*s) { base = base * 10 + (*s++ - '0'); i++; } if (base > 64 || i > 2) { return BASH_BASE_ERROR; } return base; } static int opposite(int ch) { if (ch == '(') return ')'; if (ch == '[') return ']'; if (ch == '{') return '}'; if (ch == '<') return '>'; return ch; } static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; WordList cmdDelimiter, bashStruct, bashStruct_in; cmdDelimiter.Set("| || |& & && ; ;; ( ) { }"); bashStruct.Set("if elif fi while until else then do done esac eval"); bashStruct_in.Set("for case select"); CharacterSet setWordStart(CharacterSet::setAlpha, "_"); // note that [+-] are often parts of identifiers in shell scripts CharacterSet setWord(CharacterSet::setAlphaNum, "._+-"); CharacterSet setBashOperator(CharacterSet::setNone, "^&%()-+=|{}[]:;>,*/(ch); Delimiter[DelimiterLength] = '\0'; } ~HereDocCls() { delete []Delimiter; } }; HereDocCls HereDoc; class QuoteCls { // Class to manage quote pairs (simplified vs LexPerl) public: int Count; int Up, Down; QuoteCls() { Count = 0; Up = '\0'; Down = '\0'; } void Open(int u) { Count++; Up = u; Down = opposite(Up); } void Start(int u) { Count = 0; Open(u); } }; QuoteCls Quote; int numBase = 0; int digit; unsigned int endPos = startPos + length; int cmdState = BASH_CMD_START; int testExprType = 0; // Always backtracks to the start of a line that is not a continuation // of the previous line (i.e. start of a bash command segment) int ln = styler.GetLine(startPos); for (;;) { startPos = styler.LineStart(ln); if (ln == 0 || styler.GetLineState(ln) == BASH_CMD_START) break; ln--; } initStyle = SCE_SH_DEFAULT; StyleContext sc(startPos, endPos - startPos, initStyle, styler); for (; sc.More(); sc.Forward()) { // handle line continuation, updates per-line stored state if (sc.atLineStart) { ln = styler.GetLine(sc.currentPos); if (sc.state == SCE_SH_STRING || sc.state == SCE_SH_BACKTICKS || sc.state == SCE_SH_CHARACTER || sc.state == SCE_SH_HERE_Q || sc.state == SCE_SH_COMMENTLINE || sc.state == SCE_SH_PARAM) { // force backtrack while retaining cmdState styler.SetLineState(ln, BASH_CMD_BODY); } else { if (ln > 0) { if ((sc.GetRelative(-3) == '\\' && sc.GetRelative(-2) == '\r' && sc.chPrev == '\n') || sc.GetRelative(-2) == '\\') { // handle '\' line continuation // retain last line's state } else cmdState = BASH_CMD_START; } styler.SetLineState(ln, cmdState); } } // controls change of cmdState at the end of a non-whitespace element // states BODY|TEST|ARITH persist until the end of a command segment // state WORD persist, but ends with 'in' or 'do' construct keywords int cmdStateNew = BASH_CMD_BODY; if (cmdState == BASH_CMD_TEST || cmdState == BASH_CMD_ARITH || cmdState == BASH_CMD_WORD) cmdStateNew = cmdState; int stylePrev = sc.state; // Determine if the current state should terminate. switch (sc.state) { case SCE_SH_OPERATOR: sc.SetState(SCE_SH_DEFAULT); if (cmdState == BASH_CMD_DELIM) // if command delimiter, start new command cmdStateNew = BASH_CMD_START; else if (sc.chPrev == '\\') // propagate command state if line continued cmdStateNew = cmdState; break; case SCE_SH_WORD: // "." never used in Bash variable names but used in file names if (!setWord.Contains(sc.ch)) { char s[500]; char s2[10]; sc.GetCurrent(s, sizeof(s)); // allow keywords ending in a whitespace or command delimiter s2[0] = static_cast(sc.ch); s2[1] = '\0'; bool keywordEnds = IsASpace(sc.ch) || cmdDelimiter.InList(s2); // 'in' or 'do' may be construct keywords if (cmdState == BASH_CMD_WORD) { if (strcmp(s, "in") == 0 && keywordEnds) cmdStateNew = BASH_CMD_BODY; else if (strcmp(s, "do") == 0 && keywordEnds) cmdStateNew = BASH_CMD_START; else sc.ChangeState(SCE_SH_IDENTIFIER); sc.SetState(SCE_SH_DEFAULT); break; } // a 'test' keyword starts a test expression if (strcmp(s, "test") == 0) { if (cmdState == BASH_CMD_START && keywordEnds) { cmdStateNew = BASH_CMD_TEST; testExprType = 0; } else sc.ChangeState(SCE_SH_IDENTIFIER); } // detect bash construct keywords else if (bashStruct.InList(s)) { if (cmdState == BASH_CMD_START && keywordEnds) cmdStateNew = BASH_CMD_START; else sc.ChangeState(SCE_SH_IDENTIFIER); } // 'for'|'case'|'select' needs 'in'|'do' to be highlighted later else if (bashStruct_in.InList(s)) { if (cmdState == BASH_CMD_START && keywordEnds) cmdStateNew = BASH_CMD_WORD; else sc.ChangeState(SCE_SH_IDENTIFIER); } // disambiguate option items and file test operators else if (s[0] == '-') { if (cmdState != BASH_CMD_TEST) sc.ChangeState(SCE_SH_IDENTIFIER); } // disambiguate keywords and identifiers else if (cmdState != BASH_CMD_START || !(keywords.InList(s) && keywordEnds)) { sc.ChangeState(SCE_SH_IDENTIFIER); } sc.SetState(SCE_SH_DEFAULT); } break; case SCE_SH_IDENTIFIER: if (sc.chPrev == '\\') { // for escaped chars sc.ForwardSetState(SCE_SH_DEFAULT); } else if (!setWord.Contains(sc.ch)) { sc.SetState(SCE_SH_DEFAULT); } break; case SCE_SH_NUMBER: digit = translateBashDigit(sc.ch); if (numBase == BASH_BASE_DECIMAL) { if (sc.ch == '#') { char s[10]; sc.GetCurrent(s, sizeof(s)); numBase = getBashNumberBase(s); if (numBase != BASH_BASE_ERROR) break; } else if (IsADigit(sc.ch)) break; } else if (numBase == BASH_BASE_HEX) { if (IsADigit(sc.ch, 16)) break; #ifdef PEDANTIC_OCTAL } else if (numBase == BASH_BASE_OCTAL || numBase == BASH_BASE_OCTAL_ERROR) { if (digit <= 7) break; if (digit <= 9) { numBase = BASH_BASE_OCTAL_ERROR; break; } #endif } else if (numBase == BASH_BASE_ERROR) { if (digit <= 9) break; } else { // DD#DDDD number style handling if (digit != BASH_BASE_ERROR) { if (numBase <= 36) { // case-insensitive if base<=36 if (digit >= 36) digit -= 26; } if (digit < numBase) break; if (digit <= 9) { numBase = BASH_BASE_ERROR; break; } } } // fallthrough when number is at an end or error if (numBase == BASH_BASE_ERROR #ifdef PEDANTIC_OCTAL || numBase == BASH_BASE_OCTAL_ERROR #endif ) { sc.ChangeState(SCE_SH_ERROR); } sc.SetState(SCE_SH_DEFAULT); break; case SCE_SH_COMMENTLINE: if (sc.atLineEnd && sc.chPrev != '\\') { sc.SetState(SCE_SH_DEFAULT); } break; case SCE_SH_HERE_DELIM: // From Bash info: // --------------- // Specifier format is: <<[-]WORD // Optional '-' is for removal of leading tabs from here-doc. // Whitespace acceptable after <<[-] operator // if (HereDoc.State == 0) { // '<<' encountered HereDoc.Quote = sc.chNext; HereDoc.Quoted = false; HereDoc.DelimiterLength = 0; HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0'; if (sc.chNext == '\'' || sc.chNext == '\"') { // a quoted here-doc delimiter (' or ") sc.Forward(); HereDoc.Quoted = true; HereDoc.State = 1; } else if (!HereDoc.Indent && sc.chNext == '-') { // <<- indent case HereDoc.Indent = true; } else if (setHereDoc.Contains(sc.chNext)) { // an unquoted here-doc delimiter, no special handling // TODO check what exactly bash considers part of the delim HereDoc.State = 1; } else if (sc.chNext == '<') { // HERE string <<< sc.Forward(); sc.ForwardSetState(SCE_SH_DEFAULT); } else if (IsASpace(sc.chNext)) { // eat whitespace } else if (setLeftShift.Contains(sc.chNext)) { // left shift << or <<= operator cases sc.ChangeState(SCE_SH_OPERATOR); sc.ForwardSetState(SCE_SH_DEFAULT); } else { // symbols terminates; deprecated zero-length delimiter HereDoc.State = 1; } } else if (HereDoc.State == 1) { // collect the delimiter if (setHereDoc2.Contains(sc.ch) || sc.chPrev == '\\') { HereDoc.Append(sc.ch); } else if (HereDoc.Quoted && sc.ch == HereDoc.Quote) { // closing quote => end of delimiter sc.ForwardSetState(SCE_SH_DEFAULT); } else if (sc.ch == '\\') { // skip escape prefix } else { sc.SetState(SCE_SH_DEFAULT); } if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) { // force blowup sc.SetState(SCE_SH_ERROR); HereDoc.State = 0; } } break; case SCE_SH_HERE_Q: // HereDoc.State == 2 if (sc.atLineStart) { sc.SetState(SCE_SH_HERE_Q); int prefixws = 0; while (IsASpace(sc.ch) && !sc.atLineEnd) { // whitespace prefix sc.Forward(); prefixws++; } if (prefixws > 0) sc.SetState(SCE_SH_HERE_Q); while (!sc.atLineEnd) { sc.Forward(); } char s[HERE_DELIM_MAX]; sc.GetCurrent(s, sizeof(s)); if (sc.LengthCurrent() == 0) break; if (s[strlen(s) - 1] == '\r') s[strlen(s) - 1] = '\0'; if (strcmp(HereDoc.Delimiter, s) == 0) { if ((prefixws == 0) || // indentation rule (prefixws > 0 && HereDoc.Indent)) { sc.SetState(SCE_SH_DEFAULT); break; } } } break; case SCE_SH_SCALAR: // variable names if (!setParam.Contains(sc.ch)) { if (sc.LengthCurrent() == 1) { // Special variable: $(, $_ etc. sc.ForwardSetState(SCE_SH_DEFAULT); } else { sc.SetState(SCE_SH_DEFAULT); } } break; case SCE_SH_STRING: // delimited styles case SCE_SH_CHARACTER: case SCE_SH_BACKTICKS: case SCE_SH_PARAM: if (sc.ch == '\\' && Quote.Up != '\\') { sc.Forward(); } else if (sc.ch == Quote.Down) { Quote.Count--; if (Quote.Count == 0) { sc.ForwardSetState(SCE_SH_DEFAULT); } } else if (sc.ch == Quote.Up) { Quote.Count++; } break; } // Must check end of HereDoc state 1 before default state is handled if (HereDoc.State == 1 && sc.atLineEnd) { // Begin of here-doc (the line after the here-doc delimiter): // Lexically, the here-doc starts from the next line after the >>, but the // first line of here-doc seem to follow the style of the last EOL sequence HereDoc.State = 2; if (HereDoc.Quoted) { if (sc.state == SCE_SH_HERE_DELIM) { // Missing quote at end of string! We are stricter than bash. // Colour here-doc anyway while marking this bit as an error. sc.ChangeState(SCE_SH_ERROR); } // HereDoc.Quote always == '\'' } sc.SetState(SCE_SH_HERE_Q); } // update cmdState about the current command segment if (stylePrev != SCE_SH_DEFAULT && sc.state == SCE_SH_DEFAULT) { cmdState = cmdStateNew; } // Determine if a new state should be entered. if (sc.state == SCE_SH_DEFAULT) { if (sc.ch == '\\') { // Bash can escape any non-newline as a literal sc.SetState(SCE_SH_IDENTIFIER); if (sc.chNext == '\r' || sc.chNext == '\n') sc.SetState(SCE_SH_OPERATOR); } else if (IsADigit(sc.ch)) { sc.SetState(SCE_SH_NUMBER); numBase = BASH_BASE_DECIMAL; if (sc.ch == '0') { // hex,octal if (sc.chNext == 'x' || sc.chNext == 'X') { numBase = BASH_BASE_HEX; sc.Forward(); } else if (IsADigit(sc.chNext)) { #ifdef PEDANTIC_OCTAL numBase = BASH_BASE_OCTAL; #else numBase = BASH_BASE_HEX; #endif } } } else if (setWordStart.Contains(sc.ch)) { sc.SetState(SCE_SH_WORD); } else if (sc.ch == '#') { sc.SetState(SCE_SH_COMMENTLINE); } else if (sc.ch == '\"') { sc.SetState(SCE_SH_STRING); Quote.Start(sc.ch); } else if (sc.ch == '\'') { sc.SetState(SCE_SH_CHARACTER); Quote.Start(sc.ch); } else if (sc.ch == '`') { sc.SetState(SCE_SH_BACKTICKS); Quote.Start(sc.ch); } else if (sc.ch == '$') { if (sc.Match("$((")) { sc.SetState(SCE_SH_OPERATOR); // handle '((' later continue; } sc.SetState(SCE_SH_SCALAR); sc.Forward(); if (sc.ch == '{') { sc.ChangeState(SCE_SH_PARAM); } else if (sc.ch == '\'') { sc.ChangeState(SCE_SH_CHARACTER); } else if (sc.ch == '"') { sc.ChangeState(SCE_SH_STRING); } else if (sc.ch == '(' || sc.ch == '`') { sc.ChangeState(SCE_SH_BACKTICKS); } else { continue; // scalar has no delimiter pair } // fallthrough, open delim for $[{'"(`] Quote.Start(sc.ch); } else if (sc.Match('<', '<')) { sc.SetState(SCE_SH_HERE_DELIM); HereDoc.State = 0; HereDoc.Indent = false; } else if (sc.ch == '-' && // one-char file test operators setSingleCharOp.Contains(sc.chNext) && !setWord.Contains(sc.GetRelative(2)) && IsASpace(sc.chPrev)) { sc.SetState(SCE_SH_WORD); sc.Forward(); } else if (setBashOperator.Contains(sc.ch)) { char s[10]; bool isCmdDelim = false; sc.SetState(SCE_SH_OPERATOR); // handle opening delimiters for test/arithmetic expressions - ((,[[,[ if (cmdState == BASH_CMD_START || cmdState == BASH_CMD_BODY) { if (sc.Match('(', '(')) { cmdState = BASH_CMD_ARITH; sc.Forward(); } else if (sc.Match('[', '[') && IsASpace(sc.GetRelative(2))) { cmdState = BASH_CMD_TEST; testExprType = 1; sc.Forward(); } else if (sc.ch == '[' && IsASpace(sc.chNext)) { cmdState = BASH_CMD_TEST; testExprType = 2; } } // special state -- for ((x;y;z)) in ... looping if (cmdState == BASH_CMD_WORD && sc.Match('(', '(')) { cmdState = BASH_CMD_ARITH; sc.Forward(); continue; } // handle command delimiters in command START|BODY|WORD state, also TEST if 'test' if (cmdState == BASH_CMD_START || cmdState == BASH_CMD_BODY || cmdState == BASH_CMD_WORD || (cmdState == BASH_CMD_TEST && testExprType == 0)) { s[0] = static_cast(sc.ch); if (setBashOperator.Contains(sc.chNext)) { s[1] = static_cast(sc.chNext); s[2] = '\0'; isCmdDelim = cmdDelimiter.InList(s); if (isCmdDelim) sc.Forward(); } if (!isCmdDelim) { s[1] = '\0'; isCmdDelim = cmdDelimiter.InList(s); } if (isCmdDelim) { cmdState = BASH_CMD_DELIM; continue; } } // handle closing delimiters for test/arithmetic expressions - )),]],] if (cmdState == BASH_CMD_ARITH && sc.Match(')', ')')) { cmdState = BASH_CMD_BODY; sc.Forward(); } else if (cmdState == BASH_CMD_TEST && IsASpace(sc.chPrev)) { if (sc.Match(']', ']') && testExprType == 1) { sc.Forward(); cmdState = BASH_CMD_BODY; } else if (sc.ch == ']' && testExprType == 2) { cmdState = BASH_CMD_BODY; } } } }// sc.state } sc.Complete(); } static bool IsCommentLine(int line, Accessor &styler) { int pos = styler.LineStart(line); int eol_pos = styler.LineStart(line + 1) - 1; for (int i = pos; i < eol_pos; i++) { char ch = styler[i]; if (ch == '#') return true; else if (ch != ' ' && ch != '\t') return false; } return false; } static void FoldBashDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; unsigned int endPos = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); // Comment folding if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) { if (!IsCommentLine(lineCurrent - 1, styler) && IsCommentLine(lineCurrent + 1, styler)) levelCurrent++; else if (IsCommentLine(lineCurrent - 1, styler) && !IsCommentLine(lineCurrent + 1, styler)) levelCurrent--; } if (style == SCE_SH_OPERATOR) { if (ch == '{') { levelCurrent++; } else if (ch == '}') { levelCurrent--; } } // Here Document folding if (style == SCE_SH_HERE_DELIM) { if (ch == '<' && chNext == '<') { levelCurrent++; } } else if (style == SCE_SH_HERE_Q && styler.StyleAt(i+1) == SCE_PL_DEFAULT) { levelCurrent--; } if (atEOL) { int lev = levelPrev; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if ((levelCurrent > levelPrev) && (visibleChars > 0)) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelPrev = levelCurrent; visibleChars = 0; } if (!isspacechar(ch)) visibleChars++; } // Fill in the real level of the next line, keeping the current flags as they will be filled in later int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, levelPrev | flagsNext); } static const char * const bashWordListDesc[] = { "Keywords", 0 }; LexerModule lmBash(SCLEX_BASH, ColouriseBashDoc, "bash", FoldBashDoc, bashWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexCrontab.cxx000444001750001750 1641412021352777 25210 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexCrontab.cxx ** Lexer to use with extended crontab files used by a powerful ** Windows scheduler/event monitor/automation manager nnCron. ** (http://nemtsev.eserv.ru/) **/ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static void ColouriseNncrontabDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) { int state = SCE_NNCRONTAB_DEFAULT; char chNext = styler[startPos]; int lengthDoc = startPos + length; // create a buffer large enough to take the largest chunk... char *buffer = new char[length]; int bufferCount = 0; // used when highliting environment variables inside quoted string: bool insideString = false; // this assumes that we have 3 keyword list in conf.properties WordList §ion = *keywordLists[0]; WordList &keyword = *keywordLists[1]; WordList &modifier = *keywordLists[2]; // go through all provided text segment // using the hand-written state machine shown below styler.StartAt(startPos); styler.StartSegment(startPos); for (int i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); if (styler.IsLeadByte(ch)) { chNext = styler.SafeGetCharAt(i + 2); i++; continue; } switch(state) { case SCE_NNCRONTAB_DEFAULT: if( ch == '\n' || ch == '\r' || ch == '\t' || ch == ' ') { // whitespace is simply ignored here... styler.ColourTo(i,SCE_NNCRONTAB_DEFAULT); break; } else if( ch == '#' && styler.SafeGetCharAt(i+1) == '(') { // signals the start of a task... state = SCE_NNCRONTAB_TASK; styler.ColourTo(i,SCE_NNCRONTAB_TASK); } else if( ch == '\\' && (styler.SafeGetCharAt(i+1) == ' ' || styler.SafeGetCharAt(i+1) == '\t')) { // signals the start of an extended comment... state = SCE_NNCRONTAB_COMMENT; styler.ColourTo(i,SCE_NNCRONTAB_COMMENT); } else if( ch == '#' ) { // signals the start of a plain comment... state = SCE_NNCRONTAB_COMMENT; styler.ColourTo(i,SCE_NNCRONTAB_COMMENT); } else if( ch == ')' && styler.SafeGetCharAt(i+1) == '#') { // signals the end of a task... state = SCE_NNCRONTAB_TASK; styler.ColourTo(i,SCE_NNCRONTAB_TASK); } else if( ch == '"') { state = SCE_NNCRONTAB_STRING; styler.ColourTo(i,SCE_NNCRONTAB_STRING); } else if( ch == '%') { // signals environment variables state = SCE_NNCRONTAB_ENVIRONMENT; styler.ColourTo(i,SCE_NNCRONTAB_ENVIRONMENT); } else if( ch == '<' && styler.SafeGetCharAt(i+1) == '%') { // signals environment variables state = SCE_NNCRONTAB_ENVIRONMENT; styler.ColourTo(i,SCE_NNCRONTAB_ENVIRONMENT); } else if( ch == '*' ) { // signals an asterisk // no state jump necessary for this simple case... styler.ColourTo(i,SCE_NNCRONTAB_ASTERISK); } else if( (isascii(ch) && isalpha(ch)) || ch == '<' ) { // signals the start of an identifier bufferCount = 0; buffer[bufferCount++] = ch; state = SCE_NNCRONTAB_IDENTIFIER; } else if( isascii(ch) && isdigit(ch) ) { // signals the start of a number bufferCount = 0; buffer[bufferCount++] = ch; state = SCE_NNCRONTAB_NUMBER; } else { // style it the default style.. styler.ColourTo(i,SCE_NNCRONTAB_DEFAULT); } break; case SCE_NNCRONTAB_COMMENT: // if we find a newline here, // we simply go to default state // else continue to work on it... if( ch == '\n' || ch == '\r' ) { state = SCE_NNCRONTAB_DEFAULT; } else { styler.ColourTo(i,SCE_NNCRONTAB_COMMENT); } break; case SCE_NNCRONTAB_TASK: // if we find a newline here, // we simply go to default state // else continue to work on it... if( ch == '\n' || ch == '\r' ) { state = SCE_NNCRONTAB_DEFAULT; } else { styler.ColourTo(i,SCE_NNCRONTAB_TASK); } break; case SCE_NNCRONTAB_STRING: if( ch == '%' ) { state = SCE_NNCRONTAB_ENVIRONMENT; insideString = true; styler.ColourTo(i-1,SCE_NNCRONTAB_STRING); break; } // if we find the end of a string char, we simply go to default state // else we're still dealing with an string... if( (ch == '"' && styler.SafeGetCharAt(i-1)!='\\') || (ch == '\n') || (ch == '\r') ) { state = SCE_NNCRONTAB_DEFAULT; } styler.ColourTo(i,SCE_NNCRONTAB_STRING); break; case SCE_NNCRONTAB_ENVIRONMENT: // if we find the end of a string char, we simply go to default state // else we're still dealing with an string... if( ch == '%' && insideString ) { state = SCE_NNCRONTAB_STRING; insideString = false; break; } if( (ch == '%' && styler.SafeGetCharAt(i-1)!='\\') || (ch == '\n') || (ch == '\r') || (ch == '>') ) { state = SCE_NNCRONTAB_DEFAULT; styler.ColourTo(i,SCE_NNCRONTAB_ENVIRONMENT); break; } styler.ColourTo(i+1,SCE_NNCRONTAB_ENVIRONMENT); break; case SCE_NNCRONTAB_IDENTIFIER: // stay in CONF_IDENTIFIER state until we find a non-alphanumeric if( (isascii(ch) && isalnum(ch)) || (ch == '_') || (ch == '-') || (ch == '/') || (ch == '$') || (ch == '.') || (ch == '<') || (ch == '>') || (ch == '@') ) { buffer[bufferCount++] = ch; } else { state = SCE_NNCRONTAB_DEFAULT; buffer[bufferCount] = '\0'; // check if the buffer contains a keyword, // and highlight it if it is a keyword... if(section.InList(buffer)) { styler.ColourTo(i,SCE_NNCRONTAB_SECTION ); } else if(keyword.InList(buffer)) { styler.ColourTo(i-1,SCE_NNCRONTAB_KEYWORD ); } // else if(strchr(buffer,'/') || strchr(buffer,'.')) { // styler.ColourTo(i-1,SCE_NNCRONTAB_EXTENSION); // } else if(modifier.InList(buffer)) { styler.ColourTo(i-1,SCE_NNCRONTAB_MODIFIER ); } else { styler.ColourTo(i-1,SCE_NNCRONTAB_DEFAULT); } // push back the faulty character chNext = styler[i--]; } break; case SCE_NNCRONTAB_NUMBER: // stay in CONF_NUMBER state until we find a non-numeric if( isascii(ch) && isdigit(ch) /* || ch == '.' */ ) { buffer[bufferCount++] = ch; } else { state = SCE_NNCRONTAB_DEFAULT; buffer[bufferCount] = '\0'; // Colourize here... (normal number) styler.ColourTo(i-1,SCE_NNCRONTAB_NUMBER); // push back a character chNext = styler[i--]; } break; } } delete []buffer; } static const char * const cronWordListDesc[] = { "Section keywords and Forth words", "nnCrontab keywords", "Modifiers", 0 }; LexerModule lmNncrontab(SCLEX_NNCRONTAB, ColouriseNncrontabDoc, "nncrontab", 0, cronWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/Selection.cxx000444001750001750 2237612021352777 25100 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file Selection.cxx ** Classes maintaining the selection. **/ // Copyright 2009 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include "Platform.h" #include "Scintilla.h" #include "Selection.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif void SelectionPosition::MoveForInsertDelete(bool insertion, int startChange, int length) { if (position == startChange) { virtualSpace = 0; } if (insertion) { if (position > startChange) { position += length; } } else { if (position > startChange) { int endDeletion = startChange + length; if (position > endDeletion) { position -= length; } else { position = startChange; virtualSpace = 0; } } } } bool SelectionPosition::operator <(const SelectionPosition &other) const { if (position == other.position) return virtualSpace < other.virtualSpace; else return position < other.position; } bool SelectionPosition::operator >(const SelectionPosition &other) const { if (position == other.position) return virtualSpace > other.virtualSpace; else return position > other.position; } bool SelectionPosition::operator <=(const SelectionPosition &other) const { if (position == other.position && virtualSpace == other.virtualSpace) return true; else return other > *this; } bool SelectionPosition::operator >=(const SelectionPosition &other) const { if (position == other.position && virtualSpace == other.virtualSpace) return true; else return *this > other; } int SelectionRange::Length() const { if (anchor > caret) { return anchor.Position() - caret.Position(); } else { return caret.Position() - anchor.Position(); } } bool SelectionRange::Contains(int pos) const { if (anchor > caret) return (pos >= caret.Position()) && (pos <= anchor.Position()); else return (pos >= anchor.Position()) && (pos <= caret.Position()); } bool SelectionRange::Contains(SelectionPosition sp) const { if (anchor > caret) return (sp >= caret) && (sp <= anchor); else return (sp >= anchor) && (sp <= caret); } bool SelectionRange::ContainsCharacter(int posCharacter) const { if (anchor > caret) return (posCharacter >= caret.Position()) && (posCharacter < anchor.Position()); else return (posCharacter >= anchor.Position()) && (posCharacter < caret.Position()); } SelectionSegment SelectionRange::Intersect(SelectionSegment check) const { SelectionSegment inOrder(caret, anchor); if ((inOrder.start <= check.end) || (inOrder.end >= check.start)) { SelectionSegment portion = check; if (portion.start < inOrder.start) portion.start = inOrder.start; if (portion.end > inOrder.end) portion.end = inOrder.end; if (portion.start > portion.end) return SelectionSegment(); else return portion; } else { return SelectionSegment(); } } bool SelectionRange::Trim(SelectionRange range) { SelectionPosition startRange = range.Start(); SelectionPosition endRange = range.End(); SelectionPosition start = Start(); SelectionPosition end = End(); PLATFORM_ASSERT(start <= end); PLATFORM_ASSERT(startRange <= endRange); if ((startRange <= end) && (endRange >= start)) { if ((start > startRange) && (end < endRange)) { // Completely covered by range -> empty at start end = start; } else if ((start < startRange) && (end > endRange)) { // Completely covers range -> empty at start end = start; } else if (start <= startRange) { // Trim end end = startRange; } else { // PLATFORM_ASSERT(end >= endRange); // Trim start start = endRange; } if (anchor > caret) { caret = start; anchor = end; } else { anchor = start; caret = end; } return Empty(); } else { return false; } } // If range is all virtual collapse to start of virtual space void SelectionRange::MinimizeVirtualSpace() { if (caret.Position() == anchor.Position()) { int virtualSpace = caret.VirtualSpace(); if (virtualSpace > anchor.VirtualSpace()) virtualSpace = anchor.VirtualSpace(); caret.SetVirtualSpace(virtualSpace); anchor.SetVirtualSpace(virtualSpace); } } Selection::Selection() : mainRange(0), moveExtends(false), tentativeMain(false), selType(selStream) { AddSelection(SelectionPosition(0)); } Selection::~Selection() { } bool Selection::IsRectangular() const { return (selType == selRectangle) || (selType == selThin); } int Selection::MainCaret() const { return ranges[mainRange].caret.Position(); } int Selection::MainAnchor() const { return ranges[mainRange].anchor.Position(); } SelectionRange &Selection::Rectangular() { return rangeRectangular; } SelectionSegment Selection::Limits() const { if (ranges.empty()) { return SelectionSegment(); } else { SelectionSegment sr(ranges[0].anchor, ranges[0].caret); for (size_t i=1; i ranges[i].Start().Position()) && (pos <= ranges[i].End().Position())) return i == mainRange ? 1 : 2; } return 0; } int Selection::VirtualSpaceFor(int pos) const { int virtualSpace = 0; for (size_t i=0; i= j) mainRange--; } else { j++; } } } } } void Selection::RotateMain() { mainRange = (mainRange + 1) % ranges.size(); } Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexVerilog.cxx000444001750001750 2767412021352777 25241 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexVerilog.cxx ** Lexer for Verilog. ** Written by Avi Yegudin, based on C++ lexer by Neil Hodgson **/ // Copyright 1998-2002 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '\''|| ch == '$'); } static inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '$'); } static void ColouriseVerilogDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; WordList &keywords3 = *keywordlists[2]; WordList &keywords4 = *keywordlists[3]; // Do not leak onto next line if (initStyle == SCE_V_STRINGEOL) initStyle = SCE_V_DEFAULT; StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { if (sc.atLineStart && (sc.state == SCE_V_STRING)) { // Prevent SCE_V_STRINGEOL from leaking back to previous line sc.SetState(SCE_V_STRING); } // Handle line continuation generically. if (sc.ch == '\\') { if (sc.chNext == '\n' || sc.chNext == '\r') { sc.Forward(); if (sc.ch == '\r' && sc.chNext == '\n') { sc.Forward(); } continue; } } // Determine if the current state should terminate. if (sc.state == SCE_V_OPERATOR) { sc.SetState(SCE_V_DEFAULT); } else if (sc.state == SCE_V_NUMBER) { if (!IsAWordChar(sc.ch)) { sc.SetState(SCE_V_DEFAULT); } } else if (sc.state == SCE_V_IDENTIFIER) { if (!IsAWordChar(sc.ch) || (sc.ch == '.')) { char s[100]; sc.GetCurrent(s, sizeof(s)); if (keywords.InList(s)) { sc.ChangeState(SCE_V_WORD); } else if (keywords2.InList(s)) { sc.ChangeState(SCE_V_WORD2); } else if (keywords3.InList(s)) { sc.ChangeState(SCE_V_WORD3); } else if (keywords4.InList(s)) { sc.ChangeState(SCE_V_USER); } sc.SetState(SCE_V_DEFAULT); } } else if (sc.state == SCE_V_PREPROCESSOR) { if (!IsAWordChar(sc.ch)) { sc.SetState(SCE_V_DEFAULT); } } else if (sc.state == SCE_V_COMMENT) { if (sc.Match('*', '/')) { sc.Forward(); sc.ForwardSetState(SCE_V_DEFAULT); } } else if (sc.state == SCE_V_COMMENTLINE || sc.state == SCE_V_COMMENTLINEBANG) { if (sc.atLineStart) { sc.SetState(SCE_V_DEFAULT); } } else if (sc.state == SCE_V_STRING) { if (sc.ch == '\\') { if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { sc.Forward(); } } else if (sc.ch == '\"') { sc.ForwardSetState(SCE_V_DEFAULT); } else if (sc.atLineEnd) { sc.ChangeState(SCE_V_STRINGEOL); sc.ForwardSetState(SCE_V_DEFAULT); } } // Determine if a new state should be entered. if (sc.state == SCE_V_DEFAULT) { if (IsADigit(sc.ch) || (sc.ch == '\'') || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_V_NUMBER); } else if (IsAWordStart(sc.ch)) { sc.SetState(SCE_V_IDENTIFIER); } else if (sc.Match('/', '*')) { sc.SetState(SCE_V_COMMENT); sc.Forward(); // Eat the * so it isn't used for the end of the comment } else if (sc.Match('/', '/')) { if (sc.Match("//!")) // Nice to have a different comment style sc.SetState(SCE_V_COMMENTLINEBANG); else sc.SetState(SCE_V_COMMENTLINE); } else if (sc.ch == '\"') { sc.SetState(SCE_V_STRING); } else if (sc.ch == '`') { sc.SetState(SCE_V_PREPROCESSOR); // Skip whitespace between ` and preprocessor word do { sc.Forward(); } while ((sc.ch == ' ' || sc.ch == '\t') && sc.More()); if (sc.atLineEnd) { sc.SetState(SCE_V_DEFAULT); } } else if (isoperator(static_cast(sc.ch)) || sc.ch == '@' || sc.ch == '#') { sc.SetState(SCE_V_OPERATOR); } } } sc.Complete(); } static bool IsStreamCommentStyle(int style) { return style == SCE_V_COMMENT; } static bool IsCommentLine(int line, Accessor &styler) { int pos = styler.LineStart(line); int eolPos = styler.LineStart(line + 1) - 1; for (int i = pos; i < eolPos; i++) { char ch = styler[i]; char chNext = styler.SafeGetCharAt(i + 1); int style = styler.StyleAt(i); if (ch == '/' && chNext == '/' && (style == SCE_V_COMMENTLINE || style == SCE_V_COMMENTLINEBANG)) { return true; } else if (!IsASpaceOrTab(ch)) { return false; } } return false; } // Store both the current line's fold level and the next lines in the // level store to make it easy to pick up with each increment // and to make it possible to fiddle the current level for "} else {". static void FoldNoBoxVerilogDoc(unsigned int startPos, int length, int initStyle, Accessor &styler) { bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0; // Verilog specific folding options: // fold_at_module - // Generally used methodology in verilog code is // one module per file, so folding at module definition is useless. // fold_at_brace/parenthese - // Folding of long port lists can be convenient. bool foldAtModule = styler.GetPropertyInt("fold.verilog.flags", 0) != 0; bool foldAtBrace = 1; bool foldAtParenthese = 1; unsigned int endPos = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; int levelMinCurrent = levelCurrent; int levelNext = levelCurrent; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (foldComment && IsStreamCommentStyle(style)) { if (!IsStreamCommentStyle(stylePrev)) { levelNext++; } else if (!IsStreamCommentStyle(styleNext) && !atEOL) { // Comments don't end at end of line and the next character may be unstyled. levelNext--; } } if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) { if (!IsCommentLine(lineCurrent - 1, styler) && IsCommentLine(lineCurrent + 1, styler)) levelNext++; else if (IsCommentLine(lineCurrent - 1, styler) && !IsCommentLine(lineCurrent+1, styler)) levelNext--; } if (foldComment && (style == SCE_V_COMMENTLINE)) { if ((ch == '/') && (chNext == '/')) { char chNext2 = styler.SafeGetCharAt(i + 2); if (chNext2 == '{') { levelNext++; } else if (chNext2 == '}') { levelNext--; } } } if (foldPreprocessor && (style == SCE_V_PREPROCESSOR)) { if (ch == '`') { unsigned int j = i + 1; while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) { j++; } if (styler.Match(j, "if")) { levelNext++; } else if (styler.Match(j, "end")) { levelNext--; } } } if (style == SCE_V_OPERATOR) { if (foldAtParenthese) { if (ch == '(') { levelNext++; } else if (ch == ')') { levelNext--; } } } if (style == SCE_V_OPERATOR) { if (foldAtBrace) { if (ch == '{') { levelNext++; } else if (ch == '}') { levelNext--; } } } if (style == SCE_V_WORD && stylePrev != SCE_V_WORD) { unsigned int j = i; if (styler.Match(j, "case") || styler.Match(j, "casex") || styler.Match(j, "casez") || styler.Match(j, "class") || styler.Match(j, "function") || styler.Match(j, "generate") || styler.Match(j, "covergroup") || styler.Match(j, "package") || styler.Match(j, "primitive") || styler.Match(j, "program") || styler.Match(j, "sequence") || styler.Match(j, "specify") || styler.Match(j, "table") || styler.Match(j, "task") || styler.Match(j, "fork") || (styler.Match(j, "module") && foldAtModule) || styler.Match(j, "begin")) { levelNext++; } else if (styler.Match(j, "endcase") || styler.Match(j, "endclass") || styler.Match(j, "endfunction") || styler.Match(j, "endgenerate") || styler.Match(j, "endgroup") || styler.Match(j, "endpackage") || styler.Match(j, "endprimitive") || styler.Match(j, "endprogram") || styler.Match(j, "endsequence") || styler.Match(j, "endspecify") || styler.Match(j, "endtable") || styler.Match(j, "endtask") || styler.Match(j, "join") || styler.Match(j, "join_any") || styler.Match(j, "join_none") || (styler.Match(j, "endmodule") && foldAtModule) || (styler.Match(j, "end") && !IsAWordChar(styler.SafeGetCharAt(j+3)))) { levelNext--; } } if (atEOL) { int levelUse = levelCurrent; if (foldAtElse) { levelUse = levelMinCurrent; } int lev = levelUse | levelNext << 16; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if (levelUse < levelNext) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelCurrent = levelNext; levelMinCurrent = levelCurrent; visibleChars = 0; } if (!isspacechar(ch)) visibleChars++; } } static void FoldVerilogDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { FoldNoBoxVerilogDoc(startPos, length, initStyle, styler); } static const char * const verilogWordLists[] = { "Primary keywords and identifiers", "Secondary keywords and identifiers", "System Tasks", "User defined tasks and identifiers", "Unused", 0, }; LexerModule lmVerilog(SCLEX_VERILOG, ColouriseVerilogDoc, "verilog", FoldVerilogDoc, verilogWordLists); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexAU3.cxx000444001750001750 7313212021352777 24210 0ustar00azawawiazawawi000000000000// Scintilla source code edit control // @file LexAU3.cxx // Lexer for AutoIt3 http://www.hiddensoft.com/autoit3 // by Jos van der Zande, jvdzande@yahoo.com // // Changes: // March 28, 2004 - Added the standard Folding code // April 21, 2004 - Added Preprosessor Table + Syntax Highlighting // Fixed Number highlighting // Changed default isoperator to IsAOperator to have a better match to AutoIt3 // Fixed "#comments_start" -> "#comments-start" // Fixed "#comments_end" -> "#comments-end" // Fixed Sendkeys in Strings when not terminated with } // Added support for Sendkey strings that have second parameter e.g. {UP 5} or {a down} // April 26, 2004 - Fixed # pre-processor statement inside of comment block would invalidly change the color. // Added logic for #include to treat the <> as string // Added underscore to IsAOperator. // May 17, 2004 - Changed the folding logic from indent to keyword folding. // Added Folding logic for blocks of single-commentlines or commentblock. // triggered by: fold.comment=1 // Added Folding logic for preprocessor blocks triggered by fold.preprocessor=1 // Added Special for #region - #endregion syntax highlight and folding. // May 30, 2004 - Fixed issue with continuation lines on If statements. // June 5, 2004 - Added comma to Operators for better readability. // Added fold.compact support set with fold.compact=1 // Changed folding inside of #cs-#ce. Default is no keyword folding inside comment blocks when fold.comment=1 // it will now only happen when fold.comment=2. // Sep 5, 2004 - Added logic to handle colourizing words on the last line. // Typed Characters now show as "default" till they match any table. // Oct 10, 2004 - Added logic to show Comments in "Special" directives. // Nov 1, 2004 - Added better testing for Numbers supporting x and e notation. // Nov 28, 2004 - Added logic to handle continuation lines for syntax highlighting. // Jan 10, 2005 - Added Abbreviations Keyword used for expansion // Mar 24, 2005 - Updated Abbreviations Keywords to fix when followed by Operator. // Apr 18, 2005 - Updated #CE/#Comment-End logic to take a linecomment ";" into account // - Added folding support for With...EndWith // - Added support for a DOT in variable names // - Fixed Underscore in CommentBlock // May 23, 2005 - Fixed the SentKey lexing in case of a missing } // Aug 11, 2005 - Fixed possible bug with s_save length > 100. // Aug 23, 2005 - Added Switch/endswitch support to the folding logic. // Sep 27, 2005 - Fixed the SentKey lexing logic in case of multiple sentkeys. // Mar 12, 2006 - Fixed issue with <> coloring as String in stead of Operator in rare occasions. // Apr 8, 2006 - Added support for AutoIt3 Standard UDF library (SCE_AU3_UDF) // Mar 9, 2007 - Fixed bug with + following a String getting the wrong Color. // Jun 20, 2007 - Fixed Commentblock issue when LF's are used as EOL. // Jul 26, 2007 - Fixed #endregion undetected bug. // // Copyright for Scintilla: 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. // Scintilla source code edit control #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static inline bool IsTypeCharacter(const int ch) { return ch == '$'; } static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } static inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '@' || ch == '#' || ch == '$' || ch == '.'); } static inline bool IsAOperator(char ch) { if (isascii(ch) && isalnum(ch)) return false; if (ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '&' || ch == '^' || ch == '=' || ch == '<' || ch == '>' || ch == '(' || ch == ')' || ch == '[' || ch == ']' || ch == ',' ) return true; return false; } /////////////////////////////////////////////////////////////////////////////// // GetSendKey() filters the portion before and after a/multiple space(s) // and return the first portion to be looked-up in the table // also check if the second portion is valid... (up,down.on.off,toggle or a number) /////////////////////////////////////////////////////////////////////////////// static int GetSendKey(const char *szLine, char *szKey) { int nFlag = 0; int nStartFound = 0; int nKeyPos = 0; int nSpecPos= 0; int nSpecNum= 1; int nPos = 0; char cTemp; char szSpecial[100]; // split the portion of the sendkey in the part before and after the spaces while ( ( (cTemp = szLine[nPos]) != '\0')) { // skip leading Ctrl/Shift/Alt state if (cTemp == '{') { nStartFound = 1; } // if (nStartFound == 1) { if ((cTemp == ' ') && (nFlag == 0) ) // get the stuff till first space { nFlag = 1; // Add } to the end of the first bit for table lookup later. szKey[nKeyPos++] = '}'; } else if (cTemp == ' ') { // skip other spaces } else if (nFlag == 0) { // save first portion into var till space or } is hit szKey[nKeyPos++] = cTemp; } else if ((nFlag == 1) && (cTemp != '}')) { // Save second portion into var... szSpecial[nSpecPos++] = cTemp; // check if Second portion is all numbers for repeat fuction if (isdigit(cTemp) == false) {nSpecNum = 0;} } } nPos++; // skip to next char } // End While // Check if the second portion is either a number or one of these keywords szKey[nKeyPos] = '\0'; szSpecial[nSpecPos] = '\0'; if (strcmp(szSpecial,"down")== 0 || strcmp(szSpecial,"up")== 0 || strcmp(szSpecial,"on")== 0 || strcmp(szSpecial,"off")== 0 || strcmp(szSpecial,"toggle")== 0 || nSpecNum == 1 ) { nFlag = 0; } else { nFlag = 1; } return nFlag; // 1 is bad, 0 is good } // GetSendKey() // // Routine to check the last "none comment" character on a line to see if its a continuation // static bool IsContinuationLine(unsigned int szLine, Accessor &styler) { int nsPos = styler.LineStart(szLine); int nePos = styler.LineStart(szLine+1) - 2; //int stylech = styler.StyleAt(nsPos); while (nsPos < nePos) { //stylech = styler.StyleAt(nePos); int stylech = styler.StyleAt(nsPos); if (!(stylech == SCE_AU3_COMMENT)) { char ch = styler.SafeGetCharAt(nePos); if (!isspacechar(ch)) { if (ch == '_') return true; else return false; } } nePos--; // skip to next char } // End While return false; } // IsContinuationLine() // // syntax highlighting logic static void ColouriseAU3Doc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; WordList &keywords3 = *keywordlists[2]; WordList &keywords4 = *keywordlists[3]; WordList &keywords5 = *keywordlists[4]; WordList &keywords6 = *keywordlists[5]; WordList &keywords7 = *keywordlists[6]; WordList &keywords8 = *keywordlists[7]; // find the first previous line without continuation character at the end int lineCurrent = styler.GetLine(startPos); int s_startPos = startPos; // When not inside a Block comment: find First line without _ if (!(initStyle==SCE_AU3_COMMENTBLOCK)) { while ((lineCurrent > 0 && IsContinuationLine(lineCurrent,styler)) || (lineCurrent > 1 && IsContinuationLine(lineCurrent-1,styler))) { lineCurrent--; startPos = styler.LineStart(lineCurrent); // get start position initStyle = 0; // reset the start style to 0 } } // Set the new length to include it from the start and set the start position length = length + s_startPos - startPos; // correct the total length to process styler.StartAt(startPos); StyleContext sc(startPos, length, initStyle, styler); char si; // string indicator "=1 '=2 char ni; // Numeric indicator error=9 normal=0 normal+dec=1 hex=2 Enot=3 char ci; // comment indicator 0=not linecomment(;) char s_save[100]; si=0; ni=0; ci=0; //$$$ for (; sc.More(); sc.Forward()) { char s[100]; sc.GetCurrentLowered(s, sizeof(s)); // ********************************************** // save the total current word for eof processing if (IsAWordChar(sc.ch) || sc.ch == '}') { strcpy(s_save,s); int tp = static_cast(strlen(s_save)); if (tp < 99) { s_save[tp] = static_cast(tolower(sc.ch)); s_save[tp+1] = '\0'; } } // ********************************************** // switch (sc.state) { case SCE_AU3_COMMENTBLOCK: { //Reset at line end if (sc.atLineEnd) { ci=0; if (strcmp(s, "#ce")== 0 || strcmp(s, "#comments-end")== 0) { if (sc.atLineEnd) sc.SetState(SCE_AU3_DEFAULT); else sc.SetState(SCE_AU3_COMMENTBLOCK); } break; } //skip rest of line when a ; is encountered if (sc.chPrev == ';') { ci=2; sc.SetState(SCE_AU3_COMMENTBLOCK); } // skip rest of the line if (ci==2) break; // check when first character is detected on the line if (ci==0) { if (IsAWordStart(static_cast(sc.ch)) || IsAOperator(static_cast(sc.ch))) { ci=1; sc.SetState(SCE_AU3_COMMENTBLOCK); } break; } if (!(IsAWordChar(sc.ch) || (sc.ch == '-' && strcmp(s, "#comments") == 0))) { if ((strcmp(s, "#ce")== 0 || strcmp(s, "#comments-end")== 0)) sc.SetState(SCE_AU3_COMMENT); // set to comment line for the rest of the line else ci=2; // line doesn't begin with #CE so skip the rest of the line } break; } case SCE_AU3_COMMENT: { if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);} break; } case SCE_AU3_OPERATOR: { // check if its a COMobject if (sc.chPrev == '.' && IsAWordChar(sc.ch)) { sc.SetState(SCE_AU3_COMOBJ); } else { sc.SetState(SCE_AU3_DEFAULT); } break; } case SCE_AU3_SPECIAL: { if (sc.ch == ';') {sc.SetState(SCE_AU3_COMMENT);} if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);} break; } case SCE_AU3_KEYWORD: { if (!(IsAWordChar(sc.ch) || (sc.ch == '-' && (strcmp(s, "#comments") == 0 || strcmp(s, "#include") == 0)))) { if (!IsTypeCharacter(sc.ch)) { if (strcmp(s, "#cs")== 0 || strcmp(s, "#comments-start")== 0 ) { sc.ChangeState(SCE_AU3_COMMENTBLOCK); sc.SetState(SCE_AU3_COMMENTBLOCK); break; } else if (keywords.InList(s)) { sc.ChangeState(SCE_AU3_KEYWORD); sc.SetState(SCE_AU3_DEFAULT); } else if (keywords2.InList(s)) { sc.ChangeState(SCE_AU3_FUNCTION); sc.SetState(SCE_AU3_DEFAULT); } else if (keywords3.InList(s)) { sc.ChangeState(SCE_AU3_MACRO); sc.SetState(SCE_AU3_DEFAULT); } else if (keywords5.InList(s)) { sc.ChangeState(SCE_AU3_PREPROCESSOR); sc.SetState(SCE_AU3_DEFAULT); if (strcmp(s, "#include")== 0) { si = 3; // use to determine string start for #inlude <> } } else if (keywords6.InList(s)) { sc.ChangeState(SCE_AU3_SPECIAL); sc.SetState(SCE_AU3_SPECIAL); } else if ((keywords7.InList(s)) && (!IsAOperator(static_cast(sc.ch)))) { sc.ChangeState(SCE_AU3_EXPAND); sc.SetState(SCE_AU3_DEFAULT); } else if (keywords8.InList(s)) { sc.ChangeState(SCE_AU3_UDF); sc.SetState(SCE_AU3_DEFAULT); } else if (strcmp(s, "_") == 0) { sc.ChangeState(SCE_AU3_OPERATOR); sc.SetState(SCE_AU3_DEFAULT); } else if (!IsAWordChar(sc.ch)) { sc.ChangeState(SCE_AU3_DEFAULT); sc.SetState(SCE_AU3_DEFAULT); } } } if (sc.atLineEnd) { sc.SetState(SCE_AU3_DEFAULT);} break; } case SCE_AU3_NUMBER: { // Numeric indicator error=9 normal=0 normal+dec=1 hex=2 E-not=3 // // test for Hex notation if (strcmp(s, "0") == 0 && (sc.ch == 'x' || sc.ch == 'X') && ni == 0) { ni = 2; break; } // test for E notation if (IsADigit(sc.chPrev) && (sc.ch == 'e' || sc.ch == 'E') && ni <= 1) { ni = 3; break; } // Allow Hex characters inside hex numeric strings if ((ni == 2) && (sc.ch == 'a' || sc.ch == 'b' || sc.ch == 'c' || sc.ch == 'd' || sc.ch == 'e' || sc.ch == 'f' || sc.ch == 'A' || sc.ch == 'B' || sc.ch == 'C' || sc.ch == 'D' || sc.ch == 'E' || sc.ch == 'F' )) { break; } // test for 1 dec point only if (sc.ch == '.') { if (ni==0) { ni=1; } else { ni=9; } break; } // end of numeric string ? if (!(IsADigit(sc.ch))) { if (ni==9) { sc.ChangeState(SCE_AU3_DEFAULT); } sc.SetState(SCE_AU3_DEFAULT); } break; } case SCE_AU3_VARIABLE: { // Check if its a COMObject if (sc.ch == '.' && !IsADigit(sc.chNext)) { sc.SetState(SCE_AU3_OPERATOR); } else if (!IsAWordChar(sc.ch)) { sc.SetState(SCE_AU3_DEFAULT); } break; } case SCE_AU3_COMOBJ: { if (!(IsAWordChar(sc.ch))) { sc.SetState(SCE_AU3_DEFAULT); } break; } case SCE_AU3_STRING: { // check for " to end a double qouted string or // check for ' to end a single qouted string if ((si == 1 && sc.ch == '\"') || (si == 2 && sc.ch == '\'') || (si == 3 && sc.ch == '>')) { sc.ForwardSetState(SCE_AU3_DEFAULT); si=0; break; } if (sc.atLineEnd) { si=0; // at line end and not found a continuation char then reset to default int lineCurrent = styler.GetLine(sc.currentPos); if (!IsContinuationLine(lineCurrent,styler)) { sc.SetState(SCE_AU3_DEFAULT); break; } } // find Sendkeys in a STRING if (sc.ch == '{' || sc.ch == '+' || sc.ch == '!' || sc.ch == '^' || sc.ch == '#' ) { sc.SetState(SCE_AU3_SENT);} break; } case SCE_AU3_SENT: { // Send key string ended if (sc.chPrev == '}' && sc.ch != '}') { // set color to SENDKEY when valid sendkey .. else set back to regular string char sk[100]; // split {111 222} and return {111} and check if 222 is valid. // if return code = 1 then invalid 222 so must be string if (GetSendKey(s,sk)) { sc.ChangeState(SCE_AU3_STRING); } // if single char between {?} then its ok as sendkey for a single character else if (strlen(sk) == 3) { sc.ChangeState(SCE_AU3_SENT); } // if sendkey {111} is in table then ok as sendkey else if (keywords4.InList(sk)) { sc.ChangeState(SCE_AU3_SENT); } else { sc.ChangeState(SCE_AU3_STRING); } sc.SetState(SCE_AU3_STRING); } else { // check if the start is a valid SendKey start int nPos = 0; int nState = 1; char cTemp; while (!(nState == 2) && ((cTemp = s[nPos]) != '\0')) { if (cTemp == '{' && nState == 1) { nState = 2; } if (nState == 1 && !(cTemp == '+' || cTemp == '!' || cTemp == '^' || cTemp == '#' )) { nState = 0; } nPos++; } //Verify characters infront of { ... if not assume regular string if (nState == 1 && (!(sc.ch == '{' || sc.ch == '+' || sc.ch == '!' || sc.ch == '^' || sc.ch == '#' ))) { sc.ChangeState(SCE_AU3_STRING); sc.SetState(SCE_AU3_STRING); } // If invalid character found then assume its a regular string if (nState == 0) { sc.ChangeState(SCE_AU3_STRING); sc.SetState(SCE_AU3_STRING); } } // check if next portion is again a sendkey if (sc.atLineEnd) { sc.ChangeState(SCE_AU3_STRING); sc.SetState(SCE_AU3_DEFAULT); si = 0; // reset string indicator } //* check in next characters following a sentkey are again a sent key // Need this test incase of 2 sentkeys like {F1}{ENTER} but not detect {{} if (sc.state == SCE_AU3_STRING && (sc.ch == '{' || sc.ch == '+' || sc.ch == '!' || sc.ch == '^' || sc.ch == '#' )) { sc.SetState(SCE_AU3_SENT);} // check to see if the string ended... // Sendkey string isn't complete but the string ended.... if ((si == 1 && sc.ch == '\"') || (si == 2 && sc.ch == '\'')) { sc.ChangeState(SCE_AU3_STRING); sc.ForwardSetState(SCE_AU3_DEFAULT); } break; } } //switch (sc.state) // Determine if a new state should be entered: if (sc.state == SCE_AU3_DEFAULT) { if (sc.ch == ';') {sc.SetState(SCE_AU3_COMMENT);} else if (sc.ch == '#') {sc.SetState(SCE_AU3_KEYWORD);} else if (sc.ch == '$') {sc.SetState(SCE_AU3_VARIABLE);} else if (sc.ch == '.' && !IsADigit(sc.chNext)) {sc.SetState(SCE_AU3_OPERATOR);} else if (sc.ch == '@') {sc.SetState(SCE_AU3_KEYWORD);} //else if (sc.ch == '_') {sc.SetState(SCE_AU3_KEYWORD);} else if (sc.ch == '<' && si==3) {sc.SetState(SCE_AU3_STRING);} // string after #include else if (sc.ch == '\"') { sc.SetState(SCE_AU3_STRING); si = 1; } else if (sc.ch == '\'') { sc.SetState(SCE_AU3_STRING); si = 2; } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_AU3_NUMBER); ni = 0; } else if (IsAWordStart(sc.ch)) {sc.SetState(SCE_AU3_KEYWORD);} else if (IsAOperator(static_cast(sc.ch))) {sc.SetState(SCE_AU3_OPERATOR);} else if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);} } } //for (; sc.More(); sc.Forward()) //************************************* // Colourize the last word correctly //************************************* if (sc.state == SCE_AU3_KEYWORD) { if (strcmp(s_save, "#cs")== 0 || strcmp(s_save, "#comments-start")== 0 ) { sc.ChangeState(SCE_AU3_COMMENTBLOCK); sc.SetState(SCE_AU3_COMMENTBLOCK); } else if (keywords.InList(s_save)) { sc.ChangeState(SCE_AU3_KEYWORD); sc.SetState(SCE_AU3_KEYWORD); } else if (keywords2.InList(s_save)) { sc.ChangeState(SCE_AU3_FUNCTION); sc.SetState(SCE_AU3_FUNCTION); } else if (keywords3.InList(s_save)) { sc.ChangeState(SCE_AU3_MACRO); sc.SetState(SCE_AU3_MACRO); } else if (keywords5.InList(s_save)) { sc.ChangeState(SCE_AU3_PREPROCESSOR); sc.SetState(SCE_AU3_PREPROCESSOR); } else if (keywords6.InList(s_save)) { sc.ChangeState(SCE_AU3_SPECIAL); sc.SetState(SCE_AU3_SPECIAL); } else if (keywords7.InList(s_save) && sc.atLineEnd) { sc.ChangeState(SCE_AU3_EXPAND); sc.SetState(SCE_AU3_EXPAND); } else if (keywords8.InList(s_save)) { sc.ChangeState(SCE_AU3_UDF); sc.SetState(SCE_AU3_UDF); } else { sc.ChangeState(SCE_AU3_DEFAULT); sc.SetState(SCE_AU3_DEFAULT); } } if (sc.state == SCE_AU3_SENT) { // Send key string ended if (sc.chPrev == '}' && sc.ch != '}') { // set color to SENDKEY when valid sendkey .. else set back to regular string char sk[100]; // split {111 222} and return {111} and check if 222 is valid. // if return code = 1 then invalid 222 so must be string if (GetSendKey(s_save,sk)) { sc.ChangeState(SCE_AU3_STRING); } // if single char between {?} then its ok as sendkey for a single character else if (strlen(sk) == 3) { sc.ChangeState(SCE_AU3_SENT); } // if sendkey {111} is in table then ok as sendkey else if (keywords4.InList(sk)) { sc.ChangeState(SCE_AU3_SENT); } else { sc.ChangeState(SCE_AU3_STRING); } sc.SetState(SCE_AU3_STRING); } // check if next portion is again a sendkey if (sc.atLineEnd) { sc.ChangeState(SCE_AU3_STRING); sc.SetState(SCE_AU3_DEFAULT); } } //************************************* sc.Complete(); } // static bool IsStreamCommentStyle(int style) { return style == SCE_AU3_COMMENT || style == SCE_AU3_COMMENTBLOCK; } // // Routine to find first none space on the current line and return its Style // needed for comment lines not starting on pos 1 static int GetStyleFirstWord(unsigned int szLine, Accessor &styler) { int nsPos = styler.LineStart(szLine); int nePos = styler.LineStart(szLine+1) - 1; while (isspacechar(styler.SafeGetCharAt(nsPos)) && nsPos < nePos) { nsPos++; // skip to next char } // End While return styler.StyleAt(nsPos); } // GetStyleFirstWord() // static void FoldAU3Doc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { int endPos = startPos + length; // get settings from the config files for folding comments and preprocessor lines bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldInComment = styler.GetPropertyInt("fold.comment") == 2; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; bool foldpreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0; // Backtrack to previous line in case need to fix its fold status int lineCurrent = styler.GetLine(startPos); if (startPos > 0) { if (lineCurrent > 0) { lineCurrent--; startPos = styler.LineStart(lineCurrent); } } // vars for style of previous/current/next lines int style = GetStyleFirstWord(lineCurrent,styler); int stylePrev = 0; // find the first previous line without continuation character at the end while ((lineCurrent > 0 && IsContinuationLine(lineCurrent,styler)) || (lineCurrent > 1 && IsContinuationLine(lineCurrent-1,styler))) { lineCurrent--; startPos = styler.LineStart(lineCurrent); } if (lineCurrent > 0) { stylePrev = GetStyleFirstWord(lineCurrent-1,styler); } // vars for getting first word to check for keywords bool FirstWordStart = false; bool FirstWordEnd = false; char szKeyword[11]=""; int szKeywordlen = 0; char szThen[5]=""; int szThenlen = 0; bool ThenFoundLast = false; // var for indentlevel int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; int levelNext = levelCurrent; // int visibleChars = 0; char chNext = styler.SafeGetCharAt(startPos); char chPrev = ' '; // for (int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); if (IsAWordChar(ch)) { visibleChars++; } // get the syle for the current character neede to check in comment int stylech = styler.StyleAt(i); // get first word for the line for indent check max 9 characters if (FirstWordStart && (!(FirstWordEnd))) { if (!IsAWordChar(ch)) { FirstWordEnd = true; szKeyword[szKeywordlen] = '\0'; } else { if (szKeywordlen < 10) { szKeyword[szKeywordlen++] = static_cast(tolower(ch)); } } } // start the capture of the first word if (!(FirstWordStart)) { if (IsAWordChar(ch) || IsAWordStart(ch) || ch == ';') { FirstWordStart = true; szKeyword[szKeywordlen++] = static_cast(tolower(ch)); } } // only process this logic when not in comment section if (!(stylech == SCE_AU3_COMMENT)) { if (ThenFoundLast) { if (IsAWordChar(ch)) { ThenFoundLast = false; } } // find out if the word "then" is the last on a "if" line if (FirstWordEnd && strcmp(szKeyword,"if") == 0) { if (szThenlen == 4) { szThen[0] = szThen[1]; szThen[1] = szThen[2]; szThen[2] = szThen[3]; szThen[3] = static_cast(tolower(ch)); if (strcmp(szThen,"then") == 0 ) { ThenFoundLast = true; } } else { szThen[szThenlen++] = static_cast(tolower(ch)); if (szThenlen == 5) { szThen[4] = '\0'; } } } } // End of Line found so process the information if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == endPos)) { // ************************** // Folding logic for Keywords // ************************** // if a keyword is found on the current line and the line doesn't end with _ (continuation) // and we are not inside a commentblock. if (szKeywordlen > 0 && (!(chPrev == '_')) && ((!(IsStreamCommentStyle(style)) || foldInComment)) ) { szKeyword[szKeywordlen] = '\0'; // only fold "if" last keyword is "then" (else its a one line if) if (strcmp(szKeyword,"if") == 0 && ThenFoundLast) { levelNext++; } // create new fold for these words if (strcmp(szKeyword,"do") == 0 || strcmp(szKeyword,"for") == 0 || strcmp(szKeyword,"func") == 0 || strcmp(szKeyword,"while") == 0|| strcmp(szKeyword,"with") == 0 || strcmp(szKeyword,"#region") == 0 ) { levelNext++; } // create double Fold for select&switch because Case will subtract one of the current level if (strcmp(szKeyword,"select") == 0 || strcmp(szKeyword,"switch") == 0) { levelNext++; levelNext++; } // end the fold for these words before the current line if (strcmp(szKeyword,"endfunc") == 0 || strcmp(szKeyword,"endif") == 0 || strcmp(szKeyword,"next") == 0 || strcmp(szKeyword,"until") == 0 || strcmp(szKeyword,"endwith") == 0 ||strcmp(szKeyword,"wend") == 0){ levelNext--; levelCurrent--; } // end the fold for these words before the current line and Start new fold if (strcmp(szKeyword,"case") == 0 || strcmp(szKeyword,"else") == 0 || strcmp(szKeyword,"elseif") == 0 ) { levelCurrent--; } // end the double fold for this word before the current line if (strcmp(szKeyword,"endselect") == 0 || strcmp(szKeyword,"endswitch") == 0 ) { levelNext--; levelNext--; levelCurrent--; levelCurrent--; } // end the fold for these words on the current line if (strcmp(szKeyword,"#endregion") == 0 ) { levelNext--; } } // Preprocessor and Comment folding int styleNext = GetStyleFirstWord(lineCurrent + 1,styler); // ************************************* // Folding logic for preprocessor blocks // ************************************* // process preprosessor line if (foldpreprocessor && style == SCE_AU3_PREPROCESSOR) { if (!(stylePrev == SCE_AU3_PREPROCESSOR) && (styleNext == SCE_AU3_PREPROCESSOR)) { levelNext++; } // fold till the last line for normal comment lines else if (stylePrev == SCE_AU3_PREPROCESSOR && !(styleNext == SCE_AU3_PREPROCESSOR)) { levelNext--; } } // ********************************* // Folding logic for Comment blocks // ********************************* if (foldComment && IsStreamCommentStyle(style)) { // Start of a comment block if (!(stylePrev==style) && IsStreamCommentStyle(styleNext) && styleNext==style) { levelNext++; } // fold till the last line for normal comment lines else if (IsStreamCommentStyle(stylePrev) && !(styleNext == SCE_AU3_COMMENT) && stylePrev == SCE_AU3_COMMENT && style == SCE_AU3_COMMENT) { levelNext--; } // fold till the one but last line for Blockcomment lines else if (IsStreamCommentStyle(stylePrev) && !(styleNext == SCE_AU3_COMMENTBLOCK) && style == SCE_AU3_COMMENTBLOCK) { levelNext--; levelCurrent--; } } int levelUse = levelCurrent; int lev = levelUse | levelNext << 16; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if (levelUse < levelNext) { lev |= SC_FOLDLEVELHEADERFLAG; } if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } // reset values for the next line lineCurrent++; stylePrev = style; style = styleNext; levelCurrent = levelNext; visibleChars = 0; // if the last character is an Underscore then don't reset since the line continues on the next line. if (!(chPrev == '_')) { szKeywordlen = 0; szThenlen = 0; FirstWordStart = false; FirstWordEnd = false; ThenFoundLast = false; } } // save the last processed character if (!isspacechar(ch)) { chPrev = ch; visibleChars++; } } } // static const char * const AU3WordLists[] = { "#autoit keywords", "#autoit functions", "#autoit macros", "#autoit Sent keys", "#autoit Pre-processors", "#autoit Special", "#autoit Expand", "#autoit UDF", 0 }; LexerModule lmAU3(SCLEX_AU3, ColouriseAU3Doc, "au3", FoldAU3Doc , AU3WordLists); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexPascal.cxx000444001750001750 5160412021352777 25023 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexPascal.cxx ** Lexer for Pascal. ** Written by Laurent le Tynevez ** Updated by Simon Steele September 2002 ** Updated by Mathias Rauen May 2003 (Delphi adjustments) ** Completely rewritten by Marko Njezic October 2008 **/ /* A few words about features of the new completely rewritten LexPascal... Generally speaking LexPascal tries to support all available Delphi features (up to Delphi 2009 at this time), including .NET specific features. ~ HIGHLIGHTING: If you enable "lexer.pascal.smart.highlighting" property, some keywords will only be highlighted in appropriate context. As implemented those are keywords related to property and DLL exports declarations (similar to how Delphi IDE works). For example, keywords "read" and "write" will only be highlighted if they are in property declaration: property MyProperty: boolean read FMyProperty write FMyProperty; ~ FOLDING: Folding is supported in the following cases: - Folding of stream-like comments - Folding of groups of consecutive line comments - Folding of preprocessor blocks (the following preprocessor blocks are supported: IF / IFEND; IFDEF, IFNDEF, IFOPT / ENDIF and REGION / ENDREGION blocks), including nesting of preprocessor blocks up to 255 levels - Folding of code blocks on appropriate keywords (the following code blocks are supported: "begin, asm, record, try, case / end" blocks, class & object declarations and interface declarations) Remarks: - Folding of code blocks tries to handle all special cases in which folding should not occur. As implemented those are: 1. Structure "record case / end" (there's only one "end" statement and "case" is ignored as fold point) 2. Forward class declarations ("type TMyClass = class;") and object method declarations ("TNotifyEvent = procedure(Sender: TObject) of object;") are ignored as fold points 3. Simplified complete class declarations ("type TMyClass = class(TObject);") are ignored as fold points 4. Every other situation when class keyword doesn't actually start class declaration ("class procedure", "class function", "class of", "class var", "class property" and "class operator") 5. Forward (disp)interface declarations ("type IMyInterface = interface;") are ignored as fold points - Folding of code blocks inside preprocessor blocks is disabled (any comments inside them will be folded fine) because there is no guarantee that complete code block will be contained inside folded preprocessor block in which case folded code block could end prematurely at the end of preprocessor block if there is no closing statement inside. This was done in order to properly process document that may contain something like this: type {$IFDEF UNICODE} TMyClass = class(UnicodeAncestor) {$ELSE} TMyClass = class(AnsiAncestor) {$ENDIF} private ... public ... published ... end; If class declarations were folded, then the second class declaration would end at "$ENDIF" statement, first class statement would end at "end;" statement and preprocessor "$IFDEF" block would go all the way to the end of document. However, having in mind all this, if you want to enable folding of code blocks inside preprocessor blocks, you can disable folding of preprocessor blocks by changing "fold.preprocessor" property, in which case everything inside them would be folded. ~ KEYWORDS: The list of keywords that can be used in pascal.properties file (up to Delphi 2009): - Keywords: absolute abstract and array as asm assembler automated begin case cdecl class const constructor deprecated destructor dispid dispinterface div do downto dynamic else end except export exports external far file final finalization finally for forward function goto if implementation in inherited initialization inline interface is label library message mod near nil not object of on or out overload override packed pascal platform private procedure program property protected public published raise record register reintroduce repeat resourcestring safecall sealed set shl shr static stdcall strict string then threadvar to try type unit unsafe until uses var varargs virtual while with xor - Keywords related to the "smart highlithing" feature: add default implements index name nodefault read readonly remove stored write writeonly - Keywords related to Delphi packages (in addition to all above): package contains requires */ #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static void GetRangeLowered(unsigned int start, unsigned int end, Accessor &styler, char *s, unsigned int len) { unsigned int i = 0; while ((i < end - start + 1) && (i < len-1)) { s[i] = static_cast(tolower(styler[start + i])); i++; } s[i] = '\0'; } static void GetForwardRangeLowered(unsigned int start, CharacterSet &charSet, Accessor &styler, char *s, unsigned int len) { unsigned int i = 0; while ((i < len-1) && charSet.Contains(styler.SafeGetCharAt(start + i))) { s[i] = static_cast(tolower(styler.SafeGetCharAt(start + i))); i++; } s[i] = '\0'; } enum { stateInAsm = 0x1000, stateInProperty = 0x2000, stateInExport = 0x4000, stateFoldInPreprocessor = 0x0100, stateFoldInRecord = 0x0200, stateFoldInPreprocessorLevelMask = 0x00FF, stateFoldMaskAll = 0x0FFF }; static void ClassifyPascalWord(WordList *keywordlists[], StyleContext &sc, int &curLineState, bool bSmartHighlighting) { WordList& keywords = *keywordlists[0]; char s[100]; sc.GetCurrentLowered(s, sizeof(s)); if (keywords.InList(s)) { if (curLineState & stateInAsm) { if (strcmp(s, "end") == 0 && sc.GetRelative(-4) != '@') { curLineState &= ~stateInAsm; sc.ChangeState(SCE_PAS_WORD); } else { sc.ChangeState(SCE_PAS_ASM); } } else { bool ignoreKeyword = false; if (strcmp(s, "asm") == 0) { curLineState |= stateInAsm; } else if (bSmartHighlighting) { if (strcmp(s, "property") == 0) { curLineState |= stateInProperty; } else if (strcmp(s, "exports") == 0) { curLineState |= stateInExport; } else if (!(curLineState & (stateInProperty | stateInExport)) && strcmp(s, "index") == 0) { ignoreKeyword = true; } else if (!(curLineState & stateInExport) && strcmp(s, "name") == 0) { ignoreKeyword = true; } else if (!(curLineState & stateInProperty) && (strcmp(s, "read") == 0 || strcmp(s, "write") == 0 || strcmp(s, "default") == 0 || strcmp(s, "nodefault") == 0 || strcmp(s, "stored") == 0 || strcmp(s, "implements") == 0 || strcmp(s, "readonly") == 0 || strcmp(s, "writeonly") == 0 || strcmp(s, "add") == 0 || strcmp(s, "remove") == 0)) { ignoreKeyword = true; } } if (!ignoreKeyword) { sc.ChangeState(SCE_PAS_WORD); } } } else if (curLineState & stateInAsm) { sc.ChangeState(SCE_PAS_ASM); } sc.SetState(SCE_PAS_DEFAULT); } static void ColourisePascalDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { bool bSmartHighlighting = styler.GetPropertyInt("lexer.pascal.smart.highlighting", 1) != 0; CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true); CharacterSet setWord(CharacterSet::setAlphaNum, "_", 0x80, true); CharacterSet setNumber(CharacterSet::setDigits, ".-+eE"); CharacterSet setHexNumber(CharacterSet::setDigits, "abcdefABCDEF"); CharacterSet setOperator(CharacterSet::setNone, "#$&'()*+,-./:;<=>@[]^{}"); int curLine = styler.GetLine(startPos); int curLineState = curLine > 0 ? styler.GetLineState(curLine - 1) : 0; StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { if (sc.atLineEnd) { // Update the line state, so it can be seen by next line curLine = styler.GetLine(sc.currentPos); styler.SetLineState(curLine, curLineState); } // Determine if the current state should terminate. switch (sc.state) { case SCE_PAS_NUMBER: if (!setNumber.Contains(sc.ch) || (sc.ch == '.' && sc.chNext == '.')) { sc.SetState(SCE_PAS_DEFAULT); } else if (sc.ch == '-' || sc.ch == '+') { if (sc.chPrev != 'E' && sc.chPrev != 'e') { sc.SetState(SCE_PAS_DEFAULT); } } break; case SCE_PAS_IDENTIFIER: if (!setWord.Contains(sc.ch)) { ClassifyPascalWord(keywordlists, sc, curLineState, bSmartHighlighting); } break; case SCE_PAS_HEXNUMBER: if (!setHexNumber.Contains(sc.ch)) { sc.SetState(SCE_PAS_DEFAULT); } break; case SCE_PAS_COMMENT: case SCE_PAS_PREPROCESSOR: if (sc.ch == '}') { sc.ForwardSetState(SCE_PAS_DEFAULT); } break; case SCE_PAS_COMMENT2: case SCE_PAS_PREPROCESSOR2: if (sc.Match('*', ')')) { sc.Forward(); sc.ForwardSetState(SCE_PAS_DEFAULT); } break; case SCE_PAS_COMMENTLINE: if (sc.atLineStart) { sc.SetState(SCE_PAS_DEFAULT); } break; case SCE_PAS_STRING: if (sc.atLineEnd) { sc.ChangeState(SCE_PAS_STRINGEOL); } else if (sc.ch == '\'' && sc.chNext == '\'') { sc.Forward(); } else if (sc.ch == '\'') { sc.ForwardSetState(SCE_PAS_DEFAULT); } break; case SCE_PAS_STRINGEOL: if (sc.atLineStart) { sc.SetState(SCE_PAS_DEFAULT); } break; case SCE_PAS_CHARACTER: if (!setHexNumber.Contains(sc.ch) && sc.ch != '$') { sc.SetState(SCE_PAS_DEFAULT); } break; case SCE_PAS_OPERATOR: if (bSmartHighlighting && sc.chPrev == ';') { curLineState &= ~(stateInProperty | stateInExport); } sc.SetState(SCE_PAS_DEFAULT); break; case SCE_PAS_ASM: sc.SetState(SCE_PAS_DEFAULT); break; } // Determine if a new state should be entered. if (sc.state == SCE_PAS_DEFAULT) { if (IsADigit(sc.ch) && !(curLineState & stateInAsm)) { sc.SetState(SCE_PAS_NUMBER); } else if (setWordStart.Contains(sc.ch)) { sc.SetState(SCE_PAS_IDENTIFIER); } else if (sc.ch == '$' && !(curLineState & stateInAsm)) { sc.SetState(SCE_PAS_HEXNUMBER); } else if (sc.Match('{', '$')) { sc.SetState(SCE_PAS_PREPROCESSOR); } else if (sc.ch == '{') { sc.SetState(SCE_PAS_COMMENT); } else if (sc.Match("(*$")) { sc.SetState(SCE_PAS_PREPROCESSOR2); } else if (sc.Match('(', '*')) { sc.SetState(SCE_PAS_COMMENT2); sc.Forward(); // Eat the * so it isn't used for the end of the comment } else if (sc.Match('/', '/')) { sc.SetState(SCE_PAS_COMMENTLINE); } else if (sc.ch == '\'') { sc.SetState(SCE_PAS_STRING); } else if (sc.ch == '#') { sc.SetState(SCE_PAS_CHARACTER); } else if (setOperator.Contains(sc.ch) && !(curLineState & stateInAsm)) { sc.SetState(SCE_PAS_OPERATOR); } else if (curLineState & stateInAsm) { sc.SetState(SCE_PAS_ASM); } } } if (sc.state == SCE_PAS_IDENTIFIER && setWord.Contains(sc.chPrev)) { ClassifyPascalWord(keywordlists, sc, curLineState, bSmartHighlighting); } sc.Complete(); } static bool IsStreamCommentStyle(int style) { return style == SCE_PAS_COMMENT || style == SCE_PAS_COMMENT2; } static bool IsCommentLine(int line, Accessor &styler) { int pos = styler.LineStart(line); int eolPos = styler.LineStart(line + 1) - 1; for (int i = pos; i < eolPos; i++) { char ch = styler[i]; char chNext = styler.SafeGetCharAt(i + 1); int style = styler.StyleAt(i); if (ch == '/' && chNext == '/' && style == SCE_PAS_COMMENTLINE) { return true; } else if (!IsASpaceOrTab(ch)) { return false; } } return false; } static unsigned int GetFoldInPreprocessorLevelFlag(int lineFoldStateCurrent) { return lineFoldStateCurrent & stateFoldInPreprocessorLevelMask; } static void SetFoldInPreprocessorLevelFlag(int &lineFoldStateCurrent, unsigned int nestLevel) { lineFoldStateCurrent &= ~stateFoldInPreprocessorLevelMask; lineFoldStateCurrent |= nestLevel & stateFoldInPreprocessorLevelMask; } static void ClassifyPascalPreprocessorFoldPoint(int &levelCurrent, int &lineFoldStateCurrent, unsigned int startPos, Accessor &styler) { CharacterSet setWord(CharacterSet::setAlpha); char s[11]; // Size of the longest possible keyword + one additional character + null GetForwardRangeLowered(startPos, setWord, styler, s, sizeof(s)); unsigned int nestLevel = GetFoldInPreprocessorLevelFlag(lineFoldStateCurrent); if (strcmp(s, "if") == 0 || strcmp(s, "ifdef") == 0 || strcmp(s, "ifndef") == 0 || strcmp(s, "ifopt") == 0 || strcmp(s, "region") == 0) { nestLevel++; SetFoldInPreprocessorLevelFlag(lineFoldStateCurrent, nestLevel); lineFoldStateCurrent |= stateFoldInPreprocessor; levelCurrent++; } else if (strcmp(s, "endif") == 0 || strcmp(s, "ifend") == 0 || strcmp(s, "endregion") == 0) { nestLevel--; SetFoldInPreprocessorLevelFlag(lineFoldStateCurrent, nestLevel); if (nestLevel == 0) { lineFoldStateCurrent &= ~stateFoldInPreprocessor; } levelCurrent--; if (levelCurrent < SC_FOLDLEVELBASE) { levelCurrent = SC_FOLDLEVELBASE; } } } static unsigned int SkipWhiteSpace(unsigned int currentPos, unsigned int endPos, Accessor &styler, bool includeChars = false) { CharacterSet setWord(CharacterSet::setAlphaNum, "_"); unsigned int j = currentPos + 1; char ch = styler.SafeGetCharAt(j); while ((j < endPos) && (IsASpaceOrTab(ch) || ch == '\r' || ch == '\n' || IsStreamCommentStyle(styler.StyleAt(j)) || (includeChars && setWord.Contains(ch)))) { j++; ch = styler.SafeGetCharAt(j); } return j; } static void ClassifyPascalWordFoldPoint(int &levelCurrent, int &lineFoldStateCurrent, int startPos, unsigned int endPos, unsigned int lastStart, unsigned int currentPos, Accessor &styler) { char s[100]; GetRangeLowered(lastStart, currentPos, styler, s, sizeof(s)); if (strcmp(s, "record") == 0) { lineFoldStateCurrent |= stateFoldInRecord; levelCurrent++; } else if (strcmp(s, "begin") == 0 || strcmp(s, "asm") == 0 || strcmp(s, "try") == 0 || (strcmp(s, "case") == 0 && !(lineFoldStateCurrent & stateFoldInRecord))) { levelCurrent++; } else if (strcmp(s, "class") == 0 || strcmp(s, "object") == 0) { // "class" & "object" keywords require special handling... bool ignoreKeyword = false; unsigned int j = SkipWhiteSpace(currentPos, endPos, styler); if (j < endPos) { CharacterSet setWordStart(CharacterSet::setAlpha, "_"); CharacterSet setWord(CharacterSet::setAlphaNum, "_"); if (styler.SafeGetCharAt(j) == ';') { // Handle forward class declarations ("type TMyClass = class;") // and object method declarations ("TNotifyEvent = procedure(Sender: TObject) of object;") ignoreKeyword = true; } else if (strcmp(s, "class") == 0) { // "class" keyword has a few more special cases... if (styler.SafeGetCharAt(j) == '(') { // Handle simplified complete class declarations ("type TMyClass = class(TObject);") j = SkipWhiteSpace(j, endPos, styler, true); if (j < endPos && styler.SafeGetCharAt(j) == ')') { j = SkipWhiteSpace(j, endPos, styler); if (j < endPos && styler.SafeGetCharAt(j) == ';') { ignoreKeyword = true; } } } else if (setWordStart.Contains(styler.SafeGetCharAt(j))) { char s2[11]; // Size of the longest possible keyword + one additional character + null GetForwardRangeLowered(j, setWord, styler, s2, sizeof(s2)); if (strcmp(s2, "procedure") == 0 || strcmp(s2, "function") == 0 || strcmp(s2, "of") == 0 || strcmp(s2, "var") == 0 || strcmp(s2, "property") == 0 || strcmp(s2, "operator") == 0) { ignoreKeyword = true; } } } } if (!ignoreKeyword) { levelCurrent++; } } else if (strcmp(s, "interface") == 0) { // "interface" keyword requires special handling... bool ignoreKeyword = true; int j = lastStart - 1; char ch = styler.SafeGetCharAt(j); while ((j >= startPos) && (IsASpaceOrTab(ch) || ch == '\r' || ch == '\n' || IsStreamCommentStyle(styler.StyleAt(j)))) { j--; ch = styler.SafeGetCharAt(j); } if (j >= startPos && styler.SafeGetCharAt(j) == '=') { ignoreKeyword = false; } if (!ignoreKeyword) { unsigned int k = SkipWhiteSpace(currentPos, endPos, styler); if (k < endPos && styler.SafeGetCharAt(k) == ';') { // Handle forward interface declarations ("type IMyInterface = interface;") ignoreKeyword = true; } } if (!ignoreKeyword) { levelCurrent++; } } else if (strcmp(s, "dispinterface") == 0) { // "dispinterface" keyword requires special handling... bool ignoreKeyword = false; unsigned int j = SkipWhiteSpace(currentPos, endPos, styler); if (j < endPos && styler.SafeGetCharAt(j) == ';') { // Handle forward dispinterface declarations ("type IMyInterface = dispinterface;") ignoreKeyword = true; } if (!ignoreKeyword) { levelCurrent++; } } else if (strcmp(s, "end") == 0) { lineFoldStateCurrent &= ~stateFoldInRecord; levelCurrent--; if (levelCurrent < SC_FOLDLEVELBASE) { levelCurrent = SC_FOLDLEVELBASE; } } } static void FoldPascalDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; unsigned int endPos = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; int lineFoldStateCurrent = lineCurrent > 0 ? styler.GetLineState(lineCurrent - 1) & stateFoldMaskAll : 0; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; int lastStart = 0; CharacterSet setWord(CharacterSet::setAlphaNum, "_", 0x80, true); for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (foldComment && IsStreamCommentStyle(style)) { if (!IsStreamCommentStyle(stylePrev)) { levelCurrent++; } else if (!IsStreamCommentStyle(styleNext) && !atEOL) { // Comments don't end at end of line and the next character may be unstyled. levelCurrent--; } } if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) { if (!IsCommentLine(lineCurrent - 1, styler) && IsCommentLine(lineCurrent + 1, styler)) levelCurrent++; else if (IsCommentLine(lineCurrent - 1, styler) && !IsCommentLine(lineCurrent+1, styler)) levelCurrent--; } if (foldPreprocessor) { if (style == SCE_PAS_PREPROCESSOR && ch == '{' && chNext == '$') { ClassifyPascalPreprocessorFoldPoint(levelCurrent, lineFoldStateCurrent, i + 2, styler); } else if (style == SCE_PAS_PREPROCESSOR2 && ch == '(' && chNext == '*' && styler.SafeGetCharAt(i + 2) == '$') { ClassifyPascalPreprocessorFoldPoint(levelCurrent, lineFoldStateCurrent, i + 3, styler); } } if (stylePrev != SCE_PAS_WORD && style == SCE_PAS_WORD) { // Store last word start point. lastStart = i; } if (stylePrev == SCE_PAS_WORD && !(lineFoldStateCurrent & stateFoldInPreprocessor)) { if(setWord.Contains(ch) && !setWord.Contains(chNext)) { ClassifyPascalWordFoldPoint(levelCurrent, lineFoldStateCurrent, startPos, endPos, lastStart, i, styler); } } if (!IsASpace(ch)) visibleChars++; if (atEOL) { int lev = levelPrev; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if ((levelCurrent > levelPrev) && (visibleChars > 0)) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } int newLineState = (styler.GetLineState(lineCurrent) & ~stateFoldMaskAll) | lineFoldStateCurrent; styler.SetLineState(lineCurrent, newLineState); lineCurrent++; levelPrev = levelCurrent; visibleChars = 0; } } // If we didn't reach the EOL in previous loop, store line level and whitespace information. // The rest will be filled in later... int lev = levelPrev; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; styler.SetLevel(lineCurrent, lev); } static const char * const pascalWordListDesc[] = { "Keywords", 0 }; LexerModule lmPascal(SCLEX_PASCAL, ColourisePascalDoc, "pascal", FoldPascalDoc, pascalWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexSpecman.cxx000444001750001750 2214512021352777 25204 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexSpecman.cxx ** Lexer for Specman E language. ** Written by Avi Yegudin, based on C++ lexer by Neil Hodgson **/ // Copyright 1998-2002 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '\''); } static inline bool IsANumberChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '\''); } static inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '`'); } static void ColouriseSpecmanDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler, bool caseSensitive) { WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; WordList &keywords3 = *keywordlists[2]; WordList &keywords4 = *keywordlists[3]; // Do not leak onto next line if (initStyle == SCE_SN_STRINGEOL) initStyle = SCE_SN_CODE; int visibleChars = 0; StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { if (sc.atLineStart && (sc.state == SCE_SN_STRING)) { // Prevent SCE_SN_STRINGEOL from leaking back to previous line sc.SetState(SCE_SN_STRING); } // Handle line continuation generically. if (sc.ch == '\\') { if (sc.chNext == '\n' || sc.chNext == '\r') { sc.Forward(); if (sc.ch == '\r' && sc.chNext == '\n') { sc.Forward(); } continue; } } // Determine if the current state should terminate. if (sc.state == SCE_SN_OPERATOR) { sc.SetState(SCE_SN_CODE); } else if (sc.state == SCE_SN_NUMBER) { if (!IsANumberChar(sc.ch)) { sc.SetState(SCE_SN_CODE); } } else if (sc.state == SCE_SN_IDENTIFIER) { if (!IsAWordChar(sc.ch) || (sc.ch == '.')) { char s[100]; if (caseSensitive) { sc.GetCurrent(s, sizeof(s)); } else { sc.GetCurrentLowered(s, sizeof(s)); } if (keywords.InList(s)) { sc.ChangeState(SCE_SN_WORD); } else if (keywords2.InList(s)) { sc.ChangeState(SCE_SN_WORD2); } else if (keywords3.InList(s)) { sc.ChangeState(SCE_SN_WORD3); } else if (keywords4.InList(s)) { sc.ChangeState(SCE_SN_USER); } sc.SetState(SCE_SN_CODE); } } else if (sc.state == SCE_SN_PREPROCESSOR) { if (IsASpace(sc.ch)) { sc.SetState(SCE_SN_CODE); } } else if (sc.state == SCE_SN_DEFAULT) { if (sc.Match('<', '\'')) { sc.Forward(); sc.ForwardSetState(SCE_SN_CODE); } } else if (sc.state == SCE_SN_COMMENTLINE || sc.state == SCE_SN_COMMENTLINEBANG) { if (sc.atLineEnd) { sc.SetState(SCE_SN_CODE); visibleChars = 0; } } else if (sc.state == SCE_SN_STRING) { if (sc.ch == '\\') { if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { sc.Forward(); } } else if (sc.ch == '\"') { sc.ForwardSetState(SCE_SN_CODE); } else if (sc.atLineEnd) { sc.ChangeState(SCE_SN_STRINGEOL); sc.ForwardSetState(SCE_SN_CODE); visibleChars = 0; } } else if (sc.state == SCE_SN_SIGNAL) { if (sc.atLineEnd) { sc.ChangeState(SCE_SN_STRINGEOL); sc.ForwardSetState(SCE_SN_CODE); visibleChars = 0; } else if (sc.ch == '\\') { if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { sc.Forward(); } } else if (sc.ch == '\'') { sc.ForwardSetState(SCE_SN_CODE); } } else if (sc.state == SCE_SN_REGEXTAG) { if (!IsADigit(sc.ch)) { sc.SetState(SCE_SN_CODE); } } // Determine if a new state should be entered. if (sc.state == SCE_SN_CODE) { if (sc.ch == '$' && IsADigit(sc.chNext)) { sc.SetState(SCE_SN_REGEXTAG); sc.Forward(); } else if (IsADigit(sc.ch)) { sc.SetState(SCE_SN_NUMBER); } else if (IsAWordStart(sc.ch)) { sc.SetState(SCE_SN_IDENTIFIER); } else if (sc.Match('\'', '>')) { sc.SetState(SCE_SN_DEFAULT); sc.Forward(); // Eat the * so it isn't used for the end of the comment } else if (sc.Match('/', '/')) { if (sc.Match("//!")) // Nice to have a different comment style sc.SetState(SCE_SN_COMMENTLINEBANG); else sc.SetState(SCE_SN_COMMENTLINE); } else if (sc.Match('-', '-')) { if (sc.Match("--!")) // Nice to have a different comment style sc.SetState(SCE_SN_COMMENTLINEBANG); else sc.SetState(SCE_SN_COMMENTLINE); } else if (sc.ch == '\"') { sc.SetState(SCE_SN_STRING); } else if (sc.ch == '\'') { sc.SetState(SCE_SN_SIGNAL); } else if (sc.ch == '#' && visibleChars == 0) { // Preprocessor commands are alone on their line sc.SetState(SCE_SN_PREPROCESSOR); // Skip whitespace between # and preprocessor word do { sc.Forward(); } while ((sc.ch == ' ' || sc.ch == '\t') && sc.More()); if (sc.atLineEnd) { sc.SetState(SCE_SN_CODE); } } else if (isoperator(static_cast(sc.ch)) || sc.ch == '@') { sc.SetState(SCE_SN_OPERATOR); } } if (sc.atLineEnd) { // Reset states to begining of colourise so no surprises // if different sets of lines lexed. visibleChars = 0; } if (!IsASpace(sc.ch)) { visibleChars++; } } sc.Complete(); } // Store both the current line's fold level and the next lines in the // level store to make it easy to pick up with each increment // and to make it possible to fiddle the current level for "} else {". static void FoldNoBoxSpecmanDoc(unsigned int startPos, int length, int, Accessor &styler) { bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0; unsigned int endPos = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; int levelMinCurrent = levelCurrent; int levelNext = levelCurrent; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style; for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); //int stylePrev = style; style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (foldComment && (style == SCE_SN_COMMENTLINE)) { if (((ch == '/') && (chNext == '/')) || ((ch == '-') && (chNext == '-'))) { char chNext2 = styler.SafeGetCharAt(i + 2); if (chNext2 == '{') { levelNext++; } else if (chNext2 == '}') { levelNext--; } } } if (style == SCE_SN_OPERATOR) { if (ch == '{') { // Measure the minimum before a '{' to allow // folding on "} else {" if (levelMinCurrent > levelNext) { levelMinCurrent = levelNext; } levelNext++; } else if (ch == '}') { levelNext--; } } if (atEOL) { int levelUse = levelCurrent; if (foldAtElse) { levelUse = levelMinCurrent; } int lev = levelUse | levelNext << 16; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if (levelUse < levelNext) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelCurrent = levelNext; levelMinCurrent = levelCurrent; visibleChars = 0; } if (!isspacechar(ch)) visibleChars++; } } static void FoldSpecmanDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { FoldNoBoxSpecmanDoc(startPos, length, initStyle, styler); } static const char * const specmanWordLists[] = { "Primary keywords and identifiers", "Secondary keywords and identifiers", "Sequence keywords and identifiers", "User defined keywords and identifiers", "Unused", 0, }; static void ColouriseSpecmanDocSensitive(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { ColouriseSpecmanDoc(startPos, length, initStyle, keywordlists, styler, true); } LexerModule lmSpecman(SCLEX_SPECMAN, ColouriseSpecmanDocSensitive, "specman", FoldSpecmanDoc, specmanWordLists); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexAVE.cxx000444001750001750 1550012021352777 24226 0ustar00azawawiazawawi000000000000// SciTE - Scintilla based Text Editor /** @file LexAVE.cxx ** Lexer for Avenue. ** ** Written by Alexey Yutkin . **/ // Copyright 1998-2002 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_'); } static inline bool IsEnumChar(const int ch) { return (ch < 0x80) && (isalnum(ch)|| ch == '_'); } static inline bool IsANumberChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '.' ); } inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } inline bool isAveOperator(char ch) { if (isascii(ch) && isalnum(ch)) return false; // '.' left out as it is used to make up numbers if (ch == '*' || ch == '/' || ch == '-' || ch == '+' || ch == '(' || ch == ')' || ch == '=' || ch == '{' || ch == '}' || ch == '[' || ch == ']' || ch == ';' || ch == '<' || ch == '>' || ch == ',' || ch == '.' ) return true; return false; } static void ColouriseAveDoc( unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; WordList &keywords3 = *keywordlists[2]; WordList &keywords4 = *keywordlists[3]; WordList &keywords5 = *keywordlists[4]; WordList &keywords6 = *keywordlists[5]; // Do not leak onto next line if (initStyle == SCE_AVE_STRINGEOL) { initStyle = SCE_AVE_DEFAULT; } StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { if (sc.atLineEnd) { // Update the line state, so it can be seen by next line int currentLine = styler.GetLine(sc.currentPos); styler.SetLineState(currentLine, 0); } if (sc.atLineStart && (sc.state == SCE_AVE_STRING)) { // Prevent SCE_AVE_STRINGEOL from leaking back to previous line sc.SetState(SCE_AVE_STRING); } // Determine if the current state should terminate. if (sc.state == SCE_AVE_OPERATOR) { sc.SetState(SCE_AVE_DEFAULT); } else if (sc.state == SCE_AVE_NUMBER) { if (!IsANumberChar(sc.ch)) { sc.SetState(SCE_AVE_DEFAULT); } } else if (sc.state == SCE_AVE_ENUM) { if (!IsEnumChar(sc.ch)) { sc.SetState(SCE_AVE_DEFAULT); } } else if (sc.state == SCE_AVE_IDENTIFIER) { if (!IsAWordChar(sc.ch) || (sc.ch == '.')) { char s[100]; //sc.GetCurrent(s, sizeof(s)); sc.GetCurrentLowered(s, sizeof(s)); if (keywords.InList(s)) { sc.ChangeState(SCE_AVE_WORD); } else if (keywords2.InList(s)) { sc.ChangeState(SCE_AVE_WORD2); } else if (keywords3.InList(s)) { sc.ChangeState(SCE_AVE_WORD3); } else if (keywords4.InList(s)) { sc.ChangeState(SCE_AVE_WORD4); } else if (keywords5.InList(s)) { sc.ChangeState(SCE_AVE_WORD5); } else if (keywords6.InList(s)) { sc.ChangeState(SCE_AVE_WORD6); } sc.SetState(SCE_AVE_DEFAULT); } } else if (sc.state == SCE_AVE_COMMENT) { if (sc.atLineEnd) { sc.SetState(SCE_AVE_DEFAULT); } } else if (sc.state == SCE_AVE_STRING) { if (sc.ch == '\"') { sc.ForwardSetState(SCE_AVE_DEFAULT); } else if (sc.atLineEnd) { sc.ChangeState(SCE_AVE_STRINGEOL); sc.ForwardSetState(SCE_AVE_DEFAULT); } } // Determine if a new state should be entered. if (sc.state == SCE_AVE_DEFAULT) { if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_AVE_NUMBER); } else if (IsAWordStart(sc.ch)) { sc.SetState(SCE_AVE_IDENTIFIER); } else if (sc.Match('\"')) { sc.SetState(SCE_AVE_STRING); } else if (sc.Match('\'')) { sc.SetState(SCE_AVE_COMMENT); sc.Forward(); } else if (isAveOperator(static_cast(sc.ch))) { sc.SetState(SCE_AVE_OPERATOR); } else if (sc.Match('#')) { sc.SetState(SCE_AVE_ENUM); sc.Forward(); } } } sc.Complete(); } static void FoldAveDoc(unsigned int startPos, int length, int /* initStyle */, WordList *[], Accessor &styler) { unsigned int lengthDoc = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = static_cast(tolower(styler[startPos])); bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; int styleNext = styler.StyleAt(startPos); char s[10]; for (unsigned int i = startPos; i < lengthDoc; i++) { char ch = static_cast(tolower(chNext)); chNext = static_cast(tolower(styler.SafeGetCharAt(i + 1))); int style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (style == SCE_AVE_WORD) { if (ch == 't' || ch == 'f' || ch == 'w' || ch == 'e') { for (unsigned int j = 0; j < 6; j++) { if (!iswordchar(styler[i + j])) { break; } s[j] = static_cast(tolower(styler[i + j])); s[j + 1] = '\0'; } if ((strcmp(s, "then") == 0) || (strcmp(s, "for") == 0) || (strcmp(s, "while") == 0)) { levelCurrent++; } if ((strcmp(s, "end") == 0) || (strcmp(s, "elseif") == 0)) { // Normally "elseif" and "then" will be on the same line and will cancel // each other out. // As implemented, this does not support fold.at.else. levelCurrent--; } } } else if (style == SCE_AVE_OPERATOR) { if (ch == '{' || ch == '(') { levelCurrent++; } else if (ch == '}' || ch == ')') { levelCurrent--; } } if (atEOL) { int lev = levelPrev; if (visibleChars == 0 && foldCompact) { lev |= SC_FOLDLEVELWHITEFLAG; } if ((levelCurrent > levelPrev) && (visibleChars > 0)) { lev |= SC_FOLDLEVELHEADERFLAG; } if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelPrev = levelCurrent; visibleChars = 0; } if (!isspacechar(ch)) { visibleChars++; } } // Fill in the real level of the next line, keeping the current flags as they will be filled in later int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, levelPrev | flagsNext); } LexerModule lmAVE(SCLEX_AVE, ColouriseAveDoc, "ave", FoldAveDoc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/Style.h000444001750001750 422012021352776 23643 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file Style.h ** Defines the font and colour style for a class of text. **/ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef STYLE_H #define STYLE_H #ifdef SCI_NAMESPACE namespace Scintilla { #endif struct FontSpecification { const char *fontName; int weight; bool italic; int size; int characterSet; int extraFontFlag; FontSpecification() : fontName(0), weight(SC_WEIGHT_NORMAL), italic(false), size(10 * SC_FONT_SIZE_MULTIPLIER), characterSet(0), extraFontFlag(0) { } bool EqualTo(const FontSpecification &other) const; }; // Just like Font but only has a copy of the FontID so should not delete it class FontAlias : public Font { // Private so FontAlias objects can not be copied FontAlias(const FontAlias &); FontAlias &operator=(const FontAlias &); public: FontAlias(); virtual ~FontAlias(); void MakeAlias(Font &fontOrigin); void ClearFont(); }; struct FontMeasurements { unsigned int ascent; unsigned int descent; XYPOSITION aveCharWidth; XYPOSITION spaceWidth; int sizeZoomed; FontMeasurements(); void Clear(); }; /** */ class Style : public FontSpecification, public FontMeasurements { public: ColourDesired fore; ColourDesired back; bool eolFilled; bool underline; enum ecaseForced {caseMixed, caseUpper, caseLower}; ecaseForced caseForce; bool visible; bool changeable; bool hotspot; FontAlias font; Style(); Style(const Style &source); ~Style(); Style &operator=(const Style &source); void Clear(ColourDesired fore_, ColourDesired back_, int size_, const char *fontName_, int characterSet_, int weight_, bool italic_, bool eolFilled_, bool underline_, ecaseForced caseForce_, bool visible_, bool changeable_, bool hotspot_); void ClearTo(const Style &source); void Copy(Font &font_, const FontMeasurements &fm_); bool IsProtected() const { return !(changeable && visible);} }; #ifdef SCI_NAMESPACE } #endif #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/CharacterSet.cxx000444001750001750 235212021352776 25472 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file CharacterSet.cxx ** Simple case functions for ASCII. ** Lexer infrastructure. **/ // Copyright 1998-2010 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include "CharacterSet.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif #ifdef SCI_NAMESPACE namespace Scintilla { #endif int CompareCaseInsensitive(const char *a, const char *b) { while (*a && *b) { if (*a != *b) { char upperA = MakeUpperCase(*a); char upperB = MakeUpperCase(*b); if (upperA != upperB) return upperA - upperB; } a++; b++; } // Either *a or *b is nul return *a - *b; } int CompareNCaseInsensitive(const char *a, const char *b, size_t len) { while (*a && *b && len) { if (*a != *b) { char upperA = MakeUpperCase(*a); char upperB = MakeUpperCase(*b); if (upperA != upperB) return upperA - upperB; } a++; b++; len--; } if (len == 0) return 0; else // Either *a or *b is nul return *a - *b; } #ifdef SCI_NAMESPACE } #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexConf.cxx000444001750001750 1337612021352777 24511 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexConf.cxx ** Lexer for Apache Configuration Files. ** ** First working version contributed by Ahmad Zawawi on October 28, 2000. ** i created this lexer because i needed something pretty when dealing ** when Apache Configuration files... **/ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) { int state = SCE_CONF_DEFAULT; char chNext = styler[startPos]; int lengthDoc = startPos + length; // create a buffer large enough to take the largest chunk... char *buffer = new char[length]; int bufferCount = 0; // this assumes that we have 2 keyword list in conf.properties WordList &directives = *keywordLists[0]; WordList ¶ms = *keywordLists[1]; // go through all provided text segment // using the hand-written state machine shown below styler.StartAt(startPos); styler.StartSegment(startPos); for (int i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); if (styler.IsLeadByte(ch)) { chNext = styler.SafeGetCharAt(i + 2); i++; continue; } switch(state) { case SCE_CONF_DEFAULT: if( ch == '\n' || ch == '\r' || ch == '\t' || ch == ' ') { // whitespace is simply ignored here... styler.ColourTo(i,SCE_CONF_DEFAULT); break; } else if( ch == '#' ) { // signals the start of a comment... state = SCE_CONF_COMMENT; styler.ColourTo(i,SCE_CONF_COMMENT); } else if( ch == '.' /*|| ch == '/'*/) { // signals the start of a file... state = SCE_CONF_EXTENSION; styler.ColourTo(i,SCE_CONF_EXTENSION); } else if( ch == '"') { state = SCE_CONF_STRING; styler.ColourTo(i,SCE_CONF_STRING); } else if( isascii(ch) && ispunct(ch) ) { // signals an operator... // no state jump necessary for this // simple case... styler.ColourTo(i,SCE_CONF_OPERATOR); } else if( isascii(ch) && isalpha(ch) ) { // signals the start of an identifier bufferCount = 0; buffer[bufferCount++] = static_cast(tolower(ch)); state = SCE_CONF_IDENTIFIER; } else if( isascii(ch) && isdigit(ch) ) { // signals the start of a number bufferCount = 0; buffer[bufferCount++] = ch; //styler.ColourTo(i,SCE_CONF_NUMBER); state = SCE_CONF_NUMBER; } else { // style it the default style.. styler.ColourTo(i,SCE_CONF_DEFAULT); } break; case SCE_CONF_COMMENT: // if we find a newline here, // we simply go to default state // else continue to work on it... if( ch == '\n' || ch == '\r' ) { state = SCE_CONF_DEFAULT; } else { styler.ColourTo(i,SCE_CONF_COMMENT); } break; case SCE_CONF_EXTENSION: // if we find a non-alphanumeric char, // we simply go to default state // else we're still dealing with an extension... if( (isascii(ch) && isalnum(ch)) || (ch == '_') || (ch == '-') || (ch == '$') || (ch == '/') || (ch == '.') || (ch == '*') ) { styler.ColourTo(i,SCE_CONF_EXTENSION); } else { state = SCE_CONF_DEFAULT; chNext = styler[i--]; } break; case SCE_CONF_STRING: // if we find the end of a string char, we simply go to default state // else we're still dealing with an string... if( (ch == '"' && styler.SafeGetCharAt(i-1)!='\\') || (ch == '\n') || (ch == '\r') ) { state = SCE_CONF_DEFAULT; } styler.ColourTo(i,SCE_CONF_STRING); break; case SCE_CONF_IDENTIFIER: // stay in CONF_IDENTIFIER state until we find a non-alphanumeric if( (isascii(ch) && isalnum(ch)) || (ch == '_') || (ch == '-') || (ch == '/') || (ch == '$') || (ch == '.') || (ch == '*')) { buffer[bufferCount++] = static_cast(tolower(ch)); } else { state = SCE_CONF_DEFAULT; buffer[bufferCount] = '\0'; // check if the buffer contains a keyword, and highlight it if it is a keyword... if(directives.InList(buffer)) { styler.ColourTo(i-1,SCE_CONF_DIRECTIVE ); } else if(params.InList(buffer)) { styler.ColourTo(i-1,SCE_CONF_PARAMETER ); } else if(strchr(buffer,'/') || strchr(buffer,'.')) { styler.ColourTo(i-1,SCE_CONF_EXTENSION); } else { styler.ColourTo(i-1,SCE_CONF_DEFAULT); } // push back the faulty character chNext = styler[i--]; } break; case SCE_CONF_NUMBER: // stay in CONF_NUMBER state until we find a non-numeric if( (isascii(ch) && isdigit(ch)) || ch == '.') { buffer[bufferCount++] = ch; } else { state = SCE_CONF_DEFAULT; buffer[bufferCount] = '\0'; // Colourize here... if( strchr(buffer,'.') ) { // it is an IP address... styler.ColourTo(i-1,SCE_CONF_IP); } else { // normal number styler.ColourTo(i-1,SCE_CONF_NUMBER); } // push back a character chNext = styler[i--]; } break; } } delete []buffer; } static const char * const confWordListDesc[] = { "Directives", "Parameters", 0 }; LexerModule lmConf(SCLEX_CONF, ColouriseConfDoc, "conf", 0, confWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexCPP.cxx000444001750001750 11421712021352777 24262 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexCPP.cxx ** Lexer for C++, C, Java, and JavaScript. ** Further folding features and configuration properties added by "Udo Lechner" **/ // Copyright 1998-2005 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #include "OptionSet.h" #include "SparseState.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static bool IsSpaceEquiv(int state) { return (state <= SCE_C_COMMENTDOC) || // including SCE_C_DEFAULT, SCE_C_COMMENT, SCE_C_COMMENTLINE (state == SCE_C_COMMENTLINEDOC) || (state == SCE_C_COMMENTDOCKEYWORD) || (state == SCE_C_COMMENTDOCKEYWORDERROR); } // Preconditions: sc.currentPos points to a character after '+' or '-'. // The test for pos reaching 0 should be redundant, // and is in only for safety measures. // Limitation: this code will give the incorrect answer for code like // a = b+++/ptn/... // Putting a space between the '++' post-inc operator and the '+' binary op // fixes this, and is highly recommended for readability anyway. static bool FollowsPostfixOperator(StyleContext &sc, LexAccessor &styler) { int pos = (int) sc.currentPos; while (--pos > 0) { char ch = styler[pos]; if (ch == '+' || ch == '-') { return styler[pos - 1] == ch; } } return false; } static bool followsReturnKeyword(StyleContext &sc, LexAccessor &styler) { // Don't look at styles, so no need to flush. int pos = (int) sc.currentPos; int currentLine = styler.GetLine(pos); int lineStartPos = styler.LineStart(currentLine); char ch; while (--pos > lineStartPos) { ch = styler.SafeGetCharAt(pos); if (ch != ' ' && ch != '\t') { break; } } const char *retBack = "nruter"; const char *s = retBack; while (*s && pos >= lineStartPos && styler.SafeGetCharAt(pos) == *s) { s++; pos--; } return !*s; } static std::string GetRestOfLine(LexAccessor &styler, int start, bool allowSpace) { std::string restOfLine; int i =0; char ch = styler.SafeGetCharAt(start, '\n'); while ((ch != '\r') && (ch != '\n')) { if (allowSpace || (ch != ' ')) restOfLine += ch; i++; ch = styler.SafeGetCharAt(start + i, '\n'); } return restOfLine; } static bool IsStreamCommentStyle(int style) { return style == SCE_C_COMMENT || style == SCE_C_COMMENTDOC || style == SCE_C_COMMENTDOCKEYWORD || style == SCE_C_COMMENTDOCKEYWORDERROR; } static std::vector Tokenize(const std::string &s) { // Break into space separated tokens std::string word; std::vector tokens; for (const char *cp = s.c_str(); *cp; cp++) { if ((*cp == ' ') || (*cp == '\t')) { if (!word.empty()) { tokens.push_back(word); word = ""; } } else { word += *cp; } } if (!word.empty()) { tokens.push_back(word); } return tokens; } struct PPDefinition { int line; std::string key; std::string value; PPDefinition(int line_, const std::string &key_, const std::string &value_) : line(line_), key(key_), value(value_) { } }; class LinePPState { int state; int ifTaken; int level; bool ValidLevel() const { return level >= 0 && level < 32; } int maskLevel() const { return 1 << level; } public: LinePPState() : state(0), ifTaken(0), level(-1) { } bool IsInactive() const { return state != 0; } bool CurrentIfTaken() { return (ifTaken & maskLevel()) != 0; } void StartSection(bool on) { level++; if (ValidLevel()) { if (on) { state &= ~maskLevel(); ifTaken |= maskLevel(); } else { state |= maskLevel(); ifTaken &= ~maskLevel(); } } } void EndSection() { if (ValidLevel()) { state &= ~maskLevel(); ifTaken &= ~maskLevel(); } level--; } void InvertCurrentLevel() { if (ValidLevel()) { state ^= maskLevel(); ifTaken |= maskLevel(); } } }; // Hold the preprocessor state for each line seen. // Currently one entry per line but could become sparse with just one entry per preprocessor line. class PPStates { std::vector vlls; public: LinePPState ForLine(int line) { if ((line > 0) && (vlls.size() > static_cast(line))) { return vlls[line]; } else { return LinePPState(); } } void Add(int line, LinePPState lls) { vlls.resize(line+1); vlls[line] = lls; } }; // An individual named option for use in an OptionSet // Options used for LexerCPP struct OptionsCPP { bool stylingWithinPreprocessor; bool identifiersAllowDollars; bool trackPreprocessor; bool updatePreprocessor; bool triplequotedStrings; bool hashquotedStrings; bool fold; bool foldSyntaxBased; bool foldComment; bool foldCommentMultiline; bool foldCommentExplicit; std::string foldExplicitStart; std::string foldExplicitEnd; bool foldExplicitAnywhere; bool foldPreprocessor; bool foldCompact; bool foldAtElse; OptionsCPP() { stylingWithinPreprocessor = false; identifiersAllowDollars = true; trackPreprocessor = true; updatePreprocessor = true; triplequotedStrings = false; hashquotedStrings = false; fold = false; foldSyntaxBased = true; foldComment = false; foldCommentMultiline = true; foldCommentExplicit = true; foldExplicitStart = ""; foldExplicitEnd = ""; foldExplicitAnywhere = false; foldPreprocessor = false; foldCompact = false; foldAtElse = false; } }; static const char *const cppWordLists[] = { "Primary keywords and identifiers", "Secondary keywords and identifiers", "Documentation comment keywords", "Global classes and typedefs", "Preprocessor definitions", 0, }; struct OptionSetCPP : public OptionSet { OptionSetCPP() { DefineProperty("styling.within.preprocessor", &OptionsCPP::stylingWithinPreprocessor, "For C++ code, determines whether all preprocessor code is styled in the " "preprocessor style (0, the default) or only from the initial # to the end " "of the command word(1)."); DefineProperty("lexer.cpp.allow.dollars", &OptionsCPP::identifiersAllowDollars, "Set to 0 to disallow the '$' character in identifiers with the cpp lexer."); DefineProperty("lexer.cpp.track.preprocessor", &OptionsCPP::trackPreprocessor, "Set to 1 to interpret #if/#else/#endif to grey out code that is not active."); DefineProperty("lexer.cpp.update.preprocessor", &OptionsCPP::updatePreprocessor, "Set to 1 to update preprocessor definitions when #define found."); DefineProperty("lexer.cpp.triplequoted.strings", &OptionsCPP::triplequotedStrings, "Set to 1 to enable highlighting of triple-quoted strings."); DefineProperty("lexer.cpp.hashquoted.strings", &OptionsCPP::hashquotedStrings, "Set to 1 to enable highlighting of hash-quoted strings."); DefineProperty("fold", &OptionsCPP::fold); DefineProperty("fold.cpp.syntax.based", &OptionsCPP::foldSyntaxBased, "Set this property to 0 to disable syntax based folding."); DefineProperty("fold.comment", &OptionsCPP::foldComment, "This option enables folding multi-line comments and explicit fold points when using the C++ lexer. " "Explicit fold points allows adding extra folding by placing a //{ comment at the start and a //} " "at the end of a section that should fold."); DefineProperty("fold.cpp.comment.multiline", &OptionsCPP::foldCommentMultiline, "Set this property to 0 to disable folding multi-line comments when fold.comment=1."); DefineProperty("fold.cpp.comment.explicit", &OptionsCPP::foldCommentExplicit, "Set this property to 0 to disable folding explicit fold points when fold.comment=1."); DefineProperty("fold.cpp.explicit.start", &OptionsCPP::foldExplicitStart, "The string to use for explicit fold start points, replacing the standard //{."); DefineProperty("fold.cpp.explicit.end", &OptionsCPP::foldExplicitEnd, "The string to use for explicit fold end points, replacing the standard //}."); DefineProperty("fold.cpp.explicit.anywhere", &OptionsCPP::foldExplicitAnywhere, "Set this property to 1 to enable explicit fold points anywhere, not just in line comments."); DefineProperty("fold.preprocessor", &OptionsCPP::foldPreprocessor, "This option enables folding preprocessor directives when using the C++ lexer. " "Includes C#'s explicit #region and #endregion folding directives."); DefineProperty("fold.compact", &OptionsCPP::foldCompact); DefineProperty("fold.at.else", &OptionsCPP::foldAtElse, "This option enables C++ folding on a \"} else {\" line of an if statement."); DefineWordListSets(cppWordLists); } }; class LexerCPP : public ILexer { bool caseSensitive; CharacterSet setWord; CharacterSet setNegationOp; CharacterSet setArithmethicOp; CharacterSet setRelOp; CharacterSet setLogicalOp; PPStates vlls; std::vector ppDefineHistory; WordList keywords; WordList keywords2; WordList keywords3; WordList keywords4; WordList ppDefinitions; std::map preprocessorDefinitionsStart; OptionsCPP options; OptionSetCPP osCPP; SparseState rawStringTerminators; enum { activeFlag = 0x40 }; public: LexerCPP(bool caseSensitive_) : caseSensitive(caseSensitive_), setWord(CharacterSet::setAlphaNum, "._", 0x80, true), setNegationOp(CharacterSet::setNone, "!"), setArithmethicOp(CharacterSet::setNone, "+-/*%"), setRelOp(CharacterSet::setNone, "=!<>"), setLogicalOp(CharacterSet::setNone, "|&") { } ~LexerCPP() { } void SCI_METHOD Release() { delete this; } int SCI_METHOD Version() const { return lvOriginal; } const char * SCI_METHOD PropertyNames() { return osCPP.PropertyNames(); } int SCI_METHOD PropertyType(const char *name) { return osCPP.PropertyType(name); } const char * SCI_METHOD DescribeProperty(const char *name) { return osCPP.DescribeProperty(name); } int SCI_METHOD PropertySet(const char *key, const char *val); const char * SCI_METHOD DescribeWordListSets() { return osCPP.DescribeWordListSets(); } int SCI_METHOD WordListSet(int n, const char *wl); void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess); void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess); void * SCI_METHOD PrivateCall(int, void *) { return 0; } static ILexer *LexerFactoryCPP() { return new LexerCPP(true); } static ILexer *LexerFactoryCPPInsensitive() { return new LexerCPP(false); } static int MaskActive(int style) { return style & ~activeFlag; } void EvaluateTokens(std::vector &tokens); bool EvaluateExpression(const std::string &expr, const std::map &preprocessorDefinitions); }; int SCI_METHOD LexerCPP::PropertySet(const char *key, const char *val) { if (osCPP.PropertySet(&options, key, val)) { return 0; } return -1; } int SCI_METHOD LexerCPP::WordListSet(int n, const char *wl) { WordList *wordListN = 0; switch (n) { case 0: wordListN = &keywords; break; case 1: wordListN = &keywords2; break; case 2: wordListN = &keywords3; break; case 3: wordListN = &keywords4; break; case 4: wordListN = &ppDefinitions; break; } int firstModification = -1; if (wordListN) { WordList wlNew; wlNew.Set(wl); if (*wordListN != wlNew) { wordListN->Set(wl); firstModification = 0; if (n == 4) { // Rebuild preprocessorDefinitions preprocessorDefinitionsStart.clear(); for (int nDefinition = 0; nDefinition < ppDefinitions.len; nDefinition++) { char *cpDefinition = ppDefinitions.words[nDefinition]; char *cpEquals = strchr(cpDefinition, '='); if (cpEquals) { std::string name(cpDefinition, cpEquals - cpDefinition); std::string val(cpEquals+1); preprocessorDefinitionsStart[name] = val; } else { std::string name(cpDefinition); std::string val("1"); preprocessorDefinitionsStart[name] = val; } } } } } return firstModification; } // Functor used to truncate history struct After { int line; After(int line_) : line(line_) {} bool operator()(PPDefinition &p) const { return p.line > line; } }; void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { LexAccessor styler(pAccess); CharacterSet setOKBeforeRE(CharacterSet::setNone, "([{=,:;!%^&*|?~+-"); CharacterSet setCouldBePostOp(CharacterSet::setNone, "+-"); CharacterSet setDoxygen(CharacterSet::setAlpha, "$@\\&<>#{}[]"); CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true); if (options.identifiersAllowDollars) { setWordStart.Add('$'); setWord.Add('$'); } int chPrevNonWhite = ' '; int visibleChars = 0; bool lastWordWasUUID = false; int styleBeforeDCKeyword = SCE_C_DEFAULT; bool continuationLine = false; bool isIncludePreprocessor = false; int lineCurrent = styler.GetLine(startPos); if ((initStyle == SCE_C_PREPROCESSOR) || (initStyle == SCE_C_COMMENTLINE) || (initStyle == SCE_C_COMMENTLINEDOC)) { // Set continuationLine if last character of previous line is '\' if (lineCurrent > 0) { int chBack = styler.SafeGetCharAt(startPos-1, 0); int chBack2 = styler.SafeGetCharAt(startPos-2, 0); int lineEndChar = '!'; if (chBack2 == '\r' && chBack == '\n') { lineEndChar = styler.SafeGetCharAt(startPos-3, 0); } else if (chBack == '\n' || chBack == '\r') { lineEndChar = chBack2; } continuationLine = lineEndChar == '\\'; } } // look back to set chPrevNonWhite properly for better regex colouring if (startPos > 0) { int back = startPos; while (--back && IsSpaceEquiv(styler.StyleAt(back))) ; if (styler.StyleAt(back) == SCE_C_OPERATOR) { chPrevNonWhite = styler.SafeGetCharAt(back); } } StyleContext sc(startPos, length, initStyle, styler, 0x7f); LinePPState preproc = vlls.ForLine(lineCurrent); bool definitionsChanged = false; // Truncate ppDefineHistory before current line if (!options.updatePreprocessor) ppDefineHistory.clear(); std::vector::iterator itInvalid = std::find_if(ppDefineHistory.begin(), ppDefineHistory.end(), After(lineCurrent-1)); if (itInvalid != ppDefineHistory.end()) { ppDefineHistory.erase(itInvalid, ppDefineHistory.end()); definitionsChanged = true; } std::map preprocessorDefinitions = preprocessorDefinitionsStart; for (std::vector::iterator itDef = ppDefineHistory.begin(); itDef != ppDefineHistory.end(); ++itDef) { preprocessorDefinitions[itDef->key] = itDef->value; } std::string rawStringTerminator = rawStringTerminators.ValueAt(lineCurrent-1); SparseState rawSTNew(lineCurrent); int activitySet = preproc.IsInactive() ? activeFlag : 0; for (; sc.More(); sc.Forward()) { if (sc.atLineStart) { if ((sc.state == SCE_C_STRING) || (sc.state == SCE_C_CHARACTER)) { // Prevent SCE_C_STRINGEOL from leaking back to previous line which // ends with a line continuation by locking in the state upto this position. sc.SetState(sc.state); } // Reset states to begining of colourise so no surprises // if different sets of lines lexed. visibleChars = 0; lastWordWasUUID = false; isIncludePreprocessor = false; if (preproc.IsInactive()) { activitySet = activeFlag; sc.SetState(sc.state | activitySet); } if (activitySet) { if (sc.ch == '#') { if (sc.Match("#else") || sc.Match("#end") || sc.Match("#if")) { //activitySet = 0; } } } } if (sc.atLineEnd) { lineCurrent++; vlls.Add(lineCurrent, preproc); if (rawStringTerminator != "") { rawSTNew.Set(lineCurrent-1, rawStringTerminator); } } // Handle line continuation generically. if (sc.ch == '\\') { if (sc.chNext == '\n' || sc.chNext == '\r') { lineCurrent++; vlls.Add(lineCurrent, preproc); sc.Forward(); if (sc.ch == '\r' && sc.chNext == '\n') { sc.Forward(); } continuationLine = true; continue; } } const bool atLineEndBeforeSwitch = sc.atLineEnd; // Determine if the current state should terminate. switch (MaskActive(sc.state)) { case SCE_C_OPERATOR: sc.SetState(SCE_C_DEFAULT|activitySet); break; case SCE_C_NUMBER: // We accept almost anything because of hex. and number suffixes if (!(setWord.Contains(sc.ch) || ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) { sc.SetState(SCE_C_DEFAULT|activitySet); } break; case SCE_C_IDENTIFIER: if (!setWord.Contains(sc.ch) || (sc.ch == '.')) { char s[1000]; if (caseSensitive) { sc.GetCurrent(s, sizeof(s)); } else { sc.GetCurrentLowered(s, sizeof(s)); } if (keywords.InList(s)) { lastWordWasUUID = strcmp(s, "uuid") == 0; sc.ChangeState(SCE_C_WORD|activitySet); } else if (keywords2.InList(s)) { sc.ChangeState(SCE_C_WORD2|activitySet); } else if (keywords4.InList(s)) { sc.ChangeState(SCE_C_GLOBALCLASS|activitySet); } const bool literalString = sc.ch == '\"'; if (literalString || sc.ch == '\'') { size_t lenS = strlen(s); const bool raw = literalString && sc.chPrev == 'R'; if (raw) s[lenS--] = '\0'; bool valid = (lenS == 0) || ((lenS == 1) && ((s[0] == 'L') || (s[0] == 'u') || (s[0] == 'U'))) || ((lenS == 2) && literalString && (s[0] == 'u') && (s[1] == '8')); if (valid) { if (literalString) sc.ChangeState((raw ? SCE_C_STRINGRAW : SCE_C_STRING)|activitySet); else sc.ChangeState(SCE_C_CHARACTER|activitySet); } } sc.SetState(SCE_C_DEFAULT|activitySet); } break; case SCE_C_PREPROCESSOR: if (sc.atLineStart && !continuationLine) { sc.SetState(SCE_C_DEFAULT|activitySet); } else if (options.stylingWithinPreprocessor) { if (IsASpace(sc.ch)) { sc.SetState(SCE_C_DEFAULT|activitySet); } } else { if (sc.Match('/', '*') || sc.Match('/', '/')) { sc.SetState(SCE_C_DEFAULT|activitySet); } } break; case SCE_C_COMMENT: if (sc.Match('*', '/')) { sc.Forward(); sc.ForwardSetState(SCE_C_DEFAULT|activitySet); } break; case SCE_C_COMMENTDOC: if (sc.Match('*', '/')) { sc.Forward(); sc.ForwardSetState(SCE_C_DEFAULT|activitySet); } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support // Verify that we have the conditions to mark a comment-doc-keyword if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) { styleBeforeDCKeyword = SCE_C_COMMENTDOC; sc.SetState(SCE_C_COMMENTDOCKEYWORD|activitySet); } } break; case SCE_C_COMMENTLINE: if (sc.atLineStart && !continuationLine) { sc.SetState(SCE_C_DEFAULT|activitySet); } break; case SCE_C_COMMENTLINEDOC: if (sc.atLineStart && !continuationLine) { sc.SetState(SCE_C_DEFAULT|activitySet); } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support // Verify that we have the conditions to mark a comment-doc-keyword if ((IsASpace(sc.chPrev) || sc.chPrev == '/' || sc.chPrev == '!') && (!IsASpace(sc.chNext))) { styleBeforeDCKeyword = SCE_C_COMMENTLINEDOC; sc.SetState(SCE_C_COMMENTDOCKEYWORD|activitySet); } } break; case SCE_C_COMMENTDOCKEYWORD: if ((styleBeforeDCKeyword == SCE_C_COMMENTDOC) && sc.Match('*', '/')) { sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR); sc.Forward(); sc.ForwardSetState(SCE_C_DEFAULT|activitySet); } else if (!setDoxygen.Contains(sc.ch)) { char s[100]; if (caseSensitive) { sc.GetCurrent(s, sizeof(s)); } else { sc.GetCurrentLowered(s, sizeof(s)); } if (!IsASpace(sc.ch) || !keywords3.InList(s + 1)) { sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR|activitySet); } sc.SetState(styleBeforeDCKeyword|activitySet); } break; case SCE_C_STRING: if (sc.atLineEnd) { sc.ChangeState(SCE_C_STRINGEOL|activitySet); } else if (isIncludePreprocessor) { if (sc.ch == '>') { sc.ForwardSetState(SCE_C_DEFAULT|activitySet); isIncludePreprocessor = false; } } else if (sc.ch == '\\') { if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { sc.Forward(); } } else if (sc.ch == '\"') { sc.ForwardSetState(SCE_C_DEFAULT|activitySet); } break; case SCE_C_HASHQUOTEDSTRING: if (sc.ch == '\\') { if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { sc.Forward(); } } else if (sc.ch == '\"') { sc.ForwardSetState(SCE_C_DEFAULT|activitySet); } break; case SCE_C_STRINGRAW: if (sc.Match(rawStringTerminator.c_str())) { for (size_t termPos=rawStringTerminator.size(); termPos; termPos--) sc.Forward(); sc.SetState(SCE_C_DEFAULT|activitySet); rawStringTerminator = ""; } break; case SCE_C_CHARACTER: if (sc.atLineEnd) { sc.ChangeState(SCE_C_STRINGEOL|activitySet); } else if (sc.ch == '\\') { if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { sc.Forward(); } } else if (sc.ch == '\'') { sc.ForwardSetState(SCE_C_DEFAULT|activitySet); } break; case SCE_C_REGEX: if (sc.atLineStart) { sc.SetState(SCE_C_DEFAULT|activitySet); } else if (sc.ch == '/') { sc.Forward(); while ((sc.ch < 0x80) && islower(sc.ch)) sc.Forward(); // gobble regex flags sc.SetState(SCE_C_DEFAULT|activitySet); } else if (sc.ch == '\\') { // Gobble up the quoted character if (sc.chNext == '\\' || sc.chNext == '/') { sc.Forward(); } } break; case SCE_C_STRINGEOL: if (sc.atLineStart) { sc.SetState(SCE_C_DEFAULT|activitySet); } break; case SCE_C_VERBATIM: if (sc.ch == '\"') { if (sc.chNext == '\"') { sc.Forward(); } else { sc.ForwardSetState(SCE_C_DEFAULT|activitySet); } } break; case SCE_C_TRIPLEVERBATIM: if (sc.Match("\"\"\"")) { while (sc.Match('"')) { sc.Forward(); } sc.SetState(SCE_C_DEFAULT|activitySet); } break; case SCE_C_UUID: if (sc.ch == '\r' || sc.ch == '\n' || sc.ch == ')') { sc.SetState(SCE_C_DEFAULT|activitySet); } } if (sc.atLineEnd && !atLineEndBeforeSwitch) { // State exit processing consumed characters up to end of line. lineCurrent++; vlls.Add(lineCurrent, preproc); } // Determine if a new state should be entered. if (MaskActive(sc.state) == SCE_C_DEFAULT) { if (sc.Match('@', '\"')) { sc.SetState(SCE_C_VERBATIM|activitySet); sc.Forward(); } else if (options.triplequotedStrings && sc.Match("\"\"\"")) { sc.SetState(SCE_C_TRIPLEVERBATIM|activitySet); sc.Forward(2); } else if (options.hashquotedStrings && sc.Match('#', '\"')) { sc.SetState(SCE_C_HASHQUOTEDSTRING|activitySet); sc.Forward(); } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { if (lastWordWasUUID) { sc.SetState(SCE_C_UUID|activitySet); lastWordWasUUID = false; } else { sc.SetState(SCE_C_NUMBER|activitySet); } } else if (setWordStart.Contains(sc.ch) || (sc.ch == '@')) { if (lastWordWasUUID) { sc.SetState(SCE_C_UUID|activitySet); lastWordWasUUID = false; } else { sc.SetState(SCE_C_IDENTIFIER|activitySet); } } else if (sc.Match('/', '*')) { if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style sc.SetState(SCE_C_COMMENTDOC|activitySet); } else { sc.SetState(SCE_C_COMMENT|activitySet); } sc.Forward(); // Eat the * so it isn't used for the end of the comment } else if (sc.Match('/', '/')) { if ((sc.Match("///") && !sc.Match("////")) || sc.Match("//!")) // Support of Qt/Doxygen doc. style sc.SetState(SCE_C_COMMENTLINEDOC|activitySet); else sc.SetState(SCE_C_COMMENTLINE|activitySet); } else if (sc.ch == '/' && (setOKBeforeRE.Contains(chPrevNonWhite) || followsReturnKeyword(sc, styler)) && (!setCouldBePostOp.Contains(chPrevNonWhite) || !FollowsPostfixOperator(sc, styler))) { sc.SetState(SCE_C_REGEX|activitySet); // JavaScript's RegEx } else if (sc.ch == '\"') { if (sc.chPrev == 'R') { styler.Flush(); if (MaskActive(styler.StyleAt(sc.currentPos - 1)) == SCE_C_STRINGRAW) { sc.SetState(SCE_C_STRINGRAW|activitySet); rawStringTerminator = ")"; for (int termPos = sc.currentPos + 1;; termPos++) { char chTerminator = styler.SafeGetCharAt(termPos, '('); if (chTerminator == '(') break; rawStringTerminator += chTerminator; } rawStringTerminator += '\"'; } else { sc.SetState(SCE_C_STRING|activitySet); } } else { sc.SetState(SCE_C_STRING|activitySet); } isIncludePreprocessor = false; // ensure that '>' won't end the string } else if (isIncludePreprocessor && sc.ch == '<') { sc.SetState(SCE_C_STRING|activitySet); } else if (sc.ch == '\'') { sc.SetState(SCE_C_CHARACTER|activitySet); } else if (sc.ch == '#' && visibleChars == 0) { // Preprocessor commands are alone on their line sc.SetState(SCE_C_PREPROCESSOR|activitySet); // Skip whitespace between # and preprocessor word do { sc.Forward(); } while ((sc.ch == ' ' || sc.ch == '\t') && sc.More()); if (sc.atLineEnd) { sc.SetState(SCE_C_DEFAULT|activitySet); } else if (sc.Match("include")) { isIncludePreprocessor = true; } else { if (options.trackPreprocessor) { if (sc.Match("ifdef") || sc.Match("ifndef")) { bool isIfDef = sc.Match("ifdef"); int i = isIfDef ? 5 : 6; std::string restOfLine = GetRestOfLine(styler, sc.currentPos + i + 1, false); bool foundDef = preprocessorDefinitions.find(restOfLine) != preprocessorDefinitions.end(); preproc.StartSection(isIfDef == foundDef); } else if (sc.Match("if")) { std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 2, true); bool ifGood = EvaluateExpression(restOfLine, preprocessorDefinitions); preproc.StartSection(ifGood); } else if (sc.Match("else")) { if (!preproc.CurrentIfTaken()) { preproc.InvertCurrentLevel(); activitySet = preproc.IsInactive() ? activeFlag : 0; if (!activitySet) sc.ChangeState(SCE_C_PREPROCESSOR|activitySet); } else if (!preproc.IsInactive()) { preproc.InvertCurrentLevel(); activitySet = preproc.IsInactive() ? activeFlag : 0; if (!activitySet) sc.ChangeState(SCE_C_PREPROCESSOR|activitySet); } } else if (sc.Match("elif")) { // Ensure only one chosen out of #if .. #elif .. #elif .. #else .. #endif if (!preproc.CurrentIfTaken()) { // Similar to #if std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 2, true); bool ifGood = EvaluateExpression(restOfLine, preprocessorDefinitions); if (ifGood) { preproc.InvertCurrentLevel(); activitySet = preproc.IsInactive() ? activeFlag : 0; if (!activitySet) sc.ChangeState(SCE_C_PREPROCESSOR|activitySet); } } else if (!preproc.IsInactive()) { preproc.InvertCurrentLevel(); activitySet = preproc.IsInactive() ? activeFlag : 0; if (!activitySet) sc.ChangeState(SCE_C_PREPROCESSOR|activitySet); } } else if (sc.Match("endif")) { preproc.EndSection(); activitySet = preproc.IsInactive() ? activeFlag : 0; sc.ChangeState(SCE_C_PREPROCESSOR|activitySet); } else if (sc.Match("define")) { if (options.updatePreprocessor && !preproc.IsInactive()) { std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 6, true); if (restOfLine.find(")") == std::string::npos) { // Don't handle macros with arguments std::vector tokens = Tokenize(restOfLine); std::string key; std::string value("1"); if (tokens.size() >= 1) { key = tokens[0]; if (tokens.size() >= 2) { value = tokens[1]; } preprocessorDefinitions[key] = value; ppDefineHistory.push_back(PPDefinition(lineCurrent, key, value)); definitionsChanged = true; } } } } } } } else if (isoperator(static_cast(sc.ch))) { sc.SetState(SCE_C_OPERATOR|activitySet); } } if (!IsASpace(sc.ch) && !IsSpaceEquiv(sc.state)) { chPrevNonWhite = sc.ch; visibleChars++; } continuationLine = false; } const bool rawStringsChanged = rawStringTerminators.Merge(rawSTNew, lineCurrent); if (definitionsChanged || rawStringsChanged) styler.ChangeLexerState(startPos, startPos + length); sc.Complete(); } // Store both the current line's fold level and the next lines in the // level store to make it easy to pick up with each increment // and to make it possible to fiddle the current level for "} else {". void SCI_METHOD LexerCPP::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { if (!options.fold) return; LexAccessor styler(pAccess); unsigned int endPos = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; int levelMinCurrent = levelCurrent; int levelNext = levelCurrent; char chNext = styler[startPos]; int styleNext = MaskActive(styler.StyleAt(startPos)); int style = MaskActive(initStyle); const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty(); for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; style = styleNext; styleNext = MaskActive(styler.StyleAt(i + 1)); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (options.foldComment && options.foldCommentMultiline && IsStreamCommentStyle(style)) { if (!IsStreamCommentStyle(stylePrev) && (stylePrev != SCE_C_COMMENTLINEDOC)) { levelNext++; } else if (!IsStreamCommentStyle(styleNext) && (styleNext != SCE_C_COMMENTLINEDOC) && !atEOL) { // Comments don't end at end of line and the next character may be unstyled. levelNext--; } } if (options.foldComment && options.foldCommentExplicit && ((style == SCE_C_COMMENTLINE) || options.foldExplicitAnywhere)) { if (userDefinedFoldMarkers) { if (styler.Match(i, options.foldExplicitStart.c_str())) { levelNext++; } else if (styler.Match(i, options.foldExplicitEnd.c_str())) { levelNext--; } } else { if ((ch == '/') && (chNext == '/')) { char chNext2 = styler.SafeGetCharAt(i + 2); if (chNext2 == '{') { levelNext++; } else if (chNext2 == '}') { levelNext--; } } } } if (options.foldPreprocessor && (style == SCE_C_PREPROCESSOR)) { if (ch == '#') { unsigned int j = i + 1; while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) { j++; } if (styler.Match(j, "region") || styler.Match(j, "if")) { levelNext++; } else if (styler.Match(j, "end")) { levelNext--; } } } if (options.foldSyntaxBased && (style == SCE_C_OPERATOR)) { if (ch == '{') { // Measure the minimum before a '{' to allow // folding on "} else {" if (levelMinCurrent > levelNext) { levelMinCurrent = levelNext; } levelNext++; } else if (ch == '}') { levelNext--; } } if (!IsASpace(ch)) visibleChars++; if (atEOL || (i == endPos-1)) { int levelUse = levelCurrent; if (options.foldSyntaxBased && options.foldAtElse) { levelUse = levelMinCurrent; } int lev = levelUse | levelNext << 16; if (visibleChars == 0 && options.foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if (levelUse < levelNext) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelCurrent = levelNext; levelMinCurrent = levelCurrent; if (atEOL && (i == static_cast(styler.Length()-1))) { // There is an empty line at end of file so give it same level and empty styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG); } visibleChars = 0; } } } void LexerCPP::EvaluateTokens(std::vector &tokens) { // Evaluate defined() statements to either 0 or 1 for (size_t i=0; (i+2)) tokens.erase(tokens.begin() + i + 1, tokens.begin() + i + 4); val = "1"; } tokens[i] = val; } else { i++; } } // Find bracketed subexpressions and recurse on them std::vector::iterator itBracket = std::find(tokens.begin(), tokens.end(), "("); std::vector::iterator itEndBracket = std::find(tokens.begin(), tokens.end(), ")"); while ((itBracket != tokens.end()) && (itEndBracket != tokens.end()) && (itEndBracket > itBracket)) { std::vector inBracket(itBracket + 1, itEndBracket); EvaluateTokens(inBracket); // The insertion is done before the removal because there were failures with the opposite approach tokens.insert(itBracket, inBracket.begin(), inBracket.end()); itBracket = std::find(tokens.begin(), tokens.end(), "("); itEndBracket = std::find(tokens.begin(), tokens.end(), ")"); tokens.erase(itBracket, itEndBracket + 1); itBracket = std::find(tokens.begin(), tokens.end(), "("); itEndBracket = std::find(tokens.begin(), tokens.end(), ")"); } // Evaluate logical negations for (size_t j=0; (j+1)::iterator itInsert = tokens.erase(tokens.begin() + j, tokens.begin() + j + 2); tokens.insert(itInsert, isTrue ? "1" : "0"); } else { j++; } } // Evaluate expressions in precedence order enum precedence { precArithmetic, precRelative, precLogical }; for (int prec=precArithmetic; prec <= precLogical; prec++) { // Looking at 3 tokens at a time so end at 2 before end for (size_t k=0; (k+2)") result = valA > valB; else if (tokens[k+1] == ">=") result = valA >= valB; else if (tokens[k+1] == "==") result = valA == valB; else if (tokens[k+1] == "!=") result = valA != valB; else if (tokens[k+1] == "||") result = valA || valB; else if (tokens[k+1] == "&&") result = valA && valB; char sResult[30]; sprintf(sResult, "%d", result); std::vector::iterator itInsert = tokens.erase(tokens.begin() + k, tokens.begin() + k + 3); tokens.insert(itInsert, sResult); } else { k++; } } } } bool LexerCPP::EvaluateExpression(const std::string &expr, const std::map &preprocessorDefinitions) { // Break into tokens, replacing with definitions std::string word; std::vector tokens; const char *cp = expr.c_str(); for (;;) { if (setWord.Contains(*cp)) { word += *cp; } else { std::map::const_iterator it = preprocessorDefinitions.find(word); if (it != preprocessorDefinitions.end()) { tokens.push_back(it->second); } else if (!word.empty() && ((word[0] >= '0' && word[0] <= '9') || (word == "defined"))) { tokens.push_back(word); } word = ""; if (!*cp) { break; } if ((*cp != ' ') && (*cp != '\t')) { std::string op(cp, 1); if (setRelOp.Contains(*cp)) { if (setRelOp.Contains(cp[1])) { op += cp[1]; cp++; } } else if (setLogicalOp.Contains(*cp)) { if (setLogicalOp.Contains(cp[1])) { op += cp[1]; cp++; } } tokens.push_back(op); } } cp++; } EvaluateTokens(tokens); // "0" or "" -> false else true bool isFalse = tokens.empty() || ((tokens.size() == 1) && ((tokens[0] == "") || tokens[0] == "0")); return !isFalse; } LexerModule lmCPP(SCLEX_CPP, LexerCPP::LexerFactoryCPP, "cpp", cppWordLists); LexerModule lmCPPNoCase(SCLEX_CPPNOCASE, LexerCPP::LexerFactoryCPPInsensitive, "cppnocase", cppWordLists); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/PropSetSimple.cxx000444001750001750 1156312021352777 25715 0ustar00azawawiazawawi000000000000// SciTE - Scintilla based Text Editor /** @file PropSetSimple.cxx ** A Java style properties file module. **/ // Copyright 1998-2010 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. // Maintain a dictionary of properties #include #include #include #ifdef _MSC_VER // Visual C++ doesn't like unreachable code or long decorated names in its own headers. #pragma warning(disable: 4018 4100 4245 4511 4512 4663 4702 4786) #endif #include #include #include "PropSetSimple.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif typedef std::map mapss; PropSetSimple::PropSetSimple() { mapss *props = new mapss; impl = static_cast(props); } PropSetSimple::~PropSetSimple() { mapss *props = static_cast(impl); delete props; impl = 0; } void PropSetSimple::Set(const char *key, const char *val, int lenKey, int lenVal) { mapss *props = static_cast(impl); if (!*key) // Empty keys are not supported return; if (lenKey == -1) lenKey = static_cast(strlen(key)); if (lenVal == -1) lenVal = static_cast(strlen(val)); (*props)[std::string(key, lenKey)] = std::string(val, lenVal); } static bool IsASpaceCharacter(unsigned int ch) { return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d)); } void PropSetSimple::Set(const char *keyVal) { while (IsASpaceCharacter(*keyVal)) keyVal++; const char *endVal = keyVal; while (*endVal && (*endVal != '\n')) endVal++; const char *eqAt = strchr(keyVal, '='); if (eqAt) { Set(keyVal, eqAt + 1, static_cast(eqAt-keyVal), static_cast(endVal - eqAt - 1)); } else if (*keyVal) { // No '=' so assume '=1' Set(keyVal, "1", static_cast(endVal-keyVal), 1); } } void PropSetSimple::SetMultiple(const char *s) { const char *eol = strchr(s, '\n'); while (eol) { Set(s); s = eol + 1; eol = strchr(s, '\n'); } Set(s); } const char *PropSetSimple::Get(const char *key) const { mapss *props = static_cast(impl); mapss::const_iterator keyPos = props->find(std::string(key)); if (keyPos != props->end()) { return keyPos->second.c_str(); } else { return ""; } } // There is some inconsistency between GetExpanded("foo") and Expand("$(foo)"). // A solution is to keep a stack of variables that have been expanded, so that // recursive expansions can be skipped. For now I'll just use the C++ stack // for that, through a recursive function and a simple chain of pointers. struct VarChain { VarChain(const char *var_=NULL, const VarChain *link_=NULL): var(var_), link(link_) {} bool contains(const char *testVar) const { return (var && (0 == strcmp(var, testVar))) || (link && link->contains(testVar)); } const char *var; const VarChain *link; }; static int ExpandAllInPlace(const PropSetSimple &props, std::string &withVars, int maxExpands, const VarChain &blankVars) { size_t varStart = withVars.find("$("); while ((varStart != std::string::npos) && (maxExpands > 0)) { size_t varEnd = withVars.find(")", varStart+2); if (varEnd == std::string::npos) { break; } // For consistency, when we see '$(ab$(cde))', expand the inner variable first, // regardless whether there is actually a degenerate variable named 'ab$(cde'. size_t innerVarStart = withVars.find("$(", varStart+2); while ((innerVarStart != std::string::npos) && (innerVarStart > varStart) && (innerVarStart < varEnd)) { varStart = innerVarStart; innerVarStart = withVars.find("$(", varStart+2); } std::string var(withVars.c_str(), varStart + 2, varEnd - varStart - 2); std::string val = props.Get(var.c_str()); if (blankVars.contains(var.c_str())) { val = ""; // treat blankVar as an empty string (e.g. to block self-reference) } if (--maxExpands >= 0) { maxExpands = ExpandAllInPlace(props, val, maxExpands, VarChain(var.c_str(), &blankVars)); } withVars.erase(varStart, varEnd-varStart+1); withVars.insert(varStart, val.c_str(), val.length()); varStart = withVars.find("$("); } return maxExpands; } char *PropSetSimple::Expanded(const char *key) const { std::string val = Get(key); ExpandAllInPlace(*this, val, 100, VarChain(key)); char *ret = new char [val.size() + 1]; strcpy(ret, val.c_str()); return ret; } int PropSetSimple::GetExpanded(const char *key, char *result) const { char *val = Expanded(key); const int n = static_cast(strlen(val)); if (result) { strcpy(result, val); } delete []val; return n; // Not including NUL } int PropSetSimple::GetInt(const char *key, int defaultValue) const { char *val = Expanded(key); if (val) { int retVal = val[0] ? atoi(val) : defaultValue; delete []val; return retVal; } return defaultValue; } Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/CharClassify.h000444001750001750 166612021352777 25132 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file CharClassify.h ** Character classifications used by Document and RESearch. **/ // Copyright 2006-2009 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef CHARCLASSIFY_H #define CHARCLASSIFY_H #ifdef SCI_NAMESPACE namespace Scintilla { #endif class CharClassify { public: CharClassify(); enum cc { ccSpace, ccNewLine, ccWord, ccPunctuation }; void SetDefaultCharClasses(bool includeWordClass); void SetCharClasses(const unsigned char *chars, cc newCharClass); cc GetClass(unsigned char ch) const { return static_cast(charClass[ch]);} bool IsWord(unsigned char ch) const { return static_cast(charClass[ch]) == ccWord;} private: enum { maxChar=256 }; unsigned char charClass[maxChar]; // not type cc to save space }; #ifdef SCI_NAMESPACE } #endif #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/Document.h000444001750001750 3717412021352777 24360 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file Document.h ** Text document that handles notifications, DBCS, styling, words and end of line. **/ // Copyright 1998-2011 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef DOCUMENT_H #define DOCUMENT_H #ifdef SCI_NAMESPACE namespace Scintilla { #endif /** * A Position is a position within a document between two characters or at the beginning or end. * Sometimes used as a character index where it identifies the character after the position. */ typedef int Position; const Position invalidPosition = -1; /** * The range class represents a range of text in a document. * The two values are not sorted as one end may be more significant than the other * as is the case for the selection where the end position is the position of the caret. * If either position is invalidPosition then the range is invalid and most operations will fail. */ class Range { public: Position start; Position end; Range(Position pos=0) : start(pos), end(pos) { } Range(Position start_, Position end_) : start(start_), end(end_) { } bool Valid() const { return (start != invalidPosition) && (end != invalidPosition); } // Is the position within the range? bool Contains(Position pos) const { if (start < end) { return (pos >= start && pos <= end); } else { return (pos <= start && pos >= end); } } // Is the character after pos within the range? bool ContainsCharacter(Position pos) const { if (start < end) { return (pos >= start && pos < end); } else { return (pos < start && pos >= end); } } bool Contains(Range other) const { return Contains(other.start) && Contains(other.end); } bool Overlaps(Range other) const { return Contains(other.start) || Contains(other.end) || other.Contains(start) || other.Contains(end); } }; class DocWatcher; class DocModification; class Document; /** * Interface class for regular expression searching */ class RegexSearchBase { public: virtual ~RegexSearchBase() {} virtual long FindText(Document *doc, int minPos, int maxPos, const char *s, bool caseSensitive, bool word, bool wordStart, int flags, int *length) = 0; ///@return String with the substitutions, must remain valid until the next call or destruction virtual const char *SubstituteByPosition(Document *doc, const char *text, int *length) = 0; }; /// Factory function for RegexSearchBase extern RegexSearchBase *CreateRegexSearch(CharClassify *charClassTable); struct StyledText { size_t length; const char *text; bool multipleStyles; size_t style; const unsigned char *styles; StyledText(size_t length_, const char *text_, bool multipleStyles_, int style_, const unsigned char *styles_) : length(length_), text(text_), multipleStyles(multipleStyles_), style(style_), styles(styles_) { } // Return number of bytes from start to before '\n' or end of text. // Return 1 when start is outside text size_t LineLength(size_t start) const { size_t cur = start; while ((cur < length) && (text[cur] != '\n')) cur++; return cur-start; } size_t StyleAt(size_t i) const { return multipleStyles ? styles[i] : style; } }; class HighlightDelimiter { public: HighlightDelimiter() : isEnabled(false) { Clear(); } void Clear() { beginFoldBlock = -1; endFoldBlock = -1; firstChangeableLineBefore = -1; firstChangeableLineAfter = -1; } bool NeedsDrawing(int line) { return isEnabled && (line <= firstChangeableLineBefore || line >= firstChangeableLineAfter); } bool IsFoldBlockHighlighted(int line) { return isEnabled && beginFoldBlock != -1 && beginFoldBlock <= line && line <= endFoldBlock; } bool IsHeadOfFoldBlock(int line) { return beginFoldBlock == line && line < endFoldBlock; } bool IsBodyOfFoldBlock(int line) { return beginFoldBlock != -1 && beginFoldBlock < line && line < endFoldBlock; } bool IsTailOfFoldBlock(int line) { return beginFoldBlock != -1 && beginFoldBlock < line && line == endFoldBlock; } int beginFoldBlock; // Begin of current fold block int endFoldBlock; // End of current fold block int firstChangeableLineBefore; // First line that triggers repaint before starting line that determined current fold block int firstChangeableLineAfter; // First line that triggers repaint after starting line that determined current fold block bool isEnabled; }; class CaseFolder { public: virtual ~CaseFolder() { } virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) = 0; }; class CaseFolderTable : public CaseFolder { protected: char mapping[256]; public: CaseFolderTable(); virtual ~CaseFolderTable(); virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed); void SetTranslation(char ch, char chTranslation); void StandardASCII(); }; class Document; class LexInterface { protected: Document *pdoc; ILexer *instance; bool performingStyle; ///< Prevent reentrance public: LexInterface(Document *pdoc_) : pdoc(pdoc_), instance(0), performingStyle(false) { } virtual ~LexInterface() { } void Colourise(int start, int end); bool UseContainerLexing() const { return instance == 0; } }; /** */ class Document : PerLine, public IDocument, public ILoader { public: /** Used to pair watcher pointer with user data. */ class WatcherWithUserData { public: DocWatcher *watcher; void *userData; WatcherWithUserData() { watcher = 0; userData = 0; } }; enum charClassification { ccSpace, ccNewLine, ccWord, ccPunctuation }; private: int refCount; CellBuffer cb; CharClassify charClass; char stylingMask; int endStyled; int styleClock; int enteredModification; int enteredStyling; int enteredReadOnlyCount; WatcherWithUserData *watchers; int lenWatchers; // ldSize is not real data - it is for dimensions and loops enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldSize }; PerLine *perLineData[ldSize]; bool matchesValid; RegexSearchBase *regex; public: LexInterface *pli; int stylingBits; int stylingBitsMask; int eolMode; /// Can also be SC_CP_UTF8 to enable UTF-8 mode int dbcsCodePage; int tabInChars; int indentInChars; int actualIndentInChars; bool useTabs; bool tabIndents; bool backspaceUnindents; DecorationList decorations; Document(); virtual ~Document(); int AddRef(); int SCI_METHOD Release(); virtual void Init(); virtual void InsertLine(int line); virtual void RemoveLine(int line); int SCI_METHOD Version() const { return dvOriginal; } void SCI_METHOD SetErrorStatus(int status); int SCI_METHOD LineFromPosition(int pos) const; int ClampPositionIntoDocument(int pos); bool IsCrLf(int pos); int LenChar(int pos); bool InGoodUTF8(int pos, int &start, int &end) const; int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true); int NextPosition(int pos, int moveDir) const; bool NextCharacter(int &pos, int moveDir); // Returns true if pos changed int SCI_METHOD CodePage() const; bool SCI_METHOD IsDBCSLeadByte(char ch) const; int SafeSegment(const char *text, int length, int lengthSegment); // Gateways to modifying document void ModifiedAt(int pos); void CheckReadOnly(); bool DeleteChars(int pos, int len); bool InsertString(int position, const char *s, int insertLength); int SCI_METHOD AddData(char *data, int length); void * SCI_METHOD ConvertToDocument(); int Undo(); int Redo(); bool CanUndo() { return cb.CanUndo(); } bool CanRedo() { return cb.CanRedo(); } void DeleteUndoHistory() { cb.DeleteUndoHistory(); } bool SetUndoCollection(bool collectUndo) { return cb.SetUndoCollection(collectUndo); } bool IsCollectingUndo() { return cb.IsCollectingUndo(); } void BeginUndoAction() { cb.BeginUndoAction(); } void EndUndoAction() { cb.EndUndoAction(); } void AddUndoAction(int token, bool mayCoalesce) { cb.AddUndoAction(token, mayCoalesce); } void SetSavePoint(); bool IsSavePoint() { return cb.IsSavePoint(); } const char * SCI_METHOD BufferPointer() { return cb.BufferPointer(); } int SCI_METHOD GetLineIndentation(int line); void SetLineIndentation(int line, int indent); int GetLineIndentPosition(int line) const; int GetColumn(int position); int CountCharacters(int startPos, int endPos); int FindColumn(int line, int column); void Indent(bool forwards, int lineBottom, int lineTop); static char *TransformLineEnds(int *pLenOut, const char *s, size_t len, int eolModeWanted); void ConvertLineEnds(int eolModeSet); void SetReadOnly(bool set) { cb.SetReadOnly(set); } bool IsReadOnly() { return cb.IsReadOnly(); } bool InsertChar(int pos, char ch); bool InsertCString(int position, const char *s); void ChangeChar(int pos, char ch); void DelChar(int pos); void DelCharBack(int pos); char CharAt(int position) { return cb.CharAt(position); } void SCI_METHOD GetCharRange(char *buffer, int position, int lengthRetrieve) const { cb.GetCharRange(buffer, position, lengthRetrieve); } char SCI_METHOD StyleAt(int position) const { return cb.StyleAt(position); } void GetStyleRange(unsigned char *buffer, int position, int lengthRetrieve) const { cb.GetStyleRange(buffer, position, lengthRetrieve); } int GetMark(int line); int MarkerNext(int lineStart, int mask) const; int AddMark(int line, int markerNum); void AddMarkSet(int line, int valueSet); void DeleteMark(int line, int markerNum); void DeleteMarkFromHandle(int markerHandle); void DeleteAllMarks(int markerNum); int LineFromHandle(int markerHandle); int SCI_METHOD LineStart(int line) const; int LineEnd(int line) const; int LineEndPosition(int position) const; bool IsLineEndPosition(int position) const; int VCHomePosition(int position) const; int SCI_METHOD SetLevel(int line, int level); int SCI_METHOD GetLevel(int line) const; void ClearLevels(); int GetLastChild(int lineParent, int level=-1, int lastLine=-1); int GetFoldParent(int line); void GetHighlightDelimiters(HighlightDelimiter &hDelimiter, int line, int lastLine); void Indent(bool forwards); int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false); int NextWordStart(int pos, int delta); int NextWordEnd(int pos, int delta); int SCI_METHOD Length() const { return cb.Length(); } void Allocate(int newSize) { cb.Allocate(newSize); } size_t ExtractChar(int pos, char *bytes); bool MatchesWordOptions(bool word, bool wordStart, int pos, int length); long FindText(int minPos, int maxPos, const char *search, bool caseSensitive, bool word, bool wordStart, bool regExp, int flags, int *length, CaseFolder *pcf); const char *SubstituteByPosition(const char *text, int *length); int LinesTotal() const; void ChangeCase(Range r, bool makeUpperCase); void SetDefaultCharClasses(bool includeWordClass); void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass); void SetStylingBits(int bits); void SCI_METHOD StartStyling(int position, char mask); bool SCI_METHOD SetStyleFor(int length, char style); bool SCI_METHOD SetStyles(int length, const char *styles); int GetEndStyled() { return endStyled; } void EnsureStyledTo(int pos); void LexerChanged(); int GetStyleClock() { return styleClock; } void IncrementStyleClock(); void SCI_METHOD DecorationSetCurrentIndicator(int indicator) { decorations.SetCurrentIndicator(indicator); } void SCI_METHOD DecorationFillRange(int position, int value, int fillLength); int SCI_METHOD SetLineState(int line, int state); int SCI_METHOD GetLineState(int line) const; int GetMaxLineState(); void SCI_METHOD ChangeLexerState(int start, int end); StyledText MarginStyledText(int line); void MarginSetStyle(int line, int style); void MarginSetStyles(int line, const unsigned char *styles); void MarginSetText(int line, const char *text); int MarginLength(int line) const; void MarginClearAll(); bool AnnotationAny() const; StyledText AnnotationStyledText(int line); void AnnotationSetText(int line, const char *text); void AnnotationSetStyle(int line, int style); void AnnotationSetStyles(int line, const unsigned char *styles); int AnnotationLength(int line) const; int AnnotationLines(int line) const; void AnnotationClearAll(); bool AddWatcher(DocWatcher *watcher, void *userData); bool RemoveWatcher(DocWatcher *watcher, void *userData); const WatcherWithUserData *GetWatchers() const { return watchers; } int GetLenWatchers() const { return lenWatchers; } CharClassify::cc WordCharClass(unsigned char ch); bool IsWordPartSeparator(char ch); int WordPartLeft(int pos); int WordPartRight(int pos); int ExtendStyleRange(int pos, int delta, bool singleLine = false); bool IsWhiteLine(int line) const; int ParaUp(int pos); int ParaDown(int pos); int IndentSize() { return actualIndentInChars; } int BraceMatch(int position, int maxReStyle); private: bool IsWordStartAt(int pos); bool IsWordEndAt(int pos); bool IsWordAt(int start, int end); void NotifyModifyAttempt(); void NotifySavePoint(bool atSavePoint); void NotifyModified(DocModification mh); }; class UndoGroup { Document *pdoc; bool groupNeeded; public: UndoGroup(Document *pdoc_, bool groupNeeded_=true) : pdoc(pdoc_), groupNeeded(groupNeeded_) { if (groupNeeded) { pdoc->BeginUndoAction(); } } ~UndoGroup() { if (groupNeeded) { pdoc->EndUndoAction(); } } bool Needed() const { return groupNeeded; } }; /** * To optimise processing of document modifications by DocWatchers, a hint is passed indicating the * scope of the change. * If the DocWatcher is a document view then this can be used to optimise screen updating. */ class DocModification { public: int modificationType; int position; int length; int linesAdded; /**< Negative if lines deleted. */ const char *text; /**< Only valid for changes to text, not for changes to style. */ int line; int foldLevelNow; int foldLevelPrev; int annotationLinesAdded; int token; DocModification(int modificationType_, int position_=0, int length_=0, int linesAdded_=0, const char *text_=0, int line_=0) : modificationType(modificationType_), position(position_), length(length_), linesAdded(linesAdded_), text(text_), line(line_), foldLevelNow(0), foldLevelPrev(0), annotationLinesAdded(0), token(0) {} DocModification(int modificationType_, const Action &act, int linesAdded_=0) : modificationType(modificationType_), position(act.position), length(act.lenData), linesAdded(linesAdded_), text(act.data), line(0), foldLevelNow(0), foldLevelPrev(0), annotationLinesAdded(0), token(0) {} }; /** * A class that wants to receive notifications from a Document must be derived from DocWatcher * and implement the notification methods. It can then be added to the watcher list with AddWatcher. */ class DocWatcher { public: virtual ~DocWatcher() {} virtual void NotifyModifyAttempt(Document *doc, void *userData) = 0; virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0; virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0; virtual void NotifyDeleted(Document *doc, void *userData) = 0; virtual void NotifyStyleNeeded(Document *doc, void *userData, int endPos) = 0; virtual void NotifyLexerChanged(Document *doc, void *userData) = 0; virtual void NotifyErrorOccurred(Document *doc, void *userData, int status) = 0; }; #ifdef SCI_NAMESPACE } #endif #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexEScript.cxx000444001750001750 2040312021352777 25162 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexESCRIPT.cxx ** Lexer for ESCRIPT **/ // Copyright 2003 by Patrizio Bekerle (patrizio@bekerle.com) #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_'); } static inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } static void ColouriseESCRIPTDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; WordList &keywords3 = *keywordlists[2]; // Do not leak onto next line /*if (initStyle == SCE_ESCRIPT_STRINGEOL) initStyle = SCE_ESCRIPT_DEFAULT;*/ StyleContext sc(startPos, length, initStyle, styler); bool caseSensitive = styler.GetPropertyInt("escript.case.sensitive", 0) != 0; for (; sc.More(); sc.Forward()) { /*if (sc.atLineStart && (sc.state == SCE_ESCRIPT_STRING)) { // Prevent SCE_ESCRIPT_STRINGEOL from leaking back to previous line sc.SetState(SCE_ESCRIPT_STRING); }*/ // Handle line continuation generically. if (sc.ch == '\\') { if (sc.chNext == '\n' || sc.chNext == '\r') { sc.Forward(); if (sc.ch == '\r' && sc.chNext == '\n') { sc.Forward(); } continue; } } // Determine if the current state should terminate. if (sc.state == SCE_ESCRIPT_OPERATOR || sc.state == SCE_ESCRIPT_BRACE) { sc.SetState(SCE_ESCRIPT_DEFAULT); } else if (sc.state == SCE_ESCRIPT_NUMBER) { if (!IsADigit(sc.ch) || sc.ch != '.') { sc.SetState(SCE_ESCRIPT_DEFAULT); } } else if (sc.state == SCE_ESCRIPT_IDENTIFIER) { if (!IsAWordChar(sc.ch) || (sc.ch == '.')) { char s[100]; if (caseSensitive) { sc.GetCurrent(s, sizeof(s)); } else { sc.GetCurrentLowered(s, sizeof(s)); } // sc.GetCurrentLowered(s, sizeof(s)); if (keywords.InList(s)) { sc.ChangeState(SCE_ESCRIPT_WORD); } else if (keywords2.InList(s)) { sc.ChangeState(SCE_ESCRIPT_WORD2); } else if (keywords3.InList(s)) { sc.ChangeState(SCE_ESCRIPT_WORD3); // sc.state = SCE_ESCRIPT_IDENTIFIER; } sc.SetState(SCE_ESCRIPT_DEFAULT); } } else if (sc.state == SCE_ESCRIPT_COMMENT) { if (sc.Match('*', '/')) { sc.Forward(); sc.ForwardSetState(SCE_ESCRIPT_DEFAULT); } } else if (sc.state == SCE_ESCRIPT_COMMENTDOC) { if (sc.Match('*', '/')) { sc.Forward(); sc.ForwardSetState(SCE_ESCRIPT_DEFAULT); } } else if (sc.state == SCE_ESCRIPT_COMMENTLINE) { if (sc.atLineEnd) { sc.SetState(SCE_ESCRIPT_DEFAULT); } } else if (sc.state == SCE_ESCRIPT_STRING) { if (sc.ch == '\\') { if (sc.chNext == '\"' || sc.chNext == '\\') { sc.Forward(); } } else if (sc.ch == '\"') { sc.ForwardSetState(SCE_ESCRIPT_DEFAULT); } } // Determine if a new state should be entered. if (sc.state == SCE_ESCRIPT_DEFAULT) { if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_ESCRIPT_NUMBER); } else if (IsAWordStart(sc.ch) || (sc.ch == '#')) { sc.SetState(SCE_ESCRIPT_IDENTIFIER); } else if (sc.Match('/', '*')) { sc.SetState(SCE_ESCRIPT_COMMENT); sc.Forward(); // Eat the * so it isn't used for the end of the comment } else if (sc.Match('/', '/')) { sc.SetState(SCE_ESCRIPT_COMMENTLINE); } else if (sc.ch == '\"') { sc.SetState(SCE_ESCRIPT_STRING); //} else if (isoperator(static_cast(sc.ch))) { } else if (sc.ch == '+' || sc.ch == '-' || sc.ch == '*' || sc.ch == '/' || sc.ch == '=' || sc.ch == '<' || sc.ch == '>' || sc.ch == '&' || sc.ch == '|' || sc.ch == '!' || sc.ch == '?' || sc.ch == ':') { sc.SetState(SCE_ESCRIPT_OPERATOR); } else if (sc.ch == '{' || sc.ch == '}') { sc.SetState(SCE_ESCRIPT_BRACE); } } } sc.Complete(); } static int classifyFoldPointESCRIPT(const char* s, const char* prevWord) { int lev = 0; if (strcmp(prevWord, "end") == 0) return lev; if ((strcmp(prevWord, "else") == 0 && strcmp(s, "if") == 0) || strcmp(s, "elseif") == 0) return -1; if (strcmp(s, "for") == 0 || strcmp(s, "foreach") == 0 || strcmp(s, "program") == 0 || strcmp(s, "function") == 0 || strcmp(s, "while") == 0 || strcmp(s, "case") == 0 || strcmp(s, "if") == 0 ) { lev = 1; } else if ( strcmp(s, "endfor") == 0 || strcmp(s, "endforeach") == 0 || strcmp(s, "endprogram") == 0 || strcmp(s, "endfunction") == 0 || strcmp(s, "endwhile") == 0 || strcmp(s, "endcase") == 0 || strcmp(s, "endif") == 0 ) { lev = -1; } return lev; } static bool IsStreamCommentStyle(int style) { return style == SCE_ESCRIPT_COMMENT || style == SCE_ESCRIPT_COMMENTDOC || style == SCE_ESCRIPT_COMMENTLINE; } static void FoldESCRIPTDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { //~ bool foldComment = styler.GetPropertyInt("fold.comment") != 0; // Do not know how to fold the comment at the moment. bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; bool foldComment = true; unsigned int endPos = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; int lastStart = 0; char prevWord[32] = ""; for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (foldComment && IsStreamCommentStyle(style)) { if (!IsStreamCommentStyle(stylePrev)) { levelCurrent++; } else if (!IsStreamCommentStyle(styleNext) && !atEOL) { // Comments don't end at end of line and the next character may be unstyled. levelCurrent--; } } if (foldComment && (style == SCE_ESCRIPT_COMMENTLINE)) { if ((ch == '/') && (chNext == '/')) { char chNext2 = styler.SafeGetCharAt(i + 2); if (chNext2 == '{') { levelCurrent++; } else if (chNext2 == '}') { levelCurrent--; } } } if (stylePrev == SCE_ESCRIPT_DEFAULT && style == SCE_ESCRIPT_WORD3) { // Store last word start point. lastStart = i; } if (style == SCE_ESCRIPT_WORD3) { if(iswordchar(ch) && !iswordchar(chNext)) { char s[32]; unsigned int j; for(j = 0; ( j < 31 ) && ( j < i-lastStart+1 ); j++) { s[j] = static_cast(tolower(styler[lastStart + j])); } s[j] = '\0'; levelCurrent += classifyFoldPointESCRIPT(s, prevWord); strcpy(prevWord, s); } } if (atEOL) { int lev = levelPrev; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if ((levelCurrent > levelPrev) && (visibleChars > 0)) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelPrev = levelCurrent; visibleChars = 0; strcpy(prevWord, ""); } if (!isspacechar(ch)) visibleChars++; } // Fill in the real level of the next line, keeping the current flags as they will be filled in later int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, levelPrev | flagsNext); } static const char * const ESCRIPTWordLists[] = { "Primary keywords and identifiers", "Intrinsic functions", "Extended and user defined functions", 0, }; LexerModule lmESCRIPT(SCLEX_ESCRIPT, ColouriseESCRIPTDoc, "escript", FoldESCRIPTDoc, ESCRIPTWordLists); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/ContractionState.cxx000444001750001750 1502712021352776 26431 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file ContractionState.cxx ** Manages visibility of lines for folding and wrapping. **/ // Copyright 1998-2007 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include "Platform.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" #include "ContractionState.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif ContractionState::ContractionState() : visible(0), expanded(0), heights(0), displayLines(0), linesInDocument(1) { //InsertLine(0); } ContractionState::~ContractionState() { Clear(); } void ContractionState::EnsureData() { if (OneToOne()) { visible = new RunStyles(); expanded = new RunStyles(); heights = new RunStyles(); displayLines = new Partitioning(4); InsertLines(0, linesInDocument); } } void ContractionState::Clear() { delete visible; visible = 0; delete expanded; expanded = 0; delete heights; heights = 0; delete displayLines; displayLines = 0; linesInDocument = 1; } int ContractionState::LinesInDoc() const { if (OneToOne()) { return linesInDocument; } else { return displayLines->Partitions() - 1; } } int ContractionState::LinesDisplayed() const { if (OneToOne()) { return linesInDocument; } else { return displayLines->PositionFromPartition(LinesInDoc()); } } int ContractionState::DisplayFromDoc(int lineDoc) const { if (OneToOne()) { return lineDoc; } else { if (lineDoc > displayLines->Partitions()) lineDoc = displayLines->Partitions(); return displayLines->PositionFromPartition(lineDoc); } } int ContractionState::DocFromDisplay(int lineDisplay) const { if (OneToOne()) { return lineDisplay; } else { if (lineDisplay <= 0) { return 0; } if (lineDisplay > LinesDisplayed()) { return displayLines->PartitionFromPosition(LinesDisplayed()); } int lineDoc = displayLines->PartitionFromPosition(lineDisplay); PLATFORM_ASSERT(GetVisible(lineDoc)); return lineDoc; } } void ContractionState::InsertLine(int lineDoc) { if (OneToOne()) { linesInDocument++; } else { visible->InsertSpace(lineDoc, 1); visible->SetValueAt(lineDoc, 1); expanded->InsertSpace(lineDoc, 1); expanded->SetValueAt(lineDoc, 1); heights->InsertSpace(lineDoc, 1); heights->SetValueAt(lineDoc, 1); int lineDisplay = DisplayFromDoc(lineDoc); displayLines->InsertPartition(lineDoc, lineDisplay); displayLines->InsertText(lineDoc, 1); } } void ContractionState::InsertLines(int lineDoc, int lineCount) { for (int l = 0; l < lineCount; l++) { InsertLine(lineDoc + l); } Check(); } void ContractionState::DeleteLine(int lineDoc) { if (OneToOne()) { linesInDocument--; } else { if (GetVisible(lineDoc)) { displayLines->InsertText(lineDoc, -heights->ValueAt(lineDoc)); } displayLines->RemovePartition(lineDoc); visible->DeleteRange(lineDoc, 1); expanded->DeleteRange(lineDoc, 1); heights->DeleteRange(lineDoc, 1); } } void ContractionState::DeleteLines(int lineDoc, int lineCount) { for (int l = 0; l < lineCount; l++) { DeleteLine(lineDoc); } Check(); } bool ContractionState::GetVisible(int lineDoc) const { if (OneToOne()) { return true; } else { if (lineDoc >= visible->Length()) return true; return visible->ValueAt(lineDoc) == 1; } } bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible_) { if (OneToOne() && visible_) { return false; } else { EnsureData(); int delta = 0; Check(); if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < LinesInDoc())) { for (int line = lineDocStart; line <= lineDocEnd; line++) { if (GetVisible(line) != visible_) { int difference = visible_ ? heights->ValueAt(line) : -heights->ValueAt(line); visible->SetValueAt(line, visible_ ? 1 : 0); displayLines->InsertText(line, difference); delta += difference; } } } else { return false; } Check(); return delta != 0; } } bool ContractionState::HiddenLines() const { if (OneToOne()) { return false; } else { return !visible->AllSameAs(1); } } bool ContractionState::GetExpanded(int lineDoc) const { if (OneToOne()) { return true; } else { Check(); return expanded->ValueAt(lineDoc) == 1; } } bool ContractionState::SetExpanded(int lineDoc, bool expanded_) { if (OneToOne() && expanded_) { return false; } else { EnsureData(); if (expanded_ != (expanded->ValueAt(lineDoc) == 1)) { expanded->SetValueAt(lineDoc, expanded_ ? 1 : 0); Check(); return true; } else { Check(); return false; } } } int ContractionState::ContractedNext(int lineDocStart) const { if (OneToOne()) { return -1; } else { Check(); if (!expanded->ValueAt(lineDocStart)) { return lineDocStart; } else { int lineDocNextChange = expanded->EndRun(lineDocStart); if (lineDocNextChange < LinesInDoc()) return lineDocNextChange; else return -1; } } } int ContractionState::GetHeight(int lineDoc) const { if (OneToOne()) { return 1; } else { return heights->ValueAt(lineDoc); } } // Set the number of display lines needed for this line. // Return true if this is a change. bool ContractionState::SetHeight(int lineDoc, int height) { if (OneToOne() && (height == 1)) { return false; } else if (lineDoc < LinesInDoc()) { EnsureData(); if (GetHeight(lineDoc) != height) { if (GetVisible(lineDoc)) { displayLines->InsertText(lineDoc, height - GetHeight(lineDoc)); } heights->SetValueAt(lineDoc, height); Check(); return true; } else { Check(); return false; } } else { return false; } } void ContractionState::ShowAll() { int lines = LinesInDoc(); Clear(); linesInDocument = lines; } // Debugging checks void ContractionState::Check() const { #ifdef CHECK_CORRECTNESS for (int vline = 0; vline < LinesDisplayed(); vline++) { const int lineDoc = DocFromDisplay(vline); PLATFORM_ASSERT(GetVisible(lineDoc)); } for (int lineDoc = 0; lineDoc < LinesInDoc(); lineDoc++) { const int displayThis = DisplayFromDoc(lineDoc); const int displayNext = DisplayFromDoc(lineDoc + 1); const int height = displayNext - displayThis; PLATFORM_ASSERT(height >= 0); if (GetVisible(lineDoc)) { PLATFORM_ASSERT(GetHeight(lineDoc) == height); } else { PLATFORM_ASSERT(0 == height); } } #endif } Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexAsn1.cxx000444001750001750 1253712021352777 24424 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexAsn1.cxx ** Lexer for ASN.1 **/ // Copyright 2004 by Herr Pfarrer rpfarrer yahoo de // Last Updated: 20/07/2004 // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif // Some char test functions static bool isAsn1Number(int ch) { return (ch >= '0' && ch <= '9'); } static bool isAsn1Letter(int ch) { return (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'); } static bool isAsn1Char(int ch) { return (ch == '-' ) || isAsn1Number(ch) || isAsn1Letter (ch); } // // Function determining the color of a given code portion // Based on a "state" // static void ColouriseAsn1Doc(unsigned int startPos, int length, int initStyle, WordList *keywordLists[], Accessor &styler) { // The keywords WordList &Keywords = *keywordLists[0]; WordList &Attributes = *keywordLists[1]; WordList &Descriptors = *keywordLists[2]; WordList &Types = *keywordLists[3]; // Parse the whole buffer character by character using StyleContext StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { // The state engine switch (sc.state) { case SCE_ASN1_DEFAULT: // Plain characters asn1_default: if (sc.ch == '-' && sc.chNext == '-') // A comment begins here sc.SetState(SCE_ASN1_COMMENT); else if (sc.ch == '"') // A string begins here sc.SetState(SCE_ASN1_STRING); else if (isAsn1Number (sc.ch)) // A number starts here (identifier should start with a letter in ASN.1) sc.SetState(SCE_ASN1_SCALAR); else if (isAsn1Char (sc.ch)) // An identifier starts here (identifier always start with a letter) sc.SetState(SCE_ASN1_IDENTIFIER); else if (sc.ch == ':') // A ::= operator starts here sc.SetState(SCE_ASN1_OPERATOR); break; case SCE_ASN1_COMMENT: // A comment if (sc.ch == '\r' || sc.ch == '\n') // A comment ends here sc.SetState(SCE_ASN1_DEFAULT); break; case SCE_ASN1_IDENTIFIER: // An identifier (keyword, attribute, descriptor or type) if (!isAsn1Char (sc.ch)) { // The end of identifier is here: we can look for it in lists by now and change its state char s[100]; sc.GetCurrent(s, sizeof(s)); if (Keywords.InList(s)) // It's a keyword, change its state sc.ChangeState(SCE_ASN1_KEYWORD); else if (Attributes.InList(s)) // It's an attribute, change its state sc.ChangeState(SCE_ASN1_ATTRIBUTE); else if (Descriptors.InList(s)) // It's a descriptor, change its state sc.ChangeState(SCE_ASN1_DESCRIPTOR); else if (Types.InList(s)) // It's a type, change its state sc.ChangeState(SCE_ASN1_TYPE); // Set to default now sc.SetState(SCE_ASN1_DEFAULT); } break; case SCE_ASN1_STRING: // A string delimited by "" if (sc.ch == '"') { // A string ends here sc.ForwardSetState(SCE_ASN1_DEFAULT); // To correctly manage a char sticking to the string quote goto asn1_default; } break; case SCE_ASN1_SCALAR: // A plain number if (!isAsn1Number (sc.ch)) // A number ends here sc.SetState(SCE_ASN1_DEFAULT); break; case SCE_ASN1_OPERATOR: // The affectation operator ::= and wath follows (eg: ::= { org 6 } OID or ::= 12 trap) if (sc.ch == '{') { // An OID definition starts here: enter the sub loop for (; sc.More(); sc.Forward()) { if (isAsn1Number (sc.ch) && (!isAsn1Char (sc.chPrev) || isAsn1Number (sc.chPrev))) // The OID number is highlighted sc.SetState(SCE_ASN1_OID); else if (isAsn1Char (sc.ch)) // The OID parent identifier is plain sc.SetState(SCE_ASN1_IDENTIFIER); else sc.SetState(SCE_ASN1_DEFAULT); if (sc.ch == '}') // Here ends the OID and the operator sub loop: go back to main loop break; } } else if (isAsn1Number (sc.ch)) { // A trap number definition starts here: enter the sub loop for (; sc.More(); sc.Forward()) { if (isAsn1Number (sc.ch)) // The trap number is highlighted sc.SetState(SCE_ASN1_OID); else { // The number ends here: go back to main loop sc.SetState(SCE_ASN1_DEFAULT); break; } } } else if (sc.ch != ':' && sc.ch != '=' && sc.ch != ' ') // The operator doesn't imply an OID definition nor a trap, back to main loop goto asn1_default; // To be sure to handle actually the state change break; } } sc.Complete(); } static void FoldAsn1Doc(unsigned int, int, int, WordList *[], Accessor &styler) { // No folding enabled, no reason to continue... if( styler.GetPropertyInt("fold") == 0 ) return; // No folding implemented: doesn't make sense for ASN.1 } static const char * const asn1WordLists[] = { "Keywords", "Attributes", "Descriptors", "Types", 0, }; LexerModule lmAns1(SCLEX_ASN1, ColouriseAsn1Doc, "asn1", FoldAsn1Doc, asn1WordLists); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexTAL.cxx000444001750001750 2640412021352777 24240 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexTAL.cxx ** Lexer for TAL ** Based on LexPascal.cxx ** Written by Laurent le Tynevez ** Updated by Simon Steele September 2002 ** Updated by Mathias Rauen May 2003 (Delphi adjustments) ** Updated by Rod Falck, Aug 2006 Converted to TAL **/ #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif inline bool isTALoperator(char ch) { return ch == '\'' || ch == '@' || ch == '#' || isoperator(ch); } inline bool isTALwordchar(char ch) { return ch == '$' || ch == '^' || iswordchar(ch); } inline bool isTALwordstart(char ch) { return ch == '$' || ch == '^' || iswordstart(ch); } static void getRange(unsigned int start, unsigned int end, Accessor &styler, char *s, unsigned int len) { unsigned int i = 0; while ((i < end - start + 1) && (i < len-1)) { s[i] = static_cast(tolower(styler[start + i])); i++; } s[i] = '\0'; } static bool IsStreamCommentStyle(int style) { return style == SCE_C_COMMENT || style == SCE_C_COMMENTDOC || style == SCE_C_COMMENTDOCKEYWORD || style == SCE_C_COMMENTDOCKEYWORDERROR; } static void ColourTo(Accessor &styler, unsigned int end, unsigned int attr, bool bInAsm) { if ((bInAsm) && (attr == SCE_C_OPERATOR || attr == SCE_C_NUMBER || attr == SCE_C_DEFAULT || attr == SCE_C_WORD || attr == SCE_C_IDENTIFIER)) { styler.ColourTo(end, SCE_C_REGEX); } else styler.ColourTo(end, attr); } // returns 1 if the item starts a class definition, and -1 if the word is "end", and 2 if the word is "asm" static int classifyWordTAL(unsigned int start, unsigned int end, /*WordList &keywords*/WordList *keywordlists[], Accessor &styler, bool bInAsm) { int ret = 0; WordList& keywords = *keywordlists[0]; WordList& builtins = *keywordlists[1]; WordList& nonreserved_keywords = *keywordlists[2]; char s[100]; getRange(start, end, styler, s, sizeof(s)); char chAttr = SCE_C_IDENTIFIER; if (isdigit(s[0]) || (s[0] == '.')) { chAttr = SCE_C_NUMBER; } else { if (keywords.InList(s)) { chAttr = SCE_C_WORD; if (strcmp(s, "asm") == 0) { ret = 2; } else if (strcmp(s, "end") == 0) { ret = -1; } } else if (s[0] == '$' || builtins.InList(s)) { chAttr = SCE_C_WORD2; } else if (nonreserved_keywords.InList(s)) { chAttr = SCE_C_UUID; } } ColourTo(styler, end, chAttr, (bInAsm && ret != -1)); return ret; } static int classifyFoldPointTAL(const char* s) { int lev = 0; if (!(isdigit(s[0]) || (s[0] == '.'))) { if (strcmp(s, "begin") == 0 || strcmp(s, "block") == 0) { lev=1; } else if (strcmp(s, "end") == 0) { lev=-1; } } return lev; } static void ColouriseTALDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { styler.StartAt(startPos); int state = initStyle; if (state == SCE_C_CHARACTER) // Does not leak onto next line state = SCE_C_DEFAULT; char chPrev = ' '; char chNext = styler[startPos]; unsigned int lengthDoc = startPos + length; bool bInClassDefinition; int currentLine = styler.GetLine(startPos); if (currentLine > 0) { styler.SetLineState(currentLine, styler.GetLineState(currentLine-1)); bInClassDefinition = (styler.GetLineState(currentLine) == 1); } else { styler.SetLineState(currentLine, 0); bInClassDefinition = false; } bool bInAsm = (state == SCE_C_REGEX); if (bInAsm) state = SCE_C_DEFAULT; styler.StartSegment(startPos); int visibleChars = 0; for (unsigned int i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); if ((ch == '\r' && chNext != '\n') || (ch == '\n')) { // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix) // Avoid triggering two times on Dos/Win // End of line if (state == SCE_C_CHARACTER) { ColourTo(styler, i, state, bInAsm); state = SCE_C_DEFAULT; } visibleChars = 0; currentLine++; styler.SetLineState(currentLine, (bInClassDefinition ? 1 : 0)); } if (styler.IsLeadByte(ch)) { chNext = styler.SafeGetCharAt(i + 2); chPrev = ' '; i += 1; continue; } if (state == SCE_C_DEFAULT) { if (isTALwordstart(ch)) { ColourTo(styler, i-1, state, bInAsm); state = SCE_C_IDENTIFIER; } else if (ch == '!' && chNext != '*') { ColourTo(styler, i-1, state, bInAsm); state = SCE_C_COMMENT; } else if (ch == '!' && chNext == '*') { ColourTo(styler, i-1, state, bInAsm); state = SCE_C_COMMENTDOC; } else if (ch == '-' && chNext == '-') { ColourTo(styler, i-1, state, bInAsm); state = SCE_C_COMMENTLINE; } else if (ch == '"') { ColourTo(styler, i-1, state, bInAsm); state = SCE_C_STRING; } else if (ch == '?' && visibleChars == 0) { ColourTo(styler, i-1, state, bInAsm); state = SCE_C_PREPROCESSOR; } else if (isTALoperator(ch)) { ColourTo(styler, i-1, state, bInAsm); ColourTo(styler, i, SCE_C_OPERATOR, bInAsm); } } else if (state == SCE_C_IDENTIFIER) { if (!isTALwordchar(ch)) { int lStateChange = classifyWordTAL(styler.GetStartSegment(), i - 1, keywordlists, styler, bInAsm); if(lStateChange == 1) { styler.SetLineState(currentLine, 1); bInClassDefinition = true; } else if(lStateChange == 2) { bInAsm = true; } else if(lStateChange == -1) { styler.SetLineState(currentLine, 0); bInClassDefinition = false; bInAsm = false; } state = SCE_C_DEFAULT; chNext = styler.SafeGetCharAt(i + 1); if (ch == '!' && chNext != '*') { state = SCE_C_COMMENT; } else if (ch == '!' && chNext == '*') { ColourTo(styler, i-1, state, bInAsm); state = SCE_C_COMMENTDOC; } else if (ch == '-' && chNext == '-') { state = SCE_C_COMMENTLINE; } else if (ch == '"') { state = SCE_C_STRING; } else if (isTALoperator(ch)) { ColourTo(styler, i, SCE_C_OPERATOR, bInAsm); } } } else { if (state == SCE_C_PREPROCESSOR) { if ((ch == '\r' || ch == '\n') && !(chPrev == '\\' || chPrev == '\r')) { ColourTo(styler, i-1, state, bInAsm); state = SCE_C_DEFAULT; } } else if (state == SCE_C_COMMENT) { if (ch == '!' || (ch == '\r' || ch == '\n') ) { ColourTo(styler, i, state, bInAsm); state = SCE_C_DEFAULT; } } else if (state == SCE_C_COMMENTDOC) { if (ch == '!' || (ch == '\r' || ch == '\n')) { if (((i > styler.GetStartSegment() + 2) || ( (initStyle == SCE_C_COMMENTDOC) && (styler.GetStartSegment() == static_cast(startPos))))) { ColourTo(styler, i, state, bInAsm); state = SCE_C_DEFAULT; } } } else if (state == SCE_C_COMMENTLINE) { if (ch == '\r' || ch == '\n') { ColourTo(styler, i-1, state, bInAsm); state = SCE_C_DEFAULT; } } else if (state == SCE_C_STRING) { if (ch == '"') { ColourTo(styler, i, state, bInAsm); state = SCE_C_DEFAULT; } } } if (!isspacechar(ch)) visibleChars++; chPrev = ch; } ColourTo(styler, lengthDoc - 1, state, bInAsm); } static void FoldTALDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; unsigned int endPos = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; bool was_end = false; bool section = false; int lastStart = 0; for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (stylePrev == SCE_C_DEFAULT && (style == SCE_C_WORD || style == SCE_C_UUID || style == SCE_C_PREPROCESSOR)) { // Store last word start point. lastStart = i; } if (stylePrev == SCE_C_WORD || style == SCE_C_UUID || stylePrev == SCE_C_PREPROCESSOR) { if(isTALwordchar(ch) && !isTALwordchar(chNext)) { char s[100]; getRange(lastStart, i, styler, s, sizeof(s)); if (stylePrev == SCE_C_PREPROCESSOR && strcmp(s, "?section") == 0) { section = true; levelCurrent = 1; levelPrev = 0; } else if (stylePrev == SCE_C_WORD || stylePrev == SCE_C_UUID) { if (strcmp(s, "block") == 0) { // block keyword is ignored immediately after end keyword if (!was_end) levelCurrent++; } else levelCurrent += classifyFoldPointTAL(s); if (strcmp(s, "end") == 0) { was_end = true; } else { was_end = false; } } } } if (foldComment && (style == SCE_C_COMMENTLINE)) { if ((ch == '/') && (chNext == '/')) { char chNext2 = styler.SafeGetCharAt(i + 2); if (chNext2 == '{') { levelCurrent++; } else if (chNext2 == '}') { levelCurrent--; } } } if (foldPreprocessor && (style == SCE_C_PREPROCESSOR)) { if (ch == '{' && chNext == '$') { unsigned int j=i+2; // skip {$ while ((j levelPrev || section) && (visibleChars > 0)) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelPrev = levelCurrent; visibleChars = 0; section = false; } if (!isspacechar(ch)) visibleChars++; } // Fill in the real level of the next line, keeping the current flags as they will be filled in later int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, levelPrev | flagsNext); } static const char * const TALWordListDesc[] = { "Keywords", "Builtins", 0 }; LexerModule lmTAL(SCLEX_TAL, ColouriseTALDoc, "TAL", FoldTALDoc, TALWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexFlagship.cxx000444001750001750 3051512021352776 25352 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexFlagShip.cxx ** Lexer for Harbour and FlagShip. ** (Syntactically compatible to other xBase dialects, like Clipper, dBase, Clip, FoxPro etc.) **/ // Copyright 2005 by Randy Butler // Copyright 2010 by Xavi (Harbour) // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif // Extended to accept accented characters static inline bool IsAWordChar(int ch) { return ch >= 0x80 || (isalnum(ch) || ch == '_'); } static void ColouriseFlagShipDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; WordList &keywords3 = *keywordlists[2]; WordList &keywords4 = *keywordlists[3]; WordList &keywords5 = *keywordlists[4]; // property lexer.flagship.styling.within.preprocessor // For Harbour code, determines whether all preprocessor code is styled in the preprocessor style (0) or only from the // initial # to the end of the command word(1, the default). It also determines how to present text, dump, and disabled code. bool stylingWithinPreprocessor = styler.GetPropertyInt("lexer.flagship.styling.within.preprocessor", 1) != 0; CharacterSet setDoxygen(CharacterSet::setAlpha, "$@\\&<>#{}[]"); int visibleChars = 0; int closeStringChar = 0; int styleBeforeDCKeyword = SCE_FS_DEFAULT; bool bEnableCode = initStyle < SCE_FS_DISABLEDCODE; StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { // Determine if the current state should terminate. switch (sc.state) { case SCE_FS_OPERATOR: case SCE_FS_OPERATOR_C: case SCE_FS_WORDOPERATOR: sc.SetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); break; case SCE_FS_IDENTIFIER: case SCE_FS_IDENTIFIER_C: if (!IsAWordChar(sc.ch)) { char s[64]; sc.GetCurrentLowered(s, sizeof(s)); if (keywords.InList(s)) { sc.ChangeState(bEnableCode ? SCE_FS_KEYWORD : SCE_FS_KEYWORD_C); } else if (keywords2.InList(s)) { sc.ChangeState(bEnableCode ? SCE_FS_KEYWORD2 : SCE_FS_KEYWORD2_C); } else if (bEnableCode && keywords3.InList(s)) { sc.ChangeState(SCE_FS_KEYWORD3); } else if (bEnableCode && keywords4.InList(s)) { sc.ChangeState(SCE_FS_KEYWORD4); }// Else, it is really an identifier... sc.SetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); } break; case SCE_FS_NUMBER: if (!IsAWordChar(sc.ch) && !(sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_FS_DEFAULT); } break; case SCE_FS_NUMBER_C: if (!IsAWordChar(sc.ch) && sc.ch != '.') { sc.SetState(SCE_FS_DEFAULT_C); } break; case SCE_FS_CONSTANT: if (!IsAWordChar(sc.ch)) { sc.SetState(SCE_FS_DEFAULT); } break; case SCE_FS_STRING: case SCE_FS_STRING_C: if (sc.ch == closeStringChar) { sc.ForwardSetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); } else if (sc.atLineEnd) { sc.ChangeState(bEnableCode ? SCE_FS_STRINGEOL : SCE_FS_STRINGEOL_C); } break; case SCE_FS_STRINGEOL: case SCE_FS_STRINGEOL_C: if (sc.atLineStart) { sc.SetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); } break; case SCE_FS_COMMENTDOC: case SCE_FS_COMMENTDOC_C: if (sc.Match('*', '/')) { sc.Forward(); sc.ForwardSetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support // Verify that we have the conditions to mark a comment-doc-keyword if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) { styleBeforeDCKeyword = bEnableCode ? SCE_FS_COMMENTDOC : SCE_FS_COMMENTDOC_C; sc.SetState(SCE_FS_COMMENTDOCKEYWORD); } } break; case SCE_FS_COMMENT: case SCE_FS_COMMENTLINE: if (sc.atLineStart) { sc.SetState(SCE_FS_DEFAULT); } break; case SCE_FS_COMMENTLINEDOC: case SCE_FS_COMMENTLINEDOC_C: if (sc.atLineStart) { sc.SetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support // Verify that we have the conditions to mark a comment-doc-keyword if ((IsASpace(sc.chPrev) || sc.chPrev == '/' || sc.chPrev == '!') && (!IsASpace(sc.chNext))) { styleBeforeDCKeyword = bEnableCode ? SCE_FS_COMMENTLINEDOC : SCE_FS_COMMENTLINEDOC_C; sc.SetState(SCE_FS_COMMENTDOCKEYWORD); } } break; case SCE_FS_COMMENTDOCKEYWORD: if ((styleBeforeDCKeyword == SCE_FS_COMMENTDOC || styleBeforeDCKeyword == SCE_FS_COMMENTDOC_C) && sc.Match('*', '/')) { sc.ChangeState(SCE_FS_COMMENTDOCKEYWORDERROR); sc.Forward(); sc.ForwardSetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); } else if (!setDoxygen.Contains(sc.ch)) { char s[64]; sc.GetCurrentLowered(s, sizeof(s)); if (!IsASpace(sc.ch) || !keywords5.InList(s + 1)) { sc.ChangeState(SCE_FS_COMMENTDOCKEYWORDERROR); } sc.SetState(styleBeforeDCKeyword); } break; case SCE_FS_PREPROCESSOR: case SCE_FS_PREPROCESSOR_C: if (sc.atLineEnd) { if (!(sc.chPrev == ';' || sc.GetRelative(-2) == ';')) { sc.SetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); } } else if (stylingWithinPreprocessor) { if (IsASpaceOrTab(sc.ch)) { sc.SetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); } } else if (sc.Match('/', '*') || sc.Match('/', '/') || sc.Match('&', '&')) { sc.SetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); } break; case SCE_FS_DISABLEDCODE: if (sc.ch == '#' && visibleChars == 0) { sc.SetState(bEnableCode ? SCE_FS_PREPROCESSOR : SCE_FS_PREPROCESSOR_C); do { // Skip whitespace between # and preprocessor word sc.Forward(); } while (IsASpaceOrTab(sc.ch) && sc.More()); if (sc.MatchIgnoreCase("pragma")) { sc.Forward(6); do { // Skip more whitespace until keyword sc.Forward(); } while (IsASpaceOrTab(sc.ch) && sc.More()); if (sc.MatchIgnoreCase("enddump") || sc.MatchIgnoreCase("__endtext")) { bEnableCode = true; sc.SetState(SCE_FS_DISABLEDCODE); sc.Forward(sc.ch == '_' ? 8 : 6); sc.ForwardSetState(SCE_FS_DEFAULT); } else { sc.ChangeState(SCE_FS_DISABLEDCODE); } } else { sc.ChangeState(SCE_FS_DISABLEDCODE); } } break; case SCE_FS_DATE: if (sc.ch == '}') { sc.ForwardSetState(SCE_FS_DEFAULT); } else if (sc.atLineEnd) { sc.ChangeState(SCE_FS_STRINGEOL); } } // Determine if a new state should be entered. if (sc.state == SCE_FS_DEFAULT || sc.state == SCE_FS_DEFAULT_C) { if (bEnableCode && (sc.MatchIgnoreCase(".and.") || sc.MatchIgnoreCase(".not."))) { sc.SetState(SCE_FS_WORDOPERATOR); sc.Forward(4); } else if (bEnableCode && sc.MatchIgnoreCase(".or.")) { sc.SetState(SCE_FS_WORDOPERATOR); sc.Forward(3); } else if (bEnableCode && (sc.MatchIgnoreCase(".t.") || sc.MatchIgnoreCase(".f.") || (!IsAWordChar(sc.GetRelative(3)) && sc.MatchIgnoreCase("nil")))) { sc.SetState(SCE_FS_CONSTANT); sc.Forward(2); } else if (sc.Match('/', '*')) { sc.SetState(bEnableCode ? SCE_FS_COMMENTDOC : SCE_FS_COMMENTDOC_C); sc.Forward(); } else if (bEnableCode && sc.Match('&', '&')) { sc.SetState(SCE_FS_COMMENTLINE); sc.Forward(); } else if (sc.Match('/', '/')) { sc.SetState(bEnableCode ? SCE_FS_COMMENTLINEDOC : SCE_FS_COMMENTLINEDOC_C); sc.Forward(); } else if (bEnableCode && sc.ch == '*' && visibleChars == 0) { sc.SetState(SCE_FS_COMMENT); } else if (sc.ch == '\"' || sc.ch == '\'') { sc.SetState(bEnableCode ? SCE_FS_STRING : SCE_FS_STRING_C); closeStringChar = sc.ch; } else if (closeStringChar == '>' && sc.ch == '<') { sc.SetState(bEnableCode ? SCE_FS_STRING : SCE_FS_STRING_C); } else if (sc.ch == '#' && visibleChars == 0) { sc.SetState(bEnableCode ? SCE_FS_PREPROCESSOR : SCE_FS_PREPROCESSOR_C); do { // Skip whitespace between # and preprocessor word sc.Forward(); } while (IsASpaceOrTab(sc.ch) && sc.More()); if (sc.atLineEnd) { sc.SetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); } else if (sc.MatchIgnoreCase("include")) { if (stylingWithinPreprocessor) { closeStringChar = '>'; } } else if (sc.MatchIgnoreCase("pragma")) { sc.Forward(6); do { // Skip more whitespace until keyword sc.Forward(); } while (IsASpaceOrTab(sc.ch) && sc.More()); if (sc.MatchIgnoreCase("begindump") || sc.MatchIgnoreCase("__cstream")) { bEnableCode = false; if (stylingWithinPreprocessor) { sc.SetState(SCE_FS_DISABLEDCODE); sc.Forward(8); sc.ForwardSetState(SCE_FS_DEFAULT_C); } else { sc.SetState(SCE_FS_DISABLEDCODE); } } else if (sc.MatchIgnoreCase("enddump") || sc.MatchIgnoreCase("__endtext")) { bEnableCode = true; sc.SetState(SCE_FS_DISABLEDCODE); sc.Forward(sc.ch == '_' ? 8 : 6); sc.ForwardSetState(SCE_FS_DEFAULT); } } } else if (bEnableCode && sc.ch == '{') { int p = 0; int chSeek; unsigned int endPos(startPos + length); do { // Skip whitespace chSeek = sc.GetRelative(++p); } while (IsASpaceOrTab(chSeek) && (sc.currentPos + p < endPos)); if (chSeek == '^') { sc.SetState(SCE_FS_DATE); } else { sc.SetState(SCE_FS_OPERATOR); } } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(bEnableCode ? SCE_FS_NUMBER : SCE_FS_NUMBER_C); } else if (IsAWordChar(sc.ch)) { sc.SetState(bEnableCode ? SCE_FS_IDENTIFIER : SCE_FS_IDENTIFIER_C); } else if (isoperator(static_cast(sc.ch)) || (bEnableCode && sc.ch == '@')) { sc.SetState(bEnableCode ? SCE_FS_OPERATOR : SCE_FS_OPERATOR_C); } } if (sc.atLineEnd) { visibleChars = 0; closeStringChar = 0; } if (!IsASpace(sc.ch)) { visibleChars++; } } sc.Complete(); } static void FoldFlagShipDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { int endPos = startPos + length; // Backtrack to previous line in case need to fix its fold status int lineCurrent = styler.GetLine(startPos); if (startPos > 0 && lineCurrent > 0) { lineCurrent--; startPos = styler.LineStart(lineCurrent); } int spaceFlags = 0; int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags); char chNext = styler[startPos]; for (int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == endPos-1)) { int lev = indentCurrent; int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags); if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) { if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) { lev |= SC_FOLDLEVELHEADERFLAG; } else if (indentNext & SC_FOLDLEVELWHITEFLAG) { int spaceFlags2 = 0; int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2); if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) { lev |= SC_FOLDLEVELHEADERFLAG; } } } indentCurrent = indentNext; styler.SetLevel(lineCurrent, lev); lineCurrent++; } } } static const char * const FSWordListDesc[] = { "Keywords Commands", "Std Library Functions", "Procedure, return, exit", "Class (oop)", "Doxygen keywords", 0 }; LexerModule lmFlagShip(SCLEX_FLAGSHIP, ColouriseFlagShipDoc, "flagship", FoldFlagShipDoc, FSWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/Editor.cxx000444001750001750 110415312021352776 24433 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file Editor.cxx ** Main code for the edit control. **/ // Copyright 1998-2011 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include #include #include #include #include "Platform.h" #include "ILexer.h" #include "Scintilla.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" #include "ContractionState.h" #include "CellBuffer.h" #include "KeyMap.h" #include "Indicator.h" #include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" #include "CharClassify.h" #include "Decoration.h" #include "Document.h" #include "Selection.h" #include "PositionCache.h" #include "Editor.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif /* return whether this modification represents an operation that may reasonably be deferred (not done now OR [possibly] at all) */ static bool CanDeferToLastStep(const DocModification &mh) { if (mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) return true; // CAN skip if (!(mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO))) return false; // MUST do if (mh.modificationType & SC_MULTISTEPUNDOREDO) return true; // CAN skip return false; // PRESUMABLY must do } static bool CanEliminate(const DocModification &mh) { return (mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) != 0; } /* return whether this modification represents the FINAL step in a [possibly lengthy] multi-step Undo/Redo sequence */ static bool IsLastStep(const DocModification &mh) { return (mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO)) != 0 && (mh.modificationType & SC_MULTISTEPUNDOREDO) != 0 && (mh.modificationType & SC_LASTSTEPINUNDOREDO) != 0 && (mh.modificationType & SC_MULTILINEUNDOREDO) != 0; } Caret::Caret() : active(false), on(false), period(500) {} Timer::Timer() : ticking(false), ticksToWait(0), tickerID(0) {} Idler::Idler() : state(false), idlerID(0) {} static inline bool IsControlCharacter(int ch) { // iscntrl returns true for lots of chars > 127 which are displayable return ch >= 0 && ch < ' '; } static inline bool IsAllSpacesOrTabs(char *s, unsigned int len) { for (unsigned int i = 0; i < len; i++) { // This is safe because IsSpaceOrTab() will return false for null terminators if (!IsSpaceOrTab(s[i])) return false; } return true; } Editor::Editor() { ctrlID = 0; stylesValid = false; technology = SC_TECHNOLOGY_DEFAULT; printMagnification = 0; printColourMode = SC_PRINT_NORMAL; printWrapState = eWrapWord; cursorMode = SC_CURSORNORMAL; controlCharSymbol = 0; /* Draw the control characters */ hasFocus = false; hideSelection = false; inOverstrike = false; errorStatus = 0; mouseDownCaptures = true; bufferedDraw = true; twoPhaseDraw = true; lastClickTime = 0; dwellDelay = SC_TIME_FOREVER; ticksToDwell = SC_TIME_FOREVER; dwelling = false; ptMouseLast.x = 0; ptMouseLast.y = 0; inDragDrop = ddNone; dropWentOutside = false; posDrag = SelectionPosition(invalidPosition); posDrop = SelectionPosition(invalidPosition); hotSpotClickPos = INVALID_POSITION; selectionType = selChar; lastXChosen = 0; lineAnchorPos = 0; originalAnchorPos = 0; wordSelectAnchorStartPos = 0; wordSelectAnchorEndPos = 0; wordSelectInitialCaretPos = -1; primarySelection = true; caretXPolicy = CARET_SLOP | CARET_EVEN; caretXSlop = 50; caretYPolicy = CARET_EVEN; caretYSlop = 0; visiblePolicy = 0; visibleSlop = 0; searchAnchor = 0; xOffset = 0; xCaretMargin = 50; horizontalScrollBarVisible = true; scrollWidth = 2000; trackLineWidth = false; lineWidthMaxSeen = 0; verticalScrollBarVisible = true; endAtLastLine = true; caretSticky = SC_CARETSTICKY_OFF; marginOptions = SC_MARGINOPTION_NONE; multipleSelection = false; additionalSelectionTyping = false; multiPasteMode = SC_MULTIPASTE_ONCE; additionalCaretsBlink = true; additionalCaretsVisible = true; virtualSpaceOptions = SCVS_NONE; pixmapLine = 0; pixmapSelMargin = 0; pixmapSelPattern = 0; pixmapIndentGuide = 0; pixmapIndentGuideHighlight = 0; targetStart = 0; targetEnd = 0; searchFlags = 0; topLine = 0; posTopLine = 0; lengthForEncode = -1; needUpdateUI = 0; ContainerNeedsUpdate(SC_UPDATE_CONTENT); braces[0] = invalidPosition; braces[1] = invalidPosition; bracesMatchStyle = STYLE_BRACEBAD; highlightGuideColumn = 0; theEdge = 0; paintState = notPainting; willRedrawAll = false; modEventMask = SC_MODEVENTMASKALL; pdoc = new Document(); pdoc->AddRef(); pdoc->AddWatcher(this, 0); recordingMacro = false; foldFlags = 0; wrapState = eWrapNone; wrapWidth = LineLayout::wrapWidthInfinite; wrapStart = wrapLineLarge; wrapEnd = wrapLineLarge; wrapVisualFlags = 0; wrapVisualFlagsLocation = 0; wrapVisualStartIndent = 0; wrapIndentMode = SC_WRAPINDENT_FIXED; wrapAddIndent = 0; convertPastes = true; hsStart = -1; hsEnd = -1; llc.SetLevel(LineLayoutCache::llcCaret); posCache.SetSize(0x400); } Editor::~Editor() { pdoc->RemoveWatcher(this, 0); pdoc->Release(); pdoc = 0; DropGraphics(true); } void Editor::Finalise() { SetIdle(false); CancelModes(); } void Editor::DropGraphics(bool freeObjects) { if (freeObjects) { delete pixmapLine; pixmapLine = 0; delete pixmapSelMargin; pixmapSelMargin = 0; delete pixmapSelPattern; pixmapSelPattern = 0; delete pixmapIndentGuide; pixmapIndentGuide = 0; delete pixmapIndentGuideHighlight; pixmapIndentGuideHighlight = 0; } else { if (pixmapLine) pixmapLine->Release(); if (pixmapSelMargin) pixmapSelMargin->Release(); if (pixmapSelPattern) pixmapSelPattern->Release(); if (pixmapIndentGuide) pixmapIndentGuide->Release(); if (pixmapIndentGuideHighlight) pixmapIndentGuideHighlight->Release(); } } void Editor::AllocateGraphics() { if (!pixmapLine) pixmapLine = Surface::Allocate(technology); if (!pixmapSelMargin) pixmapSelMargin = Surface::Allocate(technology); if (!pixmapSelPattern) pixmapSelPattern = Surface::Allocate(technology); if (!pixmapIndentGuide) pixmapIndentGuide = Surface::Allocate(technology); if (!pixmapIndentGuideHighlight) pixmapIndentGuideHighlight = Surface::Allocate(technology); } void Editor::InvalidateStyleData() { stylesValid = false; vs.technology = technology; DropGraphics(false); AllocateGraphics(); llc.Invalidate(LineLayout::llInvalid); posCache.Clear(); } void Editor::InvalidateStyleRedraw() { NeedWrapping(); InvalidateStyleData(); Redraw(); } void Editor::RefreshStyleData() { if (!stylesValid) { stylesValid = true; AutoSurface surface(this); if (surface) { vs.Refresh(*surface); } if (wrapIndentMode == SC_WRAPINDENT_INDENT) { wrapAddIndent = pdoc->IndentSize() * vs.spaceWidth; } else if (wrapIndentMode == SC_WRAPINDENT_SAME) { wrapAddIndent = 0; } else { //SC_WRAPINDENT_FIXED wrapAddIndent = wrapVisualStartIndent * vs.aveCharWidth; if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (wrapAddIndent <= 0)) wrapAddIndent = vs.aveCharWidth; // must indent to show start visual } SetScrollBars(); SetRectangularRange(); } } PRectangle Editor::GetClientRectangle() { return wMain.GetClientPosition(); } PRectangle Editor::GetTextRectangle() { PRectangle rc = GetClientRectangle(); rc.left += vs.fixedColumnWidth; rc.right -= vs.rightMarginWidth; return rc; } int Editor::LinesOnScreen() { PRectangle rcClient = GetClientRectangle(); int htClient = rcClient.bottom - rcClient.top; //Platform::DebugPrintf("lines on screen = %d\n", htClient / lineHeight + 1); return htClient / vs.lineHeight; } int Editor::LinesToScroll() { int retVal = LinesOnScreen() - 1; if (retVal < 1) return 1; else return retVal; } int Editor::MaxScrollPos() { //Platform::DebugPrintf("Lines %d screen = %d maxScroll = %d\n", //LinesTotal(), LinesOnScreen(), LinesTotal() - LinesOnScreen() + 1); int retVal = cs.LinesDisplayed(); if (endAtLastLine) { retVal -= LinesOnScreen(); } else { retVal--; } if (retVal < 0) { return 0; } else { return retVal; } } const char *ControlCharacterString(unsigned char ch) { const char *reps[] = { "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US" }; if (ch < (sizeof(reps) / sizeof(reps[0]))) { return reps[ch]; } else { return "BAD"; } } /** * Convenience class to ensure LineLayout objects are always disposed. */ class AutoLineLayout { LineLayoutCache &llc; LineLayout *ll; AutoLineLayout &operator=(const AutoLineLayout &); public: AutoLineLayout(LineLayoutCache &llc_, LineLayout *ll_) : llc(llc_), ll(ll_) {} ~AutoLineLayout() { llc.Dispose(ll); ll = 0; } LineLayout *operator->() const { return ll; } operator LineLayout *() const { return ll; } void Set(LineLayout *ll_) { llc.Dispose(ll); ll = ll_; } }; SelectionPosition Editor::ClampPositionIntoDocument(SelectionPosition sp) const { if (sp.Position() < 0) { return SelectionPosition(0); } else if (sp.Position() > pdoc->Length()) { return SelectionPosition(pdoc->Length()); } else { // If not at end of line then set offset to 0 if (!pdoc->IsLineEndPosition(sp.Position())) sp.SetVirtualSpace(0); return sp; } } Point Editor::LocationFromPosition(SelectionPosition pos) { Point pt; RefreshStyleData(); if (pos.Position() == INVALID_POSITION) return pt; int line = pdoc->LineFromPosition(pos.Position()); int lineVisible = cs.DisplayFromDoc(line); //Platform::DebugPrintf("line=%d\n", line); AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(line)); if (surface && ll) { // -1 because of adding in for visible lines in following loop. pt.y = (lineVisible - topLine - 1) * vs.lineHeight; pt.x = 0; unsigned int posLineStart = pdoc->LineStart(line); LayoutLine(line, surface, vs, ll, wrapWidth); int posInLine = pos.Position() - posLineStart; // In case of very long line put x at arbitrary large position if (posInLine > ll->maxLineLength) { pt.x = ll->positions[ll->maxLineLength] - ll->positions[ll->LineStart(ll->lines)]; } for (int subLine = 0; subLine < ll->lines; subLine++) { if ((posInLine >= ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine + 1))) { pt.x = ll->positions[posInLine] - ll->positions[ll->LineStart(subLine)]; if (ll->wrapIndent != 0) { int lineStart = ll->LineStart(subLine); if (lineStart != 0) // Wrapped pt.x += ll->wrapIndent; } } if (posInLine >= ll->LineStart(subLine)) { pt.y += vs.lineHeight; } } pt.x += vs.fixedColumnWidth - xOffset; } pt.x += pos.VirtualSpace() * vs.styles[ll->EndLineStyle()].spaceWidth; return pt; } Point Editor::LocationFromPosition(int pos) { return LocationFromPosition(SelectionPosition(pos)); } int Editor::XFromPosition(int pos) { Point pt = LocationFromPosition(pos); return pt.x - vs.fixedColumnWidth + xOffset; } int Editor::XFromPosition(SelectionPosition sp) { Point pt = LocationFromPosition(sp); return pt.x - vs.fixedColumnWidth + xOffset; } int Editor::LineFromLocation(Point pt) { return cs.DocFromDisplay(pt.y / vs.lineHeight + topLine); } void Editor::SetTopLine(int topLineNew) { if (topLine != topLineNew) { topLine = topLineNew; ContainerNeedsUpdate(SC_UPDATE_V_SCROLL); } posTopLine = pdoc->LineStart(cs.DocFromDisplay(topLine)); } SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid, bool charPosition, bool virtualSpace) { RefreshStyleData(); if (canReturnInvalid) { PRectangle rcClient = GetTextRectangle(); if (!rcClient.Contains(pt)) return SelectionPosition(INVALID_POSITION); if (pt.x < vs.fixedColumnWidth) return SelectionPosition(INVALID_POSITION); if (pt.y < 0) return SelectionPosition(INVALID_POSITION); } pt.x = pt.x - vs.fixedColumnWidth + xOffset; int visibleLine = pt.y / vs.lineHeight + topLine; if (pt.y < 0) { // Division rounds towards 0 visibleLine = (static_cast(pt.y) - (vs.lineHeight - 1)) / vs.lineHeight + topLine; } if (!canReturnInvalid && (visibleLine < 0)) visibleLine = 0; int lineDoc = cs.DocFromDisplay(visibleLine); if (canReturnInvalid && (lineDoc < 0)) return SelectionPosition(INVALID_POSITION); if (lineDoc >= pdoc->LinesTotal()) return SelectionPosition(canReturnInvalid ? INVALID_POSITION : pdoc->Length()); unsigned int posLineStart = pdoc->LineStart(lineDoc); SelectionPosition retVal(canReturnInvalid ? INVALID_POSITION : static_cast(posLineStart)); AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc)); if (surface && ll) { LayoutLine(lineDoc, surface, vs, ll, wrapWidth); int lineStartSet = cs.DisplayFromDoc(lineDoc); int subLine = visibleLine - lineStartSet; if (subLine < ll->lines) { int lineStart = ll->LineStart(subLine); int lineEnd = ll->LineLastVisible(subLine); XYPOSITION subLineStart = ll->positions[lineStart]; if (ll->wrapIndent != 0) { if (lineStart != 0) // Wrapped pt.x -= ll->wrapIndent; } int i = ll->FindBefore(pt.x + subLineStart, lineStart, lineEnd); while (i < lineEnd) { if (charPosition) { if ((pt.x + subLineStart) < (ll->positions[i + 1])) { return SelectionPosition(pdoc->MovePositionOutsideChar(i + posLineStart, 1)); } } else { if ((pt.x + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) { return SelectionPosition(pdoc->MovePositionOutsideChar(i + posLineStart, 1)); } } i++; } if (virtualSpace) { const XYPOSITION spaceWidth = vs.styles[ll->EndLineStyle()].spaceWidth; int spaceOffset = (pt.x + subLineStart - ll->positions[lineEnd] + spaceWidth / 2) / spaceWidth; return SelectionPosition(lineEnd + posLineStart, spaceOffset); } else if (canReturnInvalid) { if (pt.x < (ll->positions[lineEnd] - subLineStart)) { return SelectionPosition(pdoc->MovePositionOutsideChar(lineEnd + posLineStart, 1)); } } else { return SelectionPosition(lineEnd + posLineStart); } } if (!canReturnInvalid) return SelectionPosition(ll->numCharsInLine + posLineStart); } return retVal; } int Editor::PositionFromLocation(Point pt, bool canReturnInvalid, bool charPosition) { return SPositionFromLocation(pt, canReturnInvalid, charPosition, false).Position(); } /** * Find the document position corresponding to an x coordinate on a particular document line. * Ensure is between whole characters when document is in multi-byte or UTF-8 mode. */ SelectionPosition Editor::SPositionFromLineX(int lineDoc, int x) { RefreshStyleData(); if (lineDoc >= pdoc->LinesTotal()) return SelectionPosition(pdoc->Length()); //Platform::DebugPrintf("Position of (%d,%d) line = %d top=%d\n", pt.x, pt.y, line, topLine); AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc)); int retVal = 0; if (surface && ll) { unsigned int posLineStart = pdoc->LineStart(lineDoc); LayoutLine(lineDoc, surface, vs, ll, wrapWidth); int subLine = 0; int lineStart = ll->LineStart(subLine); int lineEnd = ll->LineLastVisible(subLine); XYPOSITION subLineStart = ll->positions[lineStart]; XYPOSITION newX = x; if (ll->wrapIndent != 0) { if (lineStart != 0) // Wrapped newX -= ll->wrapIndent; } int i = ll->FindBefore(newX + subLineStart, lineStart, lineEnd); while (i < lineEnd) { if ((newX + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) { retVal = pdoc->MovePositionOutsideChar(i + posLineStart, 1); return SelectionPosition(retVal); } i++; } const XYPOSITION spaceWidth = vs.styles[ll->EndLineStyle()].spaceWidth; int spaceOffset = (newX + subLineStart - ll->positions[lineEnd] + spaceWidth / 2) / spaceWidth; return SelectionPosition(lineEnd + posLineStart, spaceOffset); } return SelectionPosition(retVal); } int Editor::PositionFromLineX(int lineDoc, int x) { return SPositionFromLineX(lineDoc, x).Position(); } /** * If painting then abandon the painting because a wider redraw is needed. * @return true if calling code should stop drawing. */ bool Editor::AbandonPaint() { if ((paintState == painting) && !paintingAllText) { paintState = paintAbandoned; } return paintState == paintAbandoned; } void Editor::RedrawRect(PRectangle rc) { //Platform::DebugPrintf("Redraw %0d,%0d - %0d,%0d\n", rc.left, rc.top, rc.right, rc.bottom); // Clip the redraw rectangle into the client area PRectangle rcClient = GetClientRectangle(); if (rc.top < rcClient.top) rc.top = rcClient.top; if (rc.bottom > rcClient.bottom) rc.bottom = rcClient.bottom; if (rc.left < rcClient.left) rc.left = rcClient.left; if (rc.right > rcClient.right) rc.right = rcClient.right; if ((rc.bottom > rc.top) && (rc.right > rc.left)) { wMain.InvalidateRectangle(rc); } } void Editor::Redraw() { //Platform::DebugPrintf("Redraw all\n"); PRectangle rcClient = GetClientRectangle(); wMain.InvalidateRectangle(rcClient); //wMain.InvalidateAll(); } void Editor::RedrawSelMargin(int line, bool allAfter) { if (!AbandonPaint()) { if (vs.maskInLine) { Redraw(); } else { PRectangle rcSelMargin = GetClientRectangle(); rcSelMargin.right = vs.fixedColumnWidth; if (line != -1) { int position = pdoc->LineStart(line); PRectangle rcLine = RectangleFromRange(position, position); // Inflate line rectangle if there are image markers with height larger than line height if (vs.largestMarkerHeight > vs.lineHeight) { int delta = (vs.largestMarkerHeight - vs.lineHeight + 1) / 2; rcLine.top -= delta; rcLine.bottom += delta; if (rcLine.top < rcSelMargin.top) rcLine.top = rcSelMargin.top; if (rcLine.bottom > rcSelMargin.bottom) rcLine.bottom = rcSelMargin.bottom; } rcSelMargin.top = rcLine.top; if (!allAfter) rcSelMargin.bottom = rcLine.bottom; } wMain.InvalidateRectangle(rcSelMargin); } } } PRectangle Editor::RectangleFromRange(int start, int end) { int minPos = start; if (minPos > end) minPos = end; int maxPos = start; if (maxPos < end) maxPos = end; int minLine = cs.DisplayFromDoc(pdoc->LineFromPosition(minPos)); int lineDocMax = pdoc->LineFromPosition(maxPos); int maxLine = cs.DisplayFromDoc(lineDocMax) + cs.GetHeight(lineDocMax) - 1; PRectangle rcClient = GetTextRectangle(); PRectangle rc; rc.left = vs.fixedColumnWidth; rc.top = (minLine - topLine) * vs.lineHeight; if (rc.top < 0) rc.top = 0; rc.right = rcClient.right; rc.bottom = (maxLine - topLine + 1) * vs.lineHeight; // Ensure PRectangle is within 16 bit space rc.top = Platform::Clamp(rc.top, -32000, 32000); rc.bottom = Platform::Clamp(rc.bottom, -32000, 32000); return rc; } void Editor::InvalidateRange(int start, int end) { RedrawRect(RectangleFromRange(start, end)); } int Editor::CurrentPosition() { return sel.MainCaret(); } bool Editor::SelectionEmpty() { return sel.Empty(); } SelectionPosition Editor::SelectionStart() { return sel.RangeMain().Start(); } SelectionPosition Editor::SelectionEnd() { return sel.RangeMain().End(); } void Editor::SetRectangularRange() { if (sel.IsRectangular()) { int xAnchor = XFromPosition(sel.Rectangular().anchor); int xCaret = XFromPosition(sel.Rectangular().caret); if (sel.selType == Selection::selThin) { xCaret = xAnchor; } int lineAnchorRect = pdoc->LineFromPosition(sel.Rectangular().anchor.Position()); int lineCaret = pdoc->LineFromPosition(sel.Rectangular().caret.Position()); int increment = (lineCaret > lineAnchorRect) ? 1 : -1; for (int line=lineAnchorRect; line != lineCaret+increment; line += increment) { SelectionRange range(SPositionFromLineX(line, xCaret), SPositionFromLineX(line, xAnchor)); if ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) == 0) range.ClearVirtualSpace(); if (line == lineAnchorRect) sel.SetSelection(range); else sel.AddSelectionWithoutTrim(range); } } } void Editor::ThinRectangularRange() { if (sel.IsRectangular()) { sel.selType = Selection::selThin; if (sel.Rectangular().caret < sel.Rectangular().anchor) { sel.Rectangular() = SelectionRange(sel.Range(sel.Count()-1).caret, sel.Range(0).anchor); } else { sel.Rectangular() = SelectionRange(sel.Range(sel.Count()-1).anchor, sel.Range(0).caret); } SetRectangularRange(); } } void Editor::InvalidateSelection(SelectionRange newMain, bool invalidateWholeSelection) { if (sel.Count() > 1 || !(sel.RangeMain().anchor == newMain.anchor) || sel.IsRectangular()) { invalidateWholeSelection = true; } int firstAffected = Platform::Minimum(sel.RangeMain().Start().Position(), newMain.Start().Position()); // +1 for lastAffected ensures caret repainted int lastAffected = Platform::Maximum(newMain.caret.Position()+1, newMain.anchor.Position()); lastAffected = Platform::Maximum(lastAffected, sel.RangeMain().End().Position()); if (invalidateWholeSelection) { for (size_t r=0; rLineFromPosition(currentPos_.Position()); /* For Line selection - ensure the anchor and caret are always at the beginning and end of the region lines. */ if (sel.selType == Selection::selLines) { if (currentPos_ > anchor_) { anchor_ = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(anchor_.Position()))); currentPos_ = SelectionPosition(pdoc->LineEnd(pdoc->LineFromPosition(currentPos_.Position()))); } else { currentPos_ = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(currentPos_.Position()))); anchor_ = SelectionPosition(pdoc->LineEnd(pdoc->LineFromPosition(anchor_.Position()))); } } SelectionRange rangeNew(currentPos_, anchor_); if (sel.Count() > 1 || !(sel.RangeMain() == rangeNew)) { InvalidateSelection(rangeNew); } sel.RangeMain() = rangeNew; SetRectangularRange(); ClaimSelection(); if (highlightDelimiter.NeedsDrawing(currentLine)) { RedrawSelMargin(); } } void Editor::SetSelection(int currentPos_, int anchor_) { SetSelection(SelectionPosition(currentPos_), SelectionPosition(anchor_)); } // Just move the caret on the main selection void Editor::SetSelection(SelectionPosition currentPos_) { currentPos_ = ClampPositionIntoDocument(currentPos_); int currentLine = pdoc->LineFromPosition(currentPos_.Position()); if (sel.Count() > 1 || !(sel.RangeMain().caret == currentPos_)) { InvalidateSelection(SelectionRange(currentPos_)); } if (sel.IsRectangular()) { sel.Rectangular() = SelectionRange(SelectionPosition(currentPos_), sel.Rectangular().anchor); SetRectangularRange(); } else { sel.RangeMain() = SelectionRange(SelectionPosition(currentPos_), sel.RangeMain().anchor); } ClaimSelection(); if (highlightDelimiter.NeedsDrawing(currentLine)) { RedrawSelMargin(); } } void Editor::SetSelection(int currentPos_) { SetSelection(SelectionPosition(currentPos_)); } void Editor::SetEmptySelection(SelectionPosition currentPos_) { int currentLine = pdoc->LineFromPosition(currentPos_.Position()); SelectionRange rangeNew(ClampPositionIntoDocument(currentPos_)); if (sel.Count() > 1 || !(sel.RangeMain() == rangeNew)) { InvalidateSelection(rangeNew); } sel.Clear(); sel.RangeMain() = rangeNew; SetRectangularRange(); ClaimSelection(); if (highlightDelimiter.NeedsDrawing(currentLine)) { RedrawSelMargin(); } } void Editor::SetEmptySelection(int currentPos_) { SetEmptySelection(SelectionPosition(currentPos_)); } bool Editor::RangeContainsProtected(int start, int end) const { if (vs.ProtectionActive()) { if (start > end) { int t = start; start = end; end = t; } int mask = pdoc->stylingBitsMask; for (int pos = start; pos < end; pos++) { if (vs.styles[pdoc->StyleAt(pos) & mask].IsProtected()) return true; } } return false; } bool Editor::SelectionContainsProtected() { for (size_t r=0; rMovePositionOutsideChar(pos.Position(), moveDir, checkLineEnd); if (posMoved != pos.Position()) pos.SetPosition(posMoved); if (vs.ProtectionActive()) { int mask = pdoc->stylingBitsMask; if (moveDir > 0) { if ((pos.Position() > 0) && vs.styles[pdoc->StyleAt(pos.Position() - 1) & mask].IsProtected()) { while ((pos.Position() < pdoc->Length()) && (vs.styles[pdoc->StyleAt(pos.Position()) & mask].IsProtected())) pos.Add(1); } } else if (moveDir < 0) { if (vs.styles[pdoc->StyleAt(pos.Position()) & mask].IsProtected()) { while ((pos.Position() > 0) && (vs.styles[pdoc->StyleAt(pos.Position() - 1) & mask].IsProtected())) pos.Add(-1); } } } return pos; } int Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, bool ensureVisible) { bool simpleCaret = (sel.Count() == 1) && sel.Empty(); SelectionPosition spCaret = sel.Last(); int delta = newPos.Position() - sel.MainCaret(); newPos = ClampPositionIntoDocument(newPos); newPos = MovePositionOutsideChar(newPos, delta); if (!multipleSelection && sel.IsRectangular() && (selt == Selection::selStream)) { // Can't turn into multiple selection so clear additional selections InvalidateSelection(SelectionRange(newPos), true); SelectionRange rangeMain = sel.RangeMain(); sel.SetSelection(rangeMain); } if (!sel.IsRectangular() && (selt == Selection::selRectangle)) { // Switching to rectangular SelectionRange rangeMain = sel.RangeMain(); sel.Clear(); sel.Rectangular() = rangeMain; } if (selt != Selection::noSel) { sel.selType = selt; } if (selt != Selection::noSel || sel.MoveExtends()) { SetSelection(newPos); } else { SetEmptySelection(newPos); } ShowCaretAtCurrentPosition(); int currentLine = pdoc->LineFromPosition(newPos.Position()); if (ensureVisible) { // In case in need of wrapping to ensure DisplayFromDoc works. if (currentLine >= wrapStart) WrapLines(true, -1); XYScrollPosition newXY = XYScrollToMakeVisible(true, true, true); if (simpleCaret && (newXY.xOffset == xOffset)) { // simple vertical scroll then invalidate ScrollTo(newXY.topLine); InvalidateSelection(SelectionRange(spCaret), true); } else { SetXYScroll(newXY); } } if (highlightDelimiter.NeedsDrawing(currentLine)) { RedrawSelMargin(); } return 0; } int Editor::MovePositionTo(int newPos, Selection::selTypes selt, bool ensureVisible) { return MovePositionTo(SelectionPosition(newPos), selt, ensureVisible); } SelectionPosition Editor::MovePositionSoVisible(SelectionPosition pos, int moveDir) { pos = ClampPositionIntoDocument(pos); pos = MovePositionOutsideChar(pos, moveDir); int lineDoc = pdoc->LineFromPosition(pos.Position()); if (cs.GetVisible(lineDoc)) { return pos; } else { int lineDisplay = cs.DisplayFromDoc(lineDoc); if (moveDir > 0) { // lineDisplay is already line before fold as lines in fold use display line of line after fold lineDisplay = Platform::Clamp(lineDisplay, 0, cs.LinesDisplayed()); return SelectionPosition(pdoc->LineStart(cs.DocFromDisplay(lineDisplay))); } else { lineDisplay = Platform::Clamp(lineDisplay - 1, 0, cs.LinesDisplayed()); return SelectionPosition(pdoc->LineEnd(cs.DocFromDisplay(lineDisplay))); } } } SelectionPosition Editor::MovePositionSoVisible(int pos, int moveDir) { return MovePositionSoVisible(SelectionPosition(pos), moveDir); } Point Editor::PointMainCaret() { return LocationFromPosition(sel.Range(sel.Main()).caret); } /** * Choose the x position that the caret will try to stick to * as it moves up and down. */ void Editor::SetLastXChosen() { Point pt = PointMainCaret(); lastXChosen = pt.x + xOffset; } void Editor::ScrollTo(int line, bool moveThumb) { int topLineNew = Platform::Clamp(line, 0, MaxScrollPos()); if (topLineNew != topLine) { // Try to optimise small scrolls #ifndef UNDER_CE int linesToMove = topLine - topLineNew; bool performBlit = (abs(linesToMove) <= 10) && (paintState == notPainting); willRedrawAll = !performBlit; #endif SetTopLine(topLineNew); // Optimize by styling the view as this will invalidate any needed area // which could abort the initial paint if discovered later. StyleToPositionInView(PositionAfterArea(GetClientRectangle())); #ifndef UNDER_CE // Perform redraw rather than scroll if many lines would be redrawn anyway. if (performBlit) { ScrollText(linesToMove); } else { Redraw(); } willRedrawAll = false; #else Redraw(); #endif if (moveThumb) { SetVerticalScrollPos(); } } } void Editor::ScrollText(int /* linesToMove */) { //Platform::DebugPrintf("Editor::ScrollText %d\n", linesToMove); Redraw(); } void Editor::HorizontalScrollTo(int xPos) { //Platform::DebugPrintf("HorizontalScroll %d\n", xPos); if (xPos < 0) xPos = 0; if ((wrapState == eWrapNone) && (xOffset != xPos)) { xOffset = xPos; ContainerNeedsUpdate(SC_UPDATE_H_SCROLL); SetHorizontalScrollPos(); RedrawRect(GetClientRectangle()); } } void Editor::VerticalCentreCaret() { int lineDoc = pdoc->LineFromPosition(sel.IsRectangular() ? sel.Rectangular().caret.Position() : sel.MainCaret()); int lineDisplay = cs.DisplayFromDoc(lineDoc); int newTop = lineDisplay - (LinesOnScreen() / 2); if (topLine != newTop) { SetTopLine(newTop > 0 ? newTop : 0); RedrawRect(GetClientRectangle()); } } void Editor::MoveSelectedLines(int lineDelta) { // if selection doesn't start at the beginning of the line, set the new start int selectionStart = SelectionStart().Position(); int startLine = pdoc->LineFromPosition(selectionStart); int beginningOfStartLine = pdoc->LineStart(startLine); selectionStart = beginningOfStartLine; // if selection doesn't end at the beginning of a line greater than that of the start, // then set it at the beginning of the next one int selectionEnd = SelectionEnd().Position(); int endLine = pdoc->LineFromPosition(selectionEnd); int beginningOfEndLine = pdoc->LineStart(endLine); if (selectionEnd > beginningOfEndLine || selectionStart == selectionEnd) { selectionEnd = pdoc->LineStart(endLine + 1); } // if there's nowhere for the selection to move // (i.e. at the beginning going up or at the end going down), // stop it right there! if ((selectionStart == 0 && lineDelta < 0) || (selectionEnd == pdoc->Length() && lineDelta > 0) || selectionStart == selectionEnd) { return; } UndoGroup ug(pdoc); SetSelection(selectionStart, selectionEnd); SelectionText selectedText; CopySelectionRange(&selectedText); int selectionLength = SelectionRange(selectionStart, selectionEnd).Length(); ClearSelection(); Point currentLocation = LocationFromPosition(CurrentPosition()); int currentLine = LineFromLocation(currentLocation); GoToLine(currentLine + lineDelta); pdoc->InsertCString(CurrentPosition(), selectedText.s); SetSelection(CurrentPosition(), CurrentPosition() + selectionLength); } void Editor::MoveSelectedLinesUp() { MoveSelectedLines(-1); } void Editor::MoveSelectedLinesDown() { MoveSelectedLines(1); } void Editor::MoveCaretInsideView(bool ensureVisible) { PRectangle rcClient = GetTextRectangle(); Point pt = PointMainCaret(); if (pt.y < rcClient.top) { MovePositionTo(SPositionFromLocation( Point(lastXChosen - xOffset, rcClient.top), false, false, UserVirtualSpace()), Selection::noSel, ensureVisible); } else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) { int yOfLastLineFullyDisplayed = rcClient.top + (LinesOnScreen() - 1) * vs.lineHeight; MovePositionTo(SPositionFromLocation( Point(lastXChosen - xOffset, rcClient.top + yOfLastLineFullyDisplayed), false, false, UserVirtualSpace()), Selection::noSel, ensureVisible); } } int Editor::DisplayFromPosition(int pos) { int lineDoc = pdoc->LineFromPosition(pos); int lineDisplay = cs.DisplayFromDoc(lineDoc); AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc)); if (surface && ll) { LayoutLine(lineDoc, surface, vs, ll, wrapWidth); unsigned int posLineStart = pdoc->LineStart(lineDoc); int posInLine = pos - posLineStart; lineDisplay--; // To make up for first increment ahead. for (int subLine = 0; subLine < ll->lines; subLine++) { if (posInLine >= ll->LineStart(subLine)) { lineDisplay++; } } } return lineDisplay; } /** * Ensure the caret is reasonably visible in context. * Caret policy in SciTE If slop is set, we can define a slop value. This value defines an unwanted zone (UZ) where the caret is... unwanted. This zone is defined as a number of pixels near the vertical margins, and as a number of lines near the horizontal margins. By keeping the caret away from the edges, it is seen within its context, so it is likely that the identifier that the caret is on can be completely seen, and that the current line is seen with some of the lines following it which are often dependent on that line. If strict is set, the policy is enforced... strictly. The caret is centred on the display if slop is not set, and cannot go in the UZ if slop is set. If jumps is set, the display is moved more energetically so the caret can move in the same direction longer before the policy is applied again. '3UZ' notation is used to indicate three time the size of the UZ as a distance to the margin. If even is not set, instead of having symmetrical UZs, the left and bottom UZs are extended up to right and top UZs respectively. This way, we favour the displaying of useful information: the begining of lines, where most code reside, and the lines after the caret, eg. the body of a function. | | | | | slop | strict | jumps | even | Caret can go to the margin | When reaching limit (caret going out of | | | | | visibility or going into the UZ) display is... -----+--------+-------+------+--------------------------------------------+-------------------------------------------------------------- 0 | 0 | 0 | 0 | Yes | moved to put caret on top/on right 0 | 0 | 0 | 1 | Yes | moved by one position 0 | 0 | 1 | 0 | Yes | moved to put caret on top/on right 0 | 0 | 1 | 1 | Yes | centred on the caret 0 | 1 | - | 0 | Caret is always on top/on right of display | - 0 | 1 | - | 1 | No, caret is always centred | - 1 | 0 | 0 | 0 | Yes | moved to put caret out of the asymmetrical UZ 1 | 0 | 0 | 1 | Yes | moved to put caret out of the UZ 1 | 0 | 1 | 0 | Yes | moved to put caret at 3UZ of the top or right margin 1 | 0 | 1 | 1 | Yes | moved to put caret at 3UZ of the margin 1 | 1 | - | 0 | Caret is always at UZ of top/right margin | - 1 | 1 | 0 | 1 | No, kept out of UZ | moved by one position 1 | 1 | 1 | 1 | No, kept out of UZ | moved to put caret at 3UZ of the margin */ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const bool useMargin, const bool vert, const bool horiz) { PRectangle rcClient = GetTextRectangle(); const SelectionPosition posCaret = posDrag.IsValid() ? posDrag : sel.RangeMain().caret; const Point pt = LocationFromPosition(posCaret); const Point ptBottomCaret(pt.x, pt.y + vs.lineHeight - 1); const int lineCaret = DisplayFromPosition(posCaret.Position()); XYScrollPosition newXY(xOffset, topLine); // Vertical positioning if (vert && (pt.y < rcClient.top || ptBottomCaret.y >= rcClient.bottom || (caretYPolicy & CARET_STRICT) != 0)) { const int linesOnScreen = LinesOnScreen(); const int halfScreen = Platform::Maximum(linesOnScreen - 1, 2) / 2; const bool bSlop = (caretYPolicy & CARET_SLOP) != 0; const bool bStrict = (caretYPolicy & CARET_STRICT) != 0; const bool bJump = (caretYPolicy & CARET_JUMPS) != 0; const bool bEven = (caretYPolicy & CARET_EVEN) != 0; // It should be possible to scroll the window to show the caret, // but this fails to remove the caret on GTK+ if (bSlop) { // A margin is defined int yMoveT, yMoveB; if (bStrict) { int yMarginT, yMarginB; if (!useMargin) { // In drag mode, avoid moves // otherwise, a double click will select several lines. yMarginT = yMarginB = 0; } else { // yMarginT must equal to caretYSlop, with a minimum of 1 and // a maximum of slightly less than half the heigth of the text area. yMarginT = Platform::Clamp(caretYSlop, 1, halfScreen); if (bEven) { yMarginB = yMarginT; } else { yMarginB = linesOnScreen - yMarginT - 1; } } yMoveT = yMarginT; if (bEven) { if (bJump) { yMoveT = Platform::Clamp(caretYSlop * 3, 1, halfScreen); } yMoveB = yMoveT; } else { yMoveB = linesOnScreen - yMoveT - 1; } if (lineCaret < topLine + yMarginT) { // Caret goes too high newXY.topLine = lineCaret - yMoveT; } else if (lineCaret > topLine + linesOnScreen - 1 - yMarginB) { // Caret goes too low newXY.topLine = lineCaret - linesOnScreen + 1 + yMoveB; } } else { // Not strict yMoveT = bJump ? caretYSlop * 3 : caretYSlop; yMoveT = Platform::Clamp(yMoveT, 1, halfScreen); if (bEven) { yMoveB = yMoveT; } else { yMoveB = linesOnScreen - yMoveT - 1; } if (lineCaret < topLine) { // Caret goes too high newXY.topLine = lineCaret - yMoveT; } else if (lineCaret > topLine + linesOnScreen - 1) { // Caret goes too low newXY.topLine = lineCaret - linesOnScreen + 1 + yMoveB; } } } else { // No slop if (!bStrict && !bJump) { // Minimal move if (lineCaret < topLine) { // Caret goes too high newXY.topLine = lineCaret; } else if (lineCaret > topLine + linesOnScreen - 1) { // Caret goes too low if (bEven) { newXY.topLine = lineCaret - linesOnScreen + 1; } else { newXY.topLine = lineCaret; } } } else { // Strict or going out of display if (bEven) { // Always center caret newXY.topLine = lineCaret - halfScreen; } else { // Always put caret on top of display newXY.topLine = lineCaret; } } } newXY.topLine = Platform::Clamp(newXY.topLine, 0, MaxScrollPos()); } // Horizontal positioning if (horiz && (wrapState == eWrapNone)) { const int halfScreen = Platform::Maximum(rcClient.Width() - 4, 4) / 2; const bool bSlop = (caretXPolicy & CARET_SLOP) != 0; const bool bStrict = (caretXPolicy & CARET_STRICT) != 0; const bool bJump = (caretXPolicy & CARET_JUMPS) != 0; const bool bEven = (caretXPolicy & CARET_EVEN) != 0; if (bSlop) { // A margin is defined int xMoveL, xMoveR; if (bStrict) { int xMarginL, xMarginR; if (!useMargin) { // In drag mode, avoid moves unless very near of the margin // otherwise, a simple click will select text. xMarginL = xMarginR = 2; } else { // xMargin must equal to caretXSlop, with a minimum of 2 and // a maximum of slightly less than half the width of the text area. xMarginR = Platform::Clamp(caretXSlop, 2, halfScreen); if (bEven) { xMarginL = xMarginR; } else { xMarginL = rcClient.Width() - xMarginR - 4; } } if (bJump && bEven) { // Jump is used only in even mode xMoveL = xMoveR = Platform::Clamp(caretXSlop * 3, 1, halfScreen); } else { xMoveL = xMoveR = 0; // Not used, avoid a warning } if (pt.x < rcClient.left + xMarginL) { // Caret is on the left of the display if (bJump && bEven) { newXY.xOffset -= xMoveL; } else { // Move just enough to allow to display the caret newXY.xOffset -= (rcClient.left + xMarginL) - pt.x; } } else if (pt.x >= rcClient.right - xMarginR) { // Caret is on the right of the display if (bJump && bEven) { newXY.xOffset += xMoveR; } else { // Move just enough to allow to display the caret newXY.xOffset += pt.x - (rcClient.right - xMarginR) + 1; } } } else { // Not strict xMoveR = bJump ? caretXSlop * 3 : caretXSlop; xMoveR = Platform::Clamp(xMoveR, 1, halfScreen); if (bEven) { xMoveL = xMoveR; } else { xMoveL = rcClient.Width() - xMoveR - 4; } if (pt.x < rcClient.left) { // Caret is on the left of the display newXY.xOffset -= xMoveL; } else if (pt.x >= rcClient.right) { // Caret is on the right of the display newXY.xOffset += xMoveR; } } } else { // No slop if (bStrict || (bJump && (pt.x < rcClient.left || pt.x >= rcClient.right))) { // Strict or going out of display if (bEven) { // Center caret newXY.xOffset += pt.x - rcClient.left - halfScreen; } else { // Put caret on right newXY.xOffset += pt.x - rcClient.right + 1; } } else { // Move just enough to allow to display the caret if (pt.x < rcClient.left) { // Caret is on the left of the display if (bEven) { newXY.xOffset -= rcClient.left - pt.x; } else { newXY.xOffset += pt.x - rcClient.right + 1; } } else if (pt.x >= rcClient.right) { // Caret is on the right of the display newXY.xOffset += pt.x - rcClient.right + 1; } } } // In case of a jump (find result) largely out of display, adjust the offset to display the caret if (pt.x + xOffset < rcClient.left + newXY.xOffset) { newXY.xOffset = pt.x + xOffset - rcClient.left; } else if (pt.x + xOffset >= rcClient.right + newXY.xOffset) { newXY.xOffset = pt.x + xOffset - rcClient.right + 1; if (vs.caretStyle == CARETSTYLE_BLOCK) { // Ensure we can see a good portion of the block caret newXY.xOffset += static_cast(vs.aveCharWidth); } } if (newXY.xOffset < 0) { newXY.xOffset = 0; } } return newXY; } void Editor::SetXYScroll(XYScrollPosition newXY) { if ((newXY.topLine != topLine) || (newXY.xOffset != xOffset)) { if (newXY.topLine != topLine) { SetTopLine(newXY.topLine); SetVerticalScrollPos(); } if (newXY.xOffset != xOffset) { xOffset = newXY.xOffset; ContainerNeedsUpdate(SC_UPDATE_H_SCROLL); if (newXY.xOffset > 0) { PRectangle rcText = GetTextRectangle(); if (horizontalScrollBarVisible && rcText.Width() + xOffset > scrollWidth) { scrollWidth = xOffset + rcText.Width(); SetScrollBars(); } } SetHorizontalScrollPos(); } Redraw(); UpdateSystemCaret(); } } void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) { SetXYScroll(XYScrollToMakeVisible(useMargin, vert, horiz)); } void Editor::ShowCaretAtCurrentPosition() { if (hasFocus) { caret.active = true; caret.on = true; SetTicking(true); } else { caret.active = false; caret.on = false; } InvalidateCaret(); } void Editor::DropCaret() { caret.active = false; InvalidateCaret(); } void Editor::InvalidateCaret() { if (posDrag.IsValid()) { InvalidateRange(posDrag.Position(), posDrag.Position() + 1); } else { for (size_t r=0; rLinesTotal()); if (wrapStart > docLineStart) { wrapStart = docLineStart; llc.Invalidate(LineLayout::llPositions); } if (wrapEnd < docLineEnd) { wrapEnd = docLineEnd; } wrapEnd = Platform::Clamp(wrapEnd, 0, pdoc->LinesTotal()); // Wrap lines during idle. if ((wrapState != eWrapNone) && (wrapEnd != wrapStart)) { SetIdle(true); } } bool Editor::WrapOneLine(Surface *surface, int lineToWrap) { AutoLineLayout ll(llc, RetrieveLineLayout(lineToWrap)); int linesWrapped = 1; if (ll) { LayoutLine(lineToWrap, surface, vs, ll, wrapWidth); linesWrapped = ll->lines; } return cs.SetHeight(lineToWrap, linesWrapped + (vs.annotationVisible ? pdoc->AnnotationLines(lineToWrap) : 0)); } // Check if wrapping needed and perform any needed wrapping. // fullwrap: if true, all lines which need wrapping will be done, // in this single call. // priorityWrapLineStart: If greater than or equal to zero, all lines starting from // here to 1 page + 100 lines past will be wrapped (even if there are // more lines under wrapping process in idle). // If it is neither fullwrap, nor priorityWrap, then 1 page + 100 lines will be // wrapped, if there are any wrapping going on in idle. (Generally this // condition is called only from idler). // Return true if wrapping occurred. bool Editor::WrapLines(bool fullWrap, int priorityWrapLineStart) { // If there are any pending wraps, do them during idle if possible. int linesInOneCall = LinesOnScreen() + 100; if (priorityWrapLineStart >= 0) { // Using DocFromDisplay() here may result in chicken and egg problem in certain corner cases, // which will hopefully be handled by added 100 lines. If some lines are still missed, idle wrapping will catch on. int docLinesInOneCall = cs.DocFromDisplay(topLine + LinesOnScreen() + 100) - cs.DocFromDisplay(topLine); linesInOneCall = Platform::Maximum(linesInOneCall, docLinesInOneCall); } if (wrapState != eWrapNone) { if (wrapStart < wrapEnd) { if (!SetIdle(true)) { // Idle processing not supported so full wrap required. fullWrap = true; } } if (!fullWrap && priorityWrapLineStart >= 0 && // .. and if the paint window is outside pending wraps (((priorityWrapLineStart + linesInOneCall) < wrapStart) || (priorityWrapLineStart > wrapEnd))) { // No priority wrap pending return false; } } int goodTopLine = topLine; bool wrapOccurred = false; if (wrapStart <= pdoc->LinesTotal()) { if (wrapState == eWrapNone) { if (wrapWidth != LineLayout::wrapWidthInfinite) { wrapWidth = LineLayout::wrapWidthInfinite; for (int lineDoc = 0; lineDoc < pdoc->LinesTotal(); lineDoc++) { cs.SetHeight(lineDoc, 1 + (vs.annotationVisible ? pdoc->AnnotationLines(lineDoc) : 0)); } wrapOccurred = true; } wrapStart = wrapLineLarge; wrapEnd = wrapLineLarge; } else { if (wrapEnd >= pdoc->LinesTotal()) wrapEnd = pdoc->LinesTotal(); //ElapsedTime et; int lineDocTop = cs.DocFromDisplay(topLine); int subLineTop = topLine - cs.DisplayFromDoc(lineDocTop); PRectangle rcTextArea = GetClientRectangle(); rcTextArea.left = vs.fixedColumnWidth; rcTextArea.right -= vs.rightMarginWidth; wrapWidth = rcTextArea.Width(); RefreshStyleData(); AutoSurface surface(this); if (surface) { bool priorityWrap = false; int lastLineToWrap = wrapEnd; int lineToWrap = wrapStart; if (!fullWrap) { if (priorityWrapLineStart >= 0) { // This is a priority wrap. lineToWrap = priorityWrapLineStart; lastLineToWrap = priorityWrapLineStart + linesInOneCall; priorityWrap = true; } else { // This is idle wrap. lastLineToWrap = wrapStart + linesInOneCall; } if (lastLineToWrap >= wrapEnd) lastLineToWrap = wrapEnd; } // else do a fullWrap. // Ensure all lines being wrapped are styled. pdoc->EnsureStyledTo(pdoc->LineEnd(lastLineToWrap)); // Platform::DebugPrintf("Wraplines: full = %d, priorityStart = %d (wrapping: %d to %d)\n", fullWrap, priorityWrapLineStart, lineToWrap, lastLineToWrap); // Platform::DebugPrintf("Pending wraps: %d to %d\n", wrapStart, wrapEnd); while (lineToWrap < lastLineToWrap) { if (WrapOneLine(surface, lineToWrap)) { wrapOccurred = true; } lineToWrap++; } if (!priorityWrap) wrapStart = lineToWrap; // If wrapping is done, bring it to resting position if (wrapStart >= wrapEnd) { wrapStart = wrapLineLarge; wrapEnd = wrapLineLarge; } } goodTopLine = cs.DisplayFromDoc(lineDocTop); if (subLineTop < cs.GetHeight(lineDocTop)) goodTopLine += subLineTop; else goodTopLine += cs.GetHeight(lineDocTop); //double durWrap = et.Duration(true); //Platform::DebugPrintf("Wrap:%9.6g \n", durWrap); } } if (wrapOccurred) { SetScrollBars(); SetTopLine(Platform::Clamp(goodTopLine, 0, MaxScrollPos())); SetVerticalScrollPos(); } return wrapOccurred; } void Editor::LinesJoin() { if (!RangeContainsProtected(targetStart, targetEnd)) { UndoGroup ug(pdoc); bool prevNonWS = true; for (int pos = targetStart; pos < targetEnd; pos++) { if (IsEOLChar(pdoc->CharAt(pos))) { targetEnd -= pdoc->LenChar(pos); pdoc->DelChar(pos); if (prevNonWS) { // Ensure at least one space separating previous lines pdoc->InsertChar(pos, ' '); targetEnd++; } } else { prevNonWS = pdoc->CharAt(pos) != ' '; } } } } const char *Editor::StringFromEOLMode(int eolMode) { if (eolMode == SC_EOL_CRLF) { return "\r\n"; } else if (eolMode == SC_EOL_CR) { return "\r"; } else { return "\n"; } } void Editor::LinesSplit(int pixelWidth) { if (!RangeContainsProtected(targetStart, targetEnd)) { if (pixelWidth == 0) { PRectangle rcText = GetTextRectangle(); pixelWidth = rcText.Width(); } int lineStart = pdoc->LineFromPosition(targetStart); int lineEnd = pdoc->LineFromPosition(targetEnd); const char *eol = StringFromEOLMode(pdoc->eolMode); UndoGroup ug(pdoc); for (int line = lineStart; line <= lineEnd; line++) { AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(line)); if (surface && ll) { unsigned int posLineStart = pdoc->LineStart(line); LayoutLine(line, surface, vs, ll, pixelWidth); for (int subLine = 1; subLine < ll->lines; subLine++) { pdoc->InsertCString( static_cast(posLineStart + (subLine - 1) * strlen(eol) + ll->LineStart(subLine)), eol); targetEnd += static_cast(strlen(eol)); } } lineEnd = pdoc->LineFromPosition(targetEnd); } } } int Editor::SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) { if (vs.markers[markerCheck].markType == SC_MARK_EMPTY) return markerDefault; return markerCheck; } // Avoid 64 bit compiler warnings. // Scintilla does not support text buffers larger than 2**31 static int istrlen(const char *s) { return static_cast(strlen(s)); } bool ValidStyledText(ViewStyle &vs, size_t styleOffset, const StyledText &st) { if (st.multipleStyles) { for (size_t iStyle=0; iStyle(styles[endSegment+1]) == style)) endSegment++; width += surface->WidthText(vs.styles[style+styleOffset].font, text + start, static_cast(endSegment - start + 1)); start = endSegment + 1; } return width; } static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, const StyledText &st) { int widthMax = 0; size_t start = 0; while (start < st.length) { size_t lenLine = st.LineLength(start); int widthSubLine; if (st.multipleStyles) { widthSubLine = WidthStyledText(surface, vs, styleOffset, st.text + start, st.styles + start, lenLine); } else { widthSubLine = surface->WidthText(vs.styles[styleOffset + st.style].font, st.text + start, static_cast(lenLine)); } if (widthSubLine > widthMax) widthMax = widthSubLine; start += lenLine + 1; } return widthMax; } void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle rcText, int ascent, const StyledText &st, size_t start, size_t length) { if (st.multipleStyles) { int x = rcText.left; size_t i = 0; while (i < length) { size_t end = i; int style = st.styles[i + start]; while (end < length-1 && st.styles[start+end+1] == style) end++; style += styleOffset; int width = surface->WidthText(vs.styles[style].font, st.text + start + i, static_cast(end - i + 1)); PRectangle rcSegment = rcText; rcSegment.left = x; rcSegment.right = x + width + 1; surface->DrawTextNoClip(rcSegment, vs.styles[style].font, ascent, st.text + start + i, static_cast(end - i + 1), vs.styles[style].fore, vs.styles[style].back); x += width; i = end + 1; } } else { size_t style = st.style + styleOffset; surface->DrawTextNoClip(rcText, vs.styles[style].font, rcText.top + vs.maxAscent, st.text + start, static_cast(length), vs.styles[style].fore, vs.styles[style].back); } } void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { if (vs.fixedColumnWidth == 0) return; PRectangle rcMargin = GetClientRectangle(); rcMargin.right = vs.fixedColumnWidth; if (!rc.Intersects(rcMargin)) return; Surface *surface; if (bufferedDraw) { surface = pixmapSelMargin; } else { surface = surfWindow; } // Clip vertically to paint area to avoid drawing line numbers if (rcMargin.bottom > rc.bottom) rcMargin.bottom = rc.bottom; if (rcMargin.top < rc.top) rcMargin.top = rc.top; PRectangle rcSelMargin = rcMargin; rcSelMargin.right = rcMargin.left; for (int margin = 0; margin < vs.margins; margin++) { if (vs.ms[margin].width > 0) { rcSelMargin.left = rcSelMargin.right; rcSelMargin.right = rcSelMargin.left + vs.ms[margin].width; if (vs.ms[margin].style != SC_MARGIN_NUMBER) { if (vs.ms[margin].mask & SC_MASK_FOLDERS) // Required because of special way brush is created for selection margin surface->FillRectangle(rcSelMargin, *pixmapSelPattern); else { ColourDesired colour; switch (vs.ms[margin].style) { case SC_MARGIN_BACK: colour = vs.styles[STYLE_DEFAULT].back; break; case SC_MARGIN_FORE: colour = vs.styles[STYLE_DEFAULT].fore; break; default: colour = vs.styles[STYLE_LINENUMBER].back; break; } surface->FillRectangle(rcSelMargin, colour); } } else { surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back); } const int lineStartPaint = rcMargin.top / vs.lineHeight; int visibleLine = topLine + lineStartPaint; int yposScreen = lineStartPaint * vs.lineHeight; // Work out whether the top line is whitespace located after a // lessening of fold level which implies a 'fold tail' but which should not // be displayed until the last of a sequence of whitespace. bool needWhiteClosure = false; if (vs.ms[margin].mask & SC_MASK_FOLDERS) { int level = pdoc->GetLevel(cs.DocFromDisplay(visibleLine)); if (level & SC_FOLDLEVELWHITEFLAG) { int lineBack = cs.DocFromDisplay(visibleLine); int levelPrev = level; while ((lineBack > 0) && (levelPrev & SC_FOLDLEVELWHITEFLAG)) { lineBack--; levelPrev = pdoc->GetLevel(lineBack); } if (!(levelPrev & SC_FOLDLEVELHEADERFLAG)) { if ((level & SC_FOLDLEVELNUMBERMASK) < (levelPrev & SC_FOLDLEVELNUMBERMASK)) needWhiteClosure = true; } } if (highlightDelimiter.isEnabled) { int lastLine = cs.DocFromDisplay(topLine + LinesOnScreen()) + 1; pdoc->GetHighlightDelimiters(highlightDelimiter, pdoc->LineFromPosition(CurrentPosition()), lastLine); } } // Old code does not know about new markers needed to distinguish all cases int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID, SC_MARKNUM_FOLDEROPEN); int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND, SC_MARKNUM_FOLDER); while ((visibleLine < cs.LinesDisplayed()) && yposScreen < rcMargin.bottom) { PLATFORM_ASSERT(visibleLine < cs.LinesDisplayed()); int lineDoc = cs.DocFromDisplay(visibleLine); PLATFORM_ASSERT(cs.GetVisible(lineDoc)); bool firstSubLine = visibleLine == cs.DisplayFromDoc(lineDoc); bool lastSubLine = visibleLine == (cs.DisplayFromDoc(lineDoc + 1) - 1); int marks = pdoc->GetMark(lineDoc); if (!firstSubLine) marks = 0; bool headWithTail = false; if (vs.ms[margin].mask & SC_MASK_FOLDERS) { // Decide which fold indicator should be displayed int level = pdoc->GetLevel(lineDoc); int levelNext = pdoc->GetLevel(lineDoc + 1); int levelNum = level & SC_FOLDLEVELNUMBERMASK; int levelNextNum = levelNext & SC_FOLDLEVELNUMBERMASK; if (level & SC_FOLDLEVELHEADERFLAG) { if (firstSubLine) { if (levelNum < levelNextNum) { if (cs.GetExpanded(lineDoc)) { if (levelNum == SC_FOLDLEVELBASE) marks |= 1 << SC_MARKNUM_FOLDEROPEN; else marks |= 1 << folderOpenMid; } else { if (levelNum == SC_FOLDLEVELBASE) marks |= 1 << SC_MARKNUM_FOLDER; else marks |= 1 << folderEnd; } } else if (levelNum > SC_FOLDLEVELBASE) { marks |= 1 << SC_MARKNUM_FOLDERSUB; } } else { if (levelNum < levelNextNum) { if (cs.GetExpanded(lineDoc)) { marks |= 1 << SC_MARKNUM_FOLDERSUB; } else if (levelNum > SC_FOLDLEVELBASE) { marks |= 1 << SC_MARKNUM_FOLDERSUB; } } else if (levelNum > SC_FOLDLEVELBASE) { marks |= 1 << SC_MARKNUM_FOLDERSUB; } } needWhiteClosure = false; int firstFollowupLine = cs.DocFromDisplay(cs.DisplayFromDoc(lineDoc + 1)); int firstFollowupLineLevel = pdoc->GetLevel(firstFollowupLine); int secondFollowupLineLevelNum = pdoc->GetLevel(firstFollowupLine + 1) & SC_FOLDLEVELNUMBERMASK; if (!cs.GetExpanded(lineDoc)) { if ((firstFollowupLineLevel & SC_FOLDLEVELWHITEFLAG) && (levelNum > secondFollowupLineLevelNum)) needWhiteClosure = true; if (highlightDelimiter.IsFoldBlockHighlighted(firstFollowupLine)) headWithTail = true; } } else if (level & SC_FOLDLEVELWHITEFLAG) { if (needWhiteClosure) { if (levelNext & SC_FOLDLEVELWHITEFLAG) { marks |= 1 << SC_MARKNUM_FOLDERSUB; } else if (levelNextNum > SC_FOLDLEVELBASE) { marks |= 1 << SC_MARKNUM_FOLDERMIDTAIL; needWhiteClosure = false; } else { marks |= 1 << SC_MARKNUM_FOLDERTAIL; needWhiteClosure = false; } } else if (levelNum > SC_FOLDLEVELBASE) { if (levelNextNum < levelNum) { if (levelNextNum > SC_FOLDLEVELBASE) { marks |= 1 << SC_MARKNUM_FOLDERMIDTAIL; } else { marks |= 1 << SC_MARKNUM_FOLDERTAIL; } } else { marks |= 1 << SC_MARKNUM_FOLDERSUB; } } } else if (levelNum > SC_FOLDLEVELBASE) { if (levelNextNum < levelNum) { needWhiteClosure = false; if (levelNext & SC_FOLDLEVELWHITEFLAG) { marks |= 1 << SC_MARKNUM_FOLDERSUB; needWhiteClosure = true; } else if (lastSubLine) { if (levelNextNum > SC_FOLDLEVELBASE) { marks |= 1 << SC_MARKNUM_FOLDERMIDTAIL; } else { marks |= 1 << SC_MARKNUM_FOLDERTAIL; } } else { marks |= 1 << SC_MARKNUM_FOLDERSUB; } } else { marks |= 1 << SC_MARKNUM_FOLDERSUB; } } } marks &= vs.ms[margin].mask; PRectangle rcMarker = rcSelMargin; rcMarker.top = yposScreen; rcMarker.bottom = yposScreen + vs.lineHeight; if (vs.ms[margin].style == SC_MARGIN_NUMBER) { char number[100]; number[0] = '\0'; if (firstSubLine) sprintf(number, "%d", lineDoc + 1); if (foldFlags & SC_FOLDFLAG_LEVELNUMBERS) { int lev = pdoc->GetLevel(lineDoc); sprintf(number, "%c%c %03X %03X", (lev & SC_FOLDLEVELHEADERFLAG) ? 'H' : '_', (lev & SC_FOLDLEVELWHITEFLAG) ? 'W' : '_', lev & SC_FOLDLEVELNUMBERMASK, lev >> 16 ); } PRectangle rcNumber = rcMarker; // Right justify XYPOSITION width = surface->WidthText(vs.styles[STYLE_LINENUMBER].font, number, istrlen(number)); XYPOSITION xpos = rcNumber.right - width - 3; rcNumber.left = xpos; surface->DrawTextNoClip(rcNumber, vs.styles[STYLE_LINENUMBER].font, rcNumber.top + vs.maxAscent, number, istrlen(number), vs.styles[STYLE_LINENUMBER].fore, vs.styles[STYLE_LINENUMBER].back); } else if (vs.ms[margin].style == SC_MARGIN_TEXT || vs.ms[margin].style == SC_MARGIN_RTEXT) { if (firstSubLine) { const StyledText stMargin = pdoc->MarginStyledText(lineDoc); if (stMargin.text && ValidStyledText(vs, vs.marginStyleOffset, stMargin)) { surface->FillRectangle(rcMarker, vs.styles[stMargin.StyleAt(0)+vs.marginStyleOffset].back); if (vs.ms[margin].style == SC_MARGIN_RTEXT) { int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin); rcMarker.left = rcMarker.right - width - 3; } DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, rcMarker.top + vs.maxAscent, stMargin, 0, stMargin.length); } } } if (marks) { for (int markBit = 0; (markBit < 32) && marks; markBit++) { if (marks & 1) { LineMarker::typeOfFold tFold = LineMarker::undefined; if ((vs.ms[margin].mask & SC_MASK_FOLDERS) && highlightDelimiter.IsFoldBlockHighlighted(lineDoc)) { if (highlightDelimiter.IsBodyOfFoldBlock(lineDoc)) { tFold = LineMarker::body; } else if (highlightDelimiter.IsHeadOfFoldBlock(lineDoc)) { if (firstSubLine) { tFold = headWithTail ? LineMarker::headWithTail : LineMarker::head; } else { if (cs.GetExpanded(lineDoc) || headWithTail) { tFold = LineMarker::body; } else { tFold = LineMarker::undefined; } } } else if (highlightDelimiter.IsTailOfFoldBlock(lineDoc)) { tFold = LineMarker::tail; } } vs.markers[markBit].Draw(surface, rcMarker, vs.styles[STYLE_LINENUMBER].font, tFold, vs.ms[margin].style); } marks >>= 1; } } visibleLine++; yposScreen += vs.lineHeight; } } } PRectangle rcBlankMargin = rcMargin; rcBlankMargin.left = rcSelMargin.right; surface->FillRectangle(rcBlankMargin, vs.styles[STYLE_DEFAULT].back); if (bufferedDraw) { surfWindow->Copy(rcMargin, Point(rcMargin.left, rcMargin.top), *pixmapSelMargin); } } void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) { int ydiff = (rcTab.bottom - rcTab.top) / 2; int xhead = rcTab.right - 1 - ydiff; if (xhead <= rcTab.left) { ydiff -= rcTab.left - xhead - 1; xhead = rcTab.left - 1; } if ((rcTab.left + 2) < (rcTab.right - 1)) surface->MoveTo(rcTab.left + 2, ymid); else surface->MoveTo(rcTab.right - 1, ymid); surface->LineTo(rcTab.right - 1, ymid); surface->LineTo(xhead, ymid - ydiff); surface->MoveTo(rcTab.right - 1, ymid); surface->LineTo(xhead, ymid + ydiff); } LineLayout *Editor::RetrieveLineLayout(int lineNumber) { int posLineStart = pdoc->LineStart(lineNumber); int posLineEnd = pdoc->LineStart(lineNumber + 1); PLATFORM_ASSERT(posLineEnd >= posLineStart); int lineCaret = pdoc->LineFromPosition(sel.MainCaret()); return llc.Retrieve(lineNumber, lineCaret, posLineEnd - posLineStart, pdoc->GetStyleClock(), LinesOnScreen() + 1, pdoc->LinesTotal()); } static bool GoodTrailByte(int v) { return (v >= 0x80) && (v < 0xc0); } bool BadUTF(const char *s, int len, int &trailBytes) { // For the rules: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 if (trailBytes) { trailBytes--; return false; } const unsigned char *us = reinterpret_cast(s); if (*us < 0x80) { // Single bytes easy return false; } else if (*us > 0xF4) { // Characters longer than 4 bytes not possible in current UTF-8 return true; } else if (*us >= 0xF0) { // 4 bytes if (len < 4) return true; if (GoodTrailByte(us[1]) && GoodTrailByte(us[2]) && GoodTrailByte(us[3])) { if (*us == 0xf4) { // Check if encoding a value beyond the last Unicode character 10FFFF if (us[1] > 0x8f) { return true; } else if (us[1] == 0x8f) { if (us[2] > 0xbf) { return true; } else if (us[2] == 0xbf) { if (us[3] > 0xbf) { return true; } } } } else if ((*us == 0xf0) && ((us[1] & 0xf0) == 0x80)) { // Overlong return true; } trailBytes = 3; return false; } else { return true; } } else if (*us >= 0xE0) { // 3 bytes if (len < 3) return true; if (GoodTrailByte(us[1]) && GoodTrailByte(us[2])) { if ((*us == 0xe0) && ((us[1] & 0xe0) == 0x80)) { // Overlong return true; } if ((*us == 0xed) && ((us[1] & 0xe0) == 0xa0)) { // Surrogate return true; } if ((*us == 0xef) && (us[1] == 0xbf) && (us[2] == 0xbe)) { // U+FFFE return true; } if ((*us == 0xef) && (us[1] == 0xbf) && (us[2] == 0xbf)) { // U+FFFF return true; } trailBytes = 2; return false; } else { return true; } } else if (*us >= 0xC2) { // 2 bytes if (len < 2) return true; if (GoodTrailByte(us[1])) { trailBytes = 1; return false; } else { return true; } } else if (*us >= 0xC0) { // Overlong encoding return true; } else { // Trail byte return true; } } /** * Fill in the LineLayout data for the given line. * Copy the given @a line and its styles from the document into local arrays. * Also determine the x position at which each character starts. */ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width) { if (!ll) return; PLATFORM_ASSERT(line < pdoc->LinesTotal()); PLATFORM_ASSERT(ll->chars != NULL); int posLineStart = pdoc->LineStart(line); int posLineEnd = pdoc->LineStart(line + 1); // If the line is very long, limit the treatment to a length that should fit in the viewport if (posLineEnd > (posLineStart + ll->maxLineLength)) { posLineEnd = posLineStart + ll->maxLineLength; } if (ll->validity == LineLayout::llCheckTextAndStyle) { int lineLength = posLineEnd - posLineStart; if (!vstyle.viewEOL) { int cid = posLineEnd - 1; while ((cid > posLineStart) && IsEOLChar(pdoc->CharAt(cid))) { cid--; lineLength--; } } if (lineLength == ll->numCharsInLine) { // See if chars, styles, indicators, are all the same bool allSame = true; const int styleMask = pdoc->stylingBitsMask; // Check base line layout char styleByte = 0; int numCharsInLine = 0; while (numCharsInLine < lineLength) { int charInDoc = numCharsInLine + posLineStart; char chDoc = pdoc->CharAt(charInDoc); styleByte = pdoc->StyleAt(charInDoc); allSame = allSame && (ll->styles[numCharsInLine] == static_cast(styleByte & styleMask)); allSame = allSame && (ll->indicators[numCharsInLine] == static_cast(styleByte & ~styleMask)); if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseMixed) allSame = allSame && (ll->chars[numCharsInLine] == chDoc); else if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseLower) allSame = allSame && (ll->chars[numCharsInLine] == static_cast(tolower(chDoc))); else // Style::caseUpper allSame = allSame && (ll->chars[numCharsInLine] == static_cast(toupper(chDoc))); numCharsInLine++; } allSame = allSame && (ll->styles[numCharsInLine] == styleByte); // For eolFilled if (allSame) { ll->validity = LineLayout::llPositions; } else { ll->validity = LineLayout::llInvalid; } } else { ll->validity = LineLayout::llInvalid; } } if (ll->validity == LineLayout::llInvalid) { ll->widthLine = LineLayout::wrapWidthInfinite; ll->lines = 1; if (vstyle.edgeState == EDGE_BACKGROUND) { ll->edgeColumn = pdoc->FindColumn(line, theEdge); if (ll->edgeColumn >= posLineStart) { ll->edgeColumn -= posLineStart; } } else { ll->edgeColumn = -1; } char styleByte; const int styleMask = pdoc->stylingBitsMask; ll->styleBitsSet = 0; // Fill base line layout const int lineLength = posLineEnd - posLineStart; pdoc->GetCharRange(ll->chars, posLineStart, lineLength); pdoc->GetStyleRange(ll->styles, posLineStart, lineLength); int numCharsBeforeEOL = lineLength; while ((numCharsBeforeEOL > 0) && IsEOLChar(ll->chars[numCharsBeforeEOL-1])) { numCharsBeforeEOL--; } const int numCharsInLine = (vstyle.viewEOL) ? lineLength : numCharsBeforeEOL; for (int styleInLine = 0; styleInLine < numCharsInLine; styleInLine++) { styleByte = ll->styles[styleInLine]; ll->styleBitsSet |= styleByte; ll->styles[styleInLine] = static_cast(styleByte & styleMask); ll->indicators[styleInLine] = static_cast(styleByte & ~styleMask); } styleByte = static_cast(((lineLength > 0) ? ll->styles[lineLength-1] : 0) & styleMask); if (vstyle.someStylesForceCase) { for (int charInLine = 0; charInLinechars[charInLine]; if (vstyle.styles[ll->styles[charInLine]].caseForce == Style::caseUpper) ll->chars[charInLine] = static_cast(toupper(chDoc)); else if (vstyle.styles[ll->styles[charInLine]].caseForce == Style::caseLower) ll->chars[charInLine] = static_cast(tolower(chDoc)); } } ll->xHighlightGuide = 0; // Extra element at the end of the line to hold end x position and act as ll->chars[numCharsInLine] = 0; // Also triggers processing in the loops as this is a control character ll->styles[numCharsInLine] = styleByte; // For eolFilled ll->indicators[numCharsInLine] = 0; // Layout the line, determining the position of each character, // with an extra element at the end for the end of the line. int startseg = 0; // Start of the current segment, in char. number XYACCUMULATOR startsegx = 0; // Start of the current segment, in pixels ll->positions[0] = 0; XYPOSITION tabWidth = vstyle.spaceWidth * pdoc->tabInChars; bool lastSegItalics = false; Font &ctrlCharsFont = vstyle.styles[STYLE_CONTROLCHAR].font; XYPOSITION ctrlCharWidth[32] = {0}; bool isControlNext = IsControlCharacter(ll->chars[0]); int trailBytes = 0; bool isBadUTFNext = IsUnicodeMode() && BadUTF(ll->chars, numCharsInLine, trailBytes); for (int charInLine = 0; charInLine < numCharsInLine; charInLine++) { bool isControl = isControlNext; isControlNext = IsControlCharacter(ll->chars[charInLine + 1]); bool isBadUTF = isBadUTFNext; isBadUTFNext = IsUnicodeMode() && BadUTF(ll->chars + charInLine + 1, numCharsInLine - charInLine - 1, trailBytes); if ((ll->styles[charInLine] != ll->styles[charInLine + 1]) || isControl || isControlNext || isBadUTF || isBadUTFNext) { ll->positions[startseg] = 0; if (vstyle.styles[ll->styles[charInLine]].visible) { if (isControl) { if (ll->chars[charInLine] == '\t') { ll->positions[charInLine + 1] = ((static_cast((startsegx + 2) / tabWidth) + 1) * tabWidth) - startsegx; } else if (controlCharSymbol < 32) { if (ctrlCharWidth[ll->chars[charInLine]] == 0) { const char *ctrlChar = ControlCharacterString(ll->chars[charInLine]); // +3 For a blank on front and rounded edge each side: ctrlCharWidth[ll->chars[charInLine]] = surface->WidthText(ctrlCharsFont, ctrlChar, istrlen(ctrlChar)) + 3; } ll->positions[charInLine + 1] = ctrlCharWidth[ll->chars[charInLine]]; } else { char cc[2] = { static_cast(controlCharSymbol), '\0' }; surface->MeasureWidths(ctrlCharsFont, cc, 1, ll->positions + startseg + 1); } lastSegItalics = false; } else if (isBadUTF) { char hexits[4]; sprintf(hexits, "x%2X", ll->chars[charInLine] & 0xff); ll->positions[charInLine + 1] = surface->WidthText(ctrlCharsFont, hexits, istrlen(hexits)) + 3; } else { // Regular character int lenSeg = charInLine - startseg + 1; if ((lenSeg == 1) && (' ' == ll->chars[startseg])) { lastSegItalics = false; // Over half the segments are single characters and of these about half are space characters. ll->positions[charInLine + 1] = vstyle.styles[ll->styles[charInLine]].spaceWidth; } else { lastSegItalics = vstyle.styles[ll->styles[charInLine]].italic; posCache.MeasureWidths(surface, vstyle, ll->styles[charInLine], ll->chars + startseg, lenSeg, ll->positions + startseg + 1, pdoc); } } } else { // invisible for (int posToZero = startseg; posToZero <= (charInLine + 1); posToZero++) { ll->positions[posToZero] = 0; } } for (int posToIncrease = startseg; posToIncrease <= (charInLine + 1); posToIncrease++) { ll->positions[posToIncrease] += startsegx; } startsegx = ll->positions[charInLine + 1]; startseg = charInLine + 1; } } // Small hack to make lines that end with italics not cut off the edge of the last character if ((startseg > 0) && lastSegItalics) { ll->positions[startseg] += 2; } ll->numCharsInLine = numCharsInLine; ll->numCharsBeforeEOL = numCharsBeforeEOL; ll->validity = LineLayout::llPositions; } // Hard to cope when too narrow, so just assume there is space if (width < 20) { width = 20; } if ((ll->validity == LineLayout::llPositions) || (ll->widthLine != width)) { ll->widthLine = width; if (width == LineLayout::wrapWidthInfinite) { ll->lines = 1; } else if (width > ll->positions[ll->numCharsInLine]) { // Simple common case where line does not need wrapping. ll->lines = 1; } else { if (wrapVisualFlags & SC_WRAPVISUALFLAG_END) { width -= static_cast(vstyle.aveCharWidth); // take into account the space for end wrap mark } ll->wrapIndent = wrapAddIndent; if (wrapIndentMode != SC_WRAPINDENT_FIXED) for (int i = 0; i < ll->numCharsInLine; i++) { if (!IsSpaceOrTab(ll->chars[i])) { ll->wrapIndent += ll->positions[i]; // Add line indent break; } } // Check for text width minimum if (ll->wrapIndent > width - static_cast(vstyle.aveCharWidth) * 15) ll->wrapIndent = wrapAddIndent; // Check for wrapIndent minimum if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (ll->wrapIndent < vstyle.aveCharWidth)) ll->wrapIndent = vstyle.aveCharWidth; // Indent to show start visual ll->lines = 0; // Calculate line start positions based upon width. int lastGoodBreak = 0; int lastLineStart = 0; XYACCUMULATOR startOffset = 0; int p = 0; while (p < ll->numCharsInLine) { if ((ll->positions[p + 1] - startOffset) >= width) { if (lastGoodBreak == lastLineStart) { // Try moving to start of last character if (p > 0) { lastGoodBreak = pdoc->MovePositionOutsideChar(p + posLineStart, -1) - posLineStart; } if (lastGoodBreak == lastLineStart) { // Ensure at least one character on line. lastGoodBreak = pdoc->MovePositionOutsideChar(lastGoodBreak + posLineStart + 1, 1) - posLineStart; } } lastLineStart = lastGoodBreak; ll->lines++; ll->SetLineStart(ll->lines, lastGoodBreak); startOffset = ll->positions[lastGoodBreak]; // take into account the space for start wrap mark and indent startOffset -= ll->wrapIndent; p = lastGoodBreak + 1; continue; } if (p > 0) { if (wrapState == eWrapChar) { lastGoodBreak = pdoc->MovePositionOutsideChar(p + posLineStart, -1) - posLineStart; p = pdoc->MovePositionOutsideChar(p + 1 + posLineStart, 1) - posLineStart; continue; } else if (ll->styles[p] != ll->styles[p - 1]) { lastGoodBreak = p; } else if (IsSpaceOrTab(ll->chars[p - 1]) && !IsSpaceOrTab(ll->chars[p])) { lastGoodBreak = p; } } p++; } ll->lines++; } ll->validity = LineLayout::llLines; } } ColourDesired Editor::SelectionBackground(ViewStyle &vsDraw, bool main) { return main ? (primarySelection ? vsDraw.selbackground : vsDraw.selbackground2) : vsDraw.selAdditionalBackground; } ColourDesired Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourDesired background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) { if (inSelection == 1) { if (vsDraw.selbackset && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) { return SelectionBackground(vsDraw, true); } } else if (inSelection == 2) { if (vsDraw.selbackset && (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA)) { return SelectionBackground(vsDraw, false); } } else { if ((vsDraw.edgeState == EDGE_BACKGROUND) && (i >= ll->edgeColumn) && !IsEOLChar(ll->chars[i])) return vsDraw.edgecolour; if (inHotspot && vsDraw.hotspotBackgroundSet) return vsDraw.hotspotBackground; } if (overrideBackground && (styleMain != STYLE_BRACELIGHT) && (styleMain != STYLE_BRACEBAD)) { return background; } else { return vsDraw.styles[styleMain].back; } } void Editor::DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight) { Point from(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0); PRectangle rcCopyArea(start + 1, rcSegment.top, start + 2, rcSegment.bottom); surface->Copy(rcCopyArea, from, highlight ? *pixmapIndentGuideHighlight : *pixmapIndentGuide); } void Editor::DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourDesired wrapColour) { surface->PenColour(wrapColour); enum { xa = 1 }; // gap before start int w = rcPlace.right - rcPlace.left - xa - 1; bool xStraight = isEndMarker; // x-mirrored symbol for start marker bool yStraight = true; //bool yStraight= isEndMarker; // comment in for start marker y-mirrowed int x0 = xStraight ? rcPlace.left : rcPlace.right - 1; int y0 = yStraight ? rcPlace.top : rcPlace.bottom - 1; int dy = (rcPlace.bottom - rcPlace.top) / 5; int y = (rcPlace.bottom - rcPlace.top) / 2 + dy; struct Relative { Surface *surface; int xBase; int xDir; int yBase; int yDir; void MoveTo(int xRelative, int yRelative) { surface->MoveTo(xBase + xDir * xRelative, yBase + yDir * yRelative); } void LineTo(int xRelative, int yRelative) { surface->LineTo(xBase + xDir * xRelative, yBase + yDir * yRelative); } }; Relative rel = {surface, x0, xStraight ? 1 : -1, y0, yStraight ? 1 : -1}; // arrow head rel.MoveTo(xa, y); rel.LineTo(xa + 2*w / 3, y - dy); rel.MoveTo(xa, y); rel.LineTo(xa + 2*w / 3, y + dy); // arrow body rel.MoveTo(xa, y); rel.LineTo(xa + w, y); rel.LineTo(xa + w, y - 2 * dy); rel.LineTo(xa - 1, // on windows lineto is exclusive endpoint, perhaps GTK not... y - 2 * dy); } static void SimpleAlphaRectangle(Surface *surface, PRectangle rc, ColourDesired fill, int alpha) { if (alpha != SC_ALPHA_NOALPHA) { surface->AlphaRectangle(rc, 0, fill, alpha, fill, alpha, 0); } } void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment, const char *s, ColourDesired textBack, ColourDesired textFore, bool twoPhaseDraw) { if (!twoPhaseDraw) { surface->FillRectangle(rcSegment, textBack); } Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; int normalCharHeight = surface->Ascent(ctrlCharsFont) - surface->InternalLeading(ctrlCharsFont); PRectangle rcCChar = rcSegment; rcCChar.left = rcCChar.left + 1; rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight; rcCChar.bottom = rcSegment.top + vsDraw.maxAscent + 1; PRectangle rcCentral = rcCChar; rcCentral.top++; rcCentral.bottom--; surface->FillRectangle(rcCentral, textFore); PRectangle rcChar = rcCChar; rcChar.left++; rcChar.right--; surface->DrawTextClipped(rcChar, ctrlCharsFont, rcSegment.top + vsDraw.maxAscent, s, istrlen(s), textBack, textFore); } void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll, int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart, bool overrideBackground, ColourDesired background, bool drawWrapMarkEnd, ColourDesired wrapColour) { const int posLineStart = pdoc->LineStart(line); const int styleMask = pdoc->stylingBitsMask; PRectangle rcSegment = rcLine; const bool lastSubLine = subLine == (ll->lines - 1); XYPOSITION virtualSpace = 0; if (lastSubLine) { const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth; virtualSpace = sel.VirtualSpaceFor(pdoc->LineEnd(line)) * spaceWidth; } XYPOSITION xEol = ll->positions[lineEnd] - subLineStart; // Fill the virtual space and show selections within it if (virtualSpace) { rcSegment.left = xEol + xStart; rcSegment.right = xEol + xStart + virtualSpace; surface->FillRectangle(rcSegment, overrideBackground ? background : vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back); if (!hideSelection && ((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA))) { SelectionSegment virtualSpaceRange(SelectionPosition(pdoc->LineEnd(line)), SelectionPosition(pdoc->LineEnd(line), sel.VirtualSpaceFor(pdoc->LineEnd(line)))); for (size_t r=0; rEndLineStyle()].spaceWidth; rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth; rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth; rcSegment.left = (rcSegment.left > rcLine.left) ? rcSegment.left : rcLine.left; rcSegment.right = (rcSegment.right < rcLine.right) ? rcSegment.right : rcLine.right; surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, r == sel.Main())); } } } } } int eolInSelection = 0; int alpha = SC_ALPHA_NOALPHA; if (!hideSelection) { int posAfterLineEnd = pdoc->LineStart(line + 1); eolInSelection = (subLine == (ll->lines - 1)) ? sel.InSelectionForEOL(posAfterLineEnd) : 0; alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha; } // Draw the [CR], [LF], or [CR][LF] blobs if visible line ends are on XYPOSITION blobsWidth = 0; if (lastSubLine) { for (int eolPos=ll->numCharsBeforeEOL; eolPosnumCharsInLine; eolPos++) { rcSegment.left = xStart + ll->positions[eolPos] - subLineStart + virtualSpace; rcSegment.right = xStart + ll->positions[eolPos+1] - subLineStart + virtualSpace; blobsWidth += rcSegment.Width(); const char *ctrlChar = ControlCharacterString(ll->chars[eolPos]); int styleMain = ll->styles[eolPos]; ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, eolInSelection, false, styleMain, eolPos, ll); ColourDesired textFore = vsDraw.styles[styleMain].fore; if (eolInSelection && vsDraw.selforeset) { textFore = (eolInSelection == 1) ? vsDraw.selforeground : vsDraw.selAdditionalForeground; } if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1)) { if (alpha == SC_ALPHA_NOALPHA) { surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1)); } else { surface->FillRectangle(rcSegment, textBack); } } else { surface->FillRectangle(rcSegment, textBack); } DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, textBack, textFore, twoPhaseDraw); if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) { SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha); } } } // Draw the eol-is-selected rectangle rcSegment.left = xEol + xStart + virtualSpace + blobsWidth; rcSegment.right = rcSegment.left + vsDraw.aveCharWidth; if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) { surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1)); } else { if (overrideBackground) { surface->FillRectangle(rcSegment, background); } else if (line < pdoc->LinesTotal() - 1) { surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back); } else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) { surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back); } else { surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back); } if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) { SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha); } } // Fill the remainder of the line rcSegment.left = rcSegment.right; if (rcSegment.left < rcLine.left) rcSegment.left = rcLine.left; rcSegment.right = rcLine.right; if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) { surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1)); } else { if (overrideBackground) { surface->FillRectangle(rcSegment, background); } else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) { surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back); } else { surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back); } if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) { SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha); } } if (drawWrapMarkEnd) { PRectangle rcPlace = rcSegment; if (wrapVisualFlagsLocation & SC_WRAPVISUALFLAGLOC_END_BY_TEXT) { rcPlace.left = xEol + xStart + virtualSpace; rcPlace.right = rcPlace.left + vsDraw.aveCharWidth; } else { // draw left of the right text margin, to avoid clipping by the current clip rect rcPlace.right = rcLine.right - vs.rightMarginWidth; rcPlace.left = rcPlace.right - vsDraw.aveCharWidth; } DrawWrapMarker(surface, rcPlace, true, wrapColour); } } void Editor::DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, ViewStyle &vsDraw, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { const XYPOSITION subLineStart = ll->positions[ll->LineStart(subLine)]; PRectangle rcIndic( ll->positions[startPos] + xStart - subLineStart, rcLine.top + vsDraw.maxAscent, ll->positions[endPos] + xStart - subLineStart, rcLine.top + vsDraw.maxAscent + 3); vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine); } void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under) { // Draw decorators const int posLineStart = pdoc->LineStart(line); const int lineStart = ll->LineStart(subLine); const int posLineEnd = posLineStart + lineEnd; if (!under) { // Draw indicators // foreach indicator... for (int indicnum = 0, mask = 1 << pdoc->stylingBits; mask < 0x100; indicnum++) { if (!(mask & ll->styleBitsSet)) { mask <<= 1; continue; } int startPos = -1; // foreach style pos in line... for (int indicPos = lineStart; indicPos <= lineEnd; indicPos++) { // look for starts... if (startPos < 0) { // NOT in indicator run, looking for START if (indicPos < lineEnd && (ll->indicators[indicPos] & mask)) startPos = indicPos; } // ... or ends if (startPos >= 0) { // IN indicator run, looking for END if (indicPos >= lineEnd || !(ll->indicators[indicPos] & mask)) { // AT end of indicator run, DRAW it! DrawIndicator(indicnum, startPos, indicPos, surface, vsDraw, xStart, rcLine, ll, subLine); // RESET control var startPos = -1; } } } mask <<= 1; } } for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) { if (under == vsDraw.indicators[deco->indicator].under) { int startPos = posLineStart + lineStart; if (!deco->rs.ValueAt(startPos)) { startPos = deco->rs.EndRun(startPos); } while ((startPos < posLineEnd) && (deco->rs.ValueAt(startPos))) { int endPos = deco->rs.EndRun(startPos); if (endPos > posLineEnd) endPos = posLineEnd; DrawIndicator(deco->indicator, startPos - posLineStart, endPos - posLineStart, surface, vsDraw, xStart, rcLine, ll, subLine); startPos = deco->rs.EndRun(endPos); } } } // Use indicators to highlight matching braces if ((vs.braceHighlightIndicatorSet && (bracesMatchStyle == STYLE_BRACELIGHT)) || (vs.braceBadLightIndicatorSet && (bracesMatchStyle == STYLE_BRACEBAD))) { int braceIndicator = (bracesMatchStyle == STYLE_BRACELIGHT) ? vs.braceHighlightIndicator : vs.braceBadLightIndicator; if (under == vsDraw.indicators[braceIndicator].under) { Range rangeLine(posLineStart + lineStart, posLineEnd); if (rangeLine.ContainsCharacter(braces[0])) { int braceOffset = braces[0] - posLineStart; if (braceOffset < ll->numCharsInLine) { DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, xStart, rcLine, ll, subLine); } } if (rangeLine.ContainsCharacter(braces[1])) { int braceOffset = braces[1] - posLineStart; if (braceOffset < ll->numCharsInLine) { DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, xStart, rcLine, ll, subLine); } } } } } void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { int indent = pdoc->GetLineIndentation(line) * vsDraw.spaceWidth; PRectangle rcSegment = rcLine; int annotationLine = subLine - ll->lines; const StyledText stAnnotation = pdoc->AnnotationStyledText(line); if (stAnnotation.text && ValidStyledText(vsDraw, vsDraw.annotationStyleOffset, stAnnotation)) { surface->FillRectangle(rcSegment, vsDraw.styles[0].back); if (vs.annotationVisible == ANNOTATION_BOXED) { // Only care about calculating width if need to draw box int widthAnnotation = WidestLineWidth(surface, vsDraw, vsDraw.annotationStyleOffset, stAnnotation); widthAnnotation += vsDraw.spaceWidth * 2; // Margins rcSegment.left = xStart + indent; rcSegment.right = rcSegment.left + widthAnnotation; surface->PenColour(vsDraw.styles[vsDraw.annotationStyleOffset].fore); } else { rcSegment.left = xStart; } const int annotationLines = pdoc->AnnotationLines(line); size_t start = 0; size_t lengthAnnotation = stAnnotation.LineLength(start); int lineInAnnotation = 0; while ((lineInAnnotation < annotationLine) && (start < stAnnotation.length)) { start += lengthAnnotation + 1; lengthAnnotation = stAnnotation.LineLength(start); lineInAnnotation++; } PRectangle rcText = rcSegment; if (vs.annotationVisible == ANNOTATION_BOXED) { surface->FillRectangle(rcText, vsDraw.styles[stAnnotation.StyleAt(start) + vsDraw.annotationStyleOffset].back); rcText.left += vsDraw.spaceWidth; } DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, rcText.top + vsDraw.maxAscent, stAnnotation, start, lengthAnnotation); if (vs.annotationVisible == ANNOTATION_BOXED) { surface->MoveTo(rcSegment.left, rcSegment.top); surface->LineTo(rcSegment.left, rcSegment.bottom); surface->MoveTo(rcSegment.right, rcSegment.top); surface->LineTo(rcSegment.right, rcSegment.bottom); if (subLine == ll->lines) { surface->MoveTo(rcSegment.left, rcSegment.top); surface->LineTo(rcSegment.right, rcSegment.top); } if (subLine == ll->lines+annotationLines-1) { surface->MoveTo(rcSegment.left, rcSegment.bottom - 1); surface->LineTo(rcSegment.right, rcSegment.bottom - 1); } } } } void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { PRectangle rcSegment = rcLine; // Using one font for all control characters so it can be controlled independently to ensure // the box goes around the characters tightly. Seems to be no way to work out what height // is taken by an individual character - internal leading gives varying results. Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; // See if something overrides the line background color: Either if caret is on the line // and background color is set for that, or if a marker is defined that forces its background // color onto the line, or if a marker is defined but has no selection margin in which to // display itself (as long as it's not an SC_MARK_EMPTY marker). These are checked in order // with the earlier taking precedence. When multiple markers cause background override, // the color for the highest numbered one is used. bool overrideBackground = false; ColourDesired background; if (caret.active && vsDraw.showCaretLineBackground && (vsDraw.caretLineAlpha == SC_ALPHA_NOALPHA) && ll->containsCaret) { overrideBackground = true; background = vsDraw.caretLineBackground; } if (!overrideBackground) { int marks = pdoc->GetMark(line); for (int markBit = 0; (markBit < 32) && marks; markBit++) { if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) && (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) { background = vsDraw.markers[markBit].back; overrideBackground = true; } marks >>= 1; } } if (!overrideBackground) { if (vsDraw.maskInLine) { int marksMasked = pdoc->GetMark(line) & vsDraw.maskInLine; if (marksMasked) { for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) { if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY) && (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) { overrideBackground = true; background = vsDraw.markers[markBit].back; } marksMasked >>= 1; } } } } bool drawWhitespaceBackground = (vsDraw.viewWhitespace != wsInvisible) && (!overrideBackground) && (vsDraw.whitespaceBackgroundSet); bool inIndentation = subLine == 0; // Do not handle indentation except on first subline. const XYPOSITION indentWidth = pdoc->IndentSize() * vsDraw.spaceWidth; const XYPOSITION epsilon = 0.0001f; // A small nudge to avoid floating point precision issues int posLineStart = pdoc->LineStart(line); int startseg = ll->LineStart(subLine); XYACCUMULATOR subLineStart = ll->positions[startseg]; if (subLine >= ll->lines) { DrawAnnotation(surface, vsDraw, line, xStart, rcLine, ll, subLine); return; // No further drawing } int lineStart = 0; int lineEnd = 0; if (subLine < ll->lines) { lineStart = ll->LineStart(subLine); lineEnd = ll->LineStart(subLine + 1); if (subLine == ll->lines - 1) { lineEnd = ll->numCharsBeforeEOL; } } ColourDesired wrapColour = vsDraw.styles[STYLE_DEFAULT].fore; if (vsDraw.whitespaceForegroundSet) wrapColour = vsDraw.whitespaceForeground; bool drawWrapMarkEnd = false; if (wrapVisualFlags & SC_WRAPVISUALFLAG_END) { if (subLine + 1 < ll->lines) { drawWrapMarkEnd = ll->LineStart(subLine + 1) != 0; } } if (ll->wrapIndent != 0) { bool continuedWrapLine = false; if (subLine < ll->lines) { continuedWrapLine = ll->LineStart(subLine) != 0; } if (continuedWrapLine) { // draw continuation rect PRectangle rcPlace = rcSegment; rcPlace.left = ll->positions[startseg] + xStart - subLineStart; rcPlace.right = rcPlace.left + ll->wrapIndent; // default bgnd here.. surface->FillRectangle(rcSegment, overrideBackground ? background : vsDraw.styles[STYLE_DEFAULT].back); // main line style would be below but this would be inconsistent with end markers // also would possibly not be the style at wrap point //int styleMain = ll->styles[lineStart]; //surface->FillRectangle(rcPlace, vsDraw.styles[styleMain].back); if (wrapVisualFlags & SC_WRAPVISUALFLAG_START) { if (wrapVisualFlagsLocation & SC_WRAPVISUALFLAGLOC_START_BY_TEXT) rcPlace.left = rcPlace.right - vsDraw.aveCharWidth; else rcPlace.right = rcPlace.left + vsDraw.aveCharWidth; DrawWrapMarker(surface, rcPlace, false, wrapColour); } xStart += static_cast(ll->wrapIndent); } } bool selBackDrawn = vsDraw.selbackset && ((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA)); // Does not take margin into account but not significant int xStartVisible = static_cast(subLineStart) - xStart; ll->psel = &sel; BreakFinder bfBack(ll, lineStart, lineEnd, posLineStart, xStartVisible, selBackDrawn, pdoc); int next = bfBack.First(); // Background drawing loop while (twoPhaseDraw && (next < lineEnd)) { startseg = next; next = bfBack.Next(); int i = next - 1; int iDoc = i + posLineStart; rcSegment.left = ll->positions[startseg] + xStart - subLineStart; rcSegment.right = ll->positions[i + 1] + xStart - subLineStart; // Only try to draw if really visible - enhances performance by not calling environment to // draw strings that are completely past the right side of the window. if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) { // Clip to line rectangle, since may have a huge position which will not work with some platforms if (rcSegment.left < rcLine.left) rcSegment.left = rcLine.left; if (rcSegment.right > rcLine.right) rcSegment.right = rcLine.right; int styleMain = ll->styles[i]; const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc); bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd); ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll); if (ll->chars[i] == '\t') { // Tab display if (drawWhitespaceBackground && (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) textBack = vsDraw.whitespaceBackground; surface->FillRectangle(rcSegment, textBack); } else if (IsControlCharacter(ll->chars[i])) { // Control character display inIndentation = false; surface->FillRectangle(rcSegment, textBack); } else { // Normal text display surface->FillRectangle(rcSegment, textBack); if (vsDraw.viewWhitespace != wsInvisible || (inIndentation && vsDraw.viewIndentationGuides == ivReal)) { for (int cpos = 0; cpos <= i - startseg; cpos++) { if (ll->chars[cpos + startseg] == ' ') { if (drawWhitespaceBackground && (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { PRectangle rcSpace(ll->positions[cpos + startseg] + xStart - subLineStart, rcSegment.top, ll->positions[cpos + startseg + 1] + xStart - subLineStart, rcSegment.bottom); surface->FillRectangle(rcSpace, vsDraw.whitespaceBackground); } } else { inIndentation = false; } } } } } else if (rcSegment.left > rcLine.right) { break; } } if (twoPhaseDraw) { DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd, xStart, subLine, subLineStart, overrideBackground, background, drawWrapMarkEnd, wrapColour); } DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, true); if (vsDraw.edgeState == EDGE_LINE) { int edgeX = theEdge * vsDraw.spaceWidth; rcSegment.left = edgeX + xStart; if ((ll->wrapIndent != 0) && (lineStart != 0)) rcSegment.left -= ll->wrapIndent; rcSegment.right = rcSegment.left + 1; surface->FillRectangle(rcSegment, vsDraw.edgecolour); } // Draw underline mark as part of background if not transparent int marks = pdoc->GetMark(line); int markBit; for (markBit = 0; (markBit < 32) && marks; markBit++) { if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE) && (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) { PRectangle rcUnderline = rcLine; rcUnderline.top = rcUnderline.bottom - 2; surface->FillRectangle(rcUnderline, vsDraw.markers[markBit].back); } marks >>= 1; } inIndentation = subLine == 0; // Do not handle indentation except on first subline. // Foreground drawing loop BreakFinder bfFore(ll, lineStart, lineEnd, posLineStart, xStartVisible, ((!twoPhaseDraw && selBackDrawn) || vsDraw.selforeset), pdoc); next = bfFore.First(); while (next < lineEnd) { startseg = next; next = bfFore.Next(); int i = next - 1; int iDoc = i + posLineStart; rcSegment.left = ll->positions[startseg] + xStart - subLineStart; rcSegment.right = ll->positions[i + 1] + xStart - subLineStart; // Only try to draw if really visible - enhances performance by not calling environment to // draw strings that are completely past the right side of the window. if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) { int styleMain = ll->styles[i]; ColourDesired textFore = vsDraw.styles[styleMain].fore; Font &textFont = vsDraw.styles[styleMain].font; //hotspot foreground if (ll->hsStart != -1 && iDoc >= ll->hsStart && iDoc < hsEnd) { if (vsDraw.hotspotForegroundSet) textFore = vsDraw.hotspotForeground; } const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc); if (inSelection && (vsDraw.selforeset)) { textFore = (inSelection == 1) ? vsDraw.selforeground : vsDraw.selAdditionalForeground; } bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd); ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll); if (ll->chars[i] == '\t') { // Tab display if (!twoPhaseDraw) { if (drawWhitespaceBackground && (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) textBack = vsDraw.whitespaceBackground; surface->FillRectangle(rcSegment, textBack); } if ((vsDraw.viewWhitespace != wsInvisible) || (inIndentation && vsDraw.viewIndentationGuides != ivNone)) { if (vsDraw.whitespaceForegroundSet) textFore = vsDraw.whitespaceForeground; surface->PenColour(textFore); } if (inIndentation && vsDraw.viewIndentationGuides == ivReal) { for (int indentCount = (ll->positions[i] + epsilon) / indentWidth; indentCount <= (ll->positions[i + 1] - epsilon) / indentWidth; indentCount++) { if (indentCount > 0) { int xIndent = indentCount * indentWidth; DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, (ll->xHighlightGuide == xIndent)); } } } if (vsDraw.viewWhitespace != wsInvisible) { if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) { PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4, rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent); DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2); } } } else if (IsControlCharacter(ll->chars[i])) { // Control character display inIndentation = false; if (controlCharSymbol < 32) { // Draw the character const char *ctrlChar = ControlCharacterString(ll->chars[i]); DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, textBack, textFore, twoPhaseDraw); } else { char cc[2] = { static_cast(controlCharSymbol), '\0' }; surface->DrawTextNoClip(rcSegment, ctrlCharsFont, rcSegment.top + vsDraw.maxAscent, cc, 1, textBack, textFore); } } else if ((i == startseg) && (static_cast(ll->chars[i]) >= 0x80) && IsUnicodeMode()) { // A single byte >= 0x80 in UTF-8 is a bad byte and is displayed as its hex value char hexits[4]; sprintf(hexits, "x%2X", ll->chars[i] & 0xff); DrawTextBlob(surface, vsDraw, rcSegment, hexits, textBack, textFore, twoPhaseDraw); } else { // Normal text display if (vsDraw.styles[styleMain].visible) { if (twoPhaseDraw) { surface->DrawTextTransparent(rcSegment, textFont, rcSegment.top + vsDraw.maxAscent, ll->chars + startseg, i - startseg + 1, textFore); } else { surface->DrawTextNoClip(rcSegment, textFont, rcSegment.top + vsDraw.maxAscent, ll->chars + startseg, i - startseg + 1, textFore, textBack); } } if (vsDraw.viewWhitespace != wsInvisible || (inIndentation && vsDraw.viewIndentationGuides != ivNone)) { for (int cpos = 0; cpos <= i - startseg; cpos++) { if (ll->chars[cpos + startseg] == ' ') { if (vsDraw.viewWhitespace != wsInvisible) { if (vsDraw.whitespaceForegroundSet) textFore = vsDraw.whitespaceForeground; if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) { XYPOSITION xmid = (ll->positions[cpos + startseg] + ll->positions[cpos + startseg + 1]) / 2; if (!twoPhaseDraw && drawWhitespaceBackground && (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { textBack = vsDraw.whitespaceBackground; PRectangle rcSpace(ll->positions[cpos + startseg] + xStart - subLineStart, rcSegment.top, ll->positions[cpos + startseg + 1] + xStart - subLineStart, rcSegment.bottom); surface->FillRectangle(rcSpace, textBack); } PRectangle rcDot(xmid + xStart - subLineStart, rcSegment.top + vsDraw.lineHeight / 2, 0, 0); rcDot.right = rcDot.left + vs.whitespaceSize; rcDot.bottom = rcDot.top + vs.whitespaceSize; surface->FillRectangle(rcDot, textFore); } } if (inIndentation && vsDraw.viewIndentationGuides == ivReal) { for (int indentCount = (ll->positions[cpos + startseg] + epsilon) / indentWidth; indentCount <= (ll->positions[cpos + startseg + 1] - epsilon) / indentWidth; indentCount++) { if (indentCount > 0) { int xIndent = indentCount * indentWidth; DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, (ll->xHighlightGuide == xIndent)); } } } } else { inIndentation = false; } } } } if (ll->hsStart != -1 && vsDraw.hotspotUnderline && iDoc >= ll->hsStart && iDoc < ll->hsEnd) { PRectangle rcUL = rcSegment; rcUL.top = rcUL.top + vsDraw.maxAscent + 1; rcUL.bottom = rcUL.top + 1; if (vsDraw.hotspotForegroundSet) surface->FillRectangle(rcUL, vsDraw.hotspotForeground); else surface->FillRectangle(rcUL, textFore); } else if (vsDraw.styles[styleMain].underline) { PRectangle rcUL = rcSegment; rcUL.top = rcUL.top + vsDraw.maxAscent + 1; rcUL.bottom = rcUL.top + 1; surface->FillRectangle(rcUL, textFore); } } else if (rcSegment.left > rcLine.right) { break; } } if ((vsDraw.viewIndentationGuides == ivLookForward || vsDraw.viewIndentationGuides == ivLookBoth) && (subLine == 0)) { int indentSpace = pdoc->GetLineIndentation(line); int xStartText = ll->positions[pdoc->GetLineIndentPosition(line) - posLineStart]; // Find the most recent line with some text int lineLastWithText = line; while (lineLastWithText > Platform::Maximum(line-20, 0) && pdoc->IsWhiteLine(lineLastWithText)) { lineLastWithText--; } if (lineLastWithText < line) { xStartText = 100000; // Don't limit to visible indentation on empty line // This line is empty, so use indentation of last line with text int indentLastWithText = pdoc->GetLineIndentation(lineLastWithText); int isFoldHeader = pdoc->GetLevel(lineLastWithText) & SC_FOLDLEVELHEADERFLAG; if (isFoldHeader) { // Level is one more level than parent indentLastWithText += pdoc->IndentSize(); } if (vsDraw.viewIndentationGuides == ivLookForward) { // In viLookForward mode, previous line only used if it is a fold header if (isFoldHeader) { indentSpace = Platform::Maximum(indentSpace, indentLastWithText); } } else { // viLookBoth indentSpace = Platform::Maximum(indentSpace, indentLastWithText); } } int lineNextWithText = line; while (lineNextWithText < Platform::Minimum(line+20, pdoc->LinesTotal()) && pdoc->IsWhiteLine(lineNextWithText)) { lineNextWithText++; } if (lineNextWithText > line) { xStartText = 100000; // Don't limit to visible indentation on empty line // This line is empty, so use indentation of first next line with text indentSpace = Platform::Maximum(indentSpace, pdoc->GetLineIndentation(lineNextWithText)); } for (int indentPos = pdoc->IndentSize(); indentPos < indentSpace; indentPos += pdoc->IndentSize()) { int xIndent = indentPos * vsDraw.spaceWidth; if (xIndent < xStartText) { DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, (ll->xHighlightGuide == xIndent)); } } } DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, false); // End of the drawing of the current line if (!twoPhaseDraw) { DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd, xStart, subLine, subLineStart, overrideBackground, background, drawWrapMarkEnd, wrapColour); } if (!hideSelection && ((vsDraw.selAlpha != SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha != SC_ALPHA_NOALPHA))) { // For each selection draw int virtualSpaces = 0; if (subLine == (ll->lines - 1)) { virtualSpaces = sel.VirtualSpaceFor(pdoc->LineEnd(line)); } SelectionPosition posStart(posLineStart); SelectionPosition posEnd(posLineStart + lineEnd, virtualSpaces); SelectionSegment virtualSpaceRange(posStart, posEnd); for (size_t r=0; rEndLineStyle()].spaceWidth; rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth; rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth; rcSegment.left = (rcSegment.left > rcLine.left) ? rcSegment.left : rcLine.left; rcSegment.right = (rcSegment.right < rcLine.right) ? rcSegment.right : rcLine.right; SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, r == sel.Main()), alpha); } } } } // Draw any translucent whole line states rcSegment.left = 0; rcSegment.right = rcLine.right - 1; if (caret.active && vsDraw.showCaretLineBackground && ll->containsCaret) { SimpleAlphaRectangle(surface, rcSegment, vsDraw.caretLineBackground, vsDraw.caretLineAlpha); } marks = pdoc->GetMark(line); for (markBit = 0; (markBit < 32) && marks; markBit++) { if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND)) { SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); } else if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE)) { PRectangle rcUnderline = rcSegment; rcUnderline.top = rcUnderline.bottom - 2; SimpleAlphaRectangle(surface, rcUnderline, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); } marks >>= 1; } if (vsDraw.maskInLine) { int marksMasked = pdoc->GetMark(line) & vsDraw.maskInLine; if (marksMasked) { for (markBit = 0; (markBit < 32) && marksMasked; markBit++) { if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY)) { SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); } marksMasked >>= 1; } } } } void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour) { int lineStart = ll->LineStart(subLine); int posBefore = posCaret; int posAfter = MovePositionOutsideChar(posCaret + 1, 1); int numCharsToDraw = posAfter - posCaret; // Work out where the starting and ending offsets are. We need to // see if the previous character shares horizontal space, such as a // glyph / combining character. If so we'll need to draw that too. int offsetFirstChar = offset; int offsetLastChar = offset + (posAfter - posCaret); while ((offsetLastChar - numCharsToDraw) >= lineStart) { if ((ll->positions[offsetLastChar] - ll->positions[offsetLastChar - numCharsToDraw]) > 0) { // The char does not share horizontal space break; } // Char shares horizontal space, update the numChars to draw // Update posBefore to point to the prev char posBefore = MovePositionOutsideChar(posBefore - 1, -1); numCharsToDraw = posAfter - posBefore; offsetFirstChar = offset - (posCaret - posBefore); } // See if the next character shares horizontal space, if so we'll // need to draw that too. numCharsToDraw = offsetLastChar - offsetFirstChar; while ((offsetLastChar < ll->LineStart(subLine + 1)) && (offsetLastChar <= ll->numCharsInLine)) { // Update posAfter to point to the 2nd next char, this is where // the next character ends, and 2nd next begins. We'll need // to compare these two posBefore = posAfter; posAfter = MovePositionOutsideChar(posAfter + 1, 1); offsetLastChar = offset + (posAfter - posCaret); if ((ll->positions[offsetLastChar] - ll->positions[offsetLastChar - (posAfter - posBefore)]) > 0) { // The char does not share horizontal space break; } // Char shares horizontal space, update the numChars to draw numCharsToDraw = offsetLastChar - offsetFirstChar; } // We now know what to draw, update the caret drawing rectangle rcCaret.left = ll->positions[offsetFirstChar] - ll->positions[lineStart] + xStart; rcCaret.right = ll->positions[offsetFirstChar+numCharsToDraw] - ll->positions[lineStart] + xStart; // Adjust caret position to take into account any word wrapping symbols. if ((ll->wrapIndent != 0) && (lineStart != 0)) { XYPOSITION wordWrapCharWidth = ll->wrapIndent; rcCaret.left += wordWrapCharWidth; rcCaret.right += wordWrapCharWidth; } // This character is where the caret block is, we override the colours // (inversed) for drawing the caret here. int styleMain = ll->styles[offsetFirstChar]; surface->DrawTextClipped(rcCaret, vsDraw.styles[styleMain].font, rcCaret.top + vsDraw.maxAscent, ll->chars + offsetFirstChar, numCharsToDraw, vsDraw.styles[styleMain].back, caretColour); } void Editor::RefreshPixMaps(Surface *surfaceWindow) { if (!pixmapSelPattern->Initialised()) { const int patternSize = 8; pixmapSelPattern->InitPixMap(patternSize, patternSize, surfaceWindow, wMain.GetID()); // This complex procedure is to reproduce the checkerboard dithered pattern used by windows // for scroll bars and Visual Studio for its selection margin. The colour of this pattern is half // way between the chrome colour and the chrome highlight colour making a nice transition // between the window chrome and the content area. And it works in low colour depths. PRectangle rcPattern(0, 0, patternSize, patternSize); // Initialize default colours based on the chrome colour scheme. Typically the highlight is white. ColourDesired colourFMFill = vs.selbar; ColourDesired colourFMStripes = vs.selbarlight; if (!(vs.selbarlight == ColourDesired(0xff, 0xff, 0xff))) { // User has chosen an unusual chrome colour scheme so just use the highlight edge colour. // (Typically, the highlight colour is white.) colourFMFill = vs.selbarlight; } if (vs.foldmarginColourSet) { // override default fold margin colour colourFMFill = vs.foldmarginColour; } if (vs.foldmarginHighlightColourSet) { // override default fold margin highlight colour colourFMStripes = vs.foldmarginHighlightColour; } pixmapSelPattern->FillRectangle(rcPattern, colourFMFill); for (int y = 0; y < patternSize; y++) { for (int x = y % 2; x < patternSize; x+=2) { PRectangle rcPixel(x, y, x+1, y+1); pixmapSelPattern->FillRectangle(rcPixel, colourFMStripes); } } } if (!pixmapIndentGuide->Initialised()) { // 1 extra pixel in height so can handle odd/even positions and so produce a continuous line pixmapIndentGuide->InitPixMap(1, vs.lineHeight + 1, surfaceWindow, wMain.GetID()); pixmapIndentGuideHighlight->InitPixMap(1, vs.lineHeight + 1, surfaceWindow, wMain.GetID()); PRectangle rcIG(0, 0, 1, vs.lineHeight); pixmapIndentGuide->FillRectangle(rcIG, vs.styles[STYLE_INDENTGUIDE].back); pixmapIndentGuide->PenColour(vs.styles[STYLE_INDENTGUIDE].fore); pixmapIndentGuideHighlight->FillRectangle(rcIG, vs.styles[STYLE_BRACELIGHT].back); pixmapIndentGuideHighlight->PenColour(vs.styles[STYLE_BRACELIGHT].fore); for (int stripe = 1; stripe < vs.lineHeight + 1; stripe += 2) { PRectangle rcPixel(0, stripe, 1, stripe+1); pixmapIndentGuide->FillRectangle(rcPixel, vs.styles[STYLE_INDENTGUIDE].fore); pixmapIndentGuideHighlight->FillRectangle(rcPixel, vs.styles[STYLE_BRACELIGHT].fore); } } if (bufferedDraw) { if (!pixmapLine->Initialised()) { PRectangle rcClient = GetClientRectangle(); pixmapLine->InitPixMap(rcClient.Width(), vs.lineHeight, surfaceWindow, wMain.GetID()); pixmapSelMargin->InitPixMap(vs.fixedColumnWidth, rcClient.Height(), surfaceWindow, wMain.GetID()); } } } void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { // When drag is active it is the only caret drawn bool drawDrag = posDrag.IsValid(); if (hideSelection && !drawDrag) return; const int posLineStart = pdoc->LineStart(lineDoc); // For each selection draw for (size_t r=0; (rEndLineStyle()].spaceWidth; const XYPOSITION virtualOffset = posCaret.VirtualSpace() * spaceWidth; if (ll->InLine(offset, subLine) && offset <= ll->numCharsBeforeEOL) { XYPOSITION xposCaret = ll->positions[offset] + virtualOffset - ll->positions[ll->LineStart(subLine)]; if (ll->wrapIndent != 0) { int lineStart = ll->LineStart(subLine); if (lineStart != 0) // Wrapped xposCaret += ll->wrapIndent; } bool caretBlinkState = (caret.active && caret.on) || (!additionalCaretsBlink && !mainCaret); bool caretVisibleState = additionalCaretsVisible || mainCaret; if ((xposCaret >= 0) && (vsDraw.caretWidth > 0) && (vsDraw.caretStyle != CARETSTYLE_INVISIBLE) && ((posDrag.IsValid()) || (caretBlinkState && caretVisibleState))) { bool caretAtEOF = false; bool caretAtEOL = false; bool drawBlockCaret = false; XYPOSITION widthOverstrikeCaret; int caretWidthOffset = 0; PRectangle rcCaret = rcLine; if (posCaret.Position() == pdoc->Length()) { // At end of document caretAtEOF = true; widthOverstrikeCaret = vsDraw.aveCharWidth; } else if ((posCaret.Position() - posLineStart) >= ll->numCharsInLine) { // At end of line caretAtEOL = true; widthOverstrikeCaret = vsDraw.aveCharWidth; } else { widthOverstrikeCaret = ll->positions[offset + 1] - ll->positions[offset]; } if (widthOverstrikeCaret < 3) // Make sure its visible widthOverstrikeCaret = 3; if (xposCaret > 0) caretWidthOffset = 1; // Move back so overlaps both character cells. xposCaret += xStart; if (posDrag.IsValid()) { /* Dragging text, use a line caret */ rcCaret.left = xposCaret - caretWidthOffset; rcCaret.right = rcCaret.left + vsDraw.caretWidth; } else if (inOverstrike) { /* Overstrike (insert mode), use a modified bar caret */ rcCaret.top = rcCaret.bottom - 2; rcCaret.left = xposCaret + 1; rcCaret.right = rcCaret.left + widthOverstrikeCaret - 1; } else if (vsDraw.caretStyle == CARETSTYLE_BLOCK) { /* Block caret */ rcCaret.left = xposCaret; if (!caretAtEOL && !caretAtEOF && (ll->chars[offset] != '\t') && !(IsControlCharacter(ll->chars[offset]))) { drawBlockCaret = true; rcCaret.right = xposCaret + widthOverstrikeCaret; } else { rcCaret.right = xposCaret + vsDraw.aveCharWidth; } } else { /* Line caret */ rcCaret.left = xposCaret - caretWidthOffset; rcCaret.right = rcCaret.left + vsDraw.caretWidth; } ColourDesired caretColour = mainCaret ? vsDraw.caretcolour : vsDraw.additionalCaretColour; if (drawBlockCaret) { DrawBlockCaret(surface, vsDraw, ll, subLine, xStart, offset, posCaret.Position(), rcCaret, caretColour); } else { surface->FillRectangle(rcCaret, caretColour); } } } if (drawDrag) break; } } void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { //Platform::DebugPrintf("Paint:%1d (%3d,%3d) ... (%3d,%3d)\n", // paintingAllText, rcArea.left, rcArea.top, rcArea.right, rcArea.bottom); AllocateGraphics(); StyleToPositionInView(PositionAfterArea(rcArea)); pixmapLine->Release(); RefreshStyleData(); RefreshPixMaps(surfaceWindow); PRectangle rcClient = GetClientRectangle(); //Platform::DebugPrintf("Client: (%3d,%3d) ... (%3d,%3d) %d\n", // rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); int screenLinePaintFirst = rcArea.top / vs.lineHeight; int xStart = vs.fixedColumnWidth - xOffset; int ypos = 0; if (!bufferedDraw) ypos += screenLinePaintFirst * vs.lineHeight; int yposScreen = screenLinePaintFirst * vs.lineHeight; bool paintAbandonedByStyling = paintState == paintAbandoned; if (needUpdateUI) { NotifyUpdateUI(); needUpdateUI = 0; RefreshStyleData(); RefreshPixMaps(surfaceWindow); } // Call priority lines wrap on a window of lines which are likely // to rendered with the following paint (that is wrap the visible // lines first). int startLineToWrap = cs.DocFromDisplay(topLine) - 5; if (startLineToWrap < 0) startLineToWrap = 0; if (WrapLines(false, startLineToWrap)) { // The wrapping process has changed the height of some lines so // abandon this paint for a complete repaint. if (AbandonPaint()) { return; } RefreshPixMaps(surfaceWindow); // In case pixmaps invalidated by scrollbar change } PLATFORM_ASSERT(pixmapSelPattern->Initialised()); if (!bufferedDraw) surfaceWindow->SetClip(rcArea); if (paintState != paintAbandoned) { PaintSelMargin(surfaceWindow, rcArea); PRectangle rcRightMargin = rcClient; rcRightMargin.left = rcRightMargin.right - vs.rightMarginWidth; if (rcArea.Intersects(rcRightMargin)) { surfaceWindow->FillRectangle(rcRightMargin, vs.styles[STYLE_DEFAULT].back); } } if (paintState == paintAbandoned) { // Either styling or NotifyUpdateUI noticed that painting is needed // outside the current painting rectangle //Platform::DebugPrintf("Abandoning paint\n"); if (wrapState != eWrapNone) { if (paintAbandonedByStyling) { // Styling has spilled over a line end, such as occurs by starting a multiline // comment. The width of subsequent text may have changed, so rewrap. NeedWrapping(cs.DocFromDisplay(topLine)); } } return; } //Platform::DebugPrintf("start display %d, offset = %d\n", pdoc->Length(), xOffset); // Do the painting if (rcArea.right > vs.fixedColumnWidth) { Surface *surface = surfaceWindow; if (bufferedDraw) { surface = pixmapLine; PLATFORM_ASSERT(pixmapLine->Initialised()); } surface->SetUnicodeMode(IsUnicodeMode()); surface->SetDBCSMode(CodePage()); int visibleLine = topLine + screenLinePaintFirst; SelectionPosition posCaret = sel.RangeMain().caret; if (posDrag.IsValid()) posCaret = posDrag; int lineCaret = pdoc->LineFromPosition(posCaret.Position()); // Remove selection margin from drawing area so text will not be drawn // on it in unbuffered mode. if (!bufferedDraw) { PRectangle rcTextArea = rcClient; rcTextArea.left = vs.fixedColumnWidth; rcTextArea.right -= vs.rightMarginWidth; surfaceWindow->SetClip(rcTextArea); } // Loop on visible lines //double durLayout = 0.0; //double durPaint = 0.0; //double durCopy = 0.0; //ElapsedTime etWhole; int lineDocPrevious = -1; // Used to avoid laying out one document line multiple times AutoLineLayout ll(llc, 0); while (visibleLine < cs.LinesDisplayed() && yposScreen < rcArea.bottom) { int lineDoc = cs.DocFromDisplay(visibleLine); // Only visible lines should be handled by the code within the loop PLATFORM_ASSERT(cs.GetVisible(lineDoc)); int lineStartSet = cs.DisplayFromDoc(lineDoc); int subLine = visibleLine - lineStartSet; // Copy this line and its styles from the document into local arrays // and determine the x position at which each character starts. //ElapsedTime et; if (lineDoc != lineDocPrevious) { ll.Set(0); ll.Set(RetrieveLineLayout(lineDoc)); LayoutLine(lineDoc, surface, vs, ll, wrapWidth); lineDocPrevious = lineDoc; } //durLayout += et.Duration(true); if (ll) { ll->containsCaret = lineDoc == lineCaret; if (hideSelection) { ll->containsCaret = false; } GetHotSpotRange(ll->hsStart, ll->hsEnd); PRectangle rcLine = rcClient; rcLine.top = ypos; rcLine.bottom = ypos + vs.lineHeight; bool bracesIgnoreStyle = false; if ((vs.braceHighlightIndicatorSet && (bracesMatchStyle == STYLE_BRACELIGHT)) || (vs.braceBadLightIndicatorSet && (bracesMatchStyle == STYLE_BRACEBAD))) { bracesIgnoreStyle = true; } Range rangeLine(pdoc->LineStart(lineDoc), pdoc->LineStart(lineDoc + 1)); // Highlight the current braces if any ll->SetBracesHighlight(rangeLine, braces, static_cast(bracesMatchStyle), highlightGuideColumn * vs.spaceWidth, bracesIgnoreStyle); // Draw the line DrawLine(surface, vs, lineDoc, visibleLine, xStart, rcLine, ll, subLine); //durPaint += et.Duration(true); // Restore the previous styles for the brace highlights in case layout is in cache. ll->RestoreBracesHighlight(rangeLine, braces, bracesIgnoreStyle); bool expanded = cs.GetExpanded(lineDoc); const int level = pdoc->GetLevel(lineDoc); const int levelNext = pdoc->GetLevel(lineDoc + 1); if ((level & SC_FOLDLEVELHEADERFLAG) && ((level & SC_FOLDLEVELNUMBERMASK) < (levelNext & SC_FOLDLEVELNUMBERMASK))) { // Paint the line above the fold if ((expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_EXPANDED)) || (!expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_CONTRACTED))) { PRectangle rcFoldLine = rcLine; rcFoldLine.bottom = rcFoldLine.top + 1; surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore); } // Paint the line below the fold if ((expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_EXPANDED)) || (!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) { PRectangle rcFoldLine = rcLine; rcFoldLine.top = rcFoldLine.bottom - 1; surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore); } } DrawCarets(surface, vs, lineDoc, xStart, rcLine, ll, subLine); if (bufferedDraw) { Point from(vs.fixedColumnWidth, 0); PRectangle rcCopyArea(vs.fixedColumnWidth, yposScreen, rcClient.right - vs.rightMarginWidth, yposScreen + vs.lineHeight); surfaceWindow->Copy(rcCopyArea, from, *pixmapLine); } lineWidthMaxSeen = Platform::Maximum( lineWidthMaxSeen, ll->positions[ll->numCharsInLine]); //durCopy += et.Duration(true); } if (!bufferedDraw) { ypos += vs.lineHeight; } yposScreen += vs.lineHeight; visibleLine++; //gdk_flush(); } ll.Set(0); //if (durPaint < 0.00000001) // durPaint = 0.00000001; // Right column limit indicator PRectangle rcBeyondEOF = rcClient; rcBeyondEOF.left = vs.fixedColumnWidth; rcBeyondEOF.right = rcBeyondEOF.right; rcBeyondEOF.top = (cs.LinesDisplayed() - topLine) * vs.lineHeight; if (rcBeyondEOF.top < rcBeyondEOF.bottom) { surfaceWindow->FillRectangle(rcBeyondEOF, vs.styles[STYLE_DEFAULT].back); if (vs.edgeState == EDGE_LINE) { int edgeX = theEdge * vs.spaceWidth; rcBeyondEOF.left = edgeX + xStart; rcBeyondEOF.right = rcBeyondEOF.left + 1; surfaceWindow->FillRectangle(rcBeyondEOF, vs.edgecolour); } } //Platform::DebugPrintf( //"Layout:%9.6g Paint:%9.6g Ratio:%9.6g Copy:%9.6g Total:%9.6g\n", //durLayout, durPaint, durLayout / durPaint, durCopy, etWhole.Duration()); NotifyPainted(); } } // Space (3 space characters) between line numbers and text when printing. #define lineNumberPrintSpace " " ColourDesired InvertedLight(ColourDesired orig) { unsigned int r = orig.GetRed(); unsigned int g = orig.GetGreen(); unsigned int b = orig.GetBlue(); unsigned int l = (r + g + b) / 3; // There is a better calculation for this that matches human eye unsigned int il = 0xff - l; if (l == 0) return ColourDesired(0xff, 0xff, 0xff); r = r * il / l; g = g * il / l; b = b * il / l; return ColourDesired(Platform::Minimum(r, 0xff), Platform::Minimum(g, 0xff), Platform::Minimum(b, 0xff)); } // This is mostly copied from the Paint method but with some things omitted // such as the margin markers, line numbers, selection and caret // Should be merged back into a combined Draw method. long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { if (!pfr) return 0; AutoSurface surface(pfr->hdc, this); if (!surface) return 0; AutoSurface surfaceMeasure(pfr->hdcTarget, this); if (!surfaceMeasure) { return 0; } // Can't use measurements cached for screen posCache.Clear(); ViewStyle vsPrint(vs); // Modify the view style for printing as do not normally want any of the transient features to be printed // Printing supports only the line number margin. int lineNumberIndex = -1; for (int margin = 0; margin < ViewStyle::margins; margin++) { if ((vsPrint.ms[margin].style == SC_MARGIN_NUMBER) && (vsPrint.ms[margin].width > 0)) { lineNumberIndex = margin; } else { vsPrint.ms[margin].width = 0; } } vsPrint.showMarkedLines = false; vsPrint.fixedColumnWidth = 0; vsPrint.zoomLevel = printMagnification; vsPrint.viewIndentationGuides = ivNone; // Don't show the selection when printing vsPrint.selbackset = false; vsPrint.selforeset = false; vsPrint.selAlpha = SC_ALPHA_NOALPHA; vsPrint.selAdditionalAlpha = SC_ALPHA_NOALPHA; vsPrint.whitespaceBackgroundSet = false; vsPrint.whitespaceForegroundSet = false; vsPrint.showCaretLineBackground = false; // Don't highlight matching braces using indicators vsPrint.braceHighlightIndicatorSet = false; vsPrint.braceBadLightIndicatorSet = false; // Set colours for printing according to users settings for (size_t sty = 0; sty < vsPrint.stylesSize; sty++) { if (printColourMode == SC_PRINT_INVERTLIGHT) { vsPrint.styles[sty].fore = InvertedLight(vsPrint.styles[sty].fore); vsPrint.styles[sty].back = InvertedLight(vsPrint.styles[sty].back); } else if (printColourMode == SC_PRINT_BLACKONWHITE) { vsPrint.styles[sty].fore = ColourDesired(0, 0, 0); vsPrint.styles[sty].back = ColourDesired(0xff, 0xff, 0xff); } else if (printColourMode == SC_PRINT_COLOURONWHITE) { vsPrint.styles[sty].back = ColourDesired(0xff, 0xff, 0xff); } else if (printColourMode == SC_PRINT_COLOURONWHITEDEFAULTBG) { if (sty <= STYLE_DEFAULT) { vsPrint.styles[sty].back = ColourDesired(0xff, 0xff, 0xff); } } } // White background for the line numbers vsPrint.styles[STYLE_LINENUMBER].back = ColourDesired(0xff, 0xff, 0xff); vsPrint.Refresh(*surfaceMeasure); // Determining width must hapen after fonts have been realised in Refresh int lineNumberWidth = 0; if (lineNumberIndex >= 0) { lineNumberWidth = surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, "99999" lineNumberPrintSpace, 5 + istrlen(lineNumberPrintSpace)); vsPrint.ms[lineNumberIndex].width = lineNumberWidth; vsPrint.Refresh(*surfaceMeasure); // Recalculate fixedColumnWidth } int linePrintStart = pdoc->LineFromPosition(pfr->chrg.cpMin); int linePrintLast = linePrintStart + (pfr->rc.bottom - pfr->rc.top) / vsPrint.lineHeight - 1; if (linePrintLast < linePrintStart) linePrintLast = linePrintStart; int linePrintMax = pdoc->LineFromPosition(pfr->chrg.cpMax); if (linePrintLast > linePrintMax) linePrintLast = linePrintMax; //Platform::DebugPrintf("Formatting lines=[%0d,%0d,%0d] top=%0d bottom=%0d line=%0d %0d\n", // linePrintStart, linePrintLast, linePrintMax, pfr->rc.top, pfr->rc.bottom, vsPrint.lineHeight, // surfaceMeasure->Height(vsPrint.styles[STYLE_LINENUMBER].font)); int endPosPrint = pdoc->Length(); if (linePrintLast < pdoc->LinesTotal()) endPosPrint = pdoc->LineStart(linePrintLast + 1); // Ensure we are styled to where we are formatting. pdoc->EnsureStyledTo(endPosPrint); int xStart = vsPrint.fixedColumnWidth + pfr->rc.left; int ypos = pfr->rc.top; int lineDoc = linePrintStart; int nPrintPos = pfr->chrg.cpMin; int visibleLine = 0; int widthPrint = pfr->rc.right - pfr->rc.left - vsPrint.fixedColumnWidth; if (printWrapState == eWrapNone) widthPrint = LineLayout::wrapWidthInfinite; while (lineDoc <= linePrintLast && ypos < pfr->rc.bottom) { // When printing, the hdc and hdcTarget may be the same, so // changing the state of surfaceMeasure may change the underlying // state of surface. Therefore, any cached state is discarded before // using each surface. surfaceMeasure->FlushCachedState(); // Copy this line and its styles from the document into local arrays // and determine the x position at which each character starts. LineLayout ll(8000); LayoutLine(lineDoc, surfaceMeasure, vsPrint, &ll, widthPrint); ll.containsCaret = false; PRectangle rcLine; rcLine.left = pfr->rc.left; rcLine.top = ypos; rcLine.right = pfr->rc.right - 1; rcLine.bottom = ypos + vsPrint.lineHeight; // When document line is wrapped over multiple display lines, find where // to start printing from to ensure a particular position is on the first // line of the page. if (visibleLine == 0) { int startWithinLine = nPrintPos - pdoc->LineStart(lineDoc); for (int iwl = 0; iwl < ll.lines - 1; iwl++) { if (ll.LineStart(iwl) <= startWithinLine && ll.LineStart(iwl + 1) >= startWithinLine) { visibleLine = -iwl; } } if (ll.lines > 1 && startWithinLine >= ll.LineStart(ll.lines - 1)) { visibleLine = -(ll.lines - 1); } } if (draw && lineNumberWidth && (ypos + vsPrint.lineHeight <= pfr->rc.bottom) && (visibleLine >= 0)) { char number[100]; sprintf(number, "%d" lineNumberPrintSpace, lineDoc + 1); PRectangle rcNumber = rcLine; rcNumber.right = rcNumber.left + lineNumberWidth; // Right justify rcNumber.left = rcNumber.right - surfaceMeasure->WidthText( vsPrint.styles[STYLE_LINENUMBER].font, number, istrlen(number)); surface->FlushCachedState(); surface->DrawTextNoClip(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font, ypos + vsPrint.maxAscent, number, istrlen(number), vsPrint.styles[STYLE_LINENUMBER].fore, vsPrint.styles[STYLE_LINENUMBER].back); } // Draw the line surface->FlushCachedState(); for (int iwl = 0; iwl < ll.lines; iwl++) { if (ypos + vsPrint.lineHeight <= pfr->rc.bottom) { if (visibleLine >= 0) { if (draw) { rcLine.top = ypos; rcLine.bottom = ypos + vsPrint.lineHeight; DrawLine(surface, vsPrint, lineDoc, visibleLine, xStart, rcLine, &ll, iwl); } ypos += vsPrint.lineHeight; } visibleLine++; if (iwl == ll.lines - 1) nPrintPos = pdoc->LineStart(lineDoc + 1); else nPrintPos += ll.LineStart(iwl + 1) - ll.LineStart(iwl); } } ++lineDoc; } // Clear cache so measurements are not used for screen posCache.Clear(); return nPrintPos; } int Editor::TextWidth(int style, const char *text) { RefreshStyleData(); AutoSurface surface(this); if (surface) { return surface->WidthText(vs.styles[style].font, text, istrlen(text)); } else { return 1; } } // Empty method is overridden on GTK+ to show / hide scrollbars void Editor::ReconfigureScrollBars() {} void Editor::SetScrollBars() { RefreshStyleData(); int nMax = MaxScrollPos(); int nPage = LinesOnScreen(); bool modified = ModifyScrollBars(nMax + nPage - 1, nPage); if (modified) { DwellEnd(true); } // TODO: ensure always showing as many lines as possible // May not be, if, for example, window made larger if (topLine > MaxScrollPos()) { SetTopLine(Platform::Clamp(topLine, 0, MaxScrollPos())); SetVerticalScrollPos(); Redraw(); } if (modified) { if (!AbandonPaint()) Redraw(); } //Platform::DebugPrintf("end max = %d page = %d\n", nMax, nPage); } void Editor::ChangeSize() { DropGraphics(false); SetScrollBars(); if (wrapState != eWrapNone) { PRectangle rcTextArea = GetClientRectangle(); rcTextArea.left = vs.fixedColumnWidth; rcTextArea.right -= vs.rightMarginWidth; if (wrapWidth != rcTextArea.Width()) { NeedWrapping(); Redraw(); } } } int Editor::InsertSpace(int position, unsigned int spaces) { if (spaces > 0) { std::string spaceText(spaces, ' '); pdoc->InsertString(position, spaceText.c_str(), spaces); position += spaces; } return position; } void Editor::AddChar(char ch) { char s[2]; s[0] = ch; s[1] = '\0'; AddCharUTF(s, 1); } void Editor::FilterSelections() { if (!additionalSelectionTyping && (sel.Count() > 1)) { SelectionRange rangeOnly = sel.RangeMain(); InvalidateSelection(rangeOnly, true); sel.SetSelection(rangeOnly); } } static bool cmpSelPtrs(const SelectionRange *a, const SelectionRange *b) { return *a < *b; } // AddCharUTF inserts an array of bytes which may or may not be in UTF-8. void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) { FilterSelections(); { UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty() || inOverstrike); std::vector selPtrs; for (size_t r = 0; r < sel.Count(); r++) { selPtrs.push_back(&sel.Range(r)); } std::sort(selPtrs.begin(), selPtrs.end(), cmpSelPtrs); for (std::vector::reverse_iterator rit = selPtrs.rbegin(); rit != selPtrs.rend(); ++rit) { SelectionRange *currentSel = *rit; if (!RangeContainsProtected(currentSel->Start().Position(), currentSel->End().Position())) { int positionInsert = currentSel->Start().Position(); if (!currentSel->Empty()) { if (currentSel->Length()) { pdoc->DeleteChars(positionInsert, currentSel->Length()); currentSel->ClearVirtualSpace(); } else { // Range is all virtual so collapse to start of virtual space currentSel->MinimizeVirtualSpace(); } } else if (inOverstrike) { if (positionInsert < pdoc->Length()) { if (!IsEOLChar(pdoc->CharAt(positionInsert))) { pdoc->DelChar(positionInsert); currentSel->ClearVirtualSpace(); } } } positionInsert = InsertSpace(positionInsert, currentSel->caret.VirtualSpace()); if (pdoc->InsertString(positionInsert, s, len)) { currentSel->caret.SetPosition(positionInsert + len); currentSel->anchor.SetPosition(positionInsert + len); } currentSel->ClearVirtualSpace(); // If in wrap mode rewrap current line so EnsureCaretVisible has accurate information if (wrapState != eWrapNone) { AutoSurface surface(this); if (surface) { if (WrapOneLine(surface, pdoc->LineFromPosition(positionInsert))) { SetScrollBars(); SetVerticalScrollPos(); Redraw(); } } } } } } if (wrapState != eWrapNone) { SetScrollBars(); } ThinRectangularRange(); // If in wrap mode rewrap current line so EnsureCaretVisible has accurate information EnsureCaretVisible(); // Avoid blinking during rapid typing: ShowCaretAtCurrentPosition(); if ((caretSticky == SC_CARETSTICKY_OFF) || ((caretSticky == SC_CARETSTICKY_WHITESPACE) && !IsAllSpacesOrTabs(s, len))) { SetLastXChosen(); } if (treatAsDBCS) { NotifyChar((static_cast(s[0]) << 8) | static_cast(s[1])); } else { int byte = static_cast(s[0]); if ((byte < 0xC0) || (1 == len)) { // Handles UTF-8 characters between 0x01 and 0x7F and single byte // characters when not in UTF-8 mode. // Also treats \0 and naked trail bytes 0x80 to 0xBF as valid // characters representing themselves. } else { // Unroll 1 to 3 byte UTF-8 sequences. See reference data at: // http://www.cl.cam.ac.uk/~mgk25/unicode.html // http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt if (byte < 0xE0) { int byte2 = static_cast(s[1]); if ((byte2 & 0xC0) == 0x80) { // Two-byte-character lead-byte followed by a trail-byte. byte = (((byte & 0x1F) << 6) | (byte2 & 0x3F)); } // A two-byte-character lead-byte not followed by trail-byte // represents itself. } else if (byte < 0xF0) { int byte2 = static_cast(s[1]); int byte3 = static_cast(s[2]); if (((byte2 & 0xC0) == 0x80) && ((byte3 & 0xC0) == 0x80)) { // Three-byte-character lead byte followed by two trail bytes. byte = (((byte & 0x0F) << 12) | ((byte2 & 0x3F) << 6) | (byte3 & 0x3F)); } // A three-byte-character lead-byte not followed by two trail-bytes // represents itself. } } NotifyChar(byte); } if (recordingMacro) { NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast(s)); } } void Editor::InsertPaste(SelectionPosition selStart, const char *text, int len) { if (multiPasteMode == SC_MULTIPASTE_ONCE) { selStart = SelectionPosition(InsertSpace(selStart.Position(), selStart.VirtualSpace())); if (pdoc->InsertString(selStart.Position(), text, len)) { SetEmptySelection(selStart.Position() + len); } } else { // SC_MULTIPASTE_EACH for (size_t r=0; rDeleteChars(positionInsert, sel.Range(r).Length()); sel.Range(r).ClearVirtualSpace(); } else { // Range is all virtual so collapse to start of virtual space sel.Range(r).MinimizeVirtualSpace(); } } positionInsert = InsertSpace(positionInsert, sel.Range(r).caret.VirtualSpace()); if (pdoc->InsertString(positionInsert, text, len)) { sel.Range(r).caret.SetPosition(positionInsert + len); sel.Range(r).anchor.SetPosition(positionInsert + len); } sel.Range(r).ClearVirtualSpace(); } } } } void Editor::ClearSelection(bool retainMultipleSelections) { if (!sel.IsRectangular() && !retainMultipleSelections) FilterSelections(); UndoGroup ug(pdoc); for (size_t r=0; rDeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length()); sel.Range(r) = sel.Range(r).Start(); } } } ThinRectangularRange(); sel.RemoveDuplicates(); ClaimSelection(); } void Editor::ClearAll() { { UndoGroup ug(pdoc); if (0 != pdoc->Length()) { pdoc->DeleteChars(0, pdoc->Length()); } if (!pdoc->IsReadOnly()) { cs.Clear(); pdoc->AnnotationClearAll(); pdoc->MarginClearAll(); } } sel.Clear(); SetTopLine(0); SetVerticalScrollPos(); InvalidateStyleRedraw(); } void Editor::ClearDocumentStyle() { Decoration *deco = pdoc->decorations.root; while (deco) { // Save next in case deco deleted Decoration *decoNext = deco->next; if (deco->indicator < INDIC_CONTAINER) { pdoc->decorations.SetCurrentIndicator(deco->indicator); pdoc->DecorationFillRange(0, 0, pdoc->Length()); } deco = decoNext; } pdoc->StartStyling(0, '\377'); pdoc->SetStyleFor(pdoc->Length(), 0); cs.ShowAll(); pdoc->ClearLevels(); } void Editor::CopyAllowLine() { SelectionText selectedText; CopySelectionRange(&selectedText, true); CopyToClipboard(selectedText); } void Editor::Cut() { pdoc->CheckReadOnly(); if (!pdoc->IsReadOnly() && !SelectionContainsProtected()) { Copy(); ClearSelection(); } } void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, int len) { if (pdoc->IsReadOnly() || SelectionContainsProtected()) { return; } sel.Clear(); sel.RangeMain() = SelectionRange(pos); int line = pdoc->LineFromPosition(sel.MainCaret()); UndoGroup ug(pdoc); sel.RangeMain().caret = SelectionPosition( InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace())); int xInsert = XFromPosition(sel.RangeMain().caret); bool prevCr = false; while ((len > 0) && IsEOLChar(ptr[len-1])) len--; for (int i = 0; i < len; i++) { if (IsEOLChar(ptr[i])) { if ((ptr[i] == '\r') || (!prevCr)) line++; if (line >= pdoc->LinesTotal()) { if (pdoc->eolMode != SC_EOL_LF) pdoc->InsertChar(pdoc->Length(), '\r'); if (pdoc->eolMode != SC_EOL_CR) pdoc->InsertChar(pdoc->Length(), '\n'); } // Pad the end of lines with spaces if required sel.RangeMain().caret.SetPosition(PositionFromLineX(line, xInsert)); if ((XFromPosition(sel.MainCaret()) < xInsert) && (i + 1 < len)) { while (XFromPosition(sel.MainCaret()) < xInsert) { pdoc->InsertChar(sel.MainCaret(), ' '); sel.RangeMain().caret.Add(1); } } prevCr = ptr[i] == '\r'; } else { pdoc->InsertString(sel.MainCaret(), ptr + i, 1); sel.RangeMain().caret.Add(1); prevCr = false; } } SetEmptySelection(pos); } bool Editor::CanPaste() { return !pdoc->IsReadOnly() && !SelectionContainsProtected(); } void Editor::Clear() { // If multiple selections, don't delete EOLS if (sel.Empty()) { bool singleVirtual = false; if ((sel.Count() == 1) && !RangeContainsProtected(sel.MainCaret(), sel.MainCaret() + 1) && sel.RangeMain().Start().VirtualSpace()) { singleVirtual = true; } UndoGroup ug(pdoc, (sel.Count() > 1) || singleVirtual); for (size_t r=0; rCharAt(sel.Range(r).caret.Position()))) { pdoc->DelChar(sel.Range(r).caret.Position()); sel.Range(r).ClearVirtualSpace(); } // else multiple selection so don't eat line ends } else { sel.Range(r).ClearVirtualSpace(); } } } else { ClearSelection(); } sel.RemoveDuplicates(); } void Editor::SelectAll() { sel.Clear(); SetSelection(0, pdoc->Length()); Redraw(); } void Editor::Undo() { if (pdoc->CanUndo()) { InvalidateCaret(); int newPos = pdoc->Undo(); if (newPos >= 0) SetEmptySelection(newPos); EnsureCaretVisible(); } } void Editor::Redo() { if (pdoc->CanRedo()) { int newPos = pdoc->Redo(); if (newPos >= 0) SetEmptySelection(newPos); EnsureCaretVisible(); } } void Editor::DelChar() { if (!RangeContainsProtected(sel.MainCaret(), sel.MainCaret() + 1)) { pdoc->DelChar(sel.MainCaret()); } // Avoid blinking during rapid typing: ShowCaretAtCurrentPosition(); } void Editor::DelCharBack(bool allowLineStartDeletion) { if (!sel.IsRectangular()) FilterSelections(); if (sel.IsRectangular()) allowLineStartDeletion = false; UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty()); if (sel.Empty()) { for (size_t r=0; rLineFromPosition(sel.Range(r).caret.Position()); if (allowLineStartDeletion || (pdoc->LineStart(lineCurrentPos) != sel.Range(r).caret.Position())) { if (pdoc->GetColumn(sel.Range(r).caret.Position()) <= pdoc->GetLineIndentation(lineCurrentPos) && pdoc->GetColumn(sel.Range(r).caret.Position()) > 0 && pdoc->backspaceUnindents) { UndoGroup ugInner(pdoc, !ug.Needed()); int indentation = pdoc->GetLineIndentation(lineCurrentPos); int indentationStep = pdoc->IndentSize(); if (indentation % indentationStep == 0) { pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep); } else { pdoc->SetLineIndentation(lineCurrentPos, indentation - (indentation % indentationStep)); } // SetEmptySelection sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos), pdoc->GetLineIndentPosition(lineCurrentPos)); } else { pdoc->DelCharBack(sel.Range(r).caret.Position()); } } } } else { sel.Range(r).ClearVirtualSpace(); } } } else { ClearSelection(); } sel.RemoveDuplicates(); // Avoid blinking during rapid typing: ShowCaretAtCurrentPosition(); } void Editor::NotifyFocus(bool) {} void Editor::SetCtrlID(int identifier) { ctrlID = identifier; } void Editor::NotifyStyleToNeeded(int endStyleNeeded) { SCNotification scn = {0}; scn.nmhdr.code = SCN_STYLENEEDED; scn.position = endStyleNeeded; NotifyParent(scn); } void Editor::NotifyStyleNeeded(Document *, void *, int endStyleNeeded) { NotifyStyleToNeeded(endStyleNeeded); } void Editor::NotifyLexerChanged(Document *, void *) { } void Editor::NotifyErrorOccurred(Document *, void *, int status) { errorStatus = status; } void Editor::NotifyChar(int ch) { SCNotification scn = {0}; scn.nmhdr.code = SCN_CHARADDED; scn.ch = ch; NotifyParent(scn); } void Editor::NotifySavePoint(bool isSavePoint) { SCNotification scn = {0}; if (isSavePoint) { scn.nmhdr.code = SCN_SAVEPOINTREACHED; } else { scn.nmhdr.code = SCN_SAVEPOINTLEFT; } NotifyParent(scn); } void Editor::NotifyModifyAttempt() { SCNotification scn = {0}; scn.nmhdr.code = SCN_MODIFYATTEMPTRO; NotifyParent(scn); } void Editor::NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt) { SCNotification scn = {0}; scn.nmhdr.code = SCN_DOUBLECLICK; scn.line = LineFromLocation(pt); scn.position = PositionFromLocation(pt, true); scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); NotifyParent(scn); } void Editor::NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt) { SCNotification scn = {0}; scn.nmhdr.code = SCN_HOTSPOTDOUBLECLICK; scn.position = position; scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); NotifyParent(scn); } void Editor::NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt) { SCNotification scn = {0}; scn.nmhdr.code = SCN_HOTSPOTCLICK; scn.position = position; scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); NotifyParent(scn); } void Editor::NotifyHotSpotReleaseClick(int position, bool shift, bool ctrl, bool alt) { SCNotification scn = {0}; scn.nmhdr.code = SCN_HOTSPOTRELEASECLICK; scn.position = position; scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); NotifyParent(scn); } void Editor::NotifyUpdateUI() { SCNotification scn = {0}; scn.nmhdr.code = SCN_UPDATEUI; scn.updated = needUpdateUI; NotifyParent(scn); } void Editor::NotifyPainted() { SCNotification scn = {0}; scn.nmhdr.code = SCN_PAINTED; NotifyParent(scn); } void Editor::NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt) { int mask = pdoc->decorations.AllOnFor(position); if ((click && mask) || pdoc->decorations.clickNotified) { SCNotification scn = {0}; pdoc->decorations.clickNotified = click; scn.nmhdr.code = click ? SCN_INDICATORCLICK : SCN_INDICATORRELEASE; scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); scn.position = position; NotifyParent(scn); } } bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) { int marginClicked = -1; int x = 0; for (int margin = 0; margin < ViewStyle::margins; margin++) { if ((pt.x > x) && (pt.x < x + vs.ms[margin].width)) marginClicked = margin; x += vs.ms[margin].width; } if ((marginClicked >= 0) && vs.ms[marginClicked].sensitive) { SCNotification scn = {0}; scn.nmhdr.code = SCN_MARGINCLICK; scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); scn.position = pdoc->LineStart(LineFromLocation(pt)); scn.margin = marginClicked; NotifyParent(scn); return true; } else { return false; } } void Editor::NotifyNeedShown(int pos, int len) { SCNotification scn = {0}; scn.nmhdr.code = SCN_NEEDSHOWN; scn.position = pos; scn.length = len; NotifyParent(scn); } void Editor::NotifyDwelling(Point pt, bool state) { SCNotification scn = {0}; scn.nmhdr.code = state ? SCN_DWELLSTART : SCN_DWELLEND; scn.position = PositionFromLocation(pt, true); scn.x = pt.x; scn.y = pt.y; NotifyParent(scn); } void Editor::NotifyZoom() { SCNotification scn = {0}; scn.nmhdr.code = SCN_ZOOM; NotifyParent(scn); } // Notifications from document void Editor::NotifyModifyAttempt(Document *, void *) { //Platform::DebugPrintf("** Modify Attempt\n"); NotifyModifyAttempt(); } void Editor::NotifySavePoint(Document *, void *, bool atSavePoint) { //Platform::DebugPrintf("** Save Point %s\n", atSavePoint ? "On" : "Off"); NotifySavePoint(atSavePoint); } void Editor::CheckModificationForWrap(DocModification mh) { if (mh.modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)) { llc.Invalidate(LineLayout::llCheckTextAndStyle); int lineDoc = pdoc->LineFromPosition(mh.position); int lines = Platform::Maximum(0, mh.linesAdded); if (wrapState != eWrapNone) { NeedWrapping(lineDoc, lineDoc + lines + 1); } RefreshStyleData(); // Fix up annotation heights SetAnnotationHeights(lineDoc, lineDoc + lines + 2); } } // Move a position so it is still after the same character as before the insertion. static inline int MovePositionForInsertion(int position, int startInsertion, int length) { if (position > startInsertion) { return position + length; } return position; } // Move a position so it is still after the same character as before the deletion if that // character is still present else after the previous surviving character. static inline int MovePositionForDeletion(int position, int startDeletion, int length) { if (position > startDeletion) { int endDeletion = startDeletion + length; if (position > endDeletion) { return position - length; } else { return startDeletion; } } else { return position; } } void Editor::NotifyModified(Document *, DocModification mh, void *) { ContainerNeedsUpdate(SC_UPDATE_CONTENT); if (paintState == painting) { CheckForChangeOutsidePaint(Range(mh.position, mh.position + mh.length)); } if (mh.modificationType & SC_MOD_CHANGELINESTATE) { if (paintState == painting) { CheckForChangeOutsidePaint( Range(pdoc->LineStart(mh.line), pdoc->LineStart(mh.line + 1))); } else { // Could check that change is before last visible line. Redraw(); } } if (mh.modificationType & SC_MOD_LEXERSTATE) { if (paintState == painting) { CheckForChangeOutsidePaint( Range(mh.position, mh.position + mh.length)); } else { Redraw(); } } if (mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) { if (mh.modificationType & SC_MOD_CHANGESTYLE) { pdoc->IncrementStyleClock(); } if (paintState == notPainting) { if (mh.position < pdoc->LineStart(topLine)) { // Styling performed before this view Redraw(); } else { InvalidateRange(mh.position, mh.position + mh.length); } } if (mh.modificationType & SC_MOD_CHANGESTYLE) { llc.Invalidate(LineLayout::llCheckTextAndStyle); } } else { // Move selection and brace highlights if (mh.modificationType & SC_MOD_INSERTTEXT) { sel.MovePositions(true, mh.position, mh.length); braces[0] = MovePositionForInsertion(braces[0], mh.position, mh.length); braces[1] = MovePositionForInsertion(braces[1], mh.position, mh.length); } else if (mh.modificationType & SC_MOD_DELETETEXT) { sel.MovePositions(false, mh.position, mh.length); braces[0] = MovePositionForDeletion(braces[0], mh.position, mh.length); braces[1] = MovePositionForDeletion(braces[1], mh.position, mh.length); } if ((mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) && cs.HiddenLines()) { // Some lines are hidden so may need shown. // TODO: check if the modified area is hidden. if (mh.modificationType & SC_MOD_BEFOREINSERT) { int lineOfPos = pdoc->LineFromPosition(mh.position); bool insertingNewLine = false; for (int i=0; i < mh.length; i++) { if ((mh.text[i] == '\n') || (mh.text[i] == '\r')) insertingNewLine = true; } if (insertingNewLine && (mh.position != pdoc->LineStart(lineOfPos))) NotifyNeedShown(mh.position, pdoc->LineStart(lineOfPos+1) - mh.position); else NotifyNeedShown(mh.position, 0); } else if (mh.modificationType & SC_MOD_BEFOREDELETE) { NotifyNeedShown(mh.position, mh.length); } } if (mh.linesAdded != 0) { // Update contraction state for inserted and removed lines // lineOfPos should be calculated in context of state before modification, shouldn't it int lineOfPos = pdoc->LineFromPosition(mh.position); if (mh.linesAdded > 0) { cs.InsertLines(lineOfPos, mh.linesAdded); } else { cs.DeleteLines(lineOfPos, -mh.linesAdded); } } if (mh.modificationType & SC_MOD_CHANGEANNOTATION) { int lineDoc = pdoc->LineFromPosition(mh.position); if (vs.annotationVisible) { cs.SetHeight(lineDoc, cs.GetHeight(lineDoc) + mh.annotationLinesAdded); Redraw(); } } CheckModificationForWrap(mh); if (mh.linesAdded != 0) { // Avoid scrolling of display if change before current display if (mh.position < posTopLine && !CanDeferToLastStep(mh)) { int newTop = Platform::Clamp(topLine + mh.linesAdded, 0, MaxScrollPos()); if (newTop != topLine) { SetTopLine(newTop); SetVerticalScrollPos(); } } //Platform::DebugPrintf("** %x Doc Changed\n", this); // TODO: could invalidate from mh.startModification to end of screen //InvalidateRange(mh.position, mh.position + mh.length); if (paintState == notPainting && !CanDeferToLastStep(mh)) { QueueStyling(pdoc->Length()); Redraw(); } } else { //Platform::DebugPrintf("** %x Line Changed %d .. %d\n", this, // mh.position, mh.position + mh.length); if (paintState == notPainting && mh.length && !CanEliminate(mh)) { QueueStyling(mh.position + mh.length); InvalidateRange(mh.position, mh.position + mh.length); } } } if (mh.linesAdded != 0 && !CanDeferToLastStep(mh)) { SetScrollBars(); } if ((mh.modificationType & SC_MOD_CHANGEMARKER) || (mh.modificationType & SC_MOD_CHANGEMARGIN)) { if ((!willRedrawAll) && ((paintState == notPainting) || !PaintContainsMargin())) { if (mh.modificationType & SC_MOD_CHANGEFOLD) { // Fold changes can affect the drawing of following lines so redraw whole margin RedrawSelMargin(highlightDelimiter.isEnabled ? -1 : mh.line-1, true); } else { RedrawSelMargin(mh.line); } } } // NOW pay the piper WRT "deferred" visual updates if (IsLastStep(mh)) { SetScrollBars(); Redraw(); } // If client wants to see this modification if (mh.modificationType & modEventMask) { if ((mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) == 0) { // Real modification made to text of document. NotifyChange(); // Send EN_CHANGE } SCNotification scn = {0}; scn.nmhdr.code = SCN_MODIFIED; scn.position = mh.position; scn.modificationType = mh.modificationType; scn.text = mh.text; scn.length = mh.length; scn.linesAdded = mh.linesAdded; scn.line = mh.line; scn.foldLevelNow = mh.foldLevelNow; scn.foldLevelPrev = mh.foldLevelPrev; scn.token = mh.token; scn.annotationLinesAdded = mh.annotationLinesAdded; NotifyParent(scn); } } void Editor::NotifyDeleted(Document *, void *) { /* Do nothing */ } void Editor::NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { // Enumerates all macroable messages switch (iMessage) { case SCI_CUT: case SCI_COPY: case SCI_PASTE: case SCI_CLEAR: case SCI_REPLACESEL: case SCI_ADDTEXT: case SCI_INSERTTEXT: case SCI_APPENDTEXT: case SCI_CLEARALL: case SCI_SELECTALL: case SCI_GOTOLINE: case SCI_GOTOPOS: case SCI_SEARCHANCHOR: case SCI_SEARCHNEXT: case SCI_SEARCHPREV: case SCI_LINEDOWN: case SCI_LINEDOWNEXTEND: case SCI_PARADOWN: case SCI_PARADOWNEXTEND: case SCI_LINEUP: case SCI_LINEUPEXTEND: case SCI_PARAUP: case SCI_PARAUPEXTEND: case SCI_CHARLEFT: case SCI_CHARLEFTEXTEND: case SCI_CHARRIGHT: case SCI_CHARRIGHTEXTEND: case SCI_WORDLEFT: case SCI_WORDLEFTEXTEND: case SCI_WORDRIGHT: case SCI_WORDRIGHTEXTEND: case SCI_WORDPARTLEFT: case SCI_WORDPARTLEFTEXTEND: case SCI_WORDPARTRIGHT: case SCI_WORDPARTRIGHTEXTEND: case SCI_WORDLEFTEND: case SCI_WORDLEFTENDEXTEND: case SCI_WORDRIGHTEND: case SCI_WORDRIGHTENDEXTEND: case SCI_HOME: case SCI_HOMEEXTEND: case SCI_LINEEND: case SCI_LINEENDEXTEND: case SCI_HOMEWRAP: case SCI_HOMEWRAPEXTEND: case SCI_LINEENDWRAP: case SCI_LINEENDWRAPEXTEND: case SCI_DOCUMENTSTART: case SCI_DOCUMENTSTARTEXTEND: case SCI_DOCUMENTEND: case SCI_DOCUMENTENDEXTEND: case SCI_STUTTEREDPAGEUP: case SCI_STUTTEREDPAGEUPEXTEND: case SCI_STUTTEREDPAGEDOWN: case SCI_STUTTEREDPAGEDOWNEXTEND: case SCI_PAGEUP: case SCI_PAGEUPEXTEND: case SCI_PAGEDOWN: case SCI_PAGEDOWNEXTEND: case SCI_EDITTOGGLEOVERTYPE: case SCI_CANCEL: case SCI_DELETEBACK: case SCI_TAB: case SCI_BACKTAB: case SCI_FORMFEED: case SCI_VCHOME: case SCI_VCHOMEEXTEND: case SCI_VCHOMEWRAP: case SCI_VCHOMEWRAPEXTEND: case SCI_DELWORDLEFT: case SCI_DELWORDRIGHT: case SCI_DELWORDRIGHTEND: case SCI_DELLINELEFT: case SCI_DELLINERIGHT: case SCI_LINECOPY: case SCI_LINECUT: case SCI_LINEDELETE: case SCI_LINETRANSPOSE: case SCI_LINEDUPLICATE: case SCI_LOWERCASE: case SCI_UPPERCASE: case SCI_LINESCROLLDOWN: case SCI_LINESCROLLUP: case SCI_DELETEBACKNOTLINE: case SCI_HOMEDISPLAY: case SCI_HOMEDISPLAYEXTEND: case SCI_LINEENDDISPLAY: case SCI_LINEENDDISPLAYEXTEND: case SCI_SETSELECTIONMODE: case SCI_LINEDOWNRECTEXTEND: case SCI_LINEUPRECTEXTEND: case SCI_CHARLEFTRECTEXTEND: case SCI_CHARRIGHTRECTEXTEND: case SCI_HOMERECTEXTEND: case SCI_VCHOMERECTEXTEND: case SCI_LINEENDRECTEXTEND: case SCI_PAGEUPRECTEXTEND: case SCI_PAGEDOWNRECTEXTEND: case SCI_SELECTIONDUPLICATE: case SCI_COPYALLOWLINE: case SCI_VERTICALCENTRECARET: case SCI_MOVESELECTEDLINESUP: case SCI_MOVESELECTEDLINESDOWN: case SCI_SCROLLTOSTART: case SCI_SCROLLTOEND: break; // Filter out all others like display changes. Also, newlines are redundant // with char insert messages. case SCI_NEWLINE: default: // printf("Filtered out %ld of macro recording\n", iMessage); return ; } // Send notification SCNotification scn = {0}; scn.nmhdr.code = SCN_MACRORECORD; scn.message = iMessage; scn.wParam = wParam; scn.lParam = lParam; NotifyParent(scn); } // Something has changed that the container should know about void Editor::ContainerNeedsUpdate(int flags) { needUpdateUI |= flags; } /** * Force scroll and keep position relative to top of window. * * If stuttered = true and not already at first/last row, move to first/last row of window. * If stuttered = true and already at first/last row, scroll as normal. */ void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) { int topLineNew; SelectionPosition newPos; int currentLine = pdoc->LineFromPosition(sel.MainCaret()); int topStutterLine = topLine + caretYSlop; int bottomStutterLine = pdoc->LineFromPosition(PositionFromLocation( Point(lastXChosen - xOffset, direction * vs.lineHeight * LinesToScroll()))) - caretYSlop - 1; if (stuttered && (direction < 0 && currentLine > topStutterLine)) { topLineNew = topLine; newPos = SPositionFromLocation(Point(lastXChosen - xOffset, vs.lineHeight * caretYSlop), false, false, UserVirtualSpace()); } else if (stuttered && (direction > 0 && currentLine < bottomStutterLine)) { topLineNew = topLine; newPos = SPositionFromLocation(Point(lastXChosen - xOffset, vs.lineHeight * (LinesToScroll() - caretYSlop)), false, false, UserVirtualSpace()); } else { Point pt = LocationFromPosition(sel.MainCaret()); topLineNew = Platform::Clamp( topLine + direction * LinesToScroll(), 0, MaxScrollPos()); newPos = SPositionFromLocation( Point(lastXChosen - xOffset, pt.y + direction * (vs.lineHeight * LinesToScroll())), false, false, UserVirtualSpace()); } if (topLineNew != topLine) { SetTopLine(topLineNew); MovePositionTo(newPos, selt); Redraw(); SetVerticalScrollPos(); } else { MovePositionTo(newPos, selt); } } void Editor::ChangeCaseOfSelection(int caseMapping) { UndoGroup ug(pdoc); for (size_t r=0; r 0) { std::string sText(text, rangeBytes); std::string sMapped = CaseMapString(sText, caseMapping); if (sMapped != sText) { size_t firstDifference = 0; while (sMapped[firstDifference] == sText[firstDifference]) firstDifference++; size_t lastDifference = sMapped.size() - 1; while (sMapped[lastDifference] == sText[lastDifference]) lastDifference--; size_t endSame = sMapped.size() - 1 - lastDifference; pdoc->DeleteChars( static_cast(currentNoVS.Start().Position() + firstDifference), static_cast(rangeBytes - firstDifference - endSame)); pdoc->InsertString( static_cast(currentNoVS.Start().Position() + firstDifference), sMapped.c_str() + firstDifference, static_cast(lastDifference - firstDifference + 1)); // Automatic movement changes selection so reset to exactly the same as it was. sel.Range(r) = current; } } delete []text; } } void Editor::LineTranspose() { int line = pdoc->LineFromPosition(sel.MainCaret()); if (line > 0) { UndoGroup ug(pdoc); int startPrev = pdoc->LineStart(line - 1); int endPrev = pdoc->LineEnd(line - 1); int start = pdoc->LineStart(line); int end = pdoc->LineEnd(line); char *line1 = CopyRange(startPrev, endPrev); int len1 = endPrev - startPrev; char *line2 = CopyRange(start, end); int len2 = end - start; pdoc->DeleteChars(start, len2); pdoc->DeleteChars(startPrev, len1); pdoc->InsertString(startPrev, line2, len2); pdoc->InsertString(start - len1 + len2, line1, len1); MovePositionTo(SelectionPosition(start - len1 + len2)); delete []line1; delete []line2; } } void Editor::Duplicate(bool forLine) { if (sel.Empty()) { forLine = true; } UndoGroup ug(pdoc); const char *eol = ""; int eolLen = 0; if (forLine) { eol = StringFromEOLMode(pdoc->eolMode); eolLen = istrlen(eol); } for (size_t r=0; rLineFromPosition(sel.Range(r).caret.Position()); start = SelectionPosition(pdoc->LineStart(line)); end = SelectionPosition(pdoc->LineEnd(line)); } char *text = CopyRange(start.Position(), end.Position()); if (forLine) pdoc->InsertString(end.Position(), eol, eolLen); pdoc->InsertString(end.Position() + eolLen, text, SelectionRange(end, start).Length()); delete []text; } if (sel.Count() && sel.IsRectangular()) { SelectionPosition last = sel.Last(); if (forLine) { int line = pdoc->LineFromPosition(last.Position()); last = SelectionPosition(last.Position() + pdoc->LineStart(line+1) - pdoc->LineStart(line)); } if (sel.Rectangular().anchor > sel.Rectangular().caret) sel.Rectangular().anchor = last; else sel.Rectangular().caret = last; SetRectangularRange(); } } void Editor::CancelModes() { sel.SetMoveExtends(false); } void Editor::NewLine() { ClearSelection(); const char *eol = "\n"; if (pdoc->eolMode == SC_EOL_CRLF) { eol = "\r\n"; } else if (pdoc->eolMode == SC_EOL_CR) { eol = "\r"; } // else SC_EOL_LF -> "\n" already set if (pdoc->InsertCString(sel.MainCaret(), eol)) { SetEmptySelection(sel.MainCaret() + istrlen(eol)); while (*eol) { NotifyChar(*eol); if (recordingMacro) { char txt[2]; txt[0] = *eol; txt[1] = '\0'; NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast(txt)); } eol++; } } SetLastXChosen(); SetScrollBars(); EnsureCaretVisible(); // Avoid blinking during rapid typing: ShowCaretAtCurrentPosition(); } void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) { SelectionPosition caretToUse = sel.Range(sel.Main()).caret; if (sel.IsRectangular()) { if (selt == Selection::noSel) { caretToUse = (direction > 0) ? sel.Limits().end : sel.Limits().start; } else { caretToUse = sel.Rectangular().caret; } } Point pt = LocationFromPosition(caretToUse); int skipLines = 0; if (vs.annotationVisible) { int lineDoc = pdoc->LineFromPosition(caretToUse.Position()); Point ptStartLine = LocationFromPosition(pdoc->LineStart(lineDoc)); int subLine = (pt.y - ptStartLine.y) / vs.lineHeight; if (direction < 0 && subLine == 0) { int lineDisplay = cs.DisplayFromDoc(lineDoc); if (lineDisplay > 0) { skipLines = pdoc->AnnotationLines(cs.DocFromDisplay(lineDisplay - 1)); } } else if (direction > 0 && subLine >= (cs.GetHeight(lineDoc) - 1 - pdoc->AnnotationLines(lineDoc))) { skipLines = pdoc->AnnotationLines(lineDoc); } } int newY = pt.y + (1 + skipLines) * direction * vs.lineHeight; SelectionPosition posNew = SPositionFromLocation( Point(lastXChosen - xOffset, newY), false, false, UserVirtualSpace()); if (direction < 0) { // Line wrapping may lead to a location on the same line, so // seek back if that is the case. Point ptNew = LocationFromPosition(posNew.Position()); while ((posNew.Position() > 0) && (pt.y == ptNew.y)) { posNew.Add(-1); posNew.SetVirtualSpace(0); ptNew = LocationFromPosition(posNew.Position()); } } else if (direction > 0 && posNew.Position() != pdoc->Length()) { // There is an equivalent case when moving down which skips // over a line. Point ptNew = LocationFromPosition(posNew.Position()); while ((posNew.Position() > caretToUse.Position()) && (ptNew.y > newY)) { posNew.Add(-1); posNew.SetVirtualSpace(0); ptNew = LocationFromPosition(posNew.Position()); } } MovePositionTo(MovePositionSoVisible(posNew, direction), selt); } void Editor::ParaUpOrDown(int direction, Selection::selTypes selt) { int lineDoc, savedPos = sel.MainCaret(); do { MovePositionTo(SelectionPosition(direction > 0 ? pdoc->ParaDown(sel.MainCaret()) : pdoc->ParaUp(sel.MainCaret())), selt); lineDoc = pdoc->LineFromPosition(sel.MainCaret()); if (direction > 0) { if (sel.MainCaret() >= pdoc->Length() && !cs.GetVisible(lineDoc)) { if (selt == Selection::noSel) { MovePositionTo(SelectionPosition(pdoc->LineEndPosition(savedPos))); } break; } } } while (!cs.GetVisible(lineDoc)); } int Editor::StartEndDisplayLine(int pos, bool start) { RefreshStyleData(); int line = pdoc->LineFromPosition(pos); AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(line)); int posRet = INVALID_POSITION; if (surface && ll) { unsigned int posLineStart = pdoc->LineStart(line); LayoutLine(line, surface, vs, ll, wrapWidth); int posInLine = pos - posLineStart; if (posInLine <= ll->maxLineLength) { for (int subLine = 0; subLine < ll->lines; subLine++) { if ((posInLine >= ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine + 1))) { if (start) { posRet = ll->LineStart(subLine) + posLineStart; } else { if (subLine == ll->lines - 1) posRet = ll->LineStart(subLine + 1) + posLineStart; else posRet = ll->LineStart(subLine + 1) + posLineStart - 1; } } } } } if (posRet == INVALID_POSITION) { return pos; } else { return posRet; } } int Editor::KeyCommand(unsigned int iMessage) { switch (iMessage) { case SCI_LINEDOWN: CursorUpOrDown(1); break; case SCI_LINEDOWNEXTEND: CursorUpOrDown(1, Selection::selStream); break; case SCI_LINEDOWNRECTEXTEND: CursorUpOrDown(1, Selection::selRectangle); break; case SCI_PARADOWN: ParaUpOrDown(1); break; case SCI_PARADOWNEXTEND: ParaUpOrDown(1, Selection::selStream); break; case SCI_LINESCROLLDOWN: ScrollTo(topLine + 1); MoveCaretInsideView(false); break; case SCI_LINEUP: CursorUpOrDown(-1); break; case SCI_LINEUPEXTEND: CursorUpOrDown(-1, Selection::selStream); break; case SCI_LINEUPRECTEXTEND: CursorUpOrDown(-1, Selection::selRectangle); break; case SCI_PARAUP: ParaUpOrDown(-1); break; case SCI_PARAUPEXTEND: ParaUpOrDown(-1, Selection::selStream); break; case SCI_LINESCROLLUP: ScrollTo(topLine - 1); MoveCaretInsideView(false); break; case SCI_CHARLEFT: if (SelectionEmpty() || sel.MoveExtends()) { if ((sel.Count() == 1) && pdoc->IsLineEndPosition(sel.MainCaret()) && sel.RangeMain().caret.VirtualSpace()) { SelectionPosition spCaret = sel.RangeMain().caret; spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1); MovePositionTo(spCaret); } else { MovePositionTo(MovePositionSoVisible( SelectionPosition((sel.LimitsForRectangularElseMain().start).Position() - 1), -1)); } } else { MovePositionTo(sel.LimitsForRectangularElseMain().start); } SetLastXChosen(); break; case SCI_CHARLEFTEXTEND: if (pdoc->IsLineEndPosition(sel.MainCaret()) && sel.RangeMain().caret.VirtualSpace()) { SelectionPosition spCaret = sel.RangeMain().caret; spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1); MovePositionTo(spCaret, Selection::selStream); } else { MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() - 1), -1), Selection::selStream); } SetLastXChosen(); break; case SCI_CHARLEFTRECTEXTEND: if (pdoc->IsLineEndPosition(sel.MainCaret()) && sel.RangeMain().caret.VirtualSpace()) { SelectionPosition spCaret = sel.RangeMain().caret; spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1); MovePositionTo(spCaret, Selection::selRectangle); } else { MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() - 1), -1), Selection::selRectangle); } SetLastXChosen(); break; case SCI_CHARRIGHT: if (SelectionEmpty() || sel.MoveExtends()) { if ((virtualSpaceOptions & SCVS_USERACCESSIBLE) && pdoc->IsLineEndPosition(sel.MainCaret())) { SelectionPosition spCaret = sel.RangeMain().caret; spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1); MovePositionTo(spCaret); } else { MovePositionTo(MovePositionSoVisible( SelectionPosition((sel.LimitsForRectangularElseMain().end).Position() + 1), 1)); } } else { MovePositionTo(sel.LimitsForRectangularElseMain().end); } SetLastXChosen(); break; case SCI_CHARRIGHTEXTEND: if ((virtualSpaceOptions & SCVS_USERACCESSIBLE) && pdoc->IsLineEndPosition(sel.MainCaret())) { SelectionPosition spCaret = sel.RangeMain().caret; spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1); MovePositionTo(spCaret, Selection::selStream); } else { MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() + 1), 1), Selection::selStream); } SetLastXChosen(); break; case SCI_CHARRIGHTRECTEXTEND: if ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) && pdoc->IsLineEndPosition(sel.MainCaret())) { SelectionPosition spCaret = sel.RangeMain().caret; spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1); MovePositionTo(spCaret, Selection::selRectangle); } else { MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() + 1), 1), Selection::selRectangle); } SetLastXChosen(); break; case SCI_WORDLEFT: MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), -1), -1)); SetLastXChosen(); break; case SCI_WORDLEFTEXTEND: MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), -1), -1), Selection::selStream); SetLastXChosen(); break; case SCI_WORDRIGHT: MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), 1), 1)); SetLastXChosen(); break; case SCI_WORDRIGHTEXTEND: MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), 1), 1), Selection::selStream); SetLastXChosen(); break; case SCI_WORDLEFTEND: MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), -1), -1)); SetLastXChosen(); break; case SCI_WORDLEFTENDEXTEND: MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), -1), -1), Selection::selStream); SetLastXChosen(); break; case SCI_WORDRIGHTEND: MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), 1), 1)); SetLastXChosen(); break; case SCI_WORDRIGHTENDEXTEND: MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), 1), 1), Selection::selStream); SetLastXChosen(); break; case SCI_HOME: MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret()))); SetLastXChosen(); break; case SCI_HOMEEXTEND: MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())), Selection::selStream); SetLastXChosen(); break; case SCI_HOMERECTEXTEND: MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())), Selection::selRectangle); SetLastXChosen(); break; case SCI_LINEEND: MovePositionTo(pdoc->LineEndPosition(sel.MainCaret())); SetLastXChosen(); break; case SCI_LINEENDEXTEND: MovePositionTo(pdoc->LineEndPosition(sel.MainCaret()), Selection::selStream); SetLastXChosen(); break; case SCI_LINEENDRECTEXTEND: MovePositionTo(pdoc->LineEndPosition(sel.MainCaret()), Selection::selRectangle); SetLastXChosen(); break; case SCI_HOMEWRAP: { SelectionPosition homePos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1); if (sel.RangeMain().caret <= homePos) homePos = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret()))); MovePositionTo(homePos); SetLastXChosen(); } break; case SCI_HOMEWRAPEXTEND: { SelectionPosition homePos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1); if (sel.RangeMain().caret <= homePos) homePos = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret()))); MovePositionTo(homePos, Selection::selStream); SetLastXChosen(); } break; case SCI_LINEENDWRAP: { SelectionPosition endPos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), false), 1); SelectionPosition realEndPos = SelectionPosition(pdoc->LineEndPosition(sel.MainCaret())); if (endPos > realEndPos // if moved past visible EOLs || sel.RangeMain().caret >= endPos) // if at end of display line already endPos = realEndPos; MovePositionTo(endPos); SetLastXChosen(); } break; case SCI_LINEENDWRAPEXTEND: { SelectionPosition endPos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), false), 1); SelectionPosition realEndPos = SelectionPosition(pdoc->LineEndPosition(sel.MainCaret())); if (endPos > realEndPos // if moved past visible EOLs || sel.RangeMain().caret >= endPos) // if at end of display line already endPos = realEndPos; MovePositionTo(endPos, Selection::selStream); SetLastXChosen(); } break; case SCI_DOCUMENTSTART: MovePositionTo(0); SetLastXChosen(); break; case SCI_DOCUMENTSTARTEXTEND: MovePositionTo(0, Selection::selStream); SetLastXChosen(); break; case SCI_DOCUMENTEND: MovePositionTo(pdoc->Length()); SetLastXChosen(); break; case SCI_DOCUMENTENDEXTEND: MovePositionTo(pdoc->Length(), Selection::selStream); SetLastXChosen(); break; case SCI_STUTTEREDPAGEUP: PageMove(-1, Selection::noSel, true); break; case SCI_STUTTEREDPAGEUPEXTEND: PageMove(-1, Selection::selStream, true); break; case SCI_STUTTEREDPAGEDOWN: PageMove(1, Selection::noSel, true); break; case SCI_STUTTEREDPAGEDOWNEXTEND: PageMove(1, Selection::selStream, true); break; case SCI_PAGEUP: PageMove(-1); break; case SCI_PAGEUPEXTEND: PageMove(-1, Selection::selStream); break; case SCI_PAGEUPRECTEXTEND: PageMove(-1, Selection::selRectangle); break; case SCI_PAGEDOWN: PageMove(1); break; case SCI_PAGEDOWNEXTEND: PageMove(1, Selection::selStream); break; case SCI_PAGEDOWNRECTEXTEND: PageMove(1, Selection::selRectangle); break; case SCI_EDITTOGGLEOVERTYPE: inOverstrike = !inOverstrike; DropCaret(); ShowCaretAtCurrentPosition(); ContainerNeedsUpdate(SC_UPDATE_CONTENT); NotifyUpdateUI(); break; case SCI_CANCEL: // Cancel any modes - handled in subclass // Also unselect text CancelModes(); break; case SCI_DELETEBACK: DelCharBack(true); if ((caretSticky == SC_CARETSTICKY_OFF) || (caretSticky == SC_CARETSTICKY_WHITESPACE)) { SetLastXChosen(); } EnsureCaretVisible(); break; case SCI_DELETEBACKNOTLINE: DelCharBack(false); if ((caretSticky == SC_CARETSTICKY_OFF) || (caretSticky == SC_CARETSTICKY_WHITESPACE)) { SetLastXChosen(); } EnsureCaretVisible(); break; case SCI_TAB: Indent(true); if (caretSticky == SC_CARETSTICKY_OFF) { SetLastXChosen(); } EnsureCaretVisible(); ShowCaretAtCurrentPosition(); // Avoid blinking break; case SCI_BACKTAB: Indent(false); if ((caretSticky == SC_CARETSTICKY_OFF) || (caretSticky == SC_CARETSTICKY_WHITESPACE)) { SetLastXChosen(); } EnsureCaretVisible(); ShowCaretAtCurrentPosition(); // Avoid blinking break; case SCI_NEWLINE: NewLine(); break; case SCI_FORMFEED: AddChar('\f'); break; case SCI_VCHOME: MovePositionTo(pdoc->VCHomePosition(sel.MainCaret())); SetLastXChosen(); break; case SCI_VCHOMEEXTEND: MovePositionTo(pdoc->VCHomePosition(sel.MainCaret()), Selection::selStream); SetLastXChosen(); break; case SCI_VCHOMERECTEXTEND: MovePositionTo(pdoc->VCHomePosition(sel.MainCaret()), Selection::selRectangle); SetLastXChosen(); break; case SCI_VCHOMEWRAP: { SelectionPosition homePos = SelectionPosition(pdoc->VCHomePosition(sel.MainCaret())); SelectionPosition viewLineStart = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1); if ((viewLineStart < sel.RangeMain().caret) && (viewLineStart > homePos)) homePos = viewLineStart; MovePositionTo(homePos); SetLastXChosen(); } break; case SCI_VCHOMEWRAPEXTEND: { SelectionPosition homePos = SelectionPosition(pdoc->VCHomePosition(sel.MainCaret())); SelectionPosition viewLineStart = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1); if ((viewLineStart < sel.RangeMain().caret) && (viewLineStart > homePos)) homePos = viewLineStart; MovePositionTo(homePos, Selection::selStream); SetLastXChosen(); } break; case SCI_ZOOMIN: if (vs.zoomLevel < 20) { vs.zoomLevel++; InvalidateStyleRedraw(); NotifyZoom(); } break; case SCI_ZOOMOUT: if (vs.zoomLevel > -10) { vs.zoomLevel--; InvalidateStyleRedraw(); NotifyZoom(); } break; case SCI_DELWORDLEFT: { int startWord = pdoc->NextWordStart(sel.MainCaret(), -1); pdoc->DeleteChars(startWord, sel.MainCaret() - startWord); sel.RangeMain().ClearVirtualSpace(); SetLastXChosen(); } break; case SCI_DELWORDRIGHT: { UndoGroup ug(pdoc); sel.RangeMain().caret = SelectionPosition( InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace())); sel.RangeMain().anchor = sel.RangeMain().caret; int endWord = pdoc->NextWordStart(sel.MainCaret(), 1); pdoc->DeleteChars(sel.MainCaret(), endWord - sel.MainCaret()); } break; case SCI_DELWORDRIGHTEND: { UndoGroup ug(pdoc); sel.RangeMain().caret = SelectionPosition( InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace())); int endWord = pdoc->NextWordEnd(sel.MainCaret(), 1); pdoc->DeleteChars(sel.MainCaret(), endWord - sel.MainCaret()); } break; case SCI_DELLINELEFT: { int line = pdoc->LineFromPosition(sel.MainCaret()); int start = pdoc->LineStart(line); pdoc->DeleteChars(start, sel.MainCaret() - start); sel.RangeMain().ClearVirtualSpace(); SetLastXChosen(); } break; case SCI_DELLINERIGHT: { int line = pdoc->LineFromPosition(sel.MainCaret()); int end = pdoc->LineEnd(line); pdoc->DeleteChars(sel.MainCaret(), end - sel.MainCaret()); } break; case SCI_LINECOPY: { int lineStart = pdoc->LineFromPosition(SelectionStart().Position()); int lineEnd = pdoc->LineFromPosition(SelectionEnd().Position()); CopyRangeToClipboard(pdoc->LineStart(lineStart), pdoc->LineStart(lineEnd + 1)); } break; case SCI_LINECUT: { int lineStart = pdoc->LineFromPosition(SelectionStart().Position()); int lineEnd = pdoc->LineFromPosition(SelectionEnd().Position()); int start = pdoc->LineStart(lineStart); int end = pdoc->LineStart(lineEnd + 1); SetSelection(start, end); Cut(); SetLastXChosen(); } break; case SCI_LINEDELETE: { int line = pdoc->LineFromPosition(sel.MainCaret()); int start = pdoc->LineStart(line); int end = pdoc->LineStart(line + 1); pdoc->DeleteChars(start, end - start); } break; case SCI_LINETRANSPOSE: LineTranspose(); break; case SCI_LINEDUPLICATE: Duplicate(true); break; case SCI_SELECTIONDUPLICATE: Duplicate(false); break; case SCI_LOWERCASE: ChangeCaseOfSelection(cmLower); break; case SCI_UPPERCASE: ChangeCaseOfSelection(cmUpper); break; case SCI_WORDPARTLEFT: MovePositionTo(MovePositionSoVisible(pdoc->WordPartLeft(sel.MainCaret()), -1)); SetLastXChosen(); break; case SCI_WORDPARTLEFTEXTEND: MovePositionTo(MovePositionSoVisible(pdoc->WordPartLeft(sel.MainCaret()), -1), Selection::selStream); SetLastXChosen(); break; case SCI_WORDPARTRIGHT: MovePositionTo(MovePositionSoVisible(pdoc->WordPartRight(sel.MainCaret()), 1)); SetLastXChosen(); break; case SCI_WORDPARTRIGHTEXTEND: MovePositionTo(MovePositionSoVisible(pdoc->WordPartRight(sel.MainCaret()), 1), Selection::selStream); SetLastXChosen(); break; case SCI_HOMEDISPLAY: MovePositionTo(MovePositionSoVisible( StartEndDisplayLine(sel.MainCaret(), true), -1)); SetLastXChosen(); break; case SCI_HOMEDISPLAYEXTEND: MovePositionTo(MovePositionSoVisible( StartEndDisplayLine(sel.MainCaret(), true), -1), Selection::selStream); SetLastXChosen(); break; case SCI_LINEENDDISPLAY: MovePositionTo(MovePositionSoVisible( StartEndDisplayLine(sel.MainCaret(), false), 1)); SetLastXChosen(); break; case SCI_LINEENDDISPLAYEXTEND: MovePositionTo(MovePositionSoVisible( StartEndDisplayLine(sel.MainCaret(), false), 1), Selection::selStream); SetLastXChosen(); break; case SCI_SCROLLTOSTART: ScrollTo(0); break; case SCI_SCROLLTOEND: ScrollTo(MaxScrollPos()); break; } return 0; } int Editor::KeyDefault(int, int) { return 0; } int Editor::KeyDownWithModifiers(int key, int modifiers, bool *consumed) { DwellEnd(false); int msg = kmap.Find(key, modifiers); if (msg) { if (consumed) *consumed = true; return WndProc(msg, 0, 0); } else { if (consumed) *consumed = false; return KeyDefault(key, modifiers); } } int Editor::KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed) { int modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); return KeyDownWithModifiers(key, modifiers, consumed); } void Editor::SetWhitespaceVisible(int view) { vs.viewWhitespace = static_cast(view); } int Editor::GetWhitespaceVisible() { return vs.viewWhitespace; } void Editor::Indent(bool forwards) { for (size_t r=0; rLineFromPosition(sel.Range(r).anchor.Position()); int caretPosition = sel.Range(r).caret.Position(); int lineCurrentPos = pdoc->LineFromPosition(caretPosition); if (lineOfAnchor == lineCurrentPos) { if (forwards) { UndoGroup ug(pdoc); pdoc->DeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length()); caretPosition = sel.Range(r).caret.Position(); if (pdoc->GetColumn(caretPosition) <= pdoc->GetColumn(pdoc->GetLineIndentPosition(lineCurrentPos)) && pdoc->tabIndents) { int indentation = pdoc->GetLineIndentation(lineCurrentPos); int indentationStep = pdoc->IndentSize(); pdoc->SetLineIndentation(lineCurrentPos, indentation + indentationStep - indentation % indentationStep); sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos)); } else { if (pdoc->useTabs) { pdoc->InsertChar(caretPosition, '\t'); sel.Range(r) = SelectionRange(caretPosition+1); } else { int numSpaces = (pdoc->tabInChars) - (pdoc->GetColumn(caretPosition) % (pdoc->tabInChars)); if (numSpaces < 1) numSpaces = pdoc->tabInChars; for (int i = 0; i < numSpaces; i++) { pdoc->InsertChar(caretPosition + i, ' '); } sel.Range(r) = SelectionRange(caretPosition+numSpaces); } } } else { if (pdoc->GetColumn(caretPosition) <= pdoc->GetLineIndentation(lineCurrentPos) && pdoc->tabIndents) { UndoGroup ug(pdoc); int indentation = pdoc->GetLineIndentation(lineCurrentPos); int indentationStep = pdoc->IndentSize(); pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep); sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos)); } else { int newColumn = ((pdoc->GetColumn(caretPosition) - 1) / pdoc->tabInChars) * pdoc->tabInChars; if (newColumn < 0) newColumn = 0; int newPos = caretPosition; while (pdoc->GetColumn(newPos) > newColumn) newPos--; sel.Range(r) = SelectionRange(newPos); } } } else { // Multiline int anchorPosOnLine = sel.Range(r).anchor.Position() - pdoc->LineStart(lineOfAnchor); int currentPosPosOnLine = caretPosition - pdoc->LineStart(lineCurrentPos); // Multiple lines selected so indent / dedent int lineTopSel = Platform::Minimum(lineOfAnchor, lineCurrentPos); int lineBottomSel = Platform::Maximum(lineOfAnchor, lineCurrentPos); if (pdoc->LineStart(lineBottomSel) == sel.Range(r).anchor.Position() || pdoc->LineStart(lineBottomSel) == caretPosition) lineBottomSel--; // If not selecting any characters on a line, do not indent { UndoGroup ug(pdoc); pdoc->Indent(forwards, lineBottomSel, lineTopSel); } if (lineOfAnchor < lineCurrentPos) { if (currentPosPosOnLine == 0) sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor)); else sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos + 1), pdoc->LineStart(lineOfAnchor)); } else { if (anchorPosOnLine == 0) sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor)); else sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor + 1)); } } } } class CaseFolderASCII : public CaseFolderTable { public: CaseFolderASCII() { StandardASCII(); } ~CaseFolderASCII() { } virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) { if (lenMixed > sizeFolded) { return 0; } else { for (size_t i=0; i(mixed[i])]; } return lenMixed; } } }; CaseFolder *Editor::CaseFolderForEncoding() { // Simple default that only maps ASCII upper case to lower case. return new CaseFolderASCII(); } /** * Search of a text in the document, in the given range. * @return The position of the found text, -1 if not found. */ long Editor::FindText( uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX. sptr_t lParam) { ///< @c TextToFind structure: The text to search for in the given range. Sci_TextToFind *ft = reinterpret_cast(lParam); int lengthFound = istrlen(ft->lpstrText); std::auto_ptr pcf(CaseFolderForEncoding()); int pos = pdoc->FindText(ft->chrg.cpMin, ft->chrg.cpMax, ft->lpstrText, (wParam & SCFIND_MATCHCASE) != 0, (wParam & SCFIND_WHOLEWORD) != 0, (wParam & SCFIND_WORDSTART) != 0, (wParam & SCFIND_REGEXP) != 0, wParam, &lengthFound, pcf.get()); if (pos != -1) { ft->chrgText.cpMin = pos; ft->chrgText.cpMax = pos + lengthFound; } return pos; } /** * Relocatable search support : Searches relative to current selection * point and sets the selection to the found text range with * each search. */ /** * Anchor following searches at current selection start: This allows * multiple incremental interactive searches to be macro recorded * while still setting the selection to found text so the find/select * operation is self-contained. */ void Editor::SearchAnchor() { searchAnchor = SelectionStart().Position(); } /** * Find text from current search anchor: Must call @c SearchAnchor first. * Used for next text and previous text requests. * @return The position of the found text, -1 if not found. */ long Editor::SearchText( unsigned int iMessage, ///< Accepts both @c SCI_SEARCHNEXT and @c SCI_SEARCHPREV. uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX. sptr_t lParam) { ///< The text to search for. const char *txt = reinterpret_cast(lParam); int pos; int lengthFound = istrlen(txt); std::auto_ptr pcf(CaseFolderForEncoding()); if (iMessage == SCI_SEARCHNEXT) { pos = pdoc->FindText(searchAnchor, pdoc->Length(), txt, (wParam & SCFIND_MATCHCASE) != 0, (wParam & SCFIND_WHOLEWORD) != 0, (wParam & SCFIND_WORDSTART) != 0, (wParam & SCFIND_REGEXP) != 0, wParam, &lengthFound, pcf.get()); } else { pos = pdoc->FindText(searchAnchor, 0, txt, (wParam & SCFIND_MATCHCASE) != 0, (wParam & SCFIND_WHOLEWORD) != 0, (wParam & SCFIND_WORDSTART) != 0, (wParam & SCFIND_REGEXP) != 0, wParam, &lengthFound, pcf.get()); } if (pos != -1) { SetSelection(pos, pos + lengthFound); } return pos; } std::string Editor::CaseMapString(const std::string &s, int caseMapping) { std::string ret(s); for (size_t i=0; i= 'a' && ret[i] <= 'z') ret[i] = static_cast(ret[i] - 'a' + 'A'); break; case cmLower: if (ret[i] >= 'A' && ret[i] <= 'Z') ret[i] = static_cast(ret[i] - 'A' + 'a'); break; } } return ret; } /** * Search for text in the target range of the document. * @return The position of the found text, -1 if not found. */ long Editor::SearchInTarget(const char *text, int length) { int lengthFound = length; std::auto_ptr pcf(CaseFolderForEncoding()); int pos = pdoc->FindText(targetStart, targetEnd, text, (searchFlags & SCFIND_MATCHCASE) != 0, (searchFlags & SCFIND_WHOLEWORD) != 0, (searchFlags & SCFIND_WORDSTART) != 0, (searchFlags & SCFIND_REGEXP) != 0, searchFlags, &lengthFound, pcf.get()); if (pos != -1) { targetStart = pos; targetEnd = pos + lengthFound; } return pos; } void Editor::GoToLine(int lineNo) { if (lineNo > pdoc->LinesTotal()) lineNo = pdoc->LinesTotal(); if (lineNo < 0) lineNo = 0; SetEmptySelection(pdoc->LineStart(lineNo)); ShowCaretAtCurrentPosition(); EnsureCaretVisible(); } static bool Close(Point pt1, Point pt2) { if (abs(pt1.x - pt2.x) > 3) return false; if (abs(pt1.y - pt2.y) > 3) return false; return true; } char *Editor::CopyRange(int start, int end) { char *text = 0; if (start < end) { int len = end - start; text = new char[len + 1]; for (int i = 0; i < len; i++) { text[i] = pdoc->CharAt(start + i); } text[len] = '\0'; } return text; } void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) { if (sel.Empty()) { if (allowLineCopy) { int currentLine = pdoc->LineFromPosition(sel.MainCaret()); int start = pdoc->LineStart(currentLine); int end = pdoc->LineEnd(currentLine); char *text = CopyRange(start, end); size_t textLen = text ? strlen(text) : 0; // include room for \r\n\0 textLen += 3; char *textWithEndl = new char[textLen]; textWithEndl[0] = '\0'; if (text) strncat(textWithEndl, text, textLen); if (pdoc->eolMode != SC_EOL_LF) strncat(textWithEndl, "\r", textLen); if (pdoc->eolMode != SC_EOL_CR) strncat(textWithEndl, "\n", textLen); ss->Set(textWithEndl, static_cast(strlen(textWithEndl) + 1), pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, true); delete []text; } } else { int delimiterLength = 0; if (sel.selType == Selection::selRectangle) { if (pdoc->eolMode == SC_EOL_CRLF) { delimiterLength = 2; } else { delimiterLength = 1; } } size_t size = sel.Length() + delimiterLength * sel.Count(); char *text = new char[size + 1]; int j = 0; std::vector rangesInOrder = sel.RangesCopy(); if (sel.selType == Selection::selRectangle) std::sort(rangesInOrder.begin(), rangesInOrder.end()); for (size_t r=0; rCharAt(i); } if (sel.selType == Selection::selRectangle) { if (pdoc->eolMode != SC_EOL_LF) { text[j++] = '\r'; } if (pdoc->eolMode != SC_EOL_CR) { text[j++] = '\n'; } } } text[size] = '\0'; ss->Set(text, static_cast(size + 1), pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, sel.IsRectangular(), sel.selType == Selection::selLines); } } void Editor::CopyRangeToClipboard(int start, int end) { start = pdoc->ClampPositionIntoDocument(start); end = pdoc->ClampPositionIntoDocument(end); SelectionText selectedText; selectedText.Set(CopyRange(start, end), end - start + 1, pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false); CopyToClipboard(selectedText); } void Editor::CopyText(int length, const char *text) { SelectionText selectedText; selectedText.Copy(text, length + 1, pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false); CopyToClipboard(selectedText); } void Editor::SetDragPosition(SelectionPosition newPos) { if (newPos.Position() >= 0) { newPos = MovePositionOutsideChar(newPos, 1); posDrop = newPos; } if (!(posDrag == newPos)) { caret.on = true; SetTicking(true); InvalidateCaret(); posDrag = newPos; InvalidateCaret(); } } void Editor::DisplayCursor(Window::Cursor c) { if (cursorMode == SC_CURSORNORMAL) wMain.SetCursor(c); else wMain.SetCursor(static_cast(cursorMode)); } bool Editor::DragThreshold(Point ptStart, Point ptNow) { int xMove = ptStart.x - ptNow.x; int yMove = ptStart.y - ptNow.y; int distanceSquared = xMove * xMove + yMove * yMove; return distanceSquared > 16; } void Editor::StartDrag() { // Always handled by subclasses //SetMouseCapture(true); //DisplayCursor(Window::cursorArrow); } void Editor::DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular) { //Platform::DebugPrintf("DropAt %d %d\n", inDragDrop, position); if (inDragDrop == ddDragging) dropWentOutside = false; bool positionWasInSelection = PositionInSelection(position.Position()); bool positionOnEdgeOfSelection = (position == SelectionStart()) || (position == SelectionEnd()); if ((inDragDrop != ddDragging) || !(positionWasInSelection) || (positionOnEdgeOfSelection && !moving)) { SelectionPosition selStart = SelectionStart(); SelectionPosition selEnd = SelectionEnd(); UndoGroup ug(pdoc); SelectionPosition positionAfterDeletion = position; if ((inDragDrop == ddDragging) && moving) { // Remove dragged out text if (rectangular || sel.selType == Selection::selLines) { for (size_t r=0; r= sel.Range(r).Start()) { if (position > sel.Range(r).End()) { positionAfterDeletion.Add(-sel.Range(r).Length()); } else { positionAfterDeletion.Add(-SelectionRange(position, sel.Range(r).Start()).Length()); } } } } else { if (position > selStart) { positionAfterDeletion.Add(-SelectionRange(selEnd, selStart).Length()); } } ClearSelection(); } position = positionAfterDeletion; if (rectangular) { PasteRectangular(position, value, istrlen(value)); // Should try to select new rectangle but it may not be a rectangle now so just select the drop position SetEmptySelection(position); } else { position = MovePositionOutsideChar(position, sel.MainCaret() - position.Position()); position = SelectionPosition(InsertSpace(position.Position(), position.VirtualSpace())); if (pdoc->InsertCString(position.Position(), value)) { SelectionPosition posAfterInsertion = position; posAfterInsertion.Add(istrlen(value)); SetSelection(posAfterInsertion, position); } } } else if (inDragDrop == ddDragging) { SetEmptySelection(position); } } /** * @return true if given position is inside the selection, */ bool Editor::PositionInSelection(int pos) { pos = MovePositionOutsideChar(pos, sel.MainCaret() - pos); for (size_t r=0; r ptPos.x) { hit = false; } } if (hit) return true; } } return false; } bool Editor::PointInSelMargin(Point pt) { // Really means: "Point in a margin" if (vs.fixedColumnWidth > 0) { // There is a margin PRectangle rcSelMargin = GetClientRectangle(); rcSelMargin.right = vs.fixedColumnWidth - vs.leftMarginWidth; return rcSelMargin.Contains(pt); } else { return false; } } Window::Cursor Editor::GetMarginCursor(Point pt) { int x = 0; for (int margin = 0; margin < ViewStyle::margins; margin++) { if ((pt.x >= x) && (pt.x < x + vs.ms[margin].width)) return static_cast(vs.ms[margin].cursor); x += vs.ms[margin].width; } return Window::cursorReverseArrow; } void Editor::LineSelection(int lineCurrentPos_, int lineAnchorPos_, bool wholeLine) { int selCurrentPos, selAnchorPos; if (wholeLine) { int lineCurrent_ = pdoc->LineFromPosition(lineCurrentPos_); int lineAnchor_ = pdoc->LineFromPosition(lineAnchorPos_); if (lineAnchorPos_ < lineCurrentPos_) { selCurrentPos = pdoc->LineStart(lineCurrent_ + 1); selAnchorPos = pdoc->LineStart(lineAnchor_); } else if (lineAnchorPos_ > lineCurrentPos_) { selCurrentPos = pdoc->LineStart(lineCurrent_); selAnchorPos = pdoc->LineStart(lineAnchor_ + 1); } else { // Same line, select it selCurrentPos = pdoc->LineStart(lineAnchor_ + 1); selAnchorPos = pdoc->LineStart(lineAnchor_); } } else { if (lineAnchorPos_ < lineCurrentPos_) { selCurrentPos = StartEndDisplayLine(lineCurrentPos_, false) + 1; selCurrentPos = pdoc->MovePositionOutsideChar(selCurrentPos, 1); selAnchorPos = StartEndDisplayLine(lineAnchorPos_, true); } else if (lineAnchorPos_ > lineCurrentPos_) { selCurrentPos = StartEndDisplayLine(lineCurrentPos_, true); selAnchorPos = StartEndDisplayLine(lineAnchorPos_, false) + 1; selAnchorPos = pdoc->MovePositionOutsideChar(selAnchorPos, 1); } else { // Same line, select it selCurrentPos = StartEndDisplayLine(lineAnchorPos_, false) + 1; selCurrentPos = pdoc->MovePositionOutsideChar(selCurrentPos, 1); selAnchorPos = StartEndDisplayLine(lineAnchorPos_, true); } } SetSelection(selCurrentPos, selAnchorPos); } void Editor::WordSelection(int pos) { if (pos < wordSelectAnchorStartPos) { // Extend backward to the word containing pos. // Skip ExtendWordSelect if the line is empty or if pos is after the last character. // This ensures that a series of empty lines isn't counted as a single "word". if (!pdoc->IsLineEndPosition(pos)) pos = pdoc->ExtendWordSelect(pdoc->MovePositionOutsideChar(pos + 1, 1), -1); SetSelection(pos, wordSelectAnchorEndPos); } else if (pos > wordSelectAnchorEndPos) { // Extend forward to the word containing the character to the left of pos. // Skip ExtendWordSelect if the line is empty or if pos is the first position on the line. // This ensures that a series of empty lines isn't counted as a single "word". if (pos > pdoc->LineStart(pdoc->LineFromPosition(pos))) pos = pdoc->ExtendWordSelect(pdoc->MovePositionOutsideChar(pos - 1, -1), 1); SetSelection(pos, wordSelectAnchorStartPos); } else { // Select only the anchored word if (pos >= originalAnchorPos) SetSelection(wordSelectAnchorEndPos, wordSelectAnchorStartPos); else SetSelection(wordSelectAnchorStartPos, wordSelectAnchorEndPos); } } void Editor::DwellEnd(bool mouseMoved) { if (mouseMoved) ticksToDwell = dwellDelay; else ticksToDwell = SC_TIME_FOREVER; if (dwelling && (dwellDelay < SC_TIME_FOREVER)) { dwelling = false; NotifyDwelling(ptMouseLast, dwelling); } } void Editor::MouseLeave() { SetHotSpotRange(NULL); if (!HaveMouseCapture()) { ptMouseLast = Point(-1,-1); DwellEnd(true); } } static bool AllowVirtualSpace(int virtualSpaceOptions, bool rectangular) { return ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0) || (rectangular && ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) != 0)); } void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) { //Platform::DebugPrintf("ButtonDown %d %d = %d alt=%d %d\n", curTime, lastClickTime, curTime - lastClickTime, alt, inDragDrop); ptMouseLast = pt; SelectionPosition newPos = SPositionFromLocation(pt, false, false, AllowVirtualSpace(virtualSpaceOptions, alt)); newPos = MovePositionOutsideChar(newPos, sel.MainCaret() - newPos.Position()); inDragDrop = ddNone; sel.SetMoveExtends(false); if (NotifyMarginClick(pt, shift, ctrl, alt)) return; NotifyIndicatorClick(true, newPos.Position(), shift, ctrl, alt); bool inSelMargin = PointInSelMargin(pt); // In margin ctrl+(double)click should always select everything if (ctrl && inSelMargin) { SelectAll(); lastClickTime = curTime; lastClick = pt; return; } if (shift && !inSelMargin) { SetSelection(newPos); } if (((curTime - lastClickTime) < Platform::DoubleClickTime()) && Close(pt, lastClick)) { //Platform::DebugPrintf("Double click %d %d = %d\n", curTime, lastClickTime, curTime - lastClickTime); SetMouseCapture(true); SetEmptySelection(newPos.Position()); bool doubleClick = false; // Stop mouse button bounce changing selection type if (!Platform::MouseButtonBounce() || curTime != lastClickTime) { if (inSelMargin) { // Inside margin selection type should be either selSubLine or selWholeLine. if (selectionType == selSubLine) { // If it is selSubLine, we're inside a *double* click and word wrap is enabled, // so we switch to selWholeLine in order to select whole line. selectionType = selWholeLine; } else if (selectionType != selSubLine && selectionType != selWholeLine) { // If it is neither, reset selection type to line selection. selectionType = ((wrapState != eWrapNone) && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine; } } else { if (selectionType == selChar) { selectionType = selWord; doubleClick = true; } else if (selectionType == selWord) { // Since we ended up here, we're inside a *triple* click, which should always select // whole line irregardless of word wrap being enabled or not. selectionType = selWholeLine; } else { selectionType = selChar; originalAnchorPos = sel.MainCaret(); } } } if (selectionType == selWord) { int charPos = originalAnchorPos; if (sel.MainCaret() == originalAnchorPos) { charPos = PositionFromLocation(pt, false, true); charPos = MovePositionOutsideChar(charPos, -1); } int startWord, endWord; if ((sel.MainCaret() >= originalAnchorPos) && !pdoc->IsLineEndPosition(charPos)) { startWord = pdoc->ExtendWordSelect(pdoc->MovePositionOutsideChar(charPos + 1, 1), -1); endWord = pdoc->ExtendWordSelect(charPos, 1); } else { // Selecting backwards, or anchor beyond last character on line. In these cases, // we select the word containing the character to the *left* of the anchor. if (charPos > pdoc->LineStart(pdoc->LineFromPosition(charPos))) { startWord = pdoc->ExtendWordSelect(charPos, -1); endWord = pdoc->ExtendWordSelect(startWord, 1); } else { // Anchor at start of line; select nothing to begin with. startWord = charPos; endWord = charPos; } } wordSelectAnchorStartPos = startWord; wordSelectAnchorEndPos = endWord; wordSelectInitialCaretPos = sel.MainCaret(); WordSelection(wordSelectInitialCaretPos); } else if (selectionType == selSubLine || selectionType == selWholeLine) { lineAnchorPos = newPos.Position(); LineSelection(lineAnchorPos, lineAnchorPos, selectionType == selWholeLine); //Platform::DebugPrintf("Triple click: %d - %d\n", anchor, currentPos); } else { SetEmptySelection(sel.MainCaret()); } //Platform::DebugPrintf("Double click: %d - %d\n", anchor, currentPos); if (doubleClick) { NotifyDoubleClick(pt, shift, ctrl, alt); if (PositionIsHotspot(newPos.Position())) NotifyHotSpotDoubleClicked(newPos.Position(), shift, ctrl, alt); } } else { // Single click if (inSelMargin) { sel.selType = Selection::selStream; if (!shift) { // Single click in margin: select whole line or only subline if word wrap is enabled lineAnchorPos = newPos.Position(); selectionType = ((wrapState != eWrapNone) && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine; LineSelection(lineAnchorPos, lineAnchorPos, selectionType == selWholeLine); } else { // Single shift+click in margin: select from line anchor to clicked line if (sel.MainAnchor() > sel.MainCaret()) lineAnchorPos = sel.MainAnchor() - 1; else lineAnchorPos = sel.MainAnchor(); // Reset selection type if there is an empty selection. // This ensures that we don't end up stuck in previous selection mode, which is no longer valid. // Otherwise, if there's a non empty selection, reset selection type only if it differs from selSubLine and selWholeLine. // This ensures that we continue selecting in the same selection mode. if (sel.Empty() || (selectionType != selSubLine && selectionType != selWholeLine)) selectionType = ((wrapState != eWrapNone) && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine; LineSelection(newPos.Position(), lineAnchorPos, selectionType == selWholeLine); } SetDragPosition(SelectionPosition(invalidPosition)); SetMouseCapture(true); } else { if (PointIsHotspot(pt)) { NotifyHotSpotClicked(newPos.Position(), shift, ctrl, alt); hotSpotClickPos = PositionFromLocation(pt,true,false); } if (!shift) { if (PointInSelection(pt) && !SelectionEmpty()) inDragDrop = ddInitial; else inDragDrop = ddNone; } SetMouseCapture(true); if (inDragDrop != ddInitial) { SetDragPosition(SelectionPosition(invalidPosition)); if (!shift) { if (ctrl && multipleSelection) { SelectionRange range(newPos); sel.TentativeSelection(range); InvalidateSelection(range, true); } else { InvalidateSelection(SelectionRange(newPos), true); if (sel.Count() > 1) Redraw(); if ((sel.Count() > 1) || (sel.selType != Selection::selStream)) sel.Clear(); sel.selType = alt ? Selection::selRectangle : Selection::selStream; SetSelection(newPos, newPos); } } SelectionPosition anchorCurrent = newPos; if (shift) anchorCurrent = sel.IsRectangular() ? sel.Rectangular().anchor : sel.RangeMain().anchor; sel.selType = alt ? Selection::selRectangle : Selection::selStream; selectionType = selChar; originalAnchorPos = sel.MainCaret(); sel.Rectangular() = SelectionRange(newPos, anchorCurrent); SetRectangularRange(); } } } lastClickTime = curTime; lastClick = pt; lastXChosen = pt.x + xOffset; ShowCaretAtCurrentPosition(); } bool Editor::PositionIsHotspot(int position) { return vs.styles[pdoc->StyleAt(position) & pdoc->stylingBitsMask].hotspot; } bool Editor::PointIsHotspot(Point pt) { int pos = PositionFromLocation(pt, true); if (pos == INVALID_POSITION) return false; return PositionIsHotspot(pos); } void Editor::SetHotSpotRange(Point *pt) { if (pt) { int pos = PositionFromLocation(*pt); // If we don't limit this to word characters then the // range can encompass more than the run range and then // the underline will not be drawn properly. int hsStart_ = pdoc->ExtendStyleRange(pos, -1, vs.hotspotSingleLine); int hsEnd_ = pdoc->ExtendStyleRange(pos, 1, vs.hotspotSingleLine); // Only invalidate the range if the hotspot range has changed... if (hsStart_ != hsStart || hsEnd_ != hsEnd) { if (hsStart != -1) { InvalidateRange(hsStart, hsEnd); } hsStart = hsStart_; hsEnd = hsEnd_; InvalidateRange(hsStart, hsEnd); } } else { if (hsStart != -1) { int hsStart_ = hsStart; int hsEnd_ = hsEnd; hsStart = -1; hsEnd = -1; InvalidateRange(hsStart_, hsEnd_); } else { hsStart = -1; hsEnd = -1; } } } void Editor::GetHotSpotRange(int &hsStart_, int &hsEnd_) { hsStart_ = hsStart; hsEnd_ = hsEnd; } void Editor::ButtonMove(Point pt) { if ((ptMouseLast.x != pt.x) || (ptMouseLast.y != pt.y)) { DwellEnd(true); } SelectionPosition movePos = SPositionFromLocation(pt, false, false, AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular())); movePos = MovePositionOutsideChar(movePos, sel.MainCaret() - movePos.Position()); if (inDragDrop == ddInitial) { if (DragThreshold(ptMouseLast, pt)) { SetMouseCapture(false); SetDragPosition(movePos); CopySelectionRange(&drag); StartDrag(); } return; } ptMouseLast = pt; //Platform::DebugPrintf("Move %d %d\n", pt.x, pt.y); if (HaveMouseCapture()) { // Slow down autoscrolling/selection autoScrollTimer.ticksToWait -= timer.tickSize; if (autoScrollTimer.ticksToWait > 0) return; autoScrollTimer.ticksToWait = autoScrollDelay; // Adjust selection if (posDrag.IsValid()) { SetDragPosition(movePos); } else { if (selectionType == selChar) { if (sel.IsRectangular()) { sel.Rectangular() = SelectionRange(movePos, sel.Rectangular().anchor); SetSelection(movePos, sel.RangeMain().anchor); } else if (sel.Count() > 1) { SelectionRange range(movePos, sel.RangeMain().anchor); sel.TentativeSelection(range); InvalidateSelection(range, true); } else { SetSelection(movePos, sel.RangeMain().anchor); } } else if (selectionType == selWord) { // Continue selecting by word if (movePos.Position() == wordSelectInitialCaretPos) { // Didn't move // No need to do anything. Previously this case was lumped // in with "Moved forward", but that can be harmful in this // case: a handler for the NotifyDoubleClick re-adjusts // the selection for a fancier definition of "word" (for // example, in Perl it is useful to include the leading // '$', '%' or '@' on variables for word selection). In this // the ButtonMove() called via Tick() for auto-scrolling // could result in the fancier word selection adjustment // being unmade. } else { wordSelectInitialCaretPos = -1; WordSelection(movePos.Position()); } } else { // Continue selecting by line LineSelection(movePos.Position(), lineAnchorPos, selectionType == selWholeLine); } } // Autoscroll PRectangle rcClient = GetClientRectangle(); int lineMove = DisplayFromPosition(movePos.Position()); if (pt.y > rcClient.bottom) { ScrollTo(lineMove - LinesOnScreen() + 1); Redraw(); } else if (pt.y < rcClient.top) { ScrollTo(lineMove); Redraw(); } EnsureCaretVisible(false, false, true); if (hsStart != -1 && !PositionIsHotspot(movePos.Position())) SetHotSpotRange(NULL); if (hotSpotClickPos != INVALID_POSITION && PositionFromLocation(pt,true,false) != hotSpotClickPos) { if (inDragDrop == ddNone) { DisplayCursor(Window::cursorText); } hotSpotClickPos = INVALID_POSITION; } } else { if (vs.fixedColumnWidth > 0) { // There is a margin if (PointInSelMargin(pt)) { DisplayCursor(GetMarginCursor(pt)); SetHotSpotRange(NULL); return; // No need to test for selection } } // Display regular (drag) cursor over selection if (PointInSelection(pt) && !SelectionEmpty()) { DisplayCursor(Window::cursorArrow); } else if (PointIsHotspot(pt)) { DisplayCursor(Window::cursorHand); SetHotSpotRange(&pt); } else { DisplayCursor(Window::cursorText); SetHotSpotRange(NULL); } } } void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { //Platform::DebugPrintf("ButtonUp %d %d\n", HaveMouseCapture(), inDragDrop); SelectionPosition newPos = SPositionFromLocation(pt, false, false, AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular())); newPos = MovePositionOutsideChar(newPos, sel.MainCaret() - newPos.Position()); if (inDragDrop == ddInitial) { inDragDrop = ddNone; SetEmptySelection(newPos); selectionType = selChar; originalAnchorPos = sel.MainCaret(); } if (hotSpotClickPos != INVALID_POSITION && PointIsHotspot(pt)) { hotSpotClickPos = INVALID_POSITION; NotifyHotSpotReleaseClick(newPos.Position(), false, ctrl, false); } if (HaveMouseCapture()) { if (PointInSelMargin(pt)) { DisplayCursor(GetMarginCursor(pt)); } else { DisplayCursor(Window::cursorText); SetHotSpotRange(NULL); } ptMouseLast = pt; SetMouseCapture(false); NotifyIndicatorClick(false, newPos.Position(), false, false, false); if (inDragDrop == ddDragging) { SelectionPosition selStart = SelectionStart(); SelectionPosition selEnd = SelectionEnd(); if (selStart < selEnd) { if (drag.len) { if (ctrl) { if (pdoc->InsertString(newPos.Position(), drag.s, drag.len)) { SetSelection(newPos.Position(), newPos.Position() + drag.len); } } else if (newPos < selStart) { pdoc->DeleteChars(selStart.Position(), drag.len); if (pdoc->InsertString(newPos.Position(), drag.s, drag.len)) { SetSelection(newPos.Position(), newPos.Position() + drag.len); } } else if (newPos > selEnd) { pdoc->DeleteChars(selStart.Position(), drag.len); newPos.Add(-drag.len); if (pdoc->InsertString(newPos.Position(), drag.s, drag.len)) { SetSelection(newPos.Position(), newPos.Position() + drag.len); } } else { SetEmptySelection(newPos.Position()); } drag.Free(); } selectionType = selChar; } } else { if (selectionType == selChar) { if (sel.Count() > 1) { sel.RangeMain() = SelectionRange(newPos, sel.Range(sel.Count() - 1).anchor); InvalidateSelection(sel.RangeMain(), true); } else { SetSelection(newPos, sel.RangeMain().anchor); } } sel.CommitTentative(); } SetRectangularRange(); lastClickTime = curTime; lastClick = pt; lastXChosen = pt.x + xOffset; if (sel.selType == Selection::selStream) { SetLastXChosen(); } inDragDrop = ddNone; EnsureCaretVisible(false); } } // Called frequently to perform background UI including // caret blinking and automatic scrolling. void Editor::Tick() { if (HaveMouseCapture()) { // Auto scroll ButtonMove(ptMouseLast); } if (caret.period > 0) { timer.ticksToWait -= timer.tickSize; if (timer.ticksToWait <= 0) { caret.on = !caret.on; timer.ticksToWait = caret.period; if (caret.active) { InvalidateCaret(); } } } if (horizontalScrollBarVisible && trackLineWidth && (lineWidthMaxSeen > scrollWidth)) { scrollWidth = lineWidthMaxSeen; SetScrollBars(); } if ((dwellDelay < SC_TIME_FOREVER) && (ticksToDwell > 0) && (!HaveMouseCapture()) && (ptMouseLast.y >= 0)) { ticksToDwell -= timer.tickSize; if (ticksToDwell <= 0) { dwelling = true; NotifyDwelling(ptMouseLast, dwelling); } } } bool Editor::Idle() { bool idleDone; bool wrappingDone = wrapState == eWrapNone; if (!wrappingDone) { // Wrap lines during idle. WrapLines(false, -1); // No more wrapping if (wrapStart == wrapEnd) wrappingDone = true; } // Add more idle things to do here, but make sure idleDone is // set correctly before the function returns. returning // false will stop calling this idle funtion until SetIdle() is // called again. idleDone = wrappingDone; // && thatDone && theOtherThingDone... return !idleDone; } void Editor::SetFocusState(bool focusState) { hasFocus = focusState; NotifyFocus(hasFocus); if (hasFocus) { ShowCaretAtCurrentPosition(); } else { CancelModes(); DropCaret(); } } int Editor::PositionAfterArea(PRectangle rcArea) { // The start of the document line after the display line after the area // This often means that the line after a modification is restyled which helps // detect multiline comment additions and heals single line comments int lineAfter = topLine + (rcArea.bottom - 1) / vs.lineHeight + 1; if (lineAfter < cs.LinesDisplayed()) return pdoc->LineStart(cs.DocFromDisplay(lineAfter) + 1); else return pdoc->Length(); } // Style to a position within the view. If this causes a change at end of last line then // affects later lines so style all the viewed text. void Editor::StyleToPositionInView(Position pos) { int endWindow = PositionAfterArea(GetClientRectangle()); if (pos > endWindow) pos = endWindow; int styleAtEnd = pdoc->StyleAt(pos-1); pdoc->EnsureStyledTo(pos); if ((endWindow > pos) && (styleAtEnd != pdoc->StyleAt(pos-1))) { // Style at end of line changed so is multi-line change like starting a comment // so require rest of window to be styled. pdoc->EnsureStyledTo(endWindow); } } void Editor::IdleStyling() { // Style the line after the modification as this allows modifications that change just the // line of the modification to heal instead of propagating to the rest of the window. StyleToPositionInView(pdoc->LineStart(pdoc->LineFromPosition(styleNeeded.upTo) + 2)); if (needUpdateUI) { NotifyUpdateUI(); needUpdateUI = 0; } styleNeeded.Reset(); } void Editor::QueueStyling(int upTo) { styleNeeded.NeedUpTo(upTo); } bool Editor::PaintContains(PRectangle rc) { if (rc.Empty()) { return true; } else { return rcPaint.Contains(rc); } } bool Editor::PaintContainsMargin() { PRectangle rcSelMargin = GetClientRectangle(); rcSelMargin.right = vs.fixedColumnWidth; return PaintContains(rcSelMargin); } void Editor::CheckForChangeOutsidePaint(Range r) { if (paintState == painting && !paintingAllText) { //Platform::DebugPrintf("Checking range in paint %d-%d\n", r.start, r.end); if (!r.Valid()) return; PRectangle rcRange = RectangleFromRange(r.start, r.end); PRectangle rcText = GetTextRectangle(); if (rcRange.top < rcText.top) { rcRange.top = rcText.top; } if (rcRange.bottom > rcText.bottom) { rcRange.bottom = rcText.bottom; } if (!PaintContains(rcRange)) { AbandonPaint(); } } } void Editor::SetBraceHighlight(Position pos0, Position pos1, int matchStyle) { if ((pos0 != braces[0]) || (pos1 != braces[1]) || (matchStyle != bracesMatchStyle)) { if ((braces[0] != pos0) || (matchStyle != bracesMatchStyle)) { CheckForChangeOutsidePaint(Range(braces[0])); CheckForChangeOutsidePaint(Range(pos0)); braces[0] = pos0; } if ((braces[1] != pos1) || (matchStyle != bracesMatchStyle)) { CheckForChangeOutsidePaint(Range(braces[1])); CheckForChangeOutsidePaint(Range(pos1)); braces[1] = pos1; } bracesMatchStyle = matchStyle; if (paintState == notPainting) { Redraw(); } } } void Editor::SetAnnotationHeights(int start, int end) { if (vs.annotationVisible) { bool changedHeight = false; for (int line=start; lineLinesTotal(); line++) { int linesWrapped = 1; if (wrapState != eWrapNone) { AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(line)); if (surface && ll) { LayoutLine(line, surface, vs, ll, wrapWidth); linesWrapped = ll->lines; } } if (cs.SetHeight(line, pdoc->AnnotationLines(line) + linesWrapped)) changedHeight = true; } if (changedHeight) { Redraw(); } } } void Editor::SetDocPointer(Document *document) { //Platform::DebugPrintf("** %x setdoc to %x\n", pdoc, document); pdoc->RemoveWatcher(this, 0); pdoc->Release(); if (document == NULL) { pdoc = new Document(); } else { pdoc = document; } pdoc->AddRef(); // Ensure all positions within document sel.Clear(); targetStart = 0; targetEnd = 0; braces[0] = invalidPosition; braces[1] = invalidPosition; // Reset the contraction state to fully shown. cs.Clear(); cs.InsertLines(0, pdoc->LinesTotal() - 1); SetAnnotationHeights(0, pdoc->LinesTotal()); llc.Deallocate(); NeedWrapping(); pdoc->AddWatcher(this, 0); SetScrollBars(); Redraw(); } void Editor::SetAnnotationVisible(int visible) { if (vs.annotationVisible != visible) { bool changedFromOrToHidden = ((vs.annotationVisible != 0) != (visible != 0)); vs.annotationVisible = visible; if (changedFromOrToHidden) { int dir = vs.annotationVisible ? 1 : -1; for (int line=0; lineLinesTotal(); line++) { int annotationLines = pdoc->AnnotationLines(line); if (annotationLines > 0) { cs.SetHeight(line, cs.GetHeight(line) + annotationLines * dir); } } } Redraw(); } } /** * Recursively expand a fold, making lines visible except where they have an unexpanded parent. */ void Editor::Expand(int &line, bool doExpand) { int lineMaxSubord = pdoc->GetLastChild(line); line++; while (line <= lineMaxSubord) { if (doExpand) cs.SetVisible(line, line, true); int level = pdoc->GetLevel(line); if (level & SC_FOLDLEVELHEADERFLAG) { if (doExpand && cs.GetExpanded(line)) { Expand(line, true); } else { Expand(line, false); } } else { line++; } } } void Editor::ToggleContraction(int line) { if (line >= 0) { if ((pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) == 0) { line = pdoc->GetFoldParent(line); if (line < 0) return; } if (cs.GetExpanded(line)) { int lineMaxSubord = pdoc->GetLastChild(line); if (lineMaxSubord > line) { cs.SetExpanded(line, 0); cs.SetVisible(line + 1, lineMaxSubord, false); int lineCurrent = pdoc->LineFromPosition(sel.MainCaret()); if (lineCurrent > line && lineCurrent <= lineMaxSubord) { // This does not re-expand the fold EnsureCaretVisible(); } SetScrollBars(); Redraw(); } } else { if (!(cs.GetVisible(line))) { EnsureLineVisible(line, false); GoToLine(line); } cs.SetExpanded(line, 1); Expand(line, true); SetScrollBars(); Redraw(); } } } int Editor::ContractedFoldNext(int lineStart) { for (int line = lineStart; lineLinesTotal();) { if (!cs.GetExpanded(line) && (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG)) return line; line = cs.ContractedNext(line+1); if (line < 0) return -1; } return -1; } /** * Recurse up from this line to find any folds that prevent this line from being visible * and unfold them all. */ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) { // In case in need of wrapping to ensure DisplayFromDoc works. if (lineDoc >= wrapStart) WrapLines(true, -1); if (!cs.GetVisible(lineDoc)) { int lookLine = lineDoc; int lookLineLevel = pdoc->GetLevel(lookLine); while ((lookLine > 0) && (lookLineLevel & SC_FOLDLEVELWHITEFLAG)) { lookLineLevel = pdoc->GetLevel(--lookLine); } int lineParent = pdoc->GetFoldParent(lookLine); if (lineParent >= 0) { if (lineDoc != lineParent) EnsureLineVisible(lineParent, enforcePolicy); if (!cs.GetExpanded(lineParent)) { cs.SetExpanded(lineParent, 1); Expand(lineParent, true); } } SetScrollBars(); Redraw(); } if (enforcePolicy) { int lineDisplay = cs.DisplayFromDoc(lineDoc); if (visiblePolicy & VISIBLE_SLOP) { if ((topLine > lineDisplay) || ((visiblePolicy & VISIBLE_STRICT) && (topLine + visibleSlop > lineDisplay))) { SetTopLine(Platform::Clamp(lineDisplay - visibleSlop, 0, MaxScrollPos())); SetVerticalScrollPos(); Redraw(); } else if ((lineDisplay > topLine + LinesOnScreen() - 1) || ((visiblePolicy & VISIBLE_STRICT) && (lineDisplay > topLine + LinesOnScreen() - 1 - visibleSlop))) { SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos())); SetVerticalScrollPos(); Redraw(); } } else { if ((topLine > lineDisplay) || (lineDisplay > topLine + LinesOnScreen() - 1) || (visiblePolicy & VISIBLE_STRICT)) { SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() / 2 + 1, 0, MaxScrollPos())); SetVerticalScrollPos(); Redraw(); } } } } int Editor::GetTag(char *tagValue, int tagNumber) { char name[3] = "\\?"; const char *text = 0; int length = 0; if ((tagNumber >= 1) && (tagNumber <= 9)) { name[1] = static_cast(tagNumber + '0'); length = 2; text = pdoc->SubstituteByPosition(name, &length); } if (tagValue) { if (text) memcpy(tagValue, text, length + 1); else *tagValue = '\0'; } return length; } int Editor::ReplaceTarget(bool replacePatterns, const char *text, int length) { UndoGroup ug(pdoc); if (length == -1) length = istrlen(text); if (replacePatterns) { text = pdoc->SubstituteByPosition(text, &length); if (!text) { return 0; } } if (targetStart != targetEnd) pdoc->DeleteChars(targetStart, targetEnd - targetStart); targetEnd = targetStart; pdoc->InsertString(targetStart, text, length); targetEnd = targetStart + length; return length; } bool Editor::IsUnicodeMode() const { return pdoc && (SC_CP_UTF8 == pdoc->dbcsCodePage); } int Editor::CodePage() const { if (pdoc) return pdoc->dbcsCodePage; else return 0; } int Editor::WrapCount(int line) { AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(line)); if (surface && ll) { LayoutLine(line, surface, vs, ll, wrapWidth); return ll->lines; } else { return 1; } } void Editor::AddStyledText(char *buffer, int appendLength) { // The buffer consists of alternating character bytes and style bytes int textLength = appendLength / 2; char *text = new char[textLength]; int i; for (i = 0; i < textLength; i++) { text[i] = buffer[i*2]; } pdoc->InsertString(CurrentPosition(), text, textLength); for (i = 0; i < textLength; i++) { text[i] = buffer[i*2+1]; } pdoc->StartStyling(CurrentPosition(), static_cast(0xff)); pdoc->SetStyles(textLength, text); delete []text; SetEmptySelection(sel.MainCaret() + textLength); } static bool ValidMargin(unsigned long wParam) { return wParam < ViewStyle::margins; } static char *CharPtrFromSPtr(sptr_t lParam) { return reinterpret_cast(lParam); } void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { vs.EnsureStyle(wParam); switch (iMessage) { case SCI_STYLESETFORE: vs.styles[wParam].fore = ColourDesired(lParam); break; case SCI_STYLESETBACK: vs.styles[wParam].back = ColourDesired(lParam); break; case SCI_STYLESETBOLD: vs.styles[wParam].weight = lParam != 0 ? SC_WEIGHT_BOLD : SC_WEIGHT_NORMAL; break; case SCI_STYLESETWEIGHT: vs.styles[wParam].weight = lParam; break; case SCI_STYLESETITALIC: vs.styles[wParam].italic = lParam != 0; break; case SCI_STYLESETEOLFILLED: vs.styles[wParam].eolFilled = lParam != 0; break; case SCI_STYLESETSIZE: vs.styles[wParam].size = lParam * SC_FONT_SIZE_MULTIPLIER; break; case SCI_STYLESETSIZEFRACTIONAL: vs.styles[wParam].size = lParam; break; case SCI_STYLESETFONT: if (lParam != 0) { vs.SetStyleFontName(wParam, CharPtrFromSPtr(lParam)); } break; case SCI_STYLESETUNDERLINE: vs.styles[wParam].underline = lParam != 0; break; case SCI_STYLESETCASE: vs.styles[wParam].caseForce = static_cast(lParam); break; case SCI_STYLESETCHARACTERSET: vs.styles[wParam].characterSet = lParam; break; case SCI_STYLESETVISIBLE: vs.styles[wParam].visible = lParam != 0; break; case SCI_STYLESETCHANGEABLE: vs.styles[wParam].changeable = lParam != 0; break; case SCI_STYLESETHOTSPOT: vs.styles[wParam].hotspot = lParam != 0; break; } InvalidateStyleRedraw(); } sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { vs.EnsureStyle(wParam); switch (iMessage) { case SCI_STYLEGETFORE: return vs.styles[wParam].fore.AsLong(); case SCI_STYLEGETBACK: return vs.styles[wParam].back.AsLong(); case SCI_STYLEGETBOLD: return vs.styles[wParam].weight > SC_WEIGHT_NORMAL; case SCI_STYLEGETWEIGHT: return vs.styles[wParam].weight; case SCI_STYLEGETITALIC: return vs.styles[wParam].italic ? 1 : 0; case SCI_STYLEGETEOLFILLED: return vs.styles[wParam].eolFilled ? 1 : 0; case SCI_STYLEGETSIZE: return vs.styles[wParam].size / SC_FONT_SIZE_MULTIPLIER; case SCI_STYLEGETSIZEFRACTIONAL: return vs.styles[wParam].size; case SCI_STYLEGETFONT: if (!vs.styles[wParam].fontName) return 0; if (lParam != 0) strcpy(CharPtrFromSPtr(lParam), vs.styles[wParam].fontName); return strlen(vs.styles[wParam].fontName); case SCI_STYLEGETUNDERLINE: return vs.styles[wParam].underline ? 1 : 0; case SCI_STYLEGETCASE: return static_cast(vs.styles[wParam].caseForce); case SCI_STYLEGETCHARACTERSET: return vs.styles[wParam].characterSet; case SCI_STYLEGETVISIBLE: return vs.styles[wParam].visible ? 1 : 0; case SCI_STYLEGETCHANGEABLE: return vs.styles[wParam].changeable ? 1 : 0; case SCI_STYLEGETHOTSPOT: return vs.styles[wParam].hotspot ? 1 : 0; } return 0; } sptr_t Editor::StringResult(sptr_t lParam, const char *val) { const size_t n = strlen(val); if (lParam != 0) { char *ptr = reinterpret_cast(lParam); strcpy(ptr, val); } return n; // Not including NUL } sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { //Platform::DebugPrintf("S start wnd proc %d %d %d\n",iMessage, wParam, lParam); // Optional macro recording hook if (recordingMacro) NotifyMacroRecord(iMessage, wParam, lParam); switch (iMessage) { case SCI_GETTEXT: { if (lParam == 0) return pdoc->Length() + 1; if (wParam == 0) return 0; char *ptr = CharPtrFromSPtr(lParam); unsigned int iChar = 0; for (; iChar < wParam - 1; iChar++) ptr[iChar] = pdoc->CharAt(iChar); ptr[iChar] = '\0'; return iChar; } case SCI_SETTEXT: { if (lParam == 0) return 0; UndoGroup ug(pdoc); pdoc->DeleteChars(0, pdoc->Length()); SetEmptySelection(0); pdoc->InsertCString(0, CharPtrFromSPtr(lParam)); return 1; } case SCI_GETTEXTLENGTH: return pdoc->Length(); case SCI_CUT: Cut(); SetLastXChosen(); break; case SCI_COPY: Copy(); break; case SCI_COPYALLOWLINE: CopyAllowLine(); break; case SCI_VERTICALCENTRECARET: VerticalCentreCaret(); break; case SCI_MOVESELECTEDLINESUP: MoveSelectedLinesUp(); break; case SCI_MOVESELECTEDLINESDOWN: MoveSelectedLinesDown(); break; case SCI_COPYRANGE: CopyRangeToClipboard(wParam, lParam); break; case SCI_COPYTEXT: CopyText(wParam, CharPtrFromSPtr(lParam)); break; case SCI_PASTE: Paste(); if ((caretSticky == SC_CARETSTICKY_OFF) || (caretSticky == SC_CARETSTICKY_WHITESPACE)) { SetLastXChosen(); } EnsureCaretVisible(); break; case SCI_CLEAR: Clear(); SetLastXChosen(); EnsureCaretVisible(); break; case SCI_UNDO: Undo(); SetLastXChosen(); break; case SCI_CANUNDO: return (pdoc->CanUndo() && !pdoc->IsReadOnly()) ? 1 : 0; case SCI_EMPTYUNDOBUFFER: pdoc->DeleteUndoHistory(); return 0; case SCI_GETFIRSTVISIBLELINE: return topLine; case SCI_SETFIRSTVISIBLELINE: ScrollTo(wParam); break; case SCI_GETLINE: { // Risk of overwriting the end of the buffer int lineStart = pdoc->LineStart(wParam); int lineEnd = pdoc->LineStart(wParam + 1); if (lParam == 0) { return lineEnd - lineStart; } char *ptr = CharPtrFromSPtr(lParam); int iPlace = 0; for (int iChar = lineStart; iChar < lineEnd; iChar++) { ptr[iPlace++] = pdoc->CharAt(iChar); } return iPlace; } case SCI_GETLINECOUNT: if (pdoc->LinesTotal() == 0) return 1; else return pdoc->LinesTotal(); case SCI_GETMODIFY: return !pdoc->IsSavePoint(); case SCI_SETSEL: { int nStart = static_cast(wParam); int nEnd = static_cast(lParam); if (nEnd < 0) nEnd = pdoc->Length(); if (nStart < 0) nStart = nEnd; // Remove selection InvalidateSelection(SelectionRange(nStart, nEnd)); sel.Clear(); sel.selType = Selection::selStream; SetSelection(nEnd, nStart); EnsureCaretVisible(); } break; case SCI_GETSELTEXT: { SelectionText selectedText; CopySelectionRange(&selectedText); if (lParam == 0) { return selectedText.len ? selectedText.len : 1; } else { char *ptr = CharPtrFromSPtr(lParam); int iChar = 0; if (selectedText.len) { for (; iChar < selectedText.len; iChar++) ptr[iChar] = selectedText.s[iChar]; } else { ptr[0] = '\0'; } return iChar; } } case SCI_LINEFROMPOSITION: if (static_cast(wParam) < 0) return 0; return pdoc->LineFromPosition(wParam); case SCI_POSITIONFROMLINE: if (static_cast(wParam) < 0) wParam = pdoc->LineFromPosition(SelectionStart().Position()); if (wParam == 0) return 0; // Even if there is no text, there is a first line that starts at 0 if (static_cast(wParam) > pdoc->LinesTotal()) return -1; //if (wParam > pdoc->LineFromPosition(pdoc->Length())) // Useful test, anyway... // return -1; return pdoc->LineStart(wParam); // Replacement of the old Scintilla interpretation of EM_LINELENGTH case SCI_LINELENGTH: if ((static_cast(wParam) < 0) || (static_cast(wParam) > pdoc->LineFromPosition(pdoc->Length()))) return 0; return pdoc->LineStart(wParam + 1) - pdoc->LineStart(wParam); case SCI_REPLACESEL: { if (lParam == 0) return 0; UndoGroup ug(pdoc); ClearSelection(); char *replacement = CharPtrFromSPtr(lParam); pdoc->InsertCString(sel.MainCaret(), replacement); SetEmptySelection(sel.MainCaret() + istrlen(replacement)); EnsureCaretVisible(); } break; case SCI_SETTARGETSTART: targetStart = wParam; break; case SCI_GETTARGETSTART: return targetStart; case SCI_SETTARGETEND: targetEnd = wParam; break; case SCI_GETTARGETEND: return targetEnd; case SCI_TARGETFROMSELECTION: if (sel.MainCaret() < sel.MainAnchor()) { targetStart = sel.MainCaret(); targetEnd = sel.MainAnchor(); } else { targetStart = sel.MainAnchor(); targetEnd = sel.MainCaret(); } break; case SCI_REPLACETARGET: PLATFORM_ASSERT(lParam); return ReplaceTarget(false, CharPtrFromSPtr(lParam), wParam); case SCI_REPLACETARGETRE: PLATFORM_ASSERT(lParam); return ReplaceTarget(true, CharPtrFromSPtr(lParam), wParam); case SCI_SEARCHINTARGET: PLATFORM_ASSERT(lParam); return SearchInTarget(CharPtrFromSPtr(lParam), wParam); case SCI_SETSEARCHFLAGS: searchFlags = wParam; break; case SCI_GETSEARCHFLAGS: return searchFlags; case SCI_GETTAG: return GetTag(CharPtrFromSPtr(lParam), wParam); case SCI_POSITIONBEFORE: return pdoc->MovePositionOutsideChar(wParam - 1, -1, true); case SCI_POSITIONAFTER: return pdoc->MovePositionOutsideChar(wParam + 1, 1, true); case SCI_LINESCROLL: ScrollTo(topLine + lParam); HorizontalScrollTo(xOffset + wParam * vs.spaceWidth); return 1; case SCI_SETXOFFSET: xOffset = wParam; ContainerNeedsUpdate(SC_UPDATE_H_SCROLL); SetHorizontalScrollPos(); Redraw(); break; case SCI_GETXOFFSET: return xOffset; case SCI_CHOOSECARETX: SetLastXChosen(); break; case SCI_SCROLLCARET: EnsureCaretVisible(); break; case SCI_SETREADONLY: pdoc->SetReadOnly(wParam != 0); return 1; case SCI_GETREADONLY: return pdoc->IsReadOnly(); case SCI_CANPASTE: return CanPaste(); case SCI_POINTXFROMPOSITION: if (lParam < 0) { return 0; } else { Point pt = LocationFromPosition(lParam); return pt.x; } case SCI_POINTYFROMPOSITION: if (lParam < 0) { return 0; } else { Point pt = LocationFromPosition(lParam); return pt.y; } case SCI_FINDTEXT: return FindText(wParam, lParam); case SCI_GETTEXTRANGE: { if (lParam == 0) return 0; Sci_TextRange *tr = reinterpret_cast(lParam); int cpMax = tr->chrg.cpMax; if (cpMax == -1) cpMax = pdoc->Length(); PLATFORM_ASSERT(cpMax <= pdoc->Length()); int len = cpMax - tr->chrg.cpMin; // No -1 as cpMin and cpMax are referring to inter character positions pdoc->GetCharRange(tr->lpstrText, tr->chrg.cpMin, len); // Spec says copied text is terminated with a NUL tr->lpstrText[len] = '\0'; return len; // Not including NUL } case SCI_HIDESELECTION: hideSelection = wParam != 0; Redraw(); break; case SCI_FORMATRANGE: return FormatRange(wParam != 0, reinterpret_cast(lParam)); case SCI_GETMARGINLEFT: return vs.leftMarginWidth; case SCI_GETMARGINRIGHT: return vs.rightMarginWidth; case SCI_SETMARGINLEFT: vs.leftMarginWidth = lParam; InvalidateStyleRedraw(); break; case SCI_SETMARGINRIGHT: vs.rightMarginWidth = lParam; InvalidateStyleRedraw(); break; // Control specific mesages case SCI_ADDTEXT: { if (lParam == 0) return 0; pdoc->InsertString(CurrentPosition(), CharPtrFromSPtr(lParam), wParam); SetEmptySelection(sel.MainCaret() + wParam); return 0; } case SCI_ADDSTYLEDTEXT: if (lParam) AddStyledText(CharPtrFromSPtr(lParam), wParam); return 0; case SCI_INSERTTEXT: { if (lParam == 0) return 0; int insertPos = wParam; if (static_cast(wParam) == -1) insertPos = CurrentPosition(); int newCurrent = CurrentPosition(); char *sz = CharPtrFromSPtr(lParam); pdoc->InsertCString(insertPos, sz); if (newCurrent > insertPos) newCurrent += istrlen(sz); SetEmptySelection(newCurrent); return 0; } case SCI_APPENDTEXT: pdoc->InsertString(pdoc->Length(), CharPtrFromSPtr(lParam), wParam); return 0; case SCI_CLEARALL: ClearAll(); return 0; case SCI_CLEARDOCUMENTSTYLE: ClearDocumentStyle(); return 0; case SCI_SETUNDOCOLLECTION: pdoc->SetUndoCollection(wParam != 0); return 0; case SCI_GETUNDOCOLLECTION: return pdoc->IsCollectingUndo(); case SCI_BEGINUNDOACTION: pdoc->BeginUndoAction(); return 0; case SCI_ENDUNDOACTION: pdoc->EndUndoAction(); return 0; case SCI_GETCARETPERIOD: return caret.period; case SCI_SETCARETPERIOD: caret.period = wParam; break; case SCI_SETWORDCHARS: { pdoc->SetDefaultCharClasses(false); if (lParam == 0) return 0; pdoc->SetCharClasses(reinterpret_cast(lParam), CharClassify::ccWord); } break; case SCI_SETWHITESPACECHARS: { if (lParam == 0) return 0; pdoc->SetCharClasses(reinterpret_cast(lParam), CharClassify::ccSpace); } break; case SCI_SETCHARSDEFAULT: pdoc->SetDefaultCharClasses(true); break; case SCI_GETLENGTH: return pdoc->Length(); case SCI_ALLOCATE: pdoc->Allocate(wParam); break; case SCI_GETCHARAT: return pdoc->CharAt(wParam); case SCI_SETCURRENTPOS: if (sel.IsRectangular()) { sel.Rectangular().caret.SetPosition(wParam); SetRectangularRange(); Redraw(); } else { SetSelection(wParam, sel.MainAnchor()); } break; case SCI_GETCURRENTPOS: return sel.IsRectangular() ? sel.Rectangular().caret.Position() : sel.MainCaret(); case SCI_SETANCHOR: if (sel.IsRectangular()) { sel.Rectangular().anchor.SetPosition(wParam); SetRectangularRange(); Redraw(); } else { SetSelection(sel.MainCaret(), wParam); } break; case SCI_GETANCHOR: return sel.IsRectangular() ? sel.Rectangular().anchor.Position() : sel.MainAnchor(); case SCI_SETSELECTIONSTART: SetSelection(Platform::Maximum(sel.MainCaret(), wParam), wParam); break; case SCI_GETSELECTIONSTART: return sel.LimitsForRectangularElseMain().start.Position(); case SCI_SETSELECTIONEND: SetSelection(wParam, Platform::Minimum(sel.MainAnchor(), wParam)); break; case SCI_GETSELECTIONEND: return sel.LimitsForRectangularElseMain().end.Position(); case SCI_SETEMPTYSELECTION: SetEmptySelection(wParam); break; case SCI_SETPRINTMAGNIFICATION: printMagnification = wParam; break; case SCI_GETPRINTMAGNIFICATION: return printMagnification; case SCI_SETPRINTCOLOURMODE: printColourMode = wParam; break; case SCI_GETPRINTCOLOURMODE: return printColourMode; case SCI_SETPRINTWRAPMODE: printWrapState = (wParam == SC_WRAP_WORD) ? eWrapWord : eWrapNone; break; case SCI_GETPRINTWRAPMODE: return printWrapState; case SCI_GETSTYLEAT: if (static_cast(wParam) >= pdoc->Length()) return 0; else return pdoc->StyleAt(wParam); case SCI_REDO: Redo(); break; case SCI_SELECTALL: SelectAll(); break; case SCI_SETSAVEPOINT: pdoc->SetSavePoint(); break; case SCI_GETSTYLEDTEXT: { if (lParam == 0) return 0; Sci_TextRange *tr = reinterpret_cast(lParam); int iPlace = 0; for (int iChar = tr->chrg.cpMin; iChar < tr->chrg.cpMax; iChar++) { tr->lpstrText[iPlace++] = pdoc->CharAt(iChar); tr->lpstrText[iPlace++] = pdoc->StyleAt(iChar); } tr->lpstrText[iPlace] = '\0'; tr->lpstrText[iPlace + 1] = '\0'; return iPlace; } case SCI_CANREDO: return (pdoc->CanRedo() && !pdoc->IsReadOnly()) ? 1 : 0; case SCI_MARKERLINEFROMHANDLE: return pdoc->LineFromHandle(wParam); case SCI_MARKERDELETEHANDLE: pdoc->DeleteMarkFromHandle(wParam); break; case SCI_GETVIEWWS: return vs.viewWhitespace; case SCI_SETVIEWWS: vs.viewWhitespace = static_cast(wParam); Redraw(); break; case SCI_GETWHITESPACESIZE: return vs.whitespaceSize; case SCI_SETWHITESPACESIZE: vs.whitespaceSize = static_cast(wParam); Redraw(); break; case SCI_POSITIONFROMPOINT: return PositionFromLocation(Point(wParam, lParam), false, false); case SCI_POSITIONFROMPOINTCLOSE: return PositionFromLocation(Point(wParam, lParam), true, false); case SCI_CHARPOSITIONFROMPOINT: return PositionFromLocation(Point(wParam, lParam), false, true); case SCI_CHARPOSITIONFROMPOINTCLOSE: return PositionFromLocation(Point(wParam, lParam), true, true); case SCI_GOTOLINE: GoToLine(wParam); break; case SCI_GOTOPOS: SetEmptySelection(wParam); EnsureCaretVisible(); break; case SCI_GETCURLINE: { int lineCurrentPos = pdoc->LineFromPosition(sel.MainCaret()); int lineStart = pdoc->LineStart(lineCurrentPos); unsigned int lineEnd = pdoc->LineStart(lineCurrentPos + 1); if (lParam == 0) { return 1 + lineEnd - lineStart; } PLATFORM_ASSERT(wParam > 0); char *ptr = CharPtrFromSPtr(lParam); unsigned int iPlace = 0; for (unsigned int iChar = lineStart; iChar < lineEnd && iPlace < wParam - 1; iChar++) { ptr[iPlace++] = pdoc->CharAt(iChar); } ptr[iPlace] = '\0'; return sel.MainCaret() - lineStart; } case SCI_GETENDSTYLED: return pdoc->GetEndStyled(); case SCI_GETEOLMODE: return pdoc->eolMode; case SCI_SETEOLMODE: pdoc->eolMode = wParam; break; case SCI_STARTSTYLING: pdoc->StartStyling(wParam, static_cast(lParam)); break; case SCI_SETSTYLING: pdoc->SetStyleFor(wParam, static_cast(lParam)); break; case SCI_SETSTYLINGEX: // Specify a complete styling buffer if (lParam == 0) return 0; pdoc->SetStyles(wParam, CharPtrFromSPtr(lParam)); break; case SCI_SETBUFFEREDDRAW: bufferedDraw = wParam != 0; break; case SCI_GETBUFFEREDDRAW: return bufferedDraw; case SCI_GETTWOPHASEDRAW: return twoPhaseDraw; case SCI_SETTWOPHASEDRAW: twoPhaseDraw = wParam != 0; InvalidateStyleRedraw(); break; case SCI_SETFONTQUALITY: vs.extraFontFlag &= ~SC_EFF_QUALITY_MASK; vs.extraFontFlag |= (wParam & SC_EFF_QUALITY_MASK); InvalidateStyleRedraw(); break; case SCI_GETFONTQUALITY: return (vs.extraFontFlag & SC_EFF_QUALITY_MASK); case SCI_SETTABWIDTH: if (wParam > 0) { pdoc->tabInChars = wParam; if (pdoc->indentInChars == 0) pdoc->actualIndentInChars = pdoc->tabInChars; } InvalidateStyleRedraw(); break; case SCI_GETTABWIDTH: return pdoc->tabInChars; case SCI_SETINDENT: pdoc->indentInChars = wParam; if (pdoc->indentInChars != 0) pdoc->actualIndentInChars = pdoc->indentInChars; else pdoc->actualIndentInChars = pdoc->tabInChars; InvalidateStyleRedraw(); break; case SCI_GETINDENT: return pdoc->indentInChars; case SCI_SETUSETABS: pdoc->useTabs = wParam != 0; InvalidateStyleRedraw(); break; case SCI_GETUSETABS: return pdoc->useTabs; case SCI_SETLINEINDENTATION: pdoc->SetLineIndentation(wParam, lParam); break; case SCI_GETLINEINDENTATION: return pdoc->GetLineIndentation(wParam); case SCI_GETLINEINDENTPOSITION: return pdoc->GetLineIndentPosition(wParam); case SCI_SETTABINDENTS: pdoc->tabIndents = wParam != 0; break; case SCI_GETTABINDENTS: return pdoc->tabIndents; case SCI_SETBACKSPACEUNINDENTS: pdoc->backspaceUnindents = wParam != 0; break; case SCI_GETBACKSPACEUNINDENTS: return pdoc->backspaceUnindents; case SCI_SETMOUSEDWELLTIME: dwellDelay = wParam; ticksToDwell = dwellDelay; break; case SCI_GETMOUSEDWELLTIME: return dwellDelay; case SCI_WORDSTARTPOSITION: return pdoc->ExtendWordSelect(wParam, -1, lParam != 0); case SCI_WORDENDPOSITION: return pdoc->ExtendWordSelect(wParam, 1, lParam != 0); case SCI_SETWRAPMODE: switch (wParam) { case SC_WRAP_WORD: wrapState = eWrapWord; break; case SC_WRAP_CHAR: wrapState = eWrapChar; break; default: wrapState = eWrapNone; break; } xOffset = 0; ContainerNeedsUpdate(SC_UPDATE_H_SCROLL); InvalidateStyleRedraw(); ReconfigureScrollBars(); break; case SCI_GETWRAPMODE: return wrapState; case SCI_SETWRAPVISUALFLAGS: if (wrapVisualFlags != static_cast(wParam)) { wrapVisualFlags = wParam; InvalidateStyleRedraw(); ReconfigureScrollBars(); } break; case SCI_GETWRAPVISUALFLAGS: return wrapVisualFlags; case SCI_SETWRAPVISUALFLAGSLOCATION: wrapVisualFlagsLocation = wParam; InvalidateStyleRedraw(); break; case SCI_GETWRAPVISUALFLAGSLOCATION: return wrapVisualFlagsLocation; case SCI_SETWRAPSTARTINDENT: if (wrapVisualStartIndent != static_cast(wParam)) { wrapVisualStartIndent = wParam; InvalidateStyleRedraw(); ReconfigureScrollBars(); } break; case SCI_GETWRAPSTARTINDENT: return wrapVisualStartIndent; case SCI_SETWRAPINDENTMODE: if (wrapIndentMode != static_cast(wParam)) { wrapIndentMode = wParam; InvalidateStyleRedraw(); ReconfigureScrollBars(); } break; case SCI_GETWRAPINDENTMODE: return wrapIndentMode; case SCI_SETLAYOUTCACHE: llc.SetLevel(wParam); break; case SCI_GETLAYOUTCACHE: return llc.GetLevel(); case SCI_SETPOSITIONCACHE: posCache.SetSize(wParam); break; case SCI_GETPOSITIONCACHE: return posCache.GetSize(); case SCI_SETSCROLLWIDTH: PLATFORM_ASSERT(wParam > 0); if ((wParam > 0) && (wParam != static_cast(scrollWidth))) { lineWidthMaxSeen = 0; scrollWidth = wParam; SetScrollBars(); } break; case SCI_GETSCROLLWIDTH: return scrollWidth; case SCI_SETSCROLLWIDTHTRACKING: trackLineWidth = wParam != 0; break; case SCI_GETSCROLLWIDTHTRACKING: return trackLineWidth; case SCI_LINESJOIN: LinesJoin(); break; case SCI_LINESSPLIT: LinesSplit(wParam); break; case SCI_TEXTWIDTH: PLATFORM_ASSERT(wParam < vs.stylesSize); PLATFORM_ASSERT(lParam); return TextWidth(wParam, CharPtrFromSPtr(lParam)); case SCI_TEXTHEIGHT: return vs.lineHeight; case SCI_SETENDATLASTLINE: PLATFORM_ASSERT((wParam == 0) || (wParam == 1)); if (endAtLastLine != (wParam != 0)) { endAtLastLine = wParam != 0; SetScrollBars(); } break; case SCI_GETENDATLASTLINE: return endAtLastLine; case SCI_SETCARETSTICKY: PLATFORM_ASSERT(wParam <= SC_CARETSTICKY_WHITESPACE); if (wParam <= SC_CARETSTICKY_WHITESPACE) { caretSticky = wParam; } break; case SCI_GETCARETSTICKY: return caretSticky; case SCI_TOGGLECARETSTICKY: caretSticky = !caretSticky; break; case SCI_GETCOLUMN: return pdoc->GetColumn(wParam); case SCI_FINDCOLUMN: return pdoc->FindColumn(wParam, lParam); case SCI_SETHSCROLLBAR : if (horizontalScrollBarVisible != (wParam != 0)) { horizontalScrollBarVisible = wParam != 0; SetScrollBars(); ReconfigureScrollBars(); } break; case SCI_GETHSCROLLBAR: return horizontalScrollBarVisible; case SCI_SETVSCROLLBAR: if (verticalScrollBarVisible != (wParam != 0)) { verticalScrollBarVisible = wParam != 0; SetScrollBars(); ReconfigureScrollBars(); } break; case SCI_GETVSCROLLBAR: return verticalScrollBarVisible; case SCI_SETINDENTATIONGUIDES: vs.viewIndentationGuides = IndentView(wParam); Redraw(); break; case SCI_GETINDENTATIONGUIDES: return vs.viewIndentationGuides; case SCI_SETHIGHLIGHTGUIDE: if ((highlightGuideColumn != static_cast(wParam)) || (wParam > 0)) { highlightGuideColumn = wParam; Redraw(); } break; case SCI_GETHIGHLIGHTGUIDE: return highlightGuideColumn; case SCI_GETLINEENDPOSITION: return pdoc->LineEnd(wParam); case SCI_SETCODEPAGE: if (ValidCodePage(wParam)) { pdoc->dbcsCodePage = wParam; InvalidateStyleRedraw(); } break; case SCI_GETCODEPAGE: return pdoc->dbcsCodePage; #ifdef INCLUDE_DEPRECATED_FEATURES case SCI_SETUSEPALETTE: InvalidateStyleRedraw(); break; case SCI_GETUSEPALETTE: return 0; #endif // Marker definition and setting case SCI_MARKERDEFINE: if (wParam <= MARKER_MAX) { vs.markers[wParam].markType = lParam; vs.CalcLargestMarkerHeight(); } InvalidateStyleData(); RedrawSelMargin(); break; case SCI_MARKERSYMBOLDEFINED: if (wParam <= MARKER_MAX) return vs.markers[wParam].markType; else return 0; case SCI_MARKERSETFORE: if (wParam <= MARKER_MAX) vs.markers[wParam].fore = ColourDesired(lParam); InvalidateStyleData(); RedrawSelMargin(); break; case SCI_MARKERSETBACKSELECTED: if (wParam <= MARKER_MAX) vs.markers[wParam].backSelected = ColourDesired(lParam); InvalidateStyleData(); RedrawSelMargin(); break; case SCI_MARKERENABLEHIGHLIGHT: highlightDelimiter.isEnabled = wParam == 1; RedrawSelMargin(); break; case SCI_MARKERSETBACK: if (wParam <= MARKER_MAX) vs.markers[wParam].back = ColourDesired(lParam); InvalidateStyleData(); RedrawSelMargin(); break; case SCI_MARKERSETALPHA: if (wParam <= MARKER_MAX) vs.markers[wParam].alpha = lParam; InvalidateStyleRedraw(); break; case SCI_MARKERADD: { int markerID = pdoc->AddMark(wParam, lParam); return markerID; } case SCI_MARKERADDSET: if (lParam != 0) pdoc->AddMarkSet(wParam, lParam); break; case SCI_MARKERDELETE: pdoc->DeleteMark(wParam, lParam); break; case SCI_MARKERDELETEALL: pdoc->DeleteAllMarks(static_cast(wParam)); break; case SCI_MARKERGET: return pdoc->GetMark(wParam); case SCI_MARKERNEXT: return pdoc->MarkerNext(wParam, lParam); case SCI_MARKERPREVIOUS: { for (int iLine = wParam; iLine >= 0; iLine--) { if ((pdoc->GetMark(iLine) & lParam) != 0) return iLine; } } return -1; case SCI_MARKERDEFINEPIXMAP: if (wParam <= MARKER_MAX) { vs.markers[wParam].SetXPM(CharPtrFromSPtr(lParam)); vs.CalcLargestMarkerHeight(); }; InvalidateStyleData(); RedrawSelMargin(); break; case SCI_RGBAIMAGESETWIDTH: sizeRGBAImage.x = wParam; break; case SCI_RGBAIMAGESETHEIGHT: sizeRGBAImage.y = wParam; break; case SCI_MARKERDEFINERGBAIMAGE: if (wParam <= MARKER_MAX) { vs.markers[wParam].SetRGBAImage(sizeRGBAImage, reinterpret_cast(lParam)); vs.CalcLargestMarkerHeight(); }; InvalidateStyleData(); RedrawSelMargin(); break; case SCI_SETMARGINTYPEN: if (ValidMargin(wParam)) { vs.ms[wParam].style = lParam; InvalidateStyleRedraw(); } break; case SCI_GETMARGINTYPEN: if (ValidMargin(wParam)) return vs.ms[wParam].style; else return 0; case SCI_SETMARGINWIDTHN: if (ValidMargin(wParam)) { // Short-circuit if the width is unchanged, to avoid unnecessary redraw. if (vs.ms[wParam].width != lParam) { vs.ms[wParam].width = lParam; InvalidateStyleRedraw(); } } break; case SCI_GETMARGINWIDTHN: if (ValidMargin(wParam)) return vs.ms[wParam].width; else return 0; case SCI_SETMARGINMASKN: if (ValidMargin(wParam)) { vs.ms[wParam].mask = lParam; InvalidateStyleRedraw(); } break; case SCI_GETMARGINMASKN: if (ValidMargin(wParam)) return vs.ms[wParam].mask; else return 0; case SCI_SETMARGINSENSITIVEN: if (ValidMargin(wParam)) { vs.ms[wParam].sensitive = lParam != 0; InvalidateStyleRedraw(); } break; case SCI_GETMARGINSENSITIVEN: if (ValidMargin(wParam)) return vs.ms[wParam].sensitive ? 1 : 0; else return 0; case SCI_SETMARGINCURSORN: if (ValidMargin(wParam)) vs.ms[wParam].cursor = lParam; break; case SCI_GETMARGINCURSORN: if (ValidMargin(wParam)) return vs.ms[wParam].cursor; else return 0; case SCI_STYLECLEARALL: vs.ClearStyles(); InvalidateStyleRedraw(); break; case SCI_STYLESETFORE: case SCI_STYLESETBACK: case SCI_STYLESETBOLD: case SCI_STYLESETWEIGHT: case SCI_STYLESETITALIC: case SCI_STYLESETEOLFILLED: case SCI_STYLESETSIZE: case SCI_STYLESETSIZEFRACTIONAL: case SCI_STYLESETFONT: case SCI_STYLESETUNDERLINE: case SCI_STYLESETCASE: case SCI_STYLESETCHARACTERSET: case SCI_STYLESETVISIBLE: case SCI_STYLESETCHANGEABLE: case SCI_STYLESETHOTSPOT: StyleSetMessage(iMessage, wParam, lParam); break; case SCI_STYLEGETFORE: case SCI_STYLEGETBACK: case SCI_STYLEGETBOLD: case SCI_STYLEGETWEIGHT: case SCI_STYLEGETITALIC: case SCI_STYLEGETEOLFILLED: case SCI_STYLEGETSIZE: case SCI_STYLEGETSIZEFRACTIONAL: case SCI_STYLEGETFONT: case SCI_STYLEGETUNDERLINE: case SCI_STYLEGETCASE: case SCI_STYLEGETCHARACTERSET: case SCI_STYLEGETVISIBLE: case SCI_STYLEGETCHANGEABLE: case SCI_STYLEGETHOTSPOT: return StyleGetMessage(iMessage, wParam, lParam); case SCI_STYLERESETDEFAULT: vs.ResetDefaultStyle(); InvalidateStyleRedraw(); break; case SCI_SETSTYLEBITS: vs.EnsureStyle((1 << wParam) - 1); pdoc->SetStylingBits(wParam); break; case SCI_GETSTYLEBITS: return pdoc->stylingBits; case SCI_SETLINESTATE: return pdoc->SetLineState(wParam, lParam); case SCI_GETLINESTATE: return pdoc->GetLineState(wParam); case SCI_GETMAXLINESTATE: return pdoc->GetMaxLineState(); case SCI_GETCARETLINEVISIBLE: return vs.showCaretLineBackground; case SCI_SETCARETLINEVISIBLE: vs.showCaretLineBackground = wParam != 0; InvalidateStyleRedraw(); break; case SCI_GETCARETLINEBACK: return vs.caretLineBackground.AsLong(); case SCI_SETCARETLINEBACK: vs.caretLineBackground = wParam; InvalidateStyleRedraw(); break; case SCI_GETCARETLINEBACKALPHA: return vs.caretLineAlpha; case SCI_SETCARETLINEBACKALPHA: vs.caretLineAlpha = wParam; InvalidateStyleRedraw(); break; // Folding messages case SCI_VISIBLEFROMDOCLINE: return cs.DisplayFromDoc(wParam); case SCI_DOCLINEFROMVISIBLE: return cs.DocFromDisplay(wParam); case SCI_WRAPCOUNT: return WrapCount(wParam); case SCI_SETFOLDLEVEL: { int prev = pdoc->SetLevel(wParam, lParam); if (prev != lParam) RedrawSelMargin(); return prev; } case SCI_GETFOLDLEVEL: return pdoc->GetLevel(wParam); case SCI_GETLASTCHILD: return pdoc->GetLastChild(wParam, lParam); case SCI_GETFOLDPARENT: return pdoc->GetFoldParent(wParam); case SCI_SHOWLINES: cs.SetVisible(wParam, lParam, true); SetScrollBars(); Redraw(); break; case SCI_HIDELINES: if (wParam > 0) cs.SetVisible(wParam, lParam, false); SetScrollBars(); Redraw(); break; case SCI_GETLINEVISIBLE: return cs.GetVisible(wParam); case SCI_GETALLLINESVISIBLE: return cs.HiddenLines() ? 0 : 1; case SCI_SETFOLDEXPANDED: if (cs.SetExpanded(wParam, lParam != 0)) { RedrawSelMargin(); } break; case SCI_GETFOLDEXPANDED: return cs.GetExpanded(wParam); case SCI_SETFOLDFLAGS: foldFlags = wParam; Redraw(); break; case SCI_TOGGLEFOLD: ToggleContraction(wParam); break; case SCI_CONTRACTEDFOLDNEXT: return ContractedFoldNext(wParam); case SCI_ENSUREVISIBLE: EnsureLineVisible(wParam, false); break; case SCI_ENSUREVISIBLEENFORCEPOLICY: EnsureLineVisible(wParam, true); break; case SCI_SEARCHANCHOR: SearchAnchor(); break; case SCI_SEARCHNEXT: case SCI_SEARCHPREV: return SearchText(iMessage, wParam, lParam); case SCI_SETXCARETPOLICY: caretXPolicy = wParam; caretXSlop = lParam; break; case SCI_SETYCARETPOLICY: caretYPolicy = wParam; caretYSlop = lParam; break; case SCI_SETVISIBLEPOLICY: visiblePolicy = wParam; visibleSlop = lParam; break; case SCI_LINESONSCREEN: return LinesOnScreen(); case SCI_SETSELFORE: vs.selforeset = wParam != 0; vs.selforeground = ColourDesired(lParam); vs.selAdditionalForeground = ColourDesired(lParam); InvalidateStyleRedraw(); break; case SCI_SETSELBACK: vs.selbackset = wParam != 0; vs.selbackground = ColourDesired(lParam); vs.selAdditionalBackground = ColourDesired(lParam); InvalidateStyleRedraw(); break; case SCI_SETSELALPHA: vs.selAlpha = wParam; vs.selAdditionalAlpha = wParam; InvalidateStyleRedraw(); break; case SCI_GETSELALPHA: return vs.selAlpha; case SCI_GETSELEOLFILLED: return vs.selEOLFilled; case SCI_SETSELEOLFILLED: vs.selEOLFilled = wParam != 0; InvalidateStyleRedraw(); break; case SCI_SETWHITESPACEFORE: vs.whitespaceForegroundSet = wParam != 0; vs.whitespaceForeground = ColourDesired(lParam); InvalidateStyleRedraw(); break; case SCI_SETWHITESPACEBACK: vs.whitespaceBackgroundSet = wParam != 0; vs.whitespaceBackground = ColourDesired(lParam); InvalidateStyleRedraw(); break; case SCI_SETCARETFORE: vs.caretcolour = ColourDesired(wParam); InvalidateStyleRedraw(); break; case SCI_GETCARETFORE: return vs.caretcolour.AsLong(); case SCI_SETCARETSTYLE: if (wParam <= CARETSTYLE_BLOCK) vs.caretStyle = wParam; else /* Default to the line caret */ vs.caretStyle = CARETSTYLE_LINE; InvalidateStyleRedraw(); break; case SCI_GETCARETSTYLE: return vs.caretStyle; case SCI_SETCARETWIDTH: if (static_cast(wParam) <= 0) vs.caretWidth = 0; else if (wParam >= 3) vs.caretWidth = 3; else vs.caretWidth = wParam; InvalidateStyleRedraw(); break; case SCI_GETCARETWIDTH: return vs.caretWidth; case SCI_ASSIGNCMDKEY: kmap.AssignCmdKey(Platform::LowShortFromLong(wParam), Platform::HighShortFromLong(wParam), lParam); break; case SCI_CLEARCMDKEY: kmap.AssignCmdKey(Platform::LowShortFromLong(wParam), Platform::HighShortFromLong(wParam), SCI_NULL); break; case SCI_CLEARALLCMDKEYS: kmap.Clear(); break; case SCI_INDICSETSTYLE: if (wParam <= INDIC_MAX) { vs.indicators[wParam].style = lParam; InvalidateStyleRedraw(); } break; case SCI_INDICGETSTYLE: return (wParam <= INDIC_MAX) ? vs.indicators[wParam].style : 0; case SCI_INDICSETFORE: if (wParam <= INDIC_MAX) { vs.indicators[wParam].fore = ColourDesired(lParam); InvalidateStyleRedraw(); } break; case SCI_INDICGETFORE: return (wParam <= INDIC_MAX) ? vs.indicators[wParam].fore.AsLong() : 0; case SCI_INDICSETUNDER: if (wParam <= INDIC_MAX) { vs.indicators[wParam].under = lParam != 0; InvalidateStyleRedraw(); } break; case SCI_INDICGETUNDER: return (wParam <= INDIC_MAX) ? vs.indicators[wParam].under : 0; case SCI_INDICSETALPHA: if (wParam <= INDIC_MAX && lParam >=0 && lParam <= 255) { vs.indicators[wParam].fillAlpha = lParam; InvalidateStyleRedraw(); } break; case SCI_INDICGETALPHA: return (wParam <= INDIC_MAX) ? vs.indicators[wParam].fillAlpha : 0; case SCI_INDICSETOUTLINEALPHA: if (wParam <= INDIC_MAX && lParam >=0 && lParam <= 255) { vs.indicators[wParam].outlineAlpha = lParam; InvalidateStyleRedraw(); } break; case SCI_INDICGETOUTLINEALPHA: return (wParam <= INDIC_MAX) ? vs.indicators[wParam].outlineAlpha : 0; case SCI_SETINDICATORCURRENT: pdoc->decorations.SetCurrentIndicator(wParam); break; case SCI_GETINDICATORCURRENT: return pdoc->decorations.GetCurrentIndicator(); case SCI_SETINDICATORVALUE: pdoc->decorations.SetCurrentValue(wParam); break; case SCI_GETINDICATORVALUE: return pdoc->decorations.GetCurrentValue(); case SCI_INDICATORFILLRANGE: pdoc->DecorationFillRange(wParam, pdoc->decorations.GetCurrentValue(), lParam); break; case SCI_INDICATORCLEARRANGE: pdoc->DecorationFillRange(wParam, 0, lParam); break; case SCI_INDICATORALLONFOR: return pdoc->decorations.AllOnFor(wParam); case SCI_INDICATORVALUEAT: return pdoc->decorations.ValueAt(wParam, lParam); case SCI_INDICATORSTART: return pdoc->decorations.Start(wParam, lParam); case SCI_INDICATOREND: return pdoc->decorations.End(wParam, lParam); case SCI_LINEDOWN: case SCI_LINEDOWNEXTEND: case SCI_PARADOWN: case SCI_PARADOWNEXTEND: case SCI_LINEUP: case SCI_LINEUPEXTEND: case SCI_PARAUP: case SCI_PARAUPEXTEND: case SCI_CHARLEFT: case SCI_CHARLEFTEXTEND: case SCI_CHARRIGHT: case SCI_CHARRIGHTEXTEND: case SCI_WORDLEFT: case SCI_WORDLEFTEXTEND: case SCI_WORDRIGHT: case SCI_WORDRIGHTEXTEND: case SCI_WORDLEFTEND: case SCI_WORDLEFTENDEXTEND: case SCI_WORDRIGHTEND: case SCI_WORDRIGHTENDEXTEND: case SCI_HOME: case SCI_HOMEEXTEND: case SCI_LINEEND: case SCI_LINEENDEXTEND: case SCI_HOMEWRAP: case SCI_HOMEWRAPEXTEND: case SCI_LINEENDWRAP: case SCI_LINEENDWRAPEXTEND: case SCI_DOCUMENTSTART: case SCI_DOCUMENTSTARTEXTEND: case SCI_DOCUMENTEND: case SCI_DOCUMENTENDEXTEND: case SCI_SCROLLTOSTART: case SCI_SCROLLTOEND: case SCI_STUTTEREDPAGEUP: case SCI_STUTTEREDPAGEUPEXTEND: case SCI_STUTTEREDPAGEDOWN: case SCI_STUTTEREDPAGEDOWNEXTEND: case SCI_PAGEUP: case SCI_PAGEUPEXTEND: case SCI_PAGEDOWN: case SCI_PAGEDOWNEXTEND: case SCI_EDITTOGGLEOVERTYPE: case SCI_CANCEL: case SCI_DELETEBACK: case SCI_TAB: case SCI_BACKTAB: case SCI_NEWLINE: case SCI_FORMFEED: case SCI_VCHOME: case SCI_VCHOMEEXTEND: case SCI_VCHOMEWRAP: case SCI_VCHOMEWRAPEXTEND: case SCI_ZOOMIN: case SCI_ZOOMOUT: case SCI_DELWORDLEFT: case SCI_DELWORDRIGHT: case SCI_DELWORDRIGHTEND: case SCI_DELLINELEFT: case SCI_DELLINERIGHT: case SCI_LINECOPY: case SCI_LINECUT: case SCI_LINEDELETE: case SCI_LINETRANSPOSE: case SCI_LINEDUPLICATE: case SCI_LOWERCASE: case SCI_UPPERCASE: case SCI_LINESCROLLDOWN: case SCI_LINESCROLLUP: case SCI_WORDPARTLEFT: case SCI_WORDPARTLEFTEXTEND: case SCI_WORDPARTRIGHT: case SCI_WORDPARTRIGHTEXTEND: case SCI_DELETEBACKNOTLINE: case SCI_HOMEDISPLAY: case SCI_HOMEDISPLAYEXTEND: case SCI_LINEENDDISPLAY: case SCI_LINEENDDISPLAYEXTEND: case SCI_LINEDOWNRECTEXTEND: case SCI_LINEUPRECTEXTEND: case SCI_CHARLEFTRECTEXTEND: case SCI_CHARRIGHTRECTEXTEND: case SCI_HOMERECTEXTEND: case SCI_VCHOMERECTEXTEND: case SCI_LINEENDRECTEXTEND: case SCI_PAGEUPRECTEXTEND: case SCI_PAGEDOWNRECTEXTEND: case SCI_SELECTIONDUPLICATE: return KeyCommand(iMessage); case SCI_BRACEHIGHLIGHT: SetBraceHighlight(static_cast(wParam), lParam, STYLE_BRACELIGHT); break; case SCI_BRACEHIGHLIGHTINDICATOR: if (lParam >= 0 && lParam <= INDIC_MAX) { vs.braceHighlightIndicatorSet = wParam != 0; vs.braceHighlightIndicator = lParam; } break; case SCI_BRACEBADLIGHT: SetBraceHighlight(static_cast(wParam), -1, STYLE_BRACEBAD); break; case SCI_BRACEBADLIGHTINDICATOR: if (lParam >= 0 && lParam <= INDIC_MAX) { vs.braceBadLightIndicatorSet = wParam != 0; vs.braceBadLightIndicator = lParam; } break; case SCI_BRACEMATCH: // wParam is position of char to find brace for, // lParam is maximum amount of text to restyle to find it return pdoc->BraceMatch(wParam, lParam); case SCI_GETVIEWEOL: return vs.viewEOL; case SCI_SETVIEWEOL: vs.viewEOL = wParam != 0; InvalidateStyleRedraw(); break; case SCI_SETZOOM: vs.zoomLevel = wParam; InvalidateStyleRedraw(); NotifyZoom(); break; case SCI_GETZOOM: return vs.zoomLevel; case SCI_GETEDGECOLUMN: return theEdge; case SCI_SETEDGECOLUMN: theEdge = wParam; InvalidateStyleRedraw(); break; case SCI_GETEDGEMODE: return vs.edgeState; case SCI_SETEDGEMODE: vs.edgeState = wParam; InvalidateStyleRedraw(); break; case SCI_GETEDGECOLOUR: return vs.edgecolour.AsLong(); case SCI_SETEDGECOLOUR: vs.edgecolour = ColourDesired(wParam); InvalidateStyleRedraw(); break; case SCI_GETDOCPOINTER: return reinterpret_cast(pdoc); case SCI_SETDOCPOINTER: CancelModes(); SetDocPointer(reinterpret_cast(lParam)); return 0; case SCI_CREATEDOCUMENT: { Document *doc = new Document(); if (doc) { doc->AddRef(); } return reinterpret_cast(doc); } case SCI_ADDREFDOCUMENT: (reinterpret_cast(lParam))->AddRef(); break; case SCI_RELEASEDOCUMENT: (reinterpret_cast(lParam))->Release(); break; case SCI_CREATELOADER: { Document *doc = new Document(); if (doc) { doc->AddRef(); doc->Allocate(wParam); doc->SetUndoCollection(false); } return reinterpret_cast(static_cast(doc)); } case SCI_SETMODEVENTMASK: modEventMask = wParam; return 0; case SCI_GETMODEVENTMASK: return modEventMask; case SCI_CONVERTEOLS: pdoc->ConvertLineEnds(wParam); SetSelection(sel.MainCaret(), sel.MainAnchor()); // Ensure selection inside document return 0; case SCI_SETLENGTHFORENCODE: lengthForEncode = wParam; return 0; case SCI_SELECTIONISRECTANGLE: return sel.selType == Selection::selRectangle ? 1 : 0; case SCI_SETSELECTIONMODE: { switch (wParam) { case SC_SEL_STREAM: sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selStream)); sel.selType = Selection::selStream; break; case SC_SEL_RECTANGLE: sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selRectangle)); sel.selType = Selection::selRectangle; break; case SC_SEL_LINES: sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selLines)); sel.selType = Selection::selLines; break; case SC_SEL_THIN: sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selThin)); sel.selType = Selection::selThin; break; default: sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selStream)); sel.selType = Selection::selStream; } InvalidateSelection(sel.RangeMain(), true); } case SCI_GETSELECTIONMODE: switch (sel.selType) { case Selection::selStream: return SC_SEL_STREAM; case Selection::selRectangle: return SC_SEL_RECTANGLE; case Selection::selLines: return SC_SEL_LINES; case Selection::selThin: return SC_SEL_THIN; default: // ?! return SC_SEL_STREAM; } case SCI_GETLINESELSTARTPOSITION: case SCI_GETLINESELENDPOSITION: { SelectionSegment segmentLine(SelectionPosition(pdoc->LineStart(wParam)), SelectionPosition(pdoc->LineEnd(wParam))); for (size_t r=0; r(pdoc->BufferPointer()); case SCI_SETEXTRAASCENT: vs.extraAscent = wParam; InvalidateStyleRedraw(); break; case SCI_GETEXTRAASCENT: return vs.extraAscent; case SCI_SETEXTRADESCENT: vs.extraDescent = wParam; InvalidateStyleRedraw(); break; case SCI_GETEXTRADESCENT: return vs.extraDescent; case SCI_MARGINSETSTYLEOFFSET: vs.marginStyleOffset = wParam; InvalidateStyleRedraw(); break; case SCI_MARGINGETSTYLEOFFSET: return vs.marginStyleOffset; case SCI_SETMARGINOPTIONS: marginOptions = wParam; break; case SCI_GETMARGINOPTIONS: return marginOptions; case SCI_MARGINSETTEXT: pdoc->MarginSetText(wParam, CharPtrFromSPtr(lParam)); break; case SCI_MARGINGETTEXT: { const StyledText st = pdoc->MarginStyledText(wParam); if (lParam) { if (st.text) memcpy(CharPtrFromSPtr(lParam), st.text, st.length); else strcpy(CharPtrFromSPtr(lParam), ""); } return st.length; } case SCI_MARGINSETSTYLE: pdoc->MarginSetStyle(wParam, lParam); break; case SCI_MARGINGETSTYLE: { const StyledText st = pdoc->MarginStyledText(wParam); return st.style; } case SCI_MARGINSETSTYLES: pdoc->MarginSetStyles(wParam, reinterpret_cast(lParam)); break; case SCI_MARGINGETSTYLES: { const StyledText st = pdoc->MarginStyledText(wParam); if (lParam) { if (st.styles) memcpy(CharPtrFromSPtr(lParam), st.styles, st.length); else strcpy(CharPtrFromSPtr(lParam), ""); } return st.styles ? st.length : 0; } case SCI_MARGINTEXTCLEARALL: pdoc->MarginClearAll(); break; case SCI_ANNOTATIONSETTEXT: pdoc->AnnotationSetText(wParam, CharPtrFromSPtr(lParam)); break; case SCI_ANNOTATIONGETTEXT: { const StyledText st = pdoc->AnnotationStyledText(wParam); if (lParam) { if (st.text) memcpy(CharPtrFromSPtr(lParam), st.text, st.length); else strcpy(CharPtrFromSPtr(lParam), ""); } return st.length; } case SCI_ANNOTATIONGETSTYLE: { const StyledText st = pdoc->AnnotationStyledText(wParam); return st.style; } case SCI_ANNOTATIONSETSTYLE: pdoc->AnnotationSetStyle(wParam, lParam); break; case SCI_ANNOTATIONSETSTYLES: pdoc->AnnotationSetStyles(wParam, reinterpret_cast(lParam)); break; case SCI_ANNOTATIONGETSTYLES: { const StyledText st = pdoc->AnnotationStyledText(wParam); if (lParam) { if (st.styles) memcpy(CharPtrFromSPtr(lParam), st.styles, st.length); else strcpy(CharPtrFromSPtr(lParam), ""); } return st.styles ? st.length : 0; } case SCI_ANNOTATIONGETLINES: return pdoc->AnnotationLines(wParam); case SCI_ANNOTATIONCLEARALL: pdoc->AnnotationClearAll(); break; case SCI_ANNOTATIONSETVISIBLE: SetAnnotationVisible(wParam); break; case SCI_ANNOTATIONGETVISIBLE: return vs.annotationVisible; case SCI_ANNOTATIONSETSTYLEOFFSET: vs.annotationStyleOffset = wParam; InvalidateStyleRedraw(); break; case SCI_ANNOTATIONGETSTYLEOFFSET: return vs.annotationStyleOffset; case SCI_ADDUNDOACTION: pdoc->AddUndoAction(wParam, lParam & UNDO_MAY_COALESCE); break; case SCI_SETMULTIPLESELECTION: multipleSelection = wParam != 0; InvalidateCaret(); break; case SCI_GETMULTIPLESELECTION: return multipleSelection; case SCI_SETADDITIONALSELECTIONTYPING: additionalSelectionTyping = wParam != 0; InvalidateCaret(); break; case SCI_GETADDITIONALSELECTIONTYPING: return additionalSelectionTyping; case SCI_SETMULTIPASTE: multiPasteMode = wParam; break; case SCI_GETMULTIPASTE: return multiPasteMode; case SCI_SETADDITIONALCARETSBLINK: additionalCaretsBlink = wParam != 0; InvalidateCaret(); break; case SCI_GETADDITIONALCARETSBLINK: return additionalCaretsBlink; case SCI_SETADDITIONALCARETSVISIBLE: additionalCaretsVisible = wParam != 0; InvalidateCaret(); break; case SCI_GETADDITIONALCARETSVISIBLE: return additionalCaretsVisible; case SCI_GETSELECTIONS: return sel.Count(); case SCI_CLEARSELECTIONS: sel.Clear(); Redraw(); break; case SCI_SETSELECTION: sel.SetSelection(SelectionRange(wParam, lParam)); Redraw(); break; case SCI_ADDSELECTION: sel.AddSelection(SelectionRange(wParam, lParam)); Redraw(); break; case SCI_SETMAINSELECTION: sel.SetMain(wParam); Redraw(); break; case SCI_GETMAINSELECTION: return sel.Main(); case SCI_SETSELECTIONNCARET: sel.Range(wParam).caret.SetPosition(lParam); Redraw(); break; case SCI_GETSELECTIONNCARET: return sel.Range(wParam).caret.Position(); case SCI_SETSELECTIONNANCHOR: sel.Range(wParam).anchor.SetPosition(lParam); Redraw(); break; case SCI_GETSELECTIONNANCHOR: return sel.Range(wParam).anchor.Position(); case SCI_SETSELECTIONNCARETVIRTUALSPACE: sel.Range(wParam).caret.SetVirtualSpace(lParam); Redraw(); break; case SCI_GETSELECTIONNCARETVIRTUALSPACE: return sel.Range(wParam).caret.VirtualSpace(); case SCI_SETSELECTIONNANCHORVIRTUALSPACE: sel.Range(wParam).anchor.SetVirtualSpace(lParam); Redraw(); break; case SCI_GETSELECTIONNANCHORVIRTUALSPACE: return sel.Range(wParam).anchor.VirtualSpace(); case SCI_SETSELECTIONNSTART: sel.Range(wParam).anchor.SetPosition(lParam); Redraw(); break; case SCI_GETSELECTIONNSTART: return sel.Range(wParam).Start().Position(); case SCI_SETSELECTIONNEND: sel.Range(wParam).caret.SetPosition(lParam); Redraw(); break; case SCI_GETSELECTIONNEND: return sel.Range(wParam).End().Position(); case SCI_SETRECTANGULARSELECTIONCARET: if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; sel.Rectangular().caret.SetPosition(wParam); SetRectangularRange(); Redraw(); break; case SCI_GETRECTANGULARSELECTIONCARET: return sel.Rectangular().caret.Position(); case SCI_SETRECTANGULARSELECTIONANCHOR: if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; sel.Rectangular().anchor.SetPosition(wParam); SetRectangularRange(); Redraw(); break; case SCI_GETRECTANGULARSELECTIONANCHOR: return sel.Rectangular().anchor.Position(); case SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE: if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; sel.Rectangular().caret.SetVirtualSpace(wParam); SetRectangularRange(); Redraw(); break; case SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE: return sel.Rectangular().caret.VirtualSpace(); case SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE: if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; sel.Rectangular().anchor.SetVirtualSpace(wParam); SetRectangularRange(); Redraw(); break; case SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE: return sel.Rectangular().anchor.VirtualSpace(); case SCI_SETVIRTUALSPACEOPTIONS: virtualSpaceOptions = wParam; break; case SCI_GETVIRTUALSPACEOPTIONS: return virtualSpaceOptions; case SCI_SETADDITIONALSELFORE: vs.selAdditionalForeground = ColourDesired(wParam); InvalidateStyleRedraw(); break; case SCI_SETADDITIONALSELBACK: vs.selAdditionalBackground = ColourDesired(wParam); InvalidateStyleRedraw(); break; case SCI_SETADDITIONALSELALPHA: vs.selAdditionalAlpha = wParam; InvalidateStyleRedraw(); break; case SCI_GETADDITIONALSELALPHA: return vs.selAdditionalAlpha; case SCI_SETADDITIONALCARETFORE: vs.additionalCaretColour = ColourDesired(wParam); InvalidateStyleRedraw(); break; case SCI_GETADDITIONALCARETFORE: return vs.additionalCaretColour.AsLong(); case SCI_ROTATESELECTION: sel.RotateMain(); InvalidateSelection(sel.RangeMain(), true); break; case SCI_SWAPMAINANCHORCARET: InvalidateSelection(sel.RangeMain()); sel.RangeMain() = SelectionRange(sel.RangeMain().anchor, sel.RangeMain().caret); break; case SCI_CHANGELEXERSTATE: pdoc->ChangeLexerState(wParam, lParam); break; case SCI_SETIDENTIFIER: SetCtrlID(wParam); break; case SCI_GETIDENTIFIER: return GetCtrlID(); case SCI_SETTECHNOLOGY: // No action by default break; case SCI_GETTECHNOLOGY: return technology; case SCI_COUNTCHARACTERS: return pdoc->CountCharacters(wParam, lParam); default: return DefWndProc(iMessage, wParam, lParam); } //Platform::DebugPrintf("end wnd proc\n"); return 0l; } Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/ViewStyle.cxx000444001750001750 3257612021352777 25111 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file ViewStyle.cxx ** Store information on how the document is to be viewed. **/ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include "Platform.h" #include "Scintilla.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" #include "Indicator.h" #include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif MarginStyle::MarginStyle() : style(SC_MARGIN_SYMBOL), width(0), mask(0), sensitive(false), cursor(SC_CURSORREVERSEARROW) { } // A list of the fontnames - avoids wasting space in each style FontNames::FontNames() { size = 8; names = new char *[size]; max = 0; } FontNames::~FontNames() { Clear(); delete []names; names = 0; } void FontNames::Clear() { for (int i=0; i= size) { // Grow array int sizeNew = size * 2; char **namesNew = new char *[sizeNew]; for (int j=0; jRealise(surface, zoomLevel, technology); } } FontRealised *FontRealised::Find(const FontSpecification &fs) { if (!fs.fontName) return this; FontRealised *fr = this; while (fr) { if (fr->EqualTo(fs)) return fr; fr = fr->frNext; } return 0; } void FontRealised::FindMaxAscentDescent(unsigned int &maxAscent, unsigned int &maxDescent) { FontRealised *fr = this; while (fr) { if (maxAscent < fr->ascent) maxAscent = fr->ascent; if (maxDescent < fr->descent) maxDescent = fr->descent; fr = fr->frNext; } } ViewStyle::ViewStyle() { Init(); } ViewStyle::ViewStyle(const ViewStyle &source) { frFirst = NULL; Init(source.stylesSize); for (unsigned int sty=0; sty 0) maskInLine &= ~ms[margin].mask; } zoomLevel = 0; viewWhitespace = wsInvisible; whitespaceSize = 1; viewIndentationGuides = ivNone; viewEOL = false; showMarkedLines = true; extraFontFlag = 0; extraAscent = 0; extraDescent = 0; marginStyleOffset = 0; annotationVisible = ANNOTATION_HIDDEN; annotationStyleOffset = 0; braceHighlightIndicatorSet = false; braceHighlightIndicator = 0; braceBadLightIndicatorSet = false; braceBadLightIndicator = 0; } void ViewStyle::CreateFont(const FontSpecification &fs) { if (fs.fontName) { for (FontRealised *cur=frFirst; cur; cur=cur->frNext) { if (cur->EqualTo(fs)) return; if (!cur->frNext) { cur->frNext = new FontRealised(fs); return; } } frFirst = new FontRealised(fs); } } void ViewStyle::Refresh(Surface &surface) { delete frFirst; frFirst = NULL; selbar = Platform::Chrome(); selbarlight = Platform::ChromeHighlight(); for (unsigned int i=0; iRealise(surface, zoomLevel, technology); for (unsigned int k=0; kFind(styles[k]); styles[k].Copy(fr->font, *fr); } maxAscent = 1; maxDescent = 1; frFirst->FindMaxAscentDescent(maxAscent, maxDescent); maxAscent += extraAscent; maxDescent += extraDescent; lineHeight = maxAscent + maxDescent; someStylesProtected = false; someStylesForceCase = false; for (unsigned int l=0; l 0) maskInLine &= ~ms[margin].mask; } } void ViewStyle::AllocStyles(size_t sizeNew) { Style *stylesNew = new Style[sizeNew]; size_t i=0; for (; i STYLE_DEFAULT) { for (; i= stylesSize) { size_t sizeNew = stylesSize * 2; while (sizeNew <= index) sizeNew *= 2; AllocStyles(sizeNew); } } void ViewStyle::ResetDefaultStyle() { styles[STYLE_DEFAULT].Clear(ColourDesired(0,0,0), ColourDesired(0xff,0xff,0xff), Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, fontNames.Save(Platform::DefaultFont()), SC_CHARSET_DEFAULT, SC_WEIGHT_NORMAL, false, false, false, Style::caseMixed, true, true, false); } void ViewStyle::ClearStyles() { // Reset all styles to be like the default style for (unsigned int i=0; iGetHeight() > largestMarkerHeight) largestMarkerHeight = markers[m].pxpm->GetHeight(); break; case SC_MARK_RGBAIMAGE: if (markers[m].image->GetHeight() > largestMarkerHeight) largestMarkerHeight = markers[m].image->GetHeight(); break; } } } Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexPerl6.cxx000444001750001750 556312021352777 24573 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** * @file LexPerl6.cxx * * An experimental Perl 6 syntax highlighter for Scintilla * written by Ahmad M. Zawawi */ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif /** * Colourize the Perl 6 document */ static void ColourisePerl6Doc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) { int state = SCE_P6_DEFAULT; char chNext = styler[startPos]; int lengthDoc = startPos + length; // Create a buffer large enough to take the largest chunk... char *buffer = new char[length]; // Perl 6 Keyword list //WordList &keywords = *keywordLists[0]; // Go through all provided text segment // using the hand-written state machine shown below styler.StartAt(startPos); styler.StartSegment(startPos); for (int i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); if (styler.IsLeadByte(ch)) { chNext = styler.SafeGetCharAt(i + 2); i++; continue; } switch(state) { case SCE_P6_DEFAULT: if( ch == '\n' || ch == '\r' || ch == '\t' || ch == ' ') { // Whitespace is ignored here styler.ColourTo(i,SCE_P6_DEFAULT); break; } else if( ch == '#' ) { // The start of a comment state = SCE_P6_COMMENT; styler.ColourTo(i,SCE_P6_COMMENT); } else if( ch == '"') { // The start of a string state = SCE_P6_STRING; styler.ColourTo(i,SCE_P6_STRING); } else { // The default style.. styler.ColourTo(i,SCE_P6_DEFAULT); } break; case SCE_P6_COMMENT: // If we find a newline here, we go to the default state otherwise we continue to work on it if( ch == '\n' || ch == '\r' ) { state = SCE_P6_DEFAULT; } else { styler.ColourTo(i,SCE_P6_COMMENT); } break; case SCE_P6_STRING: // if we find the end of a string character, then we go to default state // otherwise we are still dealing with a string if( (ch == '"' && styler.SafeGetCharAt(i-1)!='\\') || (ch == '\n') || (ch == '\r') ) { state = SCE_P6_DEFAULT; } styler.ColourTo(i,SCE_P6_STRING); break; } } delete [] buffer; } static const char * const perl6WordListDesc[] = { "Keywords", 0 }; LexerModule lmPerl6(SCLEX_PERL6, ColourisePerl6Doc, "perl6", 0, perl6WordListDesc);Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/StyleContext.cxx000444001750001750 241612021352777 25571 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file StyleContext.cxx ** Lexer infrastructure. **/ // Copyright 1998-2004 by Neil Hodgson // This file is in the public domain. #include #include #include #include #include #include "ILexer.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static void getRange(unsigned int start, unsigned int end, LexAccessor &styler, char *s, unsigned int len) { unsigned int i = 0; while ((i < end - start + 1) && (i < len-1)) { s[i] = styler[start + i]; i++; } s[i] = '\0'; } void StyleContext::GetCurrent(char *s, unsigned int len) { getRange(styler.GetStartSegment(), currentPos - 1, styler, s, len); } static void getRangeLowered(unsigned int start, unsigned int end, LexAccessor &styler, char *s, unsigned int len) { unsigned int i = 0; while ((i < end - start + 1) && (i < len-1)) { s[i] = static_cast(tolower(styler[start + i])); i++; } s[i] = '\0'; } void StyleContext::GetCurrentLowered(char *s, unsigned int len) { getRangeLowered(styler.GetStartSegment(), currentPos - 1, styler, s, len); } Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexECL.cxx000444001750001750 3733312021352777 24226 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexECL.cxx ** Lexer for ECL. **/ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #ifdef _MSC_VER #pragma warning(disable: 4786) #endif #ifdef __BORLANDC__ // Borland C++ displays warnings in vector header without this #pragma option -w-ccc -w-rch #endif #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #include "OptionSet.h" #define SET_LOWER "abcdefghijklmnopqrstuvwxyz" #define SET_UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ" #define SET_DIGITS "0123456789" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static bool IsSpaceEquiv(int state) { return (state <= SCE_ECL_COMMENTDOC) || // including SCE_ECL_DEFAULT, SCE_ECL_COMMENT, SCE_ECL_COMMENTLINE (state == SCE_ECL_COMMENTLINEDOC) || (state == SCE_ECL_COMMENTDOCKEYWORD) || (state == SCE_ECL_COMMENTDOCKEYWORDERROR); } static void ColouriseEclDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords0 = *keywordlists[0]; WordList &keywords1 = *keywordlists[1]; WordList &keywords2 = *keywordlists[2]; WordList &keywords3 = *keywordlists[3]; //Value Types WordList &keywords4 = *keywordlists[4]; WordList &keywords5 = *keywordlists[5]; WordList &keywords6 = *keywordlists[6]; //Javadoc Tags WordList cplusplus; cplusplus.Set("beginc endc"); bool stylingWithinPreprocessor = false; CharacterSet setOKBeforeRE(CharacterSet::setNone, "(=,"); CharacterSet setDoxygen(CharacterSet::setLower, "$@\\&<>#{}[]"); CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true); CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true); CharacterSet setQualified(CharacterSet::setNone, "uUxX"); int chPrevNonWhite = ' '; int visibleChars = 0; bool lastWordWasUUID = false; int styleBeforeDCKeyword = SCE_ECL_DEFAULT; bool continuationLine = false; if (initStyle == SCE_ECL_PREPROCESSOR) { // Set continuationLine if last character of previous line is '\' int lineCurrent = styler.GetLine(startPos); if (lineCurrent > 0) { int chBack = styler.SafeGetCharAt(startPos-1, 0); int chBack2 = styler.SafeGetCharAt(startPos-2, 0); int lineEndChar = '!'; if (chBack2 == '\r' && chBack == '\n') { lineEndChar = styler.SafeGetCharAt(startPos-3, 0); } else if (chBack == '\n' || chBack == '\r') { lineEndChar = chBack2; } continuationLine = lineEndChar == '\\'; } } // look back to set chPrevNonWhite properly for better regex colouring if (startPos > 0) { int back = startPos; while (--back && IsSpaceEquiv(styler.StyleAt(back))) ; if (styler.StyleAt(back) == SCE_ECL_OPERATOR) { chPrevNonWhite = styler.SafeGetCharAt(back); } } StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { if (sc.atLineStart) { if (sc.state == SCE_ECL_STRING) { // Prevent SCE_ECL_STRINGEOL from leaking back to previous line which // ends with a line continuation by locking in the state upto this position. sc.SetState(SCE_ECL_STRING); } // Reset states to begining of colourise so no surprises // if different sets of lines lexed. visibleChars = 0; lastWordWasUUID = false; } // Handle line continuation generically. if (sc.ch == '\\') { if (sc.chNext == '\n' || sc.chNext == '\r') { sc.Forward(); if (sc.ch == '\r' && sc.chNext == '\n') { sc.Forward(); } continuationLine = true; continue; } } // Determine if the current state should terminate. switch (sc.state) { case SCE_ECL_ADDED: case SCE_ECL_DELETED: case SCE_ECL_CHANGED: case SCE_ECL_MOVED: if (sc.atLineStart) sc.SetState(SCE_ECL_DEFAULT); break; case SCE_ECL_OPERATOR: sc.SetState(SCE_ECL_DEFAULT); break; case SCE_ECL_NUMBER: // We accept almost anything because of hex. and number suffixes if (!setWord.Contains(sc.ch)) { sc.SetState(SCE_ECL_DEFAULT); } break; case SCE_ECL_IDENTIFIER: if (!setWord.Contains(sc.ch) || (sc.ch == '.')) { char s[1000]; sc.GetCurrentLowered(s, sizeof(s)); if (keywords0.InList(s)) { lastWordWasUUID = strcmp(s, "uuid") == 0; sc.ChangeState(SCE_ECL_WORD0); } else if (keywords1.InList(s)) { sc.ChangeState(SCE_ECL_WORD1); } else if (keywords2.InList(s)) { sc.ChangeState(SCE_ECL_WORD2); } else if (keywords4.InList(s)) { sc.ChangeState(SCE_ECL_WORD4); } else if (keywords5.InList(s)) { sc.ChangeState(SCE_ECL_WORD5); } else //Data types are of from KEYWORD## { int i = static_cast(strlen(s)) - 1; while(i >= 0 && (isdigit(s[i]) || s[i] == '_')) --i; char s2[1000]; strncpy(s2, s, i + 1); s2[i + 1] = 0; if (keywords3.InList(s2)) { sc.ChangeState(SCE_ECL_WORD3); } } sc.SetState(SCE_ECL_DEFAULT); } break; case SCE_ECL_PREPROCESSOR: if (sc.atLineStart && !continuationLine) { sc.SetState(SCE_ECL_DEFAULT); } else if (stylingWithinPreprocessor) { if (IsASpace(sc.ch)) { sc.SetState(SCE_ECL_DEFAULT); } } else { if (sc.Match('/', '*') || sc.Match('/', '/')) { sc.SetState(SCE_ECL_DEFAULT); } } break; case SCE_ECL_COMMENT: if (sc.Match('*', '/')) { sc.Forward(); sc.ForwardSetState(SCE_ECL_DEFAULT); } break; case SCE_ECL_COMMENTDOC: if (sc.Match('*', '/')) { sc.Forward(); sc.ForwardSetState(SCE_ECL_DEFAULT); } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support // Verify that we have the conditions to mark a comment-doc-keyword if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) { styleBeforeDCKeyword = SCE_ECL_COMMENTDOC; sc.SetState(SCE_ECL_COMMENTDOCKEYWORD); } } break; case SCE_ECL_COMMENTLINE: if (sc.atLineStart) { sc.SetState(SCE_ECL_DEFAULT); } break; case SCE_ECL_COMMENTLINEDOC: if (sc.atLineStart) { sc.SetState(SCE_ECL_DEFAULT); } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support // Verify that we have the conditions to mark a comment-doc-keyword if ((IsASpace(sc.chPrev) || sc.chPrev == '/' || sc.chPrev == '!') && (!IsASpace(sc.chNext))) { styleBeforeDCKeyword = SCE_ECL_COMMENTLINEDOC; sc.SetState(SCE_ECL_COMMENTDOCKEYWORD); } } break; case SCE_ECL_COMMENTDOCKEYWORD: if ((styleBeforeDCKeyword == SCE_ECL_COMMENTDOC) && sc.Match('*', '/')) { sc.ChangeState(SCE_ECL_COMMENTDOCKEYWORDERROR); sc.Forward(); sc.ForwardSetState(SCE_ECL_DEFAULT); } else if (!setDoxygen.Contains(sc.ch)) { char s[1000]; sc.GetCurrentLowered(s, sizeof(s)); if (!IsASpace(sc.ch) || !keywords6.InList(s+1)) { sc.ChangeState(SCE_ECL_COMMENTDOCKEYWORDERROR); } sc.SetState(styleBeforeDCKeyword); } break; case SCE_ECL_STRING: if (sc.atLineEnd) { sc.ChangeState(SCE_ECL_STRINGEOL); } else if (sc.ch == '\\') { if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { sc.Forward(); } } else if (sc.ch == '\"') { sc.ForwardSetState(SCE_ECL_DEFAULT); } break; case SCE_ECL_CHARACTER: if (sc.atLineEnd) { sc.ChangeState(SCE_ECL_STRINGEOL); } else if (sc.ch == '\\') { if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { sc.Forward(); } } else if (sc.ch == '\'') { sc.ForwardSetState(SCE_ECL_DEFAULT); } break; case SCE_ECL_REGEX: if (sc.atLineStart) { sc.SetState(SCE_ECL_DEFAULT); } else if (sc.ch == '/') { sc.Forward(); while ((sc.ch < 0x80) && islower(sc.ch)) sc.Forward(); // gobble regex flags sc.SetState(SCE_ECL_DEFAULT); } else if (sc.ch == '\\') { // Gobble up the quoted character if (sc.chNext == '\\' || sc.chNext == '/') { sc.Forward(); } } break; case SCE_ECL_STRINGEOL: if (sc.atLineStart) { sc.SetState(SCE_ECL_DEFAULT); } break; case SCE_ECL_VERBATIM: if (sc.ch == '\"') { if (sc.chNext == '\"') { sc.Forward(); } else { sc.ForwardSetState(SCE_ECL_DEFAULT); } } break; case SCE_ECL_UUID: if (sc.ch == '\r' || sc.ch == '\n' || sc.ch == ')') { sc.SetState(SCE_ECL_DEFAULT); } break; } // Determine if a new state should be entered. int lineCurrent = styler.GetLine(sc.currentPos); int lineState = styler.GetLineState(lineCurrent); if (sc.state == SCE_ECL_DEFAULT) { if (lineState) { sc.SetState(lineState); } else if (sc.Match('@', '\"')) { sc.SetState(SCE_ECL_VERBATIM); sc.Forward(); } else if (setQualified.Contains(sc.ch) && sc.chNext == '\'') { sc.SetState(SCE_ECL_CHARACTER); sc.Forward(); } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { if (lastWordWasUUID) { sc.SetState(SCE_ECL_UUID); lastWordWasUUID = false; } else { sc.SetState(SCE_ECL_NUMBER); } } else if (setWordStart.Contains(sc.ch) || (sc.ch == '@')) { if (lastWordWasUUID) { sc.SetState(SCE_ECL_UUID); lastWordWasUUID = false; } else { sc.SetState(SCE_ECL_IDENTIFIER); } } else if (sc.Match('/', '*')) { if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style sc.SetState(SCE_ECL_COMMENTDOC); } else { sc.SetState(SCE_ECL_COMMENT); } sc.Forward(); // Eat the * so it isn't used for the end of the comment } else if (sc.Match('/', '/')) { if ((sc.Match("///") && !sc.Match("////")) || sc.Match("//!")) // Support of Qt/Doxygen doc. style sc.SetState(SCE_ECL_COMMENTLINEDOC); else sc.SetState(SCE_ECL_COMMENTLINE); } else if (sc.ch == '/' && setOKBeforeRE.Contains(chPrevNonWhite)) { sc.SetState(SCE_ECL_REGEX); // JavaScript's RegEx // } else if (sc.ch == '\"') { // sc.SetState(SCE_ECL_STRING); } else if (sc.ch == '\'') { sc.SetState(SCE_ECL_CHARACTER); } else if (sc.ch == '#' && visibleChars == 0) { // Preprocessor commands are alone on their line sc.SetState(SCE_ECL_PREPROCESSOR); // Skip whitespace between # and preprocessor word do { sc.Forward(); } while ((sc.ch == ' ' || sc.ch == '\t') && sc.More()); if (sc.atLineEnd) { sc.SetState(SCE_ECL_DEFAULT); } } else if (isoperator(static_cast(sc.ch))) { sc.SetState(SCE_ECL_OPERATOR); } } if (!IsASpace(sc.ch) && !IsSpaceEquiv(sc.state)) { chPrevNonWhite = sc.ch; visibleChars++; } continuationLine = false; } sc.Complete(); } static bool IsStreamCommentStyle(int style) { return style == SCE_ECL_COMMENT || style == SCE_ECL_COMMENTDOC || style == SCE_ECL_COMMENTDOCKEYWORD || style == SCE_ECL_COMMENTDOCKEYWORDERROR; } bool MatchNoCase(Accessor & styler, unsigned int & pos, const char *s) { int i=0; for (; *s; i++) { char compare_char = tolower(*s); char styler_char = tolower(styler.SafeGetCharAt(pos+i)); if (compare_char != styler_char) return false; s++; } pos+=i-1; return true; } // Store both the current line's fold level and the next lines in the // level store to make it easy to pick up with each increment // and to make it possible to fiddle the current level for "} else {". static void FoldEclDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { bool foldComment = true; bool foldPreprocessor = true; bool foldCompact = true; bool foldAtElse = true; unsigned int endPos = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; int levelMinCurrent = levelCurrent; int levelNext = levelCurrent; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (foldComment && IsStreamCommentStyle(style)) { if (!IsStreamCommentStyle(stylePrev) && (stylePrev != SCE_ECL_COMMENTLINEDOC)) { levelNext++; } else if (!IsStreamCommentStyle(styleNext) && (styleNext != SCE_ECL_COMMENTLINEDOC) && !atEOL) { // Comments don't end at end of line and the next character may be unstyled. levelNext--; } } if (foldComment && (style == SCE_ECL_COMMENTLINE)) { if ((ch == '/') && (chNext == '/')) { char chNext2 = styler.SafeGetCharAt(i + 2); if (chNext2 == '{') { levelNext++; } else if (chNext2 == '}') { levelNext--; } } } if (foldPreprocessor && (style == SCE_ECL_PREPROCESSOR)) { if (ch == '#') { unsigned int j = i + 1; while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) { j++; } if (MatchNoCase(styler, j, "region") || MatchNoCase(styler, j, "if")) { levelNext++; } else if (MatchNoCase(styler, j, "endregion") || MatchNoCase(styler, j, "end")) { levelNext--; } } } if (style == SCE_ECL_OPERATOR) { if (ch == '{') { // Measure the minimum before a '{' to allow // folding on "} else {" if (levelMinCurrent > levelNext) { levelMinCurrent = levelNext; } levelNext++; } else if (ch == '}') { levelNext--; } } if (style == SCE_ECL_WORD2) { if (MatchNoCase(styler, i, "record") || MatchNoCase(styler, i, "transform") || MatchNoCase(styler, i, "type") || MatchNoCase(styler, i, "function") || MatchNoCase(styler, i, "module") || MatchNoCase(styler, i, "service") || MatchNoCase(styler, i, "interface") || MatchNoCase(styler, i, "ifblock") || MatchNoCase(styler, i, "macro") || MatchNoCase(styler, i, "beginc++")) { levelNext++; } else if (MatchNoCase(styler, i, "endmacro") || MatchNoCase(styler, i, "endc++") || MatchNoCase(styler, i, "end")) { levelNext--; } } if (atEOL || (i == endPos-1)) { int levelUse = levelCurrent; if (foldAtElse) { levelUse = levelMinCurrent; } int lev = levelUse | levelNext << 16; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if (levelUse < levelNext) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelCurrent = levelNext; levelMinCurrent = levelCurrent; if (atEOL && (i == static_cast(styler.Length()-1))) { // There is an empty line at end of file so give it same level and empty styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG); } visibleChars = 0; } if (!IsASpace(ch)) visibleChars++; } } static const char * const EclWordListDesc[] = { "Keywords", 0 }; LexerModule lmECL( SCLEX_ECL, ColouriseEclDoc, "ecl", FoldEclDoc, EclWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/UniConversion.h000444001750001750 120612021352776 25345 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file UniConversion.h ** Functions to handle UTF-8 and UTF-16 strings. **/ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen); void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len); unsigned int UTF8CharLength(unsigned char ch); unsigned int UTF16Length(const char *s, unsigned int len); unsigned int UTF16FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexTCL.cxx000444001750001750 3211412021352777 24235 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexTCL.cxx ** Lexer for TCL language. **/ // Copyright 1998-2001 by Andre Arpin // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif // Extended to accept accented characters static inline bool IsAWordChar(int ch) { return ch >= 0x80 || (isalnum(ch) || ch == '_' || ch ==':' || ch=='.'); // : name space separator } static inline bool IsAWordStart(int ch) { return ch >= 0x80 || (ch ==':' || isalpha(ch) || ch == '_'); } static inline bool IsANumberChar(int ch) { // Not exactly following number definition (several dots are seen as OK, etc.) // but probably enough in most cases. return (ch < 0x80) && (IsADigit(ch, 0x10) || toupper(ch) == 'E' || ch == '.' || ch == '-' || ch == '+'); } static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *keywordlists[], Accessor &styler) { #define isComment(s) (s==SCE_TCL_COMMENT || s==SCE_TCL_COMMENTLINE || s==SCE_TCL_COMMENT_BOX || s==SCE_TCL_BLOCK_COMMENT) bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool commentLevel = false; bool subBrace = false; // substitution begin with a brace ${.....} enum tLineState {LS_DEFAULT, LS_OPEN_COMMENT, LS_OPEN_DOUBLE_QUOTE, LS_COMMENT_BOX, LS_MASK_STATE = 0xf, LS_COMMAND_EXPECTED = 16, LS_BRACE_ONLY = 32 } lineState = LS_DEFAULT; bool prevSlash = false; int currentLevel = 0; bool expected = 0; bool subParen = 0; int currentLine = styler.GetLine(startPos); if (currentLine > 0) currentLine--; length += startPos - styler.LineStart(currentLine); // make sure lines overlap startPos = styler.LineStart(currentLine); WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; WordList &keywords3 = *keywordlists[2]; WordList &keywords4 = *keywordlists[3]; WordList &keywords5 = *keywordlists[4]; WordList &keywords6 = *keywordlists[5]; WordList &keywords7 = *keywordlists[6]; WordList &keywords8 = *keywordlists[7]; WordList &keywords9 = *keywordlists[8]; if (currentLine > 0) { int ls = styler.GetLineState(currentLine - 1); lineState = tLineState(ls & LS_MASK_STATE); expected = LS_COMMAND_EXPECTED == tLineState(ls & LS_COMMAND_EXPECTED); subBrace = LS_BRACE_ONLY == tLineState(ls & LS_BRACE_ONLY); currentLevel = styler.LevelAt(currentLine - 1) >> 17; commentLevel = (styler.LevelAt(currentLine - 1) >> 16) & 1; } else styler.SetLevel(0, SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG); bool visibleChars = false; int previousLevel = currentLevel; StyleContext sc(startPos, length, SCE_TCL_DEFAULT, styler); for (; ; sc.Forward()) { next: if (sc.ch=='\r' && sc.chNext == '\n') // only ignore \r on PC process on the mac continue; bool atEnd = !sc.More(); // make sure we coloured the last word if (lineState != LS_DEFAULT) { sc.SetState(SCE_TCL_DEFAULT); if (lineState == LS_OPEN_COMMENT) sc.SetState(SCE_TCL_COMMENTLINE); else if (lineState == LS_OPEN_DOUBLE_QUOTE) sc.SetState(SCE_TCL_IN_QUOTE); else if (lineState == LS_COMMENT_BOX && (sc.ch == '#' || (sc.ch == ' ' && sc.chNext=='#'))) sc.SetState(SCE_TCL_COMMENT_BOX); lineState = LS_DEFAULT; } if (subBrace) { // ${ overrides every thing even \ except } if (sc.ch == '}') { subBrace = false; sc.SetState(SCE_TCL_OPERATOR); sc.ForwardSetState(SCE_TCL_DEFAULT); goto next; } else sc.SetState(SCE_TCL_SUB_BRACE); if (!sc.atLineEnd) continue; } else if (sc.state == SCE_TCL_DEFAULT || sc.state ==SCE_TCL_OPERATOR) { expected &= isspacechar(static_cast(sc.ch)) || IsAWordStart(sc.ch) || sc.ch =='#'; } else if (sc.state == SCE_TCL_SUBSTITUTION) { switch(sc.ch) { case '(': subParen=true; sc.SetState(SCE_TCL_OPERATOR); sc.ForwardSetState(SCE_TCL_SUBSTITUTION); continue; case ')': sc.SetState(SCE_TCL_OPERATOR); subParen=false; continue; case '$': continue; case ',': sc.SetState(SCE_TCL_OPERATOR); if (subParen) sc.ForwardSetState(SCE_TCL_SUBSTITUTION); continue; default : // maybe spaces should be allowed ??? if (!IsAWordChar(sc.ch)) { // probably the code is wrong sc.SetState(SCE_TCL_DEFAULT); subParen = 0; } break; } } else if (isComment(sc.state)) { } else if (!IsAWordChar(sc.ch)) { if ((sc.state == SCE_TCL_IDENTIFIER && expected) || sc.state == SCE_TCL_MODIFIER) { char w[100]; char *s=w; sc.GetCurrent(w, sizeof(w)); if (w[strlen(w)-1]=='\r') w[strlen(w)-1]=0; while(*s == ':') // ignore leading : like in ::set a 10 ++s; bool quote = sc.state == SCE_TCL_IN_QUOTE; if (commentLevel || expected) { if (keywords.InList(s)) { sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD); } else if (keywords2.InList(s)) { sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD2); } else if (keywords3.InList(s)) { sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD3); } else if (keywords4.InList(s)) { sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD4); } else if (sc.GetRelative(-static_cast(strlen(s))-1) == '{' && keywords5.InList(s) && sc.ch == '}') { // {keyword} exactly no spaces sc.ChangeState(SCE_TCL_EXPAND); } if (keywords6.InList(s)) { sc.ChangeState(SCE_TCL_WORD5); } else if (keywords7.InList(s)) { sc.ChangeState(SCE_TCL_WORD6); } else if (keywords8.InList(s)) { sc.ChangeState(SCE_TCL_WORD7); } else if (keywords9.InList(s)) { sc.ChangeState(SCE_TCL_WORD8); } } expected = false; sc.SetState(quote ? SCE_TCL_IN_QUOTE : SCE_TCL_DEFAULT); } else if (sc.state == SCE_TCL_MODIFIER || sc.state == SCE_TCL_IDENTIFIER) { sc.SetState(SCE_TCL_DEFAULT); } } if (atEnd) break; if (sc.atLineEnd) { lineState = LS_DEFAULT; currentLine = styler.GetLine(sc.currentPos); if (foldComment && sc.state!=SCE_TCL_COMMENT && isComment(sc.state)) { if (currentLevel == 0) { ++currentLevel; commentLevel = true; } } else { if (visibleChars && commentLevel) { --currentLevel; --previousLevel; commentLevel = false; } } int flag = 0; if (!visibleChars) flag = SC_FOLDLEVELWHITEFLAG; if (currentLevel > previousLevel) flag = SC_FOLDLEVELHEADERFLAG; styler.SetLevel(currentLine, flag + previousLevel + SC_FOLDLEVELBASE + (currentLevel << 17) + (commentLevel << 16)); // Update the line state, so it can be seen by next line if (sc.state == SCE_TCL_IN_QUOTE) lineState = LS_OPEN_DOUBLE_QUOTE; else { if (prevSlash) { if (isComment(sc.state)) lineState = LS_OPEN_COMMENT; } else if (sc.state == SCE_TCL_COMMENT_BOX) lineState = LS_COMMENT_BOX; } styler.SetLineState(currentLine, (subBrace ? LS_BRACE_ONLY : 0) | (expected ? LS_COMMAND_EXPECTED : 0) | lineState); if (lineState == LS_COMMENT_BOX) sc.ForwardSetState(SCE_TCL_COMMENT_BOX); else if (lineState == LS_OPEN_DOUBLE_QUOTE) sc.ForwardSetState(SCE_TCL_IN_QUOTE); else sc.ForwardSetState(SCE_TCL_DEFAULT); prevSlash = false; previousLevel = currentLevel; goto next; } if (prevSlash) { prevSlash = false; if (sc.ch == '#' && IsANumberChar(sc.chNext)) sc.ForwardSetState(SCE_TCL_NUMBER); continue; } prevSlash = sc.ch == '\\'; if (isComment(sc.state)) continue; if (sc.atLineStart) { visibleChars = false; if (sc.state!=SCE_TCL_IN_QUOTE && !isComment(sc.state)) { sc.SetState(SCE_TCL_DEFAULT); expected = IsAWordStart(sc.ch)|| isspacechar(static_cast(sc.ch)); } } switch (sc.state) { case SCE_TCL_NUMBER: if (!IsANumberChar(sc.ch)) sc.SetState(SCE_TCL_DEFAULT); break; case SCE_TCL_IN_QUOTE: if (sc.ch == '"') { sc.ForwardSetState(SCE_TCL_DEFAULT); visibleChars = true; // necessary if a " is the first and only character on a line goto next; } else if (sc.ch == '[' || sc.ch == ']' || sc.ch == '$') { sc.SetState(SCE_TCL_OPERATOR); expected = sc.ch == '['; sc.ForwardSetState(SCE_TCL_IN_QUOTE); goto next; } continue; case SCE_TCL_OPERATOR: sc.SetState(SCE_TCL_DEFAULT); break; } if (sc.ch == '#') { if (visibleChars) { if (sc.state != SCE_TCL_IN_QUOTE && expected) sc.SetState(SCE_TCL_COMMENT); } else { sc.SetState(SCE_TCL_COMMENTLINE); if (sc.chNext == '~') sc.SetState(SCE_TCL_BLOCK_COMMENT); if (sc.atLineStart && (sc.chNext == '#' || sc.chNext == '-')) sc.SetState(SCE_TCL_COMMENT_BOX); } } if (!isspacechar(static_cast(sc.ch))) { visibleChars = true; } if (sc.ch == '\\') { prevSlash = true; continue; } // Determine if a new state should be entered. if (sc.state == SCE_TCL_DEFAULT) { if (IsAWordStart(sc.ch)) { sc.SetState(SCE_TCL_IDENTIFIER); } else if (IsADigit(sc.ch) && !IsAWordChar(sc.chPrev)) { sc.SetState(SCE_TCL_NUMBER); } else { switch (sc.ch) { case '\"': sc.SetState(SCE_TCL_IN_QUOTE); break; case '{': sc.SetState(SCE_TCL_OPERATOR); expected = true; ++currentLevel; break; case '}': sc.SetState(SCE_TCL_OPERATOR); expected = true; --currentLevel; break; case '[': expected = true; case ']': case '(': case ')': sc.SetState(SCE_TCL_OPERATOR); break; case ';': expected = true; break; case '$': subParen = 0; if (sc.chNext != '{') { sc.SetState(SCE_TCL_SUBSTITUTION); } else { sc.SetState(SCE_TCL_OPERATOR); // $ sc.Forward(); // { sc.ForwardSetState(SCE_TCL_SUB_BRACE); subBrace = true; } break; case '#': if ((isspacechar(static_cast(sc.chPrev))|| isoperator(static_cast(sc.chPrev))) && IsADigit(sc.chNext,0x10)) sc.SetState(SCE_TCL_NUMBER); break; case '-': sc.SetState(IsADigit(sc.chNext)? SCE_TCL_NUMBER: SCE_TCL_MODIFIER); break; default: if (isoperator(static_cast(sc.ch))) { sc.SetState(SCE_TCL_OPERATOR); } } } } } sc.Complete(); } static const char * const tclWordListDesc[] = { "TCL Keywords", "TK Keywords", "iTCL Keywords", "tkCommands", "expand" "user1", "user2", "user3", "user4", 0 }; // this code supports folding in the colourizer LexerModule lmTCL(SCLEX_TCL, ColouriseTCLDoc, "tcl", 0, tclWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexVB.cxx000444001750001750 2360112021352776 24122 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexVB.cxx ** Lexer for Visual Basic and VBScript. **/ // Copyright 1998-2005 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif // Internal state, highlighted as number #define SCE_B_FILENUMBER SCE_B_DEFAULT+100 static bool IsVBComment(Accessor &styler, int pos, int len) { return len > 0 && styler[pos] == '\''; } static inline bool IsTypeCharacter(int ch) { return ch == '%' || ch == '&' || ch == '@' || ch == '!' || ch == '#' || ch == '$'; } // Extended to accept accented characters static inline bool IsAWordChar(int ch) { return ch >= 0x80 || (isalnum(ch) || ch == '.' || ch == '_'); } static inline bool IsAWordStart(int ch) { return ch >= 0x80 || (isalpha(ch) || ch == '_'); } static inline bool IsANumberChar(int ch) { // Not exactly following number definition (several dots are seen as OK, etc.) // but probably enough in most cases. return (ch < 0x80) && (isdigit(ch) || toupper(ch) == 'E' || ch == '.' || ch == '-' || ch == '+'); } static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler, bool vbScriptSyntax) { WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; WordList &keywords3 = *keywordlists[2]; WordList &keywords4 = *keywordlists[3]; styler.StartAt(startPos); int visibleChars = 0; int fileNbDigits = 0; // Do not leak onto next line if (initStyle == SCE_B_STRINGEOL || initStyle == SCE_B_COMMENT || initStyle == SCE_B_PREPROCESSOR) { initStyle = SCE_B_DEFAULT; } StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { if (sc.state == SCE_B_OPERATOR) { sc.SetState(SCE_B_DEFAULT); } else if (sc.state == SCE_B_IDENTIFIER) { if (!IsAWordChar(sc.ch)) { // In Basic (except VBScript), a variable name or a function name // can end with a special character indicating the type of the value // held or returned. bool skipType = false; if (!vbScriptSyntax && IsTypeCharacter(sc.ch)) { sc.Forward(); // Skip it skipType = true; } if (sc.ch == ']') { sc.Forward(); } char s[100]; sc.GetCurrentLowered(s, sizeof(s)); if (skipType) { s[strlen(s) - 1] = '\0'; } if (strcmp(s, "rem") == 0) { sc.ChangeState(SCE_B_COMMENT); } else { if (keywords.InList(s)) { sc.ChangeState(SCE_B_KEYWORD); } else if (keywords2.InList(s)) { sc.ChangeState(SCE_B_KEYWORD2); } else if (keywords3.InList(s)) { sc.ChangeState(SCE_B_KEYWORD3); } else if (keywords4.InList(s)) { sc.ChangeState(SCE_B_KEYWORD4); } // Else, it is really an identifier... sc.SetState(SCE_B_DEFAULT); } } } else if (sc.state == SCE_B_NUMBER) { // We stop the number definition on non-numerical non-dot non-eE non-sign char // Also accepts A-F for hex. numbers if (!IsANumberChar(sc.ch) && !(tolower(sc.ch) >= 'a' && tolower(sc.ch) <= 'f')) { sc.SetState(SCE_B_DEFAULT); } } else if (sc.state == SCE_B_STRING) { // VB doubles quotes to preserve them, so just end this string // state now as a following quote will start again if (sc.ch == '\"') { if (sc.chNext == '\"') { sc.Forward(); } else { if (tolower(sc.chNext) == 'c') { sc.Forward(); } sc.ForwardSetState(SCE_B_DEFAULT); } } else if (sc.atLineEnd) { visibleChars = 0; sc.ChangeState(SCE_B_STRINGEOL); sc.ForwardSetState(SCE_B_DEFAULT); } } else if (sc.state == SCE_B_COMMENT) { if (sc.atLineEnd) { visibleChars = 0; sc.ForwardSetState(SCE_B_DEFAULT); } } else if (sc.state == SCE_B_PREPROCESSOR) { if (sc.atLineEnd) { visibleChars = 0; sc.ForwardSetState(SCE_B_DEFAULT); } } else if (sc.state == SCE_B_FILENUMBER) { if (IsADigit(sc.ch)) { fileNbDigits++; if (fileNbDigits > 3) { sc.ChangeState(SCE_B_DATE); } } else if (sc.ch == '\r' || sc.ch == '\n' || sc.ch == ',') { // Regular uses: Close #1; Put #1, ...; Get #1, ... etc. // Too bad if date is format #27, Oct, 2003# or something like that... // Use regular number state sc.ChangeState(SCE_B_NUMBER); sc.SetState(SCE_B_DEFAULT); } else if (sc.ch == '#') { sc.ChangeState(SCE_B_DATE); sc.ForwardSetState(SCE_B_DEFAULT); } else { sc.ChangeState(SCE_B_DATE); } if (sc.state != SCE_B_FILENUMBER) { fileNbDigits = 0; } } else if (sc.state == SCE_B_DATE) { if (sc.atLineEnd) { visibleChars = 0; sc.ChangeState(SCE_B_STRINGEOL); sc.ForwardSetState(SCE_B_DEFAULT); } else if (sc.ch == '#') { sc.ForwardSetState(SCE_B_DEFAULT); } } if (sc.state == SCE_B_DEFAULT) { if (sc.ch == '\'') { sc.SetState(SCE_B_COMMENT); } else if (sc.ch == '\"') { sc.SetState(SCE_B_STRING); } else if (sc.ch == '#' && visibleChars == 0) { // Preprocessor commands are alone on their line sc.SetState(SCE_B_PREPROCESSOR); } else if (sc.ch == '#') { // It can be a date literal, ending with #, or a file number, from 1 to 511 // The date literal depends on the locale, so anything can go between #'s. // Can be #January 1, 1993# or #1 Jan 93# or #05/11/2003#, etc. // So we set the FILENUMBER state, and switch to DATE if it isn't a file number sc.SetState(SCE_B_FILENUMBER); } else if (sc.ch == '&' && tolower(sc.chNext) == 'h') { // Hexadecimal number sc.SetState(SCE_B_NUMBER); sc.Forward(); } else if (sc.ch == '&' && tolower(sc.chNext) == 'o') { // Octal number sc.SetState(SCE_B_NUMBER); sc.Forward(); } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_B_NUMBER); } else if (IsAWordStart(sc.ch) || (sc.ch == '[')) { sc.SetState(SCE_B_IDENTIFIER); } else if (isoperator(static_cast(sc.ch)) || (sc.ch == '\\')) { // Integer division sc.SetState(SCE_B_OPERATOR); } } if (sc.atLineEnd) { visibleChars = 0; } if (!IsASpace(sc.ch)) { visibleChars++; } } if (sc.state == SCE_B_IDENTIFIER && !IsAWordChar(sc.ch)) { // In Basic (except VBScript), a variable name or a function name // can end with a special character indicating the type of the value // held or returned. bool skipType = false; if (!vbScriptSyntax && IsTypeCharacter(sc.ch)) { sc.Forward(); // Skip it skipType = true; } if (sc.ch == ']') { sc.Forward(); } char s[100]; sc.GetCurrentLowered(s, sizeof(s)); if (skipType) { s[strlen(s) - 1] = '\0'; } if (strcmp(s, "rem") == 0) { sc.ChangeState(SCE_B_COMMENT); } else { if (keywords.InList(s)) { sc.ChangeState(SCE_B_KEYWORD); } else if (keywords2.InList(s)) { sc.ChangeState(SCE_B_KEYWORD2); } else if (keywords3.InList(s)) { sc.ChangeState(SCE_B_KEYWORD3); } else if (keywords4.InList(s)) { sc.ChangeState(SCE_B_KEYWORD4); } // Else, it is really an identifier... sc.SetState(SCE_B_DEFAULT); } } sc.Complete(); } static void FoldVBDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { int endPos = startPos + length; // Backtrack to previous line in case need to fix its fold status int lineCurrent = styler.GetLine(startPos); if (startPos > 0) { if (lineCurrent > 0) { lineCurrent--; startPos = styler.LineStart(lineCurrent); } } int spaceFlags = 0; int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsVBComment); char chNext = styler[startPos]; for (int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == endPos)) { int lev = indentCurrent; int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsVBComment); if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) { // Only non whitespace lines can be headers if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) { lev |= SC_FOLDLEVELHEADERFLAG; } else if (indentNext & SC_FOLDLEVELWHITEFLAG) { // Line after is blank so check the next - maybe should continue further? int spaceFlags2 = 0; int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsVBComment); if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) { lev |= SC_FOLDLEVELHEADERFLAG; } } } indentCurrent = indentNext; styler.SetLevel(lineCurrent, lev); lineCurrent++; } } } static void ColouriseVBNetDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { ColouriseVBDoc(startPos, length, initStyle, keywordlists, styler, false); } static void ColouriseVBScriptDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { ColouriseVBDoc(startPos, length, initStyle, keywordlists, styler, true); } static const char * const vbWordListDesc[] = { "Keywords", "user1", "user2", "user3", 0 }; LexerModule lmVB(SCLEX_VB, ColouriseVBNetDoc, "vb", FoldVBDoc, vbWordListDesc); LexerModule lmVBScript(SCLEX_VBSCRIPT, ColouriseVBScriptDoc, "vbscript", FoldVBDoc, vbWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/ScintillaBase.cxx000444001750001750 5513012021352777 25662 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file ScintillaBase.cxx ** An enhanced subclass of Editor with calltips, autocomplete and context menu. **/ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include #include #include "Platform.h" #include "ILexer.h" #include "Scintilla.h" #include "PropSetSimple.h" #ifdef SCI_LEXER #include "SciLexer.h" #include "LexerModule.h" #include "Catalogue.h" #endif #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" #include "ContractionState.h" #include "CellBuffer.h" #include "CallTip.h" #include "KeyMap.h" #include "Indicator.h" #include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" #include "AutoComplete.h" #include "CharClassify.h" #include "Decoration.h" #include "Document.h" #include "Selection.h" #include "PositionCache.h" #include "Editor.h" #include "ScintillaBase.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif ScintillaBase::ScintillaBase() { displayPopupMenu = true; listType = 0; maxListWidth = 0; } ScintillaBase::~ScintillaBase() { } void ScintillaBase::Finalise() { Editor::Finalise(); popup.Destroy(); } void ScintillaBase::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) { bool isFillUp = ac.Active() && ac.IsFillUpChar(*s); if (!isFillUp) { Editor::AddCharUTF(s, len, treatAsDBCS); } if (ac.Active()) { AutoCompleteCharacterAdded(s[0]); // For fill ups add the character after the autocompletion has // triggered so containers see the key so can display a calltip. if (isFillUp) { Editor::AddCharUTF(s, len, treatAsDBCS); } } } void ScintillaBase::Command(int cmdId) { switch (cmdId) { case idAutoComplete: // Nothing to do break; case idCallTip: // Nothing to do break; case idcmdUndo: WndProc(SCI_UNDO, 0, 0); break; case idcmdRedo: WndProc(SCI_REDO, 0, 0); break; case idcmdCut: WndProc(SCI_CUT, 0, 0); break; case idcmdCopy: WndProc(SCI_COPY, 0, 0); break; case idcmdPaste: WndProc(SCI_PASTE, 0, 0); break; case idcmdDelete: WndProc(SCI_CLEAR, 0, 0); break; case idcmdSelectAll: WndProc(SCI_SELECTALL, 0, 0); break; } } int ScintillaBase::KeyCommand(unsigned int iMessage) { // Most key commands cancel autocompletion mode if (ac.Active()) { switch (iMessage) { // Except for these case SCI_LINEDOWN: AutoCompleteMove(1); return 0; case SCI_LINEUP: AutoCompleteMove(-1); return 0; case SCI_PAGEDOWN: AutoCompleteMove(ac.lb->GetVisibleRows()); return 0; case SCI_PAGEUP: AutoCompleteMove(-ac.lb->GetVisibleRows()); return 0; case SCI_VCHOME: AutoCompleteMove(-5000); return 0; case SCI_LINEEND: AutoCompleteMove(5000); return 0; case SCI_DELETEBACK: DelCharBack(true); AutoCompleteCharacterDeleted(); EnsureCaretVisible(); return 0; case SCI_DELETEBACKNOTLINE: DelCharBack(false); AutoCompleteCharacterDeleted(); EnsureCaretVisible(); return 0; case SCI_TAB: AutoCompleteCompleted(); return 0; case SCI_NEWLINE: AutoCompleteCompleted(); return 0; default: AutoCompleteCancel(); } } if (ct.inCallTipMode) { if ( (iMessage != SCI_CHARLEFT) && (iMessage != SCI_CHARLEFTEXTEND) && (iMessage != SCI_CHARRIGHT) && (iMessage != SCI_CHARRIGHTEXTEND) && (iMessage != SCI_EDITTOGGLEOVERTYPE) && (iMessage != SCI_DELETEBACK) && (iMessage != SCI_DELETEBACKNOTLINE) ) { ct.CallTipCancel(); } if ((iMessage == SCI_DELETEBACK) || (iMessage == SCI_DELETEBACKNOTLINE)) { if (sel.MainCaret() <= ct.posStartCallTip) { ct.CallTipCancel(); } } } return Editor::KeyCommand(iMessage); } void ScintillaBase::AutoCompleteDoubleClick(void *p) { ScintillaBase *sci = reinterpret_cast(p); sci->AutoCompleteCompleted(); } void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) { //Platform::DebugPrintf("AutoComplete %s\n", list); ct.CallTipCancel(); if (ac.chooseSingle && (listType == 0)) { if (list && !strchr(list, ac.GetSeparator())) { const char *typeSep = strchr(list, ac.GetTypesep()); int lenInsert = typeSep ? static_cast(typeSep-list) : static_cast(strlen(list)); if (ac.ignoreCase) { SetEmptySelection(sel.MainCaret() - lenEntered); pdoc->DeleteChars(sel.MainCaret(), lenEntered); SetEmptySelection(sel.MainCaret()); pdoc->InsertString(sel.MainCaret(), list, lenInsert); SetEmptySelection(sel.MainCaret() + lenInsert); } else { SetEmptySelection(sel.MainCaret()); pdoc->InsertString(sel.MainCaret(), list + lenEntered, lenInsert - lenEntered); SetEmptySelection(sel.MainCaret() + lenInsert - lenEntered); } return; } } ac.Start(wMain, idAutoComplete, sel.MainCaret(), PointMainCaret(), lenEntered, vs.lineHeight, IsUnicodeMode(), technology); PRectangle rcClient = GetClientRectangle(); Point pt = LocationFromPosition(sel.MainCaret() - lenEntered); PRectangle rcPopupBounds = wMain.GetMonitorRect(pt); if (rcPopupBounds.Height() == 0) rcPopupBounds = rcClient; int heightLB = 100; int widthLB = 100; if (pt.x >= rcClient.right - widthLB) { HorizontalScrollTo(xOffset + pt.x - rcClient.right + widthLB); Redraw(); pt = PointMainCaret(); } PRectangle rcac; rcac.left = pt.x - ac.lb->CaretFromEdge(); if (pt.y >= rcPopupBounds.bottom - heightLB && // Wont fit below. pt.y >= (rcPopupBounds.bottom + rcPopupBounds.top) / 2) { // and there is more room above. rcac.top = pt.y - heightLB; if (rcac.top < rcPopupBounds.top) { heightLB -= (rcPopupBounds.top - rcac.top); rcac.top = rcPopupBounds.top; } } else { rcac.top = pt.y + vs.lineHeight; } rcac.right = rcac.left + widthLB; rcac.bottom = Platform::Minimum(rcac.top + heightLB, rcPopupBounds.bottom); ac.lb->SetPositionRelative(rcac, wMain); ac.lb->SetFont(vs.styles[STYLE_DEFAULT].font); unsigned int aveCharWidth = vs.styles[STYLE_DEFAULT].aveCharWidth; ac.lb->SetAverageCharWidth(aveCharWidth); ac.lb->SetDoubleClickAction(AutoCompleteDoubleClick, this); ac.SetList(list); // Fiddle the position of the list so it is right next to the target and wide enough for all its strings PRectangle rcList = ac.lb->GetDesiredRect(); int heightAlloced = rcList.bottom - rcList.top; widthLB = Platform::Maximum(widthLB, rcList.right - rcList.left); if (maxListWidth != 0) widthLB = Platform::Minimum(widthLB, aveCharWidth*maxListWidth); // Make an allowance for large strings in list rcList.left = pt.x - ac.lb->CaretFromEdge(); rcList.right = rcList.left + widthLB; if (((pt.y + vs.lineHeight) >= (rcPopupBounds.bottom - heightAlloced)) && // Wont fit below. ((pt.y + vs.lineHeight / 2) >= (rcPopupBounds.bottom + rcPopupBounds.top) / 2)) { // and there is more room above. rcList.top = pt.y - heightAlloced; } else { rcList.top = pt.y + vs.lineHeight; } rcList.bottom = rcList.top + heightAlloced; ac.lb->SetPositionRelative(rcList, wMain); ac.Show(true); if (lenEntered != 0) { AutoCompleteMoveToCurrentWord(); } } void ScintillaBase::AutoCompleteCancel() { if (ac.Active()) { SCNotification scn = {0}; scn.nmhdr.code = SCN_AUTOCCANCELLED; scn.wParam = 0; scn.listType = 0; NotifyParent(scn); } ac.Cancel(); } void ScintillaBase::AutoCompleteMove(int delta) { ac.Move(delta); } void ScintillaBase::AutoCompleteMoveToCurrentWord() { char wordCurrent[1000]; int i; int startWord = ac.posStart - ac.startLen; for (i = startWord; i < sel.MainCaret() && i - startWord < 1000; i++) wordCurrent[i - startWord] = pdoc->CharAt(i); wordCurrent[Platform::Minimum(i - startWord, 999)] = '\0'; ac.Select(wordCurrent); } void ScintillaBase::AutoCompleteCharacterAdded(char ch) { if (ac.IsFillUpChar(ch)) { AutoCompleteCompleted(); } else if (ac.IsStopChar(ch)) { AutoCompleteCancel(); } else { AutoCompleteMoveToCurrentWord(); } } void ScintillaBase::AutoCompleteCharacterDeleted() { if (sel.MainCaret() < ac.posStart - ac.startLen) { AutoCompleteCancel(); } else if (ac.cancelAtStartPos && (sel.MainCaret() <= ac.posStart)) { AutoCompleteCancel(); } else { AutoCompleteMoveToCurrentWord(); } SCNotification scn = {0}; scn.nmhdr.code = SCN_AUTOCCHARDELETED; scn.wParam = 0; scn.listType = 0; NotifyParent(scn); } void ScintillaBase::AutoCompleteCompleted() { int item = ac.lb->GetSelection(); char selected[1000]; selected[0] = '\0'; if (item != -1) { ac.lb->GetValue(item, selected, sizeof(selected)); } else { AutoCompleteCancel(); return; } ac.Show(false); SCNotification scn = {0}; scn.nmhdr.code = listType > 0 ? SCN_USERLISTSELECTION : SCN_AUTOCSELECTION; scn.message = 0; scn.wParam = listType; scn.listType = listType; Position firstPos = ac.posStart - ac.startLen; scn.position = firstPos; scn.lParam = firstPos; scn.text = selected; NotifyParent(scn); if (!ac.Active()) return; ac.Cancel(); if (listType > 0) return; Position endPos = sel.MainCaret(); if (ac.dropRestOfWord) endPos = pdoc->ExtendWordSelect(endPos, 1, true); if (endPos < firstPos) return; UndoGroup ug(pdoc); if (endPos != firstPos) { pdoc->DeleteChars(firstPos, endPos - firstPos); } SetEmptySelection(ac.posStart); if (item != -1) { pdoc->InsertCString(firstPos, selected); SetEmptySelection(firstPos + static_cast(strlen(selected))); } SetLastXChosen(); } int ScintillaBase::AutoCompleteGetCurrent() { if (!ac.Active()) return -1; return ac.lb->GetSelection(); } int ScintillaBase::AutoCompleteGetCurrentText(char *buffer) { if (ac.Active()) { int item = ac.lb->GetSelection(); char selected[1000]; selected[0] = '\0'; if (item != -1) { ac.lb->GetValue(item, selected, sizeof(selected)); if (buffer != NULL) strcpy(buffer, selected); return static_cast(strlen(selected)); } } if (buffer != NULL) *buffer = '\0'; return 0; } void ScintillaBase::CallTipShow(Point pt, const char *defn) { ac.Cancel(); // If container knows about STYLE_CALLTIP then use it in place of the // STYLE_DEFAULT for the face name, size and character set. Also use it // for the foreground and background colour. int ctStyle = ct.UseStyleCallTip() ? STYLE_CALLTIP : STYLE_DEFAULT; if (ct.UseStyleCallTip()) { ct.SetForeBack(vs.styles[STYLE_CALLTIP].fore, vs.styles[STYLE_CALLTIP].back); } PRectangle rc = ct.CallTipStart(sel.MainCaret(), pt, vs.lineHeight, defn, vs.styles[ctStyle].fontName, vs.styles[ctStyle].sizeZoomed, CodePage(), vs.styles[ctStyle].characterSet, vs.technology, wMain); // If the call-tip window would be out of the client // space PRectangle rcClient = GetClientRectangle(); int offset = vs.lineHeight + rc.Height(); // adjust so it displays below the text. if (rc.top < rcClient.top) { rc.top += offset; rc.bottom += offset; } // adjust so it displays above the text. if (rc.bottom > rcClient.bottom) { rc.top -= offset; rc.bottom -= offset; } // Now display the window. CreateCallTipWindow(rc); ct.wCallTip.SetPositionRelative(rc, wMain); ct.wCallTip.Show(); } void ScintillaBase::CallTipClick() { SCNotification scn = {0}; scn.nmhdr.code = SCN_CALLTIPCLICK; scn.position = ct.clickPlace; NotifyParent(scn); } void ScintillaBase::ContextMenu(Point pt) { if (displayPopupMenu) { bool writable = !WndProc(SCI_GETREADONLY, 0, 0); popup.CreatePopUp(); AddToPopUp("Undo", idcmdUndo, writable && pdoc->CanUndo()); AddToPopUp("Redo", idcmdRedo, writable && pdoc->CanRedo()); AddToPopUp(""); AddToPopUp("Cut", idcmdCut, writable && !sel.Empty()); AddToPopUp("Copy", idcmdCopy, !sel.Empty()); AddToPopUp("Paste", idcmdPaste, writable && WndProc(SCI_CANPASTE, 0, 0)); AddToPopUp("Delete", idcmdDelete, writable && !sel.Empty()); AddToPopUp(""); AddToPopUp("Select All", idcmdSelectAll); popup.Show(pt, wMain); } } void ScintillaBase::CancelModes() { AutoCompleteCancel(); ct.CallTipCancel(); Editor::CancelModes(); } void ScintillaBase::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) { CancelModes(); Editor::ButtonDown(pt, curTime, shift, ctrl, alt); } #ifdef SCI_LEXER #ifdef SCI_NAMESPACE namespace Scintilla { #endif class LexState : public LexInterface { const LexerModule *lexCurrent; void SetLexerModule(const LexerModule *lex); PropSetSimple props; public: int lexLanguage; LexState(Document *pdoc_); virtual ~LexState(); void SetLexer(uptr_t wParam); void SetLexerLanguage(const char *languageName); const char *DescribeWordListSets(); void SetWordList(int n, const char *wl); int GetStyleBitsNeeded() const; const char *GetName() const; void *PrivateCall(int operation, void *pointer); const char *PropertyNames(); int PropertyType(const char *name); const char *DescribeProperty(const char *name); void PropSet(const char *key, const char *val); const char *PropGet(const char *key) const; int PropGetInt(const char *key, int defaultValue=0) const; int PropGetExpanded(const char *key, char *result) const; }; #ifdef SCI_NAMESPACE } #endif LexState::LexState(Document *pdoc_) : LexInterface(pdoc_) { lexCurrent = 0; performingStyle = false; lexLanguage = SCLEX_CONTAINER; } LexState::~LexState() { if (instance) { instance->Release(); instance = 0; } } LexState *ScintillaBase::DocumentLexState() { if (!pdoc->pli) { pdoc->pli = new LexState(pdoc); } return static_cast(pdoc->pli); } void LexState::SetLexerModule(const LexerModule *lex) { if (lex != lexCurrent) { if (instance) { instance->Release(); instance = 0; } lexCurrent = lex; if (lexCurrent) instance = lexCurrent->Create(); pdoc->LexerChanged(); } } void LexState::SetLexer(uptr_t wParam) { lexLanguage = wParam; if (lexLanguage == SCLEX_CONTAINER) { SetLexerModule(0); } else { const LexerModule *lex = Catalogue::Find(lexLanguage); if (!lex) lex = Catalogue::Find(SCLEX_NULL); SetLexerModule(lex); } } void LexState::SetLexerLanguage(const char *languageName) { const LexerModule *lex = Catalogue::Find(languageName); if (!lex) lex = Catalogue::Find(SCLEX_NULL); if (lex) lexLanguage = lex->GetLanguage(); SetLexerModule(lex); } const char *LexState::DescribeWordListSets() { if (instance) { return instance->DescribeWordListSets(); } else { return 0; } } void LexState::SetWordList(int n, const char *wl) { if (instance) { int firstModification = instance->WordListSet(n, wl); if (firstModification >= 0) { pdoc->ModifiedAt(firstModification); } } } int LexState::GetStyleBitsNeeded() const { return lexCurrent ? lexCurrent->GetStyleBitsNeeded() : 5; } const char *LexState::GetName() const { return lexCurrent ? lexCurrent->languageName : ""; } void *LexState::PrivateCall(int operation, void *pointer) { if (pdoc && instance) { return instance->PrivateCall(operation, pointer); } else { return 0; } } const char *LexState::PropertyNames() { if (instance) { return instance->PropertyNames(); } else { return 0; } } int LexState::PropertyType(const char *name) { if (instance) { return instance->PropertyType(name); } else { return SC_TYPE_BOOLEAN; } } const char *LexState::DescribeProperty(const char *name) { if (instance) { return instance->DescribeProperty(name); } else { return 0; } } void LexState::PropSet(const char *key, const char *val) { props.Set(key, val); if (instance) { int firstModification = instance->PropertySet(key, val); if (firstModification >= 0) { pdoc->ModifiedAt(firstModification); } } } const char *LexState::PropGet(const char *key) const { return props.Get(key); } int LexState::PropGetInt(const char *key, int defaultValue) const { return props.GetInt(key, defaultValue); } int LexState::PropGetExpanded(const char *key, char *result) const { return props.GetExpanded(key, result); } #endif void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded) { #ifdef SCI_LEXER if (DocumentLexState()->lexLanguage != SCLEX_CONTAINER) { int lineEndStyled = pdoc->LineFromPosition(pdoc->GetEndStyled()); int endStyled = pdoc->LineStart(lineEndStyled); DocumentLexState()->Colourise(endStyled, endStyleNeeded); return; } #endif Editor::NotifyStyleToNeeded(endStyleNeeded); } void ScintillaBase::NotifyLexerChanged(Document *, void *) { #ifdef SCI_LEXER int bits = DocumentLexState()->GetStyleBitsNeeded(); vs.EnsureStyle((1 << bits) - 1); #endif } sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { switch (iMessage) { case SCI_AUTOCSHOW: listType = 0; AutoCompleteStart(wParam, reinterpret_cast(lParam)); break; case SCI_AUTOCCANCEL: ac.Cancel(); break; case SCI_AUTOCACTIVE: return ac.Active(); case SCI_AUTOCPOSSTART: return ac.posStart; case SCI_AUTOCCOMPLETE: AutoCompleteCompleted(); break; case SCI_AUTOCSETSEPARATOR: ac.SetSeparator(static_cast(wParam)); break; case SCI_AUTOCGETSEPARATOR: return ac.GetSeparator(); case SCI_AUTOCSTOPS: ac.SetStopChars(reinterpret_cast(lParam)); break; case SCI_AUTOCSELECT: ac.Select(reinterpret_cast(lParam)); break; case SCI_AUTOCGETCURRENT: return AutoCompleteGetCurrent(); case SCI_AUTOCGETCURRENTTEXT: return AutoCompleteGetCurrentText(reinterpret_cast(lParam)); case SCI_AUTOCSETCANCELATSTART: ac.cancelAtStartPos = wParam != 0; break; case SCI_AUTOCGETCANCELATSTART: return ac.cancelAtStartPos; case SCI_AUTOCSETFILLUPS: ac.SetFillUpChars(reinterpret_cast(lParam)); break; case SCI_AUTOCSETCHOOSESINGLE: ac.chooseSingle = wParam != 0; break; case SCI_AUTOCGETCHOOSESINGLE: return ac.chooseSingle; case SCI_AUTOCSETIGNORECASE: ac.ignoreCase = wParam != 0; break; case SCI_AUTOCGETIGNORECASE: return ac.ignoreCase; case SCI_USERLISTSHOW: listType = wParam; AutoCompleteStart(0, reinterpret_cast(lParam)); break; case SCI_AUTOCSETAUTOHIDE: ac.autoHide = wParam != 0; break; case SCI_AUTOCGETAUTOHIDE: return ac.autoHide; case SCI_AUTOCSETDROPRESTOFWORD: ac.dropRestOfWord = wParam != 0; break; case SCI_AUTOCGETDROPRESTOFWORD: return ac.dropRestOfWord; case SCI_AUTOCSETMAXHEIGHT: ac.lb->SetVisibleRows(wParam); break; case SCI_AUTOCGETMAXHEIGHT: return ac.lb->GetVisibleRows(); case SCI_AUTOCSETMAXWIDTH: maxListWidth = wParam; break; case SCI_AUTOCGETMAXWIDTH: return maxListWidth; case SCI_REGISTERIMAGE: ac.lb->RegisterImage(wParam, reinterpret_cast(lParam)); break; case SCI_REGISTERRGBAIMAGE: ac.lb->RegisterRGBAImage(wParam, sizeRGBAImage.x, sizeRGBAImage.y, reinterpret_cast(lParam)); break; case SCI_CLEARREGISTEREDIMAGES: ac.lb->ClearRegisteredImages(); break; case SCI_AUTOCSETTYPESEPARATOR: ac.SetTypesep(static_cast(wParam)); break; case SCI_AUTOCGETTYPESEPARATOR: return ac.GetTypesep(); case SCI_CALLTIPSHOW: CallTipShow(LocationFromPosition(wParam), reinterpret_cast(lParam)); break; case SCI_CALLTIPCANCEL: ct.CallTipCancel(); break; case SCI_CALLTIPACTIVE: return ct.inCallTipMode; case SCI_CALLTIPPOSSTART: return ct.posStartCallTip; case SCI_CALLTIPSETHLT: ct.SetHighlight(wParam, lParam); break; case SCI_CALLTIPSETBACK: ct.colourBG = ColourDesired(wParam); vs.styles[STYLE_CALLTIP].back = ct.colourBG; InvalidateStyleRedraw(); break; case SCI_CALLTIPSETFORE: ct.colourUnSel = ColourDesired(wParam); vs.styles[STYLE_CALLTIP].fore = ct.colourUnSel; InvalidateStyleRedraw(); break; case SCI_CALLTIPSETFOREHLT: ct.colourSel = ColourDesired(wParam); InvalidateStyleRedraw(); break; case SCI_CALLTIPUSESTYLE: ct.SetTabSize((int)wParam); InvalidateStyleRedraw(); break; case SCI_CALLTIPSETPOSITION: ct.SetPosition(wParam != 0); InvalidateStyleRedraw(); break; case SCI_USEPOPUP: displayPopupMenu = wParam != 0; break; #ifdef SCI_LEXER case SCI_SETLEXER: DocumentLexState()->SetLexer(wParam); break; case SCI_GETLEXER: return DocumentLexState()->lexLanguage; case SCI_COLOURISE: if (DocumentLexState()->lexLanguage == SCLEX_CONTAINER) { pdoc->ModifiedAt(wParam); NotifyStyleToNeeded((lParam == -1) ? pdoc->Length() : lParam); } else { DocumentLexState()->Colourise(wParam, lParam); } Redraw(); break; case SCI_SETPROPERTY: DocumentLexState()->PropSet(reinterpret_cast(wParam), reinterpret_cast(lParam)); break; case SCI_GETPROPERTY: return StringResult(lParam, DocumentLexState()->PropGet(reinterpret_cast(wParam))); case SCI_GETPROPERTYEXPANDED: return DocumentLexState()->PropGetExpanded(reinterpret_cast(wParam), reinterpret_cast(lParam)); case SCI_GETPROPERTYINT: return DocumentLexState()->PropGetInt(reinterpret_cast(wParam), lParam); case SCI_SETKEYWORDS: DocumentLexState()->SetWordList(wParam, reinterpret_cast(lParam)); break; case SCI_SETLEXERLANGUAGE: DocumentLexState()->SetLexerLanguage(reinterpret_cast(lParam)); break; case SCI_GETLEXERLANGUAGE: return StringResult(lParam, DocumentLexState()->GetName()); case SCI_PRIVATELEXERCALL: return reinterpret_cast( DocumentLexState()->PrivateCall(wParam, reinterpret_cast(lParam))); case SCI_GETSTYLEBITSNEEDED: return DocumentLexState()->GetStyleBitsNeeded(); case SCI_PROPERTYNAMES: return StringResult(lParam, DocumentLexState()->PropertyNames()); case SCI_PROPERTYTYPE: return DocumentLexState()->PropertyType(reinterpret_cast(wParam)); case SCI_DESCRIBEPROPERTY: return StringResult(lParam, DocumentLexState()->DescribeProperty(reinterpret_cast(wParam))); case SCI_DESCRIBEKEYWORDSETS: return StringResult(lParam, DocumentLexState()->DescribeWordListSets()); #endif default: return Editor::WndProc(iMessage, wParam, lParam); } return 0l; } Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexMSSQL.cxx000444001750001750 2737412021352777 24526 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexMSSQL.cxx ** Lexer for MSSQL. **/ // By Filip Yaghob // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif #define KW_MSSQL_STATEMENTS 0 #define KW_MSSQL_DATA_TYPES 1 #define KW_MSSQL_SYSTEM_TABLES 2 #define KW_MSSQL_GLOBAL_VARIABLES 3 #define KW_MSSQL_FUNCTIONS 4 #define KW_MSSQL_STORED_PROCEDURES 5 #define KW_MSSQL_OPERATORS 6 static bool isMSSQLOperator(char ch) { if (isascii(ch) && isalnum(ch)) return false; // '.' left out as it is used to make up numbers if (ch == '%' || ch == '^' || ch == '&' || ch == '*' || ch == '-' || ch == '+' || ch == '=' || ch == '|' || ch == '<' || ch == '>' || ch == '/' || ch == '!' || ch == '~' || ch == '(' || ch == ')' || ch == ',') return true; return false; } static char classifyWordSQL(unsigned int start, unsigned int end, WordList *keywordlists[], Accessor &styler, unsigned int actualState, unsigned int prevState) { char s[256]; bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.'); WordList &kwStatements = *keywordlists[KW_MSSQL_STATEMENTS]; WordList &kwDataTypes = *keywordlists[KW_MSSQL_DATA_TYPES]; WordList &kwSystemTables = *keywordlists[KW_MSSQL_SYSTEM_TABLES]; WordList &kwGlobalVariables = *keywordlists[KW_MSSQL_GLOBAL_VARIABLES]; WordList &kwFunctions = *keywordlists[KW_MSSQL_FUNCTIONS]; WordList &kwStoredProcedures = *keywordlists[KW_MSSQL_STORED_PROCEDURES]; WordList &kwOperators = *keywordlists[KW_MSSQL_OPERATORS]; for (unsigned int i = 0; i < end - start + 1 && i < 128; i++) { s[i] = static_cast(tolower(styler[start + i])); s[i + 1] = '\0'; } char chAttr = SCE_MSSQL_IDENTIFIER; if (actualState == SCE_MSSQL_GLOBAL_VARIABLE) { if (kwGlobalVariables.InList(&s[2])) chAttr = SCE_MSSQL_GLOBAL_VARIABLE; } else if (wordIsNumber) { chAttr = SCE_MSSQL_NUMBER; } else if (prevState == SCE_MSSQL_DEFAULT_PREF_DATATYPE) { // Look first in datatypes if (kwDataTypes.InList(s)) chAttr = SCE_MSSQL_DATATYPE; else if (kwOperators.InList(s)) chAttr = SCE_MSSQL_OPERATOR; else if (kwStatements.InList(s)) chAttr = SCE_MSSQL_STATEMENT; else if (kwSystemTables.InList(s)) chAttr = SCE_MSSQL_SYSTABLE; else if (kwFunctions.InList(s)) chAttr = SCE_MSSQL_FUNCTION; else if (kwStoredProcedures.InList(s)) chAttr = SCE_MSSQL_STORED_PROCEDURE; } else { if (kwOperators.InList(s)) chAttr = SCE_MSSQL_OPERATOR; else if (kwStatements.InList(s)) chAttr = SCE_MSSQL_STATEMENT; else if (kwSystemTables.InList(s)) chAttr = SCE_MSSQL_SYSTABLE; else if (kwFunctions.InList(s)) chAttr = SCE_MSSQL_FUNCTION; else if (kwStoredProcedures.InList(s)) chAttr = SCE_MSSQL_STORED_PROCEDURE; else if (kwDataTypes.InList(s)) chAttr = SCE_MSSQL_DATATYPE; } styler.ColourTo(end, chAttr); return chAttr; } static void ColouriseMSSQLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { styler.StartAt(startPos); bool fold = styler.GetPropertyInt("fold") != 0; int lineCurrent = styler.GetLine(startPos); int spaceFlags = 0; int state = initStyle; int prevState = initStyle; char chPrev = ' '; char chNext = styler[startPos]; styler.StartSegment(startPos); unsigned int lengthDoc = startPos + length; for (unsigned int i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); if ((ch == '\r' && chNext != '\n') || (ch == '\n')) { int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags); int lev = indentCurrent; if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) { // Only non whitespace lines can be headers int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags); if (indentCurrent < (indentNext & ~SC_FOLDLEVELWHITEFLAG)) { lev |= SC_FOLDLEVELHEADERFLAG; } } if (fold) { styler.SetLevel(lineCurrent, lev); } } if (styler.IsLeadByte(ch)) { chNext = styler.SafeGetCharAt(i + 2); chPrev = ' '; i += 1; continue; } // When the last char isn't part of the state (have to deal with it too)... if ( (state == SCE_MSSQL_IDENTIFIER) || (state == SCE_MSSQL_STORED_PROCEDURE) || (state == SCE_MSSQL_DATATYPE) || //~ (state == SCE_MSSQL_COLUMN_NAME) || (state == SCE_MSSQL_FUNCTION) || //~ (state == SCE_MSSQL_GLOBAL_VARIABLE) || (state == SCE_MSSQL_VARIABLE)) { if (!iswordchar(ch)) { int stateTmp; if ((state == SCE_MSSQL_VARIABLE) || (state == SCE_MSSQL_COLUMN_NAME)) { styler.ColourTo(i - 1, state); stateTmp = state; } else stateTmp = classifyWordSQL(styler.GetStartSegment(), i - 1, keywordlists, styler, state, prevState); prevState = state; if (stateTmp == SCE_MSSQL_IDENTIFIER || stateTmp == SCE_MSSQL_VARIABLE) state = SCE_MSSQL_DEFAULT_PREF_DATATYPE; else state = SCE_MSSQL_DEFAULT; } } else if (state == SCE_MSSQL_LINE_COMMENT) { if (ch == '\r' || ch == '\n') { styler.ColourTo(i - 1, state); prevState = state; state = SCE_MSSQL_DEFAULT; } } else if (state == SCE_MSSQL_GLOBAL_VARIABLE) { if ((ch != '@') && !iswordchar(ch)) { classifyWordSQL(styler.GetStartSegment(), i - 1, keywordlists, styler, state, prevState); prevState = state; state = SCE_MSSQL_DEFAULT; } } // If is the default or one of the above succeeded if (state == SCE_MSSQL_DEFAULT || state == SCE_MSSQL_DEFAULT_PREF_DATATYPE) { if (iswordstart(ch)) { styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT); prevState = state; state = SCE_MSSQL_IDENTIFIER; } else if (ch == '/' && chNext == '*') { styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT); prevState = state; state = SCE_MSSQL_COMMENT; } else if (ch == '-' && chNext == '-') { styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT); prevState = state; state = SCE_MSSQL_LINE_COMMENT; } else if (ch == '\'') { styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT); prevState = state; state = SCE_MSSQL_STRING; } else if (ch == '"') { styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT); prevState = state; state = SCE_MSSQL_COLUMN_NAME; } else if (ch == '[') { styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT); prevState = state; state = SCE_MSSQL_COLUMN_NAME_2; } else if (isMSSQLOperator(ch)) { styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT); styler.ColourTo(i, SCE_MSSQL_OPERATOR); //~ style = SCE_MSSQL_DEFAULT; prevState = state; state = SCE_MSSQL_DEFAULT; } else if (ch == '@') { styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT); prevState = state; if (chNext == '@') { state = SCE_MSSQL_GLOBAL_VARIABLE; // i += 2; } else state = SCE_MSSQL_VARIABLE; } // When the last char is part of the state... } else if (state == SCE_MSSQL_COMMENT) { if (ch == '/' && chPrev == '*') { if (((i > (styler.GetStartSegment() + 2)) || ((initStyle == SCE_MSSQL_COMMENT) && (styler.GetStartSegment() == startPos)))) { styler.ColourTo(i, state); //~ state = SCE_MSSQL_COMMENT; prevState = state; state = SCE_MSSQL_DEFAULT; } } } else if (state == SCE_MSSQL_STRING) { if (ch == '\'') { if ( chNext == '\'' ) { i++; ch = chNext; chNext = styler.SafeGetCharAt(i + 1); } else { styler.ColourTo(i, state); prevState = state; state = SCE_MSSQL_DEFAULT; //i++; } //ch = chNext; //chNext = styler.SafeGetCharAt(i + 1); } } else if (state == SCE_MSSQL_COLUMN_NAME) { if (ch == '"') { if (chNext == '"') { i++; ch = chNext; chNext = styler.SafeGetCharAt(i + 1); } else { styler.ColourTo(i, state); prevState = state; state = SCE_MSSQL_DEFAULT_PREF_DATATYPE; //i++; } } } else if (state == SCE_MSSQL_COLUMN_NAME_2) { if (ch == ']') { styler.ColourTo(i, state); prevState = state; state = SCE_MSSQL_DEFAULT_PREF_DATATYPE; //i++; } } chPrev = ch; } styler.ColourTo(lengthDoc - 1, state); } static void FoldMSSQLDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; unsigned int endPos = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; bool inComment = (styler.StyleAt(startPos-1) == SCE_MSSQL_COMMENT); char s[10]; for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styler.StyleAt(i); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); // Comment folding if (foldComment) { if (!inComment && (style == SCE_MSSQL_COMMENT)) levelCurrent++; else if (inComment && (style != SCE_MSSQL_COMMENT)) levelCurrent--; inComment = (style == SCE_MSSQL_COMMENT); } if (style == SCE_MSSQL_STATEMENT) { // Folding between begin or case and end if (ch == 'b' || ch == 'B' || ch == 'c' || ch == 'C' || ch == 'e' || ch == 'E') { for (unsigned int j = 0; j < 5; j++) { if (!iswordchar(styler[i + j])) { break; } s[j] = static_cast(tolower(styler[i + j])); s[j + 1] = '\0'; } if ((strcmp(s, "begin") == 0) || (strcmp(s, "case") == 0)) { levelCurrent++; } if (strcmp(s, "end") == 0) { levelCurrent--; } } } if (atEOL) { int lev = levelPrev; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if ((levelCurrent > levelPrev) && (visibleChars > 0)) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelPrev = levelCurrent; visibleChars = 0; } if (!isspacechar(ch)) visibleChars++; } // Fill in the real level of the next line, keeping the current flags as they will be filled in later int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, levelPrev | flagsNext); } static const char * const sqlWordListDesc[] = { "Statements", "Data Types", "System tables", "Global variables", "Functions", "System Stored Procedures", "Operators", 0, }; LexerModule lmMSSQL(SCLEX_MSSQL, ColouriseMSSQLDoc, "mssql", FoldMSSQLDoc, sqlWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexVHDL.cxx000444001750001750 4103012021352777 24345 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexVHDL.cxx ** Lexer for VHDL ** Written by Phil Reid, ** Based on: ** - The Verilog Lexer by Avi Yegudin ** - The Fortran Lexer by Chuan-jian Shen ** - The C++ lexer by Neil Hodgson **/ // Copyright 1998-2002 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static void ColouriseVHDLDoc( unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler); /***************************************/ static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' ); } /***************************************/ static inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } /***************************************/ inline bool IsABlank(unsigned int ch) { return (ch == ' ') || (ch == 0x09) || (ch == 0x0b) ; } /***************************************/ static void ColouriseVHDLDoc( unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &Keywords = *keywordlists[0]; WordList &Operators = *keywordlists[1]; WordList &Attributes = *keywordlists[2]; WordList &Functions = *keywordlists[3]; WordList &Packages = *keywordlists[4]; WordList &Types = *keywordlists[5]; WordList &User = *keywordlists[6]; StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { // Determine if the current state should terminate. if (sc.state == SCE_VHDL_OPERATOR) { sc.SetState(SCE_VHDL_DEFAULT); } else if (sc.state == SCE_VHDL_NUMBER) { if (!IsAWordChar(sc.ch) && (sc.ch != '#')) { sc.SetState(SCE_VHDL_DEFAULT); } } else if (sc.state == SCE_VHDL_IDENTIFIER) { if (!IsAWordChar(sc.ch) || (sc.ch == '.')) { char s[100]; sc.GetCurrentLowered(s, sizeof(s)); if (Keywords.InList(s)) { sc.ChangeState(SCE_VHDL_KEYWORD); } else if (Operators.InList(s)) { sc.ChangeState(SCE_VHDL_STDOPERATOR); } else if (Attributes.InList(s)) { sc.ChangeState(SCE_VHDL_ATTRIBUTE); } else if (Functions.InList(s)) { sc.ChangeState(SCE_VHDL_STDFUNCTION); } else if (Packages.InList(s)) { sc.ChangeState(SCE_VHDL_STDPACKAGE); } else if (Types.InList(s)) { sc.ChangeState(SCE_VHDL_STDTYPE); } else if (User.InList(s)) { sc.ChangeState(SCE_VHDL_USERWORD); } sc.SetState(SCE_VHDL_DEFAULT); } } else if (sc.state == SCE_VHDL_COMMENT || sc.state == SCE_VHDL_COMMENTLINEBANG) { if (sc.atLineEnd) { sc.SetState(SCE_VHDL_DEFAULT); } } else if (sc.state == SCE_VHDL_STRING) { if (sc.ch == '\\') { if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { sc.Forward(); } } else if (sc.ch == '\"') { sc.ForwardSetState(SCE_VHDL_DEFAULT); } else if (sc.atLineEnd) { sc.ChangeState(SCE_VHDL_STRINGEOL); sc.ForwardSetState(SCE_VHDL_DEFAULT); } } // Determine if a new state should be entered. if (sc.state == SCE_VHDL_DEFAULT) { if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_VHDL_NUMBER); } else if (IsAWordStart(sc.ch)) { sc.SetState(SCE_VHDL_IDENTIFIER); } else if (sc.Match('-', '-')) { if (sc.Match("--!")) // Nice to have a different comment style sc.SetState(SCE_VHDL_COMMENTLINEBANG); else sc.SetState(SCE_VHDL_COMMENT); } else if (sc.ch == '\"') { sc.SetState(SCE_VHDL_STRING); } else if (isoperator(static_cast(sc.ch))) { sc.SetState(SCE_VHDL_OPERATOR); } } } sc.Complete(); } //============================================================================= static bool IsCommentLine(int line, Accessor &styler) { int pos = styler.LineStart(line); int eol_pos = styler.LineStart(line + 1) - 1; for (int i = pos; i < eol_pos; i++) { char ch = styler[i]; char chNext = styler[i+1]; if ((ch == '-') && (chNext == '-')) return true; else if (ch != ' ' && ch != '\t') return false; } return false; } //============================================================================= // Folding the code static void FoldNoBoxVHDLDoc( unsigned int startPos, int length, int, Accessor &styler) { // Decided it would be smarter to have the lexer have all keywords included. Therefore I // don't check if the style for the keywords that I use to adjust the levels. char words[] = "architecture begin case component else elsif end entity generate loop package process record then " "procedure function when"; WordList keywords; keywords.Set(words); bool foldComment = styler.GetPropertyInt("fold.comment", 1) != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; bool foldAtElse = styler.GetPropertyInt("fold.at.else", 1) != 0; bool foldAtBegin = styler.GetPropertyInt("fold.at.Begin", 1) != 0; bool foldAtParenthese = styler.GetPropertyInt("fold.at.Parenthese", 1) != 0; //bool foldAtWhen = styler.GetPropertyInt("fold.at.When", 1) != 0; //< fold at when in case statements int visibleChars = 0; unsigned int endPos = startPos + length; int lineCurrent = styler.GetLine(startPos); int levelCurrent = SC_FOLDLEVELBASE; if(lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; //int levelMinCurrent = levelCurrent; int levelMinCurrentElse = levelCurrent; //< Used for folding at 'else' int levelMinCurrentBegin = levelCurrent; //< Used for folding at 'begin' int levelNext = levelCurrent; /***************************************/ int lastStart = 0; char prevWord[32] = ""; /***************************************/ // Find prev word // The logic for going up or down a level depends on a the previous keyword // This code could be cleaned up. int end = 0; unsigned int j; for(j = startPos; j>0; j--) { char ch = styler.SafeGetCharAt(j); char chPrev = styler.SafeGetCharAt(j-1); int style = styler.StyleAt(j); int stylePrev = styler.StyleAt(j-1); if ((stylePrev != SCE_VHDL_COMMENT) && (stylePrev != SCE_VHDL_STRING)) { if(IsAWordChar(chPrev) && !IsAWordChar(ch)) { end = j-1; } } if ((style != SCE_VHDL_COMMENT) && (style != SCE_VHDL_STRING)) { if(!IsAWordChar(chPrev) && IsAWordStart(ch) && (end != 0)) { char s[32]; unsigned int k; for(k=0; (k<31 ) && (k(tolower(styler[j+k])); } s[k] = '\0'; if(keywords.InList(s)) { strcpy(prevWord, s); break; } } } } for(j=j+static_cast(strlen(prevWord)); j(tolower(styler[lastStart+k])); } s[k] = '\0'; if(keywords.InList(s)) { if ( strcmp(s, "architecture") == 0 || strcmp(s, "case") == 0 || strcmp(s, "component") == 0 || strcmp(s, "entity") == 0 || strcmp(s, "generate") == 0 || strcmp(s, "loop") == 0 || strcmp(s, "package") ==0 || strcmp(s, "process") == 0 || strcmp(s, "record") == 0 || strcmp(s, "then") == 0) { if (strcmp(prevWord, "end") != 0) { if (levelMinCurrentElse > levelNext) { levelMinCurrentElse = levelNext; } levelNext++; } } else if ( strcmp(s, "procedure") == 0 || strcmp(s, "function") == 0) { if (strcmp(prevWord, "end") != 0) // check for "end procedure" etc. { // This code checks to see if the procedure / function is a definition within a "package" // rather than the actual code in the body. int BracketLevel = 0; for(int j=i+1; j levelNext) { levelMinCurrentElse = levelNext; } levelNext++; break; } if((BracketLevel == 0) && (LocalCh == ';')) { break; } } } } else if (strcmp(s, "end") == 0) { levelNext--; } else if(strcmp(s, "elsif") == 0) { // elsif is followed by then so folding occurs correctly levelNext--; } else if (strcmp(s, "else") == 0) { if(strcmp(prevWord, "when") != 0) // ignore a <= x when y else z; { levelMinCurrentElse = levelNext - 1; // VHDL else is all on its own so just dec. the min level } } else if( ((strcmp(s, "begin") == 0) && (strcmp(prevWord, "architecture") == 0)) || ((strcmp(s, "begin") == 0) && (strcmp(prevWord, "function") == 0)) || ((strcmp(s, "begin") == 0) && (strcmp(prevWord, "procedure") == 0))) { levelMinCurrentBegin = levelNext - 1; } //Platform::DebugPrintf("Line[%04d] Prev[%20s] Cur[%20s] Level[%x]\n", lineCurrent+1, prevWord, s, levelCurrent); strcpy(prevWord, s); } } } if (atEOL) { int levelUse = levelCurrent; if (foldAtElse && (levelMinCurrentElse < levelUse)) { levelUse = levelMinCurrentElse; } if (foldAtBegin && (levelMinCurrentBegin < levelUse)) { levelUse = levelMinCurrentBegin; } int lev = levelUse | levelNext << 16; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if (levelUse < levelNext) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } //Platform::DebugPrintf("Line[%04d] ---------------------------------------------------- Level[%x]\n", lineCurrent+1, levelCurrent); lineCurrent++; levelCurrent = levelNext; //levelMinCurrent = levelCurrent; levelMinCurrentElse = levelCurrent; levelMinCurrentBegin = levelCurrent; visibleChars = 0; } /***************************************/ if (!isspacechar(ch)) visibleChars++; } /***************************************/ // Platform::DebugPrintf("Line[%04d] ---------------------------------------------------- Level[%x]\n", lineCurrent+1, levelCurrent); } //============================================================================= static void FoldVHDLDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { FoldNoBoxVHDLDoc(startPos, length, initStyle, styler); } //============================================================================= static const char * const VHDLWordLists[] = { "Keywords", "Operators", "Attributes", "Standard Functions", "Standard Packages", "Standard Types", "User Words", 0, }; LexerModule lmVHDL(SCLEX_VHDL, ColouriseVHDLDoc, "vhdl", FoldVHDLDoc, VHDLWordLists); // Keyword: // access after alias all architecture array assert attribute begin block body buffer bus case component // configuration constant disconnect downto else elsif end entity exit file for function generate generic // group guarded if impure in inertial inout is label library linkage literal loop map new next null of // on open others out package port postponed procedure process pure range record register reject report // return select severity shared signal subtype then to transport type unaffected units until use variable // wait when while with // // Operators: // abs and mod nand nor not or rem rol ror sla sll sra srl xnor xor // // Attributes: // left right low high ascending image value pos val succ pred leftof rightof base range reverse_range // length delayed stable quiet transaction event active last_event last_active last_value driving // driving_value simple_name path_name instance_name // // Std Functions: // now readline read writeline write endfile resolved to_bit to_bitvector to_stdulogic to_stdlogicvector // to_stdulogicvector to_x01 to_x01z to_UX01 rising_edge falling_edge is_x shift_left shift_right rotate_left // rotate_right resize to_integer to_unsigned to_signed std_match to_01 // // Std Packages: // std ieee work standard textio std_logic_1164 std_logic_arith std_logic_misc std_logic_signed // std_logic_textio std_logic_unsigned numeric_bit numeric_std math_complex math_real vital_primitives // vital_timing // // Std Types: // boolean bit character severity_level integer real time delay_length natural positive string bit_vector // file_open_kind file_open_status line text side width std_ulogic std_ulogic_vector std_logic // std_logic_vector X01 X01Z UX01 UX01Z unsigned signed // Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/Decoration.cxx000444001750001750 1065712021352777 25241 0ustar00azawawiazawawi000000000000/** @file Decoration.cxx ** Visual elements added over text. **/ // Copyright 1998-2007 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include "Platform.h" #include "Scintilla.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" #include "Decoration.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif Decoration::Decoration(int indicator_) : next(0), indicator(indicator_) { } Decoration::~Decoration() { } bool Decoration::Empty() { return (rs.Runs() == 1) && (rs.AllSameAs(0)); } DecorationList::DecorationList() : currentIndicator(0), currentValue(1), current(0), lengthDocument(0), root(0), clickNotified(false) { } DecorationList::~DecorationList() { Decoration *deco = root; while (deco) { Decoration *decoNext = deco->next; delete deco; deco = decoNext; } root = 0; current = 0; } Decoration *DecorationList::DecorationFromIndicator(int indicator) { for (Decoration *deco=root; deco; deco = deco->next) { if (deco->indicator == indicator) { return deco; } } return 0; } Decoration *DecorationList::Create(int indicator, int length) { currentIndicator = indicator; Decoration *decoNew = new Decoration(indicator); decoNew->rs.InsertSpace(0, length); Decoration *decoPrev = 0; Decoration *deco = root; while (deco && (deco->indicator < indicator)) { decoPrev = deco; deco = deco->next; } if (decoPrev == 0) { decoNew->next = root; root = decoNew; } else { decoNew->next = deco; decoPrev->next = decoNew; } return decoNew; } void DecorationList::Delete(int indicator) { Decoration *decoToDelete = 0; if (root) { if (root->indicator == indicator) { decoToDelete = root; root = root->next; } else { Decoration *deco=root; while (deco->next && !decoToDelete) { if (deco->next && deco->next->indicator == indicator) { decoToDelete = deco->next; deco->next = decoToDelete->next; } else { deco = deco->next; } } } } if (decoToDelete) { delete decoToDelete; current = 0; } } void DecorationList::SetCurrentIndicator(int indicator) { currentIndicator = indicator; current = DecorationFromIndicator(indicator); currentValue = 1; } void DecorationList::SetCurrentValue(int value) { currentValue = value ? value : 1; } bool DecorationList::FillRange(int &position, int value, int &fillLength) { if (!current) { current = DecorationFromIndicator(currentIndicator); if (!current) { current = Create(currentIndicator, lengthDocument); } } bool changed = current->rs.FillRange(position, value, fillLength); if (current->Empty()) { Delete(currentIndicator); } return changed; } void DecorationList::InsertSpace(int position, int insertLength) { const bool atEnd = position == lengthDocument; lengthDocument += insertLength; for (Decoration *deco=root; deco; deco = deco->next) { deco->rs.InsertSpace(position, insertLength); if (atEnd) { deco->rs.FillRange(position, 0, insertLength); } } } void DecorationList::DeleteRange(int position, int deleteLength) { lengthDocument -= deleteLength; Decoration *deco; for (deco=root; deco; deco = deco->next) { deco->rs.DeleteRange(position, deleteLength); } DeleteAnyEmpty(); } void DecorationList::DeleteAnyEmpty() { Decoration *deco = root; while (deco) { if ((lengthDocument == 0) || deco->Empty()) { Delete(deco->indicator); deco = root; } else { deco = deco->next; } } } int DecorationList::AllOnFor(int position) { int mask = 0; for (Decoration *deco=root; deco; deco = deco->next) { if (deco->rs.ValueAt(position)) { mask |= 1 << deco->indicator; } } return mask; } int DecorationList::ValueAt(int indicator, int position) { Decoration *deco = DecorationFromIndicator(indicator); if (deco) { return deco->rs.ValueAt(position); } return 0; } int DecorationList::Start(int indicator, int position) { Decoration *deco = DecorationFromIndicator(indicator); if (deco) { return deco->rs.StartRun(position); } return 0; } int DecorationList::End(int indicator, int position) { Decoration *deco = DecorationFromIndicator(indicator); if (deco) { return deco->rs.EndRun(position); } return 0; } Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexSQL.cxx000444001750001750 5650612021352776 24264 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexSQL.cxx ** Lexer for SQL, including PL/SQL and SQL*Plus. **/ // Copyright 1998-2011 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #include "OptionSet.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static inline bool IsAWordChar(int ch, bool sqlAllowDottedWord) { if (!sqlAllowDottedWord) return (ch < 0x80) && (isalnum(ch) || ch == '_'); else return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.'); } static inline bool IsAWordStart(int ch) { return (ch < 0x80) && (isalpha(ch) || ch == '_'); } static inline bool IsADoxygenChar(int ch) { return (islower(ch) || ch == '$' || ch == '@' || ch == '\\' || ch == '&' || ch == '<' || ch == '>' || ch == '#' || ch == '{' || ch == '}' || ch == '[' || ch == ']'); } static inline bool IsANumberChar(int ch) { // Not exactly following number definition (several dots are seen as OK, etc.) // but probably enough in most cases. return (ch < 0x80) && (isdigit(ch) || toupper(ch) == 'E' || ch == '.' || ch == '-' || ch == '+'); } class SQLStates { public : void Set(int lineNumber, unsigned short int sqlStatesLine) { if (!sqlStatement.size() == 0 || !sqlStatesLine == 0) { sqlStatement.resize(lineNumber + 1, 0); sqlStatement[lineNumber] = sqlStatesLine; } } unsigned short int IgnoreWhen (unsigned short int sqlStatesLine, bool enable) { if (enable) sqlStatesLine |= MASK_IGNORE_WHEN; else sqlStatesLine &= ~MASK_IGNORE_WHEN; return sqlStatesLine; } unsigned short int IntoCondition (unsigned short int sqlStatesLine, bool enable) { if (enable) sqlStatesLine |= MASK_INTO_CONDITION; else sqlStatesLine &= ~MASK_INTO_CONDITION; return sqlStatesLine; } unsigned short int IntoExceptionBlock (unsigned short int sqlStatesLine, bool enable) { if (enable) sqlStatesLine |= MASK_INTO_EXCEPTION; else sqlStatesLine &= ~MASK_INTO_EXCEPTION; return sqlStatesLine; } unsigned short int IntoDeclareBlock (unsigned short int sqlStatesLine, bool enable) { if (enable) sqlStatesLine |= MASK_INTO_DECLARE; else sqlStatesLine &= ~MASK_INTO_DECLARE; return sqlStatesLine; } unsigned short int BeginCaseBlock (unsigned short int sqlStatesLine) { if ((sqlStatesLine & MASK_NESTED_CASES) < MASK_NESTED_CASES) { sqlStatesLine++; } return sqlStatesLine; } unsigned short int EndCaseBlock (unsigned short int sqlStatesLine) { if ((sqlStatesLine & MASK_NESTED_CASES) > 0) { sqlStatesLine--; } return sqlStatesLine; } bool IsIgnoreWhen (unsigned short int sqlStatesLine) { return (sqlStatesLine & MASK_IGNORE_WHEN) != 0; } bool IsIntoCondition (unsigned short int sqlStatesLine) { return (sqlStatesLine & MASK_INTO_CONDITION) != 0; } bool IsIntoCaseBlock (unsigned short int sqlStatesLine) { return (sqlStatesLine & MASK_NESTED_CASES) != 0; } bool IsIntoExceptionBlock (unsigned short int sqlStatesLine) { return (sqlStatesLine & MASK_INTO_EXCEPTION) != 0; } bool IsIntoDeclareBlock (unsigned short int sqlStatesLine) { return (sqlStatesLine & MASK_INTO_DECLARE) != 0; } unsigned short int ForLine(int lineNumber) { if ((lineNumber > 0) && (sqlStatement.size() > static_cast(lineNumber))) { return sqlStatement[lineNumber]; } else { return 0; } } SQLStates() {} private : std::vector sqlStatement; enum { MASK_INTO_DECLARE = 0x1000, MASK_INTO_EXCEPTION = 0x2000, MASK_INTO_CONDITION = 0x4000, MASK_IGNORE_WHEN = 0x8000, MASK_NESTED_CASES = 0x0FFF }; }; // Options used for LexerSQL struct OptionsSQL { bool fold; bool foldAtElse; bool foldComment; bool foldCompact; bool foldOnlyBegin; bool sqlBackticksIdentifier; bool sqlNumbersignComment; bool sqlBackslashEscapes; bool sqlAllowDottedWord; OptionsSQL() { fold = false; foldAtElse = false; foldComment = false; foldCompact = false; foldOnlyBegin = false; sqlBackticksIdentifier = false; sqlNumbersignComment = false; sqlBackslashEscapes = false; sqlAllowDottedWord = false; } }; static const char * const sqlWordListDesc[] = { "Keywords", "Database Objects", "PLDoc", "SQL*Plus", "User Keywords 1", "User Keywords 2", "User Keywords 3", "User Keywords 4", 0 }; struct OptionSetSQL : public OptionSet { OptionSetSQL() { DefineProperty("fold", &OptionsSQL::fold); DefineProperty("fold.sql.at.else", &OptionsSQL::foldAtElse, "This option enables SQL folding on a \"ELSE\" and \"ELSIF\" line of an IF statement."); DefineProperty("fold.comment", &OptionsSQL::foldComment); DefineProperty("fold.compact", &OptionsSQL::foldCompact); DefineProperty("fold.sql.only.begin", &OptionsSQL::foldOnlyBegin); DefineProperty("lexer.sql.backticks.identifier", &OptionsSQL::sqlBackticksIdentifier); DefineProperty("lexer.sql.numbersign.comment", &OptionsSQL::sqlNumbersignComment, "If \"lexer.sql.numbersign.comment\" property is set to 0 a line beginning with '#' will not be a comment."); DefineProperty("sql.backslash.escapes", &OptionsSQL::sqlBackslashEscapes, "Enables backslash as an escape character in SQL."); DefineProperty("lexer.sql.allow.dotted.word", &OptionsSQL::sqlAllowDottedWord, "Set to 1 to colourise recognized words with dots " "(recommended for Oracle PL/SQL objects)."); DefineWordListSets(sqlWordListDesc); } }; class LexerSQL : public ILexer { public : LexerSQL() {} int SCI_METHOD Version () const { return lvOriginal; } void SCI_METHOD Release() { delete this; } const char * SCI_METHOD PropertyNames() { return osSQL.PropertyNames(); } int SCI_METHOD PropertyType(const char *name) { return osSQL.PropertyType(name); } const char * SCI_METHOD DescribeProperty(const char *name) { return osSQL.DescribeProperty(name); } int SCI_METHOD PropertySet(const char *key, const char *val) { if (osSQL.PropertySet(&options, key, val)) { return 0; } return -1; } const char * SCI_METHOD DescribeWordListSets() { return osSQL.DescribeWordListSets(); } int SCI_METHOD WordListSet(int n, const char *wl); void SCI_METHOD Lex (unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess); void SCI_METHOD Fold(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess); void * SCI_METHOD PrivateCall(int, void *) { return 0; } static ILexer *LexerFactorySQL() { return new LexerSQL(); } private: bool IsStreamCommentStyle(int style) { return style == SCE_SQL_COMMENT || style == SCE_SQL_COMMENTDOC || style == SCE_SQL_COMMENTDOCKEYWORD || style == SCE_SQL_COMMENTDOCKEYWORDERROR; } bool IsCommentStyle (int style) { switch (style) { case SCE_SQL_COMMENT : case SCE_SQL_COMMENTDOC : case SCE_SQL_COMMENTLINE : case SCE_SQL_COMMENTLINEDOC : case SCE_SQL_COMMENTDOCKEYWORD : case SCE_SQL_COMMENTDOCKEYWORDERROR : return true; default : return false; } } bool IsCommentLine (int line, LexAccessor &styler) { int pos = styler.LineStart(line); int eol_pos = styler.LineStart(line + 1) - 1; for (int i = pos; i + 1 < eol_pos; i++) { int style = styler.StyleAt(i); // MySQL needs -- comments to be followed by space or control char if (style == SCE_SQL_COMMENTLINE && styler.Match(i, "--")) return true; else if (!IsASpaceOrTab(styler[i])) return false; } return false; } OptionsSQL options; OptionSetSQL osSQL; SQLStates sqlStates; WordList keywords1; WordList keywords2; WordList kw_pldoc; WordList kw_sqlplus; WordList kw_user1; WordList kw_user2; WordList kw_user3; WordList kw_user4; }; int SCI_METHOD LexerSQL::WordListSet(int n, const char *wl) { WordList *wordListN = 0; switch (n) { case 0: wordListN = &keywords1; break; case 1: wordListN = &keywords2; break; case 2: wordListN = &kw_pldoc; break; case 3: wordListN = &kw_sqlplus; break; case 4: wordListN = &kw_user1; break; case 5: wordListN = &kw_user2; break; case 6: wordListN = &kw_user3; break; case 7: wordListN = &kw_user4; } int firstModification = -1; if (wordListN) { WordList wlNew; wlNew.Set(wl); if (*wordListN != wlNew) { wordListN->Set(wl); firstModification = 0; } } return firstModification; } void SCI_METHOD LexerSQL::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { LexAccessor styler(pAccess); StyleContext sc(startPos, length, initStyle, styler); int styleBeforeDCKeyword = SCE_SQL_DEFAULT; int offset = 0; for (; sc.More(); sc.Forward(), offset++) { // Determine if the current state should terminate. switch (sc.state) { case SCE_SQL_OPERATOR: sc.SetState(SCE_SQL_DEFAULT); break; case SCE_SQL_NUMBER: // We stop the number definition on non-numerical non-dot non-eE non-sign char if (!IsANumberChar(sc.ch)) { sc.SetState(SCE_SQL_DEFAULT); } break; case SCE_SQL_IDENTIFIER: if (!IsAWordChar(sc.ch, options.sqlAllowDottedWord)) { int nextState = SCE_SQL_DEFAULT; char s[1000]; sc.GetCurrentLowered(s, sizeof(s)); if (keywords1.InList(s)) { sc.ChangeState(SCE_SQL_WORD); } else if (keywords2.InList(s)) { sc.ChangeState(SCE_SQL_WORD2); } else if (kw_sqlplus.InListAbbreviated(s, '~')) { sc.ChangeState(SCE_SQL_SQLPLUS); if (strncmp(s, "rem", 3) == 0) { nextState = SCE_SQL_SQLPLUS_COMMENT; } else if (strncmp(s, "pro", 3) == 0) { nextState = SCE_SQL_SQLPLUS_PROMPT; } } else if (kw_user1.InList(s)) { sc.ChangeState(SCE_SQL_USER1); } else if (kw_user2.InList(s)) { sc.ChangeState(SCE_SQL_USER2); } else if (kw_user3.InList(s)) { sc.ChangeState(SCE_SQL_USER3); } else if (kw_user4.InList(s)) { sc.ChangeState(SCE_SQL_USER4); } sc.SetState(nextState); } break; case SCE_SQL_QUOTEDIDENTIFIER: if (sc.ch == 0x60) { if (sc.chNext == 0x60) { sc.Forward(); // Ignore it } else { sc.ForwardSetState(SCE_SQL_DEFAULT); } } break; case SCE_SQL_COMMENT: if (sc.Match('*', '/')) { sc.Forward(); sc.ForwardSetState(SCE_SQL_DEFAULT); } break; case SCE_SQL_COMMENTDOC: if (sc.Match('*', '/')) { sc.Forward(); sc.ForwardSetState(SCE_SQL_DEFAULT); } else if (sc.ch == '@' || sc.ch == '\\') { // Doxygen support // Verify that we have the conditions to mark a comment-doc-keyword if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) { styleBeforeDCKeyword = SCE_SQL_COMMENTDOC; sc.SetState(SCE_SQL_COMMENTDOCKEYWORD); } } break; case SCE_SQL_COMMENTLINE: case SCE_SQL_COMMENTLINEDOC: case SCE_SQL_SQLPLUS_COMMENT: case SCE_SQL_SQLPLUS_PROMPT: if (sc.atLineStart) { sc.SetState(SCE_SQL_DEFAULT); } break; case SCE_SQL_COMMENTDOCKEYWORD: if ((styleBeforeDCKeyword == SCE_SQL_COMMENTDOC) && sc.Match('*', '/')) { sc.ChangeState(SCE_SQL_COMMENTDOCKEYWORDERROR); sc.Forward(); sc.ForwardSetState(SCE_SQL_DEFAULT); } else if (!IsADoxygenChar(sc.ch)) { char s[100]; sc.GetCurrentLowered(s, sizeof(s)); if (!isspace(sc.ch) || !kw_pldoc.InList(s + 1)) { sc.ChangeState(SCE_SQL_COMMENTDOCKEYWORDERROR); } sc.SetState(styleBeforeDCKeyword); } break; case SCE_SQL_CHARACTER: if (options.sqlBackslashEscapes && sc.ch == '\\') { sc.Forward(); } else if (sc.ch == '\'') { if (sc.chNext == '\"') { sc.Forward(); } else { sc.ForwardSetState(SCE_SQL_DEFAULT); } } break; case SCE_SQL_STRING: if (sc.ch == '\\') { // Escape sequence sc.Forward(); } else if (sc.ch == '\"') { if (sc.chNext == '\"') { sc.Forward(); } else { sc.ForwardSetState(SCE_SQL_DEFAULT); } } break; } // Determine if a new state should be entered. if (sc.state == SCE_SQL_DEFAULT) { if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_SQL_NUMBER); } else if (IsAWordStart(sc.ch)) { sc.SetState(SCE_SQL_IDENTIFIER); } else if (sc.ch == 0x60 && options.sqlBackticksIdentifier) { sc.SetState(SCE_SQL_QUOTEDIDENTIFIER); } else if (sc.Match('/', '*')) { if (sc.Match("/**") || sc.Match("/*!")) { // Support of Doxygen doc. style sc.SetState(SCE_SQL_COMMENTDOC); } else { sc.SetState(SCE_SQL_COMMENT); } sc.Forward(); // Eat the * so it isn't used for the end of the comment } else if (sc.Match('-', '-')) { // MySQL requires a space or control char after -- // http://dev.mysql.com/doc/mysql/en/ansi-diff-comments.html // Perhaps we should enforce that with proper property: //~ } else if (sc.Match("-- ")) { sc.SetState(SCE_SQL_COMMENTLINE); } else if (sc.ch == '#' && options.sqlNumbersignComment) { sc.SetState(SCE_SQL_COMMENTLINEDOC); } else if (sc.ch == '\'') { sc.SetState(SCE_SQL_CHARACTER); } else if (sc.ch == '\"') { sc.SetState(SCE_SQL_STRING); } else if (isoperator(static_cast(sc.ch))) { sc.SetState(SCE_SQL_OPERATOR); } } } sc.Complete(); } void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { if (!options.fold) return; LexAccessor styler(pAccess); unsigned int endPos = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) { // Backtrack to previous line in case need to fix its fold status for folding block of single-line comments (i.e. '--'). lineCurrent -= 1; startPos = styler.LineStart(lineCurrent); if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent - 1) >> 16; } int levelNext = levelCurrent; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; bool endFound = false; bool isUnfoldingIgnored = false; // this statementFound flag avoids to fold when the statement is on only one line by ignoring ELSE or ELSIF // eg. "IF condition1 THEN ... ELSIF condition2 THEN ... ELSE ... END IF;" bool statementFound = false; unsigned short int sqlStatesCurrentLine = 0; if (!options.foldOnlyBegin) { sqlStatesCurrentLine = sqlStates.ForLine(lineCurrent); } for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (atEOL || (!IsCommentStyle(style) && ch == ';')) { if (endFound) { //Maybe this is the end of "EXCEPTION" BLOCK (eg. "BEGIN ... EXCEPTION ... END;") sqlStatesCurrentLine = sqlStates.IntoExceptionBlock(sqlStatesCurrentLine, false); } // set endFound and isUnfoldingIgnored to false if EOL is reached or ';' is found endFound = false; isUnfoldingIgnored = false; } if (options.foldComment && IsStreamCommentStyle(style)) { if (!IsStreamCommentStyle(stylePrev)) { levelNext++; } else if (!IsStreamCommentStyle(styleNext) && !atEOL) { // Comments don't end at end of line and the next character may be unstyled. levelNext--; } } if (options.foldComment && (style == SCE_SQL_COMMENTLINE)) { // MySQL needs -- comments to be followed by space or control char if ((ch == '-') && (chNext == '-')) { char chNext2 = styler.SafeGetCharAt(i + 2); char chNext3 = styler.SafeGetCharAt(i + 3); if (chNext2 == '{' || chNext3 == '{') { levelNext++; } else if (chNext2 == '}' || chNext3 == '}') { levelNext--; } } } // Fold block of single-line comments (i.e. '--'). if (options.foldComment && atEOL && IsCommentLine(lineCurrent, styler)) { if (!IsCommentLine(lineCurrent - 1, styler) && IsCommentLine(lineCurrent + 1, styler)) levelNext++; else if (IsCommentLine(lineCurrent - 1, styler) && !IsCommentLine(lineCurrent + 1, styler)) levelNext--; } if (style == SCE_SQL_OPERATOR) { if (ch == '(') { if (levelCurrent > levelNext) levelCurrent--; levelNext++; } else if (ch == ')') { levelNext--; } else if ((!options.foldOnlyBegin) && ch == ';') { sqlStatesCurrentLine = sqlStates.IgnoreWhen(sqlStatesCurrentLine, false); } } // If new keyword (cannot trigger on elseif or nullif, does less tests) if (style == SCE_SQL_WORD && stylePrev != SCE_SQL_WORD) { const int MAX_KW_LEN = 9; // Maximum length of folding keywords char s[MAX_KW_LEN + 2]; unsigned int j = 0; for (; j < MAX_KW_LEN + 1; j++) { if (!iswordchar(styler[i + j])) { break; } s[j] = static_cast(tolower(styler[i + j])); } if (j == MAX_KW_LEN + 1) { // Keyword too long, don't test it s[0] = '\0'; } else { s[j] = '\0'; } if (strcmp(s, "if") == 0) { if (endFound) { endFound = false; if (options.foldOnlyBegin && !isUnfoldingIgnored) { // this end isn't for begin block, but for if block ("end if;") // so ignore previous "end" by increment levelNext. levelNext++; } } else { if (!options.foldOnlyBegin) sqlStatesCurrentLine = sqlStates.IntoCondition(sqlStatesCurrentLine, true); if (levelCurrent > levelNext) { // doesn't include this line into the folding block // because doesn't hide IF (eg "END; IF") levelCurrent = levelNext; } } } else if (!options.foldOnlyBegin && strcmp(s, "then") == 0 && sqlStates.IsIntoCondition(sqlStatesCurrentLine)) { sqlStatesCurrentLine = sqlStates.IntoCondition(sqlStatesCurrentLine, false); if (!options.foldOnlyBegin) { if (levelCurrent > levelNext) { levelCurrent = levelNext; } if (!statementFound) levelNext++; statementFound = true; } else if (levelCurrent > levelNext) { // doesn't include this line into the folding block // because doesn't hide LOOP or CASE (eg "END; LOOP" or "END; CASE") levelCurrent = levelNext; } } else if (strcmp(s, "loop") == 0 || strcmp(s, "case") == 0) { if (endFound) { endFound = false; if (options.foldOnlyBegin && !isUnfoldingIgnored) { // this end isn't for begin block, but for loop block ("end loop;") or case block ("end case;") // so ignore previous "end" by increment levelNext. levelNext++; } if ((!options.foldOnlyBegin) && strcmp(s, "case") == 0) { sqlStatesCurrentLine = sqlStates.EndCaseBlock(sqlStatesCurrentLine); levelNext--; //again for the "end case;" and block when } } else if (!options.foldOnlyBegin) { if (strcmp(s, "case") == 0) { sqlStatesCurrentLine = sqlStates.BeginCaseBlock(sqlStatesCurrentLine); //for case block increment 2 times if (!statementFound) levelNext++; } if (levelCurrent > levelNext) { levelCurrent = levelNext; } if (!statementFound) levelNext++; statementFound = true; } else if (levelCurrent > levelNext) { // doesn't include this line into the folding block // because doesn't hide LOOP or CASE (eg "END; LOOP" or "END; CASE") levelCurrent = levelNext; } } else if ((!options.foldOnlyBegin) && ( // folding for ELSE and ELSIF block only if foldAtElse is set // and IF or CASE aren't on only one line with ELSE or ELSIF (with flag statementFound) options.foldAtElse && !statementFound) && strcmp(s, "elsif") == 0) { sqlStatesCurrentLine = sqlStates.IntoCondition(sqlStatesCurrentLine, true); levelCurrent--; levelNext--; } else if ((!options.foldOnlyBegin) && ( // folding for ELSE and ELSIF block only if foldAtElse is set // and IF or CASE aren't on only one line with ELSE or ELSIF (with flag statementFound) options.foldAtElse && !statementFound) && strcmp(s, "else") == 0) { // prevent also ELSE is on the same line (eg. "ELSE ... END IF;") statementFound = true; // we are in same case "} ELSE {" in C language levelCurrent--; } else if (strcmp(s, "begin") == 0) { levelNext++; sqlStatesCurrentLine = sqlStates.IntoDeclareBlock(sqlStatesCurrentLine, false); } else if ((strcmp(s, "end") == 0) || // SQL Anywhere permits IF ... ELSE ... ENDIF // will only be active if "endif" appears in the // keyword list. (strcmp(s, "endif") == 0)) { endFound = true; levelNext--; if (levelNext < SC_FOLDLEVELBASE) { levelNext = SC_FOLDLEVELBASE; isUnfoldingIgnored = true; } } else if ((!options.foldOnlyBegin) && strcmp(s, "when") == 0 && !sqlStates.IsIgnoreWhen(sqlStatesCurrentLine) && !sqlStates.IsIntoExceptionBlock(sqlStatesCurrentLine) && sqlStates.IsIntoCaseBlock(sqlStatesCurrentLine)) { sqlStatesCurrentLine = sqlStates.IntoCondition(sqlStatesCurrentLine, true); // Don't foldind when CASE and WHEN are on the same line (with flag statementFound) (eg. "CASE selector WHEN expression1 THEN sequence_of_statements1;\n") if (!statementFound) { levelCurrent--; levelNext--; } } else if ((!options.foldOnlyBegin) && strcmp(s, "exit") == 0) { sqlStatesCurrentLine = sqlStates.IgnoreWhen(sqlStatesCurrentLine, true); } else if ((!options.foldOnlyBegin) && !sqlStates.IsIntoDeclareBlock(sqlStatesCurrentLine) && strcmp(s, "exception") == 0) { sqlStatesCurrentLine = sqlStates.IntoExceptionBlock(sqlStatesCurrentLine, true); } else if ((!options.foldOnlyBegin) && (strcmp(s, "declare") == 0 || strcmp(s, "function") == 0 || strcmp(s, "procedure") == 0 || strcmp(s, "package") == 0)) { sqlStatesCurrentLine = sqlStates.IntoDeclareBlock(sqlStatesCurrentLine, true); } } if (atEOL) { int levelUse = levelCurrent; int lev = levelUse | levelNext << 16; if (visibleChars == 0 && options.foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if (levelUse < levelNext) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelCurrent = levelNext; visibleChars = 0; statementFound = false; if (!options.foldOnlyBegin) sqlStates.Set(lineCurrent, sqlStatesCurrentLine); } if (!isspacechar(ch)) { visibleChars++; } } } LexerModule lmSQL(SCLEX_SQL, LexerSQL::LexerFactorySQL, "sql", sqlWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexerNoExceptions.h000444001750001750 215112021352777 26163 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexerNoExceptions.h ** A simple lexer with no state. **/ // Copyright 1998-2010 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef LexerNoExceptions_H #define LexerNoExceptions_H #ifdef SCI_NAMESPACE namespace Scintilla { #endif // A simple lexer with no state class LexerNoExceptions : public LexerBase { public: // TODO Also need to prevent exceptions in constructor and destructor int SCI_METHOD PropertySet(const char *key, const char *val); int SCI_METHOD WordListSet(int n, const char *wl); void SCI_METHOD Lex(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess); void SCI_METHOD Fold(unsigned int startPos, int lengthDoc, int initStyle, IDocument *); virtual void Lexer(unsigned int startPos, int length, int initStyle, IDocument *pAccess, Accessor &styler) = 0; virtual void Folder(unsigned int startPos, int length, int initStyle, IDocument *pAccess, Accessor &styler) = 0; }; #ifdef SCI_NAMESPACE } #endif #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/WordList.cxx000444001750001750 1141712021352777 24714 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file KeyWords.cxx ** Colourise for particular languages. **/ // Copyright 1998-2002 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include "WordList.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif /** * Creates an array that points into each word in the string and puts \0 terminators * after each word. */ static char **ArrayFromWordList(char *wordlist, int *len, bool onlyLineEnds = false) { int prev = '\n'; int words = 0; // For rapid determination of whether a character is a separator, build // a look up table. bool wordSeparator[256]; for (int i=0; i<256; i++) { wordSeparator[i] = false; } wordSeparator['\r'] = true; wordSeparator['\n'] = true; if (!onlyLineEnds) { wordSeparator[' '] = true; wordSeparator['\t'] = true; } for (int j = 0; wordlist[j]; j++) { int curr = static_cast(wordlist[j]); if (!wordSeparator[curr] && wordSeparator[prev]) words++; prev = curr; } char **keywords = new char *[words + 1]; if (keywords) { words = 0; prev = '\0'; size_t slen = strlen(wordlist); for (size_t k = 0; k < slen; k++) { if (!wordSeparator[static_cast(wordlist[k])]) { if (!prev) { keywords[words] = &wordlist[k]; words++; } } else { wordlist[k] = '\0'; } prev = wordlist[k]; } keywords[words] = &wordlist[slen]; *len = words; } else { *len = 0; } return keywords; } bool WordList::operator!=(const WordList &other) const { if (len != other.len) return true; for (int i=0; i(words), len, sizeof(*words), cmpString); } void WordList::Set(const char *s) { Clear(); list = new char[strlen(s) + 1]; strcpy(list, s); words = ArrayFromWordList(list, &len, onlyLineEnds); SortWordList(words, len); for (unsigned int k = 0; k < (sizeof(starts) / sizeof(starts[0])); k++) starts[k] = -1; for (int l = len - 1; l >= 0; l--) { unsigned char indexChar = words[l][0]; starts[indexChar] = l; } } /** Check whether a string is in the list. * List elements are either exact matches or prefixes. * Prefix elements start with '^' and match all strings that start with the rest of the element * so '^GTK_' matches 'GTK_X', 'GTK_MAJOR_VERSION', and 'GTK_'. */ bool WordList::InList(const char *s) const { if (0 == words) return false; unsigned char firstChar = s[0]; int j = starts[firstChar]; if (j >= 0) { while ((unsigned char)words[j][0] == firstChar) { if (s[1] == words[j][1]) { const char *a = words[j] + 1; const char *b = s + 1; while (*a && *a == *b) { a++; b++; } if (!*a && !*b) return true; } j++; } } j = starts['^']; if (j >= 0) { while (words[j][0] == '^') { const char *a = words[j] + 1; const char *b = s; while (*a && *a == *b) { a++; b++; } if (!*a) return true; j++; } } return false; } /** similar to InList, but word s can be a substring of keyword. * eg. the keyword define is defined as def~ine. This means the word must start * with def to be a keyword, but also defi, defin and define are valid. * The marker is ~ in this case. */ bool WordList::InListAbbreviated(const char *s, const char marker) const { if (0 == words) return false; unsigned char firstChar = s[0]; int j = starts[firstChar]; if (j >= 0) { while (words[j][0] == firstChar) { bool isSubword = false; int start = 1; if (words[j][1] == marker) { isSubword = true; start++; } if (s[1] == words[j][start]) { const char *a = words[j] + start; const char *b = s + 1; while (*a && *a == *b) { a++; if (*a == marker) { isSubword = true; a++; } b++; } if ((!*a || isSubword) && !*b) return true; } j++; } } j = starts['^']; if (j >= 0) { while (words[j][0] == '^') { const char *a = words[j] + 1; const char *b = s; while (*a && *a == *b) { a++; b++; } if (!*a) return true; j++; } } return false; } Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexSmalltalk.cxx000444001750001750 2215412021352777 25542 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexSmalltalk.cxx ** Lexer for Smalltalk language. ** Written by Sergey Philippov, sphilippov-at-gmail-dot-com **/ // Copyright 1998-2002 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif /* | lexTable classificationBlock charClasses | charClasses := #(#DecDigit #Letter #Special #Upper #BinSel). lexTable := ByteArray new: 128. classificationBlock := [ :charClass :chars | | flag | flag := 1 bitShift: (charClasses indexOf: charClass) - 1. chars do: [ :char | lexTable at: char codePoint + 1 put: ((lexTable at: char codePoint + 1) bitOr: flag)]]. classificationBlock value: #DecDigit value: '0123456789'; value: #Letter value: '_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; value: #Special value: '()[]{};.^:'; value: #BinSel value: '~@%&*-+=|\/,<>?!'; value: #Upper value: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'. ((String new: 500) streamContents: [ :stream | stream crLf; nextPutAll: 'static int ClassificationTable[256] = {'. lexTable keysAndValuesDo: [ :index :value | ((index - 1) rem: 16) == 0 ifTrue: [ stream crLf; tab] ifFalse: [ stream space]. stream print: value. index ~= 256 ifTrue: [ stream nextPut: $,]]. stream crLf; nextPutAll: '};'; crLf. charClasses keysAndValuesDo: [ :index :name | stream crLf; nextPutAll: ( ('static inline bool is<1s>(int ch) {return (ch > 0) && (ch %< 0x80) && ((ClassificationTable[ch] & <2p>) != 0);}') expandMacrosWith: name with: (1 bitShift: (index - 1))) ]]) edit */ // autogenerated {{{{ static int ClassificationTable[256] = { 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, 16, 0, 0, 0, 16, 16, 0, 4, 4, 16, 16, 16, 16, 4, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 16, 16, 16, 16, 16, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 4, 16, 4, 4, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 16, 4, 16, 0, }; static inline bool isDecDigit(int ch) {return (ch > 0) && (ch < 0x80) && ((ClassificationTable[ch] & 1) != 0);} static inline bool isLetter(int ch) {return (ch > 0) && (ch < 0x80) && ((ClassificationTable[ch] & 2) != 0);} static inline bool isSpecial(int ch) {return (ch > 0) && (ch < 0x80) && ((ClassificationTable[ch] & 4) != 0);} static inline bool isUpper(int ch) {return (ch > 0) && (ch < 0x80) && ((ClassificationTable[ch] & 8) != 0);} static inline bool isBinSel(int ch) {return (ch > 0) && (ch < 0x80) && ((ClassificationTable[ch] & 16) != 0);} // autogenerated }}}} static inline bool isAlphaNumeric(int ch) { return isDecDigit(ch) || isLetter(ch); } static inline bool isDigitOfRadix(int ch, int radix) { if (isDecDigit(ch)) return (ch - '0') < radix; else if (!isUpper(ch)) return false; else return (ch - 'A' + 10) < radix; } static inline void skipComment(StyleContext& sc) { while (sc.More() && sc.ch != '\"') sc.Forward(); } static inline void skipString(StyleContext& sc) { while (sc.More()) { if (sc.ch == '\'') { if (sc.chNext != '\'') return; sc.Forward(); } sc.Forward(); } } static void handleHash(StyleContext& sc) { if (isSpecial(sc.chNext)) { sc.SetState(SCE_ST_SPECIAL); return; } sc.SetState(SCE_ST_SYMBOL); sc.Forward(); if (sc.ch == '\'') { sc.Forward(); skipString(sc); } else { if (isLetter(sc.ch)) { while (isAlphaNumeric(sc.chNext) || sc.chNext == ':') sc.Forward(); } else if (isBinSel(sc.ch)) { while (isBinSel(sc.chNext)) sc.Forward(); } } } static inline void handleSpecial(StyleContext& sc) { if (sc.ch == ':' && sc.chNext == '=') { sc.SetState(SCE_ST_ASSIGN); sc.Forward(); } else { if (sc.ch == '^') sc.SetState(SCE_ST_RETURN); else sc.SetState(SCE_ST_SPECIAL); } } static inline void skipInt(StyleContext& sc, int radix) { while (isDigitOfRadix(sc.chNext, radix)) sc.Forward(); } static void handleNumeric(StyleContext& sc) { char num[256]; int nl; int radix; sc.SetState(SCE_ST_NUMBER); num[0] = static_cast(sc.ch); nl = 1; while (isDecDigit(sc.chNext)) { num[nl++] = static_cast(sc.chNext); sc.Forward(); if (nl+1 == sizeof(num)/sizeof(num[0])) // overrun check break; } if (sc.chNext == 'r') { num[nl] = 0; if (num[0] == '-') radix = atoi(num + 1); else radix = atoi(num); sc.Forward(); if (sc.chNext == '-') sc.Forward(); skipInt(sc, radix); } else radix = 10; if (sc.chNext != '.' || !isDigitOfRadix(sc.GetRelative(2), radix)) return; sc.Forward(); skipInt(sc, radix); if (sc.chNext == 's') { // ScaledDecimal sc.Forward(); while (isDecDigit(sc.chNext)) sc.Forward(); return; } else if (sc.chNext != 'e' && sc.chNext != 'd' && sc.chNext != 'q') return; sc.Forward(); if (sc.chNext == '+' || sc.chNext == '-') sc.Forward(); skipInt(sc, radix); } static inline void handleBinSel(StyleContext& sc) { sc.SetState(SCE_ST_BINARY); while (isBinSel(sc.chNext)) sc.Forward(); } static void handleLetter(StyleContext& sc, WordList* specialSelectorList) { char ident[256]; int il; int state; bool doubleColonPresent; sc.SetState(SCE_ST_DEFAULT); ident[0] = static_cast(sc.ch); il = 1; while (isAlphaNumeric(sc.chNext)) { ident[il++] = static_cast(sc.chNext); sc.Forward(); if (il+2 == sizeof(ident)/sizeof(ident[0])) // overrun check break; } if (sc.chNext == ':') { doubleColonPresent = true; ident[il++] = ':'; sc.Forward(); } else doubleColonPresent = false; ident[il] = 0; if (specialSelectorList->InList(ident)) state = SCE_ST_SPEC_SEL; else if (doubleColonPresent) state = SCE_ST_KWSEND; else if (isUpper(ident[0])) state = SCE_ST_GLOBAL; else { if (!strcmp(ident, "self")) state = SCE_ST_SELF; else if (!strcmp(ident, "super")) state = SCE_ST_SUPER; else if (!strcmp(ident, "nil")) state = SCE_ST_NIL; else if (!strcmp(ident, "true") || !strcmp(ident, "false")) state = SCE_ST_BOOL; else state = SCE_ST_DEFAULT; } sc.ChangeState(state); } static void colorizeSmalltalkDoc(unsigned int startPos, int length, int initStyle, WordList *wordLists[], Accessor &styler) { StyleContext sc(startPos, length, initStyle, styler); if (initStyle == SCE_ST_COMMENT) { skipComment(sc); if (sc.More()) sc.Forward(); } else if (initStyle == SCE_ST_STRING) { skipString(sc); if (sc.More()) sc.Forward(); } for (; sc.More(); sc.Forward()) { int ch; ch = sc.ch; if (ch == '\"') { sc.SetState(SCE_ST_COMMENT); sc.Forward(); skipComment(sc); } else if (ch == '\'') { sc.SetState(SCE_ST_STRING); sc.Forward(); skipString(sc); } else if (ch == '#') handleHash(sc); else if (ch == '$') { sc.SetState(SCE_ST_CHARACTER); sc.Forward(); } else if (isSpecial(ch)) handleSpecial(sc); else if (isDecDigit(ch)) handleNumeric(sc); else if (isLetter(ch)) handleLetter(sc, wordLists[0]); else if (isBinSel(ch)) { if (ch == '-' && isDecDigit(sc.chNext)) handleNumeric(sc); else handleBinSel(sc); } else sc.SetState(SCE_ST_DEFAULT); } sc.Complete(); } static const char* const smalltalkWordListDesc[] = { "Special selectors", 0 }; LexerModule lmSmalltalk(SCLEX_SMALLTALK, colorizeSmalltalkDoc, "smalltalk", NULL, smalltalkWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexMPT.cxx000444001750001750 1250612021352777 24256 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexMPT.cxx ** Lexer for MPT specific files. Based on LexOthers.cxx ** LOT = the text log file created by the MPT application while running a test program ** Other MPT specific files to be added later. **/ // Copyright 2003 by Marius Gheorghe // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static int GetLotLineState(std::string &line) { if (line.length()) { // Most of the time the first non-blank character in line determines that line's type // Now finds the first non-blank character unsigned i; // Declares counter here to make it persistent after the for loop for (i = 0; i < line.length(); ++i) { if (!(isascii(line[i]) && isspace(line[i]))) break; } // Checks if it was a blank line if (i == line.length()) return SCE_LOT_DEFAULT; switch (line[i]) { case '*': // Fail measurement return SCE_LOT_FAIL; case '+': // Header case '|': // Header return SCE_LOT_HEADER; case ':': // Set test limits return SCE_LOT_SET; case '-': // Section break return SCE_LOT_BREAK; default: // Any other line // Checks for message at the end of lot file if (line.find("PASSED") != std::string::npos) { return SCE_LOT_PASS; } else if (line.find("FAILED") != std::string::npos) { return SCE_LOT_FAIL; } else if (line.find("ABORTED") != std::string::npos) { return SCE_LOT_ABORT; } else { return i ? SCE_LOT_PASS : SCE_LOT_DEFAULT; } } } else { return SCE_LOT_DEFAULT; } } static void ColourizeLotDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { styler.StartAt(startPos); styler.StartSegment(startPos); bool atLineStart = true;// Arms the 'at line start' flag char chNext = styler.SafeGetCharAt(startPos); std::string line(""); line.reserve(256); // Lot lines are less than 256 chars long most of the time. This should avoid reallocations // Styles LOT document unsigned int i; // Declared here because it's used after the for loop for (i = startPos; i < startPos + length; ++i) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); line += ch; atLineStart = false; // LOT files are only used on the Win32 platform, thus EOL == CR+LF // Searches for the end of line if (ch == '\r' && chNext == '\n') { line += chNext; // Gets the '\n' ++i; // Advances past the '\n' chNext = styler.SafeGetCharAt(i + 1); // Gets character of next line styler.ColourTo(i, GetLotLineState(line)); line = ""; atLineStart = true; // Arms flag for next line } } // Last line may not have a line ending if (!atLineStart) { styler.ColourTo(i - 1, GetLotLineState(line)); } } // Folds an MPT LOT file: the blocks that can be folded are: // sections (headed by a set line) // passes (contiguous pass results within a section) // fails (contiguous fail results within a section) static void FoldLotDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { bool foldCompact = styler.GetPropertyInt("fold.compact", 0) != 0; unsigned int endPos = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); char chNext = styler.SafeGetCharAt(startPos); int style = SCE_LOT_DEFAULT; int styleNext = styler.StyleAt(startPos); int lev = SC_FOLDLEVELBASE; // Gets style of previous line if not at the beginning of the document if (startPos > 1) style = styler.StyleAt(startPos - 2); for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); if (ch == '\r' && chNext == '\n') { // TO DO: // Should really get the state of the previous line from the styler int stylePrev = style; style = styleNext; styleNext = styler.StyleAt(i + 2); switch (style) { /* case SCE_LOT_SET: lev = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG; break; */ case SCE_LOT_FAIL: /* if (stylePrev != SCE_LOT_FAIL) lev = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG; else lev = SC_FOLDLEVELBASE + 1; */ lev = SC_FOLDLEVELBASE; break; default: if (lineCurrent == 0 || stylePrev == SCE_LOT_FAIL) lev = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG; else lev = SC_FOLDLEVELBASE + 1; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; break; } if (lev != styler.LevelAt(lineCurrent)) styler.SetLevel(lineCurrent, lev); lineCurrent++; visibleChars = 0; } if (!isspacechar(ch)) visibleChars++; } int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, lev | flagsNext); } static const char * const emptyWordListDesc[] = { 0 }; LexerModule lmLot(SCLEX_LOT, ColourizeLotDoc, "lot", FoldLotDoc, emptyWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexCsound.cxx000444001750001750 1462312021352777 25053 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexCsound.cxx ** Lexer for Csound (Orchestra & Score) ** Written by Georg Ritter - **/ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '?'); } static inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.' || ch == '%' || ch == '@' || ch == '$' || ch == '?'); } static inline bool IsCsoundOperator(char ch) { if (isascii(ch) && isalnum(ch)) return false; // '.' left out as it is used to make up numbers if (ch == '*' || ch == '/' || ch == '-' || ch == '+' || ch == '(' || ch == ')' || ch == '=' || ch == '^' || ch == '[' || ch == ']' || ch == '<' || ch == '&' || ch == '>' || ch == ',' || ch == '|' || ch == '~' || ch == '%' || ch == ':') return true; return false; } static void ColouriseCsoundDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &opcode = *keywordlists[0]; WordList &headerStmt = *keywordlists[1]; WordList &otherKeyword = *keywordlists[2]; // Do not leak onto next line if (initStyle == SCE_CSOUND_STRINGEOL) initStyle = SCE_CSOUND_DEFAULT; StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { // Handle line continuation generically. if (sc.ch == '\\') { if (sc.chNext == '\n' || sc.chNext == '\r') { sc.Forward(); if (sc.ch == '\r' && sc.chNext == '\n') { sc.Forward(); } continue; } } // Determine if the current state should terminate. if (sc.state == SCE_CSOUND_OPERATOR) { if (!IsCsoundOperator(static_cast(sc.ch))) { sc.SetState(SCE_CSOUND_DEFAULT); } }else if (sc.state == SCE_CSOUND_NUMBER) { if (!IsAWordChar(sc.ch)) { sc.SetState(SCE_CSOUND_DEFAULT); } } else if (sc.state == SCE_CSOUND_IDENTIFIER) { if (!IsAWordChar(sc.ch) ) { char s[100]; sc.GetCurrent(s, sizeof(s)); if (opcode.InList(s)) { sc.ChangeState(SCE_CSOUND_OPCODE); } else if (headerStmt.InList(s)) { sc.ChangeState(SCE_CSOUND_HEADERSTMT); } else if (otherKeyword.InList(s)) { sc.ChangeState(SCE_CSOUND_USERKEYWORD); } else if (s[0] == 'p') { sc.ChangeState(SCE_CSOUND_PARAM); } else if (s[0] == 'a') { sc.ChangeState(SCE_CSOUND_ARATE_VAR); } else if (s[0] == 'k') { sc.ChangeState(SCE_CSOUND_KRATE_VAR); } else if (s[0] == 'i') { // covers both i-rate variables and i-statements sc.ChangeState(SCE_CSOUND_IRATE_VAR); } else if (s[0] == 'g') { sc.ChangeState(SCE_CSOUND_GLOBAL_VAR); } sc.SetState(SCE_CSOUND_DEFAULT); } } else if (sc.state == SCE_CSOUND_COMMENT ) { if (sc.atLineEnd) { sc.SetState(SCE_CSOUND_DEFAULT); } } else if ((sc.state == SCE_CSOUND_ARATE_VAR) || (sc.state == SCE_CSOUND_KRATE_VAR) || (sc.state == SCE_CSOUND_IRATE_VAR)) { if (!IsAWordChar(sc.ch)) { sc.SetState(SCE_CSOUND_DEFAULT); } } // Determine if a new state should be entered. if (sc.state == SCE_CSOUND_DEFAULT) { if (sc.ch == ';'){ sc.SetState(SCE_CSOUND_COMMENT); } else if (isdigit(sc.ch) || (sc.ch == '.' && isdigit(sc.chNext))) { sc.SetState(SCE_CSOUND_NUMBER); } else if (IsAWordStart(sc.ch)) { sc.SetState(SCE_CSOUND_IDENTIFIER); } else if (IsCsoundOperator(static_cast(sc.ch))) { sc.SetState(SCE_CSOUND_OPERATOR); } else if (sc.ch == 'p') { sc.SetState(SCE_CSOUND_PARAM); } else if (sc.ch == 'a') { sc.SetState(SCE_CSOUND_ARATE_VAR); } else if (sc.ch == 'k') { sc.SetState(SCE_CSOUND_KRATE_VAR); } else if (sc.ch == 'i') { // covers both i-rate variables and i-statements sc.SetState(SCE_CSOUND_IRATE_VAR); } else if (sc.ch == 'g') { sc.SetState(SCE_CSOUND_GLOBAL_VAR); } } } sc.Complete(); } static void FoldCsoundInstruments(unsigned int startPos, int length, int /* initStyle */, WordList *[], Accessor &styler) { unsigned int lengthDoc = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; int stylePrev = 0; int styleNext = styler.StyleAt(startPos); for (unsigned int i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if ((stylePrev != SCE_CSOUND_OPCODE) && (style == SCE_CSOUND_OPCODE)) { char s[20]; unsigned int j = 0; while ((j < (sizeof(s) - 1)) && (iswordchar(styler[i + j]))) { s[j] = styler[i + j]; j++; } s[j] = '\0'; if (strcmp(s, "instr") == 0) levelCurrent++; if (strcmp(s, "endin") == 0) levelCurrent--; } if (atEOL) { int lev = levelPrev; if (visibleChars == 0) lev |= SC_FOLDLEVELWHITEFLAG; if ((levelCurrent > levelPrev) && (visibleChars > 0)) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelPrev = levelCurrent; visibleChars = 0; } if (!isspacechar(ch)) visibleChars++; stylePrev = style; } // Fill in the real level of the next line, keeping the current flags as they will be filled in later int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, levelPrev | flagsNext); } static const char * const csoundWordListDesc[] = { "Opcodes", "Header Statements", "User keywords", 0 }; LexerModule lmCsound(SCLEX_CSOUND, ColouriseCsoundDoc, "csound", FoldCsoundInstruments, csoundWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexEiffel.cxx000444001750001750 1714712021352776 25015 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexEiffel.cxx ** Lexer for Eiffel. **/ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static inline bool isEiffelOperator(unsigned int ch) { // '.' left out as it is used to make up numbers return ch == '*' || ch == '/' || ch == '\\' || ch == '-' || ch == '+' || ch == '(' || ch == ')' || ch == '=' || ch == '{' || ch == '}' || ch == '~' || ch == '[' || ch == ']' || ch == ';' || ch == '<' || ch == '>' || ch == ',' || ch == '.' || ch == '^' || ch == '%' || ch == ':' || ch == '!' || ch == '@' || ch == '?'; } static inline bool IsAWordChar(unsigned int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } static inline bool IsAWordStart(unsigned int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } static void ColouriseEiffelDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { if (sc.state == SCE_EIFFEL_STRINGEOL) { if (sc.ch != '\r' && sc.ch != '\n') { sc.SetState(SCE_EIFFEL_DEFAULT); } } else if (sc.state == SCE_EIFFEL_OPERATOR) { sc.SetState(SCE_EIFFEL_DEFAULT); } else if (sc.state == SCE_EIFFEL_WORD) { if (!IsAWordChar(sc.ch)) { char s[100]; sc.GetCurrentLowered(s, sizeof(s)); if (!keywords.InList(s)) { sc.ChangeState(SCE_EIFFEL_IDENTIFIER); } sc.SetState(SCE_EIFFEL_DEFAULT); } } else if (sc.state == SCE_EIFFEL_NUMBER) { if (!IsAWordChar(sc.ch)) { sc.SetState(SCE_EIFFEL_DEFAULT); } } else if (sc.state == SCE_EIFFEL_COMMENTLINE) { if (sc.ch == '\r' || sc.ch == '\n') { sc.SetState(SCE_EIFFEL_DEFAULT); } } else if (sc.state == SCE_EIFFEL_STRING) { if (sc.ch == '%') { sc.Forward(); } else if (sc.ch == '\"') { sc.Forward(); sc.SetState(SCE_EIFFEL_DEFAULT); } } else if (sc.state == SCE_EIFFEL_CHARACTER) { if (sc.ch == '\r' || sc.ch == '\n') { sc.SetState(SCE_EIFFEL_STRINGEOL); } else if (sc.ch == '%') { sc.Forward(); } else if (sc.ch == '\'') { sc.Forward(); sc.SetState(SCE_EIFFEL_DEFAULT); } } if (sc.state == SCE_EIFFEL_DEFAULT) { if (sc.ch == '-' && sc.chNext == '-') { sc.SetState(SCE_EIFFEL_COMMENTLINE); } else if (sc.ch == '\"') { sc.SetState(SCE_EIFFEL_STRING); } else if (sc.ch == '\'') { sc.SetState(SCE_EIFFEL_CHARACTER); } else if (IsADigit(sc.ch) || (sc.ch == '.')) { sc.SetState(SCE_EIFFEL_NUMBER); } else if (IsAWordStart(sc.ch)) { sc.SetState(SCE_EIFFEL_WORD); } else if (isEiffelOperator(sc.ch)) { sc.SetState(SCE_EIFFEL_OPERATOR); } } } sc.Complete(); } static bool IsEiffelComment(Accessor &styler, int pos, int len) { return len>1 && styler[pos]=='-' && styler[pos+1]=='-'; } static void FoldEiffelDocIndent(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { int lengthDoc = startPos + length; // Backtrack to previous line in case need to fix its fold status int lineCurrent = styler.GetLine(startPos); if (startPos > 0) { if (lineCurrent > 0) { lineCurrent--; startPos = styler.LineStart(lineCurrent); } } int spaceFlags = 0; int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsEiffelComment); char chNext = styler[startPos]; for (int i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) { int lev = indentCurrent; int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsEiffelComment); if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) { // Only non whitespace lines can be headers if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) { lev |= SC_FOLDLEVELHEADERFLAG; } else if (indentNext & SC_FOLDLEVELWHITEFLAG) { // Line after is blank so check the next - maybe should continue further? int spaceFlags2 = 0; int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsEiffelComment); if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) { lev |= SC_FOLDLEVELHEADERFLAG; } } } indentCurrent = indentNext; styler.SetLevel(lineCurrent, lev); lineCurrent++; } } } static void FoldEiffelDocKeyWords(unsigned int startPos, int length, int /* initStyle */, WordList *[], Accessor &styler) { unsigned int lengthDoc = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; int stylePrev = 0; int styleNext = styler.StyleAt(startPos); // lastDeferred should be determined by looking back to last keyword in case // the "deferred" is on a line before "class" bool lastDeferred = false; for (unsigned int i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if ((stylePrev != SCE_EIFFEL_WORD) && (style == SCE_EIFFEL_WORD)) { char s[20]; unsigned int j = 0; while ((j < (sizeof(s) - 1)) && (iswordchar(styler[i + j]))) { s[j] = styler[i + j]; j++; } s[j] = '\0'; if ( (strcmp(s, "check") == 0) || (strcmp(s, "debug") == 0) || (strcmp(s, "deferred") == 0) || (strcmp(s, "do") == 0) || (strcmp(s, "from") == 0) || (strcmp(s, "if") == 0) || (strcmp(s, "inspect") == 0) || (strcmp(s, "once") == 0) ) levelCurrent++; if (!lastDeferred && (strcmp(s, "class") == 0)) levelCurrent++; if (strcmp(s, "end") == 0) levelCurrent--; lastDeferred = strcmp(s, "deferred") == 0; } if (atEOL) { int lev = levelPrev; if (visibleChars == 0) lev |= SC_FOLDLEVELWHITEFLAG; if ((levelCurrent > levelPrev) && (visibleChars > 0)) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelPrev = levelCurrent; visibleChars = 0; } if (!isspacechar(ch)) visibleChars++; stylePrev = style; } // Fill in the real level of the next line, keeping the current flags as they will be filled in later int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, levelPrev | flagsNext); } static const char * const eiffelWordListDesc[] = { "Keywords", 0 }; LexerModule lmEiffel(SCLEX_EIFFEL, ColouriseEiffelDoc, "eiffel", FoldEiffelDocIndent, eiffelWordListDesc); LexerModule lmEiffelkw(SCLEX_EIFFELKW, ColouriseEiffelDoc, "eiffelkw", FoldEiffelDocKeyWords, eiffelWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexAPDL.cxx000444001750001750 1736012021352777 24341 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexAPDL.cxx ** Lexer for APDL. Based on the lexer for Assembler by The Black Horus. ** By Hadar Raz. **/ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static inline bool IsAWordChar(const int ch) { return (ch < 0x80 && (isalnum(ch) || ch == '_')); } static inline bool IsAnOperator(char ch) { // '.' left out as it is used to make up numbers if (ch == '*' || ch == '/' || ch == '-' || ch == '+' || ch == '(' || ch == ')' || ch == '=' || ch == '^' || ch == '[' || ch == ']' || ch == '<' || ch == '&' || ch == '>' || ch == ',' || ch == '|' || ch == '~' || ch == '$' || ch == ':' || ch == '%') return true; return false; } static void ColouriseAPDLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { int stringStart = ' '; WordList &processors = *keywordlists[0]; WordList &commands = *keywordlists[1]; WordList &slashcommands = *keywordlists[2]; WordList &starcommands = *keywordlists[3]; WordList &arguments = *keywordlists[4]; WordList &functions = *keywordlists[5]; // Do not leak onto next line initStyle = SCE_APDL_DEFAULT; StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { // Determine if the current state should terminate. if (sc.state == SCE_APDL_NUMBER) { if (!(IsADigit(sc.ch) || sc.ch == '.' || (sc.ch == 'e' || sc.ch == 'E') || ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) { sc.SetState(SCE_APDL_DEFAULT); } } else if (sc.state == SCE_APDL_COMMENT) { if (sc.atLineEnd) { sc.SetState(SCE_APDL_DEFAULT); } } else if (sc.state == SCE_APDL_COMMENTBLOCK) { if (sc.atLineEnd) { if (sc.ch == '\r') { sc.Forward(); } sc.ForwardSetState(SCE_APDL_DEFAULT); } } else if (sc.state == SCE_APDL_STRING) { if (sc.atLineEnd) { sc.SetState(SCE_APDL_DEFAULT); } else if ((sc.ch == '\'' && stringStart == '\'') || (sc.ch == '\"' && stringStart == '\"')) { sc.ForwardSetState(SCE_APDL_DEFAULT); } } else if (sc.state == SCE_APDL_WORD) { if (!IsAWordChar(sc.ch)) { char s[100]; sc.GetCurrentLowered(s, sizeof(s)); if (processors.InList(s)) { sc.ChangeState(SCE_APDL_PROCESSOR); } else if (slashcommands.InList(s)) { sc.ChangeState(SCE_APDL_SLASHCOMMAND); } else if (starcommands.InList(s)) { sc.ChangeState(SCE_APDL_STARCOMMAND); } else if (commands.InList(s)) { sc.ChangeState(SCE_APDL_COMMAND); } else if (arguments.InList(s)) { sc.ChangeState(SCE_APDL_ARGUMENT); } else if (functions.InList(s)) { sc.ChangeState(SCE_APDL_FUNCTION); } sc.SetState(SCE_APDL_DEFAULT); } } else if (sc.state == SCE_APDL_OPERATOR) { if (!IsAnOperator(static_cast(sc.ch))) { sc.SetState(SCE_APDL_DEFAULT); } } // Determine if a new state should be entered. if (sc.state == SCE_APDL_DEFAULT) { if (sc.ch == '!' && sc.chNext == '!') { sc.SetState(SCE_APDL_COMMENTBLOCK); } else if (sc.ch == '!') { sc.SetState(SCE_APDL_COMMENT); } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_APDL_NUMBER); } else if (sc.ch == '\'' || sc.ch == '\"') { sc.SetState(SCE_APDL_STRING); stringStart = sc.ch; } else if (IsAWordChar(sc.ch) || ((sc.ch == '*' || sc.ch == '/') && !isgraph(sc.chPrev))) { sc.SetState(SCE_APDL_WORD); } else if (IsAnOperator(static_cast(sc.ch))) { sc.SetState(SCE_APDL_OPERATOR); } } } sc.Complete(); } //------------------------------------------------------------------------------ // 06-27-07 Sergio Lucato // - Included code folding for Ansys APDL lexer // - Copyied from LexBasic.cxx and modified for APDL //------------------------------------------------------------------------------ /* Bits: * 1 - whitespace * 2 - operator * 4 - identifier * 8 - decimal digit * 16 - hex digit * 32 - bin digit */ static int character_classification[128] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 6, 2, 2, 2, 10, 6, 60, 60, 28, 28, 28, 28, 28, 28, 28, 28, 2, 2, 2, 2, 2, 2, 2, 20, 20, 20, 20, 20, 20, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 4, 2, 20, 20, 20, 20, 20, 20, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 0 }; static bool IsSpace(int c) { return c < 128 && (character_classification[c] & 1); } static bool IsIdentifier(int c) { return c < 128 && (character_classification[c] & 4); } static int LowerCase(int c) { if (c >= 'A' && c <= 'Z') return 'a' + c - 'A'; return c; } static int CheckAPDLFoldPoint(char const *token, int &level) { if (!strcmp(token, "*if") || !strcmp(token, "*do") || !strcmp(token, "*dowhile") ) { level |= SC_FOLDLEVELHEADERFLAG; return 1; } if (!strcmp(token, "*endif") || !strcmp(token, "*enddo") ) { return -1; } return 0; } static void FoldAPDLDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { int line = styler.GetLine(startPos); int level = styler.LevelAt(line); int go = 0, done = 0; int endPos = startPos + length; char word[256]; int wordlen = 0; int i; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; // Scan for tokens at the start of the line (they may include // whitespace, for tokens like "End Function" for (i = startPos; i < endPos; i++) { int c = styler.SafeGetCharAt(i); if (!done && !go) { if (wordlen) { // are we scanning a token already? word[wordlen] = static_cast(LowerCase(c)); if (!IsIdentifier(c)) { // done with token word[wordlen] = '\0'; go = CheckAPDLFoldPoint(word, level); if (!go) { // Treat any whitespace as single blank, for // things like "End Function". if (IsSpace(c) && IsIdentifier(word[wordlen - 1])) { word[wordlen] = ' '; if (wordlen < 255) wordlen++; } else // done with this line done = 1; } } else if (wordlen < 255) { wordlen++; } } else { // start scanning at first non-whitespace character if (!IsSpace(c)) { if (IsIdentifier(c)) { word[0] = static_cast(LowerCase(c)); wordlen = 1; } else // done with this line done = 1; } } } if (c == '\n') { // line end if (!done && wordlen == 0 && foldCompact) // line was only space level |= SC_FOLDLEVELWHITEFLAG; if (level != styler.LevelAt(line)) styler.SetLevel(line, level); level += go; line++; // reset state wordlen = 0; level &= ~SC_FOLDLEVELHEADERFLAG; level &= ~SC_FOLDLEVELWHITEFLAG; go = 0; done = 0; } } } static const char * const apdlWordListDesc[] = { "processors", "commands", "slashommands", "starcommands", "arguments", "functions", 0 }; LexerModule lmAPDL(SCLEX_APDL, ColouriseAPDLDoc, "apdl", FoldAPDLDoc, apdlWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/PerLine.cxx000444001750001750 3106212021352777 24501 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file PerLine.cxx ** Manages data associated with each line of the document **/ // Copyright 1998-2009 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include "Platform.h" #include "Scintilla.h" #include "SplitVector.h" #include "Partitioning.h" #include "CellBuffer.h" #include "PerLine.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif MarkerHandleSet::MarkerHandleSet() { root = 0; } MarkerHandleSet::~MarkerHandleSet() { MarkerHandleNumber *mhn = root; while (mhn) { MarkerHandleNumber *mhnToFree = mhn; mhn = mhn->next; delete mhnToFree; } root = 0; } int MarkerHandleSet::Length() const { int c = 0; MarkerHandleNumber *mhn = root; while (mhn) { c++; mhn = mhn->next; } return c; } int MarkerHandleSet::NumberFromHandle(int handle) const { MarkerHandleNumber *mhn = root; while (mhn) { if (mhn->handle == handle) { return mhn->number; } mhn = mhn->next; } return - 1; } int MarkerHandleSet::MarkValue() const { unsigned int m = 0; MarkerHandleNumber *mhn = root; while (mhn) { m |= (1 << mhn->number); mhn = mhn->next; } return m; } bool MarkerHandleSet::Contains(int handle) const { MarkerHandleNumber *mhn = root; while (mhn) { if (mhn->handle == handle) { return true; } mhn = mhn->next; } return false; } bool MarkerHandleSet::InsertHandle(int handle, int markerNum) { MarkerHandleNumber *mhn = new MarkerHandleNumber; if (!mhn) return false; mhn->handle = handle; mhn->number = markerNum; mhn->next = root; root = mhn; return true; } void MarkerHandleSet::RemoveHandle(int handle) { MarkerHandleNumber **pmhn = &root; while (*pmhn) { MarkerHandleNumber *mhn = *pmhn; if (mhn->handle == handle) { *pmhn = mhn->next; delete mhn; return; } pmhn = &((*pmhn)->next); } } bool MarkerHandleSet::RemoveNumber(int markerNum) { bool performedDeletion = false; MarkerHandleNumber **pmhn = &root; while (*pmhn) { MarkerHandleNumber *mhn = *pmhn; if (mhn->number == markerNum) { *pmhn = mhn->next; delete mhn; performedDeletion = true; } else { pmhn = &((*pmhn)->next); } } return performedDeletion; } void MarkerHandleSet::CombineWith(MarkerHandleSet *other) { MarkerHandleNumber **pmhn = &root; while (*pmhn) { pmhn = &((*pmhn)->next); } *pmhn = other->root; other->root = 0; } LineMarkers::~LineMarkers() { Init(); } void LineMarkers::Init() { for (int line = 0; line < markers.Length(); line++) { delete markers[line]; markers[line] = 0; } markers.DeleteAll(); } void LineMarkers::InsertLine(int line) { if (markers.Length()) { markers.Insert(line, 0); } } void LineMarkers::RemoveLine(int line) { // Retain the markers from the deleted line by oring them into the previous line if (markers.Length()) { if (line > 0) { MergeMarkers(line - 1); } markers.Delete(line); } } int LineMarkers::LineFromHandle(int markerHandle) { if (markers.Length()) { for (int line = 0; line < markers.Length(); line++) { if (markers[line]) { if (markers[line]->Contains(markerHandle)) { return line; } } } } return -1; } void LineMarkers::MergeMarkers(int pos) { if (markers[pos + 1] != NULL) { if (markers[pos] == NULL) markers[pos] = new MarkerHandleSet; markers[pos]->CombineWith(markers[pos + 1]); delete markers[pos + 1]; markers[pos + 1] = NULL; } } int LineMarkers::MarkValue(int line) { if (markers.Length() && (line >= 0) && (line < markers.Length()) && markers[line]) return markers[line]->MarkValue(); else return 0; } int LineMarkers::MarkerNext(int lineStart, int mask) const { if (lineStart < 0) lineStart = 0; int length = markers.Length(); for (int iLine = lineStart; iLine < length; iLine++) { MarkerHandleSet *onLine = markers[iLine]; if (onLine && ((onLine->MarkValue() & mask) != 0)) //if ((pdoc->GetMark(iLine) & lParam) != 0) return iLine; } return -1; } int LineMarkers::AddMark(int line, int markerNum, int lines) { handleCurrent++; if (!markers.Length()) { // No existing markers so allocate one element per line markers.InsertValue(0, lines, 0); } if (line >= markers.Length()) { return -1; } if (!markers[line]) { // Need new structure to hold marker handle markers[line] = new MarkerHandleSet(); if (!markers[line]) return -1; } markers[line]->InsertHandle(handleCurrent, markerNum); return handleCurrent; } bool LineMarkers::DeleteMark(int line, int markerNum, bool all) { bool someChanges = false; if (markers.Length() && (line >= 0) && (line < markers.Length()) && markers[line]) { if (markerNum == -1) { someChanges = true; delete markers[line]; markers[line] = NULL; } else { bool performedDeletion = markers[line]->RemoveNumber(markerNum); someChanges = someChanges || performedDeletion; while (all && performedDeletion) { performedDeletion = markers[line]->RemoveNumber(markerNum); someChanges = someChanges || performedDeletion; } if (markers[line]->Length() == 0) { delete markers[line]; markers[line] = NULL; } } } return someChanges; } void LineMarkers::DeleteMarkFromHandle(int markerHandle) { int line = LineFromHandle(markerHandle); if (line >= 0) { markers[line]->RemoveHandle(markerHandle); if (markers[line]->Length() == 0) { delete markers[line]; markers[line] = NULL; } } } LineLevels::~LineLevels() { } void LineLevels::Init() { levels.DeleteAll(); } void LineLevels::InsertLine(int line) { if (levels.Length()) { int level = (line < levels.Length()) ? levels[line] : SC_FOLDLEVELBASE; levels.InsertValue(line, 1, level); } } void LineLevels::RemoveLine(int line) { if (levels.Length()) { // Move up following lines but merge header flag from this line // to line before to avoid a temporary disappearence causing expansion. int firstHeader = levels[line] & SC_FOLDLEVELHEADERFLAG; levels.Delete(line); if (line == levels.Length()-1) // Last line loses the header flag levels[line-1] &= ~SC_FOLDLEVELHEADERFLAG; else if (line > 0) levels[line-1] |= firstHeader; } } void LineLevels::ExpandLevels(int sizeNew) { levels.InsertValue(levels.Length(), sizeNew - levels.Length(), SC_FOLDLEVELBASE); } void LineLevels::ClearLevels() { levels.DeleteAll(); } int LineLevels::SetLevel(int line, int level, int lines) { int prev = 0; if ((line >= 0) && (line < lines)) { if (!levels.Length()) { ExpandLevels(lines + 1); } prev = levels[line]; if (prev != level) { levels[line] = level; } } return prev; } int LineLevels::GetLevel(int line) { if (levels.Length() && (line >= 0) && (line < levels.Length())) { return levels[line]; } else { return SC_FOLDLEVELBASE; } } LineState::~LineState() { } void LineState::Init() { lineStates.DeleteAll(); } void LineState::InsertLine(int line) { if (lineStates.Length()) { lineStates.EnsureLength(line); int val = (line < lineStates.Length()) ? lineStates[line] : 0; lineStates.Insert(line, val); } } void LineState::RemoveLine(int line) { if (lineStates.Length() > line) { lineStates.Delete(line); } } int LineState::SetLineState(int line, int state) { lineStates.EnsureLength(line + 1); int stateOld = lineStates[line]; lineStates[line] = state; return stateOld; } int LineState::GetLineState(int line) { if (line < 0) return 0; lineStates.EnsureLength(line + 1); return lineStates[line]; } int LineState::GetMaxLineState() { return lineStates.Length(); } static int NumberLines(const char *text) { if (text) { int newLines = 0; while (*text) { if (*text == '\n') newLines++; text++; } return newLines+1; } else { return 0; } } // Each allocated LineAnnotation is a char array which starts with an AnnotationHeader // and then has text and optional styles. static const int IndividualStyles = 0x100; struct AnnotationHeader { short style; // Style IndividualStyles implies array of styles short lines; int length; }; LineAnnotation::~LineAnnotation() { ClearAll(); } void LineAnnotation::Init() { ClearAll(); } void LineAnnotation::InsertLine(int line) { if (annotations.Length()) { annotations.EnsureLength(line); annotations.Insert(line, 0); } } void LineAnnotation::RemoveLine(int line) { if (annotations.Length() && (line < annotations.Length())) { delete []annotations[line]; annotations.Delete(line); } } bool LineAnnotation::AnySet() const { return annotations.Length() > 0; } bool LineAnnotation::MultipleStyles(int line) const { if (annotations.Length() && (line < annotations.Length()) && annotations[line]) return reinterpret_cast(annotations[line])->style == IndividualStyles; else return 0; } int LineAnnotation::Style(int line) { if (annotations.Length() && (line < annotations.Length()) && annotations[line]) return reinterpret_cast(annotations[line])->style; else return 0; } const char *LineAnnotation::Text(int line) const { if (annotations.Length() && (line < annotations.Length()) && annotations[line]) return annotations[line]+sizeof(AnnotationHeader); else return 0; } const unsigned char *LineAnnotation::Styles(int line) const { if (annotations.Length() && (line < annotations.Length()) && annotations[line] && MultipleStyles(line)) return reinterpret_cast(annotations[line] + sizeof(AnnotationHeader) + Length(line)); else return 0; } static char *AllocateAnnotation(int length, int style) { size_t len = sizeof(AnnotationHeader) + length + ((style == IndividualStyles) ? length : 0); char *ret = new char[len]; memset(ret, 0, len); return ret; } void LineAnnotation::SetText(int line, const char *text) { if (text) { annotations.EnsureLength(line+1); int style = Style(line); if (annotations[line]) { delete []annotations[line]; } annotations[line] = AllocateAnnotation(static_cast(strlen(text)), style); AnnotationHeader *pah = reinterpret_cast(annotations[line]); pah->style = static_cast(style); pah->length = static_cast(strlen(text)); pah->lines = static_cast(NumberLines(text)); memcpy(annotations[line]+sizeof(AnnotationHeader), text, pah->length); } else { if (annotations.Length() && (line < annotations.Length()) && annotations[line]) { delete []annotations[line]; annotations[line] = 0; } } } void LineAnnotation::ClearAll() { for (int line = 0; line < annotations.Length(); line++) { delete []annotations[line]; annotations[line] = 0; } annotations.DeleteAll(); } void LineAnnotation::SetStyle(int line, int style) { annotations.EnsureLength(line+1); if (!annotations[line]) { annotations[line] = AllocateAnnotation(0, style); } reinterpret_cast(annotations[line])->style = static_cast(style); } void LineAnnotation::SetStyles(int line, const unsigned char *styles) { annotations.EnsureLength(line+1); if (!annotations[line]) { annotations[line] = AllocateAnnotation(0, IndividualStyles); } else { AnnotationHeader *pahSource = reinterpret_cast(annotations[line]); if (pahSource->style != IndividualStyles) { char *allocation = AllocateAnnotation(pahSource->length, IndividualStyles); AnnotationHeader *pahAlloc = reinterpret_cast(allocation); pahAlloc->length = pahSource->length; pahAlloc->lines = pahSource->lines; memcpy(allocation + sizeof(AnnotationHeader), annotations[line] + sizeof(AnnotationHeader), pahSource->length); delete []annotations[line]; annotations[line] = allocation; } } AnnotationHeader *pah = reinterpret_cast(annotations[line]); pah->style = IndividualStyles; memcpy(annotations[line] + sizeof(AnnotationHeader) + pah->length, styles, pah->length); } int LineAnnotation::Length(int line) const { if (annotations.Length() && (line < annotations.Length()) && annotations[line]) return reinterpret_cast(annotations[line])->length; else return 0; } int LineAnnotation::Lines(int line) const { if (annotations.Length() && (line < annotations.Length()) && annotations[line]) return reinterpret_cast(annotations[line])->lines; else return 0; } Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/Partitioning.h000444001750001750 1213312021352777 25235 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file Partitioning.h ** Data structure used to partition an interval. Used for holding line start/end positions. **/ // Copyright 1998-2007 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef PARTITIONING_H #define PARTITIONING_H /// A split vector of integers with a method for adding a value to all elements /// in a range. /// Used by the Partitioning class. class SplitVectorWithRangeAdd : public SplitVector { public: SplitVectorWithRangeAdd(int growSize_) { SetGrowSize(growSize_); ReAllocate(growSize_); } ~SplitVectorWithRangeAdd() { } void RangeAddDelta(int start, int end, int delta) { // end is 1 past end, so end-start is number of elements to change int i = 0; int rangeLength = end - start; int range1Length = rangeLength; int part1Left = part1Length - start; if (range1Length > part1Left) range1Length = part1Left; while (i < range1Length) { body[start++] += delta; i++; } start += gapLength; while (i < rangeLength) { body[start++] += delta; i++; } } }; /// Divide an interval into multiple partitions. /// Useful for breaking a document down into sections such as lines. /// A 0 length interval has a single 0 length partition, numbered 0 /// If interval not 0 length then each partition non-zero length /// When needed, positions after the interval are considered part of the last partition /// but the end of the last partition can be found with PositionFromPartition(last+1). class Partitioning { private: // To avoid calculating all the partition positions whenever any text is inserted // there may be a step somewhere in the list. int stepPartition; int stepLength; SplitVectorWithRangeAdd *body; // Move step forward void ApplyStep(int partitionUpTo) { if (stepLength != 0) { body->RangeAddDelta(stepPartition+1, partitionUpTo + 1, stepLength); } stepPartition = partitionUpTo; if (stepPartition >= body->Length()-1) { stepPartition = body->Length()-1; stepLength = 0; } } // Move step backward void BackStep(int partitionDownTo) { if (stepLength != 0) { body->RangeAddDelta(partitionDownTo+1, stepPartition+1, -stepLength); } stepPartition = partitionDownTo; } void Allocate(int growSize) { body = new SplitVectorWithRangeAdd(growSize); stepPartition = 0; stepLength = 0; body->Insert(0, 0); // This value stays 0 for ever body->Insert(1, 0); // This is the end of the first partition and will be the start of the second } public: Partitioning(int growSize) { Allocate(growSize); } ~Partitioning() { delete body; body = 0; } int Partitions() const { return body->Length()-1; } void InsertPartition(int partition, int pos) { if (stepPartition < partition) { ApplyStep(partition); } body->Insert(partition, pos); stepPartition++; } void SetPartitionStartPosition(int partition, int pos) { ApplyStep(partition+1); if ((partition < 0) || (partition > body->Length())) { return; } body->SetValueAt(partition, pos); } void InsertText(int partitionInsert, int delta) { // Point all the partitions after the insertion point further along in the buffer if (stepLength != 0) { if (partitionInsert >= stepPartition) { // Fill in up to the new insertion point ApplyStep(partitionInsert); stepLength += delta; } else if (partitionInsert >= (stepPartition - body->Length() / 10)) { // Close to step but before so move step back BackStep(partitionInsert); stepLength += delta; } else { ApplyStep(body->Length()-1); stepPartition = partitionInsert; stepLength = delta; } } else { stepPartition = partitionInsert; stepLength = delta; } } void RemovePartition(int partition) { if (partition > stepPartition) { ApplyStep(partition); stepPartition--; } else { stepPartition--; } body->Delete(partition); } int PositionFromPartition(int partition) const { PLATFORM_ASSERT(partition >= 0); PLATFORM_ASSERT(partition < body->Length()); if ((partition < 0) || (partition >= body->Length())) { return 0; } int pos = body->ValueAt(partition); if (partition > stepPartition) pos += stepLength; return pos; } /// Return value in range [0 .. Partitions() - 1] even for arguments outside interval int PartitionFromPosition(int pos) const { if (body->Length() <= 1) return 0; if (pos >= (PositionFromPartition(body->Length()-1))) return body->Length() - 1 - 1; int lower = 0; int upper = body->Length()-1; do { int middle = (upper + lower + 1) / 2; // Round high int posMiddle = body->ValueAt(middle); if (middle > stepPartition) posMiddle += stepLength; if (pos < posMiddle) { upper = middle - 1; } else { lower = middle; } } while (lower < upper); return lower; } void DeleteAll() { int growSize = body->GetGrowSize(); delete body; Allocate(growSize); } }; #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/KeyMap.cxx000444001750001750 1347412021352777 24340 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file KeyMap.cxx ** Defines a mapping between keystrokes and commands. **/ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include "Platform.h" #include "Scintilla.h" #include "KeyMap.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif KeyMap::KeyMap() : kmap(0), len(0), alloc(0) { for (int i = 0; MapDefault[i].key; i++) { AssignCmdKey(MapDefault[i].key, MapDefault[i].modifiers, MapDefault[i].msg); } } KeyMap::~KeyMap() { Clear(); } void KeyMap::Clear() { delete []kmap; kmap = 0; len = 0; alloc = 0; } void KeyMap::AssignCmdKey(int key, int modifiers, unsigned int msg) { if ((len+1) >= alloc) { KeyToCommand *ktcNew = new KeyToCommand[alloc + 5]; if (!ktcNew) return; for (int k = 0; k < len; k++) ktcNew[k] = kmap[k]; alloc += 5; delete []kmap; kmap = ktcNew; } for (int keyIndex = 0; keyIndex < len; keyIndex++) { if ((key == kmap[keyIndex].key) && (modifiers == kmap[keyIndex].modifiers)) { kmap[keyIndex].msg = msg; return; } } kmap[len].key = key; kmap[len].modifiers = modifiers; kmap[len].msg = msg; len++; } unsigned int KeyMap::Find(int key, int modifiers) { for (int i = 0; i < len; i++) { if ((key == kmap[i].key) && (modifiers == kmap[i].modifiers)) { return kmap[i].msg; } } return 0; } #if PLAT_GTK_MACOSX #define OS_X_KEYS 1 #else #define OS_X_KEYS 0 #endif // Define a modifier that is exactly Ctrl key on all platforms // Most uses of Ctrl map to Cmd on OS X but some can't so use SCI_[S]CTRL_META #if OS_X_KEYS #define SCI_CTRL_META SCI_META #define SCI_SCTRL_META (SCI_META | SCI_SHIFT) #else #define SCI_CTRL_META SCI_CTRL #define SCI_SCTRL_META (SCI_CTRL | SCI_SHIFT) #endif const KeyToCommand KeyMap::MapDefault[] = { #if OS_X_KEYS {SCK_DOWN, SCI_CTRL, SCI_DOCUMENTEND}, {SCK_DOWN, SCI_CSHIFT, SCI_DOCUMENTENDEXTEND}, {SCK_UP, SCI_CTRL, SCI_DOCUMENTSTART}, {SCK_UP, SCI_CSHIFT, SCI_DOCUMENTSTARTEXTEND}, {SCK_LEFT, SCI_CTRL, SCI_VCHOME}, {SCK_LEFT, SCI_CSHIFT, SCI_VCHOMEEXTEND}, {SCK_RIGHT, SCI_CTRL, SCI_LINEEND}, {SCK_RIGHT, SCI_CSHIFT, SCI_LINEENDEXTEND}, #endif {SCK_DOWN, SCI_NORM, SCI_LINEDOWN}, {SCK_DOWN, SCI_SHIFT, SCI_LINEDOWNEXTEND}, {SCK_DOWN, SCI_CTRL_META, SCI_LINESCROLLDOWN}, {SCK_DOWN, SCI_ASHIFT, SCI_LINEDOWNRECTEXTEND}, {SCK_UP, SCI_NORM, SCI_LINEUP}, {SCK_UP, SCI_SHIFT, SCI_LINEUPEXTEND}, {SCK_UP, SCI_CTRL_META, SCI_LINESCROLLUP}, {SCK_UP, SCI_ASHIFT, SCI_LINEUPRECTEXTEND}, {'[', SCI_CTRL, SCI_PARAUP}, {'[', SCI_CSHIFT, SCI_PARAUPEXTEND}, {']', SCI_CTRL, SCI_PARADOWN}, {']', SCI_CSHIFT, SCI_PARADOWNEXTEND}, {SCK_LEFT, SCI_NORM, SCI_CHARLEFT}, {SCK_LEFT, SCI_SHIFT, SCI_CHARLEFTEXTEND}, {SCK_LEFT, SCI_CTRL_META, SCI_WORDLEFT}, {SCK_LEFT, SCI_SCTRL_META, SCI_WORDLEFTEXTEND}, {SCK_LEFT, SCI_ASHIFT, SCI_CHARLEFTRECTEXTEND}, {SCK_RIGHT, SCI_NORM, SCI_CHARRIGHT}, {SCK_RIGHT, SCI_SHIFT, SCI_CHARRIGHTEXTEND}, {SCK_RIGHT, SCI_CTRL_META, SCI_WORDRIGHT}, {SCK_RIGHT, SCI_SCTRL_META, SCI_WORDRIGHTEXTEND}, {SCK_RIGHT, SCI_ASHIFT, SCI_CHARRIGHTRECTEXTEND}, {'/', SCI_CTRL, SCI_WORDPARTLEFT}, {'/', SCI_CSHIFT, SCI_WORDPARTLEFTEXTEND}, {'\\', SCI_CTRL, SCI_WORDPARTRIGHT}, {'\\', SCI_CSHIFT, SCI_WORDPARTRIGHTEXTEND}, {SCK_HOME, SCI_NORM, SCI_VCHOME}, {SCK_HOME, SCI_SHIFT, SCI_VCHOMEEXTEND}, {SCK_HOME, SCI_CTRL, SCI_DOCUMENTSTART}, {SCK_HOME, SCI_CSHIFT, SCI_DOCUMENTSTARTEXTEND}, {SCK_HOME, SCI_ALT, SCI_HOMEDISPLAY}, {SCK_HOME, SCI_ASHIFT, SCI_VCHOMERECTEXTEND}, {SCK_END, SCI_NORM, SCI_LINEEND}, {SCK_END, SCI_SHIFT, SCI_LINEENDEXTEND}, {SCK_END, SCI_CTRL, SCI_DOCUMENTEND}, {SCK_END, SCI_CSHIFT, SCI_DOCUMENTENDEXTEND}, {SCK_END, SCI_ALT, SCI_LINEENDDISPLAY}, {SCK_END, SCI_ASHIFT, SCI_LINEENDRECTEXTEND}, {SCK_PRIOR, SCI_NORM, SCI_PAGEUP}, {SCK_PRIOR, SCI_SHIFT, SCI_PAGEUPEXTEND}, {SCK_PRIOR, SCI_ASHIFT, SCI_PAGEUPRECTEXTEND}, {SCK_NEXT, SCI_NORM, SCI_PAGEDOWN}, {SCK_NEXT, SCI_SHIFT, SCI_PAGEDOWNEXTEND}, {SCK_NEXT, SCI_ASHIFT, SCI_PAGEDOWNRECTEXTEND}, {SCK_DELETE, SCI_NORM, SCI_CLEAR}, {SCK_DELETE, SCI_SHIFT, SCI_CUT}, {SCK_DELETE, SCI_CTRL, SCI_DELWORDRIGHT}, {SCK_DELETE, SCI_CSHIFT, SCI_DELLINERIGHT}, {SCK_INSERT, SCI_NORM, SCI_EDITTOGGLEOVERTYPE}, {SCK_INSERT, SCI_SHIFT, SCI_PASTE}, {SCK_INSERT, SCI_CTRL, SCI_COPY}, {SCK_ESCAPE, SCI_NORM, SCI_CANCEL}, {SCK_BACK, SCI_NORM, SCI_DELETEBACK}, {SCK_BACK, SCI_SHIFT, SCI_DELETEBACK}, {SCK_BACK, SCI_CTRL, SCI_DELWORDLEFT}, {SCK_BACK, SCI_ALT, SCI_UNDO}, {SCK_BACK, SCI_CSHIFT, SCI_DELLINELEFT}, {'Z', SCI_CTRL, SCI_UNDO}, #if OS_X_KEYS {'Z', SCI_CSHIFT, SCI_REDO}, #else {'Y', SCI_CTRL, SCI_REDO}, #endif {'X', SCI_CTRL, SCI_CUT}, {'C', SCI_CTRL, SCI_COPY}, {'V', SCI_CTRL, SCI_PASTE}, {'A', SCI_CTRL, SCI_SELECTALL}, {SCK_TAB, SCI_NORM, SCI_TAB}, {SCK_TAB, SCI_SHIFT, SCI_BACKTAB}, {SCK_RETURN, SCI_NORM, SCI_NEWLINE}, {SCK_RETURN, SCI_SHIFT, SCI_NEWLINE}, {SCK_ADD, SCI_CTRL, SCI_ZOOMIN}, {SCK_SUBTRACT, SCI_CTRL, SCI_ZOOMOUT}, {SCK_DIVIDE, SCI_CTRL, SCI_SETZOOM}, {'L', SCI_CTRL, SCI_LINECUT}, {'L', SCI_CSHIFT, SCI_LINEDELETE}, {'T', SCI_CSHIFT, SCI_LINECOPY}, {'T', SCI_CTRL, SCI_LINETRANSPOSE}, {'D', SCI_CTRL, SCI_SELECTIONDUPLICATE}, {'U', SCI_CTRL, SCI_LOWERCASE}, {'U', SCI_CSHIFT, SCI_UPPERCASE}, {0,0,0}, }; Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexCmake.cxx000444001750001750 3754712021352777 24652 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexCmake.cxx ** Lexer for Cmake **/ // Copyright 2007 by Cristian Adam // based on the NSIS lexer // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static bool isCmakeNumber(char ch) { return(ch >= '0' && ch <= '9'); } static bool isCmakeChar(char ch) { return(ch == '.' ) || (ch == '_' ) || isCmakeNumber(ch) || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'); } static bool isCmakeLetter(char ch) { return(ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'); } static bool CmakeNextLineHasElse(unsigned int start, unsigned int end, Accessor &styler) { int nNextLine = -1; for ( unsigned int i = start; i < end; i++ ) { char cNext = styler.SafeGetCharAt( i ); if ( cNext == '\n' ) { nNextLine = i+1; break; } } if ( nNextLine == -1 ) // We never foudn the next line... return false; for ( unsigned int firstChar = nNextLine; firstChar < end; firstChar++ ) { char cNext = styler.SafeGetCharAt( firstChar ); if ( cNext == ' ' ) continue; if ( cNext == '\t' ) continue; if ( styler.Match(firstChar, "ELSE") || styler.Match(firstChar, "else")) return true; break; } return false; } static int calculateFoldCmake(unsigned int start, unsigned int end, int foldlevel, Accessor &styler, bool bElse) { // If the word is too long, it is not what we are looking for if ( end - start > 20 ) return foldlevel; int newFoldlevel = foldlevel; char s[20]; // The key word we are looking for has atmost 13 characters for (unsigned int i = 0; i < end - start + 1 && i < 19; i++) { s[i] = static_cast( styler[ start + i ] ); s[i + 1] = '\0'; } if ( CompareCaseInsensitive(s, "IF") == 0 || CompareCaseInsensitive(s, "WHILE") == 0 || CompareCaseInsensitive(s, "MACRO") == 0 || CompareCaseInsensitive(s, "FOREACH") == 0 || CompareCaseInsensitive(s, "ELSEIF") == 0 ) newFoldlevel++; else if ( CompareCaseInsensitive(s, "ENDIF") == 0 || CompareCaseInsensitive(s, "ENDWHILE") == 0 || CompareCaseInsensitive(s, "ENDMACRO") == 0 || CompareCaseInsensitive(s, "ENDFOREACH") == 0) newFoldlevel--; else if ( bElse && CompareCaseInsensitive(s, "ELSEIF") == 0 ) newFoldlevel++; else if ( bElse && CompareCaseInsensitive(s, "ELSE") == 0 ) newFoldlevel++; return newFoldlevel; } static int classifyWordCmake(unsigned int start, unsigned int end, WordList *keywordLists[], Accessor &styler ) { char word[100] = {0}; char lowercaseWord[100] = {0}; WordList &Commands = *keywordLists[0]; WordList &Parameters = *keywordLists[1]; WordList &UserDefined = *keywordLists[2]; for (unsigned int i = 0; i < end - start + 1 && i < 99; i++) { word[i] = static_cast( styler[ start + i ] ); lowercaseWord[i] = static_cast(tolower(word[i])); } // Check for special words... if ( CompareCaseInsensitive(word, "MACRO") == 0 || CompareCaseInsensitive(word, "ENDMACRO") == 0 ) return SCE_CMAKE_MACRODEF; if ( CompareCaseInsensitive(word, "IF") == 0 || CompareCaseInsensitive(word, "ENDIF") == 0 ) return SCE_CMAKE_IFDEFINEDEF; if ( CompareCaseInsensitive(word, "ELSEIF") == 0 || CompareCaseInsensitive(word, "ELSE") == 0 ) return SCE_CMAKE_IFDEFINEDEF; if ( CompareCaseInsensitive(word, "WHILE") == 0 || CompareCaseInsensitive(word, "ENDWHILE") == 0) return SCE_CMAKE_WHILEDEF; if ( CompareCaseInsensitive(word, "FOREACH") == 0 || CompareCaseInsensitive(word, "ENDFOREACH") == 0) return SCE_CMAKE_FOREACHDEF; if ( Commands.InList(lowercaseWord) ) return SCE_CMAKE_COMMANDS; if ( Parameters.InList(word) ) return SCE_CMAKE_PARAMETERS; if ( UserDefined.InList(word) ) return SCE_CMAKE_USERDEFINED; if ( strlen(word) > 3 ) { if ( word[1] == '{' && word[strlen(word)-1] == '}' ) return SCE_CMAKE_VARIABLE; } // To check for numbers if ( isCmakeNumber( word[0] ) ) { bool bHasSimpleCmakeNumber = true; for (unsigned int j = 1; j < end - start + 1 && j < 99; j++) { if ( !isCmakeNumber( word[j] ) ) { bHasSimpleCmakeNumber = false; break; } } if ( bHasSimpleCmakeNumber ) return SCE_CMAKE_NUMBER; } return SCE_CMAKE_DEFAULT; } static void ColouriseCmakeDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) { int state = SCE_CMAKE_DEFAULT; if ( startPos > 0 ) state = styler.StyleAt(startPos-1); // Use the style from the previous line, usually default, but could be commentbox styler.StartAt( startPos ); styler.GetLine( startPos ); unsigned int nLengthDoc = startPos + length; styler.StartSegment( startPos ); char cCurrChar; bool bVarInString = false; bool bClassicVarInString = false; unsigned int i; for ( i = startPos; i < nLengthDoc; i++ ) { cCurrChar = styler.SafeGetCharAt( i ); char cNextChar = styler.SafeGetCharAt(i+1); switch (state) { case SCE_CMAKE_DEFAULT: if ( cCurrChar == '#' ) { // we have a comment line styler.ColourTo(i-1, state ); state = SCE_CMAKE_COMMENT; break; } if ( cCurrChar == '"' ) { styler.ColourTo(i-1, state ); state = SCE_CMAKE_STRINGDQ; bVarInString = false; bClassicVarInString = false; break; } if ( cCurrChar == '\'' ) { styler.ColourTo(i-1, state ); state = SCE_CMAKE_STRINGRQ; bVarInString = false; bClassicVarInString = false; break; } if ( cCurrChar == '`' ) { styler.ColourTo(i-1, state ); state = SCE_CMAKE_STRINGLQ; bVarInString = false; bClassicVarInString = false; break; } // CMake Variable if ( cCurrChar == '$' || isCmakeChar(cCurrChar)) { styler.ColourTo(i-1,state); state = SCE_CMAKE_VARIABLE; // If it is a number, we must check and set style here first... if ( isCmakeNumber(cCurrChar) && (cNextChar == '\t' || cNextChar == ' ' || cNextChar == '\r' || cNextChar == '\n' ) ) styler.ColourTo( i, SCE_CMAKE_NUMBER); break; } break; case SCE_CMAKE_COMMENT: if ( cNextChar == '\n' || cNextChar == '\r' ) { // Special case: if ( cCurrChar == '\\' ) { styler.ColourTo(i-2,state); styler.ColourTo(i,SCE_CMAKE_DEFAULT); } else { styler.ColourTo(i,state); state = SCE_CMAKE_DEFAULT; } } break; case SCE_CMAKE_STRINGDQ: case SCE_CMAKE_STRINGLQ: case SCE_CMAKE_STRINGRQ: if ( styler.SafeGetCharAt(i-1) == '\\' && styler.SafeGetCharAt(i-2) == '$' ) break; // Ignore the next character, even if it is a quote of some sort if ( cCurrChar == '"' && state == SCE_CMAKE_STRINGDQ ) { styler.ColourTo(i,state); state = SCE_CMAKE_DEFAULT; break; } if ( cCurrChar == '`' && state == SCE_CMAKE_STRINGLQ ) { styler.ColourTo(i,state); state = SCE_CMAKE_DEFAULT; break; } if ( cCurrChar == '\'' && state == SCE_CMAKE_STRINGRQ ) { styler.ColourTo(i,state); state = SCE_CMAKE_DEFAULT; break; } if ( cNextChar == '\r' || cNextChar == '\n' ) { int nCurLine = styler.GetLine(i+1); int nBack = i; // We need to check if the previous line has a \ in it... bool bNextLine = false; while ( nBack > 0 ) { if ( styler.GetLine(nBack) != nCurLine ) break; char cTemp = styler.SafeGetCharAt(nBack, 'a'); // Letter 'a' is safe here if ( cTemp == '\\' ) { bNextLine = true; break; } if ( cTemp != '\r' && cTemp != '\n' && cTemp != '\t' && cTemp != ' ' ) break; nBack--; } if ( bNextLine ) { styler.ColourTo(i+1,state); } if ( bNextLine == false ) { styler.ColourTo(i,state); state = SCE_CMAKE_DEFAULT; } } break; case SCE_CMAKE_VARIABLE: // CMake Variable: if ( cCurrChar == '$' ) state = SCE_CMAKE_DEFAULT; else if ( cCurrChar == '\\' && (cNextChar == 'n' || cNextChar == 'r' || cNextChar == 't' ) ) state = SCE_CMAKE_DEFAULT; else if ( (isCmakeChar(cCurrChar) && !isCmakeChar( cNextChar) && cNextChar != '}') || cCurrChar == '}' ) { state = classifyWordCmake( styler.GetStartSegment(), i, keywordLists, styler ); styler.ColourTo( i, state); state = SCE_CMAKE_DEFAULT; } else if ( !isCmakeChar( cCurrChar ) && cCurrChar != '{' && cCurrChar != '}' ) { if ( classifyWordCmake( styler.GetStartSegment(), i-1, keywordLists, styler) == SCE_CMAKE_NUMBER ) styler.ColourTo( i-1, SCE_CMAKE_NUMBER ); state = SCE_CMAKE_DEFAULT; if ( cCurrChar == '"' ) { state = SCE_CMAKE_STRINGDQ; bVarInString = false; bClassicVarInString = false; } else if ( cCurrChar == '`' ) { state = SCE_CMAKE_STRINGLQ; bVarInString = false; bClassicVarInString = false; } else if ( cCurrChar == '\'' ) { state = SCE_CMAKE_STRINGRQ; bVarInString = false; bClassicVarInString = false; } else if ( cCurrChar == '#' ) { state = SCE_CMAKE_COMMENT; } } break; } if ( state == SCE_CMAKE_COMMENT) { styler.ColourTo(i,state); } else if ( state == SCE_CMAKE_STRINGDQ || state == SCE_CMAKE_STRINGLQ || state == SCE_CMAKE_STRINGRQ ) { bool bIngoreNextDollarSign = false; if ( bVarInString && cCurrChar == '$' ) { bVarInString = false; bIngoreNextDollarSign = true; } else if ( bVarInString && cCurrChar == '\\' && (cNextChar == 'n' || cNextChar == 'r' || cNextChar == 't' || cNextChar == '"' || cNextChar == '`' || cNextChar == '\'' ) ) { styler.ColourTo( i+1, SCE_CMAKE_STRINGVAR); bVarInString = false; bIngoreNextDollarSign = false; } else if ( bVarInString && !isCmakeChar(cNextChar) ) { int nWordState = classifyWordCmake( styler.GetStartSegment(), i, keywordLists, styler); if ( nWordState == SCE_CMAKE_VARIABLE ) styler.ColourTo( i, SCE_CMAKE_STRINGVAR); bVarInString = false; } // Covers "${TEST}..." else if ( bClassicVarInString && cNextChar == '}' ) { styler.ColourTo( i+1, SCE_CMAKE_STRINGVAR); bClassicVarInString = false; } // Start of var in string if ( !bIngoreNextDollarSign && cCurrChar == '$' && cNextChar == '{' ) { styler.ColourTo( i-1, state); bClassicVarInString = true; bVarInString = false; } else if ( !bIngoreNextDollarSign && cCurrChar == '$' ) { styler.ColourTo( i-1, state); bVarInString = true; bClassicVarInString = false; } } } // Colourise remaining document styler.ColourTo(nLengthDoc-1,state); } static void FoldCmakeDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { // No folding enabled, no reason to continue... if ( styler.GetPropertyInt("fold") == 0 ) return; bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) == 1; int lineCurrent = styler.GetLine(startPos); unsigned int safeStartPos = styler.LineStart( lineCurrent ); bool bArg1 = true; int nWordStart = -1; int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; int levelNext = levelCurrent; for (unsigned int i = safeStartPos; i < startPos + length; i++) { char chCurr = styler.SafeGetCharAt(i); if ( bArg1 ) { if ( nWordStart == -1 && (isCmakeLetter(chCurr)) ) { nWordStart = i; } else if ( isCmakeLetter(chCurr) == false && nWordStart > -1 ) { int newLevel = calculateFoldCmake( nWordStart, i-1, levelNext, styler, foldAtElse); if ( newLevel == levelNext ) { if ( foldAtElse ) { if ( CmakeNextLineHasElse(i, startPos + length, styler) ) levelNext--; } } else levelNext = newLevel; bArg1 = false; } } if ( chCurr == '\n' ) { if ( bArg1 && foldAtElse) { if ( CmakeNextLineHasElse(i, startPos + length, styler) ) levelNext--; } // If we are on a new line... int levelUse = levelCurrent; int lev = levelUse | levelNext << 16; if (levelUse < levelNext ) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) styler.SetLevel(lineCurrent, lev); lineCurrent++; levelCurrent = levelNext; bArg1 = true; // New line, lets look at first argument again nWordStart = -1; } } int levelUse = levelCurrent; int lev = levelUse | levelNext << 16; if (levelUse < levelNext) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) styler.SetLevel(lineCurrent, lev); } static const char * const cmakeWordLists[] = { "Commands", "Parameters", "UserDefined", 0, 0,}; LexerModule lmCmake(SCLEX_CMAKE, ColouriseCmakeDoc, "cmake", FoldCmakeDoc, cmakeWordLists); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexTeX.cxx000444001750001750 3413112021352777 24314 0ustar00azawawiazawawi000000000000// Scintilla source code edit control // File: LexTeX.cxx - general context conformant tex coloring scheme // Author: Hans Hagen - PRAGMA ADE - Hasselt NL - www.pragma-ade.com // Version: September 28, 2003 // Copyright: 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. // This lexer is derived from the one written for the texwork environment (1999++) which in // turn is inspired on texedit (1991++) which finds its roots in wdt (1986). // If you run into strange boundary cases, just tell me and I'll look into it. // TeX Folding code added by instanton (soft_share@126.com) with borrowed code from VisualTeX source by Alex Romanenko. // Version: June 22, 2007 #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif // val SCE_TEX_DEFAULT = 0 // val SCE_TEX_SPECIAL = 1 // val SCE_TEX_GROUP = 2 // val SCE_TEX_SYMBOL = 3 // val SCE_TEX_COMMAND = 4 // val SCE_TEX_TEXT = 5 // Definitions in SciTEGlobal.properties: // // TeX Highlighting // // # Default // style.tex.0=fore:#7F7F00 // # Special // style.tex.1=fore:#007F7F // # Group // style.tex.2=fore:#880000 // # Symbol // style.tex.3=fore:#7F7F00 // # Command // style.tex.4=fore:#008800 // # Text // style.tex.5=fore:#000000 // lexer.tex.interface.default=0 // lexer.tex.comment.process=0 // todo: lexer.tex.auto.if // Auxiliary functions: static inline bool endOfLine(Accessor &styler, unsigned int i) { return (styler[i] == '\n') || ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n')) ; } static inline bool isTeXzero(int ch) { return (ch == '%') ; } static inline bool isTeXone(int ch) { return (ch == '[') || (ch == ']') || (ch == '=') || (ch == '#') || (ch == '(') || (ch == ')') || (ch == '<') || (ch == '>') || (ch == '"') ; } static inline bool isTeXtwo(int ch) { return (ch == '{') || (ch == '}') || (ch == '$') ; } static inline bool isTeXthree(int ch) { return (ch == '~') || (ch == '^') || (ch == '_') || (ch == '&') || (ch == '-') || (ch == '+') || (ch == '\"') || (ch == '`') || (ch == '/') || (ch == '|') || (ch == '%') ; } static inline bool isTeXfour(int ch) { return (ch == '\\') ; } static inline bool isTeXfive(int ch) { return ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')) || (ch == '@') || (ch == '!') || (ch == '?') ; } static inline bool isTeXsix(int ch) { return (ch == ' ') ; } static inline bool isTeXseven(int ch) { return (ch == '^') ; } // Interface determination static int CheckTeXInterface( unsigned int startPos, int length, Accessor &styler, int defaultInterface) { char lineBuffer[1024] ; unsigned int linePos = 0 ; // some day we can make something lexer.tex.mapping=(all,0)(nl,1)(en,2)... if (styler.SafeGetCharAt(0) == '%') { for (unsigned int i = 0; i < startPos + length; i++) { lineBuffer[linePos++] = styler.SafeGetCharAt(i) ; if (endOfLine(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) { lineBuffer[linePos] = '\0'; if (strstr(lineBuffer, "interface=all")) { return 0 ; } else if (strstr(lineBuffer, "interface=tex")) { return 1 ; } else if (strstr(lineBuffer, "interface=nl")) { return 2 ; } else if (strstr(lineBuffer, "interface=en")) { return 3 ; } else if (strstr(lineBuffer, "interface=de")) { return 4 ; } else if (strstr(lineBuffer, "interface=cz")) { return 5 ; } else if (strstr(lineBuffer, "interface=it")) { return 6 ; } else if (strstr(lineBuffer, "interface=ro")) { return 7 ; } else if (strstr(lineBuffer, "interface=latex")) { // we will move latex cum suis up to 91+ when more keyword lists are supported return 8 ; } else if (styler.SafeGetCharAt(1) == 'D' && strstr(lineBuffer, "%D \\module")) { // better would be to limit the search to just one line return 3 ; } else { return defaultInterface ; } } } } return defaultInterface ; } static void ColouriseTeXDoc( unsigned int startPos, int length, int, WordList *keywordlists[], Accessor &styler) { styler.StartAt(startPos) ; styler.StartSegment(startPos) ; bool processComment = styler.GetPropertyInt("lexer.tex.comment.process", 0) == 1 ; bool useKeywords = styler.GetPropertyInt("lexer.tex.use.keywords", 1) == 1 ; bool autoIf = styler.GetPropertyInt("lexer.tex.auto.if", 1) == 1 ; int defaultInterface = styler.GetPropertyInt("lexer.tex.interface.default", 1) ; char key[100] ; int k ; bool newifDone = false ; bool inComment = false ; int currentInterface = CheckTeXInterface(startPos,length,styler,defaultInterface) ; if (currentInterface == 0) { useKeywords = false ; currentInterface = 1 ; } WordList &keywords = *keywordlists[currentInterface-1] ; StyleContext sc(startPos, length, SCE_TEX_TEXT, styler); bool going = sc.More() ; // needed because of a fuzzy end of file state for (; going; sc.Forward()) { if (! sc.More()) { going = false ; } // we need to go one behind the end of text if (inComment) { if (sc.atLineEnd) { sc.SetState(SCE_TEX_TEXT) ; newifDone = false ; inComment = false ; } } else { if (! isTeXfive(sc.ch)) { if (sc.state == SCE_TEX_COMMAND) { if (sc.LengthCurrent() == 1) { // \ if (isTeXseven(sc.ch) && isTeXseven(sc.chNext)) { sc.Forward(2) ; // \^^ and \^^ } sc.ForwardSetState(SCE_TEX_TEXT) ; } else { sc.GetCurrent(key, sizeof(key)-1) ; k = static_cast(strlen(key)) ; memmove(key,key+1,k) ; // shift left over escape token key[k] = '\0' ; k-- ; if (! keywords || ! useKeywords) { sc.SetState(SCE_TEX_COMMAND) ; newifDone = false ; } else if (k == 1) { //\ sc.SetState(SCE_TEX_COMMAND) ; newifDone = false ; } else if (keywords.InList(key)) { sc.SetState(SCE_TEX_COMMAND) ; newifDone = autoIf && (strcmp(key,"newif") == 0) ; } else if (autoIf && ! newifDone && (key[0] == 'i') && (key[1] == 'f') && keywords.InList("if")) { sc.SetState(SCE_TEX_COMMAND) ; } else { sc.ChangeState(SCE_TEX_TEXT) ; sc.SetState(SCE_TEX_TEXT) ; newifDone = false ; } } } if (isTeXzero(sc.ch)) { sc.SetState(SCE_TEX_SYMBOL); if (!endOfLine(styler,sc.currentPos + 1)) sc.ForwardSetState(SCE_TEX_DEFAULT) ; inComment = ! processComment ; newifDone = false ; } else if (isTeXseven(sc.ch) && isTeXseven(sc.chNext)) { sc.SetState(SCE_TEX_TEXT) ; sc.ForwardSetState(SCE_TEX_TEXT) ; } else if (isTeXone(sc.ch)) { sc.SetState(SCE_TEX_SPECIAL) ; newifDone = false ; } else if (isTeXtwo(sc.ch)) { sc.SetState(SCE_TEX_GROUP) ; newifDone = false ; } else if (isTeXthree(sc.ch)) { sc.SetState(SCE_TEX_SYMBOL) ; newifDone = false ; } else if (isTeXfour(sc.ch)) { sc.SetState(SCE_TEX_COMMAND) ; } else if (isTeXsix(sc.ch)) { sc.SetState(SCE_TEX_TEXT) ; } else if (sc.atLineEnd) { sc.SetState(SCE_TEX_TEXT) ; newifDone = false ; inComment = false ; } else { sc.SetState(SCE_TEX_TEXT) ; } } else if (sc.state != SCE_TEX_COMMAND) { sc.SetState(SCE_TEX_TEXT) ; } } } sc.ChangeState(SCE_TEX_TEXT) ; sc.Complete(); } static inline bool isNumber(int ch) { return (ch == '0') || (ch == '1') || (ch == '2') || (ch == '3') || (ch == '4') || (ch == '5') || (ch == '6') || (ch == '7') || (ch == '8') || (ch == '9'); } static inline bool isWordChar(int ch) { return ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')); } static int ParseTeXCommand(unsigned int pos, Accessor &styler, char *command) { int length=0; char ch=styler.SafeGetCharAt(pos+1); if(ch==',' || ch==':' || ch==';' || ch=='%'){ command[0]=ch; command[1]=0; return 1; } // find end while(isWordChar(ch) && !isNumber(ch) && ch!='_' && ch!='.' && length<100){ command[length]=ch; length++; ch=styler.SafeGetCharAt(pos+length+1); } command[length]='\0'; if(!length) return 0; return length+1; } static int classifyFoldPointTeXPaired(const char* s) { int lev=0; if (!(isdigit(s[0]) || (s[0] == '.'))){ if (strcmp(s, "begin")==0||strcmp(s,"FoldStart")==0|| strcmp(s,"abstract")==0||strcmp(s,"unprotect")==0|| strcmp(s,"title")==0||strncmp(s,"start",5)==0||strncmp(s,"Start",5)==0|| strcmp(s,"documentclass")==0||strncmp(s,"if",2)==0 ) lev=1; if (strcmp(s, "end")==0||strcmp(s,"FoldStop")==0|| strcmp(s,"maketitle")==0||strcmp(s,"protect")==0|| strncmp(s,"stop",4)==0||strncmp(s,"Stop",4)==0|| strcmp(s,"fi")==0 ) lev=-1; } return lev; } static int classifyFoldPointTeXUnpaired(const char* s) { int lev=0; if (!(isdigit(s[0]) || (s[0] == '.'))){ if (strcmp(s,"part")==0|| strcmp(s,"chapter")==0|| strcmp(s,"section")==0|| strcmp(s,"subsection")==0|| strcmp(s,"subsubsection")==0|| strcmp(s,"CJKfamily")==0|| strcmp(s,"appendix")==0|| strcmp(s,"Topic")==0||strcmp(s,"topic")==0|| strcmp(s,"subject")==0||strcmp(s,"subsubject")==0|| strcmp(s,"def")==0||strcmp(s,"gdef")==0||strcmp(s,"edef")==0|| strcmp(s,"xdef")==0||strcmp(s,"framed")==0|| strcmp(s,"frame")==0|| strcmp(s,"foilhead")==0||strcmp(s,"overlays")==0||strcmp(s,"slide")==0 ){ lev=1; } } return lev; } static bool IsTeXCommentLine(int line, Accessor &styler) { int pos = styler.LineStart(line); int eol_pos = styler.LineStart(line + 1) - 1; int startpos = pos; while (startpos SC_FOLDLEVELBASE && ((ch == '\r' || ch=='\n') && (chNext == '\\'))) { ParseTeXCommand(i+1, styler, buffer); levelCurrent -= classifyFoldPointTeXUnpaired(buffer); } char chNext2; char chNext3; char chNext4; char chNext5; chNext2=styler.SafeGetCharAt(i+2); chNext3=styler.SafeGetCharAt(i+3); chNext4=styler.SafeGetCharAt(i+4); chNext5=styler.SafeGetCharAt(i+5); bool atEOfold = (ch == '%') && (chNext == '%') && (chNext2=='}') && (chNext3=='}')&& (chNext4=='-')&& (chNext5=='-'); bool atBOfold = (ch == '%') && (chNext == '%') && (chNext2=='-') && (chNext3=='-')&& (chNext4=='{')&& (chNext5=='{'); if(atBOfold){ levelCurrent+=1; } if(atEOfold){ levelCurrent-=1; } if(ch=='\\' && chNext=='['){ levelCurrent+=1; } if(ch=='\\' && chNext==']'){ levelCurrent-=1; } bool foldComment = styler.GetPropertyInt("fold.comment") != 0; if (foldComment && atEOL && IsTeXCommentLine(lineCurrent, styler)) { if (lineCurrent==0 && IsTeXCommentLine(lineCurrent + 1, styler) ) levelCurrent++; else if (lineCurrent!=0 && !IsTeXCommentLine(lineCurrent - 1, styler) && IsTeXCommentLine(lineCurrent + 1, styler) ) levelCurrent++; else if (lineCurrent!=0 && IsTeXCommentLine(lineCurrent - 1, styler) && !IsTeXCommentLine(lineCurrent+1, styler)) levelCurrent--; } //--------------------------------------------------------------------------------------------- if (atEOL) { int lev = levelPrev; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if ((levelCurrent > levelPrev) && (visibleChars > 0)) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelPrev = levelCurrent; visibleChars = 0; } if (!isspacechar(ch)) visibleChars++; } // Fill in the real level of the next line, keeping the current flags as they will be filled in later int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, levelPrev | flagsNext); } static const char * const texWordListDesc[] = { "TeX, eTeX, pdfTeX, Omega", "ConTeXt Dutch", "ConTeXt English", "ConTeXt German", "ConTeXt Czech", "ConTeXt Italian", "ConTeXt Romanian", 0, } ; LexerModule lmTeX(SCLEX_TEX, ColouriseTeXDoc, "tex", FoldTexDoc, texWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexPython.cxx000444001750001750 4600712021352777 25102 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexPython.cxx ** Lexer for Python. **/ // Copyright 1998-2002 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif /* kwCDef, kwCTypeName only used for Cython */ enum kwType { kwOther, kwClass, kwDef, kwImport, kwCDef, kwCTypeName, kwCPDef }; static const int indicatorWhitespace = 1; static bool IsPyComment(Accessor &styler, int pos, int len) { return len > 0 && styler[pos] == '#'; } enum literalsAllowed { litNone=0, litU=1, litB=2}; static bool IsPyStringTypeChar(int ch, literalsAllowed allowed) { return ((allowed & litB) && (ch == 'b' || ch == 'B')) || ((allowed & litU) && (ch == 'u' || ch == 'U')); } static bool IsPyStringStart(int ch, int chNext, int chNext2, literalsAllowed allowed) { if (ch == '\'' || ch == '"') return true; if (IsPyStringTypeChar(ch, allowed)) { if (chNext == '"' || chNext == '\'') return true; if ((chNext == 'r' || chNext == 'R') && (chNext2 == '"' || chNext2 == '\'')) return true; } if ((ch == 'r' || ch == 'R') && (chNext == '"' || chNext == '\'')) return true; return false; } /* Return the state to use for the string starting at i; *nextIndex will be set to the first index following the quote(s) */ static int GetPyStringState(Accessor &styler, int i, unsigned int *nextIndex, literalsAllowed allowed) { char ch = styler.SafeGetCharAt(i); char chNext = styler.SafeGetCharAt(i + 1); // Advance beyond r, u, or ur prefix (or r, b, or br in Python 3.0), but bail if there are any unexpected chars if (ch == 'r' || ch == 'R') { i++; ch = styler.SafeGetCharAt(i); chNext = styler.SafeGetCharAt(i + 1); } else if (IsPyStringTypeChar(ch, allowed)) { if (chNext == 'r' || chNext == 'R') i += 2; else i += 1; ch = styler.SafeGetCharAt(i); chNext = styler.SafeGetCharAt(i + 1); } if (ch != '"' && ch != '\'') { *nextIndex = i + 1; return SCE_P_DEFAULT; } if (ch == chNext && ch == styler.SafeGetCharAt(i + 2)) { *nextIndex = i + 3; if (ch == '"') return SCE_P_TRIPLEDOUBLE; else return SCE_P_TRIPLE; } else { *nextIndex = i + 1; if (ch == '"') return SCE_P_STRING; else return SCE_P_CHARACTER; } } static inline bool IsAWordChar(int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_'); } static inline bool IsAWordStart(int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } static void ColourisePyDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { int endPos = startPos + length; // Backtrack to previous line in case need to fix its tab whinging int lineCurrent = styler.GetLine(startPos); if (startPos > 0) { if (lineCurrent > 0) { lineCurrent--; // Look for backslash-continued lines while (lineCurrent > 0) { int eolPos = styler.LineStart(lineCurrent) - 1; int eolStyle = styler.StyleAt(eolPos); if (eolStyle == SCE_P_STRING || eolStyle == SCE_P_CHARACTER || eolStyle == SCE_P_STRINGEOL) { lineCurrent -= 1; } else { break; } } startPos = styler.LineStart(lineCurrent); } initStyle = startPos == 0 ? SCE_P_DEFAULT : styler.StyleAt(startPos - 1); } WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; // property tab.timmy.whinge.level // For Python code, checks whether indenting is consistent. // The default, 0 turns off indentation checking, // 1 checks whether each line is potentially inconsistent with the previous line, // 2 checks whether any space characters occur before a tab character in the indentation, // 3 checks whether any spaces are in the indentation, and // 4 checks for any tab characters in the indentation. // 1 is a good level to use. const int whingeLevel = styler.GetPropertyInt("tab.timmy.whinge.level"); // property lexer.python.literals.binary // Set to 0 to not recognise Python 3 binary and octal literals: 0b1011 0o712. bool base2or8Literals = styler.GetPropertyInt("lexer.python.literals.binary", 1) != 0; // property lexer.python.strings.u // Set to 0 to not recognise Python Unicode literals u"x" as used before Python 3. literalsAllowed allowedLiterals = (styler.GetPropertyInt("lexer.python.strings.u", 1)) ? litU : litNone; // property lexer.python.strings.b // Set to 0 to not recognise Python 3 bytes literals b"x". if (styler.GetPropertyInt("lexer.python.strings.b", 1)) allowedLiterals = static_cast(allowedLiterals | litB); // property lexer.python.strings.over.newline // Set to 1 to allow strings to span newline characters. bool stringsOverNewline = styler.GetPropertyInt("lexer.python.strings.over.newline") != 0; // property lexer.python.keywords2.no.sub.identifiers // When enabled, it will not style keywords2 items that are used as a sub-identifier. // Example: when set, will not highlight "foo.open" when "open" is a keywords2 item. const bool keywords2NoSubIdentifiers = styler.GetPropertyInt("lexer.python.keywords2.no.sub.identifiers") != 0; initStyle = initStyle & 31; if (initStyle == SCE_P_STRINGEOL) { initStyle = SCE_P_DEFAULT; } kwType kwLast = kwOther; int spaceFlags = 0; styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment); bool base_n_number = false; StyleContext sc(startPos, endPos - startPos, initStyle, styler); bool indentGood = true; int startIndicator = sc.currentPos; bool inContinuedString = false; for (; sc.More(); sc.Forward()) { if (sc.atLineStart) { styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment); indentGood = true; if (whingeLevel == 1) { indentGood = (spaceFlags & wsInconsistent) == 0; } else if (whingeLevel == 2) { indentGood = (spaceFlags & wsSpaceTab) == 0; } else if (whingeLevel == 3) { indentGood = (spaceFlags & wsSpace) == 0; } else if (whingeLevel == 4) { indentGood = (spaceFlags & wsTab) == 0; } if (!indentGood) { styler.IndicatorFill(startIndicator, sc.currentPos, indicatorWhitespace, 0); startIndicator = sc.currentPos; } } if (sc.atLineEnd) { if ((sc.state == SCE_P_DEFAULT) || (sc.state == SCE_P_TRIPLE) || (sc.state == SCE_P_TRIPLEDOUBLE)) { // Perform colourisation of white space and triple quoted strings at end of each line to allow // tab marking to work inside white space and triple quoted strings sc.SetState(sc.state); } lineCurrent++; if ((sc.state == SCE_P_STRING) || (sc.state == SCE_P_CHARACTER)) { if (inContinuedString || stringsOverNewline) { inContinuedString = false; } else { sc.ChangeState(SCE_P_STRINGEOL); sc.ForwardSetState(SCE_P_DEFAULT); } } if (!sc.More()) break; } bool needEOLCheck = false; // Check for a state end if (sc.state == SCE_P_OPERATOR) { kwLast = kwOther; sc.SetState(SCE_P_DEFAULT); } else if (sc.state == SCE_P_NUMBER) { if (!IsAWordChar(sc.ch) && !(!base_n_number && ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) { sc.SetState(SCE_P_DEFAULT); } } else if (sc.state == SCE_P_IDENTIFIER) { if ((sc.ch == '.') || (!IsAWordChar(sc.ch))) { char s[100]; sc.GetCurrent(s, sizeof(s)); int style = SCE_P_IDENTIFIER; if ((kwLast == kwImport) && (strcmp(s, "as") == 0)) { style = SCE_P_WORD; } else if (keywords.InList(s)) { style = SCE_P_WORD; } else if (kwLast == kwClass) { style = SCE_P_CLASSNAME; } else if (kwLast == kwDef) { style = SCE_P_DEFNAME; } else if (kwLast == kwCDef || kwLast == kwCPDef) { int pos = sc.currentPos; unsigned char ch = styler.SafeGetCharAt(pos, '\0'); while (ch != '\0') { if (ch == '(') { style = SCE_P_DEFNAME; break; } else if (ch == ':') { style = SCE_P_CLASSNAME; break; } else if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') { pos++; ch = styler.SafeGetCharAt(pos, '\0'); } else { break; } } } else if (keywords2.InList(s)) { if (keywords2NoSubIdentifiers) { // We don't want to highlight keywords2 // that are used as a sub-identifier, // i.e. not open in "foo.open". int pos = styler.GetStartSegment() - 1; if (pos < 0 || (styler.SafeGetCharAt(pos, '\0') != '.')) style = SCE_P_WORD2; } else { style = SCE_P_WORD2; } } sc.ChangeState(style); sc.SetState(SCE_P_DEFAULT); if (style == SCE_P_WORD) { if (0 == strcmp(s, "class")) kwLast = kwClass; else if (0 == strcmp(s, "def")) kwLast = kwDef; else if (0 == strcmp(s, "import")) kwLast = kwImport; else if (0 == strcmp(s, "cdef")) kwLast = kwCDef; else if (0 == strcmp(s, "cpdef")) kwLast = kwCPDef; else if (0 == strcmp(s, "cimport")) kwLast = kwImport; else if (kwLast != kwCDef && kwLast != kwCPDef) kwLast = kwOther; } else if (kwLast != kwCDef && kwLast != kwCPDef) { kwLast = kwOther; } } } else if ((sc.state == SCE_P_COMMENTLINE) || (sc.state == SCE_P_COMMENTBLOCK)) { if (sc.ch == '\r' || sc.ch == '\n') { sc.SetState(SCE_P_DEFAULT); } } else if (sc.state == SCE_P_DECORATOR) { if (!IsAWordChar(sc.ch)) { sc.SetState(SCE_P_DEFAULT); } } else if ((sc.state == SCE_P_STRING) || (sc.state == SCE_P_CHARACTER)) { if (sc.ch == '\\') { if ((sc.chNext == '\r') && (sc.GetRelative(2) == '\n')) { sc.Forward(); } if (sc.chNext == '\n' || sc.chNext == '\r') { inContinuedString = true; } else { // Don't roll over the newline. sc.Forward(); } } else if ((sc.state == SCE_P_STRING) && (sc.ch == '\"')) { sc.ForwardSetState(SCE_P_DEFAULT); needEOLCheck = true; } else if ((sc.state == SCE_P_CHARACTER) && (sc.ch == '\'')) { sc.ForwardSetState(SCE_P_DEFAULT); needEOLCheck = true; } } else if (sc.state == SCE_P_TRIPLE) { if (sc.ch == '\\') { sc.Forward(); } else if (sc.Match("\'\'\'")) { sc.Forward(); sc.Forward(); sc.ForwardSetState(SCE_P_DEFAULT); needEOLCheck = true; } } else if (sc.state == SCE_P_TRIPLEDOUBLE) { if (sc.ch == '\\') { sc.Forward(); } else if (sc.Match("\"\"\"")) { sc.Forward(); sc.Forward(); sc.ForwardSetState(SCE_P_DEFAULT); needEOLCheck = true; } } if (!indentGood && !IsASpaceOrTab(sc.ch)) { styler.IndicatorFill(startIndicator, sc.currentPos, indicatorWhitespace, 1); startIndicator = sc.currentPos; indentGood = true; } // One cdef or cpdef line, clear kwLast only at end of line if ((kwLast == kwCDef || kwLast == kwCPDef) && sc.atLineEnd) { kwLast = kwOther; } // State exit code may have moved on to end of line if (needEOLCheck && sc.atLineEnd) { lineCurrent++; styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment); if (!sc.More()) break; } // Check for a new state starting character if (sc.state == SCE_P_DEFAULT) { if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { if (sc.ch == '0' && (sc.chNext == 'x' || sc.chNext == 'X')) { base_n_number = true; sc.SetState(SCE_P_NUMBER); } else if (sc.ch == '0' && (sc.chNext == 'o' || sc.chNext == 'O' || sc.chNext == 'b' || sc.chNext == 'B')) { if (base2or8Literals) { base_n_number = true; sc.SetState(SCE_P_NUMBER); } else { sc.SetState(SCE_P_NUMBER); sc.ForwardSetState(SCE_P_IDENTIFIER); } } else { base_n_number = false; sc.SetState(SCE_P_NUMBER); } } else if ((isascii(sc.ch) && isoperator(static_cast(sc.ch))) || sc.ch == '`') { sc.SetState(SCE_P_OPERATOR); } else if (sc.ch == '#') { sc.SetState(sc.chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE); } else if (sc.ch == '@') { sc.SetState(SCE_P_DECORATOR); } else if (IsPyStringStart(sc.ch, sc.chNext, sc.GetRelative(2), allowedLiterals)) { unsigned int nextIndex = 0; sc.SetState(GetPyStringState(styler, sc.currentPos, &nextIndex, allowedLiterals)); while (nextIndex > (sc.currentPos + 1) && sc.More()) { sc.Forward(); } } else if (IsAWordStart(sc.ch)) { sc.SetState(SCE_P_IDENTIFIER); } } } styler.IndicatorFill(startIndicator, sc.currentPos, indicatorWhitespace, 0); sc.Complete(); } static bool IsCommentLine(int line, Accessor &styler) { int pos = styler.LineStart(line); int eol_pos = styler.LineStart(line + 1) - 1; for (int i = pos; i < eol_pos; i++) { char ch = styler[i]; if (ch == '#') return true; else if (ch != ' ' && ch != '\t') return false; } return false; } static bool IsQuoteLine(int line, Accessor &styler) { int style = styler.StyleAt(styler.LineStart(line)) & 31; return ((style == SCE_P_TRIPLE) || (style == SCE_P_TRIPLEDOUBLE)); } static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unused*/, WordList *[], Accessor &styler) { const int maxPos = startPos + length; const int maxLines = (maxPos == styler.Length()) ? styler.GetLine(maxPos) : styler.GetLine(maxPos - 1); // Requested last line const int docLines = styler.GetLine(styler.Length()); // Available last line // property fold.quotes.python // This option enables folding multi-line quoted strings when using the Python lexer. const bool foldQuotes = styler.GetPropertyInt("fold.quotes.python") != 0; const bool foldCompact = styler.GetPropertyInt("fold.compact") != 0; // Backtrack to previous non-blank line so we can determine indent level // for any white space lines (needed esp. within triple quoted strings) // and so we can fix any preceding fold level (which is why we go back // at least one line in all cases) int spaceFlags = 0; int lineCurrent = styler.GetLine(startPos); int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL); while (lineCurrent > 0) { lineCurrent--; indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL); if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG) && (!IsCommentLine(lineCurrent, styler)) && (!IsQuoteLine(lineCurrent, styler))) break; } int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK; // Set up initial loop state startPos = styler.LineStart(lineCurrent); int prev_state = SCE_P_DEFAULT & 31; if (lineCurrent >= 1) prev_state = styler.StyleAt(startPos - 1) & 31; int prevQuote = foldQuotes && ((prev_state == SCE_P_TRIPLE) || (prev_state == SCE_P_TRIPLEDOUBLE)); // Process all characters to end of requested range or end of any triple quote //that hangs over the end of the range. Cap processing in all cases // to end of document (in case of unclosed quote at end). while ((lineCurrent <= docLines) && ((lineCurrent <= maxLines) || prevQuote)) { // Gather info int lev = indentCurrent; int lineNext = lineCurrent + 1; int indentNext = indentCurrent; int quote = false; if (lineNext <= docLines) { // Information about next line is only available if not at end of document indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL); int lookAtPos = (styler.LineStart(lineNext) == styler.Length()) ? styler.Length() - 1 : styler.LineStart(lineNext); int style = styler.StyleAt(lookAtPos) & 31; quote = foldQuotes && ((style == SCE_P_TRIPLE) || (style == SCE_P_TRIPLEDOUBLE)); } const int quote_start = (quote && !prevQuote); const int quote_continue = (quote && prevQuote); if (!quote || !prevQuote) indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK; if (quote) indentNext = indentCurrentLevel; if (indentNext & SC_FOLDLEVELWHITEFLAG) indentNext = SC_FOLDLEVELWHITEFLAG | indentCurrentLevel; if (quote_start) { // Place fold point at start of triple quoted string lev |= SC_FOLDLEVELHEADERFLAG; } else if (quote_continue || prevQuote) { // Add level to rest of lines in the string lev = lev + 1; } // Skip past any blank lines for next indent level info; we skip also // comments (all comments, not just those starting in column 0) // which effectively folds them into surrounding code rather // than screwing up folding. while (!quote && (lineNext < docLines) && ((indentNext & SC_FOLDLEVELWHITEFLAG) || (lineNext <= docLines && IsCommentLine(lineNext, styler)))) { lineNext++; indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL); } const int levelAfterComments = indentNext & SC_FOLDLEVELNUMBERMASK; const int levelBeforeComments = Maximum(indentCurrentLevel,levelAfterComments); // Now set all the indent levels on the lines we skipped // Do this from end to start. Once we encounter one line // which is indented more than the line after the end of // the comment-block, use the level of the block before int skipLine = lineNext; int skipLevel = levelAfterComments; while (--skipLine > lineCurrent) { int skipLineIndent = styler.IndentAmount(skipLine, &spaceFlags, NULL); if (foldCompact) { if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > levelAfterComments) skipLevel = levelBeforeComments; int whiteFlag = skipLineIndent & SC_FOLDLEVELWHITEFLAG; styler.SetLevel(skipLine, skipLevel | whiteFlag); } else { if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > levelAfterComments && !(skipLineIndent & SC_FOLDLEVELWHITEFLAG) && !IsCommentLine(skipLine, styler)) skipLevel = levelBeforeComments; styler.SetLevel(skipLine, skipLevel); } } // Set fold header on non-quote line if (!quote && !(indentCurrent & SC_FOLDLEVELWHITEFLAG)) { if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) lev |= SC_FOLDLEVELHEADERFLAG; } // Keep track of triple quote state of previous line prevQuote = quote; // Set fold level for this line and move to next line styler.SetLevel(lineCurrent, foldCompact ? lev : lev & ~SC_FOLDLEVELWHITEFLAG); indentCurrent = indentNext; lineCurrent = lineNext; } // NOTE: Cannot set level of last line here because indentCurrent doesn't have // header flag set; the loop above is crafted to take care of this case! //styler.SetLevel(lineCurrent, indentCurrent); } static const char *const pythonWordListDesc[] = { "Keywords", "Highlighted identifiers", 0 }; LexerModule lmPython(SCLEX_PYTHON, ColourisePyDoc, "python", FoldPyDoc, pythonWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/FontQuality.h000444001750001750 106012021352777 25022 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file FontQuality.h ** Definitions to control font anti-aliasing. **/ // Copyright 1998-2009 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #define SC_EFF_QUALITY_MASK 0xF #define SC_EFF_QUALITY_DEFAULT 0 #define SC_EFF_QUALITY_NON_ANTIALIASED 1 #define SC_EFF_QUALITY_ANTIALIASED 2 #define SC_EFF_QUALITY_LCD_OPTIMIZED 3 #define SCWIN_TECH_GDI 0 #define SCWIN_TECH_DIRECTWRITE 1 Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/UniConversion.cxx000444001750001750 733612021352777 25733 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file UniConversion.cxx ** Functions to handle UTF-8 and UTF-16 strings. **/ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include "UniConversion.h" enum { SURROGATE_LEAD_FIRST = 0xD800 }; enum { SURROGATE_TRAIL_FIRST = 0xDC00 }; enum { SURROGATE_TRAIL_LAST = 0xDFFF }; unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) { unsigned int len = 0; for (unsigned int i = 0; i < tlen && uptr[i];) { unsigned int uch = uptr[i]; if (uch < 0x80) { len++; } else if (uch < 0x800) { len += 2; } else if ((uch >= SURROGATE_LEAD_FIRST) && (uch <= SURROGATE_TRAIL_LAST)) { len += 4; i++; } else { len += 3; } i++; } return len; } void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len) { int k = 0; for (unsigned int i = 0; i < tlen && uptr[i];) { unsigned int uch = uptr[i]; if (uch < 0x80) { putf[k++] = static_cast(uch); } else if (uch < 0x800) { putf[k++] = static_cast(0xC0 | (uch >> 6)); putf[k++] = static_cast(0x80 | (uch & 0x3f)); } else if ((uch >= SURROGATE_LEAD_FIRST) && (uch <= SURROGATE_TRAIL_LAST)) { // Half a surrogate pair i++; unsigned int xch = 0x10000 + ((uch & 0x3ff) << 10) + (uptr[i] & 0x3ff); putf[k++] = static_cast(0xF0 | (xch >> 18)); putf[k++] = static_cast(0x80 | ((xch >> 12) & 0x3f)); putf[k++] = static_cast(0x80 | ((xch >> 6) & 0x3f)); putf[k++] = static_cast(0x80 | (xch & 0x3f)); } else { putf[k++] = static_cast(0xE0 | (uch >> 12)); putf[k++] = static_cast(0x80 | ((uch >> 6) & 0x3f)); putf[k++] = static_cast(0x80 | (uch & 0x3f)); } i++; } putf[len] = '\0'; } unsigned int UTF8CharLength(unsigned char ch) { if (ch < 0x80) { return 1; } else if (ch < 0x80 + 0x40 + 0x20) { return 2; } else if (ch < 0x80 + 0x40 + 0x20 + 0x10) { return 3; } else { return 4; } } unsigned int UTF16Length(const char *s, unsigned int len) { unsigned int ulen = 0; unsigned int charLen; for (unsigned int i=0; i(s[i]); if (ch < 0x80) { charLen = 1; } else if (ch < 0x80 + 0x40 + 0x20) { charLen = 2; } else if (ch < 0x80 + 0x40 + 0x20 + 0x10) { charLen = 3; } else { charLen = 4; ulen++; } i += charLen; ulen++; } return ulen; } unsigned int UTF16FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen) { unsigned int ui=0; const unsigned char *us = reinterpret_cast(s); unsigned int i=0; while ((i((ch & 0x1F) << 6); ch = us[i++]; tbuf[ui] = static_cast(tbuf[ui] + (ch & 0x7F)); } else if (ch < 0x80 + 0x40 + 0x20 + 0x10) { tbuf[ui] = static_cast((ch & 0xF) << 12); ch = us[i++]; tbuf[ui] = static_cast(tbuf[ui] + ((ch & 0x7F) << 6)); ch = us[i++]; tbuf[ui] = static_cast(tbuf[ui] + (ch & 0x7F)); } else { // Outside the BMP so need two surrogates int val = (ch & 0x7) << 18; ch = us[i++]; val += (ch & 0x3F) << 12; ch = us[i++]; val += (ch & 0x3F) << 6; ch = us[i++]; val += (ch & 0x3F); tbuf[ui] = static_cast(((val - 0x10000) >> 10) + SURROGATE_LEAD_FIRST); ui++; tbuf[ui] = static_cast((val & 0x3ff) + SURROGATE_TRAIL_FIRST); } ui++; } return ui; } Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexProgress.cxx000444001750001750 2224412021352777 25422 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexProgress.cxx ** Lexer for Progress 4GL. ** Based on LexCPP.cxx of Neil Hodgson **/ // Copyright 2006-2007 by Yuval Papish // The License.txt file describes the conditions under which this software may be distributed. /** TODO: WebSpeed support in html lexer Support "end triggers" expression of the triggers phrase Support more than 6 comments levels **/ #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static inline bool IsAWordChar(int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } static inline bool IsAWordStart(int ch) { return (ch < 0x80) && (isalpha(ch) || ch == '_'); } enum SentenceStart { SetSentenceStart = 0xf, ResetSentenceStart = 0x10}; // true -> bit = 0 static void Colourise4glDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords1 = *keywordlists[0]; // regular keywords WordList &keywords2 = *keywordlists[1]; // block opening keywords, only when SentenceStart WordList &keywords3 = *keywordlists[2]; // block opening keywords //WordList &keywords4 = *keywordlists[3]; // preprocessor keywords. Not implemented int visibleChars = 0; int mask; StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { if (sc.atLineStart) { // Reset states to begining of colourise so no surprises // if different sets of lines lexed. visibleChars = 0; } // Handle line continuation generically. if ((sc.state & 0xf) < SCE_4GL_COMMENT1) { if (sc.ch == '~') { if (sc.chNext > ' ') { // skip special char after ~ sc.Forward(); continue; } else { // Skip whitespace between ~ and EOL while (sc.More() && (sc.chNext == ' ' || sc.chNext == '\t') ) { sc.Forward(); } if (sc.chNext == '\n' || sc.chNext == '\r') { sc.Forward(); if (sc.ch == '\r' && sc.chNext == '\n') { sc.Forward(); } sc.Forward(); continue; } } } } // Determine if a new state should be terminated. mask = sc.state & 0x10; switch (sc.state & 0xf) { case SCE_4GL_OPERATOR: sc.SetState(SCE_4GL_DEFAULT | mask); break; case SCE_4GL_NUMBER: if (!(IsADigit(sc.ch))) { sc.SetState(SCE_4GL_DEFAULT | mask); } break; case SCE_4GL_IDENTIFIER: if (!IsAWordChar(sc.ch) && sc.ch != '-') { char s[1000]; sc.GetCurrentLowered(s, sizeof(s)); if ((((sc.state & 0x10) == 0) && keywords2.InList(s)) || keywords3.InList(s)) { sc.ChangeState(SCE_4GL_BLOCK | ResetSentenceStart); } else if (keywords1.InList(s)) { if ((s[0] == 'e' && s[1] =='n' && s[2] == 'd' && !isalnum(s[3]) && s[3] != '-') || (s[0] == 'f' && s[1] =='o' && s[2] == 'r' && s[3] == 'w' && s[4] =='a' && s[5] == 'r' && s[6] == 'd'&& !isalnum(s[7]))) { sc.ChangeState(SCE_4GL_END | ResetSentenceStart); } else if ((s[0] == 'e' && s[1] =='l' && s[2] == 's' && s[3] == 'e') || (s[0] == 't' && s[1] =='h' && s[2] == 'e' && s[3] == 'n')) { sc.ChangeState(SCE_4GL_WORD & SetSentenceStart); } else { sc.ChangeState(SCE_4GL_WORD | ResetSentenceStart); } } sc.SetState(SCE_4GL_DEFAULT | (sc.state & 0x10)); } break; case SCE_4GL_PREPROCESSOR: if (sc.atLineStart) { sc.SetState(SCE_4GL_DEFAULT & SetSentenceStart); } /* code removed to allow comments inside preprocessor else if (sc.ch == '*' && sc.chNext == '/') { sc.ForwardSetState(SCE_4GL_DEFAULT | sentenceStartState); } */ break; case SCE_4GL_STRING: if (sc.ch == '\"') { sc.ForwardSetState(SCE_4GL_DEFAULT | mask); } break; case SCE_4GL_CHARACTER: if (sc.ch == '\'') { sc.ForwardSetState(SCE_4GL_DEFAULT | mask); } break; default: if ((sc.state & 0xf) >= SCE_4GL_COMMENT1) { if (sc.ch == '*' && sc.chNext == '/') { sc.Forward(); if ((sc.state & 0xf) == SCE_4GL_COMMENT1) { sc.ForwardSetState(SCE_4GL_DEFAULT | mask); } else sc.SetState((sc.state & 0x1f) - 1); } else if (sc.ch == '/' && sc.chNext == '*') { sc.Forward(); sc.SetState((sc.state & 0x1f) + 1); } } } // Determine if a new state should be entered. mask = sc.state & 0x10; if ((sc.state & 0xf) == SCE_4GL_DEFAULT) { if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_4GL_NUMBER | ResetSentenceStart); } else if (IsAWordStart(sc.ch) || (sc.ch == '@')) { sc.SetState(SCE_4GL_IDENTIFIER | mask); } else if (sc.ch == '/' && sc.chNext == '*') { sc.SetState(SCE_4GL_COMMENT1 | mask); sc.Forward(); } else if (sc.ch == '\"') { sc.SetState(SCE_4GL_STRING | ResetSentenceStart); } else if (sc.ch == '\'') { sc.SetState(SCE_4GL_CHARACTER | ResetSentenceStart); } else if (sc.ch == '&' && visibleChars == 0 && ((sc.state & 0x10) == 0)) { sc.SetState(SCE_4GL_PREPROCESSOR | ResetSentenceStart); // Skip whitespace between & and preprocessor word do { sc.Forward(); } while ((sc.ch == ' ' || sc.ch == '\t') && sc.More()); // Handle syntactical line termination } else if ((sc.ch == '.' || sc.ch == ':' || sc.ch == '}') && (sc.chNext == ' ' || sc.chNext == '\t' || sc.chNext == '\n' || sc.chNext == '\r')) { sc.SetState(sc.state & SetSentenceStart); } else if (isoperator(static_cast(sc.ch))) { /* This code allows highlight of handles. Alas, it would cause the phrase "last-event:function" to be recognized as a BlockBegin */ if (sc.ch == ':') sc.SetState(SCE_4GL_OPERATOR & SetSentenceStart); /* else */ sc.SetState(SCE_4GL_OPERATOR | ResetSentenceStart); } } if (!IsASpace(sc.ch)) { visibleChars++; } } sc.Complete(); } static bool IsStreamCommentStyle(int style) { return (style & 0xf) >= SCE_4GL_COMMENT1 ; } // Store both the current line's fold level and the next lines in the // level store to make it easy to pick up with each increment // and to make it possible to fiddle the current level for "} else {". static void FoldNoBox4glDoc(unsigned int startPos, int length, int initStyle, Accessor &styler) { bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0; unsigned int endPos = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; int levelMinCurrent = levelCurrent; int levelNext = levelCurrent; char chNext = static_cast(tolower(styler[startPos])); int styleNext = styler.StyleAt(startPos); int style = initStyle; for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = static_cast(tolower(styler.SafeGetCharAt(i + 1))); int stylePrev = style; style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (foldComment && IsStreamCommentStyle(style)) { if (!IsStreamCommentStyle(stylePrev)) { levelNext++; } else if (!IsStreamCommentStyle(styleNext)) { // && !atEOL) { // Comments don't end at end of line and the next character may be unstyled. levelNext--; } } else if ((style & 0xf) == SCE_4GL_BLOCK && !isalnum(chNext)) { levelNext++; } else if ((style & 0xf) == SCE_4GL_END && (ch == 'e' || ch == 'f')) { levelNext--; } if (atEOL) { int levelUse = levelCurrent; if (foldAtElse) { levelUse = levelMinCurrent; } int lev = levelUse | levelNext << 16; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if (levelUse < levelNext) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelCurrent = levelNext; levelMinCurrent = levelCurrent; visibleChars = 0; } if (!isspacechar(ch)) visibleChars++; } } static void Fold4glDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { FoldNoBox4glDoc(startPos, length, initStyle, styler); } static const char * const FglWordLists[] = { "Primary keywords and identifiers", "Secondary keywords and identifiers", "Documentation comment keywords", "Unused", "Global classes and typedefs", 0, }; LexerModule lmProgress(SCLEX_PROGRESS, Colourise4glDoc, "progress", Fold4glDoc, FglWordLists); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/RESearch.h000444001750001750 325512021352777 24207 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file RESearch.h ** Interface to the regular expression search library. **/ // Written by Neil Hodgson // Based on the work of Ozan S. Yigit. // This file is in the public domain. #ifndef RESEARCH_H #define RESEARCH_H #ifdef SCI_NAMESPACE namespace Scintilla { #endif /* * The following defines are not meant to be changeable. * They are for readability only. */ #define MAXCHR 256 #define CHRBIT 8 #define BITBLK MAXCHR/CHRBIT class CharacterIndexer { public: virtual char CharAt(int index)=0; virtual ~CharacterIndexer() { } }; class RESearch { public: RESearch(CharClassify *charClassTable); ~RESearch(); bool GrabMatches(CharacterIndexer &ci); const char *Compile(const char *pattern, int length, bool caseSensitive, bool posix); int Execute(CharacterIndexer &ci, int lp, int endp); int Substitute(CharacterIndexer &ci, char *src, char *dst); enum { MAXTAG=10 }; enum { MAXNFA=2048 }; enum { NOTFOUND=-1 }; int bopat[MAXTAG]; int eopat[MAXTAG]; char *pat[MAXTAG]; private: void Init(); void Clear(); void ChSet(unsigned char c); void ChSetWithCase(unsigned char c, bool caseSensitive); int GetBackslashExpression(const char *pattern, int &incr); int PMatch(CharacterIndexer &ci, int lp, int endp, char *ap); int bol; int tagstk[MAXTAG]; /* subpat tag stack */ char nfa[MAXNFA]; /* automaton */ int sta; unsigned char bittab[BITBLK]; /* bit table for CCL pre-set bits */ int failure; CharClassify *charClass; bool iswordc(unsigned char x) { return charClass->IsWord(x); } }; #ifdef SCI_NAMESPACE } #endif #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/Selection.h000444001750001750 1236512021352777 24522 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file Selection.h ** Classes maintaining the selection. **/ // Copyright 2009 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef SELECTION_H #define SELECTION_H #ifdef SCI_NAMESPACE namespace Scintilla { #endif class SelectionPosition { int position; int virtualSpace; public: explicit SelectionPosition(int position_=INVALID_POSITION, int virtualSpace_=0) : position(position_), virtualSpace(virtualSpace_) { PLATFORM_ASSERT(virtualSpace < 800000); if (virtualSpace < 0) virtualSpace = 0; } void Reset() { position = 0; virtualSpace = 0; } void MoveForInsertDelete(bool insertion, int startChange, int length); bool operator ==(const SelectionPosition &other) const { return position == other.position && virtualSpace == other.virtualSpace; } bool operator <(const SelectionPosition &other) const; bool operator >(const SelectionPosition &other) const; bool operator <=(const SelectionPosition &other) const; bool operator >=(const SelectionPosition &other) const; int Position() const { return position; } void SetPosition(int position_) { position = position_; virtualSpace = 0; } int VirtualSpace() const { return virtualSpace; } void SetVirtualSpace(int virtualSpace_) { PLATFORM_ASSERT(virtualSpace_ < 800000); if (virtualSpace_ >= 0) virtualSpace = virtualSpace_; } void Add(int increment) { position = position + increment; } bool IsValid() const { return position >= 0; } }; // Ordered range to make drawing simpler struct SelectionSegment { SelectionPosition start; SelectionPosition end; SelectionSegment() : start(), end() { } SelectionSegment(SelectionPosition a, SelectionPosition b) { if (a < b) { start = a; end = b; } else { start = b; end = a; } } bool Empty() const { return start == end; } void Extend(SelectionPosition p) { if (start > p) start = p; if (end < p) end = p; } }; struct SelectionRange { SelectionPosition caret; SelectionPosition anchor; SelectionRange() : caret(), anchor() { } SelectionRange(SelectionPosition single) : caret(single), anchor(single) { } SelectionRange(int single) : caret(single), anchor(single) { } SelectionRange(SelectionPosition caret_, SelectionPosition anchor_) : caret(caret_), anchor(anchor_) { } SelectionRange(int caret_, int anchor_) : caret(caret_), anchor(anchor_) { } bool Empty() const { return anchor == caret; } int Length() const; // int Width() const; // Like Length but takes virtual space into account bool operator ==(const SelectionRange &other) const { return caret == other.caret && anchor == other.anchor; } bool operator <(const SelectionRange &other) const { return caret < other.caret || ((caret == other.caret) && (anchor < other.anchor)); } void Reset() { anchor.Reset(); caret.Reset(); } void ClearVirtualSpace() { anchor.SetVirtualSpace(0); caret.SetVirtualSpace(0); } bool Contains(int pos) const; bool Contains(SelectionPosition sp) const; bool ContainsCharacter(int posCharacter) const; SelectionSegment Intersect(SelectionSegment check) const; SelectionPosition Start() const { return (anchor < caret) ? anchor : caret; } SelectionPosition End() const { return (anchor < caret) ? caret : anchor; } bool Trim(SelectionRange range); // If range is all virtual collapse to start of virtual space void MinimizeVirtualSpace(); }; class Selection { std::vector ranges; std::vector rangesSaved; SelectionRange rangeRectangular; size_t mainRange; bool moveExtends; bool tentativeMain; public: enum selTypes { noSel, selStream, selRectangle, selLines, selThin }; selTypes selType; Selection(); ~Selection(); bool IsRectangular() const; int MainCaret() const; int MainAnchor() const; SelectionRange &Rectangular(); SelectionSegment Limits() const; // This is for when you want to move the caret in response to a // user direction command - for rectangular selections, use the range // that covers all selected text otherwise return the main selection. SelectionSegment LimitsForRectangularElseMain() const; size_t Count() const; size_t Main() const; void SetMain(size_t r); SelectionRange &Range(size_t r); SelectionRange &RangeMain(); bool MoveExtends() const; void SetMoveExtends(bool moveExtends_); bool Empty() const; SelectionPosition Last() const; int Length() const; void MovePositions(bool insertion, int startChange, int length); void TrimSelection(SelectionRange range); void SetSelection(SelectionRange range); void AddSelection(SelectionRange range); void AddSelectionWithoutTrim(SelectionRange range); void TentativeSelection(SelectionRange range); void CommitTentative(); int CharacterInSelection(int posCharacter) const; int InSelectionForEOL(int pos) const; int VirtualSpaceFor(int pos) const; void Clear(); void RemoveDuplicates(); void RotateMain(); bool Tentative() const { return tentativeMain; } std::vector RangesCopy() const { return ranges; } }; #ifdef SCI_NAMESPACE } #endif #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/KeyMap.h000444001750001750 203412021352777 23733 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file KeyMap.h ** Defines a mapping between keystrokes and commands. **/ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef KEYTOCOMMAND_H #define KEYTOCOMMAND_H #ifdef SCI_NAMESPACE namespace Scintilla { #endif #define SCI_NORM 0 #define SCI_SHIFT SCMOD_SHIFT #define SCI_CTRL SCMOD_CTRL #define SCI_ALT SCMOD_ALT #define SCI_META SCMOD_META #define SCI_CSHIFT (SCI_CTRL | SCI_SHIFT) #define SCI_ASHIFT (SCI_ALT | SCI_SHIFT) /** */ class KeyToCommand { public: int key; int modifiers; unsigned int msg; }; /** */ class KeyMap { KeyToCommand *kmap; int len; int alloc; static const KeyToCommand MapDefault[]; public: KeyMap(); ~KeyMap(); void Clear(); void AssignCmdKey(int key, int modifiers, unsigned int msg); unsigned int Find(int key, int modifiers); // 0 returned on failure }; #ifdef SCI_NAMESPACE } #endif #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexErlang.cxx000444001750001750 4116512021352777 25031 0ustar00azawawiazawawi000000000000// Scintilla source code edit control // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. /** @file LexErlang.cxx ** Lexer for Erlang. ** Enhanced by Etienne 'Lenain' Girondel (lenaing@gmail.com) ** Originally wrote by Peter-Henry Mander, ** based on Matlab lexer by José Fonseca. **/ #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static int is_radix(int radix, int ch) { int digit; if (36 < radix || 2 > radix) return 0; if (isdigit(ch)) { digit = ch - '0'; } else if (isalnum(ch)) { digit = toupper(ch) - 'A' + 10; } else { return 0; } return (digit < radix); } typedef enum { STATE_NULL, COMMENT, COMMENT_FUNCTION, COMMENT_MODULE, COMMENT_DOC, COMMENT_DOC_MACRO, ATOM_UNQUOTED, ATOM_QUOTED, NODE_NAME_UNQUOTED, NODE_NAME_QUOTED, MACRO_START, MACRO_UNQUOTED, MACRO_QUOTED, RECORD_START, RECORD_UNQUOTED, RECORD_QUOTED, NUMERAL_START, NUMERAL_BASE_VALUE, NUMERAL_FLOAT, NUMERAL_EXPONENT, PREPROCESSOR } atom_parse_state_t; static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (ch != ' ') && (isalnum(ch) || ch == '_'); } static void ColouriseErlangDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { StyleContext sc(startPos, length, initStyle, styler); WordList &reservedWords = *keywordlists[0]; WordList &erlangBIFs = *keywordlists[1]; WordList &erlangPreproc = *keywordlists[2]; WordList &erlangModulesAtt = *keywordlists[3]; WordList &erlangDoc = *keywordlists[4]; WordList &erlangDocMacro = *keywordlists[5]; int radix_digits = 0; int exponent_digits = 0; atom_parse_state_t parse_state = STATE_NULL; atom_parse_state_t old_parse_state = STATE_NULL; bool to_late_to_comment = false; char cur[100]; int old_style = SCE_ERLANG_DEFAULT; styler.StartAt(startPos); for (; sc.More(); sc.Forward()) { int style = SCE_ERLANG_DEFAULT; if (STATE_NULL != parse_state) { switch (parse_state) { case STATE_NULL : sc.SetState(SCE_ERLANG_DEFAULT); break; /* COMMENTS ------------------------------------------------------*/ case COMMENT : { if (sc.ch != '%') { to_late_to_comment = true; } else if (!to_late_to_comment && sc.ch == '%') { // Switch to comment level 2 (Function) sc.ChangeState(SCE_ERLANG_COMMENT_FUNCTION); old_style = SCE_ERLANG_COMMENT_FUNCTION; parse_state = COMMENT_FUNCTION; sc.Forward(); } } // V--- Falling through! case COMMENT_FUNCTION : { if (sc.ch != '%') { to_late_to_comment = true; } else if (!to_late_to_comment && sc.ch == '%') { // Switch to comment level 3 (Module) sc.ChangeState(SCE_ERLANG_COMMENT_MODULE); old_style = SCE_ERLANG_COMMENT_MODULE; parse_state = COMMENT_MODULE; sc.Forward(); } } // V--- Falling through! case COMMENT_MODULE : { if (parse_state != COMMENT) { // Search for comment documentation if (sc.chNext == '@') { old_parse_state = parse_state; parse_state = ('{' == sc.ch) ? COMMENT_DOC_MACRO : COMMENT_DOC; sc.ForwardSetState(sc.state); } } // All comments types fall here. if (sc.atLineEnd) { to_late_to_comment = false; sc.SetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } } break; case COMMENT_DOC : // V--- Falling through! case COMMENT_DOC_MACRO : { if (!isalnum(sc.ch)) { // Try to match documentation comment sc.GetCurrent(cur, sizeof(cur)); if (parse_state == COMMENT_DOC_MACRO && erlangDocMacro.InList(cur)) { sc.ChangeState(SCE_ERLANG_COMMENT_DOC_MACRO); while (sc.ch != '}' && !sc.atLineEnd) sc.Forward(); } else if (erlangDoc.InList(cur)) { sc.ChangeState(SCE_ERLANG_COMMENT_DOC); } else { sc.ChangeState(old_style); } // Switch back to old state sc.SetState(old_style); parse_state = old_parse_state; } if (sc.atLineEnd) { to_late_to_comment = false; sc.ChangeState(old_style); sc.SetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } } break; /* -------------------------------------------------------------- */ /* Atoms ---------------------------------------------------------*/ case ATOM_UNQUOTED : { if ('@' == sc.ch){ parse_state = NODE_NAME_UNQUOTED; } else if (sc.ch == ':') { // Searching for module name if (sc.chNext == ' ') { // error sc.ChangeState(SCE_ERLANG_UNKNOWN); parse_state = STATE_NULL; } else { sc.Forward(); if (isalnum(sc.ch)) { sc.GetCurrent(cur, sizeof(cur)); sc.ChangeState(SCE_ERLANG_MODULES); sc.SetState(SCE_ERLANG_MODULES); } } } else if (!IsAWordChar(sc.ch)) { sc.GetCurrent(cur, sizeof(cur)); if (reservedWords.InList(cur)) { style = SCE_ERLANG_KEYWORD; } else if (erlangBIFs.InList(cur) && strcmp(cur,"erlang:")){ style = SCE_ERLANG_BIFS; } else if (sc.ch == '(' || '/' == sc.ch){ style = SCE_ERLANG_FUNCTION_NAME; } else { style = SCE_ERLANG_ATOM; } sc.ChangeState(style); sc.SetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } } break; case ATOM_QUOTED : { if ( '@' == sc.ch ){ parse_state = NODE_NAME_QUOTED; } else if ('\'' == sc.ch && '\\' != sc.chPrev) { sc.ChangeState(SCE_ERLANG_ATOM); sc.ForwardSetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } } break; /* -------------------------------------------------------------- */ /* Node names ----------------------------------------------------*/ case NODE_NAME_UNQUOTED : { if ('@' == sc.ch) { sc.SetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } else if (!IsAWordChar(sc.ch)) { sc.ChangeState(SCE_ERLANG_NODE_NAME); sc.SetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } } break; case NODE_NAME_QUOTED : { if ('@' == sc.ch) { sc.SetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } else if ('\'' == sc.ch && '\\' != sc.chPrev) { sc.ChangeState(SCE_ERLANG_NODE_NAME_QUOTED); sc.ForwardSetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } } break; /* -------------------------------------------------------------- */ /* Records -------------------------------------------------------*/ case RECORD_START : { if ('\'' == sc.ch) { parse_state = RECORD_QUOTED; } else if (isalpha(sc.ch) && islower(sc.ch)) { parse_state = RECORD_UNQUOTED; } else { // error sc.SetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } } break; case RECORD_UNQUOTED : { if (!IsAWordChar(sc.ch)) { sc.ChangeState(SCE_ERLANG_RECORD); sc.SetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } } break; case RECORD_QUOTED : { if ('\'' == sc.ch && '\\' != sc.chPrev) { sc.ChangeState(SCE_ERLANG_RECORD_QUOTED); sc.ForwardSetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } } break; /* -------------------------------------------------------------- */ /* Macros --------------------------------------------------------*/ case MACRO_START : { if ('\'' == sc.ch) { parse_state = MACRO_QUOTED; } else if (isalpha(sc.ch)) { parse_state = MACRO_UNQUOTED; } else { // error sc.SetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } } break; case MACRO_UNQUOTED : { if (!IsAWordChar(sc.ch)) { sc.ChangeState(SCE_ERLANG_MACRO); sc.SetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } } break; case MACRO_QUOTED : { if ('\'' == sc.ch && '\\' != sc.chPrev) { sc.ChangeState(SCE_ERLANG_MACRO_QUOTED); sc.ForwardSetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } } break; /* -------------------------------------------------------------- */ /* Numerics ------------------------------------------------------*/ /* Simple integer */ case NUMERAL_START : { if (isdigit(sc.ch)) { radix_digits *= 10; radix_digits += sc.ch - '0'; // Assuming ASCII here! } else if ('#' == sc.ch) { if (2 > radix_digits || 36 < radix_digits) { sc.SetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } else { parse_state = NUMERAL_BASE_VALUE; } } else if ('.' == sc.ch && isdigit(sc.chNext)) { radix_digits = 0; parse_state = NUMERAL_FLOAT; } else if ('e' == sc.ch || 'E' == sc.ch) { exponent_digits = 0; parse_state = NUMERAL_EXPONENT; } else { radix_digits = 0; sc.ChangeState(SCE_ERLANG_NUMBER); sc.SetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } } break; /* Integer in other base than 10 (x#yyy) */ case NUMERAL_BASE_VALUE : { if (!is_radix(radix_digits,sc.ch)) { radix_digits = 0; if (!isalnum(sc.ch)) sc.ChangeState(SCE_ERLANG_NUMBER); sc.SetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } } break; /* Float (x.yyy) */ case NUMERAL_FLOAT : { if ('e' == sc.ch || 'E' == sc.ch) { exponent_digits = 0; parse_state = NUMERAL_EXPONENT; } else if (!isdigit(sc.ch)) { sc.ChangeState(SCE_ERLANG_NUMBER); sc.SetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } } break; /* Exponent, either integer or float (xEyy, x.yyEzzz) */ case NUMERAL_EXPONENT : { if (('-' == sc.ch || '+' == sc.ch) && (isdigit(sc.chNext))) { sc.Forward(); } else if (!isdigit(sc.ch)) { if (0 < exponent_digits) sc.ChangeState(SCE_ERLANG_NUMBER); sc.SetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } else { ++exponent_digits; } } break; /* -------------------------------------------------------------- */ /* Preprocessor --------------------------------------------------*/ case PREPROCESSOR : { if (!IsAWordChar(sc.ch)) { sc.GetCurrent(cur, sizeof(cur)); if (erlangPreproc.InList(cur)) { style = SCE_ERLANG_PREPROC; } else if (erlangModulesAtt.InList(cur)) { style = SCE_ERLANG_MODULES_ATT; } sc.ChangeState(style); sc.SetState(SCE_ERLANG_DEFAULT); parse_state = STATE_NULL; } } break; } } /* End of : STATE_NULL != parse_state */ else { switch (sc.state) { case SCE_ERLANG_VARIABLE : { if (!IsAWordChar(sc.ch)) sc.SetState(SCE_ERLANG_DEFAULT); } break; case SCE_ERLANG_STRING : { if (sc.ch == '\"' && sc.chPrev != '\\') sc.ForwardSetState(SCE_ERLANG_DEFAULT); } break; case SCE_ERLANG_COMMENT : { if (sc.atLineEnd) sc.SetState(SCE_ERLANG_DEFAULT); } break; case SCE_ERLANG_CHARACTER : { if (sc.chPrev == '\\') { sc.ForwardSetState(SCE_ERLANG_DEFAULT); } else if (sc.ch != '\\') { sc.ForwardSetState(SCE_ERLANG_DEFAULT); } } break; case SCE_ERLANG_OPERATOR : { if (sc.chPrev == '.') { if (sc.ch == '*' || sc.ch == '/' || sc.ch == '\\' || sc.ch == '^') { sc.ForwardSetState(SCE_ERLANG_DEFAULT); } else if (sc.ch == '\'') { sc.ForwardSetState(SCE_ERLANG_DEFAULT); } else { sc.SetState(SCE_ERLANG_DEFAULT); } } else { sc.SetState(SCE_ERLANG_DEFAULT); } } break; } } if (sc.state == SCE_ERLANG_DEFAULT) { bool no_new_state = false; switch (sc.ch) { case '\"' : sc.SetState(SCE_ERLANG_STRING); break; case '$' : sc.SetState(SCE_ERLANG_CHARACTER); break; case '%' : { parse_state = COMMENT; sc.SetState(SCE_ERLANG_COMMENT); } break; case '#' : { parse_state = RECORD_START; sc.SetState(SCE_ERLANG_UNKNOWN); } break; case '?' : { parse_state = MACRO_START; sc.SetState(SCE_ERLANG_UNKNOWN); } break; case '\'' : { parse_state = ATOM_QUOTED; sc.SetState(SCE_ERLANG_UNKNOWN); } break; case '+' : case '-' : { if (IsADigit(sc.chNext)) { parse_state = NUMERAL_START; radix_digits = 0; sc.SetState(SCE_ERLANG_UNKNOWN); } else if (sc.ch != '+') { parse_state = PREPROCESSOR; sc.SetState(SCE_ERLANG_UNKNOWN); } } break; default : no_new_state = true; } if (no_new_state) { if (isdigit(sc.ch)) { parse_state = NUMERAL_START; radix_digits = sc.ch - '0'; sc.SetState(SCE_ERLANG_UNKNOWN); } else if (isupper(sc.ch) || '_' == sc.ch) { sc.SetState(SCE_ERLANG_VARIABLE); } else if (isalpha(sc.ch)) { parse_state = ATOM_UNQUOTED; sc.SetState(SCE_ERLANG_UNKNOWN); } else if (isoperator(static_cast(sc.ch)) || sc.ch == '\\') { sc.SetState(SCE_ERLANG_OPERATOR); } } } } sc.Complete(); } static int ClassifyErlangFoldPoint( Accessor &styler, int styleNext, int keyword_start ) { int lev = 0; if (styler.Match(keyword_start,"case") || ( styler.Match(keyword_start,"fun") && (SCE_ERLANG_FUNCTION_NAME != styleNext) ) || styler.Match(keyword_start,"if") || styler.Match(keyword_start,"query") || styler.Match(keyword_start,"receive") ) { ++lev; } else if (styler.Match(keyword_start,"end")) { --lev; } return lev; } static void FoldErlangDoc( unsigned int startPos, int length, int initStyle, WordList** /*keywordlists*/, Accessor &styler ) { unsigned int endPos = startPos + length; int currentLine = styler.GetLine(startPos); int lev; int previousLevel = styler.LevelAt(currentLine) & SC_FOLDLEVELNUMBERMASK; int currentLevel = previousLevel; int styleNext = styler.StyleAt(startPos); int style = initStyle; int stylePrev; int keyword_start = 0; char ch; char chNext = styler.SafeGetCharAt(startPos); bool atEOL; for (unsigned int i = startPos; i < endPos; i++) { ch = chNext; chNext = styler.SafeGetCharAt(i + 1); // Get styles stylePrev = style; style = styleNext; styleNext = styler.StyleAt(i + 1); atEOL = ((ch == '\r') && (chNext != '\n')) || (ch == '\n'); if (stylePrev != SCE_ERLANG_KEYWORD && style == SCE_ERLANG_KEYWORD) { keyword_start = i; } // Fold on keywords if (stylePrev == SCE_ERLANG_KEYWORD && style != SCE_ERLANG_KEYWORD && style != SCE_ERLANG_ATOM ) { currentLevel += ClassifyErlangFoldPoint(styler, styleNext, keyword_start); } // Fold on comments if (style == SCE_ERLANG_COMMENT || style == SCE_ERLANG_COMMENT_MODULE || style == SCE_ERLANG_COMMENT_FUNCTION) { if (ch == '%' && chNext == '{') { currentLevel++; } else if (ch == '%' && chNext == '}') { currentLevel--; } } // Fold on braces if (style == SCE_ERLANG_OPERATOR) { if (ch == '{' || ch == '(' || ch == '[') { currentLevel++; } else if (ch == '}' || ch == ')' || ch == ']') { currentLevel--; } } if (atEOL) { lev = previousLevel; if (currentLevel > previousLevel) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(currentLine)) styler.SetLevel(currentLine, lev); currentLine++; previousLevel = currentLevel; } } // Fill in the real level of the next line, keeping the current flags as they will be filled in later styler.SetLevel(currentLine, previousLevel | (styler.LevelAt(currentLine) & ~SC_FOLDLEVELNUMBERMASK)); } static const char * const erlangWordListDesc[] = { "Erlang Reserved words", "Erlang BIFs", "Erlang Preprocessor", "Erlang Module Attributes", "Erlang Documentation", "Erlang Documentation Macro", 0 }; LexerModule lmErlang( SCLEX_ERLANG, ColouriseErlangDoc, "erlang", FoldErlangDoc, erlangWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexSpice.cxx000444001750001750 1557012021352777 24665 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexSpice.cxx ** Lexer for Spice **/ // Copyright 2006 by Fabien Proriol // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif /* * Interface */ static void ColouriseDocument( unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler); static const char * const spiceWordListDesc[] = { "Keywords", // SPICE command "Keywords2", // SPICE functions "Keywords3", // SPICE params 0 }; LexerModule lmSpice(SCLEX_SPICE, ColouriseDocument, "spice", NULL, spiceWordListDesc); /* * Implementation */ static void ColouriseComment(StyleContext& sc, bool& apostropheStartsAttribute); static void ColouriseDelimiter(StyleContext& sc, bool& apostropheStartsAttribute); static void ColouriseNumber(StyleContext& sc, bool& apostropheStartsAttribute); static void ColouriseWhiteSpace(StyleContext& sc, bool& apostropheStartsAttribute); static void ColouriseWord(StyleContext& sc, WordList& keywords, WordList& keywords2, WordList& keywords3, bool& apostropheStartsAttribute); static inline bool IsDelimiterCharacter(int ch); static inline bool IsNumberStartCharacter(int ch); static inline bool IsNumberCharacter(int ch); static inline bool IsSeparatorOrDelimiterCharacter(int ch); static inline bool IsWordStartCharacter(int ch); static inline bool IsWordCharacter(int ch); static void ColouriseComment(StyleContext& sc, bool&) { sc.SetState(SCE_SPICE_COMMENTLINE); while (!sc.atLineEnd) { sc.Forward(); } } static void ColouriseDelimiter(StyleContext& sc, bool& apostropheStartsAttribute) { apostropheStartsAttribute = sc.Match (')'); sc.SetState(SCE_SPICE_DELIMITER); sc.ForwardSetState(SCE_SPICE_DEFAULT); } static void ColouriseNumber(StyleContext& sc, bool& apostropheStartsAttribute) { apostropheStartsAttribute = true; std::string number; sc.SetState(SCE_SPICE_NUMBER); // Get all characters up to a delimiter or a separator, including points, but excluding // double points (ranges). while (!IsSeparatorOrDelimiterCharacter(sc.ch) || (sc.ch == '.' && sc.chNext != '.')) { number += static_cast(sc.ch); sc.Forward(); } // Special case: exponent with sign if ((sc.chPrev == 'e' || sc.chPrev == 'E') && (sc.ch == '+' || sc.ch == '-')) { number += static_cast(sc.ch); sc.Forward (); while (!IsSeparatorOrDelimiterCharacter(sc.ch)) { number += static_cast(sc.ch); sc.Forward(); } } sc.SetState(SCE_SPICE_DEFAULT); } static void ColouriseWhiteSpace(StyleContext& sc, bool& ) { sc.SetState(SCE_SPICE_DEFAULT); sc.ForwardSetState(SCE_SPICE_DEFAULT); } static void ColouriseWord(StyleContext& sc, WordList& keywords, WordList& keywords2, WordList& keywords3, bool& apostropheStartsAttribute) { apostropheStartsAttribute = true; sc.SetState(SCE_SPICE_IDENTIFIER); std::string word; while (!sc.atLineEnd && !IsSeparatorOrDelimiterCharacter(sc.ch)) { word += static_cast(tolower(sc.ch)); sc.Forward(); } if (keywords.InList(word.c_str())) { sc.ChangeState(SCE_SPICE_KEYWORD); if (word != "all") { apostropheStartsAttribute = false; } } else if (keywords2.InList(word.c_str())) { sc.ChangeState(SCE_SPICE_KEYWORD2); if (word != "all") { apostropheStartsAttribute = false; } } else if (keywords3.InList(word.c_str())) { sc.ChangeState(SCE_SPICE_KEYWORD3); if (word != "all") { apostropheStartsAttribute = false; } } sc.SetState(SCE_SPICE_DEFAULT); } // // ColouriseDocument // static void ColouriseDocument( unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; WordList &keywords3 = *keywordlists[2]; StyleContext sc(startPos, length, initStyle, styler); int lineCurrent = styler.GetLine(startPos); bool apostropheStartsAttribute = (styler.GetLineState(lineCurrent) & 1) != 0; while (sc.More()) { if (sc.atLineEnd) { // Go to the next line sc.Forward(); lineCurrent++; // Remember the line state for future incremental lexing styler.SetLineState(lineCurrent, apostropheStartsAttribute); // Don't continue any styles on the next line sc.SetState(SCE_SPICE_DEFAULT); } // Comments if ((sc.Match('*') && sc.atLineStart) || sc.Match('*','~')) { ColouriseComment(sc, apostropheStartsAttribute); // Whitespace } else if (IsASpace(sc.ch)) { ColouriseWhiteSpace(sc, apostropheStartsAttribute); // Delimiters } else if (IsDelimiterCharacter(sc.ch)) { ColouriseDelimiter(sc, apostropheStartsAttribute); // Numbers } else if (IsADigit(sc.ch) || sc.ch == '#') { ColouriseNumber(sc, apostropheStartsAttribute); // Keywords or identifiers } else { ColouriseWord(sc, keywords, keywords2, keywords3, apostropheStartsAttribute); } } sc.Complete(); } static inline bool IsDelimiterCharacter(int ch) { switch (ch) { case '&': case '\'': case '(': case ')': case '*': case '+': case ',': case '-': case '.': case '/': case ':': case ';': case '<': case '=': case '>': case '|': return true; default: return false; } } static inline bool IsNumberCharacter(int ch) { return IsNumberStartCharacter(ch) || ch == '_' || ch == '.' || ch == '#' || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F'); } static inline bool IsNumberStartCharacter(int ch) { return IsADigit(ch); } static inline bool IsSeparatorOrDelimiterCharacter(int ch) { return IsASpace(ch) || IsDelimiterCharacter(ch); } static inline bool IsWordCharacter(int ch) { return IsWordStartCharacter(ch) || IsADigit(ch); } static inline bool IsWordStartCharacter(int ch) { return (isascii(ch) && isalpha(ch)) || ch == '_'; } Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexAsm.cxx000444001750001750 3266612021352777 24347 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexAsm.cxx ** Lexer for Assembler, just for the MASM syntax ** Written by The Black Horus ** Enhancements and NASM stuff by Kein-Hong Man, 2003-10 ** SCE_ASM_COMMENTBLOCK and SCE_ASM_CHARACTER are for future GNU as colouring ** Converted to lexer object and added further folding features/properties by "Udo Lechner" **/ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #include "OptionSet.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '?'); } static inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.' || ch == '%' || ch == '@' || ch == '$' || ch == '?'); } static inline bool IsAsmOperator(const int ch) { if ((ch < 0x80) && (isalnum(ch))) return false; // '.' left out as it is used to make up numbers if (ch == '*' || ch == '/' || ch == '-' || ch == '+' || ch == '(' || ch == ')' || ch == '=' || ch == '^' || ch == '[' || ch == ']' || ch == '<' || ch == '&' || ch == '>' || ch == ',' || ch == '|' || ch == '~' || ch == '%' || ch == ':') return true; return false; } static bool IsStreamCommentStyle(int style) { return style == SCE_ASM_COMMENTDIRECTIVE || style == SCE_ASM_COMMENTBLOCK; } static inline int LowerCase(int c) { if (c >= 'A' && c <= 'Z') return 'a' + c - 'A'; return c; } // An individual named option for use in an OptionSet // Options used for LexerAsm struct OptionsAsm { std::string delimiter; bool fold; bool foldSyntaxBased; bool foldCommentMultiline; bool foldCommentExplicit; std::string foldExplicitStart; std::string foldExplicitEnd; bool foldExplicitAnywhere; bool foldCompact; OptionsAsm() { delimiter = ""; fold = false; foldSyntaxBased = true; foldCommentMultiline = false; foldCommentExplicit = false; foldExplicitStart = ""; foldExplicitEnd = ""; foldExplicitAnywhere = false; foldCompact = true; } }; static const char * const asmWordListDesc[] = { "CPU instructions", "FPU instructions", "Registers", "Directives", "Directive operands", "Extended instructions", "Directives4Foldstart", "Directives4Foldend", 0 }; struct OptionSetAsm : public OptionSet { OptionSetAsm() { DefineProperty("lexer.asm.comment.delimiter", &OptionsAsm::delimiter, "Character used for COMMENT directive's delimiter, replacing the standard \"~\"."); DefineProperty("fold", &OptionsAsm::fold); DefineProperty("fold.asm.syntax.based", &OptionsAsm::foldSyntaxBased, "Set this property to 0 to disable syntax based folding."); DefineProperty("fold.asm.comment.multiline", &OptionsAsm::foldCommentMultiline, "Set this property to 1 to enable folding multi-line comments."); DefineProperty("fold.asm.comment.explicit", &OptionsAsm::foldCommentExplicit, "This option enables folding explicit fold points when using the Asm lexer. " "Explicit fold points allows adding extra folding by placing a ;{ comment at the start and a ;} " "at the end of a section that should fold."); DefineProperty("fold.asm.explicit.start", &OptionsAsm::foldExplicitStart, "The string to use for explicit fold start points, replacing the standard ;{."); DefineProperty("fold.asm.explicit.end", &OptionsAsm::foldExplicitEnd, "The string to use for explicit fold end points, replacing the standard ;}."); DefineProperty("fold.asm.explicit.anywhere", &OptionsAsm::foldExplicitAnywhere, "Set this property to 1 to enable explicit fold points anywhere, not just in line comments."); DefineProperty("fold.compact", &OptionsAsm::foldCompact); DefineWordListSets(asmWordListDesc); } }; class LexerAsm : public ILexer { WordList cpuInstruction; WordList mathInstruction; WordList registers; WordList directive; WordList directiveOperand; WordList extInstruction; WordList directives4foldstart; WordList directives4foldend; OptionsAsm options; OptionSetAsm osAsm; public: LexerAsm() { } ~LexerAsm() { } void SCI_METHOD Release() { delete this; } int SCI_METHOD Version() const { return lvOriginal; } const char * SCI_METHOD PropertyNames() { return osAsm.PropertyNames(); } int SCI_METHOD PropertyType(const char *name) { return osAsm.PropertyType(name); } const char * SCI_METHOD DescribeProperty(const char *name) { return osAsm.DescribeProperty(name); } int SCI_METHOD PropertySet(const char *key, const char *val); const char * SCI_METHOD DescribeWordListSets() { return osAsm.DescribeWordListSets(); } int SCI_METHOD WordListSet(int n, const char *wl); void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess); void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess); void * SCI_METHOD PrivateCall(int, void *) { return 0; } static ILexer *LexerFactoryAsm() { return new LexerAsm(); } }; int SCI_METHOD LexerAsm::PropertySet(const char *key, const char *val) { if (osAsm.PropertySet(&options, key, val)) { return 0; } return -1; } int SCI_METHOD LexerAsm::WordListSet(int n, const char *wl) { WordList *wordListN = 0; switch (n) { case 0: wordListN = &cpuInstruction; break; case 1: wordListN = &mathInstruction; break; case 2: wordListN = ®isters; break; case 3: wordListN = &directive; break; case 4: wordListN = &directiveOperand; break; case 5: wordListN = &extInstruction; break; case 6: wordListN = &directives4foldstart; break; case 7: wordListN = &directives4foldend; break; } int firstModification = -1; if (wordListN) { WordList wlNew; wlNew.Set(wl); if (*wordListN != wlNew) { wordListN->Set(wl); firstModification = 0; } } return firstModification; } void SCI_METHOD LexerAsm::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { LexAccessor styler(pAccess); // Do not leak onto next line if (initStyle == SCE_ASM_STRINGEOL) initStyle = SCE_ASM_DEFAULT; StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { // Prevent SCE_ASM_STRINGEOL from leaking back to previous line if (sc.atLineStart && (sc.state == SCE_ASM_STRING)) { sc.SetState(SCE_ASM_STRING); } else if (sc.atLineStart && (sc.state == SCE_ASM_CHARACTER)) { sc.SetState(SCE_ASM_CHARACTER); } // Handle line continuation generically. if (sc.ch == '\\') { if (sc.chNext == '\n' || sc.chNext == '\r') { sc.Forward(); if (sc.ch == '\r' && sc.chNext == '\n') { sc.Forward(); } continue; } } // Determine if the current state should terminate. if (sc.state == SCE_ASM_OPERATOR) { if (!IsAsmOperator(sc.ch)) { sc.SetState(SCE_ASM_DEFAULT); } } else if (sc.state == SCE_ASM_NUMBER) { if (!IsAWordChar(sc.ch)) { sc.SetState(SCE_ASM_DEFAULT); } } else if (sc.state == SCE_ASM_IDENTIFIER) { if (!IsAWordChar(sc.ch) ) { char s[100]; sc.GetCurrentLowered(s, sizeof(s)); bool IsDirective = false; if (cpuInstruction.InList(s)) { sc.ChangeState(SCE_ASM_CPUINSTRUCTION); } else if (mathInstruction.InList(s)) { sc.ChangeState(SCE_ASM_MATHINSTRUCTION); } else if (registers.InList(s)) { sc.ChangeState(SCE_ASM_REGISTER); } else if (directive.InList(s)) { sc.ChangeState(SCE_ASM_DIRECTIVE); IsDirective = true; } else if (directiveOperand.InList(s)) { sc.ChangeState(SCE_ASM_DIRECTIVEOPERAND); } else if (extInstruction.InList(s)) { sc.ChangeState(SCE_ASM_EXTINSTRUCTION); } sc.SetState(SCE_ASM_DEFAULT); if (IsDirective && !strcmp(s, "comment")) { char delimiter = options.delimiter.empty() ? '~' : options.delimiter.c_str()[0]; while (IsASpaceOrTab(sc.ch) && !sc.atLineEnd) { sc.ForwardSetState(SCE_ASM_DEFAULT); } if (sc.ch == delimiter) { sc.SetState(SCE_ASM_COMMENTDIRECTIVE); } } } } else if (sc.state == SCE_ASM_COMMENTDIRECTIVE) { char delimiter = options.delimiter.empty() ? '~' : options.delimiter.c_str()[0]; if (sc.ch == delimiter) { while (!sc.atLineEnd) { sc.Forward(); } sc.SetState(SCE_ASM_DEFAULT); } } else if (sc.state == SCE_ASM_COMMENT ) { if (sc.atLineEnd) { sc.SetState(SCE_ASM_DEFAULT); } } else if (sc.state == SCE_ASM_STRING) { if (sc.ch == '\\') { if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { sc.Forward(); } } else if (sc.ch == '\"') { sc.ForwardSetState(SCE_ASM_DEFAULT); } else if (sc.atLineEnd) { sc.ChangeState(SCE_ASM_STRINGEOL); sc.ForwardSetState(SCE_ASM_DEFAULT); } } else if (sc.state == SCE_ASM_CHARACTER) { if (sc.ch == '\\') { if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { sc.Forward(); } } else if (sc.ch == '\'') { sc.ForwardSetState(SCE_ASM_DEFAULT); } else if (sc.atLineEnd) { sc.ChangeState(SCE_ASM_STRINGEOL); sc.ForwardSetState(SCE_ASM_DEFAULT); } } // Determine if a new state should be entered. if (sc.state == SCE_ASM_DEFAULT) { if (sc.ch == ';'){ sc.SetState(SCE_ASM_COMMENT); } else if (isascii(sc.ch) && (isdigit(sc.ch) || (sc.ch == '.' && isascii(sc.chNext) && isdigit(sc.chNext)))) { sc.SetState(SCE_ASM_NUMBER); } else if (IsAWordStart(sc.ch)) { sc.SetState(SCE_ASM_IDENTIFIER); } else if (sc.ch == '\"') { sc.SetState(SCE_ASM_STRING); } else if (sc.ch == '\'') { sc.SetState(SCE_ASM_CHARACTER); } else if (IsAsmOperator(sc.ch)) { sc.SetState(SCE_ASM_OPERATOR); } } } sc.Complete(); } // Store both the current line's fold level and the next lines in the // level store to make it easy to pick up with each increment // and to make it possible to fiddle the current level for "else". void SCI_METHOD LexerAsm::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { if (!options.fold) return; LexAccessor styler(pAccess); unsigned int endPos = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; int levelNext = levelCurrent; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; char word[100]; int wordlen = 0; const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty(); for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (options.foldCommentMultiline && IsStreamCommentStyle(style)) { if (!IsStreamCommentStyle(stylePrev)) { levelNext++; } else if (!IsStreamCommentStyle(styleNext) && !atEOL) { // Comments don't end at end of line and the next character may be unstyled. levelNext--; } } if (options.foldCommentExplicit && ((style == SCE_ASM_COMMENT) || options.foldExplicitAnywhere)) { if (userDefinedFoldMarkers) { if (styler.Match(i, options.foldExplicitStart.c_str())) { levelNext++; } else if (styler.Match(i, options.foldExplicitEnd.c_str())) { levelNext--; } } else { if (ch == ';') { if (chNext == '{') { levelNext++; } else if (chNext == '}') { levelNext--; } } } } if (options.foldSyntaxBased && (style == SCE_ASM_DIRECTIVE)) { word[wordlen++] = static_cast(LowerCase(ch)); if (wordlen == 100) { // prevent overflow word[0] = '\0'; wordlen = 1; } if (styleNext != SCE_ASM_DIRECTIVE) { // reading directive ready word[wordlen] = '\0'; wordlen = 0; if (directives4foldstart.InList(word)) { levelNext++; } else if (directives4foldend.InList(word)){ levelNext--; } } } if (!IsASpace(ch)) visibleChars++; if (atEOL || (i == endPos-1)) { int levelUse = levelCurrent; int lev = levelUse | levelNext << 16; if (visibleChars == 0 && options.foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if (levelUse < levelNext) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelCurrent = levelNext; if (atEOL && (i == static_cast(styler.Length()-1))) { // There is an empty line at end of file so give it same level and empty styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG); } visibleChars = 0; } } } LexerModule lmAsm(SCLEX_ASM, LexerAsm::LexerFactoryAsm, "asm", asmWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexBullant.cxx000444001750001750 1506712021352777 25224 0ustar00azawawiazawawi000000000000// SciTE - Scintilla based Text Editor // LexBullant.cxx - lexer for Bullant #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static int classifyWordBullant(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { char s[100]; s[0] = '\0'; for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) { s[i] = static_cast(tolower(styler[start + i])); s[i + 1] = '\0'; } int lev= 0; char chAttr = SCE_C_IDENTIFIER; if (isdigit(s[0]) || (s[0] == '.')){ chAttr = SCE_C_NUMBER; } else { if (keywords.InList(s)) { chAttr = SCE_C_WORD; if (strcmp(s, "end") == 0) lev = -1; else if (strcmp(s, "method") == 0 || strcmp(s, "case") == 0 || strcmp(s, "class") == 0 || strcmp(s, "debug") == 0 || strcmp(s, "test") == 0 || strcmp(s, "if") == 0 || strcmp(s, "lock") == 0 || strcmp(s, "transaction") == 0 || strcmp(s, "trap") == 0 || strcmp(s, "until") == 0 || strcmp(s, "while") == 0) lev = 1; } } styler.ColourTo(end, chAttr); return lev; } static void ColouriseBullantDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; styler.StartAt(startPos); bool fold = styler.GetPropertyInt("fold") != 0; int lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; int state = initStyle; if (state == SCE_C_STRINGEOL) // Does not leak onto next line state = SCE_C_DEFAULT; char chPrev = ' '; char chNext = styler[startPos]; unsigned int lengthDoc = startPos + length; int visibleChars = 0; styler.StartSegment(startPos); int endFoundThisLine = 0; for (unsigned int i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); if ((ch == '\r' && chNext != '\n') || (ch == '\n')) { // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix) // Avoid triggering two times on Dos/Win // End of line endFoundThisLine = 0; if (state == SCE_C_STRINGEOL) { styler.ColourTo(i, state); state = SCE_C_DEFAULT; } if (fold) { int lev = levelPrev; if (visibleChars == 0) lev |= SC_FOLDLEVELWHITEFLAG; if ((levelCurrent > levelPrev) && (visibleChars > 0)) lev |= SC_FOLDLEVELHEADERFLAG; styler.SetLevel(lineCurrent, lev); lineCurrent++; levelPrev = levelCurrent; } visibleChars = 0; /* int indentBlock = GetLineIndentation(lineCurrent); if (blockChange==1){ lineCurrent++; int pos=SetLineIndentation(lineCurrent, indentBlock + indentSize); } else if (blockChange==-1) { indentBlock -= indentSize; if (indentBlock < 0) indentBlock = 0; SetLineIndentation(lineCurrent, indentBlock); lineCurrent++; } blockChange=0; */ } if (!(isascii(ch) && isspace(ch))) visibleChars++; if (styler.IsLeadByte(ch)) { chNext = styler.SafeGetCharAt(i + 2); chPrev = ' '; i += 1; continue; } if (state == SCE_C_DEFAULT) { if (iswordstart(ch)) { styler.ColourTo(i-1, state); state = SCE_C_IDENTIFIER; } else if (ch == '@' && chNext == 'o') { if ((styler.SafeGetCharAt(i+2) =='f') && (styler.SafeGetCharAt(i+3) == 'f')) { styler.ColourTo(i-1, state); state = SCE_C_COMMENT; } } else if (ch == '#') { styler.ColourTo(i-1, state); state = SCE_C_COMMENTLINE; } else if (ch == '\"') { styler.ColourTo(i-1, state); state = SCE_C_STRING; } else if (ch == '\'') { styler.ColourTo(i-1, state); state = SCE_C_CHARACTER; } else if (isoperator(ch)) { styler.ColourTo(i-1, state); styler.ColourTo(i, SCE_C_OPERATOR); } } else if (state == SCE_C_IDENTIFIER) { if (!iswordchar(ch)) { int levelChange = classifyWordBullant(styler.GetStartSegment(), i - 1, keywords, styler); state = SCE_C_DEFAULT; chNext = styler.SafeGetCharAt(i + 1); if (ch == '#') { state = SCE_C_COMMENTLINE; } else if (ch == '\"') { state = SCE_C_STRING; } else if (ch == '\'') { state = SCE_C_CHARACTER; } else if (isoperator(ch)) { styler.ColourTo(i, SCE_C_OPERATOR); } if (endFoundThisLine == 0) levelCurrent+=levelChange; if (levelChange == -1) endFoundThisLine=1; } } else if (state == SCE_C_COMMENT) { if (ch == '@' && chNext == 'o') { if (styler.SafeGetCharAt(i+2) == 'n') { styler.ColourTo(i+2, state); state = SCE_C_DEFAULT; i+=2; } } } else if (state == SCE_C_COMMENTLINE) { if (ch == '\r' || ch == '\n') { endFoundThisLine = 0; styler.ColourTo(i-1, state); state = SCE_C_DEFAULT; } } else if (state == SCE_C_STRING) { if (ch == '\\') { if (chNext == '\"' || chNext == '\'' || chNext == '\\') { i++; ch = chNext; chNext = styler.SafeGetCharAt(i + 1); } } else if (ch == '\"') { styler.ColourTo(i, state); state = SCE_C_DEFAULT; } else if (chNext == '\r' || chNext == '\n') { endFoundThisLine = 0; styler.ColourTo(i-1, SCE_C_STRINGEOL); state = SCE_C_STRINGEOL; } } else if (state == SCE_C_CHARACTER) { if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) { endFoundThisLine = 0; styler.ColourTo(i-1, SCE_C_STRINGEOL); state = SCE_C_STRINGEOL; } else if (ch == '\\') { if (chNext == '\"' || chNext == '\'' || chNext == '\\') { i++; ch = chNext; chNext = styler.SafeGetCharAt(i + 1); } } else if (ch == '\'') { styler.ColourTo(i, state); state = SCE_C_DEFAULT; } } chPrev = ch; } styler.ColourTo(lengthDoc - 1, state); // Fill in the real level of the next line, keeping the current flags as they will be filled in later if (fold) { int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; //styler.SetLevel(lineCurrent, levelCurrent | flagsNext); styler.SetLevel(lineCurrent, levelPrev | flagsNext); } } static const char * const bullantWordListDesc[] = { "Keywords", 0 }; LexerModule lmBullant(SCLEX_BULLANT, ColouriseBullantDoc, "bullant", 0, bullantWordListDesc); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/SplitVector.h000444001750001750 1575312021352777 25057 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file SplitVector.h ** Main data structure for holding arrays that handle insertions ** and deletions efficiently. **/ // Copyright 1998-2007 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef SPLITVECTOR_H #define SPLITVECTOR_H template class SplitVector { protected: T *body; int size; int lengthBody; int part1Length; int gapLength; /// invariant: gapLength == size - lengthBody int growSize; /// Move the gap to a particular position so that insertion and /// deletion at that point will not require much copying and /// hence be fast. void GapTo(int position) { if (position != part1Length) { if (position < part1Length) { memmove( body + position + gapLength, body + position, sizeof(T) * (part1Length - position)); } else { // position > part1Length memmove( body + part1Length, body + part1Length + gapLength, sizeof(T) * (position - part1Length)); } part1Length = position; } } /// Check that there is room in the buffer for an insertion, /// reallocating if more space needed. void RoomFor(int insertionLength) { if (gapLength <= insertionLength) { while (growSize < size / 6) growSize *= 2; ReAllocate(size + insertionLength + growSize); } } void Init() { body = NULL; growSize = 8; size = 0; lengthBody = 0; part1Length = 0; gapLength = 0; } public: /// Construct a split buffer. SplitVector() { Init(); } ~SplitVector() { delete []body; body = 0; } int GetGrowSize() const { return growSize; } void SetGrowSize(int growSize_) { growSize = growSize_; } /// Reallocate the storage for the buffer to be newSize and /// copy exisiting contents to the new buffer. /// Must not be used to decrease the size of the buffer. void ReAllocate(int newSize) { if (newSize > size) { // Move the gap to the end GapTo(lengthBody); T *newBody = new T[newSize]; if ((size != 0) && (body != 0)) { memmove(newBody, body, sizeof(T) * lengthBody); delete []body; } body = newBody; gapLength += newSize - size; size = newSize; } } /// Retrieve the character at a particular position. /// Retrieving positions outside the range of the buffer returns 0. /// The assertions here are disabled since calling code can be /// simpler if out of range access works and returns 0. T ValueAt(int position) const { if (position < part1Length) { //PLATFORM_ASSERT(position >= 0); if (position < 0) { return 0; } else { return body[position]; } } else { //PLATFORM_ASSERT(position < lengthBody); if (position >= lengthBody) { return 0; } else { return body[gapLength + position]; } } } void SetValueAt(int position, T v) { if (position < part1Length) { PLATFORM_ASSERT(position >= 0); if (position < 0) { ; } else { body[position] = v; } } else { PLATFORM_ASSERT(position < lengthBody); if (position >= lengthBody) { ; } else { body[gapLength + position] = v; } } } T &operator[](int position) const { PLATFORM_ASSERT(position >= 0 && position < lengthBody); if (position < part1Length) { return body[position]; } else { return body[gapLength + position]; } } /// Retrieve the length of the buffer. int Length() const { return lengthBody; } /// Insert a single value into the buffer. /// Inserting at positions outside the current range fails. void Insert(int position, T v) { PLATFORM_ASSERT((position >= 0) && (position <= lengthBody)); if ((position < 0) || (position > lengthBody)) { return; } RoomFor(1); GapTo(position); body[part1Length] = v; lengthBody++; part1Length++; gapLength--; } /// Insert a number of elements into the buffer setting their value. /// Inserting at positions outside the current range fails. void InsertValue(int position, int insertLength, T v) { PLATFORM_ASSERT((position >= 0) && (position <= lengthBody)); if (insertLength > 0) { if ((position < 0) || (position > lengthBody)) { return; } RoomFor(insertLength); GapTo(position); for (int i = 0; i < insertLength; i++) body[part1Length + i] = v; lengthBody += insertLength; part1Length += insertLength; gapLength -= insertLength; } } /// Ensure at least length elements allocated, /// appending zero valued elements if needed. void EnsureLength(int wantedLength) { if (Length() < wantedLength) { InsertValue(Length(), wantedLength - Length(), 0); } } /// Insert text into the buffer from an array. void InsertFromArray(int positionToInsert, const T s[], int positionFrom, int insertLength) { PLATFORM_ASSERT((positionToInsert >= 0) && (positionToInsert <= lengthBody)); if (insertLength > 0) { if ((positionToInsert < 0) || (positionToInsert > lengthBody)) { return; } RoomFor(insertLength); GapTo(positionToInsert); memmove(body + part1Length, s + positionFrom, sizeof(T) * insertLength); lengthBody += insertLength; part1Length += insertLength; gapLength -= insertLength; } } /// Delete one element from the buffer. void Delete(int position) { PLATFORM_ASSERT((position >= 0) && (position < lengthBody)); if ((position < 0) || (position >= lengthBody)) { return; } DeleteRange(position, 1); } /// Delete a range from the buffer. /// Deleting positions outside the current range fails. void DeleteRange(int position, int deleteLength) { PLATFORM_ASSERT((position >= 0) && (position + deleteLength <= lengthBody)); if ((position < 0) || ((position + deleteLength) > lengthBody)) { return; } if ((position == 0) && (deleteLength == lengthBody)) { // Full deallocation returns storage and is faster delete []body; Init(); } else if (deleteLength > 0) { GapTo(position); lengthBody -= deleteLength; gapLength += deleteLength; } } /// Delete all the buffer contents. void DeleteAll() { DeleteRange(0, lengthBody); } // Retrieve a range of elements into an array void GetRange(T *buffer, int position, int retrieveLength) const { // Split into up to 2 ranges, before and after the split then use memcpy on each. int range1Length = 0; if (position < part1Length) { int part1AfterPosition = part1Length - position; range1Length = retrieveLength; if (range1Length > part1AfterPosition) range1Length = part1AfterPosition; } memcpy(buffer, body + position, range1Length * sizeof(T)); buffer += range1Length; position = position + range1Length + gapLength; int range2Length = retrieveLength - range1Length; memcpy(buffer, body + position, range2Length * sizeof(T)); } T *BufferPointer() { RoomFor(1); GapTo(lengthBody); body[lengthBody] = 0; return body; } }; #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/Catalogue.cxx000444001750001750 1106512021352777 25050 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file KeyWords.cxx ** Colourise for particular languages. **/ // Copyright 1998-2002 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "LexerModule.h" #include "Catalogue.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static std::vector lexerCatalogue; static int nextLanguage = SCLEX_AUTOMATIC+1; const LexerModule *Catalogue::Find(int language) { Scintilla_LinkLexers(); for (std::vector::iterator it=lexerCatalogue.begin(); it != lexerCatalogue.end(); ++it) { if ((*it)->GetLanguage() == language) { return *it; } } return 0; } const LexerModule *Catalogue::Find(const char *languageName) { Scintilla_LinkLexers(); if (languageName) { for (std::vector::iterator it=lexerCatalogue.begin(); it != lexerCatalogue.end(); ++it) { if ((*it)->languageName && (0 == strcmp((*it)->languageName, languageName))) { return *it; } } } return 0; } void Catalogue::AddLexerModule(LexerModule *plm) { if (plm->GetLanguage() == SCLEX_AUTOMATIC) { plm->language = nextLanguage; nextLanguage++; } lexerCatalogue.push_back(plm); } // Alternative historical name for Scintilla_LinkLexers int wxForceScintillaLexers(void) { return Scintilla_LinkLexers(); } // To add or remove a lexer, add or remove its file and run LexGen.py. // Force a reference to all of the Scintilla lexers so that the linker will // not remove the code of the lexers. int Scintilla_LinkLexers() { static int initialised = 0; if (initialised) return 0; initialised = 1; // Shorten the code that declares a lexer and ensures it is linked in by calling a method. #define LINK_LEXER(lexer) extern LexerModule lexer; Catalogue::AddLexerModule(&lexer); //++Autogenerated -- run src/LexGen.py to regenerate //**\(\tLINK_LEXER(\*);\n\) LINK_LEXER(lmA68k); LINK_LEXER(lmAbaqus); LINK_LEXER(lmAda); LINK_LEXER(lmAns1); LINK_LEXER(lmAPDL); LINK_LEXER(lmAsm); LINK_LEXER(lmASY); LINK_LEXER(lmAU3); LINK_LEXER(lmAVE); LINK_LEXER(lmAVS); LINK_LEXER(lmBaan); LINK_LEXER(lmBash); LINK_LEXER(lmBatch); LINK_LEXER(lmBlitzBasic); LINK_LEXER(lmBullant); LINK_LEXER(lmCaml); LINK_LEXER(lmClw); LINK_LEXER(lmClwNoCase); LINK_LEXER(lmCmake); LINK_LEXER(lmCOBOL); LINK_LEXER(lmCoffeeScript); LINK_LEXER(lmConf); LINK_LEXER(lmCPP); LINK_LEXER(lmCPPNoCase); LINK_LEXER(lmCsound); LINK_LEXER(lmCss); LINK_LEXER(lmD); LINK_LEXER(lmDiff); LINK_LEXER(lmECL); LINK_LEXER(lmEiffel); LINK_LEXER(lmEiffelkw); LINK_LEXER(lmErlang); LINK_LEXER(lmErrorList); LINK_LEXER(lmESCRIPT); LINK_LEXER(lmF77); LINK_LEXER(lmFlagShip); LINK_LEXER(lmForth); LINK_LEXER(lmFortran); LINK_LEXER(lmFreeBasic); LINK_LEXER(lmGAP); LINK_LEXER(lmGui4Cli); LINK_LEXER(lmHaskell); LINK_LEXER(lmHTML); LINK_LEXER(lmInno); LINK_LEXER(lmKix); LINK_LEXER(lmLatex); LINK_LEXER(lmLISP); LINK_LEXER(lmLot); LINK_LEXER(lmLout); LINK_LEXER(lmLua); LINK_LEXER(lmMagikSF); LINK_LEXER(lmMake); LINK_LEXER(lmMarkdown); LINK_LEXER(lmMatlab); LINK_LEXER(lmMETAPOST); LINK_LEXER(lmMMIXAL); LINK_LEXER(lmModula); LINK_LEXER(lmMSSQL); LINK_LEXER(lmMySQL); LINK_LEXER(lmNimrod); LINK_LEXER(lmNncrontab); LINK_LEXER(lmNsis); LINK_LEXER(lmNull); LINK_LEXER(lmOctave); LINK_LEXER(lmOpal); LINK_LEXER(lmPascal); LINK_LEXER(lmPB); LINK_LEXER(lmPerl); LINK_LEXER(lmPHPSCRIPT); LINK_LEXER(lmPLM); LINK_LEXER(lmPo); LINK_LEXER(lmPOV); LINK_LEXER(lmPowerPro); LINK_LEXER(lmPowerShell); LINK_LEXER(lmProgress); LINK_LEXER(lmProps); LINK_LEXER(lmPS); LINK_LEXER(lmPureBasic); LINK_LEXER(lmPython); LINK_LEXER(lmR); LINK_LEXER(lmREBOL); LINK_LEXER(lmRuby); LINK_LEXER(lmScriptol); LINK_LEXER(lmSmalltalk); LINK_LEXER(lmSML); LINK_LEXER(lmSorc); LINK_LEXER(lmSpecman); LINK_LEXER(lmSpice); LINK_LEXER(lmSQL); LINK_LEXER(lmTACL); LINK_LEXER(lmTADS3); LINK_LEXER(lmTAL); LINK_LEXER(lmTCL); LINK_LEXER(lmTCMD); LINK_LEXER(lmTeX); LINK_LEXER(lmTxt2tags); LINK_LEXER(lmVB); LINK_LEXER(lmVBScript); LINK_LEXER(lmVerilog); LINK_LEXER(lmVHDL); LINK_LEXER(lmXML); LINK_LEXER(lmYAML); //--Autogenerated -- end of automatically generated section return 1; } Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexAVS.cxx000444001750001750 2122612021352777 24246 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexAVS.cxx ** Lexer for AviSynth. **/ // Copyright 2012 by Bruno Barbieri // Heavily based on LexPOV by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } static inline bool IsAWordStart(int ch) { return isalpha(ch) || (ch != ' ' && ch != '\n' && ch != '(' && ch != '.' && ch != ','); } static inline bool IsANumberChar(int ch) { // Not exactly following number definition (several dots are seen as OK, etc.) // but probably enough in most cases. return (ch < 0x80) && (isdigit(ch) || ch == '.' || ch == '-' || ch == '+'); } static void ColouriseAvsDoc( unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; WordList &filters = *keywordlists[1]; WordList &plugins = *keywordlists[2]; WordList &functions = *keywordlists[3]; WordList &clipProperties = *keywordlists[4]; WordList &userDefined = *keywordlists[5]; int currentLine = styler.GetLine(startPos); // Initialize the block comment nesting level, if we are inside such a comment. int blockCommentLevel = 0; if (initStyle == SCE_AVS_COMMENTBLOCK || initStyle == SCE_AVS_COMMENTBLOCKN) { blockCommentLevel = styler.GetLineState(currentLine - 1); } // Do not leak onto next line if (initStyle == SCE_AVS_COMMENTLINE) { initStyle = SCE_AVS_DEFAULT; } StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { if (sc.atLineEnd) { // Update the line state, so it can be seen by next line currentLine = styler.GetLine(sc.currentPos); if (sc.state == SCE_AVS_COMMENTBLOCK || sc.state == SCE_AVS_COMMENTBLOCKN) { // Inside a block comment, we set the line state styler.SetLineState(currentLine, blockCommentLevel); } else { // Reset the line state styler.SetLineState(currentLine, 0); } } // Determine if the current state should terminate. if (sc.state == SCE_AVS_OPERATOR) { sc.SetState(SCE_AVS_DEFAULT); } else if (sc.state == SCE_AVS_NUMBER) { // We stop the number definition on non-numerical non-dot non-sign char if (!IsANumberChar(sc.ch)) { sc.SetState(SCE_AVS_DEFAULT); } } else if (sc.state == SCE_AVS_IDENTIFIER) { if (!IsAWordChar(sc.ch)) { char s[100]; sc.GetCurrentLowered(s, sizeof(s)); if (keywords.InList(s)) { sc.ChangeState(SCE_AVS_KEYWORD); } else if (filters.InList(s)) { sc.ChangeState(SCE_AVS_FILTER); } else if (plugins.InList(s)) { sc.ChangeState(SCE_AVS_PLUGIN); } else if (functions.InList(s)) { sc.ChangeState(SCE_AVS_FUNCTION); } else if (clipProperties.InList(s)) { sc.ChangeState(SCE_AVS_CLIPPROP); } else if (userDefined.InList(s)) { sc.ChangeState(SCE_AVS_USERDFN); } sc.SetState(SCE_AVS_DEFAULT); } } else if (sc.state == SCE_AVS_COMMENTBLOCK) { if (sc.Match('/', '*')) { blockCommentLevel++; sc.Forward(); } else if (sc.Match('*', '/') && blockCommentLevel > 0) { blockCommentLevel--; sc.Forward(); if (blockCommentLevel == 0) { sc.ForwardSetState(SCE_AVS_DEFAULT); } } } else if (sc.state == SCE_AVS_COMMENTBLOCKN) { if (sc.Match('[', '*')) { blockCommentLevel++; sc.Forward(); } else if (sc.Match('*', ']') && blockCommentLevel > 0) { blockCommentLevel--; sc.Forward(); if (blockCommentLevel == 0) { sc.ForwardSetState(SCE_AVS_DEFAULT); } } } else if (sc.state == SCE_AVS_COMMENTLINE) { if (sc.atLineEnd) { sc.ForwardSetState(SCE_AVS_DEFAULT); } } else if (sc.state == SCE_AVS_STRING) { if (sc.ch == '\"') { sc.ForwardSetState(SCE_AVS_DEFAULT); } } else if (sc.state == SCE_AVS_TRIPLESTRING) { if (sc.Match("\"\"\"")) { sc.Forward(); sc.Forward(); sc.ForwardSetState(SCE_AVS_DEFAULT); } } // Determine if a new state should be entered. if (sc.state == SCE_AVS_DEFAULT) { if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_AVS_NUMBER); } else if (IsADigit(sc.ch) || (sc.ch == ',' && IsADigit(sc.chNext))) { sc.Forward(); sc.SetState(SCE_AVS_NUMBER); } else if (sc.Match('/', '*')) { blockCommentLevel = 1; sc.SetState(SCE_AVS_COMMENTBLOCK); sc.Forward(); // Eat the * so it isn't used for the end of the comment } else if (sc.Match('[', '*')) { blockCommentLevel = 1; sc.SetState(SCE_AVS_COMMENTBLOCKN); sc.Forward(); // Eat the * so it isn't used for the end of the comment } else if (sc.ch == '#') { sc.SetState(SCE_AVS_COMMENTLINE); } else if (sc.ch == '\"') { if (sc.Match("\"\"\"")) { sc.SetState(SCE_AVS_TRIPLESTRING); } else { sc.SetState(SCE_AVS_STRING); } } else if (isoperator(static_cast(sc.ch))) { sc.SetState(SCE_AVS_OPERATOR); } else if (IsAWordStart(sc.ch)) { sc.SetState(SCE_AVS_IDENTIFIER); } } } // End of file: complete any pending changeState if (sc.state == SCE_AVS_IDENTIFIER) { if (!IsAWordChar(sc.ch)) { char s[100]; sc.GetCurrentLowered(s, sizeof(s)); if (keywords.InList(s)) { sc.ChangeState(SCE_AVS_KEYWORD); } else if (filters.InList(s)) { sc.ChangeState(SCE_AVS_FILTER); } else if (plugins.InList(s)) { sc.ChangeState(SCE_AVS_PLUGIN); } else if (functions.InList(s)) { sc.ChangeState(SCE_AVS_FUNCTION); } else if (clipProperties.InList(s)) { sc.ChangeState(SCE_AVS_CLIPPROP); } else if (userDefined.InList(s)) { sc.ChangeState(SCE_AVS_USERDFN); } sc.SetState(SCE_AVS_DEFAULT); } } sc.Complete(); } static void FoldAvsDoc( unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; unsigned int endPos = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (foldComment && style == SCE_AVS_COMMENTBLOCK) { if (stylePrev != SCE_AVS_COMMENTBLOCK) { levelCurrent++; } else if ((styleNext != SCE_AVS_COMMENTBLOCK) && !atEOL) { // Comments don't end at end of line and the next character may be unstyled. levelCurrent--; } } if (foldComment && style == SCE_AVS_COMMENTBLOCKN) { if (stylePrev != SCE_AVS_COMMENTBLOCKN) { levelCurrent++; } else if ((styleNext != SCE_AVS_COMMENTBLOCKN) && !atEOL) { // Comments don't end at end of line and the next character may be unstyled. levelCurrent--; } } if (style == SCE_AVS_OPERATOR) { if (ch == '{') { levelCurrent++; } else if (ch == '}') { levelCurrent--; } } if (atEOL) { int lev = levelPrev; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if ((levelCurrent > levelPrev) && (visibleChars > 0)) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelPrev = levelCurrent; visibleChars = 0; } if (!isspacechar(ch)) visibleChars++; } // Fill in the real level of the next line, keeping the current flags as they will be filled in later int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, levelPrev | flagsNext); } static const char * const avsWordLists[] = { "Keywords", "Filters", "Plugins", "Functions", "Clip properties", "User defined functions", 0, }; LexerModule lmAVS(SCLEX_AVS, ColouriseAvsDoc, "avs", FoldAvsDoc, avsWordLists); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LineMarker.cxx000444001750001750 3160512021352777 25177 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LineMarker.cxx ** Defines the look of a line marker in the margin . **/ // Copyright 1998-2011 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include "Platform.h" #include "Scintilla.h" #include "XPM.h" #include "LineMarker.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif void LineMarker::SetXPM(const char *textForm) { delete pxpm; pxpm = new XPM(textForm); markType = SC_MARK_PIXMAP; } void LineMarker::SetXPM(const char *const *linesForm) { delete pxpm; pxpm = new XPM(linesForm); markType = SC_MARK_PIXMAP; } void LineMarker::SetRGBAImage(Point sizeRGBAImage, const unsigned char *pixelsRGBAImage) { delete image; image = new RGBAImage(sizeRGBAImage.x, sizeRGBAImage.y, pixelsRGBAImage); markType = SC_MARK_RGBAIMAGE; } static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore, ColourDesired back) { PRectangle rc; rc.left = centreX - armSize; rc.top = centreY - armSize; rc.right = centreX + armSize + 1; rc.bottom = centreY + armSize + 1; surface->RectangleDraw(rc, back, fore); } static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore, ColourDesired back) { PRectangle rcCircle; rcCircle.left = centreX - armSize; rcCircle.top = centreY - armSize; rcCircle.right = centreX + armSize + 1; rcCircle.bottom = centreY + armSize + 1; surface->Ellipse(rcCircle, back, fore); } static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore) { PRectangle rcV(centreX, centreY - armSize + 2, centreX + 1, centreY + armSize - 2 + 1); surface->FillRectangle(rcV, fore); PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1); surface->FillRectangle(rcH, fore); } static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore) { PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1); surface->FillRectangle(rcH, fore); } void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, typeOfFold tFold, int marginStyle) { ColourDesired head = back; ColourDesired body = back; ColourDesired tail = back; switch (tFold) { case LineMarker::head : case LineMarker::headWithTail : head = backSelected; tail = backSelected; break; case LineMarker::body : head = backSelected; body = backSelected; break; case LineMarker::tail : body = backSelected; tail = backSelected; break; default : // LineMarker::undefined break; } if ((markType == SC_MARK_PIXMAP) && (pxpm)) { pxpm->Draw(surface, rcWhole); return; } if ((markType == SC_MARK_RGBAIMAGE) && (image)) { // Make rectangle just large enough to fit image centred on centre of rcWhole PRectangle rcImage; rcImage.top = static_cast(((rcWhole.top + rcWhole.bottom) - image->GetHeight()) / 2); rcImage.bottom = rcImage.top + image->GetHeight(); rcImage.left = static_cast(((rcWhole.left + rcWhole.right) - image->GetWidth()) / 2); rcImage.right = rcImage.left + image->GetWidth(); surface->DrawRGBAImage(rcImage, image->GetWidth(), image->GetHeight(), image->Pixels()); return; } // Restrict most shapes a bit PRectangle rc = rcWhole; rc.top++; rc.bottom--; int minDim = Platform::Minimum(rc.Width(), rc.Height()); minDim--; // Ensure does not go beyond edge int centreX = (rc.right + rc.left) / 2; int centreY = (rc.bottom + rc.top) / 2; int dimOn2 = minDim / 2; int dimOn4 = minDim / 4; int blobSize = dimOn2-1; int armSize = dimOn2-2; if (marginStyle == SC_MARGIN_NUMBER || marginStyle == SC_MARGIN_TEXT || marginStyle == SC_MARGIN_RTEXT) { // On textual margins move marker to the left to try to avoid overlapping the text centreX = rc.left + dimOn2 + 1; } if (markType == SC_MARK_ROUNDRECT) { PRectangle rcRounded = rc; rcRounded.left = rc.left + 1; rcRounded.right = rc.right - 1; surface->RoundedRectangle(rcRounded, fore, back); } else if (markType == SC_MARK_CIRCLE) { PRectangle rcCircle; rcCircle.left = centreX - dimOn2; rcCircle.top = centreY - dimOn2; rcCircle.right = centreX + dimOn2; rcCircle.bottom = centreY + dimOn2; surface->Ellipse(rcCircle, fore, back); } else if (markType == SC_MARK_ARROW) { Point pts[] = { Point(centreX - dimOn4, centreY - dimOn2), Point(centreX - dimOn4, centreY + dimOn2), Point(centreX + dimOn2 - dimOn4, centreY), }; surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]), fore, back); } else if (markType == SC_MARK_ARROWDOWN) { Point pts[] = { Point(centreX - dimOn2, centreY - dimOn4), Point(centreX + dimOn2, centreY - dimOn4), Point(centreX, centreY + dimOn2 - dimOn4), }; surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]), fore, back); } else if (markType == SC_MARK_PLUS) { Point pts[] = { Point(centreX - armSize, centreY - 1), Point(centreX - 1, centreY - 1), Point(centreX - 1, centreY - armSize), Point(centreX + 1, centreY - armSize), Point(centreX + 1, centreY - 1), Point(centreX + armSize, centreY -1), Point(centreX + armSize, centreY +1), Point(centreX + 1, centreY + 1), Point(centreX + 1, centreY + armSize), Point(centreX - 1, centreY + armSize), Point(centreX - 1, centreY + 1), Point(centreX - armSize, centreY + 1), }; surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]), fore, back); } else if (markType == SC_MARK_MINUS) { Point pts[] = { Point(centreX - armSize, centreY - 1), Point(centreX + armSize, centreY -1), Point(centreX + armSize, centreY +1), Point(centreX - armSize, centreY + 1), }; surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]), fore, back); } else if (markType == SC_MARK_SMALLRECT) { PRectangle rcSmall; rcSmall.left = rc.left + 1; rcSmall.top = rc.top + 2; rcSmall.right = rc.right - 1; rcSmall.bottom = rc.bottom - 2; surface->RectangleDraw(rcSmall, fore, back); } else if (markType == SC_MARK_EMPTY || markType == SC_MARK_BACKGROUND || markType == SC_MARK_UNDERLINE || markType == SC_MARK_AVAILABLE) { // An invisible marker so don't draw anything } else if (markType == SC_MARK_VLINE) { surface->PenColour(body); surface->MoveTo(centreX, rcWhole.top); surface->LineTo(centreX, rcWhole.bottom); } else if (markType == SC_MARK_LCORNER) { surface->PenColour(tail); surface->MoveTo(centreX, rcWhole.top); surface->LineTo(centreX, centreY); surface->LineTo(rc.right - 1, centreY); } else if (markType == SC_MARK_TCORNER) { surface->PenColour(tail); surface->MoveTo(centreX, centreY); surface->LineTo(rc.right - 1, centreY); surface->PenColour(body); surface->MoveTo(centreX, rcWhole.top); surface->LineTo(centreX, centreY + 1); surface->PenColour(head); surface->LineTo(centreX, rcWhole.bottom); } else if (markType == SC_MARK_LCORNERCURVE) { surface->PenColour(tail); surface->MoveTo(centreX, rcWhole.top); surface->LineTo(centreX, centreY-3); surface->LineTo(centreX+3, centreY); surface->LineTo(rc.right - 1, centreY); } else if (markType == SC_MARK_TCORNERCURVE) { surface->PenColour(tail); surface->MoveTo(centreX, centreY-3); surface->LineTo(centreX+3, centreY); surface->LineTo(rc.right - 1, centreY); surface->PenColour(body); surface->MoveTo(centreX, rcWhole.top); surface->LineTo(centreX, centreY-2); surface->PenColour(head); surface->LineTo(centreX, rcWhole.bottom); } else if (markType == SC_MARK_BOXPLUS) { DrawBox(surface, centreX, centreY, blobSize, fore, head); DrawPlus(surface, centreX, centreY, blobSize, tail); } else if (markType == SC_MARK_BOXPLUSCONNECTED) { if (tFold == LineMarker::headWithTail) surface->PenColour(tail); else surface->PenColour(body); surface->MoveTo(centreX, centreY + blobSize); surface->LineTo(centreX, rcWhole.bottom); surface->PenColour(body); surface->MoveTo(centreX, rcWhole.top); surface->LineTo(centreX, centreY - blobSize); DrawBox(surface, centreX, centreY, blobSize, fore, head); DrawPlus(surface, centreX, centreY, blobSize, tail); if (tFold == LineMarker::body) { surface->PenColour(tail); surface->MoveTo(centreX + 1, centreY + blobSize); surface->LineTo(centreX + blobSize + 1, centreY + blobSize); surface->MoveTo(centreX + blobSize, centreY + blobSize); surface->LineTo(centreX + blobSize, centreY - blobSize); surface->MoveTo(centreX + 1, centreY - blobSize); surface->LineTo(centreX + blobSize + 1, centreY - blobSize); } } else if (markType == SC_MARK_BOXMINUS) { DrawBox(surface, centreX, centreY, blobSize, fore, head); DrawMinus(surface, centreX, centreY, blobSize, tail); surface->PenColour(head); surface->MoveTo(centreX, centreY + blobSize); surface->LineTo(centreX, rcWhole.bottom); } else if (markType == SC_MARK_BOXMINUSCONNECTED) { DrawBox(surface, centreX, centreY, blobSize, fore, head); DrawMinus(surface, centreX, centreY, blobSize, tail); surface->PenColour(head); surface->MoveTo(centreX, centreY + blobSize); surface->LineTo(centreX, rcWhole.bottom); surface->PenColour(body); surface->MoveTo(centreX, rcWhole.top); surface->LineTo(centreX, centreY - blobSize); if (tFold == LineMarker::body) { surface->PenColour(tail); surface->MoveTo(centreX + 1, centreY + blobSize); surface->LineTo(centreX + blobSize + 1, centreY + blobSize); surface->MoveTo(centreX + blobSize, centreY + blobSize); surface->LineTo(centreX + blobSize, centreY - blobSize); surface->MoveTo(centreX + 1, centreY - blobSize); surface->LineTo(centreX + blobSize + 1, centreY - blobSize); } } else if (markType == SC_MARK_CIRCLEPLUS) { DrawCircle(surface, centreX, centreY, blobSize, fore, head); DrawPlus(surface, centreX, centreY, blobSize, tail); } else if (markType == SC_MARK_CIRCLEPLUSCONNECTED) { if (tFold == LineMarker::headWithTail) surface->PenColour(tail); else surface->PenColour(body); surface->MoveTo(centreX, centreY + blobSize); surface->LineTo(centreX, rcWhole.bottom); surface->PenColour(body); surface->MoveTo(centreX, rcWhole.top); surface->LineTo(centreX, centreY - blobSize); DrawCircle(surface, centreX, centreY, blobSize, fore, head); DrawPlus(surface, centreX, centreY, blobSize, tail); } else if (markType == SC_MARK_CIRCLEMINUS) { DrawCircle(surface, centreX, centreY, blobSize, fore, head); DrawMinus(surface, centreX, centreY, blobSize, tail); surface->PenColour(head); surface->MoveTo(centreX, centreY + blobSize); surface->LineTo(centreX, rcWhole.bottom); } else if (markType == SC_MARK_CIRCLEMINUSCONNECTED) { DrawCircle(surface, centreX, centreY, blobSize, fore, head); DrawMinus(surface, centreX, centreY, blobSize, tail); surface->PenColour(head); surface->MoveTo(centreX, centreY + blobSize); surface->LineTo(centreX, rcWhole.bottom); surface->PenColour(body); surface->MoveTo(centreX, rcWhole.top); surface->LineTo(centreX, centreY - blobSize); } else if (markType >= SC_MARK_CHARACTER) { char character[1]; character[0] = static_cast(markType - SC_MARK_CHARACTER); XYPOSITION width = surface->WidthText(fontForCharacter, character, 1); rc.left += (rc.Width() - width) / 2; rc.right = rc.left + width; surface->DrawTextClipped(rc, fontForCharacter, rc.bottom - 2, character, 1, fore, back); } else if (markType == SC_MARK_DOTDOTDOT) { int right = centreX - 6; for (int b=0; b<3; b++) { PRectangle rcBlob(right, rc.bottom - 4, right + 2, rc.bottom-2); surface->FillRectangle(rcBlob, fore); right += 5; } } else if (markType == SC_MARK_ARROWS) { surface->PenColour(fore); int right = centreX - 2; for (int b=0; b<3; b++) { surface->MoveTo(right - 4, centreY - 4); surface->LineTo(right, centreY); surface->LineTo(right - 5, centreY + 5); right += 4; } } else if (markType == SC_MARK_SHORTARROW) { Point pts[] = { Point(centreX, centreY + dimOn2), Point(centreX + dimOn2, centreY), Point(centreX, centreY - dimOn2), Point(centreX, centreY - dimOn4), Point(centreX - dimOn4, centreY - dimOn4), Point(centreX - dimOn4, centreY + dimOn4), Point(centreX, centreY + dimOn4), Point(centreX, centreY + dimOn2), }; surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]), fore, back); } else if (markType == SC_MARK_LEFTRECT) { PRectangle rcLeft = rcWhole; rcLeft.right = rcLeft.left + 4; surface->FillRectangle(rcLeft, back); } else { // SC_MARK_FULLRECT surface->FillRectangle(rcWhole, back); } } Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/PerLine.h000444001750001750 605412021352777 24111 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file PerLine.h ** Manages data associated with each line of the document **/ // Copyright 1998-2009 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef PERLINE_H #define PERLINE_H #ifdef SCI_NAMESPACE namespace Scintilla { #endif /** * This holds the marker identifier and the marker type to display. * MarkerHandleNumbers are members of lists. */ struct MarkerHandleNumber { int handle; int number; MarkerHandleNumber *next; }; /** * A marker handle set contains any number of MarkerHandleNumbers. */ class MarkerHandleSet { MarkerHandleNumber *root; public: MarkerHandleSet(); ~MarkerHandleSet(); int Length() const; int NumberFromHandle(int handle) const; int MarkValue() const; ///< Bit set of marker numbers. bool Contains(int handle) const; bool InsertHandle(int handle, int markerNum); void RemoveHandle(int handle); bool RemoveNumber(int markerNum); void CombineWith(MarkerHandleSet *other); }; class LineMarkers : public PerLine { SplitVector markers; /// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big. int handleCurrent; public: LineMarkers() : handleCurrent(0) { } virtual ~LineMarkers(); virtual void Init(); virtual void InsertLine(int line); virtual void RemoveLine(int line); int MarkValue(int line); int MarkerNext(int lineStart, int mask) const; int AddMark(int line, int marker, int lines); void MergeMarkers(int pos); bool DeleteMark(int line, int markerNum, bool all); void DeleteMarkFromHandle(int markerHandle); int LineFromHandle(int markerHandle); }; class LineLevels : public PerLine { SplitVector levels; public: virtual ~LineLevels(); virtual void Init(); virtual void InsertLine(int line); virtual void RemoveLine(int line); void ExpandLevels(int sizeNew=-1); void ClearLevels(); int SetLevel(int line, int level, int lines); int GetLevel(int line); }; class LineState : public PerLine { SplitVector lineStates; public: LineState() { } virtual ~LineState(); virtual void Init(); virtual void InsertLine(int line); virtual void RemoveLine(int line); int SetLineState(int line, int state); int GetLineState(int line); int GetMaxLineState(); }; class LineAnnotation : public PerLine { SplitVector annotations; public: LineAnnotation() { } virtual ~LineAnnotation(); virtual void Init(); virtual void InsertLine(int line); virtual void RemoveLine(int line); bool AnySet() const; bool MultipleStyles(int line) const; int Style(int line); const char *Text(int line) const; const unsigned char *Styles(int line) const; void SetText(int line, const char *text); void ClearAll(); void SetStyle(int line, int style); void SetStyles(int line, const unsigned char *styles); int Length(int line) const; int Lines(int line) const; }; #ifdef SCI_NAMESPACE } #endif #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexTADS3.cxx000444001750001750 11272212021352777 24455 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexTADS3.cxx ** Lexer for TADS3. **/ // Copyright 1998-2006 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. /* * TADS3 is a language designed by Michael J. Roberts for the writing of text * based games. TADS comes from Text Adventure Development System. It has good * support for the processing and outputting of formatted text and much of a * TADS program listing consists of strings. * * TADS has two types of strings, those enclosed in single quotes (') and those * enclosed in double quotes ("). These strings have different symantics and * can be given different highlighting if desired. * * There can be embedded within both types of strings html tags * ( ), library directives ( <.directive> ), and message * parameters ( {The doctor's/his} ). * * Double quoted strings can also contain interpolated expressions * ( << rug.moved ? ' and a hole in the floor. ' : nil >> ). These expressions * may themselves contain single or double quoted strings, although the double * quoted strings may not contain interpolated expressions. * * These embedded constructs influence the output and formatting and are an * important part of a program and require highlighting. * * LINKS * http://www.tads.org/ */ #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif static const int T3_SINGLE_QUOTE = 1; static const int T3_INT_EXPRESSION = 2; static const int T3_INT_EXPRESSION_IN_TAG = 4; static const int T3_HTML_SQUOTE = 8; static inline bool IsEOL(const int ch, const int chNext) { return (ch == '\r' && chNext != '\n') || (ch == '\n'); } /* * Test the current character to see if it's the START of an EOL sequence; * if so, skip ahead to the last character of the sequence and return true, * and if not just return false. There are a few places where we want to * check to see if a newline sequence occurs at a particular point, but * where a caller expects a subroutine to stop only upon reaching the END * of a newline sequence (in particular, CR-LF on Windows). That's why * IsEOL() above only returns true on CR if the CR isn't followed by an LF * - it doesn't want to admit that there's a newline until reaching the END * of the sequence. We meet both needs by saying that there's a newline * when we see the CR in a CR-LF, but skipping the CR before returning so * that the caller's caller will see that we've stopped at the LF. */ static inline bool IsEOLSkip(StyleContext &sc) { /* test for CR-LF */ if (sc.ch == '\r' && sc.chNext == '\n') { /* got CR-LF - skip the CR and indicate that we're at a newline */ sc.Forward(); return true; } /* * in other cases, we have at most a 1-character newline, so do the * normal IsEOL test */ return IsEOL(sc.ch, sc.chNext); } static inline bool IsATADS3Operator(const int ch) { return ch == '=' || ch == '{' || ch == '}' || ch == '(' || ch == ')' || ch == '[' || ch == ']' || ch == ',' || ch == ':' || ch == ';' || ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '%' || ch == '?' || ch == '!' || ch == '<' || ch == '>' || ch == '|' || ch == '@' || ch == '&' || ch == '~'; } static inline bool IsAWordChar(const int ch) { return isalnum(ch) || ch == '_'; } static inline bool IsAWordStart(const int ch) { return isalpha(ch) || ch == '_'; } static inline bool IsAHexDigit(const int ch) { int lch = tolower(ch); return isdigit(lch) || lch == 'a' || lch == 'b' || lch == 'c' || lch == 'd' || lch == 'e' || lch == 'f'; } static inline bool IsAnHTMLChar(int ch) { return isalnum(ch) || ch == '-' || ch == '_' || ch == '.'; } static inline bool IsADirectiveChar(int ch) { return isalnum(ch) || isspace(ch) || ch == '-' || ch == '/'; } static inline bool IsANumberStart(StyleContext &sc) { return isdigit(sc.ch) || (!isdigit(sc.chPrev) && sc.ch == '.' && isdigit(sc.chNext)); } inline static void ColouriseTADS3Operator(StyleContext &sc) { int initState = sc.state; int c = sc.ch; sc.SetState(c == '{' || c == '}' ? SCE_T3_BRACE : SCE_T3_OPERATOR); sc.ForwardSetState(initState); } static void ColouriseTADSHTMLString(StyleContext &sc, int &lineState) { int endState = sc.state; int chQuote = sc.ch; int chString = (lineState & T3_SINGLE_QUOTE) ? '\'' : '"'; if (endState == SCE_T3_HTML_STRING) { if (lineState&T3_SINGLE_QUOTE) { endState = SCE_T3_S_STRING; chString = '\''; } else if (lineState&T3_INT_EXPRESSION) { endState = SCE_T3_X_STRING; chString = '"'; } else { endState = SCE_T3_HTML_DEFAULT; chString = '"'; } chQuote = (lineState & T3_HTML_SQUOTE) ? '\'' : '"'; } else { sc.SetState(SCE_T3_HTML_STRING); sc.Forward(); } if (chQuote == '"') lineState &= ~T3_HTML_SQUOTE; else lineState |= T3_HTML_SQUOTE; while (sc.More()) { if (IsEOL(sc.ch, sc.chNext)) { return; } if (sc.ch == chQuote) { sc.ForwardSetState(endState); return; } if (sc.Match('\\', static_cast(chQuote))) { sc.Forward(2); sc.SetState(endState); return; } if (sc.ch == chString) { sc.SetState(SCE_T3_DEFAULT); return; } if (sc.Match('<', '<')) { lineState |= T3_INT_EXPRESSION | T3_INT_EXPRESSION_IN_TAG; sc.SetState(SCE_T3_X_DEFAULT); sc.Forward(2); return; } if (sc.Match('\\', static_cast(chQuote)) || sc.Match('\\', static_cast(chString)) || sc.Match('\\', '\\')) { sc.Forward(2); } else { sc.Forward(); } } } static void ColouriseTADS3HTMLTagStart(StyleContext &sc) { sc.SetState(SCE_T3_HTML_TAG); sc.Forward(); if (sc.ch == '/') { sc.Forward(); } while (IsAnHTMLChar(sc.ch)) { sc.Forward(); } } static void ColouriseTADS3HTMLTag(StyleContext &sc, int &lineState) { int endState = sc.state; int chQuote = '"'; int chString = '\''; switch (endState) { case SCE_T3_S_STRING: ColouriseTADS3HTMLTagStart(sc); sc.SetState(SCE_T3_HTML_DEFAULT); chQuote = '\''; chString = '"'; break; case SCE_T3_D_STRING: case SCE_T3_X_STRING: ColouriseTADS3HTMLTagStart(sc); sc.SetState(SCE_T3_HTML_DEFAULT); break; case SCE_T3_HTML_DEFAULT: if (lineState&T3_SINGLE_QUOTE) { endState = SCE_T3_S_STRING; chQuote = '\''; chString = '"'; } else if (lineState&T3_INT_EXPRESSION) { endState = SCE_T3_X_STRING; } else { endState = SCE_T3_D_STRING; } break; } while (sc.More()) { if (IsEOL(sc.ch, sc.chNext)) { return; } if (sc.Match('/', '>')) { sc.SetState(SCE_T3_HTML_TAG); sc.Forward(2); sc.SetState(endState); return; } if (sc.ch == '>') { sc.SetState(SCE_T3_HTML_TAG); sc.ForwardSetState(endState); return; } if (sc.ch == chQuote) { sc.SetState(endState); return; } if (sc.Match('\\', static_cast(chQuote))) { sc.Forward(); ColouriseTADSHTMLString(sc, lineState); if (sc.state == SCE_T3_X_DEFAULT) break; } else if (sc.ch == chString) { ColouriseTADSHTMLString(sc, lineState); } else if (sc.ch == '=') { ColouriseTADS3Operator(sc); } else { sc.Forward(); } } } static void ColouriseTADS3Keyword(StyleContext &sc, WordList *keywordlists[], unsigned int endPos) { char s[250]; WordList &keywords = *keywordlists[0]; WordList &userwords1 = *keywordlists[1]; WordList &userwords2 = *keywordlists[2]; WordList &userwords3 = *keywordlists[3]; int initState = sc.state; sc.SetState(SCE_T3_IDENTIFIER); while (sc.More() && (IsAWordChar(sc.ch))) { sc.Forward(); } sc.GetCurrent(s, sizeof(s)); if ( strcmp(s, "is") == 0 || strcmp(s, "not") == 0) { // have to find if "in" is next int n = 1; while (n + sc.currentPos < endPos && IsASpaceOrTab(sc.GetRelative(n))) n++; if (sc.GetRelative(n) == 'i' && sc.GetRelative(n+1) == 'n') { sc.Forward(n+2); sc.ChangeState(SCE_T3_KEYWORD); } } else if (keywords.InList(s)) { sc.ChangeState(SCE_T3_KEYWORD); } else if (userwords3.InList(s)) { sc.ChangeState(SCE_T3_USER3); } else if (userwords2.InList(s)) { sc.ChangeState(SCE_T3_USER2); } else if (userwords1.InList(s)) { sc.ChangeState(SCE_T3_USER1); } sc.SetState(initState); } static void ColouriseTADS3MsgParam(StyleContext &sc, int &lineState) { int endState = sc.state; int chQuote = '"'; switch (endState) { case SCE_T3_S_STRING: sc.SetState(SCE_T3_MSG_PARAM); sc.Forward(); chQuote = '\''; break; case SCE_T3_D_STRING: case SCE_T3_X_STRING: sc.SetState(SCE_T3_MSG_PARAM); sc.Forward(); break; case SCE_T3_MSG_PARAM: if (lineState&T3_SINGLE_QUOTE) { endState = SCE_T3_S_STRING; chQuote = '\''; } else if (lineState&T3_INT_EXPRESSION) { endState = SCE_T3_X_STRING; } else { endState = SCE_T3_D_STRING; } break; } while (sc.More() && sc.ch != '}' && sc.ch != chQuote) { if (IsEOL(sc.ch, sc.chNext)) { return; } if (sc.ch == '\\') { sc.Forward(); } sc.Forward(); } if (sc.ch == chQuote) { sc.SetState(endState); } else { sc.ForwardSetState(endState); } } static void ColouriseTADS3LibDirective(StyleContext &sc, int &lineState) { int initState = sc.state; int chQuote = '"'; switch (initState) { case SCE_T3_S_STRING: sc.SetState(SCE_T3_LIB_DIRECTIVE); sc.Forward(2); chQuote = '\''; break; case SCE_T3_D_STRING: sc.SetState(SCE_T3_LIB_DIRECTIVE); sc.Forward(2); break; case SCE_T3_LIB_DIRECTIVE: if (lineState&T3_SINGLE_QUOTE) { initState = SCE_T3_S_STRING; chQuote = '\''; } else { initState = SCE_T3_D_STRING; } break; } while (sc.More() && IsADirectiveChar(sc.ch)) { if (IsEOL(sc.ch, sc.chNext)) { return; } sc.Forward(); }; if (sc.ch == '>' || !sc.More()) { sc.ForwardSetState(initState); } else if (sc.ch == chQuote) { sc.SetState(initState); } else { sc.ChangeState(initState); sc.Forward(); } } static void ColouriseTADS3String(StyleContext &sc, int &lineState) { int chQuote = sc.ch; int endState = sc.state; switch (sc.state) { case SCE_T3_DEFAULT: case SCE_T3_X_DEFAULT: if (chQuote == '"') { if (sc.state == SCE_T3_DEFAULT) { sc.SetState(SCE_T3_D_STRING); } else { sc.SetState(SCE_T3_X_STRING); } lineState &= ~T3_SINGLE_QUOTE; } else { sc.SetState(SCE_T3_S_STRING); lineState |= T3_SINGLE_QUOTE; } sc.Forward(); break; case SCE_T3_S_STRING: chQuote = '\''; endState = lineState&T3_INT_EXPRESSION ? SCE_T3_X_DEFAULT : SCE_T3_DEFAULT; break; case SCE_T3_D_STRING: chQuote = '"'; endState = SCE_T3_DEFAULT; break; case SCE_T3_X_STRING: chQuote = '"'; endState = SCE_T3_X_DEFAULT; break; } while (sc.More()) { if (IsEOL(sc.ch, sc.chNext)) { return; } if (sc.ch == chQuote) { sc.ForwardSetState(endState); return; } if (sc.state == SCE_T3_D_STRING && sc.Match('<', '<')) { lineState |= T3_INT_EXPRESSION; sc.SetState(SCE_T3_X_DEFAULT); sc.Forward(2); return; } if (sc.Match('\\', static_cast(chQuote)) || sc.Match('\\', '\\')) { sc.Forward(2); } else if (sc.ch == '{') { ColouriseTADS3MsgParam(sc, lineState); } else if (sc.Match('<', '.')) { ColouriseTADS3LibDirective(sc, lineState); } else if (sc.ch == '<') { ColouriseTADS3HTMLTag(sc, lineState); if (sc.state == SCE_T3_X_DEFAULT) return; } else { sc.Forward(); } } } static void ColouriseTADS3Comment(StyleContext &sc, int endState) { sc.SetState(SCE_T3_BLOCK_COMMENT); while (sc.More()) { if (IsEOL(sc.ch, sc.chNext)) { return; } if (sc.Match('*', '/')) { sc.Forward(2); sc.SetState(endState); return; } sc.Forward(); } } static void ColouriseToEndOfLine(StyleContext &sc, int initState, int endState) { sc.SetState(initState); while (sc.More()) { if (sc.ch == '\\') { sc.Forward(); if (IsEOLSkip(sc)) { return; } } if (IsEOL(sc.ch, sc.chNext)) { sc.SetState(endState); return; } sc.Forward(); } } static void ColouriseTADS3Number(StyleContext &sc) { int endState = sc.state; bool inHexNumber = false; bool seenE = false; bool seenDot = sc.ch == '.'; sc.SetState(SCE_T3_NUMBER); if (sc.More()) { sc.Forward(); } if (sc.chPrev == '0' && tolower(sc.ch) == 'x') { inHexNumber = true; sc.Forward(); } while (sc.More()) { if (inHexNumber) { if (!IsAHexDigit(sc.ch)) { break; } } else if (!isdigit(sc.ch)) { if (!seenE && tolower(sc.ch) == 'e') { seenE = true; seenDot = true; if (sc.chNext == '+' || sc.chNext == '-') { sc.Forward(); } } else if (!seenDot && sc.ch == '.') { seenDot = true; } else { break; } } sc.Forward(); } sc.SetState(endState); } static void ColouriseTADS3Doc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { int visibleChars = 0; int bracketLevel = 0; int lineState = 0; unsigned int endPos = startPos + length; int lineCurrent = styler.GetLine(startPos); if (lineCurrent > 0) { lineState = styler.GetLineState(lineCurrent-1); } StyleContext sc(startPos, length, initStyle, styler); while (sc.More()) { if (IsEOL(sc.ch, sc.chNext)) { styler.SetLineState(lineCurrent, lineState); lineCurrent++; visibleChars = 0; sc.Forward(); if (sc.ch == '\n') { sc.Forward(); } } switch(sc.state) { case SCE_T3_PREPROCESSOR: case SCE_T3_LINE_COMMENT: ColouriseToEndOfLine(sc, sc.state, lineState&T3_INT_EXPRESSION ? SCE_T3_X_DEFAULT : SCE_T3_DEFAULT); break; case SCE_T3_S_STRING: case SCE_T3_D_STRING: case SCE_T3_X_STRING: ColouriseTADS3String(sc, lineState); visibleChars++; break; case SCE_T3_MSG_PARAM: ColouriseTADS3MsgParam(sc, lineState); break; case SCE_T3_LIB_DIRECTIVE: ColouriseTADS3LibDirective(sc, lineState); break; case SCE_T3_HTML_DEFAULT: ColouriseTADS3HTMLTag(sc, lineState); break; case SCE_T3_HTML_STRING: ColouriseTADSHTMLString(sc, lineState); break; case SCE_T3_BLOCK_COMMENT: ColouriseTADS3Comment(sc, lineState&T3_INT_EXPRESSION ? SCE_T3_X_DEFAULT : SCE_T3_DEFAULT); break; case SCE_T3_DEFAULT: case SCE_T3_X_DEFAULT: if (IsASpaceOrTab(sc.ch)) { sc.Forward(); } else if (sc.ch == '#' && visibleChars == 0) { ColouriseToEndOfLine(sc, SCE_T3_PREPROCESSOR, sc.state); } else if (sc.Match('/', '*')) { ColouriseTADS3Comment(sc, sc.state); visibleChars++; } else if (sc.Match('/', '/')) { ColouriseToEndOfLine(sc, SCE_T3_LINE_COMMENT, sc.state); } else if (sc.ch == '"') { bracketLevel = 0; ColouriseTADS3String(sc, lineState); visibleChars++; } else if (sc.ch == '\'') { ColouriseTADS3String(sc, lineState); visibleChars++; } else if (sc.state == SCE_T3_X_DEFAULT && bracketLevel == 0 && sc.Match('>', '>')) { sc.Forward(2); sc.SetState(SCE_T3_D_STRING); if (lineState & T3_INT_EXPRESSION_IN_TAG) sc.SetState(SCE_T3_HTML_STRING); lineState &= ~(T3_SINGLE_QUOTE|T3_INT_EXPRESSION |T3_INT_EXPRESSION_IN_TAG); } else if (IsATADS3Operator(sc.ch)) { if (sc.state == SCE_T3_X_DEFAULT) { if (sc.ch == '(') { bracketLevel++; } else if (sc.ch == ')' && bracketLevel > 0) { bracketLevel--; } } ColouriseTADS3Operator(sc); visibleChars++; } else if (IsANumberStart(sc)) { ColouriseTADS3Number(sc); visibleChars++; } else if (IsAWordStart(sc.ch)) { ColouriseTADS3Keyword(sc, keywordlists, endPos); visibleChars++; } else if (sc.Match("...")) { sc.SetState(SCE_T3_IDENTIFIER); sc.Forward(3); sc.SetState(SCE_T3_DEFAULT); } else { sc.Forward(); visibleChars++; } break; default: sc.SetState(SCE_T3_DEFAULT); sc.Forward(); } } sc.Complete(); } /* TADS3 has two styles of top level block (TLB). Eg // default style silverKey : Key 'small silver key' 'small silver key' "A small key glints in the sunlight. " ; and silverKey : Key { 'small silver key' 'small silver key' "A small key glints in the sunlight. " } Some constructs mandate one or the other, but usually the author has may choose either. T3_SEENSTART is used to indicate that a braceless TLB has been (potentially) seen and is also used to match the closing ';' of the default style. T3_EXPECTINGIDENTIFIER and T3_EXPECTINGPUNCTUATION are used to keep track of what characters may be seen without incrementing the block level. The general pattern is identifier identifier, acceptable punctuation characters are ':', ',', '(' and ')'. No attempt is made to ensure that punctuation characters are syntactically correct, eg parentheses match. A ')' always signifies the start of a block. We just need to check if it is followed by a '{', in which case we let the brace handling code handle the folding level. expectingIdentifier == false && expectingIdentifier == false Before the start of a TLB. expectingIdentifier == true && expectingIdentifier == true Currently in an identifier. Will accept identifier or punctuation. expectingIdentifier == true && expectingIdentifier == false Just seen a punctuation character & now waiting for an identifier to start. expectingIdentifier == false && expectingIdentifier == truee We were in an identifier and have seen space. Now waiting to see a punctuation character Space, comments & preprocessor directives are always acceptable and are equivalent. */ static const int T3_SEENSTART = 1 << 12; static const int T3_EXPECTINGIDENTIFIER = 1 << 13; static const int T3_EXPECTINGPUNCTUATION = 1 << 14; static inline bool IsStringTransition(int s1, int s2) { return s1 != s2 && (s1 == SCE_T3_S_STRING || s1 == SCE_T3_X_STRING || (s1 == SCE_T3_D_STRING && s2 != SCE_T3_X_DEFAULT)) && s2 != SCE_T3_LIB_DIRECTIVE && s2 != SCE_T3_MSG_PARAM && s2 != SCE_T3_HTML_TAG && s2 != SCE_T3_HTML_STRING; } static inline bool IsATADS3Punctuation(const int ch) { return ch == ':' || ch == ',' || ch == '(' || ch == ')'; } static inline bool IsAnIdentifier(const int style) { return style == SCE_T3_IDENTIFIER || style == SCE_T3_USER1 || style == SCE_T3_USER2 || style == SCE_T3_USER3; } static inline bool IsAnOperator(const int style) { return style == SCE_T3_OPERATOR || style == SCE_T3_BRACE; } static inline bool IsSpaceEquivalent(const int ch, const int style) { return isspace(ch) || style == SCE_T3_BLOCK_COMMENT || style == SCE_T3_LINE_COMMENT || style == SCE_T3_PREPROCESSOR; } static char peekAhead(unsigned int startPos, unsigned int endPos, Accessor &styler) { for (unsigned int i = startPos; i < endPos; i++) { int style = styler.StyleAt(i); char ch = styler[i]; if (!IsSpaceEquivalent(ch, style)) { if (IsAnIdentifier(style)) { return 'a'; } if (IsATADS3Punctuation(ch)) { return ':'; } if (ch == '{') { return '{'; } return '*'; } } return ' '; } static void FoldTADS3Doc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { unsigned int endPos = startPos + length; int lineCurrent = styler.GetLine(startPos); int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; int seenStart = levelCurrent & T3_SEENSTART; int expectingIdentifier = levelCurrent & T3_EXPECTINGIDENTIFIER; int expectingPunctuation = levelCurrent & T3_EXPECTINGPUNCTUATION; levelCurrent &= SC_FOLDLEVELNUMBERMASK; int levelMinCurrent = levelCurrent; int levelNext = levelCurrent; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; char ch = chNext; int stylePrev = style; bool redo = false; for (unsigned int i = startPos; i < endPos; i++) { if (redo) { redo = false; i--; } else { ch = chNext; chNext = styler.SafeGetCharAt(i + 1); stylePrev = style; style = styleNext; styleNext = styler.StyleAt(i + 1); } bool atEOL = IsEOL(ch, chNext); if (levelNext == SC_FOLDLEVELBASE) { if (IsSpaceEquivalent(ch, style)) { if (expectingPunctuation) { expectingIdentifier = 0; } if (style == SCE_T3_BLOCK_COMMENT) { levelNext++; } } else if (ch == '{') { levelNext++; seenStart = 0; } else if (ch == '\'' || ch == '"' || ch == '[') { levelNext++; if (seenStart) { redo = true; } } else if (ch == ';') { seenStart = 0; expectingIdentifier = 0; expectingPunctuation = 0; } else if (expectingIdentifier && expectingPunctuation) { if (IsATADS3Punctuation(ch)) { if (ch == ')' && peekAhead(i+1, endPos, styler) != '{') { levelNext++; } else { expectingPunctuation = 0; } } else if (!IsAnIdentifier(style)) { levelNext++; } } else if (expectingIdentifier && !expectingPunctuation) { if (!IsAnIdentifier(style)) { levelNext++; } else { expectingPunctuation = T3_EXPECTINGPUNCTUATION; } } else if (!expectingIdentifier && expectingPunctuation) { if (!IsATADS3Punctuation(ch)) { levelNext++; } else { if (ch == ')' && peekAhead(i+1, endPos, styler) != '{') { levelNext++; } else { expectingIdentifier = T3_EXPECTINGIDENTIFIER; expectingPunctuation = 0; } } } else if (!expectingIdentifier && !expectingPunctuation) { if (IsAnIdentifier(style)) { seenStart = T3_SEENSTART; expectingIdentifier = T3_EXPECTINGIDENTIFIER; expectingPunctuation = T3_EXPECTINGPUNCTUATION; } } if (levelNext != SC_FOLDLEVELBASE && style != SCE_T3_BLOCK_COMMENT) { expectingIdentifier = 0; expectingPunctuation = 0; } } else if (levelNext == SC_FOLDLEVELBASE+1 && seenStart && ch == ';' && IsAnOperator(style)) { levelNext--; seenStart = 0; } else if (style == SCE_T3_BLOCK_COMMENT) { if (stylePrev != SCE_T3_BLOCK_COMMENT) { levelNext++; } else if (styleNext != SCE_T3_BLOCK_COMMENT && !atEOL) { // Comments don't end at end of line and the next character may be unstyled. levelNext--; } } else if (ch == '\'' || ch == '"') { if (IsStringTransition(style, stylePrev)) { if (levelMinCurrent > levelNext) { levelMinCurrent = levelNext; } levelNext++; } else if (IsStringTransition(style, styleNext)) { levelNext--; } } else if (IsAnOperator(style)) { if (ch == '{' || ch == '[') { // Measure the minimum before a '{' to allow // folding on "} else {" if (levelMinCurrent > levelNext) { levelMinCurrent = levelNext; } levelNext++; } else if (ch == '}' || ch == ']') { levelNext--; } } if (atEOL) { if (seenStart && levelNext == SC_FOLDLEVELBASE) { switch (peekAhead(i+1, endPos, styler)) { case ' ': case '{': break; case '*': levelNext++; break; case 'a': if (expectingPunctuation) { levelNext++; } break; case ':': if (expectingIdentifier) { levelNext++; } break; } if (levelNext != SC_FOLDLEVELBASE) { expectingIdentifier = 0; expectingPunctuation = 0; } } int lev = levelMinCurrent | (levelNext | expectingIdentifier | expectingPunctuation | seenStart) << 16; if (levelMinCurrent < levelNext) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) { styler.SetLevel(lineCurrent, lev); } lineCurrent++; levelCurrent = levelNext; levelMinCurrent = levelCurrent; } } } static const char * const tads3WordList[] = { "TADS3 Keywords", "User defined 1", "User defined 2", "User defined 3", 0 }; LexerModule lmTADS3(SCLEX_TADS3, ColouriseTADS3Doc, "tads3", FoldTADS3Doc, tads3WordList); Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/Accessor.h000444001750001750 157412021352777 24317 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file Accessor.h ** Interfaces between Scintilla and lexers. **/ // Copyright 1998-2010 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef ACCESSOR_H #define ACCESSOR_H #ifdef SCI_NAMESPACE namespace Scintilla { #endif enum { wsSpace = 1, wsTab = 2, wsSpaceTab = 4, wsInconsistent=8}; class Accessor; class WordList; class PropSetSimple; typedef bool (*PFNIsCommentLeader)(Accessor &styler, int pos, int len); class Accessor : public LexAccessor { public: PropSetSimple *pprops; Accessor(IDocument *pAccess_, PropSetSimple *pprops_); int GetPropertyInt(const char *, int defaultValue=0); int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0); }; #ifdef SCI_NAMESPACE } #endif #endif Wx-Scintilla-0.39/wx-scintilla/src/scintilla/src/LexLua.cxx000444001750001750 3337412021352777 24345 0ustar00azawawiazawawi000000000000// Scintilla source code edit control /** @file LexLua.cxx ** Lexer for Lua language. ** ** Written by Paul Winwood. ** Folder by Alexey Yutkin. ** Modified by Marcos E. Wurzius & Philippe Lhoste **/ #include #include #include #include #include #include #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif // Test for [=[ ... ]=] delimiters, returns 0 if it's only a [ or ], // return 1 for [[ or ]], returns >=2 for [=[ or ]=] and so on. // The maximum number of '=' characters allowed is 254. static int LongDelimCheck(StyleContext &sc) { int sep = 1; while (sc.GetRelative(sep) == '=' && sep < 0xFF) sep++; if (sc.GetRelative(sep) == sc.ch) return sep; return 0; } static void ColouriseLuaDoc( unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; WordList &keywords3 = *keywordlists[2]; WordList &keywords4 = *keywordlists[3]; WordList &keywords5 = *keywordlists[4]; WordList &keywords6 = *keywordlists[5]; WordList &keywords7 = *keywordlists[6]; WordList &keywords8 = *keywordlists[7]; // Accepts accented characters CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true); CharacterSet setWord(CharacterSet::setAlphaNum, "_", 0x80, true); // Not exactly following number definition (several dots are seen as OK, etc.) // but probably enough in most cases. [pP] is for hex floats. CharacterSet setNumber(CharacterSet::setDigits, ".-+abcdefpABCDEFP"); CharacterSet setExponent(CharacterSet::setNone, "eEpP"); CharacterSet setLuaOperator(CharacterSet::setNone, "*/-+()={}~[];<>,.^%:#"); CharacterSet setEscapeSkip(CharacterSet::setNone, "\"'\\"); int currentLine = styler.GetLine(startPos); // Initialize long string [[ ... ]] or block comment --[[ ... ]] nesting level, // if we are inside such a string. Block comment was introduced in Lua 5.0, // blocks with separators [=[ ... ]=] in Lua 5.1. // Continuation of a string (\z whitespace escaping) is controlled by stringWs. int nestLevel = 0; int sepCount = 0; int stringWs = 0; if (initStyle == SCE_LUA_LITERALSTRING || initStyle == SCE_LUA_COMMENT || initStyle == SCE_LUA_STRING || initStyle == SCE_LUA_CHARACTER) { int lineState = styler.GetLineState(currentLine - 1); nestLevel = lineState >> 9; sepCount = lineState & 0xFF; stringWs = lineState & 0x100; } // Do not leak onto next line if (initStyle == SCE_LUA_STRINGEOL || initStyle == SCE_LUA_COMMENTLINE || initStyle == SCE_LUA_PREPROCESSOR) { initStyle = SCE_LUA_DEFAULT; } StyleContext sc(startPos, length, initStyle, styler); if (startPos == 0 && sc.ch == '#') { // shbang line: # is a comment only if first char of the script sc.SetState(SCE_LUA_COMMENTLINE); } for (; sc.More(); sc.Forward()) { if (sc.atLineEnd) { // Update the line state, so it can be seen by next line currentLine = styler.GetLine(sc.currentPos); switch (sc.state) { case SCE_LUA_LITERALSTRING: case SCE_LUA_COMMENT: case SCE_LUA_STRING: case SCE_LUA_CHARACTER: // Inside a literal string, block comment or string, we set the line state styler.SetLineState(currentLine, (nestLevel << 9) | stringWs | sepCount); break; default: // Reset the line state styler.SetLineState(currentLine, 0); break; } } if (sc.atLineStart && (sc.state == SCE_LUA_STRING)) { // Prevent SCE_LUA_STRINGEOL from leaking back to previous line sc.SetState(SCE_LUA_STRING); } // Handle string line continuation if ((sc.state == SCE_LUA_STRING || sc.state == SCE_LUA_CHARACTER) && sc.ch == '\\') { if (sc.chNext == '\n' || sc.chNext == '\r') { sc.Forward(); if (sc.ch == '\r' && sc.chNext == '\n') { sc.Forward(); } continue; } } // Determine if the current state should terminate. if (sc.state == SCE_LUA_OPERATOR) { if (sc.ch == ':' && sc.chPrev == ':') { // ::