Author Topic: Save() of an custom editor  (Read 6866 times)

Offline Florianx

  • Multiple posting newcomer
  • *
  • Posts: 15
Save() of an custom editor
« on: October 08, 2005, 07:51:43 pm »
Hi,
I'm trying to write an editor plug-in.
I have overloaded EditorBase and implemented the functions GetModified(), SetModified() and Save().
If I close an modified file, Save() is called correctly.
If I modify the file, the save-icon and the menu entry get enabled correctly.
But if I click on the icon, the menu entry or press Ctrl+S, Save() is not called.

I have found the reason for that: its EditorManager::SaveActive():
Code
bool EditorManager::SaveActive()
{
    SANITY_CHECK(false);
    cbEditor* ed = GetBuiltinEditor(GetActiveEditor());
if (ed)
return ed->Save();
return true;
}
Why do you call GetBuiltinEditor() here?
It's completely unnecessary here, because Save() is an virtual function of EditorBase.
if you change the function to:
Code
bool EditorManager::SaveActive()
{
    SANITY_CHECK(false);
    EditorBase* ed = GetActiveEditor();
if (ed)
return ed->Save();
return true;
}
saving should also work for custom editors.
The same is with EditorManager::SaveAll().


I generally think you should redesign EditorBase, so that you don't have to make an distinction between buldin and custom editors.
I you do this, you can move cbEditor to an plug-in, which will make the source much cleaner. But thats something for >1.0.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Save() of an custom editor
« Reply #1 on: October 08, 2005, 10:05:34 pm »
It seems that someone (Rick?) who moved enough cbEditor functions to EditorBase, forgot to update the editormanager's functions.
Thanks for spotting this.
Be patient!
This bug will be fixed soon...

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Save() of an custom editor
« Reply #2 on: October 09, 2005, 05:17:18 am »
^^; oopsie... please put that in bug reports (with priority 1) so i remember to implement it after RC2 is released.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Save() of an custom editor
« Reply #3 on: October 09, 2005, 11:05:58 am »
I corrected the Save() functions but still more functions should be moved to EditorBase (like SaveAs()). We 'll settle this after RC2 is released.
Be patient!
This bug will be fixed soon...

Offline danselmi

  • Developer
  • Almost regular
  • *****
  • Posts: 206
Re: Save() of an custom editor
« Reply #4 on: October 01, 2008, 11:29:12 am »
Hi

Is someone working on this? (SaveAs() is not in editorBase)


Offline danselmi

  • Developer
  • Almost regular
  • *****
  • Posts: 206
Re: Save() of an custom editor
« Reply #5 on: December 05, 2008, 03:19:37 pm »
Hi

See patch ID 002606. It moves the SaveAs to EditorBase and adds SelectAll to EditorBase/cbEditor.
Both changes need additional changes in editormanager and SelectAll needs changes in main.
All these changes are quite small, so please take a look at it.

I work on a editor plugin (two-way structogram tool, see attachment for first screenshot) and needed this interface.
I think HexEditor will also benefit of this changes (at least the SaveAs method).

Regards Daniel

[attachment deleted by admin]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Save() of an custom editor
« Reply #6 on: December 07, 2008, 11:30:02 am »
I work on a editor plugin (two-way structogram tool, see attachment for first screenshot) and needed this interface.
Wow! Now *that* looks great.  :P  Nice work! :D
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