- Timestamp:
- 03/04/13 20:14:24 (12 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Readline.cc
r14557 r14984 317 317 } 318 318 319 conststring p = GetUpdatePrompt();319 string p = GetUpdatePrompt(); 320 320 if (p.empty()) 321 return;321 p = rl_prompt; 322 322 323 323 UpdatePrompt(""); … … 1262 1262 // -------------------------------------------------------------------------- 1263 1263 // 1264 //! Writes the current history to the file defined by fName and 1265 //! replaces the history by the data from the given file. 1266 //! 1267 //! @param fname 1268 //! Name of the history file to read 1269 //! 1270 void Readline::StaticPushHistory(const string &fname="") 1271 { 1272 write_history(This->fName.c_str()); 1273 stifle_history(0); 1274 unstifle_history(); 1275 read_history(fname.c_str()); 1276 } 1277 1278 // -------------------------------------------------------------------------- 1279 // 1280 //! Writes the current history to the file with the given name 1281 //! and replaces the history by the file defined by fName. 1282 //! 1283 //! @param fname 1284 //! Name of the history file to write (it will be truncated to 1000 lines) 1285 //! 1286 void Readline::StaticPopHistory(const string &fname="") 1287 { 1288 write_history(fname.c_str()); 1289 history_truncate_file(fname.c_str(), 1000); 1290 stifle_history(0); 1291 unstifle_history(); 1292 read_history(This->fName.c_str()); 1293 } 1294 1295 // -------------------------------------------------------------------------- 1296 // 1297 //! Just calls readline and thus allows to just prompt for something. 1298 //! Adds everything to the history except '.q' 1299 //! 1300 //! @param prompt 1301 //! Prompt to be displayed 1302 //! 1303 //! @return 1304 //! String entered by the user ('.q' is Ctrl-d is pressed) 1305 //! 1306 string Readline::StaticPrompt(const string &prompt) 1307 { 1308 char *buf = readline(prompt.c_str()); 1309 if (!buf) 1310 return ".q"; 1311 1312 const string str(buf); 1313 if (Tools::Trim(str)!=".q") 1314 add_history(buf); 1315 free(buf); 1316 1317 return str; 1318 } 1319 1320 // -------------------------------------------------------------------------- 1321 // 1264 1322 //! Process a single line. All lines are added to the history, but only 1265 1323 //! accepted lines are written to the command log. In this case fLine is -
trunk/FACT++/src/Readline.h
r14069 r14984 143 143 144 144 static Readline *Instance() { return This; } 145 146 static void StaticPushHistory(const std::string &fname); 147 static std::string StaticPrompt(const std::string &prompt); 148 static void StaticPopHistory(const std::string &fname); 145 149 }; 146 150
Note:
See TracChangeset
for help on using the changeset viewer.