2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

codemirror: Added new module jump-to-line. Can be activated with new codemirrorParam 'jumpToLine:true'. Forum #54112

git-svn-id: https://svn.fhem.de/fhem/trunk@11593 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rapster 2016-06-01 21:45:13 +00:00
parent fa66175bbd
commit f10c2ed743
2 changed files with 6 additions and 0 deletions

View File

@ -16,6 +16,7 @@ var cm_attr = {
indentWithTabs: true,
autofocus: true,
lineNumbers: true,
jumpToLine: false,
smartIndent: false,
height: false,
extraKeys: {
@ -95,6 +96,9 @@ function AddCodeMirror(e, cb) {
if (cm_attr.autoRefresh) {
cm_active++; loadScript("codemirror/autorefresh.js", function(){cm_loaded++;} );
}
if (cm_attr.jumpToLine) {
cm_active++; loadScript("codemirror/jump-to-line.js", function(){cm_loaded++;} );
}
// editor user preferences
if (cm_attr.height) {

View File

@ -0,0 +1,2 @@
(function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../dialog/dialog"],e):e(CodeMirror)})(function(e){function g(a,d,b,c,e){a.openDialog?a.openDialog(d,e,{value:c,selectValueOnOpen:!0}):e(prompt(b,c))}function f(a,d){var b=Number(d);return/^[-+]/.test(d)?a.getCursor().line+b:b-1}e.commands.jumpToLine=function(a){var d=a.getCursor();g(a,'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>',
"Jump to line:",d.line+1+":"+d.ch,function(b){if(b){var c;(c=/^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(b))?a.setCursor(f(a,c[1]),Number(c[2])):(c=/^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(b))?(b=Math.round(a.lineCount()*Number(c[1])/100),/^[-+]/.test(c[1])&&(b=d.line+b+1),a.setCursor(b-1,d.ch)):(c=/^\s*\:?\s*([\+\-]?\d+)\s*/.exec(b))&&a.setCursor(f(a,c[1]),d.ch)}})};e.keyMap["default"]["Alt-G"]="jumpToLine"});