quickOpen.ts 2.4 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5 6
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
'use strict';

7
import { Keybinding } from 'vs/base/common/keyCodes';
E
Erich Gamma 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

export interface IQuickNavigateConfiguration {
	keybindings: Keybinding[];
}

export interface IAutoFocus {

	/**
	 * The index of the element to focus in the result list.
	 */
	autoFocusIndex?: number;

	/**
	 * If set to true, will automatically select the first entry from the result list.
	 */
	autoFocusFirstEntry?: boolean;

	/**
	 * If set to true, will automatically select the second entry from the result list.
	 */
	autoFocusSecondEntry?: boolean;

30 31 32 33 34
	/**
	 * If set to true, will automatically select the last entry from the result list.
	 */
	autoFocusLastEntry?: boolean;

E
Erich Gamma 已提交
35
	/**
P
Pascal Borreli 已提交
36
	 * If set to true, will automatically select any entry whose label starts with the search
E
Erich Gamma 已提交
37 38 39 40 41 42 43 44 45
	 * value. Since some entries to the top might match the query but not on the prefix, this
	 * allows to select the most accurate match (matching the prefix) while still showing other
	 * elements.
	 */
	autoFocusPrefixMatch?: string;
}

export enum Mode {
	PREVIEW,
W
Will Prater 已提交
46 47
	OPEN,
	OPEN_IN_BACKGROUND
E
Erich Gamma 已提交
48 49
}

50
export interface IEntryRunContext {
E
Erich Gamma 已提交
51
	event: any;
52
	keymods: number[];
E
Erich Gamma 已提交
53 54 55 56 57 58 59 60 61
	quickNavigateConfiguration: IQuickNavigateConfiguration;
}

export interface IDataSource<T> {
	getId(entry: T): string;
	getLabel(entry: T): string;
}

/**
J
Joao Moreno 已提交
62
 * See vs/base/parts/tree/browser/tree.ts - IRenderer
E
Erich Gamma 已提交
63 64 65 66 67 68 69 70 71 72 73 74 75
 */
export interface IRenderer<T> {
	getHeight(entry: T): number;
	getTemplateId(entry: T): string;
	renderTemplate(templateId: string, container: HTMLElement): any;
	renderElement(entry: T, templateId: string, templateData: any): void;
	disposeTemplate(templateId: string, templateData: any): void;
}

export interface IFilter<T> {
	isVisible(entry: T): boolean;
}

76 77 78 79
export interface IAccessiblityProvider<T> {
	getAriaLabel(entry: T): string;
}

E
Erich Gamma 已提交
80
export interface IRunner<T> {
81
	run(entry: T, mode: Mode, context: IEntryRunContext): boolean;
E
Erich Gamma 已提交
82 83 84 85 86 87 88 89
}

export interface IModel<T> {
	entries: T[];
	dataSource: IDataSource<T>;
	renderer: IRenderer<T>;
	runner: IRunner<T>;
	filter?: IFilter<T>;
90
	accessibilityProvider?: IAccessiblityProvider<T>;
E
Erich Gamma 已提交
91
}