tokens.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. // Copyright (c) Jupyter Development Team.
  2. // Distributed under the terms of the Modified BSD License.
  3. import { Widget } from '@phosphor/widgets';
  4. import { Token } from '@phosphor/coreutils';
  5. import { IInstanceTracker, MainAreaWidget } from '@jupyterlab/apputils';
  6. import { TerminalSession } from '@jupyterlab/services';
  7. /**
  8. * A class that tracks editor widgets.
  9. */
  10. export interface ITerminalTracker
  11. extends IInstanceTracker<MainAreaWidget<ITerminal.ITerminal>> {}
  12. /* tslint:disable */
  13. /**
  14. * The editor tracker token.
  15. */
  16. export const ITerminalTracker = new Token<ITerminalTracker>(
  17. '@jupyterlab/terminal:ITerminalTracker'
  18. );
  19. /* tslint:enable */
  20. /**
  21. * The namespace for terminals. Separated from the widget so it can be lazy
  22. * loaded.
  23. */
  24. export namespace ITerminal {
  25. export interface ITerminal extends Widget {
  26. /**
  27. * The terminal session associated with the widget.
  28. */
  29. session: TerminalSession.ISession;
  30. /**
  31. * Get a config option for the terminal.
  32. */
  33. getOption<K extends keyof IOptions>(option: K): IOptions[K];
  34. /**
  35. * Set a config option for the terminal.
  36. */
  37. setOption<K extends keyof IOptions>(option: K, value: IOptions[K]): void;
  38. /**
  39. * Refresh the terminal session.
  40. */
  41. refresh(): Promise<void>;
  42. }
  43. /**
  44. * Options for the terminal widget.
  45. */
  46. export interface IOptions {
  47. /**
  48. * The font family used to render text.
  49. */
  50. fontFamily: string | null;
  51. /**
  52. * The font size of the terminal in pixels.
  53. */
  54. fontSize: number;
  55. /**
  56. * The line height used to render text.
  57. */
  58. lineHeight: number | null;
  59. /**
  60. * The theme of the terminal.
  61. */
  62. theme: Theme;
  63. /**
  64. * The amount of buffer scrollback to be used
  65. * with the terminal
  66. */
  67. scrollback: number | null;
  68. /**
  69. * Whether to shut down the session when closing a terminal or not.
  70. */
  71. shutdownOnClose: boolean;
  72. /**
  73. * Whether to blink the cursor. Can only be set at startup.
  74. */
  75. cursorBlink: boolean;
  76. /**
  77. * An optional command to run when the session starts.
  78. */
  79. initialCommand: string;
  80. /**
  81. * Whether to enable screen reader support.
  82. *
  83. * Set to false if you run into performance problems from DOM overhead
  84. */
  85. screenReaderMode: boolean;
  86. /**
  87. * Whether to enable using Ctrl+V to paste.
  88. *
  89. * This setting has no effect on macOS, where Cmd+V is available.
  90. */
  91. pasteWithCtrlV: boolean;
  92. }
  93. /**
  94. * The default options used for creating terminals.
  95. */
  96. export const defaultOptions: IOptions = {
  97. theme: 'inherit',
  98. fontFamily: 'Menlo, Consolas, "DejaVu Sans Mono", monospace',
  99. fontSize: 13,
  100. lineHeight: 1.0,
  101. scrollback: 1000,
  102. shutdownOnClose: false,
  103. cursorBlink: true,
  104. initialCommand: '',
  105. screenReaderMode: true,
  106. pasteWithCtrlV: true
  107. };
  108. /**
  109. * A type for the terminal theme.
  110. */
  111. export type Theme = 'light' | 'dark' | 'inherit';
  112. /**
  113. * A type for the terminal theme.
  114. */
  115. export interface IThemeObject {
  116. foreground: string;
  117. background: string;
  118. cursor: string;
  119. cursorAccent: string;
  120. selection: string;
  121. }
  122. }