bool ExecuteIfCommandComplete( void *theEnv) { if ((CompleteCommand(CommandLineData(theEnv)->CommandString) == 0) || (RouterData(theEnv)->CommandBufferInputCount == 0) || (RouterData(theEnv)->AwaitingInput == false)) { return false; } if (CommandLineData(theEnv)->BeforeCommandExecutionFunction != NULL) { if (! (*CommandLineData(theEnv)->BeforeCommandExecutionFunction)(theEnv)) { return false; } } FlushPPBuffer(theEnv); SetPPBufferStatus(theEnv,false); RouterData(theEnv)->CommandBufferInputCount = 0; RouterData(theEnv)->AwaitingInput = false; RouteCommand(theEnv,CommandLineData(theEnv)->CommandString,true); FlushPPBuffer(theEnv); FlushParsingMessages(theEnv); EnvSetHaltExecution(theEnv,false); EnvSetEvaluationError(theEnv,false); FlushCommandString(theEnv); CleanCurrentGarbageFrame(theEnv,NULL); CallPeriodicTasks(theEnv); PrintPrompt(theEnv); return true; }
void CommandLoop( void *theEnv) { int inchar; EnvPrintRouter(theEnv,WPROMPT,CommandLineData(theEnv)->BannerString); EnvSetHaltExecution(theEnv,false); EnvSetEvaluationError(theEnv,false); CleanCurrentGarbageFrame(theEnv,NULL); CallPeriodicTasks(theEnv); PrintPrompt(theEnv); RouterData(theEnv)->CommandBufferInputCount = 0; RouterData(theEnv)->AwaitingInput = true; while (true) { /*===================================================*/ /* If a batch file is active, grab the command input */ /* directly from the batch file, otherwise call the */ /* event function. */ /*===================================================*/ if (BatchActive(theEnv) == true) { inchar = LLGetcBatch(theEnv,STDIN,true); if (inchar == EOF) { (*CommandLineData(theEnv)->EventFunction)(theEnv); } else { ExpandCommandString(theEnv,(char) inchar); } } else { (*CommandLineData(theEnv)->EventFunction)(theEnv); } /*=================================================*/ /* If execution was halted, then remove everything */ /* from the command buffer. */ /*=================================================*/ if (EnvGetHaltExecution(theEnv) == true) { EnvSetHaltExecution(theEnv,false); EnvSetEvaluationError(theEnv,false); FlushCommandString(theEnv); #if ! WINDOW_INTERFACE fflush(stdin); #endif EnvPrintRouter(theEnv,WPROMPT,"\n"); PrintPrompt(theEnv); } /*=========================================*/ /* If a complete command is in the command */ /* buffer, then execute it. */ /*=========================================*/ ExecuteIfCommandComplete(theEnv); } }
void ClearDialogWnd ( void ) { extern int OldLine; extern SCREEN WinDialog; /*-----------------------------------------+ | Free all data associated with the screen | +-----------------------------------------*/ FreeTerminalText(); /*-----------------------------+ | Information about the Screen | +-----------------------------*/ WinDialog.LastLine = 0; OldLine = 0; /*-------------------+ | Update Scroll Bars | +-------------------*/ SetScrollRange ( WinDialog.hWnd, SB_VERT, WinDialog.NoLines-1, WinDialog.NoLines, FALSE); SetScrollPos ( WinDialog.hWnd, SB_VERT, WinDialog.NoLines, TRUE); SetScrollRange ( WinDialog.hWnd, SB_HORZ, 0, 1, FALSE); SetScrollPos ( WinDialog.hWnd, SB_HORZ, 0, TRUE); InvalidateRect ( WinDialog.hWnd, NULL, TRUE ); FlushCommandString(); }
globle void CommandLoop( void *theEnv) { int inchar; EnvPrintRouter(theEnv,WPROMPT,CommandLineData(theEnv)->BannerString); SetHaltExecution(theEnv,FALSE); SetEvaluationError(theEnv,FALSE); PeriodicCleanup(theEnv,TRUE,FALSE); PrintPrompt(theEnv); RouterData(theEnv)->CommandBufferInputCount = 0; while (TRUE) { /*===================================================*/ /* If a batch file is active, grab the command input */ /* directly from the batch file, otherwise call the */ /* event function. */ /*===================================================*/ if (BatchActive(theEnv) == TRUE) { inchar = LLGetcBatch(theEnv,"stdin",TRUE); if (inchar == EOF) { (*CommandLineData(theEnv)->EventFunction)(theEnv); } else { ExpandCommandString(theEnv,(char) inchar); } } else { (*CommandLineData(theEnv)->EventFunction)(theEnv); } /*=================================================*/ /* If execution was halted, then remove everything */ /* from the command buffer. */ /*=================================================*/ if (GetHaltExecution(theEnv) == TRUE) { SetHaltExecution(theEnv,FALSE); SetEvaluationError(theEnv,FALSE); FlushCommandString(theEnv); #if ! WINDOW_INTERFACE fflush(stdin); #endif EnvPrintRouter(theEnv,WPROMPT,"\n"); PrintPrompt(theEnv); } /*=========================================*/ /* If a complete command is in the command */ /* buffer, then execute it. */ /*=========================================*/ ExecuteIfCommandComplete(theEnv); } }
void CommandLoopBatchDriver( void *theEnv) { int inchar; while (true) { if (GetHaltCommandLoopBatch(theEnv) == true) { CloseAllBatchSources(theEnv); SetHaltCommandLoopBatch(theEnv,false); } /*===================================================*/ /* If a batch file is active, grab the command input */ /* directly from the batch file, otherwise call the */ /* event function. */ /*===================================================*/ if (BatchActive(theEnv) == true) { inchar = LLGetcBatch(theEnv,STDIN,true); if (inchar == EOF) { return; } else { ExpandCommandString(theEnv,(char) inchar); } } else { return; } /*=================================================*/ /* If execution was halted, then remove everything */ /* from the command buffer. */ /*=================================================*/ if (EnvGetHaltExecution(theEnv) == true) { EnvSetHaltExecution(theEnv,false); EnvSetEvaluationError(theEnv,false); FlushCommandString(theEnv); #if ! WINDOW_INTERFACE fflush(stdin); #endif EnvPrintRouter(theEnv,WPROMPT,"\n"); PrintPrompt(theEnv); } /*=========================================*/ /* If a complete command is in the command */ /* buffer, then execute it. */ /*=========================================*/ ExecuteIfCommandComplete(theEnv); } }
void SetNCommandString( void *theEnv, const char *str, unsigned length) { FlushCommandString(theEnv); CommandLineData(theEnv)->CommandString = (char *) genrealloc(theEnv,CommandLineData(theEnv)->CommandString,(unsigned) CommandLineData(theEnv)->MaximumCharacters, (unsigned) CommandLineData(theEnv)->MaximumCharacters + length + 1); genstrncpy(CommandLineData(theEnv)->CommandString,str,length); CommandLineData(theEnv)->CommandString[CommandLineData(theEnv)->MaximumCharacters + length] = 0; CommandLineData(theEnv)->MaximumCharacters += (length + 1); RouterData(theEnv)->CommandBufferInputCount += (int) length; }
void SetCommandString( void *theEnv, const char *str) { size_t length; FlushCommandString(theEnv); length = strlen(str); CommandLineData(theEnv)->CommandString = (char *) genrealloc(theEnv,CommandLineData(theEnv)->CommandString,(unsigned) CommandLineData(theEnv)->MaximumCharacters, (unsigned) CommandLineData(theEnv)->MaximumCharacters + length + 1); genstrcpy(CommandLineData(theEnv)->CommandString,str); CommandLineData(theEnv)->MaximumCharacters += (length + 1); RouterData(theEnv)->CommandBufferInputCount += (int) length; }
globle intBool ExecuteIfCommandComplete( void *theEnv) { if ((CompleteCommand(CommandLineData(theEnv)->CommandString) == 0) || (RouterData(theEnv)->CommandBufferInputCount <= 0)) { return FALSE; } FlushPPBuffer(theEnv); SetPPBufferStatus(theEnv,OFF); RouterData(theEnv)->CommandBufferInputCount = -1; RouteCommand(theEnv,CommandLineData(theEnv)->CommandString,TRUE); FlushPPBuffer(theEnv); SetHaltExecution(theEnv,FALSE); SetEvaluationError(theEnv,FALSE); FlushCommandString(theEnv); FlushBindList(theEnv); PeriodicCleanup(theEnv,TRUE,FALSE); PrintPrompt(theEnv); return TRUE; }