mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 02:36:00 +08:00
test: try handle cntr-c another way
This commit is contained in:
@@ -720,9 +720,10 @@ namespace OpenSim.Framework.Console
|
||||
/// </summary>
|
||||
public class CommandConsole : ConsoleBase, ICommandConsole
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public event OnOutputDelegate OnOutput;
|
||||
public static event OnCntrCCelegate OnCntrC;
|
||||
|
||||
public ICommands Commands { get; private set; }
|
||||
|
||||
@@ -794,5 +795,28 @@ namespace OpenSim.Framework.Console
|
||||
public virtual void ReadConfig(IConfigSource configSource)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void SetCntrCHandler(OnCntrCCelegate handler)
|
||||
{
|
||||
if(OnCntrC == null)
|
||||
{
|
||||
OnCntrC += handler;
|
||||
System.Console.CancelKeyPress += CancelKeyPressed;
|
||||
}
|
||||
}
|
||||
|
||||
protected static void CancelKeyPressed(object sender, ConsoleCancelEventArgs args)
|
||||
{
|
||||
if (OnCntrC != null && args.SpecialKey == ConsoleSpecialKey.ControlC)
|
||||
{
|
||||
OnCntrC?.Invoke();
|
||||
args.Cancel = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected static void LocalCancelKeyPressed()
|
||||
{
|
||||
OnCntrC?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,6 +150,8 @@ namespace OpenSim.Framework.Console
|
||||
m_log.InfoFormat("[LOCAL CONSOLE]: Creating new empty command line history file {0}", m_historyPath);
|
||||
File.Create(m_historyPath).Dispose();
|
||||
}
|
||||
|
||||
System.Console.TreatControlCAsInput = true;
|
||||
}
|
||||
|
||||
private void AddToHistory(string text)
|
||||
@@ -413,7 +415,6 @@ namespace OpenSim.Framework.Console
|
||||
else
|
||||
components = null;
|
||||
}
|
||||
|
||||
}
|
||||
string text;
|
||||
if (components == null || components.Length == 0)
|
||||
@@ -492,6 +493,12 @@ namespace OpenSim.Framework.Console
|
||||
Show();
|
||||
|
||||
ConsoleKeyInfo key = System.Console.ReadKey(true);
|
||||
|
||||
if((key.Modifiers & ConsoleModifiers.Control) != 0 && key.Key == ConsoleKey.C)
|
||||
{
|
||||
LocalCancelKeyPressed();
|
||||
return string.Empty;
|
||||
}
|
||||
char enteredChar = key.KeyChar;
|
||||
|
||||
if (!Char.IsControl(enteredChar))
|
||||
|
||||
@@ -75,6 +75,7 @@ namespace OpenSim.Framework.Console
|
||||
public string PasswdPrompt(string p) { return ""; }
|
||||
|
||||
public void ReadConfig(IConfigSource configSource) { }
|
||||
public void SetCntrCHandler(OnCntrCCelegate handler) { }
|
||||
}
|
||||
|
||||
public class MockCommands : ICommands
|
||||
|
||||
Reference in New Issue
Block a user