<commit_before>define(["Ti/_/declare", "Ti/_/UI/FontWidget", "Ti/_/dom", "Ti/_/css", "Ti/_/style", "Ti/_/lang", "Ti/UI"],
	function(declare, FontWidget, dom, css, style, lang, UI) {

	var set = style.set,
		undef,
		unitize = dom.unitize;

	return declare("Ti.UI.Label", FontWidget, {
		
		constructor: function() {
			
			this.touchEnabled = false;
			
			// Create the aligner div. This sets up a flexbox to float the text to the middle
			this.textAlignerDiv = dom.create("div", {
				className: css.clean("TiUILabelTextAligner")
			}, this.domNode);

			set(this.textAlignerDiv, "display", "-webkit-box");
			set(this.textAlignerDiv, {
				display: "-moz-box",
				boxOrient: "vertical",
				boxPack: "center",
				width: "100%",
				height: "100%",
				overflow: "hidden"
			});

			// Create the container div. This gets floated by the flexbox
			this.textContainerDiv = dom.create("div", {
				className: css.clean("TiUILabelTextContainer"),
				style: {
					textAlign: "left",
					textOverflow: "ellipsis",
					overflowX: "hidden",
					width: "100%",
					maxHeight: "100%",
					userSelect: "none",
					whiteSpace: "nowrap"
				}
			}, this.textAlignerDiv);

			this._addStyleableDomNode(this.textContainerDiv);
		},

		_defaultWidth: "auto",

		_defaultHeight: "auto",
		
		_getContentWidth: function() {
			return this._measureText(this.text, this.textContainerDiv).width;
		},
		
		_getContentHeight: function() {
			return this._measureText(this.text, this.textContainerDiv).height;
		},
		
		_setTouchEnabled: function(value) {
			FontWidget.prototype._setTouchEnabled.apply(this,arguments);
			var cssVal = value ? "auto" : "none"
			set(this.textAlignerDiv,"pointerEvents", cssVal);
			set(this.textContainerDiv,"pointerEvents", cssVal);
		},
		
		_setTextShadow: function() {
			var shadowColor = this.shadowColor && this.shadowColor !== "" ? this.shadowColor : undef;
			if (this.shadowOffset || shadowColor) {
				set(this.textContainerDiv,"textShadow",
					(this.shadowOffset ? unitize(this.shadowOffset.x) + " " + unitize(this.shadowOffset.y) : "0px 0px") + " 0.1em " + lang.val(shadowColor,"black"));
			} else {
				set(this.textContainerDiv,"textShadow","");
			}
		},

		properties: {
			color: {
				set: function(value) {
					this.textContainerDiv.style.color = value;
					return value;
				}
			},
			ellipsize: {
				set: function(value) {
					set(this.textContainerDiv,"textOverflow", !!value ? "ellipsis" : "clip");
					return value;
				},
				value: true
			},
			html: {
				set: function(value) {
					this.textContainerDiv.innerHTML = value;
					this._hasAutoDimensions() && this._triggerParentLayout();
					return value;
				}
			},
			shadowColor: {
				post: function(value) {
					this._setTextShadow();
					return value;
				}
			},
			shadowOffset: {
				post: function(value) {
					this._setTextShadow();
					return value;
				}
			},
			text: {
				set: function(value) {
					this.textContainerDiv.innerHTML = value;
					this._hasAutoDimensions() && this._triggerParentLayout();
					return value;
				}
			},
			textAlign: {
				set: function(value) {
					var cssValue = "";
					switch(value) {
						case UI.TEXT_ALIGNMENT_LEFT: cssValue = "left"; break;
						case UI.TEXT_ALIGNMENT_CENTER: cssValue = "center"; break;
						case UI.TEXT_ALIGNMENT_RIGHT: cssValue = "right"; break;
					}
					this.textContainerDiv.style.textAlign = cssValue;
					return value;<commit_msg>[TIMOB-7604] Implemented support for \t and \n in label<commit_after>define(["Ti/_/declare", "Ti/_/UI/FontWidget", "Ti/_/dom", "Ti/_/css", "Ti/_/style", "Ti/_/lang", "Ti/UI"],
	function(declare, FontWidget, dom, css, style, lang, UI) {

	var set = style.set,
		undef,
		unitize = dom.unitize,
		tabStop = 2;

	return declare("Ti.UI.Label", FontWidget, {
		
		constructor: function() {
			
			this.touchEnabled = false;
			
			// Create the aligner div. This sets up a flexbox to float the text to the middle
			this.textAlignerDiv = dom.create("div", {
				className: css.clean("TiUILabelTextAligner")
			}, this.domNode);

			set(this.textAlignerDiv, "display", "-webkit-box");
			set(this.textAlignerDiv, {
				display: "-moz-box",
				boxOrient: "vertical",
				boxPack: "center",
				width: "100%",
				height: "100%",
				overflow: "hidden"
			});

			// Create the container div. This gets floated by the flexbox
			this.textContainerDiv = dom.create("div", {
				className: css.clean("TiUILabelTextContainer"),
				style: {
					textAlign: "left",
					textOverflow: "ellipsis",
					overflowX: "hidden",
					width: "100%",
					maxHeight: "100%",
					userSelect: "none",
					whiteSpace: "nowrap"
				}
			}, this.textAlignerDiv);

			this._addStyleableDomNode(this.textContainerDiv);
		},

		_defaultWidth: "auto",

		_defaultHeight: "auto",
		
		_getContentWidth: function() {
			return this._measureText(this.text, this.textContainerDiv).width;
		},
		
		_getContentHeight: function() {
			return this._measureText(this.text, this.textContainerDiv).height;
		},
		
		_setTouchEnabled: function(value) {
			FontWidget.prototype._setTouchEnabled.apply(this,arguments);
			var cssVal = value ? "auto" : "none"
			set(this.textAlignerDiv,"pointerEvents", cssVal);
			set(this.textContainerDiv,"pointerEvents", cssVal);
		},
		
		_setTextShadow: function() {
			var shadowColor = this.shadowColor && this.shadowColor !== "" ? this.shadowColor : undef;
			if (this.shadowOffset || shadowColor) {
				set(this.textContainerDiv,"textShadow",
					(this.shadowOffset ? unitize(this.shadowOffset.x) + " " + unitize(this.shadowOffset.y) : "0px 0px") + " 0.1em " + lang.val(shadowColor,"black"));
			} else {
				set(this.textContainerDiv,"textShadow","");
			}
		},

		properties: {
			color: {
				set: function(value) {
					this.textContainerDiv.style.color = value;
					return value;
				}
			},
			ellipsize: {
				set: function(value) {
					set(this.textContainerDiv,"textOverflow", !!value ? "ellipsis" : "clip");
					return value;
				},
				value: true
			},
			html: {
				set: function(value) {
					this.textContainerDiv.innerHTML = value;
					this._hasAutoDimensions() && this._triggerParentLayout();
					return value;
				}
			},
			shadowColor: {
				post: function(value) {
					this._setTextShadow();
					return value;
				}
			},
			shadowOffset: {
				post: function(value) {
					this._setTextShadow();
					return value;
				}
			},
			text: {
				set: function(value) {
					
					// Convert \t and \n to &nbsp;'s and <br/>'s
					var lineStartIndex = 0,
						currentIndex = 0,
						currentTabIndex;
					while(currentIndex < value.length) {
						if (value[currentIndex] === '\t') {
							var tabSpaces = "",
								numSpacesToInsert = tabStop - (currentTabIndex) % tabStop;
							for(var i = 0; i < numSpacesToInsert; i++) {
								tabSpaces += "&nbsp;";
							}
							value = value.substring(0,currentIndex) + tabSpaces + value.substring(currentIndex + 1);
							currentIndex += tabSpaces.length;
							currentTabIndex += numSpacesToInsert;
						} else if (value[currentIndex] === '\n') {
							value = value.substring(0,currentIndex) + "<br/>" + value.substring(currentIndex + 1);
							currentIndex += 5;
							lineStartIndex = currentIndex;
							currentTabIndex = 0;
						} else {
							currentIndex++;
							currentTabIndex++;
						}
					}
					value.match("<br/>$") && (value += "&nbsp;");
					
					this.textContainerDiv.innerHTML = value;
					this._hasAutoDimensions() && this._triggerParentLayout();
					return value;
				}
			},
			textAlign: {
				set: function(value) {
					var cssValue = "";
					switch(value) {
						case UI.TEXT_ALIGNMENT_LEFT: cssValue = "left"; break;
						case UI.TEXT_ALIGNMENT_CENTER: cssValue = "center"; break;
						case UI.TEXT_ALIGNMENT_RIGHT: cssValue = "right"; break;
					}
					this.textContainerDiv.style.textAlign = cssValue;
					return value;
{'fraction_non_alphanumeric': 0.1486315255955398, 'fraction_numerical': 0.005828687278256462, 'mean_word_length': 3.0580976863753215, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2210918', 'n_tokens_mistral': 3362, 'n_tokens_neox': 2538, 'n_words': 504}