Team Ai
Datasetpublic

hschumann2/TempleOS-Source-Code

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes847downloads
HomeKeyPlugIns.txt317 linesDownload Raw Back to AcctExample
1 2//Place this file in /Home and change3//anything you want.4 5U0 TimeIns()6{7  CDate cdt;8  cdt=Now;9  "$IV,1$----%D %T----$IV,0$\n",cdt,cdt;10}11 12U0 FileLinkIns()13{14  U8 *st=PopUpPickFile;15  st[0]=':';  //This is my personal code, not production. LOL16  "$LK,\"%s\",A=\"FI:%s\"$",st+2,st;17  Free(st);18}19 20U0 DirLinksIns()21{22  CDirEntry *tmpde,*tmpde1;23  U8 *st=PopUpPickDir,*st2;24  st[0]=':';  //This is my personal code, not production. LOL25  st2=MStrPrint("%s/*",st);26  tmpde=tmpde1=FilesFind(st2,FUF_JUST_FILES);27  while (tmpde) {28    tmpde->full_name[0]=':';29    "$LK,\"%s\",A=\"FI:%s\"$\n",tmpde->full_name+2,tmpde->full_name;30    tmpde=tmpde->next;31  }32  DirTreeDel(tmpde1);33  Free(st);34  Free(st2);35}36 37U0 DocHiddenDel(CDoc *doc=NULL)38{39  Bool unlock;40  CDocEntry *doc_e,*doc_e1;41  if (!doc) doc=DocPut;42  if (doc) {43    unlock=DocLock(doc);44    DocRecalc(doc);45    doc_e=doc->head.next;46    while (doc_e!=doc) {47      doc_e1=doc_e->next;48      if (doc_e->de_flags&(DOCEF_FILTER_SKIP|DOCEF_SKIP))49        DocEntryDel(doc,doc_e);50      doc_e=doc_e1;51    }52    DocRecalc(doc);53    if (unlock)54      DocUnlock(doc);55  }56}57 58Bool MyPutKey(I64 ch,I64 sc)59{//ch=ASCII; sc=scan_code60 61  //See Char for definition of scan codes.62  //See Key Allocations.63  //See Keyboard Devices.64 65  //You can customize keys.  This routine66  //is called before the main editor67  //key hndlr DocPutKey().68  //You can intercept any key.69 70  //Return TRUE if you completely71  //handled the key.72  I64 i;73  U8 *st1,*st2;74  if (sc&SCF_ALT && !(sc&SCF_CTRL)) {75    switch (ch) {76      case 0:77        switch (sc.u8[0]) {78          case SC_F1:79            if (sc&SCF_SHIFT) {80              if (sc&SCF_KEY_DESC)81                KeyDescSet("Dol /LTPURPLE");82              else83                "$LTPURPLE$";84            } else {85              if (sc&SCF_KEY_DESC)86                KeyDescSet("Dol /PURPLE");87              else88                "$PURPLE$";89            }90            return TRUE;91          case SC_F2:92            if (sc&SCF_SHIFT) {93              if (sc&SCF_KEY_DESC)94                KeyDescSet("Dol /LTRED");95              else96                "$LTRED$";97            } else {98              if (sc&SCF_KEY_DESC)99                KeyDescSet("Dol /RED");100              else101                "$RED$";102            }103            return TRUE;104          case SC_F3:105            if (sc&SCF_SHIFT) {106              if (sc&SCF_KEY_DESC)107                KeyDescSet("Dol /LTGREEN");108              else109                "$LTGREEN$";110            } else {111              if (sc&SCF_KEY_DESC)112                KeyDescSet("Dol /GREEN");113              else114                "$GREEN$";115            }116            return TRUE;117          case SC_F4:118            if (sc&SCF_SHIFT) {119              if (sc&SCF_KEY_DESC)120                KeyDescSet("Dol /Default Color");121              else122                "$FG$";123            } else {124              if (sc&SCF_KEY_DESC)125                KeyDescSet("Dol /BLUE");126              else127                "$BLUE$";128            }129            return TRUE;130          case SC_F5:131            if (sc&SCF_KEY_DESC)132              KeyDescSet("Cmd /GodOffer");133            else134              GodOffer;135            return TRUE;136          case SC_F6:137            if (sc&SCF_SHIFT) {138              if (sc&SCF_KEY_DESC)139                KeyDescSet("Cmd /TOSIns");140              else141                TOSIns;142            } else {143              if (sc&SCF_KEY_DESC)144                KeyDescSet("Cmd /TimeIns");145              else146                TimeIns;147            }148            return TRUE;149          case SC_F7:150            if (sc&SCF_SHIFT) {151              if (sc&SCF_KEY_DESC)152                KeyDescSet("Cmd /NISTGodIns2");153              else154                NISTGodIns2;155            } else {156              if (sc&SCF_KEY_DESC)157                KeyDescSet("Cmd /GodIns");158              else159                GodIns;160            }161            return TRUE;162          case SC_F8:163            if (sc&SCF_SHIFT) {164              if (sc&SCF_KEY_DESC)165                KeyDescSet("Cmd /DirLinksIns");166              else167                DirLinksIns;168            } else {169              if (sc&SCF_KEY_DESC)170                KeyDescSet("Cmd /FileLinkIns");171              else172                FileLinkIns;173            }174            return TRUE;175        }176        break;177      case 'a':178        if (sc&SCF_KEY_DESC)179          KeyDescSet("Cmd /AutoComplete On");180        else181          AutoComplete(ON);182        return TRUE;183      case 'A':184        if (sc&SCF_KEY_DESC)185          KeyDescSet("Cmd /AutoComplete Off");186        else187          AutoComplete;188        return TRUE;189      case 'h':190        if (sc&SCF_KEY_DESC)191          KeyDescSet("Cmd /WinTileHorz");192        else193          WinTileHorz;194        return TRUE;195      case 'H':196        if (sc&SCF_KEY_DESC)197          KeyDescSet("Edit/Del Hidden Doc Entries");198        else199          DocHiddenDel;200        return TRUE;201      case 'm':202        if (sc&SCF_KEY_DESC)203          KeyDescSet("Cmd /WinMax");204        else {205          WinBorder;206          WinMax;207        }208        return TRUE;209      case 'v':210        if (sc&SCF_KEY_DESC)211          KeyDescSet("Cmd /WinTileVert");212        else213          WinTileVert;214        return TRUE;215      case 'V':216        if (sc&SCF_KEY_DESC)217          KeyDescSet("Cmd /FrameGrabberToggle");218        else219          FrameGrabberToggle;220        return TRUE;221      case 'l':222        if (sc&SCF_KEY_DESC)223          KeyDescSet("Edit/Put Link to Cur Pos on Clip");224        else {225          ClipDel;226          st1=FileNameAbs(BIBLE_FILENAME);227          st2=FileNameAbs(DocPut->filename.name);228          if (!StrCmp(st1,st2)) {229            Free(st1);230            st1=BibleLine2Verse(DocPut->cur_entry->y+1,',');231            DocPrint(sys_clip_doc,"$LK,\"BF:%s\"$",st1);232          } else233            DocPrint(sys_clip_doc,"$LK,\"FL:%s,%d\"$",234                  st2,DocPut->cur_entry->y+1);235          Free(st1);236          Free(st2);237        }238        return TRUE;239      case 'L':240        if (sc&SCF_KEY_DESC)241          KeyDescSet("Edit/Place Anchor, Put Link to Clip");242        else {243          i=RandU32;244          ClipDel;245          DocPrint(sys_clip_doc,"$LK,\"<TODO>\",A=\"FA:%s,ANC%d\"$",246                DocPut->filename.name,i);247          "$AN,\"<TODO>\",A=\"ANC%d\"$",i;248        }249        return TRUE;250 251        //Ins your own ALT-key plug-ins252      case '1':253        if (sc&SCF_KEY_DESC)254          KeyDescSet("Dol /pi");255        else256          'pi';257        return TRUE;258      case '2':259        if (sc&SCF_KEY_DESC)260          KeyDescSet("Dol /theta");261        else262          'theta';263        return TRUE;264      case '3':265        if (sc&SCF_KEY_DESC)266          KeyDescSet("Dol /phi");267        else268          'phi';269        return TRUE;270      case '4':271        if (sc&SCF_KEY_DESC)272          KeyDescSet("Dol /omega");273        else274          'omega';275        return TRUE;276      case '9':277        if (sc&SCF_KEY_DESC)278          KeyDescSet("Dol /Indent 5");279        else280          "$ID,5$";281        return TRUE;282      case '0':283        if (sc&SCF_KEY_DESC)284          KeyDescSet("Dol /Unindent 5");285        else286          "$ID,-5$";287        return TRUE;288      case 'b':289        if (sc&SCF_KEY_DESC)290          KeyDescSet("Cmd /Jump to Bad Code");291        else //::/Adam/God/HSNotes.DD292          GodCodeJmp;293        return TRUE;294      case 'g':295        if (sc&SCF_KEY_DESC)296          KeyDescSet("Edit/BlogScrnShot");297        else298          BlogScrnShot;299        return TRUE;300      case 'p':301        if (sc&SCF_KEY_DESC)302          KeyDescSet("Cmd /JukeBox(Home/Sup1Hymns)");303        else304          JukeBox("~/Sup1/Sup1Hymns");305        return TRUE;306    }307  }308  return FALSE;309}310 311Bool MyPutS(U8 *)312{313  return FALSE;314}315 316KeyDevAdd(&MyPutKey,&MyPutS,0x20000000,TRUE);317