Author Topic: ThreadSearch 0.7 release  (Read 31967 times)

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: ThreadSearch 0.7 release
« Reply #30 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



[attachment deleted by admin]

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: ThreadSearch 0.7 release
« Reply #31 on: June 30, 2007, 06:14:47 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.

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.


I've been wondering about this too. I'll make good use of your patch too, rest assured

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #32 on: June 30, 2007, 06:19:52 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



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?


Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #33 on: June 30, 2007, 06:43:59 pm »
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: [Select]
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

ThreadSearch.H
Code: [Select]
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();
 };

ThreadSearch.cpp
Code: [Select]
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
« Last Edit: June 30, 2007, 09:28:36 pm by Pecan »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #34 on: June 30, 2007, 07:34:16 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.

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.
« Last Edit: June 30, 2007, 09:24:33 pm by Pecan »

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: ThreadSearch 0.7 release
« Reply #35 on: June 30, 2007, 09:47:16 pm »
@Pecan
Quote
My fault. I assumed an absolute temporary dir of "temp". Should have asked the system for the location of the trash directory.
I don't know if it is still necessary but this is my codesnippets.ini
Code: [Select]
ExternalEditor=Enter filename of external editor
SnippetFile=C:\\Documents and Settings\\Jerome\\Application Data\\codeblocks\\codesnippets.xml
ViewSearchBox=1
casesensitive=1
scope=2
SnippetFolder=Enter Snippets storage Folder
MouseDragSensitivity=8
MouseToLineRatio=30
MouseContextDelay=192
WindowState=External
WindowPosition=520 122 300 350
EditDlgXpos=235
EditDlgYpos=122
EditDlgWidth=500
EditDlgHeight=400
EditDlgMaximized=0

Note: on my XP, I have neither C:\temp nor C:\tmp directories.
I suppose you know it but if it is not the case... There are TEMP and TMP environment variables on Windows.
Both yield on my PC
Code: [Select]
C:\DOCUME~1\Jerome\LOCALS~1\Temp
I just replace External by Floating and it works.

Thanks for patch.
Do you think I should apply it or should it be fixed directly in C::B sources ?
Note that I can paste text in your code snippets text control, does the problem concern only combo boxes ?

Dje

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #36 on: June 30, 2007, 10:05:32 pm »

Thanks for patch.
Do you think I should apply it or should it be fixed directly in C::B sources ?
Note that I can paste text in your code snippets text control, does the problem concern only combo boxes ?

For the time being, I think you'll have to apply the patch to ThreadSearch.

I submitted a CB patch to correct this situation about a 1 1/2 years ago. But it just ended getting old and finally deleted.


This patch is written so that if the CB situation in main.cpp is ever corrected, this patch will still work anyway.

The problem affects ANY window or plugin that needs the use of copy/paste.

CodeSnippets et.al. have worked around this situation from the begining. I got so used to doing copy/paste this way that I forgot that it was a work-around.

That's why I didn't recognize the problem until tracing through it again. Hacks become algorithms.

 
« Last Edit: June 30, 2007, 10:16:56 pm by Pecan »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #37 on: June 30, 2007, 11:35:25 pm »
@Pecan
I was playing with code snippets when I found a bug :

Fixed: SVN 4200

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #38 on: July 01, 2007, 02:02:13 am »
Diffs to record and restore the position of the splitter sash accross CB runs.

ThreadSearchView.h
Code: [Select]
--- ThreadSearchview.h 2007-06-26 10:02:52.000000000 -0500
+++ ../ThreadSearchview.h 2007-06-30 19:11:38.718750000 -0500
@@ -87,6 +87,7 @@
  /** Sets the splitter window sash position.
    */
  void SetSashPosition(int position, const bool redraw = true) {m_pSplitter->SetSashPosition(position, redraw);}
