riched20: Use para and row ptrs in the row number from offset function.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
410dceb939
commit
b132d8bf05
|
@ -4312,17 +4312,13 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
|
||||||
}
|
}
|
||||||
case EM_LINEFROMCHAR:
|
case EM_LINEFROMCHAR:
|
||||||
{
|
{
|
||||||
if (wParam == -1)
|
if (wParam == -1) wParam = ME_GetCursorOfs( editor->pCursors + 1 );
|
||||||
return ME_RowNumberFromCharOfs(editor, ME_GetCursorOfs(&editor->pCursors[1]));
|
return row_number_from_char_ofs( editor, wParam );
|
||||||
else
|
|
||||||
return ME_RowNumberFromCharOfs(editor, wParam);
|
|
||||||
}
|
}
|
||||||
case EM_EXLINEFROMCHAR:
|
case EM_EXLINEFROMCHAR:
|
||||||
{
|
{
|
||||||
if (lParam == -1)
|
if (lParam == -1) lParam = ME_GetCursorOfs( editor->pCursors + 1 );
|
||||||
return ME_RowNumberFromCharOfs(editor, ME_GetCursorOfs(&editor->pCursors[1]));
|
return row_number_from_char_ofs( editor, lParam );
|
||||||
else
|
|
||||||
return ME_RowNumberFromCharOfs(editor, lParam);
|
|
||||||
}
|
}
|
||||||
case EM_LINEINDEX:
|
case EM_LINEINDEX:
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,7 +118,7 @@ ME_Row *row_from_cursor( ME_Cursor *cursor ) DECLSPEC_HIDDEN;
|
||||||
ME_Row *row_from_row_number( ME_TextEditor *editor, int row_num ) DECLSPEC_HIDDEN;
|
ME_Row *row_from_row_number( ME_TextEditor *editor, int row_num ) DECLSPEC_HIDDEN;
|
||||||
ME_Row *row_next( ME_Row *row ) DECLSPEC_HIDDEN;
|
ME_Row *row_next( ME_Row *row ) DECLSPEC_HIDDEN;
|
||||||
ME_Run *row_next_run( ME_Row *row, ME_Run *run ) DECLSPEC_HIDDEN;
|
ME_Run *row_next_run( ME_Row *row, ME_Run *run ) DECLSPEC_HIDDEN;
|
||||||
int ME_RowNumberFromCharOfs(ME_TextEditor *editor, int nOfs) DECLSPEC_HIDDEN;
|
int row_number_from_char_ofs( ME_TextEditor *editor, int ofs ) DECLSPEC_HIDDEN;
|
||||||
static inline ME_DisplayItem *row_get_di( ME_Row *row )
|
static inline ME_DisplayItem *row_get_di( ME_Row *row )
|
||||||
{
|
{
|
||||||
return (ME_DisplayItem *)((ptrdiff_t)row - offsetof(ME_DisplayItem, member));
|
return (ME_DisplayItem *)((ptrdiff_t)row - offsetof(ME_DisplayItem, member));
|
||||||
|
|
|
@ -102,33 +102,28 @@ ME_Row *row_from_row_number( ME_TextEditor *editor, int row_num )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int row_number_from_char_ofs( ME_TextEditor *editor, int ofs )
|
||||||
ME_RowNumberFromCharOfs(ME_TextEditor *editor, int nOfs)
|
|
||||||
{
|
{
|
||||||
ME_DisplayItem *item = ME_FindItemFwd(editor->pBuffer->pFirst, diParagraph);
|
ME_Paragraph *para = editor_first_para( editor );
|
||||||
int nRow = 0;
|
ME_Row *row;
|
||||||
|
ME_Cursor cursor;
|
||||||
|
int row_num = 0;
|
||||||
|
|
||||||
while (item->type == diParagraph &&
|
while (para_next( para ) && para_next( para )->nCharOfs <= ofs)
|
||||||
item->member.para.next_para->member.para.nCharOfs <= nOfs)
|
|
||||||
{
|
|
||||||
nRow += item->member.para.nRows;
|
|
||||||
item = item->member.para.next_para;
|
|
||||||
}
|
|
||||||
if (item->type == diParagraph)
|
|
||||||
{
|
|
||||||
ME_DisplayItem *next_para = item->member.para.next_para;
|
|
||||||
|
|
||||||
nOfs -= item->member.para.nCharOfs;
|
|
||||||
item = ME_FindItemFwd(item, diRun);
|
|
||||||
while ((item = ME_FindItemFwd(item, diStartRowOrParagraph)) != NULL)
|
|
||||||
{
|
{
|
||||||
if (item == next_para)
|
row_num += para->nRows;
|
||||||
break;
|
para = para_next( para );
|
||||||
item = ME_FindItemFwd(item, diRun);
|
|
||||||
if (item->member.run.nCharOfs > nOfs)
|
|
||||||
break;
|
|
||||||
nRow++;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return nRow;
|
if (para_next( para ))
|
||||||
|
{
|
||||||
|
for (row = para_first_row( para ); row; row = row_next( row ))
|
||||||
|
{
|
||||||
|
row_end_cursor( row, &cursor, TRUE );
|
||||||
|
if (ME_GetCursorOfs( &cursor ) > ofs ) break;
|
||||||
|
row_num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return row_num;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue