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()
124 InsetText::InsetText(InsetText const & ins, bool same_id)
130 autoBreakRows = ins.autoBreakRows;
134 InsetText & InsetText::operator=(InsetText const & it)
137 autoBreakRows = it.autoBreakRows;
142 void InsetText::init(InsetText const * ins, bool same_id)
150 the_locking_inset = 0;
152 no_selection = false;
156 autoBreakRows = false;
159 frame_color = LColor::insetframe;
161 setParagraphData(ins->par);
162 autoBreakRows = ins->autoBreakRows;
163 drawFrame_ = ins->drawFrame_;
164 frame_color = ins->frame_color;
168 par->setInsetOwner(this);
171 last_drawn_width = -1;
172 frame_is_visible = false;
179 InsetText::~InsetText()
186 Paragraph * tmp = par->next();
193 void InsetText::clear()
196 Paragraph * tmp = par->next();
205 Inset * InsetText::clone(Buffer const &, bool same_id) const
207 return new InsetText(*this, same_id);
211 void InsetText::write(Buffer const * buf, ostream & os) const
214 writeParagraphData(buf, os);
218 void InsetText::writeParagraphData(Buffer const * buf, ostream & os) const
220 par->writeFile(buf, os, buf->params, 0);
224 void InsetText::read(Buffer const * buf, LyXLex & lex)
228 Paragraph * return_par = 0;
229 Paragraph::depth_type depth = 0;
230 LyXFont font(LyXFont::ALL_INHERIT);
236 token = lex.GetString();
239 if (token == "\\end_inset") {
241 const_cast<Buffer*>(buf)->insertErtContents(par, pos, font, false);
246 if (const_cast<Buffer*>(buf)->
247 parseSingleLyXformat2Token(lex, par, return_par,
248 token, pos, depth, font)) {
249 // the_end read this should NEVER happen
250 lex.printError("\\the_end read in inset! Error in document!");
258 return_par->setInsetOwner(this);
259 return_par = return_par->next();
262 if (token != "\\end_inset") {
263 lex.printError("Missing \\end_inset at this point. "
270 int InsetText::ascent(BufferView * bv, LyXFont const &) const
273 Row * row = getLyXText(bv)->getRowNearY(y_temp);
274 insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
279 int InsetText::descent(BufferView * bv, LyXFont const &) const
287 Row * row = lt->getRowNearY(y_temp);
288 insetDescent = lt->height - row->ascent_of_text() +
289 TEXT_TO_INSET_OFFSET;
296 int InsetText::width(BufferView * bv, LyXFont const &) const
298 insetWidth = max(textWidth(bv),
299 (int)getLyXText(bv)->width + (2 * TEXT_TO_INSET_OFFSET));
304 int InsetText::textWidth(BufferView * bv) const
308 int const w = getMaxWidth(bv, this);
313 void InsetText::draw(BufferView * bv, LyXFont const & f,
314 int baseline, float & x, bool cleared) const
319 Painter & pain = bv->painter();
321 // no draw is necessary !!!
322 if ((drawFrame_ == LOCKED) && !locked && !par->size()) {
324 top_baseline = baseline;
326 if (!cleared && (need_update & CLEAR_FRAME))
327 clearFrame(pain, cleared);
329 frame_is_visible = false;
336 x += static_cast<float>(scroll());
338 // if top_x differs we have a rule down and we don't have to clear anything
339 if (!cleared && (top_x == int(x)) &&
340 ((need_update&(INIT|FULL)) || (top_baseline!=baseline) ||
341 (last_drawn_width!=insetWidth))) {
342 clearInset(pain, baseline, cleared);
345 frame_is_visible = false;
347 if (!cleared && (need_update == NONE))
350 if (top_x != int(x)) {
351 if ((getMaxWidth(bv, this) > 0) &&
352 (getLyXText(bv)->width != old_max_width)) {
355 old_max_width = getLyXText(bv)->width;
356 bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
359 clearInset(pain, baseline, cleared);
362 // lyxerr << "InsetText::draw[" << this << "](" << need_update << ":" << int(x) << ":" << top_x << ")\n";
364 if (cleared || (last_drawn_width != insetWidth)) {
366 last_drawn_width = insetWidth;
369 top_baseline = baseline;
370 top_y = baseline - ascent(bv, f);
371 last_width = width(bv, f);
372 last_height = ascent(bv, f) + descent(bv, f);
374 if (the_locking_inset && (cpar(bv) == inset_par)
375 && (cpos(bv) == inset_pos)) {
376 inset_x = cx(bv) - top_x + drawTextXOffset;
377 inset_y = cy(bv) + drawTextYOffset;
379 if (!cleared && (need_update == CURSOR)
380 && !getLyXText(bv)->selection.set()) {
381 drawFrame(pain, cleared);
382 x += last_width; // was width(bv, f);
391 x += TEXT_TO_INSET_OFFSET;
394 Row * row = lt->getRowNearY(y);
395 int y_offset = baseline - row->ascent_of_text();
396 int ph = pain.paperHeight();
399 while ((row != 0) && ((y+row->height()) <= 0)) {
401 first += row->height();
410 while ((row != 0) && (yf < ph)) {
411 lt->getVisibleRow(bv, y+y_offset, int(x), row,
417 } else if (!locked) {
418 if (need_update & CURSOR) {
419 bv->screen()->toggleSelection(lt, bv, true, y_offset,int(x));
420 lt->clearSelection();
421 lt->selection.cursor = lt->cursor;
423 bv->screen()->update(lt, bv, y_offset, int(x));
426 if (need_update & SELECTION)
427 bv->screen()->toggleToggle(lt, bv, y_offset, int(x));
428 else if (need_update & CURSOR) {
429 bv->screen()->toggleSelection(lt, bv, true, y_offset,int(x));
430 lt->clearSelection();
431 lt->selection.cursor = lt->cursor;
433 bv->screen()->update(lt, bv, y_offset, int(x));
438 lt->status(bv, LyXText::UNCHANGED);
439 if ((need_update != CURSOR_PAR) &&
440 ((drawFrame_ == ALWAYS) || ((drawFrame_ == LOCKED) && locked)))
441 drawFrame(pain, cleared);
442 else if (need_update & CLEAR_FRAME)
443 clearFrame(pain, cleared);
444 x += last_width /* was width(bv, f) */ - TEXT_TO_INSET_OFFSET;
445 if (bv->text->status() == LyXText::CHANGED_IN_DRAW) {
447 } else if (need_update != INIT)
454 void InsetText::drawFrame(Painter & pain, bool cleared) const
456 if (!frame_is_visible || cleared) {
458 frame_y = top_baseline - insetAscent + 1;
459 frame_w = insetWidth - 1;
460 frame_h = insetAscent + insetDescent - 1;
461 pain.rectangle(frame_x, frame_y, frame_w, frame_h,
463 frame_is_visible = true;
468 void InsetText::clearFrame(Painter & pain, bool cleared) const
470 if (frame_is_visible) {
472 pain.rectangle(frame_x, frame_y, frame_w, frame_h,
475 frame_is_visible = false;
480 void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
489 owner()->update(bv, font, true);
493 if (the_locking_inset) {
494 inset_x = cx(bv) - top_x + drawTextXOffset;
495 inset_y = cy(bv) + drawTextYOffset;
496 the_locking_inset->update(bv, font, reinit);
504 int oldw = insetWidth;
505 insetWidth = lt->width + (2 * TEXT_TO_INSET_OFFSET);
506 if (oldw != insetWidth) {
514 if ((need_update & CURSOR_PAR) && (lt->status() == LyXText::UNCHANGED) &&
517 lt->updateInset(bv, the_locking_inset);
519 if (lt->status() == LyXText::NEED_MORE_REFRESH)
527 void InsetText::setUpdateStatus(BufferView * bv, int what) const
535 if (lt->status() == LyXText::NEED_MORE_REFRESH)
537 else if (lt->status() == LyXText::NEED_VERY_LITTLE_REFRESH)
538 need_update |= CURSOR_PAR;
540 // this to not draw a selection when we redraw all of it!
541 if (need_update & CURSOR) {
542 if (lt->selection.set())
544 lt->clearSelection();
551 void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty) const
559 setUpdateStatus(bv, what);
560 if ((need_update != CURSOR) || (lt->status() != LyXText::UNCHANGED) ||
563 bv->updateInset(const_cast<InsetText *>(this), mark_dirty);
565 bv->owner()->showState();
566 if (old_par != cpar(bv)) {
567 bv->owner()->setLayout(cpar(bv)->getLayout());
575 string const InsetText::editMessage() const
577 return _("Opened Text Inset");
581 void InsetText::edit(BufferView * bv, int x, int y, unsigned int button)
583 UpdatableInset::edit(bv, x, y, button);
585 if (!bv->lockInset(this)) {
586 lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
590 the_locking_inset = 0;
591 inset_pos = inset_x = inset_y = 0;
592 inset_boundary = false;
595 int tmp_y = (y < 0) ? 0 : y;
602 if (!checkAndActivateInset(bv, x, tmp_y, button))
603 lt->setCursorFromCoordinates(bv, x - drawTextXOffset,
605 lt->clearSelection();
608 updateLocal(bv, CURSOR, false);
610 // If the inset is empty set the language of the current font to the
611 // language to the surronding text (if different).
612 if (par->size() == 0 && !par->next() &&
613 bv->getParentLanguage(this) != lt->current_font.language()) {
614 LyXFont font(LyXFont::ALL_IGNORE);
615 font.setLanguage(bv->getParentLanguage(this));
616 setFont(bv, font, false);
623 void InsetText::edit(BufferView * bv, bool front)
625 UpdatableInset::edit(bv, front);
627 if (!bv->lockInset(this)) {
628 lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
632 the_locking_inset = 0;
633 inset_pos = inset_x = inset_y = 0;
634 inset_boundary = false;
643 lt->setCursor(bv, par, 0);
648 lt->setCursor(bv, p, p->size()-1);
650 lt->clearSelection();
653 updateLocal(bv, CURSOR, false);
655 // If the inset is empty set the language of the current font to the
656 // language to the surronding text (if different).
657 if (par->size() == 0 && !par->next() &&
658 bv->getParentLanguage(this) != lt->current_font.language()) {
659 LyXFont font(LyXFont::ALL_IGNORE);
660 font.setLanguage(bv->getParentLanguage(this));
661 setFont(bv, font, false);
668 void InsetText::insetUnlock(BufferView * bv)
670 if (the_locking_inset) {
671 the_locking_inset->insetUnlock(bv);
672 the_locking_inset = 0;
675 no_selection = false;
678 if (drawFrame_ == LOCKED)
679 code = CURSOR|CLEAR_FRAME;
687 if (lt->selection.set()) {
688 lt->clearSelection();
690 } else if (owner()) {
691 bv->owner()->setLayout(owner()->getLyXText(bv)
692 ->cursor.par()->getLayout());
694 bv->owner()->setLayout(bv->text->cursor.par()->getLayout());
695 updateLocal(bv, code, false);
701 bool InsetText::lockInsetInInset(BufferView * bv, UpdatableInset * inset)
703 lyxerr[Debug::INSETS] << "InsetText::LockInsetInInset("
707 if (inset == cpar(bv)->getInset(cpos(bv))) {
708 lyxerr[Debug::INSETS] << "OK" << endl;
709 the_locking_inset = inset;
710 inset_x = cx(bv) - top_x + drawTextXOffset;
711 inset_y = cy(bv) + drawTextYOffset;
712 inset_pos = cpos(bv);
713 inset_par = cpar(bv);
714 inset_boundary = cboundary(bv);
715 updateLocal(bv, CURSOR, false);
717 } else if (the_locking_inset && (the_locking_inset == inset)) {
718 if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
719 lyxerr[Debug::INSETS] << "OK" << endl;
720 inset_x = cx(bv) - top_x + drawTextXOffset;
721 inset_y = cy(bv) + drawTextYOffset;
723 lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
725 } else if (the_locking_inset) {
726 lyxerr[Debug::INSETS] << "MAYBE" << endl;
727 return the_locking_inset->lockInsetInInset(bv, inset);
729 lyxerr[Debug::INSETS] << "NOT OK" << endl;
734 bool InsetText::unlockInsetInInset(BufferView * bv, UpdatableInset * inset,
737 if (!the_locking_inset)
739 if (the_locking_inset == inset) {
740 the_locking_inset->insetUnlock(bv);
741 getLyXText(bv)->updateInset(bv, inset);
742 the_locking_inset = 0;
744 moveRight(bv, false);
745 old_par = 0; // force layout setting
749 updateLocal(bv, CURSOR, false);
752 return the_locking_inset->unlockInsetInInset(bv, inset, lr);
756 bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset)
758 if (!the_locking_inset)
760 if (the_locking_inset != inset) {
761 getLyXText(bv)->updateInset(bv, the_locking_inset);
762 setUpdateStatus(bv, CURSOR_PAR);
763 return the_locking_inset->updateInsetInInset(bv, inset);
765 // updateLocal(bv, FULL, false);
766 if (getLyXText(bv)->updateInset(bv, inset))
767 updateLocal(bv, CURSOR_PAR, false);
768 if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
769 inset_x = cx(bv) - top_x + drawTextXOffset;
770 inset_y = cy(bv) + drawTextYOffset;
776 void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
780 int tmp_x = x - drawTextXOffset;
781 int tmp_y = y + insetAscent - getLyXText(bv)->first;
782 Inset * inset = bv->checkInsetHit(getLyXText(bv), tmp_x, tmp_y, button);
785 if (the_locking_inset) {
786 if (the_locking_inset == inset) {
787 the_locking_inset->insetButtonPress(bv,x-inset_x,y-inset_y,button);
788 no_selection = false;
791 // otherwise unlock the_locking_inset and lock the new inset
792 the_locking_inset->insetUnlock(bv);
793 inset_x = cx(bv) - top_x + drawTextXOffset;
794 inset_y = cy(bv) + drawTextYOffset;
795 the_locking_inset = static_cast<UpdatableInset*>(inset);
796 inset->insetButtonPress(bv, x - inset_x, y - inset_y, button);
797 inset->edit(bv, x - inset_x, y - inset_y, button);
798 if (the_locking_inset)
799 updateLocal(bv, CURSOR, false);
800 no_selection = false;
803 // otherwise only unlock the_locking_inset
804 the_locking_inset->insetUnlock(bv);
805 the_locking_inset = 0;
807 if (bv->theLockingInset()) {
808 if (inset && inset->editable() == Inset::HIGHLY_EDITABLE) {
809 UpdatableInset * uinset = static_cast<UpdatableInset*>(inset);
810 inset_x = cx(bv) - top_x + drawTextXOffset;
811 inset_y = cy(bv) + drawTextYOffset;
812 inset_pos = cpos(bv);
813 inset_par = cpar(bv);
814 inset_boundary = cboundary(bv);
815 the_locking_inset = uinset;
816 uinset->insetButtonPress(bv, x - inset_x, y - inset_y,
818 uinset->edit(bv, x - inset_x, y - inset_y, 0);
819 if (the_locking_inset)
820 updateLocal(bv, CURSOR, false);
821 no_selection = false;
825 if (!inset) { // && (button == 2)) {
826 bool paste_internally = false;
827 if ((button == 2) && getLyXText(bv)->selection.set()) {
828 localDispatch(bv, LFUN_COPY, "");
829 paste_internally = true;
831 getLyXText(bv)->setCursorFromCoordinates(bv, x-drawTextXOffset,
833 getLyXText(bv)->clearSelection();
834 updateLocal(bv, FULL, false);
835 getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor;
836 bv->owner()->setLayout(cpar(bv)->getLayout());
838 // Insert primary selection with middle mouse
839 // if there is a local selection in the current buffer,
842 if (paste_internally)
843 localDispatch(bv, LFUN_PASTE, "");
845 localDispatch(bv, LFUN_PASTESELECTION,
850 no_selection = false;
854 void InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button)
856 UpdatableInset * inset = 0;
858 if (the_locking_inset) {
859 the_locking_inset->insetButtonRelease(bv,
860 x - inset_x, y - inset_y,
863 if (cpar(bv)->getChar(cpos(bv)) == Paragraph::META_INSET) {
864 inset = static_cast<UpdatableInset*>(cpar(bv)->getInset(cpos(bv)));
865 if (inset->editable() == Inset::HIGHLY_EDITABLE) {
866 inset->insetButtonRelease(bv,
868 y - inset_y, button);
870 inset_x = cx(bv) - top_x + drawTextXOffset;
871 inset_y = cy(bv) + drawTextYOffset;
872 inset->insetButtonRelease(bv,
874 y - inset_y, button);
876 x - inset_x, y - inset_y, button);
878 updateLocal(bv, CURSOR_PAR, false);
881 no_selection = false;
885 void InsetText::insetMotionNotify(BufferView * bv, int x, int y, int state)
889 if (the_locking_inset) {
890 the_locking_inset->insetMotionNotify(bv, x - inset_x,
894 LyXText * t = getLyXText(bv);
896 t->setCursorFromCoordinates(bv, x - drawTextXOffset, y + insetAscent);
898 if (t->toggle_cursor.par() != t->toggle_end_cursor.par() ||
899 t->toggle_cursor.pos() != t->toggle_end_cursor.pos())
900 updateLocal(bv, SELECTION, false);
905 void InsetText::insetKeyPress(XKeyEvent * xke)
907 if (the_locking_inset) {
908 the_locking_inset->insetKeyPress(xke);
914 UpdatableInset::RESULT
915 InsetText::localDispatch(BufferView * bv,
916 kb_action action, string const & arg)
918 no_selection = false;
919 UpdatableInset::RESULT
920 result= UpdatableInset::localDispatch(bv, action, arg);
921 if (result != UNDISPATCHED) {
926 if ((action < 0) && arg.empty())
929 if (the_locking_inset) {
930 result = the_locking_inset->localDispatch(bv, action, arg);
931 if (result == DISPATCHED_NOUPDATE)
933 else if (result == DISPATCHED) {
934 updateLocal(bv, CURSOR_PAR, false);
936 } else if (result == FINISHED) {
937 bool dispatched = false;
939 case LFUN_UNKNOWN_ACTION:
940 case LFUN_BREAKPARAGRAPH:
942 moveRightIntern(bv, false, false);
945 if (!getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
946 moveRightIntern(bv, false, false);
950 if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
951 moveRightIntern(bv, false, false);
957 the_locking_inset = 0;
970 case LFUN_SELFINSERT:
971 if (bv->buffer()->isReadonly()) {
972 // setErrorMessage(N_("Document is read only"));
976 /* Automatically delete the currently selected
977 * text and replace it with what is being
978 * typed in now. Depends on lyxrc settings
979 * "auto_region_delete", which defaults to
982 setUndo(bv, Undo::INSERT,
983 lt->cursor.par(), lt->cursor.par()->next());
985 if (lyxrc.auto_region_delete) {
986 if (lt->selection.set()) {
987 lt->cutSelection(bv, false);
990 lt->clearSelection();
991 for (string::size_type i = 0; i < arg.length(); ++i) {
993 if (!math_insert_greek(bv, arg[i])) {
994 bv->owner()->getIntl()->getTrans().TranslateAndInsert(arg[i], lt);
995 } else if (!the_locking_inset) {
996 (void)moveRight(bv, false);
999 bv->owner()->getIntl()->getTrans().TranslateAndInsert(arg[i], lt);
1003 lt->selection.cursor = lt->cursor;
1004 updateLocal(bv, CURSOR_PAR, true);
1005 result = DISPATCHED_NOUPDATE;
1007 // --- Cursor Movements -----------------------------------
1010 moveRight(bv, false, true);
1011 lt->setSelection(bv);
1012 updateLocal(bv, SELECTION, false);
1015 result = moveRight(bv);
1017 updateLocal(bv, CURSOR, false);
1021 moveLeft(bv, false, true);
1022 lt->setSelection(bv);
1023 updateLocal(bv, SELECTION, false);
1027 result = moveLeft(bv);
1028 updateLocal(bv, CURSOR, false);
1033 lt->setSelection(bv);
1034 updateLocal(bv, SELECTION, false);
1038 result = moveDown(bv);
1039 updateLocal(bv, CURSOR, false);
1044 lt->setSelection(bv);
1045 updateLocal(bv, SELECTION, false);
1049 result = moveUp(bv);
1050 updateLocal(bv, CURSOR, false);
1055 updateLocal(bv, CURSOR, false);
1059 updateLocal(bv, CURSOR, false);
1061 case LFUN_BACKSPACE: {
1062 setUndo(bv, Undo::DELETE,
1063 lt->cursor.par(), lt->cursor.par()->next());
1064 if (lt->selection.set())
1065 lt->cutSelection(bv);
1068 updateLocal(bv, CURSOR_PAR, true);
1073 setUndo(bv, Undo::DELETE,
1074 lt->cursor.par(), lt->cursor.par()->next());
1075 if (lt->selection.set()) {
1076 lt->cutSelection(bv);
1080 updateLocal(bv, CURSOR_PAR, true);
1085 setUndo(bv, Undo::DELETE,
1086 lt->cursor.par(), lt->cursor.par()->next());
1087 lt->cutSelection(bv);
1088 updateLocal(bv, CURSOR_PAR, true);
1094 lt->copySelection(bv);
1095 updateLocal(bv, CURSOR_PAR, false);
1097 case LFUN_PASTESELECTION:
1099 string const clip(bv->getClipboard());
1103 if (arg == "paragraph") {
1104 lt->insertStringAsParagraphs(bv, clip);
1106 lt->insertStringAsLines(bv, clip);
1108 updateLocal(bv, CURSOR_PAR, true);
1112 if (!autoBreakRows) {
1114 if (CutAndPaste::nrOfParagraphs() > 1) {
1115 WriteAlert(_("Impossible operation"),
1116 _("Cannot include more than one paragraph!"),
1121 setUndo(bv, Undo::INSERT,
1122 lt->cursor.par(), lt->cursor.par()->next());
1123 lt->pasteSelection(bv);
1124 updateLocal(bv, CURSOR_PAR, true);
1128 case LFUN_BREAKPARAGRAPH:
1129 if (!autoBreakRows) {
1130 result = DISPATCHED;
1133 lt->breakParagraph(bv, 0);
1134 updateLocal(bv, FULL, true);
1136 case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
1137 if (!autoBreakRows) {
1138 result = DISPATCHED;
1141 lt->breakParagraph(bv, 1);
1142 updateLocal(bv, FULL, true);
1145 case LFUN_BREAKLINE: {
1146 if (!autoBreakRows) {
1147 result = DISPATCHED;
1150 setUndo(bv, Undo::INSERT,
1151 lt->cursor.par(), lt->cursor.par()->next());
1152 lt->insertChar(bv, Paragraph::META_NEWLINE);
1153 updateLocal(bv, CURSOR_PAR, true);
1158 // do not set layouts on non breakable textinsets
1159 if (autoBreakRows) {
1160 LyXTextClass::size_type cur_layout = cpar(bv)->layout;
1162 // Derive layout number from given argument (string)
1163 // and current buffer's textclass (number). */
1164 LyXTextClassList::ClassList::size_type tclass =
1165 bv->buffer()->params.textclass;
1166 std::pair <bool, LyXTextClass::size_type> layout =
1167 textclasslist.NumberOfLayout(tclass, arg);
1169 // If the entry is obsolete, use the new one instead.
1171 string obs = textclasslist.Style(tclass,layout.second).
1174 layout = textclasslist.NumberOfLayout(tclass, obs);
1177 // see if we found the layout number:
1178 if (!layout.first) {
1179 string const msg = string(N_("Layout ")) + arg + N_(" not known");
1180 bv->owner()->getLyXFunc()->dispatch(LFUN_MESSAGE, msg);
1184 if (cur_layout != layout.second) {
1185 cur_layout = layout.second;
1186 lt->setLayout(bv, layout.second);
1187 bv->owner()->setLayout(cpar(bv)->getLayout());
1188 updateLocal(bv, CURSOR_PAR, true);
1191 // reset the layout box
1192 bv->owner()->setLayout(cpar(bv)->getLayout());
1195 case LFUN_PARAGRAPH_SPACING:
1196 // This one is absolutely not working. When fiddling with this
1197 // it also seems to me that the paragraphs inside the insettext
1198 // inherit bufferparams/paragraphparams in a strange way. (Lgb)
1200 Paragraph * par = lt->cursor.par();
1201 Spacing::Space cur_spacing = par->params().spacing().getSpace();
1202 float cur_value = 1.0;
1203 if (cur_spacing == Spacing::Other) {
1204 cur_value = par->params().spacing().getValue();
1207 istringstream istr(arg.c_str());
1210 Spacing::Space new_spacing = cur_spacing;
1211 float new_value = cur_value;
1213 lyxerr << "Missing argument to `paragraph-spacing'"
1215 } else if (tmp == "single") {
1216 new_spacing = Spacing::Single;
1217 } else if (tmp == "onehalf") {
1218 new_spacing = Spacing::Onehalf;
1219 } else if (tmp == "double") {
1220 new_spacing = Spacing::Double;
1221 } else if (tmp == "other") {
1222 new_spacing = Spacing::Other;
1225 lyxerr << "new_value = " << tmpval << endl;
1228 } else if (tmp == "default") {
1229 new_spacing = Spacing::Default;
1231 lyxerr << _("Unknown spacing argument: ")
1234 if (cur_spacing != new_spacing || cur_value != new_value) {
1235 par->params().spacing(Spacing(new_spacing, new_value));
1236 updateLocal(bv, CURSOR_PAR, true);
1242 if (!bv->Dispatch(action, arg))
1243 result = UNDISPATCHED;
1247 /// If the action has deleted all text in the inset, we need to change the
1248 // language to the language of the surronding text.
1249 if (par->size() == 0 && !par->next()) {
1250 LyXFont font(LyXFont::ALL_IGNORE);
1251 font.setLanguage(bv->getParentLanguage(this));
1252 setFont(bv, font, false);
1255 if (result != FINISHED) {
1256 showInsetCursor(bv);
1258 bv->unlockInset(this);
1265 int InsetText::latex(Buffer const * buf, ostream & os, bool, bool) const
1268 buf->latexParagraphs(os, par, 0, texrow);
1269 return texrow.rows();
1273 int InsetText::ascii(Buffer const * buf, ostream & os, int linelen) const
1275 Paragraph * p = par;
1276 unsigned int lines = 0;
1279 string const tmp = buf->asciiParagraph(p, linelen);
1280 lines += countChar(tmp, '\n');
1288 int InsetText::docBook(Buffer const * buf, ostream & os) const
1290 Paragraph * p = par;
1291 unsigned int lines = 0;
1296 buf->simpleDocBookOnePar(os, tmp, p, desc, 0);
1304 void InsetText::validate(LaTeXFeatures & features) const
1306 Paragraph * p = par;
1308 p->validate(features);
1314 int InsetText::beginningOfMainBody(Buffer const * buf, Paragraph * p) const
1316 if (textclasslist.Style(buf->params.textclass,
1317 p->getLayout()).labeltype != LABEL_MANUAL)
1320 return p->beginningOfMainBody();
1324 void InsetText::getCursorPos(BufferView * bv,
1325 int & x, int & y) const
1327 if (the_locking_inset) {
1328 the_locking_inset->getCursorPos(bv, x, y);
1336 unsigned int InsetText::insetInInsetY()
1338 if (!the_locking_inset)
1341 return (inset_y + the_locking_inset->insetInInsetY());
1345 void InsetText::toggleInsetCursor(BufferView * bv)
1347 if (the_locking_inset) {
1348 the_locking_inset->toggleInsetCursor(bv);
1352 LyXFont const font(getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv)));
1354 int const asc = lyxfont::maxAscent(font);
1355 int const desc = lyxfont::maxDescent(font);
1357 if (isCursorVisible())
1358 bv->hideLockedInsetCursor();
1360 bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
1361 toggleCursorVisible();
1365 void InsetText::showInsetCursor(BufferView * bv, bool show)
1367 if (the_locking_inset) {
1368 the_locking_inset->showInsetCursor(bv, show);
1371 if (!isCursorVisible()) {
1372 LyXFont const font =
1373 getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
1375 int const asc = lyxfont::maxAscent(font);
1376 int const desc = lyxfont::maxDescent(font);
1378 bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
1380 bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
1381 setCursorVisible(true);
1386 void InsetText::hideInsetCursor(BufferView * bv)
1388 if (isCursorVisible()) {
1389 bv->hideLockedInsetCursor();
1390 setCursorVisible(false);
1392 if (the_locking_inset)
1393 the_locking_inset->hideInsetCursor(bv);
1397 void InsetText::fitInsetCursor(BufferView * bv) const
1399 if (the_locking_inset) {
1400 the_locking_inset->fitInsetCursor(bv);
1403 LyXFont const font =
1404 getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
1406 int const asc = lyxfont::maxAscent(font);
1407 int const desc = lyxfont::maxDescent(font);
1409 bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
1413 UpdatableInset::RESULT
1414 InsetText::moveRight(BufferView * bv, bool activate_inset, bool selecting)
1416 if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
1417 return moveLeftIntern(bv, false, activate_inset, selecting);
1419 return moveRightIntern(bv, false, activate_inset, selecting);
1423 UpdatableInset::RESULT
1424 InsetText::moveLeft(BufferView * bv, bool activate_inset, bool selecting)
1426 if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
1427 return moveRightIntern(bv, true, activate_inset, selecting);
1429 return moveLeftIntern(bv, true, activate_inset, selecting);
1433 UpdatableInset::RESULT
1434 InsetText::moveRightIntern(BufferView * bv, bool behind,
1435 bool activate_inset, bool selecting)
1437 if (!cpar(bv)->next() && (cpos(bv) >= cpar(bv)->size()))
1439 if (activate_inset && checkAndActivateInset(bv, behind))
1441 getLyXText(bv)->cursorRight(bv);
1443 getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor;
1444 return DISPATCHED_NOUPDATE;
1448 UpdatableInset::RESULT
1449 InsetText::moveLeftIntern(BufferView * bv, bool behind,
1450 bool activate_inset, bool selecting)
1452 if (!cpar(bv)->previous() && (cpos(bv) <= 0))
1454 getLyXText(bv)->cursorLeft(bv);
1456 getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor;
1457 if (activate_inset && checkAndActivateInset(bv, behind))
1459 return DISPATCHED_NOUPDATE;
1463 UpdatableInset::RESULT
1464 InsetText::moveUp(BufferView * bv)
1466 if (!crow(bv)->previous())
1468 getLyXText(bv)->cursorUp(bv);
1469 return DISPATCHED_NOUPDATE;
1473 UpdatableInset::RESULT
1474 InsetText::moveDown(BufferView * bv)
1476 if (!crow(bv)->next())
1478 getLyXText(bv)->cursorDown(bv);
1479 return DISPATCHED_NOUPDATE;
1483 bool InsetText::insertInset(BufferView * bv, Inset * inset)
1485 if (the_locking_inset) {
1486 if (the_locking_inset->insetAllowed(inset))
1487 return the_locking_inset->insertInset(bv, inset);
1490 inset->setOwner(this);
1491 hideInsetCursor(bv);
1495 lt = getLyXText(bv);
1498 lt->insertInset(bv, inset);
1500 if ((cpar(bv)->getChar(cpos(bv)) != Paragraph::META_INSET) ||
1501 (cpar(bv)->getInset(cpos(bv)) != inset))
1505 updateLocal(bv, CURSOR_PAR|CURSOR, true);
1506 showInsetCursor(bv);
1513 bool InsetText::insetAllowed(Inset::Code code) const
1515 if (the_locking_inset)
1516 return the_locking_inset->insetAllowed(code);
1521 UpdatableInset * InsetText::getLockingInset() const
1523 return the_locking_inset ? the_locking_inset->getLockingInset() :
1524 const_cast<InsetText *>(this);
1528 UpdatableInset * InsetText::getFirstLockingInsetOfType(Inset::Code c)
1532 if (the_locking_inset)
1533 return the_locking_inset->getFirstLockingInsetOfType(c);
1538 bool InsetText::showInsetDialog(BufferView * bv) const
1540 if (the_locking_inset)
1541 return the_locking_inset->showInsetDialog(bv);
1546 std::vector<string> const InsetText::getLabelList() const
1548 std::vector<string> label_list;
1550 Paragraph * tpar = par;
1552 Paragraph::inset_iterator beg = tpar->inset_iterator_begin();
1553 Paragraph::inset_iterator end = tpar->inset_iterator_end();
1554 for (; beg != end; ++beg) {
1555 std::vector<string> const l = (*beg)->getLabelList();
1556 label_list.insert(label_list.end(), l.begin(), l.end());
1558 tpar = tpar->next();
1564 void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall,
1567 if (the_locking_inset) {
1568 the_locking_inset->setFont(bv, font, toggleall, selectall);
1573 lt = getLyXText(bv);
1576 if (lt->selection.set()) {
1577 setUndo(bv, Undo::EDIT, lt->cursor.par(), lt->cursor.par()->next());
1582 lt->toggleFree(bv, font, toggleall);
1584 lt->setFont(bv, font, toggleall);
1587 lt->clearSelection();
1589 if (selectall || lt->selection.set())
1590 updateLocal(bv, FULL, true);
1592 updateLocal(bv, CURSOR_PAR, true);
1598 bool InsetText::checkAndActivateInset(BufferView * bv, bool behind)
1600 if (cpar(bv)->getChar(cpos(bv)) == Paragraph::META_INSET) {
1604 static_cast<UpdatableInset*>(cpar(bv)->getInset(cpos(bv)));
1605 if (!inset || inset->editable() != Inset::HIGHLY_EDITABLE)
1607 LyXFont const font =
1608 getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
1610 x = inset->width(bv, font);
1611 y = font.isRightToLeft() ? 0 : inset->descent(bv, font);
1614 y = font.isRightToLeft() ? inset->descent(bv, font) : 0;
1616 //inset_x = cx(bv) - top_x + drawTextXOffset;
1617 //inset_y = cy(bv) + drawTextYOffset;
1618 inset->edit(bv, x, y, 0);
1619 if (!the_locking_inset)
1621 updateLocal(bv, CURSOR, false);
1628 bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
1631 x -= drawTextXOffset;
1633 int dummyy = y + insetAscent;
1634 Inset * inset = bv->checkInsetHit(getLyXText(bv), dummyx, dummyy, button);
1641 inset_x = cx(bv) - top_x + drawTextXOffset;
1642 inset_y = cy(bv) + drawTextYOffset;
1643 inset->edit(bv, x - inset_x, y - inset_y, button);
1644 if (!the_locking_inset)
1646 updateLocal(bv, CURSOR, false);
1653 int InsetText::getMaxWidth(BufferView * bv, UpdatableInset const * inset) const
1655 int w = UpdatableInset::getMaxWidth(bv, inset);
1660 w = w - top_x + owner()->x();
1663 w -= (2 * TEXT_TO_INSET_OFFSET);
1665 // return w - (2*TEXT_TO_INSET_OFFSET);
1669 void InsetText::setParagraphData(Paragraph * p)
1672 Paragraph * tmp = par->next();
1677 par = new Paragraph(*p);
1678 par->setInsetOwner(this);
1679 Paragraph * np = par;
1682 np->next(new Paragraph(*p));
1683 np->next()->previous(np);
1685 np->setInsetOwner(this);
1691 void InsetText::setText(string const & data)
1694 LyXFont font(LyXFont::ALL_SANE);
1695 for (unsigned int i=0; i < data.length(); ++i)
1696 par->insertChar(i, data[i], font);
1700 void InsetText::setAutoBreakRows(bool flag)
1702 if (flag != autoBreakRows) {
1703 autoBreakRows = flag;
1712 void InsetText::setDrawFrame(BufferView * bv, DrawFrame how)
1714 if (how != drawFrame_) {
1717 updateLocal(bv, DRAW_FRAME, false);
1722 void InsetText::setFrameColor(BufferView * bv, LColor::color col)
1724 if (frame_color != col) {
1727 updateLocal(bv, DRAW_FRAME, false);
1732 int InsetText::cx(BufferView * bv) const
1736 lt = getLyXText(bv);
1739 int x = lt->cursor.x() + top_x + TEXT_TO_INSET_OFFSET;
1740 if (the_locking_inset) {
1741 LyXFont font = lt->getFont(bv->buffer(),
1744 if (font.isVisibleRightToLeft())
1745 x -= the_locking_inset->width(bv, font);
1753 int InsetText::cy(BufferView * bv) const
1756 return getLyXText(bv)->cursor.y() - ascent(bv, font) + TEXT_TO_INSET_OFFSET;
1760 Paragraph::size_type InsetText::cpos(BufferView * bv) const
1762 return getLyXText(bv)->cursor.pos();
1766 Paragraph * InsetText::cpar(BufferView * bv) const
1768 return getLyXText(bv)->cursor.par();
1772 bool InsetText::cboundary(BufferView * bv) const
1774 return getLyXText(bv)->cursor.boundary();
1778 Row * InsetText::crow(BufferView * bv) const
1780 return getLyXText(bv)->cursor.row();
1784 LyXText * InsetText::getLyXText(BufferView const * lbv,
1785 bool const recursive) const
1787 if (!recursive && (cached_bview == lbv))
1788 return cached_text.get();
1790 // Super UGLY! (Lgb)
1791 BufferView * bv = const_cast<BufferView *>(lbv);
1794 Cache::iterator it = cache.find(bv);
1796 if (it != cache.end()) {
1797 if (lt || !it->second.remove) {
1798 lyx::Assert(it->second.text.get());
1799 cached_text = it->second.text;
1800 if (recursive && the_locking_inset) {
1801 return the_locking_inset->getLyXText(bv, true);
1803 return cached_text.get();
1804 } else if (it->second.remove) {
1806 saveLyXTextState(it->second.text.get());
1813 cached_text.reset(new LyXText(const_cast<InsetText *>(this)));
1814 cached_text->init(bv);
1815 restoreLyXTextState(bv, cached_text.get());
1817 cache.insert(make_pair(bv, cached_text));
1819 if (the_locking_inset && recursive) {
1820 return the_locking_inset->getLyXText(bv);
1822 return cached_text.get();
1826 void InsetText::deleteLyXText(BufferView * bv, bool recursive) const
1830 Cache::iterator it = cache.find(bv);
1832 if (it == cache.end()) {
1836 lyx::Assert(it->second.text.get());
1838 it->second.remove = true;
1840 /// then remove all LyXText in text-insets
1841 Paragraph * p = par;
1842 for (; p; p = p->next()) {
1843 p->deleteInsetsLyXText(bv);
1849 void InsetText::resizeLyXText(BufferView * bv, bool force) const
1851 if (!par->next() && !par->size()) // no data, resize not neccessary!
1853 // one endless line, resize normally not necessary
1854 if (!force && getMaxWidth(bv, this) < 0)
1857 Cache::iterator it = cache.find(bv);
1858 if (it == cache.end()) {
1861 lyx::Assert(it->second.text.get());
1863 LyXText * t = it->second.text.get();
1864 saveLyXTextState(t);
1865 for (Paragraph * p = par; p; p = p->next()) {
1866 p->resizeInsetsLyXText(bv);
1869 restoreLyXTextState(bv, t);
1870 if (the_locking_inset) {
1871 inset_x = cx(bv) - top_x + drawTextXOffset;
1872 inset_y = cy(bv) + drawTextYOffset;
1876 t->first = bv->screen()->topCursorVisible(t);
1879 updateLocal(bv, FULL, false);
1882 // this will scroll the screen such that the cursor becomes visible
1883 bv->updateScrollbar();
1887 void InsetText::reinitLyXText() const
1889 for(Cache::iterator it = cache.begin(); it != cache.end(); ++it) {
1890 lyx::Assert(it->second.text.get());
1892 LyXText * t = it->second.text.get();
1893 BufferView * bv = it->first;
1895 saveLyXTextState(t);
1896 for (Paragraph * p = par; p; p = p->next()) {
1897 p->resizeInsetsLyXText(bv);
1900 restoreLyXTextState(bv, t);
1901 if (the_locking_inset) {
1902 inset_x = cx(bv) - top_x + drawTextXOffset;
1903 inset_y = cy(bv) + drawTextYOffset;
1906 t->first = bv->screen()->topCursorVisible(t);
1909 updateLocal(bv, FULL, false);
1912 // this will scroll the screen such that the cursor becomes visible
1913 bv->updateScrollbar();
1918 void InsetText::removeNewlines()
1920 for (Paragraph * p = par; p; p = p->next()) {
1921 for (int i = 0; i < p->size(); ++i) {
1922 if (p->getChar(i) == Paragraph::META_NEWLINE)
1929 bool InsetText::nodraw() const
1931 if (the_locking_inset)
1932 return the_locking_inset->nodraw();
1933 return UpdatableInset::nodraw();
1937 int InsetText::scroll(bool recursive) const
1939 int sx = UpdatableInset::scroll(false);
1941 if (recursive && the_locking_inset)
1942 sx += the_locking_inset->scroll(recursive);
1948 bool InsetText::doClearArea() const
1950 return !locked || (need_update & (FULL|INIT));
1954 void InsetText::selectAll(BufferView * bv)
1956 getLyXText(bv)->cursorTop(bv);
1957 getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor;
1958 getLyXText(bv)->cursorBottom(bv);
1959 getLyXText(bv)->setSelection(bv);
1963 void InsetText::clearSelection(BufferView * bv)
1965 getLyXText(bv)->clearSelection();
1969 void InsetText::clearInset(Painter & pain, int baseline, bool & cleared) const
1972 int h = insetAscent + insetDescent;
1973 int ty = baseline - insetAscent;
1979 if ((ty + h) > pain.paperHeight())
1980 h = pain.paperHeight();
1981 if ((top_x + drawTextXOffset + w) > pain.paperWidth())
1982 w = pain.paperWidth();
1983 pain.fillRectangle(top_x+drawTextXOffset, ty, w, h,
1990 Paragraph * InsetText::getParFromID(int id) const
1992 Paragraph * result = par;
1993 Paragraph * ires = 0;
1994 while (result && result->id() != id) {
1995 if ((ires = result->getParFromID(id)))
1997 result = result->next();
2003 Paragraph * InsetText::firstParagraph() const
2006 if (the_locking_inset)
2007 if ((result = the_locking_inset->firstParagraph()))
2013 LyXCursor const & InsetText::cursor(BufferView * bv) const
2015 if (the_locking_inset)
2016 return the_locking_inset->cursor(bv);
2017 return getLyXText(bv)->cursor;
2021 Paragraph * InsetText::paragraph() const
2027 void InsetText::paragraph(Paragraph * p)
2031 // we now have to update/redraw all instances
2032 for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit) {
2037 // redraw myself when asked for
2038 need_update |= INIT;
2042 Inset * InsetText::getInsetFromID(int id_arg) const
2045 return const_cast<InsetText *>(this);
2047 Paragraph * lp = par;
2050 for (Paragraph::inset_iterator it = lp->inset_iterator_begin(),
2051 en = lp->inset_iterator_end();
2054 if ((*it)->id() == id_arg)
2056 Inset * in = (*it)->getInsetFromID(id_arg);
2066 string const InsetText::selectNextWord(BufferView * bv, float & value) const
2072 lt = getLyXText(bv);
2075 if (the_locking_inset) {
2076 str = the_locking_inset->selectNextWord(bv, value);
2083 #warning Dekel please have a look on this one RTL? (Jug)
2084 // we have to go on checking so move cusor to the right
2085 lt->cursor.pos(lt->cursor.pos() + 1);
2087 str = lt->selectNextWord(bv, value);
2089 bv->unlockInset(const_cast<InsetText *>(this));
2098 void InsetText::selectSelectedWord(BufferView * bv)
2100 if (the_locking_inset) {
2101 the_locking_inset->selectSelectedWord(bv);
2104 getLyXText(bv)->selectSelectedWord(bv);
2105 updateLocal(bv, SELECTION, false);
2109 void InsetText::toggleSelection(BufferView * bv, bool kill_selection)
2111 if (the_locking_inset) {
2112 the_locking_inset->toggleSelection(bv, kill_selection);
2116 lt = getLyXText(bv);
2120 int x = top_x + TEXT_TO_INSET_OFFSET;
2123 Row * row = lt->getRowNearY(y);
2124 int y_offset = top_baseline - row->ascent_of_text();
2126 while ((row != 0) && ((y+row->height()) <= 0)) {
2133 if (need_update & SELECTION)
2135 bv->screen()->toggleSelection(lt, bv, kill_selection, y_offset, x);
2141 bool InsetText::searchForward(BufferView * bv, string const & str,
2142 bool const & cs, bool const & mw)
2144 if (the_locking_inset) {
2145 if (the_locking_inset->searchForward(bv, str, cs, mw))
2149 lt = getLyXText(bv);
2152 Paragraph * lpar = lt->cursor.par();
2153 Paragraph::size_type pos = lt->cursor.pos();
2154 if (pos < lpar->size() - 1)
2158 lpar = lpar->next();
2165 lt->setCursor(bv, lpar, pos);
2169 if (LyXFind(bv, str, true, true, cs , mw)) {
2172 // we have to unlock ourself in this function by default!
2173 bv->unlockInset(const_cast<InsetText *>(this));
2177 bool InsetText::searchBackward(BufferView * bv, string const & str,
2178 bool const & cs, bool const & mw)
2180 if (the_locking_inset)
2181 if (the_locking_inset->searchBackward(bv, str, cs, mw))
2183 if (LyXFind(bv, str, false, true, cs, mw)) {
2186 // we have to unlock ourself in this function by default!
2187 bv->unlockInset(const_cast<InsetText *>(this));