From 128bf5e58d923bc517fd2456f2559dcb4e31a5ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E5=9B=BD=E4=BC=9F?= <366193849@qq.com>
Date: Mon, 29 Nov 2021 08:40:55 +0800
Subject: [PATCH] =?UTF-8?q?=E7=A6=81=E7=94=A8=E5=BF=AB=E9=80=9F=E7=BC=96?=
=?UTF-8?q?=E8=BE=91=E6=A8=A1=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
FastGithub/ConsoleUtil.cs | 44 +++++++++++++++++++++++++++++++++++++++
FastGithub/Program.cs | 1 +
2 files changed, 45 insertions(+)
create mode 100644 FastGithub/ConsoleUtil.cs
diff --git a/FastGithub/ConsoleUtil.cs b/FastGithub/ConsoleUtil.cs
new file mode 100644
index 0000000..d24f8d5
--- /dev/null
+++ b/FastGithub/ConsoleUtil.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
+
+namespace FastGithub
+{
+ static class ConsoleUtil
+ {
+ private const uint ENABLE_QUICK_EDIT = 0x0040;
+
+ private const int STD_INPUT_HANDLE = -10;
+
+ [DllImport("kernel32.dll", SetLastError = true)]
+ [SupportedOSPlatform("windows")]
+ private static extern IntPtr GetStdHandle(int nStdHandle);
+
+ [DllImport("kernel32.dll", SetLastError = true)]
+ [SupportedOSPlatform("windows")]
+ private static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint lpMode);
+
+ [DllImport("kernel32.dll", SetLastError = true)]
+ [SupportedOSPlatform("windows")]
+ private static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint dwMode);
+
+ ///
+ /// 禁用快速编辑模式
+ ///
+ ///
+ public static bool DisableQuickEdit()
+ {
+ if (OperatingSystem.IsWindows())
+ {
+ var hwnd = GetStdHandle(STD_INPUT_HANDLE);
+ if (GetConsoleMode(hwnd, out uint mode))
+ {
+ mode &= ~ENABLE_QUICK_EDIT;
+ return SetConsoleMode(hwnd, mode);
+ }
+ }
+
+ return false;
+ }
+ }
+}
diff --git a/FastGithub/Program.cs b/FastGithub/Program.cs
index 94b4b87..bb94608 100644
--- a/FastGithub/Program.cs
+++ b/FastGithub/Program.cs
@@ -17,6 +17,7 @@ namespace FastGithub
///
public static void Main(string[] args)
{
+ ConsoleUtil.DisableQuickEdit();
CreateHostBuilder(args).Build().Run();
}