public static void ShowWindow (char firstChar, ICompletionDataProvider provider, ICompletionWidget completionWidget, ICodeCompletionContext completionContext, CompletionDelegate closedDelegate)
		{
			try {
				if (!wnd.ShowListWindow (firstChar, provider,  completionWidget, completionContext, closedDelegate)) {
					provider.Dispose ();
					return;
				}
				
				// makes control-space in midle of words to work
				string text = wnd.completionWidget.GetCompletionText (completionContext);
				if (text.Length == 0) {
					text = provider.DefaultCompletionString;
					if (text != null && text.Length > 0)
						wnd.SelectEntry (text);
					return;
				}
				
				wnd.PartialWord = text; 
				//if there is only one matching result we take it by default
				if (wnd.IsUniqueMatch && !wnd.IsChanging)
				{	
					wnd.UpdateWord ();
					wnd.Hide ();
				}
				
			} catch (Exception ex) {
				Console.WriteLine (ex);
			}
		}
Esempio n. 2
0
        //========================================================================
        //  Constructors
        //========================================================================
        //Common Constructor Helper
        private void _initPre(string name, ProjectFile.FileType type)
        {
            InitializeComponent();

            icsEditor      = new TextEditorControl();
            icsEditor.Dock = DockStyle.Fill;
            icsEditor.Document.DocumentChanged += icsEditor_DocumentChanged;
            icsEditor.ActiveTextAreaControl.TextArea.MouseDown += new MouseEventHandler(icsEditor_MouseDown);
            icsEditor.VRulerRow   = 132;
            icsEditor.IndentStyle = IndentStyle.Smart;

            if (type == ProjectFile.FileType.REPGEN)
            {
                icsEditor.SetHighlighting("RepGen");
                completer = new RepGenComplete();
                folder    = new RepGenFold();
                icsEditor.Document.FoldingManager.FoldingStrategy = folder;
            }
            Controls.Add(icsEditor);

            DockAreas = DockAreas.Document;
            Text      = fileName = name;
            Icon      = IconFromType(type);
            fileType  = type;
        }
        bool ShowListWindow(char firstChar, ICompletionDataProvider provider, ICompletionWidget completionWidget, ICodeCompletionContext completionContext, CompletionDelegate closedDelegate)
        {
            if (mutableProvider != null)
            {
                mutableProvider.CompletionDataChanging -= OnCompletionDataChanging;
                mutableProvider.CompletionDataChanged  -= OnCompletionDataChanged;
            }

            this.provider          = provider;
            this.completionContext = completionContext;
            this.closedDelegate    = closedDelegate;
            mutableProvider        = provider as IMutableCompletionDataProvider;

            if (mutableProvider != null)
            {
                mutableProvider.CompletionDataChanging += OnCompletionDataChanging;
                mutableProvider.CompletionDataChanged  += OnCompletionDataChanged;

                if (mutableProvider.IsChanging)
                {
                    OnCompletionDataChanging(null, null);
                }
            }

            this.completionWidget = completionWidget;
            this.firstChar        = firstChar;

            return(FillList());
        }
        public static void ShowWindow(char firstChar, ICompletionDataProvider provider, ICompletionWidget completionWidget, ICodeCompletionContext completionContext, CompletionDelegate closedDelegate)
        {
            try
            {
                if (!wnd.ShowListWindow(firstChar, provider, completionWidget, completionContext, closedDelegate))
                {
                    provider.Dispose();
                    return;
                }

                // makes control-space in midle of words to work
                string text = wnd.completionWidget.GetCompletionText(completionContext);
                if (text.Length == 0)
                {
                    text = provider.DefaultCompletionString;
                    if (text != null && text.Length > 0)
                    {
                        wnd.SelectEntry(text);
                    }
                    return;
                }

                wnd.PartialWord = text;
                //if there is only one matching result we take it by default
                if (wnd.IsUniqueMatch && !wnd.IsChanging)
                {
                    wnd.UpdateWord();
                    wnd.Hide();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
 /// <summary>
 /// Overrides the base class method so a code completion window is
 /// not displayed but the fact that this method is called is
 /// recorded.
 /// </summary>
 protected override void ShowCodeCompletionWindow(SharpDevelopTextAreaControl textAreaControl, ICompletionDataProvider completionDataProvider, char ch)
 {
     textAreaControlUsedToShowCompletionWindow = textAreaControl;
     codeCompletionWindowDisplayed             = true;
     completionCharacter = ch;
     completionProviderUsedWhenDisplayingCodeCompletionWindow = completionDataProvider;
 }
Esempio n. 6
0
        CodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth)
            : base(parentForm, control)
        {
            this.dataProvider = completionDataProvider;
            this.completionData = completionData;
            this.document = control.Document;
            this.showDeclarationWindow = showDeclarationWindow;
            this.fixedListViewWidth = fixedListViewWidth;

            workingScreen = Screen.GetWorkingArea(Location);
            startOffset = control.ActiveTextAreaControl.Caret.Offset + 1;
            endOffset   = startOffset;
            if (completionDataProvider.PreSelection != null) {
                startOffset -= completionDataProvider.PreSelection.Length + 1;
                endOffset--;
            }

            codeCompletionListView = new CodeCompletionListView(completionData);
            codeCompletionListView.Font = new System.Drawing.Font(FontFamily.GenericMonospace, codeCompletionListView.Font.Size);
            codeCompletionListView.ImageList = completionDataProvider.ImageList;
            codeCompletionListView.Dock = DockStyle.Fill;
            codeCompletionListView.SelectedItemChanged += new EventHandler(CodeCompletionListViewSelectedItemChanged);
            codeCompletionListView.DoubleClick += new EventHandler(CodeCompletionListViewDoubleClick);
            codeCompletionListView.Click  += new EventHandler(CodeCompletionListViewClick);
            Controls.Add(codeCompletionListView);

            if (completionData.Length > MaxListLength) {
                vScrollBar.Dock = DockStyle.Right;
                vScrollBar.Minimum = 0;
                vScrollBar.Maximum = completionData.Length - 1;
                vScrollBar.SmallChange = 1;
                vScrollBar.LargeChange = MaxListLength;
                codeCompletionListView.FirstItemChanged += new EventHandler(CodeCompletionListViewFirstItemChanged);
                Controls.Add(vScrollBar);
            }

            this.drawingSize = GetListViewSize();
            SetLocation();

            if (declarationViewWindow == null) {
                declarationViewWindow = new DeclarationViewWindow(parentForm);
            }
            SetDeclarationViewLocation();
            declarationViewWindow.ShowDeclarationViewWindow();
            declarationViewWindow.MouseMove += ControlMouseMove;
            control.Focus();
            CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);

            if (completionDataProvider.DefaultIndex >= 0) {
                codeCompletionListView.SelectIndex(completionDataProvider.DefaultIndex);
            }

            if (completionDataProvider.PreSelection != null) {
                CaretOffsetChanged(this, EventArgs.Empty);
            }

            vScrollBar.ValueChanged += VScrollBarValueChanged;
            document.DocumentAboutToBeChanged += DocumentAboutToBeChanged;
        }
 public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char ch)
 {
     codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(WorkbenchSingleton.MainForm, this, this.FileName, completionDataProvider, ch);
     if (codeCompletionWindow != null)
     {
         codeCompletionWindow.Closed += new EventHandler(CloseCodeCompletionWindow);
     }
 }
