📄 ovwin.c
字号:
/******************************************************************************
U P D A T E _ H E A D E R
******************************************************************************/
update_header() { /* update display header */
gotorc(VOL_ROW,1); /* make sure volume, directory, */
out_str(cw.drivep->volbuf,11,' '); /* file, tagged info is correct */
if (!cw.showall) { /* display the current dir name */
gotorc(VOL_ROW,PATH_COL+1); /* but if showall is in effect */
out_str(cw.dirbuf,65,' '); /* its done somewhere else */
}
disp_vol_stats();
disp_file_stats();
gotorc(MASK_ROW,MASK_COL-1); /* display the selection mask */
disp_char(cw.maskcmp ? ' ' : '~');
out_str(cw.mask,MASK_LEN,' ');
gotorc(MASK_ROW+1,MASK_COL-1); /* display the selection attributes */
disp_attrib(cw.selatrs);
disp_str(cw.selatrs & DIR ? " D" : " .");
}
/******************************************************************************
U P D A T E _ W I N D O W
*****************************************************************************/
int ALTCALL
update_window(fptr) /* display a window full of file info */
int fptr;
{
int col;
register int i, m;
if (numwin > 1 || cw.showall) /* display window header if > 1 */
disp_dirname(); /* window or showall mode */
/* display a window of file names */
for (i = 0; i + cw.fnrow < cw.fnrow + cw.ndrows; i++) {
gotorc(i+cw.fnrow,0);
if (i < cw.nrows) {
for (col = 0, m = cw.nbase + i; m < cw.nfiles; col++, m += cw.nrows)
disp_file(&files[m],(m == cw.curidx && fptr));
if (col < cw.ncols) /* try to only clear on rows where less */
clr_eol(); /* than ncols are displayed */
} else
clr_eol();
}
/* display files dir path if showall mode */
if (fptr && cw.showall && cw.curidx < cw.nfiles)
disp_path(cw.curidx);
if (cw.nfiles == 0) /* display a msg if no files in dir */
disp_empty_msg(fptr);
}
/******************************************************************************
A D J U S T _ W I N D O W
*****************************************************************************/
int ALTCALL
adjust_window() {
/* for MS DOS, assume the max length file name is 13. 8 for the primary
name, 1 for '.', 3 for the extension, and 1 for '\' if its a directory */
cw.maxlen = MAX_NAMELEN + 1;
/* everything depends on # files in directory */
if (cw.nfiles == 0) /* unusual, but dir may be empty */
cw.nrows = cw.ncols = 1;
else { /* are files, calc logical rows, cols */
cw.ncols = (cw.info_display) ? 1 : 5;
cw.nrows = (cw.nfiles+(cw.ncols-1)) / cw.ncols;
}
cw.colsiz = SCREEN_COLS / cw.ncols; /* width of each column */
/* update current logical idx */
if (cw.curidx >= cw.nfiles)
cw.curidx = cw.nfiles ? cw.nfiles - 1 : 0;
/* make sure nbase is setup such that the current file is displayed */
if (cw.nfiles <= cw.ndrows * cw.ncols) /* if file entries will fit on */
cw.nbase = 0; /* 1 screen, start at 1st */
else {
cw.nbase = idx2lr(cw.curidx) - cw.ndrows / 2; /* try to center curidx */
if (cw.nbase > 0 && cw.nbase + cw.ndrows > cw.nrows) /* no blank rows */
cw.nbase = cw.nrows - cw.ndrows; /* if possible */
if (cw.nbase < 0) /* might overshoot */
cw.nbase = 0;
}
}
/******************************************************************************
I N F O C N T
*****************************************************************************/
infocnt(chg) /* display/remove info header when required */
int chg;
{
int cur_isnt_top;
inwin += chg; /* more or less info windows */
cur_isnt_top = (numwin > 1 && curwin != winlis);
/* if the count of info windows just went to 0, or it just went from 0 to 1,
we need to add or remove the info display header. The top display
window losses or gains a row when this happens */
if ((inwin == 0 && chg) || (inwin == 1 && chg > 0)) {
/* do a temp switch to the top window if not already there */
if (cur_isnt_top) {
wincpy(curwin,&cw);
savefiles(cw.save_files,cw.nfiles);
wincpy(&cw,winlis);
restorefiles(cw.save_files,cw.nfiles);
}
/* now add or remove a row from the window */
if (inwin) { /* remove a line, display header */
cw.fwrow++; cw.fnrow++;
cw.wrows--; cw.ndrows--;
infohead();
} else { /* add a line, remove header */
cw.fwrow--; cw.fnrow--;
cw.wrows++; cw.ndrows++;
}
/* now update the top window display, but don't bother if the current
window is the top window - it will be updated by caller */
if (cur_isnt_top) {
adjust_window(); /* calculate #rows, columns, etc to display */
update_window(0);
}
/* restore windows if we did a temp switch above */
if (cur_isnt_top) {
wincpy(winlis,&cw);
savefiles(cw.save_files,cw.nfiles);
wincpy(&cw,curwin);
restorefiles(cw.save_files,cw.nfiles);
}
}
}
/*****************************************************************************
D I S P _ E M P T Y _ M S G
*****************************************************************************/
static int ALTCALL
disp_empty_msg(on) /* display empty dir msg w/wo highlighting */
int on;
{
if (on)
setvattrib(DIS_HIGH);
disp_str_at("No files!",cw.fnrow+1,SCREEN_COLS/2-5);
if (on)
setvattrib(DIS_NORM);
}
/*****************************************************************************
D I S P _ D I R N A M E
*****************************************************************************/
disp_dirname() { /* display the dir name header */
char allmsg[20];
if (cw.showall) { /* special header if showall mode */
strcpy(allmsg,"FILES ON DRIVE ");
strncat(allmsg,cw.dirbuf,2);
center_text(cw.fwrow,allmsg);
} else
center_text(cw.fwrow,cw.dirbuf); /* disp the dir name */
}
/*****************************************************************************
I N F O H E A D
*****************************************************************************/
infohead() { /* display the info header */
setvattrib(DIS_HEAD);
disp_str_at(" NAME USED ALLOCATED DATE TIME R H S A DIR",
FIRST_NROW,0);
clr_eol();
setvattrib(DIS_NORM);
}
/*****************************************************************************
S H O W _ A L L
*****************************************************************************/
show_all() {
if (anyshowall && !cw.showall) /* only one window can do showall */
show_error(0,ONE_SH_ALL,1,"Only one window can show all files!");
if (cw.showall ^= 1) { /* toggle showall mode */
/* showall mode is being turned on, allocate space for dir name ptrs */
if ((dirlst = (char **) calloc(MAX_DIR,sizeof(char *))) == NULL) {
cw.showall = 0;
show_error(0,NO_MEM,1,"Out of memory! Show All is not active!");
}
if (numwin == 1) { /* make row for showall header if not already */
cw.fnrow++;
cw.ndrows--;
}
anyshowall = TRUE; /* yes, a window has showall turned on */
} else /* showall is being turned off */
showoff();
renew_window(); /* redo window with/without showall mode */
}
/*****************************************************************************
S H O W O F F
*****************************************************************************/
showoff() { /* turn off show all mode */
register int i;
register char **cp;
for (i = 0, cp = dirlst; i < diridx; i++, cp++) /* release dir name */
free(*cp); /* memory */
free((char *)dirlst); /* now release pointer memory */
diridx = 0; /* reset for next time */
dirlst = NULL;
cw.showall = anyshowall = FALSE; /* no window has showall now */
if (numwin == 1) { /* release showall header line if not needed */
cw.fnrow--;
cw.ndrows++;
}
}
/******************************************************************************
W I N C P Y
******************************************************************************/
static int ALTCALL
wincpy(to,from) /* copy window structures - I made this a separate */
WINDOW *to, *from; /* routine cause MSC generates a bunch of code for */
{ /* each structure asignment - in reality, it just a */
/* little more than the code required to call this */
/* function, but... */
*to = *from; /* not much to look at */
}
/******************************************************************************
** S A V E / R E S T O R E F I L E S **
******************************************************************************/
static int ALTCALL
savefiles(fp,nf) /* copy files[] to save area */
char far *fp;
int nf;
{
movedata(dataseg,(unsigned int) files,FP_SEG(fp),FP_OFF(fp),
nf * sizeof(FILE_ENT));
}
static int ALTCALL
restorefiles(fp,nf) /* copy files[] from save area */
char far *fp;
int nf;
{
movedata(FP_SEG(fp),FP_OFF(fp),dataseg,(unsigned int) files,
nf * sizeof(FILE_ENT));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -