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

📄 fv.file.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
	{		iconwidth = iconheight = 16;		y_off = 5;	}	/* Get offset into canvas; decrement y coordinate by offset */	scroll_offset = GET_SCROLL_VIEW_START;	x += Fv_margin;	y += foldr_top;	/* Well, the user must want to drag some icons around, so lets 	 * set him up...	 */	nseln = 0;	for (f_p=Fv_file, l_p=Fv_file+Fv_nfiles, i=0; f_p != l_p; f_p++, i++)		if ((*f_p)->selected)		{			Seln[nseln].fno = i;			if ((Fv_style & FV_DICON) || !Fv_style )				Seln[nseln].x = (*f_p)->x+Fv_margin+x_off;			else				Seln[nseln].x = MARGIN+Fv_margin+x_off;			Seln[nseln].y = trans(i)-scroll_offset+foldr_top+y_off;			/* Refuse to move icons which are invisible */			if (Seln[nseln].y >= Fv_winheight)				continue;			if (Fv_style & FV_DICON)				Seln[nseln].pr = 				       (*f_p)->icon>EMPTY && Fv_bind[(*f_p)->icon].icon 					? Fv_bind[(*f_p)->icon].icon					: Fv_icon[(*f_p)->type];			else				Seln[nseln].pr = Fv_list_icon[(*f_p)->type];			nseln++;			if (nseln == 64)			{				fv_putmsg(TRUE, "Sorry, only 64 files can be dragged; all will be %s",					(int)(copy ? "copied" : "moved"), 0);				break;			}		}	really_drag = copy;	/* Leave original in place for copy */	target = EMPTY;	lock = EMPTY;	tree_target = NULL;	tree_lock = NULL;	while(window_read_event(Fv_frame, &ev) != -1 && event_id(&ev) != MS_LEFT)	{		x1 = event_x(&ev);		y1 = event_y(&ev);#ifdef SV1		/* When copying files; we don't want to remove the		 * images in the first iteration so as to give the		 * user the illusion of having made a physical copy		 * of the icons.		 */		if (really_drag==FALSE)		{			for (i=0; i<nseln; i++)				PAINT Seln[i].x, Seln[i].y,					iconwidth, iconheight,					PIX_SRC^PIX_DST,					Seln[i].pr, 0, 0);		}		really_drag=FALSE;#endif		/* As the user drags his objects over folders we		 * need to provide him with feedback indication that		 * he can place the objects in this folder.  This can		 * be difficult to do as the sampling of events drops		 * as the mouse is moved faster.  So, for instance,		 * we could be over a folder in the tree and on the		 * next event, over a folder in the folder pane.		 */		if (y1>=tree_top && y1<=foldr_top)		{			/* In tree canvas...over anything? */			t_p = fv_infolder(x1-Fv_margin, y1-tree_top);			fv_tree_feedback(t_p, &tree_target, &tree_lock,				Fv_current, target_tree_path);		}		else if (y1>=foldr_top && y1<=Fv_winheight)		{			/* In folder canvas.  			 * List icon folder just get inverted if you can			 * open them; nothing happens if you can't.			 */			i=over_object(x1-Fv_margin, y1-foldr_top);			if (i != -1 && Fv_file[i]->type == FV_IFOLDER &&				!Fv_file[i]->selected)			{				if (target != i)				{					if (target != EMPTY)					{						/* Close old... */						draw_folder(target, FALSE);						target = EMPTY;					}					if (access(Fv_file[i]->name, W_OK) == 0)					{						/* Open new... */						draw_folder(i, TRUE);						target = i;					}					else if (lock != i && Fv_style & FV_DICON)					{						/* Show lock... */						if (lock != EMPTY)							pw_rop(Fv_foldr.pw,								Fv_file[lock]->x,								trans(lock),								GLYPH_WIDTH, 								GLYPH_HEIGHT, PIX_SRC, 								Fv_icon[FV_IFOLDER], 0, 0);						target = EMPTY;						lock = i;						pw_rop(Fv_foldr.pw,							Fv_file[lock]->x,							trans(lock),							GLYPH_WIDTH, 							GLYPH_HEIGHT, PIX_SRC, 							Fv_lock, 0, 0);					}				}			}			else if (target != EMPTY || lock != EMPTY)			{				/* Empty space; close/unlock */				if (lock != EMPTY)					target = lock;				draw_folder(target, FALSE);				target = EMPTY;				lock = EMPTY;			}		}				/* Draw new images after movement */		for (i=0; i<nseln; i++)		{			Seln[i].x += x1-x;			Seln[i].y += y1-y;#ifdef SV1			PAINT Seln[i].x, Seln[i].y,				iconwidth, iconheight,				PIX_SRC^PIX_DST, Seln[i].pr, 0, 0);#endif		}		x = x1;		y = y1;	}#ifdef SV1	/* Restore original object outline.  */	if (!copy)		for (i=0; i<nseln; i++)		{			if ((Fv_style & FV_DICON) || !Fv_style )				x = Fv_file[Seln[i].fno]->x+Fv_margin+x_off;			else				x = MARGIN+Fv_margin+x_off;			PAINT x, trans(Seln[i].fno)-				scroll_offset+foldr_top+y_off,				iconwidth, iconheight,				PIX_SRC^PIX_DST, 				Seln[i].pr, 0, 0);		}	/* Remove last position */	for (i=0; i<nseln; i++)		PAINT Seln[i].x, Seln[i].y, 			iconwidth, iconheight,			PIX_SRC^PIX_DST, Seln[i].pr, 0, 0);	fv_cursor(fd, FALSE);	/* Stop looking for all events */	win_releaseio(fd);#endif	fullscreen_destroy(fs);	desktop_link = FALSE;	winx = (int)window_get(Fv_frame, WIN_X);	winy = (int)window_get(Fv_frame, WIN_Y);#ifdef SV1	if (rootfd = open(getenv("WINDOW_PARENT"), O_RDONLY))#endif	{#ifdef SV1		i = win_findintersect(rootfd, winx+x1, winy+y1);#else		i = win_pointer_under(Fv_frame, x1, y1);#endif		/* Copy out to desktop if not over fileview or not over 		 * client */#ifdef SV1		if (i != (int)window_get(Fv_foldr.canvas, WIN_DEVICE_NUMBER) &&		    i != (int)window_get(Fv_tree.canvas, WIN_DEVICE_NUMBER) &&		    load_file(i) == -1 &&		    fv_load_client(i) == -1)#else		if (i == 0)#endif		{#ifndef SV1			int data[5];			data[0] = (int)VU_POINTER_WINDOW;			data[1] = x1;			data[2] = y1;			data[3] = (int)vu_get(Fv_frame, VU_XID);			(void)fv_set_primary_selection();			vu_send_message(Fv_frame, 0, "VU_DO_DRAG_LOAD",				32, data, 16);#else			desktop_link = TRUE;			for (i=0; i<nseln; i++)			{				/* Ensure icon will be visible */				x = winx+Seln[i].x;				if (x < 0)					x = 0;				if (x>Fv_screenwidth-64)					x = Fv_screenwidth-64;				y = winy+Seln[i].y;				if (y < 0)					y = 0;				if (y>Fv_screenheight-64)					y = Fv_screenheight-64;				link_to_desktop(Fv_file[Seln[i].fno], x, y);			}#endif		}#ifdef SV1		(void)close(rootfd);#endif	}	fv_busy_cursor(TRUE);	/* If user has moved back into folder pane then don't 	 * move/copy into last opened folder in tree.	 */	if (y1>=foldr_top && y1<=Fv_winheight && tree_target)		desktop_link = TRUE;	if (target != EMPTY || lock != EMPTY)	{		/* XXX It is possible to have locked/open folders in folder pane		 * without being over them.		 */		if (desktop_link)			target = target != EMPTY ? target : lock;		else			if (target != EMPTY)			{				(void)fv_move_copy(Fv_file[target]->name, copy);				target = EMPTY;			}			else				target = lock;		if (target != EMPTY)			pw_rop(Fv_foldr.pw, Fv_file[target]->x, 				trans(target)-scroll_offset, iconwidth, 				iconheight, PIX_SRC, Fv_icon[FV_IFOLDER], 0, 0);	}	else if (tree_target || tree_lock)	{		if (desktop_link)			tree_target = tree_target ? tree_target : tree_lock;		else			if (tree_target)				(void)fv_move_copy(target_tree_path, copy);			else				tree_target = tree_lock;		pw_rop(Fv_tree.pw, tree_target->x, tree_target->y,			GLYPH_WIDTH, TREE_GLYPH_HEIGHT, PIX_SRC, 			Fv_icon[FV_IFOLDER], 0, TREE_GLYPH_TOP);		fv_put_text_on_folder(tree_target);	}	else if (!desktop_link && copy)		fv_duplicate();	fv_busy_cursor(FALSE);}staticdraw_folder(i, open)		/* Show folder in the folder pane open/close */	register int i;		/* File index */	BOOLEAN open;		/* Display opened? */{	SBYTE color =  Fv_file[i]->color;	if (Fv_style & FV_DICON)	{		pw_rop(Fv_foldr.pw, Fv_file[i]->x, trans(i),			GLYPH_WIDTH, GLYPH_HEIGHT, PIX_SRC | PIX_COLOR(color),			Fv_icon[open?FV_IOPENFOLDER:FV_IFOLDER], 0, 0);		if (open)			pw_rop(Fv_foldr.pw, Fv_file[i]->x,				trans(i), GLYPH_WIDTH, GLYPH_HEIGHT,				(PIX_SRC^PIX_DST) | PIX_COLOR(color),				Fv_invert[FV_IOPENFOLDER], 0, 0);	}	else		fv_reverse(i);}staticlink_to_desktop(f_p, x, y)	/* Load appl with file and place on desktop */	register FV_FILE *f_p;	/* File */	int x, y;		/* Location */{	char buf[MAXPATH];	/* buffer */	Frame f;		/* Folder frame */	int argc;		/* # Frame arguments */	char *argv[10];		/* Frame arguments */	Rect *r;		/* Icon rect */	char red[4], blue[4], green[4];	/* RGB color strings */	if (f_p->color > BLACK)	{		/* Paint window with file's colors */		(void)sprintf(red, "%d", Fv_red[f_p->color]);		(void)sprintf(green, "%d", Fv_green[f_p->color]);		(void)sprintf(blue, "%d", Fv_blue[f_p->color]);	}	if (f_p->type == FV_IFOLDER)	{#ifdef SV1		F_icon.ic_width = 64;		F_icon.ic_height = 48;		F_icon.ic_gfxrect.r_width = 64;		F_icon.ic_gfxrect.r_height = 48;		F_icon.ic_mpr = &f_icon_pr;#endif		(void)sprintf(buf, "fileview: %s/%s", 			*Fv_path ? Fv_path : "", f_p->name);					if (f_p->color > BLACK)		{			argc = 5;			argv[0] = f_p->name;			argv[1] = "-Wb";			argv[2] = red;			argv[3] = green;			argv[4] = blue;			argv[5] = 0;		}		else		{			argc = 0;			argv[0] = 0;		}		if ((f = window_create(0, FRAME,			FRAME_ARGS, argc, argv,#ifdef SV1			FRAME_ICON, &F_icon,#else			FRAME_ICON, vu_create(VU_NULL, ICON, ICON_IMAGE,					&f_icon_pr, VU_WIDTH, 64, VU_HEIGHT, 48, 0),#endif			FRAME_CLOSED, TRUE,			FRAME_NO_CONFIRM, TRUE,			FRAME_LABEL, buf,			0)) &&		    (window_create(f, CANVAS,			CANVAS_WIDTH, 400,			CANVAS_HEIGHT, 200,			0)))		{#ifdef PROTO			frame_set_font_size(f, 				window_get(Fv_frame, WIN_FONT_SIZE));#endif			fv_name_icon(f, f_p->name);			if (r = (Rect *)window_get(f, FRAME_CLOSED_RECT))			{				r->r_top = y;				r->r_left = x;				window_set(f, FRAME_CLOSED_RECT, r,					WIN_SHOW, TRUE, 0);			}			if (Nfolders < MAX_FOLDERS)			{				/* Keep track of folders */				Folder_frame[Nfolders] = f;				Nfolders++;			}		}		else			fv_putmsg(TRUE, Fv_message[MEWIN], 0, 0);	}	else if (f_p->type == FV_IAPPLICATION || f_p->type == FV_IDOCUMENT)	{		char xpos[6], ypos[6];		if (f_p->type == FV_IDOCUMENT && 			(f_p->icon == EMPTY || *Fv_bind[f_p->icon].application==0))			edit(f_p->name, (char *)0, x, y, f_p->color);		else		{			if (f_p->type == FV_IAPPLICATION)				argv[0] = f_p->name; 			else				argv[0]=Fv_bind[f_p->icon].application;			argv[1] = "-Wi";			argv[2] = "-WP";			(void)sprintf(xpos, "%d", x);			(void)sprintf(ypos, "%d", y);			argv[3] = xpos;			argv[4] = ypos;			argc = 5;			if (f_p->color > BLACK)			{				argv[argc++] = "-Wb";				argv[argc++] = red;				argv[argc++] = green;				argv[argc++] = blue;			}			if (f_p->type == FV_IDOCUMENT)				argv[argc++] = f_p->name;			argv[argc] = 0;			fv_putmsg(FALSE, Fv_message[MLINK], (int)f_p->name, 0);			fv_execit(argv[0], argv);		}	}}fv_display_folder(mode)	BYTE mode;			/* Build, style change, display? */{	register FV_FILE **f_p, **nf_p, **l_p;	/* Files array pointers */	register int j;			/* Indeces */	register int lower, upper, mid;	/* Binary search variables */	time_t mtime;			/* Change date on folder */	BOOLEAN new;			/* Tree changed? */	FV_FILE *deleted[MAXFILES];	/* Deleted files */	short ndeleted;			/* Number of deleted files */	if (mode == FV_BUILD_FOLDER)		build_folder(&mtime);	else 		Ncolors = 0;	if (mode <= FV_STYLE_FOLDER)	{		/* Find bound icons and applications, clear selection */		for (f_p=Fv_file, l_p=Fv_file+Fv_nfiles; f_p < l_p; f_p++)		{			/* Look for bound icons... */			(*f_p)->icon = EMPTY;			if (Fv_style & FV_DICON)			{				if ((*f_p)->type == FV_IAPPLICATION && Fv_nappbind)				{					/* Binary search for application icon */					lower=0;					upper=Fv_nappbind-1;					while (lower<=upper)					{						mid = (lower+upper)/2;						if ((j=strcmp((*f_p)->name, 							Fv_bind[mid].pattern))<0)							upper = mid-1;						else if (j>0)							lower = mid+1;						else						{							(*f_p)->icon = mid;							break;						}					}				}				if ( (*f_p)->icon == EMPTY &&				     (*f_p)->type == FV_IDOCUMENT )					check_bind(*f_p);			}			(*f_p)->selected = FALSE;			if (Ncolors)			{				/* Binary search for color entry */				lower=0;				upper=Ncolors-1;				while (lower<=upper)				{					mid = (lower+upper)/2;					if ((j=strcmp((*f_p)->name, Color_fname[mid]))<0)						upper = mid-1;					else if (j>0)						lower = mid+1;					else					{						(*f_p)->color = Color_code[mid];						break;					}				}			}		}		/* Sort files */		if (Fv_sortby != FV_NOSORT)			qsort((char *)Fv_file, Fv_nfiles, sizeof(FV_FILE *),				Compare_fn[Fv_sortby]);		display_folder(Fv_foldr.canvas, Fv_foldr.pw, (Rectlist *)0);		if (mode == FV_BUILD_FOLDER)		{			/* XXX Can we combine these? */			if (Fv_current->mtime == 0)			{				/* Tell tree that we've opened a folder				 * that he hasn't seen before.				 */				Fv_current->mtime = mtime;				fv_updatetree();			}			else if (Fv_current->mtime < mtime)			{				fv_add_children(Fv_current, &new, (char *)0);				if (new && Fv_treeview)					fv_drawtree(TRUE);			}		}		return;	}	if (mode == FV_SMALLER_FOLDER)	{

⌨️ 快捷键说明

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