trichview.com

trichview.support




Re: Problem moving caret to line


Return to index


Author

Message

Marcus

Posted: 12/09/2004 23:41:37


here it goes...



int GetDItemLength(TCustomRichViewEdit *rve, int i)

{

  TRVDrawLines *asd = rve->RVData->DrawItems;

      if(rve->RVData->GetItemStyle(rve->RVData->DrawItems->Items[i]->ItemNo)

< 0)

    return 1;

  else

    return rve->RVData->DrawItems->Items[i]->Length;

}


bool MoveToLineCol(TCustomRichViewEdit *rve, int Line, int Col)

{

  int i, DItemNo, DOffs;


  bool Result = False;

  DItemNo = -1;

  DOffs   = -1;

  for(i = 0; i<rve->RVData->DrawItems->Count; ++i)

  {

    if(rve->RVData->DrawItems->Items[i]->FromNewLine)

    {

      --Line;

      if(Line == 0)

      {

        DItemNo = i;

        break;

      }

    }

  }

  if(DItemNo<0)

    return Result;


  if(rve->RVData->GetItemStyle(rve->RVData->DrawItems->Items[DItemNo]->ItemNo)==rvsListMarker)

  {

    ++DItemNo;

    if(GetDItemLength(rve, DItemNo)+1>=Col)

    {

      DOffs = rve->RVData->GetOffsBeforeDrawItem(DItemNo)+Col-1;

      Result = True;

    }

    else

    {

      Col -= GetDItemLength(rve, DItemNo)+1;

      for(i = DItemNo+1; i<rve->RVData->DrawItems->Count-1; ++i)

        if(rve->RVData->DrawItems->Items[i]->FromNewLine)

          return Result;

      if(GetDItemLength(rve, i)>=Col)

      {

        DItemNo = i;

        DOffs = rve->RVData->GetOffsBeforeDrawItem(DItemNo)+Col;

        Result = True;

      }

      Col -= GetDItemLength(rve, i);

    }

  }


  rve->RVData->DrawItem2Item(DItemNo, DOffs, DItemNo, DOffs);

  bool focused = rve->Focused();

  rve->SetSelectionBounds(DItemNo, DOffs, DItemNo, DOffs);

  rve->Invalidate();


  return Result;

}





Powered by ABC Amber Outlook Express Converter