Ejemplo n.º 1
0
 /// <summary>
 /// Loads the syntax and refreshes scintilla settings.
 /// </summary>
 public static void LoadConfiguration()
 {
     SciConfigUtil = new ConfigurationUtility(Assembly.GetExecutingAssembly());
     SciConfig = (Scintilla)SciConfigUtil.LoadConfiguration(typeof(Scintilla), FileNameHelper.Scintilla);
     ScintillaControl.Configuration = SciConfig;
     MainForm.Instance.ApplyAllSettings();
 }
Ejemplo n.º 2
0
 public SnippetLinkRange(int start, int end, Scintilla scintilla, string key)
 {
     Scintilla = scintilla;
     Start = start;
     End = end;
     this._key = key;
 }
Ejemplo n.º 3
0
 internal Folding(Scintilla scintilla)
     : base(scintilla)
 {
     this.IsEnabled = true;
     this.UseCompactFolding = false;
     this.MarkerScheme = FoldMarkerScheme.BoxPlusMinus;
 }
Ejemplo n.º 4
0
 internal DropMarker(int start, int end, int topOffset, Scintilla scintilla)
     : base(start, end, scintilla)
 {
     base.Start = start;
     base.End = end;
     this._topOffset = topOffset;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Loads the syntax and refreshes scintilla settings.
 /// </summary>
 public static void LoadConfiguration()
 {
     SciConfigUtil = new ConfigurationUtility(Assembly.GetExecutingAssembly());
     String[] configFiles = Directory.GetFiles(Path.Combine(PathHelper.SettingDir, "Languages"), "*.xml");
     SciConfig = (Scintilla)SciConfigUtil.LoadConfiguration(configFiles);
     ScintillaControl.Configuration = SciConfig;
     MainForm.Instance.ApplyAllSettings();
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Loads the syntax and refreshes scintilla settings.
 /// </summary>
 public static void LoadConfiguration()
 {
     sciConfigUtil = new ConfigurationUtility(Assembly.GetExecutingAssembly());
     String[] configFiles = Directory.GetFiles(Path.Combine(PathHelper.SettingDir, "Languages"), "*.xml");
     sciConfig = (Scintilla)sciConfigUtil.LoadConfiguration(configFiles);
     ScintillaControl.Configuration = sciConfig;
     if (ConfigurationLoaded != null) ConfigurationLoaded();
 }
Ejemplo n.º 7
0
        public StringAdapter(Scintilla scintilla, LineStorage lineStorage)
        {
            Debug.Assert(scintilla != null);
            Debug.Assert(lineStorage != null);

            _scintilla = scintilla;
            _scintilla.SCNotification += scintilla_SCNotification;

            _lineStorage = lineStorage;
        }
Ejemplo n.º 8
0
 internal DocumentNavigation(Scintilla scintilla)
     : base(scintilla)
 {
     this.t = new Timer
     {
         Interval = this._navigationPointTimeout
     };
     this.t.Tick += this.t_Tick;
     scintilla.SelectionChanged += this.scintilla_SelectionChanged;
 }
Ejemplo n.º 9
0
        public SnippetManager(Scintilla scintilla)
            : base(scintilla)
        {
            this._list = new SnippetList(this);

            this._snippetLinkTimer.Interval = 1;
            this._snippetLinkTimer.Tick += this.snippetLinkTimer_Tick;

            this.IsEnabled = this._isEnabled;
        }
Ejemplo n.º 10
0
        public LineStorage(Scintilla scintilla)
        {
            Debug.Assert(scintilla != null);

            _scintilla = scintilla;
            _scintilla.SCNotification += scintilla_SCNotification;

            // Every document has at least one line
            _lineData = new List<LineStorageData>();
            _lineData.Add(new LineStorageData());
        }
    public ScintillaWrapper(Scintilla trgt)
    {
        target = trgt;

        //Now add handler for the UpdateUI event.
        target.UpdateUI += (sender, args) =>
        {
            if (args?.Change == UpdateChange.HScroll || args?.Change == UpdateChange.VScroll)
            {
                Scroll?.Invoke(sender, new ScrollEventArgs(ScrollEventType.LargeIncrement, 0));
            }
        };
    }
Ejemplo n.º 12
0
 internal CallTip(Scintilla scintilla)
     : base(scintilla)
 {
     //	Go ahead and enable this. It's all pretty idiosyncratic IMO. For one
     //	thing you can't turn it off. We set the CallTip styles by default
     //	anyhow.
     NativeScintilla.CallTipUseStyle(10);
     Scintilla.BeginInvoke(new MethodInvoker(delegate
     {
         this.HighlightTextColor = this.HighlightTextColor;
         this.ForeColor = this.ForeColor;
         this.BackColor = this.BackColor;
     }));
 }
Ejemplo n.º 13
0
 public Range(int start, int end, Scintilla scintilla)
     : base(scintilla)
 {
     if (start < end)
     {
         this._start = start;
         this._end = end;
     }
     else
     {
         this._start = end;
         this._end = start;
     }
 }
Ejemplo n.º 14
0
        public Find(Scintilla.ScintillaControl control)
        {
            InitializeComponent();

              _scintilla = control;

              if (_scintilla.SelTextSize > 0)
              {
            textBoxFind.Text = _scintilla.SelText;
              }

              // reset
              _scintilla.GotoPos(0);
              _scintilla.SearchAnchor();
        }
Ejemplo n.º 15
0
        internal Lexing(Scintilla scintilla)
            : base(scintilla)
        {
            this.WhitespaceChars = DEFAULT_WHITECHARS;
            this.WordChars = DEFAULT_WORDCHARS;
            this._keywords = new KeywordCollection(scintilla);

            // Language names are a superset lexer names. For instance the chr and cs (chr#)
            // langauges both use the cpp lexer (by default). Languages are kind of a
            // SCite concept, while Scintilla only cares about Lexers. However we don't
            // need to explicetly map a language to a lexer if they are the same name
            // like cpp.
            this._lexerLanguageMap.Add("cs", "cpp");
            this._lexerLanguageMap.Add("html", "hypertext");
            this._lexerLanguageMap.Add("xml", "hypertext");
        }
Ejemplo n.º 16
0
        internal FindReplace(Scintilla scintilla)
            : base(scintilla)
        {
            _marker = scintilla.Markers[10];
            _marker.SetSymbolInternal(MarkerSymbol.Arrows);
            _indicator = scintilla.Indicators[16];
            _indicator.Color = Color.Purple;
            _indicator.Style = IndicatorStyle.RoundBox;

            _window = Windows.ScintillaFindReplace;
            _window.Scintilla = scintilla;

            _incrementalSearcher = new IncrementalSearcher();
            _incrementalSearcher.Scintilla = scintilla;
            _incrementalSearcher.Visible = false;
            scintilla.Controls.Add(_incrementalSearcher);
        }
Ejemplo n.º 17
0
        internal FindReplace(Scintilla scintilla)
            : base(scintilla)
        {
            this._marker = scintilla.Markers[10];
            this._marker.SetSymbolInternal(MarkerSymbol.Arrows);
            this._indicator = scintilla.Indicators[16];
            this._indicator.Color = Color.Purple;
            this._indicator.Style = IndicatorStyle.RoundBox;

            this._window = new FindReplaceDialog
            {
                Scintilla = scintilla
            };

            this._incrementalSearcher = new IncrementalSearcher
            {
                Scintilla = scintilla,
                Visible = false
            };
            scintilla.Controls.Add(this._incrementalSearcher);
        }
Ejemplo n.º 18
0
        internal KeywordCollection(Scintilla scintilla)
            : base(scintilla)
        {
            // Auugh, this plagued me for a while. Each of the lexers cna define their own "Name"
            // and also asign themsleves to a Scintilla Lexer Constant. Most of the time these
            // match the defined constant, but sometimes they don't. We'll always use the constant
            // name since it's easier to use, consistent and will always have valid characters.
            // However its still valid to access the lexers by this name (as SetLexerLanguage
            // uses this value) so we'll create a lookup.
            this._lexerAliasMap = new Dictionary<string, Lexer>(StringComparer.OrdinalIgnoreCase)
            {
                {
                    "PL/M", Lexer.Plm
                    },
                {
                    "props", Lexer.Properties
                    },
                {
                    "inno", Lexer.InnoSetup
                    },
                {
                    "clarion", Lexer.Clw
                    },
                {
                    "clarionnocase", Lexer.ClwNoCase
                    }
            };

            // I have no idea how Progress fits into this. It's defined with the PS lexer const
            // and a name of "progress"

            //_lexerKeywordListMap = new Dictionary<string,string[]>(StringComparer.OrdinalIgnoreCase);

            //_lexerKeywordListMap.Add("xml", new string[] { "HTML elements and attributes", "JavaScript keywords", "VBScript keywords", "Python keywords", "PHP keywords", "SGML and DTD keywords" });
            //_lexerKeywordListMap.Add("yaml", new string[] { "Keywords" });
            // baan, kix, ave, scriptol, diff, props, makefile, errorlist, latex, null, lot, haskell
            // lexers don't have keyword list names
        }
Ejemplo n.º 19
0
 internal HotspotStyle(Scintilla scintilla) : base(scintilla)
 {
     ActiveForeColor = SystemColors.HotTrack;
     ActiveBackColor = SystemColors.Window;
 }
Ejemplo n.º 20
0
        public static Scintilla CreateScintilla(Panel container, bool readOnlyMode = false)
        {
            var scintilla = new Scintilla();

            container.Controls.Add(scintilla);

            // scintilla.Dock = DockStyle.Fill;
            scintilla.Dock              = DockStyle.Fill;
            scintilla.WrapMode          = WrapMode.None;
            scintilla.IndentationGuides = IndentView.LookBoth;

            // Configure the JSON lexer styles
            scintilla.Styles[Style.Default].Font = "Consolas";
            scintilla.Styles[Style.Default].Size = 11;
            if (readOnlyMode)
            {
                var bgColor = Color.FromArgb(240, 240, 240);
                scintilla.Styles[Style.Default].BackColor             = bgColor;
                scintilla.Styles[Style.Json.BlockComment].BackColor   = bgColor;
                scintilla.Styles[Style.Json.Default].BackColor        = bgColor;
                scintilla.Styles[Style.Json.Error].BackColor          = bgColor;
                scintilla.Styles[Style.Json.EscapeSequence].BackColor = bgColor;
                scintilla.Styles[Style.Json.Keyword].BackColor        = bgColor;
                scintilla.Styles[Style.Json.LineComment].BackColor    = bgColor;
                scintilla.Styles[Style.Json.Number].BackColor         = bgColor;
                scintilla.Styles[Style.Json.Operator].BackColor       = bgColor;
                scintilla.Styles[Style.Json.PropertyName].BackColor   = bgColor;
                scintilla.Styles[Style.Json.String].BackColor         = bgColor;
                scintilla.Styles[Style.Json.CompactIRI].BackColor     = bgColor;
                scintilla.ReadOnly = true;
            }

            scintilla.Styles[Style.Json.Default].ForeColor      = Color.Silver;
            scintilla.Styles[Style.Json.BlockComment].ForeColor = Color.FromArgb(0, 128, 0); // Green
            scintilla.Styles[Style.Json.LineComment].ForeColor  = Color.FromArgb(0, 128, 0); // Green
            scintilla.Styles[Style.Json.Number].ForeColor       = Color.Olive;
            scintilla.Styles[Style.Json.PropertyName].ForeColor = Color.Blue;
            scintilla.Styles[Style.Json.String].ForeColor       = Color.FromArgb(163, 21, 21); // Red
            scintilla.Styles[Style.Json.StringEol].BackColor    = Color.Pink;
            scintilla.Styles[Style.Json.Operator].ForeColor     = Color.Purple;
            scintilla.Lexer = Lexer.Json;

            // folding
            // Instruct the lexer to calculate folding
            scintilla.SetProperty("fold", "1");
            scintilla.SetProperty("fold.compact", "1");

            // Configure a margin to display folding symbols
            scintilla.Margins[2].Type      = MarginType.Symbol;
            scintilla.Margins[2].Mask      = Marker.MaskFolders;
            scintilla.Margins[2].Sensitive = true;
            scintilla.Margins[2].Width     = 20;

            // Set colors for all folding markers
            for (int i = 25; i <= 31; i++)
            {
                scintilla.Markers[i].SetForeColor(SystemColors.ControlLightLight);
                scintilla.Markers[i].SetBackColor(SystemColors.ControlDark);
            }

            // Configure folding markers with respective symbols
            scintilla.Markers[Marker.Folder].Symbol        = MarkerSymbol.BoxPlus;
            scintilla.Markers[Marker.FolderOpen].Symbol    = MarkerSymbol.BoxMinus;
            scintilla.Markers[Marker.FolderEnd].Symbol     = MarkerSymbol.BoxPlusConnected;
            scintilla.Markers[Marker.FolderMidTail].Symbol = MarkerSymbol.TCorner;
            scintilla.Markers[Marker.FolderOpenMid].Symbol = MarkerSymbol.BoxMinusConnected;
            scintilla.Markers[Marker.FolderSub].Symbol     = MarkerSymbol.VLine;
            scintilla.Markers[Marker.FolderTail].Symbol    = MarkerSymbol.LCorner;

            // Enable automatic folding
            scintilla.AutomaticFold = (AutomaticFold.Show | AutomaticFold.Click | AutomaticFold.Change);

            // key binding

            // clear default keyboard shortcut
            scintilla.ClearCmdKey(Keys.Control | Keys.P);
            scintilla.ClearCmdKey(Keys.Control | Keys.S);
            scintilla.ClearCmdKey(Keys.Control | Keys.F);

            return(scintilla);
        }
Ejemplo n.º 21
0
        private void Search()
        {
            string searchString = txtSearch.Text;

            if (string.IsNullOrEmpty(searchString))
            {
                return;
            }

            bool matchCase = chkMatchCase.Checked;
            bool wholeWord = chkWholeWord.Checked;
            bool wordStart = chkWordStart.Checked;
            bool escape    = chkEscape.Checked;

            SearchFlags flags = SearchFlags.Empty;

            if (matchCase)
            {
                flags |= SearchFlags.MatchCase;
            }

            if (wholeWord)
            {
                flags |= SearchFlags.WholeWord;
            }

            if (wordStart)
            {
                flags |= SearchFlags.WordStart;
            }

            if (escape)
            {
                searchString = searchString.Replace("\\\\", "\\");
                searchString = searchString.Replace("\\t", "\t");
                searchString = searchString.Replace("\\r", "\r");
                searchString = searchString.Replace("\\n", "\n");
            }

            listSearchResults.Items.Clear();

            foreach (KeyValuePair <string, EditorPanel> i in editorList)
            {
                EditorPanel editor = i.Value;

                string fileName = editor.FileName;

                Scintilla scint = editor.Scint;

                List <Range> results = editor.FindAll(searchString, flags);

                foreach (Range r in results)
                {
                    int    lineNum = scint.Lines.FromPosition(r.Start).Number;
                    string resLine = scint.Lines[lineNum].Text.TrimEnd();

                    string hoverTxt = "";
                    if (lineNum >= 2)
                    {
                        hoverTxt += scint.Lines[lineNum - 2].Text.TrimEnd() + Environment.NewLine;
                    }
                    if (lineNum >= 1)
                    {
                        hoverTxt += scint.Lines[lineNum - 1].Text.TrimEnd() + Environment.NewLine;
                    }

                    hoverTxt += scint.Lines[lineNum].Text.TrimEnd() + Environment.NewLine;

                    if (lineNum < scint.Lines.Count - 1)
                    {
                        hoverTxt += scint.Lines[lineNum + 1].Text.TrimEnd() + Environment.NewLine;
                    }
                    if (lineNum < scint.Lines.Count - 2)
                    {
                        hoverTxt += scint.Lines[lineNum + 2].Text.TrimEnd() + Environment.NewLine;
                    }

                    hoverTxt = hoverTxt.TrimEnd();

                    ListViewItem lvi = new ListViewItem(new string[] { resLine, fileName, (lineNum + 1).ToString(), r.Start.ToString(), r.End.ToString(), });
                    lvi.ToolTipText = hoverTxt;

                    listSearchResults.Items.Add(lvi);
                }
            }

            ShowResults();
        }
Ejemplo n.º 22
0
        public static void Init(Scintilla scintilla, Lexer lex, bool showLineNumber = true)
        {
            scintilla.Lexer = lex;
            // we have common to every lexer style saves time.
            scintilla.StyleResetDefault();
            scintilla.Styles[Style.Default].Font = "Consolas";
            scintilla.Styles[Style.Default].Size = 10;
            scintilla.StyleClearAll();

            if (showLineNumber)
            {
                // Show line numbers
                scintilla.Margins[0].Width = 25;
                scintilla.Styles[Style.LineNumber].ForeColor = Color.FromArgb(255, 128, 128, 128);  //Dark Gray
                scintilla.Styles[Style.LineNumber].BackColor = Color.FromArgb(255, 228, 228, 228);  //Light Gray
            }

            if (lex == Lexer.Cpp)
            {
                // Configure the CPP (C#) lexer styles
                scintilla.Styles[Style.Cpp.Default].ForeColor        = Color.Silver;
                scintilla.Styles[Style.Cpp.Comment].ForeColor        = Color.FromArgb(0, 128, 0);     // Green
                scintilla.Styles[Style.Cpp.CommentLine].ForeColor    = Color.FromArgb(0, 128, 0);     // Green
                scintilla.Styles[Style.Cpp.CommentLineDoc].ForeColor = Color.FromArgb(128, 128, 128); // Gray
                scintilla.Styles[Style.Cpp.Number].ForeColor         = Color.Olive;
                scintilla.Styles[Style.Cpp.Word].ForeColor           = Color.Blue;
                scintilla.Styles[Style.Cpp.Word2].ForeColor          = Color.Blue;
                scintilla.Styles[Style.Cpp.String].ForeColor         = Color.FromArgb(163, 21, 21); // Red
                scintilla.Styles[Style.Cpp.Character].ForeColor      = Color.FromArgb(163, 21, 21); // Red
                scintilla.Styles[Style.Cpp.Verbatim].ForeColor       = Color.FromArgb(163, 21, 21); // Red
                scintilla.Styles[Style.Cpp.StringEol].BackColor      = Color.Pink;
                scintilla.Styles[Style.Cpp.Operator].ForeColor       = Color.Purple;
                scintilla.Styles[Style.Cpp.Preprocessor].ForeColor   = Color.Maroon;

                scintilla.Lexer = Lexer.Cpp;

                // Set the keywords
                scintilla.SetKeywords(0, "abstract as base break case catch checked continue default delegate do else event explicit extern false finally fixed for foreach goto if implicit in interface internal is lock namespace new null object operator out override params private protected public readonly ref return sealed sizeof stackalloc switch this throw true try typeof unchecked unsafe using virtual while equals join select on from where orderby descending var");
                scintilla.SetKeywords(1, "bool byte char class const decimal double enum float int long sbyte short static string struct uint ulong ushort void");

                //Folding
                // Instruct the lexer to calculate folding
                scintilla.SetProperty("fold", "1");
                scintilla.SetProperty("fold.compact", "1");

                // Configure a margin to display folding symbols
                scintilla.Margins[2].Type      = MarginType.Symbol;
                scintilla.Margins[2].Mask      = Marker.MaskFolders;
                scintilla.Margins[2].Sensitive = true;
                scintilla.Margins[2].Width     = 20;

                // Set colors for all folding markers
                for (int i = 25; i <= 31; i++)
                {
                    scintilla.Markers[i].SetForeColor(SystemColors.ControlLightLight);
                    scintilla.Markers[i].SetBackColor(SystemColors.ControlDark);
                }

                // Configure folding markers with respective symbols
                scintilla.Markers[Marker.Folder].Symbol        = MarkerSymbol.BoxPlus;
                scintilla.Markers[Marker.FolderOpen].Symbol    = MarkerSymbol.BoxMinus;
                scintilla.Markers[Marker.FolderEnd].Symbol     = MarkerSymbol.BoxPlusConnected;
                scintilla.Markers[Marker.FolderMidTail].Symbol = MarkerSymbol.TCorner;
                scintilla.Markers[Marker.FolderOpenMid].Symbol = MarkerSymbol.BoxMinusConnected;
                scintilla.Markers[Marker.FolderSub].Symbol     = MarkerSymbol.VLine;
                scintilla.Markers[Marker.FolderTail].Symbol    = MarkerSymbol.LCorner;

                // Enable automatic folding
                scintilla.AutomaticFold = (AutomaticFold.Show | AutomaticFold.Click | AutomaticFold.Change);
            }
            else if (lex == Lexer.Sql)
            {
                // Reset the styles
                scintilla.StyleResetDefault();
                scintilla.Styles[Style.Default].Font = "Courier New";
                scintilla.Styles[Style.Default].Size = 10;
                scintilla.StyleClearAll();

                // Set the SQL Lexer
                scintilla.Lexer = Lexer.Sql;

                // Set the Styles
                scintilla.Styles[Style.Sql.Comment].ForeColor        = Color.Green;
                scintilla.Styles[Style.Sql.CommentLine].ForeColor    = Color.Green;
                scintilla.Styles[Style.Sql.CommentLineDoc].ForeColor = Color.Green;
                scintilla.Styles[Style.Sql.Number].ForeColor         = Color.Maroon;
                scintilla.Styles[Style.Sql.Word].ForeColor           = Color.Blue;
                scintilla.Styles[Style.Sql.Word2].ForeColor          = Color.Fuchsia;
                scintilla.Styles[Style.Sql.User1].ForeColor          = Color.Gray;
                scintilla.Styles[Style.Sql.User2].ForeColor          = Color.FromArgb(255, 00, 128, 192); //Medium Blue-Green
                scintilla.Styles[Style.Sql.String].ForeColor         = Color.Red;
                scintilla.Styles[Style.Sql.Character].ForeColor      = Color.Red;
                scintilla.Styles[Style.Sql.Operator].ForeColor       = Color.Black;

                // Set keyword lists
                // Word = 0
                scintilla.SetKeywords(0, @"add alter as authorization backup begin bigint binary bit break browse bulk by cascade case catch check checkpoint close clustered column commit compute constraint containstable continue create current cursor cursor database date datetime datetime2 datetimeoffset dbcc deallocate decimal declare default delete deny desc disk distinct distributed double drop dump else end errlvl escape except exec execute exit external fetch file fillfactor float for foreign freetext freetexttable from full function goto grant group having hierarchyid holdlock identity identity_insert identitycol if image index insert int intersect into key kill lineno load merge money national nchar nocheck nocount nolock nonclustered ntext numeric nvarchar of off offsets on open opendatasource openquery openrowset openxml option order over percent plan precision primary print proc procedure public raiserror read readtext real reconfigure references replication restore restrict return revert revoke rollback rowcount rowguidcol rule save schema securityaudit select set setuser shutdown smalldatetime smallint smallmoney sql_variant statistics table table tablesample text textsize then time timestamp tinyint to top tran transaction trigger truncate try union unique uniqueidentifier update updatetext use user values varbinary varchar varying view waitfor when where while with writetext xml go ");
                // Word2 = 1
                scintilla.SetKeywords(1, @"ascii cast char charindex ceiling coalesce collate contains convert current_date current_time current_timestamp current_user floor isnull max min nullif object_id session_user substring system_user tsequal ");
                // User1 = 4
                scintilla.SetKeywords(4, @"all and any between cross exists in inner is join left like not null or outer pivot right some unpivot ( ) * ");
                // User2 = 5
                scintilla.SetKeywords(5, @"sys objects sysobjects ");
            }
            else if (lex == Lexer.Container)
            {
                // Reset the styles
                scintilla.StyleResetDefault();
                scintilla.Styles[Style.Default].Font = "Courier New";
                scintilla.Styles[Style.Default].Size = 10;
                scintilla.StyleClearAll();

                // Set the SQL Lexer
                scintilla.Styles[ScintillaRestrictionLexer.StyleDefault].ForeColor     = Color.Black;
                scintilla.Styles[ScintillaRestrictionLexer.StyleKeyword].ForeColor     = Color.Olive;
                scintilla.Styles[ScintillaRestrictionLexer.StyleIdentifier].ForeColor  = Color.Black;
                scintilla.Styles[ScintillaRestrictionLexer.StyleNumber].ForeColor      = Color.Maroon;
                scintilla.Styles[ScintillaRestrictionLexer.StyleString].ForeColor      = Color.Red;
                scintilla.Styles[ScintillaRestrictionLexer.StyleRestriction].ForeColor = Color.Teal;

                if (scintilla.Tag == null)
                {
                    ScintillaRestrictionLexer sealLexer = new ScintillaRestrictionLexer(@"all and any between cross exists in inner is join left like not null or outer pivot right some unpivot add alter as authorization backup begin bigint binary bit break browse bulk by cascade case catch check checkpoint close clustered column commit compute constraint containstable continue create current cursor cursor database date datetime datetime2 datetimeoffset dbcc deallocate decimal declare default delete deny desc disk distinct distributed double drop dump else end errlvl escape except exec execute exit external fetch file fillfactor float for foreign freetext freetexttable from full function goto grant group having hierarchyid holdlock identity identity_insert identitycol if image index insert int intersect into key kill lineno load merge money national nchar nocheck nocount nolock nonclustered ntext numeric nvarchar of off offsets on open opendatasource openquery openrowset openxml option order over percent plan precision primary print proc procedure public raiserror read readtext real reconfigure references replication restore restrict return revert revoke rollback rowcount rowguidcol rule save schema securityaudit select set setuser shutdown smalldatetime smallint smallmoney sql_variant statistics table table tablesample text textsize then time timestamp tinyint to top tran transaction trigger truncate try union unique uniqueidentifier update updatetext use user values varbinary varchar varying view waitfor when where while with writetext xml go");
                    scintilla.StyleNeeded += new EventHandler <StyleNeededEventArgs>(delegate(object sender, StyleNeededEventArgs e)
                    {
                        var startPos = scintilla.GetEndStyled();
                        var endPos   = e.Position;

                        sealLexer.Style(scintilla, startPos, endPos);
                    });
                }
            }

            //First initialization
            if (scintilla.Tag == null)
            {
                //Find replace dialog
                FindReplace replaceDlg = new FindReplace();
                replaceDlg.Scintilla = scintilla;
                scintilla.Tag        = replaceDlg;

                scintilla.KeyDown += Scintilla_KeyDown;
                if (showLineNumber)
                {
                    scintilla.TextChanged += Scintilla_TextChanged;
                }
                scintilla.CharAdded += Scintilla_CharAdded;
            }
        }
Ejemplo n.º 23
0
 public void SetStyles(Scintilla editor)
 {
     LoadStyle(editor);
 }
Ejemplo n.º 24
0
 private void scintillaControl1_DwellStart(object sender, Scintilla.DwellStartEventArgs e)
 {
     if ((_callTipsEnabled) && (e.Position > 0) &&
         (!scintillaControl1.IsCallTipActive) &&
         (!scintillaControl1.IsAutoCActive) &&
         (!InsideStringOrComment(false, e.Position)) &&
         _activated && !TabbedDocumentManager.HoveringTabs
         && !ScriptEditor.HoveringCombo)
     {
         ShowCalltip(FindEndOfCurrentWord(e.Position), -1, false);
         _dwellCalltipVisible = true;
     }
 }
Ejemplo n.º 25
0
 private void scintillaControl1_TextModified(object sender, Scintilla.TextModifiedEventArgs e)
 {
     if (TextModified != null)
     {
         TextModified(e.Position, e.Length, (e.ModificationType & 1) != 0);
     }
 }
Ejemplo n.º 26
0
        private void LoadStyle(Scintilla control)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(Properties.Settings.Default.StyleConfig);
            XmlNodeList nodeList = xmlDoc.SelectNodes("Styles/Style");
            foreach (XmlElement styleNode in nodeList)
            {
                Style thisStyle;
                int styleIndex;

                string index = styleNode.GetAttribute("index");
                string fontName = styleNode.GetAttribute("fontName");
                string fontSize = styleNode.GetAttribute("fontSize");
                string foreColor = styleNode.GetAttribute("foreColor");
                string backColor = styleNode.GetAttribute("backColor");
                string bold = styleNode.GetAttribute("bold");
                string italic = styleNode.GetAttribute("italic");
                string underline = styleNode.GetAttribute("underline");

                if (index == "") continue;
                else
                {
                    if (int.TryParse(index, out styleIndex) == false) continue;
                    thisStyle = control.Styles[styleIndex];
                }

                if (fontName != "") thisStyle.FontName = fontName;
                if (parseFloat(fontSize) > float.MinValue) thisStyle.Size = float.Parse(fontSize);
                if (parseHex(foreColor) > int.MinValue) thisStyle.ForeColor = Color.FromArgb(int.Parse(foreColor, System.Globalization.NumberStyles.HexNumber));
                if (parseHex(backColor) > int.MinValue) thisStyle.BackColor = Color.FromArgb(int.Parse(backColor, System.Globalization.NumberStyles.HexNumber));
                if (isBool(bold)) thisStyle.Bold = bool.Parse(bold);
                if (isBool(italic)) thisStyle.Italic = bool.Parse(italic);
                if (isBool(underline)) thisStyle.Underline = bool.Parse(underline);
            }
        }
Ejemplo n.º 27
0
    public void Style(Scintilla scintilla, int startPos, int endPos)
    {
        // Back up to the line start
        var line = scintilla.LineFromPosition(startPos);

        startPos = scintilla.Lines[line].Position;

        var length = 0;
        var state  = STATE_UNKNOWN;

        // Start styling
        scintilla.StartStyling(startPos);

        while (startPos < endPos)
        {
            var c = (char)scintilla.GetCharAt(startPos);


REPROCESS:
            switch (state)
            {
            case STATE_UNKNOWN:
                if (c == '/')
                {
                    scintilla.SetStyling(1, StyleDefault);
                    state = STATE_COMMENT;
                    // goto REPROCESS;
                }
                else if (Char.IsDigit(c))
                {
                    state = STATE_NUMBER;
                    //goto REPROCESS;
                }
                else if (Char.IsLetter(c))
                {
                    state = STATE_IDENTIFIER;
                    //goto REPROCESS;
                }
                else
                {
                    // Everything else
                    scintilla.SetStyling(1, StyleDefault);
                }
                break;

            case STATE_COMMENT:    //-----------------------------------------------------Estado comentarios--------------------------------
                if (c == '/')
                {
                    scintilla.SetStyling(1, StyleString);
                    state = STATE_COMMENT2;
                    // goto REPROCESS;
                }
                else if (c == '*')
                {
                    scintilla.SetStyling(1, StyleString);
                    state = STATE_COMMENT3;
                    goto REPROCESS;
                }
                else
                {
                    //division
                    state = STATE_UNKNOWN;
                    // goto REPROCESS;
                    startPos--;
                }

                break;

            case STATE_COMMENT2:
                if (c == '\n')
                {
                    state = STATE_UNKNOWN;
                    //goto REPROCESS;
                }
                else
                {
                    scintilla.SetStyling(1, StyleString);
                    state = STATE_COMMENT2;
                    //goto REPROCESS;
                }
                break;

            case STATE_COMMENT3:
                if (c == '*')
                {
                    scintilla.SetStyling(1, StyleString);
                    state = STATE_COMMENT4;
                    //goto REPROCESS;
                }
                else
                {
                    scintilla.SetStyling(1, StyleString);
                    state = STATE_COMMENT3;
                    // goto REPROCESS;
                }
                break;

            case STATE_COMMENT4:
                if (c == '/')
                {
                    scintilla.SetStyling(1, StyleString);
                    state = STATE_UNKNOWN;
                    goto REPROCESS;
                }
                else
                {
                    scintilla.SetStyling(1, StyleString);
                    state = STATE_COMMENT3;
                    //goto REPROCESS;
                }
                break;

            case STATE_NUMBER:
                if (Char.IsDigit(c))
                {
                    length++;
                }
                else if (c == '.')
                {
                    length++;
                    state = STATE_FLOAT;
                }
                else
                {
                    scintilla.SetStyling(length, StyleNumber);
                    length = 0;
                    state  = STATE_UNKNOWN;
                    startPos--;
                    //goto REPROCESS;
                }
                break;

            case STATE_FLOAT:
                if (char.IsDigit(c))
                {
                    length++;
                }
                else
                {
                    scintilla.SetStyling(length, StyleNumber);
                    length = 0;
                    state  = STATE_UNKNOWN;
                    startPos--;
                    //goto REPROCESS;
                }
                break;

            case STATE_IDENTIFIER:
                if (Char.IsLetterOrDigit(c))
                {
                    length++;
                }
                else
                {
                    var style      = StyleIdentifier;
                    var identifier = scintilla.GetTextRange(startPos - length, length);
                    if (keywords.Contains(identifier))
                    {
                        style = StyleKeyword;
                    }

                    scintilla.SetStyling(length, style);
                    length = 0;
                    state  = STATE_UNKNOWN;
                    startPos--;
                    //goto REPROCESS;
                }
                break;
            }

            startPos++;
        }
    }
Ejemplo n.º 28
0
 public void ClearAll(Scintilla editor)
 {
     editor.MarkerDeleteAll(-1);
 }
Ejemplo n.º 29
0
 private void scintillaControlInput_SavePointReached(Scintilla.ScintillaControl pSender)
 {
     buttonSave.Enabled = saveCurrentFileToolStripMenuItem.Enabled = false;
       _curTab.wasSaved = true;
       if (tabControlEditor.SelectedTab != null && _curTab != null && _curTab.doc != null)
       {
     tabControlEditor.SelectedTab.Text = _curTab.doc.File.Name;
       }
 }
Ejemplo n.º 30
0
        private void InitializeComponent()
        {
            var splitter = new SplitContainer();

            splitter.Dock   = DockStyle.Fill;
            splitter.Parent = this;

            var fontFamily = "Consolas";
            var fontSize   = 14;

#if !(LINUX)
            var scintilla = new Scintilla();
            scintilla.Margins[0].Width = 0;

            scintilla.Lexer = Lexer.Cpp;
            scintilla.StyleResetDefault();
            scintilla.Styles[Style.Default].Font = fontFamily;
            scintilla.Styles[Style.Default].Size = fontSize;
            scintilla.StyleClearAll();

            scintilla.SetKeywords(0, "abstract as base break case catch checked continue default delegate do else event explicit extern false finally fixed for foreach goto if implicit in interface internal is lock namespace new null object operator out override params private protected public readonly ref return sealed sizeof stackalloc switch this throw true try typeof unchecked unsafe using var virtual while");
            scintilla.SetKeywords(1, "bool byte char class const decimal double enum float int long sbyte short static string struct uint ulong ushort void");

            var Green = Color.FromArgb(0, 128, 0);
            var Gray  = Color.FromArgb(128, 128, 128);
            var Red   = Color.FromArgb(163, 21, 21);
            scintilla.Styles[Style.Cpp.Default].ForeColor        = Color.Silver;
            scintilla.Styles[Style.Cpp.Comment].ForeColor        = Green;
            scintilla.Styles[Style.Cpp.CommentLine].ForeColor    = Green;
            scintilla.Styles[Style.Cpp.CommentLineDoc].ForeColor = Gray;
            scintilla.Styles[Style.Cpp.Number].ForeColor         = Color.Olive;
            scintilla.Styles[Style.Cpp.Word].ForeColor           = Color.Blue;
            scintilla.Styles[Style.Cpp.Word2].ForeColor          = Color.Blue;
            scintilla.Styles[Style.Cpp.String].ForeColor         = Red;
            scintilla.Styles[Style.Cpp.Character].ForeColor      = Red;
            scintilla.Styles[Style.Cpp.Verbatim].ForeColor       = Red;
            scintilla.Styles[Style.Cpp.StringEol].BackColor      = Color.Pink;
            scintilla.Styles[Style.Cpp.Operator].ForeColor       = Color.Purple;
            scintilla.Styles[Style.Cpp.Preprocessor].ForeColor   = Color.Maroon;
#else
            var scintilla = new TextBox();
            scintilla.WordWrap   = true;
            scintilla.Multiline  = true;
            scintilla.ScrollBars = ScrollBars.Both;
            scintilla.Font       = new Font(fontFamily, fontSize, FontStyle.Regular);
#endif
            scintilla.Dock   = DockStyle.Fill;
            scintilla.Parent = splitter.Panel1;
            scintilla.Text   = "// Bienvenue dans l'éditeur C#\n\n" +
                               "var asteroids = (Asteroid[]) Radar();\n\n" +
                               "foreach (var asteroid in asteroids) {\n" +
                               "    var angle = Math.Atan(asteroid.Y / asteroid.X);\n" +
                               "    var deg = angle * 180 / 3.1415923;\n\n" +
                               "    if (asteroid.X < 0) {\n" +
                               "        deg += 180;\n" +
                               "    }\n\n" +
                               "    for (var tir = 0; tir < asteroid.Life; tir++) {\n" +
                               "        Tir(deg);\n" +
                               "    }\n" +
                               "}\n";

            fond.Dock   = DockStyle.Fill;
            fond.Parent = splitter.Panel2;

            canvas.Dock   = DockStyle.Fill;
            canvas.Parent = munition;

            munition.Dock   = DockStyle.Fill;
            munition.Parent = fond;

            devant.Dock   = DockStyle.Fill;
            devant.Parent = canvas;

            // lien.
            éditeur = scintilla;

            // Les poupées russes.
            canvas.Controls.Add(devant);
            munition.Controls.Add(canvas);
            fond.Controls.Add(munition);
            splitter.Panel1.Controls.Add(éditeur);
            splitter.Panel2.Controls.Add(fond);
            Controls.Add(splitter);
        }
Ejemplo n.º 31
0
        public static void Apply(Scintilla instance)
        {
            var events = (EventHandlerList)getEvents.GetValue(instance, null);

            events[key] = null;
        }
Ejemplo n.º 32
0
 internal Indicator(int number, Scintilla scintilla)
     : base(scintilla)
 {
     this._number = number;
 }
Ejemplo n.º 33
0
 public void SetStyles(Scintilla editor)
 {
     LoadStyle(editor);
 }
Ejemplo n.º 34
0
 public SearchManager(Scintilla editor)
 {
     _editor             = editor;
     _editor.TargetStart = 0;
     _indexLastestSearch = 0;
 }
Ejemplo n.º 35
0
		/// <summary>
		///     Initializes a new instance of the <see cref="AnnotationCollection" /> class.
		/// </summary>
		/// <param name="scintilla">The <see cref="Scintilla" /> control that created this object.</param>
		protected internal AnnotationCollection(Scintilla scintilla)
		{
			this._scintilla = scintilla;
		}
Ejemplo n.º 36
0
 public void StyleSetBack(Scintilla.Lexers.Cpp syntaxType, Color value)
 {
     this.SendMessageDirect(2052, (int)syntaxType, Utilities.ColorToRgb(value));
 }
Ejemplo n.º 37
0
        private void LoadControls(NWFContext nwfContext)
        {
            splitContainer             = new SplitContainer();
            splitContainer.Dock        = DockStyle.Fill;
            splitContainer.Orientation = Orientation.Horizontal;

            WebBrowser previewBrowser = new WebBrowser();

            previewBrowser.Dock = DockStyle.Fill;

            #region ExternalXml
            Scintilla exEditor = new Scintilla();

            exEditor.Dock = DockStyle.Fill;

            splitContainer.Panel1.Controls.Add(exEditor);

            exEditor.ConfigurationManager.Language = "xml";
            exEditor.Margins.Margin0.Width         = 10;
            exEditor.Margins.Margin2.Width         = 20;
            exEditor.Folding.UseCompactFolding     = true;
            exEditor.Lexing.Lexer      = Lexer.Xml;
            exEditor.Lexing.LexerName  = "xml";
            exEditor.Folding.IsEnabled = true;
            exEditor.Text = (nwfContext.NWFXmlDocument.InnerXml).Replace("><", ">" + Environment.NewLine + "<");
            #endregion

            #region InternalXml
            Scintilla inEditor = new Scintilla();

            inEditor.Dock = DockStyle.Fill;

            splitContainer.Panel1.Controls.Add(inEditor);
            inEditor.Visible = false;

            inEditor.ConfigurationManager.Language = "xml";
            inEditor.Margins.Margin0.Width         = 10;
            inEditor.Margins.Margin2.Width         = 20;
            inEditor.Folding.UseCompactFolding     = true;
            inEditor.Lexing.Lexer      = Lexer.Xml;
            inEditor.Lexing.LexerName  = "xml";
            inEditor.Folding.IsEnabled = true;
            var xmlNode = nwfContext.NWFXmlDocument.ChildNodes.Item(1);
            if (xmlNode != null)
            {
                inEditor.Text = (xmlNode.FirstChild.InnerText).Replace("><", ">" + Environment.NewLine + "<");
            }
            #endregion

            #region Toolbar
            ToolStrip strip = new ToolStrip();
            strip.Dock = DockStyle.Top;

            ToolStripButton savebutton = new ToolStripButton();
            savebutton.Text        = Resources.WfaMain_LoadXmlEditorWithContent_Save;
            savebutton.ToolTipText = Resources.WfaMain_LoadXmlEditorWithContent_Save_changes_to_new_NWF_file_;
            strip.Items.Add(savebutton);
            savebutton.Click += (delegate
            {
                nwfContext.SetStagedWorkflowConfiguration(exEditor.Text);
                nwfContext.SetStagedWorkflowConfiguration(inEditor.Text.Replace(Environment.NewLine, ""));
                //nwfContext.SaveStringToFile(nwfContext.NwfXmlModifiedByEditor.InnerXml, "nwf"); NEEDS TO BE REFACTORED
            });

            ToolStripButton resetbutton = new ToolStripButton();
            resetbutton.Text        = Resources.WfaMain_LoadXmlEditorWithContent_Reset;
            resetbutton.ToolTipText = Resources.WfaMain_LoadXmlEditorWithContent_Reset_XML_to_default;
            strip.Items.Add(resetbutton);
            resetbutton.Click += (delegate
            {
                //saveWorkflowPreviewToolStripMenuItem.Enabled = false; NEEDS TO BE REFACTORED
                nwfContext.NWFXmlModified = null;
                exEditor.Text = (nwfContext.NWFXmlDocument.InnerXml).Replace("><", ">" + Environment.NewLine + "<");
                var item = nwfContext.NWFXmlDocument.ChildNodes.Item(1);
                if (item != null)
                {
                    inEditor.Text = (item.FirstChild.InnerText).Replace("><", ">" + Environment.NewLine + "<");
                }
            });

            ToolStripButton previewbutton = new ToolStripButton();
            previewbutton.Text        = Resources.WfaMain_LoadXmlEditorWithContent_Preview_Changes;
            previewbutton.ToolTipText = Resources.WfaMain_LoadXmlEditorWithContent_Preview_Changes_made_to_XML;
            strip.Items.Add(previewbutton);
            previewbutton.Click += (delegate
            {
                try
                {
                    nwfContext.SetStagedWorkflowConfiguration(exEditor.Text);
                    nwfContext.SetStagedWorkflowConfiguration(inEditor.Text);

                    XmlDocument previewdoc = new XmlDocument();
                    var item = nwfContext.NWFXmlModified.ChildNodes.Item(1);
                    if (item != null)
                    {
                        previewdoc.LoadXml(item.FirstChild.InnerText);
                    }
                    var xmlNodeList = previewdoc.SelectNodes("//ExportedWorkflow");
                    if (xmlNodeList != null)
                    {
                        XmlNode wfGraphical = xmlNodeList[0];

                        //previewTab.Text = Resources.WfaMain_LoadXmlEditorWithContent_Preview;
                        previewBrowser.Dock = DockStyle.Fill;
                        //previewTab.Controls.Add(_previewBrowser);

                        String staging;
                        staging = Common.ConvertXmlToHtml(wfGraphical.OuterXml, "graphical.xsl");
                        staging = staging.Replace(@"wfimages/", (Application.StartupPath + "\\wfimages\\"));

                        #region Populate Browser
                        previewBrowser.DocumentText = staging;
                    }

                    #endregion

                    //saveWorkflowPreviewToolStripMenuItem.Enabled = true; NEEDS TO BE REFACTORED
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Resources.WfaMain_LoadXmlEditorWithContent_Failed_to_render_preview__ + ex);
                }
            });

            #endregion

            #region ToolbarV2

            Panel toolbarPanel = new Panel();

            toolbarPanel.Dock = DockStyle.Top;

            splitContainer.Panel1.Controls.Add(toolbarPanel);
            splitContainer.Panel2.Controls.Add(previewBrowser);

            #region Populate Preview Browser with Temp Text

            StringBuilder sb = new StringBuilder();

            sb.Append("<html>");
            sb.Append("<body>");
            sb.Append("<br>");
            sb.Append("<center><h2><font color=\"grey\" face=\"serif\">Click Preview to display a graphical view of the edited XML</font></h2></center>");
            sb.Append("</body>");
            sb.Append("</html>");

            previewBrowser.DocumentText = sb.ToString();

            #endregion

            Label editorDescriptionLabel = new Label();

            Button saveButton = new Button();

            #region SaveButton
            saveButton.Text     = Resources.WfaMain_LoadXmlEditorWithContent_Save;
            saveButton.AutoSize = true;
            saveButton.Click   += (delegate
            {
                nwfContext.SetStagedWorkflowConfiguration(exEditor.Text);
                nwfContext.SetStagedWorkflowConfiguration(inEditor.Text.Replace(Environment.NewLine, ""));
                //nwfContext.SaveStringToFile(nwfContext.NwfXmlModifiedByEditor.InnerXml, "nwf"); NEEDS TO BE REFACTORED
                nwfContext.SaveStringToFile(nwfContext.NWFXmlModified.InnerXml, "nwf");
            });
            #endregion

            Button resetButton = new Button();

            #region ResetButton
            resetButton.Text     = Resources.WfaMain_LoadXmlEditorWithContent_Reset;
            resetButton.AutoSize = true;
            resetButton.Click   += (delegate
            {
                //saveWorkflowPreviewToolStripMenuItem.Enabled = false; NEEDS TO BE REFACTORED
                nwfContext.NWFXmlModified = null;
                exEditor.Text = (nwfContext.NWFXmlDocument.InnerXml).Replace("><", ">" + Environment.NewLine + "<");
                var item = nwfContext.NWFXmlDocument.ChildNodes.Item(1);
                if (item != null)
                {
                    inEditor.Text = (item.FirstChild.InnerText).Replace("><", ">" + Environment.NewLine + "<");
                }
            });
            #endregion

            Button previewButton = new Button();

            #region PreviewButton

            previewButton.Text   = Resources.WfaMain_LoadXmlEditorWithContent_Preview_Changes;
            previewButton.Click += (delegate
            {
                try
                {
                    nwfContext.SetStagedWorkflowConfiguration(exEditor.Text);
                    nwfContext.SetStagedWorkflowConfiguration(inEditor.Text);

                    XmlDocument previewdoc = new XmlDocument();
                    var item = nwfContext.NWFXmlModified.ChildNodes.Item(1);
                    if (item != null)
                    {
                        previewdoc.LoadXml(item.FirstChild.InnerText);
                    }
                    var xmlNodeList = previewdoc.SelectNodes("//ExportedWorkflow");
                    if (xmlNodeList != null)
                    {
                        XmlNode wfGraphical = xmlNodeList[0];

                        String staging;
                        staging = Common.ConvertXmlToHtml(wfGraphical.OuterXml, "graphical.xsl");
                        staging = staging.Replace(@"wfimages/", (Application.StartupPath + "\\wfimages\\"));

                        #region Populate Browser
                        previewBrowser.DocumentText = staging;
                    }

                    #endregion

                    //saveWorkflowPreviewToolStripMenuItem.Enabled = true; NEEDS TO BE REFACTORED
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Resources.WfaMain_LoadXmlEditorWithContent_Failed_to_render_preview__ + ex);
                }
            });
            #endregion

            ComboBox editorComboBox = new ComboBox();

            #region EditorComboBox

            editorComboBox.Width = 150;

            editorComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            editorComboBox.Items.Add("View: External XML");
            editorComboBox.Items.Add("View: Internal XML");
            editorComboBox.SelectedIndex = 0;

            editorComboBox.SelectedIndexChanged += delegate
            {
                switch (editorComboBox.SelectedIndex)
                {
                case 0:
                    exEditor.Visible            = true;
                    inEditor.Visible            = false;
                    editorDescriptionLabel.Text =
                        "The external XML view highlights SharePoint context, including list references.";
                    break;

                case 1:
                    exEditor.Visible            = false;
                    inEditor.Visible            = true;
                    editorDescriptionLabel.Text =
                        "The internal XML view highlights workflow configuration, including actions.";
                    break;
                }
            };

            #endregion



            toolbarPanel.Controls.Add(editorComboBox);
            toolbarPanel.Controls.Add(previewButton);
            toolbarPanel.Controls.Add(saveButton);
            toolbarPanel.Controls.Add(resetButton);
            toolbarPanel.Controls.Add(editorDescriptionLabel);
            toolbarPanel.Height = previewButton.Height + editorDescriptionLabel.Height + 20;


            editorComboBox.Location = new Point(editorComboBox.Location.X + 10, editorComboBox.Location.Y + 10);
            previewButton.Location  = new Point(editorComboBox.Location.X + editorComboBox.Width + 10, editorComboBox.Location.Y);
            saveButton.Location     = new Point(previewButton.Location.X + previewButton.Width + 10, editorComboBox.Location.Y);
            resetButton.Location    = new Point(saveButton.Location.X + saveButton.Width + 10, editorComboBox.Location.Y);

            editorDescriptionLabel.Location = new Point(editorComboBox.Location.X, editorComboBox.Location.Y + editorComboBox.Height + 10);
            editorDescriptionLabel.AutoSize = true;

            editorDescriptionLabel.Text =
                "The external XML view highlights SharePoint context, including list references.";

            resetButton.Height   = saveButton.Height;
            previewButton.Height = resetButton.Height;

            #endregion
        }
