"Bo Peng" <[EMAIL PROTECTED]> writes: | An updated patch that loads all position information while keeping | only num_files Files entries. | | Question: is 0 a valid paragraph ID? I currently use -1 to indicate | invalid ID.
As said, I'd prefere a separate file in .lyx/; but even if I didn't: | Index: src/BufferView_pimpl.C | =================================================================== | --- src/BufferView_pimpl.C (revision 13463) | +++ src/BufferView_pimpl.C (working copy) | @@ -293,6 +293,14 @@ | | setBuffer(b); | bv_->showErrorList(_("Parse")); | + | + // load position when the file was last closed | + int id; | + lyx::pos_type pos; | + LyX::ref().lastfiles().loadFilePosition(s, id, pos); I must admit that I prefere to not use in/out parameters. I like tupples though :-) (boost::tuple) | + // if id is valid ... | + if( id >= 0 ) | + saved_positions[0] = Position(s, id, pos); I think we should just have a switch. LyX wide per user where (lyxrc) the decides where the lastposition info should be used or not. | + if (i == 0) { | + LyX::ref().lastfiles().saveFilePosition(buffer_->fileName(), | + cursor_.paragraph().id(), | + cursor_.pos()); Using paragraph id is icky. Please use offsets into the paragraphlist instead. You should be able to get that from the cursor. | Index: src/lastfiles.C | =================================================================== | --- src/lastfiles.C (revision 13463) | +++ src/lastfiles.C (working copy) | @@ -26,10 +31,16 @@ | using std::find; | using std::getline; | using std::string; | +using std::map; | +using std::pair; | using std::ifstream; | using std::ofstream; | using std::ostream_iterator; | | +// store file position information to a map to avoid changing the | +// dequeue structure Files | +typedef map<string, pair<int, lyx::pos_type> > file_pos; | +file_pos filePositions; This is a no-go. This information must be in the LastFiles object (class). | Index: src/lastfiles.h | =================================================================== | --- src/lastfiles.h (revision 13463) | +++ src/lastfiles.h (working copy) | @@ -56,6 +59,18 @@ | @param file the file we write the lastfiles list to. | */ | void writeFile(std::string const & file) const; | + /** add cursor position to the fname entry in the lastfile | + @param fname file entry for which to save position information | + @param id id of the paragraph of the location when the file is closed. | + @param pos position of the cursor when the file is closed. | + */ | + void LastFiles::saveFilePosition(std::string const& fname, int id, lyx::pos_type pos) const; | + /** load saved cursor position to the fname entry in the lastfile | + @param fname file entry for which to load position information | + @param id id of the paragraph of the location when the file is closed. | + @param pos position of the cursor when the file is closed. | + */ | + void LastFiles::loadFilePosition(std::string const& fname, int& id, lyx::pos_type& pos ) const; | /** Return file #n# in the lastfiles list. | @param n number in the list to get | */ Using "ClassName::Func" in the class decl. is a syntax error. Just use 'Func' instead. -- Lgb