Changeset 909 for trunk/dll/command.c


Ignore:
Timestamp:
Jan 6, 2008, 9:02:31 PM (18 years ago)
Author:
Gregg Young
Message:

Added quoting code to commands, associations and avv; Minor clean up and fixed one problem with quoting logic; Added warning re %a for commands to work on selected files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/command.c

    r907 r909  
    568568        if (insert_filename(hwnd, filename, 2, FALSE) && *filename) {
    569569          BldQuotedFileName(szfilename, filename);
    570           strcat(szfilename, " %a");
    571570          WinSetDlgItemText(hwnd, CMD_CL, szfilename);
    572571        }
     
    620619      }
    621620      {
    622         COMMAND temp;
     621        COMMAND temp;
     622        char *psz[1002];
     623        APIRET ret;
    623624
    624625        memset(&temp, 0, sizeof(COMMAND));
    625626        WinQueryDlgItemText(hwnd, CMD_CL, sizeof(temp.cl), temp.cl);
    626         bstrip(temp.cl);
     627        *psz = CheckApp_QuoteAddExe(temp.cl);
     628        memcpy(temp.cl, *psz, strlen(*psz) + 1);
     629        if (!strchr(temp.cl, '%')){
     630          ret = saymsg(MB_YESNO,
     631                       HWND_DESKTOP,
     632                       NullStr,
     633                       GetPString(IDS_TOACTONSELECTEDTEXT));
     634          if (ret == MBID_YES)
     635            strcat(temp.cl, " %a");
     636        }
    627637        WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title);
    628638        if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT))
     
    641651          temp.flags |= PROMPT;
    642652        if (WinQueryButtonCheckstate(hwnd, CMD_ONCE))
    643           temp.flags |= ONCE;
    644         info = add_command(&temp);
    645         if (!info)
     653          temp.flags |= ONCE;
     654        if (fCancelAction){
     655          fCancelAction = FALSE;
     656          break;
     657        }
     658        else
     659          info = add_command(&temp);
     660        if (!info)
    646661        {
    647662          WinDismissDlg(hwnd, 0);
     
    698713    case CMD_ADD:
    699714      {
    700         COMMAND temp;
     715        COMMAND temp;
     716        CHAR *psz[1002];
     717        APIRET ret;
    701718
    702719        memset(&temp, 0, sizeof(COMMAND));
    703720        WinQueryDlgItemText(hwnd, CMD_CL, sizeof(temp.cl), temp.cl);
    704         bstrip(temp.cl);
     721        *psz = CheckApp_QuoteAddExe(temp.cl);
     722        memcpy(temp.cl, *psz, strlen(*psz) + 1);
     723        if (!strchr(temp.cl, '%')){
     724          ret = saymsg(MB_YESNO,
     725                       HWND_DESKTOP,
     726                       NullStr,
     727                       GetPString(IDS_TOACTONSELECTEDTEXT));
     728          if (ret == MBID_YES)
     729            strcat(temp.cl, " %a");
     730        }
    705731        WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title);
    706732        if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT))
     
    719745          temp.flags |= PROMPT;
    720746        if (WinQueryButtonCheckstate(hwnd, CMD_ONCE))
    721           temp.flags |= ONCE;
    722         info = add_command(&temp);
     747          temp.flags |= ONCE;
     748        if (fCancelAction){
     749          fCancelAction = FALSE;
     750          break;
     751        }
     752        else
     753          info = add_command(&temp);
    723754        if (!info) {
    724755          saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
     
    781812      break;
    782813    case CMD_REPLACE:
    783       {
    784         CHAR temp[34];
     814      { //Delete first
     815        char *psz[1002];
     816        COMMAND temp;
     817        APIRET ret;
     818
     819        memset(&temp, 0, sizeof(COMMAND));
     820        WinQueryDlgItemText(hwnd, CMD_CL, sizeof(temp.cl), temp.cl);
     821        *psz = CheckApp_QuoteAddExe(temp.cl);
     822        memcpy(temp.cl, *psz, strlen(*psz) + 1);
     823        if (fCancelAction){
     824          fCancelAction = FALSE;
     825          break;
     826        }
     827        if (!strchr(temp.cl, '%')){
     828          ret = saymsg(MB_YESNO,
     829                       HWND_DESKTOP,
     830                       NullStr,
     831                       GetPString(IDS_TOACTONSELECTEDTEXT));
     832          if (ret == MBID_YES)
     833            strcat(temp.cl, " %a");
     834        }
     835        //remember item location in the list
    785836        y = (SHORT) WinSendDlgItemMsg(hwnd,
    786                                         CMD_LISTBOX,
    787                                         LM_QUERYSELECTION,
    788                                         MPFROMSHORT(LIT_CURSOR), MPVOID);
    789         WinQueryDlgItemText(hwnd, CMD_TITLE, 34, temp);
    790         bstrip(temp);
    791         if (kill_command(temp))
    792            {
     837                                      CMD_LISTBOX,
     838                                      LM_QUERYSELECTION,
     839                                      MPFROMSHORT(LIT_CURSOR), MPVOID);
     840        WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title);
     841        bstrip(temp.title);
     842        if (kill_command(temp.title)){
    793843          x = (SHORT) WinSendDlgItemMsg(hwnd,
    794844                                        CMD_LISTBOX,
     
    804854                              MPFROMSHORT(LIT_NONE), MPFROMSHORT(FALSE));
    805855          }
    806           save_commands();
    807         }
    808       }
    809       {
    810         COMMAND temp;
    811 
    812         memset(&temp, 0, sizeof(COMMAND));
    813         WinQueryDlgItemText(hwnd, CMD_CL, sizeof(temp.cl), temp.cl);
    814         bstrip(temp.cl);
    815         WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title);
    816         if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT))
    817           temp.flags = 0;
    818         else if (WinQueryButtonCheckstate(hwnd, CMD_FULLSCREEN))
    819           temp.flags = FULLSCREEN;
    820         else if (WinQueryButtonCheckstate(hwnd, CMD_MINIMIZED))
    821           temp.flags = MINIMIZED;
    822         else if (WinQueryButtonCheckstate(hwnd, CMD_MAXIMIZED))
    823           temp.flags = MAXIMIZED;
    824         else if (WinQueryButtonCheckstate(hwnd, CMD_INVISIBLE))
    825           temp.flags = INVISIBLE;
    826         if (WinQueryButtonCheckstate(hwnd, CMD_KEEP))
    827           temp.flags |= KEEP;
    828         if (WinQueryButtonCheckstate(hwnd, CMD_PROMPT))
    829           temp.flags |= PROMPT;
    830         if (WinQueryButtonCheckstate(hwnd, CMD_ONCE))
    831           temp.flags |= ONCE;
    832         info = add_command(&temp);
    833         if (!info) {
     856        } // then do an add
     857        if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT))
     858          temp.flags = 0;
     859        else if (WinQueryButtonCheckstate(hwnd, CMD_FULLSCREEN))
     860          temp.flags = FULLSCREEN;
     861        else if (WinQueryButtonCheckstate(hwnd, CMD_MINIMIZED))
     862          temp.flags = MINIMIZED;
     863        else if (WinQueryButtonCheckstate(hwnd, CMD_MAXIMIZED))
     864          temp.flags = MAXIMIZED;
     865        else if (WinQueryButtonCheckstate(hwnd, CMD_INVISIBLE))
     866          temp.flags = INVISIBLE;
     867        if (WinQueryButtonCheckstate(hwnd, CMD_KEEP))
     868          temp.flags |= KEEP;
     869        if (WinQueryButtonCheckstate(hwnd, CMD_PROMPT))
     870          temp.flags |= PROMPT;
     871        if (WinQueryButtonCheckstate(hwnd, CMD_ONCE))
     872          temp.flags |= ONCE;
     873        info = add_command(&temp);
     874        if (!info) {
    834875          saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
    835                  GetPString(IDS_CANTADDCOMMANDTEXT),
    836                  temp.title);
    837         }
     876                 GetPString(IDS_CANTADDCOMMANDTEXT),
     877                 temp.title);
     878          }
     879
    838880        else {
    839881          CHAR env[1002];
     
    844886          if (*env) {
    845887            PrfWriteProfileString(fmprof, FM3Str, temp.cl, env);
    846           }
     888          } //put item back in original place
    847889          x = (SHORT) WinSendDlgItemMsg(hwnd,
    848890                                        CMD_LISTBOX,
     
    850892                                        MPFROM2SHORT(y, 0),
    851893                                        MPFROMP(temp.title));
    852           if (x >= 0) {
     894          if (x >= 0) {
     895            LINKCMDS *temphead = NULL,*last = NULL, *temptail = NULL;
     896            SHORT numitems, sSelect = 0;
     897
    853898            WinSendDlgItemMsg(hwnd,
    854899                              CMD_LISTBOX,
     
    859904                              LM_SELECTITEM,
    860905                              MPFROMSHORT(x), MPFROMSHORT(TRUE));
    861             {
    862             LINKCMDS *temphead = NULL, *info, *last = NULL, *temptail = NULL;
    863         SHORT sSelect, numitems;
    864 
    865         sSelect = 0;
    866         numitems = (SHORT) WinSendDlgItemMsg(hwnd, CMD_LISTBOX,
    867                                              LM_QUERYITEMCOUNT,
    868                                              MPVOID, MPVOID);
    869         while (numitems) {
    870           info = (LINKCMDS *) WinSendDlgItemMsg(hwnd, CMD_LISTBOX,
    871                                                 LM_QUERYITEMHANDLE,
    872                                                 MPFROMSHORT(sSelect++),
    873                                                 MPVOID);
    874           if (info) {
    875             if (!temphead) {
    876               temphead = info;
    877               info->prev = NULL;
    878             }
    879             else {
    880               last->next = info;
    881               info->prev = last;
    882             }
    883             temptail = info;
    884             last = info;
    885             info->next = NULL;
    886           }
    887           numitems--;
     906            //then reorder
     907            numitems = (SHORT) WinSendDlgItemMsg(hwnd, CMD_LISTBOX,
     908                                                 LM_QUERYITEMCOUNT,
     909                                                 MPVOID, MPVOID);
     910
     911            while (numitems) {
     912
     913
     914              info = (LINKCMDS *) WinSendDlgItemMsg(hwnd, CMD_LISTBOX,
     915                                                    LM_QUERYITEMHANDLE,
     916                                                    MPFROMSHORT(sSelect++),
     917                                                    MPVOID);
     918              if (info) {
     919                if (!temphead) {
     920                  temphead = info;
     921                  info->prev = NULL;
     922                }
     923                else {
     924                  last->next = info;
     925                  info->prev = last;
     926                }
     927                temptail = info;
     928                last = info;
     929                info->next = NULL;
     930              }
     931              numitems--;
     932            }
     933            cmdhead = temphead;
     934            cmdtail = temptail;
     935            save_commands();
     936          }
    888937        }
    889             }
    890             save_commands();
    891           }
    892         }
    893938      }
    894939      break;
Note: See TracChangeset for help on using the changeset viewer.