-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from HalcyonGrid/disable-quick-edit
Added ConsoleMode class and call to disable Quick Edit mode on consoles.
- Loading branch information
Showing
3 changed files
with
44 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace OpenSim.Framework.Console | ||
{ | ||
public static class ConsoleMode | ||
{ | ||
const uint ENABLE_QUICK_EDIT = 0x0040; | ||
const uint ENABLE_EXTENDED_FLAGS = 0x0080; | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
static extern IntPtr GetStdHandle(int nStdHandle); | ||
|
||
[DllImport("kernel32.dll")] | ||
static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint lpMode); | ||
|
||
[DllImport("kernel32.dll")] | ||
static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint dwMode); | ||
|
||
private const int STDIN_HANDLE = -10; | ||
internal static bool DisableQuickEdit() | ||
{ | ||
IntPtr consoleHandle = GetStdHandle(STDIN_HANDLE); | ||
|
||
uint consoleMode; | ||
// get current console mode | ||
if (!GetConsoleMode(consoleHandle, out consoleMode)) | ||
return false; | ||
|
||
// setting QUICK_EDIT mode either way requires EXTENDED | ||
consoleMode |= ENABLE_EXTENDED_FLAGS; | ||
consoleMode &= ~ENABLE_QUICK_EDIT; | ||
return SetConsoleMode(consoleHandle, consoleMode); | ||
} | ||
} | ||
} |
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