<commit_before>module.exports = require('views/editview').extend(function CodeView(proto, base){
	
	var parser = require('jsparser/jsparser')

	proto.onInit = function(){
		base.onInit.call(this)

		this.fastTextOutput = {
			text:'',
			ann:[]
		}
	}


	proto.tools = {
		Block:require('shaders/fastrectshader').extend({
			borderRadius:5,
			vertexStyle2:function(){
				var dx = .5
				//this.x -= dx
				this.y -= dx
				//this.w += 2.*dx
				this.h += 2.*dx
			}

		})
	}
	
	proto.onDraw = function(){

		this.beginBg(this.viewBgProps)

		// ok lets parse the code
		//require.perf()
		if(this.$oldText != this.text){
			this.$oldText = this.text
			this.drawBlock()
			this.drawSelect()
			try{
				var ast = parser.parse(this.text)

				// first we format the code
				this.indent = 0
				// the indent size
				this.indentSize = this.Text.prototype.font.fontmap.glyphs[32].advance * this.style.fontSize * 3
				this.lineHeight = this.style.fontSize
				var out = this.fastTextOutput
				out.text = ''
				out.ann.length = 0

				this[ast.type](ast, null)

				this.text = out.text
				this.ann = out.ann
				// end with a space
				this.fastText(' ', this.style)
			}
			catch(e){ // uhoh.. we need to fall back to textmode
				//console.log(e)
				var ann = this.fastTextOutput.ann
				for(var i = 0, len = ann.length; i < len; i+=3){
					this.turtle.sx = ann[i+2]
					this.fastText(ann[i], ann[i+1])
				}
			}
		}
		else{
			this.reuseDrawSize()
			this.reuseBlock()
			this.drawSelect()
			this.reuseText()
		}
		//require.perf()
		//console.log("HERE")
		if(this.hasFocus){
			var cursors = this.cs.cursors
			for(var i = 0; i < cursors.length; i++){
				var cursor = cursors[i]

				var t = this.cursorRect(cursor.end)
				var boxes = this.$boundRectsText(cursor.lo(), cursor.hi())

				for(var j = 0; j < boxes.length;j++){
					var box = boxes[j]
					this.drawSelect({
						x:box.x,
						y:box.y,
						w:box.w,
						h:box.h
					})<commit_msg>annotated<commit_after>module.exports = require('views/editview').extend(function CodeView(proto, base){
	
	var parser = require('jsparser/jsparser')

	proto.onInit = function(){
		base.onInit.call(this)

		this.fastTextOutput = {
			text:'',
			ann:[]
		}
	}


	proto.tools = {
		Block:require('shaders/fastrectshader').extend({
			borderRadius:5,
			vertexStyle2:function(){
				var dx = .5
				//this.x -= dx
				this.y -= dx
				//this.w += 2.*dx
				this.h += 2.*dx
			}

		})
	}
	
	proto.onDraw = function(){

		this.beginBg(this.viewBgProps)

		// ok lets parse the code
		//require.perf()
		if(this.$oldText != this.text){
			this.$oldText = this.text
			this.drawBlock()
			this.drawSelect()
			try{
				var ast = parser.parse(this.text)

				// first we format the code
				this.indent = 0
				// the indent size
				this.indentSize = this.Text.prototype.font.fontmap.glyphs[32].advance * this.style.fontSize * 3
				this.lineHeight = this.style.fontSize
				var out = this.fastTextOutput
				out.text = ''
				out.ann.length = 0

				this[ast.type](ast, null)

				this.text = out.text
				this.ann = out.ann
				// end with a space
				this.fastText(' ', this.style)
			}
			catch(e){ // uhoh.. we need to fall back to textmode
				var ann = this.fastTextOutput.ann
				var out = this.fastTextOutput 
				this.fastTextOutput = null
				for(var i = 0, len = ann.length; i < len; i+=3){
					this.turtle.sx = ann[i+2]
					this.fastText(ann[i], ann[i+1])
				}
				this.fastTextOutput = out
			}
		}
		else{
			this.reuseDrawSize()
			this.reuseBlock()
			this.drawSelect()
			this.reuseText()
		}
		//require.perf()
		//console.log("HERE")
		if(this.hasFocus){
			var cursors = this.cs.cursors
			for(var i = 0; i < cursors.length; i++){
				var cursor = cursors[i]

				var t = this.cursorRect(cursor.end)
				var boxes = this.$boundRectsText(cursor.lo(), cursor.hi())

				for(var j = 0; j < boxes.length;j++){
					var box = boxes[j]
					this.drawSelect({
						x:box.x,
						y:box.y,
						w:box.w,
						h:box.h
					})
{'fraction_non_alphanumeric': 0.15963027729203097, 'fraction_numerical': 0.00799400449662753, 'mean_word_length': 2.43101970865467, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, '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': '1631536', 'n_tokens_mistral': 1882, 'n_tokens_neox': 1461, 'n_words': 298}