Remove old grammar view files

This commit is contained in:
probablycorey 2013-03-27 17:30:49 -07:00
parent 70010bad56
commit 72f57ad993
2 changed files with 0 additions and 106 deletions

View File

@ -1,46 +0,0 @@
RootView = require 'root-view'
GrammarView = require 'grammar-view'
_ = require 'underscore'
describe "GrammarView", ->
[editor, textGrammar, jsGrammar] = []
beforeEach ->
atom.activatePackage('text.tmbundle', sync: true)
atom.activatePackage('javascript.tmbundle', sync: true)
window.rootView = new RootView
rootView.open('sample.js')
editor = rootView.getActiveView()
textGrammar = _.find syntax.grammars, (grammar) -> grammar.name is 'Plain Text'
expect(textGrammar).toBeTruthy()
jsGrammar = _.find syntax.grammars, (grammar) -> grammar.name is 'JavaScript'
expect(jsGrammar).toBeTruthy()
expect(editor.getGrammar()).toBe jsGrammar
describe "when editor:select-grammar is toggled", ->
it "displays a list of all the available grammars", ->
editor.trigger 'editor:select-grammar'
grammarView = rootView.find('.grammar-view').view()
expect(grammarView).toExist()
grammars = syntax.grammars
expect(grammarView.list.children('li').length).toBe grammars.length + 1
expect(grammarView.list.children('li:first').text()).toBe 'Auto Detect'
describe "when a grammar is selected", ->
it "sets the new grammar on the editor", ->
editor.trigger 'editor:select-grammar'
grammarView = rootView.find('.grammar-view').view()
grammarView.confirmed(textGrammar)
expect(editor.getGrammar()).toBe textGrammar
describe "when auto-detect is selected", ->
it "restores the auto-detected grammar on the editor", ->
editor.trigger 'editor:select-grammar'
grammarView = rootView.find('.grammar-view').view()
grammarView.confirmed(textGrammar)
expect(editor.getGrammar()).toBe textGrammar
editor.trigger 'editor:select-grammar'
grammarView = rootView.find('.grammar-view').view()
grammarView.confirmed(grammarView.array[0])
expect(editor.getGrammar()).toBe jsGrammar

View File

@ -1,60 +0,0 @@
SelectList = require 'select-list'
{$$} = require 'space-pen'
module.exports =
class GrammarView extends SelectList
@viewClass: -> "#{super} grammar-view from-top overlay mini"
filterKey: 'name'
initialize: (@editor) ->
@currentGrammar = @editor.getGrammar()
@path = @editor.getPath()
@autoDetect = name: 'Auto Detect'
@command 'editor:select-grammar', =>
@cancel()
false
super
@populate()
@attach()
itemForElement: (grammar) ->
if grammar is @currentGrammar
grammarClass = 'active-item'
else
grammarClass = 'inactive-item'
$$ ->
@li grammar.name, class: grammarClass
populate: ->
grammars = new Array(syntax.grammars...)
grammars.sort (grammarA, grammarB) ->
if grammarA.scopeName is 'text.plain'
-1
else if grammarB.scopeName is 'text.plain'
1
else if grammarA.name < grammarB.name
-1
else if grammarA.name > grammarB.name
1
else
0
grammars.unshift(@autoDetect)
@setArray(grammars)
confirmed: (grammar) ->
@cancel()
if grammar is @autoDetect
syntax.clearGrammarOverrideForPath(@path)
else
syntax.setGrammarOverrideForPath(@path, grammar.scopeName)
@editor.reloadGrammar()
attach: ->
super
rootView.append(this)
@miniEditor.focus()