trichview.support
Re: Problem moving caret to line |
Author |
Message |
Sergey Tkachenko |
Posted: 12/14/2004 0:41:41 It's ported to C++ not very accurately. May be my way of code formatting (aligning "end" not by "begin" but by "if" or "for") confused you. Here is the fixed version: - removed {} for if(rve->RVData->GetItemStyle(rve->RVData->DrawItems->Items[DItemNo]->ItemNo) ==rvsListMarker) - added {} for the second for - added break in the second for - changed condition for the second for. I made these changes in the newsgroup readed and did not test them, so may be I missed something. 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; ++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; break; } 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