Files
Shrine/Demo/AcctExample/HomeKeyPlugIns.HC
T
2018-09-08 21:47:50 +02:00

339 lines
6.9 KiB
HolyC

//Place this file in /Home and change
//anything you want.
U0 InsTime()
{
CDate cdt;
cdt=Now;
"$$IV,1$$----%D %T----$$IV,0$$\n",cdt,cdt;
}
U0 InsFileLink()
{
U8 *st=PopUpPickFile;
st[0]=':'; //This is my personal code, not production. LOL
"$$LK,\"%s\",A=\"FI:%s\"$$",st+2,st;
Free(st);
}
U0 InsDirLinks()
{
CDirEntry *tempde,*tempde1;
U8 *st=PopUpPickDir,*st2;
st[0]=':'; //This is my personal code, not production. LOL
st2=MStrPrint("%s/*",st);
tempde=tempde1=FilesFind(st2,FUF_JUST_FILES);
while (tempde) {
tempde->full_name[0]=':';
"$$LK,\"%s\",A=\"FI:%s\"$$\n",tempde->full_name+2,tempde->full_name;
tempde=tempde->next;
}
DirTreeDel(tempde1);
Free(st);
Free(st2);
}
U0 DocHiddenDel(CDoc *doc=NULL)
{
Bool unlock;
CDocEntry *doc_e,*doc_e1;
if (!doc) doc=DocPut;
if (doc) {
unlock=DocLock(doc);
DocRecalc(doc);
doc_e=doc->head.next;
while (doc_e!=doc) {
doc_e1=doc_e->next;
if (doc_e->de_flags&(DOCEF_FILTER_SKIP|DOCEF_SKIP))
DocEntryDel(doc,doc_e);
doc_e=doc_e1;
}
DocRecalc(doc);
if (unlock)
DocUnlock(doc);
}
}
Bool MyPutKey(I64 ch,I64 sc)
{//ch=ASCII; sc=scan_code
//See $LK,"Char",A="HI:Char"$ for definition of scan codes.
//See $LK,"Key Allocations",A="FI:::/Doc/KeyAlloc.DD"$.
//See $LK,"Keyboard Devices",A="HI:Keyboard Devices/System"$.
//You can customize keys. This routine
//is called before the main editor
//key handler $LK,"DocPutKey",A="MN:DocPutKey"$().
//You can intercept any key.
//Return TRUE if you completely
//handled the key.
I64 i;
U8 *st1,*st2;
if (sc&SCF_ALT && !(sc&SCF_CTRL)) {
switch (ch) {
case 0:
switch (sc.u8[0]) {
case SC_F1:
if (sc&SCF_SHIFT) {
if (sc&SCF_KEY_DESC)
KeyDescSet("Dol /LTPURPLE");
else
"$$LTPURPLE$$";
} else {
if (sc&SCF_KEY_DESC)
KeyDescSet("Dol /PURPLE");
else
"$$PURPLE$$";
}
return TRUE;
case SC_F2:
if (sc&SCF_SHIFT) {
if (sc&SCF_KEY_DESC)
KeyDescSet("Dol /LTRED");
else
"$$LTRED$$";
} else {
if (sc&SCF_KEY_DESC)
KeyDescSet("Dol /RED");
else
"$$RED$$";
}
return TRUE;
case SC_F3:
if (sc&SCF_SHIFT) {
if (sc&SCF_KEY_DESC)
KeyDescSet("Dol /LTGREEN");
else
"$$LTGREEN$$";
} else {
if (sc&SCF_KEY_DESC)
KeyDescSet("Dol /GREEN");
else
"$$GREEN$$";
}
return TRUE;
case SC_F4:
if (sc&SCF_SHIFT) {
if (sc&SCF_KEY_DESC)
KeyDescSet("Dol /Default Color");
else
"$$FG$$";
} else {
if (sc&SCF_KEY_DESC)
KeyDescSet("Dol /BLUE");
else
"$$BLUE$$";
}
return TRUE;
case SC_F5:
if (sc&SCF_SHIFT) {
if (sc&SCF_KEY_DESC)
KeyDescSet("Edit/Collaborative Fiction");
else
"---- $TX,"Collaborative Fiction",HTML="http://en.wikipedia.org/wiki/Collaborative_fiction"$ ----\n"
"Once upon a time ";
} else {
if (sc&SCF_KEY_DESC)
KeyDescSet("Edit/Moses Comic");
else
"---- Moses Comic ---- "
"(Set in the $TX,"Numbers 11",HTML="http://www.biblegateway.com/passage/?search=Numbers%%%%2011&version=NIV"$ "
"part of the story.)\n"
"Moses says, \"\"\n"
"God says, \"\"\n";
}
return TRUE;
case SC_F6:
if (sc&SCF_SHIFT) {
if (sc&SCF_KEY_DESC)
KeyDescSet("Cmd /Ins Misc");
else
TOSInsMisc;
} else {
if (sc&SCF_KEY_DESC)
KeyDescSet("Cmd /Ins Datetime");
else
InsTime;
}
return TRUE;
case SC_F7:
if (sc&SCF_SHIFT) {
if (sc&SCF_KEY_DESC)
KeyDescSet("Cmd /God Misc");
else
GodMisc;
} else {
if (sc&SCF_KEY_DESC)
KeyDescSet("Cmd /God Doodle File");
else {
st1=PopUpPickFile;
st2=FileRead(st1);
GodDoodle(st2);
Free(st2);
Free(st1);
}
}
return TRUE;
case SC_F8:
if (sc&SCF_SHIFT) {
if (sc&SCF_KEY_DESC)
KeyDescSet("Cmd /Ins Dir Links");
else
InsDirLinks;
} else {
if (sc&SCF_KEY_DESC)
KeyDescSet("Cmd /Ins File Link");
else
InsFileLink;
}
return TRUE;
}
break;
case 'a':
if (sc&SCF_KEY_DESC)
KeyDescSet("Cmd /AutoComplete On");
else
AutoComplete(ON);
return TRUE;
case 'A':
if (sc&SCF_KEY_DESC)
KeyDescSet("Cmd /AutoComplete Off");
else
AutoComplete;
return TRUE;
case 'h':
if (sc&SCF_KEY_DESC)
KeyDescSet("Cmd /Tile Horizontally");
else
WinTileHorz;
return TRUE;
case 'H':
if (sc&SCF_KEY_DESC)
KeyDescSet("Edit/Del Hidden Doc Entries");
else
DocHiddenDel;
return TRUE;
case 'm':
if (sc&SCF_KEY_DESC)
KeyDescSet("Cmd /Maximize");
else {
WinBorder;
WinMax;
}
return TRUE;
case 'v':
if (sc&SCF_KEY_DESC)
KeyDescSet("Cmd /Tile Vertically");
else
WinTileVert;
return TRUE;
case 'V':
if (sc&SCF_KEY_DESC)
KeyDescSet("Cmd /Frame Grabber Toggle");
else
FrameGrabberToggle;
return TRUE;
case 'l':
if (sc&SCF_KEY_DESC)
KeyDescSet("Edit/Put Link to Cur Pos on Clipboard");
else {
ClipboardDel;
st1=FileNameAbs(BIBLE_FILENAME);
st2=FileNameAbs(DocPut->filename.name);
if (!StrCmp(st1,st2)) {
Free(st1);
st1=BibleLine2Verse(DocPut->cur_entry->y+1,',');
DocPrint(sys_clipboard_doc,"$$LK,\"BF:%s\"$$",st1);
} else
DocPrint(sys_clipboard_doc,"$$LK,\"FL:%s,%d\"$$",
st2,DocPut->cur_entry->y+1);
Free(st1);
Free(st2);
}
return TRUE;
case 'L':
if (sc&SCF_KEY_DESC)
KeyDescSet("Edit/Place Anchor, Put Link to Clipboard");
else {
i=RandU32;
ClipboardDel;
DocPrint(sys_clipboard_doc,"$$LK,\"<TODO>\",A=\"FA:%s,ANC%d\"$$",
DocPut->filename.name,i);
"$$AN,\"<TODO>\",A=\"ANC%d\"$$",i;
}
return TRUE;
//Ins your own ALT-key plug-ins
case '1':
if (sc&SCF_KEY_DESC)
KeyDescSet("Dol /ã");
else
'ã';
return TRUE;
case '2':
if (sc&SCF_KEY_DESC)
KeyDescSet("Dol /é");
else
'é';
return TRUE;
case '3':
if (sc&SCF_KEY_DESC)
KeyDescSet("Dol /è");
else
'è';
return TRUE;
case '4':
if (sc&SCF_KEY_DESC)
KeyDescSet("Dol /ê");
else
'ê';
return TRUE;
case '9':
if (sc&SCF_KEY_DESC)
KeyDescSet("Dol /Indent 5");
else
"$$ID,5$$";
return TRUE;
case '0':
if (sc&SCF_KEY_DESC)
KeyDescSet("Dol /Unindent 5");
else
"$$ID,-5$$";
return TRUE;
case 'b':
if (sc&SCF_KEY_DESC)
KeyDescSet("Cmd /Jump to Bad Code");
else //$LK,"::/Adam/God/HSNotes.DD"$
GodCodeJmp;
return TRUE;
case 'g':
if (sc&SCF_KEY_DESC)
KeyDescSet("Edit/BlogScreenShot");
else
BlogScreenShot;
return TRUE;
case 'p':
if (sc&SCF_KEY_DESC)
KeyDescSet("Cmd /JukeBox(Home/Sup1)");
else
JukeBox("~/Sup1/Sup1Psalmody");
return TRUE;
case 'P':
if (sc&SCF_KEY_DESC)
KeyDescSet("Cmd /JukeBox(Examples)");
else
JukeBox("::/Apps/Psalmody/Examples");
return TRUE;
}
}
return FALSE;
}
Bool MyPutS(U8 *)
{
return FALSE;
}
KeyDevAdd(&MyPutKey,&MyPutS,0x20000000,TRUE);