Zerobrane studio скачать


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, LuaJIT and other Lua interpreters on Windows, MacOS, and Linux

ZeroBrane Studio is a lightweight cross-platform Lua IDE with code completion, syntax highlighting, remote debugger, code analyzer, live coding, and debugging support for various Lua engines (Lua 5.1, Lua 5.2, Lua 5.3, LuaJIT, LÖVE, Moai, Gideros, Corona, Marmalade Quick, Cocos2d-x, OpenResty/Nginx, Torch7, Redis, GSL-shell, Adobe Lightroom, Lapis, Moonscript, and others).

Features

  • Small, portable, and cross-platform (Windows, Mac OSX, and Linux).
  • Written in Lua and is extensible with Lua packages.
  • Syntax highlighting and folding for 110+ languages and file formats.
  • Project view with auto-refresh and ability to hide files and directories from the list.
  • Bundled with several of the most popular Lua modules (luasocket, luafilesystem, lpeg, and luasec) compiled for all supported Lua versions.
  • Auto-complete for functions, keywords, and custom APIs with scope-aware completion for variables.
  • Scope-aware variable indicators for Lua code.
  • Integrated debugger with local and remote debugging for Lua 5.1, Lua 5.2, Lua 5.3, LuaJIT, and other Lua engines.
  • Interactive console to directly test code snippets with local and remote execution.
  • Live coding with Lua, LÖVE, Gideros, Moai, Corona SDK, GSL-shell, and other engines.
  • Static analysis to catch errors and typos during development.
  • Function outline.
  • Go to definition navigation.
  • Multi-cursor editing with scope-aware variable selection and renaming.
  • Fuzzy search with Go To File, project-wide Go To Symbol navigation, and Insert Library Function.
  • Find and replace in multiple files with preview and undo.
  • Several ways to extend the current functionality:
    • packages (packages/): plugins that provide additional functionality;
    • translations (cfg/i18n/): translations of the menus and messages to other languages;
    • user configuration (cfg/): settings for various components, styles, color themes, and other preferences;
    • apis (api/): descriptions for code completion and tooltips;
    • interpreters (interpreters/): components for setting debugging and run-time project environment;
    • specs (spec/): specifications for file syntax, lexer, and keywords;
    • tools (tools/): additional tools.

Documentation

Installation

The IDE can be installed into and run from any directory. There are three options to install it:

No compilation is needed for any of the installation options, although the scripts to compile required libraries for all supported platforms are available in the build/ directory.

See the installation section in the documentation for further details and uninstallation instructions.

Usage

The IDE can be launched by using the zbstudio command with slight variations depending on whether a packaged installation or a repository copy is used:

  • Windows: Run zbstudio from the directory that the IDE is installed to or create a shortcut pointing to zbstudio.exe.
  • Linux: Run zbstudio when installed from the package installation or run ./zbstudio.sh when using a snapshot/clone of the repository.
  • Mac OSX: Launch the ZeroBrane Studio application if installed or run ./zbstudio.sh when using a snapshot/clone of the repository.

The general command for launching is the following: zbstudio [option] [<project directory>] [<filename>...].

  • Open files: zbstudio <filename> [<filename>...].
  • Set project directory (and optionally open files): zbstudio <project directory> [<filename>...].
  • Overwrite default configuration: zbstudio -cfg "string with configuration settings", for example: zbstudio -cfg "editor.fontsize=12; editor.usetabs=true".
  • Load custom configuration file: zbstudio -cfg <filename>, for example: zbstudio -cfg cfg/xcode-keys.lua.

All configuration changes applied from the command line are only effective for the current session.

If you are loading a file, you can also set the cursor on a specific line or at a specific position by using filename:<line> and filename:p<pos> syntax (0.71+).

In all cases only one instance of the IDE will be allowed to launch by default: if one instance is already running, the other one won't launch, but the directory and file parameters passed to the second instance will trigger opening of that directory and file(s) in the already started instance.

Contributing

See CONTRIBUTING.

Author

ZeroBrane Studio and MobDebug

ZeroBrane LLC: Paul Kulchenko ([email protected])

Estrela Editor

Luxinia Dev: Christoph Kubisch ([email protected])

Where is Estrela?

The Estrela project that this IDE is based on has been merged into ZeroBrane Studio. If you have used Estrela for graphics shader authoring, you can use this GraphicsCodePack to get access to all API files, specifications and tools.

License

See LICENSE.

github.com

Features - ZeroBrane Studio - Lua IDE/editor/debugger for Windows, Mac OSX, and Linux

Open source Written in Lua. Extensible and open.

Cross-platform Windows, MacOS, and Linux: your choice.

Portable Run it from any folder. No installation required.

Lightweight Run it without fearing it will take over your computer.

Extensible 50+ plugins in the package repository; add your own.

Scope aware selection Select instances of a variable in the current scope with Ctrl/Cmd-DblClick. Type a new name.

