X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsession.C;h=4372d610e89401a6ca975bfd045235df8442e222;hb=35204f8f33d7400a5fefeffea533fb4cb4097211;hp=25cf8cc407b300e9ad595c372612fa81140a8139;hpb=f49f2f6e22a087a05904fe73b989daf26cc5e41e;p=lyx.git diff --git a/src/session.C b/src/session.C index 25cf8cc407..4372d610e8 100644 --- a/src/session.C +++ b/src/session.C @@ -48,6 +48,7 @@ string const sec_lastfilepos = "[cursor positions]"; string const sec_lastopened = "[last opened files]"; string const sec_bookmarks = "[bookmarks]"; string const sec_session = "[session info]"; +string const sec_toolbars = "[toolbars]"; } // anon namespace @@ -267,6 +268,51 @@ BookmarksSection::Bookmark const & BookmarksSection::bookmark(unsigned int i) co } +void ToolbarSection::read(istream & is) +{ + string tmp; + do { + char c = is.peek(); + if (c == '[') + break; + getline(is, tmp); + + // Read session info, saved as key/value pairs + // would better yell if pos returns npos + string::size_type pos = tmp.find_first_of(" = "); + // silently ignore lines without " = " + if (pos != string::npos) { + string key = tmp.substr(0, pos); + int state; + int location; + istringstream value(tmp.substr(pos + 3)); + value >> state; + value.ignore(1); // ignore " " + value >> location; + toolbars[key] = ToolbarInfo(state, location); + } + } while (is.good()); +} + + +void ToolbarSection::write(ostream & os) const +{ + os << '\n' << sec_toolbars << '\n'; + for (ToolbarMap::const_iterator tb = toolbars.begin(); + tb != toolbars.end(); ++tb) { + os << tb->first << " = " + << static_cast(tb->second.state) << " " + << static_cast(tb->second.location) << '\n'; + } +} + + +ToolbarSection::ToolbarInfo & ToolbarSection::load(string const & name) +{ + return toolbars[name]; +} + + void SessionInfoSection::read(istream & is) { string tmp; @@ -349,6 +395,8 @@ void Session::readFile() lastFilePos().read(is); else if (tmp == sec_bookmarks) bookmarks().read(is); + else if (tmp == sec_toolbars) + toolbars().read(is); else if (tmp == sec_session) sessionInfo().read(is); else @@ -368,6 +416,7 @@ void Session::writeFile() const lastOpened().write(os); lastFilePos().write(os); bookmarks().write(os); + toolbars().write(os); sessionInfo().write(os); } else lyxerr << "LyX: Warning: unable to save Session: "