public override void Redo (Gtk.TextBuffer buffer)
		{
			RemoveSplitTags (buffer);

			Gtk.TextIter cursor = buffer.GetIterAtOffset (Offset);

			Gtk.TextTag[] tags = {Tag};
			buffer.InsertWithTags (ref cursor, Id, tags);

			buffer.MoveMark (buffer.SelectionBound, buffer.GetIterAtOffset (Offset));
			buffer.MoveMark (buffer.InsertMark,
			                 buffer.GetIterAtOffset (Offset + chop.Length));

		}
Example #2
0
        protected override void InsertTimeStamp(Gtk.TextBuffer buffer, ref Gtk.TextIter iter,
                                                string timestamp, MessageModel msg)
        {
            if (String.IsNullOrWhiteSpace(msg.ID)) {
                buffer.Insert(ref iter, timestamp);
            } else {
                var uri = new Uri(String.Format("https://twitter.com/{0}/status/{1}", msg.GetNick(), msg.ID));

                var tags = new List<Gtk.TextTag>();
                // link URI tag
                var linkTag = new LinkTag(uri);
                linkTag.TextEvent += OnLinkTagTextEvent;
                _MessageTextTagTable.Add(linkTag);
                tags.Add(linkTag);

                // link style tag
                tags.Add(LinkTag);

                buffer.InsertWithTags(ref iter, timestamp, tags.ToArray());
            }

            buffer.Insert(ref iter, " ");
        }
Example #3
0
        private void InsertToBuffer(Gtk.TextBuffer buffer, ref Gtk.TextIter iter, TextMessagePartModel fmsgti)
        {
            var tags = new List<Gtk.TextTag>();
            if (fmsgti.Text == null) {
                // Gtk.TextBuffer.Insert*() asserts on text == NULL
                return;
            }
            if (fmsgti.ForegroundColor != TextColor.None) {
                var bg = ColorConverter.GetTextColor(BackgroundColor);
                if (fmsgti.BackgroundColor != TextColor.None) {
                    bg = fmsgti.BackgroundColor;
                }
                TextColor color = TextColorTools.GetBestTextColor(
                    fmsgti.ForegroundColor, bg
                );
                string tagname = GetTextTagName(color, null);
                var tag = _MessageTextTagTable.Lookup(tagname);
                tags.Add(tag);
            }
            if (fmsgti.BackgroundColor != TextColor.None) {
                // TODO: get this from ChatView
                string tagname = GetTextTagName(null, fmsgti.BackgroundColor);
                var tag = _MessageTextTagTable.Lookup(tagname);
                tags.Add(tag);
            }
            if (fmsgti.Underline) {
            #if LOG4NET && MSG_DEBUG
                _Logger.Debug("AddMessage(): fmsgti.Underline is true");
            #endif
                tags.Add(UnderlineTag);
            }
            if (fmsgti.Bold) {
            #if LOG4NET && MSG_DEBUG
                _Logger.Debug("AddMessage(): fmsgti.Bold is true");
            #endif
                tags.Add(BoldTag);
            }
            if (fmsgti.Italic) {
            #if LOG4NET && MSG_DEBUG
                _Logger.Debug("AddMessage(): fmsgti.Italic is true");
            #endif
                tags.Add(ItalicTag);
            }

            if (tags.Count > 0) {
                buffer.InsertWithTags(ref iter, fmsgti.Text, tags.ToArray());
            } else {
                buffer.Insert(ref iter, fmsgti.Text);
            }
        }
Example #4
0
        private void InsertToBuffer(Gtk.TextBuffer buffer, ref Gtk.TextIter iter, UrlMessagePartModel urlPart)
        {
            var linkText = urlPart.Text ?? urlPart.Url;

            Uri uri;
            try {
                uri = new Uri(urlPart.Url);
            } catch (UriFormatException ex) {
            #if LOG4NET
                _Logger.Error("AddMessage(): Invalid URL: " + urlPart.Url, ex);
            #endif
                buffer.Insert(ref iter, linkText);
                return;
            }

            var tags = new List<Gtk.TextTag>();
            // link URI tag
            var linkTag = new LinkTag(uri);
            linkTag.TextEvent += OnLinkTagTextEvent;
            _MessageTextTagTable.Add(linkTag);
            tags.Add(linkTag);

            // link style tag
            tags.Add(LinkTag);

            buffer.InsertWithTags(ref iter, linkText, tags.ToArray());
        }