Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
MCMS
Commits
53f587bc
Commit
53f587bc
authored
Dec 27, 2019
by
zhongyh
Browse files
提交资源文件
parent
f40087b8
Changes
278
Show whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
20 of 278+
files are displayed.
Plain diff
Email patch
src/main/webapp/static/plugins/codemirror/5.48.4/addon/merge/merge.css
0 → 100644
View file @
53f587bc
.CodeMirror-merge
{
position
:
relative
;
border
:
1px
solid
#ddd
;
white-space
:
pre
;
}
.CodeMirror-merge
,
.CodeMirror-merge
.CodeMirror
{
height
:
350px
;
}
.CodeMirror-merge-2pane
.CodeMirror-merge-pane
{
width
:
47%
;
}
.CodeMirror-merge-2pane
.CodeMirror-merge-gap
{
width
:
6%
;
}
.CodeMirror-merge-3pane
.CodeMirror-merge-pane
{
width
:
31%
;
}
.CodeMirror-merge-3pane
.CodeMirror-merge-gap
{
width
:
3.5%
;
}
.CodeMirror-merge-pane
{
display
:
inline-block
;
white-space
:
normal
;
vertical-align
:
top
;
}
.CodeMirror-merge-pane-rightmost
{
position
:
absolute
;
right
:
0px
;
z-index
:
1
;
}
.CodeMirror-merge-gap
{
z-index
:
2
;
display
:
inline-block
;
height
:
100%
;
-moz-box-sizing
:
border-box
;
box-sizing
:
border-box
;
overflow
:
hidden
;
border-left
:
1px
solid
#ddd
;
border-right
:
1px
solid
#ddd
;
position
:
relative
;
background
:
#f8f8f8
;
}
.CodeMirror-merge-scrolllock-wrap
{
position
:
absolute
;
bottom
:
0
;
left
:
50%
;
}
.CodeMirror-merge-scrolllock
{
position
:
relative
;
left
:
-50%
;
cursor
:
pointer
;
color
:
#555
;
line-height
:
1
;
}
.CodeMirror-merge-scrolllock
:after
{
content
:
"\21db\00a0\00a0\21da"
;
}
.CodeMirror-merge-scrolllock.CodeMirror-merge-scrolllock-enabled
:after
{
content
:
"\21db\21da"
;
}
.CodeMirror-merge-copybuttons-left
,
.CodeMirror-merge-copybuttons-right
{
position
:
absolute
;
left
:
0
;
top
:
0
;
right
:
0
;
bottom
:
0
;
line-height
:
1
;
}
.CodeMirror-merge-copy
{
position
:
absolute
;
cursor
:
pointer
;
color
:
#44c
;
z-index
:
3
;
}
.CodeMirror-merge-copy-reverse
{
position
:
absolute
;
cursor
:
pointer
;
color
:
#44c
;
}
.CodeMirror-merge-copybuttons-left
.CodeMirror-merge-copy
{
left
:
2px
;
}
.CodeMirror-merge-copybuttons-right
.CodeMirror-merge-copy
{
right
:
2px
;
}
.CodeMirror-merge-r-inserted
,
.CodeMirror-merge-l-inserted
{
background-image
:
url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12MwuCXy3+CWyH8GBgYGJgYkAABZbAQ9ELXurwAAAABJRU5ErkJggg==)
;
background-position
:
bottom
left
;
background-repeat
:
repeat-x
;
}
.CodeMirror-merge-r-deleted
,
.CodeMirror-merge-l-deleted
{
background-image
:
url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12M4Kyb2/6yY2H8GBgYGJgYkAABURgPz6Ks7wQAAAABJRU5ErkJggg==)
;
background-position
:
bottom
left
;
background-repeat
:
repeat-x
;
}
.CodeMirror-merge-r-chunk
{
background
:
#ffffe0
;
}
.CodeMirror-merge-r-chunk-start
{
border-top
:
1px
solid
#ee8
;
}
.CodeMirror-merge-r-chunk-end
{
border-bottom
:
1px
solid
#ee8
;
}
.CodeMirror-merge-r-connect
{
fill
:
#ffffe0
;
stroke
:
#ee8
;
stroke-width
:
1px
;
}
.CodeMirror-merge-l-chunk
{
background
:
#eef
;
}
.CodeMirror-merge-l-chunk-start
{
border-top
:
1px
solid
#88e
;
}
.CodeMirror-merge-l-chunk-end
{
border-bottom
:
1px
solid
#88e
;
}
.CodeMirror-merge-l-connect
{
fill
:
#eef
;
stroke
:
#88e
;
stroke-width
:
1px
;
}
.CodeMirror-merge-l-chunk.CodeMirror-merge-r-chunk
{
background
:
#dfd
;
}
.CodeMirror-merge-l-chunk-start.CodeMirror-merge-r-chunk-start
{
border-top
:
1px
solid
#4e4
;
}
.CodeMirror-merge-l-chunk-end.CodeMirror-merge-r-chunk-end
{
border-bottom
:
1px
solid
#4e4
;
}
.CodeMirror-merge-collapsed-widget
:before
{
content
:
"(...)"
;
}
.CodeMirror-merge-collapsed-widget
{
cursor
:
pointer
;
color
:
#88b
;
background
:
#eef
;
border
:
1px
solid
#ddf
;
font-size
:
90%
;
padding
:
0
3px
;
border-radius
:
4px
;
}
.CodeMirror-merge-collapsed-line
.CodeMirror-gutter-elt
{
display
:
none
;
}
src/main/webapp/static/plugins/codemirror/5.48.4/addon/merge/merge.js
0 → 100644
View file @
53f587bc
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
// declare global: diff_match_patch, DIFF_INSERT, DIFF_DELETE, DIFF_EQUAL
(
function
(
mod
)
{
if
(
typeof
exports
==
"
object
"
&&
typeof
module
==
"
object
"
)
// CommonJS
mod
(
require
(
"
../../lib/codemirror
"
));
// Note non-packaged dependency diff_match_patch
else
if
(
typeof
define
==
"
function
"
&&
define
.
amd
)
// AMD
define
([
"
../../lib/codemirror
"
,
"
diff_match_patch
"
],
mod
);
else
// Plain browser env
mod
(
CodeMirror
);
})(
function
(
CodeMirror
)
{
"
use strict
"
;
var
Pos
=
CodeMirror
.
Pos
;
var
svgNS
=
"
http://www.w3.org/2000/svg
"
;
function
DiffView
(
mv
,
type
)
{
this
.
mv
=
mv
;
this
.
type
=
type
;
this
.
classes
=
type
==
"
left
"
?
{
chunk
:
"
CodeMirror-merge-l-chunk
"
,
start
:
"
CodeMirror-merge-l-chunk-start
"
,
end
:
"
CodeMirror-merge-l-chunk-end
"
,
insert
:
"
CodeMirror-merge-l-inserted
"
,
del
:
"
CodeMirror-merge-l-deleted
"
,
connect
:
"
CodeMirror-merge-l-connect
"
}
:
{
chunk
:
"
CodeMirror-merge-r-chunk
"
,
start
:
"
CodeMirror-merge-r-chunk-start
"
,
end
:
"
CodeMirror-merge-r-chunk-end
"
,
insert
:
"
CodeMirror-merge-r-inserted
"
,
del
:
"
CodeMirror-merge-r-deleted
"
,
connect
:
"
CodeMirror-merge-r-connect
"
};
}
DiffView
.
prototype
=
{
constructor
:
DiffView
,
init
:
function
(
pane
,
orig
,
options
)
{
this
.
edit
=
this
.
mv
.
edit
;
;(
this
.
edit
.
state
.
diffViews
||
(
this
.
edit
.
state
.
diffViews
=
[])).
push
(
this
);
this
.
orig
=
CodeMirror
(
pane
,
copyObj
({
value
:
orig
,
readOnly
:
!
this
.
mv
.
options
.
allowEditingOriginals
},
copyObj
(
options
)));
if
(
this
.
mv
.
options
.
connect
==
"
align
"
)
{
if
(
!
this
.
edit
.
state
.
trackAlignable
)
this
.
edit
.
state
.
trackAlignable
=
new
TrackAlignable
(
this
.
edit
)
this
.
orig
.
state
.
trackAlignable
=
new
TrackAlignable
(
this
.
orig
)
}
this
.
lockButton
.
title
=
this
.
edit
.
phrase
(
"
Toggle locked scrolling
"
);
this
.
orig
.
state
.
diffViews
=
[
this
];
var
classLocation
=
options
.
chunkClassLocation
||
"
background
"
;
if
(
Object
.
prototype
.
toString
.
call
(
classLocation
)
!=
"
[object Array]
"
)
classLocation
=
[
classLocation
]
this
.
classes
.
classLocation
=
classLocation
this
.
diff
=
getDiff
(
asString
(
orig
),
asString
(
options
.
value
),
this
.
mv
.
options
.
ignoreWhitespace
);
this
.
chunks
=
getChunks
(
this
.
diff
);
this
.
diffOutOfDate
=
this
.
dealigned
=
false
;
this
.
needsScrollSync
=
null
this
.
showDifferences
=
options
.
showDifferences
!==
false
;
},
registerEvents
:
function
(
otherDv
)
{
this
.
forceUpdate
=
registerUpdate
(
this
);
setScrollLock
(
this
,
true
,
false
);
registerScroll
(
this
,
otherDv
);
},
setShowDifferences
:
function
(
val
)
{
val
=
val
!==
false
;
if
(
val
!=
this
.
showDifferences
)
{
this
.
showDifferences
=
val
;
this
.
forceUpdate
(
"
full
"
);
}
}
};
function
ensureDiff
(
dv
)
{
if
(
dv
.
diffOutOfDate
)
{
dv
.
diff
=
getDiff
(
dv
.
orig
.
getValue
(),
dv
.
edit
.
getValue
(),
dv
.
mv
.
options
.
ignoreWhitespace
);
dv
.
chunks
=
getChunks
(
dv
.
diff
);
dv
.
diffOutOfDate
=
false
;
CodeMirror
.
signal
(
dv
.
edit
,
"
updateDiff
"
,
dv
.
diff
);
}
}
var
updating
=
false
;
function
registerUpdate
(
dv
)
{
var
edit
=
{
from
:
0
,
to
:
0
,
marked
:
[]};
var
orig
=
{
from
:
0
,
to
:
0
,
marked
:
[]};
var
debounceChange
,
updatingFast
=
false
;
function
update
(
mode
)
{
updating
=
true
;
updatingFast
=
false
;
if
(
mode
==
"
full
"
)
{
if
(
dv
.
svg
)
clear
(
dv
.
svg
);
if
(
dv
.
copyButtons
)
clear
(
dv
.
copyButtons
);
clearMarks
(
dv
.
edit
,
edit
.
marked
,
dv
.
classes
);
clearMarks
(
dv
.
orig
,
orig
.
marked
,
dv
.
classes
);
edit
.
from
=
edit
.
to
=
orig
.
from
=
orig
.
to
=
0
;
}
ensureDiff
(
dv
);
if
(
dv
.
showDifferences
)
{
updateMarks
(
dv
.
edit
,
dv
.
diff
,
edit
,
DIFF_INSERT
,
dv
.
classes
);
updateMarks
(
dv
.
orig
,
dv
.
diff
,
orig
,
DIFF_DELETE
,
dv
.
classes
);
}
if
(
dv
.
mv
.
options
.
connect
==
"
align
"
)
alignChunks
(
dv
);
makeConnections
(
dv
);
if
(
dv
.
needsScrollSync
!=
null
)
syncScroll
(
dv
,
dv
.
needsScrollSync
)
updating
=
false
;
}
function
setDealign
(
fast
)
{
if
(
updating
)
return
;
dv
.
dealigned
=
true
;
set
(
fast
);
}
function
set
(
fast
)
{
if
(
updating
||
updatingFast
)
return
;
clearTimeout
(
debounceChange
);
if
(
fast
===
true
)
updatingFast
=
true
;
debounceChange
=
setTimeout
(
update
,
fast
===
true
?
20
:
250
);
}
function
change
(
_cm
,
change
)
{
if
(
!
dv
.
diffOutOfDate
)
{
dv
.
diffOutOfDate
=
true
;
edit
.
from
=
edit
.
to
=
orig
.
from
=
orig
.
to
=
0
;
}
// Update faster when a line was added/removed
setDealign
(
change
.
text
.
length
-
1
!=
change
.
to
.
line
-
change
.
from
.
line
);
}
function
swapDoc
()
{
dv
.
diffOutOfDate
=
true
;
dv
.
dealigned
=
true
;
update
(
"
full
"
);
}
dv
.
edit
.
on
(
"
change
"
,
change
);
dv
.
orig
.
on
(
"
change
"
,
change
);
dv
.
edit
.
on
(
"
swapDoc
"
,
swapDoc
);
dv
.
orig
.
on
(
"
swapDoc
"
,
swapDoc
);
if
(
dv
.
mv
.
options
.
connect
==
"
align
"
)
{
CodeMirror
.
on
(
dv
.
edit
.
state
.
trackAlignable
,
"
realign
"
,
setDealign
)
CodeMirror
.
on
(
dv
.
orig
.
state
.
trackAlignable
,
"
realign
"
,
setDealign
)
}
dv
.
edit
.
on
(
"
viewportChange
"
,
function
()
{
set
(
false
);
});
dv
.
orig
.
on
(
"
viewportChange
"
,
function
()
{
set
(
false
);
});
update
();
return
update
;
}
function
registerScroll
(
dv
,
otherDv
)
{
dv
.
edit
.
on
(
"
scroll
"
,
function
()
{
syncScroll
(
dv
,
true
)
&&
makeConnections
(
dv
);
});
dv
.
orig
.
on
(
"
scroll
"
,
function
()
{
syncScroll
(
dv
,
false
)
&&
makeConnections
(
dv
);
if
(
otherDv
)
syncScroll
(
otherDv
,
true
)
&&
makeConnections
(
otherDv
);
});
}
function
syncScroll
(
dv
,
toOrig
)
{
// Change handler will do a refresh after a timeout when diff is out of date
if
(
dv
.
diffOutOfDate
)
{
if
(
dv
.
lockScroll
&&
dv
.
needsScrollSync
==
null
)
dv
.
needsScrollSync
=
toOrig
return
false
}
dv
.
needsScrollSync
=
null
if
(
!
dv
.
lockScroll
)
return
true
;
var
editor
,
other
,
now
=
+
new
Date
;
if
(
toOrig
)
{
editor
=
dv
.
edit
;
other
=
dv
.
orig
;
}
else
{
editor
=
dv
.
orig
;
other
=
dv
.
edit
;
}
// Don't take action if the position of this editor was recently set
// (to prevent feedback loops)
if
(
editor
.
state
.
scrollSetBy
==
dv
&&
(
editor
.
state
.
scrollSetAt
||
0
)
+
250
>
now
)
return
false
;
var
sInfo
=
editor
.
getScrollInfo
();
if
(
dv
.
mv
.
options
.
connect
==
"
align
"
)
{
targetPos
=
sInfo
.
top
;
}
else
{
var
halfScreen
=
.
5
*
sInfo
.
clientHeight
,
midY
=
sInfo
.
top
+
halfScreen
;
var
mid
=
editor
.
lineAtHeight
(
midY
,
"
local
"
);
var
around
=
chunkBoundariesAround
(
dv
.
chunks
,
mid
,
toOrig
);
var
off
=
getOffsets
(
editor
,
toOrig
?
around
.
edit
:
around
.
orig
);
var
offOther
=
getOffsets
(
other
,
toOrig
?
around
.
orig
:
around
.
edit
);
var
ratio
=
(
midY
-
off
.
top
)
/
(
off
.
bot
-
off
.
top
);
var
targetPos
=
(
offOther
.
top
-
halfScreen
)
+
ratio
*
(
offOther
.
bot
-
offOther
.
top
);
var
botDist
,
mix
;
// Some careful tweaking to make sure no space is left out of view
// when scrolling to top or bottom.
if
(
targetPos
>
sInfo
.
top
&&
(
mix
=
sInfo
.
top
/
halfScreen
)
<
1
)
{
targetPos
=
targetPos
*
mix
+
sInfo
.
top
*
(
1
-
mix
);
}
else
if
((
botDist
=
sInfo
.
height
-
sInfo
.
clientHeight
-
sInfo
.
top
)
<
halfScreen
)
{
var
otherInfo
=
other
.
getScrollInfo
();
var
botDistOther
=
otherInfo
.
height
-
otherInfo
.
clientHeight
-
targetPos
;
if
(
botDistOther
>
botDist
&&
(
mix
=
botDist
/
halfScreen
)
<
1
)
targetPos
=
targetPos
*
mix
+
(
otherInfo
.
height
-
otherInfo
.
clientHeight
-
botDist
)
*
(
1
-
mix
);
}
}
other
.
scrollTo
(
sInfo
.
left
,
targetPos
);
other
.
state
.
scrollSetAt
=
now
;
other
.
state
.
scrollSetBy
=
dv
;
return
true
;
}
function
getOffsets
(
editor
,
around
)
{
var
bot
=
around
.
after
;
if
(
bot
==
null
)
bot
=
editor
.
lastLine
()
+
1
;
return
{
top
:
editor
.
heightAtLine
(
around
.
before
||
0
,
"
local
"
),
bot
:
editor
.
heightAtLine
(
bot
,
"
local
"
)};
}
function
setScrollLock
(
dv
,
val
,
action
)
{
dv
.
lockScroll
=
val
;
if
(
val
&&
action
!=
false
)
syncScroll
(
dv
,
DIFF_INSERT
)
&&
makeConnections
(
dv
);
(
val
?
CodeMirror
.
addClass
:
CodeMirror
.
rmClass
)(
dv
.
lockButton
,
"
CodeMirror-merge-scrolllock-enabled
"
);
}
// Updating the marks for editor content
function
removeClass
(
editor
,
line
,
classes
)
{
var
locs
=
classes
.
classLocation
for
(
var
i
=
0
;
i
<
locs
.
length
;
i
++
)
{
editor
.
removeLineClass
(
line
,
locs
[
i
],
classes
.
chunk
);
editor
.
removeLineClass
(
line
,
locs
[
i
],
classes
.
start
);
editor
.
removeLineClass
(
line
,
locs
[
i
],
classes
.
end
);
}
}
function
clearMarks
(
editor
,
arr
,
classes
)
{
for
(
var
i
=
0
;
i
<
arr
.
length
;
++
i
)
{
var
mark
=
arr
[
i
];
if
(
mark
instanceof
CodeMirror
.
TextMarker
)
mark
.
clear
();
else
if
(
mark
.
parent
)
removeClass
(
editor
,
mark
,
classes
);
}
arr
.
length
=
0
;
}
// FIXME maybe add a margin around viewport to prevent too many updates
function
updateMarks
(
editor
,
diff
,
state
,
type
,
classes
)
{
var
vp
=
editor
.
getViewport
();
editor
.
operation
(
function
()
{
if
(
state
.
from
==
state
.
to
||
vp
.
from
-
state
.
to
>
20
||
state
.
from
-
vp
.
to
>
20
)
{
clearMarks
(
editor
,
state
.
marked
,
classes
);
markChanges
(
editor
,
diff
,
type
,
state
.
marked
,
vp
.
from
,
vp
.
to
,
classes
);
state
.
from
=
vp
.
from
;
state
.
to
=
vp
.
to
;
}
else
{
if
(
vp
.
from
<
state
.
from
)
{
markChanges
(
editor
,
diff
,
type
,
state
.
marked
,
vp
.
from
,
state
.
from
,
classes
);
state
.
from
=
vp
.
from
;
}
if
(
vp
.
to
>
state
.
to
)
{
markChanges
(
editor
,
diff
,
type
,
state
.
marked
,
state
.
to
,
vp
.
to
,
classes
);
state
.
to
=
vp
.
to
;
}
}
});
}
function
addClass
(
editor
,
lineNr
,
classes
,
main
,
start
,
end
)
{
var
locs
=
classes
.
classLocation
,
line
=
editor
.
getLineHandle
(
lineNr
);
for
(
var
i
=
0
;
i
<
locs
.
length
;
i
++
)
{
if
(
main
)
editor
.
addLineClass
(
line
,
locs
[
i
],
classes
.
chunk
);
if
(
start
)
editor
.
addLineClass
(
line
,
locs
[
i
],
classes
.
start
);
if
(
end
)
editor
.
addLineClass
(
line
,
locs
[
i
],
classes
.
end
);
}
return
line
;
}
function
markChanges
(
editor
,
diff
,
type
,
marks
,
from
,
to
,
classes
)
{
var
pos
=
Pos
(
0
,
0
);
var
top
=
Pos
(
from
,
0
),
bot
=
editor
.
clipPos
(
Pos
(
to
-
1
));
var
cls
=
type
==
DIFF_DELETE
?
classes
.
del
:
classes
.
insert
;
function
markChunk
(
start
,
end
)
{
var
bfrom
=
Math
.
max
(
from
,
start
),
bto
=
Math
.
min
(
to
,
end
);
for
(
var
i
=
bfrom
;
i
<
bto
;
++
i
)
marks
.
push
(
addClass
(
editor
,
i
,
classes
,
true
,
i
==
start
,
i
==
end
-
1
));
// When the chunk is empty, make sure a horizontal line shows up
if
(
start
==
end
&&
bfrom
==
end
&&
bto
==
end
)
{
if
(
bfrom
)
marks
.
push
(
addClass
(
editor
,
bfrom
-
1
,
classes
,
false
,
false
,
true
));
else
marks
.
push
(
addClass
(
editor
,
bfrom
,
classes
,
false
,
true
,
false
));
}
}
var
chunkStart
=
0
,
pending
=
false
;
for
(
var
i
=
0
;
i
<
diff
.
length
;
++
i
)
{
var
part
=
diff
[
i
],
tp
=
part
[
0
],
str
=
part
[
1
];
if
(
tp
==
DIFF_EQUAL
)
{
var
cleanFrom
=
pos
.
line
+
(
startOfLineClean
(
diff
,
i
)
?
0
:
1
);
moveOver
(
pos
,
str
);
var
cleanTo
=
pos
.
line
+
(
endOfLineClean
(
diff
,
i
)
?
1
:
0
);
if
(
cleanTo
>
cleanFrom
)
{
if
(
pending
)
{
markChunk
(
chunkStart
,
cleanFrom
);
pending
=
false
}
chunkStart
=
cleanTo
;
}
}
else
{
pending
=
true
if
(
tp
==
type
)
{
var
end
=
moveOver
(
pos
,
str
,
true
);
var
a
=
posMax
(
top
,
pos
),
b
=
posMin
(
bot
,
end
);
if
(
!
posEq
(
a
,
b
))
marks
.
push
(
editor
.
markText
(
a
,
b
,
{
className
:
cls
}));
pos
=
end
;
}
}
}
if
(
pending
)
markChunk
(
chunkStart
,
pos
.
line
+
1
);
}
// Updating the gap between editor and original
function
makeConnections
(
dv
)
{
if
(
!
dv
.
showDifferences
)
return
;
if
(
dv
.
svg
)
{
clear
(
dv
.
svg
);
var
w
=
dv
.
gap
.
offsetWidth
;
attrs
(
dv
.
svg
,
"
width
"
,
w
,
"
height
"
,
dv
.
gap
.
offsetHeight
);
}
if
(
dv
.
copyButtons
)
clear
(
dv
.
copyButtons
);
var
vpEdit
=
dv
.
edit
.
getViewport
(),
vpOrig
=
dv
.
orig
.
getViewport
();
var
outerTop
=
dv
.
mv
.
wrap
.
getBoundingClientRect
().
top
var
sTopEdit
=
outerTop
-
dv
.
edit
.
getScrollerElement
().
getBoundingClientRect
().
top
+
dv
.
edit
.
getScrollInfo
().
top
var
sTopOrig
=
outerTop
-
dv
.
orig
.
getScrollerElement
().
getBoundingClientRect
().
top
+
dv
.
orig
.
getScrollInfo
().
top
;
for
(
var
i
=
0
;
i
<
dv
.
chunks
.
length
;
i
++
)
{
var
ch
=
dv
.
chunks
[
i
];
if
(
ch
.
editFrom
<=
vpEdit
.
to
&&
ch
.
editTo
>=
vpEdit
.
from
&&
ch
.
origFrom
<=
vpOrig
.
to
&&
ch
.
origTo
>=
vpOrig
.
from
)
drawConnectorsForChunk
(
dv
,
ch
,
sTopOrig
,
sTopEdit
,
w
);
}
}
function
getMatchingOrigLine
(
editLine
,
chunks
)
{
var
editStart
=
0
,
origStart
=
0
;
for
(
var
i
=
0
;
i
<
chunks
.
length
;
i
++
)
{
var
chunk
=
chunks
[
i
];
if
(
chunk
.
editTo
>
editLine
&&
chunk
.
editFrom
<=
editLine
)
return
null
;
if
(
chunk
.
editFrom
>
editLine
)
break
;
editStart
=
chunk
.
editTo
;
origStart
=
chunk
.
origTo
;
}
return
origStart
+
(
editLine
-
editStart
);
}
// Combines information about chunks and widgets/markers to return
// an array of lines, in a single editor, that probably need to be
// aligned with their counterparts in the editor next to it.
function
alignableFor
(
cm
,
chunks
,
isOrig
)
{
var
tracker
=
cm
.
state
.
trackAlignable
var
start
=
cm
.
firstLine
(),
trackI
=
0
var
result
=
[]
for
(
var
i
=
0
;;
i
++
)
{
var
chunk
=
chunks
[
i
]
var
chunkStart
=
!
chunk
?
1
e9
:
isOrig
?
chunk
.
origFrom
:
chunk
.
editFrom
for
(;
trackI
<
tracker
.
alignable
.
length
;
trackI
+=
2
)
{
var
n
=
tracker
.
alignable
[
trackI
]
+
1
if
(
n
<=
start
)
continue
if
(
n
<=
chunkStart
)
result
.
push
(
n
)
else
break
}
if
(
!
chunk
)
break
result
.
push
(
start
=
isOrig
?
chunk
.
origTo
:
chunk
.
editTo
)
}
return
result
}
// Given information about alignable lines in two editors, fill in
// the result (an array of three-element arrays) to reflect the
// lines that need to be aligned with each other.
function
mergeAlignable
(
result
,
origAlignable
,
chunks
,
setIndex
)
{
var
rI
=
0
,
origI
=
0
,
chunkI
=
0
,
diff
=
0
outer
:
for
(;;
rI
++
)
{
var
nextR
=
result
[
rI
],
nextO
=
origAlignable
[
origI
]
if
(
!
nextR
&&
nextO
==
null
)
break
var
rLine
=
nextR
?
nextR
[
0
]
:
1
e9
,
oLine
=
nextO
==
null
?
1
e9
:
nextO
while
(
chunkI
<
chunks
.
length
)
{
var
chunk
=
chunks
[
chunkI
]
if
(
chunk
.
origFrom
<=
oLine
&&
chunk
.
origTo
>
oLine
)
{
origI
++
rI
--
continue
outer
;
}
if
(
chunk
.
editTo
>
rLine
)
{
if
(
chunk
.
editFrom
<=
rLine
)
continue
outer
;
break
}
diff
+=
(
chunk
.
origTo
-
chunk
.
origFrom
)
-
(
chunk
.
editTo
-
chunk
.
editFrom
)
chunkI
++
}
if
(
rLine
==
oLine
-
diff
)
{
nextR
[
setIndex
]
=
oLine
origI
++
}
else
if
(
rLine
<
oLine
-
diff
)
{
nextR
[
setIndex
]
=
rLine
+
diff
}
else
{
var
record
=
[
oLine
-
diff
,
null
,
null
]
record
[
setIndex
]
=
oLine
result
.
splice
(
rI
,
0
,
record
)
origI
++
}
}
}
function
findAlignedLines
(
dv
,
other
)
{
var
alignable
=
alignableFor
(
dv
.
edit
,
dv
.
chunks
,
false
),
result
=
[]
if
(
other
)
for
(
var
i
=
0
,
j
=
0
;
i
<
other
.
chunks
.
length
;
i
++
)
{
var
n
=
other
.
chunks
[
i
].
editTo
while
(
j
<
alignable
.
length
&&
alignable
[
j
]
<
n
)
j
++
if
(
j
==
alignable
.
length
||
alignable
[
j
]
!=
n
)
alignable
.
splice
(
j
++
,
0
,
n
)
}
for
(
var
i
=
0
;
i
<
alignable
.
length
;
i
++
)
result
.
push
([
alignable
[
i
],
null
,
null
])
mergeAlignable
(
result
,
alignableFor
(
dv
.
orig
,
dv
.
chunks
,
true
),
dv
.
chunks
,
1
)
if
(
other
)
mergeAlignable
(
result
,
alignableFor
(
other
.
orig
,
other
.
chunks
,
true
),
other
.
chunks
,
2
)
return
result
}
function
alignChunks
(
dv
,
force
)
{
if
(
!
dv
.
dealigned
&&
!
force
)
return
;
if
(
!
dv
.
orig
.
curOp
)
return
dv
.
orig
.
operation
(
function
()
{
alignChunks
(
dv
,
force
);
});
dv
.
dealigned
=
false
;
var
other
=
dv
.
mv
.
left
==
dv
?
dv
.
mv
.
right
:
dv
.
mv
.
left
;
if
(
other
)
{
ensureDiff
(
other
);
other
.
dealigned
=
false
;
}
var
linesToAlign
=
findAlignedLines
(
dv
,
other
);
// Clear old aligners
var
aligners
=
dv
.
mv
.
aligners
;
for
(
var
i
=
0
;
i
<
aligners
.
length
;
i
++
)
aligners
[
i
].
clear
();
aligners
.
length
=
0
;
var
cm
=
[
dv
.
edit
,
dv
.
orig
],
scroll
=
[];
if
(
other
)
cm
.
push
(
other
.
orig
);
for
(
var
i
=
0
;
i
<
cm
.
length
;
i
++
)
scroll
.
push
(
cm
[
i
].
getScrollInfo
().
top
);
for
(
var
ln
=
0
;
ln
<
linesToAlign
.
length
;
ln
++
)
alignLines
(
cm
,
linesToAlign
[
ln
],
aligners
);
for
(
var
i
=
0
;
i
<
cm
.
length
;
i
++
)
cm
[
i
].
scrollTo
(
null
,
scroll
[
i
]);
}
function
alignLines
(
cm
,
lines
,
aligners
)
{
var
maxOffset
=
0
,
offset
=
[];
for
(
var
i
=
0
;
i
<
cm
.
length
;
i
++
)
if
(
lines
[
i
]
!=
null
)
{
var
off
=
cm
[
i
].
heightAtLine
(
lines
[
i
],
"
local
"
);
offset
[
i
]
=
off
;
maxOffset
=
Math
.
max
(
maxOffset
,
off
);
}
for
(
var
i
=
0
;
i
<
cm
.
length
;
i
++
)
if
(
lines
[
i
]
!=
null
)
{
var
diff
=
maxOffset
-
offset
[
i
];
if
(
diff
>
1
)
aligners
.
push
(
padAbove
(
cm
[
i
],
lines
[
i
],
diff
));
}
}
function
padAbove
(
cm
,
line
,
size
)
{
var
above
=
true
;
if
(
line
>
cm
.
lastLine
())
{
line
--
;
above
=
false
;
}
var
elt
=
document
.
createElement
(
"
div
"
);
elt
.
className
=
"
CodeMirror-merge-spacer
"
;
elt
.
style
.
height
=
size
+
"
px
"
;
elt
.
style
.
minWidth
=
"
1px
"
;
return
cm
.
addLineWidget
(
line
,
elt
,
{
height
:
size
,
above
:
above
,
mergeSpacer
:
true
,
handleMouseEvents
:
true
});
}
function
drawConnectorsForChunk
(
dv
,
chunk
,
sTopOrig
,
sTopEdit
,
w
)
{
var
flip
=
dv
.
type
==
"
left
"
;
var
top
=
dv
.
orig
.
heightAtLine
(
chunk
.
origFrom
,
"
local
"
,
true
)
-
sTopOrig
;
if
(
dv
.
svg
)
{
var
topLpx
=
top
;
var
topRpx
=
dv
.
edit
.
heightAtLine
(
chunk
.
editFrom
,
"
local
"
,
true
)
-
sTopEdit
;
if
(
flip
)
{
var
tmp
=
topLpx
;
topLpx
=
topRpx
;
topRpx
=
tmp
;
}
var
botLpx
=
dv
.
orig
.
heightAtLine
(
chunk
.
origTo
,
"
local
"
,
true
)
-
sTopOrig
;
var
botRpx
=
dv
.
edit
.
heightAtLine
(
chunk
.
editTo
,
"
local
"
,
true
)
-
sTopEdit
;
if
(
flip
)
{
var
tmp
=
botLpx
;
botLpx
=
botRpx
;
botRpx
=
tmp
;
}
var
curveTop
=
"
C
"
+
w
/
2
+
"
"
+
topRpx
+
"
"
+
w
/
2
+
"
"
+
topLpx
+
"
"
+
(
w
+
2
)
+
"
"
+
topLpx
;
var
curveBot
=
"
C
"
+
w
/
2
+
"
"
+
botLpx
+
"
"
+
w
/
2
+
"
"
+
botRpx
+
"
-1
"
+
botRpx
;
attrs
(
dv
.
svg
.
appendChild
(
document
.
createElementNS
(
svgNS
,
"
path
"
)),
"
d
"
,
"
M -1
"
+
topRpx
+
curveTop
+
"
L
"
+
(
w
+
2
)
+
"
"
+
botLpx
+
curveBot
+
"
z
"
,
"
class
"
,
dv
.
classes
.
connect
);
}
if
(
dv
.
copyButtons
)
{
var
copy
=
dv
.
copyButtons
.
appendChild
(
elt
(
"
div
"
,
dv
.
type
==
"
left
"
?
"
\
u21dd
"
:
"
\
u21dc
"
,
"
CodeMirror-merge-copy
"
));
var
editOriginals
=
dv
.
mv
.
options
.
allowEditingOriginals
;
copy
.
title
=
dv
.
edit
.
phrase
(
editOriginals
?
"
Push to left
"
:
"
Revert chunk
"
);
copy
.
chunk
=
chunk
;
copy
.
style
.
top
=
(
chunk
.
origTo
>
chunk
.
origFrom
?
top
:
dv
.
edit
.
heightAtLine
(
chunk
.
editFrom
,
"
local
"
)
-
sTopEdit
)
+
"
px
"
;
if
(
editOriginals
)
{
var
topReverse
=
dv
.
edit
.
heightAtLine
(
chunk
.
editFrom
,
"
local
"
)
-
sTopEdit
;
var
copyReverse
=
dv
.
copyButtons
.
appendChild
(
elt
(
"
div
"
,
dv
.
type
==
"
right
"
?
"
\
u21dd
"
:
"
\
u21dc
"
,
"
CodeMirror-merge-copy-reverse
"
));
copyReverse
.
title
=
"
Push to right
"
;
copyReverse
.
chunk
=
{
editFrom
:
chunk
.
origFrom
,
editTo
:
chunk
.
origTo
,
origFrom
:
chunk
.
editFrom
,
origTo
:
chunk
.
editTo
};
copyReverse
.
style
.
top
=
topReverse
+
"
px
"
;
dv
.
type
==
"
right
"
?
copyReverse
.
style
.
left
=
"
2px
"
:
copyReverse
.
style
.
right
=
"
2px
"
;
}
}
}
function
copyChunk
(
dv
,
to
,
from
,
chunk
)
{
if
(
dv
.
diffOutOfDate
)
return
;
var
origStart
=
chunk
.
origTo
>
from
.
lastLine
()
?
Pos
(
chunk
.
origFrom
-
1
)
:
Pos
(
chunk
.
origFrom
,
0
)
var
origEnd
=
Pos
(
chunk
.
origTo
,
0
)
var
editStart
=
chunk
.
editTo
>
to
.
lastLine
()
?
Pos
(
chunk
.
editFrom
-
1
)
:
Pos
(
chunk
.
editFrom
,
0
)
var
editEnd
=
Pos
(
chunk
.
editTo
,
0
)
var
handler
=
dv
.
mv
.
options
.
revertChunk
if
(
handler
)
handler
(
dv
.
mv
,
from
,
origStart
,
origEnd
,
to
,
editStart
,
editEnd
)
else
to
.
replaceRange
(
from
.
getRange
(
origStart
,
origEnd
),
editStart
,
editEnd
)
}
// Merge view, containing 0, 1, or 2 diff views.
var
MergeView
=
CodeMirror
.
MergeView
=
function
(
node
,
options
)
{
if
(
!
(
this
instanceof
MergeView
))
return
new
MergeView
(
node
,
options
);
this
.
options
=
options
;
var
origLeft
=
options
.
origLeft
,
origRight
=
options
.
origRight
==
null
?
options
.
orig
:
options
.
origRight
;
var
hasLeft
=
origLeft
!=
null
,
hasRight
=
origRight
!=
null
;
var
panes
=
1
+
(
hasLeft
?
1
:
0
)
+
(
hasRight
?
1
:
0
);
var
wrap
=
[],
left
=
this
.
left
=
null
,
right
=
this
.
right
=
null
;
var
self
=
this
;
if
(
hasLeft
)
{
left
=
this
.
left
=
new
DiffView
(
this
,
"
left
"
);
var
leftPane
=
elt
(
"
div
"
,
null
,
"
CodeMirror-merge-pane CodeMirror-merge-left
"
);
wrap
.
push
(
leftPane
);
wrap
.
push
(
buildGap
(
left
));
}
var
editPane
=
elt
(
"
div
"
,
null
,
"
CodeMirror-merge-pane CodeMirror-merge-editor
"
);
wrap
.
push
(
editPane
);
if
(
hasRight
)
{
right
=
this
.
right
=
new
DiffView
(
this
,
"
right
"
);
wrap
.
push
(
buildGap
(
right
));
var
rightPane
=
elt
(
"
div
"
,
null
,
"
CodeMirror-merge-pane CodeMirror-merge-right
"
);
wrap
.
push
(
rightPane
);
}
(
hasRight
?
rightPane
:
editPane
).
className
+=
"
CodeMirror-merge-pane-rightmost
"
;
wrap
.
push
(
elt
(
"
div
"
,
null
,
null
,
"
height: 0; clear: both;
"
));
var
wrapElt
=
this
.
wrap
=
node
.
appendChild
(
elt
(
"
div
"
,
wrap
,
"
CodeMirror-merge CodeMirror-merge-
"
+
panes
+
"
pane
"
));
this
.
edit
=
CodeMirror
(
editPane
,
copyObj
(
options
));
if
(
left
)
left
.
init
(
leftPane
,
origLeft
,
options
);
if
(
right
)
right
.
init
(
rightPane
,
origRight
,
options
);
if
(
options
.
collapseIdentical
)
this
.
editor
().
operation
(
function
()
{
collapseIdenticalStretches
(
self
,
options
.
collapseIdentical
);
});
if
(
options
.
connect
==
"
align
"
)
{
this
.
aligners
=
[];
alignChunks
(
this
.
left
||
this
.
right
,
true
);
}
if
(
left
)
left
.
registerEvents
(
right
)
if
(
right
)
right
.
registerEvents
(
left
)
var
onResize
=
function
()
{
if
(
left
)
makeConnections
(
left
);
if
(
right
)
makeConnections
(
right
);
};
CodeMirror
.
on
(
window
,
"
resize
"
,
onResize
);
var
resizeInterval
=
setInterval
(
function
()
{
for
(
var
p
=
wrapElt
.
parentNode
;
p
&&
p
!=
document
.
body
;
p
=
p
.
parentNode
)
{}
if
(
!
p
)
{
clearInterval
(
resizeInterval
);
CodeMirror
.
off
(
window
,
"
resize
"
,
onResize
);
}
},
5000
);
};
function
buildGap
(
dv
)
{
var
lock
=
dv
.
lockButton
=
elt
(
"
div
"
,
null
,
"
CodeMirror-merge-scrolllock
"
);
var
lockWrap
=
elt
(
"
div
"
,
[
lock
],
"
CodeMirror-merge-scrolllock-wrap
"
);
CodeMirror
.
on
(
lock
,
"
click
"
,
function
()
{
setScrollLock
(
dv
,
!
dv
.
lockScroll
);
});
var
gapElts
=
[
lockWrap
];
if
(
dv
.
mv
.
options
.
revertButtons
!==
false
)
{
dv
.
copyButtons
=
elt
(
"
div
"
,
null
,
"
CodeMirror-merge-copybuttons-
"
+
dv
.
type
);
CodeMirror
.
on
(
dv
.
copyButtons
,
"
click
"
,
function
(
e
)
{
var
node
=
e
.
target
||
e
.
srcElement
;
if
(
!
node
.
chunk
)
return
;
if
(
node
.
className
==
"
CodeMirror-merge-copy-reverse
"
)
{
copyChunk
(
dv
,
dv
.
orig
,
dv
.
edit
,
node
.
chunk
);
return
;
}
copyChunk
(
dv
,
dv
.
edit
,
dv
.
orig
,
node
.
chunk
);
});
gapElts
.
unshift
(
dv
.
copyButtons
);
}
if
(
dv
.
mv
.
options
.
connect
!=
"
align
"
)
{
var
svg
=
document
.
createElementNS
&&
document
.
createElementNS
(
svgNS
,
"
svg
"
);
if
(
svg
&&
!
svg
.
createSVGRect
)
svg
=
null
;
dv
.
svg
=
svg
;
if
(
svg
)
gapElts
.
push
(
svg
);
}
return
dv
.
gap
=
elt
(
"
div
"
,
gapElts
,
"
CodeMirror-merge-gap
"
);
}
MergeView
.
prototype
=
{
constructor
:
MergeView
,
editor
:
function
()
{
return
this
.
edit
;
},
rightOriginal
:
function
()
{
return
this
.
right
&&
this
.
right
.
orig
;
},
leftOriginal
:
function
()
{
return
this
.
left
&&
this
.
left
.
orig
;
},
setShowDifferences
:
function
(
val
)
{
if
(
this
.
right
)
this
.
right
.
setShowDifferences
(
val
);
if
(
this
.
left
)
this
.
left
.
setShowDifferences
(
val
);
},
rightChunks
:
function
()
{
if
(
this
.
right
)
{
ensureDiff
(
this
.
right
);
return
this
.
right
.
chunks
;
}
},
leftChunks
:
function
()
{
if
(
this
.
left
)
{
ensureDiff
(
this
.
left
);
return
this
.
left
.
chunks
;
}
}
};
function
asString
(
obj
)
{
if
(
typeof
obj
==
"
string
"
)
return
obj
;
else
return
obj
.
getValue
();
}
// Operations on diffs
var
dmp
;
function
getDiff
(
a
,
b
,
ignoreWhitespace
)
{
if
(
!
dmp
)
dmp
=
new
diff_match_patch
();
var
diff
=
dmp
.
diff_main
(
a
,
b
);
// The library sometimes leaves in empty parts, which confuse the algorithm
for
(
var
i
=
0
;
i
<
diff
.
length
;
++
i
)
{
var
part
=
diff
[
i
];
if
(
ignoreWhitespace
?
!
/
[^
\t]
/
.
test
(
part
[
1
])
:
!
part
[
1
])
{
diff
.
splice
(
i
--
,
1
);
}
else
if
(
i
&&
diff
[
i
-
1
][
0
]
==
part
[
0
])
{
diff
.
splice
(
i
--
,
1
);
diff
[
i
][
1
]
+=
part
[
1
];
}
}
return
diff
;
}
function
getChunks
(
diff
)
{
var
chunks
=
[];
if
(
!
diff
.
length
)
return
chunks
;
var
startEdit
=
0
,
startOrig
=
0
;
var
edit
=
Pos
(
0
,
0
),
orig
=
Pos
(
0
,
0
);
for
(
var
i
=
0
;
i
<
diff
.
length
;
++
i
)
{
var
part
=
diff
[
i
],
tp
=
part
[
0
];
if
(
tp
==
DIFF_EQUAL
)
{
var
startOff
=
!
startOfLineClean
(
diff
,
i
)
||
edit
.
line
<
startEdit
||
orig
.
line
<
startOrig
?
1
:
0
;
var
cleanFromEdit
=
edit
.
line
+
startOff
,
cleanFromOrig
=
orig
.
line
+
startOff
;
moveOver
(
edit
,
part
[
1
],
null
,
orig
);
var
endOff
=
endOfLineClean
(
diff
,
i
)
?
1
:
0
;
var
cleanToEdit
=
edit
.
line
+
endOff
,
cleanToOrig
=
orig
.
line
+
endOff
;
if
(
cleanToEdit
>
cleanFromEdit
)
{
if
(
i
)
chunks
.
push
({
origFrom
:
startOrig
,
origTo
:
cleanFromOrig
,
editFrom
:
startEdit
,
editTo
:
cleanFromEdit
});
startEdit
=
cleanToEdit
;
startOrig
=
cleanToOrig
;
}
}
else
{
moveOver
(
tp
==
DIFF_INSERT
?
edit
:
orig
,
part
[
1
]);
}
}
if
(
startEdit
<=
edit
.
line
||
startOrig
<=
orig
.
line
)
chunks
.
push
({
origFrom
:
startOrig
,
origTo
:
orig
.
line
+
1
,
editFrom
:
startEdit
,
editTo
:
edit
.
line
+
1
});
return
chunks
;
}
function
endOfLineClean
(
diff
,
i
)
{
if
(
i
==
diff
.
length
-
1
)
return
true
;
var
next
=
diff
[
i
+
1
][
1
];
if
((
next
.
length
==
1
&&
i
<
diff
.
length
-
2
)
||
next
.
charCodeAt
(
0
)
!=
10
)
return
false
;
if
(
i
==
diff
.
length
-
2
)
return
true
;
next
=
diff
[
i
+
2
][
1
];
return
(
next
.
length
>
1
||
i
==
diff
.
length
-
3
)
&&
next
.
charCodeAt
(
0
)
==
10
;
}
function
startOfLineClean
(
diff
,
i
)
{
if
(
i
==
0
)
return
true
;
var
last
=
diff
[
i
-
1
][
1
];
if
(
last
.
charCodeAt
(
last
.
length
-
1
)
!=
10
)
return
false
;
if
(
i
==
1
)
return
true
;
last
=
diff
[
i
-
2
][
1
];
return
last
.
charCodeAt
(
last
.
length
-
1
)
==
10
;
}
function
chunkBoundariesAround
(
chunks
,
n
,
nInEdit
)
{
var
beforeE
,
afterE
,
beforeO
,
afterO
;
for
(
var
i
=
0
;
i
<
chunks
.
length
;
i
++
)
{
var
chunk
=
chunks
[
i
];
var
fromLocal
=
nInEdit
?
chunk
.
editFrom
:
chunk
.
origFrom
;
var
toLocal
=
nInEdit
?
chunk
.
editTo
:
chunk
.
origTo
;
if
(
afterE
==
null
)
{
if
(
fromLocal
>
n
)
{
afterE
=
chunk
.
editFrom
;
afterO
=
chunk
.
origFrom
;
}
else
if
(
toLocal
>
n
)
{
afterE
=
chunk
.
editTo
;
afterO
=
chunk
.
origTo
;
}
}
if
(
toLocal
<=
n
)
{
beforeE
=
chunk
.
editTo
;
beforeO
=
chunk
.
origTo
;
}
else
if
(
fromLocal
<=
n
)
{
beforeE
=
chunk
.
editFrom
;
beforeO
=
chunk
.
origFrom
;
}
}
return
{
edit
:
{
before
:
beforeE
,
after
:
afterE
},
orig
:
{
before
:
beforeO
,
after
:
afterO
}};
}
function
collapseSingle
(
cm
,
from
,
to
)
{
cm
.
addLineClass
(
from
,
"
wrap
"
,
"
CodeMirror-merge-collapsed-line
"
);
var
widget
=
document
.
createElement
(
"
span
"
);
widget
.
className
=
"
CodeMirror-merge-collapsed-widget
"
;
widget
.
title
=
cm
.
phrase
(
"
Identical text collapsed. Click to expand.
"
);
var
mark
=
cm
.
markText
(
Pos
(
from
,
0
),
Pos
(
to
-
1
),
{
inclusiveLeft
:
true
,
inclusiveRight
:
true
,
replacedWith
:
widget
,
clearOnEnter
:
true
});
function
clear
()
{
mark
.
clear
();
cm
.
removeLineClass
(
from
,
"
wrap
"
,
"
CodeMirror-merge-collapsed-line
"
);
}
if
(
mark
.
explicitlyCleared
)
clear
();
CodeMirror
.
on
(
widget
,
"
click
"
,
clear
);
mark
.
on
(
"
clear
"
,
clear
);
CodeMirror
.
on
(
widget
,
"
click
"
,
clear
);
return
{
mark
:
mark
,
clear
:
clear
};
}
function
collapseStretch
(
size
,
editors
)
{
var
marks
=
[];
function
clear
()
{
for
(
var
i
=
0
;
i
<
marks
.
length
;
i
++
)
marks
[
i
].
clear
();
}
for
(
var
i
=
0
;
i
<
editors
.
length
;
i
++
)
{
var
editor
=
editors
[
i
];
var
mark
=
collapseSingle
(
editor
.
cm
,
editor
.
line
,
editor
.
line
+
size
);
marks
.
push
(
mark
);
mark
.
mark
.
on
(
"
clear
"
,
clear
);
}
return
marks
[
0
].
mark
;
}
function
unclearNearChunks
(
dv
,
margin
,
off
,
clear
)
{
for
(
var
i
=
0
;
i
<
dv
.
chunks
.
length
;
i
++
)
{
var
chunk
=
dv
.
chunks
[
i
];
for
(
var
l
=
chunk
.
editFrom
-
margin
;
l
<
chunk
.
editTo
+
margin
;
l
++
)
{
var
pos
=
l
+
off
;
if
(
pos
>=
0
&&
pos
<
clear
.
length
)
clear
[
pos
]
=
false
;
}
}
}
function
collapseIdenticalStretches
(
mv
,
margin
)
{
if
(
typeof
margin
!=
"
number
"
)
margin
=
2
;
var
clear
=
[],
edit
=
mv
.
editor
(),
off
=
edit
.
firstLine
();
for
(
var
l
=
off
,
e
=
edit
.
lastLine
();
l
<=
e
;
l
++
)
clear
.
push
(
true
);
if
(
mv
.
left
)
unclearNearChunks
(
mv
.
left
,
margin
,
off
,
clear
);
if
(
mv
.
right
)
unclearNearChunks
(
mv
.
right
,
margin
,
off
,
clear
);
for
(
var
i
=
0
;
i
<
clear
.
length
;
i
++
)
{
if
(
clear
[
i
])
{
var
line
=
i
+
off
;
for
(
var
size
=
1
;
i
<
clear
.
length
-
1
&&
clear
[
i
+
1
];
i
++
,
size
++
)
{}
if
(
size
>
margin
)
{
var
editors
=
[{
line
:
line
,
cm
:
edit
}];
if
(
mv
.
left
)
editors
.
push
({
line
:
getMatchingOrigLine
(
line
,
mv
.
left
.
chunks
),
cm
:
mv
.
left
.
orig
});
if
(
mv
.
right
)
editors
.
push
({
line
:
getMatchingOrigLine
(
line
,
mv
.
right
.
chunks
),
cm
:
mv
.
right
.
orig
});
var
mark
=
collapseStretch
(
size
,
editors
);
if
(
mv
.
options
.
onCollapse
)
mv
.
options
.
onCollapse
(
mv
,
line
,
size
,
mark
);
}
}
}
}
// General utilities
function
elt
(
tag
,
content
,
className
,
style
)
{
var
e
=
document
.
createElement
(
tag
);
if
(
className
)
e
.
className
=
className
;
if
(
style
)
e
.
style
.
cssText
=
style
;
if
(
typeof
content
==
"
string
"
)
e
.
appendChild
(
document
.
createTextNode
(
content
));
else
if
(
content
)
for
(
var
i
=
0
;
i
<
content
.
length
;
++
i
)
e
.
appendChild
(
content
[
i
]);
return
e
;
}
function
clear
(
node
)
{
for
(
var
count
=
node
.
childNodes
.
length
;
count
>
0
;
--
count
)
node
.
removeChild
(
node
.
firstChild
);
}
function
attrs
(
elt
)
{
for
(
var
i
=
1
;
i
<
arguments
.
length
;
i
+=
2
)
elt
.
setAttribute
(
arguments
[
i
],
arguments
[
i
+
1
]);
}
function
copyObj
(
obj
,
target
)
{
if
(
!
target
)
target
=
{};
for
(
var
prop
in
obj
)
if
(
obj
.
hasOwnProperty
(
prop
))
target
[
prop
]
=
obj
[
prop
];
return
target
;
}
function
moveOver
(
pos
,
str
,
copy
,
other
)
{
var
out
=
copy
?
Pos
(
pos
.
line
,
pos
.
ch
)
:
pos
,
at
=
0
;
for
(;;)
{
var
nl
=
str
.
indexOf
(
"
\n
"
,
at
);
if
(
nl
==
-
1
)
break
;
++
out
.
line
;
if
(
other
)
++
other
.
line
;
at
=
nl
+
1
;
}
out
.
ch
=
(
at
?
0
:
out
.
ch
)
+
(
str
.
length
-
at
);
if
(
other
)
other
.
ch
=
(
at
?
0
:
other
.
ch
)
+
(
str
.
length
-
at
);
return
out
;
}
// Tracks collapsed markers and line widgets, in order to be able to
// accurately align the content of two editors.
var
F_WIDGET
=
1
,
F_WIDGET_BELOW
=
2
,
F_MARKER
=
4
function
TrackAlignable
(
cm
)
{
this
.
cm
=
cm
this
.
alignable
=
[]
this
.
height
=
cm
.
doc
.
height
var
self
=
this
cm
.
on
(
"
markerAdded
"
,
function
(
_
,
marker
)
{
if
(
!
marker
.
collapsed
)
return
var
found
=
marker
.
find
(
1
)
if
(
found
!=
null
)
self
.
set
(
found
.
line
,
F_MARKER
)
})
cm
.
on
(
"
markerCleared
"
,
function
(
_
,
marker
,
_min
,
max
)
{
if
(
max
!=
null
&&
marker
.
collapsed
)
self
.
check
(
max
,
F_MARKER
,
self
.
hasMarker
)
})
cm
.
on
(
"
markerChanged
"
,
this
.
signal
.
bind
(
this
))
cm
.
on
(
"
lineWidgetAdded
"
,
function
(
_
,
widget
,
lineNo
)
{
if
(
widget
.
mergeSpacer
)
return
if
(
widget
.
above
)
self
.
set
(
lineNo
-
1
,
F_WIDGET_BELOW
)
else
self
.
set
(
lineNo
,
F_WIDGET
)
})
cm
.
on
(
"
lineWidgetCleared
"
,
function
(
_
,
widget
,
lineNo
)
{
if
(
widget
.
mergeSpacer
)
return
if
(
widget
.
above
)
self
.
check
(
lineNo
-
1
,
F_WIDGET_BELOW
,
self
.
hasWidgetBelow
)
else
self
.
check
(
lineNo
,
F_WIDGET
,
self
.
hasWidget
)
})
cm
.
on
(
"
lineWidgetChanged
"
,
this
.
signal
.
bind
(
this
))
cm
.
on
(
"
change
"
,
function
(
_
,
change
)
{
var
start
=
change
.
from
.
line
,
nBefore
=
change
.
to
.
line
-
change
.
from
.
line
var
nAfter
=
change
.
text
.
length
-
1
,
end
=
start
+
nAfter
if
(
nBefore
||
nAfter
)
self
.
map
(
start
,
nBefore
,
nAfter
)
self
.
check
(
end
,
F_MARKER
,
self
.
hasMarker
)
if
(
nBefore
||
nAfter
)
self
.
check
(
change
.
from
.
line
,
F_MARKER
,
self
.
hasMarker
)
})
cm
.
on
(
"
viewportChange
"
,
function
()
{
if
(
self
.
cm
.
doc
.
height
!=
self
.
height
)
self
.
signal
()
})
}
TrackAlignable
.
prototype
=
{
signal
:
function
()
{
CodeMirror
.
signal
(
this
,
"
realign
"
)
this
.
height
=
this
.
cm
.
doc
.
height
},
set
:
function
(
n
,
flags
)
{
var
pos
=
-
1
for
(;
pos
<
this
.
alignable
.
length
;
pos
+=
2
)
{
var
diff
=
this
.
alignable
[
pos
]
-
n
if
(
diff
==
0
)
{
if
((
this
.
alignable
[
pos
+
1
]
&
flags
)
==
flags
)
return
this
.
alignable
[
pos
+
1
]
|=
flags
this
.
signal
()
return
}
if
(
diff
>
0
)
break
}
this
.
signal
()
this
.
alignable
.
splice
(
pos
,
0
,
n
,
flags
)
},
find
:
function
(
n
)
{
for
(
var
i
=
0
;
i
<
this
.
alignable
.
length
;
i
+=
2
)
if
(
this
.
alignable
[
i
]
==
n
)
return
i
return
-
1
},
check
:
function
(
n
,
flag
,
pred
)
{
var
found
=
this
.
find
(
n
)
if
(
found
==
-
1
||
!
(
this
.
alignable
[
found
+
1
]
&
flag
))
return
if
(
!
pred
.
call
(
this
,
n
))
{
this
.
signal
()
var
flags
=
this
.
alignable
[
found
+
1
]
&
~
flag
if
(
flags
)
this
.
alignable
[
found
+
1
]
=
flags
else
this
.
alignable
.
splice
(
found
,
2
)
}
},
hasMarker
:
function
(
n
)
{
var
handle
=
this
.
cm
.
getLineHandle
(
n
)
if
(
handle
.
markedSpans
)
for
(
var
i
=
0
;
i
<
handle
.
markedSpans
.
length
;
i
++
)
if
(
handle
.
markedSpans
[
i
].
marker
.
collapsed
&&
handle
.
markedSpans
[
i
].
to
!=
null
)
return
true
return
false
},
hasWidget
:
function
(
n
)
{
var
handle
=
this
.
cm
.
getLineHandle
(
n
)
if
(
handle
.
widgets
)
for
(
var
i
=
0
;
i
<
handle
.
widgets
.
length
;
i
++
)
if
(
!
handle
.
widgets
[
i
].
above
&&
!
handle
.
widgets
[
i
].
mergeSpacer
)
return
true
return
false
},
hasWidgetBelow
:
function
(
n
)
{
if
(
n
==
this
.
cm
.
lastLine
())
return
false
var
handle
=
this
.
cm
.
getLineHandle
(
n
+
1
)
if
(
handle
.
widgets
)
for
(
var
i
=
0
;
i
<
handle
.
widgets
.
length
;
i
++
)
if
(
handle
.
widgets
[
i
].
above
&&
!
handle
.
widgets
[
i
].
mergeSpacer
)
return
true
return
false
},
map
:
function
(
from
,
nBefore
,
nAfter
)
{
var
diff
=
nAfter
-
nBefore
,
to
=
from
+
nBefore
,
widgetFrom
=
-
1
,
widgetTo
=
-
1
for
(
var
i
=
0
;
i
<
this
.
alignable
.
length
;
i
+=
2
)
{
var
n
=
this
.
alignable
[
i
]
if
(
n
==
from
&&
(
this
.
alignable
[
i
+
1
]
&
F_WIDGET_BELOW
))
widgetFrom
=
i
if
(
n
==
to
&&
(
this
.
alignable
[
i
+
1
]
&
F_WIDGET_BELOW
))
widgetTo
=
i
if
(
n
<=
from
)
continue
else
if
(
n
<
to
)
this
.
alignable
.
splice
(
i
--
,
2
)
else
this
.
alignable
[
i
]
+=
diff
}
if
(
widgetFrom
>
-
1
)
{
var
flags
=
this
.
alignable
[
widgetFrom
+
1
]
if
(
flags
==
F_WIDGET_BELOW
)
this
.
alignable
.
splice
(
widgetFrom
,
2
)
else
this
.
alignable
[
widgetFrom
+
1
]
=
flags
&
~
F_WIDGET_BELOW
}
if
(
widgetTo
>
-
1
&&
nAfter
)
this
.
set
(
from
+
nAfter
,
F_WIDGET_BELOW
)
}
}
function
posMin
(
a
,
b
)
{
return
(
a
.
line
-
b
.
line
||
a
.
ch
-
b
.
ch
)
<
0
?
a
:
b
;
}
function
posMax
(
a
,
b
)
{
return
(
a
.
line
-
b
.
line
||
a
.
ch
-
b
.
ch
)
>
0
?
a
:
b
;
}
function
posEq
(
a
,
b
)
{
return
a
.
line
==
b
.
line
&&
a
.
ch
==
b
.
ch
;
}
function
findPrevDiff
(
chunks
,
start
,
isOrig
)
{
for
(
var
i
=
chunks
.
length
-
1
;
i
>=
0
;
i
--
)
{
var
chunk
=
chunks
[
i
];
var
to
=
(
isOrig
?
chunk
.
origTo
:
chunk
.
editTo
)
-
1
;
if
(
to
<
start
)
return
to
;
}
}
function
findNextDiff
(
chunks
,
start
,
isOrig
)
{
for
(
var
i
=
0
;
i
<
chunks
.
length
;
i
++
)
{
var
chunk
=
chunks
[
i
];
var
from
=
(
isOrig
?
chunk
.
origFrom
:
chunk
.
editFrom
);
if
(
from
>
start
)
return
from
;
}
}
function
goNearbyDiff
(
cm
,
dir
)
{
var
found
=
null
,
views
=
cm
.
state
.
diffViews
,
line
=
cm
.
getCursor
().
line
;
if
(
views
)
for
(
var
i
=
0
;
i
<
views
.
length
;
i
++
)
{
var
dv
=
views
[
i
],
isOrig
=
cm
==
dv
.
orig
;
ensureDiff
(
dv
);
var
pos
=
dir
<
0
?
findPrevDiff
(
dv
.
chunks
,
line
,
isOrig
)
:
findNextDiff
(
dv
.
chunks
,
line
,
isOrig
);
if
(
pos
!=
null
&&
(
found
==
null
||
(
dir
<
0
?
pos
>
found
:
pos
<
found
)))
found
=
pos
;
}
if
(
found
!=
null
)
cm
.
setCursor
(
found
,
0
);
else
return
CodeMirror
.
Pass
;
}
CodeMirror
.
commands
.
goNextDiff
=
function
(
cm
)
{
return
goNearbyDiff
(
cm
,
1
);
};
CodeMirror
.
commands
.
goPrevDiff
=
function
(
cm
)
{
return
goNearbyDiff
(
cm
,
-
1
);
};
});
src/main/webapp/static/plugins/codemirror/5.48.4/addon/mode/loadmode.js
0 → 100644
View file @
53f587bc
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(
function
(
mod
)
{
if
(
typeof
exports
==
"
object
"
&&
typeof
module
==
"
object
"
)
// CommonJS
mod
(
require
(
"
../../lib/codemirror
"
),
"
cjs
"
);
else
if
(
typeof
define
==
"
function
"
&&
define
.
amd
)
// AMD
define
([
"
../../lib/codemirror
"
],
function
(
CM
)
{
mod
(
CM
,
"
amd
"
);
});
else
// Plain browser env
mod
(
CodeMirror
,
"
plain
"
);
})(
function
(
CodeMirror
,
env
)
{
if
(
!
CodeMirror
.
modeURL
)
CodeMirror
.
modeURL
=
"
../mode/%N/%N.js
"
;
var
loading
=
{};
function
splitCallback
(
cont
,
n
)
{
var
countDown
=
n
;
return
function
()
{
if
(
--
countDown
==
0
)
cont
();
};
}
function
ensureDeps
(
mode
,
cont
)
{
var
deps
=
CodeMirror
.
modes
[
mode
].
dependencies
;
if
(
!
deps
)
return
cont
();
var
missing
=
[];
for
(
var
i
=
0
;
i
<
deps
.
length
;
++
i
)
{
if
(
!
CodeMirror
.
modes
.
hasOwnProperty
(
deps
[
i
]))
missing
.
push
(
deps
[
i
]);
}
if
(
!
missing
.
length
)
return
cont
();
var
split
=
splitCallback
(
cont
,
missing
.
length
);
for
(
var
i
=
0
;
i
<
missing
.
length
;
++
i
)
CodeMirror
.
requireMode
(
missing
[
i
],
split
);
}
CodeMirror
.
requireMode
=
function
(
mode
,
cont
)
{
if
(
typeof
mode
!=
"
string
"
)
mode
=
mode
.
name
;
if
(
CodeMirror
.
modes
.
hasOwnProperty
(
mode
))
return
ensureDeps
(
mode
,
cont
);
if
(
loading
.
hasOwnProperty
(
mode
))
return
loading
[
mode
].
push
(
cont
);
var
file
=
CodeMirror
.
modeURL
.
replace
(
/%N/g
,
mode
);
if
(
env
==
"
plain
"
)
{
var
script
=
document
.
createElement
(
"
script
"
);
script
.
src
=
file
;
var
others
=
document
.
getElementsByTagName
(
"
script
"
)[
0
];
var
list
=
loading
[
mode
]
=
[
cont
];
CodeMirror
.
on
(
script
,
"
load
"
,
function
()
{
ensureDeps
(
mode
,
function
()
{
for
(
var
i
=
0
;
i
<
list
.
length
;
++
i
)
list
[
i
]();
});
});
others
.
parentNode
.
insertBefore
(
script
,
others
);
}
else
if
(
env
==
"
cjs
"
)
{
require
(
file
);
cont
();
}
else
if
(
env
==
"
amd
"
)
{
requirejs
([
file
],
cont
);
}
};
CodeMirror
.
autoLoadMode
=
function
(
instance
,
mode
)
{
if
(
!
CodeMirror
.
modes
.
hasOwnProperty
(
mode
))
CodeMirror
.
requireMode
(
mode
,
function
()
{
instance
.
setOption
(
"
mode
"
,
instance
.
getOption
(
"
mode
"
));
});
};
});
src/main/webapp/static/plugins/codemirror/5.48.4/addon/mode/multiplex.js
0 → 100644
View file @
53f587bc
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(
function
(
mod
)
{
if
(
typeof
exports
==
"
object
"
&&
typeof
module
==
"
object
"
)
// CommonJS
mod
(
require
(
"
../../lib/codemirror
"
));
else
if
(
typeof
define
==
"
function
"
&&
define
.
amd
)
// AMD
define
([
"
../../lib/codemirror
"
],
mod
);
else
// Plain browser env
mod
(
CodeMirror
);
})(
function
(
CodeMirror
)
{
"
use strict
"
;
CodeMirror
.
multiplexingMode
=
function
(
outer
/*, others */
)
{
// Others should be {open, close, mode [, delimStyle] [, innerStyle]} objects
var
others
=
Array
.
prototype
.
slice
.
call
(
arguments
,
1
);
function
indexOf
(
string
,
pattern
,
from
,
returnEnd
)
{
if
(
typeof
pattern
==
"
string
"
)
{
var
found
=
string
.
indexOf
(
pattern
,
from
);
return
returnEnd
&&
found
>
-
1
?
found
+
pattern
.
length
:
found
;
}
var
m
=
pattern
.
exec
(
from
?
string
.
slice
(
from
)
:
string
);
return
m
?
m
.
index
+
from
+
(
returnEnd
?
m
[
0
].
length
:
0
)
:
-
1
;
}
return
{
startState
:
function
()
{
return
{
outer
:
CodeMirror
.
startState
(
outer
),
innerActive
:
null
,
inner
:
null
};
},
copyState
:
function
(
state
)
{
return
{
outer
:
CodeMirror
.
copyState
(
outer
,
state
.
outer
),
innerActive
:
state
.
innerActive
,
inner
:
state
.
innerActive
&&
CodeMirror
.
copyState
(
state
.
innerActive
.
mode
,
state
.
inner
)
};
},
token
:
function
(
stream
,
state
)
{
if
(
!
state
.
innerActive
)
{
var
cutOff
=
Infinity
,
oldContent
=
stream
.
string
;
for
(
var
i
=
0
;
i
<
others
.
length
;
++
i
)
{
var
other
=
others
[
i
];
var
found
=
indexOf
(
oldContent
,
other
.
open
,
stream
.
pos
);
if
(
found
==
stream
.
pos
)
{
if
(
!
other
.
parseDelimiters
)
stream
.
match
(
other
.
open
);
state
.
innerActive
=
other
;
// Get the outer indent, making sure to handle CodeMirror.Pass
var
outerIndent
=
0
;
if
(
outer
.
indent
)
{
var
possibleOuterIndent
=
outer
.
indent
(
state
.
outer
,
""
,
""
);
if
(
possibleOuterIndent
!==
CodeMirror
.
Pass
)
outerIndent
=
possibleOuterIndent
;
}
state
.
inner
=
CodeMirror
.
startState
(
other
.
mode
,
outerIndent
);
return
other
.
delimStyle
&&
(
other
.
delimStyle
+
"
"
+
other
.
delimStyle
+
"
-open
"
);
}
else
if
(
found
!=
-
1
&&
found
<
cutOff
)
{
cutOff
=
found
;
}
}
if
(
cutOff
!=
Infinity
)
stream
.
string
=
oldContent
.
slice
(
0
,
cutOff
);
var
outerToken
=
outer
.
token
(
stream
,
state
.
outer
);
if
(
cutOff
!=
Infinity
)
stream
.
string
=
oldContent
;
return
outerToken
;
}
else
{
var
curInner
=
state
.
innerActive
,
oldContent
=
stream
.
string
;
if
(
!
curInner
.
close
&&
stream
.
sol
())
{
state
.
innerActive
=
state
.
inner
=
null
;
return
this
.
token
(
stream
,
state
);
}
var
found
=
curInner
.
close
?
indexOf
(
oldContent
,
curInner
.
close
,
stream
.
pos
,
curInner
.
parseDelimiters
)
:
-
1
;
if
(
found
==
stream
.
pos
&&
!
curInner
.
parseDelimiters
)
{
stream
.
match
(
curInner
.
close
);
state
.
innerActive
=
state
.
inner
=
null
;
return
curInner
.
delimStyle
&&
(
curInner
.
delimStyle
+
"
"
+
curInner
.
delimStyle
+
"
-close
"
);
}
if
(
found
>
-
1
)
stream
.
string
=
oldContent
.
slice
(
0
,
found
);
var
innerToken
=
curInner
.
mode
.
token
(
stream
,
state
.
inner
);
if
(
found
>
-
1
)
stream
.
string
=
oldContent
;
if
(
found
==
stream
.
pos
&&
curInner
.
parseDelimiters
)
state
.
innerActive
=
state
.
inner
=
null
;
if
(
curInner
.
innerStyle
)
{
if
(
innerToken
)
innerToken
=
innerToken
+
"
"
+
curInner
.
innerStyle
;
else
innerToken
=
curInner
.
innerStyle
;
}
return
innerToken
;
}
},
indent
:
function
(
state
,
textAfter
,
line
)
{
var
mode
=
state
.
innerActive
?
state
.
innerActive
.
mode
:
outer
;
if
(
!
mode
.
indent
)
return
CodeMirror
.
Pass
;
return
mode
.
indent
(
state
.
innerActive
?
state
.
inner
:
state
.
outer
,
textAfter
,
line
);
},
blankLine
:
function
(
state
)
{
var
mode
=
state
.
innerActive
?
state
.
innerActive
.
mode
:
outer
;
if
(
mode
.
blankLine
)
{
mode
.
blankLine
(
state
.
innerActive
?
state
.
inner
:
state
.
outer
);
}
if
(
!
state
.
innerActive
)
{
for
(
var
i
=
0
;
i
<
others
.
length
;
++
i
)
{
var
other
=
others
[
i
];
if
(
other
.
open
===
"
\n
"
)
{
state
.
innerActive
=
other
;
state
.
inner
=
CodeMirror
.
startState
(
other
.
mode
,
mode
.
indent
?
mode
.
indent
(
state
.
outer
,
""
,
""
)
:
0
);
}
}
}
else
if
(
state
.
innerActive
.
close
===
"
\n
"
)
{
state
.
innerActive
=
state
.
inner
=
null
;
}
},
electricChars
:
outer
.
electricChars
,
innerMode
:
function
(
state
)
{
return
state
.
inner
?
{
state
:
state
.
inner
,
mode
:
state
.
innerActive
.
mode
}
:
{
state
:
state
.
outer
,
mode
:
outer
};
}
};
};
});
src/main/webapp/static/plugins/codemirror/5.48.4/addon/mode/multiplex_test.js
0 → 100644
View file @
53f587bc
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(
function
()
{
CodeMirror
.
defineMode
(
"
markdown_with_stex
"
,
function
(){
var
inner
=
CodeMirror
.
getMode
({},
"
stex
"
);
var
outer
=
CodeMirror
.
getMode
({},
"
markdown
"
);
var
innerOptions
=
{
open
:
'
$
'
,
close
:
'
$
'
,
mode
:
inner
,
delimStyle
:
'
delim
'
,
innerStyle
:
'
inner
'
};
return
CodeMirror
.
multiplexingMode
(
outer
,
innerOptions
);
});
var
mode
=
CodeMirror
.
getMode
({},
"
markdown_with_stex
"
);
function
MT
(
name
)
{
test
.
mode
(
name
,
mode
,
Array
.
prototype
.
slice
.
call
(
arguments
,
1
),
'
multiplexing
'
);
}
MT
(
"
stexInsideMarkdown
"
,
"
[strong **Equation:**] [delim&delim-open $][inner&tag
\\
pi][delim&delim-close $]
"
);
})();
src/main/webapp/static/plugins/codemirror/5.48.4/addon/mode/overlay.js
0 → 100644
View file @
53f587bc
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
// Utility function that allows modes to be combined. The mode given
// as the base argument takes care of most of the normal mode
// functionality, but a second (typically simple) mode is used, which
// can override the style of text. Both modes get to parse all of the
// text, but when both assign a non-null style to a piece of code, the
// overlay wins, unless the combine argument was true and not overridden,
// or state.overlay.combineTokens was true, in which case the styles are
// combined.
(
function
(
mod
)
{
if
(
typeof
exports
==
"
object
"
&&
typeof
module
==
"
object
"
)
// CommonJS
mod
(
require
(
"
../../lib/codemirror
"
));
else
if
(
typeof
define
==
"
function
"
&&
define
.
amd
)
// AMD
define
([
"
../../lib/codemirror
"
],
mod
);
else
// Plain browser env
mod
(
CodeMirror
);
})(
function
(
CodeMirror
)
{
"
use strict
"
;
CodeMirror
.
overlayMode
=
function
(
base
,
overlay
,
combine
)
{
return
{
startState
:
function
()
{
return
{
base
:
CodeMirror
.
startState
(
base
),
overlay
:
CodeMirror
.
startState
(
overlay
),
basePos
:
0
,
baseCur
:
null
,
overlayPos
:
0
,
overlayCur
:
null
,
streamSeen
:
null
};
},
copyState
:
function
(
state
)
{
return
{
base
:
CodeMirror
.
copyState
(
base
,
state
.
base
),
overlay
:
CodeMirror
.
copyState
(
overlay
,
state
.
overlay
),
basePos
:
state
.
basePos
,
baseCur
:
null
,
overlayPos
:
state
.
overlayPos
,
overlayCur
:
null
};
},
token
:
function
(
stream
,
state
)
{
if
(
stream
!=
state
.
streamSeen
||
Math
.
min
(
state
.
basePos
,
state
.
overlayPos
)
<
stream
.
start
)
{
state
.
streamSeen
=
stream
;
state
.
basePos
=
state
.
overlayPos
=
stream
.
start
;
}
if
(
stream
.
start
==
state
.
basePos
)
{
state
.
baseCur
=
base
.
token
(
stream
,
state
.
base
);
state
.
basePos
=
stream
.
pos
;
}
if
(
stream
.
start
==
state
.
overlayPos
)
{
stream
.
pos
=
stream
.
start
;
state
.
overlayCur
=
overlay
.
token
(
stream
,
state
.
overlay
);
state
.
overlayPos
=
stream
.
pos
;
}
stream
.
pos
=
Math
.
min
(
state
.
basePos
,
state
.
overlayPos
);
// state.overlay.combineTokens always takes precedence over combine,
// unless set to null
if
(
state
.
overlayCur
==
null
)
return
state
.
baseCur
;
else
if
(
state
.
baseCur
!=
null
&&
state
.
overlay
.
combineTokens
||
combine
&&
state
.
overlay
.
combineTokens
==
null
)
return
state
.
baseCur
+
"
"
+
state
.
overlayCur
;
else
return
state
.
overlayCur
;
},
indent
:
base
.
indent
&&
function
(
state
,
textAfter
,
line
)
{
return
base
.
indent
(
state
.
base
,
textAfter
,
line
);
},
electricChars
:
base
.
electricChars
,
innerMode
:
function
(
state
)
{
return
{
state
:
state
.
base
,
mode
:
base
};
},
blankLine
:
function
(
state
)
{
var
baseToken
,
overlayToken
;
if
(
base
.
blankLine
)
baseToken
=
base
.
blankLine
(
state
.
base
);
if
(
overlay
.
blankLine
)
overlayToken
=
overlay
.
blankLine
(
state
.
overlay
);
return
overlayToken
==
null
?
baseToken
:
(
combine
&&
baseToken
!=
null
?
baseToken
+
"
"
+
overlayToken
:
overlayToken
);
}
};
};
});
src/main/webapp/static/plugins/codemirror/5.48.4/addon/mode/simple.js
0 → 100644
View file @
53f587bc
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(
function
(
mod
)
{
if
(
typeof
exports
==
"
object
"
&&
typeof
module
==
"
object
"
)
// CommonJS
mod
(
require
(
"
../../lib/codemirror
"
));
else
if
(
typeof
define
==
"
function
"
&&
define
.
amd
)
// AMD
define
([
"
../../lib/codemirror
"
],
mod
);
else
// Plain browser env
mod
(
CodeMirror
);
})(
function
(
CodeMirror
)
{
"
use strict
"
;
CodeMirror
.
defineSimpleMode
=
function
(
name
,
states
)
{
CodeMirror
.
defineMode
(
name
,
function
(
config
)
{
return
CodeMirror
.
simpleMode
(
config
,
states
);
});
};
CodeMirror
.
simpleMode
=
function
(
config
,
states
)
{
ensureState
(
states
,
"
start
"
);
var
states_
=
{},
meta
=
states
.
meta
||
{},
hasIndentation
=
false
;
for
(
var
state
in
states
)
if
(
state
!=
meta
&&
states
.
hasOwnProperty
(
state
))
{
var
list
=
states_
[
state
]
=
[],
orig
=
states
[
state
];
for
(
var
i
=
0
;
i
<
orig
.
length
;
i
++
)
{
var
data
=
orig
[
i
];
list
.
push
(
new
Rule
(
data
,
states
));
if
(
data
.
indent
||
data
.
dedent
)
hasIndentation
=
true
;
}
}
var
mode
=
{
startState
:
function
()
{
return
{
state
:
"
start
"
,
pending
:
null
,
local
:
null
,
localState
:
null
,
indent
:
hasIndentation
?
[]
:
null
};
},
copyState
:
function
(
state
)
{
var
s
=
{
state
:
state
.
state
,
pending
:
state
.
pending
,
local
:
state
.
local
,
localState
:
null
,
indent
:
state
.
indent
&&
state
.
indent
.
slice
(
0
)};
if
(
state
.
localState
)
s
.
localState
=
CodeMirror
.
copyState
(
state
.
local
.
mode
,
state
.
localState
);
if
(
state
.
stack
)
s
.
stack
=
state
.
stack
.
slice
(
0
);
for
(
var
pers
=
state
.
persistentStates
;
pers
;
pers
=
pers
.
next
)
s
.
persistentStates
=
{
mode
:
pers
.
mode
,
spec
:
pers
.
spec
,
state
:
pers
.
state
==
state
.
localState
?
s
.
localState
:
CodeMirror
.
copyState
(
pers
.
mode
,
pers
.
state
),
next
:
s
.
persistentStates
};
return
s
;
},
token
:
tokenFunction
(
states_
,
config
),
innerMode
:
function
(
state
)
{
return
state
.
local
&&
{
mode
:
state
.
local
.
mode
,
state
:
state
.
localState
};
},
indent
:
indentFunction
(
states_
,
meta
)
};
if
(
meta
)
for
(
var
prop
in
meta
)
if
(
meta
.
hasOwnProperty
(
prop
))
mode
[
prop
]
=
meta
[
prop
];
return
mode
;
};
function
ensureState
(
states
,
name
)
{
if
(
!
states
.
hasOwnProperty
(
name
))
throw
new
Error
(
"
Undefined state
"
+
name
+
"
in simple mode
"
);
}
function
toRegex
(
val
,
caret
)
{
if
(
!
val
)
return
/
(?:)
/
;
var
flags
=
""
;
if
(
val
instanceof
RegExp
)
{
if
(
val
.
ignoreCase
)
flags
=
"
i
"
;
val
=
val
.
source
;
}
else
{
val
=
String
(
val
);
}
return
new
RegExp
((
caret
===
false
?
""
:
"
^
"
)
+
"
(?:
"
+
val
+
"
)
"
,
flags
);
}
function
asToken
(
val
)
{
if
(
!
val
)
return
null
;
if
(
val
.
apply
)
return
val
if
(
typeof
val
==
"
string
"
)
return
val
.
replace
(
/
\.
/g
,
"
"
);
var
result
=
[];
for
(
var
i
=
0
;
i
<
val
.
length
;
i
++
)
result
.
push
(
val
[
i
]
&&
val
[
i
].
replace
(
/
\.
/g
,
"
"
));
return
result
;
}
function
Rule
(
data
,
states
)
{
if
(
data
.
next
||
data
.
push
)
ensureState
(
states
,
data
.
next
||
data
.
push
);
this
.
regex
=
toRegex
(
data
.
regex
);
this
.
token
=
asToken
(
data
.
token
);
this
.
data
=
data
;
}
function
tokenFunction
(
states
,
config
)
{
return
function
(
stream
,
state
)
{
if
(
state
.
pending
)
{
var
pend
=
state
.
pending
.
shift
();
if
(
state
.
pending
.
length
==
0
)
state
.
pending
=
null
;
stream
.
pos
+=
pend
.
text
.
length
;
return
pend
.
token
;
}
if
(
state
.
local
)
{
if
(
state
.
local
.
end
&&
stream
.
match
(
state
.
local
.
end
))
{
var
tok
=
state
.
local
.
endToken
||
null
;
state
.
local
=
state
.
localState
=
null
;
return
tok
;
}
else
{
var
tok
=
state
.
local
.
mode
.
token
(
stream
,
state
.
localState
),
m
;
if
(
state
.
local
.
endScan
&&
(
m
=
state
.
local
.
endScan
.
exec
(
stream
.
current
())))
stream
.
pos
=
stream
.
start
+
m
.
index
;
return
tok
;
}
}
var
curState
=
states
[
state
.
state
];
for
(
var
i
=
0
;
i
<
curState
.
length
;
i
++
)
{
var
rule
=
curState
[
i
];
var
matches
=
(
!
rule
.
data
.
sol
||
stream
.
sol
())
&&
stream
.
match
(
rule
.
regex
);
if
(
matches
)
{
if
(
rule
.
data
.
next
)
{
state
.
state
=
rule
.
data
.
next
;
}
else
if
(
rule
.
data
.
push
)
{
(
state
.
stack
||
(
state
.
stack
=
[])).
push
(
state
.
state
);
state
.
state
=
rule
.
data
.
push
;
}
else
if
(
rule
.
data
.
pop
&&
state
.
stack
&&
state
.
stack
.
length
)
{
state
.
state
=
state
.
stack
.
pop
();
}
if
(
rule
.
data
.
mode
)
enterLocalMode
(
config
,
state
,
rule
.
data
.
mode
,
rule
.
token
);
if
(
rule
.
data
.
indent
)
state
.
indent
.
push
(
stream
.
indentation
()
+
config
.
indentUnit
);
if
(
rule
.
data
.
dedent
)
state
.
indent
.
pop
();
var
token
=
rule
.
token
if
(
token
&&
token
.
apply
)
token
=
token
(
matches
)
if
(
matches
.
length
>
2
&&
rule
.
token
&&
typeof
rule
.
token
!=
"
string
"
)
{
state
.
pending
=
[];
for
(
var
j
=
2
;
j
<
matches
.
length
;
j
++
)
if
(
matches
[
j
])
state
.
pending
.
push
({
text
:
matches
[
j
],
token
:
rule
.
token
[
j
-
1
]});
stream
.
backUp
(
matches
[
0
].
length
-
(
matches
[
1
]
?
matches
[
1
].
length
:
0
));
return
token
[
0
];
}
else
if
(
token
&&
token
.
join
)
{
return
token
[
0
];
}
else
{
return
token
;
}
}
}
stream
.
next
();
return
null
;
};
}
function
cmp
(
a
,
b
)
{
if
(
a
===
b
)
return
true
;
if
(
!
a
||
typeof
a
!=
"
object
"
||
!
b
||
typeof
b
!=
"
object
"
)
return
false
;
var
props
=
0
;
for
(
var
prop
in
a
)
if
(
a
.
hasOwnProperty
(
prop
))
{
if
(
!
b
.
hasOwnProperty
(
prop
)
||
!
cmp
(
a
[
prop
],
b
[
prop
]))
return
false
;
props
++
;
}
for
(
var
prop
in
b
)
if
(
b
.
hasOwnProperty
(
prop
))
props
--
;
return
props
==
0
;
}
function
enterLocalMode
(
config
,
state
,
spec
,
token
)
{
var
pers
;
if
(
spec
.
persistent
)
for
(
var
p
=
state
.
persistentStates
;
p
&&
!
pers
;
p
=
p
.
next
)
if
(
spec
.
spec
?
cmp
(
spec
.
spec
,
p
.
spec
)
:
spec
.
mode
==
p
.
mode
)
pers
=
p
;
var
mode
=
pers
?
pers
.
mode
:
spec
.
mode
||
CodeMirror
.
getMode
(
config
,
spec
.
spec
);
var
lState
=
pers
?
pers
.
state
:
CodeMirror
.
startState
(
mode
);
if
(
spec
.
persistent
&&
!
pers
)
state
.
persistentStates
=
{
mode
:
mode
,
spec
:
spec
.
spec
,
state
:
lState
,
next
:
state
.
persistentStates
};
state
.
localState
=
lState
;
state
.
local
=
{
mode
:
mode
,
end
:
spec
.
end
&&
toRegex
(
spec
.
end
),
endScan
:
spec
.
end
&&
spec
.
forceEnd
!==
false
&&
toRegex
(
spec
.
end
,
false
),
endToken
:
token
&&
token
.
join
?
token
[
token
.
length
-
1
]
:
token
};
}
function
indexOf
(
val
,
arr
)
{
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
if
(
arr
[
i
]
===
val
)
return
true
;
}
function
indentFunction
(
states
,
meta
)
{
return
function
(
state
,
textAfter
,
line
)
{
if
(
state
.
local
&&
state
.
local
.
mode
.
indent
)
return
state
.
local
.
mode
.
indent
(
state
.
localState
,
textAfter
,
line
);
if
(
state
.
indent
==
null
||
state
.
local
||
meta
.
dontIndentStates
&&
indexOf
(
state
.
state
,
meta
.
dontIndentStates
)
>
-
1
)
return
CodeMirror
.
Pass
;
var
pos
=
state
.
indent
.
length
-
1
,
rules
=
states
[
state
.
state
];
scan
:
for
(;;)
{
for
(
var
i
=
0
;
i
<
rules
.
length
;
i
++
)
{
var
rule
=
rules
[
i
];
if
(
rule
.
data
.
dedent
&&
rule
.
data
.
dedentIfLineStart
!==
false
)
{
var
m
=
rule
.
regex
.
exec
(
textAfter
);
if
(
m
&&
m
[
0
])
{
pos
--
;
if
(
rule
.
next
||
rule
.
push
)
rules
=
states
[
rule
.
next
||
rule
.
push
];
textAfter
=
textAfter
.
slice
(
m
[
0
].
length
);
continue
scan
;
}
}
}
break
;
}
return
pos
<
0
?
0
:
state
.
indent
[
pos
];
};
}
});
src/main/webapp/static/plugins/codemirror/5.48.4/addon/runmode/colorize.js
0 → 100644
View file @
53f587bc
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(
function
(
mod
)
{
if
(
typeof
exports
==
"
object
"
&&
typeof
module
==
"
object
"
)
// CommonJS
mod
(
require
(
"
../../lib/codemirror
"
),
require
(
"
./runmode
"
));
else
if
(
typeof
define
==
"
function
"
&&
define
.
amd
)
// AMD
define
([
"
../../lib/codemirror
"
,
"
./runmode
"
],
mod
);
else
// Plain browser env
mod
(
CodeMirror
);
})(
function
(
CodeMirror
)
{
"
use strict
"
;
var
isBlock
=
/^
(
p|li|div|h
\\
d|pre|blockquote|td
)
$/
;
function
textContent
(
node
,
out
)
{
if
(
node
.
nodeType
==
3
)
return
out
.
push
(
node
.
nodeValue
);
for
(
var
ch
=
node
.
firstChild
;
ch
;
ch
=
ch
.
nextSibling
)
{
textContent
(
ch
,
out
);
if
(
isBlock
.
test
(
node
.
nodeType
))
out
.
push
(
"
\n
"
);
}
}
CodeMirror
.
colorize
=
function
(
collection
,
defaultMode
)
{
if
(
!
collection
)
collection
=
document
.
body
.
getElementsByTagName
(
"
pre
"
);
for
(
var
i
=
0
;
i
<
collection
.
length
;
++
i
)
{
var
node
=
collection
[
i
];
var
mode
=
node
.
getAttribute
(
"
data-lang
"
)
||
defaultMode
;
if
(
!
mode
)
continue
;
var
text
=
[];
textContent
(
node
,
text
);
node
.
innerHTML
=
""
;
CodeMirror
.
runMode
(
text
.
join
(
""
),
mode
,
node
);
node
.
className
+=
"
cm-s-default
"
;
}
};
});
src/main/webapp/static/plugins/codemirror/5.48.4/addon/runmode/runmode-standalone.js
0 → 100644
View file @
53f587bc
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
window
.
CodeMirror
=
{};
(
function
()
{
"
use strict
"
;
function
splitLines
(
string
){
return
string
.
split
(
/
\r?\n
|
\r
/
);
};
function
StringStream
(
string
)
{
this
.
pos
=
this
.
start
=
0
;
this
.
string
=
string
;
this
.
lineStart
=
0
;
}
StringStream
.
prototype
=
{
eol
:
function
()
{
return
this
.
pos
>=
this
.
string
.
length
;},
sol
:
function
()
{
return
this
.
pos
==
0
;},
peek
:
function
()
{
return
this
.
string
.
charAt
(
this
.
pos
)
||
null
;},
next
:
function
()
{
if
(
this
.
pos
<
this
.
string
.
length
)
return
this
.
string
.
charAt
(
this
.
pos
++
);
},
eat
:
function
(
match
)
{
var
ch
=
this
.
string
.
charAt
(
this
.
pos
);
if
(
typeof
match
==
"
string
"
)
var
ok
=
ch
==
match
;
else
var
ok
=
ch
&&
(
match
.
test
?
match
.
test
(
ch
)
:
match
(
ch
));
if
(
ok
)
{
++
this
.
pos
;
return
ch
;}
},
eatWhile
:
function
(
match
)
{
var
start
=
this
.
pos
;
while
(
this
.
eat
(
match
)){}
return
this
.
pos
>
start
;
},
eatSpace
:
function
()
{
var
start
=
this
.
pos
;
while
(
/
[\s\u
00a0
]
/
.
test
(
this
.
string
.
charAt
(
this
.
pos
)))
++
this
.
pos
;
return
this
.
pos
>
start
;
},
skipToEnd
:
function
()
{
this
.
pos
=
this
.
string
.
length
;},
skipTo
:
function
(
ch
)
{
var
found
=
this
.
string
.
indexOf
(
ch
,
this
.
pos
);
if
(
found
>
-
1
)
{
this
.
pos
=
found
;
return
true
;}
},
backUp
:
function
(
n
)
{
this
.
pos
-=
n
;},
column
:
function
()
{
return
this
.
start
-
this
.
lineStart
;},
indentation
:
function
()
{
return
0
;},
match
:
function
(
pattern
,
consume
,
caseInsensitive
)
{
if
(
typeof
pattern
==
"
string
"
)
{
var
cased
=
function
(
str
)
{
return
caseInsensitive
?
str
.
toLowerCase
()
:
str
;};
var
substr
=
this
.
string
.
substr
(
this
.
pos
,
pattern
.
length
);
if
(
cased
(
substr
)
==
cased
(
pattern
))
{
if
(
consume
!==
false
)
this
.
pos
+=
pattern
.
length
;
return
true
;
}
}
else
{
var
match
=
this
.
string
.
slice
(
this
.
pos
).
match
(
pattern
);
if
(
match
&&
match
.
index
>
0
)
return
null
;
if
(
match
&&
consume
!==
false
)
this
.
pos
+=
match
[
0
].
length
;
return
match
;
}
},
current
:
function
(){
return
this
.
string
.
slice
(
this
.
start
,
this
.
pos
);},
hideFirstChars
:
function
(
n
,
inner
)
{
this
.
lineStart
+=
n
;
try
{
return
inner
();
}
finally
{
this
.
lineStart
-=
n
;
}
},
lookAhead
:
function
()
{
return
null
}
};
CodeMirror
.
StringStream
=
StringStream
;
CodeMirror
.
startState
=
function
(
mode
,
a1
,
a2
)
{
return
mode
.
startState
?
mode
.
startState
(
a1
,
a2
)
:
true
;
};
var
modes
=
CodeMirror
.
modes
=
{},
mimeModes
=
CodeMirror
.
mimeModes
=
{};
CodeMirror
.
defineMode
=
function
(
name
,
mode
)
{
if
(
arguments
.
length
>
2
)
mode
.
dependencies
=
Array
.
prototype
.
slice
.
call
(
arguments
,
2
);
modes
[
name
]
=
mode
;
};
CodeMirror
.
defineMIME
=
function
(
mime
,
spec
)
{
mimeModes
[
mime
]
=
spec
;
};
CodeMirror
.
resolveMode
=
function
(
spec
)
{
if
(
typeof
spec
==
"
string
"
&&
mimeModes
.
hasOwnProperty
(
spec
))
{
spec
=
mimeModes
[
spec
];
}
else
if
(
spec
&&
typeof
spec
.
name
==
"
string
"
&&
mimeModes
.
hasOwnProperty
(
spec
.
name
))
{
spec
=
mimeModes
[
spec
.
name
];
}
if
(
typeof
spec
==
"
string
"
)
return
{
name
:
spec
};
else
return
spec
||
{
name
:
"
null
"
};
};
CodeMirror
.
getMode
=
function
(
options
,
spec
)
{
spec
=
CodeMirror
.
resolveMode
(
spec
);
var
mfactory
=
modes
[
spec
.
name
];
if
(
!
mfactory
)
throw
new
Error
(
"
Unknown mode:
"
+
spec
);
return
mfactory
(
options
,
spec
);
};
CodeMirror
.
registerHelper
=
CodeMirror
.
registerGlobalHelper
=
Math
.
min
;
CodeMirror
.
defineMode
(
"
null
"
,
function
()
{
return
{
token
:
function
(
stream
)
{
stream
.
skipToEnd
();}};
});
CodeMirror
.
defineMIME
(
"
text/plain
"
,
"
null
"
);
CodeMirror
.
runMode
=
function
(
string
,
modespec
,
callback
,
options
)
{
var
mode
=
CodeMirror
.
getMode
({
indentUnit
:
2
},
modespec
);
if
(
callback
.
nodeType
==
1
)
{
var
tabSize
=
(
options
&&
options
.
tabSize
)
||
4
;
var
node
=
callback
,
col
=
0
;
node
.
innerHTML
=
""
;
callback
=
function
(
text
,
style
)
{
if
(
text
==
"
\n
"
)
{
node
.
appendChild
(
document
.
createElement
(
"
br
"
));
col
=
0
;
return
;
}
var
content
=
""
;
// replace tabs
for
(
var
pos
=
0
;
;)
{
var
idx
=
text
.
indexOf
(
"
\t
"
,
pos
);
if
(
idx
==
-
1
)
{
content
+=
text
.
slice
(
pos
);
col
+=
text
.
length
-
pos
;
break
;
}
else
{
col
+=
idx
-
pos
;
content
+=
text
.
slice
(
pos
,
idx
);
var
size
=
tabSize
-
col
%
tabSize
;
col
+=
size
;
for
(
var
i
=
0
;
i
<
size
;
++
i
)
content
+=
"
"
;
pos
=
idx
+
1
;
}
}
if
(
style
)
{
var
sp
=
node
.
appendChild
(
document
.
createElement
(
"
span
"
));
sp
.
className
=
"
cm-
"
+
style
.
replace
(
/ +/g
,
"
cm-
"
);
sp
.
appendChild
(
document
.
createTextNode
(
content
));
}
else
{
node
.
appendChild
(
document
.
createTextNode
(
content
));
}
};
}
var
lines
=
splitLines
(
string
),
state
=
(
options
&&
options
.
state
)
||
CodeMirror
.
startState
(
mode
);
for
(
var
i
=
0
,
e
=
lines
.
length
;
i
<
e
;
++
i
)
{
if
(
i
)
callback
(
"
\n
"
);
var
stream
=
new
CodeMirror
.
StringStream
(
lines
[
i
]);
if
(
!
stream
.
string
&&
mode
.
blankLine
)
mode
.
blankLine
(
state
);
while
(
!
stream
.
eol
())
{
var
style
=
mode
.
token
(
stream
,
state
);
callback
(
stream
.
current
(),
style
,
i
,
stream
.
start
,
state
);
stream
.
start
=
stream
.
pos
;
}
}
};
})();
src/main/webapp/static/plugins/codemirror/5.48.4/addon/runmode/runmode.js
0 → 100644
View file @
53f587bc
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(
function
(
mod
)
{
if
(
typeof
exports
==
"
object
"
&&
typeof
module
==
"
object
"
)
// CommonJS
mod
(
require
(
"
../../lib/codemirror
"
));
else
if
(
typeof
define
==
"
function
"
&&
define
.
amd
)
// AMD
define
([
"
../../lib/codemirror
"
],
mod
);
else
// Plain browser env
mod
(
CodeMirror
);
})(
function
(
CodeMirror
)
{
"
use strict
"
;
CodeMirror
.
runMode
=
function
(
string
,
modespec
,
callback
,
options
)
{
var
mode
=
CodeMirror
.
getMode
(
CodeMirror
.
defaults
,
modespec
);
var
ie
=
/MSIE
\d
/
.
test
(
navigator
.
userAgent
);
var
ie_lt9
=
ie
&&
(
document
.
documentMode
==
null
||
document
.
documentMode
<
9
);
if
(
callback
.
appendChild
)
{
var
tabSize
=
(
options
&&
options
.
tabSize
)
||
CodeMirror
.
defaults
.
tabSize
;
var
node
=
callback
,
col
=
0
;
node
.
innerHTML
=
""
;
callback
=
function
(
text
,
style
)
{
if
(
text
==
"
\n
"
)
{
// Emitting LF or CRLF on IE8 or earlier results in an incorrect display.
// Emitting a carriage return makes everything ok.
node
.
appendChild
(
document
.
createTextNode
(
ie_lt9
?
'
\r
'
:
text
));
col
=
0
;
return
;
}
var
content
=
""
;
// replace tabs
for
(
var
pos
=
0
;;)
{
var
idx
=
text
.
indexOf
(
"
\t
"
,
pos
);
if
(
idx
==
-
1
)
{
content
+=
text
.
slice
(
pos
);
col
+=
text
.
length
-
pos
;
break
;
}
else
{
col
+=
idx
-
pos
;
content
+=
text
.
slice
(
pos
,
idx
);
var
size
=
tabSize
-
col
%
tabSize
;
col
+=
size
;
for
(
var
i
=
0
;
i
<
size
;
++
i
)
content
+=
"
"
;
pos
=
idx
+
1
;
}
}
if
(
style
)
{
var
sp
=
node
.
appendChild
(
document
.
createElement
(
"
span
"
));
sp
.
className
=
"
cm-
"
+
style
.
replace
(
/ +/g
,
"
cm-
"
);
sp
.
appendChild
(
document
.
createTextNode
(
content
));
}
else
{
node
.
appendChild
(
document
.
createTextNode
(
content
));
}
};
}
var
lines
=
CodeMirror
.
splitLines
(
string
),
state
=
(
options
&&
options
.
state
)
||
CodeMirror
.
startState
(
mode
);
for
(
var
i
=
0
,
e
=
lines
.
length
;
i
<
e
;
++
i
)
{
if
(
i
)
callback
(
"
\n
"
);
var
stream
=
new
CodeMirror
.
StringStream
(
lines
[
i
]);
if
(
!
stream
.
string
&&
mode
.
blankLine
)
mode
.
blankLine
(
state
);
while
(
!
stream
.
eol
())
{
var
style
=
mode
.
token
(
stream
,
state
);
callback
(
stream
.
current
(),
style
,
i
,
stream
.
start
,
state
);
stream
.
start
=
stream
.
pos
;
}
}
};
});
src/main/webapp/static/plugins/codemirror/5.48.4/addon/runmode/runmode.node.js
0 → 100644
View file @
53f587bc
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
/* Just enough of CodeMirror to run runMode under node.js */
function
splitLines
(
string
){
return
string
.
split
(
/
\r\n?
|
\n
/
);};
// Counts the column offset in a string, taking tabs into account.
// Used mostly to find indentation.
var
countColumn
=
exports
.
countColumn
=
function
(
string
,
end
,
tabSize
,
startIndex
,
startValue
)
{
if
(
end
==
null
)
{
end
=
string
.
search
(
/
[^\s\u
00a0
]
/
);
if
(
end
==
-
1
)
end
=
string
.
length
;
}
for
(
var
i
=
startIndex
||
0
,
n
=
startValue
||
0
;;)
{
var
nextTab
=
string
.
indexOf
(
"
\t
"
,
i
);
if
(
nextTab
<
0
||
nextTab
>=
end
)
return
n
+
(
end
-
i
);
n
+=
nextTab
-
i
;
n
+=
tabSize
-
(
n
%
tabSize
);
i
=
nextTab
+
1
;
}
};
function
StringStream
(
string
,
tabSize
,
context
)
{
this
.
pos
=
this
.
start
=
0
;
this
.
string
=
string
;
this
.
tabSize
=
tabSize
||
8
;
this
.
lastColumnPos
=
this
.
lastColumnValue
=
0
;
this
.
lineStart
=
0
;
this
.
context
=
context
};
StringStream
.
prototype
=
{
eol
:
function
()
{
return
this
.
pos
>=
this
.
string
.
length
;},
sol
:
function
()
{
return
this
.
pos
==
this
.
lineStart
;},
peek
:
function
()
{
return
this
.
string
.
charAt
(
this
.
pos
)
||
undefined
;},
next
:
function
()
{
if
(
this
.
pos
<
this
.
string
.
length
)
return
this
.
string
.
charAt
(
this
.
pos
++
);
},
eat
:
function
(
match
)
{
var
ch
=
this
.
string
.
charAt
(
this
.
pos
);
if
(
typeof
match
==
"
string
"
)
var
ok
=
ch
==
match
;
else
var
ok
=
ch
&&
(
match
.
test
?
match
.
test
(
ch
)
:
match
(
ch
));
if
(
ok
)
{
++
this
.
pos
;
return
ch
;}
},
eatWhile
:
function
(
match
)
{
var
start
=
this
.
pos
;
while
(
this
.
eat
(
match
)){}
return
this
.
pos
>
start
;
},
eatSpace
:
function
()
{
var
start
=
this
.
pos
;
while
(
/
[\s\u
00a0
]
/
.
test
(
this
.
string
.
charAt
(
this
.
pos
)))
++
this
.
pos
;
return
this
.
pos
>
start
;
},
skipToEnd
:
function
()
{
this
.
pos
=
this
.
string
.
length
;},
skipTo
:
function
(
ch
)
{
var
found
=
this
.
string
.
indexOf
(
ch
,
this
.
pos
);
if
(
found
>
-
1
)
{
this
.
pos
=
found
;
return
true
;}
},
backUp
:
function
(
n
)
{
this
.
pos
-=
n
;},
column
:
function
()
{
if
(
this
.
lastColumnPos
<
this
.
start
)
{
this
.
lastColumnValue
=
countColumn
(
this
.
string
,
this
.
start
,
this
.
tabSize
,
this
.
lastColumnPos
,
this
.
lastColumnValue
);
this
.
lastColumnPos
=
this
.
start
;
}
return
this
.
lastColumnValue
-
(
this
.
lineStart
?
countColumn
(
this
.
string
,
this
.
lineStart
,
this
.
tabSize
)
:
0
);
},
indentation
:
function
()
{
return
countColumn
(
this
.
string
,
null
,
this
.
tabSize
)
-
(
this
.
lineStart
?
countColumn
(
this
.
string
,
this
.
lineStart
,
this
.
tabSize
)
:
0
);
},
match
:
function
(
pattern
,
consume
,
caseInsensitive
)
{
if
(
typeof
pattern
==
"
string
"
)
{
var
cased
=
function
(
str
)
{
return
caseInsensitive
?
str
.
toLowerCase
()
:
str
;};
var
substr
=
this
.
string
.
substr
(
this
.
pos
,
pattern
.
length
);
if
(
cased
(
substr
)
==
cased
(
pattern
))
{
if
(
consume
!==
false
)
this
.
pos
+=
pattern
.
length
;
return
true
;
}
}
else
{
var
match
=
this
.
string
.
slice
(
this
.
pos
).
match
(
pattern
);
if
(
match
&&
match
.
index
>
0
)
return
null
;
if
(
match
&&
consume
!==
false
)
this
.
pos
+=
match
[
0
].
length
;
return
match
;
}
},
current
:
function
(){
return
this
.
string
.
slice
(
this
.
start
,
this
.
pos
);},
hideFirstChars
:
function
(
n
,
inner
)
{
this
.
lineStart
+=
n
;
try
{
return
inner
();
}
finally
{
this
.
lineStart
-=
n
;
}
},
lookAhead
:
function
(
n
)
{
var
line
=
this
.
context
.
line
+
n
return
line
>=
this
.
context
.
lines
.
length
?
null
:
this
.
context
.
lines
[
line
]
}
};
exports
.
StringStream
=
StringStream
;
exports
.
startState
=
function
(
mode
,
a1
,
a2
)
{
return
mode
.
startState
?
mode
.
startState
(
a1
,
a2
)
:
true
;
};
var
modes
=
exports
.
modes
=
{},
mimeModes
=
exports
.
mimeModes
=
{};
exports
.
defineMode
=
function
(
name
,
mode
)
{
if
(
arguments
.
length
>
2
)
mode
.
dependencies
=
Array
.
prototype
.
slice
.
call
(
arguments
,
2
);
modes
[
name
]
=
mode
;
};
exports
.
defineMIME
=
function
(
mime
,
spec
)
{
mimeModes
[
mime
]
=
spec
;
};
exports
.
defineMode
(
"
null
"
,
function
()
{
return
{
token
:
function
(
stream
)
{
stream
.
skipToEnd
();}};
});
exports
.
defineMIME
(
"
text/plain
"
,
"
null
"
);
exports
.
resolveMode
=
function
(
spec
)
{
if
(
typeof
spec
==
"
string
"
&&
mimeModes
.
hasOwnProperty
(
spec
))
{
spec
=
mimeModes
[
spec
];
}
else
if
(
spec
&&
typeof
spec
.
name
==
"
string
"
&&
mimeModes
.
hasOwnProperty
(
spec
.
name
))
{
spec
=
mimeModes
[
spec
.
name
];
}
if
(
typeof
spec
==
"
string
"
)
return
{
name
:
spec
};
else
return
spec
||
{
name
:
"
null
"
};
};
function
copyObj
(
obj
,
target
,
overwrite
)
{
if
(
!
target
)
target
=
{};
for
(
var
prop
in
obj
)
if
(
obj
.
hasOwnProperty
(
prop
)
&&
(
overwrite
!==
false
||
!
target
.
hasOwnProperty
(
prop
)))
target
[
prop
]
=
obj
[
prop
];
return
target
;
}
// This can be used to attach properties to mode objects from
// outside the actual mode definition.
var
modeExtensions
=
exports
.
modeExtensions
=
{};
exports
.
extendMode
=
function
(
mode
,
properties
)
{
var
exts
=
modeExtensions
.
hasOwnProperty
(
mode
)
?
modeExtensions
[
mode
]
:
(
modeExtensions
[
mode
]
=
{});
copyObj
(
properties
,
exts
);
};
exports
.
getMode
=
function
(
options
,
spec
)
{
var
spec
=
exports
.
resolveMode
(
spec
);
var
mfactory
=
modes
[
spec
.
name
];
if
(
!
mfactory
)
return
exports
.
getMode
(
options
,
"
text/plain
"
);
var
modeObj
=
mfactory
(
options
,
spec
);
if
(
modeExtensions
.
hasOwnProperty
(
spec
.
name
))
{
var
exts
=
modeExtensions
[
spec
.
name
];
for
(
var
prop
in
exts
)
{
if
(
!
exts
.
hasOwnProperty
(
prop
))
continue
;
if
(
modeObj
.
hasOwnProperty
(
prop
))
modeObj
[
"
_
"
+
prop
]
=
modeObj
[
prop
];
modeObj
[
prop
]
=
exts
[
prop
];
}
}
modeObj
.
name
=
spec
.
name
;
if
(
spec
.
helperType
)
modeObj
.
helperType
=
spec
.
helperType
;
if
(
spec
.
modeProps
)
for
(
var
prop
in
spec
.
modeProps
)
modeObj
[
prop
]
=
spec
.
modeProps
[
prop
];
return
modeObj
;
};
exports
.
innerMode
=
function
(
mode
,
state
)
{
var
info
;
while
(
mode
.
innerMode
)
{
info
=
mode
.
innerMode
(
state
);
if
(
!
info
||
info
.
mode
==
mode
)
break
;
state
=
info
.
state
;
mode
=
info
.
mode
;
}
return
info
||
{
mode
:
mode
,
state
:
state
};
}
exports
.
registerHelper
=
exports
.
registerGlobalHelper
=
Math
.
min
;
exports
.
runMode
=
function
(
string
,
modespec
,
callback
,
options
)
{
var
mode
=
exports
.
getMode
({
indentUnit
:
2
},
modespec
);
var
lines
=
splitLines
(
string
),
state
=
(
options
&&
options
.
state
)
||
exports
.
startState
(
mode
);
var
context
=
{
lines
:
lines
,
line
:
0
}
for
(
var
i
=
0
,
e
=
lines
.
length
;
i
<
e
;
++
i
,
++
context
.
line
)
{
if
(
i
)
callback
(
"
\n
"
);
var
stream
=
new
exports
.
StringStream
(
lines
[
i
],
4
,
context
);
if
(
!
stream
.
string
&&
mode
.
blankLine
)
mode
.
blankLine
(
state
);
while
(
!
stream
.
eol
())
{
var
style
=
mode
.
token
(
stream
,
state
);
callback
(
stream
.
current
(),
style
,
i
,
stream
.
start
,
state
);
stream
.
start
=
stream
.
pos
;
}
}
};
require
.
cache
[
require
.
resolve
(
"
../../lib/codemirror
"
)]
=
require
.
cache
[
require
.
resolve
(
"
./runmode.node
"
)];
require
.
cache
[
require
.
resolve
(
"
../../addon/runmode/runmode
"
)]
=
require
.
cache
[
require
.
resolve
(
"
./runmode.node
"
)];
src/main/webapp/static/plugins/codemirror/5.48.4/addon/scroll/annotatescrollbar.js
0 → 100644
View file @
53f587bc
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(
function
(
mod
)
{
if
(
typeof
exports
==
"
object
"
&&
typeof
module
==
"
object
"
)
// CommonJS
mod
(
require
(
"
../../lib/codemirror
"
));
else
if
(
typeof
define
==
"
function
"
&&
define
.
amd
)
// AMD
define
([
"
../../lib/codemirror
"
],
mod
);
else
// Plain browser env
mod
(
CodeMirror
);
})(
function
(
CodeMirror
)
{
"
use strict
"
;
CodeMirror
.
defineExtension
(
"
annotateScrollbar
"
,
function
(
options
)
{
if
(
typeof
options
==
"
string
"
)
options
=
{
className
:
options
};
return
new
Annotation
(
this
,
options
);
});
CodeMirror
.
defineOption
(
"
scrollButtonHeight
"
,
0
);
function
Annotation
(
cm
,
options
)
{
this
.
cm
=
cm
;
this
.
options
=
options
;
this
.
buttonHeight
=
options
.
scrollButtonHeight
||
cm
.
getOption
(
"
scrollButtonHeight
"
);
this
.
annotations
=
[];
this
.
doRedraw
=
this
.
doUpdate
=
null
;
this
.
div
=
cm
.
getWrapperElement
().
appendChild
(
document
.
createElement
(
"
div
"
));
this
.
div
.
style
.
cssText
=
"
position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none
"
;
this
.
computeScale
();
function
scheduleRedraw
(
delay
)
{
clearTimeout
(
self
.
doRedraw
);
self
.
doRedraw
=
setTimeout
(
function
()
{
self
.
redraw
();
},
delay
);
}
var
self
=
this
;
cm
.
on
(
"
refresh
"
,
this
.
resizeHandler
=
function
()
{
clearTimeout
(
self
.
doUpdate
);
self
.
doUpdate
=
setTimeout
(
function
()
{
if
(
self
.
computeScale
())
scheduleRedraw
(
20
);
},
100
);
});
cm
.
on
(
"
markerAdded
"
,
this
.
resizeHandler
);
cm
.
on
(
"
markerCleared
"
,
this
.
resizeHandler
);
if
(
options
.
listenForChanges
!==
false
)
cm
.
on
(
"
change
"
,
this
.
changeHandler
=
function
()
{
scheduleRedraw
(
250
);
});
}
Annotation
.
prototype
.
computeScale
=
function
()
{
var
cm
=
this
.
cm
;
var
hScale
=
(
cm
.
getWrapperElement
().
clientHeight
-
cm
.
display
.
barHeight
-
this
.
buttonHeight
*
2
)
/
cm
.
getScrollerElement
().
scrollHeight
if
(
hScale
!=
this
.
hScale
)
{
this
.
hScale
=
hScale
;
return
true
;
}
};
Annotation
.
prototype
.
update
=
function
(
annotations
)
{
this
.
annotations
=
annotations
;
this
.
redraw
();
};
Annotation
.
prototype
.
redraw
=
function
(
compute
)
{
if
(
compute
!==
false
)
this
.
computeScale
();
var
cm
=
this
.
cm
,
hScale
=
this
.
hScale
;
var
frag
=
document
.
createDocumentFragment
(),
anns
=
this
.
annotations
;
var
wrapping
=
cm
.
getOption
(
"
lineWrapping
"
);
var
singleLineH
=
wrapping
&&
cm
.
defaultTextHeight
()
*
1.5
;
var
curLine
=
null
,
curLineObj
=
null
;
function
getY
(
pos
,
top
)
{
if
(
curLine
!=
pos
.
line
)
{
curLine
=
pos
.
line
;
curLineObj
=
cm
.
getLineHandle
(
curLine
);
}
if
((
curLineObj
.
widgets
&&
curLineObj
.
widgets
.
length
)
||
(
wrapping
&&
curLineObj
.
height
>
singleLineH
))
return
cm
.
charCoords
(
pos
,
"
local
"
)[
top
?
"
top
"
:
"
bottom
"
];
var
topY
=
cm
.
heightAtLine
(
curLineObj
,
"
local
"
);
return
topY
+
(
top
?
0
:
curLineObj
.
height
);
}
var
lastLine
=
cm
.
lastLine
()
if
(
cm
.
display
.
barWidth
)
for
(
var
i
=
0
,
nextTop
;
i
<
anns
.
length
;
i
++
)
{
var
ann
=
anns
[
i
];
if
(
ann
.
to
.
line
>
lastLine
)
continue
;
var
top
=
nextTop
||
getY
(
ann
.
from
,
true
)
*
hScale
;
var
bottom
=
getY
(
ann
.
to
,
false
)
*
hScale
;
while
(
i
<
anns
.
length
-
1
)
{
if
(
anns
[
i
+
1
].
to
.
line
>
lastLine
)
break
;
nextTop
=
getY
(
anns
[
i
+
1
].
from
,
true
)
*
hScale
;
if
(
nextTop
>
bottom
+
.
9
)
break
;
ann
=
anns
[
++
i
];
bottom
=
getY
(
ann
.
to
,
false
)
*
hScale
;
}
if
(
bottom
==
top
)
continue
;
var
height
=
Math
.
max
(
bottom
-
top
,
3
);
var
elt
=
frag
.
appendChild
(
document
.
createElement
(
"
div
"
));
elt
.
style
.
cssText
=
"
position: absolute; right: 0px; width:
"
+
Math
.
max
(
cm
.
display
.
barWidth
-
1
,
2
)
+
"
px; top:
"
+
(
top
+
this
.
buttonHeight
)
+
"
px; height:
"
+
height
+
"
px
"
;
elt
.
className
=
this
.
options
.
className
;
if
(
ann
.
id
)
{
elt
.
setAttribute
(
"
annotation-id
"
,
ann
.
id
);
}
}
this
.
div
.
textContent
=
""
;
this
.
div
.
appendChild
(
frag
);
};
Annotation
.
prototype
.
clear
=
function
()
{
this
.
cm
.
off
(
"
refresh
"
,
this
.
resizeHandler
);
this
.
cm
.
off
(
"
markerAdded
"
,
this
.
resizeHandler
);
this
.
cm
.
off
(
"
markerCleared
"
,
this
.
resizeHandler
);
if
(
this
.
changeHandler
)
this
.
cm
.
off
(
"
change
"
,
this
.
changeHandler
);
this
.
div
.
parentNode
.
removeChild
(
this
.
div
);
};
});
src/main/webapp/static/plugins/codemirror/5.48.4/addon/scroll/scrollpastend.js
0 → 100644
View file @
53f587bc
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(
function
(
mod
)
{
if
(
typeof
exports
==
"
object
"
&&
typeof
module
==
"
object
"
)
// CommonJS
mod
(
require
(
"
../../lib/codemirror
"
));
else
if
(
typeof
define
==
"
function
"
&&
define
.
amd
)
// AMD
define
([
"
../../lib/codemirror
"
],
mod
);
else
// Plain browser env
mod
(
CodeMirror
);
})(
function
(
CodeMirror
)
{
"
use strict
"
;
CodeMirror
.
defineOption
(
"
scrollPastEnd
"
,
false
,
function
(
cm
,
val
,
old
)
{
if
(
old
&&
old
!=
CodeMirror
.
Init
)
{
cm
.
off
(
"
change
"
,
onChange
);
cm
.
off
(
"
refresh
"
,
updateBottomMargin
);
cm
.
display
.
lineSpace
.
parentNode
.
style
.
paddingBottom
=
""
;
cm
.
state
.
scrollPastEndPadding
=
null
;
}
if
(
val
)
{
cm
.
on
(
"
change
"
,
onChange
);
cm
.
on
(
"
refresh
"
,
updateBottomMargin
);
updateBottomMargin
(
cm
);
}
});
function
onChange
(
cm
,
change
)
{
if
(
CodeMirror
.
changeEnd
(
change
).
line
==
cm
.
lastLine
())
updateBottomMargin
(
cm
);
}
function
updateBottomMargin
(
cm
)
{
var
padding
=
""
;
if
(
cm
.
lineCount
()
>
1
)
{
var
totalH
=
cm
.
display
.
scroller
.
clientHeight
-
30
,
lastLineH
=
cm
.
getLineHandle
(
cm
.
lastLine
()).
height
;
padding
=
(
totalH
-
lastLineH
)
+
"
px
"
;
}
if
(
cm
.
state
.
scrollPastEndPadding
!=
padding
)
{
cm
.
state
.
scrollPastEndPadding
=
padding
;
cm
.
display
.
lineSpace
.
parentNode
.
style
.
paddingBottom
=
padding
;
cm
.
off
(
"
refresh
"
,
updateBottomMargin
);
cm
.
setSize
();
cm
.
on
(
"
refresh
"
,
updateBottomMargin
);
}
}
});
src/main/webapp/static/plugins/codemirror/5.48.4/addon/scroll/simplescrollbars.css
0 → 100644
View file @
53f587bc
.CodeMirror-simplescroll-horizontal
div
,
.CodeMirror-simplescroll-vertical
div
{
position
:
absolute
;
background
:
#ccc
;
-moz-box-sizing
:
border-box
;
box-sizing
:
border-box
;
border
:
1px
solid
#bbb
;
border-radius
:
2px
;
}
.CodeMirror-simplescroll-horizontal
,
.CodeMirror-simplescroll-vertical
{
position
:
absolute
;
z-index
:
6
;
background
:
#eee
;
}
.CodeMirror-simplescroll-horizontal
{
bottom
:
0
;
left
:
0
;
height
:
8px
;
}
.CodeMirror-simplescroll-horizontal
div
{
bottom
:
0
;
height
:
100%
;
}
.CodeMirror-simplescroll-vertical
{
right
:
0
;
top
:
0
;
width
:
8px
;
}
.CodeMirror-simplescroll-vertical
div
{
right
:
0
;
width
:
100%
;
}
.CodeMirror-overlayscroll
.CodeMirror-scrollbar-filler
,
.CodeMirror-overlayscroll
.CodeMirror-gutter-filler
{
display
:
none
;
}
.CodeMirror-overlayscroll-horizontal
div
,
.CodeMirror-overlayscroll-vertical
div
{
position
:
absolute
;
background
:
#bcd
;
border-radius
:
3px
;
}
.CodeMirror-overlayscroll-horizontal
,
.CodeMirror-overlayscroll-vertical
{
position
:
absolute
;
z-index
:
6
;
}
.CodeMirror-overlayscroll-horizontal
{
bottom
:
0
;
left
:
0
;
height
:
6px
;
}
.CodeMirror-overlayscroll-horizontal
div
{
bottom
:
0
;
height
:
100%
;
}
.CodeMirror-overlayscroll-vertical
{
right
:
0
;
top
:
0
;
width
:
6px
;
}
.CodeMirror-overlayscroll-vertical
div
{
right
:
0
;
width
:
100%
;
}
src/main/webapp/static/plugins/codemirror/5.48.4/addon/scroll/simplescrollbars.js
0 → 100644
View file @
53f587bc
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(
function
(
mod
)
{
if
(
typeof
exports
==
"
object
"
&&
typeof
module
==
"
object
"
)
// CommonJS
mod
(
require
(
"
../../lib/codemirror
"
));
else
if
(
typeof
define
==
"
function
"
&&
define
.
amd
)
// AMD
define
([
"
../../lib/codemirror
"
],
mod
);
else
// Plain browser env
mod
(
CodeMirror
);
})(
function
(
CodeMirror
)
{
"
use strict
"
;
function
Bar
(
cls
,
orientation
,
scroll
)
{
this
.
orientation
=
orientation
;
this
.
scroll
=
scroll
;
this
.
screen
=
this
.
total
=
this
.
size
=
1
;
this
.
pos
=
0
;
this
.
node
=
document
.
createElement
(
"
div
"
);
this
.
node
.
className
=
cls
+
"
-
"
+
orientation
;
this
.
inner
=
this
.
node
.
appendChild
(
document
.
createElement
(
"
div
"
));
var
self
=
this
;
CodeMirror
.
on
(
this
.
inner
,
"
mousedown
"
,
function
(
e
)
{
if
(
e
.
which
!=
1
)
return
;
CodeMirror
.
e_preventDefault
(
e
);
var
axis
=
self
.
orientation
==
"
horizontal
"
?
"
pageX
"
:
"
pageY
"
;
var
start
=
e
[
axis
],
startpos
=
self
.
pos
;
function
done
()
{
CodeMirror
.
off
(
document
,
"
mousemove
"
,
move
);
CodeMirror
.
off
(
document
,
"
mouseup
"
,
done
);
}
function
move
(
e
)
{
if
(
e
.
which
!=
1
)
return
done
();
self
.
moveTo
(
startpos
+
(
e
[
axis
]
-
start
)
*
(
self
.
total
/
self
.
size
));
}
CodeMirror
.
on
(
document
,
"
mousemove
"
,
move
);
CodeMirror
.
on
(
document
,
"
mouseup
"
,
done
);
});
CodeMirror
.
on
(
this
.
node
,
"
click
"
,
function
(
e
)
{
CodeMirror
.
e_preventDefault
(
e
);
var
innerBox
=
self
.
inner
.
getBoundingClientRect
(),
where
;
if
(
self
.
orientation
==
"
horizontal
"
)
where
=
e
.
clientX
<
innerBox
.
left
?
-
1
:
e
.
clientX
>
innerBox
.
right
?
1
:
0
;
else
where
=
e
.
clientY
<
innerBox
.
top
?
-
1
:
e
.
clientY
>
innerBox
.
bottom
?
1
:
0
;
self
.
moveTo
(
self
.
pos
+
where
*
self
.
screen
);
});
function
onWheel
(
e
)
{
var
moved
=
CodeMirror
.
wheelEventPixels
(
e
)[
self
.
orientation
==
"
horizontal
"
?
"
x
"
:
"
y
"
];
var
oldPos
=
self
.
pos
;
self
.
moveTo
(
self
.
pos
+
moved
);
if
(
self
.
pos
!=
oldPos
)
CodeMirror
.
e_preventDefault
(
e
);
}
CodeMirror
.
on
(
this
.
node
,
"
mousewheel
"
,
onWheel
);
CodeMirror
.
on
(
this
.
node
,
"
DOMMouseScroll
"
,
onWheel
);
}
Bar
.
prototype
.
setPos
=
function
(
pos
,
force
)
{
if
(
pos
<
0
)
pos
=
0
;
if
(
pos
>
this
.
total
-
this
.
screen
)
pos
=
this
.
total
-
this
.
screen
;
if
(
!
force
&&
pos
==
this
.
pos
)
return
false
;
this
.
pos
=
pos
;
this
.
inner
.
style
[
this
.
orientation
==
"
horizontal
"
?
"
left
"
:
"
top
"
]
=
(
pos
*
(
this
.
size
/
this
.
total
))
+
"
px
"
;
return
true
};
Bar
.
prototype
.
moveTo
=
function
(
pos
)
{
if
(
this
.
setPos
(
pos
))
this
.
scroll
(
pos
,
this
.
orientation
);
}
var
minButtonSize
=
10
;
Bar
.
prototype
.
update
=
function
(
scrollSize
,
clientSize
,
barSize
)
{
var
sizeChanged
=
this
.
screen
!=
clientSize
||
this
.
total
!=
scrollSize
||
this
.
size
!=
barSize
if
(
sizeChanged
)
{
this
.
screen
=
clientSize
;
this
.
total
=
scrollSize
;
this
.
size
=
barSize
;
}
var
buttonSize
=
this
.
screen
*
(
this
.
size
/
this
.
total
);
if
(
buttonSize
<
minButtonSize
)
{
this
.
size
-=
minButtonSize
-
buttonSize
;
buttonSize
=
minButtonSize
;
}
this
.
inner
.
style
[
this
.
orientation
==
"
horizontal
"
?
"
width
"
:
"
height
"
]
=
buttonSize
+
"
px
"
;
this
.
setPos
(
this
.
pos
,
sizeChanged
);
};
function
SimpleScrollbars
(
cls
,
place
,
scroll
)
{
this
.
addClass
=
cls
;
this
.
horiz
=
new
Bar
(
cls
,
"
horizontal
"
,
scroll
);
place
(
this
.
horiz
.
node
);
this
.
vert
=
new
Bar
(
cls
,
"
vertical
"
,
scroll
);
place
(
this
.
vert
.
node
);
this
.
width
=
null
;
}
SimpleScrollbars
.
prototype
.
update
=
function
(
measure
)
{
if
(
this
.
width
==
null
)
{
var
style
=
window
.
getComputedStyle
?
window
.
getComputedStyle
(
this
.
horiz
.
node
)
:
this
.
horiz
.
node
.
currentStyle
;
if
(
style
)
this
.
width
=
parseInt
(
style
.
height
);
}
var
width
=
this
.
width
||
0
;
var
needsH
=
measure
.
scrollWidth
>
measure
.
clientWidth
+
1
;
var
needsV
=
measure
.
scrollHeight
>
measure
.
clientHeight
+
1
;
this
.
vert
.
node
.
style
.
display
=
needsV
?
"
block
"
:
"
none
"
;
this
.
horiz
.
node
.
style
.
display
=
needsH
?
"
block
"
:
"
none
"
;
if
(
needsV
)
{
this
.
vert
.
update
(
measure
.
scrollHeight
,
measure
.
clientHeight
,
measure
.
viewHeight
-
(
needsH
?
width
:
0
));
this
.
vert
.
node
.
style
.
bottom
=
needsH
?
width
+
"
px
"
:
"
0
"
;
}
if
(
needsH
)
{
this
.
horiz
.
update
(
measure
.
scrollWidth
,
measure
.
clientWidth
,
measure
.
viewWidth
-
(
needsV
?
width
:
0
)
-
measure
.
barLeft
);
this
.
horiz
.
node
.
style
.
right
=
needsV
?
width
+
"
px
"
:
"
0
"
;
this
.
horiz
.
node
.
style
.
left
=
measure
.
barLeft
+
"
px
"
;
}
return
{
right
:
needsV
?
width
:
0
,
bottom
:
needsH
?
width
:
0
};
};
SimpleScrollbars
.
prototype
.
setScrollTop
=
function
(
pos
)
{
this
.
vert
.
setPos
(
pos
);
};
SimpleScrollbars
.
prototype
.
setScrollLeft
=
function
(
pos
)
{
this
.
horiz
.
setPos
(
pos
);
};
SimpleScrollbars
.
prototype
.
clear
=
function
()
{
var
parent
=
this
.
horiz
.
node
.
parentNode
;
parent
.
removeChild
(
this
.
horiz
.
node
);
parent
.
removeChild
(
this
.
vert
.
node
);
};
CodeMirror
.
scrollbarModel
.
simple
=
function
(
place
,
scroll
)
{
return
new
SimpleScrollbars
(
"
CodeMirror-simplescroll
"
,
place
,
scroll
);
};
CodeMirror
.
scrollbarModel
.
overlay
=
function
(
place
,
scroll
)
{
return
new
SimpleScrollbars
(
"
CodeMirror-overlayscroll
"
,
place
,
scroll
);
};
});
src/main/webapp/static/plugins/codemirror/5.48.4/addon/search/jump-to-line.js
0 → 100644
View file @
53f587bc
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
// Defines jumpToLine command. Uses dialog.js if present.
(
function
(
mod
)
{
if
(
typeof
exports
==
"
object
"
&&
typeof
module
==
"
object
"
)
// CommonJS
mod
(
require
(
"
../../lib/codemirror
"
),
require
(
"
../dialog/dialog
"
));
else
if
(
typeof
define
==
"
function
"
&&
define
.
amd
)
// AMD
define
([
"
../../lib/codemirror
"
,
"
../dialog/dialog
"
],
mod
);
else
// Plain browser env
mod
(
CodeMirror
);
})(
function
(
CodeMirror
)
{
"
use strict
"
;
function
dialog
(
cm
,
text
,
shortText
,
deflt
,
f
)
{
if
(
cm
.
openDialog
)
cm
.
openDialog
(
text
,
f
,
{
value
:
deflt
,
selectValueOnOpen
:
true
});
else
f
(
prompt
(
shortText
,
deflt
));
}
function
getJumpDialog
(
cm
)
{
return
cm
.
phrase
(
"
Jump to line:
"
)
+
'
<input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">
'
+
cm
.
phrase
(
"
(Use line:column or scroll% syntax)
"
)
+
'
</span>
'
;
}
function
interpretLine
(
cm
,
string
)
{
var
num
=
Number
(
string
)
if
(
/^
[
-+
]
/
.
test
(
string
))
return
cm
.
getCursor
().
line
+
num
else
return
num
-
1
}
CodeMirror
.
commands
.
jumpToLine
=
function
(
cm
)
{
var
cur
=
cm
.
getCursor
();
dialog
(
cm
,
getJumpDialog
(
cm
),
cm
.
phrase
(
"
Jump to line:
"
),
(
cur
.
line
+
1
)
+
"
:
"
+
cur
.
ch
,
function
(
posStr
)
{
if
(
!
posStr
)
return
;
var
match
;
if
(
match
=
/^
\s
*
([\+\-]?\d
+
)\s
*
\:\s
*
(\d
+
)\s
*$/
.
exec
(
posStr
))
{
cm
.
setCursor
(
interpretLine
(
cm
,
match
[
1
]),
Number
(
match
[
2
]))
}
else
if
(
match
=
/^
\s
*
([\+\-]?\d
+
(\.\d
+
)?)\%\s
*/
.
exec
(
posStr
))
{
var
line
=
Math
.
round
(
cm
.
lineCount
()
*
Number
(
match
[
1
])
/
100
);
if
(
/^
[
-+
]
/
.
test
(
match
[
1
]))
line
=
cur
.
line
+
line
+
1
;
cm
.
setCursor
(
line
-
1
,
cur
.
ch
);
}
else
if
(
match
=
/^
\s
*
\:?\s
*
([\+\-]?\d
+
)\s
*/
.
exec
(
posStr
))
{
cm
.
setCursor
(
interpretLine
(
cm
,
match
[
1
]),
cur
.
ch
);
}
});
};
CodeMirror
.
keyMap
[
"
default
"
][
"
Alt-G
"
]
=
"
jumpToLine
"
;
});
src/main/webapp/static/plugins/codemirror/5.48.4/addon/search/match-highlighter.js
0 → 100644
View file @
53f587bc
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
// Highlighting text that matches the selection
//
// Defines an option highlightSelectionMatches, which, when enabled,
// will style strings that match the selection throughout the
// document.
//
// The option can be set to true to simply enable it, or to a
// {minChars, style, wordsOnly, showToken, delay} object to explicitly
// configure it. minChars is the minimum amount of characters that should be
// selected for the behavior to occur, and style is the token style to
// apply to the matches. This will be prefixed by "cm-" to create an
// actual CSS class name. If wordsOnly is enabled, the matches will be
// highlighted only if the selected text is a word. showToken, when enabled,
// will cause the current token to be highlighted when nothing is selected.
// delay is used to specify how much time to wait, in milliseconds, before
// highlighting the matches. If annotateScrollbar is enabled, the occurences
// will be highlighted on the scrollbar via the matchesonscrollbar addon.
(
function
(
mod
)
{
if
(
typeof
exports
==
"
object
"
&&
typeof
module
==
"
object
"
)
// CommonJS
mod
(
require
(
"
../../lib/codemirror
"
),
require
(
"
./matchesonscrollbar
"
));
else
if
(
typeof
define
==
"
function
"
&&
define
.
amd
)
// AMD
define
([
"
../../lib/codemirror
"
,
"
./matchesonscrollbar
"
],
mod
);
else
// Plain browser env
mod
(
CodeMirror
);
})(
function
(
CodeMirror
)
{
"
use strict
"
;
var
defaults
=
{
style
:
"
matchhighlight
"
,
minChars
:
2
,
delay
:
100
,
wordsOnly
:
false
,
annotateScrollbar
:
false
,
showToken
:
false
,
trim
:
true
}
function
State
(
options
)
{
this
.
options
=
{}
for
(
var
name
in
defaults
)
this
.
options
[
name
]
=
(
options
&&
options
.
hasOwnProperty
(
name
)
?
options
:
defaults
)[
name
]
this
.
overlay
=
this
.
timeout
=
null
;
this
.
matchesonscroll
=
null
;
this
.
active
=
false
;
}
CodeMirror
.
defineOption
(
"
highlightSelectionMatches
"
,
false
,
function
(
cm
,
val
,
old
)
{
if
(
old
&&
old
!=
CodeMirror
.
Init
)
{
removeOverlay
(
cm
);
clearTimeout
(
cm
.
state
.
matchHighlighter
.
timeout
);
cm
.
state
.
matchHighlighter
=
null
;
cm
.
off
(
"
cursorActivity
"
,
cursorActivity
);
cm
.
off
(
"
focus
"
,
onFocus
)
}
if
(
val
)
{
var
state
=
cm
.
state
.
matchHighlighter
=
new
State
(
val
);
if
(
cm
.
hasFocus
())
{
state
.
active
=
true
highlightMatches
(
cm
)
}
else
{
cm
.
on
(
"
focus
"
,
onFocus
)
}
cm
.
on
(
"
cursorActivity
"
,
cursorActivity
);
}
});
function
cursorActivity
(
cm
)
{
var
state
=
cm
.
state
.
matchHighlighter
;
if
(
state
.
active
||
cm
.
hasFocus
())
scheduleHighlight
(
cm
,
state
)
}
function
onFocus
(
cm
)
{
var
state
=
cm
.
state
.
matchHighlighter
if
(
!
state
.
active
)
{
state
.
active
=
true
scheduleHighlight
(
cm
,
state
)
}
}
function
scheduleHighlight
(
cm
,
state
)
{
clearTimeout
(
state
.
timeout
);
state
.
timeout
=
setTimeout
(
function
()
{
highlightMatches
(
cm
);},
state
.
options
.
delay
);
}
function
addOverlay
(
cm
,
query
,
hasBoundary
,
style
)
{
var
state
=
cm
.
state
.
matchHighlighter
;
cm
.
addOverlay
(
state
.
overlay
=
makeOverlay
(
query
,
hasBoundary
,
style
));
if
(
state
.
options
.
annotateScrollbar
&&
cm
.
showMatchesOnScrollbar
)
{
var
searchFor
=
hasBoundary
?
new
RegExp
(
"
\\
b
"
+
query
.
replace
(
/
[\\\[
.+*?(){|^$
]
/g
,
"
\\
$&
"
)
+
"
\\
b
"
)
:
query
;
state
.
matchesonscroll
=
cm
.
showMatchesOnScrollbar
(
searchFor
,
false
,
{
className
:
"
CodeMirror-selection-highlight-scrollbar
"
});
}
}
function
removeOverlay
(
cm
)
{
var
state
=
cm
.
state
.
matchHighlighter
;
if
(
state
.
overlay
)
{
cm
.
removeOverlay
(
state
.
overlay
);
state
.
overlay
=
null
;
if
(
state
.
matchesonscroll
)
{
state
.
matchesonscroll
.
clear
();
state
.
matchesonscroll
=
null
;
}
}
}
function
highlightMatches
(
cm
)
{
cm
.
operation
(
function
()
{
var
state
=
cm
.
state
.
matchHighlighter
;
removeOverlay
(
cm
);
if
(
!
cm
.
somethingSelected
()
&&
state
.
options
.
showToken
)
{
var
re
=
state
.
options
.
showToken
===
true
?
/
[\w
$
]
/
:
state
.
options
.
showToken
;
var
cur
=
cm
.
getCursor
(),
line
=
cm
.
getLine
(
cur
.
line
),
start
=
cur
.
ch
,
end
=
start
;
while
(
start
&&
re
.
test
(
line
.
charAt
(
start
-
1
)))
--
start
;
while
(
end
<
line
.
length
&&
re
.
test
(
line
.
charAt
(
end
)))
++
end
;
if
(
start
<
end
)
addOverlay
(
cm
,
line
.
slice
(
start
,
end
),
re
,
state
.
options
.
style
);
return
;
}
var
from
=
cm
.
getCursor
(
"
from
"
),
to
=
cm
.
getCursor
(
"
to
"
);
if
(
from
.
line
!=
to
.
line
)
return
;
if
(
state
.
options
.
wordsOnly
&&
!
isWord
(
cm
,
from
,
to
))
return
;
var
selection
=
cm
.
getRange
(
from
,
to
)
if
(
state
.
options
.
trim
)
selection
=
selection
.
replace
(
/^
\s
+|
\s
+$/g
,
""
)
if
(
selection
.
length
>=
state
.
options
.
minChars
)
addOverlay
(
cm
,
selection
,
false
,
state
.
options
.
style
);
});
}
function
isWord
(
cm
,
from
,
to
)
{
var
str
=
cm
.
getRange
(
from
,
to
);
if
(
str
.
match
(
/^
\w
+$/
)
!==
null
)
{
if
(
from
.
ch
>
0
)
{
var
pos
=
{
line
:
from
.
line
,
ch
:
from
.
ch
-
1
};
var
chr
=
cm
.
getRange
(
pos
,
from
);
if
(
chr
.
match
(
/
\W
/
)
===
null
)
return
false
;
}
if
(
to
.
ch
<
cm
.
getLine
(
from
.
line
).
length
)
{
var
pos
=
{
line
:
to
.
line
,
ch
:
to
.
ch
+
1
};
var
chr
=
cm
.
getRange
(
to
,
pos
);
if
(
chr
.
match
(
/
\W
/
)
===
null
)
return
false
;
}
return
true
;
}
else
return
false
;
}
function
boundariesAround
(
stream
,
re
)
{
return
(
!
stream
.
start
||
!
re
.
test
(
stream
.
string
.
charAt
(
stream
.
start
-
1
)))
&&
(
stream
.
pos
==
stream
.
string
.
length
||
!
re
.
test
(
stream
.
string
.
charAt
(
stream
.
pos
)));
}
function
makeOverlay
(
query
,
hasBoundary
,
style
)
{
return
{
token
:
function
(
stream
)
{
if
(
stream
.
match
(
query
)
&&
(
!
hasBoundary
||
boundariesAround
(
stream
,
hasBoundary
)))
return
style
;
stream
.
next
();
stream
.
skipTo
(
query
.
charAt
(
0
))
||
stream
.
skipToEnd
();
}};
}
});
src/main/webapp/static/plugins/codemirror/5.48.4/addon/search/matchesonscrollbar.css
0 → 100644
View file @
53f587bc
.CodeMirror-search-match
{
background
:
gold
;
border-top
:
1px
solid
orange
;
border-bottom
:
1px
solid
orange
;
-moz-box-sizing
:
border-box
;
box-sizing
:
border-box
;
opacity
:
.5
;
}
src/main/webapp/static/plugins/codemirror/5.48.4/addon/search/matchesonscrollbar.js
0 → 100644
View file @
53f587bc
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(
function
(
mod
)
{
if
(
typeof
exports
==
"
object
"
&&
typeof
module
==
"
object
"
)
// CommonJS
mod
(
require
(
"
../../lib/codemirror
"
),
require
(
"
./searchcursor
"
),
require
(
"
../scroll/annotatescrollbar
"
));
else
if
(
typeof
define
==
"
function
"
&&
define
.
amd
)
// AMD
define
([
"
../../lib/codemirror
"
,
"
./searchcursor
"
,
"
../scroll/annotatescrollbar
"
],
mod
);
else
// Plain browser env
mod
(
CodeMirror
);
})(
function
(
CodeMirror
)
{
"
use strict
"
;
CodeMirror
.
defineExtension
(
"
showMatchesOnScrollbar
"
,
function
(
query
,
caseFold
,
options
)
{
if
(
typeof
options
==
"
string
"
)
options
=
{
className
:
options
};
if
(
!
options
)
options
=
{};
return
new
SearchAnnotation
(
this
,
query
,
caseFold
,
options
);
});
function
SearchAnnotation
(
cm
,
query
,
caseFold
,
options
)
{
this
.
cm
=
cm
;
this
.
options
=
options
;
var
annotateOptions
=
{
listenForChanges
:
false
};
for
(
var
prop
in
options
)
annotateOptions
[
prop
]
=
options
[
prop
];
if
(
!
annotateOptions
.
className
)
annotateOptions
.
className
=
"
CodeMirror-search-match
"
;
this
.
annotation
=
cm
.
annotateScrollbar
(
annotateOptions
);
this
.
query
=
query
;
this
.
caseFold
=
caseFold
;
this
.
gap
=
{
from
:
cm
.
firstLine
(),
to
:
cm
.
lastLine
()
+
1
};
this
.
matches
=
[];
this
.
update
=
null
;
this
.
findMatches
();
this
.
annotation
.
update
(
this
.
matches
);
var
self
=
this
;
cm
.
on
(
"
change
"
,
this
.
changeHandler
=
function
(
_cm
,
change
)
{
self
.
onChange
(
change
);
});
}
var
MAX_MATCHES
=
1000
;
SearchAnnotation
.
prototype
.
findMatches
=
function
()
{
if
(
!
this
.
gap
)
return
;
for
(
var
i
=
0
;
i
<
this
.
matches
.
length
;
i
++
)
{
var
match
=
this
.
matches
[
i
];
if
(
match
.
from
.
line
>=
this
.
gap
.
to
)
break
;
if
(
match
.
to
.
line
>=
this
.
gap
.
from
)
this
.
matches
.
splice
(
i
--
,
1
);
}
var
cursor
=
this
.
cm
.
getSearchCursor
(
this
.
query
,
CodeMirror
.
Pos
(
this
.
gap
.
from
,
0
),
{
caseFold
:
this
.
caseFold
,
multiline
:
this
.
options
.
multiline
});
var
maxMatches
=
this
.
options
&&
this
.
options
.
maxMatches
||
MAX_MATCHES
;
while
(
cursor
.
findNext
())
{
var
match
=
{
from
:
cursor
.
from
(),
to
:
cursor
.
to
()};
if
(
match
.
from
.
line
>=
this
.
gap
.
to
)
break
;
this
.
matches
.
splice
(
i
++
,
0
,
match
);
if
(
this
.
matches
.
length
>
maxMatches
)
break
;
}
this
.
gap
=
null
;
};
function
offsetLine
(
line
,
changeStart
,
sizeChange
)
{
if
(
line
<=
changeStart
)
return
line
;
return
Math
.
max
(
changeStart
,
line
+
sizeChange
);
}
SearchAnnotation
.
prototype
.
onChange
=
function
(
change
)
{
var
startLine
=
change
.
from
.
line
;
var
endLine
=
CodeMirror
.
changeEnd
(
change
).
line
;
var
sizeChange
=
endLine
-
change
.
to
.
line
;
if
(
this
.
gap
)
{
this
.
gap
.
from
=
Math
.
min
(
offsetLine
(
this
.
gap
.
from
,
startLine
,
sizeChange
),
change
.
from
.
line
);
this
.
gap
.
to
=
Math
.
max
(
offsetLine
(
this
.
gap
.
to
,
startLine
,
sizeChange
),
change
.
from
.
line
);
}
else
{
this
.
gap
=
{
from
:
change
.
from
.
line
,
to
:
endLine
+
1
};
}
if
(
sizeChange
)
for
(
var
i
=
0
;
i
<
this
.
matches
.
length
;
i
++
)
{
var
match
=
this
.
matches
[
i
];
var
newFrom
=
offsetLine
(
match
.
from
.
line
,
startLine
,
sizeChange
);
if
(
newFrom
!=
match
.
from
.
line
)
match
.
from
=
CodeMirror
.
Pos
(
newFrom
,
match
.
from
.
ch
);
var
newTo
=
offsetLine
(
match
.
to
.
line
,
startLine
,
sizeChange
);
if
(
newTo
!=
match
.
to
.
line
)
match
.
to
=
CodeMirror
.
Pos
(
newTo
,
match
.
to
.
ch
);
}
clearTimeout
(
this
.
update
);
var
self
=
this
;
this
.
update
=
setTimeout
(
function
()
{
self
.
updateAfterChange
();
},
250
);
};
SearchAnnotation
.
prototype
.
updateAfterChange
=
function
()
{
this
.
findMatches
();
this
.
annotation
.
update
(
this
.
matches
);
};
SearchAnnotation
.
prototype
.
clear
=
function
()
{
this
.
cm
.
off
(
"
change
"
,
this
.
changeHandler
);
this
.
annotation
.
clear
();
};
});
src/main/webapp/static/plugins/codemirror/5.48.4/addon/search/search.js
0 → 100644
View file @
53f587bc
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
// Define search commands. Depends on dialog.js or another
// implementation of the openDialog method.
// Replace works a little oddly -- it will do the replace on the next
// Ctrl-G (or whatever is bound to findNext) press. You prevent a
// replace by making sure the match is no longer selected when hitting
// Ctrl-G.
(
function
(
mod
)
{
if
(
typeof
exports
==
"
object
"
&&
typeof
module
==
"
object
"
)
// CommonJS
mod
(
require
(
"
../../lib/codemirror
"
),
require
(
"
./searchcursor
"
),
require
(
"
../dialog/dialog
"
));
else
if
(
typeof
define
==
"
function
"
&&
define
.
amd
)
// AMD
define
([
"
../../lib/codemirror
"
,
"
./searchcursor
"
,
"
../dialog/dialog
"
],
mod
);
else
// Plain browser env
mod
(
CodeMirror
);
})(
function
(
CodeMirror
)
{
"
use strict
"
;
function
searchOverlay
(
query
,
caseInsensitive
)
{
if
(
typeof
query
==
"
string
"
)
query
=
new
RegExp
(
query
.
replace
(
/
[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]
/g
,
"
\\
$&
"
),
caseInsensitive
?
"
gi
"
:
"
g
"
);
else
if
(
!
query
.
global
)
query
=
new
RegExp
(
query
.
source
,
query
.
ignoreCase
?
"
gi
"
:
"
g
"
);
return
{
token
:
function
(
stream
)
{
query
.
lastIndex
=
stream
.
pos
;
var
match
=
query
.
exec
(
stream
.
string
);
if
(
match
&&
match
.
index
==
stream
.
pos
)
{
stream
.
pos
+=
match
[
0
].
length
||
1
;
return
"
searching
"
;
}
else
if
(
match
)
{
stream
.
pos
=
match
.
index
;
}
else
{
stream
.
skipToEnd
();
}
}};
}
function
SearchState
()
{
this
.
posFrom
=
this
.
posTo
=
this
.
lastQuery
=
this
.
query
=
null
;
this
.
overlay
=
null
;
}
function
getSearchState
(
cm
)
{
return
cm
.
state
.
search
||
(
cm
.
state
.
search
=
new
SearchState
());
}
function
queryCaseInsensitive
(
query
)
{
return
typeof
query
==
"
string
"
&&
query
==
query
.
toLowerCase
();
}
function
getSearchCursor
(
cm
,
query
,
pos
)
{
// Heuristic: if the query string is all lowercase, do a case insensitive search.
return
cm
.
getSearchCursor
(
query
,
pos
,
{
caseFold
:
queryCaseInsensitive
(
query
),
multiline
:
true
});
}
function
persistentDialog
(
cm
,
text
,
deflt
,
onEnter
,
onKeyDown
)
{
cm
.
openDialog
(
text
,
onEnter
,
{
value
:
deflt
,
selectValueOnOpen
:
true
,
closeOnEnter
:
false
,
onClose
:
function
()
{
clearSearch
(
cm
);
},
onKeyDown
:
onKeyDown
});
}
function
dialog
(
cm
,
text
,
shortText
,
deflt
,
f
)
{
if
(
cm
.
openDialog
)
cm
.
openDialog
(
text
,
f
,
{
value
:
deflt
,
selectValueOnOpen
:
true
});
else
f
(
prompt
(
shortText
,
deflt
));
}
function
confirmDialog
(
cm
,
text
,
shortText
,
fs
)
{
if
(
cm
.
openConfirm
)
cm
.
openConfirm
(
text
,
fs
);
else
if
(
confirm
(
shortText
))
fs
[
0
]();
}
function
parseString
(
string
)
{
return
string
.
replace
(
/
\\([
nrt
\\])
/g
,
function
(
match
,
ch
)
{
if
(
ch
==
"
n
"
)
return
"
\n
"
if
(
ch
==
"
r
"
)
return
"
\r
"
if
(
ch
==
"
t
"
)
return
"
\t
"
if
(
ch
==
"
\\
"
)
return
"
\\
"
return
match
})
}
function
parseQuery
(
query
)
{
var
isRE
=
query
.
match
(
/^
\/(
.*
)\/([
a-z
]
*
)
$/
);
if
(
isRE
)
{
try
{
query
=
new
RegExp
(
isRE
[
1
],
isRE
[
2
].
indexOf
(
"
i
"
)
==
-
1
?
""
:
"
i
"
);
}
catch
(
e
)
{}
// Not a regular expression after all, do a string search
}
else
{
query
=
parseString
(
query
)
}
if
(
typeof
query
==
"
string
"
?
query
==
""
:
query
.
test
(
""
))
query
=
/x^/
;
return
query
;
}
function
startSearch
(
cm
,
state
,
query
)
{
state
.
queryText
=
query
;
state
.
query
=
parseQuery
(
query
);
cm
.
removeOverlay
(
state
.
overlay
,
queryCaseInsensitive
(
state
.
query
));
state
.
overlay
=
searchOverlay
(
state
.
query
,
queryCaseInsensitive
(
state
.
query
));
cm
.
addOverlay
(
state
.
overlay
);
if
(
cm
.
showMatchesOnScrollbar
)
{
if
(
state
.
annotate
)
{
state
.
annotate
.
clear
();
state
.
annotate
=
null
;
}
state
.
annotate
=
cm
.
showMatchesOnScrollbar
(
state
.
query
,
queryCaseInsensitive
(
state
.
query
));
}
}
function
doSearch
(
cm
,
rev
,
persistent
,
immediate
)
{
var
state
=
getSearchState
(
cm
);
if
(
state
.
query
)
return
findNext
(
cm
,
rev
);
var
q
=
cm
.
getSelection
()
||
state
.
lastQuery
;
if
(
q
instanceof
RegExp
&&
q
.
source
==
"
x^
"
)
q
=
null
if
(
persistent
&&
cm
.
openDialog
)
{
var
hiding
=
null
var
searchNext
=
function
(
query
,
event
)
{
CodeMirror
.
e_stop
(
event
);
if
(
!
query
)
return
;
if
(
query
!=
state
.
queryText
)
{
startSearch
(
cm
,
state
,
query
);
state
.
posFrom
=
state
.
posTo
=
cm
.
getCursor
();
}
if
(
hiding
)
hiding
.
style
.
opacity
=
1
findNext
(
cm
,
event
.
shiftKey
,
function
(
_
,
to
)
{
var
dialog
if
(
to
.
line
<
3
&&
document
.
querySelector
&&
(
dialog
=
cm
.
display
.
wrapper
.
querySelector
(
"
.CodeMirror-dialog
"
))
&&
dialog
.
getBoundingClientRect
().
bottom
-
4
>
cm
.
cursorCoords
(
to
,
"
window
"
).
top
)
(
hiding
=
dialog
).
style
.
opacity
=
.
4
})
};
persistentDialog
(
cm
,
getQueryDialog
(
cm
),
q
,
searchNext
,
function
(
event
,
query
)
{
var
keyName
=
CodeMirror
.
keyName
(
event
)
var
extra
=
cm
.
getOption
(
'
extraKeys
'
),
cmd
=
(
extra
&&
extra
[
keyName
])
||
CodeMirror
.
keyMap
[
cm
.
getOption
(
"
keyMap
"
)][
keyName
]
if
(
cmd
==
"
findNext
"
||
cmd
==
"
findPrev
"
||
cmd
==
"
findPersistentNext
"
||
cmd
==
"
findPersistentPrev
"
)
{
CodeMirror
.
e_stop
(
event
);
startSearch
(
cm
,
getSearchState
(
cm
),
query
);
cm
.
execCommand
(
cmd
);
}
else
if
(
cmd
==
"
find
"
||
cmd
==
"
findPersistent
"
)
{
CodeMirror
.
e_stop
(
event
);
searchNext
(
query
,
event
);
}
});
if
(
immediate
&&
q
)
{
startSearch
(
cm
,
state
,
q
);
findNext
(
cm
,
rev
);
}
}
else
{
dialog
(
cm
,
getQueryDialog
(
cm
),
"
Search for:
"
,
q
,
function
(
query
)
{
if
(
query
&&
!
state
.
query
)
cm
.
operation
(
function
()
{
startSearch
(
cm
,
state
,
query
);
state
.
posFrom
=
state
.
posTo
=
cm
.
getCursor
();
findNext
(
cm
,
rev
);
});
});
}
}
function
findNext
(
cm
,
rev
,
callback
)
{
cm
.
operation
(
function
()
{
var
state
=
getSearchState
(
cm
);
var
cursor
=
getSearchCursor
(
cm
,
state
.
query
,
rev
?
state
.
posFrom
:
state
.
posTo
);
if
(
!
cursor
.
find
(
rev
))
{
cursor
=
getSearchCursor
(
cm
,
state
.
query
,
rev
?
CodeMirror
.
Pos
(
cm
.
lastLine
())
:
CodeMirror
.
Pos
(
cm
.
firstLine
(),
0
));
if
(
!
cursor
.
find
(
rev
))
return
;
}
cm
.
setSelection
(
cursor
.
from
(),
cursor
.
to
());
cm
.
scrollIntoView
({
from
:
cursor
.
from
(),
to
:
cursor
.
to
()},
20
);
state
.
posFrom
=
cursor
.
from
();
state
.
posTo
=
cursor
.
to
();
if
(
callback
)
callback
(
cursor
.
from
(),
cursor
.
to
())
});}
function
clearSearch
(
cm
)
{
cm
.
operation
(
function
()
{
var
state
=
getSearchState
(
cm
);
state
.
lastQuery
=
state
.
query
;
if
(
!
state
.
query
)
return
;
state
.
query
=
state
.
queryText
=
null
;
cm
.
removeOverlay
(
state
.
overlay
);
if
(
state
.
annotate
)
{
state
.
annotate
.
clear
();
state
.
annotate
=
null
;
}
});}
function
getQueryDialog
(
cm
)
{
return
'
<span class="CodeMirror-search-label">
'
+
cm
.
phrase
(
"
Search:
"
)
+
'
</span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">
'
+
cm
.
phrase
(
"
(Use /re/ syntax for regexp search)
"
)
+
'
</span>
'
;
}
function
getReplaceQueryDialog
(
cm
)
{
return
'
<input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">
'
+
cm
.
phrase
(
"
(Use /re/ syntax for regexp search)
"
)
+
'
</span>
'
;
}
function
getReplacementQueryDialog
(
cm
)
{
return
'
<span class="CodeMirror-search-label">
'
+
cm
.
phrase
(
"
With:
"
)
+
'
</span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/>
'
;
}
function
getDoReplaceConfirm
(
cm
)
{
return
'
<span class="CodeMirror-search-label">
'
+
cm
.
phrase
(
"
Replace?
"
)
+
'
</span> <button>
'
+
cm
.
phrase
(
"
Yes
"
)
+
'
</button> <button>
'
+
cm
.
phrase
(
"
No
"
)
+
'
</button> <button>
'
+
cm
.
phrase
(
"
All
"
)
+
'
</button> <button>
'
+
cm
.
phrase
(
"
Stop
"
)
+
'
</button>
'
;
}
function
replaceAll
(
cm
,
query
,
text
)
{
cm
.
operation
(
function
()
{
for
(
var
cursor
=
getSearchCursor
(
cm
,
query
);
cursor
.
findNext
();)
{
if
(
typeof
query
!=
"
string
"
)
{
var
match
=
cm
.
getRange
(
cursor
.
from
(),
cursor
.
to
()).
match
(
query
);
cursor
.
replace
(
text
.
replace
(
/
\$(\d)
/g
,
function
(
_
,
i
)
{
return
match
[
i
];}));
}
else
cursor
.
replace
(
text
);
}
});
}
function
replace
(
cm
,
all
)
{
if
(
cm
.
getOption
(
"
readOnly
"
))
return
;
var
query
=
cm
.
getSelection
()
||
getSearchState
(
cm
).
lastQuery
;
var
dialogText
=
'
<span class="CodeMirror-search-label">
'
+
(
all
?
cm
.
phrase
(
"
Replace all:
"
)
:
cm
.
phrase
(
"
Replace:
"
))
+
'
</span>
'
;
dialog
(
cm
,
dialogText
+
getReplaceQueryDialog
(
cm
),
dialogText
,
query
,
function
(
query
)
{
if
(
!
query
)
return
;
query
=
parseQuery
(
query
);
dialog
(
cm
,
getReplacementQueryDialog
(
cm
),
cm
.
phrase
(
"
Replace with:
"
),
""
,
function
(
text
)
{
text
=
parseString
(
text
)
if
(
all
)
{
replaceAll
(
cm
,
query
,
text
)
}
else
{
clearSearch
(
cm
);
var
cursor
=
getSearchCursor
(
cm
,
query
,
cm
.
getCursor
(
"
from
"
));
var
advance
=
function
()
{
var
start
=
cursor
.
from
(),
match
;
if
(
!
(
match
=
cursor
.
findNext
()))
{
cursor
=
getSearchCursor
(
cm
,
query
);
if
(
!
(
match
=
cursor
.
findNext
())
||
(
start
&&
cursor
.
from
().
line
==
start
.
line
&&
cursor
.
from
().
ch
==
start
.
ch
))
return
;
}
cm
.
setSelection
(
cursor
.
from
(),
cursor
.
to
());
cm
.
scrollIntoView
({
from
:
cursor
.
from
(),
to
:
cursor
.
to
()});
confirmDialog
(
cm
,
getDoReplaceConfirm
(
cm
),
cm
.
phrase
(
"
Replace?
"
),
[
function
()
{
doReplace
(
match
);},
advance
,
function
()
{
replaceAll
(
cm
,
query
,
text
)}]);
};
var
doReplace
=
function
(
match
)
{
cursor
.
replace
(
typeof
query
==
"
string
"
?
text
:
text
.
replace
(
/
\$(\d)
/g
,
function
(
_
,
i
)
{
return
match
[
i
];}));
advance
();
};
advance
();
}
});
});
}
CodeMirror
.
commands
.
find
=
function
(
cm
)
{
clearSearch
(
cm
);
doSearch
(
cm
);};
CodeMirror
.
commands
.
findPersistent
=
function
(
cm
)
{
clearSearch
(
cm
);
doSearch
(
cm
,
false
,
true
);};
CodeMirror
.
commands
.
findPersistentNext
=
function
(
cm
)
{
doSearch
(
cm
,
false
,
true
,
true
);};
CodeMirror
.
commands
.
findPersistentPrev
=
function
(
cm
)
{
doSearch
(
cm
,
true
,
true
,
true
);};
CodeMirror
.
commands
.
findNext
=
doSearch
;
CodeMirror
.
commands
.
findPrev
=
function
(
cm
)
{
doSearch
(
cm
,
true
);};
CodeMirror
.
commands
.
clearSearch
=
clearSearch
;
CodeMirror
.
commands
.
replace
=
replace
;
CodeMirror
.
commands
.
replaceAll
=
function
(
cm
)
{
replace
(
cm
,
true
);};
});
Prev
1
2
3
4
5
6
7
…
14
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment