1 /*----------------------------------------------------------------------------
2 ChucK Concurrent, On-the-fly Audio Programming Language
3 Compiler and Virtual Machine
5 Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved.
6 http://chuck.cs.princeton.edu/
7 http://soundlab.cs.princeton.edu/
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 -----------------------------------------------------------------------------*/
25 //-----------------------------------------------------------------------------
26 // file: chuck_console.cpp
29 // author: Spencer Salazar (ssalazar@princeton.edu)
31 //-----------------------------------------------------------------------------
32 #include "chuck_console.h"
33 #include "util_console.h"
36 //-----------------------------------------------------------------------------
37 // name: Chuck_Console()
39 //-----------------------------------------------------------------------------
40 Chuck_Console::Chuck_Console()
45 //-----------------------------------------------------------------------------
46 // name: ~Chuck_Console()
48 //-----------------------------------------------------------------------------
49 Chuck_Console::~Chuck_Console()
54 //-----------------------------------------------------------------------------
57 //-----------------------------------------------------------------------------
58 t_CKBOOL
Chuck_Console::init()
64 //-----------------------------------------------------------------------------
65 // name: nextCommand()
67 //-----------------------------------------------------------------------------
68 t_CKBOOL
Chuck_Console::next_command( const string
& prompt
, string
& out
)
71 char * line_read
= NULL
;
74 line_read
= io_readline( prompt
.c_str() );
76 // check to see if EOF encountered
77 // do we need more return codes to differentiate between
78 // EOF encountered vs. empty line?
79 if( line_read
== NULL
)
85 // check first character
87 io_addhistory( line_read
);
99 //-----------------------------------------------------------------------------
100 // name: nextResult()
102 //-----------------------------------------------------------------------------
103 void Chuck_Console::next_result( const Chuck_Shell_Response
&in
)
105 fputs( in
.c_str(), stdout
);