* BufferList: new begin() and end() methods.

* LyX::exec(): in non-GUI mode, execute batch commands on all buffers.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16068 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2006-11-26 16:39:39 +00:00
parent 7ac9c50824
commit 0dae88fca6
3 changed files with 47 additions and 6 deletions

View File

@ -72,6 +72,30 @@ bool BufferList::empty() const
}
BufferList::iterator BufferList::begin()
{
return bstore.begin();
}
BufferList::const_iterator BufferList::begin() const
{
return bstore.begin();
}
BufferList::iterator BufferList::end()
{
return bstore.end();
}
BufferList::const_iterator BufferList::end() const
{
return bstore.end();
}
bool BufferList::quitWriteBuffer(Buffer * buf)
{
BOOST_ASSERT(buf);

View File

@ -28,9 +28,19 @@ class OutputParams;
* and deletions of new ones.
*/
class BufferList : boost::noncopyable {
public:
typedef std::vector<Buffer *>::iterator iterator;
typedef std::vector<Buffer *>::const_iterator const_iterator;
public:
BufferList();
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
/// write all buffers, asking the user, returns false if cancelled
bool quitWriteAll();

View File

@ -336,17 +336,24 @@ int LyX::exec(int & argc, char * argv[])
prepareExit();
return exit_status;
}
Buffer * last_loaded = pimpl_->buffer_list_.last();
if (batch_command.empty() || !last_loaded) {
if (batch_command.empty() || pimpl_->buffer_list_.empty()) {
prepareExit();
return EXIT_SUCCESS;
}
// try to dispatch to last loaded buffer first
bool success = false;
last_loaded->dispatch(batch_command, &success);
BufferList::iterator begin = pimpl_->buffer_list_.begin();
BufferList::iterator end = pimpl_->buffer_list_.end();
bool final_success = false;
for (BufferList::iterator I = begin; I != end; ++I) {
Buffer * buf = *I;
bool success = false;
buf->dispatch(batch_command, &success);
final_success |= success;
}
prepareExit();
return !success;
return !final_success;
}
// Force adding of font path _before_ Application is initialized