- 实例方法
- findMatches() 查找文本
- getOptions
- setValue
- getValue
- getValueInRange(range)
- getLineContent(lineNumber) 获取指定行的文本字符串
- getLinesContent() 获取所有行的文本字符串的集合
- getValueLength 获取文本长度
- getLineLength 获取指定行的文本长度
- getValueLengthInRange 获取指定范围的文本长度
- getCharacterCountInRange
- getWordUntilPosition
- getLineCount() 获取行数
- getEOL
- getEndOfLineSequence() 获取行尾序列
实例方法
findMatches() 查找文本
/*** Search the model.* @param searchString The string used to search. If it is a regular expression, set `isRegex` to true.* @param searchOnlyEditableRange Limit the searching to only search inside the editable range of the model.* @param isRegex Used to indicate that `searchString` is a regular expression.* @param matchCase Force the matching to match lower/upper case exactly.* @param wordSeparators Force the matching to match entire words only. Pass null otherwise.* @param captureMatches The result will contain the captured groups.* @param limitResultCount Limit the number of results* @return The ranges where the matches are. It is empty if not matches have been found.*/findMatches(searchString: string, searchOnlyEditableRange: boolean, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean, limitResultCount?: number): FindMatch[];
功能和 “⌘ + F” 一致,通过字符串或正则表达式查找编辑器内匹配的文本,并返回匹配文本 range 的集合。
getOptions
setValue
setValue(newValue: string | ITextSnapshot): void;
getValue
/*** Get the text stored in this model.* @param eol The end of line character preference. Defaults to `EndOfLinePreference.TextDefined`.* @param preserverBOM Preserve a BOM character if it was detected when the model was constructed.* @return The text.*/getValue(eol?: EndOfLinePreference, preserveBOM?: boolean): string;
getValueInRange(range)
通过 range 获取范围内的文本,返回一个字符串。
monacoCompletionProvide = monaco.languages.registerCompletionItemProvider('lua', {provideCompletionItems: function (model, position) {let textUntilPosition = model.getValueInRange({startLineNumber: position.lineNumber,startColumn: 1,endLineNumber: position.lineNumber,endColumn: position.column})let suggestions = createCompleters(textUntilPosition)console.log("🚀 ~ file: Index.vue ~ line 84 ~ init ~ suggestions", suggestions)return {suggestions: suggestions}}})
getLineContent(lineNumber) 获取指定行的文本字符串
/*** Get the text for a certain line.*/getLineContent(lineNumber: number): string;
getLinesContent() 获取所有行的文本字符串的集合
返回所有行的文本字符串的集合。
/*** Get the text for all lines.*/getLinesContent(): string[];
getValueLength 获取文本长度
/*** Get the length of the text stored in this model.*/getValueLength(eol?: EndOfLinePreference, preserveBOM?: boolean): number;
包含 \n, \t 等符号
getLineLength 获取指定行的文本长度
/*** Get the text length for a certain line.*/getLineLength(lineNumber: number): number;
getValueLengthInRange 获取指定范围的文本长度
getCharacterCountInRange
getWordUntilPosition
获取在指定行列位置的字符
getWordUntilPosition(position: IPosition): IWordAtPosition;export interface IPosition {/*** line number (starts at 1)*/readonly lineNumber: number;/*** column (the first character in a line is between column 1 and column 2)*/readonly column: number;}/*** Word inside a model.*/export interface IWordAtPosition {/*** The word.*/readonly word: string;/*** The column where the word starts.*/readonly startColumn: number;/*** The column where the word ends.*/readonly endColumn: number;}
getLineCount() 获取行数
/*** Get the number of lines in the model.*/getLineCount(): number;
getEOL
/*** Get the end of line sequence predominantly used in the text buffer.* @return EOL char sequence (e.g.: '\n' or '\r\n').*/getEOL(): string;
getEndOfLineSequence() 获取行尾序列
/*** Get the end of line sequence predominantly used in the text buffer.*/getEndOfLineSequence(): EndOfLineSequence;

