home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1993 #2
/
Image.iso
/
wp
/
ewdin2.zip
/
AUTOINS2.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1993-06-03
|
3KB
|
96 lines
{************************************************}
{ }
{ E! for Windows }
{ (c) - Patrick Philippot - 1992-1993 }
{ }
{ AutoIns2 Extension DLL - version 1.0 }
{ }
{ This DLL modifies the basic behavior of the }
{ AutoInsert function. Currently, when auto- }
{ inserting a right brace, EW doesn't move }
{ the cursor where you would expect, that is, }
{ just before the right brace. Some users prefer }
{ the original behavior. If you don't, install }
{ this DLL. }
{ }
{************************************************}
(*
To use this DLL simply load it from the user menu or add its name to the
list of autoloaded Extension DLLs by using the Autoload dialog box from
the User Menu of EW. That's all. This extension cannot be executed because
it only adds a hook responding to E! notifications. AutoIns exports no
EWExecute function.
After installation and if AutoInsert has been checked in the Local Default
dialog box from the Control Center, the AutoInsert function behavior will
be modified. After execution, the cursor will be moved backwards one
position and will be located between the left and right braces.
Please refer to the documentation for details about the AutoInsert feature.
This DLL is a less intrusive, smarter variant of AUTOINS.EWD. The cursor
will not be moved if the character preceding the right brace is not the
corresponding left brace.
This small piece of code also shows you how easy it is to modify basic
functions of E!.
*)
{$IFDEF DEBUG}
{$A+,G+,B-,D+,E-,F+,I-,N-,R+,S+,V-,L+,Q+,Y+,K+,X+}
{$ELSE}
{$A+,G+,B-,D-,E-,F+,I-,N-,R-,S-,V-,L-,Q-,Y-,K+,X+}
{$ENDIF}
{$C MOVEABLE PRELOAD DISCARDABLE}
library AutoIns;
uses WinTypes, WinProcs, EWApiImp, Strings;
{$I ewuser.inc}
var
SaveExit : Pointer;
P : PChar;
CaretPos : longint;
XPos : word;
function NotifyHook(eventcode : word; wParam : word; lParam : longint) : integer; export;
const
RightBraces : string[3] = ')]}';
LeftBraces : string[3] = '([{';
begin
NotifyHook := 0; {-A non-zero value would break the hook chain}
if (eventcode = ewNotify_CharExit)
and (Char(Lo(wParam)) in [')', ']', '}'])
and (EWGetLocalFlag(EWLclbAutoInsert) <> 0)
and (EWGetInsertState <> 0) then begin
CaretPos := EwGetCaretPos;
XPos := LoWord(CaretPos);
P := EWGetLineAt(HiWord(CaretPos));
if (XPos >= 2)
and ((P + XPos - 2)^ = LeftBraces[Pos(Char(Lo(wParam)), RightBraces)]) then
EWPrevCol;
end;
end;
procedure LibExit; far;
begin
EWRemoveHook(EWHook_Notify, @NotifyHook);
ExitProc := SaveExit;
end;
exports
NotifyHook index 1;
begin
EWSetHook(EWHook_Notify, @NotifyHook);
SaveExit := ExitProc;
ExitProc := @LibExit;
end.