From 8cc2f29aecaa1d397bf9c79e72daab2f12580b19 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Tue, 16 Dec 2014 10:14:37 -0500 Subject: [PATCH] Adding regexp flag indications --- src/js/parser/javascript/root.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/js/parser/javascript/root.js b/src/js/parser/javascript/root.js index edc8580..9e703b0 100644 --- a/src/js/parser/javascript/root.js +++ b/src/js/parser/javascript/root.js @@ -5,6 +5,23 @@ export default _.extend({}, Base, { type: 'root', _render() { + var flags = this.flags(), + flagLabels = []; + + if (flags.global) { + flagLabels.push('Global'); + } + if (flags.ignore_case) { + flagLabels.push('Ignore Case'); + } + if (flags.multiline) { + flagLabels.push('Multiline'); + } + + if (flagLabels.length > 0) { + this.flagText = this.container.text(0, 0, `Flags: ${flagLabels.join(', ')}`); + } + this.start = this.container.circle() .addClass('pin') .attr({ r: 5 }); @@ -14,10 +31,15 @@ export default _.extend({}, Base, { return this.regexp.render(this.container.group()) .then(() => { - var box; + var box, + offset = 0; + + if (this.flagText) { + offset = this.flagText.getBBox().height; + } this.regexp.transform(Snap.matrix() - .translate(10, 0)); + .translate(10, offset)); box = this.regexp.getBBox();