Team Ai
Datasetpublic

hschumann2/TempleOS-Source-Code

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes832downloads
InFile.txt142 linesDownload Raw Back to Adam
1 2#help_index "InFile;Help System/Training"3#help_file "::/Doc/InFile"4 5public U0 InGetStr(U8 *st)6{//Wait for user to type certain str.7  I64 ch,sc;8  U8 buf[256],*st2;9  while (*st) {10    ch=GetKey(&sc,FALSE);11    if (sc.u8[0]!=SC_SHIFT &&12          sc.u8[0]!=SC_ALT &&13          sc.u8[0]!=SC_CTRL) {14      if (ch==*st) {15        '' ch;16        st++;17      } else {18        st2=Char2KeyName(*st);19        StrPrint(buf,"Press the $GREEN$<%s>$FG$ key.",st2);20        Free(st2);21        PopUpOk(buf);22      }23    }24  }25}26 27public U0 InPrint(I64 mS=100,U8 *fmt,...)28{//Print message with delay after each char.29  U8 *buf=StrPrintJoin(NULL,fmt,argc,argv),*st=buf;30  I64 ch;31  while (ch=*st++) {32    '' ch;33    Sleep(mS);34  }35  Free(buf);36}37 38public U0 InGetKey(I64 scan_code,I64 sc_mask=0xFF|SCF_SHIFT|SCF_CTRL|SCF_ALT)39{//Wait for user to press certain key.40  I64 sc,ch;41  U8 buf[STR_LEN],*st;42  do {43    ch=GetKey(&sc);44    if (sc.u8[0]!=SC_PRTSCRN1 &&45          !(sc.u8[0]==SC_SHIFT && scan_code&SCF_SHIFT) &&46          !(sc.u8[0]==SC_CTRL && scan_code&SCF_CTRL) &&47          !(sc.u8[0]==SC_ALT && scan_code&SCF_ALT) ) {48      if (sc&sc_mask!=scan_code&sc_mask) {49        st=ScanCode2KeyName(scan_code);50        StrPrint(buf,"Press the $GREEN$<%s>$FG$ key",st);51        Free(st);52        PopUpOk(buf);53      }54    }55  } while (sc&sc_mask!=scan_code&sc_mask);56  Msg(MSG_KEY_DOWN,ch,sc);57}58 59public I64 InGetChar(...)60{//Wait for user to press one of set of chars.61  I64 i,sc,ch;62  U8 buf[512],*st;63  while (TRUE) {64    ch=GetKey(&sc);65    if (sc.u8[0]!=SC_SHIFT && sc.u8[0]!=SC_ALT && sc.u8[0]!=SC_CTRL) {66      for (i=0;i<argc;i++)67        if (ch==argv[i]) {68          Msg(MSG_KEY_DOWN,ch,sc);69          return ch;70        }71      StrPrint(buf,"Press ");72      for (i=0;i<argc;i++) {73        st=Char2KeyName(argv[i]);74        CatPrint(buf,"$GREEN$<%s>$FG$",st);75        Free(st);76        if (argc==i+1)77          CatPrint(buf,".");78        else if (argc==i+2)79          CatPrint(buf," or ");80        else81          CatPrint(buf,", ");82      }83      PopUpOk(buf);84    }85  }86}87 88public U0 InUntilKey(I64 scan_code,I64 sc_mask=0xFF|SCF_SHIFT|SCF_CTRL|SCF_ALT)89{//Let user type until he presses certain key.90  I64 sc,ch;91  do {92    ch=GetKey(&sc);93    Msg(MSG_KEY_DOWN,ch,sc);94  } while (sc&sc_mask!=scan_code&sc_mask);95}96 97public I64 InUntilChar(...)98{//Let user type until he presses one of set of chars.99  I64 i,sc,ch;100  while (TRUE) {101    ch=GetKey(&sc);102    Msg(MSG_KEY_DOWN,ch,sc);103    for (i=0;i<argc;i++)104      if (ch==argv[i])105        return ch;106  }107}108 109public Bool InView()110{//Let user type until <ESC> or <SHIFT-ESC>.111  Bool res=View;112  DocBottom;113  return res;114}115 116#help_index "InFile;Help System/Training;Mouse"117I64 in_plot_l,in_plot_r;118 119Bool InSetMsPlot(I64 mS,I64 x,I64 y,I64 z)120{121  MsSet(x,y,z,in_plot_l,in_plot_r);122  Sleep(mS);123  return TRUE;124}125 126public U0 InSetMs(I64 mS=7,I64 x=I64_MAX,I64 y=I64_MAX,I64 z=I64_MAX,127                I64 l=I64_MAX,I64 r=I64_MAX)128{//Move mouse to spot at certain speed.129  if (!(0<=x<GR_WIDTH))130    x=ms.pos.x;131  if (!(0<=y<GR_HEIGHT))132    y=ms.pos.y;133  if (z==I64_MAX)134    z=ms.pos.z;135  if (!(FALSE<=l<=TRUE))136    l=ms.lb;137  if (!(FALSE<=r<=TRUE))138    r=ms.rb;139  in_plot_l=l; in_plot_r=r;140  Line(mS,ms.pos.x,ms.pos.y,ms.pos.z,x,y,z,&InSetMsPlot);141}142