// Inserts a piece of text into the buffer, giving it the usual // appearance of a hyperlink in a web browser: blue and underlined. // Additionally, attaches some data on the tag, to make it recognizable // as a link. void InsertLink (TextBuffer buffer, ref TextIter iter, string text, int page) { TextTag tag = new TextTag (null); tag.Foreground = "blue"; tag.Underline = Pango.Underline.Single; tag_pages [tag] = page; buffer.TagTable.Add (tag); buffer.InsertWithTags (ref iter, text, tag); }
public DemoMain () { SetupDefaultIcon (); window = new Gtk.Window ("Gtk# Code Demos"); window.SetDefaultSize (600, 400); window.DeleteEvent += new DeleteEventHandler (WindowDelete); HBox hbox = new HBox (false, 0); window.Add (hbox); treeView = CreateTree (); hbox.PackStart (treeView, false, false, 0); Notebook notebook = new Notebook (); hbox.PackStart (notebook, true, true, 0); notebook.AppendPage (CreateText (infoBuffer, false), new Label ("_Info")); TextTag heading = new TextTag ("heading"); heading.Font = "Sans 18"; infoBuffer.TagTable.Add (heading); notebook.AppendPage (CreateText (sourceBuffer, true), new Label ("_Source")); window.ShowAll (); }
/// <summary> /// Constructs a new MonospacedTextViewControl wrapper. /// </summary> /// <param name="widget"> /// The TextView widget to be wrapped. /// </param> public MonospacedTextViewControl(Widget widget) : base(widget) { TextTag tag = new TextTag("Monospaced"); tag.Family = "Monospace"; buffer.TagTable.Add(tag); }
public ProgressDialog (MonoDevelop.Components.Window parent, bool allowCancel, bool showDetails) { MonoDevelop.Components.IdeTheme.ApplyTheme (this); this.Build (); this.Title = BrandingService.ApplicationName; HasSeparator = false; ActionArea.Hide (); DefaultHeight = 5; TransientFor = parent; btnCancel.Visible = allowCancel; expander.Visible = showDetails; buffer = detailsTextView.Buffer; detailsTextView.Editable = false; bold = new TextTag ("bold"); bold.Weight = Pango.Weight.Bold; buffer.TagTable.Add (bold); tag = new TextTag ("0"); tag.Indent = 10; buffer.TagTable.Add (tag); tags.Add (tag); }
public LogView () { buffer = new Gtk.TextBuffer (new Gtk.TextTagTable ()); textEditorControl = new Gtk.TextView (buffer); textEditorControl.Editable = false; ShadowType = ShadowType.None; Add (textEditorControl); bold = new TextTag ("bold"); bold.Weight = Pango.Weight.Bold; buffer.TagTable.Add (bold); errorTag = new TextTag ("error"); errorTag.Foreground = "red"; errorTag.Weight = Pango.Weight.Bold; buffer.TagTable.Add (errorTag); consoleLogTag = new TextTag ("consoleLog"); consoleLogTag.Foreground = "darkgrey"; buffer.TagTable.Add (consoleLogTag); tag = new TextTag ("0"); tag.LeftMargin = 10; buffer.TagTable.Add (tag); tags.Add (tag); endMark = buffer.CreateMark ("end-mark", buffer.EndIter, false); UpdateCustomFont (IdeApp.Preferences.CustomOutputPadFont); IdeApp.Preferences.CustomOutputPadFontChanged += HandleCustomFontChanged; outputDispatcher = new GLib.TimeoutHandler (outputDispatchHandler); }
void ApplyTag(string prefix, string variation, Gtk.TextIter start, Gtk.TextIter end, Action <Gtk.TextTag> apply) { var buffer = Control.Buffer; var tagName = prefix + variation; var tagsToRemove = new List <Gtk.TextTag>(); buffer.TagTable.Foreach(t => { if (t.Name != null && t.Name.StartsWith(prefix, StringComparison.Ordinal)) { tagsToRemove.Add(t); } }); foreach (var removeTag in tagsToRemove) { buffer.RemoveTag(removeTag, start, end); } var tag = buffer.TagTable.Lookup(tagName); if (tag == null) { tag = new Gtk.TextTag(tagName); apply(tag); buffer.TagTable.Add(tag); } buffer.ApplyTag(tag, start, end); }
private StatusLogPage() { m_TextView = new TextView(); m_TextView.Editable = false; ScrolledWindow swindow = new ScrolledWindow(); swindow.Add(m_TextView); this.PackStart(swindow, true, true, 0); swindow.ShowAll(); var tag = new TextTag("Error"); tag.Foreground = "darkred"; m_TextView.Buffer.TagTable.Add(tag); tag = new TextTag("Fatal"); tag.Foreground = "darkred"; m_TextView.Buffer.TagTable.Add(tag); tag = new TextTag("Warn"); tag.Foreground = "darkorange"; m_TextView.Buffer.TagTable.Add(tag); tag = new TextTag("Info"); tag.Foreground = "darkgreen"; m_TextView.Buffer.TagTable.Add(tag); tag = new TextTag("Debug"); tag.Foreground = "darkblue"; m_TextView.Buffer.TagTable.Add(tag); m_TextView.Buffer.CreateMark("end", m_TextView.Buffer.EndIter, false); LoggingService.AddLogger(this); }
// Fills the buffer with text and interspersed links. In any real // hypertext app, this method would parse a file to identify the links. void ShowPage (TextBuffer buffer, int page) { buffer.Text = ""; TextIter iter = buffer.StartIter; if (page == 1) { buffer.Insert (ref iter, "Some text to show that simple "); InsertLink (buffer, ref iter, "hypertext", 3); buffer.Insert (ref iter, " can easily be realized with "); InsertLink (buffer, ref iter, "tags", 2); buffer.Insert (ref iter, "."); } else if (page == 2) { buffer.Insert (ref iter, "A tag is an attribute that can be applied to some range of text. " + "For example, a tag might be called \"bold\" and make the text inside " + "the tag bold. However, the tag concept is more general than that; " + "tags don't have to affect appearance. They can instead affect the " + "behavior of mouse and key presses, \"lock\" a range of text so the " + "user can't edit it, or countless other things.\n"); InsertLink (buffer, ref iter, "Go back", 1); } else if (page == 3) { TextTag tag = buffer.TagTable.Lookup ("bold"); if (tag == null) { tag = new TextTag ("bold"); tag.Weight = Pango.Weight.Bold; buffer.TagTable.Add (tag); } buffer.InsertWithTags (ref iter, "hypertext:\n", tag); buffer.Insert (ref iter, "machine-readable text that is not sequential but is organized " + "so that related items of information are connected.\n"); InsertLink (buffer, ref iter, "Go back", 1); } }
public MainWindow() : base("MainWindow") { // Setup ui var textview = new TextView(); Add (textview); // Setup tag var tag = new TextTag ("helloworld-tag"); tag.Scale = Pango.Scale.XXLarge; tag.Style = Pango.Style.Italic; tag.Underline = Pango.Underline.Double; tag.Foreground = "blue"; tag.Background = "pink"; tag.Justification = Justification.Center; var buffer = textview.Buffer; buffer.TagTable.Add (tag); // Insert "Hello world!" into textview buffer var insertIter = buffer.StartIter; buffer.InsertWithTagsByName (ref insertIter, "Hello World!\n", "helloworld-tag"); buffer.Insert (ref insertIter, "Simple Hello World!"); ShowAll (); }
void ApplySelectionTag(string prefix, string variation, Action <Gtk.TextTag> apply) { var tagName = prefix + variation; Gtk.TextIter start, end; var buffer = Control.Buffer; if (buffer.GetSelectionBounds(out start, out end)) { // apply formatting to the selection ApplyTag(prefix, variation, start, end, apply); } else { // nothing selected, set insertion formatting buffer.TagTable.Foreach(t => { if (t.Name != null && t.Name != tagName && t.Name.StartsWith(prefix, StringComparison.Ordinal) && !removeTags.Contains(t)) { removeTags.Add(t); } }); insertTags.RemoveAll(removeTags.Contains); removeTags.RemoveAll(r => r.Name == tagName); var tag = buffer.TagTable.Lookup(tagName); if (tag == null) { tag = new Gtk.TextTag(tagName); apply(tag); buffer.TagTable.Add(tag); } insertTags.Add(tag); } }
public ProgressDialog (Window parent, bool allowCancel, bool showDetails) { this.Build (); HasSeparator = false; ActionArea.Hide (); DefaultHeight = 5; TransientFor = parent; btnCancel.Visible = allowCancel; expander.Visible = showDetails; buffer = detailsTextView.Buffer; detailsTextView.Editable = false; bold = new TextTag ("bold"); bold.Weight = Pango.Weight.Bold; buffer.TagTable.Add (bold); tag = new TextTag ("0"); tag.Indent = 10; buffer.TagTable.Add (tag); tags.Add (tag); }
public UtilMainWindow() : base(Gtk.WindowType.Toplevel) { this.Build(); GLib.ExceptionManager.UnhandledException += UnhandledException; this.WindowPosition = WindowPosition.Center; this.WidthRequest = 800; this.HeightRequest = 500; this.DeleteEvent += WindowClosed; ParserContext = ExecutionContext.CreateRootContext(new ToolScriptParser()); TextTag tag = new TextTag("command"); tag.Weight = Pango.Weight.Bold; tag.WeightSet = true; outputView.Buffer.TagTable.Add(tag); TextTag tagerror = new TextTag("error"); tagerror.Weight = Pango.Weight.Bold; // tagerror.WeightSet = true; tagerror.Font = "Courier Bold"; tagerror.Foreground = "#880000"; outputView.Buffer.TagTable.Add(tagerror); TextTag tagcode = new TextTag("code"); tagcode.Weight = Pango.Weight.Bold; tagcode.Font = "Courier Bold"; outputView.Buffer.TagTable.Add(tagcode); Instance = this; }
public override void Initialize () { // If a tag of this name already exists, don't install. if (Note.TagTable.Lookup ("monospace") == null) { tag = new FixedWidthTag (); Note.TagTable.Add (tag); } }
/// <summary> /// Adds a tag to a text buffer. /// </summary> public static void AddTag(this TextBuffer buff, string tagName, string foreground, string family, Pango.Style style) { TextTag tag = new TextTag(tagName); tag.Foreground = foreground; tag.Family = family; tag.Style = style; buff.TagTable.Add(tag); }
public override void Initialize () { // Only install Underline addin if it does not currently exist if (Note.TagTable.Lookup ("underline") == null) { tag = new UnderlineTag (); Note.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); } }
protected void ConnectTextTagTable (Gtk.TextTagTable table, Monotalk.SourceView.Style [] styles) { foreach (Monotalk.SourceView.Style s in styles) { Gtk.TextTag tag = new TextTag(s.path); tag.Foreground = s.color; table.Add ( tag ); } }
private void CreateTextTags(Gtk.TextBuffer tb) { table_text_tag = new Gtk.TextTagTable(); // Tag per text block - not style tag = new Gtk.TextTag("DemoTextSelection"); tag.WrapMode = Gtk.WrapMode.Char; tb.TagTable.Add(tag); return; }
public QueryWidget() { this.Build (); textviewEditor.ModifyFont(FontDescription.FromString("Monospace")); // Setup keyword format _tagKeyword = new TextTag("keyword"); _tagKeyword.Weight = Weight.Bold; _tagKeyword.Foreground = "#0000ff"; textviewEditor.Buffer.TagTable.Add(_tagKeyword); }
public TextTag[] GetToggledTags (bool toggled_on) { IntPtr raw_ret = gtk_text_iter_get_toggled_tags (ref this, toggled_on); if (raw_ret == IntPtr.Zero) return new TextTag [0]; GLib.SList list = new GLib.SList(raw_ret); TextTag[] result = new TextTag [list.Count]; for (int i = 0; i < list.Count; i++) result [i] = list [i] as TextTag; return result; }
/// <summary> /// Constructs a new MainTextViewControl object. /// </summary> /// <param name="widget"> /// The TextView widget to wrap. /// </param> public MainTextViewControl(Widget widget) : base(widget) { TextTag tag = new TextTag("Caption"); tag.Weight = Weight.Bold; buffer.TagTable.Add(tag); tag = new TextTag("Monospaced"); tag.Family = "Monospace"; buffer.TagTable.Add(tag); }
public void MakeHilightTag() { try { tag.BackgroundGdk = hilightColor; } catch (System.NullReferenceException) { tag = new Gtk.TextTag("hilight"); textBuffer.TagTable.Add(tag); tag.BackgroundGdk = hilightColor; } }
static uint RE_REMIND_DELAY = 30*60; //Wait x before re-showing [in seconds] (snooze) #endregion Fields #region Methods public override void Initialize() { // If a tag of this name already exists, don't install. if (Note.TagTable.Lookup ("reminder") == null) { TextTag highlightTag = new TextTag("reminder"); highlightTag.Background = "yellow"; Note.TagTable.Add (highlightTag); } ScanNote(); }
public override void Initialize() { person_tag = Note.TagTable.Lookup("link:person"); if (person_tag == null) { person_tag = new PersonTag("link:person", galago); Logger.Log("Adding link:person tag..."); Note.TagTable.Add(person_tag); } link_tag = Note.TagTable.Lookup("link:internal"); url_tag = Note.TagTable.Lookup("link:url"); }
public MainWindow(CCSDataSet data) : base(Gtk.WindowType.Toplevel) { this.data = data; Build (); A = CreateTag ("red", "black"); C = CreateTag ("blue", "white"); G = CreateTag ("yellow", "black"); T = CreateTag ("green","white"); Blank = CreateTag ("white", "black"); drawAlignment(); }
public ErrorDialog(Window parent) { new Glade.XML (null, "Base.glade", "ErrorDialog", null).Autoconnect (this); dialog.TransientFor = parent; okButton.Clicked += new EventHandler (OnClose); expander.Activated += new EventHandler (OnExpanded); descriptionLabel.ModifyBg (StateType.Normal, new Gdk.Color (255,0,0)); tagNoWrap = new TextTag ("nowrap"); tagNoWrap.WrapMode = WrapMode.None; detailsTextView.Buffer.TagTable.Add (tagNoWrap); tagWrap = new TextTag ("wrap"); tagWrap.WrapMode = WrapMode.Word; detailsTextView.Buffer.TagTable.Add (tagWrap); }
public ErrorDialog(Window parent) { this.Build (); TransientFor = parent; descriptionLabel.ModifyBg (StateType.Normal, new Gdk.Color (255,0,0)); tagNoWrap = new TextTag ("nowrap"); tagNoWrap.WrapMode = WrapMode.None; detailsTextView.Buffer.TagTable.Add (tagNoWrap); tagWrap = new TextTag ("wrap"); tagWrap.WrapMode = WrapMode.Word; detailsTextView.Buffer.TagTable.Add (tagWrap); expander.Visible = false; }
public TorrentError(string errortext, string tpath) { this.Build (); this.tpath = tpath; Gtk.TextTag tt = new Gtk.TextTag("bold"); tt.Weight = Pango.Weight.Bold; textview1.Buffer.TagTable.Add(tt); TextIter tr = textview1.Buffer.GetIterAtLine(0); textview1.Buffer.InsertWithTags(ref tr,"<Torrent File>\n",tt); textview1.Buffer.Insert(ref tr, tpath+"\n\n"); textview1.Buffer.InsertWithTags(ref tr,"<Error>\n",tt); textview1.Buffer.Insert(ref tr, errortext + "\n\n"); textview1.Buffer.Insert(ref tr, "Do you want to delete this file?"); }
public DefaultMonitorPad(string title, string icon) { buffer = new Gtk.TextBuffer (new Gtk.TextTagTable ()); textEditorControl = new Gtk.TextView (buffer); textEditorControl.Editable = false; scroller = new Gtk.ScrolledWindow (); scroller.ShadowType = ShadowType.In; scroller.Add (textEditorControl); Toolbar toolbar = new Toolbar (); toolbar.IconSize = IconSize.SmallToolbar; toolbar.Orientation = Orientation.Vertical; toolbar.ToolbarStyle = ToolbarStyle.Icons; buttonStop = new ToolButton ("gtk-stop"); buttonStop.Clicked += new EventHandler (OnButtonStopClick); buttonStop.SetTooltip (tips, "Stop", "Stop"); toolbar.Insert (buttonStop, -1); ToolButton buttonClear = new ToolButton ("gtk-clear"); buttonClear.Clicked += new EventHandler (OnButtonClearClick); buttonClear.SetTooltip (tips, "Clear console", "Clear console"); toolbar.Insert (buttonClear, -1); hbox = new HBox (false, 5); hbox.PackStart (scroller, true, true, 0); hbox.PackEnd (toolbar, false, false, 0); bold = new TextTag ("bold"); bold.Weight = Pango.Weight.Bold; buffer.TagTable.Add (bold); tag = new TextTag ("0"); tag.Indent = 10; buffer.TagTable.Add (tag); tags.Add (tag); Runtime.ProjectService.CombineOpened += (CombineEventHandler) Runtime.DispatchService.GuiDispatch (new CombineEventHandler (OnCombineOpen)); Runtime.ProjectService.CombineClosed += (CombineEventHandler) Runtime.DispatchService.GuiDispatch (new CombineEventHandler (OnCombineClosed)); this.title = title; this.icon = icon; this.markupTitle = title; Control.ShowAll (); }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build (); lexemesInit (); symbolTableInit (); //change console background color console.ModifyBase(StateType.Normal, new Gdk.Color(0000,0000,0000)); //change window color fixed1.ModifyBg (StateType.Normal, new Gdk.Color (0240, 0240, 0240)); //change console text color var consoleTextColorTag = new TextTag ("colorTag"); consoleTextColorTag.Foreground = "white"; console.Buffer.TagTable.Add (consoleTextColorTag); }
public AddLogEntryDialog (Dictionary<string,ChangeLogEntry> entries) { Build (); Pango.FontDescription font = Pango.FontDescription.FromString (DesktopService.DefaultMonospaceFont); textview.ModifyFont (font); textview.WrapMode = WrapMode.None; textview.AcceptsTab = true; Pango.TabArray tabs = new Pango.TabArray (1, true); tabs.SetTab (0, Pango.TabAlign.Left, GetStringWidth (" ") * 4); textview.Tabs = tabs; textview.SizeRequested += delegate (object o, SizeRequestedArgs args) { textview.WidthRequest = GetStringWidth (string.Empty.PadRight (80)); }; font.Dispose (); store = new ListStore (typeof(ChangeLogEntry), typeof(Gdk.Pixbuf), typeof(string)); fileList.Model = store; fileList.AppendColumn (string.Empty, new CellRendererPixbuf (), "pixbuf", 1); fileList.AppendColumn (string.Empty, new CellRendererText (), "text", 2); foreach (ChangeLogEntry ce in entries.Values) { Gdk.Pixbuf pic; if (ce.CantGenerate) pic = ImageService.GetPixbuf (Gtk.Stock.DialogWarning, Gtk.IconSize.Menu); else if (ce.IsNew) pic = ImageService.GetPixbuf (Gtk.Stock.New, Gtk.IconSize.Menu); else pic = null; store.AppendValues (ce, pic, ce.File); } fileList.Selection.Changed += OnSelectionChanged; textview.Buffer.Changed += OnTextChanged; TreeIter it; editMark = textview.Buffer.CreateMark (null, textview.Buffer.EndIter, false); oldTextTag = new Gtk.TextTag ("readonly"); oldTextTag.Foreground = "gray"; oldTextTag.Editable = false; textview.Buffer.TagTable.Add (oldTextTag); if (store.GetIterFirst (out it)) fileList.Selection.SelectIter (it); }
public ErrorDialog(Window parent) : base("Pinta", parent, DialogFlags.Modal | DialogFlags.DestroyWithParent) { this.Build (); TransientFor = parent; descriptionLabel.ModifyBg (StateType.Normal, new Gdk.Color (255,0,0)); tagNoWrap = new TextTag ("nowrap"); tagNoWrap.WrapMode = WrapMode.None; detailsTextView.Buffer.TagTable.Add (tagNoWrap); tagWrap = new TextTag ("wrap"); tagWrap.WrapMode = WrapMode.Word; detailsTextView.Buffer.TagTable.Add (tagWrap); expander.Visible = false; okButton.GrabFocus (); }
public SourceWindow(CoverageView.ClassItem klass) { this.classItem = klass; text_buffer = new TextBuffer (new TextTagTable ()); text_view = new TextView (text_buffer); text_view.Editable = false; Add (text_view); hit_color = new TextTag ("hit"); hit_color.Foreground = "blue"; text_buffer.TagTable.Add (hit_color); missed_color = new TextTag ("miss"); missed_color.Foreground = "red"; text_buffer.TagTable.Add (missed_color); LoadFile (klass); ShowAll (); }
public ErrorDialog (Window parent) { Build (); TransientFor = parent; okButton.Clicked += new EventHandler (OnClose); expander.Activated += new EventHandler (OnExpanded); descriptionLabel.ModifyBg (StateType.Normal, new Gdk.Color (255,0,0)); tagNoWrap = new TextTag ("nowrap"); tagNoWrap.WrapMode = WrapMode.None; detailsTextView.Buffer.TagTable.Add (tagNoWrap); tagWrap = new TextTag ("wrap"); tagWrap.WrapMode = WrapMode.Word; detailsTextView.Buffer.TagTable.Add (tagWrap); expander.Visible = false; }
public AddLogEntryDialog (Dictionary<string,ChangeLogEntry> entries) { Build (); textview.ModifyFont (FontService.MonospaceFont); textview.WrapMode = WrapMode.None; textview.AcceptsTab = true; Pango.TabArray tabs = new Pango.TabArray (1, true); tabs.SetTab (0, Pango.TabAlign.Left, GetStringWidth (" ") * 4); textview.Tabs = tabs; textview.SizeRequested += delegate { textview.WidthRequest = GetStringWidth (String.Empty.PadRight (80)); }; store = new ListStore (typeof(ChangeLogEntry), typeof(Xwt.Drawing.Image), typeof(string)); fileList.Model = store; fileList.AppendColumn (string.Empty, new CellRendererImage (), "image", 1); fileList.AppendColumn (string.Empty, new CellRendererText (), "text", 2); foreach (ChangeLogEntry ce in entries.Values) { Xwt.Drawing.Image pic; if (ce.CantGenerate) pic = ImageService.GetIcon (Ide.Gui.Stock.Warning, IconSize.Menu); else if (ce.IsNew) pic = ImageService.GetIcon (Stock.New, IconSize.Menu); else pic = null; store.AppendValues (ce, pic, ce.File); } fileList.Selection.Changed += OnSelectionChanged; textview.Buffer.Changed += OnTextChanged; TreeIter it; editMark = textview.Buffer.CreateMark (null, textview.Buffer.EndIter, false); oldTextTag = new TextTag ("readonly"); oldTextTag.Foreground = "gray"; oldTextTag.Editable = false; textview.Buffer.TagTable.Add (oldTextTag); if (store.GetIterFirst (out it)) fileList.Selection.SelectIter (it); }
private void SetupTextBufferTags() { Gtk.TextTag tag = new Gtk.TextTag("time"); tag.Foreground = "darkgrey"; //tag.Justification = Justification.Right; this.Buffer.TagTable.Add(tag); tag = new Gtk.TextTag("incoming"); tag.Foreground = "darkgreen"; tag.Weight = Pango.Weight.Bold; this.Buffer.TagTable.Add(tag); tag = new Gtk.TextTag("outgoing"); tag.Foreground = "darkblue"; tag.Weight = Pango.Weight.Bold; this.Buffer.TagTable.Add(tag); tag = new Gtk.TextTag("system"); tag.Foreground = "darkgrey"; tag.Style = Pango.Style.Italic; this.Buffer.TagTable.Add(tag); }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build(); ActionEntry[] entries = new ActionEntry[] { new ActionEntry("menu-engine", null, "_Engine", null, null, null), new ActionEntry("unpause", null, "Unpause", "<ctrl>U", null, OnUnpause), new ActionEntry("menu-script", null, "_Script", null, null, null), new ActionEntry("rebuild-and-reload", null, "Rebuild And Reload", null, null, OnRebuildAndReload), new ActionEntry("menu-connect", null, "_Connect", null, null, null), new ActionEntry("reconnect", null, "Reconnect", "<ctrl>R", null, null) }; Actions = new ActionGroup("group"); Actions.Add(entries); UI.InsertActionGroup(Actions, 0); UI.AddUiFromResource("Menu.xml"); AddAccelGroup(UI.AccelGroup); MenuBar menuBar = (MenuBar)UI.GetWidget("/MenuBar"); vbox1.PackStart(menuBar, false, false, 0); // Create tags for color-formatted text TextTag tagInfo = new Gtk.TextTag("info"); tagInfo.BackgroundGdk = new Gdk.Color(255, 255, 255); TextTag tagWarning = new Gtk.TextTag("warning"); tagWarning.BackgroundGdk = new Gdk.Color(255, 255, 153); TextTag tagError = new Gtk.TextTag("error"); tagError.BackgroundGdk = new Gdk.Color(255, 153, 153); TextTag tagDebug = new Gtk.TextTag("debug"); tagDebug.BackgroundGdk = new Gdk.Color(224, 224, 224); textview1 = new TextView(); textview1.Editable = false; textview1.CanFocus = false; TextBuffer textbuffer1 = textview1.Buffer; textbuffer1.TagTable.Add(tagInfo); textbuffer1.TagTable.Add(tagWarning); textbuffer1.TagTable.Add(tagError); textbuffer1.TagTable.Add(tagDebug); scrolledwindow1 = new ScrolledWindow(); scrolledwindow1.Add(textview1); vbox1.PackStart(scrolledwindow1, true, true, 0); entry1 = new Entry(); entry1.KeyPressEvent += new KeyPressEventHandler(OnEntryKeyPressed); entry1.Activated += new EventHandler(OnEntryActivated); vbox1.PackStart(entry1, false, true, 0); EnableMainMenu(false); Actions.GetAction("menu-script").Sensitive = false; Client = new ConsoleClient(); Client.ConnectedEvent += OnConnected; Client.DisconnectedEvent += OnDisconnected; Client.MessageReceivedEvent += OnMessageReceived; Connect(Address, Port); ShowAll(); }
private void ApplyTextTags(Gtk.TextBuffer tb, string tagname) { int cN = tb.Text.Length - 1; Gtk.TextIter start = tb.GetIterAtOffset(0); Gtk.TextIter stop = tb.GetIterAtOffset(cN); string[] delimiters = new string[] { ":" }; string[] tagname_parts = tagname.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); string key = tagname_parts[0]; string value = null; if (tagname_parts.Length > 1) { value = tagname_parts[1]; } Gtk.TextTag tag_lookup = tb.TagTable.Lookup("DemoTextSelection"); Gtk.TextTag tag_local = null; // should be the same?!?! //tag_local = tag; // class variable?? sometines null? tag_local = tag_lookup; Console.WriteLine("key [{0}] value[{1}] tagname [{2}]", key, value, tagname); switch (key) { case "font": tag_local.Font = value; break; case "fontsize": tag_local.Size = Convert.ToInt32(value); // events?!?!? break; case "fontweight": switch (value) { case "normal": tag_local.Weight = Pango.Weight.Normal; break; case "bold": // tag_local.Weight = Pango.Weight.Bold; // no visible diff tag_local.Weight = Pango.Weight.Ultrabold; break; case "heavy": tag_local.Weight = Pango.Weight.Heavy; break; case "light": tag_local.Weight = Pango.Weight.Light; break; case "semibold": tag_local.Weight = Pango.Weight.Semibold; break; case "ultrabold": tag_local.Weight = Pango.Weight.Ultrabold; break; case "ultralight": tag_local.Weight = Pango.Weight.Ultralight; break; default: tag_local.Weight = Pango.Weight.Normal; break; } break; case "style": switch (value) { case "normal": tag_local.Style = Pango.Style.Normal; break; case "italic": tag_local.Style = Pango.Style.Italic; break; case "oblique": tag_local.Style = Pango.Style.Oblique; break; default: tag_local.Style = Pango.Style.Normal; break; } break; case "strikethrough": tag_local.Strikethrough = Convert.ToBoolean(value); break; case "doublestrikethrough": tag_local.Strikethrough = Convert.ToBoolean(value); break; case "superscript": if (Convert.ToBoolean(value)) { tag_local.Rise = 50; } else { tag_local.Rise = 0; } break; case "subscript": if (Convert.ToBoolean(value)) { tag_local.Rise = -50; } else { tag_local.Rise = 0; } break; case "smallcaps": if (Convert.ToBoolean(value)) { tag_local.Variant = Pango.Variant.SmallCaps; } else { tag_local.Variant = Pango.Variant.Normal; } break; case "allcaps": // no all caps? // tamp replacement if (Convert.ToBoolean(value)) { tb.Text = tb.Text.ToUpper(); tag_local.Variant = Pango.Variant.Normal; } else { tb.Text = this.demo_text; tag_local.Variant = Pango.Variant.Normal; } break; case "hidden": if (Convert.ToBoolean(value)) { tag_local.Variant = Pango.Variant.Normal; } else { tag_local.Rise = 0; } break; case "underlinestyle": switch (value) { case "none": tag_local.Underline = Pango.Underline.None; break; case "double": tag_local.Underline = Pango.Underline.Double; break; case "single": tag_local.Underline = Pango.Underline.Single; break; case "error": tag_local.Underline = Pango.Underline.Error; break; case "low": tag_local.Underline = Pango.Underline.Low; break; default: tag_local.Underline = Pango.Underline.None; break; } break; case "underlinecolor": // cannot change color of the underline! // tag_local.Underline // trying font until custom dialog is over string rgb = tagname_parts[2]; // obtained as "rgb:HHHH/HHHH/HHHH" //-------------------------------------------------------------------- // Attempt 1 tag_local.Foreground = ""; tag_local.ForegroundGdk = new Gdk.Color(60, 60, 60); //-------------------------------------------------------------------- //-------------------------------------------------------------------- // Attempt 2 //textviewDemoText.ModifyFg(StateType.Normal, underline_color_selected); // color not applied?!?! //textviewDemoText.ModifyBg(StateType.Normal, underline_color_selected); // color not applied?!?! // return; // to skip tb.ApplyTag later does not change color break; default: tag_local = tb.TagTable.Lookup(tagname); break; } tb.ApplyTag(tag_local, start, stop); return; }