Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/base/browser/ui/findinput/findInputToggles.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { getDefaultHoverDelegate } from '../hover/hoverDelegateFactory.js';
7
import { IHoverDelegate } from '../hover/hoverDelegate.js';
8
import { Toggle } from '../toggle/toggle.js';
9
import { Codicon } from '../../../common/codicons.js';
10
import * as nls from '../../../../nls.js';
11
12
export interface IFindInputToggleOpts {
13
readonly appendTitle: string;
14
readonly isChecked: boolean;
15
readonly inputActiveOptionBorder: string | undefined;
16
readonly inputActiveOptionForeground: string | undefined;
17
readonly inputActiveOptionBackground: string | undefined;
18
readonly hoverDelegate?: IHoverDelegate;
19
}
20
21
const NLS_CASE_SENSITIVE_TOGGLE_LABEL = nls.localize('caseDescription', "Match Case");
22
const NLS_WHOLE_WORD_TOGGLE_LABEL = nls.localize('wordsDescription', "Match Whole Word");
23
const NLS_REGEX_TOGGLE_LABEL = nls.localize('regexDescription', "Use Regular Expression");
24
25
export class CaseSensitiveToggle extends Toggle {
26
constructor(opts: IFindInputToggleOpts) {
27
super({
28
icon: Codicon.caseSensitive,
29
title: NLS_CASE_SENSITIVE_TOGGLE_LABEL + opts.appendTitle,
30
isChecked: opts.isChecked,
31
hoverDelegate: opts.hoverDelegate ?? getDefaultHoverDelegate('element'),
32
inputActiveOptionBorder: opts.inputActiveOptionBorder,
33
inputActiveOptionForeground: opts.inputActiveOptionForeground,
34
inputActiveOptionBackground: opts.inputActiveOptionBackground
35
});
36
}
37
}
38
39
export class WholeWordsToggle extends Toggle {
40
constructor(opts: IFindInputToggleOpts) {
41
super({
42
icon: Codicon.wholeWord,
43
title: NLS_WHOLE_WORD_TOGGLE_LABEL + opts.appendTitle,
44
isChecked: opts.isChecked,
45
hoverDelegate: opts.hoverDelegate ?? getDefaultHoverDelegate('element'),
46
inputActiveOptionBorder: opts.inputActiveOptionBorder,
47
inputActiveOptionForeground: opts.inputActiveOptionForeground,
48
inputActiveOptionBackground: opts.inputActiveOptionBackground
49
});
50
}
51
}
52
53
export class RegexToggle extends Toggle {
54
constructor(opts: IFindInputToggleOpts) {
55
super({
56
icon: Codicon.regex,
57
title: NLS_REGEX_TOGGLE_LABEL + opts.appendTitle,
58
isChecked: opts.isChecked,
59
hoverDelegate: opts.hoverDelegate ?? getDefaultHoverDelegate('element'),
60
inputActiveOptionBorder: opts.inputActiveOptionBorder,
61
inputActiveOptionForeground: opts.inputActiveOptionForeground,
62
inputActiveOptionBackground: opts.inputActiveOptionBackground
63
});
64
}
65
}
66
67