diff --git a/lib/editor-proxy.coffee b/lib/editor-proxy.coffee index c9c1399..402d5e5 100644 --- a/lib/editor-proxy.coffee +++ b/lib/editor-proxy.coffee @@ -5,7 +5,7 @@ tabStops = emmet.require("tabStops") module.exports = setupContext: (@editorView) -> - @indentation = @editorView.editor.getTabText() + @indentation = @editorView.getEditor().getTabText() emmet.require("resources").setVariable("indentation", @indentation) @syntax = @getSyntax() @@ -13,10 +13,10 @@ module.exports = # # Returns an {Object} with `start` and `end` properties. getSelectionRange: -> - range = @editorView.getSelection().getBufferRange() + range = @editorView.getEditor().getSelection().getBufferRange() return { - start: @editorView.editor.getBuffer().characterIndexForPosition(range.start), - end: @editorView.editor.getBuffer().characterIndexForPosition(range.end) + start: @editorView.getEditor().getBuffer().characterIndexForPosition(range.start), + end: @editorView.getEditor().getBuffer().characterIndexForPosition(range.end) } # Creates a selection from the `start` to `end` character indexes. @@ -26,17 +26,17 @@ module.exports = # start - A {Number} representing the starting character index # end - A {Number} representing the ending character index createSelection: (start, end) -> - @editorView.getSelection().setBufferRange - start: @editorView.editor.getBuffer().positionForCharacterIndex(start) - end: @editorView.editor.getBuffer().positionForCharacterIndex(end) + @editorView.getEditor().getSelection().setBufferRange + start: @editorView.getEditor().getBuffer().positionForCharacterIndex(start) + end: @editorView.getEditor().getBuffer().positionForCharacterIndex(end) # Fetches the current line's start and end indexes. # # Returns an {Object} with `start` and `end` properties getCurrentLineRange: -> - row = @editorView.getCursor().getBufferRow() - lineLength = @editorView.lineLengthForBufferRow(row) - index = @editorView.editor.getBuffer().characterIndexForPosition({row: row, column: 0}) + row = @editorView.getEditor().getCursor().getBufferRow() + lineLength = @editorView.getEditor().lineLengthForBufferRow(row) + index = @editorView.getEditor().getBuffer().characterIndexForPosition({row: row, column: 0}) return { start: index, end: index + lineLength @@ -44,20 +44,20 @@ module.exports = # Returns the current caret position. getCaretPos: -> - row = @editorView.getCursor().getBufferRow() - column = @editorView.getCursor().getBufferColumn() - return @editorView.editor.getBuffer().characterIndexForPosition( {row: row, column: column} ) + row = @editorView.getEditor().getCursor().getBufferRow() + column = @editorView.getEditor().getCursor().getBufferColumn() + return @editorView.getEditor().getBuffer().characterIndexForPosition( {row: row, column: column} ) # Sets the current caret position. setCaretPos: (index) -> - pos = @editorView.editor.getBuffer().positionForCharacterIndex(index) - @editorView.editor.getSelection().clear() - @editorView.setCursorBufferPosition pos + pos = @editorView.getEditor().getBuffer().positionForCharacterIndex(index) + @editorView.getEditor().getSelection().clear() + @editorView.getEditor().setCursorBufferPosition pos # Returns the current line. getCurrentLine: -> - row = @editorView.getCursor().getBufferRow() - return @editorView.editor.lineForBufferRow(row) + row = @editorView.getEditor().getCursor().getBufferRow() + return @editorView.getEditor().lineForBufferRow(row) # Replace the editor's content (or part of it, if using `start` to # `end` index). @@ -101,24 +101,26 @@ module.exports = start: value.length + start end: value.length + start - range = @editorView.getSelection().getBufferRange() - range.start = Point.fromObject(@editorView.editor.getBuffer().positionForCharacterIndex(start)) - range.end = Point.fromObject(@editorView.editor.getBuffer().positionForCharacterIndex(end)) + range = @editorView.getEditor().getSelection().getBufferRange() + changeRange = [ + Point.fromObject(@editorView.getEditor().getBuffer().positionForCharacterIndex(start)) + Point.fromObject(@editorView.getEditor().getBuffer().positionForCharacterIndex(end)) + ] - @editorView.editor.getBuffer().change(range, value) + @editorView.getEditor().getBuffer().change(changeRange, value) - range.start = Point.fromObject(@editorView.editor.getBuffer().positionForCharacterIndex(firstTabStop.start)) - range.end = Point.fromObject(@editorView.editor.getBuffer().positionForCharacterIndex(firstTabStop.end)) + range.start = Point.fromObject(@editorView.getEditor().getBuffer().positionForCharacterIndex(firstTabStop.start)) + range.end = Point.fromObject(@editorView.getEditor().getBuffer().positionForCharacterIndex(firstTabStop.end)) - @editorView.getSelection().setBufferRange(range) + @editorView.getEditor().getSelection().setBufferRange(range) # Returns the editor content. getContent: -> - return @editorView.getText() + return @editorView.getEditor().getText() # Returns the editor's syntax mode. getSyntax: -> - grammar = @editorView.editor.getGrammar().name + grammar = @editorView.getEditor().getGrammar().name if /^CSS/.test(grammar) return "css" else if /^SCSS/.test(grammar) @@ -136,16 +138,16 @@ module.exports = # # See emmet.setupProfile for more information. getProfileName: -> - return @editorView.editor.getGrammar().name + return @editorView.getEditor().getGrammar().name # Returns the currently selected text. getSelection: -> - return @editorView.editor.getSelectedText() + return @editorView.getEditor().getSelectedText() # Returns the current editor's file path getFilePath: -> # is there a better way to get this? - return @editorView.editor.buffer.file.path + return @editorView.getEditor().buffer.file.path prompt: (message) -> # does nothing. currently breaks decoding base64 URLs diff --git a/lib/emmet.coffee b/lib/emmet.coffee index 974e789..5a7e1e7 100644 --- a/lib/emmet.coffee +++ b/lib/emmet.coffee @@ -29,7 +29,7 @@ module.exports = syntax = editorProxy.getSyntax() if emmet.require("resources").hasSyntax(syntax) emmetAction = @actionTranslation[action] - if emmetAction == "expand_abbreviation_with_tab" && !editorView.getSelection().isEmpty() + if emmetAction == "expand_abbreviation_with_tab" && !editorView.getEditor().getSelection().isEmpty() e.abortKeyBinding() return else diff --git a/package.json b/package.json index fbfbfd0..2fed371 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "emmet", "main": "./lib/emmet", - "version": "0.1.5", + "version": "0.1.6", "private": true, "dependencies": { "season": "0.11.0"