indentSize and indentWithTabs

tabWidth is now indentSize
indentWithTabs is a new setting which can be true/false (false means
spaces)
Applied immediately after updating on settings screen
This commit is contained in:
Matt Pass
2013-04-14 14:12:18 +01:00
parent 8c605674f3
commit 3c4872c231
6 changed files with 35 additions and 21 deletions

View File

@@ -132,9 +132,9 @@ function createNewCMInstance(num) {
mode: "application/x-httpd-php",
lineNumbers: true,
lineWrapping: top.ICEcoder.lineWrapping,
indentUnit: top.ICEcoder.tabWidth,
tabSize: top.ICEcoder.tabWidth,
indentWithTabs: true,
indentWithTabs: top.ICEcoder.indentWithTabs,
indentUnit: top.ICEcoder.indentSize,
tabSize: top.ICEcoder.indentSize,
electricChars: false,
autoCloseTags: true,
highlightSelectionMatches: true,

View File

@@ -60,8 +60,10 @@ if (file_exists(dirname(__FILE__)."/plugins/jshint/jshint.js")) {
echo $ICEcoder["openLastFiles"] ? 'true' : 'false';
echo ';top.ICEcoder.lineWrapping = ';
echo $ICEcoder["lineWrapping"] ? 'true' : 'false';
echo ';top.ICEcoder.tabWidth = ';
echo $ICEcoder["tabWidth"];
echo ';top.ICEcoder.indentWithTabs = ';
echo $ICEcoder["indentWithTabs"] ? 'true' : 'false';
echo ';top.ICEcoder.indentSize = ';
echo $ICEcoder["indentSize"];
?>;ICEcoder.init()<?php echo $updateMsg.$onLoadExtras;?>" onResize="ICEcoder.setLayout()" onKeyDown="return ICEcoder.interceptKeys('coder',event);" onKeyUp="parent.ICEcoder.resetKeys(event);">
<div id="blackMask" class="blackMask" onClick="ICEcoder.showHide('hide',this)" onContextMenu="return false">

View File

@@ -26,7 +26,8 @@ $ICEcoder = array(
),
"theme" => "default",
"lineWrapping" => true,
"tabWidth" => 4,
"indentWithTabs" => true,
"indentSize" => 4,
"previousFiles" => "",
"last10Files" => ""
);

View File

@@ -1431,7 +1431,7 @@ var ICEcoder = {
},
// Update the settings used when we make a change to them
useNewSettings: function(themeURL,codeAssist,lockedNav,visibleTabs,lineWrapping,tabWidth,refreshFM) {
useNewSettings: function(themeURL,codeAssist,lockedNav,visibleTabs,lineWrapping,indentWithTabs,indentSize,refreshFM) {
var styleNode, strCSS, cMCSS, activeLineBG;
// Add new stylesheet for selected theme
@@ -1461,11 +1461,13 @@ var ICEcoder = {
cMCSS[strCSS][2].style.cssText = "background: " + activeLineBG + " !important";
top.ICEcoder.lineWrapping = lineWrapping;
top.ICEcoder.tabWidth = tabWidth;
top.ICEcoder.indentWithTabs = indentWithTabs;
top.ICEcoder.indentSize = indentSize;
for (var i=0;i<ICEcoder.cMInstances.length;i++) {
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setOption("lineWrapping", top.ICEcoder.lineWrapping);
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setOption("indentUnit", top.ICEcoder.tabWidth);
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setOption("tabSize", top.ICEcoder.tabWidth);
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setOption("indentWithTabs", top.ICEcoder.indentWithTabs);
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setOption("indentUnit", top.ICEcoder.indentSize);
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setOption("tabSize", top.ICEcoder.indentSize);
}
// Finally, refresh the file manager if we need to

View File

@@ -148,8 +148,16 @@ for ($i=0;$i<count($themeArray);$i++) {
</span>
<span style="position: absolute; margin: -15px 0 0 120px">
tab width <span style="font-size: 10px; color: #888">chars</span><br>
<input type="text" name="tabWidth" id="tabWidth" style="width: 30px" onkeydown="showButton()" onkeyup="changeTabWidth()" value="<?php echo $ICEcoder["tabWidth"];?>">
indent type<br>
<select onchange="showButton()" name="indentWithTabs">
<option value="true"<?php if($ICEcoder["indentWithTabs"]) {echo " selected";};?>>tabs</option>
<option value="false"<?php if(!$ICEcoder["indentWithTabs"]) {echo " selected";};?>>spaces</option>
</select>
</span>
<span style="position: absolute; margin: -15px 0 0 220px">
indent size <span style="font-size: 10px; color: #888">chars</span><br>
<input type="text" name="indentSize" id="indentSize" style="width: 30px" onkeydown="showButton()" onkeyup="changeIndentSize()" value="<?php echo $ICEcoder["indentSize"];?>">
</span>
<br><br>
@@ -178,8 +186,8 @@ function findSequence(goal) {
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
readOnly: "nocursor",
indentUnit: top.ICEcoder.tabWidth,
tabSize: top.ICEcoder.tabWidth,
indentUnit: top.ICEcoder.indentSize,
tabSize: top.ICEcoder.indentSize,
mode: "javascript",
theme: "<?php echo $ICEcoder["theme"]=="default" ? 'icecoder' : $ICEcoder["theme"];?>"
});
@@ -191,10 +199,10 @@ function selectTheme() {
editor.setOption("theme", theme);
}
function changeTabWidth() {
var tabWidth = document.getElementById("tabWidth").value;
editor.setOption("indentUnit", tabWidth);
editor.setOption("tabSize", tabWidth);
function changeIndentSize() {
var indentSize = document.getElementById("indentSize").value;
editor.setOption("indentUnit", indentSize);
editor.setOption("tabSize", indentSize);
}
var showButton = function() {

View File

@@ -84,9 +84,10 @@ if (!$demoMode && isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] && isset
$ICEcoder["plugins"] = 'array('.PHP_EOL.' array('.PHP_EOL.' '.str_replace('====================','),'.PHP_EOL.' array(',$_POST['plugins']).'))';
$ICEcoder["theme"] = strClean($_POST['theme']);
$ICEcoder["lineWrapping"] = strClean($_POST['lineWrapping']);
$ICEcoder["tabWidth"] = numClean($_POST['tabWidth']);
$ICEcoder["indentWithTabs"] = strClean($_POST['indentWithTabs']);
$ICEcoder["indentSize"] = numClean($_POST['indentSize']);
$settingsArray = array("root","checkUpdates","openLastFiles","findFilesExclude","codeAssist","visibleTabs","lockedNav","accountPassword","bannedFiles","bannedPaths","allowedIPs","plugins","theme","lineWrapping","tabWidth");
$settingsArray = array("root","checkUpdates","openLastFiles","findFilesExclude","codeAssist","visibleTabs","lockedNav","accountPassword","bannedFiles","bannedPaths","allowedIPs","plugins","theme","lineWrapping","indentWithTabs","indentSize");
$settingsNew = "";
for ($i=0;$i<count($settingsArray);$i++) {
$settingsNew .= '"'.$settingsArray[$i].'"'.PHP_EOL.' => ';
@@ -115,7 +116,7 @@ if (!$demoMode && isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] && isset
// Do we need a file manager refresh?
$refreshFM = $_POST['changedFileSettings']=="true" ? "true" : "false";
// With all that worked out, we can now hide the settings screen and apply the new settings
echo "<script>top.ICEcoder.settingsScreen('hide');top.ICEcoder.useNewSettings('".$themeURL."',".$ICEcoder["codeAssist"].",".$ICEcoder["lockedNav"].",".$ICEcoder["visibleTabs"].",".$ICEcoder["lineWrapping"].",".$ICEcoder["tabWidth"].",".$refreshFM.");</script>";
echo "<script>top.ICEcoder.settingsScreen('hide');top.ICEcoder.useNewSettings('".$themeURL."',".$ICEcoder["codeAssist"].",".$ICEcoder["lockedNav"].",".$ICEcoder["visibleTabs"].",".$ICEcoder["lineWrapping"].",".$ICEcoder["indentWithTabs"].",".$ICEcoder["indentSize"].",".$refreshFM.");</script>";
}
// Establish our user level