home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
progm
/
tptools.zip
/
FIRSTED.ZIP
/
EDBACK.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1987-12-21
|
5KB
|
188 lines
{ EDBACK.PAS
ED 4.0
Copyright (c) 1985, 87 by Borland International, Inc. }
{$I eddirect.inc}
unit EdBack;
{-Background processes for FirstEd}
interface
uses
crt, {Basic video operations - standard unit}
Dos, {DOS calls - standard unit}
Errors, {Runtime error handler}
EdVars, {Global types and declarations}
EdScrn1, {Fast screen writing routines}
EdString, {String primitives}
EdPtrOp, {Primitive pointer operations}
EdCmds, {Maps keystrokes to commands}
int24, {DOS critical error handler}
Message, {Message system}
EdUser; {User keyboard input and error reporting}
procedure EdHscrollOne(W : PwinDesc);
{-Horizontal scroll one window}
procedure EdHscroll;
{-Scroll windows horizontally}
procedure EdMarkblock;
{-Mark lines in current block}
procedure EdGenLineNo;
{-Generate line numbers for window status lines}
procedure EdCloneModifiedFlags;
{-Update linked window modified flags}
{==========================================================================}
implementation
{***}
procedure EdHscrollOne(W : PwinDesc);
{-Horizontal scroll one window}
begin {EdHscrollOne}
with W^ do begin
if ColNo < LeftEdge then
LeftEdge := ColNo
else if ColNo > (LeftEdge+PhyScrCols-2-LeftCol) then
LeftEdge := Succ(ColNo-PhyScrCols+LeftCol);
end;
end; {EdHscrollOne}
procedure EdHscroll;
{-Scroll windows horizontally}
var
W : PwinDesc;
begin {EdHscroll}
W := CurWin;
repeat
EdHscrollOne(W);
EdFwdPtr(W);
until (W = CurWin);
end; {EdHscroll}
procedure EdMarkblock;
{-Mark lines in current block}
var
P, Q : PlineDesc;
I : Integer;
Done : Boolean;
begin {EdMarkblock}
if EdNoBlock then
Exit;
{We have a block defined, so start marking}
P := Blockfrom.Line;
Q := Blockto.Line;
I := 0;
repeat
EdChangeFlag(P, True, InBlock);
Done := (P = Q);
if not(Done) then begin
Inc(I);
if (I and 3) = 0 then
if EdKeyInterrupt then
Exit;
EdFwdPtr(P);
end;
until Done;
end; {EdMarkblock}
{***}
procedure EdGenLineOne(W : PwinDesc);
{-Generate line and byte counts for one window}
var
P : PlineDesc;
TotalLine : Word;
Len : Integer;
TotalChar : LongInt;
begin {EdGenLineOne}
with W^ do begin
TotalLine := 0;
TotalChar := 00;
{Count back to beginning of file}
P := CurLine;
while EdPtrNotNil(P) do begin
{Byte count - add 2 per line for CR/LF}
TotalChar := TotalChar+EdTextLength(P)+2;
{Line count}
Inc(TotalLine);
{Check the keyboard every four lines}
if (TotalLine and 3) = 0 then
if EdKeyInterrupt then
Exit;
EdBackPtr(P);
end;
{Update line count}
if TotalLine <> Clineno then
UpdateScreen := True;
Clineno := TotalLine;
{Update byte count, here Tcharno holds bytes to cursor, NOT total}
Len := EdTextLength(CurLine);
if ColNo > Len then
{Subtract the CR/LF added for the current line}
TotalChar := TotalChar-2
else
TotalChar := TotalChar-Len-2+ColNo;
if TotalChar <> TcharNo then
UpdateScreen := True;
TcharNo := TotalChar;
end;
end; {EdGenLineOne}
{***}
procedure EdGenLineNo;
{-Generate line numbers for window status lines}
var
W : PwinDesc;
begin {EdGenlineno}
W := CurWin;
repeat
EdGenLineOne(W);
if EdKeyInterrupt then
Exit;
EdFwdPtr(W);
until W = CurWin;
end; {EdGenlineno}
procedure EdCloneModifiedFlags;
{-Update linked window modified flags}
var
W : PwinDesc;
S : Word;
begin {EdCloneModifiedFlags}
with CurWin^ do begin
if not(Modified) then
Exit;
S := Stream;
end;
W := CurWin;
repeat
with W^ do
if (S = Stream) and not(Modified) then begin
Modified := True;
UpdateScreen := True;
end;
EdFwdPtr(W);
until W = CurWin;
end; {EdCloneModifiedFlags}
end.