Old 05-24-2016, 05:29 PM   #1
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 1,208
Default Interactive ReaScript (Lua)

This script implements a REPL shell for Lua ReaScript inside of REAPER, for quickly experimenting code and API functions.



Main Features:
  • Autocompletion
  • Code history
  • Colored output
  • Copy/Paste from clipboard (works best on macOS)
  • Error catching
  • Multiline input (functions, conditions...)
  • Pretty print return values
  • Scrolling
  • Text wrapping
  • Run actions (!command_id, !!midi_editor_action)
Known Issues/Limitations:
Install:

iReaScript is available from ReaTeam's ReaScript repository in ReaPack.

Last edited by cfillion; 02-17-2017 at 01:34 AM. Reason: OS X is macOS now
cfillion is online now   Reply With Quote
Old 05-24-2016, 11:53 PM   #2
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 1,390
Default

This is Amazing!
__________________
SoundCloud | MPL Scripts discussion | ReaPack | Donate
mpl is offline   Reply With Quote
Old 05-25-2016, 03:29 AM   #3
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 4,044
Default

This is what I call an experimental script haha

Well done, it seems pretty good !
X-Raym is offline   Reply With Quote
Old 05-25-2016, 08:57 AM   #4
Claudiohbsantos
Human being with feelings
 
Join Date: Aug 2014
Location: New York
Posts: 120
Default

This is awesome, gonna have to give it a shot later tonight. I can see this becoming a very handy tool while reascripting
Claudiohbsantos is offline   Reply With Quote
Old 06-07-2016, 08:09 PM   #5
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 1,208
Default

iReaScript v0.2

+ enhance formatting of arrays containing nil values
+ implement Delete key
+ implement word movement keys (Shift+Left and Shift+Right)
+ imply the return statement by default
+ limit maximum depth when formatting tables
+ protect against overriding of built-in variables
cfillion is online now   Reply With Quote
Old 06-07-2016, 09:03 PM   #6
semiquaver
Human being with feelings
 
Join Date: Jun 2008
Posts: 4,859
Default

yes !!
semiquaver is offline   Reply With Quote
Old 07-14-2016, 07:53 PM   #7
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 1,208
Default

iReaScript v0.3

+ added autocompletion with Tab key
+ added PageUp/PageDown keys to scroll faster
+ fix formatting of multiline text chunks
+ implement clipboard read/write with Ctrl+C and Ctrl+V (works best on OS X)
+ preserve current input and history on .clear
+ protect against invalid access on reaper/gfx tables (using X-Raym's workaround)
+ set global `_` variable to the first return value of last statement
+ support multi-line statements (like long functions, conditions...)


Last edited by cfillion; 07-14-2016 at 08:03 PM.
cfillion is online now   Reply With Quote
Old 07-14-2016, 08:33 PM   #8
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 4,099
Default

wow... I didn't know about this.
mind blown
amazing!
__________________
HeDaScripts for REAPER | VIP Donations
heda is offline   Reply With Quote
Old 07-14-2016, 09:34 PM   #9
semiquaver
Human being with feelings
 
Join Date: Jun 2008
Posts: 4,859
Default

my new favorite script
semiquaver is offline   Reply With Quote
Old 07-15-2016, 05:49 AM   #10
me2beats
Human being with feelings
 
me2beats's Avatar
 
Join Date: Jul 2015
Location: Yekaterinburg, Russia
Posts: 358
Default

omg wow
me2beats is offline   Reply With Quote
Old 07-15-2016, 06:09 AM   #11
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,173
Default

Neat.
IXix is offline   Reply With Quote
Old 08-17-2016, 06:25 PM   #12
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 1,208
Default

iReaScript v0.4

+ autocomplete partial matches
+ don't execute empty code input (v0.3 regression)
+ enhance formatting of string values
+ fix input of tildes
+ increase maximum buffer size to 2048 lines
+ limit maximum size of tables values when formatting
+ optimize layout by only computing new or modified text segments
+ preserve current input when using Ctrl+L shortcut
+ prevent cursor position from affecting text position
+ remove reaper/gfx proxy variable workaround (requires REAPER v5.23 [t=177319])
+ rewrite drawing & scrolling code
+ wait at least one second before blinking the cursor

Last edited by cfillion; 08-18-2016 at 12:19 PM.
cfillion is online now   Reply With Quote
Old 10-06-2016, 11:27 PM   #13
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 1,208
Default

iReaScript v0.4.1

+ fix auto-completion of exact matches
+ fix caret display in multiline input
+ improve how partially visible lines affect the scrollbar
+ remember docked state (use `gfx.dock(N)` to put in dock)

iReaScript v0.4.2

+ fix formatting of zero-indexed table
+ fix formatting of zero-sized (yet non-empty) tables
+ override global 'print' function
+ use braces instead of non-lua brackets for tables with numeric indexes

Last edited by cfillion; 10-07-2016 at 05:17 PM.
cfillion is online now   Reply With Quote
Old 11-29-2016, 04:12 PM   #14
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 1,208
Default

@TonE It's called "cfillion_Interactive ReaScript.lua" in the action list and ReaPack v1.0 (in v1.1 the "iReaScript" is also displayed).

Last edited by cfillion; 11-29-2016 at 04:29 PM.
cfillion is online now   Reply With Quote
Old 12-12-2016, 08:38 PM   #15
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 1,208
Default

iReaScript v0.5

+ add Copy/Paste/Clear/Dock/Close actions to the right click context menu
+ display errors using bold font
+ document the built-in functions and variables in .help
+ fix formatting of \t and \r in strings when they are followed by numbers
+ implement (fix) display of empty lines
+ remember window position, size and docked state
+ store every return values in _ global variable

iReaScript v0.6

+ allow .clear to be recorded in the history
+ do not crash on clipboard read/write failure (eg. 32-bit windows)
+ don't evaluate command/actions while in a lua block
+ implement !ACTION for Main actions, !!ACTION for MIDI Editor actions
+ remove extra newline inserted when executing an empty command since v0.5

Last edited by cfillion; 01-20-2017 at 04:26 PM.
cfillion is online now   Reply With Quote
Old 12-13-2016, 02:41 AM   #16
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,173
Default

Bravo!
IXix is offline   Reply With Quote
Old 02-17-2017, 01:31 AM   #17
Outboarder
Human being with feelings
 
Outboarder's Avatar
 
Join Date: Feb 2014
Posts: 610
Default

This is exactly what I need, Thank you.
__________________
Hope Sacred Passion Life Night Ache Soft Light
Outboarder is offline   Reply With Quote
Old 02-17-2017, 02:12 AM   #18
ceanganb
Human being with feelings
 
Join Date: May 2009
Location: Brazil
Posts: 270
Default

Very very useful tool, thanks.
__________________
Ceanganb
ceanganb is offline   Reply With Quote
Old 03-21-2017, 05:32 PM   #19
Airal
Human being with feelings
 
Join Date: Nov 2015
Posts: 376
Default

Very cool! Is there any way to have a default script run at startup? I could probably modify the code, but probably better for it to be done by the repository. Is there still a gfx issue? I assume the problem is due to the script itself using the gfx?
Airal is offline   Reply With Quote
Old 03-21-2017, 05:53 PM   #20
Airal
Human being with feelings
 
Join Date: Nov 2015
Posts: 376
Default

There seems to be some bugs in the script. When I execute the script in reaper it works fine but when I execute it in repl it fails iwth

attempt to compare nil with number.

I am simply trying to execute `reaper.CountTracks(0)`

and so it should work fine, this suggests it is a script. Other code works fine.

If I copy the code I'm using in to repl:

function NumTracks()
return reaper.CountTracks(0)
end

and then call it, it works fine.

Seems like some type of parsing issue of the library I'm importing using "require".

---

Ok, what it is, is that it is not loading the new library after I save it. Could we get an update that monitors any require's for changes(file size/hash) and if it changes to reload it automatically or to even restart the repl session if necessary?

repl is great for debugging but if it can't refresh after changes without requiring it to restart, it slows things down greatly.
Airal is offline   Reply With Quote
Old 03-21-2017, 07:31 PM   #21
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 1,208
Default

Quote:
Originally Posted by Airal View Post
Very cool! Is there any way to have a default script run at startup? I could probably modify the code, but probably better for it to be done by the repository.
Not currently. For now you might be interested with the `.` (dot) command which re-runs the previous code or the up/down arrows which navigate in the code history (TODO: save the history to file so it's not lost on the next startup).

Quote:
Originally Posted by Airal View Post
Is there still a gfx issue? I assume the problem is due to the script itself using the gfx?
Yes, until REAPER allows a single script to open multiple windows using gfx.

Quote:
Originally Posted by Airal View Post
There seems to be some bugs in the script. When I execute the script in reaper it works fine but when I execute it in repl it fails iwth

attempt to compare nil with number.

I am simply trying to execute `reaper.CountTracks(0)`
Perhaps the script you are loading is defining and using some local variables? If so, Lua erases those after the evaluation. This would explain the nil.
cfillion is online now   Reply With Quote
Old 03-22-2017, 09:05 AM   #22
Airal
Human being with feelings
 
Join Date: Nov 2015
Posts: 376
Default

Thanks. Could you had the ability for it to execute a simple script at startup automatically. e.g.,

iReaScriptStartup.lua

(if it exists in the scripts or lua dir it is executed automatically)

Should be simple to add(load file then parse it line by line as if the user typed it in)

By having that and the the history, it should work well. It would still require one to reload the script but it won't require a complete restart of the entire process like it does now.

Also, it would be nice if the `esc` key would clear the current line. It seems that the graphics window also loses focus when pasting which requires one to grab the mouse and reselect it... pretty annoying ;. Also, when starting the script for the first time, it loses focus.

It would be nice to do simple expressions.

e.g., one can't compute 1/3

I suppose this is because you are simply eval the expression as is. Maybe add a test for something like an expression and if the line seems like an expression(doesn't start with local, =, alpha, etc) then prepend a `local val =` to it then report the `value of val`. If it fails try executing the line directly(or vice versa).

Last edited by Airal; 03-22-2017 at 03:37 PM.
Airal is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:25 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.