Example #1
0
        ///////////////////////////////////////////////////////////////////////////////////////////////

        public override bool SetBackgroundColor(
            ConsoleColor backgroundColor
            )
        {
            CheckDisposed();

            return(false);
        }
Example #2
0
        ///////////////////////////////////////////////////////////////////////////////////////////////

        public override bool SetForegroundColor(
            ConsoleColor foregroundColor
            )
        {
            CheckDisposed();

            return(false);
        }
Example #3
0
        ///////////////////////////////////////////////////////////////////////

        public override bool SetBackgroundColor(
            ConsoleColor backgroundColor
            )
        {
            CheckDisposed();

            /* IGNORED */
            return(true);
        }
Example #4
0
        ///////////////////////////////////////////////////////////////////////////////////////////////

        public override bool AdjustColors(
            ref ConsoleColor foregroundColor,
            ref ConsoleColor backgroundColor
            )
        {
            CheckDisposed();

            return(false);
        }
Example #5
0
        ///////////////////////////////////////////////////////////////////////

        public override bool AdjustColors(
            ref ConsoleColor foregroundColor,
            ref ConsoleColor backgroundColor
            )
        {
            CheckDisposed();

            /* IGNORED */
            return(true);
        }
Example #6
0
        ///////////////////////////////////////////////////////////////////////

        #region IInformationHost Members
        public override bool WriteCustomInfo(
            Interpreter interpreter,
            DetailFlags detailFlags,
            bool newLine,
            ConsoleColor foregroundColor,
            ConsoleColor backgroundColor
            )
        {
            CheckDisposed();

            return(true);
        }
Example #7
0
        private static ReturnCode TraceCallback(
            BreakpointType breakpointType, /* in */
            Interpreter interpreter,       /* in */
            ITraceInfo traceInfo,          /* in */
            ref Result result              /* out */
            )
        {
            if (interpreter == null)
            {
                //
                // NOTE: We require a valid interpreter context.  Most custom
                //       variable trace methods will want to do this because it
                //       is a fairly standard safety check (HIGHLY RECOMMENDED).
                //
                result = "invalid interpreter";
                return(ReturnCode.Error);
            }

            if (traceInfo == null)
            {
                //
                // NOTE: This parameter should contain the information about
                //       the current variable access being processed.  If it
                //       is null, we cannot continue (HIGHLY RECOMMENDED).
                //
                result = "invalid trace";
                return(ReturnCode.Error);
            }

            //
            // NOTE: This trace method intercepts and show all variable access
            //       for the interpreter.  We could do practically anything
            //       inside this method, including monitoring and/or modifying
            //       the values to be fetched and/or set, changing the state of
            //       the interpreter, or aborting the operation altogether.
            //
            ///////////////////////////////////////////////////////////////////
            // ******************* BEGIN CUSTOM TRACE CODE ********************
            ///////////////////////////////////////////////////////////////////

            //
            // NOTE: This particular variable trace method requires a valid
            //       interpreter host; however, in practice, such a requirement
            //       would be very rare.
            //
            IHost host = interpreter.Host;

            if (host == null)
            {
                result = "interpreter host not available";
                return(ReturnCode.Error);
            }

            //
            // NOTE: The try block here is optional; however, custom variable
            //       trace methods are "officially" discouraged from raising
            //       exceptions.
            //
            ReturnCode code = ReturnCode.Ok;

            switch (traceInfo.BreakpointType)
            {
            case BreakpointType.BeforeVariableUnset:
            {
                try
                {
                    //
                    // NOTE: Query the configured foreground and
                    //       background colors used by the host
                    //       to display variable trace information.
                    //
                    ConsoleColor foregroundColor = _ConsoleColor.None;
                    ConsoleColor backgroundColor = _ConsoleColor.None;

                    code = host.GetColors(null,
                                          "TraceInfo", true, true, ref foregroundColor,
                                          ref backgroundColor, ref result);

                    if (code == ReturnCode.Ok)
                    {
                        //
                        // NOTE: Clear the interpreter host and reset
                        //       its output position as well.
                        //
                        host.Clear();
                        host.ResetPosition();

                        //
                        // NOTE: Write the variable trace information
                        //       received by this method to the
                        //       interpreter host.
                        //
                        host.WriteTraceInfo(
                            interpreter, traceInfo,
                            DetailFlags.EmptyContent, true,
                            foregroundColor, backgroundColor);

                        host.RestorePosition(false);

                        int left = 0;
                        int top  = 0;

                        host.GetPosition(ref left, ref top);

                        left = 0;         /* NOTE: Left aligned. */
                        top++;            /* NOTE: On next line. */

                        host.WriteBox(null,
                                      "Press any key to continue...", null,
                                      false, false, ref left, ref top);

                        host.Pause();
                    }
                }
                catch (Exception e)
                {
                    result = e;
                    code   = ReturnCode.Error;
                }

                unsetTraces++;
                break;
            }

            case BreakpointType.BeforeVariableGet:
            {
                getTraces++;
                break;
            }

            case BreakpointType.BeforeVariableSet:
            {
                setTraces++;
                break;
            }
            }

            //
            // NOTE: Finally, return one of the standard status codes that
            //       indicate success / failure of this variable access.
            //
            return(code);

            ///////////////////////////////////////////////////////////////////
            // ******************** END CUSTOM TRACE CODE *********************
            ///////////////////////////////////////////////////////////////////
        }