Go to definition Go to a local variable/function definition. Navigate back using the history of saved positions.

Multi-cursor editing Select and edit at multiple cursor positions at the same time using Ctrl/Cmd-Click and Ctrl/Cmd-Select.

Small With the Windows and MacOS installation packages being around 6MB, it is one of the smallest if not the smallest fully featured IDE.

Configurable Tabs or spaces? 2 or 4? As everyone has its own preferences, ZeroBrane Studio gives you sensible defaults and a way to change them.

Instantly usable Ever opened a new tool and didn’t know where to start? ZeroBrane Studio provides integrated lessons on how to use it and over 50 demo scripts to get you started.

Debug any Lua application Set breakpoints before or during debugging. Step in, over, and out. Run to cursor, break and continue your script. Review the call stack. Inspect and modify variables.

Unicode friendly Edit files in Unicode and run scripts with Unicode file names.

Function and expression calltip Quickly access function description or variable/expression values while debugging.

Static analyzer Detect typos, non-localized variables, and unused parameters before running your code.

Auto-complete Use auto-complete to save time on typing API functions and variable names (scope-aware).

Multi-file editing Keep as many files open as you need and navigate them using the file browser or the editor tabs.

Color scheme support Use one of the provided color schemes (Tomorrow, Zenburn, Solarized and others) or create your own.

Function outline Review and navigate all functions (and their parameters) defined in the current file, including anonymous ones.

Watch view Evaluate variables and expressions (including tables) after every step of the debugger. Expand tables and modify the values.

Live coding Execute your application as you are coding it. Detect syntax and run-time errors quickly; change numeric parameters on the fly with sliders.

Pretty printing If for k,v in pairs(tbl) do print(k,v) end works for you, you will not miss the integrated pretty printing of any value in a line or block form.

Translatable interface Use one of the provided translations (English, French, Spanish, Russian, German, Chinese, Esperanto, Italian, and Brazilian Portuguese) or create your own.

Project file browser Don’t worry about creating a new project, simply open a folder. The current file will be highlighted in the project tree (as long as it is in one of the subfolders).

Custom interpreters Want to integrate ZeroBrane Studio with your own Lua engine? If none of the provided interpreters work for you, you can write your own as some of the users have done.

Stack view Explore not only the call stack with function names, but also all local variables and upvalues for each of the stack frames. Drill down to get values of individual elements in tables.

Interactive console Want to test something quickly? Run it in the console with full access to your application state and all variables; execute code fragments and change variable values without restarting your application.

studio.zerobrane.com

Getting Started - ZeroBrane Studio

Editor

The editor allows you to open several programs or files and work on them at the same time. Each file is opened in its own page, with its name in a tab at the top of the page. You can switch between pages by clicking on those tabs. You can also close those pages when you don’t need them by using the File | Close Page menu command or its shortcut Ctrl-W (Cmd-W on MacOS).

Opening and saving files

To open a program or file you can select the File | Open menu command or use its shortcut Ctrl-O (Cmd-O on MacOS). Or, you can double click on the file name in the Project panel on the left. The editor will open that file for you in a new tab, or will activate one of the existing tabs if the file is already opened.

To save a program you can select the File | Save menu command at the top of the window or use its shortcut Ctrl-S (Cmd-S on MacOS). If the program does not have a name yet, you will be asked to provide a name for it.

Exiting the IDE

To exit ZeroBrane Studio, select the File | Quit menu command. You will be prompted to save any unsaved changes. The IDE will restore the editor tabs you are using the next time you start it.

Running programs

To execute a program you can select Project | Run menu command. This will run your program in a separate process using the interpreter you selected to run it; by default this is the Lua interpreter, which executes your code in LuaJIT. The Output window will show the output of the program (if any) and some messages from the IDE that detail what script is being executed and from what directory.

To abort the program from the IDE you can go to Project | Stop Process. You will see a message in the Output window when the program is stopped.

Output window

The Output window captures the output of the programs you run, plus any errors and additional messages you may get during execution of those programs.

The Output window is also used to enter the text your program may read. You will see a prompt in the Output window where the text is expected to be entered.

Console window

The Console window allows you to run Lua code fragments and calculate values of Lua expressions. It will switch automatically between a local console that gives you access to the Lua interpreter that runs the IDE and a remote console that allows you to execute code fragments and change variable values in your application when it is stopped in the debugger.

Project directory

The current project directory is displayed in the Project panel. The project panel helps you in several ways: it provides a bird’s-eye view of all files in your project, it highlights the file you are working with (as long as it is in the same project), and it allows you to open a file by selecting its name and pressing Enter, or double-clicking on it.

To change the current project directory you have several options:

  1. use the dropdown to select one of the project directories you used previously,
  2. type or copy a new path into the dropdown at the top of the project panel,
  3. go to Project | Project Directory | Choose... and set a new directory, or
  4. go to Project | Project Directory | Set From Current File to set it to the same directory as the path of the current file.

Selecting interpreter

ZeroBrane Studio provides support for different Lua engines that may require different parameters or settings when running or debugging. The settings are specified by interpreters that can be selected by going to Project | Lua Interpreter and selecting an interpreter you need from the list. This not only sets the environment for running and debugging of your application, but also auto-complete, scratchpad, and other engine-dependent settings.

When you switch a project directory, the currently selected interpreter is saved and restored when you switch back to the current project. The current interpreter is shown on the right side of the status bar (for example, in the screenshot on the right Moai interpreter is selected).

Debugging programs

In addition to running programs you can also debug them, which gives you the ability to pause them, inspect variables, evaluate expressions, make changes to the values, and then continue. To start debugging go to Project | Start Debugging. Depending on your interpreter configuration, the debugger may stop your program on the first instruction (this is a default for most interpreters) or may execute it immediately (as configured for Moai and Corona interpreters).

When your program is running, you can pause it by going to Project | Break, which will stop your program at the next lua command executed.

When the debugger is stopped, you can set/remove breakpoints (using Project | Toggle Breakpoint), step through the code (using Project | Step Into, Project | Step Over, and Project | Step Out commands), inspect variables using the Watch window (View | Watch Window), view the call stack using the Stack window (View | Stack Window), run Lua commands in the console, run to cursor location (Project | Run To Cursor), and continue execution of your program (using Project | Continue).

Stack window

The Stack window provides not only the call stack with function names, but also presents all local variables and upvalues for each of the stack frames. You can even drill down to get values of individual elements in tables.

Watch window

The Watch window provides a convenient way to evaluate variables and expressions after every stopping in the debugger. You can also drill down to get values of individual elements in tables.

In addition to viewing the values that variables or expressions are evaluated to, you may also change the values of those variables or expressions and those changes will be reflected in the current stack frame of the application. For example, if tbl is a table with three values ({'a', 'b', 'c'}), you can expand the table, right click on the second element, and select Edit Value. You can then edit the value of the second element. After entering the new value and pressing Enter, the new value will be sent to the application being debugger and will also be reflected in the Watch window. The result is equivalent to executing tbl[2] = "new value" in the Console window, but provides an easy way to update the value without retyping the expression.

Outline window

The Outline window provides a way to see the structure of the current file with all the functions and their parameters shown either in the order in which they are defined in a file (default) or as a sorted list.

Clicking on the function name will scroll the file to the position where the function is defined. Anonymous functions are indicated using ~ for the name. There are several settings specific to display of the outlines, as documented in the Outline section.

Live coding

Live coding (also known as Running as Scratchpad) is a special debugging mode that allows for the changes you make in the editor to be immediately reflected in your application. To enable this mode go to Project | Run as Scratchpad (when it is available) and your program will be started as during debugging. You will continue to have access to the editor tab from which the scratchpad has been started and all the changes you make will be seen in your application.

In addition to regular editing, you can also mouse over a number (all numbers will be underlined as seen in the screenshot on the right) and drag a virtual slider left or right to change the value of that number. If you make an error (whether a compile or run-time), it will be reported in the Output window.

To exit the scratchpad mode you can close the application, go to Project | Stop Process, or go to Project | Run as Scratchpad again to toggle scratchpad mode off.

Note that this functionality is highly interpreter dependent and some interpreters may not provide it at all and some may provide in a way that doesn’t restart the entire application (for example, LÖVE, Moai, or Gideros interpreters). Your code may also need to be written in a way that accomodates requirements of those engines. Please consult live coding tutorials for details.

Some of the most frequently used commands in the editor are also available on the toolbar (which is right above the editor window, and below the menu bar on Windows and Linux). There you will find commands to open a new or existing file, or save a file, commands to undo and redo your changes, and commands to search and replace text in your programs.

You will also find the most frequently used debugger commands (Start Debugging, Stop process, Break, Step Into, Step Over, Step Out, Toggle Breakpoint, Stack Windows, and Watch Window). The toolbar also includes a dropdown that lists all the functions recognized in the currently edited file and allows to navigate between those functions by selecting them from the list.

Configuring the IDE

The default settings and layout should work for most users, but occasionally you may want to have more space available on the screen or prefer to have a window moved to a different position.

You can close the Project and Output/Console windows if you are not using them to get more screen space. You can switch back to the default by using View | Default Layout.

You can resize the windows by dragging the splitters between them. You can also move the windows by clicking and holding the mouse on the window caption area and dragging the window to a new location. You can release the mouse when one side of the main window changes its color to light blue. The new configuration will then be used until you reset or change it.

You can change the color scheme, general preferences, editor preferences, and the IDE keymap.

Extending the IDE

In addition to the functionality included by default, there are also 50+ extension packages in the package repository, including packages like DocumentMap, UniqueTabName, CloneView, ProjectSettings, SyntaxCheckOnType, and many others. You can create your own package (or modify an existing one) by following the plugin documentation.

