Skip to content

Commit

Permalink
Occlusion editing + Remap Set Hook + Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alexis- authored May 2, 2018
1 parent 34ab375 commit c27399b
Showing 1 changed file with 47 additions and 5 deletions.
52 changes: 47 additions & 5 deletions supermemo.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ global OcclusionImageNamePattern := "__Occlusion: {1} {2}" ; {1} Original ima
; RegEx
; REC: RegEx Capture
; RER: RegEx Replace
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]+)$"
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]+)$"
global REC_Occlusion_Self_Element := "Osm).*^ImageFile=(?P<BackgroundImageFile>[^\n\r]+)$.*^ImageFile=(?P<OcclusionImageFile>[^\n\r]+)$"
global RER_Element_Generic := "=[^\n\r]+"
global RER_Element_ComponentsAndRepHistory := "sm)^Begin Component #.*End RepHist #[\d]+$"

Expand Down Expand Up @@ -284,11 +285,18 @@ SetHook()

OcclusionParseParentElement(element)
{
RegExMatch(element, REC_Occlusion_Element, outMatch)
RegExMatch(element, REC_Occlusion_Generic_Element, outMatch)

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

OcclusionParseSelfElement(element)
{
RegExMatch(element, REC_Occlusion_Self_Element, outMatch)

return outMatch.Count() == 2 ? outMatch : false
}

OcclusionParseOcclusionFile(element)
{
StringGetPos, startPos, element, ImageFile, L2
Expand Down Expand Up @@ -413,6 +421,11 @@ OcclusionCreateAndEdit(parentElement, parentId, parentTitle, parentImageName, pa
return true
}

OcclusionEdit(backgroundImageFile, occlusionImageFile)
{
Run, %ImageEditorBin% %backgroundImageFile% %occlusionImageFile%
}



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

elemMatch :=
parentElement :=

return
}
Expand All @@ -449,6 +462,35 @@ OcclusionCreateAndEdit(parentElement, parentId, parentTitle, parentImageName, pa
Return


; Edit Image Occlusion From Displayed Element (Ctrl+Win+e)
#^e::
ClipboardSave()

parentElement := CopyElement()

if (!parentElement)
return

elemMatch := OcclusionParseSelfElement(parentElement)

if (!elemMatch)
{
ShowWarning("Element information could not be parsed.")

parentElement :=

return
}

OcclusionEdit(elemMatch.BackgroundImageFile, elemMatch.OcclusionImageFile)

elemMatch :=
parentElement :=

ClipboardRestore()
Return


; Compress Image (Ctrl+Win+c)
#^c::
CompressImage()
Expand All @@ -461,8 +503,8 @@ Return
Return


; Set Hook (Ctrl+Win+&)
#^&::
; Set Hook (Ctrl+Win+h)
#^h::
SetHook()
Return

Expand Down

0 comments on commit c27399b

Please sign in to comment.