view release on metacpan or search on metacpan
inc/Module/Install/Fetch.pm view on Meta::CPAN
require Cwd;
my $dir = Cwd::getcwd();
chdir $args{local_dir} or return if exists $args{local_dir};
if (eval { require LWP::Simple; 1 }) {
LWP::Simple::mirror($args{url}, $file);
}
elsif (eval { require Net::FTP; 1 }) { eval {
# use Net::FTP to get past firewall
my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600);
$ftp->login("anonymous", 'anonymous@example.com');
$ftp->cwd($path);
$ftp->binary;
$ftp->get($file) or (warn("$!\n"), return);
$ftp->quit;
} }
elsif (my $ftp = $self->can_run('ftp')) { eval {
# no Net::FTP, fallback to ftp.exe
require FileHandle;
my $fh = FileHandle->new;
share/endpoint/www/js/codemirror.js view on Meta::CPAN
var endTime = new Date().getTime() + self.options.lineNumberTime;
while (node) {
setNum(next++, node.previousSibling);
for (; node && !win.isBR(node); node = node.nextSibling) {
var bott = node.offsetTop + node.offsetHeight;
while (scroller.offsetHeight && bott - 3 > pos) setNum(" ");
}
if (node) node = node.nextSibling;
if (new Date().getTime() > endTime) {
commitChanges();
pending = setTimeout(work, self.options.lineNumberDelay);
return;
}
}
while (lineNum) setNum(next++);
commitChanges();
doScroll();
}
function start(firstTime) {
doScroll();
ensureEnoughLineNumbers(firstTime);
node = body.firstChild;
lineNum = scroller.firstChild;
pos = 0;
next = self.options.firstLineNumber;
work();
}
start(true);
var pending = null;
function update() {
if (pending) clearTimeout(pending);
if (self.editor.allClean()) start();
else pending = setTimeout(update, 200);
}
self.updateNumbers = update;
var onScroll = win.addEventHandler(win, "scroll", doScroll, true),
onResize = win.addEventHandler(win, "resize", update, true);
clear = function(){
if (pending) clearTimeout(pending);
if (self.updateNumbers == update) self.updateNumbers = null;
onScroll();
onResize();
};
}
(this.options.textWrapping || this.options.styleNumbers ? wrapping : nonWrapping)();
},
setDynamicHeight: function() {
var self = this, activity = self.options.cursorActivity, win = self.win, body = win.document.body,
share/endpoint/www/js/codemirror.js view on Meta::CPAN
if (node) {
lineHeight = node.offsetHeight;
computedHeight = node.offsetTop + (1 + trailingLines) * lineHeight;
}
else if (lineHeight) {
computedHeight = trailingLines * lineHeight;
}
if (computedHeight)
self.wrapping.style.height = Math.max(vmargin + computedHeight, self.options.minHeight) + "px";
}
setTimeout(updateHeight, 300);
self.options.cursorActivity = function(x) {
if (activity) activity(x);
clearTimeout(timeout);
timeout = setTimeout(updateHeight, 100);
};
}
};
CodeMirror.InvalidLineHandle = {toString: function(){return "CodeMirror.InvalidLineHandle";}};
CodeMirror.replace = function(element) {
if (typeof element == "string")
element = document.getElementById(element);
return function(newElement) {
share/endpoint/www/js/editor.js view on Meta::CPAN
reroutePasteEvent: function() {
if (this.capturingPaste || window.opera || (gecko && gecko >= 20101026)) return;
this.capturingPaste = true;
var te = window.frameElement.CodeMirror.textareaHack;
parent.focus();
te.value = "";
te.focus();
var self = this;
this.parent.setTimeout(function() {
self.capturingPaste = false;
window.focus();
if (self.selectionSnapshot) // IE hack
window.select.setBookmark(self.container, self.selectionSnapshot);
var text = te.value;
if (text) {
self.replaceSelection(text);
select.scrollToCursor(self.container);
}
}, 10);
share/endpoint/www/js/editor.js view on Meta::CPAN
// from happening, so we have to cancel enter and tab again
// here.
if ((this.frozen && (!this.keyFilter || this.keyFilter(event.keyCode || event.code, event))) ||
event.code == 13 || (event.code == 9 && this.options.tabMode != "default") ||
(event.code == 32 && event.shiftKey && this.options.tabMode == "default"))
event.stop();
else if (mac && (event.ctrlKey || event.metaKey) && event.character == "v") {
this.reroutePasteEvent();
}
else if (electric && electric.indexOf(event.character) != -1)
this.parent.setTimeout(function(){self.indentAtCursor(null);}, 0);
// Work around a bug where pressing backspace at the end of a
// line, or delete at the start, often causes the cursor to jump
// to the start of the line in Opera 10.60.
else if (brokenOpera) {
if (event.code == 8) { // backspace
var sel = select.selectionTopNode(this.container), self = this,
next = sel ? sel.nextSibling : this.container.firstChild;
if (sel !== false && next && isBR(next))
this.parent.setTimeout(function(){
if (select.selectionTopNode(self.container) == next)
select.focusAfterNode(next.previousSibling, self.container);
}, 20);
}
else if (event.code == 46) { // delete
var sel = select.selectionTopNode(this.container), self = this;
if (sel && isBR(sel)) {
this.parent.setTimeout(function(){
if (select.selectionTopNode(self.container) != sel)
select.focusAfterNode(sel, self.container);
}, 20);
}
}
}
// In 533.* WebKit versions, when the document is big, typing
// something at the end of a line causes the browser to do some
// kind of stupid heavy operation, creating delays of several
// seconds before the typed characters appear. This very crude
// hack inserts a temporary zero-width space after the cursor to
// make it not be at the end of the line.
else if (slowWebkit) {
var sel = select.selectionTopNode(this.container),
next = sel ? sel.nextSibling : this.container.firstChild;
// Doesn't work on empty lines, for some reason those always
// trigger the delay.
if (sel && next && isBR(next) && !isBR(sel)) {
var cheat = document.createTextNode("\u200b");
this.container.insertBefore(cheat, next);
this.parent.setTimeout(function() {
if (cheat.nodeValue == "\u200b") removeElement(cheat);
else cheat.nodeValue = cheat.nodeValue.replace("\u200b", "");
}, 20);
}
}
// Magic incantation that works abound a webkit bug when you
// can't type on a blank line following a line that's wider than
// the window.
if (webkit && !this.options.textWrapping)
setTimeout(function () {
var node = select.selectionTopNode(self.container, true);
if (node && node.nodeType == 3 && node.previousSibling && isBR(node.previousSibling)
&& node.nextSibling && isBR(node.nextSibling))
node.parentNode.replaceChild(document.createElement("BR"), node.previousSibling);
}, 50);
},
// Mark the node at the cursor dirty when a non-safe key is
// released.
keyUp: function(event) {
share/endpoint/www/js/editor.js view on Meta::CPAN
line = nextLine;
}
if (i == 0) return false; // Already at last line
select.setCursorPos(this.container, {node: line, offset: 0});
select.scrollToCursor(this.container);
return true;
},
// Delay (or initiate) the next paren highlight event.
scheduleParenHighlight: function() {
if (this.parenEvent) this.parent.clearTimeout(this.parenEvent);
var self = this;
this.parenEvent = this.parent.setTimeout(function(){self.highlightParens();}, 300);
},
// Take the token before the cursor. If it contains a character in
// '()[]{}', search for the matching paren/brace/bracket, and
// highlight them in green for a moment, or red if no proper match
// was found.
highlightParens: function(jump, fromKey) {
var self = this;
// give the relevant nodes a colour.
function highlight(node, ok) {
share/endpoint/www/js/editor.js view on Meta::CPAN
node.style.color = "";
}
}
if (!fromKey && self.highlighted) {
unhighlight(self.highlighted[0]);
unhighlight(self.highlighted[1]);
}
if (!window || !window.parent || !window.select) return;
// Clear the event property.
if (this.parenEvent) this.parent.clearTimeout(this.parenEvent);
this.parenEvent = null;
// Extract a 'paren' from a piece of text.
function paren(node) {
if (node.currentText) {
var match = node.currentText.match(/^[\s\u00a0]*([\(\)\[\]{}])[\s\u00a0]*$/);
return match && match[1];
}
}
// Determine the direction a paren is facing.
share/endpoint/www/js/editor.js view on Meta::CPAN
this.highlight(found.node, endOfLine(found.node));
// Needed because in some corner cases a highlight does not
// reach a node.
found.node.dirty = false;
continue;
}
else {
highlight(cursor, found.status);
highlight(found.node, found.status);
if (fromKey)
self.parent.setTimeout(function() {unhighlight(cursor); unhighlight(found.node);}, 500);
else
self.highlighted = [cursor, found.node];
if (jump && found.node)
select.focusAfterNode(found.node.previousSibling, this.container);
break;
}
}
},
// Adjust the amount of whitespace at the start of the line that
share/endpoint/www/js/editor.js view on Meta::CPAN
cursorActivity: function(safe) {
// pagehide event hack above
if (this.unloaded) {
window.document.designMode = "off";
window.document.designMode = "on";
this.unloaded = false;
}
if (internetExplorer) {
this.container.createTextRange().execCommand("unlink");
clearTimeout(this.saveSelectionSnapshot);
var self = this;
this.saveSelectionSnapshot = setTimeout(function() {
var snapshot = select.getBookmark(self.container);
if (snapshot) self.selectionSnapshot = snapshot;
}, 200);
}
var activity = this.options.cursorActivity;
if (!safe || activity) {
var cursor = select.selectionTopNode(this.container, false);
if (cursor === false || !this.container.firstChild) return;
cursor = cursor || this.container.firstChild;
share/endpoint/www/js/editor.js view on Meta::CPAN
allClean: function() {
return !this.dirty.length;
},
// Cause a highlight pass to happen in options.passDelay
// milliseconds. Clear the existing timeout, if one exists. This
// way, the passes do not happen while the user is typing, and
// should as unobtrusive as possible.
scheduleHighlight: function() {
// Timeouts are routed through the parent window, because on
// some browsers designMode windows do not fire timeouts.
var self = this;
this.parent.clearTimeout(this.highlightTimeout);
this.highlightTimeout = this.parent.setTimeout(function(){self.highlightDirty();}, this.options.passDelay);
},
// Fetch one dirty node, and remove it from the dirty set.
getDirtyNode: function() {
while (this.dirty.length > 0) {
var found = this.dirty.pop();
// IE8 sometimes throws an unexplainable 'invalid argument'
// exception for found.parentNode
try {
// If the node has been coloured in the meantime, or is no
share/endpoint/www/js/editor.js view on Meta::CPAN
var newPos = result ? (result.node && result.node.nextSibling) : null;
pos = (pos == newPos) ? null : newPos;
self.delayScanning();
};
},
// Starts the continuous scanning process for this document after
// a given interval.
delayScanning: function() {
if (this.scanner) {
this.parent.clearTimeout(this.documentScan);
this.documentScan = this.parent.setTimeout(this.scanner, this.options.continuousScanning);
}
},
// The function that does the actual highlighting/colouring (with
// help from the parser and the DOM normalizer). Its interface is
// rather overcomplicated, because it is used in different
// situations: ensuring that a certain line is highlighted, or
// highlighting up to X milliseconds starting from a certain
// point. The 'from' argument gives the node at which it should
// start. If this is null, it will start at the beginning of the
share/endpoint/www/js/editor.js view on Meta::CPAN
dirty: lineDirty};
}
};
return Editor;
})();
addEventHandler(window, "load", function() {
var CodeMirror = window.frameElement.CodeMirror;
var e = CodeMirror.editor = new Editor(CodeMirror.options);
this.parent.setTimeout(method(CodeMirror, "init"), 0);
});
share/endpoint/www/js/undo.js view on Meta::CPAN
* spanned these nodes is added to the undo history. Undoing a change
* means taking such a chain off the undo history, restoring its
* content (text is saved per line) and linking it back into the
* document.
*/
// A history object needs to know about the DOM container holding the
// document, the maximum amount of undo levels it should store, the
// delay (of no input) after which it commits a set of changes, and,
// unfortunately, the 'parent' window -- a window that is not in
// designMode, and on which setTimeout works in every browser.
function UndoHistory(container, maxDepth, commitDelay, editor) {
this.container = container;
this.maxDepth = maxDepth; this.commitDelay = commitDelay;
this.editor = editor; this.parent = editor.parent;
// This line object represents the initial, empty editor.
var initial = {text: "", from: null, to: null};
// As the borders between lines are represented by BR elements, the
// start of the first line and the end of the last one are
// represented by null. Since you can not store any properties
// (links to line objects) in null, these properties are used in
share/endpoint/www/js/undo.js view on Meta::CPAN
// History is the set of committed changes, touched is the set of
// nodes touched since the last commit.
this.history = []; this.redoHistory = []; this.touched = [];
}
UndoHistory.prototype = {
// Schedule a commit (if no other touches come in for commitDelay
// milliseconds).
scheduleCommit: function() {
var self = this;
this.parent.clearTimeout(this.commitTimeout);
this.commitTimeout = this.parent.setTimeout(function(){self.tryCommit();}, this.commitDelay);
},
// Mark a node as touched. Null is a valid argument.
touch: function(node) {
this.setTouched(node);
this.scheduleCommit();
},
// Undo the last change.
undo: function() {
share/endpoint/www/js/undo.js view on Meta::CPAN
// Commit unless there are pending dirty nodes.
tryCommit: function() {
if (!window || !window.parent || !window.UndoHistory) return; // Stop when frame has been unloaded
if (this.editor.highlightDirty()) this.commit(true);
else this.scheduleCommit();
},
// Check whether the touched nodes hold any changes, if so, commit
// them.
commit: function(doNotHighlight) {
this.parent.clearTimeout(this.commitTimeout);
// Make sure there are no pending dirty nodes.
if (!doNotHighlight) this.editor.highlightDirty(true);
// Build set of chains.
var chains = this.touchedChains(), self = this;
if (chains.length) {
this.addUndoLevel(this.updateTo(chains, "linkChain"));
this.redoHistory = [];
this.notifyEnvironment();
}