- removed trailing spaces from some files
- tab support - indent support
This commit is contained in:
parent
1f7d6ccc2e
commit
13578c8602
|
@ -104,11 +104,11 @@ void ME_MoveCaret(ME_TextEditor *editor)
|
||||||
{
|
{
|
||||||
row = ME_FindItemBack(tmp, diStartRow);
|
row = ME_FindItemBack(tmp, diStartRow);
|
||||||
pSizeRun = run = tmp;
|
pSizeRun = run = tmp;
|
||||||
sz = ME_GetRunSize(&c, &run->member.run, ME_StrLen(run->member.run.strText));
|
sz = ME_GetRunSize(&c, ¶->member.para, &run->member.run, ME_StrLen(run->member.run.strText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pCursor->nOffset && !(run->member.run.nFlags & MERF_SKIPPED)) {
|
if (pCursor->nOffset && !(run->member.run.nFlags & MERF_SKIPPED)) {
|
||||||
sz = ME_GetRunSize(&c, &run->member.run, pCursor->nOffset);
|
sz = ME_GetRunSize(&c, ¶->member.para, &run->member.run, pCursor->nOffset);
|
||||||
}
|
}
|
||||||
CreateCaret(editor->hWnd, NULL, 0, pSizeRun->member.run.nAscent+pSizeRun->member.run.nDescent);
|
CreateCaret(editor->hWnd, NULL, 0, pSizeRun->member.run.nAscent+pSizeRun->member.run.nDescent);
|
||||||
SetCaretPos(run->member.run.pt.x+sz.cx,
|
SetCaretPos(run->member.run.pt.x+sz.cx,
|
||||||
|
@ -311,10 +311,30 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
|
||||||
len = lstrlenW(str);
|
len = lstrlenW(str);
|
||||||
pos = str;
|
pos = str;
|
||||||
/* 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')
|
while(pos-str < len && *pos != '\r' && *pos != '\n' && *pos != '\t')
|
||||||
pos++;
|
pos++;
|
||||||
/* handle EOLs */
|
if (pos-str < len && *pos == '\t') { /* handle tabs */
|
||||||
if (pos-str < len) {
|
ME_DisplayItem *pNewRun = NULL;
|
||||||
|
WCHAR tab = '\t';
|
||||||
|
|
||||||
|
if (pos!=str)
|
||||||
|
ME_InsertTextFromCursor(editor, nCursor, str, pos-str, style);
|
||||||
|
|
||||||
|
p = &editor->pCursors[nCursor];
|
||||||
|
assert(style);
|
||||||
|
assert(p->pRun->type == diRun);
|
||||||
|
pNewRun = ME_MakeRun(style, ME_MakeStringN(&tab, 1), MERF_TAB); /* addrefs style */
|
||||||
|
ME_InsertRun(editor, ME_CharOfsFromRunOfs(editor, p->pRun, p->nOffset), pNewRun);
|
||||||
|
ME_DestroyDisplayItem(pNewRun);
|
||||||
|
ME_ReleaseStyle(style);
|
||||||
|
|
||||||
|
pos++;
|
||||||
|
if(pos-str < len) {
|
||||||
|
ME_InsertTextFromCursor(editor, nCursor, pos, len-(pos-str), style);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pos-str < len) { /* handle EOLs */
|
||||||
ME_DisplayItem *tp, *end_run;
|
ME_DisplayItem *tp, *end_run;
|
||||||
ME_Paragraph *para;
|
ME_Paragraph *para;
|
||||||
ME_Style *tmp_style;
|
ME_Style *tmp_style;
|
||||||
|
|
|
@ -356,6 +356,8 @@ void ME_RTFCharAttrHook(RTF_Info *info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME this function doesn't get any information about context of the RTF tag, which is very bad,
|
||||||
|
the same tags mean different things in different contexts */
|
||||||
void ME_RTFParAttrHook(RTF_Info *info)
|
void ME_RTFParAttrHook(RTF_Info *info)
|
||||||
{
|
{
|
||||||
PARAFORMAT2 fmt;
|
PARAFORMAT2 fmt;
|
||||||
|
@ -365,8 +367,30 @@ void ME_RTFParAttrHook(RTF_Info *info)
|
||||||
switch(info->rtfMinor)
|
switch(info->rtfMinor)
|
||||||
{
|
{
|
||||||
case rtfParDef: /* I'm not 100% sure what does it do, but I guess it restores default paragraph attributes */
|
case rtfParDef: /* I'm not 100% sure what does it do, but I guess it restores default paragraph attributes */
|
||||||
fmt.dwMask = PFM_ALIGNMENT;
|
fmt.dwMask = PFM_ALIGNMENT | PFM_TABSTOPS | PFM_OFFSET | PFM_STARTINDENT;
|
||||||
fmt.wAlignment = PFA_LEFT;
|
fmt.wAlignment = PFA_LEFT;
|
||||||
|
fmt.cTabCount = 0;
|
||||||
|
fmt.dxOffset = fmt.dxStartIndent = 0;
|
||||||
|
break;
|
||||||
|
case rtfFirstIndent:
|
||||||
|
ME_GetSelectionParaFormat(info->editor, &fmt);
|
||||||
|
fmt.dwMask = PFM_STARTINDENT;
|
||||||
|
fmt.dxStartIndent = info->rtfParam + fmt.dxOffset;
|
||||||
|
break;
|
||||||
|
case rtfLeftIndent:
|
||||||
|
{
|
||||||
|
int first, left;
|
||||||
|
ME_GetSelectionParaFormat(info->editor, &fmt);
|
||||||
|
first = fmt.dxStartIndent;
|
||||||
|
left = info->rtfParam;
|
||||||
|
fmt.dwMask = PFM_STARTINDENT|PFM_OFFSET;
|
||||||
|
fmt.dxStartIndent = first + left;
|
||||||
|
fmt.dxOffset = -first;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case rtfRightIndent:
|
||||||
|
fmt.dwMask = PFM_RIGHTINDENT;
|
||||||
|
fmt.dxRightIndent = info->rtfParam;
|
||||||
break;
|
break;
|
||||||
case rtfQuadLeft:
|
case rtfQuadLeft:
|
||||||
case rtfQuadJust:
|
case rtfQuadJust:
|
||||||
|
@ -381,6 +405,16 @@ void ME_RTFParAttrHook(RTF_Info *info)
|
||||||
fmt.dwMask = PFM_ALIGNMENT;
|
fmt.dwMask = PFM_ALIGNMENT;
|
||||||
fmt.wAlignment = PFA_CENTER;
|
fmt.wAlignment = PFA_CENTER;
|
||||||
break;
|
break;
|
||||||
|
case rtfTabPos:
|
||||||
|
ME_GetSelectionParaFormat(info->editor, &fmt);
|
||||||
|
if (!(fmt.dwMask & PFM_TABSTOPS))
|
||||||
|
{
|
||||||
|
fmt.dwMask |= PFM_TABSTOPS;
|
||||||
|
fmt.cTabCount = 0;
|
||||||
|
}
|
||||||
|
if (fmt.cTabCount < MAX_TAB_STOPS)
|
||||||
|
fmt.rgxTabs[fmt.cTabCount++] = info->rtfParam;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (fmt.dwMask) {
|
if (fmt.dwMask) {
|
||||||
RTFFlushOutputBuffer(info);
|
RTFFlushOutputBuffer(info);
|
||||||
|
@ -1160,7 +1194,7 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||||
return 0; /* FIXME really 0 ? */
|
return 0; /* FIXME really 0 ? */
|
||||||
}
|
}
|
||||||
wstr = LOWORD(wParam);
|
wstr = LOWORD(wParam);
|
||||||
if (((unsigned)wstr)>=' ' || wstr=='\r') {
|
if (((unsigned)wstr)>=' ' || wstr=='\r' || wstr=='\t') {
|
||||||
/* FIXME maybe it would make sense to call EM_REPLACESEL instead ? */
|
/* FIXME maybe it would make sense to call EM_REPLACESEL instead ? */
|
||||||
ME_Style *style = ME_GetInsertStyle(editor, 0);
|
ME_Style *style = ME_GetInsertStyle(editor, 0);
|
||||||
ME_SaveTempStyle(editor);
|
ME_SaveTempStyle(editor);
|
||||||
|
|
|
@ -108,7 +108,7 @@ ME_DisplayItem *ME_InsertRun(ME_TextEditor *editor, int nCharOfs, ME_DisplayItem
|
||||||
void ME_CheckCharOffsets(ME_TextEditor *editor);
|
void ME_CheckCharOffsets(ME_TextEditor *editor);
|
||||||
void ME_PropagateCharOffset(ME_DisplayItem *p, int shift);
|
void ME_PropagateCharOffset(ME_DisplayItem *p, int shift);
|
||||||
void ME_GetGraphicsSize(ME_TextEditor *editor, ME_Run *run, SIZE *pSize);
|
void ME_GetGraphicsSize(ME_TextEditor *editor, ME_Run *run, SIZE *pSize);
|
||||||
int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Run *run);
|
int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Paragraph *para, ME_Run *run);
|
||||||
/* this one accounts for 1/2 char tolerance */
|
/* this one accounts for 1/2 char tolerance */
|
||||||
int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run);
|
int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run);
|
||||||
int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset);
|
int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset);
|
||||||
|
@ -120,8 +120,8 @@ ME_DisplayItem *ME_SplitRunSimple(ME_TextEditor *editor, ME_DisplayItem *item, i
|
||||||
int ME_FindSplitPoint(ME_Context *c, POINT *pt, ME_Run *run, int desperate);
|
int ME_FindSplitPoint(ME_Context *c, POINT *pt, ME_Run *run, int desperate);
|
||||||
void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run);
|
void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run);
|
||||||
ME_DisplayItem *ME_SplitFurther(ME_TextEditor *editor, ME_DisplayItem *run);
|
ME_DisplayItem *ME_SplitFurther(ME_TextEditor *editor, ME_DisplayItem *run);
|
||||||
void ME_CalcRunExtent(ME_Context *c, ME_Run *run);
|
void ME_CalcRunExtent(ME_Context *c, ME_Paragraph *para, ME_Run *run);
|
||||||
SIZE ME_GetRunSize(ME_Context *c, ME_Run *run, int nLen);
|
SIZE ME_GetRunSize(ME_Context *c, ME_Paragraph *para, ME_Run *run, int nLen);
|
||||||
void ME_CursorFromCharOfs(ME_TextEditor *editor, int nCharOfs, ME_Cursor *pCursor);
|
void ME_CursorFromCharOfs(ME_TextEditor *editor, int nCharOfs, ME_Cursor *pCursor);
|
||||||
void ME_RunOfsFromCharOfs(ME_TextEditor *editor, int nCharOfs, ME_DisplayItem **ppRun, int *pOfs);
|
void ME_RunOfsFromCharOfs(ME_TextEditor *editor, int nCharOfs, ME_DisplayItem **ppRun, int *pOfs);
|
||||||
int ME_CharOfsFromRunOfs(ME_TextEditor *editor, ME_DisplayItem *pRun, int nOfs);
|
int ME_CharOfsFromRunOfs(ME_TextEditor *editor, ME_DisplayItem *pRun, int nOfs);
|
||||||
|
|
|
@ -86,6 +86,8 @@ typedef enum {
|
||||||
#define MERF_STYLEFLAGS 0x0FFF
|
#define MERF_STYLEFLAGS 0x0FFF
|
||||||
/* run contains non-text content, which has its own rules for wrapping, sizing etc */
|
/* run contains non-text content, which has its own rules for wrapping, sizing etc */
|
||||||
#define MERF_GRAPHICS 1
|
#define MERF_GRAPHICS 1
|
||||||
|
/* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
|
||||||
|
#define MERF_TAB 2
|
||||||
|
|
||||||
/* run is splittable (contains white spaces in the middle or end) */
|
/* run is splittable (contains white spaces in the middle or end) */
|
||||||
#define MERF_SPLITTABLE 0x001000
|
#define MERF_SPLITTABLE 0x001000
|
||||||
|
@ -102,6 +104,11 @@ typedef enum {
|
||||||
/* the "end of paragraph" run, contains 1 character */
|
/* the "end of paragraph" run, contains 1 character */
|
||||||
#define MERF_ENDPARA 0x100000
|
#define MERF_ENDPARA 0x100000
|
||||||
|
|
||||||
|
/* runs with any of these flags set cannot be joined */
|
||||||
|
#define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA)
|
||||||
|
/* runs that don't contain real text */
|
||||||
|
#define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA)
|
||||||
|
|
||||||
/* those flags are kept when the row is split */
|
/* those flags are kept when the row is split */
|
||||||
#define MERF_SPLITMASK (~(0))
|
#define MERF_SPLITMASK (~(0))
|
||||||
|
|
||||||
|
|
|
@ -251,7 +251,7 @@ void ME_DrawRun(ME_Context *c, int x, int y, ME_DisplayItem *rundi, ME_Paragraph
|
||||||
int runofs = run->nCharOfs+para->nCharOfs;
|
int runofs = run->nCharOfs+para->nCharOfs;
|
||||||
|
|
||||||
/* you can always comment it out if you need visible paragraph marks */
|
/* you can always comment it out if you need visible paragraph marks */
|
||||||
if (run->nFlags & MERF_ENDPARA)
|
if (run->nFlags & (MERF_ENDPARA|MERF_TAB))
|
||||||
return;
|
return;
|
||||||
if (run->nFlags & MERF_GRAPHICS) {
|
if (run->nFlags & MERF_GRAPHICS) {
|
||||||
int blfrom, blto;
|
int blfrom, blto;
|
||||||
|
@ -311,19 +311,19 @@ void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) {
|
||||||
visible = RectVisible(c->hDC, &rcPara);
|
visible = RectVisible(c->hDC, &rcPara);
|
||||||
if (visible) {
|
if (visible) {
|
||||||
HBRUSH hbr;
|
HBRUSH hbr;
|
||||||
|
hbr = CreateSolidBrush(ME_GetBackColor(c->editor));
|
||||||
/* left margin */
|
/* left margin */
|
||||||
rc.left = c->rcView.left;
|
rc.left = c->rcView.left;
|
||||||
rc.right = c->rcView.left+nMargWidth;
|
rc.right = c->rcView.left+nMargWidth;
|
||||||
rc.top = y;
|
rc.top = y;
|
||||||
rc.bottom = y+p->member.row.nHeight;
|
rc.bottom = y+p->member.row.nHeight;
|
||||||
FillRect(c->hDC, &rc, c->hbrMargin);
|
FillRect(c->hDC, &rc, hbr/* c->hbrMargin */);
|
||||||
/* right margin */
|
/* right margin */
|
||||||
rc.left = xe;
|
rc.left = xe;
|
||||||
rc.right = c->rcView.right;
|
rc.right = c->rcView.right;
|
||||||
FillRect(c->hDC, &rc, c->hbrMargin);
|
FillRect(c->hDC, &rc, hbr/* c->hbrMargin */);
|
||||||
rc.left = c->rcView.left+para->nLeftMargin;
|
rc.left = c->rcView.left+nMargWidth;
|
||||||
rc.right = xe;
|
rc.right = xe;
|
||||||
hbr = CreateSolidBrush(ME_GetBackColor(c->editor));
|
|
||||||
FillRect(c->hDC, &rc, hbr);
|
FillRect(c->hDC, &rc, hbr);
|
||||||
DeleteObject(hbr);
|
DeleteObject(hbr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ void ME_MakeFirstParagraph(HDC hDC, ME_TextBuffer *text)
|
||||||
|
|
||||||
ZeroMemory(&fmt, sizeof(fmt));
|
ZeroMemory(&fmt, sizeof(fmt));
|
||||||
fmt.cbSize = sizeof(fmt);
|
fmt.cbSize = sizeof(fmt);
|
||||||
fmt.dwMask = PFM_ALIGNMENT | PFM_OFFSET | PFM_STARTINDENT | PFM_RIGHTINDENT;
|
fmt.dwMask = PFM_ALIGNMENT | PFM_OFFSET | PFM_STARTINDENT | PFM_RIGHTINDENT | PFM_TABSTOPS;
|
||||||
|
|
||||||
CopyMemory(para->member.para.pFmt, &fmt, sizeof(PARAFORMAT2));
|
CopyMemory(para->member.para.pFmt, &fmt, sizeof(PARAFORMAT2));
|
||||||
|
|
||||||
|
@ -282,6 +282,18 @@ void ME_SetParaFormat(ME_TextEditor *editor, ME_DisplayItem *para, PARAFORMAT2 *
|
||||||
|
|
||||||
if (pFmt->dwMask & PFM_ALIGNMENT)
|
if (pFmt->dwMask & PFM_ALIGNMENT)
|
||||||
para->member.para.pFmt->wAlignment = pFmt->wAlignment;
|
para->member.para.pFmt->wAlignment = pFmt->wAlignment;
|
||||||
|
if (pFmt->dwMask & PFM_STARTINDENT)
|
||||||
|
para->member.para.pFmt->dxStartIndent = pFmt->dxStartIndent;
|
||||||
|
if (pFmt->dwMask & PFM_OFFSET)
|
||||||
|
para->member.para.pFmt->dxOffset = pFmt->dxOffset;
|
||||||
|
if (pFmt->dwMask & PFM_OFFSETINDENT)
|
||||||
|
para->member.para.pFmt->dxStartIndent += pFmt->dxStartIndent;
|
||||||
|
|
||||||
|
if (pFmt->dwMask & PFM_TABSTOPS)
|
||||||
|
{
|
||||||
|
para->member.para.pFmt->cTabCount = pFmt->cTabCount;
|
||||||
|
memcpy(para->member.para.pFmt->rgxTabs, pFmt->rgxTabs, pFmt->cTabCount*sizeof(int));
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME to be continued (indents, bulleting and such) */
|
/* FIXME to be continued (indents, bulleting and such) */
|
||||||
|
|
||||||
|
@ -345,11 +357,28 @@ void ME_GetSelectionParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt)
|
||||||
ZeroMemory(&tmp, sizeof(tmp));
|
ZeroMemory(&tmp, sizeof(tmp));
|
||||||
tmp.cbSize = sizeof(tmp);
|
tmp.cbSize = sizeof(tmp);
|
||||||
ME_GetParaFormat(editor, para, &tmp);
|
ME_GetParaFormat(editor, para, &tmp);
|
||||||
assert(tmp.dwMask & PFM_ALIGNMENT);
|
|
||||||
|
|
||||||
|
assert(tmp.dwMask & PFM_ALIGNMENT);
|
||||||
if (pFmt->wAlignment != tmp.wAlignment)
|
if (pFmt->wAlignment != tmp.wAlignment)
|
||||||
pFmt->dwMask &= ~PFM_ALIGNMENT;
|
pFmt->dwMask &= ~PFM_ALIGNMENT;
|
||||||
|
|
||||||
|
assert(tmp.dwMask & PFM_STARTINDENT);
|
||||||
|
if (pFmt->dxStartIndent != tmp.dxStartIndent)
|
||||||
|
pFmt->dwMask &= ~PFM_STARTINDENT;
|
||||||
|
|
||||||
|
assert(tmp.dwMask & PFM_OFFSET);
|
||||||
|
if (pFmt->dxOffset != tmp.dxOffset)
|
||||||
|
pFmt->dwMask &= ~PFM_OFFSET;
|
||||||
|
|
||||||
|
assert(tmp.dwMask & PFM_TABSTOPS);
|
||||||
|
if (pFmt->dwMask & PFM_TABSTOPS) {
|
||||||
|
if (pFmt->cTabCount != tmp.cTabCount)
|
||||||
|
pFmt->dwMask &= ~PFM_TABSTOPS;
|
||||||
|
else
|
||||||
|
if (memcmp(pFmt->rgxTabs, tmp.rgxTabs, tmp.cTabCount*sizeof(int)))
|
||||||
|
pFmt->dwMask &= ~PFM_TABSTOPS;
|
||||||
|
}
|
||||||
|
|
||||||
if (para == para_end)
|
if (para == para_end)
|
||||||
return;
|
return;
|
||||||
para = para->member.para.next_para;
|
para = para->member.para.next_para;
|
||||||
|
|
|
@ -26,7 +26,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(richedit);
|
||||||
|
|
||||||
int ME_CanJoinRuns(ME_Run *run1, ME_Run *run2)
|
int ME_CanJoinRuns(ME_Run *run1, ME_Run *run2)
|
||||||
{
|
{
|
||||||
if ((run1->nFlags | run2->nFlags) & (MERF_ENDPARA | MERF_GRAPHICS))
|
if ((run1->nFlags | run2->nFlags) & MERF_NOJOIN)
|
||||||
return 0;
|
return 0;
|
||||||
if (run1->style != run2->style)
|
if (run1->style != run2->style)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -200,6 +200,7 @@ ME_DisplayItem *ME_SplitRun(ME_Context *c, ME_DisplayItem *item, int nVChar)
|
||||||
ME_TextEditor *editor = c->editor;
|
ME_TextEditor *editor = c->editor;
|
||||||
ME_DisplayItem *item2 = NULL;
|
ME_DisplayItem *item2 = NULL;
|
||||||
ME_Run *run, *run2;
|
ME_Run *run, *run2;
|
||||||
|
ME_Paragraph *para = &ME_GetParagraph(item)->member.para;
|
||||||
|
|
||||||
assert(item->member.run.nCharOfs != -1);
|
assert(item->member.run.nCharOfs != -1);
|
||||||
if(TRACE_ON(richedit))
|
if(TRACE_ON(richedit))
|
||||||
|
@ -218,8 +219,8 @@ ME_DisplayItem *ME_SplitRun(ME_Context *c, ME_DisplayItem *item, int nVChar)
|
||||||
|
|
||||||
run2 = &item2->member.run;
|
run2 = &item2->member.run;
|
||||||
|
|
||||||
ME_CalcRunExtent(c, run);
|
ME_CalcRunExtent(c, para, run);
|
||||||
ME_CalcRunExtent(c, run2);
|
ME_CalcRunExtent(c, para, run2);
|
||||||
|
|
||||||
run2->pt.x = run->pt.x+run->nWidth;
|
run2->pt.x = run->pt.x+run->nWidth;
|
||||||
run2->pt.y = run->pt.y;
|
run2->pt.y = run->pt.y;
|
||||||
|
@ -246,7 +247,7 @@ ME_DisplayItem *ME_SplitRunSimple(ME_TextEditor *editor, ME_DisplayItem *item, i
|
||||||
int i;
|
int i;
|
||||||
assert(nVChar > 0 && nVChar < ME_StrVLen(run->strText));
|
assert(nVChar > 0 && nVChar < ME_StrVLen(run->strText));
|
||||||
assert(item->type == diRun);
|
assert(item->type == diRun);
|
||||||
assert(!(item->member.run.nFlags & MERF_GRAPHICS));
|
assert(!(item->member.run.nFlags & (MERF_GRAPHICS | MERF_TAB)));
|
||||||
assert(item->member.run.nCharOfs != -1);
|
assert(item->member.run.nCharOfs != -1);
|
||||||
|
|
||||||
item2 = ME_MakeRun(run->style,
|
item2 = ME_MakeRun(run->style,
|
||||||
|
@ -272,18 +273,6 @@ ME_DisplayItem *ME_SplitRunSimple(ME_TextEditor *editor, ME_DisplayItem *item, i
|
||||||
return item2;
|
return item2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* split the start and final whitespace into separate runs */
|
|
||||||
/* returns the last run added */
|
|
||||||
/*
|
|
||||||
ME_DisplayItem *ME_SplitFurther(ME_TextEditor *editor, ME_DisplayItem *item)
|
|
||||||
{
|
|
||||||
int i, nVLen, nChanged;
|
|
||||||
assert(item->type == diRun);
|
|
||||||
assert(!(item->member.run.nFlags & MERF_GRAPHICS));
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
ME_DisplayItem *ME_MakeRun(ME_Style *s, ME_String *strData, int nFlags)
|
ME_DisplayItem *ME_MakeRun(ME_Style *s, ME_String *strData, int nFlags)
|
||||||
{
|
{
|
||||||
ME_DisplayItem *item = ME_MakeDI(diRun);
|
ME_DisplayItem *item = ME_MakeDI(diRun);
|
||||||
|
@ -331,7 +320,7 @@ void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run)
|
||||||
else
|
else
|
||||||
run->nFlags &= ~MERF_SPLITTABLE;
|
run->nFlags &= ~MERF_SPLITTABLE;
|
||||||
|
|
||||||
if (!(run->nFlags & MERF_GRAPHICS)) {
|
if (!(run->nFlags & MERF_NOTEXT)) {
|
||||||
if (ME_IsWhitespaces(run->strText))
|
if (ME_IsWhitespaces(run->strText))
|
||||||
run->nFlags |= MERF_WHITESPACE | MERF_STARTWHITE | MERF_ENDWHITE;
|
run->nFlags |= MERF_WHITESPACE | MERF_STARTWHITE | MERF_ENDWHITE;
|
||||||
else
|
else
|
||||||
|
@ -360,7 +349,7 @@ void ME_GetGraphicsSize(ME_TextEditor *editor, ME_Run *run, SIZE *pSize)
|
||||||
pSize->cy = 64;
|
pSize->cy = 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Run *run)
|
int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Paragraph *para, ME_Run *run)
|
||||||
{
|
{
|
||||||
int fit = 0;
|
int fit = 0;
|
||||||
HGDIOBJ hOldFont;
|
HGDIOBJ hOldFont;
|
||||||
|
@ -369,6 +358,12 @@ int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Run *run)
|
||||||
if (!run->strText->nLen)
|
if (!run->strText->nLen)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (run->nFlags & MERF_TAB)
|
||||||
|
{
|
||||||
|
if (cx < run->nWidth/2)
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
if (run->nFlags & MERF_GRAPHICS)
|
if (run->nFlags & MERF_GRAPHICS)
|
||||||
{
|
{
|
||||||
SIZE sz;
|
SIZE sz;
|
||||||
|
@ -395,6 +390,12 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
|
||||||
if (!run->strText->nLen)
|
if (!run->strText->nLen)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (run->nFlags & MERF_TAB)
|
||||||
|
{
|
||||||
|
if (cx < run->nWidth/2)
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
if (run->nFlags & MERF_GRAPHICS)
|
if (run->nFlags & MERF_GRAPHICS)
|
||||||
{
|
{
|
||||||
SIZE sz;
|
SIZE sz;
|
||||||
|
@ -452,7 +453,7 @@ void ME_GetTextExtent(ME_Context *c, LPCWSTR szText, int nChars, ME_Style *s,
|
||||||
ME_UnselectStyleFont(c->editor, hDC, s, hOldFont);
|
ME_UnselectStyleFont(c->editor, hDC, s, hOldFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
SIZE ME_GetRunSize(ME_Context *c, ME_Run *run, int nLen)
|
SIZE ME_GetRunSizeCommon(ME_Context *c, ME_Paragraph *para, ME_Run *run, int nLen, int *pAscent, int *pDescent)
|
||||||
{
|
{
|
||||||
SIZE size;
|
SIZE size;
|
||||||
int nMaxLen = ME_StrVLen(run->strText);
|
int nMaxLen = ME_StrVLen(run->strText);
|
||||||
|
@ -460,33 +461,65 @@ SIZE ME_GetRunSize(ME_Context *c, ME_Run *run, int nLen)
|
||||||
if (nLen>nMaxLen)
|
if (nLen>nMaxLen)
|
||||||
nLen = nMaxLen;
|
nLen = nMaxLen;
|
||||||
|
|
||||||
|
/* FIXME the following call also ensures that TEXTMETRIC structure is filled
|
||||||
|
* this is wasteful for graphics and TAB runs, but that shouldn't matter
|
||||||
|
* in practice
|
||||||
|
*/
|
||||||
|
ME_GetTextExtent(c, run->strText->szData, nLen, run->style, &size);
|
||||||
|
assert(run->style->tm.tmAscent>0);
|
||||||
|
assert(run->style->tm.tmDescent>0);
|
||||||
|
*pAscent = run->style->tm.tmAscent;
|
||||||
|
*pDescent = run->style->tm.tmDescent;
|
||||||
|
size.cy = *pAscent + *pDescent;
|
||||||
|
|
||||||
|
if (run->nFlags & MERF_TAB)
|
||||||
|
{
|
||||||
|
int pos = 0, i = 0, ppos;
|
||||||
|
int lpsx = GetDeviceCaps(c->hDC, LOGPIXELSX);
|
||||||
|
PARAFORMAT2 *pFmt = para->pFmt;
|
||||||
|
do {
|
||||||
|
if (i < pFmt->cTabCount)
|
||||||
|
{
|
||||||
|
pos = pFmt->rgxTabs[i]&0x00FFFFFF;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pos += 720-(pos%720);
|
||||||
|
}
|
||||||
|
ppos = pos*lpsx/1440;
|
||||||
|
if (ppos>run->pt.x) {
|
||||||
|
size.cx = ppos - run->pt.x;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while(1);
|
||||||
|
size.cy = *pAscent + *pDescent;
|
||||||
|
return size;
|
||||||
|
}
|
||||||
if (run->nFlags & MERF_GRAPHICS)
|
if (run->nFlags & MERF_GRAPHICS)
|
||||||
{
|
{
|
||||||
ME_GetGraphicsSize(c->editor, run, &size);
|
ME_GetGraphicsSize(c->editor, run, &size);
|
||||||
|
if (size.cy > *pAscent)
|
||||||
|
*pAscent = size.cy;
|
||||||
|
/* descent is unchanged */
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
ME_GetTextExtent(c, run->strText->szData, nLen, run->style, &size);
|
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ME_CalcRunExtent(ME_Context *c, ME_Run *run)
|
SIZE ME_GetRunSize(ME_Context *c, ME_Paragraph *para, ME_Run *run, int nLen)
|
||||||
{
|
{
|
||||||
SIZE size;
|
int asc, desc;
|
||||||
int nEnd = ME_StrVLen(run->strText);
|
return ME_GetRunSizeCommon(c, para, run, nLen, &asc, &desc);
|
||||||
|
}
|
||||||
|
|
||||||
if (run->nFlags & MERF_GRAPHICS) {
|
void ME_CalcRunExtent(ME_Context *c, ME_Paragraph *para, ME_Run *run)
|
||||||
ME_GetGraphicsSize(c->editor, run, &size);
|
{
|
||||||
run->nWidth = size.cx;
|
int nEnd = ME_StrVLen(run->strText);
|
||||||
run->nAscent = size.cy;
|
SIZE size = ME_GetRunSizeCommon(c, para, run, nEnd, &run->nAscent, &run->nDescent);
|
||||||
run->nDescent = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ME_GetTextExtent(c, run->strText->szData, nEnd, run->style, &size);
|
|
||||||
run->nWidth = size.cx;
|
run->nWidth = size.cx;
|
||||||
run->nAscent = run->style->tm.tmAscent;
|
assert(size.cx);
|
||||||
run->nDescent = run->style->tm.tmDescent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ME_MustBeWrapped(ME_Context *c, ME_DisplayItem *para)
|
void ME_MustBeWrapped(ME_Context *c, ME_DisplayItem *para)
|
||||||
|
|
|
@ -124,6 +124,7 @@ ME_Style *ME_MakeStyle(CHARFORMAT2W *style) {
|
||||||
s->nSequence = -2;
|
s->nSequence = -2;
|
||||||
s->nRefs = 1;
|
s->nRefs = 1;
|
||||||
s->hFont = NULL;
|
s->hFont = NULL;
|
||||||
|
s->tm.tmAscent = -1;
|
||||||
all_refs++;
|
all_refs++;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ void ME_WrapSizeRun(ME_WrapContext *wc, ME_DisplayItem *p)
|
||||||
|
|
||||||
ME_UpdateRunFlags(wc->context->editor, &p->member.run);
|
ME_UpdateRunFlags(wc->context->editor, &p->member.run);
|
||||||
|
|
||||||
ME_CalcRunExtent(wc->context, &p->member.run);
|
ME_CalcRunExtent(wc->context, &ME_GetParagraph(p)->member.para, &p->member.run);
|
||||||
}
|
}
|
||||||
|
|
||||||
ME_DisplayItem *ME_MaximizeSplit(ME_WrapContext *wc, ME_DisplayItem *p, int i)
|
ME_DisplayItem *ME_MaximizeSplit(ME_WrapContext *wc, ME_DisplayItem *p, int i)
|
||||||
|
@ -168,7 +168,7 @@ ME_DisplayItem *ME_SplitByBacktracking(ME_WrapContext *wc, ME_DisplayItem *p, in
|
||||||
int i, idesp, len;
|
int i, idesp, len;
|
||||||
ME_Run *run = &p->member.run;
|
ME_Run *run = &p->member.run;
|
||||||
|
|
||||||
idesp = i = ME_CharFromPoint(wc->context->editor, loc, run);
|
idesp = i = ME_CharFromPoint(wc->context->editor, loc, &ME_GetParagraph(p)->member.para, run);
|
||||||
len = ME_StrVLen(run->strText);
|
len = ME_StrVLen(run->strText);
|
||||||
assert(len>0);
|
assert(len>0);
|
||||||
assert(i<len);
|
assert(i<len);
|
||||||
|
@ -182,7 +182,7 @@ ME_DisplayItem *ME_SplitByBacktracking(ME_WrapContext *wc, ME_DisplayItem *p, in
|
||||||
TRACE("Must backtrack to split at: %s\n", debugstr_w(p->member.run.strText->szData));
|
TRACE("Must backtrack to split at: %s\n", debugstr_w(p->member.run.strText->szData));
|
||||||
if (wc->pLastSplittableRun)
|
if (wc->pLastSplittableRun)
|
||||||
{
|
{
|
||||||
if (wc->pLastSplittableRun->member.run.nFlags & MERF_GRAPHICS)
|
if (wc->pLastSplittableRun->member.run.nFlags & (MERF_GRAPHICS|MERF_TAB))
|
||||||
{
|
{
|
||||||
wc->pt = wc->ptLastSplittableRun;
|
wc->pt = wc->ptLastSplittableRun;
|
||||||
return wc->pLastSplittableRun;
|
return wc->pLastSplittableRun;
|
||||||
|
@ -251,15 +251,15 @@ ME_DisplayItem *ME_WrapHandleRun(ME_WrapContext *wc, ME_DisplayItem *p)
|
||||||
assert(p->type == diRun);
|
assert(p->type == diRun);
|
||||||
if (!wc->pRowStart)
|
if (!wc->pRowStart)
|
||||||
wc->pRowStart = p;
|
wc->pRowStart = p;
|
||||||
ME_WrapSizeRun(wc, p);
|
|
||||||
run = &p->member.run;
|
run = &p->member.run;
|
||||||
run->pt.x = wc->pt.x;
|
run->pt.x = wc->pt.x;
|
||||||
run->pt.y = wc->pt.y;
|
run->pt.y = wc->pt.y;
|
||||||
|
ME_WrapSizeRun(wc, p);
|
||||||
len = ME_StrVLen(run->strText);
|
len = ME_StrVLen(run->strText);
|
||||||
|
|
||||||
if (wc->bOverflown) /* just skipping final whitespaces */
|
if (wc->bOverflown) /* just skipping final whitespaces */
|
||||||
{
|
{
|
||||||
if (run->nFlags & MERF_WHITESPACE) {
|
if (run->nFlags & (MERF_WHITESPACE|MERF_TAB)) {
|
||||||
p->member.run.nFlags |= MERF_SKIPPED;
|
p->member.run.nFlags |= MERF_SKIPPED;
|
||||||
/* wc->pt.x += run->nWidth; */
|
/* wc->pt.x += run->nWidth; */
|
||||||
/* skip runs consisting of only whitespaces */
|
/* skip runs consisting of only whitespaces */
|
||||||
|
@ -293,8 +293,8 @@ ME_DisplayItem *ME_WrapHandleRun(ME_WrapContext *wc, ME_DisplayItem *p)
|
||||||
wc->bOverflown = TRUE;
|
wc->bOverflown = TRUE;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
/* graphics - we can split before */
|
/* graphics or TAB - we can split before */
|
||||||
if (run->nFlags & MERF_GRAPHICS) {
|
if (run->nFlags & (MERF_GRAPHICS|MERF_TAB)) {
|
||||||
wc->bOverflown = TRUE;
|
wc->bOverflown = TRUE;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ ME_DisplayItem *ME_WrapHandleRun(ME_WrapContext *wc, ME_DisplayItem *p)
|
||||||
/* not found anything - writing over margins is the only option left */
|
/* not found anything - writing over margins is the only option left */
|
||||||
}
|
}
|
||||||
if ((run->nFlags & (MERF_SPLITTABLE | MERF_STARTWHITE))
|
if ((run->nFlags & (MERF_SPLITTABLE | MERF_STARTWHITE))
|
||||||
|| ((run->nFlags & MERF_GRAPHICS) && (p != wc->pRowStart)))
|
|| ((run->nFlags & (MERF_GRAPHICS|MERF_TAB)) && (p != wc->pRowStart)))
|
||||||
{
|
{
|
||||||
wc->pLastSplittableRun = p;
|
wc->pLastSplittableRun = p;
|
||||||
wc->ptLastSplittableRun = wc->pt;
|
wc->ptLastSplittableRun = wc->pt;
|
||||||
|
@ -339,6 +339,7 @@ ME_DisplayItem *ME_WrapHandleRun(ME_WrapContext *wc, ME_DisplayItem *p)
|
||||||
void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp) {
|
void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp) {
|
||||||
ME_DisplayItem *p;
|
ME_DisplayItem *p;
|
||||||
ME_WrapContext wc;
|
ME_WrapContext wc;
|
||||||
|
int dpi = GetDeviceCaps(c->hDC, LOGPIXELSX);
|
||||||
|
|
||||||
assert(tp->type == diParagraph);
|
assert(tp->type == diParagraph);
|
||||||
if (!(tp->member.para.nFlags & MEPF_REWRAP)) {
|
if (!(tp->member.para.nFlags & MEPF_REWRAP)) {
|
||||||
|
@ -349,6 +350,9 @@ void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp) {
|
||||||
wc.context = c;
|
wc.context = c;
|
||||||
/* wc.para_style = tp->member.para.style; */
|
/* wc.para_style = tp->member.para.style; */
|
||||||
wc.style = NULL;
|
wc.style = NULL;
|
||||||
|
tp->member.para.nRightMargin = tp->member.para.pFmt->dxRightIndent*dpi/1440;
|
||||||
|
tp->member.para.nFirstMargin = tp->member.para.pFmt->dxStartIndent*dpi/1440;
|
||||||
|
tp->member.para.nLeftMargin = (tp->member.para.pFmt->dxStartIndent+tp->member.para.pFmt->dxOffset)*dpi/1440;
|
||||||
wc.nFirstMargin = tp->member.para.nFirstMargin;
|
wc.nFirstMargin = tp->member.para.nFirstMargin;
|
||||||
wc.nLeftMargin = tp->member.para.nLeftMargin;
|
wc.nLeftMargin = tp->member.para.nLeftMargin;
|
||||||
wc.nRightMargin = tp->member.para.nRightMargin;
|
wc.nRightMargin = tp->member.para.nRightMargin;
|
||||||
|
|
Loading…
Reference in New Issue