├── .gitignore
├── demo.png
├── demo.psd
├── icon.png
├── icon.psd
├── typings
├── node.d.ts
└── vscode-typings.d.ts
├── .vscodeignore
├── jsconfig.json
├── clockservice.js
├── .vscode
└── launch.json
├── test
├── extension.test.js
└── index.js
├── clockstatusbaritem.js
├── package.json
├── README.md
├── extension.js
└── vsc-extension-quickstart.md
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/compulim/vscode-clock/HEAD/demo.png
--------------------------------------------------------------------------------
/demo.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/compulim/vscode-clock/HEAD/demo.psd
--------------------------------------------------------------------------------
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/compulim/vscode-clock/HEAD/icon.png
--------------------------------------------------------------------------------
/icon.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/compulim/vscode-clock/HEAD/icon.psd
--------------------------------------------------------------------------------
/typings/node.d.ts:
--------------------------------------------------------------------------------
1 | ///
--------------------------------------------------------------------------------
/typings/vscode-typings.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/.vscodeignore:
--------------------------------------------------------------------------------
1 | .vscode/**
2 | typings/**
3 | test/**
4 | .gitignore
5 | jsconfig.json
6 | vsc-extension-quickstart.md
7 | *.gif
8 | demo.*
9 | *.psd
--------------------------------------------------------------------------------
/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "ES5",
5 | "noLib": true
6 | },
7 | "exclude": [
8 | "node_modules"
9 | ]
10 | }
--------------------------------------------------------------------------------
/clockservice.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const
4 | dateformat = require('dateformat'),
5 | vscode = require('vscode');
6 |
7 | const DEFAULT_DATE_FORMAT = 'hh:MM TT';
8 |
9 | module.exports = function () {
10 | return dateformat(Date.now(), vscode.workspace.getConfiguration('clock').dateFormat || DEFAULT_DATE_FORMAT);
11 | };
12 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | // A launch configuration that compiles the extension and then opens it inside a new window
2 | {
3 | "version": "0.1.0",
4 | "configurations": [
5 | {
6 | "name": "Launch Extension",
7 | "type": "extensionHost",
8 | "request": "launch",
9 | "runtimeExecutable": "${execPath}",
10 | "args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
11 | "stopOnEntry": false
12 | },
13 | {
14 | "name": "Launch Tests",
15 | "type": "extensionHost",
16 | "request": "launch",
17 | "runtimeExecutable": "${execPath}",
18 | "args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/test" ],
19 | "stopOnEntry": false
20 | }
21 | ]
22 | }
--------------------------------------------------------------------------------
/test/extension.test.js:
--------------------------------------------------------------------------------
1 | /* global suite, test */
2 |
3 | //
4 | // Note: This example test is leveraging the Mocha test framework.
5 | // Please refer to their documentation on https://mochajs.org/ for help.
6 | //
7 |
8 | // The module 'assert' provides assertion methods from node
9 | var assert = require('assert');
10 |
11 | // You can import and use all API from the 'vscode' module
12 | // as well as import your extension to test it
13 | var vscode = require('vscode');
14 | var myExtension = require('../extension');
15 |
16 | // Defines a Mocha test suite to group tests of similar kind together
17 | suite("Extension Tests", function() {
18 |
19 | // Defines a Mocha unit test
20 | test("Something 1", function() {
21 | assert.equal(-1, [1, 2, 3].indexOf(5));
22 | assert.equal(-1, [1, 2, 3].indexOf(0));
23 | });
24 | });
--------------------------------------------------------------------------------
/clockstatusbaritem.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const
4 | clockService = require('./clockservice'),
5 | dateformat = require('dateformat'),
6 | vscode = require('vscode');
7 |
8 | const DEFAULT_DATE_FORMAT = 'hh:MM TT';
9 |
10 | class StatusBarItem {
11 | constructor() {
12 | this._statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, -100);
13 | this._statusBarItem.command = 'clock.insertDateTime';
14 | this._statusBarItem.tooltip = 'Click to insert into selection';
15 | this._statusBarItem.show();
16 |
17 | this._interval = setInterval(() => this.refreshUI(), 1000);
18 |
19 | this.refreshUI();
20 | }
21 |
22 | dispose() {
23 | this._statusBarItem.dispose();
24 | clearInterval(this._interval);
25 | }
26 |
27 | refreshUI() {
28 | this._statusBarItem.text = clockService();
29 | }
30 | }
31 |
32 | module.exports = StatusBarItem;
--------------------------------------------------------------------------------
/test/index.js:
--------------------------------------------------------------------------------
1 | //
2 | // PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
3 | //
4 | // This file is providing the test runner to use when running extension tests.
5 | // By default the test runner in use is Mocha based.
6 | //
7 | // You can provide your own test runner if you want to override it by exporting
8 | // a function run(testRoot: string, clb: (error:Error) => void) that the extension
9 | // host can call to run the tests. The test runner is expected to use console.log
10 | // to report the results back to the caller. When the tests are finished, return
11 | // a possible error to the callback or null if none.
12 |
13 | var testRunner = require('vscode/lib/testrunner');
14 |
15 | // You can directly control Mocha options by uncommenting the following lines
16 | // See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
17 | testRunner.configure({
18 | ui: 'tdd', // the TDD UI is being used in extension.test.js (suite, test, etc.)
19 | useColors: true // colored output from test results
20 | });
21 |
22 | module.exports = testRunner;
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vscode-clock",
3 | "displayName": "Clock",
4 | "description": "Displays clock in status bar and insert into file",
5 | "version": "0.0.1",
6 | "publisher": "Compulim",
7 | "engines": {
8 | "vscode": "^0.10.1"
9 | },
10 | "icon": "icon.png",
11 | "galleryBanner.color": "#0D5CAB",
12 | "repository": {
13 | "type": "git",
14 | "url": "https://github.com/compulim/vscode-clock.git"
15 | },
16 | "bugs": "https://github.com/compulim/vscode-clock/issues/",
17 | "homepage": "https://github.com/compulim/vscode-clock/blob/master/README.md",
18 | "keywords": [
19 | "clock",
20 | "timer",
21 | "alarm"
22 | ],
23 | "categories": [
24 | "Other"
25 | ],
26 | "activationEvents": [
27 | "*"
28 | ],
29 | "main": "./extension",
30 | "contributes": {
31 | "commands": [{
32 | "command": "clock.insertDateTime",
33 | "title": "Clock: Insert date and time"
34 | }],
35 | "configuration": {
36 | "type": "object",
37 | "title": "Clock configuration",
38 | "properties": {
39 | "clock.dateFormat": {
40 | "type": "string",
41 | "default": "hh:MM TT",
42 | "description": "Clock: Date format according to https://github.com/felixge/node-dateformat"
43 | }
44 | }
45 | }
46 | },
47 | "devDependencies": {
48 | "vscode": "0.11.x"
49 | },
50 | "dependencies": {
51 | "dateformat": "^1.0.12"
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Clock for Visual Studio Code
2 | Shows clock in status bar in Visual Studio Code, even in full screen mode.
3 |
4 | 
5 |
6 | ## Usage
7 | When the extension is installed, a clock will be displayed on the lower right hand corner.
8 |
9 | The date time format can be changed via preferences
10 | * File > Preferences > User Settings
11 | * Adds the following line
12 | * ```"clock.dateFormat": "hh:MM TT"```
13 | * Date format can be found at https://github.com/felixge/node-dateformat
14 |
15 | To insert the clock into the selection, you can either click on the clock on status bar, or use the Command Palette.
16 | * Bring up Command Palette (`F1`, or `Ctrl+Shift+P` on Windows and Linux, or `Shift+CMD+P` on OSX)
17 | * Type or select "Clock: Insert date and time"
18 |
19 | You can also modify keyboard shortcut with JSON below.
20 | ```
21 | {
22 | "key": "ctrl+shift+f5",
23 | "command": "clock.insertDateTime",
24 | "when": "editorTextFocus"
25 | }
26 | ```
27 |
28 | ## Change log
29 | * 0.0.1 (2016-02-24): First public release
30 |
31 | ## Contributions
32 | Love this extension? [Star](https://github.com/compulim/vscode-clock/stargazers) us!
33 |
34 | Want to make this extension even more awesome? [Send us your wish](https://github.com/compulim/vscode-clock/issues/new/).
35 |
36 | Hate how it is working? [File an issue](https://github.com/compulim/vscode-clock/issues/new/) to us.
37 |
--------------------------------------------------------------------------------
/extension.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | // The module 'vscode' contains the VS Code extensibility API
4 | // Import the module and reference it with the alias vscode in your code below
5 | const
6 | clockService = require('./clockservice'),
7 | ClockStatusBarItem = require('./clockstatusbaritem'),
8 | vscode = require('vscode');
9 |
10 | // this method is called when your extension is activated
11 | // your extension is activated the very first time the command is executed
12 | function activate(context) {
13 | // Use the console to output diagnostic information (console.log) and errors (console.error)
14 | // This line of code will only be executed once when your extension is activated
15 |
16 | // The command has been defined in the package.json file
17 | // Now provide the implementation of the command with registerCommand
18 | // The commandId parameter must match the command field in package.json
19 | context.subscriptions.push(new ClockStatusBarItem());
20 |
21 | context.subscriptions.push(vscode.commands.registerTextEditorCommand('clock.insertDateTime', (textEditor, edit) => {
22 | textEditor.selections.forEach(selection => {
23 | const
24 | start = selection.start,
25 | end = selection.end;
26 |
27 | if (start.line === end.line && start.character === end.character) {
28 | edit.insert(start, clockService());
29 | } else {
30 | edit.replace(selection, clockService());
31 | }
32 | });
33 | }));
34 | }
35 |
36 | exports.activate = activate;
37 |
38 | // this method is called when your extension is deactivated
39 | function deactivate() {
40 | }
41 |
42 | exports.deactivate = deactivate;
--------------------------------------------------------------------------------
/vsc-extension-quickstart.md:
--------------------------------------------------------------------------------
1 | # Welcome to your first VS Code Extension
2 |
3 | ## What's in the folder
4 | * This folder contains all of the files necessary for your extension
5 | * `package.json` - this is the manifest file in which you declare your extension and command.
6 | The sample plugin registers a command and defines its title and command name. With this information
7 | VS Code can show the command in the command palette. It doesn’t yet need to load the plugin.
8 | * `extension.js` - this is the main file where you will provide the implementation of your command.
9 | The file exports one function, `activate`, which is called the very first time your extension is
10 | activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`.
11 | We pass the function containing the implementation of the command as the second parameter to
12 | `registerCommand`.
13 |
14 | ## Get up and running straight away
15 | * press `F5` to open a new window with your extension loaded
16 | * run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`
17 | * set breakpoints in your code inside extension.ts to debug your extension
18 | * find output from your extension in the debug console
19 |
20 | ## Make changes
21 | * you can relaunch the extension from the debug toolbar after changing code in `extension.js`
22 | * you can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes
23 |
24 | ## Explore the API
25 | * you can open the full set of our API when you open the file `node_modules/vscode/vscode.d.ts`
26 |
27 | ## Run tests
28 | * open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Launch Tests`
29 | * press `F5` to run the tests in a new window with your extension loaded
30 | * see the output of the test result in the debug console
31 | * make changes to `test/extension.test.js` or create new test files inside the `test` folder
32 | * by convention, the test runner will only consider files matching the name pattern `**.test.js`
33 | * you can create folders inside the `test` folder to structure your tests any way you want
--------------------------------------------------------------------------------