home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
progm
/
tptools.zip
/
FIRSTED.ZIP
/
EDVARS.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1987-12-21
|
11KB
|
255 lines
{ EDVARS.PAS
ED 4.0
Copyright (c) 1985, 87 by Borland International, Inc. }
{$I eddirect.inc}
unit EdVars;
interface
uses
Dos,
Errors;
const
Version = '4.00A'; {Version number of editor}
{Constants you may wish to customize}
MaxLineLength = 999; {Maximum number of chars/text line}
Bufsize = 4096; {Size of file global read/write buffer}
MaxMarker = 9; {Maximum number of text markers, 0..MaxMarker}
FreeListPerm = 4000; {Minimum bytes to keep free for heap free list}
MaxWindows = 6; {Maximum number of text windows}
MinWindowLines = 2; {Minimum rows in a text window}
PositionFindAtStart = False; {False to position cursor at END of search string}
MakeBackups = True; {True to create backup files when saving}
CleanupAtExit = False; {True to make ED free up heap space at exit}
{Basic identities}
Line1 = 1; {Logical line number 1}
Col1 = 1; {Logical column number 1}
Null = #0; {Null character}
{Flags used in the Linedesc record}
InBlock = $4000; {Set => display block in Blockcolor}
InMark = $8000; {Set => line contains a marker}
{Miscellaneous constant strings}
NoFile : string[6] = 'NONAME'; {Name of window with no file}
EolMark : string[2] = ^M^J; {Indicates end of line}
Period : Char = '.';
Blank : Char = ' ';
type
ExtString = string[3]; {File extensions}
Filename = string[14]; {DOS filename without path}
Filepath = string[64]; {DOS pathname}
VarString = string[80]; {String for screen messages}
String255 = string[255]; {Longest Turbo string}
Charset = set of Char; {General purpose for character sets}
TextLine = array[0..MaxLineLength] of Char; {Can hold the text of one line}
WorkBuffer = array[0..Bufsize] of Char; {Buffer for file, block, search operations}
PlineDesc = ^LineDesc;
PtextLine = ^TextLine;
LineDesc = {A complete text line, with links}
record
FwdLink : PlineDesc; {Ptr to previous line in stream - MUST BE FIRST FIELD}
Backlink : PlineDesc; {Ptr to next line in stream - MUST BE SECOND FIELD}
Txt : PtextLine; {Ptr to text buffer}
Flags : Word; {Packed flags word - see bit masks above}
Bufflen : Integer; {Holds current length of text buffer}
end;
BlockMarker = {Describes a unique position in text stream}
record
Line : PlineDesc;
Col : Integer;
end;
MarkArray = array[0..MaxMarker] of BlockMarker;
PwinDesc = ^WinDesc;
WinDesc = {Describes each window on screen}
record
FwdLink : PwinDesc; {Next window down - MUST BE FIRST FIELD}
Backlink : PwinDesc; {Next window up - MUST BE SECOND FIELD}
FirstLineNo : Integer; {Screen row number of window status line}
LastLineNo : Integer; {Screen row number of last text line}
FirstTextNo : Integer; {Screen row number of first text line}
Filename : Filepath; {File being edited}
InsertFlag : Boolean; {Insert mode}
AI : Boolean; {Autoindent mode}
WW : Boolean; {WordWrap mode - enables paragraph reformat}
TL : Boolean; {Tab line display}
JU : Boolean; {Right justification}
PA : Boolean; {Paginated}
AT : Boolean; {Attributes displayed}
FT : Boolean; {Fixed tabs displayed}
Modified : Boolean; {True when save is required}
PaginationDone : Boolean; {True when pagination has run through entire file}
Wmargin : Integer; {Wrap margin column number}
Lmargin : Integer; {Left margin column number}
Rmargin : Integer; {Right margin column number}
PageLen : Integer; {Default page length}
Tmargin : Integer; {Default top margin}
Bmargin : Integer; {Default bottom margin}
LineNo : Integer; {Line number relative to screen, 1..25}
ColNo : Integer; {Last cursor address}
Clineno : Word; {Display only: line in file}
TlineNo : Word; {Total lines in file}
TcharNo : LongInt; {Total bytes in file}
TpageNo : Integer; {Total pages in file}
TopLine : PlineDesc; {Ptr to first line in view}
CurLine : PlineDesc; {Ptr to current line}
PageLine : PlineDesc; {Ptr to last line with accurate pagination}
WmarginLine : PlineDesc; {Ptr to line where wmargin was set}
Stream : Word; {Unique text stream id}
LeftEdge : Integer; {Leftmost displayed text column}
LeftCol : Integer; {Screen column offset where text display starts}
Visible : Boolean; {True if window shows on screen}
end;
const
{Used by various word oriented commands}
{Punctuation symbols are for consistency with Turbo editor}
Alphas : Charset = {Used in word oriented operations}
['A'..'Z', 'a'..'z', '0'..'9', '%', '@', '_', '|', '"', '?', ';', #128..#254];
WordDelimiters : string[34] = {Used by EditScanPat for whole word searches}
#32#9#13#10#39',./?;:"<>[]{}-=\+|()*%@&^$#!~';
{Marks start of INSTALLATION AREA}
MainIDstring : string[22] = 'MAIN INSTALLATION AREA';
{Common to all windows}
SaveUndoLimit : Integer = 20; {Default number of lines for undo stack}
DefExtension : string[3] = ''; {Default extension applied to filenames}
{Set up by independent toggles for each window}
SaveInsertMode : Boolean = True; {Default to insert mode ON}
SaveIndentMode : Boolean = True; {Default to indent mode ON}
{End of INSTALLATION AREA}
var
{Keyboard-related}
EditUsercommandInput : Integer; {Count of chars pushed by UserCommand}
{Screen-related}
FullScroll : Integer; {Number of lines to BIOS scroll at next screen update}
TempScroll : Integer; {Intermediate number of lines of BIOS scroll}
UpdateScreen : Boolean; {True when text screen must be redrawn}
PromptLine : String255; {Command line image}
PromptCol : Integer; {Column for next cmd printed on command line}
{Markers and Macros}
Blockfrom : BlockMarker; {Points to beginning of block}
Blockto : BlockMarker; {Points to end of block}
CurLineTo : BlockMarker; {Used in current line buffering wrt marked blocks}
CurLineFrom : BlockMarker; {Used in current line buffering wrt marked blocks}
LastPosition : BlockMarker; {Cursor position prior to current operation}
Marker : MarkArray; {Text markers}
Blockop : Boolean; {Set if a block operation just occurred}
Blockhide : Boolean; {Set if block is not displayed}
MarkHide : Boolean; {set if marks are not displayed}
{Window-related}
WindowCount : Integer; {Number of text windows on screen, 0..MaxWindows}
CurWin : PwinDesc; {Pointer to window containing cursor}
Window1 : PwinDesc; {Pointer to window at top of screen}
WinStack : PwinDesc; {Pointer to free list of windows}
{Basic flags}
Rundown : Boolean; {Determines when scheduler is done}
UpdateCursor : Boolean; {Set if we must reposition cursor}
GotError : Boolean; {Set after any error, pollable by calling routine}
Abortcmd : Boolean; {Set when AbortChar is pressed}
Aborting : Boolean; {Stops recursion during abort}
AbortEnable : Boolean; {Set when AbortChar is to be accepted as abort}
IntrFlag : (NoInterr, Interr); {Set to Interrupt when keystrokes can interrupt screen writes}
{Find and Replace}
PromptForInput : Boolean; {Set False for Find Next operations}
LastSearchOp : (Find, Replace, RunMacro, None); {Whatever was done after last search}
{Undo-related}
UndoCount : Integer; {Number of lines currently on undo stack}
UndoLimit : Integer; {Maximum number of lines on undo stack}
UndoStack : PlineDesc; {First line on undo stack}
UndoEnd : PlineDesc; {Last line on undo stack}
CurLineBuf : PlineDesc; {Pointer to current line buffer for line restore}
CurLineCol : Integer; {Column number upon entry to line}
{File support}
WorkBuf : WorkBuffer; {Buffer used for read/write speed, also for searching}
LastBlockRead : Filepath; {Last file used in blockread}
LastBlockWrite : Filepath; {Last file used in blockwrite}
LastFileEdit : Filepath; {Last file used in edit}
FreeListSpace : Word; {Dynamic amount of free list space to retain}
{==============================================================================}
implementation
procedure EdInitGlobals;
var
P : PwinDesc;
I : Integer;
begin {EdInitGlobals}
UpdateScreen := True; {Screen needs updating}
UpdateCursor := True; {Cursor needs updating}
FullScroll := 0; {BIOS scrolling not currently needed}
IntrFlag := Interr; {Allow interrupts of screen updates}
Abortcmd := False; {Set by EditAbort to stop EditAskfor}
Aborting := False; {Set by EditAbort to stop recursion}
AbortEnable := False; {Disable AbortCmd until needed}
LastFileEdit := '';
LastBlockRead := '';
LastBlockWrite := '';
UndoCount := 0; {Used by EditUndo and EditDelline}
UndoLimit := SaveUndoLimit; {Default size of undo buffer}
UndoStack := nil; {Front of undo queue}
UndoEnd := nil; {Rear of undo queue}
PromptCol := 1; {Next cursor position on command line}
Blockop := False; {A block operation has not occurred yet}
Blockhide := True; {No block is showing}
MarkHide := False; {Show marks when set}
Rundown := False; {Set true when editor is ready to exit}
LastSearchOp := None; {Controls operation of ^L command}
EditUsercommandInput := 0; {Number of chars user has pushed so far}
GotError := False; {Indicates when error has occurred}
FreeListSpace := FreeListPerm; {Amount of free list space to keep free}
PromptForInput := True; {Prompt for find/replace parameters}
PromptCol := 1; {Column for start of cmd printing}
WindowCount := 0; {No windows open}
{Allocate window structures for later use}
WinStack := nil;
for I := 0 to MaxWindows do begin
New(P);
P^.FwdLink := WinStack;
WinStack := P;
end;
{Initialize markers}
for I := 0 to MaxMarker do
Marker[I].Line := nil;
Blockfrom.Line := nil;
Blockto.Line := nil;
end; {EdInitGlobals}
begin
EdInitGlobals;
end.