• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript vscode.TextEditor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中vscode.TextEditor的典型用法代码示例。如果您正苦于以下问题:TypeScript TextEditor类的具体用法?TypeScript TextEditor怎么用?TypeScript TextEditor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TextEditor类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: runNormalMode

	public runNormalMode(ctrl: IController, ed:TextEditor, repeatCount: number, args: string): boolean {
		let register = ctrl.getDeleteRegister();
		if (!register) {
			// No delete register - beep!!
			return true;
		}

		let str = repeatString(register.content, repeatCount);

		let pos = this.pos(ed);
		if (!register.isWholeLine) {
			ed.edit((builder) => {
				builder.insert(new Position(pos.line, pos.character + 1), str);
			});
			return true;
		}

		let doc = this.doc(ed);
		let insertLine = pos.line + 1;
		let insertCharacter = 0;

		if (insertLine >=  doc.lineCount) {
			// on last line
			insertLine = doc.lineCount - 1;
			insertCharacter = doc.lineAt(insertLine).text.length;
			str = '\n' + str;
		}

		ed.edit((builder) => {
			builder.insert(new Position(insertLine, insertCharacter), str);
		});

		return true;
	}
开发者ID:DanEEStar,项目名称:vscode-vim,代码行数:34,代码来源:operators.ts


示例2: restore

    async restore(editor: TextEditor) {
        // If the editor isn't disposed then we don't need to do anything
        // Explicitly check for `false`
        if ((this.editor as any)._disposed === false) return;

        this.status = AnnotationStatus.Computing;
        if (editor === window.activeTextEditor) {
            await setCommandContext(CommandContext.AnnotationStatus, this.status);
        }

        this.editor = editor;
        this.correlationKey = AnnotationProviderBase.getCorrelationKey(editor);
        this.document = editor.document;

        if (this.decorations !== undefined && this.decorations.length) {
            this.editor.setDecorations(this.decoration, this.decorations);

            if (this.additionalDecorations !== undefined && this.additionalDecorations.length) {
                for (const d of this.additionalDecorations) {
                    this.editor.setDecorations(d.decoration, d.ranges);
                }
            }
        }

        this.status = AnnotationStatus.Computed;
        if (editor === window.activeTextEditor) {
            await setCommandContext(CommandContext.AnnotationStatus, this.status);
        }
    }
开发者ID:chrisleaman,项目名称:vscode-gitlens,代码行数:29,代码来源:annotationProvider.ts


示例3: updateCSSNode

function updateCSSNode(editor: TextEditor, property: Property): Thenable<boolean> {
	const rule: Rule = property.parent;
	let currentPrefix = '';

	// Find vendor prefix of given property node
	for (let i = 0; i < vendorPrefixes.length; i++) {
		if (property.name.startsWith(vendorPrefixes[i])) {
			currentPrefix = vendorPrefixes[i];
			break;
		}
	}

	const propertyName = property.name.substr(currentPrefix.length);
	const propertyValue = property.value;

	return editor.edit(builder => {
		// Find properties with vendor prefixes, update each
		vendorPrefixes.forEach(prefix => {
			if (prefix === currentPrefix) {
				return;
			}
			let vendorProperty = getCssPropertyFromRule(rule, prefix + propertyName);
			if (vendorProperty) {
				builder.replace(new Range(vendorProperty.valueToken.start, vendorProperty.valueToken.end), propertyValue);
			}
		});
	});
}
开发者ID:Chan-PH,项目名称:vscode,代码行数:28,代码来源:reflectCssValue.ts


示例4: px2em

export default async function px2em(textEditor: TextEditor, lastValue: string | undefined) {
  const doc = textEditor.document;
  const selections = getValidSelections(textEditor, doc);

  if (selections.length === 0) { return; }

  textEditor.selections = selections;

  let option: InputBoxOptions = {
    placeHolder: '请输入font-size的基准值',
    prompt: '单位为px或rem,当单位为px时,可省略px。',
    value: lastValue,
  };

  let input = await window.showInputBox(option);
  if (hasInvalidInput(input)) { return; }

  let match = input.match(regex) as RegExpMatchArray;
  let factor = +match[1];
  let unit = match[2];

  if (!unit) { unit = 'px'; }
  lastValue = factor + unit;

  if (unit === 'rem') { factor *= config.htmlFontSize; }

  textEditor.edit((edit) => {
    convert(textEditor, edit, factor, 'em');
  });

  return lastValue;
}
开发者ID:Maroon1,项目名称:px2rem,代码行数:32,代码来源:px2em.ts


示例5: applypatches

/**
 * Applies the given set of patches to the document in the given editor
 *
 * @param patches array of patches to be applied
 * @param editor the TextEditor whose document will be updated
 */
function applypatches(patches: dmp.Patch[], editor: TextEditor): Thenable<boolean> {
	let totalEdits: Edit[] = [];
	patches.reverse().forEach((patch: dmp.Patch) => {
		// Godoctor provides a diff for each line, but the text accompanying the diff does not end with '\n'
		// GetEditsFromDiffs(..) expects the '\n' to exist in the text wherever there is a new line.
		// So add one for each diff from getdoctor
		for (let i = 0; i < patch.diffs.length; i++) {
			patch.diffs[i][1] += '\n';
		}
		let edits = GetEditsFromDiffs(patch.diffs, patch.start1);
		totalEdits = totalEdits.concat(edits);
	});

	return editor.edit((editBuilder) => {
		totalEdits.forEach((edit) => {
			switch (edit.action) {
				case EditTypes.EDIT_INSERT:
					editBuilder.insert(edit.start, edit.text);
					break;
				case EditTypes.EDIT_DELETE:
					editBuilder.delete(new Range(edit.start, edit.end));
					break;
				case EditTypes.EDIT_REPLACE:
					editBuilder.replace(new Range(edit.start, edit.end), edit.text);
					break;
			}
		});
	});
}
开发者ID:oliverkofoed,项目名称:vscode-go,代码行数:35,代码来源:goExtractMethod.ts


示例6: runVisualMode

	public runVisualMode(ctrl: IController, ed:TextEditor, args: string): boolean {
		if (args.length === 0) {
			// input not ready
			return false;
		}

		let doc = this.doc(ed);
		let sel = this.sel(ed);

		let srcString = doc.getText(sel);
		let dstString = '';
		for (let i = 0; i < srcString.length; i++) {
			let ch = srcString.charAt(i);
			if (ch === '\r' || ch === '\n') {
				dstString += ch;
			} else {
				dstString += args;
			}
		}

		ed.edit((builder) => {
			builder.replace(sel, dstString);
		});

		return true;
	}
开发者ID:DanEEStar,项目名称:vscode-vim,代码行数:26,代码来源:operators.ts


示例7: update_editor

export function update_editor(editor: TextEditor)
{
  if (editor) {
    const decorations = document_decorations.get(editor.document.uri.toString())
    if (decorations) {
      for (const [typ, content] of decorations) {
        editor.setDecorations(types.get(typ), content)
      }
    }
  }
}
开发者ID:seL4,项目名称:isabelle,代码行数:11,代码来源:decorations.ts


示例8: function

 const setText = async function (editor: TextEditor, text: string) {
     return editor.edit((editBuilder: TextEditorEdit) => {
         const doc = editor.document;
         const startPos = new Position(0, 0);
         const lastLine = doc.lineAt(doc.lineCount - 1);
         const endPos = lastLine.range.end;
         const entireRange = new Range(startPos, endPos);
         editBuilder.replace(entireRange, text);
         editBuilder.setEndOfLine(EndOfLine.LF);
     });
 };
开发者ID:sgryjp,项目名称:japanese-word-handler,代码行数:11,代码来源:extension.test.ts


示例9: clear

    clear() {
        this.status = undefined;
        if (this.editor === undefined) return;

        if (this.decoration !== undefined) {
            try {
                this.editor.setDecorations(this.decoration, []);
            }
            catch {}
        }

        if (this.additionalDecorations !== undefined && this.additionalDecorations.length > 0) {
            for (const d of this.additionalDecorations) {
                try {
                    this.editor.setDecorations(d.decoration, []);
                }
                catch {}
            }

            this.additionalDecorations = undefined;
        }

        if (this.highlightDecoration !== undefined) {
            try {
                this.editor.setDecorations(this.highlightDecoration, []);
            }
            catch {}
        }
    }
开发者ID:chrisleaman,项目名称:vscode-gitlens,代码行数:29,代码来源:annotationProvider.ts


示例10:

			.then((res: DocCommandTemplateResponse) => {
				if (!res || !res.body) {
					return false;
				}
				return editor.insertSnippet(
					this.templateToSnippet(res.body.newText),
					position,
					{ undoStopBefore: false, undoStopAfter: true });
			}, () => false);
开发者ID:yuit,项目名称:vscode,代码行数:9,代码来源:jsDocCompletionProvider.ts



注:本文中的vscode.TextEditor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript vscode.TextEditorEdit类代码示例发布时间:2022-05-25
下一篇:
TypeScript vscode.TextEdit类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap