@muze-nl/simplystore 0.3.6 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/package.json~ +33 -0
- package/src/server.mjs +68 -61
- package/www/codemirror/addon/comment/comment.js +0 -211
- package/www/codemirror/addon/comment/continuecomment.js +0 -114
- package/www/codemirror/addon/dialog/dialog.css +0 -32
- package/www/codemirror/addon/dialog/dialog.js +0 -163
- package/www/codemirror/addon/display/autorefresh.js +0 -47
- package/www/codemirror/addon/display/fullscreen.css +0 -6
- package/www/codemirror/addon/display/fullscreen.js +0 -41
- package/www/codemirror/addon/display/panel.js +0 -133
- package/www/codemirror/addon/display/placeholder.js +0 -78
- package/www/codemirror/addon/display/rulers.js +0 -51
- package/www/codemirror/addon/edit/closebrackets.js +0 -201
- package/www/codemirror/addon/edit/closetag.js +0 -185
- package/www/codemirror/addon/edit/continuelist.js +0 -101
- package/www/codemirror/addon/edit/matchbrackets.js +0 -160
- package/www/codemirror/addon/edit/matchtags.js +0 -66
- package/www/codemirror/addon/edit/trailingspace.js +0 -27
- package/www/codemirror/addon/fold/brace-fold.js +0 -119
- package/www/codemirror/addon/fold/comment-fold.js +0 -59
- package/www/codemirror/addon/fold/foldcode.js +0 -159
- package/www/codemirror/addon/fold/foldgutter.css +0 -20
- package/www/codemirror/addon/fold/foldgutter.js +0 -169
- package/www/codemirror/addon/fold/indent-fold.js +0 -48
- package/www/codemirror/addon/fold/markdown-fold.js +0 -49
- package/www/codemirror/addon/fold/xml-fold.js +0 -184
- package/www/codemirror/addon/hint/anyword-hint.js +0 -41
- package/www/codemirror/addon/hint/css-hint.js +0 -66
- package/www/codemirror/addon/hint/html-hint.js +0 -351
- package/www/codemirror/addon/hint/javascript-hint.js +0 -162
- package/www/codemirror/addon/hint/show-hint.css +0 -37
- package/www/codemirror/addon/hint/show-hint.js +0 -523
- package/www/codemirror/addon/hint/sql-hint.js +0 -304
- package/www/codemirror/addon/hint/xml-hint.js +0 -132
- package/www/codemirror/addon/lint/coffeescript-lint.js +0 -47
- package/www/codemirror/addon/lint/css-lint.js +0 -40
- package/www/codemirror/addon/lint/html-lint.js +0 -59
- package/www/codemirror/addon/lint/json-lint.js +0 -40
- package/www/codemirror/addon/lint/yaml-lint.js +0 -41
- package/www/codemirror/addon/merge/merge.css +0 -119
- package/www/codemirror/addon/merge/merge.js +0 -1018
- package/www/codemirror/addon/mode/loadmode.js +0 -66
- package/www/codemirror/addon/mode/multiplex.js +0 -136
- package/www/codemirror/addon/mode/multiplex_test.js +0 -49
- package/www/codemirror/addon/mode/overlay.js +0 -90
- package/www/codemirror/addon/mode/simple.js +0 -216
- package/www/codemirror/addon/runmode/colorize.js +0 -40
- package/www/codemirror/addon/runmode/runmode-standalone.js +0 -334
- package/www/codemirror/addon/runmode/runmode.js +0 -76
- package/www/codemirror/addon/runmode/runmode.node.js +0 -329
- package/www/codemirror/addon/scroll/annotatescrollbar.js +0 -128
- package/www/codemirror/addon/scroll/scrollpastend.js +0 -48
- package/www/codemirror/addon/scroll/simplescrollbars.css +0 -66
- package/www/codemirror/addon/scroll/simplescrollbars.js +0 -152
- package/www/codemirror/addon/search/jump-to-line.js +0 -53
- package/www/codemirror/addon/search/match-highlighter.js +0 -167
- package/www/codemirror/addon/search/matchesonscrollbar.css +0 -8
- package/www/codemirror/addon/search/matchesonscrollbar.js +0 -97
- package/www/codemirror/addon/search/search.js +0 -295
- package/www/codemirror/addon/search/searchcursor.js +0 -305
- package/www/codemirror/addon/selection/active-line.js +0 -72
- package/www/codemirror/addon/selection/mark-selection.js +0 -119
- package/www/codemirror/addon/selection/selection-pointer.js +0 -98
- package/www/codemirror/addon/tern/tern.css +0 -87
- package/www/codemirror/addon/tern/tern.js +0 -756
- package/www/codemirror/addon/tern/worker.js +0 -44
- package/www/codemirror/addon/wrap/hardwrap.js +0 -160
- package/www/codemirror/bin/source-highlight +0 -48
- package/www/codemirror/keymap/emacs.js +0 -545
- package/www/codemirror/keymap/sublime.js +0 -720
- package/www/codemirror/keymap/vim.js +0 -5978
- package/www/codemirror/mode/apl/apl.js +0 -174
- package/www/codemirror/mode/asciiarmor/asciiarmor.js +0 -74
- package/www/codemirror/mode/asn.1/asn.1.js +0 -204
- package/www/codemirror/mode/asterisk/asterisk.js +0 -220
- package/www/codemirror/mode/brainfuck/brainfuck.js +0 -85
- package/www/codemirror/mode/clike/clike.js +0 -940
- package/www/codemirror/mode/clojure/clojure.js +0 -292
- package/www/codemirror/mode/cmake/cmake.js +0 -97
- package/www/codemirror/mode/cobol/cobol.js +0 -255
- package/www/codemirror/mode/coffeescript/coffeescript.js +0 -359
- package/www/codemirror/mode/commonlisp/commonlisp.js +0 -125
- package/www/codemirror/mode/crystal/crystal.js +0 -433
- package/www/codemirror/mode/css/css.js +0 -862
- package/www/codemirror/mode/cypher/cypher.js +0 -152
- package/www/codemirror/mode/d/d.js +0 -223
- package/www/codemirror/mode/dart/dart.js +0 -166
- package/www/codemirror/mode/diff/diff.js +0 -47
- package/www/codemirror/mode/django/django.js +0 -356
- package/www/codemirror/mode/dockerfile/dockerfile.js +0 -211
- package/www/codemirror/mode/dtd/dtd.js +0 -142
- package/www/codemirror/mode/dylan/dylan.js +0 -352
- package/www/codemirror/mode/ebnf/ebnf.js +0 -195
- package/www/codemirror/mode/ecl/ecl.js +0 -206
- package/www/codemirror/mode/eiffel/eiffel.js +0 -160
- package/www/codemirror/mode/elm/elm.js +0 -245
- package/www/codemirror/mode/erlang/erlang.js +0 -619
- package/www/codemirror/mode/factor/factor.js +0 -85
- package/www/codemirror/mode/fcl/fcl.js +0 -173
- package/www/codemirror/mode/forth/forth.js +0 -180
- package/www/codemirror/mode/fortran/fortran.js +0 -188
- package/www/codemirror/mode/gas/gas.js +0 -353
- package/www/codemirror/mode/gfm/gfm.js +0 -129
- package/www/codemirror/mode/gherkin/gherkin.js +0 -178
- package/www/codemirror/mode/go/go.js +0 -187
- package/www/codemirror/mode/groovy/groovy.js +0 -247
- package/www/codemirror/mode/haml/haml.js +0 -161
- package/www/codemirror/mode/handlebars/handlebars.js +0 -70
- package/www/codemirror/mode/haskell/haskell.js +0 -268
- package/www/codemirror/mode/haskell-literate/haskell-literate.js +0 -43
- package/www/codemirror/mode/haxe/haxe.js +0 -515
- package/www/codemirror/mode/htmlembedded/htmlembedded.js +0 -37
- package/www/codemirror/mode/htmlmixed/htmlmixed.js +0 -153
- package/www/codemirror/mode/http/http.js +0 -113
- package/www/codemirror/mode/idl/idl.js +0 -290
- package/www/codemirror/mode/jinja2/jinja2.js +0 -193
- package/www/codemirror/mode/jsx/jsx.js +0 -148
- package/www/codemirror/mode/julia/julia.js +0 -390
- package/www/codemirror/mode/livescript/livescript.js +0 -280
- package/www/codemirror/mode/lua/lua.js +0 -160
- package/www/codemirror/mode/markdown/markdown.js +0 -886
- package/www/codemirror/mode/mathematica/mathematica.js +0 -176
- package/www/codemirror/mode/mbox/mbox.js +0 -129
- package/www/codemirror/mode/meta.js +0 -221
- package/www/codemirror/mode/mirc/mirc.js +0 -193
- package/www/codemirror/mode/mllike/mllike.js +0 -359
- package/www/codemirror/mode/modelica/modelica.js +0 -245
- package/www/codemirror/mode/mscgen/mscgen.js +0 -175
- package/www/codemirror/mode/mumps/mumps.js +0 -148
- package/www/codemirror/mode/nginx/nginx.js +0 -178
- package/www/codemirror/mode/nsis/nsis.js +0 -95
- package/www/codemirror/mode/ntriples/ntriples.js +0 -195
- package/www/codemirror/mode/octave/octave.js +0 -139
- package/www/codemirror/mode/oz/oz.js +0 -252
- package/www/codemirror/mode/pascal/pascal.js +0 -136
- package/www/codemirror/mode/pegjs/pegjs.js +0 -111
- package/www/codemirror/mode/perl/perl.js +0 -836
- package/www/codemirror/mode/php/php.js +0 -234
- package/www/codemirror/mode/pig/pig.js +0 -178
- package/www/codemirror/mode/powershell/powershell.js +0 -398
- package/www/codemirror/mode/properties/properties.js +0 -78
- package/www/codemirror/mode/protobuf/protobuf.js +0 -72
- package/www/codemirror/mode/pug/pug.js +0 -591
- package/www/codemirror/mode/puppet/puppet.js +0 -220
- package/www/codemirror/mode/python/python.js +0 -402
- package/www/codemirror/mode/q/q.js +0 -139
- package/www/codemirror/mode/r/r.js +0 -190
- package/www/codemirror/mode/rpm/changes/index.html +0 -66
- package/www/codemirror/mode/rpm/rpm.js +0 -109
- package/www/codemirror/mode/rst/rst.js +0 -557
- package/www/codemirror/mode/ruby/ruby.js +0 -303
- package/www/codemirror/mode/rust/rust.js +0 -72
- package/www/codemirror/mode/sas/sas.js +0 -303
- package/www/codemirror/mode/sass/sass.js +0 -459
- package/www/codemirror/mode/scheme/scheme.js +0 -284
- package/www/codemirror/mode/shell/shell.js +0 -168
- package/www/codemirror/mode/sieve/sieve.js +0 -193
- package/www/codemirror/mode/slim/slim.js +0 -575
- package/www/codemirror/mode/smalltalk/smalltalk.js +0 -168
- package/www/codemirror/mode/smarty/smarty.js +0 -225
- package/www/codemirror/mode/solr/solr.js +0 -104
- package/www/codemirror/mode/soy/soy.js +0 -665
- package/www/codemirror/mode/sparql/sparql.js +0 -184
- package/www/codemirror/mode/spreadsheet/spreadsheet.js +0 -112
- package/www/codemirror/mode/sql/sql.js +0 -525
- package/www/codemirror/mode/stex/stex.js +0 -264
- package/www/codemirror/mode/stylus/stylus.js +0 -775
- package/www/codemirror/mode/swift/swift.js +0 -221
- package/www/codemirror/mode/tcl/tcl.js +0 -140
- package/www/codemirror/mode/textile/textile.js +0 -469
- package/www/codemirror/mode/tiddlywiki/tiddlywiki.css +0 -14
- package/www/codemirror/mode/tiddlywiki/tiddlywiki.js +0 -308
- package/www/codemirror/mode/tiki/tiki.css +0 -26
- package/www/codemirror/mode/tiki/tiki.js +0 -312
- package/www/codemirror/mode/toml/toml.js +0 -88
- package/www/codemirror/mode/tornado/tornado.js +0 -68
- package/www/codemirror/mode/troff/troff.js +0 -84
- package/www/codemirror/mode/ttcn/ttcn.js +0 -283
- package/www/codemirror/mode/ttcn-cfg/ttcn-cfg.js +0 -214
- package/www/codemirror/mode/turtle/turtle.js +0 -162
- package/www/codemirror/mode/twig/twig.js +0 -141
- package/www/codemirror/mode/vb/vb.js +0 -275
- package/www/codemirror/mode/vbscript/vbscript.js +0 -350
- package/www/codemirror/mode/velocity/velocity.js +0 -202
- package/www/codemirror/mode/verilog/verilog.js +0 -781
- package/www/codemirror/mode/vhdl/vhdl.js +0 -189
- package/www/codemirror/mode/vue/vue.js +0 -77
- package/www/codemirror/mode/wast/wast.js +0 -132
- package/www/codemirror/mode/webidl/webidl.js +0 -195
- package/www/codemirror/mode/xml/xml.js +0 -417
- package/www/codemirror/mode/xquery/xquery.js +0 -448
- package/www/codemirror/mode/yacas/yacas.js +0 -204
- package/www/codemirror/mode/yaml/yaml.js +0 -120
- package/www/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js +0 -72
- package/www/codemirror/mode/z80/z80.js +0 -116
- package/www/codemirror/rollup.config.js +0 -52
- package/www/codemirror/src/addon/runmode/codemirror-standalone.js +0 -24
- package/www/codemirror/src/addon/runmode/codemirror.node.js +0 -21
- package/www/codemirror/src/addon/runmode/runmode-standalone.js +0 -2
- package/www/codemirror/src/addon/runmode/runmode.node.js +0 -2
- package/www/codemirror/src/codemirror.js +0 -3
- package/www/codemirror/src/display/Display.js +0 -116
- package/www/codemirror/src/display/focus.js +0 -50
- package/www/codemirror/src/display/gutters.js +0 -44
- package/www/codemirror/src/display/highlight_worker.js +0 -55
- package/www/codemirror/src/display/line_numbers.js +0 -48
- package/www/codemirror/src/display/mode_state.js +0 -22
- package/www/codemirror/src/display/operations.js +0 -206
- package/www/codemirror/src/display/scroll_events.js +0 -132
- package/www/codemirror/src/display/scrollbars.js +0 -194
- package/www/codemirror/src/display/scrolling.js +0 -186
- package/www/codemirror/src/display/selection.js +0 -173
- package/www/codemirror/src/display/update_display.js +0 -267
- package/www/codemirror/src/display/update_line.js +0 -189
- package/www/codemirror/src/display/update_lines.js +0 -82
- package/www/codemirror/src/display/view_tracking.js +0 -153
- package/www/codemirror/src/edit/CodeMirror.js +0 -217
- package/www/codemirror/src/edit/commands.js +0 -178
- package/www/codemirror/src/edit/deleteNearSelection.js +0 -30
- package/www/codemirror/src/edit/drop_events.js +0 -130
- package/www/codemirror/src/edit/fromTextArea.js +0 -61
- package/www/codemirror/src/edit/global_events.js +0 -45
- package/www/codemirror/src/edit/key_events.js +0 -163
- package/www/codemirror/src/edit/legacy.js +0 -62
- package/www/codemirror/src/edit/main.js +0 -69
- package/www/codemirror/src/edit/methods.js +0 -555
- package/www/codemirror/src/edit/mouse_events.js +0 -417
- package/www/codemirror/src/edit/options.js +0 -194
- package/www/codemirror/src/edit/utils.js +0 -7
- package/www/codemirror/src/input/ContentEditableInput.js +0 -546
- package/www/codemirror/src/input/TextareaInput.js +0 -380
- package/www/codemirror/src/input/indent.js +0 -71
- package/www/codemirror/src/input/input.js +0 -134
- package/www/codemirror/src/input/keymap.js +0 -147
- package/www/codemirror/src/input/keynames.js +0 -17
- package/www/codemirror/src/input/movement.js +0 -111
- package/www/codemirror/src/line/highlight.js +0 -284
- package/www/codemirror/src/line/line_data.js +0 -349
- package/www/codemirror/src/line/pos.js +0 -40
- package/www/codemirror/src/line/saw_special_spans.js +0 -10
- package/www/codemirror/src/line/spans.js +0 -390
- package/www/codemirror/src/line/utils_line.js +0 -85
- package/www/codemirror/src/measurement/position_measurement.js +0 -702
- package/www/codemirror/src/measurement/widgets.js +0 -26
- package/www/codemirror/src/model/Doc.js +0 -436
- package/www/codemirror/src/model/change_measurement.js +0 -61
- package/www/codemirror/src/model/changes.js +0 -339
- package/www/codemirror/src/model/chunk.js +0 -167
- package/www/codemirror/src/model/document_data.js +0 -112
- package/www/codemirror/src/model/history.js +0 -228
- package/www/codemirror/src/model/line_widget.js +0 -78
- package/www/codemirror/src/model/mark_text.js +0 -293
- package/www/codemirror/src/model/selection.js +0 -84
- package/www/codemirror/src/model/selection_updates.js +0 -216
- package/www/codemirror/src/modes.js +0 -96
- package/www/codemirror/src/util/StringStream.js +0 -90
- package/www/codemirror/src/util/bidi.js +0 -215
- package/www/codemirror/src/util/browser.js +0 -34
- package/www/codemirror/src/util/dom.js +0 -101
- package/www/codemirror/src/util/event.js +0 -103
- package/www/codemirror/src/util/feature_detection.js +0 -84
- package/www/codemirror/src/util/misc.js +0 -168
- package/www/codemirror/src/util/operation_group.js +0 -72
- package/www/codemirror/theme/3024-day.css +0 -41
- package/www/codemirror/theme/3024-night.css +0 -39
- package/www/codemirror/theme/abbott.css +0 -268
- package/www/codemirror/theme/abcdef.css +0 -32
- package/www/codemirror/theme/ambiance-mobile.css +0 -5
- package/www/codemirror/theme/ambiance.css +0 -74
- package/www/codemirror/theme/ayu-dark.css +0 -44
- package/www/codemirror/theme/ayu-mirage.css +0 -45
- package/www/codemirror/theme/base16-dark.css +0 -40
- package/www/codemirror/theme/base16-light.css +0 -38
- package/www/codemirror/theme/bespin.css +0 -34
- package/www/codemirror/theme/blackboard.css +0 -32
- package/www/codemirror/theme/cobalt.css +0 -25
- package/www/codemirror/theme/colorforth.css +0 -33
- package/www/codemirror/theme/darcula.css +0 -53
- package/www/codemirror/theme/dracula.css +0 -40
- package/www/codemirror/theme/duotone-dark.css +0 -35
- package/www/codemirror/theme/duotone-light.css +0 -36
- package/www/codemirror/theme/eclipse.css +0 -23
- package/www/codemirror/theme/elegant.css +0 -13
- package/www/codemirror/theme/erlang-dark.css +0 -34
- package/www/codemirror/theme/gruvbox-dark.css +0 -39
- package/www/codemirror/theme/hopscotch.css +0 -34
- package/www/codemirror/theme/icecoder.css +0 -43
- package/www/codemirror/theme/idea.css +0 -42
- package/www/codemirror/theme/isotope.css +0 -34
- package/www/codemirror/theme/juejin.css +0 -30
- package/www/codemirror/theme/lesser-dark.css +0 -47
- package/www/codemirror/theme/liquibyte.css +0 -95
- package/www/codemirror/theme/lucario.css +0 -37
- package/www/codemirror/theme/material-darker.css +0 -135
- package/www/codemirror/theme/material-palenight.css +0 -141
- package/www/codemirror/theme/material.css +0 -141
- package/www/codemirror/theme/mbo.css +0 -37
- package/www/codemirror/theme/mdn-like.css +0 -46
- package/www/codemirror/theme/midnight.css +0 -39
- package/www/codemirror/theme/monokai.css +0 -41
- package/www/codemirror/theme/moxer.css +0 -143
- package/www/codemirror/theme/neat.css +0 -12
- package/www/codemirror/theme/neo.css +0 -43
- package/www/codemirror/theme/night.css +0 -27
- package/www/codemirror/theme/nord.css +0 -42
- package/www/codemirror/theme/oceanic-next.css +0 -46
- package/www/codemirror/theme/panda-syntax.css +0 -85
- package/www/codemirror/theme/paraiso-dark.css +0 -38
- package/www/codemirror/theme/paraiso-light.css +0 -38
- package/www/codemirror/theme/pastel-on-dark.css +0 -52
- package/www/codemirror/theme/railscasts.css +0 -34
- package/www/codemirror/theme/rubyblue.css +0 -25
- package/www/codemirror/theme/seti.css +0 -44
- package/www/codemirror/theme/shadowfox.css +0 -52
- package/www/codemirror/theme/solarized.css +0 -165
- package/www/codemirror/theme/ssms.css +0 -16
- package/www/codemirror/theme/the-matrix.css +0 -30
- package/www/codemirror/theme/tomorrow-night-bright.css +0 -35
- package/www/codemirror/theme/tomorrow-night-eighties.css +0 -38
- package/www/codemirror/theme/ttcn.css +0 -64
- package/www/codemirror/theme/twilight.css +0 -32
- package/www/codemirror/theme/vibrant-ink.css +0 -34
- package/www/codemirror/theme/xq-dark.css +0 -53
- package/www/codemirror/theme/xq-light.css +0 -43
- package/www/codemirror/theme/yeti.css +0 -44
- package/www/codemirror/theme/yonce.css +0 -59
- package/www/codemirror/theme/zenburn.css +0 -37
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { Pos } from "../line/pos.js"
|
|
2
|
-
import { cursorCoords, displayHeight, displayWidth, estimateCoords, paddingTop, paddingVert, scrollGap, textHeight } from "../measurement/position_measurement.js"
|
|
3
|
-
import { gecko, phantom } from "../util/browser.js"
|
|
4
|
-
import { elt } from "../util/dom.js"
|
|
5
|
-
import { signalDOMEvent } from "../util/event.js"
|
|
6
|
-
|
|
7
|
-
import { startWorker } from "./highlight_worker.js"
|
|
8
|
-
import { alignHorizontally } from "./line_numbers.js"
|
|
9
|
-
import { updateDisplaySimple } from "./update_display.js"
|
|
10
|
-
|
|
11
|
-
// SCROLLING THINGS INTO VIEW
|
|
12
|
-
|
|
13
|
-
// If an editor sits on the top or bottom of the window, partially
|
|
14
|
-
// scrolled out of view, this ensures that the cursor is visible.
|
|
15
|
-
export function maybeScrollWindow(cm, rect) {
|
|
16
|
-
if (signalDOMEvent(cm, "scrollCursorIntoView")) return
|
|
17
|
-
|
|
18
|
-
let display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null
|
|
19
|
-
let doc = display.wrapper.ownerDocument
|
|
20
|
-
if (rect.top + box.top < 0) doScroll = true
|
|
21
|
-
else if (rect.bottom + box.top > (doc.defaultView.innerHeight || doc.documentElement.clientHeight)) doScroll = false
|
|
22
|
-
if (doScroll != null && !phantom) {
|
|
23
|
-
let scrollNode = elt("div", "\u200b", null, `position: absolute;
|
|
24
|
-
top: ${rect.top - display.viewOffset - paddingTop(cm.display)}px;
|
|
25
|
-
height: ${rect.bottom - rect.top + scrollGap(cm) + display.barHeight}px;
|
|
26
|
-
left: ${rect.left}px; width: ${Math.max(2, rect.right - rect.left)}px;`)
|
|
27
|
-
cm.display.lineSpace.appendChild(scrollNode)
|
|
28
|
-
scrollNode.scrollIntoView(doScroll)
|
|
29
|
-
cm.display.lineSpace.removeChild(scrollNode)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Scroll a given position into view (immediately), verifying that
|
|
34
|
-
// it actually became visible (as line heights are accurately
|
|
35
|
-
// measured, the position of something may 'drift' during drawing).
|
|
36
|
-
export function scrollPosIntoView(cm, pos, end, margin) {
|
|
37
|
-
if (margin == null) margin = 0
|
|
38
|
-
let rect
|
|
39
|
-
if (!cm.options.lineWrapping && pos == end) {
|
|
40
|
-
// Set pos and end to the cursor positions around the character pos sticks to
|
|
41
|
-
// If pos.sticky == "before", that is around pos.ch - 1, otherwise around pos.ch
|
|
42
|
-
// If pos == Pos(_, 0, "before"), pos and end are unchanged
|
|
43
|
-
end = pos.sticky == "before" ? Pos(pos.line, pos.ch + 1, "before") : pos
|
|
44
|
-
pos = pos.ch ? Pos(pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after") : pos
|
|
45
|
-
}
|
|
46
|
-
for (let limit = 0; limit < 5; limit++) {
|
|
47
|
-
let changed = false
|
|
48
|
-
let coords = cursorCoords(cm, pos)
|
|
49
|
-
let endCoords = !end || end == pos ? coords : cursorCoords(cm, end)
|
|
50
|
-
rect = {left: Math.min(coords.left, endCoords.left),
|
|
51
|
-
top: Math.min(coords.top, endCoords.top) - margin,
|
|
52
|
-
right: Math.max(coords.left, endCoords.left),
|
|
53
|
-
bottom: Math.max(coords.bottom, endCoords.bottom) + margin}
|
|
54
|
-
let scrollPos = calculateScrollPos(cm, rect)
|
|
55
|
-
let startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft
|
|
56
|
-
if (scrollPos.scrollTop != null) {
|
|
57
|
-
updateScrollTop(cm, scrollPos.scrollTop)
|
|
58
|
-
if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true
|
|
59
|
-
}
|
|
60
|
-
if (scrollPos.scrollLeft != null) {
|
|
61
|
-
setScrollLeft(cm, scrollPos.scrollLeft)
|
|
62
|
-
if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true
|
|
63
|
-
}
|
|
64
|
-
if (!changed) break
|
|
65
|
-
}
|
|
66
|
-
return rect
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Scroll a given set of coordinates into view (immediately).
|
|
70
|
-
export function scrollIntoView(cm, rect) {
|
|
71
|
-
let scrollPos = calculateScrollPos(cm, rect)
|
|
72
|
-
if (scrollPos.scrollTop != null) updateScrollTop(cm, scrollPos.scrollTop)
|
|
73
|
-
if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Calculate a new scroll position needed to scroll the given
|
|
77
|
-
// rectangle into view. Returns an object with scrollTop and
|
|
78
|
-
// scrollLeft properties. When these are undefined, the
|
|
79
|
-
// vertical/horizontal position does not need to be adjusted.
|
|
80
|
-
function calculateScrollPos(cm, rect) {
|
|
81
|
-
let display = cm.display, snapMargin = textHeight(cm.display)
|
|
82
|
-
if (rect.top < 0) rect.top = 0
|
|
83
|
-
let screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop
|
|
84
|
-
let screen = displayHeight(cm), result = {}
|
|
85
|
-
if (rect.bottom - rect.top > screen) rect.bottom = rect.top + screen
|
|
86
|
-
let docBottom = cm.doc.height + paddingVert(display)
|
|
87
|
-
let atTop = rect.top < snapMargin, atBottom = rect.bottom > docBottom - snapMargin
|
|
88
|
-
if (rect.top < screentop) {
|
|
89
|
-
result.scrollTop = atTop ? 0 : rect.top
|
|
90
|
-
} else if (rect.bottom > screentop + screen) {
|
|
91
|
-
let newTop = Math.min(rect.top, (atBottom ? docBottom : rect.bottom) - screen)
|
|
92
|
-
if (newTop != screentop) result.scrollTop = newTop
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
let gutterSpace = cm.options.fixedGutter ? 0 : display.gutters.offsetWidth
|
|
96
|
-
let screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft - gutterSpace
|
|
97
|
-
let screenw = displayWidth(cm) - display.gutters.offsetWidth
|
|
98
|
-
let tooWide = rect.right - rect.left > screenw
|
|
99
|
-
if (tooWide) rect.right = rect.left + screenw
|
|
100
|
-
if (rect.left < 10)
|
|
101
|
-
result.scrollLeft = 0
|
|
102
|
-
else if (rect.left < screenleft)
|
|
103
|
-
result.scrollLeft = Math.max(0, rect.left + gutterSpace - (tooWide ? 0 : 10))
|
|
104
|
-
else if (rect.right > screenw + screenleft - 3)
|
|
105
|
-
result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw
|
|
106
|
-
return result
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Store a relative adjustment to the scroll position in the current
|
|
110
|
-
// operation (to be applied when the operation finishes).
|
|
111
|
-
export function addToScrollTop(cm, top) {
|
|
112
|
-
if (top == null) return
|
|
113
|
-
resolveScrollToPos(cm)
|
|
114
|
-
cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Make sure that at the end of the operation the current cursor is
|
|
118
|
-
// shown.
|
|
119
|
-
export function ensureCursorVisible(cm) {
|
|
120
|
-
resolveScrollToPos(cm)
|
|
121
|
-
let cur = cm.getCursor()
|
|
122
|
-
cm.curOp.scrollToPos = {from: cur, to: cur, margin: cm.options.cursorScrollMargin}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export function scrollToCoords(cm, x, y) {
|
|
126
|
-
if (x != null || y != null) resolveScrollToPos(cm)
|
|
127
|
-
if (x != null) cm.curOp.scrollLeft = x
|
|
128
|
-
if (y != null) cm.curOp.scrollTop = y
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export function scrollToRange(cm, range) {
|
|
132
|
-
resolveScrollToPos(cm)
|
|
133
|
-
cm.curOp.scrollToPos = range
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// When an operation has its scrollToPos property set, and another
|
|
137
|
-
// scroll action is applied before the end of the operation, this
|
|
138
|
-
// 'simulates' scrolling that position into view in a cheap way, so
|
|
139
|
-
// that the effect of intermediate scroll commands is not ignored.
|
|
140
|
-
function resolveScrollToPos(cm) {
|
|
141
|
-
let range = cm.curOp.scrollToPos
|
|
142
|
-
if (range) {
|
|
143
|
-
cm.curOp.scrollToPos = null
|
|
144
|
-
let from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to)
|
|
145
|
-
scrollToCoordsRange(cm, from, to, range.margin)
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export function scrollToCoordsRange(cm, from, to, margin) {
|
|
150
|
-
let sPos = calculateScrollPos(cm, {
|
|
151
|
-
left: Math.min(from.left, to.left),
|
|
152
|
-
top: Math.min(from.top, to.top) - margin,
|
|
153
|
-
right: Math.max(from.right, to.right),
|
|
154
|
-
bottom: Math.max(from.bottom, to.bottom) + margin
|
|
155
|
-
})
|
|
156
|
-
scrollToCoords(cm, sPos.scrollLeft, sPos.scrollTop)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// Sync the scrollable area and scrollbars, ensure the viewport
|
|
160
|
-
// covers the visible area.
|
|
161
|
-
export function updateScrollTop(cm, val) {
|
|
162
|
-
if (Math.abs(cm.doc.scrollTop - val) < 2) return
|
|
163
|
-
if (!gecko) updateDisplaySimple(cm, {top: val})
|
|
164
|
-
setScrollTop(cm, val, true)
|
|
165
|
-
if (gecko) updateDisplaySimple(cm)
|
|
166
|
-
startWorker(cm, 100)
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export function setScrollTop(cm, val, forceScroll) {
|
|
170
|
-
val = Math.max(0, Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val))
|
|
171
|
-
if (cm.display.scroller.scrollTop == val && !forceScroll) return
|
|
172
|
-
cm.doc.scrollTop = val
|
|
173
|
-
cm.display.scrollbars.setScrollTop(val)
|
|
174
|
-
if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// Sync scroller and scrollbar, ensure the gutter elements are
|
|
178
|
-
// aligned.
|
|
179
|
-
export function setScrollLeft(cm, val, isScroller, forceScroll) {
|
|
180
|
-
val = Math.max(0, Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth))
|
|
181
|
-
if ((isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll) return
|
|
182
|
-
cm.doc.scrollLeft = val
|
|
183
|
-
alignHorizontally(cm)
|
|
184
|
-
if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val
|
|
185
|
-
cm.display.scrollbars.setScrollLeft(val)
|
|
186
|
-
}
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { Pos } from "../line/pos.js"
|
|
2
|
-
import { visualLine } from "../line/spans.js"
|
|
3
|
-
import { getLine } from "../line/utils_line.js"
|
|
4
|
-
import { charCoords, cursorCoords, displayWidth, paddingH, wrappedLineExtentChar } from "../measurement/position_measurement.js"
|
|
5
|
-
import { getOrder, iterateBidiSections } from "../util/bidi.js"
|
|
6
|
-
import { elt } from "../util/dom.js"
|
|
7
|
-
import { onBlur } from "./focus.js"
|
|
8
|
-
|
|
9
|
-
export function updateSelection(cm) {
|
|
10
|
-
cm.display.input.showSelection(cm.display.input.prepareSelection())
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function prepareSelection(cm, primary = true) {
|
|
14
|
-
let doc = cm.doc, result = {}
|
|
15
|
-
let curFragment = result.cursors = document.createDocumentFragment()
|
|
16
|
-
let selFragment = result.selection = document.createDocumentFragment()
|
|
17
|
-
|
|
18
|
-
let customCursor = cm.options.$customCursor
|
|
19
|
-
if (customCursor) primary = true
|
|
20
|
-
for (let i = 0; i < doc.sel.ranges.length; i++) {
|
|
21
|
-
if (!primary && i == doc.sel.primIndex) continue
|
|
22
|
-
let range = doc.sel.ranges[i]
|
|
23
|
-
if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) continue
|
|
24
|
-
let collapsed = range.empty()
|
|
25
|
-
if (customCursor) {
|
|
26
|
-
let head = customCursor(cm, range)
|
|
27
|
-
if (head) drawSelectionCursor(cm, head, curFragment)
|
|
28
|
-
} else if (collapsed || cm.options.showCursorWhenSelecting) {
|
|
29
|
-
drawSelectionCursor(cm, range.head, curFragment)
|
|
30
|
-
}
|
|
31
|
-
if (!collapsed)
|
|
32
|
-
drawSelectionRange(cm, range, selFragment)
|
|
33
|
-
}
|
|
34
|
-
return result
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Draws a cursor for the given range
|
|
38
|
-
export function drawSelectionCursor(cm, head, output) {
|
|
39
|
-
let pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine)
|
|
40
|
-
|
|
41
|
-
let cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"))
|
|
42
|
-
cursor.style.left = pos.left + "px"
|
|
43
|
-
cursor.style.top = pos.top + "px"
|
|
44
|
-
cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px"
|
|
45
|
-
|
|
46
|
-
if (/\bcm-fat-cursor\b/.test(cm.getWrapperElement().className)) {
|
|
47
|
-
let charPos = charCoords(cm, head, "div", null, null)
|
|
48
|
-
let width = charPos.right - charPos.left
|
|
49
|
-
cursor.style.width = (width > 0 ? width : cm.defaultCharWidth()) + "px"
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (pos.other) {
|
|
53
|
-
// Secondary cursor, shown when on a 'jump' in bi-directional text
|
|
54
|
-
let otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"))
|
|
55
|
-
otherCursor.style.display = ""
|
|
56
|
-
otherCursor.style.left = pos.other.left + "px"
|
|
57
|
-
otherCursor.style.top = pos.other.top + "px"
|
|
58
|
-
otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function cmpCoords(a, b) { return a.top - b.top || a.left - b.left }
|
|
63
|
-
|
|
64
|
-
// Draws the given range as a highlighted selection
|
|
65
|
-
function drawSelectionRange(cm, range, output) {
|
|
66
|
-
let display = cm.display, doc = cm.doc
|
|
67
|
-
let fragment = document.createDocumentFragment()
|
|
68
|
-
let padding = paddingH(cm.display), leftSide = padding.left
|
|
69
|
-
let rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right
|
|
70
|
-
let docLTR = doc.direction == "ltr"
|
|
71
|
-
|
|
72
|
-
function add(left, top, width, bottom) {
|
|
73
|
-
if (top < 0) top = 0
|
|
74
|
-
top = Math.round(top)
|
|
75
|
-
bottom = Math.round(bottom)
|
|
76
|
-
fragment.appendChild(elt("div", null, "CodeMirror-selected", `position: absolute; left: ${left}px;
|
|
77
|
-
top: ${top}px; width: ${width == null ? rightSide - left : width}px;
|
|
78
|
-
height: ${bottom - top}px`))
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function drawForLine(line, fromArg, toArg) {
|
|
82
|
-
let lineObj = getLine(doc, line)
|
|
83
|
-
let lineLen = lineObj.text.length
|
|
84
|
-
let start, end
|
|
85
|
-
function coords(ch, bias) {
|
|
86
|
-
return charCoords(cm, Pos(line, ch), "div", lineObj, bias)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function wrapX(pos, dir, side) {
|
|
90
|
-
let extent = wrappedLineExtentChar(cm, lineObj, null, pos)
|
|
91
|
-
let prop = (dir == "ltr") == (side == "after") ? "left" : "right"
|
|
92
|
-
let ch = side == "after" ? extent.begin : extent.end - (/\s/.test(lineObj.text.charAt(extent.end - 1)) ? 2 : 1)
|
|
93
|
-
return coords(ch, prop)[prop]
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
let order = getOrder(lineObj, doc.direction)
|
|
97
|
-
iterateBidiSections(order, fromArg || 0, toArg == null ? lineLen : toArg, (from, to, dir, i) => {
|
|
98
|
-
let ltr = dir == "ltr"
|
|
99
|
-
let fromPos = coords(from, ltr ? "left" : "right")
|
|
100
|
-
let toPos = coords(to - 1, ltr ? "right" : "left")
|
|
101
|
-
|
|
102
|
-
let openStart = fromArg == null && from == 0, openEnd = toArg == null && to == lineLen
|
|
103
|
-
let first = i == 0, last = !order || i == order.length - 1
|
|
104
|
-
if (toPos.top - fromPos.top <= 3) { // Single line
|
|
105
|
-
let openLeft = (docLTR ? openStart : openEnd) && first
|
|
106
|
-
let openRight = (docLTR ? openEnd : openStart) && last
|
|
107
|
-
let left = openLeft ? leftSide : (ltr ? fromPos : toPos).left
|
|
108
|
-
let right = openRight ? rightSide : (ltr ? toPos : fromPos).right
|
|
109
|
-
add(left, fromPos.top, right - left, fromPos.bottom)
|
|
110
|
-
} else { // Multiple lines
|
|
111
|
-
let topLeft, topRight, botLeft, botRight
|
|
112
|
-
if (ltr) {
|
|
113
|
-
topLeft = docLTR && openStart && first ? leftSide : fromPos.left
|
|
114
|
-
topRight = docLTR ? rightSide : wrapX(from, dir, "before")
|
|
115
|
-
botLeft = docLTR ? leftSide : wrapX(to, dir, "after")
|
|
116
|
-
botRight = docLTR && openEnd && last ? rightSide : toPos.right
|
|
117
|
-
} else {
|
|
118
|
-
topLeft = !docLTR ? leftSide : wrapX(from, dir, "before")
|
|
119
|
-
topRight = !docLTR && openStart && first ? rightSide : fromPos.right
|
|
120
|
-
botLeft = !docLTR && openEnd && last ? leftSide : toPos.left
|
|
121
|
-
botRight = !docLTR ? rightSide : wrapX(to, dir, "after")
|
|
122
|
-
}
|
|
123
|
-
add(topLeft, fromPos.top, topRight - topLeft, fromPos.bottom)
|
|
124
|
-
if (fromPos.bottom < toPos.top) add(leftSide, fromPos.bottom, null, toPos.top)
|
|
125
|
-
add(botLeft, toPos.top, botRight - botLeft, toPos.bottom)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (!start || cmpCoords(fromPos, start) < 0) start = fromPos
|
|
129
|
-
if (cmpCoords(toPos, start) < 0) start = toPos
|
|
130
|
-
if (!end || cmpCoords(fromPos, end) < 0) end = fromPos
|
|
131
|
-
if (cmpCoords(toPos, end) < 0) end = toPos
|
|
132
|
-
})
|
|
133
|
-
return {start: start, end: end}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
let sFrom = range.from(), sTo = range.to()
|
|
137
|
-
if (sFrom.line == sTo.line) {
|
|
138
|
-
drawForLine(sFrom.line, sFrom.ch, sTo.ch)
|
|
139
|
-
} else {
|
|
140
|
-
let fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line)
|
|
141
|
-
let singleVLine = visualLine(fromLine) == visualLine(toLine)
|
|
142
|
-
let leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end
|
|
143
|
-
let rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start
|
|
144
|
-
if (singleVLine) {
|
|
145
|
-
if (leftEnd.top < rightStart.top - 2) {
|
|
146
|
-
add(leftEnd.right, leftEnd.top, null, leftEnd.bottom)
|
|
147
|
-
add(leftSide, rightStart.top, rightStart.left, rightStart.bottom)
|
|
148
|
-
} else {
|
|
149
|
-
add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom)
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
if (leftEnd.bottom < rightStart.top)
|
|
153
|
-
add(leftSide, leftEnd.bottom, null, rightStart.top)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
output.appendChild(fragment)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// Cursor-blinking
|
|
160
|
-
export function restartBlink(cm) {
|
|
161
|
-
if (!cm.state.focused) return
|
|
162
|
-
let display = cm.display
|
|
163
|
-
clearInterval(display.blinker)
|
|
164
|
-
let on = true
|
|
165
|
-
display.cursorDiv.style.visibility = ""
|
|
166
|
-
if (cm.options.cursorBlinkRate > 0)
|
|
167
|
-
display.blinker = setInterval(() => {
|
|
168
|
-
if (!cm.hasFocus()) onBlur(cm)
|
|
169
|
-
display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"
|
|
170
|
-
}, cm.options.cursorBlinkRate)
|
|
171
|
-
else if (cm.options.cursorBlinkRate < 0)
|
|
172
|
-
display.cursorDiv.style.visibility = "hidden"
|
|
173
|
-
}
|
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import { sawCollapsedSpans } from "../line/saw_special_spans.js"
|
|
2
|
-
import { heightAtLine, visualLineEndNo, visualLineNo } from "../line/spans.js"
|
|
3
|
-
import { getLine, lineNumberFor } from "../line/utils_line.js"
|
|
4
|
-
import { displayHeight, displayWidth, getDimensions, paddingVert, scrollGap } from "../measurement/position_measurement.js"
|
|
5
|
-
import { mac, webkit } from "../util/browser.js"
|
|
6
|
-
import { activeElt, removeChildren, contains, win, doc } from "../util/dom.js"
|
|
7
|
-
import { hasHandler, signal } from "../util/event.js"
|
|
8
|
-
import { signalLater } from "../util/operation_group.js"
|
|
9
|
-
import { indexOf } from "../util/misc.js"
|
|
10
|
-
|
|
11
|
-
import { buildLineElement, updateLineForChanges } from "./update_line.js"
|
|
12
|
-
import { startWorker } from "./highlight_worker.js"
|
|
13
|
-
import { maybeUpdateLineNumberWidth } from "./line_numbers.js"
|
|
14
|
-
import { measureForScrollbars, updateScrollbars } from "./scrollbars.js"
|
|
15
|
-
import { updateSelection } from "./selection.js"
|
|
16
|
-
import { updateHeightsInViewport, visibleLines } from "./update_lines.js"
|
|
17
|
-
import { adjustView, countDirtyView, resetView } from "./view_tracking.js"
|
|
18
|
-
|
|
19
|
-
// DISPLAY DRAWING
|
|
20
|
-
|
|
21
|
-
export class DisplayUpdate {
|
|
22
|
-
constructor(cm, viewport, force) {
|
|
23
|
-
let display = cm.display
|
|
24
|
-
|
|
25
|
-
this.viewport = viewport
|
|
26
|
-
// Store some values that we'll need later (but don't want to force a relayout for)
|
|
27
|
-
this.visible = visibleLines(display, cm.doc, viewport)
|
|
28
|
-
this.editorIsHidden = !display.wrapper.offsetWidth
|
|
29
|
-
this.wrapperHeight = display.wrapper.clientHeight
|
|
30
|
-
this.wrapperWidth = display.wrapper.clientWidth
|
|
31
|
-
this.oldDisplayWidth = displayWidth(cm)
|
|
32
|
-
this.force = force
|
|
33
|
-
this.dims = getDimensions(cm)
|
|
34
|
-
this.events = []
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
signal(emitter, type) {
|
|
38
|
-
if (hasHandler(emitter, type))
|
|
39
|
-
this.events.push(arguments)
|
|
40
|
-
}
|
|
41
|
-
finish() {
|
|
42
|
-
for (let i = 0; i < this.events.length; i++)
|
|
43
|
-
signal.apply(null, this.events[i])
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function maybeClipScrollbars(cm) {
|
|
48
|
-
let display = cm.display
|
|
49
|
-
if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
|
|
50
|
-
display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth
|
|
51
|
-
display.heightForcer.style.height = scrollGap(cm) + "px"
|
|
52
|
-
display.sizer.style.marginBottom = -display.nativeBarWidth + "px"
|
|
53
|
-
display.sizer.style.borderRightWidth = scrollGap(cm) + "px"
|
|
54
|
-
display.scrollbarsClipped = true
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function selectionSnapshot(cm) {
|
|
59
|
-
if (cm.hasFocus()) return null
|
|
60
|
-
let active = activeElt(doc(cm))
|
|
61
|
-
if (!active || !contains(cm.display.lineDiv, active)) return null
|
|
62
|
-
let result = {activeElt: active}
|
|
63
|
-
if (window.getSelection) {
|
|
64
|
-
let sel = win(cm).getSelection()
|
|
65
|
-
if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) {
|
|
66
|
-
result.anchorNode = sel.anchorNode
|
|
67
|
-
result.anchorOffset = sel.anchorOffset
|
|
68
|
-
result.focusNode = sel.focusNode
|
|
69
|
-
result.focusOffset = sel.focusOffset
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return result
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function restoreSelection(snapshot) {
|
|
76
|
-
if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt(snapshot.activeElt.ownerDocument)) return
|
|
77
|
-
snapshot.activeElt.focus()
|
|
78
|
-
if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) &&
|
|
79
|
-
snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
|
|
80
|
-
let doc = snapshot.activeElt.ownerDocument
|
|
81
|
-
let sel = doc.defaultView.getSelection(), range = doc.createRange()
|
|
82
|
-
range.setEnd(snapshot.anchorNode, snapshot.anchorOffset)
|
|
83
|
-
range.collapse(false)
|
|
84
|
-
sel.removeAllRanges()
|
|
85
|
-
sel.addRange(range)
|
|
86
|
-
sel.extend(snapshot.focusNode, snapshot.focusOffset)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Does the actual updating of the line display. Bails out
|
|
91
|
-
// (returning false) when there is nothing to be done and forced is
|
|
92
|
-
// false.
|
|
93
|
-
export function updateDisplayIfNeeded(cm, update) {
|
|
94
|
-
let display = cm.display, doc = cm.doc
|
|
95
|
-
|
|
96
|
-
if (update.editorIsHidden) {
|
|
97
|
-
resetView(cm)
|
|
98
|
-
return false
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Bail out if the visible area is already rendered and nothing changed.
|
|
102
|
-
if (!update.force &&
|
|
103
|
-
update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
|
|
104
|
-
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
|
|
105
|
-
display.renderedView == display.view && countDirtyView(cm) == 0)
|
|
106
|
-
return false
|
|
107
|
-
|
|
108
|
-
if (maybeUpdateLineNumberWidth(cm)) {
|
|
109
|
-
resetView(cm)
|
|
110
|
-
update.dims = getDimensions(cm)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Compute a suitable new viewport (from & to)
|
|
114
|
-
let end = doc.first + doc.size
|
|
115
|
-
let from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first)
|
|
116
|
-
let to = Math.min(end, update.visible.to + cm.options.viewportMargin)
|
|
117
|
-
if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom)
|
|
118
|
-
if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo)
|
|
119
|
-
if (sawCollapsedSpans) {
|
|
120
|
-
from = visualLineNo(cm.doc, from)
|
|
121
|
-
to = visualLineEndNo(cm.doc, to)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
let different = from != display.viewFrom || to != display.viewTo ||
|
|
125
|
-
display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth
|
|
126
|
-
adjustView(cm, from, to)
|
|
127
|
-
|
|
128
|
-
display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom))
|
|
129
|
-
// Position the mover div to align with the current scroll position
|
|
130
|
-
cm.display.mover.style.top = display.viewOffset + "px"
|
|
131
|
-
|
|
132
|
-
let toUpdate = countDirtyView(cm)
|
|
133
|
-
if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
|
|
134
|
-
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
|
|
135
|
-
return false
|
|
136
|
-
|
|
137
|
-
// For big changes, we hide the enclosing element during the
|
|
138
|
-
// update, since that speeds up the operations on most browsers.
|
|
139
|
-
let selSnapshot = selectionSnapshot(cm)
|
|
140
|
-
if (toUpdate > 4) display.lineDiv.style.display = "none"
|
|
141
|
-
patchDisplay(cm, display.updateLineNumbers, update.dims)
|
|
142
|
-
if (toUpdate > 4) display.lineDiv.style.display = ""
|
|
143
|
-
display.renderedView = display.view
|
|
144
|
-
// There might have been a widget with a focused element that got
|
|
145
|
-
// hidden or updated, if so re-focus it.
|
|
146
|
-
restoreSelection(selSnapshot)
|
|
147
|
-
|
|
148
|
-
// Prevent selection and cursors from interfering with the scroll
|
|
149
|
-
// width and height.
|
|
150
|
-
removeChildren(display.cursorDiv)
|
|
151
|
-
removeChildren(display.selectionDiv)
|
|
152
|
-
display.gutters.style.height = display.sizer.style.minHeight = 0
|
|
153
|
-
|
|
154
|
-
if (different) {
|
|
155
|
-
display.lastWrapHeight = update.wrapperHeight
|
|
156
|
-
display.lastWrapWidth = update.wrapperWidth
|
|
157
|
-
startWorker(cm, 400)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
display.updateLineNumbers = null
|
|
161
|
-
|
|
162
|
-
return true
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export function postUpdateDisplay(cm, update) {
|
|
166
|
-
let viewport = update.viewport
|
|
167
|
-
|
|
168
|
-
for (let first = true;; first = false) {
|
|
169
|
-
if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
|
|
170
|
-
// Clip forced viewport to actual scrollable area.
|
|
171
|
-
if (viewport && viewport.top != null)
|
|
172
|
-
viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)}
|
|
173
|
-
// Updated line heights might result in the drawn area not
|
|
174
|
-
// actually covering the viewport. Keep looping until it does.
|
|
175
|
-
update.visible = visibleLines(cm.display, cm.doc, viewport)
|
|
176
|
-
if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
|
|
177
|
-
break
|
|
178
|
-
} else if (first) {
|
|
179
|
-
update.visible = visibleLines(cm.display, cm.doc, viewport)
|
|
180
|
-
}
|
|
181
|
-
if (!updateDisplayIfNeeded(cm, update)) break
|
|
182
|
-
updateHeightsInViewport(cm)
|
|
183
|
-
let barMeasure = measureForScrollbars(cm)
|
|
184
|
-
updateSelection(cm)
|
|
185
|
-
updateScrollbars(cm, barMeasure)
|
|
186
|
-
setDocumentHeight(cm, barMeasure)
|
|
187
|
-
update.force = false
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
update.signal(cm, "update", cm)
|
|
191
|
-
if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
|
|
192
|
-
update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo)
|
|
193
|
-
cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export function updateDisplaySimple(cm, viewport) {
|
|
198
|
-
let update = new DisplayUpdate(cm, viewport)
|
|
199
|
-
if (updateDisplayIfNeeded(cm, update)) {
|
|
200
|
-
updateHeightsInViewport(cm)
|
|
201
|
-
postUpdateDisplay(cm, update)
|
|
202
|
-
let barMeasure = measureForScrollbars(cm)
|
|
203
|
-
updateSelection(cm)
|
|
204
|
-
updateScrollbars(cm, barMeasure)
|
|
205
|
-
setDocumentHeight(cm, barMeasure)
|
|
206
|
-
update.finish()
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Sync the actual display DOM structure with display.view, removing
|
|
211
|
-
// nodes for lines that are no longer in view, and creating the ones
|
|
212
|
-
// that are not there yet, and updating the ones that are out of
|
|
213
|
-
// date.
|
|
214
|
-
function patchDisplay(cm, updateNumbersFrom, dims) {
|
|
215
|
-
let display = cm.display, lineNumbers = cm.options.lineNumbers
|
|
216
|
-
let container = display.lineDiv, cur = container.firstChild
|
|
217
|
-
|
|
218
|
-
function rm(node) {
|
|
219
|
-
let next = node.nextSibling
|
|
220
|
-
// Works around a throw-scroll bug in OS X Webkit
|
|
221
|
-
if (webkit && mac && cm.display.currentWheelTarget == node)
|
|
222
|
-
node.style.display = "none"
|
|
223
|
-
else
|
|
224
|
-
node.parentNode.removeChild(node)
|
|
225
|
-
return next
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
let view = display.view, lineN = display.viewFrom
|
|
229
|
-
// Loop over the elements in the view, syncing cur (the DOM nodes
|
|
230
|
-
// in display.lineDiv) with the view as we go.
|
|
231
|
-
for (let i = 0; i < view.length; i++) {
|
|
232
|
-
let lineView = view[i]
|
|
233
|
-
if (lineView.hidden) {
|
|
234
|
-
} else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
|
|
235
|
-
let node = buildLineElement(cm, lineView, lineN, dims)
|
|
236
|
-
container.insertBefore(node, cur)
|
|
237
|
-
} else { // Already drawn
|
|
238
|
-
while (cur != lineView.node) cur = rm(cur)
|
|
239
|
-
let updateNumber = lineNumbers && updateNumbersFrom != null &&
|
|
240
|
-
updateNumbersFrom <= lineN && lineView.lineNumber
|
|
241
|
-
if (lineView.changes) {
|
|
242
|
-
if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false
|
|
243
|
-
updateLineForChanges(cm, lineView, lineN, dims)
|
|
244
|
-
}
|
|
245
|
-
if (updateNumber) {
|
|
246
|
-
removeChildren(lineView.lineNumber)
|
|
247
|
-
lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)))
|
|
248
|
-
}
|
|
249
|
-
cur = lineView.node.nextSibling
|
|
250
|
-
}
|
|
251
|
-
lineN += lineView.size
|
|
252
|
-
}
|
|
253
|
-
while (cur) cur = rm(cur)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export function updateGutterSpace(display) {
|
|
257
|
-
let width = display.gutters.offsetWidth
|
|
258
|
-
display.sizer.style.marginLeft = width + "px"
|
|
259
|
-
// Send an event to consumers responding to changes in gutter width.
|
|
260
|
-
signalLater(display, "gutterChanged", display)
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
export function setDocumentHeight(cm, measure) {
|
|
264
|
-
cm.display.sizer.style.minHeight = measure.docHeight + "px"
|
|
265
|
-
cm.display.heightForcer.style.top = measure.docHeight + "px"
|
|
266
|
-
cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px"
|
|
267
|
-
}
|