Skip to content

Commit 9d0ec04

Browse files
Add support for changing cursor blink rate within the editors. pgadmin-org#8712
1 parent 24b4d35 commit 9d0ec04

4 files changed

Lines changed: 31 additions & 1 deletion

File tree

-27 KB
Loading

docs/en_US/preferences.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ Use the fields on the *Options* panel to manage editor preferences.
292292
* When the *Code folding?* switch is set to *False*, the editor will disable
293293
code folding. Disabling will improve editor performance with large files.
294294

295+
* Use the *Cursor blink rate* field to adjust the speed at which the text cursor
296+
blinks within the editors.
297+
295298
* Use the *Font family* field to be used for all SQL editors. The specified
296299
font should already be installed on your system. If the font is not found,
297300
the editor will fall back to the default font, Source Code Pro.

web/pgadmin/browser/register_editor_preferences.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,24 @@ def register_editor_preferences(self, migration_gettext=None):
150150
)
151151
)
152152

153+
self.editor_preference.register(
154+
'options', 'cursor_blink_rate',
155+
gettext("Cursor blink rate"), 'options', 'medium',
156+
category_label=PREF_LABEL_OPTIONS,
157+
options=[{'label': gettext('None'), 'value': 'none'},
158+
{'label': gettext('Slow'), 'value': 'slow'},
159+
{'label': gettext('Medium'), 'value': 'medium'},
160+
{'label': gettext('Fast'), 'value': 'fast'}],
161+
control_props={
162+
'allowClear': False,
163+
'creatable': False,
164+
},
165+
help_str=gettext(
166+
'Adjust the speed at which the text cursor blinks within '
167+
'the editors.'
168+
)
169+
)
170+
153171
self.editor_preference.register(
154172
'options', 'wrap_code',
155173
gettext("Line wrapping?"), 'boolean', False,

web/pgadmin/static/js/components/ReactCodeMirror/components/Editor.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ function insertTabWithUnit({ state, dispatch }) {
120120
/* React wrapper for CodeMirror */
121121
const defaultExtensions = [
122122
highlightSpecialChars(),
123-
drawSelection(),
124123
rectangularSelection(),
125124
dropCursor(),
126125
crosshairCursor(),
@@ -399,6 +398,16 @@ export default function Editor({
399398
}));
400399
}
401400

401+
const CURSOR_BLINK_RATE_MAP = {
402+
'none': 0,
403+
'slow': 1800,
404+
'medium': 1200,
405+
'fast': 600,
406+
};
407+
newConfigExtn.push(drawSelection({
408+
cursorBlinkRate: CURSOR_BLINK_RATE_MAP[editorPref.cursor_blink_rate] ?? 1200
409+
}));
410+
402411
// add fold service conditionally
403412
if(!editorPref.plain_editor_mode && editorPref.code_folding && language == 'pgsql') {
404413
newConfigExtn.push(plpgsqlFoldService);

0 commit comments

Comments
 (0)