Allow users to enable wrapping of code in SQL boxes. Fixes#2025
parent
1d571902da
commit
6fc8f040ff
|
@ -504,6 +504,9 @@ def browser_js():
|
|||
editor_use_spaces_pref = prefs.preference('use_spaces')
|
||||
editor_use_spaces = editor_use_spaces_pref.get()
|
||||
|
||||
editor_wrap_code_pref = prefs.preference('wrap_code')
|
||||
editor_wrap_code = editor_wrap_code_pref.get()
|
||||
|
||||
for submodule in current_blueprint.submodules:
|
||||
snippets.extend(submodule.jssnippets)
|
||||
return make_response(
|
||||
|
@ -515,6 +518,7 @@ def browser_js():
|
|||
edbas_help_path=edbas_help_path,
|
||||
editor_tab_size=editor_tab_size,
|
||||
editor_use_spaces=editor_use_spaces,
|
||||
editor_wrap_code=editor_wrap_code,
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'})
|
||||
|
|
|
@ -361,11 +361,11 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
|
|||
obj.editor = CodeMirror.fromTextArea(
|
||||
document.getElementById("sql-textarea"), {
|
||||
lineNumbers: true,
|
||||
lineWrapping: true,
|
||||
mode: "text/x-pgsql",
|
||||
readOnly: true,
|
||||
extraKeys: pgAdmin.Browser.editor_shortcut_keys,
|
||||
tabSize: pgAdmin.Browser.editor_options.tabSize
|
||||
tabSize: pgAdmin.Browser.editor_options.tabSize,
|
||||
lineWrapping: pgAdmin.Browser.editor_options.wrapCode
|
||||
});
|
||||
|
||||
setTimeout(function() {
|
||||
|
@ -1625,7 +1625,8 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
|
|||
"Cmd-Alt-Right": "goGroupRight"
|
||||
},
|
||||
editor_options: {
|
||||
tabSize: '{{ editor_tab_size }}'
|
||||
tabSize: '{{ editor_tab_size }}',
|
||||
wrapCode: '{{ editor_wrap_code }}' == 'True'
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1400,7 +1400,8 @@
|
|||
mode: "text/x-pgsql",
|
||||
readOnly: true,
|
||||
extraKeys: pgAdmin.Browser.editor_shortcut_keys,
|
||||
tabSize: pgAdmin.Browser.editor_options.tabSize
|
||||
tabSize: pgAdmin.Browser.editor_options.tabSize,
|
||||
lineWrapping: pgAdmin.Browser.editor_options.wrapCode
|
||||
});
|
||||
|
||||
/*
|
||||
|
@ -2171,7 +2172,8 @@
|
|||
lineNumbers: true,
|
||||
mode: "text/x-sql",
|
||||
extraKeys: pgAdmin.Browser.editor_shortcut_keys,
|
||||
tabSize: pgAdmin.Browser.editor_options.tabSize
|
||||
tabSize: pgAdmin.Browser.editor_options.tabSize,
|
||||
lineWrapping: pgAdmin.Browser.editor_options.wrapCode
|
||||
});
|
||||
|
||||
// Disable editor
|
||||
|
|
|
@ -252,7 +252,8 @@ define(
|
|||
indentUnit: 4,
|
||||
mode: "text/x-pgsql",
|
||||
extraKeys: pgBrowser.editor_shortcut_keys,
|
||||
tabSize: pgBrowser.editor_options.tabSize
|
||||
tabSize: pgBrowser.editor_options.tabSize,
|
||||
lineWrapping: pgAdmin.Browser.editor_options.wrapCode
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -1560,7 +1560,8 @@ define(
|
|||
mode: "text/x-pgsql",
|
||||
readOnly: true,
|
||||
extraKeys: pgAdmin.Browser.editor_shortcut_keys,
|
||||
tabSize: pgAdmin.Browser.editor_options.tabSize
|
||||
tabSize: pgAdmin.Browser.editor_options.tabSize,
|
||||
lineWrapping: pgAdmin.Browser.editor_options.wrapCode
|
||||
});
|
||||
|
||||
// On loading the docker, register the callbacks
|
||||
|
|
|
@ -146,6 +146,12 @@ class SqlEditorModule(PgAdminModule):
|
|||
help_str=gettext('Specifies whether or not to insert spaces instead of tabs when the tab key is used.')
|
||||
)
|
||||
|
||||
self.wrap_code = self.preference.register(
|
||||
'Options', 'wrap_code',
|
||||
gettext("Line wrapping?"), 'boolean', False,
|
||||
category_label=gettext('Options'),
|
||||
help_str=gettext('Specifies whether or not to wrap SQL code in editor.')
|
||||
)
|
||||
|
||||
blueprint = SqlEditorModule(MODULE_NAME, __name__, static_url_path='/static')
|
||||
|
||||
|
|
|
@ -190,7 +190,8 @@ define(
|
|||
},
|
||||
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
|
||||
extraKeys: pgBrowser.editor_shortcut_keys,
|
||||
tabSize: pgAdmin.Browser.editor_options.tabSize
|
||||
tabSize: pgAdmin.Browser.editor_options.tabSize,
|
||||
lineWrapping: pgAdmin.Browser.editor_options.wrapCode
|
||||
});
|
||||
|
||||
// Create main wcDocker instance
|
||||
|
@ -234,6 +235,7 @@ define(
|
|||
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
|
||||
extraKeys: pgBrowser.editor_shortcut_keys,
|
||||
tabSize: pgAdmin.Browser.editor_options.tabSize,
|
||||
lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
|
||||
scrollbarStyle: 'simple'
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue