mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Remove Decorations object
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
_ = require 'underscore-plus'
|
||||
Decoration = require './decoration'
|
||||
|
||||
module.exports =
|
||||
class Decorations
|
||||
constructor: (@editor, @startScreenRow, @endScreenRow) ->
|
||||
@decorationsCache = {}
|
||||
@decorationsByMarkerId = @editor.decorationsForScreenRowRange(@startScreenRow, @endScreenRow)
|
||||
@decorationsByScreenRow = @indexDecorationsByScreenRow(@decorationsByMarkerId)
|
||||
|
||||
decorationsByScreenRowForType: (decorationType) ->
|
||||
unless @decorationsCache[decorationType]?
|
||||
filteredDecorations = {}
|
||||
|
||||
for screenRow, decorations of @decorationsByScreenRow
|
||||
for decoration in decorations
|
||||
if decoration.isType(decorationType)
|
||||
filteredDecorations[screenRow] ?= []
|
||||
filteredDecorations[screenRow].push decoration
|
||||
|
||||
for screenRow in [@startScreenRow...@endScreenRow]
|
||||
if @editor.isFoldableAtScreenRow(screenRow)
|
||||
filteredDecorations[screenRow] ?= []
|
||||
filteredDecorations[screenRow].push new Decoration(null, {class: 'foldable'})
|
||||
|
||||
@decorationsCache[decorationType] = filteredDecorations
|
||||
@decorationsCache[decorationType]
|
||||
|
||||
decorationsByMarkerIdForType: (decorationType) ->
|
||||
filteredDecorations = {}
|
||||
for id, decorations of @decorationsByMarkerId
|
||||
for decoration in decorations
|
||||
if decoration.isType(decorationType)
|
||||
filteredDecorations[id] ?= []
|
||||
filteredDecorations[id].push decoration
|
||||
filteredDecorations
|
||||
|
||||
indexDecorationsByScreenRow: (decorationsByMarkerId) ->
|
||||
decorationsByScreenRow = {}
|
||||
for id, decorations of decorationsByMarkerId
|
||||
for decoration in decorations
|
||||
continue unless decoration.isValid()
|
||||
range = decoration.getScreenRange()
|
||||
for screenRow in [range.start.row..range.end.row]
|
||||
decorationsByScreenRow[screenRow] ?= []
|
||||
decorationsByScreenRow[screenRow].push(decoration)
|
||||
decorationsByScreenRow
|
||||
@@ -4,7 +4,7 @@ React = require 'react-atom-fork'
|
||||
scrollbarStyle = require 'scrollbar-style'
|
||||
{Range, Point} = require 'text-buffer'
|
||||
|
||||
Decorations = require './decorations'
|
||||
Decoration = require './decoration'
|
||||
GutterComponent = require './gutter-component'
|
||||
InputComponent = require './input-component'
|
||||
CursorsComponent = require './cursors-component'
|
||||
@@ -51,9 +51,13 @@ EditorComponent = React.createClass
|
||||
[renderedStartRow, renderedEndRow] = renderedRowRange
|
||||
cursorScreenRanges = @getCursorScreenRanges(renderedRowRange)
|
||||
selectionScreenRanges = @getSelectionScreenRanges(renderedRowRange)
|
||||
decorations = new Decorations(editor, renderedStartRow, renderedEndRow)
|
||||
gutterDecorations = decorations.decorationsByScreenRowForType('gutter')
|
||||
highlightDecorations = decorations.decorationsByMarkerIdForType('highlight')
|
||||
|
||||
decorationsByMarkerId = editor.decorationsForScreenRowRange(renderedStartRow, renderedEndRow)
|
||||
highlightDecorations = @decorationsByMarkerIdForType(decorationsByMarkerId, 'highlight')
|
||||
|
||||
decorationsByScreenRow = @indexDecorationsByScreenRow(decorationsByMarkerId)
|
||||
gutterDecorations = @decorationsByScreenRowForType(decorationsByScreenRow, 'gutter')
|
||||
|
||||
scrollHeight = editor.getScrollHeight()
|
||||
scrollWidth = editor.getScrollWidth()
|
||||
scrollTop = editor.getScrollTop()
|
||||
@@ -236,6 +240,44 @@ EditorComponent = React.createClass
|
||||
|
||||
selectionScreenRanges
|
||||
|
||||
indexDecorationsByScreenRow: (decorationsByMarkerId) ->
|
||||
decorationsByScreenRow = {}
|
||||
for id, decorations of decorationsByMarkerId
|
||||
for decoration in decorations
|
||||
continue unless decoration.isValid()
|
||||
range = decoration.getScreenRange()
|
||||
for screenRow in [range.start.row..range.end.row]
|
||||
decorationsByScreenRow[screenRow] ?= []
|
||||
decorationsByScreenRow[screenRow].push(decoration)
|
||||
decorationsByScreenRow
|
||||
|
||||
decorationsByMarkerIdForType: (decorationsByMarkerId, decorationType) ->
|
||||
filteredDecorations = {}
|
||||
for id, decorations of decorationsByMarkerId
|
||||
for decoration in decorations
|
||||
if decoration.isType(decorationType)
|
||||
filteredDecorations[id] ?= []
|
||||
filteredDecorations[id].push decoration
|
||||
filteredDecorations
|
||||
|
||||
decorationsByScreenRowForType: (decorationsByScreenRow, decorationType) ->
|
||||
{editor} = @props
|
||||
filteredDecorations = {}
|
||||
|
||||
for screenRow, decorations of decorationsByScreenRow
|
||||
for decoration in decorations
|
||||
if decoration.isType(decorationType)
|
||||
filteredDecorations[screenRow] ?= []
|
||||
filteredDecorations[screenRow].push decoration
|
||||
|
||||
[startScreenRow, endScreenRow] = @getRenderedRowRange()
|
||||
for screenRow in [startScreenRow...endScreenRow]
|
||||
if editor.isFoldableAtScreenRow(screenRow)
|
||||
filteredDecorations[screenRow] ?= []
|
||||
filteredDecorations[screenRow].push new Decoration(null, class: 'foldable')
|
||||
|
||||
filteredDecorations
|
||||
|
||||
getGutterDecorations: (renderedRowRange) ->
|
||||
[renderedStartRow, renderedEndRow] = renderedRowRange
|
||||
|
||||
|
||||
Reference in New Issue
Block a user