Scripts discussion (4)

Discuss and announce AkelPad plugins
  • Author
  • Message
Offline
Posts: 1879
Joined: Mon Aug 06, 2007 1:07 pm
Contact:

Re: Scripts discussion (4)

Post by Infocatcher »

DV
Просьба в GoToAnything.js добавить ограничение по размеру файла, пролистал соседние файлы, наткнулся на объемный криптоконтейнер без расширения, и AkelPad заругался на нехватку памяти, порекомендовал завершить работу и в итоге упал.
Я думаю, (настраиваемого) лимита в 100-200 Мбайт хватит всем.

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

DV
Offline
Posts: 1294
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Re: Scripts discussion (4)

Post by DV »

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

Offline
Posts: 1879
Joined: Mon Aug 06, 2007 1:07 pm
Contact:

Re: Scripts discussion (4)

Post 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.
Но если нужный файл уже был открыт, то временную вкладку правильнее закрыть.

DV
Offline
Posts: 1294
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Re: Scripts discussion (4)

Post by DV »

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

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

Offline
Posts: 1879
Joined: Mon Aug 06, 2007 1:07 pm
Contact:

Re: Scripts discussion (4)

Post by Infocatcher »

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

DV
Offline
Posts: 1294
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Re: Scripts discussion (4)

Post 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.

Offline
Posts: 49
Joined: Thu May 05, 2022 5:38 am

Re: Scripts discussion (4)

Post by dothen »

VerticalMarkup.js v1.1

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

Offline
Posts: 47
Joined: Sat Jul 05, 2008 11:30 am
Location: Odesa, Ukraine

Re: Scripts discussion (4)

Post 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).

DV
Offline
Posts: 1294
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Re: Scripts discussion (4)

Post 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` ?

Offline
Posts: 47
Joined: Sat Jul 05, 2008 11:30 am
Location: Odesa, Ukraine

Re: Scripts discussion (4)

Post 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);

DV
Offline
Posts: 1294
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Re: Scripts discussion (4)

Post 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 :)

Offline
Posts: 47
Joined: Sat Jul 05, 2008 11:30 am
Location: Odesa, Ukraine

Re: Scripts discussion (4)

Post 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.

Offline
Posts: 47
Joined: Sat Jul 05, 2008 11:30 am
Location: Odesa, Ukraine

Re: Scripts collection

Post 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).

Offline
Posts: 5
Joined: Tue Nov 12, 2024 10:28 pm

Re: Scripts discussion (4)

Post 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 слишком громоздкий, чтобы его запускать, если нужно к трем прибавить два.

Offline
Posts: 47
Joined: Sat Jul 05, 2008 11:30 am
Location: Odesa, Ukraine

Re: Scripts discussion (4)

Post 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.
Post Reply