Page 3 of 3
Posted: 09.06.2020 15:55
by tmsg
Alexey wrote:done as suggested. tested on Linux, -id=name works Ok.

Well done.
Seems this is supported for Linux and not the other platforms... any specific reason for that?
And while I am at this Linux-only stuff... using a pipe to feed text into Cud is also Linux only. Pipes work in Windows as well so what is the rationale behind that? Or is it an FP/Lazarus thing? (I don't use it much in Windows, so that's more a case of curiosity killing the cat.)
I will for now try to learn a bit more about Cud's plugin framework so no new

's or other

tortures... for a while

Posted: 09.06.2020 16:42
by Alexey
pipe char is changed already. to CR or LF. after syncing UniqInstance with original repo.
Linux only? i'd say Posix only. Win32 build don't use UniqInstance.
Posted: 09.06.2020 17:15
by tmsg
Alexey wrote:pipe char is changed already. to CR or LF. after syncing UniqInstance with original repo.
That's not what I meant with my question.
I mean this quote from
https://wiki.freepascal.org/CudaText:
-i - Read the contents of stdin to a new document (Unix only), can be used in Unix shell like: "ls -l | cudatext -i"
Posted: 09.06.2020 17:35
by Alexey
aha. I see. "Linux only"? Linux and *BSD and Mac. Why not for Windows? Cud for Win32 is GUI app and cannot get console input
Posted: 09.06.2020 20:23
by tmsg
Hm... I seem to remember vaguely that many years ago, in another life

, I had solved this problem... so a win32 GUI app could read and write stdin and stdout. I have to search my old archives...
Posted: 10.06.2020 10:39
by tmsg
So I climbed down and started digging through my old C archives and... (imagine Indiana Jones emerging from some deep underground tunnel, covered in cobwebs with spiders hanging off his hat, but holding up an ancient golden statue)... found this gem:
Code: Select all
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#include "io.h"
#include "fcntl.h"
#include "stdio.h"
#include "stdlib.h"
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR lpCmdLine,INT nCmdShow) {
char buf[512]="";
int i;
// minimal version, just stdin
FILE *fin;
fin=_fdopen(_open_osfhandle((long)GetStdHandle(STD_INPUT_HANDLE),_O_RDONLY),"r");
fread(buf,1,sizeof(buf),fin);
if (fclose(fin)==0) MessageBox(NULL,buf,"OK",0);
}
This short snippet works if used with a redirected stdin:
But how to translate that stuff into FP/Lazarus... I haven't got a clue. It's probably not even worth your while to try as the C runtime library does things differently to FP's, I'd assume. Nevertheless, in theory at least a Win32 GUI app can indeed read stdin if started from a console

Posted: 11.06.2020 10:36
by Alexey
yes, I recall this gem too (made win32 console apps long time ago). don't know how to translate to FP, yes
edit.
and not sure we need this trick in Cud/win32.