Skip to content

Commit 579b75c

Browse files
chore: autopublish 2023-01-19T00:03:18Z
1 parent ea1f116 commit 579b75c

3 files changed

Lines changed: 326 additions & 52 deletions

File tree

docs/library/utils.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ A library of general Lua utility functions.
77
- [copy_table(t)](#copy_table)
88
- [table_remove_first(t, value)](#table_remove_first)
99
- [iterate_keys(t)](#iterate_keys)
10-
- [round(num)](#round)
10+
- [round(num, places)](#round)
1111
- [calc_roman_numeral(num)](#calc_roman_numeral)
1212
- [calc_ordinal(num)](#calc_ordinal)
1313
- [calc_alphabet(num)](#calc_alphabet)
1414
- [clamp(num, minimum, maximum)](#clamp)
15+
- [ltrim(str)](#ltrim)
1516

1617
### copy_table
1718

@@ -67,16 +68,17 @@ Returns an unordered iterator for the keys in a table.
6768
### round
6869

6970
```lua
70-
utility_functions.round(num)
71+
utility_functions.round(num, places)
7172
```
7273

73-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/utils.lua#L71)
74+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/utils.lua#L72)
7475

75-
Rounds a number to the nearest whole integer.
76+
Rounds a number to the nearest integer or the specified number of decimal places.
7677

7778
| Input | Type | Description |
7879
| ----- | ---- | ----------- |
7980
| `num` | `number` | |
81+
| `places` (optional) | `number` | If specified, the number of decimal places to round to. If omitted or 0, will round to the nearest integer. |
8082

8183
| Return type | Description |
8284
| ----------- | ----------- |
@@ -88,7 +90,7 @@ Rounds a number to the nearest whole integer.
8890
utility_functions.calc_roman_numeral(num)
8991
```
9092

91-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/utils.lua#L83)
93+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/utils.lua#L86)
9294

9395
Calculates the roman numeral for the input number. Adapted from https://exercism.org/tracks/lua/exercises/roman-numerals/solutions/Nia11 on 2022-08-13
9496

@@ -106,7 +108,7 @@ Calculates the roman numeral for the input number. Adapted from https://exercism
106108
utility_functions.calc_ordinal(num)
107109
```
108110

109-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/utils.lua#L104)
111+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/utils.lua#L107)
110112

111113
Calculates the ordinal for the input number (e.g. 1st, 2nd, 3rd).
112114

@@ -124,7 +126,7 @@ Calculates the ordinal for the input number (e.g. 1st, 2nd, 3rd).
124126
utility_functions.calc_alphabet(num)
125127
```
126128

127-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/utils.lua#L128)
129+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/utils.lua#L131)
128130

129131
This returns one of the ways that Finale handles numbering things alphabetically, such as rehearsal marks or measure numbers.
130132

@@ -144,7 +146,7 @@ This function was written to emulate the way Finale numbers saves when Autonumbe
144146
utility_functions.clamp(num, minimum, maximum)
145147
```
146148

147-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/utils.lua#L145)
149+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/utils.lua#L148)
148150

149151
Clamps a number between two values.
150152

@@ -157,3 +159,21 @@ Clamps a number between two values.
157159
| Return type | Description |
158160
| ----------- | ----------- |
159161
| `number` | |
162+
163+
### ltrim
164+
165+
```lua
166+
utility_functions.ltrim(str)
167+
```
168+
169+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/library/utils.lua#L160)
170+
171+
Removes whitespace from the start of a string.
172+
173+
| Input | Type | Description |
174+
| ----- | ---- | ----------- |
175+
| `str` | `string` | |
176+
177+
| Return type | Description |
178+
| ----------- | ----------- |
179+
| `string` | |

docs/mixin/FCMCtrlEdit.md

Lines changed: 103 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Summary of modifications:
44
- Added `Change` custom control event.
55
- Added hooks for restoring control state
6+
- `GetMeasurement*` and `SetMeasurement*` methods have been overridden to use the `FCMString` versions of those methods under the hood. For more details on any changes, see the documentation for `FCMString`.
67

78
## Functions
89

@@ -12,15 +13,18 @@ Summary of modifications:
1213
- [GetFloat(self)](#getfloat)
1314
- [SetFloat(self, value)](#setfloat)
1415
- [GetMeasurement(self, measurementunit)](#getmeasurement)
16+
- [GetRangeMeasurement(self, measurementunit, minimum, maximum)](#getrangemeasurement)
1517
- [SetMeasurement(self, value, measurementunit)](#setmeasurement)
1618
- [GetMeasurementEfix(self, measurementunit)](#getmeasurementefix)
19+
- [GetRangeMeasurementEfix(self, measurementunit, minimum, maximum)](#getrangemeasurementefix)
1720
- [SetMeasurementEfix(self, value, measurementunit)](#setmeasurementefix)
1821
- [GetMeasurementInteger(self, measurementunit)](#getmeasurementinteger)
22+
- [GetRangeMeasurementInteger(self, measurementunit, minimum, maximum)](#getrangemeasurementinteger)
1923
- [SetMeasurementInteger(self, value, measurementunit)](#setmeasurementinteger)
24+
- [GetMeasurement10000th(self, measurementunit)](#getmeasurement10000th)
25+
- [GetRangeMeasurement10000th(self, measurementunit, minimum, maximum)](#getrangemeasurement10000th)
26+
- [SetMeasurement10000th(self, value, measurementunit)](#setmeasurement10000th)
2027
- [GetRangeInteger(self, minimum, maximum)](#getrangeinteger)
21-
- [GetRangeMeasurement(self, measurementunit, minimum, maximum)](#getrangemeasurement)
22-
- [GetRangeMeasurementEfix(self, measurementunit, minimum, maximum)](#getrangemeasurementefix)
23-
- [GetRangeMeasurementInteger(self, measurementunit, minimum, maximum)](#getrangemeasurementinteger)
2428
- [HandleChange(control, last_value)](#handlechange)
2529
- [AddHandleChange(self, callback)](#addhandlechange)
2630
- [RemoveHandleChange(self, callback)](#removehandlechange)
@@ -31,7 +35,7 @@ Summary of modifications:
3135
fcmctrledit.SetText(self, str)
3236
```
3337

34-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L29)
38+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L30)
3539

3640
**[Fluid] [Override]**
3741
Ensures that `Change` event is triggered.
@@ -47,7 +51,7 @@ Ensures that `Change` event is triggered.
4751
fcmctrledit.GetInteger(self)
4852
```
4953

50-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L201)
54+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L286)
5155

5256
**[Override]**
5357
Hooks into control state restoration.
@@ -119,7 +123,7 @@ Also hooks into control state restoration.
119123
fcmctrledit.GetMeasurement(self, measurementunit)
120124
```
121125

122-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L120)
126+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L134)
123127

124128
**[Override]**
125129
Hooks into control state restoration.
@@ -133,13 +137,35 @@ Hooks into control state restoration.
133137
| ----------- | ----------- |
134138
| `number` | |
135139

140+
### GetRangeMeasurement
141+
142+
```lua
143+
fcmctrledit.GetRangeMeasurement(self, measurementunit, minimum, maximum)
144+
```
145+
146+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L145)
147+
148+
**[Override]**
149+
Hooks into control state restoration.
150+
151+
| Input | Type | Description |
152+
| ----- | ---- | ----------- |
153+
| `self` | `FCMCtrlEdit` | |
154+
| `measurementunit` | `number` | Any of the finale.MEASUREMENTUNIT_* constants. |
155+
| `minimum` | `number` | |
156+
| `maximum` | `number` | |
157+
158+
| Return type | Description |
159+
| ----------- | ----------- |
160+
| `number` | |
161+
136162
### SetMeasurement
137163

138164
```lua
139165
fcmctrledit.SetMeasurement(self, value, measurementunit)
140166
```
141167

142-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L131)
168+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L158)
143169

144170
**[Fluid] [Override]**
145171
Ensures that `Change` event is triggered.
@@ -157,7 +183,27 @@ Also hooks into control state restoration.
157183
fcmctrledit.GetMeasurementEfix(self, measurementunit)
158184
```
159185

160-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L241)
186+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L-1)
187+
188+
**[Override]**
189+
Hooks into control state restoration.
190+
191+
| Input | Type | Description |
192+
| ----- | ---- | ----------- |
193+
| `self` | `FCMCtrlEdit` | |
194+
| `measurementunit` | `number` | Any of the finale.MEASUREMENTUNIT_* constants. |
195+
196+
| Return type | Description |
197+
| ----------- | ----------- |
198+
| `number` | |
199+
200+
### GetRangeMeasurementEfix
201+
202+
```lua
203+
fcmctrledit.GetRangeMeasurementEfix(self, measurementunit, minimum, maximum)
204+
```
205+
206+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L-1)
161207

162208
**[Override]**
163209
Hooks into control state restoration.
@@ -166,6 +212,8 @@ Hooks into control state restoration.
166212
| ----- | ---- | ----------- |
167213
| `self` | `FCMCtrlEdit` | |
168214
| `measurementunit` | `number` | Any of the finale.MEASUREMENTUNIT_* constants. |
215+
| `minimum` | `number` | |
216+
| `maximum` | `number` | |
169217

170218
| Return type | Description |
171219
| ----------- | ----------- |
@@ -195,15 +243,38 @@ Also hooks into control state restoration.
195243
fcmctrledit.GetMeasurementInteger(self, measurementunit)
196244
```
197245

198-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L261)
246+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L-1)
247+
248+
**[Override]**
249+
Hooks into control state restoration.
250+
251+
| Input | Type | Description |
252+
| ----- | ---- | ----------- |
253+
| `self` | `FCMCtrlEdit` | |
254+
| `measurementunit` | `number` | Any of the finale.MEASUREMENTUNIT_* constants. |
255+
256+
| Return type | Description |
257+
| ----------- | ----------- |
258+
| `number` | |
259+
260+
### GetRangeMeasurementInteger
261+
262+
```lua
263+
fcmctrledit.GetRangeMeasurementInteger(self, measurementunit, minimum, maximum)
264+
```
265+
266+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L-1)
199267

200268
**[Override]**
201269
Hooks into control state restoration.
270+
Also fixes issue with decimal places in `minimum` being discarded instead of being correctly taken into account (see `FCMString.GetRangeMeasurementInteger`).
202271

203272
| Input | Type | Description |
204273
| ----- | ---- | ----------- |
205274
| `self` | `FCMCtrlEdit` | |
206275
| `measurementunit` | `number` | Any of the finale.MEASUREMENTUNIT_* constants. |
276+
| `minimum` | `number` | |
277+
| `maximum` | `number` | |
207278

208279
| Return type | Description |
209280
| ----------- | ----------- |
@@ -227,37 +298,34 @@ Also hooks into control state restoration.
227298
| `value` | `number` | |
228299
| `measurementunit` | `number` | |
229300

230-
### GetRangeInteger
301+
### GetMeasurement10000th
231302

232303
```lua
233-
fcmctrledit.GetRangeInteger(self, minimum, maximum)
304+
fcmctrledit.GetMeasurement10000th(self, measurementunit)
234305
```
235306

236-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L197)
307+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L-1)
237308

238-
**[Override]**
239-
Hooks into control state restoration.
309+
Returns the measurement in 10000ths of an EVPU.
240310

241311
| Input | Type | Description |
242312
| ----- | ---- | ----------- |
243313
| `self` | `FCMCtrlEdit` | |
244-
| `minimum` | `number` | |
245-
| `maximum` | `number` | |
314+
| `measurementunit` | `number` | Any of the finale.MEASUREMENTUNIT_* constants. |
246315

247316
| Return type | Description |
248317
| ----------- | ----------- |
249318
| `number` | |
250319

251-
### GetRangeMeasurement
320+
### GetRangeMeasurement10000th
252321

253322
```lua
254-
fcmctrledit.GetRangeMeasurement(self, measurementunit, minimum, maximum)
323+
fcmctrledit.GetRangeMeasurement10000th(self, measurementunit, minimum, maximum)
255324
```
256325

257-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L216)
326+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L-1)
258327

259-
**[Override]**
260-
Hooks into control state restoration.
328+
Returns the measurement in 10000ths of an EVPU, clamped between two values.
261329

262330
| Input | Type | Description |
263331
| ----- | ---- | ----------- |
@@ -270,43 +338,38 @@ Hooks into control state restoration.
270338
| ----------- | ----------- |
271339
| `number` | |
272340

273-
### GetRangeMeasurementEfix
341+
### SetMeasurement10000th
274342

275343
```lua
276-
fcmctrledit.GetRangeMeasurementEfix(self, measurementunit, minimum, maximum)
344+
fcmctrledit.SetMeasurement10000th(self, value, measurementunit)
277345
```
278346

279-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L236)
347+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L-1)
280348

281-
**[Override]**
282-
Hooks into control state restoration.
349+
**[Fluid]**
350+
Sets a measurement in 10000ths of an EVPU.
283351

284352
| Input | Type | Description |
285353
| ----- | ---- | ----------- |
286354
| `self` | `FCMCtrlEdit` | |
287-
| `measurementunit` | `number` | Any of the finale.MEASUREMENTUNIT_* constants. |
288-
| `minimum` | `number` | |
289-
| `maximum` | `number` | |
290-
291-
| Return type | Description |
292-
| ----------- | ----------- |
293-
| `number` | |
355+
| `value` | `number` | |
356+
| `measurementunit` | `number` | |
294357

295-
### GetRangeMeasurementInteger
358+
### GetRangeInteger
296359

297360
```lua
298-
fcmctrledit.GetRangeMeasurementInteger(self, measurementunit, minimum, maximum)
361+
fcmctrledit.GetRangeInteger(self, minimum, maximum)
299362
```
300363

301-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L256)
364+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L282)
302365

303366
**[Override]**
304367
Hooks into control state restoration.
368+
Fixes issue with decimal places in `minimum` being discarded instead of being correctly taken into account.
305369

306370
| Input | Type | Description |
307371
| ----- | ---- | ----------- |
308372
| `self` | `FCMCtrlEdit` | |
309-
| `measurementunit` | `number` | Any of the finale.MEASUREMENTUNIT_* constants. |
310373
| `minimum` | `number` | |
311374
| `maximum` | `number` | |
312375

@@ -320,7 +383,7 @@ Hooks into control state restoration.
320383
fcmctrledit.HandleChange(control, last_value)
321384
```
322385

323-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L274)
386+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L299)
324387

325388
**[Callback Template]**
326389

@@ -335,7 +398,7 @@ fcmctrledit.HandleChange(control, last_value)
335398
fcmctrledit.AddHandleChange(self, callback)
336399
```
337400

338-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L291)
401+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L316)
339402

340403
**[Fluid]**
341404
Adds a handler for when the value of the control changes.
@@ -355,7 +418,7 @@ The even will fire when:
355418
fcmctrledit.RemoveHandleChange(self, callback)
356419
```
357420

358-
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L296)
421+
[View source](https://github.com/finale-lua/lua-scripts/tree/master/src/mixin/FCMCtrlEdit.lua#L321)
359422

360423
**[Fluid]**
361424
Removes a handler added with `AddHandleChange`.

0 commit comments

Comments
 (0)