Inheritance: WeifenLuo.WinFormsUI.Docking.DockContent
 public string GetSubstitutedContent(Editor edit)
 {
     string content = Content.Replace("$selection", edit.Tb.SelectedText)
         .Replace("$current_line", edit.Tb[edit.Tb.Selection.Start.iLine].Text)
         .Replace("$file_name_extension", edit.Text)
         .Replace("$file_name", Path.GetFileNameWithoutExtension(edit.Text))
         .Replace("$eol", "\r\n").Replace("$clipboard", Clipboard.GetText());
     if (Content.Contains("$choose_file"))
     {
         using (var dlg = new OpenFileDialog())
         {
             var result = dlg.ShowDialog();
             if (result == DialogResult.OK)
                 Content = Content.Replace("$choose_file", dlg.FileName);
         }
     }
     return content;
 }
Beispiel #2
0
 public static IEnumerable<AutocompleteItem> GetPlaces(Editor edit)
 {
     if (dic == null)
     {
         string json = File.ReadAllText(Path.Combine(GlobalSettings.SettingsDir, "Symbols.json"));
         dic = JsonConvert.DeserializeObject<Dictionary<string, Regex>>(json);
     }
     var lst = new List<AutocompleteItem>();
     Regex re;
     dic.TryGetValue(edit.Tb.Language, out re);
     if (re == null)
         return null;
     var matches = re.Matches(edit.Tb.Text);
     foreach (Match match in matches)
     {
         var symbol = match.Value;
         symbol = symbol.Substring(symbol.LastIndexOf(' ')).Trim();
         lst.Add(new FuzzyAutoCompleteItem(symbol) {Tag = match.Groups[1].Index});
     }
     return lst;
 }