Author Topic: ThreadSearch plugin is born !  (Read 23509 times)

Offline jomeggs

  • Multiple posting newcomer
  • *
  • Posts: 92
Re: ThreadSearch plugin is born !
« Reply #15 on: March 14, 2007, 11:57:29 am »
The "ThreadSearch" plugin offers the following features:
  • multi-threaded "Search in files"
  • preview of the results (left single click on log window)
  • file open (left double click on log window)
  • check boxes instead of radio boxes to allow searches with both project and directories for example.
  • contextual menu "Find occurrences" to start a search in files with the word under cursor (can be activated or not)

Looks fine! There is only one feature missed... :D
  • group search results by file

Best regards,
jomeggs

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: ThreadSearch plugin is born !
« Reply #16 on: March 14, 2007, 01:16:33 pm »
Quote
Please make the mini editors at least read-only
That's the case.
For know I use a cbStyledTextCtrl that allows what I use.
To be writable, it would be better to use a cbEditor, what is impossible today due to the several interactions between cbEditor/ProjectManager/wxFlatNotebook.
Make the Code preview writable is not planned for today.

Quote
group search results by file
I'm not sure to understand clearly what you mean, make column header clickable to sort the log items ?

Dje

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: ThreadSearch plugin is born !
« Reply #17 on: March 14, 2007, 01:20:32 pm »
Quote
Please make the mini editors at least read-only
That's the case. [...] Make the Code preview writable is not planned for today.
Again: Great... keep it that way. ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: ThreadSearch plugin is born !
« Reply #18 on: March 14, 2007, 02:12:52 pm »
Quote
Please make the mini editors at least read-only
That's the case.
For know I use a cbStyledTextCtrl that allows what I use.
To be writable, it would be better to use a cbEditor, what is impossible today due to the several interactions between cbEditor/ProjectManager/wxFlatNotebook.
Make the Code preview writable is not planned for today.

Although I agree that it should be read-only, still you could make it writable if you insisted, with minimal fuss.
The key is to use scintilla's document pointers. It's just one line of code for you to add:
Code: [Select]
your_control->SetDocPointer(open_cbeditor->GetDocPointer())
These are refcounted and should pose no problem. The only issue I see is that if a cbEditor is not open when previewing your search results you should then watch for EDITOR_OPEN events and if you see that an internal editor opens with the same file, then "attach" the docpointer again so that you use the one and same internal buffer.

