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