Преглед на файлове

- added shortcut key to load last search
- added shortcut key to toggle search method
- added the ability use environment variables in the database path

sabrogden преди 8 години
родител
ревизия
d03183439f
променени са 16 файла, в които са добавени 328 реда и са изтрити 28 реда
  1. 1 1
      Accels.cpp
  2. 6 0
      ActionEnums.cpp
  3. 2 0
      ActionEnums.h
  4. 44 6
      CP_Main.rc
  5. 1 2
      DatabaseUtilities.cpp
  6. 29 1
      Options.cpp
  7. 5 1
      Options.h
  8. 68 9
      OptionsGeneral.cpp
  9. 8 0
      OptionsGeneral.h
  10. 2 2
      OptionsKeyBoard.cpp
  11. 1 1
      OptionsKeyBoard.h
  12. 50 2
      QPasteWnd.cpp
  13. 2 0
      QPasteWnd.h
  14. 4 2
      Resource.h
  15. 95 1
      SymbolEdit.cpp
  16. 10 0
      SymbolEdit.h

+ 1 - 1
Accels.cpp

@@ -44,7 +44,7 @@ CString CAccels::GetCmdKeyText(DWORD cmd)
 				cmdShortcutText = CHotKey::GetHotKeyDisplayStatic(it->second.Key);
 				if (it->second.Key2 != 0)
 				{
-					CString cmdShortcutText2 = CHotKey::GetHotKeyDisplayStatic(it->second.Key);
+					CString cmdShortcutText2 = CHotKey::GetHotKeyDisplayStatic(it->second.Key2);
 
 					if (cmdShortcutText2.GetLength() > 0)
 					{

+ 6 - 0
ActionEnums.cpp

@@ -292,6 +292,12 @@ CString ActionEnums::EnumDescription(ActionEnumValues value)
 		break;
 	case TOGGLE_DESCRIPTION_WORD_WRAP:
 		val = "Toggle Description Word Wrap";
+		break;
+	case APPLY_LAST_SEARCH:
+		val = "Apply Last Search";
+		break;
+	case TOGGLE_SEARCH_METHOD:
+		val = "Toggle Search Method";
 	}
 
 	CString translatedValue = theApp.m_Language.GetQuickPasteKeyboardString(value, val);

+ 2 - 0
ActionEnums.h

@@ -99,6 +99,8 @@ public:
 		MOVE_SELECTION_UP,
 		MOVE_SELECTION_DOWN,
 		TOGGLE_DESCRIPTION_WORD_WRAP,
+		APPLY_LAST_SEARCH,
+		TOGGLE_SEARCH_METHOD,
 
 		LAST_ACTION
 	};

+ 44 - 6
CP_Main.rc

@@ -557,7 +557,6 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1
 BEGIN
     CONTROL         "HotKey1",IDC_HOTKEY,"msctls_hotkey32",WS_BORDER | WS_TABSTOP,97,13,80,14
     CONTROL         "Win",IDC_CHECK_WIN_DITTO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,180,13,33,14
-    LTEXT           "Send custom strokes Per Application",IDC_STATIC_CUSTOM_KEYS,217,16,127,8
     CONTROL         "",IDC_HOTKEY_TEXT_ONLY,"msctls_hotkey32",WS_BORDER | WS_TABSTOP,97,61,80,14
     CONTROL         "Win",IDC_CHECK_WIN_TEXT_ONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,180,61,33,14
     CONTROL         "HotKey1",IDC_HOTKEY1,"msctls_hotkey32",WS_BORDER | WS_TABSTOP,66,149,80,14
@@ -609,6 +608,8 @@ BEGIN
     LTEXT           "Activate Ditto",IDC_STATIC_ACTIVATE4,19,45,71,14,SS_CENTERIMAGE
     CONTROL         "Use currently selected group in Ditto's UI for last ten copies",IDC_CHECK_USE_UI_GROUP_LAST_10,
                     "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,134,324,12
+    CONTROL         "Send custom strokes Per Application",IDC_STATIC_CUSTOM_KEYS,
+                    "MfcLink",WS_TABSTOP,214,16,127,13
 END
 
 IDD_OPTIONS_GENERAL DIALOGEX 0, 0, 375, 275
