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

📄 listedit.c

📁 ELinks is an advanced and well-established feature-rich text mode web (HTTP/FTP/..) browser. ELinks
💻 C
📖 第 1 页 / 共 5 页
字号:
			draw_to_window(dlg->win,redraw_list,&rd);			draw_to_window(dlg->win,redraw_list_line,&rd);			return EVENT_PROCESSED;		}		if (ev->x==KBD_PAGE_DOWN || (upcase(ev->x) == 'F' && ev->y & KBD_CTRL))		{			int a;			struct list*p=ld->win_offset;			if (ld->current_pos==prev_in_tree(ld,ld->list))return EVENT_PROCESSED;  /* already on the bottom */			for (a=0;a<ld->n_items&&ld->list!=next_in_tree(ld,p);a++)				p=next_in_tree(ld,p);			if (a<ld->n_items)  /* already last screen */			{				ld->current_pos=p;				ld->win_pos=a;				rd.n=0;				draw_to_window(dlg->win,redraw_list,&rd);				draw_to_window(dlg->win,redraw_list_line,&rd);				return EVENT_PROCESSED;			}			/* here is whole screen only - the window was full before pressing the page-down key */			/* p is pointing behind last item of the window (behind last visible item in the window) */			for (a=0;a<ld->n_items&&p!=ld->list;a++)			{				ld->win_offset=next_in_tree(ld,ld->win_offset);				ld->current_pos=next_in_tree(ld,ld->current_pos);				p=next_in_tree(ld,p);			}			if (a<ld->n_items){ld->current_pos=prev_in_tree(ld,ld->list);ld->win_pos=ld->n_items-1;}			rd.n=0;			draw_to_window(dlg->win,redraw_list,&rd);			draw_to_window(dlg->win,redraw_list_line,&rd);			return EVENT_PROCESSED;		}		break;		case EV_MOUSE:		/* toggle select item */		if ((ev->b&BM_ACT)==B_DOWN&&(ev->b&BM_BUTT)==B_RIGHT)		{			int n,a;			struct list *l=ld->win_offset;			last_mouse_y=ev->y;			if (				(ev->y)<(dlg->y+DIALOG_TB)||				(ev->y)>=(dlg->y+DIALOG_TB+gf_val(ld->n_items,G_BFU_FONT_SIZE*(ld->n_items)))||				(ev->x)<(dlg->x+DIALOG_LB)||				(ev->x)>(dlg->x+dlg->xw-DIALOG_LB-(F?sirka_scrollovadla:0))			)break;  /* out of the dialog */						n=(ev->y-dlg->y-DIALOG_TB)/gf_val(1,G_BFU_FONT_SIZE);			for (a=0;a<n;a++)			{				struct list *l1;				l1=next_in_tree(ld,l);  /* current item under the mouse pointer */				if (l1==ld->list)break;				else l=l1;			}			a=ld->type?((l->depth)>=0?(l->depth)+1:0):(l->depth>=0);			l->type^=4;			ld->current_pos=l;			ld->win_pos=n;			rd.n=0;			draw_to_window(dlg->win,redraw_list,&rd);			return EVENT_PROCESSED;		}		/* click on item */		if ((ev->b&BM_ACT)==B_DOWN&&(ev->b&BM_BUTT)==B_LEFT)		{			int n,a;			struct list *l=ld->win_offset;			last_mouse_y=ev->y;			if (				(ev->y)<(dlg->y+DIALOG_TB)||				(ev->y)>=(dlg->y+DIALOG_TB+gf_val(ld->n_items,G_BFU_FONT_SIZE*(ld->n_items)))||				(ev->x)<(dlg->x+DIALOG_LB)||				(ev->x)>(dlg->x+dlg->xw-DIALOG_LB-(F?sirka_scrollovadla:0))			)break;  /* out of the dialog */						n=(ev->y-dlg->y-DIALOG_TB)/gf_val(1,G_BFU_FONT_SIZE);			for (a=0;a<n;a++)			{				struct list *l1;				l1=next_in_tree(ld,l);  /* current item under the mouse pointer */				if (l1==ld->list)break;				else l=l1;			}			a=ld->type?((l->depth)>=0?(l->depth)+1:0):(l->depth>=0);			ld->current_pos=l;			/* clicked on directory graphical stuff */			if ((ld->type)&&(ev->x)<(dlg->x+DIALOG_LB+a*BFU_ELEMENT_WIDTH)&&((l->type)&1))			{				l->type^=2;				if (!(l->type&2))unselect_in_folder(ld, ld->current_pos);			}			ld->win_pos=n;			rd.n=0;			draw_to_window(dlg->win,redraw_list,&rd);			return EVENT_PROCESSED;		}		/* scroll with the bar */#ifdef G		if (F&&((ev->b&BM_ACT)==B_DRAG&&(ev->b&BM_BUTT)==B_LEFT))		{			int total=get_total_items(ld);			int scroll_pos=get_scroll_pos(ld);			signed long delta;			long h=ld->n_items*G_BFU_FONT_SIZE;			if (				(ev->y)<(dlg->y+DIALOG_TB)||				(ev->y)>=(dlg->y+DIALOG_TB+G_BFU_FONT_SIZE*(ld->n_items))||				(ev->x)<(dlg->x+dlg->xw-DIALOG_LB-G_SCROLL_BAR_WIDTH)||				(ev->x)>(dlg->x+dlg->xw-DIALOG_LB)			)break;  /* out of the dialog */						delta=(ev->y-dlg->y-DIALOG_TB)*total/h-scroll_pos;						last_mouse_y=ev->y;			if (delta>0)  /* scroll down */			{				struct list *lll=find_last_in_window(ld);								if (next_in_tree(ld,lll)==ld->list)return EVENT_PROCESSED;  /* already at the bottom */				ld->current_pos=next_in_tree(ld,lll);				ld->win_offset=next_in_tree(ld,ld->win_offset);				ld->win_pos=ld->n_items-1;				rd.n=-1;				draw_to_window(dlg->win,scroll_list,&rd);				draw_to_window(dlg->win,redraw_list_line,&rd);			}			if (delta<0)  /* scroll up */			{				if (ld->win_offset==ld->list)return EVENT_PROCESSED;  /* already on the top */				ld->win_offset=prev_in_tree(ld,ld->win_offset);				ld->current_pos=ld->win_offset;				ld->win_pos=0;				rd.n=+1;				draw_to_window(dlg->win,scroll_list,&rd);				draw_to_window(dlg->win,redraw_list_line,&rd);			}			return EVENT_PROCESSED;		}#endif		if ((ev->b&BM_ACT)==B_DRAG&&(ev->b&BM_BUTT)==B_MIDDLE)		{			long delta=(ev->y-last_mouse_y)/MOUSE_SCROLL_DIVIDER;			last_mouse_y=ev->y;			if (delta>0)  /* scroll down */			{				if (next_in_tree(ld,ld->current_pos)==ld->list)return EVENT_PROCESSED;  /* already at the bottom */				ld->current_pos=next_in_tree(ld,ld->current_pos);				ld->win_pos++;				rd.n=-1;				if (ld->win_pos>ld->n_items-1)  /* scroll down */				{					ld->win_pos=ld->n_items-1;					ld->win_offset=next_in_tree(ld,ld->win_offset);					draw_to_window(dlg->win,scroll_list,&rd);				}				draw_to_window(dlg->win,redraw_list_line,&rd);			}			if (delta<0)  /* scroll up */			{				if (ld->current_pos==ld->list)return EVENT_PROCESSED;  /* already on the top */				ld->current_pos=prev_in_tree(ld,ld->current_pos);				ld->win_pos--;				rd.n=+1;				if (ld->win_pos<0)  /* scroll up */				{					ld->win_pos=0;					ld->win_offset=prev_in_tree(ld,ld->win_offset);					draw_to_window(dlg->win,scroll_list,&rd);				}				draw_to_window(dlg->win,redraw_list_line,&rd);			}			return EVENT_PROCESSED;		}		/* mouse wheel */		if ((ev->b&BM_ACT)==B_MOVE&&((ev->b&BM_BUTT)==B_WHEELUP||(ev->b&BM_BUTT)==B_WHEELDOWN||(ev->b&BM_BUTT)==B_WHEELDOWN1||(ev->b&BM_BUTT)==B_WHEELUP1))		{			int button=(ev->b)&BM_BUTT;			last_mouse_y=ev->y;			if (button==B_WHEELDOWN||button==B_WHEELDOWN1)  /* scroll down */			{				if (next_in_tree(ld,ld->current_pos)==ld->list)return EVENT_PROCESSED;  /* already at the bottom */				ld->current_pos=next_in_tree(ld,ld->current_pos);				ld->win_pos++;				rd.n=-1;				if (ld->win_pos>ld->n_items-1)  /* scroll down */				{					ld->win_pos=ld->n_items-1;					ld->win_offset=next_in_tree(ld,ld->win_offset);					draw_to_window(dlg->win,scroll_list,&rd);				}				draw_to_window(dlg->win,redraw_list_line,&rd);			}			if (button==B_WHEELUP||button==B_WHEELUP1)  /* scroll up */			{				if (ld->current_pos==ld->list)return EVENT_PROCESSED;  /* already on the top */				ld->current_pos=prev_in_tree(ld,ld->current_pos);				ld->win_pos--;				rd.n=+1;				if (ld->win_pos<0)  /* scroll up */				{					ld->win_pos=0;					ld->win_offset=prev_in_tree(ld,ld->win_offset);					draw_to_window(dlg->win,scroll_list,&rd);				}				draw_to_window(dlg->win,redraw_list_line,&rd);			}			return EVENT_PROCESSED;		}		break;				case EV_INIT:		case EV_RESIZE:		case EV_REDRAW:		case EV_ABORT:		break;		default:		internal("Unknown event received: %d", ev->ev);	}	return EVENT_NOT_PROCESSED;}/* display function for the list window */void create_list_window_fn(struct dialog_data *dlg){	struct terminal *term=dlg->win->term;	struct list_description *ld=(struct list_description*)(dlg->dlg->udata2);	int min=0;	int w,rw,y;	struct redraw_data rd;	int a=6;	ld->dlg=dlg;	if (ld->button_fn)a++;  /* user button */	if (ld->type==1)a++;  /* add directory button */	y=gf_val(ld->n_items,ld->n_items*G_BFU_FONT_SIZE);	min_buttons_width(term, dlg->items, a, &min);		w=gf_val(ld->window_width,ld->window_width*G_BFU_FONT_SIZE);	if (w<min)w=min;	if (w>term->x-2*DIALOG_LB)w=term->x-2*DIALOG_LB;	if (w<5)w=5;		rw=0;	dlg_format_buttons(dlg, NULL, dlg->items, a, 0, &y, w, &rw, AL_CENTER);	rw=w;	dlg->xw=rw+2*DIALOG_LB;	dlg->yw=y+2*DIALOG_TB;	center_dlg(dlg);	draw_dlg(dlg);	rd.ld=ld;	rd.dlg=dlg;	rd.n=0;		draw_to_window(dlg->win,redraw_list,&rd);		y=dlg->y+DIALOG_TB+gf_val(ld->n_items+1,(ld->n_items+1)*G_BFU_FONT_SIZE);	dlg_format_buttons(dlg, term, dlg->items, a, dlg->x+DIALOG_LB, &y, w, &rw, AL_CENTER);}void close_list_window(struct dialog_data *dlg){	struct dialog *d=dlg->dlg;	struct list_description *ld=(struct list_description*)(d->udata2);	ld->open=0;	ld->dlg=NULL;	if (ld->search_word) mem_free(ld->search_word);	ld->search_word=NULL;}/* dialog->udata2  ...  list_description  *//* dialog->udata   ...  session */int create_list_window(	struct list_description *ld,	struct list *list, 	struct terminal *term,	struct session *ses	){	struct dialog *d;	int a;	/* zavodime, zavodime... */	if (!(ld->open))ld->open=1;	else /* already in use */	{		msg_box(			term,			NULL,			TEXT(T_INFO),			AL_CENTER,			TEXT(ld->already_in_use),			NULL,			1,			TEXT(T_OK),NULL,B_ENTER|B_ESC		);		return 1;	}		if (!ld->current_pos)	{		ld->current_pos=list;		ld->win_offset=list;		ld->win_pos=0;		ld->dlg=NULL;	}	a=7;	if (ld->button_fn)a++;	if (ld->type==1)a++;	d = mem_calloc(sizeof(struct dialog) + a * sizeof(struct dialog_item));		d->title=TEXT(ld->window_title);	d->fn=create_list_window_fn;	d->abort=close_list_window;	d->handle_event=list_event_handler;	d->udata=ses;	d->udata2=ld;		a=0;	if (ld->button_fn)	{		d->items[a].type=D_BUTTON;		d->items[a].fn=list_item_button;		d->items[a].text=TEXT(ld->button);		a++;	}	if (ld->type==1)	{		d->items[a].type=D_BUTTON;		d->items[a].text=TEXT(T_FOLDER);		d->items[a].fn=list_folder_add;		a++;	}	d->items[a].type=D_BUTTON;	d->items[a].text=TEXT(T_ADD);	d->items[a].fn=list_item_add;		d->items[a+1].type=D_BUTTON;	d->items[a+1].text=TEXT(T_DELETE);	d->items[a+1].fn=list_item_delete;		d->items[a+2].type=D_BUTTON;	d->items[a+2].text=TEXT(T_EDIT);	d->items[a+2].fn=list_item_edit;		d->items[a+3].type=D_BUTTON;	d->items[a+3].text=TEXT(T_MOVE);	d->items[a+3].fn=list_item_move;		d->items[a+4].type=D_BUTTON;	d->items[a+4].text=TEXT(T_UNSELECT_ALL);	d->items[a+4].fn=list_item_unselect;		d->items[a+5].type=D_BUTTON;	d->items[a+5].gid=B_ESC;	d->items[a+5].fn=cancel_dialog;	d->items[a+5].text=TEXT(T_CLOSE);	d->items[a+6].type=D_END;	do_dialog(term, d, getml(d, NULL));	return 0;}void redraw_list_window(struct list_description *ld){	struct redraw_data rd;	if (!(ld->open)||!(ld->dlg))return;	rd.ld=ld;	rd.dlg=ld->dlg;	rd.n=0;		draw_to_window(ld->dlg->win,redraw_list,&rd);}void reinit_list_window(struct list_description *ld){	struct redraw_data rd;	ld->current_pos=ld->list;	ld->win_offset=ld->list;	ld->win_pos=0;	if (!(ld->open)||!(ld->dlg))return;	rd.ld=ld;	rd.dlg=ld->dlg;	rd.n=0;		draw_to_window(ld->dlg->win,redraw_list,&rd);}

⌨️ 快捷键说明

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