Skip to content

Commit c27399b

Browse files
authored
Occlusion editing + Remap Set Hook + Minor fix
1 parent 34ab375 commit c27399b

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

supermemo.ahk

+47-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ global OcclusionImageNamePattern := "__Occlusion: {1} {2}" ; {1} Original ima
1616
; RegEx
1717
; REC: RegEx Capture
1818
; RER: RegEx Replace
19-
global REC_Occlusion_Element := "UOsm)^Begin Element #(?P<Id>[\d]+).*^Title=(?P<Title>[^\n\r]+)$.*^ImageName=(?P<ImageName>[^\n\r]+)$[\r\n]+^ImageFile=(?P<ImageFile>[^\n\r]+)$"
19+
global REC_Occlusion_Generic_Element := "UOsm)^Begin Element #(?P<Id>[\d]+).*^Title=(?P<Title>[^\n\r]+)$.*^ImageName=(?P<ImageName>[^\n\r]+)$[\r\n]+^ImageFile=(?P<ImageFile>[^\n\r]+)$"
20+
global REC_Occlusion_Self_Element := "Osm).*^ImageFile=(?P<BackgroundImageFile>[^\n\r]+)$.*^ImageFile=(?P<OcclusionImageFile>[^\n\r]+)$"
2021
global RER_Element_Generic := "=[^\n\r]+"
2122
global RER_Element_ComponentsAndRepHistory := "sm)^Begin Component #.*End RepHist #[\d]+$"
2223

@@ -284,11 +285,18 @@ SetHook()
284285

285286
OcclusionParseParentElement(element)
286287
{
287-
RegExMatch(element, REC_Occlusion_Element, outMatch)
288+
RegExMatch(element, REC_Occlusion_Generic_Element, outMatch)
288289

289290
return outMatch.Count() == 4 ? outMatch : false
290291
}
291292

293+
OcclusionParseSelfElement(element)
294+
{
295+
RegExMatch(element, REC_Occlusion_Self_Element, outMatch)
296+
297+
return outMatch.Count() == 2 ? outMatch : false
298+
}
299+
292300
OcclusionParseOcclusionFile(element)
293301
{
294302
StringGetPos, startPos, element, ImageFile, L2
@@ -413,6 +421,11 @@ OcclusionCreateAndEdit(parentElement, parentId, parentTitle, parentImageName, pa
413421
return true
414422
}
415423

424+
OcclusionEdit(backgroundImageFile, occlusionImageFile)
425+
{
426+
Run, %ImageEditorBin% %backgroundImageFile% %occlusionImageFile%
427+
}
428+
416429

417430

418431
; Macros
@@ -435,7 +448,7 @@ OcclusionCreateAndEdit(parentElement, parentId, parentTitle, parentImageName, pa
435448
{
436449
ShowWarning("Element information could not be parsed.")
437450

438-
elemMatch :=
451+
parentElement :=
439452

440453
return
441454
}
@@ -449,6 +462,35 @@ OcclusionCreateAndEdit(parentElement, parentId, parentTitle, parentImageName, pa
449462
Return
450463

451464

465+
; Edit Image Occlusion From Displayed Element (Ctrl+Win+e)
466+
#^e::
467+
ClipboardSave()
468+
469+
parentElement := CopyElement()
470+
471+
if (!parentElement)
472+
return
473+
474+
elemMatch := OcclusionParseSelfElement(parentElement)
475+
476+
if (!elemMatch)
477+
{
478+
ShowWarning("Element information could not be parsed.")
479+
480+
parentElement :=
481+
482+
return
483+
}
484+
485+
OcclusionEdit(elemMatch.BackgroundImageFile, elemMatch.OcclusionImageFile)
486+
487+
elemMatch :=
488+
parentElement :=
489+
490+
ClipboardRestore()
491+
Return
492+
493+
452494
; Compress Image (Ctrl+Win+c)
453495
#^c::
454496
CompressImage()
@@ -461,8 +503,8 @@ Return
461503
Return
462504

463505

464-
; Set Hook (Ctrl+Win+&)
465-
#^&::
506+
; Set Hook (Ctrl+Win+h)
507+
#^h::
466508
SetHook()
467509
Return
468510

0 commit comments

Comments
 (0)