FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
atom/src/lines-component.coffee at master · jforge/atom · GitHub
jforge
/
atom
Public
forked from
atom/atom
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
atom
/
src
/
lines-component.coffee
Copy path
More file actions
More file actions
Latest commit
History
History
History
126 lines (91 loc) · 3.85 KB
Breadcrumbs
atom
/
src
/
lines-component.coffee
Copy path
File metadata and controls
126 lines (91 loc) · 3.85 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
{
$$
}
=
require
'
space-pen
'
CursorsComponent
=
require
'
./cursors-component
'
TileComponent
=
require
'
./tile-component
'
DummyLineNode
=
$$
(
->
@
div
className
:
'
line
'
,
style
:
'
position: absolute; visibility: hidden;
'
,
=>
@
span
'
x
'
)[
0
]
cloneObject
=
(
object
)
->
clone
=
{}
clone[key]
=
value
for
key, value
of
object
clone
module
.
exports
=
class
LinesComponent
placeholderTextDiv
:
null
constructor
:
({
@presenter
,
@hostElement
,
@useShadowDOM
, visible})
->
@tileComponentsByTileId
=
{}
@domNode
=
document
.
createElement
(
'
div
'
)
@domNode
.
classList
.
add
(
'
lines
'
)
@cursorsComponent
=
new
CursorsComponent
(
@presenter
)
@domNode
.
appendChild
(
@cursorsComponent
.
getDomNode
())
if
@useShadowDOM
insertionPoint
=
document
.
createElement
(
'
content
'
)
insertionPoint
.
setAttribute
(
'
select
'
,
'
.overlayer
'
)
@domNode
.
appendChild
(insertionPoint)
getDomNode
:
->
@domNode
updateSync
:
(
state
)
->
@newState
=
state
.
content
@oldState
?=
{
tiles
:
{}}
if
@newState
.
scrollHeight
isnt
@oldState
.
scrollHeight
@domNode
.
style
.
height
=
@newState
.
scrollHeight
+
'
px
'
@oldState
.
scrollHeight
=
@newState
.
scrollHeight
if
@newState
.
backgroundColor
isnt
@oldState
.
backgroundColor
@domNode
.
style
.
backgroundColor
=
@newState
.
backgroundColor
@oldState
.
backgroundColor
=
@newState
.
backgroundColor
if
@newState
.
placeholderText
isnt
@oldState
.
placeholderText
@placeholderTextDiv
?
.
remove
()
if
@newState
.
placeholderText
?
@placeholderTextDiv
=
document
.
createElement
(
'
div
'
)
@placeholderTextDiv
.
classList
.
add
(
'
placeholder-text
'
)
@placeholderTextDiv
.
textContent
=
@newState
.
placeholderText
@domNode
.
appendChild
(
@placeholderTextDiv
)
@
removeTileNodes
()
unless
@oldState
.
indentGuidesVisible
is
@newState
.
indentGuidesVisible
@
updateTileNodes
()
if
@newState
.
width
isnt
@oldState
.
width
@domNode
.
style
.
width
=
@newState
.
width
+
'
px
'
@cursorsComponent
.
updateSync
(state)
@oldState
.
indentGuidesVisible
=
@newState
.
indentGuidesVisible
@oldState
.
scrollWidth
=
@newState
.
scrollWidth
@oldState
.
width
=
@newState
.
width
removeTileNodes
:
->
@
removeTileNode
(id)
for
id
of
@oldState
.
tiles
return
removeTileNode
:
(
id
)
->
node
=
@tileComponentsByTileId
[id].
getDomNode
()
node
.
remove
()
delete
@tileComponentsByTileId
[id]
delete
@oldState
.
tiles
[id]
updateTileNodes
:
->
for
id
of
@oldState
.
tiles
unless
@newState
.
tiles
.
hasOwnProperty
(id)
@
removeTileNode
(id)
for
id, tileState
of
@newState
.
tiles
if
@oldState
.
tiles
.
hasOwnProperty
(id)
tileComponent
=
@tileComponentsByTileId
[id]
else
tileComponent
=
@tileComponentsByTileId
[id]
=
new
TileComponent
({id,
@presenter
})
@domNode
.
appendChild
(
tileComponent
.
getDomNode
())
@oldState
.
tiles
[id]
=
cloneObject
(tileState)
tileComponent
.
updateSync
(
@newState
)
return
measureLineHeightAndDefaultCharWidth
:
->
@domNode
.
appendChild
(DummyLineNode)
lineHeightInPixels
=
DummyLineNode
.
getBoundingClientRect
().
height
charWidth
=
DummyLineNode
.
firstChild
.
getBoundingClientRect
().
width
@domNode
.
removeChild
(DummyLineNode)
@presenter
.
setLineHeight
(lineHeightInPixels)
@presenter
.
setBaseCharacterWidth
(charWidth)
remeasureCharacterWidths
:
->
return
unless
@presenter
.
baseCharacterWidth
@
clearScopedCharWidths
()
@
measureCharactersInNewLines
()
measureCharactersInNewLines
:
->
@presenter
.
batchCharacterMeasurement
=>
for
id, component
of
@tileComponentsByTileId
component
.
measureCharactersInNewLines
()
return
clearScopedCharWidths
:
->
for
id, component
of
@tileComponentsByTileId
component
.
clearMeasurements
()
@presenter
.
clearScopedCharacterWidths
()
lineNodeForScreenRow
:
(
screenRow
)
->
tile
=
@presenter
.
tileForRow
(screenRow)
@tileComponentsByTileId
[tile]
?
.
lineNodeForScreenRow
(screenRow)
Back
|
FazBrowse Home
|
New Git URL