From 8455ac4b57193759189f5d48f04a85f3df69ec5a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 25 Jun 2015 15:59:55 +0200 Subject: [PATCH 01/47] Bump version number post-5.4 --- doc/manual.html | 2 +- lib/codemirror.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index 6f579cb670..43fac0e475 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

User manual and reference guide - version 5.4.0 + version 5.4.1

CodeMirror is a code-editor component that can be embedded in diff --git a/lib/codemirror.js b/lib/codemirror.js index 283fc09fec..9d812c910f 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -8729,7 +8729,7 @@ // THE END - CodeMirror.version = "5.4.0"; + CodeMirror.version = "5.4.1"; return CodeMirror; }); diff --git a/package.json b/package.json index ece298bc5f..687c185b9a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version":"5.4.0", + "version":"5.4.1", "main": "lib/codemirror.js", "description": "In-browser code editing made bearable", "license": "MIT", From 0fc02ca3b1a50c941336c9b3990c3360932a012d Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 26 Jun 2015 12:18:54 +0200 Subject: [PATCH 02/47] [gfm mode] Define a MIME, remove bogus use of defineMIME Closes #3345 --- mode/gfm/gfm.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mode/gfm/gfm.js b/mode/gfm/gfm.js index 80a8e2c84d..94ff920bfb 100644 --- a/mode/gfm/gfm.js +++ b/mode/gfm/gfm.js @@ -116,8 +116,9 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) { markdownConfig[attr] = modeConfig[attr]; } markdownConfig.name = "markdown"; - CodeMirror.defineMIME("gfmBase", markdownConfig); - return CodeMirror.overlayMode(CodeMirror.getMode(config, "gfmBase"), gfmOverlay); + return CodeMirror.overlayMode(CodeMirror.getMode(config, markdownConfig), gfmOverlay); + }, "markdown"); + CodeMirror.defineMIME("text/x-gfm", "gfm"); }); From eea1ed18f29e443fe61a9eeab222410a57db6dbb Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 25 Jun 2015 15:30:24 +0200 Subject: [PATCH 03/47] Start on ::selection workaround --- lib/codemirror.css | 4 ++-- lib/codemirror.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/codemirror.css b/lib/codemirror.css index b313b61c68..2384ad01f3 100644 --- a/lib/codemirror.css +++ b/lib/codemirror.css @@ -297,8 +297,8 @@ div.CodeMirror-cursors { .CodeMirror-selected { background: #d9d9d9; } .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; } .CodeMirror-crosshair { cursor: crosshair; } -.CodeMirror ::selection { background: #d7d4f0; } -.CodeMirror ::-moz-selection { background: #d7d4f0; } +.CodeMirror-line::selection, .CodeMirror-line > span::selection { background: #d7d4f0; } +.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection { background: #d7d4f0; } .cm-searching { background: #ffa; diff --git a/lib/codemirror.js b/lib/codemirror.js index 9d812c910f..a0fce911eb 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -6790,7 +6790,7 @@ // The padding-right forces the element to have a 'border', which // is needed on Webkit to be able to get line-level bounding // rectangles for it (in measureChar). - var content = elt("span", null, null, webkit ? "padding-right: .1px" : null); + var content = elt("span", null, "CodeMirror-line", webkit ? "padding-right: .1px" : null); var builder = {pre: elt("pre", [content]), content: content, col: 0, pos: 0, cm: cm, splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")}; From 0ac8955e5ccad9160e7fcd7212486da1383619d3 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 26 Jun 2015 12:41:06 +0200 Subject: [PATCH 04/47] Change the way the native selection style is overridden by themes So that selection inside widgets isn't affected Issue #3342 --- lib/codemirror.css | 4 ++-- lib/codemirror.js | 4 ++-- theme/3024-day.css | 5 +++-- theme/3024-night.css | 4 ++-- theme/ambiance.css | 4 ++-- theme/base16-dark.css | 4 ++-- theme/base16-light.css | 4 ++-- theme/blackboard.css | 4 ++-- theme/cobalt.css | 4 ++-- theme/erlang-dark.css | 4 ++-- theme/lesser-dark.css | 4 ++-- theme/mbo.css | 4 ++-- theme/mdn-like.css | 4 ++-- theme/midnight.css | 4 ++-- theme/monokai.css | 4 ++-- theme/night.css | 4 ++-- theme/paraiso-dark.css | 4 ++-- theme/paraiso-light.css | 4 ++-- theme/pastel-on-dark.css | 4 ++-- theme/rubyblue.css | 4 ++-- theme/solarized.css | 6 +++--- theme/the-matrix.css | 4 ++-- theme/tomorrow-night-eighties.css | 4 ++-- theme/twilight.css | 4 ++-- theme/vibrant-ink.css | 4 ++-- theme/xq-dark.css | 4 ++-- 26 files changed, 54 insertions(+), 53 deletions(-) diff --git a/lib/codemirror.css b/lib/codemirror.css index 2384ad01f3..c4aa3c0635 100644 --- a/lib/codemirror.css +++ b/lib/codemirror.css @@ -297,8 +297,8 @@ div.CodeMirror-cursors { .CodeMirror-selected { background: #d9d9d9; } .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; } .CodeMirror-crosshair { cursor: crosshair; } -.CodeMirror-line::selection, .CodeMirror-line > span::selection { background: #d7d4f0; } -.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection { background: #d7d4f0; } +.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; } +.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; } .cm-searching { background: #ffa; diff --git a/lib/codemirror.js b/lib/codemirror.js index a0fce911eb..572cbbce52 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -6790,8 +6790,8 @@ // The padding-right forces the element to have a 'border', which // is needed on Webkit to be able to get line-level bounding // rectangles for it (in measureChar). - var content = elt("span", null, "CodeMirror-line", webkit ? "padding-right: .1px" : null); - var builder = {pre: elt("pre", [content]), content: content, + var content = elt("span", null, null, webkit ? "padding-right: .1px" : null); + var builder = {pre: elt("pre", [content], "CodeMirror-line"), content: content, col: 0, pos: 0, cm: cm, splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")}; lineView.measure = {}; diff --git a/theme/3024-day.css b/theme/3024-day.css index 359281621b..1eb109e438 100644 --- a/theme/3024-day.css +++ b/theme/3024-day.css @@ -10,8 +10,9 @@ .cm-s-3024-day.CodeMirror {background: #f7f7f7; color: #3a3432;} .cm-s-3024-day div.CodeMirror-selected {background: #d6d5d4 !important;} -.cm-s-3024-day.CodeMirror ::selection { background: #d6d5d4; } -.cm-s-3024-day.CodeMirror ::-moz-selection { background: #d9d9d9; } + +.cm-s-3024-day .CodeMirror-line::selection, .cm-s-3024-day .CodeMirror-line > span::selection, .cm-s-3024-day .CodeMirror-line > span > span::selection { background: #d6d5d4; } +.cm-s-3024-day .CodeMirror-line::-moz-selection, .cm-s-3024-day .CodeMirror-line > span::-moz-selection, .cm-s-3024-day .CodeMirror-line > span > span::selection { background: #d9d9d9; } .cm-s-3024-day .CodeMirror-gutters {background: #f7f7f7; border-right: 0px;} .cm-s-3024-day .CodeMirror-guttermarker { color: #db2d20; } diff --git a/theme/3024-night.css b/theme/3024-night.css index ccab9d50bf..36bb8b4eea 100644 --- a/theme/3024-night.css +++ b/theme/3024-night.css @@ -10,8 +10,8 @@ .cm-s-3024-night.CodeMirror {background: #090300; color: #d6d5d4;} .cm-s-3024-night div.CodeMirror-selected {background: #3a3432 !important;} -.cm-s-3024-night.CodeMirror ::selection { background: rgba(58, 52, 50, .99); } -.cm-s-3024-night.CodeMirror ::-moz-selection { background: rgba(58, 52, 50, .99); } +.cm-s-3024-night .CodeMirror-line::selection, .cm-s-3024-night .CodeMirror-line > span::selection, .cm-s-3024-night .CodeMirror-line > span > span::selection { background: rgba(58, 52, 50, .99); } +.cm-s-3024-night .CodeMirror-line::-moz-selection, .cm-s-3024-night .CodeMirror-line > span::-moz-selection, .cm-s-3024-night .CodeMirror-line > span > span::-moz-selection { background: rgba(58, 52, 50, .99); } .cm-s-3024-night .CodeMirror-gutters {background: #090300; border-right: 0px;} .cm-s-3024-night .CodeMirror-guttermarker { color: #db2d20; } .cm-s-3024-night .CodeMirror-guttermarker-subtle { color: #5c5855; } diff --git a/theme/ambiance.css b/theme/ambiance.css index 3ab9b25483..0e68f75e4c 100644 --- a/theme/ambiance.css +++ b/theme/ambiance.css @@ -33,8 +33,8 @@ .cm-s-ambiance .CodeMirror-selected { background: rgba(255, 255, 255, 0.15); } .cm-s-ambiance.CodeMirror-focused .CodeMirror-selected { background: rgba(255, 255, 255, 0.10); } -.cm-s-ambiance.CodeMirror ::selection { background: rgba(255, 255, 255, 0.10); } -.cm-s-ambiance.CodeMirror ::-moz-selection { background: rgba(255, 255, 255, 0.10); } +.cm-s-ambiance .CodeMirror-line::selection, .cm-s-ambiance .CodeMirror-line > span::selection, .cm-s-ambiance .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); } +.cm-s-ambiance .CodeMirror-line::-moz-selection, .cm-s-ambiance .CodeMirror-line > span::-moz-selection, .cm-s-ambiance .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); } /* Editor styling */ diff --git a/theme/base16-dark.css b/theme/base16-dark.css index b009d2b9d6..fb79fae2b9 100644 --- a/theme/base16-dark.css +++ b/theme/base16-dark.css @@ -10,8 +10,8 @@ .cm-s-base16-dark.CodeMirror {background: #151515; color: #e0e0e0;} .cm-s-base16-dark div.CodeMirror-selected {background: #303030 !important;} -.cm-s-base16-dark.CodeMirror ::selection { background: rgba(48, 48, 48, .99); } -.cm-s-base16-dark.CodeMirror ::-moz-selection { background: rgba(48, 48, 48, .99); } +.cm-s-base16-dark .CodeMirror-line::selection, .cm-s-base16-dark .CodeMirror-line > span::selection, .cm-s-base16-dark .CodeMirror-line > span > span::selection { background: rgba(48, 48, 48, .99); } +.cm-s-base16-dark .CodeMirror-line::-moz-selection, .cm-s-base16-dark .CodeMirror-line > span::-moz-selection, .cm-s-base16-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(48, 48, 48, .99); } .cm-s-base16-dark .CodeMirror-gutters {background: #151515; border-right: 0px;} .cm-s-base16-dark .CodeMirror-guttermarker { color: #ac4142; } .cm-s-base16-dark .CodeMirror-guttermarker-subtle { color: #505050; } diff --git a/theme/base16-light.css b/theme/base16-light.css index 15df6d3807..46508e02c6 100644 --- a/theme/base16-light.css +++ b/theme/base16-light.css @@ -10,8 +10,8 @@ .cm-s-base16-light.CodeMirror {background: #f5f5f5; color: #202020;} .cm-s-base16-light div.CodeMirror-selected {background: #e0e0e0 !important;} -.cm-s-base16-light.CodeMirror ::selection { background: #e0e0e0; } -.cm-s-base16-light.CodeMirror ::-moz-selection { background: #e0e0e0; } +.cm-s-base16-light .CodeMirror-line::selection, .cm-s-base16-light .CodeMirror-line > span::selection, .cm-s-base16-light .CodeMirror-line > span > span::selection { background: #e0e0e0; } +.cm-s-base16-light .CodeMirror-line::-moz-selection, .cm-s-base16-light .CodeMirror-line > span::-moz-selection, .cm-s-base16-light .CodeMirror-line > span > span::-moz-selection { background: #e0e0e0; } .cm-s-base16-light .CodeMirror-gutters {background: #f5f5f5; border-right: 0px;} .cm-s-base16-light .CodeMirror-guttermarker { color: #ac4142; } .cm-s-base16-light .CodeMirror-guttermarker-subtle { color: #b0b0b0; } diff --git a/theme/blackboard.css b/theme/blackboard.css index 02289b630b..6de11dd20a 100644 --- a/theme/blackboard.css +++ b/theme/blackboard.css @@ -2,8 +2,8 @@ .cm-s-blackboard.CodeMirror { background: #0C1021; color: #F8F8F8; } .cm-s-blackboard .CodeMirror-selected { background: #253B76 !important; } -.cm-s-blackboard.CodeMirror ::selection { background: rgba(37, 59, 118, .99); } -.cm-s-blackboard.CodeMirror ::-moz-selection { background: rgba(37, 59, 118, .99); } +.cm-s-blackboard .CodeMirror-line::selection, .cm-s-blackboard .CodeMirror-line > span::selection, .cm-s-blackboard .CodeMirror-line > span > span::selection { background: rgba(37, 59, 118, .99); } +.cm-s-blackboard .CodeMirror-line::-moz-selection, .cm-s-blackboard .CodeMirror-line > span::-moz-selection, .cm-s-blackboard .CodeMirror-line > span > span::-moz-selection { background: rgba(37, 59, 118, .99); } .cm-s-blackboard .CodeMirror-gutters { background: #0C1021; border-right: 0; } .cm-s-blackboard .CodeMirror-guttermarker { color: #FBDE2D; } .cm-s-blackboard .CodeMirror-guttermarker-subtle { color: #888; } diff --git a/theme/cobalt.css b/theme/cobalt.css index 3915589494..b6eebcfcff 100644 --- a/theme/cobalt.css +++ b/theme/cobalt.css @@ -1,7 +1,7 @@ .cm-s-cobalt.CodeMirror { background: #002240; color: white; } .cm-s-cobalt div.CodeMirror-selected { background: #b36539 !important; } -.cm-s-cobalt.CodeMirror ::selection { background: rgba(179, 101, 57, .99); } -.cm-s-cobalt.CodeMirror ::-moz-selection { background: rgba(179, 101, 57, .99); } +.cm-s-cobalt .CodeMirror-line::selection, .cm-s-cobalt .CodeMirror-line > span::selection, .cm-s-cobalt .CodeMirror-line > span > span::selection { background: rgba(179, 101, 57, .99); } +.cm-s-cobalt .CodeMirror-line::-moz-selection, .cm-s-cobalt .CodeMirror-line > span::-moz-selection, .cm-s-cobalt .CodeMirror-line > span > span::-moz-selection { background: rgba(179, 101, 57, .99); } .cm-s-cobalt .CodeMirror-gutters { background: #002240; border-right: 1px solid #aaa; } .cm-s-cobalt .CodeMirror-guttermarker { color: #ffee80; } .cm-s-cobalt .CodeMirror-guttermarker-subtle { color: #d0d0d0; } diff --git a/theme/erlang-dark.css b/theme/erlang-dark.css index e20bf1259b..48552f862f 100644 --- a/theme/erlang-dark.css +++ b/theme/erlang-dark.css @@ -1,7 +1,7 @@ .cm-s-erlang-dark.CodeMirror { background: #002240; color: white; } .cm-s-erlang-dark div.CodeMirror-selected { background: #b36539 !important; } -.cm-s-erlang-dark.CodeMirror ::selection { background: rgba(179, 101, 57, .99); } -.cm-s-erlang-dark.CodeMirror ::-moz-selection { background: rgba(179, 101, 57, .99); } +.cm-s-erlang-dark .CodeMirror-line::selection, .cm-s-erlang-dark .CodeMirror-line > span::selection, .cm-s-erlang-dark .CodeMirror-line > span > span::selection { background: rgba(179, 101, 57, .99); } +.cm-s-erlang-dark .CodeMirror-line::-moz-selection, .cm-s-erlang-dark .CodeMirror-line > span::-moz-selection, .cm-s-erlang-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(179, 101, 57, .99); } .cm-s-erlang-dark .CodeMirror-gutters { background: #002240; border-right: 1px solid #aaa; } .cm-s-erlang-dark .CodeMirror-guttermarker { color: white; } .cm-s-erlang-dark .CodeMirror-guttermarker-subtle { color: #d0d0d0; } diff --git a/theme/lesser-dark.css b/theme/lesser-dark.css index 88dff92191..0573c06692 100644 --- a/theme/lesser-dark.css +++ b/theme/lesser-dark.css @@ -7,8 +7,8 @@ Ported to CodeMirror by Peter Kroon } .cm-s-lesser-dark.CodeMirror { background: #262626; color: #EBEFE7; text-shadow: 0 -1px 1px #262626; } .cm-s-lesser-dark div.CodeMirror-selected {background: #45443B !important;} /* 33322B*/ -.cm-s-lesser-dark.CodeMirror ::selection { background: rgba(69, 68, 59, .99); } -.cm-s-lesser-dark.CodeMirror ::-moz-selection { background: rgba(69, 68, 59, .99); } +.cm-s-lesser-dark .CodeMirror-line::selection, .cm-s-lesser-dark .CodeMirror-line > span::selection, .cm-s-lesser-dark .CodeMirror-line > span > span::selection { background: rgba(69, 68, 59, .99); } +.cm-s-lesser-dark .CodeMirror-line::-moz-selection, .cm-s-lesser-dark .CodeMirror-line > span::-moz-selection, .cm-s-lesser-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(69, 68, 59, .99); } .cm-s-lesser-dark .CodeMirror-cursor { border-left: 1px solid white !important; } .cm-s-lesser-dark pre { padding: 0 8px; }/*editable code holder*/ diff --git a/theme/mbo.css b/theme/mbo.css index e39879522e..cc9032e0ed 100644 --- a/theme/mbo.css +++ b/theme/mbo.css @@ -6,8 +6,8 @@ .cm-s-mbo.CodeMirror {background: #2c2c2c; color: #ffffec;} .cm-s-mbo div.CodeMirror-selected {background: #716C62 !important;} -.cm-s-mbo.CodeMirror ::selection { background: rgba(113, 108, 98, .99); } -.cm-s-mbo.CodeMirror ::-moz-selection { background: rgba(113, 108, 98, .99); } +.cm-s-mbo .CodeMirror-line::selection, .cm-s-mbo .CodeMirror-line > span::selection, .cm-s-mbo .CodeMirror-line > span > span::selection { background: rgba(113, 108, 98, .99); } +.cm-s-mbo .CodeMirror-line::-moz-selection, .cm-s-mbo .CodeMirror-line > span::-moz-selection, .cm-s-mbo .CodeMirror-line > span > span::-moz-selection { background: rgba(113, 108, 98, .99); } .cm-s-mbo .CodeMirror-gutters {background: #4e4e4e; border-right: 0px;} .cm-s-mbo .CodeMirror-guttermarker { color: white; } .cm-s-mbo .CodeMirror-guttermarker-subtle { color: grey; } diff --git a/theme/mdn-like.css b/theme/mdn-like.css index 9c73dc2f0c..771d4471e5 100644 --- a/theme/mdn-like.css +++ b/theme/mdn-like.css @@ -9,8 +9,8 @@ */ .cm-s-mdn-like.CodeMirror { color: #999; background-color: #fff; } .cm-s-mdn-like .CodeMirror-selected { background: #cfc !important; } -.cm-s-mdn-like.CodeMirror ::selection { background: #cfc; } -.cm-s-mdn-like.CodeMirror ::-moz-selection { background: #cfc; } +.cm-s-mdn-like .CodeMirror-line::selection, .cm-s-mdn-like .CodeMirror-line > span::selection, .cm-s-mdn-like .CodeMirror-line > span > span::selection { background: #cfc; } +.cm-s-mdn-like .CodeMirror-line::-moz-selection, .cm-s-mdn-like .CodeMirror-line > span::-moz-selection, .cm-s-mdn-like .CodeMirror-line > span > span::-moz-selection { background: #cfc; } .cm-s-mdn-like .CodeMirror-gutters { background: #f8f8f8; border-left: 6px solid rgba(0,83,159,0.65); color: #333; } .cm-s-mdn-like .CodeMirror-linenumber { color: #aaa; padding-left: 8px; } diff --git a/theme/midnight.css b/theme/midnight.css index 296af4f7d2..9e9825b3f8 100644 --- a/theme/midnight.css +++ b/theme/midnight.css @@ -15,8 +15,8 @@ .cm-s-midnight.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;} .cm-s-midnight div.CodeMirror-selected {background: #314D67 !important;} -.cm-s-midnight.CodeMirror ::selection { background: rgba(49, 77, 103, .99); } -.cm-s-midnight.CodeMirror ::-moz-selection { background: rgba(49, 77, 103, .99); } +.cm-s-midnight .CodeMirror-line::selection, .cm-s-midnight .CodeMirror-line > span::selection, .cm-s-midnight .CodeMirror-line > span > span::selection { background: rgba(49, 77, 103, .99); } +.cm-s-midnight .CodeMirror-line::-moz-selection, .cm-s-midnight .CodeMirror-line > span::-moz-selection, .cm-s-midnight .CodeMirror-line > span > span::-moz-selection { background: rgba(49, 77, 103, .99); } .cm-s-midnight .CodeMirror-gutters {background: #0F192A; border-right: 1px solid;} .cm-s-midnight .CodeMirror-guttermarker { color: white; } .cm-s-midnight .CodeMirror-guttermarker-subtle { color: #d0d0d0; } diff --git a/theme/monokai.css b/theme/monokai.css index cea775f67f..e11e80cace 100644 --- a/theme/monokai.css +++ b/theme/monokai.css @@ -2,8 +2,8 @@ .cm-s-monokai.CodeMirror {background: #272822; color: #f8f8f2;} .cm-s-monokai div.CodeMirror-selected {background: #49483E !important;} -.cm-s-monokai.CodeMirror ::selection { background: rgba(73, 72, 62, .99); } -.cm-s-monokai.CodeMirror ::-moz-selection { background: rgba(73, 72, 62, .99); } +.cm-s-monokai .CodeMirror-line::selection, .cm-s-monokai .CodeMirror-line > span::selection, .cm-s-monokai .CodeMirror-line > span > span::selection { background: rgba(73, 72, 62, .99); } +.cm-s-monokai .CodeMirror-line::-moz-selection, .cm-s-monokai .CodeMirror-line > span::-moz-selection, .cm-s-monokai .CodeMirror-line > span > span::-moz-selection { background: rgba(73, 72, 62, .99); } .cm-s-monokai .CodeMirror-gutters {background: #272822; border-right: 0px;} .cm-s-monokai .CodeMirror-guttermarker { color: white; } .cm-s-monokai .CodeMirror-guttermarker-subtle { color: #d0d0d0; } diff --git a/theme/night.css b/theme/night.css index 6b2ac6c7cf..6fbbcaa202 100644 --- a/theme/night.css +++ b/theme/night.css @@ -2,8 +2,8 @@ .cm-s-night.CodeMirror { background: #0a001f; color: #f8f8f8; } .cm-s-night div.CodeMirror-selected { background: #447 !important; } -.cm-s-night.CodeMirror ::selection { background: rgba(68, 68, 119, .99); } -.cm-s-night.CodeMirror ::-moz-selection { background: rgba(68, 68, 119, .99); } +.cm-s-night .CodeMirror-line::selection, .cm-s-night .CodeMirror-line > span::selection, .cm-s-night .CodeMirror-line > span > span::selection { background: rgba(68, 68, 119, .99); } +.cm-s-night .CodeMirror-line::-moz-selection, .cm-s-night .CodeMirror-line > span::-moz-selection, .cm-s-night .CodeMirror-line > span > span::-moz-selection { background: rgba(68, 68, 119, .99); } .cm-s-night .CodeMirror-gutters { background: #0a001f; border-right: 1px solid #aaa; } .cm-s-night .CodeMirror-guttermarker { color: white; } .cm-s-night .CodeMirror-guttermarker-subtle { color: #bbb; } diff --git a/theme/paraiso-dark.css b/theme/paraiso-dark.css index af914b60bf..2b6a797d0d 100644 --- a/theme/paraiso-dark.css +++ b/theme/paraiso-dark.css @@ -10,8 +10,8 @@ .cm-s-paraiso-dark.CodeMirror {background: #2f1e2e; color: #b9b6b0;} .cm-s-paraiso-dark div.CodeMirror-selected {background: #41323f !important;} -.cm-s-paraiso-dark.CodeMirror ::selection { background: rgba(65, 50, 63, .99); } -.cm-s-paraiso-dark.CodeMirror ::-moz-selection { background: rgba(65, 50, 63, .99); } +.cm-s-paraiso-dark .CodeMirror-line::selection, .cm-s-paraiso-dark .CodeMirror-line > span::selection, .cm-s-paraiso-dark .CodeMirror-line > span > span::selection { background: rgba(65, 50, 63, .99); } +.cm-s-paraiso-dark .CodeMirror-line::-moz-selection, .cm-s-paraiso-dark .CodeMirror-line > span::-moz-selection, .cm-s-paraiso-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(65, 50, 63, .99); } .cm-s-paraiso-dark .CodeMirror-gutters {background: #2f1e2e; border-right: 0px;} .cm-s-paraiso-dark .CodeMirror-guttermarker { color: #ef6155; } .cm-s-paraiso-dark .CodeMirror-guttermarker-subtle { color: #776e71; } diff --git a/theme/paraiso-light.css b/theme/paraiso-light.css index e198066faa..01d2e11f54 100644 --- a/theme/paraiso-light.css +++ b/theme/paraiso-light.css @@ -10,8 +10,8 @@ .cm-s-paraiso-light.CodeMirror {background: #e7e9db; color: #41323f;} .cm-s-paraiso-light div.CodeMirror-selected {background: #b9b6b0 !important;} -.cm-s-paraiso-light.CodeMirror ::selection { background: #b9b6b0; } -.cm-s-paraiso-light.CodeMirror ::-moz-selection { background: #b9b6b0; } +.cm-s-paraiso-light .CodeMirror-line::selection, .cm-s-paraiso-light .CodeMirror-line > span::selection, .cm-s-paraiso-light .CodeMirror-line > span > span::selection { background: #b9b6b0; } +.cm-s-paraiso-light .CodeMirror-line::-moz-selection, .cm-s-paraiso-light .CodeMirror-line > span::-moz-selection, .cm-s-paraiso-light .CodeMirror-line > span > span::-moz-selection { background: #b9b6b0; } .cm-s-paraiso-light .CodeMirror-gutters {background: #e7e9db; border-right: 0px;} .cm-s-paraiso-light .CodeMirror-guttermarker { color: black; } .cm-s-paraiso-light .CodeMirror-guttermarker-subtle { color: #8d8687; } diff --git a/theme/pastel-on-dark.css b/theme/pastel-on-dark.css index 0d06f63284..1c7f84c45b 100644 --- a/theme/pastel-on-dark.css +++ b/theme/pastel-on-dark.css @@ -14,8 +14,8 @@ font-size: 14px; } .cm-s-pastel-on-dark div.CodeMirror-selected { background: rgba(221,240,255,0.2) !important; } -.cm-s-pastel-on-dark.CodeMirror ::selection { background: rgba(221,240,255,0.2); } -.cm-s-pastel-on-dark.CodeMirror ::-moz-selection { background: rgba(221,240,255,0.2); } +.cm-s-pastel-on-dark .CodeMirror-line::selection, .cm-s-pastel-on-dark .CodeMirror-line > span::selection, .cm-s-pastel-on-dark .CodeMirror-line > span > span::selection { background: rgba(221,240,255,0.2); } +.cm-s-pastel-on-dark .CodeMirror-line::-moz-selection, .cm-s-pastel-on-dark .CodeMirror-line > span::-moz-selection, .cm-s-pastel-on-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(221,240,255,0.2); } .cm-s-pastel-on-dark .CodeMirror-gutters { background: #34302f; diff --git a/theme/rubyblue.css b/theme/rubyblue.css index d2fc0ecdbc..064f192f78 100644 --- a/theme/rubyblue.css +++ b/theme/rubyblue.css @@ -1,7 +1,7 @@ .cm-s-rubyblue.CodeMirror { background: #112435; color: white; } .cm-s-rubyblue div.CodeMirror-selected { background: #38566F !important; } -.cm-s-rubyblue.CodeMirror ::selection { background: rgba(56, 86, 111, 0.99); } -.cm-s-rubyblue.CodeMirror ::-moz-selection { background: rgba(56, 86, 111, 0.99); } +.cm-s-rubyblue .CodeMirror-line::selection, .cm-s-rubyblue .CodeMirror-line > span::selection, .cm-s-rubyblue .CodeMirror-line > span > span::selection { background: rgba(56, 86, 111, 0.99); } +.cm-s-rubyblue .CodeMirror-line::-moz-selection, .cm-s-rubyblue .CodeMirror-line > span::-moz-selection, .cm-s-rubyblue .CodeMirror-line > span > span::-moz-selection { background: rgba(56, 86, 111, 0.99); } .cm-s-rubyblue .CodeMirror-gutters { background: #1F4661; border-right: 7px solid #3E7087; } .cm-s-rubyblue .CodeMirror-guttermarker { color: white; } .cm-s-rubyblue .CodeMirror-guttermarker-subtle { color: #3E7087; } diff --git a/theme/solarized.css b/theme/solarized.css index 1f1dedac10..03ace472d9 100644 --- a/theme/solarized.css +++ b/theme/solarized.css @@ -96,11 +96,11 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png .cm-s-solarized.cm-s-dark .CodeMirror-selected { background: #073642; } .cm-s-solarized.cm-s-dark.CodeMirror ::selection { background: rgba(7, 54, 66, 0.99); } -.cm-s-solarized.cm-s-dark.CodeMirror ::-moz-selection { background: rgba(7, 54, 66, 0.99); } +.cm-s-solarized.cm-s-dark .CodeMirror-line::-moz-selection, .cm-s-dark .CodeMirror-line > span::-moz-selection, .cm-s-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(7, 54, 66, 0.99); } .cm-s-solarized.cm-s-light .CodeMirror-selected { background: #eee8d5; } -.cm-s-solarized.cm-s-light.CodeMirror ::selection { background: #eee8d5; } -.cm-s-solarized.cm-s-lightCodeMirror ::-moz-selection { background: #eee8d5; } +.cm-s-solarized.cm-s-light .CodeMirror-line::selection, .cm-s-light .CodeMirror-line > span::selection, .cm-s-light .CodeMirror-line > span > span::selection { background: #eee8d5; } +.cm-s-solarized.cm-s-ligh .CodeMirror-line::-moz-selection, .cm-s-ligh .CodeMirror-line > span::-moz-selection, .cm-s-ligh .CodeMirror-line > span > span::-moz-selection { background: #eee8d5; } /* Editor styling */ diff --git a/theme/the-matrix.css b/theme/the-matrix.css index f29b22b0da..ec6046ad96 100644 --- a/theme/the-matrix.css +++ b/theme/the-matrix.css @@ -1,7 +1,7 @@ .cm-s-the-matrix.CodeMirror { background: #000000; color: #00FF00; } .cm-s-the-matrix div.CodeMirror-selected { background: #2D2D2D !important; } -.cm-s-the-matrix.CodeMirror ::selection { background: rgba(45, 45, 45, 0.99); } -.cm-s-the-matrix.CodeMirror ::-moz-selection { background: rgba(45, 45, 45, 0.99); } +.cm-s-the-matrix .CodeMirror-line::selection, .cm-s-the-matrix .CodeMirror-line > span::selection, .cm-s-the-matrix .CodeMirror-line > span > span::selection { background: rgba(45, 45, 45, 0.99); } +.cm-s-the-matrix .CodeMirror-line::-moz-selection, .cm-s-the-matrix .CodeMirror-line > span::-moz-selection, .cm-s-the-matrix .CodeMirror-line > span > span::-moz-selection { background: rgba(45, 45, 45, 0.99); } .cm-s-the-matrix .CodeMirror-gutters { background: #060; border-right: 2px solid #00FF00; } .cm-s-the-matrix .CodeMirror-guttermarker { color: #0f0; } .cm-s-the-matrix .CodeMirror-guttermarker-subtle { color: white; } diff --git a/theme/tomorrow-night-eighties.css b/theme/tomorrow-night-eighties.css index 5fca3cafbf..a8ee8f5d97 100644 --- a/theme/tomorrow-night-eighties.css +++ b/theme/tomorrow-night-eighties.css @@ -10,8 +10,8 @@ .cm-s-tomorrow-night-eighties.CodeMirror {background: #000000; color: #CCCCCC;} .cm-s-tomorrow-night-eighties div.CodeMirror-selected {background: #2D2D2D !important;} -.cm-s-tomorrow-night-eighties.CodeMirror ::selection { background: rgba(45, 45, 45, 0.99); } -.cm-s-tomorrow-night-eighties.CodeMirror ::-moz-selection { background: rgba(45, 45, 45, 0.99); } +.cm-s-tomorrow-night-eighties .CodeMirror-line::selection, .cm-s-tomorrow-night-eighties .CodeMirror-line > span::selection, .cm-s-tomorrow-night-eighties .CodeMirror-line > span > span::selection { background: rgba(45, 45, 45, 0.99); } +.cm-s-tomorrow-night-eighties .CodeMirror-line::-moz-selection, .cm-s-tomorrow-night-eighties .CodeMirror-line > span::-moz-selection, .cm-s-tomorrow-night-eighties .CodeMirror-line > span > span::-moz-selection { background: rgba(45, 45, 45, 0.99); } .cm-s-tomorrow-night-eighties .CodeMirror-gutters {background: #000000; border-right: 0px;} .cm-s-tomorrow-night-eighties .CodeMirror-guttermarker { color: #f2777a; } .cm-s-tomorrow-night-eighties .CodeMirror-guttermarker-subtle { color: #777; } diff --git a/theme/twilight.css b/theme/twilight.css index 889a83d799..360d44afc9 100644 --- a/theme/twilight.css +++ b/theme/twilight.css @@ -1,7 +1,7 @@ .cm-s-twilight.CodeMirror { background: #141414; color: #f7f7f7; } /**/ .cm-s-twilight .CodeMirror-selected { background: #323232 !important; } /**/ -.cm-s-twilight.CodeMirror ::selection { background: rgba(50, 50, 50, 0.99); } -.cm-s-twilight.CodeMirror ::-moz-selection { background: rgba(50, 50, 50, 0.99); } +.cm-s-twilight .CodeMirror-line::selection, .cm-s-twilight .CodeMirror-line > span::selection, .cm-s-twilight .CodeMirror-line > span > span::selection { background: rgba(50, 50, 50, 0.99); } +.cm-s-twilight .CodeMirror-line::-moz-selection, .cm-s-twilight .CodeMirror-line > span::-moz-selection, .cm-s-twilight .CodeMirror-line > span > span::-moz-selection { background: rgba(50, 50, 50, 0.99); } .cm-s-twilight .CodeMirror-gutters { background: #222; border-right: 1px solid #aaa; } .cm-s-twilight .CodeMirror-guttermarker { color: white; } diff --git a/theme/vibrant-ink.css b/theme/vibrant-ink.css index 8ea535973c..8d3e99d386 100644 --- a/theme/vibrant-ink.css +++ b/theme/vibrant-ink.css @@ -2,8 +2,8 @@ .cm-s-vibrant-ink.CodeMirror { background: black; color: white; } .cm-s-vibrant-ink .CodeMirror-selected { background: #35493c !important; } -.cm-s-vibrant-ink.CodeMirror ::selection { background: rgba(53, 73, 60, 0.99); } -.cm-s-vibrant-ink.CodeMirror ::-moz-selection { background: rgba(53, 73, 60, 0.99); } +.cm-s-vibrant-ink .CodeMirror-line::selection, .cm-s-vibrant-ink .CodeMirror-line > span::selection, .cm-s-vibrant-ink .CodeMirror-line > span > span::selection { background: rgba(53, 73, 60, 0.99); } +.cm-s-vibrant-ink .CodeMirror-line::-moz-selection, .cm-s-vibrant-ink .CodeMirror-line > span::-moz-selection, .cm-s-vibrant-ink .CodeMirror-line > span > span::-moz-selection { background: rgba(53, 73, 60, 0.99); } .cm-s-vibrant-ink .CodeMirror-gutters { background: #002240; border-right: 1px solid #aaa; } .cm-s-vibrant-ink .CodeMirror-guttermarker { color: white; } diff --git a/theme/xq-dark.css b/theme/xq-dark.css index d537993e89..5cdfe8f03a 100644 --- a/theme/xq-dark.css +++ b/theme/xq-dark.css @@ -22,8 +22,8 @@ THE SOFTWARE. */ .cm-s-xq-dark.CodeMirror { background: #0a001f; color: #f8f8f8; } .cm-s-xq-dark .CodeMirror-selected { background: #27007A !important; } -.cm-s-xq-dark.CodeMirror ::selection { background: rgba(39, 0, 122, 0.99); } -.cm-s-xq-dark.CodeMirror ::-moz-selection { background: rgba(39, 0, 122, 0.99); } +.cm-s-xq-dark .CodeMirror-line::selection, .cm-s-xq-dark .CodeMirror-line > span::selection, .cm-s-xq-dark .CodeMirror-line > span > span::selection { background: rgba(39, 0, 122, 0.99); } +.cm-s-xq-dark .CodeMirror-line::-moz-selection, .cm-s-xq-dark .CodeMirror-line > span::-moz-selection, .cm-s-xq-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(39, 0, 122, 0.99); } .cm-s-xq-dark .CodeMirror-gutters { background: #0a001f; border-right: 1px solid #aaa; } .cm-s-xq-dark .CodeMirror-guttermarker { color: #FFBD40; } .cm-s-xq-dark .CodeMirror-guttermarker-subtle { color: #f8f8f8; } From d85fd8c4b25889da29576f4ff94557fd64c7e794 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 26 Jun 2015 21:36:48 +0200 Subject: [PATCH 05/47] [css mode] Recognize color keywords in @-block expressions Closes #3336 --- mode/css/css.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mode/css/css.js b/mode/css/css.js index 1e6d2ddbc7..63698c15c9 100644 --- a/mode/css/css.js +++ b/mode/css/css.js @@ -273,6 +273,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) { override = "string-2"; else if (valueKeywords.hasOwnProperty(word)) override = "atom"; + else if (colorKeywords.hasOwnProperty(word)) + override = "keyword"; else override = "error"; } From cfba4b1b61b68d3524a3336d5e990d593945fd0d Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 2 Jul 2015 21:59:22 +0200 Subject: [PATCH 06/47] [show-hint addon] Document selectedHint Closes #3348 --- doc/manual.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/manual.html b/doc/manual.html index 43fac0e475..49faee7982 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -2481,7 +2481,9 @@

