浏览代码

Simplify index.js

Alex Dima 8 年之前
父节点
当前提交
3d3fea5626
共有 2 个文件被更改,包括 112 次插入121 次删除
  1. 1 1
      metadata.js
  2. 111 120
      test/index.js

+ 1 - 1
metadata.js

@@ -63,4 +63,4 @@
 		self.METADATA = METADATA;
 		self.METADATA = METADATA;
 	}
 	}
 
 
-})();
+})();

+ 111 - 120
test/index.js

@@ -3,24 +3,12 @@ define(['require', './samples'], function(require, SAMPLES) {
 
 
 var domutils = require('vs/base/browser/dom');
 var domutils = require('vs/base/browser/dom');
 
 
-var WRAPPING_COLUMN = 300;
-
 var model = monaco.editor.createModel('', 'plaintext');
 var model = monaco.editor.createModel('', 'plaintext');
 
 
 var editor = monaco.editor.create(document.getElementById('container'), {
 var editor = monaco.editor.create(document.getElementById('container'), {
 	model: model,
 	model: model,
-	readOnly: false,
 	glyphMargin: true,
 	glyphMargin: true,
-	wrappingColumn: WRAPPING_COLUMN,
-	outlineMarkers: false,
-	renderWhitespace: true,
-	minimap: {
-		enabled: true
-	}
-	// scrollbar: {
-	// 	verticalHasArrows: true,
-	// 	horizontalHasArrows: true
-	// }
+	renderWhitespace: true
 });
 });
 
 
 editor.addCommand({
 editor.addCommand({
@@ -42,7 +30,6 @@ editor.addAction({
 	}
 	}
 });
 });
 
 
-
 var currentSamplePromise = null;
 var currentSamplePromise = null;
 var samplesData = {};
 var samplesData = {};
 SAMPLES.sort(function(a,b) {
 SAMPLES.sort(function(a,b) {
@@ -170,16 +157,8 @@ function createToolbar(editor) {
 			}
 			}
 		};
 		};
 	})()));
 	})()));
-
-	bar.appendChild(createButton("Colorize", function(e) {
-		var out = document.getElementById('colorizeOutput');
-		monaco.editor.colorize(editor.getModel().getValue(), editor.getModel().getMode().getId(), { tabSize: 4 }).then(function(r) {
-			out.innerHTML = r;
-		});
-	}));
 }
 }
 
 
-
 function createButton(label, onClick) {
 function createButton(label, onClick) {
 	var result = document.createElement("button");
 	var result = document.createElement("button");
 	result.innerHTML = label;
 	result.innerHTML = label;
@@ -187,117 +166,129 @@ function createButton(label, onClick) {
 	return result;
 	return result;
 }
 }
 
 
-
 function createOptions(editor) {
 function createOptions(editor) {
 	var options = document.getElementById('options');
 	var options = document.getElementById('options');
 
 
-	options.appendChild(createOptionToggle(editor, 'lineNumbers', function(config) {
-		return config.viewInfo.lineNumbers;
-	}, function(editor, newValue) {
-		editor.updateOptions({ lineNumbers: newValue });
-	}));
-
-	options.appendChild(createOptionToggle(editor, 'glyphMargin', function(config) {
-		return config.viewInfo.glyphMargin;
-	}, function(editor, newValue) {
-		editor.updateOptions({ glyphMargin: newValue });
-	}));
-
-	options.appendChild(createOptionToggle(editor, 'roundedSelection', function(config) {
-		return config.viewInfo.roundedSelection;
-	}, function(editor, newValue) {
-		editor.updateOptions({ roundedSelection: newValue });
-	}));
+	options.appendChild(createOptionToggle(
+		editor,
+		'lineNumbers',
+		function(config) {
+			return config.viewInfo.renderLineNumbers;
+		},
+		function(editor, newValue) {
+			editor.updateOptions({ lineNumbers: newValue ? 'on': 'off' });
+		}
+	));
+
+	options.appendChild(createOptionToggle(
+		editor,
+		'glyphMargin',
+		function(config) {
+			return config.viewInfo.glyphMargin;
+		},
+		function(editor, newValue) {
+			editor.updateOptions({ glyphMargin: newValue });
+		}
+	));
+
+	options.appendChild(createOptionToggle(
+		editor,
+		'minimap',
+		function(config) {
+			return config.viewInfo.minimap.enabled;
+		},
+		function(editor, newValue) {
+			editor.updateOptions({ minimap: { enabled: newValue } });
+		}
+	));
+
+	options.appendChild(createOptionToggle(
+		editor,
+		'roundedSelection',
+		function(config) {
+			return config.viewInfo.roundedSelection;
+		},
+		function(editor, newValue) {
+			editor.updateOptions({ roundedSelection: newValue });
+		}
+	));
+
+	options.appendChild(createOptionToggle(
+		editor,
+		'scrollBeyondLastLine',
+		function(config) {
+			return config.viewInfo.scrollBeyondLastLine;
+		}, function(editor, newValue) {
+			editor.updateOptions({ scrollBeyondLastLine: newValue });
+		}
+	));
+
+	options.appendChild(createOptionToggle(
+		editor,
+		'renderWhitespace',
+		function(config) {
+			return config.viewInfo.renderWhitespace;
+		}, function(editor, newValue) {
+			editor.updateOptions({ renderWhitespace: newValue });
+		}
+	));
+
+	options.appendChild(createOptionToggle(
+		editor,
+		'light',
+		function(config) {
+			return false;//config.viewInfo.theme === 'vs-dark';
+		}, function(editor, newValue) {
+			monaco.editor.setTheme('vs');
+			// editor.updateOptions({ theme: newValue ? 'vs-dark' : 'vs' });
+		}
+	));
 
 
 	options.appendChild(createOptionToggle(editor, 'dark', function(config) {
 	options.appendChild(createOptionToggle(editor, 'dark', function(config) {
-		return config.viewInfo.theme === 'vs-dark';
+		return false;//config.viewInfo.theme === 'vs-dark';
 	}, function(editor, newValue) {
 	}, function(editor, newValue) {
-		editor.updateOptions({ theme: newValue ? 'vs-dark' : 'vs' });
+		monaco.editor.setTheme('vs-dark');
+		// editor.updateOptions({ theme: newValue ? 'vs-dark' : 'vs' });
 	}));
 	}));
 
 
 	options.appendChild(createOptionToggle(editor, 'hc-black', function(config) {
 	options.appendChild(createOptionToggle(editor, 'hc-black', function(config) {
-		return config.viewInfo.theme === 'hc-black';
+		return false;
+		//return config.viewInfo.theme === 'hc-black';
 	}, function(editor, newValue) {
 	}, function(editor, newValue) {
+		monaco.editor.setTheme('hc-black');
 		editor.updateOptions({ theme: newValue ? 'hc-black' : 'vs' });
 		editor.updateOptions({ theme: newValue ? 'hc-black' : 'vs' });
 	}));
 	}));
 
 
-	options.appendChild(createOptionToggle(editor, 'readOnly', function(config) {
-		return config.readOnly;
-	}, function(editor, newValue) {
-		editor.updateOptions({ readOnly: newValue });
-	}));
-
-	options.appendChild(createOptionToggle(editor, 'hideCursorInOverviewRuler', function(config) {
-		return config.viewInfo.hideCursorInOverviewRuler;
-	}, function(editor, newValue) {
-		editor.updateOptions({ hideCursorInOverviewRuler: newValue });
-	}));
-
-	options.appendChild(createOptionToggle(editor, 'scrollBeyondLastLine', function(config) {
-		return config.viewInfo.scrollBeyondLastLine;
-	}, function(editor, newValue) {
-		editor.updateOptions({ scrollBeyondLastLine: newValue });
-	}));
-
-	options.appendChild(createOptionToggle(editor, 'wordWrap', function(config) {
-		return config.wrappingInfo.isViewportWrapping;
-	}, function(editor, newValue) {
-		editor.updateOptions({ wrappingColumn: newValue ? 0 : WRAPPING_COLUMN });
-	}));
-
-	options.appendChild(createOptionToggle(editor, 'quickSuggestions', function(config) {
-		return config.contribInfo.quickSuggestions;
-	}, function(editor, newValue) {
-		editor.updateOptions({ quickSuggestions: newValue });
-	}));
-
-	options.appendChild(createOptionToggle(editor, 'iconsInSuggestions', function(config) {
-		return config.contribInfo.iconsInSuggestions;
-	}, function(editor, newValue) {
-		editor.updateOptions({ iconsInSuggestions: newValue });
-	}));
-
-	options.appendChild(createOptionToggle(editor, 'autoClosingBrackets', function(config) {
-		return config.autoClosingBrackets;
-	}, function(editor, newValue) {
-		editor.updateOptions({ autoClosingBrackets: newValue });
-	}));
-
-	options.appendChild(createOptionToggle(editor, 'formatOnType', function(config) {
-		return config.contribInfo.formatOnType;
-	}, function(editor, newValue) {
-		editor.updateOptions({ formatOnType: newValue });
-	}));
-
-	options.appendChild(createOptionToggle(editor, 'suggestOnTriggerCharacters', function(config) {
-		return config.contribInfo.suggestOnTriggerCharacters;
-	}, function(editor, newValue) {
-		editor.updateOptions({ suggestOnTriggerCharacters: newValue });
-	}));
-
-	options.appendChild(createOptionToggle(editor, 'acceptSuggestionOnEnter', function(config) {
-		return config.contribInfo.acceptSuggestionOnEnter;
-	}, function(editor, newValue) {
-		editor.updateOptions({ acceptSuggestionOnEnter: newValue });
-	}));
-
-	options.appendChild(createOptionToggle(editor, 'selectionHighlight', function(config) {
-		return config.contribInfo.selectionHighlight;
-	}, function(editor, newValue) {
-		editor.updateOptions({ selectionHighlight: newValue });
-	}));
-
-	options.appendChild(createOptionToggle(editor, 'folding', function(config) {
-		return config.contribInfo.folding;
-	}, function(editor, newValue) {
-		editor.updateOptions({ folding: newValue });
-	}));
-
-	options.appendChild(createOptionToggle(editor, 'renderWhitespace', function(config) {
-		return config.viewInfo.renderWhitespace;
-	}, function(editor, newValue) {
-		editor.updateOptions({ renderWhitespace: newValue });
-	}));
+	options.appendChild(createOptionToggle(
+		editor,
+		'readOnly',
+		function(config) {
+			return config.readOnly;
+		},
+		function(editor, newValue) {
+			editor.updateOptions({ readOnly: newValue });
+		}
+	));
+
+	options.appendChild(createOptionToggle(
+		editor,
+		'wordWrap',
+		function(config) {
+			return config.wrappingInfo.isViewportWrapping;
+		}, function(editor, newValue) {
+			editor.updateOptions({ wordWrap: newValue ? 'on' : 'off' });
+		}
+	));
+
+	options.appendChild(createOptionToggle(
+		editor,
+		'folding',
+		function(config) {
+			return config.contribInfo.folding;
+		}, function(editor, newValue) {
+			editor.updateOptions({ folding: newValue });
+		}
+	));
 }
 }