Allow users to enable wrapping of code in SQL boxes. Fixes#2025

pull/3/head
Murtuza Zabuawala 2016-12-16 17:07:41 +00:00 committed by Dave Page
parent 1d571902da
commit 6fc8f040ff
7 changed files with 25 additions and 8 deletions

View File

@ -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'})

View File

@ -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'
}
});

View File

@ -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

View File

@ -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
});
},

View File

@ -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

View File

@ -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')

View File

@ -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'
});