Esempio n. 8
0
 public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char ch)
 {
     codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(this.FindForm(), this, this.FileName, completionDataProvider, ch);
     if (codeCompletionWindow != null)
     {
         codeCompletionWindow.Closed += new EventHandler(CloseCodeCompletionWindow);
     }
 }
        /// <remarks>
        /// Creates a new Completion window at a given location
        /// </remarks>
        CompletionWindow(TextEditorControl control, Point location, ICompletionDataProvider completionDataProvider)
            : base(type)
        {
            this.completionDataProvider = completionDataProvider;
            this.control                = control;

            InitializeControls();
        }
 public override void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char ch)
 {
     codeCompletionWindow = IdeBridgeCodeCompletionWindow.ShowCompletionWindow(WorkbenchSingleton.MainForm, this, _backend.FileName, completionDataProvider, ch);
     if (codeCompletionWindow != null)
     {
         codeCompletionWindow.Closed += new EventHandler(CloseCodeCompletionWindow);
     }
 }
Esempio n. 11
0
 public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider)
 {
     completionWindow = CodeCompletionWindow.ShowCompletionWindow(textEditorControl.ParentForm, textEditorControl, String.Empty, completionDataProvider, ' ');
     if (completionWindow != null)
     {
         completionWindow.Closed += CompletionWindowClosed;
     }
 }
		CodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth) : base(parentForm, control)
		{
			this.dataProvider = completionDataProvider;
			this.completionData = completionData;
			this.document = control.Document;
			this.showDeclarationWindow = showDeclarationWindow;
			this.fixedListViewWidth = fixedListViewWidth;

			workingScreen = Screen.GetWorkingArea(Location);
			startOffset = control.ActiveTextAreaControl.Caret.Offset + 1;
			endOffset   = startOffset;
			if (completionDataProvider.PreSelection != null) {
				startOffset -= completionDataProvider.PreSelection.Length + 1;
				endOffset--;
			}
			
			codeCompletionListView = new CodeCompletionListView(completionData);
            codeCompletionListView.Font = new System.Drawing.Font(FontFamily.GenericMonospace, codeCompletionListView.Font.Size);
			codeCompletionListView.ImageList = completionDataProvider.ImageList;
			codeCompletionListView.Dock = DockStyle.Fill;
			codeCompletionListView.SelectedItemChanged += new EventHandler(CodeCompletionListViewSelectedItemChanged);
			codeCompletionListView.DoubleClick += new EventHandler(CodeCompletionListViewDoubleClick);
			codeCompletionListView.Click  += new EventHandler(CodeCompletionListViewClick);
			Controls.Add(codeCompletionListView);
			
			if (completionData.Length > MaxListLength) {
				vScrollBar.Dock = DockStyle.Right;
				vScrollBar.Minimum = 0;
				vScrollBar.Maximum = completionData.Length - 1;
				vScrollBar.SmallChange = 1;
				vScrollBar.LargeChange = MaxListLength;
				codeCompletionListView.FirstItemChanged += new EventHandler(CodeCompletionListViewFirstItemChanged);
				Controls.Add(vScrollBar);
			}
			
			this.drawingSize = GetListViewSize();
			SetLocation();
			
			if (declarationViewWindow == null) {
				declarationViewWindow = new DeclarationViewWindow(parentForm);
			}
			SetDeclarationViewLocation();
			declarationViewWindow.ShowDeclarationViewWindow();
			declarationViewWindow.MouseMove += ControlMouseMove;
			control.Focus();
			CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);
			
			if (completionDataProvider.DefaultIndex >= 0) {
				codeCompletionListView.SelectIndex(completionDataProvider.DefaultIndex);
			}
			
			if (completionDataProvider.PreSelection != null) {
				CaretOffsetChanged(this, EventArgs.Empty);
			}
			
			vScrollBar.ValueChanged += VScrollBarValueChanged;
			document.DocumentAboutToBeChanged += DocumentAboutToBeChanged;
		}
 public override void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char firstChar)
 {
     completionWindow = CodeCompletionWindow.ShowCompletionWindow(textEditorControl.ParentForm, textEditorControl, String.Empty, completionDataProvider, firstChar);
     if (completionWindow != null)
     {
         completionWindow.Width   = 250;
         completionWindow.Closed += CompletionWindowClosed;
     }
 }
