]> git.lyx.org Git - features.git/commitdiff
My final commit of the year? pair<bool, string> askForText
authorAllan Rae <rae@lyx.org>
Thu, 30 Dec 1999 02:35:43 +0000 (02:35 +0000)
committerAllan Rae <rae@lyx.org>
Thu, 30 Dec 1999 02:35:43 +0000 (02:35 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@398 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
lib/templates/IEEEtran.lyx
src/lyx_cb.C
src/lyx_gui_misc.C
src/lyx_gui_misc.h
src/lyxvc.C
src/mathed/formula.C

index 331839a2700e97cd12c29dd87a4c4ac71e049462..5cfb172a305762c6870bd65acbbfc82abca59b62 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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.
index 0d603f49c1ff6ac2334bec4f15a965f4fc54a442..ddc4f311d5dc99e157467d1a8b57ba70b3bec1cb 100644 (file)
@@ -1,4 +1,4 @@
-#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
index 63a87be339b46d4b584bef5003e0974c9cea1704..b81d045c74c373f05ae142d0d3a4a53a800d94c7 100644 (file)
@@ -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<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);
index 1084810b02ac6e7e39231a21fc8c2a8e2a67e901..1bd09b6672771ce0196dec471cc782d2791d8648 100644 (file)
@@ -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<bool, string> 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<bool, string>(true, tmp);
        else
-         return string();
+         return make_pair<bool, string>(false, string());
 }
 
 
index a8d3eb203d8ac0065923f1ce2cbdb9a551031c93..e9f44c90771a5f2172a0e8196fc6cad3886309c2 100644 (file)
@@ -16,6 +16,7 @@
 
 #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 *);
@@ -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<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);
index 1eb2cfc258dba7b19646e8e8846b4a66e6f551dc..a577c7f8edd6c9f94d2956677c075f128690037e 100644 (file)
@@ -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<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);
 }
 
 
@@ -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<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;
+       }
 }
 
 
index 7ea19a586db970f024330e5da30055272f38b9b9..d59847f6864bb82a877e0aac5e11befe069a7678 100644 (file)
@@ -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<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) {