MCPcopy Create free account
hub / github.com/NetHack/NetHack / ttyinv_create_window

Function ttyinv_create_window

win/tty/wintty.c:2915–2999  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2913#ifdef TTY_PERM_INVENT
2914
2915static int
2916ttyinv_create_window(int newid, struct WinDesc *newwin)
2917{
2918 int r, c;
2919 long minrow; /* long to match maxrow declaration */
2920 unsigned n;
2921
2922 /* Is there enough real estate to do this beyond the status line?
2923 * Rows:
2924 * Top border line (1)
2925 * 26 inventory rows (26)
2926 * [should be 27 to have room for '$' and '#']
2927 * Bottom border line (1)
2928 * 1 + 26 + 1 = 28
2929 *
2930 * Cols:
2931 * Left border (1)
2932 * Left inventory items (38)
2933 * Middle separation (1)
2934 * Right inventory items (38)
2935 * Right border (1)
2936 * 1 + 38 + 1 + 38 + 1 = 79
2937 *
2938 * The topline + map rows + status lines require:
2939 * 1 + 21 + 2 (or 3) = 24 (or 25 depending on status line count).
2940 * So we can only present a full inventory on tty if there are
2941 * 28 + 24 (or 25) available (52 or 53 rows on the terminal).
2942 * Correspondingly ttyDisplay->rows has to be at least 52 (or 53).
2943 * [The top and bottom borderlines aren't necessary. Suppressing
2944 * them would reduce the number of rows needed by 2.]
2945 *
2946 */
2947
2948 /* preliminary init in case tty_destroy_nhwindow() gets called */
2949 newwin->data = (char **) 0;
2950 newwin->datlen = (short *) 0;
2951 newwin->cells = (struct tty_perminvent_cell **) 0;
2952
2953 if (!assesstty(ttyinvmode, &newwin->offx, &newwin->offy, &newwin->rows,
2954 &newwin->cols, &newwin->maxcol, &minrow,
2955 &newwin->maxrow)) {
2956 tty_destroy_nhwindow(newid);
2957 WIN_INVEN = WIN_ERR;
2958 pline("%s.", "tty perm_invent could not be enabled");
2959 pline("tty perm_invent needs a terminal that is at least %dx%d, "
2960 "yours is %dx%d.",
2961 (int) (minrow + 1 + ROWNO + StatusRows()), tty_perminv_mincol,
2962 ttyDisplay->rows, ttyDisplay->cols);
2963 tty_wait_synch();
2964#ifndef RESIZABLE
2965 set_option_mod_status("perm_invent", set_gameview);
2966#endif
2967 iflags.perm_invent = FALSE;
2968 return WIN_ERR;
2969 }
2970
2971 /*
2972 * Terminal/window/screen is big enough.

Callers 1

tty_start_menuFunction · 0.85

Calls 7

assessttyFunction · 0.85
tty_destroy_nhwindowFunction · 0.85
tty_wait_synchFunction · 0.85
set_option_mod_statusFunction · 0.85
plineFunction · 0.50
allocFunction · 0.50

Tested by

no test coverage detected