Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
- don't replace in comments
- enhance internal classes _macros & _regex
- add realese workflow
  • Loading branch information
vdelachaux committed Oct 8, 2024
1 parent 77f8eba commit 0531551
Show file tree
Hide file tree
Showing 12 changed files with 267 additions and 188 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ macOS,Windows ]
os: [ macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand All @@ -26,5 +26,4 @@ jobs:
version: vcs
build: official
token: ${{ secrets.DLTK }}



18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Release
on:
release:
types: [published]
jobs:
publish:
name: Publish
runs-on: macos-latest
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
permissions:
contents: write # for asset upload
steps:
- name: ⬇️ Checkout
uses: actions/checkout@v4
- name: Upload
run: |
gh release upload ${{github.event.release.tag_name}} BUILD/4D-Macros.zip
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ DEV/
#--------------------------------
.DS_Store
Project/Sources/dependencies.json
*.dmg
BUILD/4D-Macros.dmg
BUILD/Components/4D Macros.4dbase/Resources/InfoPlist.strings
Binary file added BUILD/4D-Macros.zip
Binary file not shown.
Binary file modified BUILD/Components/4D Macros.4dbase/4D Macros.4DZ
Binary file not shown.
Binary file modified BUILD/Components/4D Macros.4dbase/Libraries/lib4d-arm64.dylib
Binary file not shown.
6 changes: 6 additions & 0 deletions Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
<plist>
<dict>
</dict>
</plist>
3 changes: 2 additions & 1 deletion Project/4D Macros.4DProject
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$comment": "The project file serves as an anchor to locate other project files",
"compatibilityVersion": 2070
"compatibilityVersion": 2070,
"$4DPopAppMakerToolVersion": "20R8"
}
20 changes: 3 additions & 17 deletions Project/Sources/Classes/_formatCode.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Class constructor
// Replace declaration lines using the old “(_o_)C_xxx” syntax with the new “var ... type”.
Function C_2var()

var $code : Text:=This:C1470.method //This.withSelection ? This.highlighted : This.method
var $pattern : Text:="(?-msi)(?<!//)(?<!//\\s){C_}\\((?![\\w\\s]+;\\s*\\$\\{?\\d+\\}?)([^\\)]*)\\)"

var $pattern : Text:="(?-msi){C_}\\((?![\\w\\s]+;\\s*\\$\\{?\\d+\\}?)([^\\)]*)\\)"
var $code : Text:=This:C1470.fullMethodText
$code:=This:C1470.rgx.setTarget($code).setPattern(Replace string:C233($pattern; "{C_}"; Command name:C538(604))).substitute("var \\1 : Blob")
$code:=This:C1470.rgx.setTarget($code).setPattern(Replace string:C233($pattern; "{C_}"; Command name:C538(305))).substitute("var \\1 : Boolean")
$code:=This:C1470.rgx.setTarget($code).setPattern(Replace string:C233($pattern; "{C_}"; Command name:C538(1488))).substitute("var \\1 : Collection")
Expand All @@ -24,18 +24,4 @@ Function C_2var()
$code:=This:C1470.rgx.setTarget($code).setPattern(Replace string:C233($pattern; "{C_}"; Command name:C538(306))).substitute("var \\1 : Time")
$code:=This:C1470.rgx.setTarget($code).setPattern(Replace string:C233($pattern; "{C_}"; Command name:C538(1683))).substitute("var \\1")

// Return modified code
If (Position:C15("var"; $code)=1)

// Turn around:
// "<caret/>var …" remove the space after the keyword var
This:C1470.paste($code; False:C215)

Else

// Place cursor at start of method
This:C1470.paste(This:C1470.caret+$code; False:C215)

End if

This:C1470.tokenise()
This:C1470.fullMethodText:=This:C1470.cursorOnFirstLine($code)
107 changes: 66 additions & 41 deletions Project/Sources/Classes/_macros.4dm
Original file line number Diff line number Diff line change
@@ -1,90 +1,115 @@
property title : Text
property method : Text
property highlighted : Text
property withSelection : Boolean
property lineTexts : Collection
property rgx : cs:C1710._regex
property caret : Text
property _highlighted : Boolean

Class constructor()

This:C1470.title:=Get window title:C450(Frontmost window:C447)
This:C1470.rgx:=cs:C1710._regex.new()

var $t : Text

