Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed select+deselect+cut/copy

  • Loading branch information...
commit 8453a302d3d04edeff72532a888ebf817af1f6b1 1 parent a4a51f4
@tmpvar authored
Showing with 28 additions and 13 deletions.
  1. +28 −13 lib/cider.js
View
41 lib/cider.js
@@ -741,9 +741,14 @@
var selecting = false,shiftKey = false, ranges = [];
-
obj.event.bind("mouse.down", function() {
if (!shiftKey) {
+ obj.event.trigger("selection.change", {
+ previous: ranges[0],
+ current : null,
+ node : obj
+ });
+
ranges = [];
selecting = false;
}
@@ -753,6 +758,12 @@
obj.event.bind("keyboard.down", function(name, data) {
if (!data.shiftKey) {
+ obj.event.trigger("selection.change", {
+ previous: ranges[0],
+ current : null,
+ node : obj
+ });
+
ranges = [];
}
selecting = shiftKey = data.shiftKey;
@@ -762,6 +773,11 @@
});
obj.event.bind("mouse.up", function(name, data) {
if (!shiftKey && !selecting) {
+ obj.event.trigger("selection.change", {
+ previous: ranges[0],
+ current : null,
+ node : obj
+ });
ranges = [];
selecting = false;
}
@@ -769,6 +785,11 @@
obj.dragstart = function(node, mouse) {
if (!shiftKey) {
+ obj.event.trigger("selection.change", {
+ previous: ranges[0],
+ current : null,
+ node : obj
+ });
ranges = [];
}
@@ -1718,21 +1739,20 @@
});
obj.event.bind("keyboard.down", function(name, data) {
- if ((data.ctrlKey || data.metaKey) && data.character) {
+ if ((data.ctrlKey || data.metaKey) &&
+ data.character &&
+ selection &&
+ selection.current)
+ {
var hack = document.createElement("textarea"),
active = document.activeElement,
text = "",
- r,
+ r = selection.current,
i, l, lines = [];
switch (data.character)
{
case 'c': // Copy
- // There must be a selection to copy!
- if (!selection) { return; };
-
- r = selection.current;
-
// find the side of the range that is closest to the top
if (r.src.y !== r.dest.y) {
if (r.dest.y > r.src.y) {
@@ -1819,11 +1839,6 @@
break; // End Paste
case 'x': // Cut
- // There must be a selection to copy!
- if (!selection) { return; };
-
- r = selection.current;
-
// find the side of the range that is closest to the top
if (r.src.y !== r.dest.y) {
if (r.dest.y > r.src.y) {
Please sign in to comment.
Something went wrong with that request. Please try again.