InlineEdit: Allow to activate match brackets Codemirror addon

Codemirror matchbrackets.js addon defines an option `matchBrackets`
which, when set to true, causes matching brackets to be highlighted
whenever the cursor is next to them. Set default to be true.

Change-Id: I8d107a70af484562f5938fe41245f0603b820492
This commit is contained in:
David Ostrovsky 2015-05-15 00:00:48 +02:00
parent 85f843a657
commit c232840a1a
8 changed files with 32 additions and 2 deletions

View File

@ -1345,7 +1345,8 @@ link:#edit-preferences-info[EditPreferencesInfo] entity.
"cursor_blink_rate": 530,
"hide_top_menu": true,
"show_whitespace_errors": true,
"hide_line_numbers": true
"hide_line_numbers": true,
"match_brackets": true
}
----
@ -1375,7 +1376,8 @@ link:#edit-preferences-info[EditPreferencesInfo] entity.
"show_tabs": true,
"show_whitespace_errors": true,
"syntax_highlighting": true,
"hide_line_numbers": true
"hide_line_numbers": true,
"match_brackets": true
}
----
@ -1781,6 +1783,8 @@ Whether whitespace errors should be shown.
Whether syntax highlighting should be enabled.
|`hide_line_numbers` |not set if `false`|
Whether line numbers should be hidden.
|`match_brackets` |not set if `false`|
Whether matching brackets should be highlighted.
|===========================================
[[email-info]]

View File

@ -43,6 +43,7 @@ public class EditPreferencesIT extends AbstractDaemonTest {
assertThat(out.showWhitespaceErrors).isNull();
assertThat(out.syntaxHighlighting).isTrue();
assertThat(out.hideLineNumbers).isNull();
assertThat(out.matchBrackets).isTrue();
assertThat(out.theme).isEqualTo(Theme.DEFAULT);
assertThat(out.keyMapType).isEqualTo(KeyMapType.DEFAULT);
@ -55,6 +56,7 @@ public class EditPreferencesIT extends AbstractDaemonTest {
out.showWhitespaceErrors = true;
out.syntaxHighlighting = false;
out.hideLineNumbers = true;
out.matchBrackets = false;
out.theme = Theme.TWILIGHT;
out.keyMapType = KeyMapType.EMACS;
@ -83,6 +85,7 @@ public class EditPreferencesIT extends AbstractDaemonTest {
assertThat(out.showWhitespaceErrors).isEqualTo(in.showWhitespaceErrors);
assertThat(out.syntaxHighlighting).isNull();
assertThat(out.hideLineNumbers).isEqualTo(in.hideLineNumbers);
assertThat(out.matchBrackets).isNull();
assertThat(out.theme).isEqualTo(in.theme);
assertThat(out.keyMapType).isEqualTo(in.keyMapType);
}

View File

@ -24,6 +24,7 @@ public class EditPreferencesInfo {
public Boolean showWhitespaceErrors;
public Boolean syntaxHighlighting;
public Boolean hideLineNumbers;
public Boolean matchBrackets;
public Theme theme;
public KeyMapType keyMapType;
@ -37,6 +38,7 @@ public class EditPreferencesInfo {
i.showWhitespaceErrors = false;
i.syntaxHighlighting = true;
i.hideLineNumbers = false;
i.matchBrackets = true;
i.theme = Theme.DEFAULT;
i.keyMapType = KeyMapType.DEFAULT;
return i;

View File

@ -30,6 +30,7 @@ public class EditPreferences extends JavaScriptObject {
p.showWhitespaceErrors(in.showWhitespaceErrors);
p.syntaxHighlighting(in.syntaxHighlighting);
p.hideLineNumbers(in.hideLineNumbers);
p.matchBrackets(in.matchBrackets);
p.theme(in.theme);
p.keyMapType(in.keyMapType);
return p;
@ -44,6 +45,7 @@ public class EditPreferences extends JavaScriptObject {
p.showWhitespaceErrors = showWhitespaceErrors();
p.syntaxHighlighting = syntaxHighlighting();
p.hideLineNumbers = hideLineNumbers();
p.matchBrackets = matchBrackets();
p.theme = theme();
p.keyMapType = keyMapType();
}
@ -66,6 +68,7 @@ public class EditPreferences extends JavaScriptObject {
public final native void showWhitespaceErrors(boolean s) /*-{ this.show_whitespace_errors = s }-*/;
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 Theme theme() {
String s = themeRaw();
@ -87,6 +90,7 @@ public class EditPreferences extends JavaScriptObject {
public final native boolean showWhitespaceErrors() /*-{ return this.show_whitespace_errors || false }-*/;
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 }-*/;
private final native int get(String n, int d) /*-{ return this.hasOwnProperty(n) ? this[n] : d }-*/;
protected EditPreferences() {

View File

@ -62,6 +62,7 @@ class EditPreferencesBox extends Composite {
@UiField ToggleButton showTabs;
@UiField ToggleButton whitespaceErrors;
@UiField ToggleButton lineNumbers;
@UiField ToggleButton matchBrackets;
@UiField ListBox theme;
@UiField ListBox keyMap;
@UiField Button apply;
@ -85,6 +86,7 @@ class EditPreferencesBox extends Composite {
showTabs.setValue(prefs.showTabs());
whitespaceErrors.setValue(prefs.showWhitespaceErrors());
lineNumbers.setValue(prefs.hideLineNumbers());
matchBrackets.setValue(prefs.matchBrackets());
setTheme(prefs.theme());
setKeyMapType(prefs.keyMapType());
}
@ -149,6 +151,12 @@ class EditPreferencesBox extends Composite {
view.setSyntaxHighlighting(prefs.syntaxHighlighting());
}
@UiHandler("matchBrackets")
void onMatchBrackets(ValueChangeEvent<Boolean> e) {
prefs.matchBrackets(e.getValue());
view.getEditor().setOption("matchBrackets", prefs.matchBrackets());
}
@UiHandler("theme")
void onTheme(@SuppressWarnings("unused") ChangeEvent e) {
final Theme newTheme = Theme.valueOf(theme.getValue(theme.getSelectedIndex()));

View File

@ -222,6 +222,13 @@ limitations under the License.
<g:downFace><ui:msg>Show</ui:msg></g:downFace>
</g:ToggleButton></td>
</tr>
<tr>
<th><ui:msg>Match Brackets</ui:msg></th>
<td><g:ToggleButton ui:field='matchBrackets'>
<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>

View File

@ -446,6 +446,7 @@ public class EditScreen extends Screen {
.set("lineNumbers", prefs.hideLineNumbers())
.set("tabSize", prefs.tabSize())
.set("lineWrapping", false)
.set("matchBrackets", prefs.matchBrackets())
.set("scrollbarStyle", "overlay")
.set("styleSelectedText", true)
.set("showTrailingSpace", prefs.showWhitespaceErrors())

View File

@ -14,6 +14,7 @@ CM_JS = [
CM_ADDONS = [
'dialog/dialog.js',
'edit/matchbrackets.js',
'edit/trailingspace.js',
'scroll/annotatescrollbar.js',
'scroll/simplescrollbars.js',