home *** CD-ROM | disk | FTP | other *** search
- { MSVARS.PAS
- MS 4.0
- Copyright (c) 1985, 87 by Borland International, Inc. }
-
- {$I msdirect.inc}
-
- unit MsVars;
-
- interface
-
- const
- ProgName : string[8] = 'MS'; {Root name for support files}
- Version = '4.0'; {Version number of editor}
-
- {Constants you may wish to customize}
- Maxlinelength = 999; {Maximum number of chars/text line}
- Bufsize = 4096; {Size of file global work buffer}
- MaxMarker = 9; {Maximum number of text markers, 0..MaxMarker}
- MaxWindows = 6; {Maximum number of text windows}
- MinWindowLines = 2; {Minimum rows in a text window}
- FreeListTemp = 2000; {Freelist bytes to keep free even for temporary requests}
- FreeListPerm = 8000; {Freelist bytes to keep free during permanent allocation requests}
- MaxNumTabs = 20; {Maximum number of tab stops per window}
- PositionFindAtStart = False; {False to position cursor at END of search string}
- MakeBackups = True; {True to create backup files when saving}
- OpeningMenu = False; {True to bring up menus when no command line parameter is entered from DOS}
- ShowMenuHelp = True; {True to display continuous prompt about how to activate menu system}
- CleanupAtExit = False; {True to make MS clean up the heap upon exit}
-
- {Basic identities}
- Line1 = 1; {Logical line number 1}
- Col1 = 1; {Logical column number 1}
- Null = #0; {Null character}
-
- {Masks used in the Linedesc record}
- MaxPage = $0FFF; {Low 12 bits of flag word are page number}
- NewAttr = $1000; {Set => attribute changes within line}
- NewPage = $2000; {Set => display page marker on screen}
- 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}
- EopMark : string[1] = ^L; {String used to terminate pages}
- Period : Char = '.';
- Blank : Char = ' ';
-
- Months : string[36] = {Names of months}
- 'JanFebMarAprMayJunJulAugSepOctNovDec';
-
- FormatCommands : string[41] = {Names of print formatting commands}
- {0 1 2 3 4 5 6}
- {123456789012345678901234567890123456789012345678901234567890}
- 'PA CP PN PL MT MB PO HM FM OP PG HE FO PC';
-
- FormatChar : Char = '@'; {Character used to indicate print format command}
-
- OnOff : array[False..True] of string[3] = {Used for toggle status}
- ('OFF', ' ON');
-
- ExeExt : string[3] = 'EXE';
-
- type
- ExtString = string[3]; {File extensions}
- Filename = string[14]; {DOS filename without path, with room for padding}
- Filepath = string[64]; {DOS pathname}
- VarString = string[80]; {String for screen messages}
-
- Charset = set of Char; {General purpose for character sets}
- WorkBuffer = array[0..Bufsize] of Char; {Buffer for file, block, search operations}
- CaseChange = (ToUpper, ToLower, Toggle); {Used in case changing operations}
-
- TextLine = array[0..Maxlinelength] of Char; {Can hold the text of one line}
- PtextLine = ^TextLine;
- PlineDesc = ^Linedesc;
- TabArray = array[1..MaxNumTabs] of Integer; {Holds tab columns}
-
- 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}
- Font : Byte; {Font the line starts with}
- 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}
- CW : Boolean; {Compress line when wrapping}
- 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}
- CPagelen : Integer; {Current page length for on-screen pagination}
- CTmargin : Integer; {Current top margin for on-screen pagination}
- CBmargin : Integer; {Current bottom margin for on-screen pagination}
- Clnum : Integer; {Line number in page at point of pagination interruption}
- Lineno : Integer; {Line number relative to screen, 1..25}
- Colno : Integer; {Last cursor address}
- Clineno : Word; {Display only: line in file}
- Crelpos : LongInt; {Display only: relative position 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}
- Tabs : TabArray; {Tab stop settings}
- end;
-
- ZoomDesc = {Former size of currently zoomed window}
- record
- Firstlineno : Integer; {Physical top line number}
- Lastlineno : Integer; {Physical bottom line number}
- end;
-
- type
- PrintCommandtype =
- (PrtInit, {Initialization/reset}
- PrtBold, {Bolding on/off - keep second}
- PrtDbl, {Doublestrike on/off}
- PrtUnd, {Underline on/off}
- PrtSup, {Superscript on/off}
- PrtSub, {Subscript on/off}
- PrtAlt1, {Alternate font 1 on/off}
- PrtAlt2, {Alternate font 2 on/off - keep next to last}
- PrtNone {Used only as terminator}
- );
- PrintCommandMap = array[#0..#255] of PrintCommandtype; {Print command associated with each ASCII character}
-
-
- 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];
-
- SentenceEnd : Charset = {Used in sentence oriented operations}
- ['.', '?', '!', ';'];
-
- WordDelimiters : string[34] = {Used by EditScanPat for whole word searches}
- #32#9#13#10#39',./?;:"<>[]{}-=\+|()*%@&^$#!~';
-
- PrtCmdSet : Charset = {Characters to scroll around print setup menu}
- [^J, ^M, ^[ , ^E, ^X];
-
- {Marks start of INSTALLATION AREA}
- MainIDstring : string[22] = 'MAIN INSTALLATION AREA';
-
- {Common to all windows}
- SaveUndoLimit : Integer = 20; {Default number of lines for undo queue}
- DefExtension : string[3] = ''; {Default extension applied to filenames}
- SaveTabSize : Integer = 8; {Spacing of default tabs}
- ReadExpandTabs : Boolean = True; {True if tabs are expanded to spaces on read-in}
- WriteCompressTabs : Boolean = False; {True if spaces are compressed to tabs on file writes}
- SaveDeviceName : Filepath = 'PLAIN.PDF'; {Default printer configuration}
- SaveOutputName : Filepath = ''; {Default printer output file}
- SavePrinterPort : Byte = 0; {Default printer port - 0 for LPT1, 1 for LPT2}
- SaveToFile : Boolean = False; {True if printing is done to file}
- SaveFormatState : Boolean = True; {True to format printed documents}
- SaveStripMode : Boolean = False; {True to convert WordStar DOC files on read-in}
- SaveSupportPath : Filepath = ''; {Drive:Path to support files - MS.HLP, MS.DCT, MS.MAC}
- SaveKeyHelpMode : Boolean = True; {Keystroke help displayed in menus}
- SaveInitZoomState : Boolean = False; {Initial zoom state}
-
- {Set up by independent toggles for each window}
- SaveInsertMode : Boolean = True; {Default to insert mode ON}
- SaveIndentMode : Boolean = True; {Default to indent mode ON}
- SaveWWmode : Boolean = True; {Default to word wrap mode ON}
- SaveJustMode : Boolean = False; {Default to right justification OFF}
- SavePageMode : Boolean = False; {Default to pagination OFF}
- SaveAttrMode : Boolean = True; {Default to attribute display ON}
- SaveFTmode : Boolean = True; {Default to using fixed tabs}
- SaveTabMode : Boolean = True; {Default to tab line displayed}
- SaveLeftMargin : Integer = 1; {Default left margin for word wrap}
- SaveRightMargin : Integer = 65; {Default right margin for word wrap}
- SaveTopMargin : Integer = 3; {Length of top margin}
- SaveBottomMargin : Integer = 8; {Length of bottom margin}
- SavePageLen : Integer = 66; {Length of default page}
- SaveCompressWrap : Boolean = True; {True to compress lines before wrapping}
-
- {End of INSTALLATION AREA}
- LastMainDefault : Byte = 0;
-
- var
- {Keyboard-related}
- EditUsercommandInput : Integer; {Count of chars pushed by UserCommand}
-
- {Markers}
- 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}
-
- {Macros}
- UseExtendedSequence : Boolean; {False to interpret nulls individually}
- Recording : Boolean; {Set true to activate macro recording}
-
- {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}
- ZoomWin : ZoomDesc; {Holds Window zoom info}
- Zoomed : Boolean; {True when one window has zoomed to fill the screen}
-
- {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}
- Recurring : Boolean; {Used to control Recursion during macro playback}
- MarginRelease : Boolean; {Set when word wrap not to be active}
-
- {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}
- LastPrintFile : Filepath; {Last file printed}
- LastPrintOutput : Filepath; {Last printer output file}
- LastDosCommand : VarString; {Last DOS command entered}
- LastDirectory : VarString; {Last file directory mask}
- SupportPath : Filepath; {Path to the support files for this editor run}
-
- PrintMap : PrintCommandMap; {Maps control chars to printer toggle commands}
-
- FreeListSpace : Word; {Dynamic amount of free list space to retain}
-
- {==========================================================================}
-
- implementation
-
- procedure EdInitGlobals;
- var
- P : Pwindesc;
- I : Integer;
-
- begin {EdInitGlobals}
-
- 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}
-
- if DefExtension = '' then
- LastFileEdit := '*.*'
- else
- LastFileEdit := '*.'+DefExtension;
- LastPrintFile := '';
- LastBlockRead := '';
- LastBlockWrite := '';
- LastDosCommand := '';
- LastDirectory := '';
- LastPrintOutput := SaveOutputName;
-
- 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}
- 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}
- Recording := False; {Set true to activate macro recording}
- Recurring := False; {Set true when Find and Macro is playing macro}
- EditUsercommandInput := 0; {Number of chars user has pushed so far}
- Goterror := False; {Indicates when error has occurred}
- FreeListSpace := FreeListPerm; {Amount of free list to keep free}
- PromptForInput := True; {Prompt for find/replace parameters}
- WindowCount := 0; {No windows open}
- MarginRelease := False; {Margins are not released}
- UseExtendedSequence := True; {Interpret Nulls by reading following character}
-
- {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}
-
- procedure EdInitPrintMap;
- {-Initialize the mapping between control chars and printer toggle commands}
-
- begin {EdInitPrintMap}
- FillChar(PrintMap, SizeOf(PrintMap), PrtNone);
- PrintMap[^B] := PrtBold;
- PrintMap[^D] := PrtDbl;
- PrintMap[^S] := PrtUnd;
- PrintMap[^T] := PrtSup;
- PrintMap[^V] := PrtSub;
- PrintMap[^A] := PrtAlt1;
- PrintMap[^N] := PrtAlt2;
- end; {EdInitPrintMap}
-
- begin
- EdInitGlobals;
- EdInitPrintMap;
- end.