home *** CD-ROM | disk | FTP | other *** search
- {$R-,S-}
-
- program Test1;
- {-Display BinEd internals information}
-
- uses
- Crt, {Just for convenience of demo}
- BinEd,
- BinInt; {Makes BinEd internals available to event handlers}
-
- const
- ExitCommands : Char = #0; {No special exit characters}
-
- var
- EdData : EdCB; {Editor control block}
- EdInt : EdIntRec; {Internals record}
-
- procedure Abort(Msg : string);
- begin
- WriteLn(Msg);
- Halt(1);
- end;
-
- {$F+}
- procedure EventHandler(EventNo, KbdFlagInfo : Word);
- {-Event handler reports on internals}
- const
- {Used to avoid rewriting screen too much}
- LOfsS : Word = $FFFF;
- CharS : Char = #$FF;
- LPosS : Byte = $FF;
- LLenS : Byte = $FF;
- OptnS : Byte = $FF;
- var
- LOfsC : Word;
- CharC : Char;
- LPosC : Byte;
- LLenC : Byte;
- OptnC : Byte;
- begin
- {Get current values}
- LOfsC := CurrLineOfs(EdInt);
- CharC := CurrChar(EdInt);
- LPosC := LinePos(EdInt);
- LLenC := LineLen(EdInt);
- OptnC := EditOptions(EdInt);
-
- {See if they're different than last time we updated screen}
- if (LOfsC <> LOfsS) or (CharC <> CharS) or
- (LPosC <> LPosS) or (LLenC <> LLenS) or
- (OptnC <> OptnS) then begin
- {Write the buffer offset of the current line}
- GoToXy(27, 20);
- Write(LOfsC, ' ');
- {Write the character at the cursor}
- GoToXy(27, 21);
- Write(CharC);
- {Write the position within current line}
- GoToXy(27, 22);
- Write(LPosC, ' ');
- {Write the length of the current line}
- GoToXy(27, 23);
- Write(LLenC, ' ');
- GotoXy(27, 24);
- Write(OptnC, ' ');
- {Save values for next time}
- LOfsS := LOfsC;
- CharS := CharC;
- LPosS := LPosC;
- LLenS := LLenC;
- OptnS := OptnC;
- end;
- end;
- {$F-}
-
- begin
- if ParamCount = 0 then
- Abort('Usage: TEST1 filename.ext');
-
- {Initialize binary editor for a partial screen window}
- if InitBinaryEditor(EdData, MaxFileSize, 1, 1, 80, 18,
- True, EdOptInsert, '', ExitCommands,
- @EventHandler) <> 0 then
- Abort('Unable to load binary editor.');
-
- {Store internals for event handler}
- FindInternals(EdData, EdInt);
-
- {Read file to edit}
- if ReadFileBinaryEditor(EdData, ParamStr(1)) > 1 then
- Abort('Unable to read '+ParamStr(1));
-
- {Write titles for the event handler}
- ClrScr;
- GoToXy(1, 20);
- WriteLn('Offset of current line :');
- WriteLn('Character at cursor :');
- WriteLn('Position in current line:');
- WriteLn('Length of current line :');
- WriteLn('Editor options byte :');
-
- {Reset for this file}
- ResetBinaryEditor(EdData);
-
- {Edit it, no save supported}
- if UseBinaryEditor(EdData, '') = -1 then
- ;
-
- GoToXy(1, 25);
- end.