SetHighlighting() публичный Метод

public SetHighlighting ( string name ) : void
name string
Результат void
Пример #1
0
        private TextEditorControl CreateTextBox()
        {
            var tb = new TextEditorControl();
            tb.IsReadOnly = true;            
            
            // TODO: set proper highlighting.
            tb.SetHighlighting("C#");

            var high = (ICSharpCode.TextEditor.Document.DefaultHighlightingStrategy)tb.Document.HighlightingStrategy;
            var def = high.Rules.First();
            var delim = " ,().:\t\n\r";
            for(int i = 0; i < def.Delimiters.Length; ++i)
                def.Delimiters[i] = delim.Contains((char)i);

            tb.ShowLineNumbers = false;
            tb.ShowInvalidLines = false;
            tb.ShowVRuler = false;
            tb.ActiveTextAreaControl.TextArea.ToolTipRequest += OnToolTipRequest;
            tb.ActiveTextAreaControl.TextArea.MouseMove += OnTextAreaMouseMove;

            string[] tryFonts = new[] { "Consolas", "Lucida Console" };

            foreach (var fontName in tryFonts)
            {
                tb.Font = new Font(fontName, 9, FontStyle.Regular);
                if (tb.Font.Name == fontName) break;
            }

            if (!tryFonts.Contains(tb.Font.Name))
                tb.Font = new Font(FontFamily.GenericMonospace, 9);
            
            return tb;
        }
Пример #2
0
 public FdoSqlQueryCtl()
 {
     InitializeComponent();
     _editor = new TextEditorControl();
     _editor.Dock = DockStyle.Fill;
     _editor.SetHighlighting("SQL");
     this.Controls.Add(_editor);
 }
Пример #3
0
        /// <summary>
        /// Crée une nouvelle page.
        /// </summary>
        void CreateNewPage(string fullpath, bool load)
        {
            // Création de l'éditeur de code.
            ICSharpCode.TextEditor.TextEditorControl editor = new ICSharpCode.TextEditor.TextEditorControl();
            string dir = "res\\";
            FileSyntaxModeProvider fsmProvider;

            if (Directory.Exists(dir))
            {
                fsmProvider = new FileSyntaxModeProvider(dir);

                HighlightingManager.Manager.AddSyntaxModeFileProvider(fsmProvider);
                editor.SetHighlighting("clank");
            }
            editor.ConvertTabsToSpaces = true;
            editor.Dock              = System.Windows.Forms.DockStyle.Fill;
            editor.IsReadOnly        = false;
            editor.Location          = new System.Drawing.Point(0, 0);
            editor.Size              = new System.Drawing.Size(591, 249);
            editor.Font              = new System.Drawing.Font("Consolas", 10);
            editor.TabIndex          = 0;
            editor.Text              = "main\r\n{\r\n}\r\n";
            editor.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            // Ajout d'un nouveau tab page.
            int    index   = m_codeTabs.TabCount;
            string display = fullpath;

            if (File.Exists(fullpath))
            {
                display = Path.GetFileName(fullpath);
            }
            TabPage page = new TabPage(display);

            page.Controls.Add(editor);
            PageInfo info = new PageInfo()
            {
                SourceFile = fullpath, Page = page, Editor = editor
            };

            m_pageInfos.Add(info);

            editor.TextChanged += (object sender, EventArgs e) => { OnEditorTextChanged(info); };

            // Chargement ?
            if (load && File.Exists(fullpath))
            {
                string text = File.ReadAllText(fullpath);
                editor.Text = text;
            }

            m_codeTabs.TabPages.Add(page);
            m_codeTabs.SelectedTab = page;
        }
Пример #4
0
        public PlistEditControl(FATabStrip tabStrip, string title, PlistInfo p = null)
        {
            Editor = new TextEditorControl();
            Tab = new FATabStripItem();
            Tab.Title = title;
            Tab.Controls.Add(Editor);
            Editor.Dock = DockStyle.Fill;
            if (p == null)
            {
                p = new PlistInfo();
            }
            Pinfo = p;
            Editor.Text = p.Content;
            Editor.SetHighlighting("XML");
            Editor.TextChanged += Editor_TextChanged;

            tabStrip.AddTab(Tab);
            Saved = true;
        }
