GithubHelp home page GithubHelp logo

surdu / scroll-marker Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 2.0 105 KB

Provides scrollbar highlight functionality for Atom Editor

Home Page: https://atom.io/packages/scroll-marker

License: MIT License

JavaScript 92.67% Less 7.33%
atom atom-package atom-editor scrollbar highlight hacktoberfest

scroll-marker's Introduction

Scroll Marker

Actions Status dependencies Status Buy me a coffee

This is a base package for Atom that provides the functionality for other atom packages (see list below) to highlight important things on the editor's scroll bar.

Screenshot

That means, in order to get any use out of this package, you also need to install one of the packages bellow.

Packages powered by Scroll Marker:

Name What it highlights Marker Layer Class
find-scroll-marker Search results. .find-marker-layer
lint-scroll-marker Lint errors found by linter, atom-ide-ui or nuclide. .link-scroll-marker-warn, .lint-scroll-marker-error or .link-scroll-marker-info
highlight-selected Occurrences of the selected text. Scrollbar highlight requires enabling in the package settings. .highlight-selected-selected-marker-layer

Customize marker color

If you would like to customize the color of the marker for one of the scroll marker types, place the following CSS in you Atom stylesheet:

<marker-layer-class> .scroll-marker {
	background-color: <css-color> !important;
}

Substitute <marker-layer-class> with one of the marker layer classes from the table above and <css-color> with a valid CSS color

Developer documentation

The next part is addressed to developers who want to use the services provided by this package in order to create their own scroll bar marker package or to add scroll bar highlight capabilities to their packages.

If you're new to Atom's Services API I would strongly encourage you to first read the documentation for Services API and their nice blog post about this topic.

The first thing that is needed is declare in your plugin's package.json that you want to consume the scroll-marker service:

{
  "name": "example-scroll-marker",
  "main": "lib/index.js",
  "version": "0.0.0",

  // ...

  "consumedServices": {
    "scroll-marker": {
      "versions": {
        "0.1.0": "consumeScrollMarker"
      }
    }
  }
}

Then, in your main JS file (in this case lib/index.js) add the consumeScrollMarker method:

module.exports = {
  activate() {
    // ...
  },

  consumeScrollMarker(api) {
    // Use `api` here
  },

  deactivate() {
    // ...
  }
};

This will give you the reference to the scroll-marker API.

API

getLayer(editor, name, color)

Creates and returns a singleton instance of Marker Layer. That means there will be only one instance of Marker Layer for a given editor/name combination.

This Marker Layer instance is what you'll use to add/remove markers to the scroll bar. All Markers added to this layer will have the specified color.

Arguments:

  • editor - an editor instance, usually acquired by using observeTextEditors
  • name - a unique name for the layer, usually the name of your package
  • color - CSS color that you want the markers added to this layer to be

Example:

consumeScrollMarker(api) {
  atom.workspace.observeTextEditors(function(editor) {
    const layer = api.getLayer(editor, "example-layer", "#00ff00");
    // ...
  });
}

Marker Layer

addMarker(line)

Adds a marker on the marker layer at the specified line.

Arguments:

  • line - line number you want to add the marker to. Note that the first line number is 0.

Example:

consumeScrollMarker(api) {
  atom.workspace.observeTextEditors(function(editor) {
    const layer = api.getLayer(editor, "example-layer", "#00ff00");
    layer.addMarker(2);
  });
}

syncToMarkerLayer(markerLayer)

Sync the markers on the scroll marker layer with the markers on a DisplayMarkerLayer.

Arguments:

  • markerLayer - an instance of DisplayMarkerLayer that is usually used to highlight text in the editor

Example:

consumeScrollMarker(api) {
  atom.workspace.observeTextEditors(function(editor) {
    const scrollLayer = api.getLayer(editor, "example-layer", "#00ff00");
    // `findApi` was obtained similarly to `api` but from find-and-replace package
    const searchLayer = findApi.resultsMarkerLayerForTextEditor(editor);

    scrollLayer.syncToMarkerLayer(searchLayer);
  });
}

For a detailed syncToMarkerLayer working example you can checkout the find-scroll-marker source code.

scroll-marker's People

Contributors

chameleonhider avatar dependabot[bot] avatar guidezpl avatar surdu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

scroll-marker's Issues

Failed to activate the scroll-marker package

[Enter steps to reproduce:]

  1. ...
  2. ...

