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


TypeScript window.onDidChangeTextEditorSelection方法代码示例

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


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

示例1: 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

示例2: registerRangeType

export function registerRangeType(ext: ExtensionState) {
    const context = ext.context;
    let selTimeout: NodeJS.Timer | null = null;

    const decoCurrent = vscode.window.createTextEditorDecorationType({
        borderStyle: 'solid',
        borderColor: '#66f',
        borderWidth: '0px 0px 1px 0px'
    });

    const decoType = vscode.window.createTextEditorDecorationType({
        after: {
            color: '#999',
            margin: '0px 0px 0px 20px'
        },
        rangeBehavior: vscode.DecorationRangeBehavior.ClosedClosed
    })

    context.subscriptions.push(vscode.window.onDidChangeTextEditorSelection((event) => {
        const doc = event.textEditor.document;
        if (doc.languageId !== 'haskell' && ! doc.uri.fsPath.endsWith('.hs'))
            return;
        
        if (doc.isDirty) {
            event.textEditor.setDecorations(decoCurrent, []);
            event.textEditor.setDecorations(decoType, []);
        } else {
            if (selTimeout !== null) {
                clearTimeout(selTimeout);
            }

            const sel = event.selections[0];

            selTimeout = setTimeout(async () => {
                const session = await startSession(ext, doc);
                const res = await getType(session, sel, doc);
                if (res !== null) {
                    const [range, type] = res;
                    const lineRange = doc.lineAt(range.start.line).range;
                    event.textEditor.setDecorations(decoCurrent, [{
                        range,
                        hoverMessage: type
                    }]);
                    event.textEditor.setDecorations(decoType, [{
                        range: lineRange,
                        renderOptions: {
                            after: {
                                contentText: `:: ${type}`
                            }
                        }
                    }]);
                } else {
                    event.textEditor.setDecorations(decoCurrent, []);
                    event.textEditor.setDecorations(decoType, []);
                }
                selTimeout = null;
            }, 300);
        }
    }));
}
开发者ID:OlingCat,项目名称:vscode-ghc-simple,代码行数:60,代码来源:range-type.ts

示例3: resolve

 return new Promise<void>((resolve, reject) => {
     window.onDidChangeTextEditorSelection((e) => {
         if (this.isSelectionsEqual(e.selections, selections)) {
             resolve();
         }
     });
 });
开发者ID:benjaminRomano,项目名称:amVim-for-VSCode,代码行数:7,代码来源:Runner.ts

示例4: activate

export function activate(context: vscode.ExtensionContext) {
    const vim = new Vim();

    let disposable = vscode.commands.registerCommand("type", args => {
        vim.key(args.text);
    });
    context.subscriptions.push(disposable);

    disposable = vscode.commands.registerCommand("extension.vimEscape", () => {
        vim.key("<esc>");
    });
    context.subscriptions.push(disposable);

    vscode.window.onDidChangeTextEditorSelection(e => {
        vim.updateSelection(e.selections);
    });

    vscode.workspace.onDidChangeTextDocument(e => {
        vim.documentChanged(e);
    });

    vscode.window.onDidChangeActiveTextEditor(e => {
        vim.updateUI();
    });

    vim.updateUI();
}
开发者ID:cozmo,项目名称:vimish,代码行数:27,代码来源:extension.ts

示例5: activate

export function activate(context: vscode.ExtensionContext) {

    console.log("Congratulations, your extension 'highlight-trailing-white-spaces' is now active!");

    vscode.window.onDidChangeActiveTextEditor(editor => {
        if (!editor) {
            return;
        }
        updateDecorations(editor);
    }, null, context.subscriptions);

    vscode.window.onDidChangeTextEditorSelection(event => {
        if (!event.textEditor) {
            console.error("onDidChangeTextEditorSelection(" + event + "): no active text editor.");
            return;
        }
        updateDecorations(event.textEditor);
    }, null, context.subscriptions);

    vscode.workspace.onDidChangeTextDocument(event => {
        if (!vscode.window.activeTextEditor) {
            console.error("onDidChangeTextDocument(" + event + "): no active text editor.");
            return;
        }
        updateDecorations(vscode.window.activeTextEditor);
    }, null, context.subscriptions);

    let trailingSpacesDecorationType = vscode.window.createTextEditorDecorationType({
        backgroundColor: "rgba(255,0,0,0.3)"
    });

    function updateDecorations(activeTextEditor: vscode.TextEditor) {
        if (!activeTextEditor) {
            console.error("updateDecorations(): no active text editor.");
            return;
        }

        const regEx = /\s+$/g;
        const doc = activeTextEditor.document;
        const decorationOptions: vscode.DecorationOptions[] = [];
        for (let i = 0; i < doc.lineCount; i++) {
            let lineText = doc.lineAt(i);
            let line = lineText.text;
            if (i === activeTextEditor.selection.active.line) {
                continue;
            }

            let match;
            while (match = regEx.exec(line)) {
                let startPos = new vscode.Position(i, match.index);
                let endPos = new vscode.Position(i, match.index + match[0].length);
                const decoration = { range: new vscode.Range(startPos, endPos), hoverMessage: "Number **" + match[0] + "**"};
                decorationOptions.push(decoration);
            }
        }
        activeTextEditor.setDecorations(trailingSpacesDecorationType, decorationOptions);
    }

    updateDecorations(vscode.window.activeTextEditor);
}
开发者ID:yifu,项目名称:highlight-trailing-whitespaces,代码行数:60,代码来源:extension.ts

示例6: activate

export function activate(context: vscode.ExtensionContext) : api.PrettifySymbolsMode {
	function registerTextEditorCommand(commandId:string, run:(editor:vscode.TextEditor,edit:vscode.TextEditorEdit,...args:any[])=>void): void {
    context.subscriptions.push(vscode.commands.registerTextEditorCommand(commandId, run));
  }
  function registerCommand(commandId:string, run:(...args:any[])=>void): void {
    context.subscriptions.push(vscode.commands.registerCommand(commandId, run));
  }

  registerTextEditorCommand('prettifySymbolsMode.copyWithSubstitutions', copyWithSubstitutions);
  registerCommand('prettifySymbolsMode.disablePrettySymbols', disablePrettySymbols);
  registerCommand('prettifySymbolsMode.enablePrettySymbols', enablePrettySymbols);
  registerCommand('prettifySymbolsMode.togglePrettySymbols', (editor: vscode.TextEditor) => {
    if(prettySymbolsEnabled) {
      disablePrettySymbols();
    } else {
      enablePrettySymbols();
    }
  });

  registerCommand('extension.disablePrettySymbols', () => { vscode.window.showErrorMessage('Command "extension.disablePrettySymbols" is deprecated; use "prettifySymbolsMode.disablePrettySymbols" instead.') });
  registerCommand('extension.enablePrettySymbols', () => { vscode.window.showErrorMessage('Command "extension.enablePrettySymbols" is deprecated; use "prettifySymbolsMode.enablePrettySymbols" instead.') });
  registerCommand('extension.togglePrettySymbols', () => { vscode.window.showErrorMessage('Command "extension.togglePrettySymbols" is deprecated; use "prettifySymbolsMode.togglePrettySymbols" instead.') });

  context.subscriptions.push(vscode.window.onDidChangeTextEditorSelection(selectionChanged));

  context.subscriptions.push(vscode.workspace.onDidOpenTextDocument(openDocument));
  context.subscriptions.push(vscode.workspace.onDidCloseTextDocument(closeDocument));
  context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(onConfigurationChanged));

  context.subscriptions.push(vscode.window.onDidChangeActiveTextEditor(changeActiveTextEditor));

  reloadConfiguration();

  const result : api.PrettifySymbolsMode = {
    onDidEnabledChange: function(handler: (enabled:boolean)=>void) : vscode.Disposable {
      onEnabledChangeHandlers.add(handler);
      return {
        dispose() {
          onEnabledChangeHandlers.delete(handler);
        }
      }
    },
    isEnabled: function() : boolean {
      return prettySymbolsEnabled;
    },
    registerSubstitutions: function(substitutions: api.LanguageEntry) : vscode.Disposable {
      additionalSubstitutions.add(substitutions);
      // TODO: this could be smart about not unloading & reloading everything 
      reloadConfiguration();
      return {
        dispose() {
          additionalSubstitutions.delete(substitutions);
        }
      }
    }
  };

  return result;
}
开发者ID:siegebell,项目名称:vsc-prettify-symbols-mode,代码行数:59,代码来源:extension.ts

示例7: constructor

	constructor() {
		this.minibuf = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);

		vscode.window.onDidChangeTextEditorSelection((e) => {
			this.clearMiniBuf();
		});

		this.updateMiniBuf("Emacs mode activated !");
	}
开发者ID:gizak,项目名称:vscode-emacsify,代码行数:9,代码来源:emacsify.ts

示例8: update_caret

    language_client.onReady().then(() =>
    {
      context.subscriptions.push(
        window.onDidChangeActiveTextEditor(_ => update_caret()),
        window.onDidChangeTextEditorSelection(_ => update_caret()))
      update_caret()

      language_client.onNotification(protocol.caret_update_type, goto_file)
    })
开发者ID:seL4,项目名称:isabelle,代码行数:9,代码来源:extension.ts

示例9: constructor

 constructor(utilities?: Utilities, htmlDocumentContentProvider?: HTMLDocumentContentProvider) {
     this.utilities = utilities && utilities || new Utilities();
     this.htmlDocumentContentProvider = htmlDocumentContentProvider && htmlDocumentContentProvider || new HTMLDocumentContentProvider();
     this.htmlDocumentContentProvider.generateHTML();
     // subscribe to selection change event
     let subscriptions: vscode.Disposable[] = [];
     vscode.window.onDidChangeTextEditorSelection(this.onEvent, this, subscriptions)
     this.disposable = vscode.Disposable.from(...subscriptions);
 }
开发者ID:HarshdeepGupta,项目名称:live-html-preview,代码行数:9,代码来源:PreviewManager.ts

示例10: Promise

  await new Promise((resolve, reject) => {
    let timer = setTimeout(rejectOnTimeout ? reject : resolve, timeout);

    const disposable = vscode.window.onDidChangeTextEditorSelection(x => {
      disposable.dispose();
      clearTimeout(timer);
      resolve();
    });
  });
开发者ID:arussellk,项目名称:Vim,代码行数:9,代码来源:util.ts


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