Esempio n. 14
0
        CodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, string fileName) : base(parentForm, control, fileName)
        {
            this.dataProvider   = completionDataProvider;
            this.completionData = completionData;

            workingScreen = Screen.GetWorkingArea(Location);
            startOffset   = control.ActiveTextAreaControl.Caret.Offset + 1;
            endOffset     = startOffset;
            if (completionDataProvider.PreSelection != null)
            {
                startOffset -= completionDataProvider.PreSelection.Length + 1;
                endOffset--;
            }

            codeCompletionListView                      = new CodeCompletionListView(completionData);
            codeCompletionListView.ImageList            = completionDataProvider.ImageList;
            codeCompletionListView.Dock                 = DockStyle.Fill;
            codeCompletionListView.SelectedItemChanged += new EventHandler(CodeCompletionListViewSelectedItemChanged);
            codeCompletionListView.DoubleClick         += new EventHandler(CodeCompletionListViewDoubleClick);
            codeCompletionListView.Click               += new EventHandler(CodeCompletionListViewClick);
            Controls.Add(codeCompletionListView);

            if (completionData.Length > 10)
            {
                vScrollBar.Dock        = DockStyle.Right;
                vScrollBar.Minimum     = 0;
                vScrollBar.Maximum     = completionData.Length - 8;
                vScrollBar.SmallChange = 1;
                vScrollBar.LargeChange = 3;
                codeCompletionListView.FirstItemChanged += new EventHandler(CodeCompletionListViewFirstItemChanged);
                Controls.Add(vScrollBar);
            }

            this.drawingSize = new Size(codeCompletionListView.ItemHeight * 10, codeCompletionListView.ItemHeight * Math.Min(10, completionData.Length));
            SetLocation();

            if (declarationViewWindow == null)
            {
                declarationViewWindow = new DeclarationViewWindow(parentForm);
            }
            SetDeclarationViewLocation();
            declarationViewWindow.ShowDeclarationViewWindow();
            control.Focus();
            CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);

            if (completionDataProvider.DefaultIndex >= 0)
            {
                codeCompletionListView.SelectIndex(completionDataProvider.DefaultIndex);
            }

            if (completionDataProvider.PreSelection != null)
            {
                CaretOffsetChanged(this, EventArgs.Empty);
            }

            vScrollBar.Scroll += new ScrollEventHandler(DoScroll);
        }
        /// <remarks>
        /// Creates a new Completion window and puts it location under the caret
        /// </remarks>
        public CompletionWindow(TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider)
            : base(type)
        {
            this.fileName = fileName;
            this.completionDataProvider = completionDataProvider;
            this.control                = control;

            InitializeControls();
        }
 public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char ch)
 {
     _codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(
         ParentForm, this, FileName, completionDataProvider, ch);
     if (_codeCompletionWindow != null)
     {
         _codeCompletionWindow.Closed += CloseCodeCompletionWindow;
     }
 }
 protected IdeBridgeCodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth)
     : base(completionDataProvider, completionData, parentForm, control, showDeclarationWindow, fixedListViewWidth)
 {
     TopMost = true;
     declarationViewWindow.Dispose();
     declarationViewWindow = new DeclarationViewWindow(null);
     declarationViewWindow.TopMost = true;
     SetDeclarationViewLocation();
 }
 private CodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth) : base(parentForm, control)
 {
     this.dataProvider          = completionDataProvider;
     this.completionData        = completionData;
     this.document              = control.Document;
     this.showDeclarationWindow = showDeclarationWindow;
     this.fixedListViewWidth    = fixedListViewWidth;
     this.workingScreen         = Screen.GetWorkingArea(base.Location);
     this.startOffset           = control.ActiveTextAreaControl.Caret.Offset + 1;
     this.endOffset             = this.startOffset;
     if (completionDataProvider.PreSelection != null)
     {
         CodeCompletionWindow length = this;
         length.startOffset = length.startOffset - (completionDataProvider.PreSelection.Length + 1);
         this.endOffset--;
     }
     this.codeCompletionListView = new CodeCompletionListView(completionData)
     {
         ImageList = completionDataProvider.ImageList,
         Dock      = DockStyle.Fill
     };
     this.codeCompletionListView.SelectedItemChanged += new EventHandler(this.CodeCompletionListViewSelectedItemChanged);
     this.codeCompletionListView.DoubleClick         += new EventHandler(this.CodeCompletionListViewDoubleClick);
     this.codeCompletionListView.Click += new EventHandler(this.CodeCompletionListViewClick);
     base.Controls.Add(this.codeCompletionListView);
     if ((int)completionData.Length > 10)
     {
         this.vScrollBar.Dock        = DockStyle.Right;
         this.vScrollBar.Minimum     = 0;
         this.vScrollBar.Maximum     = (int)completionData.Length - 1;
         this.vScrollBar.SmallChange = 1;
         this.vScrollBar.LargeChange = 10;
         this.codeCompletionListView.FirstItemChanged += new EventHandler(this.CodeCompletionListViewFirstItemChanged);
         base.Controls.Add(this.vScrollBar);
     }
     this.drawingSize = this.GetListViewSize();
     this.SetLocation();
     if (this.declarationViewWindow == null)
     {
         this.declarationViewWindow = new DeclarationViewWindow(parentForm);
     }
     this.SetDeclarationViewLocation();
     this.declarationViewWindow.ShowDeclarationViewWindow();
     this.declarationViewWindow.MouseMove += new MouseEventHandler(this.ControlMouseMove);
     control.Focus();
     this.CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);
     if (completionDataProvider.DefaultIndex >= 0)
     {
         this.codeCompletionListView.SelectIndex(completionDataProvider.DefaultIndex);
     }
     if (completionDataProvider.PreSelection != null)
     {
         this.CaretOffsetChanged(this, EventArgs.Empty);
     }
     this.vScrollBar.ValueChanged           += new EventHandler(this.VScrollBarValueChanged);
     this.document.DocumentAboutToBeChanged += new DocumentEventHandler(this.DocumentAboutToBeChanged);
 }
    /// <summary>
    /// Shows the completion window.
    /// </summary>
    /// <param name="parent">The parent.</param>
    /// <param name="control">The text editor control.</param>
    /// <param name="fileName">Name of the file.</param>
    /// <param name="completionDataProvider">The completion data provider.</param>
    /// <param name="firstChar">The first char.</param>
    /// <param name="showDeclarationWindow"><see langword="true"/> to show declaration window; otherwise <see langword="false"/>.</param>
    /// <param name="fixedListViewWidth"><see langword="true"/> to use a fixed width in the list view.</param>
    /// <param name="closeAutomatically"><see langword="true"/> to close the completion window automatically.</param>
    /// <returns>The code completion window.</returns>
    public static CompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth, bool closeAutomatically)
    {
      ICompletionData[] completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar);
      if (completionData == null || completionData.Length == 0)
        return null;

      CompletionWindow codeCompletionWindow = new CompletionWindow(completionDataProvider, completionData, parent, control, showDeclarationWindow, fixedListViewWidth, closeAutomatically);
      codeCompletionWindow.ShowCompletionWindow();
      return codeCompletionWindow;
    }
Esempio n. 20
0
		public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar)
		{
			ICompletionData[] completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar);
			if (completionData == null || completionData.Length == 0) {
				return null;
			}
			CodeCompletionWindow codeCompletionWindow = new CodeCompletionWindow(completionDataProvider, completionData, parent, control);
			codeCompletionWindow.ShowCompletionWindow();
			return codeCompletionWindow;
		}
        public static PABCNETCodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool visibleKeyPressed, bool is_by_dot,PascalABCCompiler.Parsers.KeywordKind keyw)
		{
        	ICompletionData[] completionData = (completionDataProvider as VisualPascalABC.CodeCompletionProvider).GenerateCompletionDataWithKeyword(fileName, control.ActiveTextAreaControl.TextArea, firstChar, keyw);
			if (completionData == null || completionData.Length == 0) {
				return null;
			}
            PABCNETCodeCompletionWindow codeCompletionWindow = new PABCNETCodeCompletionWindow(completionDataProvider, completionData, parent, control, visibleKeyPressed, is_by_dot);
			codeCompletionWindow.ShowCompletionWindow();
			return codeCompletionWindow;
		}
        public static PABCNETCodeCompletionWindow ShowOverridableMethodsCompletionWindows(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider)
        {
        	ICompletionData[] completionData = (completionDataProvider as VisualPascalABC.CodeCompletionProvider).GenerateCompletionDataForOverridableMethods(fileName, control.ActiveTextAreaControl.TextArea);
        	if (completionData == null || completionData.Length == 0) {
				return null;
			}
        	PABCNETCodeCompletionWindow codeCompletionWindow = new PABCNETCodeCompletionWindow(completionDataProvider, completionData, parent, control, false, false);
			codeCompletionWindow.is_overrided_meths = true;
        	codeCompletionWindow.ShowCompletionWindow();
			return codeCompletionWindow;
        }
        public static PABCNETCodeCompletionWindow ShowCompletionWindowWithFirstChar(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, PascalABCCompiler.Parsers.KeywordKind keyw)
        {
        	ICompletionData[] completionData = (completionDataProvider as VisualPascalABC.CodeCompletionProvider).GenerateCompletionDataByFirstChar(fileName, control.ActiveTextAreaControl.TextArea, firstChar, keyw);
        	if (completionData == null || completionData.Length == 0) {
				return null;
			}
        	(completionDataProvider as VisualPascalABC.CodeCompletionProvider).preSelection = firstChar.ToString();
            PABCNETCodeCompletionWindow codeCompletionWindow = new PABCNETCodeCompletionWindow(completionDataProvider, completionData, parent, control, true, false);
			codeCompletionWindow.ShowCompletionWindow();
			return codeCompletionWindow;
        }
Esempio n. 24
0
		public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth)
		{
			ICompletionData[] completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar);
			if (completionData == null || completionData.Length == 0) {
				return null;
			}
			CodeCompletionWindow codeCompletionWindow = new CodeCompletionWindow(completionDataProvider, completionData, parent, control, showDeclarationWindow, fixedListViewWidth);
			codeCompletionWindow.CloseWhenCaretAtBeginning = firstChar == '\0';
			codeCompletionWindow.ShowCompletionWindow();
			return codeCompletionWindow;
		}
Esempio n. 25
0
        AutoCompleteWindow(ICompletionDataProvider completionDataProvider, Form parentForm, TextEditorControl control, string fileName, bool showDeclarationWindow)
            : base(parentForm, control)
        {
            this.showDeclarationWindow = showDeclarationWindow;

            workingScreen = Screen.GetWorkingArea(Location);
            startOffset = control.ActiveTextAreaControl.Caret.Offset + 1;
            endOffset = startOffset;
            if (completionDataProvider.PreSelection != null)
            {
                startOffset -= completionDataProvider.PreSelection.Length + 1;
                endOffset--;
            }

            codeCompletionListView = new CodeCompletionListView(completionData);
            codeCompletionListView.ImageList = completionDataProvider.ImageList;
            codeCompletionListView.Dock = DockStyle.Fill;
            codeCompletionListView.SelectedItemChanged += new EventHandler(CodeCompletionListViewSelectedItemChanged);
            codeCompletionListView.DoubleClick += new EventHandler(CodeCompletionListViewDoubleClick);
            codeCompletionListView.Click += new EventHandler(CodeCompletionListViewClick);
            Controls.Add(codeCompletionListView);

            if (completionData.Length > 10)
            {
                vScrollBar.Dock = DockStyle.Right;
                vScrollBar.Minimum = 0;
                vScrollBar.Maximum = completionData.Length - 8;
                vScrollBar.SmallChange = 1;
                vScrollBar.LargeChange = 3;
                codeCompletionListView.FirstItemChanged += new EventHandler(CodeCompletionListViewFirstItemChanged);
                Controls.Add(vScrollBar);
            }

            this.drawingSize = GetListViewSize();
            SetLocation();

            declarationViewWindow = new DeclarationViewWindow(parentForm);
            SetDeclarationViewLocation();
            declarationViewWindow.ShowDeclarationViewWindow();
            control.Focus();
            CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);

            if (completionDataProvider.DefaultIndex >= 0)
            {
                codeCompletionListView.SelectIndex(completionDataProvider.DefaultIndex);
            }

            if (completionDataProvider.PreSelection != null)
            {
                CaretOffsetChanged(this, EventArgs.Empty);
            }

            vScrollBar.Scroll += new ScrollEventHandler(DoScroll);
        }
Esempio n. 26
0
        // Was part of the CodeCompletionKeyHandler file

        /// <summary>
        /// Return true to handle the keypress, return false to let the text area handle the keypress
        /// </summary>
        public bool TextAreaKeyEventHandler(char key)
        {
            if (codeCompletionWindow != null)
            {
                // If completion window is open and wants to handle the key, don't let the text area
                // handle it

                if (codeCompletionWindow != null)
                {
                    if (codeCompletionWindow.ProcessKeyEvent(key))
                    {
                        return(true);
                    }
                }
            }
            //         "key pressed:{0}".format(key).info();
            if (key == '.')
            {
                //O2Thread.mtaThread(   //I really want to run this on a separate thread but It is causing a weird problem where the codecomplete only happens after the 2nd char
                //() =>
                //{
                currentExpression = FindExpression();
                //var o2Timer = new O2Timer("Code Completion").start();
                //textEditor.invokeOnThread(()=> textEditor.textArea().Caret.Column ++ );
                try
                {
                    //startOffset = textEditor.currentOffset() + 1;   // it was +1 before we made this run on an mta thread
                    ICompletionDataProvider completionDataProvider = this;    //new CodeCompletionProvider(this);

                    codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(
                        textEditor.ParentForm,                                          // The parent window for the completion window
                        textEditor,                                                     // The text editor to show the window for
                        DummyFileName,                                                  // Filename - will be passed back to the provider
                        completionDataProvider,                                         // Provider to get the list of possible completions
                        key                                                             // Key pressed - will be passed to the provider
                        );

                    if (codeCompletionWindow != null)
                    {
                        // ShowCompletionWindow can return null when the provider returns an empty list
                        codeCompletionWindow.Closed += new EventHandler(CloseCodeCompletionWindow);
                    }
                    //textEditor.insertTextAtCurrentCaretLocation(".");
                }
                catch (Exception ex)
                {
                    ex.log("in O2CodeCompletion.TextAreaKeyEventHandler");
                }
                //  o2Timer.stop();
                //});
//                return true;
            }
            return(false);
        }
Esempio n. 27
0
        //------------------------------------------------------------------------
        private void SaveAsSymitar()
        {
            frmFileOpen  saveAs = new frmFileOpen(fileName);
            DialogResult result = saveAs.ShowDialog(Util.MainForm);

            if (result == DialogResult.Cancel)
            {
                saveAs.Dispose();
                return;
            }
            if (result == DialogResult.No)
            {
                saveAs.Dispose();
                SaveAsLocal();
                return;
            }
            if (saveAs.saveAsIsLocal) //not a Local Filesystem file, but a LOCAL mounted Filesystem file
            {
                fileLocal = saveAs.saveAsLocal.Path + '\\' + saveAs.saveAsName;
                if (SaveLocal())
                {
                    fileOrigin = Origin.LOCAL;
                    fileType   = FileTypeFromExtension(fileLocal);
                    Icon       = IconFromType(fileType);
                }
            }
            else
            {
                SymInst inst = saveAs.saveAsInst;
                fileSym  = new SymFile(inst.Parent.IP, inst.SymDir, saveAs.saveAsName, DateTime.Now, icsEditor.Text.Length, saveAs.saveAsType);
                fileName = saveAs.saveAsName;
                if (SaveSymitar())
                {
                    fileOrigin = Origin.SYM;
                    fileType   = FileTypeFromSymFile(fileSym);
                    Icon       = IconFromType(fileType);
                    if (fileType == ProjectFile.FileType.REPGEN)
                    {
                        icsEditor.SetHighlighting("RepGen");
                        completer = new RepGenComplete();
                        folder    = new RepGenFold();
                        icsEditor.Document.FoldingManager.FoldingStrategy = folder;
                    }
                    else if (fileType == ProjectFile.FileType.LETTER)
                    {
                        icsEditor.SetHighlighting("Default");
                        icsEditor.Document.FoldingManager.FoldingStrategy = new ICSharpCode.TextEditor.Document.IndentFoldingStrategy();
                    }
                    SetModified(false, true);
                }
            }
        }
