Esempio n. 1
0
        void InitHotkeys()
        {
            // register the hotkeys with the form
            HotKeyManager.AddHotKey(this, OpenSearch, Keys.F, true);
            HotKeyManager.AddHotKey(this, OpenFindDialog, Keys.F, true, false, true);
            HotKeyManager.AddHotKey(this, OpenReplaceDialog, Keys.R, true);
            HotKeyManager.AddHotKey(this, OpenReplaceDialog, Keys.H, true);
            HotKeyManager.AddHotKey(this, Uppercase, Keys.U, true);
            HotKeyManager.AddHotKey(this, Lowercase, Keys.L, true);
            HotKeyManager.AddHotKey(this, ZoomIn, Keys.Oemplus, true);
            HotKeyManager.AddHotKey(this, ZoomOut, Keys.OemMinus, true);
            HotKeyManager.AddHotKey(this, ZoomDefault, Keys.D0, true);
            HotKeyManager.AddHotKey(this, CloseSearch, Keys.Escape);

            // remove conflicting hotkeys from scintilla
            TextArea.ClearCmdKey(Keys.Control | Keys.F);
            TextArea.ClearCmdKey(Keys.Control | Keys.R);
            TextArea.ClearCmdKey(Keys.Control | Keys.H);
            TextArea.ClearCmdKey(Keys.Control | Keys.L);
            TextArea.ClearCmdKey(Keys.Control | Keys.U);

            // Prevent Scinitilla from rendering certain keys
            TextArea.KeyPress += (object sender, KeyPressEventArgs e) =>
            {
                if (e.KeyChar < 32)
                {
                    // Prevent control characters from getting inserted into the text buffer
                    e.Handled = true;
                }
            };
        }
Esempio n. 2
0
        private void InitHotkeys()
        {
            //new HotKey(ModifierKeys.Windows | ModifierKeys.Alt, Keys.Left, mainWindow).HotKeyPressed += (k) => Console.Beep();

            //new HotKey(ModifierKeys.Control, Keys.F, mainWindow).HotKeyPressed += (k) => Console.Beep();
            //new HotKey(ModifierKeys.Control, Keys.H, mainWindow).HotKeyPressed += (k) => Console.Beep();
            new HotKey(ModifierKeys.Control, Keys.U, mainWindow).HotKeyPressed        += (k) => Uppercase();
            new HotKey(ModifierKeys.Control, Keys.L, mainWindow).HotKeyPressed        += (k) => Lowercase();
            new HotKey(ModifierKeys.Control, Keys.Oemplus, mainWindow).HotKeyPressed  += (k) => ZoomIn();
            new HotKey(ModifierKeys.Control, Keys.OemMinus, mainWindow).HotKeyPressed += (k) => ZoomOut();
            new HotKey(ModifierKeys.Control, Keys.D0, mainWindow).HotKeyPressed       += (k) => ZoomDefault();
            //new HotKey(ModifierKeys.Control, Keys.Escape, mainWindow).HotKeyPressed += (k) => Console.Beep();
            // register the hotkeys with the form

            /*HotKeyManager.AddHotKey(this, OpenSearch, Keys.F, true);
            *  HotKeyManager.AddHotKey(this, OpenFindDialog, Keys.F, true, false, true);
            *  HotKeyManager.AddHotKey(this, OpenReplaceDialog, Keys.R, true);
            *  HotKeyManager.AddHotKey(this, OpenReplaceDialog, Keys.H, true);
            *  HotKeyManager.AddHotKey(this, Uppercase, Keys.U, true);
            *  HotKeyManager.AddHotKey(this, Lowercase, Keys.L, true);
            *  HotKeyManager.AddHotKey(this, ZoomIn, Keys.Oemplus, true);
            *  HotKeyManager.AddHotKey(this, ZoomOut, Keys.OemMinus, true);
            *  HotKeyManager.AddHotKey(this, ZoomDefault, Keys.D0, true);
            *  HotKeyManager.AddHotKey(this, CloseSearch, Keys.Escape);*/

            // 从 scintilla 移除冲突热键
            codeEditor.ClearCmdKey(Keys.Control | Keys.F);
            codeEditor.ClearCmdKey(Keys.Control | Keys.R);
            codeEditor.ClearCmdKey(Keys.Control | Keys.H);
            codeEditor.ClearCmdKey(Keys.Control | Keys.L);
            codeEditor.ClearCmdKey(Keys.Control | Keys.U);
        }
Esempio n. 3
0
        void InitScintilla()
        {
            scintilla = new Scintilla();
            panelScintilla.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;
            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);
        }
 private void InitHotkeys()
 {
     // remove conflicting hotkeys from scintilla
     TextArea.ClearCmdKey(Keys.Control | Keys.F);
     TextArea.ClearCmdKey(Keys.Control | Keys.R);
     TextArea.ClearCmdKey(Keys.Control | Keys.H);
     TextArea.ClearCmdKey(Keys.Control | Keys.L);
     TextArea.ClearCmdKey(Keys.Control | Keys.U);
 }
Esempio n. 5
0
        private void InitHotkeys()
        {
            // register the hotkeys with the form
            HotKeyManager.AddHotKey(this, OpenSearch, Keys.F, true);
            HotKeyManager.AddHotKey(this, OpenFindDialog, Keys.F, true, false, true);
            HotKeyManager.AddHotKey(this, OpenReplaceDialog, Keys.R, true);
            HotKeyManager.AddHotKey(this, OpenReplaceDialog, Keys.H, true);
            HotKeyManager.AddHotKey(this, Uppercase, Keys.U, true);
            HotKeyManager.AddHotKey(this, Lowercase, Keys.L, true);
            HotKeyManager.AddHotKey(this, ZoomIn, Keys.Oemplus, true);
            HotKeyManager.AddHotKey(this, ZoomOut, Keys.OemMinus, true);
            HotKeyManager.AddHotKey(this, ZoomDefault, Keys.D0, true);
            HotKeyManager.AddHotKey(this, CloseSearch, Keys.Escape);

            // remove conflicting hotkeys from scintilla
            TextArea.ClearCmdKey(Keys.Control | Keys.F);
            TextArea.ClearCmdKey(Keys.Control | Keys.R);
            TextArea.ClearCmdKey(Keys.Control | Keys.H);
            TextArea.ClearCmdKey(Keys.Control | Keys.L);
            TextArea.ClearCmdKey(Keys.Control | Keys.U);

            TextArea.ClearCmdKey(Keys.F5);
            TextArea.ClearCmdKey(Keys.F6);
            TextArea.ClearCmdKey(Keys.F10);
            TextArea.ClearCmdKey(Keys.F12);

            HotKeyManager.AddHotKey(this, RunDebugger, Keys.F5);
            HotKeyManager.AddHotKey(this, OpenStorage, Keys.F6);
            HotKeyManager.AddHotKey(this, StepDebugger, Keys.F10);
            HotKeyManager.AddHotKey(this, ToggleDebuggerSource, Keys.F12);
        }
Esempio n. 6
0
        private void InitHotkeys()
        {
            // register the hotkeys with the form
            HotKeyManager.AddHotKey(this, OpenSearch, Keys.F, true);
            HotKeyManager.AddHotKey(this, OpenFindDialog, Keys.F, true, false, true);
            HotKeyManager.AddHotKey(this, OpenReplaceDialog, Keys.R, true);
            HotKeyManager.AddHotKey(this, OpenReplaceDialog, Keys.H, true);
            HotKeyManager.AddHotKey(this, Uppercase, Keys.U, true);
            HotKeyManager.AddHotKey(this, Lowercase, Keys.L, true);
            HotKeyManager.AddHotKey(this, ZoomIn, Keys.Oemplus, true);
            HotKeyManager.AddHotKey(this, ZoomOut, Keys.OemMinus, true);
            HotKeyManager.AddHotKey(this, ZoomDefault, Keys.D0, true);
            HotKeyManager.AddHotKey(this, CloseSearch, Keys.Escape);
            HotKeyManager.AddHotKey(this, NewFile, Keys.N, true);
            HotKeyManager.AddHotKey(this, OpenFile, Keys.O, true);
            HotKeyManager.AddHotKey(this, SaveFile, Keys.S, true);
            //HotKeyManager.AddHotKey(this, CloseFile, Keys.X, true);

            // remove conflicting hotkeys from scintilla
            TextArea.ClearCmdKey(Keys.Control | Keys.N);
            TextArea.ClearCmdKey(Keys.Control | Keys.O);
            TextArea.ClearCmdKey(Keys.Control | Keys.S);
            //TextArea.ClearCmdKey(Keys.Control | Keys.X);
            TextArea.ClearCmdKey(Keys.Control | Keys.F);

            TextArea.ClearCmdKey(Keys.Control | Keys.R);
            TextArea.ClearCmdKey(Keys.Control | Keys.H);
            TextArea.ClearCmdKey(Keys.Control | Keys.L);
            TextArea.ClearCmdKey(Keys.Control | Keys.U);
            //TextArea.ClearCmdKey(Keys.Control | Keys.S);
        }
        private void InitHotkeys()
        {
            // register the hotkeys with the form
            HotKeyManager.AddHotKey(this, OpenSearch, Keys.F, true);
            HotKeyManager.AddHotKey(this, Uppercase, Keys.U, true);
            HotKeyManager.AddHotKey(this, Lowercase, Keys.L, true);
            HotKeyManager.AddHotKey(this, ZoomIn, Keys.Oemplus, true);
            HotKeyManager.AddHotKey(this, ZoomOut, Keys.OemMinus, true);
            HotKeyManager.AddHotKey(this, ZoomDefault, Keys.D0, true);
            HotKeyManager.AddHotKey(this, CloseSearch, Keys.Escape);

            // remove conflicting hotkeys from scintilla
            scintillaTextArea.ClearCmdKey(Keys.Control | Keys.F);
            scintillaTextArea.ClearCmdKey(Keys.Control | Keys.R);
            scintillaTextArea.ClearCmdKey(Keys.Control | Keys.H);
            scintillaTextArea.ClearCmdKey(Keys.Control | Keys.L);
            scintillaTextArea.ClearCmdKey(Keys.Control | Keys.U);
        }
Esempio n. 8
0
        private void InitHotkeys()
        {
            Scintilla.KeyDown += OnHotkey;

            Scintilla.ClearCmdKey(Keys.Control | Keys.F);
            Scintilla.ClearCmdKey(Keys.Control | Keys.R);
            Scintilla.ClearCmdKey(Keys.Control | Keys.H);
            Scintilla.ClearCmdKey(Keys.Control | Keys.L);
            Scintilla.ClearCmdKey(Keys.Control | Keys.U);
            Scintilla.ClearCmdKey(Keys.Control | Keys.S);
        }
Esempio n. 9
0
        /// <summary>
        /// Set styles to a ScintillaNET control and disable some keybinds
        /// </summary>
        /// <param name="theBox"></param>
        public static void SetScintillaStyle(Scintilla theBox)
        {
            theBox.Styles[Style.Json.Default].ForeColor      = Color.Silver;
            theBox.Styles[Style.Json.Number].ForeColor       = Color.Goldenrod;
            theBox.Styles[Style.Json.String].ForeColor       = Color.RoyalBlue;
            theBox.Styles[Style.Json.StringEol].ForeColor    = Color.RoyalBlue;
            theBox.Styles[Style.Json.PropertyName].ForeColor = Color.Crimson;
            theBox.Styles[Style.Json.LineComment].ForeColor  = Color.DarkGray;
            theBox.Styles[Style.Json.BlockComment].ForeColor = Color.DarkGray;
            theBox.Styles[Style.Json.Uri].ForeColor          = Color.Peru;
            theBox.Styles[Style.Json.CompactIRI].ForeColor   = Color.Peru;
            theBox.Styles[Style.LineNumber].ForeColor        = Color.DarkGray;
            var nums = theBox.Margins[1];

            nums.Width     = 30;
            nums.Type      = MarginType.Number;
            nums.Sensitive = true;
            nums.Mask      = 0;

            theBox.SetProperty("fold", "1");
            theBox.SetProperty("fold.compact", "1");
            theBox.Margins[2].Type      = MarginType.Symbol;
            theBox.Margins[2].Mask      = Marker.MaskFolders;
            theBox.Margins[2].Sensitive = true;
            theBox.Margins[2].Width     = 20;
            for (int i = 25; i <= 31; i++)
            {
                theBox.Markers[i].SetForeColor(SystemColors.ControlLightLight);
                theBox.Markers[i].SetBackColor(SystemColors.ControlDark);
            }
            theBox.Markers[Marker.Folder].Symbol        = MarkerSymbol.BoxPlus;
            theBox.Markers[Marker.FolderOpen].Symbol    = MarkerSymbol.BoxMinus;
            theBox.Markers[Marker.FolderEnd].Symbol     = MarkerSymbol.BoxPlusConnected;
            theBox.Markers[Marker.FolderMidTail].Symbol = MarkerSymbol.TCorner;
            theBox.Markers[Marker.FolderOpenMid].Symbol = MarkerSymbol.BoxMinusConnected;
            theBox.Markers[Marker.FolderSub].Symbol     = MarkerSymbol.VLine;
            theBox.Markers[Marker.FolderTail].Symbol    = MarkerSymbol.LCorner;

            theBox.ClearCmdKey(Keys.Control | Keys.F);
            theBox.ClearCmdKey(Keys.Control | Keys.Z);
        }
Esempio n. 10
0
        /// <summary>
        /// Set styles to a ScintillaNET control and disable some keybinds
        /// </summary>
        /// <param name="theBox"></param>
        public static void SetScintillaStyle(Scintilla theBox)
        {
            theBox.Styles[Style.Json.Default].ForeColor      = Color.Silver;
            theBox.Styles[Style.Json.BlockComment].ForeColor = Color.FromArgb(0, 128, 0);
            theBox.Styles[Style.Json.LineComment].ForeColor  = Color.FromArgb(0, 128, 0);
            theBox.Styles[Style.Json.Number].ForeColor       = Color.Green;
            theBox.Styles[Style.Json.PropertyName].ForeColor = Color.SteelBlue;
            theBox.Styles[Style.Json.String].ForeColor       = Color.OrangeRed;
            theBox.Styles[Style.Json.StringEol].BackColor    = Color.OrangeRed;
            theBox.Styles[Style.Json.Operator].ForeColor     = Color.Black;
            theBox.Styles[Style.LineNumber].ForeColor        = Color.DarkGray;
            var nums = theBox.Margins[1];

            nums.Width     = 30;
            nums.Type      = MarginType.Number;
            nums.Sensitive = true;
            nums.Mask      = 0;

            theBox.ClearCmdKey(Keys.Control | Keys.F);
            theBox.ClearCmdKey(Keys.Control | Keys.Z);
            theBox.Lexer = Lexer.Json;
        }
Esempio n. 11
0
        private void InitHotkeys()
        {
            // register the hotkeys with the form
            //HotKeyManager.AddHotKey(form, OpenSearch, Keys.F, true);
            HotKeyManager.AddHotKey(Form, OpenFindDialog, Keys.F, true, false, true);
            HotKeyManager.AddHotKey(Form, OpenReplaceDialog, Keys.R, true);
            HotKeyManager.AddHotKey(Form, OpenReplaceDialog, Keys.H, true);
            HotKeyManager.AddHotKey(Form, Uppercase, Keys.U, true);
            HotKeyManager.AddHotKey(Form, SetIndentation, Keys.I, true);
            HotKeyManager.AddHotKey(Form, Lowercase, Keys.L, true);
            HotKeyManager.AddHotKey(Form, Lowercase, Keys.L, true);
            HotKeyManager.AddHotKey(Form, ZoomIn, Keys.Oemplus, true);
            HotKeyManager.AddHotKey(Form, ZoomOut, Keys.OemMinus, true);
            HotKeyManager.AddHotKey(Form, ZoomDefault, Keys.D0, true);
            //HotKeyManager.AddHotKey(this, CloseSearch, Keys.Escape);

            // remove conflicting hotkeys from scintilla
            TextArea.ClearCmdKey(Keys.Control | Keys.F);
            TextArea.ClearCmdKey(Keys.Control | Keys.R);
            TextArea.ClearCmdKey(Keys.Control | Keys.H);
            TextArea.ClearCmdKey(Keys.Control | Keys.L);
            TextArea.ClearCmdKey(Keys.Control | Keys.U);
        }
Esempio n. 12
0
        private void KisaYollar(Scintilla TextArea)
        {
            HotKeyManager.AddHotKey(this, TextArea.ZoomIn, Keys.Oemplus, true);
            HotKeyManager.AddHotKey(this, TextArea.ZoomOut, Keys.OemMinus, true);
            HotKeyManager.AddHotKey(this, KodUret, Keys.F5);

            TextArea.ClearCmdKey(Keys.Control | Keys.F);
            TextArea.ClearCmdKey(Keys.Control | Keys.R);
            TextArea.ClearCmdKey(Keys.Control | Keys.H);
            TextArea.ClearCmdKey(Keys.Control | Keys.L);
            TextArea.ClearCmdKey(Keys.Control | Keys.U);
            TextArea.ClearCmdKey(Keys.Control | Keys.S);

            void KodUret()
            {
                kodUretButon.PerformClick();
            }
        }
        private static void InitHotkeys(Scintilla editor)
        {
            // register the hotkeys with the form
            //HotKeyManager.AddHotKey(this, OpenSearch, Keys.F, true);
            //HotKeyManager.AddHotKey(this, OpenFindDialog, Keys.F, true, false, true);
            //HotKeyManager.AddHotKey(this, OpenReplaceDialog, Keys.R, true);
            //HotKeyManager.AddHotKey(this, OpenReplaceDialog, Keys.H, true);
            //HotKeyManager.AddHotKey(this, Uppercase, Keys.U, true);
            //HotKeyManager.AddHotKey(this, Lowercase, Keys.L, true);
            //HotKeyManager.AddHotKey(this, ZoomIn, Keys.Oemplus, true);
            //HotKeyManager.AddHotKey(this, ZoomOut, Keys.OemMinus, true);
            //HotKeyManager.AddHotKey(this, ZoomDefault, Keys.D0, true);
            //HotKeyManager.AddHotKey(this, CloseSearch, Keys.Escape);

            // remove conflicting hotkeys from scintilla
            editor.ClearCmdKey(Keys.Control | Keys.S);
            editor.ClearCmdKey(Keys.Control | Keys.F);
            editor.ClearCmdKey(Keys.Control | Keys.R);
            editor.ClearCmdKey(Keys.Control | Keys.H);
            editor.ClearCmdKey(Keys.Control | Keys.L);
            editor.ClearCmdKey(Keys.Control | Keys.U);
        }
Esempio n. 14
0
        private void loadTabPage(String fn)
        {
            String str = Path.GetFileName(fn);

            if (!(this.fileTabs.TabPages.Cast <TabPage>().Select(x => x.Text).Contains(str)))
            {
                TabPage tc = new TabPage(str);
                tc.Name = fn;
                this.fileTabs.TabPages.Add(tc);
                Scintilla s = null;
                tc.Controls.Add(new Scintilla()
                {
                    Size     = new Size(tc.Size.Width - 2, tc.Size.Height - 2),
                    Location = new Point(1, 1)
                });

                s = tc.Controls.Cast <Control>().Where(x => x.GetType() == typeof(Scintilla)).First() as Scintilla;
                s.StyleResetDefault();
                s.Styles[Style.Default].Font  = this.settings.getSetting("defaultStyleFont", "Consolas");
                s.Styles[Style.Default].SizeF = Single.Parse(this.settings.getSetting("defaultStyleSizeF", "13.5"));
                s.StyleClearAll();

                s.WrapMode = WrapMode.None;

                if (str.EndsWith(".bat"))
                {
                    s.Styles[Style.Batch.Command].ForeColor    = Color.Blue;
                    s.Styles[Style.Batch.Comment].ForeColor    = Color.Green;
                    s.Styles[Style.Batch.Identifier].ForeColor = Color.HotPink;
                    s.Styles[Style.Batch.Word].ForeColor       = Color.Blue;
                    s.Styles[Style.Batch.Default].ForeColor    = Color.Black;
                    s.Styles[Style.Batch.Label].ForeColor      = Color.White;
                    s.Styles[Style.Batch.Label].BackColor      = Color.Black;
                    s.Styles[Style.Batch.Operator].ForeColor   = Color.Black;

                    s.Lexer = Lexer.Batch;
                }

                else if (str.EndsWith(".asm"))
                {
                    s.Styles[Style.Asm.Comment].ForeColor          = Color.Gray;
                    s.Styles[Style.Asm.CommentBlock].ForeColor     = Color.Gray;
                    s.Styles[Style.Asm.CommentDirective].ForeColor = Color.Gray;
                    s.Styles[Style.Asm.CpuInstruction].ForeColor   = Color.Blue;
                    s.Styles[Style.Asm.Operator].ForeColor         = Color.Black;
                    s.Styles[Style.Asm.Number].ForeColor           = Color.DarkBlue;
                    s.Styles[Style.Asm.Character].ForeColor        = Color.HotPink;
                    s.Styles[Style.Asm.Default].ForeColor          = Color.Black;
                    s.Styles[Style.Asm.Directive].ForeColor        = Color.Blue;
                    s.Styles[Style.Asm.DirectiveOperand].ForeColor = Color.Blue;

                    s.Styles[Style.Asm.String].ForeColor = Color.LightSalmon;

                    s.Lexer = Lexer.Asm;

                    //TODO:: Autofill suggestions
                    //etc, like sharpdevelop
                }

                Int32 lldc = 0;
                s.TextChanged += delegate {
                    this.lastTxtChanged = s;

                    s.IndicatorCurrent = 8;
                    s.IndicatorClearRange(0, s.TextLength);

                    Int32 largestLineDigitCount = s.Lines.Count().ToString().Length;
                    if (largestLineDigitCount == lldc)
                    {
                        return;
                    }

                    s.Margins.First().Width = s.TextWidth(Style.LineNumber, new String('9', largestLineDigitCount + 1)) + Editor.numCtPadding;
                    lldc = largestLineDigitCount;
                };

                s.ClearCmdKey(Keys.Control | Keys.S);
                s.ClearCmdKey(Keys.Control | Keys.Shift | Keys.S);
                s.ClearCmdKey(Keys.Control | Keys.F);
                s.ClearCmdKey(Keys.Control | Keys.Shift | Keys.F);
                s.ClearCmdKey(Keys.Control | Keys.G);

                s.IndicatorCurrent = 8;
                s.IndicatorClearRange(0, s.TextLength);

                s.Indicators[8].Style     = IndicatorStyle.StraightBox;
                s.Indicators[8].ForeColor = Color.Red;

                tc.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
                foreach (Control con in tc.allChildren())
                {
                    con.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
                }

                s.Text = File.ReadAllText(fn);
                this.fileTabs.SelectTab(tc);
            }
        }
Esempio n. 15
0
        private void InitHotkeys()
        {
            var context = MainWindow.GetContext.DataContext as MainWindowVM;

            HotKeyManager.AddHotKey(textArea, ClearSelection, Keys.Escape);
            HotKeyManager.AddHotKey(textArea, GoBackwards, Keys.B, true);
            HotKeyManager.AddHotKey(textArea, GoForwards, Keys.B, true, true);
            HotKeyManager.AddHotKey(textArea, Lexer.Format, Keys.F, true);
            HotKeyManager.AddHotKey(textArea, SelectAll, Keys.A, true);
            HotKeyManager.AddHotKey(textArea, CommentFile, Keys.Q, true);
            HotKeyManager.AddHotKey(textArea, UnCommentFile, Keys.W, true);
            HotKeyManager.AddHotKey(textArea, FoldAll, Keys.G, true);
            HotKeyManager.AddHotKey(textArea, context.FileNew, Keys.N, true);
            HotKeyManager.AddHotKey(textArea, context.FileOpen, Keys.O, true);
            HotKeyManager.AddHotKey(textArea, context.FileSave, Keys.S, true);

            HotKeyManager.AddHotKey(textArea, lexer.SetSnippets, Keys.Enter, true);

            // remove conflicting hotkeys from scintilla
            textArea.ClearCmdKey(Keys.Control | Keys.N);
            textArea.ClearCmdKey(Keys.Control | Keys.O);
            textArea.ClearCmdKey(Keys.Control | Keys.S);
            textArea.ClearCmdKey(Keys.Control | Keys.F);
            textArea.ClearCmdKey(Keys.Control | Keys.H);
            textArea.ClearCmdKey(Keys.Control | Keys.Shift | Keys.W);
            textArea.ClearCmdKey(Keys.Control | Keys.W);
            textArea.ClearCmdKey(Keys.Escape);
            textArea.ClearCmdKey(Keys.Control | Keys.B);
            textArea.ClearCmdKey(Keys.Control | Keys.Shift | Keys.B);
            textArea.ClearCmdKey(Keys.Control | Keys.E);
            textArea.ClearCmdKey(Keys.Control | Keys.G);
            textArea.ClearCmdKey(Keys.Control | Keys.A);
            textArea.ClearCmdKey(Keys.Control | Keys.Q);
            textArea.ClearCmdKey(Keys.Control | Keys.U);
            textArea.ClearCmdKey(Keys.Control | Keys.Enter);
        }
Esempio n. 16
0
        public static void zClearCmdKeys(this Scintilla scintilla)
        {
            // Key Bindings https://github.com/jacobslusser/ScintillaNET/wiki/Key-Bindings
            // keep ctrl-A : select all, ctrl-Y : redo, ctrl-Z : undo
            // keep ctrl-C, ctrl-U, ctrl-V, ctrl-X,
            scintilla.ClearCmdKey(Keys.Control | Keys.B);
            scintilla.ClearCmdKey(Keys.Control | Keys.D);
            scintilla.ClearCmdKey(Keys.Control | Keys.E);
            scintilla.ClearCmdKey(Keys.Control | Keys.F);
            scintilla.ClearCmdKey(Keys.Control | Keys.G);
            scintilla.ClearCmdKey(Keys.Control | Keys.H);
            scintilla.ClearCmdKey(Keys.Control | Keys.I);
            scintilla.ClearCmdKey(Keys.Control | Keys.J);
            scintilla.ClearCmdKey(Keys.Control | Keys.K);
            scintilla.ClearCmdKey(Keys.Control | Keys.L);
            scintilla.ClearCmdKey(Keys.Control | Keys.M);
            scintilla.ClearCmdKey(Keys.Control | Keys.N);
            scintilla.ClearCmdKey(Keys.Control | Keys.O);
            scintilla.ClearCmdKey(Keys.Control | Keys.P);
            scintilla.ClearCmdKey(Keys.Control | Keys.Q);
            scintilla.ClearCmdKey(Keys.Control | Keys.R);
            scintilla.ClearCmdKey(Keys.Control | Keys.S);
            scintilla.ClearCmdKey(Keys.Control | Keys.T);
            scintilla.ClearCmdKey(Keys.Control | Keys.W);
            scintilla.ClearCmdKey(Keys.Control | Keys.Oem6);     // ctrl+^

            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.A);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.B);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.C);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.D);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.E);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.F);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.G);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.H);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.I);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.J);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.K);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.L);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.M);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.N);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.O);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.P);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.Q);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.R);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.S);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.T);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.U);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.V);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.W);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.X);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.Y);
            scintilla.ClearCmdKey(Keys.Control | Keys.Shift | Keys.Z);
        }
Esempio n. 17
0
        public static Scintilla CreateLuaEditor(Panel container)
        {
            var scintilla = new Scintilla();

            container.Controls.Add(scintilla);

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

            // https://gist.github.com/jacobslusser/91a3a00ec8eb52ea238ee7c18c8cdf99

            // Extracted from the Lua Scintilla lexer and SciTE .properties file

            var alphaChars    = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
            var numericChars  = "0123456789";
            var accentedChars = "ŠšŒœŸÿÀàÁáÂâÃãÄäÅåÆæÇçÈèÉéÊêËëÌìÍíÎîÏïÐðÑñÒòÓóÔôÕõÖØøÙùÚúÛûÜüÝýÞþßö";

            // Configuring the default style with properties
            // 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();

            // Configure the Lua lexer styles
            scintilla.Styles[Style.Lua.Default].ForeColor       = Color.Silver;
            scintilla.Styles[Style.Lua.Comment].ForeColor       = Color.Green;
            scintilla.Styles[Style.Lua.CommentLine].ForeColor   = Color.Green;
            scintilla.Styles[Style.Lua.Number].ForeColor        = Color.Olive;
            scintilla.Styles[Style.Lua.Word].ForeColor          = Color.Blue;
            scintilla.Styles[Style.Lua.Word2].ForeColor         = Color.BlueViolet;
            scintilla.Styles[Style.Lua.Word3].ForeColor         = Color.DarkSlateBlue;
            scintilla.Styles[Style.Lua.Word4].ForeColor         = Color.DarkSlateBlue;
            scintilla.Styles[Style.Lua.String].ForeColor        = Color.Red;
            scintilla.Styles[Style.Lua.Character].ForeColor     = Color.Red;
            scintilla.Styles[Style.Lua.LiteralString].ForeColor = Color.Red;
            scintilla.Styles[Style.Lua.StringEol].BackColor     = Color.Pink;
            scintilla.Styles[Style.Lua.Operator].ForeColor      = Color.Purple;
            scintilla.Styles[Style.Lua.Preprocessor].ForeColor  = Color.Maroon;
            scintilla.Lexer     = Lexer.Lua;
            scintilla.WordChars = alphaChars + numericChars + accentedChars;

            // Console.WriteLine(scintilla.DescribeKeywordSets());

            var luaKeyWords = "Api Signal Stop Sleep Print ";

            // Keywords
            scintilla.SetKeywords(0, "and break do else elseif end for function if in local nil not or repeat return then until while" + " false true" + " goto");
            // Basic Functions
            scintilla.SetKeywords(1, luaKeyWords + "assert collectgarbage dofile error _G getmetatable ipairs loadfile next pairs pcall print rawequal rawget rawset setmetatable tonumber tostring type _VERSION xpcall string table math coroutine io os debug" + " getfenv gcinfo load loadlib loadstring require select setfenv unpack _LOADED LUA_PATH _REQUIREDNAME package rawlen package bit32 utf8 _ENV");
            // String Manipulation & Mathematical
            scintilla.SetKeywords(2, "string.byte string.char string.dump string.find string.format string.gsub string.len string.lower string.rep string.sub string.upper table.concat table.insert table.remove table.sort math.abs math.acos math.asin math.atan math.atan2 math.ceil math.cos math.deg math.exp math.floor math.frexp math.ldexp math.log math.max math.min math.pi math.pow math.rad math.random math.randomseed math.sin math.sqrt math.tan" + " string.gfind string.gmatch string.match string.reverse string.pack string.packsize string.unpack table.foreach table.foreachi table.getn table.setn table.maxn table.pack table.unpack table.move math.cosh math.fmod math.huge math.log10 math.modf math.mod math.sinh math.tanh math.maxinteger math.mininteger math.tointeger math.type math.ult" + " bit32.arshift bit32.band bit32.bnot bit32.bor bit32.btest bit32.bxor bit32.extract bit32.replace bit32.lrotate bit32.lshift bit32.rrotate bit32.rshift" + " utf8.char utf8.charpattern utf8.codes utf8.codepoint utf8.len utf8.offset");
            // Input and Output Facilities and System Facilities
            scintilla.SetKeywords(3, "coroutine.create coroutine.resume coroutine.status coroutine.wrap coroutine.yield io.close io.flush io.input io.lines io.open io.output io.read io.tmpfile io.type io.write io.stdin io.stdout io.stderr os.clock os.date os.difftime os.execute os.exit os.getenv os.remove os.rename os.setlocale os.time os.tmpname" + " coroutine.isyieldable coroutine.running io.popen module package.loaders package.seeall package.config package.searchers package.searchpath" + " require package.cpath package.loaded package.loadlib package.path package.preload");

            // 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);

            // Disable cmd
            scintilla.ClearCmdKey(Keys.Control | Keys.F);
            return(scintilla);
        }
Esempio n. 18
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);

            // Configure a margin to display line number
            if (!readOnlyMode)
            {
                scintilla.Margins[0].Type  = MarginType.Number;
                scintilla.Margins[0].Width = 16;
                scintilla.Styles[Style.LineNumber].ForeColor = Color.DarkGray;
            }

            VgcApis.Misc.UI.SetSearchIndicator(scintilla);

            return(scintilla);
        }
Esempio n. 19
0
        public void InitScintilla(Scintilla scintilla)
        {
            // INITIAL VIEW CONFIG
            scintilla.WrapMode          = WrapMode.None;
            scintilla.IndentationGuides = IndentView.LookBoth;

            scintilla.StyleResetDefault();
            scintilla.Styles[Style.Default].Font  = "Courier New";
            scintilla.Styles[Style.Default].SizeF = 9.75f;
            scintilla.StyleClearAll();

            //scintilla.Margins[0].Type = MarginType.Number;
            scintilla.Margins[0].Width = 20; // Show line numbers.

            scintilla.Lexer = Lexer.Xml;

            // DEFAULT
            scintilla.Styles[0].ForeColor = Color.FromArgb(0x000000);
            scintilla.Styles[0].BackColor = Color.FromArgb(0xFFFFFF);
            scintilla.Styles[0].Bold      = true;
            // TAG
            scintilla.Styles[1].ForeColor = Color.FromArgb(0x0000FF);
            scintilla.Styles[1].BackColor = Color.FromArgb(0xFFFFFF);
            // TAGUNKNOWN
            scintilla.Styles[2].ForeColor = Color.FromArgb(0x0000FF);
            scintilla.Styles[2].BackColor = Color.FromArgb(0xFFFFFF);
            // ATTRIBUTE
            scintilla.Styles[3].ForeColor = Color.FromArgb(0xFF0000);
            scintilla.Styles[3].BackColor = Color.FromArgb(0xFFFFFF);
            // ATTRIBUTEUNKNOWN
            scintilla.Styles[4].ForeColor = Color.FromArgb(0xFF0000);
            scintilla.Styles[4].BackColor = Color.FromArgb(0xFFFFFF);
            // NUMBER
            scintilla.Styles[5].ForeColor = Color.FromArgb(0xFF0000);
            scintilla.Styles[5].BackColor = Color.FromArgb(0xFFFFFF);
            // DOUBLESTRING
            scintilla.Styles[6].ForeColor = Color.FromArgb(0x8000FF);
            scintilla.Styles[6].BackColor = Color.FromArgb(0xFFFFFF);
            //scintilla.Styles[6].Bold = true;
            // SINGLESTRING
            scintilla.Styles[7].ForeColor = Color.FromArgb(0x8000FF);
            scintilla.Styles[7].BackColor = Color.FromArgb(0xFFFFFF);
            //scintilla.Styles[7].Bold = true;
            // COMMENT
            scintilla.Styles[9].ForeColor = Color.FromArgb(0x008000);
            scintilla.Styles[9].BackColor = Color.FromArgb(0xFFFFFF);
            // ENTITY
            scintilla.Styles[10].ForeColor = Color.FromArgb(0x000000);
            scintilla.Styles[10].BackColor = Color.FromArgb(0xFEFDE0);
            //scintilla.Styles[10].Italic = true;
            // TAGEND
            scintilla.Styles[11].ForeColor = Color.FromArgb(0x0000FF);
            scintilla.Styles[11].BackColor = Color.FromArgb(0xFFFFFF);
            // XMLSTART
            scintilla.Styles[12].ForeColor = Color.FromArgb(0xFF0000);
            scintilla.Styles[12].BackColor = Color.FromArgb(0xFFFF00);
            // XMLEND
            scintilla.Styles[13].ForeColor = Color.FromArgb(0xFF0000);
            scintilla.Styles[13].BackColor = Color.FromArgb(0xFFFF00);
            // SGMLDEFAULT
            scintilla.Styles[21].ForeColor = Color.FromArgb(0x000000);
            scintilla.Styles[21].BackColor = Color.FromArgb(0xA6CAF0);
            // CDATA
            scintilla.Styles[17].ForeColor = Color.FromArgb(0xFF8000);
            scintilla.Styles[17].BackColor = Color.FromArgb(0xFFFFFF);

            // Enable folding
            scintilla.SetProperty("fold", "1");
            scintilla.SetProperty("fold.compact", "1");
            scintilla.SetProperty("fold.html", "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);
             * }*/

            // 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;

            scintilla.ClearCmdKey(Keys.Control | Keys.F);
            scintilla.ClearCmdKey(Keys.Control | Keys.G);
            scintilla.ClearCmdKey(Keys.Control | Keys.S);
            scintilla.ClearCmdKey(Keys.Control | Keys.H);
            scintilla.ClearCmdKey(Keys.Control | Keys.B);

            scintilla.FoldAll(FoldAction.Expand);
            scintilla.FoldAll(FoldAction.Contract);

            scintilla.Text = string.Empty;
            scintilla.EmptyUndoBuffer();

            scintilla.TextChanged += (this.OnTextChanged);
        }
Esempio n. 20
0
        /// <summary>
        /// Creates a new SQL (default) Scintilla editor with highlighting
        /// </summary>
        /// <param name="commandFactory">Unless your control is going to be 100% ReadOnly then you should supply an ICommandFactory e.g. RDMPCommandFactory to allow dragging and
        /// dropping components into the window.  The ICommandFactory will decide whether the given object can be translated into an ICommand and hence into a unique bit of SQL
        /// to add to the editor</param>
        /// <param name="language">Determines highlighting, options include mssql,csharp or null</param>
        /// <param name="syntaxHelper"></param>
        /// <param name="spellCheck"></param>
        /// <param name="lineNumbers"></param>
        /// <param name="currentDirectory"></param>
        /// <returns></returns>
        public Scintilla Create(ICommandFactory commandFactory = null, string language = "mssql", IQuerySyntaxHelper syntaxHelper = null, bool spellCheck = false, bool lineNumbers = true, string currentDirectory = null)
        {
            var toReturn = new Scintilla();

            toReturn.Dock       = DockStyle.Fill;
            toReturn.HScrollBar = true;
            toReturn.VScrollBar = true;

            if (lineNumbers)
            {
                toReturn.Margins[0].Width = 40; //allows display of line numbers
            }
            else
            {
                foreach (var margin in toReturn.Margins)
                {
                    margin.Width = 0;
                }
            }

            toReturn.ClearCmdKey(Keys.Control | Keys.S); //prevent Ctrl+S displaying ascii code
            toReturn.ClearCmdKey(Keys.Control | Keys.R); //prevent Ctrl+R displaying ascii code
            toReturn.ClearCmdKey(Keys.Control | Keys.W); //prevent Ctrl+W displaying ascii code

            if (language == "mssql")
            {
                SetSQLHighlighting(toReturn, syntaxHelper);
            }

            if (language == "csharp")
            {
                SetCSharpHighlighting(toReturn);
            }

            if (commandFactory != null)
            {
                toReturn.AllowDrop  = true;
                toReturn.DragEnter += (s, e) => OnDragEnter(s, e, commandFactory);
                toReturn.DragDrop  += (s, e) => OnDragDrop(s, e, commandFactory);
            }

            toReturn.WrapMode         = (WrapMode)UserSettings.WrapMode;
            toReturn.ContextMenuStrip = new ScintillaMenu(toReturn);
            try
            {
                if (spellCheck)
                {
                    string aff;
                    string dic;

                    if (currentDirectory == null)
                    {
                        aff = "en_us.aff";
                        dic = "en_us.dic";
                    }
                    else
                    {
                        aff = Path.Combine(currentDirectory, "en_us.aff");
                        dic = Path.Combine(currentDirectory, "en_us.dic");
                    }

                    var hunspell = new Hunspell(aff, dic);
                    toReturn.TextChanged += (s, e) => scintilla_TextChanged(s, e, hunspell);
                    toReturn.Disposed    += (s, e) => scintilla_Disposed(s, e, hunspell);
                }
            }
            catch (Exception e)
            {
                if (!DictionaryExceptionShown)
                {
                    ExceptionViewer.Show("Could not load dictionary", e);
                    DictionaryExceptionShown = true;
                }
            }

            return(toReturn);
        }
