Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find info on hosting terminal in another app. #4572

Open
Tracked by #6999
sharpninja opened this issue Feb 13, 2020 · 16 comments
Open
Tracked by #6999

Cannot find info on hosting terminal in another app. #4572

sharpninja opened this issue Feb 13, 2020 · 16 comments
Assignees
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Docs It's a documentation issue that really should be on MicrosoftDocs/Console-Docs Product-Meta The product is the management of the products.
Milestone

Comments

@sharpninja
Copy link

We need documentation on hosting the console. Project templates would be very helpful.

@sharpninja sharpninja added the Issue-Docs It's a documentation issue that really should be on MicrosoftDocs/Console-Docs label Feb 13, 2020
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Feb 13, 2020
@DHowett-MSFT
Copy link
Contributor

This is very well-documented on our docs.microsoft.com section

@DHowett-MSFT
Copy link
Contributor

There's also samples in this repository.

@sharpninja
Copy link
Author

There are no samples or document for hosting in a UWP process, which has been promised for a long time. Please reopen.

@DHowett-MSFT
Copy link
Contributor

We haven’t promised documentation on that, because hosting an unconstrained application from a UWP context is currently impossible. This is why we didn’t build the terminal as a UWP. That’s just not something the platform supports.

@sharpninja
Copy link
Author

sharpninja commented Feb 13, 2020 via email

@zadjii-msft
Copy link
Member

Okay you're not wrong about that. That doc is maybe a little out of date, but I guess we did mention that publicly.

The way the terminal's architecture is designed, it's certainly possible to re-use the terminal control in other UWP projects. However, I think we've let the priority of that particular feature slip a bit as we approach 1.0. AS it currently stands, I don't think that we'll have the cycles to be able to officially support a nuget package or something for the terminal control in the 1.0 timeframe. I think it was more important for us to prepare for allowing arbitrary apps to host the control, and that we've most certainly done.

Thant being said, it'd definitely be possible to unofficially use the TerminalControl.dll and TerminalControl.winmd that's built from this project in other projects. I'm not saying you should do this. I'm saying you could.

@DHowett-MSFT is alluding to the fact that launching other processes from a UWP context is fraught with peril. Those perils is why we've chosen the Win32+Xaml Hosting model for the Terminal. That being said, you could totally add a terminal to a pure UWP application. Just be aware that it's a here be dragons path.

We probably should add documentation on this, but I'm going to toss it on the backlog, since I don't think we'll want to author documentation at this time while things are still changing pretty rapidly.

@zadjii-msft zadjii-msft reopened this Feb 13, 2020
@zadjii-msft zadjii-msft added Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Product-Meta The product is the management of the products. labels Feb 13, 2020
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Feb 13, 2020
@zadjii-msft zadjii-msft added this to the Terminal Backlog milestone Feb 13, 2020
@DHowett-MSFT
Copy link
Contributor

Ah, sorry about that!

@sharpninja
Copy link
Author

Totally cool!

I am very happy to guinea pig this as I'm working on a project that literally is providing a programmer's "toolbox" that having an embedded terminal is a foundational requirement, and I started this project after months ago reading that quote and anxiously awaiting the release of the hostable console. I understand not wanting to post any formal docs yet, but if you could at least give me a rough set of steps to get a terminal hosted in a C# UWP app then I'd be greatly appreciative.

@DHowett-MSFT
Copy link
Contributor

DHowett-MSFT commented Feb 14, 2020

@sharpninja If you're willing to take instructions with no warranty whatsoever and do something that might simply break for no reason because we're not ready to ship it yet, read on...

And on and on

If you build Terminal, you'll get a bunch of interesting things in ./x64/Debug:

  • TerminalControl.dll and TerminalControl.winmd: These implement the terminal control; the winmd is how you'll import references to another project. This is easier with C#, actually, but I don't know how it's going to feel about activating classes from these DLLs.
  • resources.pri: Localizable resources from the entire terminal app and all of microsoft.ui.xaml (sorry: we can't split it finer than this right now; you might be able to grab a pri from x64/Debug/TerminalControl?)
  • TerminalSettings.dll and TerminalSettings.winmd: A single-class library that lets you construct an object that can be used to pass settings to a terminal.
  • TerminalConnection.dll and TerminalConnection.winmd: Contains the ITerminalConnection interface you'll need to conform to and a couple other classes. If you don't need the conpty, azure or telnet connections you should be able to get by with only the winmd? If you copy the dll, make sure to copy cpprest and telnetpp DLLs as well.

Know that you'll be going significantly off-road here.

Anyway, once you grab those things and integrate them into your own package, you should be able to host a Microsoft.Terminal.TerminalControl.TermControl (yes, that is a heck of a name) in your Xaml tree. It can't be constructed without an IControlSettings (TerminalSettings winmd) and an ITerminalConnection (TerminalConnection winmd).

There might be one or two .xbf files you need as well; if you see it failing to load SearchBoxControl, you'll want to make sure you copy that over too.

It's really not in a good place right now!

@DHowett-MSFT DHowett-MSFT removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Feb 14, 2020
@DHowett-MSFT DHowett-MSFT self-assigned this Feb 14, 2020
@sharpninja
Copy link
Author

sharpninja commented Feb 14, 2020 via email

@DHowett-MSFT
Copy link
Contributor

If you want to go significantly the other way on this, the WpfTerminalControl project will produce a nuget package with far fewer dependencies that'll work with WPF Xaml (yeah!) down to Windows 7ish. I know that's really outside the scope of UWP 😉

@DHowett DHowett assigned DHowett and unassigned DHowett-MSFT May 17, 2020
@RWeigelt
Copy link

RWeigelt commented May 21, 2020

If you want to go significantly the other way on this, the WpfTerminalControl project will produce a nuget package with far fewer dependencies that'll work with WPF Xaml [...]

Where can I find more information about WpfTerminalControl and how to use it in my WPF application?

@DHowett
Copy link
Member

DHowett commented May 22, 2020

Sorry -- it's undocumented for a reason. It's very much an act of trailblazing to get it going.

@zadjii-msft zadjii-msft added this to the Backlog milestone Jan 4, 2022
@akasarto
Copy link

Hey! If someone is still interested in this, I've been playing around with the available WpfTerminalControl and the simplest way I found to make this work is as follows:

  • Make sure the WPF app has the compiled PublicTerminalCore.dll available for DLLImport/PInvoke. I was able to achieve this by including the microsoft/terminal repository as a submodule of mine and creating a script called build-deps.cmd to compile only the necessary bits: /modules/ms-terminal/src/cascadia/PublicTerminalCore.
  • Add a reference to the submodule /src/cascadia/WpfTerminalControl project to your solution.
  • Implement the ITerminalConnection to handle user input.
  • On your WPF app, add a reference to the WpfTerminalControl project above and instantiate the user control TerminalControl.xaml, assigning your custom IterminalConnection implementation to it.

**Note that for the compilation script above to work, the Prerequisites from the microsoft/terminal must be met.

The implementation referred above can be found under the net5-refactor branch, here

For my use case, the result looks like this:

dTerm

@Crypties
Copy link

It's really not in a good place right now!

About 3 years later. Is it in a good place now?

@zadjii-msft
Copy link
Member

Not really. This unfortunately hasn't really bubbled up to the top of our list of priorities yet.

  • The WPF control is technically hostable in another app, but not in a productized sense. See WPF control / ConPTY example (included) #15053. You could surely follow that path, with the caveat that the entire interface is subject to change.
  • Speaking of productization, we're mostly tracking that in Productize the WPF, UWP Terminal Controls #6999.
  • We really want to refine the whole HwndTerminal / TerminalCore / ControlCore/Interactivity story. There's a lot of duplicated work there, and we could surely just replace one with the other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Docs It's a documentation issue that really should be on MicrosoftDocs/Console-Docs Product-Meta The product is the management of the products.
Projects
None yet
Development

No branches or pull requests

7 participants