├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ └── BUG-Report.yml └── workflows │ └── ci.yml ├── Documentation ├── Changelog.md ├── Contribute.md ├── Customize.md └── KeyBindings.md ├── LICENSE ├── README.md ├── Resources ├── Keymap.json ├── Menus.json ├── Screenshots │ ├── Selection.png │ ├── Showcase.png │ └── Underline.png ├── Space.svg └── Styles │ ├── Package.less │ └── Theme.less ├── Source ├── Actions.js ├── App.js ├── Commands.js ├── Marker.js ├── Model.js ├── Select.js └── Settings.js ├── Tests ├── Workspace │ └── Example.coffee └── highlight-line-spec.js └── package.json /.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root = true 3 | 4 | [*] 5 | 6 | end_of_line = lf 7 | 8 | [*.{gitignore,json,less,yml,js,md}] 9 | 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | indent_style = space 13 | indent_size = 4 14 | charset = utf-8 15 | 16 | [*.md] 17 | 18 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/BUG-Report.yml: -------------------------------------------------------------------------------- 1 | 2 | description : Create a new ticket for a bug. 3 | title : ❌ Title 4 | name : Bug Report 5 | 6 | labels: 7 | 8 | - bug 9 | 10 | body: 11 | 12 | # Pulsar Version 13 | 14 | - type : textarea 15 | id : pulsar-version 16 | 17 | attributes: 18 | 19 | description : Version of Pulsar, check with `pulsar --version` 20 | label : Pulsar Version 21 | value : | 22 | Pulsar : 1.100.0-beta 23 | Electron : 12.2.3 24 | Chrome : 89.0.4389.128 25 | Node : 14.16.0 26 | 27 | validations: 28 | 29 | required : true 30 | 31 | 32 | # Package Version 33 | 34 | - type : input 35 | id : package-version 36 | 37 | attributes: 38 | 39 | description : Version of Highlight-Line. 40 | placeholder : 0.12.0 41 | label : Package Version 42 | 43 | validations: 44 | 45 | required : true 46 | 47 | 48 | # Description 49 | 50 | - type : textarea 51 | id : description 52 | 53 | attributes: 54 | 55 | description : Please describe your problem as detailed as possible. 56 | label : Description 57 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | 2 | name: CI 3 | 4 | # Disabled as long as the GitHub Action 5 | # is not available / ppm is not properly 6 | # installed. 7 | # 8 | on: 9 | workflow_dispatch: 10 | 11 | # pull_request: 12 | 13 | # push: 14 | # branches: 15 | 16 | # - main 17 | 18 | jobs: 19 | 20 | Test: 21 | 22 | runs-on : ${{ matrix.os }} 23 | if : "!contains(github.event.head_commit.message,'[skip ci]')" 24 | 25 | strategy: 26 | matrix: 27 | channel : [ stable , beta ] 28 | os : [ ubuntu-latest , macos-latest , windows-latest ] 29 | 30 | steps: 31 | 32 | - uses : actions/checkout@v3 33 | 34 | # - uses : pulsar-edit/action-setup-pulsar 35 | # with : 36 | # channel : ${{ matrix.channel }} 37 | 38 | - name : Print Pulsar's Version 39 | run : pulsar -v 40 | 41 | - name : Print PPM's Version 42 | run : ppm -v 43 | 44 | - name : Install Dependencies 45 | run : ppm ci 46 | env : 47 | APM_TEST_PACKAGES : minimap minimap-highlight-selected status-bar 48 | 49 | - name : Run Tests 50 | run : npm run test 51 | 52 | 53 | Skip: 54 | 55 | runs-on : ubuntu-latest 56 | if : "contains(github.event.head_commit.message,'[skip ci]')" 57 | 58 | steps: 59 | 60 | - name : Skip CI 🚫 61 | run : echo skip ci 62 | -------------------------------------------------------------------------------- /Documentation/Changelog.md: -------------------------------------------------------------------------------- 1 | 2 | [][#] 3 | [][#] 4 | 5 |
6 | 7 | # Changelog 8 | 9 | *If not otherwise specified, commit are by **[@richrace]**.* 10 | 11 |
12 | 13 | ## 0.12.0 14 | 15 | `2016 / 12 / 28` 16 | 17 | - Changed to support only `Atom 1.13` selectors. 18 | 19 |
20 | 21 | ## 0.11.2 22 | 23 | `2016 / 12 / 28` 24 | 25 |
26 | 27 | #### [@itiut] 28 | 29 | - Update selected line when consolidating selections. 30 | 31 | 32 |
33 | 34 | ## 0.11.1 35 | 36 | `2016 / 02 / 02` 37 | 38 |
39 | 40 | #### [@shemerey] 41 | 42 | - Fixed    Cmd    **+**    L    empty line selection. 43 | 44 |
45 | 46 | ## 0.11.0 47 | 48 | `2015 / 04 / 18` 49 | 50 |
51 | 52 | - Removed `Space Pen View` dependency 53 | 54 | - No longer adds to the DOM. 55 | 56 |
57 | 58 | ## 0.10.2 59 | 60 | `2015 / 04 / 17` 61 | 62 | - Fixed activating package. #66 63 | 64 |
65 | 66 | ## 0.10.1 67 | 68 | `2015 / 03 / 01` 69 | 70 | - Fixed 1px border above the status bar. #62 71 | 72 |
73 | 74 | ## 0.10.0 75 | 76 | `2015 / 02 / 28` 77 | 78 | - Fixed specs 79 | 80 |
81 | 82 | #### [@skulled] 83 | 84 | - Fixed deprecations 85 | 86 |
87 | 88 |
89 | 90 | [][#] 91 | [][#] 92 | 93 |
94 | 95 | ## 0.9.3 96 | 97 | `2015 / 01 / 14` 98 | 99 | - Added support for Shadow Dom 100 | 101 |
102 | 103 | ## 0.9.0 104 | 105 | `2014 / 09 / 04` 106 | 107 | - Use new Event API 108 | 109 | - Use new config settings 110 | 111 |
112 | 113 | ## 0.8.1 114 | 115 | `2014 / 08 / 31` 116 | 117 | - Don't hide underline when hide highlight enabled 118 | 119 |
120 | 121 | ## 0.8.0 122 | 123 | `2014 / 08 / 24` 124 | 125 | - Total rewrite to use decorations 126 | 127 | - Use selection changed to handle multiple cursors 128 | 129 | - Make lines not exceed 80 columns 130 | 131 | - Ignore tmp folder 132 | 133 | - Add specs 134 | 135 | - Add Travis yml 136 | 137 |
138 | 139 | ## 0.7.6 140 | 141 | `2014 / 07 / 22` 142 | 143 | - Don't iterate over every line when resetting 144 | 145 | - Prepared release 146 | 147 |
148 | 149 | ## 0.7.5 150 | 151 | `2014 / 07 / 21` 152 | 153 | - Prepared release 154 | 155 |
156 | 157 | #### [@kelp404] 158 | 159 | - Fixed the highlight style doesn't remove. 160 | 161 |
162 | 163 | ## 0.7.4 164 | 165 | `2014 / 07 / 19` 166 | 167 | - Start moving logic into smaller methods 168 | 169 | - Only reset the top `.line` 170 | 171 | - Prepared release 172 | 173 |
174 | 175 | ## 0.7.3 176 | 177 | `2014 / 07 / 19` 178 | 179 | - Override theme's highlight line 180 | 181 | Don't multilines disappearing 182 | 183 | - Prepared release 184 | 185 |
186 | 187 |
188 | 189 | [][#] 190 | [][#] 191 | 192 |
193 | 194 | ## 0.7.2 195 | 196 | `2014 / 06 / 21` 197 | 198 | - Don't crash if the user hasn't selected underline style 199 | 200 | - Prepared release 201 | 202 |
203 | 204 | ## 0.7.1 205 | 206 | `2014 / 05 / 29` 207 | 208 | - Use `lineNodeForScreenRow` for React Editor 209 | 210 | - Prepared release 211 | 212 |
213 | 214 | ## 0.7.0 215 | 216 | `2014 / 05 / 24` 217 | 218 | - Fixes 219 | 220 | - Fix line height growing. 221 | 222 | - Add support for React Editor 223 | 224 | - Prepared release 225 | 226 |
227 | 228 | #### [@djak250] 229 | 230 | - Added support for selection borders, in the form of lines above and below the selection. This extends the underline functionality somewhat, and only triggers on multi line selection. Can be toggle with shift-alt-cmd-h. If underline is disabled, this will not show up 231 | 232 | - Added hotkey to toggle hiding the highlight on select 233 | 234 | - updated readme 235 | 236 | - Added screenshot for multi line selection borders 237 | 238 |
239 | 240 | ## 0.6.0 241 | 242 | `2014 / 04 / 03` 243 | 244 | - Closes #12 245 | 246 | - Update Readme 247 | 248 | - Prepared release 249 | 250 |
251 | 252 | #### [@djak250] 253 | 254 | - Added option to hide highlight on line when a chunk of text is selected. It will still show the underline which is a nice touch 255 | 256 |
257 | 258 | ## 0.5.5 259 | 260 | `2014 / 03 / 28` 261 | 262 | - Rename update setting 263 | 264 | - Remove all enabled 265 | 266 | - Make sure line is deleted 267 | 268 | - Prepared release 269 | 270 |
271 | 272 | #### [@philnash] 273 | 274 | - Handles opacity percentages better 275 | 276 |
277 | 278 |
279 | 280 | [][#] 281 | [][#] 282 | 283 |
284 | 285 | ## 0.5.4 286 | 287 | `2014 / 03 / 21` 288 | 289 | - Add Hotkeys/Menu for enabling/disabling Background/underline 290 | 291 | - Closes #10 292 | 293 | - Prepared release 294 | 295 |
296 | 297 | ## 0.5.3 298 | 299 | `2014 / 03 / 18` 300 | 301 | - Prepared release 302 | 303 |
304 | 305 | #### [@sniperbat] 306 | 307 | - Added background color enabler 308 | 309 | - Added back this plugin enable switch, fix syntax error 310 | 311 |
312 | 313 | ## 0.5.2 314 | 315 | `2014 / 03 / 15` 316 | 317 | - Keep height consistent. 318 | 319 | - Prepared release 320 | 321 |
322 | 323 | #### [@sniperbat] 324 | 325 | - Resolved the problem that the height of the line increase by one pixel when underline is enabled 326 | 327 |
328 | 329 | ## 0.5.1 330 | 331 | `2014 / 03 / 15` 332 | 333 | - Improve destroying event 334 | 335 | - Prepared release 336 | 337 |
338 | 339 | ## 0.5.0 340 | 341 | `2014 / 03 / 15` 342 | 343 | - Disable underline by default 344 | 345 | - Tidy up coffee 346 | 347 | - Updated README to include underline support 348 | 349 | - Prepared release 350 | 351 |
352 | 353 | #### [@sniperbat] 354 | 355 | - Added underline support 356 | 357 | 358 |
359 | 360 | ## 0.4.1 361 | 362 | `2014 / 03 / 13` 363 | 364 | - Fix error being thrown when moving tabs to different panes 365 | 366 | - Improve GC 367 | 368 | - Prepared release 369 | 370 |
371 | 372 |
373 | 374 | [][#] 375 | [][#] 376 | 377 |
378 | 379 | ## 0.4.0 380 | 381 | `2014 / 03 / 12` 382 | 383 | - Attempt to improve performance and stability 384 | 385 | - Prepared release 386 | 387 |
388 | 389 | ## 0.3.2 390 | 391 | `2014 / 03 / 09` 392 | 393 | - Change the triggering event. 394 | 395 | - Prepared release 396 | 397 |
398 | 399 | ## 0.3.1 400 | 401 | `2014 / 03 / 09` 402 | 403 | - Only look for Cursors on `EditorViews`. 404 | 405 | Closes #4 406 | 407 | - Prepared release 408 | 409 |
410 | 411 | ## 0.3.0 412 | 413 | `2014 / 03 / 09` 414 | 415 | - Add support for multiline highlights. 416 | 417 | Closes #3 418 | 419 | - Prepared release 420 | 421 |
422 | 423 | ## 0.2.1 424 | 425 | `2014 / 03 / 06` 426 | 427 | - All opacity to be set at 100 428 | 429 | - Prepared release 430 | 431 |
432 | 433 | ## 0.2.0 434 | 435 | `2014 / 03 / 05` 436 | 437 | - Add options to enable or disable the line, and to change the color of the line 438 | 439 | - Update Readme 440 | 441 | - Prepared release 442 | 443 |
444 | 445 | ## 0.1.0 446 | 447 | `2014 / 02 / 28` 448 | 449 | - Initial Commit 450 | 451 | - Stop it from crashing 452 | 453 | - Updated Read Me 454 | 455 | - Removed double brackets 456 | 457 | - Prepared release 458 | 459 |
460 | 461 |
462 | 463 | 464 | 465 | 466 | [@sniperbat]: https://github.com/sniperbat 467 | [@philnash]: https://github.com/philnash 468 | [@shemerey]: https://github.com/shemerey 469 | [@richrace]: https://github.com/richrace 470 | [@djak250]: https://github.com/djak250 471 | [@kelp404]: https://github.com/kelp404 472 | [@skulled]: https://github.com/skulled 473 | [@itiut]: https://github.com/itiut 474 | 475 | [#]: # 476 | -------------------------------------------------------------------------------- /Documentation/Contribute.md: -------------------------------------------------------------------------------- 1 | 2 | # Contributing 3 | 4 | Before you open a pull request, make sure to have all tests pass. 5 | 6 |
7 | 8 | ## Running Tests 9 | 10 | Tests can be run with: 11 | 12 | ```sh 13 | npm run test 14 | ``` 15 | 16 |
17 | -------------------------------------------------------------------------------- /Documentation/Customize.md: -------------------------------------------------------------------------------- 1 | 2 | # Customization 3 | 4 | Colors can be set by modifying the  [`Theme.less`] 5 | stylesheet or by adding to your  `style.less`  file. 6 | 7 |
8 | 9 | *Using the  `.cursor-line`  class selector is not recommended as 10 | you will loose highlighting when selecting text on the current line.* 11 | 12 |
13 | 14 | ```scss 15 | atom-text-editor::shadow { 16 | 17 | /* 18 | * Background 19 | * Uses !important to override theme specific settings 20 | */ 21 | 22 | .line.highlight-line { 23 | background : rgba( 255 , 0 , 0 , 0.3 ) !important ; 24 | } 25 | 26 | /* 27 | * Underline 28 | * Replace `solid` with `dashed` or `dotted` depending 29 | * on the style you selected in the settings. 30 | */ 31 | 32 | .line.highlight-line-multi-line-solid-bottom { 33 | border-bottom-color : red ; 34 | } 35 | 36 | /* 37 | * Borders 38 | * Style for the optional area selection borders. 39 | */ 40 | 41 | .line.highlight-line-multi-line-solid-top { 42 | border-top-color : red ; 43 | } 44 | } 45 | ``` 46 | 47 |
48 | 49 | [`Theme.less`]: ../Resources/Styles/Theme.less 50 | -------------------------------------------------------------------------------- /Documentation/KeyBindings.md: -------------------------------------------------------------------------------- 1 | 2 | # Keybindings 3 | 4 | *Toggles whether or not the ..* 5 | 6 |
7 | 8 | ## Highlighting 9 | 10 |   Cmd    **+**    Alt    **+**    H   11 | 12 |
13 | 14 | background of the current 15 | line should be highlighted. 16 | 17 |
18 | 19 | ## On Selection 20 | 21 |   Cmd    **+**    Alt    **+**    Shift    **+**    H   22 | 23 |
24 | 25 | background of the current line should be 26 | highlighted while selecting some text. 27 | 28 |
29 | 30 | ## Underline 31 | 32 |   Cmd    **+**    Alt    **+**    U   33 | 34 |
35 | 36 | current line should be underlined. 37 | 38 |
39 | 40 | ## Borders 41 | 42 |   Cmd    **+**    Alt    **+**    Shift    **+**    U   43 | 44 |
45 | 46 | area of the currently selection text should 47 | be have borders at the top and bottom. 48 | 49 |
50 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2014 Richard Race 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 |
5 | 6 | [![Badge Version]][Releases]   7 | [![Badge License]][License] 8 | 9 | 10 | 11 |
12 |
13 | 14 | # Highlight Line 15 | 16 | *Pulsar package that highlights the* 17 | *currently selected area of your editor.* 18 | 19 |
20 |
21 | 22 | [![Button Customize]][Customize]   23 | [![Button KeyBindings]][KeyBindings] 24 | 25 | [![Button Contribute]][Contribute]   26 | [![Button Changelog]][Changelog] 27 | 28 |
29 |
30 | 31 | [![Image Showcase]][#] 32 | 33 |
34 |
35 | 36 | ## Features 37 | 38 |
39 | 40 | You can enable underlining of the current 41 | line, as well as adjust it's color and style. 42 | 43 | [![Image Underline]][#] 44 | 45 |
46 |
47 | 48 | You can enable borders for multi-line selection. 49 | 50 | [![Image Selection]][#] 51 | 52 |
53 | 54 |
55 |
56 | 57 | ## Thanks To 58 | 59 |
60 | 61 | - **[@sniperbat]** 62 | 63 | *For the underline feature.* 64 | 65 | - **[@djak250]** 66 | 67 | *For the selection border feature.* 68 | 69 |
70 | 71 | 72 | 73 | [Releases]: https://github.com/Pulsar-Edit-Highlights/line/releases 74 | [Package]: https://web.pulsar-edit.dev/packages/highlight-line 75 | [Actions]: https://github.com/Pulsar-Edit-Highlights/line/actions 76 | 77 | [@sniperbat]: https://github.com/sniperbat 78 | [@djak250]: https://github.com/djak250 79 | 80 | [Image Selection]: Resources/Screenshots/Selection.png 81 | [Image Underline]: Resources/Screenshots/Underline.png 82 | [Image Showcase]: Resources/Screenshots/Showcase.png 83 | [KeyBindings]: Documentation/KeyBindings.md 84 | [Contribute]: Documentation/Contribute.md 85 | [Changelog]: Documentation/Changelog.md 86 | [Customize]: Documentation/Customize.md 87 | [License]: LICENSE 88 | 89 | [#]: # 90 | 91 | 92 | 93 | 94 | [Badge License]: https://img.shields.io/badge/License-MIT-ac8b11.svg?style=for-the-badge&labelColor=yellow&logo=GitBook&logoColor=white 95 | [Badge Version]: https://img.shields.io/github/package-json/v/Pulsar-Edit-Highlights/line?style=for-the-badge&logo=BookStack&logoColor=white&labelColor=609926&color=4e7a1e 96 | [Badge CI]: https://img.shields.io/github/actions/workflow/status/Pulsar-Edit-Highlights/line/ci.yml?style=for-the-badge&logo=GitHubActions&logoColor=white&color=582c6d&labelColor=73398D 97 | 98 | 99 | 100 | 101 | [Button KeyBindings]: https://img.shields.io/badge/KeyBindings-3499CD?style=for-the-badge&logoColor=white&logo=AppleArcade 102 | [Button Contribute]: https://img.shields.io/badge/Contribute-7952B3?style=for-the-badge&logoColor=white&logo=GitHub 103 | [Button Changelog]: https://img.shields.io/badge/Changelog-37814A?style=for-the-badge&logoColor=white&logo=GitLFS 104 | [Button Customize]: https://img.shields.io/badge/Customize-00979D?style=for-the-badge&logoColor=white&logo=Rainmeter 105 | -------------------------------------------------------------------------------- /Resources/Keymap.json: -------------------------------------------------------------------------------- 1 | { 2 | "atom-text-editor" : { 3 | "cmd-alt-shift-h" : "highlight-line:toggle-hide-highlight-on-select" , 4 | "cmd-alt-shift-u" : "highlight-line:toggle-selection-borders" , 5 | "cmd-shift-h" : "highlight-line:toggle-background" , 6 | "cmd-shift-u" : "highlight-line:toggle-underline" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Resources/Menus.json: -------------------------------------------------------------------------------- 1 | { 2 | "menu" : [{ 3 | 4 | "label" : "Packages" , 5 | 6 | "submenu" : [{ 7 | 8 | "label" : "Highlight Line" , 9 | 10 | "submenu" : [{ 11 | "command" : "highlight-line:toggle-background" , 12 | "label" : "Toggle Background" 13 | },{ 14 | "command" : "highlight-line:toggle-hide-highlight-on-select" , 15 | "label" : "Toggle Hide Highlight on Select" 16 | },{ 17 | "command" : "highlight-line:toggle-underline" , 18 | "label" : "Toggle Underline" 19 | },{ 20 | "command" : "highlight-line:toggle-selection-borders" , 21 | "label" : "Toggle Selection Borders" 22 | }] 23 | }] 24 | }] 25 | } 26 | -------------------------------------------------------------------------------- /Resources/Screenshots/Selection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pulsar-Edit-Highlights/line/ff7c54d1525dac16e92e020b55009f8b6a573dde/Resources/Screenshots/Selection.png -------------------------------------------------------------------------------- /Resources/Screenshots/Showcase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pulsar-Edit-Highlights/line/ff7c54d1525dac16e92e020b55009f8b6a573dde/Resources/Screenshots/Showcase.png -------------------------------------------------------------------------------- /Resources/Screenshots/Underline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pulsar-Edit-Highlights/line/ff7c54d1525dac16e92e020b55009f8b6a573dde/Resources/Screenshots/Underline.png -------------------------------------------------------------------------------- /Resources/Space.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Resources/Styles/Package.less: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * The UI variables found in this file are defined in the themes 4 | * you are using, for example check the atom-dark-ui theme: 5 | * 6 | * https://github.com/pulsar-edit/atom-dark-ui/blob/master/styles/ui-variables.less 7 | * 8 | */ 9 | 10 | 11 | @import "Theme"; 12 | 13 | @borderWidth : +1px; 14 | @marginWidth : -1px; 15 | 16 | 17 | .highlight-view.hidden { 18 | display : none ; 19 | } 20 | 21 | 22 | .highlight-multi-line ( @style : '' ){ 23 | 24 | .line[ class *= 'highlight-line-multi-line-@{style}-top' ]{ 25 | border-top-width : @borderWidth ; 26 | border-top-color : @lineColour ; 27 | border-top-style : @style ; 28 | margin-top : @marginWidth ; 29 | } 30 | 31 | .line[ class *= 'highlight-line-multi-line-@{style}-bottom' ]{ 32 | border-bottom-width : @borderWidth ; 33 | border-bottom-color : @lineColour ; 34 | border-bottom-style : @style ; 35 | margin-bottom : @marginWidth ; 36 | } 37 | } 38 | 39 | 40 | atom-text-editor { 41 | 42 | .line.highlight-line { 43 | background : @cursorBackground !important ; 44 | } 45 | 46 | .highlight-multi-line(dashed) ; 47 | .highlight-multi-line(dotted) ; 48 | .highlight-multi-line(solid) ; 49 | } 50 | -------------------------------------------------------------------------------- /Resources/Styles/Theme.less: -------------------------------------------------------------------------------- 1 | 2 | @cursorBackground : rgba( 100 , 100 , 100 , 0.3 ) ; 3 | 4 | @lineColour : rgb(202, 141, 29) ; 5 | -------------------------------------------------------------------------------- /Source/Actions.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | const Id = 'highlight-line'; 4 | 5 | 6 | const Actions = { 7 | 'toggle-hide-highlight-on-select' : 'hideHighlightOnSelect' , 8 | 'toggle-selection-borders' : 'enableSelectionBorder' , 9 | 'toggle-background' : 'enableBackgroundColor' , 10 | 'toggle-underline' : 'enableUnderline' 11 | } 12 | 13 | 14 | const toCommand = ( name ) => 15 | `${ Id }:${ name }` 16 | 17 | const toSetting = ( name ) => 18 | `${ Id }.${ name }` 19 | 20 | 21 | const toAction = ([ command , setting ]) => 22 | [ toCommand(command) , toSetting(setting) ] 23 | 24 | 25 | module.exports = Object 26 | .entries(Actions) 27 | .map(toAction) 28 | -------------------------------------------------------------------------------- /Source/App.js: -------------------------------------------------------------------------------- 1 | 2 | const 3 | { CompositeDisposable } = require('atom') , 4 | HighlightLineModel = require('./Model') , 5 | Commands = require('./Commands') ; 6 | 7 | 8 | 9 | module.exports = { 10 | 11 | subscriptions : null , 12 | line : null , 13 | 14 | 15 | activate (){ 16 | 17 | this.subscriptions = new CompositeDisposable; 18 | this.line = new HighlightLineModel; 19 | 20 | this.subscriptions.add( 21 | ... Commands.register() ); 22 | }, 23 | 24 | 25 | deactivate (){ 26 | 27 | const { subscriptions , line } = this; 28 | 29 | line.destroy(); 30 | 31 | subscriptions.dispose(); 32 | this.subscriptions = null; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Source/Commands.js: -------------------------------------------------------------------------------- 1 | 2 | const Actions = require('./Actions'); 3 | 4 | const { commands , config } = atom; 5 | 6 | 7 | 8 | function toggle ( setting ){ 9 | 10 | const opposite = ! 11 | config.get(setting); 12 | 13 | config.set(setting,opposite); 14 | } 15 | 16 | 17 | const registerAction = ([ action , setting ]) => 18 | commands.add('atom-workspace',{ 19 | [ action ] : () => toggle(setting) 20 | }); 21 | 22 | 23 | function * register (){ 24 | 25 | for ( const action of Actions ) 26 | yield registerAction(action) 27 | } 28 | 29 | 30 | 31 | module.exports = { register } 32 | -------------------------------------------------------------------------------- /Source/Marker.js: -------------------------------------------------------------------------------- 1 | 2 | const Settings = require('./Settings'); 3 | 4 | const { workspace } = atom; 5 | 6 | 7 | 8 | function marker ( range , styling ){ 9 | 10 | let selector = 'highlight-line'; 11 | 12 | if( styling ) 13 | selector += styling; 14 | 15 | 16 | const editor = workspace 17 | .getActiveTextEditor(); 18 | 19 | const marker = editor 20 | .markBufferRange(range); 21 | 22 | editor.decorateMarker(marker,{ 23 | class : selector , 24 | type : 'line' 25 | }) 26 | 27 | return marker 28 | } 29 | 30 | 31 | function line ( range , type ){ 32 | 33 | const { underlineStyle } = Settings; 34 | 35 | return marker(range,`-multi-line-${ underlineStyle }-${ type }`); 36 | } 37 | 38 | 39 | module.exports = { marker , line } 40 | -------------------------------------------------------------------------------- /Source/Model.js: -------------------------------------------------------------------------------- 1 | 2 | const { CompositeDisposable } = require('atom'); 3 | const { workspace , config } = atom; 4 | const select = require('./Select'); 5 | 6 | const activeEditor = () => 7 | workspace.getActiveTextEditor(); 8 | 9 | 10 | module.exports = class HighlightLineView { 11 | 12 | subscriptions = new CompositeDisposable; 13 | markers = []; 14 | 15 | 16 | constructor (){ 17 | 18 | const update = () => 19 | this.updateSelectedLine(); 20 | 21 | 22 | const { subscriptions } = this; 23 | 24 | subscriptions.add( 25 | workspace.observeTextEditors((editor) => { 26 | editor.onDidChangeSelectionRange(update); 27 | editor.onDidRemoveSelection(update); 28 | editor.onDidAddSelection(update); 29 | })); 30 | 31 | subscriptions.add( 32 | workspace.onDidChangeActivePaneItem(update)); 33 | 34 | 35 | this.observeSettings(); 36 | this.updateSelectedLine(); 37 | } 38 | 39 | 40 | // Tear down any state and detach 41 | 42 | destroy (){ 43 | this.subscriptions.dispose(); 44 | } 45 | 46 | 47 | updateSelectedLine (){ 48 | this.resetBackground(); 49 | this.showHighlight(); 50 | } 51 | 52 | 53 | resetBackground (){ 54 | 55 | for ( const marker of this.markers ) 56 | marker.destroy(); 57 | 58 | this.markers = []; 59 | } 60 | 61 | showHighlight (){ 62 | 63 | if( ! activeEditor() ) 64 | return; 65 | 66 | this.markers.push( ... select() ); 67 | } 68 | 69 | 70 | observeSettings (){ 71 | 72 | const { subscriptions } = this; 73 | 74 | const settings = [ 75 | 'highlight-line.enableBackgroundColor' , 76 | 'highlight-line.hideHighlightOnSelect' , 77 | 'highlight-line.enableSelectionBorder' , 78 | 'highlight-line.enableUnderline' 79 | ] 80 | 81 | for ( const setting of settings ){ 82 | 83 | const listener = config 84 | .onDidChange(setting,() => this.updateSelectedLine()); 85 | 86 | subscriptions.add(listener); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Source/Select.js: -------------------------------------------------------------------------------- 1 | 2 | const { marker , line } = require('./Marker'); 3 | const Settings = require('./Settings'); 4 | 5 | const { workspace } = atom; 6 | 7 | 8 | const toContent = ( selection ) => [ 9 | selection.isSingleScreenLine() , 10 | selection.getBufferRange() , 11 | selection.getText() 12 | ] 13 | 14 | const selections = () => workspace 15 | .getActiveTextEditor() 16 | .getSelections() 17 | .map(toContent); 18 | 19 | 20 | module.exports = function * (){ 21 | 22 | const { hideWhenSelecting , paintUnderline , 23 | paintBackground , paintOverline } = Settings; 24 | 25 | 26 | for ( const [ single , range , text ] of selections() ){ 27 | 28 | if( single ){ 29 | 30 | if( paintUnderline) 31 | yield line(range,'bottom'); 32 | 33 | if( ! paintBackground ) 34 | continue 35 | 36 | if( text.length && hideWhenSelecting ) 37 | continue 38 | 39 | yield marker(range); 40 | 41 | continue 42 | } 43 | 44 | if( ! paintOverline ) 45 | continue 46 | 47 | const [ bottom , top ] = 48 | [ range.copy() , range.copy() ]; 49 | 50 | bottom.start = bottom.end; 51 | top.end = top.start; 52 | 53 | if(bottom.start.column === 0) 54 | bottom.start.row -= 1; 55 | 56 | yield line(bottom,'bottom'); 57 | yield line(top,'top'); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Source/Settings.js: -------------------------------------------------------------------------------- 1 | 2 | const { config } = atom; 3 | 4 | 5 | const Settings = { 6 | hideWhenSelecting : 'hideHighlightOnSelect' , 7 | paintBackground : 'enableBackgroundColor' , 8 | paintUnderline : 'enableUnderline' , 9 | underlineStyle : 'underline' , 10 | paintOverline : 'enableSelectionBorder' 11 | } 12 | 13 | 14 | const { defineProperty , entries } = Object; 15 | 16 | 17 | for ( const [ name , setting ] of entries(Settings)){ 18 | 19 | const get = () => config 20 | .get(`highlight-line.${ setting }`); 21 | 22 | defineProperty(exports,name,{ get }) 23 | } 24 | -------------------------------------------------------------------------------- /Tests/Workspace/Example.coffee: -------------------------------------------------------------------------------- 1 | # Sample file for ensuring the regions get added. 2 | # Output Fizz on multiples of 3, Output Buzz on multiples of 5 3 | # Output FizzBuzz on multiples of 3 and 5 4 | 5 | output = "" 6 | 7 | i = 1 8 | while i <= 100 9 | string = "#{i} " 10 | string += 'Fizz' if i % 3 is 0 11 | string += 'Buzz' if i % 5 is 0 12 | output += "#{string}\n" 13 | i++ 14 | -------------------------------------------------------------------------------- /Tests/highlight-line-spec.js: -------------------------------------------------------------------------------- 1 | 2 | const { Range , Point } = require('atom'); 3 | 4 | const path = require('path'); 5 | 6 | 7 | const cmd = path 8 | .join(__dirname,'Workspace'); 9 | 10 | 11 | const { workspace , packages , project , config , views } = atom; 12 | 13 | 14 | describe(`Highlight Line`,() => { 15 | 16 | let activationPromise , 17 | workspaceElement , 18 | editorElement , 19 | editor ; 20 | 21 | 22 | const queryAll = ( selector ) => 23 | editorElement.querySelectorAll(selector); 24 | 25 | const selectRanges = ( ... ranges ) => 26 | editor.setSelectedBufferRanges(ranges); 27 | 28 | const selectArea = ( a , b ) => 29 | selectRanges(new Range( 30 | new Point( ... a ) , 31 | new Point( ... b ) )) 32 | 33 | const selectPosition = ( x , y ) => 34 | selectArea([ x , y ],[ x , y ]); 35 | 36 | const addClass = ( classname ) => 37 | config.set(`highlight-line.${ classname }`,true); 38 | 39 | const expectSelector = ( selector , amount ) => 40 | expect(queryAll(selector)).toHaveLength(amount); 41 | 42 | 43 | beforeEach(async () => { 44 | 45 | workspaceElement = views 46 | .getView(workspace); 47 | 48 | project.setPaths([ cmd ]); 49 | 50 | await workspace.open('Example.coffee'); 51 | 52 | runs(() => { 53 | 54 | jasmine.attachToDOM(workspaceElement); 55 | 56 | editor = workspace 57 | .getActiveTextEditor(); 58 | 59 | editorElement = views 60 | .getView(editor); 61 | 62 | activationPromise = packages 63 | .activatePackage('highlight-line'); 64 | }); 65 | 66 | return await activationPromise 67 | }); 68 | 69 | 70 | describe(`When the view is loaded`,() => 71 | it(`does not attach to the view`,() => 72 | expectSelector('.highlight-view',0))); 73 | 74 | 75 | return describe(`When the background color is enabled`,() => { 76 | 77 | beforeEach(() => 78 | addClass('enabledBackgroundColor')); 79 | 80 | describe(`When there is only one cursor`,() => { 81 | 82 | beforeEach(() => 83 | selectPosition(8,2)); 84 | 85 | it(`adds the background class to the cursor line`,() => 86 | expectSelector('.cursor-line.highlight-line',1)); 87 | 88 | return describe(`When hide highlight on select is enabled`,() => { 89 | 90 | beforeEach(() => 91 | addClass('hideHighlightOnSelect')); 92 | 93 | it('will have a highlight when there is no text selected', () => 94 | expectSelector('.cursor-line.highlight-line',1)); 95 | 96 | return it(`won't have a highlight when there is text selected`,() => { 97 | 98 | selectArea([ 8 , 2 ],[ 8 , 5 ]); 99 | 100 | return expectSelector('.cursor-line.highlight-line',0); 101 | }); 102 | }); 103 | }); 104 | 105 | 106 | describe(`When underline is enabled`,() => { 107 | 108 | beforeEach(() => 109 | addClass('enableUnderline')); 110 | 111 | describe(`When solid settings has been set`,() => { 112 | 113 | beforeEach(() => { 114 | config.set('highlight-line.underline','solid'); 115 | return selectPosition(8,2); 116 | }); 117 | 118 | it(`adds an underline to the current line`,() => 119 | expectSelector('.cursor-line.highlight-line-multi-line-solid-bottom',1)); 120 | 121 | return describe(`When hide highlight on select is enabled`,() => { 122 | 123 | beforeEach(() => 124 | addClass('hideHighlightOnSelect')); 125 | 126 | return it(`will still have a line`,() => { 127 | 128 | selectArea([ 8 , 2 ],[ 8 , 5 ]) 129 | 130 | return expectSelector('.line.highlight-line-multi-line-solid-bottom',1); 131 | }); 132 | }); 133 | }); 134 | 135 | describe(`When dashed settings has been set`,() => { 136 | 137 | beforeEach(() => { 138 | 139 | config.set('highlight-line.underline','dashed'); 140 | 141 | return selectPosition(8,2); 142 | }); 143 | 144 | return it(`adds an underline to the current line`,() => 145 | expectSelector('.cursor-line.highlight-line-multi-line-dashed-bottom',1)); 146 | }); 147 | 148 | return describe(`When dotted settings has been set`,() => { 149 | 150 | beforeEach(() => { 151 | 152 | config.set('highlight-line.underline','dotted'); 153 | 154 | return selectPosition(8,2); 155 | }); 156 | 157 | return it(`adds an underline to the current line`,() => 158 | expectSelector('.cursor-line.highlight-line-multi-line-dotted-bottom',1)); 159 | }); 160 | }); 161 | 162 | describe(`When there are two cursors`,() => { 163 | 164 | beforeEach(() => 165 | selectRanges( 166 | new Range(new Point(8,2),new Point(8,2)) , 167 | new Range(new Point(10,2),new Point(10,2)) 168 | )); 169 | 170 | return it(`adds the background class to the cursor line`,() => 171 | expectSelector('.cursor-line.highlight-line',2)); 172 | }); 173 | 174 | 175 | return describe(`When there is a multi row selection`,() => { 176 | 177 | beforeEach(() => 178 | selectArea([ 8 , 2 ],[ 10 , 8 ])); 179 | 180 | it(`won't add a highlight line class`,() => 181 | expectSelector('.cursor-line.highlight-line',0)); 182 | 183 | return describe(`When selection border is enabled`,() => { 184 | 185 | beforeEach(() => { 186 | addClass('enableSelectionBorder'); 187 | config.set('highlight-line.underline','solid'); 188 | return selectArea([ 8 , 2 ],[ 10 , 8 ]) 189 | }); 190 | 191 | return it(`will add highlights to the top and bottom`,() => 192 | expectSelector('.cursor-line .highlight-line-multi-line-solid-top .highlight-line-multi-line-solid-bottom',0)); 193 | }); 194 | }); 195 | }); 196 | }); 197 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Highlights the current line in your editor", 3 | "repository": "https://github.com/Pulsar-Edit-Highlights/line", 4 | "homepage": "https://github.com/Pulsar-Edit-Highlights/line", 5 | "version": "1.0.1", 6 | "license": "MIT", 7 | "name": "line", 8 | "keywords": [ 9 | "highlight", 10 | "line", 11 | "selectiton" 12 | ], 13 | "bugs": { 14 | "url": "https://github.com/Pulsar-Edit-Highlights/line/issues" 15 | }, 16 | "keymaps": [ 17 | "../Resources/Keymap.json" 18 | ], 19 | "menus": [ 20 | "../Resources/Menus.json" 21 | ], 22 | "main": "./Source/App", 23 | "styleSheets": [ 24 | "../Resources/Styles/Package.less", 25 | "../Resources/Styles/Theme.less" 26 | ], 27 | "scripts": { 28 | "test": "pulsar --test Tests" 29 | }, 30 | "engines": { 31 | "pulsar": ">=1.100.0 <2.0.0" 32 | }, 33 | "configSchema": { 34 | "enableBackgroundColor": { 35 | "default": true, 36 | "type": "boolean" 37 | }, 38 | "hideHighlightOnSelect": { 39 | "default": false, 40 | "type": "boolean" 41 | }, 42 | "enableSelectionBorder": { 43 | "default": false, 44 | "type": "boolean" 45 | }, 46 | "enableUnderline": { 47 | "default": false, 48 | "type": "boolean" 49 | }, 50 | "underline": { 51 | "default": "solid", 52 | "enum": [ 53 | "solid", 54 | "dotted", 55 | "dashed" 56 | ], 57 | "type": "string" 58 | } 59 | } 60 | } 61 | --------------------------------------------------------------------------------