diff --git a/src/ace/Document.js b/src/ace/Document.js index 44aaae39..5814b8c6 100644 --- a/src/ace/Document.js +++ b/src/ace/Document.js @@ -33,6 +33,7 @@ var Document = function(text, mode) { } }; + (function() { oop.implement(this, MEventEmitter); @@ -43,13 +44,13 @@ var Document = function(text, mode) { return text.split(/\r\n|\r|\n/); }; - this.setValue = function(text) { - var args = [0, this.lines.length]; - args.push.apply(args, this.$split(text)); - this.lines.splice.apply(this.lines, args); - this.modified = true; - this.fireChangeEvent(0); - }; + this.setValue = function(text) { + var args = [0, this.lines.length]; + args.push.apply(args, this.$split(text)); + this.lines.splice.apply(this.lines, args); + this.modified = true; + this.fireChangeEvent(0); + }; this.toString = function() { return this.lines.join(this.$getNewLineCharacter()); @@ -259,6 +260,14 @@ var Document = function(text, mode) { 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) { return this.lines.slice(firstRow, lastRow+1); }; @@ -504,7 +513,7 @@ var Document = function(text, mode) { return range.start; }; - + this.undoChanges = function(deltas) { this.selection.clearSelection(); for (var i=deltas.length-1; i>=0; i--) { diff --git a/src/ace/Editor.js b/src/ace/Editor.js index c4f5e91a..e3574357 100644 --- a/src/ace/Editor.js +++ b/src/ace/Editor.js @@ -371,7 +371,6 @@ var Editor = function(renderer, doc) { }; this.onTextInput = function(text) { - console.log("onTextInput was called"); if (this.$readOnly) return; @@ -406,10 +405,8 @@ var Editor = function(renderer, doc) { */ var line = _self.doc.getLine(row); - console.log("Poofing"); _self.bgTokenizer.getState(row, function(lineState) { // multi line insert - console.log("Poof " + row + "of" + end.row); if (row !== end.row) { var indent = _self.mode.getNextLineIndent(lineState, line, _self.doc.getTabString()); if (indent) { @@ -417,9 +414,7 @@ var Editor = function(renderer, doc) { end.column += _self.doc.indentRows(indentRange, indent); } } else { - console.log("Last row"); if (shouldOutdent) { - console.log("We should outdent"); 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.scrollToRow(this.getPageDownRow()); }; diff --git a/src/ace/commands/DefaultCommands.js b/src/ace/commands/DefaultCommands.js index 305fa902..f0877051 100644 --- a/src/ace/commands/DefaultCommands.js +++ b/src/ace/commands/DefaultCommands.js @@ -66,7 +66,7 @@ PluginManager.registerCommand("golineup", function(editor, selection) { PluginManager.registerCommand("copylinesdown", function(editor, selection) { editor.copyLinesDown(); }); -PluginManager.registerCommand("movelinsedown", function(editor, selection) { +PluginManager.registerCommand("movelinesdown", function(editor, selection) { editor.moveLinesDown(); }); PluginManager.registerCommand("selecttoend", function(editor, selection) { @@ -123,12 +123,18 @@ PluginManager.registerCommand("selectpagedown", function(editor, selection) { PluginManager.registerCommand("pagedown", function(editor, selection) { editor.scrollPageDown(); }); +PluginManager.registerCommand("gotopagedown", function(editor, selection) { + editor.gotoPageDown(); +}); PluginManager.registerCommand("selectpageup", function(editor, selection) { editor.selectPageUp(); }); PluginManager.registerCommand("pageup", function(editor, selection) { editor.scrollPageUp(); }); +PluginManager.registerCommand("gotopageup", function(editor, selection) { + editor.gotoPageUp(); +}); PluginManager.registerCommand("selectlinestart", function(editor, selection) { selection.selectLineStart(); });