fix dispatch calls as suggested by Herbert

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4725 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-07-20 17:27:03 +00:00
parent 3d5734b98f
commit 0b8aac3f51
11 changed files with 56 additions and 64 deletions

View File

@ -1,3 +1,11 @@
2002-07-20 John Levon <moz@compsoc.man.ac.uk>
* paragraph_pimpl.C: constify
* BufferView_pimpl.C:
* LaTeX.C:
* lyxfunc.C: fix dispatch in a nicer way
2002-07-20 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* version.C.in: update lyx_docversion

View File

@ -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()();

View File

@ -1,3 +1,7 @@
2002-07-20 John Levon <moz@compsoc.man.ac.uk>
* ControlRef.C: fix dispatch call nicely
2002-07-19 John Levon <moz@compsoc.man.ac.uk>
* Makefile.am:

View File

@ -44,14 +44,14 @@ vector<string> 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);
}

View File

@ -1,3 +1,8 @@
2002-07-20 John Levon <moz@compsoc.man.ac.uk>
* FormMathsDelim.C:
* FormMathsMatrix.C: fix dispatch calls nicely
2002-07-20 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* Menubar_pimpl.C (add_toc): avoid crash when there is no document

View File

@ -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)

View File

@ -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)

View File

@ -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<string> 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<string>::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_);
}

View File

@ -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> dropdown_;
/// info suffix timer
boost::scoped_ptr<Timeout> suffix_timer_;
/// info timer
boost::scoped_ptr<Timeout> info_timer_;
/// idle timer
boost::scoped_ptr<Timeout> 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

View File

@ -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:

View File

@ -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