/* vi:set ts=8 sts=4 sw=4 noet:
*
* VIM - Vi IMproved by Bram Moolenaar
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
* See README.txt for an overview of the Vim source code.
*/
/*
* help.c: functions for Vim help
*/
#include "vim.h"
/*
* ":help": open a read-only window on a help file
*/
void
ex_help(exarg_T *eap)
{
char_u *arg;
char_u *tag;
FILE *helpfd; // file descriptor of help file
int n;
int i;
win_T *wp;
int num_matches;
char_u **matches;
char_u *p;
int empty_fnum = 0;
int alt_fnum = 0;
buf_T *buf;
#ifdef FEAT_MULTI_LANG
int len;
char_u *lang;
#endif
#ifdef FEAT_FOLDING
int old_KeyTyped = KeyTyped;
#endif
if (eap != NULL)
{
// A ":help" command ends at the first LF, or at a '|' that is
// followed by some text. Set nextcmd to the following command.
for (arg = eap->arg; *arg; ++arg)
{
if (*arg == '\n' || *arg == '\r'
|| (*arg == '|' && arg[1] != NUL && arg[1] != '|'))
{
*arg++ = NUL;
eap->nextcmd = arg;
break;
}
}
arg = eap->arg;
if (eap->forceit && *arg == NUL && !curbuf->b_help)
{
emsg(_("E478: Don't panic!"));
return;
}
if (eap->skip) // not executing commands
return;
}
else
arg = (char_u *)"";
// remove trailing blanks
p = arg + STRLEN(arg) - 1;
while (p > arg && VIM_ISWHITE(*p) && p[-1] != '\\')
*p-- = NUL;
#ifdef FEAT_MULTI_LANG
// Check for a specified language
lang = check_help_lang(arg);
#endif
// When no argument given go to the index.
if (*arg == NUL)
arg = (char_u *)"help.txt";
// Check if there is a match for the argument.
n = find_help_tags(arg, &num_matches, &matches,
eap != NULL