studio.zerobrane.com

Frequently Asked Questions - ZeroBrane Studio

What are the dotted and dashed lines under variable names?

These are scope indicators: global variables are marked with solid underlines, local variables are maked with dotted underlines, local variables that shadow other local variables in the same scope are marked with dashed underlines, and those local variables that are shadowed by other local variables are striken out. For example, in local foo = 1; local foo = 2, first foo variable will be striken out as it’s shadowed by the second foo instance and the second foo variable will be marked with dashed underline.

You can change their types, colors, or disable them.

How to specify a directory my script should be executed in for require commands to work?

You can set the project directory, which will be used to set the current directory when your application is run or debugged.

Why stepping into function calls doesn’t work in some cases?

You need to have a file opened in the IDE before you can step into functions defined in that file. You can also configure the IDE to auto-open files for you.

How to refresh the files shown in the Project tree after the changes made outside of the IDE?

(1.40+) All the changes in the file system will be reflected in the Project tree when they happen in the folders expanded in the tree. You can still refresh the Project tree content manually when it gets out of sync by using Refresh item in the Project tree local menu (activated with right click on an item). If you are using one of the earlier versions, you can check Refresh Project plugin (Windows only).

Why do I get a warning about attempt to connect to port 8172 when I start debugging?

The IDE is using port 8172 to communicate with the application being debugged. If you get a firewall warning, you need to allow the connection for the debugging to work properly.

Why am I getting “could not connect to …:8172” message?

This may happen for several reasons:

  • You start your application that uses require('mobdebug').start() call to connect to the IDE, but the debugger server is not started in the IDE. You can fix this by selecting Project | Start Debugger Server; if it is disabled, the server is already started.
  • Your firewall is configured to block connection to port 8172, which is used by the IDE to communicate with the application you are debugging. You need to allow this connection for the debugging to work.
  • In rare cases the IDE may incorrectly detect the hostname of the computer it runs on, which may prevent the debugging from working. The hostname is shown in the Output window when the debugging is started: Debugger server started at <hostname>:<port>. You can use a different hostname by setting debugger.hostname value in the configuration file. For example, if the default hostname is incorrect, try setting it to localhost by using debugger.hostname = "localhost".
  • You may be on VPN, which may block connections or cause the IDE to incorrectly detect the hostname. You may configure debugger.hostname as described above to see if this resolves the issue.

Why breakpoints are not triggered?

Breakpoints set in source files may not work for several reasons:

  • A breakpoint may be inside a coroutine; by default breakpoints inside coroutines are not triggered. To enable debugging in coroutines, including triggering of breakpoints, you may either (1) add require('mobdebug').on() call to that coroutine, which will enable debugging for that particular coroutine, or (2) add require('mobdebug').coro() call to your script, which will enable debugging for all coroutines created using coroutine.create later in the script.
  • If you enable coroutine debugging using require('mobdebug').coro(), this will not affect coroutines created using C API or Lua code wrapped into coroutine.wrap. You can still debug those fragments after adding require('mobdebug').on() to the coroutine code.
  • The path of the file known to the IDE may not be the same as the path known to the Lua engine. For example, if you use an embedded engine, you may want to check if the path reported by the engine is normalized (doesn’t include ../ references) by checking the result of debug.getinfo(1,"S").source.
  • The capitalization of the file known to the IDE may not be the same as the capitalization of the file known to the Lua engine with the latter running on a case-sensitive system. For example, if you set a breakpoint on the file TEST.lua in the IDE running on Window (case-insensitive), it may not fire in the application running test.lua on Linux (with case-sensitive file system). To avoid this make sure that the capitalization for your project files is the same on both file systems.
  • The script you are debugging may change the current folder (for example, using lfs module) and load the script (using dofile) from the changed folder. To make breakpoints work in this case you may want to use absolute path with dofile.
  • You may have a symlink in your path and be referencing paths to your scripts differently in the code and in the IDE (using a path with symlink in one case and not using it in the other case).
  • You may be using your own Lua engine that doesn’t report file names relative to the project directory (as set in the IDE). For example, you set the project directory pointing to scripts folder (with common subfolder) and the engine reports the file name as myfile.lua instead of common/myfile.lua; the IDE will be looking for scripts/myfile.lua instead of scripts/common/myfile.lua and the file will not be activated and the breakpoints won’t work. You may also be using inconsistent path separators in the file names; for example, common/myfile.lua in one case and common\myfile.lua in another.
  • If you are loading files using luaL_loadbuffer, make sure that the chunk name specified (the last parameter) matches the file location.
  • If you set/remove breakpoints while the application is running, these changes may not have any effect if only a small number of Lua commands get executed. To limit the negative impact of socket checks for pending messages, the debugger in the application only checks for incoming requests every 200 messages (by default), so if your tests include fewer messages, then pause/break commands and toggling breakpoints without suspending the application may not work. To make the debugger to check more frequently, you can update checkcount field (require('mobdebug').checkcount = 1) before or after debugging is started.
  • If breakpoints are still not working, you may want to enable verbose debugging (debugger.verbose=true) as this will provide additional information about paths reported by the interpreter and used by the IDE.

