Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
ThreadSearch 0.7 release
dje:
@Pecan
Nice work :)
What would be a developer without copy/paste ??
Little parenthesis
I was playing with code snippets when I found a bug :
* I created a snippet (test was its name :))
* I clicked on its properties
* I chose a link target to a cpp file
* I opened it
* I right click on the root/settings
* I selected the external option and validated
* I reopen the snippet to see if there was a difference
* I clicked on View/Code snippets twice
* I systematically have the snapshot error
There must be an error because I can't use code snippets any more both in nightlies and SVN environments.
I'll reset my default.conf and see if it is systematic and if I can reduce number of steps.
Dje
[attachment deleted by admin]
dmoore:
--- Quote from: Pecan on June 30, 2007, 05:34:18 pm ---
--- Quote from: dje on June 30, 2007, 03:34:42 pm ---
I confirm the paste bug. The same happens with copy from the preview editor.
It does not work anymore with keyboard shortcuts but works with contextual menus.
EDIT: Paste works with default target (nightly build environment) but not with DevDebug target (debug development environment).
EDIT: Copy from preview editor does not works (whereas it did).
This is a regression but I don't see at first glance where it comes from.
--- End quote ---
I've found the casue of the copy/paste bug. And am working up a fix for it now.
It's a bug in the way CB main.cpp handles the clipboard/copy/paste events. It always thinks the paste is for the current editor even when the editor DOES NOT have the focus.
Edit: I've tested the work-around and will paste a diff.
--- End quote ---
I've been wondering about this too. I'll make good use of your patch too, rest assured
Pecan:
--- Quote from: dje on June 30, 2007, 06:13:27 pm ---@Pecan
Nice work :)
What would be a developer without copy/paste ??
Little parenthesis
I was playing with code snippets when I found a bug :
* I created a snippet (test was its name :))
* I clicked on its properties
* I chose a link target to a cpp file
* I opened it
* I right click on the root/settings
* I selected the external option and validated
* I reopen the snippet to see if there was a difference
* I clicked on View/Code snippets twice
* I systematically have the snapshot error
There must be an error because I can't use code snippets any more both in nightlies and SVN environments.
I'll reset my default.conf and see if it is systematic and if I can reduce number of steps.
Dje
--- End quote ---
CodeSnippets does not keep data in .conf. It's in codesnippets.ini in the data folder.
Would you translate that whole error message for me please.
Also, show me what's in codesnippets.ini
What OS and wxWidgets version?
Pecan:
Here are the diffs to work around the copy/paste bug in CB main.cpp and allow correct pasting in ThreadSearch.
However, it still will not allow the CB menu, menu hotkeys, or the toolbar icons to be used for copy paste because main.cpp is disabling those in its UpdateUI routine if the focus is not on an editor.
It will, however, allow Ctrl-C and Ctrl-V to work correctly.
ThreadSearchView.h
--- Code: ---c:\Usr\Proj\ThreadSearch\ThreadSearch7>C:\Usr\bin\GnuWin32\bin\diff.exe -u --strip-trailing-cr ThreadSearchView.h ..
--- ThreadSearchView.h 2007-06-26 10:02:52.000000000 -0500
+++ ../ThreadSearchView.h 2007-06-30 11:27:19.390625000 -0500
@@ -40,6 +40,8 @@
class ThreadSearchThread;
class ThreadSearchView: public MessageLog {
+
+ friend class ThreadSearch;
public:
// begin wxGlade: ThreadSearchView::ids
// end wxGlade
--- End code ---
ThreadSearch.H
--- Code: ---c:\Usr\Proj\ThreadSearch\ThreadSearch7>C:\Usr\bin\GnuWin32\bin\diff.exe -u --strip-trailing-cr ThreadSearch.h ..
--- ThreadSearch.h 2007-06-28 20:30:16.000000000 -0500
+++ ../ThreadSearch.h 2007-06-30 11:11:56.515625000 -0500
@@ -233,6 +233,8 @@
* the 'Find implementation' item if possible
*/
int GetInsertionMenuIndex(const wxMenu* const pCtxMenu);
+ void OnEditPaste(wxCommandEvent& event);
+
// Member variables
wxString m_SearchedWord; // Word under cursor on right click
@@ -247,6 +249,8 @@
bool m_ShowDirControls; // True if user wants to display directory specific controls
bool m_DisplayLogHeaders;
bool m_DrawLogLines;
+ bool b_OnReleased;
+ wxComboBox* m_pCboSearchExpr;
DECLARE_EVENT_TABLE();
};
--- End code ---
ThreadSearch.cpp
--- Code: ---c:\Usr\Proj\ThreadSearch\ThreadSearch7>C:\Usr\bin\GnuWin32\bin\diff.exe -u --strip-trailing-cr ThreadSearch.cpp ..
--- ThreadSearch.cpp 2007-06-28 21:12:28.000000000 -0500
+++ ../ThreadSearch.cpp 2007-06-30 12:13:47.640625000 -0500
@@ -18,6 +18,7 @@
#include <configurationpanel.h>
#include <editor_hooks.h>
#include <wx/wxFlatNotebook/wxFlatNotebook.h>
+#include <wx/clipbrd.h>
#include "ThreadSearch.h"
#include "ThreadSearchConfPanel.h"
@@ -32,6 +33,7 @@
PluginRegistrant<ThreadSearch> reg(_T("ThreadSearch"));
}
+int idEditPaste = XRCID("idEditPaste");
// events handling
BEGIN_EVENT_TABLE(ThreadSearch, cbPlugin)
@@ -44,6 +46,8 @@
EVT_BUTTON (idBtnOptions, ThreadSearch::OnBtnOptionsClick)
EVT_BUTTON (idBtnSearch, ThreadSearch::OnBtnSearchClick)
EVT_TEXT_ENTER(idCboSearchExpr, ThreadSearch::OnCboSearchExprEnter)
+ EVT_TEXT (idCboSearchExpr, ThreadSearch::OnCboSearchExprEnter)
+ EVT_MENU (idEditPaste, ThreadSearch::OnEditPaste)
END_EVENT_TABLE()
// constructor
@@ -57,7 +61,8 @@
m_ShowSearchControls(true),
m_ShowDirControls(false),
m_DisplayLogHeaders(true),
- m_DrawLogLines(false)
+ m_DrawLogLines(false),
+ m_pCboSearchExpr(0)
{
// Make sure our resources are available.
// In the generated boilerplate code we have no resources but when
@@ -99,6 +104,8 @@
// Shows/Hides search widgets on the Messages notebook ThreadSearch panel
m_pThreadSearchView->ShowSearchControls(m_ShowSearchControls);
+
+ b_OnReleased = false;
}
void ThreadSearch::OnRelease(bool appShutDown)
@@ -109,6 +116,12 @@
// NOTE: after this function, the inherited member variable
// m_IsAttached will be FALSE...
+ // --------------------------------------------------------------
+ // Carefull! This routine can be entered consecutive times
+ // --------------------------------------------------------------
+ if ( b_OnReleased ) return;
+ b_OnReleased = true;
+
// Removes Thread search menu item from the View menu
RemoveMenuItems();
@@ -594,7 +606,8 @@
// Runs a multi threaded search with combo text
wxComboBox* pCboBox = static_cast<wxComboBox*>(m_pToolbar->FindControl(idCboSearchExpr));
wxASSERT(pCboBox != NULL);
- RunThreadSearch(pCboBox->GetValue());
+ if ( event.GetEventType() == wxEVT_COMMAND_TEXT_ENTER )
+ RunThreadSearch(pCboBox->GetValue());
}
@@ -648,3 +661,75 @@
return wordFound;
}
+// ----------------------------------------------------------------------------
+void ThreadSearch::OnEditPaste(wxCommandEvent& event)
+// ----------------------------------------------------------------------------
+{
+ // Process clipboard data only if we have the focus
+
+ // ----------------------------------------------------------------
+ // NB: A bug in CB main.cpp causes a ctrl-v to always paste into the
+ // current editor. Here, we'll make checks to see if the paste
+ // is for our search combo boxes and paste the data there.
+ // If the focused window is one of ours that shouldn't get pasted
+ // data, we'll simply ignore it.
+ // If the window isn't one of ours, we'll event.Skip();
+ // ----------------------------------------------------------------
+
+ if ( !IsAttached() )
+ { event.Skip(); return; }
+
+ if (not m_IsAttached) {event.Skip(); return;}
+
+ wxWindow* pFocused = wxWindow::FindFocus();
+ if (not pFocused) { event.Skip(); return; }
+
+ wxString focusedStr = pFocused->GetName();
+ //DBGLOG(wxT("OnEditPaste:Focused[%p][%s]"), pFocused, focusedStr.c_str());
+
+ // don't allow paste when the following windows have the focus
+ if ( ( pFocused == m_pThreadSearchView->m_pSearchPreview )
+ || ( pFocused == m_pThreadSearchView->m_pListLog ) )
+ { return; }
+ if ( pFocused == m_pThreadSearchView->m_pListLog->GetListControl())
+ return;
+
+ // if the following window have the focus, own the paste.
+ if ( (pFocused != m_pCboSearchExpr)
+ && (pFocused != m_pThreadSearchView->m_pCboSearchExpr) )
+ { event.Skip(); return;}
+
+ if ( not wxTheClipboard->Open() )
+ {
+ //DBGLOG( wxT("ThreadSearch::OnPaste Can't open clipboard.") );
+ event.Skip();
+ return;
+ }
+ // -- Text Processing ----------------------------------------------------
+ if ( not wxTheClipboard->IsSupported(wxDF_TEXT) )
+ {
+ //DBGLOG( wxT("ThreadSearch::OnPaste:No text data on clipboard") );
+ wxTheClipboard->Close();
+ event.Skip();
+ return;
+ }
+
+ wxTextDataObject text;
+ if ( not wxTheClipboard->GetData(text) ) {
+ //DBGLOG( wxT("ThreadSearch::OnPaste:Can't get text from the clipboard") );
+ }
+ else { // Put text in search wxComboBoxes
+ wxString str = text.GetText();
+ // stuff the search boxes
+ if (pFocused == m_pCboSearchExpr)
+ m_pCboSearchExpr->SetValue(str);
+ if (pFocused == m_pThreadSearchView->m_pCboSearchExpr)
+ m_pThreadSearchView->m_pCboSearchExpr->SetValue(str);
+ }
+
+ wxTheClipboard->Close();
+ // If you Skip(), CB main.cpp will wrongly paste your text into the current editor
+ // because CB main.cpp thinks it owns the clipboard.
+ //- event.Skip();
+ return; //own the event
+}//OnEditPaste
--- End code ---
Pecan:
--- Quote from: dje on June 30, 2007, 06:13:27 pm ---@Pecan
There must be an [CodeSnippets] error because I can't use code snippets any more both in nightlies and SVN environments.
I'll reset my default.conf and see if it is systematic and if I can reduce number of steps.
--- End quote ---
It appears that external CodeSnippets is trying to create the memory mapped file to communicate with CB, and can't allocate the file.
Is your /temp full or unwrittable?
What does "le chemin d'acces specific est introuvable" mean?
Anyway to get it running again, edit your codesnippet.ini and change
WindowState=External
to
WindowState=Floating
or
WindowState=Docked
This does mean I should check the directory for usability before trying to create the memory mapped file.
Thanks for the report.
EDIT: 2007/06/30
My fault. I assumed an absolute temporary dir of "temp". Should have asked the system for the location of the trash directory.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version