// The complete method code
GET MACRO PARAMETER:C997(Full method text:K5:17; $t)
This:C1470.method:=$t

// The selected code
GET MACRO PARAMETER:C997(Highlighted method text:K5:18; $t)
This:C1470.highlighted:=$t
This:C1470.withSelection:=Length:C16($t)>0
This:C1470._highlighted:=Length:C16($t)>0

This:C1470.caret:="<caret/"+">"

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function C_xx2var()
// MARK:- [IN/OUT]
// <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <==
Function get fullMethodText() : Text

cs:C1710._formatCode.new().C_2var()
var $t : Text

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function split($useSelection : Boolean)
GET MACRO PARAMETER:C997(Full method text:K5:17; $t)

var $target : Text
return $t

If (Count parameters:C259>=1)

$target:=$useSelection ? This:C1470.highlighted : This:C1470.method

Else

$target:=This:C1470.withSelection ? This:C1470.highlighted : This:C1470.method

End if
// ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==>
Function set fullMethodText($code : Text)

This:C1470.lineTexts:=Split string:C1554($target; "\r"; sk trim spaces:K86:2)
SET MACRO PARAMETER:C998(Full method text:K5:17; $code)

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function setMethodText($text : Text)

SET MACRO PARAMETER:C998(Full method text:K5:17; $text)

// <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <==
Function get highlightedMethodText() : Text

var $t : Text

GET MACRO PARAMETER:C997(Highlighted method text:K5:18; $t)

return $t

// ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==>
Function set highlightedMethodText($code : Text)

SET MACRO PARAMETER:C998(Highlighted method text:K5:18; $code)

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function setHighlightedText($text : Text)

SET MACRO PARAMETER:C998(Highlighted method text:K5:18; $text)

// <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <==
Function get code() : Text

var $code : Text

GET MACRO PARAMETER:C997(This:C1470._highlighted ? Highlighted method text:K5:18 : Full method text:K5:17; $code)

return $code

// ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==>
Function set code($code : Text)

SET MACRO PARAMETER:C998(This:C1470._highlighted ? Highlighted method text:K5:18 : Full method text:K5:17; $code)

// MARK:-[
// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function C_xx2var()

cs:C1710._formatCode.new().C_2var()

// MARK:-
// === === === === === === === === === === === === === === === === === === === === === === === === === ===
// Set code and force tokenisation
Function paste($text : Text; $useSelection : Boolean)

var $target : Integer
$useSelection:=Count parameters:C259>=2 ? $useSelection : This:C1470._highlighted
SET MACRO PARAMETER:C998($useSelection ? Highlighted method text:K5:18 : Full method text:K5:17; $text)

$useSelection:=Count parameters:C259>=2 ? $useSelection : This:C1470.withSelection
$target:=$useSelection ? Highlighted method text:K5:18 : Full method text:K5:17
This:C1470.tokenise()

SET MACRO PARAMETER:C998($target; $text)
// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function split($useSelection : Boolean) : Collection

If (Structure file:C489=Structure file:C489(*))

return

End if
$useSelection:=Count parameters:C259>=2 ? $useSelection : This:C1470._highlighted

return Split string:C1554($useSelection ? This:C1470.highlightedMethodText : This:C1470.fullMethodText; "\r"; sk trim spaces:K86:2)

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
// Place cursor at the end of the first line
Function cursorOnFirstLine($code : Text) : Text

return Replace string:C233($code; "\r"; This:C1470.caret+"\r"; 1)

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
// Force tokenisation of the foreground method
Function tokenise()

var $name : Text
var $processNumber; $mode; $origin; $state; $time; $UID : Integer
var $process; $mode; $origin; $state; $time; $UID : Integer

For ($processNumber; 1; Count tasks:C335; 1)
For ($process; 1; Count tasks:C335; 1)

Try(_O_PROCESS PROPERTIES:C336($processNumber; $name; $state; $time; $mode; $UID; $origin))
Try(_O_PROCESS PROPERTIES:C336($process; $name; $state; $time; $mode; $UID; $origin))

If ($origin=Design process:K36:9)

POST EVENT:C467(Key down event:K17:4; Enter:K15:35; Tickcount:C458; 0; 0; 0; $processNumber)
POST EVENT:C467(Key down event:K17:4; Enter:K15:35; Tickcount:C458; 0; 0; 0; $process)

break

Expand Down
Loading

0 comments on commit 0531551

Please sign in to comment.