@@ -628,11 +629,11 @@ BEGIN
     PUSHBUTTON      "....",IDC_GET_PATH,354,148,14,12
     LTEXT           "Days",IDC_STATIC_DAYS,196,40,51,12,SS_CENTERIMAGE
     LTEXT           "Language",IDC_STATIC_LANGUAGE,9,60,36,12,SS_CENTERIMAGE
-    LTEXT           "Include",IDC_STATIC_INCLUDE_APPS,14,181,36,13,SS_CENTERIMAGE
-    LTEXT           "Exclude",IDC_STATIC_EXCLUDE_APPS,14,203,36,13,SS_CENTERIMAGE
-    EDITTEXT        IDC_EDIT_APP_COPY_INCLUDE,50,181,316,13,ES_AUTOHSCROLL
-    EDITTEXT        IDC_EDIT_APP_COPY_EXCLUDE,50,203,316,13,ES_AUTOHSCROLL
-    GROUPBOX        "Accepted Copy Applications (seperate by ;)",IDC_STATIC_APP_SEP_DESC,7,168,361,55
+    LTEXT           "Include",IDC_STATIC_INCLUDE_APPS,14,186,36,13,SS_CENTERIMAGE
+    LTEXT           "Exclude",IDC_STATIC_EXCLUDE_APPS,14,208,36,13,SS_CENTERIMAGE
+    EDITTEXT        IDC_EDIT_APP_COPY_INCLUDE,50,186,316,13,ES_AUTOHSCROLL
+    EDITTEXT        IDC_EDIT_APP_COPY_EXCLUDE,50,208,316,13,ES_AUTOHSCROLL
+    GROUPBOX        "Accepted Copy Applications (seperate by ;)",IDC_STATIC_APP_SEP_DESC,7,173,361,55
     PUSHBUTTON      "Advanced",IDC_BUTTON_ADVANCED,318,256,50,14
     COMBOBOX        IDC_COMBO_THEME,67,82,130,95,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
     PUSHBUTTON      "About Theme",IDC_BUTTON_THEME,207,82,106,14
@@ -643,6 +644,7 @@ BEGIN
     COMBOBOX        IDC_COMBO_POPUP_POSITION,67,104,130,95,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
     LTEXT           "Popup Position",IDC_STATIC_POPUP_POS,9,104,51,12,SS_CENTERIMAGE
     LTEXT           "Display Font",IDC_STATIC_FONT,9,125,51,14,SS_CENTERIMAGE
+    CONTROL         "Environment Variables",IDC_MFCLINK_ENV_VAR,"MfcLink",WS_TABSTOP,67,160,283,14
 END
 
 IDD_SELECT_DB DIALOGEX 0, 0, 276, 46
@@ -1604,6 +1606,42 @@ BEGIN
     0
 END
 
