1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-29 21:09:56 +00:00
TiddlyWiki5/plugins/tiddlywiki/codemirror-keymap-sublime-text/files/keymap/sublime.js

4 lines
15 KiB
JavaScript
Raw Normal View History

CodeMirror 5.36.0 modularized (#3184) * v5.35.1 * codemirror 5.35.1 * v5.35.1 * v5.35.1 * v5.35.1 * v5.35.1 * v5.35.1 * adding search&replace and autocomplete * update version number * add jump-to-line.js required for search&replace * adding show-hint.js required by autocomplete * adding basic autocomplete for any word * adding autocomplete css * adding new files to tiddlywiki.files * forgot adding search.js * minify 'em all * Delete vim.js * Delete sublime.js * Delete emacs.js * Delete anyword-hint.js * Delete show-hint.css * Delete show-hint.js * Update config.tid * Update tiddlywiki.files * Update tiddlywiki.files * Update config.tid * Update config.tid * Update config.tid * Delete dialog.js * Delete dialog.css * Delete jump-to-line.js * Delete search.js * Delete searchcursor.js * Update tiddlywiki.files * Update tiddlywiki.files * Update tiddlywiki.files * add search-and-replace cm-addon as plugin * add autocomplete cm-addon as plugin * add fullscreen-editing cm-addon as plugin * add keymaps as plugins + cleanup * add highlighting modes as plugins * small update on usage.tid * moved multiplex.js to htmlembedded mode - the only one using it * config/CodeMirror update * how to disable line numbers * how to change CM theme * add closebrackets and closetags addons * packaging a base-addon * move meta.js from codemirror to base addon * inputStyle: textarea -> prevents contenteditable on mobile browsers, keeps focus when clicking toolbar buttons, prevents import on paste * default config no line numbers * temporary add panel plugin for demo * put base-plugin back to codemirror editor * searchcursor to searchnreplace plugin * bad copypasta mistake * another typo * stripped down meta.js + moved matchbrackets to closebrackets plugin * remove panel * change module-type to codemirro and make init "require" dynamic. * make config handling dynamic with sensible defaults * make cm settings translateable * delete multids. they will be replaced * add auto-config tiddlers * dynamically create config structure for CM * fix filename * change typo * kitchensink config, plus change plugin description for better sorting. * add matchBrackets config tiddler * RIP codeblock * removed install instructions from readme - codemirror usage tiddler still todo * control panel settings for cm base * add setting for auto-close tags * adding fontfamily settings and theme settings * change tags for settings from $:/tags/ControlPanel/Settings to $:/tags/ControlPanel/Settings/CodeMirror * more usage info * more usage info * update to v5.36.0 * ugly hack enables highlighting and tag-closing for vnd.tiddlywiki and x-tiddlywiki * disable auto-indent for vnd.tiddlywiki & x-tiddlywiki and add some hidden settings * remove engine.js hack * meta.js -> tw-meta.js * codemirror settings tab * rename tiddler to tw-meta.js * make editor font monospace or sans-serif - dropdown select * make editor font monospace or sans-serif - dropdown select * now using correct tiddler for editor font setting * better usage doc * make markdown-mode require tw-meta * add more themes info * add active-line highlighting option * mini usage change * add integer type to engine.js config-getter * blink rate config type string * correct engine.js * license for base-plugin, usage link in settings tab * codemirrordemo hellothere update * codemirrordemo hellothere update * Update license.tid * codemirror demo sidebarlayout, license * license headers to addon files * license formatting & forgot what year we have * license formatting & forgot what year we have & codemirror demo sitetitle sitesubtitle * more informations 'try-this-style' for codemirrordemo hellothere * codemirror demo sitetitle & cm fontfamily * hellothere * font-family setting must be editor-font-family, not code-font-family * add basic keyboard shortcuts table * shortcuts change to not interfere with toolbar shortcuts - needs testing - vim and emacs todo * formatting * controlpanel change keymap - default keymap is default * ctrl-T becomes Alt-T in default keymap * adjustments for codemirror demo * demo: hellothere - hint for sidebar keymap cheatsheet * toolbar focus fix + remove console log * engine.js cleanup * formatting * reverting focus fix * indenting engine.js * hoping that indenting gets better
2018-04-06 16:34:50 +00:00
// 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