Skip to content

Commit

Permalink
Item14330: patching matchbrackets
Browse files Browse the repository at this point in the history
- improving foswiki mode and theme
  • Loading branch information
MichaelDaum committed Jun 27, 2017
1 parent 7770553 commit f451ceb
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -9,3 +9,4 @@ pub/System/CodeMirrorContrib/lib/codemirror.js
pub/System/CodeMirrorContrib/mode/foswiki/foswiki.js
pub/System/CodeMirrorContrib/widgets/widgets.js
pub/System/CodeMirrorContrib/widgets/widgets.uncompressed.js
node_modules
3 changes: 1 addition & 2 deletions pub/System/CodeMirrorContrib/addon/edit/matchbrackets.js
Expand Up @@ -23,7 +23,6 @@
var dir = match.charAt(1) == ">" ? 1 : -1;
if (strict && (dir > 0) != (pos == where.ch)) return null;
var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));

var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config);
if (found == null) return null;
return {from: Pos(where.line, pos), to: found && found.pos,
Expand Down Expand Up @@ -53,7 +52,7 @@
if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
for (; pos != end; pos += dir) {
var ch = line.charAt(pos);
if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
if (re.test(ch) && (style == undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
var match = matching[ch];
if ((match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
Expand Down
21 changes: 21 additions & 0 deletions pub/System/CodeMirrorContrib/matchbrackets.js.patch
@@ -0,0 +1,21 @@
diff --git a/addon/edit/matchbrackets.js b/addon/edit/matchbrackets.js
index 76754ed..85fea76 100644
--- a/addon/edit/matchbrackets.js
+++ b/addon/edit/matchbrackets.js
@@ -23,7 +23,6 @@
var dir = match.charAt(1) == ">" ? 1 : -1;
if (strict && (dir > 0) != (pos == where.ch)) return null;
var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
-
var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config);
if (found == null) return null;
return {from: Pos(where.line, pos), to: found && found.pos,
@@ -53,7 +52,7 @@
if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
for (; pos != end; pos += dir) {
var ch = line.charAt(pos);
- if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
+ if (re.test(ch) && (style == undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
var match = matching[ch];
if ((match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
Expand Up @@ -146,13 +146,13 @@
// macro w/o attributes
if ((match = stream.match(simpleMacroRegExp, 1))) {
//state.macroName = match[1];
return "tag "+match[1];
return "tag";
}

// macros start
if ((match = stream.match(macroStartRegExp, 1))) {
state.macroName = match[1];
return "tag "+state.macroName;
return "tag";
}

// macro end
Expand Down
7 changes: 7 additions & 0 deletions pub/System/CodeMirrorContrib/theme/foswiki.css
Expand Up @@ -5,13 +5,18 @@
overflow-y: hidden;
overflow-x: auto;
}
.cm-s-foswiki .CodeMirror-dialog input {
width:100%;
box-shadow:none;
}
.cm-s-foswiki {
margin:0px;
border:1px solid #ccc;
padding:4px 6px;
background:#fff;
font-size:12px;
color:inherit;
box-sizing:border-box;
}
.cm-s-foswiki,
.cm-s-foswiki pre {
Expand Down Expand Up @@ -116,8 +121,10 @@
padding: 0px 2px;
font-size:95%;
}
.cm-fat-cursor div.CodeMirror-cursors,
div.CodeMirror-cursors {
z-index:10;
opacity:0.8;
}

.cm-s-foswiki .cm-header {
Expand Down

0 comments on commit f451ceb

Please sign in to comment.