"Context coloring face, depth 6."
:group 'context-coloring-faces)
-(defface context-coloring-depth--1-italic-face
- '((default (:inherit context-coloring-depth--1-face :slant italic)))
- "Context coloring face, depth -1; italic; comments."
- :group 'context-coloring-faces)
-
-(defface context-coloring-depth-0-bold-face
- '((default (:inherit context-coloring-depth-0-face :weight bold)))
- "Context coloring face, depth 0; bold; global scope."
- :group 'context-coloring-faces)
-
-(defface context-coloring-depth-1-bold-face
- '((default (:inherit context-coloring-depth-1-face :weight bold)))
- "Context coloring face, depth 1; bold."
- :group 'context-coloring-faces)
-
-(defface context-coloring-depth-2-bold-face
- '((default (:inherit context-coloring-depth-2-face :weight bold)))
- "Context coloring face, depth 2; bold."
- :group 'context-coloring-faces)
-
-(defface context-coloring-depth-3-bold-face
- '((default (:inherit context-coloring-depth-3-face :weight bold)))
- "Context coloring face, depth 3; bold."
- :group 'context-coloring-faces)
-
-(defface context-coloring-depth-4-bold-face
- '((default (:inherit context-coloring-depth-4-face :weight bold)))
- "Context coloring face, depth 4; bold."
- :group 'context-coloring-faces)
-
-(defface context-coloring-depth-5-bold-face
- '((default (:inherit context-coloring-depth-5-face :weight bold)))
- "Context coloring face, depth 5; bold."
- :group 'context-coloring-faces)
-
-(defface context-coloring-depth-6-bold-face
- '((default (:inherit context-coloring-depth-6-face :weight bold)))
- "Context coloring face, depth 6; bold."
- :group 'context-coloring-faces)
-
(defconst context-coloring-face-count 7
"Number of faces defined for highlighting delimiter levels.
Determines depth at which to cycle through faces again.")
;;; Face functions
-(defsubst context-coloring-level-face (depth style)
- "Return face-name for DEPTH and STYLE as a string \"context-coloring-depth-DEPTH-face\".
+(defsubst context-coloring-level-face (depth)
+ "Return face-name for DEPTH as a string \"context-coloring-depth-DEPTH-face\".
For example: \"context-coloring-depth-1-face\"."
(intern-soft
(concat "context-coloring-depth-"
(+ 1
(mod (- depth 1)
(- context-coloring-face-count 1)))))
- (cond ((= 1 style) "-bold")
- ((= 2 style) "-italic")
- (t ""))
"-face")))
(defun context-coloring-apply-tokens (tokens)
"Processes TOKENS to apply context-based coloring to the
-current buffer. Tokens are 4 integers: start, end, level, and
-style. The array is flat, with a new token occurring after every
-4th number."
+current buffer. Tokens are 3 integers: start, end, level. The
+array is flat, with a new token occurring after every 3rd
+number."
(with-silent-modifications
;; Reset in case there should be uncolored areas.
(remove-text-properties (point-min) (point-max) `(face nil rear-nonsticky nil))
(add-text-properties
(elt tokens i)
(elt tokens (+ i 1))
- `(face ,(context-coloring-level-face
- (elt tokens (+ i 2))
- (elt tokens (+ i 3))) rear-nonsticky t))
- (setq i (+ i 4))))))
+ `(face ,(context-coloring-level-face (elt tokens (+ i 2))) rear-nonsticky t))
+ (setq i (+ i 3))))))
(defsubst context-coloring-kill-scopifier ()
"Kills the currently-running scopifier process for this
'use strict';
var escope = require('./lib/escope'),
- esprima = require('./lib/esprima'),
+ esprima = require('./lib/esprima');
- normal = 0,
- bold = 1,
- italic = 2;
-
-// Given code, returns an array of `[start, end, level, style]' tokens for
-// context-coloring.
+// Given code, returns an array of tokens for context-coloring.
module.exports = function (code) {
var analyzedScopes,
ast,
scopes.push(
range[0] + 1,
range[1] + 1,
- scope.level,
- normal
+ scope.level
);
definitionsIndex = tokens.length;
definitionsCount = 0;
tokens.push(
range[0] + 1,
range[1] + 1,
- scope.level,
- bold
+ scope.level
);
}
}
// declared and initialized simultaneously; this filters
// them.)
for (k = 0; k < definitionsCount; k += 1) {
- pointer = definitionsIndex + (k * 4);
+ pointer = definitionsIndex + (k * 3);
if (tokens[pointer] === range[0] + 1 &&
tokens[pointer + 1] === range[1] + 1) {
isDefined = true;
// Handle global references too.
range[0] + 1,
range[1] + 1,
- reference.resolved ? reference.resolved.scope.level : 0,
- reference.__maybeImplicitGlobal ? bold : normal
+ reference.resolved ? reference.resolved.scope.level : 0
);
}
}
tokens.push(
range[0] + 1,
range[1] + 1,
- -1,
- italic
+ -1
);
}