Esempio n. 28
0
        public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char ch)
        {
#if ModifiedForAltaxo
            Form active = Form.ActiveForm;
            codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(active, this, this.FileName, completionDataProvider, ch);
#else
            codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow((Form)WorkbenchSingleton.Workbench, this, this.FileName, completionDataProvider, ch);
#endif
            if (codeCompletionWindow != null)
            {
                codeCompletionWindow.Closed += new EventHandler(CloseCodeCompletionWindow);
            }
        }
Esempio n. 29
0
 CodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth) : base(parentForm, control)
 {
     this.dataProvider          = completionDataProvider;
     this.completionData        = completionData;
     this.document              = control.Document;
     this.showDeclarationWindow = showDeclarationWindow;
     this.fixedListViewWidth    = fixedListViewWidth;
     this.guiLoaded             = false;
     startOffset = control.ActiveTextAreaControl.Caret.Offset + 1;
     endOffset   = startOffset;
     //startOffset = -1;
     //endOffset = -1;
 }
		public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth)
		{
            if (busy)  // DC to prevent multiple calls
            {
                "CodeCompletionWindow.ShowCompletionWindow was busy, skipping ShowCompletionWindow calculation".info();
                return null;
            }

                busy = true;
                return (CodeCompletionWindow)parent.invokeOnThread(
                    () =>
                    {
                        try
                        {

                            var tempCompletionData = new ICompletionData[] { };
                            CodeCompletionWindow codeCompletionWindow = new CodeCompletionWindow(completionDataProvider, tempCompletionData, parent, control, showDeclarationWindow, fixedListViewWidth);
                            codeCompletionWindow.CloseWhenCaretAtBeginning = firstChar == '\0';
                            codeCompletionWindow.ShowCompletionWindow();

                            O2Thread.mtaThread(         // run in on a separate thread for performance reasons
                                () =>
                                {
                                    try
                                    {
                                        ICompletionData[] completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar);
                                        if (completionData == null || completionData.Length == 0)
                                        {
                                            //return null;
                                        }
                                        else
                                            codeCompletionWindow.setCodeCompletionData(completionData);
                                        busy = false;
                                    }
                                    catch (Exception ex)
                                    {
                                        ex.log("in CodeCompletionWindow.ShowCompletionWindow ");
                                    }
                                });

                            return codeCompletionWindow;
                        }
                        catch (Exception ex)
                        {
                            busy = false;
                            return null;
                        }
                    });
            
		}     
Esempio n. 31
0
        public override ICompletionDataProvider CodeCompletionCommand(CodeCompletionContext completionContext)
        {
            int    pos = completionContext.TriggerOffset;
            string txt = Editor.GetText(pos - 1, pos);
            int    triggerWordLength   = 0;
            ICompletionDataProvider cp = null;

            if (txt.Length > 0)
            {
                cp = HandleCodeCompletion((CodeCompletionContext)completionContext, true, ref triggerWordLength);
            }

            return(cp);
        }
Esempio n. 32
0
 CodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth)
     : base(parentForm, control)
 {
     this.dataProvider = completionDataProvider;
     this.completionData = completionData;
     this.document = control.Document;
     this.showDeclarationWindow = showDeclarationWindow;
     this.fixedListViewWidth = fixedListViewWidth;
     this.guiLoaded = false;
     startOffset = control.ActiveTextAreaControl.Caret.Offset +1;
     endOffset = startOffset;
     //startOffset = -1;
     //endOffset = -1;
 }
 public new void Hide()
 {
     base.Hide();
     declarationviewwindow.HideAll();
     if (provider != null)
     {
         provider.Dispose();
         provider = null;
     }
     if (closedDelegate != null)
     {
         closedDelegate();
         closedDelegate = null;
     }
 }
Esempio n. 34
0
 /// <summary>
 /// Shows the code completion window if the keyword is handled.
 /// </summary>
 /// <param name="word">The keyword string.</param>
 /// <returns>true if the keyword is handled; otherwise false.</returns>
 public override bool HandleKeyword(SharpDevelopTextAreaControl editor, string word)
 {
     if (word != null)
     {
         switch (word.ToLowerInvariant())
         {
         case "import":
         case "from":
             ICompletionDataProvider dataProvider = CreateCompletionDataProvider();
             ShowCodeCompletionWindow(editor, dataProvider, ' ');
             return(true);
         }
     }
     return(false);
 }
		public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth)
		{
            if (busy)  // DC to prevent multiple calls
            {
                "CodeCompletionWindow.ShowCompletionWindow was busy, skipping ShowCompletionWindow calculation".info();
                return null;
            }

            busy = true;
            
            //return (CodeCompletionWindow)parent.invokeOnThread(
            return (CodeCompletionWindow)control.invokeOnThread(
                        ()=>{
                                return ShowCompletionWindow_Thread(parent, control, fileName,completionDataProvider, firstChar, showDeclarationWindow, fixedListViewWidth);
                            });
            
		}
        public override void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char firstChar)
        {
            //Not ready for beta 5. Remove after release of beta 5.
            return;

            /*
             * var context = new AutoCompletionListBox.AutoCompleteContext()
             * {
             *  AutoCompleteTooltip = _autoCompleteTooltip,
             *  CompletionProvider = completionDataProvider,
             *  Editor = textEditorControl,
             *  FirstChar = firstChar,
             *  GetCaretPoint = GetCaretPoint,
             *  InsertionOffset = textEditorControl.ActiveTextAreaControl.Caret.Offset
             * };
             * _autoBox.SetCompletionItems(textEditorControl.ParentForm, context, string.Empty);
             */
        }
Esempio n. 37
0
        public static CompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, ICompletionDataProvider completionDataProvider, Point location)
        {
            CompletionDataProvider = completionDataProvider;
            var completionData = CompletionDataProvider.GenerateCompletionData(null, null, ' ');

            if (completionData.Length == 0)
            {
                return(null);
            }

            var window = new CompletionWindow(parent, control);

            window.RefreshList(completionData);
            //window.SetLocation();
            window.Location = location;
            window.ShowCompletionWindow();
            return(window);
        }
Esempio n. 38
0
        public static CompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName,
                                                            ICompletionDataProvider completionDataProvider, char firstChar)
        {
            CompletionDataProvider = completionDataProvider;
            var completionData = CompletionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar);

            if (completionData.Length == 0)
            {
                return(null);
            }

            var window = new CompletionWindow(parent, control);

            window.RefreshList(completionData);
            window.SetLocation();
            window.ShowCompletionWindow();
            return(window);
        }
