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);
727 assert(dialoghdlr !=
NULL);
730 cleanuphistory = (dialog !=
NULL);
736 if( command !=
NULL )
799 assert(dialog !=
NULL);
809 assert(num <= dialog->subdialogssize);
829 assert(dialog !=
NULL);
830 assert(name !=
NULL);
835 (*dialog)->dialogcopy = dialogcopy;
836 (*dialog)->dialogexec = dialogexec;
837 (*dialog)->dialogdesc = dialogdesc;
838 (*dialog)->dialogfree = dialogfree;
846 (*dialog)->desc =
NULL;
848 (*dialog)->issubmenu = issubmenu;
849 (*dialog)->parent =
NULL;
850 (*dialog)->subdialogs =
NULL;
851 (*dialog)->nsubdialogs = 0;
852 (*dialog)->subdialogssize = 0;
853 (*dialog)->nuses = 0;
854 (*dialog)->dialogdata = dialogdata;
878 assert(dialog !=
NULL);
879 assert(*dialog !=
NULL);
880 assert((*dialog)->nuses == 0);
883 if( (*dialog)->dialogfree !=
NULL )
885 SCIP_CALL( (*dialog)->dialogfree(scip, *dialog) );
889 for( i = 0; i < (*dialog)->nsubdialogs; ++i )
907 assert(dialog !=
NULL);
918 assert(dialog !=
NULL);
921 if( (*dialog)->nuses == 0 )
937 assert(dialog !=
NULL);
938 assert(dialog->dialogexec !=
NULL);
940 assert(nextdialog !=
NULL);
942 SCIP_CALL( dialog->dialogexec(set->scip, dialog, dialoghdlr, nextdialog) );
961 assert(dialog !=
NULL);
962 assert(subdialog !=
NULL);
967 SCIPerrorMessage(
"dialog entry with name <%s> already exists in dialog <%s>\n",
977 subdialog->parent = dialog;
988 const char* entryname
995 assert(dialog !=
NULL);
996 assert(entryname !=
NULL);
1001 for( i = 0; i < nsubdialogs; ++i )
1021 const char* entryname,
1026 unsigned int namelen;
1031 assert(dialog !=
NULL);
1032 assert(entryname !=
NULL);
1033 assert(subdialog !=
NULL);
1040 namelen = (
unsigned int) strlen(entryname);
1042 for( i = 0; i < nsubdialogs; ++i )
1047 *subdialog = subdialogs[i];
1070 assert(dialog !=
NULL);
1104 assert(dialog !=
NULL);
1112 if( strlen(name) > 21 )
1119 if( dialog->dialogdesc !=
NULL )
1121 SCIP_CALL( dialog->dialogdesc(scip, dialog) );
1134 const char* entryname
1138 unsigned int namelen;
1142 assert(dialog !=
NULL);
1143 assert(entryname !=
NULL);
1148 namelen = (
unsigned int) strlen(entryname);
1149 for( i = 0; i < nsubdialogs; ++i )
1170 assert(dialog !=
NULL);
1176 while( dialog !=
NULL )
1190 assert(dialog !=
NULL);
1192 return dialog->
name;
1200 assert(dialog !=
NULL);
1202 return dialog->
desc;
1210 assert(dialog !=
NULL);
1220 assert(dialog !=
NULL);
1230 assert(dialog !=
NULL);
1240 assert(dialog !=
NULL);
1250 assert(dialog !=
NULL);
1261 assert(dialog !=
NULL);
1268 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