📄 scintillamfcview.cpp
字号:
pCmdUI->SetText(strLine);
}
/////////////////////////////////////
// @mfunc menu handler - delete selection
// @rvalue void | not used
//
void CScintillamfcView::OnEditClear()
{
m_wndScintilla.Clear();
}
/////////////////////////////////////
// @mfunc menu handler - redo last undone action
// @rvalue void | not used
//
void CScintillamfcView::OnEditRedo()
{
if (m_wndScintilla.CanRedo())
m_wndScintilla.Redo();
}
/////////////////////////////////////
// @mfunc menu check handler - check if there is an action to redo
// @rvalue void | not used
//
void CScintillamfcView::OnUpdateEditRedo(
CCmdUI* pCmdUI) //@parm menu handle
{
pCmdUI->Enable(m_wndScintilla.CanRedo());
}
/////////////////////////////////////
// @mfunc menu handler - select complete text
// @rvalue void | not used
//
void CScintillamfcView::OnEditSelectAll()
{
m_wndScintilla.SelectAll();
}
/////////////////////////////////////
// @mfunc menu handler - display a window font selection dialog and set font attributes for style at caret position
// @rvalue void | not used
//
void CScintillamfcView::OnOptionsSetfont()
{
CFontDialog dlg;
if (dlg.DoModal() == IDOK)
{
m_wndScintilla.SetFontname(m_wndScintilla.GetCurrentStyle(), dlg.GetFaceName());
m_wndScintilla.SetFontheight(m_wndScintilla.GetCurrentStyle(), dlg.GetSize()/10);
m_wndScintilla.SetBold(m_wndScintilla.GetCurrentStyle(), dlg.IsBold());
m_wndScintilla.SetItalic(m_wndScintilla.GetCurrentStyle(), dlg.IsItalic());
m_wndScintilla.SetUnderline(m_wndScintilla.GetCurrentStyle(), dlg.IsUnderline());
}
}
/////////////////////////////////////
// @mfunc menu handler - display a color selection dialog and set foreground color attribute for style at caret position
// @rvalue void | not used
//
void CScintillamfcView::OnOptionsForeground()
{
CColorDialog dlg;
if (dlg.DoModal() == IDOK)
{
m_wndScintilla.SetForeground(m_wndScintilla.GetCurrentStyle(), dlg.GetColor());
}
}
/////////////////////////////////////
// @mfunc menu handler - display a color selection dialog and set background color attribute for style at caret position
// @rvalue void | not used
//
void CScintillamfcView::OnOptionsBackground()
{
CColorDialog dlg;
if (dlg.DoModal() == IDOK)
{
m_wndScintilla.SetBackground(m_wndScintilla.GetCurrentStyle(), dlg.GetColor());
}
}
/////////////////////////////////////
// @mfunc menu handler - display a wordlist dialog and set a wordlist with keywords for current lexer
// @rvalue void | not used
//
void CScintillamfcView::OnOptionsWordlist()
{
CWordlistDlg dlg;
if (dlg.DoModal() == IDOK)
{
int nWordlist = ::atoi(dlg.m_strWordlistNumber);
m_wndScintilla.SendMessage(SCI_SETKEYWORDS, nWordlist, (long)(LPCSTR)dlg.m_strKeywords);
m_wndScintilla.Refresh();
}
}
/////////////////////////////////////
// @mfunc menu check handler - set indicator for overstrike mode
// @rvalue void | not used
//
void CScintillamfcView::OnUpdateInsert(
CCmdUI* pCmdUI) //@parm menu handle
{
CString strText;
if (m_wndScintilla.GetOverstrike())
strText.LoadString(ID_INDICATOR_OVR);
pCmdUI->SetText(strText);
}
/////////////////////////////////////
// @mfunc command handler - set control to overstrike mode - see accelarator table in ressource file
// @rvalue void | not used
//
void CScintillamfcView::OnToggleInsert()
{
m_wndScintilla.SetOverstrike(!m_wndScintilla.GetOverstrike());
}
/////////////////////////////////////
// @mfunc menu handler - toggle display of folding margin
// @rvalue void | not used
//
void CScintillamfcView::OnOptionsFoldMargin()
{
m_wndScintilla.SetDisplayFolding();
}
/////////////////////////////////////
// @mfunc menu handler - toggle display of selection margin
// @rvalue void | not used
//
void CScintillamfcView::OnOptionsSelectionMargin()
{
m_wndScintilla.SetDisplaySelection(!m_wndScintilla.GetDisplaySelection());
}
/////////////////////////////////////
// @mfunc menu check handler - check menu when selection margin is displayed
// @rvalue void | not used
//
void CScintillamfcView::OnUpdateOptionsSelectionMargin(
CCmdUI* pCmdUI) //@parm menu handle
{
pCmdUI->SetCheck(m_wndScintilla.GetDisplaySelection());
}
/////////////////////////////////////
// @mfunc menu check handler - check menu when folding margin is displayed
// @rvalue void | not used
//
void CScintillamfcView::OnUpdateOptionsFoldMargin(
CCmdUI* pCmdUI) //@parm menu handle
{
pCmdUI->SetCheck(m_wndScintilla.GetDisplayFolding());
}
/////////////////////////////////////
// @mfunc menu handler - add a bookmark at the caret line
// @rvalue void | not used
//
void CScintillamfcView::OnOptionsAddmarker()
{
m_wndScintilla.AddBookmark(m_wndScintilla.GetCurrentLine());
}
/////////////////////////////////////
// @mfunc menu check handler - disable menu item when there is already a marker at that line
// @rvalue void | not used
//
void CScintillamfcView::OnUpdateOptionsAddmarker(
CCmdUI* pCmdUI) //@parm menu handle
{
pCmdUI->Enable(!m_wndScintilla.HasBookmark(m_wndScintilla.GetCurrentLine()));
}
/////////////////////////////////////
// @mfunc menu handler - delete a bookmark at the caret line
// @rvalue void | not used
//
void CScintillamfcView::OnOptionsDeletemarker()
{
m_wndScintilla.DeleteBookmark(m_wndScintilla.GetCurrentLine());
}
/////////////////////////////////////
// @mfunc menu check handler - disable menu item when there is no marker at that line
// @rvalue void | not used
//
void CScintillamfcView::OnUpdateOptionsDeletemarker(
CCmdUI* pCmdUI) //@parm menu handle
{
pCmdUI->Enable(m_wndScintilla.HasBookmark(m_wndScintilla.GetCurrentLine()));
}
/////////////////////////////////////
// @mfunc menu handler - find next bookmark from the caret line
// @rvalue void | not used
//
void CScintillamfcView::OnOptionsFindNextmarker()
{
m_wndScintilla.FindNextBookmark();
}
/////////////////////////////////////
// @mfunc menu handler - find previous bookmark from the caret line
// @rvalue void | not used
//
void CScintillamfcView::OnOptionsFindPrevmarker()
{
m_wndScintilla.FindPreviousBookmark();
}
/////////////////////////////////////
// @mfunc menu handler - find previous bookmark from the caret line
// @rvalue BOOL | TRUE if we handled the message - FALSE if message should be processed further
//
BOOL CScintillamfcView::OnNotify(
WPARAM wParam, //@parm not used
LPARAM lParam, //@parm pointer to notification structure
LRESULT* pResult ) //@parm result
{
NMHDR *phDR;
phDR = (NMHDR*)lParam;
// does notification come from my scintilla window?
if (phDR != NULL && phDR->hwndFrom == m_wndScintilla.m_hWnd)
{
SCNotification *pMsg = (SCNotification*)lParam;
switch (phDR->code)
{
case SCN_STYLENEEDED:
break;
case SCN_CHARADDED:
break;
case SCN_SAVEPOINTREACHED:
break;
// called when the document is changed - mark document modified
case SCN_SAVEPOINTLEFT:
{
CDocument *pDoc = GetDocument();
pDoc->SetModifiedFlag(TRUE);
}
break;
case SCN_MODIFYATTEMPTRO:
break;
case SCN_KEY:
break;
case SCN_DOUBLECLICK:
break;
// called when something changes and we want to show new indicator state or brace matching
case SCN_UPDATEUI:
{
m_wndScintilla.UpdateUI();
}
break;
case SCN_MODIFIED:
break;
case SCN_MACRORECORD:
break;
// user clicked margin - try folding action
case SCN_MARGINCLICK:
{
m_wndScintilla.DoDefaultFolding(pMsg->margin, pMsg->position);
}
break;
case SCN_NEEDSHOWN:
break;
case SCN_PAINTED:
break;
case SCN_USERLISTSELECTION:
break;
case SCN_URIDROPPED:
break;
case SCN_DWELLSTART:
break;
case SCN_DWELLEND:
break;
}
return TRUE; // we processed the message
}
return CWnd::OnNotify(wParam, lParam, pResult);
}
/////////////////////////////////////
// @mfunc menu handler - save current document - let the control do the work
// @rvalue void | not used
//
BOOL CScintillamfcView::Save(
LPCSTR szPath) //@parm path of document to save to
{
return m_wndScintilla.SaveFile(szPath);
}
/////////////////////////////////////
// @mfunc menu handler - goto to a character position in the control
// @rvalue void | not used
//
void CScintillamfcView::OnOptionsGotopos()
{
CGotoPosDlg dlg;
dlg.m_nPos = m_wndScintilla.GetCurrentPosition();
if (dlg.DoModal() == IDOK)
{
m_wndScintilla.GotoPosition(dlg.m_nPos);
m_wndScintilla.SetFocus();
}
}
/////////////////////////////////////
// @mfunc menu handler - goto to a character position in the control
// @rvalue void | not used
//
void CScintillamfcView::OnOptionsGotoline()
{
CGotoLineDlg dlg;
dlg.m_nLine = m_wndScintilla.GetCurrentLine();
if (dlg.DoModal() == IDOK)
{
m_wndScintilla.GotoLine(dlg.m_nLine);
m_wndScintilla.SetFocus();
}
}
/////////////////////////////////////
// @mfunc menu handler -
// @rvalue void | not used
//
void CScintillamfcView::OnOptionsDlg()
{
CScintillaDlg dlg;
dlg.DoModal();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -