File size: 7,795 Bytes
806d4b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317

//Place this file in /Home and change
//anything you want.

U0 TimeIns()
{
  CDate cdt;
  cdt=Now;
  "$IV,1$----%D %T----$IV,0$\n",cdt,cdt;
}

U0 FileLinkIns()
{
  U8 *st=PopUpPickFile;
  st[0]=':';  //This is my personal code, not production. LOL
  "$LK,\"%s\",A=\"FI:%s\"$",st+2,st;
  Free(st);
}

U0 DirLinksIns()
{
  CDirEntry *tmpde,*tmpde1;
  U8 *st=PopUpPickDir,*st2;
  st[0]=':';  //This is my personal code, not production. LOL
  st2=MStrPrint("%s/*",st);
  tmpde=tmpde1=FilesFind(st2,FUF_JUST_FILES);
  while (tmpde) {
    tmpde->full_name[0]=':';
    "$LK,\"%s\",A=\"FI:%s\"$\n",tmpde->full_name+2,tmpde->full_name;
    tmpde=tmpde->next;
  }
  DirTreeDel(tmpde1);
  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 Char for definition of scan codes.
  //See Key Allocations.
  //See Keyboard Devices.

  //You can customize keys.  This routine
  //is called before the main editor
  //key hndlr 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_KEY_DESC)
              KeyDescSet("Cmd /GodOffer");
            else
              GodOffer;
            return TRUE;
          case SC_F6:
            if (sc&SCF_SHIFT) {
              if (sc&SCF_KEY_DESC)
                KeyDescSet("Cmd /TOSIns");
              else
                TOSIns;
            } else {
              if (sc&SCF_KEY_DESC)
                KeyDescSet("Cmd /TimeIns");
              else
                TimeIns;
            }
            return TRUE;
          case SC_F7:
            if (sc&SCF_SHIFT) {
              if (sc&SCF_KEY_DESC)
                KeyDescSet("Cmd /NISTGodIns2");
              else
                NISTGodIns2;
            } else {
              if (sc&SCF_KEY_DESC)
                KeyDescSet("Cmd /GodIns");
              else
                GodIns;
            }
            return TRUE;
          case SC_F8:
            if (sc&SCF_SHIFT) {
              if (sc&SCF_KEY_DESC)
                KeyDescSet("Cmd /DirLinksIns");
              else
                DirLinksIns;
            } else {
              if (sc&SCF_KEY_DESC)
                KeyDescSet("Cmd /FileLinkIns");
              else
                FileLinkIns;
            }
            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 /WinTileHorz");
        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 /WinMax");
        else {
          WinBorder;
          WinMax;
        }
        return TRUE;
      case 'v':
        if (sc&SCF_KEY_DESC)
          KeyDescSet("Cmd /WinTileVert");
        else
          WinTileVert;
        return TRUE;
      case 'V':
        if (sc&SCF_KEY_DESC)
          KeyDescSet("Cmd /FrameGrabberToggle");
        else
          FrameGrabberToggle;
        return TRUE;
      case 'l':
        if (sc&SCF_KEY_DESC)
          KeyDescSet("Edit/Put Link to Cur Pos on Clip");
        else {
          ClipDel;
          st1=FileNameAbs(BIBLE_FILENAME);
          st2=FileNameAbs(DocPut->filename.name);
          if (!StrCmp(st1,st2)) {
            Free(st1);
            st1=BibleLine2Verse(DocPut->cur_entry->y+1,',');
            DocPrint(sys_clip_doc,"$LK,\"BF:%s\"$",st1);
          } else
            DocPrint(sys_clip_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 Clip");
        else {
          i=RandU32;
          ClipDel;
          DocPrint(sys_clip_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 /pi");
        else
          'pi';
        return TRUE;
      case '2':
        if (sc&SCF_KEY_DESC)
          KeyDescSet("Dol /theta");
        else
          'theta';
        return TRUE;
      case '3':
        if (sc&SCF_KEY_DESC)
          KeyDescSet("Dol /phi");
        else
          'phi';
        return TRUE;
      case '4':
        if (sc&SCF_KEY_DESC)
          KeyDescSet("Dol /omega");
        else
          'omega';
        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 //::/Adam/God/HSNotes.DD
          GodCodeJmp;
        return TRUE;
      case 'g':
        if (sc&SCF_KEY_DESC)
          KeyDescSet("Edit/BlogScrnShot");
        else
          BlogScrnShot;
        return TRUE;
      case 'p':
        if (sc&SCF_KEY_DESC)
          KeyDescSet("Cmd /JukeBox(Home/Sup1Hymns)");
        else
          JukeBox("~/Sup1/Sup1Hymns");
        return TRUE;
    }
  }
  return FALSE;
}

Bool MyPutS(U8 *)
{
  return FALSE;
}

KeyDevAdd(&MyPutKey,&MyPutS,0x20000000,TRUE);