コード例 #1
0
        void BindEvents()
        {
            fsWatcher = CreateFileSystemWatcher(@"lua");

            editor.TextChanged += AnalyzeScriptLater;
            editor.Click       += (s, a) => history.Add(editor.CurrentLine);

            miEanbleCodeAnalyze.Click += (s, a) =>
            {
                var enable = !miEanbleCodeAnalyze.Checked;
                SetIsEnableCodeAnalyze(enable);
            };

            cboxVarList.DropDownClosed += (s, a) =>
                                          VgcApis.Misc.UI.Invoke(() =>
            {
                var kw = cboxVarList.Text;
                ScrollToVariable(kw);
                editor.Focus();
            });

            cboxVarList.DropDown += OnCboxVarListDropDownHandler;

            cboxFunctionList.DropDownClosed += (s, a) =>
                                               VgcApis.Misc.UI.Invoke(() =>
            {
                var kw = cboxFunctionList.Text;
                ScrollToFunction(kw);
                editor.Focus();
            });

            cboxFunctionList.DropDown += OnCboxFunctionListDropDownHandler;
        }
コード例 #2
0
        public void GoToPosition(int position)
        {
            int line = _editor.LineFromPosition(position);

            _editor.GotoPosition(position);
            int firstVisible = _editor.FirstVisibleLine;

            if (line > firstVisible)
            {
                int delta = firstVisible - line;
                _editor.LineScroll(-delta, 0);
            }
            _editor.Focus();
        }
コード例 #3
0
 private static void GenerateKeystrokes(Scintilla editor, string keys)
 {
     HotKeyManager.Enable = false;
     editor.Focus();
     SendKeys.Send(keys);
     HotKeyManager.Enable = true;
 }
コード例 #4
0
 private void GenerateKeystrokes(string keys, Scintilla textbox)
 {
     //HotKeyManager.Enable = false;
     textbox.Focus();
     SendKeys.Send(keys);
     //HotKeyManager.Enable = true;
 }
コード例 #5
0
 void GenerateKeystrokes(string keys)
 {
     HotKeyManager.Enable = false;
     TextArea.Focus();
     SendKeys.Send(keys);
     HotKeyManager.Enable = true;
 }
コード例 #6
0
ファイル: ErrorListForm.cs プロジェクト: watrt/EsPy_cn
        private void listView1_DoubleClick(object sender, EventArgs e)
        {
            if (this.listView1.SelectedItems.Count > 0)
            {
                ErrorItem ei = (this.listView1.SelectedItems[0].Tag as ErrorItem);

                IDocument doc = Globals.MainForm.FindDocument(ei.FileName);
                if (doc == null)
                {
                    doc = Globals.MainForm.OpenFromFile(ei.FileName, EditorForm.EditorFileFormats);
                }

                if (doc != null)
                {
                    if (doc is EditorForm)
                    {
                        //(doc as EditorForm).Show(Globals.MainForm.dockPanel1);

                        Scintilla s    = (doc as EditorForm).scintilla;
                        Line      line = s.Lines[ei.Line - 1];

                        s.GotoPosition(line.Position + ei.Column);
                        s.Focus();
                    }
                }
            }
        }
コード例 #7
0
ファイル: SuEditor.cs プロジェクト: d8vjork/Cocktail
 private void GenerateKeystrokes(string keys)
 {
     HotKeyManager.Enable = false;
     editor.Focus();
     SendKeys.Send(keys);
     HotKeyManager.Enable = true;
 }
コード例 #8
0
        public void ShowGoToDialog()
        {
            //GoToDialog gd = new GoToDialog();
            GoToDialog gd = _window;

            gd.CurrentLineNumber = _scintilla.CurrentLine;
            gd.MaximumLineNumber = _scintilla.Lines.Count;
            gd.Scintilla         = _scintilla;

            if (!_window.Visible)
            {
                _window.Show(_scintilla.FindForm());
            }

            //_window.ShowDialog(_scintilla.FindForm());
            //_window.Show(_scintilla.FindForm());

            //if (gd.ShowDialog() == DialogResult.OK)
            //Line(gd.GotoLineNumber);

            //gd.ShowDialog();
            //gd.Show();

            _scintilla.Focus();
        }
コード例 #9
0
 void GotoLine()
 {
     if (int.TryParse(tboxGoto.Text, out int lineNumber))
     {
         var line          = editor.Lines[lineNumber - 1];
         var linesOnScreen = editor.LinesOnScreen - 2; // Fudge factor
         var top           = line.Index - (linesOnScreen / 2);
         line.Goto();
         editor.FirstVisibleLine = Math.Max(0, top);
         editor.Focus();
     }
 }
