Source:NetHack 3.6.0/src/windows.c

From NetHackWiki
(Redirected from Windows.c)
Jump to: navigation, search

Below is the full text to windows.c from the source code of NetHack 3.6.0. To link to a particular line, write [[Source:NetHack 3.6.0/src/windows.c#line123]], for example.

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

Top of file

  1.  /* NetHack 3.6	windows.c	$NHDT-Date: 1448013599 2015/11/20 09:59:59 $  $NHDT-Branch: master $:$NHDT-Revision: 1.35 $ */
  2.  /* Copyright (c) D. Cohrs, 1993. */
  3.  /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5.  #include "hack.h"
  6.  #ifdef TTY_GRAPHICS
  7.  #include "wintty.h"
  8.  #endif
  9.  #ifdef X11_GRAPHICS
  10.  /* Cannot just blindly include winX.h without including all of X11 stuff
  11.     and must get the order of include files right.  Don't bother. */
  12.  extern struct window_procs X11_procs;
  13.  extern void FDECL(win_X11_init, (int));
  14.  #endif
  15.  #ifdef QT_GRAPHICS
  16.  extern struct window_procs Qt_procs;
  17.  #endif
  18.  #ifdef GEM_GRAPHICS
  19.  #include "wingem.h"
  20.  #endif
  21.  #ifdef MAC
  22.  extern struct window_procs mac_procs;
  23.  #endif
  24.  #ifdef BEOS_GRAPHICS
  25.  extern struct window_procs beos_procs;
  26.  extern void FDECL(be_win_init, (int));
  27.  FAIL /* be_win_init doesn't exist? XXX*/
  28.  #endif
  29.  #ifdef AMIGA_INTUITION
  30.  extern struct window_procs amii_procs;
  31.  extern struct window_procs amiv_procs;
  32.  extern void FDECL(ami_wininit_data, (int));
  33.  #endif
  34.  #ifdef WIN32_GRAPHICS
  35.  extern struct window_procs win32_procs;
  36.  #endif
  37.  #ifdef GNOME_GRAPHICS
  38.  #include "winGnome.h"
  39.  extern struct window_procs Gnome_procs;
  40.  #endif
  41.  #ifdef MSWIN_GRAPHICS
  42.  extern struct window_procs mswin_procs;
  43.  #endif
  44.  #ifdef WINCHAIN
  45.  extern struct window_procs chainin_procs;
  46.  extern void FDECL(chainin_procs_init, (int));
  47.  extern void *FDECL(chainin_procs_chain, (int, int, void *, void *, void *));
  48.  
  49.  extern struct chain_procs chainout_procs;
  50.  extern void FDECL(chainout_procs_init, (int));
  51.  extern void *FDECL(chainout_procs_chain, (int, int, void *, void *, void *));
  52.  
  53.  extern struct chain_procs trace_procs;
  54.  extern void FDECL(trace_procs_init, (int));
  55.  extern void *FDECL(trace_procs_chain, (int, int, void *, void *, void *));
  56.  #endif
  57.  
  58.  STATIC_DCL void FDECL(def_raw_print, (const char *s));
  59.  
  60.  #ifdef HANGUPHANDLING
  61.  volatile
  62.  #endif
  63.      NEARDATA struct window_procs windowprocs;
  64.  
  65.  #ifdef WINCHAIN
  66.  #define CHAINR(x) , x
  67.  #else
  68.  #define CHAINR(x)
  69.  #endif
  70.  
  71.  static struct win_choices {
  72.      struct window_procs *procs;
  73.      void FDECL((*ini_routine), (int)); /* optional (can be 0) */
  74.  #ifdef WINCHAIN
  75.      void *FDECL((*chain_routine), (int, int, void *, void *, void *));
  76.  #endif
  77.  } winchoices[] = {
  78.  #ifdef TTY_GRAPHICS
  79.      { &tty_procs, win_tty_init CHAINR(0) },
  80.  #endif
  81.  #ifdef X11_GRAPHICS
  82.      { &X11_procs, win_X11_init CHAINR(0) },
  83.  #endif
  84.  #ifdef QT_GRAPHICS
  85.      { &Qt_procs, 0 CHAINR(0) },
  86.  #endif
  87.  #ifdef GEM_GRAPHICS
  88.      { &Gem_procs, win_Gem_init CHAINR(0) },
  89.  #endif
  90.  #ifdef MAC
  91.      { &mac_procs, 0 CHAINR(0) },
  92.  #endif
  93.  #ifdef BEOS_GRAPHICS
  94.      { &beos_procs, be_win_init CHAINR(0) },
  95.  #endif
  96.  #ifdef AMIGA_INTUITION
  97.      { &amii_procs,
  98.        ami_wininit_data CHAINR(0) }, /* Old font version of the game */
  99.      { &amiv_procs,
  100.        ami_wininit_data CHAINR(0) }, /* Tile version of the game */
  101.  #endif
  102.  #ifdef WIN32_GRAPHICS
  103.      { &win32_procs, 0 CHAINR(0) },
  104.  #endif
  105.  #ifdef GNOME_GRAPHICS
  106.      { &Gnome_procs, 0 CHAINR(0) },
  107.  #endif
  108.  #ifdef MSWIN_GRAPHICS
  109.      { &mswin_procs, 0 CHAINR(0) },
  110.  #endif
  111.  #ifdef WINCHAIN
  112.      { &chainin_procs, chainin_procs_init, chainin_procs_chain },
  113.      { (struct window_procs *) &chainout_procs, chainout_procs_init,
  114.        chainout_procs_chain },
  115.  
  116.      { (struct window_procs *) &trace_procs, trace_procs_init,
  117.        trace_procs_chain },
  118.  #endif
  119.      { 0, 0 CHAINR(0) } /* must be last */
  120.  };
  121.  

Window chain functions

  1.  #ifdef WINCHAIN
  2.  struct winlink {
  3.      struct winlink *nextlink;
  4.      struct win_choices *wincp;
  5.      void *linkdata;
  6.  };
  7.  /* NB: this chain does not contain the terminal real window system pointer */
  8.  
  9.  static struct winlink *chain = 0;
  10.  

wl_new

  1.  static struct winlink *
  2.  wl_new()
  3.  {
  4.      return calloc(1, sizeof(struct winlink));
  5.  }

wl_addhead

  1.  static void
  2.  wl_addhead(struct winlink *wl)
  3.  {
  4.      wl->nextlink = chain;
  5.      chain = wl;
  6.  }

wl_addtail

  1.  static void
  2.  wl_addtail(struct winlink *wl)
  3.  {
  4.      struct winlink *p = chain;
  5.  
  6.      if (!chain) {
  7.          chain = wl;
  8.          return;
  9.      }
  10.      while (p->nextlink) {
  11.          p = p->nextlink;
  12.      }
  13.      p->nextlink = wl;
  14.      return;
  15.  }
  16.  #endif /* WINCHAIN */
  17.  


  1.  static struct win_choices *last_winchoice = 0;
  2.  

genl_can_suspend_no

  1.  boolean
  2.  genl_can_suspend_no(VOID_ARGS)
  3.  {
  4.      return FALSE;
  5.  }
  6.  

genl_can_suspend_yes

  1.  boolean
  2.  genl_can_suspend_yes(VOID_ARGS)
  3.  {
  4.      return TRUE;
  5.  }
  6.  

def_raw_print

  1.  STATIC_OVL
  2.  void
  3.  def_raw_print(s)
  4.  const char *s;
  5.  {
  6.      puts(s);
  7.  }
  8.  

win_choices_find

  1.  #ifdef WINCHAIN
  2.  static struct win_choices *
  3.  win_choices_find(s)
  4.  const char *s;
  5.  {
  6.      register int i;
  7.  
  8.      for (i = 0; winchoices[i].procs; i++) {
  9.          if (!strcmpi(s, winchoices[i].procs->name)) {
  10.              return &winchoices[i];
  11.          }
  12.      }
  13.      return (struct win_choices *) 0;
  14.  }
  15.  #endif
  16.  

choose_windows

  1.  void
  2.  choose_windows(s)
  3.  const char *s;
  4.  {
  5.      register int i;
  6.  
  7.      for (i = 0; winchoices[i].procs; i++) {
  8.          if ('+' == winchoices[i].procs->name[0])
  9.              continue;
  10.          if ('-' == winchoices[i].procs->name[0])
  11.              continue;
  12.          if (!strcmpi(s, winchoices[i].procs->name)) {
  13.              windowprocs = *winchoices[i].procs;
  14.  
  15.              if (last_winchoice && last_winchoice->ini_routine)
  16.                  (*last_winchoice->ini_routine)(WININIT_UNDO);
  17.              if (winchoices[i].ini_routine)
  18.                  (*winchoices[i].ini_routine)(WININIT);
  19.              last_winchoice = &winchoices[i];
  20.              return;
  21.          }
  22.      }
  23.  
  24.      if (!windowprocs.win_raw_print)
  25.          windowprocs.win_raw_print = def_raw_print;
  26.  
  27.      if (!winchoices[0].procs) {
  28.          raw_printf("No window types?");
  29.          exit(EXIT_FAILURE);
  30.      }
  31.      if (!winchoices[1].procs) {
  32.          raw_printf("Window type %s not recognized.  The only choice is: %s.",
  33.                     s, winchoices[0].procs->name);
  34.      } else {
  35.          raw_printf("Window type %s not recognized.  Choices are:", s);
  36.          for (i = 0; winchoices[i].procs; i++) {
  37.              if ('+' == winchoices[i].procs->name[0])
  38.                  continue;
  39.              if ('-' == winchoices[i].procs->name[0])
  40.                  continue;
  41.              raw_printf("        %s", winchoices[i].procs->name);
  42.          }
  43.      }
  44.  
  45.      if (windowprocs.win_raw_print == def_raw_print)
  46.          terminate(EXIT_SUCCESS);
  47.      wait_synch();
  48.  }
  49.  

addto_windowchain

  1.  #ifdef WINCHAIN
  2.  void
  3.  addto_windowchain(s)
  4.  const char *s;
  5.  {
  6.      register int i;
  7.  
  8.      for (i = 0; winchoices[i].procs; i++) {
  9.          if ('+' != winchoices[i].procs->name[0])
  10.              continue;
  11.          if (!strcmpi(s, winchoices[i].procs->name)) {
  12.              struct winlink *p = wl_new();
  13.              p->wincp = &winchoices[i];
  14.              wl_addtail(p);
  15.              /* NB: The ini_routine() will be called during commit. */
  16.              return;
  17.          }
  18.      }
  19.  
  20.      windowprocs.win_raw_print = def_raw_print;
  21.  
  22.      raw_printf("Window processor %s not recognized.  Choices are:", s);
  23.      for (i = 0; winchoices[i].procs; i++) {
  24.          if ('+' != winchoices[i].procs->name[0])
  25.              continue;
  26.          raw_printf("        %s", winchoices[i].procs->name);
  27.      }
  28.  
  29.      exit(EXIT_FAILURE);
  30.  }
  31.  

commit_windowchain

  1.  void
  2.  commit_windowchain()
  3.  {
  4.      struct winlink *p;
  5.      int n;
  6.      int wincap, wincap2;
  7.  
  8.      if (!chain)
  9.          return;
  10.  
  11.      /* Save wincap* from the real window system - we'll restore it below. */
  12.      wincap = windowprocs.wincap;
  13.      wincap2 = windowprocs.wincap2;
  14.  
  15.      /* add -chainin at head and -chainout at tail */
  16.      p = wl_new();
  17.      p->wincp = win_choices_find("-chainin");
  18.      if (!p->wincp) {
  19.          raw_printf("Can't locate processor '-chainin'");
  20.          exit(EXIT_FAILURE);
  21.      }
  22.      wl_addhead(p);
  23.  
  24.      p = wl_new();
  25.      p->wincp = win_choices_find("-chainout");
  26.      if (!p->wincp) {
  27.          raw_printf("Can't locate processor '-chainout'");
  28.          exit(EXIT_FAILURE);
  29.      }
  30.      wl_addtail(p);
  31.  
  32.      /* Now alloc() init() similar to Objective-C. */
  33.      for (n = 1, p = chain; p; n++, p = p->nextlink) {
  34.          p->linkdata = (*p->wincp->chain_routine)(WINCHAIN_ALLOC, n, 0, 0, 0);
  35.      }
  36.  
  37.      for (n = 1, p = chain; p; n++, p = p->nextlink) {
  38.          if (p->nextlink) {
  39.              (void) (*p->wincp->chain_routine)(WINCHAIN_INIT, n, p->linkdata,
  40.                                                p->nextlink->wincp->procs,
  41.                                                p->nextlink->linkdata);
  42.          } else {
  43.              (void) (*p->wincp->chain_routine)(WINCHAIN_INIT, n, p->linkdata,
  44.                                                last_winchoice->procs, 0);
  45.          }
  46.      }
  47.  
  48.      /* Restore the saved wincap* values.  We do it here to give the
  49.       * ini_routine()s a chance to change or check them. */
  50.      chain->wincp->procs->wincap = wincap;
  51.      chain->wincp->procs->wincap2 = wincap2;
  52.  
  53.      /* Call the init procs.  Do not re-init the terminal real win. */
  54.      p = chain;
  55.      while (p->nextlink) {
  56.          if (p->wincp->ini_routine) {
  57.              (*p->wincp->ini_routine)(WININIT);
  58.          }
  59.          p = p->nextlink;
  60.      }
  61.  
  62.      /* Install the chain into window procs very late so ini_routine()s
  63.       * can raw_print on error. */
  64.      windowprocs = *chain->wincp->procs;
  65.  
  66.      p = chain;
  67.      while (p) {
  68.          struct winlink *np = p->nextlink;
  69.          free(p);
  70.          p = np; /* assignment, not proof */
  71.      }
  72.  }
  73.  #endif /* WINCHAIN */
  74.  

genl_message_menu

  1.  /*
  2.   * tty_message_menu() provides a means to get feedback from the
  3.   * --More-- prompt; other interfaces generally don't need that.
  4.   */
  5.  /*ARGSUSED*/
  6.  char
  7.  genl_message_menu(let, how, mesg)
  8.  char let UNUSED;
  9.  int how UNUSED;
  10.  const char *mesg;
  11.  {
  12.      pline("%s", mesg);
  13.      return 0;
  14.  }
  15.  

genl_preference_update

  1.  /*ARGSUSED*/
  2.  void
  3.  genl_preference_update(pref)
  4.  const char *pref UNUSED;
  5.  {
  6.      /* window ports are expected to provide
  7.         their own preference update routine
  8.         for the preference capabilities that
  9.         they support.
  10.         Just return in this genl one. */
  11.      return;
  12.  }
  13.  

genl_getmsghistory

  1.  char *
  2.  genl_getmsghistory(init)
  3.  boolean init UNUSED;
  4.  {
  5.      /* window ports can provide
  6.         their own getmsghistory() routine to
  7.         preserve message history between games.
  8.         The routine is called repeatedly from
  9.         the core save routine, and the window
  10.         port is expected to successively return
  11.         each message that it wants saved, starting
  12.         with the oldest message first, finishing
  13.         with the most recent.
  14.         Return null pointer when finished.
  15.       */
  16.      return (char *) 0;
  17.  }
  18.  

genl_putmsghistory

  1.  void
  2.  genl_putmsghistory(msg, is_restoring)
  3.  const char *msg;
  4.  boolean is_restoring;
  5.  {
  6.      /* window ports can provide
  7.         their own putmsghistory() routine to
  8.         load message history from a saved game.
  9.         The routine is called repeatedly from
  10.         the core restore routine, starting with
  11.         the oldest saved message first, and
  12.         finishing with the latest.
  13.         The window port routine is expected to
  14.         load the message recall buffers in such
  15.         a way that the ordering is preserved.
  16.         The window port routine should make no
  17.         assumptions about how many messages are
  18.         forthcoming, nor should it assume that
  19.         another message will follow this one,
  20.         so it should keep all pointers/indexes
  21.         intact at the end of each call.
  22.      */
  23.  
  24.      /* this doesn't provide for reloading the message window with the
  25.         previous session's messages upon restore, but it does put the quest
  26.         message summary lines there by treating them as ordinary messages */
  27.      if (!is_restoring)
  28.          pline("%s", msg);
  29.      return;
  30.  }
  31.  

Hangup handling

  1.  #ifdef HANGUPHANDLING
  2.  /*
  3.   * Dummy windowing scheme used to replace current one with no-ops
  4.   * in order to avoid all terminal I/O after hangup/disconnect.
  5.   */
  6.  
  7.  static int NDECL(hup_nhgetch);
  8.  static char FDECL(hup_yn_function, (const char *, const char *, CHAR_P));
  9.  static int FDECL(hup_nh_poskey, (int *, int *, int *));
  10.  static void FDECL(hup_getlin, (const char *, char *));
  11.  static void FDECL(hup_init_nhwindows, (int *, char **));
  12.  static void FDECL(hup_exit_nhwindows, (const char *));
  13.  static winid FDECL(hup_create_nhwindow, (int));
  14.  static int FDECL(hup_select_menu, (winid, int, MENU_ITEM_P **));
  15.  static void FDECL(hup_add_menu, (winid, int, const anything *, CHAR_P, CHAR_P,
  16.                                   int, const char *, BOOLEAN_P));
  17.  static void FDECL(hup_end_menu, (winid, const char *));
  18.  static void FDECL(hup_putstr, (winid, int, const char *));
  19.  static void FDECL(hup_print_glyph, (winid, XCHAR_P, XCHAR_P, int, int));
  20.  static void FDECL(hup_outrip, (winid, int, time_t));
  21.  static void FDECL(hup_curs, (winid, int, int));
  22.  static void FDECL(hup_display_nhwindow, (winid, BOOLEAN_P));
  23.  static void FDECL(hup_display_file, (const char *, BOOLEAN_P));
  24.  #ifdef CLIPPING
  25.  static void FDECL(hup_cliparound, (int, int));
  26.  #endif
  27.  #ifdef CHANGE_COLOR
  28.  static void FDECL(hup_change_color, (int, long, int));
  29.  #ifdef MAC
  30.  static short FDECL(hup_set_font_name, (winid, char *));
  31.  #endif
  32.  static char *NDECL(hup_get_color_string);
  33.  #endif /* CHANGE_COLOR */
  34.  #ifdef STATUS_VIA_WINDOWPORT
  35.  static void FDECL(hup_status_update, (int, genericptr_t, int, int));
  36.  #endif
  37.  
  38.  static int NDECL(hup_int_ndecl);
  39.  static void NDECL(hup_void_ndecl);
  40.  static void FDECL(hup_void_fdecl_int, (int));
  41.  static void FDECL(hup_void_fdecl_winid, (winid));
  42.  static void FDECL(hup_void_fdecl_constchar_p, (const char *));
  43.  
  44.  static struct window_procs hup_procs = {
  45.      "hup", 0L, 0L, hup_init_nhwindows,
  46.      hup_void_ndecl,                                    /* player_selection */
  47.      hup_void_ndecl,                                    /* askname */
  48.      hup_void_ndecl,                                    /* get_nh_event */
  49.      hup_exit_nhwindows, hup_void_fdecl_constchar_p,    /* suspend_nhwindows */
  50.      hup_void_ndecl,                                    /* resume_nhwindows */
  51.      hup_create_nhwindow, hup_void_fdecl_winid,         /* clear_nhwindow */
  52.      hup_display_nhwindow, hup_void_fdecl_winid,        /* destroy_nhwindow */
  53.      hup_curs, hup_putstr, hup_putstr,                  /* putmixed */
  54.      hup_display_file, hup_void_fdecl_winid,            /* start_menu */
  55.      hup_add_menu, hup_end_menu, hup_select_menu, genl_message_menu,
  56.      hup_void_ndecl,                                    /* update_inventory */
  57.      hup_void_ndecl,                                    /* mark_synch */
  58.      hup_void_ndecl,                                    /* wait_synch */
  59.  #ifdef CLIPPING
  60.      hup_cliparound,
  61.  #endif
  62.  #ifdef POSITIONBAR
  63.      (void FDECL((*), (char *))) hup_void_fdecl_constchar_p,
  64.                                                        /* update_positionbar */
  65.  #endif
  66.      hup_print_glyph,
  67.      hup_void_fdecl_constchar_p,                       /* raw_print */
  68.      hup_void_fdecl_constchar_p,                       /* raw_print_bold */
  69.      hup_nhgetch, hup_nh_poskey, hup_void_ndecl,       /* nhbell  */
  70.      hup_int_ndecl,                                    /* doprev_message */
  71.      hup_yn_function, hup_getlin, hup_int_ndecl,       /* get_ext_cmd */
  72.      hup_void_fdecl_int,                               /* number_pad */
  73.      hup_void_ndecl,                                   /* delay_output  */
  74.  #ifdef CHANGE_COLOR
  75.      hup_change_color,
  76.  #ifdef MAC
  77.      hup_void_fdecl_int,                               /* change_background */
  78.      hup_set_font_name,
  79.  #endif
  80.      hup_get_color_string,
  81.  #endif /* CHANGE_COLOR */
  82.      hup_void_ndecl,                                   /* start_screen */
  83.      hup_void_ndecl,                                   /* end_screen */
  84.      hup_outrip, genl_preference_update, genl_getmsghistory,
  85.      genl_putmsghistory,
  86.  #ifdef STATUS_VIA_WINDOWPORT
  87.      hup_void_ndecl,                                   /* status_init */
  88.      hup_void_ndecl,                                   /* status_finish */
  89.      genl_status_enablefield, hup_status_update,
  90.  #ifdef STATUS_HILITES
  91.      genl_status_threshold,
  92.  #endif
  93.  #endif /* STATUS_VIA_WINDOWPORT */
  94.      genl_can_suspend_no,
  95.  };
  96.  
  97.  static void FDECL((*previnterface_exit_nhwindows), (const char *)) = 0;
  98.  

nhwindows_hangup

  1.  /* hangup has occurred; switch to no-op user interface */
  2.  void
  3.  nhwindows_hangup()
  4.  {
  5.      char *FDECL((*previnterface_getmsghistory), (BOOLEAN_P)) = 0;
  6.  
  7.  #ifdef ALTMETA
  8.      /* command processor shouldn't look for 2nd char after seeing ESC */
  9.      iflags.altmeta = FALSE;
  10.  #endif
  11.  
  12.      /* don't call exit_nhwindows() directly here; if a hangup occurs
  13.         while interface code is executing, exit_nhwindows could knock
  14.         the interface's active data structures out from under itself */
  15.      if (iflags.window_inited
  16.          && windowprocs.win_exit_nhwindows != hup_exit_nhwindows)
  17.          previnterface_exit_nhwindows = windowprocs.win_exit_nhwindows;
  18.  
  19.      /* also, we have to leave the old interface's getmsghistory()
  20.         in place because it will be called while saving the game */
  21.      if (windowprocs.win_getmsghistory != hup_procs.win_getmsghistory)
  22.          previnterface_getmsghistory = windowprocs.win_getmsghistory;
  23.  
  24.      windowprocs = hup_procs;
  25.  
  26.      if (previnterface_getmsghistory)
  27.          windowprocs.win_getmsghistory = previnterface_getmsghistory;
  28.  }
  29.  

hup_exit_nhwindows

  1.  static void
  2.  hup_exit_nhwindows(lastgasp)
  3.  const char *lastgasp;
  4.  {
  5.      /* core has called exit_nhwindows(); call the previous interface's
  6.         shutdown routine now; xxx_exit_nhwindows() needs to call other
  7.         xxx_ routines directly rather than through windowprocs pointers */
  8.      if (previnterface_exit_nhwindows) {
  9.          lastgasp = 0; /* don't want exit routine to attempt extra output */
  10.          (*previnterface_exit_nhwindows)(lastgasp);
  11.          previnterface_exit_nhwindows = 0;
  12.      }
  13.      iflags.window_inited = 0;
  14.  }
  15.  

hup_nhgetch

  1.  static int
  2.  hup_nhgetch(VOID_ARGS)
  3.  {
  4.      return '\033'; /* ESC */
  5.  }
  6.  

hup_yn_function

  1.  /*ARGSUSED*/
  2.  static char
  3.  hup_yn_function(prompt, resp, deflt)
  4.  const char *prompt UNUSED, *resp UNUSED;
  5.  char deflt;
  6.  {
  7.      if (!deflt)
  8.          deflt = '\033';
  9.      return deflt;
  10.  }
  11.  

hup_nh_poskey

  1.  /*ARGSUSED*/
  2.  static int
  3.  hup_nh_poskey(x, y, mod)
  4.  int *x UNUSED, *y UNUSED, *mod UNUSED;
  5.  {
  6.      return '\033';
  7.  }
  8.  

hup_getlin

  1.  /*ARGSUSED*/
  2.  static void
  3.  hup_getlin(prompt, outbuf)
  4.  const char *prompt UNUSED;
  5.  char *outbuf;
  6.  {
  7.      Strcpy(outbuf, "\033");
  8.  }
  9.  

hup_init_nhwindows

  1.  /*ARGSUSED*/
  2.  static void
  3.  hup_init_nhwindows(argc_p, argv)
  4.  int *argc_p UNUSED;
  5.  char **argv UNUSED;
  6.  {
  7.      iflags.window_inited = 1;
  8.  }
  9.  

hup_create_nhwindow

  1.  /*ARGUSED*/
  2.  static winid
  3.  hup_create_nhwindow(type)
  4.  int type UNUSED;
  5.  {
  6.      return WIN_ERR;
  7.  }
  8.  

hup_select_menu

  1.  /*ARGSUSED*/
  2.  static int
  3.  hup_select_menu(window, how, menu_list)
  4.  winid window UNUSED;
  5.  int how UNUSED;
  6.  struct mi **menu_list UNUSED;
  7.  {
  8.      return -1;
  9.  }
  10.  

hup_add_menu

  1.  /*ARGSUSED*/
  2.  static void
  3.  hup_add_menu(window, glyph, identifier, sel, grpsel, attr, txt, preselected)
  4.  winid window UNUSED;
  5.  int glyph UNUSED, attr UNUSED;
  6.  const anything *identifier UNUSED;
  7.  char sel UNUSED, grpsel UNUSED;
  8.  const char *txt UNUSED;
  9.  boolean preselected UNUSED;
  10.  {
  11.      return;
  12.  }
  13.  

hup_end_menu

  1.  /*ARGSUSED*/
  2.  static void
  3.  hup_end_menu(window, prompt)
  4.  winid window UNUSED;
  5.  const char *prompt UNUSED;
  6.  {
  7.      return;
  8.  }
  9.  

hup_putstr

  1.  /*ARGSUSED*/
  2.  static void
  3.  hup_putstr(window, attr, text)
  4.  winid window UNUSED;
  5.  int attr UNUSED;
  6.  const char *text UNUSED;
  7.  {
  8.      return;
  9.  }
  10.  

hup_print_glyph

  1.  /*ARGSUSED*/
  2.  static void
  3.  hup_print_glyph(window, x, y, glyph, bkglyph)
  4.  winid window UNUSED;
  5.  xchar x UNUSED, y UNUSED;
  6.  int glyph UNUSED;
  7.  int bkglyph UNUSED;
  8.  {
  9.      return;
  10.  }
  11.  

hup_outrip

  1.  /*ARGSUSED*/
  2.  static void
  3.  hup_outrip(tmpwin, how, when)
  4.  winid tmpwin UNUSED;
  5.  int how UNUSED;
  6.  time_t when UNUSED;
  7.  {
  8.      return;
  9.  }
  10.  

hup_curs

  1.  /*ARGSUSED*/
  2.  static void
  3.  hup_curs(window, x, y)
  4.  winid window UNUSED;
  5.  int x UNUSED, y UNUSED;
  6.  {
  7.      return;
  8.  }
  9.  

hup_display_nhwindow

  1.  /*ARGSUSED*/
  2.  static void
  3.  hup_display_nhwindow(window, blocking)
  4.  winid window UNUSED;
  5.  boolean blocking UNUSED;
  6.  {
  7.      return;
  8.  }
  9.  

hup_display_file

  1.  /*ARGSUSED*/
  2.  static void
  3.  hup_display_file(fname, complain)
  4.  const char *fname UNUSED;
  5.  boolean complain UNUSED;
  6.  {
  7.      return;
  8.  }
  9.  

hup_cliparound ==

  1.  #ifdef CLIPPING
  2.  /*ARGSUSED*/
  3.  static void
  4.  hup_cliparound(x, y)
  5.  int x UNUSED, y UNUSED;
  6.  {
  7.      return;
  8.  }
  9.  #endif
  10.  

hup_change_color

  1.  #ifdef CHANGE_COLOR
  2.  /*ARGSUSED*/
  3.  static void
  4.  hup_change_color(color, rgb, reverse)
  5.  int color, reverse;
  6.  long rgb;
  7.  {
  8.      return;
  9.  }
  10.  

hup_set_font_name

  1.  #ifdef MAC
  2.  /*ARGSUSED*/
  3.  static short
  4.  hup_set_font_name(window, fontname)
  5.  winid window;
  6.  char *fontname;
  7.  {
  8.      return 0;
  9.  }
  10.  #endif /* MAC */
  11.  

hup_get_color_string

  1.  static char *
  2.  hup_get_color_string(VOID_ARGS)
  3.  {
  4.      return (char *) 0;
  5.  }
  6.  #endif /* CHANGE_COLOR */
  7.  

hup_status_update

  1.  #ifdef STATUS_VIA_WINDOWPORT
  2.  /*ARGSUSED*/
  3.  static void
  4.  hup_status_update(idx, ptr, chg, percent)
  5.  int idx UNUSED, chg UNUSED, percent UNUSED;
  6.  genericptr_t ptr UNUSED;
  7.  {
  8.      return;
  9.  }
  10.  #endif /* STATUS_VIA_WINDOWPORT */
  11.  

hup_int_ndecl

  1.  /*
  2.   * Non-specific stubs.
  3.   */
  4.  
  5.  static int
  6.  hup_int_ndecl(VOID_ARGS)
  7.  {
  8.      return -1;
  9.  }
  10.  

hup_void_ndecl

  1.  static void
  2.  hup_void_ndecl(VOID_ARGS)
  3.  {
  4.      return;
  5.  }
  6.  

hup_void_fdecl_int

  1.  /*ARGUSED*/
  2.  static void
  3.  hup_void_fdecl_int(arg)
  4.  int arg UNUSED;
  5.  {
  6.      return;
  7.  }
  8.  

hup_void_fdecl_winid

  1.  /*ARGUSED*/
  2.  static void
  3.  hup_void_fdecl_winid(window)
  4.  winid window UNUSED;
  5.  {
  6.      return;
  7.  }
  8.  

hup_void_fdecl_constchar_p

  1.  /*ARGUSED*/
  2.  static void
  3.  hup_void_fdecl_constchar_p(string)
  4.  const char *string UNUSED;
  5.  {
  6.      return;
  7.  }
  8.  
  9.  #endif /* HANGUPHANDLING */
  10.  

genl backward compatibility

  1.  #ifdef STATUS_VIA_WINDOWPORT
  2.  
  3.  /****************************************************************************/
  4.  /* genl backward compat stuff                                               */
  5.  /****************************************************************************/
  6.  
  7.  const char *status_fieldnm[MAXBLSTATS];
  8.  const char *status_fieldfmt[MAXBLSTATS];
  9.  char *status_vals[MAXBLSTATS];
  10.  boolean status_activefields[MAXBLSTATS];
  11.  NEARDATA winid WIN_STATUS;
  12.  

genl_status_init

  1.  void
  2.  genl_status_init()
  3.  {
  4.      int i;
  5.      for (i = 0; i < MAXBLSTATS; ++i) {
  6.          status_vals[i] = (char *) alloc(MAXCO);
  7.          *status_vals[i] = '\0';
  8.          status_activefields[i] = FALSE;
  9.          status_fieldfmt[i] = (const char *) 0;
  10.      }
  11.      /* Use a window for the genl version; backward port compatibility */
  12.      WIN_STATUS = create_nhwindow(NHW_STATUS);
  13.      display_nhwindow(WIN_STATUS, FALSE);
  14.  }
  15.  

genl_status_finish

  1.  void
  2.  genl_status_finish()
  3.  {
  4.      /* tear down routine */
  5.      int i;
  6.  
  7.      /* free alloc'd memory here */
  8.      for (i = 0; i < MAXBLSTATS; ++i) {
  9.          if (status_vals[i])
  10.              free((genericptr_t) status_vals[i]);
  11.          status_vals[i] = (char *) 0;
  12.      }
  13.  }
  14.  

genl_status_enablefield

  1.  void
  2.  genl_status_enablefield(fieldidx, nm, fmt, enable)
  3.  int fieldidx;
  4.  const char *nm;
  5.  const char *fmt;
  6.  boolean enable;
  7.  {
  8.      status_fieldfmt[fieldidx] = fmt;
  9.      status_fieldnm[fieldidx] = nm;
  10.      status_activefields[fieldidx] = enable;
  11.  }
  12.  

genl_status_update

  1.  void
  2.  genl_status_update(idx, ptr, chg, percent)
  3.  int idx, chg, percent;
  4.  genericptr_t ptr;
  5.  {
  6.      char newbot1[MAXCO], newbot2[MAXCO];
  7.      long cond, *condptr = (long *) ptr;
  8.      register int i;
  9.      char *text = (char *) ptr;
  10.  
  11.      enum statusfields fieldorder[2][15] = {
  12.          { BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH, BL_ALIGN,
  13.            BL_SCORE, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH,
  14.            BL_FLUSH },
  15.          { BL_LEVELDESC, BL_GOLD, BL_HP, BL_HPMAX, BL_ENE, BL_ENEMAX,
  16.            BL_AC, BL_XP, BL_EXP, BL_HD, BL_TIME, BL_HUNGER,
  17.            BL_CAP, BL_CONDITION, BL_FLUSH }
  18.      };
  19.  
  20.      if (idx != BL_FLUSH) {
  21.          if (!status_activefields[idx])
  22.              return;
  23.          switch (idx) {
  24.          case BL_CONDITION:
  25.              cond = *condptr;
  26.              *status_vals[idx] = '\0';
  27.              if (cond & BL_MASK_BLIND)
  28.                  Strcat(status_vals[idx], " Blind");
  29.              if (cond & BL_MASK_CONF)
  30.                  Strcat(status_vals[idx], " Conf");
  31.              if (cond & BL_MASK_FOODPOIS)
  32.                  Strcat(status_vals[idx], " FoodPois");
  33.              if (cond & BL_MASK_ILL)
  34.                  Strcat(status_vals[idx], " Ill");
  35.              if (cond & BL_MASK_STUNNED)
  36.                  Strcat(status_vals[idx], " Stun");
  37.              if (cond & BL_MASK_HALLU)
  38.                  Strcat(status_vals[idx], " Hallu");
  39.              if (cond & BL_MASK_SLIMED)
  40.                  Strcat(status_vals[idx], " Slime");
  41.              break;
  42.          default:
  43.              Sprintf(status_vals[idx],
  44.                      status_fieldfmt[idx] ? status_fieldfmt[idx] : "%s", text);
  45.              break;
  46.          }
  47.      }
  48.  
  49.      /* This genl version updates everything on the display, everytime */
  50.      newbot1[0] = '\0';
  51.      for (i = 0; fieldorder[0][i] != BL_FLUSH; ++i) {
  52.          int idx1 = fieldorder[0][i];
  53.          if (status_activefields[idx1])
  54.              Strcat(newbot1, status_vals[idx1]);
  55.      }
  56.      newbot2[0] = '\0';
  57.      for (i = 0; fieldorder[1][i] != BL_FLUSH; ++i) {
  58.          int idx2 = fieldorder[1][i];
  59.          if (status_activefields[idx2])
  60.              Strcat(newbot2, status_vals[idx2]);
  61.      }
  62.      curs(WIN_STATUS, 1, 0);
  63.      putstr(WIN_STATUS, 0, newbot1);
  64.      curs(WIN_STATUS, 1, 1);
  65.      putmixed(WIN_STATUS, 0, newbot2); /* putmixed() due to GOLD glyph */
  66.  }
  67.  

genl_status_threshold

  1.  #ifdef STATUS_HILITES
  2.  void
  3.  genl_status_threshold(fldidx, thresholdtype, threshold, behavior, under, over)
  4.  int fldidx, thresholdtype;
  5.  int behavior, under, over;
  6.  anything threshold;
  7.  {
  8.      return;
  9.  }
  10.  #endif /* STATUS_HILITES */
  11.  #endif /* STATUS_VIA_WINDOWPORT */
  12.  
  13.  /*windows.c*/