MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / EditFindPrev

Function EditFindPrev

src/Edit.c:4812–4860  ·  view source on GitHub ↗

============================================================================= EditFindPrev()

Source from the content-addressed store, hash-verified

4810// EditFindPrev()
4811//
4812BOOL EditFindPrev ( HWND hwnd, LPCEDITFINDREPLACE lpefr, BOOL fExtendSelection )
4813{
4814 struct TextToFind ttf;
4815 int iPos;
4816 int iSelPos, iSelAnchor;
4817 int iLength;
4818 char szFind2[512];
4819 BOOL bSuppressNotFound = FALSE;
4820 if ( !lstrlenA ( lpefr->szFind ) ) {
4821 return /*EditFindReplaceDlg(hwnd,lpefr,FALSE)*/FALSE;
4822 }
4823 lstrcpynA ( szFind2, lpefr->szFind, COUNTOF ( szFind2 ) );
4824 if ( lpefr->bTransformBS )
4825 TransformBackslashes ( szFind2, ( lpefr->fuFlags & SCFIND_REGEXP ),
4826 ( UINT ) SendMessage ( hwnd, SCI_GETCODEPAGE, 0, 0 ) );
4827 if ( lstrlenA ( szFind2 ) == 0 ) {
4828 InfoBox ( 0, L"MsgNotFound", IDS_NOTFOUND );
4829 return FALSE;
4830 }
4831 iSelPos = ( int ) SendMessage ( hwnd, SCI_GETCURRENTPOS, 0, 0 );
4832 iSelAnchor = ( int ) SendMessage ( hwnd, SCI_GETANCHOR, 0, 0 );
4833 ZeroMemory ( &ttf, sizeof ( ttf ) );
4834 ttf.chrg.cpMin = max ( 0, ( int ) SendMessage ( hwnd, SCI_GETSELECTIONSTART, 0, 0 ) );
4835 ttf.chrg.cpMax = 0;
4836 ttf.lpstrText = szFind2;
4837 iPos = ( int ) SendMessage ( hwnd, SCI_FINDTEXT, lpefr->fuFlags, ( LPARAM ) &ttf );
4838 iLength = ( int ) SendMessage ( hwnd, SCI_GETLENGTH, 0, 0 );
4839 if ( iPos == -1 && ttf.chrg.cpMin < iLength && !lpefr->bNoFindWrap && !fExtendSelection ) {
4840 if ( IDOK == InfoBox ( MBOKCANCEL, L"MsgFindWrap2", IDS_FIND_WRAPRE ) ) {
4841 ttf.chrg.cpMin = iLength;
4842 iPos = ( int ) SendMessage ( hwnd, SCI_FINDTEXT, lpefr->fuFlags, ( LPARAM ) &ttf );
4843 } else {
4844 bSuppressNotFound = TRUE;
4845 }
4846 }
4847 if ( iPos == -1 ) {
4848 // notfound
4849 if ( !bSuppressNotFound ) {
4850 InfoBox ( 0, L"MsgNotFound", IDS_NOTFOUND );
4851 }
4852 return FALSE;
4853 }
4854 if ( !fExtendSelection ) {
4855 EditSelectEx ( hwnd, ttf.chrgText.cpMin, ttf.chrgText.cpMax );
4856 } else {
4857 EditSelectEx ( hwnd, max ( iSelPos, iSelAnchor ), ttf.chrgText.cpMin );
4858 }
4859 return TRUE;
4860}
4861
4862
4863void HL_Find_next_word(HWND hwnd, LPCEDITFINDREPLACE lpref, BOOL next) {

Callers 3

EditFindReplaceDlgProcWFunction · 0.85
InitInstanceFunction · 0.85
MsgCommandFunction · 0.85

Calls 3

TransformBackslashesFunction · 0.85
InfoBoxFunction · 0.85
EditSelectExFunction · 0.85

Tested by

no test coverage detected