(Russian below)
Hello,
I am currently using the script "NoOverwriteSelection.js" (see attachment).
This script will prevent unintentional deletion of text. For example, if a few words of text are selected, and you press "a", or the "tabulator"-key, the text will be deleted. The script prevents that and requires that you press the delete key.
However, Akelpad also has a great function that will indent text: For example, if you mark 10 lines of text and then press "tabulator", all 10 lines will be moved to the right (by one tabulator-space each).
If you select ONE line and do NOT include the line break at the end of the line, THEN "tabulator" will delete the line.
If you select ONE line and INCLUDE the line break at the end of the line, then "tabulator" will indent (move to the right).
As a result, if I want to indent lines, I always have to DEACTIVATE the NoOverwriteSelection.js-script, then intend the lines, and then RE-ACTIVATE NoOverwriteSelection.js.
I would like to ask if it is possible to make NoOverwriteSelection.js BLOCK "tabulators" EXCEPT if a line break is within the selection?
Or if there are other ideas how to make this work?
I always thought that command "4165" means "Insert tabulation ONLY if several lines selected" -- but it will still insert a tabulator key even if just a word is selected.
I there no command that will excluseively indent a text block by adding tabs to the front that has NOTHING to do with the simple "tabulator" key (which has the potential to delete text)?
Thank you a lot!
RUSSIAN:
TRANSLATED WITH DeepL:
Добавление клавиш табулятора перед текстовым блоком
Здравствуйте,
В настоящее время я использую скрипт "NoOverwriteSelection.js" (см. вложение).
Этот скрипт предотвращает непреднамеренное удаление текста. Например, если выделено несколько слов текста, и вы нажимаете "a", или клавишу "табулятор", то текст будет удален. Скрипт предотвращает это и требует, чтобы вы нажали клавишу удаления.
Однако в Akelpad также есть замечательная функция, которая позволяет делать отступы текста: Например, если выделить 10 строк текста и нажать клавишу "табулятор", то все 10 строк будут сдвинуты вправо (на одно табуляторное пространство каждая).
Если вы выделите ОДНУ строку и НЕ включите разрыв строки в конце строки, ТО "tabulator" удалит эту строку.
Если выделить ОДНУ строку и ВКЛЮЧИТЬ разрыв строки в конце строки, то "табулятор" сделает отступ (сдвинется вправо).
В результате, если я хочу сделать отступ строки, мне всегда приходится ДЕАКТИВИРОВАТЬ скрипт NoOverwriteSelection.js, затем выделять строки, а затем снова активировать NoOverwriteSelection.js.
Я хотел бы спросить, возможно ли сделать так, чтобы NoOverwriteSelection.js БЛОКИРОВАЛ "табуляторы" ИСКЛЮЧИТЕЛЬНО в том случае, если перенос строки находится внутри выделения?
Или если есть другие идеи, как заставить это работать?
Я всегда думал, что команда "4165" означает "Вставлять табуляцию ТОЛЬКО если выделено несколько строк" - но она все равно будет вставлять клавишу табуляции, даже если выделено только слово.
Нет ли команды, которая бы исключительно отступала от текстового блока, добавляя табуляцию спереди, и не имела бы НИКАКОГО отношения к простой клавише "табулятор" (которая потенциально может удалять текст)?
Спасибо!
Adding tabulator keys at front of a text block (+Russian)
- Author
- Message
-
Offline
- Posts: 84
- Joined: Wed Jan 27, 2016 6:53 pm
- Location: Europe
-
Offline
- Posts: 84
- Joined: Wed Jan 27, 2016 6:53 pm
- Location: Europe
Code: Select all
// http://akelpad.sourceforge.net/forum/viewtopic.php?p=30468#p30468
// Version: 2016-02-01
// Author: KDJ
//
// *** Prevents overwrite selection ***
//
// Usage:
// Call("Scripts::Main", 1, "NoOverwriteSelection.js", "-msg=true")
//
// Argument (optional):
// -msg - if false, message box is not displayed (default is true)
//
// Remarks:
// After first call, the script resides in the memory. Second script call, closes it.
// If the script is running, you can not overwrite selection. Can delete selection (DEL key or Menu->Edit->Delete).
// For autostart, in AkelPad.ini or registry CmdLineBegin/CmdLineEnd key, need to add eg:
// /Call("Scripts::Main", 1, "NoOverwriteSelection.js", "-msg=false")
var bMsg = AkelPad.GetArgValue("msg", true);
var hMainWnd = AkelPad.GetMainWnd();
var hScript = AkelPad.ScriptHandle(WScript.ScriptName, 3 /*SH_FINDSCRIPT*/);
var hSubClassMain;
var hSubClassEdit;
if (hScript && AkelPad.ScriptHandle(hScript, 13 /*SH_GETMESSAGELOOP*/))
{
//script already is running, close it
AkelPad.ScriptHandle(hScript, 33 /*SH_CLOSESCRIPT*/);
if (bMsg)
AkelPad.MessageBox(hMainWnd, "Prevention of overwrite selection is turned off.", WScript.ScriptName, 0x40 /*MB_ICONINFORMATION*/);
}
else if (hSubClassMain = AkelPad.WindowSubClass(1 /*WSC_MAINPROC*/, MainCallback, 273 /*WM_COMMAND*/))
{
if (hSubClassEdit = AkelPad.WindowSubClass(2 /*WSC_EDITPROC*/, EditCallback, 256 /*WM_KEYDOWN*/, 258 /*WM_CHAR*/))
{
if (bMsg)
AkelPad.MessageBox(hMainWnd, "Prevention of overwrite selection is turned on.", WScript.ScriptName, 0x40 /*MB_ICONINFORMATION*/);
AkelPad.ScriptNoMutex();
AkelPad.WindowGetMessage();
AkelPad.WindowUnsubClass(2 /*WSC_EDITPROC*/);
}
AkelPad.WindowUnsubClass(1 /*WSC_MAINPROC*/);
}
function MainCallback(hWnd, uMsg, wParam, lParam)
{
var nCmd;
if (uMsg == 273 /*WM_COMMAND*/)
{
nCmd = wParam & 0xFFFF;
if ((nCmd == 4155 /*IDM_EDIT_PASTE*/) ||
(nCmd >= 4164 /*IDM_EDIT_INSERT_TAB*/) && (nCmd <= 4173 /*IDM_EDIT_DELETE_FIRST_CHAR_MENU*/) ||
(nCmd >= 4175 /*IDM_EDIT_UPPERCASE*/) && (nCmd <= 4180 /*IDM_EDIT_LOOPCASE*/) ||
(nCmd == 4183 /*IDM_EDIT_INSERTDATE*/) ||
(nCmd >= 4191 /*IDM_EDIT_PASTEANSI*/) && (nCmd <= 4196 /*IDM_EDIT_AUTOINDENT*/))
{
if (AkelPad.GetSelStart() != AkelPad.GetSelEnd())
AkelPad.WindowNoNextProc(hSubClassMain);
}
}
return 0;
}
function EditCallback(hWnd, uMsg, wParam, lParam)
{
if (uMsg == 256 /*WM_KEYDOWN*/)
{
if (wParam == 0x08 /*VK_BACK*/)
{
if (AkelPad.GetSelStart() != AkelPad.GetSelEnd())
AkelPad.WindowNoNextProc(hSubClassEdit);
}
}
else if (uMsg == 258 /*WM_CHAR*/)
{
if (AkelPad.GetSelStart() != AkelPad.GetSelEnd())
AkelPad.WindowNoNextProc(hSubClassEdit);
}
return 0;
}