/// <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.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, ScaleHelper.Scale(14));
            sci.SetMarginTypeN(1, 1);
            sci.SetMarginMaskN(1, 0);
            sci.SetMarginTypeN(2, 0);
            sci.SetMarginMaskN(2, -33554432 | 1 << 2);
            sci.SetMultiSelectionTyping(true);
            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.SetXCaretPolicy((Int32)(ScintillaNet.Enums.CaretPolicy.Jumps | ScintillaNet.Enums.CaretPolicy.Even), 30);
            sci.SetYCaretPolicy((Int32)(ScintillaNet.Enums.CaretPolicy.Jumps | ScintillaNet.Enums.CaretPolicy.Even), 2);
            sci.ScrollWidthTracking = (Globals.Settings.ScrollWidth == 3000);
            sci.CodePage            = SelectCodePage(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);
        }