VOID insa_stypes(LONG tree, BYTE *pdata) { WORD i; BYTE *pstr, doctype[4]; for(i=0; i<8; i++) { pdata = scasb(pdata, '.'); if (*pdata == '.') pdata++; pstr = &doctype[0]; while ( (*pdata) && (*pdata != ',') ) *pstr++ = *pdata++; *pstr = '\0'; inf_sset(tree, APDFTYPE+i, &doctype[0]); } }
/* * Routine to take the filenames that will appear in the window, * based on the current scrolled position, and point at them * with the sub-tree of G_STRINGs that makes up the window box. */ static void fs_format(LONG tree, WORD currtop, WORD count) { register WORD i, cnt; register WORD y, h, th; BYTE *p, name[LEN_FSNAME]; OBJECT *obj, *treeptr = (OBJECT *)tree; /* build in real text */ /* strings */ cnt = min(NM_NAMES, count - currtop); for(i=0, obj=treeptr+NAME_OFFSET; i<NM_NAMES; i++, obj++) { if (i < cnt) { p = ad_fsnames + g_fslist[currtop+i]; fmt_str(p+1, name+1); /* format file/folder name */ name[0] = p[0]; /* copy file/folder indicator */ } else { name[0] = ' '; name[1] = '\0'; } inf_sset(tree, NAME_OFFSET+i, name); obj->ob_type = G_FBOXTEXT; obj->ob_state = NORMAL; } /* size and position the*/ /* elevator */ y = 0; obj = treeptr + FSVSLID; th = h = obj->ob_height; if ( count > NM_NAMES) { h = mul_div(NM_NAMES, h, count); h = max(gl_hbox/2, h); /* min size elevator */ y = mul_div(currtop, th-h, count-NM_NAMES); } obj = treeptr + FSVELEV; obj->ob_y = y; obj->ob_height = h; }
VOID insa_elev(LONG tree, WORD nicon, WORD numics) { WORD y, h, th; LONG lp; y = 0; th = h = LWGET(OB_HEIGHT(APFSVSLI)); if ( numics > 1) { #if M68000 h = h / numics; #else h = mul_div(1, h, numics); #endif h = max((gl_hbox/2)+2, h); /* min size elevator */ #if M68000 y = (WORD)((LONG)nicon * (LONG)(th-h) / (LONG)(numics-1)); #else y = mul_div(nicon, th-h, numics-1); #endif } LWSET(OB_Y(APFSVELE), y); LWSET(OB_HEIGHT(APFSVELE), h); strcpy(&G.g_1text[0], ini_str(STAPPL)); insa_icon(tree, APF1NAME, IA_GENERIC+nicon, &gl_aib, &G.g_1text[0]); strcpy(&G.g_2text[0], ini_str(STDOCU)); insa_icon(tree, APF2NAME, ID_GENERIC+nicon, &gl_dib, &G.g_2text[0]); #if ALCYON lp = G.a_datastart + *((BYTE **)(G.a_datastart + gl_pstart + (nicon * sizeof(BYTE *)) ) ); #else lp = G.a_datastart + LWGET(G.a_datastart + gl_pstart + (nicon * sizeof(BYTE *)) ); #endif LSTCPY(lp, ADDR(&gl_lngstr[0])); inf_sset(tree, APFTITLE, &gl_lngstr[0] ); } /* insa_elev */
/* ins_app */ WORD ins_app(BYTE *pfname, ANODE *pa) { LONG tree; ANODE *newpa; BYTE pname[12]; BYTE ntypes[6*8]; WORD oicon, nicon; WORD oflag, nflag; WORD change, field; WORD uninstalled, h; #if MULTIAPP BYTE memszstr[4]; WORD omemsz, nmemsz; #endif tree = G.a_trees[ADINSAPP]; #if MULTIAPP LWSET(OB_NEXT(APMEMBOX),APMEMSZ); #endif h = LWGET(OB_HEIGHT(APSCRLBA)); LWSET(OB_HEIGHT(APFUPARO), gl_hbox + 2); LWSET(OB_Y(APFSVSLI), gl_hbox + 2); LWSET(OB_HEIGHT(APFSVSLI), h - (2 * (gl_hbox + 2))); LWSET(OB_Y(APFDNARO), h - (gl_hbox + 2)); LWSET(OB_HEIGHT(APFDNARO), gl_hbox + 2); uninstalled = !is_installed(pa); LWSET(OB_STATE(APREMV), (uninstalled) ? DISABLED : NORMAL ); /* stuff in appl name */ fmt_str(pfname, &pname[0]); inf_sset(tree, APNAME, &pname[0]); /* stuff in docu types */ insa_stypes(tree, pa->a_pdata); LWSET(OB_STATE(APYMEM), NORMAL); oflag = pa->a_flags; if (pa->a_flags & AF_ISCRYS) { field = APGEM; LWSET(OB_STATE(APYMEM), DISABLED); } else field = (pa->a_flags & AF_ISPARM) ? APPARMS : APDOS; LWSET(OB_STATE(field), SELECTED); field = (pa->a_flags & AF_ISFMEM) ? APYMEM : APNMEM; LWSET(OB_STATE(field), SELECTED); oicon = pa->a_aicon - IA_GENERIC; #if MULTIAPP omemsz = pa->a_memreq; merge_str(&memszstr[0], "%W", &omemsz); inf_sset(tree, APMEMSZ, &memszstr[0]); #endif insa_elev(tree, oicon, gl_numics); nicon = insa_dial(tree, oicon, gl_numics); change = FALSE; #if MULTIAPP nmemsz = ins_latoi(LLGET(LLGET(OB_SPEC(APMEMSZ)))); #endif /* set memory flag */ field = inf_gindex(tree, APYMEM, 2); nflag = (field == 0) ? AF_ISFMEM : 0; LWSET(OB_STATE(APYMEM + field), NORMAL); /* set type flags */ field = inf_gindex(tree, APGEM, 3); if (field == 0) nflag = AF_ISCRYS | AF_ISGRAF; if (field == 2) nflag |= AF_ISPARM; LWSET(OB_STATE(APGEM + field), NORMAL); /* get button selection */ field = inf_gindex(tree, APINST, 3); LWSET(OB_STATE(APINST + field), NORMAL); if ( field == 0 ) { /* install the appl. if its uninstalled or has new types */ insa_gtypes(tree, &ntypes[0]); if ( (uninstalled) || (!strcmp(&ntypes[0], pa->a_pdata)) ) { newpa = (uninstalled) ? app_alloc(TRUE) : pa; if (newpa) { if ( (uninstalled) || (!strcmp(&ntypes[0], pa->a_pdata)) ) { change = TRUE; ntypes[ strlen(&ntypes[0]) ] = '@'; scan_str(&ntypes[0], &newpa->a_pdata); } if (newpa != pa) { uninstalled = change = TRUE; strcpy(&ntypes[0], pfname); ntypes[ strlen(&ntypes[0]) ] = '@'; scan_str(&ntypes[0], &newpa->a_pappl); newpa->a_flags = nflag; newpa->a_type = AT_ISFILE; newpa->a_obid = NIL; newpa->a_letter = '\0'; newpa->a_xspot = 0x0; newpa->a_yspot = 0x0; } pa = newpa; } else fun_alert(1, STAPGONE, NULL); } /* see if icon changed or flags changed */ if ( (uninstalled) || #if MULTIAPP (omemsz != nmemsz) || #endif (oicon != nicon) || (oflag != nflag) ) { change = TRUE; pa->a_aicon = nicon + IA_GENERIC; pa->a_dicon = nicon + ID_GENERIC; pa->a_flags = nflag; #if MULTIAPP pa->a_memreq = nmemsz; #endif } } else if ( field == 1 ) { /* remove installed app */ if ( !uninstalled ) { app_free(pa); change = TRUE; } } return(change); } /* ins_app */
/* ins_disk */ WORD ins_disk(ANODE *pa) { LONG tree; WORD change, icon, flop, hard, fld; BYTE cletter[2], clabel[13]; BYTE nletter[2], nlabel[13]; ANODE *newpa; tree = G.a_trees[ADINSDIS]; change = FALSE; cletter[0] = pa->a_letter; cletter[1] = '\0'; strcpy(&clabel[0], pa->a_pappl); inf_sset(tree, DRID, &cletter[0]); inf_sset(tree, DRLABEL, &clabel[0]); flop = (pa->a_aicon == IG_FLOPPY) ? SELECTED : NORMAL; hard = (pa->a_aicon == IG_HARD) ? SELECTED : NORMAL; LWSET(OB_STATE(DRFLOPPY), flop); LWSET(OB_STATE(DRHARD), hard); LWSET(OB_STATE(DRREM), (lastdisk()) ? DISABLED : NORMAL ); inf_show(tree, 0); inf_sget(tree, DRID, &nletter[0]); inf_sget(tree, DRLABEL, &nlabel[0]); fld = inf_gindex(tree, DRINST, 3); /* which exit button? */ LWSET(OB_STATE(DRINST + fld), NORMAL); icon = ( LWGET(OB_STATE(DRFLOPPY)) & SELECTED ); icon = (icon) ? IG_FLOPPY : IG_HARD; if ( fld == 0 ) /* Install */ { if ( (cletter[0] != nletter[0]) && (nletter[0] != '\0') ) { newpa = get_disk(nletter[0]); if (!newpa) { newpa = app_alloc(FALSE); if (newpa) { newpa->a_flags = pa->a_flags; newpa->a_type = pa->a_type; newpa->a_obid = pa->a_obid; newpa->a_pappl = pa->a_pappl; scan_str("@", &newpa->a_pdata); newpa->a_aicon = pa->a_aicon; newpa->a_dicon = NIL; newpa->a_letter = nletter[0]; } /* if newpa */ else fun_alert(1, STAPGONE, NULL); } /* if !newpa */ if (newpa) pa = newpa; change = TRUE; } /* if cletter */ /* see if icon changed */ if (pa->a_aicon != icon) { pa->a_aicon = icon; change = TRUE; } /* see if label changed */ if ( (!strcmp(&clabel[0], &nlabel[0])) && (nlabel[0] != '\0') ) { nlabel[ strlen(&nlabel[0]) ] = '@'; scan_str(&nlabel[0], &pa->a_pappl); change = TRUE; } } /* if INSTALL */ else if ( fld == 1 ) /* Remove */ { /* find matching anode delete it */ for (pa = G.g_ahead; pa; pa = pa->a_next) { if ( (pa->a_aicon == icon) && (pa->a_letter == nletter[0]) ) { app_free(pa); change = TRUE; } } /* for */ } /* if REMOVE */ return(change); } /* ins_disk */
WORD dofiles( BYTE *s, BYTE *d, WORD code, LONG *ndirs, LONG *nfiles, LONG *tsize, WORD type, WORD multiple, WORD handle) { WORD ret; /*trash; */ BYTE buffer[2]; if ( *d == 'c' ) return( FALSE ); /* desk_mice( HOURGLASS ); */ /* get the dialog box string */ whandle = handle; cpbox = get_tree( CPBOX ); f_cancel = 0; f_level = 0; /* the current depth of the directory path */ f_abort = 0; /* No abortion */ rename = 0; buffer[1] = 0; ret = FALSE; if ( (opcode = code) == OP_COUNT ) { numfiles = 0x0L; /* the number of files show in the dialog box */ numdirs = 0x0L; /* the number of directories */ tolsize = 0x0L; /* the total size of all files in the path */ } else { numdirs = *ndirs; numfiles = *nfiles; tolsize = *tsize; } do { if ( *s == 'c' ) /* skip cartridge */ goto cc_4; buffer[0] = *s; if ( ( d_display ) && ( code != OP_COUNT ) ) { inf_sset( (LONG)cpbox, CSDRIVE, buffer ); wind_update( 1 ); w_draw_fld( handle, cpbox, CSDRIVE ); wind_update( 0 ); } /* do the counting only */ if (code == OP_COUNT) { if ( !(ret = count( s ) ) ) goto clnup; /* error */ } else /* do the actual operation */ { if ( !ch_undo() || f_cancel ) /* check for undo key */ { f_abort = 1; goto clnup; } /* delete the whole disk */ if ( ( type == DISK ) && ( code == OP_DELETE ) ) { if ( fill_string( buffer, DELDISK ) != 1 ) goto cc_4; } if ( ( code == OP_COPY ) || ( code == OP_MOVE ) ) { if ( ( type == SUBDIR ) || ( type == XDIR ) || ( type == DISK ) ) { if ( !chk_par( s, d ) ) /* illegal */ { if ( do1_alert( NODIRCOP ) == 2 ) goto clnup; /* abort */ else { ret = TRUE; goto cc_3; /* go to next one */ } } } } if (!(ret = getinfo(s, d))) goto clnup; if ( ret == SKIP ) continue; if (!(ret = doright(ret))) goto clnup; if ( ret == SKIP ) continue; } cc_3: if ( code != OP_COUNT ) x_deselect(); /* deselect object */ if ( ( code == OP_DELETE ) || ( code == OP_MOVE ) ) dr[ *s - 'A' ] = 1; if ( ( code == OP_COPY ) || ( code == OP_MOVE ) ) dr[ *d - 'A' ] = 1; cc_4: if ( !multiple ) /* do only one device */ break; }while( x_next( &s, &type ) ); *ndirs = numdirs; *nfiles = numfiles; *tsize = tolsize; clnup: /* deselect object */ if ( ( code == OP_DELETE ) || ( code == OP_MOVE ) ) { if ( *s != 'c' ) dr[ *s - 'A' ] = 1; } if ( ( code == OP_COPY ) || ( code == OP_MOVE ) ) dr[ *d - 'A' ] = 1; /* desk_mice( ARROW ); */ if ( f_abort ) return( TRUE ); return( ret ); }
/* * File Selector input routine that takes control of the mouse * and keyboard, searchs and sort the directory, draws the file * selector, interacts with the user to determine a selection * or change of path, and returns to the application with * the selected path, filename, and exit button. */ WORD fs_input(BYTE *pipath, BYTE *pisel, WORD *pbutton, BYTE *pilabel) { register WORD touchob, value, fnum; WORD curr, count, sel; WORD mx, my; LONG tree; ULONG bitmask; BYTE *ad_fpath, *ad_fname, *ad_ftitle; WORD drive; WORD dclkret, cont, newlist, newsel, newdrive; register BYTE *pstr; GRECT pt; BYTE locstr[LEN_ZPATH+1], mask[LEN_ZFNAME+1], selname[LEN_FSNAME]; OBJECT *obj; TEDINFO *tedinfo; curr = 0; count = 0; /* get out quick if path is */ /* nullptr or if pts to null. */ if (pipath == NULL) return(FALSE); /* if path string is empty, */ /* set reasonable default */ if (*pipath == '\0') { strcpy(pipath,"A:\\*.*"); *pipath += dos_gdrv(); } /* get memory for the filename buffer */ /* & the array that points to it */ for (nm_files = MAX_NM_FILES; nm_files >= MIN_NM_FILES; nm_files /= 2) { ad_fsnames = (BYTE *)dos_alloc(nm_files*(LEN_FSNAME+sizeof(BYTE *))); if (ad_fsnames) break; } if (!ad_fsnames) return(FALSE); g_fslist = (LONG *)(ad_fsnames+nm_files*LEN_FSNAME); strcpy(locstr, pipath); tree = ad_fstree; /* init strings in form */ obj = ((OBJECT *)tree) + FTITLE; tedinfo = (TEDINFO *)obj->ob_spec; ad_ftitle = (BYTE *)tedinfo->te_ptext; set_mask(mask, locstr); /* save caller's mask */ strcpy(ad_ftitle, mask); /* & copy to title line */ obj = ((OBJECT *)tree) + FSDIRECT; tedinfo = (TEDINFO *)obj->ob_spec; ad_fpath = (BYTE *)tedinfo->te_ptext; inf_sset(tree, FSDIRECT, locstr); obj = ((OBJECT *)tree) + FSSELECT; tedinfo = (TEDINFO *)obj->ob_spec; ad_fname = (BYTE *)tedinfo->te_ptext; fmt_str(pisel, selname); /* selname[] is without dot */ inf_sset(tree, FSSELECT, selname); obj = ((OBJECT *)tree) + FSTITLE; obj->ob_spec = pilabel ? (LONG)pilabel : (LONG)rs_str(ITEMSLCT); /* set drive buttons */ obj = ((OBJECT *)tree) + DRIVE_OFFSET; for (drive = 0, bitmask = 1; drive < NM_DRIVES; drive++, bitmask <<= 1, obj++) { if (drvbits & bitmask) obj->ob_state &= ~DISABLED; else obj->ob_state |= DISABLED; } select_drive(tree,locstr[0]-'A',0); /* set clip and start */ /* form fill-in by */ /* drawing the form */ gsx_sclip(&gl_rfs); fm_dial(FMD_START, &gl_rfs); ob_draw(tree, ROOT, 2); /* init for while loop */ /* by forcing initial */ /* fs_newdir call */ sel = 0; newsel = FALSE; cont = newlist = TRUE; while( cont ) { touchob = (newlist) ? 0x0 : fm_do(tree, FSSELECT); gsx_mxmy(&mx, &my); if ( newlist ) { fs_sel(sel, NORMAL); if ( (touchob == FSOK) || (touchob == FSCANCEL) ) ob_change(tree, touchob, NORMAL, TRUE); inf_sset(tree, FSDIRECT, locstr); pstr = fs_pspec(locstr, NULL); strcpy(pstr, mask); fs_newdir(locstr, mask, tree, &count); curr = 0; sel = touchob = 0; newlist = FALSE; } value = 0; dclkret = ((touchob & 0x8000) != 0); switch( (touchob &= 0x7fff) ) { case FSOK: case FSCANCEL: cont = FALSE; break; case FUPAROW: case FDNAROW: value = 1; break; case FSVSLID: ob_actxywh(tree, FSVELEV, &pt); /* anemic slidebars pt.g_x -= 3; pt.g_w += 6; */ if ( !inside(mx, my, &pt) ) { touchob = (my <= pt.g_y) ? FUPAROW : FDNAROW; value = NM_NAMES; break; } /* drop through */ case FSVELEV: fm_own(TRUE); value = gr_slidebox(tree, FSVSLID, FSVELEV, TRUE); fm_own(FALSE); value = curr - mul_div(value, count-NM_NAMES, 1000); if (value >= 0) touchob = FUPAROW; else { touchob = FDNAROW; value = -value; } break; case F1NAME: case F2NAME: case F3NAME: case F4NAME: case F5NAME: case F6NAME: case F7NAME: case F8NAME: case F9NAME: fnum = touchob - F1NAME + 1; if ( fnum > count ) break; if ( (sel) && (sel != fnum) ) fs_sel(sel, NORMAL); if ( sel != fnum) { sel = fnum; fs_sel(sel, SELECTED); } /* get string and see */ /* if file or folder */ inf_sget(tree, touchob, selname); if (selname[0] == ' ') /* a file was selected */ { /* copy to selection */ newsel = TRUE; if (dclkret) cont = FALSE; } else /* a folder was selected: */ { /* insert name before mask */ pstr = fs_pspec(locstr, NULL); unfmt_str(selname+1, pstr); pstr += strlen(pstr); *pstr++ = '\\'; strcpy(pstr, mask); newlist = TRUE; } break; case FCLSBOX: pstr = fs_back(locstr, NULL); if (*pstr-- != '\\') /* ignore strange path string */ break; if (*pstr != ':') /* not at root of drive, so back up */ { pstr = fs_back(locstr, pstr); if (*pstr == '\\') /* we must have at least X:\ */ strcpy(pstr+1, mask); } newlist = TRUE; break; default: drive = touchob - DRIVE_OFFSET; if ((drive < 0) || (drive >= NM_DRIVES))/* not for us */ break; if (drive == locstr[0] - 'A') /* no change */ break; obj = ((OBJECT *)tree) + touchob; if (obj->ob_state & DISABLED) /* non-existent drive */ break; strcpy(locstr, "A:\\*.*"); locstr[0] += drive; newdrive = TRUE; break; } if (!newlist && !newdrive && path_changed(locstr)) /* path changed manually */ { if (ad_fpath[0] != locstr[0]) /* drive has changed */ newdrive = TRUE; else newlist = TRUE; strcpy(locstr, ad_fpath); } if (newdrive) { select_drive(tree, touchob-DRIVE_OFFSET,1); newdrive = FALSE; newlist = TRUE; } if (newlist) { inf_sset(tree, FSDIRECT, locstr); set_mask(mask, locstr); /* set mask */ selname[1] = '\0'; /* selected is empty */ newsel = TRUE; } if (newsel) { strcpy(ad_fname, selname + 1); ob_draw(tree, FSSELECT, MAX_DEPTH); if (!cont) ob_change(tree, FSOK, SELECTED, TRUE); newsel = FALSE; } if (value) curr = fs_nscroll(tree, &sel, curr, count, touchob, value); } /* return path and */ /* file name to app */ strcpy(pipath, locstr); unfmt_str(ad_fname, selname); strcpy(pisel, selname); /* start the redraw */ fm_dial(FMD_FINISH, &gl_rfs); /* return exit button */ *pbutton = inf_what(tree, FSOK, FSCANCEL); dos_free((LONG)ad_fsnames); return( TRUE ); }
/* * Routine that creates a new directory in the specified window/path */ WORD fun_mkdir(WNODE *pw_node) { PNODE *pp_node; OBJECT *tree; WORD i, len, err; BYTE fnew_name[LEN_ZFNAME], unew_name[LEN_ZFNAME], *ptmp; BYTE path[MAXPATHLEN]; tree = G.a_trees[ADMKDBOX]; pp_node = pw_node->w_path; ptmp = path; strcpy(ptmp, pp_node->p_spec); i = 0; while (*ptmp++) { if (*ptmp == '\\') i++; } if (i > MAX_LEVEL) { fun_alert(1, STFO8DEE); return FALSE; } while(1) { fnew_name[0] = '\0'; inf_sset(tree, MKNAME, fnew_name); show_hide(FMD_START, tree); form_do(tree, 0); if (inf_what(tree, MKOK, MKCNCL) == 0) break; inf_sget(tree, MKNAME, fnew_name); unfmt_str(fnew_name, unew_name); if (unew_name[0] == '\0') break; ptmp = add_fname(path, unew_name); err = dos_mkdir(path); if (err == 0) /* mkdir succeeded */ { fun_rebld(pw_node); break; } /* * if we're getting a BIOS (rather than GEMDOS) error, the * critical error handler has already issued a message, so * just quit */ if (IS_BIOS_ERROR(err)) break; len = strlen(path); /* before we restore old path */ restore_path(ptmp); /* restore original path */ if (len >= LEN_ZPATH-3) { fun_alert(1,STDEEPPA); break; } /* * mkdir failed with a recoverable error: * prompt for Cancel or Retry */ if (fun_alert(2,STFOFAIL) == 1) /* Cancel */ break; } show_hide(FMD_FINISH, tree); return TRUE; }