public static void CreatMenu(textEditor fctb, ImageList imgList) { //create autocomplete popup menu popupMenu = new AutocompleteMenu(fctb); CurrentTB = fctb; popupMenu.Items.ImageList = imgList; popupMenu.Opening += new EventHandler <System.ComponentModel.CancelEventArgs>(popupMenu_Opening); BuildAutocompleteMenu(); }
public virtual void AutoIndentNeeded(object sender, AutoIndentEventArgs args) { textEditor tb = (sender as textEditor); Language language = tb.Language; switch (language) { case Language.CSharp: CSharpAutoIndentNeeded(sender, args); break; default: break; } }
public AutocompleteMenu(textEditor tb) { // create a new popup and add the list view to it AutoClose = false; AutoSize = false; Margin = Padding.Empty; Padding = Padding.Empty; listView = new AutocompleteListView(tb); host = new ToolStripControlHost(listView); host.Margin = new Padding(1, 1, 1, 1); host.Padding = Padding.Empty; host.AutoSize = false; host.AutoToolTip = false; CalcSize(); base.Items.Add(host); listView.Parent = this; SearchPattern = @"[\w\.]"; MinFragmentLength = 2; }
internal AutocompleteListView(textEditor tb) { this.Width = 210; SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true); base.Font = new Font(FontFamily.GenericSansSerif, 9); visibleItems = new List <AutocompleteItem>(); itemHeight = Font.Height + 2; VerticalScroll.SmallChange = itemHeight; this.BackColor = Color.Transparent; //Color.FromArgb(255, 255, 17, 18); BorderStyle = BorderStyle.None; MaximumSize = new Size(Size.Width, 180); toolTip.ShowAlways = false; AppearInterval = 500; timer.Tick += new EventHandler(timer_Tick); this.tb = tb; tb.KeyDown += new KeyEventHandler(tb_KeyDown); tb.SelectionChanged += new EventHandler(tb_SelectionChanged); tb.KeyPressed += new KeyPressEventHandler(tb_KeyPressed); Form form = tb.FindForm(); if (form != null) { form.LocationChanged += (o, e) => Menu.Close(); form.ResizeBegin += (o, e) => Menu.Close(); form.FormClosing += (o, e) => Menu.Close(); form.LostFocus += (o, e) => Menu.Close(); } tb.LostFocus += (o, e) => { if (!Menu.Focused) { Menu.Close(); } }; tb.Scroll += (o, e) => Menu.Close(); }
/// <summary> /// Shows VisualMarker /// Call this method in Draw method, when you need to show VisualMarker for your style /// </summary> protected virtual void AddVisualMarker(textEditor tb, StyleVisualMarker marker) { tb.AddVisualMarker(marker); }
public ReplaceForm(textEditor editor) { InitializeComponent(); this.tb = editor; }
/// <summary> /// Constructor /// </summary> public Range(textEditor tb, Place start, Place end) : this(tb) { this.start = start; this.end = end; }
/// <summary> /// Constructor /// </summary> public Range(textEditor tb, int iStartChar, int iStartLine, int iEndChar, int iEndLine) : this(tb) { start = new Place(iStartChar, iStartLine); end = new Place(iEndChar, iEndLine); }
/// <summary> /// Constructor /// </summary> public Range(textEditor tb) { this.tb = tb; }
public string GetHtml(Range r) { this.tb = r.tb; Dictionary <StyleIndex, object> styles = new Dictionary <StyleIndex, object>(); StringBuilder sb = new StringBuilder(); StringBuilder tempSB = new StringBuilder(); StyleIndex currentStyleId = StyleIndex.None; r.Normalize(); int currentLine = r.Start.iLine; styles[currentStyleId] = null; // if (UseOriginalFont) { sb.AppendFormat("<font style=\"font-family: {0}, monospace; font-size: {1}px; line-height: {2}px;\">", r.tb.Font.Name, r.tb.CharHeight - r.tb.LineInterval, r.tb.CharHeight); } // if (IncludeLineNumbers) { tempSB.AppendFormat("<span class=lineNumber>{0}</span> ", currentLine + 1); } // bool hasNonSpace = false; foreach (Place p in r) { Char c = r.tb[p.iLine][p.iChar]; if (c.style != currentStyleId) { Flush(sb, tempSB, currentStyleId); currentStyleId = c.style; styles[currentStyleId] = null; } if (p.iLine != currentLine) { for (int i = currentLine; i < p.iLine; i++) { tempSB.AppendLine(UseBr ? "<br>" : ""); if (IncludeLineNumbers) { tempSB.AppendFormat("<span class=lineNumber>{0}</span> ", i + 2); } } currentLine = p.iLine; hasNonSpace = false; } switch (c.c) { case ' ': if ((hasNonSpace || !UseForwardNbsp) && !UseNbsp) { goto default; } tempSB.Append(" "); break; case '<': tempSB.Append("<"); break; case '>': tempSB.Append(">"); break; case '&': tempSB.Append("&"); break; default: hasNonSpace = true; tempSB.Append(c.c); break; } } Flush(sb, tempSB, currentStyleId); if (UseOriginalFont) { sb.AppendLine("</font>"); } //build styles if (UseStyleTag) { tempSB.Length = 0; tempSB.AppendLine("<style type=\"text/css\">"); foreach (var styleId in styles.Keys) { tempSB.AppendFormat(".fctb{0}{{ {1} }}\r\n", GetStyleName(styleId), GetCss(styleId)); } tempSB.AppendLine("</style>"); sb.Insert(0, tempSB.ToString()); } if (IncludeLineNumbers) { sb.Insert(0, LineNumbersCSS); } return(sb.ToString()); }
public FindForm(textEditor te) { InitializeComponent(); this.tb = te; }