Esempio n. 39
0
        //------------------------------------------------------------------------
        private void SaveAsLocal()
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.DefaultExt = ExtensionFromType(fileType);
            sfd.Filter     = "All Files (*.*)|*.*";
            sfd.FileName   = fileName;
            sfd.Title      = "Save As";
            if (fileLocal != null)
            {
                sfd.InitialDirectory = Util.FileDirectoryPathLocal(fileLocal);
            }
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Util.FileWriteLocal(sfd.FileName, icsEditor.Text);
                    fileLocal  = sfd.FileName;
                    fileName   = Util.FileBaseNameLocal(fileLocal);
                    fileOrigin = Origin.LOCAL;
                    fileType   = FileTypeFromExtension(fileLocal);
                    Icon       = IconFromType(fileType);
                    if (fileType == ProjectFile.FileType.REPGEN)
                    {
                        icsEditor.SetHighlighting("RepGen");
                        completer = new RepGenComplete();
                        folder    = new RepGenFold();
                        icsEditor.Document.FoldingManager.FoldingStrategy = folder;
                    }
                    else if (fileType == ProjectFile.FileType.LETTER)
                    {
                        icsEditor.SetHighlighting("Default");
                        icsEditor.Document.FoldingManager.FoldingStrategy = new ICSharpCode.TextEditor.Document.IndentFoldingStrategy();
                    }
                    SetModified(false, true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error Saving File\n" + ex.Message, "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            sfd.Dispose();
        }
        public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName,
                                                                ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow,
                                                                bool fixedListViewWidth)
        {
            var completionData =
                completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea,
                                                              firstChar);

            if (completionData == null || completionData.Length == 0)
            {
                return(null);
            }
            var codeCompletionWindow = new CodeCompletionWindow(completionDataProvider, completionData, parent, control,
                                                                showDeclarationWindow, fixedListViewWidth);

            codeCompletionWindow.CloseWhenCaretAtBeginning = firstChar == '\0';
            codeCompletionWindow.ShowCompletionWindow();
            return(codeCompletionWindow);
        }
        public static CodeCompletionWindow ShowCompletionWindow_Thread(Form parent,TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth)
        { 
            try
                {

                    var tempCompletionData = new ICompletionData[] { };
                    CodeCompletionWindow codeCompletionWindow = new CodeCompletionWindow(completionDataProvider, tempCompletionData, parent, control, showDeclarationWindow, fixedListViewWidth);
	                codeCompletionWindow.CloseWhenCaretAtBeginning = firstChar == '\0';
                    codeCompletionWindow.ShowCompletionWindow();

					codeCompletionWindow.AfterWindowOpen.invoke();

                    O2Thread.mtaThread(         // run in on a separate thread for performance reasons
                        () =>
                        {
                            try
                            {
                                ICompletionData[] completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar);
                                if (completionData == null || completionData.Length == 0)
                                {
                                    //"There was no CompleteData".error();
                                    //return null;
                                }
                                else
                                    codeCompletionWindow.setCodeCompletionData(completionData);                                
                            }
                            catch (Exception ex)
                            {
                                ex.log("in CodeCompletionWindow.ShowCompletionWindow ");
                            }
                            busy = false;
                        });

                    return codeCompletionWindow;
                }
                catch// (Exception ex)
                {
                    busy = false;
                    return null;
                }
        }
Esempio n. 42
0
 private CodeCompletionWindow(ICompletionDataProvider completionDataProvider, Form parentForm, TextEditorControl control, string fileName) : base(parentForm, control, fileName)
 {
     this.workingScreen = Screen.GetWorkingArea(base.Location);
     this.startOffset   = control.ActiveTextAreaControl.Caret.Offset + 1;
     this.endOffset     = this.startOffset;
     if (completionDataProvider.PreSelection != null)
     {
         this.startOffset -= completionDataProvider.PreSelection.Length + 1;
         this.endOffset--;
     }
     this.codeCompletionListView                      = new CodeCompletionListView(CodeCompletionWindow.completionData);
     this.codeCompletionListView.ImageList            = completionDataProvider.ImageList;
     this.codeCompletionListView.Dock                 = DockStyle.Fill;
     this.codeCompletionListView.SelectedItemChanged += new EventHandler(this.CodeCompletionListViewSelectedItemChanged);
     this.codeCompletionListView.DoubleClick         += new EventHandler(this.CodeCompletionListViewDoubleClick);
     this.codeCompletionListView.Click               += new EventHandler(this.CodeCompletionListViewClick);
     base.Controls.Add(this.codeCompletionListView);
     if (CodeCompletionWindow.completionData.Length > 10)
     {
         this.vScrollBar.Dock        = DockStyle.Right;
         this.vScrollBar.Minimum     = 0;
         this.vScrollBar.Maximum     = CodeCompletionWindow.completionData.Length - 8;
         this.vScrollBar.SmallChange = 1;
         this.vScrollBar.LargeChange = 3;
         this.codeCompletionListView.FirstItemChanged += new EventHandler(this.CodeCompletionListViewFirstItemChanged);
         base.Controls.Add(this.vScrollBar);
     }
     this.drawingSize = new Size(this.codeCompletionListView.ItemHeight * 10, this.codeCompletionListView.ItemHeight * Math.Min(10, CodeCompletionWindow.completionData.Length));
     this.SetLocation();
     this.declarationViewWindow = new DeclarationViewWindow(parentForm);
     this.SetDeclarationViewLocation();
     this.declarationViewWindow.ShowDeclarationViewWindow();
     control.Focus();
     this.CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);
     if (completionDataProvider.PreSelection != null)
     {
         this.CaretOffsetChanged(this, EventArgs.Empty);
     }
     this.vScrollBar.Scroll += new ScrollEventHandler(this.DoScroll);
 }
