-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the LiveCode Script language. (#6833)
* Add the "LiveCode Script" language. * Add examples for the `*.lc` extension * Removing the ".lc" extension and its samples * Update vendor/licenses/git_submodule/vscode-livecodescript.dep.yml --------- Co-authored-by: Colin Seymour <[email protected]>
- Loading branch information
1 parent
f7c7baa
commit 0523920
Showing
10 changed files
with
349 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <pLongId> | ||
Description: | ||
Use the <minifyScript> 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 <pLongId> | ||
Description: | ||
Use the <getMinifiedScript> 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule vscode-livecodescript
added at
3b1c57
41 changes: 41 additions & 0 deletions
41
vendor/licenses/git_submodule/vscode-livecodescript.dep.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: [] |