- PageDown/Up now only move the cursor if Command
is pressed as well
This commit is contained in:
parent
325d1e20c3
commit
f22fc5a2f5
3 changed files with 46 additions and 14 deletions
|
|
@ -33,6 +33,7 @@ var Document = function(text, mode) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
oop.implement(this, MEventEmitter);
|
oop.implement(this, MEventEmitter);
|
||||||
|
|
@ -43,13 +44,13 @@ var Document = function(text, mode) {
|
||||||
return text.split(/\r\n|\r|\n/);
|
return text.split(/\r\n|\r|\n/);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setValue = function(text) {
|
this.setValue = function(text) {
|
||||||
var args = [0, this.lines.length];
|
var args = [0, this.lines.length];
|
||||||
args.push.apply(args, this.$split(text));
|
args.push.apply(args, this.$split(text));
|
||||||
this.lines.splice.apply(this.lines, args);
|
this.lines.splice.apply(this.lines, args);
|
||||||
this.modified = true;
|
this.modified = true;
|
||||||
this.fireChangeEvent(0);
|
this.fireChangeEvent(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.toString = function() {
|
this.toString = function() {
|
||||||
return this.lines.join(this.$getNewLineCharacter());
|
return this.lines.join(this.$getNewLineCharacter());
|
||||||
|
|
@ -259,6 +260,14 @@ var Document = function(text, mode) {
|
||||||
return this.lines[row] || "";
|
return this.lines[row] || "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a line as it is displayed on screen. Tabs are replaced by spaces.
|
||||||
|
*/
|
||||||
|
this.getDisplayLine = function(row) {
|
||||||
|
var tab = new Array(this.getTabSize()+1).join(" ");
|
||||||
|
return this.lines[row].replace(/\t/g, tab);
|
||||||
|
};
|
||||||
|
|
||||||
this.getLines = function(firstRow, lastRow) {
|
this.getLines = function(firstRow, lastRow) {
|
||||||
return this.lines.slice(firstRow, lastRow+1);
|
return this.lines.slice(firstRow, lastRow+1);
|
||||||
};
|
};
|
||||||
|
|
@ -504,7 +513,7 @@ var Document = function(text, mode) {
|
||||||
|
|
||||||
return range.start;
|
return range.start;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.undoChanges = function(deltas) {
|
this.undoChanges = function(deltas) {
|
||||||
this.selection.clearSelection();
|
this.selection.clearSelection();
|
||||||
for (var i=deltas.length-1; i>=0; i--) {
|
for (var i=deltas.length-1; i>=0; i--) {
|
||||||
|
|
|
||||||
|
|
@ -371,7 +371,6 @@ var Editor = function(renderer, doc) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.onTextInput = function(text) {
|
this.onTextInput = function(text) {
|
||||||
console.log("onTextInput was called");
|
|
||||||
if (this.$readOnly)
|
if (this.$readOnly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -406,10 +405,8 @@ var Editor = function(renderer, doc) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var line = _self.doc.getLine(row);
|
var line = _self.doc.getLine(row);
|
||||||
console.log("Poofing");
|
|
||||||
_self.bgTokenizer.getState(row, function(lineState) {
|
_self.bgTokenizer.getState(row, function(lineState) {
|
||||||
// multi line insert
|
// multi line insert
|
||||||
console.log("Poof " + row + "of" + end.row);
|
|
||||||
if (row !== end.row) {
|
if (row !== end.row) {
|
||||||
var indent = _self.mode.getNextLineIndent(lineState, line, _self.doc.getTabString());
|
var indent = _self.mode.getNextLineIndent(lineState, line, _self.doc.getTabString());
|
||||||
if (indent) {
|
if (indent) {
|
||||||
|
|
@ -417,9 +414,7 @@ var Editor = function(renderer, doc) {
|
||||||
end.column += _self.doc.indentRows(indentRange, indent);
|
end.column += _self.doc.indentRows(indentRange, indent);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("Last row");
|
|
||||||
if (shouldOutdent) {
|
if (shouldOutdent) {
|
||||||
console.log("We should outdent");
|
|
||||||
end.column += _self.mode.autoOutdent(lineState, _self.doc, row);
|
end.column += _self.mode.autoOutdent(lineState, _self.doc, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -736,6 +731,28 @@ var Editor = function(renderer, doc) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.gotoPageDown = function() {
|
||||||
|
console.log("Goto page down");
|
||||||
|
|
||||||
|
var row = this.getPageDownRow(),
|
||||||
|
column = Math.min(this.getCursorPosition().column,
|
||||||
|
this.doc.getLine(row).length);
|
||||||
|
|
||||||
|
this.scrollToRow(row);
|
||||||
|
this.getSelection().moveCursorTo(row, column);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.gotoPageUp = function() {
|
||||||
|
console.log("Goto page up");
|
||||||
|
|
||||||
|
var row = this.getPageUpRow(),
|
||||||
|
column = Math.min(this.getCursorPosition().column,
|
||||||
|
this.doc.getLine(row).length);
|
||||||
|
|
||||||
|
this.scrollToRow(row);
|
||||||
|
this.getSelection().moveCursorTo(row, column);
|
||||||
|
};
|
||||||
|
|
||||||
this.scrollPageDown = function() {
|
this.scrollPageDown = function() {
|
||||||
this.scrollToRow(this.getPageDownRow());
|
this.scrollToRow(this.getPageDownRow());
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ PluginManager.registerCommand("golineup", function(editor, selection) {
|
||||||
PluginManager.registerCommand("copylinesdown", function(editor, selection) {
|
PluginManager.registerCommand("copylinesdown", function(editor, selection) {
|
||||||
editor.copyLinesDown();
|
editor.copyLinesDown();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("movelinsedown", function(editor, selection) {
|
PluginManager.registerCommand("movelinesdown", function(editor, selection) {
|
||||||
editor.moveLinesDown();
|
editor.moveLinesDown();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selecttoend", function(editor, selection) {
|
PluginManager.registerCommand("selecttoend", function(editor, selection) {
|
||||||
|
|
@ -123,12 +123,18 @@ PluginManager.registerCommand("selectpagedown", function(editor, selection) {
|
||||||
PluginManager.registerCommand("pagedown", function(editor, selection) {
|
PluginManager.registerCommand("pagedown", function(editor, selection) {
|
||||||
editor.scrollPageDown();
|
editor.scrollPageDown();
|
||||||
});
|
});
|
||||||
|
PluginManager.registerCommand("gotopagedown", function(editor, selection) {
|
||||||
|
editor.gotoPageDown();
|
||||||
|
});
|
||||||
PluginManager.registerCommand("selectpageup", function(editor, selection) {
|
PluginManager.registerCommand("selectpageup", function(editor, selection) {
|
||||||
editor.selectPageUp();
|
editor.selectPageUp();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("pageup", function(editor, selection) {
|
PluginManager.registerCommand("pageup", function(editor, selection) {
|
||||||
editor.scrollPageUp();
|
editor.scrollPageUp();
|
||||||
});
|
});
|
||||||
|
PluginManager.registerCommand("gotopageup", function(editor, selection) {
|
||||||
|
editor.gotoPageUp();
|
||||||
|
});
|
||||||
PluginManager.registerCommand("selectlinestart", function(editor, selection) {
|
PluginManager.registerCommand("selectlinestart", function(editor, selection) {
|
||||||
selection.selectLineStart();
|
selection.selectLineStart();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue