107
101
if (frame == null || textEditor == null)
109
103
int newX = textEditor.Allocation.Width - Allocation.Width - 8;
110
TextEditorContainer.EditorContainerChild containerChild = ((TextEditorContainer.EditorContainerChild)textEditorContainer [frame]);
104
TextEditor.EditorContainerChild containerChild = ((TextEditor.EditorContainerChild)textEditor [frame]);
111
105
if (newX != containerChild.X) {
112
106
searchEntry.WidthRequest = textEditor.Allocation.Width / 3;
113
107
containerChild.X = newX;
114
textEditorContainer.QueueResize ();
108
textEditor.QueueResize ();
112
static string GetShortcut (object commandId)
114
var key = IdeApp.CommandService.GetCommand (commandId).AccelKey;
115
if (string.IsNullOrEmpty (key))
117
var nextShortcut = KeyBindingManager.BindingToDisplayLabel (key, false);
118
return "(" + nextShortcut + ")";
118
121
public SearchAndReplaceWidget (TextEditor textEditor, Widget frame)
123
if (textEditor == null)
124
throw new ArgumentNullException ("textEditor");
120
125
this.textEditor = textEditor;
121
textEditorContainer = textEditor.Parent as TextEditorContainer;
122
126
this.frame = frame;
123
textEditorContainer.SizeAllocated += HandleViewTextEditorhandleSizeAllocated;
127
textEditor.SizeAllocated += HandleViewTextEditorhandleSizeAllocated;
124
128
textEditor.TextViewMargin.SearchRegionsUpdated += HandleWidgetTextEditorTextViewMarginSearchRegionsUpdated;
125
129
textEditor.Caret.PositionChanged += HandleWidgetTextEditorCaretPositionChanged;
126
130
SizeAllocated += HandleViewTextEditorhandleSizeAllocated;
439
453
public void UpdateSearchPattern ()
441
searchEntry.Entry.Text = textEditor.SearchPattern;
455
searchEntry.Entry.Text = textEditor.SearchPattern ?? "";
442
456
SetSearchPattern (textEditor.SearchPattern);
443
searchPattern = textEditor.SearchPattern;
457
SearchAndReplaceOptions.SearchPattern = textEditor.SearchPattern;
444
458
// UpdateSearchEntry ();
446
461
int curSearchResult = -1;
447
462
string curSearchPattern = null;
448
464
private void OnNavigateKeyPressEvent (object o, KeyPressEventArgs args)
450
466
args.RetVal = false;
451
467
switch (args.Event.Key) {
453
case Gdk.Key.KP_Enter:/*
469
case Gdk.Key.KP_Enter:/*
454
470
I think this is not needed, this code leads to a search twice bug when you hit return.
455
471
But I leave it in in the case I've missed something. Mike
456
472
if (o == buttonSearchBackward || o == buttonSearchForward) {
457
473
if (!((Button)o).HasFocus)
458
474
((Button)o).Click ();
463
if (o != searchEntry.Entry) {
467
if ((args.Event.State & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask && o == searchEntry.Entry) {
468
searchEntry.PopupFilterMenu ();
470
if (curSearchResult == -1)
471
curSearchPattern = searchEntry.Entry.Text;
479
if (o != searchEntry.Entry) {
483
if ((args.Event.State & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask && o == searchEntry.Entry) {
484
searchEntry.PopupFilterMenu ();
486
if (curSearchResult == -1)
487
curSearchPattern = searchEntry.Entry.Text;
473
List<string> history = GetHistory (seachHistoryProperty);
474
if (history.Count > 0) {
475
curSearchResult += args.Event.Key == Gdk.Key.Up ? -1 : 1;
476
if (curSearchResult >= history.Count)
477
curSearchResult = -1;
478
if (curSearchResult == -1) {
479
searchEntry.Entry.Text = curSearchPattern;
481
if (curSearchResult < -1)
482
curSearchResult = history.Count - 1;
489
List<string> history = GetHistory (seachHistoryProperty);
490
if (history.Count > 0) {
491
curSearchResult += args.Event.Key == Gdk.Key.Up ? -1 : 1;
492
if (curSearchResult >= history.Count)
493
curSearchResult = -1;
494
if (curSearchResult == -1) {
495
searchEntry.Entry.Text = curSearchPattern;
497
if (curSearchResult < -1)
498
curSearchResult = history.Count - 1;
484
searchEntry.Entry.Text = history[curSearchResult];
486
searchEntry.Entry.Position = -1;
493
buttonSearchForward.GrabFocus ();
494
buttonSearchForward.Click ();
498
buttonSearchBackward.GrabFocus ();
499
buttonSearchBackward.Click ();
502
RemoveSearchWidget ();
505
searchEntry.GrabFocus ();
507
case Gdk.Key.ISO_Left_Tab:
508
if (this.IsReplaceMode) {
509
if (o == entryReplace) {
510
searchEntry.Entry.GrabFocus ();
511
} else if (o == buttonReplace) {
512
entryReplace.GrabFocus ();
513
} else if (o == buttonReplaceAll) {
514
buttonReplace.GrabFocus ();
515
} else if (o == buttonSearchBackward) {
516
buttonReplaceAll.GrabFocus ();
517
} else if (o == buttonSearchForward) {
518
buttonSearchBackward.GrabFocus ();
520
buttonSearchForward.GrabFocus ();
524
if (o == buttonSearchBackward) {
525
searchEntry.Entry.GrabFocus ();
526
} else if (o == buttonSearchForward) {
527
buttonSearchBackward.GrabFocus ();
529
buttonSearchForward.GrabFocus ();
535
if (this.IsReplaceMode) {
536
if (o == entryReplace) {
537
buttonReplace.GrabFocus ();
538
} else if (o == buttonReplace) {
539
buttonReplaceAll.GrabFocus ();
540
} else if (o == buttonReplaceAll) {
541
buttonSearchBackward.GrabFocus ();
542
} else if (o == buttonSearchBackward) {
543
buttonSearchForward.GrabFocus ();
544
} else if (o == buttonSearchForward) {
545
// textEditor.GrabFocus ();
546
searchEntry.Entry.GrabFocus ();
548
entryReplace.GrabFocus ();
552
if (o == buttonSearchBackward) {
553
buttonSearchForward.GrabFocus ();
554
} else if (o == buttonSearchForward) {
555
searchEntry.Entry.GrabFocus ();
556
// textEditor.GrabFocus ();
558
buttonSearchBackward.GrabFocus ();
500
searchEntry.Entry.Text = history [curSearchResult];
502
searchEntry.Entry.Position = -1;
509
buttonSearchForward.GrabFocus ();
510
buttonSearchForward.Click ();
514
buttonSearchBackward.GrabFocus ();
515
buttonSearchBackward.Click ();
518
RemoveSearchWidget ();
521
searchEntry.GrabFocus ();
523
case Gdk.Key.ISO_Left_Tab:
524
if (this.IsReplaceMode) {
525
if (o == entryReplace) {
526
searchEntry.Entry.GrabFocus ();
527
} else if (o == buttonReplace) {
528
entryReplace.GrabFocus ();
529
} else if (o == buttonReplaceAll) {
530
buttonReplace.GrabFocus ();
531
} else if (o == buttonSearchBackward) {
532
buttonReplaceAll.GrabFocus ();
533
} else if (o == buttonSearchForward) {
534
buttonSearchBackward.GrabFocus ();
536
buttonSearchForward.GrabFocus ();
540
if (o == buttonSearchBackward) {
541
searchEntry.Entry.GrabFocus ();
542
} else if (o == buttonSearchForward) {
543
buttonSearchBackward.GrabFocus ();
545
buttonSearchForward.GrabFocus ();
551
if (this.IsReplaceMode) {
552
if (o == entryReplace) {
553
buttonReplace.GrabFocus ();
554
} else if (o == buttonReplace) {
555
buttonReplaceAll.GrabFocus ();
556
} else if (o == buttonReplaceAll) {
557
buttonSearchBackward.GrabFocus ();
558
} else if (o == buttonSearchBackward) {
559
buttonSearchForward.GrabFocus ();
560
} else if (o == buttonSearchForward) {
561
// textEditor.GrabFocus ();
562
searchEntry.Entry.GrabFocus ();
564
entryReplace.GrabFocus ();
568
if (o == buttonSearchBackward) {
569
buttonSearchForward.GrabFocus ();
570
} else if (o == buttonSearchForward) {
571
searchEntry.Entry.GrabFocus ();
572
// textEditor.GrabFocus ();
574
buttonSearchBackward.GrabFocus ();