mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
47 lines
932 B
JavaScript
47 lines
932 B
JavaScript
'use strict';
|
|
|
|
/* global CloudCmd */
|
|
|
|
const exec = require('execon');
|
|
const Events = require('../dom/events');
|
|
|
|
const {Key} = CloudCmd;
|
|
|
|
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()
|
|
.setKeyMap('vim');
|
|
};
|
|
|
|
this.hide = () => {
|
|
CloudCmd.Edit.hide();
|
|
};
|
|
|
|
function listener({keyCode, shiftKey}) {
|
|
if (shiftKey && keyCode === Key.ESC)
|
|
EditFileVim.hide();
|
|
}
|
|
|
|
init(callback);
|
|
};
|
|
|