+ int  GetSashPosition() { return m_pSplitter->GetSashPosition(); }


  /** PostThreadSearchEvent


ThreadSearch.h
Code: [Select]
--- ThreadSearch.h 2007-06-28 20:30:16.000000000 -0500
+++ ../ThreadSearch.h 2007-06-30 19:11:34.703125000 -0500
@@ -248,6 +249,9 @@
     bool                 m_ShowDirControls;           // True if user wants to display directory specific controls
     bool                 m_DisplayLogHeaders;
     bool                 m_DrawLogLines;
     bool                 b_OnReleased;
     wxComboBox*          m_pCboSearchExpr;
+    int                  m_SplitterPosn;               // position of splitter from config

  DECLARE_EVENT_TABLE();
 };


ThreadSearch.cpp
Code: [Select]
--- ThreadSearch.cpp 2007-06-28 21:12:28.000000000 -0500
+++ ../ThreadSearch.cpp 2007-06-30 19:11:57.968750000 -0500
@@ -102,8 +103,14 @@
  m_pThreadSearchView->SetSashPosition(x/2);
  m_pThreadSearchView->SetListColumns();

+    // Set the splitter posn from the config
+    if (m_SplitterPosn)
+        m_pThreadSearchView->SetSashPosition(m_SplitterPosn);
+
  // Shows/Hides search widgets on the Messages notebook ThreadSearch panel
  m_pThreadSearchView->ShowSearchControls(m_ShowSearchControls);

  b_OnReleased = false;
 }

 void ThreadSearch::OnRelease(bool appShutDown)
@@ -509,6 +510,9 @@

     m_FindData.SetSearchPath      (pCfg->Read    (wxT("/DirPath"),            wxEmptyString));
     m_FindData.SetSearchMask      (pCfg->Read    (wxT("/Mask"),               wxT("*.cpp;*.c;*.h")));
+
+    m_SplitterPosn               = pCfg->ReadInt(wxT("/SplitterPosn"),       0);
+
 }


@@ -490,6 +509,8 @@

     pCfg->Write(wxT("/DirPath"),            m_FindData.GetSearchPath());
     pCfg->Write(wxT("/Mask"),               m_FindData.GetSearchMask());
+
+    pCfg->Write(wxT("/SplitterPosn"),       m_pThreadSearchView->GetSashPosition() );
 }


« Last Edit: July 01, 2007, 02:10:04 am by Pecan »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #39 on: July 01, 2007, 03:56:14 pm »
I've run across a peculiar situation.

The ThreadSearch ToolBar and Log controls had been turned off.

I could find no other way to turn them back on except to edit default.conf.

What am I missing.

Edit: 2007/07/1

I figured it out. I had run  /src/output/codeblocks which did not have ThreadSearch installed.
It evidently saved the default.conf entries as 0.

When I went back to /src/devel/codeblocks, I found no way to turn the ThreadSearch controls back on.


« Last Edit: July 01, 2007, 03:59:13 pm by Pecan »

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: ThreadSearch 0.7 release
« Reply #40 on: July 01, 2007, 04:02:33 pm »
I'll add a confirmation pop-up.

You can reenable it with Settings/Environment... and ThreadSearch on the left column.
It displays then the configuration panel that allows you to display what you want.

Dje

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #41 on: July 01, 2007, 07:30:15 pm »
I'm having the following problems with the ThreadSearch Toolbar on Linux Ubuntu 7.04 wx263. Anyone else?




Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: ThreadSearch 0.7 release
« Reply #42 on: July 01, 2007, 07:39:59 pm »
I never saw that on my Ubuntu 6.10.
Maybe should I use a "real" size instead of wxDefaultSize...

EDIT : can you undock it and resize it ?

Dje
« Last Edit: July 01, 2007, 07:42:11 pm by dje »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #43 on: July 01, 2007, 08:49:33 pm »
I never saw that on my Ubuntu 6.10.
Maybe should I use a "real" size instead of wxDefaultSize...

EDIT : can you undock it and resize it ?

Dje

Here it is undocked and with the downArrow clicked.



Would you like me to change anything?
 
« Last Edit: July 01, 2007, 08:51:17 pm by Pecan »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2195
Re: ThreadSearch 0.7 release
« Reply #44 on: July 01, 2007, 09:37:37 pm »
Dje


http://www.savefile.com/files/856233


The above file contains ThreadSearch0.7 source containing the mods I've made along with mods for update.bat, ThreadSearch.cbp and ThreadSearch-unix.cbp



« Last Edit: July 01, 2007, 10:39:29 pm by Pecan »