File: rundemo.g

package info (click to toggle)
gap-scscp 2.2.3%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,696 kB
  • sloc: xml: 1,226; sh: 388; makefile: 19
file content (52 lines) | stat: -rw-r--r-- 1,455 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
LogTo();

if not IsBound( Demonstration ) then
	ReadLib("demo.g");
fi;	

MakeReadWriteGlobal("Demonstration");
UnbindGlobal( "Demonstration" );
#
# This is a modified version of Demonstration from lib/demo.g
# to colorise GAP prompt and input
#
BindGlobal( "Demonstration", function( file )
    local   input,  keyboard,  result, storedtime;

    input := InputTextFile( file );
    while input = fail do
        Error( "Cannot open file ", file );
    od;

    Print( "\nStart of demonstration.\n\n" );

    InputLogTo( "*stdout*" );
    keyboard := InputTextUser();
    # Use the following line in two places if you wish
    # GAP prompt and input displayed in bold
    # Print( "\033[1m\033[34m", "demo> \c", "\033[0m" );
    Print( "\033[34m", "demo> \c", "\033[0m" );
    while CHAR_INT( ReadByte( keyboard ) ) <> 'q' do
        storedtime := Runtime();
        result:=READ_COMMAND_REAL( input, true ); # Executing the command.
        time := Runtime()-storedtime;
        if Length(result) = 2 then
            last3 := last2;
            last2 := last;
            last := result[2];
            View(result[2]);
            Print("\n" );
        fi;

        if IsEndOfStream( input ) then
            break;
        fi;
        Print( "\033[34m", "demo> \c", "\033[0m" );
    od;
    Print( "\nEnd of demonstration.\n\n", "\033[0m");
    CloseStream( keyboard );
    CloseStream( input );
    InputLogTo();
end );

Demonstration("paris2011.g");