Addons

is an array of strings or objects (the completions), and from and to give the start and end of the token that is being completed as {line, ch} - objects. + objects. An optional selectedHint property (an + integer) can be added to the completion object to control the + initially selected hint.
If no hinting function is given, the addon will use CodeMirror.hint.auto, which calls getHelpers with From f52e64d095db6a8bbbd2528bab341ccd44e4b2bf Mon Sep 17 00:00:00 2001 From: mkaminsky11 Date: Fri, 3 Jul 2015 13:42:02 -0700 Subject: [PATCH 07/47] [dracula, seti, yeti, material themes] Add --- demo/theme.html | 8 ++++ theme/dracula.css | 87 ++++++++++++++++++++++++++++++++++++ theme/material.css | 105 ++++++++++++++++++++++++++++++++++++++++++++ theme/seti.css | 88 +++++++++++++++++++++++++++++++++++++ theme/solarized.css | 2 +- theme/yeti.css | 86 ++++++++++++++++++++++++++++++++++++ 6 files changed, 375 insertions(+), 1 deletion(-) create mode 100644 theme/dracula.css create mode 100644 theme/material.css create mode 100644 theme/seti.css create mode 100644 theme/yeti.css diff --git a/demo/theme.html b/demo/theme.html index a5599859ad..8833e87560 100644 --- a/demo/theme.html +++ b/demo/theme.html @@ -13,11 +13,13 @@ + + @@ -29,6 +31,7 @@ + @@ -38,6 +41,7 @@ + @@ -85,11 +89,13 @@

Theme Demo

+ + @@ -101,6 +107,7 @@

Theme Demo

+ @@ -111,6 +118,7 @@

Theme Demo

+

diff --git a/theme/dracula.css b/theme/dracula.css new file mode 100644 index 0000000000..5badef282e --- /dev/null +++ b/theme/dracula.css @@ -0,0 +1,87 @@ +/* + + Name: dracula + Author: Michael Kaminsky (http://github.com/mkaminsky11) + + Original dracula color scheme by Zeno Rocha (https://github.com/zenorocha/dracula-theme) + +*/ + + +.cm-s-dracula.CodeMirror, .cm-s-dracula .CodeMirror-gutters { + background-color: #282a36 !important; + color: #f8f8f2 !important; + border: none; +} +.cm-s-dracula .CodeMirror-gutters{ + color: #282a36; +} +.cm-s-dracula .CodeMirror-cursor { + border-left: solid thin #f8f8f0 !important; +} +.cm-s-dracula .CodeMirror-linenumber { + color: #6D8A88; +} +.cm-s-dracula.CodeMirror-focused .CodeMirror-selected { + background: rgba(255, 255, 255, 0.10); +} +.cm-s-dracula .CodeMirror-line::selection, .cm-s-dracula .CodeMirror-line > span::selection, .cm-s-dracula .CodeMirror-line > span > span::selection { + background: rgba(255, 255, 255, 0.10); +} +.cm-s-dracula .CodeMirror-line::-moz-selection, .cm-s-dracula .CodeMirror-line > span::-moz-selection, .cm-s-dracula .CodeMirror-line > span > span::-moz-selection { + background: rgba(255, 255, 255, 0.10); +} +.cm-s-dracula span.cm-comment { + color: #6272a4; +} +.cm-s-dracula span.cm-string, .cm-s-dracula span.cm-string-2 { + color: #f1fa8c; +} +.cm-s-dracula span.cm-number { + color: #bd93f9; +} +.cm-s-dracula span.cm-variable { + color: #50fa7b; +} +.cm-s-dracula span.cm-variable-2 { + color: white; +} +.cm-s-dracula span.cm-def { + color: #ffb86c; +} +.cm-s-dracula span.cm-keyword { + color: #ff79c6; +} +.cm-s-dracula span.cm-operator { + color: #ff79c6; +} +.cm-s-dracula span.cm-keyword { + color: #ff79c6; +} +.cm-s-dracula span.cm-atom { + color: #bd93f9; +} +.cm-s-dracula span.cm-meta { + color: #f8f8f2; +} +.cm-s-dracula span.cm-tag { + color: #ff79c6; +} +.cm-s-dracula span.cm-attribute { + color: #50fa7b; +} +.cm-s-dracula span.cm-qualifier { + color: #50fa7b; +} +.cm-s-dracula span.cm-property { + color: #66d9ef; +} +.cm-s-dracula span.cm-builtin { + color: #50fa7b; +} +.cm-s-dracula span.cm-variable-3 { + color: #50fa7b; +} + +.cm-s-dracula .CodeMirror-activeline-background {background: rgba(255,255,255,0.1) !important;} +.cm-s-dracula .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;} \ No newline at end of file diff --git a/theme/material.css b/theme/material.css new file mode 100644 index 0000000000..85e1f185d5 --- /dev/null +++ b/theme/material.css @@ -0,0 +1,105 @@ +/* + + Name: material + Author: Michael Kaminsky (http://github.com/mkaminsky11) + + Original material color scheme by Mattia Astorino (https://github.com/equinusocio/material-theme) + +*/ + +.cm-s-material { + background-color: #263238; + color: rgba(233, 237, 237, 1); +} +.cm-s-material .CodeMirror-gutters { + background: #263238; + color: rgb(83,127,126); + border: none; +} +.cm-s-material .CodeMirror-guttermarker, .cm-s-material .CodeMirror-guttermarker-subtle, .cm-s-material .CodeMirror-linenumber { + color: rgb(83,127,126); +} +.cm-s-material .CodeMirror-cursor { + border-left: 1px solid #f8f8f0 !important; +} +.cm-s-material .CodeMirror-selected { + background: rgba(255, 255, 255, 0.15); +} +.cm-s-material.CodeMirror-focused .CodeMirror-selected { + background: rgba(255, 255, 255, 0.10); +} +.cm-s-material .CodeMirror-line::selection, .cm-s-material .CodeMirror-line > span::selection, .cm-s-material .CodeMirror-line > span > span::selection { + background: rgba(255, 255, 255, 0.10); +} +.cm-s-material .CodeMirror-line::-moz-selection, .cm-s-material .CodeMirror-line > span::-moz-selection, .cm-s-material .CodeMirror-line > span > span::-moz-selection { + background: rgba(255, 255, 255, 0.10); +} + +.CodeMirror-activeline-background { + background: rgba(0, 0, 0, 0) !important; +} +.cm-s-material span.cm-keyword { + color: rgba(199, 146, 234, 1); +} +.cm-s-material span.cm-operator { + color: rgba(233, 237, 237, 1); +} +.cm-s-material span.cm-variable-2 { + color: #80CBC4; +} +.cm-s-material span.cm-variable-3 { + color: #82B1FF; +} +.cm-s-material span.cm-builtin { + color: #DECB6B; +} +.cm-s-material span.cm-atom { + color: #F77669; +} +.cm-s-material span.cm-number { + color: #F77669; +} +.cm-s-material span.cm-def { + color: rgba(233, 237, 237, 1); +} +.cm-s-material span.cm-error { + color: rgba(255, 255, 255, 1.0); + background-color: #EC5F67; +} +.cm-s-material span.cm-string { + color: #C3E88D; +} +.cm-s-material span.cm-string-2 { + color: #80CBC4; +} +.cm-s-material span.cm-comment { + color: #546E7A; +} +.cm-s-material span.cm-variable { + color: #82B1FF; +} +.cm-s-material span.cm-tag { + color: #80CBC4; +} +.cm-s-material span.cm-meta{ + color: #80CBC4; +} +.cm-s-material span.cm-attribute { + color: #FFCB6B; +} +.cm-s-material span.cm-property { + color: #80CBAE; +} +.cm-s-material span.cm-qualifier { + color: #DECB6B; +} +.cm-s-material span.cm-variable-3{ + color: #DECB6B; +} +.cm-s-material span.cm-tag { + color: rgba(255, 83, 112, 1); +} +.cm-s-material .CodeMirror-matchingbracket { + text-decoration: underline; + color: white !important; +} \ No newline at end of file diff --git a/theme/seti.css b/theme/seti.css new file mode 100644 index 0000000000..ea27d5eee7 --- /dev/null +++ b/theme/seti.css @@ -0,0 +1,88 @@ +/* + + Name: seti + Author: Michael Kaminsky (http://github.com/mkaminsky11) + + Original seti color scheme by Jesse Weed (https://github.com/jesseweed/seti-syntax) + +*/ + + +.cm-s-seti.CodeMirror { + background-color: #151718 !important; + color: #CFD2D1 !important; + border: none; +} +.cm-s-seti .CodeMirror-gutters{ + color: #404b53; + background-color: #0E1112; + border: none; +} +.cm-s-seti .CodeMirror-cursor { + border-left: solid thin #f8f8f0 !important; +} +.cm-s-seti .CodeMirror-linenumber { + color: #6D8A88; +} +.cm-s-seti.CodeMirror-focused .CodeMirror-selected { + background: rgba(255, 255, 255, 0.10); +} +.cm-s-seti .CodeMirror-line::selection, .cm-s-seti .CodeMirror-line > span::selection, .cm-s-seti .CodeMirror-line > span > span::selection { + background: rgba(255, 255, 255, 0.10); +} +.cm-s-seti .CodeMirror-line::-moz-selection, .cm-s-seti .CodeMirror-line > span::-moz-selection, .cm-s-seti .CodeMirror-line > span > span::-moz-selection { + background: rgba(255, 255, 255, 0.10); +} +.cm-s-seti span.cm-comment { + color: #41535b; +} +.cm-s-seti span.cm-string, .cm-s-seti span.cm-string-2 { + color: #55b5db; +} +.cm-s-seti span.cm-number { + color: #cd3f45; +} +.cm-s-seti span.cm-variable { + color: #55b5db; +} +.cm-s-seti span.cm-variable-2 { + color: #a074c4; +} +.cm-s-seti span.cm-def { + color: #55b5db; +} +.cm-s-seti span.cm-keyword { + color: #ff79c6; +} +.cm-s-seti span.cm-operator { + color: #9fca56; +} +.cm-s-seti span.cm-keyword { + color: #e6cd69; +} +.cm-s-seti span.cm-atom { + color: #cd3f45; +} +.cm-s-seti span.cm-meta { + color: #55b5db; +} +.cm-s-seti span.cm-tag { + color: #55b5db; +} +.cm-s-seti span.cm-attribute { + color: #9fca56; +} +.cm-s-seti span.cm-qualifier { + color: #9fca56; +} +.cm-s-seti span.cm-property { + color: #a074c4; +} +.cm-s-seti span.cm-variable-3 { + color: #9fca56; +} +.cm-s-seti span.cm-builtin { + color: #9fca56; +} +.cm-s-seti .CodeMirror-activeline-background {background: #101213 !important;} +.cm-s-seti .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;} \ No newline at end of file diff --git a/theme/solarized.css b/theme/solarized.css index 03ace472d9..18ed6de63f 100644 --- a/theme/solarized.css +++ b/theme/solarized.css @@ -100,7 +100,7 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png .cm-s-solarized.cm-s-light .CodeMirror-selected { background: #eee8d5; } .cm-s-solarized.cm-s-light .CodeMirror-line::selection, .cm-s-light .CodeMirror-line > span::selection, .cm-s-light .CodeMirror-line > span > span::selection { background: #eee8d5; } -.cm-s-solarized.cm-s-ligh .CodeMirror-line::-moz-selection, .cm-s-ligh .CodeMirror-line > span::-moz-selection, .cm-s-ligh .CodeMirror-line > span > span::-moz-selection { background: #eee8d5; } +.cm-s-solarized.cm-s-light .CodeMirror-line::-moz-selection, .cm-s-ligh .CodeMirror-line > span::-moz-selection, .cm-s-ligh .CodeMirror-line > span > span::-moz-selection { background: #eee8d5; } /* Editor styling */ diff --git a/theme/yeti.css b/theme/yeti.css new file mode 100644 index 0000000000..dce32588cd --- /dev/null +++ b/theme/yeti.css @@ -0,0 +1,86 @@ +/* + + Name: yeti + Author: Michael Kaminsky (http://github.com/mkaminsky11) + + Original yeti color scheme by Jesse Weed (https://github.com/jesseweed/yeti-syntax) + +*/ + + +.cm-s-yeti.CodeMirror { + background-color: #ECEAE8 !important; + color: #d1c9c0 !important; + border: none; +} + +.cm-s-yeti .CodeMirror-gutters{ + color: #adaba6; + background-color: #E5E1DB; + border: none; +} +.cm-s-yeti .CodeMirror-cursor { + border-left: solid thin #d1c9c0 !important; +} +.cm-s-yeti .CodeMirror-linenumber { + color: #adaba6; +} +.cm-s-yeti.CodeMirror-focused .CodeMirror-selected { + background: #DCD8D2; +} +.cm-s-yeti .CodeMirror-line::selection, .cm-s-yeti .CodeMirror-line > span::selection, .cm-s-yeti .CodeMirror-line > span > span::selection { + background: #DCD8D2; +} +.cm-s-yeti .CodeMirror-line::-moz-selection, .cm-s-yeti .CodeMirror-line > span::-moz-selection, .cm-s-yeti .CodeMirror-line > span > span::-moz-selection { + background: #DCD8D2; +} +.cm-s-yeti span.cm-comment { + color: #d4c8be; +} +.cm-s-yeti span.cm-string, .cm-s-yeti span.cm-string-2 { + color: #96c0d8; +} +.cm-s-yeti span.cm-number { + color: #a074c4; +} +.cm-s-yeti span.cm-variable { + color: #55b5db; +} +.cm-s-yeti span.cm-variable-2 { + color: #a074c4; +} +.cm-s-yeti span.cm-def { + color: #55b5db; +} +.cm-s-yeti span.cm-operator { + color: #9fb96e; +} +.cm-s-yeti span.cm-keyword { + color: #9fb96e; +} +.cm-s-yeti span.cm-atom { + color:##a074c4; +} +.cm-s-yeti span.cm-meta { + color: #96c0d8; +} +.cm-s-yeti span.cm-tag { + color: #96c0d8; +} +.cm-s-yeti span.cm-attribute { + color: #9fb96e; +} +.cm-s-yeti span.cm-qualifier { + color: #96c0d8; +} +.cm-s-yeti span.cm-property { + color: #a074c4; +} +.cm-s-yeti span.cm-builtin { + color: #a074c4; +} +.cm-s-yeti span.cm-variable-3 { + color: #96c0d8; +} +.cm-s-yeti .CodeMirror-activeline-background {background: #E7E4E0 !important;} +.cm-s-yeti .CodeMirror-matchingbracket { text-decoration: underline;} \ No newline at end of file From 165f5d9d9363620faa458c49410c2fa6458bb89f Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 10 Jul 2015 17:19:58 +0200 Subject: [PATCH 08/47] [theme demo] Make hash reflect current theme --- demo/theme.html | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/demo/theme.html b/demo/theme.html index 8833e87560..7898fcd7b4 100644 --- a/demo/theme.html +++ b/demo/theme.html @@ -131,14 +131,20 @@

Theme Demo

}); var input = document.getElementById("select"); function selectTheme() { - var theme = input.options[input.selectedIndex].innerHTML; + var theme = input.options[input.selectedIndex].textContent; editor.setOption("theme", theme); + location.hash = "#" + theme; } - var choice = document.location.search && - decodeURIComponent(document.location.search.slice(1)); + var choice = (location.hash && location.hash.slice(1)) || + (document.location.search && + decodeURIComponent(document.location.search.slice(1))); if (choice) { input.value = choice; editor.setOption("theme", choice); } + CodeMirror.on(window, "hashchange", function() { + var theme = location.hash.slice(1); + if (theme) { input.value = theme; selectTheme(); } + }); From 84c8c92968174df6d35ce5a3772ca9900d9b4f26 Mon Sep 17 00:00:00 2001 From: mkaminsky11 Date: Tue, 7 Jul 2015 14:54:15 -0700 Subject: [PATCH 09/47] [brainfuck mode] Add --- doc/compress.html | 1 + mode/brainfuck/brainfuck.js | 85 +++++++++++++++++++++++++++++++++++++ mode/brainfuck/index.html | 85 +++++++++++++++++++++++++++++++++++++ mode/index.html | 1 + mode/meta.js | 3 +- 5 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 mode/brainfuck/brainfuck.js create mode 100644 mode/brainfuck/index.html diff --git a/doc/compress.html b/doc/compress.html index ecbc406591..7acdefe2af 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -110,6 +110,7 @@

Script compression helper

+ diff --git a/mode/brainfuck/brainfuck.js b/mode/brainfuck/brainfuck.js new file mode 100644 index 0000000000..3becf2a5a3 --- /dev/null +++ b/mode/brainfuck/brainfuck.js @@ -0,0 +1,85 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +// Brainfuck mode created by Michael Kaminsky https://github.com/mkaminsky11 + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") + mod(require("../../lib/codemirror")) + else if (typeof define == "function" && define.amd) + define(["../../lib/codemirror"], mod) + else + mod(CodeMirror) +})(function(CodeMirror) { + "use strict" + var reserve = "><+-.,[]".split(""); + /* + comments can be either: + placed behind lines + + +++ this is a comment + + where reserved characters cannot be used + or in a loop + [ + this is ok to use [ ] and stuff + ] + or preceded by # + */ + CodeMirror.defineMode("brainfuck", function() { + return { + startState: function() { + return { + commentLine: false, + left: 0, + right: 0, + commentLoop: false + } + }, + token: function(stream, state) { + if (stream.eatSpace()) return null + if(stream.sol()){ + state.commentLine = false; + } + var ch = stream.next().toString(); + if(reserve.indexOf(ch) !== -1){ + if(state.commentLine === true){ + if(stream.eol()){ + state.commentLine = false; + } + return "comment"; + } + if(ch === "]" || ch === "["){ + if(ch === "["){ + state.left++; + } + else{ + state.right++; + } + return "bracket"; + } + else if(ch === "+" || ch === "-"){ + return "keyword"; + } + else if(ch === "<" || ch === ">"){ + return "atom"; + } + else if(ch === "." || ch === ","){ + return "def"; + } + } + else{ + state.commentLine = true; + if(stream.eol()){ + state.commentLine = false; + } + return "comment"; + } + if(stream.eol()){ + state.commentLine = false; + } + } + }; + }); +CodeMirror.defineMIME("text/x-brainfuck","brainfuck") +}); diff --git a/mode/brainfuck/index.html b/mode/brainfuck/index.html new file mode 100644 index 0000000000..6048fc2412 --- /dev/null +++ b/mode/brainfuck/index.html @@ -0,0 +1,85 @@ + + +CodeMirror: Brainfuck mode + + + + + + + + + + +
+

Brainfuck mode

+
+ + + +

A mode for Brainfuck

+ +

MIME types defined: text/x-brainfuck

+
diff --git a/mode/index.html b/mode/index.html index 8c6d0a435e..ca89a377a8 100644 --- a/mode/index.html +++ b/mode/index.html @@ -33,6 +33,7 @@

