本文整理汇总了C#中TextEditor.CenterToCaret方法的典型用法代码示例。如果您正苦于以下问题:C# TextEditor.CenterToCaret方法的具体用法?C# TextEditor.CenterToCaret怎么用?C# TextEditor.CenterToCaret使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextEditor
的用法示例。
在下文中一共展示了TextEditor.CenterToCaret方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComparisonWidget
public ComparisonWidget (VersionControlDocumentInfo info)
{
this.info = info;
vAdjustment = new Adjustment (0, 0, 0, 0, 0, 0);
vAdjustment.Changed += HandleAdjustmentChanged;
leftVAdjustment = new Adjustment (0, 0, 0, 0, 0, 0);
Connect (leftVAdjustment, vAdjustment);
rightVAdjustment = new Adjustment (0, 0, 0, 0, 0, 0);
Connect (rightVAdjustment, vAdjustment);
vScrollBar = new VScrollbar (vAdjustment);
AddChild (vScrollBar);
vScrollBar.Hide ();
hAdjustment = new Adjustment (0, 0, 0, 0, 0, 0);
hAdjustment.Changed += HandleAdjustmentChanged;
leftHAdjustment = new Adjustment (0, 0, 0, 0, 0, 0);
Connect (leftHAdjustment, hAdjustment);
rightHAdjustment = new Adjustment (0, 0, 0, 0, 0, 0);
Connect (rightHAdjustment, hAdjustment);
leftHScrollBar = new HScrollbar (hAdjustment);
AddChild (leftHScrollBar);
rightHScrollBar = new HScrollbar (hAdjustment);
AddChild (rightHScrollBar);
originalEditor = new TextEditor ();
originalEditor.Caret.PositionChanged += CaretPositionChanged;
originalEditor.FocusInEvent += EditorFocusIn;
AddChild (originalEditor);
originalEditor.SetScrollAdjustments (leftHAdjustment, leftVAdjustment);
originalComboBox = new DropDownBox ();
originalComboBox.WindowRequestFunc = CreateComboBoxSelector;
originalComboBox.Text = "Local";
originalComboBox.Tag = originalEditor;
AddChild (originalComboBox);
diffEditor = new TextEditor ();
diffEditor.Caret.PositionChanged += CaretPositionChanged;
diffEditor.FocusInEvent += EditorFocusIn;
AddChild (diffEditor);
diffEditor.Document.ReadOnly = true;
diffEditor.SetScrollAdjustments (leftHAdjustment, leftVAdjustment);
this.vAdjustment.ValueChanged += delegate {
middleArea.QueueDraw ();
};
diffComboBox = new DropDownBox ();
diffComboBox.WindowRequestFunc = CreateComboBoxSelector;
diffComboBox.Text = "Base";
diffComboBox.Tag = diffEditor;
AddChild (diffComboBox);
overview = new OverviewRenderer (this);
AddChild (overview);
middleArea = new MiddleArea (this);
AddChild (middleArea);
prev = new Button ();
prev.Add (new Arrow (ArrowType.Up, ShadowType.None));
AddChild (prev);
prev.ShowAll ();
prev.Clicked += delegate {
if (this.Diff == null)
return;
originalEditor.GrabFocus ();
int line = originalEditor.Caret.Line;
int max = -1, searched = -1;
foreach (Diff.Hunk hunk in this.Diff) {
if (hunk.Same)
continue;
max = System.Math.Max (hunk.Right.Start, max);
if (hunk.Right.Start < line)
searched = System.Math.Max (hunk.Right.Start, searched);
}
if (max >= 0) {
originalEditor.Caret.Line = searched < 0 ? max : searched;
originalEditor.CenterToCaret ();
}
};
next = new Button ();
next.BorderWidth = 0;
next.Add (new Arrow (ArrowType.Down, ShadowType.None));
next.Clicked += delegate {
if (this.Diff == null)
return;
originalEditor.GrabFocus ();
int line = originalEditor.Caret.Line;
int min = Int32.MaxValue, searched = Int32.MaxValue;
foreach (Diff.Hunk hunk in this.Diff) {
//.........这里部分代码省略.........
示例2: FindPrevious
public static SearchResult FindPrevious (TextEditor textEditor)
{
SearchResult result = textEditor.FindPrevious (true);
textEditor.CenterToCaret ();
if (result == null) {
IdeApp.Workbench.StatusBar.ShowError (GettextCatalog.GetString ("Search pattern not found"));
} else if (result.SearchWrapped) {
IdeApp.Workbench.StatusBar.ShowMessage (
Stock.Find,
GettextCatalog.GetString ("Reached top, continued from bottom")
);
} else {
IdeApp.Workbench.StatusBar.ShowReady ();
}
return result;
}
示例3: FindNext
public static SearchResult FindNext (TextEditor textEditor)
{
textEditor.SearchPattern = SearchAndReplaceOptions.SearchPattern;
SearchResult result = textEditor.FindNext (true);
if (result == null)
return null;
textEditor.CenterToCaret ();
if (result == null) {
IdeApp.Workbench.StatusBar.ShowError (GettextCatalog.GetString ("Search pattern not found"));
} else if (result.SearchWrapped) {
IdeApp.Workbench.StatusBar.ShowMessage (
Stock.Find,
GettextCatalog.GetString ("Reached bottom, continued from top")
);
} else {
IdeApp.Workbench.StatusBar.ShowReady ();
}
return result;
}