Пример #1
0
	public void TagEndsHereSimple ()
	{
		DocumentEditor editor = new DocumentEditor ();
		TextBuffer buffer = editor.Buffer;
		
		TextIter insertIter = buffer.StartIter;
		buffer.InsertWithTagsByName (ref insertIter, "Example Region", "Type");
		
		TextIter endIter = buffer.GetIterAtOffset (insertIter.Offset - 1);
		TextIter nextIter = buffer.GetIterAtOffset (insertIter.Offset);
		bool endsTag = DocumentUtils.TagEndsHere (buffer.TagTable.Lookup ("Type"), endIter, nextIter);
		Assert.IsTrue (endsTag, "TEH01");
	}
Пример #2
0
	public void GetLastTag ()
	{
		DocumentEditor editor = new DocumentEditor ();
		TextBuffer buffer = editor.Buffer;
		
		TextIter insertIter = buffer.StartIter;
		buffer.Insert (ref insertIter, "Start Extern Region ");
		buffer.InsertWithTagsByName (ref insertIter, "Intern Region", "Type:Attributes");
		int index = insertIter.Offset - 1;
		buffer.Insert (ref insertIter, "End Extern Region");
		buffer.ApplyTag ("Type", buffer.StartIter, insertIter);
		
		TextTag expectedTag = buffer.TagTable.Lookup ("Type:Attributes");
		TextTag actualTag = DocumentUtils.GetLastTag (buffer.GetIterAtOffset (index));
		Assert.AreEqual (expectedTag, actualTag, "GLT01");
	}
Пример #3
0
	public void TestText ()
	{
		DocumentEditor editor = new DocumentEditor ();
		TextBuffer buffer = editor.Buffer;
		
		TextTag summaryTag = buffer.TagTable.Lookup ("summary");
		TextTag textTag = buffer.TagTable.Lookup ("summary:Text");
		
		TextIter insertAt = buffer.StartIter;
		buffer.InsertWithTags (ref insertAt, "Test: ", summaryTag);
		
		int startIndex = insertAt.Offset;
		buffer.InsertWithTags (ref insertAt, "Testing TextRange", textTag);

		TextRange textRange = new TextRange (buffer.GetIterAtOffset (startIndex), insertAt);
		Assert.AreEqual ("Testing TextRange", textRange.Text, "TRT");
	}
	public void TestSerialize ()
	{
		string originalXml, newXml, filename;
		
		foreach (string file in files) {
			DocumentEditor editor = new DocumentEditor ();
			DocumentBuffer buffer = (DocumentBuffer) editor.Buffer;
			
			MonoDocument document = new MonoDocument (file);
			filename = Path.GetFileName (file);
			originalXml= document.Xml;
			
			buffer.Undoer.FreezeUndo ();
			DocumentBufferArchiver.Deserialize (buffer, originalXml);
			buffer.Undoer.ThrawUndo ();
			newXml = DocumentBufferArchiver.Serialize (buffer);
			
			Assert.AreEqual (originalXml, newXml, "SR:" + filename);
		}
	}
Пример #5
0
	public void TagEndsHereOverlaping ()
	{
		DocumentEditor editor = new DocumentEditor ();
		TextBuffer buffer = editor.Buffer;
		
		TextIter insertIter = buffer.StartIter;
		buffer.InsertWithTagsByName (ref insertIter, "Example Region", "Type");
		int firstEndOffset = insertIter.Offset;
		buffer.InsertWithTagsByName (ref insertIter, "Second Region", "Type");
		
		TextIter firstEndIter = buffer.GetIterAtOffset (firstEndOffset - 1);
		TextIter firstNextIter = buffer.GetIterAtOffset (firstEndOffset);
		TextIter secondEndIter = buffer.GetIterAtOffset (insertIter.Offset - 1);
		TextIter secondNextIter = buffer.GetIterAtOffset (insertIter.Offset);
		
		bool firstEndsTag = DocumentUtils.TagEndsHere (buffer.TagTable.Lookup ("Type"), firstEndIter, firstNextIter);
		bool secondEndsTag = DocumentUtils.TagEndsHere (buffer.TagTable.Lookup ("Type"), secondEndIter, secondNextIter);
		Assert.IsFalse (firstEndsTag, "TEH01");
		Assert.IsTrue (secondEndsTag, "TEH02");
	}
	public void TestSerializePerformance ()
	{
		foreach (string file in files) {
			DocumentEditor editor = new DocumentEditor ();
			DocumentBuffer buffer = (DocumentBuffer) editor.Buffer;
			
			MonoDocument document = new MonoDocument (file);
			string filename = Path.GetFileName (file);
			
			buffer.Undoer.FreezeUndo ();
			DocumentBufferArchiver.Deserialize (buffer, document.Xml);
			buffer.Undoer.ThrawUndo ();
			
			DateTime startTime = DateTime.Now;
			DocumentBufferArchiver.Serialize (buffer);
			DateTime stopTime = DateTime.Now;
			
			TimeSpan duration = stopTime - startTime;			
			Assert.Less (duration.TotalMilliseconds, 3000, "SP:" + filename);
		}
	}
