29 #include <readline/readline.h> 30 #include <readline/history.h> 61 assert(endoffile !=
NULL);
94 #ifndef NO_REMOVE_HISTORY 95 return history_length;
107 #ifndef NO_REMOVE_HISTORY 110 entry = remove_history(pos);
116 #if RL_VERSION_MAJOR >= 5 117 (void)free_history_entry(entry);
121 free((
void*)entry->line);
136 int retval = write_history(filename);
156 assert(dialoghdlr !=
NULL);
160 assert(endoffile !=
NULL);
170 printf(
"%s", prompt);
174 assert(result !=
NULL);
235 assert(linelist !=
NULL);
247 assert(linelist !=
NULL);
249 while( *linelist !=
NULL )
255 *linelist = nextline;
267 assert(dialoghdlr !=
NULL);
271 assert(endoffile !=
NULL);
315 assert(dialog !=
NULL);
317 assert(set->scip !=
NULL);
319 if( dialog->dialogcopy !=
NULL )
322 SCIP_CALL( dialog->dialogcopy(set->scip, dialog) );
334 char readlineversion[20];
337 assert(dialoghdlr !=
NULL);
340 (*dialoghdlr)->rootdialog =
NULL;
341 (*dialoghdlr)->inputlist =
NULL;
342 (*dialoghdlr)->inputlistptr = &(*dialoghdlr)->inputlist;
344 (*dialoghdlr)->nprotectedhistelems = -1;
350 (void)
SCIPsnprintf(readlineversion,
sizeof(readlineversion),
"Readline %s", rl_library_version);
363 assert(dialoghdlr !=
NULL);
381 assert(dialoghdlr !=
NULL);
389 while( dialog !=
NULL )
408 assert(dialoghdlr !=
NULL);
429 assert(dialoghdlr !=
NULL);
439 assert(dialoghdlr !=
NULL);
441 dialoghdlr->
buffer[0] =
'\0';
450 assert(dialoghdlr !=
NULL);
470 assert(dialoghdlr !=
NULL);
473 assert(inputline !=
NULL);
498 while( isspace((
unsigned char)dialoghdlr->
buffer[dialoghdlr->
bufferpos + len - 1]) )
517 while( isspace((
unsigned char)dialoghdlr->
buffer[dialoghdlr->
bufferpos]) )
549 assert(dialoghdlr !=
NULL);
552 assert(inputword !=
NULL);
553 assert(endoffile !=
NULL);
580 while( isspace((
unsigned char)dialoghdlr->
buffer[dialoghdlr->
bufferpos + len - 1]) )
598 while( isspace((
unsigned char)dialoghdlr->
buffer[dialoghdlr->
bufferpos]) )
605 assert(pos <= dialoghdlr->bufferpos);
665 assert(pos <= dialoghdlr->bufferpos);
672 if( dialoghdlr->
buffer[pos] !=
'\0' )
673 dialoghdlr->
buffer[pos] =
'\0';
676 while( isspace((
unsigned char)dialoghdlr->
buffer[dialoghdlr->
bufferpos]) )
679 *inputword = firstword;
689 const char* inputline
695 assert(dialoghdlr !=
NULL);
698 assert(inputline !=
NULL);
728 assert(dialoghdlr !=
NULL);
731 cleanuphistory = (dialog !=
NULL);
737 if( command !=
NULL )
800 assert(dialog !=
NULL);
810 assert(num <= dialog->subdialogssize);
830 assert(dialog !=
NULL);
831 assert(name !=
NULL);
836 (*dialog)->dialogcopy = dialogcopy;
837 (*dialog)->dialogexec = dialogexec;
838 (*dialog)->dialogdesc = dialogdesc;
839 (*dialog)->dialogfree = dialogfree;
847 (*dialog)->desc =
NULL;
849 (*dialog)->issubmenu = issubmenu;
850 (*dialog)->parent =
NULL;
851 (*dialog)->subdialogs =
NULL;
852 (*dialog)->nsubdialogs = 0;
853 (*dialog)->subdialogssize = 0;
854 (*dialog)->nuses = 0;
855 (*dialog)->dialogdata = dialogdata;
880 assert(dialog !=
NULL);
881 assert(*dialog !=
NULL);
882 assert((*dialog)->nuses == 0);
885 if( (*dialog)->dialogfree !=
NULL )
887 SCIP_CALL( (*dialog)->dialogfree(scip, *dialog) );
891 for( i = 0; i < (*dialog)->nsubdialogs; ++i )
909 assert(dialog !=
NULL);
920 assert(dialog !=
NULL);
923 if( (*dialog)->nuses == 0 )
939 assert(dialog !=
NULL);
940 assert(dialog->dialogexec !=
NULL);
942 assert(nextdialog !=
NULL);
944 SCIP_CALL( dialog->dialogexec(set->scip, dialog, dialoghdlr, nextdialog) );
963 assert(dialog !=
NULL);
964 assert(subdialog !=
NULL);
969 SCIPerrorMessage(
"dialog entry with name <%s> already exists in dialog <%s>\n",
979 subdialog->parent = dialog;
990 const char* entryname
997 assert(dialog !=
NULL);
998 assert(entryname !=
NULL);
1003 for( i = 0; i < nsubdialogs; ++i )
1023 const char* entryname,
1028 unsigned int namelen;
1033 assert(dialog !=
NULL);
1034 assert(entryname !=
NULL);
1035 assert(subdialog !=
NULL);
1042 namelen = (
unsigned int) strlen(entryname);
1044 for( i = 0; i < nsubdialogs; ++i )
1049 *subdialog = subdialogs[i];
1072 assert(dialog !=
NULL);
1106 assert(dialog !=
NULL);
1114 if( strlen(name) > 21 )
1121 if( dialog->dialogdesc !=
NULL )
1123 SCIP_CALL( dialog->dialogdesc(scip, dialog) );
1136 const char* entryname
1140 unsigned int namelen;
1144 assert(dialog !=
NULL);
1145 assert(entryname !=
NULL);
1150 namelen = (
unsigned int) strlen(entryname);
1151 for( i = 0; i < nsubdialogs; ++i )
1172 assert(dialog !=
NULL);
1178 while( dialog !=
NULL )
1192 assert(dialog !=
NULL);
1194 return dialog->
name;
1202 assert(dialog !=
NULL);
1204 return dialog->
desc;
1212 assert(dialog !=
NULL);
1222 assert(dialog !=
NULL);
1232 assert(dialog !=
NULL);
1242 assert(dialog !=
NULL);
1252 assert(dialog !=
NULL);
1263 assert(dialog !=
NULL);
1270 const char* filename
int SCIPdialogGetNSubdialogs(SCIP_DIALOG *dialog)
static SCIP_RETCODE dialogFree(SCIP *scip, SCIP_DIALOG **dialog)
void SCIPdialoghdlrClearBuffer(SCIP_DIALOGHDLR *dialoghdlr)
#define BMSfreeMemoryArrayNull(ptr)
const char * SCIPdialogGetName(SCIP_DIALOG *dialog)
void SCIPdialogMessage(SCIP *scip, FILE *file, const char *formatstr,...)
SCIP_RETCODE SCIPdialogRelease(SCIP *scip, SCIP_DIALOG **dialog)
#define SCIP_DECL_DIALOGCOPY(x)
SCIP_RETCODE SCIPdialogExec(SCIP_DIALOG *dialog, SCIP_SET *set, SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG **nextdialog)
SCIP_DIALOG ** SCIPdialogGetSubdialogs(SCIP_DIALOG *dialog)
void SCIPdialogGetPath(SCIP_DIALOG *dialog, const char sepchar, char *path)
SCIP_RETCODE SCIPdialogDisplayMenuEntry(SCIP_DIALOG *dialog, SCIP *scip)
SCIP_RETCODE SCIPdialogDisplayCompletions(SCIP_DIALOG *dialog, SCIP *scip, const char *entryname)
data structures for user interface dialog
int SCIPsnprintf(char *t, int len, const char *s,...)
enum SCIP_Retcode SCIP_RETCODE
int SCIPsetCalcMemGrowSize(SCIP_SET *set, int num)
int SCIPdialogFindEntry(SCIP_DIALOG *dialog, const char *entryname, SCIP_DIALOG **subdialog)
static void linelistFree(SCIP_LINELIST **linelist)
#define BMSallocMemoryArray(ptr, num)
struct SCIP_DialogData SCIP_DIALOGDATA
static void linelistFreeAll(SCIP_LINELIST **linelist)
#define BMSfreeMemory(ptr)
SCIP_DIALOG * SCIPdialogGetParent(SCIP_DIALOG *dialog)
static SCIP_RETCODE ensureSubdialogMem(SCIP_DIALOG *dialog, SCIP_SET *set, int num)
void SCIPdialogSetData(SCIP_DIALOG *dialog, SCIP_DIALOGDATA *dialogdata)
void SCIPdialogCapture(SCIP_DIALOG *dialog)
#define SCIP_DECL_DIALOGDESC(x)
static SCIP_RETCODE writeHistory(const char *filename)
#define BMSfreeMemoryArray(ptr)
SCIP_DIALOG ** subdialogs
SCIP_RETCODE SCIPdialogWriteHistory(const char *filename)
static SCIP_RETCODE addHistory(const char *s)
void SCIPescapeString(char *t, int bufsize, const char *s)
SCIP_RETCODE SCIPdialogDisplayMenu(SCIP_DIALOG *dialog, SCIP *scip)
SCIP_RETCODE SCIPdialoghdlrCreate(SCIP_SET *set, SCIP_DIALOGHDLR **dialoghdlr)
const char * SCIPdialogGetDesc(SCIP_DIALOG *dialog)
internal methods for global SCIP settings
#define BMSduplicateMemoryArray(ptr, source, num)
SCIP_LINELIST * inputlist
public data structures and miscellaneous methods
SCIP_RETCODE SCIPdialogCreate(SCIP_DIALOG **dialog, SCIP_DECL_DIALOGCOPY((*dialogcopy)), SCIP_DECL_DIALOGEXEC((*dialogexec)), SCIP_DECL_DIALOGDESC((*dialogdesc)), SCIP_DECL_DIALOGFREE((*dialogfree)), const char *name, const char *desc, SCIP_Bool issubmenu, SCIP_DIALOGDATA *dialogdata)
SCIP_DIALOGDATA * dialogdata
internal methods for user interface dialog
SCIP_Bool SCIPdialogHasEntry(SCIP_DIALOG *dialog, const char *entryname)
SCIP_RETCODE SCIPdialoghdlrAddInputLine(SCIP_DIALOGHDLR *dialoghdlr, const char *inputline)
static int getHistoryLength(void)
SCIP_Bool SCIPdialogIsSubmenu(SCIP_DIALOG *dialog)
SCIP_RETCODE SCIPsetIncludeExternalCode(SCIP_SET *set, const char *name, const char *description)
static SCIP_DECL_SORTPTRCOMP(dialogComp)
SCIP_LINELIST ** inputlistptr
SCIP_RETCODE SCIPdialoghdlrSetRoot(SCIP *scip, SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG *dialog)
#define SCIP_DECL_DIALOGFREE(x)
SCIP_RETCODE SCIPdialoghdlrGetWord(SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG *dialog, const char *prompt, char **inputword, SCIP_Bool *endoffile)
void SCIPsortedvecInsertPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), void *keyval, int *len, int *pos)
SCIP_RETCODE SCIPdialoghdlrAddHistory(SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG *dialog, const char *command, SCIP_Bool escapecommand)
#define SCIP_DECL_DIALOGEXEC(x)
SCIP_DIALOG * SCIPdialoghdlrGetRoot(SCIP_DIALOGHDLR *dialoghdlr)
SCIP_RETCODE SCIPdialogCopyInclude(SCIP_DIALOG *dialog, SCIP_SET *set)
SCIP_Bool SCIPdialoghdlrIsBufferEmpty(SCIP_DIALOGHDLR *dialoghdlr)
static SCIP_RETCODE readLine(SCIP_DIALOGHDLR *dialoghdlr, const char *prompt, SCIP_Bool *endoffile)
static SCIP_RETCODE readInputLine(SCIP_DIALOGHDLR *dialoghdlr, const char *prompt, SCIP_Bool *endoffile)
#define BMSallocMemory(ptr)
#define BMSreallocMemoryArray(ptr, num)
SCIP_RETCODE SCIPdialogAddEntry(SCIP_DIALOG *dialog, SCIP_SET *set, SCIP_DIALOG *subdialog)
SCIP_RETCODE SCIPdialoghdlrGetLine(SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG *dialog, const char *prompt, char **inputline, SCIP_Bool *endoffile)
SCIP_RETCODE SCIPdialoghdlrExec(SCIP_DIALOGHDLR *dialoghdlr, SCIP_SET *set)
common defines and data types used in all packages of SCIP
SCIP_RETCODE SCIPdialoghdlrFree(SCIP *scip, SCIP_DIALOGHDLR **dialoghdlr)
SCIP_DIALOGDATA * SCIPdialogGetData(SCIP_DIALOG *dialog)
#define SCIP_ALLOC_TERMINATE(retcode, x, TERM)
static SCIP_RETCODE removeHistory(int pos)
memory allocation routines