Ejemplo n.º 38
0
        public void StyleSetBold(Scintilla.Lexers.Cpp syntaxType, bool bold)
        {

            this.SendMessageDirect(2053, (int)syntaxType, bold);
        }
Ejemplo n.º 39
0
 public ScintillaWrapper(Scintilla trgt)
 {
     target = trgt;
 }
Ejemplo n.º 40
0
 internal Indentation(Scintilla scintilla) : base(scintilla)
 {
 }
Ejemplo n.º 41
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 /// <param name="oScintillaControl">Scintilla control being printed</param>
 public PrintDocument(Scintilla oScintillaControl)
 {
     m_oScintillaControl = oScintillaControl;
     DefaultPageSettings = new PageSettings();
 }
Ejemplo n.º 42
0
        /// <summary>
        /// If Smart Indenting is enabled, this delegate will be added to the CharAdded multicast event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal void CheckSmartIndent(char ch)
        {
            char newline = (Scintilla.EndOfLine.Mode == EndOfLineMode.CR) ? '\r' : '\n';

            switch (SmartIndentType)
            {
            case SmartIndent.None:
                return;

            case SmartIndent.Simple:
                if (ch == newline)
                {
                    Line curLine = Scintilla.Lines.Current;
                    curLine.Indentation  = curLine.Previous.Indentation;
                    Scintilla.CurrentPos = curLine.IndentPosition;
                }
                break;

            case SmartIndent.CPP:
            case SmartIndent.CPP2:
                if (ch == newline)
                {
                    Line   curLine  = Scintilla.Lines.Current;
                    Line   tempLine = curLine;
                    int    previousIndent;
                    string tempText;

                    do
                    {
                        tempLine       = tempLine.Previous;
                        previousIndent = tempLine.Indentation;
                        tempText       = tempLine.Text.Trim();
                        if (tempText.Length == 0)
                        {
                            previousIndent = -1;
                        }
                    }while ((tempLine.Number > 1) && (previousIndent < 0));

                    if (tempText.EndsWith("{"))
                    {
                        int bracePos = Scintilla.CurrentPos - 1;
                        while (bracePos > 0 && Scintilla.CharAt(bracePos) != '{')
                        {
                            bracePos--;
                        }
                        if (bracePos > 0 && Scintilla.Styles.GetStyleAt(bracePos) == 10)
                        {
                            previousIndent += TabWidth;
                        }
                    }
                    curLine.Indentation  = previousIndent;
                    Scintilla.CurrentPos = curLine.IndentPosition;
                }
                else if (ch == '}')
                {
                    int  position       = Scintilla.CurrentPos;
                    Line curLine        = Scintilla.Lines.Current;
                    int  previousIndent = curLine.Previous.Indentation;
                    int  match          = Scintilla.SafeBraceMatch(position - 1);
                    if (match != -1)
                    {
                        previousIndent      = Scintilla.Lines.FromPosition(match).Indentation;
                        curLine.Indentation = previousIndent;
                    }
                }
                break;
            }
        }
Ejemplo n.º 43
0
 internal Scrolling(Scintilla scintilla) : base(scintilla)
 {
 }
Ejemplo n.º 44
0
        private CharacterRange ReplaceNext(bool searchUp)
        {
            Regex          rr       = null;
            CharacterRange selRange = new CharacterRange(_scintilla.Selections[0].Start, _scintilla.Selections[0].End);

            //	We only do the actual replacement if the current selection exactly
            //	matches the find.
            if (selRange.cpMax - selRange.cpMin > 0)
            {
                if (rdoRegexR.Checked)
                {
                    rr = new Regex(txtFindR.Text, GetRegexOptions());
                    string selRangeText = Scintilla.GetTextRange(selRange.cpMin, selRange.cpMax - selRange.cpMin);

                    if (selRange.Equals(FindReplace.Find(selRange, rr, false)))
                    {
                        //	If searching up we do the replacement using the range object.
                        //	Otherwise we use the selection object. The reason being if
                        //	we use the range the caret is positioned before the replaced
                        //	text. Conversely if we use the selection object the caret will
                        //	be positioned after the replaced text. This is very important
                        //	becuase we don't want the new text to be potentially matched
                        //	in the next search.
                        if (searchUp)
                        {
                            _scintilla.SelectionStart = selRange.cpMin;
                            _scintilla.SelectionEnd   = selRange.cpMax;
                            _scintilla.ReplaceSelection(rr.Replace(selRangeText, txtReplace.Text));
                            _scintilla.GotoPosition(selRange.cpMin);
                        }
                        else
                        {
                            Scintilla.ReplaceSelection(rr.Replace(selRangeText, txtReplace.Text));
                        }
                    }
                }
                else
                {
                    string textToFind = rdoExtendedR.Checked ? FindReplace.Transform(txtFindR.Text) : txtFindR.Text;
                    if (selRange.Equals(FindReplace.Find(selRange, textToFind, false)))
                    {
                        //	If searching up we do the replacement using the range object.
                        //	Otherwise we use the selection object. The reason being if
                        //	we use the range the caret is positioned before the replaced
                        //	text. Conversely if we use the selection object the caret will
                        //	be positioned after the replaced text. This is very important
                        //	becuase we don't want the new text to be potentially matched
                        //	in the next search.
                        if (searchUp)
                        {
                            string textToReplace = rdoExtendedR.Checked ? FindReplace.Transform(txtReplace.Text) : txtReplace.Text;
                            _scintilla.SelectionStart = selRange.cpMin;
                            _scintilla.SelectionEnd   = selRange.cpMax;
                            _scintilla.ReplaceSelection(textToReplace);

                            _scintilla.GotoPosition(selRange.cpMin);
                        }
                        else
                        {
                            string textToReplace = rdoExtendedR.Checked ? FindReplace.Transform(txtReplace.Text) : txtReplace.Text;
                            Scintilla.ReplaceSelection(textToReplace);
                        }
                    }
                }
            }
            return(FindNextR(searchUp, rr));
        }
