Remork like Tabs in an arduino sketch.
Can't be done at the moment, but you can have different browser tabs, each with its own file if that is helpful. I am not sure if this question is just about being able to edit multiple files side by side, but I'll take the longer approach of explaining how to split custom handling code for O2O across different source files: if you have a single O2O instance, then you could split incoming messages based on the paths of individual programs and write the code to handle each path in a different file.
You'd then need some header file osc-handlers.h
where you declare the handler functions and make the Error
enum accessible from multiple files:
#include <oscpkt.hh>
#include "u8g2/U8g2LinuxI2C.h"
enum Error {
kOk = 0,
kUnmatchedPattern,
kWrongArguments,
kInvalidMode,
kOutOfRange,
};
enum Error handleProject0(U8G2& u8g2, const oscpkt::Message& msg);
enum Error handleProject1(U8G2& u8g2, const oscpkt::Message& msg);
Two changes are then needed for the stock parseMessage()
function:
- account for the global enum: repalace the definition of the
error
variable with a simpler enum Error error = kOk
.
- call these external handlers. For instance, after the
else if (msg.match("/waveform")){...}
block, you'd add:
} else if (msg.match("/waveform"))
{
// existing code here
// ...
} else if (msg.partialMatch("/project0/"))
{
error = handleProject0(u8g2, args);
} else if (msg.partialMatch("/project1/"))
{
error = handleProject1(u8g2, args);
} else
error = kUnmatchedPattern;
Then you can have some HandleProject0.cpp
and HandleProject1.cpp
files where in each you implement all the functions and possible pattern matches for each of the partial matches /project0/
and /project1/
. These will follow the blueprint of the chained msg.match()
calls present in parseMessage()
, with minimal boilerplate code to get the arguments and return the result, e.g. HandleProject0.cpp
:
#include
enum Error handleProject0(U8G2& u8g2, const oscpkt::Message& msg)
{
oscpkt::Message::ArgReader args = msg.arg();
if (msg.match("/project0/test"))
{
if(!args.isOkNoMoreArgs()){
error = kWrongArguments;
}
else {
printf("received /project0/test\n");
u8g2.setFont(u8g2_font_ncenB08_tr);
u8g2.setFontRefHeightText();
u8g2.drawStr(0, displayHeight * 0.5, "PROJECT0 TEST");
}
} else if (msg.match("/project0/another-pattern/") {
// ...
}
return error;
}
With this approach, each of the Handle*.cpp
files will be smaller and easier to scroll through and it conveniently keeps implementations out of the main file.
If you wanted to embed an O2O instance inside each project, then you could use a similar approach to use a unified custom Pd render.cpp shared across all projects, where you enable the O2O functionalities, then adding anything that's project-specific in a dedicated HandleOsc.cpp
file.