

window.InitEditor = () => {
	if (!window.editor)
		return
	window.editor = ace.edit("editor")
	window.editor.setOptions({
		selectionStyle: "line",
		highlightActiveLine: true,
		highlightSelectedWord: true,
		readOnly: false,
		cursorStyle: "smooth slim",
		mergeUndoDeltas: true,
		behavioursEnabled: true,
		wrapBehavioursEnabled: true,
		copyWithEmptySelection: true,
		navigateWithinSoftTabs: true,
		printMargin: false,
		scrollPastEnd: 0.2,
		theme: "ace/theme/solarized_light",
		mode: "ace/mode/nginx",
		fixedWidthGutter: true,
		firstLineNumber: 1,
		newLineMode: "auto",
		tabSize: 2,
		keyboardHandler: "ace/keyboard/vscode",
		//enableBasicAutocompletion: true,
		enableLiveAutocompletion: true,
		//enableSnippets: true
	})
	window.editor.session.on('change', function (delta) {
		// delta.start, delta.end, delta.lines, delta.action
	})
}

window.GetEditorCode = () => {
	return window.editor.getValue()
}

window.UpdateEditor = (code) => {
	window.editor.session.setValue(code)
	window.editor.focus()
}

window.ClearEditor = () => {
	window.editor.session.setValue("")
}
