From: Lars Gullik Bjønnes Date: Sun, 17 Dec 2000 06:09:35 +0000 (+0000) Subject: fix the deadkey bug and a patch from Dekel X-Git-Tag: 1.6.10~21769 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=4b9ed498eafad6a72f12b46d7e9750873d33ae32;p=features.git fix the deadkey bug and a patch from Dekel git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1280 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/ChangeLog b/ChangeLog index b15533e9f3..dbdf020ed2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2000-12-17 Lars Gullik Bjønnes + + * src/kbsequence.C (addkey): also clear sequence and modifiers if + length == 0 + + * src/BufferView2.C (theLockingInset): return 0 if text is 0 + +2000-12-17 Dekel Tsur + + * Many files: Fix RTL support for insettext. + 2000-12-11 John Levon * README: add mention of broken ghostscript versions, remove @@ -10,6 +21,9 @@ 2000-12-11 Jean-Marc Lasgouttes + * src/insets/insetexternal.C (getScreenLabel): Return a default + value if the template label is empty. + * src/lyxlookup.C: do not condition on FL_REVISION. * forms/sp_form.fd: diff --git a/po/POTFILES.in b/po/POTFILES.in index 59c622c560..6bbe76c923 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -53,35 +53,35 @@ src/frontends/kde/refdlg.C src/frontends/kde/tocdlg.C src/frontends/kde/urldlg.C src/frontends/xforms/FormBase.h -src/frontends/xforms/FormCitation.C src/frontends/xforms/form_citation.C -src/frontends/xforms/FormCopyright.C +src/frontends/xforms/FormCitation.C src/frontends/xforms/form_copyright.C -src/frontends/xforms/FormDocument.C +src/frontends/xforms/FormCopyright.C src/frontends/xforms/form_document.C -src/frontends/xforms/FormError.C +src/frontends/xforms/FormDocument.C src/frontends/xforms/form_error.C -src/frontends/xforms/FormGraphics.C +src/frontends/xforms/FormError.C src/frontends/xforms/form_graphics.C -src/frontends/xforms/FormIndex.C +src/frontends/xforms/FormGraphics.C src/frontends/xforms/form_index.C +src/frontends/xforms/FormIndex.C src/frontends/xforms/FormInset.h -src/frontends/xforms/FormParagraph.C src/frontends/xforms/form_paragraph.C -src/frontends/xforms/FormPreferences.C +src/frontends/xforms/FormParagraph.C src/frontends/xforms/form_preferences.C -src/frontends/xforms/FormPrint.C +src/frontends/xforms/FormPreferences.C src/frontends/xforms/form_print.C -src/frontends/xforms/FormRef.C +src/frontends/xforms/FormPrint.C src/frontends/xforms/form_ref.C -src/frontends/xforms/FormTabular.C +src/frontends/xforms/FormRef.C src/frontends/xforms/form_tabular.C -src/frontends/xforms/FormTabularCreate.C +src/frontends/xforms/FormTabular.C src/frontends/xforms/form_tabular_create.C -src/frontends/xforms/FormToc.C +src/frontends/xforms/FormTabularCreate.C src/frontends/xforms/form_toc.C -src/frontends/xforms/FormUrl.C +src/frontends/xforms/FormToc.C src/frontends/xforms/form_url.C +src/frontends/xforms/FormUrl.C src/frontends/xforms/input_validators.C src/frontends/xforms/Menubar_pimpl.C src/frontends/xforms/xform_helpers.C diff --git a/src/BufferView.h b/src/BufferView.h index fbe29d70d2..47deee2bfd 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -100,6 +100,8 @@ public: */ LyXText * text; /// + LyXText * getLyXText() const; + /// int workWidth() const; /// UpdatableInset * theLockingInset() const; diff --git a/src/BufferView2.C b/src/BufferView2.C index 2f90faa753..b1a13b1097 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -741,9 +741,20 @@ void BufferView::showLockedInsetCursor(int x, int y, int asc, int desc) theLockingInset()->GetLockingInset())) text->SetCursor(this, cursor, cursor.par(), cursor.pos() - 1); + LyXScreen::Cursor_Shape shape = LyXScreen::BAR_SHAPE; + LyXText * txt = getLyXText(); + if (theLockingInset()->GetLockingInset()->LyxCode() == + Inset::TEXT_CODE && + (txt->real_current_font.language() != + buffer()->params.language + || txt->real_current_font.isVisibleRightToLeft() + != buffer()->params.language->RightToLeft())) + shape = (txt->real_current_font.isVisibleRightToLeft()) + ? LyXScreen::REVERSED_L_SHAPE + : LyXScreen::L_SHAPE; y += cursor.y() + theLockingInset()->InsetInInsetY(); pimpl_->screen_->ShowManualCursor(text, x, y, asc, desc, - LyXScreen::BAR_SHAPE); + shape); } } @@ -910,7 +921,10 @@ bool BufferView::ChangeRefsIfUnique(string const & from, string const & to) UpdatableInset * BufferView::theLockingInset() const { - return text->the_locking_inset; + // If NULL is not allowed we should put an Assert here. (Lgb) + if (text) + return text->the_locking_inset; + return 0; } @@ -918,3 +932,15 @@ void BufferView::theLockingInset(UpdatableInset * inset) { text->the_locking_inset = inset; } + + +LyXText * BufferView::getLyXText() const +{ + if (theLockingInset()) { + LyXText * txt = theLockingInset()->getLyXText(this); + if (txt) + return txt; + } + return text; +} + diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 855c719261..6d6c98fe8f 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -1237,8 +1237,9 @@ void BufferView::Pimpl::setState() if (!lyxrc.rtl_support) return; - if (bv_->text->real_current_font.isRightToLeft() && - bv_->text->real_current_font.latex() != LyXFont::ON) { + LyXText * text = bv_->getLyXText(); + if (text->real_current_font.isRightToLeft() && + text->real_current_font.latex() != LyXFont::ON) { if (owner_->getIntl()->primarykeymap) owner_->getIntl()->KeyMapSec(); } else { diff --git a/src/WorkArea.C b/src/WorkArea.C index 5735d381f3..57e8e01f18 100644 --- a/src/WorkArea.C +++ b/src/WorkArea.C @@ -346,8 +346,8 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event, if (lyxerr.debugging(Debug::KEY)) { char const * tmp = XKeysymToString(key); char const * tmp2 = XKeysymToString(keysym); - string stm = (tmp ? tmp : ""); - string stm2 = (tmp2 ? tmp2 : ""); + string const stm = (tmp ? tmp : ""); + string const stm2 = (tmp2 ? tmp2 : ""); lyxerr << "WorkArea: Key is `" << stm << "' [" << key << "]" << endl; @@ -387,7 +387,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event, } #endif - unsigned int ret_state = xke->state; + unsigned int const ret_state = xke->state; // If you have a better way to handle "wild-output" of // characters after the key has been released than the one @@ -399,7 +399,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event, << xke->time - last_time_pressed << endl; if (xke->time - last_time_pressed < 35 // should perhaps be tunable - && xke->state == last_state_pressed + && ret_state == last_state_pressed && xke->keycode == last_key_pressed) { lyxerr[Debug::KEY] << "Workarea: Purging X events." << endl; @@ -417,7 +417,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event, } last_time_pressed = xke->time; last_key_pressed = xke->keycode; - last_state_pressed = xke->state; + last_state_pressed = ret_state; area->workAreaKeyPress(ret_key, ret_state); } diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index bcdf2cc0c6..a68acf56c0 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -253,13 +253,7 @@ string const CurrentState(BufferView * bv) if (bv->available()) { // I think we should only show changes from the default // font. (Asger) - LyXText *text = 0; - - if (bv->theLockingInset()) - text = bv->theLockingInset()->getLyXText(bv); - if (!text) - text = bv->text; - + LyXText * text = bv->getLyXText(); Buffer * buffer = bv->buffer(); LyXFont font = text->real_current_font; LyXFont const & defaultfont = @@ -320,7 +314,7 @@ void ToggleAndShow(BufferView * bv, LyXFont const & font) if (font.language() != ignore_language || font.latex() != LyXFont::IGNORE || font.number() != LyXFont::IGNORE) { - LyXText * text = bv->text; + LyXText * text = bv->getLyXText(); LyXCursor & cursor = text->cursor; text->ComputeBidiTables(bv->buffer(), cursor.row()); if (cursor.boundary() != diff --git a/src/insets/inset.C b/src/insets/inset.C index c5526aa723..fa361c96fc 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -76,7 +76,7 @@ string const Inset::EditMessage() const } -LyXText * Inset::getLyXText(BufferView * bv) const +LyXText * Inset::getLyXText(BufferView const * bv) const { if (owner()) return owner()->getLyXText(bv); diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index ca8f71d31c..8698182c10 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -435,7 +435,7 @@ bool InsetCollapsable::doClearArea() const } -LyXText * InsetCollapsable::getLyXText(BufferView * bv) const +LyXText * InsetCollapsable::getLyXText(BufferView const * bv) const { return inset->getLyXText(bv); } diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 87b89ffbe9..f8a3b69688 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -120,7 +120,7 @@ public: /// int getMaxWidth(Painter & pain, UpdatableInset const *) const; /// - LyXText * getLyXText(BufferView *) const; + LyXText * getLyXText(BufferView const *) const; /// void deleteLyXText(BufferView *, bool recursive=true) const; /// diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index d1f7fd49be..13cee12c2b 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -420,7 +420,10 @@ string const InsetExternal::getScreenLabel() const return _("External"); } else { ExternalTemplate const & et = getTemplate(templatename); - return doSubstitution(0, et.guiName); + if (et.guiName.empty()) + return "ext: ???"; + else + return doSubstitution(0, et.guiName); } } @@ -550,7 +553,9 @@ int InsetExternal::getTemplateNumber(string const & name) const ++i; } // This should never happen - Assert(false); + /// This can happen if someone sends you a lyx file that uses + /// external templates that are defined only on his machine + //Assert(false); return 0; } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 3636d99d79..0563397d6c 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -1724,7 +1724,7 @@ void InsetTabular::resizeLyXText(BufferView *) const } -LyXText * InsetTabular::getLyXText(BufferView * bv) const +LyXText * InsetTabular::getLyXText(BufferView const * bv) const { if (the_locking_inset) return the_locking_inset->getLyXText(bv); diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index f9d8396978..c9af4cd409 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -166,7 +166,7 @@ public: /// Buffer * BufferOwner() const { return const_cast(buffer); } /// - LyXText * getLyXText(BufferView *) const; + LyXText * getLyXText(BufferView const *) const; /// void resizeLyXText(BufferView *) const; /// diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 2d5f381ea4..f3edf42778 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -480,6 +480,7 @@ void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button) locked = true; the_locking_inset = 0; inset_pos = inset_x = inset_y = 0; + inset_boundary = false; inset_par = 0; old_par = 0; if (!checkAndActivateInset(bv, x, y, button)) @@ -523,6 +524,7 @@ bool InsetText::LockInsetInInset(BufferView * bv, UpdatableInset * inset) inset_y = cy(bv) + drawTextYOffset; inset_pos = cpos(bv); inset_par = cpar(bv); + inset_boundary = cboundary(bv); TEXT(bv)->UpdateInset(bv, the_locking_inset); return true; } else if (the_locking_inset && (the_locking_inset == inset)) { @@ -618,6 +620,7 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button) inset_y = cy(bv) + drawTextYOffset; inset_pos = cpos(bv); inset_par = cpar(bv); + inset_boundary = cboundary(bv); the_locking_inset = uinset; uinset->InsetButtonPress(bv, x - inset_x, y - inset_y, button); uinset->Edit(bv, x - inset_x, y - inset_y, 0); @@ -749,7 +752,7 @@ InsetText::LocalDispatch(BufferView * bv, HideInsetCursor(bv); switch (action) { // Normal chars - case -1: + case LFUN_UNKNOWN_ACTION: if (bv->buffer()->isReadonly()) { LyXBell(); // setErrorMessage(N_("Document is read only")); @@ -788,6 +791,7 @@ InsetText::LocalDispatch(BufferView * bv, font.setLanguage(text->cursor.par()->getParLanguage(bv->buffer()->params)); SetFont(bv, font, false); } + bv->setState(); if (lyxrc.auto_region_delete) { if (TEXT(bv)->selection){ TEXT(bv)->CutSelection(bv, false); @@ -1480,6 +1484,11 @@ LyXParagraph * InsetText::cpar(BufferView * bv) const return TEXT(bv)->cursor.par(); } +bool InsetText::cboundary(BufferView * bv) const +{ + return TEXT(bv)->cursor.boundary(); +} + Row * InsetText::crow(BufferView * bv) const { @@ -1487,15 +1496,18 @@ Row * InsetText::crow(BufferView * bv) const } -LyXText * InsetText::getLyXText(BufferView * bv) const +LyXText * InsetText::getLyXText(BufferView const * lbv) const { + // Super UGLY! (Lgb) + BufferView * bv = const_cast(lbv); + if ((cache.find(bv) != cache.end()) && cache[bv]) return cache[bv]; LyXText * lt = new LyXText(const_cast(this)); lt->init(bv); cache[bv] = lt; if (the_locking_inset) { - lt->SetCursor(bv, inset_par, inset_pos); + lt->SetCursor(bv, inset_par, inset_pos, true, inset_boundary); } return lt; } @@ -1530,6 +1542,9 @@ void InsetText::resizeLyXText(BufferView * bv) const LyXParagraph::size_type pos = 0; LyXParagraph::size_type selstartpos = 0; LyXParagraph::size_type selendpos = 0; + bool boundary = false; + bool selstartboundary = false; + bool selendboundary = false; int selection = 0; int mark_set = 0; @@ -1538,10 +1553,13 @@ void InsetText::resizeLyXText(BufferView * bv) const if (locked) { lpar = TEXT(bv)->cursor.par(); pos = TEXT(bv)->cursor.pos(); + boundary = TEXT(bv)->cursor.boundary(); selstartpar = TEXT(bv)->sel_start_cursor.par(); selstartpos = TEXT(bv)->sel_start_cursor.pos(); + selstartboundary = TEXT(bv)->sel_start_cursor.boundary(); selendpar = TEXT(bv)->sel_end_cursor.par(); selendpos = TEXT(bv)->sel_end_cursor.pos(); + selendboundary = TEXT(bv)->sel_end_cursor.boundary(); selection = TEXT(bv)->selection; mark_set = TEXT(bv)->mark_set; } @@ -1553,13 +1571,14 @@ void InsetText::resizeLyXText(BufferView * bv) const * Mechanism when setting the cursor */ TEXT(bv)->mark_set = mark_set; if (selection) { - TEXT(bv)->SetCursor(bv, selstartpar, selstartpos); + TEXT(bv)->SetCursor(bv, selstartpar, selstartpos,true, + selstartboundary); TEXT(bv)->sel_cursor = TEXT(bv)->cursor; - TEXT(bv)->SetCursor(bv, selendpar, selendpos); + TEXT(bv)->SetCursor(bv, selendpar, selendpos, true, selendboundary); TEXT(bv)->SetSelection(); TEXT(bv)->SetCursor(bv, lpar, pos); } else { - TEXT(bv)->SetCursor(bv, lpar, pos); + TEXT(bv)->SetCursor(bv, lpar, pos, true, boundary); TEXT(bv)->sel_cursor = TEXT(bv)->cursor; TEXT(bv)->selection = false; } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index cfa525aea5..d7b1e9757a 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -164,7 +164,7 @@ public: /// void SetFrameColor(BufferView *, LColor::color); /// - LyXText * getLyXText(BufferView *) const; + LyXText * getLyXText(BufferView const *) const; /// void deleteLyXText(BufferView *, bool recursive=true) const; /// @@ -229,6 +229,8 @@ private: /// LyXParagraph * cpar(BufferView *) const; /// + bool cboundary(BufferView *) const; + /// Row * crow(BufferView *) const; /// This instead of a macro @@ -256,6 +258,8 @@ private: /// LyXParagraph::size_type inset_pos; /// + bool inset_boundary; + /// mutable int inset_x; /// mutable int inset_y; diff --git a/src/insets/lyxinset.h b/src/insets/lyxinset.h index da544af9be..146741299b 100644 --- a/src/insets/lyxinset.h +++ b/src/insets/lyxinset.h @@ -223,7 +223,7 @@ public: // because we could have fake text insets and have to call this // inside them without cast!!! /// - virtual LyXText * getLyXText(BufferView *) const; + virtual LyXText * getLyXText(BufferView const *) const; /// virtual void deleteLyXText(BufferView *, bool = true) const {} /// diff --git a/src/kbmap.C b/src/kbmap.C index 13f19e224d..00462974ad 100644 --- a/src/kbmap.C +++ b/src/kbmap.C @@ -73,6 +73,12 @@ void kb_keymap::printKey(kb_key const & key, string & buf) // This binds a key to an action int kb_keymap::bind(string const & seq, int action) { + if (lyxerr.debugging(Debug::KBMAP)) { + lyxerr << "BIND: Sequence `" + << seq << "' Action `" + << action << "'" << endl; + } + kb_sequence k; int const res = k.parse(seq); diff --git a/src/kbsequence.C b/src/kbsequence.C index d429f710e8..9289bf60a2 100644 --- a/src/kbsequence.C +++ b/src/kbsequence.C @@ -61,7 +61,11 @@ void printKeysym(unsigned int key, unsigned int mod, string & buf); int kb_sequence::addkey(unsigned int key, unsigned int mod, unsigned int nmod /*= 0*/) { - if (length < 0) { + //lyxerr << "kb_sequence::addkey: length is [" << length << "]\n" + // << "kb_sequence::addkey::key == [" << key << "]\n" + // << "kb_sequence::addkey::mod == [" << mod << "]" << endl; + + if (length <= 0) { length = 0; sequence.clear(); modifiers.clear(); @@ -162,13 +166,14 @@ int kb_sequence::parse(string const & s) Called by : [user] Purpose : print the currently defined sequence into a string Parameters: buf - string where the result goes - maxlen - length of string (including '\0') when_defined - only print when sequence is real: length > 0. Returns : 0, if ok, -1 if string too long \* ---F------------------------------------------------------------------- */ int kb_sequence::print(string & buf, bool when_defined) const { + //lyxerr << "kb_sequence::print: length is [" << length << "]" << endl; + KeySym key; unsigned int mod; int l = length; @@ -177,6 +182,9 @@ int kb_sequence::print(string & buf, bool when_defined) const for (int i = 0; i < l; ++i) { key = sequence[i]; mod = modifiers[i] & 0xffff; + //lyxerr << "kb_sequence::sequence[" << i << "] == [" << key << "]\n" + // << "kb_sequence::modifiers[" << i << "] == [" << mod << "]" + // << endl; printKeysym(key, mod, buf); // RVDK_PATCH_5 diff --git a/src/lyxfunc.C b/src/lyxfunc.C index c08c037b31..ac9c22fbb9 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -156,11 +156,12 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state) if (lyxerr.debugging(Debug::KEY)) { char * tmp = XKeysymToString(keysym); - string stm = (tmp ? tmp : ""); + string const stm = (tmp ? tmp : ""); lyxerr << "KeySym is " << stm << "[" - << keysym << "]" + << keysym << "] State is [" + << state << "]" << endl; } // Do nothing if we have nothing (JMarc) @@ -204,17 +205,25 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state) int action = cancel_meta_seq.addkey(keysym, state &(ShiftMask|ControlMask |Mod1Mask)); - + if (lyxerr.debugging(Debug::KEY)) { + lyxerr << "action first set to [" << action << "]" << endl; + } + // When not cancel or meta-fake, do the normal lookup. // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards. // Mostly, meta_fake_bit = 0. RVDK_PATCH_5. if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) { - + if (lyxerr.debugging(Debug::KEY)) { + lyxerr << "meta_fake_bit is [" << meta_fake_bit << "]" << endl; + } // remove Caps Lock and Mod2 as a modifiers action = keyseq.addkey(keysym, (state | meta_fake_bit) &(ShiftMask|ControlMask - |Mod1Mask)); + |Mod1Mask)); + if (lyxerr.debugging(Debug::KEY)) { + lyxerr << "action now set to [" << action << "]" << endl; + } } // Dont remove this unless you know what you are doing. meta_fake_bit = 0; @@ -249,7 +258,7 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state) return 0; } - char isochar = keyseq.getiso(); + char const isochar = keyseq.getiso(); if (!(state & ControlMask) && !(state & Mod1Mask) && (isochar && keysym < 0xF000)) { @@ -418,13 +427,8 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const if (buf) { func_status box = LyXFunc::ToggleOff; - LyXFont font; - if (owner->view()->theLockingInset() && - owner->view()->theLockingInset()->getLyXText(owner->view())) - font = owner->view()->theLockingInset()-> - getLyXText(owner->view())->real_current_font; - else - font = owner->view()->text->real_current_font; + LyXFont const & font = + owner->view()->getLyXText()->real_current_font; switch (action) { case LFUN_EMPH: if (font.emph() == LyXFont::ON) @@ -472,7 +476,6 @@ string const LyXFunc::Dispatch(int ac, string argument; kb_action action; - LyXText * text = 0; // we have not done anything wrong yet. errorstat = false; @@ -496,6 +499,9 @@ string const LyXFunc::Dispatch(int ac, if (owner->view()->available()) owner->view()->hideCursor(); + // We have to do this heare because of te goto below. (Lgb) + LyXText * text = owner->view()->getLyXText(); + // We cannot use this function here if (getStatus(ac) & Disabled) goto exit_with_message; @@ -526,7 +532,8 @@ string const LyXFunc::Dispatch(int ac, } } - string shortcuts = toplevel_keymap->findbinding(pseudoaction); + string const shortcuts = + toplevel_keymap->findbinding(pseudoaction); if (!shortcuts.empty()) { comname += ": " + shortcuts; @@ -632,14 +639,8 @@ string const LyXFunc::Dispatch(int ac, } } } - if (owner->view()->theLockingInset()) - text = owner->view()->theLockingInset()-> - getLyXText(owner->view()); } - if (!text) - text = owner->view()->text; - switch (action) { // --- Misc ------------------------------------------- case LFUN_WORDFINDFORWARD : diff --git a/src/support/lyxfunctional.h b/src/support/lyxfunctional.h index 50d7ed2243..19e15c20e8 100644 --- a/src/support/lyxfunctional.h +++ b/src/support/lyxfunctional.h @@ -3,10 +3,17 @@ #ifndef LYX_FUNCTIONAL_H #define LYX_FUNCTIONAL_H +/** \file lyxfunctional.h + \brief Convenient function objects for use with LyX + This is currently a small collection of small function objects for use + together with std::algorithms. +**/ + #include //namespace lyx { + template class class_fun_t { public: @@ -34,7 +41,16 @@ private: void(C::*cmf)(A); }; - + +/// Use to call a class method with a container element. +/** Most easily used as a functor to std::algoritms. + Small example: + \verbatim + A a; // class that have a int print(string const &) method + vector vs; + for_each(vs.begin(), vs.end(), class_fun(int, vs, &A::print); + \endverbatim +**/ template class_fun_t class_fun(C & c, R(C::*f)(A)) { diff --git a/src/text2.C b/src/text2.C index 6636883fe8..3acc851c45 100644 --- a/src/text2.C +++ b/src/text2.C @@ -2674,7 +2674,8 @@ void LyXText::CheckParagraph(BufferView * bview, LyXParagraph * par, // set the cursor again. Otherwise // dangling pointers are possible - SetCursor(bview, cursor.par(), cursor.pos()); + SetCursor(bview, cursor.par(), cursor.pos(), + false, cursor.boundary()); sel_cursor = cursor; return; } @@ -2709,20 +2710,25 @@ void LyXText::CheckParagraph(BufferView * bview, LyXParagraph * par, if (selection) { tmpcursor = cursor; - SetCursorIntern(bview, sel_cursor.par(), sel_cursor.pos()); + SetCursorIntern(bview, sel_cursor.par(), sel_cursor.pos(), + false, sel_cursor.boundary()); sel_cursor = cursor; SetCursorIntern(bview, sel_start_cursor.par(), - sel_start_cursor.pos()); + sel_start_cursor.pos(), + false, sel_start_cursor.boundary()); sel_start_cursor = cursor; SetCursorIntern(bview, sel_end_cursor.par(), - sel_end_cursor.pos()); + sel_end_cursor.pos(), + false, sel_end_cursor.boundary()); sel_end_cursor = cursor; SetCursorIntern(bview, last_sel_cursor.par(), - last_sel_cursor.pos()); + last_sel_cursor.pos(), + false, last_sel_cursor.boundary()); last_sel_cursor = cursor; cursor = tmpcursor; } - SetCursorIntern(bview, cursor.par(), cursor.pos()); + SetCursorIntern(bview, cursor.par(), cursor.pos(), + false, cursor.boundary()); }