+IDD_OPTIONS_GENERAL DLGINIT
+BEGIN
+    IDC_MFCLINK_ENV_VAR, 0x37c, 255, 0
+0x4d3c, 0x4346, 0x694c, 0x6b6e, 0x555f, 0x6c72, 0x683e, 0x7474, 0x7370, 
+0x2f3a, 0x732f, 0x756f, 0x6372, 0x6665, 0x726f, 0x6567, 0x6e2e, 0x7465, 
+0x702f, 0x642f, 0x7469, 0x6f74, 0x632d, 0x2f70, 0x6977, 0x696b, 0x452f, 
+0x766e, 0x7269, 0x6e6f, 0x656d, 0x746e, 0x6156, 0x6972, 0x6261, 0x656c, 
+0x2f73, 0x2f3c, 0x464d, 0x4c43, 0x6e69, 0x5f6b, 0x7255, 0x3e6c, 0x4d3c, 
+0x4346, 0x694c, 0x6b6e, 0x555f, 0x6c72, 0x7250, 0x6665, 0x7869, 0x3c3e, 
+0x4d2f, 0x4346, 0x694c, 0x6b6e, 0x555f, 0x6c72, 0x7250, 0x6665, 0x7869, 
+0x3c3e, 0x464d, 0x4c43, 0x6e69, 0x5f6b, 0x6f54, 0x6c6f, 0x6974, 0x3e70, 
+0x6e45, 0x6976, 0x6f72, 0x6d6e, 0x6e65, 0x2074, 0x6176, 0x6972, 0x6261, 
+0x656c, 0x2073, 0x6e69, 0x6420, 0x7461, 0x6261, 0x7361, 0x2065, 0x6170, 
+0x6874, 0x2f3c, 0x464d, 0x4c43, 0x6e69, 0x5f6b, 0x6f54, 0x6c6f, 0x6974, 
+0x3e70, 0x4d3c, 0x4346, 0x694c, 0x6b6e, 0x465f, 0x6c75, 0x546c, 0x7865, 
+0x5474, 0x6f6f, 0x746c, 0x7069, 0x543e, 0x5552, 0x3c45, 0x4d2f, 0x4346, 
+0x694c, 0x6b6e, 0x465f, 0x6c75, 0x546c, 0x7865, 0x5474, 0x6f6f, 0x746c, 
+0x7069, "\076" 
+    0
+END
+
+IDD_OPTIONS_KEYSTROKES DLGINIT
+BEGIN
+    IDC_STATIC_CUSTOM_KEYS, 0x37c, 157, 0
+0x4d3c, 0x4346, 0x694c, 0x6b6e, 0x555f, 0x6c72, 0x3c3e, 0x4d2f, 0x4346, 
+0x694c, 0x6b6e, 0x555f, 0x6c72, 0x3c3e, 0x464d, 0x4c43, 0x6e69, 0x5f6b, 
+0x7255, 0x506c, 0x6572, 0x6966, 0x3e78, 0x2f3c, 0x464d, 0x4c43, 0x6e69, 
+0x5f6b, 0x7255, 0x506c, 0x6572, 0x6966, 0x3e78, 0x4d3c, 0x4346, 0x694c, 
+0x6b6e, 0x545f, 0x6f6f, 0x746c, 0x7069, 0x3c3e, 0x4d2f, 0x4346, 0x694c, 
+0x6b6e, 0x545f, 0x6f6f, 0x746c, 0x7069, 0x3c3e, 0x464d, 0x4c43, 0x6e69, 
+0x5f6b, 0x7546, 0x6c6c, 0x6554, 0x7478, 0x6f54, 0x6c6f, 0x6974, 0x3e70, 
+0x4146, 0x534c, 0x3c45, 0x4d2f, 0x4346, 0x694c, 0x6b6e, 0x465f, 0x6c75, 
+0x546c, 0x7865, 0x5474, 0x6f6f, 0x746c, 0x7069, "\076" 
+    0
+END
+
 
 /////////////////////////////////////////////////////////////////////////////
 //

+ 1 - 2
DatabaseUtilities.cpp

@@ -186,8 +186,7 @@ BOOL OpenDatabase(CString csDB)
 	try
 	{
 		theApp.m_db.close();
-		theApp.m_db.open(csDB);
-		CGetSetOptions::SetDBPath(csDB);
+		theApp.m_db.open(csDB);		
 
 		theApp.m_db.setBusyTimeout(CGetSetOptions::GetDbTimeout());
 

+ 29 - 1
Options.cpp

@@ -907,11 +907,29 @@ BOOL CGetSetOptions::SetDBPath(CString csPath)
 	return SetProfileString("DBPath3", csPath);
 }
 
-CString CGetSetOptions::GetDBPath()
+CString CGetSetOptions::ResolvePath(CString path)
+{
+	CString dest;
+	int newSize = max(path.GetLength() * 10, 1000);
+
+	//path = _T("some string %COMPUTERNAME% test");
+
+	ExpandEnvironmentStrings(path, dest.GetBuffer(newSize), newSize);
+	dest.ReleaseBuffer();
+
+	return dest;
+}
+
+CString CGetSetOptions::GetDBPath(bool resolvePath)
 {
 	CString csDBPath;
 	csDBPath = GetProfileString("DBPath3", "");
 
+	if (resolvePath)
+	{
+		csDBPath = ResolvePath(csDBPath);
+	}
+
 	return csDBPath;
 }
 
@@ -2586,4 +2604,14 @@ void CGetSetOptions::SetToolTipTimeout(long val)
 {
 	m_tooltipTimeout = val;
 	SetProfileLong("ToolTipTimeout", val);
+}
+
+CString CGetSetOptions::GetPastSearchXml()
+{
+	return GetProfileString("PastSearchXml", "");
+}
+
+void CGetSetOptions::SetPastSearchXml(CString val)
+{
+	SetProfileString(_T("PastSearchXml"), val);
 }

+ 5 - 1
Options.h

@@ -137,7 +137,8 @@ public:
 	static void SetCopyGap(long lGap);
 
 	static BOOL SetDBPath(CString csPath);
-	static CString GetDBPath();
+	static CString GetDBPath(bool resolvePath = true);
+	static CString ResolvePath(CString path);
 
 	static BOOL SetDBPathOld(CString csPath);
 	static CString GetDBPathOld();
@@ -587,6 +588,9 @@ public:
 	static long GetToolTipTimeout();
 	static void SetToolTipTimeout(int long);
 
+	static CString GetPastSearchXml();
+	static void SetPastSearchXml(CString val);
+
 };
 
 // global for easy access and for initialization of fast access variables

+ 68 - 9
OptionsGeneral.cpp

@@ -11,6 +11,7 @@
 #include "AccessToSqlite.h"
 #include "AdvGeneral.h"
 #include "DimWnd.h"
+#include "HyperLink.h"
 
 using namespace nsPath;
 
@@ -63,6 +64,7 @@ void COptionsGeneral::DoDataExchange(CDataExchange* pDX)
 	DDX_Control(pDX, IDC_BUTTON_FONT, m_btFont);
 	DDX_Control(pDX, IDC_BUTTON_DEFAULT_FAULT, m_btDefaultButton);
 	DDX_Control(pDX, IDC_COMBO_POPUP_POSITION, m_popupPositionCombo);
+	DDX_Control(pDX, IDC_MFCLINK_ENV_VAR, m_envVarLink);
 }
 
 
@@ -76,6 +78,7 @@ BEGIN_MESSAGE_MAP(COptionsGeneral, CPropertyPage)
 	ON_BN_CLICKED(IDC_BUTTON_THEME, &COptionsGeneral::OnBnClickedButtonTheme)
 	ON_BN_CLICKED(IDC_BUTTON_DEFAULT_FAULT, &COptionsGeneral::OnBnClickedButtonDefaultFault)
 	ON_BN_CLICKED(IDC_BUTTON_FONT, &COptionsGeneral::OnBnClickedButtonFont)
+	ON_EN_CHANGE(IDC_PATH, &COptionsGeneral::OnEnChangePath)
 END_MESSAGE_MAP()
 
 /////////////////////////////////////////////////////////////////////////////
@@ -85,6 +88,11 @@ BOOL COptionsGeneral::OnInitDialog()
 {
 	CPropertyPage::OnInitDialog();
 
+	CString url = _T("https://sourceforge.net/p/ditto-cp/wiki/EnvironmentVariables/");
+	
+	/*m_envVarLink.SetURL(_T("\"") + url);
+	m_envVarLink.SetFontSize(-9);*/
+
 	m_brush.CreateSolidBrush(RGB(251, 251, 251));
 	
 	m_pParent = (COptionsSheet *)GetParent();
@@ -110,7 +118,7 @@ BOOL COptionsGeneral::OnInitDialog()
 	m_copyAppInclude.SetWindowText(g_Opt.GetCopyAppInclude());
 	m_copyAppExclude.SetWindowText(g_Opt.GetCopyAppExclude());
 
-	CString csPath = CGetSetOptions::GetDBPath();
+	CString csPath = CGetSetOptions::GetDBPath(false);
 	m_ePath.SetWindowText(csPath);
 	
 	if (CGetSetOptions::GetFont(m_LogFont))
@@ -158,6 +166,9 @@ BOOL COptionsGeneral::OnInitDialog()
 	UpdateData(FALSE);
 
 	theApp.m_Language.UpdateOptionGeneral(this);
+
+	OnEnChangePath();
+
 	return TRUE;
 }
 
@@ -240,22 +251,23 @@ BOOL COptionsGeneral::OnApply()
 		}
 	}
 
-	CString csPath;
-	m_ePath.GetWindowText(csPath);
+	CString toSavePath;
+	m_ePath.GetWindowText(toSavePath);
+	CString resolvedPath = CGetSetOptions::ResolvePath(toSavePath);
 
 	bool bOpenNewDatabase = false;
 
-	if(csPath.IsEmpty() == FALSE)
+	if(resolvedPath.IsEmpty() == FALSE)
 	{
-		if(FileExists(csPath) == FALSE)
+		if(FileExists(resolvedPath) == FALSE)
 		{
 			CString cs;
-			cs.Format(_T("The database %s does not exist.\n\nCreate a new database?"), csPath);
+			cs.Format(_T("The database %s does not exist.\n\nCreate a new database?"), resolvedPath);
 
 			if(MessageBox(cs, _T("Ditto"), MB_YESNO) == IDYES)
 			{
 				// -- create a new one
-				if(CreateDB(csPath))
+				if(CreateDB(resolvedPath))
 				{
 					bOpenNewDatabase = true;
 				}
@@ -267,7 +279,7 @@ BOOL COptionsGeneral::OnApply()
 		}
 		else
 		{
-			if(ValidDB(csPath) == FALSE)
+			if(ValidDB(resolvedPath) == FALSE)
 			{
 				MessageBox(_T("Invalid Database"), _T("Ditto"), MB_OK);
 				m_ePath.SetFocus();
@@ -281,7 +293,9 @@ BOOL COptionsGeneral::OnApply()
 
 		if(bOpenNewDatabase)
 		{
-			if(OpenDatabase(csPath) == FALSE)
+			CGetSetOptions::SetDBPath(toSavePath);
+
+			if(OpenDatabase(resolvedPath) == FALSE)
 			{
 				MessageBox(_T("Error Opening new database"), _T("Ditto"), MB_OK);
 				m_ePath.SetFocus();
@@ -602,3 +616,48 @@ void COptionsGeneral::OnBnClickedButtonFont()
 		m_btFont.SetWindowText(cs);
 	}
 }
+
+
+//void COptionsGeneral::OnNMClickSyslinkEnvVarInfo(NMHDR *pNMHDR, LRESULT *pResult)
+//{
+//	CString url = _T("https:////sourceforge.net//p//ditto-cp//wiki//EnvironmentVariables//");
+//
+//	CHyperLink::GotoURL(url, SW_SHOW);
+//
+//	*pResult = 0;
+//}
+//
+//
+//void COptionsGeneral::OnEnChangePath()
+//{
+//	// TODO:  If this is a RICHEDIT control, the control will not
+//	// send this notification unless you override the CPropertyPage::OnInitDialog()
+//	// function and call CRichEditCtrl().SetEventMask()
+//	// with the ENM_CHANGE flag ORed into the mask.
+//
+//	// TODO:  Add your control notification handler code here
+//}
+
+
+void COptionsGeneral::OnEnChangePath()
+{
+	// TODO:  If this is a RICHEDIT control, the control will not
+	// send this notification unless you override the CPropertyPage::OnInitDialog()
+	// function and call CRichEditCtrl().SetEventMask()
+	// with the ENM_CHANGE flag ORed into the mask.
+
+	// TODO:  Add your control notification handler code here
+
+	CString toSavePath;
+	m_ePath.GetWindowText(toSavePath);
+
+	if (toSavePath.Find(_T("%")) >= 0)
+	{
+		CString resolvedPath = CGetSetOptions::ResolvePath(toSavePath);
+		m_envVarLink.SetWindowText(resolvedPath);		
+	}
+	else
+	{
+		m_envVarLink.SetWindowText(_T("Environment Variables"));
+	}		
+}

+ 8 - 0
OptionsGeneral.h

@@ -11,6 +11,7 @@
 #include "OptionsSheet.h"
 #include "NumberEdit.h"
 #include "afxwin.h"
+#include "HyperLink.h"
 
 /////////////////////////////////////////////////////////////////////////////
 // COptionsGeneral dialog
@@ -46,6 +47,8 @@ public:
 	CEdit m_ClipSeparator;
 	CEdit m_copyAppInclude;
 	CEdit m_copyAppExclude;
+	CMFCLinkCtrl m_envVarLink;
+	 
 	//}}AFX_DATA
 
 
@@ -71,6 +74,8 @@ protected:
 	CFont m_Font;
 	LOGFONT m_LogFont;
 
+	CFont m_envVarFont;
+
 	void FillThemes();
 	
 	void FillLanguages();
@@ -93,6 +98,9 @@ public:
 	CButton m_btFont;
 	CButton m_btDefaultButton;
 	CComboBox m_popupPositionCombo;
+	//afx_msg void OnNMClickSyslinkEnvVarInfo(NMHDR *pNMHDR, LRESULT *pResult);
+	//afx_msg void OnEnChangePath();
+	afx_msg void OnEnChangePath();
 };
 
 //{{AFX_INSERT_LOCATION}}

+ 2 - 2
OptionsKeyBoard.cpp

@@ -69,8 +69,8 @@ BOOL COptionsKeyBoard::OnInitDialog()
 	CPropertyPage::OnInitDialog();
 
 	CString csHelpPath = CGetSetOptions::GetPath(PATH_HELP);
-	csHelpPath += "DittoCustomKeys.htm\"";
-	m_CustomeKeysHelp.SetURL(_T("\"") + csHelpPath);
+	csHelpPath += "DittoCustomKeys.htm";
+	m_CustomeKeysHelp.SetURL(csHelpPath);
 
 	m_pParent = (COptionsSheet *)GetParent();
 

+ 1 - 1
OptionsKeyBoard.h

@@ -75,7 +75,7 @@ protected:
 	DECLARE_MESSAGE_MAP()
 
 public:
-	CHyperLink m_CustomeKeysHelp;
+	CMFCLinkCtrl m_CustomeKeysHelp;
 	CHotKeyCtrl m_saveClipboardHotKey;
 };
 

+ 50 - 2
QPasteWnd.cpp

@@ -332,6 +332,7 @@ int CQPasteWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
     m_search.Create(WS_TABSTOP | WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL, CRect(0, 0, 0, 0), this, ID_EDIT_SEARCH);
 	m_search.SetPromptText(theApp.m_Language.GetString(_T("Search"), _T("Search")));
 	SetSearchImages();
+	m_search.LoadPastSearches(CGetSetOptions::GetPastSearchXml());
 
 	CRect rcEditArea(theApp.m_metrics.ScaleX(4), theApp.m_metrics.ScaleY(2), theApp.m_metrics.ScaleX(20), theApp.m_metrics.ScaleY(2));
 	//m_search.SetBorder(rcEditArea);
@@ -475,6 +476,8 @@ void CQPasteWnd::LoadShortcuts()
 	m_actions.AddAccel(ActionEnums::HOMELIST, VK_HOME);
 	m_actions.AddAccel(ActionEnums::SHOWMENU, VK_APPS);
 
+	m_search.SetLastSearchAccel(CAccel(0, ActionEnums::APPLY_LAST_SEARCH, 0));
+
 	for (DWORD i = ActionEnums::FIRST_ACTION + 1; i < ActionEnums::LAST_ACTION; i++)
 	{
 		ActionEnums::ActionEnumValues action = (ActionEnums::ActionEnumValues) i;
@@ -500,6 +503,10 @@ void CQPasteWnd::LoadShortcuts()
 
 						m_actions.AddAccel(action, ACCEL_MAKEKEY(LOBYTE(a), shift), b);
 					}
+					else if (action == ActionEnums::APPLY_LAST_SEARCH)
+					{
+						m_search.SetLastSearchAccel(CAccel(a, action, b));
+					}
 
 					if (ActionEnums::ToolTipAction(action))
 					{
@@ -3119,11 +3126,45 @@ bool CQPasteWnd::DoAction(DWORD actionId)
 	case ActionEnums::TOGGLE_DESCRIPTION_WORD_WRAP:
 		ret = DoActionToggleDescriptionWordWrap();
 		break;
+	case ActionEnums::APPLY_LAST_SEARCH:
+		ret = DoActionApplyLastSearch();
+		break;
+	case ActionEnums::TOGGLE_SEARCH_METHOD:
+		ret = DoActionToggleSearchMethod();
+		break;
 	}
 
 	return ret;
 }
 
+bool CQPasteWnd::DoActionToggleSearchMethod()
+{
+	if (CGetSetOptions::GetRegExTextSearch())
+	{
+		//if regex go back to wildcard
+		CGetSetOptions::SetSimpleTextSearch(FALSE);
+		CGetSetOptions::SetRegExTextSearch(FALSE);
+	}
+	else if (CGetSetOptions::GetSimpleTextSearch())
+	{
+		//if contains search go to regex
+		CGetSetOptions::SetSimpleTextSearch(FALSE);
+		CGetSetOptions::SetRegExTextSearch(TRUE);
+	}
+	else
+	{
+		//if wildcard to to contains
+		CGetSetOptions::SetSimpleTextSearch(TRUE);
+		CGetSetOptions::SetRegExTextSearch(FALSE);
+	}
+	return true;
+}
+
+bool CQPasteWnd::DoActionApplyLastSearch()
+{
+	return m_search.ApplyLastSearch();
+}
+
 bool CQPasteWnd::DoActionToggleDescriptionWordWrap()
 {
 	if (m_lstHeader.IsToolTipWindowVisible() == FALSE)
@@ -3137,14 +3178,19 @@ bool CQPasteWnd::DoActionShowDescription()
 {
 	bool ret = false;
 
+	CString csText;
+	m_search.GetWindowText(csText);
+	if (csText != _T(""))
+	{
+		m_search.AddToSearchHistory();
+	}
+
 	if (m_lstHeader.IsToolTipWindowVisible() == false)
 	{
 		ret = m_lstHeader.ShowFullDescription(false, false);
 	}
 	else
 	{
-		CString csText;
-		m_search.GetWindowText(csText);
 		if (csText != _T(""))
 		{
 			m_lstHeader.DoToolTipSearch();
@@ -5606,6 +5652,8 @@ void CQPasteWnd::FillMainTable(CMainTable &table, CppSQLite3Query &q)
 
 void CQPasteWnd::OnDestroy()
 {
+	CGetSetOptions::SetPastSearchXml(m_search.SavePastSearches());
+
     CWndEx::OnDestroy();
     m_thread.Stop();
 	m_extraDataThread.Stop();

+ 2 - 0
QPasteWnd.h

@@ -236,6 +236,8 @@ public:
 	bool DoActionEditClip();
 	bool DoActionMoveSelectionDown();
 	bool DoActionToggleDescriptionWordWrap();
+	bool DoActionApplyLastSearch();
+	bool DoActionToggleSearchMethod();
 	bool DoActionMoveSelectionUp();
 	bool DoModifierActiveActionSelectionUp();
 	bool DoModifierActiveActionSelectionDown();

+ 4 - 2
Resource.h

@@ -547,9 +547,11 @@
 #define IDC_STATIC_ACTIVE               2164
 #define IDC_MFCLINK1                    2165
 #define IDC_MFCLINK_CHAISCRIPT          2165
+#define IDC_MFCLINK_ENV_VAR             2165
 #define IDC_MFCLINK2_EXAMPLES           2166
 #define IDC_STATIC_MD5                  2167
 #define IDC_EDIT_MD5                    2168
+#define IDC_STATIC_ENV_VAR              2170
 #define ID_FIRST_OPTION                 32771
 #define ID_FIRST_EXIT                   32772
 #define ID_FIRST_SHOWQUICKPASTE         32773
@@ -719,9 +721,9 @@
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_3D_CONTROLS                     1
-#define _APS_NEXT_RESOURCE_VALUE        337
+#define _APS_NEXT_RESOURCE_VALUE        338
 #define _APS_NEXT_COMMAND_VALUE         32943
-#define _APS_NEXT_CONTROL_VALUE         2169
+#define _APS_NEXT_CONTROL_VALUE         2172
 #define _APS_NEXT_SYMED_VALUE           104
 #endif
 #endif

+ 95 - 1
SymbolEdit.cpp

@@ -5,6 +5,7 @@
 #include "SymbolEdit.h"
 #include "cp_main.h"
 #include "QListCtrl.h"
+#include "Shared\TextConvert.h"
 
 // CSymbolEdit
 
@@ -164,6 +165,59 @@ BOOL CSymbolEdit::PreTranslateMessage(MSG* pMsg)
 	return CEdit::PreTranslateMessage(pMsg);
 }
 
+CString CSymbolEdit::SavePastSearches()
+{
+	TiXmlDocument doc;
+
+	TiXmlElement* outer = new TiXmlElement("PastSearches");
+	doc.LinkEndChild(outer);
+
+	int count = m_searches.GetCount();
+	for (int i = 0; i < count; i++)
+	{		
+		TiXmlElement* searchElement = new TiXmlElement("Search");
+
+		CStringA t;
+		CTextConvert::ConvertToUTF8(m_searches[i], t);
+		searchElement->SetAttribute("text", t);
+
+		outer->LinkEndChild(searchElement);
+	}
+
+	TiXmlPrinter printer;
+	printer.SetLineBreak("");
+	doc.Accept(&printer);
+	CString cs = printer.CStr();
+
+	return cs;
+}
+
+void CSymbolEdit::LoadPastSearches(CString values)
+{
+	m_searches.RemoveAll();
+
+	TiXmlDocument doc;
+	CStringA xmlA;
+	CTextConvert::ConvertToUTF8(values, xmlA);
+	doc.Parse(xmlA);
+
+	TiXmlElement *ItemHeader = doc.FirstChildElement("PastSearches");
+
+	if (ItemHeader != NULL)
+	{
+		TiXmlElement *ItemElement = ItemHeader->FirstChildElement();
+
+		while (ItemElement)
+		{
+			CString item = ItemElement->Attribute("text");
+
+			m_searches.Add(item);
+
+			ItemElement = ItemElement->NextSiblingElement();
+		}
+	}
+}
+
 void CSymbolEdit::AddToSearchHistory()
 {
 	CString cs;
@@ -208,7 +262,28 @@ bool CSymbolEdit::ShowSearchHistoryMenu()
 	int count = min(m_searches.GetCount(), LIST_MAX_COUNT);
 	for (int i = count-1; i >= 0; i--)
 	{
-		cmPopUp.AppendMenuW(MF_STRING, (RANGE_START + i), m_searches[i]);
+		CString text = m_searches[i];
+
+		if (i == count - 1 &&
+			m_lastSearchShortCut.Key > 0)
+		{
+			CString cmdShortcutText = CHotKey::GetHotKeyDisplayStatic(m_lastSearchShortCut.Key);
+			if (m_lastSearchShortCut.Key2 != 0)
+			{
+				CString cmdShortcutText2 = CHotKey::GetHotKeyDisplayStatic(m_lastSearchShortCut.Key2);
+
+				if (cmdShortcutText2.GetLength() > 0)
+				{
+					cmdShortcutText += _T(" - ");
+					cmdShortcutText += cmdShortcutText2;
+				}
+			}
+
+			text += "\t";
+			text += cmdShortcutText;
+		}
+
+		cmPopUp.AppendMenuW(MF_STRING, (RANGE_START + i), text);
 	}
 
 	cmPopUp.AppendMenu(MF_SEPARATOR);
@@ -652,3 +727,22 @@ void CSymbolEdit::OnSelectSearchString(UINT idIn)
 		m_searches.Add(cs);
 	}
 }
+
+bool CSymbolEdit::ApplyLastSearch()
+{
+	bool ret = false;
+	if (m_searches.GetCount() > 0)
+	{
+		CString cs = m_searches[m_searches.GetCount()-1];
+		this->SetWindowTextW(cs);
+
+		this->SetFocus();
+		this->SetSel(-1);
+
+		this->Invalidate();
+
+		ret = true;
+	}
+
+	return ret;
+}

+ 10 - 0
SymbolEdit.h

@@ -27,6 +27,7 @@
 #pragma once
 
 #include "GdiImageDrawer.h"
+#include "Accels.h"
 
 // CSymbolEdit
 
@@ -63,6 +64,13 @@ public:
 	void SetPromptFont(CFont& font, BOOL redraw = TRUE);
 	void SetPromptFont(const LOGFONT* lpLogFont, BOOL redraw = TRUE);
 
+	bool ApplyLastSearch();
+
+	void SetLastSearchAccel(CAccel a) { m_lastSearchShortCut = a; }
+
+	CString SavePastSearches();
+	void LoadPastSearches(CString values);
+
 protected:
 	
 	//CGdiImageDrawer m_searchButton;
@@ -76,6 +84,8 @@ protected:
 	bool m_mouseDownOnSearches;
 	bool m_mouseHoveringOverSearches;
 
+	CAccel m_lastSearchShortCut;
+
 	CStringArray m_searches;
 
 	void RecalcLayout();