mirror of
https://github.com/salexdv/bsl_console.git
synced 2025-02-13 13:48:24 +02:00
Переключение пунктов контекстного меню в завизимости от режима редактора (редактирование кода или текста запроса)
This commit is contained in:
parent
058428e355
commit
55d5564322
@ -40,43 +40,47 @@ define(['vs/editor/editor.main'], function () {
|
||||
cmd: monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_D),
|
||||
order: 1.3,
|
||||
callback: function (ed) {
|
||||
sendEvent('EVENT_QUERY_CONSTRUCT', getQuery());
|
||||
sendEvent('EVENT_QUERY_CONSTRUCT', queryMode ? getText() : getQuery());
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
actions.formatstr_bsl = {
|
||||
label: 'Конструктор форматной строки...',
|
||||
key: null,
|
||||
cmd: null,
|
||||
order: 1.4,
|
||||
callback: function (ed) {
|
||||
sendEvent('EVENT_FORMAT_CONSTRUCT', getFormatString());
|
||||
return null;
|
||||
}
|
||||
};
|
||||
if (!queryMode) {
|
||||
|
||||
actions.comment_bsl = {
|
||||
label: 'Добавить комментарий',
|
||||
key: monaco.KeyMod.CtrlCmd | monaco.KeyCode.NUMPAD_DIVIDE,
|
||||
cmd: monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyCode.NUMPAD_DIVIDE),
|
||||
order: 1.5,
|
||||
callback: function (ed) {
|
||||
addComment();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
actions.formatstr_bsl = {
|
||||
label: 'Конструктор форматной строки...',
|
||||
key: null,
|
||||
cmd: null,
|
||||
order: 1.4,
|
||||
callback: function (ed) {
|
||||
sendEvent('EVENT_FORMAT_CONSTRUCT', getFormatString());
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
actions.uncomment_bsl = {
|
||||
label: 'Удалить комментарий',
|
||||
key: monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.NUMPAD_DIVIDE,
|
||||
cmd: monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.NUMPAD_DIVIDE),
|
||||
order: 1.6,
|
||||
callback: function (ed) {
|
||||
removeComment();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
actions.comment_bsl = {
|
||||
label: 'Добавить комментарий',
|
||||
key: monaco.KeyMod.CtrlCmd | monaco.KeyCode.NUMPAD_DIVIDE,
|
||||
cmd: monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyCode.NUMPAD_DIVIDE),
|
||||
order: 1.5,
|
||||
callback: function (ed) {
|
||||
addComment();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
actions.uncomment_bsl = {
|
||||
label: 'Удалить комментарий',
|
||||
key: monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.NUMPAD_DIVIDE,
|
||||
cmd: monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.NUMPAD_DIVIDE),
|
||||
order: 1.6,
|
||||
callback: function (ed) {
|
||||
removeComment();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
return actions;
|
||||
|
||||
|
@ -292,8 +292,7 @@ define([], function () {
|
||||
tokenPostfix: 'bsl',
|
||||
ignoreCase: true,
|
||||
keywords: bsl_language.rules.queryWords,
|
||||
expressions: bsl_language.rules.queryExp,
|
||||
as : '\u041A\u0410\u041A',
|
||||
expressions: bsl_language.rules.queryExp,
|
||||
operators: /[=><+\-*\/%;,]+/,
|
||||
tokenizer: {
|
||||
root: [
|
||||
|
@ -9,6 +9,7 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
|
||||
generateModificationEvent = false;
|
||||
readOnlyMode = false;
|
||||
queryMode = false;
|
||||
contextActions = [];
|
||||
|
||||
sendEvent = function(eventName, eventParams) {
|
||||
|
||||
@ -148,10 +149,15 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
|
||||
|
||||
init = function(version1C) {
|
||||
|
||||
contextActions.forEach(action => {
|
||||
action.dispose();
|
||||
});
|
||||
|
||||
const actions = getActions(version1C);
|
||||
|
||||
for (const [action_id, action] of Object.entries(actions)) {
|
||||
editor.addAction({
|
||||
|
||||
let menuAction = editor.addAction({
|
||||
id: action_id,
|
||||
label: action.label,
|
||||
keybindings: [action.key, action.cmd],
|
||||
@ -160,8 +166,9 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
|
||||
contextMenuGroupId: 'navigation',
|
||||
contextMenuOrder: action.order,
|
||||
run: action.callback
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
contextActions.push(menuAction)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user