OSDN Git Service

On double-clicking and entering formula, the last input string is remembered and...
authortoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Sat, 17 Aug 2019 04:13:18 +0000 (04:13 +0000)
committertoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Sat, 17 Aug 2019 04:13:18 +0000 (04:13 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@623 a2be9bc6-48de-4e38-9406-05402d4bc13c

MolLib/MainView.c
MolLib/MolAction.c
MolLib/MolAction.h
build-xcode/Molby.xcodeproj/project.xcworkspace/xcuserdata/toshi_n.xcuserdatad/UserInterfaceState.xcuserstate
wxSources/MyApp.cpp

index d105833..dd1f3ac 100755 (executable)
@@ -2269,11 +2269,19 @@ MainView_mouseUp(MainView *mview, const float *mousePos, int flags, int clickCou
 
        if (clickCount == 2 && mview->isDragging == 0) {
                /*  Create a new molecular fragment  */
-               int n1, n2, found;
+               int n1, n2, status, found;
+        char *p;
                found = MainView_findObjectAtPoint(mview, mousePos, &n1, &n2, 0, 0);
-               buf[0] = 0;
+        status = MyAppCallback_getGlobalSettingsWithType("global.entered_formula", 's', &p);
+        if (status == 0) {
+            strncpy(buf, p, sizeof buf - 1);
+            buf[sizeof buf - 1] = 0;
+        } else {
+            buf[0] = 0;
+        }
                if (MyAppCallback_getTextWithPrompt("Enter formula (e.g. CH2OCH3)", buf, sizeof buf) == 0)
                        return;
+        MyAppCallback_setGlobalSettingsWithType("global.entered_formula", 's', buf);
                MolActionCreateAndPerform(mview->mol, SCRIPT_ACTION("si"), "cmd_fuse_or_dock", buf, n1);
                goto exit;
        }
@@ -2321,12 +2329,6 @@ MainView_mouseUp(MainView *mview, const float *mousePos, int flags, int clickCou
                                        TransformVec(&offset, mview->mol->cell->rtr, &offset); */
                                MolActionCreateAndPerform(mview->mol, gMolActionTranslateAtoms, &offset, dupSelection);
                                IntGroupRelease(dupSelection);
-               /*      } else if (clickCount == 2) {
-                               buf[0] = 0;
-                               if (MyAppCallback_getTextWithPrompt("Enter formula (e.g. CH2OCH3)", buf, sizeof buf) == 0)
-                                       return;
-                               MolActionCreateAndPerform(mview->mol, SCRIPT_ACTION("s"), "dock_formula", buf);
-               */
                        }
                        break;
                }
index 21e002b..f70912e 100644 (file)
@@ -75,6 +75,9 @@ const char *gMolActionAmendBySymmetry = "amendBySymmetry:G;G";
 /*  A Ruby array to retain objects used in MolActionArg  */
 static VALUE sMolActionArgValues = Qfalse;
 
+/*  A global flag to suppress RubyError dialog during execution  */
+int gMolActionNoErrorDialog = 0;
+
 /*  Action arguments  */
 /*  (Simple types)  i: Int, d: double, s: string, v: Vector, t: Transform, u: UnionPar
  (Array types)   I: array of Int, D: array of double, V: array of Vector, C: array of char, T: array of Transform, U: array of UnionPars
@@ -547,7 +550,7 @@ s_MolActionPerformRubyScript(Molecule *mol, MolAction *action)
                Ruby_SetInterruptFlag(save_interrupt);
                MyAppCallback_endUndoGrouping();
        }
-       if (result != 0) {
+       if (result != 0 && gMolActionNoErrorDialog == 0) {
                Ruby_showError(result);
        }
        MyAppCallback_hideProgressPanel();  /*  In case when the progress panel is still onscreen */
index 85754a8..a7196f1 100644 (file)
@@ -83,6 +83,9 @@ extern const char *gMolActionAmendBySymmetry;
 #define kMolActionPerformScript "script:s"
 #define SCRIPT_ACTION(sig) (kMolActionPerformScript sig)
 
+/*  A global flag to suppress RubyError dialog during execution  */
+extern int gMolActionNoErrorDialog;
+
 /*  Action record for reversible editing  */
 typedef struct MolAction {
        int refCount;
index 59c2ae6..340eb3d 100644 (file)
Binary files a/build-xcode/Molby.xcodeproj/project.xcworkspace/xcuserdata/toshi_n.xcuserdatad/UserInterfaceState.xcuserstate and b/build-xcode/Molby.xcodeproj/project.xcworkspace/xcuserdata/toshi_n.xcuserdatad/UserInterfaceState.xcuserstate differ
index d001298..3fd2c8f 100755 (executable)
@@ -1793,12 +1793,15 @@ MyAppCallback_setGlobalSettings(const char *key, const char *value)
 int
 MyAppCallback_getGlobalSettingsWithType(const char *key, int type, void *ptr)
 {
-       int retval;
+    int retval, temp;
        char *s = MyAppCallback_getGlobalSettings(key);
        char desc[] = SCRIPT_ACTION("s; ");
        desc[sizeof(desc) - 2] = type;
+    temp = gMolActionNoErrorDialog;
+    gMolActionNoErrorDialog = 1;
        retval = MolActionCreateAndPerform(NULL, desc, "eval", s, ptr);
        free(s);
+    gMolActionNoErrorDialog = temp;
        return retval;
 }
 
@@ -1807,11 +1810,11 @@ MyAppCallback_setGlobalSettingsWithType(const char *key, int type, const void *p
 {
        const char *cmd = "set_global_settings";
        switch (type) {
-               case 'i': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("i"), cmd, *((const Int *)ptr));
-               case 'd': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("d"), cmd, *((const Double *)ptr));
-               case 's': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("s"), cmd, (const char *)ptr);
-               case 'v': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("v"), cmd, (const Vector *)ptr);
-               case 't': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("t"), cmd, (const Transform *)ptr);
+               case 'i': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("si"), cmd, key, *((const Int *)ptr));
+               case 'd': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("sd"), cmd, key, *((const Double *)ptr));
+               case 's': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("ss"), cmd, key, (const char *)ptr);
+               case 'v': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("sv"), cmd, key, (const Vector *)ptr);
+               case 't': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("st"), cmd, key, (const Transform *)ptr);
                default:
                        MyAppCallback_errorMessageBox("Internal error: unsupported format '%c' at line %d, file %s", type, __LINE__, __FILE__);
                        return -2;
@@ -1869,6 +1872,7 @@ MyAppCallback_getTextWithPrompt(const char *prompt, char *buf, int bufsize)
                sizer1->Layout();
                dialog->SetSizerAndFit(sizer1);
                dialog->Centre(wxBOTH);
+        tctrl->SelectAll();
                tctrl->SetFocus();
        }
        if (dialog->ShowModal() == wxID_OK) {