]> git.lyx.org Git - features.git/commitdiff
My six month cleanup crusade is now paying off: LyX has now multiple windows support!
authorAbdelrazak Younes <younes@lyx.org>
Sat, 21 Oct 2006 09:45:11 +0000 (09:45 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sat, 21 Oct 2006 09:45:11 +0000 (09:45 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15438 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ui/stdmenus.ui
src/LyXAction.C
src/coordcache.h
src/frontends/qt4/GuiWorkArea.C
src/lfuns.h
src/lyx_main.C
src/lyx_main.h
src/lyxfunc.C
src/text2.C

index 772cedaebb2e6d6d8f140bd5789f80bebfa1498d..a9c9ec6a13f3fae5cd3e9338b06ba5873ac041b6 100644 (file)
@@ -32,6 +32,7 @@ Menuset
 #
 
        Menu "file"
+               Item "New Window|W" "window-new"
                Item "New|N" "buffer-new"
                Item "New from Template...|m" "buffer-new-template"
                Item "Open...|O" "file-open"
index 0d86ba6d86b0b62ec0f66904a35b24362514271e..aa07b19e6865814ed8990d0340cf0a51a3080c8d 100644 (file)
@@ -362,6 +362,7 @@ void LyXAction::init()
                { LFUN_MOUSE_TRIPLE, "", ReadOnly },
                { LFUN_PARAGRAPH_MOVE_DOWN, "paragraph-move-down", Noop },
                { LFUN_PARAGRAPH_MOVE_UP, "paragraph-move-up", Noop },
+               { LFUN_WINDOW_NEW, "window-new", NoBuffer },
                { LFUN_NOACTION, "", Noop }
        };
 
index 4adf25ac39f93facd075707418c19019660db268..d5ac02f6eb220ce1f65433195c0118fa6f193507 100644 (file)
@@ -45,6 +45,11 @@ public:
                data_.clear();
        }
 
