OffsetToLocation() public method

public OffsetToLocation ( int offset ) : DocumentLocation
offset int
return DocumentLocation
    void SetLocationTextData (Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
    {
        CellRendererText cellRendererText = (CellRendererText)cell;
        Change change = store.GetValue (iter, objColumn) as Change;
        cellRendererText.Visible = (bool)store.GetValue (iter, statusVisibleColumn);
        TextReplaceChange replaceChange = change as TextReplaceChange;
        if (replaceChange == null)
        {
            cellRendererText.Text = "";
            return;
        }

        Mono.TextEditor.TextDocument doc = new Mono.TextEditor.TextDocument ();
        doc.Text = Mono.TextEditor.Utils.TextFileUtility.ReadAllText (replaceChange.FileName);
        DocumentLocation loc = doc.OffsetToLocation (replaceChange.Offset);

        string text = string.Format (GettextCatalog.GetString ("(Line:{0}, Column:{1})"), loc.Line, loc.Column);
        if (treeviewPreview.Selection.IterIsSelected (iter))
        {
            cellRendererText.Text = text;
        }
        else
        {
            cellRendererText.Markup = "<span foreground=\"" + MonoDevelop.Components.PangoCairoHelper.GetColorString (Style.Text (StateType.Insensitive)) + "\">" + text + "</span>";
        }
    }
Example #2
0
        public void GetLineColumnFromPosition(int position, out int line, out int column)
        {
            DocumentLocation loc = document.OffsetToLocation(position);

            line   = loc.Line;
            column = loc.Column;
        }
Example #3
0
        CSharpCompletionTextEditorExtension CreateCompletion(MonoDevelop.Ide.Gui.Document realDocument, DocumentInfo info, LocalDocumentInfo localInfo, out CodeCompletionContext codeCompletionContext)
        {
            var doc = new Mono.TextEditor.TextDocument()
            {
                Text = localInfo.LocalDocument,
            };
            var documentLocation = doc.OffsetToLocation(localInfo.CaretPosition);

            codeCompletionContext = new CodeCompletionContext()
            {
                TriggerOffset     = localInfo.CaretPosition,
                TriggerLine       = documentLocation.Line,
                TriggerLineOffset = documentLocation.Column - 1
            };

            return(new CSharpCompletionTextEditorExtension(localInfo.HiddenDocument)
            {
                CompletionWidget = CreateCompletionWidget(realDocument, localInfo)
            });
        }
		void SetLocationTextData (Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
		{
			CellRendererText cellRendererText = (CellRendererText)cell;
			Change change = store.GetValue (iter, objColumn) as Change;
			cellRendererText.Visible = (bool)store.GetValue (iter, statusVisibleColumn);
			TextReplaceChange replaceChange = change as TextReplaceChange;
			if (replaceChange == null) {
				cellRendererText.Text = "";
				return;
			}
			
			Mono.TextEditor.TextDocument doc = new Mono.TextEditor.TextDocument ();
			doc.Text = Mono.TextEditor.Utils.TextFileUtility.ReadAllText (replaceChange.FileName);
			DocumentLocation loc = doc.OffsetToLocation (replaceChange.Offset);
			
			string text = string.Format (GettextCatalog.GetString ("(Line:{0}, Column:{1})"), loc.Line, loc.Column);
			if (treeviewPreview.Selection.IterIsSelected (iter)) {
				cellRendererText.Text = text;
			} else {
				cellRendererText.Markup = "<span foreground=\"" + MonoDevelop.Components.PangoCairoHelper.GetColorString (Style.Text (StateType.Insensitive)) + "\">" + text + "</span>";
			}
		}
Example #5
0
            public CodeLocation ToLocation(int offset)
            {
                var dl = doc.OffsetToLocation(offset);

                return(new CodeLocation(dl.Column, dl.Line));
            }
		CSharpCompletionTextEditorExtension CreateCompletion (MonoDevelop.Ide.Gui.Document realDocument, DocumentInfo info, LocalDocumentInfo localInfo, out CodeCompletionContext codeCompletionContext)
		{
			var doc = new Mono.TextEditor.TextDocument () {
				Text = localInfo.LocalDocument,
			};
			var documentLocation = doc.OffsetToLocation (localInfo.CaretPosition);
			
			codeCompletionContext = new CodeCompletionContext () {
				TriggerOffset = localInfo.CaretPosition,
				TriggerLine = documentLocation.Line,
				TriggerLineOffset = documentLocation.Column - 1
			};
			
			return new CSharpCompletionTextEditorExtension (localInfo.HiddenDocument) {
				CompletionWidget = CreateCompletionWidget (realDocument, localInfo)
			};
		}
Example #7
0
            public D_Parser.Dom.CodeLocation ToLocation(int offset)
            {
                var dl = doc.OffsetToLocation(offset);

                return(new D_Parser.Dom.CodeLocation(dl.Column, dl.Line));
            }