File modules/editor/codemirror/src/display/line_numbers.min.js

Last commit: Tue May 22 22:39:49 2018 +0200	Jan Dankert	Fix für PHP 7.2: 'Object' darf nun nicht mehr als Klassennamen verwendet werden. AUCH NICHT IN EINEM NAMESPACE! WTF, wozu habe ich das in einen verfickten Namespace gepackt? Wozu soll der sonst da sein??? Amateure. Daher nun notgedrungen unbenannt in 'BaseObject'.
1 import { lineNumberFor } from "../line/utils_line.js" 2 import { compensateForHScroll } from "../measurement/position_measurement.js" 3 import { elt } from "../util/dom.js" 4 5 import { updateGutterSpace } from "./update_display.js" 6 7 // Re-align line numbers and gutter marks to compensate for 8 // horizontal scrolling. 9 export function alignHorizontally(cm) { 10 let display = cm.display, view = display.view 11 if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return 12 let comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft 13 let gutterW = display.gutters.offsetWidth, left = comp + "px" 14 for (let i = 0; i < view.length; i++) if (!view[i].hidden) { 15 if (cm.options.fixedGutter) { 16 if (view[i].gutter) 17 view[i].gutter.style.left = left 18 if (view[i].gutterBackground) 19 view[i].gutterBackground.style.left = left 20 } 21 let align = view[i].alignable 22 if (align) for (let j = 0; j < align.length; j++) 23 align[j].style.left = left 24 } 25 if (cm.options.fixedGutter) 26 display.gutters.style.left = (comp + gutterW) + "px" 27 } 28 29 // Used to ensure that the line number gutter is still the right 30 // size for the current document size. Returns true when an update 31 // is needed. 32 export function maybeUpdateLineNumberWidth(cm) { 33 if (!cm.options.lineNumbers) return false 34 let doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display 35 if (last.length != display.lineNumChars) { 36 let test = display.measure.appendChild(elt("div", [elt("div", last)], 37 "CodeMirror-linenumber CodeMirror-gutter-elt")) 38 let innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW 39 display.lineGutter.style.width = "" 40 display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1 41 display.lineNumWidth = display.lineNumInnerWidth + padding 42 display.lineNumChars = display.lineNumInnerWidth ? last.length : -1 43 display.lineGutter.style.width = display.lineNumWidth + "px" 44 updateGutterSpace(cm) 45 return true 46 } 47 return false 48 }
Download modules/editor/codemirror/src/display/line_numbers.min.js
History Tue, 22 May 2018 22:39:49 +0200 Jan Dankert Fix für PHP 7.2: 'Object' darf nun nicht mehr als Klassennamen verwendet werden. AUCH NICHT IN EINEM NAMESPACE! WTF, wozu habe ich das in einen verfickten Namespace gepackt? Wozu soll der sonst da sein??? Amateure. Daher nun notgedrungen unbenannt in 'BaseObject'.