public SourceEditorBuffer() : base(new TextTagTable()) { markup = new TextTag("breakpoint"); markup.Background = "yellow"; TagTable.Add(markup); complete_ahead = new TextTag("complete_ahead"); complete_ahead.Foreground = "grey"; TagTable.Add(complete_ahead); compilation_error = new TextTag("compilation_error"); compilation_error.Underline = Pango.Underline.Error; TagTable.Add(compilation_error); complete_end = CreateMark(null, StartIter, true); highlightLineTag = new TextTag("highlightLine"); highlightLineTag.Background = "lightgrey"; TagTable.Add(highlightLineTag); MaxUndoLevels = 1000; base.InsertText += OnInsertText; base.DeleteRange += onDeleteRangeAfter; base.DeleteRange += onDeleteRangeBefore; }
private void SetupTags() { TextTag tag = new TextTag("category"); tag.Weight = Pango.Weight.Bold; tag.Scale = 1.5; tag.Background = "#ddd"; tag.BackgroundFullHeight = true; TagTable.Add(tag); tag = new TextTag("name"); tag.Weight = Pango.Weight.Bold; tag.Scale = 1.3; tag.LeftMargin = 15; tag.PixelsAboveLines = 5; tag.PixelsBelowLines = 5; TagTable.Add(tag); tag = new TextTag("author"); tag.LeftMargin = 15; tag.PixelsBelowLines = 5; TagTable.Add(tag); tag = new TextTag("description"); tag.Style = Pango.Style.Italic; tag.LeftMargin = 15; TagTable.Add(tag); tag = new TextTag("spacer"); tag.Scale = 0.25; TagTable.Add(tag); }
private void AddTags() { foreach (Monotalk.SourceView.Style s in config.styles) { Gtk.TextTag tag = new TextTag(s.path); tag.Foreground = s.color; //tag.Weight = Convert.ToInt32 (s.weight); TagTable.Add(tag); } }
public void EmitEndLink() { var link = openLinks.Pop(); var tag = new Gtk.TextTag(null); tag.Underline = Pango.Underline.Single; tag.ForegroundGdk = Toolkit.CurrentEngine.Defaults.FallbackLinkColor.ToGtkValue(); TagTable.Add(tag); ApplyTag(tag, GetIterAtMark(link.StartMark), EndIter); Links[tag] = link; }
// Add a tag at the specified tag path public ImageTag AddTagAtPath(string path, ImageTagTypes type = ImageTagTypes.Regular) { // If tag already exists, only update type if (ContainsTag(path)) { ChangeTagType(path, type); return(TagTable[path]); } // Start at root tag ImageTag tag = RootTag; // Navigate to parent tag String[] tagNames = path.Split(':'); foreach (String tagName in tagNames.Take(tagNames.Length - 1)) { ImageTag child = tag.Children.Find(t => t.Name == tagName); if (child == null) { // Tag along path not found, display warning message string errorMessage = $"Tag matching path [" + ((tag.Type == ImageTagTypes.Root) ? "" : $"{tag.Path}:") + $"{tagName}] not found"; Log.WriteLine(errorMessage, MessageType.Warning); // Create the missing tag child = new ImageTag(tagName, tag); Log.WriteLine($"Created tag [{child.Path}]"); // Add the tag to the tag table TagTable.Add(child.Path, child); Log.WriteLine($"Created tag table entry for tag [{child.Path}]"); } tag = child; } // Create leaf tag under parent tag ImageTag leaf = new ImageTag(tagNames.Last(), tag, type); Log.WriteLine($"Created leaf tag [{leaf.Path}] with parent [{leaf.Parent.Path}]"); // Add new tag to tag table TagTable.Add(path, leaf); Log.WriteLine($"Created tag table entry for tag [{leaf.Path}]"); // Return newly created tag return(leaf); }
public void EmitText(FormattedText markup) { var iterEnd = EndIter; var textmark = CreateMark(null, iterEnd, true); Insert(ref iterEnd, markup.Text); foreach (var attr in markup.Attributes) { var iterEndAttr = GetIterAtMark(textmark); iterEndAttr.ForwardChars(attr.StartIndex); var attrStart = CreateMark(null, iterEndAttr, true); iterEndAttr.ForwardChars(attr.Count); var tag = new Gtk.TextTag(null); if (attr is BackgroundTextAttribute) { var xa = (BackgroundTextAttribute)attr; tag.BackgroundGdk = xa.Color.ToGtkValue(); } else if (attr is ColorTextAttribute) { var xa = (ColorTextAttribute)attr; tag.ForegroundGdk = xa.Color.ToGtkValue(); } else if (attr is FontWeightTextAttribute) { var xa = (FontWeightTextAttribute)attr; tag.Weight = (Pango.Weight)(int) xa.Weight; } else if (attr is FontStyleTextAttribute) { var xa = (FontStyleTextAttribute)attr; tag.Style = (Pango.Style)(int) xa.Style; } else if (attr is UnderlineTextAttribute) { var xa = (UnderlineTextAttribute)attr; tag.Underline = xa.Underline ? Pango.Underline.Single : Pango.Underline.None; } else if (attr is StrikethroughTextAttribute) { var xa = (StrikethroughTextAttribute)attr; tag.Strikethrough = xa.Strikethrough; } else if (attr is FontTextAttribute) { var xa = (FontTextAttribute)attr; tag.FontDesc = (Pango.FontDescription)Toolkit.GetBackend(xa.Font); } else if (attr is LinkTextAttribute) { var xa = (LinkTextAttribute)attr; Uri uri = xa.Target; if (uri == null) { Uri.TryCreate(markup.Text.Substring(xa.StartIndex, xa.Count), UriKind.RelativeOrAbsolute, out uri); } var link = new Link { Href = uri }; tag.Underline = Pango.Underline.Single; tag.ForegroundGdk = Toolkit.CurrentEngine.Defaults.FallbackLinkColor.ToGtkValue(); Links [tag] = link; } TagTable.Add(tag); ApplyTag(tag, GetIterAtMark(attrStart), iterEndAttr); DeleteMark(attrStart); } DeleteMark(textmark); }