Esempio n. 1
0
/** Load the definition of the comments for each language.
 *  @param languages Array of languages.
 *  @see LanguageDef
 */
int LoadSettings(LanguageDef languages[NB_FILETYPES_MAX])
{
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("codestat"));
    int nb_languages = cfg->ReadInt(_T("/nb_languages"), 0);

    // If no comment styles exist, use and save default ones
    if (nb_languages == 0)
    {
       nb_languages = LoadDefaultSettings(languages);
    }
    // else, load the user settings
    else
    {
        if (nb_languages > NB_FILETYPES_MAX)
           nb_languages = NB_FILETYPES_MAX;
        for (int i=0; i<nb_languages; ++i)
        {
            wxString extensions;
            languages[i].name = cfg->Read(wxString::Format(_T("/l%d/name"),i), _T(""));
            extensions = cfg->Read(wxString::Format(_T("/l%d/ext"),i), _T(""));
            languages[i].ext.Clear();
            wxStringTokenizer tkz(extensions);
            while (tkz.HasMoreTokens())
               languages[i].ext.Add(tkz.GetNextToken());
            languages[i].single_line_comment = cfg->Read(wxString::Format(_T("/l%d/single_line_comment"),i), _T(""));
            languages[i].multiple_line_comment[0] = cfg->Read(wxString::Format(_T("/l%d/multiple_line_comment_begin"),i), _T(""));
            languages[i].multiple_line_comment[1] = cfg->Read(wxString::Format(_T("/l%d/multiple_line_comment_end"),i), _T(""));
        }
    }
    return nb_languages;
}
Esempio n. 2
0
bool ModuleSettings::LoadSettings() {  
  int n = sizeof(SettingData);
  uint8_t *p = (uint8_t*)(&data);

  TRACE("Loading setting from EEPROM");
  EEPROM.begin(n);
  for (int i=0; i<n; i++) {
    delay(0);
    *p = EEPROM.read(i);
    p++;
  }

  EEPROM.end();

  if ( IsDirty() ) {
    TRACE("Invalid EEPROM data. Load default setting instead.");
    LoadDefaultSettings(); 
    return false;
  }
  return true;
}
Esempio n. 3
0
ModuleSettings::ModuleSettings() {
  LoadDefaultSettings(); 
}
Esempio n. 4
0
/** Restore the default settings.
 */
void CodeStatConfigDlg::RestoreDefault(wxCommandEvent& event)
{
    nb_languages = LoadDefaultSettings(languages);
    ReInitDialog();
}