Ejemplo n.º 1
0
        public static ScintillaControl CreateControl( )
        {
            ScintillaControl sci = new ScintillaControl();
            sci.AutoCSeparator = 32;
            sci.AutoCTypeSeparator = 63;
            sci.IsAutoCGetAutoHide = true;
            sci.IsAutoCGetCancelAtStart = false;
            sci.IsAutoCGetChooseSingle = false;
            sci.IsAutoCGetDropRestOfWord = false;
            sci.IsAutoCGetIgnoreCase = false;
            sci.ControlCharSymbol = 0;
            sci.CurrentPos = 0;
            sci.CursorType = -1;
            sci.Dock = System.Windows.Forms.DockStyle.Fill;
            sci.DocPointer = 187541976;
            sci.EndAtLastLine = 1;
            sci.EdgeColumn = 0;
            sci.EdgeMode = 0;
            sci.IsHScrollBar = true;
            sci.IsMouseDownCaptures = true;
            sci.IsBufferedDraw = true;
            sci.IsOvertype = false;
            sci.IsReadOnly = false;
            sci.IsUndoCollection = true;
            sci.IsVScrollBar = true;
            sci.IsUsePalette = true;
            sci.IsTwoPhaseDraw = true;
            sci.LayoutCache = 1;
            sci.Lexer = 3;
            sci.Location = new System.Drawing.Point(0, 0);
            sci.MarginLeft = 0;
            sci.MarginRight = 0;
            sci.ModEventMask = (Int32)ScintillaNet.Enums.ModificationFlags.InsertText | (Int32)ScintillaNet.Enums.ModificationFlags.DeleteText | (Int32)ScintillaNet.Enums.ModificationFlags.RedoPerformed | (Int32)ScintillaNet.Enums.ModificationFlags.UndoPerformed;
            sci.MouseDwellTime = ScintillaControl.MAXDWELLTIME;
            sci.Name = "sci";
            sci.PasteConvertEndings = false;
            sci.PrintColourMode = (Int32)ScintillaNet.Enums.PrintOption.Normal;
            sci.PrintWrapMode = (Int32)ScintillaNet.Enums.Wrap.Word;
            sci.PrintMagnification = 0;
            sci.SearchFlags = 0;
            sci.SelectionEnd = 0;
            sci.SelectionMode = 0;
            sci.SelectionStart = 0;
            sci.SmartIndentType = ScintillaNet.Enums.SmartIndent.CPP;
            sci.Status = 0;
            sci.StyleBits = 7;
            sci.TabIndex = 0;
            sci.TargetEnd = 0;
            sci.TargetStart = 0;
            sci.WrapStartIndent = 4;
            sci.WrapVisualFlagsLocation = (Int32)ScintillaNet.Enums.WrapVisualLocation.EndByText;
            sci.WrapVisualFlags = (Int32)ScintillaNet.Enums.WrapVisualFlag.End;
            sci.XOffset = 0;
            sci.ZoomLevel = 0;
            sci.UsePopUp(true);
            sci.SetMarginTypeN(0, 1);
            sci.SetMarginMaskN(0, 0);
            sci.SetYCaretPolicy((Int32)(ScintillaNet.Enums.CaretPolicy.Jumps | ScintillaNet.Enums.CaretPolicy.Even), 0);

            /*try
            {
                sci.Encoding = Encoding.GetEncoding((Int32)MainForm.Settings.DefaultCodePage);
            }
            catch(Exception error)
            {
                sci.Encoding = Encoding.GetEncoding(65001);
            }*/

            sci.Encoding = Encoding.UTF8;
            sci.EmptyUndoBuffer();
            ApplySciSettings(sci);
            return sci;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new editor control for the document 
 /// </summary>
 public static ScintillaControl CreateControl(String file, String text, Int32 codepage)
 {
     ScintillaControl sci = new ScintillaControl();
     sci.AutoCSeparator = 32;
     sci.AutoCTypeSeparator = 63;
     sci.IsAutoCGetAutoHide = true;
     sci.IsAutoCGetCancelAtStart = false;
     sci.IsAutoCGetChooseSingle = false;
     sci.IsAutoCGetDropRestOfWord = false;
     sci.IsAutoCGetIgnoreCase = false;
     sci.ControlCharSymbol = 0;
     sci.CurrentPos = 0;
     sci.CursorType = -1;
     sci.Dock = System.Windows.Forms.DockStyle.Fill;
     sci.DocPointer = 187541976;
     sci.EndAtLastLine = 1;
     sci.EdgeColumn = 0;
     sci.EdgeMode = 0;
     sci.IsHScrollBar = true;
     sci.IsMouseDownCaptures = true;
     sci.IsBufferedDraw = true;
     sci.IsOvertype = false;
     sci.IsReadOnly = false;
     sci.IsUndoCollection = true;
     sci.IsVScrollBar = true;
     sci.IsUsePalette = true;
     sci.IsTwoPhaseDraw = true;
     sci.LayoutCache = 1;
     sci.Lexer = 3;
     sci.Location = new System.Drawing.Point(0, 0);
     sci.MarginLeft = 5;
     sci.MarginRight = 5;
     sci.ModEventMask = (Int32)ScintillaNet.Enums.ModificationFlags.InsertText | (Int32)ScintillaNet.Enums.ModificationFlags.DeleteText | (Int32)ScintillaNet.Enums.ModificationFlags.RedoPerformed | (Int32)ScintillaNet.Enums.ModificationFlags.UndoPerformed;
     sci.MouseDwellTime = ScintillaControl.MAXDWELLTIME;
     sci.Name = "sci";
     sci.PasteConvertEndings = false;
     sci.PrintColourMode = (Int32)ScintillaNet.Enums.PrintOption.Normal;
     sci.PrintWrapMode = (Int32)ScintillaNet.Enums.Wrap.Word;
     sci.PrintMagnification = 0;
     sci.SearchFlags = 0;
     sci.SelectionEnd = 0;
     sci.SelectionMode = 0;
     sci.SelectionStart = 0;
     sci.SmartIndentType = ScintillaNet.Enums.SmartIndent.CPP;
     sci.Status = 0;
     sci.StyleBits = 7;
     sci.TabIndex = 0;
     sci.TargetEnd = 0;
     sci.TargetStart = 0;
     sci.WrapStartIndent = Globals.Settings.IndentSize;
     sci.WrapVisualFlagsLocation = (Int32)ScintillaNet.Enums.WrapVisualLocation.EndByText;
     sci.WrapVisualFlags = (Int32)ScintillaNet.Enums.WrapVisualFlag.End;
     sci.XOffset = 0;
     sci.ZoomLevel = 0;
     sci.UsePopUp(false);
     sci.SetMarginTypeN(0, 0);
     sci.SetMarginWidthN(0, 14);
     sci.SetMarginTypeN(1, 1);
     sci.SetMarginMaskN(1, 0);
     sci.SetMarginTypeN(2, 0);
     sci.SetMarginMaskN(2, -33554432 | 1 << 2);
     sci.MarginSensitiveN(2, true);
     sci.MarkerDefinePixmap(0, XpmBookmark);
     sci.SetMarginMaskN(0, MarkerManager.MARKERS);
     sci.MarkerDefine(2, ScintillaNet.Enums.MarkerSymbol.Fullrect);
     sci.MarkerDefine((Int32)ScintillaNet.Enums.MarkerOutline.Folder, ScintillaNet.Enums.MarkerSymbol.BoxPlus);
     sci.MarkerDefine((Int32)ScintillaNet.Enums.MarkerOutline.FolderOpen, ScintillaNet.Enums.MarkerSymbol.BoxMinus);
     sci.MarkerDefine((Int32)ScintillaNet.Enums.MarkerOutline.FolderSub, ScintillaNet.Enums.MarkerSymbol.VLine);
     sci.MarkerDefine((Int32)ScintillaNet.Enums.MarkerOutline.FolderTail, ScintillaNet.Enums.MarkerSymbol.LCorner);
     sci.MarkerDefine((Int32)ScintillaNet.Enums.MarkerOutline.FolderEnd, ScintillaNet.Enums.MarkerSymbol.BoxPlusConnected);
     sci.MarkerDefine((Int32)ScintillaNet.Enums.MarkerOutline.FolderOpenMid, ScintillaNet.Enums.MarkerSymbol.BoxMinusConnected);
     sci.MarkerDefine((Int32)ScintillaNet.Enums.MarkerOutline.FolderMidTail, ScintillaNet.Enums.MarkerSymbol.TCorner);
     sci.SetYCaretPolicy((Int32)(ScintillaNet.Enums.CaretPolicy.Jumps | ScintillaNet.Enums.CaretPolicy.Even), 0);
     sci.SetXCaretPolicy((Int32)(ScintillaNet.Enums.CaretPolicy.Even), 0);
     sci.CodePage = SelectCodePage(codepage);
     sci.Encoding = Encoding.GetEncoding(codepage);
     sci.SaveBOM = (sci.CodePage == 65001) && Globals.Settings.SaveUnicodeWithBOM;
     sci.Text = text; sci.FileName = file; // Set text and save file name
     sci.Modified += new ModifiedHandler(Globals.MainForm.OnScintillaControlModified);
     sci.MarginClick += new MarginClickHandler(Globals.MainForm.OnScintillaControlMarginClick);
     sci.UpdateUI += new UpdateUIHandler(Globals.MainForm.OnScintillaControlUpdateControl);
     sci.URIDropped += new URIDroppedHandler(Globals.MainForm.OnScintillaControlDropFiles);
     sci.ModifyAttemptRO += new ModifyAttemptROHandler(Globals.MainForm.OnScintillaControlModifyRO);
     String untitledFileStart = TextHelper.GetString("Info.UntitledFileStart");
     if (!file.StartsWith(untitledFileStart)) sci.IsReadOnly = FileHelper.FileIsReadOnly(file);
     sci.SetFoldFlags((Int32)Globals.Settings.FoldFlags);
     sci.EmptyUndoBuffer(); ApplySciSettings(sci);
     UITools.Manager.ListenTo(sci);
     return sci;
 }
Ejemplo n.º 3
0
		/**
		* Creates a new editor control for the document 
		*/
		public ScintillaControl CreateNewSciControl(string file, string text, int codepage)
		{
			ScintillaControl sciControl = new ScintillaControl();
			sciControl.AutoCSeparator = 32;
			sciControl.AutoCTypeSeparator = 63;
			sciControl.IsAutoCGetAutoHide = true;
			sciControl.IsAutoCGetCancelAtStart = false;
			sciControl.IsAutoCGetChooseSingle = false;
			sciControl.IsAutoCGetDropRestOfWord = false;
			sciControl.IsAutoCGetIgnoreCase = false;
			sciControl.ControlCharSymbol = 0;
			sciControl.CurrentPos = 0;
			sciControl.CursorType = -1;
			sciControl.Dock = System.Windows.Forms.DockStyle.Fill;
			sciControl.DocPointer = 187541976;
			sciControl.EndAtLastLine = 1;
			sciControl.EdgeColumn = 0;
			sciControl.EdgeMode = 0;
			sciControl.IsHScrollBar = true;
			sciControl.IsMouseDownCaptures = true;
			sciControl.IsBufferedDraw = true;
			sciControl.IsOvertype = false;
			sciControl.IsReadOnly = false;
			sciControl.IsUndoCollection = true;
			sciControl.IsVScrollBar = true;
			sciControl.IsUsePalette = true;
			sciControl.IsTwoPhaseDraw = true;
			sciControl.LayoutCache = 1;
			sciControl.Lexer = 3;
			sciControl.Location = new System.Drawing.Point(0, 0);
			sciControl.MarginLeft = 5;
			sciControl.MarginRight = 5;
			sciControl.ModEventMask = this.sciEventMask;
			sciControl.MouseDwellTime = ScintillaControl.MAXDWELLTIME;
			sciControl.Name = "sciControl";
			sciControl.PrintMagnification = 0;
			sciControl.PrintColourMode = (int)ScintillaNet.Enums.PrintOption.Normal;
			sciControl.PrintWrapMode = (int)ScintillaNet.Enums.Wrap.Word;
			sciControl.SearchFlags = 0;
			sciControl.SelectionEnd = 0;
			sciControl.SelectionMode = 0;
			sciControl.SelectionStart = 0;
			sciControl.Size = new System.Drawing.Size(100, 100);
			sciControl.SmartIndentType = ScintillaNet.Enums.SmartIndent.CPP;
			sciControl.Status = 0;
			sciControl.StyleBits = 7;
			sciControl.TabIndex = 0;
			sciControl.TargetEnd = 0;
			sciControl.TargetStart = 0;
			sciControl.WrapStartIndent = 4;
			sciControl.WrapVisualFlagsLocation = (int)ScintillaNet.Enums.WrapVisualLocation.EndByText;
			sciControl.WrapVisualFlags = (int)ScintillaNet.Enums.WrapVisualFlag.End;
			sciControl.XOffset = 0;
			sciControl.ZoomLevel = 0;
			sciControl.UsePopUp(false);
			sciControl.SetMarginTypeN(0, 0);
			sciControl.SetMarginWidthN(0, 14);
			sciControl.SetMarginTypeN(1, 1);
			sciControl.SetMarginMaskN(1, 0);
			sciControl.SetMarginTypeN(2, 0);
			sciControl.SetMarginMaskN(2, -33554432);
			sciControl.MarginSensitiveN(2, true);
			sciControl.MarkerDefinePixmap(0, this.xpmBookmark);
			sciControl.MarkerSetBack((int)ScintillaNet.Enums.MarkerOutline.Folder, 0x777777);
			sciControl.MarkerSetFore((int)ScintillaNet.Enums.MarkerOutline.Folder, 0xFFFFFF);
			sciControl.MarkerSetBack((int)ScintillaNet.Enums.MarkerOutline.FolderOpen, 0x777777);
			sciControl.MarkerSetFore((int)ScintillaNet.Enums.MarkerOutline.FolderOpen, 0xFFFFFF);
			sciControl.MarkerSetBack((int)ScintillaNet.Enums.MarkerOutline.FolderSub, 0x777777);
			sciControl.MarkerSetFore((int)ScintillaNet.Enums.MarkerOutline.FolderSub, 0xFFFFFF);
			sciControl.MarkerSetBack((int)ScintillaNet.Enums.MarkerOutline.FolderTail, 0x777777);
			sciControl.MarkerSetFore((int)ScintillaNet.Enums.MarkerOutline.FolderTail, 0xFFFFFF);
			sciControl.MarkerSetBack((int)ScintillaNet.Enums.MarkerOutline.FolderEnd, 0x777777);
			sciControl.MarkerSetFore((int)ScintillaNet.Enums.MarkerOutline.FolderEnd, 0xFFFFFF);
			sciControl.MarkerSetBack((int)ScintillaNet.Enums.MarkerOutline.FolderOpenMid, 0x777777);
			sciControl.MarkerSetFore((int)ScintillaNet.Enums.MarkerOutline.FolderOpenMid, 0xFFFFFF);
			sciControl.MarkerSetBack((int)ScintillaNet.Enums.MarkerOutline.FolderMidTail, 0x777777);
			sciControl.MarkerSetFore((int)ScintillaNet.Enums.MarkerOutline.FolderMidTail, 0xFFFFFF);
			sciControl.MarkerDefine((int)ScintillaNet.Enums.MarkerOutline.Folder, ScintillaNet.Enums.MarkerSymbol.BoxPlus);
			sciControl.MarkerDefine((int)ScintillaNet.Enums.MarkerOutline.FolderOpen, ScintillaNet.Enums.MarkerSymbol.BoxMinus);
			sciControl.MarkerDefine((int)ScintillaNet.Enums.MarkerOutline.FolderSub, ScintillaNet.Enums.MarkerSymbol.VLine);
			sciControl.MarkerDefine((int)ScintillaNet.Enums.MarkerOutline.FolderTail, ScintillaNet.Enums. MarkerSymbol.LCorner);
			sciControl.MarkerDefine((int)ScintillaNet.Enums.MarkerOutline.FolderEnd, ScintillaNet.Enums.MarkerSymbol.BoxPlusConnected);
			sciControl.MarkerDefine((int)ScintillaNet.Enums.MarkerOutline.FolderOpenMid, ScintillaNet.Enums.MarkerSymbol.BoxMinusConnected);
			sciControl.MarkerDefine((int)ScintillaNet.Enums.MarkerOutline.FolderMidTail, ScintillaNet.Enums.MarkerSymbol.TCorner);
			sciControl.MarkerSetBack((int)ScintillaNet.Enums.MarkerSymbol.Background, SharedUtils.ResolveColor(this.settings.GetValue("FlashDevelop.BookmarkColor")));
			sciControl.CodePage = this.SelectCodePage(codepage);
			sciControl.Encoding = Encoding.GetEncoding(codepage);
			sciControl.Text = SharedUtils.ConvertText(text, codepage, sciControl.CodePage);
			sciControl.Tag = file;
			sciControl.ContextMenu = this.editorMenu;
			sciControl.MarginClick += new MarginClickHandler(this.OnScintillaControlMarginClick);
			sciControl.Modified += new ModifiedHandler(this.OnScintillaControlModified);
			sciControl.UpdateUI += new UpdateUIHandler(this.OnScintillaControlUpdateControl);
			sciControl.URIDropped += new URIDroppedHandler(this.OnScintillaControlDropFiles);
			sciControl.ModifyAttemptRO += new ModifyAttemptROHandler(this.OnScintillaControlModifyRO);
			if (!file.StartsWith("Untitled")) sciControl.IsReadOnly = FileSystem.IsReadOnly(file);
			sciControl.SetFoldFlags(this.settings.GetInt("FlashDevelop.FoldFlags"));
			sciControl.ConfigurationLanguage = this.SciConfig.GetLanguageFromFile(file);
			this.CheckActiveLanguageButton(sciControl.ConfigurationLanguage);
			this.ApplySciSettings(sciControl);
			sciControl.EmptyUndoBuffer();
			UITools.ListenTo(sciControl);
			try 
			{
				bool collapseAll = this.settings.GetBool("FlashDevelop.CollapseAllOnFileOpen");
				if (collapseAll) sciControl.CollapseAllFolds();
			} 
			catch (Exception ex)
			{
				ErrorHandler.ShowError("Error while handling collapse all on file open.", ex);
			}
			return sciControl;
		}
Ejemplo n.º 4
0
 public static void ApplySciSettings(ScintillaControl sci, Boolean hardUpdate)
 {
     try
     {
         sci.CaretPeriod = Globals.Settings.CaretPeriod;
         sci.CaretWidth = Globals.Settings.CaretWidth;
         sci.EOLMode = LineEndDetector.DetectNewLineMarker(sci.Text, (Int32)Globals.Settings.EOLMode);
         sci.IsBraceMatching = Globals.Settings.BraceMatchingEnabled;
         sci.UseHighlightGuides = !Globals.Settings.HighlightGuide;
         sci.Indent = Globals.Settings.IndentSize;
         sci.SmartIndentType = Globals.Settings.SmartIndentType;
         sci.IsBackSpaceUnIndents = Globals.Settings.BackSpaceUnIndents;
         sci.IsCaretLineVisible = Globals.Settings.CaretLineVisible;
         sci.IsIndentationGuides = Globals.Settings.ViewIndentationGuides;
         sci.IndentView = Globals.Settings.IndentView;
         sci.IsTabIndents = Globals.Settings.TabIndents;
         sci.IsUseTabs = Globals.Settings.UseTabs;
         sci.IsViewEOL = Globals.Settings.ViewEOL;
         sci.ScrollWidth = Globals.Settings.ScrollWidth;
         sci.TabWidth = Globals.Settings.TabWidth;
         sci.ViewWS = Convert.ToInt32(Globals.Settings.ViewWhitespace);
         sci.WrapMode = Convert.ToInt32(Globals.Settings.WrapText);
         sci.SetProperty("fold", Convert.ToInt32(Globals.Settings.UseFolding).ToString());
         sci.SetProperty("fold.comment", Convert.ToInt32(Globals.Settings.FoldComment).ToString());
         sci.SetProperty("fold.compact", Convert.ToInt32(Globals.Settings.FoldCompact).ToString());
         sci.SetProperty("fold.preprocessor", Convert.ToInt32(Globals.Settings.FoldPreprocessor).ToString());
         sci.SetProperty("fold.at.else", Convert.ToInt32(Globals.Settings.FoldAtElse).ToString());
         sci.SetProperty("fold.html", Convert.ToInt32(Globals.Settings.FoldHtml).ToString());
         sci.SetProperty("lexer.cpp.track.preprocessor", "0");
         sci.SetVirtualSpaceOptions((Int32)Globals.Settings.VirtualSpaceMode);
         sci.SetFoldFlags((Int32)Globals.Settings.FoldFlags);
         /**
         * Set if themes should colorize the first margin
         */
         Language language = SciConfig.GetLanguage(sci.ConfigurationLanguage);
         if (language != null && language.editorstyle != null)
         {
             Boolean colorizeMarkerBack = language.editorstyle.ColorizeMarkerBack;
             if (colorizeMarkerBack) sci.SetMarginTypeN(0, (Int32)MarginType.Fore);
             else sci.SetMarginTypeN(0, (Int32)MarginType.Symbol);
         }
         /**
         * Set correct line number margin width
         */
         Boolean viewLineNumbers = Globals.Settings.ViewLineNumbers;
         if (viewLineNumbers) sci.SetMarginWidthN(1, ScaleArea(sci, 36));
         else sci.SetMarginWidthN(1, 0);
         /**
         * Set correct bookmark margin width
         */
         Boolean viewBookmarks = Globals.Settings.ViewBookmarks;
         if (viewBookmarks) sci.SetMarginWidthN(0, ScaleArea(sci, 14));
         else sci.SetMarginWidthN(0, 0);
         /**
         * Set correct folding margin width
         */
         Boolean useFolding = Globals.Settings.UseFolding;
         if (!useFolding && !viewBookmarks && !viewLineNumbers) sci.SetMarginWidthN(2, 0);
         else if (useFolding) sci.SetMarginWidthN(2, ScaleArea(sci, 15));
         else sci.SetMarginWidthN(2, ScaleArea(sci, 2));
         /**
         * Adjust the print margin
         */
         sci.EdgeColumn = Globals.Settings.PrintMarginColumn;
         if (sci.EdgeColumn > 0) sci.EdgeMode = 1;
         else sci.EdgeMode = 0;
         /**
         * Add missing ignored keys
         */
         foreach (Keys keys in ShortcutManager.AllShortcuts)
         {
             if (keys != Keys.None && !sci.ContainsIgnoredKeys(keys))
             {
                 sci.AddIgnoredKeys(keys);
             }
         }
         if (hardUpdate)
         {
             String lang = sci.ConfigurationLanguage;
             sci.ConfigurationLanguage = lang;
         }
         sci.Colourise(0, -1);
         sci.Refresh();
     }
     catch (Exception ex)
     {
         ErrorManager.ShowError(ex);
     }
 }