xOleg wrote: ↑Fri Dec 20, 2024 10:27 am...Единственная идея там...
A good idea makes the difference.
xOleg,
By the way, I have an idea for your MathCalc script:
An option to sum all the numbers within the text/selection with modes a. sum only, b. sum regarding the minus sign before numbers.
It can work out as follows:
Code: Select all
$start=AkelPad.GetSelStart();
$end=AkelPad.GetSelEnd();
if ($start == $end)
AkelPad.SetSel(0,-1);
$text=AkelPad.GetSelText();
// extract numbers off the text/selection and make a sum expression from it
$plus=$text.replace(/[^0-9.]/g,"+").replace(/^[+.0]+(\d)/g,"$1").replace(/(\d)[+.]+$/g,"$1").replace(/\+(0|[.])+/g,"+").replace(/\++/g,"+").replace(/(\d)[.][+]/g,"$1+")
// same as above but retain minus sign before numbers and use it in the expression as such
$math=$text.replace(/[^0-9.-]/g,"+").replace(/^[+-.0]+(\d)/g,"$1").replace(/(\d)[+-.]+$/g,"$1").replace(/\+0+/g,"+").replace(/\-0+/g,"-").replace(/\+[.-]+\+/g,"+").replace(/\++/g,"+").replace(/(\d)[.][+]/g,"$1+")
$text=$text+'\r'+$math+'\r'+$plus+'\r'
AkelPad.ReplaceSel($text);
AkelPad.SetSel($start,$start);
Video illustration:
https://i.imgur.com/4CyGtax.mp4
Here, the example script prepares the expressions, and then MathCalc does the actual maths.
Text for testing:
Code: Select all
Lorem ipsum 000 dolor 111 sit amet,
Nullam ut 222 finibus 333 lectus.
"Praesent 444 eusem 555 lorem."
Fusce 05-09-2024 elementum gravida luctus?
Sed non 2,5 accumsan lorem!
1. Vivamus at mauris mi[1]
2. Duis ac faucibus elit.[2][3]
3. Sed sed 'tempor' diam.
Vivamus tincidunt tristique dolor.[4,5]
Morbi vel 25.25 blandit augue.