• R/O
  • SSH
  • HTTPS

molby: Commit


Commit MetaInfo

Revision623 (tree)
Time2019-08-17 13:13:18
Authortoshinagata1964

Log Message

On double-clicking and entering formula, the last input string is remembered and shown as the default input

Change Summary

Incremental Difference

--- trunk/MolLib/MainView.c (revision 622)
+++ trunk/MolLib/MainView.c (revision 623)
@@ -2269,11 +2269,19 @@
22692269
22702270 if (clickCount == 2 && mview->isDragging == 0) {
22712271 /* Create a new molecular fragment */
2272- int n1, n2, found;
2272+ int n1, n2, status, found;
2273+ char *p;
22732274 found = MainView_findObjectAtPoint(mview, mousePos, &n1, &n2, 0, 0);
2274- buf[0] = 0;
2275+ status = MyAppCallback_getGlobalSettingsWithType("global.entered_formula", 's', &p);
2276+ if (status == 0) {
2277+ strncpy(buf, p, sizeof buf - 1);
2278+ buf[sizeof buf - 1] = 0;
2279+ } else {
2280+ buf[0] = 0;
2281+ }
22752282 if (MyAppCallback_getTextWithPrompt("Enter formula (e.g. CH2OCH3)", buf, sizeof buf) == 0)
22762283 return;
2284+ MyAppCallback_setGlobalSettingsWithType("global.entered_formula", 's', buf);
22772285 MolActionCreateAndPerform(mview->mol, SCRIPT_ACTION("si"), "cmd_fuse_or_dock", buf, n1);
22782286 goto exit;
22792287 }
@@ -2321,12 +2329,6 @@
23212329 TransformVec(&offset, mview->mol->cell->rtr, &offset); */
23222330 MolActionCreateAndPerform(mview->mol, gMolActionTranslateAtoms, &offset, dupSelection);
23232331 IntGroupRelease(dupSelection);
2324- /* } else if (clickCount == 2) {
2325- buf[0] = 0;
2326- if (MyAppCallback_getTextWithPrompt("Enter formula (e.g. CH2OCH3)", buf, sizeof buf) == 0)
2327- return;
2328- MolActionCreateAndPerform(mview->mol, SCRIPT_ACTION("s"), "dock_formula", buf);
2329- */
23302332 }
23312333 break;
23322334 }
--- trunk/MolLib/MolAction.c (revision 622)
+++ trunk/MolLib/MolAction.c (revision 623)
@@ -75,6 +75,9 @@
7575 /* A Ruby array to retain objects used in MolActionArg */
7676 static VALUE sMolActionArgValues = Qfalse;
7777
78+/* A global flag to suppress RubyError dialog during execution */
79+int gMolActionNoErrorDialog = 0;
80+
7881 /* Action arguments */
7982 /* (Simple types) i: Int, d: double, s: string, v: Vector, t: Transform, u: UnionPar
8083 (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 @@
547550 Ruby_SetInterruptFlag(save_interrupt);
548551 MyAppCallback_endUndoGrouping();
549552 }
550- if (result != 0) {
553+ if (result != 0 && gMolActionNoErrorDialog == 0) {
551554 Ruby_showError(result);
552555 }
553556 MyAppCallback_hideProgressPanel(); /* In case when the progress panel is still onscreen */
--- trunk/MolLib/MolAction.h (revision 622)
+++ trunk/MolLib/MolAction.h (revision 623)
@@ -83,6 +83,9 @@
8383 #define kMolActionPerformScript "script:s"
8484 #define SCRIPT_ACTION(sig) (kMolActionPerformScript sig)
8585
86+/* A global flag to suppress RubyError dialog during execution */
87+extern int gMolActionNoErrorDialog;
88+
8689 /* Action record for reversible editing */
8790 typedef struct MolAction {
8891 int refCount;
--- trunk/wxSources/MyApp.cpp (revision 622)
+++ trunk/wxSources/MyApp.cpp (revision 623)
@@ -1793,12 +1793,15 @@
17931793 int
17941794 MyAppCallback_getGlobalSettingsWithType(const char *key, int type, void *ptr)
17951795 {
1796- int retval;
1796+ int retval, temp;
17971797 char *s = MyAppCallback_getGlobalSettings(key);
17981798 char desc[] = SCRIPT_ACTION("s; ");
17991799 desc[sizeof(desc) - 2] = type;
1800+ temp = gMolActionNoErrorDialog;
1801+ gMolActionNoErrorDialog = 1;
18001802 retval = MolActionCreateAndPerform(NULL, desc, "eval", s, ptr);
18011803 free(s);
1804+ gMolActionNoErrorDialog = temp;
18021805 return retval;
18031806 }
18041807
@@ -1807,11 +1810,11 @@
18071810 {
18081811 const char *cmd = "set_global_settings";
18091812 switch (type) {
1810- case 'i': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("i"), cmd, *((const Int *)ptr));
1811- case 'd': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("d"), cmd, *((const Double *)ptr));
1812- case 's': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("s"), cmd, (const char *)ptr);
1813- case 'v': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("v"), cmd, (const Vector *)ptr);
1814- case 't': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("t"), cmd, (const Transform *)ptr);
1813+ case 'i': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("si"), cmd, key, *((const Int *)ptr));
1814+ case 'd': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("sd"), cmd, key, *((const Double *)ptr));
1815+ case 's': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("ss"), cmd, key, (const char *)ptr);
1816+ case 'v': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("sv"), cmd, key, (const Vector *)ptr);
1817+ case 't': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("st"), cmd, key, (const Transform *)ptr);
18151818 default:
18161819 MyAppCallback_errorMessageBox("Internal error: unsupported format '%c' at line %d, file %s", type, __LINE__, __FILE__);
18171820 return -2;
@@ -1869,6 +1872,7 @@
18691872 sizer1->Layout();
18701873 dialog->SetSizerAndFit(sizer1);
18711874 dialog->Centre(wxBOTH);
1875+ tctrl->SelectAll();
18721876 tctrl->SetFocus();
18731877 }
18741878 if (dialog->ShowModal() == wxID_OK) {
Show on old repository browser