Why stepping into coroutines doesn’t work?

See this section in the documentation for details on how to enable it.

Is it possible to debug dynamic fragments loaded with loadstring()?

Yes; starting from v0.38 if you step into loadstring() call, the IDE will open a new window (when editor.autoactivate is enabled) with the code you can then step through. As an alternative, you can specify a filename as the second parameter to loadstring (also as the absolute or relative path) and have that file in your project directory with the same content as what’s loaded with loadstring.

You can then open that file in the IDE or configure it to auto-open it for you.

There is one caveat with debugging of fragments loaded with loadstring: one-line code fragments will be interpreted as filenames. To make them recognized as the code fragment, just add a new line or make it more than one line long.

Is debugging of Lua 5.2 applications supported?

Yes; see Lua 5.2 debugging section for details.

Is debugging of Lua 5.3 applications supported?

Yes; see Lua 5.3 debugging section for details.

Is debugging of LuaJIT applications supported?

Starting from v0.35 the debugging of LuaJIT applications is supported out-of-the-box. See LuaJIT debugging section for details.

Is debugging of 64bit applications supported?

Yes; even when you use a 32bit version of the IDE, you can still run and debug 64bit applications. See Debugging of 64bit applications section for details.

Why am I getting compilation errors in the IDE when my code runs fine outside of it?

Starting from v0.39, ZeroBrane Studio is using LuaJIT as its internal Lua engine. LuaJIT is a bit more strict than Lua 5.1 in some checks and may return errors even when your application runs fine by Lua 5.1. One typical example is string escape sequences. Lua 5.1 lists escape sequences it recognizes, but it will accept other sequences as well, for example, \/. Running a script with this escape sequence under LuaJIT will trigger an error: invalid escape sequence near ....

The solution in this case is to “fix” the escape sequence and replace \/ with /, which will have the same effect in Lua 5.1, LuaJIT, and Lua 5.2.

How to open file and position cursor to a specific line or position in the file?

When launching the IDE and passing a filename as a parameter, it’s possible to include the line number (using filename:<line>) and position (using filename:p<pos>) in the file. After the file is opened, the cursor will be moved to the specified position or the beginning of the specified line.

How to search or replace with regular expressions?

To search or replace using regular expressions, you can toggle Regular expression icon on the search panel toolbar. These regular expressions do not accept Lua character classes that start with % (like %s, %d, and others), but accept . (as any character), char-sets ([] and [^]), modifiers + and *, and characters ^ and $ to match beginning and end of the string. Regular expressions only match within a single line (not over multiple lines). See Scintilla documentation for details on what special characters are accepted.

How to replace using captures in regular expressions?

(0.39+) When regular expression search is used with search and replace, \n refer to first through ninth pattern captures marked with brackets (). For example, when searching for MyVariable([1-9]) and replacing with MyOtherVariable\1, MyVariable1 will be replaced with MyOtherVariable1, MyVariable2 with MyOtherVariable2, and so on.

Why is the text blurry when running on Windows 8?

Right-click on ZeroBrane Studio icon -> Properties -> Compatibility -> "Disable display scaling on high DPI settings". See the link in this ticket for alternative solutions if this doesn’t work.

(1.11+) If you are using v1.11 or later, this may no longer be needed as the IDE launcher (zbstudio.exe) enables dpi awareness by default. (1.40+) HiDPI awareness has also been enabled for Lua executables for all supported versions. You may still need to enable it for other executables (not included with the IDE) as needed to make the applications you start from the IDE dpi-aware as well.

Why is the text blurry in the editor when running on retina display (MacOS)?

You can set hidpi = true in configuration settings; this setting is enabled by default on MacOS starting from v0.60.

(1.30 and earlier) Note that using this setting negatively affects indicators that have alpha property (the indicators are not shown when this setting is enabled).

How to change background color in the editor?

You can specify styles.text.bg = {240,240,240} in configuration settings. See the example. To modify colors and appearance of IDE elements, check documentation on styles and color schemes.

How to change the color scheme in the editor?

You can open cfg/scheme-picker.lua in the IDE and click on links with color scheme names to test included schemes. These schemes can be configured as shown in user-sample.lua.

For more information on how to modify colors and appearance of IDE elements, check documentation on styles and color schemes.

How to accept keyboard input for applications started from the IDE?

(No longer necessary for 1.21+) You need to output something using print or io.write before reading input. You will see a prompt in the Output window where you can enter your input.

If you launch the application outside of the IDE, make sure you flush the printed output (or use io.stdout:setvbuf('no')) before accepting the input.

Lua (and some engines based on it, like LÖVE) has output buffered by default, so if you only print a small number of bytes, you may see the results only after the script is completed.

