home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 21 / CD_ASCQ_21_040595.iso / dos / prg / pas / tvgr70 / editors.doc < prev    next >
Text File  |  1994-11-15  |  28KB  |  667 lines

  1.  
  2.  
  3.   file EDITORS.DOC
  4.  
  5.   8/10/94
  6.   {11/14/94 bug fix THeapFileEditor.InitBuffer}
  7.  
  8.   DOCUMENTATION FOR THE GEDITORS UNIT
  9.  
  10.   This unit is based on BP7.0 maintenance release of Editors.PAS.
  11.  
  12.   The Editors unit contains the basic text editor view (TEditor). It
  13.   also contains a text file editor and a window for the text file
  14.   editor with Scrollbars and cursor position Indicator. These are for
  15.   ASCII text files. TMemo is a descendant of TEditor that is designed
  16.   for insertion as a control in Dialogs. See Turbo Vision 2.0 doc
  17.   Chapter 15 for general discussion plus description of several vital
  18.   programming issues necessary to using TEditor in your program. (If 
  19.   you don't read about memory usage, your program will bomb.)
  20.  
  21.   The TVGraphic GEditors unit offers the choice between the Turbo
  22.   Vision (TV) Editor behavior and several behavior changes that most
  23.   users will see as improvements. These improvements are controlled by 
  24.   setting the efImprovedBehavior flag in the EditorFlags variable. It 
  25.   is set by default in TVGraphic.
  26.  
  27.   Note that TV's Editors unit does NOT duplicate the editing behavior 
  28.   of the Pascal IDE (Integrated Development Environment). In 
  29.   particular, TV and TVGraphic's selected (highlighted) blocks are 
  30.   released whenever the cursor is moved. You cannot Undo more than once
  31.   or after you have moved the cursor. The max file size is 64K. EMS is
  32.   not supported though protected mode works.
  33.  
  34.   Several minor features from the IDE have been added to TVGraphic's
  35.   Editors. These include place markers, adjustable tab widths, and 
  36.   selecting a word in response to Ctrl-KT. The behavior when moving the 
  37.   cursor word by word or deleting the word at the end of a line is like 
  38.   the IDE.  
  39.  
  40.   Two major features have been added. One is Wordwraping. The other is
  41.   the option of adding a pull down menu at the Close Icon of an editing
  42.   window.
  43.  
  44.   REGISTRATION NOTE: non-Registered versions of TVGraphic come with a
  45.     demo version of the GEditor unit. Edited files and memos can not
  46.     be saved with the demo unit.
  47. ---------------------------------
  48.  
  49. Features
  50.  
  51.   Indicator - displays "I" for AutoIndent, "W" for WordWrap enabled,
  52.       diamond shape for modified.
  53.  
  54.   Place Markers
  55.     Place markers are numbered 0 to 9 and are not visible. Set by 
  56.     Ctrl-K-number. Jump to by Ctrl-Q-number. Will not jump to a marker 
  57.     unless set. Deleting a block of text does not delete an imbedded 
  58.     marker - it remains where the block was.
  59.  
  60.   SelectWord   called by Ctrl-K-T
  61.      selects entire word under the cursor, leaves cursor at end of word
  62.  
  63.   Tabs
  64.     Display
  65.       With wordwrap it is useful to see the imbedded tabs in a
  66.       document. Tabs appear as as right arrow. Control the display with
  67.       flag efShowTabs in EditorFlags.
  68.  
  69.     Width
  70.       TabWidth field added to TEditor
  71.       Tab width may be set to a power of two (2,4,8,16..). The editors
  72.       unit has a default tab width constant. StdEditorDialog has an
  73.       added dialog to set the tab width.
  74.  
  75.   Right Margin
  76.     Field added to TEditor.
  77.     Used when reformating or wordwrapping.
  78.     StdEditorDialog has added dialog to set right margin.
  79.  
  80.   Wordwrapping - Reformating(Re-Aligning) text
  81.    (NOTE: These operations are designed to work with TVGraphic's
  82.    Improved Behavior option for Editors.)
  83.  
  84.     Wordwrap and Reformating work by looking at the last character in
  85.     a line. (The character that precedes the carriage return in the
  86.     buffer.) If the character is a space or a Tab, then the line's
  87.     carriage return is treated as a "soft" or movable carriage return.
  88.     Otherwise a line's carriage return is "hard" - it will not be
  89.     moved/deleted. No special characters are added to the file.
  90.  
  91.     Wordwrapping and Reformating work with respect to the Right Margin.
  92.     They also handle Tabs. You may change the margin or Tabwidth at any time.
  93.     They will work with AutoIndent enabled but see comments under
  94.     Wordwrap below.
  95.  
  96.     Reformating
  97.       A block reformating command (cmBlockReformat, type Ctrl-B) has
  98.       been added which will reformat text based on the Right Margin.
  99.       The reformating command may be disabled clearing a
  100.       flag in the VOptions field. Reformating begins at the start of
  101.       the line the text cursor is on and continues until it reaches a
  102.       line with a "hard" carriage return.
  103.  
  104.       Calling Reformat repeatedly until the end of the document will
  105.       re-align all the text.
  106.          while LineStart(CurPtr) <> LineStart(NextLine(CurPtr)) do
  107.                             Reformat(CurPtr);
  108.  
  109.     WordWrap
  110.       Wordwrapping is enabled if the TEditor.Wordwrap field is true. 
  111.       This field is set during construction to the value of global
  112.       DefaultWordWrap.
  113.       Wordwrap strips any leading spaces from lines following the one 
  114.       you are typing on. Wordwrap will also work (but slowly and with 
  115.       considerable redrawing flicker) with AutoIndent mode. It is a 
  116.       little strange to use this combination but it is nice for 
  117.       document files like this one.
  118.  
  119.       The Undo capability is limited to 255 chars when Wordwrap is
  120.       enabled. A dialog will ask you if you want to procede with an 
  121.       Edit operation that will exceed this limit.
  122.  
  123.  
  124.   Drop down window menu
  125.     Optionally every window can have a drop down menu in the upper left 
  126.     corner. These menus are of type TWindowPopup. Their constructor has
  127.     no TRect parameter, just a PMenu. The menu appears if the window's 
  128.     Close Icon is pressed or if Alt-spacebar is pressed. Create a 
  129.     TWindowPopup and assign it to the window's Menu field. Easy. See 
  130.     example in Editors demo program.
  131.  
  132.  
  133.  
  134. Behavior Options
  135.  
  136.   Which chars are considered parts of words
  137.     TV provides the set  (chars not in this set act to separate words)
  138.   WordChars set of Char = ['0'..'9', 'A'..'Z', '_', 'a'..'z',''''];
  139.       TVGraphic adds the ' char to the set. Modify as required.
  140.  
  141.  
  142.   Capitalization of non-English characters
  143.     This can be accomplished globally in TVGraphic by overriding the
  144.     UpCase function.  See file European.Doc
  145.  
  146.  
  147.   EditorDialog / Default Editor Dialog
  148.     In  TV's Editors unit,
  149.       the default EditorDialog := DefEditorDialog;
  150.     DefEditorDialog does nothing except return cmCancel.
  151.     You would normally assign the real Editor dialog
  152.                   EditorDialog := StdEditorDialog
  153.     in your code. This is the default assignment in GEditors.
  154.  
  155.  
  156.   Improved Behavior summary
  157.  
  158.     Deleting Text with TVGraphic's Improved behavior
  159.       To cause a selected block to be deleted during a call to
  160.       InsertText or InsertBuffer, you must set TEditor field
  161.       NeedToDelete to true before the call. The call will reset it
  162.       false. NeedToDelete has no effect if there is no selected block.
  163.  
  164.  
  165.     efImprovedBehavior       flag for EditorFlags variable.
  166.       Fixes TV Quirks.   set by default
  167.       With TV, if you enter any alpha key while a block of text is
  168.       selected (highlighted), then the selected text is deleted and the
  169.       letter is entered. If you then move the cursor at all, you cannot
  170.       undelete the deleted text. Improved behavior will deselect the
  171.       block and enter the letter you typed.
  172.  
  173.       The Delete key will delete a character unless there is a
  174.       highlighted block - then deletes the block but not the character.
  175.       Improved behavior will cause the Delete key to deselect the block
  176.       and delete the character.
  177.       Use the usual Ctrl-Delete to delete a block.
  178.       Or if you have a ClipBoard, then Shift-Delete will "Cut" the
  179.       block to the Clipboard.
  180.  
  181.     edvEnableDeleteKeyForBlockDelete      flag for TEditor.VOptions
  182.       When using efImprovedBehavior, pressing the Delete key will NOT
  183.       delete a selected block. This is like the IDE Editor window.
  184.       However you may want the Delete key to delete the selected block,
  185.       perhaps in a TMemo. If so, then set this flag after construction.
  186.  
  187.     Cursor positioning
  188.       When moving the cursor from start of one line to the end of the
  189.       previous line, TV leaves cursor at start of last word of previous
  190.       line. Improved behavior leaves cursor at end of line.
  191.       Moving left (but not right) a word at a time skips over blank
  192.       lines. Improved behavior does skip over blank lines.
  193.  
  194.     InsertText, SearchReplace do not highlight the new text. Improved
  195.       behavior will highlight new text.
  196.  
  197.  
  198.  
  199. Editors BUG Status
  200.  
  201.   Editors unit has a number of (non-Borland) published bugs.
  202.      Most were fixed in the maintanence release of Pascal 7.0 that this
  203.      unit is based on.
  204.  
  205.   1. ^T in the last word of line deletes the carriage return as well as
  206.      the word. Fixed in TVGraphic.
  207.  
  208.   2. Search
  209.      ^QF, then ^L and then typing letter deletes text.
  210.      This is the way TV's Editor's code must work by its conceptual
  211.      design. Fixed in TVGraphic.
  212.  
  213.   3. Bug (non-published)
  214.      When text cursor is in Overwrite mode, a block of text is selected
  215.      and the user enters a letter key, then the letter is inserted as
  216.      if cursor is in Insert mode. Fixed in TVGraphic.
  217.  
  218.   4. Editors uses variable ShiftState which is not reliable in
  219.      protected mode. TVGraphic uses function GetShiftState.
  220.  
  221.  
  222.  
  223. ---------------------------
  224.  
  225. A FileEditor NOT using TV's special memory buffers
  226.  
  227.  (The following discussion only applies in real mode. In protected
  228.   mode, TV uses the protected mode memory manager which does not
  229.   restrict the size of the heap when using FileEditors.)
  230.  
  231.   TV provides a special resizable buffer memory system for its
  232.   FileEditor objects. This system avoids memory fragmentation.
  233.   This is a big advantage when the purpose of the program is to have
  234.   numerous file editors open. The disadvantage is that you have to
  235.   specify at the beginning of your program how much heap space
  236.   to reserve for the non-FileEditor portion of your program.
  237.   The FileEditors get the rest of the memory. You can't change this
  238.   later.
  239.  
  240.   It is simple to override three methods to create a descendant of
  241.   FileEditor that uses the regular heap and respects the safety pool.
  242.   The code below allows the Buffer to shrink and grow. Changing the
  243.   buffer size is done by creating a second buffer and then copying
  244.   the contents from the first buffer.  So there must be enough memory for
  245.   both buffers to exist at once.
  246.   If your file/Edit buffer is/becomes over 32K bytes, the code will
  247.   set the Buffer size to the max $FFF0 (almost 64K).
  248.   Note: Repeated changing of the Buffer size mixed with other memory
  249.   allocations from the heap may/will fragment the heap.
  250.  
  251.   NOTE: The ClipBoard must use the same memory scheme (type of
  252.         FileEditor) as your other FileEditors.
  253.  
  254.  
  255.     THeapFileEditor = object(TFileEditor)
  256.       procedure InitBuffer; virtual;
  257.       procedure DoneBuffer; virtual;
  258.       function SetBufSize(NewSize: Word): Boolean; virtual;
  259.     end;
  260.  
  261.     procedure THeapFileEditor.InitBuffer;
  262.     begin
  263.          {make an initial allocation > 0  - here 4K bytes}
  264.       Buffer := MemAlloc($1000);
  265.          {next line added 11/14/94, match allocation above}
  266.       if Buffer <> nil then BufSize := $1000; 
  267.     end;
  268.     procedure THeapFileEditor.DoneBuffer; virtual;
  269.          {code from TEditor}
  270.     begin
  271.       if Buffer <> nil then
  272.       begin
  273.         FreeMem(Buffer, BufSize);
  274.         Buffer := nil;
  275.       end;
  276.     end;
  277.  
  278.     function THeapFileEditor.SetBufSize(NewSize: Word): Boolean;
  279.     var
  280.       N: Word;
  281.       BPtr : PEDitBuffer;
  282.     begin
  283.       SetBufSize := False;
  284.       if NewSize = 0 then NewSize := $1000 else
  285.         if NewSize > $F000 then NewSize := $FFF0 else
  286.           NewSize := (NewSize + $0FFF) and $F000;
  287.       if NewSize > $8000 then NewSize := $FFF0; {assign max mem if > 32K}
  288.       if NewSize <> BufSize then
  289.       begin
  290.         BPtr := MemAllocSeg(NewSize);   {allocate new buffer}
  291.         if BPtr = nil then Exit;        {Exit if not successful}
  292.         N := BufLen - CurPtr + DelCount;
  293.         Move(Buffer^[0], BPtr^[0], CurPtr);
  294.         Move(Buffer^[BufSize - N], BPtr^[NewSize - N], N);
  295.         FreeMem(Buffer, BufSize);     {free old buffer}
  296.         Buffer := BPtr;               {point to new buffer}
  297.         BufSize := NewSize;
  298.         GapLen := BufSize - BufLen;
  299.       end;
  300.       SetBufSize := True;
  301.     end;
  302.  
  303.   Now we need to create a descendant of TEDitWindow.Init that uses
  304.   the new HeapFileEditor.
  305.  
  306.     PHeapEditWindow = ^THeapEditWindow;
  307.     THeapEditWindow = object(TEditWindow)
  308.       constructor THeapEditWindow.Init(var Bounds: TRect;
  309.                   FileName: FNameStr; ANumber: Integer);
  310.     end;
  311.  
  312.     constructor THeapEditWindow.Init(var Bounds: TRect;
  313.                 FileName: FNameStr; ANumber: Integer);
  314.     const
  315.       Inset = FrameInset;    {distance from edge of window in pixels}
  316.     var
  317.       HScrollBar, VScrollBar: PScrollBar;
  318.       Indicator: PIndicator;
  319.       R: TRect;
  320.     begin
  321.       inherited Init(Bounds, '', ANumber);
  322.       Options := Options or ofTileable;
  323.  
  324.       R.Assign( 18*Charlen,    Size.Y-Inset-HScrollBarWidth,
  325.                 Size.X-2*Charlen, Size.Y-Inset);
  326.       HScrollBar := New(PScrollBar, Init(R));
  327.       Insert(HScrollBar);
  328.       R.Assign(Size.X-Inset-VScrollBarWidth, Boxheight,
  329.                Size.X-Inset, Size.Y-Boxheight);
  330.       VScrollBar := New(PScrollBar, Init(R));
  331.       Insert(VScrollBar);
  332.       if Frame <> nil then with Frame^ do
  333.         VOptions := VOptions or tfVScrollBar or tfHScrollBar;
  334.  
  335.       R.Assign( 2*Charlen,    Size.Y-Inset-HScrollBarWidth,
  336.                16*Charlen -1, Size.Y-Inset-1);
  337.       Indicator := New(PIndicator, Init(R));
  338.       Insert(Indicator);
  339.  
  340.       GetMaxSubViewSize(R);
  341.           {use THeapFileEditor type}
  342.      Editor := New(PHeapFileEditor, Init(
  343.         R, HScrollBar, VScrollBar, Indicator, FileName));
  344.       Insert(Editor);
  345.     end;
  346.  
  347. -----------------------
  348.  
  349. REFERENCE
  350.  
  351. Note: TVGraphic's TEditor.ClipCopy
  352.   sets ClipBoard^.CanUndo false automatically. Borland recommends always
  353.   doing this (manaully) for the clipboard on page 267 of TV2.0 guide.
  354.  
  355. Note: TMemo palette has been changed.
  356.  
  357. * = unique to TVGraphic
  358. + = modified in TVGraphic
  359.  
  360. const
  361.   used in TEditor.VOptions field
  362.  
  363. *   edvEnableDeleteKeyForBlockDelete = $40;
  364.         When using efImprovedBehavior, the Delete key no longer deletes
  365.         a selected block - it just deletes the character the cursor is on.
  366.         This is like the IDE. To delete a selected block, use Ctrl-Delete.
  367.         If you want the Delete key to delete the selcted block, set
  368.         this flag in the view's VOptions field.
  369.  
  370. *   edvReformat = $40;    {cmBlockReformat enabled when this bit set}
  371.  
  372.   global
  373.       values used to set TabWidth, Wordwrap in TEditor.Init
  374. *   DefaultTabWidth : byte = 4;  {width of tabs, Value MUST be power of two!}
  375. *   DefaultWordWrap : boolean = true;  {Wordwrap is disabled if false}
  376.  
  377. *   MinRm = 20;         {right margin limits for wordwrap/reformating}
  378. *   MaxRm = 128;
  379.  
  380. *   cmBlockReformat  = 526;    keycode Ctrl-B
  381. *   cmSelectWord     = 527;    keycode Ctrl-K-T
  382. *   cmJumpToMark     = 528;    keycode Ctrl-Q-number
  383. *   cmSetMark        = 529;    keycode Ctrl-K-number
  384. *   cmSetRightMargin = 530;
  385. *   cmSetTabWidth    = 531;
  386. *   cmToggleWordwrap = 532;
  387.  
  388.     MaxLineLength = 256;                 used by TEditor
  389. *   MaxMemoLineLength : byte = 128;      used by TMemo
  390.  
  391.   used with StdEditorDialog
  392.  
  393. *   edWordWrapNoUndo = 11;
  394. *   edSetRightMargin = 12;
  395. *   edSetTabWidth    = 13;
  396.  
  397.   used in EditorFlags to control all Editor views
  398.  
  399. *   efShowTabs        = $0080;
  400. *   efImprovedBehavior = $1000;
  401.  
  402.   TMemo Palette
  403.  
  404. +   CMemo   = #19#20;  {was  CMemo = #26#27;  TV2.0}
  405.              {#19#20 is InputLine Normal,Selected}
  406.  
  407.  
  408. global functions
  409.  
  410. + function StdEditorDialog(Dialog: Integer; Info: Pointer): Word;
  411.     add dialogs for
  412.       setting right margin
  413.       setting tab width
  414.       notifying user that current operation is too big to Undo with
  415.         Wordwrap enabled.
  416.  
  417. const
  418. + WordChars: set of Char = ['0'..'9', 'A'..'Z', '_', 'a'..'z',''''];
  419.         added apostrophe ' to WordChars
  420. + EditorDialog: TEditorDialog = StdEditorDialog {DefEditorDialog};
  421.         assign the StdEditorDialog, rather than DefaultEditorDialog
  422.         which does nothing.
  423.   EditorFlags: Word = efBackupFiles + efPromptOnReplace
  424. *     {added}         + efImprovedBehavior + efShowTabs;
  425.  
  426.  
  427. type
  428.   PIndicator = ^TIndicator;  only new or changed methods/fields listed
  429.   TIndicator = object(TView)
  430. *   AutoIndent : boolean;
  431. *   WordWrap : boolean;
  432. +   constructor Init(var Bounds: TRect);
  433.         sets VFont := font8x8;
  434. +   procedure SetState(AState: Word; Enable: Boolean); virtual;
  435.         calls inherited SetState, then
  436.         if AState and (sfActive) <> 0 then DrawView;
  437.         no code for sfDragging
  438. +   procedure SetValue(ALocation: TPoint; AModified,AIndent,AWrap : boolean);
  439.         Also sets new fields AutoIndent and Wordwrap based on AIndent,AWrap.
  440.         Redraws if necessary.
  441.   end;
  442.  
  443. type
  444.   PEditor = ^TEditor;        only new or changed methods/fields listed
  445.   TEditor = object(TView)
  446. *   WordWrap : boolean;
  447. *   Spacing : TPoint;      {READ ONLY - set with SetSpacing
  448.                             number of pixels that view scrolls by -
  449.                               Spacing.x must be 8,
  450.                               match Spacing.y to your font}
  451. *   TabWidth : byte;        {2,4,8,...}
  452. *   RightMargin : byte;     {for reformating and wordwrap}
  453. *   NeedToDelete : boolean; {temp,
  454.            used when efImprovedBehavior is set in EditorFlags.
  455.            Or with wordwrap.
  456.            Must set true before calling InsertText or InsertBuffer if
  457.              you want the existing selected block to be deleted.
  458.            No effect if no selected block.}
  459. +   constructor Init(var Bounds: TRect;
  460.       AHScrollBar, AVScrollBar: PScrollBar;
  461.       AIndicator: PIndicator; ABufSize: Word);
  462.         usual code plus
  463.         SetSpacing(Charlen, Boxheight);  {default settings,
  464.               Must precede SetBufLen to prevent division by 0 in DoUpDate}
  465.         SetBufLen(0); {existing code}
  466.  
  467.         EventMask := EventMask or evTimerTick;  need to enable TimerTick
  468.                                                 events so can flash cursor
  469.         TabWidth := DefaultTabWidth;
  470.         if DefaultRightMargin = 0 then
  471.           RightMargin := ((Size.x+1) div Spacing.x)-1  {autosize}
  472.         else RightMargin := DefaultRightMargin;  {default setting}
  473.         VOptions := edvReformat;
  474.         Wordwrap := DefaultWordWrap;
  475.         VFont := font8x14;                      text font
  476. +   constructor Load(var S: TStream);
  477.         load Wordwrap,Spacing,TabWidth,RightMargin
  478. +   procedure ChangeBounds(var Bounds: TRect); virtual;
  479.         use Spacing field
  480. +   procedure ConvertEvent(var Event: TEvent); virtual;
  481.         Event.InfoChar := UserChar;  {return chars "0"-"9" for keys 0..9}
  482. +   function CursorVisible: Boolean;
  483.         use Spacing field
  484. +   procedure DeleteSelect;
  485.         sets NeedToDelete := true; before calling InsertText
  486. +   procedure Draw; virtual;
  487.         use Spacing.y
  488. +   procedure HandleEvent(var Event: TEvent); virtual;
  489.       if ImprovedBehavior:
  490.         a selected block is not deleted whena keystoke is entered.
  491.         cmWordLeft - modified to leave cursor at end of line
  492.         cmBackSpace - modified if Wordwrap is true
  493.         cmDelChar - if ImprovedBehavior and HasSelection
  494.               and (VOptions and edvEnableDeleteKeyForBlockDelete <>0) then
  495.               DeleteSelect
  496.             otherwise original DeleteRange()
  497.       all cases
  498.         cmIndentMode: begin
  499.                         AutoIndent := not AutoIndent;
  500.                         UpDate(ufUpDate);
  501.                       end;
  502.         cmBlockReformat: if (VOptions and edvReformat <> 0)
  503.                    then Reformat(CurPtr, true);
  504.         cmSetMark : SetPlaceMarker(Ord(Event.InfoChar) - 48);
  505.         cmJumpToMark: JumpToPlaceMarker(Ord(Event.InfoChar)-48, SelectMode);
  506.         cmSelectWord : SelectWord;  
  507.         cmSetRightMargin : StdEditorDialog(edSetRightMargin, @RightMargin);
  508.         cmSetTabWidth :    StdEditorDialog(edSetTabWidth, @TabWidth);
  509.         cmToggleWordwrap : begin
  510.                              WordWrap := not WordWrap;
  511.                              UpDate(ufUpDate);
  512.                            end;
  513. *   function HorzTextOffset : integer; virtual;
  514.         HorzTextOffset := 1;
  515. *   function ImprovedBehavior : boolean;
  516.         true if efImprovedBehavior flag set in EditorFlags and
  517.         not the Clipboard
  518. +   function InsertBuffer(var P: PEditBuffer; Offset, Length: Word;
  519.       AllowUndo, SelectText: Boolean): Boolean;
  520.         updates Placemarkers.
  521.         if ImprovedBehavior then to kill instant delete of selected block.
  522.         much redrawing control
  523. +   function InsertFrom(Editor: PEditor): Boolean; virtual;
  524.         add highlight to inserted block if improved behavior
  525. +   function InsertText(Text: Pointer; Length: Word;
  526.       SelectText: Boolean): Boolean;
  527.         warn user if block is too big to Undo if in wordwrap
  528.           if WordWrap and CanUndo and NeedToDelete
  529.            and ((SelEnd-SelStart) > 255) then
  530.              StdEditorDialog(edWordWrapNoUndo, nil)
  531.         after calling InsertBuffer,
  532.           call Reformat(CurPtr, false) if Wordwrap is true.
  533. *   procedure Reformat(APtr : word; BlockReformat : boolean);
  534.         Does the reformating starting at line containing APtr.
  535.         If BlockReformat is true, leaves cursor at end of block,
  536.         otherwise cursor doesn't move.
  537. +   procedure ScrollTo(X, Y: Integer);
  538.         use Spacing
  539. +   function Search(const FindStr: String; Opts: Word): Boolean;
  540. +   procedure SetSelect(NewStart, NewEnd: Word; CurStart: Boolean);
  541.         added much redrawing control
  542. *   procedure SetSpacing(XSpacing, YSpacing : byte); virtual;
  543.         Spacing.x := Charlen;       {required in v2.0}
  544.         if YSpacing = 0 then Spacing.y := 1; {prevent divide by zero}
  545.         else Spacing.y := YSpacing;
  546.         UpDate(ufView);              {redraw}
  547. +   procedure Store(var S: TStream);
  548.         store Wordwrap,Spacing,TabWidth,RightMargin
  549. +   procedure TrackCursor(Center: Boolean);
  550.         use Spacing
  551. +   procedure Undo;
  552.       usual code, then add
  553.       >NeedToDelete := true;
  554.       InsertBuffer(Buffer, CurPtr + GapLen - Length, Length, False, True);
  555.       >if WordWrap then Reformat(CurPtr, false);
  556. *   function VertTextSpacing : integer; virtual;
  557.         VertTextSpacing := Spacing.y;
  558.   private
  559. +   UpdateFlags: word {Byte};
  560.  
  561. *   OldSelStart : word;  {temp, previous value of SelStart}
  562. *   OldSelEnd   : word;  {temp, previous vsalue of SelEnd}
  563. *   OldDelta : TPoint;   {temp, saves previous value of Delta - see if
  564.                                   scrolled}
  565. *   SaveCurPtr : word;   {temp, saves previous value of CurPtr}
  566. *   Reformating : boolean;
  567. *   PlaceMarker : array [0..9] of Word; {array to hold place markers}
  568. *   SaveDelCount : word;
  569.  
  570. *   procedure  JumpToPlaceMarker (MarkNum : Byte; SelectMode : Byte);
  571. *   procedure  SetPlaceMarker(MarkNum : Byte);
  572. *   procedure  UpdatePlaceMarkers (AddCount : Word; EraseCount : Word;
  573.                                      StartPtr, EndPtr : Word);
  574. *   procedure SelectWord;
  575.         if CutPtr is in a word, this procedure will select the entire word.
  576. *   function WrapWordLength(APtr : word) : word;
  577.         returns length of word at APtr based on what word wrap
  578.         algorithm can wrap. returns 0 for CR only line.
  579. +   function CharPos(P, Target: Word): Integer;
  580. +   function CharPtr(P: Word; Target: Integer): Word;
  581. +   function ClipCopy: Boolean;
  582.        ClipBoard^.CanUndo := false;  {Borland recommendation}
  583. +   procedure DeleteRange(StartPtr, EndPtr: Word; DelSelect: Boolean);
  584.         If DelSelect is true, does not call DeleteSelect for existing
  585.         select block if ImprovedBehavior is true.
  586.         If DelSelect is false, only calls DeleteSelect if there is
  587.         something to delete between StartPtr,CurPtr,EndPtr.
  588.  
  589. +   procedure DoUpdate;
  590.         redrawing code completely rewritten
  591. +   procedure DoSearchReplace;
  592.         use Spacing
  593.         set NeedToDelete := true; before calling InsertText
  594.         set last parameter in call to InsertText to ImprovedBehavior
  595. +   procedure DrawLines(Y, Count: Integer; LinePtr: Word;
  596.                     DrawAll : boolean); virtual;
  597.                      {rewritten, added new parameter}
  598. +   procedure FormatLine(var DrawBuf; LinePtr: Word;
  599.       Width: Integer; Colors: Word; TabWidth_1 : byte; EdFlags : word);
  600.                                     {new parameter}
  601. +   function GetMousePtr(Mouse: TPoint): Word;
  602. +   function NextWord(P: Word; Deleting : boolean): Word;
  603.         added new parameter
  604.         code rewritten so Ctrl-T (^T) in last word of line doesn't
  605.           erase the line's carriage return.
  606.           If not deleting the word, go to first WordChar of next word.
  607.           If deleting, then go to last WordChar of this word. Like IDE.
  608. +   function PrevLine(P: Word): Word;
  609. +   procedure SetBufLen(Length: Word);  virtual;  {add virtual 1/28/94}
  610. +   procedure Update(AFlags: word {Byte});
  611.   end;
  612.  
  613. type
  614.   PMemo = ^TMemo;            only new or changed methods/fields listed
  615.   TMemo = object(TEditor)
  616. *   constructor Init(var Bounds: TRect;
  617.       AHScrollBar, AVScrollBar: PScrollBar;
  618.       AIndicator: PIndicator; ABufSize: Word);
  619.         calls inherited Init, then
  620.         sets ofFramed flag in Options to draw its own frame
  621.     function GetPalette: PPalette; virtual;
  622.         uses modified CMemo palette
  623.   private
  624. *   procedure SetBufLen(Length: Word);   virtual;
  625.         TEditor.SetBufLen(Length);
  626.         Limit.X := MaxMemoLineLength;
  627.   end;
  628.  
  629.  
  630. type
  631.   PFileEditor = ^TFileEditor;  only new or changed methods/fields listed
  632.   TFileEditor = object(TEditor)
  633.     FileName: FNameStr;
  634. +   constructor Init(var Bounds: TRect;
  635.       AHScrollBar, AVScrollBar: PScrollBar;
  636.       AIndicator: PIndicator; AFileName: FNameStr);
  637.           if memory for the file FileName is not available (file too
  638.           big, etc.), resets the filename to ''. This prevents user from
  639.           accidently saving an empty file on top of an existing file.
  640.             if not IsValid then begin
  641.               FileName := '';
  642.               Message(Owner, evBroadcast, cmUpdateTitle, nil);
  643.             end;
  644.   end;
  645.  
  646.  
  647. type
  648.   PEditWindow = ^TEditWindow;
  649.   TEditWindow = object(TWindow)
  650.     Editor: PFileEditor;
  651. +   constructor Init(var Bounds: TRect;
  652.       FileName: FNameStr; ANumber: Integer);
  653. +   procedure HandleEvent(var Event: TEvent); virtual;
  654.         for broadcasts of cmUpdateTitle then
  655.             begin
  656.               Frame^.DrawView;
  657.               with Editor^ do begin
  658.                 if HScrollBar <> nil then HScrollBar^.DrawView;
  659.                 if VScrollBar <> nil then VScrollBar^.DrawView;
  660.                 if Indicator <> nil then Indicator^.DrawView;
  661.               end;
  662.             end;
  663.             ClearEvent;
  664. *   procedure SizeLimits(var Min, Max: TPoint); virtual;
  665.         Min.X := 23*Charlen-1;  {was 23}
  666.   end;
  667.