Skip to content

PoC: Redirect program output/input to separate window#112

Open
fafok29 wants to merge 2 commits intonakst:masterfrom
fafok29:dev_program_stdout_window
Open

PoC: Redirect program output/input to separate window#112
fafok29 wants to merge 2 commits intonakst:masterfrom
fafok29:dev_program_stdout_window

Conversation

@fafok29
Copy link
Copy Markdown

@fafok29 fafok29 commented Aug 30, 2023

This is pretty much the same as the Log window, but it is implemented via the gdb tty command and pseudo tty, so you don't have to change your code for it to work.

The window name can be changed)

@fafok29 fafok29 force-pushed the dev_program_stdout_window branch from f8c7213 to 41519df Compare August 30, 2023 20:30
@fafok29
Copy link
Copy Markdown
Author

fafok29 commented Aug 30, 2023

Updated solution to use portable functions.

Also not sure if I found the best place to open ptty

@nakst
Copy link
Copy Markdown
Owner

nakst commented Aug 31, 2023

In the case of errors occurring when creating the window, you should not return NULL. Instead, return UILabelCreate(parent, 0, "error message here...", -1);

@nakst
Copy link
Copy Markdown
Owner

nakst commented Aug 31, 2023

@aolo2 Since you tried making something similar, can you review this commit?

@fafok29 fafok29 force-pushed the dev_program_stdout_window branch from 41519df to 48f8daf Compare August 31, 2023 18:42
@fafok29
Copy link
Copy Markdown
Author

fafok29 commented Aug 31, 2023

Didn't work with UILabelCreate, used UICodeInsertContent

@aolo2
Copy link
Copy Markdown

aolo2 commented Aug 31, 2023

@aolo2 Since you tried making something similar, can you review this commit?

This approach (i.e. create your own pts) makes much more sense than what I did (the reverse, try to get the pts of a real terminal). Can't test right now, but I don't think this handles input, which is what most people want the terminal for.

@fafok29 fafok29 changed the title PoC: Redirect program output to separate window PoC: Redirect program output/input to separate window Sep 1, 2023
@nakst
Copy link
Copy Markdown
Owner

nakst commented Sep 3, 2023

I think this window would work better as a separate plugin.

Here is the general documentation for making plugins: https://github.com/nakst/gf#plugins

In commit 2746442 I have added the following features:

  • You can register custom message for receiving data:
UIMessage ReceiveMessageRegister(void (*callback)(char *input));

It returns the message code you should pass to UIWindowPostMessage. The input buffer is freed automatically. Use this to get your MSG_RECEIVED_STDOUT value.

  • You can append to the first command that is sent to GDB:
strcat_s(initialGDBCommand, sizeof(initialGDBCommand) - 1, "...\n")

This is where you should append your setPttyCMD.

  • You can set a callback for configuration settings.
void InterfaceWindow.config(const char *key, const char *value);

It will match key-value pairs in the section corresponding to the interface window name. So, key-value pairs in the [STDOUT] section would be passed to this callback.

Once you have made this plugin, I will link to it in the README.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants