2 * \file BufferView_pimpl.C
3 * Copyright 2002 the LyX Team
4 * Read the file COPYING
12 #pragma implementation
15 #include "BufferView_pimpl.h"
16 #include "frontends/WorkArea.h"
17 #include "frontends/screen.h"
18 #include "frontends/LyXScreenFactory.h"
19 #include "frontends/WorkAreaFactory.h"
20 #include "frontends/Dialogs.h"
21 #include "frontends/Alert.h"
22 #include "frontends/FileDialog.h"
25 #include "paragraph.h"
26 #include "frontends/LyXView.h"
27 #include "commandtags.h"
30 #include "bufferview_funcs.h"
31 #include "TextCache.h"
32 #include "bufferlist.h"
35 // added for Dispatch functions
38 #include "FloatList.h"
40 #include "ParagraphParameters.h"
41 #include "undo_funcs.h"
42 #include "funcrequest.h"
44 #include "insets/insetbib.h"
45 #include "insets/insettext.h"
46 #include "insets/inseturl.h"
47 #include "insets/insetlatexaccent.h"
48 #include "insets/insettoc.h"
49 #include "insets/insetref.h"
50 #include "insets/insetparent.h"
51 #include "insets/insetindex.h"
52 #include "insets/insetinclude.h"
53 #include "insets/insetcite.h"
54 #include "insets/insetgraphics.h"
55 #include "insets/insetmarginal.h"
56 #include "insets/insetcaption.h"
57 #include "insets/insetfloatlist.h"
59 #include "mathed/formulabase.h"
61 #include "graphics/Previews.h"
63 #include "support/LAssert.h"
64 #include "support/lstrings.h"
65 #include "support/filetools.h"
67 #include <boost/bind.hpp>
68 #include <boost/signals/connection.hpp>
84 /* the selection possible is needed, that only motion events are
85 * used, where the bottom press event was on the drawing area too */
86 bool selection_possible = false;
88 extern BufferList bufferlist;
89 extern int bibitemMaxWidth(BufferView *, LyXFont const &);
94 unsigned int const saved_positions_num = 20;
96 // All the below connection objects are needed because of a bug in some
97 // versions of GCC (<=2.96 are on the suspects list.) By having and assigning
98 // to these connections we avoid a segfault upon startup, and also at exit.
101 boost::signals::connection timecon;
102 boost::signals::connection doccon;
103 boost::signals::connection resizecon;
104 boost::signals::connection bpresscon;
105 boost::signals::connection breleasecon;
106 boost::signals::connection motioncon;
107 boost::signals::connection doublecon;
108 boost::signals::connection triplecon;
109 boost::signals::connection kpresscon;
110 boost::signals::connection selectioncon;
111 boost::signals::connection lostcon;
116 BufferView::Pimpl::Pimpl(BufferView * bv, LyXView * owner,
117 int xpos, int ypos, int width, int height)
118 : bv_(bv), owner_(owner), buffer_(0), cursor_timeout(400),
119 using_xterm_cursor(false)
121 workarea_.reset(WorkAreaFactory::create(xpos, ypos, width, height));
122 screen_.reset(LyXScreenFactory::create(workarea()));
125 doccon = workarea().scrollDocView
126 .connect(boost::bind(&BufferView::Pimpl::scrollDocView, this, _1));
127 resizecon = workarea().workAreaResize
128 .connect(boost::bind(&BufferView::Pimpl::workAreaResize, this));
129 bpresscon = workarea().workAreaButtonPress
130 .connect(boost::bind(&BufferView::Pimpl::workAreaButtonPress, this, _1, _2, _3));
131 breleasecon = workarea().workAreaButtonRelease
132 .connect(boost::bind(&BufferView::Pimpl::workAreaButtonRelease, this, _1, _2, _3));
133 motioncon = workarea().workAreaMotionNotify
134 .connect(boost::bind(&BufferView::Pimpl::workAreaMotionNotify, this, _1, _2, _3));
135 doublecon = workarea().workAreaDoubleClick
136 .connect(boost::bind(&BufferView::Pimpl::doubleClick, this, _1, _2, _3));
137 triplecon = workarea().workAreaTripleClick
138 .connect(boost::bind(&BufferView::Pimpl::tripleClick, this, _1, _2, _3));
139 kpresscon = workarea().workAreaKeyPress
140 .connect(boost::bind(&BufferView::Pimpl::workAreaKeyPress, this, _1, _2));
141 selectioncon = workarea().selectionRequested
142 .connect(boost::bind(&BufferView::Pimpl::selectionRequested, this));
143 lostcon = workarea().selectionLost
144 .connect(boost::bind(&BufferView::Pimpl::selectionLost, this));
146 timecon = cursor_timeout.timeout
147 .connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
148 cursor_timeout.start();
149 saved_positions.resize(saved_positions_num);
153 WorkArea & BufferView::Pimpl::workarea() const
155 return *workarea_.get();
159 LyXScreen & BufferView::Pimpl::screen() const
161 return *screen_.get();
165 Painter & BufferView::Pimpl::painter() const
167 return workarea().getPainter();
171 void BufferView::Pimpl::buffer(Buffer * b)
173 lyxerr[Debug::INFO] << "Setting buffer in BufferView ("
176 buffer_->delUser(bv_);
178 // Put the old text into the TextCache, but
179 // only if the buffer is still loaded.
180 // Also set the owner of the test to 0
181 // bv_->text->owner(0);
182 textcache.add(buffer_, workarea().workWidth(), bv_->text);
183 if (lyxerr.debugging())
184 textcache.show(lyxerr, "BufferView::buffer");
189 // set current buffer
192 if (bufferlist.getState() == BufferList::CLOSING) return;
194 // if we are closing the buffer, use the first buffer as current
196 buffer_ = bufferlist.first();
200 lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl;
201 buffer_->addUser(bv_);
203 // If we don't have a text object for this, we make one
204 if (bv_->text == 0) {
205 resizeCurrentBuffer();
208 // FIXME: needed when ?
210 screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y);
212 // Similarly, buffer-dependent dialogs should be updated or
213 // hidden. This should go here because some dialogs (eg ToC)
214 // require bv_->text.
215 owner_->getDialogs().updateBufferDependent(true);
217 lyxerr[Debug::INFO] << " No Buffer!" << endl;
218 owner_->getDialogs().hideBufferDependent();
220 // Also remove all remaining text's from the testcache.
221 // (there should not be any!) (if there is any it is a
223 if (lyxerr.debugging())
224 textcache.show(lyxerr, "buffer delete all");
230 owner_->updateMenubar();
231 owner_->updateToolbar();
232 owner_->updateLayoutChoice();
233 owner_->updateWindowTitle();
235 if (grfx::Previews::activated() && buffer_)
236 grfx::Previews::get().generateBufferPreviews(*buffer_);
240 bool BufferView::Pimpl::fitCursor()
244 if (bv_->theLockingInset()) {
245 bv_->theLockingInset()->fitInsetCursor(bv_);
248 ret = screen().fitCursor(bv_->text, bv_);
251 bv_->owner()->getDialogs().updateParagraph();
258 void BufferView::Pimpl::redoCurrentBuffer()
260 lyxerr[Debug::INFO] << "BufferView::redoCurrentBuffer" << endl;
261 if (buffer_ && bv_->text) {
262 resizeCurrentBuffer();
264 owner_->updateLayoutChoice();
270 int BufferView::Pimpl::resizeCurrentBuffer()
272 lyxerr[Debug::INFO] << "resizeCurrentBuffer" << endl;
275 Paragraph * selstartpar = 0;
276 Paragraph * selendpar = 0;
277 UpdatableInset * the_locking_inset = 0;
280 pos_type selstartpos = 0;
281 pos_type selendpos = 0;
282 bool selection = false;
283 bool mark_set = false;
285 owner_->prohibitInput();
287 owner_->message(_("Formatting document..."));
290 par = bv_->text->cursor.par();
291 pos = bv_->text->cursor.pos();
292 selstartpar = bv_->text->selection.start.par();
293 selstartpos = bv_->text->selection.start.pos();
294 selendpar = bv_->text->selection.end.par();
295 selendpos = bv_->text->selection.end.pos();
296 selection = bv_->text->selection.set();
297 mark_set = bv_->text->selection.mark();
298 the_locking_inset = bv_->theLockingInset();
299 buffer_->resizeInsets(bv_);
300 // I don't think the delete and new are necessary here we just could
301 // call only init! (Jug 20020419)
303 bv_->text = new LyXText(bv_);
304 bv_->text->init(bv_);
306 // See if we have a text in TextCache that fits
307 // the new buffer_ with the correct width.
308 bv_->text = textcache.findFit(buffer_, workarea().workWidth());
310 if (lyxerr.debugging()) {
311 lyxerr << "Found a LyXText that fits:\n";
312 textcache.show(lyxerr, make_pair(buffer_, make_pair(workarea().workWidth(), bv_->text)));
314 // Set the owner of the newly found text
315 // bv_->text->owner(bv_);
316 if (lyxerr.debugging())
317 textcache.show(lyxerr, "resizeCurrentBuffer");
319 bv_->text = new LyXText(bv_);
320 bv_->text->init(bv_);
321 //buffer_->resizeInsets(bv_);
326 bv_->text->selection.set(true);
327 // At this point just to avoid the Delete-Empty-Paragraph-
328 // Mechanism when setting the cursor.
329 bv_->text->selection.mark(mark_set);
331 bv_->text->setCursor(bv_, selstartpar, selstartpos);
332 bv_->text->selection.cursor = bv_->text->cursor;
333 bv_->text->setCursor(bv_, selendpar, selendpos);
334 bv_->text->setSelection(bv_);
335 bv_->text->setCursor(bv_, par, pos);
337 bv_->text->setCursor(bv_, par, pos);
338 bv_->text->selection.cursor = bv_->text->cursor;
339 bv_->text->selection.set(false);
341 // remake the inset locking
342 bv_->theLockingInset(the_locking_inset);
345 bv_->text->first_y = screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y);
348 owner_->allowInput();
356 void BufferView::Pimpl::repaint()
358 // Regenerate the screen.
359 screen().redraw(bv_->text, bv_);
363 void BufferView::Pimpl::updateScrollbar()
366 lyxerr[Debug::GUI] << "no text in updateScrollbar" << endl;
367 workarea().setScrollbarParams(0, 0, 0);
371 LyXText const & t = *bv_->text;
373 lyxerr[Debug::GUI] << "Updating scrollbar: h " << t.height << ", first_y "
374 << t.first_y << ", default height " << t.defaultHeight() << endl;
376 workarea().setScrollbarParams(t.height, t.first_y, t.defaultHeight());
380 void BufferView::Pimpl::scrollDocView(int value)
382 lyxerr[Debug::GUI] << "scrollDocView of " << value << endl;
384 if (!buffer_) return;
386 screen().draw(bv_->text, bv_, value);
388 if (!lyxrc.cursor_follows_scrollbar) {
392 LyXText * vbt = bv_->text;
394 int const height = vbt->defaultHeight();
395 int const first = static_cast<int>((bv_->text->first_y + height));
396 int const last = static_cast<int>((bv_->text->first_y + workarea().workHeight() - height));
398 if (vbt->cursor.y() < first)
399 vbt->setCursorFromCoordinates(bv_, 0, first);
400 else if (vbt->cursor.y() > last)
401 vbt->setCursorFromCoordinates(bv_, 0, last);
405 int BufferView::Pimpl::scroll(long time)
410 LyXText const * t = bv_->text;
412 double const diff = t->defaultHeight()
413 + double(time) * double(time) * 0.125;
415 scrollDocView(int(diff));
416 workarea().setScrollbarParams(t->height, t->first_y, t->defaultHeight());
421 void BufferView::Pimpl::workAreaKeyPress(LyXKeySymPtr key,
422 key_modifier::state state)
424 bv_->owner()->getLyXFunc().processKeySym(key, state);
428 void BufferView::Pimpl::workAreaMotionNotify(int x, int y, mouse_button::state state)
430 // Only use motion with button 1
431 if (!(state & mouse_button::button1))
437 // Check for inset locking
438 if (bv_->theLockingInset()) {
439 LyXCursor cursor = bv_->text->cursor;
440 LyXFont font = bv_->text->getFont(buffer_,
441 cursor.par(), cursor.pos());
442 int width = bv_->theLockingInset()->width(bv_, font);
443 int inset_x = font.isVisibleRightToLeft()
444 ? cursor.ix() - width : cursor.ix();
445 int start_x = inset_x + bv_->theLockingInset()->scroll();
447 FuncRequest cmd(bv_, LFUN_MOUSE_MOTION,
448 x - start_x, y - cursor.iy() + bv_->text->first_y, state);
449 bv_->theLockingInset()->localDispatch(cmd);
453 // The test for not selection possible is needed, that only motion
454 // events are used, where the bottom press event was on
455 // the drawing area too
456 if (!selection_possible)
459 screen().hideCursor();
461 Row * cursorrow = bv_->text->cursor.row();
462 bv_->text->setCursorFromCoordinates(bv_, x, y + bv_->text->first_y);
464 // sorry for this but I have a strange error that the y value jumps at
465 // a certain point. This seems like an error in my xforms library or
466 // in some other local environment, but I would like to leave this here
467 // for the moment until I can remove this (Jug 20020418)
468 if (y_before < bv_->text->cursor.y())
469 lyxerr << y_before << ":" << bv_->text->cursor.y() << endl;
471 // This is to allow jumping over large insets
472 if (cursorrow == bv_->text->cursor.row()) {
473 if (y >= int(workarea().workHeight())) {
474 bv_->text->cursorDown(bv_, false);
476 bv_->text->cursorUp(bv_, false);
480 if (!bv_->text->selection.set())
481 update(bv_->text, BufferView::UPDATE); // Maybe an empty line was deleted
483 bv_->text->setSelection(bv_);
484 screen().toggleToggle(bv_->text, bv_);
490 // Single-click on work area
491 void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
492 mouse_button::state button)
497 // ok ok, this is a hack (for xforms)
498 if (button == mouse_button::button4) {
499 scroll(-lyxrc.wheel_jump);
500 // We shouldn't go further down as we really should only do the
501 // scrolling and be done with this. Otherwise we may open some
502 // dialogs (Jug 20020424).
504 } else if (button == mouse_button::button5) {
505 scroll(lyxrc.wheel_jump);
506 // We shouldn't go further down as we really should only do the
507 // scrolling and be done with this. Otherwise we may open some
508 // dialogs (Jug 20020424).
512 Inset * inset_hit = checkInsetHit(bv_->text, xpos, ypos);
514 // Middle button press pastes if we have a selection
515 // We do this here as if the selection was inside an inset
516 // it could get cleared on the unlocking of the inset so
517 // we have to check this first
518 bool paste_internally = false;
519 if (button == mouse_button::button2 && bv_->getLyXText()->selection.set()) {
520 owner_->dispatch(FuncRequest(LFUN_COPY));
521 paste_internally = true;
524 int const screen_first = bv_->text->first_y;
526 if (bv_->theLockingInset()) {
527 // We are in inset locking mode
529 // Check whether the inset was hit. If not reset mode,
530 // otherwise give the event to the inset
531 if (inset_hit == bv_->theLockingInset()) {
532 FuncRequest cmd(bv_, LFUN_MOUSE_PRESS, xpos, ypos, button);
533 bv_->theLockingInset()->localDispatch(cmd);
536 bv_->unlockInset(bv_->theLockingInset());
540 selection_possible = true;
541 screen().hideCursor();
543 // Clear the selection
544 screen().toggleSelection(bv_->text, bv_);
545 bv_->text->clearSelection();
546 bv_->text->fullRebreak(bv_);
550 // Single left click in math inset?
551 if (isHighlyEditableInset(inset_hit)) {
552 // Highly editable inset, like math
553 UpdatableInset * inset = static_cast<UpdatableInset *>(inset_hit);
554 selection_possible = false;
555 owner_->updateLayoutChoice();
556 owner_->message(inset->editMessage());
557 //inset->edit(bv_, xpos, ypos, button);
558 // We just have to lock the inset before calling a PressEvent on it!
559 // we don't need the edit() call here! (Jug20020329)
560 if (!bv_->lockInset(inset)) {
561 lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
563 FuncRequest cmd(bv_, LFUN_MOUSE_PRESS, xpos, ypos, button);
564 inset->localDispatch(cmd);
567 // I'm not sure we should continue here if we hit an inset (Jug20020403)
569 // Right click on a footnote flag opens float menu
570 if (button == mouse_button::button3) {
571 selection_possible = false;
575 if (!inset_hit) // otherwise it was already set in checkInsetHit(...)
576 bv_->text->setCursorFromCoordinates(bv_, xpos, ypos + screen_first);
578 bv_->text->selection.cursor = bv_->text->cursor;
579 bv_->text->cursor.x_fix(bv_->text->cursor.x());
581 owner_->updateLayoutChoice();
583 selection_possible = false;
586 // Insert primary selection with middle mouse
587 // if there is a local selection in the current buffer,
589 if (button == mouse_button::button2) {
590 if (paste_internally)
591 owner_->dispatch(FuncRequest(LFUN_PASTE));
593 owner_->dispatch(FuncRequest(LFUN_PASTESELECTION, "paragraph"));
594 selection_possible = false;
600 void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, mouse_button::state button)
605 LyXText * text = bv_->getLyXText();
607 if (text->bv_owner && bv_->theLockingInset())
610 if (button == mouse_button::button1) {
611 if (text->bv_owner) {
612 screen().hideCursor();
613 screen().toggleSelection(text, bv_);
614 text->selectWord(bv_, LyXText::WHOLE_WORD_STRICT);
615 screen().toggleSelection(text, bv_, false);
617 text->selectWord(bv_, LyXText::WHOLE_WORD_STRICT);
619 // This will fit the cursor on the screen if necessary
620 update(text, BufferView::SELECT|BufferView::FITCUR);
621 workarea().haveSelection(bv_->getLyXText()->selection.set());
626 void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, mouse_button::state button)
631 LyXText * text = bv_->getLyXText();
633 if (text->bv_owner && bv_->theLockingInset())
636 if (button == mouse_button::button1) {
637 if (text->bv_owner) {
638 screen().hideCursor();
639 screen().toggleSelection(text, bv_);
641 text->cursorHome(bv_);
642 text->selection.cursor = text->cursor;
643 text->cursorEnd(bv_);
644 text->setSelection(bv_);
645 if (text->bv_owner) {
646 screen().toggleSelection(text, bv_, false);
648 // This will fit the cursor on the screen if necessary
649 update(text, BufferView::SELECT|BufferView::FITCUR);
650 workarea().haveSelection(bv_->getLyXText()->selection.set());
655 void BufferView::Pimpl::selectionRequested()
662 LyXText * text = bv_->getLyXText();
664 if (text->selection.set() &&
665 (!bv_->text->xsel_cache.set() ||
666 text->selection.start != bv_->text->xsel_cache.start ||
667 text->selection.end != bv_->text->xsel_cache.end))
669 bv_->text->xsel_cache = text->selection;
670 sel = text->selectionAsString(bv_->buffer(), false);
671 } else if (!text->selection.set()) {
673 bv_->text->xsel_cache.set(false);
676 workarea().putClipboard(sel);
681 void BufferView::Pimpl::selectionLost()
686 bv_->getLyXText()->clearSelection();
688 bv_->text->xsel_cache.set(false);
693 void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
694 mouse_button::state button)
696 // do nothing if we used the mouse wheel
697 if (!buffer_ || button == mouse_button::button4 || button == mouse_button::button5)
700 // If we hit an inset, we have the inset coordinates in these
701 // and inset_hit points to the inset. If we do not hit an
702 // inset, inset_hit is 0, and inset_x == x, inset_y == y.
703 Inset * inset_hit = checkInsetHit(bv_->text, x, y);
705 if (bv_->theLockingInset()) {
706 // We are in inset locking mode.
708 // LyX does a kind of work-area grabbing for insets.
709 // Only a ButtonPress FuncRequest outside the inset will
710 // force a insetUnlock.
711 FuncRequest cmd(bv_, LFUN_MOUSE_RELEASE, x, y, button);
712 bv_->theLockingInset()->localDispatch(cmd);
716 selection_possible = false;
718 if (button == mouse_button::button2)
722 if (button == mouse_button::button1) {
723 workarea().haveSelection(bv_->getLyXText()->selection.set());
727 owner_->view_state_changed();
728 owner_->updateMenubar();
729 owner_->updateToolbar();
731 // Did we hit an editable inset?
733 selection_possible = false;
735 // if we reach this point with a selection, it
736 // must mean we are currently selecting.
737 // But we don't want to open the inset
738 // because that is annoying for the user.
739 // So just pretend we didn't hit it.
740 // this is OK because a "kosher" ButtonRelease
741 // will follow a ButtonPress that clears
743 // Note this also fixes selection drawing
744 // problems if we end up opening an inset
745 if (bv_->getLyXText()->selection.set())
748 // CHECK fix this proper in 0.13
749 // well, maybe 13.0 !!!!!!!!!
751 // Following a ref shouldn't issue
752 // a push on the undo-stack
753 // anylonger, now that we have
754 // keybindings for following
755 // references and returning from
756 // references. IMHO though, it
757 // should be the inset's own business
758 // to push or not push on the undo
759 // stack. They don't *have* to
760 // alter the document...
762 // ...or maybe the SetCursorParUndo()
763 // below isn't necessary at all anylonger?
764 if (inset_hit->lyxCode() == Inset::REF_CODE) {
765 setCursorParUndo(bv_);
768 owner_->message(inset_hit->editMessage());
770 if (isHighlyEditableInset(inset_hit)) {
771 // Highly editable inset, like math
772 UpdatableInset *inset = (UpdatableInset *)inset_hit;
773 FuncRequest cmd(bv_, LFUN_MOUSE_RELEASE, x, y, button);
774 inset->localDispatch(cmd);
776 FuncRequest cmd(bv_, LFUN_MOUSE_RELEASE, x, y, button);
777 inset_hit->localDispatch(cmd);
778 // IMO this is a grosshack! Inset's should be changed so that
779 // they call the actions they have to do with the insetButtonRel.
780 // function and not in the edit(). This should be changed
783 #warning Please remove donot call inset->edit() here (Jug 20020812)
785 inset_hit->edit(bv_, x, y, button);
790 // Maybe we want to edit a bibitem ale970302
791 if (bv_->text->cursor.par()->bibkey) {
792 bool const is_rtl = bv_->text->cursor.par()->isRightToLeftPar(buffer_->params);
793 int const width = bibitemMaxWidth(bv_, buffer_->params.getLyXTextClass().defaultfont());
794 if ((is_rtl && x > bv_->text->workWidth(bv_)-20-width) ||
795 (!is_rtl && x < 20+width)) {
796 bv_->text->cursor.par()->bibkey->edit(bv_, 0, 0, mouse_button::none);
804 Box BufferView::Pimpl::insetDimensions(LyXText const & text,
805 LyXCursor const & cursor) const
807 Paragraph /*const*/ & par = *cursor.par();
808 pos_type const pos = cursor.pos();
810 lyx::Assert(par.getInset(pos));
812 Inset const & inset(*par.getInset(pos));
814 LyXFont const & font = text.getFont(buffer_, &par, pos);
816 int const width = inset.width(bv_, font);
817 int const inset_x = font.isVisibleRightToLeft()
818 ? (cursor.ix() - width) : cursor.ix();
821 inset_x + inset.scroll(),
823 cursor.iy() - inset.ascent(bv_, font),
824 cursor.iy() + inset.descent(bv_, font));
828 Inset * BufferView::Pimpl::checkInset(LyXText const & text,
829 LyXCursor const & cursor,
830 int & x, int & y) const
832 pos_type const pos(cursor.pos());
833 Paragraph /*const*/ & par(*cursor.par());
835 if (pos >= par.size() || !par.isInset(pos)) {
839 Inset /*const*/ * inset = par.getInset(pos);
841 if (!isEditableInset(inset)) {
845 Box b(insetDimensions(text, cursor));
847 if (!b.contained(x, y)) {
848 lyxerr[Debug::GUI] << "Missed inset at x,y " << x << "," << y
849 << " box " << b << endl;
853 text.setCursor(bv_, &par, pos, true);
856 // The origin of an inset is on the baseline
857 y -= text.cursor.iy();
863 Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y)
865 int y_tmp = y + text->first_y;
868 text->setCursorFromCoordinates(bv_, cursor, x, y_tmp);
870 Inset * inset = checkInset(*text, cursor, x, y_tmp);
877 // look at previous position
878 if (cursor.pos() == 0) {
883 text->setCursor(bv_, cursor, cursor.par(), cursor.pos() - 1, true);
885 inset = checkInset(*text, cursor, x, y_tmp);
893 void BufferView::Pimpl::workAreaResize()
895 static int work_area_width;
896 static int work_area_height;
898 bool const widthChange = workarea().workWidth() != work_area_width;
899 bool const heightChange = workarea().workHeight() != work_area_height;
901 // update from work area
902 work_area_width = workarea().workWidth();
903 work_area_height = workarea().workHeight();
907 // The visible LyXView need a resize
908 resizeCurrentBuffer();
910 // Remove all texts from the textcache
911 // This is not _really_ what we want to do. What
912 // we really want to do is to delete in textcache
913 // that does not have a BufferView with matching
914 // width, but as long as we have only one BufferView
915 // deleting all gives the same result.
916 if (lyxerr.debugging())
917 textcache.show(lyxerr, "Expose delete all");
919 // FIXME: this is already done in resizeCurrentBuffer() ??
920 buffer_->resizeInsets(bv_);
921 } else if (heightChange) {
922 // fitCursor() ensures we don't jump back
923 // to the start of the document on vertical
929 if (widthChange || heightChange) {
933 // always make sure that the scrollbar is sane.
935 owner_->updateLayoutChoice();
940 void BufferView::Pimpl::update()
942 if (!bv_->theLockingInset() || !bv_->theLockingInset()->nodraw()) {
943 LyXText::text_status st = bv_->text->status();
944 screen().update(bv_->text, bv_);
946 while (bv_->text->status() == LyXText::CHANGED_IN_DRAW) {
947 bv_->text->fullRebreak(bv_);
948 st = LyXText::NEED_MORE_REFRESH;
949 bv_->text->setCursor(bv_, bv_->text->cursor.par(),
950 bv_->text->cursor.pos());
951 if (bv_->text->selection.set()) {
952 bv_->text->setCursor(bv_, bv_->text->selection.start,
953 bv_->text->selection.start.par(),
954 bv_->text->selection.start.pos());
955 bv_->text->setCursor(bv_, bv_->text->selection.end,
956 bv_->text->selection.end.par(),
957 bv_->text->selection.end.pos());
960 bv_->text->status(bv_, st);
961 screen().update(bv_->text, bv_);
963 // do this here instead of in the screen::update because of
965 bv_->text->status(bv_, LyXText::UNCHANGED);
971 // Values used when calling update:
973 // -2 - update, move sel_cursor if selection, fitcursor
974 // -1 - update, move sel_cursor if selection, fitcursor, mark dirty
975 // 0 - update, move sel_cursor if selection, fitcursor
976 // 1 - update, move sel_cursor if selection, fitcursor, mark dirty
977 // 3 - update, move sel_cursor if selection
980 // a simple redraw of the parts that need refresh
982 // move sel_cursor if selection -
983 // the text's sel_cursor is moved if there is selection is progress
986 // fitCursor() is called and the scrollbar updated
989 // the buffer is marked dirty.
998 // UPDATE_ONLY = UPDATE;
999 // UPDATE_SELECT = UPDATE | SELECT;
1000 // UPDATE_SELECT_MOVE = UPDATE | SELECT | FITCUR;
1001 // UPDATE_SELECT_MOVE_AFTER_CHANGE = UPDATE | SELECT | FITCUR | CHANGE;
1003 // update(-3) -> update(0) -> update(0) -> update(UPDATE)
1004 // update(-2) -> update(1 + 2) -> update(3) -> update(SELECT|FITCUR)
1005 // update(-1) -> update(1 + 2 + 4) -> update(7) -> update(SELECT|FITCUR|CHANGE)
1006 // update(1) -> update(1 + 2 + 4) -> update(7) -> update(SELECT|FITCUR|CHANGE)
1007 // update(3) -> update(1) -> update(1) -> update(SELECT)
1009 void BufferView::Pimpl::update(LyXText * text, BufferView::UpdateCodes f)
1011 owner_->updateLayoutChoice();
1013 if (!text->selection.set() && (f & SELECT)) {
1014 text->selection.cursor = text->cursor;
1017 text->fullRebreak(bv_);
1019 if (text->inset_owner) {
1020 text->inset_owner->setUpdateStatus(bv_, InsetText::NONE);
1021 updateInset(text->inset_owner, false);
1031 buffer_->markDirty();
1036 // Callback for cursor timer
1037 void BufferView::Pimpl::cursorToggle()
1040 cursor_timeout.restart();
1045 extern void reapSpellchecker(void);
1048 if (!bv_->theLockingInset()) {
1049 screen().cursorToggle(bv_);
1051 bv_->theLockingInset()->toggleInsetCursor(bv_);
1054 cursor_timeout.restart();
1058 bool BufferView::Pimpl::available() const
1060 if (buffer_ && bv_->text)
1066 void BufferView::Pimpl::beforeChange(LyXText * text)
1069 text->clearSelection();
1073 void BufferView::Pimpl::savePosition(unsigned int i)
1075 if (i >= saved_positions_num)
1077 saved_positions[i] = Position(buffer_->fileName(),
1078 bv_->text->cursor.par()->id(),
1079 bv_->text->cursor.pos());
1082 str << _("Saved bookmark") << ' ' << i;
1083 owner_->message(str.str().c_str());
1088 void BufferView::Pimpl::restorePosition(unsigned int i)
1090 if (i >= saved_positions_num)
1093 string const fname = saved_positions[i].filename;
1095 beforeChange(bv_->text);
1097 if (fname != buffer_->fileName()) {
1098 Buffer * b = bufferlist.exists(fname) ?
1099 bufferlist.getBuffer(fname) :
1100 bufferlist.loadLyXFile(fname); // don't ask, just load it
1101 if (b != 0) buffer(b);
1104 Paragraph * par = buffer_->getParFromID(saved_positions[i].par_id);
1108 bv_->text->setCursor(bv_, par,
1109 min(par->size(), saved_positions[i].par_pos));
1111 update(bv_->text, BufferView::SELECT | BufferView::FITCUR);
1114 str << _("Moved to bookmark") << ' ' << i;
1115 owner_->message(str.str().c_str());
1120 bool BufferView::Pimpl::isSavedPosition(unsigned int i)
1122 if (i >= saved_positions_num)
1125 return !saved_positions[i].filename.empty();
1129 void BufferView::Pimpl::switchKeyMap()
1131 if (!lyxrc.rtl_support)
1134 LyXText * text = bv_->getLyXText();
1135 if (text->real_current_font.isRightToLeft()
1136 && !(bv_->theLockingInset()
1137 && bv_->theLockingInset()->lyxCode() == Inset::ERT_CODE))
1139 if (owner_->getIntl().keymap == Intl::PRIMARY)
1140 owner_->getIntl().KeyMapSec();
1142 if (owner_->getIntl().keymap == Intl::SECONDARY)
1143 owner_->getIntl().KeyMapPrim();
1148 void BufferView::Pimpl::insetUnlock()
1150 if (bv_->theLockingInset()) {
1151 bv_->theLockingInset()->insetUnlock(bv_);
1152 bv_->theLockingInset(0);
1158 void BufferView::Pimpl::showCursor()
1160 if (bv_->theLockingInset())
1161 bv_->theLockingInset()->showInsetCursor(bv_);
1163 screen().showCursor(bv_->text, bv_);
1167 void BufferView::Pimpl::hideCursor()
1169 if (!bv_->theLockingInset())
1170 screen().hideCursor();
1174 void BufferView::Pimpl::toggleSelection(bool b)
1176 if (bv_->theLockingInset())
1177 bv_->theLockingInset()->toggleSelection(bv_, b);
1178 screen().toggleSelection(bv_->text, bv_, b);
1182 void BufferView::Pimpl::toggleToggle()
1184 screen().toggleToggle(bv_->text, bv_);
1188 void BufferView::Pimpl::center()
1190 LyXText * t = bv_->text;
1193 int const half_height = workarea().workHeight() / 2;
1196 if (t->cursor.y() > half_height) {
1197 new_y = t->cursor.y() - half_height;
1200 // FIXME: can we do this w/o calling screen directly ?
1201 // This updates first_y but means the fitCursor() call
1202 // from the update(FITCUR) doesn't realise that we might
1203 // have moved (e.g. from GOTOPARAGRAPH), so doesn't cause
1204 // the scrollbar to be updated as it should, so we have
1205 // to do it manually. Any operation that does a center()
1206 // and also might have moved first_y must make sure to call
1207 // updateScrollbar() currently. Never mind that this is a
1208 // pretty obfuscated way of updating t->first_y
1209 screen().draw(t, bv_, new_y);
1211 update(t, BufferView::SELECT | BufferView::FITCUR);
1215 void BufferView::Pimpl::stuffClipboard(string const & stuff) const
1217 workarea().putClipboard(stuff);
1222 * Dispatch functions for actions which can be valid for BufferView->text
1223 * and/or InsetText->text!!!
1227 Inset * BufferView::Pimpl::getInsetByCode(Inset::Code code)
1230 LyXCursor cursor = bv_->getLyXText()->cursor;
1231 Buffer::inset_iterator it =
1232 find_if(Buffer::inset_iterator(
1233 cursor.par(), cursor.pos()),
1234 buffer_->inset_iterator_end(),
1235 lyx::compare_memfun(&Inset::lyxCode, code));
1236 return it != buffer_->inset_iterator_end() ? (*it) : 0;
1238 // Ok, this is a little bit too brute force but it
1239 // should work for now. Better infrastructure is comming. (Lgb)
1241 Buffer * b = bv_->buffer();
1242 LyXCursor cursor = bv_->getLyXText()->cursor;
1244 Buffer::inset_iterator beg = b->inset_iterator_begin();
1245 Buffer::inset_iterator end = b->inset_iterator_end();
1247 bool cursor_par_seen = false;
1249 for (; beg != end; ++beg) {
1250 if (beg.getPar() == cursor.par()) {
1251 cursor_par_seen = true;
1253 if (cursor_par_seen) {
1254 if (beg.getPar() == cursor.par()
1255 && beg.getPos() >= cursor.pos()) {
1257 } else if (beg.getPar() != cursor.par()) {
1264 // Now find the first inset that matches code.
1265 for (; beg != end; ++beg) {
1266 if (beg->lyxCode() == code) {
1276 void BufferView::Pimpl::MenuInsertLyXFile(string const & filen)
1278 string filename = filen;
1280 if (filename.empty()) {
1281 // Launch a file browser
1282 string initpath = lyxrc.document_path;
1285 string const trypath = owner_->buffer()->filePath();
1286 // If directory is writeable, use this as default.
1287 if (IsDirWriteable(trypath))
1291 FileDialog fileDlg(bv_->owner(),
1292 _("Select LyX document to insert"),
1294 make_pair(string(_("Documents|#o#O")),
1295 string(lyxrc.document_path)),
1296 make_pair(string(_("Examples|#E#e")),
1297 string(AddPath(system_lyxdir, "examples"))));
1299 FileDialog::Result result =
1300 fileDlg.Select(initpath,
1301 _("*.lyx| LyX Documents (*.lyx)"));
1303 if (result.first == FileDialog::Later)
1306 filename = result.second;
1308 // check selected filename
1309 if (filename.empty()) {
1310 owner_->message(_("Canceled."));
1315 // get absolute path of file and add ".lyx" to the filename if
1317 filename = FileSearch(string(), filename, "lyx");
1319 string const disp_fn(MakeDisplayPath(filename));
1322 s1 << _("Inserting document") << ' '
1323 << disp_fn << " ...";
1324 owner_->message(s1.str().c_str());
1325 bool const res = bv_->insertLyXFile(filename);
1328 str << _("Document") << ' ' << disp_fn
1329 << ' ' << _("inserted.");
1330 owner_->message(str.str().c_str());
1333 str << _("Could not insert document") << ' '
1335 owner_->message(str.str().c_str());
1340 bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
1342 lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch: action["
1343 << ev.action <<"] arg[" << ev.argument << "]" << endl;
1345 LyXTextClass const & tclass = buffer_->params.getLyXTextClass();
1347 switch (ev.action) {
1349 case LFUN_TOC_INSERT:
1351 InsetCommandParams p;
1352 p.setCmdName("tableofcontents");
1353 Inset * inset = new InsetTOC(p);
1354 if (!insertInset(inset, tclass.defaultLayoutName()))
1359 case LFUN_SCROLL_INSET:
1360 // this is not handled here as this function is only active
1361 // if we have a locking_inset and that one is (or contains)
1365 case LFUN_INSET_GRAPHICS:
1367 Inset * new_inset = new InsetGraphics;
1368 if (!insertInset(new_inset)) {
1371 // this is need because you don't use a inset->Edit()
1372 updateInset(new_inset, true);
1373 new_inset->edit(bv_);
1378 case LFUN_LAYOUT_COPY:
1379 bv_->copyEnvironment();
1382 case LFUN_LAYOUT_PASTE:
1383 bv_->pasteEnvironment();
1387 case LFUN_DEPTH_MIN:
1388 changeDepth(bv_, bv_->getLyXText(), -1);
1391 case LFUN_DEPTH_PLUS:
1392 changeDepth(bv_, bv_->getLyXText(), 1);
1396 owner_->getDialogs().setUserFreeFont();
1399 case LFUN_FILE_INSERT:
1400 MenuInsertLyXFile(ev.argument);
1403 case LFUN_FILE_INSERT_ASCII_PARA:
1404 InsertAsciiFile(bv_, ev.argument, true);
1407 case LFUN_FILE_INSERT_ASCII:
1408 InsertAsciiFile(bv_, ev.argument, false);
1412 lang(bv_, ev.argument);
1414 owner_->view_state_changed();
1419 owner_->view_state_changed();
1424 owner_->view_state_changed();
1429 owner_->view_state_changed();
1434 owner_->view_state_changed();
1439 owner_->view_state_changed();
1444 owner_->view_state_changed();
1449 owner_->view_state_changed();
1452 case LFUN_UNDERLINE:
1454 owner_->view_state_changed();
1457 case LFUN_FONT_SIZE:
1458 fontSize(bv_, ev.argument);
1459 owner_->view_state_changed();
1462 case LFUN_FONT_STATE:
1463 owner_->getLyXFunc().setMessage(currentState(bv_));
1466 case LFUN_INSERT_LABEL:
1467 MenuInsertLabel(bv_, ev.argument);
1470 case LFUN_REF_INSERT:
1471 if (ev.argument.empty()) {
1472 InsetCommandParams p("ref");
1473 owner_->getDialogs().createRef(p.getAsString());
1475 InsetCommandParams p;
1476 p.setFromString(ev.argument);
1478 InsetRef * inset = new InsetRef(p, *buffer_);
1479 if (!insertInset(inset))
1482 updateInset(inset, true);
1486 case LFUN_BOOKMARK_SAVE:
1487 savePosition(strToUnsignedInt(ev.argument));
1490 case LFUN_BOOKMARK_GOTO:
1491 restorePosition(strToUnsignedInt(ev.argument));
1496 string label = ev.argument;
1497 if (label.empty()) {
1499 static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE));
1501 label = inset->getContents();
1506 if (!label.empty()) {
1507 //bv_->savePosition(0);
1508 if (!bv_->gotoLabel(label))
1509 Alert::alert(_("Error"),
1510 _("Couldn't find this label"),
1511 _("in current document."));
1519 InsetCommandParams p;
1520 if (ev.action == LFUN_HTMLURL)
1521 p.setCmdName("htmlurl");
1523 p.setCmdName("url");
1524 owner_->getDialogs().createUrl(p.getAsString());
1528 case LFUN_INSERT_URL:
1530 InsetCommandParams p;
1531 p.setFromString(ev.argument);
1533 InsetUrl * inset = new InsetUrl(p);
1534 if (!insertInset(inset))
1537 updateInset(inset, true);
1541 case LFUN_INSET_CAPTION:
1543 // Do we have a locking inset...
1544 if (bv_->theLockingInset()) {
1545 lyxerr << "Locking inset code: "
1546 << static_cast<int>(bv_->theLockingInset()->lyxCode());
1547 InsetCaption * new_inset =
1548 new InsetCaption(buffer_->params);
1549 new_inset->setOwner(bv_->theLockingInset());
1550 new_inset->setAutoBreakRows(true);
1551 new_inset->setDrawFrame(0, InsetText::LOCKED);
1552 new_inset->setFrameColor(0, LColor::captionframe);
1553 if (insertInset(new_inset))
1554 new_inset->edit(bv_);
1562 // --- accented characters ---------------------------
1565 case LFUN_CIRCUMFLEX:
1575 case LFUN_SPECIAL_CARON:
1578 case LFUN_HUNG_UMLAUT:
1581 if (ev.argument.empty()) {
1583 owner_->getLyXFunc().handleKeyFunc(ev.action);
1585 owner_->getLyXFunc().handleKeyFunc(ev.action);
1586 owner_->getIntl().getTransManager()
1587 .TranslateAndInsert(ev.argument[0], bv_->getLyXText());
1588 update(bv_->getLyXText(),
1590 | BufferView::FITCUR
1591 | BufferView::CHANGE);
1595 case LFUN_MATH_MACRO:
1596 case LFUN_MATH_DELIM:
1597 case LFUN_INSERT_MATRIX:
1598 case LFUN_INSERT_MATH:
1599 case LFUN_MATH_IMPORT_SELECTION: // Imports LaTeX from the X selection
1600 case LFUN_MATH_DISPLAY: // Open or create a displayed math inset
1601 case LFUN_MATH_MODE: // Open or create an inlined math inset
1602 case LFUN_GREEK: // Insert a single greek letter
1603 mathDispatch(FuncRequest(bv_, ev.action, ev.argument));
1606 case LFUN_CITATION_INSERT:
1608 InsetCommandParams p;
1609 p.setFromString(ev.argument);
1611 InsetCitation * inset = new InsetCitation(p);
1612 if (!insertInset(inset))
1615 updateInset(inset, true);
1619 case LFUN_INSERT_BIBTEX:
1621 // ale970405+lasgoutt970425
1622 // The argument can be up to two tokens separated
1623 // by a space. The first one is the bibstyle.
1624 string const db = token(ev.argument, ' ', 0);
1625 string bibstyle = token(ev.argument, ' ', 1);
1626 if (bibstyle.empty())
1629 InsetCommandParams p("BibTeX", db, bibstyle);
1630 InsetBibtex * inset = new InsetBibtex(p);
1632 if (insertInset(inset)) {
1633 if (ev.argument.empty())
1640 // BibTeX data bases
1641 case LFUN_BIBDB_ADD:
1643 InsetBibtex * inset =
1644 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
1646 inset->addDatabase(ev.argument);
1651 case LFUN_BIBDB_DEL:
1653 InsetBibtex * inset =
1654 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
1656 inset->delDatabase(ev.argument);
1661 case LFUN_BIBTEX_STYLE:
1663 InsetBibtex * inset =
1664 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
1666 inset->setOptions(ev.argument);
1671 case LFUN_INDEX_INSERT:
1673 string entry = ev.argument;
1675 entry = bv_->getLyXText()->getStringToIndex(bv_);
1677 if (entry.empty()) {
1678 owner_->getDialogs().createIndex();
1682 InsetIndex * inset = new InsetIndex(InsetCommandParams("index", entry));
1684 if (!insertInset(inset)) {
1687 updateInset(inset, true);
1692 case LFUN_INDEX_PRINT:
1694 InsetCommandParams p("printindex");
1695 Inset * inset = new InsetPrintIndex(p);
1696 if (!insertInset(inset, tclass.defaultLayoutName()))
1701 case LFUN_PARENTINSERT:
1703 InsetCommandParams p("lyxparent", ev.argument);
1704 Inset * inset = new InsetParent(p, *buffer_);
1705 if (!insertInset(inset, tclass.defaultLayoutName()))
1711 case LFUN_CHILD_INSERT:
1713 InsetInclude::Params p;
1714 p.cparams.setFromString(ev.argument);
1715 p.masterFilename_ = buffer_->fileName();
1717 InsetInclude * inset = new InsetInclude(p);
1718 if (!insertInset(inset))
1721 updateInset(inset, true);
1722 bv_->owner()->getDialogs().showInclude(inset);
1727 case LFUN_FLOAT_LIST:
1728 if (floatList.typeExist(ev.argument)) {
1729 Inset * inset = new InsetFloatList(ev.argument);
1730 if (!insertInset(inset, tclass.defaultLayoutName()))
1733 lyxerr << "Non-existent float type: "
1734 << ev.argument << endl;
1738 case LFUN_THESAURUS_ENTRY:
1740 string arg = ev.argument;
1743 arg = bv_->getLyXText()->selectionAsString(buffer_,
1747 if (arg.size() > 100 || arg.empty()) {
1748 // Get word or selection
1749 bv_->getLyXText()->selectWordWhenUnderCursor(bv_, LyXText::WHOLE_WORD);
1750 arg = bv_->getLyXText()->selectionAsString(buffer_, false);
1751 // FIXME: where is getLyXText()->unselect(bv_) ?
1755 bv_->owner()->getDialogs().showThesaurus(arg);
1759 case LFUN_UNKNOWN_ACTION:
1760 ev.errorMessage(N_("Unknown function!"));
1764 FuncRequest cmd = ev;
1766 return bv_->getLyXText()->dispatch(cmd);
1773 bool BufferView::Pimpl::insertInset(Inset * inset, string const & lout)
1775 // if we are in a locking inset we should try to insert the
1776 // inset there otherwise this is a illegal function now
1777 if (bv_->theLockingInset()) {
1778 if (bv_->theLockingInset()->insetAllowed(inset))
1779 return bv_->theLockingInset()->insertInset(bv_, inset);
1783 // not quite sure if we want this...
1784 setCursorParUndo(bv_);
1787 beforeChange(bv_->text);
1788 if (!lout.empty()) {
1789 update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
1790 bv_->text->breakParagraph(bv_);
1791 update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
1793 if (!bv_->text->cursor.par()->empty()) {
1794 bv_->text->cursorLeft(bv_);
1796 bv_->text->breakParagraph(bv_);
1797 update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
1801 LyXTextClass const & tclass =
1802 buffer_->params.getLyXTextClass();
1803 bool hasLayout = tclass.hasLayout(lres);
1804 string lay = tclass.defaultLayoutName();
1806 if (hasLayout != false) {
1810 // layout not fount using default
1811 lay = tclass.defaultLayoutName();
1814 bv_->text->setLayout(bv_, lay);
1816 bv_->text->setParagraph(bv_, 0, 0,
1818 VSpace(VSpace::NONE), VSpace(VSpace::NONE),
1823 update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
1826 bv_->text->insertInset(bv_, inset);
1827 update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
1834 void BufferView::Pimpl::updateInset(Inset * inset, bool mark_dirty)
1836 if (!inset || !available())
1839 // first check for locking insets
1840 if (bv_->theLockingInset()) {
1841 if (bv_->theLockingInset() == inset) {
1842 if (bv_->text->updateInset(bv_, inset)) {
1845 buffer_->markDirty();
1850 } else if (bv_->theLockingInset()->updateInsetInInset(bv_, inset)) {
1851 if (bv_->text->updateInset(bv_, bv_->theLockingInset())) {
1854 buffer_->markDirty();
1862 // then check if the inset is a top_level inset (has no owner)
1863 // if yes do the update as always otherwise we have to update the
1864 // toplevel inset where this inset is inside
1865 Inset * tl_inset = inset;
1866 while (tl_inset->owner())
1867 tl_inset = tl_inset->owner();
1869 if (tl_inset == inset) {
1870 update(bv_->text, BufferView::UPDATE);
1871 if (bv_->text->updateInset(bv_, inset)) {
1875 | BufferView::FITCUR
1876 | BufferView::CHANGE);
1878 update(bv_->text, SELECT);
1882 } else if (static_cast<UpdatableInset *>(tl_inset)
1883 ->updateInsetInInset(bv_, inset))
1885 if (bv_->text->updateInset(bv_, tl_inset)) {