Compare commits
10 Commits
ebbf92d92d
...
master
Author | SHA1 | Date |
---|---|---|
sloum | 125a18a07e | |
sloum | a7b864ce38 | |
sloum | d35d17d5f8 | |
sloum | a0553b8531 | |
sloum | 4d3c2e5903 | |
sloum | b97fbc468d | |
sloum | 10bf83a21b | |
sloum | 715268a8e8 | |
sloum | f6f6348c8d | |
sloum | e1d13dd927 |
|
@ -0,0 +1,259 @@
|
|||
gnums is (c) 2021 sloum <sloum AT rawtext.club>, All Rights Reserved
|
||||
gnums is made available under the following terms:
|
||||
|
||||
Floodgap Free Software License
|
||||
|
||||
The author of your software has chosen to distribute it under the
|
||||
Floodgap Free Software License. Although this software is without cost,
|
||||
it is not released under Copyleft or GPL, and there are differences
|
||||
which you should read. Your use of this software package constitutes
|
||||
your binding acceptance without restriction.
|
||||
|
||||
This software is without cost
|
||||
|
||||
The Floodgap Free Software License (FFSL) has one overriding mandate:
|
||||
that software using it, or derivative works based on software that uses
|
||||
it, must be free. By free we mean simply "free as in beer" -- you may
|
||||
put your work into open or closed source packages as you see fit,
|
||||
whether or not you choose to release your changes or updates publicly,
|
||||
but you must not ask any fee for it. (There are certain exceptions for
|
||||
for-profit use which we will discuss below.)
|
||||
|
||||
Definitions and terms
|
||||
|
||||
Author
|
||||
The declared copyright owner of this software package.
|
||||
|
||||
Binary
|
||||
A pre-compiled or pre-interpreted bytecode or machine language
|
||||
representation of a software package not designed for further
|
||||
modification and tied to a particular platform or architecture.
|
||||
|
||||
Derivative work
|
||||
Any distribution (q.v.) that contains any modification to or
|
||||
deviation from the official reference distribution (q.v.); or
|
||||
any software package significantly based on or integrally
|
||||
including the source code for its features, including but not
|
||||
limited to supersets; subsets of a significant proportion;
|
||||
in-place patched changes to source or binary files; linking in
|
||||
as a library; binary-only distributions if the original package
|
||||
included source (even if the source was not modified prior to
|
||||
compilation); or translations to another programming language,
|
||||
architecture or operating system environment. Derivative works
|
||||
of packages released under this license are also considered
|
||||
subject to this license.
|
||||
|
||||
However, a software package that requires this package but does
|
||||
not include it or is not based upon it, even if it will not
|
||||
operate without it, is not considered a derivative work. For
|
||||
example, interpreted programs requiring an interpreter issued
|
||||
under this license, assuming they are not distributed with any
|
||||
portion of the interpreter, are not derivative works.
|
||||
|
||||
Distribution
|
||||
A packaged release of this software, either the author's
|
||||
original work (the "reference distribution") or a derivative
|
||||
work based upon it.
|
||||
|
||||
Reference distribution
|
||||
A packaged release of this software explicitly designated as the
|
||||
official release, written by or on behalf of the Author with his
|
||||
or her explicit designation as official. Only exact copies of
|
||||
the reference distribution may be called reference
|
||||
distributions; all other forms are derivative works.
|
||||
|
||||
Source code
|
||||
The human-readable programming instructions of the package which
|
||||
might be easily read as text and subsequently edited, but
|
||||
requiring compilation or interpretation into binary before being
|
||||
directly useable.
|
||||
|
||||
What you are permitted to do under this license
|
||||
|
||||
Pursuant to the remainder of the terms below,
|
||||
* You may freely use, copy, and disseminate this software package for
|
||||
any non-commercial purpose as well as the commercial purposes
|
||||
permitted below.
|
||||
* You may freely modify this package, including source code if
|
||||
available. Your modifications need not be released, although you
|
||||
are encouraged to do so.
|
||||
* You may release your derivative works based upon this software in
|
||||
purely binary (non-source) form if you choose. You are not
|
||||
obligated to release any portion of your source code openly,
|
||||
although you are encouraged to do so.
|
||||
* If this package is a tool used for generation, compilation or
|
||||
maintenance of works, including but not limited to readable
|
||||
documents, software packages or images (for example, compilers,
|
||||
interpreters, translators, linkers, editors, assemblers or
|
||||
typesetters), you may freely use it for that purpose, commercial or
|
||||
otherwise, as the works made by this package are not considered
|
||||
subject to this license unless specified otherwise within and may
|
||||
be distributed under any desired license and/or offered for sale or
|
||||
rental. Any run-time library or run-time code section linked into
|
||||
the output by a compiler or similar code-generating tool governed
|
||||
by this license is considered to be an integral part of the output,
|
||||
and its presence does not subject the generated work to this
|
||||
license either. (This is, of course, assuming you are not using
|
||||
said tools to generate a derivative work based on this package in
|
||||
violation of the other license terms.)
|
||||
However, if you are linking or including a separately distributed
|
||||
library that is under this license, no matter what tool you are
|
||||
using to do the linking or inclusion, you are then considered to be
|
||||
making a derivative work based on that library and your work does
|
||||
fall under this license. To avoid this, do not include the library
|
||||
with your work (even though it needs the library to function) and
|
||||
instead offer the library separately without cost.
|
||||
* In addition to non-commercial use and the uses permitted above, you
|
||||
may use this software package in any for-profit endeavour as long
|
||||
as it does not involve the specific sale or rental of this package.
|
||||
Some specific but by no means exhaustive examples are listed below.
|
||||
Note that some of these situations may require additional action be
|
||||
taken to ensure compliance.
|
||||
+ If this package or a derivative work allows you to serve data
|
||||
or make data available to others (for example, web servers,
|
||||
mail servers, gopher servers, etc.), you may use it to serve
|
||||
any commercial content or in any commercial setting whether
|
||||
you choose to charge a fee or not, as you are considered to be
|
||||
earning income from the content you serve and/or the services
|
||||
facilitated by your business and not from the sale of this
|
||||
package itself. (This is, of course, assuming that you are not
|
||||
charging a fee for sale or rental of this package or a
|
||||
derivative work based on this package in violation of the
|
||||
other license terms.) Similarly, any data you may acquire from
|
||||
the use of this package is yours, and not governed by this
|
||||
license in any way even if for-profit.
|
||||
+ If you are selling a product that includes this package or a
|
||||
derivative work either as part of your product's requirements
|
||||
for function or as a bundled extra, such as an operating
|
||||
system distribution, you may charge a fee for your product as
|
||||
long as you also make this package or said derivative work
|
||||
available for free separately (such as by download or link
|
||||
back to this package's site), as you are considered to be
|
||||
requesting a fee for your own product and the package is
|
||||
merely included as a convenience to your users.
|
||||
+ If you offer installation of this package or a derivative work
|
||||
as a service, you may charge a fee for the act of installation
|
||||
as long as you also make this package or said derivative work
|
||||
available for free (such as by download or link back to this
|
||||
package's site), as you are considered to be requesting a fee
|
||||
for the act of installation and not for the software you are
|
||||
installing.
|
||||
+ The Author may also grant, in writing, other specified
|
||||
exemptions for your particular commercial purpose that do not
|
||||
contravene the spirit of this license or any license terms
|
||||
this package additionally carries.
|
||||
* In your derivative works based on this package, you may choose to
|
||||
offer warranty support or guarantees of performance. This does not
|
||||
in any way make the original Author legally, financially or in any
|
||||
other respect liable for claims issued under your warranty or
|
||||
guarantee, and you are solely responsible for the fulfillment of
|
||||
your terms even if the Author of the work you have based your work
|
||||
upon offers his or her own.
|
||||
* In your derivative works based on this package, you may further
|
||||
restrict the acceptable uses of your package or situations in which
|
||||
it may be employed as long as you clearly state that your terms
|
||||
apply only to your derivative work and not to the original
|
||||
reference distribution. However, you may not countermand or ignore,
|
||||
directly or otherwise, any restriction already made in the
|
||||
reference distribution's license, including in this document
|
||||
itself, in similar fashion to other licenses allowing compatible
|
||||
licenses to co-govern a particular package's use.
|
||||
|
||||
What you must not do under this license
|
||||
|
||||
Remember that these limits apply only to redistribution of a reference
|
||||
distribution, or to a true derivative work. If your project does not
|
||||
include this package or code based upon it, even if it requires this
|
||||
package to function, it is not considered subject to this license or
|
||||
these restrictions.
|
||||
* You must not charge a fee for purchase or rental of this package or
|
||||
any derivative work based on this package. It is still possible to
|
||||
use this package in a commercial environment, however -- see What
|
||||
you are permitted to do under this license.
|
||||
* You must not countermand or ignore, directly or otherwise, the
|
||||
restrictions already extant in this package's license in your
|
||||
derivative work based on it. As a corollary, you must not place
|
||||
your derivative work under a secondary license or description of
|
||||
terms that conflicts with it (for example, this license is not
|
||||
compatible with the GNU Public License).
|
||||
* You must not label any modified distribution of this package as a
|
||||
reference or otherwise official distribution without the permission
|
||||
of the original Author or Authors. You must clearly specify that
|
||||
your modified work is a derivative work, including binary-only
|
||||
releases if the original included source code and you do not even
|
||||
if you did not modify the source prior to compilation.
|
||||
|
||||
What you must do under this license
|
||||
|
||||
* You must agree to all terms specified (agreement to which is
|
||||
unconditionally signified by your usage, modification or
|
||||
repurposing of this package), or to remove the package from your
|
||||
computer and not use it further.
|
||||
* In the absence of any specific offer for redress or assistance
|
||||
under warranty or guarantee of performance that the Author of this
|
||||
package might make, you must agree to accept any and all liability
|
||||
that may come from the use of this package, proper or improper,
|
||||
real or imagined, and certify without condition that you use this
|
||||
product at your own risk with no guarantee of function,
|
||||
merchantability or fitness for a particular purpose. If such offer
|
||||
of redress or assistance is extended, it is fulfillable only by the
|
||||
Author who extended the offer, which might not necessarily be this
|
||||
Author, nor might it be the Authors of any packages it might be
|
||||
based upon.
|
||||
* If you choose to publicly redistribute this package or create a
|
||||
derivative work based on this package, you must make it available
|
||||
without any purchase or rental fee of any kind.
|
||||
* If you choose to create a derivative work based on this package,
|
||||
your derivative work must be copyrighted, and must be governed
|
||||
under (at a minimum) the original package's license, which will
|
||||
necessarily include all terms noted here. As such, if you choose to
|
||||
distribute your derivative work, you must include a human-readable
|
||||
license in your distribution containing all restrictions of use,
|
||||
necessarily including this license, and any additional restrictions
|
||||
the Author has mandated that do not contravene this license which
|
||||
you and users of your derivative work must also honour.
|
||||
* If you choose to create and distribute a derivative work based on
|
||||
this package, your derivative work must clearly make reference to
|
||||
this package, any other packages your work or the original work
|
||||
might be based on, and all applicable copyrights, either in your
|
||||
documentation, your work's standard human-readable output, or both.
|
||||
A suggested method might be
|
||||
|
||||
Contains or is based on the Foo software package.
|
||||
Copyright (C) 2112 D. Original Author. All rights reserved.
|
||||
http://their.web.site.invalid/
|
||||
|
||||
Additional notes
|
||||
|
||||
Enforcement is the responsibility of the Author. However, violation of
|
||||
this license may subject you to criminal and civil penalties depending
|
||||
on your country.
|
||||
|
||||
This package is bound by the version of license that accompanies it.
|
||||
Future official versions of a particular package may use a more updated
|
||||
license, and you should always review the license before use. This
|
||||
license's most current version is always available from the following
|
||||
locations:
|
||||
|
||||
[1]http://www.floodgap.com/software/ffsl/
|
||||
[2]gopher://gopher.floodgap.com/1/ffsl/
|
||||
|
||||
This license is version 1, dated 19 November 2006.
|
||||
|
||||
This license is copyright <20> 2006 Cameron Kaiser. All rights reserved.
|
||||
The text of this license is available for re-use and re-distribution
|
||||
under the Creative Commons. The use of the term "Floodgap Free Software
|
||||
License" does not imply endorsement of packages using this license by
|
||||
Floodgap Systems or by Cameron Kaiser. Modified licenses using portions
|
||||
of these terms may refer to themselves as modified FFSL, with the
|
||||
proviso that their modifications be clearly marked in accordance with
|
||||
the Creative Commons Attribution-ShareAlike 2.5 License.
|
||||
|
||||
Only the text of this license, and not programs covered by this
|
||||
license, is so offered under Creative Commons.
|
||||
|
||||
References
|
||||
|
||||
1. http://www.floodgap.com/software/ffsl/
|
||||
2. gopher://gopher.floodgap.com/1/ffsl/
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
GOCMD := go
|
||||
BINARY := gnums
|
||||
PREFIX := /usr/local
|
||||
EXEC_PREFIX := ${PREFIX}
|
||||
BINDIR := ${EXEC_PREFIX}/bin
|
||||
DATAROOTDIR := ${PREFIX}/share
|
||||
MANDIR := ${DATAROOTDIR}/man
|
||||
MAN1DIR := ${MANDIR}/man1
|
||||
|
||||
UPX := $(shell upx -V 2> /dev/null)
|
||||
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
${GOCMD} build -ldflags "-w -s" -o ${BINARY}
|
||||
|
||||
.PHONY: compress
|
||||
compress: ${BINARY}
|
||||
ifdef UPX
|
||||
@echo Compressing the binary with UPX
|
||||
@upx ${BINARY}
|
||||
else
|
||||
@echo Skipping upx compression
|
||||
endif
|
||||
|
||||
.PHONY: install-bin
|
||||
install-bin: build compress
|
||||
install -d ${DESTDIR}${BINDIR}
|
||||
install -m 0755 ./${BINARY} ${DESTDIR}${BINDIR}
|
||||
|
||||
.PHONY: install
|
||||
install: install-bin install-desktop clean
|
||||
|
||||
.PHONY: clean
|
||||
${GOCMD} clean
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall: clean
|
||||
rm -f ${DESTDIR}${BINDIR}/${BINARY}
|
||||
rm -f ${DESTDIR}${DATAROOTDIR}/applications/${BINARY}
|
||||
rm -f ${DESTDIR}${DATAROOTDIR}/pixmaps/${BINARY}-icon.png
|
||||
-update-desktop-database 2> /dev/null
|
||||
|
||||
.PHONY: install-desktop
|
||||
install-desktop: ${BINARY}-icon.png
|
||||
ifeq ($(shell uname), Linux)
|
||||
install -d ${DESTDIR}${DATAROOTDIR}/applications
|
||||
install -m 0644 ./${BINARY}.desktop ${DESTDIR}${DATAROOTDIR}/applications
|
||||
install -d ${DESTDIR}${DATAROOTDIR}/pixmaps
|
||||
install -m 0644 ./${BINARY}-icon.png ${DESTDIR}${DATAROOTDIR}/pixmaps
|
||||
-update-desktop-database 2> /dev/null
|
||||
endif
|
45
README.md
45
README.md
|
@ -8,7 +8,32 @@ gnums is the gui version of my program <a href="https://tildegit.org/sloum/nums"
|
|||
|
||||
On initial load some sensible defaults will be set up. Other options are avialable in the settings menu. You will see a stack view on the left, the calculator buttons on the right, and the main input/output at the top. The main input/output will show what you are typing as you type it and will show the current TOS/total after performing an operation (but before more numerical entry), similar to a regular calculator. The stack view will show the full input stack and allow for more complex operations.
|
||||
|
||||
At present there is no keyboard input. This is on the TODO list and should get added in the near future (after all, who really wants to use a mouse for anything?).
|
||||
Most of the keys can be figured out if you don't know what they are already. I will mention that the enter key will add the currently typed in number to the top of the stack. If you have a number typed in, but have not hit enter, and you use a non-numeric/non-enter key (+, swap, sqrt, etc) the number will automatically be added to the top of the stack before the function is run.
|
||||
|
||||
### Hot Keys
|
||||
|
||||
| Key(s) | Effect |
|
||||
|-------------|-------------------------------------------------------|
|
||||
| Number Key (`0`-`9`) | Enter the given number |
|
||||
| `.` | Enter a decimal point to the current input value |
|
||||
| `Backspace` | Delete a character from the current input value |
|
||||
| `Enter` | Place the current input value on the top of the stack |
|
||||
| `Tab` | Toggle the stack view open/closed |
|
||||
| `Ctrl-q` | Exit gnums |
|
||||
| `+` | Add |
|
||||
| `-` | Subtract |
|
||||
| `*` | Multiply |
|
||||
| `/` | Divide |
|
||||
| `!` | Invert the top stack value's sign (+/-) |
|
||||
| `^` | Exponent |
|
||||
| `f` | Floor |
|
||||
| `c` | Ceiling |
|
||||
| `r` | Round |
|
||||
| `q` | Square root |
|
||||
| `o` | Over |
|
||||
| `s` | Swap |
|
||||
| `d` | Drop |
|
||||
| `u` | Dup |
|
||||
|
||||
## Dependencies
|
||||
|
||||
|
@ -23,17 +48,21 @@ At present there is no keyboard input. This is on the TODO list and should get a
|
|||
|
||||
## Building
|
||||
|
||||
Minor build variations can be found for each system. Using `upx` will reduce binary size by a good bit for any of these systems. After running the build command, and optionally running upx, move the resulting binary onto your path and you are good to go. Makefile coming soon<sup>TM</sup>.
|
||||
Minor build variations can be found for each system. Using upx (`apt install upx` or `brew install upx`) will reduce binary size by a good bit for any of these systems. After running the build command, and optionally running upx, move the resulting binary onto your path and you are good to go.
|
||||
|
||||
### OSX
|
||||
### OSX / Linux
|
||||
|
||||
`go build -ldflags "-s -w" .`
|
||||
You should be able to just run `sudo make install`. If you just want to build locally you can run: `make && make compress`
|
||||
|
||||
Alternatively, you can just run a few things yourself and avoid make altogether:
|
||||
|
||||
`go build -ldflags "-s -w" -o gnums && upx gnums`
|
||||
|
||||
You would then need to move the executable to where you want it, as well as install the desktop entry/icon (linux only).
|
||||
|
||||
### Windows
|
||||
|
||||
`go build -ldflags "-s -w -H=windowsgui -extldflags=-static" .`
|
||||
Windows functionality and build steps are unconfirmed. As is the Makefile for windows usage. The following _should_ work. The makefile instructions provided for OSX/Linux _might_ work.
|
||||
|
||||
### Linux
|
||||
|
||||
`go build`
|
||||
`go build -ldflags "-s -w -H=windowsgui -extldflags=-static" -o gnums.exe`
|
||||
|
||||
|
|
3
calc.go
3
calc.go
|
@ -46,6 +46,9 @@ func (s *stack) String() string {
|
|||
}
|
||||
} else {
|
||||
for i := range s.data {
|
||||
if i > s.ptr {
|
||||
break
|
||||
}
|
||||
strArr = append(strArr, strconv.FormatFloat(s.data[i], 'f', -1, 64))
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 5.0 KiB |
|
@ -0,0 +1,10 @@
|
|||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=gnums
|
||||
GenericName=RPN Calculator
|
||||
Comment=Reverse Polish Notation Calculator
|
||||
Terminal=false
|
||||
Categories=Utility;Calculator;
|
||||
Exec=gnums
|
||||
Icon=gnums-icon
|
||||
|
BIN
gnums.png
BIN
gnums.png
Binary file not shown.
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 30 KiB |
6
go.mod
6
go.mod
|
@ -2,4 +2,8 @@ module tildegit.org/sloum/gnums
|
|||
|
||||
go 1.16
|
||||
|
||||
require github.com/AllenDang/giu v0.5.4
|
||||
require (
|
||||
github.com/AllenDang/giu v0.5.5-0.20210618140556-043793d78478
|
||||
github.com/go-resty/resty/v2 v2.6.0 // indirect
|
||||
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
|
||||
)
|
||||
|
|
21
go.sum
21
go.sum
|
@ -1,7 +1,13 @@
|
|||
github.com/AllenDang/giu v0.5.4 h1:OuSgcTZYH9buug1yWsJAvUr57aQwiJK7hjk+JYtv4tM=
|
||||
github.com/AllenDang/giu v0.5.4/go.mod h1:1CyOLkJREGGWFVx+p2z5+1KMhY3H7Zbl8gQ/huzThsI=
|
||||
github.com/AllenDang/giu v0.5.5-0.20210618140556-043793d78478 h1:cJqc5MdsIzCh/xKIX/lwyCAJs/kgByO+2+RVdufrnJU=
|
||||
github.com/AllenDang/giu v0.5.5-0.20210618140556-043793d78478/go.mod h1:mBndBoUtz/rB2cCVpEMeO+1TXYemYFokE/i/FTjPkUc=
|
||||
github.com/AllenDang/go-findfont v0.0.0-20200702051237-9f180485aeb8 h1:dKZMqib/yUDoCFigmz2agG8geZ/e3iRq304/KJXqKyw=
|
||||
github.com/AllenDang/go-findfont v0.0.0-20200702051237-9f180485aeb8/go.mod h1:b4uuDd0s6KRIPa84cEEchdQ9ICh7K0OryZHbSzMca9k=
|
||||
github.com/AllenDang/imgui-go v1.12.1-0.20210509113325-c0e4c78e7a88 h1:dXpshnNwPl+QjFOiJNFlQrtOz1oA565EO9FUseKvlhU=
|
||||
github.com/AllenDang/imgui-go v1.12.1-0.20210509113325-c0e4c78e7a88/go.mod h1:+pYwstqlGGlU2lI1FREPlVAKP2nwV+bNhAlMrbQynhQ=
|
||||
github.com/AllenDang/imgui-go v1.12.1-0.20210617113257-a210d0333fc7 h1:Pk4JnlvVIHhE2TuLaCoJ3TtSDe+rEn7vdCD/rfoDwp8=
|
||||
github.com/AllenDang/imgui-go v1.12.1-0.20210617113257-a210d0333fc7/go.mod h1:+pYwstqlGGlU2lI1FREPlVAKP2nwV+bNhAlMrbQynhQ=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/faiface/mainthread v0.0.0-20171120011319-8b78f0a41ae3 h1:baVdMKlASEHrj19iqjARrPbaRisD7EuZEVJj6ZMLl1Q=
|
||||
|
@ -13,17 +19,32 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210410170116-ea3d685f79fb h1:T6gaWBvRzJ
|
|||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210410170116-ea3d685f79fb/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8So=
|
||||
github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU=
|
||||
github.com/go-resty/resty/v2 v2.6.0 h1:joIR5PNLM2EFqqESUjCMGXrWmXNHEU9CEiK813oKYS4=
|
||||
github.com/go-resty/resty/v2 v2.6.0/go.mod h1:PwvJS6hvaPkjtjNg9ph+VrSD92bi5Zq73w/BIH7cC3Q=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sahilm/fuzzy v0.1.0 h1:FzWGaw2Opqyu+794ZQ9SYifWv2EIXpwP4q8dY1kDAwI=
|
||||
github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120 h1:EZ3cVSzKOlJxAd8e8YAJ7no8nNypTxexh/YE/xW3ZEY=
|
||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q=
|
||||
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
|
156
main.go
156
main.go
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"image/color"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -9,8 +10,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
MasterWidth int = 376
|
||||
Version string = "0.1.1"
|
||||
MasterWidth int = 378
|
||||
Version string = "0.2.0"
|
||||
FullStack int = iota
|
||||
TopThree
|
||||
TopOfStack
|
||||
|
@ -133,26 +134,23 @@ func SetStackLabelWithSort() {
|
|||
}
|
||||
|
||||
stackLabel = g.Label(fmt.Sprintf("Stack Output\n[d]{%s}", sort))
|
||||
outputDisplay = s.String()
|
||||
}
|
||||
|
||||
func ToggleScreenSize() {
|
||||
width := MasterWidth
|
||||
if ShowStack {
|
||||
width = MasterWidth + MasterWidth / 2
|
||||
}
|
||||
wnd.SetSize(width,400)
|
||||
}
|
||||
|
||||
func loop() {
|
||||
g.SingleWindowWithMenuBar("gnums - " + Version).Layout(
|
||||
g.MenuBar().Layout(
|
||||
g.Menu("File").Layout(
|
||||
g.MenuItem("Exit").OnClick(Exit),
|
||||
),
|
||||
g.Menu("Edit").Layout(
|
||||
g.MenuItem("Copy TOS"),
|
||||
g.MenuItem("Copy Stack"),
|
||||
g.MenuItem("Clear Stack"),
|
||||
),
|
||||
g.Menu("Settings").Layout(
|
||||
g.Checkbox("Show Stack Window", &ShowStack).OnChange(func(){
|
||||
width := MasterWidth
|
||||
if ShowStack {
|
||||
width = MasterWidth + MasterWidth / 2
|
||||
}
|
||||
wnd.SetSize(width,400)}),
|
||||
g.Menu("gnums").Layout(
|
||||
g.Label("v"+Version),
|
||||
g.Checkbox("Show Stack Window", &ShowStack).OnChange(ToggleScreenSize),
|
||||
g.Menu("Output Style").Layout(
|
||||
g.RadioButton("Full Stack", stackStyle == FullStack).OnChange(func(){stackStyle = FullStack; outputDisplay = s.String()}),
|
||||
g.RadioButton("Top Three", stackStyle == TopThree).OnChange(func(){stackStyle = TopThree; outputDisplay = s.String()}),
|
||||
|
@ -162,13 +160,12 @@ func loop() {
|
|||
g.RadioButton("TOS ...", stackSort == Dsc).OnChange(func(){stackSort = Dsc; SetStackLabelWithSort()}),
|
||||
g.RadioButton("... TOS", stackSort == Asc).OnChange(func(){stackSort = Asc; SetStackLabelWithSort()}),
|
||||
),
|
||||
g.MenuItem("Exit").OnClick(Exit),
|
||||
),
|
||||
),
|
||||
g.Row(
|
||||
g.Label("gnums v" + Version),
|
||||
),
|
||||
g.Dummy(0, 5),
|
||||
g.Dummy(-1, 8),
|
||||
ComboView.Size(-1).Flags(1 << 14),
|
||||
g.Dummy(-1, 8),
|
||||
g.Row(
|
||||
g.Condition(ShowStack, g.Layout{
|
||||
g.Row(
|
||||
|
@ -181,7 +178,9 @@ func loop() {
|
|||
),
|
||||
g.Child("Section").Layout(
|
||||
g.Row(
|
||||
g.Button("Clear").Size(50,50).OnClick(func(){callStackWord(s.Clear)}),
|
||||
g.Style().SetColor(g.StyleColorButton, color.RGBA{150, 55, 55, 255}).To(
|
||||
g.Button("Clear").Size(50,50).OnClick(func(){callStackWord(s.Clear)}),
|
||||
),
|
||||
g.Button("Delete").Size(50,50).OnClick(func(){inputBuffer.Delete()}),
|
||||
g.Button("Round").Size(50,50).OnClick(func(){callStackWord(s.Round)}),
|
||||
g.Button("^").Size(50,50).OnClick(func(){callStackWord(s.Pow)}),
|
||||
|
@ -190,40 +189,58 @@ func loop() {
|
|||
),
|
||||
g.Row(
|
||||
g.Button("Over").Size(50,50).OnClick(func(){callStackWord(s.Ovr)}),
|
||||
g.Button("7").Size(50,50).OnClick(func(){inputBuffer.Append('7')}),
|
||||
g.Button("8").Size(50,50).OnClick(func(){inputBuffer.Append('8')}),
|
||||
g.Button("9").Size(50,50).OnClick(func(){inputBuffer.Append('9')}),
|
||||
g.Style().SetColor(g.StyleColorButton, color.RGBA{205, 150, 30, 200}).To(
|
||||
g.Row(
|
||||
g.Button("7").Size(50,50).OnClick(func(){inputBuffer.Append('7')}),
|
||||
g.Button("8").Size(50,50).OnClick(func(){inputBuffer.Append('8')}),
|
||||
g.Button("9").Size(50,50).OnClick(func(){inputBuffer.Append('9')}),
|
||||
),
|
||||
),
|
||||
g.Button("×").Size(50,50).OnClick(func(){callStackWord(s.Mul)}),
|
||||
g.Button("Floor").Size(50,50).OnClick(func(){callStackWord(s.Floor)}),
|
||||
),
|
||||
g.Row(
|
||||
g.Button("Swap").Size(50,50).OnClick(func(){callStackWord(s.Swp)}),
|
||||
g.Button("4").Size(50,50).OnClick(func(){inputBuffer.Append('4')}),
|
||||
g.Button("5").Size(50,50).OnClick(func(){inputBuffer.Append('5')}),
|
||||
g.Button("6").Size(50,50).OnClick(func(){inputBuffer.Append('6')}),
|
||||
g.Style().SetColor(g.StyleColorButton, color.RGBA{205, 150, 30, 200}).To(
|
||||
g.Row(
|
||||
g.Button("4").Size(50,50).OnClick(func(){inputBuffer.Append('4')}),
|
||||
g.Button("5").Size(50,50).OnClick(func(){inputBuffer.Append('5')}),
|
||||
g.Button("6").Size(50,50).OnClick(func(){inputBuffer.Append('6')}),
|
||||
),
|
||||
),
|
||||
g.Button("-").Size(50,50).OnClick(func(){callStackWord(s.Sub)}),
|
||||
g.Button("Ceil").Size(50,50).OnClick(func(){callStackWord(s.Ceil)}),
|
||||
),
|
||||
g.Row(
|
||||
g.Button("Dup").Size(50,50).OnClick(func(){callStackWord(s.Dup)}),
|
||||
g.Button("1").Size(50,50).OnClick(func(){inputBuffer.Append('1')}),
|
||||
g.Button("2").Size(50,50).OnClick(func(){inputBuffer.Append('2')}),
|
||||
g.Button("3").Size(50,50).OnClick(func(){inputBuffer.Append('3')}),
|
||||
g.Style().SetColor(g.StyleColorButton, color.RGBA{205, 150, 30, 200}).To(
|
||||
g.Row(
|
||||
g.Button("1").Size(50,50).OnClick(func(){inputBuffer.Append('1')}),
|
||||
g.Button("2").Size(50,50).OnClick(func(){inputBuffer.Append('2')}),
|
||||
g.Button("3").Size(50,50).OnClick(func(){inputBuffer.Append('3')}),
|
||||
),
|
||||
),
|
||||
g.Button("+").Size(50,50).OnClick(func(){callStackWord(s.Add)}),
|
||||
g.Button("+/-").Size(50,50).OnClick(func(){callStackWord(s.Inv)}),
|
||||
),
|
||||
g.Row(
|
||||
g.Button("Drop").Size(50,50).OnClick(func(){callStackWord(s.Drp)}),
|
||||
g.Button(".").Size(50,50).OnClick(func(){inputBuffer.Append('.')}),
|
||||
g.Button("0").Size(50,50).OnClick(func(){inputBuffer.Append('0')}),
|
||||
g.Button("Enter").Size(165,50).OnClick(func(){inputBuffer.Store(); outputDisplay = s.String()}),
|
||||
g.Style().SetColor(g.StyleColorButton, color.RGBA{205, 150, 30, 200}).To(
|
||||
g.Button("0").Size(50,50).OnClick(func(){inputBuffer.Append('0')}),
|
||||
),
|
||||
g.Style().SetColor(g.StyleColorButton, color.RGBA{51, 102, 55, 255}).To(
|
||||
g.Button("Enter").Size(165,50).OnClick(func(){inputBuffer.Store(); outputDisplay = s.String()}),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
}, g.Layout{
|
||||
g.Child("Button Section").Layout(
|
||||
g.Row(
|
||||
g.Button("Clear").Size(50,50).OnClick(func(){callStackWord(s.Clear)}),
|
||||
g.Style().SetColor(g.StyleColorButton, color.RGBA{150, 55, 55, 255}).To(
|
||||
g.Button("Clear").Size(50,50).OnClick(func(){callStackWord(s.Clear)}),
|
||||
),
|
||||
g.Button("Delete").Size(50,50).OnClick(func(){inputBuffer.Delete()}),
|
||||
g.Button("Round").Size(50,50).OnClick(func(){callStackWord(s.Round)}),
|
||||
g.Button("^").Size(50,50).OnClick(func(){callStackWord(s.Pow)}),
|
||||
|
@ -232,33 +249,49 @@ func loop() {
|
|||
),
|
||||
g.Row(
|
||||
g.Button("Over").Size(50,50).OnClick(func(){callStackWord(s.Ovr)}),
|
||||
g.Button("7").Size(50,50).OnClick(func(){inputBuffer.Append('7')}),
|
||||
g.Button("8").Size(50,50).OnClick(func(){inputBuffer.Append('8')}),
|
||||
g.Button("9").Size(50,50).OnClick(func(){inputBuffer.Append('9')}),
|
||||
g.Style().SetColor(g.StyleColorButton, color.RGBA{205, 150, 30, 200}).To(
|
||||
g.Row(
|
||||
g.Button("7").Size(50,50).OnClick(func(){inputBuffer.Append('7')}),
|
||||
g.Button("8").Size(50,50).OnClick(func(){inputBuffer.Append('8')}),
|
||||
g.Button("9").Size(50,50).OnClick(func(){inputBuffer.Append('9')}),
|
||||
),
|
||||
),
|
||||
g.Button("×").Size(50,50).OnClick(func(){callStackWord(s.Mul)}),
|
||||
g.Button("Floor").Size(50,50).OnClick(func(){callStackWord(s.Floor)}),
|
||||
),
|
||||
g.Row(
|
||||
g.Button("Swap").Size(50,50).OnClick(func(){callStackWord(s.Swp)}),
|
||||
g.Button("4").Size(50,50).OnClick(func(){inputBuffer.Append('4')}),
|
||||
g.Button("5").Size(50,50).OnClick(func(){inputBuffer.Append('5')}),
|
||||
g.Button("6").Size(50,50).OnClick(func(){inputBuffer.Append('6')}),
|
||||
g.Style().SetColor(g.StyleColorButton, color.RGBA{205, 150, 30, 200}).To(
|
||||
g.Row(
|
||||
g.Button("4").Size(50,50).OnClick(func(){inputBuffer.Append('4')}),
|
||||
g.Button("5").Size(50,50).OnClick(func(){inputBuffer.Append('5')}),
|
||||
g.Button("6").Size(50,50).OnClick(func(){inputBuffer.Append('6')}),
|
||||
),
|
||||
),
|
||||
g.Button("-").Size(50,50).OnClick(func(){callStackWord(s.Sub)}),
|
||||
g.Button("Ceil").Size(50,50).OnClick(func(){callStackWord(s.Ceil)}),
|
||||
),
|
||||
g.Row(
|
||||
g.Button("Dup").Size(50,50).OnClick(func(){callStackWord(s.Dup)}),
|
||||
g.Button("1").Size(50,50).OnClick(func(){inputBuffer.Append('1')}),
|
||||
g.Button("2").Size(50,50).OnClick(func(){inputBuffer.Append('2')}),
|
||||
g.Button("3").Size(50,50).OnClick(func(){inputBuffer.Append('3')}),
|
||||
g.Style().SetColor(g.StyleColorButton, color.RGBA{205, 150, 30, 200}).To(
|
||||
g.Row(
|
||||
g.Button("1").Size(50,50).OnClick(func(){inputBuffer.Append('1')}),
|
||||
g.Button("2").Size(50,50).OnClick(func(){inputBuffer.Append('2')}),
|
||||
g.Button("3").Size(50,50).OnClick(func(){inputBuffer.Append('3')}),
|
||||
),
|
||||
),
|
||||
g.Button("+").Size(50,50).OnClick(func(){callStackWord(s.Add)}),
|
||||
g.Button("+/-").Size(50,50).OnClick(func(){callStackWord(s.Inv)}),
|
||||
),
|
||||
g.Row(
|
||||
g.Button("Drop").Size(50,50).OnClick(func(){callStackWord(s.Drp)}),
|
||||
g.Button(".").Size(50,50).OnClick(func(){inputBuffer.Append('.')}),
|
||||
g.Button("0").Size(50,50).OnClick(func(){inputBuffer.Append('0')}),
|
||||
g.Button("Enter").Size(165,50).OnClick(func(){inputBuffer.Store(); outputDisplay = s.String()}),
|
||||
g.Style().SetColor(g.StyleColorButton, color.RGBA{205, 150, 30, 200}).To(
|
||||
g.Button("0").Size(50,50).OnClick(func(){inputBuffer.Append('0')}),
|
||||
),
|
||||
g.Style().SetColor(g.StyleColorButton, color.RGBA{51, 102, 55, 255}).To(
|
||||
g.Button("Enter").Size(165,50).OnClick(func(){inputBuffer.Store(); outputDisplay = s.String()}),
|
||||
),
|
||||
),
|
||||
),
|
||||
}),
|
||||
|
@ -271,6 +304,37 @@ func Exit() {
|
|||
}
|
||||
|
||||
func main() {
|
||||
wnd = g.NewMasterWindow("gnums", MasterWidth+MasterWidth/2, 390, g.MasterWindowFlagsNotResizable, nil)
|
||||
wnd = g.NewMasterWindow("gnums", MasterWidth+MasterWidth/2, 385, g.MasterWindowFlagsNotResizable).RegisterKeyboardShortcuts(
|
||||
g.WindowShortcut{Key: g.KeyQ, Modifier: g.ModControl, Callback: Exit},
|
||||
g.WindowShortcut{Key: g.Key0, Callback: func(){inputBuffer.Append('0')}},
|
||||
g.WindowShortcut{Key: g.Key1, Callback: func(){inputBuffer.Append('1')}},
|
||||
g.WindowShortcut{Key: g.Key2, Callback: func(){inputBuffer.Append('2')}},
|
||||
g.WindowShortcut{Key: g.Key3, Callback: func(){inputBuffer.Append('3')}},
|
||||
g.WindowShortcut{Key: g.Key4, Callback: func(){inputBuffer.Append('4')}},
|
||||
g.WindowShortcut{Key: g.Key5, Callback: func(){inputBuffer.Append('5')}},
|
||||
g.WindowShortcut{Key: g.Key6, Callback: func(){inputBuffer.Append('6')}},
|
||||
g.WindowShortcut{Key: g.Key7, Callback: func(){inputBuffer.Append('7')}},
|
||||
g.WindowShortcut{Key: g.Key8, Callback: func(){inputBuffer.Append('8')}},
|
||||
g.WindowShortcut{Key: g.Key9, Callback: func(){inputBuffer.Append('9')}},
|
||||
g.WindowShortcut{Key: g.KeyPeriod, Callback: func(){inputBuffer.Append('.')}},
|
||||
g.WindowShortcut{Key: g.KeyMinus, Callback: func(){callStackWord(s.Sub)}},
|
||||
g.WindowShortcut{Key: g.KeyR, Callback: func(){callStackWord(s.Round)}},
|
||||
g.WindowShortcut{Key: g.KeyC, Callback: func(){callStackWord(s.Ceil)}},
|
||||
g.WindowShortcut{Key: g.KeyF, Callback: func(){callStackWord(s.Floor)}},
|
||||
g.WindowShortcut{Key: g.KeyQ, Callback: func(){callStackWord(s.Sqt)}},
|
||||
g.WindowShortcut{Key: g.KeyS, Callback: func(){callStackWord(s.Swp)}},
|
||||
g.WindowShortcut{Key: g.KeyO, Callback: func(){callStackWord(s.Ovr)}},
|
||||
g.WindowShortcut{Key: g.KeyD, Callback: func(){callStackWord(s.Drp)}},
|
||||
g.WindowShortcut{Key: g.KeyU, Callback: func(){callStackWord(s.Dup)}},
|
||||
g.WindowShortcut{Key: g.KeyEqual, Modifier: g.ModShift, Callback: func(){callStackWord(s.Add)}},
|
||||
g.WindowShortcut{Key: g.Key8, Modifier: g.ModShift, Callback: func(){callStackWord(s.Mul)}},
|
||||
g.WindowShortcut{Key: g.KeySlash, Callback: func(){callStackWord(s.Div)}},
|
||||
g.WindowShortcut{Key: g.Key6, Modifier: g.ModShift, Callback: func(){callStackWord(s.Pow)}},
|
||||
g.WindowShortcut{Key: g.KeyEnter, Callback: func(){inputBuffer.Store(); outputDisplay = s.String()}},
|
||||
g.WindowShortcut{Key: g.KeyTab, Callback: func(){ShowStack = !ShowStack; ToggleScreenSize()}},
|
||||
g.WindowShortcut{Key: g.KeyEscape, Callback: func(){callStackWord(s.Clear)}},
|
||||
g.WindowShortcut{Key: g.Key1, Modifier: g.ModShift, Callback: func(){callStackWord(s.Inv)}},
|
||||
g.WindowShortcut{Key: g.KeyBackspace, Callback: func(){inputBuffer.Delete()}},
|
||||
)
|
||||
wnd.Run(loop)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue