Text editor: updated to use fileSystem, cleaned up

This commit is contained in:
Ben Wells
2012-06-29 14:20:43 -07:00
parent 2c989fcf53
commit 9d6cbfcef8
50 changed files with 385 additions and 2249 deletions

View File

@@ -1,5 +1,5 @@
function onLaunched(launchData) {
chrome.appWindow.create('demo.html', function(win) {
chrome.appWindow.create('editor.html', function(win) {
win.launchData = launchData;
});
}

View File

@@ -1,218 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Text Editor Demo</title>
<meta name="author" content="Fabian Jakobs">
<link rel="stylesheet" href="styles.css" type="text/css" media="screen" charset="utf-8">
</head>
<body>
<div id="toolbar">
<div id="new" class="toolbarbutton enabled"></div>
<div id="openfile" class="toolbarbutton enabled"></div>
<div id="openweb" class="toolbarbutton enabled"></div>
<div id="save" class="toolbarbutton hidden"></div>
<div id="saveas" class="toolbarbutton enabled"></div>
<div id="config" class="toolbarbutton enabled"></div>
<input id="openfileinput" class="hidden" type="file"></input>
<a id="savelink" class="hidden"></a>
</div>
<div id="controlspanel">
<img id="logo" src="logo.gif">
<table id="controls">
<tr>
<td >
<label for="mode">Syntax</label>
</td><td>
<select id="mode" size="1">
</select>
</td>
</tr>
<tr>
<td>
<label for="split">Split</label>
</td><td>
<select id="split" size="1">
<option value="none">None</option>
<option value="below">Below</option>
<option value="beside">Beside</option>
</select>
</td>
</tr>
<tr>
<td >
<label for="theme">Theme</label>
</td><td>
<select id="theme" size="1">
<option value="ace/theme/chrome">Chrome</option>
<option value="ace/theme/clouds">Clouds</option>
<option value="ace/theme/clouds_midnight">Clouds Midnight</option>
<option value="ace/theme/cobalt">Cobalt</option>
<option value="ace/theme/crimson_editor">Crimson Editor</option>
<option value="ace/theme/dawn">Dawn</option>
<option value="ace/theme/dreamweaver">Dreamweaver</option>
<option value="ace/theme/eclipse">Eclipse</option>
<option value="ace/theme/idle_fingers">idleFingers</option>
<option value="ace/theme/kr_theme">krTheme</option>
<option value="ace/theme/merbivore">Merbivore</option>
<option value="ace/theme/merbivore_soft">Merbivore Soft</option>
<option value="ace/theme/mono_industrial">Mono Industrial</option>
<option value="ace/theme/monokai">Monokai</option>
<option value="ace/theme/pastel_on_dark">Pastel on dark</option>
<option value="ace/theme/solarized_dark">Solarized Dark</option>
<option value="ace/theme/solarized_light">Solarized Light</option>
<option value="ace/theme/textmate" selected="selected">TextMate</option>
<option value="ace/theme/twilight">Twilight</option>
<option value="ace/theme/tomorrow">Tomorrow</option>
<option value="ace/theme/tomorrow_night">Tomorrow Night</option>
<option value="ace/theme/tomorrow_night_blue">Tomorrow Night Blue</option>
<option value="ace/theme/tomorrow_night_bright">Tomorrow Night Bright</option>
<option value="ace/theme/tomorrow_night_eighties">Tomorrow Night 80s</option>
<option value="ace/theme/vibrant_ink">Vibrant Ink</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="fontsize">Font Size</label>
</td><td>
<select id="fontsize" size="1">
<option value="10px">10px</option>
<option value="11px">11px</option>
<option value="12px">12px</option>
<option value="14px">14px</option>
<option value="16px" selected="selected">16px</option>
<option value="20px">20px</option>
<option value="24px">24px</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="folding">Code Folding</label>
</td><td>
<select id="folding" size="1">
<option value="manual">manual</option>
<option value="markbegin" selected="selected">mark begin</option>
<option value="markbeginend">mark begin and end</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="select_style">Full Line Selection</label>
</td><td>
<input type="checkbox" name="select_style" id="select_style" checked>
</td>
</tr>
<tr>
<td>
<label for="highlight_active">Highlight Active Line</label>
</td><td>
<input type="checkbox" name="highlight_active" id="highlight_active" checked>
</td>
</tr>
<tr>
<td >
<label for="show_hidden">Show Invisibles</label>
</td><td>
<input type="checkbox" name="show_hidden" id="show_hidden" checked>
</td>
</tr>
<tr>
<td >
<label for="show_hscroll">Persistent HScroll</label>
</td><td>
<input type="checkbox" name="show_hscroll" id="show_hscroll">
</td>
</tr>
<tr>
<td >
<label for="animate_scroll">Animate scrolling</label>
</td><td>
<input type="checkbox" name="animate_scroll" id="animate_scroll">
</td>
</tr>
<tr>
<td >
<label for="keybinding">Key Binding</label>
</td><td>
<select id="keybinding" size="1">
<option value="ace">Ace</option>
<option value="vim">Vim</option>
<option value="emacs">Emacs</option>
<option value="custom">Custom</option>
</select>
</td>
</tr>
<tr>
<td >
<label for="soft_wrap">Soft Wrap</label>
</td><td>
<select id="soft_wrap" size="1">
<option value="off">Off</option>
<option value="40">40 Chars</option>
<option value="80">80 Chars</option>
<option value="free">Free</option>
</select>
</td>
</tr>
<tr>
<td >
<label for="show_gutter">Show Gutter</label>
</td><td>
<input type="checkbox" id="show_gutter" checked>
</td>
</tr>
<tr>
<td >
<label for="show_print_margin">Show Print Margin</label>
</td><td>
<input type="checkbox" id="show_print_margin" checked>
</td>
</tr>
<tr>
<td >
<label for="soft_tab">Use Soft Tab</label>
</td><td>
<input type="checkbox" id="soft_tab" checked>
</td>
</tr>
<tr>
<td >
<label for="highlight_selected_word">Highlight selected word</label>
</td>
<td>
<input type="checkbox" id="highlight_selected_word" checked>
</td>
</tr>
<tr>
<td >
<label for="enable_behaviours">Enable Behaviours</label>
</td>
<td>
<input type="checkbox" id="enable_behaviours">
</td>
</tr>
</table>
</div>
<div id="editor">
</div>
<!-- DEVEL-->
<script src="require_config.js" type="text/javascript"></script>
<script src="require.js" data-main="demo" type="text/javascript"></script>
<!--DEVEL -->
<!--PACKAGE
<script src="demo/kitchen-sink/kitchen-sink-uncompressed.js" data-ace-suffix="-uncompressed.js" data-ace-base="demo/kitchen-sink" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
require("kitchen-sink/demo");
</script>
<!--PACKAGE-->
</body>
</html>

View File

@@ -1,557 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Skywriter.
*
* The Initial Developer of the Original Code is
* Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Kevin Dangoor (kdangoor@mozilla.com)
* Julian Viereck <julian DOT viereck AT gmail DOT com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
require("ace/lib/fixoldbrowsers");
require("ace/config").init();
var env = {};
var event = require("ace/lib/event");
var theme = require("ace/theme/textmate");
var EditSession = require("ace/edit_session").EditSession;
var UndoManager = require("ace/undomanager").UndoManager;
var vim = require("ace/keyboard/keybinding/vim").Vim;
var emacs = require("ace/keyboard/keybinding/emacs").Emacs;
var HashHandler = require("ace/keyboard/hash_handler").HashHandler;
var modesByName;
// workers do not work for file:
if (location.protocol == "file:")
EditSession.prototype.$useWorker = false;
var Doc = function(name, desc, file) {
this.name = name;
this.desc = desc;
this.doc = new EditSession(file);
this.doc.modeName = name;
this.doc.setUndoManager(new UndoManager());
};
var WrappedDoc = function(name, desc, file) {
Doc.apply(this, arguments);
this.doc.setUseWrapMode(true);
this.doc.setWrapLimitRange(80, 80);
};
var Mode = function(name, desc, extensions) {
this.name = name;
this.desc = desc;
this.mode = "ace/mode/" + name;
this.extRe = new RegExp("^.*\\.(" + extensions.join("|") + ")$", "g");
};
Mode.prototype.supportsFile = function(filename) {
return filename.match(this.extRe);
};
var modes = [
new Mode("c_cpp", "C/C++", ["c", "cpp", "cc", "cxx", "h", "hpp"]),
new Mode("clojure", "Clojure", ["clj"]),
new Mode("coffee", "CoffeeScript", ["coffee"]),
new Mode("coldfusion", "ColdFusion", ["cfm"]),
new Mode("csharp", "C#", ["cs"]),
new Mode("css", "CSS", ["css"]),
new Mode("golang", "Go", ["go"]),
new Mode("groovy", "Groovy", ["groovy"]),
new Mode("haxe", "haXe", ["hx"]),
new Mode("html", "HTML", ["html", "htm"]),
new Mode("java", "Java", ["java"]),
new Mode("javascript", "JavaScript", ["js"]),
new Mode("json", "JSON", ["json"]),
new Mode("latex", "LaTeX", ["tex"]),
new Mode("less", "LESS", ["less"]),
new Mode("lua", "Lua", ["lua"]),
new Mode("liquid", "Liquid", ["liquid"]),
new Mode("markdown", "Markdown", ["md", "markdown"]),
new Mode("ocaml", "OCaml", ["ml", "mli"]),
new Mode("perl", "Perl", ["pl", "pm"]),
new Mode("pgsql", "pgSQL", ["pgsql", "sql"]),
new Mode("php", "PHP", ["php"]),
new Mode("powershell", "Powershell", ["ps1"]),
new Mode("python", "Python", ["py"]),
new Mode("scala", "Scala", ["scala"]),
new Mode("scss", "SCSS", ["scss"]),
new Mode("ruby", "Ruby", ["rb"]),
new Mode("sql", "SQL", ["sql"]),
new Mode("svg", "SVG", ["svg"]),
new Mode("text", "Text", ["txt"]),
new Mode("textile", "Textile", ["textile"]),
new Mode("xml", "XML", ["xml"]),
new Mode("sh", "SH", ["sh"]),
new Mode("xquery", "XQuery", ["xq"])
];
modesByName = {};
modes.forEach(function(m) {
modesByName[m.name] = m;
});
var loreIpsum = require("ace/requirejs/text!./docs/plaintext.txt");
for (var i = 0; i < 5; i++) {
loreIpsum += loreIpsum;
}
var doc = new Doc("c_cpp", "C / C++", "");
var keybindings = {
// Null = use "default" keymapping
ace: null,
vim: vim,
emacs: emacs,
// This is a way to define simple keyboard remappings
custom: new HashHandler({
"gotoright": "Tab",
"indent": "]",
"outdent": "[",
"gotolinestart": "^",
"gotolineend": "$"
})
};
var container = document.getElementById("editor");
// Splitting.
var Split = require("ace/split").Split;
var split = new Split(container, theme, 1);
env.editor = split.getEditor(0);
split.on("focus", function(editor) {
env.editor = editor;
updateUIEditorOptions();
});
env.split = split;
window.env = env;
window.ace = env.editor;
var modeEl = document.getElementById("mode");
var wrapModeEl = document.getElementById("soft_wrap");
var themeEl = document.getElementById("theme");
var foldingEl = document.getElementById("folding");
var selectStyleEl = document.getElementById("select_style");
var highlightActiveEl = document.getElementById("highlight_active");
var showHiddenEl = document.getElementById("show_hidden");
var showGutterEl = document.getElementById("show_gutter");
var showPrintMarginEl = document.getElementById("show_print_margin");
var highlightSelectedWordE = document.getElementById("highlight_selected_word");
var showHScrollEl = document.getElementById("show_hscroll");
var animateScrollEl = document.getElementById("animate_scroll");
var softTabEl = document.getElementById("soft_tab");
var behavioursEl = document.getElementById("enable_behaviours");
modes.forEach(function(mode) {
var option = document.createElement("option");
option.setAttribute("value", mode.name);
option.innerHTML = mode.desc;
modeEl.appendChild(option);
});
bindDropdown("mode", function(value) {
env.editor.getSession().setMode(modesByName[value].mode || modesByName.text.mode);
env.editor.getSession().modeName = value;
});
var docdoc = doc.doc;
docdoc.setMode(modesByName[doc.name].mode);
var session = env.split.setSession(docdoc);
session.name = docdoc.name;
updateUIEditorOptions();
env.editor.focus();
function updateUIEditorOptions() {
var editor = env.editor;
var session = editor.session;
session.setFoldStyle(foldingEl.value);
saveOption(modeEl, session.modeName || "text");
saveOption(wrapModeEl, session.getUseWrapMode() ? session.getWrapLimitRange().min || "free" : "off");
saveOption(selectStyleEl, editor.getSelectionStyle() == "line");
saveOption(themeEl, editor.getTheme());
saveOption(highlightActiveEl, editor.getHighlightActiveLine());
saveOption(showHiddenEl, editor.getShowInvisibles());
saveOption(showGutterEl, editor.renderer.getShowGutter());
saveOption(showPrintMarginEl, editor.renderer.getShowPrintMargin());
saveOption(highlightSelectedWordE, editor.getHighlightSelectedWord());
saveOption(showHScrollEl, editor.renderer.getHScrollBarAlwaysVisible());
saveOption(animateScrollEl, editor.getAnimatedScroll());
saveOption(softTabEl, session.getUseSoftTabs());
saveOption(behavioursEl, editor.getBehavioursEnabled());
}
function saveOption(el, val) {
if (!el.onchange || el.onclick)
return;
if ("checked" in el) {
if (val !== undefined)
el.checked = val;
localStorage && localStorage.setItem(el.id, el.checked ? 1 : 0);
}
else {
if (val !== undefined)
el.value = val;
localStorage && localStorage.setItem(el.id, el.value);
}
}
bindDropdown("theme", function(value) {
if (!value)
return;
env.editor.setTheme(value);
});
bindDropdown("keybinding", function(value) {
env.editor.setKeyboardHandler(keybindings[value]);
});
bindDropdown("fontsize", function(value) {
env.split.setFontSize(value);
});
bindDropdown("folding", function(value) {
env.editor.getSession().setFoldStyle(value);
env.editor.setShowFoldWidgets(value !== "manual");
});
bindDropdown("soft_wrap", function(value) {
var session = env.editor.getSession();
var renderer = env.editor.renderer;
switch (value) {
case "off":
session.setUseWrapMode(false);
renderer.setPrintMarginColumn(80);
break;
case "40":
session.setUseWrapMode(true);
session.setWrapLimitRange(40, 40);
renderer.setPrintMarginColumn(40);
break;
case "80":
session.setUseWrapMode(true);
session.setWrapLimitRange(80, 80);
renderer.setPrintMarginColumn(80);
break;
case "free":
session.setUseWrapMode(true);
session.setWrapLimitRange(null, null);
renderer.setPrintMarginColumn(80);
break;
}
});
bindCheckbox("select_style", function(checked) {
env.editor.setSelectionStyle(checked ? "line" : "text");
});
bindCheckbox("highlight_active", function(checked) {
env.editor.setHighlightActiveLine(checked);
});
bindCheckbox("show_hidden", function(checked) {
env.editor.setShowInvisibles(checked);
});
bindCheckbox("show_gutter", function(checked) {
env.editor.renderer.setShowGutter(checked);
});
bindCheckbox("show_print_margin", function(checked) {
env.editor.renderer.setShowPrintMargin(checked);
});
bindCheckbox("highlight_selected_word", function(checked) {
env.editor.setHighlightSelectedWord(checked);
});
bindCheckbox("show_hscroll", function(checked) {
env.editor.renderer.setHScrollBarAlwaysVisible(checked);
});
bindCheckbox("animate_scroll", function(checked) {
env.editor.setAnimatedScroll(checked);
});
bindCheckbox("soft_tab", function(checked) {
env.editor.getSession().setUseSoftTabs(checked);
});
bindCheckbox("enable_behaviours", function(checked) {
env.editor.setBehavioursEnabled(checked);
});
var secondSession = null;
bindDropdown("split", function(value) {
var sp = env.split;
if (value == "none") {
if (sp.getSplits() == 2) {
secondSession = sp.getEditor(1).session;
}
sp.setSplits(1);
} else {
var newEditor = (sp.getSplits() == 1);
if (value == "below") {
sp.setOrientation(sp.BELOW);
} else {
sp.setOrientation(sp.BESIDE);
}
sp.setSplits(2);
if (newEditor) {
var session = secondSession || sp.getEditor(0).session;
var newSession = sp.setSession(session, 1);
newSession.name = session.name;
}
}
});
function bindCheckbox(id, callback) {
var el = document.getElementById(id);
if (localStorage && localStorage.getItem(id))
el.checked = localStorage.getItem(id) == "1";
var onCheck = function() {
callback(!!el.checked);
saveOption(el);
};
el.onclick = onCheck;
onCheck();
}
function bindDropdown(id, callback) {
var el = document.getElementById(id);
if (localStorage && localStorage.getItem(id))
el.value = localStorage.getItem(id);
var onChange = function() {
callback(el.value);
saveOption(el);
};
el.onchange = onChange;
onChange();
}
function onResize() {
var left = env.split.$container.offsetLeft;
var width = document.documentElement.clientWidth - left;
container.style.width = width + "px";
container.style.height = document.documentElement.clientHeight + "px";
env.split.resize();
}
window.onresize = onResize;
env.editor.renderer.onResize(true);
event.addListener(container, "dragover", function(e) {
return event.preventDefault(e);
});
function replaceDocContentsFromString(string) {
env.editor.getSelection().selectAll();
if (string) {
env.editor.onTextInput(string);
} else {
var range = env.editor.getSelectionRange();
env.editor.session.remove(range);
env.editor.clearSelection();
}
}
var currentFilename = "foo.txt";
function replaceDocContentsFromFile(file) {
if (window.FileReader) {
var reader = new FileReader();
reader.onload = function() {
currentFilename = file.name;
var mode = modesByName.text;
for (var i = 0; i < modes.length; i++) {
if (modes[i].supportsFile(file.name)) {
mode = modes[i];
break;
}
}
replaceDocContentsFromString(reader.result);
modeEl.value = mode.name;
env.editor.getSession().setMode(mode.mode);
env.editor.getSession().modeName = mode.name;
};
reader.readAsText(file);
}
}
function replaceDocContentsFromFileEntry(entry) {
entry.file(replaceDocContentsFromFile);
}
event.addListener(container, "drop", function(e) {
var file;
try {
entry = e.dataTransfer.items[0].webkitGetAsEntry(function(entry) {
replaceDocContentsFromFileEntry(entry);
});
//file = e.dataTransfer.files[0];
} catch(err) {
return event.stopEvent();
}
//replaceDocContentsFromFile(file);
return event.preventDefault(e);
});
var commands = env.editor.commands;
commands.addCommand({
name: "copy",
bindKey: {
win: "Ctrl-C",
mac: "Command-C",
sender: "editor"
},
exec: function() {
document.execCommand("copy");
}
});
commands.addCommand({
name: "paste",
bindKey: {
win: "Ctrl-V",
mac: "Command-V",
sender: "editor"
},
exec: function() {
document.execCommand("paste");
}
});
commands.addCommand({
name: "cutX",
bindKey: {
win: "Ctrl-X",
mac: "Command-X",
sender: "editor"
},
exec: function() {
document.execCommand("cut");
}
});
// add multiple cursor support to editor
require("ace/multi_select").MultiSelect(env.editor);
var showingConfig = false;
function showhideConfig() {
var controlsEl = document.getElementById("controlspanel");
showingConfig = !showingConfig;
var newLeft = -242;
if (showingConfig)
newLeft += 300;
controlsEl.style.left = newLeft + "px";
}
var configbuttonEl = document.getElementById("config");
configbuttonEl.onclick = showhideConfig;
function newDocument() {
replaceDocContentsFromString("");
}
var newbuttonEl = document.getElementById("new");
newbuttonEl.onclick = newDocument;
var fileinputEl = document.getElementById("openfileinput");
function openFile() {
if (fileinputEl.files.length === 0) { return; }
var file = fileinputEl.files[0];
replaceDocContentsFromFile(file);
}
fileinputEl.onchange = openFile;
var openfilebuttonEl = document.getElementById("openfile");
openfilebuttonEl.onclick = function() {fileinputEl.click();};
var Intent = window.Intent || window.WebKitIntent;
var startActivity = window.navigator.startActivity || window.navigator.webkitStartActivity;
window.intent = window.intent || window.webkitIntent;
function openFromWeb() {
var i = new Intent("http://webintents.org/pick", "text/*");
startActivity.call(window.navigator, i, function(data) {
replaceDocContentsFromString(data);
});
}
var openwebbuttonEl = document.getElementById("openweb");
openwebbuttonEl.onclick = openFromWeb;
var savelinkEl = document.getElementById("savelink");
function saveClicked() {
var bb = new (window.BlobBuilder || window.WebKitBlobBuilder)();
bb.append(env.editor.session.getDocument().getValue());
var blob = bb.getBlob("text/plain");
savelinkEl.download = currentFilename;
savelinkEl.href = window.webkitURL.createObjectURL(blob);
}
savelinkEl.onclick = saveClicked;
var saveasbuttonEl = document.getElementById("saveas");
saveasbuttonEl.onclick = function() {savelinkEl.click();};
if (launchData && launchData.intent && launchData.intent.data)
replaceDocContentsFromFileEntry(launchData.intent.data);
});

