Merge pull request #57 from tophf/keymap
Edit style: use 'sublime' keymap, add custom keys
This commit is contained in:
		
						commit
						9a90e15d45
					
				| 
						 | 
					@ -92,6 +92,10 @@
 | 
				
			||||||
		"message": "Disable",
 | 
							"message": "Disable",
 | 
				
			||||||
		"description": "Label for the button to disable a style"
 | 
							"description": "Label for the button to disable a style"
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
						"editGotoLine": {
 | 
				
			||||||
 | 
							"message": "Goto line (or line:col)",
 | 
				
			||||||
 | 
							"description": "Go to line or line:column on Ctrl-G in style code editor"
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
	"editStyleHeading": {
 | 
						"editStyleHeading": {
 | 
				
			||||||
		"message": "Edit Style",
 | 
							"message": "Edit Style",
 | 
				
			||||||
		"description": "Title of the page for editing styles"
 | 
							"description": "Title of the page for editing styles"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,6 +29,8 @@
 | 
				
			||||||
		<script src="codemirror/addon/hint/show-hint.js"></script>
 | 
							<script src="codemirror/addon/hint/show-hint.js"></script>
 | 
				
			||||||
		<script src="codemirror/addon/hint/css-hint.js"></script>
 | 
							<script src="codemirror/addon/hint/css-hint.js"></script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<script src="codemirror/keymap/sublime.js"></script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		<style type="text/css">
 | 
							<style type="text/css">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			body {
 | 
								body {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										18
									
								
								edit.js
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								edit.js
									
									
									
									
									
								
							| 
						 | 
					@ -25,8 +25,26 @@ function setupCodeMirror(textarea) {
 | 
				
			||||||
		matchBrackets: true,
 | 
							matchBrackets: true,
 | 
				
			||||||
		lint: CodeMirror.lint.css,
 | 
							lint: CodeMirror.lint.css,
 | 
				
			||||||
		smartIndent: prefs.getPref("smart-indent"),
 | 
							smartIndent: prefs.getPref("smart-indent"),
 | 
				
			||||||
 | 
							keyMap: "sublime",
 | 
				
			||||||
		extraKeys: {"Ctrl-Space": "autocomplete"}
 | 
							extraKeys: {"Ctrl-Space": "autocomplete"}
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
						cm.addKeyMap({
 | 
				
			||||||
 | 
							"Ctrl-G": function(cm) {
 | 
				
			||||||
 | 
								var cur = cm.getCursor();
 | 
				
			||||||
 | 
								cm.openDialog(t('editGotoLine') + ': <input type="text" style="width: 5em"/>', function(str) {
 | 
				
			||||||
 | 
									var m = str.match(/^\s*(\d+)(?:\s*:\s*(\d+))?\s*$/);
 | 
				
			||||||
 | 
									if (m) {
 | 
				
			||||||
 | 
										cm.setCursor(m[1] - 1, m[2] ? m[2] - 1 : cur.ch);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}, {value: cur.line+1});
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Alt-PageDown": function(cm) {
 | 
				
			||||||
 | 
								editors[(editors.indexOf(cm) + 1) % editors.length].focus();
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Alt-PageUp": function(cm) {
 | 
				
			||||||
 | 
								editors[(editors.indexOf(cm) - 1 + editors.length) % editors.length].focus();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
	cm.lastChange = cm.changeGeneration();
 | 
						cm.lastChange = cm.changeGeneration();
 | 
				
			||||||
	cm.on("change", indicateCodeChange);
 | 
						cm.on("change", indicateCodeChange);
 | 
				
			||||||
	editors.push(cm);
 | 
						editors.push(cm);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user