update keys file for changes to NextWindow syntax

This commit is contained in:
Mark Tiefenbruck 2008-08-19 05:48:16 -07:00
parent 18ae02875f
commit e5d43edb8e
3 changed files with 55 additions and 2 deletions

View file

@ -29,4 +29,4 @@ session.colorsPerChannel: 4
session.doubleClickInterval: 250
session.cacheMax: 200
session.imageDither: True
session.configVersion: 9
session.configVersion: 10

View file

@ -595,7 +595,7 @@ void Fluxbox::setupConfigFiles() {
if (create_windowmenu)
FbTk::FileUtil::copyFile(DEFAULT_WINDOWMENU, windowmenu_file.c_str());
#define CONFIG_VERSION 9
#define CONFIG_VERSION 10
FbTk::Resource<int> config_version(m_resourcemanager, 0,
"session.configVersion", "Session.ConfigVersion");
if (*config_version < CONFIG_VERSION) {

View file

@ -323,6 +323,59 @@ int run_updates(int old_version, FbTk::ResourceManager &rm) {
new_version = 9;
}
if (old_version < 10) { // update keys file for NextWindow syntax changes
string whole_keyfile = read_file(keyfilename);
size_t pos = 0;
while (true) {
const char *keyfile = whole_keyfile.c_str();
const char *loc = 0;
size_t old_pos = pos;
// find the first position that matches any of next/prevwindow/group
if ((loc = FbTk::StringUtil::strcasestr(keyfile + old_pos,
"nextwindow")))
pos = (loc - keyfile) + 10;
if ((loc = FbTk::StringUtil::strcasestr(keyfile + old_pos,
"prevwindow")))
pos = (pos > old_pos && keyfile + pos < loc) ?
pos : (loc - keyfile) + 10;
if ((loc = FbTk::StringUtil::strcasestr(keyfile + old_pos,
"nextgroup")))
pos = (pos > old_pos && keyfile + pos < loc) ?
pos : (loc - keyfile) + 9;
if ((loc = FbTk::StringUtil::strcasestr(keyfile + old_pos,
"prevgroup")))
pos = (pos > old_pos && keyfile + pos < loc) ?
pos : (loc - keyfile) + 9;
if (pos == old_pos)
break;
pos = whole_keyfile.find_first_not_of(" \t", pos);
if (pos != std::string::npos && isdigit(whole_keyfile[pos])) {
char *endptr = 0;
unsigned int mask = strtoul(keyfile + pos, &endptr, 0);
string insert = "";
if ((mask & 9) == 9)
insert = "{static groups}";
else if (mask & 1)
insert = "{groups}";
else if (mask & 8)
insert = "{static}";
if (mask & 2)
insert += " (stuck=no)";
if (mask & 4)
insert += " (shaded=no)";
if (mask & 16)
insert += " (minimized=no)";
if (mask)
whole_keyfile.replace(pos, endptr - keyfile - pos, insert);
}
}
write_file(keyfilename, whole_keyfile);
new_version = 10;
}
return new_version;
}