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

Method qt_display_file

outdated/win/Qt3/qt3_win.cpp:4770–4818  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4768}
4769
4770void NetHackQtBind::qt_display_file(const char *filename, BOOLEAN_P must_exist)
4771{
4772 NetHackQtTextWindow* window=new NetHackQtTextWindow(keybuffer);
4773 bool complain = FALSE;
4774
4775#ifdef DLB
4776 {
4777 dlb *f;
4778 char buf[BUFSZ];
4779 char *cr;
4780
4781 window->Clear();
4782 f = dlb_fopen(filename, "r");
4783 if (!f) {
4784 complain = must_exist;
4785 } else {
4786 while (dlb_fgets(buf, BUFSZ, f)) {
4787 if ((cr = strchr(buf, '\n')) != 0) *cr = 0;
4788#ifdef MSDOS
4789 if ((cr = strchr(buf, '\r')) != 0) *cr = 0;
4790#endif
4791 if (strchr(buf, '\t') != 0) (void) tabexpand(buf);
4792 window->PutStr(ATR_NONE, buf);
4793 }
4794 window->Display(FALSE);
4795 (void) dlb_fclose(f);
4796 }
4797 }
4798#else
4799 QFile file(filename);
4800
4801 if (file.open(IO_ReadOnly)) {
4802 char line[128];
4803 while (file.readLine(line,127) >= 0) {
4804 line[strlen(line)-1]=0;// remove newline
4805 window->PutStr(ATR_NONE,line);
4806 }
4807 window->Display(FALSE);
4808 } else {
4809 complain = must_exist;
4810 }
4811#endif
4812
4813 if (complain) {
4814 QString message;
4815 message.sprintf("File not found: %s\n",filename);
4816 QMessageBox::message("File Error", (const char*)message, "Ignore");
4817 }
4818}
4819
4820void NetHackQtBind::qt_start_menu(winid wid, unsigned long mbehavior)
4821{

Callers

nothing calls this directly

Calls 7

dlb_fopenFunction · 0.85
dlb_fgetsFunction · 0.85
tabexpandFunction · 0.85
dlb_fcloseFunction · 0.85
ClearMethod · 0.45
PutStrMethod · 0.45
DisplayMethod · 0.45

Tested by

no test coverage detected