From 20d01284c2b4d0af466454effe622d0bf41d5c38 Mon Sep 17 00:00:00 2001
From: Marijn Haverbeke Configuration
horizontally (false) or whether it stays fixed during horizontal
scrolling (true, the default).
+ coverGutterNextToScrollbar: booleanfixedGutter
+ is on, and there is a horizontal scrollbar, by default the
+ gutter will be visible to the left of this scrollbar. If this
+ option is set to true, it will be covered by an element with
+ class CodeMirror-gutter-filler.readOnly: boolean|string"nocursor" is given (instead of
diff --git a/lib/codemirror.js b/lib/codemirror.js
index 051852f0c2..4becd1a0b6 100644
--- a/lib/codemirror.js
+++ b/lib/codemirror.js
@@ -213,7 +213,7 @@ window.CodeMirror = (function() {
estimateLineHeights(cm);
regChange(cm);
clearCaches(cm);
- setTimeout(function(){updateScrollbars(cm.display, cm.doc.height, cm.options.fixedGutter);}, 100);
+ setTimeout(function(){updateScrollbars(cm);}, 100);
}
function estimateHeight(cm) {
@@ -251,6 +251,7 @@ window.CodeMirror = (function() {
function guttersChanged(cm) {
updateGutters(cm);
+ alignHorizontally(cm);
regChange(cm);
}
@@ -318,7 +319,8 @@ window.CodeMirror = (function() {
// Re-synchronize the fake scrollbars with the actual size of the
// content. Optionally force a scrollTop.
- function updateScrollbars(d /* display */, docHeight, fixedGutter) {
+ function updateScrollbars(cm) {
+ var d = cm.display, docHeight = cm.doc.height;
var totalHeight = docHeight + paddingVert(d);
d.sizer.style.minHeight = d.heightForcer.style.top = totalHeight + "px";
var scrollHeight = Math.max(totalHeight, d.scroller.scrollHeight);
@@ -340,7 +342,7 @@ window.CodeMirror = (function() {
d.scrollbarFiller.style.display = "block";
d.scrollbarFiller.style.height = d.scrollbarFiller.style.width = scrollbarWidth(d.measure) + "px";
} else d.scrollbarFiller.style.display = "";
- if (needsH && fixedGutter) {
+ if (needsH && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
d.gutterFiller.style.display = "block";
d.gutterFiller.style.height = scrollbarWidth(d.measure) + "px";
d.gutterFiller.style.width = d.gutters.offsetWidth + "px";
@@ -410,7 +412,7 @@ window.CodeMirror = (function() {
signalLater(cm, "viewportChange", cm, cm.display.showingFrom, cm.display.showingTo);
} else break;
updateSelection(cm);
- updateScrollbars(cm.display, cm.doc.height, cm.options.fixedGutter);
+ updateScrollbars(cm);
// Clip forced viewport to actual scrollable area
if (viewPort)
@@ -3123,6 +3125,7 @@ window.CodeMirror = (function() {
cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
cm.refresh();
}, true);
+ option("coverGutterNextToScrollbar", false, updateScrollbars);
option("lineNumbers", false, function(cm) {
setGuttersForLineNumbers(cm.options);
guttersChanged(cm);
From 53bc4b1f54670c827662d5210a37b35e63a07c39 Mon Sep 17 00:00:00 2001
From: Andy Kimball Mode, state, and token-related methods
Miscellaneous methods
-
CodeMirror(elt: Element|function(elt: Element), ?config: object)cm.operation(func: () → any) → anyMiscellaneous methods
cm.toggleOverwrite(?value: bool)doc.posFromIndex(index: integer) → {line, ch}{line, ch} object for a
zero-based index who's value is relative to the start of the
diff --git a/lib/codemirror.js b/lib/codemirror.js
index 4becd1a0b6..c1b95555fa 100644
--- a/lib/codemirror.js
+++ b/lib/codemirror.js
@@ -3002,7 +3002,8 @@ window.CodeMirror = (function() {
sel.goalColumn = pos.left;
}),
- toggleOverwrite: function() {
+ toggleOverwrite: function(value) {
+ if (value != null && value == this.state.overwrite) return;
if (this.state.overwrite = !this.state.overwrite)
this.display.cursor.className += " CodeMirror-overwrite";
else
From dc3ca9661bd9902f672f417ddfa1f839ab889a9e Mon Sep 17 00:00:00 2001
From: Marijn Haverbeke { } CodeMi
{ } CodeMi
{ } CodeMi
"], function(line) {
var inv = line.charAt(0) == "خ";
cm.setValue(line + "\n"); cm.execCommand(inv ? "goLineEnd" : "goLineStart");
var cursor = byClassName(cm.getWrapperElement(), "CodeMirror-cursor")[0];
From 32050bbb0a9aa4d7e4ff995c4ecd06abf5c926b6 Mon Sep 17 00:00:00 2001
From: lynschinzer { } CodeMi
{ } CodeMi
Add-ons
prompt (should include an input tag), and a
callback function that is called when text has been entered.
Depends on addon/dialog/dialog.css.search/searchcursor.jsgetSearchCursor(query, start, caseFold) →
cursor method to CodeMirror instances, which can be used
@@ -1539,6 +1540,7 @@ Add-ons
on searchcursor.js, and will make use
of openDialog when
available to make prompting for search queries less ugly.edit/matchbrackets.jsmatchBrackets which, when set
to true, causes matching brackets to be highlighted whenever the
@@ -1547,6 +1549,7 @@ Add-ons
once, and a method findMatchingBracket that can be
used to run the bracket-finding algorithm that this uses
internally.edit/closebrackets.jsautoCloseBrackets that will
auto-close brackets and quotes when typed. By default, it'll
@@ -1554,6 +1557,50 @@ Add-ons
string similar to that (containing pairs of matching characters)
to customize it. Demo
here.comment/comment.js
+
+ The lineComment(from: {line, ch}, to: {line, ch}, ?options: object)blockComment when no line comment
+ style is defined for the mode.blockComment(from: {line, ch}, to: {line, ch}, ?options: object)lineComment when no block comment
+ style is defined for the mode.uncomment(from: {line, ch}, to: {line, ch}, ?options: object) → booleantrue if a comment range was found and
+ removed, false otherwise.options object accepted by these methods may
+ have the following properties:
+
+
+ The addon also defines
+ a blockCommentStart, blockCommentEnd, blockCommentLead, lineComment: stringpaddingcommentBlankLinesindentfullLinestrue.toggleComment command,
+ which will try to uncomment the current selection, and if that
+ fails, line-comments it.fold/foldcode.jsAdd-ons
where indentation determines block structure (Python, Haskell),
and CodeMirror.tagRangeFinder, for XML-style
languages.runmode/runmode.jsAdd-ons
(without including all of CodeMirror) and
for running under
node.js.mode/overlay.jsAdd-ons
Defines CodeMirror.overlayMode, which is used to
create such a mode. See this
demo for a detailed example.mode/multiplex.jsAdd-ons
see the content between the delimiters.
See this demo for an
example.hint/show-hint.jsCodeMirror.showHint, which takes a
@@ -1622,11 +1673,13 @@ Add-ons
hint sources for various languages. Check
out the demo for an
example.match-highlighter.jshighlightSelectionMatches option that
can be enabled to highlight all instances of a currently
selected word.
Demo here.lint/lint.jsAdd-ons
example CodeMirror.javascriptValidator). Depends
on addon/lint/lint.css. A demo can be
found here.selection/mark-selection.jsCodeMirror-selectedtext when the styleSelectedText option
is enabled. Useful to change the colour of the selection (in addition to the background),
like in this demo.selection/active-line.jsstyleActiveLine option that, when enabled,
gives the wrapper of the active line the class CodeMirror-activeline,
and adds a background with the class CodeMirror-activeline-background.
is enabled. See the demo.edit/closetag.jsmode/loadmode.jsCodeMirror.requireMode(modename,
callback) function that will try to load a given mode and
@@ -1663,12 +1720,14 @@ Add-ons
which will ensure the given mode is loaded and cause the given
editor instance to refresh its mode when the loading
succeeded. See the demo.edit/continuecomment.jscontinueComments option, which can be
set to true to have the editor prefix new lines inside C-like
block comments with an asterisk when Enter is pressed. It can
also be set to a string in order to bind this functionality to a
specific key..display/placeholder.jsplaceholder option that can be used to
make text appear in the editor when it is empty and not focused.
@@ -1833,6 +1892,15 @@ Writing CodeMirror Modes
return CodeMirror.Pass to indicate that it
could not come up with a precise indentation.
To work well with
+ the commenting addon, a mode may
+ define lineComment (string that starts a line
+ comment), blockCommentStart, blockCommentEnd
+ (strings that start and end block comments),
+ and blockCommentLead (a string to put at the start of
+ continued lines in a block comment). All of these are
+ optional.
Finally, a mode may define
an electricChars property, which should hold a string
containing all the characters that should trigger the behaviour
diff --git a/mode/clike/clike.js b/mode/clike/clike.js
index c14d7b4006..83bf8019f2 100644
--- a/mode/clike/clike.js
+++ b/mode/clike/clike.js
@@ -155,7 +155,10 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
else return ctx.indented + (closing ? 0 : indentUnit);
},
- electricChars: "{}"
+ electricChars: "{}",
+ blockCommentStart: "/*",
+ blockCommentEnd: "*/",
+ lineComment: "//"
};
});
diff --git a/mode/clojure/clojure.js b/mode/clojure/clojure.js
index fae675477d..ee22a12fed 100644
--- a/mode/clojure/clojure.js
+++ b/mode/clojure/clojure.js
@@ -215,7 +215,9 @@ CodeMirror.defineMode("clojure", function () {
indent: function (state) {
if (state.indentStack == null) return state.indentation;
return state.indentStack.indent;
- }
+ },
+
+ lineComment: ";;"
};
});
diff --git a/mode/coffeescript/coffeescript.js b/mode/coffeescript/coffeescript.js
index cf1cf4f246..509d9207bb 100644
--- a/mode/coffeescript/coffeescript.js
+++ b/mode/coffeescript/coffeescript.js
@@ -337,8 +337,9 @@ CodeMirror.defineMode('coffeescript', function(conf) {
}
return state.scopes[0].offset;
- }
+ },
+ lineComment: "#"
};
return external;
});
diff --git a/mode/commonlisp/commonlisp.js b/mode/commonlisp/commonlisp.js
index eeba759668..8fa08c8ac2 100644
--- a/mode/commonlisp/commonlisp.js
+++ b/mode/commonlisp/commonlisp.js
@@ -94,7 +94,11 @@ CodeMirror.defineMode("commonlisp", function (config) {
indent: function (state, _textAfter) {
var i = state.ctx.indentTo;
return typeof i == "number" ? i : state.ctx.start + 1;
- }
+ },
+
+ lineComment: ";;",
+ blockCommentStart: "#|",
+ blockCommentEnd: "|#"
};
});
diff --git a/mode/css/css.js b/mode/css/css.js
index f0fae602d1..f4ee021ed4 100644
--- a/mode/css/css.js
+++ b/mode/css/css.js
@@ -286,7 +286,9 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
return state.baseIndent + n * indentUnit;
},
- electricChars: "}"
+ electricChars: "}",
+ blockCommentStart: "/*",
+ blockCommentEnd: "*/"
};
});
diff --git a/mode/erlang/erlang.js b/mode/erlang/erlang.js
index 029b8e5561..79e0434d1f 100644
--- a/mode/erlang/erlang.js
+++ b/mode/erlang/erlang.js
@@ -456,8 +456,9 @@ CodeMirror.defineMode("erlang", function(cmCfg) {
indent:
function(state, textAfter) {
-// console.log(state.tokenStack);
return myIndent(state,textAfter);
- }
+ },
+
+ lineComment: "%"
};
});
diff --git a/mode/gas/gas.js b/mode/gas/gas.js
index 6604f01820..a6e6892908 100644
--- a/mode/gas/gas.js
+++ b/mode/gas/gas.js
@@ -321,6 +321,10 @@ CodeMirror.defineMode("gas", function(_config, parserConfig) {
return style;
}
}
- }
+ },
+
+ lineComment: lineCommentStartSymbol,
+ blockCommentStart: "/*",
+ blockCommentEnd: "*/"
};
});
diff --git a/mode/go/go.js b/mode/go/go.js
index 8b84a5ca42..6a458a6fe9 100644
--- a/mode/go/go.js
+++ b/mode/go/go.js
@@ -158,7 +158,10 @@ CodeMirror.defineMode("go", function(config) {
else return ctx.indented + (closing ? 0 : indentUnit);
},
- electricChars: "{}:"
+ electricChars: "{}:",
+ blockCommentStart: "/*",
+ blockCommentEnd: "*/",
+ lineComment: "//"
};
});
diff --git a/mode/haskell/haskell.js b/mode/haskell/haskell.js
index faec08dc33..b18d5ced1a 100644
--- a/mode/haskell/haskell.js
+++ b/mode/haskell/haskell.js
@@ -234,7 +234,11 @@ CodeMirror.defineMode("haskell", function() {
var t = state.f(stream, function(s) { state.f = s; });
var w = stream.current();
return (w in wellKnownWords) ? wellKnownWords[w] : t;
- }
+ },
+
+ blockCommentStart: "{-",
+ blockCommentEnd: "-}",
+ lineComment: "--"
};
});
diff --git a/mode/javascript/index.html b/mode/javascript/index.html
index dd0ca220d8..db063b772d 100644
--- a/mode/javascript/index.html
+++ b/mode/javascript/index.html
@@ -7,6 +7,7 @@
+
@@ -68,7 +69,8 @@
lib/codemirror.js
for some more details.
-
+ A plain text/Smarty mode which allows for custom delimiter tags (defaults to { and }).
+A plain text/Smarty version 2 or 3 mode, which allows for custom delimiter tags.
MIME types defined: text/x-smarty