+1999-12-30 Allan Rae <rae@lyx.org>
+
+ * 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 <Jean-Marc.Lasgouttes@inria.fr>
* src/buffer.C (Dispatch): remove an extraneous break statement.
-#This file was created by <rae> Mon Dec 20 11:39:44 1999
+#This file was created by <rae> Mon Dec 20 11:59:31 1999
#LyX 1.0 (C) 1995-1999 Matthias Ettrich and the LyX Team
\lyxformat 2.15
\textclass IEEEtran
{
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<bool, string>
+ 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);
// Asks for a text
-string askForText(string const & msg, string const & dflt)
+pair<bool, string> askForText(string const & msg, string const & dflt)
{
char const * tmp;
fl_set_resource("flInput.cancel.label", idex(_("Cancel|^[")));
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<bool, string>(true, tmp);
else
- return string();
+ return make_pair<bool, string>(false, string());
}
#include FORMS_H_LOCATION
#include "LString.h"
+#include <utility> /* 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 *);
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<bool, string> 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);
}
lyxerr[Debug::LYXVC] << "LyXVC: registrer" << endl;
- string tmp = askForText(_("LyX VC: Initial description"),
- _("(no initial description)"));
- if (tmp.empty()) {
+ pair<bool, string> 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);
}
}
lyxerr[Debug::LYXVC] << "LyXVC: checkIn" << endl;
- string tmp = askForText(_("LyX VC: Log Message"));
- if (tmp.empty()) tmp = "(no log msg)";
-
- vcs->checkIn(tmp);
-
+ pair<bool, string> 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;
+ }
}
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<bool, string>
+ 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) {