diff --git a/web/pgadmin/browser/__init__.py b/web/pgadmin/browser/__init__.py index 7a8e9f8..6c9e1bb 100644 --- a/web/pgadmin/browser/__init__.py +++ b/web/pgadmin/browser/__init__.py @@ -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'}) diff --git a/web/pgadmin/browser/templates/browser/js/browser.js b/web/pgadmin/browser/templates/browser/js/browser.js index d11dc0f..89c7cb3 100644 --- a/web/pgadmin/browser/templates/browser/js/browser.js +++ b/web/pgadmin/browser/templates/browser/js/browser.js @@ -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' } }); diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js index db79a73..ae2cea3 100644 --- a/web/pgadmin/static/js/backform.pgadmin.js +++ b/web/pgadmin/static/js/backform.pgadmin.js @@ -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 diff --git a/web/pgadmin/tools/datagrid/templates/datagrid/js/datagrid.js b/web/pgadmin/tools/datagrid/templates/datagrid/js/datagrid.js index 59d10f5..e5bb9a1 100644 --- a/web/pgadmin/tools/datagrid/templates/datagrid/js/datagrid.js +++ b/web/pgadmin/tools/datagrid/templates/datagrid/js/datagrid.js @@ -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 }); }, diff --git a/web/pgadmin/tools/debugger/templates/debugger/js/direct.js b/web/pgadmin/tools/debugger/templates/debugger/js/direct.js index d9a0daa..c482bcb 100644 --- a/web/pgadmin/tools/debugger/templates/debugger/js/direct.js +++ b/web/pgadmin/tools/debugger/templates/debugger/js/direct.js @@ -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 diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py index 78b77b8..5636f57 100644 --- a/web/pgadmin/tools/sqleditor/__init__.py +++ b/web/pgadmin/tools/sqleditor/__init__.py @@ -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 the sql code in editor.') + ) blueprint = SqlEditorModule(MODULE_NAME, __name__, static_url_path='/static') diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js index 30a7932..f25af01 100644 --- a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js +++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js @@ -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' });