mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-10-30 14:46:19 +00:00
769ffa19b7
* Update codemirror.js to 5.58.2 * Update codemirror.css to 5.58.2 * Update activeline.js to 5.58.2 * Update dialog.js to 5.58.2 * Update jump-to-line.js to 5.58.2 * Update search.js to 5.58.2 * Update searchcursor.js to 5.58.2 * Update xml.js to 5.58.2 * Update show-hint.js to 5.58.2 * Update show-hint.css to 5.58.2 * Update javascript-hint.js to 5.58.2 * Update xml-hint.js to 5.58.2 * Update html-hint.js to 5.58.2 * Update css-hint.js to 5.58.2 * Update anyword-hint.js to 5.58.2 * Update closebrackets.js to 5.58.2 * Update matchbrackets.js to 5.58.2 * Update closetag.js to 5.58.2 * Update xml-fold.js to 5.58.2 * Update fullscreen.js to 5.58.2 * Update emacs.js to 5.58.2 * Update sublime.js to 5.58.2 * Update comment.js to 5.58.2 * Update vim.js to 5.58.2 * Update css.js to 5.58.2 * Update multiplex.js to 5.58.2 * Update htmlembedded.js to 5.58.2 * Update htmlmixed.js to 5.58.2 * Update javascript.js to 5.58.2 * Update markdown.js to 5.58.2 * Update markdown.js * Update readme.tid * Update markdown.js
4 lines
15 KiB
JavaScript
Executable File
4 lines
15 KiB
JavaScript
Executable File
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
|
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../lib/codemirror"),require("../addon/search/searchcursor"),require("../addon/edit/matchbrackets")):"function"==typeof define&&define.amd?define(["../lib/codemirror","../addon/search/searchcursor","../addon/edit/matchbrackets"],e):e(CodeMirror)}(function(u){"use strict";var r=u.commands,d=u.Pos;function t(t,n){t.extendSelectionsBy(function(e){return t.display.shift||t.doc.extend||e.empty()?function(e,t,n){if(n<0&&0==t.ch)return e.clipPos(d(t.line-1));var r=e.getLine(t.line);if(0<n&&t.ch>=r.length)return e.clipPos(d(t.line+1,0));for(var o,i="start",l=t.ch,a=l,s=n<0?0:r.length;a!=s;a+=n,0){var c=r.charAt(n<0?a-1:a),f="_"!=c&&u.isWordChar(c)?"w":"o";if("w"==f&&c.toUpperCase()==c&&(f="W"),"start"==i)"o"!=f?(i="in",o=f):l=a+n;else if("in"==i&&o!=f){if("w"==o&&"W"==f&&n<0&&a--,"W"==o&&"w"==f&&0<n){if(a==l+1){o="w";continue}a--}break}}return d(t.line,a)}(t.doc,e.head,n):n<0?e.from():e.to()})}function n(l,a){if(l.isReadOnly())return u.Pass;l.operation(function(){for(var e=l.listSelections().length,t=[],n=-1,r=0;r<e;r++){var o,i=l.listSelections()[r].head;i.line<=n||(o=d(i.line+(a?0:1),0),l.replaceRange("\n",o,null,"+insertLine"),l.indentLine(o.line,null,!0),t.push({head:o,anchor:o}),n=i.line+1)}l.setSelections(t)}),l.execCommand("indentAuto")}function c(e,t){for(var n=t.ch,r=n,o=e.getLine(t.line);n&&u.isWordChar(o.charAt(n-1));)--n;for(;r<o.length&&u.isWordChar(o.charAt(r));)++r;return{from:d(t.line,n),to:d(t.line,r),word:o.slice(n,r)}}function o(e,t){for(var n=e.listSelections(),r=[],o=0;o<n.length;o++){var i=n[o],l=e.findPosV(i.anchor,t,"line",i.anchor.goalColumn),a=e.findPosV(i.head,t,"line",i.head.goalColumn);l.goalColumn=null!=i.anchor.goalColumn?i.anchor.goalColumn:e.cursorCoords(i.anchor,"div").left,a.goalColumn=null!=i.head.goalColumn?i.head.goalColumn:e.cursorCoords(i.head,"div").left;var s={anchor:l,head:a};r.push(i),r.push(s)}e.setSelections(r)}r.goSubwordLeft=function(e){t(e,-1)},r.goSubwordRight=function(e){t(e,1)},r.scrollLineUp=function(e){var t,n=e.getScrollInfo();e.somethingSelected()||(t=e.lineAtHeight(n.top+n.clientHeight,"local"),e.getCursor().line>=t&&e.execCommand("goLineUp")),e.scrollTo(null,n.top-e.defaultTextHeight())},r.scrollLineDown=function(e){var t,n=e.getScrollInfo();e.somethingSelected()||(t=e.lineAtHeight(n.top,"local")+1,e.getCursor().line<=t&&e.execCommand("goLineDown")),e.scrollTo(null,n.top+e.defaultTextHeight())},r.splitSelectionByLine=function(e){for(var t=e.listSelections(),n=[],r=0;r<t.length;r++)for(var o=t[r].from(),i=t[r].to(),l=o.line;l<=i.line;++l)i.line>o.line&&l==i.line&&0==i.ch||n.push({anchor:l==o.line?o:d(l,0),head:l==i.line?i:d(l)});e.setSelections(n,0)},r.singleSelectionTop=function(e){var t=e.listSelections()[0];e.setSelection(t.anchor,t.head,{scroll:!1})},r.selectLine=function(e){for(var t=e.listSelections(),n=[],r=0;r<t.length;r++){var o=t[r];n.push({anchor:d(o.from().line,0),head:d(o.to().line+1,0)})}e.setSelections(n)},r.insertLineAfter=function(e){return n(e,!1)},r.insertLineBefore=function(e){return n(e,!0)},r.selectNextOccurrence=function(e){var t=e.getCursor("from"),n=e.getCursor("to"),r=e.state.sublimeFindFullWord==e.doc.sel;if(0==u.cmpPos(t,n)){var o=c(e,t);if(!o.word)return;e.setSelection(o.from,o.to),r=!0}else{var i=e.getRange(t,n),l=r?new RegExp("\\b"+i+"\\b"):i,a=e.getSearchCursor(l,n);if(!(a.findNext()||(a=e.getSearchCursor(l,d(e.firstLine(),0))).findNext())||function(e,t,n){for(var r=0;r<e.length;r++)if(0==u.cmpPos(e[r].from(),t)&&0==u.cmpPos(e[r].to(),n))return!0;return!1}(e.listSelections(),a.from(),a.to()))return;e.addSelection(a.from(),a.to())}r&&(e.state.sublimeFindFullWord=e.doc.sel)},r.skipAndSelectNextOccurrence=function(e){var t=e.getCursor("anchor"),n=e.getCursor("head");r.selectNextOccurrence(e),0!=u.cmpPos(t,n)&&e.doc.setSelections(e.doc.listSelections().filter(function(e){return e.anchor!=t||e.head!=n}))},r.addCursorToPrevLine=function(e){o(e,-1)},r.addCursorToNextLine=function(e){o(e,1)};var f="(){}[]";function i(e){for(var t=e.listSelections(),n=[],r=0;r<t.length;r++){var o=t[r],i=o.head,l=e.scanForBracket(i,-1);if(!l)return;for(;;){var a=e.scanForBracket(i,1);if(!a)return;if(a.ch==f.charAt(f.indexOf(l.ch)+1)){var s=d(l.pos.line,l.pos.ch+1);if(0!=u.cmpPos(s,o.from())||0!=u.cmpPos(a.pos,o.to())){n.push({anchor:s,head:a.pos});break}if(!(l=e.scanForBracket(l.pos,-1)))return}i=d(a.pos.line,a.pos.ch+1)}}return e.setSelections(n),1}function l(e){return e?/\bpunctuation\b/.test(e)?e:void 0:null}function a(a,s){if(a.isReadOnly())return u.Pass;for(var c,e=a.listSelections(),f=[],t=0;t<e.length;t++){var n=e[t];if(!n.empty()){for(var r=n.from().line,o=n.to().line;t<e.length-1&&e[t+1].from().line==o;)o=e[++t].to().line;e[t].to().ch||o--,f.push(r,o)}}f.length?c=!0:f.push(a.firstLine(),a.lastLine()),a.operation(function(){for(var e=[],t=0;t<f.length;t+=2){var n=f[t],r=f[t+1],o=d(n,0),i=d(r),l=a.getRange(o,i,!1);s?l.sort():l.sort(function(e,t){var n=e.toUpperCase(),r=t.toUpperCase();return n!=r&&(e=n,t=r),e<t?-1:e==t?0:1}),a.replaceRange(l,o,i),c&&e.push({anchor:o,head:d(r+1,0)})}c&&a.setSelections(e,0)})}function s(a,s){a.operation(function(){for(var e=a.listSelections(),t=[],n=[],r=0;r<e.length;r++){(l=e[r]).empty()?(t.push(r),n.push("")):n.push(s(a.getRange(l.from(),l.to())))}a.replaceSelections(n,"around","case");for(r=t.length-1;0<=r;r--){var o,i,l=e[t[r]];i&&0<u.cmpPos(l.head,i)||(i=(o=c(a,l.head)).from,a.replaceRange(s(o.word),o.from,o.to))}})}function m(e){var t=e.getCursor("from"),n=e.getCursor("to");if(0==u.cmpPos(t,n)){var r=c(e,t);if(!r.word)return;t=r.from,n=r.to}return{from:t,to:n,query:e.getRange(t,n),word:r}}function h(e,t){var n,r,o=m(e);o&&(n=o.query,r=e.getSearchCursor(n,t?o.to:o.from),(t?r.findNext():r.findPrevious())?e.setSelection(r.from(),r.to()):(r=e.getSearchCursor(n,t?d(e.firstLine(),0):e.clipPos(d(e.lastLine()))),(t?r.findNext():r.findPrevious())?e.setSelection(r.from(),r.to()):o.word&&e.setSelection(o.from,o.to)))}r.selectScope=function(e){i(e)||e.execCommand("selectAll")},r.selectBetweenBrackets=function(e){if(!i(e))return u.Pass},r.goToBracket=function(r){r.extendSelectionsBy(function(e){var t=r.scanForBracket(e.head,1,l(r.getTokenTypeAt(e.head)));if(t&&0!=u.cmpPos(t.pos,e.head))return t.pos;var n=r.scanForBracket(e.head,-1,l(r.getTokenTypeAt(d(e.head.line,e.head.ch+1))));return n&&d(n.pos.line,n.pos.ch+1)||e.head})},r.swapLineUp=function(o){if(o.isReadOnly())return u.Pass;for(var e=o.listSelections(),i=[],t=o.firstLine()-1,l=[],n=0;n<e.length;n++){var r=e[n],a=r.from().line-1,s=r.to().line;l.push({anchor:d(r.anchor.line-1,r.anchor.ch),head:d(r.head.line-1,r.head.ch)}),0!=r.to().ch||r.empty()||--s,t<a?i.push(a,s):i.length&&(i[i.length-1]=s),t=s}o.operation(function(){for(var e=0;e<i.length;e+=2){var t=i[e],n=i[e+1],r=o.getLine(t);o.replaceRange("",d(t,0),d(t+1,0),"+swapLine"),n>o.lastLine()?o.replaceRange("\n"+r,d(o.lastLine()),null,"+swapLine"):o.replaceRange(r+"\n",d(n,0),null,"+swapLine")}o.setSelections(l),o.scrollIntoView()})},r.swapLineDown=function(o){if(o.isReadOnly())return u.Pass;for(var e=o.listSelections(),i=[],t=o.lastLine()+1,n=e.length-1;0<=n;n--){var r=e[n],l=r.to().line+1,a=r.from().line;0!=r.to().ch||r.empty()||l--,l<t?i.push(l,a):i.length&&(i[i.length-1]=a),t=a}o.operation(function(){for(var e=i.length-2;0<=e;e-=2){var t=i[e],n=i[e+1],r=o.getLine(t);t==o.lastLine()?o.replaceRange("",d(t-1),d(t),"+swapLine"):o.replaceRange("",d(t,0),d(t+1,0),"+swapLine"),o.replaceRange(r+"\n",d(n,0),null,"+swapLine")}o.scrollIntoView()})},r.toggleCommentIndented=function(e){e.toggleComment({indent:!0})},r.joinLines=function(s){for(var e=s.listSelections(),c=[],t=0;t<e.length;t++){for(var n=e[t],r=n.from(),o=r.line,i=n.to().line;t<e.length-1&&e[t+1].from().line==i;)i=e[++t].to().line;c.push({start:o,end:i,anchor:!n.empty()&&r})}s.operation(function(){for(var e=0,t=[],n=0;n<c.length;n++){for(var r,o=c[n],i=o.anchor&&d(o.anchor.line-e,o.anchor.ch),l=o.start;l<=o.end;l++){var a=l-e;l==o.end&&(r=d(a,s.getLine(a).length+1)),a<s.lastLine()&&(s.replaceRange(" ",d(a),d(1+a,/^\s*/.exec(s.getLine(1+a))[0].length)),++e)}t.push({anchor:i||r,head:r})}s.setSelections(t,0)})},r.duplicateLine=function(r){r.operation(function(){for(var e=r.listSelections().length,t=0;t<e;t++){var n=r.listSelections()[t];n.empty()?r.replaceRange(r.getLine(n.head.line)+"\n",d(n.head.line,0)):r.replaceRange(r.getRange(n.from(),n.to()),n.from())}r.scrollIntoView()})},r.sortLines=function(e){a(e,!0)},r.sortLinesInsensitive=function(e){a(e,!1)},r.nextBookmark=function(e){var t=e.state.sublimeBookmarks;if(t)for(;t.length;){var n=t.shift(),r=n.find();if(r)return t.push(n),e.setSelection(r.from,r.to)}},r.prevBookmark=function(e){var t=e.state.sublimeBookmarks;if(t)for(;t.length;){t.unshift(t.pop());var n=t[t.length-1].find();if(n)return e.setSelection(n.from,n.to);t.pop()}},r.toggleBookmark=function(e){for(var t=e.listSelections(),n=e.state.sublimeBookmarks||(e.state.sublimeBookmarks=[]),r=0;r<t.length;r++){for(var o=t[r].from(),i=t[r].to(),l=t[r].empty()?e.findMarksAt(o):e.findMarks(o,i),a=0;a<l.length;a++)if(l[a].sublimeBookmark){l[a].clear();for(var s=0;s<n.length;s++)n[s]==l[a]&&n.splice(s--,1);break}a==l.length&&n.push(e.markText(o,i,{sublimeBookmark:!0,clearWhenEmpty:!1}))}},r.clearBookmarks=function(e){var t=e.state.sublimeBookmarks;if(t)for(var n=0;n<t.length;n++)t[n].clear();t.length=0},r.selectBookmarks=function(e){var t=e.state.sublimeBookmarks,n=[];if(t)for(var r=0;r<t.length;r++){var o=t[r].find();o?n.push({anchor:o.from,head:o.to}):t.splice(r--,0)}n.length&&e.setSelections(n,0)},r.smartBackspace=function(s){if(s.somethingSelected())return u.Pass;s.operation(function(){for(var e=s.listSelections(),t=s.getOption("indentUnit"),n=e.length-1;0<=n;n--){var r,o=e[n].head,i=s.getRange({line:o.line,ch:0},o),l=u.countColumn(i,null,s.getOption("tabSize")),a=s.findPosH(o,-1,"char",!1);!i||/\S/.test(i)||l%t!=0||(r=new d(o.line,u.findColumn(i,l-t,t))).ch!=o.ch&&(a=r),s.replaceRange("",a,o,"+delete")}})},r.delLineRight=function(n){n.operation(function(){for(var e=n.listSelections(),t=e.length-1;0<=t;t--)n.replaceRange("",e[t].anchor,d(e[t].to().line),"+delete");n.scrollIntoView()})},r.upcaseAtCursor=function(e){s(e,function(e){return e.toUpperCase()})},r.downcaseAtCursor=function(e){s(e,function(e){return e.toLowerCase()})},r.setSublimeMark=function(e){e.state.sublimeMark&&e.state.sublimeMark.clear(),e.state.sublimeMark=e.setBookmark(e.getCursor())},r.selectToSublimeMark=function(e){var t=e.state.sublimeMark&&e.state.sublimeMark.find();t&&e.setSelection(e.getCursor(),t)},r.deleteToSublimeMark=function(e){var t,n,r,o=e.state.sublimeMark&&e.state.sublimeMark.find();o&&(r=e.getCursor(),n=o,0<u.cmpPos(r,n)&&(t=n,n=r,r=t),e.state.sublimeKilled=e.getRange(r,n),e.replaceRange("",r,n))},r.swapWithSublimeMark=function(e){var t=e.state.sublimeMark&&e.state.sublimeMark.find();t&&(e.state.sublimeMark.clear(),e.state.sublimeMark=e.setBookmark(e.getCursor()),e.setCursor(t))},r.sublimeYank=function(e){null!=e.state.sublimeKilled&&e.replaceSelection(e.state.sublimeKilled,null,"paste")},r.showInCenter=function(e){var t=e.cursorCoords(null,"local");e.scrollTo(null,(t.top+t.bottom)/2-e.getScrollInfo().clientHeight/2)},r.findUnder=function(e){h(e,!0)},r.findUnderPrevious=function(e){h(e,!1)},r.findAllUnder=function(e){var t=m(e);if(t){for(var n=e.getSearchCursor(t.query),r=[],o=-1;n.findNext();)r.push({anchor:n.from(),head:n.to()}),n.from().line<=t.from.line&&n.from().ch<=t.from.ch&&o++;e.setSelections(r,o)}};var e=u.keyMap;e.macSublime={"Cmd-Left":"goLineStartSmart","Shift-Tab":"indentLess","Shift-Ctrl-K":"deleteLine","Alt-Q":"wrapLines","Ctrl-Left":"goSubwordLeft","Ctrl-Right":"goSubwordRight","Ctrl-Alt-Up":"scrollLineUp","Ctrl-Alt-Down":"scrollLineDown","Cmd-L":"selectLine","Shift-Cmd-L":"splitSelectionByLine",Esc:"singleSelectionTop","Cmd-Enter":"insertLineAfter","Shift-Cmd-Enter":"insertLineBefore","Cmd-D":"selectNextOccurrence","Shift-Cmd-Space":"selectScope","Shift-Cmd-M":"selectBetweenBrackets","Cmd-M":"goToBracket","Cmd-Ctrl-Up":"swapLineUp","Cmd-Ctrl-Down":"swapLineDown","Cmd-/":"toggleCommentIndented","Cmd-J":"joinLines","Shift-Cmd-D":"duplicateLine",F5:"sortLines","Cmd-F5":"sortLinesInsensitive",F2:"nextBookmark","Shift-F2":"prevBookmark","Cmd-F2":"toggleBookmark","Shift-Cmd-F2":"clearBookmarks","Alt-F2":"selectBookmarks",Backspace:"smartBackspace","Cmd-K Cmd-D":"skipAndSelectNextOccurrence","Cmd-K Cmd-K":"delLineRight","Cmd-K Cmd-U":"upcaseAtCursor","Cmd-K Cmd-L":"downcaseAtCursor","Cmd-K Cmd-Space":"setSublimeMark","Cmd-K Cmd-A":"selectToSublimeMark","Cmd-K Cmd-W":"deleteToSublimeMark","Cmd-K Cmd-X":"swapWithSublimeMark","Cmd-K Cmd-Y":"sublimeYank","Cmd-K Cmd-C":"showInCenter","Cmd-K Cmd-G":"clearBookmarks","Cmd-K Cmd-Backspace":"delLineLeft","Cmd-K Cmd-1":"foldAll","Cmd-K Cmd-0":"unfoldAll","Cmd-K Cmd-J":"unfoldAll","Ctrl-Shift-Up":"addCursorToPrevLine","Ctrl-Shift-Down":"addCursorToNextLine","Cmd-F3":"findUnder","Shift-Cmd-F3":"findUnderPrevious","Alt-F3":"findAllUnder","Shift-Cmd-[":"fold","Shift-Cmd-]":"unfold","Cmd-I":"findIncremental","Shift-Cmd-I":"findIncrementalReverse","Cmd-H":"replace",F3:"findNext","Shift-F3":"findPrev",fallthrough:"macDefault"},u.normalizeKeyMap(e.macSublime),e.pcSublime={"Shift-Tab":"indentLess","Shift-Ctrl-K":"deleteLine","Alt-Q":"wrapLines","Ctrl-T":"transposeChars","Alt-Left":"goSubwordLeft","Alt-Right":"goSubwordRight","Ctrl-Up":"scrollLineUp","Ctrl-Down":"scrollLineDown","Ctrl-L":"selectLine","Shift-Ctrl-L":"splitSelectionByLine",Esc:"singleSelectionTop","Ctrl-Enter":"insertLineAfter","Shift-Ctrl-Enter":"insertLineBefore","Ctrl-D":"selectNextOccurrence","Shift-Ctrl-Space":"selectScope","Shift-Ctrl-M":"selectBetweenBrackets","Ctrl-M":"goToBracket","Shift-Ctrl-Up":"swapLineUp","Shift-Ctrl-Down":"swapLineDown","Ctrl-/":"toggleCommentIndented","Ctrl-J":"joinLines","Shift-Ctrl-D":"duplicateLine",F9:"sortLines","Ctrl-F9":"sortLinesInsensitive",F2:"nextBookmark","Shift-F2":"prevBookmark","Ctrl-F2":"toggleBookmark","Shift-Ctrl-F2":"clearBookmarks","Alt-F2":"selectBookmarks",Backspace:"smartBackspace","Ctrl-K Ctrl-D":"skipAndSelectNextOccurrence","Ctrl-K Ctrl-K":"delLineRight","Ctrl-K Ctrl-U":"upcaseAtCursor","Ctrl-K Ctrl-L":"downcaseAtCursor","Ctrl-K Ctrl-Space":"setSublimeMark","Ctrl-K Ctrl-A":"selectToSublimeMark","Ctrl-K Ctrl-W":"deleteToSublimeMark","Ctrl-K Ctrl-X":"swapWithSublimeMark","Ctrl-K Ctrl-Y":"sublimeYank","Ctrl-K Ctrl-C":"showInCenter","Ctrl-K Ctrl-G":"clearBookmarks","Ctrl-K Ctrl-Backspace":"delLineLeft","Ctrl-K Ctrl-1":"foldAll","Ctrl-K Ctrl-0":"unfoldAll","Ctrl-K Ctrl-J":"unfoldAll","Ctrl-Alt-Up":"addCursorToPrevLine","Ctrl-Alt-Down":"addCursorToNextLine","Ctrl-F3":"findUnder","Shift-Ctrl-F3":"findUnderPrevious","Alt-F3":"findAllUnder","Shift-Ctrl-[":"fold","Shift-Ctrl-]":"unfold","Ctrl-I":"findIncremental","Shift-Ctrl-I":"findIncrementalReverse","Ctrl-H":"replace",F3:"findNext","Shift-F3":"findPrev",fallthrough:"pcDefault"},u.normalizeKeyMap(e.pcSublime);var C=e.default==e.macDefault;e.sublime=C?e.macSublime:e.pcSublime});
|