Merge pull request #402 from nonameShijian/PR-Branch
修复编辑器在安卓端选中一个提示后光标回到行首的问题。增加鼠标悬浮或者触摸一个代码提示时自动选中(不补全)的功能,代码提示改为字典排序,增加手机端代码提示滚动条宽度,修复报错代码提示行数比实际行数少1的bug
This commit is contained in:
commit
39a126b64d
|
@ -10164,6 +10164,24 @@
|
||||||
if (cur.render) cur.render(elt, data, cur);
|
if (cur.render) cur.render(elt, data, cur);
|
||||||
else elt.appendChild(ownerDocument.createTextNode(cur.displayText || getText(cur)));
|
else elt.appendChild(ownerDocument.createTextNode(cur.displayText || getText(cur)));
|
||||||
elt.hintId = i;
|
elt.hintId = i;
|
||||||
|
CodeMirror.on(elt, "mouseover", function (e) {
|
||||||
|
widget.changeActive(this.hintId);
|
||||||
|
});
|
||||||
|
CodeMirror.on(elt, "touchstart", function (e) {
|
||||||
|
widget.changeActive(this.hintId);
|
||||||
|
});
|
||||||
|
CodeMirror.on(elt, "touchend", function (e) {
|
||||||
|
var cur = cm.getCursor();
|
||||||
|
var self = this;
|
||||||
|
setTimeout(function () {
|
||||||
|
cm.focus();
|
||||||
|
var cur2 = cm.getCursor();
|
||||||
|
if (cur2.line == cur.line && cur2.ch == 0) {
|
||||||
|
var textLen = self.innerText.length;
|
||||||
|
cm.setCursor({ line: cur.line, ch: cur.ch + textLen });
|
||||||
|
}
|
||||||
|
}, 10);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var container = completion.options.container || ownerDocument.body;
|
var container = completion.options.container || ownerDocument.body;
|
||||||
|
@ -10267,7 +10285,7 @@
|
||||||
setTimeout(function () { cm.focus(); }, 20);
|
setTimeout(function () { cm.focus(); }, 20);
|
||||||
});
|
});
|
||||||
|
|
||||||
//滑动修复//
|
//滑动修复
|
||||||
CodeMirror.on(hints, "touchmove", function (event) {
|
CodeMirror.on(hints, "touchmove", function (event) {
|
||||||
if (ios && this.scrollHeight <= this.offsetHeight + 5 && this.scrollWidth <= this.offsetWidth + 5) {
|
if (ios && this.scrollHeight <= this.offsetHeight + 5 && this.scrollWidth <= this.offsetWidth + 5) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -10537,8 +10555,6 @@
|
||||||
"if in import instanceof let new null return super switch this throw true try typeof var void while with yield").split(" ");
|
"if in import instanceof let new null return super switch this throw true try typeof var void while with yield").split(" ");
|
||||||
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
|
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
|
||||||
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
|
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
|
||||||
//var nonameWords = ("_status ai audio card charlotte content control damage enable event extension fixed forced gainable game get group identity lib lose loseHp mod mode nobracket player recover remove result select set source superCharlotte target trigger ui viewAs").split(" ");
|
|
||||||
//var extension = ["ai:{\n},", "content:function(){\n},", "enable:\"phaseUse\",", "event.player", "event.source", "event.target", "filter:function(event,player,name){\n},", "init:function(player){\n},", "for(var i = 0; i < xx.length; i++) {\n}", "for(var i in xx){\n}", "for(var i of xx){\n}", "mod:{\n},", "skill = {\n\ttrigger:{},\n\tfilter:function(event,player,name){},\n\tcontent:function(){},\n}", "switch(){\n}", "trigger:{\n},", "trigger.name", "trigger.player", "trigger.source", "trigger.target", "try{\n}catch(e){\n}", "usable:1,", "while(){\n}", "window"];
|
|
||||||
function forAllProps(obj, callback) {
|
function forAllProps(obj, callback) {
|
||||||
if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) {
|
if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) {
|
||||||
for (var name in obj) callback(name)
|
for (var name in obj) callback(name)
|
||||||
|
@ -10596,8 +10612,6 @@
|
||||||
gatherCompletions(global);*/
|
gatherCompletions(global);*/
|
||||||
forEach(keywords, maybeAdd);
|
forEach(keywords, maybeAdd);
|
||||||
forEach(coffeescriptKeywords, maybeAdd);
|
forEach(coffeescriptKeywords, maybeAdd);
|
||||||
//forEach(nonameWords, maybeAdd);
|
|
||||||
//forEach(extension, maybeAdd);
|
|
||||||
}
|
}
|
||||||
return found.sort(function (a, b) {
|
return found.sort(function (a, b) {
|
||||||
return (a + '').localeCompare(b + '');
|
return (a + '').localeCompare(b + '');
|
||||||
|
|
15
game/game.js
15
game/game.js
|
@ -7554,13 +7554,13 @@
|
||||||
if(str.lastIndexOf(start,0)==0&&!list.includes(str)) list.push(str);
|
if(str.lastIndexOf(start,0)==0&&!list.includes(str)) list.push(str);
|
||||||
}
|
}
|
||||||
for(let v=token.state.localVars;v;v=v.next) maybeAdd(v.name);
|
for(let v=token.state.localVars;v;v=v.next) maybeAdd(v.name);
|
||||||
for(let c=token.state.context;c;c=c.prev) for (let v=c.vars;v;v=v.next) maybeAdd(v.name)
|
for(let c=token.state.context;c;c=c.prev) for(let v=c.vars;v;v=v.next) maybeAdd(v.name)
|
||||||
for(let v=token.state.globalVars;v;v=v.next) maybeAdd(v.name);
|
for(let v=token.state.globalVars;v;v=v.next) maybeAdd(v.name);
|
||||||
if(options&&options.additionalContext!=null) for(let key in options.additionalContext) maybeAdd(key);
|
if(options&&options.additionalContext!=null) for(let key in options.additionalContext) maybeAdd(key);
|
||||||
list.addArray(keys);
|
list.addArray(keys);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
list:list.filter(key=>key.startsWith(token.string)),
|
list:list.filter(key=>key.startsWith(token.string)).sort((a,b)=>(a+'').localeCompare(b+'')),
|
||||||
from:CodeMirror.Pos(cur.line,token.start),
|
from:CodeMirror.Pos(cur.line,token.start),
|
||||||
to:CodeMirror.Pos(cur.line,token.end),
|
to:CodeMirror.Pos(cur.line,token.end),
|
||||||
};
|
};
|
||||||
|
@ -8521,15 +8521,15 @@
|
||||||
if(lines.length>=10){
|
if(lines.length>=10){
|
||||||
if(line>4){
|
if(line>4){
|
||||||
for(let i=line-5;i<line+6&&i<lines.length;i++){
|
for(let i=line-5;i<line+6&&i<lines.length;i++){
|
||||||
showCode+=`${i}| ${line==i+1?'⚠️':''}${lines[i]}\n`;
|
showCode+=`${i+1}| ${line==i+1?'⚠️':''}${lines[i]}\n`;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
for(let i=0;i<line+6&&i<lines.length;i++){
|
for(let i=0;i<line+6&&i<lines.length;i++){
|
||||||
showCode+=`${i}| ${line==i+1?'⚠️':''}${lines[i]}\n`;
|
showCode+=`${i+1}| ${line==i+1?'⚠️':''}${lines[i]}\n`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
showCode=lines.map((_line,i)=>`${i}| ${line==i+1?'⚠️':''}${_line}\n`).toString();
|
showCode=lines.map((_line,i)=>`${i+1}| ${line==i+1?'⚠️':''}${_line}\n`).toString();
|
||||||
}
|
}
|
||||||
return showCode;
|
return showCode;
|
||||||
}
|
}
|
||||||
|
@ -40919,6 +40919,9 @@
|
||||||
this.focus();
|
this.focus();
|
||||||
click.call(this);
|
click.call(this);
|
||||||
});
|
});
|
||||||
|
elt.onmousemove=elt.ontouchstart=()=>{
|
||||||
|
setActive(i);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
createList.push(ul);
|
createList.push(ul);
|
||||||
|
@ -40974,7 +40977,7 @@
|
||||||
}
|
}
|
||||||
const self=this;
|
const self=this;
|
||||||
const pos=this.getBoundingClientRect();
|
const pos=this.getBoundingClientRect();
|
||||||
const list=['撤销\t\tCtrl+Z', '恢复撤销\tCtrl+Y'/* , '全选\t\tCtrl+A' */];
|
const list=['撤销 Ctrl+Z', '恢复撤销 Ctrl+Y'];
|
||||||
const click=function(e){
|
const click=function(e){
|
||||||
const num=this.innerHTML.indexOf("Ctrl");
|
const num=this.innerHTML.indexOf("Ctrl");
|
||||||
const inner=this.innerHTML.slice(num).replace("+", "-");
|
const inner=this.innerHTML.slice(num).replace("+", "-");
|
||||||
|
|
|
@ -457,11 +457,32 @@ div.cm-s-mdn-like span.CodeMirror-matchingbracket { outline:1px solid grey; colo
|
||||||
background: white;
|
background: white;
|
||||||
font-size: 90%;
|
font-size: 90%;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
|
text-shadow: none;
|
||||||
|
|
||||||
max-height: 20em;
|
max-height: 20em;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.CodeMirror-hints::-webkit-scrollbar {
|
||||||
|
width: 15px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1000px) {
|
||||||
|
.CodeMirror-hints::-webkit-scrollbar {
|
||||||
|
width: 25px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-hints::-webkit-scrollbar-thumb {
|
||||||
|
background-color: rgb(218, 215, 215);
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-hints::-webkit-scrollbar-track {
|
||||||
|
background-color: #6b6565;
|
||||||
|
}
|
||||||
|
|
||||||
.CodeMirror-hint {
|
.CodeMirror-hint {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0 4px;
|
padding: 0 4px;
|
||||||
|
|
Loading…
Reference in New Issue