+       bool const empty() const
+       {
+               return data_.empty();
+       }
+
        void add(T const * thing, int x, int y)
        {
                data_[thing] = Point(x, y);
index d8d66ea0dad5f6386d5dbcaaf9079043b87894c1..a01f8ecbea63e7ee75e434594c2d67bd9ccb2df9 100644 (file)
@@ -424,7 +424,7 @@ void GuiWorkArea::resizeEvent(QResizeEvent *)
 
 void GuiWorkArea::update(int x, int y, int w, int h)
 {
-       viewport()->update(x, y, w, h);
+       viewport()->repaint(x, y, w, h);
 }
 
 
index 4768e01893342280bc66027bd4d91ff38c66b416..58b990b7eb0a703fe5caa46b5783af55b691e57e 100644 (file)
@@ -369,6 +369,7 @@ enum kb_action {
        // 280
        LFUN_INSET_DISSOLVE,                 // jspitzm 20060807
        LFUN_CHANGE_NEXT,
+       LFUN_WINDOW_NEW,                 // Abdel 20062110
 
        LFUN_LASTACTION                  // end of the table
 };
index 874f10d8c024190f4e455627d17feeb33230cbfd..a36bc40c0657b8ede8d62fb4b1c37ca56ec847e6 100644 (file)
@@ -491,6 +491,28 @@ int LyX::execBatchCommands(int & argc, char * argv[],
 
 
 void LyX::restoreGuiSession(vector<string> const & files)
+{
+       LyXView * view = newLyXView();
+
+       // load files
+       for_each(files.begin(), files.end(),
+               bind(&LyXView::loadLyXFile, view, _1, true));
+
+       // if a file is specified, I assume that user wants to edit *that* file
+       if (files.empty() && lyxrc.load_session) {
+               vector<string> const & lastopened = pimpl_->session_->lastOpenedFiles();
+               // do not add to the lastfile list since these files are restored from
+               // last seesion, and should be already there (regular files), or should
+               // not be added at all (help files).
+               for_each(lastopened.begin(), lastopened.end(),
+                       bind(&LyXView::loadLyXFile, view, _1, false));
+       }
+       // clear this list to save a few bytes of RAM
+       pimpl_->session_->clearLastOpenedFiles();
+}
+
+
+LyXView * LyX::newLyXView()
 {
        // determine windows size and position, from lyxrc and/or session
        // initial geometry
@@ -513,6 +535,7 @@ void LyX::restoreGuiSession(vector<string> const & files)
                if (session().loadSessionInfo("WindowIsMaximized") == "yes")
                        maximize = true;
        }
+
        // if user wants to restore window position
        int posx = -1;
        int posy = -1;
@@ -533,24 +556,9 @@ void LyX::restoreGuiSession(vector<string> const & files)
        LyXView * view = &pimpl_->application_->createView(width, height, posx, posy, maximize);
        ref().addLyXView(view);
 
-       // load files
-       for_each(files.begin(), files.end(),
-               bind(&LyXView::loadLyXFile, view, _1, true));
-
-       // if a file is specified, I assume that user wants to edit *that* file
-       if (files.empty() && lyxrc.load_session) {
-               vector<string> const & lastopened = pimpl_->session_->lastOpenedFiles();
-               // do not add to the lastfile list since these files are restored from
-               // last seesion, and should be already there (regular files), or should
-               // not be added at all (help files).
-               for_each(lastopened.begin(), lastopened.end(),
-                       bind(&LyXView::loadLyXFile, view, _1, false));
-       }
-       // clear this list to save a few bytes of RAM
-       pimpl_->session_->clearLastOpenedFiles();
+       return view;
 }
 
-
 /*
 Signals and Windows
 ===================
index 283ad13c0020be0f64b55b6b34ddfe2c3afd14fc..a95ec5334910b7d212329794aa3d1d082d691052 100644 (file)
@@ -93,7 +93,7 @@ public:
        kb_keymap & topLevelKeymap();
        kb_keymap const & topLevelKeymap() const;
 
-       void addLyXView(LyXView * lyxview);
+       LyXView * newLyXView();
 
        /** redraw \c inset in all the BufferViews in which it is currently
         *  visible. If successful return a pointer to the owning Buffer.
@@ -123,6 +123,9 @@ private:
        /// Create a View and restore GUI Session.
        void restoreGuiSession(std::vector<std::string> const & files);
 
+       ///
+       void addLyXView(LyXView * lyxview);
+
        /// Initialize RC font for the GUI.
        void initGuiFont();
 
index 027a7828051324948765ac241b652a74c7edfdf6..7fa89e0b6793ef51ea64ac20b05018d47fc38292 100644 (file)
@@ -619,6 +619,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        case LFUN_LYXRC_APPLY:
        case LFUN_BUFFER_NEXT:
        case LFUN_BUFFER_PREVIOUS:
+       case LFUN_WINDOW_NEW:
                // these are handled in our dispatch()
                break;
 
@@ -1583,6 +1584,10 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        break;
                }
 
+               case LFUN_WINDOW_NEW:
+                       BOOST_ASSERT(theApp);
+                       LyX::ref().newLyXView();
+
                default: {
                        view()->cursor().dispatch(cmd);
                        updateforce |= view()->cursor().result().update();
index d88edd4af99febe4839f81e82f9fadcf58cb8f55..239cb1e4059bd38a52e75e55d9f29bc7f4a97cd8 100644 (file)
@@ -980,10 +980,33 @@ InsetBase * LyXText::editXY(LCursor & cur, int x, int y)
                return 0;
        }
 
+       int i=0;
+       InsetBase * inset2 = pars_[pit].getInset(pos - 1);
+       InsetBase * inset3 = pars_[pit].getInset(pos);
+       if (inset != pars_[pit].getInset(pos - 1))
+       {
+               i++;            
+               std::cout << "pit " << pit 
+               << "  pos -1 " << pos - 1
+               << "\ninset " << inset
+               << "\ninset2 " << inset2
+               << endl;
+       }
+
+       if (inset != pars_[pit].getInset(pos))
+       {               
+               i++;
+               std::cout << "pit " << pit 
+               << "  pos " << pos
+               << "\ninset " << inset
+               << "\ninset3 " << inset3
+               << endl;
+       }
+       if (i == 2)
+               std::cout << endl;
+
        // This should be just before or just behind the
        // cursor position set above.
-        InsetBase * inset2 = pars_[pit].getInset(pos - 1);
-        InsetBase * inset3 = pars_[pit].getInset(pos);
         
        BOOST_ASSERT((pos != 0 && inset == inset2)
                     || inset == inset3);