trichview.com

trichview.support




Re: Insert/overwrite modes


Return to index


Author

Message

Sergey Tkachenko

Posted: 08/28/2004 22:21:46


Hi,


It does not support overwrite mode directly.

But one solution is possible - selecting a next character after caret on key

pressing.

The code is below.



var IgnoreNextChar: Boolean = False;


procedure TForm1.RichViewEdit1KeyDown(Sender: TObject; var Key: Word;

  Shift: TShiftState);

begin

  IgnoreNextChar := RichViewEdit1.SelectionExists;

end;


procedure TForm1.RichViewEdit1KeyPress(Sender: TObject; var Key: Char);

var rve: TCustomRichViewEdit;

    ItemNo, Offs: Integer;

begin

  if IgnoreNextChar then begin

    IgnoreNextChar := False;

    exit;

  end;

  IgnoreNextChar := False;

  if not ((Key=#9) or (Key>=' ')) then

    exit;

  rve := RichViewEdit1;

  while rve.InplaceEditor<>nil do

    rve := TCustomRichViewEdit(rve.InplaceEditor);

  if rve.SelectionExists then

    exit;

  ItemNo := rve.CurItemNo;

  Offs  := rve.OffsetInCurItem;

  if (Offs>=rve.GetOffsAfterItem(ItemNo)) then begin

    if (ItemNo+1<rve.ItemCount) and

       not rve.IsFromNewLine(ItemNo+1) then begin

      inc(ItemNo);

      Offs := rve.GetOffsBeforeItem(ItemNo);

      end

    else

      exit;

  end;

  rve.SetSelectionBounds(ItemNo, Offs, ItemNo, Offs+1);

  rve.Invalidate;

end;






> Hi,

>

> TRichViewEdit can change between Insert mode and overwrite mode?

>

> if can not, are you planning to support?

>

> Thanks,

>

> Lee






> Hi Sergey,

>

> I need to switch TRichViewEdit editing from insert to overwrite mode, as

> available in most editors. Is it possible?

>

> Thanks,

> Gustavo Ricardi

>

>





Powered by ABC Amber Outlook Express Converter