From dc21e8707f54de77fb0f4459df897c5dace95247 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Thu, 4 Sep 2014 15:25:55 -0700 Subject: [PATCH] Deprecate EditorView::getFirstVisibleScreenRow --- benchmark/benchmark-suite.coffee | 8 ++++---- src/editor-view.coffee | 14 ++++---------- src/editor.coffee | 16 +++++++++++++++- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/benchmark/benchmark-suite.coffee b/benchmark/benchmark-suite.coffee index c60811985..0a3901ec9 100644 --- a/benchmark/benchmark-suite.coffee +++ b/benchmark/benchmark-suite.coffee @@ -62,8 +62,8 @@ describe "editorView.", -> describe "empty-vs-set-innerHTML.", -> [firstRow, lastRow] = [] beforeEach -> - firstRow = editorView.getFirstVisibleScreenRow() - lastRow = editorView.getLastVisibleScreenRow() + firstRow = editorView.getModel().getFirstVisibleScreenRow() + lastRow = editorView.getModel().getLastVisibleScreenRow() benchmark "build-gutter-html.", 1000, -> editorView.gutter.renderLineNumbers(null, firstRow, lastRow) @@ -97,8 +97,8 @@ describe "editorView.", -> describe "multiple-lines.", -> [firstRow, lastRow] = [] beforeEach -> - firstRow = editorView.getFirstVisibleScreenRow() - lastRow = editorView.getLastVisibleScreenRow() + firstRow = editorView.getModel().getFirstVisibleScreenRow() + lastRow = editorView.getModel().getLastVisibleScreenRow() benchmark "cache-entire-visible-area", 100, -> for i in [firstRow..lastRow] diff --git a/src/editor-view.coffee b/src/editor-view.coffee index cc891ec3a..3eccc2340 100644 --- a/src/editor-view.coffee +++ b/src/editor-view.coffee @@ -256,19 +256,13 @@ class EditorView extends View deprecate('Use editorView.getModel().pageUp()') @editor.pageUp() - # Public: Retrieves the number of the row that is visible and currently at the - # top of the editor. - # - # Returns a {Number}. getFirstVisibleScreenRow: -> - @editor.getVisibleRowRange()[0] + deprecate 'Use Editor::getFirstVisibleScreenRow instead. You can get the editor via editorView.getModel()' + @editor.getFirstVisibleScreenRow() - # Public: Retrieves the number of the row that is visible and currently at the - # bottom of the editor. - # - # Returns a {Number}. getLastVisibleScreenRow: -> - @editor.getVisibleRowRange()[1] + deprecate 'Use Editor::getLastVisibleScreenRow instead. You can get the editor via editorView.getModel()' + @editor.getLastVisibleScreenRow() # Public: Gets the font family for the editor. # diff --git a/src/editor.coffee b/src/editor.coffee index 2ca4d20d4..de62f8453 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -2396,7 +2396,21 @@ class Editor extends Model Section: Editor Rendering ### - # Public: Converts a buffer position to a pixel position. + # Extended: Retrieves the number of the row that is visible and currently at the + # top of the editor. + # + # Returns a {Number}. + getFirstVisibleScreenRow: -> + @getVisibleRowRange()[0] + + # Extended: Retrieves the number of the row that is visible and currently at the + # bottom of the editor. + # + # Returns a {Number}. + getLastVisibleScreenRow: -> + @getVisibleRowRange()[1] + + # Extended: Converts a buffer position to a pixel position. # # * `bufferPosition` An object that represents a buffer position. It can be either # an {Object} (`{row, column}`), {Array} (`[row, column]`), or {Point}