diff options
| author | Li Jin <dragon-fly@qq.com> | 2024-08-05 17:20:00 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2024-08-05 17:20:00 +0800 |
| commit | 94edfbc8c7d62d700dfb59334a0ed3beedd49493 (patch) | |
| tree | f695cec8b8873d5a6e763ac94bf3c81fb6ba0be9 /spec/inputs | |
| parent | f8cd1220147d606b7e96f88c12fd0f163fb4e1c5 (diff) | |
| download | yuescript-94edfbc8c7d62d700dfb59334a0ed3beedd49493.tar.gz yuescript-94edfbc8c7d62d700dfb59334a0ed3beedd49493.tar.bz2 yuescript-94edfbc8c7d62d700dfb59334a0ed3beedd49493.zip | |
add macros generating macros feature.v0.23.9
Diffstat (limited to 'spec/inputs')
| -rw-r--r-- | spec/inputs/macro.yue | 33 | ||||
| -rw-r--r-- | spec/inputs/macro_export.yue | 18 |
2 files changed, 51 insertions, 0 deletions
diff --git a/spec/inputs/macro.yue b/spec/inputs/macro.yue index ae14f53..a2e1046 100644 --- a/spec/inputs/macro.yue +++ b/spec/inputs/macro.yue | |||
| @@ -5,6 +5,39 @@ import "macro_export" as { | |||
| 5 | 5 | ||
| 6 | import "macro_todo" as $ | 6 | import "macro_todo" as $ |
| 7 | 7 | ||
| 8 | macro WindowFlag = $enum( | ||
| 9 | NoNav | ||
| 10 | NoDecoration | ||
| 11 | NoTitleBar | ||
| 12 | NoResize | ||
| 13 | NoMove | ||
| 14 | NoScrollbar | ||
| 15 | NoScrollWithMouse | ||
| 16 | NoCollapse | ||
| 17 | AlwaysAutoResize | ||
| 18 | NoSavedSettings | ||
| 19 | NoInputs | ||
| 20 | MenuBar | ||
| 21 | HorizontalScrollbar | ||
| 22 | NoFocusOnAppearing | ||
| 23 | NoBringToFrontOnFocus | ||
| 24 | AlwaysVerticalScrollbar | ||
| 25 | AlwaysHorizontalScrollbar | ||
| 26 | NoNavInputs | ||
| 27 | NoNavFocus | ||
| 28 | UnsavedDocument | ||
| 29 | ) | ||
| 30 | |||
| 31 | print $WindowFlag AlwaysAutoResize | ||
| 32 | print $WindowFlag( | ||
| 33 | NoNav | ||
| 34 | NoDecoration | ||
| 35 | NoTitleBar | ||
| 36 | NoResize | ||
| 37 | NoMove | ||
| 38 | NoScrollbar | ||
| 39 | ) | ||
| 40 | |||
| 8 | $asserts item == nil | 41 | $asserts item == nil |
| 9 | 42 | ||
| 10 | $myconfig false | 43 | $myconfig false |
diff --git a/spec/inputs/macro_export.yue b/spec/inputs/macro_export.yue index eec5848..cc7d459 100644 --- a/spec/inputs/macro_export.yue +++ b/spec/inputs/macro_export.yue | |||
| @@ -44,6 +44,24 @@ do | |||
| 44 | _dst_.#{field} = _src_.#{field} | 44 | _dst_.#{field} = _src_.#{field} |
| 45 | "}" | 45 | "}" |
| 46 | 46 | ||
| 47 | export macro enum = (...) -> | ||
| 48 | items = {...} | ||
| 49 | items = [item\gsub('"', '') for item in *items] | ||
| 50 | itemSet = {item, true for item in *items} | ||
| 51 | (...) -> | ||
| 52 | count = select "#", ... | ||
| 53 | if 1 < count | ||
| 54 | result = "[" | ||
| 55 | for i = 1, count | ||
| 56 | item = select i, ... | ||
| 57 | error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item] | ||
| 58 | result ..= "\"#{item}\"," | ||
| 59 | result .. "]" | ||
| 60 | else | ||
| 61 | item = select 1, ... | ||
| 62 | error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item] | ||
| 63 | "\"#{item}\"" | ||
| 64 | |||
| 47 | $ -> | 65 | $ -> |
| 48 | global debugMode = true | 66 | global debugMode = true |
| 49 | global debugMacro = true | 67 | global debugMacro = true |
