public Marker( object id, MarkerLayer layer, Range range, bool tailed = true, bool reversed = false, bool valid = true, string invalidate = "overlap", bool?exclusive = null, IDictionary <string, object> properties = null, bool exclusivitySet = false) { Id = id; Layer = layer; Tailed = tailed; Reversed = reversed; Valid = valid; Invalidate = invalidate; Exclusive = exclusive; Properties = properties == null ? new ReadOnlyDictionary <string, object>(new Dictionary <string, object>()) : new ReadOnlyDictionary <string, object>(properties); HasChangeObservers = false; if (!exclusivitySet) { Layer.SetMarkerIsExclusive(id, IsExclusive()); } PreviousEventState = GetSnapshot(GetRange()); }
/// <summary> /// Public: Create a new buffer with the given params. /// /// * `params` {Object} or {String} of text /// * `text` The initial {String} text of the buffer. /// * `shouldDestroyOnFileDelete` A {Function} that returns a {Boolean} /// indicating whether the buffer should be destroyed if its file is /// deleted. /// </summary> /// <param name="text">The initial <see cref="string"/> text of the buffer.</param> /// <param name="shouldDestroyOnFileDelete"> /// A <see cref="Action<bool>"/> that returns a <see cref="bool"/> /// indicating whether the buffer should be destroyed if its file is /// deleted. /// </param> public TextBuffer( string text, object maxUndoEntries = null, object encoding = null, object preferredLineEnding = null, Action <bool> shouldDestroyOnFileDelete = null, string filePath = null, bool?load = null) { refcount = 0; conflict = false; file = null; fileSubscriptions = null; stoppedChangingTimeout = null; emitter = new Emitter(); changesSinceLastStoppedChangingEvent = new object[0]; changesSinceLastDidChangeTextEvent = new object[0]; id = crypto.randomBytes(16).toString('hex'); buffer = new NativeTextBuffer(text); debouncedEmitDidStopChangingEvent = debounce(this.emitDidStopChangingEvent.bind(this), this.stoppedChangingDelay); this.maxUndoEntries = maxUndoEntries != null ? maxUndoEntries : defaultMaxUndoEntries; this.setHistoryProvider(new DefaultHistoryProvider(this)); languageMode = new NullLanguageMode(); nextMarkerLayerId = 0; nextDisplayLayerId = 0; defaultMarkerLayer = new MarkerLayer(this, String(nextMarkerLayerId++)); displayLayers = new { }; markerLayers = new { }; markerLayers[defaultMarkerLayer.id] = defaultMarkerLayer; markerLayersWithPendingUpdateEvents = new Set(); selectionsMarkerLayerIds = new Set(); nextMarkerId = 1; outstandingSaveCount = 0; loadCount = 0; cachedHasAstral = null; _emittedWillChangeEvent = false; this.setEncoding(p.encoding); this.setPreferredLineEnding(p.preferredLineEnding); loaded = false; destroyed = false; transactCallDepth = 0; digestWhenLastPersisted = false; shouldDestroyOnFileDelete = p.shouldDestroyOnFileDelete || (() => false); if (p.filePath) { this.setPath(p.filePath); if (p.load) { Grim.deprecate( 'The `load` option to the TextBuffer constructor is deprecated. ' + 'Get a loaded buffer using TextBuffer.load(filePath) instead.'); this.load(new ('internal' : true)); } } version = 5; newlineRegex = newlineRegex; spliceArray = spliceArray; Patch = superstring.Patch; stoppedChangingDelay = 300; fileChangeDelay = 200; backwardsScanChunkSize = 8000; defaultMaxUndoEntries = 10000; }