mirror of
https://github.com/neocities/neocities.git
synced 2025-05-14 16:37:20 +02:00
updated ace editor with new settings
settings for tab width, font size, keyboard mode, and autocomplete
This commit is contained in:
parent
d11e951fe6
commit
811b956a4b
1998 changed files with 1585 additions and 1527684 deletions
|
@ -1,113 +1,5 @@
|
|||
define("ace/ext/hardwrap",["require","exports","module","ace/range","ace/editor","ace/config"], function(require, exports, module){"use strict";
|
||||
var Range = require("../range").Range;
|
||||
function hardWrap(editor, options) {
|
||||
var max = options.column || editor.getOption("printMarginColumn");
|
||||
var allowMerge = options.allowMerge != false;
|
||||
var row = Math.min(options.startRow, options.endRow);
|
||||
var endRow = Math.max(options.startRow, options.endRow);
|
||||
var session = editor.session;
|
||||
while (row <= endRow) {
|
||||
var line = session.getLine(row);
|
||||
if (line.length > max) {
|
||||
var space = findSpace(line, max, 5);
|
||||
if (space) {
|
||||
var indentation = /^\s*/.exec(line)[0];
|
||||
session.replace(new Range(row, space.start, row, space.end), "\n" + indentation);
|
||||
}
|
||||
endRow++;
|
||||
}
|
||||
else if (allowMerge && /\S/.test(line) && row != endRow) {
|
||||
var nextLine = session.getLine(row + 1);
|
||||
if (nextLine && /\S/.test(nextLine)) {
|
||||
var trimmedLine = line.replace(/\s+$/, "");
|
||||
var trimmedNextLine = nextLine.replace(/^\s+/, "");
|
||||
var mergedLine = trimmedLine + " " + trimmedNextLine;
|
||||
var space = findSpace(mergedLine, max, 5);
|
||||
if (space && space.start > trimmedLine.length || mergedLine.length < max) {
|
||||
var replaceRange = new Range(row, trimmedLine.length, row + 1, nextLine.length - trimmedNextLine.length);
|
||||
session.replace(replaceRange, " ");
|
||||
row--;
|
||||
endRow--;
|
||||
}
|
||||
else if (trimmedLine.length < line.length) {
|
||||
session.remove(new Range(row, trimmedLine.length, row, line.length));
|
||||
}
|
||||
}
|
||||
}
|
||||
row++;
|
||||
}
|
||||
function findSpace(line, max, min) {
|
||||
if (line.length < max)
|
||||
return;
|
||||
var before = line.slice(0, max);
|
||||
var after = line.slice(max);
|
||||
var spaceAfter = /^(?:(\s+)|(\S+)(\s+))/.exec(after);
|
||||
var spaceBefore = /(?:(\s+)|(\s+)(\S+))$/.exec(before);
|
||||
var start = 0;
|
||||
var end = 0;
|
||||
if (spaceBefore && !spaceBefore[2]) {
|
||||
start = max - spaceBefore[1].length;
|
||||
end = max;
|
||||
}
|
||||
if (spaceAfter && !spaceAfter[2]) {
|
||||
if (!start)
|
||||
start = max;
|
||||
end = max + spaceAfter[1].length;
|
||||
}
|
||||
if (start) {
|
||||
return {
|
||||
start: start,
|
||||
end: end
|
||||
};
|
||||
}
|
||||
if (spaceBefore && spaceBefore[2] && spaceBefore.index > min) {
|
||||
return {
|
||||
start: spaceBefore.index,
|
||||
end: spaceBefore.index + spaceBefore[2].length
|
||||
};
|
||||
}
|
||||
if (spaceAfter && spaceAfter[2]) {
|
||||
start = max + spaceAfter[2].length;
|
||||
return {
|
||||
start: start,
|
||||
end: start + spaceAfter[3].length
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
function wrapAfterInput(e) {
|
||||
if (e.command.name == "insertstring" && /\S/.test(e.args)) {
|
||||
var editor = e.editor;
|
||||
var cursor = editor.selection.cursor;
|
||||
if (cursor.column <= editor.renderer.$printMarginColumn)
|
||||
return;
|
||||
var lastDelta = editor.session.$undoManager.$lastDelta;
|
||||
hardWrap(editor, {
|
||||
startRow: cursor.row, endRow: cursor.row,
|
||||
allowMerge: false
|
||||
});
|
||||
if (lastDelta != editor.session.$undoManager.$lastDelta)
|
||||
editor.session.markUndoGroup();
|
||||
}
|
||||
}
|
||||
var Editor = require("../editor").Editor;
|
||||
require("../config").defineOptions(Editor.prototype, "editor", {
|
||||
hardWrap: {
|
||||
set: function (val) {
|
||||
if (val) {
|
||||
this.commands.on("afterExec", wrapAfterInput);
|
||||
}
|
||||
else {
|
||||
this.commands.off("afterExec", wrapAfterInput);
|
||||
}
|
||||
},
|
||||
value: false
|
||||
}
|
||||
});
|
||||
exports.hardWrap = hardWrap;
|
||||
|
||||
}); (function() {
|
||||
window.require(["ace/ext/hardwrap"], function(m) {
|
||||
ace.define("ace/ext/hardwrap",["require","exports","module","ace/range","ace/editor","ace/config"],function(e,t,n){"use strict";function i(e,t){function m(e,t,n){if(e.length<t)return;var r=e.slice(0,t),i=e.slice(t),s=/^(?:(\s+)|(\S+)(\s+))/.exec(i),o=/(?:(\s+)|(\s+)(\S+))$/.exec(r),u=0,a=0;o&&!o[2]&&(u=t-o[1].length,a=t),s&&!s[2]&&(u||(u=t),a=t+s[1].length);if(u)return{start:u,end:a};if(o&&o[2]&&o.index>n)return{start:o.index,end:o.index+o[2].length};if(s&&s[2])return u=t+s[2].length,{start:u,end:u+s[3].length}}var n=t.column||e.getOption("printMarginColumn"),i=t.allowMerge!=0,s=Math.min(t.startRow,t.endRow),o=Math.max(t.startRow,t.endRow),u=e.session;while(s<=o){var a=u.getLine(s);if(a.length>n){var f=m(a,n,5);if(f){var l=/^\s*/.exec(a)[0];u.replace(new r(s,f.start,s,f.end),"\n"+l)}o++}else if(i&&/\S/.test(a)&&s!=o){var c=u.getLine(s+1);if(c&&/\S/.test(c)){var h=a.replace(/\s+$/,""),p=c.replace(/^\s+/,""),d=h+" "+p,f=m(d,n,5);if(f&&f.start>h.length||d.length<n){var v=new r(s,h.length,s+1,c.length-p.length);u.replace(v," "),s--,o--}else h.length<a.length&&u.remove(new r(s,h.length,s,a.length))}}s++}}function s(e){if(e.command.name=="insertstring"&&/\S/.test(e.args)){var t=e.editor,n=t.selection.cursor;if(n.column<=t.renderer.$printMarginColumn)return;var r=t.session.$undoManager.$lastDelta;i(t,{startRow:n.row,endRow:n.row,allowMerge:!1}),r!=t.session.$undoManager.$lastDelta&&t.session.markUndoGroup()}}var r=e("../range").Range,o=e("../editor").Editor;e("../config").defineOptions(o.prototype,"editor",{hardWrap:{set:function(e){e?this.commands.on("afterExec",s):this.commands.off("afterExec",s)},value:!1}}),t.hardWrap=i}); (function() {
|
||||
ace.require(["ace/ext/hardwrap"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue