Skip to content

Commit

Permalink
Merge pull request #74 from espenja/features/file-extension-tag-support
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardssh authored Jul 20, 2022
2 parents d8c866b + f2c1884 commit d0cac0f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"rpc.detailsEditing": {
"type": "string",
"default": "In {workspace} {problems}",
"description": "Custom string for the details section of the rich presence\n\t- {empty} will be replaced with an empty space\n\t- {file_name} will be replaced with the current file name\n\t- {dir_name} will get replaced with the folder name that has the current file\n\t- {full_dir_name} will get replaced with the full directory name without the current file name\n\t- {workspace} will be replaced with the current workspace name, if any\n\t- {workspace_folder} will be replaced with the currently accessed workspace folder, if any\n\t- {workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - workspace_folder'\n\t- {current_column} will get replaced with the current column of the current line\n\t- {current_line} will get replaced with the current line number\n\t- {total_lines} will get replaced with the total line number\n\t- {git_repo} will be replaced by the current git repository (also detects repos in subdirectories) if any\n\t- {git_branch} will be replaced by the current git branch if in an repository\n\t- {problems} will be replaced with the count of problems (warnings, errors) present in your workspace."
"description": "Custom string for the details section of the rich presence\n\t- {empty} will be replaced with an empty space\n\t- {file_name} will be replaced with the current file name\n\t- {file_extension} will be replaced with the current file name\n\t- {file_extension} will be replaced with the current file name\n\t- {dir_name} will get replaced with the folder name that has the current file\n\t- {full_dir_name} will get replaced with the full directory name without the current file name\n\t- {workspace} will be replaced with the current workspace name, if any\n\t- {workspace_folder} will be replaced with the currently accessed workspace folder, if any\n\t- {workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - workspace_folder'\n\t- {current_column} will get replaced with the current column of the current line\n\t- {current_line} will get replaced with the current line number\n\t- {total_lines} will get replaced with the total line number\n\t- {git_repo} will be replaced by the current git repository (also detects repos in subdirectories) if any\n\t- {git_branch} will be replaced by the current git branch if in an repository\n\t- {problems} will be replaced with the count of problems (warnings, errors) present in your workspace."
},
"rpc.detailsIdling": {
"type": "string",
Expand All @@ -164,17 +164,17 @@
"rpc.detailsDebugging": {
"type": "string",
"default": "Debugging {file_name}",
"description": "Custom string for the details section of the rich presence when debugging\n\t- {empty} will be replaced with an empty space\n\t- {file_name} will be replaced with the current file name\n\t- {dir_name} will get replaced with the folder name that has the current file\n\t- {full_dir_name} will get replaced with the full directory name without the current file name\n\t- {workspace} will be replaced with the current workspace name, if any\n\t- {workspace_folder} will be replaced with the currently accessed workspace folder, if any\n\t- {workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - workspace_folder'\n\t- {current_column} will get replaced with the current column of the current line\n\t- {current_line} will get replaced with the current line number\n\t- {total_lines} will get replaced with the total line number\n\t- {git_repo} will be replaced by the current git repository (also detects repos in subdirectories) if any\n\t- {git_branch} will be replaced by the current git branch if in an repository\n\t- {problems} will be replaced with the count of problems (warnings, errors) present in your workspace."
"description": "Custom string for the details section of the rich presence when debugging\n\t- {empty} will be replaced with an empty space\n\t- {file_name} will be replaced with the current file name\n\t- {file_extension} will be replaced with the current file name\n\t- {dir_name} will get replaced with the folder name that has the current file\n\t- {full_dir_name} will get replaced with the full directory name without the current file name\n\t- {workspace} will be replaced with the current workspace name, if any\n\t- {workspace_folder} will be replaced with the currently accessed workspace folder, if any\n\t- {workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - workspace_folder'\n\t- {current_column} will get replaced with the current column of the current line\n\t- {current_line} will get replaced with the current line number\n\t- {total_lines} will get replaced with the total line number\n\t- {git_repo} will be replaced by the current git repository (also detects repos in subdirectories) if any\n\t- {git_branch} will be replaced by the current git branch if in an repository\n\t- {problems} will be replaced with the count of problems (warnings, errors) present in your workspace."
},
"rpc.detailsViewing": {
"type": "string",
"default": "In {workspace} {problems}",
"description": "Custom string for the details section of the rich presence when viewing\n\t- {empty} will be replaced with an empty space\n\t- {file_name} will be replaced with the current file name\n\t- {dir_name} will get replaced with the folder name that has the current file\n\t- {full_dir_name} will get replaced with the full directory name without the current file name\n\t- {workspace} will be replaced with the current workspace name, if any\n\t- {workspace_folder} will be replaced with the currently accessed workspace folder, if any\n\t- {workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - workspace_folder'\n\t- {current_column} will get replaced with the current column of the current line\n\t- {current_line} will get replaced with the current line number\n\t- {total_lines} will get replaced with the total line number\n\t- {git_repo} will be replaced by the current git repository (also detects repos in subdirectories) if any\n\t- {git_branch} will be replaced by the current git branch if in an repository\n\t- {problems} will be replaced with the count of problems (warnings, errors) present in your workspace."
"description": "Custom string for the details section of the rich presence when viewing\n\t- {empty} will be replaced with an empty space\n\t- {file_name} will be replaced with the current file name\n\t- {file_extension} will be replaced with the current file name\n\t- {dir_name} will get replaced with the folder name that has the current file\n\t- {full_dir_name} will get replaced with the full directory name without the current file name\n\t- {workspace} will be replaced with the current workspace name, if any\n\t- {workspace_folder} will be replaced with the currently accessed workspace folder, if any\n\t- {workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - workspace_folder'\n\t- {current_column} will get replaced with the current column of the current line\n\t- {current_line} will get replaced with the current line number\n\t- {total_lines} will get replaced with the total line number\n\t- {git_repo} will be replaced by the current git repository (also detects repos in subdirectories) if any\n\t- {git_branch} will be replaced by the current git branch if in an repository\n\t- {problems} will be replaced with the count of problems (warnings, errors) present in your workspace."
},
"rpc.lowerDetailsEditing": {
"type": "string",
"default": "Working on {file_name}:{current_line}:{current_column}",
"description": "Custom string for the state section of the rich presence\n\t- {empty} will be replaced with an empty space\n\t- {file_name} will be replaced with the current file name\n\t- {dir_name} will get replaced with the folder name that has the current file\n\t- {full_dir_name} will get replaced with the full directory name without the current file name\n\t- {workspace} will be replaced with the current workspace name, if any\n\t- {workspace_folder} will be replaced with the currently accessed workspace folder, if any\n\t- {workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - workspace_folder'\n\t- {current_column} will get replaced with the current column of the current line\n\t- {current_line} will get replaced with the current line number\n\t- {total_lines} will get replaced with the total line number\n\t- {git_repo} will be replaced by the current git repository (also detects repos in subdirectories) if any\n\t- {git_branch} will be replaced by the current git branch if in an repository\n\t- {problems} will be replaced with the count of problems (warnings, errors) present in your workspace."
"description": "Custom string for the state section of the rich presence\n\t- {empty} will be replaced with an empty space\n\t- {file_name} will be replaced with the current file name\n\t- {file_extension} will be replaced with the current file name\n\t- {dir_name} will get replaced with the folder name that has the current file\n\t- {full_dir_name} will get replaced with the full directory name without the current file name\n\t- {workspace} will be replaced with the current workspace name, if any\n\t- {workspace_folder} will be replaced with the currently accessed workspace folder, if any\n\t- {workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - workspace_folder'\n\t- {current_column} will get replaced with the current column of the current line\n\t- {current_line} will get replaced with the current line number\n\t- {total_lines} will get replaced with the total line number\n\t- {git_repo} will be replaced by the current git repository (also detects repos in subdirectories) if any\n\t- {git_branch} will be replaced by the current git branch if in an repository\n\t- {problems} will be replaced with the count of problems (warnings, errors) present in your workspace."
},
"rpc.lowerDetailsIdling": {
"type": "string",
Expand All @@ -184,12 +184,12 @@
"rpc.lowerDetailsDebugging": {
"type": "string",
"default": "Debugging: {workspace}",
"description": "Custom string for the state section of the rich presence when debugging\n\t- {empty} will be replaced with an empty space\n\t- {file_name} will be replaced with the current file name\n\t- {dir_name} will get replaced with the folder name that has the current file\n\t- {full_dir_name} will get replaced with the full directory name without the current file name\n\t- {workspace} will be replaced with the current workspace name, if any\n\t- {workspace_folder} will be replaced with the currently accessed workspace folder, if any\n\t- {workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - workspace_folder'\n\t- {current_column} will get replaced with the current column of the current line\n\t- {current_line} will get replaced with the current line number\n\t- {total_lines} will get replaced with the total line number\n\t- {git_repo} will be replaced by the current git repository (also detects repos in subdirectories) if any\n\t- {git_branch} will be replaced by the current git branch if in an repository\n\t- {problems} will be replaced with the count of problems (warnings, errors) present in your workspace."
"description": "Custom string for the state section of the rich presence when debugging\n\t- {empty} will be replaced with an empty space\n\t- {file_name} will be replaced with the current file name\n\t- {file_extension} will be replaced with the current file name\n\t- {dir_name} will get replaced with the folder name that has the current file\n\t- {full_dir_name} will get replaced with the full directory name without the current file name\n\t- {workspace} will be replaced with the current workspace name, if any\n\t- {workspace_folder} will be replaced with the currently accessed workspace folder, if any\n\t- {workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - workspace_folder'\n\t- {current_column} will get replaced with the current column of the current line\n\t- {current_line} will get replaced with the current line number\n\t- {total_lines} will get replaced with the total line number\n\t- {git_repo} will be replaced by the current git repository (also detects repos in subdirectories) if any\n\t- {git_branch} will be replaced by the current git branch if in an repository\n\t- {problems} will be replaced with the count of problems (warnings, errors) present in your workspace."
},
"rpc.lowerDetailsViewing": {
"type": "string",
"default": "Viewing {file_name}",
"description": "Custom string for the state section of the rich presence when viewing\n\t- {empty} will be replaced with an empty space\n\t- {file_name} will be replaced with the current file name\n\t- {dir_name} will get replaced with the folder name that has the current file\n\t- {full_dir_name} will get replaced with the full directory name without the current file name\n\t- {workspace} will be replaced with the current workspace name, if any\n\t- {workspace_folder} will be replaced with the currently accessed workspace folder, if any\n\t- {workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - workspace_folder'\n\t- {current_column} will get replaced with the current column of the current line\n\t- {current_line} will get replaced with the current line number\n\t- {total_lines} will get replaced with the total line number\n\t- {git_repo} will be replaced by the current git repository (also detects repos in subdirectories) if any\n\t- {git_branch} will be replaced by the current git branch if in an repository\n\t- {problems} will be replaced with the count of problems (warnings, errors) present in your workspace."
"description": "Custom string for the state section of the rich presence when viewing\n\t- {empty} will be replaced with an empty space\n\t- {file_name} will be replaced with the current file name\n\t- {file_extension} will be replaced with the current file name\n\t- {dir_name} will get replaced with the folder name that has the current file\n\t- {full_dir_name} will get replaced with the full directory name without the current file name\n\t- {workspace} will be replaced with the current workspace name, if any\n\t- {workspace_folder} will be replaced with the currently accessed workspace folder, if any\n\t- {workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - workspace_folder'\n\t- {current_column} will get replaced with the current column of the current line\n\t- {current_line} will get replaced with the current line number\n\t- {total_lines} will get replaced with the total line number\n\t- {git_repo} will be replaced by the current git repository (also detects repos in subdirectories) if any\n\t- {git_branch} will be replaced by the current git branch if in an repository\n\t- {problems} will be replaced with the count of problems (warnings, errors) present in your workspace."
},
"rpc.lowerDetailsNoWorkspaceFound": {
"type": "string",
Expand Down
1 change: 1 addition & 0 deletions src/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ function details(

raw = raw
.replace(REPLACE_KEYS.FileName, dataClass.fileName ?? FAKE_EMPTY)
.replace(REPLACE_KEYS.FileExtension, dataClass.fileExtension ?? FAKE_EMPTY)
.replace(REPLACE_KEYS.DirName, dataClass.dirName ?? FAKE_EMPTY)
.replace(REPLACE_KEYS.Workspace, workspaceName)
.replace(REPLACE_KEYS.WorkspaceFolder, workspaceFolderName)
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const enum CONFIG_KEYS {
export const enum REPLACE_KEYS {
Empty = '{empty}',
FileName = '{file_name}',
FileExtension = '{file_extension}',
DirName = '{dir_name}',
FullDirName = '{full_dir_name}',
Workspace = '{workspace}',
Expand Down
6 changes: 6 additions & 0 deletions src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ export class Data implements DisposableLike {
return v;
}

public get fileExtension(): string | undefined {
const v = this._file ? this._file.ext : undefined;
this.debug(4, `fileExtension(): ${v}`);
return v;
}

public get dirName(): string | undefined {
const v = this._file?.dir.split(sep).pop();
this.debug(4, `dirName(): ${v}`);
Expand Down

0 comments on commit d0cac0f

Please sign in to comment.