There are two modes in which you can run an interactive REPL session with Nift, interpreter mode interp and shell mode sh. The only difference between the two modes is that interpreter mode just has the language in the prompt, whereas shell mode has both the language and the present working directory in the prompt.
[contents]
Contents
Interpreter mode
An interpreter REPL session can be started with either of:
nsm interp -lang
nift interp -lang
Note: f++ is the default language used when no language option is specified.
In the interpreter mode the prompt will just tell you which language you are using. If you would like the prompt to also display the present working directory (up to using half the width of the console) you can switch to shell mode using nsm_mode("sh"). You can switch back again with nsm_mode("interp").
Shell mode
A shell REPL session can be started with either of:
nsm sh -lang
nift sh -lang
Note: f++ is the default language used when no language option is specified.
The f++ shell, nicknamed FLASHELL, works as an extension of the default shell for c++ system calls.
In the shell mode the prompt will tell you which language you are using and the present working directory (up to using half the width of the console). If you would like the prompt to just display the language you can switch to interpreter mode using nsm_mode("interp"). You can switch back again with nsm_mode("sh").
RC Scripts
You can have a global script titled similar to niftrc.f but for the exec name you use in the same directory as your global config file (try opening up a shell or interpreter from outside any Nift projects to find the location of the global config file).
Alternatively, you can do project specific "run commands" scripts for the language being used following the naming structure [interp/sh].langChar, eg. sh.f and interp.l.
You can also name the global and project "run commands" scripts with the language as the extension rather than just the first letter, for example niftrc.lua or interp.exprtk or sh.f++, etc..
Languages
The following language options are available:
- exprtk
- f++ (default)
- lua
- n++
You can switch to one of the other languages available during an interactive REPL session using nsm_lang(langStr) where langStr is one of f++, n++, lua or exprtk.
The are various ways to achieve multi-line input during an interactive REPL session, when reading additional lines of input before parsing the end of the prompt changes to > instead of its normal $. The following table lists the shortcuts on different platforms to input another line before parsing (including ending a line with \):
Note: An interactive REPL session will continue to input lines before parsing until the input to be parsed has an equal number of open and close brackets. To override this put an = at the end of an input line with no whitespace following. A couple of f++ examples follow:
int x=10
if(x == 10) {
console("code-blocks in interactive REPL sessions")
}
console("example with ( and { not closed") =
Shortcuts
The following shortcuts are available during interactive REPL sessions:
Description |
FreeBSD |
Linux |
OSX |
Windows |
go to start of line |
ctrl a |
ctrl a |
ctrl a |
ctrl a |
go to end of line |
ctrl e |
ctrl e |
ctrl e |
ctrl e |
move cursor forwards one position |
→ ctrl f |
→ ctrl f |
→ ctrl f |
→ ctrl f |
move cursor backwards one position |
← ctrl b |
← ctrl b |
← ctrl b |
← ctrl b |
move cursor forwards to next space |
alt f |
alt → alt f ctrl → |
alt → |
ctrl → |
move cursor backwards to previous space |
alt b |
alt ← alt b ctrl ← |
alt ← |
ctrl ← |
delete from cursor to end of line |
ctrl d |
ctrl d |
ctrl d |
ctrl d |
delete from cursor to start of previous word |
ctrl delete ctrl shift - ctrl - |
ctrl delete ctrl shift - |
ctrl shift - ctrl - |
ctrl delete ctrl [ |
delete from cursor to start of next word |
ctrl ] |
ctrl ] |
ctrl ] |
ctrl ] |
line break (input another line before parsing) |
alt enter ctrl r \ enter |
alt enter ctrl r \ enter |
ctrl r \ enter |
ctrl enter ctrl r \ enter |
Description |
FreeBSD |
Linux |
OSX |
Windows |