Skip to content

Commit

Permalink
conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
PankajBhojwani committed Apr 2, 2021
2 parents 40ef35f + fd99b01 commit 9fa647e
Show file tree
Hide file tree
Showing 47 changed files with 416 additions and 448 deletions.
66 changes: 66 additions & 0 deletions samples/PixelShaders/Outlines.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// A minimal pixel shader that outlines text

// The terminal graphics as a texture
Texture2D shaderTexture;
SamplerState samplerState;

// Terminal settings such as the resolution of the texture
cbuffer PixelShaderSettings {
// The number of seconds since the pixel shader was enabled
float Time;
// UI Scale
float Scale;
// Resolution of the shaderTexture
float2 Resolution;
// Background color as rgba
float4 Background;
};

// A pixel shader is a program that given a texture coordinate (tex) produces a color.
// tex is an x,y tuple that ranges from 0,0 (top left) to 1,1 (bottom right).
// Just ignore the pos parameter.
float4 main(float4 pos : SV_POSITION, float2 tex : TEXCOORD) : SV_TARGET
{
// Read the color value at the current texture coordinate (tex)
// float4 is tuple of 4 floats, rgba
float4 color = shaderTexture.Sample(samplerState, tex);

// Read the color value at some offset, will be used as shadow. For the best
// effect, read the colors offset on the left, right, top, bottom of this
// fragment, as well as on the corners of this fragment.
//
// You could get away with fewer samples, but the resulting outlines will be
// blurrier.

//left, right, top, bottom:
float4 leftColor = shaderTexture.Sample(samplerState, tex+1.0*Scale*float2( 1.0, 0.0)/Resolution.y);
float4 rightColor = shaderTexture.Sample(samplerState, tex+1.0*Scale*float2(-1.0, 0.0)/Resolution.y);
float4 topColor = shaderTexture.Sample(samplerState, tex+1.0*Scale*float2( 0.0, 1.0)/Resolution.y);
float4 bottomColor = shaderTexture.Sample(samplerState, tex+1.0*Scale*float2( 0.0, -1.0)/Resolution.y);

// Corners
float4 topLeftColor = shaderTexture.Sample(samplerState, tex+1.0*Scale*float2( 1.0, 1.0)/Resolution.y);
float4 topRightColor = shaderTexture.Sample(samplerState, tex+1.0*Scale*float2(-1.0, 1.0)/Resolution.y);
float4 bottomLeftColor = shaderTexture.Sample(samplerState, tex+1.0*Scale*float2( 1.0, -1.0)/Resolution.y);
float4 bottomRightColor = shaderTexture.Sample(samplerState, tex+1.0*Scale*float2(-1.0, -1.0)/Resolution.y);


// Now, if any of those adjacent cells has text in it, then the *color vec4
// will have a non-zero .w (which is used for alpha). Use that alpha value
// to add some black to the current fragment.
//
// This will result in only coloring fragments adjacent to text, but leaving
// background images (for example) untouched.
float3 outlineColor = float3(0, 0, 0);
float4 result = color;
result = result + float4(outlineColor, leftColor.w);
result = result + float4(outlineColor, rightColor.w);
result = result + float4(outlineColor, topColor.w);
result = result + float4(outlineColor, bottomColor.w);

result = result + float4(outlineColor, topLeftColor.w);
result = result + float4(outlineColor, topRightColor.w);
result = result + float4(outlineColor, bottomLeftColor.w);
result = result + float4(outlineColor, bottomRightColor.w);
return result;
}
2 changes: 2 additions & 0 deletions src/cascadia/LocalTests_SettingsModel/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Author(s):

#include <winrt/Microsoft.UI.Xaml.Controls.h>

#include <winrt/Microsoft.Terminal.Core.h>

// Manually include til after we include Windows.Foundation to give it winrt superpowers
#include "til.h"

Expand Down
15 changes: 12 additions & 3 deletions src/cascadia/LocalTests_TerminalApp/TabTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,15 @@ namespace TerminalAppLocalTests
page->Create();
Log::Comment(L"Create()'d the page successfully");

// Build a NewTab action, to make sure we start with one. The real
// Terminal will always get one from AppCommandlineArgs.
NewTerminalArgs newTerminalArgs{};
NewTabArgs args{ newTerminalArgs };
ActionAndArgs newTabAction{ ShortcutAction::NewTab, args };
// push the arg onto the front
page->_startupActions.Append(newTabAction);
Log::Comment(L"Added a single newTab action");

auto app = ::winrt::Windows::UI::Xaml::Application::Current();

winrt::TerminalApp::TerminalPage pp = *page;
Expand All @@ -276,8 +285,9 @@ namespace TerminalAppLocalTests
// In the real app, this isn't a problem, but doesn't happen
// reliably in the unit tests.
Log::Comment(L"Ensure we set the first tab as the selected one.");
auto tab = page->_GetTerminalTabImpl(page->_tabs.GetAt(0));
page->_tabView.SelectedItem(tab->TabViewItem());
auto tab = page->_tabs.GetAt(0);
auto tabImpl = page->_GetTerminalTabImpl(tab);
page->_tabView.SelectedItem(tabImpl->TabViewItem());
page->_UpdatedSelectedTab(0);
});
VERIFY_SUCCEEDED(result);
Expand Down Expand Up @@ -601,7 +611,6 @@ namespace TerminalAppLocalTests
auto result = RunOnUIThread([&page]() {
SplitPaneArgs args{ SplitType::Duplicate };
ActionEventArgs eventArgs{ args };
// eventArgs.Args(args);
page->_HandleSplitPane(nullptr, eventArgs);
auto firstTab = page->_GetTerminalTabImpl(page->_tabs.GetAt(0));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
</ProjectReference>
</ItemGroup>

<Import Project="$(OpenConsoleDir)\build\rules\Branding.targets" />
<Import Project="$(OpenConsoleDir)src\cppwinrt.build.post.props" />

<!-- Override GetPackagingOutputs to roll up our DLL.
Expand Down
4 changes: 2 additions & 2 deletions src/cascadia/TerminalApp/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
<SolidColorBrush x:Name="ErrorTextBrush"
Color="{ThemeResource SystemErrorTextColor}" />

<!-- Suppress all padding except left around the tabs. The TabView looks far better like this. -->
<Thickness x:Key="TabViewHeaderPadding">8,0,0,0</Thickness>
<!-- Suppress top padding -->
<Thickness x:Key="TabViewHeaderPadding">8,0,8,0</Thickness>

<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Dark">
Expand Down
58 changes: 3 additions & 55 deletions src/cascadia/TerminalApp/ShortcutActionDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,61 +41,9 @@ namespace winrt::TerminalApp::implementation

switch (action)
{
ACTION_CASE(CopyText);
ACTION_CASE(PasteText);
ACTION_CASE(OpenNewTabDropdown);
ACTION_CASE(DuplicateTab);
ACTION_CASE(OpenSettings);
ACTION_CASE(NewTab);
ACTION_CASE(CloseWindow);
ACTION_CASE(CloseTab);
ACTION_CASE(ClosePane);
ACTION_CASE(ScrollUp);
ACTION_CASE(ScrollDown);
ACTION_CASE(ScrollUpPage);
ACTION_CASE(ScrollDownPage);
ACTION_CASE(ScrollToTop);
ACTION_CASE(ScrollToBottom);
ACTION_CASE(NextTab);
ACTION_CASE(PrevTab);
ACTION_CASE(SendInput);

case ShortcutAction::SplitVertical:
case ShortcutAction::SplitHorizontal:
case ShortcutAction::SplitPane:
{
_SplitPaneHandlers(*this, eventArgs);
break;
}

ACTION_CASE(TogglePaneZoom);
ACTION_CASE(SwitchToTab);
ACTION_CASE(ResizePane);
ACTION_CASE(MoveFocus);
ACTION_CASE(AdjustFontSize);
ACTION_CASE(Find);
ACTION_CASE(ResetFontSize);
ACTION_CASE(ToggleShaderEffects);
ACTION_CASE(ToggleFocusMode);
ACTION_CASE(ToggleFullscreen);
ACTION_CASE(ToggleAlwaysOnTop);
ACTION_CASE(ToggleCommandPalette);
ACTION_CASE(SetColorScheme);
ACTION_CASE(SetTabColor);
ACTION_CASE(OpenTabColorPicker);
ACTION_CASE(RenameTab);
ACTION_CASE(OpenTabRenamer);
ACTION_CASE(ExecuteCommandline);
ACTION_CASE(CloseOtherTabs);
ACTION_CASE(CloseTabsAfter);
ACTION_CASE(MoveTab);
ACTION_CASE(TabSearch);
ACTION_CASE(BreakIntoDebugger);
ACTION_CASE(FindMatch);
ACTION_CASE(TogglePaneReadOnly);
ACTION_CASE(NewWindow);
ACTION_CASE(IdentifyWindow);
ACTION_CASE(IdentifyWindows);
#define ON_ALL_ACTIONS(id) ACTION_CASE(id);
ALL_SHORTCUT_ACTIONS
#undef ON_ALL_ACTIONS
default:
return false;
}
Expand Down
53 changes: 4 additions & 49 deletions src/cascadia/TerminalApp/ShortcutActionDispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "ShortcutActionDispatch.g.h"
#include "../inc/cppwinrt_utils.h"
#include "../TerminalSettingsModel/AllShortcutActions.h"

// fwdecl unittest classes
namespace TerminalAppLocalTests
Expand All @@ -23,55 +24,9 @@ namespace winrt::TerminalApp::implementation

bool DoAction(const Microsoft::Terminal::Settings::Model::ActionAndArgs& actionAndArgs);

// clang-format off
DECLARE_ACTION(CopyText);
DECLARE_ACTION(PasteText);
DECLARE_ACTION(OpenNewTabDropdown);
DECLARE_ACTION(DuplicateTab);
DECLARE_ACTION(NewTab);
DECLARE_ACTION(CloseWindow);
DECLARE_ACTION(CloseTab);
DECLARE_ACTION(ClosePane);
DECLARE_ACTION(SwitchToTab);
DECLARE_ACTION(NextTab);
DECLARE_ACTION(PrevTab);
DECLARE_ACTION(SendInput);
DECLARE_ACTION(SplitPane);
DECLARE_ACTION(TogglePaneZoom);
DECLARE_ACTION(AdjustFontSize);
DECLARE_ACTION(ResetFontSize);
DECLARE_ACTION(ScrollUp);
DECLARE_ACTION(ScrollDown);
DECLARE_ACTION(ScrollUpPage);
DECLARE_ACTION(ScrollDownPage);
DECLARE_ACTION(ScrollToTop);
DECLARE_ACTION(ScrollToBottom);
DECLARE_ACTION(OpenSettings);
DECLARE_ACTION(ResizePane);
DECLARE_ACTION(Find);
DECLARE_ACTION(MoveFocus);
DECLARE_ACTION(ToggleShaderEffects);
DECLARE_ACTION(ToggleFocusMode);
DECLARE_ACTION(ToggleFullscreen);
DECLARE_ACTION(ToggleAlwaysOnTop);
DECLARE_ACTION(ToggleCommandPalette);
DECLARE_ACTION(SetColorScheme);
DECLARE_ACTION(SetTabColor);
DECLARE_ACTION(OpenTabColorPicker);
DECLARE_ACTION(RenameTab);
DECLARE_ACTION(OpenTabRenamer);
DECLARE_ACTION(ExecuteCommandline);
DECLARE_ACTION(CloseOtherTabs);
DECLARE_ACTION(CloseTabsAfter);
DECLARE_ACTION(TabSearch);
DECLARE_ACTION(MoveTab);
DECLARE_ACTION(BreakIntoDebugger);
DECLARE_ACTION(FindMatch);
DECLARE_ACTION(TogglePaneReadOnly);
DECLARE_ACTION(NewWindow);
DECLARE_ACTION(IdentifyWindow);
DECLARE_ACTION(IdentifyWindows);
// clang-format on
#define ON_ALL_ACTIONS(action) DECLARE_ACTION(action);
ALL_SHORTCUT_ACTIONS
#undef ON_ALL_ACTIONS

private:
friend class TerminalAppLocalTests::SettingsTests;
Expand Down
52 changes: 5 additions & 47 deletions src/cascadia/TerminalApp/ShortcutActionDispatch.idl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "../TerminalSettingsModel/AllShortcutActions.h"

#define ACTION_EVENT(name) event Windows.Foundation.TypedEventHandler<ShortcutActionDispatch, Microsoft.Terminal.Settings.Model.ActionEventArgs> name

Expand All @@ -10,53 +11,10 @@ namespace TerminalApp

Boolean DoAction(Microsoft.Terminal.Settings.Model.ActionAndArgs actionAndArgs);

ACTION_EVENT(CopyText);
ACTION_EVENT(PasteText);
ACTION_EVENT(NewTab);
ACTION_EVENT(OpenNewTabDropdown);
ACTION_EVENT(DuplicateTab);
ACTION_EVENT(CloseWindow);
ACTION_EVENT(CloseTab);
ACTION_EVENT(ClosePane);
ACTION_EVENT(SwitchToTab);
ACTION_EVENT(NextTab);
ACTION_EVENT(PrevTab);
ACTION_EVENT(SendInput);
ACTION_EVENT(SplitPane);
ACTION_EVENT(TogglePaneZoom);
ACTION_EVENT(AdjustFontSize);
ACTION_EVENT(ResetFontSize);
ACTION_EVENT(ScrollUp);
ACTION_EVENT(ScrollDown);
ACTION_EVENT(ScrollUpPage);
ACTION_EVENT(ScrollDownPage);
ACTION_EVENT(ScrollToTop);
ACTION_EVENT(ScrollToBottom);
ACTION_EVENT(OpenSettings);
ACTION_EVENT(ResizePane);
ACTION_EVENT(Find);
ACTION_EVENT(MoveFocus);
ACTION_EVENT(ToggleShaderEffects);
ACTION_EVENT(ToggleFocusMode);
ACTION_EVENT(ToggleFullscreen);
ACTION_EVENT(ToggleAlwaysOnTop);
ACTION_EVENT(ToggleCommandPalette);
ACTION_EVENT(SetColorScheme);
ACTION_EVENT(SetTabColor);
ACTION_EVENT(OpenTabColorPicker);
ACTION_EVENT(RenameTab);
ACTION_EVENT(OpenTabRenamer);
ACTION_EVENT(ExecuteCommandline);
ACTION_EVENT(CloseOtherTabs);
ACTION_EVENT(CloseTabsAfter);
ACTION_EVENT(TabSearch);
ACTION_EVENT(MoveTab);
ACTION_EVENT(BreakIntoDebugger);
ACTION_EVENT(FindMatch);
ACTION_EVENT(TogglePaneReadOnly);
ACTION_EVENT(NewWindow);
ACTION_EVENT(IdentifyWindow);
ACTION_EVENT(IdentifyWindows);
// When adding a new action, add them to AllShortcutActions.h!
#define ON_ALL_ACTIONS(action) ACTION_EVENT(action);
ALL_SHORTCUT_ACTIONS
#undef ON_ALL_ACTIONS

}
}
50 changes: 3 additions & 47 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,53 +949,9 @@ namespace winrt::TerminalApp::implementation
// Hook up the ShortcutActionDispatch object's events to our handlers.
// They should all be hooked up here, regardless of whether or not
// there's an actual keychord for them.
HOOKUP_ACTION(OpenNewTabDropdown);
HOOKUP_ACTION(DuplicateTab);
HOOKUP_ACTION(CloseTab);
HOOKUP_ACTION(ClosePane);
HOOKUP_ACTION(CloseWindow);
HOOKUP_ACTION(ScrollUp);
HOOKUP_ACTION(ScrollDown);
HOOKUP_ACTION(NextTab);
HOOKUP_ACTION(PrevTab);
HOOKUP_ACTION(SendInput);
HOOKUP_ACTION(SplitPane);
HOOKUP_ACTION(TogglePaneZoom);
HOOKUP_ACTION(ScrollUpPage);
HOOKUP_ACTION(ScrollDownPage);
HOOKUP_ACTION(ScrollToTop);
HOOKUP_ACTION(ScrollToBottom);
HOOKUP_ACTION(OpenSettings);
HOOKUP_ACTION(PasteText);
HOOKUP_ACTION(NewTab);
HOOKUP_ACTION(SwitchToTab);
HOOKUP_ACTION(ResizePane);
HOOKUP_ACTION(MoveFocus);
HOOKUP_ACTION(CopyText);
HOOKUP_ACTION(AdjustFontSize);
HOOKUP_ACTION(Find);
HOOKUP_ACTION(ResetFontSize);
HOOKUP_ACTION(ToggleShaderEffects);
HOOKUP_ACTION(ToggleFocusMode);
HOOKUP_ACTION(ToggleFullscreen);
HOOKUP_ACTION(ToggleAlwaysOnTop);
HOOKUP_ACTION(ToggleCommandPalette);
HOOKUP_ACTION(SetColorScheme);
HOOKUP_ACTION(SetTabColor);
HOOKUP_ACTION(OpenTabColorPicker);
HOOKUP_ACTION(RenameTab);
HOOKUP_ACTION(OpenTabRenamer);
HOOKUP_ACTION(ExecuteCommandline);
HOOKUP_ACTION(CloseOtherTabs);
HOOKUP_ACTION(CloseTabsAfter);
HOOKUP_ACTION(TabSearch);
HOOKUP_ACTION(MoveTab);
HOOKUP_ACTION(BreakIntoDebugger);
HOOKUP_ACTION(FindMatch);
HOOKUP_ACTION(TogglePaneReadOnly);
HOOKUP_ACTION(NewWindow);
HOOKUP_ACTION(IdentifyWindow);
HOOKUP_ACTION(IdentifyWindows);
#define ON_ALL_ACTIONS(action) HOOKUP_ACTION(action);
ALL_SHORTCUT_ACTIONS
#undef ON_ALL_ACTIONS
}

// Method Description:
Expand Down
Loading

1 comment on commit 9fa647e

@github-actions

This comment was marked as resolved.

Please sign in to comment.