Esempio n. 1
0
        //interface


        //constructor
        public Console(IConsoleTarget target)
        {
            if (target == null)
            {
                throw new ArgumentException("target cannot be null");
            }
            title       = target.ConsoleTitle;
            this.target = target;
            var targetScope = target.GetScope();
            var locals      = new IronPython.Runtime.PythonDictionary();

            foreach (var name in targetScope.GetVariableNames())
            {
                locals[name] = targetScope.GetVariable(name);
            }
            scope = Py.CreateScope();
            scope.SetVariable("_locals", locals);
            var    ops         = scope.Engine.Operations;
            string init_script = System.IO.File.ReadAllText(Util.ResourcePath("PythonScripts/initialize_new_console.py"));

            Py.Engine.Execute(init_script, scope);
            python_output_buffer    = scope.GetVariable <IronPython.Modules.PythonIOModule.StringIO>("output_buffer");
            python_compile_command  = scope.GetVariable <IronPython.Runtime.PythonFunction>("compile_command");
            python_console_run_code = scope.GetVariable <IronPython.Runtime.PythonFunction>("console_run_code");

            output             = new LineBuffer(new string[] { ">>> " });
            input              = new LineBuffer(new string[] { "" });
            editor             = new StringBuilder(500);
            multilineEditor    = new StringBuilder(500);
            _currentInputIndex = 0;
            _editorCursor      = 0;
        }
Esempio n. 2
0
 public ConsoleWindow(IConsoleTarget target)
     : this(new Console(target))
 {
 }