Changeset 12961 for trunk/FACT++/src
- Timestamp:
- 02/29/12 10:04:55 (13 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Readline.cc
r12824 r12961 96 96 // 97 97 Readline::Readline(const char *prgname) : 98 fMaxLines(500), fLine(0), f Completion(0)98 fMaxLines(500), fLine(0), fLabel(-1), fCompletion(0) 99 99 { 100 100 if (This) … … 952 952 fprintf(rl_outstream, " .w n Sleep n milliseconds\n"); 953 953 fprintf(rl_outstream, " .x filename Execute a script of commands\n"); 954 fprintf(rl_outstream, " .x file:N Execute a script of commands, start at label N\n"); 955 fprintf(rl_outstream, " .j N Forward jump to label N\n"); 956 fprintf(rl_outstream, " : N Defines a label\n"); 954 957 fprintf(rl_outstream, " .q,quit Quit\n"); 955 958 fprintf(rl_outstream, "\n"); … … 994 997 //! 995 998 // 999 bool Readline::PreProcess(const string &str) 1000 { 1001 // ----------- Labels ------------- 1002 1003 if (str[0]==':') 1004 { 1005 if (fLabel!=atoi(str.substr(1).c_str())) 1006 return true; 1007 1008 fLabel=-1; 1009 return false; 1010 } 1011 1012 if (fLabel>=0) 1013 { 1014 fCommandLog << "# SKIP[" << fLabel << "]: " << str << endl; 1015 return true; 1016 } 1017 1018 if (str.substr(0, 3)==".j ") 1019 { 1020 fLabel = atoi(str.substr(3).c_str()); 1021 return false; 1022 } 1023 1024 return Process(str); 1025 1026 } 1027 1028 // -------------------------------------------------------------------------- 1029 // 1030 //! 1031 // 996 1032 bool Readline::Process(const string &str) 997 1033 { 1034 // ----------- Common commands ------------- 1035 998 1036 if (str.substr(0, 3)==".w ") 999 1037 { … … 1116 1154 void Readline::ProcessLine(const string &str) 1117 1155 { 1118 const bool rc = Pr ocess(str);1156 const bool rc = PreProcess(str); 1119 1157 1120 1158 AddToHistory(str); … … 1186 1224 return 0; 1187 1225 1188 int rc = 0; 1189 1190 const string name = Tools::Trim(fname); 1226 fLabel = -1; 1227 1228 string name = Tools::Trim(fname); 1229 1230 const size_t p = name.find_last_of(':'); 1231 if (p!=string::npos) 1232 { 1233 fLabel = atoi(name.substr(p+1).c_str()); 1234 name = name.substr(0, p); 1235 } 1191 1236 1192 1237 ifstream fin(name.c_str()); … … 1194 1239 return -1; 1195 1240 1196 fCommandLog << "# " << Time() << " - " << name << " (START)" << endl; 1241 fCommandLog << "# " << Time() << " - " << name << " (START"; 1242 if (fLabel>=0) 1243 fCommandLog << ':' << fLabel; 1244 fCommandLog << ")" << endl; 1245 1246 int rc = 0; 1197 1247 1198 1248 string buffer; … … 1214 1264 } 1215 1265 1266 fLabel = -1; 1267 1216 1268 fCommandLog << "# " << Time() << " - " << name << " (FINISHED)" << endl; 1217 1269 -
trunk/FACT++/src/Readline.h
r11326 r12961 26 26 27 27 int fLine; 28 int fLabel; 28 29 29 30 // Static member function which are used to adapt readline to ncurses … … 54 55 void SetCompletion(const std::vector<std::string> *v) { fCompletion = v; } 55 56 char **Complete(const std::vector<std::string> &v, const char *text); 57 58 void SetLabel(int l) { fLabel = l; } 56 59 57 60 public: … … 84 87 void UpdatePrompt() const { UpdatePrompt(GetUpdatePrompt()); } 85 88 89 virtual bool PreProcess(const std::string &str); 86 90 virtual bool Process(const std::string &str); 87 91 virtual std::string GetUpdatePrompt() const { return ""; }
Note:
See TracChangeset
for help on using the changeset viewer.