public void Update(GameTime time, IConsoleInput input) { foreach (var item in Components) { item.Update(time, input); } }
public ClientConsole( IConsoleInput consoleInput, IConsoleRender consoleRender) { _consoleInput = consoleInput; _consoleRender = consoleRender; }
public Command(IConsoleInput consoleInput, IStandardMessages standardMessages, IErrorMessages errorMessages, IValidator validator) { _consoleInput = consoleInput; _standardMessages = standardMessages; _errorMessages = errorMessages; _validator = validator; }
public static ICommand CreateCommand() { IConsoleInput input = CreateConsoleInput(); IStandardMessages standardMessages = CreateStandardMessages(); IErrorMessages errorMessages = CreateErrorMessages(); IValidator validator = CreateValidator(); return(new Command(input, standardMessages, errorMessages, validator)); }
public GameManager(IFieldView fieldView, IConsoleInput consoleInput, IBuilder builder, IRandom random, IBorderChecker borderChecker, IEmptyCellProvider emptyCellProvider) { _consoleInput = consoleInput; _builder = builder; _fieldView = fieldView; _random = random; _borderChecker = borderChecker; _emptyCellProvider = emptyCellProvider; }
public void Update(GameTime time, IConsoleInput input) { var updatables = this.Behaviours.Where(n => n.GetType().IsAssignableFrom(typeof(IUpdatable))).Cast <IUpdatable>(); foreach (var updater in updatables) { updater.Update(time, input); } }
public Input(InputType inputType, String filename, IStandardMessages standardMessages, IConsoleInput consoleInput, IFileInput fileInput) { _inputType = inputType; _filename = filename; _standardMessages = standardMessages; _consoleInput = consoleInput; _fileInput = fileInput; }
/// <summary> /// Primary constructor. /// </summary> /// <param name="lineInput">Line input engine.</param> /// <param name="consoleInput">Interface for interacting with the input /// console; a default implementation is used if this parameter is null. /// </param> /// <param name="consoleOutput">Interface for interacting with the output /// console; a default implementation is used if this parameter is null. /// </param> /// <param name="keyBindingSet">The key bindings to use in the reader. /// Default bindings are used if this parameter is null.</param> public ConsoleReader(IConsoleLineInput lineInput = null, IConsoleInput consoleInput = null, IConsoleOutput consoleOutput = null, IReadOnlyConsoleKeyBindingSet keyBindingSet = null) { ConsoleInput = consoleInput ?? BasicConsoleInputAndOutput.Default; ConsoleOutput = consoleOutput ?? BasicConsoleInputAndOutput.Default; KeyBindingSet = keyBindingSet ?? ConsoleKeyBindingSet.Default; LineInput = lineInput ?? new ConsoleLineInput(ConsoleOutput, new ConsoleInputBuffer(), new ConsoleHistory(), null); _defaultCursorSize = ConsoleOutput.CursorSize; }
public ClientConsole( ILogShipping logShipping, IConsoleInput consoleInput, IConsoleRender consoleRender) { _logShipping = logShipping; _consoleInput = consoleInput; _consoleRender = consoleRender; }
private static bool TryAutocomplete(IConsoleInput input, string commandString) { if (commandString.StartsWith(input.LastAutocompleteEntry, StringComparisonMethod)) { input.Clear(); input.Append(commandString); return(true); } return(false); }
private static async Task CommandLoopAsync(IConsoleInput consoleInput) { var command = ReadCommand(); while (command != "exit") { await consoleInput.ExecuteCommandAsync(command).ConfigureAwait(false); command = ReadCommand(); } }
public Console(IConsoleInput consoleReader, V8ScriptEngine evaluator) { this.evaluator = evaluator; ConsoleReader = consoleReader; DataStream = new PipeableStream(evaluator); AltStream = new PipeableStream(evaluator); LogStream = new PipeableStream(evaluator); ErrorStream = new PipeableStream(evaluator); CoreStream = new PipeableStream(evaluator); CommandStream = new PipeableStream(evaluator); ResultStream = new PipeableStream(evaluator); }
public PlayerService( GanzenBoardGame.Application.Logging.ILogger logger, IConsoleInput consoleInput, INumbervalidator numberValidator, IStringValidatie stringValidatie, IDateTimeValidatie dateTimeValidatie) { _logger = logger; _consoleInput = consoleInput; _numberValidator = numberValidator; _stringValidatie = stringValidatie; _dateTimeValidatie = dateTimeValidatie; }
/// <summary> /// Primary constructor. /// </summary> /// <param name="lineInput">Line input engine.</param> /// <param name="consoleInput">Interface for interacting with the input /// console; a default implementation is used if this parameter is null. /// </param> /// <param name="consoleOutput">Interface for interacting with the output /// console; a default implementation is used if this parameter is null. /// </param> /// <param name="keyBindingSet">The key bindings to use in the reader. /// Default bindings are used if this parameter is null.</param> public ConsoleReader(IConsoleLineInput lineInput, IConsoleInput consoleInput = null, IConsoleOutput consoleOutput = null, IReadOnlyConsoleKeyBindingSet keyBindingSet = null) { if (lineInput == null) { throw new ArgumentNullException(nameof(lineInput)); } LineInput = lineInput; ConsoleInput = consoleInput ?? BasicConsoleInputAndOutput.Default; ConsoleOutput = consoleOutput ?? BasicConsoleInputAndOutput.Default; KeyBindingSet = keyBindingSet ?? ConsoleKeyBindingSet.Default; _defaultCursorSize = ConsoleOutput.CursorSize; }
public static InstructionBase GetInstruction(long[] program, long pc, IConsoleInput input, IConsoleOutput output, IMemoryController memoryController) { var instructionCode = program[pc]; InstructionBase instruction = null; switch (ParseInstructionCode(instructionCode)) { case OptCode.OptCode1: instruction = new Instruction01(instructionCode, memoryController); break; case OptCode.OptCode2: instruction = new Instruction02(instructionCode, memoryController); break; case OptCode.OptCode3: instruction = new Instruction03(instructionCode, input, memoryController); break; case OptCode.OptCode4: instruction = new Instruction04(instructionCode, output, memoryController); break; case OptCode.OptCode5: instruction = new Instruction05(instructionCode, memoryController); break; case OptCode.OptCode6: instruction = new Instruction06(instructionCode, memoryController); break; case OptCode.OptCode7: instruction = new Instruction07(instructionCode, memoryController); break; case OptCode.OptCode8: instruction = new Instruction08(instructionCode, memoryController); break; case OptCode.OptCode9: instruction = new Instruction09(instructionCode, memoryController); break; default: instruction = null; break; } return(instruction); }
/// <summary> /// Tries to autocomplete the current input value in the <see cref="Console"/> <see cref="ConsoleInput"/>. /// </summary> /// <param name="input">Console input.</param> /// <param name="forward">True if user wants to autocomplete to the next value; false if to the previous value.</param> public void Autocomplete(IConsoleInput input, bool forward) { if (_autocompleteEntries == null) { _autocompleteEntries = _commandMap.Keys.OrderBy(x => x).ToArray(); } if (_autocompleteEntries.Length == 0) { return; } string currentInput = input.Value; int index = _autocompleteEntries.IndexOf(x => x.Equals(currentInput, StringComparisonMethod)); if (index == -1 || input.LastAutocompleteEntry == null) { input.LastAutocompleteEntry = currentInput; } if (forward) { index = (index + 1) % _autocompleteEntries.Length; for (int i = index; i < _autocompleteEntries.Length; ++i) { if (TryAutocomplete(input, _autocompleteEntries[i])) { return; } } } else { index--; if (index == -1) { index = _autocompleteEntries.Length - 1; } for (int i = index; i >= 0; --i) { if (TryAutocomplete(input, _autocompleteEntries[i])) { return; } } } }
private static void FindAutocompleteForEntries(IConsoleInput consoleInput, IList <string> autocompleteEntries, string command, int startIndex, bool isNextValue, AutocompletionType completionType) { int index = autocompleteEntries.IndexOf(x => x.Equals(command, StringComparison.Ordinal)); if (index == -1 || consoleInput.LastAutocompleteEntry == null) { consoleInput.LastAutocompleteEntry = command; } string inputEntry = consoleInput.LastAutocompleteEntry; Func <string, bool> predicate = x => x.StartsWith(inputEntry, StringComparison.Ordinal); int firstIndex = autocompleteEntries.IndexOf(predicate); if (firstIndex == -1) { return; } int lastIndex = autocompleteEntries.LastIndexOf(predicate); if (index == -1) { index = firstIndex - 1; } if (isNextValue) { index++; if (index > lastIndex) { index = firstIndex; } } else { index--; if (index < firstIndex) { index = lastIndex; } } string autocompleteValue = autocompleteEntries[index]; //if (completionType == AutocompletionType.Regular) // autocompleteValue = nameof(ExpandoWrapper.globals) + AccessorSymbol + autocompleteValue; SetAutocompleteValue(consoleInput, startIndex, autocompleteValue); }
private static int FindPreviousLinkEndIndex(IConsoleInput consoleInput, int startIndex) { int chainEndIndex = -1; for (int i = startIndex; i >= 0; i--) { if (consoleInput[i] == AccessorSymbol || consoleInput[i] == AssignmentSymbol || consoleInput[i] == FunctionStartSymbol) { chainEndIndex = i - 1; break; } } return(chainEndIndex); }
public HumanMoverSystem(IScene scene, IConsoleInput input) { GameEntity?entity = scene.GetEntity <Transform, HumanMover>(); if (entity.HasValue) { _transIndex = entity.Value.ComponentIndices[0]; _transforms = scene.GetComponents <Transform>(); _mover = scene.GetComponents <HumanMover>()[entity.Value.ComponentIndices[1]]; _continuousLeft = _transforms[_transIndex].LocalLeft; _continuousTop = _transforms[_transIndex].LocalTop; } _input = input; }
private static void FindAutocompleteForEntries(IConsoleInput consoleInput, IList <string> autocompleteEntries, string command, int startIndex, bool isNextValue) { int index = autocompleteEntries.IndexOf(x => x.Equals(command, PythonInterpreter.StringComparisonMethod)); if (index == -1 || consoleInput.LastAutocompleteEntry == null) { consoleInput.LastAutocompleteEntry = command; } string inputEntry = consoleInput.LastAutocompleteEntry; Func <string, bool> predicate = x => x.StartsWith(inputEntry, PythonInterpreter.StringComparisonMethod); int firstIndex = autocompleteEntries.IndexOf(predicate); if (firstIndex == -1) { return; } int lastIndex = autocompleteEntries.LastIndexOf(predicate); if (index == -1) { index = firstIndex - 1; } if (isNextValue) { index++; if (index > lastIndex) { index = firstIndex; } } else { index--; if (index < firstIndex) { index = lastIndex; } } SetAutocompleteValue(consoleInput, startIndex, autocompleteEntries[index]); }
public Game(GanzenBoardGame.Application.Logging.ILogger logger, IConsoleInput consoleInput, INumbervalidator validator, IStringValidatie stringValidatie, IDateTimeValidatie dateTimeValidatie, IGameBoardService gameBoardService, IPlayerService playerService, IPionService pionService, IRoundService roundService ) { _logger = logger; _consoleInput = consoleInput; _numberValidator = validator; _stringValidatie = stringValidatie; _dateTimeValidatie = dateTimeValidatie; _gameBoardService = gameBoardService; _playerService = playerService; _pionService = pionService; _roundService = roundService; }
private static AutocompletionContextResult FindAutocompletionContext(IConsoleInput consoleInput) { var result = new AutocompletionContextResult { StartIndex = 0 }; for (int i = Math.Min(consoleInput.CaretIndex, consoleInput.Length - 1); i >= 0; i--) { if (consoleInput[i] == FunctionEndSymbol) { result.Context = AutocompletionContext.Regular; break; } if (consoleInput[i] == FunctionStartSymbol) { result.Context = AutocompletionContext.Method; result.StartIndex = i + 1; break; } } return(result); }
private static AutocompletionType FindAutocompleteType(IConsoleInput consoleInput, int startIndex) { if (startIndex == 0) { return(AutocompletionType.Regular); } startIndex--; // Does not take into account what was before the accessor or assignment symbol. for (int i = startIndex; i >= 0; i--) { char c = consoleInput[i]; if (c == SpaceSymbol) { continue; } if (c == AccessorSymbol) { return(AutocompletionType.Accessor); } if (c == AssignmentSymbol) { if (i <= 0) { return(AutocompletionType.Assignment); } // If we have for example == or += instead of =, use regular autocompletion. char prev = consoleInput[i - 1]; return(prev == AssignmentSymbol || Operators.Any(x => x == prev) ? AutocompletionType.Regular : AutocompletionType.Assignment); } return(AutocompletionType.Regular); } return(AutocompletionType.Regular); }
private static int FindBoundaryIndices(IConsoleInput consoleInput, int lookupIndex) { if (consoleInput.Length == 0) { return(0); } int previousIndex = lookupIndex - 1; // Find start index. for (int i = previousIndex; i >= 0; i--) { if (AutocompleteBoundaryDenoters.Any(x => x == consoleInput[i])) { break; } lookupIndex = i; } // Find length. int length = 0; if (previousIndex >= 0) { for (int i = lookupIndex; i < consoleInput.Length; i++) { if (AutocompleteBoundaryDenoters.Any(x => x == consoleInput[i]) || consoleInput[i] == SpaceSymbol) { break; } length++; } } return(lookupIndex + (length << 16)); }
/// <summary> /// Does nothing. /// </summary> /// <param name="input">Console input.</param> /// <param name="forward">True if user wants to autocomplete to the next value; false if to the previous value.</param> public void Autocomplete(IConsoleInput input, bool forward) { }
public LifecycleSystem(IConsoleInput input) => _input = input;
public void Update(GameTime time, IConsoleInput input) { }
/// <summary> /// Tries to autocomplete the current input value in the <see cref="Console"/> <see cref="ConsoleInput"/>. /// </summary> /// <param name="input">Console input.</param> /// <param name="forward">True if user wants to autocomplete to the next value; false if to the previous value.</param> public void Autocomplete(IConsoleInput input, bool forward) => _autocompleter.Autocomplete(input, forward);
public Instruction03(long instructionCode, IConsoleInput input, IMemoryController memoryController) : base( instructionCode, memoryController) { _input = input; }
private static void SetAutocompleteValue(IConsoleInput consoleInput, int startIndex, string autocompleteEntry) { consoleInput.Remove(startIndex, consoleInput.Length - startIndex); consoleInput.Append(autocompleteEntry); }
public void Autocomplete(IConsoleInput consoleInput, bool isNextValue) { // Which context we in, method or regular. AutocompletionContextResult contextResult = FindAutocompletionContext(consoleInput); Type typeToPrefer = null; if (contextResult.Context == AutocompletionContext.Method) { long newCommandLength_whichParamAt_newStartIndex_numParams = FindParamIndexNewStartIndexAndNumParams(consoleInput, contextResult.StartIndex); int chainEndIndex = FindPreviousLinkEndIndex(consoleInput, contextResult.StartIndex - 1); if (chainEndIndex >= 0) { Stack <string> accessorChain = FindAccessorChain(consoleInput, chainEndIndex); Member lastChainLink = FindLastChainLinkMember(accessorChain); if (lastChainLink?.ParameterInfo != null) { var numParams = (int)(newCommandLength_whichParamAt_newStartIndex_numParams & 0xff); ParameterInfo[] overload = null; for (int i = numParams; i <= lastChainLink.ParameterInfo.Max(x => x.Length); i++) { ParameterInfo[] overloadCandidate = lastChainLink.ParameterInfo.FirstOrDefault(x => x.Length == i); if (overloadCandidate != null) { overload = overloadCandidate; break; } } if (overload != null) { var paramIndex = newCommandLength_whichParamAt_newStartIndex_numParams >> 32 & 0xff; if (overload.Length > paramIndex) { typeToPrefer = overload[paramIndex].ParameterType; } } } } } int autocompleteBoundaryIndices = FindBoundaryIndices(consoleInput, consoleInput.CaretIndex); int startIndex = autocompleteBoundaryIndices & 0xff; int length = autocompleteBoundaryIndices >> 16; string command = consoleInput.Substring(startIndex, length); AutocompletionType completionType = FindAutocompleteType(consoleInput, startIndex); if (completionType == AutocompletionType.Regular) { if (typeToPrefer == null || !string.IsNullOrWhiteSpace(command)) { FindAutocompleteForEntries(consoleInput, InstancesAndStatics, command, startIndex, isNextValue); } else { FindAutocompleteForEntries(consoleInput, GetAvailableNamesForType(typeToPrefer), command, startIndex, isNextValue); } } else // Accessor or assignment or method. { // We also need to find the value for whatever was before the type accessor. int chainEndIndex = FindPreviousLinkEndIndex(consoleInput, startIndex - 1); if (chainEndIndex < 0) { return; } Stack <string> accessorChain = FindAccessorChain(consoleInput, chainEndIndex); Member lastChainLink = FindLastChainLinkMember(accessorChain); // If no types were found, that means we are assigning a new variable. // Provide all autocomplete entries in that scenario. if (lastChainLink == null) { FindAutocompleteForEntries(consoleInput, InstancesAndStatics, command, startIndex, isNextValue); return; } switch (completionType) { case AutocompletionType.Accessor: MemberCollection autocompleteValues; if (lastChainLink.IsInstance) { _interpreter.InstanceMembers.TryGetValue(lastChainLink.Type, out autocompleteValues); } else { _interpreter.StaticMembers.TryGetValue(lastChainLink.Type, out autocompleteValues); } if (autocompleteValues == null) { break; } FindAutocompleteForEntries(consoleInput, autocompleteValues.Names, command, startIndex, isNextValue); break; case AutocompletionType.Assignment: FindAutocompleteForEntries( consoleInput, GetAvailableNamesForType(lastChainLink.Type), command, startIndex, isNextValue); break; } } }
public void Autocomplete(IConsoleInput input, bool forward) { _manualInterpreter.Autocomplete(input, forward); }
public ConsolePlayer(IConsoleInput consoleInputStub) { _consoleInputStub = consoleInputStub; }