PluginProbe ʕ •ᴥ•ʔ
SiteOrigin CSS / trunk
SiteOrigin CSS vtrunk
1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.10 1.5.11 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0
so-css / lib / codemirror / addon / search / jump-to-line.js
so-css / lib / codemirror / addon / search Last commit date
jump-to-line.js 6 years ago jump-to-line.min.js 6 years ago match-highlighter.js 6 years ago match-highlighter.min.js 6 years ago matchesonscrollbar.css 6 years ago matchesonscrollbar.js 6 years ago matchesonscrollbar.min.js 6 years ago search.js 6 years ago search.min.js 6 years ago searchcursor.js 6 years ago searchcursor.min.js 6 years ago
jump-to-line.js
50 lines
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
3
4 // Defines jumpToLine command. Uses dialog.js if present.
5
6 (function(mod) {
7 if (typeof exports == "object" && typeof module == "object") // CommonJS
8 mod(require("../../lib/codemirror"), require("../dialog/dialog"));
9 else if (typeof define == "function" && define.amd) // AMD
10 define(["../../lib/codemirror", "../dialog/dialog"], mod);
11 else // Plain browser env
12 mod(CodeMirror);
13 })(function(CodeMirror) {
14 "use strict";
15
16 function dialog(cm, text, shortText, deflt, f) {
17 if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
18 else f(prompt(shortText, deflt));
19 }
20
21 var jumpDialog =
22 'Jump to line: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use line:column or scroll% syntax)</span>';
23
24 function interpretLine(cm, string) {
25 var num = Number(string)
26 if (/^[-+]/.test(string)) return cm.getCursor().line + num
27 else return num - 1
28 }
29
30 CodeMirror.commands.jumpToLine = function(cm) {
31 var cur = cm.getCursor();
32 dialog(cm, jumpDialog, "Jump to line:", (cur.line + 1) + ":" + cur.ch, function(posStr) {
33 if (!posStr) return;
34
35 var match;
36 if (match = /^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(posStr)) {
37 cm.setCursor(interpretLine(cm, match[1]), Number(match[2]))
38 } else if (match = /^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(posStr)) {
39 var line = Math.round(cm.lineCount() * Number(match[1]) / 100);
40 if (/^[-+]/.test(match[1])) line = cur.line + line + 1;
41 cm.setCursor(line - 1, cur.ch);
42 } else if (match = /^\s*\:?\s*([\+\-]?\d+)\s*/.exec(posStr)) {
43 cm.setCursor(interpretLine(cm, match[1]), cur.ch);
44 }
45 });
46 };
47
48 CodeMirror.keyMap["default"]["Alt-G"] = "jumpToLine";
49 });
50