예제 #1
0
/* Create or delete the footnotes window depending on whether footnotes
   exist in WINDOW's node or not.  Returns FN_FOUND if footnotes were found
   and displayed.  Returns FN_UNFOUND if there were no footnotes found
   in WINDOW's node.  Returns FN_UNABLE if there were footnotes, but the
   window to show them couldn't be made. */
int
info_get_or_remove_footnotes (WINDOW *window)
{
  WINDOW *fn_win;
  NODE *new_footnotes;

  fn_win = find_footnotes_window ();

  /* If we are in the footnotes window, change nothing. */
  if (fn_win == window)
    return (FN_FOUND);

  /* Try to find footnotes for this window's node. */
  new_footnotes = make_footnotes_node (window->node);

  /* If there was a window showing footnotes, and there are no footnotes
     for the current window, delete the old footnote window. */
  if (fn_win && !new_footnotes)
    {
      if (windows->next)
        info_delete_window_internal (fn_win);
    }

  /* If there are footnotes for this window's node, but no window around
     showing footnotes, try to make a new window. */
  if (new_footnotes && !fn_win)
    {
      WINDOW *old_active;
      WINDOW *last, *win;

      /* Always make this window be the last one appearing in the list.  Find
         the last window in the chain. */
      for (win = windows, last = windows; win; last = win, win = win->next);

      /* Try to split this window, and make the split window the one to
         contain the footnotes. */
      old_active = active_window;
      active_window = last;
      fn_win = window_make_window (new_footnotes);
      active_window = old_active;

      if (!fn_win)
        {
          free (new_footnotes->contents);
          free (new_footnotes);

          /* If we are hacking automatic footnotes, and there are footnotes
             but we couldn't display them, print a message to that effect. */
          if (auto_footnotes_p)
            inform_in_echo_area ((char *) _("Footnotes could not be displayed"));
          return (FN_UNABLE);
        }
    }

  /* If there are footnotes, and there is a window to display them,
     make that window be the number of lines appearing in the footnotes. */
  if (new_footnotes && fn_win)
    {
      window_set_node_of_window (fn_win, new_footnotes);

      window_change_window_height
        (fn_win, fn_win->line_count - fn_win->height);

      remember_window_and_node (fn_win, new_footnotes);
      add_gcable_pointer (new_footnotes->contents);
    }

  if (!new_footnotes)
    return (FN_UNFOUND);
  else
    return (FN_FOUND);
}
예제 #2
0
/* Restore the caller's window so that it shows the node that it was showing
   on entry to info_read_xxx_echo_area (). */
static void
restore_calling_window (void)
{
  register WINDOW *win, *compwin = NULL;

  /* If the calling window is still visible, and it is the window that
     we used for completions output, then restore the calling window. */
  for (win = windows; win; win = win->next)
    {
      if (completions_window_p (win))
        compwin = win;

      if (win == calling_window && win == compwin)
        {
          window_set_node_of_window (calling_window, calling_window_node);
          calling_window->point = calling_window_point;
          calling_window->pagetop = calling_window_pagetop;
          compwin = NULL;
          break;
        }
    }

  /* Delete the completions window if it is still present, it isn't the
     last window on the screen, and there aren't any prior echo area reads
     pending which created a completions window. */
  if (compwin)
    {
      if ((compwin != windows || windows->next) &&
          !echo_area_stack_contains_completions_p ())
        {
          WINDOW *next;
          int pagetop = 0;
          int start = 0;
          int end = 0;
          int amount = 0;

          next = compwin->next;
          if (next)
            {
              start = next->first_row;
              end = start + next->height;
              amount = - (compwin->height + 1);
              pagetop = next->pagetop;
            }

          info_delete_window_internal (compwin);

          /* This is not necessary because info_delete_window_internal ()
             calls echo_area_inform_of_deleted_window (), which does the
             right thing. */
#if defined (UNNECESSARY)
          echo_area_completions_window = NULL;
#endif /* UNNECESSARY */

          if (next)
            {
              display_scroll_display (start, end, amount);
              next->pagetop = pagetop;
              display_update_display (windows);
            }
        }
    }
}