Skip to content

Commit

Permalink
included some "using Microsoft::Console::Types" to make code prettier
Browse files Browse the repository at this point in the history
Added correct strings to WindowUiaProvider description fields
  • Loading branch information
carlos-zamora committed Jul 17, 2019
1 parent a162758 commit b618509
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 55 deletions.
4 changes: 4 additions & 0 deletions src/cascadia/WindowsTerminal/WindowUiaProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class WindowUiaProvider final :
_COM_Outptr_result_maybenull_ IRawElementProviderFragment** ppProvider) override;
IFACEMETHODIMP GetFocus(_COM_Outptr_result_maybenull_ IRawElementProviderFragment** ppProvider) override;

protected:
const OLECHAR* AutomationIdPropertyName = L"Terminal Window";
const OLECHAR* ProviderDescriptionPropertyName = L"Microsoft Windows Terminal Window";

private:
WindowUiaProvider(Microsoft::Console::Types::IConsoleWindow* baseWindow);
~WindowUiaProvider();
Expand Down
9 changes: 5 additions & 4 deletions src/host/scrolling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

using Microsoft::Console::VirtualTerminal::StateMachine;
using namespace Microsoft::Console::Interactivity;
using namespace Microsoft::Console::Types;

ULONG Scrolling::s_ucWheelScrollLines = 0;
ULONG Scrolling::s_ucWheelScrollChars = 0;
Expand All @@ -30,7 +31,7 @@ bool Scrolling::s_IsInScrollMode()
void Scrolling::s_DoScroll()
{
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
Microsoft::Console::Types::IConsoleWindow* const pWindow = ServiceLocator::LocateConsoleWindow();
IConsoleWindow* const pWindow = ServiceLocator::LocateConsoleWindow();
if (!s_IsInScrollMode())
{
// clear any selection we may have -- can't scroll and select at the same time
Expand All @@ -48,7 +49,7 @@ void Scrolling::s_DoScroll()
void Scrolling::s_ClearScroll()
{
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
Microsoft::Console::Types::IConsoleWindow* const pWindow = ServiceLocator::LocateConsoleWindow();
IConsoleWindow* const pWindow = ServiceLocator::LocateConsoleWindow();
WI_ClearFlag(gci.Flags, CONSOLE_SCROLLING);
if (pWindow != nullptr)
{
Expand All @@ -58,7 +59,7 @@ void Scrolling::s_ClearScroll()

void Scrolling::s_ScrollIfNecessary(const SCREEN_INFORMATION& ScreenInfo)
{
Microsoft::Console::Types::IConsoleWindow* pWindow = ServiceLocator::LocateConsoleWindow();
IConsoleWindow* pWindow = ServiceLocator::LocateConsoleWindow();
FAIL_FAST_IF_NULL(pWindow);

Selection* const pSelection = &Selection::Instance();
Expand Down Expand Up @@ -202,7 +203,7 @@ void Scrolling::s_HandleMouseWheel(_In_ bool isMouseWheel,
bool Scrolling::s_HandleKeyScrollingEvent(const INPUT_KEY_INFO* const pKeyInfo)
{
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
Microsoft::Console::Types::IConsoleWindow* pWindow = ServiceLocator::LocateConsoleWindow();
IConsoleWindow* pWindow = ServiceLocator::LocateConsoleWindow();
FAIL_FAST_IF_NULL(pWindow);

const WORD VirtualKeyCode = pKeyInfo->GetVirtualKey();
Expand Down
9 changes: 5 additions & 4 deletions src/host/selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "../interactivity/inc/ServiceLocator.hpp"

using namespace Microsoft::Console::Interactivity;
using namespace Microsoft::Console::Types;

std::unique_ptr<Selection> Selection::_instance;

Expand Down Expand Up @@ -309,7 +310,7 @@ void Selection::InitializeMouseSelection(const COORD coordBufferPos)
CheckAndSetAlternateSelection();

// set window title to mouse selection mode
Microsoft::Console::Types::IConsoleWindow* const pWindow = ServiceLocator::LocateConsoleWindow();
IConsoleWindow* const pWindow = ServiceLocator::LocateConsoleWindow();
if (pWindow != nullptr)
{
pWindow->UpdateWindowText();
Expand Down Expand Up @@ -437,7 +438,7 @@ void Selection::_CancelMouseSelection()
// turn off selection flag
_SetSelectingState(false);

Microsoft::Console::Types::IConsoleWindow* const pWindow = ServiceLocator::LocateConsoleWindow();
IConsoleWindow* const pWindow = ServiceLocator::LocateConsoleWindow();
if (pWindow != nullptr)
{
pWindow->UpdateWindowText();
Expand Down Expand Up @@ -467,7 +468,7 @@ void Selection::_CancelMarkSelection()
// Turn off selection flag.
_SetSelectingState(false);

Microsoft::Console::Types::IConsoleWindow* const pWindow = ServiceLocator::LocateConsoleWindow();
IConsoleWindow* const pWindow = ServiceLocator::LocateConsoleWindow();
if (pWindow != nullptr)
{
pWindow->UpdateWindowText();
Expand Down Expand Up @@ -621,7 +622,7 @@ void Selection::InitializeMarkSelection()
_coordSelectionAnchor = coordPosition;

// set frame title text
Microsoft::Console::Types::IConsoleWindow* const pWindow = ServiceLocator::LocateConsoleWindow();
IConsoleWindow* const pWindow = ServiceLocator::LocateConsoleWindow();
if (pWindow != nullptr)
{
pWindow->UpdateWindowText();
Expand Down
2 changes: 1 addition & 1 deletion src/host/tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ void Tracing::s_TraceApi(const CONSOLE_WRITECONSOLEOUTPUTSTRING_MSG* const a)
TraceLoggingKeyword(TraceKeywords::API));
}

void Tracing::s_TraceWindowViewport(const Microsoft::Console::Types::Viewport& viewport)
void Tracing::s_TraceWindowViewport(const Viewport& viewport)
{
TraceLoggingWrite(
g_hConhostV2EventTraceProvider,
Expand Down
11 changes: 0 additions & 11 deletions src/host/tracing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ Author(s):

#include "../types/inc/Viewport.hpp"

namespace Microsoft::Console::Types
{
class WindowUiaProvider;

namespace WindowUiaProviderTracing
{
enum class ApiCall;
struct IApiMsg;
}
}

namespace Microsoft::Console::Interactivity::Win32
{
class UiaTextRange;
Expand Down
7 changes: 4 additions & 3 deletions src/interactivity/base/ServiceLocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#pragma hdrstop

using namespace Microsoft::Console::Types;
using namespace Microsoft::Console::Interactivity;

#pragma region Private Static Member Initialization
Expand All @@ -22,7 +23,7 @@ std::unique_ptr<IHighDpiApi> ServiceLocator::s_highDpiApi;
std::unique_ptr<ISystemConfigurationProvider> ServiceLocator::s_systemConfigurationProvider;
std::unique_ptr<IInputServices> ServiceLocator::s_inputServices;

Microsoft::Console::Types::IConsoleWindow* ServiceLocator::s_consoleWindow = nullptr;
IConsoleWindow* ServiceLocator::s_consoleWindow = nullptr;

Globals ServiceLocator::s_globals;

Expand Down Expand Up @@ -103,7 +104,7 @@ void ServiceLocator::RundownAndExit(const HRESULT hr)

#pragma region Set Methods

[[nodiscard]] NTSTATUS ServiceLocator::SetConsoleWindowInstance(_In_ Microsoft::Console::Types::IConsoleWindow* window)
[[nodiscard]] NTSTATUS ServiceLocator::SetConsoleWindowInstance(_In_ IConsoleWindow* window)
{
NTSTATUS status = STATUS_SUCCESS;

Expand All @@ -127,7 +128,7 @@ void ServiceLocator::RundownAndExit(const HRESULT hr)

#pragma region Location Methods

Microsoft::Console::Types::IConsoleWindow* ServiceLocator::LocateConsoleWindow()
IConsoleWindow* ServiceLocator::LocateConsoleWindow()
{
return s_consoleWindow;
}
Expand Down
8 changes: 5 additions & 3 deletions src/interactivity/inc/ServiceLocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Author(s):

#pragma hdrstop

using namespace Microsoft::Console::Types;

namespace Microsoft::Console::Interactivity
{
class ServiceLocator final
Expand Down Expand Up @@ -52,8 +54,8 @@ namespace Microsoft::Console::Interactivity
return static_cast<T*>(LocateConsoleInputThread());
}

[[nodiscard]] static NTSTATUS SetConsoleWindowInstance(_In_ Microsoft::Console::Types::IConsoleWindow* window);
static Microsoft::Console::Types::IConsoleWindow* LocateConsoleWindow();
[[nodiscard]] static NTSTATUS SetConsoleWindowInstance(_In_ IConsoleWindow* window);
static IConsoleWindow* LocateConsoleWindow();
template<typename T>
static T* LocateConsoleWindow()
{
Expand Down Expand Up @@ -102,7 +104,7 @@ namespace Microsoft::Console::Interactivity
// TODO: MSFT 15344939 - some implementations of IConsoleWindow are currently singleton
// classes so we can't own a pointer to them here. fix this so s_consoleWindow can follow the
// pattern of the rest of the service interface pointers.
static Microsoft::Console::Types::IConsoleWindow* s_consoleWindow;
static IConsoleWindow* s_consoleWindow;
static std::unique_ptr<IWindowMetrics> s_windowMetrics;
static std::unique_ptr<IHighDpiApi> s_highDpiApi;
static std::unique_ptr<ISystemConfigurationProvider> s_systemConfigurationProvider;
Expand Down
17 changes: 9 additions & 8 deletions src/interactivity/win32/AccessibilityNotifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
#include "..\inc\ServiceLocator.hpp"
#include "ConsoleControl.hpp"

using namespace Microsoft::Console::Types;
using namespace Microsoft::Console::Interactivity::Win32;

void AccessibilityNotifier::NotifyConsoleCaretEvent(_In_ RECT rectangle)
{
Microsoft::Console::Types::IConsoleWindow* const pWindow = ServiceLocator::LocateConsoleWindow();
IConsoleWindow* const pWindow = ServiceLocator::LocateConsoleWindow();
if (pWindow != nullptr)
{
CONSOLE_CARET_INFO caretInfo;
Expand Down Expand Up @@ -41,7 +42,7 @@ void AccessibilityNotifier::NotifyConsoleCaretEvent(_In_ ConsoleCaretEventFlags

// UIA event notification
static COORD previousCursorLocation = { 0, 0 };
Microsoft::Console::Types::IConsoleWindow* const pWindow = ServiceLocator::LocateConsoleWindow();
IConsoleWindow* const pWindow = ServiceLocator::LocateConsoleWindow();

if (pWindow != nullptr)
{
Expand All @@ -63,7 +64,7 @@ void AccessibilityNotifier::NotifyConsoleCaretEvent(_In_ ConsoleCaretEventFlags

void AccessibilityNotifier::NotifyConsoleUpdateScrollEvent(_In_ LONG x, _In_ LONG y)
{
Microsoft::Console::Types::IConsoleWindow* pWindow = ServiceLocator::LocateConsoleWindow();
IConsoleWindow* pWindow = ServiceLocator::LocateConsoleWindow();
if (pWindow)
{
NotifyWinEvent(EVENT_CONSOLE_UPDATE_SCROLL,
Expand All @@ -75,7 +76,7 @@ void AccessibilityNotifier::NotifyConsoleUpdateScrollEvent(_In_ LONG x, _In_ LON

void AccessibilityNotifier::NotifyConsoleUpdateSimpleEvent(_In_ LONG start, _In_ LONG charAndAttribute)
{
Microsoft::Console::Types::IConsoleWindow* pWindow = ServiceLocator::LocateConsoleWindow();
IConsoleWindow* pWindow = ServiceLocator::LocateConsoleWindow();
if (pWindow)
{
NotifyWinEvent(EVENT_CONSOLE_UPDATE_SIMPLE,
Expand All @@ -87,7 +88,7 @@ void AccessibilityNotifier::NotifyConsoleUpdateSimpleEvent(_In_ LONG start, _In_

void AccessibilityNotifier::NotifyConsoleUpdateRegionEvent(_In_ LONG startXY, _In_ LONG endXY)
{
Microsoft::Console::Types::IConsoleWindow* pWindow = ServiceLocator::LocateConsoleWindow();
IConsoleWindow* pWindow = ServiceLocator::LocateConsoleWindow();
if (pWindow)
{
NotifyWinEvent(EVENT_CONSOLE_UPDATE_REGION,
Expand All @@ -99,7 +100,7 @@ void AccessibilityNotifier::NotifyConsoleUpdateRegionEvent(_In_ LONG startXY, _I

void AccessibilityNotifier::NotifyConsoleLayoutEvent()
{
Microsoft::Console::Types::IConsoleWindow* pWindow = ServiceLocator::LocateConsoleWindow();
IConsoleWindow* pWindow = ServiceLocator::LocateConsoleWindow();
if (pWindow)
{
NotifyWinEvent(EVENT_CONSOLE_LAYOUT,
Expand All @@ -111,7 +112,7 @@ void AccessibilityNotifier::NotifyConsoleLayoutEvent()

void AccessibilityNotifier::NotifyConsoleStartApplicationEvent(_In_ DWORD processId)
{
Microsoft::Console::Types::IConsoleWindow* pWindow = ServiceLocator::LocateConsoleWindow();
IConsoleWindow* pWindow = ServiceLocator::LocateConsoleWindow();
if (pWindow)
{
NotifyWinEvent(EVENT_CONSOLE_START_APPLICATION,
Expand All @@ -123,7 +124,7 @@ void AccessibilityNotifier::NotifyConsoleStartApplicationEvent(_In_ DWORD proces

void AccessibilityNotifier::NotifyConsoleEndApplicationEvent(_In_ DWORD processId)
{
Microsoft::Console::Types::IConsoleWindow* pWindow = ServiceLocator::LocateConsoleWindow();
IConsoleWindow* pWindow = ServiceLocator::LocateConsoleWindow();
if (pWindow)
{
NotifyWinEvent(EVENT_CONSOLE_END_APPLICATION,
Expand Down
5 changes: 3 additions & 2 deletions src/interactivity/win32/windowUiaProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
#include "../host/renderData.hpp"
#include "../inc/ServiceLocator.hpp"

using namespace Microsoft::Console::Types;
using namespace Microsoft::Console::Interactivity::Win32;

WindowUiaProvider::WindowUiaProvider(Microsoft::Console::Types::IConsoleWindow* baseWindow) :
WindowUiaProvider::WindowUiaProvider(IConsoleWindow* baseWindow) :
_pScreenInfoProvider{ nullptr },
WindowUiaProviderBase(baseWindow)
{
Expand All @@ -25,7 +26,7 @@ WindowUiaProvider::~WindowUiaProvider()
}
}

WindowUiaProvider* WindowUiaProvider::Create(Microsoft::Console::Types::IConsoleWindow* baseWindow)
WindowUiaProvider* WindowUiaProvider::Create(IConsoleWindow* baseWindow)
{
WindowUiaProvider* pWindowProvider = nullptr;
Microsoft::Console::Types::ScreenInfoUiaProvider* pScreenInfoProvider = nullptr;
Expand Down
9 changes: 9 additions & 0 deletions src/interactivity/win32/windowUiaProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Author(s):
#include "precomp.h"
#include "../types/WindowUiaProviderBase.hpp"

namespace Microsoft::Console::Types
{
class IConsoleWindow;
}

namespace Microsoft::Console::Interactivity::Win32
{
class WindowUiaProvider final :
Expand All @@ -44,6 +49,10 @@ namespace Microsoft::Console::Interactivity::Win32
_COM_Outptr_result_maybenull_ IRawElementProviderFragment** ppProvider) override;
IFACEMETHODIMP GetFocus(_COM_Outptr_result_maybenull_ IRawElementProviderFragment** ppProvider) override;

protected:
const OLECHAR* AutomationIdPropertyName = L"Console Window";
const OLECHAR* ProviderDescriptionPropertyName = L"Microsoft Console Host Window";

private:
WindowUiaProvider(Microsoft::Console::Types::IConsoleWindow* baseWindow);
~WindowUiaProvider();
Expand Down
20 changes: 10 additions & 10 deletions src/interactivity/win32/windowproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ using namespace Microsoft::Console::Types;
// The static and specific window procedures for this class are contained here
#pragma region Window Procedure

[[nodiscard]] LRESULT CALLBACK Microsoft::Console::Interactivity::Win32::Window::s_ConsoleWindowProc(_In_ HWND hWnd, _In_ UINT Message, _In_ WPARAM wParam, _In_ LPARAM lParam)
[[nodiscard]] LRESULT CALLBACK Window::s_ConsoleWindowProc(_In_ HWND hWnd, _In_ UINT Message, _In_ WPARAM wParam, _In_ LPARAM lParam)
{
// Save the pointer here to the specific window instance when one is created
if (Message == WM_CREATE)
Expand All @@ -61,7 +61,7 @@ using namespace Microsoft::Console::Types;
return DefWindowProcW(hWnd, Message, wParam, lParam);
}

[[nodiscard]] LRESULT CALLBACK Microsoft::Console::Interactivity::Win32::Window::ConsoleWindowProc(_In_ HWND hWnd, _In_ UINT Message, _In_ WPARAM wParam, _In_ LPARAM lParam)
[[nodiscard]] LRESULT CALLBACK Window::ConsoleWindowProc(_In_ HWND hWnd, _In_ UINT Message, _In_ WPARAM wParam, _In_ LPARAM lParam)
{
Globals& g = ServiceLocator::LocateGlobals();
CONSOLE_INFORMATION& gci = g.getConsoleInformation();
Expand Down Expand Up @@ -777,7 +777,7 @@ using namespace Microsoft::Console::Types;
// Helper handler methods for specific cases within the large window procedure are in this section
#pragma region Message Handlers

void Microsoft::Console::Interactivity::Win32::Window::_HandleWindowPosChanged(const LPARAM lParam)
void Window::_HandleWindowPosChanged(const LPARAM lParam)
{
HWND hWnd = GetWindowHandle();
SCREEN_INFORMATION& ScreenInfo = GetScreenInfo();
Expand Down Expand Up @@ -822,7 +822,7 @@ void Microsoft::Console::Interactivity::Win32::Window::_HandleWindowPosChanged(c
// - <none>
// Return Value:
// - S_OK if we succeeded. ERROR_INVALID_HANDLE if there is no HWND. E_FAIL if GDI failed for some reason.
[[nodiscard]] HRESULT Microsoft::Console::Interactivity::Win32::Window::_HandlePaint() const
[[nodiscard]] HRESULT Window::_HandlePaint() const
{
HWND const hwnd = GetWindowHandle();
RETURN_HR_IF_NULL(HRESULT_FROM_WIN32(ERROR_INVALID_HANDLE), hwnd);
Expand Down Expand Up @@ -860,7 +860,7 @@ void Microsoft::Console::Interactivity::Win32::Window::_HandleWindowPosChanged(c
// - Console - Pointer to CONSOLE_INFORMATION structure
// Return Value:
// - <none>
void Microsoft::Console::Interactivity::Win32::Window::_HandleDrop(const WPARAM wParam) const
void Window::_HandleDrop(const WPARAM wParam) const
{
WCHAR szPath[MAX_PATH];
BOOL fAddQuotes;
Expand Down Expand Up @@ -888,7 +888,7 @@ void Microsoft::Console::Interactivity::Win32::Window::_HandleDrop(const WPARAM
}
}

[[nodiscard]] LRESULT Microsoft::Console::Interactivity::Win32::Window::_HandleGetObject(const HWND hwnd, const WPARAM wParam, const LPARAM lParam)
[[nodiscard]] LRESULT Window::_HandleGetObject(const HWND hwnd, const WPARAM wParam, const LPARAM lParam)
{
LRESULT retVal = 0;

Expand All @@ -912,7 +912,7 @@ void Microsoft::Console::Interactivity::Win32::Window::_HandleDrop(const WPARAM
// Dispatchers are used to post or send a window message into the queue from other portions of the codebase without accessing internal properties directly
#pragma region Dispatchers

BOOL Microsoft::Console::Interactivity::Win32::Window::PostUpdateWindowSize() const
BOOL Window::PostUpdateWindowSize() const
{
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
const SCREEN_INFORMATION& ScreenInfo = GetScreenInfo();
Expand All @@ -931,17 +931,17 @@ BOOL Microsoft::Console::Interactivity::Win32::Window::PostUpdateWindowSize() co
return PostMessageW(GetWindowHandle(), CM_SET_WINDOW_SIZE, (WPARAM)&ScreenInfo, 0);
}

BOOL Microsoft::Console::Interactivity::Win32::Window::SendNotifyBeep() const
BOOL Window::SendNotifyBeep() const
{
return SendNotifyMessageW(GetWindowHandle(), CM_BEEP, 0, 0);
}

BOOL Microsoft::Console::Interactivity::Win32::Window::PostUpdateScrollBars() const
BOOL Window::PostUpdateScrollBars() const
{
return PostMessageW(GetWindowHandle(), CM_UPDATE_SCROLL_BARS, (WPARAM)&GetScreenInfo(), 0);
}

BOOL Microsoft::Console::Interactivity::Win32::Window::PostUpdateExtendedEditKeys() const
BOOL Window::PostUpdateExtendedEditKeys() const
{
return PostMessageW(GetWindowHandle(), CM_UPDATE_EDITKEYS, 0, 0);
}
Expand Down
Loading

0 comments on commit b618509

Please sign in to comment.