MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / Prompt

Function Prompt

SRC/tcl/tclMain85.cpp:930–979  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

928 *
929 * Issue a prompt on standard output, or invoke a script to issue the
930 * prompt.
931 *
932 * Results:
933 * None.
934 *
935 * Side effects:
936 * A prompt gets output, and a Tcl script may be evaluated in interp.
937 *
938 *----------------------------------------------------------------------
939 */
940
941static void
942Prompt(
943 Tcl_Interp *interp, /* Interpreter to use for prompting. */
944 PromptType *promptPtr) /* Points to type of prompt to print. Filled
945 * with PROMPT_NONE after a prompt is
946 * printed. */
947{
948 Tcl_Obj *promptCmdPtr;
949 int code;
950 Tcl_Channel outChannel, errChannel;
951
952 if (*promptPtr == PROMPT_NONE) {
953 return;
954 }
955
956 promptCmdPtr = Tcl_GetVar2Ex(interp,
957 ((*promptPtr == PROMPT_CONTINUE) ? "tcl_prompt2" : "tcl_prompt1"),
958 NULL, TCL_GLOBAL_ONLY);
959
960 if (Tcl_InterpDeleted(interp)) {
961 return;
962 }
963 if (promptCmdPtr == NULL) {
964 defaultPrompt:
965 outChannel = Tcl_GetStdChannel(TCL_STDOUT);
966 if ((*promptPtr == PROMPT_START)
967 && (outChannel != (Tcl_Channel) NULL)) {
968 Tcl_WriteChars(outChannel, DEFAULT_PRIMARY_PROMPT,
969 strlen(DEFAULT_PRIMARY_PROMPT));
970 }
971 } else {
972 code = Tcl_EvalObjEx(interp, promptCmdPtr, TCL_EVAL_GLOBAL);
973 if (code != TCL_OK) {
974 Tcl_AddErrorInfo(interp,
975 "\n (script that generates prompt)");
976 errChannel = Tcl_GetStdChannel(TCL_STDERR);
977 if (errChannel != (Tcl_Channel) NULL) {
978 Tcl_WriteObj(errChannel, Tcl_GetObjResult(interp));
979 Tcl_WriteChars(errChannel, "\n", 1);
980 }
981 goto defaultPrompt;
982 }

Callers 2

tclMain85.cppFile · 0.70
StdinProcFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected