aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--static/explorer.scss2
-rw-r--r--static/panes/editor.js71
-rw-r--r--static/settings.interfaces.ts2
-rw-r--r--static/settings.js8
-rw-r--r--views/popups.pug7
-rw-r--r--views/templates.pug2
6 files changed, 25 insertions, 67 deletions
diff --git a/static/explorer.scss b/static/explorer.scss
index 2ef1892b6..75a7aeb14 100644
--- a/static/explorer.scss
+++ b/static/explorer.scss
@@ -862,7 +862,7 @@ html[data-theme=dark] {
cursor: pointer;
}
-.currentCursorPosition, .ctrlSNothing {
+.currentCursorPosition {
font-size: small;
border: none;
user-select: text;
diff --git a/static/panes/editor.js b/static/panes/editor.js
index bc4b29ee4..677542a0c 100644
--- a/static/panes/editor.js
+++ b/static/panes/editor.js
@@ -469,7 +469,23 @@ Editor.prototype.initButtons = function (state) {
this.initLoadSaver();
$(this.domRoot).on('keydown', _.bind(function (event) {
if ((event.ctrlKey || event.metaKey) && String.fromCharCode(event.which).toLowerCase() === 's') {
- this.handleCtrlS(event);
+ event.preventDefault();
+ if (this.settings.enableCtrlStree && this.hub.hasTree()) {
+ var trees = this.hub.trees;
+ // todo: change when multiple trees are used
+ if (trees && trees.length > 0) {
+ trees[0].multifileService.includeByEditorId(this.id).then(_.bind(function () {
+ trees[0].refresh();
+ }, this));
+ }
+ } else if (this.settings.enableCtrlS) {
+ loadSave.setMinimalOptions(this.getSource(), this.currentLanguage);
+ if (!loadSave.onSaveToFile(this.id)) {
+ this.showLoadSaver();
+ }
+ } else {
+ this.eventHub.emit('displaySharingPopover');
+ }
}
}, this));
@@ -489,53 +505,6 @@ Editor.prototype.initButtons = function (state) {
this.currentCursorPosition.hide();
};
-Editor.prototype.handleCtrlS = function (event) {
- event.preventDefault();
- if (this.settings.enableCtrlStree && this.hub.hasTree()) {
- var trees = this.hub.trees;
- // todo: change when multiple trees are used
- if (trees && trees.length > 0) {
- trees[0].multifileService.includeByEditorId(this.id).then(_.bind(function () {
- trees[0].refresh();
- }, this));
- }
- } else {
- if (this.settings.enableCtrlS === 'true') {
- loadSave.setMinimalOptions(this.getSource(), this.currentLanguage);
- if (!loadSave.onSaveToFile(this.id)) {
- this.showLoadSaver();
- }
- } else if (this.settings.enableCtrlS === 'false') {
- this.eventHub.emit('displaySharingPopover');
- } else if (this.settings.enableCtrlS === '2') {
- this.runFormatDocumentAction();
- } else if (this.settings.enableCtrlS === '3') {
- this.handleCtrlSDoNothing();
- }
- }
-};
-
-Editor.prototype.handleCtrlSDoNothing = function () {
- if (this.nothingCtrlSTimes === undefined) {
- this.nothingCtrlSTimes = 0;
- this.nothingCtrlSSince = Date.now();
- } else {
- if (Date.now() - this.nothingCtrlSSince > 5000) {
- this.nothingCtrlSTimes = undefined;
- } else if (this.nothingCtrlSTimes === 4) {
- var element = this.domRoot.find('.ctrlSNothing');
- element.show(100);
- setTimeout(function () {
- element.hide();
- }, 2000);
- this.nothingCtrlSTimes = undefined;
- } else {
- this.nothingCtrlSTimes++;
- }
- }
-
-};
-
Editor.prototype.updateButtons = function () {
if (options.thirdPartyIntegrationEnabled) {
if (this.currentLanguage.id === 'c++') {
@@ -818,7 +787,7 @@ Editor.prototype.initEditorActions = function () {
});
this.editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.F9, _.bind(function () {
- this.runFormatDocumentAction();
+ this.editor.getAction('editor.action.formatDocument').run();
}, this));
this.editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyD, _.bind(function () {
@@ -826,10 +795,6 @@ Editor.prototype.initEditorActions = function () {
}, this));
};
-Editor.prototype.runFormatDocumentAction = function () {
- this.editor.getAction('editor.action.formatDocument').run();
-};
-
Editor.prototype.searchOnCppreference = function (ed) {
var pos = ed.getPosition();
var word = ed.getModel().getWordAtPosition(pos);
diff --git a/static/settings.interfaces.ts b/static/settings.interfaces.ts
index c2e9f5461..d5043d8a8 100644
--- a/static/settings.interfaces.ts
+++ b/static/settings.interfaces.ts
@@ -52,7 +52,7 @@ export interface SiteSettings {
delayAfterChange: number;
enableCodeLens: boolean;
enableCommunityAds: boolean
- enableCtrlS: boolean | number;
+ enableCtrlS: boolean;
enableCtrlStree: boolean;
editorsFFont: string
editorsFLigatures: boolean;
diff --git a/static/settings.js b/static/settings.js
index 4d3b8424b..837b494f4 100644
--- a/static/settings.js
+++ b/static/settings.js
@@ -255,13 +255,7 @@ function setupSettings(root, settings, onChange, subLangId) {
add(root.find('.useSpaces'), 'useSpaces', true, Checkbox);
add(root.find('.tabWidth'), 'tabWidth', 4, Numeric, {min: 1, max: 80});
// note: this is the ctrl+s "Save option"
- var actions = [
- {label: true, desc: 'Save To Local File'},
- {label: false, desc: 'Create Short Link'},
- {label: 2, desc: 'Reformat code'},
- {label: 3, desc: 'Do nothing'},
- ];
- add(root.find('.enableCtrlS'), 'enableCtrlS', true, Select, actions);
+ add(root.find('.enableCtrlS'), 'enableCtrlS', true, Checkbox);
add(root.find('.enableCtrlStree'), 'enableCtrlStree', true, Checkbox);
add(root.find('.editorsFFont'), 'editorsFFont', 'Consolas, "Liberation Mono", Courier, monospace', Textbox);
add(root.find('.editorsFLigatures'), 'editorsFLigatures', false, Checkbox);
diff --git a/views/popups.pug b/views/popups.pug
index 0b968363a..569b6ff68 100644
--- a/views/popups.pug
+++ b/views/popups.pug
@@ -131,13 +131,14 @@
label
input.useVim(type="checkbox")
| Vim editor mode
- .the-save-option-to-auto-share
+ .checkbox.the-save-option-to-auto-share
label
+ input.enableCtrlS(type="checkbox")
+ | Make
kbd Ctrl
| +
kbd S
- |  behaviour
- select.enableCtrlS
+ |  save to local file instead of creating a share link
.checkbox.the-save-option-to-tree-save
label
input.enableCtrlStree(type="checkbox")
diff --git a/views/templates.pug b/views/templates.pug
index cc3f50c72..879ca0020 100644
--- a/views/templates.pug
+++ b/views/templates.pug
@@ -38,8 +38,6 @@
span.hideable Quick-bench
.btn-group.btn-group-sm.mx-auto
button.btn.btn-sm.btn-outline-info.currentCursorPosition(disabled=true)
- button.btn.btn-sm.btn-outline-info.ctrlSNothing(disabled=true style="display: none")
- span.fas.fa-smile
.btn-group.btn-group-sm.ml-auto(role="group" aria-label="Editor language")
select.change-language(title="Change this editor's (and associated panels) language" placeholder="Language" disabled=embedded && readOnly)
div#v-status