This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
BigTwisty's profile picture

Can You Get The Currently Wrapped Terminal?

Started by BigTwisty, 12 September 2013 - 12:20 PM
BigTwisty #1
Posted 12 September 2013 - 02:20 PM
In a good buffer wrapper, it would be helpful to be able to set a Parent redirect object for the buffer to always copy to. This SHOULD default to whatever terminal is currently wrapped. I can't find a way to save that object. terminal.native just represents the unwrapped base computer screen and the storage variables for wrapping buffers within the "term" API seem to be local.
Lyqyd #2
Posted 12 September 2013 - 02:25 PM
This is (unfortunately) unavailable.
BigTwisty #3
Posted 12 September 2013 - 08:46 PM
This is (unfortunately) unavailable.

Bummer. You of all people here would appreciate how useful that could be.
Yevano #4
Posted 12 September 2013 - 09:21 PM
An alternative is to detour the term.redirect function to save the redirect object in your own accessible scope.
BigTwisty #5
Posted 12 September 2013 - 09:24 PM
An alternative is to detour the term.redirect function to save the redirect object in your own accessible scope.
That has me thinking… Thanks.
Lyqyd #6
Posted 12 September 2013 - 09:26 PM
If the point is to get the existing point of redirection when your code is started, overriding term.redirect won't help, since it will have already been redirected (or not) to wherever it's currently at when your code starts.
Yevano #7
Posted 12 September 2013 - 09:43 PM
Yeah, I should have noted that it really only works when run at startup. This is not a problem for a custom OS, but otherwise you'd need to restore the native terminal on program start. I'd say that isn't too bad of a deal for most environments.
BigTwisty #8
Posted 13 September 2013 - 01:09 AM
I've ended up just having the OS wrap term from _G. It's working quite well, any applications running will see their local buffer as term.native.