From b5657d035e31acd60877e8330ee43c3430c0e8a7 Mon Sep 17 00:00:00 2001 From: Kamikaze Date: Wed, 16 Dec 2020 20:14:10 -0500 Subject: [PATCH] [Fix] More improvements to SVG import --- LEEME.md | 4 +- README.md | 4 +- .../api.lcdoc | 0 .../frlDragDropFilesIntoIDE.livecodescript | 614 ------------------ .../manifest.xml | 8 - frlDragDropFilesIntoIDE.livecodescript | 136 ++-- 6 files changed, 79 insertions(+), 687 deletions(-) delete mode 100644 com.ferruslogic.library.dragDropFilesIntoIDE/api.lcdoc delete mode 100644 com.ferruslogic.library.dragDropFilesIntoIDE/frlDragDropFilesIntoIDE.livecodescript delete mode 100644 com.ferruslogic.library.dragDropFilesIntoIDE/manifest.xml diff --git a/LEEME.md b/LEEME.md index bb0aeb1..7f129d1 100644 --- a/LEEME.md +++ b/LEEME.md @@ -20,13 +20,13 @@ frlDragDropFilesIntoIDE se distribuye bajo la [licencia MIT](LICENSE). -## Versión actual: 1.0.5 +## Versión actual: 1.0.6 ## Instalación -Para instalar el plugin use la stack **startup** que está en este repositorio. La misma copiará la extensión a su carpeta de extensiones de LiveCode. +Para instalar el plugin use la stack **dragdropFilesIntoIDEInstaller.livecode**. La misma copiará la extensión a su carpeta de extensiones de LiveCode. ## Archivos soportados diff --git a/README.md b/README.md index 87b7571..2be142c 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,13 @@ frlDragDropFilesIntoIDE is distributed under the [MIT license](LICENSE). -## Current version: 1.0.5 +## Current version: 1.0.6 ## Installation -To install the plugin use the **startup** stack that is in this repository. It will copy the extension to your LiveCode extensions folder. +To install the plugin use the **dragdropFilesIntoIDEInstaller.livecode** stack. It will copy the extension to your LiveCode extensions folder. ## Supported files diff --git a/com.ferruslogic.library.dragDropFilesIntoIDE/api.lcdoc b/com.ferruslogic.library.dragDropFilesIntoIDE/api.lcdoc deleted file mode 100644 index e69de29..0000000 diff --git a/com.ferruslogic.library.dragDropFilesIntoIDE/frlDragDropFilesIntoIDE.livecodescript b/com.ferruslogic.library.dragDropFilesIntoIDE/frlDragDropFilesIntoIDE.livecodescript deleted file mode 100644 index 6382901..0000000 --- a/com.ferruslogic.library.dragDropFilesIntoIDE/frlDragDropFilesIntoIDE.livecodescript +++ /dev/null @@ -1,614 +0,0 @@ -script "com.ferruslogic.library.dragDropFilesIntoIDE" -/* -Copyright (c) 2020 FerrusLogic - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files the frlDragDropFilesIntoIDE, to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -Summary -This small library is to aid in the application creation process by -allowing you to drag files into the development IDE. So it only runs -in development mode for the time being. - -version 1.0.4 -Made: 2020-07-09 15:20 -Last Update: 2020-12-04 12:15 -*/ - -# list of files being dragged. -local sFiles - -# The stack that is on top. -local sTopStack - -# Graph that is dynamically created in the background for the DragDrop event to be sent. -local sLongIdBackGraphic - -# The object that is the object and its type. -local sDragDestination, sTypeDragDestination - -# The last control that was imported. It is to select it at the end of everything. -local sLastControl - -# Whether to import into the dragDestination or create a new object. -local sReplace - -constant kBynaryStack = "livecode,rev,mc" -constant kScriptOnlyStack = "livecodescript" -constant kAudio = "mp3,mp4,mpg,mov,avi,m4a,midi,midi,snd,aac,wma,ogg,mpeg,m2v,mpeg2,qt,ram,rm" -constant kImage = "svg,png,jpeg,jpg,gif,bmp,pbm,pgm,ppm,xbm,xpm,xwd,pict,webp,jfif,tif,tiff,dib,vga,pict,pict2,pic" -constant kTextPlan = "json,html,htm,txt,lng,locale,log,mnu,nfo,inf,ini,inc,bar,cfg,sav,conf,manifest,lst,ion,rc,properties,mf,list,wbt,lic,css,hs,iss,js,nsi,nsh,java,php,php3,php4,php5,tct,xml,xsml,xsl,kml,adr,sfx,,sh,bsh,lua,pl,pm,py,as,las,mx,vb,f,for,f90,f95,f2k,tex,mak,tpl,asm,plx,lsp,lisp,scm,smd,ss,kix,au3,ml,mli,sml,thy,ada,ads,adb,v,lhs,cmake,twig,yml" - - -on extensionInitialize - if the target is not me then - pass extensionInitialize - end if - - if the environment is "development" then - insert the script of me into front - set the _ideoverride of me to true - end if -end extensionInitialize - -on extensionFinalize - if the target is not me then - pass extensionFinalize - end if - - remove the script of me from front -end extensionFinalize - -on dragEnter - if the dragData["files"] is not empty then _acceptDrop - pass dragEnter -end dragEnter - -on dragMove - if the dragData["files"] is not empty then _acceptDrop - pass dragMove -end dragMove - - -on dragLeave - if within(stack sTopStack, globalLoc(the mouseLoc)) is false then - _deleteBackgroundGraphic - end if - pass dragLeave -end dragLeave - - -local sMouseLoc -on dragDrop - - _deleteBackgroundGraphic - - if sFiles is empty then pass dragDrop - - put (the mouseLoc) into sMouseLoc - - put the optionKey is down and the shiftKey is down and the number of lines of sFiles is 1 into sReplace - - if sFiles is not empty then - lock screen; lock messages;lock cursor - - set the cursor to watch - - repeat for each line tFile in sFiles - _importFile tFile - end repeat - - unlock messages - - choose pointer tool - - if there is a sLastControl then - focus on nothing - select empty - select sLastControl - end if - - unlock screen; unlock messages;unlock cursor - exit dragDrop - end if - - pass dragDrop -end dragDrop - - -# remove data being dragged. -on dragEnd - _deleteBackgroundGraphic - pass dragEnd -end dragEnd - - - -private command _acceptDrop - - _setDefaultStack - - - put the dragData["files"] into sFiles - - - if sFiles is empty then exit _acceptDrop - - if the mouse is down and sFiles is not empty and there is not graphic "frlDragDropBack" of this cd of stack sTopStack then - - # I create this graph because the drag & drop message is not generated on the card - create invisible graphic "frlDragDropBack" in this cd - put it into sLongIdBackGraphic - - set the rect of sLongIdBackGraphic to the rect of this cd of stack sTopStack - - try - set the opaque of sLongIdBackGraphic to true - set the blendlevel of sLongIdBackGraphic to 7 - set the layer of sLongIdBackGraphic to bottom - set the lineSize of sLongIdBackGraphic to 0 - set the backColor of sLongIdBackGraphic to "YellowGreen" - set the visible of sLongIdBackGraphic to true - end try - - put empty into sDragDestination - put empty into sTypeDragDestination - put empty into sReplace - - end if - - - if _filesTypeDragDrop(sFiles) is true then - set the dragAction to "copy" - else - set the dragAction to "none" - end if - -end _acceptDrop - - -private command _importFile pFilePath - local tExtencion - - set the itemdel to "." - - put _DragDestination() into sDragDestination - _deleteBackgroundGraphic - - put word 1 of sDragDestination into sTypeDragDestination - put item - 1 of pFilePath into tExtencion - - set the itemdel to comma - - if there is a file pFilePath then - switch - - case tExtencion is "svg" - _importPathSVG pFilePath - break - - # LiveCode, Revolution and MetaCard binary stack files - case tExtencion is among the items of kBynaryStack - open stack pFilePath - break - - # Script-only stack - case tExtencion is kScriptOnlyStack - edit the script of stack pFilePath - break - - # Images file - case tExtencion is among the items of kImage - _importImage pFilePath, "file" - break - - # Audio and Videos file - case tExtencion is among the items of kAudio - _importPlayer pFilePath - break - - # Text Plan - case tExtencion is among the items of kTextPlan - _importTextPlan pFilePath - break - - end switch - - end if -end _importFile - - -private command _importImage pPathOrData, pType - local tNameFile, tImageData, tNewImage - - set the itemdel to slash - - _setDefaultStack - - if there is a stack sTopStack then - - if pType is "file" then - - if there is a sDragDestination and sTypeDragDestination is "image" and sReplace is true then - - if the filename of sDragDestination is empty then - set the text of sDragDestination to URL ("binfile:" & pPathOrData) - else - set the filename of sDragDestination to _convertPathToRelativePath(pPathOrData) - end if - - put sDragDestination into sLastControl - - exit _importImage - end if - - set the text of templateImage to URL ("binfile:" & pPathOrData) - - put item - 1 of pPathOrData into tNameFile - - create image tNameFile in this cd - put it into tNewImage - - if the text of tNewImage is empty then - set the filename of tNewImage to _convertPathToRelativePath(pPathOrData) - end if - - if there is tNewImage then - - _scaleImage tNewImage - - if sMouseLoc is within the rect of card 1 of stack sTopStack then - set the loc of tNewImage to sMouseLoc - else - set the loc of tNewImage to (the loc of cd 1 of stack sTopStack) - end if - - - put tNewImage into sLastControl - end if - - reset templateImage - - else - local tOldText, tNewText - put drawingSvgCompileFile(pPathOrData) into tNewText - - if there is a sDragDestination and sTypeDragDestination is "image" then - put the text of sDragDestination into tOldText - - set the text of sDragDestination to tNewText - - if the text of sDragDestination is empty then - set the text of sDragDestination to tOldText - end if - - else - put the mouseLoc into sMouseLoc - set the text of templateImage to tNewText - - put item - 1 of pPathOrData into tNameFile - create image tNameFile in this cd - put it into tNewImage - - - if there is tNewImage then - _scaleImage tNewImage - - if sMouseLoc is within the rect of card 1 of stack sTopStack then - set the loc of tNewImage to sMouseLoc - else - set the loc of tNewImage to (the loc of cd 1 of stack sTopStack) - end if - - - put tNewImage into sLastControl - end if - - reset templateImage - end if - end if - end if - -end _importImage - - -private command _importPlayer pPathOrData - local tNameFile, tNumPlayer - set the itemdel to slash - - _setDefaultStack - - if there is a stack sTopStack then - - if there is a sDragDestination and sTypeDragDestination is "player" and sReplace is true then - - set the filename of sDragDestination to _convertPathToRelativePath(pPathOrData) - put sDragDestination into sLastControl - else - local tNewPlayer - - set the filename of templatePlayer to _convertPathToRelativePath(pPathOrData) - set the showController of templatePlayer to true - - put item - 1 of pPathOrData into tNameFile - create player tNameFile in this cd - put it into tNewPlayer - - if sMouseLoc is within the rect of card 1 of stack sTopStack then - set the loc of tNewPlayer to sMouseLoc - else - set the loc of tNewPlayer to (the loc of cd 1 of stack sTopStack) - end if - - put tNewPlayer into sLastControl - end if - - reset templatePlayer - end if - -end _importPlayer - - -private command _importPathSVG pFilePath - local tNewWidget, tPathSVG - - set the itemdel to slash - - _setDefaultStack - - put _getPathSVG(pFilePath) into tPathSVG - - if there is a stack sTopStack then - if tPathSVG is not empty then - - local tKind - try - put the kind of sDragDestination into tKind - end try - - if there is a sDragDestination and sTypeDragDestination is "widget" and tKind is "com.livecode.widget.svgpath" and sReplace is true then - - set the iconPath of sDragDestination to tPathSVG - - put sDragDestination into sLastControl - else - - - create widget as "com.livecode.widget.svgpath" in this cd - put it into tNewWidget - - set the iconPath of tNewWidget to tPathSVG - set the width of tNewWidget to 180 - set the height of tNewWidget to 180 - - if sMouseLoc is within the rect of card 1 of stack sTopStack then - set the loc of tNewWidget to sMouseLoc - else - set the loc of tNewWidget to (the loc of cd 1 of stack sTopStack) - end if - - put tNewWidget into sLastControl - end if - else - _importImage pFilePath, "SVG_Data" - end if - end if -end _importPathSVG - - -command _importTextPlan pFilePath - local tText - - _setDefaultStack - - if there is a stack sTopStack then - put URL("file:" & pFilePath) into tText - - if there is a sDragDestination and sTypeDragDestination is "field" and sReplace is true then - set the text of sDragDestination to tText - - else - create field - put it into sLastControl - set the text of sLastControl to tText - set the locktext of sLastControl to true - - if sMouseLoc is within the rect of card 1 of stack sTopStack then - set the loc of sLastControl to sMouseLoc - else - set the loc of sLastControl to (the loc of cd 1 of stack sTopStack) - end if - end if - end if - -end _importTextPlan - - -private command _setDefaultStack - - put the short name of the topstack into sTopStack - set the defaultStack to sTopStack -end _setDefaultStack - - -private function _DragDestination - local tStack, tDragDestination - - _setDefaultStack - - put the dragDestination into tDragDestination - - if there is a stack sTopStack then - - if there is tDragDestination then - put the long id of tDragDestination into tDragDestination - - put _meOwnerStack(tDragDestination) into tStack - - if there is a tDragDestination and tStack is the long name stack sTopStack then - return tDragDestination - end if - - end if - - return the long id of this cd - end if -end _DragDestination - - -private function _meOwnerStack pLongIdControl - local tOffset, tLongStack, tDragDestination - - put the long id of pLongIdControl into tDragDestination - - put wordOffset("stack",tDragDestination) into tOffset - put word tOffset to -1 of tDragDestination into tLongStack - - return tLongStack -end _meOwnerStack - - -private command _deleteBackgroundGraphic - - if sLongIdBackGraphic is not empty and there is sLongIdBackGraphic then - delete sLongIdBackGraphic - delete variable sLongIdBackGraphic - end if - -end _deleteBackgroundGraphic - - -private function _convertPathToRelativePath pPath - local tStackPath - - set the itemdel to slash - - if there is not a stack sTopStack then return pPath - - put item 1 to - 2 of the effective filename of stack sTopStack into tStackPath - if there is not a folder tStackPath then return pPath - - replace backslash with slash in pPath - replace tStackPath & slash with empty in pPath - - return pPath -end _convertPathToRelativePath - - -private function _getPathSVG pFilePath - local tSVG, tPathOpen , tOpen = 0, tClose, tSVGPath, tNumChars, tNewPath - set the itemdel to quote - - if there is a file pFilePath then - - put URL("file:" & pFilePath ) into tSVG - - put length(tSVG) into tNumChars - - repeat for tNumChars - put offset("path", tSVG, tPathOpen) into tOpen - - if tOpen is 0 then exit repeat - if tNumChars <= tOpen then exit repeat - put tOpen + tPathOpen into tPathOpen - - if the char(tPathOpen - 1) of tSVG is not "<" and char (tPathOpen - 1) of tSVG is not space then - put tPathOpen + 3 into tPathOpen - next repeat - end if - - put offset("d=" & quote, tSVG, tPathOpen) into tOpen - if tOpen is 0 then exit repeat - put tOpen + tPathOpen + 3 into tOpen - - put offset(quote, tSVG, tOpen) into tClose - if tClose is 0 then exit repeat - put tOpen + tClose into tClose - - put char tOpen to (tClose - 1) of tSVG into tNewPath - add 1 to tClose - put tClose into tPathOpen - - get (the item 1 to 2 of ( the char tClose to - 1 of tSVG)) - - if the trueWord 1 of it is "fill" and the trueWord -1 of it is "none" then - next repeat - end if - - put tNewPath && cr after tSVGPath - - end repeat - end if - - create widget as "com.livecode.widget.svgpath" - put it into tWidget - - local tOutPathSVG = "" - try - set the iconPath of tWidget to tSVGPath - put tSVGPath into tOutPathSVG - end try - - delete tWidget - - return tOutPathSVG -end _getPathSVG - - -private function _filesTypeDragDrop pFiles - local tResult, tExtension - put false into tResult - - repeat for each line tFile in pFiles - - set the itemdel to "." - put item - 1 of tFile into tExtension - - set the itemdel to comma - - if tExtension is among the items of (kBynaryStack,kScriptOnlyStack,kAudio,kImage,kTextPlan) then - put true into tResult - exit repeat - end if - end repeat - - return tResult -end _filesTypeDragDrop - - -private command _scaleImage pLongId - local tFormattedWidth, tFormattedHeight, tWidthCard, tHeightCard, tAspectRatio - - _setDefaultStack - - put the formattedWidth of pLongId into tFormattedWidth - put the formattedHeight of pLongId into tFormattedHeight - - put the width of this card into tWidthCard - put the height of this card into tHeightCard - - if tFormattedWidth is 0 or tFormattedHeight is 0 or (tFormattedWidth < tWidthCard and tFormattedHeight < tHeightCard) then - exit _scaleImage - end if - - put min(tWidthCard/tFormattedWidth, tHeightCard/tFormattedHeight) into tAspectRatio - - set the width of pLongId to tFormattedWidth * tAspectRatio - set the height of pLongId to tFormattedHeight * tAspectRatio -end _scaleImage - diff --git a/com.ferruslogic.library.dragDropFilesIntoIDE/manifest.xml b/com.ferruslogic.library.dragDropFilesIntoIDE/manifest.xml deleted file mode 100644 index b6bdd08..0000000 --- a/com.ferruslogic.library.dragDropFilesIntoIDE/manifest.xml +++ /dev/null @@ -1,8 +0,0 @@ - - com.ferruslogic.library.dragDropFilesIntoIDE - Drag Drop Files into IDE - FerrusLogic - 1.0.1 - library - community - diff --git a/frlDragDropFilesIntoIDE.livecodescript b/frlDragDropFilesIntoIDE.livecodescript index a1ed3f9..6ab3772 100644 --- a/frlDragDropFilesIntoIDE.livecodescript +++ b/frlDragDropFilesIntoIDE.livecodescript @@ -25,9 +25,9 @@ This small library is to aid in the application creation process by allowing you to drag files into the development IDE. So it only runs in development mode for the time being. -version 1.0.5 +version 1.0.6 Made: 2020-07-09 15:20 -Last Update: 2020-12-14 12:15 +Last Update: 2020-12-16 17:03 */ # list of files being dragged. @@ -48,13 +48,11 @@ local sLastControl # Whether to import into the dragDestination or create a new object. local sReplace -local sMouseLoc - constant kBynaryStack = "livecode,rev,mc" constant kScriptOnlyStack = "livecodescript" constant kAudio = "mp3,mp4,mpg,mov,avi,m4a,midi,midi,snd,aac,wma,ogg,mpeg,m2v,mpeg2,qt,ram,rm" constant kImage = "svg,png,jpeg,jpg,gif,bmp,pbm,pgm,ppm,xbm,xpm,xwd,pict,webp,jfif,tif,tiff,dib,vga,pict,pict2,pic" -constant kTextPlan = "lc,json,html,htm,txt,lng,locale,log,mnu,nfo,inf,ini,inc,bar,cfg,sav,conf,manifest,lst,ion,rc,properties,mf,list,wbt,lic,css,hs,iss,js,nsi,nsh,java,php,php3,php4,php5,tct,xml,xsml,xsl,kml,adr,sfx,,sh,bsh,lua,pl,pm,py,as,las,mx,vb,f,for,f90,f95,f2k,tex,mak,tpl,asm,plx,lsp,lisp,scm,smd,ss,kix,au3,ml,mli,sml,thy,ada,ads,adb,v,lhs,cmake,twig,yml" +constant kTextPlan = "json,html,htm,txt,lng,locale,log,mnu,nfo,inf,ini,inc,bar,cfg,sav,conf,manifest,lst,ion,rc,properties,mf,list,wbt,lic,css,hs,iss,js,nsi,nsh,java,php,php3,php4,php5,tct,xml,xsml,xsl,kml,adr,sfx,,sh,bsh,lua,pl,pm,py,as,las,mx,vb,f,for,f90,f95,f2k,tex,mak,tpl,asm,plx,lsp,lisp,scm,smd,ss,kix,au3,ml,mli,sml,thy,ada,ads,adb,v,lhs,cmake,twig,yml" on extensionInitialize @@ -95,6 +93,7 @@ on dragLeave end dragLeave +local sMouseLoc on dragDrop _deleteBackgroundGraphic @@ -147,10 +146,8 @@ private command _acceptDrop put the dragData["files"] into sFiles - if sFiles is empty or _filesTypeDragDrop(sFiles) is false then - _deleteBackgroundGraphic - exit _acceptDrop - end if + + if sFiles is empty then exit _acceptDrop if the mouse is down and sFiles is not empty and there is not graphic "frlDragDropBack" of this cd of stack sTopStack then @@ -248,6 +245,10 @@ private command _importImage pPathOrData, pType if pType is "file" then if there is a sDragDestination and sTypeDragDestination is "image" and sReplace is true then + local tLockLoc + + put the lockLoc of sDragDestination into tLockLoc + set the lockLoc of sDragDestination to true if the filename of sDragDestination is empty then set the text of sDragDestination to URL ("binfile:" & pPathOrData) @@ -255,6 +256,8 @@ private command _importImage pPathOrData, pType set the filename of sDragDestination to _convertPathToRelativePath(pPathOrData) end if + set the lockLoc of sDragDestination to tLockLoc + put sDragDestination into sLastControl exit _importImage @@ -291,38 +294,43 @@ private command _importImage pPathOrData, pType local tOldText, tNewText put drawingSvgCompileFile(pPathOrData) into tNewText - if there is a sDragDestination and sTypeDragDestination is "image" then - put the text of sDragDestination into tOldText + if tNewText is not empty then - set the text of sDragDestination to tNewText + if there is a sDragDestination and sTypeDragDestination is "image" then + put the text of sDragDestination into tOldText - if the text of sDragDestination is empty then - set the text of sDragDestination to tOldText - end if + set the text of sDragDestination to tNewText - else - put the mouseLoc into sMouseLoc - set the text of templateImage to tNewText + if the text of sDragDestination is empty then + set the text of sDragDestination to tOldText + end if - put item - 1 of pPathOrData into tNameFile - create image tNameFile in this cd - put it into tNewImage + else + put the mouseLoc into sMouseLoc + set the text of templateImage to tNewText + put item - 1 of pPathOrData into tNameFile + create image tNameFile in this cd + put it into tNewImage - if there is tNewImage then - _scaleImage tNewImage - if sMouseLoc is within the rect of card 1 of stack sTopStack then - set the loc of tNewImage to sMouseLoc - else - set the loc of tNewImage to (the loc of cd 1 of stack sTopStack) - end if + if there is tNewImage then + _scaleImage tNewImage + if sMouseLoc is within the rect of card 1 of stack sTopStack then + set the loc of tNewImage to sMouseLoc + else + set the loc of tNewImage to (the loc of cd 1 of stack sTopStack) + end if - put tNewImage into sLastControl - end if - reset templateImage + put tNewImage into sLastControl + end if + + reset templateImage + end if + else + beep end if end if end if @@ -523,51 +531,57 @@ private function _getPathSVG pFilePath put length(tSVG) into tNumChars - repeat for tNumChars - put offset("path", tSVG, tPathOpen) into tOpen + if "path" is in tSVG then + repeat for tNumChars + put offset("path", tSVG, tPathOpen) into tOpen - if tOpen is 0 then exit repeat - if tNumChars <= tOpen then exit repeat - put tOpen + tPathOpen into tPathOpen + if tOpen is 0 then exit repeat + if tNumChars <= tOpen then exit repeat + put tOpen + tPathOpen into tPathOpen - if the char(tPathOpen - 1) of tSVG is not "<" and char (tPathOpen - 1) of tSVG is not space then - put tPathOpen + 3 into tPathOpen - next repeat - end if + if the char(tPathOpen - 1) of tSVG is not "<" and char (tPathOpen - 1) of tSVG is not space then + put tPathOpen + 3 into tPathOpen + next repeat + end if - put offset("d=" & quote, tSVG, tPathOpen) into tOpen - if tOpen is 0 then exit repeat - put tOpen + tPathOpen + 3 into tOpen + put offset("d=" & quote, tSVG, tPathOpen) into tOpen + if tOpen is 0 then exit repeat + put tOpen + tPathOpen + 3 into tOpen - put offset(quote, tSVG, tOpen) into tClose - if tClose is 0 then exit repeat - put tOpen + tClose into tClose + put offset(quote, tSVG, tOpen) into tClose + if tClose is 0 then exit repeat + put tOpen + tClose into tClose - put char tOpen to (tClose - 1) of tSVG into tNewPath - add 1 to tClose - put tClose into tPathOpen + put char tOpen to (tClose - 1) of tSVG into tNewPath + add 1 to tClose + put tClose into tPathOpen - get (the item 1 to 2 of ( the char tClose to - 1 of tSVG)) + get (the item 1 to 2 of ( the char tClose to - 1 of tSVG)) - if the trueWord 1 of it is "fill" and the trueWord -1 of it is "none" then - next repeat - end if + if the trueWord 1 of it is "fill" and the trueWord -1 of it is "none" then + next repeat + end if - put tNewPath && cr after tSVGPath + put tNewPath && cr after tSVGPath - end repeat + end repeat + end if + else + + put tSVG into tSVGPath end if + local tWidget, tOutPathSVG + create widget as "com.livecode.widget.svgpath" put it into tWidget - local tOutPathSVG = "" - try - set the iconPath of tWidget to tSVGPath - put tSVGPath into tOutPathSVG - end try + try + set the iconPath of tWidget to tSVGPath + put tSVGPath into tOutPathSVG + end try - delete tWidget + delete tWidget return tOutPathSVG end _getPathSVG