- PageDown/Up now only move the cursor if Command

is pressed as well
This commit is contained in:
Eddy Bruel 2010-10-26 15:53:19 +02:00
commit f22fc5a2f5
3 changed files with 46 additions and 14 deletions

View file

@ -33,6 +33,7 @@ var Document = function(text, mode) {
} }
}; };
(function() { (function() {
oop.implement(this, MEventEmitter); oop.implement(this, MEventEmitter);
@ -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);
}; };

View file

@ -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());
}; };

View file

@ -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();
}); });