Created
May 2, 2012 16:09
-
-
Save assertchris/2577836 to your computer and use it in GitHub Desktop.
Highlight lines in Ace (Editor)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
CoffeeScript | |
marker = null; | |
require(["ace/range"], (range) -> | |
marker = editor.getSession().addMarker(new range.Range(7, 0, 7, 2000), "warning", "line", true); | |
) | |
setTimeout(-> | |
editor.getSession().removeMarker(marker) | |
, 3000) | |
### | |
### | |
CSS | |
.warning | |
{ | |
background: rgba(255, 50, 50, 0.1); | |
position: absolute; | |
width: 100% !important; | |
left: 0 !important; | |
} | |
### |
position: absolute is the secret sauce here. Without that you will be left scratching your head.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seven years old, but still useful!
A note to others using this as a reference: This puts the marker on top of the line, and uses transparency to achieve the highlighting effect. This will recolor the text slightly (and enough markers on the same line will obscure it completely). If you change the last argument to
addMarker()
(parameter nameinFront
) tofalse
the marker will sit beneath the text and you can use an opaque background color.