UNPKG

1.54 kBPlain TextView Raw
1// Copyright (c) Jupyter Development Team.
2// Distributed under the terms of the Modified BSD License.
3
4import { IRankedMenu, RankedMenu } from '@jupyterlab/ui-components';
5import { SemanticCommand } from '@jupyterlab/apputils';
6
7/**
8 * An interface for a View menu.
9 */
10export interface IViewMenu extends IRankedMenu {
11 /**
12 * Semantic commands IEditorViewer for the View menu.
13 */
14 readonly editorViewers: IViewMenu.IEditorViewer;
15}
16
17/**
18 * An extensible View menu for the application.
19 */
20export class ViewMenu extends RankedMenu implements IViewMenu {
21 /**
22 * Construct the view menu.
23 */
24 constructor(options: IRankedMenu.IOptions) {
25 super(options);
26 this.editorViewers = {
27 toggleLineNumbers: new SemanticCommand(),
28 toggleMatchBrackets: new SemanticCommand(),
29 toggleWordWrap: new SemanticCommand()
30 };
31 }
32
33 /**
34 * Semantic commands IEditorViewer for the View menu.
35 */
36 readonly editorViewers: IViewMenu.IEditorViewer;
37}
38
39/**
40 * Namespace for IViewMenu.
41 */
42export namespace IViewMenu {
43 /**
44 * Interface for a text editor viewer to register
45 * itself with the text editor semantic commands.
46 */
47 export interface IEditorViewer {
48 /**
49 * A semantic command to show line numbers in the editor.
50 */
51 toggleLineNumbers: SemanticCommand;
52
53 /**
54 * A semantic command to word-wrap the editor.
55 */
56 toggleWordWrap: SemanticCommand;
57
58 /**
59 * A semantic command to match brackets in the editor.
60 */
61 toggleMatchBrackets: SemanticCommand;
62 }
63}