Skip to content

Commit

Permalink
Merge pull request #2 from dgriffen/dev/dgriffen/minor-cleanup
Browse files Browse the repository at this point in the history
cleanup erroneous code
  • Loading branch information
ZoeyR authored Jul 8, 2019
2 parents 74130f9 + fcb88a5 commit ef9baf9
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 60 deletions.
2 changes: 1 addition & 1 deletion src/cascadia/PublicTerminalCore/PublicTerminalCore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ProjectGuid>{84848BFA-931D-42CE-9ADF-01EE54DE7890}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>PublicTerminalCore</RootNamespace>
<ProjectName>PublicTerminalCore.DLL</ProjectName>
<ProjectName>PublicTerminalCore</ProjectName>
</PropertyGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
Expand Down
12 changes: 6 additions & 6 deletions src/cascadia/WpfTerminalControl/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ internal static class NativeMethods
{
public delegate void ScrollCallback(int viewTop, int viewHeight, int bufferSize);

[DllImport("PublicTerminalCore.DLL.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
[DllImport("PublicTerminalCore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern uint CreateTerminal(IntPtr parent, out IntPtr hwnd, out IntPtr terminal);

[DllImport("PublicTerminalCore.DLL.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
[DllImport("PublicTerminalCore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern void SendTerminalOutput(IntPtr terminal, string lpdata);

[DllImport("PublicTerminalCore.DLL.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
[DllImport("PublicTerminalCore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern uint TriggerResize(IntPtr terminal, double width, double height, out int columns, out int rows);

[DllImport("PublicTerminalCore.DLL.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
[DllImport("PublicTerminalCore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern void DpiChanged(IntPtr terminal, int newDpi);

[DllImport("PublicTerminalCore.DLL.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
[DllImport("PublicTerminalCore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern void RegisterScrollCallback(IntPtr terminal, [MarshalAs(UnmanagedType.FunctionPtr)]ScrollCallback callback);

[DllImport("PublicTerminalCore.DLL.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
[DllImport("PublicTerminalCore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern void UserScroll(IntPtr terminal, int viewTop);

[DllImport("user32.dll", SetLastError = true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace WpfTerminalControl
/// <MyNamespace:TerminalControl/>
///
/// </summary>
public class TerminalControl : HwndHost
public class TerminalContainer : HwndHost
{
private ITerminalConnection connection;
private IntPtr hwnd;
Expand All @@ -61,12 +61,10 @@ public class TerminalControl : HwndHost

public event EventHandler<int> UserScrolled;

public TerminalControl()
public TerminalContainer()
{
//this.SizeChanged += TerminalControl_SizeChanged;
this.PreviewKeyDown += TerminalControl_PreviewKeyDown;
this.MessageHook += TerminalControl_MessageHook;
this.GotFocus += TerminalControl_GotFocus;
this.MessageHook += TerminalContainer_MessageHook;
this.GotFocus += TerminalContainer_GotFocus;
this.Focusable = true;
}

Expand All @@ -80,12 +78,12 @@ protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
NativeMethods.DpiChanged(this.terminal, (int)(96 * newDpi.DpiScaleX));
}

private void TerminalControl_GotFocus(object sender, RoutedEventArgs e)
private void TerminalContainer_GotFocus(object sender, RoutedEventArgs e)
{
NativeMethods.SetFocus(this.hwnd);
}

private IntPtr TerminalControl_MessageHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
private IntPtr TerminalContainer_MessageHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if (hwnd == this.hwnd)
{
Expand Down Expand Up @@ -118,21 +116,6 @@ private IntPtr TerminalControl_MessageHook(IntPtr hwnd, int msg, IntPtr wParam,
return IntPtr.Zero;
}

protected override bool TranslateAcceleratorCore(ref MSG msg, ModifierKeys modifiers)
{
return base.TranslateAcceleratorCore(ref msg, modifiers);
}

private void TerminalControl_PreviewKeyDown(object sender, KeyEventArgs e)
{
var x = e.Key;
}

protected override bool TranslateCharCore(ref MSG msg, ModifierKeys modifiers)
{
return false;
}

private bool HandleChar(char character)
{
if (this.connection == null)
Expand Down Expand Up @@ -191,22 +174,6 @@ private get
}
}

private void TerminalControl_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (this.terminal != IntPtr.Zero)
{
var dpiScale = VisualTreeHelper.GetDpi(this);
NativeMethods.TriggerResize(
this.terminal,
this.ActualWidth * dpiScale.DpiScaleX,
this.ActualHeight * dpiScale.DpiScaleY,
out var columns,
out var rows);

this.connection?.Resize((uint)rows, (uint)columns);
}
}

private void Connection_TerminalDisconnected(object sender, EventArgs e)
{
// TODO
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<UserControl x:Class="WpfTerminalControl.UserControl1"
<UserControl x:Class="WpfTerminalControl.TerminalControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Expand All @@ -7,7 +7,7 @@
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<local:TerminalControl x:Name="termControl" Margin="0,0,17,0"/>
<local:TerminalContainer x:Name="termContainer" Margin="0,0,17,0"/>
<ScrollBar x:Name="scrollbar" Width="17" HorizontalAlignment="Right" ValueChanged="Scrollbar_ValueChanged"/>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ namespace WpfTerminalControl
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class UserControl1 : UserControl
public partial class TerminalControl : UserControl
{
private int accumulatedDelta = 0;

public UserControl1()
public TerminalControl()
{
InitializeComponent();
this.termControl.TerminalScrolled += TermControl_TerminalScrolled;
this.termControl.UserScrolled += TermControl_UserScrolled;
this.termContainer.TerminalScrolled += TermControl_TerminalScrolled;
this.termContainer.UserScrolled += TermControl_UserScrolled;
this.scrollbar.MouseWheel += Scrollbar_MouseWheel;
}

Expand Down Expand Up @@ -57,7 +57,7 @@ public ITerminalConnection Connection
{
set
{
this.termControl.Connection = value;
this.termContainer.Connection = value;
}
}

Expand All @@ -76,7 +76,7 @@ private void TermControl_TerminalScrolled(object sender, (int viewTop, int viewH
private void Scrollbar_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
var viewTop = (int)this.scrollbar.Value;
this.termControl.UserScroll(viewTop);
this.termContainer.UserScroll(viewTop);
}
}
}
2 changes: 1 addition & 1 deletion src/cascadia/WpfTerminalControl/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfTerminalControl">

<Style TargetType="{x:Type local:TerminalControl}">
<Style TargetType="{x:Type local:TerminalContainer}">

</Style>
</ResourceDictionary>
10 changes: 5 additions & 5 deletions src/cascadia/WpfTerminalControl/WpfTerminalControl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,24 @@
<ItemGroup>
<ProjectReference Include="..\PublicTerminalCore\PublicTerminalCore.vcxproj">
<Project>{84848BFA-931D-42CE-9ADF-01EE54DE7890}</Project>
<Name>PublicTerminalCore.DLL</Name>
<Name>PublicTerminalCore</Name>
<OutputItemType>Content</OutputItemType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="ITerminalConnection.cs" />
<Compile Include="NativeMethods.cs" />
<Compile Include="TerminalControl.cs" />
<Compile Include="TerminalContainer.cs" />
<Compile Include="TerminalSettings.cs" />
<Compile Include="UserControl1.xaml.cs">
<DependentUpon>UserControl1.xaml</DependentUpon>
<Compile Include="TerminalControl.xaml.cs">
<DependentUpon>TerminalControl.xaml</DependentUpon>
</Compile>
<Page Include="Themes\Generic.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="UserControl1.xaml">
<Page Include="TerminalControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
Expand Down

0 comments on commit ef9baf9

Please sign in to comment.