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

📄 htapp.cc

📁 功能较全面的反汇编器:反汇编器ht-2.0.15.tar.gz
💻 CC
📖 第 1 页 / 共 5 页
字号:
	ht_file_window *window = new ht_file_window();	window->init(b, title, FS_KILLER | FS_TITLE | FS_NUMBER | FS_MOVE | FS_RESIZE, 0, file);	Bounds k=*b;	k.x=b->w-2;	k.y=0;	k.w=1;	k.h-=2;	ht_scrollbar *hs=new ht_scrollbar();	hs->init(&k, &window->pal, true);	window->setvscrollbar(hs);	k=*b;	k.x=3;	k.y=k.h-2;	k.w-=7;	k.h=1;	ht_statictext *ind=new ht_statictext();	ind->init(&k, NULL, align_left, false, true);	ind->disable_buffering();	ind->growmode = MK_GM(GMH_FIT, GMV_BOTTOM);	window->setpindicator(ind);	k=*b;	k.x=0;	k.y=0;	k.w-=2;	k.h-=2;	ht_format_group *format_group=new ht_format_group();	format_group->init(&k, VO_SELECTABLE | VO_RESIZE, VIEWERGROUP_NAME, file, true, true, format_viewer_ifs, NULL);	window->insert(format_group);	/**/	if (isfile) {		char cfgfilename[FILENAME_MAX];		strcpy(cfgfilename, title);		strcat(cfgfilename, HT_FILE_CONFIG_SUFFIX);		String einfo;		LOG("%s: loading config file...", cfgfilename);		loadstore_result lsr = load_fileconfig(cfgfilename, ht_fileconfig_magic, ht_fileconfig_fileversion, file_window_load_fcfg_func, window, einfo);		if (lsr == LS_ERROR_CORRUPTED) {			LOG_EX(LOG_ERROR, "%s: error: ", cfgfilename, &einfo);			errorbox("%s: error: %y", cfgfilename, &einfo);		} else if (lsr == LS_ERROR_MAGIC || lsr == LS_ERROR_FORMAT) {			LOG_EX(LOG_ERROR, "%s: wrong magic/format", cfgfilename);			errorbox("%s: wrong magic/format", cfgfilename);		} else if (lsr == LS_ERROR_VERSION) {			LOG_EX(LOG_ERROR, "%s: wrong version", cfgfilename);			errorbox("%s: wrong version", cfgfilename);		} else if (lsr == LS_ERROR_NOT_FOUND) {			LOG("%s: not found", cfgfilename);		} else if (lsr != LS_OK) {			LOG_EX(LOG_ERROR, "%s: error: %y", cfgfilename, &einfo);			errorbox("%s: error: %y", cfgfilename, &einfo);		} else {			LOG("%s: ok", cfgfilename);		}	}	/**/	if (isfile) LOG("%s: done.", title);	htmsg m;	m.msg = msg_postinit;	m.type = mt_broadcast;	window->sendmsg(&m);	insert_window(window, AWT_FILE, 0, isfile, file);	return window;}ht_window *ht_app::create_window_file_text(const char *filename, bool allow_duplicates){	Bounds b, c;	get_stdbounds_file(&c);	b = c;	int e;	char *fullfilename;	if ((e = sys_canonicalize(&fullfilename, filename))) {		LOG_EX(LOG_ERROR, "error loading file %s: %s", filename, strerror(e));		return NULL;	}	String f(fullfilename);	free(fullfilename);		ht_window *w;	if (!allow_duplicates && ((w = get_window_by_filename(f.contentChar())))) {		focus(w);		return w;	}	File *emfile = NULL;	ht_ltextfile *tfile = NULL;	FileLayer *file = NULL;	try {		File *emfile = new LocalFile(f, IOAM_READ, FOM_EXISTS);		if (!doFileChecks(emfile)) {			delete emfile;			return NULL;		}		tfile = new ht_ltextfile(emfile, true, NULL);		file = new ht_layer_textfile(tfile, true);	} catch (const IOException &e) {		LOG_EX(LOG_ERROR, "error loading file %y: %y", &f, &e);		if (file) delete file;		else if (tfile) delete tfile;		else delete emfile;		return NULL;	}	LOG("loading text file %y...", &f);	return create_window_file_text(&b, file, f.contentChar(), true);}ht_window *ht_app::create_window_file_text(Bounds *c, FileLayer *f, const char *title, bool isfile){	Bounds b=*c;	ht_layer_textfile *file = (ht_layer_textfile *)f;		ht_file_window *window = new ht_file_window();	window->init(&b, title, FS_KILLER | FS_TITLE | FS_NUMBER | FS_MOVE | FS_RESIZE, 0, file);	b.x=0;	b.y=0;	b.w-=2;	b.h-=2;	ht_text_editor *text_editor=new ht_text_editor();	text_editor->init(&b, true, file, syntax_lexers, TEXTEDITOPT_INPUTTABS|TEXTEDITOPT_UNDO);	IString fn, base, fn_suf;	file->getFilename(fn);	if (fn.rightSplit('.', base, fn_suf)) {		if (fn_suf == "c" || fn_suf == "cc"		 || fn_suf == "cpp"		 || fn_suf == "h" || fn_suf == "hpp") {			text_editor->set_lexer((ht_syntax_lexer*)(*syntax_lexers)[0], false);		}#ifdef HT_HTML_SYNTAX_LEXER		if (fn_suf == "htm" || fn_suf == "html") {			text_editor->set_lexer((ht_syntax_lexer*)(*syntax_lexers)[1], false);		}#endif	}	Bounds k=*c;	k.x=k.w-2;	k.y=0;	k.w=1;	k.h-=2;	ht_scrollbar *hs=new ht_scrollbar();	hs->init(&k, &window->pal, true);	window->setvscrollbar(hs);	k=*c;	k.x=3;	k.y=k.h-2;	k.w-=7;	k.h=1;		ht_statictext *ind=new ht_statictext();	ind->init(&k, NULL, align_left, false, true);	ind->disable_buffering();	ind->growmode = MK_GM(GMH_FIT, GMV_BOTTOM);	window->setpindicator(ind);	window->insert(text_editor);	if (isfile) LOG("%s: done.", title);	insert_window(window, AWT_FILE, 0, isfile, file);	return window;}ht_window *ht_app::create_window_help(const char *file, const char *node){	ht_window *w = get_window_by_type(AWT_HELP);	if (w) {		focus(w);		return w;	} else {		Bounds b, c;		battlefield->getbounds(&c);		b.w=c.w*7/8;		b.h=c.h*7/8;		b.x=(c.w-b.w)/2;		b.y=(c.h-b.h)/2;		Bounds k = b;		ht_help_window *window=new ht_help_window();		window->init(&b, "help", FS_KILLER | FS_TITLE | FS_NUMBER | FS_MOVE | FS_RESIZE, 0);		b.x=0;		b.y=0;		b.w-=2;		b.h-=2;		c=b;		b=c;		b.x+=b.w;		b.w=1;		ht_scrollbar *scrollbar=new ht_scrollbar();		scrollbar->init(&b, &window->pal, true);		scrollbar->enable();		window->setvscrollbar(scrollbar);		k.x=3;		k.y=k.h-2;		k.w-=7;		k.h=1;		ht_statictext *ind=new ht_statictext();		ind->init(&k, NULL, align_left, false, true);		ind->disable_buffering();		ind->growmode = MK_GM(GMH_FIT, GMV_BOTTOM);		window->setpindicator(ind);		b=c;		ht_info_viewer *infoviewer=new ht_info_viewer();		infoviewer->init(&b);		window->insert(infoviewer);		char ff[HT_NAME_MAX], cwd[HT_NAME_MAX];		cwd[0] = 0;		getcwd(cwd, sizeof cwd);		if (strcmp(file, "hthelp.info")) {			sys_common_canonicalize(ff, file, cwd, sys_is_path_delim);		} else {			strcpy(ff, file);		}		if (infoviewer->gotonode(ff, node)) {			insert_window(window, AWT_HELP, 0, false, NULL);						window->setpalette(palkey_generic_cyan);			return window;		}		errorbox("help topic '(%s)%s' not found", file, node);		window->done();		delete window;	}	return NULL;}ht_window *ht_app::create_window_project(){	ht_window *w = get_window_by_type(AWT_PROJECT);	if (w) {		focus(w);		return w;	} else {		Bounds b;		get_stdbounds_tool(&b);		ht_project_window *project_window=new ht_project_window();		ht_project *p = (ht_project *)project;		project_window->init(&b, "project window", FS_KILLER | FS_TITLE | FS_NUMBER | FS_MOVE | FS_RESIZE, 0, &p);		project = p;		Bounds k = b;		k.x = b.w-2;		k.y = 0;		k.w = 1;		k.h -= 2;		ht_scrollbar *hs = new ht_scrollbar();		hs->init(&k, &project_window->pal, true);		project_window->sethscrollbar(hs);/*		b.x = 0;		b.y = 0;		b.w -= 2;		b.h -= 2;		ht_project_listbox *project_viewer = new ht_project_listbox();		project_viewer->init(&b, project);		project_window->insert(project_viewer);*/		insert_window(project_window, AWT_PROJECT, 0, false, NULL);				project_window->setpalette(palkey_generic_cyan);		return project_window;	}}#if 0ht_view *create_ofm_single(Bounds *c, char *url, ht_vfs_viewer **x){	Bounds b=*c;	b.h-=2;	ht_group *g=new ht_group();	g->init(&b, VO_SELECTABLE, 0);	Bounds d=b;		b.x=0;	b.y=0;	b.h=1;	ht_vfs_viewer_status *vst=new ht_vfs_viewer_status();	vst->init(&b);	   	d.x=0;	d.y=1;	d.h--;	ht_vfs_viewer *v=new ht_vfs_viewer();	v->init(&d, "vfs viewer", 0, 0, 0, vst);	   	g->insert(v);	g->insert(vst);	ht_vfs_sub *vs=new ht_vfs_sub();	vs->init(url);	v->insertsub(vs);	v->sendmsg(msg_complete_init, 0);	*x=v;	return g;}#endifht_window *ht_app::create_window_ofm(const char *url1, const char *url2){	Bounds b;	get_stdbounds_file(&b);	ht_window *window=new ht_window();	window->init(&b, "file manager", FS_KILLER | FS_TITLE | FS_NUMBER | FS_MOVE | FS_RESIZE, 0);#if 1	b.w-=2;	b.h-=2;	VfsListbox2 *l = new VfsListbox2();	l->init(&b, virtual_fs_list, window->getframe());//	l->changeURL("local:/bp/././..");	l->changeURL(url1);	window->insert(l);#else	Bounds b1, b2, b3;	ht_vfs_viewer *v1, *v2=NULL;	b.w-=2;	b1=b;	b1.w/=2;	b1.w--;	window->insert(create_ofm_single(&b1, url1, &v1));	if (url2) {		b2=b;		b2.w/=2;		b2.x=b2.w-1;		b2.w=1;		b2.h-=2;		ht_vbar *x=new ht_vbar();		x->init(&b2, 0, 0);		window->insert(x);		b3=b;		b3.w/=2;		b3.x=b3.w;		window->insert(create_ofm_single(&b3, url2, &v2));	}	if (v2) {		v1->set_assoc_vfs_viewer(v2);		v2->set_assoc_vfs_viewer(v1);	}#endif	insert_window(window, AWT_OFM, 0, false, NULL);	return window;}const char *ht_app::defaultpalette(){	return NULL;}const char *ht_app::defaultpaletteclass(){	return NULL;}int analy_id = 0;void ht_app::draw(){/* show draw timings */#ifdef DRAW_TIMING	int xyz=get_timer_1024tick(h0);	buf->printf(17, 1, 7, "cur: %d (%d msec)", xyz*1024, get_timer_msec(h0));#ifndef NO_AVG	if (cur_timing>=AVG_TIMINGS-1) cur_timing=0;	timings[cur_timing++]=xyz;	if (cur_timing>max_timing) max_timing=cur_timing;	int avg=0;	for (int i=0; i<max_timing; i++) avg+=timings[i];	avg=avg/max_timing;	buf->printf(57, 1, 7, "avg%d: %d", max_timing+1, avg*1024);#endif#endif}void ht_app::delete_window(ht_window *window){	ObjHandle oh = get_window_listindex(window);	if (oh != invObjHandle) {		battlefield->remove(window);		windows->del(oh);		window->done();		delete window;	}}uint ht_app::find_free_window_number(){	ht_app_window_entry e(NULL, 1, 0, false, false, NULL);	ObjHandle oh;	while ((oh = windows->find(&e)) != invObjHandle) {		e.number++;	}	return e.number;}bool ht_app::focus(ht_view *view){	return ht_dialog::focus(view);}const char *ht_app::func(uint i, bool execute){	switch (i) {		case 1:			if (execute) sendmsg(cmd_popup_window_help);			return "help";		case 3:			if (execute) sendmsg(cmd_file_open);			return "open";		case 6:			if (execute) sendmsg(cmd_popup_dialog_view_list);			return "mode";		/* FIXME: experimental *//*		case 9:			if (execute) {				create_window_term("make");			}			return "make";*/		case 10:			if (execute) sendmsg(cmd_quit);			return "quit";	}	return 0;}void ht_app::get_stdbounds_file(Bounds *b){	if (project) {		Bounds c;		get_stdbounds_tool(&c);		battlefield->getbounds(b);		b->x = 0;		b->y = 0;		b->h -= c.h;	} else {		battlefield->getbounds(b);		b->x = 0;		b->y = 0;	}}void ht_app::get_stdbounds_tool(Bounds *b){	uint h = MAX(size.h/4, 3);	battlefield->getbounds(b);	b->x = 0;	b->y = b->h - h;	b->h = h;}ht_window *ht_app::get_window_by_filename(const char *filename){	foreach(ht_app_window_entry, e, *windows, {		// FIXME: filename_compare (taking into account slash/backslash, and case)		if (strcmp(e->window->desc, filename) == 0) return e->window;	});	return NULL;}ht_window *ht_app::get_window_by_number(uint number){	ht_app_window_entry *e;	firstThat(ht_app_window_entry, e, *windows, e->number==number);	return e ? e->window : NULL;}ht_window *ht_app::get_window_by_type(uint type){	ht_app_window_entry *e;	firstThat(ht_app_window_entry, e, *windows, e->type==type);	return e ? e->window : NULL;}uint ht_app::get_window_number(ht_window *window){	ht_app_window_entry *e;	firstThat(ht_app_window_entry, e, *windows, e->window==window);	return e ? e->number : 0;}ObjHandle ht_app::get_window_listindex(ht_window *window){	ObjHandle oh;	for (oh = windows->findFirst(); oh != invObjHandle; ) {		ht_app_window_entry *e = (ht_app_window_entry*)windows->get(oh);		if (e->window == window) break;		oh = windows->findNext(oh);	}	return oh;}#include "cstream.h"void ht_app::handlemsg(htmsg *msg){	switch (msg->msg) {		case cmd_edit_copy_native: {			int dz = sys_native_clipboard_get_size();			if (dz) {				void *data = ht_malloc(dz);				if ((dz = sys_native_clipboard_read(data, dz))) {					clipboard_copy(sys_native_clipboard_name(), data, dz);				}				free(data);			}			break;		}		case cmd_edit_paste_native: {			int maxsize = clipboard_getsize();			if (maxsize) {				byte *buf = ht_malloc(maxsize);				int r = clipboard_paste(buf, maxsize);				if (r) {					sys_native_clipboard_write(buf, r);				}				free(buf);			}			break;		}		case cmd_file_save: {			ObjHandle oh = get_window_listindex((ht_window*)battlefield->current);			ht_app_window_entry *e = (ht_app_window_entry*)windows->get(oh);			if (e && e->layer && e->isfile) break;		}		case cmd_file_saveas: {			ObjHandle oh = get_window_listindex((ht_window*)battlefield->current);			ht_app_window_entry *e = (ht_app_window_entry*)windows->get(oh);			if (e && e->layer) {				char fn[HT_NAME_MAX];				fn[0] = 0;				if (file_chooser("Save as", fn, sizeof fn)) {					bool work = true;					if (access(fn, F_OK) == 0) {						work = (confirmbox("File '%s' already exists. Overwrite?", fn) == button_yes);					}					if (work) {						LocalFile *f = NULL;						try {							String n(fn);							f = new LocalFile(n, IOAM_WRITE, FOM_CREATE);							e->layer->seek(0);							e->layer->copyAllTo(f);						} catch (const IOException &e) {							LOG_EX(LOG_ERROR, "error saving file %s: %y", fn, &e);							errorbox("error saving file %s: %y", fn, &e);							delete f;							return;						}//						asm(".byte 0xcc");						File *old = e->layer->getLayered();

⌨️ 快捷键说明

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