Merge pull request #402 from nonameShijian/PR-Branch

修复编辑器在安卓端选中一个提示后光标回到行首的问题。增加鼠标悬浮或者触摸一个代码提示时自动选中(不补全)的功能,代码提示改为字典排序,增加手机端代码提示滚动条宽度,修复报错代码提示行数比实际行数少1的bug
This commit is contained in:
Spmario233 2023-09-27 10:57:14 +08:00 committed by GitHub
commit 39a126b64d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 11 deletions

View File

@ -10164,6 +10164,24 @@
if (cur.render) cur.render(elt, data, cur);
else elt.appendChild(ownerDocument.createTextNode(cur.displayText || getText(cur)));
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;
@ -10267,7 +10285,7 @@
setTimeout(function () { cm.focus(); }, 20);
});
//滑动修复//
//滑动修复
CodeMirror.on(hints, "touchmove", function (event) {
if (ios && this.scrollHeight <= this.offsetHeight + 5 && this.scrollWidth <= this.offsetWidth + 5) {
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(" ");
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(" ");
//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) {
if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) {
for (var name in obj) callback(name)
@ -10596,8 +10612,6 @@
gatherCompletions(global);*/
forEach(keywords, maybeAdd);
forEach(coffeescriptKeywords, maybeAdd);
//forEach(nonameWords, maybeAdd);
//forEach(extension, maybeAdd);
}
return found.sort(function (a, b) {
return (a + '').localeCompare(b + '');

View File

@ -7560,7 +7560,7 @@
list.addArray(keys);
}
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),
to:CodeMirror.Pos(cur.line,token.end),
};
@ -8521,15 +8521,15 @@
if(lines.length>=10){
if(line>4){
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{
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{
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;
}
@ -40919,6 +40919,9 @@
this.focus();
click.call(this);
});
elt.onmousemove=elt.ontouchstart=()=>{
setActive(i);
};
}
}
createList.push(ul);
@ -40974,7 +40977,7 @@
}
const self=this;
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 num=this.innerHTML.indexOf("Ctrl");
const inner=this.innerHTML.slice(num).replace("+", "-");

View File

@ -457,11 +457,32 @@ div.cm-s-mdn-like span.CodeMirror-matchingbracket { outline:1px solid grey; colo
background: white;
font-size: 90%;
font-family: monospace;
text-shadow: none;
max-height: 20em;
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 {
margin: 0;
padding: 0 4px;