X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferView_pimpl.C;h=fb46ea88cc2aa86342592d0291dde68db5c37e92;hb=15271fce0705ea5611647b5b3d1e993362ff5284;hp=de14a84718959e093c6b68f80bc17e6082054515;hpb=fdc6082cfc9ca47bd6e8482ab78dc1fd7ff4a02c;p=lyx.git diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index de14a84718..fb46ea88cc 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -53,6 +53,7 @@ #include "insets/insettabular.h" #include "insets/insettheorem.h" #include "insets/insetcaption.h" +#include "insets/insetfloatlist.h" #include "mathed/formulamacro.h" #include "gettext.h" @@ -807,73 +808,6 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y, return; } -#ifndef NEW_INSETS - // check whether we want to open a float - if (bv_->text) { - bool hit = false; - char c = ' '; - if (bv_->text->cursor.pos() < - bv_->text->cursor.par()->Last()) { - c = bv_->text->cursor.par()-> - GetChar(bv_->text->cursor.pos()); - } - if(!bv_->text->selection) - if (c == LyXParagraph::META_FOOTNOTE - || c == LyXParagraph::META_MARGIN - || c == LyXParagraph::META_FIG - || c == LyXParagraph::META_TAB - || c == LyXParagraph::META_WIDE_FIG - || c == LyXParagraph::META_WIDE_TAB - || c == LyXParagraph::META_ALGORITHM){ - hit = true; - } else - if (bv_->text->cursor.pos() - 1 >= 0) { - c = bv_->text->cursor.par()-> - GetChar(bv_->text->cursor.pos() - 1); - if (c == LyXParagraph::META_FOOTNOTE - || c == LyXParagraph::META_MARGIN - || c == LyXParagraph::META_FIG - || c == LyXParagraph::META_TAB - || c == LyXParagraph::META_WIDE_FIG - || c == LyXParagraph::META_WIDE_TAB - || c == LyXParagraph::META_ALGORITHM){ - // We are one step too far to the right - bv_->text->CursorLeft(bv_); - hit = true; - } - } - if (hit == true) { - bv_->toggleFloat(); - selection_possible = false; - return; - } - } - // Do we want to close a float? (click on the float-label) - if (bv_->text->cursor.row()->par()->footnoteflag == - LyXParagraph::OPEN_FOOTNOTE - && bv_->text->cursor.row()->previous() && - bv_->text->cursor.row()->previous()->par()-> - footnoteflag != LyXParagraph::OPEN_FOOTNOTE){ - LyXFont font(LyXFont::ALL_SANE); - font.setSize(LyXFont::SIZE_FOOTNOTE); - - int box_x = 20; // LYX_PAPER_MARGIN; - box_x += lyxfont::width(" wide-tab ", font); - - unsigned int screen_first = bv_->text->first; - - if (x < box_x - && y + screen_first > bv_->text->cursor.y() - - bv_->text->cursor.row()->baseline() - && y + screen_first < bv_->text->cursor.y() - - bv_->text->cursor.row()->baseline() - + lyxfont::maxAscent(font) * 1.2 + lyxfont::maxDescent(font) * 1.2) { - bv_->toggleFloat(); - selection_possible = false; - return; - } - } -#else // check whether we want to open a float if (bv_->text) { bool hit = false; @@ -892,7 +826,7 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y, return; } } -#endif + // Maybe we want to edit a bibitem ale970302 if (bv_->text->cursor.par()->bibkey && x < 20 + bibitemMaxWidth(bv_, textclasslist. @@ -923,11 +857,7 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y, text->SetCursor(bv_, cursor, cursor.par(),cursor.pos(),true); -#ifndef NEW_INSETS - if (cursor.pos() < cursor.par()->Last() -#else if (cursor.pos() < cursor.par()->size() -#endif && cursor.par()->GetChar(cursor.pos()) == LyXParagraph::META_INSET && cursor.par()->GetInset(cursor.pos()) && cursor.par()->GetInset(cursor.pos())->Editable()) { @@ -972,7 +902,8 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y, #if 0 if (move_cursor && (tmpinset != bv_->theLockingInset())) #endif - text->SetCursor(bv_, cursor.par(),cursor.pos()-1,true); + text->SetCursor(bv_, cursor.par(), + cursor.pos() - 1, true); x = x - start_x; // The origin of an inset is on the baseline y = y_tmp - (text->cursor.y()); @@ -1219,7 +1150,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i) if (i >= saved_positions_num) return; - string fname = saved_positions[i].filename; + string const fname = saved_positions[i].filename; beforeChange(bv_->text); @@ -1234,13 +1165,9 @@ void BufferView::Pimpl::restorePosition(unsigned int i) if (!par) return; -#ifndef NEW_INSETS - bv_->text->SetCursor(bv_, par, - min(par->Last(), saved_positions[i].par_pos)); -#else bv_->text->SetCursor(bv_, par, min(par->size(), saved_positions[i].par_pos)); -#endif + update(bv_->text, BufferView::SELECT|BufferView::FITCUR); if (i > 0) { string const str = _("Moved to bookmark") + ' ' + tostr(i); @@ -1503,21 +1430,9 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) break; case LFUN_TOC_INSERT: - case LFUN_LOA_INSERT: - case LFUN_LOF_INSERT: - case LFUN_LOT_INSERT: { InsetCommandParams p; - - if (action == LFUN_TOC_INSERT ) - p.setCmdName("tableofcontents"); - else if (action == LFUN_LOA_INSERT ) - p.setCmdName("listof{algorithm}{List of Algorithms}"); - else if (action == LFUN_LOF_INSERT ) - p.setCmdName("listoffigures"); - else - p.setCmdName("listoftables"); - + p.setCmdName("tableofcontents"); Inset * inset = new InsetTOC(p); if (!bv_->insertInset(inset, "Standard", true)) delete inset; @@ -1838,11 +1753,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR); if (is_rtl) TEXT(bv_)->CursorLeft(bv_, false); -#ifndef NEW_INSETS - if (TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->Last() -#else if (TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->size() -#endif && TEXT(bv_)->cursor.par()->GetChar(TEXT(bv_)->cursor.pos()) == LyXParagraph::META_INSET && TEXT(bv_)->cursor.par()->GetInset(TEXT(bv_)->cursor.pos()) @@ -1851,10 +1762,10 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) owner_->getLyXFunc()->setMessage(tmpinset->EditMessage()); int y = 0; if (is_rtl) { - LyXFont font = + LyXFont const font = TEXT(bv_)->GetFont(buffer_, - TEXT(bv_)->cursor.par(), - TEXT(bv_)->cursor.pos()); + TEXT(bv_)->cursor.par(), + TEXT(bv_)->cursor.pos()); y = tmpinset->descent(bv_,font); } tmpinset->Edit(bv_, 0, y, 0); @@ -1880,11 +1791,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) if (!is_rtl) TEXT(bv_)->CursorLeft(bv_, false); if ((is_rtl || cur != TEXT(bv_)->cursor) && // only if really moved! -#ifndef NEW_INSETS - TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->Last() && -#else TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->size() && -#endif (TEXT(bv_)->cursor.par()->GetChar(TEXT(bv_)->cursor.pos()) == LyXParagraph::META_INSET) && TEXT(bv_)->cursor.par()->GetInset(TEXT(bv_)->cursor.pos()) && @@ -2202,13 +2109,16 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) case LFUN_PROTECTEDSPACE: { - LyXLayout const & style = - textclasslist.Style(buffer_->params.textclass, - TEXT(bv_)->cursor.par()->GetLayout()); + LyXLayout const & style = textclasslist + .Style(buffer_->params.textclass, + TEXT(bv_)->cursor.par()->GetLayout()); if (style.free_spacing) { TEXT(bv_)->InsertChar(bv_, ' '); - update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + update(TEXT(bv_), + BufferView::SELECT + | BufferView::FITCUR + | BufferView::CHANGE); } else { bv_->protectedBlank(TEXT(bv_)); } @@ -2219,12 +2129,14 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) case LFUN_SETMARK: if (TEXT(bv_)->mark_set) { beforeChange(TEXT(bv_)); - update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR); + update(TEXT(bv_), + BufferView::SELECT|BufferView::FITCUR); owner_->getLyXFunc()->setMessage(N_("Mark removed")); } else { beforeChange(TEXT(bv_)); TEXT(bv_)->mark_set = 1; - update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR); + update(TEXT(bv_), + BufferView::SELECT|BufferView::FITCUR); owner_->getLyXFunc()->setMessage(N_("Mark set")); } TEXT(bv_)->sel_cursor = TEXT(bv_)->cursor; @@ -2236,7 +2148,9 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) TEXT(bv_)->sel_cursor = TEXT(bv_)->cursor; update(TEXT(bv_), - BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + BufferView::SELECT + | BufferView::FITCUR + | BufferView::CHANGE); // It is possible to make it a lot faster still // just comment out the line below... showCursor(); @@ -2255,11 +2169,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) LyXCursor cursor = TEXT(bv_)->cursor; if (!TEXT(bv_)->selection) { -#ifndef NEW_INSETS - if (cursor.pos() == cursor.par()->Last()) { -#else if (cursor.pos() == cursor.par()->size()) { -#endif TEXT(bv_)->CursorRight(bv_); cursor = TEXT(bv_)->cursor; if (cursor.pos() == 0 @@ -2955,6 +2865,15 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) } break; + case LFUN_FLOAT_LIST: + { + // We should check the argument for validity. (Lgb) + Inset * inset = new InsetFloatList(argument); + if (!bv_->insertInset(inset, "Standard", true)) + delete inset; + } + break; + case LFUN_INSERT_NOTE: bv_->insertNote(); break;