Author Topic: External use of cbEditor  (Read 20739 times)

Offline dje

  • Lives here!
  • ****
  • Posts: 683
External use of cbEditor
« on: December 06, 2006, 10:40:27 am »
Hi !!

I am working on a plug-in and I would like to use the cbEditor class outside the wxFlatNotebook using the EditorManager.

This plug-in adds a Find occrences of: contextual menu item just below Find declaration of: and Find implementation of:
items.
Look at the attachment for a better global understanding.

The search looks like a Search in files with options on the panel but has the advantage is of using its own thread not to block the IDE when searching.
Results are redirected in a Search results log and propose a preview window.

I felt that need when diving into very large projects and beeing forced to switch from current editor and to change caret in current one when searching for items.

For now, I use the cbStyledTextCtrl with EditorColourSet to colorise but I would like to use cbEditor to manage all other user options and not reinvent the wheel.

Is it possible to change the API, changing from private to public some method mike SetEditorStyleBeforeFileOpen ??

By the way, are you interested in such a plug-in ?

Thanks

Dje


[attachment deleted by admin]

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: External use of cbEditor
« Reply #1 on: December 06, 2006, 02:06:17 pm »
Quote
For now, I use the cbStyledTextCtrl with EditorColourSet to colorise but I would like to use cbEditor to manage all other user options and not reinvent the wheel.

Is it possible to change the API, changing from private to public some method mike SetEditorStyleBeforeFileOpen ??

cbEditor is tightly coupled because it has to be (for various reasons). What is it exactly that you would do with cbEditor that you can't do with cbStyledTextCtrl? I 'd be happy to help you and even provide API access to any internals you would like, but not without a good reason too. So please explain a bit more.
Be patient!
This bug will be fixed soon...

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: External use of cbEditor
« Reply #2 on: December 06, 2006, 02:25:52 pm »
I'd like to use the same configuration for my preview window as for the editor.

I am interested in all "already implemented" services concerning control management :
  • colours
  • folding
  • indentation
  • font
  • bookmark
  • contextual menu
  • keyboard shortcuts (Ctrl+C)

For colours, I use :
Code
EditorColourSet EdColSet;
EdColSet.Apply(EdColSet.GetLanguageForFilename(m_sPreviewFilePath), m_pSearchPreview);

But that's too limited.

Basically, for now, I need API to:
  • create my control on my panel
  • styling methods (SetEditorStyle()),

The idea is to provide a read only cbEditor to the user to be able to browse code without losing his "main" editor/position.

Thanks,

Dje

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: External use of cbEditor
« Reply #3 on: December 06, 2006, 02:48:52 pm »
So you just want SetEditorStyleBeforeFileOpen() and SetEditorStyleAfterFileOpen() made public?
If that is so, then it is doable. Just say the word ;).

For more, don't even bother to ask. Not now that we 're heading into the API freeze.
Be patient!
This bug will be fixed soon...

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: External use of cbEditor
« Reply #4 on: December 06, 2006, 03:06:50 pm »
Yes, please  :wink:

I think it is sufficient.

What about the constructor ??
In header, there is
Note: you should not create a cbEditor object directly. Instead use EditorManager's methods to do it...

For sure I won't use EditorManager for creation as I want to be independant from the wxFlatNotebook...
Anything particular to know about construction requirements ??

Thanks,

Dje

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: External use of cbEditor
« Reply #5 on: December 06, 2006, 03:38:42 pm »
What about the constructor ??
In header, there is
Note: you should not create a cbEditor object directly. Instead use EditorManager's methods to do it...

For sure I won't use EditorManager for creation as I want to be independant from the wxFlatNotebook...
Anything particular to know about construction requirements ??

Maybe you misunderstood something. You will not be able to create a new cbEditor, as a matter of fact I moved the constructors/destructor to protected scope.
But I have added a static function cbEditor::ApplyStyles(cbStyledTextCtrl*). Just feed this function with your cbStyledTextCtrl* and it will set it up like internal editors are setup.

Note: I haven't yet committed the above, but I will do so once I verify everything works as expected.
Be patient!
This bug will be fixed soon...

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: External use of cbEditor
« Reply #6 on: December 06, 2006, 03:46:22 pm »
Ok, my SVN code from yesterday shew me public.

That's OK for me.

I can help you to test it in my case...

Thanks again,

Dje

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: External use of cbEditor
« Reply #7 on: December 06, 2006, 04:06:26 pm »
Just committed what I posted in my previous message. Feel free to test it.
Be patient!
This bug will be fixed soon...

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: External use of cbEditor
« Reply #8 on: December 06, 2006, 04:10:39 pm »
very interested in that plug-in :-)

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: External use of cbEditor
« Reply #9 on: December 06, 2006, 05:03:08 pm »
off topic a little, but...

Not now that we 're heading into the API freeze.

Does this mean you won't be doing anything with the debugger plugin API until v1.x?
(Since I'm the only one who seems to need changes to this part of API and the apparently the only person that uses my python debugger plugin, I'm not all that concerned, but it will help my planning to know what's in store.)

It would be nice if you could post a message sometime soon about this feature freeze.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: External use of cbEditor
« Reply #10 on: December 06, 2006, 05:41:55 pm »
Not now that we 're heading into the API freeze.

Does this mean you won't be doing anything with the debugger plugin API until v1.x?
(Since I'm the only one who seems to need changes to this part of API and the apparently the only person that uses my python debugger plugin, I'm not all that concerned, but it will help my planning to know what's in store.)

I 'm talking about the SDK API (sdk/*.h). Any plugin's interface can change without causing any problems. But the main SDK interfaces won't change after that.

It would be nice if you could post a message sometime soon about this feature freeze.

There will be a public announcement a few days before we enter the freeze.
Be patient!
This bug will be fixed soon...

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: External use of cbEditor
« Reply #11 on: December 06, 2006, 06:02:41 pm »
Quote
Just committed what I posted in my previous message. Feel free to test it.

Great !!!  :D
It works as expected !!

Thanks for the evolution.

A problem still remains; I'd like to handle margin click and added this code :
Code
index = m_pSearchPreview->GetId();
Connect(index, -1, wxEVT_SCI_MARGINCLICK,   (wxObjectEventFunction) (wxEventFunction) (wxScintillaEventFunction)   &cbEditor::OnMarginClick );

but cbEditor::OnMarginClick is private.
Is it possible to make it public too ?

Dje



Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: External use of cbEditor
« Reply #12 on: December 06, 2006, 06:39:31 pm »
I 'm talking about the SDK API (sdk/*.h). Any plugin's interface can change without causing any problems. But the main SDK interfaces won't change after that.

in our last exchange, you hinted at changing the way debuggers are handled:

Quote
What I plan to add soon is a language enum so that each compiler/debugger can report the languages it supports. Consequently, the editor will send breakpoint events to the debugger that should handle them.

would this not affect the SDK?

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: External use of cbEditor
« Reply #13 on: December 06, 2006, 07:11:12 pm »
would this not affect the SDK?

Have we entered the freeze yet and I 'm not aware? ;)
Be patient!
This bug will be fixed soon...

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: External use of cbEditor
« Reply #14 on: December 07, 2006, 03:55:31 pm »
Hi !!

Quote
but cbEditor::OnMarginClick is private.
Is it possible to make it public too ?

Waiting for an answer, I adapted the cbEditor::OnMarginClick in my class to handle only folding events.

I would like to use the default contextual menu.
I don't understand why the follwing code doesn't work:
Code
// Panel constructor
id = m_pSearchPreview->GetId();
Connect(id, wxEVT_SCI_MARGINCLICK,
(wxObjectEventFunction) (wxEventFunction) (wxScintillaEventFunction)
&FindOccurrencesView::OnMarginClick); // OK

Connect(id, wxEVT_CONTEXT_MENU,
(wxObjectEventFunction) (wxEventFunction) (wxContextMenuEventFunction)
&FindOccurrencesView::OnContextMenu); // KO

Connect(id, wxEVT_RIGHT_UP,
(wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction)
&FindOccurrencesView::OnMouseRightUp); // KO
// End of panel constructor


// m_pSearchPreview is a cbStyledTextCtrl*
void FindOccurrencesView::OnContextMenu(wxContextMenuEvent& event)
{
m_pSearchPreview->ProcessEvent(event);
}


void FindOccurrencesView::OnMouseRightUp(wxMouseEvent& event)
{
m_pSearchPreview->ProcessEvent(event);
}

Any idea ??

When I use the EVT_CONTEXT_MENU and EVT_RIGHT_UP macros, the right clicks on panel are correctly handled, but not on cbStyledTextCtrl (for sure, no id provided...).

Thanks for support,

Dje