Esempio n. 1
0
        public bool Parse(string[] particles, ref ConfigCollection data)
        {
            if (particles[0] != Instruction)
            {
                FetchResult = null;
                return(false);
            }

            variableFinder.PushContext(data);
            var keybind = variableFinder.ParseAll(particles[1]);
            var command = string.Join(' ', particles.Skip(2));

            if (commandExecutor.Execute(command, data, commandHandler) == null)
            {
                AddError($"Unknown bindsym command \"{command}\"");
                variableFinder.PopContext();
                FetchResult = null;
                return(true);
            }

            data.KeyBinds.Add(keybind, command);
            variableFinder.PopContext();
            FetchResult = new ParseInstructionResult(FileParserStateResult.None, "", this);
            return(true);
        }
Esempio n. 2
0
        public bool Parse(string[] particles, ref ConfigCollection data)
        {
            if (particles[0] != Instruction)
            {
                FetchResult = null;
                return(false);
            }

            if (particles[1].StartsWith('$') == false)
            {
                AddError?.Invoke("Invalid variable name. Variables must start with $");
                FetchResult = null;
                return(true);
            }

            data.AddVariable(particles[1], string.Join(' ', particles.Skip(2)));
            FetchResult = new ParseInstructionResult(FileParserStateResult.None, "", this);
            return(true);
        }
Esempio n. 3
0
        public bool Parse(string[] particles, ref ConfigCollection data)
        {
            if (particles[0] != Instruction)
            {
                FetchResult = null;
                return(false);
            }

            if (particles[1].StartsWith('{') == false)
            {
                AddError("Invalid value for bar. It should be followed by an {");
                FetchResult = null;
                return(true);
            }

            var remaining = string.Join(' ', particles.Skip(1)).Substring(1);

            FetchResult = new ParseInstructionResult(FileParserStateResult.OpenBracket, remaining, this);
            return(true);
        }