Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: LETARTARE on August 15, 2026, 03:00:59 pm

Title: Editor : Swap header/source
Post by: LETARTARE 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 ?
Title: Re: Editor : Swap header/source
Post by: LETARTARE 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.
Title: Re: Editor : Swap header/source
Post by: christo on August 20, 2026, 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?
Title: Re: Editor : Swap header/source
Post by: LETARTARE on August 21, 2026, 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.
Title: Re: Editor : Swap header/source
Post by: LETARTARE on August 23, 2026, 06:32:22 pm
I just dropped off a ticket to correct the first and 2th messages.