From 22cc0e9a1cf0b3e14f6c6a9d1db1822c42a47aec Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Tue, 25 Jan 2011 02:58:15 +0100 Subject: [PATCH 1/6] Implementing CLI settings that are shown in the demo editor. --- demo/boot.js | 6 +- lib/ace/defaults.js | 51 +++++++++++++++ lib/ace/settings/default-settings.js | 97 ++++++++++++++++++++++++++++ support/pilot | 2 +- 4 files changed, 153 insertions(+), 3 deletions(-) create mode 100644 lib/ace/defaults.js create mode 100644 lib/ace/settings/default-settings.js diff --git a/demo/boot.js b/demo/boot.js index e84bfe3f..c5ca3b28 100644 --- a/demo/boot.js +++ b/demo/boot.js @@ -36,7 +36,7 @@ * ***** END LICENSE BLOCK ***** */ var config = { - paths: { + paths: { demo: "../demo", ace: "../lib/ace", cockpit: "../support/cockpit/lib/cockpit", @@ -47,10 +47,12 @@ var config = { var deps = [ "pilot/fixoldbrowsers", "pilot/plugin_manager", "pilot/settings", "pilot/environment", "demo/startup" ]; +var plugins = [ "pilot/index", "cockpit/index", "ace/defaults" ]; + require(config); require(deps, function() { var catalog = require("pilot/plugin_manager").catalog; - catalog.registerPlugins([ "pilot/index", "cockpit/index" ]).then(function() { + catalog.registerPlugins(plugins).then(function() { var env = require("pilot/environment").create(); catalog.startupPlugins({ env: env }).then(function() { require("demo/startup").launch(env); diff --git a/lib/ace/defaults.js b/lib/ace/defaults.js new file mode 100644 index 00000000..bd217cd1 --- /dev/null +++ b/lib/ace/defaults.js @@ -0,0 +1,51 @@ +/* vim:ts=4:sts=4:sw=4: + * ***** 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 Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Irakli Gozalishvili (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) { + +var settings = require("ace/settings/default-settings") + +exports.startup = function startup(data, reason) { + settings.startup(data, reason) +} + +exports.shutdown = function shutdown(data, reason) { + settings.shutdown(data, reason) +} + +}) diff --git a/lib/ace/settings/default-settings.js b/lib/ace/settings/default-settings.js new file mode 100644 index 00000000..4e5e0fdf --- /dev/null +++ b/lib/ace/settings/default-settings.js @@ -0,0 +1,97 @@ +/* vim:ts=4:sts=4:sw=4: + * ***** 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 Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Irakli Gozalishvili (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) { + +var types = require('pilot/types') +var SelectionType = require('pilot/types/basic').SelectionType + +var env + +var settingTypes = { + selectionStyle: new SelectionType({ + data: [ 'line', 'text' ] + }) +} + +var settings = { + printMargin: { + description: 'Position of the print margin column.', + type: 'number', + defaultValue: 80, + onChange: function onChange(event) { + if (env.editor) env.editor.setPrintMarginColumn(event.value) + } + }, + showIvisibles: { + description: 'Whether or not to show invisible characters.', + type: 'bool', + defaultValue: false, + onChange: function onChange(event) { + if (env.editor) env.editor.setShowInvisibles(event.value) + } + }, + highlightActiveLine: { + description: 'Whether or not highlight active line.', + type: 'bool', + defaultValue: true, + onChange: function onChange(event) { + if (env.editor) env.editor.setHighlightActiveLine(event.value) + } + }, + selectionStyle: { + description: 'Type of text selection.', + type: 'selectionStyle', + defaultValue: 'line', + onChange: function onChange(event) { + if (env.editor) env.editor.setSelectionStyle(event.value) + } + } +} + +exports.startup = function startup(data, reason) { + env = data.env + types.registerTypes(settingTypes) + data.env.settings.addSettings(settings) +} + +exports.shutdown = function shutdown(data, reason) { + data.env.settings.removeSettings(settings) +} + +}) diff --git a/support/pilot b/support/pilot index 9ef10946..85ecce3f 160000 --- a/support/pilot +++ b/support/pilot @@ -1 +1 @@ -Subproject commit 9ef10946d31d1b0e2bd63466fa5aba9c5269e5fd +Subproject commit 85ecce3f54711a5198ca7771bb000edbe71a0010 From 762dc52f861457e654b6ba4f4cf91cc80b5ef1be Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Tue, 25 Jan 2011 12:39:52 +0100 Subject: [PATCH 2/6] Allowing textmate like highlighting of right margin & indicator. Changed twilight style to demo this. --- lib/ace/css/editor.css | 24 +++++++++++++++++------- lib/ace/theme/twilight.js | 5 +++-- lib/ace/virtual_renderer.js | 11 ++++++++--- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/lib/ace/css/editor.css b/lib/ace/css/editor.css index cd537ddd..adfa1511 100644 --- a/lib/ace/css/editor.css +++ b/lib/ace/css/editor.css @@ -32,13 +32,23 @@ left: 0px; } +.ace_editor .ace_print_margin_layer { + z-index: 0; + position: absolute; + overflow: hidden; + margin: 0px; + left: 0px; + height: 100%; + width: 100%; +} + .ace_editor .ace_print_margin { position: absolute; height: 100%; } .ace_layer { - z-index: 0; + z-index: 1; position: absolute; overflow: hidden; white-space: nowrap; @@ -56,7 +66,7 @@ } .ace_cursor { - z-index: 3; + z-index: 4; position: absolute; } @@ -69,20 +79,20 @@ .ace_marker-layer .ace_step { position: absolute; - z-index: 2; + z-index: 3; } .ace_marker-layer .ace_selection { position: absolute; - z-index: 3; + z-index: 4; } .ace_marker-layer .ace_bracket { position: absolute; - z-index: 4; + z-index: 5; } .ace_marker-layer .ace_active_line { position: absolute; - z-index: 1; -} \ No newline at end of file + z-index: 2; +} diff --git a/lib/ace/theme/twilight.js b/lib/ace/theme/twilight.js index 4d27f963..36fb8953 100644 --- a/lib/ace/theme/twilight.js +++ b/lib/ace/theme/twilight.js @@ -64,8 +64,9 @@ define(function(require, exports, module) { }\ \ .ace-twilight .ace_print_margin {\ - width: 1px;\ - background: #e8e8e8;\ + border-left: 1px solid #3C3C3C;\ + width: 100%;\ + background: #242424;\ }\ \ .ace-twilight .ace_scroller {\ diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 687085fa..e52cd2c0 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -20,6 +20,7 @@ * * Contributor(s): * Fabian Jakobs + * Irakli Gozalishvili (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 @@ -265,13 +266,17 @@ var VirtualRenderer = function(container, theme) { } this.$updatePrintMargin = function() { + var containerEl + if (!this.$showPrintMargin && !this.$printMarginEl) return; - if (!this.$printMarginEl) { - this.$printMarginEl = document.createElement("div"); - this.content.insertBefore(this.$printMarginEl, this.$textLayer.element); + containerEl = document.createElement("div"); + containerEl.className = "ace_print_margin_layer"; + this.$printMarginEl = document.createElement("div") this.$printMarginEl.className = "ace_print_margin"; + containerEl.appendChild(this.$printMarginEl); + this.content.insertBefore(containerEl, this.$textLayer.element); } var style = this.$printMarginEl.style; From b98a404d983fe115c05915526105d316069fe0a6 Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Tue, 25 Jan 2011 15:47:56 +0100 Subject: [PATCH 3/6] Change git submodule to point to the latest pilot. --- support/pilot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/pilot b/support/pilot index 85ecce3f..b3a656ba 160000 --- a/support/pilot +++ b/support/pilot @@ -1 +1 @@ -Subproject commit 85ecce3f54711a5198ca7771bb000edbe71a0010 +Subproject commit b3a656ba07e038bb8f84530c4f56c38f7029929d From 83a43bfd625cb18cef4c38d7040e9b53ffce39ab Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Tue, 25 Jan 2011 16:00:01 +0100 Subject: [PATCH 4/6] Removing unnecessary and dependency on heavy 'node-o3-xml'. --- .gitmodules | 3 --- support/node-o3-xml | 1 - 2 files changed, 4 deletions(-) delete mode 160000 support/node-o3-xml diff --git a/.gitmodules b/.gitmodules index aee8d549..6074430c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "support/node-o3-xml"] - path = support/node-o3-xml - url = git://github.com/ajaxorg/node-o3-xml.git [submodule "support/cockpit"] path = support/cockpit url = git://github.com/ajaxorg/cockpit.git diff --git a/support/node-o3-xml b/support/node-o3-xml deleted file mode 160000 index 563a2b10..00000000 --- a/support/node-o3-xml +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 563a2b1091bd1b9a7d26a9f597aacb4341edb619 From 275a34a1dc279cf1e428e8f213a270514d8bbc36 Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Wed, 26 Jan 2011 00:35:31 +0100 Subject: [PATCH 5/6] Merge branch 'keyboard-handling' into vice --- lib/ace/keyboard/state_handler.js | 17 ++++++++++++----- support/pilot | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/ace/keyboard/state_handler.js b/lib/ace/keyboard/state_handler.js index ab50bc74..5861ad23 100644 --- a/lib/ace/keyboard/state_handler.js +++ b/lib/ace/keyboard/state_handler.js @@ -80,13 +80,13 @@ StateHandler.prototype = { } var keyArray = []; - if (hashId & 1) keyArray.push("Ctrl"); - if (hashId & 8) keyArray.push("Command"); - if (hashId & 2) keyArray.push("Option"); - if (hashId & 4) keyArray.push("Shift"); + if (hashId & 1) keyArray.push("ctrl"); + if (hashId & 8) keyArray.push("command"); + if (hashId & 2) keyArray.push("option"); + if (hashId & 4) keyArray.push("shift"); if (key) keyArray.push(key); - var symbolicName = keyArray.join("-").toLowerCase(); + var symbolicName = keyArray.join("-"); var bufferToUse = data.buffer + symbolicName; // Don't add the symbolic name to the key buffer if the alt_ key is @@ -194,6 +194,13 @@ StateHandler.prototype = { * This function is called by keyBinding. */ handleKeyboard: function(data, hashId, key) { + // If we pressed any command key but no other key, then ignore the input. + // Otherwise "shift-" is added to the buffer, and later on "shift-g" + // which results in "shift-shift-g" which doesn't make senese. + if (hashId != 0 && (key == "" || String.fromCharCode(0))) { + return null; + } + // Compute the current value of the keyboard input buffer. var r = this.$composeBuffer(data, hashId, key); var buffer = r.bufferToUse; diff --git a/support/pilot b/support/pilot index b3a656ba..af903446 160000 --- a/support/pilot +++ b/support/pilot @@ -1 +1 @@ -Subproject commit b3a656ba07e038bb8f84530c4f56c38f7029929d +Subproject commit af90344687c8486892b44d5decc4c2181df3a6cf From 838db65610156e6700359bf626e13cb810c18a99 Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Wed, 26 Jan 2011 18:01:40 +0100 Subject: [PATCH 6/6] Extending editor and twilight theme to allow styling of cursor form a vim plugin or any other that needs to visually indicate it's mode. --- lib/ace/css/editor.css | 1 + lib/ace/editor.js | 12 +++++++++++- lib/ace/theme/twilight.js | 4 ++++ lib/ace/virtual_renderer.js | 15 ++++++++++++++- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/ace/css/editor.css b/lib/ace/css/editor.css index f59da076..e610ca44 100644 --- a/lib/ace/css/editor.css +++ b/lib/ace/css/editor.css @@ -81,6 +81,7 @@ } .ace_cursor-layer { + z-index: 0; cursor: text; pointer-events: none; } diff --git a/lib/ace/editor.js b/lib/ace/editor.js index efa1cb9a..62b53138 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -1,4 +1,5 @@ -/* ***** BEGIN LICENSE BLOCK ***** +/* vim:ts=4:sts=4:sw=4: + * ***** 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 @@ -20,6 +21,7 @@ * * Contributor(s): * Fabian Jakobs + * Irakli Gozalishvili (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 @@ -196,6 +198,14 @@ var Editor =function(renderer, session) { this.renderer.setTheme(theme); }; + this.setStyle = function(style) { + this.renderer.setStyle(style) + }; + + this.unsetStyle = function(style) { + this.renderer.unsetStyle(style) + } + this.$highlightBrackets = function() { if (this.$bracketHighlight) { this.renderer.removeMarker(this.$bracketHighlight); diff --git a/lib/ace/theme/twilight.js b/lib/ace/theme/twilight.js index 36fb8953..600ba519 100644 --- a/lib/ace/theme/twilight.js +++ b/lib/ace/theme/twilight.js @@ -85,6 +85,10 @@ define(function(require, exports, module) { .ace-twilight .ace_cursor.ace_overwrite {\ border-left: 0px;\ border-bottom: 1px solid #A7A7A7;\ +}\ +.ace-twilight.normal-mode .ace_cursor.ace_overwrite {\ + border: 1px solid #FFE300;\ + background: #766B13;\ }\ \ .ace-twilight .ace_marker-layer .ace_selection {\ diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index edcaa3d9..47444ee4 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -1,4 +1,5 @@ -/* ***** BEGIN LICENSE BLOCK ***** +/* vim:ts=4:sts=4:sw=4: + * ***** 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 @@ -658,6 +659,18 @@ var VirtualRenderer = function(container, theme) { } }; + // Methods allows to add / remove CSS classnames to the editor element. + // This feature can be used by plug-ins to provide a visual indication of + // a certain mode that editor is in. + + this.setStyle = function setStyle(style) { + dom.addCssClass(this.container, style) + }; + + this.unsetStyle = function unsetStyle(style) { + dom.removeCssClass(this.container, style) + }; + }).call(VirtualRenderer.prototype); exports.VirtualRenderer = VirtualRenderer;