Skip to content

Commit 18d3e0b

Browse files
sbruchmannmarijnh
authored andcommitted
[active-line addon] Add active line number
This patch enables styling of active line numbers by adding a `CodeMirror-activeline-gutter` class to the line's gutter space.
1 parent c4908be commit 18d3e0b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

addon/selection/active-line.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"use strict";
1919
var WRAP_CLASS = "CodeMirror-activeline";
2020
var BACK_CLASS = "CodeMirror-activeline-background";
21+
var GUTT_CLASS = "CodeMirror-activeline-gutter";
2122

2223
CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
2324
var prev = old && old != CodeMirror.Init;
@@ -36,6 +37,7 @@
3637
for (var i = 0; i < cm.state.activeLines.length; i++) {
3738
cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS);
3839
cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS);
40+
cm.removeLineClass(cm.state.activeLines[i], "gutter", GUTT_CLASS);
3941
}
4042
}
4143

@@ -60,6 +62,7 @@
6062
for (var i = 0; i < active.length; i++) {
6163
cm.addLineClass(active[i], "wrap", WRAP_CLASS);
6264
cm.addLineClass(active[i], "background", BACK_CLASS);
65+
cm.addLineClass(active[i], "gutter", GUTT_CLASS);
6366
}
6467
cm.state.activeLines = active;
6568
});

doc/manual.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2736,8 +2736,10 @@ <h2 id="addons">Addons</h2>
27362736
<dt id="addon_active-line"><a href="../addon/selection/active-line.js"><code>selection/active-line.js</code></a></dt>
27372737
<dd>Defines a <code>styleActiveLine</code> option that, when enabled,
27382738
gives the wrapper of the active line the class <code>CodeMirror-activeline</code>,
2739-
and adds a background with the class <code>CodeMirror-activeline-background</code>.
2740-
is enabled. See the <a href="../demo/activeline.html">demo</a>.</dd>
2739+
adds a background with the class <code>CodeMirror-activeline-background</code>,
2740+
and adds the class <code>CodeMirror-activeline-gutter</code> to the
2741+
line's gutter space is enabled. See the
2742+
<a href="../demo/activeline.html">demo</a>.</dd>
27412743

27422744
<dt id="addon_selection-pointer"><a href="../addon/selection/selection-pointer.js"><code>selection/selection-pointer.js</code></a></dt>
27432745
<dd>Defines a <code>selectionPointer</code> option which you can

0 commit comments

Comments
 (0)