Replace() public méthode

public Replace ( int offset, int count, string value ) : void
offset int
count int
value string
Résultat void
    void SetDiffCellData (Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
    {
        try
        {
            CellRendererDiff cellRendererDiff = (CellRendererDiff)cell;
            Change change = store.GetValue (iter, objColumn) as Change;
            cellRendererDiff.Visible = !(bool)store.GetValue (iter, statusVisibleColumn);
            if (change == null || !cellRendererDiff.Visible)
            {
                cellRendererDiff.InitCell (treeviewPreview, false, "", "");
                return;
            }
            TextReplaceChange replaceChange = change as TextReplaceChange;
            if (replaceChange == null)
                return;

            var openDocument = IdeApp.Workbench.GetDocument (replaceChange.FileName);
            Mono.TextEditor.TextDocument originalDocument = new Mono.TextEditor.TextDocument ();
            originalDocument.FileName = replaceChange.FileName;
            if (openDocument == null)
            {
                originalDocument.Text = Mono.TextEditor.Utils.TextFileUtility.ReadAllText (replaceChange.FileName);
            }
            else
            {
                originalDocument.Text = openDocument.Editor.Document.Text;
            }

            Mono.TextEditor.TextDocument changedDocument = new Mono.TextEditor.TextDocument ();
            changedDocument.FileName = replaceChange.FileName;
            changedDocument.Text = originalDocument.Text;

            changedDocument.Replace (replaceChange.Offset, replaceChange.RemovedChars, replaceChange.InsertedText);

            string diffString = Mono.TextEditor.Utils.Diff.GetDiffString (originalDocument, changedDocument);

            cellRendererDiff.InitCell (treeviewPreview, true, diffString, replaceChange.FileName);
        }
        catch (Exception e)
        {
            Console.WriteLine (e);
        }
    }
			public virtual void Redo (TextDocument doc)
			{
				doc.Replace (args.Offset, args.RemovalLength, args.InsertedText.Text);
				OnRedoDone ();
			}
			public virtual void Undo (TextDocument doc)
			{
				doc.Replace (args.Offset, args.InsertionLength, args.RemovedText.Text);
				OnUndoDone ();
			}
Exemple #4
0
 public void DeleteText(int position, int length)
 {
     document.Replace(position, length, "");
 }
		void SetDiffCellData (Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
		{
			try {
				CellRendererDiff cellRendererDiff = (CellRendererDiff)cell;
				Change change = store.GetValue (iter, objColumn) as Change;
				cellRendererDiff.Visible = !(bool)store.GetValue (iter, statusVisibleColumn);
				if (change == null || !cellRendererDiff.Visible) {
					cellRendererDiff.InitCell (treeviewPreview, false, "", "");
					return;
				}
				TextReplaceChange replaceChange = change as TextReplaceChange;
				if (replaceChange == null) 
					return;
			
				var openDocument = IdeApp.Workbench.GetDocument (replaceChange.FileName);
				Mono.TextEditor.TextDocument originalDocument = new Mono.TextEditor.TextDocument ();
				originalDocument.FileName = replaceChange.FileName;
				if (openDocument == null) {
					originalDocument.Text = Mono.TextEditor.Utils.TextFileUtility.ReadAllText (replaceChange.FileName);
				} else {
					originalDocument.Text = openDocument.Editor.Document.Text;
				}
				
				Mono.TextEditor.TextDocument changedDocument = new Mono.TextEditor.TextDocument ();
				changedDocument.FileName = replaceChange.FileName;
				changedDocument.Text = originalDocument.Text;
				
				changedDocument.Replace (replaceChange.Offset, replaceChange.RemovedChars, replaceChange.InsertedText);
				
				string diffString = Mono.TextEditor.Utils.Diff.GetDiffString (originalDocument, changedDocument);
				
				cellRendererDiff.InitCell (treeviewPreview, true, diffString, replaceChange.FileName);
			} catch (Exception e) {
				Console.WriteLine (e);
			}
		}
Exemple #6
0
			public virtual void Redo (TextDocument doc, bool fireEvent = true)
			{
				doc.Replace (args.Offset, args.RemovalLength, args.InsertedText.Text);
				if (fireEvent)
					OnRedoDone ();
			}