Skip to content
Snippets Groups Projects
Commit 3e6613c7 authored by Gareth Tribello's avatar Gareth Tribello
Browse files

Fixed the output on error and made it much simpler

parent 8bf11cb8
No related branches found
No related tags found
No related merge requests found
......@@ -240,7 +240,7 @@ void Keywords::print( Log& log ) const {
if (nkeys>0 ){
log.printf( "The input for this keyword can be specified using one of the following \n\n");
for(unsigned i=0;i<keys.size();++i){
if ( types[i].isAtomList() ) log.printKeyword( keys[i], documentation[i] );
if ( types[i].isAtomList() ) printKeyword( i, log ); //log.printKeyword( keys[i], documentation[i] );
}
}
nkeys=0;
......@@ -250,7 +250,7 @@ void Keywords::print( Log& log ) const {
if( nkeys>0 ){
log.printf( "\n The compulsory keywords for this action are: \n\n");
for(unsigned i=0;i<keys.size();++i){
if ( types[i].isCompulsory() ) log.printKeyword( keys[i], documentation[i] );
if ( types[i].isCompulsory() ) printKeyword( i, log ); //log.printKeyword( keys[i], documentation[i] );
}
}
// This is a special option specifically for steered MD
......@@ -260,7 +260,7 @@ void Keywords::print( Log& log ) const {
}
if( nkeys>0 ){
for(unsigned i=0;i<keys.size();++i){
if ( types[i].isNumbered() ) log.printKeyword( keys[i], documentation[i] );
if ( types[i].isNumbered() ) printKeyword( i, log ); //log.printKeyword( keys[i], documentation[i] );
}
}
nkeys=0;
......@@ -270,7 +270,7 @@ void Keywords::print( Log& log ) const {
if( nkeys>0 ){
log.printf( "\n The following options are available: \n\n");
for(unsigned i=0;i<keys.size();++i){
if ( types[i].isFlag() ) log.printKeyword( keys[i], documentation[i] );
if ( types[i].isFlag() ) printKeyword( i, log ); //log.printKeyword( keys[i], documentation[i] );
}
log.printf("\n");
}
......@@ -280,12 +280,29 @@ void Keywords::print( Log& log ) const {
}
if( nkeys>0 ){
for(unsigned i=0;i<keys.size();++i){
if ( types[i].isOptional() || types[i].isNoHTML() ) log.printKeyword( keys[i], documentation[i] );
if ( types[i].isOptional() || types[i].isNoHTML() ) printKeyword( i, log ); //log.printKeyword( keys[i], documentation[i] );
}
log.printf("\n");
}
}
void Keywords::printKeyword( const unsigned& j, Log& log ) const {
bool killdot=( documentation[j].find("\\f$")!=std::string::npos ); // Check for latex
std::vector<std::string> w=Tools::getWords( documentation[j] );
log.printf("%23s - ", keys[j].c_str() );
unsigned nl=0; std::string blank=" ";
for(unsigned i=0;i<w.size();++i){
nl+=w[i].length() + 1;
if( nl>60 ){
log.printf("\n%23s %s ", blank.c_str(), w[i].c_str() ); nl=0;
} else {
log.printf("%s ", w[i].c_str() );
}
if( killdot && w[i].find(".")!=std::string::npos ) break; // If there is latex only write up to first dot
}
log.printf("\n");
}
void Keywords::print_html_item( const unsigned& j ) const {
printf("<tr>\n");
printf("<td width=15%%> <b> %s </b></td>\n",keys[j].c_str() );
......
......@@ -50,6 +50,8 @@ private:
void print_html_item( const unsigned& j ) const;
/// Print the documentation to the log file (used by PLMD::Action::error)
void print( Log& log ) const ;
/// Print a particular keyword
void printKeyword( const unsigned& j, Log& log ) const ;
/// find out whether flag key is on or off by default.
bool getLogicalDefault( std::string key, bool& def ) const ;
/// Get the value of the default for the keyword named key
......
......@@ -57,25 +57,3 @@ void Log::flush(){
fflush(fp);
}
void Log::printKeyword( const std::string& key, const std::string& documentation ){
unsigned nlines; nlines=floor( double(documentation.length() / 60) );
if ( nlines==0 ){
printf("%23s - %-60s \n", key.c_str(), documentation.c_str() );
} else {
std::vector<std::string> w=Tools::getWords( documentation );
std::vector<unsigned> lens( nlines + 1 );
unsigned ll=1, nl=0;
for(unsigned i=0;i<w.size();++i){
nl+=w[i].length() + 1;
if( nl>=ll*60 ){ lens[ll]=nl-1-w[i].length(); ll++; }
}
printf("%23s - %-60s \n", key.c_str(), documentation.substr(0,lens[1]).c_str() );
std::string blank=" ";
for(unsigned i=1;i<nlines;++i){
printf("%23s %-60s \n", blank.c_str(), documentation.substr(lens[i],lens[i+1]-lens[i]).c_str() );
}
printf("%23s %-60s \n", blank.c_str(), documentation.substr(lens[nlines]).c_str() );
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment