pkulchenko / ZeroBraneStudio

Lightweight Lua-based IDE for Lua with code completion, syntax highlighting, live coding, remote debugger, and code analyzer; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and other Lua interpreters on Windows, macOS, and Linux
http://studio.zerobrane.com/
Other
2.61k stars 519 forks source link

Feature request: select interpreter based on comment in first line of lua script #82

Closed marcelvanherk closed 11 years ago

marcelvanherk commented 11 years ago

Paul,

I often start zerobrane with the wrong interpreter. Would it be possible to allow a lua compatible unix-style shebang to the started script to select the correct one?

--#!Lua print(1)

or:

--#!deros -- do giderosstuff here

It may even be a nice feature to pass some application specific parameters there that are passed to the interpreter (this is mine, a closed source medical image processing application):

--#!Worldmatch(6)

Thanks,

Marcel

pkulchenko commented 11 years ago

Marcel, this is unlikely. The interpreter is currently used not only for Running/Debugging, but also for setting things like specs/apis, recognition of functions and some other things. It may be possible to set it right before running, but it creates some other problems (as it changes the state of the IDE by reloading configuration files).

Why do you start ZBS with the wrong interpreter? The interpreter should be saved on a per-project basis, so if you set it for a particular project, it will apply this setting when you switch projects as long as the project is listed in the project dropbox. Is it not working for you?

marcelvanherk commented 11 years ago

Hi Paul, I open lua files from the command line and by drag and drop, I totally missed the project feature. I will use it for a while and let you know.

Marcel

pkulchenko commented 11 years ago

Marcel, sounds good. I'll close the ticket for now, but feel free to re-open after you test project switching.

Also, this brings up an interesting point. Right now you can only open a file from the command line (or by drag and drop). It may be possible to also switch projects that way (by providing a path as a parameter, rather than a file name). Is it something that would make your workflow easier?

marcelvanherk commented 11 years ago

Hi Paul, this would work. I also just discovered the set project directory button - I had only been looking in menus. May be a good idea to add it to the project menu. Another question: how do you avoid that the turtle window reopens in scratchpad mode?

Regards, Marcel

pkulchenko commented 11 years ago

May be a good idea to add it to the project menu.

It used to be there. I've hidden it to keep the menu simpler ;). I'll consider bringing it back.

how do you avoid that the turtle window reopens in scratchpad mode?

Have a sequence of steps I can try to reproduce? I tried on a few turtle graphics examples on Windows, but they all work as expected.

marcelvanherk commented 11 years ago

Hi, I agree turtle works perfect; I run into this issue when I try to using livecoding for iup windows. I saw your moaib post (use initialize) and I guess turtle uses a similar mechanism inside.

Marcel


Van: Paul Kulchenko [notifications@github.com] Verzonden: maandag 26 november 2012 23:07 Aan: pkulchenko/ZeroBraneStudio CC: Marcel van Herk Onderwerp: Re: [ZeroBraneStudio] Feature request: select interpreter based on comment in first line of lua script (#82)

May be a good idea to add it to the project menu.

It used to be there. I've hidden it to keep the menu simpler ;). I'll consider bringing it back.

how do you avoid that the turtle window reopens in scratchpad mode?

Have a sequence of steps I can try to reproduce? I tried on a few turtle graphics examples on Windows, but they all work as expected.

— Reply to this email directly or view it on GitHubhttps://github.com/pkulchenko/ZeroBraneStudio/issues/82#issuecomment-10736237.

pkulchenko commented 11 years ago

I agree turtle works perfect; I run into this issue when I try to using livecoding for iup windows. I saw your moai post (use initialize) and I guess turtle uses a similar mechanism inside.

Got it; I misunderstood the question. Yes, there is little bit of help from the "turtles" library that you can reproduce.

First of all mobdebug will reset all "required" modules, so when you execute require "mymodule", then mymodule will be loaded again. This is used by the "turtle" library to call open() method which opens a new window. However, it saves the current frame in a global variable and then skips creating a new frame when there is an existing one (this is from turtle.lua):

  local function open(name)
  name = name or "Turtle Graphics Window"
  -- if the window is open, then only reset it
  if frame then
    if name then frame:SetTitle(name) end
    return reset()
  end

reset then clears the canvas among other initial setup tasks. You should be able to implement something similar for iup.

Use initialize advice may be specific to moai/love2d/gideros and other toolkits that use an external event loop to control re-drawing. Note that interpreters that support scratchpad have additional parameter scratchextloop that indicates whether a particular engine implements that external loop or not. "Lua" interpreter has it set to false, but others I listed have it set to true (if it's nil it means that scratchpad is not supported). I don't know the details of iup implementation, but it may be that this initialization check is similar to the shortcut I described earlier (in my case frame variable plays the same role as initialized in the moai example).

marcelvanherk commented 11 years ago

Hi,

just to tell you that once I got used to the project feature (slick), I no longer feel the need for selecting the interpreter based on the first line of code. I have written interpreters for an internal image processing application and for out public domain Conquest DICOM server. With the help of paul these now work very nice, hope the latest changes make it into the 0.34 release.

Marcel