1 | import { IRankedMenu, RankedMenu } from '@jupyterlab/ui-components';
|
2 | import { Widget } from '@lumino/widgets';
|
3 | import { IMenuExtender } from './tokens';
|
4 | /**
|
5 | * An interface for a Run menu.
|
6 | */
|
7 | export interface IRunMenu extends IRankedMenu {
|
8 | /**
|
9 | * A set storing ICodeRunner for the Run menu.
|
10 | *
|
11 | * ### Notes
|
12 | * The key for the set may be used in menu labels.
|
13 | */
|
14 | readonly codeRunners: Set<IRunMenu.ICodeRunner<Widget>>;
|
15 | }
|
16 | /**
|
17 | * An extensible Run menu for the application.
|
18 | */
|
19 | export declare class RunMenu extends RankedMenu implements IRunMenu {
|
20 | /**
|
21 | * Construct the run menu.
|
22 | */
|
23 | constructor(options: IRankedMenu.IOptions);
|
24 | /**
|
25 | * A set storing ICodeRunner for the Run menu.
|
26 | *
|
27 | * ### Notes
|
28 | * The key for the set may be used in menu labels.
|
29 | */
|
30 | readonly codeRunners: Set<IRunMenu.ICodeRunner<Widget>>;
|
31 | /**
|
32 | * Dispose of the resources held by the run menu.
|
33 | */
|
34 | dispose(): void;
|
35 | }
|
36 | /**
|
37 | * A namespace for RunMenu statics.
|
38 | */
|
39 | export declare namespace IRunMenu {
|
40 | /**
|
41 | * An object that runs code, which may be
|
42 | * registered with the Run menu.
|
43 | */
|
44 | interface ICodeRunner<T extends Widget> extends IMenuExtender<T> {
|
45 | /**
|
46 | * Return the caption associated to the `run` function.
|
47 | *
|
48 | * This function receives the number of items `n` to be able to provided
|
49 | * correct pluralized forms of translations.
|
50 | */
|
51 | runCaption?: (n: number) => string;
|
52 | /**
|
53 | * Return the label associated to the `run` function.
|
54 | *
|
55 | * This function receives the number of items `n` to be able to provided
|
56 | * correct pluralized forms of translations.
|
57 | */
|
58 | runLabel?: (n: number) => string;
|
59 | /**
|
60 | * Return the caption associated to the `runAll` function.
|
61 | *
|
62 | * This function receives the number of items `n` to be able to provided
|
63 | * correct pluralized forms of translations.
|
64 | */
|
65 | runAllCaption?: (n: number) => string;
|
66 | /**
|
67 | * Return the label associated to the `runAll` function.
|
68 | *
|
69 | * This function receives the number of items `n` to be able to provided
|
70 | * correct pluralized forms of translations.
|
71 | */
|
72 | runAllLabel?: (n: number) => string;
|
73 | /**
|
74 | * Return the caption associated to the `restartAndRunAll` function.
|
75 | *
|
76 | * This function receives the number of items `n` to be able to provided
|
77 | * correct pluralized forms of translations.
|
78 | */
|
79 | restartAndRunAllCaption?: (n: number) => string;
|
80 | /**
|
81 | * Return the label associated to the `restartAndRunAll` function.
|
82 | *
|
83 | * This function receives the number of items `n` to be able to provided
|
84 | * correct pluralized forms of translations.
|
85 | */
|
86 | restartAndRunAllLabel?: (n: number) => string;
|
87 | /**
|
88 | * A function to run a chunk of code.
|
89 | */
|
90 | run?: (widget: T) => Promise<void>;
|
91 | /**
|
92 | * A function to run the entirety of the code hosted by the widget.
|
93 | */
|
94 | runAll?: (widget: T) => Promise<void>;
|
95 | /**
|
96 | * A function to restart and run all the code hosted by the widget, which
|
97 | * returns a promise of whether the action was performed.
|
98 | */
|
99 | restartAndRunAll?: (widget: T) => Promise<boolean>;
|
100 | }
|
101 | }
|