home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-06 | 2.5 KB | 101 lines | [TEXT/CWIE] |
- {•This sourcecode is an example for creating a FKey coderesource with•}
- {•Metrowerks Pascal. It is copyrighted by Peter Hoerster and released•}
- {•for free use in any Shareware or Freeware product as a way to thank all•}
- {•programmers who share code snippets. You may put this sources on any•}
- {•CD ROM or any Archive Server but you may not sell it. •}
-
- {• For comments please write to <hoerster@muenster.de>•}
-
-
- unit CodeComment;
-
- interface
-
- uses
- Types, OSUtils, GestaltEqu, Script, notification, Resources, Events,
- PascalA4, QuickDraw, ToolUtils, Memory, LowMem, Scrap;
-
-
-
- {$MAIN}
-
- procedure main;
-
- implementation
-
- procedure dopaste;
- const
- pastecode=2422;
- var
- qel: EvQelPtr;
- begin
- if ppostevent(3, pastecode, qel) = noerr then
- qel^.evtqmodifiers := cmdkey;
- end;
-
-
-
- procedure main;
- const
- step = 1000;
- tab = char(ord(9));
- esc = char(ord(27));
- Enter = char(ord(3)); {the enter character}
- Return = char(ord(13)); {the return character}
- Type
- chararray=packed array[1..1]of char;
- chararrayptr=^chararray;
- chararrayhdl=^chararrayptr;
- var
- oldA4: LongInt;
- myerr: oserr;
- myclipsize, templongint: longint;
- myclipHandle: handle;
- substhandle: Handle;
- i: integer;
- subst: str15;
- wasreturn:boolean;
- begin
- oldA4 := SetCurrentA4;
- wasreturn:=false;
- myclipsize := GetScrap(nil, 'TEXT', templongint);
- mycliphandle := Tempnewhandle(myclipsize,myerr);
- if myerr=noerr then
- begin
- myclipsize := GetScraP(myclipHandle, 'TEXT', templongint);
- if myclipsize > 0 then
- begin
- if chararrayhdl(mycliphandle)^^[myclipsize]=return then
- begin
- myclipsize:=myclipsize-1;
- wasreturn:=true;
- end;
- sethandlesize(mycliphandle,myclipsize+2);
- blockmove(mycliphandle^, pointer(ord4(mycliphandle^)+2),myclipsize);
- subst := '123';
- subst[1]:=return;
- subst[2]:='/';
- subst[3]:='/';
- blockmove(@subst[2], mycliphandle^,2);
-
- substhandle := newhandle(3);
- blockmove(@subst[1], substhandle^, 3);
- subst :=return;
- subst[1] := return;
- i := ReplaceText(mycliphandle, substhandle, subst);
- if wasreturn=true then
- begin
- myerr:=ptrandhand(@subst[1],mycliphandle,1);
- end;
- myerr := ZeroScrap;
- myclipsize:=gethandlesize(mycliphandle);
- Temphlock(mycliphandle,myerr);
- myerr := putscrap(myclipsize, 'TEXT', myclipHandle^);
- Temphunlock(myCliphandle,myerr);
- dopaste;
- end;
- end;
- TempDisposeHandle(myCliphandle,myerr);
- oldA4 := SetA4(oldA4);
- end;
- end.