/*$Id: c_comand.cc,v 26.19 2007/03/21 01:30:28 al Exp $ -*- C++ -*- * Copyright (C) 2001 Albert Davis * Author: Albert Davis * * This file is part of "Gnucap", the Gnu Circuit Analysis Package * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. *------------------------------------------------------------------ * simple commands and stubs for the missing commands */ //testing=script,sparse 2006.07.16 #include "l_dispatcher.h" #include "constant.h" #include "declare.h" /* plclear */ #include "u_opt.h" #include "ap.h" #include "c_comand.h" extern DISPATCHER command_dispatcher; /*--------------------------------------------------------------------------*/ extern std::string head; /*--------------------------------------------------------------------------*/ namespace { /*--------------------------------------------------------------------------*/ class CMD_OPT : public CMD { public: void do_it(CS& cmd) { static OPT o; o.command(cmd); } } p5; DISPATCHER::INSTALL d5(&command_dispatcher, "options,set,width", &p5); /*--------------------------------------------------------------------------*/ class CMD_END : public CMD { public: void do_it(CS&) { switch (ENV::run_mode) { case rPRE_MAIN: unreachable(); break; case rPRESET: untested(); break; //BUG// this should close the file case rINTERACTIVE: untested(); command("quit"); break; case rSCRIPT: if (OPT::acct) {untested(); command("status"); }else{untested(); } error(bERROR, ""); break; case rBATCH: if (OPT::acct) {untested(); command("status"); }else{ } command("quit"); break; } } } p0; DISPATCHER::INSTALL d0(&command_dispatcher, "end", &p0); /*--------------------------------------------------------------------------*/ class CMD_PAUSE : public CMD { public: void do_it(CS&) {untested(); IO::error << "Continue? "; int ch = getchar(); if (ch=='n' || ch=='N' || ch=='C'-'@' || ch=='['-'@') {untested(); error(bERROR, "\r"); }else{untested(); } } } p1; DISPATCHER::INSTALL d1(&command_dispatcher, "pause", &p1); /*--------------------------------------------------------------------------*/ class CMD_QUIT : public CMD { public: void do_it(CS&) { switch (ENV::run_mode) { case rPRE_MAIN: unreachable(); break; case rINTERACTIVE: itested(); case rSCRIPT: case rBATCH: command("clear"); exit(0); break; case rPRESET: itested(); /*nothing*/ break; } } } p2; DISPATCHER::INSTALL d2(&command_dispatcher, "quit,exit", &p2); /*--------------------------------------------------------------------------*/ class CMD_TEMP : public CMD { public: void do_it(CS& cmd) {untested(); double t = NOT_INPUT; int here = cmd.cursor(); cmd >> '=' >> t; if (!cmd.stuck(&here)) {untested(); OPT::temp_c = t; }else{untested(); IO::mstdout << ".temp = " << OPT::temp_c << '\n'; } } } p3; DISPATCHER::INSTALL d3(&command_dispatcher, "temperature,temp", &p3); /*--------------------------------------------------------------------------*/ class CMD_TITLE : public CMD { public: void do_it(CS& cmd) { if (cmd.more()) { head = cmd.tail(); }else{untested(); IO::mstdout << head << '\n'; } } } p4; DISPATCHER::INSTALL d4(&command_dispatcher, "title", &p4); /*--------------------------------------------------------------------------*/ } /*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/