1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1998-2001 The LyX Team.
8 * ======================================================
20 #pragma implementation
23 #include "insettext.h"
24 #include "paragraph.h"
28 #include "commandtags.h"
31 #include "BufferView.h"
33 #include "LaTeXFeatures.h"
35 #include "lyx_gui_misc.h"
37 #include "lyxcursor.h"
38 #include "CutAndPaste.h"
41 #include "support/textutils.h"
42 #include "support/LAssert.h"
43 #include "support/lstrings.h"
47 #include "trans_mgr.h"
48 #include "lyxscreen.h"
52 #include "ParagraphParameters.h"
53 #include "undo_funcs.h"
63 extern unsigned char getCurrentTextClass(Buffer *);
64 extern bool math_insert_greek(BufferView *, char);
65 extern int greek_kb_flag;
68 #warning this functions should probably go into bufferview_funcs somehow (Jug)
70 void InsetText::saveLyXTextState(LyXText * t) const
72 sstate.lpar = t->cursor.par();
73 sstate.pos = t->cursor.pos();
74 sstate.boundary = t->cursor.boundary();
75 sstate.selstartpar = t->selection.start.par();
76 sstate.selstartpos = t->selection.start.pos();
77 sstate.selstartboundary = t->selection.start.boundary();
78 sstate.selendpar = t->selection.end.par();
79 sstate.selendpos = t->selection.end.pos();
80 sstate.selendboundary = t->selection.end.boundary();
81 sstate.selection = t->selection.set();
82 sstate.mark_set = t->selection.mark();
85 void InsetText::restoreLyXTextState(BufferView * bv, LyXText * t) const
88 t->selection.set(true);
89 /* at this point just to avoid the Delete-Empty-Paragraph
90 * Mechanism when setting the cursor */
91 t->selection.mark(sstate.mark_set);
92 if (sstate.selection) {
93 t->setCursor(bv, sstate.selstartpar, sstate.selstartpos,
94 true, sstate.selstartboundary);
95 t->selection.cursor = t->cursor;
96 t->setCursor(bv, sstate.selendpar, sstate.selendpos,
97 true, sstate.selendboundary);
99 t->setCursor(bv, sstate.lpar, sstate.pos);
101 t->setCursor(bv, sstate.lpar, sstate.pos, true, sstate.boundary);
102 t->selection.cursor = t->cursor;
103 t->selection.set(false);
109 InsetText::InnerCache::InnerCache(boost::shared_ptr<LyXText> t)
116 InsetText::InsetText()
123 InsetText::InsetText(InsetText const & ins, bool same_id)
128 autoBreakRows = ins.autoBreakRows;
132 InsetText & InsetText::operator=(InsetText const & it)
135 autoBreakRows = it.autoBreakRows;
140 void InsetText::init(InsetText const * ins, bool same_id)
148 the_locking_inset = 0;
150 no_selection = false;
154 autoBreakRows = false;
157 frame_color = LColor::insetframe;
159 setParagraphData(ins->par);
160 autoBreakRows = ins->autoBreakRows;
161 drawFrame_ = ins->drawFrame_;
162 frame_color = ins->frame_color;
166 par->setInsetOwner(this);
169 last_drawn_width = -1;
170 frame_is_visible = false;
177 InsetText::~InsetText()
184 Paragraph * tmp = par->next();
191 void InsetText::clear()
194 Paragraph * tmp = par->next();
203 Inset * InsetText::clone(Buffer const &, bool same_id) const
205 return new InsetText(*this, same_id);
209 void InsetText::write(Buffer const * buf, ostream & os) const
212 writeParagraphData(buf, os);
216 void InsetText::writeParagraphData(Buffer const * buf, ostream & os) const
218 par->writeFile(buf, os, buf->params, 0);
222 void InsetText::read(Buffer const * buf, LyXLex & lex)
226 Paragraph * return_par = 0;
227 Paragraph::depth_type depth = 0;
228 LyXFont font(LyXFont::ALL_INHERIT);
234 token = lex.GetString();
237 if (token == "\\end_inset") {
239 const_cast<Buffer*>(buf)->insertErtContents(par, pos, font, false);
244 if (const_cast<Buffer*>(buf)->
245 parseSingleLyXformat2Token(lex, par, return_par,
246 token, pos, depth, font)) {
247 // the_end read this should NEVER happen
248 lex.printError("\\the_end read in inset! Error in document!");
256 return_par->setInsetOwner(this);
257 return_par = return_par->next();
260 if (token != "\\end_inset") {
261 lex.printError("Missing \\end_inset at this point. "
268 int InsetText::ascent(BufferView * bv, LyXFont const &) const
271 Row * row = getLyXText(bv)->getRowNearY(y_temp);
272 insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
277 int InsetText::descent(BufferView * bv, LyXFont const &) const
285 Row * row = lt->getRowNearY(y_temp);
286 insetDescent = lt->height - row->ascent_of_text() +
287 TEXT_TO_INSET_OFFSET;
294 int InsetText::width(BufferView * bv, LyXFont const &) const
296 insetWidth = max(textWidth(bv),
297 (int)getLyXText(bv)->width + (2 * TEXT_TO_INSET_OFFSET));
302 int InsetText::textWidth(BufferView * bv) const
306 int const w = getMaxWidth(bv, this);
311 void InsetText::draw(BufferView * bv, LyXFont const & f,
312 int baseline, float & x, bool cleared) const
317 Painter & pain = bv->painter();
319 // no draw is necessary !!!
320 if ((drawFrame_ == LOCKED) && !locked && !par->size()) {
322 top_baseline = baseline;
324 if (!cleared && (need_update & CLEAR_FRAME))
325 clearFrame(pain, cleared);
327 frame_is_visible = false;
334 x += static_cast<float>(scroll());
336 // if top_x differs we have a rule down and we don't have to clear anything
337 if (!cleared && (top_x == int(x)) &&
338 ((need_update&(INIT|FULL)) || (top_baseline!=baseline) ||
339 (last_drawn_width!=insetWidth))) {
340 clearInset(pain, baseline, cleared);
343 frame_is_visible = false;
345 if (!cleared && (need_update == NONE))
348 if (top_x != int(x)) {
349 if ((getMaxWidth(bv, this) > 0) &&
350 (getLyXText(bv)->width != old_max_width)) {
353 old_max_width = getLyXText(bv)->width;
354 bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
357 clearInset(pain, baseline, cleared);
360 // lyxerr << "InsetText::draw[" << this << "](" << need_update << ":" << int(x) << ":" << top_x << ")\n";
362 if (cleared || (last_drawn_width != insetWidth)) {
364 last_drawn_width = insetWidth;
367 top_baseline = baseline;
368 top_y = baseline - ascent(bv, f);
369 last_width = width(bv, f);
370 last_height = ascent(bv, f) + descent(bv, f);
372 if (the_locking_inset && (cpar(bv) == inset_par)
373 && (cpos(bv) == inset_pos)) {
374 inset_x = cx(bv) - top_x + drawTextXOffset;
375 inset_y = cy(bv) + drawTextYOffset;
377 if (!cleared && (need_update == CURSOR)
378 && !getLyXText(bv)->selection.set()) {
379 drawFrame(pain, cleared);
380 x += last_width; // was width(bv, f);
389 x += TEXT_TO_INSET_OFFSET;
392 Row * row = lt->getRowNearY(y);
393 int y_offset = baseline - row->ascent_of_text();
394 int ph = pain.paperHeight();
397 while ((row != 0) && ((y+row->height()) <= 0)) {
399 first += row->height();
408 while ((row != 0) && (yf < ph)) {
409 lt->getVisibleRow(bv, y+y_offset, int(x), row,
415 } else if (!locked) {
416 if (need_update & CURSOR) {
417 bv->screen()->toggleSelection(lt, bv, true, y_offset,int(x));
418 lt->clearSelection(bv);
419 lt->selection.cursor = lt->cursor;
421 bv->screen()->update(lt, bv, y_offset, int(x));
424 if (need_update & SELECTION)
425 bv->screen()->toggleToggle(lt, bv, y_offset, int(x));
426 else if (need_update & CURSOR) {
427 bv->screen()->toggleSelection(lt, bv, true, y_offset,int(x));
428 lt->clearSelection(bv);
429 lt->selection.cursor = lt->cursor;
431 bv->screen()->update(lt, bv, y_offset, int(x));
436 lt->status(bv, LyXText::UNCHANGED);
437 if ((need_update != CURSOR_PAR) &&
438 ((drawFrame_ == ALWAYS) || ((drawFrame_ == LOCKED) && locked)))
439 drawFrame(pain, cleared);
440 else if (need_update & CLEAR_FRAME)
441 clearFrame(pain, cleared);
442 x += last_width /* was width(bv, f) */ - TEXT_TO_INSET_OFFSET;
443 if (bv->text->status() == LyXText::CHANGED_IN_DRAW) {
445 } else if (need_update != INIT)
452 void InsetText::drawFrame(Painter & pain, bool cleared) const
454 if (!frame_is_visible || cleared) {
456 frame_y = top_baseline - insetAscent + 1;
457 frame_w = insetWidth - 1;
458 frame_h = insetAscent + insetDescent - 1;
459 pain.rectangle(frame_x, frame_y, frame_w, frame_h,
461 frame_is_visible = true;
466 void InsetText::clearFrame(Painter & pain, bool cleared) const
468 if (frame_is_visible) {
470 pain.rectangle(frame_x, frame_y, frame_w, frame_h,
473 frame_is_visible = false;
478 void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
484 owner()->update(bv, font, true);
487 if (the_locking_inset) {
488 inset_x = cx(bv) - top_x + drawTextXOffset;
489 inset_y = cy(bv) + drawTextYOffset;
490 the_locking_inset->update(bv, font, reinit);
498 int oldw = insetWidth;
499 insetWidth = lt->width + (2 * TEXT_TO_INSET_OFFSET);
500 if (oldw != insetWidth) {
507 if ((need_update & CURSOR_PAR) && (lt->status() == LyXText::UNCHANGED) &&
510 lt->updateInset(bv, the_locking_inset);
512 if (lt->status() == LyXText::NEED_MORE_REFRESH)
519 void InsetText::setUpdateStatus(BufferView * bv, int what) const
527 if (lt->status() == LyXText::NEED_MORE_REFRESH)
529 else if (lt->status() == LyXText::NEED_VERY_LITTLE_REFRESH)
530 need_update |= CURSOR_PAR;
532 // this to not draw a selection when we redraw all of it!
533 if ((need_update & (INIT|FULL)) && (need_update & CURSOR))
534 lt->clearSelection(bv);
540 void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty) const
548 setUpdateStatus(bv, what);
549 if ((need_update != CURSOR) || (lt->status() != LyXText::UNCHANGED) ||
552 bv->updateInset(const_cast<InsetText *>(this), mark_dirty);
554 bv->owner()->showState();
555 if (old_par != cpar(bv)) {
556 bv->owner()->setLayout(cpar(bv)->getLayout());
564 string const InsetText::editMessage() const
566 return _("Opened Text Inset");
570 void InsetText::edit(BufferView * bv, int x, int y, unsigned int button)
572 UpdatableInset::edit(bv, x, y, button);
574 if (!bv->lockInset(this)) {
575 lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
579 the_locking_inset = 0;
580 inset_pos = inset_x = inset_y = 0;
581 inset_boundary = false;
584 int tmp_y = (y < 0) ? 0 : y;
591 if (!checkAndActivateInset(bv, x, tmp_y, button))
592 lt->setCursorFromCoordinates(bv, x - drawTextXOffset,
594 lt->clearSelection(bv);
597 updateLocal(bv, CURSOR, false);
599 // If the inset is empty set the language of the current font to the
600 // language to the surronding text (if different).
601 if (par->size() == 0 && !par->next() &&
602 bv->getParentLanguage(this) != lt->current_font.language()) {
603 LyXFont font(LyXFont::ALL_IGNORE);
604 font.setLanguage(bv->getParentLanguage(this));
605 setFont(bv, font, false);
612 void InsetText::edit(BufferView * bv, bool front)
614 UpdatableInset::edit(bv, front);
616 if (!bv->lockInset(this)) {
617 lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
621 the_locking_inset = 0;
622 inset_pos = inset_x = inset_y = 0;
623 inset_boundary = false;
632 lt->setCursor(bv, par, 0);
637 lt->setCursor(bv, p, p->size()-1);
639 lt->clearSelection(bv);
642 updateLocal(bv, CURSOR, false);
644 // If the inset is empty set the language of the current font to the
645 // language to the surronding text (if different).
646 if (par->size() == 0 && !par->next() &&
647 bv->getParentLanguage(this) != lt->current_font.language()) {
648 LyXFont font(LyXFont::ALL_IGNORE);
649 font.setLanguage(bv->getParentLanguage(this));
650 setFont(bv, font, false);
657 void InsetText::insetUnlock(BufferView * bv)
659 if (the_locking_inset) {
660 the_locking_inset->insetUnlock(bv);
661 the_locking_inset = 0;
664 no_selection = false;
667 if (drawFrame_ == LOCKED)
668 code = CURSOR|CLEAR_FRAME;
676 if (lt->selection.set()) {
677 lt->clearSelection(bv);
679 } else if (owner()) {
680 bv->owner()->setLayout(owner()->getLyXText(bv)
681 ->cursor.par()->getLayout());
683 bv->owner()->setLayout(bv->text->cursor.par()->getLayout());
684 updateLocal(bv, code, false);
690 bool InsetText::lockInsetInInset(BufferView * bv, UpdatableInset * inset)
692 lyxerr[Debug::INSETS] << "InsetText::LockInsetInInset("
696 if (inset == cpar(bv)->getInset(cpos(bv))) {
697 lyxerr[Debug::INSETS] << "OK" << endl;
698 the_locking_inset = inset;
699 inset_x = cx(bv) - top_x + drawTextXOffset;
700 inset_y = cy(bv) + drawTextYOffset;
701 inset_pos = cpos(bv);
702 inset_par = cpar(bv);
703 inset_boundary = cboundary(bv);
704 updateLocal(bv, CURSOR, false);
706 } else if (the_locking_inset && (the_locking_inset == inset)) {
707 if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
708 lyxerr[Debug::INSETS] << "OK" << endl;
709 inset_x = cx(bv) - top_x + drawTextXOffset;
710 inset_y = cy(bv) + drawTextYOffset;
712 lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
714 } else if (the_locking_inset) {
715 lyxerr[Debug::INSETS] << "MAYBE" << endl;
716 return the_locking_inset->lockInsetInInset(bv, inset);
718 lyxerr[Debug::INSETS] << "NOT OK" << endl;
723 bool InsetText::unlockInsetInInset(BufferView * bv, UpdatableInset * inset,
726 if (!the_locking_inset)
728 if (the_locking_inset == inset) {
729 the_locking_inset->insetUnlock(bv);
730 getLyXText(bv)->updateInset(bv, inset);
731 the_locking_inset = 0;
733 moveRight(bv, false);
734 old_par = 0; // force layout setting
738 updateLocal(bv, CURSOR, false);
741 return the_locking_inset->unlockInsetInInset(bv, inset, lr);
745 bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset)
747 if (!the_locking_inset)
749 if (the_locking_inset != inset) {
750 getLyXText(bv)->updateInset(bv, the_locking_inset);
751 setUpdateStatus(bv, CURSOR_PAR);
752 return the_locking_inset->updateInsetInInset(bv, inset);
754 // updateLocal(bv, FULL, false);
755 if (getLyXText(bv)->updateInset(bv, inset))
756 updateLocal(bv, CURSOR_PAR, false);
757 if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
758 inset_x = cx(bv) - top_x + drawTextXOffset;
759 inset_y = cy(bv) + drawTextYOffset;
765 void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
769 int tmp_x = x - drawTextXOffset;
770 int tmp_y = y + insetAscent - getLyXText(bv)->first;
771 Inset * inset = bv->checkInsetHit(getLyXText(bv), tmp_x, tmp_y, button);
774 if (the_locking_inset) {
775 if (the_locking_inset == inset) {
776 the_locking_inset->insetButtonPress(bv,x-inset_x,y-inset_y,button);
777 no_selection = false;
780 // otherwise unlock the_locking_inset and lock the new inset
781 the_locking_inset->insetUnlock(bv);
782 inset_x = cx(bv) - top_x + drawTextXOffset;
783 inset_y = cy(bv) + drawTextYOffset;
784 the_locking_inset = static_cast<UpdatableInset*>(inset);
785 inset->insetButtonPress(bv, x - inset_x, y - inset_y, button);
786 inset->edit(bv, x - inset_x, y - inset_y, button);
787 if (the_locking_inset)
788 updateLocal(bv, CURSOR, false);
789 no_selection = false;
792 // otherwise only unlock the_locking_inset
793 the_locking_inset->insetUnlock(bv);
794 the_locking_inset = 0;
796 if (bv->theLockingInset()) {
797 if (inset && inset->editable() == Inset::HIGHLY_EDITABLE) {
798 UpdatableInset * uinset = static_cast<UpdatableInset*>(inset);
799 inset_x = cx(bv) - top_x + drawTextXOffset;
800 inset_y = cy(bv) + drawTextYOffset;
801 inset_pos = cpos(bv);
802 inset_par = cpar(bv);
803 inset_boundary = cboundary(bv);
804 the_locking_inset = uinset;
805 uinset->insetButtonPress(bv, x - inset_x, y - inset_y,
807 uinset->edit(bv, x - inset_x, y - inset_y, 0);
808 if (the_locking_inset)
809 updateLocal(bv, CURSOR, false);
810 no_selection = false;
814 if (!inset) { // && (button == 2)) {
815 bool paste_internally = false;
816 if ((button == 2) && getLyXText(bv)->selection.set()) {
817 localDispatch(bv, LFUN_COPY, "");
818 paste_internally = true;
820 getLyXText(bv)->setCursorFromCoordinates(bv, x-drawTextXOffset,
822 getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor;
823 updateLocal(bv, CURSOR, false);
824 bv->owner()->setLayout(cpar(bv)->getLayout());
826 // Insert primary selection with middle mouse
827 // if there is a local selection in the current buffer,
830 if (paste_internally)
831 localDispatch(bv, LFUN_PASTE, "");
833 localDispatch(bv, LFUN_PASTESELECTION,
838 no_selection = false;
842 void InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button)
844 UpdatableInset * inset = 0;
846 if (the_locking_inset) {
847 the_locking_inset->insetButtonRelease(bv,
848 x - inset_x, y - inset_y,
851 if (cpar(bv)->getChar(cpos(bv)) == Paragraph::META_INSET) {
852 inset = static_cast<UpdatableInset*>(cpar(bv)->getInset(cpos(bv)));
853 if (inset->editable() == Inset::HIGHLY_EDITABLE) {
854 inset->insetButtonRelease(bv,
856 y - inset_y, button);
858 inset_x = cx(bv) - top_x + drawTextXOffset;
859 inset_y = cy(bv) + drawTextYOffset;
860 inset->insetButtonRelease(bv,
862 y - inset_y, button);
864 x - inset_x, y - inset_y, button);
866 updateLocal(bv, CURSOR_PAR, false);
869 no_selection = false;
873 void InsetText::insetMotionNotify(BufferView * bv, int x, int y, int state)
877 if (the_locking_inset) {
878 the_locking_inset->insetMotionNotify(bv, x - inset_x,
882 LyXText * t = getLyXText(bv);
884 t->setCursorFromCoordinates(bv, x - drawTextXOffset, y + insetAscent);
886 if (t->toggle_cursor.par() != t->toggle_end_cursor.par() ||
887 t->toggle_cursor.pos() != t->toggle_end_cursor.pos())
888 updateLocal(bv, SELECTION, false);
893 void InsetText::insetKeyPress(XKeyEvent * xke)
895 if (the_locking_inset) {
896 the_locking_inset->insetKeyPress(xke);
902 UpdatableInset::RESULT
903 InsetText::localDispatch(BufferView * bv,
904 kb_action action, string const & arg)
906 no_selection = false;
907 UpdatableInset::RESULT
908 result= UpdatableInset::localDispatch(bv, action, arg);
909 if (result != UNDISPATCHED) {
914 if ((action < 0) && arg.empty())
917 if (the_locking_inset) {
918 result = the_locking_inset->localDispatch(bv, action, arg);
919 if (result == DISPATCHED_NOUPDATE)
921 else if (result == DISPATCHED) {
922 updateLocal(bv, CURSOR_PAR, false);
924 } else if (result == FINISHED) {
925 bool dispatched = false;
927 case LFUN_UNKNOWN_ACTION:
928 case LFUN_BREAKPARAGRAPH:
930 moveRightIntern(bv, false, false);
933 if (!getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
934 moveRightIntern(bv, false, false);
938 if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
939 moveRightIntern(bv, false, false);
945 the_locking_inset = 0;
958 case LFUN_SELFINSERT:
959 if (bv->buffer()->isReadonly()) {
960 // setErrorMessage(N_("Document is read only"));
964 /* Automatically delete the currently selected
965 * text and replace it with what is being
966 * typed in now. Depends on lyxrc settings
967 * "auto_region_delete", which defaults to
970 setUndo(bv, Undo::INSERT,
971 lt->cursor.par(), lt->cursor.par()->next());
973 if (lyxrc.auto_region_delete) {
974 if (lt->selection.set()) {
975 lt->cutSelection(bv, false);
978 lt->clearSelection(bv);
979 for (string::size_type i = 0; i < arg.length(); ++i) {
981 if (!math_insert_greek(bv, arg[i])) {
982 bv->owner()->getIntl()->getTrans().TranslateAndInsert(arg[i], lt);
983 } else if (!the_locking_inset) {
984 (void)moveRight(bv, false);
987 bv->owner()->getIntl()->getTrans().TranslateAndInsert(arg[i], lt);
991 lt->selection.cursor = lt->cursor;
992 updateLocal(bv, CURSOR_PAR, true);
993 result = DISPATCHED_NOUPDATE;
995 // --- Cursor Movements -----------------------------------
998 moveRight(bv, false, true);
999 lt->setSelection(bv);
1000 updateLocal(bv, SELECTION, false);
1003 result = moveRight(bv);
1005 updateLocal(bv, CURSOR, false);
1009 moveLeft(bv, false, true);
1010 lt->setSelection(bv);
1011 updateLocal(bv, SELECTION, false);
1015 result = moveLeft(bv);
1016 updateLocal(bv, CURSOR, false);
1021 lt->setSelection(bv);
1022 updateLocal(bv, SELECTION, false);
1026 result = moveDown(bv);
1027 updateLocal(bv, CURSOR, false);
1032 lt->setSelection(bv);
1033 updateLocal(bv, SELECTION, false);
1037 result = moveUp(bv);
1038 updateLocal(bv, CURSOR, false);
1043 updateLocal(bv, CURSOR, false);
1047 updateLocal(bv, CURSOR, false);
1049 case LFUN_BACKSPACE: {
1050 setUndo(bv, Undo::DELETE,
1051 lt->cursor.par(), lt->cursor.par()->next());
1052 if (lt->selection.set())
1053 lt->cutSelection(bv);
1056 updateLocal(bv, CURSOR_PAR, true);
1061 setUndo(bv, Undo::DELETE,
1062 lt->cursor.par(), lt->cursor.par()->next());
1063 if (lt->selection.set()) {
1064 lt->cutSelection(bv);
1068 updateLocal(bv, CURSOR_PAR, true);
1073 setUndo(bv, Undo::DELETE,
1074 lt->cursor.par(), lt->cursor.par()->next());
1075 lt->cutSelection(bv);
1076 updateLocal(bv, CURSOR_PAR, true);
1082 lt->copySelection(bv);
1083 updateLocal(bv, CURSOR_PAR, false);
1085 case LFUN_PASTESELECTION:
1087 string const clip(bv->getClipboard());
1091 if (arg == "paragraph") {
1092 lt->insertStringAsParagraphs(bv, clip);
1094 lt->insertStringAsLines(bv, clip);
1096 updateLocal(bv, CURSOR_PAR, true);
1100 if (!autoBreakRows) {
1102 if (CutAndPaste::nrOfParagraphs() > 1) {
1103 WriteAlert(_("Impossible operation"),
1104 _("Cannot include more than one paragraph!"),
1109 setUndo(bv, Undo::INSERT,
1110 lt->cursor.par(), lt->cursor.par()->next());
1111 lt->pasteSelection(bv);
1112 updateLocal(bv, CURSOR_PAR, true);
1116 case LFUN_BREAKPARAGRAPH:
1117 if (!autoBreakRows) {
1118 result = DISPATCHED;
1121 lt->breakParagraph(bv, 0);
1122 updateLocal(bv, FULL, true);
1124 case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
1125 if (!autoBreakRows) {
1126 result = DISPATCHED;
1129 lt->breakParagraph(bv, 1);
1130 updateLocal(bv, FULL, true);
1133 case LFUN_BREAKLINE: {
1134 if (!autoBreakRows) {
1135 result = DISPATCHED;
1138 setUndo(bv, Undo::INSERT,
1139 lt->cursor.par(), lt->cursor.par()->next());
1140 lt->insertChar(bv, Paragraph::META_NEWLINE);
1141 updateLocal(bv, CURSOR_PAR, true);
1146 // do not set layouts on non breakable textinsets
1147 if (autoBreakRows) {
1148 LyXTextClass::size_type cur_layout = cpar(bv)->layout;
1150 // Derive layout number from given argument (string)
1151 // and current buffer's textclass (number). */
1152 LyXTextClassList::ClassList::size_type tclass =
1153 bv->buffer()->params.textclass;
1154 std::pair <bool, LyXTextClass::size_type> layout =
1155 textclasslist.NumberOfLayout(tclass, arg);
1157 // If the entry is obsolete, use the new one instead.
1159 string obs = textclasslist.Style(tclass,layout.second).
1162 layout = textclasslist.NumberOfLayout(tclass, obs);
1165 // see if we found the layout number:
1166 if (!layout.first) {
1167 string const msg = string(N_("Layout ")) + arg + N_(" not known");
1168 bv->owner()->getLyXFunc()->dispatch(LFUN_MESSAGE, msg);
1172 if (cur_layout != layout.second) {
1173 cur_layout = layout.second;
1174 lt->setLayout(bv, layout.second);
1175 bv->owner()->setLayout(cpar(bv)->getLayout());
1176 updateLocal(bv, CURSOR_PAR, true);
1179 // reset the layout box
1180 bv->owner()->setLayout(cpar(bv)->getLayout());
1183 case LFUN_PARAGRAPH_SPACING:
1184 // This one is absolutely not working. When fiddling with this
1185 // it also seems to me that the paragraphs inside the insettext
1186 // inherit bufferparams/paragraphparams in a strange way. (Lgb)
1188 Paragraph * par = lt->cursor.par();
1189 Spacing::Space cur_spacing = par->params().spacing().getSpace();
1190 float cur_value = 1.0;
1191 if (cur_spacing == Spacing::Other) {
1192 cur_value = par->params().spacing().getValue();
1195 istringstream istr(arg.c_str());
1198 Spacing::Space new_spacing = cur_spacing;
1199 float new_value = cur_value;
1201 lyxerr << "Missing argument to `paragraph-spacing'"
1203 } else if (tmp == "single") {
1204 new_spacing = Spacing::Single;
1205 } else if (tmp == "onehalf") {
1206 new_spacing = Spacing::Onehalf;
1207 } else if (tmp == "double") {
1208 new_spacing = Spacing::Double;
1209 } else if (tmp == "other") {
1210 new_spacing = Spacing::Other;
1213 lyxerr << "new_value = " << tmpval << endl;
1216 } else if (tmp == "default") {
1217 new_spacing = Spacing::Default;
1219 lyxerr << _("Unknown spacing argument: ")
1222 if (cur_spacing != new_spacing || cur_value != new_value) {
1223 par->params().spacing(Spacing(new_spacing, new_value));
1224 updateLocal(bv, CURSOR_PAR, true);
1230 if (!bv->Dispatch(action, arg))
1231 result = UNDISPATCHED;
1235 /// If the action has deleted all text in the inset, we need to change the
1236 // language to the language of the surronding text.
1237 if (par->size() == 0 && !par->next()) {
1238 LyXFont font(LyXFont::ALL_IGNORE);
1239 font.setLanguage(bv->getParentLanguage(this));
1240 setFont(bv, font, false);
1243 if (result != FINISHED) {
1244 showInsetCursor(bv);
1246 bv->unlockInset(this);
1253 int InsetText::latex(Buffer const * buf, ostream & os, bool, bool) const
1256 buf->latexParagraphs(os, par, 0, texrow);
1257 return texrow.rows();
1261 int InsetText::ascii(Buffer const * buf, ostream & os, int linelen) const
1263 Paragraph * p = par;
1264 unsigned int lines = 0;
1267 string const tmp = buf->asciiParagraph(p, linelen);
1268 lines += countChar(tmp, '\n');
1276 int InsetText::docBook(Buffer const * buf, ostream & os) const
1278 Paragraph * p = par;
1279 unsigned int lines = 0;
1284 buf->simpleDocBookOnePar(os, tmp, p, desc, 0);
1292 void InsetText::validate(LaTeXFeatures & features) const
1294 Paragraph * p = par;
1296 p->validate(features);
1302 int InsetText::beginningOfMainBody(Buffer const * buf, Paragraph * p) const
1304 if (textclasslist.Style(buf->params.textclass,
1305 p->getLayout()).labeltype != LABEL_MANUAL)
1308 return p->beginningOfMainBody();
1312 void InsetText::getCursorPos(BufferView * bv,
1313 int & x, int & y) const
1315 if (the_locking_inset) {
1316 the_locking_inset->getCursorPos(bv, x, y);
1324 unsigned int InsetText::insetInInsetY()
1326 if (!the_locking_inset)
1329 return (inset_y + the_locking_inset->insetInInsetY());
1333 void InsetText::toggleInsetCursor(BufferView * bv)
1335 if (the_locking_inset) {
1336 the_locking_inset->toggleInsetCursor(bv);
1340 LyXFont const font(getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv)));
1342 int const asc = lyxfont::maxAscent(font);
1343 int const desc = lyxfont::maxDescent(font);
1345 if (isCursorVisible())
1346 bv->hideLockedInsetCursor();
1348 bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
1349 toggleCursorVisible();
1353 void InsetText::showInsetCursor(BufferView * bv, bool show)
1355 if (the_locking_inset) {
1356 the_locking_inset->showInsetCursor(bv, show);
1359 if (!isCursorVisible()) {
1360 LyXFont const font =
1361 getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
1363 int const asc = lyxfont::maxAscent(font);
1364 int const desc = lyxfont::maxDescent(font);
1366 bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
1368 bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
1369 setCursorVisible(true);
1374 void InsetText::hideInsetCursor(BufferView * bv)
1376 if (isCursorVisible()) {
1377 bv->hideLockedInsetCursor();
1378 setCursorVisible(false);
1380 if (the_locking_inset)
1381 the_locking_inset->hideInsetCursor(bv);
1385 void InsetText::fitInsetCursor(BufferView * bv) const
1387 if (the_locking_inset) {
1388 the_locking_inset->fitInsetCursor(bv);
1391 LyXFont const font =
1392 getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
1394 int const asc = lyxfont::maxAscent(font);
1395 int const desc = lyxfont::maxDescent(font);
1397 bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
1401 UpdatableInset::RESULT
1402 InsetText::moveRight(BufferView * bv, bool activate_inset, bool selecting)
1404 if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
1405 return moveLeftIntern(bv, false, activate_inset, selecting);
1407 return moveRightIntern(bv, false, activate_inset, selecting);
1411 UpdatableInset::RESULT
1412 InsetText::moveLeft(BufferView * bv, bool activate_inset, bool selecting)
1414 if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
1415 return moveRightIntern(bv, true, activate_inset, selecting);
1417 return moveLeftIntern(bv, true, activate_inset, selecting);
1421 UpdatableInset::RESULT
1422 InsetText::moveRightIntern(BufferView * bv, bool behind,
1423 bool activate_inset, bool selecting)
1425 if (!cpar(bv)->next() && (cpos(bv) >= cpar(bv)->size()))
1427 if (activate_inset && checkAndActivateInset(bv, behind))
1429 getLyXText(bv)->cursorRight(bv);
1431 getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor;
1432 return DISPATCHED_NOUPDATE;
1436 UpdatableInset::RESULT
1437 InsetText::moveLeftIntern(BufferView * bv, bool behind,
1438 bool activate_inset, bool selecting)
1440 if (!cpar(bv)->previous() && (cpos(bv) <= 0))
1442 getLyXText(bv)->cursorLeft(bv);
1444 getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor;
1445 if (activate_inset && checkAndActivateInset(bv, behind))
1447 return DISPATCHED_NOUPDATE;
1451 UpdatableInset::RESULT
1452 InsetText::moveUp(BufferView * bv)
1454 if (!crow(bv)->previous())
1456 getLyXText(bv)->cursorUp(bv);
1457 return DISPATCHED_NOUPDATE;
1461 UpdatableInset::RESULT
1462 InsetText::moveDown(BufferView * bv)
1464 if (!crow(bv)->next())
1466 getLyXText(bv)->cursorDown(bv);
1467 return DISPATCHED_NOUPDATE;
1471 bool InsetText::insertInset(BufferView * bv, Inset * inset)
1473 if (the_locking_inset) {
1474 if (the_locking_inset->insetAllowed(inset))
1475 return the_locking_inset->insertInset(bv, inset);
1478 inset->setOwner(this);
1479 hideInsetCursor(bv);
1483 lt = getLyXText(bv);
1486 lt->insertInset(bv, inset);
1487 if ((cpar(bv)->getChar(cpos(bv)) != Paragraph::META_INSET) ||
1488 (cpar(bv)->getInset(cpos(bv)) != inset))
1491 updateLocal(bv, CURSOR_PAR|CURSOR, true);
1492 showInsetCursor(bv);
1499 bool InsetText::insetAllowed(Inset::Code code) const
1501 if (the_locking_inset)
1502 return the_locking_inset->insetAllowed(code);
1507 UpdatableInset * InsetText::getLockingInset() const
1509 return the_locking_inset ? the_locking_inset->getLockingInset() :
1510 const_cast<InsetText *>(this);
1514 UpdatableInset * InsetText::getFirstLockingInsetOfType(Inset::Code c)
1518 if (the_locking_inset)
1519 return the_locking_inset->getFirstLockingInsetOfType(c);
1524 bool InsetText::showInsetDialog(BufferView * bv) const
1526 if (the_locking_inset)
1527 return the_locking_inset->showInsetDialog(bv);
1532 std::vector<string> const InsetText::getLabelList() const
1534 std::vector<string> label_list;
1536 Paragraph * tpar = par;
1538 Paragraph::inset_iterator beg = tpar->inset_iterator_begin();
1539 Paragraph::inset_iterator end = tpar->inset_iterator_end();
1540 for (; beg != end; ++beg) {
1541 std::vector<string> const l = (*beg)->getLabelList();
1542 label_list.insert(label_list.end(), l.begin(), l.end());
1544 tpar = tpar->next();
1550 void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall,
1553 if (the_locking_inset) {
1554 the_locking_inset->setFont(bv, font, toggleall, selectall);
1559 lt = getLyXText(bv);
1562 if (lt->selection.set()) {
1563 setUndo(bv, Undo::EDIT, lt->cursor.par(), lt->cursor.par()->next());
1568 lt->toggleFree(bv, font, toggleall);
1570 lt->setFont(bv, font, toggleall);
1573 lt->clearSelection(bv);
1575 if (selectall || lt->selection.set())
1576 updateLocal(bv, FULL, true);
1578 updateLocal(bv, CURSOR_PAR, true);
1584 bool InsetText::checkAndActivateInset(BufferView * bv, bool behind)
1586 if (cpar(bv)->getChar(cpos(bv)) == Paragraph::META_INSET) {
1590 static_cast<UpdatableInset*>(cpar(bv)->getInset(cpos(bv)));
1591 if (!inset || inset->editable() != Inset::HIGHLY_EDITABLE)
1593 LyXFont const font =
1594 getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
1596 x = inset->width(bv, font);
1597 y = font.isRightToLeft() ? 0 : inset->descent(bv, font);
1600 y = font.isRightToLeft() ? inset->descent(bv, font) : 0;
1602 //inset_x = cx(bv) - top_x + drawTextXOffset;
1603 //inset_y = cy(bv) + drawTextYOffset;
1604 inset->edit(bv, x, y, 0);
1605 if (!the_locking_inset)
1607 updateLocal(bv, CURSOR, false);
1614 bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
1617 x -= drawTextXOffset;
1619 int dummyy = y + insetAscent;
1620 Inset * inset = bv->checkInsetHit(getLyXText(bv), dummyx, dummyy, button);
1627 inset_x = cx(bv) - top_x + drawTextXOffset;
1628 inset_y = cy(bv) + drawTextYOffset;
1629 inset->edit(bv, x - inset_x, y - inset_y, button);
1630 if (!the_locking_inset)
1632 updateLocal(bv, CURSOR, false);
1639 int InsetText::getMaxWidth(BufferView * bv, UpdatableInset const * inset) const
1641 int w = UpdatableInset::getMaxWidth(bv, inset);
1646 w = w - top_x + owner()->x();
1649 w -= (2 * TEXT_TO_INSET_OFFSET);
1651 // return w - (2*TEXT_TO_INSET_OFFSET);
1655 void InsetText::setParagraphData(Paragraph * p)
1658 Paragraph * tmp = par->next();
1663 par = new Paragraph(*p);
1664 par->setInsetOwner(this);
1665 Paragraph * np = par;
1668 np->next(new Paragraph(*p));
1669 np->next()->previous(np);
1671 np->setInsetOwner(this);
1677 void InsetText::setText(string const & data)
1680 LyXFont font(LyXFont::ALL_SANE);
1681 for (unsigned int i=0; i < data.length(); ++i)
1682 par->insertChar(i, data[i], font);
1686 void InsetText::setAutoBreakRows(bool flag)
1688 if (flag != autoBreakRows) {
1689 autoBreakRows = flag;
1698 void InsetText::setDrawFrame(BufferView * bv, DrawFrame how)
1700 if (how != drawFrame_) {
1703 updateLocal(bv, DRAW_FRAME, false);
1708 void InsetText::setFrameColor(BufferView * bv, LColor::color col)
1710 if (frame_color != col) {
1713 updateLocal(bv, DRAW_FRAME, false);
1718 int InsetText::cx(BufferView * bv) const
1722 lt = getLyXText(bv);
1725 int x = lt->cursor.x() + top_x + TEXT_TO_INSET_OFFSET;
1726 if (the_locking_inset) {
1727 LyXFont font = lt->getFont(bv->buffer(),
1730 if (font.isVisibleRightToLeft())
1731 x -= the_locking_inset->width(bv, font);
1739 int InsetText::cy(BufferView * bv) const
1742 return getLyXText(bv)->cursor.y() - ascent(bv, font) + TEXT_TO_INSET_OFFSET;
1746 Paragraph::size_type InsetText::cpos(BufferView * bv) const
1748 return getLyXText(bv)->cursor.pos();
1752 Paragraph * InsetText::cpar(BufferView * bv) const
1754 return getLyXText(bv)->cursor.par();
1758 bool InsetText::cboundary(BufferView * bv) const
1760 return getLyXText(bv)->cursor.boundary();
1764 Row * InsetText::crow(BufferView * bv) const
1766 return getLyXText(bv)->cursor.row();
1770 LyXText * InsetText::getLyXText(BufferView const * lbv,
1771 bool const recursive) const
1773 if (!recursive && (cached_bview == lbv))
1774 return cached_text.get();
1776 // Super UGLY! (Lgb)
1777 BufferView * bv = const_cast<BufferView *>(lbv);
1780 Cache::iterator it = cache.find(bv);
1782 if (it != cache.end()) {
1783 if (lt || !it->second.remove) {
1784 lyx::Assert(it->second.text.get());
1785 cached_text = it->second.text;
1786 if (recursive && the_locking_inset) {
1787 return the_locking_inset->getLyXText(bv);
1789 return cached_text.get();
1790 } else if (it->second.remove) {
1792 saveLyXTextState(it->second.text.get());
1799 cached_text.reset(new LyXText(const_cast<InsetText *>(this)));
1800 cached_text->init(bv);
1801 restoreLyXTextState(bv, cached_text.get());
1803 cache.insert(make_pair(bv, cached_text));
1805 if (the_locking_inset && recursive) {
1806 return the_locking_inset->getLyXText(bv);
1808 return cached_text.get();
1812 void InsetText::deleteLyXText(BufferView * bv, bool recursive) const
1816 Cache::iterator it = cache.find(bv);
1818 if (it == cache.end()) {
1822 lyx::Assert(it->second.text.get());
1824 it->second.remove = true;
1826 /// then remove all LyXText in text-insets
1827 Paragraph * p = par;
1828 for (; p; p = p->next()) {
1829 p->deleteInsetsLyXText(bv);
1835 void InsetText::resizeLyXText(BufferView * bv, bool force) const
1837 if (!par->next() && !par->size()) // no data, resize not neccessary!
1839 // one endless line, resize normally not necessary
1840 if (!force && getMaxWidth(bv, this) < 0)
1843 Cache::iterator it = cache.find(bv);
1844 if (it == cache.end()) {
1847 lyx::Assert(it->second.text.get());
1849 LyXText * t = it->second.text.get();
1850 saveLyXTextState(t);
1851 for (Paragraph * p = par; p; p = p->next()) {
1852 p->resizeInsetsLyXText(bv);
1855 restoreLyXTextState(bv, t);
1856 if (the_locking_inset) {
1857 inset_x = cx(bv) - top_x + drawTextXOffset;
1858 inset_y = cy(bv) + drawTextYOffset;
1862 t->first = bv->screen()->topCursorVisible(t);
1865 updateLocal(bv, FULL, false);
1868 // this will scroll the screen such that the cursor becomes visible
1869 bv->updateScrollbar();
1873 void InsetText::reinitLyXText() const
1875 for(Cache::iterator it = cache.begin(); it != cache.end(); ++it) {
1876 lyx::Assert(it->second.text.get());
1878 LyXText * t = it->second.text.get();
1879 BufferView * bv = it->first;
1881 saveLyXTextState(t);
1882 for (Paragraph * p = par; p; p = p->next()) {
1883 p->resizeInsetsLyXText(bv);
1886 restoreLyXTextState(bv, t);
1887 if (the_locking_inset) {
1888 inset_x = cx(bv) - top_x + drawTextXOffset;
1889 inset_y = cy(bv) + drawTextYOffset;
1892 t->first = bv->screen()->topCursorVisible(t);
1895 updateLocal(bv, FULL, false);
1898 // this will scroll the screen such that the cursor becomes visible
1899 bv->updateScrollbar();
1904 void InsetText::removeNewlines()
1906 for (Paragraph * p = par; p; p = p->next()) {
1907 for (int i = 0; i < p->size(); ++i) {
1908 if (p->getChar(i) == Paragraph::META_NEWLINE)
1915 bool InsetText::nodraw() const
1917 if (the_locking_inset)
1918 return the_locking_inset->nodraw();
1919 return UpdatableInset::nodraw();
1923 int InsetText::scroll(bool recursive) const
1925 int sx = UpdatableInset::scroll(false);
1927 if (recursive && the_locking_inset)
1928 sx += the_locking_inset->scroll(recursive);
1934 bool InsetText::doClearArea() const
1936 return !locked || (need_update & (FULL|INIT));
1940 void InsetText::selectAll(BufferView * bv)
1942 getLyXText(bv)->cursorTop(bv);
1943 getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor;
1944 getLyXText(bv)->cursorBottom(bv);
1945 getLyXText(bv)->setSelection(bv);
1949 void InsetText::clearSelection(BufferView * bv)
1951 getLyXText(bv)->clearSelection(bv);
1955 void InsetText::clearInset(Painter & pain, int baseline, bool & cleared) const
1958 int h = insetAscent + insetDescent;
1959 int ty = baseline - insetAscent;
1965 if ((ty + h) > pain.paperHeight())
1966 h = pain.paperHeight();
1967 if ((top_x + drawTextXOffset + w) > pain.paperWidth())
1968 w = pain.paperWidth();
1969 pain.fillRectangle(top_x+drawTextXOffset, ty, w, h,
1976 Paragraph * InsetText::getParFromID(int id) const
1978 Paragraph * result = par;
1979 Paragraph * ires = 0;
1980 while (result && result->id() != id) {
1981 if ((ires = result->getParFromID(id)))
1983 result = result->next();
1989 Paragraph * InsetText::firstParagraph() const
1992 if (the_locking_inset)
1993 if ((result = the_locking_inset->firstParagraph()))
1999 LyXCursor const & InsetText::cursor(BufferView * bv) const
2001 if (the_locking_inset)
2002 return the_locking_inset->cursor(bv);
2003 return getLyXText(bv)->cursor;
2007 Paragraph * InsetText::paragraph() const
2013 void InsetText::paragraph(Paragraph * p)
2017 // we now have to update/redraw all instances
2018 for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit) {
2023 // redraw myself when asked for
2024 need_update |= INIT;
2028 Inset * InsetText::getInsetFromID(int id_arg) const
2031 return const_cast<InsetText *>(this);
2033 Paragraph * lp = par;
2036 for (Paragraph::inset_iterator it = lp->inset_iterator_begin(),
2037 en = lp->inset_iterator_end();
2040 if ((*it)->id() == id_arg)
2042 Inset * in = (*it)->getInsetFromID(id_arg);
2052 string const InsetText::selectNextWord(BufferView * bv, float & value) const
2058 lt = getLyXText(bv);
2061 if (the_locking_inset) {
2062 str = the_locking_inset->selectNextWord(bv, value);
2069 #warning Dekel please have a look on this one RTL? (Jug)
2070 // we have to go on checking so move cusor to the right
2071 lt->cursor.pos(lt->cursor.pos() + 1);
2073 str = lt->selectNextWord(bv, value);
2075 bv->unlockInset(const_cast<InsetText *>(this));
2084 void InsetText::selectSelectedWord(BufferView * bv)
2086 if (the_locking_inset) {
2087 the_locking_inset->selectSelectedWord(bv);
2090 getLyXText(bv)->selectSelectedWord(bv);
2091 updateLocal(bv, SELECTION, false);
2095 void InsetText::toggleSelection(BufferView * bv, bool kill_selection)
2097 if (the_locking_inset) {
2098 the_locking_inset->toggleSelection(bv, kill_selection);
2102 lt = getLyXText(bv);
2106 int x = top_x + TEXT_TO_INSET_OFFSET;
2109 Row * row = lt->getRowNearY(y);
2110 int y_offset = top_baseline - row->ascent_of_text();
2112 while ((row != 0) && ((y+row->height()) <= 0)) {
2119 if (need_update & SELECTION)
2121 bv->screen()->toggleSelection(lt, bv, kill_selection, y_offset, x);
2127 bool InsetText::searchForward(BufferView * bv, string const & str,
2128 bool const & cs, bool const & mw)
2130 if (the_locking_inset)
2131 if (the_locking_inset->searchForward(bv, str, cs, mw))
2133 if (LyXFind(bv, str, true, true, cs , mw)) {
2136 // we have to unlock ourself in this function by default!
2137 bv->unlockInset(const_cast<InsetText *>(this));
2141 bool InsetText::searchBackward(BufferView * bv, string const & str,
2142 bool const & cs, bool const & mw)
2144 if (the_locking_inset)
2145 if (the_locking_inset->searchBackward(bv, str, cs, mw))
2147 if (LyXFind(bv, str, false, true, cs, mw)) {
2150 // we have to unlock ourself in this function by default!
2151 bv->unlockInset(const_cast<InsetText *>(this));