Skip to content

Commit

Permalink
(Enhance: FileManager) 编辑文件文件路径改为输入框, 现在可以手动输入文件路径后, 按 Enter 键快速打开文件了
Browse files Browse the repository at this point in the history
  • Loading branch information
Medicean committed Dec 4, 2019
1 parent 17d2ee4 commit 51fb80e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ key2=val2
* 新建文件默认内容更改为 `#Halo AntSword!`

* 编辑文件文件路径改为输入框, 现在可以手动输入文件路径后, 按 Enter 键快速打开文件了

![file_manager_filepath.png](https://i.loli.net/2019/12/04/rtpJCafoDLSBsAi.png)

### 虚拟终端

* 新增 `asenv` 本地指令, 用于手动设置当前终端下的环境变量
Expand Down
30 changes: 28 additions & 2 deletions source/modules/filemanager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand All @@ -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();
Expand Down Expand Up @@ -952,6 +952,12 @@ class FileManager {
type: 'text',
text: hinttext
},
{
id: 'filepath',
type: 'buttonInput',
width: 500,
value: antSword.noxss(path),
},
{
type: 'separator'
},
Expand Down Expand Up @@ -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(`<i class="fa fa-file-o"></i> ${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'];
Expand All @@ -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(
Expand Down

0 comments on commit 51fb80e

Please sign in to comment.