From 0b8aac3f51192831f567670b128cc176570276e4 Mon Sep 17 00:00:00 2001 From: John Levon Date: Sat, 20 Jul 2002 17:27:03 +0000 Subject: [PATCH] fix dispatch calls as suggested by Herbert git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4725 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 8 ++++ src/LaTeX.C | 14 +++--- src/frontends/controllers/ChangeLog | 4 ++ src/frontends/controllers/ControlRef.C | 4 +- src/frontends/xforms/ChangeLog | 5 +++ src/frontends/xforms/FormMathsDelim.C | 3 +- src/frontends/xforms/FormMathsMatrix.C | 3 +- src/frontends/xforms/XMiniBuffer.C | 59 +++++++++----------------- src/frontends/xforms/XMiniBuffer.h | 14 +++--- src/lyxfunc.C | 4 +- src/paragraph_pimpl.C | 2 +- 11 files changed, 56 insertions(+), 64 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 88a4cf7a93..04558c167e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2002-07-20 John Levon + + * paragraph_pimpl.C: constify + + * BufferView_pimpl.C: + * LaTeX.C: + * lyxfunc.C: fix dispatch in a nicer way + 2002-07-20 Jean-Marc Lasgouttes * version.C.in: update lyx_docversion diff --git a/src/LaTeX.C b/src/LaTeX.C index 664486e801..b1817790ea 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -197,8 +197,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) if (lfun) { ostringstream str; str << _("LaTeX run number") << ' ' << count; - // check lyxstring string stream and gcc 3.1 before fixing - lfun->dispatch(LFUN_MESSAGE, string(str.str().c_str())); + lfun->dispatch(LFUN_MESSAGE, str.str().c_str(), false); } this->operator()(); @@ -234,7 +233,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) // no checks for now lyxerr[Debug::LATEX] << "Running MakeIndex." << endl; if (lfun) { - lfun->dispatch(LFUN_MESSAGE, string(_("Running MakeIndex."))); + lfun->dispatch(LFUN_MESSAGE, _("Running MakeIndex."), false); } rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx"))); @@ -249,7 +248,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) // no checks for now lyxerr[Debug::LATEX] << "Running BibTeX." << endl; if (lfun) { - lfun->dispatch(LFUN_MESSAGE, string(_("Running BibTeX."))); + lfun->dispatch(LFUN_MESSAGE, _("Running BibTeX."), false); } updateBibtexDependencies(head, bibtex_info); @@ -284,7 +283,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) ostringstream str; str << _("LaTeX run number") << ' ' << count; // check lyxstring string stream and gcc 3.1 before fixing - lfun->dispatch(LFUN_MESSAGE, string(str.str().c_str())); + lfun->dispatch(LFUN_MESSAGE, str.str().c_str(), false); } this->operator()(); @@ -314,7 +313,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) // no checks for now lyxerr[Debug::LATEX] << "Running MakeIndex." << endl; if (lfun) { - lfun->dispatch(LFUN_MESSAGE, string(_("Running MakeIndex."))); + lfun->dispatch(LFUN_MESSAGE, _("Running MakeIndex."), false); } rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx"))); @@ -340,8 +339,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) if (lfun) { ostringstream str; str << _("LaTeX run number") << ' ' << count; - // check lyxstring string stream and gcc 3.1 before fixing - lfun->dispatch(LFUN_MESSAGE, string(str.str().c_str())); + lfun->dispatch(LFUN_MESSAGE, str.str().c_str(), false); } this->operator()(); diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 2b62ad73a0..2531e10007 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,7 @@ +2002-07-20 John Levon + + * ControlRef.C: fix dispatch call nicely + 2002-07-19 John Levon * Makefile.am: diff --git a/src/frontends/controllers/ControlRef.C b/src/frontends/controllers/ControlRef.C index 6c0f6a604b..5e1ea07ef4 100644 --- a/src/frontends/controllers/ControlRef.C +++ b/src/frontends/controllers/ControlRef.C @@ -44,14 +44,14 @@ vector const ControlRef::getLabelList(string const & name) const void ControlRef::gotoRef(string const & ref) const { - lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_SAVE, string("0")); + lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_SAVE, "0", false); lv_.getLyXFunc()->dispatch(LFUN_REF_GOTO, ref); } void ControlRef::gotoBookmark() const { - lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_GOTO, string("0")); + lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_GOTO, "0", false); } diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index f97cb60f12..2c93c21f51 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2002-07-20 John Levon + + * FormMathsDelim.C: + * FormMathsMatrix.C: fix dispatch calls nicely + 2002-07-20 Jean-Marc Lasgouttes * Menubar_pimpl.C (add_toc): avoid crash when there is no document diff --git a/src/frontends/xforms/FormMathsDelim.C b/src/frontends/xforms/FormMathsDelim.C index 6908337cd3..1b5531f44d 100644 --- a/src/frontends/xforms/FormMathsDelim.C +++ b/src/frontends/xforms/FormMathsDelim.C @@ -91,8 +91,7 @@ void FormMathsDelim::apply() ostringstream ost; ost << delim_values[left] << ' ' << delim_values[right]; - // the unusual formulation here is necessary for lyxstring stringstream - lv_->getLyXFunc()->dispatch(LFUN_MATH_DELIM, string(ost.str().c_str())); + lv_->getLyXFunc()->dispatch(LFUN_MATH_DELIM, ost.str().c_str(), false); } bool FormMathsDelim::input(FL_OBJECT *, long) diff --git a/src/frontends/xforms/FormMathsMatrix.C b/src/frontends/xforms/FormMathsMatrix.C index 05c9b92466..6e2f650050 100644 --- a/src/frontends/xforms/FormMathsMatrix.C +++ b/src/frontends/xforms/FormMathsMatrix.C @@ -99,8 +99,7 @@ void FormMathsMatrix::apply() ostringstream ost; ost << nx << ' ' << ny << ' ' << c << ' ' << sh; - // remeber gcc 3.1 and lyxstring stringstream before "fixing" - lv_->getLyXFunc()->dispatch(LFUN_INSERT_MATRIX, string(ost.str().c_str())); + lv_->getLyXFunc()->dispatch(LFUN_INSERT_MATRIX, ost.str().c_str(), false); } bool FormMathsMatrix::input(FL_OBJECT * ob, long) diff --git a/src/frontends/xforms/XMiniBuffer.C b/src/frontends/xforms/XMiniBuffer.C index e9e1f4f4dc..0cdfd349ed 100644 --- a/src/frontends/xforms/XMiniBuffer.C +++ b/src/frontends/xforms/XMiniBuffer.C @@ -39,12 +39,12 @@ using std::vector; XMiniBuffer::XMiniBuffer(XFormsView * v, ControlCommandBuffer & control, FL_Coord x, FL_Coord y, FL_Coord h, FL_Coord w) : controller_(control), view_(v), - info_suffix_shown_(false) + info_shown_(false) { input_obj_ = create_input_box(FL_NORMAL_INPUT, x, y, h, w); - suffix_timer_.reset(new Timeout(1500)); + info_timer_.reset(new Timeout(1500)); idle_timer_.reset(new Timeout(6000)); - suffix_timer_->timeout.connect(boost::bind(&XMiniBuffer::suffix_timeout, this)); + info_timer_->timeout.connect(boost::bind(&XMiniBuffer::info_timeout, this)); idle_timer_->timeout.connect(boost::bind(&XMiniBuffer::idle_timeout, this)); idle_timer_->start(); messageMode(); @@ -68,12 +68,6 @@ XMiniBuffer::~XMiniBuffer() int XMiniBuffer::peek_event(FL_OBJECT * ob, int event, int key, XEvent * /*xev*/) { -#if 0 - if (dropdown_->isVisible()) { - return dropdown_->peek(xev); - } -#endif - switch (event) { case FL_FOCUS: messageMode(false); @@ -84,9 +78,9 @@ int XMiniBuffer::peek_event(FL_OBJECT * ob, int event, case FL_KEYBOARD: { string input; - if (info_suffix_shown_) { - suffix_timer_->stop(); - suffix_timeout(); + if (info_shown_) { + info_timer_->stop(); + info_timeout(); } char const * tmp = fl_get_input(ob); @@ -100,7 +94,7 @@ int XMiniBuffer::peek_event(FL_OBJECT * ob, int event, { string const h(controller_.historyDown()); if (h.empty()) { - show_info_suffix(_("[End of history]"), input); + show_info(_("[End of history]"), input, false); } else { set_input(h); } @@ -114,7 +108,7 @@ int XMiniBuffer::peek_event(FL_OBJECT * ob, int event, { string const h(controller_.historyUp()); if (h.empty()) { - show_info_suffix(_("[Beginning of history]"), input); + show_info(_("[Beginning of history]"), input, false); } else { set_input(h); } @@ -128,13 +122,13 @@ int XMiniBuffer::peek_event(FL_OBJECT * ob, int event, vector comp = controller_.completions(input, new_input); if (comp.empty() && new_input == input) { - show_info_suffix(_("[no match]"), input); + show_info(_("[no match]"), input); break; } if (comp.empty()) { set_input(new_input); - show_info_suffix(("[only completion]"), new_input + " "); + show_info(("[only completion]"), new_input + " "); break; } @@ -162,27 +156,9 @@ int XMiniBuffer::peek_event(FL_OBJECT * ob, int event, case XK_KP_Enter: #endif { -#if 0 - // This will go in again in a little while - // we need to be able to declare what types - // of argumetns LFUN's should have first. (Lgb) - // First check for match - vector::const_iterator cit = - find(completion_.begin(), - completion_.end(), - input); - if (cit == completion_.end()) { - // no such func/item - string const tmp = input + _(" [no match]"); - show_info_suffix(tmp, input); - } else { -#endif messageMode(); redraw(); controller_.dispatch(input); -# if 0 - } -#endif return 1; } default: @@ -240,12 +216,15 @@ void XMiniBuffer::freeze() } -void XMiniBuffer::show_info_suffix(string const & suffix, string const & input) +void XMiniBuffer::show_info(string const & info, string const & input, bool append) { stored_input_ = input; - info_suffix_shown_ = true; - set_input(input + " " + suffix); - suffix_timer_->start(); + info_shown_ = true; + if (append) + set_input(input + " " + info); + else + set_input(info); + info_timer_->start(); } @@ -255,9 +234,9 @@ void XMiniBuffer::idle_timeout() } -void XMiniBuffer::suffix_timeout() +void XMiniBuffer::info_timeout() { - info_suffix_shown_ = false; + info_shown_ = false; set_input(stored_input_); } diff --git a/src/frontends/xforms/XMiniBuffer.h b/src/frontends/xforms/XMiniBuffer.h index f48ada3a0c..0388b6f5f4 100644 --- a/src/frontends/xforms/XMiniBuffer.h +++ b/src/frontends/xforms/XMiniBuffer.h @@ -55,7 +55,7 @@ protected: bool isEditingMode() const; /// reset buffer to stored input text - void suffix_timeout(); + void info_timeout(); /// go back to "at rest" message void idle_timeout(); @@ -79,13 +79,13 @@ protected: void messageMode(bool on = true); /// show a temporary message whilst in edit mode - void show_info_suffix(string const & suffix, string const & input); + void show_info(string const & info, string const & input, bool append = true); /// the dropdown menu boost::scoped_ptr dropdown_; - /// info suffix timer - boost::scoped_ptr suffix_timer_; + /// info timer + boost::scoped_ptr info_timer_; /// idle timer boost::scoped_ptr idle_timer_; @@ -102,11 +102,11 @@ protected: /// the lyx view XFormsView * view_; - /// stored input when showing suffix info + /// stored input when showing info string stored_input_; - /// are we showing an informational suffix of the mesage ? - bool info_suffix_shown_; + /// are we showing an informational temporary message ? + bool info_shown_; }; #endif // XMINIBUFFER_H diff --git a/src/lyxfunc.C b/src/lyxfunc.C index e658408d1a..c4cc777372 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1363,10 +1363,10 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose) // passthrough hat and underscore outside mathed: case LFUN_SUBSCRIPT: - dispatch(LFUN_SELFINSERT, string("_")); + dispatch(LFUN_SELFINSERT, "_", false); break; case LFUN_SUPERSCRIPT: - dispatch(LFUN_SELFINSERT, string("^")); + dispatch(LFUN_SELFINSERT, "^", false); break; case LFUN_MATH_PANEL: diff --git a/src/paragraph_pimpl.C b/src/paragraph_pimpl.C index 0126b79e2e..45c81b9736 100644 --- a/src/paragraph_pimpl.C +++ b/src/paragraph_pimpl.C @@ -55,7 +55,7 @@ special_phrase special_phrases[] = { { "LaTeX", "\\LaTeX{}", true }, }; -size_t phrases_nr = sizeof(special_phrases)/sizeof(special_phrase); +size_t const phrases_nr = sizeof(special_phrases)/sizeof(special_phrase); } // namespace anon