Esempio n. 21
0
        public static Scintilla CreateLuaEditor(Panel container)
        {
            var scintilla = new Scintilla();

            container.Controls.Add(scintilla);

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

            // https://gist.github.com/jacobslusser/91a3a00ec8eb52ea238ee7c18c8cdf99

            // Extracted from the Lua Scintilla lexer and SciTE .properties file

            var alphaChars    = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
            var numericChars  = "0123456789";
            var accentedChars = "ŠšŒœŸÿÀàÁáÂâÃãÄäÅåÆæÇçÈèÉéÊêËëÌìÍíÎîÏïÐðÑñÒòÓóÔôÕõÖØøÙùÚúÛûÜüÝýÞþßö";

            // Configuring the default style with properties
            // we have common to every lexer style saves time.
            scintilla.StyleResetDefault();
            scintilla.Styles[Style.Default].Font = "Consolas";
            scintilla.Styles[Style.Default].Size = 11;
            scintilla.StyleClearAll();

            // Configure the Lua lexer styles
            scintilla.Styles[Style.Lua.Default].ForeColor       = Color.Silver;
            scintilla.Styles[Style.Lua.Comment].ForeColor       = Color.Green;
            scintilla.Styles[Style.Lua.CommentLine].ForeColor   = Color.Green;
            scintilla.Styles[Style.Lua.Number].ForeColor        = Color.Olive;
            scintilla.Styles[Style.Lua.Word].ForeColor          = Color.Blue;
            scintilla.Styles[Style.Lua.Word2].ForeColor         = Color.BlueViolet;
            scintilla.Styles[Style.Lua.Word3].ForeColor         = Color.DarkSlateBlue;
            scintilla.Styles[Style.Lua.Word4].ForeColor         = Color.Violet;
            scintilla.Styles[Style.Lua.String].ForeColor        = Color.Red;
            scintilla.Styles[Style.Lua.Character].ForeColor     = Color.Red;
            scintilla.Styles[Style.Lua.LiteralString].ForeColor = Color.Red;
            scintilla.Styles[Style.Lua.StringEol].BackColor     = Color.Pink;
            scintilla.Styles[Style.Lua.Operator].ForeColor      = Color.Purple;
            scintilla.Styles[Style.Lua.Preprocessor].ForeColor  = Color.Maroon;
            scintilla.Lexer = Lexer.Lua;

            scintilla.WordChars = alphaChars + numericChars + accentedChars;

            // Console.WriteLine(scintilla.DescribeKeywordSets());

            // Keywords
            scintilla.SetKeywords(0, VgcApis.Models.Consts.Lua.LuaKeywords);

            // Basic Functions

            scintilla.SetKeywords(1,
                                  VgcApis.Models.Consts.Lua.ApiFuncNames +
                                  " " +
                                  VgcApis.Models.Consts.Lua.LuaFunctions);

            // String Manipulation & Mathematical
            // Input and Output Facilities and System Facilities
            scintilla.SetKeywords(2, VgcApis.Models.Consts.Lua.LuaSubFunctions);

            scintilla.SetKeywords(3, VgcApis.Models.Consts.Lua.LuaModules);

            // 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);

            // Disable cmd
            scintilla.ClearCmdKey(Keys.Control | Keys.G);
            scintilla.ClearCmdKey(Keys.Control | Keys.OemOpenBrackets);
            scintilla.ClearCmdKey(Keys.Control | Keys.Oem6);
            scintilla.ClearCmdKey(Keys.Control | Keys.OemMinus);
            scintilla.ClearCmdKey(Keys.Control | Keys.Oemplus);
            scintilla.ClearCmdKey(Keys.Control | Keys.F);
            scintilla.ClearCmdKey(Keys.Control | Keys.S);
            scintilla.ClearCmdKey(Keys.Control | Keys.N);

            // Configure a margin to display line number
            scintilla.Margins[0].Type  = MarginType.Number;
            scintilla.Margins[0].Width = 16;
            scintilla.Styles[Style.LineNumber].ForeColor = Color.DarkGray;

            VgcApis.Misc.UI.SetSearchIndicator(scintilla);

            return(scintilla);
        }
        /// <summary>
        /// Creates a new SQL (default) Scintilla editor with highlighting
        /// </summary>
        /// <param name="commandFactory">Unless your control is going to be 100% ReadOnly then you should supply an <see cref="ICombineableFactory"/> to allow dragging and
        /// dropping components into the window.  The <see cref="ICombineableFactory"/> will decide whether the given object can be translated into an <see cref="ICombineToMakeCommand"/> and hence into a unique bit of SQL
        /// to add to the editor</param>
        /// <param name="language">Determines highlighting, options include mssql,csharp or null</param>
        /// <param name="syntaxHelper"></param>
        /// <param name="spellCheck"></param>
        /// <param name="lineNumbers"></param>
        /// <param name="currentDirectory"></param>
        /// <returns></returns>
        public Scintilla Create(ICombineableFactory commandFactory = null, SyntaxLanguage language = SyntaxLanguage.SQL, IQuerySyntaxHelper syntaxHelper = null, bool spellCheck = false, bool lineNumbers = true, string currentDirectory = null)
        {
            var toReturn = new Scintilla();

            toReturn.Dock       = DockStyle.Fill;
            toReturn.HScrollBar = true;
            toReturn.VScrollBar = true;

            if (lineNumbers)
            {
                toReturn.Margins[0].Width = 40; //allows display of line numbers
            }
            else
            {
                foreach (var margin in toReturn.Margins)
                {
                    margin.Width = 0;
                }
            }

            toReturn.ClearCmdKey(Keys.Control | Keys.S); //prevent Ctrl+S displaying ascii code
            toReturn.ClearCmdKey(Keys.Control | Keys.R); //prevent Ctrl+R displaying ascii code
            toReturn.ClearCmdKey(Keys.Control | Keys.W); //prevent Ctrl+W displaying ascii code

            switch (language)
            {
            case SyntaxLanguage.SQL:
                SetSQLHighlighting(toReturn, syntaxHelper);
                break;

            case SyntaxLanguage.CSharp:
                SetCSharpHighlighting(toReturn);
                break;

            case SyntaxLanguage.XML:
                SetLexerEnumHighlighting(toReturn, Lexer.Xml);
                break;

            case SyntaxLanguage.LogFile:
                SetLexerEnumHighlighting(toReturn, Lexer.Verilog);
                break;
            }

            if (commandFactory != null)
            {
                toReturn.AllowDrop  = true;
                toReturn.DragEnter += (s, e) => OnDragEnter(s, e, commandFactory);
                toReturn.DragDrop  += (s, e) => OnDragDrop(s, e, commandFactory);
            }

            toReturn.WrapMode = (WrapMode)UserSettings.WrapMode;
            var scintillaMenu = new ScintillaMenu(toReturn, spellCheck);

            toReturn.ContextMenuStrip = scintillaMenu;

            try
            {
                if (spellCheck)
                {
                    string aff;
                    string dic;

                    if (currentDirectory == null)
                    {
                        aff = "en_us.aff";
                        dic = "en_us.dic";
                    }
                    else
                    {
                        aff = Path.Combine(currentDirectory, "en_us.aff");
                        dic = Path.Combine(currentDirectory, "en_us.dic");
                    }

                    var hunspell = new Hunspell(aff, dic);

                    DateTime lastCheckedSpelling = DateTime.MinValue;

                    toReturn.KeyPress += (s, e) =>
                    {
                        if (DateTime.Now.Subtract(lastCheckedSpelling) > TimeSpan.FromSeconds(10))
                        {
                            lastCheckedSpelling = DateTime.Now;
                            CheckSpelling((Scintilla)s, hunspell);
                        }
                    };

                    toReturn.Leave        += (s, e) => CheckSpelling((Scintilla)s, hunspell);
                    toReturn.Disposed     += (s, e) => scintilla_Disposed(s, e, hunspell);
                    scintillaMenu.Hunspell = hunspell;
                }
            }
            catch (Exception e)
            {
                if (!DictionaryExceptionShown)
                {
                    ExceptionViewer.Show("Could not load dictionary", e);
                    DictionaryExceptionShown = true;
                }
            }

            return(toReturn);
        }
Esempio n. 23
0
        private void InitHotkeys()
        {
            // register the hotkeys with the document
            HotKeyManager.AddHotKey(textArea, ZoomIn, Keys.Oemplus, true);
            HotKeyManager.AddHotKey(textArea, ZoomOut, Keys.OemMinus, true);
            HotKeyManager.AddHotKey(textArea, ZoomDefault, Keys.D0, true);
            HotKeyManager.AddHotKey(textArea, AddWatch, Keys.W, true, true);
            HotKeyManager.AddHotKey(textArea, SelectWord, Keys.W, true);
            HotKeyManager.AddHotKey(textArea, TopOfView, Keys.End, true, false, true);
            HotKeyManager.AddHotKey(textArea, ClearSelection, Keys.Escape);
            HotKeyManager.AddHotKey(textArea, GoBackwards, Keys.B, true);
            HotKeyManager.AddHotKey(textArea, GoForwards, Keys.B, true, true);

            // remove conflicting hotkeys from scintilla
            textArea.ClearCmdKey(Keys.Control | Keys.N);
            textArea.ClearCmdKey(Keys.Control | Keys.O);
            textArea.ClearCmdKey(Keys.Control | Keys.S);
            textArea.ClearCmdKey(Keys.Control | Keys.Shift | Keys.S);
            textArea.ClearCmdKey(Keys.Control | Keys.Shift | Keys.O);
            textArea.ClearCmdKey(Keys.Control | Keys.F);
            textArea.ClearCmdKey(Keys.Control | Keys.H);
            textArea.ClearCmdKey(Keys.Control | Keys.Shift | Keys.W);
            textArea.ClearCmdKey(Keys.Control | Keys.W);
            textArea.ClearCmdKey(Keys.Control | Keys.Alt | Keys.End);
            textArea.ClearCmdKey(Keys.Escape);
            textArea.ClearCmdKey(Keys.Control | Keys.B);
            textArea.ClearCmdKey(Keys.Control | Keys.Shift | Keys.B);
        }