2013-07-18 09:27:19 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2022-12-06 15:50:17 +08:00
|
|
|
|
using System.Linq;
|
2013-07-18 09:27:19 +02:00
|
|
|
|
using System.Text;
|
2022-12-06 15:50:17 +08:00
|
|
|
|
using System.Threading;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2022-12-06 20:32:46 +08:00
|
|
|
|
using Brigadier.NET;
|
2022-12-06 15:50:17 +08:00
|
|
|
|
using FuzzySharp;
|
|
|
|
|
|
using MinecraftClient.CommandHandler;
|
|
|
|
|
|
using MinecraftClient.Scripting;
|
|
|
|
|
|
using static MinecraftClient.Settings;
|
2013-07-18 09:27:19 +02:00
|
|
|
|
|
|
|
|
|
|
namespace MinecraftClient
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Allows simultaneous console input and output without breaking user input
|
|
|
|
|
|
/// (Without having this annoying behaviour : User inp[Some Console output]ut)
|
2018-05-28 22:01:51 +02:00
|
|
|
|
/// Provide some fancy features such as formatted output, text pasting and tab-completion.
|
|
|
|
|
|
/// By ORelio - (c) 2012-2018 - Available under the CDDL-1.0 license
|
2013-07-18 09:27:19 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static class ConsoleIO
|
|
|
|
|
|
{
|
2022-10-02 18:31:08 +08:00
|
|
|
|
private static IAutoComplete? autocomplete_engine;
|
2015-05-10 18:57:33 +02:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2015-05-13 10:59:46 +02:00
|
|
|
|
/// Reset the IO mechanism and clear all buffers
|
2015-05-10 18:57:33 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static void Reset()
|
|
|
|
|
|
{
|
2022-07-03 22:34:07 +08:00
|
|
|
|
ClearLineAndBuffer();
|
2015-05-10 18:57:33 +02:00
|
|
|
|
}
|
2013-07-18 09:27:19 +02:00
|
|
|
|
|
2018-05-28 22:01:51 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Set an auto-completion engine for TAB autocompletion.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="engine">Engine implementing the IAutoComplete interface</param>
|
|
|
|
|
|
public static void SetAutoCompleteEngine(IAutoComplete engine)
|
|
|
|
|
|
{
|
|
|
|
|
|
autocomplete_engine = engine;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Determines whether to use interactive IO or basic IO.
|
|
|
|
|
|
/// Set to true to disable interactive command prompt and use the default Console.Read|Write() methods.
|
|
|
|
|
|
/// Color codes are printed as is when BasicIO is enabled.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static bool BasicIO = false;
|
|
|
|
|
|
|
2020-05-14 13:36:56 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Determines whether not to print color codes in BasicIO mode.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static bool BasicIO_NoColor = false;
|
|
|
|
|
|
|
2018-05-28 22:01:51 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Determine whether WriteLineFormatted() should prepend lines with timestamps by default.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static bool EnableTimestamps = false;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Specify a generic log line prefix for WriteLogLine()
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static string LogPrefix = "§8[Log] ";
|
|
|
|
|
|
|
2014-05-31 01:59:03 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Read a password from the standard input
|
|
|
|
|
|
/// </summary>
|
2022-08-15 23:55:44 +08:00
|
|
|
|
public static string? ReadPassword()
|
2013-08-23 10:48:26 +02:00
|
|
|
|
{
|
2022-07-03 22:34:07 +08:00
|
|
|
|
if (BasicIO)
|
|
|
|
|
|
return Console.ReadLine();
|
|
|
|
|
|
else
|
2013-08-23 10:48:26 +02:00
|
|
|
|
{
|
2022-07-03 22:34:07 +08:00
|
|
|
|
ConsoleInteractive.ConsoleReader.SetInputVisible(false);
|
|
|
|
|
|
var input = ConsoleInteractive.ConsoleReader.RequestImmediateInput();
|
|
|
|
|
|
ConsoleInteractive.ConsoleReader.SetInputVisible(true);
|
|
|
|
|
|
return input;
|
2013-08-23 10:48:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-05-31 01:59:03 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Read a line from the standard input
|
|
|
|
|
|
/// </summary>
|
2013-07-18 09:27:19 +02:00
|
|
|
|
public static string ReadLine()
|
|
|
|
|
|
{
|
2018-05-28 22:01:51 +02:00
|
|
|
|
if (BasicIO)
|
2022-10-02 18:31:08 +08:00
|
|
|
|
return Console.ReadLine() ?? String.Empty;
|
|
|
|
|
|
else
|
2022-07-03 22:34:07 +08:00
|
|
|
|
return ConsoleInteractive.ConsoleReader.RequestImmediateInput();
|
2013-07-18 09:27:19 +02:00
|
|
|
|
}
|
2017-05-28 15:09:19 +02:00
|
|
|
|
|
2014-05-31 01:59:03 +02:00
|
|
|
|
/// <summary>
|
2018-05-28 22:01:51 +02:00
|
|
|
|
/// Debug routine: print all keys pressed in the console
|
2014-05-31 01:59:03 +02:00
|
|
|
|
/// </summary>
|
2017-05-28 15:09:19 +02:00
|
|
|
|
public static void DebugReadInput()
|
|
|
|
|
|
{
|
2022-10-02 18:31:08 +08:00
|
|
|
|
ConsoleKeyInfo k;
|
2017-05-28 15:09:19 +02:00
|
|
|
|
while (true)
|
|
|
|
|
|
{
|
|
|
|
|
|
k = Console.ReadKey(true);
|
|
|
|
|
|
Console.WriteLine("Key: {0}\tChar: {1}\tModifiers: {2}", k.Key, k.KeyChar, k.Modifiers);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2013-07-18 09:27:19 +02:00
|
|
|
|
|
2014-05-31 01:59:03 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Write a string to the standard output with a trailing newline
|
|
|
|
|
|
/// </summary>
|
2013-07-18 09:27:19 +02:00
|
|
|
|
public static void WriteLine(string line)
|
|
|
|
|
|
{
|
2022-07-03 22:34:07 +08:00
|
|
|
|
if (BasicIO)
|
|
|
|
|
|
Console.WriteLine(line);
|
|
|
|
|
|
else
|
|
|
|
|
|
ConsoleInteractive.ConsoleWriter.WriteLine(line);
|
2013-07-18 09:27:19 +02:00
|
|
|
|
}
|
2014-05-31 01:59:03 +02:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-05-28 22:01:51 +02:00
|
|
|
|
/// Write a Minecraft-Like formatted string to the standard output, using §c color codes
|
2023-10-07 04:59:08 -05:00
|
|
|
|
/// <see href="https://minecraft.wiki/w/Classic_server_protocol#Color_codes"/> for more info
|
2014-05-31 01:59:03 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="str">String to write</param>
|
|
|
|
|
|
/// <param name="acceptnewlines">If false, space are printed instead of newlines</param>
|
2019-10-03 09:46:08 +02:00
|
|
|
|
/// <param name="displayTimestamp">
|
2018-05-28 22:01:51 +02:00
|
|
|
|
/// If false, no timestamp is prepended.
|
|
|
|
|
|
/// If true, "hh-mm-ss" timestamp will be prepended.
|
|
|
|
|
|
/// If unspecified, value is retrieved from EnableTimestamps.
|
|
|
|
|
|
/// </param>
|
2022-07-03 22:34:07 +08:00
|
|
|
|
public static void WriteLineFormatted(string str, bool acceptnewlines = false, bool? displayTimestamp = null)
|
2014-05-31 01:59:03 +02:00
|
|
|
|
{
|
2022-10-02 18:31:08 +08:00
|
|
|
|
StringBuilder output = new();
|
|
|
|
|
|
|
2014-05-31 01:59:03 +02:00
|
|
|
|
if (!String.IsNullOrEmpty(str))
|
|
|
|
|
|
{
|
2022-10-02 18:31:08 +08:00
|
|
|
|
displayTimestamp ??= EnableTimestamps;
|
2022-08-16 00:17:30 +08:00
|
|
|
|
if (displayTimestamp.Value)
|
2014-05-31 01:59:03 +02:00
|
|
|
|
{
|
|
|
|
|
|
int hour = DateTime.Now.Hour, minute = DateTime.Now.Minute, second = DateTime.Now.Second;
|
2022-07-03 22:34:07 +08:00
|
|
|
|
output.Append(String.Format("{0}:{1}:{2} ", hour.ToString("00"), minute.ToString("00"), second.ToString("00")));
|
2014-05-31 01:59:03 +02:00
|
|
|
|
}
|
2022-08-16 00:17:30 +08:00
|
|
|
|
if (!acceptnewlines)
|
|
|
|
|
|
{
|
|
|
|
|
|
str = str.Replace('\n', ' ');
|
|
|
|
|
|
}
|
2018-05-28 22:01:51 +02:00
|
|
|
|
if (BasicIO)
|
|
|
|
|
|
{
|
2020-05-14 13:36:56 -04:00
|
|
|
|
if (BasicIO_NoColor)
|
|
|
|
|
|
{
|
2022-07-03 22:34:07 +08:00
|
|
|
|
output.Append(ChatBot.GetVerbatim(str));
|
2020-05-14 13:36:56 -04:00
|
|
|
|
}
|
2022-08-16 00:17:30 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Append(str);
|
|
|
|
|
|
}
|
2022-07-03 22:34:07 +08:00
|
|
|
|
Console.WriteLine(output.ToString());
|
2018-05-28 22:01:51 +02:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2022-08-16 00:17:30 +08:00
|
|
|
|
output.Append(str);
|
2022-07-03 22:34:07 +08:00
|
|
|
|
ConsoleInteractive.ConsoleWriter.WriteLineFormatted(output.ToString());
|
2014-05-31 01:59:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2013-07-18 09:27:19 +02:00
|
|
|
|
|
2015-06-21 16:40:13 +02:00
|
|
|
|
/// <summary>
|
2018-05-28 22:01:51 +02:00
|
|
|
|
/// Write a prefixed log line. Prefix is set in LogPrefix.
|
2015-06-21 16:40:13 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="text">Text of the log line</param>
|
2020-04-01 21:15:35 +02:00
|
|
|
|
/// <param name="acceptnewlines">Allow line breaks</param>
|
|
|
|
|
|
public static void WriteLogLine(string text, bool acceptnewlines = true)
|
2015-06-21 16:40:13 +02:00
|
|
|
|
{
|
2020-04-01 21:15:35 +02:00
|
|
|
|
if (!acceptnewlines)
|
|
|
|
|
|
text = text.Replace('\n', ' ');
|
2022-09-01 23:10:09 +08:00
|
|
|
|
WriteLineFormatted(LogPrefix + text, acceptnewlines);
|
2015-06-21 16:40:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-01-11 12:48:59 +01:00
|
|
|
|
#region Subfunctions
|
2018-05-28 22:01:51 +02:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Clear all text inside the input prompt
|
|
|
|
|
|
/// </summary>
|
2013-07-18 09:27:19 +02:00
|
|
|
|
private static void ClearLineAndBuffer()
|
|
|
|
|
|
{
|
2022-07-03 22:34:07 +08:00
|
|
|
|
if (BasicIO) return;
|
|
|
|
|
|
ConsoleInteractive.ConsoleReader.ClearBuffer();
|
2013-07-18 09:27:19 +02:00
|
|
|
|
}
|
2018-05-28 22:01:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
2013-07-18 09:27:19 +02:00
|
|
|
|
#endregion
|
2014-01-11 12:48:59 +01:00
|
|
|
|
|
2022-12-06 15:50:17 +08:00
|
|
|
|
internal static bool AutoCompleteDone = false;
|
|
|
|
|
|
internal static string[] AutoCompleteResult = Array.Empty<string>();
|
|
|
|
|
|
|
|
|
|
|
|
private static HashSet<string> Commands = new();
|
|
|
|
|
|
private static string[] CommandsFromAutoComplete = Array.Empty<string>();
|
|
|
|
|
|
private static string[] CommandsFromDeclareCommands = Array.Empty<string>();
|
|
|
|
|
|
|
|
|
|
|
|
private static Task _latestTask = Task.CompletedTask;
|
|
|
|
|
|
private static CancellationTokenSource? _cancellationTokenSource;
|
|
|
|
|
|
|
|
|
|
|
|
private static void MccAutocompleteHandler(ConsoleInteractive.ConsoleReader.Buffer buffer)
|
2014-01-11 12:48:59 +01:00
|
|
|
|
{
|
2022-12-06 15:50:17 +08:00
|
|
|
|
string fullCommand = buffer.Text;
|
|
|
|
|
|
if (string.IsNullOrEmpty(fullCommand))
|
|
|
|
|
|
{
|
|
|
|
|
|
ConsoleInteractive.ConsoleSuggestion.ClearSuggestions();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var InternalCmdChar = Config.Main.Advanced.InternalCmdChar;
|
2024-04-16 21:21:08 +03:00
|
|
|
|
if (InternalCmdChar == MainConfigHelper.MainConfig.AdvancedConfig.InternalCmdCharType.none || fullCommand[0] == InternalCmdChar.ToChar())
|
2022-12-06 15:50:17 +08:00
|
|
|
|
{
|
2024-04-16 21:21:08 +03:00
|
|
|
|
int offset = InternalCmdChar == MainConfigHelper.MainConfig.AdvancedConfig.InternalCmdCharType.none ? 0 : 1;
|
2022-12-06 15:50:17 +08:00
|
|
|
|
if (buffer.CursorPosition - offset < 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
ConsoleInteractive.ConsoleSuggestion.ClearSuggestions();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
_cancellationTokenSource?.Cancel();
|
|
|
|
|
|
using var cts = new CancellationTokenSource();
|
|
|
|
|
|
_cancellationTokenSource = cts;
|
|
|
|
|
|
var previousTask = _latestTask;
|
|
|
|
|
|
var newTask = new Task(async () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
string command = fullCommand[offset..];
|
|
|
|
|
|
if (command.Length == 0)
|
|
|
|
|
|
{
|
2022-12-11 13:00:19 +08:00
|
|
|
|
List<ConsoleInteractive.ConsoleSuggestion.Suggestion> sugList = new();
|
|
|
|
|
|
|
|
|
|
|
|
sugList.Add(new("/"));
|
|
|
|
|
|
|
2022-12-11 16:30:45 +08:00
|
|
|
|
var childs = McClient.dispatcher.GetRoot().Children;
|
2022-12-11 13:00:19 +08:00
|
|
|
|
if (childs != null)
|
|
|
|
|
|
foreach (var child in childs)
|
|
|
|
|
|
sugList.Add(new(child.Name));
|
2022-12-06 15:50:17 +08:00
|
|
|
|
|
|
|
|
|
|
foreach (var cmd in Commands)
|
2022-12-11 13:00:19 +08:00
|
|
|
|
sugList.Add(new(cmd));
|
|
|
|
|
|
|
|
|
|
|
|
ConsoleInteractive.ConsoleSuggestion.UpdateSuggestions(sugList.ToArray(), new(offset, offset));
|
2022-12-06 15:50:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
else if (command.Length > 0 && command[0] == '/' && !command.Contains(' '))
|
|
|
|
|
|
{
|
|
|
|
|
|
var sorted = Process.ExtractSorted(command[1..], Commands);
|
|
|
|
|
|
var sugList = new ConsoleInteractive.ConsoleSuggestion.Suggestion[sorted.Count()];
|
|
|
|
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
foreach (var sug in sorted)
|
|
|
|
|
|
sugList[index++] = new(sug.Value);
|
|
|
|
|
|
ConsoleInteractive.ConsoleSuggestion.UpdateSuggestions(sugList, new(offset, offset + command.Length));
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2022-12-11 16:30:45 +08:00
|
|
|
|
CommandDispatcher<CmdResult>? dispatcher = McClient.dispatcher;
|
2022-12-11 13:00:19 +08:00
|
|
|
|
if (dispatcher == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
ParseResults<CmdResult> parse = dispatcher.Parse(command, CmdResult.Empty);
|
2022-12-06 15:50:17 +08:00
|
|
|
|
|
2022-12-11 13:00:19 +08:00
|
|
|
|
Brigadier.NET.Suggestion.Suggestions suggestions = await dispatcher.GetCompletionSuggestions(parse, buffer.CursorPosition - offset);
|
2022-12-06 15:50:17 +08:00
|
|
|
|
|
2022-12-11 13:00:19 +08:00
|
|
|
|
int sugLen = suggestions.List.Count;
|
2022-12-06 15:50:17 +08:00
|
|
|
|
if (sugLen == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
ConsoleInteractive.ConsoleSuggestion.ClearSuggestions();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-11 13:00:19 +08:00
|
|
|
|
Dictionary<string, string?> dictionary = new();
|
|
|
|
|
|
foreach (var sug in suggestions.List)
|
|
|
|
|
|
dictionary.Add(sug.Text, sug.Tooltip?.String);
|
|
|
|
|
|
|
2022-12-06 15:50:17 +08:00
|
|
|
|
var sugList = new ConsoleInteractive.ConsoleSuggestion.Suggestion[sugLen];
|
|
|
|
|
|
if (cts.IsCancellationRequested)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2022-12-11 13:00:19 +08:00
|
|
|
|
Tuple<int, int> range = new(suggestions.Range.Start + offset, suggestions.Range.End + offset);
|
|
|
|
|
|
var sorted = Process.ExtractSorted(fullCommand[range.Item1..range.Item2], dictionary.Keys);
|
2022-12-06 15:50:17 +08:00
|
|
|
|
if (cts.IsCancellationRequested)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
foreach (var sug in sorted)
|
2022-12-11 13:00:19 +08:00
|
|
|
|
sugList[index++] = new(sug.Value, dictionary[sug.Value] ?? string.Empty);
|
2022-10-02 18:31:08 +08:00
|
|
|
|
|
2022-12-06 15:50:17 +08:00
|
|
|
|
ConsoleInteractive.ConsoleSuggestion.UpdateSuggestions(sugList, range);
|
|
|
|
|
|
}
|
|
|
|
|
|
}, cts.Token);
|
|
|
|
|
|
_latestTask = newTask;
|
|
|
|
|
|
try { newTask.Start(); } catch { }
|
|
|
|
|
|
if (_cancellationTokenSource == cts) _cancellationTokenSource = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
ConsoleInteractive.ConsoleSuggestion.ClearSuggestions();
|
2022-07-03 22:34:07 +08:00
|
|
|
|
return;
|
2022-12-06 15:50:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void AutocompleteHandler(object? sender, ConsoleInteractive.ConsoleReader.Buffer buffer)
|
|
|
|
|
|
{
|
2022-12-11 13:00:19 +08:00
|
|
|
|
if (Settings.Config.Console.CommandSuggestion.Enable)
|
|
|
|
|
|
MccAutocompleteHandler(buffer);
|
2022-12-06 15:50:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void CancelAutocomplete()
|
|
|
|
|
|
{
|
|
|
|
|
|
_cancellationTokenSource?.Cancel();
|
|
|
|
|
|
_latestTask = Task.CompletedTask;
|
|
|
|
|
|
ConsoleInteractive.ConsoleSuggestion.ClearSuggestions();
|
|
|
|
|
|
|
|
|
|
|
|
AutoCompleteDone = false;
|
|
|
|
|
|
AutoCompleteResult = Array.Empty<string>();
|
|
|
|
|
|
CommandsFromAutoComplete = Array.Empty<string>();
|
|
|
|
|
|
CommandsFromDeclareCommands = Array.Empty<string>();
|
|
|
|
|
|
}
|
2022-10-02 18:31:08 +08:00
|
|
|
|
|
2022-12-06 15:50:17 +08:00
|
|
|
|
private static void MergeCommands()
|
|
|
|
|
|
{
|
|
|
|
|
|
Commands.Clear();
|
|
|
|
|
|
foreach (string cmd in CommandsFromAutoComplete)
|
|
|
|
|
|
Commands.Add('/' + cmd);
|
|
|
|
|
|
foreach (string cmd in CommandsFromDeclareCommands)
|
|
|
|
|
|
Commands.Add('/' + cmd);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void OnAutoCompleteDone(int transactionId, string[] result)
|
|
|
|
|
|
{
|
|
|
|
|
|
AutoCompleteResult = result;
|
|
|
|
|
|
if (transactionId == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
CommandsFromAutoComplete = result;
|
|
|
|
|
|
MergeCommands();
|
|
|
|
|
|
}
|
|
|
|
|
|
AutoCompleteDone = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void OnDeclareMinecraftCommand(string[] rootCommands)
|
|
|
|
|
|
{
|
|
|
|
|
|
CommandsFromDeclareCommands = rootCommands;
|
|
|
|
|
|
MergeCommands();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-06 20:32:46 +08:00
|
|
|
|
public static void InitCommandList(CommandDispatcher<CmdResult> dispatcher)
|
2022-12-06 15:50:17 +08:00
|
|
|
|
{
|
|
|
|
|
|
autocomplete_engine!.AutoComplete("/");
|
2014-01-11 12:48:59 +01:00
|
|
|
|
}
|
2013-07-18 09:27:19 +02:00
|
|
|
|
}
|
2013-08-06 12:25:09 +02:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Interface for TAB autocompletion
|
|
|
|
|
|
/// Allows to use any object which has an AutoComplete() method using the IAutocomplete interface
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public interface IAutoComplete
|
|
|
|
|
|
{
|
2018-05-28 22:01:51 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Provide a list of auto-complete strings based on the provided input behing the cursor
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="BehindCursor">Text behind the cursor, e.g. "my input comm"</param>
|
|
|
|
|
|
/// <returns>List of auto-complete words, e.g. ["command", "comment"]</returns>
|
2022-12-06 15:50:17 +08:00
|
|
|
|
int AutoComplete(string BehindCursor);
|
2013-08-06 12:25:09 +02:00
|
|
|
|
}
|
2013-07-18 09:27:19 +02:00
|
|
|
|
}
|