From 7150f70333e63104cf1a25826d4d6c5491314e3e Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:16:28 -0800 Subject: [PATCH 001/133] editor stats package genesis --- src/packages/editor-stats/index.coffee | 9 +++ .../editor-stats/src/editor-stats-view.coffee | 58 +++++++++++++++++++ .../editor-stats/stylesheets/editor-stats.css | 9 +++ 3 files changed, 76 insertions(+) create mode 100644 src/packages/editor-stats/index.coffee create mode 100644 src/packages/editor-stats/src/editor-stats-view.coffee create mode 100644 src/packages/editor-stats/stylesheets/editor-stats.css diff --git a/src/packages/editor-stats/index.coffee b/src/packages/editor-stats/index.coffee new file mode 100644 index 000000000..60a97582e --- /dev/null +++ b/src/packages/editor-stats/index.coffee @@ -0,0 +1,9 @@ +DeferredAtomPackage = require 'deferred-atom-package' + +module.exports = +class EditorStats extends DeferredAtomPackage + loadEvents: ['editor-stats:toggle'] + + instanceClass: 'editor-stats/src/editor-stats-view' + + onLoadEvent: (event, instance) -> instance.toggle() diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee new file mode 100644 index 000000000..480a34017 --- /dev/null +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -0,0 +1,58 @@ +{$$$} = require 'space-pen' +ScrollView = require 'scroll-view' +$ = require 'jquery' +_ = require 'underscore' + +module.exports = +class EditorStatsView extends ScrollView + time = (date) -> + date.setTime(date.getTime() + 6e4) + hour = date.getHours() + minute = date.getMinutes() + "#{hour}:#{minute}" + + @activate: (rootView, state) -> + @instance = new EditorStatsView(rootView, state?.eventLog) + + @content: (rootView) -> + @div class: 'editor-stats', tabindex: -1 + + @serialize: -> + @instance.serialize() + + eventlog: [], + + initialize: (@rootView, @eventLog = {}) -> + super + + date = new Date() + future = new Date(date.getTime() + 36e5) + @eventlog[time(date)] = 0 + + while date <= future + @eventlog[time(date)] = 0 + + @rootView.on 'keyup', @track + @rootView.on 'mousedown', @track + + track: => + date = new Date + @eventlog[time(date)] += 1 + console.log @eventlog + + toggle: -> + if @hasParent() + @detach() + else + @attach() + + attach: -> + @rootView.append @ + @focus() + + detach: -> + super() + @rootView.focus() + + serialize: -> + eventLog: @eventLog \ No newline at end of file diff --git a/src/packages/editor-stats/stylesheets/editor-stats.css b/src/packages/editor-stats/stylesheets/editor-stats.css new file mode 100644 index 000000000..827da6667 --- /dev/null +++ b/src/packages/editor-stats/stylesheets/editor-stats.css @@ -0,0 +1,9 @@ +.editor-stats { + position: absolute; + height: 200px; + width: 100%; + bottom: 0; + left: 0; + z-index: 99; + background: #1d1f21; +} \ No newline at end of file From fd7358cb9ad42d71413256f016fc1d57a4b2a1d4 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:21:01 -0800 Subject: [PATCH 002/133] maintain the event log length at 60 items --- src/packages/editor-stats/src/editor-stats-view.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 480a34017..72873c6ea 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -37,7 +37,11 @@ class EditorStatsView extends ScrollView track: => date = new Date - @eventlog[time(date)] += 1 + times = time date + @eventlog[times] ||= 0 + @eventlog[times] += 1 + + @eventlog.shift() if @eventlog.length > 60 console.log @eventlog toggle: -> From e3831dddbae28ca0c75e269771ebed63dd6af1c6 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:38:00 -0800 Subject: [PATCH 003/133] cancel command --- src/packages/editor-stats/src/editor-stats-view.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 72873c6ea..861d8cb0b 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -25,6 +25,8 @@ class EditorStatsView extends ScrollView initialize: (@rootView, @eventLog = {}) -> super + @command 'core:cancel', @detach + date = new Date() future = new Date(date.getTime() + 36e5) @eventlog[time(date)] = 0 From 740d929cdd6a3526ce8dd1a093648c1b6b02b128 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:38:19 -0800 Subject: [PATCH 004/133] expose d3 to the view --- src/packages/editor-stats/src/editor-stats-view.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 861d8cb0b..555dbfd3f 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -11,6 +11,8 @@ class EditorStatsView extends ScrollView minute = date.getMinutes() "#{hour}:#{minute}" + d3 = require 'd3.v3' + @activate: (rootView, state) -> @instance = new EditorStatsView(rootView, state?.eventLog) From b065a67605075374d8bd1664c57b85231ff8a024 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:38:38 -0800 Subject: [PATCH 005/133] fat arrow detach --- src/packages/editor-stats/src/editor-stats-view.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 555dbfd3f..16c12bc6f 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -58,7 +58,7 @@ class EditorStatsView extends ScrollView @rootView.append @ @focus() - detach: -> + detach: => super() @rootView.focus() From f6c9dc1b1c100194553ed594db0501d0c65c2a8c Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:38:57 -0800 Subject: [PATCH 006/133] append svg element --- .../editor-stats/src/editor-stats-view.coffee | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 16c12bc6f..a35de475e 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -39,6 +39,17 @@ class EditorStatsView extends ScrollView @rootView.on 'keyup', @track @rootView.on 'mousedown', @track + append: -> + w = @.width() + h = @.height() + [pt, pl, pb, pr] = [0,0,0,0] + + d3.select(@.get(0)).append('svg') + .attr('width', w) + .attr('height', h) + .append('g') + .attr('transform', "translate(#{pl},#{pt})") + track: => date = new Date times = time date @@ -57,6 +68,7 @@ class EditorStatsView extends ScrollView attach: -> @rootView.append @ @focus() + @append() detach: => super() From 7b586d85f8cb75599cde3887f2f765792399f345 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:39:06 -0800 Subject: [PATCH 007/133] update drawing on every event --- src/packages/editor-stats/src/editor-stats-view.coffee | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index a35de475e..279392ec1 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -50,6 +50,12 @@ class EditorStatsView extends ScrollView .append('g') .attr('transform', "translate(#{pl},#{pt})") + draw: -> + w = @.width() + h = @.height() + [pt, pl, pb, pr] = [0,0,0,0] + + track: => date = new Date times = time date @@ -57,7 +63,7 @@ class EditorStatsView extends ScrollView @eventlog[times] += 1 @eventlog.shift() if @eventlog.length > 60 - console.log @eventlog + @draw() toggle: -> if @hasParent() From 3cb4519230097ecd6393981506e57cea6a60ce1c Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:56:44 -0800 Subject: [PATCH 008/133] store x and y scales --- src/packages/editor-stats/src/editor-stats-view.coffee | 2 ++ src/packages/editor-stats/stylesheets/editor-stats.css | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 279392ec1..ab2f7abaf 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -12,6 +12,8 @@ class EditorStatsView extends ScrollView "#{hour}:#{minute}" d3 = require 'd3.v3' + x = d3.scale.ordinal().domain d3.range(60) + y = d3.scale.linear() @activate: (rootView, state) -> @instance = new EditorStatsView(rootView, state?.eventLog) diff --git a/src/packages/editor-stats/stylesheets/editor-stats.css b/src/packages/editor-stats/stylesheets/editor-stats.css index 827da6667..9e01e5b7a 100644 --- a/src/packages/editor-stats/stylesheets/editor-stats.css +++ b/src/packages/editor-stats/stylesheets/editor-stats.css @@ -1,6 +1,6 @@ .editor-stats { position: absolute; - height: 200px; + height: 50px; width: 100%; bottom: 0; left: 0; From 4b0a7a135d3aab2e83f6b5af5d9899c515e780ea Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:56:53 -0800 Subject: [PATCH 009/133] append the bars --- .../editor-stats/src/editor-stats-view.coffee | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index ab2f7abaf..283b0c0bc 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -57,6 +57,23 @@ class EditorStatsView extends ScrollView h = @.height() [pt, pl, pb, pr] = [0,0,0,0] + data = d3.entries @eventlog + max = d3.max data, (d) -> d.value + + x.rangeRoundBands [0, w - pl - pr], 0.1 + y.domain([0, max]).range [h, 0] + + vis = d3.select('svg g') + + bars = vis.selectAll('g.bar') + .data(data) + .enter().append('g') + .attr('transform', (d, i) -> "translate(#{x(i)}, 0)") + + bars.append('rect') + .attr('width', x.rangeBand()) + .attr('height', (d, i) -> y(d.value)) + track: => date = new Date From e9ba5f8f8567ca31ad147e4c0c491be688c1bc08 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 14:57:47 -0800 Subject: [PATCH 010/133] update working smoothly --- .../editor-stats/src/editor-stats-view.coffee | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 283b0c0bc..cb8f59909 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -38,19 +38,8 @@ class EditorStatsView extends ScrollView while date <= future @eventlog[time(date)] = 0 - @rootView.on 'keyup', @track - @rootView.on 'mousedown', @track - - append: -> - w = @.width() - h = @.height() - [pt, pl, pb, pr] = [0,0,0,0] - - d3.select(@.get(0)).append('svg') - .attr('width', w) - .attr('height', h) - .append('g') - .attr('transform', "translate(#{pl},#{pt})") + @rootView.on 'keydown', @track + @rootView.on 'mouseup', @track draw: -> w = @.width() @@ -63,17 +52,32 @@ class EditorStatsView extends ScrollView x.rangeRoundBands [0, w - pl - pr], 0.1 y.domain([0, max]).range [h, 0] - vis = d3.select('svg g') + vis = d3.select(@.get(0)).append('svg') + .attr('width', w) + .attr('height', h) + .append('g') + .attr('transform', "translate(#{pl},#{pt})") - bars = vis.selectAll('g.bar') + bars = vis.selectAll('rect.bar') .data(data) - .enter().append('g') - .attr('transform', (d, i) -> "translate(#{x(i)}, 0)") - - bars.append('rect') + .enter().append('rect') + .attr('x', (d, i) => x i) + .attr('y', (d) -> y d.value) + .attr('height', (d) -> h - y(d.value)) .attr('width', x.rangeBand()) - .attr('height', (d, i) -> y(d.value)) + update = => + newdata = d3.entries @eventlog + max = d3.max newdata, (d) -> d.value + + x.rangeRoundBands [0, w - pl - pr], 0.1 + y.domain([0, max]).range [h, 0] + + bars.data(newdata).transition() + .attr('height', (d, i) -> h - y(d.value)) + .attr('y', (d, i) -> y(d.value)) + + setInterval update, 5000 track: => date = new Date @@ -81,8 +85,7 @@ class EditorStatsView extends ScrollView @eventlog[times] ||= 0 @eventlog[times] += 1 - @eventlog.shift() if @eventlog.length > 60 - @draw() + @eventlog.shift() if @eventlog.length > 59 toggle: -> if @hasParent() @@ -93,7 +96,7 @@ class EditorStatsView extends ScrollView attach: -> @rootView.append @ @focus() - @append() + @draw() detach: => super() From 168f08611c63ee036313367a2d5bdf1d3b0419df Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 15:44:09 -0800 Subject: [PATCH 011/133] color dem bars --- src/packages/editor-stats/stylesheets/editor-stats.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/packages/editor-stats/stylesheets/editor-stats.css b/src/packages/editor-stats/stylesheets/editor-stats.css index 9e01e5b7a..d298ab9d9 100644 --- a/src/packages/editor-stats/stylesheets/editor-stats.css +++ b/src/packages/editor-stats/stylesheets/editor-stats.css @@ -6,4 +6,9 @@ left: 0; z-index: 99; background: #1d1f21; + border-top: 1px solid rgba(255, 255, 255, 0.1); +} + +.editor-stats rect.bar { + fill: rgba(255, 255, 255, 0.1); } \ No newline at end of file From 57c9412d99d4cf16b66b9444d6cc67cbb6b71971 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 15:44:16 -0800 Subject: [PATCH 012/133] fix scales --- .../editor-stats/src/editor-stats-view.coffee | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index cb8f59909..66e47dcf5 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -5,6 +5,8 @@ _ = require 'underscore' module.exports = class EditorStatsView extends ScrollView + hours = 2 + time = (date) -> date.setTime(date.getTime() + 6e4) hour = date.getHours() @@ -12,7 +14,7 @@ class EditorStatsView extends ScrollView "#{hour}:#{minute}" d3 = require 'd3.v3' - x = d3.scale.ordinal().domain d3.range(60) + x = d3.scale.ordinal().domain d3.range(hours * 60) y = d3.scale.linear() @activate: (rootView, state) -> @@ -32,25 +34,25 @@ class EditorStatsView extends ScrollView @command 'core:cancel', @detach date = new Date() - future = new Date(date.getTime() + 36e5) + future = new Date(date.getTime() + (36e5 * hours)) @eventlog[time(date)] = 0 - while date <= future + while date < future @eventlog[time(date)] = 0 + console.log @eventlog @rootView.on 'keydown', @track @rootView.on 'mouseup', @track draw: -> w = @.width() h = @.height() - [pt, pl, pb, pr] = [0,0,0,0] + [pt, pl, pb, pr] = [5,0,0,0] data = d3.entries @eventlog - max = d3.max data, (d) -> d.value x.rangeRoundBands [0, w - pl - pr], 0.1 - y.domain([0, max]).range [h, 0] + y.range [h, 0] vis = d3.select(@.get(0)).append('svg') .attr('width', w) @@ -61,17 +63,16 @@ class EditorStatsView extends ScrollView bars = vis.selectAll('rect.bar') .data(data) .enter().append('rect') - .attr('x', (d, i) => x i) + .attr('x', (d, i) -> console.log x(0); x(i)) .attr('y', (d) -> y d.value) - .attr('height', (d) -> h - y(d.value)) .attr('width', x.rangeBand()) + .attr('class', 'bar') update = => newdata = d3.entries @eventlog max = d3.max newdata, (d) -> d.value - x.rangeRoundBands [0, w - pl - pr], 0.1 - y.domain([0, max]).range [h, 0] + y.domain [0, max] bars.data(newdata).transition() .attr('height', (d, i) -> h - y(d.value)) @@ -84,8 +85,7 @@ class EditorStatsView extends ScrollView times = time date @eventlog[times] ||= 0 @eventlog[times] += 1 - - @eventlog.shift() if @eventlog.length > 59 + @eventlog.shift() if @eventlog.length > (hours * 60) toggle: -> if @hasParent() From aa5660ba81c451e27145462f1854c180b30e5783 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 15:46:19 -0800 Subject: [PATCH 013/133] syntax yo --- src/packages/editor-stats/src/editor-stats-view.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 66e47dcf5..996968724 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -5,7 +5,7 @@ _ = require 'underscore' module.exports = class EditorStatsView extends ScrollView - hours = 2 + hours = 6 time = (date) -> date.setTime(date.getTime() + 6e4) @@ -63,7 +63,7 @@ class EditorStatsView extends ScrollView bars = vis.selectAll('rect.bar') .data(data) .enter().append('rect') - .attr('x', (d, i) -> console.log x(0); x(i)) + .attr('x', (d, i) -> x i) .attr('y', (d) -> y d.value) .attr('width', x.rangeBand()) .attr('class', 'bar') @@ -76,7 +76,7 @@ class EditorStatsView extends ScrollView bars.data(newdata).transition() .attr('height', (d, i) -> h - y(d.value)) - .attr('y', (d, i) -> y(d.value)) + .attr('y', (d, i) -> y d.value) setInterval update, 5000 From 29b3a1d5828415a28a4d747dea345a409065ca91 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 09:00:16 -0800 Subject: [PATCH 014/133] add keymap for editor stats --- src/packages/editor-stats/keymaps/editor-stats.cson | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/packages/editor-stats/keymaps/editor-stats.cson diff --git a/src/packages/editor-stats/keymaps/editor-stats.cson b/src/packages/editor-stats/keymaps/editor-stats.cson new file mode 100644 index 000000000..1364f2098 --- /dev/null +++ b/src/packages/editor-stats/keymaps/editor-stats.cson @@ -0,0 +1,5 @@ +'body, .editor-stats': + 'meta-alt-s': 'editor-stats:toggle' + +'.editor-stats': + 'meta-alt-s': 'editor-stats:toggle' From 0c878c5e7da508ce14f4298dec2ba913deaad041 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 09:00:40 -0800 Subject: [PATCH 015/133] put editor stats in the document flow so it doesn't overlap the status bar --- .../editor-stats/src/editor-stats-view.coffee | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 996968724..037c449b2 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -5,7 +5,7 @@ _ = require 'underscore' module.exports = class EditorStatsView extends ScrollView - hours = 6 + hours = 2 time = (date) -> date.setTime(date.getTime() + 6e4) @@ -17,6 +17,9 @@ class EditorStatsView extends ScrollView x = d3.scale.ordinal().domain d3.range(hours * 60) y = d3.scale.linear() + xaxis = d3.svg.axis().scale(x) + .orient('top') + @activate: (rootView, state) -> @instance = new EditorStatsView(rootView, state?.eventLog) @@ -32,6 +35,7 @@ class EditorStatsView extends ScrollView super @command 'core:cancel', @detach + @statusBar = @rootView.find '.status-bar' date = new Date() future = new Date(date.getTime() + (36e5 * hours)) @@ -40,19 +44,19 @@ class EditorStatsView extends ScrollView while date < future @eventlog[time(date)] = 0 - console.log @eventlog @rootView.on 'keydown', @track @rootView.on 'mouseup', @track draw: -> - w = @.width() + w = @statusBar.width() h = @.height() - [pt, pl, pb, pr] = [5,0,0,0] + [pt, pl, pb, pr] = [15,0,0,0] data = d3.entries @eventlog - x.rangeRoundBands [0, w - pl - pr], 0.1 + x.rangeRoundBands [0, w - pl - pr], 0.2 y.range [h, 0] + xaxis.tickSize(-h - pt - pb, 50) vis = d3.select(@.get(0)).append('svg') .attr('width', w) @@ -60,6 +64,10 @@ class EditorStatsView extends ScrollView .append('g') .attr('transform', "translate(#{pl},#{pt})") + vis.append('g') + .attr('class', 'x axis') + .call(xaxis) + bars = vis.selectAll('rect.bar') .data(data) .enter().append('rect') @@ -94,7 +102,7 @@ class EditorStatsView extends ScrollView @attach() attach: -> - @rootView.append @ + @.insertBefore @statusBar @focus() @draw() From ebc7daf1dcc0d46ccf7dca3d398a1471ce5a7dd0 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 09:00:48 -0800 Subject: [PATCH 016/133] more styles --- .../editor-stats/stylesheets/editor-stats.css | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/packages/editor-stats/stylesheets/editor-stats.css b/src/packages/editor-stats/stylesheets/editor-stats.css index d298ab9d9..0644808bf 100644 --- a/src/packages/editor-stats/stylesheets/editor-stats.css +++ b/src/packages/editor-stats/stylesheets/editor-stats.css @@ -1,14 +1,27 @@ .editor-stats { - position: absolute; height: 50px; width: 100%; - bottom: 0; - left: 0; - z-index: 99; background: #1d1f21; border-top: 1px solid rgba(255, 255, 255, 0.1); } .editor-stats rect.bar { - fill: rgba(255, 255, 255, 0.1); + fill: rgba(255, 255, 255, 0.2); + shape-rendering: crispedges; +} + +.editor-stats text { + font-size: 10px; + fill: rgba(255, 255, 255, 0.2); +} + +.editor-stats line { + stroke: #ccc; + stroke-opacity: 0.05; + stroke-width: 1px; + shape-rendering: crispedges; +} + +.editor-stats path.domain { + fill: none; } \ No newline at end of file From 6080ba66e152ef4c7b910b03bf85aad55971c4e2 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 09:33:39 -0800 Subject: [PATCH 017/133] tweak x axis display --- .../editor-stats/src/editor-stats-view.coffee | 16 ++++++++++++---- .../editor-stats/stylesheets/editor-stats.css | 5 +++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 037c449b2..61e671ec8 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -5,7 +5,7 @@ _ = require 'underscore' module.exports = class EditorStatsView extends ScrollView - hours = 2 + hours = 4 time = (date) -> date.setTime(date.getTime() + 6e4) @@ -13,6 +13,7 @@ class EditorStatsView extends ScrollView minute = date.getMinutes() "#{hour}:#{minute}" + startDate = new Date d3 = require 'd3.v3' x = d3.scale.ordinal().domain d3.range(hours * 60) y = d3.scale.linear() @@ -37,7 +38,7 @@ class EditorStatsView extends ScrollView @command 'core:cancel', @detach @statusBar = @rootView.find '.status-bar' - date = new Date() + date = new Date(startDate) future = new Date(date.getTime() + (36e5 * hours)) @eventlog[time(date)] = 0 @@ -48,7 +49,7 @@ class EditorStatsView extends ScrollView @rootView.on 'mouseup', @track draw: -> - w = @statusBar.width() + w = @statusBar.outerWidth() h = @.height() [pt, pl, pb, pr] = [15,0,0,0] @@ -56,7 +57,7 @@ class EditorStatsView extends ScrollView x.rangeRoundBands [0, w - pl - pr], 0.2 y.range [h, 0] - xaxis.tickSize(-h - pt - pb, 50) + xaxis.tickSize(-h + pt + pb, 50) vis = d3.select(@.get(0)).append('svg') .attr('width', w) @@ -67,6 +68,13 @@ class EditorStatsView extends ScrollView vis.append('g') .attr('class', 'x axis') .call(xaxis) + .selectAll('g') + .style('display', (d, i) -> + if i % 15 == 0 || i % 5 == 0 + 'block' + else + 'none' + ).classed('minor', (d, i) -> i % 5 == 0 && i % 15 != 0) bars = vis.selectAll('rect.bar') .data(data) diff --git a/src/packages/editor-stats/stylesheets/editor-stats.css b/src/packages/editor-stats/stylesheets/editor-stats.css index 0644808bf..3e9ccdf97 100644 --- a/src/packages/editor-stats/stylesheets/editor-stats.css +++ b/src/packages/editor-stats/stylesheets/editor-stats.css @@ -13,6 +13,11 @@ .editor-stats text { font-size: 10px; fill: rgba(255, 255, 255, 0.2); + font-family: Courier; +} + +.editor-stats .minor text { + display: none; } .editor-stats line { From 2abe3e47ded248b0fc6993876f8379b0e4bda48d Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 09:41:49 -0800 Subject: [PATCH 018/133] show actual time on scale --- src/packages/editor-stats/src/editor-stats-view.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 61e671ec8..ae008decd 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -20,6 +20,9 @@ class EditorStatsView extends ScrollView xaxis = d3.svg.axis().scale(x) .orient('top') + .tickFormat (d) -> + d = new Date(startDate.getTime() + (d * 6e4)) + "#{d.getHours()}:#{d.getMinutes()}" @activate: (rootView, state) -> @instance = new EditorStatsView(rootView, state?.eventLog) From bc61c3ca984956316625996bdc94268673390921 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 10:14:04 -0800 Subject: [PATCH 019/133] remove when detached --- src/packages/editor-stats/src/editor-stats-view.coffee | 1 + src/packages/editor-stats/stylesheets/editor-stats.css | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index ae008decd..e558dfa68 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -119,6 +119,7 @@ class EditorStatsView extends ScrollView detach: => super() + @.remove() @rootView.focus() serialize: -> diff --git a/src/packages/editor-stats/stylesheets/editor-stats.css b/src/packages/editor-stats/stylesheets/editor-stats.css index 3e9ccdf97..1368dcdb1 100644 --- a/src/packages/editor-stats/stylesheets/editor-stats.css +++ b/src/packages/editor-stats/stylesheets/editor-stats.css @@ -10,6 +10,10 @@ shape-rendering: crispedges; } +.editor-stats rect.bar.max { + fill: rgba(0, 163, 255, 1); +} + .editor-stats text { font-size: 10px; fill: rgba(255, 255, 255, 0.2); From 1afb2fbeb571e813fe65082176fe11ca6d82e6e3 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 10:14:12 -0800 Subject: [PATCH 020/133] highlight the max minute --- src/packages/editor-stats/src/editor-stats-view.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index e558dfa68..13fbb1ad7 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -97,6 +97,8 @@ class EditorStatsView extends ScrollView .attr('height', (d, i) -> h - y(d.value)) .attr('y', (d, i) -> y d.value) + bars.classed('max', (d, i) -> d.value == max) + setInterval update, 5000 track: => From 164b50d795542f67a6b528ed8f059c3b0bddc6a7 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 10:14:26 -0800 Subject: [PATCH 021/133] zero pad minutes --- src/packages/editor-stats/src/editor-stats-view.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 13fbb1ad7..8dc2ae947 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -22,7 +22,9 @@ class EditorStatsView extends ScrollView .orient('top') .tickFormat (d) -> d = new Date(startDate.getTime() + (d * 6e4)) - "#{d.getHours()}:#{d.getMinutes()}" + mins = d.getMinutes() + mins = "0#{mins}" if mins < 9 + "#{d.getHours()}:#{mins}" @activate: (rootView, state) -> @instance = new EditorStatsView(rootView, state?.eventLog) From 6c10622b2faa4ac2143d6b7ddedf6b544630824a Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 10:57:44 -0800 Subject: [PATCH 022/133] support escape key to exit command panel --- src/packages/command-panel/src/command-panel-view.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/packages/command-panel/src/command-panel-view.coffee b/src/packages/command-panel/src/command-panel-view.coffee index 7ccb74a48..b297516df 100644 --- a/src/packages/command-panel/src/command-panel-view.coffee +++ b/src/packages/command-panel/src/command-panel-view.coffee @@ -44,6 +44,7 @@ class CommandPanelView extends View @command 'tool-panel:unfocus', => @rootView.focus() @command 'core:close', => @detach(); false + @command 'core:cancel', => @detach(); false @command 'core:confirm', => @execute() @command 'core:move-up', => @navigateBackwardInHistory() @command 'core:move-down', => @navigateForwardInHistory() From 2d87a60019af9f086d4063acd82f512f4707003a Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 12:15:15 -0800 Subject: [PATCH 023/133] camelCase --- .../editor-stats/src/editor-stats-view.coffee | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 8dc2ae947..a5cd4053d 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -35,7 +35,7 @@ class EditorStatsView extends ScrollView @serialize: -> @instance.serialize() - eventlog: [], + eventLog: [], initialize: (@rootView, @eventLog = {}) -> super @@ -45,10 +45,10 @@ class EditorStatsView extends ScrollView date = new Date(startDate) future = new Date(date.getTime() + (36e5 * hours)) - @eventlog[time(date)] = 0 + @eventLog[time(date)] = 0 while date < future - @eventlog[time(date)] = 0 + @eventLog[time(date)] = 0 @rootView.on 'keydown', @track @rootView.on 'mouseup', @track @@ -58,7 +58,7 @@ class EditorStatsView extends ScrollView h = @.height() [pt, pl, pb, pr] = [15,0,0,0] - data = d3.entries @eventlog + data = d3.entries @eventLog x.rangeRoundBands [0, w - pl - pr], 0.2 y.range [h, 0] @@ -90,7 +90,7 @@ class EditorStatsView extends ScrollView .attr('class', 'bar') update = => - newdata = d3.entries @eventlog + newdata = d3.entries @eventLog max = d3.max newdata, (d) -> d.value y.domain [0, max] @@ -106,9 +106,9 @@ class EditorStatsView extends ScrollView track: => date = new Date times = time date - @eventlog[times] ||= 0 - @eventlog[times] += 1 - @eventlog.shift() if @eventlog.length > (hours * 60) + @eventLog[times] ||= 0 + @eventLog[times] += 1 + @eventLog.shift() if @eventLog.length > (hours * 60) toggle: -> if @hasParent() From c5b9c38311a9765f702142bf02e898d8456c4959 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 12:15:25 -0800 Subject: [PATCH 024/133] specs for editor stats --- .../spec/editor-stats-spec.coffee | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/packages/editor-stats/spec/editor-stats-spec.coffee diff --git a/src/packages/editor-stats/spec/editor-stats-spec.coffee b/src/packages/editor-stats/spec/editor-stats-spec.coffee new file mode 100644 index 000000000..deba8fe9e --- /dev/null +++ b/src/packages/editor-stats/spec/editor-stats-spec.coffee @@ -0,0 +1,46 @@ +$ = require 'jquery' +RootView = require 'root-view' +EditorStats = require 'editor-stats/src/editor-stats-view' + +fdescribe "EditorStats", -> + [rootView, editorStats, editor, date, time] = [] + + simulateKeyUp = (key) -> + e = $.Event "keydown", keyCode: key.charCodeAt(0) + rootView.trigger(e) + + simulateClick = -> + e = $.Event "mouseup" + rootView.trigger(e) + + beforeEach -> + rootView = new RootView(require.resolve('fixtures/sample.js')) + + date = new Date() + mins = date.getMinutes() + hours = date.getHours() + + mins = if mins == 60 then '01' else mins + 1 + time = "#{hours}:#{mins}" + + atom.loadPackage('editor-stats').getInstance() + editor = rootView.getActiveEditor() + editorStats = EditorStats.instance + + afterEach -> + rootView.deactivate() + + describe "when a keyup event is triggered", -> + it "records the number of times a keyup is triggered", -> + simulateKeyUp('a') + expect(editorStats.eventLog[time]).toBe 1 + simulateKeyUp('b') + expect(editorStats.eventLog[time]).toBe 2 + + describe "when a mouseup event is triggered", -> + it "records the number of times a mouseup is triggered", -> + simulateClick() + expect(editorStats.eventLog[time]).toBe 1 + simulateClick() + expect(editorStats.eventLog[time]).toBe 2 + From 1fa16c4ae125c3c1904cf8a7f23d78aecc837d16 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 13:56:35 -0800 Subject: [PATCH 025/133] refocus preview list after performing operation Allows esc key to exit the command pallete --- src/packages/command-panel/src/command-panel-view.coffee | 1 - src/packages/command-panel/src/preview-list.coffee | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/packages/command-panel/src/command-panel-view.coffee b/src/packages/command-panel/src/command-panel-view.coffee index b297516df..7ccb74a48 100644 --- a/src/packages/command-panel/src/command-panel-view.coffee +++ b/src/packages/command-panel/src/command-panel-view.coffee @@ -44,7 +44,6 @@ class CommandPanelView extends View @command 'tool-panel:unfocus', => @rootView.focus() @command 'core:close', => @detach(); false - @command 'core:cancel', => @detach(); false @command 'core:confirm', => @execute() @command 'core:move-up', => @navigateBackwardInHistory() @command 'core:move-down', => @navigateForwardInHistory() diff --git a/src/packages/command-panel/src/preview-list.coffee b/src/packages/command-panel/src/preview-list.coffee index 34cbd240c..a068da3e2 100644 --- a/src/packages/command-panel/src/preview-list.coffee +++ b/src/packages/command-panel/src/preview-list.coffee @@ -83,7 +83,7 @@ class PreviewList extends ScrollView editSession = @rootView.open(operation.getPath()) bufferRange = operation.execute(editSession) editSession.setSelectedBufferRange(bufferRange, autoscroll: true) if bufferRange - @rootView.focus() + @.focus() false getPathCount: -> From 79d569d55b5f635785032f9f44ab57b93cd76846 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 15:30:10 -0800 Subject: [PATCH 026/133] rename atom.coffee to user.coffee --- .atom/{atom.coffee => user.coffee} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .atom/{atom.coffee => user.coffee} (100%) diff --git a/.atom/atom.coffee b/.atom/user.coffee similarity index 100% rename from .atom/atom.coffee rename to .atom/user.coffee From 0233b4a53eecff7bfe96aeb6cea2b914b178e230 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 15:30:18 -0800 Subject: [PATCH 027/133] add .atom/user.css file --- .atom/user.css | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .atom/user.css diff --git a/.atom/user.css b/.atom/user.css new file mode 100644 index 000000000..f53057581 --- /dev/null +++ b/.atom/user.css @@ -0,0 +1,8 @@ +// User styles +.tree-view { + +} + +.editor { + +} \ No newline at end of file From 228c9ff5225467331053ee782bf3838592f20410 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 15:33:52 -0800 Subject: [PATCH 028/133] update readme to point to user.coffee instead of atom.coffee --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f6e23611e..04459faa3 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Requirements Atom is installed! Type `atom [path]` from the commmand line or find it in `/Applications/Atom.app` ## Your ~/.atom Directory -A basic ~/.atom directory is installed when you run `rake install`. Take a look at ~/.atom/atom.coffee for more information. +A basic ~/.atom directory is installed when you run `rake install`. Take a look at ~/.atom/user.coffee for more information. ## Basic Keyboard shortcuts Atom doesn't have much in the way of menus yet. Use these keyboard shortcuts to @@ -53,7 +53,7 @@ Most default OS X keybindings also work. ## Init Script -Atom will require `~/.atom/atom.coffee` whenever a window is opened or reloaded if it is present in your +Atom will require `~/.atom/user.coffee` whenever a window is opened or reloaded if it is present in your home directory. This is a rudimentary jumping off point for your own customizations. ## Command Panel From 389ecc0b4ae807bc94e7bd5072f40aefda7be249 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 15:34:26 -0800 Subject: [PATCH 029/133] copy over user.coffee in rake task --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index e6adbba94..bd693df3f 100644 --- a/Rakefile +++ b/Rakefile @@ -80,7 +80,7 @@ task "create-dot-atom" do `rm -rf "#{DOT_ATOM_PATH}"` `mkdir "#{DOT_ATOM_PATH}"` - `cp "#{dot_atom_template_path}/atom.coffee" "#{DOT_ATOM_PATH}"` + `cp "#{dot_atom_template_path}/user.coffee" "#{DOT_ATOM_PATH}"` `cp "#{dot_atom_template_path}/packages" "#{DOT_ATOM_PATH}"` `cp -r "#{ATOM_SRC_PATH}/themes" "#{DOT_ATOM_PATH}"` `cp "#{ATOM_SRC_PATH}/vendor/themes/IR_Black.tmTheme" "#{DOT_ATOM_PATH}/themes"` From 82f1fb44200f8f109d4adf057878ebe5f2e548b4 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 15:34:38 -0800 Subject: [PATCH 030/133] load user.coffee from .atom directory --- src/app/config.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/config.coffee b/src/app/config.coffee index bf35eff63..26efbd674 100644 --- a/src/app/config.coffee +++ b/src/app/config.coffee @@ -4,7 +4,7 @@ EventEmitter = require 'event-emitter' configDirPath = fs.absolute("~/.atom") configJsonPath = fs.join(configDirPath, "config.json") -userInitScriptPath = fs.join(configDirPath, "atom.coffee") +userInitScriptPath = fs.join(configDirPath, "user.coffee") bundledPackagesDirPath = fs.join(resourcePath, "src/packages") bundledThemesDirPath = fs.join(resourcePath, "themes") vendoredPackagesDirPath = fs.join(resourcePath, "vendor/packages") From 95d7c89ec52dab8cf677ff0bf46b0e3d7839b41b Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 16:00:45 -0800 Subject: [PATCH 031/133] load styles from ~/.atom/user.css --- src/app/atom.coffee | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/app/atom.coffee b/src/app/atom.coffee index 455382926..43c4d942d 100644 --- a/src/app/atom.coffee +++ b/src/app/atom.coffee @@ -7,6 +7,8 @@ LoadTextMatePackagesTask = require 'load-text-mate-packages-task' messageIdCounter = 1 originalSendMessageToBrowserProcess = atom.sendMessageToBrowserProcess +configDirPath = fs.absolute("~/.atom") +userStylePath = fs.join(configDirPath, "user.css") _.extend atom, exitWhenDone: window.location.params.exitWhenDone @@ -53,10 +55,15 @@ _.extend atom, themeNames = config.get("core.themes") ? ['Atom - Dark', 'IR_Black'] themeNames = [themeNames] unless _.isArray(themeNames) @loadTheme(themeName) for themeName in themeNames + @loadUserStyles() loadTheme: (name) -> @loadedThemes.push Theme.load(name) + loadUserStyles: -> + if fs.exists(userStylePath) + applyStylesheet(userStylePath, fs.read(userStylePath), 'userTheme') + getAtomThemeStylesheets: -> themeNames = config.get("core.themes") ? ['Atom - Dark', 'IR_Black'] themeNames = [themeNames] unless _.isArray(themeNames) From 7e030b09e7a7da933b6f4931e73a40ae619b6a17 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Wed, 30 Jan 2013 21:40:26 -0500 Subject: [PATCH 032/133] Adding a line-height to the editor. --- themes/Atom - Dark/editor.css | 1 + themes/Atom - Light/editor.css | 1 + 2 files changed, 2 insertions(+) diff --git a/themes/Atom - Dark/editor.css b/themes/Atom - Dark/editor.css index b2daa3586..533dca1b5 100644 --- a/themes/Atom - Dark/editor.css +++ b/themes/Atom - Dark/editor.css @@ -1,5 +1,6 @@ .editor { font-family: Inconsolata, Monaco, Courier; + line-height: 1.3; } .editor.mini { diff --git a/themes/Atom - Light/editor.css b/themes/Atom - Light/editor.css index 26dec9cb1..ac4a98014 100644 --- a/themes/Atom - Light/editor.css +++ b/themes/Atom - Light/editor.css @@ -1,5 +1,6 @@ .editor { font-family: Inconsolata, Monaco, Courier; + line-height: 1.3; } .editor.mini { From 11c0637220472f8cadcaf0b0d7653a7ccaad0d71 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Thu, 31 Jan 2013 10:19:41 -0500 Subject: [PATCH 033/133] Not adding a font family when the user doesn't have it set --- spec/app/editor-spec.coffee | 7 +++---- src/app/editor.coffee | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 2cbc0cc34..2729be262 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -520,9 +520,8 @@ describe "Editor", -> beforeEach -> expect(editor.css('font-family')).not.toBe 'Courier' - it "sets the initial font family based on the value from config", -> - expect($("head style.font-family")).toExist() - expect($("head style.font-family").text()).toMatch "{font-family: #{config.get('editor.fontFamily')}}" + it "when there is no config in fontFamily don't set it", -> + expect($("head style.font-family")).not.toExist() describe "when the font family changes", -> it "updates the font family on new and existing editors", -> @@ -544,7 +543,7 @@ describe "Editor", -> lineHeightBefore = editor.lineHeight charWidthBefore = editor.charWidth - config.set("editor.fontFamily", "Courier") + config.set("editor.fontFamily", "Inconsolata") editor.setCursorScreenPosition [5, 6] expect(editor.charWidth).not.toBe charWidthBefore expect(editor.getCursorView().position()).toEqual { top: 5 * editor.lineHeight, left: 6 * editor.charWidth } diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 2769b6cba..e9a197158 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -14,7 +14,6 @@ _ = require 'underscore' module.exports = class Editor extends View @configDefaults: - fontFamily: "Inconsolata, Monaco, Courier" fontSize: 20 showInvisibles: false autosave: false @@ -697,6 +696,7 @@ class Editor extends View parseInt(@css("font-size")) setFontFamily: (fontFamily) -> + return if fontFamily == undefined headTag = $("head") styleTag = headTag.find("style.font-family") if styleTag.length == 0 From 4f8181969ed873f134a07259d4448624a1ef7f9e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 31 Jan 2013 09:24:59 -0800 Subject: [PATCH 034/133] :lipstick: --- static/editor.css | 1 - 1 file changed, 1 deletion(-) diff --git a/static/editor.css b/static/editor.css index 0b8cfb452..40c3d1b4e 100644 --- a/static/editor.css +++ b/static/editor.css @@ -56,7 +56,6 @@ overflow-x: hidden; } - .editor .underlayer, .editor .lines, .editor .overlayer { width: 100%; height: 100%; From ef6e525674def664631bf58af6e3ceafd192ef8e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 31 Jan 2013 09:32:20 -0800 Subject: [PATCH 035/133] Use package instead of package's view in specs Event logs are now stored on the package and passed to the view when toggled. --- .../command-logger/spec/command-logger-spec.coffee | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/packages/command-logger/spec/command-logger-spec.coffee b/src/packages/command-logger/spec/command-logger-spec.coffee index c01f24320..e2a06da2b 100644 --- a/src/packages/command-logger/spec/command-logger-spec.coffee +++ b/src/packages/command-logger/spec/command-logger-spec.coffee @@ -6,9 +6,8 @@ describe "CommandLogger", -> beforeEach -> rootView = new RootView(require.resolve('fixtures/sample.js')) - atom.loadPackage('command-logger').getInstance() + commandLogger = atom.loadPackage('command-logger') editor = rootView.getActiveEditor() - commandLogger = CommandLogger.instance afterEach -> rootView.deactivate() @@ -44,9 +43,11 @@ describe "CommandLogger", -> describe "when an event is ignored", -> it "does not create a node for that event", -> - commandLogger.ignoredEvents.push 'editor:delete-line' + commandLoggerView = commandLogger.getInstance() + commandLoggerView.ignoredEvents.push 'editor:delete-line' editor.trigger 'editor:delete-line' - nodes = commandLogger.createNodes() + commandLoggerView.eventLog = commandLogger.eventLog + nodes = commandLoggerView.createNodes() for node in nodes continue unless node.name is 'Editor' for child in node.children From e5bd097592aa7c5987d341ceb678f7b78c354e6b Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 31 Jan 2013 09:41:40 -0800 Subject: [PATCH 036/133] Use configDirPath exposed by global config object --- src/app/atom.coffee | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/app/atom.coffee b/src/app/atom.coffee index 43c4d942d..4630eb6fc 100644 --- a/src/app/atom.coffee +++ b/src/app/atom.coffee @@ -7,8 +7,6 @@ LoadTextMatePackagesTask = require 'load-text-mate-packages-task' messageIdCounter = 1 originalSendMessageToBrowserProcess = atom.sendMessageToBrowserProcess -configDirPath = fs.absolute("~/.atom") -userStylePath = fs.join(configDirPath, "user.css") _.extend atom, exitWhenDone: window.location.params.exitWhenDone @@ -55,14 +53,15 @@ _.extend atom, themeNames = config.get("core.themes") ? ['Atom - Dark', 'IR_Black'] themeNames = [themeNames] unless _.isArray(themeNames) @loadTheme(themeName) for themeName in themeNames - @loadUserStyles() + @loadUserStylesheet() loadTheme: (name) -> @loadedThemes.push Theme.load(name) - loadUserStyles: -> - if fs.exists(userStylePath) - applyStylesheet(userStylePath, fs.read(userStylePath), 'userTheme') + loadUserStylesheet: -> + userStylesheetPath = fs.join(config.configDirPath, 'user.css') + if fs.isFile(userStylesheetPath) + applyStylesheet(userStylesheetPath, fs.read(userStylesheetPath), 'userTheme') getAtomThemeStylesheets: -> themeNames = config.get("core.themes") ? ['Atom - Dark', 'IR_Black'] From 30103b66fcefd45ab6050983d5c61794558b3557 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Thu, 31 Jan 2013 10:18:25 -0800 Subject: [PATCH 037/133] move old atom.coffee to user.coffee on rake install if it exists --- Rakefile | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index bd693df3f..01db92806 100644 --- a/Rakefile +++ b/Rakefile @@ -76,11 +76,24 @@ task "create-dot-atom" do dot_atom_template_path = ATOM_SRC_PATH + "/.atom" replace_dot_atom = false - next if File.exists?(DOT_ATOM_PATH) + + if File.exists?(DOT_ATOM_PATH) + user_config = "#{DOT_ATOM_PATH}/user.coffee" + old_user_config = "#{DOT_ATOM_PATH}/atom.coffee" + + if File.exists?(old_user_config) + `mv #{old_user_config} #{user_config}` + puts "\033[32mRenamed #{old_user_config} to #{user_config}\033[0m" + end + + next + end `rm -rf "#{DOT_ATOM_PATH}"` `mkdir "#{DOT_ATOM_PATH}"` + `cp "#{dot_atom_template_path}/user.coffee" "#{DOT_ATOM_PATH}"` + `cp "#{dot_atom_template_path}/user.css" "#{DOT_ATOM_PATH}"` `cp "#{dot_atom_template_path}/packages" "#{DOT_ATOM_PATH}"` `cp -r "#{ATOM_SRC_PATH}/themes" "#{DOT_ATOM_PATH}"` `cp "#{ATOM_SRC_PATH}/vendor/themes/IR_Black.tmTheme" "#{DOT_ATOM_PATH}/themes"` From 2982c5e51a304ca91f9efb8c12a0ffd895555ea7 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Thu, 31 Jan 2013 10:22:36 -0800 Subject: [PATCH 038/133] need -r when copying packages directory --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 01db92806..2a14471ac 100644 --- a/Rakefile +++ b/Rakefile @@ -94,7 +94,7 @@ task "create-dot-atom" do `cp "#{dot_atom_template_path}/user.coffee" "#{DOT_ATOM_PATH}"` `cp "#{dot_atom_template_path}/user.css" "#{DOT_ATOM_PATH}"` - `cp "#{dot_atom_template_path}/packages" "#{DOT_ATOM_PATH}"` + `cp -r "#{dot_atom_template_path}/packages" "#{DOT_ATOM_PATH}"` `cp -r "#{ATOM_SRC_PATH}/themes" "#{DOT_ATOM_PATH}"` `cp "#{ATOM_SRC_PATH}/vendor/themes/IR_Black.tmTheme" "#{DOT_ATOM_PATH}/themes"` end From 8f030cd97e9ff83519b3692c3bb4150c31721910 Mon Sep 17 00:00:00 2001 From: Corey Johnson & Kevin Sawicki Date: Thu, 31 Jan 2013 10:31:13 -0800 Subject: [PATCH 039/133] Always calculate dimensions with editor on DOM Closes #206 --- spec/app/editor-spec.coffee | 18 ++++++++++++++++++ src/app/editor.coffee | 6 ++++++ src/stdlib/jquery-extensions.coffee | 3 +++ 3 files changed, 27 insertions(+) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 2729be262..dee1224d0 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -552,6 +552,7 @@ describe "Editor", -> describe "font size", -> beforeEach -> expect(editor.css('font-size')).not.toBe "20px" + expect(editor.css('font-size')).not.toBe "10px" it "sets the initial font size based on the value from config", -> expect($("head style.font-size")).toExist() @@ -614,6 +615,23 @@ describe "Editor", -> config.set("editor.fontSize", 10) expect(editor.renderedLines.find(".line").length).toBeGreaterThan originalLineCount + describe "when the editor is detached", -> + it "updates the font-size correctly and recalculates the dimensions by placing the rendered lines on the DOM", -> + rootView.attachToDom() + rootView.height(200) + rootView.width(200) + + newEditor = editor.splitRight() + newEditorParent = newEditor.parent() + newEditor.detach() + config.set("editor.fontSize", 10) + newEditorParent.append(newEditor) + + expect(newEditor.lineHeight).toBe editor.lineHeight + expect(newEditor.charWidth).toBe editor.charWidth + expect(newEditor.getCursorView().position()).toEqual editor.getCursorView().position() + expect(newEditor.verticalScrollbarContent.height()).toBe editor.verticalScrollbarContent.height() + describe "mouse events", -> beforeEach -> editor.attachToDom() diff --git a/src/app/editor.coffee b/src/app/editor.coffee index e9a197158..01b8ac40f 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -804,6 +804,10 @@ class Editor extends View @overlayer.append(view) calculateDimensions: -> + if not @isOnDom() + detachedEditorParent = _.last(@parents()) ? this + $(document.body).append(detachedEditorParent) + fragment = $('