Unfortunately in Codeblocks i didn't yet find a possibility to redirect a programs' output to a seperate tab in the "Logs & others" section.
Well I know, that exact same job. But i can't use them when debugging a program. Also, I find it more convinient to just press the run-/debug-button and the output will automatically displayed in an logger window.
So I decided to simply write a plugin.
I already managed to write a message to a seperate, self-created logging-window in the "Logs & others" section, when the user presses the "debug" button (or presses [F8]).
For this purpose I read the source code of the Valgrind-plugin, which was quite straight forward.
But now I'm stuck. I don't know how to redirect the output of the program to this logging-window.
Does anyone know how to fetch the output and redirect it?
Another question, which is not related to my problem above:
As I created a new logging window in the plugin I wrote, it was very tricky to find a "free slot".
Manager::Get()->GetLogManager()->Slot(i);
whereas
i is the so called tab-index.
But i could just guess at which index i want to place my new logging-window and which slot is free.
Well, the first 3 indices (1, 2, 3) are already used. But all others are more or less "unknown".
I used the following piece of code to get the first free slot:
logman = Manager::Get()->GetLogManager();
// ...
for (int i = 0; i < logman->ListAvailable().size(); i++)
// check for g_null_log to indicate a free slot
if (logman->Slot(i).GetLogger() != &g_null_log)
{
free_slot_index = i;
break;
}
Now my question: Is there an easier way to do this. Cause the solution above is just a dirty hack, but it works
Regards