| Notes for
WSciTE Basic Macro Hack |
|
2004-02-26: Updated for customised WSciTE
1.59
2004-10-11: Updated for customised WSciTE 1.61+
2005-04-06: Updated for customised WSciTE 1.63+
WSciTE 1.55:
Introduction
Here are some notes in roughly chronological order. The button
bitmaps were drawn by hand. This and all other changes for this
feature hereby have their copyrights assigned to Neil Hodgson
under the existing Scintilla/SciTE license. All the modified
files reside under the scite/ directory tree.
WSciTE 1.55: Macro
Buttons
- src/SciTE.h: Added 3 resource IDs for
macro button bitmaps, IDR_MACRO*
- +win32/macroplay.bmp: Play button.
Buttons were derived from closefile.bmp.
- +win32/macrorecord.bmp: Record button.
- +win32/macrostoprecord.bmp: Stop button.
- win32/SciTERes.rc: Declaration for
IDR_MACRO* bitmap resources.
- win32/SciTEWinBar.cxx: Updated toolbar
table with new buttons and separator. Added calls to load
macro button bitmap resources. Updated SciTEWin::Creation
to handle loading of extra custom bitmaps for the
toolbar.
WSciTE 1.55: Simple
Macro Extension
- win32/SciTEWin.h: Added preprocessor
define for a new extension, SIMPLE_MACRO_EXT. Added
include file entry for SimpleMacroExt.h.
- src/SciTEBase.cxx: Set macrosEnabled to
true by default in SciTEBase::SciTEBase.
- win32/SciTEWin.cxx: Added instantiation
for a new SimpleMacroExt Extension object in WinMain,
which calls the main SciTEWin object.
- win32/Makefile: Added object file
entries for SimpleMacroExt.* and
disabled entries for DirectorExtension.*.
- +win32/SimpleMacroExt.h: SimpleMacroExt
class declaration mostly copied from src/Extender.h
and win32/DirectorExtension.h.
- +win32/SimpleMacroExt.cxx: SimpleMacroExt
class implementation mostly copied from win32/DirectorExtension.cxx,
pared down to the bare essentials. Most functionality
resides in SimpleMacroExt::OnMacro.
WSciTE 1.55: Fixes for
Macro Playing
- src/SciTEBase.cxx: Fixed SciTEBase::ExecuteMacroCommand
to conform with SciTEBase::RecordMacroCommand
(so that the recorded commands are correctly decoded.)
Update 20041011: The code here is actually wrong, I
slashed my own decoder onto perfectly good code. See the
notes for version 1.61 below for more information.
- win32/SimpleMacroExt.h: Added MacroItem,
a class for a singly-linked list for holding a list of
recorded macro data.
- win32/SimpleMacroExt.cxx: Implementation
of a singly-linked list for holding a list of recorded
macro data. Due to a severe lack of practice coding in
C++, the code is more or less in C, and it might be
leaky...
Cleaning Up
- win32/SciTERes.rc: Removed macro list
accelerator for IDM_MACROLIST.
- src/SciTEBuffers.cxx: Removed insertion
call for IDM_MACROLIST's menu item.
Update for WSciTE 1.59
For WSciTE 1.59, a MultipleExtension interface has been
implemented. Here is an incomplete list of additional changes
made:
- win32/SciTEWin.cxx: Adjusted
instantiation of SimpleMacroExt to use MultipleExtension.
- src/SciTEBuffers.cxx: No change because
IDM_MACROLIST may be needed by other installed
extensions.
- win32/SimpleMacroExt.h: Added
instantiation code.
- win32/SimpleMacroExt.cxx: Added
instantiation code.
- win32/Makefile: Fixed to compile and
link DirectorExtension as well, since MultipleExtension
can use it.
Update for WSciTE 1.61+
This version of WSciTE has a LuaExtension and is a bit later
than the official 1.61 release (it is the CVS HEAD dated
20041010.) Here is a list of changes made, in chronological
order:
- src/SciTEBase.cxx: [463] Added line in
About dialog box to say that it's customized.
- src/SciTEProps.cxx: [1302] Added
"use.monospaced" boolean property.
- win32/macroplay.bmp: Added file, toolbar
icon.
- win32/macrorecord.bmp: Added file,
toolbar icon.
- win32/macrostoprecord.bmp: Added file,
toolbar icon.
- src/SciTE.h: [233] Added resource IDs.
- win32/SciTERes.rc: [495] Disabled menu
item for macro listing, MACROLIST. [522] Added resource
declarations for three macro toolbar button bitmaps.
- win32/SciTEWinBar.cxx: [680] Added macro
buttons and a separator to toolbar data structure. [765]
Added calls to load bitmap resources for macro buttons.
[768] Added statements for macro button initialisation.
- win32/SciTEWin.h: [58] Header inclusion
for SimpleMacroExt.h.
- src/SciTEBuffers.cxx: [1052] Remove item
enabling macro listing.
- win32/Makefile: Added SimpleMacroExt.o
in list of object files (2 places.)
- win32/SciTEWin.cxx: [1961] Added call to
initialise macro extension.
- win32/SimpleMacroExt.h: [versus 1.59]
Added pass-through functions (returning false) for new
extension API calls.
- src/SciTEBase.cxx: [349] Set
macrosEnabled to true.
- win32/SimpleMacroExt.cxx: [versus 1.59]
Added code to break up incoming macro message and
properly reformat it for use as an outgoing message. The
two formats are not similar. Added header and footer
messages to block off the entire macro sequence as a
single undo unit.
WSciTE 1.61: Some Notes
on Macro Messaging
Incoming macro messages, with the command
"macro:record" has a string parameter in the form: message;wParam;{0|1}[;lParam]
message is an integer, wParam is an integer,
and lParam is a string, and is present only if the third
parameter is a 1. As far as I can tell, lParam is either
zero or one characters, but it doesn't really matter to the
extension.
Outgoing macro messages for execution is in the form:
macrocommand:message;XYZ;wParam[;lParam]
"macrocommand:" is the prefix. message is
an integer, XYZ is a sequence of 3 characters, wParam
is either an integer or a string, lParam is either
an integer or a string. If X is '0', the command
(message) has no return value. If X is 'S', a string is
returned, otherwise an integer is returned. If Y is 'R',
wParam is a string, otherwise it is an integer. If Z
is 'I', then lParam is present and it is an integer. If Z
is 'S', then lParam is present and it is a string,
otherwise it does not exist.
In order to properly handle macro sequences, an incoming
message must be reformatted into a outgoing message. A macro
sequence is collected as long as the command is
"macro:record". The macro sequence is cleared when
recording restarts after a "macro:stoprecord". When
"macro:run" is encountered, the recorded sequence is
played back, and the entire sequence is blocked as a single undo
unit.
Update for WSciTE 1.63+
This version of WSciTE is dated a day or two later than the
official 1.63 release (it is the CVS HEAD dated 20050405.) It
turns out that the above method of running the macro (using
macrocommand: and the Perform() method) does not work for the
backslash character. I haven't found out why, but in the
meantime, switching over to using the Send() method works and '\'
is produced correctly with recorded and executed.