Ejemplo n.º 45
0
 public void RegisterForEvents(Scintilla queryEditor)
 {
     _autocomplete.TargetControlWrapper = new ScintillaWrapper(queryEditor);
 }
Ejemplo n.º 46
0
 public static void zSetFont(this Scintilla scintilla, string font, int fontSize)
 {
     scintilla.Styles[Style.Default].Font = font;
     scintilla.Styles[Style.Default].Size = fontSize;
     scintilla.StyleClearAll();
 }
Ejemplo n.º 47
0
        private void OnCharAdded(object sender, Scintilla.CharAddedEventArgs e)
        {
            // Reset to normal fillups
            this.scintillaControl1.AutoCSetFillups(_fillupKeys);

            if (e.Ch == 10)
            {
                int lineNumber = scintillaControl1.LineFromPosition(scintillaControl1.CurrentPos);
                if (lineNumber > 0)
                {
                    int previousLineIndent = scintillaControl1.GetLineIndentation(lineNumber - 1);
                    string previousLine = scintillaControl1.GetLine(lineNumber - 1).Trim('\r', '\n', '\0');
                    if (previousLine.EndsWith("{"))
                    {
                        previousLineIndent += scintillaControl1.TabWidth;
                    }
                    /*else if (previousLine.EndsWith("}"))
                    {
                        previousLineIndent -= scintillaControl1.TabWidth;
                        if (previousLineIndent < 0) previousLineIndent = 0;
                        if (_autoDedentClosingBrace)
                        {
                            scintillaControl1.SetLineIndentation(lineNumber - 1, previousLineIndent);
                        }
                    }*/
                    scintillaControl1.SetLineIndentation(lineNumber, previousLineIndent);
                    scintillaControl1.GotoPos(scintillaControl1.GetLineIndentationPosition(lineNumber));
                }
            }
            // The following events must be piped to the UpdateUI event,
            // otherwise they don't work properly
            else if ((e.Ch == '}') || (e.Ch == ')'))
            {
                if (!InsideStringOrComment(true))
                {
                    _doBraceMatch = true;
                }

                if (scintillaControl1.IsCallTipActive)
                {
                    scintillaControl1.CallTipCancel();
                }
            }
            else if ((e.Ch == '(') || (e.Ch == ','))
            {
                if ((e.Ch == ',') && (!InsideStringOrComment(true)) &&
                    (_autoSpaceAfterComma))
                {
                    scintillaControl1.AddText(" ");
                }

                _doCalltip = true;
            }
            else if ((e.Ch == '.') && (!scintillaControl1.IsAutoCActive))
            {
                _doShowAutocomplete = true;
            }
            else if (((Char.IsLetterOrDigit(e.Ch)) || (e.Ch == '_') || (e.Ch == ' ')) && (!scintillaControl1.IsAutoCActive))
            {
                _doShowAutocomplete = true;
            }

            if (CharAdded != null)
            {
                CharAdded(e.Ch);
            }
        }
