

I have done IPC before so I might look into this and come back with some ideas.
And in everyday use of Cud I know how to deal with this problem now so it's NBD.
I have three suggestions if you ever decide to fork (or rewrite) the TUniqueInstance stuff.
1. Change the code within GetFormattedParams() (uniqueinstancebase.pas, line 39) so that it accepts an array of strings with the command-line parameters (CLParray) instead of using hardcoded accesses to ParamStrUTF8(). This requires a change to TUniqueInstance.Loaded() (uniqueinstance.pas, line 119) because this is the main interface, so you would have the CLParray as an argument to TUniqueInstance.Loaded() which in turn gives them to GetFormattedParams().
This change would allow to add to or change the CLParray as required before it gets transmitted to the the first instance.
2. Change the ParamsSeparator (line 11, uniqueinstancebase.pas) from '|' to something more sensible. A good candidate might be \x00 but I don't know whether binary zeroes are legal in Pascal strings. Another choice could be '\n' or another control character between \x01 to \x1f.
3. Enable communication between **separate** first instances and their respective **second** instances. This is a slightly tricky concept but it would enable nifty stuff like the following:
3.1. Start a cudatext first instance with an id of "cudatext.1" by running "cudatext -id=cudatext.1 file1a.txt".
3.2. Start another cudatext first instance with an id of "cudatext.2" by running "cudatext -id=cudatext.2 file2a.txt".
3.3. Add a file to the running cudatext.1 instance by running "cudatext -id=cudatext.1 file1b.txt".
3.4. Add a file to the running cudatext.2 instance by running "cudatext -id=cudatext.2 file2b.txt".
Admittedly, this is something for command-line freaks and power-users (I have patched all open-source editors I've used so that they supported this sort of thing but I don't think I will for Cud because I have absolutely no idea about Lazarus development).
For this Cud would need an -id=... command line argument and then this id has to be set before calling TUniqueInstance.Loaded(). There's a line (757) in formmain.lfm that probably sets this id to a fixed "cudatext.0"; I don't know enough about the inner workings of FP/Lazarus to say what and where you have to change stuff to set this dynamically but I'm sure you know:-)
Well, I for one need it: as I wrote, I have patched every single editor (if I had the source code in a language I could readily work withAlexey wrote:>Enable communication between **separate** first instances and their respective **second** instances. This is a slightly tricky concept
hmm, I don't like that idea- I dont know IPC codde at all (I just use ready wrapper) and it sounds tricky.noone will need it..