Alpha Consoles Help
Alpha |
Version: | 9.2.3 - "Suhail" |
Last update: | 2021-05-21 14:43:30 |
Introduction
A console is a document window which lets the user enter commands to
execute, very much like the terminal windows which communicate with a Unix
shell. The window presents a prompt which designates the command line. The user types an instruction on the command line and hits the Return
key to have it executed by some program. If the program produces
some output, this is inserted under the command line, then the console
provides a new prompt to execute the following instruction.
Such a console is called an interactive console. There also exists
simple consoles (like the TeX console) which are meant to display
(synchronously or asynchronously) the output of some program during the
execution of a task.
Many Alpha modes and packages provide interactive consoles. This
document gives an overview of the available resources. For more
information, see the documentation of the relevant packages or modes.
Console Launcher
In order to have a direct access to the different consoles, you may
activate the Console Launcher package. It inserts a
Consoles submenu in the Tools menu. This submenu contains
a list of all the registered consoles: selecting any item will lauch the
corresponding console.
Otherwise, the modes that support a console usually have a menu item
called Launch Console, often bound to the ⌘K
key combo.
Alpha Consoles
The Bc console
The Bc console is defined by Alpha's Bc mode. It communicates with the
arbitrary precision numeric processing language. For more information, see
the Bc Mode Help.
Here is an example:
Welcome to Alpha's Bc console.
> scale=10
> 2^20
1048576
> a(1)*4
3.1415926532
>
The bc tool is installed by default on Mac OS X.
The Coq console
The Coq console is defined by Alpha's Coq mode. It communicates with
coqtop, the proof assistant for verification of mathematical proofs.
For more information, see the Coq Mode Help.
Here is an example:
Welcome to Coq 8.4pl6 (September 2016)
Coq < Check O.
0
: nat
Coq < Variable n : nat.
n is assumed
Warning: n is declared as a parameter because it is at a global level
Coq <
For this to work, the Coq software must
be installed on your machine.
The Gnuplot console
The Gnuplot console is defined by Alpha's Gnuplot mode. It
communicates with the interactive function plotting utility Gnuplot.
For more information, see the Gnuplot Mode Help.
Here is an example:
Welcome to Alpha's Gnuplot shell.
gnuplot> set yrange [-1.1 : 1.1]
gnuplot> set ytics -1, 1.0 / 10, 1
gnuplot> set title "Functions sine and cosine"
gnuplot> plot cos(x),sin(x)
gnuplot>
For this to work, the gnuplot
utility must be installed on your machine.
The Haskell console
The Haskell console is defined by Alpha's Haskell mode. It
communicates with the interactive Glasgow Haskell Compiler. For
more information, see the Haskell Mode Help.
Here is an example:
-- Welcome to Alpha's Haskell console.
-- Running ghc 8.6.5.
λ> :show imports
import Prelude -- implicit
λ> map (+3) [2,6,7,1]
[5,9,10,4]
λ> :info filter
filter :: (a -> Bool) -> [a] -> [a] -- Defined in ‘GHC.List’
λ> filter even [1..10]
[2,4,6,8,10]
λ>
For this to work, the ghc
command line tool must be installed on your machine.
The Julia console
The Julia console is defined by Alpha's Julia mode. It
communicates with the Julia dynamic programming language for numerical computing.
For more information, see the Julia Mode Help.
Here is an example:
# Welcome to Alpha's Julia console.
# Running julia interpreter in interactive mode.
julia> π
π = 3.1415926535897...
julia> sqrt(2)
1.4142135623730951
julia> M=[1 -1; 2 3]
2×2 Array{Int64,2}:
1 -1
2 3
julia> det(M)
5.0
julia> eigvals(M)
2-element Array{Complex{Float64},1}:
2.0+1.0im
2.0-1.0im
julia>
For this to work, the julia tool
must be installed on your machine.
The Mac Shell console
The Mac Shell console is defined by Alpha's Mac Menu package. It lets
you execute from a command line the menu items provided by this package.
For more information, see the Syntax section
of the Mac Menu Help.
Here is an example:
Welcome to Mac Shell
Type 'help' to get info about available commands.
«» cd $HOME
«AlphaTcl» infos file Tcl/Menus/colorsMenu.tcl
Creation date: 2016-12-28 11:18:47
Creator: msng
Everyone's privileges: read
Group privileges: read
Group: (inconnu)
Kind: Alpha Tcl File
Locked: false
Logical size: 35208
Modification date: 2016-12-28 11:18:47
Name: colorsMenu.tcl
Owner's privileges: rdwr
Owner: bernardo
Parent folder: /Applications/Alpha.app/Contents/Resources/Libraries/AlphaTcl/Tcl/Menus
Physical size: 36864
Stationery pad: false
Type: msng
Version info:
Version:
The Matlab console
The Matlab console is defined by Alpha's Matlab mode. It
communicates with the Matlab program.
For more information, see the Matlab Mode Help.
Here is an example:
% Welcome to Alpha's Matlab console.
>> A = [1 2 0; 2 5 -1; 4 10 -1]
A =
1 2 0
2 5 -1
4 10 -1
>> p = round(poly(A))
p =
1 -5 5 -1
>> roots(p)
ans =
3.7321
1.0000
0.2679
>>
For this to work, the Matlab program must be
installed on your machine.
The Maxima console
The Maxima console is defined by Alpha's Maxima mode. It
communicates with the Maxima symbolic calculus system.
For more information, see the Maxima Mode Help.
Here is an example:
Welcome to Alpha's Maxima console.
maxima> p: (x+1)^2*(x-2);
(%i1)
2
(%o1) (x - 2) (x + 1)
maxima> expand(p);
(%i2)
3
(%o2) x - 3 x - 2
maxima>
For this to work, the maxima tool must be installed on your machine.
The Octave console
The Octave console is defined by Alpha's Octave mode. It
communicates with the high-level language for numerical computations Octave.
For more information, see the Octave Mode Help.
Here is an example:
Welcome to Alpha's Octave console.
Running octave interpreter in interactive mode.
octave> M=[1,2; 2,-1]
M =
1 2
2 -1
octave> det(M)
ans = -5
octave> c=[3;4]
c =
3
4
octave> M\c
ans =
2.20000
0.40000
octave>
For this to work, the octave tool must be installed on your machine.
The R console
The R console is defined by Alpha's S+/R mode. It
communicates with the R statistical computing software.
For more information, see the SMode Help.
Here is an example:
Welcome to Alpha's R console.
> set.seed(1)
> x <- rnorm(20)
> x
[1] -0.62645381 0.18364332 -0.83562861 1.59528080 0.32950777 -0.82046838
[7] 0.48742905 0.73832471 0.57578135 -0.30538839 1.51178117 0.38984324
[13] -0.62124058 -2.21469989 1.12493092 -0.04493361 -0.01619026 0.94383621
[19] 0.82122120 0.59390132
> summary(x)
Min. 1st Qu. Median Mean 3rd Qu. Max.
-2.2150 -0.3844 0.3597 0.1905 0.7590 1.5950
>
For this to work, the R software must be
installed on your machine.
The Sqlite3 console
The Sqlite3 console is defined by Alpha's Sqlite3 mode. It communicates
with the sqlite3 command line tool.
For more information, see the Sqlite3 Mode Help.
Here is an example:
Welcome to Alpha's Sqlite3 console.
> .open alpha_releases.db
SQLite version 3.20.1 2017-08-24 16:21:36
Enter ".help" for usage hints.
> .tables
releases
> .mode list
> SELECT name,date,size FROM releases WHERE version='9.0.5';
Decrux|2019-05-03 13:28:12|27622345
> .mode line
> SELECT name,date,size FROM releases WHERE version='9.0.5';
name = Decrux
date = 2019-05-03 13:28:12
size = 27622345
> .headers on
> .mode column
> SELECT name,date,size FROM releases WHERE version='9.0.5';
name date size
---------- ------------------- ----------
Decrux 2019-05-03 13:28:12 27622345
>
For this to work, the sqlite3 command
must be installed on your machine.
The Tclsh console
The Tclsh console is defined by Alpha's Tcl mode. It
communicates with an external tclsh interpreter (not the Tcl
interpreter included in Alpha).
For more information, see the Tcl Mode Help.
Here is an example:
Welcome to the tclsh console.
Running an external tclsh interpreter.
Warning: this is not the AlphaTcl shell (cmd-Y).
> info tclversion
8.5
> info patchlevel
8.5.9
> lsort {z g j y c}
c g j y z
>
The Unix Shell console
The Unix Shell console is defined by Alpha's InSh mode ([In]teractive
[Sh]ell windows in Alpha). It features a Unix like shell.
For more information, see the InSh Mode Help.
Here is an example:
sh-3.2$ pwd
pwd
/
sh-3.2$ cd
cd
sh-3.2$ ls | grep P
ls | grep P
Pictures
Public
sh-3.2$
Console Editing Shortcuts
The consoles implement the following keyboard shortcuts to help you edit
the current command line:
Shortcut | Description |
⌃A | go to beginning of line |
⌃E | go to end of line |
⌃K | delete to end of line |
⌃U | delete entire line |
⌃D | delete previous character |
⌃P | insert next history command |
⌃N | insert previous history command |
⌃H | display history popover |
Console Commands History
The consoles keep a history of recent commands. There are two ways of
navigating through the history:
- using the Up or Down arrows when the cursor is on the current input
line. The arrows scroll respectively backwards or forwards in the command
history and insert the corresponding commands in the current line.
- using the Up or Down arrows while pressing the Option
(
⌥
) key displays a popover window containing the entire
history. One can select any command in the popover and double-click to
insert it in the console. The ⌥-Up
combo displays the
history from top to bottom (most recent command at the bottom of the
popover) and the ⌥-Down
combo does the opposite (most
recent command at the top of the popover). If all the history does not fit
in the popover, you can use the vertical scroller. The following image
illustrates the history popover in the R console:
- Console History Size
- The default history storage capacity is 30 items. Most consoles supply a
Console History Size preference that lets you modify this value.
- Clear History
- The Consoles ↣ Clear History menu
item lets you erase the commands history of the currently active console.
Note for developers
Most of the consoles described in the previous section rely on the
Interactive console API provided by AlphaTcl. This mechanism is entirely
described in the Interactive console
section of the Extending Alpha manual.
Client packages can add their own console to the Tools ↣ Consoles submenu (provided by the Console Launcher package) by setting a new entry in the index::consoles array. The value of this entry is the name of the proc
which is responsible for displaying the console. For instance:
set ::index::consoles(MyConsole) My::displayConsole
This instruction should be placed in the initialization or the preinit
block of the client package to make sure that the console is available even
if the package has not been activated.
Known problems
Please report any problem or bug you encounter to
Alpha's Bug Tracker.
License and Disclaimer
Copyright (c) 2016-2021, Bernard Desgraupes.
All rights reserved.
The Alpha Consoles package is free software and distributed under
the terms of the new BSD license:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Neither the name of Bernard Desgraupes nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BERNARD DESGRAUPES BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
This document has been placed in the public domain.