예제 #1
0
        private static void BuildAutocompleteItemsFromResourse(string file, int imageIndex, string toolTipText, AutocompleteItems itemsList, DefKind kind)
        {
            string   section  = "";
            string   filter   = "";
            Assembly assembly = Assembly.GetExecutingAssembly();
            Stream   stream   = assembly.GetManifestResourceStream(file);
            try {
                if (stream != null) {
                    using (var reader = new StreamReader(stream)) {
                        stream = null; string line;
                        while ((line = reader.ReadLine()) != null) {
                            var m = Regex.Match(line, @"^\*\s*?\[(.*)\]"); if (m.Success) { section = m.Groups[1].Value.Trim(); continue; }
                                m = Regex.Match(line, @"^\*(sm\w+)"     ); if (m.Success) { filter  = m.Groups[1].Value.Trim(); continue; }
                            if (filter == "smAll") filter = "";
                            if (line.StartsWith("*") || (line.Trim().Length == 0)) continue; // Skip comments and blank lines
                            int indent = line.Length - line.TrimStart().Length;
                            HMSItem item;
                            if (indent == 0) {
                                item = GetHmsItemFromLine(line);
                                item.ImageIndex  = imageIndex;
                                item.ToolTipText = toolTipText + ((section.Length > 0) ? (" ("+ section + ")") : "");
                                item.Kind        = kind;
                                item.Filter      = filter;
                                if (kind == DefKind.Function) item.Kind = (item.Type.Length > 0) ? DefKind.Function : DefKind.Procedure;
                                itemsList.Add(item);
                            } else if ((indent == 2) || (line[0] == '\t')) {
                                // it's help for parameters of last method
                                if (itemsList.Count > 0) {
                                    item = itemsList[itemsList.Count - 1];
                                    item.Params.Add(StylishHelp(line));
                                }
                            }
                        }
                    }
                }

            } catch (Exception e) {
                LogError(e.ToString());

            } finally {
                stream?.Dispose();
            }
        }
예제 #2
0
 private void SearchAutocompleteItemsInScriptDescrition(Regex reBlock, ref string xml, int imageIndex, string toolTipText, DefKind kind, AutocompleteItems Items)
 {
     string xmlBlock = reBlock.Match(xml).Value;
     MatchCollection mc = regexCutItem.Matches(xmlBlock);
     foreach (Match matchItem in mc) {
         var text = kind == DefKind.Function ? regexCutTextF.Match(matchItem.Value).Groups[1].Value : regexCutText.Match(matchItem.Value).Groups[1].Value;
         var descr = regexCutDesc.Match(matchItem.Value).Groups[1].Value;
         if (text.Length==0) continue;
         var item = HMS.GetHmsItemFromLine(text);
         item.ImageIndex  = imageIndex;
         item.ToolTipText = toolTipText;
         item.Kind        = kind;
         item.Help        = descr;
         if (kind == DefKind.Function) item.Kind = (item.Type.Length > 0) ? DefKind.Function : DefKind.Procedure;
         if (regexExcludeConst.IsMatch(item.MenuText)) continue;
         var foundItem = Items.GetItemOrNull(item.MenuText);
         if (foundItem!=null) {
             if (foundItem.Help.Length == 0) foundItem.Help = descr;
         } else {
             ScriptAutocompleteItems.Add(item);
             //Console.WriteLine(kind.ToString() + " MenuText: " + item.MenuText);
         }
     }
 }
예제 #3
0
 protected LangOrTransDef(DefKind kind, FastSort domain)
     : base(kind)
 {
     this.domain = domain;
 }
예제 #4
0
        private static void BuildAutocompleteItemsFromResourse(string file, int imageIndex, string toolTipText, AutocompleteItems itemsList, DefKind kind)
        {
            string   section  = "";
            string   filter   = "";
            Assembly assembly = Assembly.GetExecutingAssembly();
            Stream   stream   = assembly.GetManifestResourceStream(file);

            try {
                using (StreamReader reader = new StreamReader(stream)) {
                    stream = null; string line; HMSItem item = null; Match m;
                    while ((line = reader.ReadLine()) != null)
                    {
                        m = Regex.Match(line, @"^\*\s*?\[(.*)\]"); if (m.Success)
                        {
                            section = m.Groups[1].Value.Trim(); continue;
                        }
                        m = Regex.Match(line, @"^\*sm\w+\s*?<(.*?)>"); if (m.Success)
                        {
                            filter = m.Groups[1].Value.Trim(); continue;
                        }
                        if (filter == "-")
                        {
                            continue;
                        }
                        if (line.StartsWith("*") || (line.Trim().Length == 0))
                        {
                            continue;                                                    // Skip comments and blank lines
                        }
                        int indent = line.Length - line.TrimStart().Length;
                        if (indent == 0)
                        {
                            item             = GetHmsItemFromLine(line);
                            item.ImageIndex  = imageIndex;
                            item.ToolTipText = toolTipText + ((section.Length > 0) ? (" (" + section + ")") : "");
                            item.Kind        = kind;
                            item.Filter      = filter;
                            if (kind == DefKind.Function)
                            {
                                item.Kind = (item.Type.Length > 0) ? DefKind.Function : DefKind.Procedure;
                            }
                            itemsList.Add(item);
                        }
                        else if ((indent == 2) || (line[0] == '\t'))
                        {
                            // it's help for parameters of last method
                            if (itemsList.Count > 0)
                            {
                                item = itemsList[itemsList.Count - 1];
                                item.Params.Add(StylishHelp(line));
                            }
                        }
                    }
                }
            } catch (Exception e) {
                HMS.LogError(e.ToString());
            } finally {
                if (stream != null)
                {
                    stream.Dispose();
                }
            }
        }
예제 #5
0
 protected Def(DefKind kind)
 {
     this.kind = kind;
 }