On Thu, Dec 06, 2001 at 12:25:37AM +0100, Lars Gullik Bjønnes wrote: > I have applied all the patches that I currently had a tab on, so if > anyone have patches ready that they want reviewed/applied; > please resend.
attached. If you still have an issue with the X selection thing, tell me what ;) The rest are all bugfixes that work fine for me. There is also my inset error patch that I'd like someone to look at - they need fixing ... thanks john -- "Faced with the prospect of rereading this book, I would rather have my brains ripped out by a plastic fork." - Charles Cooper on "Business at the Speed of Thought"
Index: src/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.429 diff -u -r1.429 ChangeLog --- src/ChangeLog 2001/12/03 13:17:01 1.429 +++ src/ChangeLog 2001/12/04 02:22:14 @@ -1,3 +1,9 @@ +2001-12-04 John Levon <[EMAIL PROTECTED]> + + * lyx_cb.h: + * lyx_cb.C: + * lyx_main.C: better behaviour on SIGINT + 2001-12-03 Juergen Vigna <[EMAIL PROTECTED]> * text.C (rowLast): simplified code Index: src/lyx_cb.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_cb.C,v retrieving revision 1.162 diff -u -r1.162 lyx_cb.C --- src/lyx_cb.C 2001/11/26 10:19:49 1.162 +++ src/lyx_cb.C 2001/12/04 02:22:18 @@ -277,13 +277,13 @@ } -void QuitLyX() +bool QuitLyX() { lyxerr[Debug::INFO] << "Running QuitLyX." << endl; if (lyxrc.use_gui) { if (!bufferlist.qwriteAll()) - return; + return false; lastfiles->writeFile(lyxrc.lastfiles); } @@ -301,8 +301,9 @@ DestroyLyXTmpDir(system_tempdir); finished = true; -} + return true; +} void AutoSave(BufferView * bv) Index: src/lyx_cb.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_cb.h,v retrieving revision 1.24 diff -u -r1.24 lyx_cb.h --- src/lyx_cb.h 2001/11/07 11:39:57 1.24 +++ src/lyx_cb.h 2001/12/04 02:22:18 @@ -22,8 +22,8 @@ string const & filename = string()); /// int MenuRunChktex(Buffer * buffer); -/// -void QuitLyX(); +/// returns false if the user cancelled +bool QuitLyX(); /// void AutoSave(BufferView * bv); /// Index: src/lyx_main.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_main.C,v retrieving revision 1.97 diff -u -r1.97 lyx_main.C --- src/lyx_main.C 2001/11/26 10:19:49 1.97 +++ src/lyx_main.C 2001/12/04 02:30:28 @@ -20,6 +20,7 @@ #include <version.h> #include "lyx_main.h" #include "lyx_gui.h" +#include "lyx_cb.h" #include "LyXView.h" #include "lyxfunc.h" #include "frontends/Alert.h" @@ -52,7 +53,6 @@ #endif extern void LoadLyXFile(string const &); -extern void QuitLyX(); string system_lyxdir; string build_lyxdir; @@ -75,6 +75,11 @@ boost::scoped_ptr<kb_keymap> toplevel_keymap; +namespace { + /// have we quit from a SIGINT ? + bool from_sig_int; +}; // anon + LyX::LyX(int * argc, char * argv[]) { // Prevent crash with --help @@ -173,8 +178,23 @@ // fall through... } - // Let the ball begin... - lyxGUI->runTime(); + bool really_quit = false; + + while (!really_quit) { + // main event loop + lyxGUI->runTime(); + + // if we have tried to quit via a SIGINT, + // we might not yet have saved etc. + if (from_sig_int) { + from_sig_int = false; + really_quit = QuitLyX(); + finished = really_quit; + GUIRunTime::processEvents(); + } else { + really_quit = true; + } + } } @@ -196,8 +216,12 @@ lyxerr << "\nlyx: SIGHUP signal caught" << endl; break; case SIGINT: - // no comments - break; + // a perfectly fine signal to be sent by a user + // do what they request + // see the end of LyX::LyX() + from_sig_int = true; + finished = true; + return; case SIGFPE: lyxerr << "\nlyx: SIGFPE signal caught" << endl; break;
Index: src/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.436 diff -u -r1.436 ChangeLog --- src/ChangeLog 2001/12/05 15:34:41 1.436 +++ src/ChangeLog 2001/12/05 18:05:25 @@ -1,3 +1,7 @@ +2001-12-05 John Levon <[EMAIL PROTECTED]> + + * BufferView_pimpl.C: fix insertAscii for insets + 2001-12-05 Juergen Vigna <[EMAIL PROTECTED]> * CutAndPaste.C (pasteSelection): remove not allowed insets/chars and Index: src/BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.181 diff -u -r1.181 BufferView_pimpl.C --- src/BufferView_pimpl.C 2001/12/05 08:04:13 1.181 +++ src/BufferView_pimpl.C 2001/12/05 18:05:32 @@ -1347,9 +1369,9 @@ if (clip.empty()) return; if (asPara) { - bv_->text->insertStringAsParagraphs(bv_, clip); + bv_->getLyXText()->insertStringAsParagraphs(bv_, clip); } else { - bv_->text->insertStringAsLines(bv_, clip); + bv_->getLyXText()->insertStringAsLines(bv_, clip); } update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); }
Index: BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.175 diff -u -r1.175 BufferView_pimpl.C --- BufferView_pimpl.C 2001/11/26 10:19:46 1.175 +++ BufferView_pimpl.C 2001/11/26 20:37:07 @@ -144,6 +144,8 @@ .connect(slot(this, &BufferView::Pimpl::tripleClick)); workarea_.workAreaKeyPress .connect(slot(this, &BufferView::Pimpl::workAreaKeyPress)); + workarea_.selectionRequested + .connect(slot(this, &BufferView::Pimpl::selectionRequested)); cursor_timeout.timeout.connect(slot(this, &BufferView::Pimpl::cursorToggle)); @@ -719,6 +721,15 @@ } +void BufferView::Pimpl::selectionRequested() +{ + string const sel(bv_->getLyXText()->selectionAsString(bv_->buffer(), false)); + if (!sel.empty()) { + workarea_.putClipboard(sel); + } +} + + void BufferView::Pimpl::enterView() { if (active() && available()) { @@ -763,6 +774,11 @@ if (button == 2) return; + // finish selection + if (button == 1) { + workarea_.haveSelection(bv_->getLyXText()->selection.set()); + } + setState(); owner_->showState(); Index: BufferView_pimpl.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.h,v retrieving revision 1.39 diff -u -r1.39 BufferView_pimpl.h --- BufferView_pimpl.h 2001/08/02 14:55:00 1.39 +++ BufferView_pimpl.h 2001/11/26 20:37:07 @@ -74,6 +74,8 @@ /// void tripleClick(int x, int y, unsigned int button); /// + void selectionRequested(); + /// void enterView(); /// void leaveView(); Index: ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.404 diff -u -r1.404 ChangeLog --- ChangeLog 2001/11/26 14:59:54 1.404 +++ ChangeLog 2001/11/26 20:37:19 @@ -1,3 +1,12 @@ +2001-11-26 John Levon <[EMAIL PROTECTED]> + + * BufferView_pimpl.h: + * BufferView_pimpl.C: + * WorkArea.h: + * WorkArea.C: + * text2.C: tell X when we have made a selection + for copying + 2001-11-23 John Levon <[EMAIL PROTECTED]> * <various>: change to use Alert.h diff -u -r1.54 WorkArea.C --- WorkArea.C 2001/11/09 13:44:42 1.54 +++ WorkArea.C 2001/11/26 20:37:26 @@ -28,6 +28,10 @@ #include "lyxlookup.h" #endif +// xforms doesn't define this (but it should be in <forms.h>). +extern "C" +FL_APPEVENT_CB fl_set_preemptive_callback(Window, FL_APPEVENT_CB, void *); + using std::endl; FL_OBJECT * figinset_canvas; @@ -64,6 +68,13 @@ return WorkArea::work_area_handler(ob, event, 0, 0, key, xev); } + + static + int C_WorkAreaEventCB(FL_FORM * form, void * xev) { + WorkArea * wa=static_cast<WorkArea*>(form->u_vdata); + wa->event_cb(static_cast<XEvent*>(xev)); + return 0; + } } @@ -172,6 +183,10 @@ fl_set_object_resize(obj, FL_RESIZE_ALL); fl_set_object_gravity(obj, NorthWestGravity, SouthEastGravity); + /// X selection hook - xforms gets it wrong + fl_current_form->u_vdata = this; + fl_register_raw_callback(fl_current_form, FL_ALL_EVENT, C_WorkAreaEventCB); + fl_unfreeze_all_forms(); } @@ -563,6 +574,27 @@ } // namespace anon +void WorkArea::event_cb(XEvent * xev) +{ + if (xev->type != SelectionRequest) + return; + + selectionRequested.emit(); + return; +} + + +void WorkArea::haveSelection(bool yes) const +{ + if (!yes) { + XSetSelectionOwner(fl_get_display(), XA_PRIMARY, None, CurrentTime); + return; + } + + XSetSelectionOwner(fl_get_display(), XA_PRIMARY, FL_ObjWin(work_area), +CurrentTime); +} + + string const WorkArea::getClipboard() const { clipboard_read = false; Index: WorkArea.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/WorkArea.h,v retrieving revision 1.26 diff -u -r1.26 WorkArea.h --- WorkArea.h 2001/10/02 16:00:54 1.26 +++ WorkArea.h 2001/11/26 20:37:26 @@ -95,6 +97,8 @@ int /*key*/, void * xev); /// xforms callback static void scroll_cb(FL_OBJECT *, long); + /// a selection exists + void haveSelection(bool) const; /// string const getClipboard() const; /// @@ -124,9 +128,15 @@ SigC::Signal3<void, int, int, unsigned int> workAreaDoubleClick; /// SigC::Signal3<void, int, int, unsigned int> workAreaTripleClick; + /// emitted when an X client has requested our selection + SigC::Signal0<void> selectionRequested; + + /// handles SelectionRequest X Event, to fill the clipboard + void WorkArea::event_cb(XEvent * xev); private: /// void createPixmap(int, int); + /// FL_OBJECT * backgroundbox; /// diff -u -r1.176 text2.C --- text2.C 2001/11/23 10:16:01 1.176 +++ text2.C 2001/11/26 20:38:38 @@ -1789,14 +1789,7 @@ void LyXText::copySelection(BufferView * bview) { - // Stuff what we got on the clipboard. Even if there is no selection. - - // There is a problem with having the stuffing here in that the - // larger the selection the slower LyX will get. This can be - // solved by running the line below only when the selection has - // finished. The solution used currently just works, to make it - // faster we need to be more clever and probably also have more - // calls to stuffClipboard. (Lgb) + // stuff the selection onto the X clipboard, from an explicit copy request bview->stuffClipboard(selectionAsString(bview->buffer(), true)); // this doesnt make sense, if there is no selection
Index: src/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.429 diff -u -r1.429 ChangeLog --- src/ChangeLog 2001/12/03 13:17:01 1.429 +++ src/ChangeLog 2001/12/03 16:23:23 @@ -1,3 +1,8 @@ +2001-12-03 John Levon <[EMAIL PROTECTED]> + + * kbsequence.h: + * kbsequence.C: re-instate nmodifier mask + 2001-12-03 Juergen Vigna <[EMAIL PROTECTED]> * text.C (rowLast): simplified code Index: src/kbsequence.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/kbsequence.h,v retrieving revision 1.7 diff -u -r1.7 kbsequence.h --- src/kbsequence.h 2001/11/30 13:25:35 1.7 +++ src/kbsequence.h 2001/12/03 16:23:23 @@ -34,9 +34,10 @@ * Add a key to the key sequence and look it up in the curmap * if the latter is defined. * @param mod modifier mask + * @param nmod which modifiers to mask out for equality test * @return the action matching this key sequence or LFUN_UNKNOWN_ACTION */ - kb_action addkey(unsigned int key, unsigned int mod); + kb_action addkey(unsigned int key, unsigned int mod, unsigned int nmod = 0); /** * Add a sequence of keys from a string to the sequence Index: src/kbsequence.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/kbsequence.C,v retrieving revision 1.18 diff -u -r1.18 kbsequence.C --- src/kbsequence.C 2001/11/30 13:25:35 1.18 +++ src/kbsequence.C 2001/12/03 16:23:23 @@ -29,7 +29,7 @@ enum { ModsMask = ShiftMask | ControlMask | Mod1Mask }; -kb_action kb_sequence::addkey(unsigned int key, unsigned int mod) +kb_action kb_sequence::addkey(unsigned int key, unsigned int mod, unsigned int nmod) { // adding a key to a deleted sequence // starts a new sequence @@ -40,7 +40,7 @@ modifiers.clear(); } - modifiers.push_back(mod); + modifiers.push_back(mod + (nmod << 16)); sequence.push_back(key); ++length_; @@ -58,6 +58,7 @@ string::size_type i = 0; unsigned int mod = 0; + unsigned int nmod = 0; while (i < s.length()) { if (s[i] == ' ') ++i; @@ -85,12 +86,15 @@ && s[i + 2] == '-') { switch (s[i + 1]) { case 's': case 'S': + nmod |= ShiftMask; i += 3; continue; case 'c': case 'C': + nmod |= ControlMask; i += 3; continue; case 'm': case 'M': + nmod |= Mod1Mask; i += 3; continue; default: @@ -111,7 +115,7 @@ } i = j; - addkey(key, mod); + addkey(key, mod, nmod); mod = 0; } } @@ -149,7 +153,7 @@ string buf; buf += print(); - + if (!curmap) return buf;
Index: src/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.427 diff -u -r1.427 ChangeLog --- src/ChangeLog 2001/12/02 16:39:56 1.427 +++ src/ChangeLog 2001/12/02 18:24:47 @@ -1,3 +1,7 @@ +2001-12-02 John Levon <[EMAIL PROTECTED]> + + * lyxfunc.C: disable FONT_EMPH etc. in mathed + 2001-12-02 Lars Gullik Bjønnes <[EMAIL PROTECTED]> * vspace.[Ch] (operator!=): add operator. @@ -102,7 +106,7 @@ * paragraph_pimpl.h: * paragraph_pimpl.C: tidy, and fix font-change in "LaTeX" bug a bit - + 2001-11-26 John Levon <[EMAIL PROTECTED]> * text.C: Index: src/lyxfunc.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v retrieving revision 1.268 diff -u -r1.268 lyxfunc.C --- src/lyxfunc.C 2001/11/30 13:25:35 1.268 +++ src/lyxfunc.C 2001/12/02 18:24:50 @@ -704,14 +704,20 @@ case LFUN_EMPH: if (font.emph() == LyXFont::ON) box = func_status::ToggleOn; + if (mathcursor) + box = func_status::Disabled; break; case LFUN_NOUN: if (font.noun() == LyXFont::ON) box = func_status::ToggleOn; + if (mathcursor) + box = func_status::Disabled; break; case LFUN_BOLD: if (font.series() == LyXFont::BOLD_SERIES) box = func_status::ToggleOn; + if (mathcursor) + box = func_status::Disabled; break; case LFUN_READ_ONLY_TOGGLE: if (buf->isReadonly())