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

📄 ovwin.c

📁 汇编语言编的关于ov143b.asm的小程序
💻 C
📖 第 1 页 / 共 3 页
字号:
/*  037  23-May-87  ovwin.c

        Copyright (c) 1987 by Blue Sky Software.  All rights reserved.
*/

#include <setjmp.h>
#include <dos.h>
#include "ov.h"
#include "overr.h"
#include "direct.h"
#include "strmem.h"

#define V_bar (0xba)
#define H_bar (0xcd)

int diridx = 0;                        /* # dir names when showall */
char **dirlst = NULL;                  /* ptr to dir name ptrs when showall */

static int win_update;                         /* NZ if refresh_screen update */
static unsigned char inwin = 0;                /* # active info windows */
static unsigned char numwin = 1;               /* # active windows */
static WINDOW *curwin = NULL, *winlis = NULL, *winp;

static char *tdir;                             /* target dir */
static char *tname;                            /* target name */
static FILE_ENT holdf;                         /* save file_ent */

static char *nomem = "Insufficient memory for another window, no window created!";
static char *noaccess = "Unable to access specified directory: ";

extern WINDOW cw;
extern int winupdate;
extern FILE_ENT files[];
extern unsigned dataseg;
extern jmp_buf back_to_main;
extern unsigned char anyshowall;

char far *malloc_f();
int ALTCALL scanwindows(), ALTCALL win_switch();
int addfile_ent(), delfile_ent(), refresh_window();
char *strrchr(), *strchr(), *parsepath(), *findir();
int ALTCALL wincpy(WINDOW *, WINDOW *), ALTCALL disp_empty_msg(int);
int ALTCALL savefiles(char far *, int), ALTCALL restorefiles(char far *, int);

/******************************************************************************
 **                         W I N _ O P E N                                  **
 *****************************************************************************/

win_open() {           /* open another file name display window */

   register WINDOW *wp;

   /* make sure the current window is large enough to split */

   if (cw.wrows < 6)
      show_error(0,WIN_2_SMALL,1,"Current window is too small to open another");

   /* allocate memory for the new window structure */

   if ((wp = (WINDOW *) malloc(sizeof(WINDOW))) == NULL)
      show_error(0,NO_MEM,1,nomem);

   wincpy(wp,&cw);             /* initialize new window via current window */

   /* allocate memory to store files[] data */

   if ((wp->save_files = malloc_f(MAX_FILES * sizeof(FILE_ENT))) == NULL) {
      free((char *)wp);
      show_error(0,NO_MEM,1,nomem);
   }

   /*  if there is only one window open so far, create the window structure
       and files[] save area to store the current window stuff */

   if (numwin == 1) {
      curwin = (WINDOW *) malloc(sizeof(WINDOW));
      cw.save_files = malloc_f(MAX_FILES * sizeof(FILE_ENT));
      if (curwin == NULL || cw.save_files == NULL) {
         free((char *)wp);
         if (curwin) {
            free((char *)curwin);
            curwin = NULL;
         }
         show_error(0,NO_MEM,1,nomem);
      }
      cw.prev = cw.next = winlis = curwin;
   }

   savefiles(cw.save_files,cw.nfiles); /* save current window's files[] data */

   /* link the new window just after the current window */

   wincpy(curwin,&cw);
   wp->next = curwin->next;
   wp->prev = curwin;
   wp->prev->next = wp;
   wp->next->prev = wp;
   wincpy(&cw,curwin);

   /* adjust the current window and new window display sizes */

   wp->wrows = cw.wrows / 2;           /* new is at most 1/2 of current */
   cw.wrows = cw.wrows - wp->wrows;    /* current keeps whats left */
   wp->fwrow = cw.fwrow + cw.wrows;    /* new start at end of current */
   cw.ndrows -= wp->wrows;             /* all new rows came from name disp */
   wp->fnrow = wp->fwrow + 1;          /* one overhead row for dir name */
   wp->ndrows = wp->wrows - 1;

   /* adjust the top window if it was the only one and it didn't already
      have a header line */

   if (numwin == 1 && !cw.showall) {
      cw.fnrow++;                         /* need a line to display window */
      cw.ndrows--;                        /*   directory line */
      insert_line(cw.fwrow+1,cw.wrows-1); /* scroll file info down a line */
      disp_dirname();                     /* disp the dir name */
   }

   /* adjust old window if current item is no longer visible and turn off
      the file pointer in the old window */

   if (!on_screen(cw.curidx)) {        /* adjust/redisplay window */

      adjust_window();                 /*   if current item no longer */
      update_window(0);                /*   displayed */

   } else              /* not redisplaying window, turn off highlighted ptr */

      if (cw.nfiles)                      /* turn off file ptr in old window */
         fp_off(cw.curidx);
      else                                /* or de-highlight empty dir msg */
         disp_empty_msg(0);

   /* make the new window the current one */

   wincpy(curwin,&cw);                 /* save the old current one */
   wincpy(&cw,wp);                     /* new one becomes current */
   curwin = wp;                        /* remember who it is */

   numwin++;                           /* one more window than there was */

   if (cw.info_display)                /* if info display is active, there */
      infocnt(1);                      /*   is now 1 more info window active */

   /* only one window can be in showall mode */

   if (cw.showall) {                   /* did the old window have showall? */
      cw.showall = 0;                  /* yes, turn off on this one */
      getfiles();                      /* reread current dir only */
      update_header();                 /* display current dir header info */
   }

   /* display the file data in the new window */

   adjust_window();
   update_window(1);

}