Esempio n. 43
0
 public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char key)
 {
     try
     {
         FCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(
             FParentForm,                        // The parent window for the completion window
             this,                               // The text editor to show the window for
             TextDocument.LocalPath,             // Filename - will be passed back to the provider
             completionDataProvider,             // Provider to get the list of possible completions
             key                                 // Key pressed - will be passed to the provider
             );
         if (FCompletionWindow != null)
         {
             // ShowCompletionWindow can return null when the provider returns an empty list
             FCompletionWindow.Closed += CloseCodeCompletionWindow;
         }
     }
     catch (Exception e)
     {
         Logger.Log(e);
     }
 }
        private void ShowCodeCompleteWindow(char key)
        {
            try
            {
                _completionDataProvider = this;

                _codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(
                    _editor.ParentForm,
                    _editor,
                    "file.sql",
                    _completionDataProvider,
                    key
                    );

                if (_codeCompletionWindow != null)
                {
                    _codeCompletionWindow.Closed += CloseCodeCompletionWindow;
                }
            }
            catch (Exception)
            {
            }
        }
        /// <summary>
        /// Shows the completion window.
        /// </summary>
        /// <param name="completionDataProvider">The completion data provider.</param>
        /// <param name="ch">The character that was typed - or <c>'\0'</c> if no character was typed.</param>
        /// <param name="closeAutomatically"><see langword="true"/> to close the completion wnidow automatically.</param>
        public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char ch, bool closeAutomatically)
        {
            completionDataProvider.PreSelection = String.Empty;

            // Make default pre-selection
            string previousWord = TextHelper.GetWordBeforeCaret(ActiveTextAreaControl.TextArea);

            if (!String.IsNullOrEmpty(previousWord))
            {
                char lastChar = previousWord[previousWord.Length - 1];
                if (TextHelper.IsLetterDigitOrUnderscore(lastChar))
                {
                    completionDataProvider.PreSelection = previousWord;
                }
            }

            completionWindow = CompletionWindow.ShowCompletionWindow(ParentForm, this, "", completionDataProvider, ch, true, false, closeAutomatically);

            if (completionWindow != null)
            {
                completionWindow.Closed += OnCompletionWindowClosed;
            }
        }
 // IdeBridge
 public virtual void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char ch)
 {
     codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(WorkbenchSingleton.MainForm, this, this.FileName, completionDataProvider, ch);
     if (codeCompletionWindow != null) {
         codeCompletionWindow.Closed += new EventHandler(CloseCodeCompletionWindow);
     }
 }
 public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar)
 {
     return(CodeCompletionWindow.ShowCompletionWindow(parent, control, fileName, completionDataProvider, firstChar, true, true));
 }
		bool ShowListWindow (char firstChar, ICompletionDataProvider provider, ICompletionWidget completionWidget, ICodeCompletionContext completionContext, CompletionDelegate closedDelegate)
		{
			if (mutableProvider != null) {
				mutableProvider.CompletionDataChanging -= OnCompletionDataChanging;
				mutableProvider.CompletionDataChanged -= OnCompletionDataChanged;
			}
			
			this.provider = provider;
			this.completionContext = completionContext;
			this.closedDelegate = closedDelegate;
			mutableProvider = provider as IMutableCompletionDataProvider;
			
			if (mutableProvider != null) {
				mutableProvider.CompletionDataChanging += OnCompletionDataChanging;
				mutableProvider.CompletionDataChanged += OnCompletionDataChanged;
			
				if (mutableProvider.IsChanging)
					OnCompletionDataChanging (null, null);
			}
			
			this.completionWidget = completionWidget;
			this.firstChar = firstChar;

			return FillList ();
		}
        public static void ShowWindow(char firstChar, ICompletionDataProvider provider, ICompletionWidget completionWidget)
        {
            try {
                if (!wnd.ShowListWindow (firstChar, provider,  completionWidget))
                    return;

                // makes control-space in midle of words to work
                string text = wnd.completionWidget.CompletionText;
                if (text.Length == 0)
                    return;

                wnd.PartialWord = text;
                //if there is only one matching result we take it by default
                if (wnd.IsUniqueMatch)
                {
                    wnd.Hide ();
                }

                wnd.UpdateWord ();

                wnd.PartialWord = wnd.CompleteWord;
            } catch (Exception ex) {
                Console.WriteLine (ex);
            }
        }
        public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char ch)
        {
            
            if (InsightWindowVisible)
            {
                CloseInsightWindow(null, null);
            }
            ICompletionData[] completionData = completionDataProvider.GenerateCompletionData(this.FileName, this, ch);
            if (completionData == null || completionData.Length == 0) {
                this.AutoListVisible = false;
				return ;
			}
      //      this.Caret.CurrentRow.AddToParseQueue();
            
            Word curWord = this.Caret.CurrentWord;
            TextPoint tp = null;
            if (ch == '\0')
            {

                if (curWord != null)
                {
                    // control space with some word already typed
                    tp = this.Caret.Position;
                    startOffset = new TextPoint(curWord.Column, tp.Y);
                }
                else
                {
                    tp = new TextPoint(this.Caret.Position.X + 1, this.Caret.Position.Y);
                    startOffset = new TextPoint(this.Caret.Position.X + 1, this.Caret.Position.Y);
                }
            }
            else
            {
                tp = new TextPoint(this.Caret.Position.X + 1, this.Caret.Position.Y);
                startOffset = new TextPoint(this.Caret.Position.X + 1, this.Caret.Position.Y);
            }
            this._AutoListStartPos = tp;
            
            // Set Caret correct Position before TryAutoCompletion;
            if (ch == '\0')
                if(TryAutoCompletion(completionData))
                    return ;

            this._AutoList.BeginLoad();
            this._AutoList.Clear();
            foreach (ICompletionData data in completionData)
            {
                this._AutoList.Add(data, data.ImageIndex);
            }
           
            this._AutoList.EndLoad();
            this.AutoListVisible = true;
            if (completionDataProvider != null && completionDataProvider.DefaultIndex >= 0)
            {
                this._AutoList.SelectItemByIndex(completionDataProvider.DefaultIndex);
            }
            else
            {
                this._AutoList.SelectItemByIndex(0);
            }
        }
Esempio n. 51
0
 public static AutoCompleteWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, int IOffset, int FOffset, bool QualifierBehind)
 {
     AutoCompleteWindow aux = ShowCompletionWindow(parent, control, fileName, completionDataProvider, firstChar, true);
     if (aux == null)
         return null;
     aux.startOffset = IOffset;
     aux.endOffset = FOffset;
     aux.qualifierBehind = QualifierBehind;
     return aux;
 }
Esempio n. 52
0
 public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar)
 {
     return ShowCompletionWindow(parent, control, fileName, completionDataProvider, firstChar, true, true);
 }
			internal ContextCompletionDataProvider(ICompletionDataProvider baseProvider) : base(baseProvider)
			{
			}
        /// <summary>
        /// Shows the completion window.
        /// </summary>
        /// <param name="completionDataProvider">The completion data provider.</param>
        /// <param name="ch">The character that was typed - or <c>'\0'</c> if no character was typed.</param>
        /// <param name="closeAutomatically"><c>true</c> to close the completion wnidow automatically.</param>
        public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char ch, bool closeAutomatically)
        {
            completionDataProvider.PreSelection = String.Empty;

              // Make default pre-selection
              string previousWord = TextHelper.GetWordBeforeCaret(ActiveTextAreaControl.TextArea);
              if (!String.IsNullOrEmpty(previousWord))
              {
            char lastChar = previousWord[previousWord.Length - 1];
            if (TextHelper.IsLetterDigitOrUnderscore(lastChar))
              completionDataProvider.PreSelection = previousWord;
              }

              completionWindow = CompletionWindow.ShowCompletionWindow(ParentForm, this, "", completionDataProvider, ch, true, false, closeAutomatically);

              if (completionWindow != null)
            completionWindow.Closed += OnCompletionWindowClosed;
        }
    /// <summary>
    /// Initializes a new instance of the <see cref="CompletionWindow"/> class.
    /// </summary>
    /// <param name="completionDataProvider">The completion data provider.</param>
    /// <param name="completionData">The completion data.</param>
    /// <param name="parentForm">The parent form.</param>
    /// <param name="control">The text editor control.</param>
    /// <param name="showDeclarationWindow"><see langword="true"/> to show declaration window; otherwise <see langword="false"/>.</param>
    /// <param name="fixedListViewWidth"><see langword="true"/> to use a fixed width in the list view.</param>
    /// <param name="closeAutomatically"><see langword="true"/> to close the completion window automatically.</param>
    CompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth, bool closeAutomatically)
      : base(parentForm, control)
    {
      _dataProvider = completionDataProvider;
      _completionData = completionData;
      _document = control.Document;
      _showDeclarationWindow = showDeclarationWindow;
      _fixedListViewWidth = fixedListViewWidth;
      _closeAutomatically = closeAutomatically;

      int caretOffset = control.ActiveTextAreaControl.Caret.Offset;
      _startOffset = caretOffset;
      _endOffset = caretOffset;

      // Move start offset if something is pre-selected.
      if (!String.IsNullOrEmpty(completionDataProvider.PreSelection))
        _startOffset -= completionDataProvider.PreSelection.Length;

      _completionListView = new CompletionListView(completionData);
      _completionListView.Dock = DockStyle.Fill;
      _completionListView.FilterList = true;
      _completionListView.ImageList = completionDataProvider.ImageList;
      _completionListView.Click += CompletionListViewClick;
      _completionListView.DoubleClick += CompletionListViewDoubleClick;
      _completionListView.FirstItemChanged += CompletionListViewFirstItemChanged;
      _completionListView.ItemCountChanged += CompletionListViewItemCountChanged;
      _completionListView.SelectedItemChanged += CompletionListViewSelectedItemChanged;
      Controls.Add(_completionListView);

      _vScrollBar = new VScrollBar();
      _vScrollBar.SmallChange = 1;
      _vScrollBar.LargeChange = _maxListLength;
      _vScrollBar.Dock = DockStyle.Right;
      Controls.Add(_vScrollBar);
      UpdateScrollBar();

      _workingScreen = Screen.GetWorkingArea(Location);
      DrawingSize = GetListViewSize();
      _textLocation = TextEditorControl.ActiveTextAreaControl.TextArea.Caret.Position;
      SetLocation(_textLocation);

      if (_declarationViewWindow == null)
        _declarationViewWindow = new DeclarationViewWindow(parentForm);

      SetDeclarationViewLocation();
      _declarationViewWindow.Show();
      _declarationViewWindow.MouseMove += ControlMouseMove;
      control.Focus();
      CompletionListViewSelectedItemChanged(this, EventArgs.Empty);

      if (!String.IsNullOrEmpty(completionDataProvider.PreSelection))
      {
        // Select item based on pre-selection.
        CaretOffsetChanged(this, EventArgs.Empty);
      }
      else if (completionDataProvider.DefaultIndex >= 0)
      {
        // Select default item
        _completionListView.SelectItem(completionDataProvider.DefaultIndex);
      }

      _vScrollBar.ValueChanged += VScrollBarValueChanged;
      _document.DocumentAboutToBeChanged += DocumentAboutToBeChanged;
    }
