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

📄 htdialog.cc

📁 功能较全面的反汇编器:反汇编器ht-2.0.15.tar.gz
💻 CC
📖 第 1 页 / 共 4 页
字号:
}void	ht_text_listbox::insert_str(int id, const char **strs){	insert_str_extra(id, NULL, strs);}void ht_text_listbox::insert_str(int id, const char *str, ...){	// FIXME: same as insert_str(id, NULL, str, ...)	ht_text_listbox_item *item = ht_malloc(sizeof(ht_text_listbox_item)+sizeof(char *)*cols);	item->next = NULL;	item->prev = last;	item->id = id;	item->extra_data = NULL;	va_list str2;	va_start(str2, str);	const char *str3 = str;	for (int i=0; i<cols; i++) {		int slen = strlen(str3);		if (slen > widths[i]) {			widths[i] = slen;		}		item->data[i] = ht_strdup(str3);		str3 = va_arg(str2, char *);	}	va_end(str2);	if (first) {		last->next = item;	} else {		first = item;	}	last = item;	count++;}int ht_text_listbox::numColumns(){	return cols;}void *ht_text_listbox::quickfind(const char *s){	ht_text_listbox_item *item = first;	int slen = strlen(s);	while (item && (compare_strn(item->data[keycol], s, slen)!=0)) {		item = item->next;	}	return item;}char *ht_text_listbox::quickfindCompletition(const char *s){	ht_text_listbox_item *item = first;	char *res = NULL;	int slen = strlen(s);	while (item) {		if (compare_strn(item->data[keycol], s, slen)==0) {			if (!res) {				res = ht_strdup(item->data[keycol]);			} else {				int a = compare_ccomm(item->data[keycol], res);				res[a] = 0;			}		}		item = item->next;	}	return res;}static int ht_text_listboxcomparatio(ht_text_listbox_item *a, ht_text_listbox_item *b, int count, ht_text_listbox_sort_order *so){	for (int i=0;i<count;i++) {		int r = so[i].compare_func(a->data[so[i].col], b->data[so[i].col]);		if (r!=0) return r;	}	return 0;}static void ht_text_listboxqsort(int l, int r, int count, ht_text_listbox_sort_order *so, ht_text_listbox_item **list){	int m = (l+r)/2;	int L = l;	int R = r;	ht_text_listbox_item *c = list[m];	do {		while (l <= r && ht_text_listboxcomparatio(list[l], c, count, so) < 0) l++;		while (l <= r && ht_text_listboxcomparatio(list[r], c, count, so) > 0) r--;		if (l<=r) {			ht_text_listbox_item *t = list[l];			list[l] = list[r];			list[r] = t;			l++;			r--;		}	} while(l < r);	if (L < r) ht_text_listboxqsort(L, r, count, so, list);	if (l < R) ht_text_listboxqsort(l, R, count, so, list);}void ht_text_listbox::sort(int count, ht_text_listbox_sort_order *so){	ht_text_listbox_item **list;	ht_text_listbox_item *tmp;	int i=0;	int cnt = calcCount();	if (cnt < 2) return;		list = ht_malloc(cnt*sizeof(void *));	tmp = first;	while (tmp) {		list[i++] = tmp;		tmp = (ht_text_listbox_item *)getNext(tmp);	}	int c_id = ((ht_text_listbox_item*)e_cursor)->id;	ht_text_listboxqsort(0, cnt-1, count, so, list);	for (i=0; i<cnt; i++) {		if (list[i]->id == c_id) {			pos = i;			e_cursor = list[i];		}	}	first = list[0];	last = list[cnt-1];	first->prev = NULL;	last->next = NULL;	last->prev = list[cnt-2];	tmp = first->next = list[1];	for (i=1; i<cnt-1; i++) {		tmp->prev = list[i-1];		tmp->next = list[i+1];		tmp = list[i+1];	}	free(list);	update();	stateChanged();}void ht_text_listbox::update(){	ht_listbox::update();	Cursor_adjust = 0;	if (widths) {		for (int i=0; i<keycol; i++) {			Cursor_adjust+=widths[i]+3;		}	}}/* *	CLASS ht_itext_listbox */void	ht_itext_listbox::init(Bounds *b, int Cols, int Keycol){	ht_text_listbox::init(b, Cols, Keycol);}int	ht_itext_listbox::compare_strn(const char *s1, const char *s2, int l){	return ht_strnicmp(s1, s2, l);}int	ht_itext_listbox::compare_ccomm(const char *s1, const char *s2){	return ht_strcicomm(s1, s2);}/* *	CLASS ht_statictext */#define STATICTEXT_MIN_LINE_FILL 70	/* percent */void ht_statictext_align(ht_statictext_linedesc *d, statictext_align align, int w){	switch (align) {	case align_center:		d->ofs = (w-d->len)/2;		break;	case align_right:		d->ofs = w-d->len;		break;	default:		d->ofs = 0;		break;	}}void ht_statictext::init(Bounds *b, const char *t, statictext_align al, bool breakl, bool trans){	ht_view::init(b, VO_OWNBUFFER | VO_RESIZE, "some statictext");	VIEW_DEBUG_NAME("ht_statictext");	align = al;	breaklines = breakl;	transparent = trans;	text = ht_strdup(t);}void ht_statictext::done(){	free(text);	ht_view::done();}const char *ht_statictext::defaultpalette(){	return palkey_generic_dialog_default;}#define ssst_word		0#define ssst_separator	1#define ssst_whitespace	2static int get_ssst(char s){	if (strchr(".,:;+-*/=()[]", s)) {		return ssst_separator;	} else if (s==' ') {		return ssst_whitespace;	}	return ssst_word;}void ht_statictext::draw(){	if (!transparent) clear(gettextcolor());	char text[size.w*size.h];	if (gettext(text, size.w*size.h) <= 0) return;	char *t = text;	if (breaklines) {		/* format string... */			ht_statictext_linedesc *orig_d = ht_malloc(sizeof (ht_statictext_linedesc)*size.h);		ht_statictext_linedesc *d = orig_d;		statictext_align lalign = align;		int c=0;		while (*t && c < size.h) {			/* custom alignment */			if (*t == ALIGN_CHAR_ESCAPE && align == align_custom) {				switch (t[1]) {				case ALIGN_CHAR_LEFT:					lalign=align_left;					break;				case ALIGN_CHAR_CENTER:					lalign=align_center;					break;				case ALIGN_CHAR_RIGHT:					lalign=align_right;					break;				}				t+=2;			}			/* determine line length */			int i=0, len=1;			char *bp = t+1;			char *n = t+1;			int ssst = get_ssst(t[i]);			while (t[i]) {				if (i+1 > size.w || t[i]=='\n' || !t[i+1]) {					bool kill_ws = (t[i]!='\n');					if (i+1 <= size.w) {						/* line shorter than size.w */						bp=t+i+1;					} else if (t[i]=='\n') {						/* line end */						bp=t+i+1;					} else if (size.w && ((bp-t)*100/size.w < STATICTEXT_MIN_LINE_FILL)) {						/* force break to make line long enough */						bp=t+i;					}					len=bp-t;					if (t[len-1]=='\n') len--;					n=bp;					if (kill_ws) {						while (*n==' ') n++;						while (t[len-1]==' ') len--;					}					break;				}				int s=get_ssst(t[i+1]);				if ((ssst!=s) || (ssst==ssst_separator)) {					bp=t+i+1;				}				ssst=s;				i++;			}			d->text=t;			d->len=len;			ht_statictext_align(d, lalign, size.w);			d++;			c++;			t=n;		}/**/		d = orig_d;		for (int i=0; i<c; i++) {			buf->nprint(d->ofs, i, gettextcolor(), d->text, d->len);			d++;		}		free(orig_d);	} else {		int o=0;		buf->print(o, 0, gettextcolor(), t);	}}vcp ht_statictext::gettextcolor(){	return getcolor(palidx_generic_body);//	return VCP(VC_RED, VC_BLACK);}int ht_statictext::gettext(char *aText, int maxlen){	if (text) {		return ht_strlcpy(aText, text, maxlen);	} else {		if (maxlen > 0) *aText = 0;		return 0;	}}void ht_statictext::settext(const char *aText){	free(text);	text = ht_strdup(aText);	dirtyview();}/* *	CLASS ht_listpopup_dialog */void ht_listpopup_dialog::init(Bounds *b, const char *desc){	ht_dialog::init(b, desc, FS_TITLE | FS_MOVE);	VIEW_DEBUG_NAME("ht_listpopup_dialog");	Bounds c;	getclientarea(&c);	c.x=0;	c.y=0;	init_text_listbox(&c);}int ht_listpopup_dialog::datasize(){	return sizeof (ht_listpopup_dialog_data);}const char *ht_listpopup_dialog::defaultpalette(){	return palkey_generic_blue;}void ht_listpopup_dialog::getdata(ObjectStream &s){	ht_listbox_data d;	ViewDataBuf vdb(listbox, &d, sizeof d);	PUTX_INT32D(s, ((ht_text_listbox*)listbox)->getID(d.data->cursor_ptr), NULL);	ht_text_listbox_item *cursor = (ht_text_listbox_item*)d.data->cursor_ptr;	if (cursor) {		PUTX_STRING(s, cursor->data[0], NULL);	} else {		PUTX_STRING(s, NULL, NULL);	}}void ht_listpopup_dialog::init_text_listbox(Bounds *b){	listbox = new ht_text_listbox();	((ht_text_listbox *)listbox)->init(b);	insert(listbox);}void ht_listpopup_dialog::insertstring(const char *string){	((ht_text_listbox *)listbox)->insert_str(listbox->calcCount(), string);	listbox->update();}void ht_listpopup_dialog::select_next(){	listbox->cursorDown(1);}void ht_listpopup_dialog::select_prev(){	listbox->cursorUp(1);}void ht_listpopup_dialog::setdata(ObjectStream &s){	int cursor_id = GETX_INT32D(s, NULL);//	free(GETX_STRING(s, NULL));	/* ignored */	listbox->gotoItemByPosition(cursor_id);}/* *	CLASS ht_listpopup */void	ht_listpopup::init(Bounds *b){	ht_statictext::init(b, 0, align_left, 0);	setoptions(options | VO_SELECTABLE);	VIEW_DEBUG_NAME("ht_listpopup");	Bounds c=*b;	c.x=0;	c.y=0;	c.h=5;		listpopup = new ht_listpopup_dialog();	listpopup->init(&c, 0);}void	ht_listpopup::done(){	listpopup->done();	delete listpopup;		ht_view::done();}int ht_listpopup::datasize(){	return listpopup->datasize();}void ht_listpopup::draw(){	ht_statictext::draw();	buf->printChar(size.w-1, 0, gettextcolor(), GC_SMALL_ARROW_DOWN, CP_GRAPHICAL);}vcp ht_listpopup::gettextcolor(){	return focused ? getcolor(palidx_generic_input_selected) :		getcolor(palidx_generic_input_focused);}void ht_listpopup::getdata(ObjectStream &s){	listpopup->getdata(s);}int ht_listpopup::gettext(char *text, int maxlen){	ht_listpopup_dialog_data d;	ViewDataBuf vdb(listpopup, &d, sizeof d);	return ht_strlcpy(text, d.cursor_string, maxlen);}void ht_listpopup::handlemsg(htmsg *msg){	if (msg->msg == msg_keypressed) {		switch (msg->data1.integer) {		case K_Up: {			int r;			ht_listpopup_dialog_data d;			ViewDataBuf vdb(listpopup, &d, sizeof d);			listpopup->select_prev();			r = run_listpopup();			clearmsg(msg);			if (!r) listpopup->databuf_set(&d, sizeof d);			return;		}		case K_Down: {			int r;			ht_listpopup_dialog_data d;			ViewDataBuf vdb(listpopup, &d, sizeof d);			listpopup->select_next();			r = run_listpopup();			clearmsg(msg);			if (!r) listpopup->databuf_set(&d, sizeof d);			return;		}						}	}	ht_statictext::handlemsg(msg);}int ht_listpopup::run_listpopup(){	int r;	listpopup->relocate_to(this);	r = listpopup->run(false);	listpopup->unrelocate_to(this);	return r;}void ht_listpopup::insertstring(const char *string){	listpopup->insertstring(string);}void ht_listpopup::setdata(ObjectStream &s){	listpopup->setdata(s);}/* *	CLASS ht_label */void ht_label::init(Bounds *b, const char *_text, ht_view *_connected){	ht_view::init(b, VO_POSTPROCESS, 0);	text = ht_strdup(_text);	magicchar = strchr(text, '~');	if (magicchar) {		int l = strlen(text);		memmove(magicchar, magicchar+1, l-(magicchar-text));	}	connected = _connected;	if (magicchar) {		shortcut = keyb_metakey((ht_key)*magicchar);	} else {		shortcut = K_INVALID;	}}void ht_label::done(){	free(text);	ht_view::done();}const char *ht_label::defaultpalette(){	return palkey_generic_dialog_default;}void ht_label::draw(){	vcp c;	vcp sc = getcolor(palidx_generic_text_shortcut);	if (connected->focused) {		c = getcolor(palidx_generic_text_focused);	} else {		c = getcolor(palidx_generic_text_unfocused);	}	buf->nprint(0, 0, c, text, size.w);	if (magicchar) buf->printChar(magicchar-text, 0, sc, *magicchar);}void ht_label::handlemsg(htmsg *msg){	if (msg->type==mt_postprocess) {		if (msg->msg==msg_keypressed) {			if ((shortcut!=-1) && (msg->data1.integer==shortcut)) {				app->focus(connected);				dirtyview();				clearmsg(msg);				return;			}		}	} else ht_view::handlemsg(msg);}/* *	CLASS ht_progress_indicator */void	ht_progress_indicator::init(Bounds *b, const char *hint){	ht_window::init(b, NULL, 0);	Bounds c=*b;	c.x=1;	c.y=1;	c.w-=c.x+2;	c.h-=c.y+3;	text=new ht_statictext();	text->init(&c, NULL, align_center, true);	insert(text);	c.y+=2;	c.h=1;	ht_statictext *t=new ht_statictext();	t->init(&c, hint, align_center);	insert(t);}const char *ht_progress_indicator::defaultpalette(){	return palkey_generic_dialog_default;}void ht_progress_indicator::settext(const char *t){	text->settext(t);}/* *	CLASS ht_color_block */int vcs[16]={VC_BLACK, VC_BLUE, VC_GREEN, VC_CYAN, VC_RED, VC_MAGENTA, VC_YELLOW, VC_WHITE,   VC_LIGHT(VC_BLACK), VC_LIGHT(VC_BLUE), VC_LIGHT(VC_GREEN), VC_LIGHT(VC_CYAN), VC_LIGHT(VC_RED), VC_LIGHT(VC_MAGENTA), VC_LIGHT(VC_YELLOW), VC_LIGHT(VC_WHITE)};void ht_color_block::init(Bounds *b, int selected, int Flags){	ht_view::init(b, VO_OWNBUFFER | VO_SELECTABLE, 0);	VIEW_DEBUG_NAME("ht_color_block");	flags=Flags;		ht_color_block_data d;	d.color = selected;	databuf_set(&d, sizeof d);	if (flags & cf_light) colors=16; else colors=8;}void ht_color_block::done(){	ht_view::done();}int ht_color_block::datasize(){	return sizeof (ht_color_block_data);}const char *ht_color_block::defaultpalette(){	return palkey_generic_dialog_default;}void ht_color_block::draw(){	clear(getcolor(palidx_generic_body));	uint32 cursor=VCP(focused ? VC_LIGHT(VC_WHITE) : VC_BLACK, VC_TRANSPARENT);	for (int i=0; i < colors; i++) {		buf->printChar((i%4)*3+1, i/4, VCP(vcs[i], VC_TRANSPARENT), GC_FULL, CP_GRAPHICAL);		buf->printChar((i%4)*3+2, i/4, VCP(vcs[i], VC_BLACK), GC_MEDIUM, CP_GRAPHICAL);		if (i == color) {			buf->printChar((i%4)*3, i/4, cursor, '>');			buf->printChar((i%4)*3+3, i/4, cursor, '<');		}	}	if (flags & cf_transparent) {		buf->print(1, (colors==8) ? 2 : 4, VCP(VC_BLACK, VC_TRANSPARENT), "transparent");		if (color == -1) {			buf->printChar(0, (colors==8) ? 2 : 4, cursor, '>');			buf->printChar(12, (colors==8) ? 2 : 4, cursor, '<');		}	}}void ht_color_block::getdata(ObjectStream &s){	PUTX_INT32D(s, (color==-1) ? VC_TRANSPARENT : vcs[color], NULL);}void ht_color_block::handlemsg(htmsg *msg){	if (msg->msg==msg_keypressed) {		switch (msg->data1.integer) {			case K_Left:				if (color==-1) color=(flags & cf_light) ? 15 : 7; else					if (color%4-1>=0) color--;				dirtyview();				clearmsg(msg);				return;			case K_Right:				if (color==-1) color=(flags & cf_light) ? 15 : 7; else					if (color%4+1<=3) color++;				dirtyview();				clearmsg(msg);				return;			case K_Up:				if (color==-1) color=(flags & cf_light) ? 15 : 7; else					if (color-4>=0) color-=4;				dirtyview();				clearmsg(msg);				return;			case K_Down:				if (color != -1) {					if (color+4 < colors) {						color += 4;					} else {						color = -1;					}				}				dirtyview();				clearmsg(msg);				return;		}	}	ht_view::handlemsg(msg);}void ht_color_block::setdata(ObjectStream &s){	int c = GETX_INT32D(s, NULL);	if (c == VC_TRANSPARENT) {		color = -1; 	} else {		for (int i=0; i<16; i++) if (vcs[i]==c) {			color=i;			break;		}	}	dirtyview();}void center_bounds(Bounds *b){	Bounds c;	app->getbounds(&c);	b->x = (c.w - b->w) / 2;	b->y = (c.h - b->h) / 2;     }

⌨️ 快捷键说明

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