trichview.com

trichview.support




Re: How to move caret to line/col


Return to index


Author

Message

Sergey Tkachenko

Posted: 01/16/2005 15:05:32


The method GetCurrentLineCol returns the current line and column.


The function below moves the caret to the beginning of the given line:


// LineNo is counted from 1

procedure GoToLine(rve: TCustomRichViewEdit; LineNo: Integer);

var i, ItemNo, Offs: Integer;

begin

  for i := 0 to rve.RVData.DrawItems.Count-1 do

    if rve.RVData.DrawItems[i].FromNewLine then begin

      dec(LineNo);

      if LineNo=0 then begin

        rve.RVData.DrawItem2Item(i, rve.RVData.GetOffsBeforeDrawItem(i),

ItemNo, Offs);

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

        rve.Invalidate;

        exit;

      end;

    end;

end;


Note: a line wrapping depends on window width, the number of lines is not a

characteristic of document.


> Hi

>

> Can't find this topic: "Move Caret to Line/Col".

> How to do it ?  And how to know where is caret now ?

>

>





Powered by ABC Amber Outlook Express Converter