コード例 #10
0
        public void GoToPosition(int pos, Scintilla editor, Scintilla resultsPanel)
        {
            var selectedLine = resultsPanel.LineFromPosition(pos);

            var charRange = this.Items[selectedLine];

            editor.GotoPosition(charRange.cpMax);
            editor.GotoPosition(charRange.cpMin);
            editor.SetSelection(charRange.cpMin, charRange.cpMax);
            editor.ScrollCaret();
            editor.Focus();
        }
コード例 #11
0
 private void SelectDifferentChar(Scintilla tbox, int index)
 {
     tbox.Focus();
     if (index < tbox.Text.Length)
     {
         tbox.SelectionStart = index;
         tbox.SelectionEnd   = index + 1;
     }
     else
     {
         tbox.SetEmptySelection(index);
     }
     ShowCharStatus(tbox.SelectedText);
 }
コード例 #12
0
        private void modeTabs_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (modeTabs.SelectedIndex)
            {
            case 0:
                UpdateDesigner();
                browserDesign.Focus();
                break;

            case 1:
                UpdateEditor();
                editor.Focus();
                break;
            }
        }
コード例 #13
0
        public void ShowGoToDialog()
        {
            GoToDialog gd = new GoToDialog();

            gd.CurrentLineNumber = Scintilla.Lines.Current.Number;
            gd.MaximumLineNumber = Scintilla.Lines.Count;
            gd.Scintilla         = Scintilla;

            if (gd.ShowDialog() == DialogResult.OK)
            {
                Line(gd.GotoLineNumber);
            }

            Scintilla.Focus();
        }
コード例 #14
0
        public void GoToPosition(int pos, Scintilla editor, Scintilla resultsPanel)
        {
            var selectedLine = resultsPanel.LineFromPosition(pos);
            var item         = this.Items[selectedLine];

            if (item.LineNumber > editor.Lines.Count)
            {
                return;
            }

            var targetLine = editor.Lines[item.LineNumber - 1];

            editor.SetSelection(targetLine.Position, targetLine.Position + targetLine.Length);
            editor.ScrollCaret();
            editor.Focus();
        }
コード例 #15
0
        internal void SetFocus()
        {
            switch (_CurrentTab)
            {
            case DesignTabs.Edit:
                scintilla1.Focus();
                break;

            case DesignTabs.Preview:
                rdlPreview.Focus();
                break;

            case DesignTabs.Design:
                dcDesign.SetFocus();
                break;
            }
        }
コード例 #16
0
        protected override void OnVisibleChanged(EventArgs e)
        {
            base.OnVisibleChanged(e);

            txtFind.Text      = string.Empty;
            txtFind.BackColor = SystemColors.Window;

            MoveFormAwayFromSelection();

            if (Visible)
            {
                txtFind.Focus();
            }
            else if (_scintilla != null)
            {
                _scintilla.Focus();
            }
        }
コード例 #17
0
        static void setRazorError(Scintilla textBox, Dictionary <int, string> compilationErrors, Line line, int column, string error)
        {
            line.Goto();
            textBox.CurrentPosition += column - 1;
            int end = textBox.CurrentPosition;

            while (++end < textBox.Text.Length)
            {
                if (" [](){}.,;\"\':-+*&".IndexOf(textBox.Text[end]) >= 0)
                {
                    break;
                }
            }
            textBox.SelectionStart = textBox.CurrentPosition;
            textBox.SelectionEnd   = textBox.CurrentPosition;
            textBox.Focus();

            textBox.IndicatorFillRange(textBox.CurrentPosition, end - textBox.CurrentPosition);
            for (int i = textBox.CurrentPosition; i < end; i++)
            {
                //Split error text if too long...
                var errText   = "";
                int lineCount = 0;
                for (int j = 0; j < error.Length; j++)
                {
                    lineCount++;
                    errText += error[j];
                    if (lineCount > 120 && error[j] == ' ')
                    {
                        lineCount = 0;
                        errText  += "\r\n";
                    }
                }

                if (!compilationErrors.ContainsKey(i))
                {
                    compilationErrors.Add(i, errText);
                }
            }
        }
