New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: add project specific settings #107
Comments
I think there are two separate issues. One is that some of that functionality you are looking for is not implemented yet (for example, ability to pass command line options) or set the PATH. Second is that the behavior would need to be customized for that particular project. Also, if it is customized per project, it's likely needs to be restored when you switch the project, which means the previous state needs to be captured and preserved somewhere. As some of these features still need need to be implemented, I'll keep this request in mind when these features are being worked on, but will revisit when most of them are available. One question: is the primary goal of this project setup to simplify it for other people using the same project (in which case the configuration stored in an .ini file is not likely to work) or is this primarily for you to make switching between projects easier (in which case the exact mechanism used may not matter much)? |
Hi, I am struggling a bit with the same issue for first install of my conquest DICOM server. You want people to install the application, download ZBS, and then somehow merge ZBS with application specific interpreter and app files and then be up and running. Similar to the welcome page in ZBS but then tailored to a new application with its own interpreter. Marcel |
Hi Marcel, This is interesting; are the files you need to use from ZBS (like the interpreter) distributed together with your application? Or are they available as a separate package? I see two ways to facilitate the process:
In either case you can also provide additional customization, like setting the default interpreter to be the value you need (after it's installed or configured). The first option is probably more elegant, but if you need to keep making changes to the application and related scripts, the second one may be better. Another option would be to have something like a plugin that users would install and which would provide whatever configuration you need on top of ZBS, but this becomes somewhat similar to option 1, but the users are still in control what they download and install. Although this may all be different from what Thijs has in mind for his request... |
Hi, I would distribute the files with the application, as they are very small compared to the app. Both options are elegant but both need small changes to ZBS I think. Option 1 has my preference as it avoid typing command lines for the user. Marcel Van: Paul Kulchenko [notifications@github.com] Hi Marcel, This is interesting; are the files you need to use from ZBS (like the interpreter) distributed together with your application? Or are they available as a separate package? I see two ways to facilitate the process:
In either case you can also provide additional customization, like setting the default interpreter to be the value you need (after it's installed or configured). The first option is probably more elegant, but if you need to keep making changes to the application and related scripts, the second one may be better. Another option would be to have something like a plugin that users would install and which would provide whatever configuration you need on top of ZBS, but this becomes somewhat similar to option 1, but the users are still in control what they download and install. Although this may all be different from what Thijs has in mind for his request... — |
You should be able to try option 1 right now; I don't expect any issues even with the current code, but can tweak it if needed. Basically:
After you have the sequence, I'll help you wrap it into a command you can then expose it as a link in your instructions. |
Thanks, but not tonight (off to bed ;->>>) Marcel Van: Paul Kulchenko [notifications@github.com] You should be able to try option 1 right now; I don't expect any issues even with the current code, but can tweak it if needed. Basically:
After you have the sequence, I'll help you wrap it into a command you can then expose it as a link in your instructions. — |
Sure ;); For 2 and 3 you can run the following command: |
correct
priority 2 imo
priotity1 imo, new options available from 1, can then added here as they become available
it could be a one off configuration file, no need to store stuff when switching. It could simply be yet another file opened in the editor. Ideally (as with the other options/settings) a menu accessible GUI.
please put the second one somewhere top of the list, as several settings, like interpreter to use, are already available as global settings.
doesn't the approach cater for both? or am I missing something? My reason for bringing this up was the latter one; easier project switching. |
Hi, if you have different folders for the projects, project switching is easy in my experience. It is the initial setup of of an application and its project folder that I am trying to simplify as much as possible. I.e., copy zbs mobdebug.lua to app/lua folder optionally copy zbs socket to app/lua folder copy interpreter file from app/zbs to zbs copy app file from app/zbs to zbs select the newly installed interpreter set project folder to app/lua close any pages on zbs open the new app's welcome page (app/lua/welcome.lua) in zbs optionally open the rest of the demo lua files in zbs bring app/lua/welcome.lua to foreground restart zbs such that you can now immediately run the app first demo.It would be nice if is a menu option where you select an app folder which has e.g, a zerobrane.lua file, but manually loading it as lua script in zbs and then presssing twice would be a great start. Marcel Van: Thijs Schreijer [notifications@github.com] I think there are two separate issues. correct One is that some of that functionality you are looking for is not implemented yet (for example, ability to pass command line options) or set the PATH. priority 2 imo Second is that the behavior would need to be customized for that particular project. priotity1 imo, new options available from 1, can then added here as they become available Also, if it (ED: second one) is customized per project, it's likely needs to be restored when you switch the project, which means the previous state needs to be captured and preserved somewhere. it could be a one off configuration file, no need to store stuff when switching. It could simply be yet another file opened in the editor. Ideally (as with the other options/settings) a menu accessible GUI. As some of these features still need need to be implemented, I'll keep this request in mind when these features are being worked on, but will revisit when most of them are available. please put the second one somewhere top of the list, as several settings, like interpreter to use, are already available as global settings. One question: is the primary goal of this project setup to simplify it for other people using the same project (in which case the configuration stored in an .ini file is not likely to work) or is this primarily for you to make switching between projects easier (in which case the exact mechanism used may not matter much)? doesn't the approach cater for both? or am I missing something? My reason for bringing this up was the latter one; easier project switching. — |
This is as far as I got, I do not know well how to manipulate the ide. local zbs = ide.editorFilename |
It just occurred to me that I can just modify zeroBraneStudio.ini just after SettingsSaveAll() in the above install code to achieve all the missing bits. Is there a nice way to find its path? And of course the above code is just a sketch, a real installer would need to do lots of checks, for instance when orverwriting existign files. |
-- how to use this install code: open install.lua from the c:\dicomserver\zbs folder in zbs
-- select all and then right click - run in console
-- this code almost works; ide.settings = nil is necessary to stop zbs overwriting my just saved settings
-- but it crashes the IDE
-- please help, Marcel
local zbs = ide.editorFilename
zbs = string.gsub(zbs, 'zbstudio\.exe$', '')
local dcm = ''
for i,v in pairs(ide.openDocuments) do
if v.filePath then
if string.find(v.filePath, 'zbs\\install\.lua') then
dcm = string.gsub(v.filePath, 'zbs\\install\.lua', '')
end
end
end
wx.wxCopyFile(zbs .. 'lualibs\\mobdebug\\mobdebug.lua', dcm .. 'lua\\mobdebug.lua')
wx.wxCopyFile(zbs .. 'lualibs\\socket.lua', dcm .. 'lua\\socket.lua')
wx.wxCopyFile(dcm .. 'zbs\\conquest.lua', zbs .. 'api\\lua\\conquest.lua')
wx.wxCopyFile(dcm .. 'zbs\\conquestdicomserver.lua', zbs .. 'interpreters\\conquestdicomserver.lua')
wx.wxCopyFile(dcm .. 'zbs\\conquestdicomutil.lua', zbs .. 'interpreters\\conquestdicomutil.lua')
SettingsSaveAll();
ide.settings:SetPath('/editor')
ide.settings:Write('interpreter', 'conquestdicomserver')
ide.settings:SetPath('/projectsession')
for i=1, 100 do
local f, p = ide.settings:Read(tostring(i))
if f==nil then
ide.settings:Write(tostring(i), dcm .. 'lua')
break
end
if p==dcm .. 'lua' then break end
end
ide.settings:DeleteGroup('/session')
ide.settings:SetPath('/session')
ide.settings:Write('1', dcm .. 'lua\\welcome.lua')
ide.settings:Write('2', dcm .. 'lua\\livecoding.lua')
ide.settings:Write('3', dcm .. 'lua\\install.lua')
ide.settings:Write('index', 0)
ide.settings:Flush()
ide.settings = nil
wx.wxExecute(ide.editorFilename .. ' -cfg singleinstance=false', wx.wxEXEC_ASYNC);
os.exit() |
You need to remove local config = {appname='Conquest Dicom Server', api={'conquest.lua'}, interpreter={'conquestdicomserver.lua', 'conquestdicomutil.lua'}, interpretername='conquestdicomserver', |
-- Here is the complete script, it should be useable for any app
--[[ ---------------------------------------------------------------
This is a small installer script to enable editing and debugging [Lua](http://www.lua.org)
scripts for [Conquest Dicom Server](http://ingenium.home.xs4all.nl/dicom.html) (`V 1.4.17alpha up`) in the fantastic
[ZeroBrane Studio](http://studio.zerobrane.com) (`V 0.35 up`) development environment. Use as follows:
Open **ZeroBrane Studio** and look at the `Local console` tab
Load this **install.lua** file with `File - Open`
Select all text using `right-click - Select All`
Run it in the console using `right-click - Evaluate in Console`
After this - ZeroBrane Studio will reopen ready to run demo scripts
and develop for **Conquest Dicom Server**. As installed, Zerobrane Studio
communicates with a running Conquest Dicom Server and offers code
completion and full debugging facilities.
---------------------------------------------------------------- ]]--
local config = {appname='Conquest Dicom Server',
api={'conquest.lua'},
interpreter={'conquestdicomserver.lua', 'conquestdicomutil.lua'},
interpretername='conquestdicomserver',
tools={},
demos={'welcome.lua', 'livecoding.lua', 'nifty.lua'},
ds='\\',
installdir='ZeroBraneStudio'}
local z, ds = config.installdir, config.ds
-- Clear the local console tab for our messages
ide.frame.bottomnotebook.shellbox:ClearAll()
-- Detect ZeroBrane Studio Folder
local zbs = ide.editorFilename
zbs = string.gsub(zbs, 'zbstudio\.exe$', '')
print('Installing into ZeroBrane Studio at: ' .. zbs)
-- Detect app folder (assumes one app\zbs\install.lua is open in ide)
local app = ''; local installfile = z..ds..'install\.lua'
for i,v in pairs(ide.openDocuments) do
if v.filePath then
if string.find(v.filePath, installfile) then
app = string.gsub(v.filePath, installfile, '')
end
end
end
print(config.appname .. ' is at: ' .. app)
-- Copy file from to but do not replace newer one
function safecopy(file, from, to)
local ffr = GetFileModTime(from..file)
local fto = GetFileModTime(to..file)
if ffr==nil then
error('Cannot install file: ' .. from..file)
end
if fto==nil then
wx.wxCopyFile(from .. file, to .. file)
elseif GetFileModTime(from..file):GetTicks()>=GetFileModTime(to..file):GetTicks() then
wx.wxCopyFile(from .. file, to .. file)
print('Updated file: ' .. to..file)
else
print("Didn't replace newer file: " .. to..file)
end
end
-- install files from zbs to app
safecopy('mobdebug.lua', zbs..'lualibs'..ds..'mobdebug'..ds, app..'lua'..ds)
safecopy('socket.lua', zbs..'lualibs'..ds, app..'lua'..ds)
-- install files from app to zbs
for k,v in ipairs(config.api) do
safecopy(v, app..ds..z..ds, zbs..'api'..ds..'lua'..ds)
end
for k,v in ipairs(config.interpreter) do
safecopy(v, app..z..ds, zbs..'interpreters'..ds)
end
for k,v in ipairs(config.tools) do
safecopy(v, app..z..ds, zbs..'tools'..ds)
end
-- modify the main interpreter file to tell it where the conquest folder is
local f=io.open(zbs..'interpreters'..ds..config.interpreter[1], 'rt')
local s=f:read('*all'); s = string.format('local appdir = %q\n', app) .. s
f:close(); f=io.open(zbs..'interpreters'..ds..config.interpreter[1], 'wt')
f:write(s); f:close();
-- start setting the ZBS configuration
SettingsSaveAll();
ide.settings:SetPath('/editor')
ide.settings:Write('interpreter', config.interpretername)
-- add project folder
ide.settings:SetPath('/projectsession')
local f, org = ide.settings:Read(tostring(1))
for i=1, 100 do
local f, p = ide.settings:Read(tostring(i))
if f==false then
ide.settings:Write(tostring(i), org)
ide.settings:Write(tostring(1), app .. 'lua')
break
end
if p==app .. 'lua' then break end
end
-- prepare to open a list of documents
ide.settings:DeleteGroup('/session')
ide.settings:SetPath('/session')
for k, v in ipairs(config.demos) do
ide.settings:Write(tostring(k), app .. 'lua'..ds..v)
end
ide.settings:Write('index', 0)
ide.settings:Flush()
-- restart ZBS
print('Updated ZBS session; restarting ZBS in 2s'); wx.wxYield(); wx.wxSleep(2)
wx.wxExecute(ide.editorFilename .. ' -cfg singleinstance=false', wx.wxEXEC_ASYNC);
wx.wxSleep(1)
os.exit() |
If you replace ide.settings:Write(tostring(k), app .. 'lua'..ds..v) by ide.settings:Write(tostring(2_k-1), app .. 'lua'..ds..v) You can load samples both from the lua and the luasamples folder (using that invalid files are not loaded by zbs) |
@Tieske, I've been reviewing the open tickets and would like to get some clarification on this one. As we discussed earlier, it can be split into two parts: (1) have a mechanism to apply some settings on a per-project basis, and (2) make some of the settings more configurable. I think I have a solution for (1). I'm proposing a plugin that will keep track of project changes and will load As to (2), we can discuss which options are not (yet) modifiable from a config and how to enable that. Would this work? |
Sounds like a plan. Just a thought that popped up while going through this issue again; instead of
|
These are interesting ideas. To support (1) I'd need to allow multiple filenames to be provided and to process them in the order specified. Something like To support (2), I'd need to "catch" load request for that file, change the project folder instead and suppress opening of that file. This should all be doable with a plugin. You are still limited to whatever settings are processed in |
thx. looking forward to it! |
I'd like to second this feature request! One thing that this model provides is the ability to define multiple roots for the project tree. This is helpful in case 1 of @Tieske's original use case. I opened a case and then read this one more closely. Realising that it was duplicative, I closed it. I'll post my original thoughts: When I work on writing libraries, I sometimes work from different directories. This is especially true when I'm using a tool kit and for some reason, in the middle of my project, I need to modify something in that tool kit. In these cases, I wish that I could have the tool kit shown as a second root directory in my project view. Along with this, I'd like a simple Lua file that represented a project to ZBS. In this file, there could be any amount of valid ZBS configuration data, but the primary thing it would contain is the folders that the project should include. Some thoughts:
|
adding to @andrewstarks ;
I think it should be: user-project -> project -> user-system -> system. Or stated otherwise; have project and system settings, and for each a user variant that overrides the generic one. |
Yeah. You're right. The use case is: The project settings are in source control and then the user can have their version that is list in .gitignore. That is a great idea. |
Right, I was thinking about something as simple as having this as a default: The settings are applied in the order: system ( The tricky part is to save/restore settings when you switch projects as those are flattened into one table. I do have several options, just need to find the best one. |
The "easy" thing would be perhaps just to shut it down and reload with the new project. Or launch a new ZBS Process then the use can close the existing one. |
Yes, this can be done, but I'm looking for something a bit less invasive ;). I'll try saving and restoring settings first and they we can see what settings may be not reset correctly (and deal with them on a case-by-case basis). |
This is needed to take project configuration into account before files are loaded.
You'll need to use the plugin below and the latest code from project-settings branch. The default configuration file is .zbstudio/user.lua, but you can change this by setting The configuration is applied and then fully restored when you switch projects. Technically, any settings should work, but due to implementation details, some may not. For example, setting The plugin also adds one menu item |
Closing as project settings support has been merged into master. |
I have two ways for coding Lua
Especially for nr 2 I would like to have project specific settings. Things to be included for a project;
Adding those things in a
.zerobrane
file in the project root for example.The text was updated successfully, but these errors were encountered: