@@ -207,34 +207,39 @@ void THelpTopic::addParagraph( TParagraph *p )
207
207
void THelpTopic::getCrossRef ( int i, TPoint& loc, uchar& length,
208
208
int & ref )
209
209
{
210
- int oldOffset, curOffset, offset, paraOffset;
210
+ int curOffset, offset, paraOffset;
211
211
TParagraph *p;
212
212
int line;
213
213
TCrossRef *crossRefPtr;
214
214
215
215
paraOffset = 0 ;
216
216
curOffset = 0 ;
217
- oldOffset = 0 ;
218
217
line = 0 ;
219
218
crossRefPtr = crossRefs + i;
220
219
offset = crossRefPtr->offset ;
221
220
p = paragraphs;
222
- while (paraOffset + curOffset < offset)
223
- {
224
- oldOffset = paraOffset + curOffset;
221
+ do {
222
+ int lineOffset = curOffset;
225
223
wrapText (p->text , p->size , curOffset, p->wrap );
226
224
++line;
225
+ if (offset <= paraOffset + curOffset)
226
+ {
227
+ int refOffset = offset - (paraOffset + lineOffset) - 1 ;
228
+ TStringView textBefore (&p->text [lineOffset], refOffset);
229
+ TStringView refText (&p->text [lineOffset + refOffset], crossRefPtr->length );
230
+ loc.x = strwidth (textBefore);
231
+ loc.y = line;
232
+ length = strwidth (refText);
233
+ ref = crossRefPtr->ref ;
234
+ return ;
235
+ }
227
236
if (curOffset >= p->size )
228
237
{
229
238
paraOffset += p->size ;
230
239
p = p->next ;
231
240
curOffset = 0 ;
232
241
}
233
- }
234
- loc.x = offset - oldOffset - 1 ;
235
- loc.y = line;
236
- length = crossRefPtr->length ;
237
- ref = crossRefPtr->ref ;
242
+ } while (True);
238
243
}
239
244
240
245
TStringView THelpTopic::getLine ( int line )
0 commit comments