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

Function tty_create_nhwindow

win/tty/wintty.c:847–961  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

845}
846
847DISABLE_WARNING_UNREACHABLE_CODE
848
849winid
850tty_create_nhwindow(int type)
851{
852 struct WinDesc *newwin;
853 int i, rowoffset;
854 int newid;
855
856 for (newid = 0; newid < MAXWIN; ++newid)
857 if (wins[newid] == 0)
858 break;
859 if (newid == MAXWIN) {
860 panic("No window slots!");
861 /*NOTREACHED*/
862 return WIN_ERR;
863 }
864
865 newwin = (struct WinDesc *) alloc(sizeof (struct WinDesc));
866 wins[newid] = newwin;
867
868 newwin->type = type;
869 newwin->flags = 0;
870 newwin->active = FALSE;
871 newwin->curx = newwin->cury = 0;
872 newwin->morestr = 0;
873 newwin->mlist = (tty_menu_item *) 0;
874 newwin->plist = (tty_menu_item **) 0;
875 newwin->npages = newwin->plist_size = newwin->nitems = newwin->how = 0;
876 newwin->mbehavior = 0U;
877 switch (type) {
878 case NHW_BASE:
879 /* base window, used for absolute movement on the screen */
880 newwin->offx = newwin->offy = 0;
881 newwin->rows = ttyDisplay->rows;
882 newwin->cols = ttyDisplay->cols;
883 newwin->maxrow = newwin->maxcol = 0;
884 break;
885 case NHW_MESSAGE:
886 /* message window, 1 line long, very wide, top of screen */
887 newwin->offx = newwin->offy = 0;
888 /* sanity check */
889 if (iflags.msg_history < 20)
890 iflags.msg_history = 20;
891 else if (iflags.msg_history > MAX_MSG_HISTORY)
892 iflags.msg_history = MAX_MSG_HISTORY;
893 newwin->maxrow = newwin->rows = iflags.msg_history;
894 newwin->maxcol = newwin->cols = 0;
895 break;
896 case NHW_STATUS:
897 /* status window, 2 or 3 lines long, full width, bottom of screen */
898 if (iflags.wc2_statuslines < 2
899#ifndef CLIPPING
900 || (LI < 1 + ROWNO + 3)
901#endif
902 || iflags.wc2_statuslines > 3)
903 iflags.wc2_statuslines = 2;
904 newwin->offx = 0;

Callers 4

tty_init_nhwindowsFunction · 0.85
tty_display_fileFunction · 0.85
mac_init_nhwindowsFunction · 0.85
mac_create_nhwindowFunction · 0.85

Calls 2

panicFunction · 0.50
allocFunction · 0.50

Tested by

no test coverage detected