View File

@@ -1,17 +0,0 @@
class Haxe
{
public static function main()
{
// Say Hello!
var greeting:String = "Hello World";
trace(greeting);
var targets:Array<String> = ["Flash","Javascript","PHP","Neko","C++","iOS","Android","webOS"];
trace("Haxe is a great language that can target:");
for (target in targets)
{
trace (" - " + target);
}
trace("And many more!");
}
}

View File

@@ -1,19 +0,0 @@
(defn parting
"returns a String parting in a given language"
([] (parting "World"))
([name] (parting name "en"))
([name language]
; condp is similar to a case statement in other languages.
; It is described in more detail later.
; It is used here to take different actions based on whether the
; parameter "language" is set to "en", "es" or something else.
(condp = language
"en" (str "Goodbye, " name)
"es" (str "Adios, " name)
(throw (IllegalArgumentException.
(str "unsupported language " language))))))
(println (parting)) ; -> Goodbye, World
(println (parting "Mark")) ; -> Goodbye, Mark
(println (parting "Mark" "es")) ; -> Adios, Mark
(println (parting "Mark", "xy")) ; -> java.lang.IllegalArgumentException: unsupported language xy

View File

@@ -1,22 +0,0 @@
#!/usr/bin/env coffee
try
throw URIError decodeURI(0xC0ffee * 123456.7e-8 / .9)
catch e
console.log 'qstring' + "qqstring" + '''
qdoc
''' + """
qqdoc
"""
do ->
###
herecomment
###
re = /regex/imgy.test ///
heregex # comment
///imgy
this isnt: `just JavaScript`
undefined
sentence = "#{ 22 / 7 } is a decent approximation of π"