Atom: 1.33.1 x64
Electron: 2.0.16
OS: Mac OS X 10.14.2
Thrown From: scroll-marker package 0.3.0

Stack Trace

Failed to activate the scroll-marker package

At Cannot read property 'fontSize' of undefined

TypeError: Cannot read property 'fontSize' of undefined
    at /packages/scroll-marker/lib/Marker.js:7:33)
    at /packages/scroll-marker/lib/Marker.js:51:3)
    at Module.get_Module._compile (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:146684)
    at Object.value [as .js] (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:150231)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:504:12)
    at Function.Module._load (module.js:496:3)
    at Module.require (/app.asar/static/index.js:47:45)
    at require (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:145974)
    at /packages/scroll-marker/lib/MarkerLayer.js:4:16)
    at /packages/scroll-marker/lib/MarkerLayer.js:64:3)
    at Module.get_Module._compile (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:146684)
    at Object.value [as .js] (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:150231)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:504:12)
    at Function.Module._load (module.js:496:3)
    at Module.require (/app.asar/static/index.js:47:45)
    at require (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:145974)
    at /packages/scroll-marker/lib/MarkerView.js:4:21)
    at /packages/scroll-marker/lib/MarkerView.js:47:3)
    at Module.get_Module._compile (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:146684)
    at Object.value [as .js] (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:150231)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:504:12)
    at Function.Module._load (module.js:496:3)
    at Module.require (/app.asar/static/index.js:47:45)
    at require (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:145974)
    at /packages/scroll-marker/lib/api.js:1:181)
    at /packages/scroll-marker/lib/api.js:23:3)
    at Module.get_Module._compile (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:146684)

Commands

Non-Core Packages

highlight-selected 0.14.0 
minimap 4.29.9 
scroll-marker 0.3.0 

Feature Request: marker for split-diff

Since minimap-split-diff makes my Atom painfully slow, I'd really appreciate some "lighter" diff highlighting. scroll-marker would be the ideal place for that!

Regards,
Alex

Doesn't work in Atom 1.32.2

Atom 1.32.2 x64 in Ubuntu 18.04.1
scroll-marker version 0.2.0

After installing, I restarted all Atom instances, but still it doesn't seem to add the markers:
image

I also have the symbols-list plugin, but even with it disabled, the markers don't appear. No errors appear in the Atom console.

TextEditor.getHeight is deprecated.

This is now a view method. Call TextEditorElement::getHeight instead.

TextEditor.getHeight (<embedded>:11:54607)
new Marker (C:\Users\aminy\.atom\packages\scroll-marker\lib\Marker.js:12:62)
render (C:\Users\aminy\.atom\packages\sync-settings\node_modules\etch\lib\render.js:21:25)
updateChildren (C:\Users\aminy\.atom\packages\sync-settings\node_modules\etch\lib\patch.js:117:34)
patch (C:\Users\aminy\.atom\packages\sync-settings\node_modules\etch\lib\patch.js:19:9)
updateSync (C:\Users\aminy\.atom\packages\sync-settings\node_modules\etch\lib\component-helpers.js:130:20)

Not showing in scroll bar

Windows 10
Atom ver 1.53.0
scroll-marker 0.3.5
find-scroll-marker 0.1.3

I am not seeing anything in the scroll bar.
I searched for installed packages that have anything to do with scroll and disabled them. Except for the two mentioned above, of course.
Changed UI and Syntax themes back to Atom Dark

Change scroll marker color for searches

Not really a bug, but hoping someone could help me out. I would like to change the scroll marker color from the default yellow to a different color.

search-scrollbar

Is that possible and if so, what would be the css rule to add to my stylesheet?

Add marker for multiple lines

This could help to develop plugins that highlight large portions of code, like diff tools.

Another possible side-feature would be that if two or more markers are added to adjacent lines, only one multi-line marker is created.

Inform users they need additional plugins

It may not be apparent to first time users that they also need additional plugins to make this one do something useful.

One idea would be to show a notification with this information, and capability to either jump to search with prefilled text or open a webpage to the list of scroll-marker plugins.

marker position is wrong when folding code blocks

In Atom, the body of functions/objects etc. can be folded into one line by clicking the arrow beside line number (I think this is part of the core functionalities). Marker created by scroll-marker will be at wrong position if code blocks are folded (more obvious if you fold a large chunk of code).

I think there would be two things that need to be changed:

  1. The calculation of marker's vertical position needs to account for folding.
  2. If any marker would be set on a folded (invisible) line, show it on the first line of that block instead.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.