diff --git a/ChangeLog b/ChangeLog index 331839a270..5cfb172a30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +1999-12-30 Allan Rae + + * lib/templates/IEEEtran.lyx: minor change + + * src/lyxvc.C (registrer, checkIn), src/lyx_cb.C (MenuInsertLabel), + src/mathed/formula.C (LocalDispatch): askForText changes + + * src/lyx_gui_misc.[Ch] (askForText): now returns a bool also so we + know when a user has cancelled input. Fixes annoying problems with + inserting labels and version control. + 1999-12-28 Jean-Marc Lasgouttes * src/buffer.C (Dispatch): remove an extraneous break statement. diff --git a/lib/templates/IEEEtran.lyx b/lib/templates/IEEEtran.lyx index 0d603f49c1..ddc4f311d5 100644 --- a/lib/templates/IEEEtran.lyx +++ b/lib/templates/IEEEtran.lyx @@ -1,4 +1,4 @@ -#This file was created by Mon Dec 20 11:39:44 1999 +#This file was created by Mon Dec 20 11:59:31 1999 #LyX 1.0 (C) 1995-1999 Matthias Ettrich and the LyX Team \lyxformat 2.15 \textclass IEEEtran diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 63a87be339..b81d045c74 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -1244,9 +1244,13 @@ void MenuInsertLabel(char const * arg) { string label = arg; ProhibitInput(); - //string label = fl_show_input(_("Enter new label to insert:"), ""); - if (label.empty()) - label = frontStrip(strip(askForText(_("Enter new label to insert:")))); + if (label.empty()) { + pair + result = askForText(_("Enter new label to insert:")); + if (result.first) { + label = frontStrip(strip(result.second)); + } + } if (!label.empty()) { InsetLabel * new_inset = new InsetLabel; new_inset->setContents(label); diff --git a/src/lyx_gui_misc.C b/src/lyx_gui_misc.C index 1084810b02..1bd09b6672 100644 --- a/src/lyx_gui_misc.C +++ b/src/lyx_gui_misc.C @@ -400,7 +400,7 @@ int AskConfirmation(string const & s1, string const & s2, string const & s3) // Asks for a text -string askForText(string const & msg, string const & dflt) +pair askForText(string const & msg, string const & dflt) { char const * tmp; fl_set_resource("flInput.cancel.label", idex(_("Cancel|^["))); @@ -408,9 +408,9 @@ string askForText(string const & msg, string const & dflt) fl_set_resource("flInput.clear.label", idex(_("Clear|#e"))); tmp = fl_show_input(msg.c_str(), dflt.c_str()); if (tmp != 0) - return tmp; + return make_pair(true, tmp); else - return string(); + return make_pair(false, string()); } diff --git a/src/lyx_gui_misc.h b/src/lyx_gui_misc.h index a8d3eb203d..e9f44c9077 100644 --- a/src/lyx_gui_misc.h +++ b/src/lyx_gui_misc.h @@ -16,6 +16,7 @@ #include FORMS_H_LOCATION #include "LString.h" +#include /* needed for pair<> definition */ /// Prevents LyX from being killed when the close box is pressed in a popup. extern "C" int CancelCloseBoxCB(FL_FORM *, void *); @@ -53,8 +54,9 @@ bool AskQuestion(string const & s1, string const & s2 = string(), int AskConfirmation(string const & s1, string const & s2 = string(), string const & s3 = string()); -/// returns a text -string askForText(string const & msg, string const & dflt = string()); +/// returns a bool: false=cancelled, true=okay. string contains returned text +pair askForText(string const & msg, + string const & dflt = string()); /// Informs the user that changes in the coming form will be ignored void WarnReadonly(string const & file); diff --git a/src/lyxvc.C b/src/lyxvc.C index 1eb2cfc258..a577c7f8ed 100644 --- a/src/lyxvc.C +++ b/src/lyxvc.C @@ -98,15 +98,17 @@ void LyXVC::registrer() } lyxerr[Debug::LYXVC] << "LyXVC: registrer" << endl; - string tmp = askForText(_("LyX VC: Initial description"), - _("(no initial description)")); - if (tmp.empty()) { + pair tmp = askForText(_("LyX VC: Initial description"), + _("(no initial description)")); + if (!tmp.first || tmp.second.empty()) { + // should we insist on checking tmp.second.empty()? lyxerr[Debug::LYXVC] << "LyXVC: user cancelled" << endl; - WriteAlert(_("Info"), _("This document has NOT been registered.")); + WriteAlert(_("Info"), + _("This document has NOT been registered.")); return; } - vcs->registrer(tmp); + vcs->registrer(tmp.second); } @@ -128,11 +130,15 @@ void LyXVC::checkIn() } lyxerr[Debug::LYXVC] << "LyXVC: checkIn" << endl; - string tmp = askForText(_("LyX VC: Log Message")); - if (tmp.empty()) tmp = "(no log msg)"; - - vcs->checkIn(tmp); - + pair tmp = askForText(_("LyX VC: Log Message")); + if (tmp.first) { + if (tmp.second.empty()) { + tmp.second = _("(no log message)"); + } + vcs->checkIn(tmp.second); + } else { + lyxerr[Debug::LYXVC] << "LyXVC: user cancelled" << endl; + } } diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 7ea19a586d..d59847f686 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -1043,11 +1043,16 @@ bool InsetFormula::LocalDispatch(int action, char const * arg) case LFUN_INSERT_LABEL: { - LockedInsetStoreUndo(Undo::INSERT); + LockedInsetStoreUndo(Undo::INSERT); if (par->GetType() < LM_OT_PAR) break; string lb = arg; - if (lb.empty()) - lb = string(askForText(_("Enter new label to insert:"))); + if (lb.empty()) { + pair + result = askForText(_("Enter new label to insert:")); + if (result.first) { + lb = result.second; + } + } if (!lb.empty() && lb[0] > ' ') { SetNumber(true); if (par->GetType() == LM_OT_MPARN) {