Beispiel #1
0
void RgbLed::_parseCommands(String data, Cmd* commands, int i){
  Serial.print("Parsing LED commands.  Data: ");
  Serial.println(data);
  int index = data.indexOf(",", 0);
  Serial.print("Index for first '=' ");
  Serial.println(index);
  if(index == -1){
    _parseCommand(data, commands, i);
    return;
  }

  _parseCommand(data.substring(0, index), commands, i);
  _parseCommands(data.substring(index + 1), commands, i+1);
}
Beispiel #2
0
// == Give a line to to be parsed to the parser ==
void TCParser::parseLine(const std::string &line)
{
	// Unscape protocol special chars
	std::string *l1 = createReplaceAll(line, "\\n", "\n");
	std::string *l2 = createReplaceAll(*l1, "\\/", "\\");
		
	// Eplode the line with spaces
	std::vector<std::string> *exp = createExplode(*l2, " ");
	
	// Parse the array
	_parseCommand(*exp);
	
	// Free memory
	delete l1;
	delete l2;
	delete exp;	
}
Beispiel #3
0
void ConsoleState::Update(const ActionMap & actions, unsigned int tElapsed)  {
   const InputState & input = *actions.GetInputState();

   if (input.KeyDown(SDLKey::SDLK_PAGEUP))
      console.ScrollUp(3);

   if (input.KeyDown(SDLKey::SDLK_PAGEDOWN))
      console.ScrollDown(3);

   if (!input.KeyDown(SDLKey::SDLK_BACKQUOTE))
      _input->Update(actions, tElapsed);

   if (input.KeyDown(SDLKey::SDLK_RETURN)) {
      ConsoleCommand c = _parseCommand(_input->GetText());

      if (c.Command == "dumplog")  {

         if (c.Params.size() > 0) 
            console.Write(c.Params.at(0).c_str());
         else
            console.Write("console.log");

         console.AddLine("Successfully wrote console log to file!");

      } else if (c.Command == "showfps")  {

         Preferences.SetValue<bool>("SHOWFPS", !Preferences.GetValue<bool>("SHOWFPS"));
         if (Preferences.GetValue<bool>("SHOWFPS"))
            console.AddLine("Frames per second display on.");
         else
            console.AddLine("Frames per second display off.");

      } else
         console.AddLine(std::string("[echo] ") + _input->GetText());

      _input->SetText(std::string(""));
   }
}