wmcalc: Remove trailing whitespace.

This commit is contained in:
Doug Torrance 2015-01-10 10:59:48 -06:00 committed by Carlos R. Mafra
parent 587fe05cc1
commit 6b282a4b4d
15 changed files with 241 additions and 241 deletions

View file

@ -1,13 +1,13 @@
# wmcalc Configuration File # wmcalc Configuration File
# Last Manual Update: 10/29/00 # Last Manual Update: 10/29/00
# General Notes: # General Notes:
# * There must be a tab character '\t' between the variable name and # * There must be a tab character '\t' between the variable name and
# the value, not a series of spaces. # the value, not a series of spaces.
# * wmcalc is case sensitive when reading these variables. Examine the # * wmcalc is case sensitive when reading these variables. Examine the
# wmcalc_g.h file for currently defined variables. # wmcalc_g.h file for currently defined variables.
#Calculator Memory Locations #Calculator Memory Locations
#Note: These must all exist, though they may be in any order #Note: These must all exist, though they may be in any order
Mem0 0.000000 Mem0 0.000000
Mem1 0.000000 Mem1 0.000000
@ -21,15 +21,15 @@ Mem8 0.000000
Mem9 0.000000 Mem9 0.000000
# The CalcStart variable is intended to allow the user to start a larger # The CalcStart variable is intended to allow the user to start a larger
# calculator for more complicated needs. Everything after the tab '\t' # calculator for more complicated needs. Everything after the tab '\t'
# character is sent unmodified in a system() call, so anything you can type # character is sent unmodified in a system() call, so anything you can type
# at the command prompt may be put here. # at the command prompt may be put here.
#CalcStart xterm -T "Basic Calculator" -e bc & #CalcStart xterm -T "Basic Calculator" -e bc &
#CalcStart xterm -T "gnuplot" -sb -sl 500 -e gnuplot & #CalcStart xterm -T "gnuplot" -sb -sl 500 -e gnuplot &
CalcStart xcalc & CalcStart xcalc &
# The ImagChar variable allows the user to choose between 'i' and 'j' to # The ImagChar variable allows the user to choose between 'i' and 'j' to
# represent the sqrt(-1). (Electrical Engineers (such as myself) use 'j' # represent the sqrt(-1). (Electrical Engineers (such as myself) use 'j'
# rather than 'i.') # rather than 'i.')
#ImagChar i #ImagChar i
ImagChar j ImagChar j

View file

@ -1,13 +1,13 @@
# wmcalc Configuration File # wmcalc Configuration File
# Last Manual Update: 10/29/00 # Last Manual Update: 10/29/00
# General Notes: # General Notes:
# * There must be a tab character '\t' between the variable name and # * There must be a tab character '\t' between the variable name and
# the value, not a series of spaces. # the value, not a series of spaces.
# * wmcalc is case sensitive when reading these variables. Examine the # * wmcalc is case sensitive when reading these variables. Examine the
# wmcalc_g.h file for currently defined variables. # wmcalc_g.h file for currently defined variables.
#Calculator Memory Locations #Calculator Memory Locations
#Note: These must all exist, though they may be in any order #Note: These must all exist, though they may be in any order
Mem0 0.000000 Mem0 0.000000
Mem1 0.000000 Mem1 0.000000
@ -21,15 +21,15 @@ Mem8 0.000000
Mem9 0.000000 Mem9 0.000000
# The CalcStart variable is intended to allow the user to start a larger # The CalcStart variable is intended to allow the user to start a larger
# calculator for more complicated needs. Everything after the tab '\t' # calculator for more complicated needs. Everything after the tab '\t'
# character is sent unmodified in a system() call, so anything you can type # character is sent unmodified in a system() call, so anything you can type
# at the command prompt may be put here. # at the command prompt may be put here.
#CalcStart xterm -T "Basic Calculator" -e bc & #CalcStart xterm -T "Basic Calculator" -e bc &
#CalcStart xterm -T "gnuplot" -sb -sl 500 -e gnuplot & #CalcStart xterm -T "gnuplot" -sb -sl 500 -e gnuplot &
CalcStart xcalc & CalcStart xcalc &
# The ImagChar variable allows the user to choose between 'i' and 'j' to # The ImagChar variable allows the user to choose between 'i' and 'j' to
# represent the sqrt(-1). (Electrical Engineers (such as myself) use 'j' # represent the sqrt(-1). (Electrical Engineers (such as myself) use 'j'
# rather than 'i.') # rather than 'i.')
#ImagChar i #ImagChar i
ImagChar j ImagChar j

View file

@ -1,13 +1,13 @@
# wmcalc Configuration File # wmcalc Configuration File
# Last Manual Update: 10/29/00 # Last Manual Update: 10/29/00
# General Notes: # General Notes:
# * There must be a tab character '\t' between the variable name and # * There must be a tab character '\t' between the variable name and
# the value, not a series of spaces. # the value, not a series of spaces.
# * wmcalc is case sensitive when reading these variables. Examine the # * wmcalc is case sensitive when reading these variables. Examine the
# wmcalc_g.h file for currently defined variables. # wmcalc_g.h file for currently defined variables.
#Calculator Memory Locations #Calculator Memory Locations
#Note: These must all exist, though they may be in any order #Note: These must all exist, though they may be in any order
Mem0 0.000000 Mem0 0.000000
Mem1 0.000000 Mem1 0.000000
@ -21,15 +21,15 @@ Mem8 0.000000
Mem9 0.000000 Mem9 0.000000
# The CalcStart variable is intended to allow the user to start a larger # The CalcStart variable is intended to allow the user to start a larger
# calculator for more complicated needs. Everything after the tab '\t' # calculator for more complicated needs. Everything after the tab '\t'
# character is sent unmodified in a system() call, so anything you can type # character is sent unmodified in a system() call, so anything you can type
# at the command prompt may be put here. # at the command prompt may be put here.
#CalcStart xterm -T "Basic Calculator" -e bc & #CalcStart xterm -T "Basic Calculator" -e bc &
#CalcStart xterm -T "gnuplot" -sb -sl 500 -e gnuplot & #CalcStart xterm -T "gnuplot" -sb -sl 500 -e gnuplot &
CalcStart xcalc & CalcStart xcalc &
# The ImagChar variable allows the user to choose between 'i' and 'j' to # The ImagChar variable allows the user to choose between 'i' and 'j' to
# represent the sqrt(-1). (Electrical Engineers (such as myself) use 'j' # represent the sqrt(-1). (Electrical Engineers (such as myself) use 'j'
# rather than 'i.') # rather than 'i.')
#ImagChar i #ImagChar i
ImagChar j ImagChar j

View file

@ -9,10 +9,10 @@ DESCRIPTION:
------------ ------------
wmcalc is a program designed to act as a simple four-function wmcalc is a program designed to act as a simple four-function
calculator. It is different from other calculator programs, however calculator. It is different from other calculator programs, however
in that it is designed to take up very little desktop space. As such, in that it is designed to take up very little desktop space. As such,
it can be left running on the desktop at all times. It is intended to it can be left running on the desktop at all times. It is intended to
placed in the WindowMaker dock, or in Wharf under Afterstep, though it placed in the WindowMaker dock, or in Wharf under Afterstep, though it
should run as well under any window manager. should run as well under any window manager.
LICENSING: LICENSING:
---------- ----------
@ -24,7 +24,7 @@ CONTRIBUTORS:
------------- -------------
Co-Developers: Co-Developers:
Rick Stuart <stuart@xnet.com> Rick Stuart <stuart@xnet.com>
Philippe Trbich <philippe.trbich@free.fr> Philippe Trbich <philippe.trbich@free.fr>
Original Web Page Designs: Original Web Page Designs:
Jon Bruno <bruno@ksu.edu> Jon Bruno <bruno@ksu.edu>
Thanks to: Thanks to:
@ -36,35 +36,35 @@ bugs in the code, etc.
INSTALLATION: INSTALLATION:
------------- -------------
Untar the file: Untar the file:
tar xvzf wmcalc-0.3.tar.gz tar xvzf wmcalc-0.3.tar.gz
CD to source directory: CD to source directory:
cd wmcalc-0.3 cd wmcalc-0.3
Compile it: Compile it:
make clean; make make clean; make
Copy the config file: Copy the config file:
cp .wmcalc ~ cp .wmcalc ~
Put the executable somewhere in your path: Put the executable somewhere in your path:
mv wmcalc /usr/local/bin (or anyhere in your path) mv wmcalc /usr/local/bin (or anyhere in your path)
Run it: Run it:
wmcalc & wmcalc &
Grab the appicon and move it to the dock. Grab the appicon and move it to the dock.
Change the settings to start with Windowmaker Change the settings to start with Windowmaker
Afterstep Wharf 1.6.??: (I don't use Afterstep anymore, so...) Afterstep Wharf 1.6.??: (I don't use Afterstep anymore, so...)
*Wharf wmcalc -Swallow "wmcalc" wmcalc & *Wharf wmcalc -Swallow "wmcalc" wmcalc &
***Note***: ***Note***:
The appicon only has a two pixel border where you can grab The appicon only has a two pixel border where you can grab
and move it. It is easiest to grab along the bottom edge. and move it. It is easiest to grab along the bottom edge.
If make doesn't work, you may need to fiddle with the settings in If make doesn't work, you may need to fiddle with the settings in
the Makefile. the Makefile.
Tested on: (Well, it runs, I don't know if 'Tested' is quite right...) Tested on: (Well, it runs, I don't know if 'Tested' is quite right...)
@ -77,23 +77,23 @@ usage: wmcalc [-g geometry] [-d dpy] [-v] [-f configfilename] [-h]
-g <geometry> Window Geometry - ie: 64x64+10+10 -g <geometry> Window Geometry - ie: 64x64+10+10
-d <display> Display - ie: 127.0.0.1:0.0 -d <display> Display - ie: 127.0.0.1:0.0
-v Verbose Mode. -v Verbose Mode.
-h Help. This message. -h Help. This message.
-f <filename> Full path to configuration file to use. -f <filename> Full path to configuration file to use.
Buttons are defined as: Buttons are defined as:
____________________ ____________________
| x00 | where: x = 1 for Left Mouse Button | x00 | where: x = 1 for Left Mouse Button
| 0 1 2 3 4 5 6 7 8 9| x = 2 for Middle Mouse Button | 0 1 2 3 4 5 6 7 8 9| x = 2 for Middle Mouse Button
|--------------------| x = 3 for Right Mouse Button |--------------------| x = 3 for Right Mouse Button
|x01 x02 x03 x04 x05 | |x01 x02 x03 x04 x05 |
|x06 x07 x08 x09 x10 | Note: the numbers 0..9 are the indicators |x06 x07 x08 x09 x10 | Note: the numbers 0..9 are the indicators
|x11 x12 x13 x14 x15 | for memory cells 0..9 respectively |x11 x12 x13 x14 x15 | for memory cells 0..9 respectively
|x16 x17 x18 x19 x20 | |x16 x17 x18 x19 x20 |
-------------------- --------------------
Button Functions: Button Functions:
100 Reinitialize the calculator, and both Registers 100 Reinitialize the calculator, and both Registers
(Clear All) (Clear All)
200 Clear all the memory registers (0..10) 200 Clear all the memory registers (0..10)
300 Clear the current number being entered only 300 Clear the current number being entered only
@ -106,18 +106,18 @@ Button Functions:
3yy Store Displayed number in memory location [0-9] 3yy Store Displayed number in memory location [0-9]
if yy = 2,3,4, 7,8,9, 12,13,14, 17 if yy = 2,3,4, 7,8,9, 12,13,14, 17
otherwise, can run a user-defined function (not implemented) otherwise, can run a user-defined function (not implemented)
1xx Hopefully the other functions are obvious from their 1xx Hopefully the other functions are obvious from their
button graphics. button graphics.
NOTES: NOTES:
------ ------
I am sure that there are better ways to do some of the things that are I am sure that there are better ways to do some of the things that are
done in wmcalc. In fact, wmcalc is basically a series of hacks, but appears done in wmcalc. In fact, wmcalc is basically a series of hacks, but appears
to be stable... to be stable...
The configuration file (.wmcalc) is written by wmcalc whenever the user The configuration file (.wmcalc) is written by wmcalc whenever the user
requests to store a number to memory. As a part of this process, a file requests to store a number to memory. As a part of this process, a file
is written to /tmp. If /tmp is not accessible, it tries in the user's home is written to /tmp. If /tmp is not accessible, it tries in the user's home
directory, as defined by the environment variable HOME. This file is directory, as defined by the environment variable HOME. This file is
erased as soon as it is written over the main configuration file. erased as soon as it is written over the main configuration file.
@ -125,16 +125,16 @@ erased as soon as it is written over the main configuration file.
Changes made to the configuration file (other than memory stores) will not Changes made to the configuration file (other than memory stores) will not
take effect until the next time wmcalc is started. take effect until the next time wmcalc is started.
Although one can only "Clear" all unlocked memory locations, one may clear the Although one can only "Clear" all unlocked memory locations, one may clear the
display and then "store" a '0' in the memory location, providing the display and then "store" a '0' in the memory location, providing the
ability to clear individual cells. ability to clear individual cells.
The fonts are stored in charmap.xpm. This file may be edited to The fonts are stored in charmap.xpm. This file may be edited to
change colors or fonts, but the app must be recompiled for the changes change colors or fonts, but the app must be recompiled for the changes
to take effect. The buttons are located in calcbuttons.xpm. This to take effect. The buttons are located in calcbuttons.xpm. This
file may be edited, though the borders should stay where they are file may be edited, though the borders should stay where they are
unless you want to change the button regions that are hard coded. unless you want to change the button regions that are hard coded.
The background border is defined in backdrop.xpm. The background border is defined in backdrop.xpm.
"C code. C code run. Run, code, run. "C code. C code run. Run, code, run.
PLEASE!?!?!?!?!?!?" PLEASE!?!?!?!?!?!?"
@ -158,9 +158,9 @@ CHANGE LOG:
functional calculator, but just tested the display. It was more functional calculator, but just tested the display. It was more
of a proof of concept. of a proof of concept.
TODO: TODO:
----- -----
These are partially a dream list. I don't know when they'll get done, These are partially a dream list. I don't know when they'll get done,
as I'm pretty busy at work. Anyone want to tackle these?? as I'm pretty busy at work. Anyone want to tackle these??
* Re-implement the register/display design to allow full double precision. * Re-implement the register/display design to allow full double precision.
@ -174,19 +174,19 @@ as I'm pretty busy at work. Anyone want to tackle these??
that one can intentionally write data to. (This could grow to a pipe to that one can intentionally write data to. (This could grow to a pipe to
plotting programs, etc, though this is a bit extreme...) plotting programs, etc, though this is a bit extreme...)
RPN: RPN:
I have no intention at this time to add in an RPN format, as I I have no intention at this time to add in an RPN format, as I
personally do not like it. It should be noted that I have NOT used it personally do not like it. It should be noted that I have NOT used it
extensively, and I've heard that I would like it. But, until then... extensively, and I've heard that I would like it. But, until then...
BUGS: BUGS:
----- -----
Remember, they're just undocumented FEATURES!!! Remember, they're just undocumented FEATURES!!!
* The display can lose the last digit of a three character exponential * The display can lose the last digit of a three character exponential
notation number. notation number.
* Due to an implementation fault, at every step of calculations, precision * Due to an implementation fault, at every step of calculations, precision
is lost, as the number is only as accurate at that displayed. is lost, as the number is only as accurate at that displayed.
* Order of operations: 1 + 2 * 5 = 15, not 11, as it should. * Order of operations: 1 + 2 * 5 = 15, not 11, as it should.
@ -194,8 +194,8 @@ Remember, they're just undocumented FEATURES!!!
* Changing sign when the display is blank results in "-0". Further entry * Changing sign when the display is blank results in "-0". Further entry
yields "-05...," but this does not affect calculations. yields "-05...," but this does not affect calculations.
* Changes to the configuration file do not take effect until wmcalc is * Changes to the configuration file do not take effect until wmcalc is
restarted. (Note that file is written whenever a "store memory restarted. (Note that file is written whenever a "store memory
location" is requested) location" is requested)
Probably many more. Send comments (preferably with fixes) to Probably many more. Send comments (preferably with fixes) to
@ -204,9 +204,9 @@ I will happily include your name in the documentation for the program
if you send me a bug report and the correction. This can be in the if you send me a bug report and the correction. This can be in the
form of a patch file, or ASCII text to exchange, or an equivalent. form of a patch file, or ASCII text to exchange, or an equivalent.
Note, this program is written in C. Not C++. I'm not a computer Note, this program is written in C. Not C++. I'm not a computer
science person, I don't do objects. Therefore, bug fixes that convert science person, I don't do objects. Therefore, bug fixes that convert
this to C++ don't count, since I would no longer be able to support this to C++ don't count, since I would no longer be able to support
the program. Of course, you can modify the code and release a new the program. Of course, you can modify the code and release a new
application. application.
Thanks, and Good Luck. Thanks, and Good Luck.

View file

@ -10,10 +10,10 @@ static char mask_bits[] = {
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,

View file

@ -29,23 +29,23 @@ This manual page was written for the Debian GNU/Linux distribution
because the original program does not have a manual page. because the original program does not have a manual page.
.PP .PP
.\" TeX users may be more comfortable with the \fB<whatever>\fP and .\" TeX users may be more comfortable with the \fB<whatever>\fP and
.\" \fI<whatever>\fP escape sequences to invode bold face and italics, .\" \fI<whatever>\fP escape sequences to invode bold face and italics,
.\" respectively. .\" respectively.
\fBwmcalc\fP is a program designed to act as a simple calculator offering basic operations like addition, subtraction, multiplication, division, square and squareroot. It is different from other calculator programs, however in that it is designed to take up very little desktop space. As such, it can be left running on the desktop at all times. It is intended to placed in the WindowMaker dock, or in Wharf under Afterstep, though it should run as well under any window manager. \fBwmcalc\fP is a program designed to act as a simple calculator offering basic operations like addition, subtraction, multiplication, division, square and squareroot. It is different from other calculator programs, however in that it is designed to take up very little desktop space. As such, it can be left running on the desktop at all times. It is intended to placed in the WindowMaker dock, or in Wharf under Afterstep, though it should run as well under any window manager.
\fB*IMPORTANT*\fP: this calculator, due to its simple target, does not respect the proper mathematical operations order, and they are executed in the order they are inserted. \fB*IMPORTANT*\fP: this calculator, due to its simple target, does not respect the proper mathematical operations order, and they are executed in the order they are inserted.
Buttons are defined as: Buttons are defined as:
.nf .nf
____________________ ____________________
| x00 | x = 1 for Left Mouse Button | x00 | x = 1 for Left Mouse Button
| 0 1 2 3 4 5 6 7 8 9| x = 2 for Middle Mouse Button | 0 1 2 3 4 5 6 7 8 9| x = 2 for Middle Mouse Button
|--------------------| x = 3 for Right Mouse Button |--------------------| x = 3 for Right Mouse Button
|x01 x02 x03 x04 x05 | |x01 x02 x03 x04 x05 |
|x06 x07 x08 x09 x10 | Note: the numbers 0..9 are the |x06 x07 x08 x09 x10 | Note: the numbers 0..9 are the
|x11 x12 x13 x14 x15 | indicators for memory cells |x11 x12 x13 x14 x15 | indicators for memory cells
|x16 x17 x18 x19 x20 | 0..9 respectively |x16 x17 x18 x19 x20 | 0..9 respectively
-------------------- --------------------
.fi .fi
.TP .TP
Button Functions: Button Functions:
@ -87,7 +87,7 @@ Display - ie: 127.0.0.1:0.0
Full path to configuration file. Full path to configuration file.
.TP .TP
.B \-v .B \-v
Verbose Mode. Verbose Mode.
.TP .TP
.B \-h .B \-h
Help. Help.

View file

@ -4,28 +4,28 @@
* Date: January 17, 2001 * Date: January 17, 2001
* Author: Edward H. Flora <ehflora@access1.net> * Author: Edward H. Flora <ehflora@access1.net>
* *
* This file is a part of the wmcalc application. As such, this * This file is a part of the wmcalc application. As such, this
* file is licensed under the GNU General Public License, version 2. * file is licensed under the GNU General Public License, version 2.
* A copy of this license may be found in the file COPYING that should * A copy of this license may be found in the file COPYING that should
* have been distributed with this file. If not, please refer to * have been distributed with this file. If not, please refer to
* http://www.gnu.org/copyleft/gpl.html for details. * http://www.gnu.org/copyleft/gpl.html for details.
* *
**************************************************************** ****************************************************************
Description: Description:
This file contains the main program code for the wmcalc This file contains the main program code for the wmcalc
application. Wmcalc is a dockapp designed for the WindowMaker or application. Wmcalc is a dockapp designed for the WindowMaker or
Afterstep window managers (although it should run well in most Afterstep window managers (although it should run well in most
others.) wmcalc is a four-function (and more) calculator that others.) wmcalc is a four-function (and more) calculator that
has a small enough footprint that you may leave it open on your has a small enough footprint that you may leave it open on your
desktop at all times, for convenient use. desktop at all times, for convenient use.
Change History: Change History:
Date Modification Date Modification
01/17/01 Updated to use XLookupString 01/17/01 Updated to use XLookupString
12/10/00 Revised includes, extracting X libs to wmcalc_x.h 12/10/00 Revised includes, extracting X libs to wmcalc_x.h
11/09/00 Added "locked" memory capabilities 11/09/00 Added "locked" memory capabilities
11/08/00 Added Code to Support Keyboard / focus 11/08/00 Added Code to Support Keyboard / focus
10/29/00 Implemented memory use, configuration files, and a 10/29/00 Implemented memory use, configuration files, and a
quickstart button for a larger calculator. Also quickstart button for a larger calculator. Also
abstracted some of the macros, global vars, function abstracted some of the macros, global vars, function
@ -34,7 +34,7 @@
02/10/00 Added keyboard event code, without success 02/10/00 Added keyboard event code, without success
12/21/99 Original product release, version 0.1 12/21/99 Original product release, version 0.1
11/26/99 Original file creation 11/26/99 Original file creation
****************************************************************/ ****************************************************************/
#include "wmcalc_x.h" #include "wmcalc_x.h"
@ -69,7 +69,7 @@ char OpFlag = ' '; /* Operation requested */
int ExpFlag = 0; /* Flag if in scientific notation */ int ExpFlag = 0; /* Flag if in scientific notation */
int DecFlag = 0; /* Flag if a decimal is in display */ int DecFlag = 0; /* Flag if a decimal is in display */
int ImgFlag = 0; /* Flag if a number is imaginary */ int ImgFlag = 0; /* Flag if a number is imaginary */
int StrCnt = 0; int StrCnt = 0;
double RegisterA = 0.0; /* Main working register, displayed */ double RegisterA = 0.0; /* Main working register, displayed */
double RegisterB = 0.0; /* Second register to add to, etc */ double RegisterB = 0.0; /* Second register to add to, etc */
char DispString[DISPSIZE+1]; /* Pointer to string of display */ char DispString[DISPSIZE+1]; /* Pointer to string of display */
@ -84,7 +84,7 @@ char *app_name = "wmcalc"; /* Name of app, for window management */
This is the main Program control function for wmcalc. It This is the main Program control function for wmcalc. It
contains all the X11 windows function calls, as well as other contains all the X11 windows function calls, as well as other
general operations. general operations.
Change History: Change History:
Date Modification Date Modification
01/17/01 Updated to use XLookupString to get KeySym 01/17/01 Updated to use XLookupString to get KeySym
@ -94,7 +94,7 @@ char *app_name = "wmcalc"; /* Name of app, for window management */
****************************************************************/ ****************************************************************/
int main( int argc, char **argv ) { int main( int argc, char **argv ) {
XEvent report; XEvent report;
XGCValues xgcValues; XGCValues xgcValues;
XTextProperty app_name_atom; XTextProperty app_name_atom;
int err_code = OKAY; int err_code = OKAY;
int dummy = 0; int dummy = 0;
@ -106,7 +106,7 @@ int main( int argc, char **argv ) {
XComposeStatus compose; XComposeStatus compose;
char buffer[20]; char buffer[20];
int bufsize = 20; int bufsize = 20;
strcpy(configfile, getenv("HOME")); // Added to wmbutton by Casey Harkin, 3/6/99 strcpy(configfile, getenv("HOME")); // Added to wmbutton by Casey Harkin, 3/6/99
strcat(configfile, CONFFILENAME); // Fixed Bug - didn't look in home directory strcat(configfile, CONFFILENAME); // Fixed Bug - didn't look in home directory
@ -117,7 +117,7 @@ int main( int argc, char **argv ) {
for(i=0; i<DISPSIZE; i++) DispString[i] = ' '; for(i=0; i<DISPSIZE; i++) DispString[i] = ' ';
DispString[DISPSIZE] = '\0'; DispString[DISPSIZE] = '\0';
/* Parse Command Line Arguments */ /* Parse Command Line Arguments */
for ( i=1; i < argc; i++ ) { for ( i=1; i < argc; i++ ) {
if ( *argv[i] == '-' ) { if ( *argv[i] == '-' ) {
switch ( *(argv[i]+1) ) { switch ( *(argv[i]+1) ) {
@ -129,7 +129,7 @@ int main( int argc, char **argv ) {
sscanf(argv[i], "%s", Geometry_str); sscanf(argv[i], "%s", Geometry_str);
if ( Verbose ) printf("Geometry is: %s\n", Geometry_str); if ( Verbose ) printf("Geometry is: %s\n", Geometry_str);
break; break;
case 'd': // Set display case 'd': // Set display
if ( ++i >= argc ) show_usage(); if ( ++i >= argc ) show_usage();
sscanf(argv[i], "%s", Display_str); sscanf(argv[i], "%s", Display_str);
if ( Verbose ) printf("Display is: %s\n", Display_str); if ( Verbose ) printf("Display is: %s\n", Display_str);
@ -148,35 +148,35 @@ int main( int argc, char **argv ) {
} }
} }
} /* End of loop to process command line options */ } /* End of loop to process command line options */
/* Open display on requested X server */ /* Open display on requested X server */
if ( (display = XOpenDisplay(Display_str)) == NULL ) { if ( (display = XOpenDisplay(Display_str)) == NULL ) {
error_handler(ERR_X_DISPLAY, Display_str); error_handler(ERR_X_DISPLAY, Display_str);
} }
screen = DefaultScreen(display); screen = DefaultScreen(display);
rootwin = RootWindow(display,screen); rootwin = RootWindow(display,screen);
depth = DefaultDepth(display, screen); depth = DefaultDepth(display, screen);
bg_pixel = WhitePixel(display, screen ); bg_pixel = WhitePixel(display, screen );
fg_pixel = BlackPixel(display, screen ); fg_pixel = BlackPixel(display, screen );
xsizehints.flags = USSize | USPosition; xsizehints.flags = USSize | USPosition;
xsizehints.width = APP_WIDTH; xsizehints.width = APP_WIDTH;
xsizehints.height = APP_HEIGHT; xsizehints.height = APP_HEIGHT;
/* Parse Geometry string and fill in sizehints fields */ /* Parse Geometry string and fill in sizehints fields */
XWMGeometry(display, screen, XWMGeometry(display, screen,
Geometry_str, Geometry_str,
NULL, NULL,
border, border,
&xsizehints, &xsizehints,
&xsizehints.x, &xsizehints.x,
&xsizehints.y, &xsizehints.y,
&xsizehints.width, &xsizehints.width,
&xsizehints.height, &xsizehints.height,
&dummy); &dummy);
if ( (win = XCreateSimpleWindow(display, if ( (win = XCreateSimpleWindow(display,
rootwin, rootwin,
xsizehints.x, xsizehints.x,
@ -187,7 +187,7 @@ int main( int argc, char **argv ) {
fg_pixel, bg_pixel) ) == 0 ) { fg_pixel, bg_pixel) ) == 0 ) {
error_handler(ERR_X_CREATE_WINDOW, NULL); error_handler(ERR_X_CREATE_WINDOW, NULL);
} }
if ( (iconwin = XCreateSimpleWindow(display, if ( (iconwin = XCreateSimpleWindow(display,
win, win,
xsizehints.x, xsizehints.x,
@ -202,14 +202,14 @@ int main( int argc, char **argv ) {
/* Set up shaped windows */ /* Set up shaped windows */
/*Gives the appicon a border so you can grab and move it. */ /*Gives the appicon a border so you can grab and move it. */
if ( ( pixmask = XCreateBitmapFromData(display, if ( ( pixmask = XCreateBitmapFromData(display,
win, win,
mask_bits, mask_bits,
mask_width, mask_width,
mask_height) ) == 0 ) { mask_height) ) == 0 ) {
error_handler(ERR_X_CREATE_BITMAP, NULL); error_handler(ERR_X_CREATE_BITMAP, NULL);
} }
XShapeCombineMask(display, win, ShapeBounding, 0, 0, pixmask, ShapeSet ); XShapeCombineMask(display, win, ShapeBounding, 0, 0, pixmask, ShapeSet );
XShapeCombineMask(display, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet); XShapeCombineMask(display, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet);
@ -219,10 +219,10 @@ int main( int argc, char **argv ) {
/* Interclient Communication stuff */ /* Interclient Communication stuff */
/* Appicons don't work with out this stuff */ /* Appicons don't work with out this stuff */
xwmhints = XAllocWMHints(); xwmhints = XAllocWMHints();
xwmhints->flags = WindowGroupHint | IconWindowHint | StateHint; xwmhints->flags = WindowGroupHint | IconWindowHint | StateHint;
xwmhints->icon_window = iconwin; xwmhints->icon_window = iconwin;
xwmhints->window_group = win; xwmhints->window_group = win;
xwmhints->initial_state = WithdrawnState; xwmhints->initial_state = WithdrawnState;
XSetWMHints( display, win, xwmhints ); XSetWMHints( display, win, xwmhints );
xclasshint.res_name = app_name; xclasshint.res_name = app_name;
@ -230,15 +230,15 @@ int main( int argc, char **argv ) {
XSetClassHint( display, win, &xclasshint ); XSetClassHint( display, win, &xclasshint );
XSetWMNormalHints( display, win, &xsizehints ); XSetWMNormalHints( display, win, &xsizehints );
/* Tell window manager what the title bar name is. We never see */ /* Tell window manager what the title bar name is. We never see */
/* this anyways in the WithdrawnState */ /* this anyways in the WithdrawnState */
if ( XStringListToTextProperty(&app_name, 1, &app_name_atom) == 0 ) { if ( XStringListToTextProperty(&app_name, 1, &app_name_atom) == 0 ) {
error_handler(ERR_SETUP_WINDOW_NAME, app_name); error_handler(ERR_SETUP_WINDOW_NAME, app_name);
} }
XSetWMName( display, win, &app_name_atom ); XSetWMName( display, win, &app_name_atom );
/* Create Graphic Context */ /* Create Graphic Context */
if (( gc = XCreateGC(display, win,(GCForeground | GCBackground), &xgcValues)) if (( gc = XCreateGC(display, win,(GCForeground | GCBackground), &xgcValues))
== NULL ) { == NULL ) {
error_handler(ERR_CREATE_GC, NULL); error_handler(ERR_CREATE_GC, NULL);
@ -246,18 +246,8 @@ int main( int argc, char **argv ) {
/* XEvent Masks. We want both windows to process X events */ /* XEvent Masks. We want both windows to process X events */
XSelectInput(display, win, XSelectInput(display, win,
ExposureMask | ExposureMask |
ButtonPressMask | ButtonPressMask |
ButtonReleaseMask | /* added ButtonReleaseMask *charkins*/
PointerMotionMask |
FocusChangeMask |
LeaveWindowMask |
KeyPressMask | /* Try this to get keyboard working */
StructureNotifyMask |
EnterWindowMask );
XSelectInput(display, iconwin,
ExposureMask |
ButtonPressMask |
ButtonReleaseMask | /* added ButtonReleaseMask *charkins*/ ButtonReleaseMask | /* added ButtonReleaseMask *charkins*/
PointerMotionMask | PointerMotionMask |
FocusChangeMask | FocusChangeMask |
@ -265,9 +255,19 @@ int main( int argc, char **argv ) {
KeyPressMask | /* Try this to get keyboard working */ KeyPressMask | /* Try this to get keyboard working */
StructureNotifyMask | StructureNotifyMask |
EnterWindowMask ); EnterWindowMask );
XSelectInput(display, iconwin,
ExposureMask |
ButtonPressMask |
ButtonReleaseMask | /* added ButtonReleaseMask *charkins*/
PointerMotionMask |
FocusChangeMask |
LeaveWindowMask |
KeyPressMask | /* Try this to get keyboard working */
StructureNotifyMask |
EnterWindowMask );
/* Store the 'state' of the application for restarting */ /* Store the 'state' of the application for restarting */
XSetCommand( display, win, argv, argc ); XSetCommand( display, win, argv, argc );
/* Window won't ever show up until it is mapped.. then drawn after a */ /* Window won't ever show up until it is mapped.. then drawn after a */
/* ConfigureNotify */ /* ConfigureNotify */
@ -284,23 +284,23 @@ int main( int argc, char **argv ) {
XNextEvent(display, &report ); XNextEvent(display, &report );
switch (report.type) { switch (report.type) {
case Expose: case Expose:
if (report.xexpose.count != 0) { if (report.xexpose.count != 0) {
break; break;
} }
if ( Verbose ) printf("Event: Expose\n"); if ( Verbose ) printf("Event: Expose\n");
redraw(); redraw();
break; break;
case ConfigureNotify: case ConfigureNotify:
if ( Verbose ) printf("Event: ConfigureNotify\n"); if ( Verbose ) printf("Event: ConfigureNotify\n");
// redraw(); // redraw();
break; break;
case KeyPress: case KeyPress:
if (Verbose) printf("Event: Key state: 0x%x Key: 0x%x\n", if (Verbose) printf("Event: Key state: 0x%x Key: 0x%x\n",
report.xkey.state, report.xkey.keycode); report.xkey.state, report.xkey.keycode);
// ksym = XLookupKeysym(&(report.xkey), report.xkey.state); // ksym = XLookupKeysym(&(report.xkey), report.xkey.state);
/* KeywithMask - this allows Left, middle, and right button functions /* KeywithMask - this allows Left, middle, and right button functions
to be implemented via keyboard */ to be implemented via keyboard */
XLookupString(&(report.xkey), buffer, bufsize, &ksym, &compose); XLookupString(&(report.xkey), buffer, bufsize, &ksym, &compose);
if (Verbose) printf("Keysym is: 0x%x\n", (int) ksym); if (Verbose) printf("Keysym is: 0x%x\n", (int) ksym);
@ -308,7 +308,7 @@ int main( int argc, char **argv ) {
ExecFunc( KeywithMask ); ExecFunc( KeywithMask );
redraw(); redraw();
break; break;
case ButtonPress: /* draw button pressed, don't launch *charkins*/ case ButtonPress: /* draw button pressed, don't launch *charkins*/
switch (report.xbutton.button) { switch (report.xbutton.button) {
case Button1: case Button1:
@ -317,9 +317,9 @@ int main( int argc, char **argv ) {
button_pressed = N + LMASK; button_pressed = N + LMASK;
// redraw(); // redraw();
} }
if ( Verbose ) if ( Verbose )
printf("Button 1:x=%d y=%d N=%d\n", printf("Button 1:x=%d y=%d N=%d\n",
report.xbutton.x, report.xbutton.y, N+LMASK); report.xbutton.x, report.xbutton.y, N+LMASK);
break; break;
case Button2: case Button2:
if (mmouse) { if (mmouse) {
@ -328,8 +328,8 @@ int main( int argc, char **argv ) {
button_pressed = N + MMASK; button_pressed = N + MMASK;
// redraw(); // redraw();
} }
if ( Verbose ) if ( Verbose )
printf("Button 2:x=%d y=%d N=%d\n", printf("Button 2:x=%d y=%d N=%d\n",
report.xbutton.x, report.xbutton.y, N+MMASK); report.xbutton.x, report.xbutton.y, N+MMASK);
} }
break; break;
@ -339,8 +339,8 @@ int main( int argc, char **argv ) {
button_pressed = N + RMASK; button_pressed = N + RMASK;
// redraw(); // redraw();
} }
if ( Verbose ) if ( Verbose )
printf("Button 3:x=%d y=%d N=%d\n", printf("Button 3:x=%d y=%d N=%d\n",
report.xbutton.x, report.xbutton.y, N+RMASK); report.xbutton.x, report.xbutton.y, N+RMASK);
break; break;
} }
@ -353,9 +353,9 @@ int main( int argc, char **argv ) {
ExecFunc(N + LMASK); ExecFunc(N + LMASK);
button_pressed=-1; button_pressed=-1;
redraw(); redraw();
if ( Verbose ) if ( Verbose )
printf("Button 1:x=%d y=%d N=%d\n", printf("Button 1:x=%d y=%d N=%d\n",
report.xbutton.x, report.xbutton.y, N+LMASK); report.xbutton.x, report.xbutton.y, N+LMASK);
break; break;
case Button2: case Button2:
if (mmouse) { if (mmouse) {
@ -364,8 +364,8 @@ int main( int argc, char **argv ) {
ExecFunc( N + MMASK); ExecFunc( N + MMASK);
button_pressed=-1; button_pressed=-1;
redraw(); redraw();
if ( Verbose ) if ( Verbose )
printf("Button 2:x=%d y=%d N=%d\n", printf("Button 2:x=%d y=%d N=%d\n",
report.xbutton.x, report.xbutton.y, N+MMASK); report.xbutton.x, report.xbutton.y, N+MMASK);
} }
break; break;
@ -375,8 +375,8 @@ int main( int argc, char **argv ) {
ExecFunc( N + RMASK); ExecFunc( N + RMASK);
button_pressed=-1; button_pressed=-1;
redraw(); redraw();
if ( Verbose ) if ( Verbose )
printf("Button 3:x=%d y=%d N=%d\n", printf("Button 3:x=%d y=%d N=%d\n",
report.xbutton.x, report.xbutton.y, N+RMASK); report.xbutton.x, report.xbutton.y, N+RMASK);
break; break;
} }
@ -389,11 +389,11 @@ int main( int argc, char **argv ) {
XCloseDisplay(display); XCloseDisplay(display);
exit(OKAY); exit(OKAY);
break; break;
case EnterNotify: case EnterNotify:
case LeaveNotify: case LeaveNotify:
XSetInputFocus(display, PointerRoot, RevertToParent, CurrentTime); XSetInputFocus(display, PointerRoot, RevertToParent, CurrentTime);
if (Verbose) printf("Focus Change\n"); if (Verbose) printf("Focus Change\n");
break; break;
} }
} }
return (OKAY); return (OKAY);
@ -403,9 +403,9 @@ int main( int argc, char **argv ) {
* Function: redraw * Function: redraw
**************************************************************** ****************************************************************
Description: Description:
This function maintains the appearance of the application This function maintains the appearance of the application
by copying the "visible" pixmap to the two windows (the withdrawn by copying the "visible" pixmap to the two windows (the withdrawn
main window, and the icon window which is the main windows's icon main window, and the icon window which is the main windows's icon
image). image).
Change History: Change History:
@ -415,21 +415,21 @@ int main( int argc, char **argv ) {
void redraw() { void redraw() {
XCopyArea(display, template.pixmap, visible.pixmap, gc, 0, 0, XCopyArea(display, template.pixmap, visible.pixmap, gc, 0, 0,
template.attributes.width, template.attributes.height, 0, 0 ); template.attributes.width, template.attributes.height, 0, 0 );
defineButtonRegions(); defineButtonRegions();
/* Copy button to icon */ /* Copy button to icon */
XCopyArea(display, buttons.pixmap, visible.pixmap, gc, XCopyArea(display, buttons.pixmap, visible.pixmap, gc,
1, 1, 53, 40, 6, 20); 1, 1, 53, 40, 6, 20);
flush_expose( win ); flush_expose( win );
XCopyArea(display, visible.pixmap, win, gc, 0, 0, XCopyArea(display, visible.pixmap, win, gc, 0, 0,
visible.attributes.width, visible.attributes.height, 0, 0 ); visible.attributes.width, visible.attributes.height, 0, 0 );
flush_expose( iconwin ); flush_expose( iconwin );
XCopyArea(display, visible.pixmap, iconwin, gc, 0, 0, XCopyArea(display, visible.pixmap, iconwin, gc, 0, 0,
visible.attributes.width, visible.attributes.height, 0, 0 ); visible.attributes.width, visible.attributes.height, 0, 0 );
// if ( Verbose ) printf("In Redraw()\n"); // if ( Verbose ) printf("In Redraw()\n");
displaystr(); displaystr();
} /***** End of function redraw() ********************************/ } /***** End of function redraw() ********************************/
@ -439,10 +439,10 @@ void redraw() {
Description: Description:
Return the button at the x,y coordinates. The button need not Return the button at the x,y coordinates. The button need not
be visible ( drawn ). Return -1 if no button match. be visible ( drawn ). Return -1 if no button match.
Change History: Change History:
Date Modification Date Modification
11/1/00 Function Header Updated 11/1/00 Function Header Updated
****************************************************************/ ****************************************************************/
int whichButton( int x, int y ) { int whichButton( int x, int y ) {
int index; int index;
@ -468,7 +468,7 @@ int whichButton( int x, int y ) {
Change History: Change History:
Date Modification Date Modification
01/17/01 Updated to take a KeySym, rather than a KeyCode 01/17/01 Updated to take a KeySym, rather than a KeyCode
11/09/00 Original Function creation 11/09/00 Original Function creation
****************************************************************/ ****************************************************************/
int whichKey (KeySym keysym) { int whichKey (KeySym keysym) {
extern int Verbose; extern int Verbose;
@ -612,7 +612,7 @@ int whichKey (KeySym keysym) {
**************************************************************** ****************************************************************
Description: Description:
Load XPM data into X Pixmaps. Load XPM data into X Pixmaps.
* Pixmap 'template' contains the untouched window backdrop image. * Pixmap 'template' contains the untouched window backdrop image.
* Pixmap 'visible' is the template pixmap with buttons drawn on it. * Pixmap 'visible' is the template pixmap with buttons drawn on it.
-- what is seen by the user. -- what is seen by the user.
@ -630,31 +630,31 @@ void getPixmaps() {
visible.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions); visible.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);
buttons.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions); buttons.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);
charmap.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions); charmap.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);
/* Template Pixmap. Never Drawn To. */ /* Template Pixmap. Never Drawn To. */
if ( XpmCreatePixmapFromData( display, rootwin, backdrop_xpm, if ( XpmCreatePixmapFromData( display, rootwin, backdrop_xpm,
&template.pixmap, &template.mask, &template.pixmap, &template.mask,
&template.attributes) != XpmSuccess ) { &template.attributes) != XpmSuccess ) {
error_handler(ERR_CREATE_PIXMAP, "template"); error_handler(ERR_CREATE_PIXMAP, "template");
} }
/* Visible Pixmap. Copied from template Pixmap and then drawn to. */ /* Visible Pixmap. Copied from template Pixmap and then drawn to. */
if ( XpmCreatePixmapFromData( display, rootwin, backdrop_xpm, if ( XpmCreatePixmapFromData( display, rootwin, backdrop_xpm,
&visible.pixmap, &visible.mask, &visible.pixmap, &visible.mask,
&visible.attributes) != XpmSuccess ) { &visible.attributes) != XpmSuccess ) {
error_handler(ERR_CREATE_PIXMAP, "visible"); error_handler(ERR_CREATE_PIXMAP, "visible");
} }
/* Button Pixmap. */ /* Button Pixmap. */
if ( XpmCreatePixmapFromData( display, rootwin, calcbuttons_xpm, if ( XpmCreatePixmapFromData( display, rootwin, calcbuttons_xpm,
&buttons.pixmap, &buttons.mask, &buttons.pixmap, &buttons.mask,
&buttons.attributes) != XpmSuccess ) { &buttons.attributes) != XpmSuccess ) {
error_handler(ERR_CREATE_PIXMAP, "buttons"); error_handler(ERR_CREATE_PIXMAP, "buttons");
} }
/* Character Map Pixmap. */ /* Character Map Pixmap. */
if ( XpmCreatePixmapFromData( display, rootwin, charmap_xpm, if ( XpmCreatePixmapFromData( display, rootwin, charmap_xpm,
&charmap.pixmap, &charmap.mask, &charmap.pixmap, &charmap.mask,
&charmap.attributes) != XpmSuccess ) { &charmap.attributes) != XpmSuccess ) {
error_handler(ERR_CREATE_PIXMAP, "charmap"); error_handler(ERR_CREATE_PIXMAP, "charmap");
} }
@ -664,7 +664,7 @@ void getPixmaps() {
* Function: flush_expose * Function: flush_expose
**************************************************************** ****************************************************************
Description: Description:
This function is a hold-over from previous programs (wmcp). This function is a hold-over from previous programs (wmcp).
The use of this function is not well understood. The use of this function is not well understood.
Change History: Change History:
@ -674,7 +674,7 @@ void getPixmaps() {
int flush_expose(Window w) { int flush_expose(Window w) {
XEvent dummy; XEvent dummy;
int i=0; int i=0;
while (XCheckTypedWindowEvent(display, w, Expose, &dummy)) i++; while (XCheckTypedWindowEvent(display, w, Expose, &dummy)) i++;
return(i); return(i);
} /***** End of function flush_expose() *************************/ } /***** End of function flush_expose() *************************/
@ -684,10 +684,10 @@ int flush_expose(Window w) {
**************************************************************** ****************************************************************
Description: Description:
This function defines the start and end x and y coordinates for This function defines the start and end x and y coordinates for
the various buttons used in wmcalc. the various buttons used in wmcalc.
There should be a better way to do this, as right now, changing There should be a better way to do this, as right now, changing
the pixmap calcbuttons.xpm may require the modification of these the pixmap calcbuttons.xpm may require the modification of these
magic numbers. magic numbers.
Change History: Change History:
@ -745,7 +745,7 @@ void defineButtonRegions(void) {
**************************************************************** ****************************************************************
Description: Description:
This function displays individual characters to the "display". This function displays individual characters to the "display".
This function should only be called from displaystr(). This function should only be called from displaystr().
Change History: Change History:
Date Modification Date Modification
@ -761,26 +761,26 @@ void displaychar(char ch, int location) {
containing the character to containing the character to
display */ display */
locaty = 6; locaty = 6;
locatx = 2 + location * 6; locatx = 2 + location * 6;
/* If the character is a memory display character, use the memory /* If the character is a memory display character, use the memory
location display region. Valid Characters are: location display region. Valid Characters are:
'_' - No data in Memory Location '_' - No data in Memory Location
'=' - Value in Memory Location, Not Locked '=' - Value in Memory Location, Not Locked
'#' - Constant in Memory Location, Locked '#' - Constant in Memory Location, Locked
*/ */
if ((ch == '=') || (ch == '_') || ch == '#') { if ((ch == '=') || (ch == '_') || ch == '#') {
locaty = 15; locaty = 15;
} }
XCopyArea(display, charmap.pixmap, win, gc, XCopyArea(display, charmap.pixmap, win, gc,
dispchar.x, dispchar.y, dispchar.x, dispchar.y,
dispchar.i-dispchar.x, dispchar.j-dispchar.y, dispchar.i-dispchar.x, dispchar.j-dispchar.y,
locatx, locaty); locatx, locaty);
XCopyArea(display, charmap.pixmap, iconwin, gc, XCopyArea(display, charmap.pixmap, iconwin, gc,
dispchar.x, dispchar.y, dispchar.x, dispchar.y,
dispchar.i-dispchar.x, dispchar.j-dispchar.y, dispchar.i-dispchar.x, dispchar.j-dispchar.y,
locatx, locaty); locatx, locaty);
} /***** End of Function displaychar() **************************/ } /***** End of Function displaychar() **************************/
@ -789,7 +789,7 @@ void displaychar(char ch, int location) {
* Function: displaystr * Function: displaystr
**************************************************************** ****************************************************************
Description: Description:
Change History: Change History:
Date Modification Date Modification
11/09/00 Added Capabilities for "Locked" memories 11/09/00 Added Capabilities for "Locked" memories
@ -813,7 +813,7 @@ void displaystr(void) {
for (i = 0; i < NUM_MEM_CELLS; i++) { for (i = 0; i < NUM_MEM_CELLS; i++) {
if (MemArray[i] == 0.0) if (MemArray[i] == 0.0)
displaychar('_', i); /* Value NOT stored here */ displaychar('_', i); /* Value NOT stored here */
else if (MemLock[i] == 0) else if (MemLock[i] == 0)
displaychar('=', i); /* Value IS stored here */ displaychar('=', i); /* Value IS stored here */
else else
displaychar('#', i); /* Constant IS stored here */ displaychar('#', i); /* Constant IS stored here */
@ -826,7 +826,7 @@ void displaystr(void) {
* Function: show_usage * Function: show_usage
**************************************************************** ****************************************************************
Description: Description:
This function prints a brief usage message to stdout, This function prints a brief usage message to stdout,
and exits. and exits.
Change History: Change History:
@ -842,7 +842,7 @@ void show_usage(void) {
app_name); app_name);
printf("\n"); printf("\n");
printf("-g <geometry> Window Geometry - ie: 64x64+10+10\n"); printf("-g <geometry> Window Geometry - ie: 64x64+10+10\n");
printf("-d <display> Display - ie: 127.0.0.1:0.0\n"); printf("-d <display> Display - ie: 127.0.0.1:0.0\n");
printf("-f <filename> Name of Config file - ie: /home/user/.wmcalc\n"); printf("-f <filename> Name of Config file - ie: /home/user/.wmcalc\n");
printf("-v Verbose Mode. \n"); printf("-v Verbose Mode. \n");
printf("-h Help. This message.\n"); printf("-h Help. This message.\n");
@ -865,8 +865,8 @@ void error_handler (int err_code, char *err_string) {
extern char tempfile[]; extern char tempfile[];
if (err_code == OKAY) { if (err_code == OKAY) {
/* This case should never happen. /* This case should never happen.
If it does, somebody screwed up (probably me), If it does, somebody screwed up (probably me),
but don't kill the program!! */ but don't kill the program!! */
return; return;
} }
@ -878,9 +878,9 @@ void error_handler (int err_code, char *err_string) {
break; break;
case ERR_TMP_FILE_FAILED: case ERR_TMP_FILE_FAILED:
fprintf(stderr, "Could not open temporary file %s\n", tempfile); fprintf(stderr, "Could not open temporary file %s\n", tempfile);
break; break;
case ERR_X_CREATE_WINDOW: case ERR_X_CREATE_WINDOW:
fprintf(stderr, "Could not create simple window\n"); fprintf(stderr, "Could not create simple window\n");
break; break;
case ERR_X_CREATE_BITMAP: case ERR_X_CREATE_BITMAP:
fprintf(stderr, "Could not create bitmap from data\n"); fprintf(stderr, "Could not create bitmap from data\n");

View file

@ -1,13 +1,13 @@
# wmcalc Configuration File # wmcalc Configuration File
# Last Manual Update: 10/29/00 # Last Manual Update: 10/29/00
# General Notes: # General Notes:
# * There must be a tab character '\t' between the variable name and # * There must be a tab character '\t' between the variable name and
# the value, not a series of spaces. # the value, not a series of spaces.
# * wmcalc is case sensitive when reading these variables. Examine the # * wmcalc is case sensitive when reading these variables. Examine the
# wmcalc_g.h file for currently defined variables. # wmcalc_g.h file for currently defined variables.
#Calculator Memory Locations #Calculator Memory Locations
#Note: These must all exist, though they may be in any order #Note: These must all exist, though they may be in any order
Mem0 0.000000 Mem0 0.000000
Mem1 0.000000 Mem1 0.000000
@ -21,15 +21,15 @@ Mem8 0.000000
Mem9 0.000000 Mem9 0.000000
# The CalcStart variable is intended to allow the user to start a larger # The CalcStart variable is intended to allow the user to start a larger
# calculator for more complicated needs. Everything after the tab '\t' # calculator for more complicated needs. Everything after the tab '\t'
# character is sent unmodified in a system() call, so anything you can type # character is sent unmodified in a system() call, so anything you can type
# at the command prompt may be put here. # at the command prompt may be put here.
#CalcStart xterm -T "Basic Calculator" -e bc & #CalcStart xterm -T "Basic Calculator" -e bc &
#CalcStart xterm -T "gnuplot" -sb -sl 500 -e gnuplot & #CalcStart xterm -T "gnuplot" -sb -sl 500 -e gnuplot &
CalcStart xcalc & CalcStart xcalc &
# The ImagChar variable allows the user to choose between 'i' and 'j' to # The ImagChar variable allows the user to choose between 'i' and 'j' to
# represent the sqrt(-1). (Electrical Engineers (such as myself) use 'j' # represent the sqrt(-1). (Electrical Engineers (such as myself) use 'j'
# rather than 'i.') # rather than 'i.')
#ImagChar i #ImagChar i
ImagChar j ImagChar j

View file

@ -3,7 +3,7 @@
* Version: 0.2 * Version: 0.2
* *
* Description: * Description:
* This file contains the constants settings for the wmcalc program, * This file contains the constants settings for the wmcalc program,
* except for the error constants, which are contained in the file wmcalc_err.h * except for the error constants, which are contained in the file wmcalc_err.h
* *
* Change History: * Change History:

View file

@ -10,7 +10,7 @@
* Date Modification * Date Modification
* 01/17/01 Updated whichKey() function to take a KeySym * 01/17/01 Updated whichKey() function to take a KeySym
* 11/09/00 Removed function clrmem() as this was merged into clrallmem() * 11/09/00 Removed function clrmem() as this was merged into clrallmem()
* Also add function whichKey, in wmcalc.c to handle Keyboard * Also add function whichKey, in wmcalc.c to handle Keyboard
* events * events
* 10/25/00 Original file creation, extracted from wmcalc.h * 10/25/00 Original file creation, extracted from wmcalc.h
*/ */
@ -23,7 +23,7 @@
#include "wmcalc_t.h" #include "wmcalc_t.h"
void ExecFunc(int val); // function to run app N as found in conf file void ExecFunc(int val); // function to run app N as found in conf file
void redraw(void); void redraw(void);
void getPixmaps(void); void getPixmaps(void);
int whichButton(int x, int y); // determine which button has been pressed int whichButton(int x, int y); // determine which button has been pressed
int whichKey(KeySym keysym); // determine which key has been pressed int whichKey(KeySym keysym); // determine which key has been pressed

View file

@ -30,7 +30,7 @@ Pixel bg_pixel, fg_pixel;
XSizeHints xsizehints; XSizeHints xsizehints;
XWMHints *xwmhints; XWMHints *xwmhints;
XClassHint xclasshint; XClassHint xclasshint;
char configfile[CONFIGFILEMAX]; char configfile[CONFIGFILEMAX];
char tempfile[CONFIGFILEMAX]; char tempfile[CONFIGFILEMAX];
Pixmap pixmask; Pixmap pixmask;

View file

@ -51,4 +51,4 @@ typedef enum {
} cfg_var_label_type; } cfg_var_label_type;
#endif #endif

View file

@ -3,20 +3,20 @@
* Version: 0.3 * Version: 0.3
* Author: Edward H. Flora <ehflora@access1.net> * Author: Edward H. Flora <ehflora@access1.net>
* *
* This file is a part of the wmcalc application. As such, this * This file is a part of the wmcalc application. As such, this
* file is licensed under the GNU General Public License, version 2. * file is licensed under the GNU General Public License, version 2.
* A copy of this license may be found in the file COPYING that should * A copy of this license may be found in the file COPYING that should
* have been distributed with this file. If not, please refer to * have been distributed with this file. If not, please refer to
* http://www.gnu.org/copyleft/gpl.html for details. * http://www.gnu.org/copyleft/gpl.html for details.
* *
**************************************************************** ****************************************************************
Description: Description:
This file includes the X libraries. This file includes the X libraries.
Change History: Change History:
Date Modification Date Modification
12/10/00 Original File Creation, from Peter da Silva <peter@taronga.com> 12/10/00 Original File Creation, from Peter da Silva <peter@taronga.com>
****************************************************************/ ****************************************************************/
#ifndef WMCALC_X_H #ifndef WMCALC_X_H
#define WMCALC_X_H #define WMCALC_X_H

View file

@ -3,21 +3,21 @@
* Version: 0.21 * Version: 0.21
* Author: Edward H. Flora <ehflora@access1.net> * Author: Edward H. Flora <ehflora@access1.net>
* *
* This file is a part of the wmcalc application. As such, this * This file is a part of the wmcalc application. As such, this
* file is licensed under the GNU General Public License, version 2. * file is licensed under the GNU General Public License, version 2.
* A copy of this license may be found in the file COPYING that should * A copy of this license may be found in the file COPYING that should
* have been distributed with this file. If not, please refer to * have been distributed with this file. If not, please refer to
* http://www.gnu.org/copyleft/gpl.html for details. * http://www.gnu.org/copyleft/gpl.html for details.
* *
**************************************************************** ****************************************************************
Description: Description:
This file contains the code for the actual calculator functions, This file contains the code for the actual calculator functions,
such as a add, subt, clear, etc. such as a add, subt, clear, etc.
Change History: Change History:
Date Modification Date Modification
11/03/00 File Header added 11/03/00 File Header added
****************************************************************/ ****************************************************************/
/***** Includes *************************************************/ /***** Includes *************************************************/
@ -70,7 +70,7 @@ void clearcalc(void) {
**************************************************************** ****************************************************************
Description: Description:
Clears the current number being entered. Clears the current number being entered.
Change History: Change History:
Date Modification Date Modification
11/03/00 Updated function header 11/03/00 Updated function header
@ -101,7 +101,7 @@ void clearnum(void) {
**************************************************************** ****************************************************************
Description: Description:
Add characters to the number being entered. Add characters to the number being entered.
Change History: Change History:
Date Modification Date Modification
11/03/00 Updated function header 11/03/00 Updated function header
@ -119,7 +119,7 @@ void charkey(char ch) {
if (StrCnt < DISPSIZE) { if (StrCnt < DISPSIZE) {
if (ch == '.') { if (ch == '.') {
if (DecFlag == 0) { if (DecFlag == 0) {
for (i = 1; i < DISPSIZE; i++) for (i = 1; i < DISPSIZE; i++)
DispString[i-1] = DispString[i]; DispString[i-1] = DispString[i];
DecFlag = 1; DecFlag = 1;
@ -160,7 +160,7 @@ void charkey(char ch) {
**************************************************************** ****************************************************************
Description: Description:
Change the sign of the number currently being entered Change the sign of the number currently being entered
Change History: Change History:
Date Modification Date Modification
11/03/00 Updated Function header 11/03/00 Updated Function header
@ -250,7 +250,7 @@ void sqrtnum(void) {
Add the number in Registers A to Register B. Add the number in Registers A to Register B.
Change History: Change History:
Date Modification Date Modification
11/03/00 Updated Function header 11/03/00 Updated Function header
****************************************************************/ ****************************************************************/
void addnums(void) { void addnums(void) {
extern int Verbose; extern int Verbose;
@ -363,10 +363,10 @@ void divnums(void) {
} /* End of Function divnums() ********************************/ } /* End of Function divnums() ********************************/
/**************************************************************** /****************************************************************
* Function: * Function:
**************************************************************** ****************************************************************
Description: Description:
Calculate result of entered calculation. Calculate result of entered calculation.
Change History: Change History:
Date Modification Date Modification
11/04/00 Updated Function Header 11/04/00 Updated Function Header
@ -439,8 +439,8 @@ void clrallmem(void) {
* Function: stormem * Function: stormem
**************************************************************** ****************************************************************
Description: Description:
Store value to memory cell #N Store value to memory cell #N
Change History: Change History:
Date Modification Date Modification
11/04/00 Updated function header 11/04/00 Updated function header
@ -461,11 +461,11 @@ void stormem(int mem_loc) {
write_config(); write_config();
} }
else { else {
if (Verbose) printf("Memory location %d Locked at %f\n", if (Verbose) printf("Memory location %d Locked at %f\n",
mem_loc, MemArray[mem_loc]); mem_loc, MemArray[mem_loc]);
} }
if (Verbose) { if (Verbose) {
for (i = 0; i < NUM_MEM_CELLS; i++) for (i = 0; i < NUM_MEM_CELLS; i++)
printf(" %f ", MemArray[i]); printf(" %f ", MemArray[i]);
printf("\n"); printf("\n");
@ -478,7 +478,7 @@ void stormem(int mem_loc) {
* Function: recallmem * Function: recallmem
**************************************************************** ****************************************************************
Description: Description:
Store value to memory cell #N Store value to memory cell #N
Change History: Change History:
Date Modification Date Modification
11/04/00 Updated function header 11/04/00 Updated function header
@ -497,7 +497,7 @@ void recallmem(int mem_loc) {
sprintf(DispString, "%10.5g", RegisterA); sprintf(DispString, "%10.5g", RegisterA);
if (Verbose) { if (Verbose) {
for (i = 0; i < NUM_MEM_CELLS; i++) for (i = 0; i < NUM_MEM_CELLS; i++)
printf(" %f ", MemArray[i]); printf(" %f ", MemArray[i]);
printf("\n"); printf("\n");
@ -509,7 +509,7 @@ void recallmem(int mem_loc) {
* Function: startcalc * Function: startcalc
**************************************************************** ****************************************************************
Description: Description:
Change the sign of the number currently being entered Change the sign of the number currently being entered
Change History: Change History:
Date Modification Date Modification
11/04/00 Updated function header 11/04/00 Updated function header
@ -518,7 +518,7 @@ void startcalc(void) {
extern int Verbose; extern int Verbose;
extern char SysCalcCmd[]; extern char SysCalcCmd[];
if (Verbose) if (Verbose)
fprintf(stderr, "Starting external calculator %s\n", SysCalcCmd); fprintf(stderr, "Starting external calculator %s\n", SysCalcCmd);
if (system(SysCalcCmd) == -1) if (system(SysCalcCmd) == -1)

View file

@ -4,16 +4,16 @@
* Date: November 1, 2000 * Date: November 1, 2000
* Author: Edward H. Flora <ehflora@access1.net> * Author: Edward H. Flora <ehflora@access1.net>
* *
* This file is a part of the wmcalc application. As such, this * This file is a part of the wmcalc application. As such, this
* file is licensed under the GNU General Public License, version 2. * file is licensed under the GNU General Public License, version 2.
* A copy of this license may be found in the file COPYING that should * A copy of this license may be found in the file COPYING that should
* have been distributed with this file. If not, please refer to * have been distributed with this file. If not, please refer to
* http://www.gnu.org/copyleft/gpl.html for details. * http://www.gnu.org/copyleft/gpl.html for details.
* *
**************************************************************** ****************************************************************
Description: Description:
This file contains system level functions, such as read/write of This file contains system level functions, such as read/write of
the config file, character map boundaries, etc. the config file, character map boundaries, etc.
Change History: Change History:
Date Modification Date Modification
@ -256,8 +256,8 @@ void ExecFunc( int val ) {
* Function: getboundaries * Function: getboundaries
**************************************************************** ****************************************************************
Description: Description:
This function returns the x,y boundaries for each character This function returns the x,y boundaries for each character
that is to be displayed on the display. that is to be displayed on the display.
There must be a better way to do this, as by changing the file There must be a better way to do this, as by changing the file
charmap.xpm, one may have to adjust these constants. charmap.xpm, one may have to adjust these constants.
@ -379,7 +379,7 @@ ButtonArea getboundaries(char ch) {
This function updates the configuration file as memory locations This function updates the configuration file as memory locations
are updated in the program. It re-writes the entire file, but are updated in the program. It re-writes the entire file, but
should ignore all lines that do not start with "Mem". should ignore all lines that do not start with "Mem".
Change History: Change History:
Date Modification Date Modification
11/01/00 Function Header updated 11/01/00 Function Header updated
@ -406,7 +406,7 @@ int write_config(void) {
/* We cannot write to the global config-file... */ /* We cannot write to the global config-file... */
if(!strcmp(configfile, CONFIGGLOBAL)) { if(!strcmp(configfile, CONFIGGLOBAL)) {
strcpy(configfile, getenv("HOME")); // Added to wmbutton by Gordon Fraser, 9/21/01 strcpy(configfile, getenv("HOME")); // Added to wmbutton by Gordon Fraser, 9/21/01
strcat(configfile, CONFFILENAME); strcat(configfile, CONFFILENAME);
} }
/* Open Temporary File */ /* Open Temporary File */
@ -423,7 +423,7 @@ int write_config(void) {
while ((line = readln(fp)) != NULL) { // Read Lines in config file while ((line = readln(fp)) != NULL) { // Read Lines in config file
if (Verbose) printf("line:%s", line); if (Verbose) printf("line:%s", line);
if ((strncmp(line, CfgVarList[MEM_LABEL_0], if ((strncmp(line, CfgVarList[MEM_LABEL_0],
strlen(CfgVarList[MEM_LABEL_0]) - 1) == 0)) { strlen(CfgVarList[MEM_LABEL_0]) - 1) == 0)) {
// -1 to generalize to all Mem? strings // -1 to generalize to all Mem? strings
// If we've found a memory entry // If we've found a memory entry
@ -445,9 +445,9 @@ int write_config(void) {
/* Copy temp file over original */ /* Copy temp file over original */
/* Note: If changing command, make sure to adjust size of string above!! */ /* Note: If changing command, make sure to adjust size of string above!! */
sprintf(movefilecmd, "mv -f %s %s\n", tempfile, configfile); sprintf(movefilecmd, "mv -f %s %s\n", tempfile, configfile);
err_code = system(movefilecmd); err_code = system(movefilecmd);
if(Verbose) printf("New config file written.\n"); if(Verbose) printf("New config file written.\n");
return(err_code); return(err_code);
@ -461,7 +461,7 @@ int write_config(void) {
This function reads the configuration file on program startup, This function reads the configuration file on program startup,
and sets the appropriate configuration options. and sets the appropriate configuration options.
(By default, this is ~/.wmcalc, or a user set value) (By default, this is ~/.wmcalc, or a user set value)
Change History: Change History:
Date Modification Date Modification
11/01/00 Function header updated. 11/01/00 Function header updated.
@ -500,10 +500,10 @@ int read_config(void) {
line = readln(fp); line = readln(fp);
if (Verbose) printf("Line Read:%s\n", line); if (Verbose) printf("Line Read:%s\n", line);
if (line == NULL) break; // if end of file, quit if (line == NULL) break; // if end of file, quit
if ( (line[0] != '#') && (line[0] != '\n')) { /* Ignore comments and if ( (line[0] != '#') && (line[0] != '\n')) { /* Ignore comments and
blanks */ blanks */
if (strchr(line, sep_ch) != NULL) { /* The line has a tab, so let's if (strchr(line, sep_ch) != NULL) { /* The line has a tab, so let's
see if the variable is see if the variable is
understood */ understood */
i = 0; i = 0;
/* Loop while we haven't found the variable */ /* Loop while we haven't found the variable */
@ -514,7 +514,7 @@ int read_config(void) {
/* If we've found the variable, let's set the appropriate value */ /* If we've found the variable, let's set the appropriate value */
if (i <= MAX_LABEL) { if (i <= MAX_LABEL) {
if (Verbose) printf("Variable %s found\n", CfgVarList[i]); if (Verbose) printf("Variable %s found\n", CfgVarList[i]);
/* Point to the 'tab' character, to read the value */ /* Point to the 'tab' character, to read the value */
cfg_var_ptr = strchr(line, sep_ch); cfg_var_ptr = strchr(line, sep_ch);
cfg_var_ptr++; // ++ to avoid tab character itself cfg_var_ptr++; // ++ to avoid tab character itself
@ -535,7 +535,7 @@ int read_config(void) {
MemLock[i] = 0; MemLock[i] = 0;
/* Set Memory Element */ /* Set Memory Element */
MemArray[i] = atof(cfg_var_ptr); MemArray[i] = atof(cfg_var_ptr);
if (Verbose) if (Verbose)
printf("Assign Memory Element %d to %f\n", i, MemArray[i]); printf("Assign Memory Element %d to %f\n", i, MemArray[i]);
break; break;
@ -553,18 +553,18 @@ int read_config(void) {
MemLock[i - MEM_LOCK_0] = 1; MemLock[i - MEM_LOCK_0] = 1;
/* Set Memory Element */ /* Set Memory Element */
MemArray[i - MEM_LOCK_0] = atof(cfg_var_ptr); MemArray[i - MEM_LOCK_0] = atof(cfg_var_ptr);
if (Verbose) if (Verbose)
printf("Assign Memory Element %d to %f\n", i - printf("Assign Memory Element %d to %f\n", i -
MEM_LOCK_0, MemArray[i - MEM_LOCK_0]); MEM_LOCK_0, MemArray[i - MEM_LOCK_0]);
break; break;
case IMAG_LABEL: case IMAG_LABEL:
/* Get the character that the user wishes to use to /* Get the character that the user wishes to use to
represent sqrt(-1) (i or j) */ represent sqrt(-1) (i or j) */
if ((cfg_var_ptr[0] == 'i') || cfg_var_ptr[0] == 'j') { if ((cfg_var_ptr[0] == 'i') || cfg_var_ptr[0] == 'j') {
ImagChar = cfg_var_ptr[0]; ImagChar = cfg_var_ptr[0];
} }
if (Verbose) if (Verbose)
printf("Use character '%c' to represent sqrt(-1)\n", ImagChar); printf("Use character '%c' to represent sqrt(-1)\n", ImagChar);
break; break;