Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 292b0f9

Browse files
committed
Added code so you canset "command line options" if you
option-click/drag python. Needs a new dialog resource.
1 parent cc456fb commit 292b0f9

1 file changed

Lines changed: 61 additions & 1 deletion

File tree

Mac/Python/macglue.c

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ typedef FileFilterYDProcPtr FileFilterYDUPP;
7373
#define GETDIR_ID 130 /* Resource ID for our "get directory" */
7474
#define SELECTCUR_ITEM 10 /* "Select current directory" button */
7575

76+
/* The dialog for interactive options */
77+
#define OPT_DIALOG 131 /* Resource ID for dialog */
78+
#define OPT_OK 1
79+
#define OPT_CANCEL 2
80+
#define OPT_INSPECT 3
81+
#define OPT_VERBOSE 4
82+
#define OPT_SUPPRESS 5
83+
#define OPT_UNBUFFERED 6
84+
#define OPT_DEBUGGING 7
85+
7686
/* The STR# resource for sys.path initialization */
7787
#define PYTHONPATH_ID 128
7888

@@ -954,7 +964,7 @@ PyMac_InitApplet()
954964
if (!err)
955965
SIOUXSettings.autocloseonquit = 1;
956966
else
957-
SIOUXSettings.showstatusline = 1;
967+
printf("\n[Terminated]\n");
958968
#endif
959969
/* XXX Should we bother to Py_Exit(sts)? */
960970
}
@@ -991,3 +1001,53 @@ PyMac_InitApplication()
9911001
}
9921002
Py_Main(argc, argv);
9931003
}
1004+
1005+
/*
1006+
** PyMac_InteractiveOptions - Allow user to set options if option key is pressed
1007+
*/
1008+
void
1009+
PyMac_InteractiveOptions(int *inspect, int *verbose, int *suppress_print,
1010+
int *unbuffered, int *debugging)
1011+
{
1012+
KeyMap rmap;
1013+
unsigned char *map;
1014+
short item, type;
1015+
ControlHandle handle;
1016+
DialogPtr dialog;
1017+
Rect rect;
1018+
1019+
GetKeys(rmap);
1020+
map = (unsigned char *)rmap;
1021+
if ( ( map[0x3a>>3] & (1<<(0x3a&7)) ) == 0 ) /* option key is 3a */
1022+
return;
1023+
1024+
dialog = GetNewDialog(OPT_DIALOG, NULL, (WindowPtr)-1);
1025+
if ( dialog == NULL )
1026+
return;
1027+
while (1) {
1028+
handle = NULL;
1029+
ModalDialog(NULL, &item);
1030+
if ( item == OPT_OK )
1031+
break;
1032+
if ( item == OPT_CANCEL ) {
1033+
DisposDialog(dialog);
1034+
exit(0);
1035+
}
1036+
#define OPT_ITEM(num, var) \
1037+
if ( item == (num) ) { \
1038+
*(var) = !*(var); \
1039+
GetDialogItem(dialog, (num), &type, (Handle *)&handle, &rect); \
1040+
SetCtlValue(handle, (short)*(var)); \
1041+
}
1042+
1043+
OPT_ITEM(OPT_INSPECT, inspect);
1044+
OPT_ITEM(OPT_VERBOSE, verbose);
1045+
OPT_ITEM(OPT_SUPPRESS, suppress_print);
1046+
OPT_ITEM(OPT_UNBUFFERED, unbuffered);
1047+
OPT_ITEM(OPT_DEBUGGING, debugging);
1048+
1049+
#undef OPT_ITEM
1050+
}
1051+
DisposDialog(dialog);
1052+
/*DBG*/printf("options: %d %d %d %d %d %d\n", *inspect, *verbose, *suppress_print, *unbuffered, *debugging);
1053+
}

0 commit comments

Comments
 (0)