@@ -1147,11 +1147,12 @@ void CRegexAssistantDlg::OnNMDblclkTokenListCtrl( NMHDR *pNMHDR, LRESULT *pResul
11471147 {
11481148 int nStartChar = 0 , nEndChar = 0 ;
11491149 CEdit *EditBoxToChange = &m_RegexStatement_editBx;
1150- const CString Column1Value = m_TokenList_list.GetItemText ( CurSel, 0 );
1150+ const CString Column1Value = m_TokenList_list.GetItemText ( CurSel, 0 );
1151+ const CString ExampleExpressions = m_TokenList_list.GetItemText ( CurSel, 2 );
1152+ const CString Sample = m_TokenList_list.GetItemText ( CurSel, 3 );
11511153 CString InsertStr = Column1Value;
1152- CString Sample = m_TokenList_list.GetItemText ( CurSel, 3 );
1153- if ( pNMItemActivate->uKeyFlags & LVKF_CONTROL || Sample[0 ] == ' \\ ' || Column1Value.Left ( 2 ) == _T ( " ()" ) )
1154- InsertStr = m_TokenList_list.GetItemText ( CurSel, 2 );
1154+ if ( pNMItemActivate->uKeyFlags & LVKF_CONTROL && ExampleExpressions.GetLength ())
1155+ InsertStr = ExampleExpressions;
11551156 if ( InsertStr.GetLength () > 1 && (isdigit ( InsertStr[1 ] ) && InsertStr[1 ] != ' 0' ) )
11561157 EditBoxToChange = &m_RegexReplacementExpression_editBx;
11571158
@@ -1187,10 +1188,7 @@ void CRegexAssistantDlg::KeyUpOrDown( UINT nChar )
11871188 if ( nChar == (VK_SHIFT | VK_CONTROL | VK_UP) )
11881189 {
11891190 m_RegexCompatibility_cmbx.VerifyValidSelect ( GO_TO_FIRSTVALIDITEM );
1190- } /* else if ( nChar == (VK_SHIFT | VK_CONTROL | VK_DOWN) )
1191- {
1192- m_RegexCompatibility_cmbx.VerifyValidSelect( GO_TO_LASTVALIDITEM );
1193- } */ else if ( nChar == VK_DOWN )
1191+ } else if ( nChar == VK_DOWN )
11941192 {
11951193 m_RegexCompatibility_cmbx.VerifyValidSelect ( 1 );
11961194 } else if ( nChar == VK_UP )
@@ -1222,138 +1220,3 @@ COLORREF CMFCListCtrl_AltRowColors::OnGetCellBkColor( int nRow, int nColumn )
12221220 return RGB ( 255 , 255 , 0 );
12231221 return CMFCListCtrl::OnGetCellBkColor (nRow, nColumn );
12241222}
1225-
1226- // void CRegexAssistantDlg::ChangeRegexEditBox_LineByLine( CString RegexStatement )
1227- // {
1228- // try
1229- // {
1230- // if ( RegexStatement == _T( "\\b" ) )
1231- // return;
1232- // std::unique_ptr<char[]> pcTempBuffer( new char[m_MaxViewWidth + m_ViewWidthAddedPad]() );
1233- // std::string strRegexStatement = Common::ToString( RegexStatement );
1234- // boost::xpressive::sregex boost_Needle = GetNeedle( strRegexStatement, m_IgnoreCase );
1235- // std::regex std_Needle( strRegexStatement, GetStdRegexOptionFlags() );
1236- // const std::regex_constants::match_flag_type regex_compatibility_flag = GetStdRegexMatchFlags();
1237- // const boost::xpressive::regex_constants::match_flag_type boost_compatibility_flag = GetBoostCompatibilityFlag();
1238- // int count_top = 0;
1239- //
1240- // for ( int LineCurrent = m_ScintillaWrapper.SendEditor( SCI_LINEFROMPOSITION );; ++LineCurrent )
1241- // {
1242- // count_top++;
1243- // int LineLen = m_ScintillaWrapper.SendEditor( SCI_GETLINE, LineCurrent, reinterpret_cast<sptr_t>(pcTempBuffer.get()) );
1244- // if ( LineLen == 0 || LineLen > m_MaxViewWidth )
1245- // break;
1246- // else
1247- // pcTempBuffer[LineLen] = '\0';
1248- // int count = 0;
1249- // const int MaxCount = 32;
1250- // const long CurrentLineBytePos = (long)m_ScintillaWrapper.SendEditor( SCI_POSITIONFROMLINE, LineCurrent );
1251- // string strHaystack = pcTempBuffer.get();
1252- // string::const_iterator start = strHaystack.begin(), end = strHaystack.end(), itHaystackStart = strHaystack.begin();
1253- // if ( IsBoost() )
1254- // {
1255- // boost::xpressive::smatch what;
1256- // boost::xpressive::regex_constants::match_flag_type flags = boost_compatibility_flag;
1257- // while ( boost::xpressive::regex_search( start, end, what, boost_Needle, flags ) )
1258- // {
1259- // if ( ++count > MaxCount )
1260- // break;
1261- // string::const_iterator NeedleStart = what[0].first;
1262- // string::const_iterator NeedleEnd = what[0].second;
1263- // Sci_TextToFind ft = {0};
1264- // ft.chrgText.cpMin = CurrentLineBytePos + (long)std::distance( itHaystackStart, NeedleStart );
1265- // ft.chrgText.cpMax = CurrentLineBytePos + (long)std::distance( itHaystackStart, NeedleEnd );
1266- // ft.chrg.cpMin = ft.chrgText.cpMax + 1;
1267- // m_ScintillaWrapper.SetStartStyling( ft, GetMarkerID() );
1268- //
1269- // start = what[0].second;
1270- // flags = boost::xpressive::regex_constants::match_prev_avail | boost_compatibility_flag;
1271- // }
1272- // } else
1273- // {
1274- // std::smatch what;
1275- // while ( std::regex_search( start, end, what, std_Needle, regex_compatibility_flag ) )
1276- // {
1277- // if ( ++count > MaxCount )
1278- // break;
1279- // string::const_iterator NeedleStart = what[0].first;
1280- // string::const_iterator NeedleEnd = what[0].second;
1281- // Sci_TextToFind ft = {0};
1282- // ft.chrgText.cpMin = CurrentLineBytePos + (long)std::distance( itHaystackStart, NeedleStart );
1283- // ft.chrgText.cpMax = CurrentLineBytePos + (long)std::distance( itHaystackStart, NeedleEnd );
1284- // ft.chrg.cpMin = ft.chrgText.cpMax + 1;
1285- // m_ScintillaWrapper.SetStartStyling( ft, GetMarkerID() );
1286- // start = what.suffix().first;
1287- // }
1288- // }
1289- // }
1290- // } catch ( ... )
1291- // {//ToDo: Add logging logic here
1292- // return;
1293- // }
1294- // }
1295- //
1296- //
1297- // void CRegexAssistantDlg::RegexReplace_LineByLine( CString NeedleCstr, CString NeedleReplacementCstr )
1298- // {
1299- // const std::regex_constants::match_flag_type std_regex_compatibility_flag = GetStdRegexMatchFlags();
1300- // const boost::xpressive::regex_constants::match_flag_type boost_compatibility_flag = GetBoostCompatibilityFlag();
1301- //
1302- // int BufferSize = m_ScintillaWrapper.SendEditor( SCI_GETTEXTLENGTH ) + 1;
1303- // if ( BufferSize < 1 )
1304- // return;
1305- // std::unique_ptr<char[]> pcBuffer( new char[BufferSize + m_ViewWidthAddedPad]() );
1306- // m_ScintillaWrapper.GetText( BufferSize, pcBuffer );
1307- // string Haystack = pcBuffer.get();
1308- // pcBuffer.reset( new char[m_MaxViewWidth + m_ViewWidthAddedPad] );
1309- // string HaystackAfterReplacement;
1310- // string NeedleReplacement = Common::ToString( (LPCTSTR)NeedleReplacementCstr );
1311- // boost::xpressive::sregex BoostNeedle;
1312- // std::regex Needle;
1313- // try
1314- // {
1315- // BoostNeedle = GetNeedle( Common::ToString( NeedleCstr ), m_IgnoreCase );
1316- // string s = Common::ToString( (LPCTSTR)NeedleCstr );
1317- // Needle = std::regex( s, GetStdRegexOptionFlags() );
1318- // } catch ( ... )
1319- // {
1320- // MessageBox( _T( "Error while trying to compile replacement string. Check " ) );
1321- // return;
1322- // }
1323- // for ( int LineCurrent = m_ScintillaWrapper.SendEditor( SCI_LINEFROMPOSITION );; ++LineCurrent )
1324- // {
1325- // int LineLen = m_ScintillaWrapper.GetText( LineCurrent, pcBuffer, ScintillaWrapper::Sci_GetLine );
1326- // if ( LineLen <= 0 || LineLen > LineCurrent )
1327- // break;
1328- // try
1329- // {
1330- // string strHaystack = pcBuffer.get();
1331- // string ConvertedString;
1332- // try
1333- // {
1334- // if ( IsSTD_Regex() )
1335- // {
1336- // ConvertedString = std::regex_replace( strHaystack, Needle, NeedleReplacement, std_regex_compatibility_flag );
1337- // } else
1338- // {
1339- // ConvertedString = boost::xpressive::regex_replace( strHaystack, BoostNeedle, NeedleReplacement, boost_compatibility_flag );
1340- // }
1341- // } catch ( ... )
1342- // {
1343- // ConvertedString = strHaystack;
1344- // }
1345- // HaystackAfterReplacement += ConvertedString;
1346- // } catch ( ... )
1347- // {
1348- // //ToDo: Add more catch types here so a more specific error can be logged or display
1349- // break;
1350- // }
1351- // }
1352- // if ( Haystack != HaystackAfterReplacement )
1353- // {
1354- // m_ScintillaWrapper.SendEditor( SCI_CLEARALL );
1355- // m_ScintillaWrapper.SendEditor( SCI_APPENDTEXT, HaystackAfterReplacement );
1356- // }
1357- // }
1358-
1359-
0 commit comments