News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

ThreadSearch 0.7 release

Started by dje, June 29, 2007, 12:00:41 AM

Previous topic - Next topic

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.

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
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

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



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

#33
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

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

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

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

Pecan

#34
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.

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.

dje

@Pecan
QuoteMy 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
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
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

Pecan

#36
Quote from: dje on June 30, 2007, 09:47:16 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.



Pecan

Quote from: dje on June 30, 2007, 06:13:27 PM
@Pecan
I was playing with code snippets when I found a bug :

Fixed: SVN 4200

Pecan

#38
Diffs to record and restore the position of the splitter sash accross CB runs.

ThreadSearchView.h

--- 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

--- 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

--- 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() );
}




Pecan

#39
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.



dje

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

Pecan

I'm having the following problems with the ThreadSearch Toolbar on Linux Ubuntu 7.04 wx263. Anyone else?




dje

#42
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

Pecan

#43
Quote from: dje 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

Here it is undocked and with the downArrow clicked.



Would you like me to change anything?

Pecan

#44
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