View File

@@ -1,5 +0,0 @@
<!--- hello world --->
<cfset welcome="Hello World!">
<cfoutput>#welcome#</cfoutput>

View File

@@ -1,13 +0,0 @@
// compound assignment operators
#include <iostream>
using namespace std;
int main ()
{
int a, b=3; /* foobar */
a = b;
a+=2; // equivalent to a=a+2
cout << a;
return 0;
}

View File

@@ -1,4 +0,0 @@
public void HelloWorld() {
//Say Hello!
Console.WriteLine("Hello World");
}

View File

@@ -1,28 +0,0 @@
.text-layer {
font-family: Monaco, "Courier New", monospace;
font-size: 12px;
cursor: text;
}
.blinker {
animation-duration: 1s;
animation-name: blink;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-timing-function: linear;
}
@keyframes blink {
0% {
opacity: 0;
}
40% {
opacity: 0;
}
40.5% {
opacity: 1
}
100% {
opacity: 1
}
}

View File

@@ -1,34 +0,0 @@
// Concurrent computation of pi.
// See http://goo.gl/ZuTZM.
//
// This demonstrates Go's ability to handle
// large numbers of concurrent processes.
// It is an unreasonable way to calculate pi.
package main
import (
"fmt"
"math"
)
func main() {
fmt.Println(pi(5000))
}
// pi launches n goroutines to compute an
// approximation of pi.
func pi(n int) float64 {
ch := make(chan float64)
for k := 0; k <= n; k++ {
go term(ch, float64(k))
}
f := 0.0
for k := 0; k <= n; k++ {
f += <-ch
}
return f
}
func term(ch chan float64, k float64) {
ch <- 4 * math.Pow(-1, k) / (2*k + 1)
}

View File

@@ -1,41 +0,0 @@
//http://groovy.codehaus.org/Martin+Fowler%27s+closure+examples+in+Groovy
class Employee {
def name, salary
boolean manager
String toString() { return name }
}
def emps = [new Employee(name:'Guillaume', manager:true, salary:200),
new Employee(name:'Graeme', manager:true, salary:200),
new Employee(name:'Dierk', manager:false, salary:151),
new Employee(name:'Bernd', manager:false, salary:50)]
def managers(emps) {
emps.findAll { e -> e.isManager() }
}
assert emps[0..1] == managers(emps) // [Guillaume, Graeme]
def highPaid(emps) {
threshold = 150
emps.findAll { e -> e.salary > threshold }
}
assert emps[0..2] == highPaid(emps) // [Guillaume, Graeme, Dierk]
def paidMore(amount) {
{ e -> e.salary > amount}
}
def highPaid = paidMore(150)
assert highPaid(emps[0]) // true
assert emps[0..2] == emps.findAll(highPaid)
def filename = 'test.txt'
new File(filename).withReader{ reader -> doSomethingWith(reader) }
def readersText
def doSomethingWith(reader) { readersText = reader.text }
assert new File(filename).text == readersText

View File

@@ -1,16 +0,0 @@
<html>
<head>
<style type="text/css">
.text-layer {
font-family: Monaco, "Courier New", monospace;
font-size: 12px;
cursor: text;
}
</style>
</head>
<body>
<h1 style="color:red">Juhu Kinners</h1>
</body>
</html>

View File

@@ -1,15 +0,0 @@
public class InfiniteLoop {
/*
* This will cause the program to hang...
*
* Taken from:
* http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/
*/
public static void main(String[] args) {
double d = Double.parseDouble("2.2250738585072012e-308");
// unreachable code
System.out.println("Value: " + d);
}
}

View File

@@ -1,5 +0,0 @@
function foo(items, nada) {
for (var i=0; i<items.length; i++) {
alert(items[i] + "juhu\n");
} // Real Tab.
}

View File

@@ -1,66 +0,0 @@
{
"query": {
"count": 10,
"created": "2011-06-21T08:10:46Z",
"lang": "en-US",
"results": {
"photo": [
{
"farm": "6",
"id": "5855620975",
"isfamily": "0",
"isfriend": "0",
"ispublic": "1",
"owner": "32021554@N04",
"secret": "f1f5e8515d",
"server": "5110",
"title": "7087 bandit cat"
},
{
"farm": "4",
"id": "5856170534",
"isfamily": "0",
"isfriend": "0",
"ispublic": "1",
"owner": "32021554@N04",
"secret": "ff1efb2a6f",
"server": "3217",
"title": "6975 rusty cat"
},
{
"farm": "6",
"id": "5856172972",
"isfamily": "0",
"isfriend": "0",
"ispublic": "1",
"owner": "51249875@N03",
"secret": "6c6887347c",
"server": "5192",
"title": "watermarked-cats"
},
{
"farm": "6",
"id": "5856168328",
"isfamily": "0",
"isfriend": "0",
"ispublic": "1",
"owner": "32021554@N04",
"secret": "0c1cfdf64c",
"server": "5078",
"title": "7020 mandy cat"
},
{
"farm": "3",
"id": "5856171774",
"isfamily": "0",
"isfriend": "0",
"ispublic": "1",
"owner": "32021554@N04",
"secret": "7f5a3180ab",
"server": "2696",
"title": "7448 bobby cat"
}
]
}
}
}

View File

@@ -1,22 +0,0 @@
\usepackage{amsmath}
\title{\LaTeX}
\date{}
\begin{document}
\maketitle
\LaTeX{} is a document preparation system for the \TeX{}
typesetting program. It offers programmable desktop publishing
features and extensive facilities for automating most aspects of
typesetting and desktop publishing, including numbering and
cross-referencing, tables and figures, page layout, bibliographies,
and much more. \LaTeX{} was originally written in 1984 by Leslie
Lamport and has become the dominant method for using \TeX; few
people write in plain \TeX{} anymore. The current version is
\LaTeXe.
% This is a comment; it will not be shown in the final output.
% The following shows a little of the typesetting power of LaTeX:
\begin{align}
E &= mc^2 \\
m &= \frac{m_0}{\sqrt{1-\frac{v^2}{c^2}}}
\end{align}
\end{document}

View File

@@ -1,28 +0,0 @@
/* styles.less */
@base: #f938ab;
.box-shadow(@style, @c) when (iscolor(@c)) {
box-shadow: @style @c;
-webkit-box-shadow: @style @c;
-moz-box-shadow: @style @c;
}
.box-shadow(@style, @alpha: 50%) when (isnumber(@alpha)) {
.box-shadow(@style, rgba(0, 0, 0, @alpha));
}
// Box styles
.box {
color: saturate(@base, 5%);
border-color: lighten(@base, 30%);
div { .box-shadow(0 0 5px, 30%) }
a {
color: @base;
&:hover {
color: lighten(@base, 50%);
}
}
}

View File

@@ -1,76 +0,0 @@
The following examples can be found in full at http://liquidmarkup.org/
Liquid is an extraction from the e-commerce system Shopify.
Shopify powers many thousands of e-commerce stores which all call for unique designs.
For this we developed Liquid which allows our customers complete design freedom while
maintaining the integrity of our servers.
Liquid has been in production use since June 2006 and is now used by many other
hosted web applications.
It was developed for usage in Ruby on Rails web applications and integrates seamlessly
as a plugin but it also works excellently as a stand alone library.
Here's what it looks like:
<ul id="products">
{% for product in products %}
<li>
<h2>{{ product.title }}</h2>
Only {{ product.price | format_as_money }}
<p>{{ product.description | prettyprint | truncate: 200 }}</p>
</li>
{% endfor %}
</ul>
Some more features include:
<h2>Filters</h2>
<p> The word "tobi" in uppercase: {{ 'tobi' | upcase }} </p>
<p>The word "tobi" has {{ 'tobi' | size }} letters! </p>
<p>Change "Hello world" to "Hi world": {{ 'Hello world' | replace: 'Hello', 'Hi' }} </p>
<p>The date today is {{ 'now' | date: "%Y %b %d" }} </p>
<h2>If</h2>
<p>
{% if user.name == 'tobi' or user.name == 'marc' %}
hi marc or tobi
{% endif %}
</p>
<h2>Case</h2>
<p>
{% case template %}
{% when 'index' %}
Welcome
{% when 'product' %}
{{ product.vendor | link_to_vendor }} / {{ product.title }}
{% else %}
{{ page_title }}
{% endcase %}
</p>
<h2>For Loops</h2>
<p>
{% for item in array %}
{{ item }}
{% endfor %}
</p>
<h2>Tables</h2>
<p>
{% tablerow item in items cols: 3 %}
{% if tablerowloop.col_first %}
First column: {{ item.variable }}
{% else %}
Different column: {{ item.variable }}
{% endif %}
{% endtablerow %}
</p>

View File

