diff --git a/CHANGELOG b/CHANGELOG index 26bf59b94f..1b70ea7cbd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -53,6 +53,7 @@ Interface changes - SCIPnetmatdecCreate() and SCIPnetmatdecFree() for creating and deleting a network matrix decomposition. SCIPnetmatdecTryAddCol() and SCIPnetmatdecTryAddRow() are used to add columns and rows of the matrix to the decomposition. SCIPnetmatdecContainsRow() and SCIPnetmatdecContainsColumn() check if the decomposition contains the given row or columns. SCIPnetmatdecRemoveComponent() can remove connected components from the decomposition. SCIPnetmatdecCreateDiGraph() can be used to expose the underlying digraph. SCIPnetmatdecIsMinimal() and SCIPnetmatdecVerifyCycle() check if certain invariants of the decomposition are satisfied and are used in tests. - SCIPfreeReaderdataCor(), SCIPfreeReaderdataTim() and SCIPfreeReaderdataSto() for freeing the data for the COR, TIM and STO readers respectively. These readers are all used when reading an SMPS instance. +- SCIPdialogIsHidden(), SCIPdialogSetHidden() to determine whether a dialog should be hidden in help list ### Changes in preprocessor macros @@ -61,6 +62,10 @@ Interface changes ### Command line interface +- help now allows to display information on specific command. +- allow to hide certain commands in the help list +- add the (hidden) command "exit¨ to exit SCIP. + ### Interfaces to external software ### Changed parameters diff --git a/src/scip/dialog.c b/src/scip/dialog.c index 909a957e8b..8344851de1 100644 --- a/src/scip/dialog.c +++ b/src/scip/dialog.c @@ -861,6 +861,7 @@ SCIP_RETCODE SCIPdialogCreate( (*dialog)->subdialogssize = 0; (*dialog)->nuses = 0; (*dialog)->dialogdata = dialogdata; + (*dialog)->hidden = FALSE; /* capture dialog */ SCIPdialogCapture(*dialog); @@ -935,6 +936,24 @@ SCIP_RETCODE SCIPdialogRelease( return SCIP_OKAY; } +/** is dialog hidden */ +SCIP_Bool SCIPdialogIsHidden( + SCIP_DIALOG* dialog /**< dialog */ + ) +{ + assert(dialog != NULL); + return dialog->hidden; +} + +/** set dialog to be hidden */ +void SCIPdialogSetHidden( + SCIP_DIALOG* dialog /**< dialog */ + ) +{ + assert(dialog != NULL); + dialog->hidden = TRUE; +} + /** executes dialog */ SCIP_RETCODE SCIPdialogExec( SCIP_DIALOG* dialog, /**< dialog */ @@ -1090,7 +1109,7 @@ SCIP_RETCODE SCIPdialogDisplayMenu( /* display the dialog's menu options */ for( i = 0; i < dialog->nsubdialogs; ++i ) { - if( !SCIPdialogIsSubmenu(dialog->subdialogs[i]) ) + if( !SCIPdialogIsSubmenu(dialog->subdialogs[i]) && ! SCIPdialogIsHidden(dialog->subdialogs[i]) ) { SCIP_CALL( SCIPdialogDisplayMenuEntry(dialog->subdialogs[i], scip) ); } diff --git a/src/scip/dialog_default.c b/src/scip/dialog_default.c index eb21b2573a..1c0857c994 100644 --- a/src/scip/dialog_default.c +++ b/src/scip/dialog_default.c @@ -2030,7 +2030,42 @@ SCIP_DECL_DIALOGEXEC(SCIPdialogExecHelp) SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, NULL, FALSE) ); SCIPdialogMessage(scip, NULL, "\n"); - SCIP_CALL( SCIPdialogDisplayMenu(SCIPdialogGetParent(dialog), scip) ); + + /* check whether the user entered "help " */ + if( ! SCIPdialoghdlrIsBufferEmpty(dialoghdlr) ) + { + SCIP_DIALOG* rootdialog; + SCIP_DIALOG* subdialog; + SCIP_Bool endoffile; + char* command; + + /* get command as next word on line */ + SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, NULL, &command, &endoffile) ); + + /* search for command */ + rootdialog = SCIPdialoghdlrGetRoot(dialoghdlr); + if ( SCIPdialogFindEntry(rootdialog, command, &subdialog) ) + { + /* if the command has subdialogs */ + if( SCIPdialogGetNSubdialogs(subdialog) > 0 ) + { + /* print information on command itself and its subdialogs */ + SCIP_CALL( SCIPdialogDisplayMenuEntry(subdialog, scip) ); + SCIPdialogMessage(scip, NULL, "\n"); + SCIP_CALL( SCIPdialogDisplayMenu(subdialog, scip) ); + } + else + { + /* print information on command */ + SCIP_CALL( SCIPdialogDisplayMenuEntry(subdialog, scip) ); + } + } + } + else + { + /* print information on all subdialogs */ + SCIP_CALL( SCIPdialogDisplayMenu(SCIPdialogGetParent(dialog), scip) ); + } SCIPdialogMessage(scip, NULL, "\n"); *nextdialog = SCIPdialogGetParent(dialog); @@ -2427,7 +2462,7 @@ SCIP_DECL_DIALOGEXEC(SCIPdialogExecSetSave) SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, filename, TRUE) ); - retcode = SCIPwriteParams(scip, filename, TRUE, FALSE); + retcode = SCIPwriteParams(scip, filename, TRUE, FALSE); if( retcode == SCIP_FILECREATEERROR ) { @@ -3364,7 +3399,7 @@ SCIP_DECL_DIALOGEXEC(SCIPdialogExecWriteLp) SCIP_RETCODE retcode; SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, filename, TRUE) ); - retcode = SCIPwriteLP(scip, filename); + retcode = SCIPwriteLP(scip, filename); if( retcode == SCIP_FILECREATEERROR ) { @@ -3554,7 +3589,7 @@ SCIP_DECL_DIALOGEXEC(SCIPdialogExecWriteNlp) SCIP_RETCODE retcode; SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, dialog, filename, TRUE) ); - retcode = SCIPwriteNLP(scip, filename); + retcode = SCIPwriteNLP(scip, filename); if( retcode == SCIP_FILECREATEERROR ) { @@ -4511,7 +4546,7 @@ SCIP_RETCODE SCIPincludeDialogDefaultBasic( SCIP_CALL( SCIPincludeDialog(scip, &dialog, NULL, SCIPdialogExecHelp, NULL, NULL, - "help", "display this help", FALSE, NULL) ); + "help", "display this help (add to show information on specific command)", FALSE, NULL) ); SCIP_CALL( SCIPaddDialogEntry(scip, root, dialog) ); SCIP_CALL( SCIPreleaseDialog(scip, &dialog) ); } @@ -4579,8 +4614,23 @@ SCIP_RETCODE SCIPincludeDialogDefaultBasic( SCIP_CALL( SCIPincludeDialog(scip, &dialog, NULL, SCIPdialogExecQuit, NULL, NULL, - "quit", "leave SCIP", FALSE, NULL) ); + "quit", "leave SCIP ( works as well)", FALSE, NULL) ); + SCIP_CALL( SCIPaddDialogEntry(scip, root, dialog) ); + SCIP_CALL( SCIPreleaseDialog(scip, &dialog) ); + } + + /* exit - same as quit */ + if( !SCIPdialogHasEntry(root, "exit") ) + { + SCIP_CALL( SCIPincludeDialog(scip, &dialog, + NULL, + SCIPdialogExecQuit, NULL, NULL, + "exit", "leave SCIP", FALSE, NULL) ); SCIP_CALL( SCIPaddDialogEntry(scip, root, dialog) ); + + /* mark command as hidden, because "exit" is already there */ + SCIPdialogSetHidden(dialog); + SCIP_CALL( SCIPreleaseDialog(scip, &dialog) ); } diff --git a/src/scip/pub_dialog.h b/src/scip/pub_dialog.h index 99b97f461f..ea5f552558 100644 --- a/src/scip/pub_dialog.h +++ b/src/scip/pub_dialog.h @@ -219,6 +219,16 @@ void SCIPdialogSetData( SCIP_DIALOGDATA* dialogdata /**< new dialog user data */ ); +/** is dialog hidden */ +SCIP_Bool SCIPdialogIsHidden( + SCIP_DIALOG* dialog /**< dialog */ + ); + +/** set dialog to be hidden */ +void SCIPdialogSetHidden( + SCIP_DIALOG* dialog /**< dialog */ + ); + /** writes command history to specified filename */ SCIP_EXPORT SCIP_RETCODE SCIPdialogWriteHistory( diff --git a/src/scip/struct_dialog.h b/src/scip/struct_dialog.h index 80b50c23d4..ca5ed4f7cd 100644 --- a/src/scip/struct_dialog.h +++ b/src/scip/struct_dialog.h @@ -57,6 +57,7 @@ struct SCIP_Dialog int subdialogssize; /**< size of subdialogs array */ int nuses; /**< number of times, the dialog is used */ SCIP_Bool issubmenu; /**< is the dialog a submenu? */ + SCIP_Bool hidden; /**< dialog is hidden in the help list? */ }; /** linked list of single input lines */