
These classes provides a MFC wrapping for the Scintilla edit control (http://scintilla.sourceforge.net).
This control provides an open source cross platform edit control. Some of the
features it provides include syntax colouring, call tips, brace highlighting,
Styles, margins and markers to name but a few. The provided wrapper classes make
it easier to include the control in MFC projects on Windows.
Features
- Implements all the
functionality provided by Scintilla v1.76.
- The CScintillaCtrl wrapper class observes the same
semantics as the built in MFC "CEdit" wrapper class.
- Uses the direct access functions provided by scintilla
to improve performance. Multi threaded code can still use SendMessage by
specifying FALSE for the bDirect parameter in the wrapper methods of
CScintillaCtrl.
- The generation of the wrapper class methods are created
using a Windows script file "ConvertScintillaiface.js" included in the
download. This allows the class to be easily updated when new versions of
Scintilla are released.
- The CScintillaView and CScintillaDoc classes provide a
complete doc / view implementation which can be dropped into an existing
project instead of the built in MFC rich edit or edit control classes.
- Provides built in MFC persistence support.
- All notifications sent using WM_NOTIFY and
WM_COMMAND are mapped to easier to use C++ virtual functions in the view
wrapper class.
- The CScintillaView class provides a default folding
implementation.
- Includes full "Find and Replace" support including the
regular expression support provided by Scintilla. To achieve this a
"CScintillaFindReplaceDlg" class is implemented which derives from the
standard MFC "CFindReplaceDialog".
- Includes a complete MFC printing implementation in
CScintillaView.
- Includes complete support for standard Page Setup
dialog and print margins.
- Includes a framework for Print headers and footers.
- Includes support for all the standard MFC menu items,
such as Cut, Copy, Paste etc.
- The sample app demonstrates how top level messages
should be forwarded to the Scintilla control.
- The sample app also demonstrates how you would
implement autocompletion and call tips in your code.
- The classes hide the fact that Scintilla does not natively support
Windows Unicode (aka UTF16 or UCS-2). The way Scintilla supports Unicode is
through a UTF8 API. The "CScintillaCtrl" wrapper class looks after the
details of setting up the Unicode code page for Scintilla and the
translation to and from UTF8 strings. If you take a look at the "ScintillaCtrl.h"
header file, you will see a section which includes widechar string versions
of the functions in Scintilla which involves string parameters. These
widechar string functions are wrapped in a "_UNICODE" pre-processor
#ifdef.
Internally, these functions perform the thunking required to map between
Windows Unicode and the UTF8 API of Scintilla. Please note that
to perform this thunking the code uses the UTF8 translation functionality
provided by the "WideCharToMultiByte" and "MultiByteToWideChar" Win32 API
calls. Please note that UTF8 support for these Win32 API calls is limited to
Windows 98, Windows ME, Windows NT 4.0 or later. This does mean that it is
not possible to use the wrapper classes for Unicode on Windows 95 (if you
were to arrange to use the Microsoft Layer for Unicode aka Unicows). This
should not be an inconvenience for many people. Also note that this new
functionality which was introduced in v1.15 in no way prevents the wrapper
classes from being fully used if you were to use them in non Unicode mode on
Windows 9x.
The
enclosed zip file contains the
wrapper class source code and a simple MFC demo application which
exercises the classes functionality.
Copyright
- You are allowed to include the source code in
any product (commercial, shareware, freeware or otherwise) when your product
is released in binary form.
- You are allowed to modify the source code in
any way you want except you cannot modify the copyright details at the top
of each module.
- If you want to distribute source code with
your application, then you are only allowed to distribute versions released
by the author. This is to maintain a single distribution point for the
source code.
Updates
V1.0 (17 July 1998)
V1.01 (18 March 2004)
- Updated the sample app's Find Next and Find Previous
marker functions. Now correctly goes to the next and previous markers when a
marker is on the current line.
- Updated the sample app's passing of messages to
Scintilla from the top level CMainFrame window.
V1.02 (6 June 2004)
- Updated class to work with Scintilla v1.61.
V1.03 (13 August 2004)
- Made all the remaining non virtual functions related to
Find and Replace in CScintillaView virtual.
- CScintillaView::TextNotFound function is now passed the
parameters used for the search. Thanks to Dmitry Naumov for this update.
- Removed the CScintillaView::OnTextNotFound function as
all the work for it is achieved using the TextNotFound function.
- Creation of the find / replace dialog now takes place
in a new virtual function "CScintillaViewCreateFindReplaceDialog". Again
thanks to Dmitry Naumov for this update.
V1.04 (20 December 2004)
- Updated class to work with Scintilla v1.62.
- Sample app now includes a common control 6 manifest
- Sample app now includes an example of scintilla
autocompletion. When you type "scintilla is " case insensitively a
autocompletion list is displayed which allows "very cool",
"easy" or "way cool!!" to be entered.
- Sample app now includes an example of scintilla
calltips. Whenever you hover over text which is "author " case
insensitively, a call tip with the text "PJ Naughter" is
displayed.
V1.05 (4 March 2005)
- Fix in CScintillaView::PrintPage which now sorts out the issue of print preview not working in the MFC doc / view wrappers for scintilla. Thanks to Frank Kiesel for reporting this fix.
30 May 2005
- Updated the sample app to show how to handle cancel
call tips if a view loses focus, is sized or moved. This is achieved by
handling WM_ACTIVATE in the view class and WM_SIZE and WM_MOVE in the child
frame class. Thanks to Markus Werle for spotting this issue.
V1.06 (10 July 2005)
- Addition of a virtual function namely OnAutoCSelection
which handles the SCN_AUTOCSELECTION notification message which was
introduced in Scintilla v1.63. Thanks to Dan Petitt for suggesting this
update.
- Updated class to work with Scintilla v1.64.
- A new boolean variable called
"m_bUseROFileAttributeDuringLoading" has been added to
CScintillaView. If this value is set then the code will check the read only
file attribute of the file being loaded and if it is set, then the document
is marked as read only by Scintilla. By doing this any attempts to modify
the document will cause the OnModifyAttemptRO virtual function to be called.
This allows you to prompt to make the file read write or to check out the
file from a version control system. Thanks to Dan Petitt for suggesting this
update.
- Demo app now demonstrates how to use the
SCN_MODIFYATTEMPTRO notification.
- Fixed a number of warnings when the code is compiled
using Visual Studio .NET 2003.
- SetSavePoint and SetReadOnly calls are now made in CScintillaDoc::OnSaveDocument instead of CScintillaView::Serialize. This ensures that the control is only reset upon a successful save.
V1.07 (3 January 2006)
- Updated class to work with Scintilla v1.67. New messages wrapped
include: SCI_MARKERADDSET, SCI_SETPASTECONVERTENDINGS,
SCI_GETPASTECONVERTENDINGS, SCI_SELECTIONDUPLICATE and
SCI_GETSTYLEBITSNEEDED.
- Updated copyright messages
- Fixed a bug where the separator line in the header was not being drawn
due to issues in the code which calculates the coordinates.
- Added two member variables which decide whether printer headers and
footers should be printed (CScintillaView::m_bPrintHeader and
CScintillaView::m_bPrintFooter). You could of course achieve the same result
by deriving a class from CScintillaView and implementing empty PrintHeader
and PrinterFooter methods!!!. Thanks to Jason Elliott for suggesting this
update.
- Optimized the construction of member variables in
CScintillaView::CScintillaView and in
CScintillaFindReplaceDlg::CScintillaFindReplaceDlg
- CScintillaView::OnReplaceAll sets the selection to 0,0 before doing text
replacement. This ensures that all text in a document is replaced. Also this
function now does not bother calling TextNotFound at the end of the function
if replacements took place. Thanks to Jason Elliott for this nice update.
- A parameter which indicates whether text is being replaced or found is
now sent to CScintillaView::TextNotFound.
V1.08 (6 January 2006)
- Removed some unnecessary code from CScintillaView::OnEndPrinting. Thanks
to Greg Smith for spotting this issue.
- Updated the documentation to use the same style as the web site
V1.09 (8 January 2006)
- Find / Replace dialog and associated state is now maintained outside of
CScintillaView. This means that if you have multiple CScintillaView's in
your app, that they share the one find / replace dialog which is the
standard type of UI you would normally expect for this. Thanks to Greg Smith
for reporting this issue.
- Find / replace dialog is now closed when the last CScintillaView is
destroyed. Thanks to Greg Smith for reporting this issue.
V1.10 (16 January 2006)
- Removed an unused "rSetup" variable in CScintillaView::PrintPage
- Optimized code in CScintillaView::PrintPage and
CScintillaView::OnFilePageSetup which determines if metric or imperial
measurements are being used. Now a boolean member variable of CScintillaView
called m_bUsingMetric which by default picks up the control panel preference
is provided. This allows client code to change this value to customize how
measurements are specified. Thanks to Greg Smith for reporting this issue.
- Fixed a small typo in CScintillaView::PrintHeader and PrintFooter. Also
explicitly uses the TA_TOP flag in combination with TA_LEFT when setting
alignment settings for header and footer text. Again thanks to Greg Smith
for reporting this.
- Scintilla find / replace state is now stored in a standard global
variable instead of using the CProcessLocal template which it was using
previously. This is no longer required since it was used to provide Win32s
support for MFC on older versions of MFC. Since Win32s is no longer
supported by MFC, there is no need to use this mechanism any more.
V1.11 (2 February 2006)
- Minor update to CScintillaView to allow deletion of text when there is
nothing selected. Thanks to Alexander Kirillov for reporting this bug.
V1.12 (14 March 2006)
- Updated class to work with Scintilla v1.68. New messages wrapped
include: SCI_CALLTIPUSESTYLE, SCI_SETCARETLINEBACKALPHA and
SCI_GETCARETLINEBACKALPHA.
- Updated the internal function CScintillaView::SameAsSelected to support
regular expressions. Thanks to Greg Smith for this update.
V1.13 (22 May 2006)
- Fixed a flicker issue when the CScintillaView is resized. Thanks to Michael Gunlock
for reporting this issue.
V1.14 (5 June 2006)
- Updated class to work with Scintilla v1.69. New messages wrapped
include: SCI_MARKERSETALPHA, SCI_GETSELALPHA and SCI_SETSELALPHA.
V1.15 (6 June 2006)
- Updated the wrapper classes to work correctly when compiled for Unicode.
V1.16 (29 June 2006)
- Removed common control 6 manifest as this conflicts with VC 2005
compilation.
- Code now uses new C++ style casts rather than old style C casts where
necessary.
- Optimized CScintillaCtrl constructor code
- Updated the code to clean compile in VC 2005
- Fixed a bug in the sample program when you invoke Print Preview when
compiled using VC 2005.
- Code now supports persisting margin settings. Thanks to Krasimir
Stoychev for this update.
27 July 2006
- Minor update to the sample app to fix an ASSERT related to the
formatting of the IDR_SCINTITYPE string resource. Thanks to Matt Spear for
reporting this issue.
V1.17 (17 September 2006)
- Updated the CScintillaView::OnReplaceSel and CScintillaView::OnReplaceAll
implementations to use TargetFromSelection and ReplaceTargetRE/ReplaceTarget.
Thanks to Matt Spear for reporting this issue.
- Fixed a bug in UTF82W (and W2UTF8) where if GetLine is called in a
Unicode build for the end of the file (i.e. a line having a length of 0),
the UTF82W function would allocate no buffer, but still erroneously write a
one character terminating null. In addition, the caller (GetLine) will try
to deallocate the buffer that was never allocated. Thanks to Scott Kelley
for spotting this nasty bug.
- Added of a GetLineEx method which explicitly sets the first WORD value
in the text string to the maximum size. This avoids client code from having
to deal with the weird semantics of the EM_GETLINE message. Thanks to Scott
Kelley for providing this
nice addition.
- Verified code implements all the functionality of Scintilla v1.71
V1.18 (11 June 2007)
- Demo program included in the download is now compiled with VC 2005 SP1
- Addition of a SCINTILLADOCVIEW_EXT_CLASS preprocessor to allow the
classes to be more easily used in an extension DLL.
- Addition of a SCINTILLACTRL_EXT_CLASS preprocessor macro to allow the
classes to be more easily used in an extension DLL.
- Updated copyright details.
- CScintillaCtrl::GetSelText now uses CString::GetBufferSetLength to avoid
having to allocate an intermediate buffer. Thanks to Jochen Neubeck for
reporting this optimization.
- Updated class to work with Scintilla v1.73. New messages wrapped
include: SCI_STYLEGETFORE, SCI_STYLEGETBACK, SCI_STYLEGETBOLD,
SCI_STYLEGETITALIC, SCI_STYLEGETSIZE, SCI_STYLEGETFONT,
SCI_STYLEGETEOLFILLED, SCI_STYLEGETUNDERLINE, SCI_STYLEGETCASE,
SCI_STYLEGETCHARACTERSET, SCI_STYLEGETVISIBLE, SCI_STYLEGETCHANGEABLE,
SCI_STYLEGETHOTSPOT, SCI_GETSELEOLFILLED, SCI_SETSELEOLFILLED,
SCI_GETHOTSPOTACTIVEFORE, SCI_GETHOTSPOTACTIVEBACK,
SCI_GETHOTSPOTACTIVEUNDERLINE & SCI_GETHOTSPOTSINGLELINE
V1.19 (28 November 2007)
- Updated class to work with Scintilla v1.75. New messages wrapped
include: SCI_INDICSETUNDER, SCI_INDICGETUNDER, new behavior for
SCI_SETINDENTATIONGUIDES & SCI_GETINDENTATIONGUIDES,
SCI_SETSCROLLWIDTHTRACKING, SCI_GETSCROLLWIDTHTRACKING, SCI_DELWORDRIGHTEND,
SCI_SETCARETSTYLE, SCI_GETCARETSTYLE, SCI_SETINDICATORCURRENT,
SCI_SETINDICATORVALUE, SCI_INDICATORFILLRANGE, SCI_INDICATORCLEARRANGE,
SCI_INDICATORALLONFOR, SCI_INDICATORVALUEAT, SCI_INDICATORSTART,
SCI_INDICATOREND, SCI_SETPOSITIONCACHE & SCI_GETPOSITIONCACHE
- The auto completion sample in CScintillaDemoView::OnCharAdded has been
extended to show another style of auto completion. Thanks to alessandro
limonta for suggesting this update.
V1.20 (19 March 2008)
- Updated class to work with Scintilla v1.76. New messages wrapped include:
SCI_COPYALLOWLINE.
- Updated copyright details.
- Updated code to clean compile on VC 2008.
- Removed VC 6 style classwizard comments from the code.
- Updated the sample app's document icon.
- Fixed a copy and paste bug in CScintillaView::PrintPage where the
incorrect margin value was being used in the calculation of "rfPrint.rc.left".
Thanks to Steve Arnold for reporting this bug.
- Fixed a level 4 warning when the code is compiled on VC 6.
V1.21 (15 June 2008)
- Code now compiles cleanly using Code Analysis (/analyze)
- Updated code to compile correctly using _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
define
- The code now only supports VC 2005 or later.