InlineEdit: make autoindent width (indentUnit) configurable

Allow to configure the indent unit for inline edit mode.
Currently it is not possible to configure it per file-type
(e.g java:2, python:4),
but one can adjust it via the edit preferences.

Change-Id: Ie5167c615f963212f53ec3c87c687dba0f043010
This commit is contained in:
Björn Pedersen
2016-04-13 11:04:24 +02:00
parent 92ba0dd270
commit dc0503895b
7 changed files with 41 additions and 0 deletions

View File

@@ -60,6 +60,7 @@ public class EditPreferencesBox extends Composite {
@UiField Anchor close;
@UiField NpIntTextBox tabWidth;
@UiField NpIntTextBox lineLength;
@UiField NpIntTextBox indentUnit;
@UiField NpIntTextBox cursorBlinkRate;
@UiField ToggleButton topMenu;
@UiField ToggleButton syntaxHighlighting;
@@ -94,6 +95,7 @@ public class EditPreferencesBox extends Composite {
tabWidth.setIntValue(prefs.tabSize());
lineLength.setIntValue(prefs.lineLength());
indentUnit.setIntValue(prefs.indentUnit());
cursorBlinkRate.setIntValue(prefs.cursorBlinkRate());
topMenu.setValue(!prefs.hideTopMenu());
syntaxHighlighting.setValue(prefs.syntaxHighlighting());
@@ -128,6 +130,17 @@ public class EditPreferencesBox extends Composite {
}
}
@UiHandler("indentUnit")
void onIndentUnit(ValueChangeEvent<String> e) {
String v = e.getValue();
if (v != null && v.length() > 0) {
prefs.indentUnit(Math.max(0, Integer.parseInt(v)));
if (view != null) {
view.setIndentUnit(prefs.indentUnit());
}
}
}
@UiHandler("cursorBlinkRate")
void onCursoBlinkRate(ValueChangeEvent<String> e) {
String v = e.getValue();

View File

@@ -183,6 +183,12 @@ limitations under the License.
visibleLength='4'
alignment='RIGHT'/></td>
</tr>
<tr>
<th><ui:msg>Indent Unit</ui:msg></th>
<td><x:NpIntTextBox ui:field='indentUnit'
visibleLength='4'
alignment='RIGHT'/></td>
</tr>
<tr>
<th><ui:msg>Cursor Blink Rate</ui:msg></th>
<td><x:NpIntTextBox ui:field='cursorBlinkRate'

View File

@@ -366,6 +366,11 @@ public class EditScreen extends Screen {
Patch.COMMIT_MSG.equals(path) ? 72 : length);
}
void setIndentUnit(int indent) {
cm.setOption("indentUnit",
Patch.COMMIT_MSG.equals(path) ? 2 : indent);
}
void setShowLineNumbers(boolean show) {
cm.setOption("lineNumbers", show);
}
@@ -424,6 +429,7 @@ public class EditScreen extends Screen {
.set("autoCloseBrackets", prefs.autoCloseBrackets())
.set("cursorBlinkRate", prefs.cursorBlinkRate())
.set("cursorHeight", 0.85)
.set("indentUnit", prefs.indentUnit())
.set("keyMap", prefs.keyMapType().name().toLowerCase())
.set("lineNumbers", prefs.hideLineNumbers())
.set("lineWrapping", false)