Changeset 1486 for trunk/dll/command.c
- Timestamp:
- Dec 17, 2009, 1:36:04 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/command.c
r1398 r1486 65 65 { 66 66 PSZ pszCmdLine; 67 INT flags;68 67 CHAR title[100]; 68 ULONG flags; 69 ULONG ID; 70 ULONG HotKeyID; 69 71 } 70 72 COMMAND; … … 75 77 static PSZ pszSrcFile = __FILE__; 76 78 static LINKCMDS *cmdtail; 79 static INT CommandDatVersion = 0; 77 80 78 81 #pragma data_seg(GLOBAL2) 79 82 LINKCMDS *cmdhead; 80 83 BOOL cmdloaded; 84 BOOL UsedCommandIDs[300]; 85 BOOL UsedHotKeyIDs[20]; 81 86 82 87 MRESULT EXPENTRY CommandTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) … … 344 349 LINKCMDS *info; 345 350 PSZ pszCmdLine; 351 CHAR *p; 346 352 CHAR title[100]; 347 353 CHAR flags[34]; 354 CHAR ID[34]; 355 CHAR HotKeyID[34]; 348 356 349 357 if (cmdhead) … … 355 363 fp = _fsopen(pszCmdLine, "r", SH_DENYWR); 356 364 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 } 357 374 while (!feof(fp)) { 358 375 if (!xfgets_bstripcr(title, sizeof(title), fp, pszSrcFile, __LINE__)) … … 365 382 if (!xfgets_bstripcr(flags, sizeof(flags), fp, pszSrcFile, __LINE__)) 366 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 } 367 392 pszCmdLine[strlen(pszCmdLine)] = 0; // fixme to know why chopped this way? 368 393 //bstripcr(pszCmdLine); … … 380 405 info->title = xstrdup(title, pszSrcFile, __LINE__); 381 406 info->flags = atol(flags); 407 if (CommandDatVersion) { 408 info->ID = atol(ID); 409 info->HotKeyID = atol(HotKeyID); 410 } 382 411 if (!info->pszCmdLine || !info->title) { 383 412 xfree(info->pszCmdLine, pszSrcFile, __LINE__); … … 412 441 FILE *fp; 413 442 CHAR s[CCHMAXPATH + 14]; 443 INT x = 0; 414 444 415 445 if (!cmdloaded || !cmdhead) … … 421 451 fp = xfopen(s, "w", pszSrcFile, __LINE__); 422 452 if (fp) { 453 //Adds line for version tracking 454 fprintf(fp,"Version 2\n"); 423 455 fputs(GetPString(IDS_COMMANDFILETEXT), fp); 424 456 info = cmdhead; 425 457 while (info) { 426 fprintf(fp, 427 ";\n%0.99s\n%0.*s\n%lu\n", 428 info->title, MaxComLineStrg, info->pszCmdLine, info->flags); 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); 475 x++; 429 476 info = info->next; 430 } 477 } // while 478 PrfWriteProfileData(fmprof, FM3Str, "UsedCommandIDs", &UsedCommandIDs, 479 sizeof(BOOL) * 300); 480 PrfWriteProfileData(fmprof, FM3Str, "UsedHotKeyIDs", &UsedHotKeyIDs, 481 sizeof(BOOL) * 20); 431 482 fclose(fp); 432 } 483 } // if (fp) 433 484 } 434 485 435 486 //== add_command() Add command to list == 436 487 437 LINKCMDS *add_command(COMMAND * 488 LINKCMDS *add_command(COMMAND *addme) 438 489 { 439 490 LINKCMDS *info; 491 ULONG size; 492 INT x; 440 493 441 494 if (!addme || !*addme->pszCmdLine || !*addme->title) … … 452 505 info->pszCmdLine = xstrdup(addme->pszCmdLine, pszSrcFile, __LINE__); 453 506 info->title = xstrdup(addme->title, pszSrcFile, __LINE__); 507 info->HotKeyID = addme->HotKeyID; 508 if (!info->ID) { 509 PrfQueryProfileData(fmprof, FM3Str, "UsedCommandIDs", &UsedCommandIDs, 510 &size); //profile updated by save_commands 511 for (x = 0; x < 300; x++) { 512 if (!UsedCommandIDs[x]) { 513 info->ID = IDM_COMMANDSTART + x; 514 break; 515 } 516 } 517 } 454 518 if (addme->flags) 455 519 info->flags = addme->flags; 456 if (!info->pszCmdLine || !info->title ) {520 if (!info->pszCmdLine || !info->title || !info->ID) { 457 521 xfree(info->pszCmdLine, pszSrcFile, __LINE__); 458 522 xfree(info->title, pszSrcFile, __LINE__); … … 479 543 while (info) { 480 544 if (!stricmp(info->title, killme)) { 545 UsedCommandIDs[info->ID - IDM_COMMANDSTART] = FALSE; 546 if (info->HotKeyID) 547 UsedHotKeyIDs[info->HotKeyID - IDM_COMMANDNUM0] = FALSE; 481 548 if (info == cmdhead) { 482 549 cmdhead = info->next; … … 818 885 bstripcr(env); 819 886 if (*env) { 820 PrfWriteProfileString(fmprof, FM3Str, temp. pszCmdLine, env);887 PrfWriteProfileString(fmprof, FM3Str, temp.title, env); 821 888 } 822 889 x = (SHORT) WinSendDlgItemMsg(hwnd, … … 846 913 847 914 WinQueryDlgItemText(hwnd, CMD_TITLE, 100, temp); 848 bstrip(temp); 915 bstrip(temp); 916 PrfWriteProfileString(fmprof, FM3Str, temp, NULL); 849 917 if (!kill_command(temp)) 850 918 Runtime_Error(pszSrcFile, __LINE__, "kill_command"); … … 908 976 WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title); 909 977 bstrip(temp.title); 978 PrfWriteProfileString(fmprof, FM3Str, temp.title, NULL); 910 979 if (kill_command(temp.title)){ 911 980 x = (SHORT) WinSendDlgItemMsg(hwnd, … … 953 1022 bstripcr(env); 954 1023 if (*env) { 955 PrfWriteProfileString(fmprof, FM3Str, temp. pszCmdLine, env);1024 PrfWriteProfileString(fmprof, FM3Str, temp.title, env); 956 1025 } //put item back in original place 957 1026 x = (SHORT) WinSendDlgItemMsg(hwnd, … … 1019 1088 LINKCMDS *info; 1020 1089 1090 DbgMsg(pszSrcFile, __LINE__,"ID %i", cx); 1021 1091 list = BuildList(hwnd); 1022 1092 x = 0; 1023 1093 info = cmdhead; 1024 1094 while (info) { 1025 x++; 1026 if (x == cx) 1027 break; 1095 //x++; 1096 if (cx < 4300) { 1097 if (info->ID == cx) 1098 break; 1099 } 1100 else { 1101 if (info->HotKeyID == cx) 1102 break; 1103 } 1028 1104 info = info->next; 1029 1105 } … … 1031 1107 1032 1108 INT flags; 1109 CHAR env[1002]; 1033 1110 1034 1111 x--; … … 1041 1118 flags |= SEPARATE; 1042 1119 flags &= ~(KEEP | DIEAFTER); 1120 PrfQueryProfileString(fmprof, FM3Str, info->title, NullStr, env, sizeof(env)); 1043 1121 if (!strchr(info->pszCmdLine, '%')) { 1044 1122 CHAR *fakelist[2]; … … 1048 1126 ExecOnList(hwnd, 1049 1127 info->pszCmdLine, 1050 flags, NULL, fakelist, GetPString(IDS_EXECCMDTITLETEXT),1128 flags, env, fakelist, GetPString(IDS_EXECCMDTITLETEXT), 1051 1129 pszSrcFile, __LINE__); 1052 1130 } … … 1062 1140 ExecOnList(hwnd, 1063 1141 info->pszCmdLine, 1064 flags, NULL, fakelist, GetPString(IDS_EXECCMDTITLETEXT),1142 flags, env, fakelist, GetPString(IDS_EXECCMDTITLETEXT), 1065 1143 pszSrcFile, __LINE__); 1066 1144 } … … 1069 1147 ExecOnList(hwnd, 1070 1148 info->pszCmdLine, 1071 flags, NULL, list, GetPString(IDS_EXECCMDTITLETEXT),1149 flags, env, list, GetPString(IDS_EXECCMDTITLETEXT), 1072 1150 pszSrcFile, __LINE__); 1073 1151 else
Note:
See TracChangeset
for help on using the changeset viewer.