本文整理汇总了C++中NppParameters::getFindHistory方法的典型用法代码示例。如果您正苦于以下问题:C++ NppParameters::getFindHistory方法的具体用法?C++ NppParameters::getFindHistory怎么用?C++ NppParameters::getFindHistory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NppParameters
的用法示例。
在下文中一共展示了NppParameters::getFindHistory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: highlightViewWithWord
void SmartHighlighter::highlightViewWithWord(ScintillaEditView * pHighlightView, const generic_string & word2Hilite)
{
// save target locations for other search functions
auto originalStartPos = pHighlightView->execute(SCI_GETTARGETSTART);
auto originalEndPos = pHighlightView->execute(SCI_GETTARGETEND);
// Get the range of text visible and highlight everything in it
auto firstLine = static_cast<int>(pHighlightView->execute(SCI_GETFIRSTVISIBLELINE));
auto nbLineOnScreen = pHighlightView->execute(SCI_LINESONSCREEN);
auto nbLines = min(nbLineOnScreen, MAXLINEHIGHLIGHT) + 1;
auto lastLine = firstLine + nbLines;
int startPos = 0;
int endPos = 0;
auto currentLine = firstLine;
int prevDocLineChecked = -1; //invalid start
// Determine mode for SmartHighlighting
bool isWordOnly = true;
bool isCaseSensentive = true;
const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI();
if (nppGUI._smartHiliteUseFindSettings)
{
// fetch find dialog's setting
NppParameters *nppParams = NppParameters::getInstance();
FindHistory &findHistory = nppParams->getFindHistory();
isWordOnly = findHistory._isMatchWord;
isCaseSensentive = findHistory._isMatchCase;
}
else
{
isWordOnly = nppGUI._smartHiliteWordOnly;
isCaseSensentive = nppGUI._smartHiliteCaseSensitive;
}
FindOption fo;
fo._isMatchCase = isCaseSensentive;
fo._isWholeWord = isWordOnly;
FindReplaceInfo frInfo;
frInfo._txt2find = word2Hilite.c_str();
for (; currentLine < lastLine; ++currentLine)
{
int docLine = static_cast<int>(pHighlightView->execute(SCI_DOCLINEFROMVISIBLE, currentLine));
if (docLine == prevDocLineChecked)
continue; //still on same line (wordwrap)
prevDocLineChecked = docLine;
startPos = static_cast<int>(pHighlightView->execute(SCI_POSITIONFROMLINE, docLine));
endPos = static_cast<int>(pHighlightView->execute(SCI_POSITIONFROMLINE, docLine + 1));
frInfo._startRange = startPos;
frInfo._endRange = endPos;
if (endPos == -1)
{ //past EOF
frInfo._endRange = pHighlightView->getCurrentDocLen() - 1;
_pFRDlg->processRange(ProcessMarkAll_2, frInfo, NULL, &fo, -1, pHighlightView);
break;
}
else
{
_pFRDlg->processRange(ProcessMarkAll_2, frInfo, NULL, &fo, -1, pHighlightView);
}
}
// restore the original targets to avoid conflicts with the search/replace functions
pHighlightView->execute(SCI_SETTARGETRANGE, originalStartPos, originalEndPos);
}
示例2: highlightView
void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView, ScintillaEditView * unfocusView)
{
// Clear marks
pHighlightView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_SMART);
const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI();
// If nothing selected or smart highlighting disabled, don't mark anything
if ((!nppGUI._enableSmartHilite) || (pHighlightView->execute(SCI_GETSELECTIONEMPTY) == 1))
{
if (nppGUI._smartHiliteOnAnotherView && unfocusView && unfocusView->isVisible()
&& unfocusView->getCurrentBufferID() != pHighlightView->getCurrentBufferID())
{
unfocusView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_SMART);
}
return;
}
auto curPos = pHighlightView->execute(SCI_GETCURRENTPOS);
auto range = pHighlightView->getSelection();
int textlen = range.cpMax - range.cpMin + 1;
// Determine mode for SmartHighlighting
bool isWordOnly = true;
if (nppGUI._smartHiliteUseFindSettings)
{
// fetch find dialog's setting
NppParameters *nppParams = NppParameters::getInstance();
FindHistory &findHistory = nppParams->getFindHistory();
isWordOnly = findHistory._isMatchWord;
}
else
{
isWordOnly = nppGUI._smartHiliteWordOnly;
}
// additional checks for wordOnly mode
// Make sure the "word" positions match the current selection
if (isWordOnly)
{
auto wordStart = pHighlightView->execute(SCI_WORDSTARTPOSITION, curPos, true);
auto wordEnd = pHighlightView->execute(SCI_WORDENDPOSITION, wordStart, true);
if (wordStart == wordEnd || wordStart != range.cpMin || wordEnd != range.cpMax)
return;
}
else
{
auto line = pHighlightView->execute(SCI_LINEFROMPOSITION, curPos);
auto lineLength = pHighlightView->execute(SCI_LINELENGTH, line);
if (textlen > lineLength)
return;
}
char * text2Find = new char[textlen];
pHighlightView->getSelectedText(text2Find, textlen, false); //do not expand selection (false)
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
UINT cp = static_cast<UINT>(pHighlightView->execute(SCI_GETCODEPAGE));
const TCHAR * text2FindW = wmc->char2wchar(text2Find, cp);
highlightViewWithWord(pHighlightView, text2FindW);
if (nppGUI._smartHiliteOnAnotherView && unfocusView && unfocusView->isVisible()
&& unfocusView->getCurrentBufferID() != pHighlightView->getCurrentBufferID())
{
// Clear marks
unfocusView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_SMART);
highlightViewWithWord(unfocusView, text2FindW);
}
delete[] text2Find;
}