patternModeHelpers.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.printRestoredPatternCaret = exports.printPatternCaret = void 0;
  6. function _ansiEscapes() {
  7. const data = _interopRequireDefault(require('ansi-escapes'));
  8. _ansiEscapes = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _chalk() {
  14. const data = _interopRequireDefault(require('chalk'));
  15. _chalk = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _stringLength() {
  21. const data = _interopRequireDefault(require('string-length'));
  22. _stringLength = function () {
  23. return data;
  24. };
  25. return data;
  26. }
  27. function _interopRequireDefault(obj) {
  28. return obj && obj.__esModule ? obj : {default: obj};
  29. }
  30. /**
  31. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  32. *
  33. * This source code is licensed under the MIT license found in the
  34. * LICENSE file in the root directory of this source tree.
  35. */
  36. const printPatternCaret = (pattern, pipe) => {
  37. const inputText = `${_chalk().default.dim(' pattern \u203A')} ${pattern}`;
  38. pipe.write(_ansiEscapes().default.eraseDown);
  39. pipe.write(inputText);
  40. pipe.write(_ansiEscapes().default.cursorSavePosition);
  41. };
  42. exports.printPatternCaret = printPatternCaret;
  43. const printRestoredPatternCaret = (pattern, currentUsageRows, pipe) => {
  44. const inputText = `${_chalk().default.dim(' pattern \u203A')} ${pattern}`;
  45. pipe.write(
  46. _ansiEscapes().default.cursorTo(
  47. (0, _stringLength().default)(inputText),
  48. currentUsageRows - 1
  49. )
  50. );
  51. pipe.write(_ansiEscapes().default.cursorRestorePosition);
  52. };
  53. exports.printRestoredPatternCaret = printRestoredPatternCaret;