/// <summary>
        /// Creates a new code completion window.
        /// </summary>
        public PythonConsoleCompletionWindow(TextArea textArea, PythonTextEditor textEditor)
            : base(textArea)
        {
            // keep height automatic
            this.completionDataProvider = textEditor.CompletionProvider;
            this.textEditor = textEditor;
            this.CloseAutomatically = true;
            this.SizeToContent = SizeToContent.Height;
            this.MaxHeight = 300;
            this.Width = 175;
            this.Content = completionList;
            // prevent user from resizing window to 0x0
            this.MinHeight = 15;
            this.MinWidth = 30;

            toolTip.PlacementTarget = this;
            toolTip.Placement = PlacementMode.Right;
            toolTip.Closed += toolTip_Closed;

            completionList.InsertionRequested += completionList_InsertionRequested;
            completionList.SelectionChanged += completionList_SelectionChanged;
            AttachEvents();

            updateDescription = new DispatcherTimer();
            updateDescription.Tick += new EventHandler(completionList_UpdateDescription);
            updateDescriptionInterval = TimeSpan.FromSeconds(0.3);

            EventInfo eventInfo = typeof(TextView).GetEvent("ScrollOffsetChanged");
            Delegate methodDelegate = Delegate.CreateDelegate(eventInfo.EventHandlerType, (this as CompletionWindowBase), "TextViewScrollOffsetChanged");
            eventInfo.RemoveEventHandler(this.TextArea.TextView, methodDelegate);
        }
示例#2
0
        /// <summary>
        /// Creates a new code completion window.
        /// </summary>
        public PythonConsoleCompletionWindow(TextArea textArea, PythonTextEditor textEditor)
            : base(textArea)
        {
            // keep height automatic
            this.completionDataProvider = textEditor.CompletionProvider;
            this.textEditor             = textEditor;
            this.CloseAutomatically     = true;
            this.SizeToContent          = SizeToContent.Height;
            this.MaxHeight = 300;
            this.Width     = 250;
            this.Content   = completionList;
            // prevent user from resizing window to 0x0
            this.MinHeight = 15;
            this.MinWidth  = 30;

            toolTip.PlacementTarget = this;
            toolTip.Placement       = PlacementMode.Right;
            toolTip.Closed         += toolTip_Closed;

            completionList.InsertionRequested += completionList_InsertionRequested;
            completionList.SelectionChanged   += completionList_SelectionChanged;
            AttachEvents();

            updateDescription         = new DispatcherTimer();
            updateDescription.Tick   += new EventHandler(completionList_UpdateDescription);
            updateDescriptionInterval = TimeSpan.FromSeconds(0.3);

            EventInfo eventInfo      = typeof(TextView).GetEvent("ScrollOffsetChanged");
            Delegate  methodDelegate = Delegate.CreateDelegate(eventInfo.EventHandlerType, (this as CompletionWindowBase), "TextViewScrollOffsetChanged");

            eventInfo.RemoveEventHandler(this.TextArea.TextView, methodDelegate);
        }
示例#3
0
 public PythonConsolePad()
 {
     textEditor = new TextEditor();
     pythonTextEditor = new PythonTextEditor(textEditor);
     host = new PythonConsoleHost(pythonTextEditor);
     host.Run();
     textEditor.FontFamily = new FontFamily("Consolas");
     textEditor.FontSize = 12;
 }
示例#4
0
 public PythonConsolePad()
 {
     textEditor       = new TextEditor();
     pythonTextEditor = new PythonTextEditor(textEditor);
     host             = new PythonConsoleHost(pythonTextEditor);
     host.Run();
     textEditor.FontFamily = new FontFamily("Consolas");
     textEditor.FontSize   = 12;
 }
