-
Notifications
You must be signed in to change notification settings - Fork 448
feat: support electron titlebar string template #2194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7f2139f
feat: support electron titlebar string template
yantze a787271
chore: add preferenceService
yantze 6e3c058
chore: support watch window.title perference name
yantze 5e24572
chore: use onPreferenceChangedEvent
yantze 7de316c
chore: change _titleTemplate init
yantze bae251d
chore: update typo
yantze 583f0ce
chore: fix typo
yantze b9ee060
fix: check the validity of the preference value
yantze a9ea55d
fix: typo
yantze File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/electron-basic/src/browser/electron-preference.contribution.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { PreferenceSchema, PreferenceContribution, localize, Domain } from '@opensumi/ide-core-browser'; | ||
|
|
||
| export const electronPreferencesSchema: PreferenceSchema = { | ||
| type: 'object', | ||
| properties: { | ||
| 'window.title': { | ||
| type: 'string', | ||
| description: localize('window.title'), | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| export const ElectronPreferences = Symbol('ElectronPreferences'); | ||
|
|
||
| @Domain(PreferenceContribution) | ||
| export class ElectronPreferenceContribution implements PreferenceContribution { | ||
| schema: PreferenceSchema = electronPreferencesSchema; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| export const localizationBundle = { | ||
| languageId: 'en-US', | ||
| languageName: 'english', | ||
| localizedLanguageName: 'English', | ||
| contents: { | ||
| 'window.title': [ | ||
| 'Controls the window title based on the active editor. Variables are substituted based on the context:', | ||
| '`${activeEditorShort}`: the file name (e.g. myFile.txt).', | ||
| '`${activeEditorMedium}`: the path of the file relative to the workspace folder (e.g. myFolder/myFileFolder/myFile.txt).', | ||
| '`${activeEditorLong}`: the full path of the file (e.g. /Users/Development/myFolder/myFileFolder/myFile.txt).', | ||
| '`${activeFolderShort}`: the name of the folder the file is contained in (e.g. myFileFolder).', | ||
| '`${activeFolderMedium}`: the path of the folder the file is contained in, relative to the workspace folder (e.g. myFolder/myFileFolder).', | ||
| '`${activeFolderLong}`: the full path of the folder the file is contained in (e.g. /Users/Development/myFolder/myFileFolder).', | ||
| '`${folderName}`: name of the workspace folder the file is contained in (e.g. myFolder).', | ||
| '`${folderPath}`: file path of the workspace folder the file is contained in (e.g. /Users/Development/myFolder).', | ||
| '`${rootName}`: name of the opened workspace or folder (e.g. myFolder or myWorkspace).', | ||
| '`${rootPath}`: file path of the opened workspace or folder (e.g. /Users/Development/myWorkspace).', | ||
| '`${appName}`: e.g. OpenSumi.', | ||
| '`${remoteName}`: e.g. SSH', | ||
| '`${dirty}`: an indicator for when the active editor has unsaved changes.', | ||
| '`${separator}`: a conditional separator (" - ") that only shows when surrounded by variables with values or static text.', | ||
| ].join('\n- '), | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { registerLocalizationBundle } from '@opensumi/ide-core-common/lib/localize'; | ||
|
|
||
| import { localizationBundle as en } from './en-US.lang'; | ||
| import { localizationBundle as zh } from './zh-CN.lang'; | ||
|
|
||
| registerLocalizationBundle(zh); | ||
| registerLocalizationBundle(en); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| export const localizationBundle = { | ||
| languageId: 'zh-CN', | ||
| languageName: 'Chinese', | ||
| localizedLanguageName: '中文(中国)', | ||
| contents: { | ||
| 'window.title': [ | ||
| '基于活跃文件控制窗口标题。变量根据上下文替换:', | ||
| '`${activeEditorShort}`: 活跃文件标题 (例如: myFile.txt).', | ||
| '`${activeEditorMedium}`: 活跃文件相对工作区的路径 (例如: myFolder/myFileFolder/myFile.txt).', | ||
| '`${activeEditorLong}`: 活跃文件的绝对路径 (例如: /Users/Development/myFolder/myFileFolder/myFile.txt).', | ||
| '`${activeFolderShort}`: 活跃文件的父目录 (例如: myFileFolder).', | ||
| '`${activeFolderMedium}`: 活跃文件的父目录相约对工作区的路径 (例如: myFolder/myFileFolder).', | ||
| '`${activeFolderLong}`: 活跃文件的父目录相约对工作区的绝对路径 (例如: /Users/Development/myFolder/myFileFolder).', | ||
| '`${folderName}`: 目录名称 (例如: myFolder).', | ||
| '`${folderPath}`: 目录绝对路径 (例如: /Users/Development/myFolder).', | ||
| '`${rootName}`: 工作区名称 (例如: myFolder or myWorkspace).', | ||
| '`${rootPath}`: 工作区绝对路径 (例如: /Users/Development/myWorkspace).', | ||
| '`${appName}`: 例如: OpenSumi.', | ||
| '`${remoteName}`: 例如: SSH', | ||
| '`${dirty}`: 有文件被修改的标记', | ||
| '`${separator}`: 分隔符只在两边都有值的变量中出现', | ||
| ].join('\n- '), | ||
| }, | ||
| }; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.