Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Relaxing license.

  • Loading branch information...
commit ea1113b08df52e89f65d1df288896117302c5420 1 parent b8cf772
@Gozala authored
View
66 lib/commands.js → commands.js
@@ -1,44 +1,11 @@
-/* vim:ts=2:sts=2:sw=2:
- * ***** 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):
- * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.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 ***** */
+/* vim:set ts=2 sw=2 sts=2 expandtab */
+/*jshint asi: true undef: true es5: true node: true devel: true browser: true
+ forin: true latedef: false */
+/*global define: true */
-define(function(require, exports, module) {
+!define(function(require, exports, module) {
-'use strict'
+'use strict';
var canon = require('pilot/canon')
var types = require('./params')
@@ -82,24 +49,28 @@ function FocusEditor(env, target) {
function focusEditor(event) {
// If escape key we set focus to the editor.
if (event.keyCode === 27) {
- event.stopPropagation();
- event.preventDefault();
- event.target.blur();
- env.editor.focus();
+ event.stopPropagation()
+ event.preventDefault()
+ target.value = ""
+ target.blur()
+ env.editor.focus()
}
}
target.addEventListener("keyup", focusEditor, true);
return true;
}
+var conflicts = {
+ 'gotoline': 'gotoline'
+};
var commands = exports.commands = {
commandLine: {
exec: function exec(env, params, request) {
- var cli = document.getElementById("cockpitInput");
- env.editor.blur();
- cli.focus();
+ var cli = document.getElementById("cockpitInput")
+ env.editor.blur()
+ cli.focus()
// Yeap it's an ugly hack to put focus back to an editor.
- return exec.inited || (exec.inited = FocusEditor(env, cli));
+ return exec.inited || (exec.inited = FocusEditor(env, cli))
}
},
start: {
@@ -217,6 +188,7 @@ var commands = exports.commands = {
}
exports.plug = function plug(data, reason) {
+ canon.removeCommands(conflicts)
canon.addCommands(exports.commands)
}
exports.unplug = function unplug(data, reason) {
View
94 demo/launcher.js
@@ -1,100 +1,44 @@
-define(function(require, exports, module) {
+/* vim:set ts=2 sw=2 sts=2 expandtab */
+/*jshint asi: true undef: true es5: true node: true devel: true
+ forin: true latedef: false browser: true */
+/*global define: true port: true */
+!define(function(require, exports, module) {
exports.startup = function(data) {
- var env = data.env;
- var event = require("pilot/event");
+ var env = window.env = data.env;
+
+ var Range = require("ace/range").Range;
var Editor = require("ace/editor").Editor;
var Renderer = require("ace/virtual_renderer").VirtualRenderer;
- var theme = require("ace/theme/twilight");
- var EditSession = require("ace/edit_session").EditSession;
- var JavaScriptMode = require("ace/mode/javascript").Mode;
- var CssMode = require("ace/mode/css").Mode;
- var HtmlMode = require("ace/mode/html").Mode;
- var XmlMode = require("ace/mode/xml").Mode;
- var PythonMode = require("ace/mode/python").Mode;
- var PhpMode = require("ace/mode/php").Mode;
- var TextMode = require("ace/mode/text").Mode;
var UndoManager = require("ace/undomanager").UndoManager;
+ var EditSession = require("ace/edit_session").EditSession;
- var modes = {
- text: new TextMode(),
- xml: new XmlMode(),
- html: new HtmlMode(),
- css: new CssMode(),
- javascript: new JavaScriptMode(),
- python: new PythonMode(),
- php: new PhpMode()
- };
-
+ var theme = require("ace/theme/twilight");
var session = new EditSession('');
- session.setUndoManager(new UndoManager)
+ session.setUndoManager(new UndoManager());
var container = document.getElementById("editor");
env.editor = new Editor(new Renderer(container, theme));
+ env.editor.setSession(session);
// Each editor should contain reference to an `env` which will be used be
// passed to the commands executed by keybindings.
env.editor.env = Object.create(env);
-
function onResize() {
container.style.width = (document.documentElement.clientWidth) + "px";
container.style.height = (document.documentElement.clientHeight - 22) + "px";
env.editor.resize();
- };
+ env.editor.focus();
+ }
window.onresize = onResize;
onResize();
- event.addListener(container, "dragover", function(e) {
- return event.preventDefault(e);
- });
-
- event.addListener(container, "drop", function(e) {
- try {
- var file = e.dataTransfer.files[0];
- } catch(e) {
- console.error(e);
- return event.stopEvent();
- }
-
- if (window.FileReader) {
- var reader = new FileReader();
- reader.onload = function(e) {
- loadContent(reader.result, file.name)
- };
- reader.readAsText(file);
- }
- return event.preventDefault(e);
- });
-
- function getModeForFileURI(uri) {
- uri = String(uri).split('?')[0].split('#')[0]
- var mode = "text";
- if (/^.*\.js$/i.test(uri)) {
- mode = "javascript";
- } else if (/^.*\.xml$/i.test(uri)) {
- mode = "xml";
- } else if (/^.*\.html$/i.test(uri)) {
- mode = "html";
- } else if (/^.*\.css$/i.test(uri)) {
- mode = "css";
- } else if (/^.*\.py$/i.test(uri)) {
- mode = "python";
- } else if (/^.*\.php$/i.test(uri)) {
- mode = "php";
- }
- return modes[mode];
- }
-
- function loadContent(content, uri) {
- var session = env.editor.getSession()
- session.setValue(content)
- session.setMode(getModeForFileURI(uri))
- env.editor.focus()
- }
+ env.editor.renderer.setHScrollBarAlwaysVisible(false);
+ env.editor.setShowInvisibles(true);
- // Load default content.
- loadContent(document.getElementById("source").value, "helpme.js")
+ var JavaScriptMode = require("ace/mode/javascript").Mode;
+ session.setValue(document.getElementById("source").value, "helpme.js");
+ session.setMode(new JavaScriptMode());
};
-
});
View
60 index.html
@@ -5,42 +5,61 @@
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<style type="text/css" media="screen">
html, body {
+ font-size: 12px;
overflow: hidden;
margin: 0;
padding: 0;
height: 100%;
width: 100%;
- color: #ccc;
+ background: #2E2E2E;
}
-
+
+ #cockpitInput, #cockpitOutput, .cptOutput, .cptHints,
+ .cptCompletion span {
+ color: #ccc !important;
+ background: rgba(24, 24, 24, 0.8) !important;
+ border-color: rgb(24, 24, 24) !important;
+ box-shadow: 5px -1px 18px #000;
+ }
+
+ .cptRowIn, .cptRowOut {
+ border-radius: 4px;
+ padding: 1px;
+ margin: 2px;
+ background: rgba(64, 64, 64, 0.2) !important;
+ }
+ .cptRowIn *, .cptRowIn, .cptRowOut {
+ color: #ccc !important;
+ }
+
+ .cptRowOut p {
+ margin: 2px;
+ }
+
#cockpitInput {
position: absolute;
width: 100%;
- bottom: 0;
+ bottom: 0px;
+ padding: 3px;
border: none;
outline: none;
font-family: monaco consolas, courier, monospace;
- font-size: 120%;
+ font-size: 14px;
}
#cockpitOutput {
padding: 10px;
margin: 0 15px;
- border: 1px solid #ccc;
-moz-border-radius-topleft: 10px;
-moz-border-radius-topright: 10px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
- background: #DDD;
- color: #000;
}
</style>
</head>
<body>
- <div id="editor"></div>
- <input id="cockpitInput" type="text"/>
- <textarea id="source" style="display: none">/*
+ <textarea id="source" style="display: none">/*
This is a VIM mode for ACE
k
Move around: Use the cursor keys, or "h" to go left, h l
@@ -93,6 +112,8 @@
$ To the end of the line. When a count is given also go
[count - 1] lines downward |inclusive|.
*/</textarea>
+ <div id="editor"></div>
+ <input id="cockpitInput" type="text"/>
<script src="demo/require.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
@@ -101,8 +122,8 @@
ace: "../support/ace/lib/ace",
cockpit: "../support/cockpit/lib/cockpit",
pilot: "../support/pilot/lib/pilot",
- vice: "../lib",
- launcher: "./launcher"
+ vice: "../",
+ launcher: "../demo/launcher"
}
};
@@ -118,18 +139,17 @@
"pilot/index",
"cockpit/index",
"ace/defaults",
- "ace/keyboard",
"vice/vice",
"launcher"
];
- require(config, deps, function() {
- var catalog = require("pilot/plugin_manager").catalog;
- var env = window.env = require("pilot/environment").Environment();
- catalog.registerPlugins(plugins, { env: env }).then(function() {
- catalog.startupPlugins({ env: env });
- });
- });
+ require(config, deps, function() {
+ var catalog = require("pilot/plugin_manager").catalog;
+ catalog.registerPlugins(plugins).then(function() {
+ var env = require("pilot/environment").create();
+ catalog.startupPlugins({ env: env });
+ });
+ });
</script>
</body>
</html>
View
49 lib/keyboard.js → keyboard.js
@@ -1,44 +1,11 @@
-/* vim:ts=2:sts=2:sw=2:
- * ***** 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):
- * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.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 ***** */
+/* vim:set ts=2 sw=2 sts=2 expandtab */
+/*jshint asi: true undef: true es5: true node: true devel: true browser: true
+ forin: true latedef: false */
+/*global define: true */
-define(function(require, exports, module) {
+!define(function(require, exports, module) {
-"use strict"
+'use strict';
var types = require('./params')
var StateHandler = require("ace/keyboard/state_handler").StateHandler
@@ -129,11 +96,11 @@ var states = exports.states = {
params: [ types.line ]
},
{
- key: '\\$',
+ key: 'shift-4',
exec: 'gotolineend'
},
{
- key: '\\^',
+ key: 'shift-6',
exec: 'gotolinestart'
},
{
View
68 lib/params.js
@@ -1,68 +0,0 @@
-/* vim:ts=2:sts=2:sw=2:
- * ***** 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):
- * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.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) {
-
-exports['!'] = exports.ifBang = {
- name: '!',
- type: '!',
- defaultValue: ''
-}
-
-exports.bang = {
- name: '!',
- type: '!',
- defaultValue: '!'
-}
-
-exports.count = {
- name: 'count',
- regex: '([0-9]*)',
- match: 1,
- type: 'number',
- defaultValue: 1
-}
-
-exports.line = {
- name: 'line',
- regex: '([0-9]+)',
- match: 1,
- type: 'number'
-}
-
-})
View
77 lib/settings.js
@@ -1,77 +0,0 @@
-/* vim:ts=2:sts=2:sw=2:
- * ***** 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):
- * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.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) {
-
-// Ideally `onChange` have to be called with `env`, but as it's not we
-// save `env` given on startup and use it in setting change listeners.
-var env
-
-var keyboardBindings = require('./keyboard').bindings
-var utils = require('./utils')
-
-var settings = {
- isVimMode: {
- name: 'isVimMode',
- description: 'Whethere or not Vim mode is enabled',
- type: 'bool',
- defaultValue: true,
- onChange: function onChange(event) {
- if (event.value) {
- env.editor.setKeyboardHandler(keyboardBindings)
- utils.normalMode(env)
- } else {
- utils.insertMode(env)
- env.editor.setKeyboardHandler(null)
- }
- }
- }
-}
-
-exports.plug = function plug(data, reason) {
- env = data.env
- data.env.settings.addSettings(settings)
-}
-
-exports.unplug = function unplug(data, reason) {
- // if (env.settings) env.settings.setSetting('isVimMode', false)
- settings.isVimMode.onChange({ value: false })
- data.env.settings.removeSettings(settings)
-}
-
-})
View
63 lib/types.js
@@ -1,63 +0,0 @@
-/* vim:ts=2:sts=2:sw=2:
- * ***** 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):
- * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.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) {
-
-// Ideally `onChange` have to be called with `env`, but as it's not we
-// save `env` given on startup and use it in setting change listeners.
-var env
-
-var types = require('pilot/types')
-var SelectionType = require('pilot/types/basic').SelectionType
-
-exports.types = {
- '!': new SelectionType({
- name: '!',
- description: 'Whethere or not value must be inverted',
- data: [ '!', '' ]
- })
-}
-
-exports.plug = function plug() {
- types.registerTypes(exports.types)
-}
-exports.unplug = function unplug() {
- types.unregisterTypes(exports.types)
-}
-
-})
View
66 lib/vice.js
@@ -1,66 +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):
- * Irakli Gozalishvili <rfobic@gmail.com> (original author)
- *
- * 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) {
- var plugins = [
- require('./types'),
- require('./commands'),
- require('./settings')
- ]
-
- exports.startup = function startup(data, reason) {
- // Unfortunately plugins are initialized before `editor` is created and
- // there is no event we can listen to be called when editor is ready so we
- // use this ugly hack to init settings ones editor is ready.
- if (!data.env.editor) setTimeout(startup, 0, data, reason)
- else exports.plug(data, reason)
- }
-
- exports.plug = function plug(data, reason) {
- plugins.forEach(function(plugin) {
- plugin.plug(data, reason)
- })
- }
-
- exports.unplug = function unplug(data, reason) {
- plugins.forEach(function(plugin) {
- plugin.unplug(data, reason)
- })
- }
- exports.shutdown = exports.unplug
-
-})
View
51 package.json
@@ -1,32 +1,21 @@
-{ "name": "vice"
-, "version": "0.0.3"
-, "description": "Vim mode for ace."
-, "homepage": "http://github.com/Gozala/vice/"
-, "keywords": ["vim", "ace", "editor"]
-, "contributors":
- [ "Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)" ]
-, "repository":
- { "type": "git"
- , "url": "git://github.com/Gozala/vice.git"
- }
-, "bugs": { "web": "http://github.com/Gozala/vice/issues/" }
-, "directories":
- { "doc": "./docs"
- , "lib": "./lib"
- , "test": "./test"
- }
-, "dependencies":
- { "test": ">=0.0.10"
- , "ace": ">=0.1.5"
- }
-, "main": "./lib/vice.js"
-, "engines":
- { "node": ">=0.1.103"
- , "teleport": ">=0.2.0"
- }
-, "licenses" :
- [ { "type" : "MPL 1.1/LGPL 2.1/GPL 2.0"
- , "url" : "http://www.mozilla.org/MPL/"
- }
- ]
+{
+ "name": "vice",
+ "version": "0.0.4",
+ "description": "Vim mode for ace.",
+ "homepage": "http://github.com/Gozala/vice/",
+ "keywords": [ "vim", "ace", "editor" ],
+ "aouthor": "Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/Gozala/vice.git",
+ "web": "https://github.com/Gozala/vice"
+ },
+ "bugs": {
+ "web": "http://github.com/Gozala/vice/issues/"
+ },
+ "main": "./vice.js",
+ "licenses": [{
+ "type": "MIT",
+ "url": "http://jeditoolkit.com/LICENSE"
+ }]
}
View
36 params.js
@@ -0,0 +1,36 @@
+/* vim:set ts=2 sw=2 sts=2 expandtab */
+/*jshint asi: true undef: true es5: true node: true devel: true browser: true
+ forin: true latedef: false */
+/*global define: true */
+!define(function(require, exports, module) {
+
+'use strict';
+
+exports['!'] = exports.ifBang = {
+ name: '!',
+ type: '!',
+ defaultValue: ''
+}
+
+exports.bang = {
+ name: '!',
+ type: '!',
+ defaultValue: '!'
+}
+
+exports.count = {
+ name: 'count',
+ regex: '([0-9]*)',
+ match: 1,
+ type: 'number',
+ defaultValue: 1
+}
+
+exports.line = {
+ name: 'line',
+ regex: '([0-9]+)',
+ match: 1,
+ type: 'number'
+}
+
+});
View
45 settings.js
@@ -0,0 +1,45 @@
+/* vim:set ts=2 sw=2 sts=2 expandtab */
+/*jshint asi: true undef: true es5: true node: true devel: true browser: true
+ forin: true latedef: false */
+/*global define: true */
+!define(function(require, exports, module) {
+
+'use strict';
+
+// Ideally `onChange` have to be called with `env`, but as it's not we
+// save `env` given on startup and use it in setting change listeners.
+var env
+
+var keyboardBindings = require('./keyboard').bindings
+var utils = require('./utils')
+
+var settings = {
+ isVimMode: {
+ name: 'isVimMode',
+ description: 'Whethere or not Vim mode is enabled',
+ type: 'bool',
+ defaultValue: true,
+ onChange: function onChange(event) {
+ if (event.value) {
+ env.editor.setKeyboardHandler(keyboardBindings)
+ utils.normalMode(env)
+ } else {
+ utils.insertMode(env)
+ env.editor.setKeyboardHandler(null)
+ }
+ }
+ }
+}
+
+exports.plug = function plug(data, reason) {
+ env = data.env
+ data.env.settings.addSettings(settings)
+}
+
+exports.unplug = function unplug(data, reason) {
+ // if (env.settings) env.settings.setSetting('isVimMode', false)
+ settings.isVimMode.onChange({ value: false })
+ data.env.settings.removeSettings(settings)
+}
+
+});
View
31 types.js
@@ -0,0 +1,31 @@
+/* vim:set ts=2 sw=2 sts=2 expandtab */
+/*jshint asi: true undef: true es5: true node: true devel: true browser: true
+ forin: true latedef: false */
+/*global define: true */
+!define(function(require, exports, module) {
+
+'use strict';
+
+// Ideally `onChange` have to be called with `env`, but as it's not we
+// save `env` given on startup and use it in setting change listeners.
+var env
+
+var types = require('pilot/types')
+var SelectionType = require('pilot/types/basic').SelectionType
+
+exports.types = {
+ '!': new SelectionType({
+ name: '!',
+ description: 'Whethere or not value must be inverted',
+ data: [ '!', '' ]
+ })
+}
+
+exports.plug = function plug() {
+ types.registerTypes(exports.types)
+}
+exports.unplug = function unplug() {
+ types.unregisterTypes(exports.types)
+}
+
+});
View
50 lib/utils.js → utils.js
@@ -1,44 +1,10 @@
-/* vim:ts=2:sts=2:sw=2:
- * ***** 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):
- * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.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"
+/* vim:set ts=2 sw=2 sts=2 expandtab */
+/*jshint asi: true undef: true es5: true node: true devel: true browser: true
+ forin: true latedef: false */
+/*global define: true */
+!define(function(require, exports, module) {
+
+'use strict';
function moveUp(env, count) {
env.editor.selection.moveCursorBy(-1 * (count || 1), 0);
@@ -150,4 +116,4 @@ function insertMode(env) {
}
exports.insertMode = insertMode
-})
+});
View
36 vice.js
@@ -0,0 +1,36 @@
+/* vim:set ts=2 sw=2 sts=2 expandtab */
+/*jshint asi: true undef: true es5: true node: true devel: true browser: true
+ forin: true latedef: false */
+/*global define: true */
+!define(function(require, exports, module) {
+
+'use strict';
+
+ var plugins = [
+ require('./types'),
+ require('./commands'),
+ require('./settings')
+ ]
+
+ exports.startup = function startup(data, reason) {
+ // Unfortunately plugins are initialized before `editor` is created and
+ // there is no event we can listen to be called when editor is ready so we
+ // use this ugly hack to init settings ones editor is ready.
+ if (!data.env.editor) setTimeout(startup, 0, data, reason)
+ else exports.plug(data, reason)
+ }
+
+ exports.plug = function plug(data, reason) {
+ plugins.forEach(function(plugin) {
+ plugin.plug(data, reason)
+ })
+ }
+
+ exports.unplug = function unplug(data, reason) {
+ plugins.forEach(function(plugin) {
+ plugin.unplug(data, reason)
+ })
+ }
+ exports.shutdown = exports.unplug
+
+});
Please sign in to comment.
Something went wrong with that request. Please try again.