📄 textserv.cpp
字号:
case WM_MOUSEWHEEL: // Megellan zmouse scroll n lines.
lres = HandleMouseWheel(wparam, lparam);
break;
#endif
case EM_LINEFROMCHAR:
hr = TxLineFromCp((LONG) wparam, &lres);
break;
case EM_LINEINDEX:
hr = TxLineIndex((LONG)wparam, &lres);
break;
case EM_LINELENGTH:
hr = TxLineLength((LONG) wparam, &lres);
break;
case EM_LINESCROLL:
hr = TxLineScroll((LONG) lparam, (LONG) wparam);
lres = TxGetMultiLine();
break;
#ifndef PEGASUS
case WM_MOUSEACTIVATE:
lres = MA_ACTIVATE;
// if the window that currently has focus is part of our "application",
// then don't eat the mouse click. Otherwise, if it's from another
// app, the user is probably trying to swap apps, so eat the mosue
// down message and let our host app get a chance to come to the
// foreground.
if(!( IsChild((HWND) wparam, GetFocus()) || ((HWND)wparam != NULL &&
(HWND)wparam == GetFocus())))
{
_fEatLeftDown = TRUE;
}
break;
#endif
case WM_MOUSEMOVE:
// we reset the "number of tries to put an active object
// in place" count here
_cActiveObjPosTries = MAX_ACTIVE_OBJ_POS_TRIES;
hr = OnTxMouseMove(MOUSEX, MOUSEY, (WORD) wparam, &undobldr);
break;
case EM_OUTLINE:
{
if(wparam == EMO_GETVIEWMODE)
{
hr = GetViewKind(&lres);
break;
}
CTxtSelection * psel = GetSelNC();
if(!TxGetMultiLine() || !IsRich() || !psel) // Control must be rich,
break; // multiline and active
if(wparam == EMO_ENTER || wparam == EMO_EXIT)
{
hr = SetViewKind(wparam == EMO_ENTER ? VM_OUTLINE : VM_NORMAL);
lres = SUCCEEDED(hr);
break;
}
if(!IsInOutlineView() || !IsntProtectedOrReadOnly(msg, wparam, lparam))
break;
CTxtRange rg(*psel);
switch(wparam)
{
case EMO_PROMOTE:
hr = rg.Promote(lparam, &undobldr);
psel->Update_iFormat(-1);
psel->Update(FALSE);
break;
case EMO_EXPAND:
#ifdef PWD_JUPITER // GuyBark 81387: Allow undo of expand/collapse operation
hr = rg.ExpandOutline((short)LOWORD(lparam),
HIWORD(lparam) == EMO_EXPANDDOCUMENT, &undobldr);
#else
hr = rg.ExpandOutline((short)LOWORD(lparam),
HIWORD(lparam) == EMO_EXPANDDOCUMENT);
#endif // PWD_JUPITER
break;
case EMO_MOVESELECTION:
hr = MoveSelection(lparam, &undobldr);
psel->Update(TRUE);
break;
default:
// TraceMessage("Unknown outline function received\r\n");
break;
};
lres = SUCCEEDED(hr);
_fModified = TRUE;
}
break;
case WM_PASTE:
case EM_PASTESPECIAL:
if( IsntProtectedOrReadOnly(msg, wparam, lparam) )
{
CTxtSelection *psel = GetSel();
hr = PasteDataObjectToRange(NULL, psel,
(CLIPFORMAT) wparam, (REPASTESPECIAL *)lparam, &undobldr,
PDOR_NONE);
// to match the Word UI, better go ahead and update the window
TxUpdateWindow();
}
break;
case EM_POSFROMCHAR:
// RichEdit 2.x used wparam instead of lparam for the cp and ignored
// wparam, unlike RE 1.0 and the Win32 documentation (sigh!). We fix
// this, but are compatible with RE 2.x for cp's < 1MB, since no
// 32-bit addresses on Win95 or NT are smaller than that.
if(wparam < 0x10000 || wparam == 0xFFFFFFFF)// Illegal ptr, so assume
{ // incorrect RE 2.0 params
// TODO: enable when msgtest gets updated
//AssertSz(FALSE,
// "EM_POSFROMCHAR: wparam is illegal ptr, assuming cp value");
POINT pt;
hr = TxPosFromChar((LONG)wparam, &pt);
lres = SUCCEEDED(hr) ? MAKELONG(pt.x, pt.y) : -1;
}
else
hr = TxPosFromChar((LONG)lparam, (LPPOINT)wparam);
break;
#ifndef PEGASUS
case WM_RBUTTONDBLCLK:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
// give the client a chance to handle these messages,
// if we are over a link
if( HandleLinkNotification(msg, wparam, lparam) )
{
break;
}
if( msg == WM_RBUTTONUP )
{
hr = OnTxRButtonUp(MOUSEX, MOUSEY, (WORD) wparam);
}
else if( msg == WM_RBUTTONDOWN )
{
hr = OnTxRButtonDown(MOUSEX, MOUSEY, (WORD) wparam);
}
break;
#endif
case EM_INSERTGRAPHIC:
if (wparam == IG_TYPE_DIB)
{
IUndoBuilder * publdr;
CGenUndoBuilder undobldr(this, UB_AUTOCOMMIT);
publdr = &undobldr;
lres = hr = OnInsertDIB(lparam, publdr);
}
break;
case EM_REPLACESEL:
// BUG 511 - check wParam to see if we want to setup undo
if(!IsProtected(msg, wparam, lparam))
lres = OnReplaceSel(lparam ? -1 : 0, (TCHAR *) lparam,
wparam ? &undobldr : NULL);
break;
case EM_REQUESTRESIZE:
hr = _pdp->RequestResize();
break;
case EM_SCROLL:
// TxVScroll returns the number of lines scrolled;
// this info should be returned in lres
lres = TxVScroll((WORD)wparam, 0);
break;
case EM_SCROLLCARET:
OnScrollCaret();
break;
case EM_SELECTIONTYPE:
{
SELCHANGE selchg;
GetSel()->SetSelectionInfo( &selchg );
lres = selchg.seltyp;
}
break;
case WM_SETFOCUS:
hr = OnSetFocus();
break;
case EM_SETFONTSIZE:
{ // TODO: ? Return non-zero if we set a new font size for some text.
CCharFormat CF;
CF.dwMask = CFM_SIZE;
CF.yHeight = 0x80000000 | LOWORD(wparam);
lres = OnSetCharFormat(SCF_SELECTION, &CF, &undobldr);
}
break;
case EM_SETMODIFY:
_fModified = wparam != 0;
#ifdef LATER
if (!_fModified)
ObFreezeFrames();
#endif // LATER
break;
case EM_SETSCROLLPOS:
{
POINT *pPoint = (POINT*)lparam;
_pdp->ScrollView(pPoint->x, pPoint->y, FALSE, TRUE);
lres = 1;
}
break;
case EM_EXSETSEL:
// EM_EXSETSEL duplicates the functionality of the 32-bit EM_SETSEL
// and exists purely for backward compatibility with Win16. We just
// repackage the params and fall thru to EM_SETSEL
wparam = (WPARAM)((CHARRANGE *)lparam)->cpMin;
lparam = (LPARAM)((CHARRANGE *)lparam)->cpMost;
// FALL-THROUGH to EM_SETSEL!!!
case EM_SETSEL:
OnSetSel((LONG)wparam, (LONG)lparam);
break;
// Win95's dialog manager doesn't even
// pretend to be 32 bits despite the best attempts of our marketing dudes.
// WM_USER + 1 is the old Win3.0 EM_SETSEL in which the selection range
// was packed into the lparam.
//
// Sometimes (like tabbing through a dialog), Win95 will send us the 16
// bit EM_SETSEL message, so process it here.
case (WM_USER + 1):
OnSetSel(LOWORD(lparam), HIWORD(lparam));
break;
case EM_SETTARGETDEVICE:
// Keep width sane so that LXtoDX works OK at least for displays
// Note that 0x7fffff = 485 feet! This keeps LXtoDX working provided
// _xPerInch < 257 (it's typically 96 for displays). For more
// generality, we'd need to use 64-bit arithmetic (see LXtoDX).
lparam = min(lparam, 0x7fffff);
lres = _pdp->SetMainTargetDC((HDC) wparam, (LONG) lparam);
break;
case WM_SETTEXT:
hr = TxSetText((LPTSTR) lparam);
if( SUCCEEDED(hr) )
{
lres = 1;
}
break;
case EM_SETWORDBREAKPROC:
_pfnWB = (EDITWORDBREAKPROC) lparam;
break;
case WM_SYSCHAR:
// If this message is generated by the UNDO keystroke, we eat it
if(((DWORD) lparam & SYS_ALTERNATE) && ((WORD) wparam == VK_BACK))
break;
goto def;
case WM_SYSKEYDOWN:
if (OnTxSysKeyDown(wparam, lparam, &undobldr) == S_OK)
{
lres = TRUE;
break;
}
goto def;
case WM_TIMER:
OnTxTimer((UINT)wparam);
goto def;
case EM_UNDO:
case WM_UNDO:
if (_pundo && !_fReadOnly )
{
hr = PopAndExecuteAntiEvent(_pundo, wparam);
if( hr == NOERROR )
{
lres = TRUE;
}
}
break;
case EM_REDO:
if( _predo && !_fReadOnly )
{
hr = PopAndExecuteAntiEvent(_predo, wparam);
if( hr == NOERROR )
{
lres = TRUE;
}
}
break;
case EM_SETUNDOLIMIT:
lres = HandleSetUndoLimit((DWORD)wparam);
break;
case WM_VSCROLL:
// TxVScroll returns the number of lines scrolled;
// WM_VSCROLL doesn't care about that info however.
Assert(lres == 0);
Assert(hr == NOERROR);
TxVScroll(LOWORD(wparam), HIWORD(wparam));
break;
// Old stuff that's no longer supported
case EM_FMTLINES: // Controls returning CRCRLFs for soft
// line breaks in EM_GETTEXT. Could
// implement
case WM_GETFONT: // Can support but have to hang onto a
// default HFONT. CCcs has an _hfont, but
// need to be sure default font is in
// cache at time of return
case EM_SETTABSTOPS: // Can support easily (need to convert
// dialog-box units to twips and handle
// ctabs = 1 special case)
case EM_GETHANDLE: // Not supported by Win95 32-bit MLE either
case EM_SETHANDLE: // Not supported by Win95 32-bit MLE either
#ifdef DEBUG
TRACEINFOSZ("Homey don't play dat");
#endif
break;
case EM_SETCHARFORMAT:
{
// Ensure that all CCharFormat's manipulated internally are
// CCharFormat's and not CHARFORMAT's or CHARFORMAT2's
CCharFormat CF;
CHARFORMAT *pCF = (CHARFORMAT *)lparam;
CF.Set(pCF);
CF.cbSize = pCF->cbSize;
CF.dwMask = pCF->dwMask;
lres = OnSetCharFormat(wparam, &CF, &undobldr);
break;
}
case WM_SETFONT:
lres = OnSetFont((HFONT) wparam);
break;
case EM_SETPARAFORMAT:
{
// Ensure that all CParaFormat's manipulated internally are
// CParaFormat's and not PARAFORMAT's or PARAFORMAT2's
CParaFormat PF;
PARAFORMAT *pPF = (PARAFORMAT *)lparam;
PF.Set(pPF);
PF.cbSize = pPF->cbSize;
PF.dwMask = pPF->dwMask;
lres = OnSetParaFormat(wparam, &PF, &undobldr);
break;
}
case EM_SETZOOM:
if(wparam < 65536 && lparam < 65536)
{
SetZoomNumerator(wparam);
SetZoomDenominator(lparam);
// GuyBark:
// Don't always return TRUE here. Return the success of UpdateView().
#ifdef PWD_JUPITER
lres =
#endif // PWD_JUPITER
_pdp->UpdateView();
#ifndef PWD_JUPITER
lres = 1;
#endif // !PWD_JUPITER
}
break;
case EM_STREAMIN:
case EM_STREAMOUT:
{
IUndoBuilder *publdr = &undobldr;
CTxtRange rg(this, 0, -(LONG)GetTextLength());
CTxtRange * prg = &rg; // Default whole doc
if( wparam & SFF_SELECTION ) // Save to current selection
{
prg = (CTxtRange *)GetSel();
AssertSz(prg,
"EM_STREAMIN/OUT: requested selection doesn't exist");
}
else
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -