Merge "InlineEdit: make autoindent width (indentUnit) configurable"
This commit is contained in:
@@ -1361,6 +1361,7 @@ link:#edit-preferences-info[EditPreferencesInfo] entity.
|
||||
"key_map_type": "VIM",
|
||||
"tab_size": 4,
|
||||
"line_length": 80,
|
||||
"indent_unit": 2,
|
||||
"cursor_blink_rate": 530,
|
||||
"hide_top_menu": true,
|
||||
"show_whitespace_errors": true,
|
||||
@@ -1391,6 +1392,7 @@ link:#edit-preferences-info[EditPreferencesInfo] entity.
|
||||
"key_map_type": "VIM",
|
||||
"tab_size": 4,
|
||||
"line_length": 80,
|
||||
"indent_unit": 2,
|
||||
"cursor_blink_rate": 530,
|
||||
"hide_top_menu": true,
|
||||
"show_tabs": true,
|
||||
@@ -1817,6 +1819,8 @@ supported: `DEFAULT`, `EMACS`, `VIM`.
|
||||
Number of spaces that should be used to display one tab.
|
||||
|`line_length` ||
|
||||
Number of characters that should be displayed per line.
|
||||
|`indent_unit` ||
|
||||
Number of spaces that should be used for auto-indent.
|
||||
|`cursor_blink_rate` ||
|
||||
Half-period in milliseconds used for cursor blinking.
|
||||
Setting it to 0 disables cursor blinking.
|
||||
|
||||
@@ -33,6 +33,7 @@ public class EditPreferencesIT extends AbstractDaemonTest {
|
||||
.getEditPreferences();
|
||||
|
||||
assertThat(out.lineLength).isEqualTo(100);
|
||||
assertThat(out.indentUnit).isEqualTo(2);
|
||||
assertThat(out.tabSize).isEqualTo(8);
|
||||
assertThat(out.cursorBlinkRate).isEqualTo(0);
|
||||
assertThat(out.hideTopMenu).isNull();
|
||||
@@ -47,6 +48,7 @@ public class EditPreferencesIT extends AbstractDaemonTest {
|
||||
|
||||
// change some default values
|
||||
out.lineLength = 80;
|
||||
out.indentUnit = 4;
|
||||
out.tabSize = 4;
|
||||
out.cursorBlinkRate = 500;
|
||||
out.hideTopMenu = true;
|
||||
@@ -80,6 +82,7 @@ public class EditPreferencesIT extends AbstractDaemonTest {
|
||||
private void assertEditPreferences(EditPreferencesInfo out,
|
||||
EditPreferencesInfo in) throws Exception {
|
||||
assertThat(out.lineLength).isEqualTo(in.lineLength);
|
||||
assertThat(out.indentUnit).isEqualTo(in.indentUnit);
|
||||
assertThat(out.tabSize).isEqualTo(in.tabSize);
|
||||
assertThat(out.cursorBlinkRate).isEqualTo(in.cursorBlinkRate);
|
||||
assertThat(out.hideTopMenu).isEqualTo(in.hideTopMenu);
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.google.gerrit.extensions.client;
|
||||
public class EditPreferencesInfo {
|
||||
public Integer tabSize;
|
||||
public Integer lineLength;
|
||||
public Integer indentUnit;
|
||||
public Integer cursorBlinkRate;
|
||||
public Boolean hideTopMenu;
|
||||
public Boolean showTabs;
|
||||
@@ -33,6 +34,7 @@ public class EditPreferencesInfo {
|
||||
EditPreferencesInfo i = new EditPreferencesInfo();
|
||||
i.tabSize = 8;
|
||||
i.lineLength = 100;
|
||||
i.indentUnit = 2;
|
||||
i.cursorBlinkRate = 0;
|
||||
i.hideTopMenu = false;
|
||||
i.showTabs = true;
|
||||
|
||||
@@ -24,6 +24,7 @@ public class EditPreferences extends JavaScriptObject {
|
||||
EditPreferences p = createObject().cast();
|
||||
p.tabSize(in.tabSize);
|
||||
p.lineLength(in.lineLength);
|
||||
p.indentUnit(in.indentUnit);
|
||||
p.cursorBlinkRate(in.cursorBlinkRate);
|
||||
p.hideTopMenu(in.hideTopMenu);
|
||||
p.showTabs(in.showTabs);
|
||||
@@ -40,6 +41,7 @@ public class EditPreferences extends JavaScriptObject {
|
||||
public final EditPreferencesInfo copyTo(EditPreferencesInfo p) {
|
||||
p.tabSize = tabSize();
|
||||
p.lineLength = lineLength();
|
||||
p.indentUnit = indentUnit();
|
||||
p.cursorBlinkRate = cursorBlinkRate();
|
||||
p.hideTopMenu = hideTopMenu();
|
||||
p.showTabs = showTabs();
|
||||
@@ -65,6 +67,7 @@ public class EditPreferences extends JavaScriptObject {
|
||||
|
||||
public final native void tabSize(int t) /*-{ this.tab_size = t }-*/;
|
||||
public final native void lineLength(int c) /*-{ this.line_length = c }-*/;
|
||||
public final native void indentUnit(int c) /*-{ this.indent_unit = c }-*/;
|
||||
public final native void cursorBlinkRate(int r) /*-{ this.cursor_blink_rate = r }-*/;
|
||||
public final native void hideTopMenu(boolean s) /*-{ this.hide_top_menu = s }-*/;
|
||||
public final native void showTabs(boolean s) /*-{ this.show_tabs = s }-*/;
|
||||
@@ -94,6 +97,10 @@ public class EditPreferences extends JavaScriptObject {
|
||||
return get("line_length", 100);
|
||||
}
|
||||
|
||||
public final int indentUnit() {
|
||||
return get("indent_unit", 2);
|
||||
}
|
||||
|
||||
public final int cursorBlinkRate() {
|
||||
return get("cursor_blink_rate", 0);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user