Пример #5
0
        public DocumentPanel(string fileName)
        {
            InitializeComponent();
            _fileName = fileName;
            TabText = _fileName;
            if (PlatformSupport.Platform == PlatformType.Windows)
            {
                Icon = Properties.Resources.document_properties;

                // SharpDevelop text editor is Windows only.
                var txtDocument = new TextEditorControl {Dock = DockStyle.Fill, IsReadOnly = true, Name = "txtDocument"};
                Controls.Add(txtDocument);

                txtDocument.SetHighlighting("SMI"); // Activate the highlighting, use the name from the SyntaxDefinition node.
                txtDocument.LoadFile(_fileName);
            }
            else
            {
                var txtDocument = new RichTextBox {Dock = DockStyle.Fill, Name = "txtDocument", ReadOnly = true};
                Controls.Add(txtDocument);

                txtDocument.LoadFile(_fileName, RichTextBoxStreamType.PlainText);
            }
        }
Пример #6
0
        public void SetSyntax(StandardSyntaxType type)
        {
            var name = type.GetAttributeProperty <SyntaxModeNameAttribute, string>(attribute => attribute.Name) ?? "";

            _editor.SetHighlighting(name);
        }
Пример #7
0
 public override void _initControl()
 {
     if (null == mTextEditorControl || mTextEditorControl.IsDisposed)
     {
         mTextEditorControl = new TextEditorControl();
         if (string.Compare(mDockStyle, @"Top") == 0)
         {
             mTextEditorControl.Dock = DockStyle.Top;
         }
         else if (string.Compare(mDockStyle, @"Bottom") == 0)
         {
             mTextEditorControl.Dock = DockStyle.Bottom;
         }
         else if (string.Compare(mDockStyle, @"Fill") == 0)
         {
             mTextEditorControl.Dock = DockStyle.Fill;
         }
         else if (string.Compare(mDockStyle, @"Left") == 0)
         {
             mTextEditorControl.Dock = DockStyle.Left;
         }
         else if (string.Compare(mDockStyle, @"Right") == 0)
         {
             mTextEditorControl.Dock = DockStyle.Right;
         }
         else
         {
             mTextEditorControl.Dock = DockStyle.None;
         }
         mTextEditorControl.SetHighlighting(mHighlighting);
         if (null != mUrl)
         {
             this._openUrl(mUrl);
         }
     }
 }
Пример #8
0
        public TabInfo Open(string file, OpenType type, bool addToMRU = true, bool alwaysNew = false)
        {
            if (type == OpenType.File) {
                if (!Path.IsPathRooted(file)) {
                    file = Path.GetFullPath(file);
                }
                //Add this file to the recent files list
                if (addToMRU) {
                    Settings.AddRecentFile(file);
                }
                UpdateRecentList();
                //If this is an int, decompile
                if (string.Compare(Path.GetExtension(file), ".int", true) == 0) {
                    var compiler = new Compiler();
                    string decomp = compiler.Decompile(file);
                    if (decomp == null) {
                        MessageBox.Show("Decompilation of '" + file + "' was not successful", "Error");
                        return null;
                    } else {
                        file = decomp;
                        type = OpenType.Text;
                    }
                } else {
                    //Check if the file is already open
                    for (int i = 0; i < tabs.Count; i++) {
                        if (string.Compare(tabs[i].filepath, file, true) == 0) {
                            tabControl1.SelectTab(i);
                            return tabs[i];
                        }
                    }
                }
            }
            //Create the text editor and set up the tab
            ICSharpCode.TextEditor.TextEditorControl te = new ICSharpCode.TextEditor.TextEditorControl();
            te.ShowVRuler = false;
            te.Document.FoldingManager.FoldingStrategy = new CodeFolder();
            te.IndentStyle = IndentStyle.Smart;
            te.ConvertTabsToSpaces = Settings.tabsToSpaces;
            te.TabIndent = Settings.tabSize;
            te.Document.TextEditorProperties.IndentationSize = Settings.tabSize;
            if (type == OpenType.File)
                te.LoadFile(file, false, true);
            else if (type == OpenType.Text)
                te.Text = file;
            if (type == OpenType.File && string.Compare(Path.GetExtension(file), ".msg", true) == 0)
                te.SetHighlighting("msg");
            else
                te.SetHighlighting("ssl"); // Activate the highlighting, use the name from the SyntaxDefinition node.
            te.TextChanged += textChanged;
            te.ActiveTextAreaControl.TextArea.MouseDown += delegate(object a1, MouseEventArgs a2) {
                if (a2.Button == MouseButtons.Left)
                    UpdateEditorToolStripMenu();
                lbAutocomplete.Hide();
            };
            te.ActiveTextAreaControl.TextArea.KeyPress += KeyPressed;
            te.HorizontalScroll.Visible = false;

            te.ActiveTextAreaControl.TextArea.PreviewKeyDown += delegate(object sender, PreviewKeyDownEventArgs a2) {
                if (lbAutocomplete.Visible) {
                    if ((a2.KeyCode == Keys.Down || a2.KeyCode == Keys.Up || a2.KeyCode == Keys.Tab)) {
                        lbAutocomplete.Focus();
                        lbAutocomplete.SelectedIndex = 0;
                    } else if (a2.KeyCode == Keys.Escape) {
                        lbAutocomplete.Hide();
                    }
                } else {
                    if (toolTipAC.Active && a2.KeyCode != Keys.Left && a2.KeyCode != Keys.Right)
                        toolTipAC.Hide(panel1);
                }
            };

            TabInfo ti = new TabInfo();
            ti.textEditor = te;
            ti.changed = false;
            if (type == OpenType.File && !alwaysNew) {
                ti.filepath = file;
                ti.filename = Path.GetFileName(file);
            } else {
                ti.filepath = null;
                ti.filename = unsaved;
            }
            ti.index = tabControl1.TabCount;
            te.ActiveTextAreaControl.TextArea.ToolTipRequest += new ToolTipRequestEventHandler(TextArea_ToolTipRequest);
            te.ContextMenuStrip = editorMenuStrip;

            tabs.Add(ti);
            TabPage tp = new TabPage(ti.filename);
            tp.Controls.Add(te);
            te.Dock = DockStyle.Fill;

            tabControl1.TabPages.Add(tp);
            if (type == OpenType.File & !alwaysNew) {
                tp.ToolTipText = ti.filepath;
                System.String ext = Path.GetExtension(file).ToLower();
                if (ext == ".ssl" || ext == ".h") {
                    ti.shouldParse = true;
                    ti.needsParse = true;
                    if (Settings.autoOpenMsgs && ti.filepath != null)
                        AssossciateMsg(ti, false);
                }
            }
            if (tabControl1.TabPages.Count > 1) {
                tabControl1.SelectTab(tp);
            } else {
                tabControl1_Selected(null, null);
            }
            return ti;
        }
Пример #9
0
		public void SetupIntellisense(TextEditorControl control)
		{
			_control = control;

			control.SetHighlighting((SupportedLanguage == SupportedLanguage.CSharp) ? "C#" : "VBNET");
			control.ShowEOLMarkers = false;
			control.ShowInvalidLines = false;

			HostCallbackImplementation.Register(this);
			CodeCompletionKeyHandler.Attach(this, control);
			ToolTipProvider.Attach(this, control);

			ProjectContentRegistry = new ProjectContentRegistry(); // Default .NET 2.0 registry

			// Persistence lets SharpDevelop.Dom create a cache file on disk so that
			// future starts are faster.
			// It also caches XML documentation files in an on-disk hash table, thus
			// reducing memory usage.
			try
			{
				if (Settings.Default.CacheFiles)
				{
					var persistencePath = Path.Combine(Path.GetTempPath(), ReflexilPersistence);
					var persistenceCheck = Path.Combine(persistencePath, ReflexilPersistenceCheck);

					Directory.CreateDirectory(persistencePath); // Check write/access to directory
					File.WriteAllText(persistenceCheck, @"Using cache!"); // Check write file rights
					File.ReadAllText(persistenceCheck); // Check read file rights

					ProjectContentRegistry.ActivatePersistence(persistencePath);
				}
			}
				// ReSharper disable once EmptyGeneralCatchClause
			catch (Exception)
			{
				// don't use cache file
			}

			ProjectContent = new DefaultProjectContent {Language = LanguageProperties};
			ParseInformation = new ParseInformation(new DefaultCompilationUnit(ProjectContent));
		}