Back to index

tetex-bin  3.0
Classes | Defines | Typedefs | Functions | Variables
doc.h File Reference
#include "info.h"
#include "infomap.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  function_keyseq
struct  FUNCTION_DOC

Defines

#define InfoFunction(ic)   ((ic) ? (ic)->func : (VFunction *) NULL)
#define InfoCmd(fn)   (&function_doc_array[A_##fn])
#define DocInfoCmd(fd)   ((fd) && (fd)->func ? (fd) : NULL)

Typedefs

typedef struct function_keyseq FUNCTION_KEYSEQ
typedef FUNCTION_DOC InfoCommand

Functions

char * function_name (InfoCommand *cmd)
InfoCommandnamed_function (char *name)
char * function_documentation (InfoCommand *cmd)
char * key_documentation (char key, Keymap map)
char * pretty_keyname (unsigned char key)
char * pretty_keyseq (char *keyseq)
char * where_is (Keymap map, InfoCommand *cmd)
char * replace_in_documentation (char *string, int help_is_only_window_p)
void dump_map_to_message_buffer (char *prefix, Keymap map)

Variables

FUNCTION_DOC function_doc_array []

Class Documentation

struct function_keyseq

Definition at line 40 of file doc.h.

Collaboration diagram for function_keyseq:
Class Members
char * keyseq
struct keymap_entry * map
struct function_keyseq * next
struct FUNCTION_DOC

Definition at line 55 of file doc.h.

Collaboration diagram for FUNCTION_DOC:
Class Members
char * doc
VFunction * func
char * func_name
FUNCTION_KEYSEQ * keys

Define Documentation

#define DocInfoCmd (   fd)    ((fd) && (fd)->func ? (fd) : NULL)

Definition at line 80 of file doc.h.

#define InfoCmd (   fn)    (&function_doc_array[A_##fn])

Definition at line 79 of file doc.h.

#define InfoFunction (   ic)    ((ic) ? (ic)->func : (VFunction *) NULL)

Definition at line 78 of file doc.h.


Typedef Documentation

Definition at line 75 of file doc.h.


Function Documentation

void dump_map_to_message_buffer ( char *  prefix,
Keymap  map 
)

Definition at line 191 of file infodoc.c.

{
  register int i;
  unsigned prefix_len = strlen (prefix);
  char *new_prefix = (char *)xmalloc (prefix_len + 2);

  strncpy (new_prefix, prefix, prefix_len);
  new_prefix[prefix_len + 1] = '\0';

  for (i = 0; i < 256; i++)
    {
      new_prefix[prefix_len] = i;
      if (map[i].type == ISKMAP)
        {
          dump_map_to_message_buffer (new_prefix, (Keymap)map[i].function);
        }
      else if (map[i].function)
        {
          register int last;
          char *doc, *name;

          doc = function_documentation (map[i].function);
          name = function_name (map[i].function);

          if (!*doc)
            continue;

          /* Find out if there is a series of identical functions, as in
             ea_insert (). */
          for (last = i + 1; last < 256; last++)
            if ((map[last].type != ISFUNC) ||
                (map[last].function != map[i].function))
              break;

          if (last - 1 != i)
            {
              printf_to_message_buffer ("%s .. ", pretty_keyseq (new_prefix),
                  NULL, NULL);
              new_prefix[prefix_len] = last - 1;
              printf_to_message_buffer ("%s\t", pretty_keyseq (new_prefix),
                  NULL, NULL);
              i = last - 1;
            }
          else
            printf_to_message_buffer ("%s\t", pretty_keyseq (new_prefix),
                NULL, NULL);

#if defined (NAMED_FUNCTIONS)
          /* Print the name of the function, and some padding before the
             documentation string is printed. */
          {
            int length_so_far;
            int desired_doc_start = 40; /* Must be multiple of 8. */

            printf_to_message_buffer ("(%s)", name, NULL, NULL);
            length_so_far = message_buffer_length_this_line ();

            if ((desired_doc_start + strlen (doc))
                >= (unsigned int) the_screen->width)
              printf_to_message_buffer ("\n     ", NULL, NULL, NULL);
            else
              {
                while (length_so_far < desired_doc_start)
                  {
                    printf_to_message_buffer ("\t", NULL, NULL, NULL);
                    length_so_far += character_width ('\t', length_so_far);
                  }
              }
          }
#endif /* NAMED_FUNCTIONS */
          printf_to_message_buffer ("%s\n", doc, NULL, NULL);
        }
    }
  free (new_prefix);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

char* function_name ( InfoCommand cmd)

Here is the caller graph for this function:

char* key_documentation ( char  key,
Keymap  map 
)
InfoCommand* named_function ( char *  name)

Here is the caller graph for this function:

char* pretty_keyname ( unsigned char  key)

Here is the caller graph for this function:

char* pretty_keyseq ( char *  keyseq)

Definition at line 795 of file infodoc.c.

{
  static char keyseq_rep[200];

  keyseq_rep[0] = '\0';
  if (*keyseq)
    pretty_keyseq_internal (keyseq, keyseq_rep);
  return (keyseq_rep);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* replace_in_documentation ( char *  string,
int  help_is_only_window_p 
)

Definition at line 890 of file infodoc.c.

{
  unsigned reslen = strlen (string);
  register int i, start, next;
  static char *result = (char *)NULL;

  maybe_free (result);
  result = (char *)xmalloc (1 + reslen);

  i = next = start = 0;

  /* Skip to the beginning of a replaceable function. */
  for (i = start; string[i]; i++)
    {
      int j = i + 1;

      /* Is this the start of a replaceable function name? */
      if (string[i] == '\\')
        {
          char *fmt = NULL;
          unsigned min = 0;
          unsigned max = 0;

          if(string[j] == '%')
            {
              if (string[++j] == '-')
                j++;
              if (isdigit(string[j]))
                {
                  min = atoi(string + j);
                  while (isdigit(string[j]))
                    j++;
                  if (string[j] == '.' && isdigit(string[j + 1]))
                    {
                      j += 1;
                      max = atoi(string + j);
                      while (isdigit(string[j]))
                        j++;
                    }
                  fmt = (char *)xmalloc (j - i + 2);
                  strncpy (fmt, string + i + 1, j - i);
                  fmt[j - i - 1] = 's';
                  fmt[j - i] = '\0';
                }
              else
                j = i + 1;
            }
          if (string[j] == '[')
            {
              unsigned arg = 0;
              char *argstr = NULL;
              char *rep_name, *fun_name, *rep;
              InfoCommand *command;
              char *repstr = NULL;
              unsigned replen;

              /* Copy in the old text. */
              strncpy (result + next, string + start, i - start);
              next += (i - start);
              start = j + 1;

              /* Look for an optional numeric arg. */
              i = start;
              if (isdigit(string[i])
                  || (string[i] == '-' && isdigit(string[i + 1])) )
                {
                  arg = atoi(string + i);
                  if (string[i] == '-')
                    i++;
                  while (isdigit(string[i]))
                    i++;
                }
              start = i;

              /* Move to the end of the function name. */
              for (i = start; string[i] && (string[i] != ']'); i++);

              rep_name = (char *)xmalloc (1 + i - start);
              strncpy (rep_name, string + start, i - start);
              rep_name[i - start] = '\0';

            /* If we have only one window (because the window size was too
               small to split it), we have to quit help by going back one
               noew in the history list, not deleting the window.  */
              if (strcmp (rep_name, "quit-help") == 0)
                fun_name = help_is_only_window_p ? "history-node"
                                                 : "delete-window";
              else
                fun_name = rep_name;

              /* Find a key which invokes this function in the info_keymap. */
              command = named_function (fun_name);

              free (rep_name);

              /* If the internal documentation string fails, there is a
                 serious problem with the associated command's documentation.
                 We croak so that it can be fixed immediately. */
              if (!command)
                abort ();

              if (arg)
                {
                  char *argrep, *p;

                  argrep = where_is (info_keymap, InfoCmd(info_add_digit_to_numeric_arg));
                  p = argrep ? strrpbrk (argrep, "0123456789-") : NULL;
                  if (p)
                    {
                      argstr = (char *)xmalloc (p - argrep + 21);
                      strncpy (argstr, argrep, p - argrep);
                      sprintf (argstr + (p - argrep), "%d", arg);
                    }
                  else
                    command = NULL;
                }
              rep = command ? where_is (info_keymap, command) : NULL;
              if (!rep)
                rep = "N/A";
              replen = (argstr ? strlen (argstr) : 0) + strlen (rep) + 1;
              repstr = (char *)xmalloc (replen);
              repstr[0] = '\0';
              if (argstr)
                {
                  strcat(repstr, argstr);
                  strcat(repstr, " ");
                  free (argstr);
                }
              strcat(repstr, rep);

              if (fmt)
                {
                  if (replen > max)
                    replen = max;
                  if (replen < min)
                    replen = min;
                }
              if (next + replen > reslen)
                {
                  reslen = next + replen + 1;
                  result = (char *)xrealloc (result, reslen + 1);
                }

              if (fmt)
                  sprintf (result + next, fmt, repstr);
              else
                  strcpy (result + next, repstr);

              next = strlen (result);
              free (repstr);

              start = i;
              if (string[i])
                start++;
            }

          maybe_free (fmt);
        }
    }
  strcpy (result + next, string + start);
  return (result);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* where_is ( Keymap  map,
InfoCommand cmd 
)

Definition at line 1060 of file infodoc.c.

{
  char *rep;

  if (!where_is_rep_size)
    where_is_rep = (char *)xmalloc (where_is_rep_size = 100);
  where_is_rep_index = 0;

  rep = where_is_internal (map, cmd);

  /* If it couldn't be found, return "M-x Foo" (or equivalent). */
  if (!rep)
    {
      char *name;

      name = function_name (cmd);
      if (!name)
        return NULL; /* no such function */

      rep = where_is_internal (map, InfoCmd(info_execute_command));
      if (!rep)
        return ""; /* function exists but can't be got to by user */

      sprintf (where_is_rep, "%s %s", rep, name);

      rep = where_is_rep;
    }
  return (rep);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation