Page 29 of 31

Re: Scripts discussion (4)

Posted: Sun Feb 18, 2024 10:01 pm
by Infocatcher
DV
Просьба в GoToAnything.js добавить ограничение по размеру файла, пролистал соседние файлы, наткнулся на объемный криптоконтейнер без расширения, и AkelPad заругался на нехватку памяти, порекомендовал завершить работу и в итоге упал.
Я думаю, (настраиваемого) лимита в 100-200 Мбайт хватит всем.

А еще у меня (периодически?) не закрывается временная вкладка, которая использовалась для предварительного просмотра. Если закрыть окно GoToAnything.js крестиком или через Esc – временная вкладка закрывается. А если через двойной клик по другому файлу или Enter – остается.

Re: Scripts discussion (4)

Posted: Mon Feb 19, 2024 7:28 pm
by DV
Infocatcher wrote:Просьба в GoToAnything.js добавить ограничение по размеру файла
Added in 0.7.2.
Infocatcher wrote:А еще у меня (периодически?) не закрывается временная вкладка, которая использовалась для предварительного просмотра. Если закрыть окно GoToAnything.js крестиком или через Esc – временная вкладка закрывается. А если через двойной клик по другому файлу или Enter – остается.
F1 ?

Re: Scripts discussion (4)

Posted: Tue Feb 20, 2024 9:18 pm
by Infocatcher
DV wrote: Mon Feb 19, 2024 7:28 pm Added in 0.7.2.
Спасибо!
DV wrote: Mon Feb 19, 2024 7:28 pm F1 ?
Справку-то я читал.
Вопрос в ожидаемом поведении.
Вот я открыл список файлов, полистал/поискал в поисках нужного, нашел, нажал Enter.
Но если нужный файл уже был открыт, то временную вкладку правильнее закрыть.

Re: Scripts discussion (4)

Posted: Wed Feb 21, 2024 11:38 am
by DV
Infocatcher wrote: Tue Feb 20, 2024 9:18 pmНо если нужный файл уже был открыт, то временную вкладку правильнее закрыть.
А! Тепер зрозумів. Так, це мій недогляд, виправлю.

Fixed in 0.7.4.
https://github.com/d0vgan/AkelPad-Scrip ... nything.js

Re: Scripts discussion (4)

Posted: Thu Feb 22, 2024 6:15 pm
by Infocatcher
DV wrote: Wed Feb 21, 2024 11:38 am Fixed in 0.7.4.
https://github.com/d0vgan/AkelPad-Scrip ... nything.js
Спасибо, теперь работает как надо.

Re: Scripts discussion (4)

Posted: Sun Feb 25, 2024 8:46 pm
by DV
GoToAnything 0.7.5 is available!
Here is something you surely wanted but hesitated to ask :) A new static option "ExcludePreviewedFilesFromRecentFiles" to not update the Recent Files while previewing.
Also, you may be interested in playing with the static options "SelTextColor_ThemeVar" and "SelBkColor_ThemeVar" if you haven't already.

Re: Scripts discussion (4)

Posted: Sat Nov 09, 2024 7:59 pm
by dothen
VerticalMarkup.js v1.1

Добавлено: Левый отступ автоматически устанавливается равным нулю.
Добавлено: Восстанавливает изначальный фон и левый отступ.

Re: Scripts discussion (4)

Posted: Mon Dec 02, 2024 6:32 pm
by ewild
How to find a pair of slashes (/something-in-between/) and replace it with a pair of square brackets ([something-in-between]) within a line excluding ones (slashes) that are part of a URL (such as https://, etc.)?
Example target text:

Code: Select all

Lorem // ipsum
https://www.google.com/search?q=lorem+ipsum
/lorem:ipsum/[A][B][C] ( nnn { ggg { nnn
consecteur /adipiscing/  eu/turpis//velit/ ut/rhoncus
tincidunt/ eget/ nibh nam/ facilisis/ ligula/ lacinia
Expected result:

Code: Select all

Lorem [] ipsum
https://www.google.com/search?q=lorem+ipsum
[lorem:ipsum][][][] (nnn {ggg {nnn
consecteur [adipiscing]  eu[turpis][velit] ut/rhoncus
tincidunt[ eget] nibh nam[ facilisis] ligula/ lacinia
Now I do it this way:

Code: Select all

var $hashTable = {
"/(.*?)/":"[\\1]" // slashes to square brackets
}
$mode = 0x002C0000;
for(var $key in $hashTable)
AkelPad.TextReplace(0,$key,$hashTable[$key],$mode,0x1);
Indeed, the above code replaces all the pairs of slashes indistinguishably, so I have to use the second pass to repair the square brackets within URLs replacing them back with slashes (as a "workaround", name it).
Of course, I hate that so-called "workaround" and would prefer a straightforward approach, but I just could not find it.
I have tried a 'negative lookbehind search' method, that could work somewhere (https://regex101.com/r/RedAmd/1), but not in AkelPad since AkelPad doesn't accept .* in (?<!http.*) (as in https://regex101.com/r/RedAmd/1).

Re: Scripts discussion (4)

Posted: Mon Dec 02, 2024 8:13 pm
by DV
ewild wrote: Mon Dec 02, 2024 6:32 pmIndeed, the above code replaces all the pairs of slashes indistinguishably, so I have to use the second pass to repair the square brackets within URLs replacing them back with slashes (as a "workaround", name it).
The simpler, the better :) Why not just do something like `pos = s.indexOf("https://", 0); if (pos != -1) pos = s.indexOf(" ", pos);` and then continue to replace from the `pos` ?

Re: Scripts discussion (4)

Posted: Tue Dec 03, 2024 8:30 pm
by ewild
DV wrote: Mon Dec 02, 2024 8:13 pm .indexOf
Thanks for the hint.
At first, I split the text line by line; then I applied the indexOf() method to each line, doing find/replace for the lines that did not include 'http', and it worked:

Code: Select all

$start=AkelPad.GetSelStart();
$end=AkelPad.GetSelEnd();
if ($start == $end)
AkelPad.SetSel(0,-1);
$text=AkelPad.GetSelText(); //WScript.Echo($text);
$line=$text.split(/\r\n|\n|\r/gm); //WScript.Echo($line.length);
for (var $i = 0; $i < $line.length; $i++) { //WScript.Echo($line[$i]);
if ($line[$i].indexOf("http") == -1) {
$swap=$line[$i].replace(/\/(.*?)\//gm,"[$1]");
$text=$text.replace($line[$i],$swap);
}}
AkelPad.ReplaceSel($text);
AkelPad.SetSel($start,$start);

Re: Scripts discussion (4)

Posted: Wed Dec 04, 2024 2:33 pm
by DV
ewild wrote: Tue Dec 03, 2024 8:30 pmdoing find/replace for the lines that did not include 'http'
In general, you may still want to apply some find/replace to the same line where "http" is located. I mean, if you had a situation similar to the following:

Code: Select all

pre-text http://some_url post-text
then you would probably want to perform some replacements in the `pre-text` and `post-text` parts.
Or, in even more general case, you may have something like this:

Code: Select all

pre-text http://some_url sub-text https://other_url post-text
In such case, you would probably need a loop that skips every "http://..." and "https://..." parts and performs find/replace in all the other parts.
But the level of the complexity is completely determined by the actual needs :)

Re: Scripts discussion (4)

Posted: Wed Dec 04, 2024 8:25 pm
by ewild
2DV
Funny/sad thing, while distinguishing 'pre-text http://some_url', and 'sub-text https://other_url' parts is a piece of cake (since 'http*' part clearly indicates the boundaries, where the next part starts, and the previous part ends), parting 'http://some_url mid-text', and 'http://some_url post-text' could be tricky, if possible at all (outside of mark-ups with apparent delimiters, such as htmls, xmls, etc) in case of plain texts where URLs include whitespace(s).
Luckily, my use case doesn't imply such issues.

Re: Scripts collection

Posted: Mon Dec 16, 2024 6:20 pm
by ewild
xOleg wrote: Tue Nov 12, 2024 10:53 pm MathCad "на минималках"...
🜨 MathCalc.js...
xOleg,
Great script. The best AkelPad's calculator so far. Thank you.
When its first version rolled out, I had to change it a bit (four lines) to fit my needs.
Now it works that way just out of the box (now I change only two default variable values).

Re: Scripts discussion (4)

Posted: Wed Dec 18, 2024 11:52 am
by xOleg
ewild wrote: Mon Dec 16, 2024 6:20 pm
xOleg wrote: Tue Nov 12, 2024 10:53 pm MathCad "на минималках"...
🜨 MathCalc.js...
xOleg,
Great script. The best AkelPad's calculator so far. Thank you.
When its first version rolled out, I had to change it a bit (four lines) to fit my needs.
Now it works that way just out of the box (now I change only two default variable values).
Спасибо за отзыв. Давно хотел сделать что-то такое. Пользоваться стандартным калькулятором, как по мне, не сильно удобно, а MathCAD слишком громоздкий, чтобы его запускать, если нужно к трем прибавить два.

Re: Scripts discussion (4)

Posted: Wed Dec 18, 2024 8:17 pm
by ewild
xOleg wrote: Wed Dec 18, 2024 11:52 am Спасибо за отзыв. Давно хотел сделать что-то такое...
You're very welcome.
Thank you again for the mathCalc script. It's just an actual gem.