示例#5
0
 public PythonConsolePad()
 {
     _textEditor       = new TextEditor();
     _pythonTextEditor = new PythonTextEditor(_textEditor);
     _host             = new PythonConsoleHost(_pythonTextEditor);
     _host.Run();
     _textEditor.FontFamily = new FontFamily("Consolas");
     _textEditor.FontSize   = 12;
 }
        public PythonConsole(PythonTextEditor textEditor, CommandLine commandLine)
        {
            waitHandles = new WaitHandle[] { lineReceivedEvent, disposedEvent };

            this.commandLine = commandLine;
            this.textEditor = textEditor;
            textEditor.CompletionProvider = new PythonConsoleCompletionDataProvider(commandLine) { ExcludeCallables = disableAutocompletionForCallables };
            textEditor.PreviewKeyDown += textEditor_PreviewKeyDown;
            textEditor.TextEntering += textEditor_TextEntering;
            dispatcherThread = new Thread(new ThreadStart(DispatcherThreadStartingPoint));
            dispatcherThread.SetApartmentState(ApartmentState.STA);
            dispatcherThread.IsBackground = true;
            dispatcherThread.Start();

            // Only required when running outside REP loop.
            prompt = ">>> ";

            // Set commands:
            this.textEditor.textArea.Dispatcher.Invoke(new Action(delegate()
            {
                CommandBinding pasteBinding = null;
                CommandBinding copyBinding = null;
                CommandBinding cutBinding = null;
                CommandBinding undoBinding = null;
                CommandBinding deleteBinding = null;
                foreach (CommandBinding commandBinding in (this.textEditor.textArea.CommandBindings))
                {
                    if (commandBinding.Command == ApplicationCommands.Paste) pasteBinding = commandBinding;
                    if (commandBinding.Command == ApplicationCommands.Copy) copyBinding = commandBinding;
                    if (commandBinding.Command == ApplicationCommands.Cut) cutBinding = commandBinding;
                    if (commandBinding.Command == ApplicationCommands.Undo) undoBinding = commandBinding;
                    if (commandBinding.Command == ApplicationCommands.Delete) deleteBinding = commandBinding;
                }
                // Remove current bindings completely from control. These are static so modifying them will cause other
                // controls' behaviour to change too.
                if (pasteBinding != null) this.textEditor.textArea.CommandBindings.Remove(pasteBinding);
                if (copyBinding != null) this.textEditor.textArea.CommandBindings.Remove(copyBinding);
                if (cutBinding != null) this.textEditor.textArea.CommandBindings.Remove(cutBinding);
                if (undoBinding != null) this.textEditor.textArea.CommandBindings.Remove(undoBinding);
                if (deleteBinding != null) this.textEditor.textArea.CommandBindings.Remove(deleteBinding);
                this.textEditor.textArea.CommandBindings.Add(new CommandBinding(ApplicationCommands.Paste, OnPaste, CanPaste));
                this.textEditor.textArea.CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, OnCopy, PythonEditingCommandHandler.CanCutOrCopy));
                this.textEditor.textArea.CommandBindings.Add(new CommandBinding(ApplicationCommands.Cut, PythonEditingCommandHandler.OnCut, CanCut));
                this.textEditor.textArea.CommandBindings.Add(new CommandBinding(ApplicationCommands.Undo, OnUndo, CanUndo));
                this.textEditor.textArea.CommandBindings.Add(new CommandBinding(ApplicationCommands.Delete, PythonEditingCommandHandler.OnDelete(ApplicationCommands.NotACommand), CanDeleteCommand));

            }));
            // Set dispatcher to run on a UI thread independent of both the Control UI thread and thread running the REPL.
            WhenConsoleInitialized(delegate
            {
                SetCommandDispatcher(DispatchCommand);
            });
        }
示例#7
0
 public PythonConsolePad()
 {
     textEditor       = new TextEditor();
     pythonTextEditor = new PythonTextEditor(textEditor);
     host             = new PythonConsoleHost(pythonTextEditor);
     host.Run();
     textEditor.FontFamily = new FontFamily("Consolas");
     textEditor.FontSize   = 14;
     textEditor.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
     textEditor.VerticalScrollBarVisibility   = ScrollBarVisibility.Visible;
     textEditor.WordWrap = true;
 }
示例#8
0
 public PythonOutputStream(PythonTextEditor textEditor)
 {
     this.textEditor = textEditor;
 }
 public PythonEditingCommandHandler(PythonTextEditor textEditor)
 {
     this.textEditor = textEditor;
     this.textArea = textEditor.textArea;
 }
 public PythonConsoleHost(PythonTextEditor textEditor)
 {
     this.textEditor = textEditor;
 }
