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

Function X11_display_file

win/X11/winX.c:2070–2109  ·  view source on GitHub ↗

uses a menu (with no selectors specified) rather than a text window to allow previous_page and first_menu actions to move backwards */

Source from the content-addressed store, hash-verified

2068/* uses a menu (with no selectors specified) rather than a text window
2069 to allow previous_page and first_menu actions to move backwards */
2070void
2071X11_display_file(const char *str, boolean complain)
2072{
2073 dlb *fp;
2074 winid newwin;
2075 struct xwindow *wp;
2076 anything any;
2077 menu_item *menu_list;
2078#define LLEN 128
2079 char line[LLEN];
2080 int clr = 0;
2081
2082 /* Use the port-independent file opener to see if the file exists. */
2083 fp = dlb_fopen(str, RDTMODE);
2084 if (!fp) {
2085 if (complain)
2086 pline("Cannot open %s. Sorry.", str);
2087 return; /* it doesn't exist, ignore */
2088 }
2089
2090 newwin = X11_create_nhwindow(NHW_MENU);
2091 wp = &window_list[newwin];
2092 X11_start_menu(newwin, MENU_BEHAVE_STANDARD);
2093
2094 any = cg.zeroany;
2095 while (dlb_fgets(line, LLEN, fp)) {
2096 X11_add_menu(newwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE,
2097 clr, line, MENU_ITEMFLAGS_NONE);
2098 }
2099 (void) dlb_fclose(fp);
2100
2101 /* show file name as the window title */
2102 if (str)
2103 wp->title = dupstr(str);
2104
2105 wp->menu_information->permi = FALSE;
2106 wp->menu_information->disable_mcolors = TRUE;
2107 (void) X11_select_menu(newwin, PICK_NONE, &menu_list);
2108 X11_destroy_nhwindow(newwin);
2109}
2110
2111/* yn_function ------------------------------------------------------------ */
2112/* (not threaded) */

Callers

nothing calls this directly

Calls 10

dlb_fopenFunction · 0.85
X11_create_nhwindowFunction · 0.85
X11_start_menuFunction · 0.85
dlb_fgetsFunction · 0.85
X11_add_menuFunction · 0.85
dlb_fcloseFunction · 0.85
dupstrFunction · 0.85
X11_select_menuFunction · 0.85
X11_destroy_nhwindowFunction · 0.85
plineFunction · 0.50

Tested by

no test coverage detected