├── .editorconfig ├── .eslintrc.json ├── .gitignore ├── .vscode ├── extensions.json ├── launch.json └── settings.json ├── .vscodeignore ├── LICENSE ├── README.md ├── extension.js ├── icon.svg ├── jsconfig.json ├── package.json ├── selectlinestatusbar.js ├── test ├── extension.test.js └── index.js └── vsc-extension-quickstart.md /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": false, 4 | "commonjs": true, 5 | "es6": true, 6 | "node": true 7 | }, 8 | "parserOptions": { 9 | "ecmaFeatures": { 10 | "jsx": true 11 | }, 12 | "sourceType": "module" 13 | }, 14 | "rules": { 15 | "no-const-assign": "warn", 16 | "no-this-before-super": "warn", 17 | "no-undef": "warn", 18 | "no-unreachable": "warn", 19 | "no-unused-vars": "warn", 20 | "constructor-super": "warn", 21 | "valid-typeof": "warn", 22 | "semi": "error" 23 | } 24 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | *.vsix -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "dbaeumer.vscode-eslint" 6 | ] 7 | } -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension 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 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "typescript.tsdk": "./node_modules/typescript/lib" // we want to use the TS server from our node_modules folder to control its version 4 | } -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | test/** 4 | .gitignore 5 | jsconfig.json 6 | vsc-extension-quickstart.md 7 | .eslintrc.json 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 tomoki1207 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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # selectline-statusbar 2 | 3 | Displays selected lines count in status bar. 4 | 5 | ![ScreenShot](https://raw.githubusercontent.com/tomoki1207/selectline-statusbar/images/screenshot.png) 6 | 7 | ## Usage 8 | 9 | When you selected more 2 lines, selected lines count will be displayed in status bar. 10 | 11 | ### Configurations 12 | 13 | You can change the display in the following steps. 14 | 1. File > Preferences > User Setting (or Workspace Setting) 15 | 1. Add/Modify the these key-value. 16 | 17 | #### Format 18 | 19 | name|type|default 20 | :--|:--|:-- 21 | `selectline.displayFormat`|string|`Selected %d Lines` 22 | 23 | - Display format of selected lines. 24 | - The format can be use https://nodejs.org/api/util.html#util_util_format_format. 25 | - Argument into display format is line count only. 26 | - You can display with [octicon](https://octicons.github.com/) like `$(three-bars) Selected line: %d`. 27 | 28 | #### Alignment 29 | 30 | name|type|default 31 | :--|:--|:-- 32 | `selectline.alignment`|string (`left` or `right`)|`left` 33 | 34 | - Show on the left or right in the status bar. 35 | 36 | #### Statusbar priority 37 | 38 | name|type|default 39 | :--|:--|:-- 40 | `selectline.statusbarPriority`|number|`100` 41 | 42 | - The priority of display in the status bar. Higher value means shown the left. 43 | 44 | 45 | ## Change log 46 | - 0.0.2 (2017-3-7): Add an icon and some configurations 47 | - 0.0.1 (2016-10-6): Initial release 48 | 49 | ## License 50 | Please see [LICENSE]("./LICENSE"). -------------------------------------------------------------------------------- /extension.js: -------------------------------------------------------------------------------- 1 | const 2 | SelectLineStatusBar = require('./selectlinestatusbar'); 3 | 4 | function activate(context) { 5 | context.subscriptions.push(new SelectLineStatusBar()); 6 | } 7 | exports.activate = activate; 8 | 9 | function deactivate() { 10 | } 11 | exports.deactivate = deactivate; -------------------------------------------------------------------------------- /icon.svg: -------------------------------------------------------------------------------- 1 | selected-lines -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "lib": [ 6 | "es6" 7 | ] 8 | }, 9 | "exclude": [ 10 | "node_modules" 11 | ] 12 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "selectline-statusbar", 3 | "displayName": "Select Line Status Bar", 4 | "description": "Displays selected lines count in status bar", 5 | "version": "0.0.2", 6 | "publisher": "tomoki1207", 7 | "icon": "icon.svg", 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/tomoki1207/selectline-statusbar" 11 | }, 12 | "bugs": { 13 | "url": "https://github.com/tomoki1207/selectline-statusbar/issues" 14 | }, 15 | "license": "MIT", 16 | "engines": { 17 | "vscode": "^1.5.0" 18 | }, 19 | "categories": [ 20 | "Other" 21 | ], 22 | "activationEvents": [ 23 | "*" 24 | ], 25 | "main": "./extension", 26 | "contributes": { 27 | "commands": [], 28 | "configuration": { 29 | "type": "object", 30 | "title": "Select line configuration", 31 | "properties": { 32 | "selectline.displayFormat": { 33 | "type": "string", 34 | "default": "Selected %d Lines", 35 | "description": "Display format: according to https://nodejs.org/api/util.html#util_util_format_format" 36 | }, 37 | "selectline.alignment": { 38 | "type": "string", 39 | "enum": [ 40 | "left", "right" 41 | ], 42 | "default": "left", 43 | "description": "Controls the alignment of the selected lines. It can either show on the left or right of the status bar." 44 | }, 45 | "selectline.statusbarPriority": { 46 | "type": "number", 47 | "default": 100, 48 | "description": "The priority of the selected lines in status bar. Higher values mean the item should be shown more to the left." 49 | } 50 | } 51 | } 52 | }, 53 | "scripts": { 54 | "postinstall": "node ./node_modules/vscode/bin/install", 55 | "package": "vsce package" 56 | }, 57 | "devDependencies": { 58 | "@types/mocha": "^2.2.32", 59 | "@types/node": "^6.0.40", 60 | "eslint": "^3.7.1", 61 | "mocha": "^2.3.3", 62 | "typescript": "^2.0.3", 63 | "vsce": "^1.15.0", 64 | "vscode": "^1.0.0" 65 | } 66 | } -------------------------------------------------------------------------------- /selectlinestatusbar.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const 4 | vscode = require('vscode'), 5 | util = require('util'), 6 | DEFAULT_FORMAT = 'Selected %d Lines'; 7 | 8 | class SelectLineStatusBar { 9 | constructor() { 10 | this.alignConfig = vscode.workspace.getConfiguration('selectline').alignment || 'left'; 11 | this.statusBarPriority = vscode.workspace.getConfiguration('selectline').statusbarPriority || 100; 12 | this.displayFormat = vscode.workspace.getConfiguration('selectline').displayFormat || DEFAULT_FORMAT; 13 | this._statusBar = vscode.window.createStatusBarItem(this.getAlignmentEnum(this.alignConfig), this.statusBarPriority); 14 | vscode.window.onDidChangeActiveTextEditor(e => e && this.displaySelectedLineCount(e.selections)); 15 | vscode.window.onDidChangeTextEditorSelection(e => e && this.displaySelectedLineCount(e.selections)); 16 | vscode.window.onDidChangeTextEditorViewColumn(e => e && this.displaySelectedLineCount(e.selections)); 17 | 18 | vscode.workspace.onDidChangeConfiguration(() => { 19 | this.displayFormat = vscode.workspace.getConfiguration('selectline').displayFormat || DEFAULT_FORMAT; 20 | if ((vscode.workspace.getConfiguration('selectline').alignment || 'left') != this.alignConfig || (vscode.workspace.getConfiguration('selectline').statusbarPriority || 100) != this.statusBarPriority) { 21 | this.alignConfig = vscode.workspace.getConfiguration('selectline').alignment || 'left'; 22 | this.statusBarPriority = vscode.workspace.getConfiguration('selectline').statusbarPriority || 100; 23 | this._statusBar.hide(); 24 | this._statusBar.dispose(); 25 | this._statusBar = vscode.window.createStatusBarItem(this.getAlignmentEnum(this.alignConfig), this.statusBarPriority); 26 | } 27 | }); 28 | } 29 | displaySelectedLineCount(selections) { 30 | let selectedcount = selections.reduce((pre, selection) => pre + selection.end.line - selection.start.line + (selection.end.character == 0 ? 0 : 1), 0); 31 | if (selectedcount > 1) { 32 | this._statusBar.text = util.format(this.displayFormat, selectedcount); 33 | this._statusBar.show(); 34 | } else { 35 | this._statusBar.hide(); 36 | } 37 | } 38 | getAlignmentEnum(alignConfig) { 39 | if (alignConfig == 'left') { 40 | return vscode.StatusBarAlignment.Left; 41 | } else if (alignConfig == 'right') { 42 | return vscode.StatusBarAlignment.Right; 43 | } else { 44 | return vscode.StatusBarAlignment.Left; 45 | } 46 | } 47 | dispose() { 48 | this._statusBar.dispose(); 49 | } 50 | } 51 | 52 | module.exports = SelectLineStatusBar; -------------------------------------------------------------------------------- /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 | }); -------------------------------------------------------------------------------- /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; -------------------------------------------------------------------------------- /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 --------------------------------------------------------------------------------