InlineEdit: Make cursor blink rate customizable
Codemirror supports out of the box customizability of cursor blink rate. Half-period in milliseconds is used for cursor blinking. The default blink rate in Codemirror is 530ms. Default in inline editor is 0: blinking is disabled. Change-Id: Ie54063f3ba11e98dcebaf727e29b50093258c028
This commit is contained in:
@@ -56,6 +56,7 @@ class EditPreferencesBox extends Composite {
|
||||
@UiField Anchor close;
|
||||
@UiField NpIntTextBox tabWidth;
|
||||
@UiField NpIntTextBox lineLength;
|
||||
@UiField NpIntTextBox cursorBlinkRate;
|
||||
@UiField ToggleButton topMenu;
|
||||
@UiField ToggleButton syntaxHighlighting;
|
||||
@UiField ToggleButton showTabs;
|
||||
@@ -78,6 +79,7 @@ class EditPreferencesBox extends Composite {
|
||||
|
||||
tabWidth.setIntValue(prefs.tabSize());
|
||||
lineLength.setIntValue(prefs.lineLength());
|
||||
cursorBlinkRate.setIntValue(prefs.cursorBlinkRate());
|
||||
topMenu.setValue(!prefs.hideTopMenu());
|
||||
syntaxHighlighting.setValue(prefs.syntaxHighlighting());
|
||||
showTabs.setValue(prefs.showTabs());
|
||||
@@ -105,6 +107,17 @@ class EditPreferencesBox extends Composite {
|
||||
}
|
||||
}
|
||||
|
||||
@UiHandler("cursorBlinkRate")
|
||||
void onCursoBlinkRate(ValueChangeEvent<String> e) {
|
||||
String v = e.getValue();
|
||||
if (v != null && v.length() > 0) {
|
||||
// A negative value hides the cursor entirely:
|
||||
// don't let user shoot himself in the foot.
|
||||
prefs.cursorBlinkRate(Math.max(0, Integer.parseInt(v)));
|
||||
view.getEditor().setOption("cursorBlinkRate", prefs.cursorBlinkRate());
|
||||
}
|
||||
}
|
||||
|
||||
@UiHandler("topMenu")
|
||||
void onTopMenu(ValueChangeEvent<Boolean> e) {
|
||||
prefs.hideTopMenu(!e.getValue());
|
||||
|
||||
@@ -181,6 +181,12 @@ limitations under the License.
|
||||
visibleLength='4'
|
||||
alignment='RIGHT'/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><ui:msg>Cursor Blink Rate</ui:msg></th>
|
||||
<td><x:NpIntTextBox ui:field='cursorBlinkRate'
|
||||
visibleLength='4'
|
||||
alignment='RIGHT'/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><ui:msg>Top Menu</ui:msg></th>
|
||||
<td><g:ToggleButton ui:field='topMenu'>
|
||||
|
||||
@@ -441,7 +441,7 @@ public class EditScreen extends Screen {
|
||||
cm = CodeMirror.create(editor, Configuration.create()
|
||||
.set("value", content)
|
||||
.set("readOnly", false)
|
||||
.set("cursorBlinkRate", 0)
|
||||
.set("cursorBlinkRate", prefs.cursorBlinkRate())
|
||||
.set("cursorHeight", 0.85)
|
||||
.set("lineNumbers", prefs.hideLineNumbers())
|
||||
.set("tabSize", prefs.tabSize())
|
||||
|
||||
Reference in New Issue
Block a user