Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Target Management » Writing to a local terminal programmatically(Writing to a local terminal programmatically)
Writing to a local terminal programmatically [message #1850629] Thu, 10 March 2022 21:14
Edward MezarinaFriend
Messages: 1
Registered: March 2022
Junior Member
Hello,
I am creating an Eclipse plugin and along the process i need to open a terminal to run a command. I can do that like this:
       
        ...
        properties.put(ITerminalsConnectorConstants.PROP_TITLE, projectName);
        properties.put(ITerminalsConnectorConstants.PROP_DELEGATE_ID, CustomDelegate.id);
        properties.put(ITerminalsConnectorConstants.PROP_PROCESS_ARGS, cmd);
        ITerminalService ts = TerminalServiceFactory.getService();
        ts.openConsole(properties, null);


The command being issued under the covers spawns a process that requires further input to the terminal to do various actions (i.e. exit, etc).

I have been doing some digging on how to do this, and it looks like i would need to get a hold of the terminal's connector (for example, by creating a CustomDelegate that extends LocalLauncherDelegate and caching the connector during createTerminalConnector(), using it, and disposing of it at the end) so that i can do something like this:

ITerminalConnector terminalConnector = getTerminalConnector();
OutputStream terminalStream = terminalConnector.getTerminalToRemoteStream();
String cmd = "exit" + System.lineSeparator();
terminalStream.write(cmd.getBytes());


Now, doing it this way involves using/referencing org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector, which is an internal and experimental API.

My question: Is there a another way to write to the local terminal programmatically that does not involve getting a hold of the terminal connector? If not, given that this API has been out there for many years, can the ITerminalConnector API be used in the way similar to what is described above with minimal risk?

Thanks.
Edward.

[Updated on: Fri, 11 March 2022 12:35]

Report message to a moderator

Previous Topic:SSH terminal and RSE integration
Goto Forum:
  


Current Time: Mon Jan 30 19:05:29 GMT 2023

Powered by FUDForum. Page generated in 0.06379 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top