Add support for CodeEditor edit config indentWithTabs

Will allow us to switch on or off the indentWithTabs config which will
indent the lines in tabs.

Bug: Issue 6609
Change-Id: If0e75de66a20d028ba066ff207f1d24e4633be27
This commit is contained in:
Paladox none
2017-06-28 17:03:33 +00:00
parent f4b2a76864
commit 6406b2c223
7 changed files with 33 additions and 0 deletions

View File

@@ -1525,6 +1525,7 @@ link:#edit-preferences-info[EditPreferencesInfo] entity.
"hide_line_numbers": true, "hide_line_numbers": true,
"match_brackets": true, "match_brackets": true,
"line_wrapping": false, "line_wrapping": false,
"indent_with_tabs": false,
"auto_close_brackets": true "auto_close_brackets": true
} }
---- ----
@@ -2428,6 +2429,8 @@ Number of spaces that should be used to display one tab.
Default font size in pixels for change to be displayed in the diff view. Default font size in pixels for change to be displayed in the diff view.
|`line_wrapping` |optional| |`line_wrapping` |optional|
Whether to enable line wrapping or not. Whether to enable line wrapping or not.
|`indent_with_tabs` |optional|
Whether to enable indent with tabs or not.
|=========================================== |===========================================
[[edit-preferences-info]] [[edit-preferences-info]]

View File

