riched20: Remove InternalInsertTextFromCursor().

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2020-10-15 10:39:40 +01:00 committed by Alexandre Julliard
parent 120ee0de1b
commit fe0a7a78db
1 changed files with 49 additions and 61 deletions

View File

@ -460,20 +460,6 @@ BOOL ME_DeleteTextAtCursor(ME_TextEditor *editor, int nCursor, int nChars)
nChars, FALSE); nChars, FALSE);
} }
static ME_DisplayItem *
ME_InternalInsertTextFromCursor(ME_TextEditor *editor, int nCursor,
const WCHAR *str, int len, ME_Style *style,
int flags)
{
ME_Cursor *p = &editor->pCursors[nCursor];
editor->bCaretAtEnd = FALSE;
assert(p->pRun->type == diRun);
return run_get_di( run_insert( editor, p, style, str, len, flags ) );
}
static struct re_object* create_re_object(const REOBJECT *reo) static struct re_object* create_re_object(const REOBJECT *reo)
{ {
struct re_object *reobj = heap_alloc(sizeof(*reobj)); struct re_object *reobj = heap_alloc(sizeof(*reobj));
@ -489,96 +475,98 @@ static struct re_object* create_re_object(const REOBJECT *reo)
void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCursor) void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCursor)
{ {
ME_Style *pStyle = ME_GetInsertStyle(editor, nCursor); ME_Style *style = ME_GetInsertStyle( editor, nCursor );
ME_DisplayItem *di; ME_Run *run, *prev;
WCHAR space = ' '; const WCHAR space = ' ';
ME_DisplayItem *di_prev = NULL; struct re_object *reobj_prev = NULL;
struct re_object *reobj_prev = NULL; ME_Cursor *cursor = editor->pCursors + nCursor;
/* FIXME no no no */ /* FIXME no no no */
if (ME_IsSelection(editor)) if (ME_IsSelection(editor))
ME_DeleteSelection(editor); ME_DeleteSelection(editor);
di = ME_InternalInsertTextFromCursor(editor, nCursor, &space, 1, pStyle, run = run_insert( editor, cursor, style, &space, 1, MERF_GRAPHICS );
MERF_GRAPHICS); editor->bCaretAtEnd = FALSE;
di->member.run.reobj = create_re_object(reo);
di_prev = di; run->reobj = create_re_object( reo );
while (ME_PrevRun(NULL, &di_prev, TRUE))
prev = run;
while ((prev = run_prev_all_paras( prev )))
{ {
if (di_prev->member.run.reobj) if (prev->reobj)
{ {
reobj_prev = di_prev->member.run.reobj; reobj_prev = prev->reobj;
break; break;
} }
} }
if (reobj_prev) if (reobj_prev)
list_add_after(&reobj_prev->entry, &di->member.run.reobj->entry); list_add_after(&reobj_prev->entry, &run->reobj->entry);
else else
list_add_head(&editor->reobj_list, &di->member.run.reobj->entry); list_add_head(&editor->reobj_list, &run->reobj->entry);
ME_ReleaseStyle(pStyle); ME_ReleaseStyle( style );
} }
void ME_InsertEndRowFromCursor(ME_TextEditor *editor, int nCursor) void ME_InsertEndRowFromCursor(ME_TextEditor *editor, int nCursor)
{ {
ME_Style *pStyle = ME_GetInsertStyle(editor, nCursor); ME_Style *style = ME_GetInsertStyle( editor, nCursor );
WCHAR space = ' '; const WCHAR space = ' ';
ME_Cursor *cursor = editor->pCursors + nCursor;
/* FIXME no no no */ /* FIXME no no no */
if (ME_IsSelection(editor)) if (ME_IsSelection(editor))
ME_DeleteSelection(editor); ME_DeleteSelection(editor);
ME_InternalInsertTextFromCursor(editor, nCursor, &space, 1, pStyle, run_insert( editor, cursor, style, &space, 1, MERF_ENDROW );
MERF_ENDROW); editor->bCaretAtEnd = FALSE;
ME_ReleaseStyle(pStyle);
ME_ReleaseStyle( style );
} }
void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor, void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
const WCHAR *str, int len, ME_Style *style) const WCHAR *str, int len, ME_Style *style)
{ {
const WCHAR *pos; const WCHAR *pos;
ME_Cursor *p = NULL; ME_Cursor *cursor = editor->pCursors + nCursor;
int oldLen; int oldLen;
/* FIXME really HERE ? */ /* FIXME really HERE ? */
if (ME_IsSelection(editor)) if (ME_IsSelection(editor))
ME_DeleteSelection(editor); ME_DeleteSelection(editor);
/* FIXME: is this too slow? */
/* Didn't affect performance for WM_SETTEXT (around 50sec/30K) */
oldLen = ME_GetTextLength(editor); oldLen = ME_GetTextLength(editor);
/* text operations set modified state */ /* text operations set modified state */
editor->nModifyStep = 1; editor->nModifyStep = 1;
editor->bCaretAtEnd = FALSE;
assert(style); assert(style);
assert(nCursor>=0 && nCursor<editor->nCursors); if (len == -1) len = lstrlenW( str );
if (len == -1)
len = lstrlenW(str);
/* grow the text limit to fit our text */ /* grow the text limit to fit our text */
if(editor->nTextLimit < oldLen +len) if (editor->nTextLimit < oldLen + len) editor->nTextLimit = oldLen + len;
editor->nTextLimit = oldLen + len;
pos = str; pos = str;
while (len) while (len)
{ {
/* FIXME this sucks - no respect for unicode (what else can be a line separator in unicode?) */ /* FIXME this sucks - no respect for unicode (what else can be a line separator in unicode?) */
while(pos - str < len && *pos != '\r' && *pos != '\n' && *pos != '\t') while (pos - str < len && *pos != '\r' && *pos != '\n' && *pos != '\t')
pos++; pos++;
if (pos != str) { /* handle text */ if (pos != str) /* handle text */
ME_InternalInsertTextFromCursor(editor, nCursor, str, pos-str, style, 0); run_insert( editor, cursor, style, str, pos - str, 0 );
} else if (*pos == '\t') { /* handle tabs */ else if (*pos == '\t') /* handle tabs */
WCHAR tab = '\t'; {
ME_InternalInsertTextFromCursor(editor, nCursor, &tab, 1, style, MERF_TAB); const WCHAR tab = '\t';
run_insert( editor, cursor, style, &tab, 1, MERF_TAB );
pos++; pos++;
} else { /* handle EOLs */ }
else /* handle EOLs */
{
ME_Run *end_run, *run, *prev; ME_Run *end_run, *run, *prev;
ME_Paragraph *new_para; ME_Paragraph *new_para;
int eol_len = 0; int eol_len = 0;
@ -596,7 +584,9 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
eol_len = 3; eol_len = 3;
else else
eol_len = 1; eol_len = 1;
} else { }
else
{
assert(*pos == '\n'); assert(*pos == '\n');
eol_len = 1; eol_len = 1;
} }
@ -605,8 +595,8 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
if (!editor->bEmulateVersion10 && eol_len == 3) if (!editor->bEmulateVersion10 && eol_len == 3)
{ {
/* handle special \r\r\n sequence (richedit 2.x and higher only) */ /* handle special \r\r\n sequence (richedit 2.x and higher only) */
WCHAR space = ' '; const WCHAR space = ' ';
ME_InternalInsertTextFromCursor(editor, nCursor, &space, 1, style, 0); run_insert( editor, cursor, style, &space, 1, 0 );
} }
else else
{ {
@ -618,17 +608,15 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
eol_len = 1; eol_len = 1;
} }
p = &editor->pCursors[nCursor]; if (cursor->nOffset == cursor->pRun->member.run.len)
if (p->nOffset == p->pRun->member.run.len)
{ {
run = run_next( &p->pRun->member.run ); run = run_next( &cursor->pRun->member.run );
if (!run) run = &p->pRun->member.run; if (!run) run = &cursor->pRun->member.run;
} }
else else
{ {
if (p->nOffset) run_split( editor, p ); if (cursor->nOffset) run_split( editor, cursor );
run = &p->pRun->member.run; run = &cursor->pRun->member.run;
} }
new_para = &ME_SplitParagraph( editor, run_get_di( run ), style, eol_str, eol_len, 0 )->member.para; new_para = &ME_SplitParagraph( editor, run_get_di( run ), style, eol_str, eol_len, 0 )->member.para;