From 125539052ace7e934abdd280068fb4d9937fab9c Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 26 Jan 2011 19:13:54 +0800 Subject: [PATCH 1/2] setShowGutter must update width --- lib/ace/virtual_renderer.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 47444ee4..134fe487 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -260,9 +260,14 @@ var VirtualRenderer = function(container, theme) { }; this.setShowGutter = function(show){ + if(this.showGutter === show) + return; this.$gutter.style.display = show ? "block" : "none"; this.showGutter = show; + // set fake width to make onResize work + this.$size.width = -1 this.onResize(); + this.$gutterLayer.update(this.layerConfig) } this.$updatePrintMargin = function() { From 6b0087c234ca5adfd947cad2b12ab78ad94270d9 Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 26 Jan 2011 19:15:37 +0800 Subject: [PATCH 2/2] add toggle gutter to demo --- demo/startup.js | 10 ++++++++++ demo/styles.css | 16 ++++++++++++++++ editor.html | 4 +++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/demo/startup.js b/demo/startup.js index 1403fd1b..1b5a958f 100644 --- a/demo/startup.js +++ b/demo/startup.js @@ -277,6 +277,16 @@ exports.launch = function(env) { return event.preventDefault(e); }); + + // gutter + editor = env.editor + toggleGutter=function(){ + editor.renderer.setShowGutter(!editor.renderer.showGutter) + } + // + window.ace={ + editor: editor + } }; }); diff --git a/demo/styles.css b/demo/styles.css index ce59595c..325e6e82 100644 --- a/demo/styles.css +++ b/demo/styles.css @@ -53,4 +53,20 @@ body { -moz-border-radius-topright: 10px; border-top-left-radius: 4px; border-top-right-radius: 4px; background: #DDD; color: #000; +} + +#toggleGutter{ + height:8px; + width:20px; + background:lightblue; + bottom:0; + position:absolute; + z-index: 1000; + -moz-border-radius-topright: 20px; +} + +#toggleGutter:hover{ + -moz-box-shadow: 2px -1px 5px 3px #91B6D5; + border-right: 1px solid #A1A1CF; + border-top: 1px solid #A1A1CF; } \ No newline at end of file diff --git a/editor.html b/editor.html index 30e67abb..9849cbcb 100644 --- a/editor.html +++ b/editor.html @@ -64,8 +64,10 @@ -
+
+
+