Skip to content

Commit 98375f2

Browse files
committed
Add option for color text, LICENSE, and CHANGELOG.
Fixes: #1, #2, #4, #7
1 parent af4c443 commit 98375f2

File tree

5 files changed

+126
-64
lines changed

5 files changed

+126
-64
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Changelog
2+
3+
## [1.0.3] - 2017-08-08
4+
### Fixed
5+
- [#1](https://github.com/RoscoP/ActiveFileInStatusBar/issues/1) - Copy to clipboard doesn't respect fullPath setting
6+
- [#2](https://github.com/RoscoP/ActiveFileInStatusBar/issues/2) - Update configuration on config changed instead of file open
7+
- [#4](https://github.com/RoscoP/ActiveFileInStatusBar/issues/4) - Force display of absolute path when file is outside of opened folder
8+
- [#7](https://github.com/RoscoP/ActiveFileInStatusBar/issues/7) - The last active file is still shown even if there is no active editor
9+
10+
### Changed
11+
- Removed SVG marketplace icon as per changes to the [VSCode Marketplace requirements](https://code.visualstudio.com/docs/extensions/publish-extension#_usage).
12+
13+
### Added
14+
- Configuration `ActiveFileInStatusBar.color` for the color of the text of the file name in the statusbar.
15+
- Changelog file.
16+
- License file.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 RoscoP - https://github.com/RoscoP/ActiveFileInStatusBar
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

extension.js

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,69 @@
11
var vscode = require('vscode');
2+
var copypaste = require('copy-paste');
23
var path = require('path');
34

45
var sb = null;
56

67
function OnStatusBarUpdate( textEditor ) {
8+
textEditor = textEditor ? textEditor : vscode.window.activeTextEditor;
79
if( textEditor ){
810
var config = vscode.workspace.getConfiguration('ActiveFileInStatusBar');
9-
if( textEditor.document.isUntitled ){
11+
if( !textEditor.document || textEditor.document.isUntitled ){
1012
sb.text = '';
1113
sb.hide();
1214
}
1315
else {
1416
var filePath = textEditor.document.fileName;
15-
if (!config.fullpath && vscode.workspace.rootPath){
16-
filePath = path.relative(vscode.workspace.rootPath, textEditor.document.fileName);
17+
if (!config.fullpath){
18+
filePath = vscode.workspace.asRelativePath(textEditor.document.fileName)
19+
filePath = path.normalize(filePath)
1720
}
18-
var icon = '$(clippy)';
1921
sb.tooltip = 'Copy active file to clipboard';
2022
if (config.revealFile) {
21-
icon = '$(file-submodule)';
2223
sb.tooltip = 'Reveal file';
2324
}
24-
sb.text = icon + ' ' + filePath;
25+
sb.color = config.color;
26+
sb.text = filePath;
2527
sb.show();
2628
}
2729
}
2830
}
2931

3032
function CreateStatusBar() {
3133
var config = vscode.workspace.getConfiguration('ActiveFileInStatusBar');
32-
var sb = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
34+
var sb = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, -1);
3335
sb.text = '';
34-
sb.command = 'workbench.action.files.copyPathOfActiveFile';
35-
if (config.revealFile) {
36-
sb.command = 'workbench.action.files.revealActiveFileInWindows';
37-
}
36+
sb.command = 'extension.ActiveFileInStatusBarClicked';
3837
return sb;
3938
}
4039

4140
// this method is called when your extension is activated
4241
// your extension is activated the very first time the command is executed
4342
function activate(context) {
44-
4543
var config = vscode.workspace.getConfiguration('ActiveFileInStatusBar');
4644
if (config.enable) {
4745
sb = CreateStatusBar();
4846
vscode.window.onDidChangeActiveTextEditor( OnStatusBarUpdate );
47+
vscode.workspace.onDidChangeConfiguration( OnStatusBarUpdate );
4948
OnStatusBarUpdate( vscode.window.activeTextEditor );
5049

5150
context.subscriptions.push(sb);
5251
}
5352

53+
// The command has been defined in the package.json file
54+
// Now provide the implementation of the command with registerCommand
55+
// The commandId parameter must match the command field in package.json
56+
var disposable = vscode.commands.registerCommand('extension.ActiveFileInStatusBarClicked', function (args) {
57+
var config = vscode.workspace.getConfiguration('ActiveFileInStatusBar');
58+
if (config.revealFile){
59+
vscode.commands.executeCommand('workbench.action.files.revealActiveFileInWindows')
60+
}
61+
else {
62+
copypaste.copy(sb.text)
63+
}
64+
});
65+
context.subscriptions.push(disposable);
66+
5467
}
5568
exports.activate = activate;
5669

media/icon.png

1.93 KB
Loading

package.json

Lines changed: 64 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,65 @@
11
{
2-
"name": "ActiveFileInStatusBar",
3-
"displayName": "Active File In StatusBar",
4-
"description": "Add statusbar entry to show path for currently active file.",
5-
"version": "1.0.2",
6-
"publisher": "RoscoP",
7-
"engines": {
8-
"vscode": "^0.10.1"
9-
},
10-
"categories": [
11-
"Other"
12-
],
13-
"activationEvents": [
14-
"*"
15-
],
16-
"icon": "media/icon.svg",
17-
"galleryBanner": {
18-
"theme": "dark",
19-
"color": "#614051"
20-
},
21-
"icon_attribution": "Icon made by [Anton Saputro](http://www.flaticon.com/authors/anton-saputro) from [Flaticon](http://www.flaticon.com) is licensed by [Creative Commons BY 3.0](http://creativecommons.org/licenses/by/3.0/)",
22-
"main": "./extension",
23-
"contributes": {
24-
"configuration": {
25-
"type": "object",
26-
"title": "ActiveFileInStatusBar configuration",
27-
"properties": {
28-
"ActiveFileInStatusBar.enable": {
29-
"type": "boolean",
30-
"default": true,
31-
"description": "Enable/Disable ActiveFileInStatusBar"
32-
},
33-
"ActiveFileInStatusBar.fullpath": {
34-
"type": "boolean",
35-
"default": true,
36-
"description": "Show fullpath or relative path in status bar."
37-
},
38-
"ActiveFileInStatusBar.revealFile": {
39-
"type": "boolean",
40-
"default": false,
41-
"description": "Reveal the active file in the file system."
42-
}
43-
}
44-
}
45-
},
46-
"repository": {
47-
"type": "git",
48-
"url": "https://github.com/RoscoP/ActiveFileInStatusBar"
49-
},
50-
"devDependencies": {
51-
"vscode": "0.10.x"
52-
}
53-
}
2+
"name": "ActiveFileInStatusBar",
3+
"displayName": "Active File In StatusBar",
4+
"description": "Add statusbar entry to show path for currently active file.",
5+
"version": "1.0.3",
6+
"publisher": "RoscoP",
7+
"engines": {
8+
"vscode": "^0.10.1"
9+
},
10+
"categories": [
11+
"Other"
12+
],
13+
"activationEvents": [
14+
"*"
15+
],
16+
"icon": "media/icon.png",
17+
"galleryBanner": {
18+
"theme": "dark",
19+
"color": "#614051"
20+
},
21+
"icon_attribution": "Icon made by [Anton Saputro](http://www.flaticon.com/authors/anton-saputro) from [Flaticon](http://www.flaticon.com) is licensed by [Creative Commons BY 3.0](http://creativecommons.org/licenses/by/3.0/)",
22+
"main": "./extension",
23+
"contributes": {
24+
"commands": [{
25+
"command": "extension.ActiveFileInStatusBarClicked",
26+
"title": "ActiveFileInStatusBarClicked"
27+
}],
28+
"configuration": {
29+
"type": "object",
30+
"title": "ActiveFileInStatusBar configuration",
31+
"properties": {
32+
"ActiveFileInStatusBar.enable": {
33+
"type": "boolean",
34+
"default": true,
35+
"description": "Enable/Disable ActiveFileInStatusBar"
36+
},
37+
"ActiveFileInStatusBar.fullpath": {
38+
"type": "boolean",
39+
"default": true,
40+
"description": "Show fullpath or relative path in status bar."
41+
},
42+
"ActiveFileInStatusBar.revealFile": {
43+
"type": "boolean",
44+
"default": false,
45+
"description": "Reveal the active file in the file system."
46+
},
47+
"ActiveFileInStatusBar.color": {
48+
"type": "string",
49+
"default": "",
50+
"description": "Set text color for the filename in the status bar."
51+
}
52+
}
53+
}
54+
},
55+
"repository": {
56+
"type": "git",
57+
"url": "https://github.com/RoscoP/ActiveFileInStatusBar"
58+
},
59+
"dependencies": {
60+
"copy-paste": "^1.2.0"
61+
},
62+
"devDependencies": {
63+
"vscode": "0.10.x"
64+
}
65+
}

0 commit comments

Comments
 (0)