Author Topic: Editor : Swap header/source  (Read 3372 times)

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 584
  • L'ami de l'homme. The friend of man.
    • LETARTARE
Editor : Swap header/source
« on: August 15, 2026, 03:00:59 pm »
Leap-15.6

Currently, on a file editor: if you ask to switch to the header/source the requested file opens in an editor all to the right of the open files.
If many files are opened, the layout is incorrectly appropriate.
Is there an option to open it next to the applicant ?
CB-13960, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 584
  • L'ami de l'homme. The friend of man.
    • LETARTARE
Re: Editor : Swap header/source
« Reply #1 on: August 19, 2026, 02:39:26 pm »
Not having found, I wrote a fix to do so.
But when analyzing the code I found an anomaly !

The class managing the exchange is called 'EditorManager' ('editormanager.h' and 'editormanager.cpp')

Also I offer you a test:
I use the renowned version 'cb-13951' (cb51) and 'cb-13958' (cb58)
(or any other available versions)

1- open any version of 'CB' but empty,
2- load the 'cb51.cbp' project, open the file 'include/editormanager.h'
3- load the 'cb58.cbp' project, open the file 'include/editormanager.h'
4- activate the project 'cb51' :
    4-1 select 'cb51::editormanager.h'
    4.2 use in the editor's survey menu' => 'Swap header/source' and validate :
    => a file ''cb51::editormanager.cpp' appears on the right ; it's good

    4.3-  select 'cb58::editormanager.h'
    4.4- use in the editor's survey menu' => 'Swap header/source' and validate :
    => the file 'cb51::editormanager.cpp' is selected !!, it's not the good file

This shows that the verification of belonging to the same project was not carried out in the code

If you could confirm these results, I'll drop off a ticket with the fix.
« Last Edit: Yesterday at 03:29:40 pm by LETARTARE »
CB-13960, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

Offline christo

  • Developer
  • Multiple posting newcomer
  • *****
  • Posts: 88
Re: Editor : Swap header/source
« Reply #2 on: Yesterday at 07:09:02 pm »
Hi @Letartare,

I've implemented an option to open new tab to the right of current tab instead of last in the tab panel : https://github.com/josephch/codeblocks/commit/78858208489bd7ca3cb932ee5596eaee1c4bee27

I think this option is better to limiting this feature to just "swap hearder/source" as it will help to position tabs nearby when opening files when using features like "jump to definition" etc.

Could you please share your thoughts?

@Devs, could you please review and suggest if this is ok to be merged as this introduces a new option?

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 584
  • L'ami de l'homme. The friend of man.
    • LETARTARE
Re: Editor : Swap header/source
« Reply #3 on: Today at 01:12:45 am »
Thank you for being interested in the problem.

The first job is to remove the reported anomaly.
Have you tried the proposed test ?
Does your proposal delete it ?

I looked at your proposal (I didn't test it) :
1- for the modification of 'editor_configuration.xrc': it seems better to choose a 'wxCheckBox' because we only need a boolean to define the exchange either next to the selection or all right.

2- for the modification of the class 'EditorManager' the fact of using 'AddEditorBase(...)', to insert a page, can lead to confusion.
Maybe create an insertion method ? But it is true that in both cases a page is added.

That being the developers will notify.
CB-13960, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'