Language modes

  • APL
  • ASN.1
  • Asterisk dialplan
  • +
  • Brainfuck
  • C, C++, C#
  • Clojure
  • CMake
  • diff --git a/mode/meta.js b/mode/meta.js index bb30c80f54..bf0929eba6 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -14,8 +14,9 @@ CodeMirror.modeInfo = [ {name: "APL", mime: "text/apl", mode: "apl", ext: ["dyalog", "apl"]}, {name: "PGP", mimes: ["application/pgp", "application/pgp-keys", "application/pgp-signature"], mode: "asciiarmor", ext: ["pgp"]}, - {name: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn, asn1"]}, + {name: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn", "asn1"]}, {name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk", file: /^extensions\.conf$/i}, + {name: "Brainfuck", mime: "text/x-brainfuck", mode: "brainfuck", ext: ["b", "bf"]}, {name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h"]}, {name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]}, {name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]}, From 31d89d6e4f84631198800e7b4f991606fb1cc57b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 13 Jul 2015 11:07:36 +0200 Subject: [PATCH 10/47] Prevent sizer from propping up scroll height Closes #3361 --- lib/codemirror.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index 572cbbce52..a806e9a4e1 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -714,7 +714,7 @@ // width and height. removeChildren(display.cursorDiv); removeChildren(display.selectionDiv); - display.gutters.style.height = 0; + display.gutters.style.height = display.sizer.style.minHeight = 0; if (different) { display.lastWrapHeight = update.wrapperHeight; From 50aba2033fc4b96bf033f8b8a0dcd18aec464748 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 13 Jul 2015 11:38:59 +0200 Subject: [PATCH 11/47] Add a test for resizing editors shrinking correctly Issue #3362 --- test/scroll_test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/scroll_test.js b/test/scroll_test.js index 20470028ce..82fd126c48 100644 --- a/test/scroll_test.js +++ b/test/scroll_test.js @@ -102,4 +102,14 @@ cm.replaceSelection("\n"); is(cm.cursorCoords(null, "window").bottom < displayBottom(cm, false)); }, {lineWrapping: true}); + + testCM("height_auto_with_gutter_expect_no_scroll_after_line_delete", function(cm) { + cm.setSize(null, "auto"); + cm.setValue("x\n"); + cm.execCommand("goDocEnd"); + cm.execCommand("delCharBefore"); + eq(cm.getScrollInfo().top, 0); + cm.scrollTo(null, 10); + is(cm.getScrollInfo().top < 5); + }, {lineNumbers: true}); })(); From 8d797495642152f140aaf430650016ea55dd14aa Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 13 Jul 2015 11:50:38 +0200 Subject: [PATCH 12/47] [show-hint addon] Ignore hint updates that start at a different place from original list See http://discuss.codemirror.net/t/tern-special-characters-causing-issues/294 --- addon/hint/show-hint.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addon/hint/show-hint.js b/addon/hint/show-hint.js index d228fc8890..fc85a10bb7 100644 --- a/addon/hint/show-hint.js +++ b/addon/hint/show-hint.js @@ -111,6 +111,7 @@ }, finishUpdate: function(data, first) { + if (data && this.data && CodeMirror.cmpPos(data.from, this.data.from)) data = null; this.data = data; var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle); From 66ba83ca1a7e043cf78e13c16cc7b9d94d59f2db Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Fri, 3 Jul 2015 19:40:45 +0100 Subject: [PATCH 13/47] [icecoder theme] Add Spent quite a while perfecting this (IMO), but a lot of people seem to really like it. Hope you do too. --- demo/theme.html | 2 ++ theme/icecoder.css | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 theme/icecoder.css diff --git a/demo/theme.html b/demo/theme.html index 7898fcd7b4..93d52510fb 100644 --- a/demo/theme.html +++ b/demo/theme.html @@ -17,6 +17,7 @@ + @@ -93,6 +94,7 @@

    Theme Demo

    + diff --git a/theme/icecoder.css b/theme/icecoder.css new file mode 100644 index 0000000000..ff2d43bd21 --- /dev/null +++ b/theme/icecoder.css @@ -0,0 +1,42 @@ +/* +ICEcoder default theme by Matt Pass, used in code editor available at https://icecoder.net +*/ + +.cm-s-icecoder {color: #666; background: #141612} + +.cm-s-icecoder span.cm-keyword {color: #eee; font-weight:bold} /* off-white 1 */ +.cm-s-icecoder span.cm-atom {color: #e1c76e} /* yellow */ +.cm-s-icecoder span.cm-number {color: #6cb5d9} /* blue */ +.cm-s-icecoder span.cm-def {color: #b9ca4a} /* green */ + +.cm-s-icecoder span.cm-variable {color: #6cb5d9} /* blue */ +.cm-s-icecoder span.cm-variable-2 {color: #bf255c} /* pink */ +.cm-s-icecoder span.cm-variable-3 {color: #f9602c} /* orange */ + +.cm-s-icecoder span.cm-property {color: #eee} /* off-white 1 */ +.cm-s-icecoder span.cm-operator {color: #9179bb} /* purple */ +.cm-s-icecoder span.cm-comment {color: #97a3aa} /* grey-blue */ + +.cm-s-icecoder span.cm-string {color: #b9ca4a} /* green */ +.cm-s-icecoder span.cm-string-2 {color: #6cb5d9} /* blue */ + +.cm-s-icecoder span.cm-meta {color: #555} /* grey */ + +.cm-s-icecoder span.cm-qualifier {color: #555} /* grey */ +.cm-s-icecoder span.cm-builtin {color: #214e7b} /* bright blue */ +.cm-s-icecoder span.cm-bracket {color: #cc7} /* grey-yellow */ + +.cm-s-icecoder span.cm-tag {color: #e8e8e8} /* off-white 2 */ +.cm-s-icecoder span.cm-attribute {color: #099} /* teal */ + +.cm-s-icecoder span.cm-header {color: #6a0d6a} /* purple-pink */ +.cm-s-icecoder span.cm-quote {color: #186718} /* dark green */ +.cm-s-icecoder span.cm-hr {color: #888} /* mid-grey */ +.cm-s-icecoder span.cm-link {color: #e1c76e} /* yellow */ +.cm-s-icecoder span.cm-error {color: #d00} /* red */ + +.cm-s-icecoder .CodeMirror-cursor {border-left: 1px solid white !important} +.cm-s-icecoder .CodeMirror-selected {color: #fff !important; background: #037 !important} +.cm-s-icecoder .CodeMirror-gutters {background: #141612; min-width: 41px; border-right: 0} +.cm-s-icecoder .CodeMirror-linenumber {color: #555; cursor: default} +.cm-s-icecoder .CodeMirror-matchingbracket {border: 1px solid grey; color: black !important} \ No newline at end of file From 96b50658e14bc7796790c0024f067f191face333 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 13 Jul 2015 12:14:45 +0200 Subject: [PATCH 14/47] [CONTRIBUTING.md] Add note about focused pull requests --- CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1645548239..6d65e41129 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -61,7 +61,8 @@ should be asked on the - Make sure all tests pass. Visit `test/index.html` in your browser to run them. - Submit a pull request -([how to create a pull request](https://help.github.com/articles/fork-a-repo)) +([how to create a pull request](https://help.github.com/articles/fork-a-repo)). + Don't put more than one feature/fix in a single pull request. By contributing code to CodeMirror you From afd407f572d1bb82fef31b21a07eb810ce1bd432 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 13 Jul 2015 12:28:13 +0200 Subject: [PATCH 15/47] [ruby mode] Fix management of curPunc output variable Closes #3365 --- mode/ruby/ruby.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/ruby/ruby.js b/mode/ruby/ruby.js index eab9d9da7f..771f855abf 100644 --- a/mode/ruby/ruby.js +++ b/mode/ruby/ruby.js @@ -37,7 +37,6 @@ CodeMirror.defineMode("ruby", function(config) { } function tokenBase(stream, state) { - curPunc = null; if (stream.sol() && stream.match("=begin") && stream.eol()) { state.tokenize.push(readBlockComment); return "comment"; @@ -232,6 +231,7 @@ CodeMirror.defineMode("ruby", function(config) { }, token: function(stream, state) { + curPunc = null; if (stream.sol()) state.indented = stream.indentation(); var style = state.tokenize[state.tokenize.length-1](stream, state), kwtype; var thisTok = curPunc; From e585ae81469c21394432407da1754ad6340850e1 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Mon, 13 Jul 2015 11:28:14 +0100 Subject: [PATCH 16/47] [icecoder theme] Color boost on variable-2 to be brighter Was a little subdued --- theme/icecoder.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/theme/icecoder.css b/theme/icecoder.css index ff2d43bd21..5ec374342a 100644 --- a/theme/icecoder.css +++ b/theme/icecoder.css @@ -10,7 +10,7 @@ ICEcoder default theme by Matt Pass, used in code editor available at https://ic .cm-s-icecoder span.cm-def {color: #b9ca4a} /* green */ .cm-s-icecoder span.cm-variable {color: #6cb5d9} /* blue */ -.cm-s-icecoder span.cm-variable-2 {color: #bf255c} /* pink */ +.cm-s-icecoder span.cm-variable-2 {color: #cc1e5c} /* pink */ .cm-s-icecoder span.cm-variable-3 {color: #f9602c} /* orange */ .cm-s-icecoder span.cm-property {color: #eee} /* off-white 1 */ @@ -39,4 +39,4 @@ ICEcoder default theme by Matt Pass, used in code editor available at https://ic .cm-s-icecoder .CodeMirror-selected {color: #fff !important; background: #037 !important} .cm-s-icecoder .CodeMirror-gutters {background: #141612; min-width: 41px; border-right: 0} .cm-s-icecoder .CodeMirror-linenumber {color: #555; cursor: default} -.cm-s-icecoder .CodeMirror-matchingbracket {border: 1px solid grey; color: black !important} \ No newline at end of file +.cm-s-icecoder .CodeMirror-matchingbracket {border: 1px solid grey; color: black !important} From 8e6aca8c445b716fffac9cdd19fa8fc42abed430 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 13 Jul 2015 12:37:58 +0200 Subject: [PATCH 17/47] Make activeElt aware of shadow DOM nesting Issue #3369 --- lib/codemirror.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index a806e9a4e1..221dacd8d5 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -8269,7 +8269,12 @@ } while (child = child.parentNode); }; - function activeElt() { return document.activeElement; } + function activeElt() { + var activeElement = document.activeElement; + while (activeElement && activeElement.root && activeElement.root.activeElement) + activeElement = activeElement.root.activeElement; + return activeElement; + } // Older versions of IE throws unspecified error when touching // document.activeElement in some cases (during loading, in iframe) if (ie && ie_version < 11) activeElt = function() { From efca20989567651901895dae6532953386d191f1 Mon Sep 17 00:00:00 2001 From: Oreoluwa Onatemowo Date: Wed, 8 Jul 2015 16:53:41 -0700 Subject: [PATCH 18/47] [tern addon] Update CSS to prevent cutting off of icons I noticed that the image that accompanies auto-completion suggestions when the tern addon is active gets cut slightly, because the default line height is slightly smaller than the image height. This change above ensures that the line height is bigger, hence ensuring that the image is fully shown. --- addon/tern/tern.css | 1 + 1 file changed, 1 insertion(+) diff --git a/addon/tern/tern.css b/addon/tern/tern.css index 76fba33d4a..c4b8a2f77e 100644 --- a/addon/tern/tern.css +++ b/addon/tern/tern.css @@ -1,6 +1,7 @@ .CodeMirror-Tern-completion { padding-left: 22px; position: relative; + line-height: 1.5; } .CodeMirror-Tern-completion:before { position: absolute; From bd36c1dbe484d6a9a692d814995ff02473279449 Mon Sep 17 00:00:00 2001 From: Michael Zhou Date: Fri, 10 Jul 2015 01:02:43 -0700 Subject: [PATCH 19/47] [vhdl mode] Add Reference: https://groups.google.com/forum/#!msg/codemirror/uRUuqXimqj0/mn3Lmdkab18J Rewritten to match the style of the Verilog mode --- mode/vhdl/index.html | 95 +++++++++++++++++++++ mode/vhdl/vhdl.js | 193 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 288 insertions(+) create mode 100644 mode/vhdl/index.html create mode 100644 mode/vhdl/vhdl.js diff --git a/mode/vhdl/index.html b/mode/vhdl/index.html new file mode 100644 index 0000000000..24e86f039d --- /dev/null +++ b/mode/vhdl/index.html @@ -0,0 +1,95 @@ + + +CodeMirror: VHDL mode + + + + + + + + + + +
    +

    VHDL mode

    + +
    + + + +

    +Syntax highlighting and indentation for the VHDL language. +

    Configuration options:

    +
      +
    • atoms - List of atom words. Default: "null"
    • +
    • hooks - List of meta hooks. Default: ["`", "$"]
    • +
    • multiLineStrings - Whether multi-line strings are accepted. Default: undefined
    • +
    +

    + +

    MIME types defined: text/x-vhdl.

    +
    diff --git a/mode/vhdl/vhdl.js b/mode/vhdl/vhdl.js new file mode 100644 index 0000000000..cc9c43d80f --- /dev/null +++ b/mode/vhdl/vhdl.js @@ -0,0 +1,193 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +// Originall written by Alf Nielsen, re-written by Michael Zhou +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + +function words(str) { + var obj = {}, words = str.split(","); + for (var i = 0; i < words.length; ++i) { + var allCaps = words[i].toUpperCase(); + var firstCap = words[i].charAt(0).toUpperCase() + words[i].slice(1); + obj[words[i]] = true; + obj[allCaps] = true; + obj[firstCap] = true; + } + return obj; +} + +CodeMirror.defineMode("vhdl", function(config, parserConfig) { + var indentUnit = config.indentUnit, + atoms = parserConfig.atoms || {}, + hooks = parserConfig.hooks || {}, + multiLineStrings = parserConfig.multiLineStrings; + + var keywords = words("abs,access,after,alias,all,and,architecture,array,assert,attribute,begin,block," + + "body,buffer,bus,case,component,configuration,constant,disconnent,downto,else,elsif,end,end block,end case," + + "end component,end for,end generate,end if,end loop,end process,end record,end units,entity,exit,file,for," + + "function,generate,generic,generic map,group,guarded,if,impure,in,inertial,inout,is,label,library,linkage," + + "literal,loop,map,mod,nand,new,next,nor,null,of,on,open,or,others,out,package,package body,port,port map," + + "postponed,procedure,process,pure,range,record,register,reject,rem,report,return,rol,ror,select,severity,signal," + + "sla,sll,sra,srl,subtype,then,to,transport,type,unaffected,units,until,use,variable,wait,when,while,with,xnor,xor"); + + var blockKeywords = words("architecture,entity,begin,case,port,else,elsif,end,for,function,if"); + + var isOperatorChar = /[&|~> Date: Mon, 13 Jul 2015 12:53:12 +0200 Subject: [PATCH 20/47] [vhdl mode] Integrate Issue #3372 --- doc/compress.html | 1 + mode/index.html | 1 + mode/vhdl/index.html | 2 +- mode/vhdl/vhdl.js | 20 ++++++++------------ 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/doc/compress.html b/doc/compress.html index 7acdefe2af..98b0f674f0 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -208,6 +208,7 @@

    Script compression helper

    + diff --git a/mode/index.html b/mode/index.html index ca89a377a8..7629561932 100644 --- a/mode/index.html +++ b/mode/index.html @@ -137,6 +137,7 @@

    Language modes

  • VBScript
  • Velocity
  • Verilog/SystemVerilog
  • +
  • VHDL
  • XML/HTML
  • XQuery
  • YAML
  • diff --git a/mode/vhdl/index.html b/mode/vhdl/index.html index 24e86f039d..3051bc37e5 100644 --- a/mode/vhdl/index.html +++ b/mode/vhdl/index.html @@ -87,7 +87,7 @@

    Configuration options:

    • atoms - List of atom words. Default: "null"
    • hooks - List of meta hooks. Default: ["`", "$"]
    • -
    • multiLineStrings - Whether multi-line strings are accepted. Default: undefined
    • +
    • multiLineStrings - Whether multi-line strings are accepted. Default: false

    diff --git a/mode/vhdl/vhdl.js b/mode/vhdl/vhdl.js index cc9c43d80f..470cf2be8a 100644 --- a/mode/vhdl/vhdl.js +++ b/mode/vhdl/vhdl.js @@ -24,10 +24,15 @@ function words(str) { return obj; } +function metaHook(stream) { + stream.eatWhile(/[\w\$_]/); + return "meta"; +} + CodeMirror.defineMode("vhdl", function(config, parserConfig) { var indentUnit = config.indentUnit, - atoms = parserConfig.atoms || {}, - hooks = parserConfig.hooks || {}, + atoms = parserConfig.atoms || words("null"), + hooks = parserConfig.hooks || {"`": metaHook, "$": metaHook}, multiLineStrings = parserConfig.multiLineStrings; var keywords = words("abs,access,after,alias,all,and,architecture,array,assert,attribute,begin,block," + @@ -179,15 +184,6 @@ CodeMirror.defineMode("vhdl", function(config, parserConfig) { }; }); -function metaHook(stream) { - stream.eatWhile(/[\w\$_]/); - return "meta"; -} - -CodeMirror.defineMIME("text/x-vhdl", { - name: "vhdl", - atoms: words("null"), - hooks: {"`": metaHook, "$": metaHook} -}); +CodeMirror.defineMIME("text/x-vhdl", "vhdl"); }); From 127a6e017e4d40c43734a301e0c4e9135c6375d6 Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Fri, 10 Jul 2015 09:01:39 +0100 Subject: [PATCH 21/47] [emacs keymap] Fix handling of non-integer line numbers in goto-line. --- keymap/emacs.js | 2 +- test/emacs_test.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/keymap/emacs.js b/keymap/emacs.js index c4135237e1..3eec1e5762 100644 --- a/keymap/emacs.js +++ b/keymap/emacs.js @@ -377,7 +377,7 @@ getInput(cm, "Goto line", function(str) { var num; - if (str && !isNaN(num = Number(str)) && num == num|0 && num > 0) + if (str && !isNaN(num = Number(str)) && num == (num|0) && num > 0) cm.setCursor(num - 1); }); }, diff --git a/test/emacs_test.js b/test/emacs_test.js index ccbd6ce491..01db618b24 100644 --- a/test/emacs_test.js +++ b/test/emacs_test.js @@ -138,4 +138,10 @@ cm.triggerOnKeyDown(fakeEvent("Ctrl-S")); is(saved, "hi"); }, {value: "hi", keyMap: "emacs"}); + + testCM("gotoInvalidLineFloat", function(cm) { + cm.openDialog = function(_, cb) { cb("2.2"); }; + cm.triggerOnKeyDown(fakeEvent("Alt-G")); + cm.triggerOnKeyDown(fakeEvent("G")); + }, {value: "1\n2\n3\n4", keyMap: "emacs"}); })(); From 8cc9eb8c9c47081bf4fb7edf7dd7e98f428cf34c Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Fri, 10 Jul 2015 09:06:14 +0100 Subject: [PATCH 22/47] [erlang mode] Remove duplicate if conditions. --- mode/erlang/erlang.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mode/erlang/erlang.js b/mode/erlang/erlang.js index fbca292f03..5aed76a526 100644 --- a/mode/erlang/erlang.js +++ b/mode/erlang/erlang.js @@ -220,8 +220,6 @@ CodeMirror.defineMode("erlang", function(cmCfg) { }else{ return rval(state,stream,"function"); } - }else if (is_member(w,operatorAtomWords)) { - return rval(state,stream,"operator"); }else if (lookahead(stream) == ":") { if (w == "erlang") { return rval(state,stream,"builtin"); @@ -230,8 +228,6 @@ CodeMirror.defineMode("erlang", function(cmCfg) { } }else if (is_member(w,["true","false"])) { return rval(state,stream,"boolean"); - }else if (is_member(w,["true","false"])) { - return rval(state,stream,"boolean"); }else{ return rval(state,stream,"atom"); } From c2350fd4eea27fcb0a4fbc6e121ac62c0c5de4e7 Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Fri, 10 Jul 2015 09:19:25 +0100 Subject: [PATCH 23/47] [vim tests] Remove a few useless expressions --- test/vim_test.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/vim_test.js b/test/vim_test.js index e9b7bec069..320a67b99e 100644 --- a/test/vim_test.js +++ b/test/vim_test.js @@ -390,7 +390,6 @@ testVim('%_skip_string', function(cm, vim, helpers) { helpers.doKeys(['%']); helpers.assertCursorAt(0,0); }, {value:'(")")'}); -(')') testVim('%_skip_comment', function(cm, vim, helpers) { cm.setCursor(0,0); helpers.doKeys(['%']); @@ -3128,8 +3127,7 @@ testVim('zt==z', function(cm, vim, helpers){ }); var moveTillCharacterSandbox = - 'The quick brown fox \n' - 'jumped over the lazy dog.' + 'The quick brown fox \n'; testVim('moveTillCharacter', function(cm, vim, helpers){ cm.setCursor(0, 0); // Search for the 'q'. @@ -3176,9 +3174,6 @@ testVim('searchForPipe', function(cm, vim, helpers){ var scrollMotionSandbox = - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'; testVim('scrollMotion', function(cm, vim, helpers){ var prevCursor, prevScrollInfo; From 9a532d3ca683e3810a777506314feda15a37b74a Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Fri, 10 Jul 2015 10:08:56 +0100 Subject: [PATCH 24/47] [vim mode] Fix notification about lacking pattern support in sort command. --- keymap/vim.js | 2 +- test/vim_test.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/keymap/vim.js b/keymap/vim.js index d50cc4af45..14897a84da 100644 --- a/keymap/vim.js +++ b/keymap/vim.js @@ -4308,7 +4308,7 @@ if (decimal + hex + octal > 1) { return 'Invalid arguments'; } number = decimal && 'decimal' || hex && 'hex' || octal && 'octal'; } - if (args.eatSpace() && args.match(/\/.*\//)) { 'patterns not supported'; } + if (args.match(/\/.*\//)) { return 'patterns not supported'; } } } var err = parseArgs(); diff --git a/test/vim_test.js b/test/vim_test.js index 320a67b99e..855cb8825e 100644 --- a/test/vim_test.js +++ b/test/vim_test.js @@ -3392,6 +3392,14 @@ testVim('ex_sort_decimal_mixed_reverse', function(cm, vim, helpers) { helpers.doEx('sort! d'); eq('a3\nb2\nc1\nz\ny', cm.getValue()); }, { value: 'a3\nz\nc1\ny\nb2'}); +testVim('ex_sort_patterns_not_supported', function(cm, vim, helpers) { + var notified = false; + cm.openNotification = helpers.fakeOpenNotification(function(text) { + notified = /patterns not supported/.test(text); + }); + helpers.doEx('sort /abc/'); + is(notified, 'No notification.'); +}); // test for :global command testVim('ex_global', function(cm, vim, helpers) { cm.setCursor(0, 0); From b8c4ea12a7c472981c0a35dd20c79bbebb01bc69 Mon Sep 17 00:00:00 2001 From: Angelo Date: Fri, 10 Jul 2015 16:13:26 +0200 Subject: [PATCH 25/47] [tern addon] Use displayName if it exists for completion display text Tern completion for required module returns name (module wuith quote) and displayName (module without quote). This PR gives the capability to display completion for required module without quote. --- addon/tern/tern.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/tern/tern.js b/addon/tern/tern.js index dfb19b8451..42c3cdee24 100644 --- a/addon/tern/tern.js +++ b/addon/tern/tern.js @@ -216,7 +216,7 @@ var completion = data.completions[i], className = typeToIcon(completion.type); if (data.guess) className += " " + cls + "guess"; completions.push({text: completion.name + after, - displayText: completion.name, + displayText: completion.displayName || completion.name, className: className, data: completion}); } From baad003136869696e044f7cd6f48f973512fb527 Mon Sep 17 00:00:00 2001 From: Vincent Woo Date: Sat, 11 Jul 2015 03:12:19 -0700 Subject: [PATCH 26/47] [sublime keymap] Fix scrollLine[Up/Down] bindings --- keymap/sublime.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/keymap/sublime.js b/keymap/sublime.js index 441456f58c..1d9a9d8ef6 100644 --- a/keymap/sublime.js +++ b/keymap/sublime.js @@ -55,7 +55,9 @@ cmds[map["Alt-Left"] = "goSubwordLeft"] = function(cm) { moveSubword(cm, -1); }; cmds[map["Alt-Right"] = "goSubwordRight"] = function(cm) { moveSubword(cm, 1); }; - cmds[map[ctrl + "Up"] = "scrollLineUp"] = function(cm) { + var scrollLineCombo = mac ? "Ctrl-Alt-" : "Ctrl-"; + + cmds[map[scrollLineCombo + "Up"] = "scrollLineUp"] = function(cm) { var info = cm.getScrollInfo(); if (!cm.somethingSelected()) { var visibleBottomLine = cm.lineAtHeight(info.top + info.clientHeight, "local"); @@ -64,7 +66,7 @@ } cm.scrollTo(null, info.top - cm.defaultTextHeight()); }; - cmds[map[ctrl + "Down"] = "scrollLineDown"] = function(cm) { + cmds[map[scrollLineCombo + "Down"] = "scrollLineDown"] = function(cm) { var info = cm.getScrollInfo(); if (!cm.somethingSelected()) { var visibleTopLine = cm.lineAtHeight(info.top, "local")+1; From 002688377fc8c5f0f5d6229259fbfddf05ed62b4 Mon Sep 17 00:00:00 2001 From: Vincent Woo Date: Sat, 11 Jul 2015 03:31:27 -0700 Subject: [PATCH 27/47] [travis] Use stable node and container infrastructure --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 20fd86b6a5..52b8b81591 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ language: node_js node_js: - - 0.10 + - stable +sudo: false From 9abd9e63331e4fa3db61a4159acab222c8490112 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 13 Jul 2015 14:51:00 +0200 Subject: [PATCH 28/47] Work around bad interaction between above-line widgets and gutter backgrounds Issue #3357 --- lib/codemirror.css | 8 +++++++- lib/codemirror.js | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/codemirror.css b/lib/codemirror.css index c4aa3c0635..08eb6bbf29 100644 --- a/lib/codemirror.css +++ b/lib/codemirror.css @@ -202,7 +202,13 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} .CodeMirror-gutter-wrapper { position: absolute; z-index: 4; - height: 100%; + background: none !important; + border: none !important; +} +.CodeMirror-gutter-background { + position: absolute; + top: 0; bottom: 0; + z-index: 4; } .CodeMirror-gutter-elt { position: absolute; diff --git a/lib/codemirror.js b/lib/codemirror.js index 221dacd8d5..36ce1913d9 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -955,12 +955,22 @@ lineView.node.removeChild(lineView.gutter); lineView.gutter = null; } + if (lineView.gutterBackground) { + lineView.node.removeChild(lineView.gutterBackground); + lineView.gutterBackground = null; + } + if (lineView.line.gutterClass) { + var wrap = ensureLineWrapped(lineView); + lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass, + "left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + + "px; width: " + dims.gutterTotalWidth + "px"); + wrap.insertBefore(lineView.gutterBackground, lineView.text); + } var markers = lineView.line.gutterMarkers; if (cm.options.lineNumbers || markers) { var wrap = ensureLineWrapped(lineView); var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " + - (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + - "px; width: " + dims.gutterTotalWidth + "px"); + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"); cm.display.input.setUneditable(gutterWrap); wrap.insertBefore(gutterWrap, lineView.text); if (lineView.line.gutterClass) From 9332d055660824849dfdfab1788b52c2aa8ece80 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 13 Jul 2015 14:53:37 +0200 Subject: [PATCH 29/47] Fix test for gutter line classes --- test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.js b/test/test.js index f3e9da7645..0002be9b99 100644 --- a/test/test.js +++ b/test/test.js @@ -1583,7 +1583,7 @@ testCM("addLineClass", function(cm) { eq(byClassName(lines, "foo").length, 2); eq(byClassName(lines, "bar").length, 1); eq(byClassName(lines, "baz").length, 1); - eq(byClassName(lines, "gutter-class").length, 1); + eq(byClassName(lines, "gutter-class").length, 2); // Gutter classes are reflected in 2 nodes cm.removeLineClass(0, "text", "foo"); cls(0, "bar", null, null, null); cm.removeLineClass(0, "text", "foo"); From 4c4c0c6f2425056dfc894262515a21cc5a6dca65 Mon Sep 17 00:00:00 2001 From: belhaj Date: Sat, 11 Jul 2015 02:01:28 -0500 Subject: [PATCH 30/47] [.npmignore] Add --- .npmignore | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .npmignore diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000000..54322f9e2a --- /dev/null +++ b/.npmignore @@ -0,0 +1,9 @@ +/node_modules +/demo +/doc +/test +/index.html +/mode/*/*test.js +/mode/*/*.html +/mode/index.html +.* From bb3aac30b46c24004777f8f7a0014e559a764d51 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 14 Jul 2015 10:32:37 +0200 Subject: [PATCH 31/47] [search addon] Add some blank lines --- addon/search/search.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/addon/search/search.js b/addon/search/search.js index 761cb9492e..4bcfbe1be1 100644 --- a/addon/search/search.js +++ b/addon/search/search.js @@ -18,6 +18,7 @@ mod(CodeMirror); })(function(CodeMirror) { "use strict"; + function searchOverlay(query, caseInsensitive) { if (typeof query == "string") query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g"); @@ -42,16 +43,20 @@ this.posFrom = this.posTo = this.lastQuery = this.query = null; this.overlay = null; } + function getSearchState(cm) { return cm.state.search || (cm.state.search = new SearchState()); } + function queryCaseInsensitive(query) { return typeof query == "string" && query == query.toLowerCase(); } + function getSearchCursor(cm, query, pos) { // Heuristic: if the query string is all lowercase, do a case insensitive search. return cm.getSearchCursor(query, pos, queryCaseInsensitive(query)); } + function dialog(cm, text, shortText, deflt, f) { if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true}); else f(prompt(shortText, deflt)); @@ -60,6 +65,7 @@ if (cm.openConfirm) cm.openConfirm(text, fs); else if (confirm(shortText)) fs[0](); } + function parseQuery(query) { var isRE = query.match(/^\/(.*)\/([a-z]*)$/); if (isRE) { @@ -70,8 +76,10 @@ query = /x^/; return query; } + var queryDialog = 'Search: (Use /re/ syntax for regexp search)'; + function doSearch(cm, rev) { var state = getSearchState(cm); if (state.query) return findNext(cm, rev); @@ -92,6 +100,7 @@ }); }); } + function findNext(cm, rev) {cm.operation(function() { var state = getSearchState(cm); var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo); @@ -103,6 +112,7 @@ cm.scrollIntoView({from: cursor.from(), to: cursor.to()}); state.posFrom = cursor.from(); state.posTo = cursor.to(); });} + function clearSearch(cm) {cm.operation(function() { var state = getSearchState(cm); state.lastQuery = state.query; @@ -116,6 +126,7 @@ 'Replace: (Use /re/ syntax for regexp search)'; var replacementQueryDialog = 'With: '; var doReplaceConfirm = "Replace? "; + function replace(cm, all) { if (cm.getOption("readOnly")) return; var query = cm.getSelection() || getSearchState(cm).lastQuery; From 404e30823680c94203794a78aa0f91d31a9cdb41 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 14 Jul 2015 10:57:41 +0200 Subject: [PATCH 32/47] [search addon] Add persistent search command Issue #3337 Issue #3338 --- addon/search/search.js | 54 ++++++++++++++++++++++++++++++------------ demo/search.html | 6 +++-- 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/addon/search/search.js b/addon/search/search.js index 4bcfbe1be1..9f804b1512 100644 --- a/addon/search/search.js +++ b/addon/search/search.js @@ -57,10 +57,20 @@ return cm.getSearchCursor(query, pos, queryCaseInsensitive(query)); } + function persistentDialog(cm, text, deflt, f) { + cm.openDialog(text, f, { + value: deflt, + selectValueOnOpen: true, + closeOnEnter: false, + onClose: function() { clearSearch(cm); } + }); + } + function dialog(cm, text, shortText, deflt, f) { if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true}); else f(prompt(shortText, deflt)); } + function confirmDialog(cm, text, shortText, fs) { if (cm.openConfirm) cm.openConfirm(text, fs); else if (confirm(shortText)) fs[0](); @@ -80,25 +90,38 @@ var queryDialog = 'Search: (Use /re/ syntax for regexp search)'; - function doSearch(cm, rev) { + function startSearch(cm, state, query) { + state.queryText = query; + state.query = parseQuery(query); + cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query)); + state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query)); + cm.addOverlay(state.overlay); + if (cm.showMatchesOnScrollbar) { + if (state.annotate) { state.annotate.clear(); state.annotate = null; } + state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query)); + } + } + + function doSearch(cm, rev, persistent) { var state = getSearchState(cm); if (state.query) return findNext(cm, rev); var q = cm.getSelection() || state.lastQuery; - dialog(cm, queryDialog, "Search for:", q, function(query) { - cm.operation(function() { - if (!query || state.query) return; - state.query = parseQuery(query); - cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query)); - state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query)); - cm.addOverlay(state.overlay); - if (cm.showMatchesOnScrollbar) { - if (state.annotate) { state.annotate.clear(); state.annotate = null; } - state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query)); - } - state.posFrom = state.posTo = cm.getCursor(); - findNext(cm, rev); + if (persistent && cm.openDialog) { + persistentDialog(cm, queryDialog, q, function(query, event) { + CodeMirror.e_stop(event); + if (!query) return; + if (query != state.queryText) startSearch(cm, state, query); + findNext(cm, event.shiftKey); }); - }); + } else { + dialog(cm, queryDialog, "Search for:", q, function(query) { + if (query && !state.query) cm.operation(function() { + startSearch(cm, state, query); + state.posFrom = state.posTo = cm.getCursor(); + findNext(cm, rev); + }); + }); + } } function findNext(cm, rev) {cm.operation(function() { @@ -170,6 +193,7 @@ } CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);}; + CodeMirror.commands.findPersistent = function(cm) {clearSearch(cm); doSearch(cm, false, true);}; CodeMirror.commands.findNext = doSearch; CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);}; CodeMirror.commands.clearSearch = clearSearch; diff --git a/demo/search.html b/demo/search.html index 04ba7ac09a..21c34251e2 100644 --- a/demo/search.html +++ b/demo/search.html @@ -71,18 +71,20 @@

    Search/Replace Demo

    Demonstration of primitive search/replace functionality. The - keybindings (which can be overridden by custom keymaps) are:

    + keybindings (which can be configured with custom keymaps) are:

    Ctrl-F / Cmd-F
    Start searching
    Ctrl-G / Cmd-G
    Find next
    Shift-Ctrl-G / Shift-Cmd-G
    Find previous
    Shift-Ctrl-F / Cmd-Option-F
    Replace
    Shift-Ctrl-R / Shift-Cmd-Option-F
    Replace all
    +
    Alt-F
    Persistent search (dialog doesn't autoclose, enter to find next, shift-enter to find previous)

    Searching is enabled by including addon/search/search.js From bafd405ef0df3cf643cef35ad1fcb85cae2fedb2 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 14 Jul 2015 11:14:12 +0200 Subject: [PATCH 33/47] [markdown mode] Fix broken scanning for markdown=1 attribute --- mode/markdown/markdown.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index bef37b8ab6..bbc3dd8f99 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -447,11 +447,10 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { } if (ch === '<' && stream.match(/^\w/, false)) { - if (stream.string.indexOf(">") != -1) { - var atts = stream.string.substring(1,stream.string.indexOf(">")); - if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) { - state.md_inside = true; - } + var end = stream.string.indexOf(">", stream.pos); + if (end != -1) { + var atts = stream.string.substring(stream.start, end); + if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) state.md_inside = true; } stream.backUp(1); state.htmlState = CodeMirror.startState(htmlMode); From ff04f127ba8a736b97d06c505fb85d976e3f2980 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 14 Jul 2015 11:24:41 +0200 Subject: [PATCH 34/47] [markdown mode] Recognize HTML comments Closes #3384 --- mode/markdown/markdown.js | 5 +++-- mode/xml/xml.js | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index bbc3dd8f99..87c3ad30ad 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -202,7 +202,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { function htmlBlock(stream, state) { var style = htmlMode.token(stream, state.htmlState); - if ((htmlFound && state.htmlState.tagStart === null && !state.htmlState.context) || + if ((htmlFound && state.htmlState.tagStart === null && + (!state.htmlState.context && state.htmlState.tokenize.isInText)) || (state.md_inside && stream.current().indexOf(">") > -1)) { state.f = inlineNormal; state.block = blockNormal; @@ -446,7 +447,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { return type + linkemail; } - if (ch === '<' && stream.match(/^\w/, false)) { + if (ch === '<' && stream.match(/^(!--|\w)/, false)) { var end = stream.string.indexOf(">", stream.pos); if (end != -1) { var atts = stream.string.substring(stream.start, end); diff --git a/mode/xml/xml.js b/mode/xml/xml.js index 2f3b8f87a0..5ad21720fb 100644 --- a/mode/xml/xml.js +++ b/mode/xml/xml.js @@ -109,6 +109,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) { return null; } } + inText.isInText = true; function inTag(stream, state) { var ch = stream.next(); From 0c2264b44b085630113dc499eccaca5b544e5d77 Mon Sep 17 00:00:00 2001 From: M1cha Date: Tue, 14 Jul 2015 11:06:16 +0200 Subject: [PATCH 35/47] [squirrel mode] Add --- mode/clike/clike.js | 13 +++++++++++++ mode/clike/index.html | 3 ++- mode/index.html | 1 + mode/meta.js | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mode/clike/clike.js b/mode/clike/clike.js index f1a7e7a957..e13b79c14c 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -588,4 +588,17 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { modeProps: {fold: "brace"} }); + def("text/x-squirrel", { + name: "clike", + keywords: words("base break clone continue const default delete enum extends function in class" + + " foreach local resume return this throw typeof yield constructor instanceof static"), + types: words(cTypes), + blockKeywords: words("case catch class else for foreach if switch try while"), + defKeywords: words("function local class"), + typeFirstDefinitions: true, + atoms: words("true false null"), + hooks: {"#": cppHook}, + modeProps: {fold: ["brace", "include"]} + }); + }); diff --git a/mode/clike/index.html b/mode/clike/index.html index 8b386d22e0..226c6ce846 100644 --- a/mode/clike/index.html +++ b/mode/clike/index.html @@ -247,5 +247,6 @@

    Scala example

    (Java), text/x-csharp (C#), text/x-objectivec (Objective-C), text/x-scala (Scala), text/x-vertex - and x-shader/x-fragment (shader programs).

    + and x-shader/x-fragment (shader programs), + text/x-squirrel (Squirrel).

    diff --git a/mode/index.html b/mode/index.html index 7629561932..ca1703aff9 100644 --- a/mode/index.html +++ b/mode/index.html @@ -120,6 +120,7 @@

    Language modes

  • Stylus
  • SQL (several dialects)
  • SPARQL
  • +
  • Squirrel
  • Swift
  • sTeX, LaTeX
  • Tcl
  • diff --git a/mode/meta.js b/mode/meta.js index bf0929eba6..bc9f121d04 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -117,6 +117,7 @@ {name: "SPARQL", mime: "application/sparql-query", mode: "sparql", ext: ["rq", "sparql"], alias: ["sparul"]}, {name: "Spreadsheet", mime: "text/x-spreadsheet", mode: "spreadsheet", alias: ["excel", "formula"]}, {name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]}, + {name: "Squirrel", mime: "text/x-squirrel", mode: "clike", ext: ["nut"]}, {name: "Swift", mime: "text/x-swift", mode: "swift", ext: ["swift"]}, {name: "MariaDB", mime: "text/x-mariadb", mode: "sql"}, {name: "sTeX", mime: "text/x-stex", mode: "stex"}, From 01f2a1bedd4069c82afd273de27ba01e2609d9a8 Mon Sep 17 00:00:00 2001 From: Jeff Blaisdell Date: Tue, 14 Jul 2015 10:31:24 -0500 Subject: [PATCH 36/47] [search addon] Clear queryString on search reset, add scroll margin Issue #3337 --- addon/search/search.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/search/search.js b/addon/search/search.js index 9f804b1512..ed3c477550 100644 --- a/addon/search/search.js +++ b/addon/search/search.js @@ -132,7 +132,7 @@ if (!cursor.find(rev)) return; } cm.setSelection(cursor.from(), cursor.to()); - cm.scrollIntoView({from: cursor.from(), to: cursor.to()}); + cm.scrollIntoView({from: cursor.from(), to: cursor.to()}, 20); state.posFrom = cursor.from(); state.posTo = cursor.to(); });} @@ -140,7 +140,7 @@ var state = getSearchState(cm); state.lastQuery = state.query; if (!state.query) return; - state.query = null; + state.query = state.queryText = null; cm.removeOverlay(state.overlay); if (state.annotate) { state.annotate.clear(); state.annotate = null; } });} From 127850e7106ade846a3a3e528f52414c682a3113 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 15 Jul 2015 09:58:36 +0200 Subject: [PATCH 37/47] Force display update when measuring during operation redrew a line When something is redraw, we definitely need to do the consistency- ensuring that is done by a display update. Issue #3387 --- lib/codemirror.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index 36ce1913d9..8246529c6c 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -2555,10 +2555,12 @@ function prepareMeasureForLine(cm, line) { var lineN = lineNo(line); var view = findViewForLine(cm, lineN); - if (view && !view.text) + if (view && !view.text) { view = null; - else if (view && view.changes) + } else if (view && view.changes) { updateLineForChanges(cm, view, lineN, getDimensions(cm)); + cm.curOp.forceUpdate = true; + } if (!view) view = updateExternalMeasurement(cm, line); From 78c619e7117b6e13722cad322f918665664a2223 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 15 Jul 2015 10:39:39 +0200 Subject: [PATCH 38/47] [show-hint addon] Don't fire update event until async response comes back See http://discuss.codemirror.net/t/tern-webworker-causing-hint-flickering/300 --- addon/hint/show-hint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/hint/show-hint.js b/addon/hint/show-hint.js index fc85a10bb7..a14c652dd7 100644 --- a/addon/hint/show-hint.js +++ b/addon/hint/show-hint.js @@ -99,7 +99,6 @@ update: function(first) { if (this.tick == null) return; - if (this.data) CodeMirror.signal(this.data, "update"); if (!this.options.hint.async) { this.finishUpdate(this.options.hint(this.cm, this.options), first); } else { @@ -111,6 +110,7 @@ }, finishUpdate: function(data, first) { + if (this.data) CodeMirror.signal(this.data, "update"); if (data && this.data && CodeMirror.cmpPos(data.from, this.data.from)) data = null; this.data = data; From e7b3d6992c750cdebde3c607334a602c8467b0c0 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 16 Jul 2015 22:34:38 +0200 Subject: [PATCH 39/47] Add a code of conduct --- README.md | 27 +++++++++++++++++++++------ index.html | 5 ++++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 38156a7427..77824ebdbf 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,25 @@ [![NPM version](https://img.shields.io/npm/v/codemirror.svg)](https://www.npmjs.org/package/codemirror) [Funding status: ![maintainer happiness](https://marijnhaverbeke.nl/fund/status_s.png?again)](https://marijnhaverbeke.nl/fund/) -CodeMirror is a JavaScript component that provides a code editor in -the browser. When a mode is available for the language you are coding -in, it will color your code, and optionally help with indentation. +CodeMirror is a versatile text editor implemented in JavaScript for +the browser. It is specialized for editing code, and comes with over +100 language modes and various addons that implement more advanced +editing functionality. -The project page is http://codemirror.net -The manual is at http://codemirror.net/doc/manual.html -The contributing guidelines are in [CONTRIBUTING.md](https://github.com/codemirror/CodeMirror/blob/master/CONTRIBUTING.md) +A rich programming API and a CSS theming system are available for +customizing CodeMirror to fit your application, and extending it with +new functionality. + +You can find more information (and the +[manual](http://codemirror.net/doc/manual.html)) on the [project +page](http://codemirror.net). For questions and discussion, use the +[discussion forum](http://discuss.codemirror.net/). + +See +[CONTRIBUTING.md](https://github.com/codemirror/CodeMirror/blob/master/CONTRIBUTING.md) +for contributing guidelines. + +The CodeMirror community aims to be welcoming to everybody. We use the +[Contributor Covenant +(1.1)](http://contributor-covenant.org/version/1/1/0/) as our code of +conduct. diff --git a/index.html b/index.html index b769386c7e..ddb804a560 100644 --- a/index.html +++ b/index.html @@ -168,7 +168,10 @@

    Community

    list, which is only used for major announcements (such as new versions). If needed, you can contact the maintainer - directly.

    + directly. We aim to be an inclusive, welcoming community. To make + that explicit, we have + a code of + conduct that applies to communication around the project.

    A list of CodeMirror-related software that is not part of the main distribution is maintained From da42989b854fe9545f283602e5df8c30cae4e598 Mon Sep 17 00:00:00 2001 From: Rrandom Date: Thu, 16 Jul 2015 21:16:13 +0800 Subject: [PATCH 40/47] [rust mode] Update primitive types --- mode/rust/rust.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/rust/rust.js b/mode/rust/rust.js index 2bffa9a6aa..4970b2f7cb 100644 --- a/mode/rust/rust.js +++ b/mode/rust/rust.js @@ -26,7 +26,7 @@ CodeMirror.defineMode("rust", function() { }; var typeKeywords = function() { var keywords = {"fn": "fn", "block": "fn", "obj": "obj"}; - var atoms = "bool uint int i8 i16 i32 i64 u8 u16 u32 u64 float f32 f64 str char".split(" "); + var atoms = "bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 str char isize usize".split(" "); for (var i = 0, e = atoms.length; i < e; ++i) keywords[atoms[i]] = "atom"; return keywords; }(); From 76582eeb03ab5c1ddf953066bef922810f1001bb Mon Sep 17 00:00:00 2001 From: Sungho Kim Date: Fri, 17 Jul 2015 15:58:34 +0900 Subject: [PATCH 41/47] [textarea input] Don't disable poll() when input has selection during composing --- lib/codemirror.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index 8246529c6c..22082263b8 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -1398,7 +1398,7 @@ // will be the case when there is a lot of text in the textarea, // in which case reading its value would be expensive. if (this.contextMenuPending || !cm.state.focused || - (hasSelection(input) && !prevInput) || + (hasSelection(input) && !prevInput && !this.composing) || isReadOnly(cm) || cm.options.disableInput || cm.state.keySeq) return false; From 09e14b3dc85c1f7153a8749ba2520889fcec0a4b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 20 Jul 2015 08:11:59 +0200 Subject: [PATCH 42/47] [show-hint addon] Fix bad handling of non-word tokens in fromList hinter --- addon/hint/show-hint.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/addon/hint/show-hint.js b/addon/hint/show-hint.js index a14c652dd7..980da5235d 100644 --- a/addon/hint/show-hint.js +++ b/addon/hint/show-hint.js @@ -352,18 +352,20 @@ CodeMirror.registerHelper("hint", "fromList", function(cm, options) { var cur = cm.getCursor(), token = cm.getTokenAt(cur); + var to = CodeMirror.Pos(cur.line, token.end); + if (token.string && /\w/.test(token.string[token.string.length - 1])) { + var term = token.string, from = CodeMirror.Pos(cur.line, token.start); + } else { + var term = "", from = to; + } var found = []; for (var i = 0; i < options.words.length; i++) { var word = options.words[i]; - if (word.slice(0, token.string.length) == token.string) + if (word.slice(0, term.length) == term) found.push(word); } - if (found.length) return { - list: found, - from: CodeMirror.Pos(cur.line, token.start), - to: CodeMirror.Pos(cur.line, token.end) - }; + if (found.length) return {list: found, from: from, to: to}; }); CodeMirror.commands.autocomplete = CodeMirror.showHint; From a84b756b4c5f2b921f2e16fafc811805a8e82dd0 Mon Sep 17 00:00:00 2001 From: Vincent Woo Date: Mon, 20 Jul 2015 00:37:03 -0700 Subject: [PATCH 43/47] [vim] Make it easier to override color on blinking cursor --- lib/codemirror.css | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/codemirror.css b/lib/codemirror.css index 08eb6bbf29..318d25f02d 100644 --- a/lib/codemirror.css +++ b/lib/codemirror.css @@ -63,21 +63,22 @@ -webkit-animation: blink 1.06s steps(1) infinite; -moz-animation: blink 1.06s steps(1) infinite; animation: blink 1.06s steps(1) infinite; + background-color: #7e7; } @-moz-keyframes blink { - 0% { background: #7e7; } - 50% { background: none; } - 100% { background: #7e7; } + 0% {} + 50% { background-color: transparent; } + 100% {} } @-webkit-keyframes blink { - 0% { background: #7e7; } - 50% { background: none; } - 100% { background: #7e7; } + 0% {} + 50% { background-color: transparent; } + 100% {} } @keyframes blink { - 0% { background: #7e7; } - 50% { background: none; } - 100% { background: #7e7; } + 0% {} + 50% { background-color: transparent; } + 100% {} } /* Can style cursor different in overwrite (non-insert) mode */ From 83f2bad66d9a423a0ae19833696bf393a9cbf1fd Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 20 Jul 2015 09:59:12 +0200 Subject: [PATCH 44/47] Be more explicit about event timing for change and changes Issue #3387 --- doc/manual.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index 49faee7982..78b67731c1 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -510,13 +510,17 @@

    Events

    an array of strings representing the text that replaced the changed range (split by line). removed is the text that used to be between from and to, - which is overwritten by this change.
    + which is overwritten by this change. This event is + fired before the end of + an operation, before the DOM updates + happen.
    "changes" (instance: CodeMirror, changes: array<object>)
    Like the "change" event, but batched per operation, passing an array containing all the changes that happened in the - operation.
    + operation. This event is fired after the operation finished, and + display changes it makes will trigger a new operation.
    "beforeChange" (instance: CodeMirror, changeObj: object)
    This event is fired before a change is applied, and its From 04ea39c64af2de0ca5141202aebc730408df65bf Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 20 Jul 2015 11:16:44 +0200 Subject: [PATCH 45/47] Allow precise line separator to be specified through lineSeparator option Issue #3395 --- doc/manual.html | 10 ++++++ lib/codemirror.js | 87 +++++++++++++++++++++++++++++++++-------------- test/test.js | 15 ++++++++ 3 files changed, 86 insertions(+), 26 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index 78b67731c1..47afe3e748 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -236,6 +236,16 @@

    Configuration

    mode names to their constructors, and the second maps MIME types to mode specs.
    +
    lineSeparator: string|null
    +
    Explicitly set the line separator for the editor. By default + (value null), the document will be split on CRLFs + as well as lone CRs and LFs, and a single LF will be used as + line separator in all output (such + as getValue). When a + specific string is given, lines will only be split on that + string, and output will, by default, use that same + separator.
    +
    theme: string
    The theme to style the editor with. You must make sure the CSS file defining the corresponding .cm-s-[name] diff --git a/lib/codemirror.js b/lib/codemirror.js index 22082263b8..29892a51c7 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -65,7 +65,7 @@ setGuttersForLineNumbers(options); var doc = options.value; - if (typeof doc == "string") doc = new Doc(doc, options.mode); + if (typeof doc == "string") doc = new Doc(doc, options.mode, null, options.lineSeparator); this.doc = doc; var input = new CodeMirror.inputStyles[options.inputStyle](this); @@ -1092,13 +1092,18 @@ if (!sel) sel = doc.sel; var paste = cm.state.pasteIncoming || origin == "paste"; - var textLines = splitLines(inserted), multiPaste = null; + var textLines = doc.splitLines(inserted), multiPaste = null; // When pasing N lines into N selections, insert one line per selection if (paste && sel.ranges.length > 1) { - if (lastCopied && lastCopied.join("\n") == inserted) - multiPaste = sel.ranges.length % lastCopied.length == 0 && map(lastCopied, splitLines); - else if (textLines.length == sel.ranges.length) + if (lastCopied && lastCopied.join("\n") == inserted) { + if (sel.ranges.length % lastCopied.length == 0) { + multiPaste = []; + for (var i = 0; i < lastCopied.length; i++) + multiPaste.push(doc.splitLines(lastCopied[i])); + } + } else if (textLines.length == sel.ranges.length) { multiPaste = map(textLines, function(l) { return [l]; }); + } } // Normal behavior is to insert the new text into every selection @@ -1766,7 +1771,7 @@ var toNode = display.view[toIndex + 1].node.previousSibling; } - var newText = splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine)); + var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine)); var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length)); while (newText.length > 1 && oldText.length > 1) { if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; } @@ -1922,7 +1927,7 @@ } function domTextBetween(cm, from, to, fromLine, toLine) { - var text = "", closing = false; + var text = "", closing = false, lineSep = cm.doc.lineSep || "\n"; function recognizeMarker(id) { return function(marker) { return marker.id == id; }; } function walk(node) { if (node.nodeType == 1) { @@ -1936,7 +1941,7 @@ if (markerID) { var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID)); if (found.length && (range = found[0].find())) - text += getBetween(cm.doc, range.from, range.to).join("\n"); + text += getBetween(cm.doc, range.from, range.to).join(lineSep); return; } if (node.getAttribute("contenteditable") == "false") return; @@ -1948,7 +1953,7 @@ var val = node.nodeValue; if (!val) return; if (closing) { - text += "\n"; + text += lineSep; closing = false; } text += val; @@ -3797,7 +3802,9 @@ text[i] = reader.result; if (++read == n) { pos = clipPos(cm.doc, pos); - var change = {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"}; + var change = {from: pos, to: pos, + text: cm.doc.splitLines(text.join(cm.doc.lineSep || "\n")), + origin: "paste"}; makeChange(cm.doc, change); setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change))); } @@ -4480,7 +4487,7 @@ function replaceRange(doc, code, from, to, origin) { if (!to) to = from; if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; } - if (typeof code == "string") code = splitLines(code); + if (typeof code == "string") code = doc.splitLines(code); makeChange(doc, {from: from, to: to, text: code, origin: origin}); } @@ -5275,6 +5282,22 @@ clearCaches(cm); regChange(cm); }, true); + option("lineSeparator", null, function(cm, val) { + cm.doc.lineSep = val; + if (!val) return; + var newBreaks = [], lineNo = cm.doc.first; + cm.doc.iter(function(line) { + for (var pos = 0;;) { + var found = line.text.indexOf(val, pos); + if (found == -1) break; + pos = found + val.length; + newBreaks.push(Pos(lineNo, found)); + } + lineNo++; + }); + for (var i = newBreaks.length - 1; i >= 0; i--) + replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)) + }); option("specialChars", /[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, function(cm, val, old) { cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g"); if (old != CodeMirror.Init) cm.refresh(); @@ -5625,7 +5648,8 @@ } else if (cur.line > cm.doc.first) { var prev = getLine(cm.doc, cur.line - 1).text; if (prev) - cm.replaceRange(line.charAt(0) + "\n" + prev.charAt(prev.length - 1), + cm.replaceRange(line.charAt(0) + (cm.doc.lineSep || "\n") + + prev.charAt(prev.length - 1), Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose"); } } @@ -5639,7 +5663,7 @@ var len = cm.listSelections().length; for (var i = 0; i < len; i++) { var range = cm.listSelections()[i]; - cm.replaceRange("\n", range.anchor, range.head, "+input"); + cm.replaceRange(cm.doc.lineSep || "\n", range.anchor, range.head, "+input"); cm.indentLine(range.from().line + 1, null, true); ensureCursorVisible(cm); } @@ -6893,6 +6917,10 @@ txt.setAttribute("role", "presentation"); txt.setAttribute("cm-text", "\t"); builder.col += tabWidth; + } else if (m[0] == "\r" || m[0] == "\n") { + var txt = content.appendChild(elt("span", m[0] == "\r" ? "␍" : "␤", "cm-invalidchar")); + txt.setAttribute("cm-text", m[0]); + builder.col += 1; } else { var txt = builder.cm.options.specialCharPlaceholder(m[0]); txt.setAttribute("cm-text", m[0]); @@ -7238,8 +7266,8 @@ }; var nextDocId = 0; - var Doc = CodeMirror.Doc = function(text, mode, firstLine) { - if (!(this instanceof Doc)) return new Doc(text, mode, firstLine); + var Doc = CodeMirror.Doc = function(text, mode, firstLine, lineSep) { + if (!(this instanceof Doc)) return new Doc(text, mode, firstLine, lineSep); if (firstLine == null) firstLine = 0; BranchChunk.call(this, [new LeafChunk([new Line("", null)])]); @@ -7253,8 +7281,9 @@ this.history = new History(null); this.id = ++nextDocId; this.modeOption = mode; + this.lineSep = lineSep; - if (typeof text == "string") text = splitLines(text); + if (typeof text == "string") text = this.splitLines(text); updateDoc(this, {from: start, to: start, text: text}); setSelection(this, simpleSelection(start), sel_dontScroll); }; @@ -7284,12 +7313,12 @@ getValue: function(lineSep) { var lines = getLines(this, this.first, this.first + this.size); if (lineSep === false) return lines; - return lines.join(lineSep || "\n"); + return lines.join(lineSep || this.lineSep || "\n"); }, setValue: docMethodOp(function(code) { var top = Pos(this.first, 0), last = this.first + this.size - 1; makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length), - text: splitLines(code), origin: "setValue", full: true}, true); + text: this.splitLines(code), origin: "setValue", full: true}, true); setSelection(this, simpleSelection(top)); }), replaceRange: function(code, from, to, origin) { @@ -7300,7 +7329,7 @@ getRange: function(from, to, lineSep) { var lines = getBetween(this, clipPos(this, from), clipPos(this, to)); if (lineSep === false) return lines; - return lines.join(lineSep || "\n"); + return lines.join(lineSep || this.lineSep || "\n"); }, getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;}, @@ -7366,13 +7395,13 @@ lines = lines ? lines.concat(sel) : sel; } if (lineSep === false) return lines; - else return lines.join(lineSep || "\n"); + else return lines.join(lineSep || this.lineSep || "\n"); }, getSelections: function(lineSep) { var parts = [], ranges = this.sel.ranges; for (var i = 0; i < ranges.length; i++) { var sel = getBetween(this, ranges[i].from(), ranges[i].to()); - if (lineSep !== false) sel = sel.join(lineSep || "\n"); + if (lineSep !== false) sel = sel.join(lineSep || this.lineSep || "\n"); parts[i] = sel; } return parts; @@ -7387,7 +7416,7 @@ var changes = [], sel = this.sel; for (var i = 0; i < sel.ranges.length; i++) { var range = sel.ranges[i]; - changes[i] = {from: range.from(), to: range.to(), text: splitLines(code[i]), origin: origin}; + changes[i] = {from: range.from(), to: range.to(), text: this.splitLines(code[i]), origin: origin}; } var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse); for (var i = changes.length - 1; i >= 0; i--) @@ -7537,7 +7566,8 @@ }, copy: function(copyHistory) { - var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first); + var doc = new Doc(getLines(this, this.first, this.first + this.size), + this.modeOption, this.first, this.lineSep); doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft; doc.sel = this.sel; doc.extend = false; @@ -7553,7 +7583,7 @@ var from = this.first, to = this.first + this.size; if (options.from != null && options.from > from) from = options.from; if (options.to != null && options.to < to) to = options.to; - var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from); + var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep); if (options.sharedHist) copy.history = this.history; (this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist}); copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}]; @@ -7582,7 +7612,12 @@ iterLinkedDocs: function(f) {linkedDocs(this, f);}, getMode: function() {return this.mode;}, - getEditor: function() {return this.cm;} + getEditor: function() {return this.cm;}, + + splitLines: function(str) { + if (this.lineSep) return str.split(this.lineSep); + return splitLinesAuto(str); + } }); // Public alias. @@ -8388,7 +8423,7 @@ // See if "".split is the broken IE version, if so, provide an // alternative way to split lines. - var splitLines = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) { + var splitLinesAuto = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) { var pos = 0, result = [], l = string.length; while (pos <= l) { var nl = string.indexOf("\n", pos); diff --git a/test/test.js b/test/test.js index 0002be9b99..7bc2c8e95b 100644 --- a/test/test.js +++ b/test/test.js @@ -2125,3 +2125,18 @@ test("core_addClass", function() { CodeMirror.addClass(node, "b"); eq(node.className, "a b"); }); + +testCM("lineSeparator", function(cm) { + eq(cm.lineCount(), 3); + eq(cm.getLine(1), "bar\r"); + eq(cm.getLine(2), "baz\rquux"); + cm.setOption("lineSeparator", "\r"); + eq(cm.lineCount(), 5); + eq(cm.getLine(4), "quux"); + eq(cm.getValue(), "foo\rbar\r\rbaz\rquux"); + eq(cm.getValue("\n"), "foo\nbar\n\nbaz\nquux"); + cm.setOption("lineSeparator", null); + cm.setValue("foo\nbar\r\nbaz\rquux"); + eq(cm.lineCount(), 4); +}, {value: "foo\nbar\r\nbaz\rquux", + lineSeparator: "\n"}); From 0d9dbab4bcb3bcfef596e9ce475efff5507765bb Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 20 Jul 2015 11:21:22 +0200 Subject: [PATCH 46/47] Add lineSeparator method Issue #3395 --- doc/manual.html | 6 ++++++ lib/codemirror.js | 19 ++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index 47afe3e748..f10203359f 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -1997,6 +1997,12 @@

    Miscellaneous methods

    given an argument), or sets the overwrite mode to a specific state (when given an argument).
    +
    doc.lineSeparator()
    +
    Returns the preferred line separator string for this + document, as per the option + by the same name. When that option is null, the + string "\n" is returned.
    +
    cm.execCommand(name: string)
    Runs the command with the given name on the editor.
    diff --git a/lib/codemirror.js b/lib/codemirror.js index 29892a51c7..df0af5d2e3 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -1927,7 +1927,7 @@ } function domTextBetween(cm, from, to, fromLine, toLine) { - var text = "", closing = false, lineSep = cm.doc.lineSep || "\n"; + var text = "", closing = false, lineSep = cm.doc.lineSeparator(); function recognizeMarker(id) { return function(marker) { return marker.id == id; }; } function walk(node) { if (node.nodeType == 1) { @@ -3803,7 +3803,7 @@ if (++read == n) { pos = clipPos(cm.doc, pos); var change = {from: pos, to: pos, - text: cm.doc.splitLines(text.join(cm.doc.lineSep || "\n")), + text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())), origin: "paste"}; makeChange(cm.doc, change); setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change))); @@ -5648,7 +5648,7 @@ } else if (cur.line > cm.doc.first) { var prev = getLine(cm.doc, cur.line - 1).text; if (prev) - cm.replaceRange(line.charAt(0) + (cm.doc.lineSep || "\n") + + cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() + prev.charAt(prev.length - 1), Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose"); } @@ -5663,7 +5663,7 @@ var len = cm.listSelections().length; for (var i = 0; i < len; i++) { var range = cm.listSelections()[i]; - cm.replaceRange(cm.doc.lineSep || "\n", range.anchor, range.head, "+input"); + cm.replaceRange(cm.doc.lineSeparator(), range.anchor, range.head, "+input"); cm.indentLine(range.from().line + 1, null, true); ensureCursorVisible(cm); } @@ -7313,7 +7313,7 @@ getValue: function(lineSep) { var lines = getLines(this, this.first, this.first + this.size); if (lineSep === false) return lines; - return lines.join(lineSep || this.lineSep || "\n"); + return lines.join(lineSep || this.lineSeparator()); }, setValue: docMethodOp(function(code) { var top = Pos(this.first, 0), last = this.first + this.size - 1; @@ -7329,7 +7329,7 @@ getRange: function(from, to, lineSep) { var lines = getBetween(this, clipPos(this, from), clipPos(this, to)); if (lineSep === false) return lines; - return lines.join(lineSep || this.lineSep || "\n"); + return lines.join(lineSep || this.lineSeparator()); }, getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;}, @@ -7395,13 +7395,13 @@ lines = lines ? lines.concat(sel) : sel; } if (lineSep === false) return lines; - else return lines.join(lineSep || this.lineSep || "\n"); + else return lines.join(lineSep || this.lineSeparator()); }, getSelections: function(lineSep) { var parts = [], ranges = this.sel.ranges; for (var i = 0; i < ranges.length; i++) { var sel = getBetween(this, ranges[i].from(), ranges[i].to()); - if (lineSep !== false) sel = sel.join(lineSep || this.lineSep || "\n"); + if (lineSep !== false) sel = sel.join(lineSep || this.lineSeparator()); parts[i] = sel; } return parts; @@ -7617,7 +7617,8 @@ splitLines: function(str) { if (this.lineSep) return str.split(this.lineSep); return splitLinesAuto(str); - } + }, + lineSeparator: function() { return this.lineSep || "\n"; } }); // Public alias. From 8cc06af2c04cd16b11d2a2ccc4c8ef52d9d080d4 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 20 Jul 2015 12:56:59 +0200 Subject: [PATCH 47/47] Mark relese 5.5.0 --- AUTHORS | 8 ++++++++ doc/compress.html | 1 + doc/manual.html | 2 +- doc/releases.html | 39 ++++++++++++++++++++++++++------------- index.html | 2 +- lib/codemirror.js | 2 +- package.json | 2 +- 7 files changed, 39 insertions(+), 17 deletions(-) diff --git a/AUTHORS b/AUTHORS index 3299d4fd0c..c8e17d0778 100644 --- a/AUTHORS +++ b/AUTHORS @@ -59,6 +59,7 @@ AtomicPages LLC Atul Bhouraskar Aurelian Oancea Bastian Müller +belhaj Bem Jones-Bey benbro Beni Cherniavsky-Paskin @@ -215,6 +216,7 @@ Jason San Jose Jason Siefken Jaydeep Solanki Jean Boussier +Jeff Blaisdell jeffkenton Jeff Pickhardt jem (graphite) @@ -272,6 +274,7 @@ Lorenzo Stoakes Luciano Longo Luke Stagner lynschinzer +M1cha Madhura Jayaratne Maksim Lin Maksym Taran @@ -307,6 +310,7 @@ mauricio Maximilian Hils Maxim Kraev Max Kirsch +Max Schaefer Max Xiantu mbarkhau Metatheos @@ -327,6 +331,7 @@ Mike Kadin MinRK Miraculix87 misfo +mkaminsky11 mloginov Moritz Schwörer mps @@ -354,6 +359,7 @@ Nisarg Jhaveri nlwillia noragrossman Norman Rzepka +Oreoluwa Onatemowo pablo Page Panupong Pasupat @@ -387,6 +393,7 @@ Robert Crossfield Roberto Abdelkader Martínez Pérez robertop23 Robert Plummer +Rrandom Ruslan Osmanov Ryan Prior sabaca @@ -421,6 +428,7 @@ Stefan Borsje Steffen Beyer Steve O'Hara stoskov +Sungho Kim Taha Jahangir Takuji Shimokawa Tarmil diff --git a/doc/compress.html b/doc/compress.html index 98b0f674f0..f64f4bbfaf 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -36,6 +36,7 @@

    Script compression helper

    Version: