Changeset 10654
- Timestamp:
- 05/10/11 19:32:32 (14 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Readline.cc
r10498 r10654 897 897 fprintf(rl_outstream, " c,commands Dump available commands\n"); 898 898 fprintf(rl_outstream, " k,keylist Dump key bindings\n"); 899 fprintf(rl_outstream, " .x filename Execute a script of commands\n"); 899 900 fprintf(rl_outstream, " .q,quit Quit\n"); 900 901 fprintf(rl_outstream, "\n"); … … 941 942 bool Readline::Process(const string &str) 942 943 { 944 if (str.substr(0, 3)==".x ") 945 { 946 Execute(str.substr(3)); 947 return true; 948 } 949 943 950 // ----------- Readline static ------------- 944 951 … … 1081 1088 } 1082 1089 1090 // -------------------------------------------------------------------------- 1091 // 1092 //! Executes commands read from an ascii file as they were typed in 1093 //! the console. Empty lines and lines beginning with # are ignored. 1094 //! 1095 //! @param fname 1096 //! Filename of file to read 1097 //! 1098 //! @returns 1099 //! -1 if the file couldn't be read and the number of command for which 1100 //! Process() was callled otherwise 1101 //! 1102 int Readline::Execute(const string &fname) 1103 { 1104 int rc = 0; 1105 1106 ifstream fin(Tools::Trim(fname).c_str()); 1107 if (!fin) 1108 return -1; 1109 1110 string buffer; 1111 while (getline(fin, buffer, '\n')) 1112 { 1113 buffer = Tools::Trim(buffer); 1114 if (buffer.empty()) 1115 continue; 1116 1117 if (buffer[0]=='#') 1118 continue; 1119 1120 rc++; 1121 1122 if (Process(buffer)) 1123 continue; 1124 1125 fLine++; 1126 1127 AddToHistory(buffer); 1128 } 1129 1130 return rc; 1131 } 1132 1083 1133 void Readline::Stop() 1084 1134 { -
trunk/FACT++/src/Readline.h
r10343 r10654 87 87 virtual void Run(const char *prompt=0); 88 88 static void Stop(); 89 int Execute(const std::string &fname); 89 90 90 91 int GetLine() const { return fLine; } -
trunk/FACT++/src/ReadlineColor.cc
r10337 r10654 151 151 out << kBold << " k,keylist " << kReset << "Dump key bindings" << endl; 152 152 out << kBold << " a,attrs " << kReset << "Dump available stream attributes" << endl; 153 out << kBold << " .x filename " << kReset << "Execute a script of commands" << endl; 153 154 out << kBold << " .q,quit " << kReset << "Quit" << endl; 154 155 out << endl;
Note:
See TracChangeset
for help on using the changeset viewer.