MCPcopy
hub / github.com/kekingcn/kkFileView / markText

Function markText

server/src/main/resources/static/js/codemirror.js:1292–1319  ·  view source on GitHub ↗
(doc,from,to,options,type)

Source from the content-addressed store, hash-verified

1290signalLater(cm,"markerChanged",cm,this$1);});};TextMarker.prototype.attachLine=function(line){if(!this.lines.length&&this.doc.cm){var op=this.doc.cm.curOp;if(!op.maybeHiddenMarkers||indexOf(op.maybeHiddenMarkers,this)==-1)
1291{(op.maybeUnhiddenMarkers||(op.maybeUnhiddenMarkers=[])).push(this);}}
1292this.lines.push(line);};TextMarker.prototype.detachLine=function(line){this.lines.splice(indexOf(this.lines,line),1);if(!this.lines.length&&this.doc.cm){var op=this.doc.cm.curOp;(op.maybeHiddenMarkers||(op.maybeHiddenMarkers=[])).push(this);}};eventMixin(TextMarker);function markText(doc,from,to,options,type){if(options&&options.shared){return markTextShared(doc,from,to,options,type)}
1293if(doc.cm&&!doc.cm.curOp){return operation(doc.cm,markText)(doc,from,to,options,type)}
1294var marker=new TextMarker(doc,type),diff=cmp(from,to);if(options){copyObj(options,marker,false);}
1295if(diff>0||diff==0&&marker.clearWhenEmpty!==false)
1296{return marker}
1297if(marker.replacedWith){marker.collapsed=true;marker.widgetNode=eltP("span",[marker.replacedWith],"CodeMirror-widget");if(!options.handleMouseEvents){marker.widgetNode.setAttribute("cm-ignore-events","true");}
1298if(options.insertLeft){marker.widgetNode.insertLeft=true;}}
1299if(marker.collapsed){if(conflictingCollapsedRange(doc,from.line,from,to,marker)||from.line!=to.line&&conflictingCollapsedRange(doc,to.line,from,to,marker))
1300{throw new Error("Inserting collapsed marker partially overlapping an existing one")}
1301seeCollapsedSpans();}
1302if(marker.addToHistory)
1303{addChangeToHistory(doc,{from:from,to:to,origin:"markText"},doc.sel,NaN);}
1304var curLine=from.line,cm=doc.cm,updateMaxLine;doc.iter(curLine,to.line+1,function(line){if(cm&&marker.collapsed&&!cm.options.lineWrapping&&visualLine(line)==cm.display.maxLine)
1305{updateMaxLine=true;}
1306if(marker.collapsed&&curLine!=from.line){updateLineHeight(line,0);}
1307addMarkedSpan(line,new MarkedSpan(marker,curLine==from.line?from.ch:null,curLine==to.line?to.ch:null),doc.cm&&doc.cm.curOp);++curLine;});if(marker.collapsed){doc.iter(from.line,to.line+1,function(line){if(lineIsHidden(doc,line)){updateLineHeight(line,0);}});}
1308if(marker.clearOnEnter){on(marker,"beforeCursorEnter",function(){return marker.clear();});}
1309if(marker.readOnly){seeReadOnlySpans();if(doc.history.done.length||doc.history.undone.length)
1310{doc.clearHistory();}}
1311if(marker.collapsed){marker.id=++nextMarkerId;marker.atomic=true;}
1312if(cm){if(updateMaxLine){cm.curOp.updateMaxLine=true;}
1313if(marker.collapsed)
1314{regChange(cm,from.line,to.line+1);}
1315else if(marker.className||marker.startStyle||marker.endStyle||marker.css||marker.attributes||marker.title)
1316{for(var i=from.line;i<=to.line;i++){regLineChange(cm,i,"text");}}
1317if(marker.atomic){reCheckSelection(cm.doc);}
1318signalLater(cm,"markerAdded",cm,marker);}
1319return marker}
1320var SharedTextMarker=function(markers,primary){this.markers=markers;this.primary=primary;for(var i=0;i<markers.length;++i)
1321{markers[i].parent=this;}};SharedTextMarker.prototype.clear=function(){if(this.explicitlyCleared){return}
1322this.explicitlyCleared=true;for(var i=0;i<this.markers.length;++i)

Callers 3

markTextSharedFunction · 0.85
copySharedMarkersFunction · 0.85
codemirror.jsFile · 0.85

Calls 15

markTextSharedFunction · 0.85
operationFunction · 0.85
copyObjFunction · 0.85
eltPFunction · 0.85
seeCollapsedSpansFunction · 0.85
addChangeToHistoryFunction · 0.85
visualLineFunction · 0.85
updateLineHeightFunction · 0.85
addMarkedSpanFunction · 0.85
lineIsHiddenFunction · 0.85
seeReadOnlySpansFunction · 0.85

Tested by

no test coverage detected