#include <algorithm>
#include <iterator>
-using lyx::support::AddName;
-using lyx::support::package;
+using lyx::support::addName;
+using lyx::support::package;
namespace fs = boost::filesystem;
using std::find;
using std::ostream_iterator;
-namespace lyx{
-
namespace {
string const sec_lastfiles = "[recent files]";
} // anon namespace
+namespace lyx {
+
Session::Session(unsigned int num) :
default_num_last_files(4),
absolute_max_last_files(100),
setNumberOfLastFiles(num);
// locate the session file
// note that the session file name 'session' is hard-coded
- session_file = AddName(package().user_support(), "session");
+ session_file = addName(package().user_support(), "session");
//
readFile();
}
// the following is currently not implemented very
// robustly. (Manually editing of the session file may crash lyx)
- //
+ //
while (getline(ifs, tmp)) {
// Ignore comments, empty line or line stats with ' '
if (tmp == "" || tmp[0] == '#' || tmp[0] == ' ')
} else if (section == id_lastfilepos) {
// read lastfilepos
// pos, file\n
- lyx::pit_type pit;
- lyx::pos_type pos;
+ pit_type pit;
+ pos_type pos;
string fname;
istringstream itmp(tmp);
itmp >> pit;
continue;
lastopened.push_back(tmp);
} else if (section == id_bookmarks) {
- // read bookmarks
+ // read bookmarks
// bookmarkid, id, pos, file\n
unsigned int num;
unsigned int id;
- lyx::pos_type pos;
+ pos_type pos;
string fname;
istringstream itmp(tmp);
itmp >> num;
ostream_iterator<string>(ofs, "\n"));
// second section
ofs << '\n' << sec_lastfilepos << '\n';
- for (FilePosMap::const_iterator file = lastfilepos.begin();
+ for (FilePosMap::const_iterator file = lastfilepos.begin();
file != lastfilepos.end(); ++file) {
- ofs << file->second.get<0>() << ", "
+ ofs << file->second.get<0>() << ", "
<< file->second.get<1>() << ", "
<< file->first << '\n';
}
ostream_iterator<string>(ofs, "\n"));
// fourth section
ofs << '\n' << sec_bookmarks << '\n';
- for (BookmarkList::const_iterator bm = bookmarks.begin();
+ for (BookmarkList::const_iterator bm = bookmarks.begin();
bm != bookmarks.end(); ++bm) {
// save bookmark number, id, pos, fname
ofs << bm->get<0>() << ", "
- << bm->get<2>() << ", "
+ << bm->get<2>() << ", "
<< bm->get<3>() << ", "
<< bm->get<1>() << '\n';
}
if (entry != lastfilepos.end())
return entry->second;
// Not found, return the first paragraph
- else
+ else
return 0;
}
}
-void Session::setLastOpenedFiles(vector<string> const & files)
+void Session::addLastOpenedFile(string const & file)
{
- lastopened = files;
+ lastopened.push_back(file);
}