diff --git a/OpenConsole.slnx b/OpenConsole.slnx index 90b231587c..6867f9ee75 100644 --- a/OpenConsole.slnx +++ b/OpenConsole.slnx @@ -723,16 +723,6 @@ - - - - - - - - - - diff --git a/build/config/esrp.build.batch.terminal_constituents.json b/build/config/esrp.build.batch.terminal_constituents.json index c33123a16d..66fa52943a 100644 --- a/build/config/esrp.build.batch.terminal_constituents.json +++ b/build/config/esrp.build.batch.terminal_constituents.json @@ -17,7 +17,6 @@ "PackageContents/WindowsTerminalShellExt.dll", // The rest - "PackageContents/TerminalAzBridge.exe", "PackageContents/wt.exe", "PackageContents/WindowsTerminal.exe", "PackageContents/elevate-shim.exe" diff --git a/src/cascadia/CascadiaPackage/CascadiaPackage.wapproj b/src/cascadia/CascadiaPackage/CascadiaPackage.wapproj index 6e43186c76..465f41ca94 100644 --- a/src/cascadia/CascadiaPackage/CascadiaPackage.wapproj +++ b/src/cascadia/CascadiaPackage/CascadiaPackage.wapproj @@ -77,9 +77,6 @@ {CA5CAD1A-1754-4A9D-93D7-857A9D17CB1B} - - {067F0A06-FCB7-472C-96E9-B03B54E8E18D} - {f2ed628a-db22-446f-a081-4cc845b51a2b} diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index c45ca80ec0..a5a74e140f 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -1491,18 +1491,8 @@ namespace winrt::TerminalApp::implementation if (connectionType == TerminalConnection::AzureConnection::ConnectionType() && TerminalConnection::AzureConnection::IsAzureConnectionAvailable()) { - std::filesystem::path azBridgePath{ wil::GetModuleFileNameW(nullptr) }; - azBridgePath.replace_filename(L"TerminalAzBridge.exe"); - if constexpr (Feature_AzureConnectionInProc::IsEnabled()) - { - connection = TerminalConnection::AzureConnection{}; - } - else - { - connection = TerminalConnection::ConptyConnection{}; - } - - valueSet = TerminalConnection::ConptyConnection::CreateSettings(azBridgePath.native(), + connection = TerminalConnection::AzureConnection{}; + valueSet = TerminalConnection::ConptyConnection::CreateSettings(winrt::hstring{}, L".", L"Azure", false, diff --git a/src/cascadia/TerminalAzBridge/ConsoleInputReader.cpp b/src/cascadia/TerminalAzBridge/ConsoleInputReader.cpp deleted file mode 100644 index 23ce94f64f..0000000000 --- a/src/cascadia/TerminalAzBridge/ConsoleInputReader.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -#include "pch.h" -#include "ConsoleInputReader.h" -#include "unicode.hpp" - -ConsoleInputReader::ConsoleInputReader(HANDLE handle) : - _handle(handle) -{ - _buffer.resize(BufferSize); - _convertedString.reserve(BufferSize); -} - -void ConsoleInputReader::SetWindowSizeChangedCallback(std::function callback) -{ - _windowSizeChangedCallback = std::move(callback); -} - -std::optional ConsoleInputReader::Read() -{ - DWORD readCount{ 0 }; - - _convertedString.clear(); - while (_convertedString.empty()) - { - _buffer.resize(BufferSize); - auto succeeded = - ReadConsoleInputW(_handle, _buffer.data(), gsl::narrow_cast(_buffer.size()), &readCount); - if (!succeeded) - { - return std::nullopt; - } - - _buffer.resize(readCount); - for (auto it = _buffer.begin(); it != _buffer.end(); ++it) - { - if (it->EventType == WINDOW_BUFFER_SIZE_EVENT && _windowSizeChangedCallback) - { - _windowSizeChangedCallback(); - } - else if (it->EventType == KEY_EVENT) - { - const auto& keyEvent = it->Event.KeyEvent; - if (keyEvent.bKeyDown || (!keyEvent.bKeyDown && keyEvent.wVirtualKeyCode == VK_MENU)) - { - // Got a high surrogate at the end of the buffer - if (IS_HIGH_SURROGATE(keyEvent.uChar.UnicodeChar)) - { - _highSurrogate.emplace(keyEvent.uChar.UnicodeChar); - continue; // we've consumed it -- only dispatch it if we get a low - } - - if (IS_LOW_SURROGATE(keyEvent.uChar.UnicodeChar)) - { - // No matter what we do, we want to destructively consume the high surrogate - if (const auto oldHighSurrogate{ std::exchange(_highSurrogate, std::nullopt) }) - { - _convertedString.push_back(*_highSurrogate); - } - else - { - // If we get a low without a high surrogate, we've done everything we can. - // This is an illegal state. - _convertedString.push_back(UNICODE_REPLACEMENT); - continue; // onto the next event - } - } - - // (\0 with a scancode is probably a modifier key, not a VT input key) - if (keyEvent.uChar.UnicodeChar != L'\0' || keyEvent.wVirtualScanCode == 0) - { - if (_highSurrogate) // non-destructive: we don't want to set it to nullopt needlessly for every character - { - // If we get a high surrogate *here*, we didn't find a low surrogate. - // This state is also illegal. - _convertedString.push_back(UNICODE_REPLACEMENT); - _highSurrogate.reset(); - } - _convertedString.push_back(keyEvent.uChar.UnicodeChar); - } - } - } - } - } - return _convertedString; -} diff --git a/src/cascadia/TerminalAzBridge/ConsoleInputReader.h b/src/cascadia/TerminalAzBridge/ConsoleInputReader.h deleted file mode 100644 index fecf62af89..0000000000 --- a/src/cascadia/TerminalAzBridge/ConsoleInputReader.h +++ /dev/null @@ -1,33 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. -Licensed under the MIT license. - -Module Name: - - ConsoleInputReader.h - -Abstract: - - This file contains a class whose sole purpose is to - abstract away a bunch of details you usually need to - know to read VT from a console input handle. - ---*/ - -class ConsoleInputReader -{ -public: - explicit ConsoleInputReader(HANDLE handle); - void SetWindowSizeChangedCallback(std::function callback); - std::optional Read(); - -private: - static constexpr size_t BufferSize{ 128 }; - - HANDLE _handle; - std::wstring _convertedString; - std::vector _buffer; - std::optional _highSurrogate; - std::function _windowSizeChangedCallback; -}; diff --git a/src/cascadia/TerminalAzBridge/TerminalAzBridge.vcxproj b/src/cascadia/TerminalAzBridge/TerminalAzBridge.vcxproj deleted file mode 100644 index 29719f4850..0000000000 --- a/src/cascadia/TerminalAzBridge/TerminalAzBridge.vcxproj +++ /dev/null @@ -1,93 +0,0 @@ - - - - - {067F0A06-FCB7-472C-96E9-B03B54E8E18D} - Win32Proj - TerminalAzBridge - TerminalAzBridge - TerminalAzBridge - Application - false - Windows Store - Windows - Windows Terminal Azure Cloud Shell Connector - - - - true - - - - - - - - true - true - - - - - - - - - - Create - - - - - - - - {CA5CAD1A-C46D-4588-B1C0-40F31AE9100B} - - - - - - - - - - - WindowsLocalDebugger - - - - - - - - - true - - - Console - - - - - - - false - - - - - diff --git a/src/cascadia/TerminalAzBridge/main.cpp b/src/cascadia/TerminalAzBridge/main.cpp deleted file mode 100644 index 05e3e99b23..0000000000 --- a/src/cascadia/TerminalAzBridge/main.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -#include "pch.h" -#include "winrt/Microsoft.Terminal.TerminalConnection.h" -#include "ConsoleInputReader.h" - -using namespace winrt; -using namespace winrt::Windows::Foundation; -using namespace winrt::Microsoft::Terminal::TerminalConnection; - -static til::size GetConsoleScreenSize(HANDLE outputHandle) -{ - CONSOLE_SCREEN_BUFFER_INFOEX csbiex{}; - csbiex.cbSize = sizeof(csbiex); - GetConsoleScreenBufferInfoEx(outputHandle, &csbiex); - return { - (csbiex.srWindow.Right - csbiex.srWindow.Left) + 1, - (csbiex.srWindow.Bottom - csbiex.srWindow.Top) + 1 - }; -} - -static ConnectionState RunConnectionToCompletion(const ITerminalConnection& connection, HANDLE outputHandle, HANDLE inputHandle) -{ - connection.TerminalOutput([outputHandle](const winrt::hstring& output) { - WriteConsoleW(outputHandle, output.data(), output.size(), nullptr, nullptr); - }); - - // Detach a thread to spin the console read indefinitely. - // This application exits when the connection is closed, so - // the connection's lifetime will outlast this thread. - std::thread([connection, outputHandle, inputHandle] { - ConsoleInputReader reader{ inputHandle }; - reader.SetWindowSizeChangedCallback([&]() { - const auto size = GetConsoleScreenSize(outputHandle); - - connection.Resize(size.height, size.width); - }); - - while (true) - { - auto input = reader.Read(); - if (input) - { - connection.WriteInput(winrt_wstring_to_array_view(*input)); - } - } - }).detach(); - - std::condition_variable stateChangeVar; - std::optional state; - std::mutex stateMutex; - - connection.StateChanged([&](auto&& /*s*/, auto&& /*e*/) { - std::unique_lock lg{ stateMutex }; - state = connection.State(); - stateChangeVar.notify_all(); - }); - - connection.Start(); - - std::unique_lock lg{ stateMutex }; - stateChangeVar.wait(lg, [&]() { - if (!state.has_value()) - { - return false; - } - return state.value() == ConnectionState::Closed || state.value() == ConnectionState::Failed; - }); - - return state.value(); -} - -int wmain(int /*argc*/, wchar_t** /*argv*/) -{ - winrt::init_apartment(winrt::apartment_type::single_threaded); - - DWORD inputMode{}, outputMode{}; - auto conIn{ GetStdHandle(STD_INPUT_HANDLE) }, conOut{ GetStdHandle(STD_OUTPUT_HANDLE) }; - auto codepage{ GetConsoleCP() }, outputCodepage{ GetConsoleOutputCP() }; - - RETURN_IF_WIN32_BOOL_FALSE(GetConsoleMode(conIn, &inputMode)); - RETURN_IF_WIN32_BOOL_FALSE(GetConsoleMode(conOut, &outputMode)); - - RETURN_IF_WIN32_BOOL_FALSE(SetConsoleMode(conIn, ENABLE_WINDOW_INPUT | ENABLE_VIRTUAL_TERMINAL_INPUT)); - RETURN_IF_WIN32_BOOL_FALSE(SetConsoleMode(conOut, ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING | ENABLE_WRAP_AT_EOL_OUTPUT | DISABLE_NEWLINE_AUTO_RETURN)); - RETURN_IF_WIN32_BOOL_FALSE(SetConsoleCP(CP_UTF8)); - RETURN_IF_WIN32_BOOL_FALSE(SetConsoleOutputCP(CP_UTF8)); - - auto restoreConsoleModes = wil::scope_exit([&]() { - SetConsoleMode(conIn, inputMode); - SetConsoleMode(conOut, outputMode); - SetConsoleCP(codepage); - SetConsoleOutputCP(outputCodepage); - }); - - const auto size = GetConsoleScreenSize(conOut); - - AzureConnection azureConn{}; - winrt::Windows::Foundation::Collections::ValueSet vs{}; - vs.Insert(L"initialRows", winrt::Windows::Foundation::PropertyValue::CreateUInt32(gsl::narrow_cast(size.height))); - vs.Insert(L"initialCols", winrt::Windows::Foundation::PropertyValue::CreateUInt32(gsl::narrow_cast(size.width))); - azureConn.Initialize(vs); - - const auto state = RunConnectionToCompletion(azureConn, conOut, conIn); - - return state == ConnectionState::Closed ? 0 : 1; -} diff --git a/src/cascadia/TerminalAzBridge/pch.cpp b/src/cascadia/TerminalAzBridge/pch.cpp deleted file mode 100644 index 398a99f665..0000000000 --- a/src/cascadia/TerminalAzBridge/pch.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -#include "pch.h" diff --git a/src/cascadia/TerminalAzBridge/pch.h b/src/cascadia/TerminalAzBridge/pch.h deleted file mode 100644 index 5882c56b92..0000000000 --- a/src/cascadia/TerminalAzBridge/pch.h +++ /dev/null @@ -1,40 +0,0 @@ -/*++ -Copyright (c) Microsoft Corporation -Licensed under the MIT license. - -Module Name: -- pch.h - -Abstract: -- Contains external headers to include in the precompile phase of console build process. -- Avoid including internal project headers. Instead include them only in the classes that need them (helps with test project building). ---*/ - -#pragma once - -// Ignore checked iterators warning from VC compiler. -#define _SCL_SECURE_NO_WARNINGS - -// Block minwindef.h min/max macros to prevent conflict -#define NOMINMAX - -#define WIN32_LEAN_AND_MEAN -#define NOMCX -#define NOHELP -#define NOCOMM -#include - -#include - -#include "../inc/LibraryIncludes.h" - -#include - -#include -#include -#include - -#include -#include - -#include diff --git a/src/features.xml b/src/features.xml index d5c7942104..9b115a0c06 100644 --- a/src/features.xml +++ b/src/features.xml @@ -107,16 +107,6 @@ - - Feature_AzureConnectionInProc - Host the AzureConnection inside Terminal rather than via TerminalAzBridge - 4661 - AlwaysDisabled - - Dev - - - Feature_ShellCompletions An experimental escape sequence for client applications to request the Terminal display a list of suggestions.