Skip to content

Commit 4207029

Browse files
authored
Calculator plugin port (#889)
Calculator plugin port'ed in
1 parent cf66a3d commit 4207029

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+36760
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ add_subdirectory (editorcomp)
240240
add_subdirectory (inside)
241241
add_subdirectory (incsrch)
242242
add_subdirectory (NetRocks)
243+
add_subdirectory (calc)
243244
add_subdirectory (packaging)
244245

245246
if(PYTHON)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Works also on OSX/MacOS and BSD (but later not tested on regular manner)
44
ALPHA VERSION.
55
**Currently interesting only for enthusiasts!!!**
66

7-
Plug-ins that are currently working: NetRocks (SFTP/SCP/FTP/FTPS/SMB/NFS/WebDAV), colorer, multiarc, tmppanel, align, autowrap, drawline, editcase, SimpleIndent, Python (optional scripting support)
7+
Plug-ins that are currently working: NetRocks (SFTP/SCP/FTP/FTPS/SMB/NFS/WebDAV), colorer, multiarc, tmppanel, align, autowrap, drawline, editcase, SimpleIndent, Calculator, Python (optional scripting support)
88

99
Linux/MacOS (Travis CI): [![Travis](https://img.shields.io/travis/elfmz/far2l.svg)](https://travis-ci.org/elfmz/far2l)
1010

calc/CMakeLists.txt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
project(calc)
2+
3+
set(SOURCES
4+
src/plugcalc/api.cpp
5+
src/plugcalc/api.h
6+
src/plugcalc/api-far2.cpp
7+
src/plugcalc/calc.cpp
8+
src/plugcalc/calc.h
9+
src/plugcalc/calc.rc
10+
src/plugcalc/config.cpp
11+
src/plugcalc/config.h
12+
src/plugcalc/messages.h
13+
src/plugcalc/newparse.cpp
14+
src/plugcalc/newparse.h
15+
src/plugcalc/sarg.cpp
16+
src/plugcalc/sarg.h
17+
src/plugcalc/syntax.cpp
18+
src/plugcalc/syntax.h
19+
src/plugcalc/version.h
20+
src/shared/hashmap/HashMap.h
21+
src/shared/mathexpression/MathExpressionBase.h
22+
src/shared/sgml/sgml.cpp
23+
src/shared/trex/trex.c
24+
src/shared/trex/trex.h
25+
src/shared/ttmath/ttmath.h
26+
src/shared/ttmath/ttmathbig.h
27+
src/shared/ttmath/ttmathint.h
28+
src/shared/ttmath/ttmathobjects.h
29+
src/shared/ttmath/ttmathparser.h
30+
src/shared/ttmath/ttmathtypes.h
31+
src/shared/ttmath/ttmathuint.h
32+
src/shared/ttmath/ttmathuint_noasm.h
33+
)
34+
35+
#====================================================
36+
# build
37+
#====================================================
38+
39+
add_library (${PROJECT_NAME} MODULE ${SOURCES})
40+
41+
target_link_libraries(${PROJECT_NAME} utils far2l)
42+
43+
target_compile_definitions(${PROJECT_NAME} PUBLIC TTMATH_NOASM UNICODE _UNICODE)
44+
45+
target_include_directories(${PROJECT_NAME} PRIVATE src/shared)
46+
target_include_directories(${PROJECT_NAME} PRIVATE ../WinPort)
47+
target_include_directories(${PROJECT_NAME} PRIVATE ../far2l/Include)
48+
49+
set_target_properties(${PROJECT_NAME} PROPERTIES
50+
CXX_STANDARD 11
51+
CXX_STANDARD_REQUIRED YES
52+
CXX_EXTENSIONS NO
53+
LIBRARY_OUTPUT_DIRECTORY "${INSTALL_DIR}/Plugins/${PROJECT_NAME}/plug"
54+
PREFIX ""
55+
SUFFIX ".far-plug-wide")
56+
57+
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
58+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/configs
59+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/configs "${INSTALL_DIR}/Plugins/${PROJECT_NAME}/plug")
60+

calc/LICENSE

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 1998-2001, Igor Russkih
4+
Copyright (c) 2009-2012, uncle-vunkis
5+
Copyright (c) 2020, FarPlugins Team
6+
All rights reserved.
7+
8+
Redistribution and use in source and binary forms, with or without
9+
modification, are permitted provided that the following conditions are met:
10+
11+
* Redistributions of source code must retain the above copyright notice, this
12+
list of conditions and the following disclaimer.
13+
14+
* Redistributions in binary form must reproduce the above copyright notice,
15+
this list of conditions and the following disclaimer in the documentation
16+
and/or other materials provided with the distribution.
17+
18+
* Neither the name of the copyright holder nor the names of its
19+
contributors may be used to endorse or promote products derived from
20+
this software without specific prior written permission.
21+
22+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

calc/configs/calce.hlf

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
.Language=English,English
2+
.PluginContents=Calculator
3+
4+
@Contents
5+
$^#Calculator for FAR Manager. Version #
6+
$^#Copyright (c) 1998-2001 Igor Russkih#.
7+
$^#Copyright (c) 2009-2012 uncle-vunkis#.
8+
$^#Copyright (c) 2020 FarPlugins Team#.
9+
10+
PlugIn #Calculator# for #Far# Manager.
11+
12+
13+
~how you can use it?~@howuse@
14+
15+
~technical information.~@techinfo@
16+
17+
~advanced features~@addon@
18+
19+
~about this program.~@prog@
20+
21+
~about author.~@author@
22+
23+
@howuse
24+
$^#How you can use it?#
25+
26+
So, if you didn't understand yet, I'll describe it for you:
27+
28+
In the #Input Line# you can enter any combination of digits,
29+
words and points, using rules, you know from school(#I hope#).
30+
Calculator will analyze this expression, and show you the result.
31+
If you know little more, you can use extended features.
32+
They are listed in ~Technical Info~@TechInfo@. Pressing #Ctrl-Down# you
33+
will see history, where are saved recently used expressions.
34+
35+
The Left from the results you can choose shown number system
36+
with #RadioButtons#. You can press F2 in calculator or select item
37+
in calculator's main menu - you'll see contertation dialogs.
38+
There you can convert different values.
39+
40+
41+
@unders
42+
$#Wherefrom it Appears?#
43+
44+
A-a, I don't know really. So, if we can make a little decision
45+
that my Brains architecture is more complexes, than the Windows 95
46+
architecture, the ideas of those programs was created in parallel
47+
threads of my own brains.
48+
49+
Ou, where you can get #Windows Version#?
50+
Visit ~http://www.uic.nnov.ru/~~ruiv/files/calc.zip~@http://www.uic.nnov.ru/~~ruiv/files/calc.zip@
51+
52+
@techinfo
53+
$^#Technical Information#
54+
55+
The Calculator lets you compute in all popular systems:
56+
#Decimal#, #Hexadecimal#, #Binary#, #Octal#.
57+
58+
The number showing is like all standard (#C#, #Pascal#, #Assembler#):
59+
60+
#0x#12EF = #$#12EF = 12EF#h# - #Hexadecimal.#
61+
1289 = 1289#D# - #Decimal.#
62+
123#.#001 = 1#.#23001#e2# = 1#.#23001#e+2# - #Decimal, Exponential.#
63+
#0#1267 = 1267#O# - #Octal.#
64+
0111#b# - #Binary.#
65+
'b', 'bb', 'bbbb' - #Symbolic#.
66+
67+
And now about operators, functions and constants. They are fully configurable
68+
in file #CalcSet.Csr#. How you can do it? Easy. It has the next syntax:
69+
70+
#<calc# version="3.20"#>#
71+
#<use# set="test"#/>#
72+
<!--#<lang# id="en"#/>#-->
73+
#<set# Name="test"#>#
74+
#<const# syntax="pi" mean="3.14159"#/>#
75+
#<op# syntax="+" priority="8" mean="op0 _plus op1"#/>#
76+
#<func# syntax="sqrt" mean="op0 _pow 0.5"#/>#
77+
#<numeral# syntax="/([0-9]+)/" format="10" mean="op0"#/>#
78+
#<addon# syntax="rad" mean="{(op0 * pi) / 180}" format="10"#/>#
79+
80+
#<dialog ru:name="test">#
81+
#<text# ru:name="один" langid:name="one"#/>#
82+
#<field# ru:name="номер1" langid:name="number1" scale="1"#/>#
83+
#<field# ru:name="номер2" langid:name="number2" scale="2/pi"#/>#
84+
#<field# ru:name="номер3" langid:name="number3" output="{op0+10}" input="op0-10"#/>#
85+
#</dialog>#
86+
87+
#</set>#
88+
#</calc>#
89+
90+
This is an exemplary scheme - you can add blocks #Set# and #Use# as much,
91+
as you want. 'Set' Block defines constants, functions, and operators.
92+
Parameter Syntax sets symbolic name, and Mean parameter - calculating expression.
93+
Expression can use variables #op0#, #op1#, #op2#... Operators use only first two -
94+
left and right operators. Functions can have up to ten parameters.
95+
96+
#Mean# Expression can use buildin and previously user-defined elements.
97+
98+
#Format# is a radix value (2,8,10,16) or
99+
"exp" = exponential format (for addons only)
100+
"rep" = repeating decimal format
101+
"con" = continued fraction format
102+
Default format is "10".
103+
Also additional flags are available (comma separated):
104+
- for output:
105+
"delim" = use current digit delimiter (depends on settings)
106+
107+
108+
Build-in operators (in order of precedence):
109+
#_lor# Logical OR
110+
#_land# Logical AND
111+
#_or# Binary OR
112+
#_xor# Binary XOR
113+
#_and# Binary AND
114+
#_neq, _eq# Not Equal, Equal
115+
#_gt ,_lt# More, Less
116+
#_shr _shl _ror _rol# Shift right, left, rotate shift
117+
#_minus, _plus# Plus, minus
118+
#_mod _div _mul# Mod, Divide, Multiply
119+
#_pow# Power
120+
#_not# Bitwise Not
121+
#_lnot# Logical Not
122+
123+
124+
Base functions - #Func(Par)#:
125+
126+
Functions with no arguments
127+
#_rnd# Random number
128+
#_finf# Float +Infinity number
129+
#_fnan# Float NaN number
130+
131+
Functions with one argument
132+
#_frac# Fraction
133+
#_floor# Floor of number
134+
#_ceil# Ceil of number
135+
#_sin# Sine
136+
#_cos# Cosine
137+
#_tan# Tanget
138+
#_arctan# ArcTangent
139+
#_ln# Natural Logarithm
140+
#_factor# Factorial
141+
#_f2b# Float to binary (IEEE-754)
142+
#_d2b# Double to binary (IEEE-754)
143+
#_b2f# Binary to float (IEEE-754)
144+
#_b2d# Binary to double (IEEE-754)
145+
#_numer# Numerator of a common fraction
146+
#_denom# Denominator of a common fraction
147+
148+
Functions with multiple arguments:
149+
#_if# _if(val,a,b). Return a, if val, else return b.
150+
#_gcd# _gcd(num,denom). Greatest common divisor
151+
152+
Functional operators
153+
#_int64# #_uint64#
154+
#_int# #_uint#
155+
#_short# #_ushort#
156+
#_char# #_byte#
157+
#_double# #_float#
158+
159+
All #Spaces# in entered expression mean nothing,
160+
so you can use it anywhere. #Symbols register# mean nothing too.
161+
162+
163+
@addon
164+
$^#Advanced Features.#
165+
In #Far v1.6# and higher the Calc can work in FAR Editor.
166+
You can call it with #F11-Calculator#.
167+
168+
Also, there is an #advanced feature# of background working.
169+
With this mode Calc try to calculate any expression in plain text,
170+
with #Alt=#, #AltH#, #AltO#, #AltB# macroses.
171+
172+
173+
@prog
174+
$^#About this program and so...#
175+
The Idea of this PlugIn was born from DN's Calculator. So, there
176+
r some visual aspects.... Also you can find Windows version of this
177+
#calc# with the same functionality. I don't know, ~which~@Unders@ of
178+
the ideas came first in my head.
179+
180+
So, doing nothing, I desided to incarnate this Idea. With BG Music
181+
under the Star Adelaide it was created.
182+
183+
Thanks for using Calc,
184+
I hope it needs somebody.
185+
#Igor Russkih#
186+
...and a tiny bit by #uncle-vunkis#
187+
188+
@DN
189+
190+
#Hmmmm...#
191+
192+
@author
193+
$^#Calculator for FAR Manager. Version
194+
#Igor Russkih#. Copyright (c) 1998-2001. All rights reserved.
195+
#uncle-vunkis#. Copyright (c) 2009-2012. #.
196+
#FarPlugins Team#. Copyright (c) 2020. #.
197+
This program is a #FreeWare#. It Means, that you can do anything with
198+
it copies, if this actions are not breaks #Author Rights#.
199+
200+
Spinning tales about silence
201+
About radio silence
202+
About some kind of asylum
203+
In the middle of an empty field full of danger

calc/configs/calce.lng

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.Language=English,English
2+
3+
"Calculator"
4+
"&Calculator"
5+
"Calculator's Setup"
6+
"en"
7+
8+
"Dialogs"
9+
"OK"
10+
"Save"
11+
"Cancel"
12+
"Advanced"
13+
14+
"Show results during the input"
15+
"Case-sensitive input"
16+
"Show periodic fractions"
17+
"Max.period"
18+
"Pad zeroes for fixed-size numbers"
19+
"Right-aligned"
20+
"History"
21+
"Hide"
22+
"Show above"
23+
"Show below"
24+
"lines"
25+
"Autocomplete"
26+
"Delimiters"
27+
"Decimal symbol"
28+
"Use regional settings"
29+
"Arguments"
30+
"Digit group delimiter"
31+
32+
"ok"
33+
"error"
34+
"expression error"
35+
"type error"
36+
"parameters error"
37+
"brackets error"
38+
"division by zero"
39+
"overflow error"
40+
"too long expression"

0 commit comments

Comments
 (0)