Re: LyX/Mac 1.3.6 - Keybindings
Bennett Helm wrote: Something needs to change, and the question is what. Here are some options (which I think go from less desirable to more desirable, other things being equal): Perhaps the easiest solution (for 1.3.6) is to disable the QIMEvent stuff for Mac. For 1.4, I think we have to investigate further. Did the qt-immodule problem (bug 1830) occur on Mac or is qt/mac not patched with qt-immodule at all? Jürgen
Re: LyX/Mac 1.3.6 - Keybindings
Juergen Spitzmueller wrote: Perhaps the easiest solution (for 1.3.6) is to disable the QIMEvent stuff for Mac. For 1.4, I think we have to investigate further. Did the qt-immodule problem (bug 1830) occur on Mac or is qt/mac not patched with qt-immodule at all? After some more investigation on the web, I think the safest is to enable it just for Q_WS_X11. It seems that the qt-immodule patches are only available for qt/x11 anyway. See attached. Agreed? Also for 1.4? Jürgen Index: QContentPane.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QContentPane.C,v retrieving revision 1.18.2.3 diff -u -r1.18.2.3 QContentPane.C --- QContentPane.C 28 May 2005 11:07:45 - 1.18.2.3 +++ QContentPane.C 3 Jun 2005 06:57:15 - @@ -96,10 +96,12 @@ setFocusPolicy(QWidget::WheelFocus); setFocus(); setCursor(ibeamCursor); +#ifdef Q_WS_X11 #if QT_VERSION = 0x030200 // to make qt-immodule work setInputMethodEnabled(true); -#endif +#endif //QT_VERSION +#endif //Q_WS_X11 // stupid moc strikes again connect(wa_-scrollbar_, SIGNAL(valueChanged(int)), @@ -108,6 +110,7 @@ } +#ifdef Q_WS_X11 #if QT_VERSION = 0x030200 // to make qt-immodule work void QContentPane::imStartEvent(QIMEvent *e) @@ -136,7 +139,8 @@ } e-accept(); } -#endif +#endif //QT_VERSION +#endif //Q_WS_X11 void QContentPane::scrollBarChanged(int val) Index: QContentPane.h === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QContentPane.h,v retrieving revision 1.7.2.3 diff -u -r1.7.2.3 QContentPane.h --- QContentPane.h 28 May 2005 11:07:45 - 1.7.2.3 +++ QContentPane.h 3 Jun 2005 06:57:15 - @@ -97,12 +97,14 @@ void wheelEvent(QWheelEvent * e); /// key press void keyPressEvent(QKeyEvent * e); +#ifdef Q_WS_X11 #if QT_VERSION = 0x030200 /// IM events void imStartEvent(QIMEvent *); void imComposeEvent(QIMEvent *); void imEndEvent(QIMEvent *); -#endif +#endif //QT_VERSION +#endif //Q_WS_X11 public slots: void doubleClickTimeout();
Re: LyX/Mac 1.3.6 - Keybindings
Juergen == Juergen Spitzmueller [EMAIL PROTECTED] writes: Juergen Juergen Spitzmueller wrote: Perhaps the easiest solution (for 1.3.6) is to disable the QIMEvent stuff for Mac. For 1.4, I think we have to investigate further. Did the qt-immodule problem (bug 1830) occur on Mac or is qt/mac not patched with qt-immodule at all? Juergen After some more investigation on the web, I think the safest Juergen is to enable it just for Q_WS_X11. It seems that the Juergen qt-immodule patches are only available for qt/x11 anyway. See Juergen attached. It is definitely the best solution. About the tests, what about using #if defined(Q_WS_X11) QT_VERSION = 0x030200 You could also define a USE_INPUT_METHODS in QContentPane.h #if defined(Q_WS_X11) QT_VERSION = 0x030200 #define USE_INPUT_METHODS 1 #endif and use this later. The advantage is to make the meaning of the test clear. Juergen Agreed? Also for 1.4? Yes. JMarc
Re: LyX/Mac 1.3.6 - Keybindings
Jean-Marc Lasgouttes wrote: It is definitely the best solution. About the tests, what about using #if defined(Q_WS_X11) QT_VERSION = 0x030200 OK. I was careful because I didn't know how these two tests can be mixed. Thanks. You could also define a USE_INPUT_METHODS in QContentPane.h #if defined(Q_WS_X11) QT_VERSION = 0x030200 #define USE_INPUT_METHODS 1 #endif and use this later. The advantage is to make the meaning of the test clear. Yes, this is semantically very clear. I'll use this and commit. Jürgen
Re: [PATCH] fix selection of error range through errorlist dialog
Jean-Marc == Jean-Marc Lasgouttes [EMAIL PROTECTED] writes: Jean-Marc The following patch fixes in the common cases the selection Jean-Marc relevant document range when clicking on an entry of the Jean-Marc errorlist dialog. There are still cases where this does not Jean-Marc work at all, the worst being when the error is in a text Jean-Marc inset. This would require more work (in particular passing Jean-Marc the main TexRow object to the underlying textinset). Jean-Marc I will commit tomorrow if nobody objects. Done. JMarc
Re: [Patch] Re: [patch] key event queue
Lars Gullik Bjnnes wrote: Martin Vermeer [EMAIL PROTECTED] writes: [...] | No, I meant that just the other way around. The fact that fast mouse | scrolling exists allows us to make keyboard scrolling slow... as your | event queue for ex. does. The slowness will drive people to use the | mouse for fast positioning within the document, which I again dislike. | (and about surprising behaviour: only the first time. You get used to | it, and _like_ it, real fast. And it does no damage...) I want to scroll down to next chapter beginning how do you know when you get there? In that case, use navigate and select the chapter. No need for scrolling to a chapter heading (or any other structured heading.) Helge Hafting
[PATCH] Bug 961: reintroduce LFUN_BIBDB_ADD/DEL
http://bugzilla.lyx.org/show_bug.cgi?id=961 The attached patch reimplements those lfuns. It also fixes InsetBibtex::delDatabase, which is broken in 1.3. The only drawback is that the lfuns are not working when the cursor sits behind the inset. The same applies to 1.3. The reason is that getInsetByCode stops at the end of the document. OK to apply? Jürgen Index: BufferView_pimpl.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.584 diff -u -r1.584 BufferView_pimpl.C --- BufferView_pimpl.C 31 May 2005 14:40:23 - 1.584 +++ BufferView_pimpl.C 3 Jun 2005 13:14:31 - @@ -51,6 +51,7 @@ #include undo.h #include vspace.h +#include insets/insetbibtex.h #include insets/insetref.h #include insets/insettext.h @@ -987,6 +988,8 @@ case LFUN_MARK_ON: case LFUN_SETMARK: case LFUN_CENTER: + case LFUN_BIBDB_ADD: + case LFUN_BIBDB_DEL: case LFUN_WORDS_COUNT: flag.enabled(true); break; @@ -1211,6 +1214,24 @@ case LFUN_CENTER: center(); break; + + case LFUN_BIBDB_ADD: { + InsetBibtex * inset = + getInsetByCodeInsetBibtex(cursor_, + InsetBase::BIBTEX_CODE); + if (inset) + inset-addDatabase(cmd.argument); + break; + } + + case LFUN_BIBDB_DEL: { + InsetBibtex * inset = + getInsetByCodeInsetBibtex(cursor_, + InsetBase::BIBTEX_CODE); + if (inset) + inset-delDatabase(cmd.argument); + break; + } case LFUN_WORDS_COUNT: { DocIterator from, to; Index: LyXAction.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v retrieving revision 1.206 diff -u -r1.206 LyXAction.C --- LyXAction.C 8 May 2005 10:02:37 - 1.206 +++ LyXAction.C 3 Jun 2005 13:14:31 - @@ -188,6 +188,8 @@ { LFUN_INSERT_LABEL, label-insert, Noop }, { LFUN_INSET_OPTARG, optional-insert, Noop }, { LFUN_INSERT_BIBITEM, bibitem-insert, Noop }, + { LFUN_BIBDB_ADD, bibtex-database-add, Noop }, + { LFUN_BIBDB_DEL, bibtex-database-del, Noop }, { LFUN_INSERT_LINE, line-insert, Noop }, { LFUN_INSERT_PAGEBREAK, pagebreak-insert, Noop }, { LFUN_LANGUAGE, language, Noop }, Index: lfuns.h === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lfuns.h,v retrieving revision 1.41 diff -u -r1.41 lfuns.h --- lfuns.h 8 May 2005 10:02:37 - 1.41 +++ lfuns.h 3 Jun 2005 13:14:32 - @@ -355,6 +355,8 @@ // 270 LFUN_WORDS_COUNT, LFUN_OUTPUT_CHANGES, // jspitzm 20050121 + LFUN_BIBDB_ADD, + LFUN_BIBDB_DEL, LFUN_LASTACTION // end of the table }; Index: insets/insetbibtex.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibtex.C,v retrieving revision 1.54 diff -u -r1.54 insetbibtex.C --- insets/insetbibtex.C 17 May 2005 11:11:45 - 1.54 +++ insets/insetbibtex.C 3 Jun 2005 13:14:36 - @@ -283,16 +283,17 @@ bool InsetBibtex::delDatabase(string const db) { - if (contains(getContents(), db)) { + string contents(getContents()); + if (contains(contents, db)) { + int const n = tokenPos(contents, ',', db); string bd = db; - int const n = tokenPos(getContents(), ',', bd); if (n 0) { - // Weird code, would someone care to explain this?(Lgb) - string tmp(, ); - tmp += bd; - setContents(subst(getContents(), tmp, , )); + // this is not the first database + string tmp = ',' + bd; + setContents(subst(contents, tmp, )); } else if (n == 0) - setContents(split(getContents(), bd, ',')); + // this is the first (or only) database + setContents(split(contents, bd, ',')); else return false; }
Re: [PATCH] Bug 961: reintroduce LFUN_BIBDB_ADD/DEL
Juergen == Juergen Spitzmueller [EMAIL PROTECTED] writes: Juergen The only drawback is that the lfuns are not working when the Juergen cursor sits behind the inset. The same applies to 1.3. The Juergen reason is that getInsetByCode stops at the end of the Juergen document. Did you look at gotoInset in bufferview_funcs.[Ch]? JMarc
Re: [PATCH] Bug 961: reintroduce LFUN_BIBDB_ADD/DEL
Jean-Marc Lasgouttes wrote: Did you look at gotoInset in bufferview_funcs.[Ch]? Yes, but I think this is not what I need here. gotoInset moves the cursor to the next inset, while LFUN_BIBDB_* needs the next bibtex inset, without moving the cursor. It would probably make more sense to use gotoInset in LFUN_LABEL_GOTO, which also uses getInsetByCode, but I'm not sure. Actually, I'm not even sure I understand what LABEL_GOTO does (or is it broken?) Do you have an idea how to make getInsetByCode loop (and stop if there is no inset in the document)? Here's the code: /// Get next inset of this class from current cursor position template class T T * getInsetByCode(LCursor cur, InsetBase::Code code) { T * inset = 0; DocIterator it = cur; if (it.nextInset() it.nextInset()-lyxCode() == code) { inset = static_castT*(it.nextInset()); } return inset; } Jürgen
Re: [PATCH] Bug 961: reintroduce LFUN_BIBDB_ADD/DEL
Juergen Spitzmueller wrote: /// Get next inset of this class from current cursor position template class T T * getInsetByCode(LCursor cur, InsetBase::Code code) { T * inset = 0; DocIterator it = cur; if (it.nextInset() it.nextInset()-lyxCode() == code) { inset = static_castT*(it.nextInset()); } return inset; } Actually, this thing is so stupid that it stumbles over the next inset, no matter what kind. The attached patch fixes this and also starts from the beginning. What do you think? Jürgen Index: BufferView_pimpl.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.584 diff -u -r1.584 BufferView_pimpl.C --- BufferView_pimpl.C 31 May 2005 14:40:23 - 1.584 +++ BufferView_pimpl.C 3 Jun 2005 18:03:15 - @@ -51,6 +51,7 @@ #include undo.h #include vspace.h +#include insets/insetbibtex.h #include insets/insetref.h #include insets/insettext.h @@ -128,9 +129,20 @@ { T * inset = 0; DocIterator it = cur; - if (it.nextInset() - it.nextInset()-lyxCode() == code) { - inset = static_castT*(it.nextInset()); + T * first_inset = static_castT*(it.nextInset()); + while (it) { + if (!it.nextInset()) { + // try from the beginning, but break after one loop + it.pit() = 0; + it.pos() = 0; + if (!it.nextInset() || it.nextInset() == first_inset) +break; + } + if (it.nextInset()-lyxCode() == code) { + inset = static_castT*(it.nextInset()); + break; + } + it.forwardInset(); } return inset; } @@ -987,6 +999,8 @@ case LFUN_MARK_ON: case LFUN_SETMARK: case LFUN_CENTER: + case LFUN_BIBDB_ADD: + case LFUN_BIBDB_DEL: case LFUN_WORDS_COUNT: flag.enabled(true); break; @@ -1211,6 +1225,24 @@ case LFUN_CENTER: center(); break; + + case LFUN_BIBDB_ADD: { + InsetBibtex * inset = + getInsetByCodeInsetBibtex(cursor_, + InsetBase::BIBTEX_CODE); + if (inset) + inset-addDatabase(cmd.argument); + break; + } + + case LFUN_BIBDB_DEL: { + InsetBibtex * inset = + getInsetByCodeInsetBibtex(cursor_, + InsetBase::BIBTEX_CODE); + if (inset) + inset-delDatabase(cmd.argument); + break; + } case LFUN_WORDS_COUNT: { DocIterator from, to; Index: LyXAction.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v retrieving revision 1.206 diff -u -r1.206 LyXAction.C --- LyXAction.C 8 May 2005 10:02:37 - 1.206 +++ LyXAction.C 3 Jun 2005 18:03:17 - @@ -188,6 +188,8 @@ { LFUN_INSERT_LABEL, label-insert, Noop }, { LFUN_INSET_OPTARG, optional-insert, Noop }, { LFUN_INSERT_BIBITEM, bibitem-insert, Noop }, + { LFUN_BIBDB_ADD, bibtex-database-add, Noop }, + { LFUN_BIBDB_DEL, bibtex-database-del, Noop }, { LFUN_INSERT_LINE, line-insert, Noop }, { LFUN_INSERT_PAGEBREAK, pagebreak-insert, Noop }, { LFUN_LANGUAGE, language, Noop }, Index: lfuns.h === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lfuns.h,v retrieving revision 1.41 diff -u -r1.41 lfuns.h --- lfuns.h 8 May 2005 10:02:37 - 1.41 +++ lfuns.h 3 Jun 2005 18:03:19 - @@ -355,6 +355,8 @@ // 270 LFUN_WORDS_COUNT, LFUN_OUTPUT_CHANGES, // jspitzm 20050121 + LFUN_BIBDB_ADD, + LFUN_BIBDB_DEL, LFUN_LASTACTION // end of the table }; Index: insets/insetbibtex.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibtex.C,v retrieving revision 1.54 diff -u -r1.54 insetbibtex.C --- insets/insetbibtex.C 17 May 2005 11:11:45 - 1.54 +++ insets/insetbibtex.C 3 Jun 2005 18:03:24 - @@ -283,16 +283,17 @@ bool InsetBibtex::delDatabase(string const db) { - if (contains(getContents(), db)) { + string contents(getContents()); + if (contains(contents, db)) { + int const n = tokenPos(contents, ',', db); string bd = db; - int const n = tokenPos(getContents(), ',', bd); if (n 0) { - // Weird code, would someone care to explain this?(Lgb) - string tmp(, ); - tmp += bd; - setContents(subst(getContents(), tmp, , )); + // this is not the first database + string tmp = ',' + bd; + setContents(subst(contents, tmp, )); } else if (n == 0) - setContents(split(getContents(), bd, ',')); + // this is the first (or only) database + setContents(split(contents, bd, ',')); else return false; }
Re: [PATCH] Bug 961: reintroduce LFUN_BIBDB_ADD/DEL
Juergen Spitzmueller wrote: I'm not even sure I understand what LABEL_GOTO does (or is it broken?) OK, now I do. This is really odd. Jürgen
Re: [PATCH] Bug 961: reintroduce LFUN_BIBDB_ADD/DEL
Juergen Spitzmueller wrote: I'm not even sure I understand what LABEL_GOTO does (or is it broken?) OK, now I do. This is really odd. I think this menu entry is extremely irritating. How about the following patch, that does enable the entry only when it actually makes sense? Jürgen Index: BufferView_pimpl.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.584 diff -u -r1.584 BufferView_pimpl.C --- BufferView_pimpl.C 31 May 2005 14:40:23 - 1.584 +++ BufferView_pimpl.C 3 Jun 2005 19:08:13 - @@ -976,7 +976,6 @@ case LFUN_FONT_STATE: case LFUN_INSERT_LABEL: case LFUN_BOOKMARK_SAVE: - case LFUN_LABEL_GOTO: case LFUN_GOTO_PARAGRAPH: case LFUN_GOTOERROR: case LFUN_GOTONOTE: @@ -990,6 +989,16 @@ case LFUN_WORDS_COUNT: flag.enabled(true); break; + + case LFUN_LABEL_GOTO: { + if (cmd.argument.empty() + !getInsetByCodeInsetRef(cursor_, InsetBase::REF_CODE)) { +flag.enabled(false); +break; + } + flag.enabled(true); + break; + } case LFUN_BOOKMARK_GOTO: flag.enabled(isSavedPosition(convertunsigned int(cmd.argument)));
Re: LyX/Mac 1.3.6 - Keybindings
Bennett Helm wrote: > Something needs to change, and the question is what. Here are some > options (which I think go from less desirable to more desirable, other > things being equal): Perhaps the easiest solution (for 1.3.6) is to disable the QIMEvent stuff for Mac. For 1.4, I think we have to investigate further. Did the qt-immodule problem (bug 1830) occur on Mac or is qt/mac not patched with qt-immodule at all? Jürgen
Re: LyX/Mac 1.3.6 - Keybindings
Juergen Spitzmueller wrote: > Perhaps the easiest solution (for 1.3.6) is to disable the QIMEvent stuff > for Mac. For 1.4, I think we have to investigate further. > > Did the qt-immodule problem (bug 1830) occur on Mac or is qt/mac not > patched with qt-immodule at all? After some more investigation on the web, I think the safest is to enable it just for Q_WS_X11. It seems that the qt-immodule patches are only available for qt/x11 anyway. See attached. Agreed? Also for 1.4? Jürgen Index: QContentPane.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QContentPane.C,v retrieving revision 1.18.2.3 diff -u -r1.18.2.3 QContentPane.C --- QContentPane.C 28 May 2005 11:07:45 - 1.18.2.3 +++ QContentPane.C 3 Jun 2005 06:57:15 - @@ -96,10 +96,12 @@ setFocusPolicy(QWidget::WheelFocus); setFocus(); setCursor(ibeamCursor); +#ifdef Q_WS_X11 #if QT_VERSION >= 0x030200 // to make qt-immodule work setInputMethodEnabled(true); -#endif +#endif //QT_VERSION +#endif //Q_WS_X11 // stupid moc strikes again connect(wa_->scrollbar_, SIGNAL(valueChanged(int)), @@ -108,6 +110,7 @@ } +#ifdef Q_WS_X11 #if QT_VERSION >= 0x030200 // to make qt-immodule work void QContentPane::imStartEvent(QIMEvent *e) @@ -136,7 +139,8 @@ } e->accept(); } -#endif +#endif //QT_VERSION +#endif //Q_WS_X11 void QContentPane::scrollBarChanged(int val) Index: QContentPane.h === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QContentPane.h,v retrieving revision 1.7.2.3 diff -u -r1.7.2.3 QContentPane.h --- QContentPane.h 28 May 2005 11:07:45 - 1.7.2.3 +++ QContentPane.h 3 Jun 2005 06:57:15 - @@ -97,12 +97,14 @@ void wheelEvent(QWheelEvent * e); /// key press void keyPressEvent(QKeyEvent * e); +#ifdef Q_WS_X11 #if QT_VERSION >= 0x030200 /// IM events void imStartEvent(QIMEvent *); void imComposeEvent(QIMEvent *); void imEndEvent(QIMEvent *); -#endif +#endif //QT_VERSION +#endif //Q_WS_X11 public slots: void doubleClickTimeout();
Re: LyX/Mac 1.3.6 - Keybindings
> "Juergen" == Juergen Spitzmueller <[EMAIL PROTECTED]> writes: Juergen> Juergen Spitzmueller wrote: >> Perhaps the easiest solution (for 1.3.6) is to disable the QIMEvent >> stuff for Mac. For 1.4, I think we have to investigate further. >> >> Did the qt-immodule problem (bug 1830) occur on Mac or is qt/mac >> not patched with qt-immodule at all? Juergen> After some more investigation on the web, I think the safest Juergen> is to enable it just for Q_WS_X11. It seems that the Juergen> qt-immodule patches are only available for qt/x11 anyway. See Juergen> attached. It is definitely the best solution. About the tests, what about using #if defined(Q_WS_X11) && QT_VERSION >= 0x030200 You could also define a USE_INPUT_METHODS in QContentPane.h #if defined(Q_WS_X11) && QT_VERSION >= 0x030200 #define USE_INPUT_METHODS 1 #endif and use this later. The advantage is to make the meaning of the test clear. Juergen> Agreed? Also for 1.4? Yes. JMarc
Re: LyX/Mac 1.3.6 - Keybindings
Jean-Marc Lasgouttes wrote: > It is definitely the best solution. About the tests, what about using > #if defined(Q_WS_X11) && QT_VERSION >= 0x030200 OK. I was careful because I didn't know how these two tests can be mixed. Thanks. > You could also define a USE_INPUT_METHODS in QContentPane.h > #if defined(Q_WS_X11) && QT_VERSION >= 0x030200 > #define USE_INPUT_METHODS 1 > #endif > and use this later. The advantage is to make the meaning of the test > clear. Yes, this is semantically very clear. I'll use this and commit. Jürgen
Re: [PATCH] fix selection of error range through errorlist dialog
> "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes: Jean-Marc> The following patch fixes in the common cases the selection Jean-Marc> relevant document range when clicking on an entry of the Jean-Marc> errorlist dialog. There are still cases where this does not Jean-Marc> work at all, the worst being when the error is in a text Jean-Marc> inset. This would require more work (in particular passing Jean-Marc> the main TexRow object to the underlying textinset). Jean-Marc> I will commit tomorrow if nobody objects. Done. JMarc
Re: [Patch] Re: [patch] key event queue
Lars Gullik Bjønnes wrote: Martin Vermeer <[EMAIL PROTECTED]> writes: [...] | No, I meant that just the other way around. The fact that fast mouse | scrolling exists allows us to make keyboard scrolling slow... as your | event queue for ex. does. The slowness will drive people to use the | mouse for fast positioning within the document, which I again dislike. | (and about "surprising behaviour": only the first time. You get used to | it, and _like_ it, real fast. And it does no damage...) "I want to scroll down to next chapter beginning" how do you know when you get there? In that case, use "navigate" and select the chapter. No need for scrolling to a chapter heading (or any other structured heading.) Helge Hafting
[PATCH] Bug 961: reintroduce LFUN_BIBDB_ADD/DEL
http://bugzilla.lyx.org/show_bug.cgi?id=961 The attached patch reimplements those lfuns. It also fixes InsetBibtex::delDatabase, which is broken in 1.3. The only drawback is that the lfuns are not working when the cursor sits behind the inset. The same applies to 1.3. The reason is that getInsetByCode stops at the end of the document. OK to apply? Jürgen Index: BufferView_pimpl.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.584 diff -u -r1.584 BufferView_pimpl.C --- BufferView_pimpl.C 31 May 2005 14:40:23 - 1.584 +++ BufferView_pimpl.C 3 Jun 2005 13:14:31 - @@ -51,6 +51,7 @@ #include "undo.h" #include "vspace.h" +#include "insets/insetbibtex.h" #include "insets/insetref.h" #include "insets/insettext.h" @@ -987,6 +988,8 @@ case LFUN_MARK_ON: case LFUN_SETMARK: case LFUN_CENTER: + case LFUN_BIBDB_ADD: + case LFUN_BIBDB_DEL: case LFUN_WORDS_COUNT: flag.enabled(true); break; @@ -1211,6 +1214,24 @@ case LFUN_CENTER: center(); break; + + case LFUN_BIBDB_ADD: { + InsetBibtex * inset = + getInsetByCode(cursor_, + InsetBase::BIBTEX_CODE); + if (inset) + inset->addDatabase(cmd.argument); + break; + } + + case LFUN_BIBDB_DEL: { + InsetBibtex * inset = + getInsetByCode(cursor_, + InsetBase::BIBTEX_CODE); + if (inset) + inset->delDatabase(cmd.argument); + break; + } case LFUN_WORDS_COUNT: { DocIterator from, to; Index: LyXAction.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v retrieving revision 1.206 diff -u -r1.206 LyXAction.C --- LyXAction.C 8 May 2005 10:02:37 - 1.206 +++ LyXAction.C 3 Jun 2005 13:14:31 - @@ -188,6 +188,8 @@ { LFUN_INSERT_LABEL, "label-insert", Noop }, { LFUN_INSET_OPTARG, "optional-insert", Noop }, { LFUN_INSERT_BIBITEM, "bibitem-insert", Noop }, + { LFUN_BIBDB_ADD, "bibtex-database-add", Noop }, + { LFUN_BIBDB_DEL, "bibtex-database-del", Noop }, { LFUN_INSERT_LINE, "line-insert", Noop }, { LFUN_INSERT_PAGEBREAK, "pagebreak-insert", Noop }, { LFUN_LANGUAGE, "language", Noop }, Index: lfuns.h === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lfuns.h,v retrieving revision 1.41 diff -u -r1.41 lfuns.h --- lfuns.h 8 May 2005 10:02:37 - 1.41 +++ lfuns.h 3 Jun 2005 13:14:32 - @@ -355,6 +355,8 @@ // 270 LFUN_WORDS_COUNT, LFUN_OUTPUT_CHANGES, // jspitzm 20050121 + LFUN_BIBDB_ADD, + LFUN_BIBDB_DEL, LFUN_LASTACTION // end of the table }; Index: insets/insetbibtex.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibtex.C,v retrieving revision 1.54 diff -u -r1.54 insetbibtex.C --- insets/insetbibtex.C 17 May 2005 11:11:45 - 1.54 +++ insets/insetbibtex.C 3 Jun 2005 13:14:36 - @@ -283,16 +283,17 @@ bool InsetBibtex::delDatabase(string const & db) { - if (contains(getContents(), db)) { + string contents(getContents()); + if (contains(contents, db)) { + int const n = tokenPos(contents, ',', db); string bd = db; - int const n = tokenPos(getContents(), ',', bd); if (n > 0) { - // Weird code, would someone care to explain this?(Lgb) - string tmp(", "); - tmp += bd; - setContents(subst(getContents(), tmp, ", ")); + // this is not the first database + string tmp = ',' + bd; + setContents(subst(contents, tmp, "")); } else if (n == 0) - setContents(split(getContents(), bd, ',')); + // this is the first (or only) database + setContents(split(contents, bd, ',')); else return false; }
Re: [PATCH] Bug 961: reintroduce LFUN_BIBDB_ADD/DEL
> "Juergen" == Juergen Spitzmueller <[EMAIL PROTECTED]> writes: Juergen> The only drawback is that the lfuns are not working when the Juergen> cursor sits behind the inset. The same applies to 1.3. The Juergen> reason is that getInsetByCode stops at the end of the Juergen> document. Did you look at gotoInset in bufferview_funcs.[Ch]? JMarc
Re: [PATCH] Bug 961: reintroduce LFUN_BIBDB_ADD/DEL
Jean-Marc Lasgouttes wrote: > Did you look at gotoInset in bufferview_funcs.[Ch]? Yes, but I think this is not what I need here. gotoInset moves the cursor to the next inset, while LFUN_BIBDB_* needs the next bibtex inset, without moving the cursor. It would probably make more sense to use gotoInset in LFUN_LABEL_GOTO, which also uses getInsetByCode, but I'm not sure. Actually, I'm not even sure I understand what LABEL_GOTO does (or is it broken?) Do you have an idea how to make getInsetByCode loop (and stop if there is no inset in the document)? Here's the code: /// Get next inset of this class from current cursor position template T * getInsetByCode(LCursor & cur, InsetBase::Code code) { T * inset = 0; DocIterator it = cur; if (it.nextInset() && it.nextInset()->lyxCode() == code) { inset = static_cast(it.nextInset()); } return inset; } Jürgen
Re: [PATCH] Bug 961: reintroduce LFUN_BIBDB_ADD/DEL
Juergen Spitzmueller wrote: > /// Get next inset of this class from current cursor position > template > T * getInsetByCode(LCursor & cur, InsetBase::Code code) > { > T * inset = 0; > DocIterator it = cur; > if (it.nextInset() && > it.nextInset()->lyxCode() == code) { > inset = static_cast(it.nextInset()); > } > return inset; > } Actually, this thing is so stupid that it stumbles over the next inset, no matter what kind. The attached patch fixes this and also starts from the beginning. What do you think? Jürgen Index: BufferView_pimpl.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.584 diff -u -r1.584 BufferView_pimpl.C --- BufferView_pimpl.C 31 May 2005 14:40:23 - 1.584 +++ BufferView_pimpl.C 3 Jun 2005 18:03:15 - @@ -51,6 +51,7 @@ #include "undo.h" #include "vspace.h" +#include "insets/insetbibtex.h" #include "insets/insetref.h" #include "insets/insettext.h" @@ -128,9 +129,20 @@ { T * inset = 0; DocIterator it = cur; - if (it.nextInset() && - it.nextInset()->lyxCode() == code) { - inset = static_cast (it.nextInset()); + T * first_inset = static_cast (it.nextInset()); + while (it) { + if (!it.nextInset()) { + // try from the beginning, but break after one loop + it.pit() = 0; + it.pos() = 0; + if (!it.nextInset() || it.nextInset() == first_inset) +break; + } + if (it.nextInset()->lyxCode() == code) { + inset = static_cast (it.nextInset()); + break; + } + it.forwardInset(); } return inset; } @@ -987,6 +999,8 @@ case LFUN_MARK_ON: case LFUN_SETMARK: case LFUN_CENTER: + case LFUN_BIBDB_ADD: + case LFUN_BIBDB_DEL: case LFUN_WORDS_COUNT: flag.enabled(true); break; @@ -1211,6 +1225,24 @@ case LFUN_CENTER: center(); break; + + case LFUN_BIBDB_ADD: { + InsetBibtex * inset = + getInsetByCode(cursor_, + InsetBase::BIBTEX_CODE); + if (inset) + inset->addDatabase(cmd.argument); + break; + } + + case LFUN_BIBDB_DEL: { + InsetBibtex * inset = + getInsetByCode(cursor_, + InsetBase::BIBTEX_CODE); + if (inset) + inset->delDatabase(cmd.argument); + break; + } case LFUN_WORDS_COUNT: { DocIterator from, to; Index: LyXAction.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v retrieving revision 1.206 diff -u -r1.206 LyXAction.C --- LyXAction.C 8 May 2005 10:02:37 - 1.206 +++ LyXAction.C 3 Jun 2005 18:03:17 - @@ -188,6 +188,8 @@ { LFUN_INSERT_LABEL, "label-insert", Noop }, { LFUN_INSET_OPTARG, "optional-insert", Noop }, { LFUN_INSERT_BIBITEM, "bibitem-insert", Noop }, + { LFUN_BIBDB_ADD, "bibtex-database-add", Noop }, + { LFUN_BIBDB_DEL, "bibtex-database-del", Noop }, { LFUN_INSERT_LINE, "line-insert", Noop }, { LFUN_INSERT_PAGEBREAK, "pagebreak-insert", Noop }, { LFUN_LANGUAGE, "language", Noop }, Index: lfuns.h === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lfuns.h,v retrieving revision 1.41 diff -u -r1.41 lfuns.h --- lfuns.h 8 May 2005 10:02:37 - 1.41 +++ lfuns.h 3 Jun 2005 18:03:19 - @@ -355,6 +355,8 @@ // 270 LFUN_WORDS_COUNT, LFUN_OUTPUT_CHANGES, // jspitzm 20050121 + LFUN_BIBDB_ADD, + LFUN_BIBDB_DEL, LFUN_LASTACTION // end of the table }; Index: insets/insetbibtex.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibtex.C,v retrieving revision 1.54 diff -u -r1.54 insetbibtex.C --- insets/insetbibtex.C 17 May 2005 11:11:45 - 1.54 +++ insets/insetbibtex.C 3 Jun 2005 18:03:24 - @@ -283,16 +283,17 @@ bool InsetBibtex::delDatabase(string const & db) { - if (contains(getContents(), db)) { + string contents(getContents()); + if (contains(contents, db)) { + int const n = tokenPos(contents, ',', db); string bd = db; - int const n = tokenPos(getContents(), ',', bd); if (n > 0) { - // Weird code, would someone care to explain this?(Lgb) - string tmp(", "); - tmp += bd; - setContents(subst(getContents(), tmp, ", ")); + // this is not the first database + string tmp = ',' + bd; + setContents(subst(contents, tmp, "")); } else if (n == 0) - setContents(split(getContents(), bd, ',')); + // this is the first (or only) database + setContents(split(contents, bd, ',')); else return false; }
Re: [PATCH] Bug 961: reintroduce LFUN_BIBDB_ADD/DEL
Juergen Spitzmueller wrote: > I'm not even sure I understand what LABEL_GOTO does (or is it broken?) OK, now I do. This is really odd. Jürgen
Re: [PATCH] Bug 961: reintroduce LFUN_BIBDB_ADD/DEL
Juergen Spitzmueller wrote: > > I'm not even sure I understand what LABEL_GOTO does (or is it broken?) > > OK, now I do. This is really odd. I think this menu entry is extremely irritating. How about the following patch, that does enable the entry only when it actually makes sense? Jürgen Index: BufferView_pimpl.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.584 diff -u -r1.584 BufferView_pimpl.C --- BufferView_pimpl.C 31 May 2005 14:40:23 - 1.584 +++ BufferView_pimpl.C 3 Jun 2005 19:08:13 - @@ -976,7 +976,6 @@ case LFUN_FONT_STATE: case LFUN_INSERT_LABEL: case LFUN_BOOKMARK_SAVE: - case LFUN_LABEL_GOTO: case LFUN_GOTO_PARAGRAPH: case LFUN_GOTOERROR: case LFUN_GOTONOTE: @@ -990,6 +989,16 @@ case LFUN_WORDS_COUNT: flag.enabled(true); break; + + case LFUN_LABEL_GOTO: { + if (cmd.argument.empty() + && !getInsetByCode(cursor_, InsetBase::REF_CODE)) { +flag.enabled(false); +break; + } + flag.enabled(true); + break; + } case LFUN_BOOKMARK_GOTO: flag.enabled(isSavedPosition(convert(cmd.argument)));