コード例 #18
0
        private static int FindTheText(Scintilla textBox, string text, int start)
        {
            // Initialize the return value to false by default.
            int returnValue = -1;

            // Ensure that a search string has been specified and a valid start point.
            if (text.Length > 0 && start >= 0)
            {
                if (!textBox.Focused)
                {
                    textBox.Focus();
                }
                // Obtain the location of the search string in richTextBox1.
                textBox.TargetStart = start;
                textBox.TargetEnd   = textBox.TextLength;
                int indexToText = textBox.SearchInTarget(text);
                // Determine whether the text was found in richTextBox1.
                if (indexToText >= 0)
                {
                    returnValue = indexToText;
                    textBox.SetSel(textBox.TargetStart, textBox.TargetEnd);
                }
            }
            if (returnValue == -1)
            {
                if (start == 0)
                {
                    MessageBox.Show("Text \"" + text + "\" was not found.", "Find text", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (MessageBox.Show("No more occurence of \"" + text + "\" was found.\nSearch from the beginning?", "Find text", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
                {
                    FindTheText(textBox, text, 0);
                }
            }
            return(returnValue);
        }
コード例 #19
0
 public override void Focus()
 {
     _control.Focus();
 }
コード例 #20
0
        public void SearchScintilla(ref TextBox searchBox, SearchMode myMode, String replaceText, ref int laststart)
        {
            String regExString = searchBox.Text;

            if (searchBox.SelectedText != null && searchBox.SelectedText.Length != 0)
            {
                regExString = searchBox.SelectedText;
            }

            Regex Expressions = new Regex(regExString, SessionOptions);

            switch (myMode)
            {
            case SearchMode.IsaMatch:
                break;

            case SearchMode.Match:
            case SearchMode.Replace:
                rangeMatch = _textBox.FindReplace.Find(laststart, _textBox.Text.Length - 1, Expressions);
                //(Match)ExecuteRegEx(ref myBox, RegularExpressionMonster.SearchMode.Match, replaceText, laststart, 0);
                if (rangeMatch != null)
                {
                    rangeMatch.Select();
                    laststart = rangeMatch.End;
                    _textBox.Focus();
                }
                else
                {
                    MessageBox.Show("No Occurances Found");
                }
                break;

            case SearchMode.FindAll:
                List <Range> resultsOf = _textBox.FindReplace.FindAll(Expressions);
                if (resultsOf != null && resultsOf.Count > 0)
                {
                    foreach (Range hl in resultsOf)
                    {
                        hl.SetStyle(1);
                    }
                    _textBox.FindReplace.HighlightAll(resultsOf);
                }
                else
                {
                    MessageBox.Show("No results found.");
                }
                break;


            case SearchMode.Matches:
                break;

            case SearchMode.ReplaceAll:
                //String result = ExecuteRegEx(ref myBox, RegularExpressionMonster.SearchMode.ReplaceAll, replaceText, laststart, 0).ToString();
                _textBox.FindReplace.ReplaceAll(Expressions, replaceText);
                MessageBox.Show("All text matching regular expression have been replaced");
                //myBox.Text = result;

                break;
            }
        }
コード例 #21
0
 public void SetFocus()
 {
     _editor.Focus();
 }
コード例 #22
0
ファイル: FormHelper.cs プロジェクト: xbgRookie/Seal-Report
        public static void CheckRazorSyntax(Scintilla textBox, string header, object objectForCheckSyntax, Dictionary <int, string> compilationErrors)
        {
            string    error = "";
            const int NUM   = 18;

            // Remove all uses of our indicator
            textBox.IndicatorCurrent = NUM;
            textBox.IndicatorClearRange(0, textBox.TextLength);

            compilationErrors.Clear();
            try
            {
                string script       = textBox.Text;
                string scriptHeader = header;
                if (scriptHeader == null)
                {
                    scriptHeader = RazorHelper.GetScriptHeader(objectForCheckSyntax);
                }
                if (!string.IsNullOrEmpty(scriptHeader))
                {
                    script += "\r\n" + scriptHeader;
                }
                RazorHelper.Compile(script, objectForCheckSyntax.GetType(), Guid.NewGuid().ToString());
            }
            catch (TemplateCompilationException ex)
            {
                // Update indicator appearance
                textBox.Indicators[NUM].Style        = IndicatorStyle.StraightBox;
                textBox.Indicators[NUM].Under        = true;
                textBox.Indicators[NUM].ForeColor    = Color.Red;
                textBox.Indicators[NUM].OutlineAlpha = 120;
                textBox.Indicators[NUM].Alpha        = 120;

                foreach (var err in ex.CompilerErrors)
                {
                    var sourceLines = ex.CompilationData.SourceCode.Split('\n');
                    if (err.Line > 0 && err.Line < sourceLines.Length)
                    {
                        var pattern = sourceLines[err.Line - 1].Trim();
                        foreach (var line in textBox.Lines)
                        {
                            var line2 = line.Text.Trim();
                            if (line2 == pattern)
                            {
                                line.Goto();
                                textBox.CurrentPosition += err.Column - 1;
                                int end = textBox.CurrentPosition;
                                while (++end < textBox.Text.Length)
                                {
                                    if (" [](){}.,;\"\':-+*&".IndexOf(textBox.Text[end]) >= 0)
                                    {
                                        break;
                                    }
                                }
                                textBox.SelectionStart = textBox.CurrentPosition;
                                textBox.SelectionEnd   = textBox.CurrentPosition;
                                textBox.Focus();

                                textBox.IndicatorFillRange(textBox.CurrentPosition, end - textBox.CurrentPosition);
                                for (int i = textBox.CurrentPosition; i < end; i++)
                                {
                                    //Split error text if too long...
                                    var errText   = "";
                                    int lineCount = 0;
                                    for (int j = 0; j < err.ErrorText.Length; j++)
                                    {
                                        lineCount++;
                                        errText += err.ErrorText[j];
                                        if (lineCount > 120 && err.ErrorText[j] == ' ')
                                        {
                                            lineCount = 0;
                                            errText  += "\r\n";
                                        }
                                    }

                                    if (!compilationErrors.ContainsKey(i))
                                    {
                                        compilationErrors.Add(i, errText);
                                    }
                                }
                            }
                        }
                    }
                }

                error = string.Format("Compilation error:\r\n{0}", Helper.GetExceptionMessage(ex));
                if (ex.InnerException != null)
                {
                    error += "\r\n" + ex.InnerException.Message;
                }
                if (error.ToLower().Contains("are you missing an assembly reference"))
                {
                    error += string.Format("\r\nNote that you can add assemblies to load by copying your .dll files in the Assemblies Repository folder:'{0}'", Repository.Instance.AssembliesFolder);
                }
            }
            catch (Exception ex)
            {
                error = string.Format("Compilation error:\r\n{0}", ex.Message);
                if (ex.InnerException != null)
                {
                    error += "\r\n" + ex.InnerException.Message;
                }
            }

            if (!string.IsNullOrEmpty(error))
            {
                throw new Exception(error);
            }
        }
コード例 #23
0
ファイル: CodeForm.cs プロジェクト: hongfagj/Live-CSharp
 private void GenerateKeystrokes(string keys)
 {
     TextArea.Focus();
     SendKeys.Send(keys);
 }
コード例 #24
0
        public bool UpdateSuggestions(SuggestionList suggestions, Point p)
        {
            suggestionList = suggestions;
            theList.Sorted = false; //  !suggestionList.queryMode;

            Point pOrig = p;

            p = parent.PointToClient(p);

            leftWidth   = 0;
            rightWidth  = 0;
            middleWidth = 0;

            int lineHeight = theList.ItemHeight = FormsToolbox.GetTextHeight("0", this.Font) + 4;

            // suggestions.Clear();
            if (suggestions != null && suggestions.Count > 0)
            {
                int maxWidth = 0;
                theList.BeginUpdate();
                theList.Items.Clear();
                theList.SelectedIndex = -1;
                Suggestion selectedItem = null;
                string     match        = suggestions.textEntered.ToLower().Trim();
                foreach (Suggestion s in suggestions.GetSuggestions(!suggestionList.queryMode, match))
                {
                    if (s.expr.Trim().Length > 0)
                    {
                        if (s.expr.ToLower().Contains(match))
                        {
                            leftWidth = Math.Max(leftWidth, 20 + FormsToolbox.GetTextWidth(s.expr + "00", Font));
                            if (s.middleStuff != null)
                            {
                                middleWidth = Math.Max(middleWidth, FormsToolbox.GetTextWidth(s.middleStuff + "00", SystemFonts.MessageBoxFont));
                            }
                            if (s.rightStuff != null)
                            {
                                rightWidth = Math.Max(rightWidth, FormsToolbox.GetTextWidth(s.rightStuff + "00", SystemFonts.MessageBoxFont));
                            }
                            theList.Items.Add(s);
                            if (s.expr.ToLower().StartsWith(match) &&
                                (selectedItem == null || s.position < selectedItem.position))
                            {
                                selectedItem = s;
                            }
                        }
                    }
                }
                theList.EndUpdate();
                if (selectedItem != null)
                {
                    theList.SelectedItem = selectedItem;
                    int topItem = Math.Max(0, theList.SelectedIndex - (maxVisibleItems / 2));
                    theList.TopIndex = topItem;
                }

                maxWidth = leftWidth + middleWidth + rightWidth;

                if (theList.Items.Count > 0)
                {
                    if (!Visible)
                    {
                        Show();
                        BringToFront();
                    }
                    T.Debug(p.Y.ToString() + " " + pOrig.Y.ToString());
                    int maxHeight = maxVisibleItems * lineHeight;
                    theList.Size = new Size(T.MinMax(20, 600, maxWidth), T.MinMax(lineHeight, maxHeight, lineHeight * theList.Items.Count));
                    int y = p.Y;
                    if (!suggestionList.queryMode)
                    {
                        y += lineHeight;
                    }
                    Bounds = new Rectangle(p.X, y, theList.Width, theList.Height);
                    editor.Focus();
                    return(theList.Items.Count > 0);
                }
            }
            Hide();
            editor.Focus();
            return(false);
        }