@@ -40,6 +40,7 @@ public class EditPreferencesIT extends AbstractDaemonTest {
assertThat(out.hideLineNumbers).isNull(); assertThat(out.hideLineNumbers).isNull();
assertThat(out.matchBrackets).isTrue(); assertThat(out.matchBrackets).isTrue();
assertThat(out.lineWrapping).isNull(); assertThat(out.lineWrapping).isNull();
assertThat(out.indentWithTabs).isNull();
assertThat(out.autoCloseBrackets).isNull(); assertThat(out.autoCloseBrackets).isNull();
assertThat(out.showBase).isNull(); assertThat(out.showBase).isNull();
assertThat(out.theme).isEqualTo(Theme.DEFAULT); assertThat(out.theme).isEqualTo(Theme.DEFAULT);
@@ -57,6 +58,7 @@ public class EditPreferencesIT extends AbstractDaemonTest {
out.hideLineNumbers = true; out.hideLineNumbers = true;
out.matchBrackets = false; out.matchBrackets = false;
out.lineWrapping = true; out.lineWrapping = true;
out.indentWithTabs = true;
out.autoCloseBrackets = true; out.autoCloseBrackets = true;
out.showBase = true; out.showBase = true;
out.theme = Theme.TWILIGHT; out.theme = Theme.TWILIGHT;
@@ -89,6 +91,7 @@ public class EditPreferencesIT extends AbstractDaemonTest {
assertThat(out.hideLineNumbers).isEqualTo(in.hideLineNumbers); assertThat(out.hideLineNumbers).isEqualTo(in.hideLineNumbers);
assertThat(out.matchBrackets).isNull(); assertThat(out.matchBrackets).isNull();
assertThat(out.lineWrapping).isEqualTo(in.lineWrapping); assertThat(out.lineWrapping).isEqualTo(in.lineWrapping);
assertThat(out.indentWithTabs).isEqualTo(in.indentWithTabs);
assertThat(out.autoCloseBrackets).isEqualTo(in.autoCloseBrackets); assertThat(out.autoCloseBrackets).isEqualTo(in.autoCloseBrackets);
assertThat(out.showBase).isEqualTo(in.showBase); assertThat(out.showBase).isEqualTo(in.showBase);
assertThat(out.theme).isEqualTo(in.theme); assertThat(out.theme).isEqualTo(in.theme);

View File

@@ -27,6 +27,7 @@ public class EditPreferencesInfo {
public Boolean hideLineNumbers; public Boolean hideLineNumbers;
public Boolean matchBrackets; public Boolean matchBrackets;
public Boolean lineWrapping; public Boolean lineWrapping;
public Boolean indentWithTabs;
public Boolean autoCloseBrackets; public Boolean autoCloseBrackets;
public Boolean showBase; public Boolean showBase;
public Theme theme; public Theme theme;
@@ -45,6 +46,7 @@ public class EditPreferencesInfo {
i.hideLineNumbers = false; i.hideLineNumbers = false;
i.matchBrackets = true; i.matchBrackets = true;
i.lineWrapping = false; i.lineWrapping = false;
i.indentWithTabs = false;
i.autoCloseBrackets = false; i.autoCloseBrackets = false;
i.showBase = false; i.showBase = false;
i.theme = Theme.DEFAULT; i.theme = Theme.DEFAULT;

View File

@@ -33,6 +33,7 @@ public class EditPreferences extends JavaScriptObject {
p.hideLineNumbers(in.hideLineNumbers); p.hideLineNumbers(in.hideLineNumbers);
p.matchBrackets(in.matchBrackets); p.matchBrackets(in.matchBrackets);
p.lineWrapping(in.lineWrapping); p.lineWrapping(in.lineWrapping);
p.indentWithTabs(in.indentWithTabs);
p.autoCloseBrackets(in.autoCloseBrackets); p.autoCloseBrackets(in.autoCloseBrackets);
p.showBase(in.showBase); p.showBase(in.showBase);
p.theme(in.theme); p.theme(in.theme);
@@ -52,6 +53,7 @@ public class EditPreferences extends JavaScriptObject {
p.hideLineNumbers = hideLineNumbers(); p.hideLineNumbers = hideLineNumbers();
p.matchBrackets = matchBrackets(); p.matchBrackets = matchBrackets();
p.lineWrapping = lineWrapping(); p.lineWrapping = lineWrapping();
p.indentWithTabs = indentWithTabs();
p.autoCloseBrackets = autoCloseBrackets(); p.autoCloseBrackets = autoCloseBrackets();
p.showBase = showBase(); p.showBase = showBase();
p.theme = theme(); p.theme = theme();
@@ -94,6 +96,8 @@ public class EditPreferences extends JavaScriptObject {
public final native void lineWrapping(boolean w) /*-{ this.line_wrapping = w }-*/; public final native void lineWrapping(boolean w) /*-{ this.line_wrapping = w }-*/;
public final native void indentWithTabs(boolean w) /*-{ this.indent_with_tabs = w }-*/;
public final native void autoCloseBrackets(boolean c) /*-{ this.auto_close_brackets = c }-*/; public final native void autoCloseBrackets(boolean c) /*-{ this.auto_close_brackets = c }-*/;
public final native void showBase(boolean s) /*-{ this.show_base = s }-*/; public final native void showBase(boolean s) /*-{ this.show_base = s }-*/;
@@ -144,6 +148,8 @@ public class EditPreferences extends JavaScriptObject {
public final native boolean lineWrapping() /*-{ return this.line_wrapping || false }-*/; public final native boolean lineWrapping() /*-{ return this.line_wrapping || false }-*/;
public final native boolean indentWithTabs() /*-{ return this.indent_with_tabs || false }-*/;
public final native boolean public final native boolean
autoCloseBrackets() /*-{ return this.auto_close_brackets || false }-*/; autoCloseBrackets() /*-{ return this.auto_close_brackets || false }-*/;

View File

@@ -69,6 +69,7 @@ public class EditPreferencesBox extends Composite {
@UiField ToggleButton lineNumbers; @UiField ToggleButton lineNumbers;
@UiField ToggleButton matchBrackets; @UiField ToggleButton matchBrackets;
@UiField ToggleButton lineWrapping; @UiField ToggleButton lineWrapping;
@UiField ToggleButton indentWithTabs;
@UiField ToggleButton autoCloseBrackets; @UiField ToggleButton autoCloseBrackets;
@UiField ToggleButton showBase; @UiField ToggleButton showBase;
@UiField ListBox theme; @UiField ListBox theme;
@@ -106,6 +107,7 @@ public class EditPreferencesBox extends Composite {
lineNumbers.setValue(prefs.hideLineNumbers()); lineNumbers.setValue(prefs.hideLineNumbers());
matchBrackets.setValue(prefs.matchBrackets()); matchBrackets.setValue(prefs.matchBrackets());
lineWrapping.setValue(prefs.lineWrapping()); lineWrapping.setValue(prefs.lineWrapping());
indentWithTabs.setValue(prefs.indentWithTabs());
autoCloseBrackets.setValue(prefs.autoCloseBrackets()); autoCloseBrackets.setValue(prefs.autoCloseBrackets());
showBase.setValue(prefs.showBase()); showBase.setValue(prefs.showBase());
setTheme(prefs.theme()); setTheme(prefs.theme());
@@ -215,6 +217,15 @@ public class EditPreferencesBox extends Composite {
} }
} }
@UiHandler("indentWithTabs")
void onIndentWithTabs(ValueChangeEvent<Boolean> e) {
prefs.indentWithTabs(e.getValue());
if (view != null) {
view.getEditor().setOption("indentWithTabs", prefs.indentWithTabs());
}
}
@UiHandler("autoCloseBrackets") @UiHandler("autoCloseBrackets")
void onCloseBrackets(ValueChangeEvent<Boolean> e) { void onCloseBrackets(ValueChangeEvent<Boolean> e) {
prefs.autoCloseBrackets(e.getValue()); prefs.autoCloseBrackets(e.getValue());

View File

@@ -245,6 +245,13 @@ limitations under the License.
<g:downFace><ui:msg>On</ui:msg></g:downFace> <g:downFace><ui:msg>On</ui:msg></g:downFace>
</g:ToggleButton></td> </g:ToggleButton></td>
</tr> </tr>
<tr>
<th><ui:msg>Indent With Tabs</ui:msg></th>
<td><g:ToggleButton ui:field='indentWithTabs'>
<g:upFace><ui:msg>Off</ui:msg></g:upFace>
<g:downFace><ui:msg>On</ui:msg></g:downFace>
</g:ToggleButton></td>
</tr>
<tr> <tr>
<th><ui:msg>Auto Close Brackets</ui:msg></th> <th><ui:msg>Auto Close Brackets</ui:msg></th>
<td><g:ToggleButton ui:field='autoCloseBrackets'> <td><g:ToggleButton ui:field='autoCloseBrackets'>

View File

@@ -581,6 +581,7 @@ public class EditScreen extends Screen {
.set("keyMap", prefs.keyMapType().name().toLowerCase()) .set("keyMap", prefs.keyMapType().name().toLowerCase())
.set("lineNumbers", prefs.hideLineNumbers()) .set("lineNumbers", prefs.hideLineNumbers())
.set("lineWrapping", prefs.lineWrapping()) .set("lineWrapping", prefs.lineWrapping())
.set("indentWithTabs", prefs.indentWithTabs())
.set("matchBrackets", prefs.matchBrackets()) .set("matchBrackets", prefs.matchBrackets())
.set("mode", mode != null ? mode.mime() : null) .set("mode", mode != null ? mode.mime() : null)
.set("origLeft", editContent) .set("origLeft", editContent)