當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ansi-escapes.cursorUp函數代碼示例

本文整理匯總了TypeScript中ansi-escapes.cursorUp函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript cursorUp函數的具體用法?TypeScript cursorUp怎麽用?TypeScript cursorUp使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了cursorUp函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: draw

function draw(testRuns: Heroku.TestRun[], watchOption = false, jsonOption = false, count = 15) {
  const latestTestRuns = sort(testRuns).slice(0, count)

  if (jsonOption) {
    cli.styledJSON(latestTestRuns)
    return
  }

  if (watchOption) {
    process.stdout.write(ansiEscapes.eraseDown)
  }

  let data: any = []

  latestTestRuns.forEach(testRun => {
    data.push(
      {
        iconStatus: `${statusIcon(testRun)}`,
        number: testRun.number,
        branch: testRun.commit_branch,
        sha: testRun.commit_sha!.slice(0, 7),
        status: testRun.status
      }
    )
  })

  cli.table(data, {
    printHeader: undefined,
    columns: [
      {key: 'iconStatus', width: 1, label: ''}, // label '' is to make sure that widh is 1 character
      {key: 'number', label: ''},
      {key: 'branch'},
      {key: 'sha'},
      {key: 'status'}
    ]
  })

  if (watchOption) {
    process.stdout.write(ansiEscapes.cursorUp(latestTestRuns.length))
  }
}
開發者ID:jimmyurl,項目名稱:cli,代碼行數:41,代碼來源:test-run.ts

示例2: _clearTestSummary

 private _clearTestSummary() {
   this._pipe.write(ansiEscapes.cursorUp(6));
   this._pipe.write(ansiEscapes.eraseDown);
 }
開發者ID:Volune,項目名稱:jest,代碼行數:4,代碼來源:SnapshotInteractiveMode.ts

示例3: exit

  const onKeypress = (key: string) => {
    if (key === KEYS.CONTROL_C || key === KEYS.CONTROL_D) {
      if (typeof stdin.setRawMode === 'function') {
        stdin.setRawMode(false);
      }
      outputStream.write('\n');
      exit(0);
      return;
    }

    if (activePlugin != null && activePlugin.onKey) {
      // if a plugin is activate, Jest should let it handle keystrokes, so ignore
      // them here
      activePlugin.onKey(key);
      return;
    }

    // Abort test run
    const pluginKeys = getSortedUsageRows(watchPlugins, globalConfig).map(
      usage => Number(usage.key).toString(16),
    );
    if (
      isRunning &&
      testWatcher &&
      ['q', KEYS.ENTER, 'a', 'o', 'f'].concat(pluginKeys).includes(key)
    ) {
      testWatcher.setState({interrupted: true});
      return;
    }

    const matchingWatchPlugin = filterInteractivePlugins(
      watchPlugins,
      globalConfig,
    ).find(plugin => getPluginKey(plugin, globalConfig) === key);

    if (matchingWatchPlugin != null) {
      if (isRunning) {
        testWatcher.setState({interrupted: true});
        return;
      }
      // "activate" the plugin, which has jest ignore keystrokes so the plugin
      // can handle them
      activePlugin = matchingWatchPlugin;
      if (activePlugin.run) {
        activePlugin.run(globalConfig, updateConfigAndRun).then(
          shouldRerun => {
            activePlugin = null;
            if (shouldRerun) {
              updateConfigAndRun();
            }
          },
          () => {
            activePlugin = null;
            onCancelPatternPrompt();
          },
        );
      } else {
        activePlugin = null;
      }
    }

    switch (key) {
      case KEYS.ENTER:
        startRun(globalConfig);
        break;
      case 'a':
        globalConfig = updateGlobalConfig(globalConfig, {
          mode: 'watchAll',
          testNamePattern: '',
          testPathPattern: '',
        });
        startRun(globalConfig);
        break;
      case 'c':
        updateConfigAndRun({
          mode: 'watch',
          testNamePattern: '',
          testPathPattern: '',
        });
        break;
      case 'f':
        globalConfig = updateGlobalConfig(globalConfig, {
          onlyFailures: !globalConfig.onlyFailures,
        });
        startRun(globalConfig);
        break;
      case 'o':
        globalConfig = updateGlobalConfig(globalConfig, {
          mode: 'watch',
          testNamePattern: '',
          testPathPattern: '',
        });
        startRun(globalConfig);
        break;
      case '?':
        break;
      case 'w':
        if (!shouldDisplayWatchUsage && !isWatchUsageDisplayed) {
          outputStream.write(ansiEscapes.cursorUp());
          outputStream.write(ansiEscapes.eraseDown);
//.........這裏部分代碼省略.........
開發者ID:facebook,項目名稱:jest,代碼行數:101,代碼來源:watch.ts

示例4:

import * as ansi from "ansi-escapes";

console.log(ansi.cursorUp(2) + ansi.cursorLeft === "\u001B[2A\u001B[1000D");
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:3,代碼來源:ansi-escapes-tests.ts


注:本文中的ansi-escapes.cursorUp函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。