diff --git a/.gitmodules b/.gitmodules index bdab40a259..aa54b96a7a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1320,6 +1320,9 @@ [submodule "vendor/grammars/vscode-lean4"] path = vendor/grammars/vscode-lean4 url = https://github.com/leanprover/vscode-lean4.git +[submodule "vendor/grammars/vscode-livecodescript"] + path = vendor/grammars/vscode-livecodescript + url = https://github.com/Ferruslogic/vscode-livecodescript.git [submodule "vendor/grammars/vscode-monkey-c"] path = vendor/grammars/vscode-monkey-c url = https://github.com/ghisguth/vscode-monkey-c diff --git a/grammars.yml b/grammars.yml index 8e77984a96..562bc761bf 100644 --- a/grammars.yml +++ b/grammars.yml @@ -1186,6 +1186,9 @@ vendor/grammars/vscode-lean4: - markdown.lean4.codeblock - source.lean4 - source.lean4.markdown +vendor/grammars/vscode-livecodescript: +- source.lcb +- source.livecodescript vendor/grammars/vscode-monkey-c: - source.mc vendor/grammars/vscode-motoko: diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 9b25b88b2f..b4dea96f95 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -3955,6 +3955,14 @@ Literate Haskell: codemirror_mode: haskell-literate codemirror_mime_type: text/x-literate-haskell language_id: 207 +LiveCode Script: + type: programming + color: "#0c5ba5" + extensions: + - ".livecodescript" + tm_scope: source.livecodescript + ace_mode: text + language_id: 891017 LiveScript: type: programming color: "#499886" diff --git a/samples/LiveCode Script/colorToRGB.livecodescript b/samples/LiveCode Script/colorToRGB.livecodescript new file mode 100644 index 0000000000..2e7abd4302 --- /dev/null +++ b/samples/LiveCode Script/colorToRGB.livecodescript @@ -0,0 +1,13 @@ +script "colorToRGB" + +function colorToRGB pColor + local tColorRGB + + if pColor is a color then + set the colorOverlay["color"] of the templateGraphic to pColor + put the colorOverlay["color"] of the templateGraphic into tColorRGB + reset the templateGraphic + return tColorRGB for value + + else return empty for value +end colorToRGB diff --git a/samples/LiveCode Script/hideFolder.livecodescript b/samples/LiveCode Script/hideFolder.livecodescript new file mode 100644 index 0000000000..335b1ecb0f --- /dev/null +++ b/samples/LiveCode Script/hideFolder.livecodescript @@ -0,0 +1,25 @@ +script "hideFolder" + +command hideFolder pPath + local tLastItem, tNewName + set the itemdel to "/" + + if "\" is in pPath then replace "\" with "/" in pPath + + put pPath into tNewName + put the item - 1 of pPath into tLastItem + + if platform() is "Win32" then + set the hideConsoleWindows to true + get shell( "ATTRIB +H " & quote & tNewName & quote ) + if it is not empty then + answer error it + end if + else if the char 1 of tLastItem is not "." then + put "." & tLastItem into the item - 1 of tNewName + rename folder pPath to tNewName + end if + +end hideFolder + + diff --git a/samples/LiveCode Script/longIdAllControls.livecodescript b/samples/LiveCode Script/longIdAllControls.livecodescript new file mode 100644 index 0000000000..00289f2bb6 --- /dev/null +++ b/samples/LiveCode Script/longIdAllControls.livecodescript @@ -0,0 +1,27 @@ +script "longIdAllControls" + + +function longIdAllControls pLongId + local tType, tCards, tControls, tResult + + if there is not a pLongId then return empty for value + put word 1 of pLongId into tType + + if tType is "stack" then + put the cardIDs of pLongId into tCards + repeat for each line tCard in tCards + put longIdAllControls("card id"&& tCard && "of" && pLongId) & cr after tResult + end repeat + delete char - 1 of tResult + else if tType is in "group card" then + put the number of controls of pLongId into tControls + repeat with x = 1 to tControls + put the long id of control x of pLongId into line x of tResult + end repeat + else + return the long id of pLongId + end if + + sort lines of tResult + return tResult for value +end longIdAllControls \ No newline at end of file diff --git a/samples/LiveCode Script/minifyScript.livecodescript b/samples/LiveCode Script/minifyScript.livecodescript new file mode 100644 index 0000000000..c611a33e37 --- /dev/null +++ b/samples/LiveCode Script/minifyScript.livecodescript @@ -0,0 +1,227 @@ +script "com.livecode.library.minifyScript" + +on extensionInitialize + if the target is not me then + pass "extensionInitialize" + end if + + set the _ideOverride of me to true + insert the script of me into back +end extensionInitialize + +on extensionFinalize + if the target is not me then + pass "extensionFinalize" + end if + + remove the script of me from back +end extensionFinalize + +/** +Type: library + +Title: Minify script + +Author: torocruzand + +Version: 0.0.1 + +SVGIcon: m21.706 5.292-2.999-2.999A.996.996 0 0 0 18 2H6a.997.997 0 0 0-.707.293L2.294 5.292A.996.996 0 0 0 2 6v13c0 1.103.897 2 2 2h16c1.103 0 2-.897 2-2V6a.994.994 0 0 0-.294-.708zM6.414 4h11.172l1 1H5.414l1-1zM12 18l-5-5h3v-3h4v3h3l-5 5z + +OS: Mac, Windows, Linux, iOS, Android + +Platforms: desktop, mobile, web + +Summary: The “minify script” library is a tool for LiveCode that reduces stack +file sizes by eliminating comments and spaces from control code, enhancing +efficiency but reducing human readability. + +Description: +The “minify script” library is designed to reduce the size of stack files +in LiveCode. This library removes comments and spaces from the code of controls, +resulting in smaller stack sizes. However, this also makes the code more +difficult for humans to read. Therefore, it’s important to maintain a version +of the code that includes all comments and other elements for readability and +future reference. +*/ + +/** +Minifies the script of a control. + +Syntax: minifyScript + +Description: +Use the command to minify the script of a control. +This command sets the script of the control to the minified version +of the script. + +Parameters: +pLongId (string): The long ID of the control. + +Example: +minifyScript the long id of button "button 1", true +-- The script of button 1 is minified and obfuscated +*/ +command minifyScript pLongId + if there is a not pLongId then + return "control not found" + end if + + try + set the script of pLongId to getMinifiedScript(pLongId) + end try +end minifyScript + + +/** +Minifies a script and returns the minified version. + +Syntax: getMinifiedScript + +Description: +Use the function to minify a script. +This function removes comments and unnecessary whitespace from the script and +returns the minified version. + +Parameters: +pLongId (string): The long ID of the control. + +Returns: +The minified script. + +Example: +put getMinifiedScript(the long id of button "button 1", true) into tMinifiedScript +-- The minified script is stored in tMinifiedScript +*/ +function getMinifiedScript pLongId + local tScript + local tCommentOneLineChars = "//,--,#" + local tCurrentLine = 0 + local tNumItems = 0 + local tBreak = 0 + local tCommentOneLine + local tInsideQuote = false + local tClosure = 0 + local tMinifiedScript = "" + + # Valid that it is an object. + if there is a not pLongId then return empty + + # I take the object code + put word 1 to - 1 of (the script of pLongId) into tScript + + # If you do not have empty return code. + if tScript is empty then return empty + + set the itemDel to quote + replace comma with cr in tCommentOneLineChars + + repeat for each line tLine in tScript + add 1 to tCurrentLine + put the num of items of tLine into tNumItems + + if tBreak is 0 then + put word 1 to - 1 of tLine into tLine + if tLine is empty then next repeat + + # Comment of a line. + # To avoid doing everything for pleasure. + if tLine contains "//" or tLine contains "-" or tLine contains "#" then + + repeat for each line tCommentChar in tCommentOneLineChars + put offset(tCommentChar, tLine) into tCommentOneLine + + if tCommentOneLine is 0 then next repeat + + # If it's in quotes. + put _insideQuote(tCommentOneLine, tLine) into tInsideQuote + + if tInsideQuote is not 1 then + if tInsideQuote mod 2 is not 0 then + delete char tCommentOneLine to - 1 of tLine + end if + else + delete char tCommentOneLine to - 1 of tLine + end if + + if tLine is empty then exit repeat + end repeat + + if tLine is empty then next repeat + end if + + # looking for the opening of multiline comments. + put offSet("/*", tLine) into tBreak + if tBreak is not 0 then + + # I have quotes. + put _insideQuote(tBreak, tLine) into tInsideQuote + + # if it is not within the first item. + if tInsideQuote is not 1 then + # It's in quotes. + if tInsideQuote mod 2 is not 0 then + delete char tBreak to - 1 of tLine + else + put 0 into tBreak + end if + else + + # If it is not before the quotation marks or does not have + # quotation marks, I am looking for the closure on this line. + put offSet("*/", tLine) into tClosure + + if tClosure is 0 then + delete char tBreak to - 1 of tLine + else + put tBreak + tClosure into tClosure + delete char tBreak to tClosure of tLine + put 0 into tBreak + end if + end if + + if tLine is empty then next repeat + end if + + put tLine & return after tMinifiedScript + else + # Here I look for the closure of the multiline. + put offSet("*/", tLine) into tClosure + + if tClosure is 0 then + next repeat + else + put tClosure + 1 into tBreak + delete char 1 to tBreak of tLine + + # I have quotes. + put 0 into tBreak + if tLine is empty then next repeat + put tLine & return after tMinifiedScript + end if + end if + end repeat + + # Delete the blank lines. + filter tMinifiedScript without empty + put tMinifiedScript into tScript + put empty into tMinifiedScript + + repeat for each line tLine in tScript + if "\" is last char of last word of tLine then + delete last char of last word of tLine + put tLine & space after tMinifiedScript + else + put tLine & cr after tMinifiedScript + end if + end repeat + + # Return the code without comment. + return tMinifiedScript +end getMinifiedScript + + +private function _insideQuote pNumChar, pText + set the itemDel to quote + return the num of items of the char 1 to pNumChar of pText +end _insideQuote diff --git a/vendor/README.md b/vendor/README.md index 6efa31be5e..5939295164 100644 --- a/vendor/README.md +++ b/vendor/README.md @@ -322,6 +322,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting - **Liquid:** [Shopify/liquid-tm-grammar](https://github.com/Shopify/liquid-tm-grammar) - **Literate CoffeeScript:** [atom/language-coffee-script](https://github.com/atom/language-coffee-script) - **Literate Haskell:** [atom-haskell/language-haskell](https://github.com/atom-haskell/language-haskell) +- **LiveCode Script:** [Ferruslogic/vscode-livecodescript](https://github.com/Ferruslogic/vscode-livecodescript) - **LiveScript:** [paulmillr/LiveScript.tmbundle](https://github.com/paulmillr/LiveScript.tmbundle) - **Logos:** [Cykey/Sublime-Logos](https://github.com/Cykey/Sublime-Logos) - **Logtalk:** [textmate/logtalk.tmbundle](https://github.com/textmate/logtalk.tmbundle) diff --git a/vendor/grammars/vscode-livecodescript b/vendor/grammars/vscode-livecodescript new file mode 160000 index 0000000000..3b1c572b54 --- /dev/null +++ b/vendor/grammars/vscode-livecodescript @@ -0,0 +1 @@ +Subproject commit 3b1c572b5497851e438b92d0a88b08c0888e29a9 diff --git a/vendor/licenses/git_submodule/vscode-livecodescript.dep.yml b/vendor/licenses/git_submodule/vscode-livecodescript.dep.yml new file mode 100644 index 0000000000..036bc3de65 --- /dev/null +++ b/vendor/licenses/git_submodule/vscode-livecodescript.dep.yml @@ -0,0 +1,41 @@ +--- +name: vscode-livecodescript +version: 3b1c572b5497851e438b92d0a88b08c0888e29a9 +type: git_submodule +homepage: https://github.com/Ferruslogic/vscode-livecodescript.git +license: bsd-3-clause +licenses: +- sources: LICENSE.md + text: | + BSD 3-Clause License + + Copyright (c) 2022, FerrusLogic + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- sources: README.md + text: "[BSD 3](LICENSE.md) © FerrusLogic" +notices: []