- for (BookmarkList::const_iterator bm = bookmarks.begin();
- bm != bookmarks.end(); ++bm) {
- // save bookmark number, id, pos, fname
- os << bm->get<0>() << ", "
- << bm->get<2>() << ", "
- << bm->get<3>() << ", "
- << bm->get<1>() << '\n';
+ for (size_t i = 0; i < bookmarks.size(); ++i) {
+ os << bookmarks[i].par_pit << ", "
+ << bookmarks[i].par_pos << ", "
+ << bookmarks[i].filename << '\n';
+ }
+}
+
+
+void BookmarksSection::save(FileName const & fname, pit_type par_pit, int par_id, pos_type par_pos, bool persistent)
+{
+ if (persistent) {
+ bookmarks.push_back(Bookmark(fname, par_pit, par_id, par_pos));
+ if (bookmarks.size() > max_bookmarks)
+ bookmarks.pop_back();
+ }
+ else
+ temp_bookmark = Bookmark(fname, par_pit, par_id, par_pos);
+}
+
+
+bool BookmarksSection::isValid(unsigned int i) const
+{
+ if (i == 0)
+ return !temp_bookmark.filename.empty();
+ else
+ return i <= bookmarks.size() && !bookmarks[i-1].filename.empty();
+}
+
+
+BookmarksSection::Bookmark const & BookmarksSection::bookmark(unsigned int i) const
+{
+ if (i == 0)
+ return temp_bookmark;
+ else
+ return bookmarks[i-1];
+}
+
+
+void ToolbarSection::read(istream & is)
+{
+ string tmp;
+ do {
+ char c = is.peek();
+ if (c == '[')
+ break;
+ getline(is, tmp);
+ if (tmp == "" || tmp[0] == '#' || tmp[0] == ' ')
+ continue;
+
+ try {
+ // 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);
+ } else
+ lyxerr[Debug::INIT] << "LyX: Warning: Ignore toolbar info: " << tmp << endl;
+ } catch (...) {
+ lyxerr[Debug::INIT] << "LyX: Warning: unknown Toolbar info: " << tmp << endl;
+ }
+ } 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<int>(tb->second.state) << " "
+ << static_cast<int>(tb->second.location) << '\n';