This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
676 additions
and
60 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/Common/src/Interop/Unix/System.Native/Interop.GetWindowWidth.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class Sys | ||
{ | ||
[StructLayout(LayoutKind.Sequential)] | ||
private struct WinSize | ||
{ | ||
internal ushort Row; | ||
internal ushort Col; | ||
internal ushort XPixel; | ||
internal ushort YPixel; | ||
}; | ||
|
||
[DllImport(Libraries.SystemNative, SetLastError = true)] | ||
private static extern int GetWindowSize(out WinSize winSize); | ||
|
||
internal static int GetWindowWidth() | ||
{ | ||
WinSize winsize; | ||
|
||
if (GetWindowSize(out winsize) == 0) | ||
{ | ||
return winsize.Col; | ||
} | ||
|
||
return -1; | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Common/src/Interop/Windows/mincore/Interop.ConsoleCursorInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class mincore | ||
{ | ||
[StructLayoutAttribute(LayoutKind.Sequential)] | ||
internal struct CONSOLE_CURSOR_INFO | ||
{ | ||
internal int dwSize; | ||
internal bool bVisible; | ||
} | ||
|
||
[DllImport(Libraries.Console_L2, SetLastError = true)] | ||
internal static extern bool GetConsoleCursorInfo(IntPtr hConsoleOutput, out CONSOLE_CURSOR_INFO cci); | ||
|
||
[DllImport(Libraries.Console_L2, SetLastError = true)] | ||
internal static extern bool SetConsoleCursorInfo(IntPtr hConsoleOutput, ref CONSOLE_CURSOR_INFO cci); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Common/src/Interop/Windows/mincore/Interop.GetLargestConsoleWindowSize.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class mincore | ||
{ | ||
[DllImport(Libraries.Console_L2, SetLastError = true)] | ||
internal static extern Interop.mincore.COORD GetLargestConsoleWindowSize(IntPtr hConsoleOutput); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Common/src/Interop/Windows/mincore/Interop.SetConsoleScreenBufferSize.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class mincore | ||
{ | ||
[DllImport(Libraries.Console_L2, SetLastError = true)] | ||
internal static extern bool SetConsoleScreenBufferSize(IntPtr hConsoleOutput, Interop.mincore.COORD size); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Common/src/Interop/Windows/mincore/Interop.SetConsoleWindowInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class mincore | ||
{ | ||
[DllImport(Libraries.Console_L2, SetLastError = true)] | ||
internal static unsafe extern bool SetConsoleWindowInfo(IntPtr hConsoleOutput, bool absolute, SMALL_RECT* consoleWindow); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.IO; | ||
using System.Text; | ||
|
||
internal sealed class InterceptStreamWriter : StreamWriter | ||
{ | ||
private readonly StreamWriter _wrappedWriter; | ||
|
||
public InterceptStreamWriter(Stream baseStream, StreamWriter wrappedWriter, Encoding encoding, int bufferSize, bool leaveOpen) : | ||
base(baseStream, encoding, bufferSize, leaveOpen) | ||
{ | ||
_wrappedWriter = wrappedWriter; | ||
} | ||
|
||
public override void Write(string value) | ||
{ | ||
base.Write(value); | ||
_wrappedWriter.Write(value); | ||
} | ||
|
||
public override void Write(char value) | ||
{ | ||
base.Write(value); | ||
_wrappedWriter.Write(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.