If you want to see the print output immediately, add io.stdout:setvbuf("no") to your script, which will turn the buffering on. There may be a small performance penalty as the output will be flushed after each print, so keep that in mind.

How to pass command line arguments?

This is described in the command line parameters section.

Where is the configuration file stored?

This is covered in the description of system configuration.

How can I modify a key mapping?

To modify a key mapping for a particular menu item, see the key mapping section. You may also review xcode-keys configuration file that can be used to modify keyboard shortcuts to match those in XCode.

Why am I getting a warning about “invalid UTF8 character” in the files I open in the editor?

(1.30 and earlier) You probably have files created using one of Microsoft Windows code pages; most likely 1252, 936, or 950. ZeroBrane Studio is using UTF-8 encoding, which allows users to use any supported language, but the files need to use Unicode encodings. If you want to continue editing this file in the IDE, you have two choices:

  1. Ignore the warning and change [SYN] characters to whatever text you need inside ZeroBrane Studio.
  2. Convert your files from the encoding you are using to UTF-8 (65001) and then load them into the IDE.

How do I run multiple instances of ZeroBrane Studio?

You can start multiple instances if you disable “single instance” check either by adding singleinstance=false to the configuration file or by starting the second instance with the following command: zbstudio -cfg "singleinstance=false".

The single instance check is disabled on MacOS by default; to run multiple instances, you need to use open -n ZeroBraneStudio.app.

How do I start two ZeroBrane Studio instances to debug two applications at the same time?

You can start one instance as you normally do and then start the second instance using the following command: zbstudio -cfg "singleinstance=false; debugger.port = 8173". This command disables a singleinstance check for the second instance and configures it to use port 8173 for debugging. You can then use require('mobdebug').start("domain-name", 8173) in your application to connect to the second instance for debugging.

If you use MacOS, you may need to run the command as open -n ZeroBraneStudio.app --args -cfg "debugger.port = 8173".

How do I restore default configuration for UI elements?

If you made changes by moving panels/windows around and want to undo them, you can restore the original UI configuration by selecting View | Default Layout.

How do I merge or split windows and tabs?

To merge or split windows and tabs and to change their positions, check the section in the Tips and Tricks document.

How do I restore default configuration for recent files, projects, and editor tabs?

You can remove the configuration file ZeroBrane Studio is using to store these settings.

(This restriction has been removed in v1.20) Formatted comments allow usage of Markdown formatting, which uses styles with hidden characters. Those characters can’t be deleted with some of the delete operations (line ‘cut’ or ‘delete selection’) and need to be deleted using Delete or Backspace.

I’m getting a message about mixed end-of-line sequences. How do I make them visible?

You may run GetEditor():SetViewEOL(1) in the local console; you will see end-of-line sequences marked as CR, LF, or CRLF. Re-open the document or run GetEditor():SetViewEOL(0) to disable showing end-of-line sequences.

How to make the current line more visible during debugging?

You can try changing the current line marker to something more visible, like underline by adding the following code to the configuration file: styles.marker.currentline.ch = wxstc.wxSTC_MARK_UNDERLINE. You can also change the color and the type of the marker: styles.marker.currentline = {ch = wxstc.wxSTC_MARK_UNDERLINE, bg = {0, 0, 255}} (this will set the background to blue).

Where do I find the list of functions in the current file?

(0.90+) The list of functions is shown in the Outline tab located next to the Project tab. The content of the Outline can be configured in various ways.

(0.80 and earlier) The list of functions was available through the dropdown in the toolbar.

How to set the edge in the editor at a particular column?

(1.61+) You can set editor.edge = true or editor.edge = 76 to mark the edge at a specific column (80 is the default). See editor settings for details.

With earlier versions you can use the edgemark plugin.

Why not all upvalues are shown in the debugger?

Upvalues shown in watch/console/stack windows will only include those upvalues that are used or referenced in the current function. For example, if you step into function abc from the following fragment – local a, b = 1, 2; function abc() print(a) end – then only a variable will be listed as the upvalue. If you try to access the value of b in the Watch or the Console window, you’ll get nil as that upvalue is not present in the scope of that function.

Why am I getting mach-o, but wrong architecture error on MacOS?

You may be trying to load a 64bit module using Lua executable that is included with the IDE. Since the Lua executable is 32bit, you get the error about incompatible architectures.

To avoid this issue you need to configure the IDE to use your own 64bit Lua executable by setting path.lua = '/full/path/lua-executable' in the configuration.

Note that you can still use the IDE to debug your applications as the luasocket library required for debugging is compiled as universal binary and can be loaded into both 32bit and 64bit applications.

How do I select a main file to use with Run or Debug commands?

By default the execution of the project starts with the file in the current editor tab (at least with the default Lua interpreters). If you want to start the execution from a different file, you may set it using the following steps:

  1. selecting the file in the Project panel,
  2. right-click with the mouse to open the popup menu, and
  3. using Set As Start File.

This will set the selected file as the start file; the file will have a different icon to help distinguish it from other files. You can later change it to a different file or unset by selecting Unset .... As Start File from the same menu.

How do I show Corona SDK Console window on Windows?

(0.81+) You may set corona = {showconsole = true} in system or user configuration. See all Corona-specific preferences for details.

(0.80 and earlier) You may add the following line to system or user configuration: unhidewindow.ConsoleWindowClass = 0.

studio.zerobrane.com

Lua Debugging - ZeroBrane Studio

General debugging

The debugger allows to execute Lua scripts and applications step by step, pause them, inspect variables, evaluate expressions, make changes to variables, and then continue execution. To start debugging go to Project | Start Debugging. Depending on your interpreter configuration, the debugger may stop your program on the first instruction (this is a default for most interpreters) or may execute it immediately (as configured for Moai and Corona interpreters).

When your program is running, you can pause it by going to Project | Break, which will stop your program at the next lua command executed.

When the debugger is stopped, you can set/remove breakpoints (using Project | Toggle Breakpoint), step through the code (using Project | Step Into, Project | Step Over, and Project | Step Out commands), inspect variables using the Watch window (View | Watch Window), view the call stack using the Stack window (View | Stack Window), run Lua commands in the console, run to cursor location (Project | Run To Cursor), and continue execution of your program (using Project | Continue).

Live coding

Live coding (also known as Running as Scratchpad) is a special debugging mode that allows for the changes you make in the editor to be immediately reflected in your application. To enable this mode go to Project | Run as Scratchpad (when it is available) and your program will be started as during debugging. You will continue to have access to the editor tab from which the scratchpad has been started and all the changes you make will be seen in your application.

In addition to regular editing, you can also mouse over a number (all the number in your script will be underlined as you can see in the screenshot on the right) and drag a virtual sliders left or right to change the value of that number. If you make an error (whether a compile or run-time), it will be reported in the Output window.

To exit the scratchpad mode you can close the application, go to Project | Stop Process, or go to Project | Run as Scratchpad.

Note that this functionality is highly interpreter dependent and some interpreters may not provide it at all (for example, Corona) and some may provide in a way that doesn’t restart the entire application (for example, LÖVE, Moai, or Gideros interpreters). Your code may also need to be written in a way that accomodates requirements of those engines. Please consult live coding tutorials for details.

Console window

The Console window allows to run Lua code fragments and calculate values of Lua expressions. It will switch automatically between a local console that gives you access to the Lua interpreter that runs the IDE and a remote console that allows you to execute code fragments and change variable values in your application when it is stopped in the debugger.

You can execute any expression in the console and the result will be pretty printed for you. You can also do =expression to pretty print the results in the block form.

Stack window

The Stack window provides not only the call stack with function names, but also presents all local variables and upvalues for each of the stack frames. You can even drill down to get values of individual elements in tables.

Watch window

The Watch window provides a convenient way to evaluate variables and expressions after every stopping in the debugger. You can also drill down to get values of individual elements in tables.

In addition to viewing the values that variables or expressions are evaluated to, you may also change the values of those variables or expressions and those changes will be reflected in the current stack frame of the application. For example, if tbl is a table with three values ({'a', 'b', 'c'}), you can expand the table, right click on the second element, and select Edit Value. You can then edit the value of the second element. After entering the new value and pressing Enter, the new value will be sent to the application being debugger and will also be reflected in the Watch window. The result is equivalent to executing tbl[2] = "new value" in the Console window, but provides an easy way to update the value without retyping the expression.

In addition to being able to use the Console or the Watch window to see the values of variables and expressions, you can also mouse over a variable (or select an expression and mouse over it) during debugging to see its value.

The value is shown for the simplest expression the cursor is over; for example, if the cursor is over ‘a’ in foo.bar, you will see the value for foo.bar, but if the cursor is over ‘o’ in the same expression, you’ll see the value of foo instead. You can always select the expression to be shown in the tooltip to avoid ambiguity.

How debugging works

Even though there are different ways to start debugging in the IDE, all of them work the same way: the debugger component is loaded into the application being debugged and establishes a socket connection to the IDE. The IDE then accepts user commands (step, set breakpoint, remove breakpoint, evaluate an expression, and so on) and sends those commands to the debugger component in the application and receives the results back (if any).

When the application is suspended because of a step command, break command, or a breakpoint, the IDE will attempt to find and activate a source file where the application is suspended. If the file is already opened in the IDE, it will be activated with the current line marker (green arrow by default) pointing to the location of the statement executed next. If the file is not opened in the IDE, but the IDE is configured to auto-activate files (editor.autoactivate = true), the file will be loaded into the IDE.

See remote debugging section of the documentation for details on how to configure and initiate debugging from your application.

Turning debugging off and on

You may notice that in some cases the application you are debugging runs much slower than without debugging; when you run it without the debugger the speed is likely to be three to ten times faster. This may be okay for many situations, but in some cases when the application is complex, things may get slow.

The debugger provides two methods that allow you to temporarily turn the debugging on and off. If you turn it on/off right around where the changes need to be applied, you can get almost the same performance you see without the debugger.

For example, let’s say you have a bodyCollision function where you check for collisions and you want to break when a body collision is detected. You can turn the debugging off (require("mobdebug").off()) right after starting debugging (using require("mobdebug").start()) and then turn it on and off around the section you are interested in:

function bodyCollision(event) local target = event.target if event.phase == "began" then require("mobdebug").on() --<-- turn the debugger on -- do whatever else needed for collision handling require("mobdebug").off() --<-- turn the debugger off end end

If you set a breakpoint somewhere between on() and off() calls, it will fire as expected. The rest of the application will be running with a “normal” speed in this case (you can see the difference if you remove all off() calls).

Coroutine debugging

The debugging of coroutines is disabled by default. To enable debugging in coroutines, including stepping into resume/yield calls and triggering of breakpoints, you may do one of the following:

  • add require('mobdebug').on() call to that coroutine, which will enable debugging for that particular coroutine, or
  • add require('mobdebug').coro() call to your script, which will enable debugging for all coroutines created using coroutine.create later in the script.

If you enable coroutine debugging using require('mobdebug').coro(), this will not affect coroutines created using C API or Lua code wrapped into coroutine.wrap. You can still debug those fragments after adding require('mobdebug').on() to the coroutine code.

studio.zerobrane.com

Configuration - ZeroBrane Studio - Lua IDE/editor/debugger for Windows, Mac OSX, and Linux

ZeroBrane Studio uses Lua files to allow users to modify its default settings and to set editor color scheme, UI language, paths to executables, and other general and editor preferences. These configuration files can be specified in three ways: system-wide, per user, and via command line. The settings set in these files are applied in the same order: system, user, command line (thus parameters specified using the command line will overwrite those specified in the system-wide configuration file).

System and user configuration changes do not take effect until the configuration file is saved and ZeroBrane Studio is restarted.

System-wide configuration

System-wide cfg/user.lua (which you may need to create) is located under the directory you installed ZeroBrane Studio to. You can access this configuration file by going to Edit | Preferences | Settings: System (v0.37+). If you are using an older version, you may need to open and edit the file directly. For example, on MacOS it is going to be /Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/cfg/user.lua; you may need to right click on “ZeroBrane Studio” application and select Show Package Contents.

System-wide packages are stored in packages/ directory.

Note that on MacOS the per-system configuration file and packages may be overwritten when a new version of ZeroBrane Studio is installed to the Applications directory, so you may want to save them before upgrading.

Per-user configuration

Per-user configuration is stored in HOME/.zbstudio/user.lua (where HOME is the path specified by the HOME environment variable). You can access this configuration file by going to Edit | Preferences | Settings: User (v0.37+).

Per-user packages are stored in HOME/.zbstudio/packages/ directory.

Configuration via command line

In addition to system-wide and per-user configurations, it is also possible to provide a set of parameters that will be in effect only for one session. Command line configuration can be specified by adding -cfg <filename> parameter when the application is started. For example, on Windows the command zbstudio.exe -cfg myconfig.lua will apply settings from myconfig.lua.

Individual commands can also be specified as configuration parameters; for example, zbstudio.exe -cfg "language='ru'" will set Russian as the user interface language in the IDE. The format of the arguments passed using the command line is exactly the same as specified in the configuration files. If you need to set several values you can separate them with a semicolon: zbstudio.exe -cfg "language='ru'; editor.fontsize = 12".

Configuration file commands

The configuration files allow for several special commands:

  • include "file.lua": includes another (configuration) file using relative or absolute name. The relative name is checked against the directory (1) of the current configuration file, (2) of the per-user configuration file, and (3) of the system-wide configuration file (in that order). As soon as the file is found, it’s processed and the search is stopped.
  • package {}, package "path/", and package "file.lua": loads and processes the file as the package in the IDE. The first syntax (package {}) allows to include the package code in the config file, where the table passed is the package code. The other two load all files from a folder as packages or one particular package. Path and file names may be relative or absolute. The relative name is checked against . (current directory), packages/, and ../packages/ directories (in this order and all relative to the directory of the current configuration file). As soon as the file is found, it’s processed and the search is stopped.

Configuration variables

There are some rare cases in which you may need to access or change some values that are not configuration settings in the IDE. For example, you may need access the spec configuration (ide.specs.lua) or call lua functions from an inline package (package { onRegister = function() table.insert(something, 'else') end }). Before version 1.21, local G = ... was used to provide access to the global environment from the config file. Starting from version 1.21, this is no longer needed, as the global environment is already available, so those methods can be used directly (as can be seen in cfg/user-sample.lua). The access and the processing is the same for all config files.

studio.zerobrane.com


Смотрите также