From 7c3a40368f3002474f37d45e1bb8227ee3d54d33 Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 8 May 2011 23:14:56 +0200 Subject: [PATCH] and change syntax highlighter API once more --- demos/syntax/js/syntax.js | 2 +- source/Ox.UI/js/Core/Ox.SyntaxHighlighter.js | 21 ++++++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/demos/syntax/js/syntax.js b/demos/syntax/js/syntax.js index cac6979d..8190fcf3 100644 --- a/demos/syntax/js/syntax.js +++ b/demos/syntax/js/syntax.js @@ -19,7 +19,7 @@ Ox.load('UI', { .append( Ox.FormElementGroup({ elements: [ - 'showLineNumbers', 'showPage', 'showReturns', 'showSpaces', 'showTabs', 'stripComments' + 'showLineNumbers', 'showPage', 'showLinebreaks', 'showTabs', 'showWhitespace', 'stripComments' ].map(function(v, i) { return Ox.Checkbox({ overlap: 'right', diff --git a/source/Ox.UI/js/Core/Ox.SyntaxHighlighter.js b/source/Ox.UI/js/Core/Ox.SyntaxHighlighter.js index fad31a46..96160385 100644 --- a/source/Ox.UI/js/Core/Ox.SyntaxHighlighter.js +++ b/source/Ox.UI/js/Core/Ox.SyntaxHighlighter.js @@ -6,14 +6,14 @@ Ox.SyntaxHighlighter Syntax Highlighter options Options lineLength If larger than zero, show edge of page offset First line number + showLinebreaks If true, show linebreaks showLineNumbers If true, show line numbers - showReturns If true, show linebreaks - showSpaces If true, show whitespace + showWhitespace If true, show whitespace showTabs If true, show tabs source JavaScript source stripComments If true, strip comments tabSize Number of spaces per tab - self Shared private + self Shared private variable @*/ Ox.SyntaxHighlighter = function(options, self) { @@ -23,10 +23,10 @@ Ox.SyntaxHighlighter = function(options, self) { .defaults({ lineLength: 0, offset: 1, + showLinebreaks: false, showLineNumbers: false, - showReturns: false, - showSpaces: false, showTabs: false, + showWhitespace: false, source: '', stripComments: false, tabSize: 4, @@ -40,14 +40,14 @@ Ox.SyntaxHighlighter = function(options, self) { var $lineNumbers, $line, $source, width, lines, source = '', tokens, linebreak = ( - self.options.showReturns ? + self.options.showLinebreaks ? '\u21A9' : '' ) + '
', tab = ( self.options.showTabs ? '\u2192' : '' ) + Ox.repeat(' ', self.options.tabSize - self.options.showTabs), - whitespace = self.options.showSpaces ? '\u00B7' : ' '; + whitespace = self.options.showWhitespace ? '\u00B7' : ' '; self.options.source = self.options.source .replace(/\r\n/g, '\n') .replace(/\r/g, '\n'); @@ -59,7 +59,7 @@ Ox.SyntaxHighlighter = function(options, self) { !(self.options.stripComments && token.type == 'comment') ) { classNames = 'Ox' + Ox.toTitleCase(token.type); - if (self.options.showSpaces && token.type == 'whitespace') { + if (self.options.showWhitespace && token.type == 'whitespace') { if (isAfterLinebreak() && hasIrregularSpaces()) { classNames += ' OxLeading' } else if (isBeforeLinebreak()) { @@ -100,11 +100,6 @@ Ox.SyntaxHighlighter = function(options, self) { } $source = new Ox.Element() .addClass('OxSourceCode') - .css({ - background: '-webkit-linear-gradient(left, rgb(255, 255, 255) ' + - width + 'px, rgb(192, 192, 192) ' + width + 'px, rgb(255, 255, 255) ' + - (width + 1) + 'px)' - }) .html(source) .appendTo(that); if (self.options.lineLength) {