@@ -1,36 +0,0 @@
--[[--
num_args takes in 5.1 byte code and extracts the number of arguments
from its function header.
--]]--
function int(t)
return t:byte(1)+t:byte(2)*0x100+t:byte(3)*0x10000+t:byte(4)*0x1000000
end
function num_args(func)
local dump = string.dump(func)
local offset, cursor = int(dump:sub(13)), offset + 26
--Get the params and var flag (whether there's a ... in the param)
return dump:sub(cursor):byte(), dump:sub(cursor+1):byte()
end
-- Usage:
num_args(function(a,b,c,d, ...) end) -- return 4, 7
-- Python styled string format operator
local gm = debug.getmetatable("")
gm.__mod=function(self, other)
if type(other) ~= "table" then other = {other} end
for i,v in ipairs(other) do other[i] = tostring(v) end
return self:format(unpack(other))
end
print([===[
blah blah %s, (%d %d)
]===]%{"blah", num_args(int)})
--[=[--
table.maxn is deprecated, use # instead.
--]=]--
print(table.maxn{1,2,[4]=4,[8]=8) -- outputs 8 instead of 2

View File

@@ -1,186 +0,0 @@
Ace (Ajax.org Cloud9 Editor)
============================
Ace is a standalone code editor written in JavaScript. Our goal is to create a browser based editor that matches and extends the features, usability and performance of existing native editors such as TextMate, Vim or Eclipse. It can be easily embedded in any web page or JavaScript application. Ace is developed as the primary editor for [Cloud9 IDE](http://www.cloud9ide.com/) and the successor of the Mozilla Skywriter (Bespin) Project.
Features
--------
* Syntax highlighting
* Automatic indent and outdent
* An optional command line
* Handles huge documents (100,000 lines and more are no problem)
* Fully customizable key bindings including VI and Emacs modes
* Themes (TextMate themes can be imported)
* Search and replace with regular expressions
* Highlight matching parentheses
* Toggle between soft tabs and real tabs
* Displays hidden characters
* Drag and drop text using the mouse
* Line wrapping
* Unstructured / user code folding
* Live syntax checker (currently JavaScript/CoffeeScript)
Take Ace for a spin!
--------------------
Check out the Ace live [demo](http://ajaxorg.github.com/ace/) or get a [Cloud9 IDE account](http://run.cloud9ide.com) to experience Ace while editing one of your own GitHub projects.
If you want, you can use Ace as a textarea replacement thanks to the [Ace Bookmarklet](http://ajaxorg.github.com/ace/build/textarea/editor.html).
History
-------
Previously known as “Bespin” and “Skywriter” its now known as Ace (Ajax.org Cloud9 Editor)! Bespin and Ace started as two independent projects, both aiming to build a no-compromise code editor component for the web. Bespin started as part of Mozilla Labs and was based on the canvas tag, while Ace is the Editor component of the Cloud9 IDE and is using the DOM for rendering. After the release of Ace at JSConf.eu 2010 in Berlin the Skywriter team decided to merge Ace with a simplified version of Skywriter's plugin system and some of Skywriter's extensibility points. All these changes have been merged back to Ace. Both Ajax.org and Mozilla are actively developing and maintaining Ace.
Getting the code
----------------
Ace is a community project. We actively encourage and support contributions. The Ace source code is hosted on GitHub. It is released under the Mozilla tri-license (MPL/GPL/LGPL), the same license used by Firefox. This license is friendly to all kinds of projects, whether open source or not. Take charge of your editor and add your favorite language highlighting and keybindings!
```bash
git clone git://github.com/ajaxorg/ace.git
cd ace
git submodule update --init --recursive
```
Embedding Ace
-------------
Ace can be easily embedded into any existing web page. The Ace git repository ships with a pre-packaged version of Ace inside of the `build` directory. The same packaged files are also available as a separate [download](https://github.com/ajaxorg/ace/downloads). Simply copy the contents of the `src` subdirectory somewhere into your project and take a look at the included demos of how to use Ace.
The easiest version is simply:
```html
<div id="editor">some text</div>
<script src="src/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
window.onload = function() {
var editor = ace.edit("editor");
};
</script>
```
With "editor" being the id of the DOM element, which should be converted to an editor. Note that this element must be explicitly sized and positioned `absolute` or `relative` for Ace to work. e.g.
```css
#editor {
position: absolute;
width: 500px;
height: 400px;
}
```
To change the theme simply include the Theme's JavaScript file
```html
<script src="src/theme-twilight.js" type="text/javascript" charset="utf-8"></script>
```
and configure the editor to use the theme:
```javascript
editor.setTheme("ace/theme/twilight");
```
By default the editor only supports plain text mode; many other languages are available as separate modules. After including the mode's JavaScript file:
```html
<script src="src/mode-javascript.js" type="text/javascript" charset="utf-8"></script>
```
Then the mode can be used like this:
```javascript
var JavaScriptMode = require("ace/mode/javascript").Mode;
editor.getSession().setMode(new JavaScriptMode());
```
Documentation
-------------
You find a lot more sample code in the [demo app](https://github.com/ajaxorg/ace/blob/master/demo/demo.js).
There is also some documentation on the [wiki page](https://github.com/ajaxorg/ace/wiki).
If you still need help, feel free to drop a mail on the [ace mailing list](http://groups.google.com/group/ace-discuss).
Running Ace
-----------
After the checkout Ace works out of the box. No build step is required. Open 'editor.html' in any browser except Google Chrome. Google Chrome doesn't allow XMLHTTPRequests from files loaded from disc (i.e. with a file:/// URL). To open Ace in Chrome simply start the bundled mini HTTP server:
```bash
./static.py
```
Or using Node.JS
```bash
./static.js
```
The editor can then be opened at http://localhost:8888/index.html.
Package Ace
-----------
To package Ace we use the dryice build tool developed by the Mozilla Skywriter team. Before you can build you need to make sure that the submodules are up to date.
```bash
git submodule update --init --recursive
```
Afterwards Ace can be built by calling
```bash
./Makefile.dryice.js normal
```
The packaged Ace will be put in the 'build' folder.
To build the bookmarklet version execute
```bash
./Makefile.dryice.js bm
```
Running the Unit Tests
----------------------
The Ace unit tests run on node.js. Before the first run a couple of node modules have to be installed. The easiest way to do this is by using the node package manager (npm). In the Ace base directory simply call
```bash
npm link .
```
To run the tests call:
```bash
node lib/ace/test/all.js
```
You can also run the tests in your browser by serving:
http://localhost:8888/lib/ace/test/tests.html
This makes debugging failing tests way more easier.
Contributing
------------
Ace wouldn't be what it is without contributions! Feel free to fork and improve/enhance Ace any way you want. If you feel that the editor or the Ace community will benefit from your changes, please open a pull request. To protect the interests of the Ace contributors and users we require contributors to sign a Contributors License Agreement (CLA) before we pull the changes into the main repository. Our CLA is the simplest of agreements, requiring that the contributions you make to an ajax.org project are only those you're allowed to make. This helps us significantly reduce future legal risk for everyone involved. It is easy, helps everyone, takes ten minutes, and only needs to be completed once. There are two versions of the agreement:
1. [The Individual CLA](https://github.com/ajaxorg/ace/raw/master/doc/Contributor_License_Agreement-v2.pdf): use this version if you're working on an ajax.org in your spare time, or can clearly claim ownership of copyright in what you'll be submitting.
2. [The Corporate CLA](https://github.com/ajaxorg/ace/raw/master/doc/Corporate_Contributor_License_Agreement-v2.pdf): have your corporate lawyer review and submit this if your company is going to be contributing to ajax.org projects
If you want to contribute to an ajax.org project please print the CLA and fill it out and sign it. Then either send it by snail mail or fax to us or send it back scanned (or as a photo) by email.
Email: fabian.jakobs@web.de
Fax: +31 (0) 206388953
Address: Ajax.org B.V.
Keizersgracht 241
1016 EA, Amsterdam
the Netherlands

View File

@@ -1,18 +0,0 @@
(*
* Example of early return implementation taken from
* http://ocaml.janestreet.com/?q=node/91
*)
let with_return (type t) (f : _ -> t) =
let module M =
struct exception Return of t end
in
let return = { return = (fun x -> raise (M.Return x)); } in
try f return with M.Return x -> x
(* Function that uses the 'early return' functionality provided by `with_return` *)
let sum_until_first_negative list =
with_return (fun r ->
List.fold list ~init:0 ~f:(fun acc x ->
if x >= 0 then acc + x else r.return acc))

View File

@@ -1,32 +0,0 @@
#!/usr/bin/perl
use strict;
use warnings;
my $num_primes = 0;
my @primes;
# Put 2 as the first prime so we won't have an empty array
$primes[$num_primes] = 2;
$num_primes++;
MAIN_LOOP:
for my $number_to_check (3 .. 200)
{
for my $p (0 .. ($num_primes-1))
{
if ($number_to_check % $primes[$p] == 0)
{
next MAIN_LOOP;
}
}
# If we reached this point it means $number_to_check is not
# divisable by any prime number that came before it.
$primes[$num_primes] = $number_to_check;
$num_primes++;
}
for my $p (0 .. ($num_primes-1))
{
print $primes[$p], ", ";
}
print "\n";

View File

@@ -1,100 +0,0 @@
BEGIN;
/**
* Samples from PostgreSQL src/tutorial/basics.source
*/
CREATE TABLE weather (
city varchar(80),
temp_lo int, -- low temperature
temp_hi int, -- high temperature
prcp real, -- precipitation
"date" date
);
CREATE TABLE cities (
name varchar(80),
location point
);
INSERT INTO weather
VALUES ('San Francisco', 46, 50, 0.25, '1994-11-27');
INSERT INTO cities
VALUES ('San Francisco', '(-194.0, 53.0)');
INSERT INTO weather (city, temp_lo, temp_hi, prcp, "date")
VALUES ('San Francisco', 43, 57, 0.0, '1994-11-29');
INSERT INTO weather (date, city, temp_hi, temp_lo)
VALUES ('1994-11-29', 'Hayward', 54, 37);
SELECT city, (temp_hi+temp_lo)/2 AS temp_avg, "date" FROM weather;
SELECT city, temp_lo, temp_hi, prcp, "date", location
FROM weather, cities
WHERE city = name;
/**
* Dollar quotes starting at the end of the line are colored as SQL unless
* a special language tag is used. Pearl and Python are currently implemented
* but lots of others are possible.
*/
create or replace function blob_content_chunked(
in p_data bytea,
in p_chunk integer)
returns setof bytea as $$
-- Still SQL comments
declare
v_size integer = octet_length(p_data);
begin
for i in 1..v_size by p_chunk loop
return next substring(p_data from i for p_chunk);
end loop;
end;
$$ language plpgsql stable;
-- pl/perl
CREATE FUNCTION perl_max (integer, integer) RETURNS integer AS $perl$
# perl comment...
my ($x,$y) = @_;
if (! defined $x) {
if (! defined $y) { return undef; }
return $y;
}
if (! defined $y) { return $x; }
if ($x > $y) { return $x; }
return $y;
$perl$ LANGUAGE plperl;
-- pl/python
CREATE FUNCTION usesavedplan() RETURNS trigger AS $python$
# python comment...
if SD.has_key("plan"):
plan = SD["plan"]
else:
plan = plpy.prepare("SELECT 1")
SD["plan"] = plan
$python$ LANGUAGE plpythonu;
-- psql commands
\df cash*
-- Some string samples.
select 'don''t do it now;' || 'maybe later';
select E'dont\'t do it';
select length('some other''s stuff' || $$cat in hat's stuff $$);
select $$ strings
over multiple
lines - use dollar quotes
$$;
END;

View File

@@ -1,19 +0,0 @@
<?php
function nfact($n) {
if ($n == 0) {
return 1;
}
else {
return $n * nfact($n - 1);
}
}
echo "\n\nPlease enter a whole number ... ";
$num = trim(fgets(STDIN));
// ===== PROCESS - Determing the factorial of the input number =====
$output = "\n\nFactorial " . $num . " = " . nfact($num) . "\n\n";
echo $output;
?>

View File

@@ -1,11 +0,0 @@
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis.
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur

View File

@@ -1,24 +0,0 @@
# This is a simple comment
function Hello($name) {
Write-host "Hello $name"
}
function add($left, $right=4) {
if ($right -ne 4) {
return $left
} elseif ($left -eq $null -and $right -eq 2) {
return 3
} else {
return 2
}
}
$number = 1 + 2;
$number += 3
Write-Host Hello -name "World"
$an_array = @(1, 2, 3)
$a_hash = @{"something" = "something else"}
& notepad .\readme.md

View File

@@ -1,19 +0,0 @@
#!/usr/local/bin/python
import string, sys
# If no arguments were given, print a helpful message
if len(sys.argv)==1:
print '''Usage:
celsius temp1 temp2 ...'''
sys.exit(0)
# Loop over the arguments
for i in sys.argv[1:]:
try:
fahrenheit=float(string.atoi(i))
except string.atoi_error:
print repr(i), "not a numeric value"
else:
celsius=(fahrenheit-32)*5.0/9.0
print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5))

View File

@@ -1,12 +0,0 @@
#!/usr/bin/ruby
# Program to find the factorial of a number
def fact(n)
if n == 0
1
else
n * fact(n-1)
end
end
puts fact(ARGV[0].to_i)

View File

@@ -1,69 +0,0 @@
// http://www.scala-lang.org/node/54
package examples.actors
import scala.actors.Actor
import scala.actors.Actor._
abstract class PingMessage
case object Start extends PingMessage
case object SendPing extends PingMessage
case object Pong extends PingMessage
abstract class PongMessage
case object Ping extends PongMessage
case object Stop extends PongMessage
object pingpong extends Application {
val pong = new Pong
val ping = new Ping(100000, pong)
ping.start
pong.start
ping ! Start
}
class Ping(count: Int, pong: Actor) extends Actor {
def act() {
println("Ping: Initializing with count "+count+": "+pong)
var pingsLeft = count
loop {
react {
case Start =>
println("Ping: starting.")
pong ! Ping
pingsLeft = pingsLeft - 1
case SendPing =>
pong ! Ping
pingsLeft = pingsLeft - 1
case Pong =>
if (pingsLeft % 1000 == 0)
println("Ping: pong from: "+sender)
if (pingsLeft > 0)
self ! SendPing
else {
println("Ping: Stop.")
pong ! Stop
exit('stop)
}
}
}
}
}
class Pong extends Actor {
def act() {
var pongCount = 0
loop {
react {
case Ping =>
if (pongCount % 1000 == 0)
println("Pong: ping "+pongCount+" from "+sender)
sender ! Pong
pongCount = pongCount + 1
case Stop =>
println("Pong: Stop.")
exit('stop)
}
}
}
}

View File

@@ -1,20 +0,0 @@
/* style.scss */
#navbar {
$navbar-width: 800px;
$items: 5;
$navbar-color: #ce4dd6;
width: $navbar-width;
border-bottom: 2px solid $navbar-color;
li {
float: left;
width: $navbar-width/$items - 10px;
background-color: lighten($navbar-color, 20%);
&:hover {
background-color: lighten($navbar-color, 10%);
}
}
}

View File

@@ -1,38 +0,0 @@
#!/bin/sh
# Script to open a browser to current branch
# Repo formats:
# ssh git@github.com:richoH/gh_pr.git
# http https://richoH@github.com/richoH/gh_pr.git
# git git://github.com/richoH/gh_pr.git
username=`git config --get github.user`
get_repo() {
git remote -v | grep ${@:-$username} | while read remote; do
if repo=`echo $remote | grep -E -o "git@github.com:[^ ]*"`; then
echo $repo | sed -e "s/^git@github\.com://" -e "s/\.git$//"
exit 1
fi
if repo=`echo $remote | grep -E -o "https?://([^@]*@)?github.com/[^ ]*\.git"`; then
echo $repo | sed -e "s|^https?://||" -e "s/^.*github\.com\///" -e "s/\.git$//"
exit 1
fi
if repo=`echo $remote | grep -E -o "git://github.com/[^ ]*\.git"`; then
echo $repo | sed -e "s|^git://github.com/||" -e "s/\.git$//"
exit 1
fi
done
if [ $? -eq 0 ]; then
echo "Couldn't find a valid remote" >&2
exit 1
fi
}
if repo=`get_repo $@`; then
branch=`git symbolic-ref HEAD 2>/dev/null`
echo "http://github.com/$repo/pull/new/${branch##refs/heads/}"
else
exit 1
fi

View File

@@ -1,6 +0,0 @@
SELECT city, COUNT(id) AS users_count
FROM users
WHERE group_name = 'salesman'
AND created > '2011-05-21'
GROUP BY 1
ORDER BY 2 DESC

View File

@@ -1,83 +0,0 @@
<svg
width="800" height="600"
xmlns="http://www.w3.org/2000/svg"
onload="StartAnimation(evt)">
<title>Test Tube Progress Bar</title>
<desc>Created for the Web Directions SVG competition</desc>
<script type="text/ecmascript"><![CDATA[
var timevalue = 0;
var timer_increment = 1;
var max_time = 100;
var hickory;
var dickory;
var dock;
var i;
function StartAnimation(evt) {
hickory = evt.target.ownerDocument.getElementById("hickory");
dickory = evt.target.ownerDocument.getElementById("dickory");
dock = evt.target.ownerDocument.getElementById("dock");
ShowAndGrowElement();
}
function ShowAndGrowElement() {
timevalue = timevalue + timer_increment;
if (timevalue > max_time)
return;
// Scale the text string gradually until it is 20 times larger
scalefactor = (timevalue * 650) / max_time;
if (timevalue < 30) {
hickory.setAttribute("display", "");
hickory.setAttribute("transform", "translate(" + (600+scalefactor*3*-1 ) + ", -144 )");
}
if (timevalue > 30 && timevalue < 66) {
dickory.setAttribute("display", "");
dickory.setAttribute("transform", "translate(" + (-795+scalefactor*2) + ", 0 )");
}
if (timevalue > 66) {
dock.setAttribute("display", "");
dock.setAttribute("transform", "translate(" + (1450+scalefactor*2*-1) + ", 144 )");
}
// Call ShowAndGrowElement again <timer_increment> milliseconds later.
setTimeout("ShowAndGrowElement()", timer_increment)
}
window.ShowAndGrowElement = ShowAndGrowElement
]]</script>
<rect
fill="#2e3436"
fill-rule="nonzero"
stroke-width="3"
y="0"
x="0"
height="600"
width="800"
id="rect3590"/>
<text
style="font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
x="50"
y="350"
id="hickory"
display="none">
Hickory,</text>
<text
style="font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
x="50"
y="350"
id="dickory"
display="none">
dickory,</text>
<text
style="font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
x="50"
y="350"
id="dock"
display="none">
dock!</text>
</svg>

Before

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -1,29 +0,0 @@
h1. Textile document
h2. Heading Two
h3. A two-line
header
h2. Another two-line
header
Paragraph:
one, two,
thee lines!
p(classone two three). This is a paragraph with classes
p(#id). (one with an id)
p(one two three#my_id). ..classes + id
* Unordered list
** sublist
* back again!
** sublist again..
# ordered
bg. Blockquote!
This is a two-list blockquote..!

View File

@@ -1,55 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
yahoo:count="7" yahoo:created="2011-10-11T08:40:23Z" yahoo:lang="en-US">
<diagnostics>
<publiclyCallable>true</publiclyCallable>
<url execution-start-time="0" execution-stop-time="25" execution-time="25"><![CDATA[http://where.yahooapis.com/v1/continents;start=0;count=10]]></url>
<user-time>26</user-time>
<service-time>25</service-time>
<build-version>21978</build-version>
</diagnostics>
<results>
<place xmlns="http://where.yahooapis.com/v1/schema.rng"
xml:lang="en-US" yahoo:uri="http://where.yahooapis.com/v1/place/24865670">
<woeid>24865670</woeid>
<placeTypeName code="29">Continent</placeTypeName>
<name>Africa</name>
</place>
<place xmlns="http://where.yahooapis.com/v1/schema.rng"
xml:lang="en-US" yahoo:uri="http://where.yahooapis.com/v1/place/24865675">
<woeid>24865675</woeid>
<placeTypeName code="29">Continent</placeTypeName>
<name>Europe</name>
</place>
<place xmlns="http://where.yahooapis.com/v1/schema.rng"
xml:lang="en-US" yahoo:uri="http://where.yahooapis.com/v1/place/24865673">
<woeid>24865673</woeid>
<placeTypeName code="29">Continent</placeTypeName>
<name>South America</name>
</place>
<place xmlns="http://where.yahooapis.com/v1/schema.rng"
xml:lang="en-US" yahoo:uri="http://where.yahooapis.com/v1/place/28289421">
<woeid>28289421</woeid>
<placeTypeName code="29">Continent</placeTypeName>
<name>Antarctic</name>
</place>
<place xmlns="http://where.yahooapis.com/v1/schema.rng"
xml:lang="en-US" yahoo:uri="http://where.yahooapis.com/v1/place/24865671">
<woeid>24865671</woeid>
<placeTypeName code="29">Continent</placeTypeName>
<name>Asia</name>
</place>
<place xmlns="http://where.yahooapis.com/v1/schema.rng"
xml:lang="en-US" yahoo:uri="http://where.yahooapis.com/v1/place/24865672">
<woeid>24865672</woeid>
<placeTypeName code="29">Continent</placeTypeName>
<name>North America</name>
</place>
<place xmlns="http://where.yahooapis.com/v1/schema.rng"
xml:lang="en-US" yahoo:uri="http://where.yahooapis.com/v1/place/55949070">
<woeid>55949070</woeid>
<placeTypeName code="29">Continent</placeTypeName>
<name>Australia</name>
</place>
</results>
</query>

View File

@@ -1,6 +0,0 @@
xquery version "1.0";
let $message := "Hello World!"
return <results>
<message>{$message}</message>
</results>

25
text-editor/editor.html Normal file
View File

@@ -0,0 +1,25 @@
<html>
<head>
<title>Platform App Text Editor Demo</title>
<meta name="author" content="Ben Wells">
<link rel="stylesheet" href="styles.css" type="text/css">
</head>
<body>
<div id="toolbar">
<div id="new" class="toolbarbutton enabled"></div>
<div id="openfile" class="toolbarbutton enabled"></div>
<div id="openweb" class="toolbarbutton hidden"></div>
<div id="save" class="toolbarbutton enabled"></div>
<div id="saveas" class="toolbarbutton enabled"></div>
</div>
<div id="editarea">
<div id="status">
<div id="path">[new file]</div>
<div id="error"></div>
</div>
<div id="editor"></div>
</div>
<script src="require_config.js" type="text/javascript"></script>
<script src="require.js" data-main="editor" type="text/javascript"></script>
</body>
</html>

265
text-editor/editor.js Normal file
View File

@@ -0,0 +1,265 @@
define(function(require, exports, module) {
"use strict";
// Load dependent modules
var EditSession = require("ace/edit_session").EditSession;
var UndoManager = require("ace/undomanager").UndoManager;
var Editor = require("ace/editor").Editor;
var Renderer = require("ace/virtual_renderer").VirtualRenderer;
var modes = require("modes");
var event = require("ace/lib/event");
// Load theme info
var theme = require("ace/theme/textmate");
// Setup edited document and put it in the container
var container = document.getElementById("editor");
var editor = new Editor(new Renderer(container, theme));
var session = new EditSession('');
session.setUndoManager(new UndoManager());
editor.setSession(session);
// Make sure editor is kept to an appropriate size
function onResize() {
var left = container.offsetLeft;
var top = container.offsetTop;
var width = document.documentElement.clientWidth - left;
var height = document.documentElement.clientHeight - top;
container.style.width = width + 'px';
container.style.height = height + 'px';
editor.resize();
}
window.onresize = onResize;
// Do resize once to get everything in a happy place.
onResize();
var fileEntry;
var gotWritable = false;
var modeDescription = '';
function updatePathTo(aPath) {
var pathDisplay = aPath;
if (modeDescription) {
pathDisplay = pathDisplay + ' [' + modeDescription + ']';
}
document.getElementById('path').innerHTML = pathDisplay;
}
function updatePath() {
if (fileEntry) {
chrome.fileSystem.getDisplayPath(fileEntry, updatePathTo);
} else {
updatePathTo('[new file]');
}
}
function updateModeForBaseName(aBaseName) {
modeDescription = '';
var mode = modes.getModeFromBaseName(aBaseName);
if (mode) {
editor.getSession().setMode(mode.mode);
modeDescription = mode.desc;
}
}
function showError(anError) {
var errorEl = document.getElementById('error');
errorEl.innerHTML = anError;
document.getElementById('error').style.display = 'default';
}
function clearError() {
document.getElementById('error').style.display = 'none';
}
function replaceDocContentsFromString(string) {
editor.getSession().setValue(string);
}
function replaceDocContentsFromFile(file) {
if (window.FileReader) {
var reader = new FileReader();
reader.onload = function() {
replaceDocContentsFromString(reader.result);
};
reader.readAsText(file);
}
}
function replaceDocContentsFromFileEntry() {
fileEntry.file(replaceDocContentsFromFile);
}
function saveToEntry() {
fileEntry.createWriter(function(fileWriter) {
fileWriter.onwriteend = function(e) {
if (this.error)
gStatusEl.innerHTML = 'Error during write: ' + this.error.toString();
else
clearError();
};
var blob = new Blob([editor.getSession().getValue()], {type: 'text/plain'});
fileWriter.write(blob);
});
}
function setEntry(anEntry, isWritable, name) {
fileEntry = anEntry;
gotWritable = isWritable;
if (fileEntry) {
updateModeForBaseName(fileEntry.name);
} else if (name) {
updateModeForBaseName(name);
}
updatePath();
}
// Create a new document. This just wipes the old document.
function createNew() {
replaceDocContentsFromString();
setEntry(null, false);
}
function openFile() {
chrome.fileSystem.chooseFile(function (entry) {
if (chrome.extension.lastError) {
showError(chrome.extension.lastError.message);
return;
}
clearError();
setEntry(entry, false);
replaceDocContentsFromFileEntry();
});
}
function saveFile() {
if (gotWritable) {
saveToEntry();
} else if (fileEntry) {
chrome.fileSystem.getWritableFileEntry(fileEntry, function(entry) {
if (chrome.extension.lastError) {
showError(chrome.extension.lastError.message);
return;
}
clearError();
setEntry(entry, true);
saveToEntry();
});
} else {
saveAs();
}
}
function saveAs() {
chrome.fileSystem.chooseFile({type: 'saveFile'}, function(entry) {
if (chrome.extension.lastError) {
showError(chrome.extension.lastError.message);
return;
}
clearError();
setEntry(entry, true);
saveToEntry();
});
}
// Setup commands
// New probably should warn the user as there is no undo!
document.getElementById('new').onclick = createNew;
document.getElementById('openfile').onclick = openFile;
document.getElementById('save').onclick = saveFile;
document.getElementById('saveas').onclick = saveAs;
editor.commands.addCommand({
name: "new",
bindKey: {
win: "Ctrl-N",
mac: "Command-N",
sender: "editor"
},
exec: function() {
createNew();
}
});
editor.commands.addCommand({
name: "open",
bindKey: {
win: "Ctrl-O",
mac: "Command-O",
sender: "editor"
},
exec: function() {
openFile();
}
});
editor.commands.addCommand({
name: "save",
bindKey: {
win: "Ctrl-S",
mac: "Command-S",
sender: "editor"
},
exec: function() {
saveFile();
}
});
editor.commands.addCommand({
name: "saveas",
bindKey: {
win: "Ctrl-Shift-S",
mac: "Command-Shift-S",
sender: "editor"
},
exec: function() {
saveAs();
}
});
editor.commands.addCommand({
name: "copy",
bindKey: {
win: "Ctrl-C",
mac: "Command-C",
sender: "editor"
},
exec: function() {
document.execCommand("copy");
}
});
editor.commands.addCommand({
name: "paste",
bindKey: {
win: "Ctrl-V",
mac: "Command-V",
sender: "editor"
},
exec: function() {
document.execCommand("paste");
}
});
editor.commands.addCommand({
name: "cutX",
bindKey: {
win: "Ctrl-X",
mac: "Command-X",
sender: "editor"
},
exec: function() {
document.execCommand("cut");
}
});
// Handle drop events.
event.addListener(container, "drop", function(e) {
var file = e.dataTransfer.files[0];
replaceDocContentsFromFile(file);
setEntry(null, false, file.name);
return event.preventDefault(e);
});
});

View File

@@ -1 +1 @@
The icons in this folder are from the Eclipse project and licensed under the Eclipse public license version 1.0 (EPL).
The icons in this project are awesome and come from http://www.silvestre.com.ar/.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -1,260 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0049)http://www.eclipse.org/org/documents/epl-v10.html -->
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Eclipse Public License - Version 1.0</title>
<style type="text/css">
body {
size: 8.5in 11.0in;
margin: 0.25in 0.5in 0.25in 0.5in;
tab-interval: 0.5in;
}
p {
margin-left: auto;
margin-top: 0.5em;
margin-bottom: 0.5em;
}
p.list {
margin-left: 0.5in;
margin-top: 0.05em;
margin-bottom: 0.05em;
}
</style>
<script src="chrome-extension://jgghnecdoiloelcogfmgjgcacadpaejf/inject.js"></script></head>
<body lang="EN-US">
<h2>Eclipse Public License - v 1.0</h2>
<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS
AGREEMENT.</p>
<p><b>1. DEFINITIONS</b></p>
<p>"Contribution" means:</p>
<p class="list">a) in the case of the initial Contributor, the initial
code and documentation distributed under this Agreement, and</p>
<p class="list">b) in the case of each subsequent Contributor:</p>
<p class="list">i) changes to the Program, and</p>
<p class="list">ii) additions to the Program;</p>
<p class="list">where such changes and/or additions to the Program
originate from and are distributed by that particular Contributor. A
Contribution 'originates' from a Contributor if it was added to the
Program by such Contributor itself or anyone acting on such
Contributor's behalf. Contributions do not include additions to the
Program which: (i) are separate modules of software distributed in
conjunction with the Program under their own license agreement, and (ii)
are not derivative works of the Program.</p>
<p>"Contributor" means any person or entity that distributes
the Program.</p>
<p>"Licensed Patents" mean patent claims licensable by a
Contributor which are necessarily infringed by the use or sale of its
Contribution alone or when combined with the Program.</p>
<p>"Program" means the Contributions distributed in accordance
with this Agreement.</p>
<p>"Recipient" means anyone who receives the Program under
this Agreement, including all Contributors.</p>
<p><b>2. GRANT OF RIGHTS</b></p>
<p class="list">a) Subject to the terms of this Agreement, each
Contributor hereby grants Recipient a non-exclusive, worldwide,
royalty-free copyright license to reproduce, prepare derivative works
of, publicly display, publicly perform, distribute and sublicense the
Contribution of such Contributor, if any, and such derivative works, in
source code and object code form.</p>
<p class="list">b) Subject to the terms of this Agreement, each
Contributor hereby grants Recipient a non-exclusive, worldwide,
royalty-free patent license under Licensed Patents to make, use, sell,
offer to sell, import and otherwise transfer the Contribution of such
Contributor, if any, in source code and object code form. This patent
license shall apply to the combination of the Contribution and the
Program if, at the time the Contribution is added by the Contributor,
such addition of the Contribution causes such combination to be covered
by the Licensed Patents. The patent license shall not apply to any other
combinations which include the Contribution. No hardware per se is
licensed hereunder.</p>
<p class="list">c) Recipient understands that although each Contributor
grants the licenses to its Contributions set forth herein, no assurances
are provided by any Contributor that the Program does not infringe the
patent or other intellectual property rights of any other entity. Each
Contributor disclaims any liability to Recipient for claims brought by
any other entity based on infringement of intellectual property rights
or otherwise. As a condition to exercising the rights and licenses
granted hereunder, each Recipient hereby assumes sole responsibility to
secure any other intellectual property rights needed, if any. For
example, if a third party patent license is required to allow Recipient
to distribute the Program, it is Recipient's responsibility to acquire
that license before distributing the Program.</p>
<p class="list">d) Each Contributor represents that to its knowledge it
has sufficient copyright rights in its Contribution, if any, to grant
the copyright license set forth in this Agreement.</p>
<p><b>3. REQUIREMENTS</b></p>
<p>A Contributor may choose to distribute the Program in object code
form under its own license agreement, provided that:</p>
<p class="list">a) it complies with the terms and conditions of this
Agreement; and</p>
<p class="list">b) its license agreement:</p>
<p class="list">i) effectively disclaims on behalf of all Contributors
all warranties and conditions, express and implied, including warranties
or conditions of title and non-infringement, and implied warranties or
conditions of merchantability and fitness for a particular purpose;</p>
<p class="list">ii) effectively excludes on behalf of all Contributors
all liability for damages, including direct, indirect, special,
incidental and consequential damages, such as lost profits;</p>
<p class="list">iii) states that any provisions which differ from this
Agreement are offered by that Contributor alone and not by any other
party; and</p>
<p class="list">iv) states that source code for the Program is available
from such Contributor, and informs licensees how to obtain it in a
reasonable manner on or through a medium customarily used for software
exchange.</p>
<p>When the Program is made available in source code form:</p>
<p class="list">a) it must be made available under this Agreement; and</p>
<p class="list">b) a copy of this Agreement must be included with each
copy of the Program.</p>
<p>Contributors may not remove or alter any copyright notices contained
within the Program.</p>
<p>Each Contributor must identify itself as the originator of its
Contribution, if any, in a manner that reasonably allows subsequent
Recipients to identify the originator of the Contribution.</p>
<p><b>4. COMMERCIAL DISTRIBUTION</b></p>
<p>Commercial distributors of software may accept certain
responsibilities with respect to end users, business partners and the
like. While this license is intended to facilitate the commercial use of
the Program, the Contributor who includes the Program in a commercial
product offering should do so in a manner which does not create
potential liability for other Contributors. Therefore, if a Contributor
includes the Program in a commercial product offering, such Contributor
("Commercial Contributor") hereby agrees to defend and
indemnify every other Contributor ("Indemnified Contributor")
against any losses, damages and costs (collectively "Losses")
arising from claims, lawsuits and other legal actions brought by a third
party against the Indemnified Contributor to the extent caused by the
acts or omissions of such Commercial Contributor in connection with its
distribution of the Program in a commercial product offering. The
obligations in this section do not apply to any claims or Losses
relating to any actual or alleged intellectual property infringement. In
order to qualify, an Indemnified Contributor must: a) promptly notify
the Commercial Contributor in writing of such claim, and b) allow the
Commercial Contributor to control, and cooperate with the Commercial
Contributor in, the defense and any related settlement negotiations. The
Indemnified Contributor may participate in any such claim at its own
expense.</p>
<p>For example, a Contributor might include the Program in a commercial
product offering, Product X. That Contributor is then a Commercial
Contributor. If that Commercial Contributor then makes performance
claims, or offers warranties related to Product X, those performance
claims and warranties are such Commercial Contributor's responsibility
alone. Under this section, the Commercial Contributor would have to
defend claims against the other Contributors related to those
performance claims and warranties, and if a court requires any other
Contributor to pay any damages as a result, the Commercial Contributor
must pay those damages.</p>
<p><b>5. NO WARRANTY</b></p>
<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,
ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
responsible for determining the appropriateness of using and
distributing the Program and assumes all risks associated with its
exercise of rights under this Agreement , including but not limited to
the risks and costs of program errors, compliance with applicable laws,
damage to or loss of data, programs or equipment, and unavailability or
interruption of operations.</p>
<p><b>6. DISCLAIMER OF LIABILITY</b></p>
<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>
<p><b>7. GENERAL</b></p>
<p>If any provision of this Agreement is invalid or unenforceable under
applicable law, it shall not affect the validity or enforceability of
the remainder of the terms of this Agreement, and without further action
by the parties hereto, such provision shall be reformed to the minimum
extent necessary to make such provision valid and enforceable.</p>
<p>If Recipient institutes patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that the
Program itself (excluding combinations of the Program with other
software or hardware) infringes such Recipient's patent(s), then such
Recipient's rights granted under Section 2(b) shall terminate as of the
date such litigation is filed.</p>
<p>All Recipient's rights under this Agreement shall terminate if it
fails to comply with any of the material terms or conditions of this
Agreement and does not cure such failure in a reasonable period of time
after becoming aware of such noncompliance. If all Recipient's rights
under this Agreement terminate, Recipient agrees to cease use and
distribution of the Program as soon as reasonably practicable. However,
Recipient's obligations under this Agreement and any licenses granted by
Recipient relating to the Program shall continue and survive.</p>
<p>Everyone is permitted to copy and distribute copies of this
Agreement, but in order to avoid inconsistency the Agreement is
copyrighted and may only be modified in the following manner. The
Agreement Steward reserves the right to publish new versions (including
revisions) of this Agreement from time to time. No one other than the
Agreement Steward has the right to modify this Agreement. The Eclipse
Foundation is the initial Agreement Steward. The Eclipse Foundation may
assign the responsibility to serve as the Agreement Steward to a
suitable separate entity. Each new version of the Agreement will be
given a distinguishing version number. The Program (including
Contributions) may always be distributed subject to the version of the
Agreement under which it was received. In addition, after a new version
of the Agreement is published, Contributor may elect to distribute the
Program (including its Contributions) under the new version. Except as
expressly stated in Sections 2(a) and 2(b) above, Recipient receives no
rights or licenses to the intellectual property of any Contributor under
this Agreement, whether expressly, by implication, estoppel or
otherwise. All rights in the Program not expressly granted under this
Agreement are reserved.</p>
<p>This Agreement is governed by the laws of the State of New York and
the intellectual property laws of the United States of America. No party
to this Agreement will bring a legal action under this Agreement more
than one year after the cause of action arose. Each party waives its
rights to a jury trial in any resulting litigation.</p>
</body></html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -1,7 +1,7 @@
{
"name": "Text Editor",
"name": "Text Editor (Platform app)",
"description": "Syntax highlighting text editor",
"version": "0.15",
"version": "0.16",
"manifest_version": 2,
"icons": {
"16": "icons/texteditor_16.png",
@@ -9,11 +9,20 @@
"48": "icons/texteditor_48.png",
"128": "icons/texteditor_128.png"
},
"intents": {
"http://webintents.org/view": {
"type": [
"text/*"
],
"title": "Text Editor (Platform app)"
}
},
"permissions": [
"experimental",
"clipboardRead",
"clipboardWrite",
"fileSystem"
"fileSystem",
"fileSystemWrite"
],
"app": {
"background": {

64
text-editor/modes.js Normal file
View File

@@ -0,0 +1,64 @@
define(function(require, exports, module) {
"use strict";
var Mode = function(name, desc, extensions) {
this.desc = desc;
this.mode = "ace/mode/" + name;
this.extRe = new RegExp("^.*\\.(" + extensions.join("|") + ")$", "g");
};
Mode.prototype.supportsFile = function(filename) {
return filename.match(this.extRe);
};
var modes = [
new Mode("c_cpp", "C/C++", ["c", "cpp", "cc", "cxx", "h", "hpp"]),
new Mode("clojure", "Clojure", ["clj"]),
new Mode("coffee", "CoffeeScript", ["coffee"]),
new Mode("coldfusion", "ColdFusion", ["cfm"]),
new Mode("csharp", "C#", ["cs"]),
new Mode("css", "CSS", ["css"]),
new Mode("golang", "Go", ["go"]),
new Mode("groovy", "Groovy", ["groovy"]),
new Mode("haxe", "haXe", ["hx"]),
new Mode("html", "HTML", ["html", "htm"]),
new Mode("java", "Java", ["java"]),
new Mode("javascript", "JavaScript", ["js"]),
new Mode("json", "JSON", ["json"]),
new Mode("latex", "LaTeX", ["tex"]),
new Mode("less", "LESS", ["less"]),
new Mode("lua", "Lua", ["lua"]),
new Mode("liquid", "Liquid", ["liquid"]),
new Mode("markdown", "Markdown", ["md", "markdown"]),
new Mode("ocaml", "OCaml", ["ml", "mli"]),
new Mode("perl", "Perl", ["pl", "pm"]),
new Mode("pgsql", "pgSQL", ["pgsql", "sql"]),
new Mode("php", "PHP", ["php"]),
new Mode("powershell", "Powershell", ["ps1"]),
new Mode("python", "Python", ["py"]),
new Mode("scala", "Scala", ["scala"]),
new Mode("scss", "SCSS", ["scss"]),
new Mode("ruby", "Ruby", ["rb"]),
new Mode("sql", "SQL", ["sql"]),
new Mode("svg", "SVG", ["svg"]),
new Mode("text", "Text", ["txt"]),
new Mode("textile", "Textile", ["textile"]),
new Mode("xml", "XML", ["xml"]),
new Mode("sh", "SH", ["sh"]),
new Mode("xquery", "XQuery", ["xq"])
];
function getModeFromBaseName(aBaseName) {
var mode = null;
for (var i = 0; i < modes.length; i++) {
if (modes[i].supportsFile(aBaseName)) {
mode = modes[i];
break;
}
}
return mode;
}
exports.getModeFromBaseName = getModeFromBaseName;
});

View File

@@ -44,10 +44,6 @@ body {
background-position: center;
}
#config {
background-image: url("icons/config.png");
}
#openfile {
background-image: url("icons/openfile.png");
}
@@ -68,41 +64,27 @@ body {
background-image: url("icons/new.png");
}
#controlspanel {
position: absolute;
left: -242px;
top: 0px;
width: 300px;
height: 100%;
z-index: 100000;
opacity: 0.9;
background: white;
border-right: 1px solid #CCC;
-webkit-transition: all 0.5s ease-out;
}
#logo {
padding: 15px;
margin-left: 70px;
}
#controls {
padding: 5px;
}
#controls td {
text-align: right;
}
#controls td + td {
text-align: left;
}
#editor {
#editarea {
position: absolute;
top: 0px;
left: 58px;
bottom: 0px;
right: 0px;
background: white;
}
#status {
border-bottom: 1px solid #CCC;
background-color: #EEE;
}
#path {
padding: 5px;
color: #777;
}
#error {
padding: 5px;
padding-top: 0px;
color: #C66;
}