GetTextOnLeftOfPos() публичный статический Метод

returns the text on the left of the position... it will always return empty string at minima
public static GetTextOnLeftOfPos ( int curPos, int maxLenght = KeywordMaxLength ) : string
curPos int
maxLenght int
Результат string
Пример #1
0
        /// <summary>
        /// Called when the user has finished entering a word
        /// Called after the UI has updated, allows to correctly read the text style, to correct
        /// the indentation w/o it being erased and so on...
        /// </summary>
        /// <param name="c"></param>
        public static void OnCharAddedWordEnd(char c)
        {
            try {
                // we finished entering a keyword
                var curPos = Npp.CurrentPosition;
                int offset;
                if (c == '\n')
                {
                    offset  = curPos - Npp.GetLine().Position;
                    offset += (Npp.GetTextOnLeftOfPos(curPos - offset, 2).Equals("\r\n")) ? 2 : 1;
                }
                else
                {
                    offset = 1;
                }
                var searchWordAt    = curPos - offset;
                var keyword         = Npp.GetKeyword(searchWordAt);
                var isNormalContext = Style.IsCarretInNormalContext(searchWordAt);

                if (!String.IsNullOrWhiteSpace(keyword) && isNormalContext)
                {
                    string replacementWord = null;

                    // automatically insert selected keyword of the completion list
                    if (Config.Instance.AutoCompleteInsertSelectedSuggestionOnWordEnd && keyword.ContainsAtLeastOneLetter())
                    {
                        if (AutoComplete.IsVisible)
                        {
                            var lastSugg = AutoComplete.GetCurrentSuggestion();
                            if (lastSugg != null)
                            {
                                replacementWord = lastSugg.DisplayText;
                            }
                        }
                    }

                    // replace abbreviation by completekeyword
                    if (Config.Instance.CodeReplaceAbbreviations)
                    {
                        var fullKeyword = Keywords.GetFullKeyword(replacementWord ?? keyword);
                        if (fullKeyword != null)
                        {
                            replacementWord = fullKeyword;
                        }
                    }

                    // replace the last keyword by the correct case
                    var casedKeyword = AutoComplete.CorrectKeywordCase(replacementWord ?? keyword, searchWordAt);
                    if (casedKeyword != null)
                    {
                        replacementWord = casedKeyword;
                    }

                    if (replacementWord != null)
                    {
                        Npp.ReplaceKeywordWrapped(replacementWord, -offset);
                    }
                }


                // replace semicolon by a point
                if (c == ';' && Config.Instance.CodeReplaceSemicolon && isNormalContext)
                {
                    Npp.ModifyTextAroundCaret(-1, 0, ".");
                }

                // handles the autocompletion
                AutoComplete.UpdateAutocompletion();
            } catch (Exception e) {
                ErrorHandler.ShowErrors(e, "Error in OnCharAddedWordEnd");
            }
        }