From b42ce65a54326fee1d72373488f6da67ae609c39 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 17 Nov 2013 16:30:57 +0400 Subject: [PATCH] use css counter for static highlight gutter --- lib/ace/ext/static.css | 11 ++++++++++- lib/ace/ext/static_highlight.js | 4 ++-- lib/ace/ext/static_highlight_test.js | 14 +++++++------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/ace/ext/static.css b/lib/ace/ext/static.css index bd479780..f82359da 100644 --- a/lib/ace/ext/static.css +++ b/lib/ace/ext/static.css @@ -20,4 +20,13 @@ -khtml-user-select: none; -webkit-user-select: none; user-select: none; -} \ No newline at end of file +} + + +.ace_static_highlight .ace_gutter-cell:before { + content: counter(ace_line, decimal); + counter-increment: ace_line; +} +.ace_static_highlight { + counter-reset: ace_line; +} diff --git a/lib/ace/ext/static_highlight.js b/lib/ace/ext/static_highlight.js index 56588f14..a3461424 100644 --- a/lib/ace/ext/static_highlight.js +++ b/lib/ace/ext/static_highlight.js @@ -160,14 +160,14 @@ highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) { for(var ix = 0; ix < length; ix++) { stringBuilder.push("
"); if (!disableGutter) - stringBuilder.push("" + (ix + lineStart) + ""); + stringBuilder.push("" + /*(ix + lineStart) + */ ""); textLayer.$renderLine(stringBuilder, ix, true, false); stringBuilder.push("\n
"); } // let's prepare the whole html var html = "
" + - "
" + + "
" + stringBuilder.join("") + "
" + "
"; diff --git a/lib/ace/ext/static_highlight_test.js b/lib/ace/ext/static_highlight_test.js index 63f0ebc3..075cea7b 100644 --- a/lib/ace/ext/static_highlight_test.js +++ b/lib/ace/ext/static_highlight_test.js @@ -28,13 +28,13 @@ module.exports = { var mode = new JavaScriptMode(); var result = highlighter.render(snippet, mode, theme); - assert.equal(result.html, "
" - + "
1/**\xa0this\xa0is\xa0a\xa0function\n
" - + "
2*\n
" - + "
3*/\n
" - + "
4function\xa0hello\xa0(a,\xa0b,\xa0c)\xa0{\n
" - + "
5\xa0\xa0\xa0\xa0console.log(a\xa0*\xa0b\xa0+\xa0c\xa0+\xa0'sup$');\n
" - + "
6}\n
" + assert.equal(result.html, "
" + + "
/**\xa0this\xa0is\xa0a\xa0function\n
" + + "
*\n
" + + "
*/\n
" + + "
function\xa0hello\xa0(a,\xa0b,\xa0c)\xa0{\n
" + + "
\xa0\xa0\xa0\xa0console.log(a\xa0*\xa0b\xa0+\xa0c\xa0+\xa0'sup$');\n
" + + "
}\n
" + "
"); assert.ok(!!result.css); next();