slynch8 / 10x

10x IDE/Editor
191 stars 35 forks source link

Support reading in data from pipe. #2785

Closed JPBarrick closed 1 month ago

JPBarrick commented 2 months ago

The editor should be able to create a new document and copy the contents of piped in data.

For example: oh-my-posh config export | 10x should open 10x, create a new file, and copy the output from the oh_my_posh command into the new document. This can be achieved using stdin.

Example:

In main()

#define MEGABYTE 0x100000

char* buffer = malloc(MEGABYTE);
memset(buffer, 0, MEGABYTE);

char in;
int index = 0;

while ((in = getc(stdin)) != EOF && index < MEGABYTE)
{
    buffer[index++] = in;
}

buffer[index] = '\0';

printf("%s\n", buffer);
free(buffer);

Obviously, make the buffer a dynamically resizing array and do allocation checks, etc., etc., etc.

slynch8 commented 2 months ago

done (early access build (1.0.211)

slynch8 commented 1 month ago

done (1.0.218)