示例#1
0
        public char?GetCharExclusiveJustDownAndSwallow(InputConsumer ic)
        {
            var shift = IsKeyDown(SKeys.ShiftAny);

            if (IsKeyExclusiveJustDown(SKeys.Space))
            {
                SwallowKey(SKeys.Space, ic); return(' ');
            }

            for (SKeys chr = SKeys.A; chr < SKeys.Z; chr++)
            {
                if (IsKeyExclusiveJustDown(chr))
                {
                    SwallowKey(chr, ic); return((char)(chr - SKeys.A + (shift ? 'A' : 'a')));
                }
            }

            if (IsKeyExclusiveJustDown(SKeys.D0))
            {
                SwallowKey(SKeys.D0, ic); return('0');
            }
            if (IsKeyExclusiveJustDown(SKeys.D1))
            {
                SwallowKey(SKeys.D1, ic); return('1');
            }
            if (IsKeyExclusiveJustDown(SKeys.D2))
            {
                SwallowKey(SKeys.D2, ic); return('2');
            }
            if (IsKeyExclusiveJustDown(SKeys.D3))
            {
                SwallowKey(SKeys.D3, ic); return('3');
            }
            if (IsKeyExclusiveJustDown(SKeys.D4))
            {
                SwallowKey(SKeys.D4, ic); return('4');
            }
            if (IsKeyExclusiveJustDown(SKeys.D5))
            {
                SwallowKey(SKeys.D5, ic); return('5');
            }
            if (IsKeyExclusiveJustDown(SKeys.D6))
            {
                SwallowKey(SKeys.D6, ic); return('6');
            }
            if (IsKeyExclusiveJustDown(SKeys.D7))
            {
                SwallowKey(SKeys.D7, ic); return('7');
            }
            if (IsKeyExclusiveJustDown(SKeys.D8))
            {
                SwallowKey(SKeys.D8, ic); return('8');
            }
            if (IsKeyExclusiveJustDown(SKeys.D9))
            {
                SwallowKey(SKeys.D9, ic); return('9');
            }

            return(null);
        }
示例#2
0
 public void SwallowKey(KeyCombination s, InputConsumer ic)
 {
     if (_consumedKeyEvts == null)
     {
         _consumedKeyEvts = new List <Tuple <SKeys, InputConsumer> >();
     }
     _consumedKeyEvts.Add(Tuple.Create(s.Key, ic));
 }
示例#3
0
 /// <summary>
 /// Contructor
 /// </summary>
 /// <param name="logger"><see cref="ILogger{TCategoryName}"/></param>
 /// <param name="databaseFactory">The database factory</param>
 /// <param name="compilerFactory">The compiler factory</param>
 internal Engine(ILogger logger, Func <Database> databaseFactory, Func <Compiler> compilerFactory) : base(new Logger(trace => logger.LogTrace(trace), debug => logger.LogDebug(debug), info => logger.LogInformation(info), warning => logger.LogWarning(warning), error => logger.LogError(error), critical => logger.LogCritical(critical)), databaseFactory, compilerFactory)
 {
     _logger        = logger;
     _queuing       = new ChannelQueuing <string>(new BoundedChannelOptions(Compiler.Mode == CompilerMode.HsModeBlock ? Environment.ProcessorCount : 1));
     InputConsumers = new HashSet <InputConsumer>();
     foreach (var _ in Enumerable.Range(0, Compiler.Mode == CompilerMode.HsModeBlock ? Environment.ProcessorCount : 1))
     {
         var scanner       = CreateScanner();
         var inputConsumer = new InputConsumer(_logger, _queuing.Consumer, scanner);
         inputConsumer.Consume(_cancellationTokenSource.Token);
         InputConsumers.Add(inputConsumer);
     }
 }
示例#4
0
 public void Swallow(InputConsumer ic)
 {
     isUpDownSwallowed = true;
     SwallowConsumer   = ic;
 }
示例#5
0
 public InputHandler(InputConsumer inputConsumer)
 {
     this.inputConsumer = inputConsumer;
 }