Once again: I don't think that making it writable is a good idea. I 'm just writing this so you learn something new (if you didn't know already).
Be patient!
This bug will be fixed soon...

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2165
Re: ThreadSearch plugin is born !
« Reply #19 on: March 14, 2007, 02:15:40 pm »
I must be overlooking something. I was going to compile ThreadSearch under Linux but cannot find the source.

Could you give us a link to the source, and I'll run it through andLinux.

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: ThreadSearch plugin is born !
« Reply #20 on: March 14, 2007, 03:00:00 pm »
My source code is in the ThreadSearch.zip zip.
Just extract it to the <...>\codeblocks\src\plugins\contrib directory.

You will notice there is no LINUX/UNIX project.
Have a look at the linker settings.
To use it in my SVN environment, I use the generated static libs.
To use it with a nightly, I link directly with the corresponding dlls.
If I do not respect these rules, plugin install fails; I suspect the link because I didn't apply C::B team wxWidgets patch for menu alignement in my development environment.


Quote
I don't think that making it writable is a good idea.
I agree. In my opinion, it is just a previewer, not an editor. The code preview is not there to fill the need of editors splitting/cascading.

Dje

Offline jomeggs

  • Multiple posting newcomer
  • *
  • Posts: 92
Re: ThreadSearch plugin is born !
« Reply #21 on: March 14, 2007, 03:00:56 pm »
I'm not sure to understand clearly what you mean, make column header clickable to sort the log items ?

No, i am referring to gather the search results in a treeview. Each file is a root node, the single search results are subitems of these root nodes.


Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: ThreadSearch plugin is born !
« Reply #22 on: March 14, 2007, 04:28:40 pm »
Quote
No, i am referring to gather the search results in a treeview.
I see now...
I keep it in mind but I have already planned changes before.

Thanks for the idea !

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2165
Re: ThreadSearch plugin is born !
« Reply #23 on: March 14, 2007, 05:41:19 pm »
Under Linux, the following statements get error:
Does anyone know how to fix this?



Code: [Select]
-------------- Build: default in ThreadSearch-Lunix ---------------
g++-4.0 -Wall `pkg-config --cflags codeblocks` `wx-config --cflags` -g  -I/home/pecan/devel/trunk/src/include -I/usr/include -I/home/pecan/devel/trunk/src/include/wxFlatNotebook/include -I/home/pecan/devel/trunk/src/include/wxscintilla/include -I/usr/include  -c /mnt/e/linux/proj/ThreadSearch/ThreadSearch.cpp -o .objs/ThreadSearch.o
Package codeblocks was not found in the pkg-config search path.
Perhaps you should add the directory containing `codeblocks.pc'
to the PKG_CONFIG_PATH environment variable
No package 'codeblocks' found
/mnt/e/linux/proj/ThreadSearch/ThreadSearchEvent.h:48: error: ISO C++ forbids declaration of '__declspec' with no type
/mnt/e/linux/proj/ThreadSearch/ThreadSearchEvent.h:48: warning: '__declspec' initialized and declared 'extern'
/mnt/e/linux/proj/ThreadSearch/ThreadSearchEvent.h:48: error: 'dllexport' was not declared in this scope


Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: ThreadSearch plugin is born !
« Reply #24 on: March 14, 2007, 06:38:14 pm »
Hi !

I found info on the net.
You need to use __declspec(dllimport/dllexport) on windows to import/export symbol from/to a dll.
On Linux, it seems that nothing is required.

I'll define or use a set of macro to differentiate the OSs.

I'll update it today.

Dje

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2165
Re: ThreadSearch plugin is born !
« Reply #25 on: March 14, 2007, 08:10:30 pm »
Here's what I came up with to get it to compile under Linux.


Code: [Select]
diff -u C:\Usr\Proj\ThreadSearch/ThreadSearch.cpp e:\linux\proj\ThreadSearch/ThreadSearch.cpp
--- C:\Usr\Proj\ThreadSearch/ThreadSearch.cpp 2007-02-20 22:54:02.000000000 -0500
+++ e:\linux\proj\ThreadSearch/ThreadSearch.cpp 2007-03-14 13:04:36.000000000 -0500
@@ -17,6 +17,11 @@
 #include "ThreadSearchConfPanel.h"
 #include "ThreadSearchControlIds.h"

+//Missing headers //(pecan 2007/3/14)
+#include "messagemanager.h"
+#include "configmanager.h"
+#include "sdk_events.h"
+
 class wxFlatNotebook;

 // Register the plugin with Code::Blocks.
Files C:\Usr\Proj\ThreadSearch/ThreadSearch.zip and e:\linux\proj\ThreadSearch/ThreadSearch.zip differ
diff -u C:\Usr\Proj\ThreadSearch/ThreadSearchEvent.h e:\linux\proj\ThreadSearch/ThreadSearchEvent.h
--- C:\Usr\Proj\ThreadSearch/ThreadSearchEvent.h 2007-03-11 10:17:34.000000000 -0500
+++ e:\linux\proj\ThreadSearch/ThreadSearchEvent.h 2007-03-14 12:49:58.000000000 -0500
@@ -19,6 +19,26 @@
 #include <wx/event.h>
 #include <wx/arrstr.h>

+//(pecan 2007/3/14)
+#if defined(__WXGTK__)
+    #ifdef _MSC_VER
+      #ifdef BUILDING_DLL
+        #define DLLEXPORT __declspec(dllexport)
+      #else
+        #define DLLEXPORT __declspec(dllimport)
+      #endif
+      #define DLLLOCAL
+    #else
+      #ifdef HAVE_GCCVISIBILITYPATCH
+        #define DLLEXPORT __attribute__ ((visibility("default")))
+        #define DLLLOCAL __attribute__ ((visibility("hidden")))
+      #else
+        #define DLLEXPORT
+        #define DLLLOCAL
+      #endif
+    #endif
+#endif
+
 class ThreadSearchEvent : public wxCommandEvent
 {
 public:
@@ -45,7 +65,9 @@
 typedef void (wxEvtHandler::*ThreadSearchEventFunction)(ThreadSearchEvent&);

 BEGIN_DECLARE_EVENT_TYPES()
- DECLARE_EXPORTED_EVENT_TYPE(__declspec(dllexport), wxEVT_THREAD_SEARCH, wxID_ANY)
+    //(pecan 2007/3/14)
+ //DECLARE_EXPORTED_EVENT_TYPE(__declspec(dllexport), wxEVT_THREAD_SEARCH, wxID_ANY)
+ DECLARE_EXPORTED_EVENT_TYPE(DLLEXPORT, wxEVT_THREAD_SEARCH, wxID_ANY)
 END_DECLARE_EVENT_TYPES()

 #define EVT_THREAD_SEARCH(id, fn) \

However, it must not be right, because the layout gets screwed up when I resize CB. Sometimes the menu completely disappears. I think it's not getting its events.

When I enter a search string into the search textCtrl, it doesn't do anything.

« Last Edit: March 14, 2007, 08:13:01 pm by Pecan »

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: ThreadSearch plugin is born !
« Reply #26 on: March 14, 2007, 10:49:17 pm »
Pecan,
I found the magical macro in wxWidgets dlimpexp.h :
WXEXPORT
All OSs are managed.

Why do you speak of missing includes, on LINUX:
sdk.h -> sdk_precomp.h -> sdk_common.h -> configmanager.h, messagemanager.h and sdk_events.h

To have this behaviour, the CB_PRECOMP macro must be defined in project settings and __WXMSW__ must not be defined.
Can you check and tell me more about this ?

ThreadSearch 0.4 is available :

What's new :
  • Quote
    I'll add another menu entry in the Search menu with the same event ID as in the view menu.
  • Use of the WXEXPORT instead of __declspec(dllexport) to compile under LINUX (correction has to be checked)

Dje

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5177
Re: ThreadSearch plugin is born !
« Reply #27 on: March 14, 2007, 10:58:28 pm »
not all compilers support precompiled headers, and the CB_PRECOMP is for pch's.
To be honest, I hate them. Today I once again fixed a bug due to those darn pch's.
Pch's can be a help , a speed up, but still people first need to write correct headers and includes, and only then pch should be applied. Now too many people write incorrect headers and includes but things work because of those pch's (this is not a good side effect, it is a bad one, because it create unportable code). I once prepared a post on correct header inclusion, next week I will spend a lot of time in hotels. I will finish it and post it (finally), it will explain al ot of things.

Basically you do something like this :

#include "sdk.h"
#indef CB_PRECOMP
 // include here all headers which are actually needed and are otherwise delivered through include of sdk.h
#endif
// include here all remaining headers needed and which are not provided by sdk.h

when there's no CB_PRECOMP then sdk.h should bring no headers at all, that's the correct way.

I promise to post my article next week to clarify a lot of things.


Cheers,
Lieven

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: ThreadSearch plugin is born !
« Reply #28 on: March 14, 2007, 11:02:56 pm »
I'll apply this in O.5, but not today, it's time to stop !

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: ThreadSearch plugin is born !
« Reply #29 on: March 14, 2007, 11:13:07 pm »
What's new :
  • Quote
    I'll add another menu entry in the Search menu with the same event ID as in the view menu.
  • Use of the WXEXPORT instead of __declspec(dllexport) to compile under LINUX (correction has to be checked)
Nice one. Will try tomorrow. So far I have attached something you might want to consider, too: The zip file contains fixes to the project file (there were e.g. references to non-existing folders) and an update to the post-build process using a batch file on windows. Thus ensuring that the images are being copied to all locations required.
The same file can be converted to a unix bash script appropriate next to another project file for unix.

With regards, Morten.

[attachment deleted by admin]
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