← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2441: Repurpose Ctrl+F to in-place searches in chat windows & file lists

 

------------------------------------------------------------
revno: 2441
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Fri 2011-02-25 17:41:03 +0100
message:
  Repurpose Ctrl+F to in-place searches in chat windows & file lists
modified:
  changelog.txt
  help/keyboard_commands.html
  win32/AspectChat.h
  win32/DirectoryListingFrame.cpp
  win32/HubFrame.cpp
  win32/MainWindow.cpp
  win32/RichTextBox.cpp
  win32/RichTextBox.h
  win32/WinUtil.cpp


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt	2011-02-21 19:48:45 +0000
+++ changelog.txt	2011-02-25 16:41:03 +0000
@@ -13,6 +13,7 @@
 * Highlight window splitters on mouse hover (poy)
 * Continue from the beginning after reaching the end of a file list when searching (poy)
 * Report the progress of file list searches in the status bar (poy)
+* Repurpose Ctrl+F to in-place searches in chat windows & file lists (poy)
 
 -- 0.781 2011-01-12 --
 * Add a dummy serial number to TLS certs to satisfy some parsers (poy)

=== modified file 'help/keyboard_commands.html'
--- help/keyboard_commands.html	2010-02-06 19:38:21 +0000
+++ help/keyboard_commands.html	2011-02-25 16:41:03 +0000
@@ -31,10 +31,14 @@
   <dt>F5</dt>
   <dt>Ctrl + E</dt>
   <dd>Refresh file list.</dd>
-  <dt>Ctrl + F</dt>
-  <dd>Open the <placeholder><a href="window_favorite_hubs.html">Favorite Hubs</a></placeholder> window.</dd>
+  <dt>F3</dt>
+  <dt>Ctrl + F<dt>
+  <dd>In-place search within the chat of <placeholder><a href="window_hub.html">Hub</a></placeholder> and <placeholder><a href="window_pm.html">Private Message</a></placeholder> windows and in <placeholder><a href="window_file_list.html">File List</a></placeholder> windows.<br/>
+  <b>F3</b> continues the previous search or initiates one if no search term has yet been defined. On the other hand, <b>Ctrl + F</b> always initiates a new search.
   <dt>Ctrl + G</dt>
   <dd>Quick connect to a group of favorite hubs.</dd>
+  <dt>Ctrl + H</dt>
+  <dd>Open the <placeholder><a href="window_favorite_hubs.html">Favorite Hubs</a></placeholder> window.</dd>
   <dt>Ctrl + N</dt>
   <dd>Open the <placeholder><a href="window_notepad.html">Notepad</a></placeholder> window.</dd>
   <dt>Ctrl + L</dt>
@@ -74,8 +78,6 @@
   <dd>Send chat message.</dd>
   <dt>Alt + U (in <placeholder><a href="window_hub.html">Hub</a></placeholder> windows)</dt>
   <dd>Focus the user list.</dd>
-  <dt>F3 (in <placeholder><a href="window_hub.html">Hub</a></placeholder> and <placeholder><a href="window_pm.html">Private Message</a></placeholder> windows)</dt>
-  <dd>Search in the chat.</dd>
   <dt>Escape (in <placeholder><a href="window_hub.html">Hub</a></placeholder> and <placeholder><a href="window_pm.html">Private Message</a></placeholder> windows)</dt>
   <dd>
   <div>Focus the message writing box of the window.</div>

=== modified file 'win32/AspectChat.h'
--- win32/AspectChat.h	2011-01-09 22:09:24 +0000
+++ win32/AspectChat.h	2011-02-25 16:41:03 +0000
@@ -58,7 +58,8 @@
 		t().addAccel(FALT, 'M', std::bind(&dwt::Control::setFocus, message));
 		t().addAccel(FALT, 'S', std::bind(&ThisType::sendMessage_, this));
 		t().addAccel(0, VK_ESCAPE, std::bind(&ThisType::handleEscape, this));
-		t().addAccel(0, VK_F3, std::bind(&RichTextBox::findTextNext, chat));
+		t().addAccel(FCONTROL, 'F', [this] { chat->findTextNew(); });
+		t().addAccel(0, VK_F3, [this] { chat->findTextNext(); });
 	}
 
 	virtual ~AspectChat() { }
@@ -127,6 +128,10 @@
 				chat->setSelection();
 				chat->replaceSelection(_T(""));
 			}
+
+		} else if(Util::stricmp(cmd.c_str(), _T("f")) == 0) {
+			chat->findText(param.empty() ? chat->findTextPopup() : param);
+
 		} else if(Util::stricmp(cmd.c_str(), _T("ts")) == 0) {
 			timeStamps = !timeStamps;
 			if(timeStamps) {
@@ -134,6 +139,7 @@
 			} else {
 				status = T_("Timestamps disabled");
 			}
+
 		} else {
 			return false;
 		}