示例#11
0
 public PythonEditingCommandHandler(PythonTextEditor textEditor)
 {
     _textEditor = textEditor;
     _textArea   = textEditor.TextArea;
 }
示例#12
0
        public PythonConsole(PythonTextEditor textEditor, CommandLine commandLine)
        {
            waitHandles = new WaitHandle[] { lineReceivedEvent, disposedEvent };

            this.commandLine = commandLine;
            this.textEditor  = textEditor;
            textEditor.CompletionProvider = new PythonConsoleCompletionDataProvider(commandLine)
            {
                ExcludeCallables = disableAutocompletionForCallables
            };
            textEditor.PreviewKeyDown += textEditor_PreviewKeyDown;
            textEditor.TextEntering   += textEditor_TextEntering;
            dispatcherThread           = new Thread(new ThreadStart(DispatcherThreadStartingPoint));
            dispatcherThread.SetApartmentState(ApartmentState.STA);
            dispatcherThread.IsBackground = true;
            dispatcherThread.Start();

            // Only required when running outside REP loop.
            prompt = ">>> ";

            // Set commands:
            this.textEditor.textArea.Dispatcher.Invoke(new Action(delegate()
            {
                CommandBinding pasteBinding  = null;
                CommandBinding copyBinding   = null;
                CommandBinding cutBinding    = null;
                CommandBinding undoBinding   = null;
                CommandBinding deleteBinding = null;
                foreach (CommandBinding commandBinding in (this.textEditor.textArea.CommandBindings))
                {
                    if (commandBinding.Command == ApplicationCommands.Paste)
                    {
                        pasteBinding = commandBinding;
                    }
                    if (commandBinding.Command == ApplicationCommands.Copy)
                    {
                        copyBinding = commandBinding;
                    }
                    if (commandBinding.Command == ApplicationCommands.Cut)
                    {
                        cutBinding = commandBinding;
                    }
                    if (commandBinding.Command == ApplicationCommands.Undo)
                    {
                        undoBinding = commandBinding;
                    }
                    if (commandBinding.Command == ApplicationCommands.Delete)
                    {
                        deleteBinding = commandBinding;
                    }
                }
                // Remove current bindings completely from control. These are static so modifying them will cause other
                // controls' behaviour to change too.
                if (pasteBinding != null)
                {
                    this.textEditor.textArea.CommandBindings.Remove(pasteBinding);
                }
                if (copyBinding != null)
                {
                    this.textEditor.textArea.CommandBindings.Remove(copyBinding);
                }
                if (cutBinding != null)
                {
                    this.textEditor.textArea.CommandBindings.Remove(cutBinding);
                }
                if (undoBinding != null)
                {
                    this.textEditor.textArea.CommandBindings.Remove(undoBinding);
                }
                if (deleteBinding != null)
                {
                    this.textEditor.textArea.CommandBindings.Remove(deleteBinding);
                }
                this.textEditor.textArea.CommandBindings.Add(new CommandBinding(ApplicationCommands.Paste, OnPaste, CanPaste));
                this.textEditor.textArea.CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, OnCopy, PythonEditingCommandHandler.CanCutOrCopy));
                this.textEditor.textArea.CommandBindings.Add(new CommandBinding(ApplicationCommands.Cut, PythonEditingCommandHandler.OnCut, CanCut));
                this.textEditor.textArea.CommandBindings.Add(new CommandBinding(ApplicationCommands.Undo, OnUndo, CanUndo));
                this.textEditor.textArea.CommandBindings.Add(new CommandBinding(ApplicationCommands.Delete, PythonEditingCommandHandler.OnDelete(ApplicationCommands.NotACommand), CanDeleteCommand));
            }));
            // Set dispatcher to run on a UI thread independent of both the Control UI thread and thread running the REPL.
            WhenConsoleInitialized(delegate
            {
                SetCommandDispatcher(DispatchCommand);
            });
        }
示例#13
0
 public PythonOutputStream(PythonTextEditor textEditor)
 {
     this.textEditor = textEditor;
 }
 public PythonEditingCommandHandler(PythonTextEditor textEditor)
 {
     this.textEditor = textEditor;
     this.textArea   = textEditor.textArea;
 }
示例#15
0
 public PythonConsoleHost(PythonTextEditor textEditor)
 {
     this.textEditor = textEditor;
 }