// 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);
		}
Beispiel #2
0
	public static void AddPadding (TextBuffer buffer, ref TextIter insertAt, string suffix)
	{
		DocumentTagTable tagTable = (DocumentTagTable) buffer.TagTable;
		TextTag tag = tagTable.Lookup ("padding" + suffix);
		
		if (tag == null)
			tag = tagTable.CreateDynamicTag ("padding" + suffix);
		buffer.InsertWithTags (ref insertAt, " ", tag);
	}
Beispiel #3
0
        public void BeginTask(string name)
        {
            if (name != null && name.Length > 0)
            {
                Indent();
                indents.Push(name);
                Message = name;
            }
            else
            {
                indents.Push(null);
            }

            if (name != null)
            {
                TextIter it  = buffer.EndIter;
                string   txt = name + "\n";
                buffer.InsertWithTags(ref it, txt, tag, bold);
                detailsTextView.ScrollMarkOnscreen(buffer.InsertMark);
            }
        }
		// 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);
			}
		}
Beispiel #5
0
	public static void AddText (TextBuffer buffer, ref TextIter insertAt, string data, TextTag tag)
	{
		DocumentTagTable tagTable = (DocumentTagTable) buffer.TagTable;
		TextTag textTag = tagTable.Lookup ("significant-whitespace" + "#" +  tag.Name);
		if (textTag == null)
			textTag = tagTable.CreateDynamicTag ("significant-whitespace" + "#" + tag.Name);
		
		string trimData = data.Trim ();
		int index = data.IndexOf (trimData);
		
		string startSpace = data.Substring (0, index);
		string prefixSpace = String.Empty;
		if (!startSpace.Equals (String.Empty)) {
			if (startSpace.Length == 1) {
				prefixSpace = startSpace;
				startSpace = String.Empty;
			} else {
				prefixSpace = startSpace.Substring (startSpace.Length - 1);
				startSpace = startSpace.Substring (0, startSpace.Length - 1);
			}
		}
		
		string endSpace = data.Substring (index + trimData.Length);
		string postSpace = String.Empty;
		if (!endSpace.Equals (String.Empty)) {
			if (endSpace.Length == 1) {
				if (endSpace.Equals (" ")) {
					postSpace = endSpace;
					endSpace = String.Empty;
				}
			} else {
				if (endSpace.Substring (0, 1).Equals (" ")) {
					postSpace = endSpace.Substring (0, 1);
					endSpace = endSpace.Substring (1);
				}
			}
		}
		
		buffer.InsertWithTags (ref insertAt, Escape (startSpace), textTag);
		buffer.InsertWithTags (ref insertAt, prefixSpace + trimData + postSpace, tag);
		buffer.InsertWithTags (ref insertAt, Escape (endSpace), textTag);
	}
Beispiel #6
0
	public static void AddStub (TextBuffer buffer, ref TextIter insertAt, string data, string suffix)
	{
		DocumentTagTable tagTable = (DocumentTagTable) buffer.TagTable;
		
		TextTag textTag = tagTable.Lookup ("stub" + suffix + "#" + counter);
		if (textTag == null)
			textTag = tagTable.CreateDynamicTag ("stub" + suffix + "#" +  counter);
		
		counter++;
		buffer.InsertWithTags (ref insertAt, data, textTag);
	}
Beispiel #7
0
        private void DrawPart(ContentText text, TextBuffer tb = null)
        {
            if (tb == null)
            {
                tb = richTextBox.Buffer;
            }

            Gtk.TextIter iter = tb.EndIter;

            TextTag format = new TextTag(null);

            format.FontDesc = DefaultFont;

            if (text.Bold)
            {
                format.Weight = Pango.Weight.Bold;
                if (Configuration.Scrollback.UnderlineBold)
                {
                    format.Underline = Pango.Underline.Double;
                }
            }

            if (text.Underline)
            {
                format.Underline = Pango.Underline.Single;
            }

            if (text.Italic)
            {
                format.Style = Pango.Style.Italic;
                format.BackgroundGdk = Core.FromColor(text.TextColor);
                format.ForegroundGdk = Core.FromColor(Configuration.CurrentSkin.BackgroundColor);
            }

            if (text.Link != null)
            {
                format.TextEvent += new TextEventHandler(LinkHandler);
            }
            else
            {
                format.TextEvent += new TextEventHandler(LinkRm);
            }

            format.Data.Add("link", text.Link);
            format.Data.Add("identifier", text.Text);
            if (!text.Italic)
            {
                format.ForegroundGdk = Core.FromColor(text.TextColor);
            }
            tb.TagTable.Add(format);
            //format.SizePoints = Configuration.CurrentSkin.FontSize;
            tb.InsertWithTags(ref iter, text.Text, format);
        }
	private static void DeserializeAttributesNone (TextBuffer buffer, ref TextIter insertAt, XmlTextReader xmlReader, string tagSuffix)
	{
		string tagName = String.Empty;
		string tagPrefix = xmlReader.Name + ":";
		
		DocumentTagTable tagTable = (DocumentTagTable) buffer.TagTable;
		while (xmlReader.MoveToNextAttribute ()) {
			tagName = tagPrefix + xmlReader.Name + tagSuffix;
			
			TextTag tag = tagTable.Lookup (tagName);
			if (tag == null)
				tag = tagTable.CreateDynamicTag (tagName);
			
			buffer.InsertWithTags (ref insertAt, xmlReader.Value, tag);
		}
		
		#if DEBUG
		Console.WriteLine ("Attribute: {0} End: {1}", tagName, insertAt.Offset);
		#endif
	}
	private static void DeserializeAttributesMemberSignature (TextBuffer buffer, ref TextIter insertAt, XmlTextReader xmlReader, string tagSuffix)
	{
		string tagName = String.Empty;
		string tagPrefix = xmlReader.Name + ":";
		
		DocumentTagTable tagTable = (DocumentTagTable) buffer.TagTable;
		while (xmlReader.MoveToNextAttribute ()) {
			tagName = tagPrefix + xmlReader.Name + tagSuffix;
			
			TextTag formatTag = tagTable.Lookup ("format" + tagSuffix);
			if (formatTag == null)
				formatTag = tagTable.CreateDynamicTag ("format" + tagSuffix);
			
			if (xmlReader.Name == "Language")
				buffer.InsertWithTags (ref insertAt, "Member Language: ", formatTag);
			
			if (xmlReader.Name == "Value")
				buffer.InsertWithTags (ref insertAt, "Member Signature: ", formatTag);
			
			TextTag tag = tagTable.Lookup (tagName);
			if (tag == null)
				tag = tagTable.CreateDynamicTag (tagName);
			
			buffer.InsertWithTags (ref insertAt, xmlReader.Value, tag);
			DocumentUtils.AddNewLine (buffer, ref insertAt, tagSuffix);
			
			#if DEBUG
			Console.WriteLine ("Attribute: {0} End: {1}", tagName, insertAt.Offset);
			#endif
		}
	}