Ejemplo n.º 48
0
 public static int zGetCurrentLineNumber(this Scintilla scintilla)
 {
     return(scintilla.LineFromPosition(scintilla.CurrentPosition));
 }
Ejemplo n.º 49
0
        void scintillaControl1_MarginClick(object sender, Scintilla.MarginClickEventArgs e)
        {
            if (e.Margin == 1)
            {
                if (ToggleBreakpoint != null)
                    ToggleBreakpoint(this, e);
            }
            else if (e.Margin == 2)
            {
                this.scintillaControl1.ToggleFold(e.LineNumber);
            }

            this.scintillaControl1.Invalidate();
        }
Ejemplo n.º 50
0
 public static Line zGetCurrentLine(this Scintilla scintilla)
 {
     return(scintilla.Lines[scintilla.zGetCurrentLineNumber()]);
 }
Ejemplo n.º 51
0
        private void LoadStyle(Scintilla control)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(Properties.Settings.Default.StyleConfig);
            XmlNodeList nodeList = xmlDoc.SelectNodes("Styles/Style");

            foreach (XmlElement styleNode in nodeList)
            {
                Style thisStyle;
                int   styleIndex;

                string index     = styleNode.GetAttribute("index");
                string fontName  = styleNode.GetAttribute("fontName");
                string fontSize  = styleNode.GetAttribute("fontSize");
                string foreColor = styleNode.GetAttribute("foreColor");
                string backColor = styleNode.GetAttribute("backColor");
                string bold      = styleNode.GetAttribute("bold");
                string italic    = styleNode.GetAttribute("italic");
                string underline = styleNode.GetAttribute("underline");

                if (index == "")
                {
                    continue;
                }
                else
                {
                    if (int.TryParse(index, out styleIndex) == false)
                    {
                        continue;
                    }
                    thisStyle = control.Styles[styleIndex];
                }

                if (fontName != "")
                {
                    thisStyle.FontName = fontName;
                }
                if (parseFloat(fontSize) > float.MinValue)
                {
                    thisStyle.Size = float.Parse(fontSize);
                }
                if (parseHex(foreColor) > int.MinValue)
                {
                    thisStyle.ForeColor = Color.FromArgb(int.Parse(foreColor, System.Globalization.NumberStyles.HexNumber));
                }
                if (parseHex(backColor) > int.MinValue)
                {
                    thisStyle.BackColor = Color.FromArgb(int.Parse(backColor, System.Globalization.NumberStyles.HexNumber));
                }
                if (isBool(bold))
                {
                    thisStyle.Bold = bool.Parse(bold);
                }
                if (isBool(italic))
                {
                    thisStyle.Italic = bool.Parse(italic);
                }
                if (isBool(underline))
                {
                    thisStyle.Underline = bool.Parse(underline);
                }
            }
        }
Ejemplo n.º 52
0
 public static Line zGetLineFromPosition(this Scintilla scintilla, int position)
 {
     return(scintilla.Lines[scintilla.LineFromPosition(position)]);
 }
Ejemplo n.º 53
0
        private void ConfigureForPython(Scintilla scintilla)
        {
            // Reset the styles
            scintilla.StyleResetDefault();
            string EditorFont = ConfigurationManager.AppSettings["EditorFont"];

            if (!String.IsNullOrEmpty(EditorFont))
            {
                scintilla.Styles[Style.Default].Font = EditorFont;
            }
            else
            {
                scintilla.Styles[Style.Default].Font = "Consolas";
            }
            string EditorFontSize = ConfigurationManager.AppSettings["EditorFontSize"];

            if (!String.IsNullOrEmpty(EditorFontSize))
            {
                scintilla.Styles[Style.Default].Size = Convert.ToInt32(EditorFontSize);
            }
            else
            {
                scintilla.Styles[Style.Default].Size = 12;
            }
            scintilla.StyleClearAll(); // i.e. Apply to all

            // Set the lexer
            scintilla.Lexer = Lexer.Python;

            // Known lexer properties:
            // "tab.timmy.whinge.level",
            // "lexer.python.literals.binary",
            // "lexer.python.strings.u",
            // "lexer.python.strings.b",
            // "lexer.python.strings.over.newline",
            // "lexer.python.keywords2.no.sub.identifiers",
            // "fold.quotes.python",
            // "fold.compact",
            // "fold"

            // Some properties we like
            scintilla.SetProperty("tab.timmy.whinge.level", "1");
            scintilla.SetProperty("fold", "1");

            scintilla1.Margins[0].Width = 25;
            scintilla1.Margins[0].Type  = MarginType.Number;

            // Use margin 2 for fold markers
            scintilla.Margins[2].Type      = MarginType.Symbol;
            scintilla.Margins[2].Mask      = Marker.MaskFolders;
            scintilla.Margins[2].Sensitive = true;
            scintilla.Margins[2].Width     = 20;

            // Reset folder markers
            for (int i = Marker.FolderEnd; i <= Marker.FolderOpen; i++)
            {
                scintilla.Markers[i].SetForeColor(SystemColors.ControlLightLight);
                scintilla.Markers[i].SetBackColor(SystemColors.ControlDark);
            }

            // Style the folder markers
            scintilla.Markers[Marker.Folder].Symbol = MarkerSymbol.BoxPlus;
            scintilla.Markers[Marker.Folder].SetBackColor(SystemColors.ControlText);
            scintilla.Markers[Marker.FolderOpen].Symbol = MarkerSymbol.BoxMinus;
            scintilla.Markers[Marker.FolderEnd].Symbol  = MarkerSymbol.BoxPlusConnected;
            scintilla.Markers[Marker.FolderEnd].SetBackColor(SystemColors.ControlText);
            scintilla.Markers[Marker.FolderMidTail].Symbol = MarkerSymbol.TCorner;
            scintilla.Markers[Marker.FolderOpenMid].Symbol = MarkerSymbol.BoxMinusConnected;
            scintilla.Markers[Marker.FolderSub].Symbol     = MarkerSymbol.VLine;
            scintilla.Markers[Marker.FolderTail].Symbol    = MarkerSymbol.LCorner;

            // Enable automatic folding
            scintilla.AutomaticFold = (AutomaticFold.Show | AutomaticFold.Click | AutomaticFold.Change);

            // Set the styles
            scintilla.Styles[Style.Python.Default].ForeColor      = DecodeColor("Python.Default.ForeColor");
            scintilla.Styles[Style.Python.CommentLine].ForeColor  = DecodeColor("Python.CommentLine.ForeColor");
            scintilla.Styles[Style.Python.CommentLine].Italic     = DecodeBoolean("Python.CommentLine.Italic");
            scintilla.Styles[Style.Python.Number].ForeColor       = DecodeColor("Python.Number.ForeColor");
            scintilla.Styles[Style.Python.String].ForeColor       = DecodeColor("Python.String.ForeColor");
            scintilla.Styles[Style.Python.Character].ForeColor    = DecodeColor("Python.Character.ForeColor");
            scintilla.Styles[Style.Python.Word].ForeColor         = DecodeColor("Python.Word.ForeColor");
            scintilla.Styles[Style.Python.Word].Bold              = DecodeBoolean("Python.Word.Bold");
            scintilla.Styles[Style.Python.Triple].ForeColor       = DecodeColor("Python.Triple.ForeColor");
            scintilla.Styles[Style.Python.TripleDouble].ForeColor = DecodeColor("Python.TripleDouble.ForeColor");
            scintilla.Styles[Style.Python.ClassName].ForeColor    = DecodeColor("Python.ClassName.ForeColor");
            scintilla.Styles[Style.Python.ClassName].Bold         = DecodeBoolean("Python.ClassName.Bold");
            scintilla.Styles[Style.Python.DefName].ForeColor      = DecodeColor("Python.DefName.ForeColor");
            scintilla.Styles[Style.Python.DefName].Bold           = DecodeBoolean("Python.DefName.Bold");
            scintilla.Styles[Style.Python.Operator].Bold          = DecodeBoolean("Python.Operator.Bold");
            scintilla.Styles[Style.Python.Identifier].ForeColor   = DecodeColor("Python.Identifier.ForeColor");
            scintilla.Styles[Style.Python.CommentBlock].ForeColor = DecodeColor("Python.CommentBlock.ForeColor");
            scintilla.Styles[Style.Python.CommentBlock].Italic    = DecodeBoolean("Python.CommentBlock.Italic");
            scintilla.Styles[Style.Python.StringEol].ForeColor    = DecodeColor("Python.StringEol.ForeColor");
            scintilla.Styles[Style.Python.StringEol].BackColor    = DecodeColor("Python.StringEol.BackColor");
            scintilla.Styles[Style.Python.StringEol].Bold         = DecodeBoolean("Python.StringEol.Bold");
            scintilla.Styles[Style.Python.StringEol].FillLine     = DecodeBoolean("Python.StringEol.FillLine");
            scintilla.Styles[Style.Python.Word2].ForeColor        = DecodeColor("Python.Word2.ForeColor");
            scintilla.Styles[Style.Python.Decorator].ForeColor    = DecodeColor("Python.Decorator.ForeColor");

            // Important for Python
            scintilla.ViewWhitespace = WhitespaceMode.VisibleAlways;

            // Keyword lists:
            // 0 "Keywords",
            // 1 "Highlighted identifiers"

            //var python2 = "and as assert break class continue def del elif else except exec finally for from global if import in is lambda not or pass print raise return try while with yield";
            //var python3 = "False None True and as assert break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield";
            var micropython = ConfigurationManager.AppSettings["Python.Keywords"];

            scintilla.SetKeywords(0, micropython);
            // scintilla.SetKeywords(1, "add your own keywords here");
        }
Ejemplo n.º 54
0
 public static int zGetLineIndent(this Scintilla scintilla, int line)
 {
     return(scintilla.DirectMessage(SCI_GETLINEINDENTATION, new IntPtr(line), IntPtr.Zero).ToInt32());
 }
Ejemplo n.º 55
0
 protected internal Line(Scintilla scintilla, int number) : base(scintilla)
 {
     _number = number;
 }
Ejemplo n.º 56
0
 public static void zSetLineIndent(this Scintilla scintilla, int line, int indent)
 {
     scintilla.DirectMessage(SCI_SETLINEINDENTATION, new IntPtr(line), new IntPtr(indent));
 }
Ejemplo n.º 57
0
    public static void Style(Scintilla scintilla, int startPos, int endPos, bool fullDoc = false)
    {
        startPos = (fullDoc ? 0 : scintilla.Lines[scintilla.LineFromPosition(startPos)].Position);
        endPos   = (fullDoc ? (scintilla.Lines[scintilla.Lines.Count].EndPosition - 1) : endPos);

        int style, length = 0, state = STATE_UNKNOWN;

        bool SINGLE_LINE_COMMENT,
             MULTI_LINE_COMMENT,
             VERBATIM      = false,
             PARENTHESIS   = false,
             QUOTED_STRING = false,
             DBL_OPR;

        char c = '\0', d = '\0';

        void ClearState()
        {
            length = state = STATE_UNKNOWN;
        }

        void DefaultStyle() => scintilla.SetStyling(1, StyleDefault);

        int StyleUntilEndOfLine(int inPosition, int inStyle)
        {
            int len = (scintilla.Lines[scintilla.LineFromPosition(inPosition)].EndPosition - inPosition);

            scintilla.SetStyling(len, inStyle);

            return(--len); //We return the length, cause we'll have to adjust the startPos.
        }

        bool ContainsUsingStatement(int inPosition) => (scintilla.GetTextRange(scintilla.Lines[scintilla.LineFromPosition(inPosition)].Position, 5)).Contains("using");

        if (MULTI_KEYWORDS.Count > 0)
        {
            RegSearchForWordsIn(scintilla.GetTextRange(startPos, (endPos - startPos)), startPos);
        }

        scintilla.StartStyling(startPos);
        {
            for (; startPos < endPos; startPos++)
            {
                c = scintilla.Text[startPos];

                if ((state == STATE_UNKNOWN) && c == ' ')
                {
                    DefaultStyle(); continue;
                }                                                                                     //Better than allowing it to set all the booleans and trickle down the if/else-if structure?

                d = (((startPos + 1) < scintilla.Text.Length) ? scintilla.Text[startPos + 1] : '\0'); //d = (char)scintilla.GetCharAt(startPos + 1);

                if (state == STATE_UNKNOWN)
                {
                    bool bFormattedVerbatim = ((c == '$') && (d == '@')),
                         bFormatted         = ((c == '$') && ((d == '"'))),
                         bNegativeNum       = ((c == '-') && (char.IsDigit(d))),
                         bFraction          = ((c == '.') && (char.IsDigit(d))),
                         bString            = (c == '"'),
                         bQuotedString      = (c == '\'');

                    VERBATIM = ((c == '@') && (d == '"'));

                    SINGLE_LINE_COMMENT = ((c == '/') && (d == '/'));
                    MULTI_LINE_COMMENT  = ((c == '/') && (d == '*'));

                    //I always want braces to be highlighted
                    if ((c == '{') || (c == '}'))
                    {
                        scintilla.SetStyling(1, ((scintilla.BraceMatch(startPos) > -1) ? StyleBraces : StyleError));
                    }
                    else if (char.IsLetter(c)) //Indentifier - Keywords, procedures, etc ...
                    {
                        state = (((MULTI_KEYWORDS.Count > 0) && MULTI_DICT.ContainsKey(startPos)) ? STATE_MULTI_IDENTIFIER : STATE_IDENTIFIER);
                    }
                    else if (bString || VERBATIM || bFormatted || bFormattedVerbatim || bQuotedString) //String
                    {
                        int len = ((VERBATIM || bFormatted || bFormattedVerbatim) ? ((bFormattedVerbatim) ? 3 : 2) : 1);

                        QUOTED_STRING = bQuotedString;

                        scintilla.SetStyling(len, (!VERBATIM ? (QUOTED_STRING ? StyleQuotedString : StyleString) : StyleVerbatim));

                        startPos += (len - 1);

                        state = STATE_STRING;
                    }
                    else if (char.IsDigit(c) || bNegativeNum || bFraction) //Number
                    {
                        state = STATE_NUMBER;
                    }
                    else if (SINGLE_LINE_COMMENT || MULTI_LINE_COMMENT) //Comment
                    {
                        if (SINGLE_LINE_COMMENT)
                        {
                            startPos += StyleUntilEndOfLine(startPos, StyleComment);
                        }
                        else
                        {
                            scintilla.SetStyling(2, StyleComment);

                            startPos += 2;

                            state = STATE_MULTILINE_COMMENT;
                        }
                    }
                    else if (c == '#')                                                //Preprocessor
                    {
                        startPos += StyleUntilEndOfLine(startPos, StylePreprocessor); //continue;
                    }
                    else if (
                        (char.IsSymbol(c) || OperatorStragglers.Contains(c)) && (Operators.Contains($"{c}" +
                                                                                                    ((DBL_OPR = (char.IsSymbol(d) || OperatorStragglers.Contains(d))) ? $"{d}" : "")))
                        )     //Operators
                    {
                        scintilla.SetStyling((DBL_OPR ? 2 : 1), StyleOperator);

                        startPos += (DBL_OPR ? 1 : 0);
                    }
                    else
                    {
                        DefaultStyle();
                    }

                    continue;
                }

                length++;

                switch (state)
                {
                case STATE_IDENTIFIER:
                    string identifier = scintilla.GetWordFromPosition(startPos);

                    style = StyleIdentifier;

                    int s = startPos;

                    startPos += (identifier.Length - 2);

                    d = (((startPos + 1) < scintilla.Text.Length) ? scintilla.Text[startPos + 1] : '\0');     //d = (char)scintilla.GetCharAt(startPos + 1);

                    bool OPEN_PAREN = (d == '(');

                    if (!OPEN_PAREN && KEYWORDS.Contains(identifier))
                    {
                        style = StyleKeyword;
                    }                                                                               //Keywords
                    else if (!OPEN_PAREN && CONTEXTUAL_KEYWORDS.Contains(identifier))
                    {
                        style = StyleContextual;
                    }                                                                                                  //Contextual Keywords
                    else if (!OPEN_PAREN && USER_KEYWORDS.Contains(identifier))
                    {
                        style = StyleUser;
                    }                                                                                      //User Keywords
                    else if (OPEN_PAREN)
                    {
                        style = StyleProcedure;
                    }                                                    //Procedures
                    else if (IdentifierMarkers.Contains(d) && !ContainsUsingStatement(startPos))
                    {
                        style = StyleProcedureContainer;
                    }                                                                                                                     //Procedure Containers "classes?"
                    else if (((char)scintilla.GetCharAt(s - 2) == '.') && !ContainsUsingStatement(s))
                    {
                        style = StyleContainerProcedure;
                    }                                                                                                                          //Container "procedures"

                    ClearState();

                    scintilla.SetStyling(identifier.Length, style);

                    break;

                case STATE_MULTI_IDENTIFIER:
                    int value;

                    MULTI_DICT.TryGetValue((startPos - 1), out value);

                    startPos += (value - 2);

                    ClearState();

                    scintilla.SetStyling(value, StyleMultiIdentifier);

                    break;

                case STATE_NUMBER:
                    if (!NumberTypes.Contains(c))
                    {
                        scintilla.SetStyling(length, StyleNumber);

                        ClearState();

                        startPos--;
                    }

                    break;

                case STATE_STRING:
                    style = (VERBATIM ? StyleVerbatim : (QUOTED_STRING ? StyleQuotedString : StyleString));

                    if (QUOTED_STRING)
                    {
                        if (c == '\'')     //End of our Quoted string?
                        {
                            QUOTED_STRING = false;

                            scintilla.SetStyling(length, style);
                            ClearState();
                        }
                        else if (c == '\\')
                        {
                            length++; startPos++;
                        }
                    }
                    else if (PARENTHESIS || ((c == '{') || (d == '}')))     //Formatted strings that are using braces
                    {
                        if (c == '{')
                        {
                            PARENTHESIS = true;
                        }
                        if (c == '}')
                        {
                            PARENTHESIS = false;
                        }
                    }
                    else if (VERBATIM && ((c == '"') && (d == '"')))     //Skip over embedded quotation marks
                    {
                        length++; startPos++;
                    }
                    else if (c == '"')     //End of our string?
                    {
                        length = ((length < 1) ? 1 : length);

                        scintilla.SetStyling(length, style);

                        ClearState();
                    }
                    else
                    {
                        if (!QUOTED_STRING && (c == '\\') && EscapeSequences.Contains(d))     //Escape Sequences
                        {
                            length += ((d == '\\') ? 0 : -1);

                            scintilla.SetStyling(length, style);
                            {
                                startPos++; length = 0;
                            }
                            scintilla.SetStyling(2, StyleEscapeSequence);
                        }
                    }

                    break;

                case STATE_MULTILINE_COMMENT:
                    if ((c == '*') && (d == '/'))
                    {
                        length += 2;

                        scintilla.SetStyling(length, StyleComment);

                        ClearState();

                        startPos++;
                    }

                    break;
                }
            }
        }
    }
Ejemplo n.º 58
0
 public ScintillaForm(Scintilla scintillaControl)
 {
     _scintillaControl = scintillaControl;
     InitScintillaControl();
 }
Ejemplo n.º 59
0
 void scintilla_ToggleBreakpoint(object sender, Scintilla.MarginClickEventArgs e)
 {
     ToggleBreakpoint(e.LineNumber);
 }
Ejemplo n.º 60
0
 public static void zClearStyle(this Scintilla scintilla)
 {
     scintilla.StyleResetDefault();
     scintilla.StyleClearAll();
 }