mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
45 lines
921 B
JavaScript
45 lines
921 B
JavaScript
'use strict';
|
|
|
|
const exec = require('execon');
|
|
const Key = CloudCmd.Key;
|
|
|
|
const Events = require('../dom/events');
|
|
|
|
CloudCmd.EditFileVim = function EditFileVimProto(callback) {
|
|
const EditFileVim = this;
|
|
|
|
const ConfigView = {
|
|
bindKeys: false,
|
|
beforeClose: () => {
|
|
Events.rmKey(listener);
|
|
}
|
|
};
|
|
|
|
function init(callback) {
|
|
exec.series([
|
|
CloudCmd.EditFile,
|
|
callback || EditFileVim.show,
|
|
]);
|
|
}
|
|
|
|
this.show = () => {
|
|
Events.addKey(listener);
|
|
|
|
CloudCmd.EditFile
|
|
.show(ConfigView)
|
|
.getEditor()
|
|
.setOption('keyMap', 'vim');
|
|
};
|
|
|
|
this.hide = () => {
|
|
CloudCmd.Edit.hide();
|
|
};
|
|
|
|
function listener({keyCode, shiftKey}) {
|
|
if (shiftKey && keyCode === Key.ESC)
|
|
EditFileVim.hide();
|
|
}
|
|
|
|
init(callback);
|
|
};
|
|
|