Esempio n. 1
0
 void _OnGotLostFocus(bool got, _SciTextBox tb)
 {
     if (!_cRegex.Checked)
     {
         return;
     }
     if (got)
     {
         //use timer to avoid temporary focus problems, for example when tabbing quickly or closing active Regex window
         ATimer.After(70, _ => { if (tb.Focused)
                                 {
                                     _ShowRegexInfo(tb, false);
                                 }
                      });
     }
     else
     {
         if (_regexWindow.Window.Visible)
         {
             var c = AWnd.ThisThread.FocusedControl;
             if (c == null || (c != _tFind && c != _tReplace && c != _regexWindow.Window && c.TopLevelControl != _regexWindow.Window))
             {
                 _regexWindow.Hide();
             }
         }
     }
 }
Esempio n. 2
0
    public void RegexWindowShow(SciCode doc, string code, int pos16, TextSpan stringSpan, bool replace)
    {
        int j = stringSpan.Start, vi = _StringPrefixLength(code, j);

        if (!replace && (vi == 0 || !(code[j] == '@' || code[j + 1] == '@')))
        {
            ADialog.ShowInfo(null, "Regular expression string should be like @\"text\", not like \"text\". The Regex tool will not escape \\ when inserting text.");
        }

        if (_regexWindow == null)
        {
            _regexWindow             = new RegexWindow();
            _regexWindow.Window.Name = "Ci.Regex";             //prevent hiding when activated
        }

        var r = CiUtil.GetCaretRectFromPos(doc, pos16);
        int i = Au.Util.ADpi.ScaleInt(100);

        r.Width = i;
        r.Inflate(i, 0);
        _regexWindow.Show(doc, r, false, PopupAlignment.TPM_CENTERALIGN | PopupAlignment.TPM_VERTICAL);
        _regexWindow.InsertInControl = doc;
        var s = _regexWindow.CurrentTopic;

        if (s == "replace")
        {
            if (!replace)
            {
                _regexWindow.CurrentTopic = _regexTopic;
            }
        }
        else if (replace)
        {
            _regexTopic = s;
            _regexWindow.CurrentTopic = "replace";
        }
        doc.ZTempRanges_Add(this, stringSpan.Start + vi + 1, stringSpan.End - 1, onLeave: () => _regexWindow.Hide());
    }