diff --git a/CHANGELOG.md b/CHANGELOG.md index 5391726e..f2d523b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,10 @@ key2=val2 * 新建文件默认内容更改为 `#Halo AntSword!` +* 编辑文件文件路径改为输入框, 现在可以手动输入文件路径后, 按 Enter 键快速打开文件了 + +![file_manager_filepath.png](https://i.loli.net/2019/12/04/rtpJCafoDLSBsAi.png) + ### 虚拟终端 * 新增 `asenv` 本地指令, 用于手动设置当前终端下的环境变量 diff --git a/source/modules/filemanager/index.js b/source/modules/filemanager/index.js index 385908ad..e8563d3a 100644 --- a/source/modules/filemanager/index.js +++ b/source/modules/filemanager/index.js @@ -871,7 +871,7 @@ class FileManager { let codes = ''; let win; let hinttext = ''; - let tooltip = `IP:${this.opts['ip']} File:${antSword.noxss(path)}`; + let tooltip = `IP:${this.opts['ip']} File:`; if (openfileintab == false) { win = this.createWin({ title: LANG['editor']['title'](antSword.noxss(path)), @@ -894,7 +894,7 @@ class FileManager { tmpbuf.write(name, 100 - name.length); hitpath = tmpbuf.toString(); } - hinttext = `IP:${this.opts['ip']} File:${antSword.noxss(hitpath)}`; + hinttext = `IP:${this.opts['ip']} File:`; } win.progressOn(); @@ -952,6 +952,12 @@ class FileManager { type: 'text', text: hinttext }, + { + id: 'filepath', + type: 'buttonInput', + width: 500, + value: antSword.noxss(path), + }, { type: 'separator' }, @@ -1040,6 +1046,18 @@ class FileManager { }) ).then((res) => { win.progressOff(); + name = path.substr(path.lastIndexOf('/') + 1); + if (openfileintab == false) { + win.setText(LANG['editor']['title'](antSword.noxss(path))); + } else { + win.setText(` ${antSword.noxss(name)}`); + } + ext = name.substr(name.lastIndexOf('.') + 1); + if (!(ext in ext_dict)) { + ext = 'txt' + }; + toolbar.callEvent('onClick', [`mode_${ext_dict[ext]}`]); + let ret = antSword.unxss(res['text'], false); codes = Buffer.from(antSword.unxss(res['buff'].toString(), false)); let encoding = res['encoding'] || this.opts['encode']; @@ -1056,6 +1074,14 @@ class FileManager { console.info('toolbar.onClick', id); } }); + toolbar.attachEvent('onEnter', (id, value) => { + switch (id) { + case 'filepath': + path = toolbar.getInput('filepath').value; + toolbar.callEvent('onClick', ['refresh']); + break; + } + }); // 获取文件代码 this.core.request(