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

📄 osdep.c

📁 一个很有名的浏览器
💻 C
📖 第 1 页 / 共 2 页
字号:
		}	}	s[j] = '\0';	/* Send terminal escape sequence + title string */	printf("\033]0;%s\a", s);#if 0	/* Miciah don't like this so it is disabled because it changes the	 * default window name. --jonas */	/* Set the GNU screen window name */	if (is_gnuscreen())		printf("\033k%s\033\134", s);#endif	fflush(stdout);	mem_free(s);}#ifdef HAVE_X11static int x_error = 0;static intcatch_x_error(void){	x_error = 1;	return 0;}#endifunsigned char *get_window_title(void){#ifdef HAVE_X11	/* Following code is stolen from our beloved vim. */	unsigned char *winid;	Display *display;	Window window, root, parent, *children;	XTextProperty text_prop;	Status status;	unsigned int num_children;	unsigned char *ret = NULL;	if (!is_xterm())		return NULL;	winid = getenv("WINDOWID");	if (!winid)		return NULL;	window = (Window) atol(winid);	if (!window)		return NULL;	display = XOpenDisplay(NULL);	if (!display)		return NULL;	/* If WINDOWID is bad, we don't want X to abort us. */	x_error = 0;	XSetErrorHandler((int (*)(Display *, XErrorEvent *)) catch_x_error);	status = XGetWMName(display, window, &text_prop);	/* status = XGetWMIconName(x11_display, x11_window, &text_prop); */	while (!x_error && (!status || !text_prop.value)) {		if (!XQueryTree(display, window, &root, &parent, &children, &num_children))			break;		if (children)			XFree((void *) children);		if (parent == root || parent == 0)			break;		window = parent;		status = XGetWMName(display, window, &text_prop);	}	if (!x_error && status && text_prop.value) {		ret = stracpy(text_prop.value);		XFree(text_prop.value);	}	XCloseDisplay(display);	return ret;#else	/* At least reset the window title to a blank one. */	return stracpy("");#endif}intresize_window(int width, int height, int old_width, int old_height){#ifdef HAVE_X11	/* Following code is stolen from our beloved vim. */	unsigned char *winid;	Display *display;	Window window;	Status status;	XWindowAttributes attributes;	if (!is_xterm())		return -1;	winid = getenv("WINDOWID");	if (!winid)		return -1;	window = (Window) atol(winid);	if (!window)		return -1;	display = XOpenDisplay(NULL);	if (!display)		return -1;	/* If WINDOWID is bad, we don't want X to abort us. */	x_error = 0;	XSetErrorHandler((int (*)(Display *, XErrorEvent *)) catch_x_error);	status = XGetWindowAttributes(display, window, &attributes);	while (!x_error && !status) {		Window root, parent, *children;		unsigned int num_children;		if (!XQueryTree(display, window, &root, &parent, &children, &num_children))			break;		if (children)			XFree((void *) children);		if (parent == root || parent == 0)			break;		window = parent;		status = XGetWindowAttributes(display, window, &attributes);	}	if (!x_error && status) {		double ratio_width = (double) attributes.width  / old_width;		double ratio_height = (double) attributes.height / old_height;		width  = (int) ((double) width * ratio_width);		height = (int) ((double) height * ratio_height);		status = XResizeWindow(display, window, width, height);		while (!x_error && !status) {			Window root, parent, *children;			unsigned int num_children;			if (!XQueryTree(display, window, &root, &parent, &children, &num_children))				break;			if (children)				XFree((void *) children);			if (parent == root || parent == 0)				break;			window = parent;			status = XResizeWindow(display, window, width, height);		}	}	XCloseDisplay(display);	return 0;#else	return -1;#endif}#endif/* Threads */#if defined(HAVE_BEGINTHREAD) || defined(CONFIG_BEOS)struct tdata {	void (*fn)(void *, int);	int h;	unsigned char data[1];};voidbgt(struct tdata *t){#ifdef SIGPIPE	signal(SIGPIPE, SIG_IGN);#endif	t->fn(t->data, t->h);	write(t->h, "x", 1);	close(t->h);	free(t);}#elseintstart_thread(void (*fn)(void *, int), void *ptr, int l){	int p[2];	pid_t pid;	if (c_pipe(p) < 0) return -1;	if (set_nonblocking_fd(p[0]) < 0) return -1;	if (set_nonblocking_fd(p[1]) < 0) return -1;	pid = fork();	if (!pid) {		struct terminal *term;		/* Close input in this thread; otherwise, if it will live		 * longer than its parent, it'll block the terminal until it'll		 * quit as well; this way it will hopefully just die unseen and		 * in background, causing no trouble. */		/* Particularly, when async dns resolving was in progress and		 * someone quitted ELinks, it could make a delay before the		 * terminal would be really freed and returned to shell. */		foreach (term, terminals)			if (term->fdin > 0)				close(term->fdin);		close(p[0]);		fn(ptr, p[1]);		write(p[1], "x", 1);		close(p[1]);		/* We use _exit() here instead of exit(), see		 * http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC6 for		 * reasons. Fixed by Sven Neumann <sven@convergence.de>. */		_exit(0);	}	if (pid == -1) {		close(p[0]);		close(p[1]);		return -1;	}	close(p[1]);	return p[0];}#endif#ifndef OS2_MOUSEvoidwant_draw(void){}voiddone_draw(void){}#endif#if !defined(CONFIG_WIN32)intget_output_handle(void){	return 1;}intget_ctl_handle(){	static int fd = -1;	if (isatty(0)) return 0;	if (fd < 0) fd = open("/dev/tty", O_RDONLY);	return fd;}#endif#if !defined(CONFIG_BEOS) && !(defined(HAVE_BEGINTHREAD) && defined(HAVE_READ_KBD)) \	&& !defined(CONFIG_WIN32)intget_input_handle(void){	return get_ctl_handle();}#endif#ifndef CONFIG_WIN32voidinit_osdep(void){#ifdef HAVE_LOCALE_H	setlocale(LC_ALL, "");#endif}#endif#if defined(CONFIG_UNIX) || defined(CONFIG_OS2) || defined(CONFIG_RISCOS)voidterminate_osdep(void){}#endif#ifndef CONFIG_BEOSvoidblock_stdin(void){}voidunblock_stdin(void){}#endifvoidelinks_cfmakeraw(struct termios *t){#ifdef HAVE_CFMAKERAW	cfmakeraw(t);#ifdef VMIN	t->c_cc[VMIN] = 1; /* cfmakeraw() is broken on AIX --mikulas */#endif#else	t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);	t->c_oflag &= ~OPOST;	t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);	t->c_cflag &= ~(CSIZE|PARENB);	t->c_cflag |= CS8;	t->c_cc[VMIN] = 1;	t->c_cc[VTIME] = 0;#endif}#if !defined(CONFIG_MOUSE) || (!defined(CONFIG_GPM) && !defined(OS2_MOUSE))void *handle_mouse(int cons, void (*fn)(void *, unsigned char *, int),	     void *data){	return NULL;}voidunhandle_mouse(void *data){}voidsuspend_mouse(void *data){}voidresume_mouse(void *data){}#endif#ifndef CONFIG_WIN32/* Create a bitmask consisting from system-independent envirnoment modifiers. * This is then complemented by system-specific modifiers in an appropriate * get_system_env() routine. */static intget_common_env(void){	int env = 0;	if (is_xterm()) env |= ENV_XWIN;	if (is_twterm()) env |= ENV_TWIN;	if (is_gnuscreen()) env |= ENV_SCREEN;	/* ENV_CONSOLE is always set now and indicates that we are working w/ a	 * displaying-capable character-adressed terminal. Sounds purely	 * theoretically now, but it already makes some things easier and it	 * could give us interesting opportunities later (after graphical	 * frontends will be introduced, when working in some mysterious daemon	 * mode or who knows what ;). --pasky */	env |= ENV_CONSOLE;	return env;}#endif#if defined(CONFIG_UNIX) || defined(CONFIG_RISCOS)intget_system_env(void){	return get_common_env();}#endifintcan_resize_window(int environment){	return !!(environment & (ENV_OS2VIO | ENV_XWIN));}#ifndef CONFIG_OS2intcan_open_os_shell(int environment){	return 1;}voidset_highpri(void){}#endifunsigned char *get_system_str(int xwin){	return xwin ? SYSTEM_STR "-xwin" : SYSTEM_STR;}

⌨️ 快捷键说明

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