Esempio n. 56
0
 public static AutoCompleteWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow)
 {
     completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar);
     if (completionData == null || completionData.Length == 0)
     {
         return null;
     }
     AutoCompleteWindow codeCompletionWindow = new AutoCompleteWindow(completionDataProvider, parent, control, fileName, showDeclarationWindow);
     codeCompletionWindow.ShowCompletionWindow();
     return codeCompletionWindow;
 }
		PABCNETCodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control,bool visibleKeyPressed, bool is_by_dot) : base(parentForm, control)
		{
			this.dataProvider = completionDataProvider;
			this.completionData = completionData;
			this.document = control.Document;
			workingScreen = Screen.GetWorkingArea(Location);
            lastCursorScreenPosition = control.ActiveTextAreaControl.Caret.ScreenPosition;
            startOffset = control.ActiveTextAreaControl.Caret.Offset + (visibleKeyPressed ? 1 : 0);
			endOffset   = startOffset;
			if (completionDataProvider.PreSelection != null) {
				
				startOffset -= completionDataProvider.PreSelection.Length; //+ 1;
				if (visibleKeyPressed) endOffset--;
				//endOffset--;
				(completionDataProvider as VisualPascalABC.CodeCompletionProvider).preSelection = null;
			}
			
			codeCompletionListView = new PABCNETCodeCompletionListView(completionData, is_by_dot);
			codeCompletionListView.ImageList = completionDataProvider.ImageList;
			codeCompletionListView.Dock = DockStyle.Fill;
			codeCompletionListView.SelectedItemChanged += new EventHandler(CodeCompletionListViewSelectedItemChanged);
			codeCompletionListView.DoubleClick += new EventHandler(CodeCompletionListViewDoubleClick);
			codeCompletionListView.Click  += new EventHandler(CodeCompletionListViewClick);
            codeCompletionListView.Font = new Font(VisualPascalABC.Constants.CompletionWindowCodeCompletionListViewFontName,codeCompletionListView.Font.Size);
			Controls.Add(codeCompletionListView);
			
			int MaxListLength = VisualPascalABC.Constants.CompletionWindowMaxListLength;
			if (completionData.Length > MaxListLength) {
				vScrollBar.Dock = DockStyle.Right;
				vScrollBar.Minimum = 0;
				vScrollBar.Maximum = completionData.Length - 1;
				vScrollBar.SmallChange = 1;
				vScrollBar.LargeChange = MaxListLength;
				codeCompletionListView.FirstItemChanged += new EventHandler(CodeCompletionListViewFirstItemChanged);
				Controls.Add(vScrollBar);
			}
            this.drawingSize = new Size(//codeCompletionListView.ItemHeight * 10,
                                        VisualPascalABC.Constants.CompletionWindowWidth,
                                        codeCompletionListView.ItemHeight * Math.Min(MaxListLength, completionData.Length) + 2);
			SetLocation();
			
			if (declarationViewWindow == null) {
				declarationViewWindow = new DeclarationWindow(parentForm);
				declarationViewWindow.in_completion_list = true;
                declarationViewWindow.Font = new Font(VisualPascalABC.Constants.CompletionWindowDeclarationViewWindowFontName, declarationViewWindow.Font.Size);
			}            
			SetDeclarationViewLocation();
            //DS закоментил, это желтый квадрат при старте
			//declarationViewWindow.ShowDeclarationViewWindow();
			declarationViewWindow.MouseMove += ControlMouseMove;
			control.Focus();
			CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);
			
			if ((completionDataProvider as VisualPascalABC.CodeCompletionProvider).DefaultCompletionElement != null) {
				if ((completionDataProvider as VisualPascalABC.CodeCompletionProvider).ByFirstChar)
				codeCompletionListView.FirstInsert = true;
				codeCompletionListView.SelectIndexByCompletionData((completionDataProvider as VisualPascalABC.CodeCompletionProvider).DefaultCompletionElement);
			}
			
			if (completionDataProvider.PreSelection != null) {
				CaretOffsetChanged(this, EventArgs.Empty);
			}
			
			vScrollBar.ValueChanged += VScrollBarValueChanged;
			document.DocumentAboutToBeChanged += DocumentAboutToBeChanged;
		}
		public CachedCompletionDataProvider(ICompletionDataProvider baseProvider)
		{
			this.baseProvider = baseProvider;
		}
Esempio n. 59
0
 /// <summary>
 /// Shows the code completion window.
 /// </summary>
 protected virtual void ShowCodeCompletionWindow(SharpDevelopTextAreaControl textAreaControl, ICompletionDataProvider completionDataProvider, char ch)
 {
     textAreaControl.ShowCompletionWindow(completionDataProvider, ch);
 }
		public new void Hide ()
		{
			base.Hide ();
			declarationviewwindow.HideAll ();
			if (provider != null) {
				provider.Dispose ();
				provider = null;
			}
			if (closedDelegate != null) {
				closedDelegate ();
				closedDelegate = null;
			}
		}