small cleanups

This commit is contained in:
nightwing 2012-05-25 11:28:20 +04:00
commit 6e1215a45e
13 changed files with 172 additions and 136 deletions

View file

@ -51,16 +51,11 @@ oop.inherits(CommandManager, HashHandler);
if (editor && editor.$readOnly && !command.readOnly) if (editor && editor.$readOnly && !command.readOnly)
return false; return false;
try { var retvalue = this._emit("exec", {
var retvalue = this._emit("exec", { editor: editor,
editor: editor, command: command,
command: command, args: args
args: args });
});
} catch (e) {
window.console && window.console.log(e);
return true;
}
return retvalue === false ? false : true; return retvalue === false ? false : true;
}; };

View file

@ -79,12 +79,15 @@ exports.defaultCommands = [{
exec: function(editor) { editor.selectMore(1, true); }, exec: function(editor) { editor.selectMore(1, true); },
bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"}, bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
readonly: true readonly: true
}, { }, {
name: "splitIntoLines", name: "splitIntoLines",
exec: function(editor) { editor.multiSelect.splitIntoLines(); }, exec: function(editor) { editor.multiSelect.splitIntoLines(); },
bindKey: {win: "Ctrl-Shift-L", mac: "Ctrl-Shift-L"}, bindKey: {win: "Ctrl-Shift-L", mac: "Ctrl-Shift-L"},
readonly: true readonly: true
}, { }];
// commands active in multiselect mode
exports.multiSelectCommands = [{
name: "singleSelection", name: "singleSelection",
bindKey: "esc", bindKey: "esc",
exec: function(editor) { editor.exitMultiSelectMode(); }, exec: function(editor) { editor.exitMultiSelectMode(); },
@ -92,10 +95,7 @@ exports.defaultCommands = [{
isAvailable: function(editor) {return editor.inMultiSelectMode} isAvailable: function(editor) {return editor.inMultiSelectMode}
}]; }];
// commands active in multiselect mode
exports.multiEditCommands = {"singleSelection": "esc"};
var HashHandler = require("../keyboard/hash_handler").HashHandler; var HashHandler = require("../keyboard/hash_handler").HashHandler;
exports.keyboardHandler = new HashHandler(exports.multiEditCommands); exports.keyboardHandler = new HashHandler(exports.multiSelectCommands);
}); });

View file

@ -55,14 +55,14 @@ var options = {
exports.get = function(key) { exports.get = function(key) {
if (!options.hasOwnProperty(key)) if (!options.hasOwnProperty(key))
throw new Error("Unknown confik key: " + key); throw new Error("Unknown config key: " + key);
return options[key]; return options[key];
}; };
exports.set = function(key, value) { exports.set = function(key, value) {
if (!options.hasOwnProperty(key)) if (!options.hasOwnProperty(key))
throw new Error("Unknown confik key: " + key); throw new Error("Unknown config key: " + key);
options[key] = value; options[key] = value;
}; };

View file

@ -235,6 +235,35 @@ var Editor = function(renderer, session) {
return this.session; return this.session;
}; };
/** related to: Document.setValue
* Editor.setValue(val [,dontSelect]) -> String
* - val (String): The new value to set for the document
* - cursorPos (number): 0: selectAll, -1 document start, 1 end
*
* Sets the current document to `val`.
**/
this.setValue = function(val, cursorPos) {
this.session.doc.setValue(val);
if (!cursorPos)
this.selectAll();
else if (cursorPos == 1)
this.navigateFileEnd();
else if (cursorPos == -1)
this.navigateFileStart();
return val;
};
/** related to: EditSession.getValue
* Editor.getValue() -> String
*
* Returns the current session's content.
**/
this.getValue = function() {
return this.session.getValue();
};
/** /**
* Editor.getSelection() -> String * Editor.getSelection() -> String
* *
@ -249,8 +278,8 @@ var Editor = function(renderer, session) {
* *
* {:VirtualRenderer.onResize} * {:VirtualRenderer.onResize}
**/ **/
this.resize = function() { this.resize = function(force) {
this.renderer.onResize(); this.renderer.onResize(force);
}; };
/** /**

View file

@ -57,9 +57,8 @@ function HashHandler(config, platform) {
this.commands[command.name] = command; this.commands[command.name] = command;
if (command.bindKey) { if (command.bindKey)
this._buildKeyHash(command); this._buildKeyHash(command);
}
}; };
this.removeCommand = function(command) { this.removeCommand = function(command) {
@ -81,6 +80,10 @@ function HashHandler(config, platform) {
this.bindKey = function(key, command) { this.bindKey = function(key, command) {
if(!key) if(!key)
return; return;
if (typeof command == "function") {
this.addCommand({exec: command, bindKey: key, name: key});
return;
}
var ckb = this.commmandKeyBinding; var ckb = this.commmandKeyBinding;
key.split("|").forEach(function(keyPart) { key.split("|").forEach(function(keyPart) {

View file

@ -119,7 +119,8 @@ var KeyBinding = function(editor) {
else else
success = toExecute.passEvent != true; success = toExecute.passEvent != true;
if (success && e) // do not stop input events to not break repeating
if (success && e && hashId != -1)
event.stopEvent(e); event.stopEvent(e);
return success; return success;

View file

@ -108,7 +108,9 @@ exports.handler = {
editor.removeListener("click", exports.onCursorMove); editor.removeListener("click", exports.onCursorMove);
util.noMode(editor); util.noMode(editor);
util.currentMode = "normal"; util.currentMode = "normal";
} },
actions: cmds.actions
}; };

View file

@ -52,18 +52,6 @@ var MOTION = 3;
var ACTION = 4; var ACTION = 4;
var HMARGIN = 8; // Minimum amount of line separation between margins; var HMARGIN = 8; // Minimum amount of line separation between margins;
exports.searchStore = {
current: "",
options: {
needle: "",
backwards: false,
wrap: true,
caseSensitive: false,
wholeWord: false,
regExp: false
}
};
var repeat = function repeat(fn, count, args) { var repeat = function repeat(fn, count, args) {
while (0 < count--) while (0 < count--)
fn.apply(this, args); fn.apply(this, args);
@ -88,7 +76,7 @@ var ensureScrollMargin = function(editor) {
} }
}; };
var actions = { var actions = exports.actions = {
"z": { "z": {
param: true, param: true,
fn: function(editor, range, count, param) { fn: function(editor, range, count, param) {
@ -288,16 +276,17 @@ var actions = {
}, },
":": { ":": {
fn: function(editor, range, count, param) { fn: function(editor, range, count, param) {
editor.blur(); // not implemented
txtConsoleInput.focus();
txtConsoleInput.setValue(":");
} }
}, },
"/": { "/": {
fn: function(editor, range, count, param) { fn: function(editor, range, count, param) {
editor.blur(); // not implemented
txtConsoleInput.focus(); }
txtConsoleInput.setValue("/"); },
"?": {
fn: function(editor, range, count, param) {
// not implemented
} }
}, },
".": { ".": {

View file

@ -67,6 +67,7 @@ function GutterHandler(mouseHandler) {
} }
mouseHandler.captureMouse(e, "selectByLines"); mouseHandler.captureMouse(e, "selectByLines");
return e.preventDefault();
}); });
} }

View file

@ -42,16 +42,12 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var dom = require("../lib/dom"); var dom = require("../lib/dom");
var BrowserFocus = require("../lib/browser_focus").BrowserFocus; var useragent = require("../lib/useragent");
var DRAG_OFFSET = 5; // pixels var DRAG_OFFSET = 5; // pixels
function DefaultHandlers(mouseHandler) { function DefaultHandlers(mouseHandler) {
mouseHandler.$clickSelection = null; mouseHandler.$clickSelection = null;
mouseHandler.browserFocus = new BrowserFocus();
var editor = mouseHandler.editor; var editor = mouseHandler.editor;
editor.setDefaultHandler("mousedown", this.onMouseDown.bind(mouseHandler)); editor.setDefaultHandler("mousedown", this.onMouseDown.bind(mouseHandler));
@ -69,14 +65,16 @@ function DefaultHandlers(mouseHandler) {
mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange"); mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange"); mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
mouseHandler.$focusWaitTimout = 250;
} }
(function() { (function() {
this.onMouseDown = function(ev) { this.onMouseDown = function(ev) {
this.mousedownEvent = ev;
var inSelection = ev.inSelection(); var inSelection = ev.inSelection();
var pos = ev.getDocumentPosition(); var pos = ev.getDocumentPosition();
this.mousedownEvent = ev;
var editor = this.editor; var editor = this.editor;
var _self = this; var _self = this;
@ -99,7 +97,10 @@ function DefaultHandlers(mouseHandler) {
// selection // selection
if (inSelection && !editor.isFocused()) { if (inSelection && !editor.isFocused()) {
editor.focus(); editor.focus();
return; if (this.$focusWaitTimout && !this.$clickSelection) {
// todo start select after focusWaitTimout passes
return;
}
} }
if (!inSelection || this.$clickSelection || ev.getShiftKey()) { if (!inSelection || this.$clickSelection || ev.getShiftKey()) {
@ -116,7 +117,8 @@ function DefaultHandlers(mouseHandler) {
} }
} }
this.captureMouse(ev) this.captureMouse(ev);
return ev.preventDefault();
}; };
this.startSelect = function(pos) { this.startSelect = function(pos) {

View file

@ -43,7 +43,8 @@ var Range = require("./range").Range;
var Selection = require("./selection").Selection; var Selection = require("./selection").Selection;
var onMouseDown = require("./mouse/multi_select_handler").onMouseDown; var onMouseDown = require("./mouse/multi_select_handler").onMouseDown;
var event = require("./lib/event"); var event = require("./lib/event");
exports.commands = require("./commands/multi_select_commands"); var commands = require("./commands/multi_select_commands");
exports.commands = commands.defaultCommands.concat(commands.multiSelectCommands);
// Todo: session.find or editor.findVolatile that returns range // Todo: session.find or editor.findVolatile that returns range
var Search = require("./search").Search; var Search = require("./search").Search;
@ -397,7 +398,7 @@ var Editor = require("./editor").Editor;
this.inMultiSelectMode = true; this.inMultiSelectMode = true;
this.setStyle("multiselect"); this.setStyle("multiselect");
this.keyBinding.addKeyboardHandler(exports.commands.keyboardHandler); this.keyBinding.addKeyboardHandler(commands.keyboardHandler);
this.commands.on("exec", this.$onMultiSelectExec); this.commands.on("exec", this.$onMultiSelectExec);
this.renderer.updateCursor(); this.renderer.updateCursor();
@ -410,7 +411,7 @@ var Editor = require("./editor").Editor;
this.inMultiSelectMode = false; this.inMultiSelectMode = false;
this.unsetStyle("multiselect"); this.unsetStyle("multiselect");
this.keyBinding.removeKeyboardHandler(exports.commands.keyboardHandler); this.keyBinding.removeKeyboardHandler(commands.keyboardHandler);
this.commands.removeEventListener("exec", this.$onMultiSelectExec); this.commands.removeEventListener("exec", this.$onMultiSelectExec);
this.renderer.updateCursor(); this.renderer.updateCursor();
@ -420,6 +421,8 @@ var Editor = require("./editor").Editor;
this.$onMultiSelectExec = function(e) { this.$onMultiSelectExec = function(e) {
var command = e.command; var command = e.command;
var editor = e.editor; var editor = e.editor;
if (!editor.multiSelect)
return;
if (!command.multiSelectAction) { if (!command.multiSelectAction) {
command.exec(editor, e.args || {}); command.exec(editor, e.args || {});
editor.multiSelect.addRange(editor.multiSelect.toOrientedRange()); editor.multiSelect.addRange(editor.multiSelect.toOrientedRange());
@ -724,7 +727,7 @@ function MultiSelect(editor) {
editor.on("changeSession", exports.onSessionChange.bind(editor)); editor.on("changeSession", exports.onSessionChange.bind(editor));
editor.on("mousedown", onMouseDown); editor.on("mousedown", onMouseDown);
editor.commands.addCommands(exports.commands.defaultCommands); editor.commands.addCommands(commands.defaultCommands);
addAltCursorListeners(editor); addAltCursorListeners(editor);
} }

View file

@ -55,7 +55,7 @@ var Range = require("./range").Range;
/** /**
* new Selection(session) * new Selection(session)
* - session (EditSession): The session to use * - session (EditSession): The session to use
* *
* Creates a new `Selection` object. * Creates a new `Selection` object.
* *
**/ **/
@ -88,7 +88,7 @@ var Selection = function(session) {
/** /**
* Selection.isEmpty() -> Boolean * Selection.isEmpty() -> Boolean
* *
* Returns `true` if the selection is empty. * Returns `true` if the selection is empty.
**/ **/
this.isEmpty = function() { this.isEmpty = function() {
@ -100,7 +100,7 @@ var Selection = function(session) {
/** /**
* Selection.isMultiLine() -> Boolean * Selection.isMultiLine() -> Boolean
* *
* Returns `true` if the selection is a multi-line. * Returns `true` if the selection is a multi-line.
**/ **/
this.isMultiLine = function() { this.isMultiLine = function() {
@ -113,7 +113,7 @@ var Selection = function(session) {
/** /**
* Selection.getCursor() -> Number * Selection.getCursor() -> Number
* *
* Gets the current position of the cursor. * Gets the current position of the cursor.
**/ **/
this.getCursor = function() { this.getCursor = function() {
@ -121,7 +121,7 @@ var Selection = function(session) {
}; };
/** /**
* Selection.setSelectionAnchor(row, column) * Selection.setSelectionAnchor(row, column)
* - row (Number): The new row * - row (Number): The new row
* - column (Number): The new column * - column (Number): The new column
* *
@ -138,7 +138,7 @@ var Selection = function(session) {
/** related to: Anchor.getPosition /** related to: Anchor.getPosition
* Selection.getSelectionAnchor() -> Object * Selection.getSelectionAnchor() -> Object
* *
* Returns an object containing the `row` and `column` of the calling selection anchor. * Returns an object containing the `row` and `column` of the calling selection anchor.
* *
**/ **/
@ -149,9 +149,9 @@ var Selection = function(session) {
return this.anchor.getPosition(); return this.anchor.getPosition();
}; };
/** /**
* Selection.getSelectionLead() -> Object * Selection.getSelectionLead() -> Object
* *
* Returns an object containing the `row` and `column` of the calling selection lead. * Returns an object containing the `row` and `column` of the calling selection lead.
**/ **/
this.getSelectionLead = function() { this.getSelectionLead = function() {
@ -159,9 +159,9 @@ var Selection = function(session) {
}; };
/** /**
* Selection.shiftSelection(columns) * Selection.shiftSelection(columns)
* - columns (Number): The number of columns to shift by * - columns (Number): The number of columns to shift by
* *
* Shifts the selection up (or down, if [[Selection.isBackwards `isBackwards()`]] is true) the given number of columns. * Shifts the selection up (or down, if [[Selection.isBackwards `isBackwards()`]] is true) the given number of columns.
* *
**/ **/
@ -188,7 +188,7 @@ var Selection = function(session) {
/** /**
* Selection.isBackwards() -> Boolean * Selection.isBackwards() -> Boolean
* *
* Returns `true` if the selection is going backwards in the document. * Returns `true` if the selection is going backwards in the document.
**/ **/
this.isBackwards = function() { this.isBackwards = function() {
@ -199,7 +199,7 @@ var Selection = function(session) {
/** /**
* Selection.getRange() -> Range * Selection.getRange() -> Range
* *
* [Returns the [[Range `Range`]] for the selected text.]{: #Selection.getRange} * [Returns the [[Range `Range`]] for the selected text.]{: #Selection.getRange}
**/ **/
this.getRange = function() { this.getRange = function() {
@ -218,8 +218,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.clearSelection() * Selection.clearSelection()
* *
* [Empties the selection (by de-selecting it). This function also emits the `'changeSelection'` event.]{: #Selection.clearSelection} * [Empties the selection (by de-selecting it). This function also emits the `'changeSelection'` event.]{: #Selection.clearSelection}
**/ **/
this.clearSelection = function() { this.clearSelection = function() {
@ -230,24 +230,25 @@ var Selection = function(session) {
}; };
/** /**
* Selection.selectAll() * Selection.selectAll()
* *
* Selects all the text in the document. * Selects all the text in the document.
**/ **/
this.selectAll = function() { this.selectAll = function() {
var lastRow = this.doc.getLength() - 1; var lastRow = this.doc.getLength() - 1;
this.setSelectionAnchor(lastRow, this.doc.getLine(lastRow).length); this.setSelectionAnchor(0, 0);
this.moveCursorTo(0, 0); this.moveCursorTo(lastRow, this.doc.getLine(lastRow).length);
}; };
/** /**
* Selection.setSelectionRange(range, reverse) * Selection.setSelectionRange(range, reverse)
* - range (Range): The range of text to select * - range (Range): The range of text to select
* - reverse (Boolean): Indicates if the range should go backwards (`true`) or not * - reverse (Boolean): Indicates if the range should go backwards (`true`) or not
* *
* Sets the selection to the provided range. * Sets the selection to the provided range.
* *
**/ **/
this.setRange =
this.setSelectionRange = function(range, reverse) { this.setSelectionRange = function(range, reverse) {
if (reverse) { if (reverse) {
this.setSelectionAnchor(range.end.row, range.end.column); this.setSelectionAnchor(range.end.row, range.end.column);
@ -268,7 +269,7 @@ var Selection = function(session) {
}; };
/** /**
* Selection.selectTo(row, column) * Selection.selectTo(row, column)
* - row (Number): The row to select to * - row (Number): The row to select to
* - column (Number): The column to select to * - column (Number): The column to select to
* *
@ -282,9 +283,9 @@ var Selection = function(session) {
}; };
/** /**
* Selection.selectToPosition(pos) * Selection.selectToPosition(pos)
* - pos (Object): An object containing the row and column * - pos (Object): An object containing the row and column
* *
* Moves the selection cursor to the row and column indicated by `pos`. * Moves the selection cursor to the row and column indicated by `pos`.
* *
**/ **/
@ -295,8 +296,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.selectUp() * Selection.selectUp()
* *
* Moves the selection up one row. * Moves the selection up one row.
**/ **/
this.selectUp = function() { this.selectUp = function() {
@ -304,8 +305,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.selectDown() * Selection.selectDown()
* *
* Moves the selection down one row. * Moves the selection down one row.
**/ **/
this.selectDown = function() { this.selectDown = function() {
@ -313,8 +314,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.selectRight() * Selection.selectRight()
* *
* Moves the selection right one column. * Moves the selection right one column.
**/ **/
this.selectRight = function() { this.selectRight = function() {
@ -322,8 +323,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.selectLeft() * Selection.selectLeft()
* *
* Moves the selection left one column. * Moves the selection left one column.
**/ **/
this.selectLeft = function() { this.selectLeft = function() {
@ -331,8 +332,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.selectLineStart() * Selection.selectLineStart()
* *
* Moves the selection to the beginning of the current line. * Moves the selection to the beginning of the current line.
**/ **/
this.selectLineStart = function() { this.selectLineStart = function() {
@ -340,8 +341,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.selectLineEnd() * Selection.selectLineEnd()
* *
* Moves the selection to the end of the current line. * Moves the selection to the end of the current line.
**/ **/
this.selectLineEnd = function() { this.selectLineEnd = function() {
@ -349,8 +350,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.selectFileEnd() * Selection.selectFileEnd()
* *
* Moves the selection to the end of the file. * Moves the selection to the end of the file.
**/ **/
this.selectFileEnd = function() { this.selectFileEnd = function() {
@ -358,8 +359,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.selectFileStart() * Selection.selectFileStart()
* *
* Moves the selection to the start of the file. * Moves the selection to the start of the file.
**/ **/
this.selectFileStart = function() { this.selectFileStart = function() {
@ -367,8 +368,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.selectWordRight() * Selection.selectWordRight()
* *
* Moves the selection to the first word on the right. * Moves the selection to the first word on the right.
**/ **/
this.selectWordRight = function() { this.selectWordRight = function() {
@ -376,8 +377,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.selectWordLeft() * Selection.selectWordLeft()
* *
* Moves the selection to the first word on the left. * Moves the selection to the first word on the left.
**/ **/
this.selectWordLeft = function() { this.selectWordLeft = function() {
@ -385,8 +386,8 @@ var Selection = function(session) {
}; };
/** related to: EditSession.getWordRange /** related to: EditSession.getWordRange
* Selection.selectWord() * Selection.selectWord()
* *
* Moves the selection to highlight the entire word. * Moves the selection to highlight the entire word.
**/ **/
this.getWordRange = function(row, column) { this.getWordRange = function(row, column) {
@ -403,8 +404,8 @@ var Selection = function(session) {
}; };
/** related to: EditSession.getAWordRange /** related to: EditSession.getAWordRange
* Selection.selectAWord() * Selection.selectAWord()
* *
* Selects a word, including its right whitespace. * Selects a word, including its right whitespace.
**/ **/
this.selectAWord = function() { this.selectAWord = function() {
@ -430,9 +431,9 @@ var Selection = function(session) {
return new Range(rowStart, 0, rowEnd + 1, 0); return new Range(rowStart, 0, rowEnd + 1, 0);
}; };
/** /**
* Selection.selectLine() * Selection.selectLine()
* *
* Selects the entire line. * Selects the entire line.
**/ **/
this.selectLine = function() { this.selectLine = function() {
@ -440,8 +441,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.moveCursorUp() * Selection.moveCursorUp()
* *
* Moves the cursor up one row. * Moves the cursor up one row.
**/ **/
this.moveCursorUp = function() { this.moveCursorUp = function() {
@ -449,8 +450,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.moveCursorDown() * Selection.moveCursorDown()
* *
* Moves the cursor down one row. * Moves the cursor down one row.
**/ **/
this.moveCursorDown = function() { this.moveCursorDown = function() {
@ -458,8 +459,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.moveCursorLeft() * Selection.moveCursorLeft()
* *
* Moves the cursor left one column. * Moves the cursor left one column.
**/ **/
this.moveCursorLeft = function() { this.moveCursorLeft = function() {
@ -484,8 +485,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.moveCursorRight() * Selection.moveCursorRight()
* *
* Moves the cursor right one column. * Moves the cursor right one column.
**/ **/
this.moveCursorRight = function() { this.moveCursorRight = function() {
@ -510,8 +511,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.moveCursorLineStart() * Selection.moveCursorLineStart()
* *
* Moves the cursor to the start of the line. * Moves the cursor to the start of the line.
**/ **/
this.moveCursorLineStart = function() { this.moveCursorLineStart = function() {
@ -543,8 +544,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.moveCursorLineEnd() * Selection.moveCursorLineEnd()
* *
* Moves the cursor to the end of the line. * Moves the cursor to the end of the line.
**/ **/
this.moveCursorLineEnd = function() { this.moveCursorLineEnd = function() {
@ -558,8 +559,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.moveCursorFileEnd() * Selection.moveCursorFileEnd()
* *
* Moves the cursor to the end of the file. * Moves the cursor to the end of the file.
**/ **/
this.moveCursorFileEnd = function() { this.moveCursorFileEnd = function() {
@ -569,8 +570,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.moveCursorFileStart() * Selection.moveCursorFileStart()
* *
* Moves the cursor to the start of the file. * Moves the cursor to the start of the file.
**/ **/
this.moveCursorFileStart = function() { this.moveCursorFileStart = function() {
@ -578,8 +579,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.moveCursorLongWordRight() * Selection.moveCursorLongWordRight()
* *
* Moves the cursor to the word on the right. * Moves the cursor to the word on the right.
**/ **/
this.moveCursorLongWordRight = function() { this.moveCursorLongWordRight = function() {
@ -598,14 +599,14 @@ var Selection = function(session) {
this.moveCursorTo(fold.end.row, fold.end.column); this.moveCursorTo(fold.end.row, fold.end.column);
return; return;
} }
// first skip space // first skip space
if (match = this.session.nonTokenRe.exec(rightOfCursor)) { if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
column += this.session.nonTokenRe.lastIndex; column += this.session.nonTokenRe.lastIndex;
this.session.nonTokenRe.lastIndex = 0; this.session.nonTokenRe.lastIndex = 0;
rightOfCursor = line.substring(column); rightOfCursor = line.substring(column);
} }
// if at line end proceed with next line // if at line end proceed with next line
if (column >= line.length) { if (column >= line.length) {
this.moveCursorTo(row, line.length); this.moveCursorTo(row, line.length);
@ -614,7 +615,7 @@ var Selection = function(session) {
this.moveCursorWordRight(); this.moveCursorWordRight();
return; return;
} }
// advance to the end of the next token // advance to the end of the next token
if (match = this.session.tokenRe.exec(rightOfCursor)) { if (match = this.session.tokenRe.exec(rightOfCursor)) {
column += this.session.tokenRe.lastIndex; column += this.session.tokenRe.lastIndex;
@ -625,8 +626,8 @@ var Selection = function(session) {
}; };
/** /**
* Selection.moveCursorLongWordLeft() * Selection.moveCursorLongWordLeft()
* *
* Moves the cursor to the word on the left. * Moves the cursor to the word on the left.
**/ **/
this.moveCursorLongWordLeft = function() { this.moveCursorLongWordLeft = function() {
@ -644,19 +645,19 @@ var Selection = function(session) {
if (str == null) { if (str == null) {
str = this.doc.getLine(row).substring(0, column) str = this.doc.getLine(row).substring(0, column)
} }
var leftOfCursor = lang.stringReverse(str); var leftOfCursor = lang.stringReverse(str);
var match; var match;
this.session.nonTokenRe.lastIndex = 0; this.session.nonTokenRe.lastIndex = 0;
this.session.tokenRe.lastIndex = 0; this.session.tokenRe.lastIndex = 0;
// skip whitespace // skip whitespace
if (match = this.session.nonTokenRe.exec(leftOfCursor)) { if (match = this.session.nonTokenRe.exec(leftOfCursor)) {
column -= this.session.nonTokenRe.lastIndex; column -= this.session.nonTokenRe.lastIndex;
leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex); leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
this.session.nonTokenRe.lastIndex = 0; this.session.nonTokenRe.lastIndex = 0;
} }
// if at begin of the line proceed in line above // if at begin of the line proceed in line above
if (column <= 0) { if (column <= 0) {
this.moveCursorTo(row, 0); this.moveCursorTo(row, 0);
@ -762,7 +763,7 @@ var Selection = function(session) {
}; };
/** related to: EditSession.documentToScreenPosition /** related to: EditSession.documentToScreenPosition
* Selection.moveCursorBy(rows, chars) * Selection.moveCursorBy(rows, chars)
* - rows (Number): The number of rows to move by * - rows (Number): The number of rows to move by
* - chars (Number): The number of characters to move by * - chars (Number): The number of characters to move by
* *
@ -788,9 +789,9 @@ var Selection = function(session) {
}; };
/** /**
* Selection.moveCursorToPosition(position) * Selection.moveCursorToPosition(position)
* - position (Object): The position to move to * - position (Object): The position to move to
* *
* Moves the selection to the position indicated by its `row` and `column`. * Moves the selection to the position indicated by its `row` and `column`.
**/ **/
this.moveCursorToPosition = function(position) { this.moveCursorToPosition = function(position) {
@ -798,7 +799,7 @@ var Selection = function(session) {
}; };
/** /**
* Selection.moveCursorTo(row, column, keepDesiredColumn) * Selection.moveCursorTo(row, column, keepDesiredColumn)
* - row (Number): The row to move to * - row (Number): The row to move to
* - column (Number): The column to move to * - column (Number): The column to move to
* - keepDesiredColumn (Boolean): [If `true`, the cursor move does not respect the previous column]{: #preventUpdateBool} * - keepDesiredColumn (Boolean): [If `true`, the cursor move does not respect the previous column]{: #preventUpdateBool}
@ -822,7 +823,7 @@ var Selection = function(session) {
}; };
/** /**
* Selection.moveCursorToScreen(row, column, keepDesiredColumn) * Selection.moveCursorToScreen(row, column, keepDesiredColumn)
* - row (Number): The row to move to * - row (Number): The row to move to
* - column (Number): The column to move to * - column (Number): The column to move to
* - keepDesiredColumn (Boolean): {:preventUpdateBool} * - keepDesiredColumn (Boolean): {:preventUpdateBool}

View file

@ -65,7 +65,11 @@ if (location.search)
testNames = location.search.substr(1).split(",") testNames = location.search.substr(1).split(",")
require(testNames, function() { require(testNames, function() {
var tests = testNames.map(require); var tests = testNames.map(function(x) {
var module = require(x);
module.href = x;
return module;
});
async.list(tests) async.list(tests)
.expand(function(test) { .expand(function(test) {
@ -73,6 +77,12 @@ require(testNames, function() {
}, AsyncTest.TestGenerator) }, AsyncTest.TestGenerator)
.run() .run()
.each(function(test, next) { .each(function(test, next) {
if (test.index == 1 && test.context.href) {
var href = test.context.href;
var node = document.createElement("div");
node.innerHTML = "<a href='?" + href + "'>" + href.replace(/^ace\//, "") + "</a>";
log.appendChild(node);
}
var node = document.createElement("div"); var node = document.createElement("div");
node.className = test.passed ? "passed" : "failed"; node.className = test.passed ? "passed" : "failed";