FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
atom/src/lines-component.coffee at master · onnodejong/atom · GitHub
onnodejong
atom
Repository navigation
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
108 lines (84 loc) · 4.01 KB
Breadcrumbs
atom
/
src
/
lines-component.coffee
Copy path
File metadata and controls
108 lines (84 loc) · 4.01 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
CursorsComponent
=
require
'
./cursors-component
'
LinesTileComponent
=
require
'
./lines-tile-component
'
TiledComponent
=
require
'
./tiled-component
'
DummyLineNode
=
document
.
createElement
(
'
div
'
)
DummyLineNode
.
className
=
'
line
'
DummyLineNode
.
style
.
position
=
'
absolute
'
DummyLineNode
.
style
.
visibility
=
'
hidden
'
DummyLineNode
.
appendChild
(
document
.
createElement
(
'
span
'
))
DummyLineNode
.
appendChild
(
document
.
createElement
(
'
span
'
))
DummyLineNode
.
appendChild
(
document
.
createElement
(
'
span
'
))
DummyLineNode
.
appendChild
(
document
.
createElement
(
'
span
'
))
DummyLineNode
.
children
[
0
].
textContent
=
'
x
'
DummyLineNode
.
children
[
1
].
textContent
=
'
我
'
DummyLineNode
.
children
[
2
].
textContent
=
'
ハ
'
DummyLineNode
.
children
[
3
].
textContent
=
'
세
'
RangeForMeasurement
=
document
.
createRange
()
module
.
exports
=
class
LinesComponent
extends
TiledComponent
placeholderTextDiv
:
null
constructor
:
({
@presenter
,
@useShadowDOM
,
@domElementPool
,
@assert
,
@grammars
})
->
@domNode
=
document
.
createElement
(
'
div
'
)
@domNode
.
classList
.
add
(
'
lines
'
)
@tilesNode
=
document
.
createElement
(
"
div
"
)
#
Create a new stacking context, so that tiles z-index does not interfere
#
with other visual elements.
@tilesNode
.
style
.
isolation
=
"
isolate
"
@tilesNode
.
style
.
zIndex
=
0
@domNode
.
appendChild
(
@tilesNode
)
@cursorsComponent
=
new
CursorsComponent
@domNode
.
appendChild
(
@cursorsComponent
.
getDomNode
())
if
@useShadowDOM
insertionPoint
=
document
.
createElement
(
'
content
'
)
insertionPoint
.
setAttribute
(
'
select
'
,
'
.overlayer
'
)
@domNode
.
appendChild
(insertionPoint)
getDomNode
:
->
@domNode
shouldRecreateAllTilesOnUpdate
:
->
@newState
.
continuousReflow
beforeUpdateSync
:
(
state
)
->
if
@newState
.
maxHeight
isnt
@oldState
.
maxHeight
@domNode
.
style
.
height
=
@newState
.
maxHeight
+
'
px
'
@oldState
.
maxHeight
=
@newState
.
maxHeight
if
@newState
.
backgroundColor
isnt
@oldState
.
backgroundColor
@domNode
.
style
.
backgroundColor
=
@newState
.
backgroundColor
@oldState
.
backgroundColor
=
@newState
.
backgroundColor
afterUpdateSync
:
(
state
)
->
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
)
@oldState
.
placeholderText
=
@newState
.
placeholderText
if
@newState
.
width
isnt
@oldState
.
width
@domNode
.
style
.
width
=
@newState
.
width
+
'
px
'
@oldState
.
width
=
@newState
.
width
@cursorsComponent
.
updateSync
(state)
buildComponentForTile
:
(
id
)
->
new
LinesTileComponent
({id,
@presenter
,
@domElementPool
,
@assert
,
@grammars
})
buildEmptyState
:
->
{
tiles
:
{}}
getNewState
:
(
state
)
->
state
.
content
getTilesNode
:
->
@tilesNode
measureLineHeightAndDefaultCharWidth
:
->
@domNode
.
appendChild
(DummyLineNode)
textNode
=
DummyLineNode
.
firstChild
.
childNodes
[
0
]
lineHeightInPixels
=
DummyLineNode
.
getBoundingClientRect
().
height
defaultCharWidth
=
DummyLineNode
.
children
[
0
].
getBoundingClientRect
().
width
doubleWidthCharWidth
=
DummyLineNode
.
children
[
1
].
getBoundingClientRect
().
width
halfWidthCharWidth
=
DummyLineNode
.
children
[
2
].
getBoundingClientRect
().
width
koreanCharWidth
=
DummyLineNode
.
children
[
3
].
getBoundingClientRect
().
width
@domNode
.
removeChild
(DummyLineNode)
@presenter
.
setLineHeight
(lineHeightInPixels)
@presenter
.
setBaseCharacterWidth
(defaultCharWidth, doubleWidthCharWidth, halfWidthCharWidth, koreanCharWidth)
lineIdForScreenRow
:
(
screenRow
)
->
tile
=
@presenter
.
tileForRow
(screenRow)
@
getComponentForTile
(tile)
?
.
lineIdForScreenRow
(screenRow)
lineNodeForScreenRow
:
(
screenRow
)
->
tile
=
@presenter
.
tileForRow
(screenRow)
@
getComponentForTile
(tile)
?
.
lineNodeForScreenRow
(screenRow)
textNodesForScreenRow
:
(
screenRow
)
->
tile
=
@presenter
.
tileForRow
(screenRow)
@
getComponentForTile
(tile)
?
.
textNodesForScreenRow
(screenRow)
Back
|
FazBrowse Home
|
New Git URL