Exemplo n.º 1
0
static int findhelp( VTAB *tab )
{
    help_file   *fileinfo;
    int         ret;

    fileinfo = help_open( helpInBuf );
    if( fileinfo == NULL ) {
        return( HELP_NO_SUBJECT );
    }
    helpFileHdl = fileinfo->f;
    helpSearchHdl = fileinfo->searchhdl;
    ret = dispHelp( helpStack->word, tab );
    /* if a new help file name exists,
       then link to the new file
    */
    if( helpTab != NULL && helpCur->key2_len != 0 ) {
        curEvent = EV_ESCAPE;
    }
    return( ret );
}
Exemplo n.º 2
0
/*
 * variable_help()
 *
 * it shows help about variable from file ${datadir}/ekg/vars.txt
 * or ${datadir}/ekg/plugins/{plugin_name}/vars.txt
 *
 * name - name of the variable
 */
void variable_help(const char *name) {
	GIOChannel *f; 
	gchar *type = NULL, *def = NULL, *tmp;
	const gchar *line, *seeking_name;
	string_t s;
	int found = 0;
	variable_t *v = variable_find(name);

	if (!v) {
		print("variable_not_found", name);
		return;
	}

	if (v->plugin && v->plugin->name) {
		char *tmp2;

		if (!(f = help_open("vars", v->plugin->name))) {
			print("help_set_file_not_found_plugin", v->plugin->name);
			return;
		}

		tmp2 = xstrchr(name, ':');
		if (tmp2)
			seeking_name = tmp2+1;
		else
			seeking_name = name;
	} else {
		if (!(f = help_open("vars", NULL))) {
			print("help_set_file_not_found");
			return;
		}
		
		seeking_name = name;
	}

	while ((line = read_line(f))) {
		if (!xstrcasecmp(line, seeking_name)) {
			found = 1;
			break;
		}
	}

	if (!found) {
		g_io_channel_unref(f);
		print("help_set_var_not_found", name);
		return;
	}

	line = read_line(f);
	
	if ((tmp = xstrstr(line, (": "))))
		type = xstrdup(tmp + 2);
	else
		type = xstrdup(("?"));
	
	line = read_line(f);
	if ((tmp = xstrstr(line, (": "))))
		def = xstrdup(tmp + 2);
	else
		def = xstrdup(("?"));

	print("help_set_header", name, type, def);

	xfree(type);
	xfree(def);

	if (tmp)		/* je¶li nie jest to ukryta zmienna... */
		read_line(f);	/* ... pomijamy liniê */
	s = string_init(NULL);
	while ((line = read_line(f))) {
		if (line[0] != '\t')
			break;

		if (!xstrncmp(line, ("\t- "), 3) && xstrcmp(s->str, (""))) {
			print("help_set_body", s->str);
			string_clear(s);
		}

		if (!xstrncmp(line, ("\t"), 1) && xstrlen(line) == 1) {
			string_append(s, ("\n\r"));
			continue;
		}
	
		string_append(s, line + 1);

		if (line[xstrlen(line) - 1] != ' ')
			string_append_c(s, ' ');
	}

	if (xstrcmp(s->str, ("")))
		print("help_set_body", s->str);

	string_free(s, 1);
	
	if (format_exists("help_set_footer"))
		print("help_set_footer", name);

	g_io_channel_unref(f);
}