mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 18:18:56 +00:00
feature(key) add copy, cut to buffer; paste from buffer
This commit is contained in:
parent
f859d9a3ee
commit
f56a175101
3 changed files with 116 additions and 24 deletions
3
HELP.md
3
HELP.md
|
|
@ -111,6 +111,9 @@ Hot keys
|
|||
| `*` | select/unselect all
|
||||
| `+` | expand selection
|
||||
| `-` | shrink selection
|
||||
| `Ctrl + с` | copy to buffer
|
||||
| `Ctrl + x` | cut to buffer
|
||||
| `Ctrl + v` | paste from buffer
|
||||
| `Ctrl + r` | refresh
|
||||
| `Ctrl + d` | clear local storage
|
||||
| `Alt + q` | disable key bindings
|
||||
|
|
|
|||
|
|
@ -1464,16 +1464,16 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
* process files (copy or move)
|
||||
* @param operation
|
||||
*/
|
||||
function processFiles(operation) {
|
||||
function processFiles(operation, data) {
|
||||
var n, name, files, cmp, msg, opFunc,
|
||||
RESTful = DOM.RESTful,
|
||||
|
||||
from = CurrentInfo.dirPath,
|
||||
to = DOM.getNotCurrentDirPath(),
|
||||
from = '',
|
||||
to = '',
|
||||
|
||||
names = Cmd.getSelectedNames(),
|
||||
names = [],
|
||||
|
||||
length = names && names.length;
|
||||
length = 0;
|
||||
|
||||
if (operation.copy) {
|
||||
opFunc = RESTful.cp;
|
||||
|
|
@ -1483,24 +1483,37 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
msg = 'Rename/Move ';
|
||||
}
|
||||
|
||||
if (!length) {
|
||||
name = DOM.getCurrentName();
|
||||
names.push(name);
|
||||
} else if (length === 1) {
|
||||
name = names[0];
|
||||
if (data) {
|
||||
from = data.from;
|
||||
to = data.to;
|
||||
names = data.names;
|
||||
} else {
|
||||
from = CurrentInfo.dirPath;
|
||||
to = DOM.getNotCurrentDirPath();
|
||||
|
||||
names = Cmd.getSelectedNames();
|
||||
length = names && names.length;
|
||||
|
||||
if (!length) {
|
||||
name = DOM.getCurrentName();
|
||||
names.push(name);
|
||||
} else if (length === 1) {
|
||||
name = names[0];
|
||||
}
|
||||
|
||||
if (length > 1)
|
||||
msg += n + ' file(s)';
|
||||
else
|
||||
msg += '"' + name + '"';
|
||||
|
||||
msg += ' to';
|
||||
}
|
||||
|
||||
if (length > 1)
|
||||
msg += n + ' file(s)';
|
||||
else
|
||||
msg += '"' + name + '"';
|
||||
|
||||
msg += ' to';
|
||||
|
||||
if (name === '..') {
|
||||
Dialog.alert('No files selected!');
|
||||
} else {
|
||||
to = Dialog.prompt(msg, to);
|
||||
if (!data)
|
||||
to = Dialog.prompt(msg, to);
|
||||
|
||||
cmp = Util.strCmp(from, to);
|
||||
|
||||
|
|
@ -1530,16 +1543,16 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
}
|
||||
}
|
||||
|
||||
this.copyFiles = function() {
|
||||
this.copyFiles = function(data) {
|
||||
processFiles({
|
||||
copy: true
|
||||
});
|
||||
}, data);
|
||||
};
|
||||
|
||||
this.moveFiles = function() {
|
||||
this.moveFiles = function(data) {
|
||||
processFiles({
|
||||
move: true
|
||||
});
|
||||
}, data);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
var CloudCmd, Util, DOM;
|
||||
|
||||
(function(CloudCmd, Util, DOM) {
|
||||
'use strict';
|
||||
|
||||
var Info = DOM.CurrentInfo,
|
||||
Events = DOM.Events,
|
||||
Storage = DOM.Storage,
|
||||
Dialog = DOM.Dialog,
|
||||
|
||||
Chars = [],
|
||||
KEY = {
|
||||
BACKSPACE : 8,
|
||||
|
|
@ -26,6 +30,7 @@ var CloudCmd, Util, DOM;
|
|||
|
||||
A : 65,
|
||||
|
||||
C : 67,
|
||||
D : 68,
|
||||
|
||||
G : 71,
|
||||
|
|
@ -36,6 +41,10 @@ var CloudCmd, Util, DOM;
|
|||
S : 83,
|
||||
T : 84,
|
||||
|
||||
V : 86,
|
||||
|
||||
X : 88,
|
||||
|
||||
Z : 90,
|
||||
|
||||
ASTERISK : 106,
|
||||
|
|
@ -162,12 +171,16 @@ var CloudCmd, Util, DOM;
|
|||
|
||||
function switchKey(event) {
|
||||
var i, obj, name, isSelected, isDir, prev, next,
|
||||
names = [],
|
||||
copy = Storage.get.bind(Storage, 'copy'),
|
||||
move = Storage.get.bind(Storage, 'move'),
|
||||
|
||||
current = Info.element,
|
||||
panel = Info.panel,
|
||||
path = Info.path,
|
||||
keyCode = event.keyCode,
|
||||
shift = event.shiftKey,
|
||||
lAlt = event.altKey,
|
||||
alt = event.altKey,
|
||||
ctrl = event.ctrlKey;
|
||||
|
||||
if (current) {
|
||||
|
|
@ -413,6 +426,69 @@ var CloudCmd, Util, DOM;
|
|||
}
|
||||
break;
|
||||
|
||||
case Key.C:
|
||||
if (ctrl) {
|
||||
names = DOM.getSelectedNames();
|
||||
i = names.length;
|
||||
|
||||
Storage.remove('move')
|
||||
.set('copy', {
|
||||
from : Info.dirPath,
|
||||
names: i ? names : [Info.name]
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case Key.X:
|
||||
if (ctrl) {
|
||||
names = DOM.getSelectedNames();
|
||||
i = names.length;
|
||||
|
||||
Storage.remove('cop')
|
||||
.set('move', {
|
||||
from : Info.dirPath,
|
||||
names: i ? names : [Info.name]
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case Key.V:
|
||||
if (ctrl) {
|
||||
Util.exec.parallel([copy, move], function(error, cp, mv) {
|
||||
var data = {},
|
||||
msg = 'Path is same!',
|
||||
path = Info.dirPath;
|
||||
|
||||
if (!error && !cp && !mv)
|
||||
error = 'No files selected!';
|
||||
|
||||
if (error) {
|
||||
DOM.Dialog.alert(error);
|
||||
} else if (cp) {
|
||||
data = Util.parseJSON(cp);
|
||||
data.to = path;
|
||||
|
||||
if (data.from === path)
|
||||
Dialog.alert(msg);
|
||||
else
|
||||
DOM.copyFiles(data);
|
||||
|
||||
} else if (mv) {
|
||||
data = Util.parseJSON(mv);
|
||||
data.to = path;
|
||||
|
||||
if (data.from === path)
|
||||
Dialog.alert(msg);
|
||||
else
|
||||
DOM.moveFiles(data);
|
||||
}
|
||||
|
||||
Storage.remove('copy')
|
||||
.remove('move');
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
/* чистим хранилище */
|
||||
case Key.D:
|
||||
if (ctrl) {
|
||||
|
|
@ -427,7 +503,7 @@ var CloudCmd, Util, DOM;
|
|||
|
||||
/* убираем все обработчики нажатий клавиш */
|
||||
case Key.Q:
|
||||
if (lAlt) {
|
||||
if (alt) {
|
||||
Util.log('<alt>+q pressed\n' +
|
||||
'<ctrl>+r reload key-handerl - removed' +
|
||||
'<ctrl>+s clear Storage key-handler - removed'+
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue