mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Add keyboard debug routine
This commit is contained in:
parent
9f1ef83680
commit
7c9c12bee7
2 changed files with 21 additions and 12 deletions
|
|
@ -11,7 +11,6 @@ namespace MinecraftClient
|
||||||
/// Allows simultaneous console input and output without breaking user input
|
/// Allows simultaneous console input and output without breaking user input
|
||||||
/// (Without having this annoying behaviour : User inp[Some Console output]ut)
|
/// (Without having this annoying behaviour : User inp[Some Console output]ut)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public static class ConsoleIO
|
public static class ConsoleIO
|
||||||
{
|
{
|
||||||
public static bool basicIO = false;
|
public static bool basicIO = false;
|
||||||
|
|
@ -26,7 +25,6 @@ namespace MinecraftClient
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset the IO mechanism and clear all buffers
|
/// Reset the IO mechanism and clear all buffers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public static void Reset()
|
public static void Reset()
|
||||||
{
|
{
|
||||||
lock (io_lock)
|
lock (io_lock)
|
||||||
|
|
@ -43,7 +41,6 @@ namespace MinecraftClient
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read a password from the standard input
|
/// Read a password from the standard input
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public static string ReadPassword()
|
public static string ReadPassword()
|
||||||
{
|
{
|
||||||
StringBuilder password = new StringBuilder();
|
StringBuilder password = new StringBuilder();
|
||||||
|
|
@ -89,7 +86,6 @@ namespace MinecraftClient
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read a line from the standard input
|
/// Read a line from the standard input
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public static string ReadLine()
|
public static string ReadLine()
|
||||||
{
|
{
|
||||||
if (basicIO) { return Console.ReadLine(); }
|
if (basicIO) { return Console.ReadLine(); }
|
||||||
|
|
@ -203,11 +199,23 @@ namespace MinecraftClient
|
||||||
return buffer + buffer2;
|
return buffer + buffer2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Debug routine
|
||||||
|
/// </summary>
|
||||||
|
public static void DebugReadInput()
|
||||||
|
{
|
||||||
|
ConsoleKeyInfo k = new ConsoleKeyInfo();
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
k = Console.ReadKey(true);
|
||||||
|
Console.WriteLine("Key: {0}\tChar: {1}\tModifiers: {2}", k.Key, k.KeyChar, k.Modifiers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Write a string to the standard output, without newline character
|
/// Write a string to the standard output, without newline character
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public static void Write(string text)
|
public static void Write(string text)
|
||||||
{
|
{
|
||||||
if (!basicIO)
|
if (!basicIO)
|
||||||
|
|
@ -256,7 +264,6 @@ namespace MinecraftClient
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Write a string to the standard output with a trailing newline
|
/// Write a string to the standard output with a trailing newline
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public static void WriteLine(string line)
|
public static void WriteLine(string line)
|
||||||
{
|
{
|
||||||
Write(line + '\n');
|
Write(line + '\n');
|
||||||
|
|
@ -265,7 +272,6 @@ namespace MinecraftClient
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Write a single character to the standard output
|
/// Write a single character to the standard output
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public static void Write(char c)
|
public static void Write(char c)
|
||||||
{
|
{
|
||||||
Write("" + c);
|
Write("" + c);
|
||||||
|
|
@ -276,7 +282,6 @@ namespace MinecraftClient
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="str">String to write</param>
|
/// <param name="str">String to write</param>
|
||||||
/// <param name="acceptnewlines">If false, space are printed instead of newlines</param>
|
/// <param name="acceptnewlines">If false, space are printed instead of newlines</param>
|
||||||
|
|
||||||
public static void WriteLineFormatted(string str, bool acceptnewlines = true)
|
public static void WriteLineFormatted(string str, bool acceptnewlines = true)
|
||||||
{
|
{
|
||||||
if (basicIO) { Console.WriteLine(str); return; }
|
if (basicIO) { Console.WriteLine(str); return; }
|
||||||
|
|
@ -331,7 +336,6 @@ namespace MinecraftClient
|
||||||
/// Write a Minecraft Console Client Log line
|
/// Write a Minecraft Console Client Log line
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="text">Text of the log line</param>
|
/// <param name="text">Text of the log line</param>
|
||||||
|
|
||||||
public static void WriteLogLine(string text)
|
public static void WriteLogLine(string text)
|
||||||
{
|
{
|
||||||
WriteLineFormatted("§8[MCC] " + text);
|
WriteLineFormatted("§8[MCC] " + text);
|
||||||
|
|
@ -438,7 +442,6 @@ namespace MinecraftClient
|
||||||
/// Set an auto-completion engine for TAB autocompletion
|
/// Set an auto-completion engine for TAB autocompletion
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="engine">Engine implementing the IAutoComplete interface</param>
|
/// <param name="engine">Engine implementing the IAutoComplete interface</param>
|
||||||
|
|
||||||
public static void SetAutoCompleteEngine(IAutoComplete engine)
|
public static void SetAutoCompleteEngine(IAutoComplete engine)
|
||||||
{
|
{
|
||||||
autocomplete_engine = engine;
|
autocomplete_engine = engine;
|
||||||
|
|
@ -450,7 +453,6 @@ namespace MinecraftClient
|
||||||
/// Interface for TAB autocompletion
|
/// Interface for TAB autocompletion
|
||||||
/// Allows to use any object which has an AutoComplete() method using the IAutocomplete interface
|
/// Allows to use any object which has an AutoComplete() method using the IAutocomplete interface
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public interface IAutoComplete
|
public interface IAutoComplete
|
||||||
{
|
{
|
||||||
IEnumerable<string> AutoComplete(string BehindCursor);
|
IEnumerable<string> AutoComplete(string BehindCursor);
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,13 @@ namespace MinecraftClient
|
||||||
{
|
{
|
||||||
Console.WriteLine("Console Client for MC {0} to {1} - v{2} - By ORelio & Contributors", MCLowestVersion, MCHighestVersion, Version);
|
Console.WriteLine("Console Client for MC {0} to {1} - v{2} - By ORelio & Contributors", MCLowestVersion, MCHighestVersion, Version);
|
||||||
|
|
||||||
|
//Debug input ?
|
||||||
|
if (args.Length == 1 && args[0] == "--keyboard-debug")
|
||||||
|
{
|
||||||
|
Console.WriteLine("Keyboard debug mode: Press any key to display info");
|
||||||
|
ConsoleIO.DebugReadInput();
|
||||||
|
}
|
||||||
|
|
||||||
//Basic Input/Output ?
|
//Basic Input/Output ?
|
||||||
if (args.Length >= 1 && args[args.Length - 1] == "BasicIO")
|
if (args.Length >= 1 && args[args.Length - 1] == "BasicIO")
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue