A command prompt in File Workbench represents any command interpretor, that takes a command string, processes it and outputs the resulting string. Most interpretors fit this pattern. Some obvious cases are:
Bash/Sh/Csh command shells under Unix/Linux
DOS/CMD prompts under Win32
- Script interpretors (Squirrel and others)
File Workbench provides ready to use prompt configurations for these by default.
The Flavour of FWB Command Prompts
Squirrel Session command prompt_.
Win32 CMD/DOS command prompt.
| The aim is to provide a useful interface to any type of command interpreter, where the environment is quite “text-editor-like” (those who have used the Windows CMD prompt know the pain of very limited editing facilities).
The prompt will look and behave much the same regardless of what object is behind it. Command line history, input editing, word / filename completion happens in much the same way in Bash/DOS/Squirrel prompts.
The purpose has not been to provide a replica of Bash and all its features under Unix (or… add your favorite OS and shell here).
A Linux Bash prompt with filename completion active. A plugin GCC output parser provides hilighted and clickable errors.
The FWB shell can do these basic things:
- Receive a line of input from the user.
- Provides command line history and editing.
Red : The ‘prompt ready’ string
Blue_: The prompt editing line
- _Black: Command output
- Restart the shell: Ctrl-R
- Empty the output area: Ctrl-E
- Toggle between command line editing an free arrow key navigation: Escape
- Break the currently running command: Ctrl-C (Note: this also works for Squirrel script prompts).
Copy/Cut/Paste as in a text editor, but Copy uses Ctrl-Shift-C instead.
- It knows when the prompt is busy/ready so that it can interact with browsers and editors.
- It answers queries/requests from other components to report or change its current directory.
Recognizing the Prompt
To know when a command interpreter is ready to receive new input and when it is working, FWB must know its prompt string. This string is described with a regular expression (PCRE flavour) in the Command Prompt preferences dialog. Whenever FWB find a match in the output, it will color it red and consider itself ready to recive input.
For example, to recognize a Windows CMD prompt: C:> the following regular expression can be used:
@ (\w\:\>)$ @
If using a different shell or a different prompt in the bash/cmd, you will have to tweak the prompt expression.
Regular expressions is a big subject. PCRE is the same library as used in PHP. Some useful pages:
Starting a Command Prompt
| The command prompt start dialog is shown when a new Cmd Prompt MiniApp is created. Pressing Ctrl-R from inside a prompt will also always bring it up.
In this dialog one can select type of prompt to create and give it additional startup parameters, such as commands to execute on startup and the prompt regular expression.
The types SqScrEng and SqSession are both Squirrel script prompts. FWB script commands can be developed and tested from there.
Through plugin interfaces, additional command processing and output parsing can be added. For example, File Workbench has a scripted plugin that can parse GCC compiler output that generates red clickable error messages.
It is also possible to add context menu handling, command preprocessing that is specific for a prompt type and context.
- Commands can be scanned, preprocessed and responded to before sent to the interpretor.
- Possibility to add scripted output parsers that can hilight / colorize command output.
- Respond to mouse clicks on output / error messages.
- Show context sensitive menu handling on mouse right clicks
On the command prompt toolbar (above), there are some additional commands:
Connect to default script engine – This connects with the script engine that is started when FWB is launched and that runs in the background. One can follow output and enter new commands here.
Lift on output – This causes a command prompt to raise its window when it receives new text output. Convenient if one wants to be alerted when an error report is printed, or when some lengthy command is done.
Always scroll to end… – This causes a prompt to jump to the end of the window as soon as new input comes. That is suitable for seeing the latest output, but can be annoying if reading some output portion higher up. Toggle to swap mode.