]> git.lyx.org Git - features.git/commitdiff
* BufferList: new begin() and end() methods.
authorAbdelrazak Younes <younes@lyx.org>
Sun, 26 Nov 2006 16:39:39 +0000 (16:39 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 26 Nov 2006 16:39:39 +0000 (16:39 +0000)
* 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

src/bufferlist.C
src/bufferlist.h
src/lyx_main.C

index 5dd594e8cd8e40aa557b05e37009c86730466a8b..ed824f93c4cacfd173e2f5d75cc533e39b40281a 100644 (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);
index 4debd75e87eccaaa945e5e134fbe19634a9f32ee..161f95b7f520a63a2742f7ad0d10322164507795 100644 (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();
 
index 4a4bd42c3845c5ef6d7b59daf607e9dc007f2c17..90d98fd03d9f965ac36e2a2ea111922c48f459ac 100644 (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