InlineEdit: Allow to activate auto-close brackets Codemirror addon
Codemirror closebrackets.js addons defines an option `autoCloseBrackets` that will auto-close brackets and quotes when typed. By default, it will auto-close ()[]{}''"". Change-Id: I844d49c7d60d8fc78808df566e4c4f9aff1b012e
This commit is contained in:
parent
c232840a1a
commit
3cd7a19ea0
@ -1346,7 +1346,8 @@ link:#edit-preferences-info[EditPreferencesInfo] entity.
|
||||
"hide_top_menu": true,
|
||||
"show_whitespace_errors": true,
|
||||
"hide_line_numbers": true,
|
||||
"match_brackets": true
|
||||
"match_brackets": true,
|
||||
"auto_close_brackets": true
|
||||
}
|
||||
----
|
||||
|
||||
@ -1377,7 +1378,8 @@ link:#edit-preferences-info[EditPreferencesInfo] entity.
|
||||
"show_whitespace_errors": true,
|
||||
"syntax_highlighting": true,
|
||||
"hide_line_numbers": true,
|
||||
"match_brackets": true
|
||||
"match_brackets": true,
|
||||
"auto_close_brackets": true
|
||||
}
|
||||
----
|
||||
|
||||
@ -1785,6 +1787,8 @@ Whether syntax highlighting should be enabled.
|
||||
Whether line numbers should be hidden.
|
||||
|`match_brackets` |not set if `false`|
|
||||
Whether matching brackets should be highlighted.
|
||||
|`auto_close_brackets` |not set if `false`|
|
||||
Whether brackets and quotes should be auto-closed during typing.
|
||||
|===========================================
|
||||
|
||||
[[email-info]]
|
||||
|
@ -44,6 +44,7 @@ public class EditPreferencesIT extends AbstractDaemonTest {
|
||||
assertThat(out.syntaxHighlighting).isTrue();
|
||||
assertThat(out.hideLineNumbers).isNull();
|
||||
assertThat(out.matchBrackets).isTrue();
|
||||
assertThat(out.autoCloseBrackets).isNull();
|
||||
assertThat(out.theme).isEqualTo(Theme.DEFAULT);
|
||||
assertThat(out.keyMapType).isEqualTo(KeyMapType.DEFAULT);
|
||||
|
||||
@ -57,6 +58,7 @@ public class EditPreferencesIT extends AbstractDaemonTest {
|
||||
out.syntaxHighlighting = false;
|
||||
out.hideLineNumbers = true;
|
||||
out.matchBrackets = false;
|
||||
out.autoCloseBrackets = true;
|
||||
out.theme = Theme.TWILIGHT;
|
||||
out.keyMapType = KeyMapType.EMACS;
|
||||
|
||||
@ -86,6 +88,7 @@ public class EditPreferencesIT extends AbstractDaemonTest {
|
||||
assertThat(out.syntaxHighlighting).isNull();
|
||||
assertThat(out.hideLineNumbers).isEqualTo(in.hideLineNumbers);
|
||||
assertThat(out.matchBrackets).isNull();
|
||||
assertThat(out.autoCloseBrackets).isEqualTo(in.autoCloseBrackets);
|
||||
assertThat(out.theme).isEqualTo(in.theme);
|
||||
assertThat(out.keyMapType).isEqualTo(in.keyMapType);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ public class EditPreferencesInfo {
|
||||
public Boolean syntaxHighlighting;
|
||||
public Boolean hideLineNumbers;
|
||||
public Boolean matchBrackets;
|
||||
public Boolean autoCloseBrackets;
|
||||
public Theme theme;
|
||||
public KeyMapType keyMapType;
|
||||
|
||||
@ -39,6 +40,7 @@ public class EditPreferencesInfo {
|
||||
i.syntaxHighlighting = true;
|
||||
i.hideLineNumbers = false;
|
||||
i.matchBrackets = true;
|
||||
i.autoCloseBrackets = false;
|
||||
i.theme = Theme.DEFAULT;
|
||||
i.keyMapType = KeyMapType.DEFAULT;
|
||||
return i;
|
||||
|
@ -31,6 +31,7 @@ public class EditPreferences extends JavaScriptObject {
|
||||
p.syntaxHighlighting(in.syntaxHighlighting);
|
||||
p.hideLineNumbers(in.hideLineNumbers);
|
||||
p.matchBrackets(in.matchBrackets);
|
||||
p.autoCloseBrackets(in.autoCloseBrackets);
|
||||
p.theme(in.theme);
|
||||
p.keyMapType(in.keyMapType);
|
||||
return p;
|
||||
@ -46,6 +47,7 @@ public class EditPreferences extends JavaScriptObject {
|
||||
p.syntaxHighlighting = syntaxHighlighting();
|
||||
p.hideLineNumbers = hideLineNumbers();
|
||||
p.matchBrackets = matchBrackets();
|
||||
p.autoCloseBrackets = autoCloseBrackets();
|
||||
p.theme = theme();
|
||||
p.keyMapType = keyMapType();
|
||||
}
|
||||
@ -69,6 +71,7 @@ public class EditPreferences extends JavaScriptObject {
|
||||
public final native void syntaxHighlighting(boolean s) /*-{ this.syntax_highlighting = s }-*/;
|
||||
public final native void hideLineNumbers(boolean s) /*-{ this.hide_line_numbers = s }-*/;
|
||||
public final native void matchBrackets(boolean m) /*-{ this.match_brackets = m }-*/;
|
||||
public final native void autoCloseBrackets(boolean c) /*-{ this.auto_close_brackets = c }-*/;
|
||||
|
||||
public final Theme theme() {
|
||||
String s = themeRaw();
|
||||
@ -91,6 +94,7 @@ public class EditPreferences extends JavaScriptObject {
|
||||
public final native boolean syntaxHighlighting() /*-{ return this.syntax_highlighting || false }-*/;
|
||||
public final native boolean hideLineNumbers() /*-{ return this.hide_line_numbers || false }-*/;
|
||||
public final native boolean matchBrackets() /*-{ return this.match_brackets || false }-*/;
|
||||
public final native boolean autoCloseBrackets() /*-{ return this.auto_close_brackets || false }-*/;
|
||||
private final native int get(String n, int d) /*-{ return this.hasOwnProperty(n) ? this[n] : d }-*/;
|
||||
|
||||
protected EditPreferences() {
|
||||
|
@ -63,6 +63,7 @@ class EditPreferencesBox extends Composite {
|
||||
@UiField ToggleButton whitespaceErrors;
|
||||
@UiField ToggleButton lineNumbers;
|
||||
@UiField ToggleButton matchBrackets;
|
||||
@UiField ToggleButton autoCloseBrackets;
|
||||
@UiField ListBox theme;
|
||||
@UiField ListBox keyMap;
|
||||
@UiField Button apply;
|
||||
@ -87,6 +88,7 @@ class EditPreferencesBox extends Composite {
|
||||
whitespaceErrors.setValue(prefs.showWhitespaceErrors());
|
||||
lineNumbers.setValue(prefs.hideLineNumbers());
|
||||
matchBrackets.setValue(prefs.matchBrackets());
|
||||
autoCloseBrackets.setValue(prefs.autoCloseBrackets());
|
||||
setTheme(prefs.theme());
|
||||
setKeyMapType(prefs.keyMapType());
|
||||
}
|
||||
@ -157,6 +159,12 @@ class EditPreferencesBox extends Composite {
|
||||
view.getEditor().setOption("matchBrackets", prefs.matchBrackets());
|
||||
}
|
||||
|
||||
@UiHandler("autoCloseBrackets")
|
||||
void onCloseBrackets(ValueChangeEvent<Boolean> e) {
|
||||
prefs.autoCloseBrackets(e.getValue());
|
||||
view.getEditor().setOption("autoCloseBrackets", prefs.autoCloseBrackets());
|
||||
}
|
||||
|
||||
@UiHandler("theme")
|
||||
void onTheme(@SuppressWarnings("unused") ChangeEvent e) {
|
||||
final Theme newTheme = Theme.valueOf(theme.getValue(theme.getSelectedIndex()));
|
||||
|
@ -229,6 +229,13 @@ limitations under the License.
|
||||
<g:downFace><ui:msg>On</ui:msg></g:downFace>
|
||||
</g:ToggleButton></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><ui:msg>Auto Close Brackets</ui:msg></th>
|
||||
<td><g:ToggleButton ui:field='autoCloseBrackets'>
|
||||
<g:upFace><ui:msg>Off</ui:msg></g:upFace>
|
||||
<g:downFace><ui:msg>On</ui:msg></g:downFace>
|
||||
</g:ToggleButton></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
|
@ -447,6 +447,7 @@ public class EditScreen extends Screen {
|
||||
.set("tabSize", prefs.tabSize())
|
||||
.set("lineWrapping", false)
|
||||
.set("matchBrackets", prefs.matchBrackets())
|
||||
.set("autoCloseBrackets", prefs.autoCloseBrackets())
|
||||
.set("scrollbarStyle", "overlay")
|
||||
.set("styleSelectedText", true)
|
||||
.set("showTrailingSpace", prefs.showWhitespaceErrors())
|
||||
|
@ -14,6 +14,7 @@ CM_JS = [
|
||||
|
||||
CM_ADDONS = [
|
||||
'dialog/dialog.js',
|
||||
'edit/closebrackets.js',
|
||||
'edit/matchbrackets.js',
|
||||
'edit/trailingspace.js',
|
||||
'scroll/annotatescrollbar.js',
|
||||
|
Loading…
Reference in New Issue
Block a user