=== modified file 'win32/DirectoryListingFrame.cpp'
--- win32/DirectoryListingFrame.cpp	2011-02-21 19:48:45 +0000
+++ win32/DirectoryListingFrame.cpp	2011-02-25 16:41:03 +0000
@@ -183,7 +183,7 @@
 }
 
 DirectoryListingFrame::DirectoryListingFrame(TabViewPtr parent, const HintedUser& aUser, int64_t aSpeed) :
-	BaseType(parent, _T(""), IDH_FILE_LIST, IDI_DIRECTORY),
+	BaseType(parent, _T(""), IDH_FILE_LIST, IDI_DIRECTORY, false),
 	rebar(0),
 	pathBox(0),
 	grid(0),
@@ -335,6 +335,10 @@
 	ClientManager::getInstance()->addListener(this);
 	updateTitle();
 
+	addAccel(FCONTROL, 'F', [this] { if(searchGrid->getEnabled()) searchBox->setFocus(); else handleFindToggle(); });
+	addAccel(0, VK_F3, [this] { if(searchGrid->getEnabled()) handleFind(false); else handleFindToggle(); });
+	initAccels();
+
 	layout();
 
 	lists.insert(std::make_pair(aUser, this));

=== modified file 'win32/HubFrame.cpp'
--- win32/HubFrame.cpp	2011-02-25 11:49:51 +0000
+++ win32/HubFrame.cpp	2011-02-25 16:41:03 +0000
@@ -395,13 +395,8 @@
 				openLog();
 			else if(Util::stricmp(param.c_str(), _T("status")) == 0)
 				openLog(true);
-		} else if(Util::stricmp(cmd.c_str(), _T("f")) == 0) {
-			if(param.empty())
-				param = chat->findTextPopup();
-
-			chat->findText(param);
 		} else if(Util::stricmp(cmd.c_str(), _T("help")) == 0) {
-			addChat(_T("*** ") + WinUtil::commands + _T(", /join <hub-ip>, /showjoins, /favshowjoins, /close, /userlist, /connection, /favorite, /pm <user> [message], /getlist <user>, /log <status, system, downloads, uploads>, /removefavorite, /f <text-to-find>"));
+			addChat(_T("*** ") + WinUtil::commands + _T(", /join <hub-ip>, /showjoins, /favshowjoins, /close, /userlist, /connection, /favorite, /pm <user> [message], /getlist <user>, /log <status, system, downloads, uploads>, /removefavorite"));
 		} else if(Util::stricmp(cmd.c_str(), _T("pm")) == 0) {
 			string::size_type j = param.find(_T(' '));
 			if(j != string::npos) {

=== modified file 'win32/MainWindow.cpp'
--- win32/MainWindow.cpp	2011-02-19 17:03:15 +0000
+++ win32/MainWindow.cpp	2011-02-25 16:41:03 +0000
@@ -118,21 +118,21 @@
 	initTransfers();
 	initTray();
 
-	addAccel(FCONTROL, '1', std::bind(&MainWindow::switchToolbar, this));
-	addAccel(FCONTROL, '2', std::bind(&MainWindow::switchTransfers, this));
-	addAccel(FCONTROL, '3', std::bind(&MainWindow::switchStatus, this));
+	addAccel(FCONTROL, '1', [this] { switchToolbar(); });
+	addAccel(FCONTROL, '2', [this] { switchTransfers(); });
+	addAccel(FCONTROL, '3', [this] { switchStatus(); });
 	addAccel(FCONTROL, 'D', [this] { QueueFrame::openWindow(getTabView()); });
-	addAccel(FCONTROL, 'E', std::bind(&MainWindow::handleRefreshFileList, this));
-	addAccel(FCONTROL, 'F', [this] { FavHubsFrame::openWindow(getTabView()); });
-	addAccel(FCONTROL, 'G', std::bind(&MainWindow::handleConnectFavHubGroup, this));
-	addAccel(FCONTROL, 'L', std::bind(&MainWindow::handleOpenFileList, this));
+	addAccel(FCONTROL, 'E', [this] { handleRefreshFileList(); });
+	addAccel(FCONTROL, 'G', [this] { handleConnectFavHubGroup(); });
+	addAccel(FCONTROL, 'H', [this] { FavHubsFrame::openWindow(getTabView()); });
+	addAccel(FCONTROL, 'L', [this] { handleOpenFileList(); });
 	addAccel(FCONTROL, 'N', [this] { NotepadFrame::openWindow(getTabView()); });
 	addAccel(FCONTROL, 'P', [this] { PublicHubsFrame::openWindow(getTabView()); });
-	addAccel(FCONTROL, 'Q', std::bind(&MainWindow::handleQuickConnect, this));
+	addAccel(FCONTROL, 'Q', [this] { handleQuickConnect(); });
 	addAccel(FCONTROL, 'S', [this] { SearchFrame::openWindow(getTabView()); });
 	addAccel(FCONTROL, 'U', [this] { UsersFrame::openWindow(getTabView()); });
-	addAccel(FCONTROL, VK_F3, std::bind(&MainWindow::handleSettings, this));
-	addAccel(0, VK_F5, std::bind(&MainWindow::handleRefreshFileList, this));
+	addAccel(FCONTROL, VK_F3, [this] { handleSettings(); });
+	addAccel(0, VK_F5, [this] { handleRefreshFileList(); });
 	initAccels();
 
 	onActivate(std::bind(&MainWindow::handleActivate, this, _1));
@@ -261,7 +261,7 @@
 
 		viewIndexes[PublicHubsFrame::id] = viewMenu->appendItem(T_("&Public Hubs\tCtrl+P"),
 			[this] { PublicHubsFrame::openWindow(getTabView()); }, WinUtil::menuIcon(IDI_PUBLICHUBS));
-		viewIndexes[FavHubsFrame::id] = viewMenu->appendItem(T_("&Favorite Hubs\tCtrl+F"),
+		viewIndexes[FavHubsFrame::id] = viewMenu->appendItem(T_("&Favorite Hubs\tCtrl+H"),
 			[this] { FavHubsFrame::openWindow(getTabView()); }, WinUtil::menuIcon(IDI_FAVORITE_HUBS));
 		viewIndexes[UsersFrame::id] = viewMenu->appendItem(T_("&Users\tCtrl+U"),
 			[this] { UsersFrame::openWindow(getTabView()); }, WinUtil::menuIcon(IDI_FAVORITE_USERS));

=== modified file 'win32/RichTextBox.cpp'
--- win32/RichTextBox.cpp	2011-01-02 17:12:02 +0000
+++ win32/RichTextBox.cpp	2011-02-25 16:41:03 +0000
@@ -62,11 +62,29 @@
 	MenuPtr menu = BaseType::getMenu();
 
 	menu->appendSeparator();
-	menu->appendItem(T_("&Find...\tF3"), [this]() { GCC_WTF->findText(this->findTextPopup()); }, dwt::IconPtr(), !getText().empty());
+	menu->appendItem(T_("&Find...\tCtrl+F"), [this] { findTextNew(); }, dwt::IconPtr(), !getText().empty());
+	menu->appendItem(T_("&Find Next\tF3"), [this] { findTextNext(); }, dwt::IconPtr(), !getText().empty());
 
 	return menu;
 }
 
+tstring RichTextBox::findTextPopup() {
+	tstring param = Util::emptyStringT;
+	ParamDlg lineFind(this, T_("Search"), T_("Specify search string"), Util::emptyStringT, false);
+	if(lineFind.run() == IDOK) {
+		param = lineFind.getValue();
+	}
+	return param;
+}
+
+void RichTextBox::findTextNew() {
+	findText(findTextPopup());
+}
+
+void RichTextBox::findTextNext() {
+	findText(currentNeedle.empty() ? findTextPopup() : currentNeedle);
+}
+
 bool RichTextBox::handleKeyDown(int c) {
 	switch(c) {
 	case VK_F3:
@@ -80,16 +98,3 @@
 	}
 	return false;
 }
-
-tstring RichTextBox::findTextPopup() {
-	tstring param = Util::emptyStringT;
-	ParamDlg lineFind(this, T_("Search"), T_("Specify search string"), Util::emptyStringT, false);
-	if(lineFind.run() == IDOK) {
-		param = lineFind.getValue();
-	}
-	return param;
-}
-
-void RichTextBox::findTextNext() {
-	findText(currentNeedle.empty() ? findTextPopup() : currentNeedle);
-}

=== modified file 'win32/RichTextBox.h'
--- win32/RichTextBox.h	2011-01-02 17:12:02 +0000
+++ win32/RichTextBox.h	2011-02-25 16:41:03 +0000
@@ -41,11 +41,11 @@
 	MenuPtr getMenu();
 
 	tstring findTextPopup();
+	void findTextNew();
 	void findTextNext();
 
 private:
 	bool handleKeyDown(int c);
-	void handleFind();
 };
 
 typedef RichTextBox::ObjectType RichTextBoxPtr;

=== modified file 'win32/WinUtil.cpp'
--- win32/WinUtil.cpp	2011-02-19 17:03:15 +0000
+++ win32/WinUtil.cpp	2011-02-25 16:41:03 +0000
@@ -439,7 +439,7 @@
 
 tstring
 	WinUtil::commands =
-		_T("/refresh, /me <msg>, /clear [lines to keep], /slots #, /dslots #, /search <string>, /dc++, /away <msg>, /back, /g <searchstring>, /imdb <imdbquery>, /u <url>, /rebuild, /ts, /download, /upload");
+		_T("/refresh, /me <msg>, /clear [lines to keep], /slots #, /dslots #, /search <string>, /f <string>, /dc++, /away <msg>, /back, /g <searchstring>, /imdb <imdbquery>, /u <url>, /rebuild, /ts, /download, /upload");
 
 bool WinUtil::checkCommand(tstring& cmd, tstring& param, tstring& message, tstring& status, bool& thirdPerson) {
 	string::size_type i = cmd.find(' ');