Esempio n. 1
0
void FarHrcSettings::readProfileFromRegistry()
{
  HRCParser *hrcParser = parserFactory->getHRCParser();
  
  SettingsControl ColorerSettings;
  size_t hrc_subkey;
  hrc_subkey = ColorerSettings.rGetSubKey(0,HrcSettings);
  FarSettingsEnum fse;
  fse.StructSize = sizeof(FarSettingsEnum);
  // enum all the sections in HrcSettings
  if (ColorerSettings.rEnum(hrc_subkey,&fse)){
    for (size_t i=0; i<fse.Count; i++){
      if (fse.Items[i].Type == FST_SUBKEY){
        //check whether we have such a scheme
        FileTypeImpl *type = (FileTypeImpl *)hrcParser->getFileType(&DString(fse.Items[i].Name));
        if (type){
          // enum all params in the section
          size_t type_subkey;
          type_subkey = ColorerSettings.rGetSubKey(hrc_subkey,fse.Items[i].Name);
          FarSettingsEnum type_fse;
          type_fse.StructSize = sizeof(FarSettingsEnum);
          if (ColorerSettings.rEnum(type_subkey,&type_fse)){
            for (size_t j=0; j<type_fse.Count; j++){
              if (type_fse.Items[j].Type == FST_STRING){
                if (type->getParamValue(DString(type_fse.Items[j].Name))==null){
                  type->addParam(&DString(type_fse.Items[j].Name));
                }
				const wchar_t *p = ColorerSettings.Get(type_subkey,type_fse.Items[j].Name,(wchar_t*)NULL);
				if (p) {
					delete type->getParamNotDefaultValue(DString(type_fse.Items[j].Name));
					type->setParamValue(DString(type_fse.Items[j].Name), &DString(p));
				}
              }
            }
          }
        }
      }
    }
  }
}
Esempio n. 2
0
void FarHrcSettings::UpdatePrototype(Element *elem, bool userValue)
{
  const String *typeName = elem->getAttribute(DString("name"));
  if (typeName == null){
    return;
  }
  HRCParser *hrcParser = parserFactory->getHRCParser();
  FileTypeImpl *type = (FileTypeImpl *)hrcParser->getFileType(typeName);
  if (type== null){
    return;
  };
  for(Node *content = elem->getFirstChild(); content != null; content = content->getNextSibling()){
    if (*content->getNodeName() == "param"){
      const String *name = ((Element*)content)->getAttribute(DString("name"));
      const String *value = ((Element*)content)->getAttribute(DString("value"));
      const String *descr = ((Element*)content)->getAttribute(DString("description"));
      if (name == null || value == null){
        continue;
      };

      if (type->getParamValue(SString(name))==null){
        type->addParam(name);
      }
      if (descr != null){
        type->setParamDescription(SString(name), descr);
      }
      if (userValue){
        delete type->getParamNotDefaultValue(DString(name));
        type->setParamValue(SString(name), value);
      }
      else{
        delete type->getParamDefaultValue(DString(name));
        type->setParamDefaultValue(SString(name), value);
      }
    };
  };
}
Esempio n. 3
0
void FarHrcSettings::writeProfileToRegistry()
{
  HRCParser *hrcParser = parserFactory->getHRCParser();
  FileTypeImpl *type = NULL;

  SettingsControl ColorerSettings;
  ColorerSettings.rDeleteSubKey(0,HrcSettings);
  size_t hrc_subkey;
  hrc_subkey = ColorerSettings.rGetSubKey(0,HrcSettings);

  // enum all FileTypes
  for (int idx = 0; ; idx++){
    type =(FileTypeImpl *) hrcParser->enumerateFileTypes(idx);

    if (!type){
      break;
    }

    const String *p, *v;
    if (type->getParamCount() && type->getParamNotDefaultValueCount()){// params>0 and user values >0
      size_t type_subkey = ColorerSettings.rGetSubKey(hrc_subkey,type->getName()->getWChars());
      // enum all params
      for (int i=0;;i++){
        p=type->enumerateParameters(i);
        if (!p){
          break;
        }
        v=type->getParamNotDefaultValue(*p);
        if (v!=NULL){
          ColorerSettings.Set(type_subkey,p->getWChars(),v->getWChars());
        }
      }
    }
  }

}