当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript commands.registerTextEditorCommand方法代码示例

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


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

示例1: registerCommands

 private registerCommands(subscriptions: vscode.Disposable[]): void {
     subscriptions.push(
         vscode.commands.registerTextEditorCommand('trailing-spaces.deleteTrailingSpaces', this.trailingSpaces.delete, this.trailingSpaces),
         vscode.commands.registerTextEditorCommand('trailing-spaces.deleteTrailingSpacesModifiedLinesOnly', this.trailingSpaces.deleteModifiedLinesOnly, this.trailingSpaces),
         vscode.commands.registerTextEditorCommand('trailing-spaces.highlightTrailingSpaces', this.trailingSpaces.highlight, this.trailingSpaces)
     )
 }
开发者ID:shardulm94,项目名称:vscode-trailingspaces,代码行数:7,代码来源:loader.ts

示例2: activate

export function activate(context: vs.ExtensionContext): void {
    context.subscriptions.push(vs.commands.registerTextEditorCommand("docthis.documentThis", (editor, edit) => {
        const commandName = "Document This";

        runCommand(commandName, editor.document, () => {
            documenter.documentThis(editor, edit, commandName);
        });
    }));

    context.subscriptions.push(vs.commands.registerTextEditorCommand("docthis.documentEverything", (editor, edit) => {
        const commandName = "Document Everything";

        runCommand(commandName, editor.document, () => {
            documenter.documentEverything(editor, edit, false, commandName);
        });
    }));

    context.subscriptions.push(vs.commands.registerTextEditorCommand("docthis.documentEverythingVisible", (editor, edit) => {
        const commandName = "Document Everything Visible";

        runCommand(commandName, editor.document, () => {
            documenter.documentEverything(editor, edit, true, commandName);
        });
    }));

    context.subscriptions.push(vs.commands.registerTextEditorCommand("docthis.traceTypeScriptSyntaxNode", (editor, edit) => {
        const commandName = "Trace TypeScript Syntax Node";

        runCommand(commandName, editor.document, () => {
            documenter.traceNode(editor, edit);
        });
    }));
}
开发者ID:jamietre,项目名称:vscode-docthis,代码行数:33,代码来源:extension.ts

示例3: activate

export function activate(ctx: vsc.ExtensionContext) {
    console.log('activate extension');
    // expose global and workspace state to the entire extension
    GlobalState = ctx.globalState;
    WorkspaceState = ctx.workspaceState;
    
	// register palette commands
    ctx.subscriptions.push(
        vsc.commands.registerTextEditorCommand('xmlTools.minifyXml', TextEditorCommands.minifyXml),
        vsc.commands.registerTextEditorCommand('xmlTools.evaluateXPath', TextEditorCommands.evaluateXPath),
        vsc.commands.registerTextEditorCommand('xmlTools.executeXQuery', TextEditorCommands.executeXQuery),
        vsc.commands.registerTextEditorCommand('xmlTools.viewXmlTree', TextEditorCommands.viewXmlTree)
    );
	
	// register language feature providers
    ctx.subscriptions.push(
        vsc.languages.registerDocumentFormattingEditProvider(LANG_XML, new XmlFormattingEditProvider()),
        vsc.languages.registerDocumentRangeFormattingEditProvider(LANG_XML, new XmlFormattingEditProvider()),
        
        vsc.languages.registerCompletionItemProvider(LANG_XQUERY, new XQueryCompletionItemProvider(), ':', '$')
    );
    
    // register workspace feature providers
    ctx.subscriptions.push(
        vsc.workspace.registerTextDocumentContentProvider(XmlTreeDocumentContentProvider.SCHEME, new XmlTreeDocumentContentProvider())
    );
    
    // listen to editor events (for linting)
    ctx.subscriptions.push(
        vsc.window.onDidChangeActiveTextEditor(_handleChangeActiveTextEditor),
        vsc.window.onDidChangeTextEditorSelection(_handleChangeTextEditorSelection)
    );
}
开发者ID:mad-mike,项目名称:vscode-xml,代码行数:33,代码来源:Extension.ts

示例4: activate

export function activate(context: vscode.ExtensionContext) {
	let emacs = new em.Emacs();
	vscode.commands.registerTextEditorCommand("emacsify.killLine", emacs.killLine);
	vscode.commands.registerTextEditorCommand("emacsify.killBuffer", emacs.killBuffer);
	vscode.commands.registerCommand("emacsify.isearchForward", emacs.isearchForward);
	vscode.commands.registerCommand("emacsify.isearchBackward", emacs.isearchBackward);
	context.subscriptions.push(emacs);
}
开发者ID:gizak,项目名称:vscode-emacsify,代码行数:8,代码来源:index.ts

示例5: activateRepl

export function activateRepl(): vscode.Disposable[] {
  return [
    vscode.commands.registerCommand('elm.replStart', () => startRepl(workspace.rootPath + "/x")),
    vscode.commands.registerTextEditorCommand('elm.replSendLine', sendLine),
    vscode.commands.registerTextEditorCommand('elm.replSendSelection', sendSelection),
    vscode.commands.registerTextEditorCommand('elm.replSendFile', sendFile)
  ];
}
开发者ID:ThomasWeiser,项目名称:vscode-elm,代码行数:8,代码来源:elmRepl.ts

示例6: activate

export function activate(context: vscode.ExtensionContext) {

    const html2JadeDisposable = vscode.commands.registerTextEditorCommand('extension.html2jade', (textEditor, edit) => {
        const convertHtmlOptions = {
            bodyless: true,
            nspaces: textEditor.options.insertSpaces ? textEditor.options.tabSize : undefined,
            tabs: !textEditor.options.insertSpaces,
            double: true,
            noattrcomma: true
        };

        textEditor.options.insertSpaces;
        const promises = textEditor.selections.map(selection => {
            const text = textEditor.document.getText(selection);
            return convertHtml(text, convertHtmlOptions)
                .then(jadeText => {
                    const replacementText = jadeText.substr(0, jadeText.length - 1).split('\n')
                        .filter(line => !line.match(/\s*\|\s*/))
                        .reduce((p, c) => p + '\n' + c, '');
                    return {
                        selection,
                        replacementText
                    };
                });
        });

        Promise.all(promises)
            .then(x => textEditor.edit(editBuilder => {
                x.forEach(y => {
                    editBuilder.replace(y.selection, y.replacementText);
                });
            }));
    });
    context.subscriptions.push(html2JadeDisposable);

    const jade2HtmlDisposable = vscode.commands.registerTextEditorCommand('extension.jade2html', (textEditor, edit) => {
        const selectionsTransformed = textEditor.selections.map(selection => {
            const text = textEditor.document.getText(selection);
            const replacementText = jade.compile(text, { pretty: true })() as string;
            return {
                selection,
                replacementText
            };
        });

        textEditor.edit(editBuilder => {
            selectionsTransformed.forEach(x => {
                editBuilder.replace(x.selection, x.replacementText);
            });
        });

        vscode.commands.executeCommand('editor.action.format');
    });
    context.subscriptions.push(jade2HtmlDisposable);
}
开发者ID:jdforsythe,项目名称:vscode-html2jade,代码行数:55,代码来源:extension.ts

示例7: build

const activate = (context) => {
  context.subscriptions.push(
    commands.registerTextEditorCommand('extension.innosetup.compile', () => {
      return build();
    })
  );
  context.subscriptions.push(
    commands.registerTextEditorCommand('extension.innosetup.create-build-task', () => {
      return createTask();
    })
  );
};
开发者ID:idleberg,项目名称:vscode-innosetup,代码行数:12,代码来源:main.ts

示例8: osascript

const activate = (context) => {
  context.subscriptions.push(
    commands.registerTextEditorCommand('extension.applescript.run', () => {
      return osascript();
    })
  );
  context.subscriptions.push(
    commands.registerTextEditorCommand('extension.applescript.compile', () => {
      return osacompile('scpt');
    })
  );
  context.subscriptions.push(
    commands.registerTextEditorCommand('extension.applescript.compileBundle', () => {
      return osacompile('scptd');
    })
  );
  context.subscriptions.push(
    commands.registerTextEditorCommand('extension.applescript.compileApp', () => {
      return osacompile('app');
    })
  );
  context.subscriptions.push(
    commands.registerTextEditorCommand('extension.applescript.createBuildTask', () => {
      return createBuildTask();
    })
  );
  context.subscriptions.push(
    commands.registerTextEditorCommand('extension.jxa.run', () => {
      return osascript({ isJXA: true });
    })
  );
  context.subscriptions.push(
    commands.registerTextEditorCommand('extension.jxa.compile', () => {
      return osacompile('scpt', { isJXA: true });
    })
  );
  context.subscriptions.push(
    commands.registerTextEditorCommand('extension.jxa.compileBundle', () => {
      return osacompile('scptd', { isJXA: true });
    })
  );
  context.subscriptions.push(
    commands.registerTextEditorCommand('extension.jxa.compileApp', () => {
      return osacompile('app', { isJXA: true });
    })
  );
  context.subscriptions.push(
    commands.registerTextEditorCommand('extension.jxa.createBuildTask', () => {
      return createBuildTask(true);
    })
  );
};
开发者ID:idleberg,项目名称:vscode-applescript,代码行数:52,代码来源:main.ts

示例9: activate

export function activate(context: vscode.ExtensionContext) {
  // To make us VS Code agnostic outside of this file
  const pluginSettings = getExtensionSettings()
  const jestPath = pathToJest(pluginSettings)
  const configPath = pathToConfig(pluginSettings)
  const currentJestVersion = 20
  const workspace = new ProjectWorkspace(pluginSettings.rootPath, jestPath, configPath, currentJestVersion)

  // Create our own console
  const channel = vscode.window.createOutputChannel('Jest')

  // We need a singleton to represent the extension
  extensionInstance = new JestExt(workspace, channel, pluginSettings)

  const languages = [
    { language: 'javascript' },
    { language: 'javascriptreact' },
    { language: 'typescript' },
    { language: 'typescriptreact' },
  ]
  context.subscriptions.push(
    registerStatusBar(channel),
    vscode.commands.registerTextEditorCommand(`${extensionName}.start`, () => {
      vscode.window.showInformationMessage('Started Jest, press escape to hide this message.')
      extensionInstance.startProcess()
    }),
    vscode.commands.registerTextEditorCommand(`${extensionName}.stop`, () => extensionInstance.stopProcess()),
    vscode.commands.registerTextEditorCommand(`${extensionName}.show-channel`, () => {
      channel.show()
    }),
    ...registerSnapshotCodeLens(pluginSettings.enableSnapshotPreviews),
    ...registerSnapshotPreview(),
    ...registerCoverageCodeLens(extensionInstance),
    registerToggleCoverageOverlay(pluginSettings.showCoverageOnLoad),
    vscode.commands.registerCommand(`${extensionName}.run-test`, extensionInstance.runTest),
    vscode.languages.registerCodeLensProvider(languages, extensionInstance.debugCodeLensProvider),
    vscode.workspace.onDidChangeConfiguration(e => {
      if (e.affectsConfiguration('jest')) {
        const updatedSettings = getExtensionSettings()
        extensionInstance.triggerUpdateSettings(updatedSettings)
      }
    }),

    vscode.workspace.onDidCloseTextDocument(document => {
      extensionInstance.onDidCloseTextDocument(document)
    }),

    vscode.window.onDidChangeActiveTextEditor(extensionInstance.onDidChangeActiveTextEditor, extensionInstance),
    vscode.workspace.onDidChangeTextDocument(extensionInstance.onDidChangeTextDocument, extensionInstance)
  )
}
开发者ID:bookman25,项目名称:vscode-jest,代码行数:51,代码来源:extension.ts

示例10: activate

export function activate(context: vscode.ExtensionContext): void {
	const command = vscode.commands.registerTextEditorCommand('lebab.convert', (textEditor) => {
		const options = vscode.workspace.getConfiguration().get<IOptions>('lebab');
		const document = textEditor.document;
		const selections = textEditor.selections;

		const transforms: ITask[] = [];
		const collection = vscode.languages.createDiagnosticCollection();

		// If the primary selection is empty, then transform full document
		if (isEmptyPrimarySelection(selections)) {
			const lastLine = document.lineAt(document.lineCount - 1);
			const range = getRange(0, 0, document.lineCount - 1, lastLine.text.length);
			transforms.push(transformRange(document, range, options, collection));
		} else {
			selections.forEach((selection) => {
				const range = new vscode.Range(selection.start, selection.end);
				transforms.push(transformRange(document, range, options, collection, true));
			});
		}

		if (!options.skipWarnings) {
			vscode.window.onDidChangeActiveTextEditor(() => collection.delete(document.uri));
		}

		textEditor.edit((editBuilder) => {
			transforms.forEach((task) => {
				editBuilder.replace(task.range, task.code);
			});
		});
	});

	// Subscriptions
	context.subscriptions.push(command);
}
开发者ID:mrmlnc,项目名称:vscode-lebab,代码行数:35,代码来源:extension.ts

示例11: activate

export function activate(context: vscode.ExtensionContext) {


	// The command has been defined in the package.json file
	// Now provide the implementation of the command with  registerCommand
	// The commandId parameter must match the command field in package.json
	var search = vscode.commands.registerCommand('extension.searchStack', () => {
		// The code you place here will be executed every time your command is executed

		vscode.window.showInputBox({
			prompt: 'What do you want to search for?'
		}).then((result) => {
			if(result){
				open('http://stackoverflow.com/search?q=' + result);
			}
		});
	});
	
	//use Stack Overflow to search selected text
	var s_search = vscode.commands.registerTextEditorCommand('extension.searchSelection', (textEdtior: vscode.TextEditor, edit: vscode.TextEditorEdit) => {
		let thisSelection = {
			start: textEdtior.selections[0].start, 
			end: textEdtior.selections[0].end
		};
		
		//Use the node module "open" to open a web browser
		let output = selection.getStringFromSelection(thisSelection, textEdtior.document);
		if(output && output.trim.length > 0){
			open('http://stackoverflow.com/search?q='+output);
		}
	});

	context.subscriptions.push(search);
}
开发者ID:surgeforward,项目名称:code-stackoverflow,代码行数:34,代码来源:extension.ts

示例12: activate

export function activate(context: vscode.ExtensionContext) {
    cljConnection.setCljContext(context);
    context.subscriptions.push(nreplController);
    cljConnection.disconnect(false);
    var config = vscode.workspace.getConfiguration('clojureVSCode');
    if (config.autoStartNRepl) {
        cljConnection.startNRepl();
    }

    maybeActivateFormatOnSave();

    const testResultDataProvidier = buildTestProvider();

    vscode.commands.registerCommand('clojureVSCode.manuallyConnectToNRepl', cljConnection.manuallyConnect);
    vscode.commands.registerCommand('clojureVSCode.stopDisconnectNRepl', cljConnection.disconnect);
    vscode.commands.registerCommand('clojureVSCode.startNRepl', cljConnection.startNRepl);

    const evaluationResultChannel = vscode.window.createOutputChannel('Evaluation results');
    vscode.commands.registerCommand('clojureVSCode.eval', () => clojureEval(evaluationResultChannel));
    vscode.commands.registerCommand('clojureVSCode.evalAndShowResult', () => clojureEvalAndShowResult(evaluationResultChannel));

    vscode.commands.registerCommand('clojureVSCode.testNamespace', () => testNamespace(evaluationResultChannel, testResultDataProvidier));
    vscode.commands.registerCommand('clojureVSCode.runAllTests', () => runAllTests(evaluationResultChannel, testResultDataProvidier));
    vscode.window.registerTreeDataProvider('clojure', testResultDataProvidier);

    vscode.commands.registerTextEditorCommand('clojureVSCode.formatFile', formatFile);

    context.subscriptions.push(vscode.languages.registerCompletionItemProvider(CLOJURE_MODE, new ClojureCompletionItemProvider(), '.', '/'));
    context.subscriptions.push(vscode.languages.registerDefinitionProvider(CLOJURE_MODE, new ClojureDefinitionProvider()));
    context.subscriptions.push(vscode.languages.registerHoverProvider(CLOJURE_MODE, new ClojureHoverProvider()));
    context.subscriptions.push(vscode.languages.registerSignatureHelpProvider(CLOJURE_MODE, new ClojureSignatureProvider(), ' ', '\n'));

    vscode.workspace.registerTextDocumentContentProvider('jar', new JarContentProvider());
    vscode.languages.setLanguageConfiguration(CLOJURE_MODE.language, ClojureLanguageConfiguration);
}
开发者ID:avli,项目名称:clojureVSCode,代码行数:35,代码来源:clojureMain.ts

示例13: activate

export function activate(context: vscode.ExtensionContext) {
    
    let confViewer = new configuration.ConfigurationViewer;
    context.subscriptions.push(confViewer);
    context.subscriptions.push(vscode.commands.registerTextEditorCommand('clang.showExecConf',
    (editor: vscode.TextEditor, edit: vscode.TextEditorEdit) => {
        if (!vscode.languages.match(CLANG_MODE, editor.document)) {
            vscode.window.showErrorMessage(`Current language is not C, C++ or Objective-C`);
            return;            
        }
        confViewer.show(editor.document);
    }));    
    
    let confTester = new configuration.ConfigurationTester;
    context.subscriptions.push(confTester);
    let subscriptions: vscode.Disposable[] = [];
    vscode.window.onDidChangeActiveTextEditor((editor) => {
        if (!editor || !vscode.languages.match(CLANG_MODE, editor.document)) return;
        confTester.test(editor.document.languageId);
    }, null, subscriptions);
    

    let residentExtension: ResidentExtension = new ResidentExtension();
    context.subscriptions.push(residentExtension);
    vscode.workspace.onDidChangeConfiguration(() => {
        residentExtension.update();
    }, null, subscriptions);
    context.subscriptions.push(vscode.Disposable.from(...subscriptions));
}
开发者ID:Sean1708,项目名称:vscode-clang,代码行数:29,代码来源:extension.ts

示例14: activate

export function activate(context: vscode.ExtensionContext) {

  context.subscriptions.push(vscode.languages.registerDocumentFormattingEditProvider('javascript', {
    provideDocumentFormattingEdits: (document, options, token) => {
      return format(document, null, options)
    }
  }));
  context.subscriptions.push(vscode.languages.registerDocumentRangeFormattingEditProvider('javascript', {
    provideDocumentRangeFormattingEdits: (document, range, options, token) => {
      var start = new vscode.Position(0, 0);
      var end = new vscode.Position(document.lineCount - 1, document.lineAt(document.lineCount - 1).text.length);
      return format(document, new vscode.Range(start, end), options)
    }
  }));
  context.subscriptions.push(vscode.commands.registerTextEditorCommand('format.standard', (textEditor, edit) => {
    var { document, selection } = textEditor
    var start;
    var end;
    if (selection.start.line === selection.end.line && selection.start.character === selection.end.character) {
      // no selections, then whole document
       start = new vscode.Position(0, 0);
       end = new vscode.Position(document.lineCount - 1, document.lineAt(document.lineCount - 1).text.length);
    } else {
      // with selection
      start = new vscode.Position(selection.start.line, 0)
      end = new vscode.Position(selection.end.line, document.lineAt(selection.end.line).text.length)
    }
    var range = new vscode.Range(start, end);
    var content = document.getText(range);
    var formatted = standardFormat.transform(content);
    var result: vscode.TextEdit[] = [];
    edit.replace(range, formatted);
  }))
}
开发者ID:jahtalab,项目名称:vscode-standard-format,代码行数:34,代码来源:extension.ts

示例15: activate

export function activate(context: ExtensionContext) 
{
	const provider = new ContentProvider();

	const providerRegistrations = Disposable.from(
		workspace.registerTextDocumentContentProvider(ContentProvider.scheme, provider)
	);
    
	const commandRegistration = commands.registerTextEditorCommand('editor.printFunctions', editor => {
        return provider.newDocument(editor);
	});

    let contextMenuSwitchSort = commands.registerCommand('contextmenu.switchSort', () => {
        provider.updateDocument(true);
    });
    
    let contextMenuRefresh = commands.registerCommand('contextmenu.refresh', () => {
        provider.updateDocument(false);
    });
        
	context.subscriptions.push(
		provider,
        commandRegistration,
        contextMenuSwitchSort,
        contextMenuRefresh,
        providerRegistrations
    );
}
开发者ID:martinandersen3d,项目名称:funcList,代码行数:28,代码来源:extension.ts


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