Changeset 1488 for trunk/dll/command.c
- Timestamp:
- Dec 22, 2009, 12:42:55 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/command.c
r1487 r1488 28 28 24 Aug 08 GKY Warn full drive on save of .DAT file; prevent loss of existing file 29 29 15 Oct 08 GKY Prevent asking to add %a on NormalizeCmdLine abort 30 21 Dec 09 GKY Fix the environment so it can be saved, deleted and used consistently. 31 21 Dec 09 GKY Allow command menu reorder without changing the "ID" or hot key for a command. 32 Added load_inicommand to load the IDs from the ini file. 33 21 Dec 09 GKY Added 20 new hot keys for commands. 34 21 Dec 09 GKY Added CheckExecutibleFlags to streamline code in command.c assoc.c & cmdline.c 30 35 31 36 ***********************************************************************/ … … 62 67 #include "fortify.h" 63 68 69 VOID load_inicommands(VOID); 70 64 71 typedef struct 65 72 { 66 73 PSZ pszCmdLine; 67 74 CHAR title[100]; 75 CHAR env[1002]; 68 76 ULONG flags; 69 77 ULONG ID; … … 77 85 static PSZ pszSrcFile = __FILE__; 78 86 static LINKCMDS *cmdtail; 79 static INT CommandDatVersion = 0; 87 static BOOL UsedCommandIDs[300]; 88 static BOOL UsedHotKeyIDs[40]; 80 89 81 90 #pragma data_seg(GLOBAL2) 82 91 LINKCMDS *cmdhead; 83 92 BOOL cmdloaded; 84 BOOL UsedCommandIDs[300];85 BOOL UsedHotKeyIDs[20];86 93 87 94 MRESULT EXPENTRY CommandTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) … … 338 345 xfree(info->title, pszSrcFile, __LINE__); 339 346 xfree(info->pszCmdLine, pszSrcFile, __LINE__); 347 xfree(info->env, pszSrcFile, __LINE__); 340 348 free(info); 341 349 info = next; … … 349 357 LINKCMDS *info; 350 358 PSZ pszCmdLine; 351 CHAR *p;352 359 CHAR title[100]; 353 360 CHAR flags[34]; 354 CHAR ID[34]; 355 CHAR HotKeyID[34]; 361 ULONG size; 356 362 357 363 if (cmdhead) 358 364 free_commands(); 365 PrfQueryProfileData(fmprof, FM3Str, "UsedCommandIDs", &UsedCommandIDs, 366 &size); 367 PrfQueryProfileData(fmprof, FM3Str, "UsedHotKeyIDs", &UsedHotKeyIDs, 368 &size); 359 369 cmdloaded = TRUE; 360 370 pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); … … 363 373 fp = _fsopen(pszCmdLine, "r", SH_DENYWR); 364 374 if (fp) { 365 xfgets(title, sizeof(title), fp, pszSrcFile, __LINE__);366 lstrip(title);367 if (!strnicmp(title, "Version", 7) && !CommandDatVersion) {368 p = title + 7;369 while (*p == ' ')370 p++;371 bstripcr(p);372 CommandDatVersion = atol(p);373 }374 375 while (!feof(fp)) { 375 376 if (!xfgets_bstripcr(title, sizeof(title), fp, pszSrcFile, __LINE__)) 376 377 break; 377 title[strlen(title)] = 0; // Match size to entry file max378 //title[strlen(title)] = 0; // Match size to entry file max? Not needed as bstripcr does this? GKY 21 Dec 09 378 379 if (!*title || *title == ';') 379 380 continue; … … 381 382 break; /* error! */ 382 383 if (!xfgets_bstripcr(flags, sizeof(flags), fp, pszSrcFile, __LINE__)) 383 break; /* error! */ 384 if (CommandDatVersion) { 385 if (!xfgets_bstripcr(ID, sizeof(ID), fp, pszSrcFile, __LINE__)) 386 break; /* error! */ 387 ID[34] = 0; 388 if (!xfgets_bstripcr(HotKeyID, sizeof(HotKeyID), fp, pszSrcFile, __LINE__)) 389 break; /* error! */ 390 ID[34] = 0; 391 } 392 pszCmdLine[strlen(pszCmdLine)] = 0; // fixme to know why chopped this way? 393 //bstripcr(pszCmdLine); 384 break; 385 //pszCmdLine[strlen(pszCmdLine)] = 0; // fixme to know why chopped this way? Not needed as bstripcr does this? GKY 21 Dec 09 394 386 flags[34] = 0; 395 //bstripcr(flags);396 387 if (!pszCmdLine) 397 388 continue; … … 405 396 info->title = xstrdup(title, pszSrcFile, __LINE__); 406 397 info->flags = atol(flags); 407 if (CommandDatVersion) {408 info->ID = atol(ID);409 info->HotKeyID = atol(HotKeyID);410 }411 398 if (!info->pszCmdLine || !info->title) { 412 399 xfree(info->pszCmdLine, pszSrcFile, __LINE__); … … 432 419 free(pszCmdLine); 433 420 fclose(fp); 434 } 421 load_inicommands(); 422 } 423 } 424 } 425 426 /** 427 * load_inicommand loads the data from the ini file into an info struct 428 * after COMMANDS.DAT has been loaded; It generates new IDs where necessary 429 * it saves the environment from the old ini key and deletes it as needed 430 **/ 431 432 VOID load_inicommands(VOID) 433 { 434 LINKCMDS *info;; 435 INT x = 0; 436 INT y = 0; 437 ULONG ID = 0; 438 ULONG HotKeyID = 0; 439 CHAR env[1002]; 440 CHAR keyID[120]; 441 CHAR keyHotKeyID[120]; 442 CHAR keyenv[120]; 443 ULONG size; 444 445 if (!cmdloaded || !cmdhead) 446 return; 447 info = cmdhead; 448 while (info) { 449 bstripcr(info->title); 450 sprintf(keyID, "COMMAND.%sID", info->title); 451 sprintf(keyHotKeyID, "COMMAND.%sHotKeyID", info->title); 452 sprintf(keyenv, "COMMAND.%senv", info->title); 453 size = sizeof(ULONG); 454 PrfQueryProfileData(fmprof, FM3Str, keyID, &ID, &size); 455 size = sizeof(ULONG); 456 PrfQueryProfileData(fmprof, FM3Str, keyHotKeyID, &HotKeyID, &size); 457 PrfQueryProfileString(fmprof, FM3Str, keyenv, NullStr, env, sizeof(env)); 458 if (ID) { 459 if (env != NullStr) 460 info->env = xstrdup(env, pszSrcFile, __LINE__); 461 info->ID = ID; 462 info->HotKeyID = HotKeyID; 463 } 464 //This updates the old commands.dat file to the new format 465 //assigning the IDs based on file order or on next available ID if 466 //COMMAND.DAT is hand edited. 467 else { 468 for (x = 0; x < 300; x++) { 469 if (!UsedCommandIDs[x]) { 470 ID = info->ID = IDM_COMMANDSTART + x; 471 UsedCommandIDs[x] = TRUE; 472 for (y = 0; y < 40; y++) { 473 if (!UsedHotKeyIDs[y]) { 474 HotKeyID = info->HotKeyID = IDM_COMMANDNUM0 + y; 475 UsedHotKeyIDs[y] = TRUE; 476 break; 477 } 478 } 479 break; 480 } 481 if (x == 299) 482 saymsg(MB_OK | MB_ICONEXCLAMATION , HWND_DESKTOP, 483 GetPString(IDS_COMMANDSLIMITTITLETEXT), 484 GetPString(IDS_COMMANDSLIMITREACHEDTEXT )); 485 } 486 PrfQueryProfileString(fmprof, FM3Str, info->pszCmdLine, NullStr, env, sizeof(env)); 487 info->env = env; 488 if (env != NullStr) 489 PrfWriteProfileString(fmprof, FM3Str, info->pszCmdLine, NULL); 490 if (info->env) 491 strcpy(env, info->env); 492 ID = info->ID; 493 HotKeyID = info->HotKeyID; 494 PrfWriteProfileData(fmprof, FM3Str, keyID, &ID, sizeof(INT)); 495 PrfWriteProfileData(fmprof, FM3Str, keyHotKeyID, &HotKeyID, sizeof(INT)); 496 if (env != NullStr) 497 PrfWriteProfileString(fmprof, FM3Str, keyenv, env); 498 PrfWriteProfileData(fmprof, FM3Str, "UsedCommandIDs", &UsedCommandIDs, 499 sizeof(BOOL) * 300); 500 PrfWriteProfileData(fmprof, FM3Str, "UsedHotKeyIDs", &UsedHotKeyIDs, 501 sizeof(BOOL) * 40); 502 } 503 ID = 0; 504 HotKeyID = 0; 505 info = info->next; 435 506 } 436 507 } … … 442 513 CHAR s[CCHMAXPATH + 14]; 443 514 INT x = 0; 515 INT ID = 0; 516 INT HotKeyID = 0; 517 CHAR env[1002]; 518 CHAR keyID[120]; 519 CHAR keyHotKeyID[120]; 520 CHAR keyenv[120]; 444 521 445 522 if (!cmdloaded || !cmdhead) … … 451 528 fp = xfopen(s, "w", pszSrcFile, __LINE__); 452 529 if (fp) { 453 //Adds line for version tracking454 fprintf(fp,"Version 2\n");455 fputs(GetPString(IDS_COMMANDFILETEXT), fp);456 info = cmdhead;457 530 while (info) { 458 //This updates the old commands.dat file to the new format 459 //assigning the IDs based on file order 460 if (!info->ID) { 461 info->ID = IDM_COMMANDSTART + x; 462 UsedCommandIDs[x] = TRUE; 463 if (x < 20) { 464 info->HotKeyID = IDM_COMMANDNUM0 + x; 465 UsedHotKeyIDs[x] = TRUE; 466 } 467 } 468 fprintf(fp, ";\n%0.99s\n%0.*s\n%lu\n%lu\n%lu\n", 469 info->title, MaxComLineStrg, info->pszCmdLine, 470 info->flags, info->ID, info->HotKeyID); 471 //else 472 // fprintf(fp, 473 // ";\n%0.99s\n%0.*s\n%lu\n", 474 // info->title, MaxComLineStrg, info->pszCmdLine, info->flags); 531 fprintf(fp, ";\n%0.99s\n%0.*s\n%lu\n", 532 info->title, MaxComLineStrg, info->pszCmdLine, info->flags); 533 534 if (info->env) 535 strcpy(env, info->env); 536 ID = info->ID; 537 HotKeyID = info->HotKeyID; 538 bstripcr(info->title); 539 sprintf(keyID, "COMMAND.%sID", info->title); 540 sprintf(keyHotKeyID, "COMMAND.%sHotKeyID", info->title); 541 sprintf(keyenv, "COMMAND.%senv", info->title); 542 PrfWriteProfileData(fmprof, FM3Str, keyID, &ID, sizeof(INT)); 543 PrfWriteProfileData(fmprof, FM3Str, keyHotKeyID, &HotKeyID, sizeof(INT)); 544 if (env != NullStr) 545 PrfWriteProfileString(fmprof, FM3Str, keyenv, env); 475 546 x++; 476 547 info = info->next; 477 } // while 548 } // while info 478 549 PrfWriteProfileData(fmprof, FM3Str, "UsedCommandIDs", &UsedCommandIDs, 479 550 sizeof(BOOL) * 300); 480 551 PrfWriteProfileData(fmprof, FM3Str, "UsedHotKeyIDs", &UsedHotKeyIDs, 481 sizeof(BOOL) * 20);552 sizeof(BOOL) * 40); 482 553 fclose(fp); 483 554 } // if (fp) … … 489 560 { 490 561 LINKCMDS *info; 491 ULONG size;492 562 INT x; 563 INT y; 493 564 494 565 if (!addme || !*addme->pszCmdLine || !*addme->title) … … 498 569 if (!stricmp(info->title, addme->title)) 499 570 return NULL; // Got a dup 571 if (addme->HotKeyID && info->HotKeyID && info->HotKeyID == addme->HotKeyID) 572 info->HotKeyID = 0; //avoid assigning hot key to multiple commands 500 573 info = info->next; 501 574 } … … 506 579 info->title = xstrdup(addme->title, pszSrcFile, __LINE__); 507 580 info->HotKeyID = addme->HotKeyID; 581 if (info->HotKeyID >= IDM_COMMANDNUM0 && info->HotKeyID <= IDM_COMMANDNUM19) 582 UsedHotKeyIDs[info->HotKeyID - IDM_COMMANDNUM0] = TRUE; 583 else 584 info->HotKeyID = 0; 508 585 if (!info->ID) { 509 PrfQueryProfileData(fmprof, FM3Str, "UsedCommandIDs", &UsedCommandIDs, 510 &size); //profile updated by save_commands 586 //profile updated by save_commands 511 587 for (x = 0; x < 300; x++) { 512 588 if (!UsedCommandIDs[x]) { 513 589 info->ID = IDM_COMMANDSTART + x; 514 590 UsedCommandIDs[x] = TRUE; 591 for (y = 0; y < 40; y++) { 592 if (!UsedHotKeyIDs[y]) { 593 info->HotKeyID = IDM_COMMANDNUM0 + y; 594 UsedHotKeyIDs[y] = TRUE; 595 break; 596 } 597 } 515 598 break; 516 599 } 600 if (x == 299) 601 saymsg(MB_OK | MB_ICONEXCLAMATION , HWND_DESKTOP, 602 GetPString(IDS_COMMANDSLIMITTITLETEXT), 603 GetPString(IDS_COMMANDSLIMITREACHEDTEXT )); 517 604 } 518 605 } 519 606 if (addme->flags) 520 607 info->flags = addme->flags; 608 if (addme->env) 609 info->env = xstrdup(addme->env, pszSrcFile, __LINE__); 521 610 if (!info->pszCmdLine || !info->title || !info->ID) { 522 611 xfree(info->pszCmdLine, pszSrcFile, __LINE__); 612 xfree(info->title, pszSrcFile, __LINE__); 523 613 xfree(info->title, pszSrcFile, __LINE__); 524 614 free(info); … … 561 651 } 562 652 xfree(info->pszCmdLine, pszSrcFile, __LINE__); 563 xfree(info->title, pszSrcFile, __LINE__); 653 xfree(info->title, pszSrcFile, __LINE__); 654 xfree(info->env, pszSrcFile, __LINE__); 564 655 free(info); 565 656 return TRUE; … … 642 733 WinCheckButton(hwnd, CMD_KEEP, ((info->flags & KEEP) != 0)); 643 734 WinCheckButton(hwnd, CMD_ONCE, ((info->flags & ONCE) != 0)); 644 WinSetDlgItemText(hwnd, CMD_TITLE, info->title); 645 { 646 CHAR env[1002]; 647 ULONG size; 648 649 *env = 0; 650 size = sizeof(env) - 1; 651 if (PrfQueryProfileData(fmprof, FM3Str, info->pszCmdLine, env, &size) && 652 *env) 653 WinSetDlgItemText(hwnd, CMD_ENVIRON, env); 654 else 655 WinSetDlgItemText(hwnd, CMD_ENVIRON, NullStr); 656 } 735 WinSetDlgItemText(hwnd, CMD_TITLE, info->title); 736 if (info->env) 737 WinSetDlgItemText(hwnd, CMD_ENVIRON, info->env); 738 else 739 WinSetDlgItemText(hwnd, CMD_ENVIRON, NullStr); 657 740 } 658 741 break; … … 724 807 PSZ pszWorkBuf; 725 808 APIRET ret; 809 CHAR env[1002]; 726 810 727 811 memset(&temp, 0, sizeof(COMMAND)); … … 746 830 strcat(temp.pszCmdLine, " %a"); 747 831 } 748 WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title); 749 if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT)) 832 WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title); 833 bstripcr(temp.title); 834 temp.flags = CheckExecutibleFlags(hwnd, 3); 835 /*if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT)) 750 836 temp.flags = 0; 751 837 else if (WinQueryButtonCheckstate(hwnd, CMD_FULLSCREEN)) … … 762 848 temp.flags |= PROMPT; 763 849 if (WinQueryButtonCheckstate(hwnd, CMD_ONCE)) 764 temp.flags |= ONCE; 850 temp.flags |= ONCE;*/ 851 *env = 0; 852 WinQueryDlgItemText(hwnd, CMD_ENVIRON, 1000, env); 853 bstripcr(env); 854 if (*env) { 855 strcpy(temp.env, env); 856 } 765 857 if (fCancelAction){ 766 858 fCancelAction = FALSE; … … 771 863 info = add_command(&temp); 772 864 if (!info) 773 { 774 WinDismissDlg(hwnd, 0); 775 /*saymsg(MB_ENTER, hwnd, 776 GetPString(IDS_ERRORTEXT), 777 GetPString(IDS_CANTADDCOMMANDTEXT), 778 temp.title);*/ 779 } 865 WinDismissDlg(hwnd, 0); 866 else { 867 x = (SHORT) WinSendDlgItemMsg(hwnd, 868 CMD_LISTBOX, 869 LM_INSERTITEM, 870 MPFROM2SHORT(LIT_END, 0), 871 MPFROMP(temp.title)); 872 if (x >= 0) { 873 WinSendDlgItemMsg(hwnd, 874 CMD_LISTBOX, 875 LM_SETITEMHANDLE, 876 MPFROMSHORT(x), MPFROMP(info)); 877 WinSendDlgItemMsg(hwnd, 878 CMD_LISTBOX, 879 LM_SELECTITEM, 880 MPFROMSHORT(x), MPFROMSHORT(TRUE)); 881 } 882 } 883 save_commands(); 884 load_commands(); 885 free(temp.pszCmdLine); 886 } 887 x = (SHORT) WinSendDlgItemMsg(hwnd, 888 CMD_LISTBOX, 889 LM_QUERYSELECTION, 890 MPFROMSHORT(LIT_FIRST), MPVOID); 891 save_commands(); 892 WinDismissDlg(hwnd, 0); 893 break; 894 895 case DID_CANCEL: 896 WinDismissDlg(hwnd, 0); 897 break; 898 899 case IDM_HELP: 900 if (hwndHelp) 901 WinSendMsg(hwndHelp, 902 HM_DISPLAY_HELP, 903 MPFROM2SHORT(HELP_COMMAND, 0), MPFROMSHORT(HM_RESOURCEID)); 904 break; 905 906 case CMD_ADD: 907 { 908 COMMAND temp; 909 PSZ pszWorkBuf; 910 APIRET ret; 911 CHAR env[1002]; 912 913 memset(&temp, 0, sizeof(COMMAND)); 914 temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); 915 if (!temp.pszCmdLine) 916 break; //already complained 917 pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__); 918 if (!pszWorkBuf) { 919 free(temp.pszCmdLine); 920 break; //already complained 921 } 922 WinQueryDlgItemText(hwnd, CMD_CL, MaxComLineStrg, temp.pszCmdLine); 923 NormalizeCmdLine(pszWorkBuf, temp.pszCmdLine); 924 memcpy(temp.pszCmdLine, pszWorkBuf, strlen(pszWorkBuf) + 1); 925 free(pszWorkBuf); 926 if (!strchr(temp.pszCmdLine, '%') && !fCancelAction){ 927 ret = saymsg(MB_YESNO, 928 HWND_DESKTOP, 929 NullStr, 930 GetPString(IDS_TOACTONSELECTEDTEXT)); 931 if (ret == MBID_YES) 932 strcat(temp.pszCmdLine, " %a"); 933 } 934 WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title); 935 bstripcr(temp.title); 936 temp.flags = CheckExecutibleFlags(hwnd, 3); 937 /*if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT)) 938 temp.flags = 0; 939 else if (WinQueryButtonCheckstate(hwnd, CMD_FULLSCREEN)) 940 temp.flags = FULLSCREEN; 941 else if (WinQueryButtonCheckstate(hwnd, CMD_MINIMIZED)) 942 temp.flags = MINIMIZED; 943 else if (WinQueryButtonCheckstate(hwnd, CMD_MAXIMIZED)) 944 temp.flags = MAXIMIZED; 945 else if (WinQueryButtonCheckstate(hwnd, CMD_INVISIBLE)) 946 temp.flags = INVISIBLE; 947 if (WinQueryButtonCheckstate(hwnd, CMD_KEEP)) 948 temp.flags |= KEEP; 949 if (WinQueryButtonCheckstate(hwnd, CMD_PROMPT)) 950 temp.flags |= PROMPT; 951 if (WinQueryButtonCheckstate(hwnd, CMD_ONCE)) 952 temp.flags |= ONCE;*/ 953 *env = 0; 954 WinQueryDlgItemText(hwnd, CMD_ENVIRON, 1000, env); 955 bstripcr(env); 956 if (*env) { 957 strcpy(temp.env, env); 958 } 959 if (fCancelAction){ 960 fCancelAction = FALSE; 961 free(temp.pszCmdLine); 962 break; 963 } 964 else 965 info = add_command(&temp); 966 if (!info) { 967 saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT), 968 GetPString(IDS_CANTADDCOMMANDTEXTDUP), temp.title); 969 } 780 970 else { 781 CHAR env[1002];782 783 *env = 0;784 WinQueryDlgItemText(hwnd, CMD_ENVIRON, 1000, env);785 bstripcr(env);786 if (*env) {787 PrfWriteProfileString(fmprof, FM3Str, temp.pszCmdLine, env);788 }789 971 x = (SHORT) WinSendDlgItemMsg(hwnd, 790 972 CMD_LISTBOX, … … 806 988 free(temp.pszCmdLine); 807 989 } 808 x = (SHORT) WinSendDlgItemMsg(hwnd,809 CMD_LISTBOX,810 LM_QUERYSELECTION,811 MPFROMSHORT(LIT_FIRST), MPVOID);812 WinDismissDlg(hwnd, 0);813 break;814 815 case DID_CANCEL:816 WinDismissDlg(hwnd, 0);817 break;818 819 case IDM_HELP:820 if (hwndHelp)821 WinSendMsg(hwndHelp,822 HM_DISPLAY_HELP,823 MPFROM2SHORT(HELP_COMMAND, 0), MPFROMSHORT(HM_RESOURCEID));824 break;825 826 case CMD_ADD:827 {828 COMMAND temp;829 PSZ pszWorkBuf;830 APIRET ret;831 832 memset(&temp, 0, sizeof(COMMAND));833 temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);834 if (!temp.pszCmdLine)835 break; //already complained836 pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);837 if (!pszWorkBuf) {838 free(temp.pszCmdLine);839 break; //already complained840 }841 WinQueryDlgItemText(hwnd, CMD_CL, MaxComLineStrg, temp.pszCmdLine);842 NormalizeCmdLine(pszWorkBuf, temp.pszCmdLine);843 memcpy(temp.pszCmdLine, pszWorkBuf, strlen(pszWorkBuf) + 1);844 free(pszWorkBuf);845 if (!strchr(temp.pszCmdLine, '%') && !fCancelAction){846 ret = saymsg(MB_YESNO,847 HWND_DESKTOP,848 NullStr,849 GetPString(IDS_TOACTONSELECTEDTEXT));850 if (ret == MBID_YES)851 strcat(temp.pszCmdLine, " %a");852 }853 WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title);854 if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT))855 temp.flags = 0;856 else if (WinQueryButtonCheckstate(hwnd, CMD_FULLSCREEN))857 temp.flags = FULLSCREEN;858 else if (WinQueryButtonCheckstate(hwnd, CMD_MINIMIZED))859 temp.flags = MINIMIZED;860 else if (WinQueryButtonCheckstate(hwnd, CMD_MAXIMIZED))861 temp.flags = MAXIMIZED;862 else if (WinQueryButtonCheckstate(hwnd, CMD_INVISIBLE))863 temp.flags = INVISIBLE;864 if (WinQueryButtonCheckstate(hwnd, CMD_KEEP))865 temp.flags |= KEEP;866 if (WinQueryButtonCheckstate(hwnd, CMD_PROMPT))867 temp.flags |= PROMPT;868 if (WinQueryButtonCheckstate(hwnd, CMD_ONCE))869 temp.flags |= ONCE;870 if (fCancelAction){871 fCancelAction = FALSE;872 free(temp.pszCmdLine);873 break;874 }875 else876 info = add_command(&temp);877 if (!info) {878 saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),879 GetPString(IDS_CANTADDCOMMANDTEXTDUP), temp.title);880 }881 else {882 CHAR env[1002];883 884 *env = 0;885 WinQueryDlgItemText(hwnd, CMD_ENVIRON, 1000, env);886 bstripcr(env);887 if (*env) {888 PrfWriteProfileString(fmprof, FM3Str, temp.title, env);889 }890 x = (SHORT) WinSendDlgItemMsg(hwnd,891 CMD_LISTBOX,892 LM_INSERTITEM,893 MPFROM2SHORT(LIT_END, 0),894 MPFROMP(temp.title));895 if (x >= 0) {896 WinSendDlgItemMsg(hwnd,897 CMD_LISTBOX,898 LM_SETITEMHANDLE,899 MPFROMSHORT(x), MPFROMP(info));900 WinSendDlgItemMsg(hwnd,901 CMD_LISTBOX,902 LM_SELECTITEM,903 MPFROMSHORT(x), MPFROMSHORT(TRUE));904 save_commands();905 }906 }907 free(temp.pszCmdLine);908 }909 990 break; 910 991 911 992 case CMD_DELETE: 912 993 { 913 CHAR temp[100]; 994 CHAR temp[100]; 995 CHAR keyID[120]; 996 CHAR keyHotKeyID[120]; 997 CHAR keyenv[120]; 914 998 915 999 WinQueryDlgItemText(hwnd, CMD_TITLE, 100, temp); 916 bstrip(temp); 917 PrfWriteProfileString(fmprof, FM3Str, temp, NULL); 1000 bstripcr(temp); 1001 sprintf(keyID, "COMMAND.%sID", temp); 1002 sprintf(keyHotKeyID, "COMMAND.%sHotKeyID", temp); 1003 sprintf(keyenv, "COMMAND.%senv", temp); 1004 PrfWriteProfileData(fmprof, FM3Str, keyID, NULL, NULL); 1005 PrfWriteProfileData(fmprof, FM3Str, keyHotKeyID, NULL, NULL); 1006 PrfWriteProfileString(fmprof, FM3Str, keyenv, NULL); 918 1007 if (!kill_command(temp)) 919 1008 Runtime_Error(pszSrcFile, __LINE__, "kill_command"); … … 932 1021 MPFROMSHORT(LIT_NONE), MPFROMSHORT(FALSE)); 933 1022 } 934 1023 save_commands(); 935 1024 } 936 1025 } … … 942 1031 COMMAND temp; 943 1032 APIRET ret; 1033 CHAR keyID[120]; 1034 CHAR keyHotKeyID[120]; 1035 CHAR keyenv[120]; 1036 CHAR env[1002]; 1037 INT ID = 0; 1038 INT HotKeyID = 0; 1039 ULONG size; 944 1040 945 1041 pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__); … … 976 1072 MPFROMSHORT(LIT_CURSOR), MPVOID); 977 1073 WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title); 978 bstrip(temp.title); 979 PrfWriteProfileString(fmprof, FM3Str, temp.title, NULL); 1074 bstripcr(temp.title); 1075 sprintf(keyID, "COMMAND.%sID", temp.title); 1076 sprintf(keyHotKeyID, "COMMAND.%sHotKeyID", temp.title); 1077 sprintf(keyenv, "COMMAND.%senv", temp.title); 1078 PrfQueryProfileData(fmprof, FM3Str, keyID, &ID, &size); 1079 PrfQueryProfileData(fmprof, FM3Str, keyHotKeyID, &HotKeyID, &size); 1080 PrfQueryProfileString(fmprof, FM3Str, keyenv, NullStr, env, sizeof(env)); 1081 temp.ID = ID; 1082 temp.HotKeyID = HotKeyID; 1083 if (env != NullStr) 1084 strcpy(temp.env, env); 1085 PrfWriteProfileData(fmprof, FM3Str, keyID, NULL, NULL); 1086 PrfWriteProfileData(fmprof, FM3Str, keyHotKeyID, NULL, NULL); 1087 PrfWriteProfileString(fmprof, FM3Str, keyenv, NULL); 980 1088 if (kill_command(temp.title)){ 981 1089 x = (SHORT) WinSendDlgItemMsg(hwnd, … … 993 1101 } 994 1102 } // then do an add 995 if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT)) 1103 temp.flags = CheckExecutibleFlags(hwnd, 3); 1104 /*if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT)) 996 1105 temp.flags = 0; 997 1106 else if (WinQueryButtonCheckstate(hwnd, CMD_FULLSCREEN)) … … 1008 1117 temp.flags |= PROMPT; 1009 1118 if (WinQueryButtonCheckstate(hwnd, CMD_ONCE)) 1010 temp.flags |= ONCE; 1119 temp.flags |= ONCE;*/ 1120 *env = 0; 1121 WinQueryDlgItemText(hwnd, CMD_ENVIRON, 1000, env); 1122 bstripcr(env); 1123 if (*env) 1124 strcpy(temp.env, env); 1125 if (!*env && temp.env != NullStr) 1126 strcpy(temp.env, NullStr); 1011 1127 info = add_command(&temp); 1012 1128 if (!info) { … … 1017 1133 1018 1134 else { 1019 CHAR env[1002]; 1020 1021 *env = 0; 1022 WinQueryDlgItemText(hwnd, CMD_ENVIRON, 1000, env); 1023 bstripcr(env); 1024 if (*env) { 1025 PrfWriteProfileString(fmprof, FM3Str, temp.title, env); 1026 } //put item back in original place 1135 //put item back in original place 1027 1136 x = (SHORT) WinSendDlgItemMsg(hwnd, 1028 1137 CMD_LISTBOX, … … 1089 1198 LINKCMDS *info; 1090 1199 1091 DbgMsg(pszSrcFile, __LINE__,"ID %i", cx);1092 1200 list = BuildList(hwnd); 1093 1201 x = 0; 1094 1202 info = cmdhead; 1095 1203 while (info) { 1096 //x++;1097 1204 if (cx < 4300) { 1098 1205 if (info->ID == cx) … … 1108 1215 1109 1216 INT flags; 1110 CHAR env[1002];1111 1217 1112 1218 x--; … … 1119 1225 flags |= SEPARATE; 1120 1226 flags &= ~(KEEP | DIEAFTER); 1121 PrfQueryProfileString(fmprof, FM3Str, info->title, NullStr, env, sizeof(env));1122 1227 if (!strchr(info->pszCmdLine, '%')) { 1123 1228 CHAR *fakelist[2]; … … 1127 1232 ExecOnList(hwnd, 1128 1233 info->pszCmdLine, 1129 flags, env, fakelist, GetPString(IDS_EXECCMDTITLETEXT), 1234 flags, info->env != NullStr ? info->env : NULL, 1235 fakelist, GetPString(IDS_EXECCMDTITLETEXT), 1130 1236 pszSrcFile, __LINE__); 1131 1237 } … … 1141 1247 ExecOnList(hwnd, 1142 1248 info->pszCmdLine, 1143 flags, env, fakelist, GetPString(IDS_EXECCMDTITLETEXT), 1249 flags, info->env != NullStr ? info->env : NULL, 1250 fakelist, GetPString(IDS_EXECCMDTITLETEXT), 1144 1251 pszSrcFile, __LINE__); 1145 1252 } … … 1148 1255 ExecOnList(hwnd, 1149 1256 info->pszCmdLine, 1150 flags, env, list, GetPString(IDS_EXECCMDTITLETEXT), 1257 flags, info->env != NullStr ? info->env : NULL, 1258 list, GetPString(IDS_EXECCMDTITLETEXT), 1151 1259 pszSrcFile, __LINE__); 1152 1260 else
Note:
See TracChangeset
for help on using the changeset viewer.