/******************************************************************************
                            W I N _ C L O S E
 *****************************************************************************/

win_close() {          /* close the current window */

   int fwrowadj;
   register WINDOW *wp;

   if (numwin == 1)            /* nothing to do if only one window */
      return;

   /* determine the window adjustment fudge factor, 1 extra line is available
      if only one window will remain and that window is not showall */

   fwrowadj = (numwin == 2 && (!anyshowall || cw.showall)) ? 0 : 1;

   /* adjust the next or prior window to take up the closing windows space
      on the screen.  Always pick the next window unless current is the
      last one displyed */

   if ((wp = cw.next) != winlis) {             /* next = winlis if last */

      wp->fwrow = cw.fwrow;                    /* adj nxt to take over */

   } else              /* closing last window on screen */

      wp = cw.prev;                            /* prev is current to be */

   wp->wrows += cw.wrows;              /* it has this many more rows */
   wp->fnrow = wp->fwrow + fwrowadj;   /*   name display rows */
   wp->ndrows = wp->wrows - fwrowadj;

   cw.next->prev = cw.prev;            /* delink the current (closing) */
   cw.prev->next = cw.next;            /* windows block from window list */

   if (curwin == winlis)               /* keep track of new top window if */
      winlis = wp;                     /* old top is being closed */

   if (cw.showall)                     /* turn off showall mode if this */
      showoff();                       /*   window had it on */

   if (cw.info_display)                /* one less info window if this wind */
      infocnt(-1);                     /*   had info display active */

   free_f(cw.save_files);              /* free the cur win's  files[] area */
   free((char *)curwin);               /* free the cur/old win's block */

   /* make the next (or prior) window current, restore its files */

   wincpy(&cw,curwin = wp);
   restorefiles(cw.save_files,cw.nfiles);

   numwin--;                           /* one less window now */

   /* when there is only one window, don't keep the block and files[]
      save area overhead */

   if (numwin == 1) {
      free((char *)curwin);
      free_f(cw.save_files);
      curwin = winlis = NULL;
      cw.save_files = (char far *) NULL;
   }

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

   adjust_window();            /* adjust the display */
   update_window(1);

   /* switch to the window's directory */

   if (change_dir(cw.dirbuf) != 0)
      show_error(SHOW_DOS,0,1,noaccess);
}


/******************************************************************************
                            W I N _ E X P A N D
 *****************************************************************************/

win_expand() {         /* expand current window to full screen */

   int i;
   register WINDOW *wp, *np;

   if (numwin == 1)            /* nothing to do if only one window */
      return;

   /* there will only be one window left, free up all memory blocks */

   for (i == numwin, wp = winlis; i; i--) {
      np = wp->next;
      free_f(wp->save_files);
      free((char *)wp);
      wp = np;
   }

   numwin = 1;                 /* set counters/pointer to 1 window status */
   curwin = winlis = NULL;

   if (anyshowall && !cw.showall)      /* turn off showall mode if it was */
      showoff();                       /*   active in another window */

   infocnt(cw.info_display ? -(inwin-1) : -inwin); /* at most 1 info win left */

   /* adjust to full screen */

   cw.fwrow = cw.fnrow = FIRST_NROW + cw.info_display;
   cw.wrows = cw.ndrows = NAME_ROWS - cw.info_display;

   if (cw.showall) {           /* showall always has a header */
      cw.fnrow++;
      cw.ndrows--;
   }

   adjust_window();            /* redisplay the window with new size */
   update_window(1);

}


/******************************************************************************
 **                         W I N _ N E X T                                  **
 *****************************************************************************/

win_next() {           /* switch to the next window */

   if (numwin == 1)            /* nothing to do if only one window */
      return;

   win_switch(curwin->next);   /* switch to next window */
}


/******************************************************************************
                            W I N _ P R E V
 *****************************************************************************/

win_prev() {           /* switch to the previous window */

   if (numwin == 1)            /* nothing to do if only one window */
      return;

   win_switch(curwin->prev);   /* switch to previous window */
}


/******************************************************************************
                            W I N _ S W I T C H
 *****************************************************************************/

static int ALTCALL
win_switch(newp)       /* switch to a new window */
register WINDOW *newp;
{
   savefiles(cw.save_files,cw.nfiles); /* save current window's files[] data */

   if (cw.nfiles)                      /* deselect current item in widow */
      fp_off(cw.curidx);

⌨️ 快捷键说明

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