From 838db65610156e6700359bf626e13cb810c18a99 Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Wed, 26 Jan 2011 18:01:40 +0100 Subject: [PATCH] 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;