Commit 00fa9a95 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Use paragraph and run ptrs in the cursor structure.

parent 12dd2d5d
......@@ -26,16 +26,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(richedit);
void ME_SetCursorToStart(ME_TextEditor *editor, ME_Cursor *cursor)
{
cursor->pPara = para_get_di( editor_first_para( editor ) );
cursor->pRun = run_get_di( para_first_run( &cursor->pPara->member.para ) );
cursor->para = editor_first_para( editor );
cursor->run = para_first_run( cursor->para );
cursor->nOffset = 0;
}
static void ME_SetCursorToEnd(ME_TextEditor *editor, ME_Cursor *cursor, BOOL final_eop)
{
cursor->pPara = para_get_di( para_prev( editor_end_para( editor ) ) );
cursor->pRun = run_get_di( para_end_run( &cursor->pPara->member.para ) );
cursor->nOffset = final_eop ? cursor->pRun->member.run.len : 0;
cursor->para = para_prev( editor_end_para( editor ) );
cursor->run = para_end_run( cursor->para );
cursor->nOffset = final_eop ? cursor->run->len : 0;
}
......@@ -205,12 +205,12 @@ int set_selection_cursors(ME_TextEditor *editor, int from, int to)
editor->pCursors[0] = editor->pCursors[1];
ME_MoveCursorChars(editor, &editor->pCursors[0], to - from, FALSE);
/* Selection is not allowed in the middle of an end paragraph run. */
if (editor->pCursors[1].pRun->member.run.nFlags & MERF_ENDPARA)
if (editor->pCursors[1].run->nFlags & MERF_ENDPARA)
editor->pCursors[1].nOffset = 0;
if (editor->pCursors[0].pRun->member.run.nFlags & MERF_ENDPARA)
if (editor->pCursors[0].run->nFlags & MERF_ENDPARA)
{
if (to > len)
editor->pCursors[0].nOffset = editor->pCursors[0].pRun->member.run.len;
editor->pCursors[0].nOffset = editor->pCursors[0].run->len;
else
editor->pCursors[0].nOffset = 0;
}
......@@ -222,8 +222,8 @@ void cursor_coords( ME_TextEditor *editor, ME_Cursor *cursor,
int *x, int *y, int *height )
{
ME_Row *row;
ME_Run *run = &cursor->pRun->member.run;
ME_Paragraph *para = &cursor->pPara->member.para;
ME_Run *run = cursor->run;
ME_Paragraph *para = cursor->para;
ME_Run *size_run = run, *prev;
ME_Context c;
int run_x;
......@@ -302,7 +302,7 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start,
/* Prevent deletion past last end of paragraph run. */
nChars = min(nChars, text_len - nOfs);
if (nChars == text_len) delete_all = TRUE;
start_para = &c.pPara->member.para;
start_para = c.para;
if (!bForce)
{
......@@ -318,17 +318,17 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start,
{
/* We aren't deleting anything in this run, so we will go back to the
* last run we are deleting text in. */
c.pRun = run_get_di( run_prev_all_paras( &c.pRun->member.run ) );
c.pPara = para_get_di( c.pRun->member.run.para );
c.nOffset = c.pRun->member.run.len;
c.run = run_prev_all_paras( c.run );
c.para = c.run->para;
c.nOffset = c.run->len;
}
run = &c.pRun->member.run;
run = c.run;
if (run->nFlags & MERF_ENDPARA)
{
int eollen = c.pRun->member.run.len;
int eollen = c.run->len;
BOOL keepFirstParaFormat;
if (!para_next( para_next( &c.pPara->member.para ) )) return TRUE;
if (!para_next( para_next( c.para ) )) return TRUE;
keepFirstParaFormat = (totalChars == nChars && nChars <= eollen &&
run->nCharOfs);
......@@ -354,7 +354,7 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start,
keepFirstParaFormat = TRUE;
}
}
para_join( editor, &c.pPara->member.para, keepFirstParaFormat );
para_join( editor, c.para, keepFirstParaFormat );
/* ME_SkipAndPropagateCharOffset(p->pRun, shift); */
ME_CheckCharOffsets(editor);
nChars -= (eollen < nChars) ? eollen : nChars;
......@@ -368,7 +368,7 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start,
c.nOffset -= nCharsToDelete;
para_mark_rewrap( editor, c.pRun->member.run.para );
para_mark_rewrap( editor, c.run->para );
cursor = c;
/* nChars is the number of characters that should be deleted from the
......@@ -393,7 +393,7 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start,
for (i=-1; i<editor->nCursors; i++) {
ME_Cursor *pThisCur = editor->pCursors + i;
if (i == -1) pThisCur = &c;
if (pThisCur->pRun == cursor.pRun) {
if (pThisCur->run == cursor.run) {
if (pThisCur->nOffset > cursor.nOffset) {
if (pThisCur->nOffset-cursor.nOffset < nCharsToDelete)
pThisCur->nOffset = cursor.nOffset;
......@@ -404,8 +404,8 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start,
}
if (pThisCur->nOffset == run->len)
{
pThisCur->pRun = run_get_di( run_next( &pThisCur->pRun->member.run ) );
assert( pThisCur->pRun );
pThisCur->run = run_next( pThisCur->run );
assert( pThisCur->run );
pThisCur->nOffset = 0;
}
}
......@@ -413,22 +413,19 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start,
/* c = updated data now */
if (c.pRun == cursor.pRun)
ME_SkipAndPropagateCharOffset(c.pRun, shift);
if (c.run == cursor.run)
ME_SkipAndPropagateCharOffset( run_get_di( c.run ), shift );
else
ME_PropagateCharOffset(c.pRun, shift);
ME_PropagateCharOffset( run_get_di( c.run ), shift );
if (!cursor.pRun->member.run.len)
if (!cursor.run->len)
{
TRACE("Removing empty run\n");
ME_Remove(cursor.pRun);
ME_DestroyDisplayItem(cursor.pRun);
ME_Remove( run_get_di( cursor.run ));
ME_DestroyDisplayItem( run_get_di( cursor.run ));
}
shift = 0;
/*
ME_CheckCharOffsets(editor);
*/
continue;
}
}
......@@ -590,15 +587,15 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
eol_len = 1;
}
if (cursor->nOffset == cursor->pRun->member.run.len)
if (cursor->nOffset == cursor->run->len)
{
run = run_next( &cursor->pRun->member.run );
if (!run) run = &cursor->pRun->member.run;
run = run_next( cursor->run );
if (!run) run = cursor->run;
}
else
{
if (cursor->nOffset) run_split( editor, cursor );
run = &cursor->pRun->member.run;
run = cursor->run;
}
new_para = para_split( editor, run, style, eol_str, eol_len, 0 );
......@@ -611,11 +608,11 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
int i;
for (i = 0; i < editor->nCursors; i++)
{
if (editor->pCursors[i].pRun == run_get_di( prev ) &&
if (editor->pCursors[i].run == prev &&
editor->pCursors[i].nOffset == prev->len)
{
editor->pCursors[i].pPara = para_get_di( new_para );
editor->pCursors[i].pRun = run_get_di( run );
editor->pCursors[i].para = new_para;
editor->pCursors[i].run = run;
editor->pCursors[i].nOffset = 0;
}
}
......@@ -638,18 +635,18 @@ int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs, BO
cursor->nOffset += nRelOfs;
if (cursor->nOffset < 0)
{
cursor->nOffset += cursor->pRun->member.run.nCharOfs;
cursor->nOffset += cursor->run->nCharOfs;
if (cursor->nOffset >= 0)
{
/* new offset in the same paragraph */
do {
cursor->pRun = run_get_di( run_prev( &cursor->pRun->member.run ) );
} while (cursor->nOffset < cursor->pRun->member.run.nCharOfs);
cursor->nOffset -= cursor->pRun->member.run.nCharOfs;
cursor->run = run_prev( cursor->run );
} while (cursor->nOffset < cursor->run->nCharOfs);
cursor->nOffset -= cursor->run->nCharOfs;
return nRelOfs;
}
cursor->nOffset += cursor->pPara->member.para.nCharOfs;
cursor->nOffset += cursor->para->nCharOfs;
if (cursor->nOffset <= 0)
{
/* moved to the start of the text */
......@@ -660,30 +657,29 @@ int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs, BO
/* new offset in a previous paragraph */
do {
cursor->pPara = para_get_di( para_prev( &cursor->pPara->member.para ) );
} while (cursor->nOffset < cursor->pPara->member.para.nCharOfs);
cursor->nOffset -= cursor->pPara->member.para.nCharOfs;
cursor->pRun = run_get_di( para_end_run( &cursor->pPara->member.para ) );
while (cursor->nOffset < cursor->pRun->member.run.nCharOfs) {
cursor->pRun = run_get_di( run_prev( &cursor->pRun->member.run ) );
}
cursor->nOffset -= cursor->pRun->member.run.nCharOfs;
cursor->para = para_prev( cursor->para );
} while (cursor->nOffset < cursor->para->nCharOfs);
cursor->nOffset -= cursor->para->nCharOfs;
cursor->run = para_end_run( cursor->para );
while (cursor->nOffset < cursor->run->nCharOfs)
cursor->run = run_prev( cursor->run );
cursor->nOffset -= cursor->run->nCharOfs;
}
else if (cursor->nOffset >= cursor->pRun->member.run.len)
else if (cursor->nOffset >= cursor->run->len)
{
ME_Paragraph *next_para;
int new_offset;
new_offset = ME_GetCursorOfs(cursor);
next_para = para_next( &cursor->pPara->member.para );
next_para = para_next( cursor->para );
if (new_offset < next_para->nCharOfs)
{
/* new offset in the same paragraph */
do {
cursor->nOffset -= cursor->pRun->member.run.len;
cursor->pRun = run_get_di( run_next( &cursor->pRun->member.run ) );
} while (cursor->nOffset >= cursor->pRun->member.run.len);
cursor->nOffset -= cursor->run->len;
cursor->run = run_next( cursor->run );
} while (cursor->nOffset >= cursor->run->len);
return nRelOfs;
}
......@@ -697,16 +693,16 @@ int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs, BO
/* new offset in a following paragraph */
do {
cursor->pPara = para_get_di( next_para );
cursor->para = next_para;
next_para = para_next( next_para );
} while (new_offset >= next_para->nCharOfs);
cursor->nOffset = new_offset - cursor->pPara->member.para.nCharOfs;
cursor->pRun = run_get_di( para_first_run( &cursor->pPara->member.para ) );
while (cursor->nOffset >= cursor->pRun->member.run.len)
cursor->nOffset = new_offset - cursor->para->nCharOfs;
cursor->run = para_first_run( cursor->para );
while (cursor->nOffset >= cursor->run->len)
{
cursor->nOffset -= cursor->pRun->member.run.len;
cursor->pRun = run_get_di( run_next( &cursor->pRun->member.run ) );
cursor->nOffset -= cursor->run->len;
cursor->run = run_next( cursor->run );
}
} /* else new offset is in the same run */
return nRelOfs;
......@@ -716,8 +712,8 @@ int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs, BO
BOOL
ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
{
ME_Run *run = &cursor->pRun->member.run, *other_run;
ME_Paragraph *para = &cursor->pPara->member.para;
ME_Run *run = cursor->run, *other_run;
ME_Paragraph *para = cursor->para;
int nOffset = cursor->nOffset;
if (nRelOfs == -1)
......@@ -732,7 +728,7 @@ ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
{
if (ME_CallWordBreakProc( editor, get_text( other_run, 0 ), other_run->len, other_run->len - 1, WB_ISDELIMITER )
&& !(run->nFlags & MERF_ENDPARA)
&& !(&cursor->pRun->member.run == run && cursor->nOffset == 0)
&& !(cursor->run == run && cursor->nOffset == 0)
&& !ME_CallWordBreakProc( editor, get_text( run, 0 ), run->len, 0, WB_ISDELIMITER ))
break;
run = other_run;
......@@ -740,7 +736,7 @@ ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
}
else
{
if (&cursor->pRun->member.run == run && cursor->nOffset == 0)
if (cursor->run == run && cursor->nOffset == 0)
{
para = run->para;
/* Skip empty start of table row paragraph */
......@@ -776,21 +772,21 @@ ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
else
{
para = para_next( para );
if (para_get_di( para )->type == diTextEnd)
if (!para_next( para ))
{
if (&cursor->pRun->member.run == run) return FALSE;
if (cursor->run == run) return FALSE;
nOffset = 0;
break;
}
if (para->nFlags & MEPF_ROWSTART) para = para_next( para );
if (&cursor->pRun->member.run == run) run = para_first_run( para );
if (cursor->run == run) run = para_first_run( para );
nOffset = 0;
break;
}
}
}
cursor->pPara = para_get_di( para );
cursor->pRun = run_get_di( run );
cursor->para = para;
cursor->run = run;
cursor->nOffset = nOffset;
return TRUE;
}
......@@ -818,11 +814,11 @@ ME_SelectByType(ME_TextEditor *editor, ME_SelectionType selectionType)
case stParagraph:
editor->pCursors[1] = editor->pCursors[0];
editor->pCursors[0].pRun = run_get_di( para_end_run( &editor->pCursors[0].pPara->member.para ) );
editor->pCursors[0].pPara = para_get_di( editor->pCursors[0].pRun->member.run.para );
editor->pCursors[0].nOffset = editor->pCursors[0].pRun->member.run.len;
editor->pCursors[0].run = para_end_run( editor->pCursors[0].para );
editor->pCursors[0].para = editor->pCursors[0].run->para;
editor->pCursors[0].nOffset = editor->pCursors[0].run->len;
editor->pCursors[1].pRun = run_get_di( para_first_run( &editor->pCursors[1].pPara->member.para ) );
editor->pCursors[1].run = para_first_run( editor->pCursors[1].para );
editor->pCursors[1].nOffset = 0;
break;
case stLine:
......@@ -847,8 +843,7 @@ ME_SelectByType(ME_TextEditor *editor, ME_SelectionType selectionType)
int ME_GetCursorOfs(const ME_Cursor *cursor)
{
return cursor->pPara->member.para.nCharOfs
+ cursor->pRun->member.run.nCharOfs + cursor->nOffset;
return cursor->para->nCharOfs + cursor->run->nCharOfs + cursor->nOffset;
}
/* Helper function for cursor_from_virtual_coords() to find paragraph within tables */
......@@ -910,8 +905,8 @@ static BOOL row_cursor( ME_TextEditor *editor, ME_Row *row, int x,
if (x >= run->pt.x && x < run->pt.x + run->nWidth)
{
cursor->nOffset = ME_CharFromPoint( editor, x - run->pt.x, run, TRUE, TRUE );
cursor->pRun = run_get_di( run );
cursor->pPara = para_get_di( run->para );
cursor->run = run;
cursor->para = run->para;
return exact;
}
last = run;
......@@ -920,8 +915,8 @@ static BOOL row_cursor( ME_TextEditor *editor, ME_Row *row, int x,
run = last;
cursor->pRun = run_get_di( run );
cursor->pPara = para_get_di( run->para );
cursor->run = run;
cursor->para = run->para;
return FALSE;
}
......@@ -1057,7 +1052,7 @@ static void ME_ExtendAnchorSelection(ME_TextEditor *editor)
}
case stParagraph:
editor->pCursors[1].pRun = run_get_di( para_first_run( &editor->pCursors[1].pPara->member.para ) );
editor->pCursors[1].run = para_first_run( editor->pCursors[1].para );
editor->pCursors[1].nOffset = 0;
break;
......@@ -1083,9 +1078,9 @@ static void ME_ExtendAnchorSelection(ME_TextEditor *editor)
}
case stParagraph:
editor->pCursors[0].pRun = run_get_di( para_end_run( &editor->pCursors[0].pPara->member.para ) );
editor->pCursors[0].pPara = para_get_di( editor->pCursors[0].pRun->member.run.para );
editor->pCursors[0].nOffset = editor->pCursors[0].pRun->member.run.len;
editor->pCursors[0].run = para_end_run( editor->pCursors[0].para );
editor->pCursors[0].para = editor->pCursors[0].run->para;
editor->pCursors[0].nOffset = editor->pCursors[0].run->len;
break;
default:
......@@ -1188,7 +1183,7 @@ void ME_MouseMove(ME_TextEditor *editor, int x, int y)
static int ME_GetXForArrow(ME_TextEditor *editor, ME_Cursor *pCursor)
{
ME_Run *run = &pCursor->pRun->member.run;
ME_Run *run = pCursor->run;
int x;
if (editor->nUDArrowX != -1)
......@@ -1206,8 +1201,8 @@ static int ME_GetXForArrow(ME_TextEditor *editor, ME_Cursor *pCursor)
static void
ME_MoveCursorLines(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs, BOOL extend)
{
ME_DisplayItem *pRun = pCursor->pRun;
ME_Paragraph *old_para = &pCursor->pPara->member.para, *new_para;
ME_DisplayItem *pRun = run_get_di( pCursor->run );
ME_Paragraph *old_para = pCursor->para, *new_para;
ME_DisplayItem *pItem;
int x = ME_GetXForArrow(editor, pCursor);
......@@ -1277,8 +1272,6 @@ ME_MoveCursorLines(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs, BOOL
return;
}
row_cursor( editor, &pItem->member.row, x, pCursor );
assert(pCursor->pRun);
assert(pCursor->pRun->type == diRun);
}
static void ME_ArrowPageUp(ME_TextEditor *editor, ME_Cursor *pCursor)
......@@ -1293,7 +1286,7 @@ static void ME_ArrowPageUp(ME_TextEditor *editor, ME_Cursor *pCursor)
* Doesn't make sense, but we try to be bug for bug compatible. */
editor->nUDArrowX = -1;
} else {
ME_DisplayItem *pRun = pCursor->pRun;
ME_DisplayItem *pRun = run_get_di( pCursor->run );
ME_DisplayItem *pLast;
int x, y, yd, yp;
int yOldScrollPos = editor->vert_si.nPos;
......@@ -1328,8 +1321,6 @@ static void ME_ArrowPageUp(ME_TextEditor *editor, ME_Cursor *pCursor)
row_cursor( editor, &pLast->member.row, x, pCursor );
}
assert(pCursor->pRun);
assert(pCursor->pRun->type == diRun);
}
static void ME_ArrowPageDown(ME_TextEditor *editor, ME_Cursor *pCursor)
......@@ -1348,7 +1339,7 @@ static void ME_ArrowPageDown(ME_TextEditor *editor, ME_Cursor *pCursor)
{
ME_SetCursorToEnd(editor, pCursor, FALSE);
} else {
ME_DisplayItem *pRun = pCursor->pRun;
ME_DisplayItem *pRun = run_get_di( pCursor->run );
ME_DisplayItem *p;
int yd, yp;
int yOldScrollPos = editor->vert_si.nPos;
......@@ -1382,8 +1373,6 @@ static void ME_ArrowPageDown(ME_TextEditor *editor, ME_Cursor *pCursor)
row_cursor( editor, &pLast->member.row, x, pCursor );
}
assert(pCursor->pRun);
assert(pCursor->pRun->type == diRun);
}
static void ME_ArrowHome( ME_TextEditor *editor, ME_Cursor *cursor )
......@@ -1412,7 +1401,7 @@ static void ME_ArrowCtrlEnd(ME_TextEditor *editor, ME_Cursor *pCursor)
BOOL ME_IsSelection(ME_TextEditor *editor)
{
return editor->pCursors[0].pRun != editor->pCursors[1].pRun ||
return editor->pCursors[0].run != editor->pCursors[1].run ||
editor->pCursors[0].nOffset != editor->pCursors[1].nOffset;
}
......
......@@ -348,7 +348,7 @@ static HGLOBAL get_unicode_text(ME_TextEditor *editor, const ME_Cursor *start, i
int nEnd = ME_GetCursorOfs(start) + nChars;
/* count paragraphs in range */
para = &start->pPara->member.para;
para = start->para;
while ((para = para_next( para )) && para->nCharOfs <= nEnd)
pars++;
......
......@@ -593,9 +593,9 @@ void ME_RTFParAttrHook(RTF_Info *info)
/* We are just after a table row. */
RTFFlushOutputBuffer(info);
cursor = info->editor->pCursors[0];
para = &cursor.pPara->member.para;
para = cursor.para;
if (para == para_next( info->tableDef->row_start )
&& !cursor.nOffset && !cursor.pRun->member.run.nCharOfs)
&& !cursor.nOffset && !cursor.run->nCharOfs)
{
/* Since the table row end, no text has been inserted, and the \intbl
* control word has not be used. We can confirm that we are not in a
......@@ -632,7 +632,7 @@ void ME_RTFParAttrHook(RTF_Info *info)
ME_Cursor cursor;
WCHAR endl = '\r';
cursor = info->editor->pCursors[0];
if (cursor.nOffset || cursor.pRun->member.run.nCharOfs)
if (cursor.nOffset || cursor.run->nCharOfs)
ME_InsertTextFromCursor(info->editor, 0, &endl, 1, info->style);
tableDef->row_start = table_insert_row_start( info->editor, info->editor->pCursors );
}
......@@ -658,7 +658,7 @@ void ME_RTFParAttrHook(RTF_Info *info)
if (tableDef->row_start && tableDef->row_start->nFlags & MEPF_ROWEND)
para = para_next( tableDef->row_start );
else
para = &info->editor->pCursors[0].pPara->member.para;
para = info->editor->pCursors[0].para;
tableDef->row_start = table_insert_row_start_at_para( info->editor, para );
......@@ -901,7 +901,7 @@ void ME_RTFTblAttrHook(RTF_Info *info)
{
/* Tab stops were used to store cell positions before v4.1 but v4.1
* still seems to set the tabstops without using them. */
PARAFORMAT2 *fmt = &info->editor->pCursors[0].pPara->member.para.fmt;
PARAFORMAT2 *fmt = &info->editor->pCursors[0].para->fmt;
fmt->rgxTabs[cellNum] &= ~0x00FFFFFF;
fmt->rgxTabs[cellNum] |= 0x00FFFFFF & info->rtfParam;
}
......@@ -971,7 +971,7 @@ void ME_RTFSpecialCharHook(RTF_Info *info)
}
else /* v1.0 - v3.0 */
{
ME_Paragraph *para = &info->editor->pCursors[0].pPara->member.para;
ME_Paragraph *para = info->editor->pCursors[0].para;
if (para_in_table( para ) && tableDef->numCellsInserted < tableDef->numCellsDefined)
{
......@@ -1043,13 +1043,12 @@ void ME_RTFSpecialCharHook(RTF_Info *info)
}
run = para_first_run( cell_first_para( cell ) );
if (&info->editor->pCursors[0].pRun->member.run != run ||
info->editor->pCursors[0].nOffset)
if (info->editor->pCursors[0].run != run || info->editor->pCursors[0].nOffset)
{
int nOfs, nChars;
/* Delete inserted cells that aren't defined. */
info->editor->pCursors[1].pRun = run_get_di( run );
info->editor->pCursors[1].pPara = para_get_di( run->para );
info->editor->pCursors[1].run = run;
info->editor->pCursors[1].para = run->para;
info->editor->pCursors[1].nOffset = 0;
nOfs = ME_GetCursorOfs(&info->editor->pCursors[1]);
nChars = ME_GetCursorOfs(&info->editor->pCursors[0]) - nOfs;
......@@ -1085,7 +1084,7 @@ void ME_RTFSpecialCharHook(RTF_Info *info)
{
WCHAR endl = '\r';
para = &info->editor->pCursors[0].pPara->member.para;
para = info->editor->pCursors[0].para;
para->fmt.dxOffset = info->tableDef->gapH;
para->fmt.dxStartIndent = info->tableDef->leftEdge;
......@@ -1110,7 +1109,7 @@ void ME_RTFSpecialCharHook(RTF_Info *info)
ME_Paragraph *para;
RTFFlushOutputBuffer(info);
para = &info->editor->pCursors[0].pPara->member.para;
para = info->editor->pCursors[0].para;
if (para_in_table( para ))
{
/* rtfPar is treated like a space within a table. */
......@@ -1609,20 +1608,20 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
/* Don't insert text at the end of the table row */
if (!editor->bEmulateVersion10) /* v4.1 */
{
ME_Paragraph *para = &editor->pCursors->pPara->member.para;
ME_Paragraph *para = editor->pCursors->para;
if (para->nFlags & (MEPF_ROWSTART | MEPF_ROWEND))
{
para = para_next( para );
editor->pCursors[0].pPara = para_get_di( para );
editor->pCursors[0].pRun = run_get_di( para_first_run( para ) );
editor->pCursors[0].para = para;
editor->pCursors[0].run = para_first_run( para );
editor->pCursors[0].nOffset = 0;
}
editor->pCursors[1] = editor->pCursors[0];
}
else /* v1.0 - 3.0 */
{
if (editor->pCursors[0].pRun->member.run.nFlags & MERF_ENDPARA &&
para_in_table( &editor->pCursors[0].pPara->member.para ))
if (editor->pCursors[0].run->nFlags & MERF_ENDPARA &&
para_in_table( editor->pCursors[0].para ))
return 0;
}
}
......@@ -1635,7 +1634,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
ME_GetTextLength(editor), FALSE);
from = to = 0;
ME_ClearTempStyle(editor);
editor_set_default_para_fmt( editor, &editor->pCursors[0].pPara->member.para.fmt );
editor_set_default_para_fmt( editor, &editor->pCursors[0].para->fmt );
}
......@@ -1724,8 +1723,8 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
para = para_next( para );
}
editor->pCursors[1].pPara = para_get_di( para );
editor->pCursors[1].pRun = run_get_di( para_first_run( para ) );
editor->pCursors[1].para = para;
editor->pCursors[1].run = para_first_run( para );
editor->pCursors[1].nOffset = 0;
nOfs = ME_GetCursorOfs(&editor->pCursors[1]);
nChars = ME_GetCursorOfs(&editor->pCursors[0]) - nOfs;
......@@ -1921,14 +1920,14 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
if ((flags & FR_WHOLEWORD) && nMin)
{
cursor_from_char_ofs( editor, nMin - 1, &cursor );
wLastChar = *get_text( &cursor.pRun->member.run, cursor.nOffset );
wLastChar = *get_text( cursor.run, cursor.nOffset );
ME_MoveCursorChars(editor, &cursor, 1, FALSE);
}
else cursor_from_char_ofs( editor, nMin, &cursor );
while (cursor.pRun && ME_GetCursorOfs(&cursor) + nLen <= nMax)
while (cursor.run && ME_GetCursorOfs(&cursor) + nLen <= nMax)
{
ME_Run *run = &cursor.pRun->member.run;
ME_Run *run = cursor.run;
int nCurStart = cursor.nOffset;
int nMatched = 0;
......@@ -1962,7 +1961,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
break;
}
cursor.nOffset += cursor.pPara->member.para.nCharOfs + cursor.pRun->member.run.nCharOfs;
cursor.nOffset += cursor.para->nCharOfs + cursor.run->nCharOfs;
if (chrgText)
{
chrgText->cpMin = cursor.nOffset;
......@@ -1983,16 +1982,16 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
wLastChar = ' ';
cursor.nOffset++;
if (cursor.nOffset == cursor.pRun->member.run.len)
if (cursor.nOffset == cursor.run->len)
{
if (run_next_all_paras( &cursor.pRun->member.run ))
if (run_next_all_paras( cursor.run ))
{
cursor.pRun = run_get_di( run_next_all_paras( &cursor.pRun->member.run ) );
cursor.pPara = para_get_di( cursor.pRun->member.run.para );
cursor.run = run_next_all_paras( cursor.run );
cursor.para = cursor.run->para;
cursor.nOffset = 0;
}
else
cursor.pRun = NULL;
cursor.run = NULL;
}
}
}
......@@ -2002,15 +2001,15 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
if ((flags & FR_WHOLEWORD) && nMax < nTextLen - 1)
{
cursor_from_char_ofs( editor, nMax + 1, &cursor );
wLastChar = *get_text( &cursor.pRun->member.run, cursor.nOffset );
wLastChar = *get_text( cursor.run, cursor.nOffset );
ME_MoveCursorChars(editor, &cursor, -1, FALSE);
}
else cursor_from_char_ofs( editor, nMax, &cursor );
while (cursor.pRun && ME_GetCursorOfs(&cursor) - nLen >= nMin)
while (cursor.run && ME_GetCursorOfs(&cursor) - nLen >= nMin)
{
ME_Run *run = &cursor.pRun->member.run;
ME_Paragraph *para = &cursor.pPara->member.para;
ME_Run *run = cursor.run;
ME_Paragraph *para = cursor.para;
int nCurEnd = cursor.nOffset;
int nMatched = 0;
......@@ -2080,14 +2079,14 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
cursor.nOffset--;
if (cursor.nOffset < 0)
{
if (run_prev_all_paras( &cursor.pRun->member.run ) )
if (run_prev_all_paras( cursor.run ) )
{
cursor.pRun = run_get_di( run_prev_all_paras( &cursor.pRun->member.run ) );
cursor.pPara = para_get_di( cursor.pRun->member.run.para );
cursor.nOffset = cursor.pRun->member.run.len;
cursor.run = run_prev_all_paras( cursor.run );
cursor.para = cursor.run->para;
cursor.nOffset = cursor.run->len;
}
else
cursor.pRun = NULL;
cursor.run = NULL;
}
}
}
......@@ -2448,14 +2447,14 @@ static void ME_UpdateSelectionLinkAttribute(ME_TextEditor *editor)
ME_GetSelection(editor, &from, &to);
/* Find paragraph previous to the one that contains start cursor */
start_para = &from->pPara->member.para;
start_para = from->para;
if (para_prev( start_para )) start_para = para_prev( start_para );
/* Find paragraph that contains end cursor */
end_para = para_next( &to->pPara->member.para );
end_para = para_next( to->para );
start.pPara = para_get_di( start_para );
start.pRun = run_get_di( para_first_run( start_para ) );
start.para = start_para;
start.run = para_first_run( start_para );
start.nOffset = 0;
num_chars = end_para->nCharOfs - start_para->nCharOfs;
......@@ -2497,7 +2496,7 @@ static BOOL handle_enter(ME_TextEditor *editor)
static const WCHAR endl = '\r';
static const WCHAR endlv10[] = {'\r','\n'};
ME_Cursor cursor = editor->pCursors[0];
ME_Paragraph *para = &cursor.pPara->member.para;
ME_Paragraph *para = cursor.para;
int from, to;
ME_Style *style, *eop_style;
......@@ -2517,33 +2516,32 @@ static BOOL handle_enter(ME_TextEditor *editor)
/* Add a new table row after this row. */
para = table_append_row( editor, para );
para = para_next( para );
editor->pCursors[0].pPara = para_get_di( para );
editor->pCursors[0].pRun = run_get_di( para_first_run( para ) );
editor->pCursors[0].para = para;
editor->pCursors[0].run = para_first_run( para );
editor->pCursors[0].nOffset = 0;
editor->pCursors[1] = editor->pCursors[0];
ME_CommitUndo(editor);
ME_UpdateRepaint(editor, FALSE);
return TRUE;
}
else if (para == &editor->pCursors[1].pPara->member.para &&
cursor.nOffset + cursor.pRun->member.run.nCharOfs == 0 &&
else if (para == editor->pCursors[1].para &&
cursor.nOffset + cursor.run->nCharOfs == 0 &&
para_prev( para ) && para_prev( para )->nFlags & MEPF_ROWSTART &&
!para_prev( para )->nCharOfs)
{
/* Insert a newline before the table. */
para = para_prev( para );
para->nFlags &= ~MEPF_ROWSTART;
editor->pCursors[0].pPara = para_get_di( para );
editor->pCursors[0].pRun = run_get_di( para_first_run( para ) );
editor->pCursors[0].para = para;
editor->pCursors[0].run = para_first_run( para );
editor->pCursors[1] = editor->pCursors[0];
ME_InsertTextFromCursor(editor, 0, &endl, 1,
editor->pCursors[0].pRun->member.run.style);
ME_InsertTextFromCursor( editor, 0, &endl, 1, editor->pCursors[0].run->style );
para = editor_first_para( editor );
editor_set_default_para_fmt( editor, &para->fmt );
para->nFlags = 0;
para_mark_rewrap( editor, para );
editor->pCursors[0].pPara = para_get_di( para );
editor->pCursors[0].pRun = run_get_di( para_first_run( para ) );
editor->pCursors[0].para = para;
editor->pCursors[0].run = para_first_run( para );
editor->pCursors[1] = editor->pCursors[0];
para_next( para )->nFlags |= MEPF_ROWSTART;
ME_CommitCoalescingUndo(editor);
......@@ -2553,17 +2551,17 @@ static BOOL handle_enter(ME_TextEditor *editor)
}
else /* v1.0 - 3.0 */
{
ME_Paragraph *para = &cursor.pPara->member.para;
ME_Paragraph *para = cursor.para;
if (para_in_table( para ))
{
if (cursor.pRun->member.run.nFlags & MERF_ENDPARA)
if (cursor.run->nFlags & MERF_ENDPARA)
{
if (from == to)
{
ME_ContinueCoalescingTransaction(editor);
para = table_append_row( editor, para );
editor->pCursors[0].pPara = para_get_di( para );
editor->pCursors[0].pRun = run_get_di( para_first_run( para ) );
editor->pCursors[0].para = para;
editor->pCursors[0].run = para_first_run( para );
editor->pCursors[0].nOffset = 0;
editor->pCursors[1] = editor->pCursors[0];
ME_CommitCoalescingUndo(editor);
......@@ -2574,27 +2572,26 @@ static BOOL handle_enter(ME_TextEditor *editor)
else
{
ME_ContinueCoalescingTransaction(editor);
if (cursor.pRun->member.run.nCharOfs + cursor.nOffset == 0 &&
if (cursor.run->nCharOfs + cursor.nOffset == 0 &&
para_prev( para ) && !para_in_table( para_prev( para ) ))
{
/* Insert newline before table */
cursor.pRun = run_get_di( para_end_run( para_prev( para ) ) );
if (cursor.pRun)
cursor.run = para_end_run( para_prev( para ) );
if (cursor.run)
{
editor->pCursors[0].pRun = cursor.pRun;
editor->pCursors[0].pPara = para_get_di( para_prev( para ) );
editor->pCursors[0].run = cursor.run;
editor->pCursors[0].para = para_prev( para );
}
editor->pCursors[0].nOffset = 0;
editor->pCursors[1] = editor->pCursors[0];
ME_InsertTextFromCursor(editor, 0, &endl, 1,
editor->pCursors[0].pRun->member.run.style);
ME_InsertTextFromCursor( editor, 0, &endl, 1, editor->pCursors[0].run->style );
}
else
{
editor->pCursors[1] = editor->pCursors[0];
para = table_append_row( editor, para );
editor->pCursors[0].pPara = para_get_di( para );
editor->pCursors[0].pRun = run_get_di( para_first_run( para ) );
editor->pCursors[0].para = para;
editor->pCursors[0].run = para_first_run( para );
editor->pCursors[0].nOffset = 0;
editor->pCursors[1] = editor->pCursors[0];
}
......@@ -2795,7 +2792,7 @@ static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode,
if ((unsigned)wstr >= ' ' || wstr == '\t')
{
ME_Cursor cursor = editor->pCursors[0];
ME_Paragraph *para = &cursor.pPara->member.para;
ME_Paragraph *para = cursor.para;
int from, to;
BOOL ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000;
ME_GetSelectionOfs(editor, &from, &to);
......@@ -2806,7 +2803,7 @@ static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode,
BOOL selected_row = FALSE;
if (ME_IsSelection(editor) &&
cursor.pRun->member.run.nCharOfs + cursor.nOffset == 0 &&
cursor.run->nCharOfs + cursor.nOffset == 0 &&
to == ME_GetCursorOfs(&editor->pCursors[0]) && para_prev( para ))
{
para = para_prev( para );
......@@ -2827,8 +2824,8 @@ static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode,
{
para = para_next( para );
if (para->nFlags & MEPF_ROWSTART) para = para_next( para );
editor->pCursors[0].pPara = para_get_di( para );
editor->pCursors[0].pRun = run_get_di( para_first_run( para ) );
editor->pCursors[0].para = para;
editor->pCursors[0].run = para_first_run( para );
editor->pCursors[0].nOffset = 0;
editor->pCursors[1] = editor->pCursors[0];
}
......@@ -2836,9 +2833,7 @@ static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode,
}
else /* v1.0 - 3.0 */
{
if (para_in_table( para ) &&
cursor.pRun->member.run.nFlags & MERF_ENDPARA &&
from == to)
if (para_in_table( para ) && cursor.run->nFlags & MERF_ENDPARA && from == to)
{
/* Text should not be inserted at the end of the table. */
MessageBeep(-1);
......@@ -2983,9 +2978,8 @@ static BOOL ME_SetCursor(ME_TextEditor *editor)
ME_CharFromPos(editor, pt.x, pt.y, &cursor, &isExact);
if (isExact)
{
ME_Run *run;
ME_Run *run = cursor.run;
run = &cursor.pRun->member.run;
if (is_link( run ))
{
ITextHost_TxSetCursor(editor->texthost,
......@@ -3039,10 +3033,8 @@ static LONG ME_GetSelectionType(ME_TextEditor *editor)
ME_Cursor cursor;
cursor_from_char_ofs( editor, start + i, &cursor );
if (cursor.pRun->member.run.reobj)
object_count++;
else
character_count++;
if (cursor.run->reobj) object_count++;
else character_count++;
if (character_count >= 2 && object_count >= 2)
return (SEL_TEXT | SEL_MULTICHAR | SEL_OBJECT | SEL_MULTIOBJECT);
}
......@@ -3138,7 +3130,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
ed->nUndoMode = umAddToUndo;
ed->nParagraphs = 1;
ed->nLastSelStart = ed->nLastSelEnd = 0;
ed->last_sel_start_para = ed->last_sel_end_para = &ed->pCursors[0].pPara->member.para;
ed->last_sel_start_para = ed->last_sel_end_para = ed->pCursors[0].para;
ed->bHideSelection = FALSE;
ed->pfnWordBreak = NULL;
ed->lpOleCallback = NULL;
......@@ -3459,7 +3451,7 @@ static void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM
ME_CharFromPos(editor, x, y, &cursor, &isExact);
if (!isExact) return;
if (is_link( &cursor.pRun->member.run ))
if (is_link( cursor.run ))
{ /* The clicked run has CFE_LINK set */
info.nmhdr.hwndFrom = NULL;
info.nmhdr.idFrom = 0;
......@@ -3471,13 +3463,13 @@ static void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM
/* find the first contiguous run with CFE_LINK set */
info.chrg.cpMin = ME_GetCursorOfs(&cursor);
run = &cursor.pRun->member.run;
run = cursor.run;
while ((run = run_prev( run )) && is_link( run ))
info.chrg.cpMin -= run->len;
/* find the last contiguous run with CFE_LINK set */
info.chrg.cpMax = ME_GetCursorOfs(&cursor) + cursor.pRun->member.run.len;
run = &cursor.pRun->member.run;
info.chrg.cpMax = ME_GetCursorOfs(&cursor) + cursor.run->len;
run = cursor.run;
while ((run = run_next( run )) && is_link( run ))
info.chrg.cpMax += run->len;
......@@ -4253,13 +4245,13 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
row_first_cursor( row, &start );
row_end_cursor( row, &end, TRUE );
run = &start.pRun->member.run;
run = start.run;
while (nCharsLeft)
{
WCHAR *str;
unsigned int nCopy;
int ofs = (run == &start.pRun->member.run) ? start.nOffset : 0;
int len = (run == &end.pRun->member.run) ? end.nOffset : run->len;
int ofs = (run == start.run) ? start.nOffset : 0;
int len = (run == end.run) ? end.nOffset : run->len;
str = get_text( run, ofs );
nCopy = min( nCharsLeft, len );
......@@ -4271,7 +4263,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
nCharsLeft, NULL, NULL);
dest += nCopy * (unicode ? sizeof(WCHAR) : 1);
nCharsLeft -= nCopy;
if (run == &end.pRun->member.run) break;
if (run == end.run) break;
run = row_next_run( row, run );
}
......@@ -4457,18 +4449,17 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
nCharOfs = max(nCharOfs, 0);
cursor_from_char_ofs( editor, nCharOfs, &cursor );
pt.y = cursor.pRun->member.run.pt.y;
pt.x = cursor.pRun->member.run.pt.x +
ME_PointFromChar( editor, &cursor.pRun->member.run, cursor.nOffset, TRUE );
pt.y += cursor.pPara->member.para.pt.y + editor->rcFormat.top;
pt.y = cursor.run->pt.y;
pt.x = cursor.run->pt.x +
ME_PointFromChar( editor, cursor.run, cursor.nOffset, TRUE );
pt.y += cursor.para->pt.y + editor->rcFormat.top;
pt.x += editor->rcFormat.left;
pt.x -= editor->horz_si.nPos;
pt.y -= editor->vert_si.nPos;
if (wParam >= 0x40000) {
*(POINTL *)wParam = pt;
}
if (wParam >= 0x40000) *(POINTL *)wParam = pt;
return (wParam >= 0x40000) ? 0 : MAKELONG( pt.x, pt.y );
}
case WM_CREATE:
......@@ -4910,8 +4901,8 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
/* plain text can only have the default style. */
ME_ClearTempStyle(editor);
ME_AddRefStyle(editor->pBuffer->pDefaultStyle);
ME_ReleaseStyle(editor->pCursors[0].pRun->member.run.style);
editor->pCursors[0].pRun->member.run.style = editor->pBuffer->pDefaultStyle;
ME_ReleaseStyle( editor->pCursors[0].run->style );
editor->pCursors[0].run->style = editor->pBuffer->pDefaultStyle;
}
}
/* FIXME: Currently no support for undo level and code page options */
......@@ -5165,7 +5156,7 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen,
/* bCRLF flag is only honored in 2.0 and up. 1.0 must always return text verbatim */
if (editor->bEmulateVersion10) bCRLF = FALSE;
run = &start->pRun->member.run;
run = start->run;
next_run = run_next_all_paras( run );
nLen = run->len - start->nOffset;
......@@ -5358,8 +5349,8 @@ static BOOL ME_FindNextURLCandidate(ME_TextEditor *editor,
while (nChars > 0)
{
WCHAR *str = get_text( &cursor.pRun->member.run, 0 );
int run_len = cursor.pRun->member.run.len;
WCHAR *str = get_text( cursor.run, 0 );
int run_len = cursor.run->len;
nChars -= run_len - cursor.nOffset;
......@@ -5373,8 +5364,8 @@ static BOOL ME_FindNextURLCandidate(ME_TextEditor *editor,
{
*candidate_min = cursor;
candidateStarted = TRUE;
neutral_end.pPara = NULL;
space_end.pPara = NULL;
neutral_end.para = NULL;
space_end.para = NULL;
cursor.nOffset++;
break;
}
......@@ -5393,9 +5384,9 @@ static BOOL ME_FindNextURLCandidate(ME_TextEditor *editor,
{
if (quoted && c != '\r')
{
if (!space_end.pPara)
if (!space_end.para)
{
if (neutral_end.pPara)
if (neutral_end.para)
space_end = neutral_end;
else
space_end = cursor;
......@@ -5408,15 +5399,15 @@ static BOOL ME_FindNextURLCandidate(ME_TextEditor *editor,
{
if (quoted && c == '>')
{
neutral_end.pPara = NULL;
space_end.pPara = NULL;
neutral_end.para = NULL;
space_end.para = NULL;
goto done;
}
if (!neutral_end.pPara)
if (!neutral_end.para)
neutral_end = cursor;
}
else
neutral_end.pPara = NULL;
neutral_end.para = NULL;
cursor.nOffset++;
}
......@@ -5430,9 +5421,9 @@ static BOOL ME_FindNextURLCandidate(ME_TextEditor *editor,
done:
if (candidateStarted)
{
if (space_end.pPara)
if (space_end.para)
*candidate_max = space_end;
else if (neutral_end.pPara)
else if (neutral_end.para)
*candidate_max = neutral_end;
else
*candidate_max = cursor;
......@@ -5521,7 +5512,7 @@ static BOOL ME_UpdateLinkAttribute(ME_TextEditor *editor, ME_Cursor *start, int
nChars = 0;
}
if (startCur.pRun != candidateStart.pRun ||
if (startCur.run != candidateStart.run ||
startCur.nOffset != candidateStart.nOffset)
{
/* CFE_LINK effect should be consistently unset */
......@@ -5538,15 +5529,15 @@ static BOOL ME_UpdateLinkAttribute(ME_TextEditor *editor, ME_Cursor *start, int
/* Update candidateEnd since setting character formats may split
* runs, which can cause a cursor to be at an invalid offset within
* a split run. */
while (candidateEnd.nOffset >= candidateEnd.pRun->member.run.len)
while (candidateEnd.nOffset >= candidateEnd.run->len)
{
candidateEnd.nOffset -= candidateEnd.pRun->member.run.len;
candidateEnd.pRun = ME_FindItemFwd(candidateEnd.pRun, diRun);
candidateEnd.nOffset -= candidateEnd.run->len;
candidateEnd.run = run_next_all_paras( candidateEnd.run );
}
modified = TRUE;
}
}
if (candidateStart.pRun != candidateEnd.pRun ||
if (candidateStart.run != candidateEnd.run ||
candidateStart.nOffset != candidateEnd.nOffset)
{
/* CFE_LINK effect should be consistently set */
......
......@@ -274,8 +274,8 @@ typedef struct tagME_TextBuffer
typedef struct tagME_Cursor
{
ME_DisplayItem *pPara;
ME_DisplayItem *pRun;
ME_Paragraph *para;
ME_Run *run;
int nOffset;
} ME_Cursor;
......
......@@ -437,7 +437,7 @@ static void ME_DebugWrite(HDC hDC, const POINT *pt, LPCWSTR szText) {
static void draw_run( ME_Context *c, int x, int y, ME_Cursor *cursor )
{
ME_Row *row;
ME_Run *run = &cursor->pRun->member.run;
ME_Run *run = cursor->run;
int runofs = run_char_ofs( run, cursor->nOffset );
int nSelFrom, nSelTo;
......@@ -999,8 +999,8 @@ static void draw_paragraph( ME_Context *c, ME_Paragraph *para )
{
ME_Cursor cursor;
cursor.pRun = run_get_di( run );
cursor.pPara = para_get_di( para );
cursor.run = run;
cursor.para = para;
cursor.nOffset = 0;
draw_run( c, c->pt.x + run->pt.x, c->pt.y + para->pt.y + run->pt.y + baseline, &cursor );
}
......@@ -1271,9 +1271,9 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
void editor_ensure_visible( ME_TextEditor *editor, ME_Cursor *cursor )
{
ME_Run *run = &cursor->pRun->member.run;
ME_Run *run = cursor->run;
ME_Row *row = row_from_cursor( cursor );
ME_Paragraph *para = &cursor->pPara->member.para;
ME_Paragraph *para = cursor->para;
int x, y, yheight;
......
......@@ -581,10 +581,10 @@ ME_Paragraph *para_split( ME_TextEditor *editor, ME_Run *run, ME_Style *style,
/* Update selection cursors to point to the correct paragraph. */
for (i = 0; i < editor->nCursors; i++)
{
if (editor->pCursors[i].pPara == para_get_di( old_para ) &&
run->nCharOfs <= editor->pCursors[i].pRun->member.run.nCharOfs)
if (editor->pCursors[i].para == old_para &&
run->nCharOfs <= editor->pCursors[i].run->nCharOfs)
{
editor->pCursors[i].pPara = para_get_di( new_para );
editor->pCursors[i].para = new_para;
}
}
......@@ -708,10 +708,10 @@ ME_Paragraph *para_join( ME_TextEditor *editor, ME_Paragraph *para, BOOL use_fir
/* null char format operation to store the original char format for the ENDPARA run */
ME_InitCharFormat2W(&fmt);
startCur.pPara = para_get_di( para );
startCur.pRun = run_get_di( end_run );
endCur.pPara = para_get_di( next );
endCur.pRun = run_get_di( next_first_run );
startCur.para = para;
startCur.run = end_run;
endCur.para = next;
endCur.run = next_first_run;
startCur.nOffset = endCur.nOffset = 0;
ME_SetCharFormat(editor, &startCur, &endCur, &fmt);
......@@ -757,13 +757,13 @@ ME_Paragraph *para_join( ME_TextEditor *editor, ME_Paragraph *para, BOOL use_fir
* paragraph run, and point to the correct paragraph. */
for (i = 0; i < editor->nCursors; i++)
{
if (editor->pCursors[i].pRun == run_get_di( end_run ))
if (editor->pCursors[i].run == end_run)
{
editor->pCursors[i].pRun = run_get_di( next_first_run );
editor->pCursors[i].run = next_first_run;
editor->pCursors[i].nOffset = 0;
}
else if (editor->pCursors[i].pPara == para_get_di( next ))
editor->pCursors[i].pPara = para_get_di( para );
else if (editor->pCursors[i].para == next)
editor->pCursors[i].para = para;
}
for (tmp_run = next_first_run; tmp_run; tmp_run = run_next( tmp_run ))
......@@ -869,8 +869,8 @@ void editor_get_selection_paras( ME_TextEditor *editor, ME_Paragraph **para, ME_
{
ME_Cursor *pEndCursor = &editor->pCursors[1];
*para = &editor->pCursors[0].pPara->member.para;
*para_end = &editor->pCursors[1].pPara->member.para;
*para = editor->pCursors[0].para;
*para_end = editor->pCursors[1].para;
if (*para == *para_end)
return;
......@@ -885,7 +885,7 @@ void editor_get_selection_paras( ME_TextEditor *editor, ME_Paragraph **para, ME_
/* The paragraph at the end of a non-empty selection isn't included
* if the selection ends at the start of the paragraph. */
if (!pEndCursor->pRun->member.run.nCharOfs && !pEndCursor->nOffset)
if (!pEndCursor->run->nCharOfs && !pEndCursor->nOffset)
*para_end = para_prev( *para_end );
}
......
......@@ -1390,20 +1390,20 @@ IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
TRACE("character offset: %d\n", lpreobject->cp);
cursor_from_char_ofs( This->editor, lpreobject->cp, &cursor );
if (!cursor.pRun->member.run.reobj)
if (!cursor.run->reobj)
return E_INVALIDARG;
else
reobj = cursor.pRun->member.run.reobj;
reobj = cursor.run->reobj;
}
else if (iob == REO_IOB_SELECTION)
{
ME_Cursor *from, *to;
ME_GetSelection(This->editor, &from, &to);
if (!from->pRun->member.run.reobj)
if (!from->run->reobj)
return E_INVALIDARG;
else
reobj = from->pRun->member.run.reobj;
reobj = from->run->reobj;
}
else
{
......@@ -1659,7 +1659,7 @@ static HRESULT WINAPI ITextRange_fnGetText(ITextRange *me, BSTR *str)
if (!*str)
return E_OUTOFMEMORY;
bEOP = (end.pRun->next->type == diTextEnd && This->end > ME_GetTextLength(editor));
bEOP = (!para_next( para_next( end.para )) && This->end > ME_GetTextLength(editor));
ME_GetTextW(editor, *str, length, &start, length, FALSE, bEOP);
return S_OK;
}
......@@ -1714,7 +1714,7 @@ static HRESULT range_GetChar(ME_TextEditor *editor, ME_Cursor *cursor, LONG *pch
{
WCHAR wch[2];
ME_GetTextW(editor, wch, 1, cursor, 1, FALSE, cursor->pRun->next->type == diTextEnd);
ME_GetTextW(editor, wch, 1, cursor, 1, FALSE, !para_next( para_next( cursor->para ) ));
*pch = wch[0];
return S_OK;
......@@ -4745,7 +4745,7 @@ static HRESULT WINAPI ITextSelection_fnGetText(ITextSelection *me, BSTR *pbstr)
if (!*pbstr)
return E_OUTOFMEMORY;
bEOP = (end->pRun->next->type == diTextEnd && endOfs > ME_GetTextLength(This->reOle->editor));
bEOP = (!para_next( para_next( end->para ) ) && endOfs > ME_GetTextLength(This->reOle->editor));
ME_GetTextW(This->reOle->editor, *pbstr, nChars, start, nChars, FALSE, bEOP);
TRACE("%s\n", wine_dbgstr_w(*pbstr));
......
......@@ -57,7 +57,7 @@ ME_Row *row_from_cursor( ME_Cursor *cursor )
{
ME_DisplayItem *item;
item = ME_FindItemBack( cursor->pRun, diStartRow );
item = ME_FindItemBack( run_get_di( cursor->run ), diStartRow );
return &item->member.row;
}
......@@ -66,8 +66,8 @@ void row_first_cursor( ME_Row *row, ME_Cursor *cursor )
ME_DisplayItem *item;
item = ME_FindItemFwd( row_get_di( row ), diRun );
cursor->pRun = item;
cursor->pPara = para_get_di( cursor->pRun->member.run.para );
cursor->run = &item->member.run;
cursor->para = cursor->run->para;
cursor->nOffset = 0;
}
......@@ -77,9 +77,9 @@ void row_end_cursor( ME_Row *row, ME_Cursor *cursor, BOOL include_eop )
item = ME_FindItemFwd( row_get_di( row ), diStartRowOrParagraphOrEnd );
run = ME_FindItemBack( item, diRun );
cursor->pRun = run;
cursor->pPara = para_get_di( cursor->pRun->member.run.para );
cursor->nOffset = (item->type == diStartRow || include_eop) ? cursor->pRun->member.run.len : 0;
cursor->run = &run->member.run;
cursor->para = cursor->run->para;
cursor->nOffset = (item->type == diStartRow || include_eop) ? cursor->run->len : 0;
}
ME_Row *row_from_row_number( ME_TextEditor *editor, int row_num )
......
......@@ -29,15 +29,15 @@ WINE_DECLARE_DEBUG_CHANNEL(richedit_lists);
BOOL cursor_next_run( ME_Cursor *cursor, BOOL all_para )
{
ME_DisplayItem *p = cursor->pRun->next;
ME_DisplayItem *p = run_get_di( cursor->run )->next;
while (p->type != diTextEnd)
{
if (p->type == diParagraph && !all_para) return FALSE;
else if (p->type == diRun)
{
cursor->pRun = p;
cursor->pPara = para_get_di( cursor->pRun->member.run.para );
cursor->run = &p->member.run;
cursor->para = cursor->run->para;
cursor->nOffset = 0;
return TRUE;
}
......@@ -48,15 +48,15 @@ BOOL cursor_next_run( ME_Cursor *cursor, BOOL all_para )
BOOL cursor_prev_run( ME_Cursor *cursor, BOOL all_para )
{
ME_DisplayItem *p = cursor->pRun->prev;
ME_DisplayItem *p = run_get_di( cursor->run )->prev;
while (p->type != diTextStart)
{
if (p->type == diParagraph && !all_para) return FALSE;
else if (p->type == diRun)
{
cursor->pRun = p;
cursor->pPara = para_get_di( cursor->pRun->member.run.para );
cursor->run = &p->member.run;
cursor->para = cursor->run->para;
cursor->nOffset = 0;
return TRUE;
}
......@@ -69,12 +69,12 @@ ME_Run *run_next( ME_Run *run )
{
ME_Cursor cursor;
cursor.pRun = run_get_di( run );
cursor.pPara = para_get_di( run->para );
cursor.run = run;
cursor.para = run->para;
cursor.nOffset = 0;
if (cursor_next_run( &cursor, FALSE ))
return &cursor.pRun->member.run;
return cursor.run;
return NULL;
}
......@@ -83,12 +83,12 @@ ME_Run *run_prev( ME_Run *run )
{
ME_Cursor cursor;
cursor.pRun = run_get_di( run );
cursor.pPara = para_get_di( run->para );
cursor.run = run;
cursor.para = run->para;
cursor.nOffset = 0;
if (cursor_prev_run( &cursor, FALSE ))
return &cursor.pRun->member.run;
return cursor.run;
return NULL;
}
......@@ -97,12 +97,12 @@ ME_Run *run_next_all_paras( ME_Run *run )
{
ME_Cursor cursor;
cursor.pRun = run_get_di( run );
cursor.pPara = para_get_di( run->para );
cursor.run = run;
cursor.para = run->para;
cursor.nOffset = 0;
if (cursor_next_run( &cursor, TRUE ))
return &cursor.pRun->member.run;
return cursor.run;
return NULL;
}
......@@ -111,12 +111,12 @@ ME_Run *run_prev_all_paras( ME_Run *run )
{
ME_Cursor cursor;
cursor.pRun = run_get_di( run );
cursor.pPara = para_get_di( run->para );
cursor.run = run;
cursor.para = run->para;
cursor.nOffset = 0;
if (cursor_prev_run( &cursor, TRUE ))
return &cursor.pRun->member.run;
return cursor.run;
return NULL;
}
......@@ -282,8 +282,8 @@ void cursor_from_char_ofs( ME_TextEditor *editor, int char_ofs, ME_Cursor *curso
char_ofs -= run->nCharOfs;
cursor->pPara = para_get_di( para );
cursor->pRun = run_get_di( run );
cursor->para = para;
cursor->run = run;
cursor->nOffset = char_ofs;
}
......@@ -304,9 +304,9 @@ void run_join( ME_TextEditor *editor, ME_Run *run )
/* Update all cursors so that they don't contain the soon deleted run */
for (i = 0; i < editor->nCursors; i++)
{
if (&editor->pCursors[i].pRun->member.run == next)
if (editor->pCursors[i].run == next)
{
editor->pCursors[i].pRun = run_get_di( run );
editor->pCursors[i].run = run;
editor->pCursors[i].nOffset += run->len;
}
}
......@@ -326,7 +326,7 @@ void run_join( ME_TextEditor *editor, ME_Run *run )
*/
ME_Run *run_split( ME_TextEditor *editor, ME_Cursor *cursor )
{
ME_Run *run = &cursor->pRun->member.run, *new_run;
ME_Run *run = cursor->run, *new_run;
int i;
int nOffset = cursor->nOffset;
......@@ -337,7 +337,7 @@ ME_Run *run_split( ME_TextEditor *editor, ME_Cursor *cursor )
new_run->len = run->len - nOffset;
new_run->para = run->para;
run->len = nOffset;
cursor->pRun = run_get_di( new_run );
cursor->run = new_run;
cursor->nOffset = 0;
ME_InsertBefore( run_get_di( run )->next, run_get_di( new_run ) );
......@@ -346,10 +346,10 @@ ME_Run *run_split( ME_TextEditor *editor, ME_Cursor *cursor )
ME_UpdateRunFlags( editor, new_run );
for (i = 0; i < editor->nCursors; i++)
{
if (editor->pCursors[i].pRun == run_get_di( run ) &&
if (editor->pCursors[i].run == run &&
editor->pCursors[i].nOffset >= nOffset)
{
editor->pCursors[i].pRun = run_get_di( new_run );
editor->pCursors[i].run = new_run;
editor->pCursors[i].nOffset -= nOffset;
}
}
......@@ -397,19 +397,19 @@ ME_Run *run_create( ME_Style *s, int flags )
ME_Run *run_insert( ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style,
const WCHAR *str, int len, int flags )
{
ME_Run *insert_before = &cursor->pRun->member.run, *run, *prev;
ME_Run *insert_before = cursor->run, *run, *prev;
if (cursor->nOffset)
{
if (cursor->nOffset == insert_before->len)
{
insert_before = run_next_all_paras( insert_before );
if (!insert_before) insert_before = &cursor->pRun->member.run; /* Always insert before the final eop run */
if (!insert_before) insert_before = cursor->run; /* Always insert before the final eop run */
}
else
{
run_split( editor, cursor );
insert_before = &cursor->pRun->member.run;
insert_before = cursor->run;
}
}
......@@ -433,10 +433,10 @@ ME_Run *run_insert( ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style,
for (i = 0; i < editor->nCursors; i++)
{
if (editor->pCursors[i].pRun == run_get_di( prev ) &&
if (editor->pCursors[i].run == prev &&
editor->pCursors[i].nOffset == prev->len)
{
editor->pCursors[i].pRun = run_get_di( run );
editor->pCursors[i].run = run;
editor->pCursors[i].nOffset = len;
}
}
......@@ -795,35 +795,35 @@ void ME_SetSelectionCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt)
*/
void ME_SetCharFormat( ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, CHARFORMAT2W *fmt )
{
ME_Run *run, *start_run = &start->pRun->member.run, *end_run = NULL;
ME_Run *run, *start_run = start->run, *end_run = NULL;
if (end && start->pRun == end->pRun && start->nOffset == end->nOffset)
if (end && start->run == end->run && start->nOffset == end->nOffset)
return;
if (start->nOffset == start->pRun->member.run.len)
start_run = run_next_all_paras( &start->pRun->member.run );
if (start->nOffset == start->run->len)
start_run = run_next_all_paras( start->run );
else if (start->nOffset)
{
/* run_split() may or may not update the cursors, depending on whether they
* are selection cursors, but we need to make sure they are valid. */
int split_offset = start->nOffset;
ME_Run *split_run = run_split( editor, start );
start_run = &start->pRun->member.run;
if (end && &end->pRun->member.run == split_run)
start_run = start->run;
if (end && end->run == split_run)
{
end->pRun = start->pRun;
end->run = start->run;
end->nOffset -= split_offset;
}
}
if (end)
{
if (end->nOffset == end->pRun->member.run.len)
end_run = run_next_all_paras( &end->pRun->member.run );
if (end->nOffset == end->run->len)
end_run = run_next_all_paras( end->run );
else
{
if (end->nOffset) run_split( editor, end );
end_run = &end->pRun->member.run;
end_run = end->run;
}
}
......@@ -893,16 +893,16 @@ void ME_GetCharFormat( ME_TextEditor *editor, const ME_Cursor *from,
ME_Run *run, *run_end, *prev_run;
CHARFORMAT2W tmp;
run = &from->pRun->member.run;
run = from->run;
/* special case - if selection is empty, take previous char's formatting */
if (from->pRun == to->pRun && from->nOffset == to->nOffset)
if (from->run == to->run && from->nOffset == to->nOffset)
{
if (!from->nOffset && (prev_run = run_prev( run ))) run = prev_run;
run_copy_char_fmt( run, fmt );
return;
}
run_end = &to->pRun->member.run;
run_end = to->run;
if (!to->nOffset) run_end = run_prev_all_paras( run_end );
run_copy_char_fmt( run, fmt );
......
......@@ -482,14 +482,14 @@ ME_Style *style_get_insert_style( ME_TextEditor *editor, ME_Cursor *cursor )
if (ME_IsSelection( editor ))
{
ME_GetSelection( editor, &from, &to );
style = from->pRun->member.run.style;
style = from->run->style;
}
else if (editor->pBuffer->pCharStyle)
style = editor->pBuffer->pCharStyle;
else if (!cursor->nOffset && (prev = run_prev( &cursor->pRun->member.run )))
else if (!cursor->nOffset && (prev = run_prev( cursor->run )))
style = prev->style;
else
style = cursor->pRun->member.run.style;
style = cursor->run->style;
ME_AddRefStyle( style );
return style;
......
......@@ -64,10 +64,10 @@ static ME_Paragraph* table_insert_end_para( ME_TextEditor *editor, ME_Cursor *cu
if (cursor->nOffset) run_split( editor, cursor );
para = para_split( editor, &cursor->pRun->member.run, style, eol_str, eol_len, para_flags );
para = para_split( editor, cursor->run, style, eol_str, eol_len, para_flags );
ME_ReleaseStyle( style );
cursor->pPara = para_get_di( para );
cursor->pRun = run_get_di( para_first_run( para ) );
cursor->para = para;
cursor->run = para_first_run( para );
return para;
}
......@@ -84,13 +84,13 @@ ME_Paragraph* table_insert_row_start_at_para( ME_TextEditor *editor, ME_Paragrap
ME_Paragraph *prev_para, *end_para, *start_row;
ME_Cursor cursor;
cursor.pPara = para_get_di( para );
cursor.pRun = run_get_di( para_first_run( para ) );
cursor.para = para;
cursor.run = para_first_run( para );
cursor.nOffset = 0;
start_row = table_insert_row_start( editor, &cursor );
end_para = para_next( &editor->pCursors[0].pPara->member.para );
end_para = para_next( editor->pCursors[0].para );
prev_para = para_next( start_row );
para = para_next( prev_para );
......@@ -220,20 +220,20 @@ void table_protect_partial_deletion( ME_TextEditor *editor, ME_Cursor *c, int *n
{
int start_ofs = ME_GetCursorOfs( c );
ME_Cursor c2 = *c;
ME_Paragraph *this_para = &c->pPara->member.para, *end_para;
ME_Paragraph *this_para = c->para, *end_para;
ME_MoveCursorChars( editor, &c2, *num_chars, FALSE );
end_para = &c2.pPara->member.para;
if (c2.pRun->member.run.nFlags & MERF_ENDPARA)
end_para = c2.para;
if (c2.run->nFlags & MERF_ENDPARA)
{
/* End offset might be in the middle of the end paragraph run.
* If this is the case, then we need to use the next paragraph as the last
* paragraphs.
*/
int remaining = start_ofs + *num_chars - c2.pRun->member.run.nCharOfs - end_para->nCharOfs;
int remaining = start_ofs + *num_chars - c2.run->nCharOfs - end_para->nCharOfs;
if (remaining)
{
assert( remaining < c2.pRun->member.run.len );
assert( remaining < c2.run->len );
end_para = para_next( end_para );
}
}
......@@ -293,11 +293,11 @@ void table_protect_partial_deletion( ME_TextEditor *editor, ME_Cursor *c, int *n
if ((this_para->nCharOfs != start_ofs || this_para == end_para) && para_in_table( this_para ))
{
run = &c->pRun->member.run;
run = c->run;
/* Find the next tab or end paragraph to use as a delete boundary */
while (!(run->nFlags & (MERF_TAB | MERF_ENDPARA)))
run = run_next( run );
chars_to_boundary = run->nCharOfs - c->pRun->member.run.nCharOfs - c->nOffset;
chars_to_boundary = run->nCharOfs - c->run->nCharOfs - c->nOffset;
*num_chars = min( *num_chars, chars_to_boundary );
}
else if (para_in_table( end_para ))
......@@ -341,8 +341,8 @@ ME_Paragraph* table_append_row( ME_TextEditor *editor, ME_Paragraph *table_row )
prev_table_end = table_row_end( table_row );
para = para_next( prev_table_end );
run = para_first_run( para );
editor->pCursors[0].pPara = para_get_di( para );
editor->pCursors[0].pRun = run_get_di( run );
editor->pCursors[0].para = para;
editor->pCursors[0].run = run;
editor->pCursors[0].nOffset = 0;
editor->pCursors[1] = editor->pCursors[0];
new_row_start = table_insert_row_start( editor, editor->pCursors );
......@@ -368,12 +368,12 @@ ME_Paragraph* table_append_row( ME_TextEditor *editor, ME_Paragraph *table_row )
{
run = para_end_run( table_row );
assert( para_in_table( table_row ) );
editor->pCursors[0].pPara = para_get_di( table_row );
editor->pCursors[0].pRun = run_get_di( run );
editor->pCursors[0].para = table_row;
editor->pCursors[0].run = run;
editor->pCursors[0].nOffset = 0;
editor->pCursors[1] = editor->pCursors[0];
ME_InsertTextFromCursor( editor, 0, &endl, 1, run->style );
run = &editor->pCursors[0].pRun->member.run;
run = editor->pCursors[0].run;
for (i = 0; i < table_row->fmt.cTabCount; i++)
ME_InsertTextFromCursor( editor, 0, &tab, 1, run->style );
......@@ -410,8 +410,8 @@ static void table_select_next_cell_or_append( ME_TextEditor *editor, ME_Run *run
para = table_append_row( editor, table_row_start( para ) );
/* Put cursor at the start of the new table row */
para = para_next( para );
editor->pCursors[0].pPara = para_get_di( para );
editor->pCursors[0].pRun = run_get_di( para_first_run( para ) );
editor->pCursors[0].para = para;
editor->pCursors[0].run = para_first_run( para );
editor->pCursors[0].nOffset = 0;
editor->pCursors[1] = editor->pCursors[0];
ME_WrapMarkedParagraphs(editor);
......@@ -419,11 +419,11 @@ static void table_select_next_cell_or_append( ME_TextEditor *editor, ME_Run *run
}
}
/* Select cell */
editor->pCursors[1].pPara = para_get_di( cell_first_para( cell ) );
editor->pCursors[1].pRun = run_get_di( para_first_run( &editor->pCursors[1].pPara->member.para ) );
editor->pCursors[1].para = cell_first_para( cell );
editor->pCursors[1].run = para_first_run( editor->pCursors[1].para );
editor->pCursors[1].nOffset = 0;
editor->pCursors[0].pPara = para_get_di( cell_end_para( cell ) );
editor->pCursors[0].pRun = run_get_di( para_end_run( &editor->pCursors[0].pPara->member.para ) );
editor->pCursors[0].para = cell_end_para( cell );
editor->pCursors[0].run = para_end_run( editor->pCursors[0].para );
editor->pCursors[0].nOffset = 0;
}
else /* v1.0 - 3.0 */
......@@ -443,8 +443,8 @@ static void table_select_next_cell_or_append( ME_TextEditor *editor, ME_Run *run
if (para_in_table( para ))
{
run = para_first_run( para );
editor->pCursors[0].pPara = para_get_di( para );
editor->pCursors[0].pRun = run_get_di( run );
editor->pCursors[0].para = para;
editor->pCursors[0].run = run;
editor->pCursors[0].nOffset = 0;
i = 1;
}
......@@ -453,8 +453,8 @@ static void table_select_next_cell_or_append( ME_TextEditor *editor, ME_Run *run
/* Insert table row */
para = table_append_row( editor, para_prev( para ) );
/* Put cursor at the start of the new table row */
editor->pCursors[0].pPara = para_get_di( para );
editor->pCursors[0].pRun = run_get_di( para_first_run( para ) );
editor->pCursors[0].para = para;
editor->pCursors[0].run = para_first_run( para );
editor->pCursors[0].nOffset = 0;
editor->pCursors[1] = editor->pCursors[0];
ME_WrapMarkedParagraphs(editor);
......@@ -464,8 +464,8 @@ static void table_select_next_cell_or_append( ME_TextEditor *editor, ME_Run *run
else run = run_next( run );
}
if (i == 0) run = run_next_all_paras( run );
editor->pCursors[i].pRun = run_get_di( run );
editor->pCursors[i].pPara = para_get_di( run->para );
editor->pCursors[i].run = run;
editor->pCursors[i].para = run->para;
editor->pCursors[i].nOffset = 0;
}
}
......@@ -494,32 +494,32 @@ void table_handle_tab( ME_TextEditor *editor, BOOL selected_row )
}
if (!editor->bEmulateVersion10) /* v4.1 */
{
if (!para_in_table( &toCursor.pPara->member.para ))
if (!para_in_table( toCursor.para ))
{
editor->pCursors[0] = toCursor;
editor->pCursors[1] = toCursor;
}
else table_select_next_cell_or_append( editor, &toCursor.pRun->member.run );
else table_select_next_cell_or_append( editor, toCursor.run );
}
else /* v1.0 - 3.0 */
{
if (!para_in_table( &fromCursor.pPara->member.para) )
if (!para_in_table( fromCursor.para ))
{
editor->pCursors[0] = fromCursor;
editor->pCursors[1] = fromCursor;
/* FIXME: For some reason the caret is shown at the start of the
* previous paragraph in v1.0 to v3.0 */
}
else if ((selected_row || !para_in_table( &toCursor.pPara->member.para )))
table_select_next_cell_or_append( editor, &fromCursor.pRun->member.run );
else if ((selected_row || !para_in_table( toCursor.para )))
table_select_next_cell_or_append( editor, fromCursor.run );
else
{
ME_Run *run = run_prev( &toCursor.pRun->member.run );
ME_Run *run = run_prev( toCursor.run );
if (ME_IsSelection(editor) && !toCursor.nOffset && run && run->nFlags & MERF_TAB)
table_select_next_cell_or_append( editor, run );
else
table_select_next_cell_or_append( editor, &toCursor.pRun->member.run );
table_select_next_cell_or_append( editor, toCursor.run );
}
}
ME_InvalidateSelection(editor);
......@@ -532,15 +532,15 @@ void table_handle_tab( ME_TextEditor *editor, BOOL selected_row )
* without a selection. */
void table_move_from_row_start( ME_TextEditor *editor )
{
ME_Paragraph *para = &editor->pCursors[0].pPara->member.para;
ME_Paragraph *para = editor->pCursors[0].para;
if (para == &editor->pCursors[1].pPara->member.para && para->nFlags & MEPF_ROWSTART)
if (para == editor->pCursors[1].para && para->nFlags & MEPF_ROWSTART)
{
/* The cursors should not be at the hidden start row paragraph without
* a selection, so the cursor is moved into the first cell. */
para = para_next( para );
editor->pCursors[0].pPara = para_get_di( para );
editor->pCursors[0].pRun = run_get_di( para_first_run( para ) );
editor->pCursors[0].para = para;
editor->pCursors[0].run = para_first_run( para );
editor->pCursors[0].nOffset = 0;
editor->pCursors[1] = editor->pCursors[0];
}
......
......@@ -336,10 +336,10 @@ static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo)
{
ME_Cursor tmp;
cursor_from_char_ofs( editor, undo->u.set_para_fmt.pos, &tmp );
add_undo_set_para_fmt( editor, &tmp.pPara->member.para );
tmp.pPara->member.para.fmt = undo->u.set_para_fmt.fmt;
tmp.pPara->member.para.border = undo->u.set_para_fmt.border;
para_mark_rewrap( editor, &tmp.pPara->member.para );
add_undo_set_para_fmt( editor, tmp.para );
tmp.para->fmt = undo->u.set_para_fmt.fmt;
tmp.para->border = undo->u.set_para_fmt.border;
para_mark_rewrap( editor, tmp.para );
break;
}
case undo_set_char_fmt:
......@@ -371,7 +371,7 @@ static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo)
{
ME_Cursor tmp;
cursor_from_char_ofs( editor, undo->u.join_paras.pos, &tmp );
para_join( editor, &tmp.pPara->member.para, TRUE );
para_join( editor, tmp.para, TRUE );
break;
}
case undo_split_para:
......@@ -383,7 +383,7 @@ static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo)
cursor_from_char_ofs( editor, undo->u.split_para.pos, &tmp );
if (tmp.nOffset) run_split( editor, &tmp );
this_para = &tmp.pPara->member.para;
this_para = tmp.para;
bFixRowStart = this_para->nFlags & MEPF_ROWSTART;
if (bFixRowStart)
{
......@@ -391,7 +391,7 @@ static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo)
* is correct. */
this_para->nFlags &= ~MEPF_ROWSTART;
}
new_para = para_split( editor, &tmp.pRun->member.run, tmp.pRun->member.run.style,
new_para = para_split( editor, tmp.run, tmp.run->style,
undo->u.split_para.eol_str->szData, undo->u.split_para.eol_str->nLen, paraFlags );
if (bFixRowStart)
new_para->nFlags |= MEPF_ROWSTART;
......
......@@ -131,7 +131,7 @@ static ME_Run *split_run_extents( ME_WrapContext *wc, ME_Run *run, int nVChar )
{
ME_TextEditor *editor = wc->context->editor;
ME_Run *run2;
ME_Cursor cursor = {para_get_di( wc->para ), run_get_di( run ), nVChar};
ME_Cursor cursor = { wc->para, run, nVChar };
assert( run->nCharOfs != -1 );
ME_CheckCharOffsets(editor);
......@@ -141,7 +141,7 @@ static ME_Run *split_run_extents( ME_WrapContext *wc, ME_Run *run, int nVChar )
run_split( editor, &cursor );
run2 = &cursor.pRun->member.run;
run2 = cursor.run;
run2->script_analysis = run->script_analysis;
shape_run( wc->context, run );
......@@ -157,7 +157,7 @@ static ME_Run *split_run_extents( ME_WrapContext *wc, ME_Run *run, int nVChar )
debugstr_run( run ), run->pt.x, run->pt.y,
debugstr_run( run2 ), run2->pt.x, run2->pt.y);
return &cursor.pRun->member.run;
return cursor.run;
}
/******************************************************************************
......@@ -777,7 +777,7 @@ static HRESULT itemize_para( ME_Context *c, ME_Paragraph *para )
if (run->nCharOfs + run->len > items[cur_item+1].iCharPos)
{
ME_Cursor cursor = {para_get_di( para ), run_get_di( run ), items[cur_item+1].iCharPos - run->nCharOfs};
ME_Cursor cursor = { para, run, items[cur_item + 1].iCharPos - run->nCharOfs };
run_split( c->editor, &cursor );
}
}
......
......@@ -1003,7 +1003,7 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
if (!ME_StreamOutRTFHeader(pStream, dwFormat))
return FALSE;
if (!stream_out_font_and_colour_tbls( pStream, &cursor.pRun->member.run, &endCur.pRun->member.run ))
if (!stream_out_font_and_colour_tbls( pStream, cursor.run, endCur.run ))
return FALSE;
/* TODO: stylesheet table */
......@@ -1021,29 +1021,29 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
do
{
if (&cursor.pPara->member.para != prev_para)
if (cursor.para != prev_para)
{
prev_para = &cursor.pPara->member.para;
if (!stream_out_para_props( editor, pStream, &cursor.pPara->member.para ))
prev_para = cursor.para;
if (!stream_out_para_props( editor, pStream, cursor.para ))
return FALSE;
}
if (cursor.pRun == endCur.pRun && !endCur.nOffset)
if (cursor.run == endCur.run && !endCur.nOffset)
break;
TRACE("flags %xh\n", cursor.pRun->member.run.nFlags);
TRACE("flags %xh\n", cursor.run->nFlags);
/* TODO: emit embedded objects */
if (cursor.pPara->member.para.nFlags & (MEPF_ROWSTART | MEPF_ROWEND))
if (cursor.para->nFlags & (MEPF_ROWSTART | MEPF_ROWEND))
continue;
if (cursor.pRun->member.run.nFlags & MERF_GRAPHICS)
if (cursor.run->nFlags & MERF_GRAPHICS)
{
if (!stream_out_graphics(editor, pStream, &cursor.pRun->member.run))
if (!stream_out_graphics( editor, pStream, cursor.run ))
return FALSE;
}
else if (cursor.pRun->member.run.nFlags & MERF_TAB)
else if (cursor.run->nFlags & MERF_TAB)
{
if (editor->bEmulateVersion10 && /* v1.0 - 3.0 */
para_in_table( &cursor.pPara->member.para ))
para_in_table( cursor.para ))
{
if (!ME_StreamOutPrint(pStream, "\\cell "))
return FALSE;
......@@ -1054,7 +1054,7 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
return FALSE;
}
}
else if (cursor.pRun->member.run.nFlags & MERF_ENDCELL)
else if (cursor.run->nFlags & MERF_ENDCELL)
{
if (pStream->nNestingLevel > 1)
{
......@@ -1068,13 +1068,13 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
}
nChars--;
}
else if (cursor.pRun->member.run.nFlags & MERF_ENDPARA)
else if (cursor.run->nFlags & MERF_ENDPARA)
{
if (!ME_StreamOutRTFCharProps(pStream, &cursor.pRun->member.run.style->fmt))
if (!ME_StreamOutRTFCharProps( pStream, &cursor.run->style->fmt ))
return FALSE;
if (para_in_table( &cursor.pPara->member.para) &&
!(cursor.pPara->member.para.nFlags & (MEPF_ROWSTART | MEPF_ROWEND | MEPF_CELL)))
if (para_in_table( cursor.para ) &&
!(cursor.para->nFlags & (MEPF_ROWSTART | MEPF_ROWEND | MEPF_CELL)))
{
if (!ME_StreamOutPrint(pStream, "\\row\r\n"))
return FALSE;
......@@ -1085,9 +1085,9 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
return FALSE;
}
/* Skip as many characters as required by current line break */
nChars = max(0, nChars - cursor.pRun->member.run.len);
nChars = max(0, nChars - cursor.run->len);
}
else if (cursor.pRun->member.run.nFlags & MERF_ENDROW)
else if (cursor.run->nFlags & MERF_ENDROW)
{
if (!ME_StreamOutPrint(pStream, "\\line\r\n"))
return FALSE;
......@@ -1097,17 +1097,17 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
{
int nEnd;
TRACE("style %p\n", cursor.pRun->member.run.style);
if (!ME_StreamOutRTFCharProps(pStream, &cursor.pRun->member.run.style->fmt))
TRACE("style %p\n", cursor.run->style);
if (!ME_StreamOutRTFCharProps( pStream, &cursor.run->style->fmt ))
return FALSE;
nEnd = (cursor.pRun == endCur.pRun) ? endCur.nOffset : cursor.pRun->member.run.len;
if (!ME_StreamOutRTFText(pStream, get_text( &cursor.pRun->member.run, cursor.nOffset ),
nEnd = (cursor.run == endCur.run) ? endCur.nOffset : cursor.run->len;
if (!ME_StreamOutRTFText(pStream, get_text( cursor.run, cursor.nOffset ),
nEnd - cursor.nOffset))
return FALSE;
cursor.nOffset = 0;
}
} while (cursor.pRun != endCur.pRun && cursor_next_run( &cursor, TRUE ));
} while (cursor.run != endCur.run && cursor_next_run( &cursor, TRUE ));
if (!ME_StreamOutMove(pStream, "}\0", 2))
return FALSE;
......@@ -1125,7 +1125,7 @@ static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream,
int nBufLen = 0;
BOOL success = TRUE;
if (!cursor.pRun)
if (!cursor.run)
return FALSE;
if (dwFormat & SF_USECODEPAGE)
......@@ -1133,10 +1133,11 @@ static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream,
/* TODO: Handle SF_TEXTIZED */
while (success && nChars && cursor.pRun) {
nLen = min(nChars, cursor.pRun->member.run.len - cursor.nOffset);
while (success && nChars && cursor.run)
{
nLen = min(nChars, cursor.run->len - cursor.nOffset);
if (!editor->bEmulateVersion10 && cursor.pRun->member.run.nFlags & MERF_ENDPARA)
if (!editor->bEmulateVersion10 && cursor.run->nFlags & MERF_ENDPARA)
{
static const WCHAR szEOL[] = { '\r', '\n' };
......@@ -1147,18 +1148,18 @@ static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream,
success = ME_StreamOutMove(pStream, "\r\n", 2);
} else {
if (dwFormat & SF_UNICODE)
success = ME_StreamOutMove(pStream, (const char *)(get_text( &cursor.pRun->member.run, cursor.nOffset )),
success = ME_StreamOutMove(pStream, (const char *)(get_text( cursor.run, cursor.nOffset )),
sizeof(WCHAR) * nLen);
else {
int nSize;
nSize = WideCharToMultiByte(nCodePage, 0, get_text( &cursor.pRun->member.run, cursor.nOffset ),
nSize = WideCharToMultiByte(nCodePage, 0, get_text( cursor.run, cursor.nOffset ),
nLen, NULL, 0, NULL, NULL);
if (nSize > nBufLen) {
buffer = heap_realloc(buffer, nSize);
nBufLen = nSize;
}
WideCharToMultiByte(nCodePage, 0, get_text( &cursor.pRun->member.run, cursor.nOffset ),
WideCharToMultiByte(nCodePage, 0, get_text( cursor.run, cursor.nOffset ),
nLen, buffer, nSize, NULL, NULL);
success = ME_StreamOutMove(pStream, buffer, nSize);
}
......@@ -1166,8 +1167,7 @@ static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream,
nChars -= nLen;
cursor.nOffset = 0;
cursor.pRun = run_next_all_paras( &cursor.pRun->member.run ) ?
run_get_di( run_next_all_paras( &cursor.pRun->member.run ) ) : NULL;
cursor.run = run_next_all_paras( cursor.run );
}
heap_free(buffer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment