⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ovwin.c

📁 汇编语言编的关于ov143b.asm的小程序
💻 C
📖 第 1 页 / 共 3 页
字号:
   else                                /* or de-highlight empty dir msg */
      disp_empty_msg(0);

   wincpy(curwin,&cw);                 /* switch to new window */
   wincpy(&cw,curwin = newp);

   restorefiles(cw.save_files,cw.nfiles); /* get new windows files[] entries */

   if (cw.nfiles)                      /* select current item in new window */
      fp_on(cw.curidx);
   else                                /* or highlight empty dir msg */
      disp_empty_msg(1);

   if (change_dir(cw.dirbuf) != 0)     /* switch to the window's directory */
      show_error(SHOW_DOS,0,1,noaccess);

   update_header();               /* make volume, dir, file, tag info correct */
}


/*****************************************************************************
                          A D D 2 W I N D O W S
 *****************************************************************************/

add2windows(todir,tofn,fp)     /* add file to any windows showing dest dir */
FILE_ENT *fp;
char *todir, *tofn;
{
   tdir = Strdup(todir);       /* save dir and fn in var's for addfile_ent */
   tname = Strdup(tofn);

   holdf = *fp;                /* save file_ent 'cause files[] is changed */
   holdf.flags &= ~TAGGED;     /* we don't want the tagged flag */

   scanwindows(addfile_ent);   /* add the file_ent to all matching windows */

   free(tdir);                 /* local strings alloc'd because callers tend */
   free(tname);                /* to use strings in files[] which is swapped */
}


/*****************************************************************************
                          D E L F R O M W I N S
 *****************************************************************************/

delfromwins(fromdir,fromfn)  /* delete file from all windows showing dest dir */
char *fromdir, *fromfn;
{

   tdir = Strdup(fromdir);     /* save target dir and name in var's */
   tname = Strdup(fromfn);     /*   for delfile_ent */

   scanwindows(delfile_ent);   /* delete the file_ent from all windows */

   free(tdir);                 /* local strings alloc'd because callers tend */
   free(tname);                /* to use strings in files[] which is swapped */
}


/****************************************************************************
                          A D D F I L E _ E N T
 ****************************************************************************/

static int
addfile_ent() {        /* add a FILE_ENT to target windows */

   register int i;
   register FILE_ENT *tfp;

   /* if the current window displays the target dir or the target drive
      in showall mode, add the file ent to it */

   if (stricmp(cw.dirbuf,tdir) == 0 || (cw.showall && *cw.dirbuf == *tdir)) {

      /* don't add the file if it doesn't match the selection criteria */

      if ((cw.selatrs & holdf.flags) != holdf.flags ||
          (*cw.mask && (cw.maskcmp != match_name(holdf.name,cw.mask))))
         return;

      if (numwin > 1)                       /* make sure files[] is ok */
         restorefiles(cw.save_files,cw.nfiles);

      /* see if there is an existing file by that name in the target dir */

      for (i = 0, tfp = files; i < cw.nfiles; i++, tfp++)
          if (stricmp(tname,tfp->name) == 0 && stricmp(tdir,tfp->dirp) == 0)
             break;

      if (i < cw.nfiles) {          /* back out info for an existing  */
         delent(tfp);               /* file by the same name          */
         packfiles();               /* pack files[] now, not later    */
         if (i < cw.curidx)         /* adjust current file pointer if */
            cw.curidx--;            /* deleted file before current    */
      }

      /* modify holding file entry to its final form */

      strncpy(holdf.name,tname,sizeof(holdf.name));        /* file name */
      holdf.dirp = cw.showall ? findir(tdir) : cw.dirbuf;  /* file's dir */
      holdf.index = cw.nfiles+1;                           /* a guess */

      /* add file to files[] if there is room */

      if (cw.nfiles < MAX_FILES) {

         /* since the files may be sorted by something other than name (say
            date for example) we need to scan files[] again to find where to
            insert the new entry - I used to just sort files[] again but qsort
            is way to slow when files[] is already almost sorted */

         for (i = cw.nfiles, tfp = files; i; i--, tfp++)
             if ((*cw.sortfunc)(&holdf,tfp) < 0)
                break;

         /* i > 0 if entry needs to be inserted, i = 0 if at end */

         if (i)
            memcpy((char *)(tfp+1),(char *)tfp,i*sizeof(FILE_ENT));

         *tfp = holdf;                 /* finally, add entry */
         cw.nfiles++;                  /* there is one more file now */
         cw.num_files++;
         cw.files_size += tfp->size;   /* taking this much more space */
         cw.updated = W_DISP;          /* win needs redisplay (not packing) */
         winupdate++;                  /* some window needs redisplay */

         if (tfp < &files[cw.curidx])  /* bump current file pointer if added */
            cw.curidx++;               /* file is before current file        */

         if (numwin > 1)
            savefiles(cw.save_files,cw.nfiles);
      }
   }
}


/****************************************************************************
                          D E L F I L E _ E N T
 ****************************************************************************/

static int
delfile_ent() {        /* delete a FILE_ENT from target windows */

   register int i;
   register FILE_ENT *tfp;

   /* if the current window displays the target dir or the target drive
      in showall mode, delete the file ent */

   if (stricmp(cw.dirbuf,tdir) == 0 || (cw.showall && *cw.dirbuf == *tdir)) {

      if (numwin > 1)                       /* make sure files[] is ok */
         restorefiles(cw.save_files,cw.nfiles);

      /* see if there is an existing file by that name in the target dir */

      for (i = 0, tfp = files; i < cw.nfiles; i++, tfp++)
          if (stricmp(tname,tfp->name) == 0 && stricmp(tdir,tfp->dirp) == 0)
             break;

      if (i < cw.nfiles) {          /* back out info for an existing */
         delent(tfp);               /* file by the same name         */
         winupdate++;               /* window needs redisplay        */
         cw.updated |= W_PACK;      /* files[] needs to be packed    */
         if (i < cw.curidx)         /* move file pointer if deleted  */
            cw.curidx--;            /* file is before current        */
         if (numwin > 1)
            savefiles(cw.save_files,cw.nfiles);
      }
   }
}


/*****************************************************************************
                                D E L E N T
 *****************************************************************************/

delent(fp)             /* remove an entry from files[] */
register FILE_ENT *fp;
{
   /* Note: this routine changes cw.num_files, but it doesn't change
      cw.nfiles - this is because the routine packfiles which should
      be called shortly needs the old value of cw.nfiles */

   cw.num_files--;                     /* one fewer file */
   cw.files_size -= fp->size;          /* that much space not used */
   if (fp->flags & TAGGED) {           /* was file tagged? */
      cw.num_tagged--;                 /* one less tagged file */
      cw.tag_size -= fp->size;         /* this space not tagged now */
   }
   *fp->name = '\0';                   /* mark this entry as deleted */
}


/****************************************************************************
                          S C A N W I N D O W S
 ****************************************************************************/

static int ALTCALL
scanwindows(func)      /* scan windows, call func for each one */
int (*func)();
{
   int i;
   register WINDOW *wp;

   /* if there is a list of windows, start with the 1st; switch if not there */

   if (numwin > 1) {
      wincpy(curwin,&cw);                      /* save current window if > 1 */
      savefiles(cw.save_files,cw.nfiles);
      if (curwin != winlis) {                  /* temp switch to top window */
         wincpy(&cw,winlis);
      }
   }

   /* Note: only the files for the original window are saved and restored,
      callers func should restore/savefiles if it needs to */

   for (i = numwin, wp = winlis; i; i--) {     /* check each file window */

      winp = wp;               /* let func know which window it is */

      (*func)();               /* invoke callers func with this window */

      if (numwin > 1) {        /* advance to next window if there is one */
         wincpy(wp,&cw);
         wincpy(&cw,wp = cw.next);
      }
   }

   if (numwin > 1) {           /* restore the current window if > 1 */
      wincpy(&cw,curwin);
      restorefiles(cw.save_files,cw.nfiles);
   }
}


/******************************************************************************
 **                             R E N E W                                    **
 *****************************************************************************/

renew() {              /* renew the file display */

   getcwd(cw.dirbuf,MAX_PATHLEN);        /* reinit drive/dir info incase */
   initdrive(*cw.dirbuf);                /*   it changed somehow */

   getfiles();                         /* reread the directory */
   setup_file_scr();                   /* display the static screen image */
   update_header();                    /* update header info */
   refresh_screen(0);                  /* redisplay all file data */
}


/******************************************************************************
                        R E N E W _ W I N D O W
 *****************************************************************************/

renew_window() {       /* renew the current window display */

   getfiles();                         /* reload the files[] structure */
   adjust_window();                    /* resize window data */
   update_header();                    /* update the header  */
   update_window(1);                   /* and the window data */
}


/******************************************************************************
                          R E F R E S H _ S C R E E N
 *****************************************************************************/

refresh_screen(wup)    /* (re)initialize the total file data display */
int wup;
{
   win_update = wup;          /* save wup in static for refresh_window */

   if (inwin && wup == 0)     /* display the info header if needed */
      infohead();

   scanwindows(refresh_window);        /* redisplay each window */
}

/*****************************************************************************
                        R E F R E S H _ W I N D O W
 *****************************************************************************/

static int
refresh_window() {     /* refresh one window - called by scanwindows */

   if (numwin > 1)
      restorefiles(cw.save_files,cw.nfiles);

   if (win_update && cw.updated) {     /* is this a window update call? */
      if (cw.updated & W_PACK)
         packfiles();
      if (numwin > 1)
         savefiles(cw.save_files,cw.nfiles);
   }

   /* redisplay this window if not a win_update call or win_update call and
      this window has been modified */

   if (!win_update || cw.updated) {
      adjust_window();                 /* calculate display parameters */
      update_window(winp == curwin);   /* update display window */
      cw.updated = 0;                  /* doesn't need to be updated again */
   }
}


/******************************************************************************
                    U P D A T E _ V O L _ S T A T S
 ******************************************************************************/

update_vol_stats() {   /* get and display volume statistics */

   getvolsiz(*cw.dirbuf,&cw.drivep->vol_size,&cw.drivep->vol_free,
             &cw.drivep->clustersiz);
   disp_vol_stats();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -