*** empty log message ***
[chuck-blob.git] / v2 / chuck_console.cpp
blob0b06524eb459391c3d775ba651d369ac3a9f6ee9
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
22 U.S.A.
23 -----------------------------------------------------------------------------*/
25 //-----------------------------------------------------------------------------
26 // file: chuck_console.cpp
27 // desc: ...
29 // author: Spencer Salazar (ssalazar@princeton.edu)
30 // date: Autumn 2005
31 //-----------------------------------------------------------------------------
32 #include "chuck_console.h"
33 #include "util_console.h"
36 //-----------------------------------------------------------------------------
37 // name: Chuck_Console()
38 // desc: ...
39 //-----------------------------------------------------------------------------
40 Chuck_Console::Chuck_Console()
45 //-----------------------------------------------------------------------------
46 // name: ~Chuck_Console()
47 // desc: ...
48 //-----------------------------------------------------------------------------
49 Chuck_Console::~Chuck_Console()
54 //-----------------------------------------------------------------------------
55 // name: init()
56 // desc: ...
57 //-----------------------------------------------------------------------------
58 t_CKBOOL Chuck_Console::init()
60 return TRUE;
64 //-----------------------------------------------------------------------------
65 // name: nextCommand()
66 // desc: ...
67 //-----------------------------------------------------------------------------
68 t_CKBOOL Chuck_Console::next_command( const string & prompt, string & out )
70 // the line read
71 char * line_read = NULL;
73 // read the next line
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 )
81 out = "";
82 return FALSE;
85 // check first character
86 if( *line_read != 0 )
87 io_addhistory( line_read );
89 // copy the result
90 out = line_read;
92 // free the thing
93 free( line_read );
95 return TRUE;
99 //-----------------------------------------------------------------------------
100 // name: nextResult()
101 // desc: ...
102 //-----------------------------------------------------------------------------
103 void Chuck_Console::next_result( const Chuck_Shell_Response &in )
105 fputs( in.c_str(), stdout );