本文整理汇总了C#中MonoDevelop.Ide.Gui.TextEditor.OffsetToLocation方法的典型用法代码示例。如果您正苦于以下问题:C# TextEditor.OffsetToLocation方法的具体用法?C# TextEditor.OffsetToLocation怎么用?C# TextEditor.OffsetToLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoDevelop.Ide.Gui.TextEditor
的用法示例。
在下文中一共展示了TextEditor.OffsetToLocation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowTooltipWindow
public override void ShowTooltipWindow (TextEditor editor, Control tipWindow, TooltipItem item, Gdk.ModifierType modifierState, int mouseX, int mouseY)
{
var location = editor.OffsetToLocation (item.Offset);
var point = editor.LocationToPoint (location);
int lineHeight = (int) editor.LineHeight;
int y = (int)point.Y;
// find the top of the line that the mouse is hovering over
while (y + lineHeight < mouseY)
y += lineHeight;
var caret = new Gdk.Rectangle (mouseX, y, 1, lineHeight);
tooltip = (DebugValueWindow)tipWindow;
tooltip.ShowPopup (editor, caret, PopupPosition.TopLeft);
}
示例2: InsertTemplateContents
/// <summary>
/// Don't use this unless you're implementing ICodeTemplateWidget. Use Insert instead.
/// </summary>
public TemplateResult InsertTemplateContents (TextEditor editor, DocumentContext context)
{
var data = editor;
int offset = data.CaretOffset;
// string leadingWhiteSpace = GetLeadingWhiteSpace (editor, editor.CursorLine);
var templateCtx = new TemplateContext {
Template = this,
DocumentContext = context,
Editor = editor,
//ParsedDocument = context.ParsedDocument != null ? context.ParsedDocument.ParsedFile : null,
InsertPosition = data.CaretLocation,
LineIndent = data.GetLineIndent (data.CaretLocation.Line),
TemplateCode = Code
};
if (data.IsSomethingSelected) {
int start = data.SelectionRange.Offset;
while (Char.IsWhiteSpace (data.GetCharAt (start))) {
start++;
}
int end = data.SelectionRange.EndOffset;
while (Char.IsWhiteSpace (data.GetCharAt (end - 1))) {
end--;
}
templateCtx.LineIndent = data.GetLineIndent (data.OffsetToLineNumber (start));
templateCtx.SelectedText = RemoveIndent (data.GetTextBetween (start, end), templateCtx.LineIndent);
data.RemoveText (start, end - start);
offset = start;
} else {
string word = GetTemplateShortcutBeforeCaret (data).Trim ();
if (word.Length > 0)
offset = DeleteTemplateShortcutBeforeCaret (data);
}
TemplateResult template = FillVariables (templateCtx);
template.InsertPosition = offset;
editor.InsertText (offset, template.Code);
int newoffset;
if (template.CaretEndOffset >= 0) {
newoffset = offset + template.CaretEndOffset;
} else {
newoffset = offset + template.Code.Length;
}
editor.CaretLocation = editor.OffsetToLocation (newoffset) ;
var prettyPrinter = CodeFormatterService.GetFormatter (data.MimeType);
if (prettyPrinter != null && prettyPrinter.SupportsOnTheFlyFormatting) {
int endOffset = template.InsertPosition + template.Code.Length;
var oldVersion = data.Version;
prettyPrinter.OnTheFlyFormat (editor, context, TextSegment.FromBounds (template.InsertPosition, endOffset));
foreach (var textLink in template.TextLinks) {
for (int i = 0; i < textLink.Links.Count; i++) {
var segment = textLink.Links [i];
var translatedOffset = oldVersion.MoveOffsetTo (data.Version, template.InsertPosition + segment.Offset) - template.InsertPosition;
textLink.Links [i] = new TextSegment (translatedOffset, segment.Length);
}
}
}
return template;
}
示例3: JumpToCurrentLocation
protected void JumpToCurrentLocation (TextEditor editor)
{
if (version.BelongsToSameDocumentAs (editor.Version)) {
var currentOffset = version.MoveOffsetTo (editor.Version, offset);
var loc = editor.OffsetToLocation (currentOffset);
editor.SetCaretLocation (loc);
} else {
editor.SetCaretLocation (Math.Max (line, 1), Math.Max (column, 1));
}
}