From: Abdelrazak Younes Date: Sat, 21 Oct 2006 09:45:11 +0000 (+0000) Subject: My six month cleanup crusade is now paying off: LyX has now multiple windows support! X-Git-Tag: 1.6.10~12284 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=4d3fbc113f44373cd54f266570b0347a748904dc;p=features.git My six month cleanup crusade is now paying off: LyX has now multiple windows support! git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15438 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/lib/ui/stdmenus.ui b/lib/ui/stdmenus.ui index 772cedaebb..a9c9ec6a13 100644 --- a/lib/ui/stdmenus.ui +++ b/lib/ui/stdmenus.ui @@ -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" diff --git a/src/LyXAction.C b/src/LyXAction.C index 0d86ba6d86..aa07b19e68 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -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 } }; diff --git a/src/coordcache.h b/src/coordcache.h index 4adf25ac39..d5ac02f6eb 100644 --- a/src/coordcache.h +++ b/src/coordcache.h @@ -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); diff --git a/src/frontends/qt4/GuiWorkArea.C b/src/frontends/qt4/GuiWorkArea.C index d8d66ea0da..a01f8ecbea 100644 --- a/src/frontends/qt4/GuiWorkArea.C +++ b/src/frontends/qt4/GuiWorkArea.C @@ -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); } diff --git a/src/lfuns.h b/src/lfuns.h index 4768e01893..58b990b7eb 100644 --- a/src/lfuns.h +++ b/src/lfuns.h @@ -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 }; diff --git a/src/lyx_main.C b/src/lyx_main.C index 874f10d8c0..a36bc40c06 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -491,6 +491,28 @@ int LyX::execBatchCommands(int & argc, char * argv[], void LyX::restoreGuiSession(vector 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 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 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 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 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 =================== diff --git a/src/lyx_main.h b/src/lyx_main.h index 283ad13c00..a95ec53349 100644 --- a/src/lyx_main.h +++ b/src/lyx_main.h @@ -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 const & files); + /// + void addLyXView(LyXView * lyxview); + /// Initialize RC font for the GUI. void initGuiFont(); diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 027a782805..7fa89e0b67 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -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(); diff --git a/src/text2.C b/src/text2.C index d88edd4af9..239cb1e405 100644 --- a/src/text2.C +++ b/src/text2.C @@ -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);