Пример #7
0
        public void TagEndsHereOverlaping()
        {
            DocumentEditor editor = new DocumentEditor();
            TextBuffer     buffer = editor.Buffer;

            TextIter insertIter = buffer.StartIter;

            buffer.InsertWithTagsByName(ref insertIter, "Example Region", "Type");
            int firstEndOffset = insertIter.Offset;

            buffer.InsertWithTagsByName(ref insertIter, "Second Region", "Type");

            TextIter firstEndIter   = buffer.GetIterAtOffset(firstEndOffset - 1);
            TextIter firstNextIter  = buffer.GetIterAtOffset(firstEndOffset);
            TextIter secondEndIter  = buffer.GetIterAtOffset(insertIter.Offset - 1);
            TextIter secondNextIter = buffer.GetIterAtOffset(insertIter.Offset);

            bool firstEndsTag  = DocumentUtils.TagEndsHere(buffer.TagTable.Lookup("Type"), firstEndIter, firstNextIter);
            bool secondEndsTag = DocumentUtils.TagEndsHere(buffer.TagTable.Lookup("Type"), secondEndIter, secondNextIter);

            Assert.IsFalse(firstEndsTag, "TEH01");
            Assert.IsTrue(secondEndsTag, "TEH02");
        }
Пример #8
0
	public DocumentTab (Notebook docTabs) : base ()
	{
		doc_tabs = docTabs;
		InitializeProperties ();
		
		editor = new DocumentEditor ();
		this.Add (editor);
		
		tab_label = new HBox (false, 2);
		title_label = new Label ("Untitled");
		
		// Close tab button
		Button tabClose = new Button ();
		Image img = new Image (Stock.Close, IconSize.SmallToolbar);
		tabClose.Add (img);
		tabClose.Relief = ReliefStyle.None;
		tabClose.SetSizeRequest (23, 23);
		tabClose.Clicked += new EventHandler (OnTabClose);
		
		tab_label.PackStart (title_label, true, true, 0);
		tab_label.PackStart (tabClose, false, false, 2);
		
		tab_label.ShowAll ();
	}
Пример #9
0
	public void AddPaddingIntOffset ()
	{
		int initialOffset = 0;
		DocumentEditor editor = new DocumentEditor ();
		TextBuffer buffer = editor.Buffer;
		
		int nextOffset = DocumentUtils.AddPadding (buffer, initialOffset, "#0");
		Assert.AreEqual (1, nextOffset, "APIO");
	}
Пример #10
0
	public void GetAssociatedTextTag ()
	{
		DocumentEditor editor = new DocumentEditor ();
		TextBuffer buffer = editor.Buffer;
		
		TextTag summaryTag = buffer.TagTable.Lookup ("summary");
		Assert.IsNotNull (summaryTag);
		DocumentTag actualTag = (DocumentTag) DocumentUtils.GetAssociatedTextTag (buffer, summaryTag);
		Assert.AreEqual ("summary:Text", actualTag.Name);
		Assert.IsTrue (actualTag.IsText);
	}
Пример #11
0
	public void AddPaddingEmptyIntValidRegion ()
	{
		int initialOffset, endOffset, nextOffset;
		DocumentEditor editor = new DocumentEditor ();
		TextBuffer buffer = editor.Buffer;
		
		initialOffset = 0;
		nextOffset = DocumentUtils.AddPaddingEmpty (buffer, initialOffset, "#0");
		endOffset = nextOffset - 1;
		
		TextTag expectedTag = buffer.TagTable.Lookup ("padding-empty#0");
		bool beginsPadding = buffer.GetIterAtOffset (initialOffset).BeginsTag (expectedTag);
		bool endsPadding = DocumentUtils.TagEndsHere  (expectedTag, buffer.GetIterAtOffset (endOffset), buffer.GetIterAtOffset (nextOffset));
		Assert.IsTrue (beginsPadding, "APEIVR01");
		Assert.IsTrue (endsPadding, "APEIVR02");
	}
Пример #12
0
	public void AddNewLineVoid ()
	{
		int initialOffset, endOffset;
		DocumentEditor editor = new DocumentEditor ();
		TextBuffer buffer = editor.Buffer;
		
		initialOffset = 0;
		TextIter insertIter = buffer.StartIter;
		DocumentUtils.AddNewLine (buffer, ref insertIter, "#0");
		endOffset = insertIter.Offset - 1;
		
		TextTag expectedTag = buffer.TagTable.Lookup ("newline#0");
		bool beginsNewLine = buffer.GetIterAtOffset (initialOffset).BeginsTag (expectedTag);
		bool endsNewLine = DocumentUtils.TagEndsHere  (expectedTag, buffer.GetIterAtOffset (endOffset), insertIter);
		Assert.IsTrue (beginsNewLine, "ANLV01");
		Assert.IsTrue (endsNewLine, "ANLV02");
	}
Пример #13
0
	public void AddStringVoidValidRegion ()
	{
		string data = "Inserting format Region";
		DocumentEditor editor = new DocumentEditor ();
		TextBuffer buffer = editor.Buffer;
		
		TextIter insertIter = buffer.StartIter;
		DocumentUtils.AddString (buffer, ref insertIter, data, "#0");
		
		TextTag expectedTag = buffer.TagTable.Lookup ("format#0");
		bool beginsFormat = buffer.StartIter.BeginsTag (expectedTag);
		bool endsFormat = DocumentUtils.TagEndsHere  (expectedTag, buffer.GetIterAtOffset (insertIter.Offset - 2), buffer.GetIterAtOffset (insertIter.Offset -1 ));
		Assert.IsTrue (beginsFormat, "ASVR01");
		Assert.IsTrue (endsFormat, "ASVR02");
	}
Пример #14
0
	public void AddStringVoidOffset ()
	{
		string data = "Inserting format Region";
		DocumentEditor editor = new DocumentEditor ();
		TextBuffer buffer = editor.Buffer;
		
		TextIter insertIter = buffer.StartIter;
		DocumentUtils.AddString (buffer, ref insertIter, data, "#0");
		
		Assert.AreEqual (data.Length + 1, insertIter.Offset, "ASVO");
	}
Пример #15
0
	public void AddStringIntValidRegion ()
	{
		int initialOffset, endOffset, nextOffset;
		string data = "Inserting format Region";
		DocumentEditor editor = new DocumentEditor ();
		TextBuffer buffer = editor.Buffer;
		
		initialOffset = 0;
		nextOffset = DocumentUtils.AddString (buffer, initialOffset, data, "#0");
		endOffset = nextOffset - 2;
		
		TextTag expectedTag = buffer.TagTable.Lookup ("format#0");
		bool beginsFormat = buffer.GetIterAtOffset (initialOffset).BeginsTag (expectedTag);
		bool endsFormat = DocumentUtils.TagEndsHere  (expectedTag, buffer.GetIterAtOffset (endOffset), buffer.GetIterAtOffset (nextOffset - 1));
		Assert.IsTrue (beginsFormat, "ASIVR01");
		Assert.IsTrue (endsFormat, "ASIVR02");
	}
Пример #16
0
	public void AddStringIntOffset ()
	{
		int initialOffset, nextOffset;
		string data = "Inserting format Region";
		DocumentEditor editor = new DocumentEditor ();
		TextBuffer buffer = editor.Buffer;
		initialOffset = 0;
		
		nextOffset = DocumentUtils.AddString (buffer, initialOffset, data, "#0");
		Assert.AreEqual (data.Length + 1, nextOffset, "ASIO");
	}
Пример #17
0
	public void AddPaddingEmptyVoidValidRegion ()
	{
		DocumentEditor editor = new DocumentEditor ();
		TextBuffer buffer = editor.Buffer;
		
		TextIter insertIter = buffer.StartIter;
		DocumentUtils.AddPaddingEmpty (buffer, ref insertIter, "#0");
		
		TextTag expectedTag = buffer.TagTable.Lookup ("padding-empty#0");
		bool beginsPadding = buffer.StartIter.BeginsTag (expectedTag);
		bool endsPadding = DocumentUtils.TagEndsHere  (expectedTag, buffer.GetIterAtOffset (insertIter.Offset - 1), insertIter);
		Assert.IsTrue (beginsPadding, "APEVR01");
		Assert.IsTrue (endsPadding, "APEVR02");
	}
Пример #18
0
	public void AddPaddingEmptyVoidOffset ()
	{
		DocumentEditor editor = new DocumentEditor ();
		TextBuffer buffer = editor.Buffer;
		
		TextIter insertIter = buffer.StartIter;
		DocumentUtils.AddPaddingEmpty (buffer, ref insertIter, "#0");
		
		Assert.AreEqual (1, insertIter.Offset, "APEVO");
	}