added cdk to deps and building fileapprove

This commit is contained in:
Andrew Pamment 2017-03-20 21:40:32 +10:00
parent 071df70e4c
commit 71858e4583
265 changed files with 99585 additions and 18 deletions

View File

@ -7,7 +7,7 @@ LUA = deps/lua/liblua.a
ODOORS = deps/odoors/libs-`uname -s`/libODoors.a
JSMN = deps/jsmn/libjsmn.a
all: magicka magimail magiedit ticproc mgpost magichat
all: magicka magimail magiedit ticproc mgpost magichat fileapprove
${LUA}:
cd deps/lua && $(MAKE) -f Makefile freebsd MAKEFLAGS=
@ -24,6 +24,10 @@ ${ODOORS}:
$(JSMN):
cd deps/jsmn/ && $(MAKE)
$(CDK):
cd deps/cdk-5.0-20161210/ && ./configure
cd deps/cdk-5.0-20161210/ && $(MAKE)
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
@ -46,6 +50,9 @@ magichat: $(JSMN)
mgpost: $(JAMLIB)
cd utils/mgpost && $(MAKE)
fileapprove: $(CDK)
cd utils/fileapprove && $(MAKE)
.PHONY: clean
clean:
@ -58,4 +65,6 @@ clean:
cd deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s`
cd utils/ticproc && $(MAKE) clean
cd utils/mgpost && $(MAKE) clean
cd utils/magichat && $(MAKE) clean
cd utils/magichat && $(MAKE) clean
cd deps/cdk-5.0-20161210 && $(MAKE) clean
cd utils/fileapprove && $(MAKE) clean

View File

@ -9,7 +9,7 @@ MICROHTTPD=-lmicrohttpd
ODOORS = deps/odoors/libs-`uname -s`/libODoors.a
JSMN = deps/jsmn/libjsmn.a
all: magicka magimail magiedit ticproc mgpost magichat
all: magicka magimail magiedit ticproc mgpost magichat fileapprove
${LUA}:
cd deps/lua && $(MAKE) -f Makefile freebsd MAKEFLAGS=
@ -29,6 +29,10 @@ ${ODOORS}:
$(JSMN):
cd deps/jsmn/ && $(MAKE)
$(CDK):
cd deps/cdk-5.0-20161210/ && ./configure
cd deps/cdk-5.0-20161210/ && $(MAKE)
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o hashmap/hashmap.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
@ -51,6 +55,9 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd utils/magichat && $(MAKE)
fileapprove: $(CDK)
cd utils/fileapprove && $(MAKE)
.PHONY: clean
clean:
@ -64,4 +71,6 @@ clean:
cd deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s`
cd utils/ticproc && $(MAKE) clean
cd utils/mgpost && $(MAKE) clean
cd utils/magichat && $(MAKE) clean
cd utils/magichat && $(MAKE) clean
cd deps/cdk-5.0-20161210 && $(MAKE) clean
cd utils/fileapprove && $(MAKE) clean

View File

@ -6,8 +6,9 @@ ZMODEM = deps/Xmodem/libzmodem.a
LUA = deps/lua/liblua.a
ODOORS = deps/odoors/libs-`uname -s`/libODoors.a
JSMN = deps/jsmn/libjsmn.a
CDK = deps/cdk-5-20161210/libcdk.a
all: magicka magimail magiedit ticproc mgpost magichat
all: magicka magimail magiedit ticproc mgpost magichat fileapprove
${LUA}:
cd deps/lua && $(MAKE) -f Makefile linux MAKEFLAGS=
@ -24,6 +25,11 @@ ${ODOORS}:
$(JSMN):
cd deps/jsmn/ && $(MAKE)
$(CDK):
cd deps/cdk-5.0-20161210/ && ./configure
cd deps/cdk-5.0-20161210/ && $(MAKE)
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
@ -46,6 +52,9 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd utils/magichat && $(MAKE)
fileapprove: $(CDK)
cd utils/fileapprove && $(MAKE)
.PHONY: clean
clean:
@ -58,4 +67,6 @@ clean:
cd deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s`
cd utils/ticproc && $(MAKE) clean
cd utils/mgpost && $(MAKE) clean
cd utils/magichat && $(MAKE) clean
cd utils/magichat && $(MAKE) clean
cd deps/cdk-5.0-20161210 && $(MAKE) clean
cd utils/fileapprove && $(MAKE) clean

View File

@ -9,7 +9,7 @@ MICROHTTPD=-lmicrohttpd
ODOORS = deps/odoors/libs-`uname -s`/libODoors.a
JSMN = deps/jsmn/libjsmn.a
all: magicka magimail magiedit ticproc mgpost magichat
all: magicka magimail magiedit ticproc mgpost magichat fileapprove
${LUA}:
cd deps/lua && $(MAKE) -f Makefile linux MAKEFLAGS=
@ -29,6 +29,10 @@ ${ODOORS}:
$(JSMN):
cd deps/jsmn/ && $(MAKE)
$(CDK):
cd deps/cdk-5.0-20161210/ && ./configure
cd deps/cdk-5.0-20161210/ && $(MAKE)
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o bluewave.o hashmap/hashmap.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
@ -51,6 +55,9 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd utils/magichat && $(MAKE)
fileapprove: $(CDK)
cd utils/fileapprove && $(MAKE)
.PHONY: clean
clean:
@ -64,4 +71,6 @@ clean:
cd deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s`
cd utils/ticproc && $(MAKE) clean
cd utils/mgpost && $(MAKE) clean
cd utils/magichat && $(MAKE) clean
cd utils/magichat && $(MAKE) clean
cd deps/cdk-5.0-20161210 && $(MAKE) clean
cd utils/fileapprove && $(MAKE) clean

View File

@ -7,7 +7,7 @@ LUA = deps/lua/liblua.a
ODOORS = deps/odoors/libs-`uname -s`/libODoors.a
JSMN = deps/jsmn/libjsmn.a
all: magicka magimail magiedit ticproc mgpost magichat
all: magicka magimail magiedit ticproc mgpost magichat fileapprove
${LUA}:
cd deps/lua && $(MAKE) -f Makefile bsd MAKEFLAGS=
@ -24,6 +24,10 @@ ${ODOORS}:
$(JSMN):
cd deps/jsmn/ && $(MAKE)
$(CDK):
cd deps/cdk-5.0-20161210/ && ./configure
cd deps/cdk-5.0-20161210/ && $(MAKE)
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
@ -46,6 +50,9 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd utils/magichat && $(MAKE)
fileapprove: $(CDK)
cd utils/fileapprove && $(MAKE)
.PHONY: clean
clean:
@ -58,4 +65,6 @@ clean:
cd deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s`
cd utils/ticproc && $(MAKE) clean
cd utils/mgpost && $(MAKE) clean
cd utils/magichat && $(MAKE) clean
cd utils/magichat && $(MAKE) clean
cd deps/cdk-5.0-20161210 && $(MAKE) clean
cd utils/fileapprove && $(MAKE) clean

View File

@ -9,7 +9,7 @@ MICROHTTPD=-lmicrohttpd
ODOORS = deps/odoors/libs-`uname -s`/libODoors.a
JSMN = deps/jsmn/libjsmn.a
all: magicka magimail magiedit ticproc mgpost magichat
all: magicka magimail magiedit ticproc mgpost magichat fileapprove
${LUA}:
cd deps/lua && $(MAKE) -f Makefile bsd MAKEFLAGS=
@ -29,6 +29,10 @@ ${ODOORS}:
$(JSMN):
cd deps/jsmn/ && $(MAKE)
$(CDK):
cd deps/cdk-5.0-20161210/ && ./configure
cd deps/cdk-5.0-20161210/ && $(MAKE)
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o hashmap/hashmap.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
@ -51,6 +55,9 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd utils/magichat && $(MAKE)
fileapprove: $(CDK)
cd utils/fileapprove && $(MAKE)
.PHONY: clean
clean:
@ -64,4 +71,6 @@ clean:
cd deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s`
cd utils/ticproc && $(MAKE) clean
cd utils/mgpost && $(MAKE) clean
cd utils/magichat && $(MAKE) clean
cd utils/magichat && $(MAKE) clean
cd deps/cdk-5.0-20161210 && $(MAKE) clean
cd utils/fileapprove && $(MAKE) clean

View File

@ -9,7 +9,7 @@ JSMN = deps/jsmn/libjsmn.a
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o
all: magicka magimail magiedit ticproc mgpost magichat
all: magicka magimail magiedit ticproc mgpost magichat fileapprove
${LUA}:
cd deps/lua && $(MAKE) -f Makefile macosx MAKEFLAGS=
@ -26,6 +26,10 @@ ${ODOORS}:
$(JSMN):
cd deps/jsmn/ && $(MAKE)
$(CDK):
cd deps/cdk-5.0-20161210/ && ./configure
cd deps/cdk-5.0-20161210/ && $(MAKE)
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
@ -47,6 +51,9 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd utils/magichat && $(MAKE)
fileapprove: $(CDK)
cd utils/fileapprove && $(MAKE)
.PHONY: clean
clean:
@ -59,4 +66,6 @@ clean:
cd deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s`
cd utils/ticproc && $(MAKE) clean
cd utils/mgpost && $(MAKE) clean
cd utils/magichat && $(MAKE) clean
cd utils/magichat && $(MAKE) clean
cd deps/cdk-5.0-20161210 && $(MAKE) clean
cd utils/fileapprove && $(MAKE) clean

View File

@ -9,7 +9,7 @@ MICROHTTPD=-lmicrohttpd
ODOORS = deps/odoors/libs-`uname -s`/libODoors.a
JSMN = deps/jsmn/libjsmn.a
all: magicka magimail magiedit ticproc mgpost magichat
all: magicka magimail magiedit ticproc mgpost magichat fileapprove
${LUA}:
cd deps/lua && $(MAKE) -f Makefile macosx MAKEFLAGS=
@ -29,6 +29,10 @@ ${ODOORS}:
$(JSMN):
cd deps/jsmn/ && $(MAKE)
$(CDK):
cd deps/cdk-5.0-20161210/ && ./configure
cd deps/cdk-5.0-20161210/ && $(MAKE)
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o bluewave.o hashmap/hashmap.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
@ -51,6 +55,9 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd utils/magichat && $(MAKE)
fileapprove: $(CDK)
cd utils/fileapprove && $(MAKE)
.PHONY: clean
clean:
@ -63,4 +70,6 @@ clean:
cd deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s`
cd utils/ticproc && $(MAKE) clean
cd utils/mgpost && $(MAKE) clean
cd utils/magichat && $(MAKE) clean
cd utils/magichat && $(MAKE) clean
cd deps/cdk-5.0-20161210 && $(MAKE) clean
cd utils/fileapprove && $(MAKE) clean

1388
deps/cdk-5.0-20161210/CHANGES vendored Normal file

File diff suppressed because it is too large Load Diff

92
deps/cdk-5.0-20161210/COPYING vendored Normal file
View File

@ -0,0 +1,92 @@
Modifications copyright Thomas Dickey 1999-2015,2016
The software and documentation are still under the same licensing are the
original Cdk, but noting that substantial work and enhancements have been made,
I've added my name as needed -TD
The original COPYING file follows (with corrections as noted in CHANGES).
-------------------------------------------------------------------------------
Cdk Copying Guide
Copyright Mike Glover, 1995, 1996, 1997, 1998, 1999
-------------------------------------------------------------------------------
In order to copy Cdk around I have some requirements that will protect me,
and possibly even you. First thing, I feel I should say that this little project
of mine has taken quite a bit 'free' time and I have put a lot of work
into it. I do ask that if anyone asks you about Cdk, tell them where you got it
and who wrote it. If you see Cdk installed without this file on the system
somewhere, then assume the copy the person has is a 'corrupt' version. I will
not be responsible for any unfortunate results if someone else makes a personal
modification to the Cdk library. I will also not be responsible if for some
reason the installation of Cdk creates a negative effect on your machine. You
do have my word that there are no "Trojan horses", worms, or other security
worries lurking in this code. If there are I did not put them there and you
should remove the version of Cdk you have and go get a proper copy. I hate
virus writers as much as anyone else!
Instead of writing my own license (I'm a programmer, not a lawyer!) I'm going
to adapt the BSD public license on public software. If you do not agree to
this license then remove the Cdk distribution and we all will be happier in
the end. Here is the complete BSD public license in its true form, for
reference.
I will say one thing, Cdk is my copyright. I will continue to support any
released versions out there as long as they are in their released form. I am
releasing this into the "public" because I feel I have benefited from other
people's hard work, I'd like to chip into the pot as well. This does NOT make
Cdk public domain though. Cdk is still my copyright, and owned by me, I am
merely stating this so I don't see 40 different versions of my code floating
around with other people's names attached.
With that ugly stuff said, I will happily take any comments or questions about
Cdk. Input is more than welcomed. In fact I encourage it. Feel free to mail
me and ask questions you think the supplied documents don't cover. If I get
enough I may build a FAQ to help newcomers. (We'll see how Cdk is accepted
though).
For you Perl programmers, there is a Perl5 extension to Cdk. Look at your
closest CPAN site under authors/id/GLOVER.
If you want to get a hold of me mail me at one of the following:
glover@credit.erin.utoronto.ca
mike@vexus.ca
The CDK Web page has several homes. They are:
http://www.vexus.ca/CDK.html (official)
http://www.datasoft.on.ca/~cdk (Sponsored by the nice folks at Datasoft)
ttfn,
Mike
-------------------------------------------------------------------------------
/*
* Copyright (c) 1999, Mike Glover
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgment:
* This product includes software developed by Mike Glover
* and contributors.
* 4. Neither the name of Mike Glover, nor the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/

76
deps/cdk-5.0-20161210/EXPANDING vendored Normal file
View File

@ -0,0 +1,76 @@
Cdk New Widget Guide
Copyright Mike Glover, 1995, 1996, 1997, 1998, 1999
-------------------------------------------------------------------------------
If you want to create a new widget for Cdk, and want it in the standard
dist of Cdk, you will have to follow some requisites that I have. I state
these because Cdk has been worked on for quite some time and I finally
got it to a state where the functions calls are somewhat consistent. Any new
widgets should adhere to this. The requirements are as follows:
* The function names should be like:
newCDKXXX, destroyCDKXXX, setCDKXXX, drawCDKXX,...
Any widgets with functions not in this format should be 'private'.
If this is not the case one of three things will happen:
1) The widget will not get accepted
2) I will mail you back asking you to follow the standards.
3) I will do it myself. (HIGHLY unlikely)
* The first parameter of the newCDKXXX function should be of type
CDKSCREEN.
* If applicable, the next two parameters should be xpos and ypos in
that order.
* If applicable, the next two parameters should be the height and
width of the widget.
* If the widget has a title, the next parameter should be a char *
for the title.
* If the widget has a label, the next parameter should be a char *
for the label.
* The last two parameters of the newCDKXXX function should be:
Boolean box, Boolean shadow if the parameters apply.
* The drawCDKXXX function should only have the pointer to the object and
a Boolean box as it's parameters. (in that order)
* The first parameters of any other function relating to the widget
should be a pointer to the widget type. ie: CDKRADIO *, CDKFSELECT *...
* A destroyCDKXXX function has to be provided as well as a drawCDKXXX
function.
* Try to contain anything specific to the widget in a single file. This
keeps the overhead of misc. files from floating around.
* Create a standalone header file which includes cdk.h if needed.
If you follow the guidelines, then the files you need to change to sew the new
widget into Cdk, are:
cdkscreen.c So this widget will get refreshed on a refreshCDKScreen
function call.
binding.c To allow key bindings for the widget. If it is possible
to have key bindings I stress that this be incorporated.
cdk.h To add in the function def's to the header file. (ie:
include the newly created header file.)
Makefile Add in the new widget files.
If you have done all of this then what I need from you is the following:
* A diff of all the files from the dist. that you modified. Use
patch, I prefer it. If you haven't got it, get it and use it. It makes
life easy.
* A copy of the new widget file.
* tar this up and send it to me at
glover@credit.erin.utoronto.ca or at mike@vexus.ca
I will mail you back when I get it and I will tell you if everything is
OK or not.
I hate to be such a nit pick, but if we follow the above standards, Cdk will
evolve into a very nice library, with a lot of really nice widgets.
If you want to get a hold of me mail me at one of the following:
glover@credit.erin.utoronto.ca
mike@vexus.ca
The CDK Web page has several homes. They are:
http://www.vexus.ca/CDK.html (official)
http://www.datasoft.on.ca/~cdk (Sponsored by the nice folks at Datasoft)
ttfn,
Mike

55
deps/cdk-5.0-20161210/INSTALL vendored Normal file
View File

@ -0,0 +1,55 @@
Cdk Installation Guide
-------------------------------------------------------------------------------
Cdk should build/work on any Unix system running SVr4 curses or X/Open curses.
The original INSTALL notes follow:
-------------------------------------------------------------------------------
Copyright Mike Glover, 1995, 1996, 1997, 1998, 1999
-------------------------------------------------------------------------------
General
-------
This document details how to build and install the Cdk library. The first thing
you should know is what compile options you may require. I have had the
fortunate luck of being able to compile this library on the following
platforms:
* Sun/OS 4.1.*
* Solaris 2.3/2.4/2.5/2.5.1/2.6
* AIX 3.2.* (and even AIX 4.1 but there is no mention of this in the
makefile. Sorry.)
* HPUX 9.* (and even HPUX 10.* but there is no mention of this in the
makefile. Sorry.)
* Linux (all sorts Slackware, BSD, and Redhat)
Building
--------
To build the library cd into the Cdk distribution directory and follow
the following steps:
1) Run configure. This will create a Makefile with a default
install directory root of /usr/local. If you want to
change the default install directory use the --prefix
command line argument on configure. For example, if you
want to install under /export/local instead, run the command:
./configure --prefix="/export/local"
2) Type make. This will make the library, the example binaries
and the demonstration binaries.
3) Type make install. This will install the CDK distribution. Look
at step 1 if you want to install other than /usr/local.
4) Start to play. :)
If you want to get a hold of me mail me at one of the following:
glover@credit.erin.utoronto.ca
mike@vexus.ca
The CDK Web page has several homes. They are:
http://www.vexus.ca/CDK.html (official)
http://www.datasoft.on.ca/~cdk (Sponsered by the nice folks at Datasoft)
ttfn,
Mike

622
deps/cdk-5.0-20161210/Makefile.in vendored Normal file
View File

@ -0,0 +1,622 @@
# $Id: Makefile.in,v 1.123 2015/09/28 23:37:35 tom Exp $
#
# Copyright 2001-2014,2015 Thomas E. Dickey
# Copyright 1999, Mike Glover
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgment:
# This product includes software developed by Mike Glover
# and contributors.
# 4. Neither the name of Mike Glover, nor the names of contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
SHELL = /bin/sh
@SET_MAKE@
MAKE_RECUR = @cf_cv_makeflags@ prefix=$(prefix)
PACKAGE = @PACKAGE@
CFG_ROOTNAME = @CFG_ROOTNAME@
HDR_ROOTNAME = @HDR_ROOTNAME@
LIB_ROOTNAME = @LIB_ROOTNAME@
LIB_PREFIX = @LIB_PREFIX@
LIB_SUFFIX = @DFT_LIB_SUFFIX@
VERSION_MAJOR = @VERSION_MAJOR@
VERSION_MINOR = @VERSION_MINOR@
VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
REL_VERSION = @REL_VERSION@
ABI_VERSION = @ABI_VERSION@
RESULTING_SYMS = @RESULTING_SYMS@
VERSIONED_SYMS = @VERSIONED_SYMS@
@SET_SHLIB_VARS@
CDKLIB = @LIB_TARGET@
IMPORT_LIB = lib$(LIB_ROOTNAME).dll.a
@MAKE_NORMAL@OLD_SHLIB_LINK = @LIB_PREFIX@$(LIB_ROOTNAME).so
@MAKE_NORMAL@OLD_SONAME = $(OLD_SHLIB_LINK).$(VERSION_MAJOR)
@MAKE_NORMAL@OLD_SHLIB_FILE = $(OLD_SONAME).$(VERSION_MINOR)
prefix = @prefix@
exec_prefix = @exec_prefix@
top_srcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = $(srcdir)
x = @EXEEXT@
o = .@OBJEXT@
a = $(LIB_SUFFIX)
DESTDIR =
bindir = @bindir@
includedir = @includedir@
libdir = @libdir@
shlibdir = @shlibdir@
datarootdir = @datarootdir@
datadir = @datadir@
mandir = @mandir@
DOCUMENT_DIR = $(DESTDIR)$(datadir)/doc/$(PACKAGE)
BIN_DIR = $(DESTDIR)$(bindir)
INCLUDE_DIR = $(DESTDIR)$(includedir)
INCLUDE_SUBDIR = $(DESTDIR)$(includedir)/$(HDR_ROOTNAME)
SHLIB_DIR = $(DESTDIR)$(shlibdir)
LIB_DIR = $(DESTDIR)$(libdir)
MAN_DIR = $(DESTDIR)$(mandir)/man@MAN_TAG@
MANSECT = @MANSECT@
CC = @CC@
CPP = @CPP@
AR = @AR@
RANLIB = @LIB_PREP@
RM = rm -f
LN_S = @LN_S@
CTAGS = @CTAGS@
ETAGS = @ETAGS@
LINT = @LINT@
LINT_OPTS = @LINT_OPTS@
LIBS = @LIBS@
CFLAGS = @CFLAGS@ @EXTRA_CFLAGS@
CPPFLAGS = @DEFS@ -I./include -I$(srcdir)/include @CPPFLAGS@
LDFLAGS = @LDFLAGS@
RPATH_LIST = @RPATH_LIST@
LIBTOOL = @LIBTOOL@ @ECHO_LT@
LIBTOOL_OPTS = @LIBTOOL_OPTS@
LIBTOOL_CLEAN = @LIB_CLEAN@
LIBTOOL_COMPILE = @LIB_COMPILE@
LIBTOOL_CREATE = @LIB_CREATE@ $(EXTRA_LDFLAGS)
LIBTOOL_LINK = @LIB_LINK@
LIBTOOL_INSTALL = @LIB_INSTALL@
LIBTOOL_UNINSTALL = @LIB_UNINSTALL@
LIBTOOL_VERSION = @LIBTOOL_VERSION@
INSTALL = @INSTALL@
INSTALL_PROGRAM = $(LIBTOOL_INSTALL) @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_LIB = $(LIBTOOL_INSTALL) $(INSTALL_DATA)
UNINSTALL_LIB = $(LIBTOOL_UNINSTALL) $(RM)
.SUFFIXES: .c .o .lo .os .i
default :: $(CDKLIB)
#
# Create the file lists.
#
AUTO_HDR = \
include/dscale.h \
include/fscale.h \
include/fslider.h \
include/scale.h \
include/slider.h \
include/uscale.h \
include/uslider.h
AUTO_SRC = \
dscale.c \
fscale.c \
fslider.c \
scale.c \
slider.c \
uscale.c \
uslider.c
AUTO_MAN = \
man/cdk_dscale.3 \
man/cdk_fscale.3 \
man/cdk_fslider.3 \
man/cdk_scale.3 \
man/cdk_slider.3 \
man/cdk_uscale.3 \
man/cdk_uslider.3
MY_HDR = \
include/cdk_config.h \
$(AUTO_HDR)
CDKHDR = \
alphalist.h \
binding.h \
button.h \
buttonbox.h \
calendar.h \
cdk.h \
cdk_compat.h \
cdk_objs.h \
cdk_params.h \
cdk_test.h \
cdk_util.h \
cdk_version.h \
cdkscreen.h \
curdefs.h \
dialog.h \
draw.h \
entry.h \
fselect.h \
graph.h \
histogram.h \
itemlist.h \
label.h \
marquee.h \
matrix.h \
mentry.h \
menu.h \
radio.h \
scroll.h \
scroller.h \
selection.h \
swindow.h \
template.h \
traverse.h \
viewer.h
CDKSRC = \
$(AUTO_SRC) \
alphalist.c \
binding.c \
button.c \
buttonbox.c \
calendar.c \
cdk.c \
cdk_compat.c \
cdk_display.c \
cdk_objs.c \
cdk_params.c \
cdkscreen.c \
debug.c \
dialog.c \
draw.c \
entry.c \
fselect.c \
get_index.c \
get_string.c \
graph.c \
histogram.c \
itemlist.c \
label.c \
marquee.c \
matrix.c \
mentry.c \
menu.c \
popup_dialog.c \
popup_label.c \
position.c \
radio.c \
scroll.c \
scroller.c \
selection.c \
swindow.c \
select_file.c \
template.c \
traverse.c \
version.c \
view_file.c \
view_info.c \
viewer.c
CDKMAN = \
cdk.3 \
cdk_alphalist.3 \
cdk_binding.3 \
cdk_button.3 \
cdk_buttonbox.3 \
cdk_calendar.3 \
cdk_compat.3 \
cdk_dialog.3 \
cdk_display.3 \
cdk_draw.3 \
cdk_entry.3 \
cdk_fscale.3 \
cdk_fselect.3 \
cdk_graph.3 \
cdk_histogram.3 \
cdk_itemlist.3 \
cdk_label.3 \
cdk_marquee.3 \
cdk_matrix.3 \
cdk_mentry.3 \
cdk_menu.3 \
cdk_misc.3 \
cdk_objs.3 \
cdk_params.3 \
cdk_position.3 \
cdk_process.3 \
cdk_radio.3 \
cdk_scale.3 \
cdk_screen.3 \
cdk_scroll.3 \
cdk_selection.3 \
cdk_swindow.3 \
cdk_template.3 \
cdk_traverse.3 \
cdk_util.3 \
cdk_viewer.3
CDKREADME = EXPANDING NOTES TODO COPYING INSTALL README
OBJECTS = $(CDKSRC:.c=.o)
CDKSHOBJS = $(CDKSRC:.c=.os)
LIB_OBJECT = @LIB_OBJECT@
all sources :: $(AUTO_SRC)
$(OBJECTS) : include/cdk_config.h
#
# Standard library directive.
#
all cdklib :: $(CDKLIB)
@MAKE_NORMAL@cdkshlib $(OLD_SHLIB_FILE) :: $(CDKSHOBJS)
@MAKE_NORMAL@ gcc -shared -Wl,-soname=$(OLD_SONAME) $(LDFLAGS) $(LIBS) -o $(OLD_SHLIB_FILE) $(CDKSHOBJS)
#
# Make the examples directory.
#
all examples ::
cd examples && $(MAKE) $(MAKE_RECUR)
#
# Make the demos directory.
#
all demos ::
cd demos && $(MAKE) $(MAKE_RECUR)
#
# Make the cli directory.
#
all cli ::
cd cli && $(MAKE) $(MAKE_RECUR)
#
# Make the generated manpages.
#
all manpages :: $(AUTO_MAN)
# Order of install-targets should match the order of uninstalls. Put the
# documentation first, then the headers, and finally the library:
# (un)installCDKReadme
# (un)installCDKManPages
# (un)installCDKHeaderFiles
# (un)installCDKLibrary
#
# This installs the informational readme files.
#
install \
installCDKReadme :: $(DOCUMENT_DIR)
@echo "Installing CDK Readme files in $(DOCUMENT_DIR)..."
@for i in $(CDKREADME); do \
echo " ... $$i"; \
$(INSTALL_DATA) $(srcdir)/$$i $(DOCUMENT_DIR)/$$i; \
done
uninstall \
uninstallCDKReadme ::
@echo "Uninstalling CDK Readme files from $(DOCUMENT_DIR)..."
@- for i in $(CDKREADME); do \
$(RM) $(DOCUMENT_DIR)/$$i; \
done
#
# This installs the CDK man pages.
#
install \
installCDKManPages :: headers.sed $(MAN_DIR) manpage.sed $(AUTO_MAN)
@echo "Installing the CDK man pages in $(MAN_DIR) ..."
@for i in $(AUTO_MAN); do \
$(SHELL) $(srcdir)/headers.sh \
-x "$(INSTALL_DATA)" \
-d $(MAN_DIR) \
-s . \
-t $(MANSECT) \
-e manpage.sed $$i; \
$(SHELL) $(srcdir)/manlinks.sh installing $(srcdir) $(MAN_DIR) $(MANSECT) $$i; \
done
@for i in $(CDKMAN); do \
$(SHELL) $(srcdir)/headers.sh \
-x "$(INSTALL_DATA)" \
-d $(MAN_DIR) \
-s . \
-t $(MANSECT) \
-e manpage.sed $(srcdir)/man/$$i; \
$(SHELL) $(srcdir)/manlinks.sh installing $(srcdir) $(MAN_DIR) $(MANSECT) $(srcdir)/man/$$i; \
done
uninstall \
uninstallCDKManPages ::
@echo "Uninstalling the CDK man pages from $(MAN_DIR) ..."
@- for i in $(AUTO_MAN); do \
$(SHELL) $(srcdir)/manlinks.sh removing $(srcdir) $(MAN_DIR) $(MANSECT) $(srcdir)/$$i; \
done
@- for i in $(CDKMAN); do \
$(SHELL) $(srcdir)/manlinks.sh removing $(srcdir) $(MAN_DIR) $(MANSECT) $(srcdir)/man/$$i; \
done
#
# This installs the header files.
#
HDR_SUBDIR = @HDR_SUBDIR@ -h cdk.h
HEADERS_SH = $(SHELL) $(srcdir)/headers.sh $(HDR_SUBDIR) -x "$(INSTALL_DATA)" -d $(INCLUDE_SUBDIR) -s $(srcdir)
install \
installCDKHeaderFiles :: \
$(INCLUDE_DIR) \
$(INCLUDE_SUBDIR) \
headers.sed \
$(MY_HDR)
@echo "Installing CDK header files in $(INCLUDE_SUBDIR)..."
$(HEADERS_SH) $(MY_HDR)
@for i in $(CDKHDR); do \
$(HEADERS_SH) include/$$i; \
done
@HDR_SUBDIR@ rm -f $(INCLUDE_DIR)/cdk.h && mv $(INCLUDE_SUBDIR)/cdk.h $(INCLUDE_DIR)/$(PACKAGE).h
uninstall \
uninstallCDKHeaderFiles ::
@echo "Uninstalling CDK header files from $(INCLUDE_SUBDIR)..."
@- for i in $(MY_HDR); do \
$(RM) $(INCLUDE_SUBDIR)/`basename $$i`; \
done
@- for i in $(CDKHDR); do \
$(RM) $(INCLUDE_SUBDIR)/$$i; \
done
@HDR_SUBDIR@ rm -f $(INCLUDE_DIR)/cdk.h
#
# This installs the CDK library.
#
install \
installCDKLibrary :: $(SHLIB_DIR) $(CDKLIB)
@echo "Installing CDK library"
@$(INSTALL_LIB) $(CDKLIB) $(SHLIB_DIR)/$(CDKLIB)
uninstall \
uninstallCDKLibrary ::
@echo "Uninstalling CDK library"
@- $(UNINSTALL_LIB) $(SHLIB_DIR)/$(CDKLIB)
@MAKE_DLLS@install \
@MAKE_DLLS@installImportLibrary :: $(LIB_DIR) $(IMPORT_LIB)
@MAKE_DLLS@ @echo "Installing Import library"
@MAKE_DLLS@ @$(INSTALL_LIB) $(IMPORT_LIB) $(LIB_DIR)/$(IMPORT_LIB)
@MAKE_DLLS@uninstall \
@MAKE_DLLS@uninstallImportLibrary ::
@MAKE_DLLS@ @echo "Uninstalling Import library"
@MAKE_DLLS@ @- $(UNINSTALL_LIB) $(LIB_DIR)/$(IMPORT_LIB)
#
# This installs the CDK package-config script.
#
install \
installCDKHeaderFiles \
installCDKLibrary :: $(BIN_DIR) cdk-config
@echo "Installing script $(CFG_ROOTNAME)$(VERSION_MAJOR)-config"
@$(INSTALL) cdk-config $(BIN_DIR)/$(CFG_ROOTNAME)$(VERSION_MAJOR)-config
uninstall \
uninstallCDKHeaderFiles \
uninstallCDKLibrary :: cdk-config
@echo "Uninstalling script $(CFG_ROOTNAME)$(VERSION_MAJOR)-config"
@$(RM) $(BIN_DIR)/$(CFG_ROOTNAME)$(VERSION_MAJOR)-config
#
# This installs the CDK shared library. The rules are for an RPM spec, and
# not of general interest.
#
@MAKE_NORMAL@installCDKSHLibrary :: $(SHLIB_DIR) $(OLD_SHLIB_FILE)
@MAKE_NORMAL@ @echo "Installing CDK library"
@MAKE_NORMAL@ @ECHO_CC@$(INSTALL_DATA) $(OLD_SHLIB_FILE) $(SHLIB_DIR)
@MAKE_NORMAL@ @ECHO_CC@$(SHELL) -c "cd $(SHLIB_DIR) && $(LN_S) $(OLD_SHLIB_FILE) $(OLD_SONAME)"
@MAKE_NORMAL@ @ECHO_CC@$(SHELL) -c "cd $(SHLIB_DIR) && $(LN_S) $(OLD_SHLIB_FILE) $(OLD_SHLIB_LINK)"
@MAKE_NORMAL@
@MAKE_NORMAL@uninstall \
@MAKE_NORMAL@uninstallCDKSHLibrary ::
@MAKE_NORMAL@ @ECHO_CC@- $(RM) $(SHLIB_DIR)/$(LIB_BASENAME)
@MAKE_NORMAL@ @ECHO_CC@- $(RM) $(SHLIB_DIR)/$(OLD_SONAME)
@MAKE_NORMAL@ @ECHO_CC@- $(RM) $(SHLIB_DIR)/$(OLD_SHLIB_FILE)
headers.sed : $(srcdir)/headers.sh
$(SHELL) $(srcdir)/headers.sh -p CDK $(HDR_SUBDIR) -c include/cdk_config.h -d $(INCLUDE_SUBDIR) -s $(srcdir)/include -i -s include -i
manpage.sed :
@echo "creating $@"
@echo "s/(3)/($(MANSECT))/g" >$@
@echo "/^\.TH/s/\<3\>/$(MANSECT)/" >>$@
@MAKE_LOWER_TAGS@tags :
@MAKE_LOWER_TAGS@ $(CTAGS) *.[ch] */*.[ch]
@MAKE_LOWER_TAGS@TAGS :
@MAKE_LOWER_TAGS@ $(ETAGS) *.[ch] */*.[ch]
lint: $(AUTO_HDR) $(AUTO_SRC) $(CDKSRC)
$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(AUTO_SRC) $(CDKSRC)
all-lint: lint
cd examples && $(MAKE) $(MAKE_RECUR) lint
cd demos && $(MAKE) $(MAKE_RECUR) lint
cd cli && $(MAKE) $(MAKE_RECUR) lint
#
# Clean up after ourselves...
#
clean ::
@- $(RM) -r autom4te.cache
- $(LIBTOOL_CLEAN) $(RM) $(LIB_OBJECT) $(CDKLIB) $(RM_SHARED_OPTS)
@MAKE_NORMAL@ - $(RM) *.os $(OLD_SHLIB_FILE)
- $(RM) headers.sed manpage.sed core tags *.i *~
$(RM) $(AUTO_HDR)
$(RM) $(AUTO_SRC)
$(RM) $(AUTO_MAN)
realclean :: clean
cd examples && $(MAKE) $(MAKE_RECUR) clean
cd demos && $(MAKE) $(MAKE_RECUR) clean
cd cli && $(MAKE) $(MAKE_RECUR) clean
#
# Use this to clean the distribution.
#
distclean :: realclean
$(RM) config.cache config.log config.status
cd examples && $(RM) Makefile
cd demos && $(RM) Makefile
cd cli && $(RM) Makefile
$(RM) include/cdk_config.h
$(RM) include/cdk_version.h
$(RM) Makefile
$(RM) cdk-config
$(RM) mk_shared_lib.sh
@- $(SHELL) -c 'if test "$(srcdir)" != . ; then \
rmdir examples; \
rmdir demos; \
rmdir cli; \
rmdir include; \
fi'
#
# Standard .c to .o compile line.
#
.c.o:
@RULE_CC@
@ECHO_CC@$(LIBTOOL_COMPILE) $(CC) $(CFLAGS) $(CPPFLAGS) -c $<
.c.lo:
@RULE_CC@
@ECHO_CC@$(LIBTOOL_COMPILE) $(CC) $(CFLAGS) $(CPPFLAGS) -c $<
.c.i:
@RULE_CC@
@ECHO_CC@$(CPP) $(CPPFLAGS) -E -C $< >$@
.c.os:
@RULE_CC@
@ECHO_CC@$(CC) $(CFLAGS) $(CPPFLAGS) -c -fPIC $< -o $@
man \
$(BIN_DIR) \
$(DOCUMENT_DIR) \
$(INCLUDE_DIR) \
$(INCLUDE_SUBDIR) \
$(LIB_DIR) \
$(MAN_DIR) : ; mkdir -p $@
#
# Files generated from templates:
#
GEN_SCALE = $(SHELL) $(srcdir)/gen-scale.sh
SCALE_H = $(srcdir)/include/gen-scale.h
SCALE_C = $(srcdir)/gen-scale.c
SCALE_M = $(srcdir)/man/gen-scale.3
MKDIR_MAN = test -d man || mkdir man
include/dscale.h : $(SCALE_H)
$(GEN_SCALE) DSCALE DScale Double double $(SCALE_H) >$@
dscale.c : $(SCALE_C) $(AUTO_HDR)
$(GEN_SCALE) DSCALE DScale Double double $(SCALE_C) >$@
man/cdk_dscale.3 : $(SCALE_M) man
-$(MKDIR_MAN)
$(GEN_SCALE) DSCALE DScale Double double $(SCALE_M) >$@
include/fscale.h : $(SCALE_H)
$(GEN_SCALE) FSCALE FScale Float float $(SCALE_H) >$@
fscale.c : $(SCALE_C) $(AUTO_HDR)
$(GEN_SCALE) FSCALE FScale Float float $(SCALE_C) >$@
man/cdk_fscale.3 : $(SCALE_M) man
-$(MKDIR_MAN)
$(GEN_SCALE) FSCALE FScale Float float $(SCALE_M) >$@
include/scale.h : $(SCALE_H)
$(GEN_SCALE) SCALE Scale Int int $(SCALE_H) >$@
scale.c : $(SCALE_C) $(AUTO_HDR)
$(GEN_SCALE) SCALE Scale Int int $(SCALE_C) >$@
man/cdk_scale.3 : $(SCALE_M) man
-$(MKDIR_MAN)
$(GEN_SCALE) SCALE Scale Int int $(SCALE_M) >$@
include/uscale.h : $(SCALE_H)
$(GEN_SCALE) USCALE UScale Unsigned unsigned $(SCALE_H) >$@
uscale.c : $(SCALE_C) $(AUTO_HDR)
$(GEN_SCALE) USCALE UScale Unsigned unsigned $(SCALE_C) >$@
man/cdk_uscale.3 : $(SCALE_M) man
-$(MKDIR_MAN)
$(GEN_SCALE) USCALE UScale Unsigned unsigned $(SCALE_M) >$@
SLIDER_H = $(srcdir)/include/gen-slider.h
SLIDER_C = $(srcdir)/gen-slider.c
SLIDER_M = $(srcdir)/man/gen-slider.3
include/fslider.h : $(SLIDER_H)
$(GEN_SCALE) FSLIDER FSlider Float float $(SLIDER_H) >$@
fslider.c : $(SLIDER_C) $(AUTO_HDR)
$(GEN_SCALE) FSLIDER FSlider Float float $(SLIDER_C) >$@
man/cdk_fslider.3 : $(SLIDER_M) man
-$(MKDIR_MAN)
$(GEN_SCALE) FSLIDER FSlider Float float $(SLIDER_M) >$@
include/slider.h : $(SLIDER_H)
$(GEN_SCALE) SLIDER Slider Int int $(SLIDER_H) >$@
slider.c : $(SLIDER_C) $(AUTO_HDR)
$(GEN_SCALE) SLIDER Slider Int int $(SLIDER_C) >$@
man/cdk_slider.3 : $(SLIDER_M) man
-$(MKDIR_MAN)
$(GEN_SCALE) SLIDER Slider Int int $(SLIDER_M) >$@
include/uslider.h : $(SLIDER_H)
$(GEN_SCALE) USLIDER USlider Unsigned unsigned $(SLIDER_H) >$@
uslider.c : $(SLIDER_C) $(AUTO_HDR)
$(GEN_SCALE) USLIDER USlider Unsigned unsigned $(SLIDER_C) >$@
man/cdk_uslider.3 : $(SLIDER_M) man
-$(MKDIR_MAN)
$(GEN_SCALE) USLIDER USlider Unsigned unsigned $(SLIDER_M) >$@

48
deps/cdk-5.0-20161210/NOTES vendored Normal file
View File

@ -0,0 +1,48 @@
Cdk Notes
Copyright Mike Glover, 1995, 1996, 1997, 1998, 1999
-------------------------------------------------------------------------------
This document states some of the testing and history of the Cdk widget set.
Cdk has gone through a major facelift since I first created it, and it's
current look I like enough to release and attach my name to. :) I have made sure
to remain as consistent as possible with function parameter positions, names,
purposes, and what-not. I hope I have been, if not mail me tell me what you
find inconsistent and I may change it. I say may because I don't want to kill
anyone's code if I can help it. That is why I waited so long before releasing
Cdk. I wanted it to be as stable as possible before sending it out into the
world. I think it's stable, and hopefully so will you. There are a few things
worth noting before continuing.
Cdk has gone through some fairly rigorous testing, but since I did the testing
it may not be complete. I have complied the code with Purify (TM) and
Centerline's Testcenter (TM) and both say my code is clean. There are no
memory leaks, and the only problems exist in the curses library. If you use the
Ncurses library, it has been cleaned. Of course I am not the best to ask. The
only reason why I can say this is because I asked the Ncurses author. I don't
know how clean it is. I will assume very clean.
But since I may not be able to see the forest for the trees, I'm willing to
bet that bugs still do exist, and you folks will find them. If you do find bugs
read the BUGS document supplied with this release to find out what to do.
I do not plan on changing the interface to Cdk, so any code developed in it now
should pass the test of time. The only changes I can see are bug fixes and new
widgets. Lets hope this wish of mine remains true...
There is an examples directory available which demonstrates all of the widgets
and some extra concepts, it's a great place to tool around in before banging
away at your own code.
If you want to get a hold of me mail me at one of the following:
glover@credit.erin.utoronto.ca
mike@vexus.ca
The CDK Web page has several homes. They are:
http://www.vexus.ca/CDK.html (official)
http://www.datasoft.on.ca/~cdk (Sponsered by the nice folks at Datasoft)
Have fun. :)
ttfn,
Mike

150
deps/cdk-5.0-20161210/README vendored Normal file
View File

@ -0,0 +1,150 @@
-- $Id: README,v 1.10 2016/01/31 19:55:06 tom Exp $
-------------------------------------------------------------------------------
Copyright Thomas Dickey 1999-2015,2016
This is a modified/enhanced version of Cdk. The original README contents are
given below.
This version of Cdk is found at
http://invisible-island.net/cdk/
ftp://invisible-island.net/cdk/
The intent of the modifications is to preserve nominal compatibility with the
original Cdk, while fixing bugs and design limitations. Some macros such as
ObjOf() have been introduced to move details out of individual widgets into
common functionality (see the cdk_objs.h header). In addition, fixed array
limits have been removed, using new functions in some instances which do not
have the fixed limits.
Converting a program which uses the original Cdk is done by wrapping the widget
pointers in ObjOf() for struct members which have been moved into the CDKOBJS
struct. This is not a one-way conversion (for many applications), since a
header cdk_compat.h defines ObjOf() and a few obsolete functions which may be
used by older programs. By wrapping the widget pointers as needed in ObjOf(),
one may compile the same source against the old/new versions of Cdk to check
that the application is correctly upgraded.
Once converted, there are additional functions and widgets provided by the
new version of Cdk. Bugs should (as noted on the webpage) be reported to me.
-------------------------------------------------------------------------------
Cdk Readme Guide
Copyright Mike Glover, 1995, 1996, 1997, 1998, 1999
-------------------------------------------------------------------------------
Overview:
---------
Cdk stands for 'Curses Development Kit' and it currently contains 21 ready
to use widgets which facilitate the speedy development of full screen
curses programs. This little project of mine started as a test to see how
compatible my Linux machine was to other UNIX breeds. While doing this I
discovered Ncurses, and played with it. These widgets are the result of
over a years worth of playing. The current complement of widgets are:
Widget Type Quick Description
===========================================================================
Alphalist Allows a user to select from a list of words, with
the ability to narrow the search list by typing in a
few characters of the desired word.
Buttonbox This creates a multiple button widget.
Calendar Creates a little simple calendar widget.
Dialog Prompts the user with a message, and the user
can pick an answer from the buttons provided.
Entry Allows the user to enter various types of information.
File Selector A file selector built from Cdk base widgets. This
example shows how to create more complicated widgets
using the Cdk widget library.
Graph Draws a graph.
Histogram Draws a histogram.
Item List Creates a pop up field which allows the user to select
one of several choices in a small field. Very useful
for things like days of the week or month names.
Label Displays messages in a pop up box, or the label can be
considered part of the screen.
Marquee Displays a message in a scrolling marquee.
Matrix Creates a complex matrix with lots of options.
Menu Creates a pull-down menu interface.
Multiple Line Entry A multiple line entry field. Very useful
for long fields. (like a description
field)
Radio List Creates a radio button list.
Scale Creates a numeric scale. Used for allowing a user to
pick a numeric value and restrict them to a range of
values.
Scrolling List Creates a scrolling list/menu list.
Scrolling Window Creates a scrolling log file viewer. Can add
information into the window while its running.
A good widget for displaying the progress of
something. (akin to a console window)
Selection List Creates a multiple option selection list.
Slider Akin to the scale widget, this widget provides a
visual slide bar to represent the numeric value.
Template Creates a entry field with character sensitive
positions. Used for pre-formatted fields like
dates and phone numbers.
Viewer This is a file/information viewer. Very useful
when you need to display loads of information.
===========================================================================
Each widget has the ability to display color, or other character attributes.
Cdk comes with a attribute/color format command set which allows a programmer
to add colors and characters attributes simply.
The code has been cleaned using both Purify(TM) and Sun's Testcenter(TM),
so it is as clean as a babies butt. :) Any leaks I have seen are in the curses
libraries; there is nothing I can do about that, sorry. There should be no
memory leaks within the code, it shouldn't core dump, and it shouldn't do
anything unexpected. Unfortunately this probably is not the case. If you do
see something like this tell me after you read the BUGS file.
Distribution:
-------------
This distribution has a full complement of manual pages, so any specifics to
the widgets will not be addressed in this read me. If you want to get right in
there, nroff the cdk.3 file in the man directory. It is the starting point
for all the manual pages.
There are some other files to look at if you want to get anywhere. They are:
INSTALL - This will show you how to build Cdk and install it on your system.
If there are any personal modifications that you think may be
needed, read this file. In fact read it regardless. :)
COPYING - The legal stuff to protect my butt and all of the hard work that I
have put into this library.
EXPANDING - You feel creative enough to add a widget, here are my requirements
that you have to follow to make the integration of a new widget
seamless.
BUGS - What to do when you find a bug. It also lists all of the bugs found,
who found them, who fixed them, and when they were fixed. If you think
you have found a bug look at this file. If you do not think you have
the most up to date version of Cdk, go get it and try to replicate the
problem. Then look at the BUGS file again. If it is NOT there, then you
can mail me notifying me of a possible bug. I will try my hardest to get
back to you, but I have a pretty busy schedule so don't expect an instant
reply. This file will also explain how I would like any bug fixes sent to
me.
NOTES - Misc babblings of myself somewhat related to this distribution.
TODO - A list of things I plan to do in the future. (sleep)
CHANGES - A list of changes from one release to another.
If you want to get a hold of me mail me at one of the following:
glover@credit.erin.utoronto.ca
mike@vexus.ca
The CDK Web page has several homes. They are:
http://www.vexus.ca/CDK.html (official)
http://www.datasoft.on.ca/~cdk (Sponsored by the nice folks at Datasoft)
ttfn,
Mike
PS: There is also a Perl5 extension of this library for you Perl5 fans.
Look under any CPAN site under the directory CPAN/authors/id/GLOVER.

53
deps/cdk-5.0-20161210/TODO vendored Normal file
View File

@ -0,0 +1,53 @@
Cdk To-Do List
Copyright Mike Glover, 1995, 1996, 1997, 1998, 1999
------------------------------------------------------------------------------
There are a few things that I am either currently working on, or going to
work on in the near future. They are:
* Add more functions to the drawing routines. (yadda, yadda, yadda...)
* Working on a tree widget...
* Working on a tab list widget...
* I would like to be able to have a captive shell widget. This
would allow you to start a subshell and have the user interact
with a spawned command via the captive shell. This would allow
you to spawn an interactive command through the widget. If any
one knows how to do this, please mail me. Maybe we'll work this
through. (I WOULD LOVE TO ADD THIS, IF ANYONE HAS ANY IDEAS
PLEASE MAIL ME)
* I am thinking about adding an X windows element to Cdk using
the Xforms library, because it seems to have roughly the same
widgets as I do. The plan is to have a simple environment variable
which tells the program what you want curses/X windows. We'll
see how this goes.
* I am going to (in the next revision), make the Cdk library more
X like with the ability to set/get attributes of the widgets via
functions. The proposed method is something like :
value = CdkEntryGetXXX (widget)
CdkEntrySetXXX (widget, value)
Where XXX is a property of the widget. It would be nice to create
a singlar widget type (CdkWidget) and to have generic functions
set/get the properties. (this is all being thought of to phase
in the X/Cdk idea mentioned above.)
* I'm also working on fixing the way the default callback function
for the widget editing functions is called. (i know this is brief,
but it's there more to remind me of an idea which was spurred on by
someone else's suggestion.)
* Version 5 should have the ability to properly attach widgets
together via constraints, positioning within forms, etc... The
next inception should make it simpler to create home-grown widgets.
(Version 5 may also only support Ncurses because I'm losing a lot
of functionality by being backward compatible.)
If you want to get a hold of me mail me at one of the following:
glover@credit.erin.utoronto.ca
mike@vexus.ca
The CDK Web page has several homes. They are:
http://www.vexus.ca/CDK.html (official)
http://www.datasoft.on.ca/~cdk (Sponsored by the nice folks at Datasoft)
ttfn,
Mike

1
deps/cdk-5.0-20161210/VERSION vendored Normal file
View File

@ -0,0 +1 @@
6:1:4 5.0 20161210

4949
deps/cdk-5.0-20161210/aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

939
deps/cdk-5.0-20161210/alphalist.c vendored Normal file
View File

@ -0,0 +1,939 @@
#include <cdk_int.h>
/*
* $Author: tom $
* $Date: 2016/11/20 18:39:12 $
* $Revision: 1.111 $
*/
/*
* Declare file local prototypes.
*/
static BINDFN_PROTO (adjustAlphalistCB);
static BINDFN_PROTO (completeWordCB);
static int preProcessEntryField (EObjectType, void *, void *, chtype);
static int createList (CDKALPHALIST *alphalist, CDK_CSTRING *list, int listSize);
DeclareSetXXchar (static, _setMy);
DeclareCDKObjects (ALPHALIST, Alphalist, _setMy, String);
/*
* This creates the alphalist widget.
*/
CDKALPHALIST *newCDKAlphalist (CDKSCREEN *cdkscreen,
int xplace,
int yplace,
int height,
int width,
const char *title,
const char *label,
CDK_CSTRING *list,
int listSize,
chtype fillerChar,
chtype highlight,
boolean Box,
boolean shadow)
{
/* *INDENT-EQLS* */
CDKALPHALIST *alphalist = 0;
int parentWidth = getmaxx (cdkscreen->window);
int parentHeight = getmaxy (cdkscreen->window);
int boxWidth;
int boxHeight;
int xpos = xplace;
int ypos = yplace;
int tempWidth = 0;
int tempHeight = 0;
int labelLen = 0;
int x, junk2;
/* *INDENT-OFF* */
static const struct { int from; int to; } bindings[] = {
{ CDK_BACKCHAR, KEY_PPAGE },
{ CDK_FORCHAR, KEY_NPAGE },
};
/* *INDENT-ON* */
if ((alphalist = newCDKObject (CDKALPHALIST, &my_funcs)) == 0
|| !createList (alphalist, list, listSize))
{
destroyCDKObject (alphalist);
return (0);
}
setCDKAlphalistBox (alphalist, Box);
/*
* If the height is a negative value, the height will
* be ROWS-height, otherwise, the height will be the
* given height.
*/
boxHeight = setWidgetDimension (parentHeight, height, 0);
/*
* If the width is a negative value, the width will
* be COLS-width, otherwise, the width will be the
* given width.
*/
boxWidth = setWidgetDimension (parentWidth, width, 0);
/* Translate the label char *pointer to a chtype pointer. */
if (label != 0)
{
chtype *chtypeLabel = char2Chtype (label, &labelLen, &junk2);
freeChtype (chtypeLabel);
}
/* Rejustify the x and y positions if we need to. */
alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
/* Make the file selector window. */
alphalist->win = newwin (boxHeight, boxWidth, ypos, xpos);
if (alphalist->win == 0)
{
destroyCDKObject (alphalist);
return (0);
}
keypad (alphalist->win, TRUE);
/* *INDENT-EQLS* Set some variables. */
ScreenOf (alphalist) = cdkscreen;
alphalist->parent = cdkscreen->window;
alphalist->highlight = highlight;
alphalist->fillerChar = fillerChar;
alphalist->boxHeight = boxHeight;
alphalist->boxWidth = boxWidth;
initExitType (alphalist);
alphalist->shadow = shadow;
alphalist->shadowWin = 0;
/* Do we want a shadow? */
if (shadow)
{
alphalist->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
}
/* Create the entry field. */
tempWidth = (isFullWidth (width)
? FULL
: boxWidth - 2 - labelLen);
alphalist->entryField = newCDKEntry (cdkscreen,
getbegx (alphalist->win),
getbegy (alphalist->win),
title, label,
A_NORMAL, fillerChar,
vMIXED, tempWidth, 0, 512,
Box, FALSE);
if (alphalist->entryField == 0)
{
destroyCDKObject (alphalist);
return (0);
}
setCDKEntryLLChar (alphalist->entryField, ACS_LTEE);
setCDKEntryLRChar (alphalist->entryField, ACS_RTEE);
/* Set the key bindings for the entry field. */
bindCDKObject (vENTRY,
alphalist->entryField,
KEY_UP,
adjustAlphalistCB,
alphalist);
bindCDKObject (vENTRY,
alphalist->entryField,
KEY_DOWN,
adjustAlphalistCB,
alphalist);
bindCDKObject (vENTRY,
alphalist->entryField,
KEY_NPAGE,
adjustAlphalistCB,
alphalist);
bindCDKObject (vENTRY,
alphalist->entryField,
KEY_PPAGE,
adjustAlphalistCB,
alphalist);
bindCDKObject (vENTRY,
alphalist->entryField,
KEY_TAB,
completeWordCB,
alphalist);
/* Set up the post-process function for the entry field. */
setCDKEntryPreProcess (alphalist->entryField, preProcessEntryField, alphalist);
/*
* Create the scrolling list. It overlaps the entry field by one line if
* we are using box-borders.
*/
tempHeight = getmaxy (alphalist->entryField->win) - BorderOf (alphalist);
tempWidth = (isFullWidth (width)
? FULL
: boxWidth - 1);
alphalist->scrollField = newCDKScroll (cdkscreen,
getbegx (alphalist->win),
getbegy (alphalist->entryField->win)
+ tempHeight,
RIGHT,
boxHeight - tempHeight,
tempWidth,
0, (CDK_CSTRING2)list, listSize,
NONUMBERS, A_REVERSE,
Box, FALSE);
setCDKScrollULChar (alphalist->scrollField, ACS_LTEE);
setCDKScrollURChar (alphalist->scrollField, ACS_RTEE);
/* Setup the key bindings. */
for (x = 0; x < (int)SIZEOF (bindings); ++x)
bindCDKObject (vALPHALIST,
alphalist,
(chtype)bindings[x].from,
getcCDKBind,
(void *)(long)bindings[x].to);
registerCDKObject (cdkscreen, vALPHALIST, alphalist);
return (alphalist);
}
/*
* This erases the file selector from the screen.
*/
static void _eraseCDKAlphalist (CDKOBJS *object)
{
if (validCDKObject (object))
{
CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
eraseCDKScroll (alphalist->scrollField);
eraseCDKEntry (alphalist->entryField);
eraseCursesWindow (alphalist->shadowWin);
eraseCursesWindow (alphalist->win);
}
}
/*
* This moves the alphalist field to the given location.
*/
static void _moveCDKAlphalist (CDKOBJS *object,
int xplace,
int yplace,
boolean relative,
boolean refresh_flag)
{
CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
/* *INDENT-EQLS* */
int currentX = getbegx (alphalist->win);
int currentY = getbegy (alphalist->win);
int xpos = xplace;
int ypos = yplace;
int xdiff = 0;
int ydiff = 0;
/*
* If this is a relative move, then we will adjust where we want
* to move to.
*/
if (relative)
{
xpos = getbegx (alphalist->win) + xplace;
ypos = getbegy (alphalist->win) + yplace;
}
/* Adjust the window if we need to. */
alignxy (WindowOf (alphalist), &xpos, &ypos, alphalist->boxWidth, alphalist->boxHeight);
/* Get the difference. */
xdiff = currentX - xpos;
ydiff = currentY - ypos;
/* Move the window to the new location. */
moveCursesWindow (alphalist->win, -xdiff, -ydiff);
moveCursesWindow (alphalist->shadowWin, -xdiff, -ydiff);
/* Move the sub-widgets. */
moveCDKEntry (alphalist->entryField, xplace, yplace, relative, FALSE);
moveCDKScroll (alphalist->scrollField, xplace, yplace, relative, FALSE);
/* Touch the windows so they 'move'. */
refreshCDKWindow (WindowOf (alphalist));
/* Redraw the window, if they asked for it. */
if (refresh_flag)
{
drawCDKAlphalist (alphalist, ObjOf (alphalist)->box);
}
}
/*
* The alphalist's focus resides in the entry widget. But the scroll widget
* will not draw items highlighted unless it has focus. Temporarily adjust the
* focus of the scroll widget when drawing on it to get the right highlighting.
*/
#define SaveFocus(widget) \
boolean save = HasFocusObj (ObjOf (widget->scrollField)); \
HasFocusObj (ObjOf (widget->scrollField)) = \
HasFocusObj (ObjOf (widget->entryField))
#define RestoreFocus(widget) \
HasFocusObj (ObjOf (widget->scrollField)) = save
static void drawMyScroller (CDKALPHALIST *widget)
{
SaveFocus (widget);
drawCDKScroll (widget->scrollField, ObjOf (widget->scrollField)->box);
RestoreFocus (widget);
}
static void injectMyScroller (CDKALPHALIST *widget, chtype key)
{
SaveFocus (widget);
(void)injectCDKScroll (widget->scrollField, key);
RestoreFocus (widget);
}
/*
* This draws the file selector widget.
*/
static void _drawCDKAlphalist (CDKOBJS *obj, boolean Box GCC_UNUSED)
{
CDKALPHALIST *alphalist = (CDKALPHALIST *)obj;
/* Does this widget have a shadow? */
if (alphalist->shadowWin != 0)
{
drawShadow (alphalist->shadowWin);
}
/* Draw in the entry field. */
drawCDKEntry (alphalist->entryField, ObjOf (alphalist->entryField)->box);
/* Draw in the scroll field. */
drawMyScroller (alphalist);
}
/*
* This activates the file selector.
*/
char *activateCDKAlphalist (CDKALPHALIST *alphalist, chtype *actions)
{
char *ret = 0;
/* Draw the widget. */
drawCDKAlphalist (alphalist, ObjOf (alphalist)->box);
/* Activate the widget. */
ret = activateCDKEntry (alphalist->entryField, actions);
/* Copy the exit type from the entry field. */
copyExitType (alphalist, alphalist->entryField);
/* Determine the exit status. */
if (alphalist->exitType != vEARLY_EXIT)
{
return ret;
}
return 0;
}
/*
* This injects a single character into the alphalist.
*/
static int _injectCDKAlphalist (CDKOBJS *object, chtype input)
{
CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
char *ret;
/* Draw the widget. */
drawCDKAlphalist (alphalist, ObjOf (alphalist)->box);
/* Inject a character into the widget. */
ret = injectCDKEntry (alphalist->entryField, input);
/* Copy the exit type from the entry field. */
copyExitType (alphalist, alphalist->entryField);
/* Determine the exit status. */
if (alphalist->exitType == vEARLY_EXIT)
ret = unknownString;
ResultOf (alphalist).valueString = ret;
return (ret != unknownString);
}
/*
* This sets multiple attributes of the widget.
*/
void setCDKAlphalist (CDKALPHALIST *alphalist,
CDK_CSTRING *list,
int listSize,
chtype fillerChar,
chtype highlight,
boolean Box)
{
setCDKAlphalistContents (alphalist, list, listSize);
setCDKAlphalistFillerChar (alphalist, fillerChar);
setCDKAlphalistHighlight (alphalist, highlight);
setCDKAlphalistBox (alphalist, Box);
}
/*
* This function sets the information inside the file selector.
*/
void setCDKAlphalistContents (CDKALPHALIST *widget, CDK_CSTRING *list, int listSize)
{
CDKSCROLL *scrollp = widget->scrollField;
CDKENTRY *entry = widget->entryField;
if (!createList (widget, list, listSize))
return;
/* Set the information in the scrolling list. */
setCDKScroll (scrollp,
(CDK_CSTRING2)widget->list,
widget->listSize,
NONUMBERS,
scrollp->highlight,
ObjOf (scrollp)->box);
/* Clean out the entry field. */
setCDKAlphalistCurrentItem (widget, 0);
cleanCDKEntry (entry);
/* Redraw the widget. */
eraseCDKAlphalist (widget);
drawCDKAlphalist (widget, ObjOf (widget)->box);
}
/*
* This returns the contents of the widget.
*/
char **getCDKAlphalistContents (CDKALPHALIST *widget, int *size)
{
(*size) = widget->listSize;
return widget->list;
}
/*
* Get/set the current position in the scroll-widget.
*/
int getCDKAlphalistCurrentItem (CDKALPHALIST *widget)
{
return getCDKScrollCurrent (widget->scrollField);
}
void setCDKAlphalistCurrentItem (CDKALPHALIST *widget, int item)
{
if (widget->listSize != 0)
{
setCDKScrollCurrent (widget->scrollField, item);
setCDKEntryValue (widget->entryField,
widget->list[getCDKScrollCurrentItem (widget->scrollField)]);
}
}
/*
* This sets the filler character of the entry field of the alphalist.
*/
void setCDKAlphalistFillerChar (CDKALPHALIST *alphalist, chtype fillerCharacter)
{
CDKENTRY *entry = (CDKENTRY *)alphalist->entryField;
alphalist->fillerChar = fillerCharacter;
setCDKEntryFillerChar (entry, fillerCharacter);
}
chtype getCDKAlphalistFillerChar (CDKALPHALIST *alphalist)
{
return alphalist->fillerChar;
}
/*
* This sets the highlight bar attributes.
*/
void setCDKAlphalistHighlight (CDKALPHALIST *alphalist, chtype highlight)
{
alphalist->highlight = highlight;
}
chtype getCDKAlphalistHighlight (CDKALPHALIST *alphalist)
{
return alphalist->highlight;
}
/*
* This sets whether or not the widget will be drawn with a box.
*/
void setCDKAlphalistBox (CDKALPHALIST *alphalist, boolean Box)
{
ObjOf (alphalist)->box = Box;
ObjOf (alphalist)->borderSize = Box ? 1 : 0;
}
boolean getCDKAlphalistBox (CDKALPHALIST *alphalist)
{
return ObjOf (alphalist)->box;
}
/*
* These functions set the drawing characters of the widget.
*/
static void _setMyULchar (CDKOBJS *object, chtype character)
{
CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
setCDKEntryULChar (alphalist->entryField, character);
}
static void _setMyURchar (CDKOBJS *object, chtype character)
{
CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
setCDKEntryURChar (alphalist->entryField, character);
}
static void _setMyLLchar (CDKOBJS *object, chtype character)
{
CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
setCDKScrollLLChar (alphalist->scrollField, character);
}
static void _setMyLRchar (CDKOBJS *object, chtype character)
{
CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
setCDKScrollLRChar (alphalist->scrollField, character);
}
static void _setMyVTchar (CDKOBJS *object, chtype character)
{
CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
setCDKEntryVerticalChar (alphalist->entryField, character);
setCDKScrollVerticalChar (alphalist->scrollField, character);
}
static void _setMyHZchar (CDKOBJS *object, chtype character)
{
CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
setCDKEntryHorizontalChar (alphalist->entryField, character);
setCDKScrollHorizontalChar (alphalist->scrollField, character);
}
static void _setMyBXattr (CDKOBJS *object, chtype character)
{
CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
setCDKEntryBoxAttribute (alphalist->entryField, character);
setCDKScrollBoxAttribute (alphalist->scrollField, character);
}
/*
* This sets the background attribute of the widget.
*/
static void _setBKattrAlphalist (CDKOBJS *obj, chtype attrib)
{
CDKALPHALIST *alphalist = (CDKALPHALIST *)obj;
setCDKEntryBackgroundAttrib (alphalist->entryField, attrib);
setCDKScrollBackgroundAttrib (alphalist->scrollField, attrib);
}
static void destroyInfo (CDKALPHALIST *widget)
{
CDKfreeStrings (widget->list);
widget->list = 0;
widget->listSize = 0;
}
/*
* This destroys the file selector.
*/
static void _destroyCDKAlphalist (CDKOBJS *object)
{
if (object != 0)
{
CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
destroyInfo (alphalist);
/* Clean the key bindings. */
cleanCDKObjectBindings (vALPHALIST, alphalist);
destroyCDKEntry (alphalist->entryField);
destroyCDKScroll (alphalist->scrollField);
/* Free up the window pointers. */
deleteCursesWindow (alphalist->shadowWin);
deleteCursesWindow (alphalist->win);
/* Unregister the object. */
unregisterCDKObject (vALPHALIST, alphalist);
}
}
/*
* This function sets the pre-process function.
*/
void setCDKAlphalistPreProcess (CDKALPHALIST *alphalist,
PROCESSFN callback,
void *data)
{
setCDKEntryPreProcess (alphalist->entryField, callback, data);
}
/*
* This function sets the post-process function.
*/
void setCDKAlphalistPostProcess (CDKALPHALIST *alphalist,
PROCESSFN callback,
void *data)
{
setCDKEntryPostProcess (alphalist->entryField, callback, data);
}
/*
* Start of callback functions.
*/
static int adjustAlphalistCB (EObjectType objectType GCC_UNUSED, void
*object GCC_UNUSED,
void *clientData,
chtype key)
{
/* *INDENT-EQLS* */
CDKALPHALIST *alphalist = (CDKALPHALIST *)clientData;
CDKSCROLL *scrollp = alphalist->scrollField;
CDKENTRY *entry = alphalist->entryField;
if (scrollp->listSize > 0)
{
char *current;
/* Adjust the scrolling list. */
injectMyScroller (alphalist, key);
/* Set the value in the entry field. */
current = chtype2Char (scrollp->item[scrollp->currentItem]);
setCDKEntryValue (entry, current);
drawCDKEntry (entry, ObjOf (entry)->box);
freeChar (current);
return (TRUE);
}
Beep ();
return (FALSE);
}
/*
* This is the heart-beat of the widget.
*/
static int preProcessEntryField (EObjectType cdktype GCC_UNUSED, void
*object GCC_UNUSED,
void *clientData,
chtype input)
{
/* *INDENT-EQLS* */
CDKALPHALIST *alphalist = (CDKALPHALIST *)clientData;
CDKSCROLL *scrollp = alphalist->scrollField;
CDKENTRY *entry = alphalist->entryField;
int infoLen = ((entry->info != 0)
? (int)strlen (entry->info)
: 0);
int result = 1;
bool empty = FALSE;
/* Make sure the entry field isn't empty. */
if (entry->info == 0)
{
empty = TRUE;
}
else if (isCDKObjectBind (ObjTypeOf (alphalist), ObjOf (alphalist), input))
{
result = 1; /* don't try to use this key in editing */
}
else if ((isChar (input) &&
(isalnum (CharOf (input)) ||
ispunct (input))) ||
input == KEY_BACKSPACE ||
input == KEY_DC)
{
int Index, difference, absoluteDifference, x;
int currPos = (entry->screenCol + entry->leftChar);
char *pattern = (char *)malloc ((size_t) infoLen + 2);
if (pattern != 0)
{
strcpy (pattern, entry->info);
if (input == KEY_BACKSPACE || input == KEY_DC)
{
if (input == KEY_BACKSPACE)
--currPos;
if (currPos >= 0)
strcpy (pattern + currPos, entry->info + currPos + 1);
}
else
{
pattern[currPos] = (char)input;
strcpy (pattern + currPos + 1, entry->info + currPos);
}
}
if (pattern == 0)
{
Beep ();
}
else if (strlen (pattern) == 0)
{
empty = TRUE;
}
else if ((Index = searchList ((CDK_CSTRING2)alphalist->list,
alphalist->listSize,
pattern)) >= 0)
{
/* *INDENT-EQLS* */
difference = Index - scrollp->currentItem;
absoluteDifference = abs (difference);
/*
* If the difference is less than zero, then move up.
* Otherwise move down.
*
* If the difference is greater than 10 jump to the new
* index position. Otherwise provide the nice scroll.
*/
if (absoluteDifference <= 10)
{
for (x = 0; x < absoluteDifference; x++)
{
injectMyScroller (alphalist,
(chtype)((difference <= 0)
? KEY_UP
: KEY_DOWN));
}
}
else
{
setCDKScrollPosition (scrollp, Index);
}
drawMyScroller (alphalist);
}
else
{
Beep ();
result = 0;
}
if (pattern != 0)
free (pattern);
}
if (empty)
{
setCDKScrollPosition (scrollp, 0);
drawMyScroller (alphalist);
}
return result;
}
/*
* This tries to complete the word in the entry field.
*/
static int completeWordCB (EObjectType objectType GCC_UNUSED, void *object GCC_UNUSED,
void *clientData,
chtype key GCC_UNUSED)
{
/* *INDENT-EQLS* */
CDKALPHALIST *alphalist = (CDKALPHALIST *)clientData;
CDKENTRY *entry = (CDKENTRY *)alphalist->entryField;
CDKSCROLL *scrollp = 0;
int wordLength = 0;
int Index = 0;
int ret = 0;
char **altWords = 0;
if (entry->info == 0)
{
Beep ();
return (TRUE);
}
wordLength = (int)strlen (entry->info);
/* If the word length is equal to zero, just leave. */
if (wordLength == 0)
{
Beep ();
return (TRUE);
}
/* Look for a unique word match. */
Index = searchList ((CDK_CSTRING2)alphalist->list, alphalist->listSize, entry->info);
/* If the index is less than zero, return we didn't find a match. */
if (Index < 0)
{
Beep ();
return (TRUE);
}
/* Did we find the last word in the list? */
if (Index == alphalist->listSize - 1)
{
setCDKEntryValue (entry, alphalist->list[Index]);
drawCDKEntry (entry, ObjOf (entry)->box);
return (TRUE);
}
/* Ok, we found a match, is the next item similar? */
ret = strncmp (alphalist->list[Index + 1], entry->info, (size_t) wordLength);
if (ret == 0)
{
int currentIndex = Index;
int altCount = 0;
unsigned used = 0;
int selected;
int height;
int match;
int x;
/* Start looking for alternate words. */
/* FIXME: bsearch would be more suitable */
while ((currentIndex < alphalist->listSize)
&& (strncmp (alphalist->list[currentIndex],
entry->info,
(size_t) wordLength) == 0))
{
used = CDKallocStrings (&altWords,
alphalist->list[currentIndex++],
(unsigned)altCount++,
used);
}
/* Determine the height of the scrolling list. */
height = (altCount < 8 ? altCount + 3 : 11);
/* Create a scrolling list of close matches. */
scrollp = newCDKScroll (entry->obj.screen,
CENTER, CENTER, RIGHT, height, -30,
"<C></B/5>Possible Matches.",
(CDK_CSTRING2)altWords, altCount,
NUMBERS, A_REVERSE, TRUE, FALSE);
/* Allow them to select a close match. */
match = activateCDKScroll (scrollp, 0);
selected = scrollp->currentItem;
/* Check how they exited the list. */
if (scrollp->exitType == vESCAPE_HIT)
{
/* Destroy the scrolling list. */
destroyCDKScroll (scrollp);
/* Clean up. */
CDKfreeStrings (altWords);
/* Beep at the user. */
Beep ();
/* Redraw the alphalist and return. */
drawCDKAlphalist (alphalist, ObjOf (alphalist)->box);
return (TRUE);
}
/* Destroy the scrolling list. */
destroyCDKScroll (scrollp);
/* Set the entry field to the selected value. */
setCDKEntry (entry,
altWords[match],
entry->min,
entry->max,
ObjOf (entry)->box);
/* Move the highlight bar down to the selected value. */
for (x = 0; x < selected; x++)
{
injectMyScroller (alphalist, KEY_DOWN);
}
/* Clean up. */
CDKfreeStrings (altWords);
/* Redraw the alphalist. */
drawCDKAlphalist (alphalist, ObjOf (alphalist)->box);
}
else
{
/* Set the entry field with the found item. */
setCDKEntry (entry,
alphalist->list[Index],
entry->min,
entry->max,
ObjOf (entry)->box);
drawCDKEntry (entry, ObjOf (entry)->box);
}
return (TRUE);
}
static int createList (CDKALPHALIST *alphalist, CDK_CSTRING *list, int listSize)
{
int status = 0;
if (listSize >= 0)
{
char **newlist = typeCallocN (char *, listSize + 1);
if (newlist != 0)
{
int x;
/*
* We'll sort the list before we use it. It would have been better to
* declare list[] const and only modify the copy, but there may be
* clients that rely on the old behavior.
*/
sortList (list, listSize);
/* Copy in the new information. */
status = 1;
for (x = 0; x < listSize; x++)
{
if ((newlist[x] = copyChar (list[x])) == 0)
{
status = 0;
break;
}
}
if (status)
{
destroyInfo (alphalist);
alphalist->listSize = listSize;
alphalist->list = newlist;
}
else
{
CDKfreeStrings (newlist);
}
}
}
else
{
destroyInfo (alphalist);
status = TRUE;
}
return status;
}
static void _focusCDKAlphalist (CDKOBJS *object)
{
CDKALPHALIST *widget = (CDKALPHALIST *)object;
FocusObj (ObjOf (widget->entryField));
}
static void _unfocusCDKAlphalist (CDKOBJS *object)
{
CDKALPHALIST *widget = (CDKALPHALIST *)object;
UnfocusObj (ObjOf (widget->entryField));
}
dummyRefreshData (Alphalist)
dummySaveData (Alphalist)

230
deps/cdk-5.0-20161210/binding.c vendored Normal file
View File

@ -0,0 +1,230 @@
#include <cdk_int.h>
/*
* $Author: tom $
* $Date: 2011/05/16 22:36:08 $
* $Revision: 1.56 $
*
* Notes:
*
* The cdktype parameter passed to bindCDKObject, etc., is redundant since
* the object parameter also has the same information. For compatibility
* just use it for a sanity check.
*/
#ifndef KEY_MAX
#define KEY_MAX 512
#endif
static CDKOBJS *bindableObject (EObjectType * cdktype, void *object)
{
CDKOBJS *obj = (CDKOBJS *)object;
if (obj != 0 && *cdktype == ObjTypeOf (obj))
{
if (*cdktype == vFSELECT)
{
*cdktype = vENTRY;
object = ((CDKFSELECT *)object)->entryField;
}
else if (*cdktype == vALPHALIST)
{
*cdktype = vENTRY;
object = ((CDKALPHALIST *)object)->entryField;
}
}
else
{
object = 0;
}
return (CDKOBJS *)object;
}
/*
* This inserts a binding.
*/
void bindCDKObject (EObjectType cdktype,
void *object,
chtype key,
BINDFN function,
void *data)
{
CDKOBJS *obj = bindableObject (&cdktype, object);
if ((key < KEY_MAX) && obj != 0)
{
if (key != 0 && (unsigned)key >= obj->bindingCount)
{
unsigned next = (unsigned) (key + 1);
if (obj->bindingList != 0)
obj->bindingList = typeReallocN (CDKBINDING, obj->bindingList, next);
else
obj->bindingList = typeMallocN (CDKBINDING, next);
memset (&(obj->bindingList[obj->bindingCount]), 0,
(next - obj->bindingCount) * sizeof (CDKBINDING));
obj->bindingCount = next;
}
if (obj->bindingList != 0)
{
obj->bindingList[key].bindFunction = function;
obj->bindingList[key].bindData = data;
}
}
}
/*
* This removes a binding on an object.
*/
void unbindCDKObject (EObjectType cdktype, void *object, chtype key)
{
CDKOBJS *obj = bindableObject (&cdktype, object);
if (obj != 0 && ((unsigned)key < obj->bindingCount))
{
obj->bindingList[key].bindFunction = 0;
obj->bindingList[key].bindData = 0;
}
}
/*
* This removes all the bindings for the given objects.
*/
void cleanCDKObjectBindings (EObjectType cdktype, void *object)
{
CDKOBJS *obj = bindableObject (&cdktype, object);
if (obj != 0 && obj->bindingList != 0)
{
unsigned x;
for (x = 0; x < obj->bindingCount; x++)
{
(obj)->bindingList[x].bindFunction = 0;
(obj)->bindingList[x].bindData = 0;
}
freeAndNull ((obj)->bindingList);
}
}
/*
* This checks to see if the binding for the key exists:
* If it does then it runs the command and returns its value, normally TRUE.
* If it doesn't it returns a FALSE. This way we can 'overwrite' coded
* bindings.
*/
int checkCDKObjectBind (EObjectType cdktype, void *object, chtype key)
{
CDKOBJS *obj = bindableObject (&cdktype, object);
if (obj != 0 && ((unsigned)key < obj->bindingCount))
{
if ((obj)->bindingList[key].bindFunction != 0)
{
BINDFN function = obj->bindingList[key].bindFunction;
void *data = obj->bindingList[key].bindData;
return function (cdktype, object, data, key);
}
}
return (FALSE);
}
/*
* This checks to see if the binding for the key exists.
*/
bool isCDKObjectBind (EObjectType cdktype, void *object, chtype key)
{
bool result = FALSE;
CDKOBJS *obj = bindableObject (&cdktype, object);
if (obj != 0 && ((unsigned)key < obj->bindingCount))
{
if ((obj)->bindingList[key].bindFunction != 0)
result = TRUE;
}
return (result);
}
/*
* This is a dummy function used to ensure that the constant for mapping has
* a distinct address.
*/
int getcCDKBind (EObjectType cdktype GCC_UNUSED,
void *object GCC_UNUSED,
void *clientData GCC_UNUSED,
chtype input GCC_UNUSED)
{
return 0;
}
/*
* Read from the input window, filtering keycodes as needed.
*/
int getcCDKObject (CDKOBJS *obj)
{
EObjectType cdktype = ObjTypeOf (obj);
CDKOBJS *test = bindableObject (&cdktype, obj);
int result = wgetch (InputWindowOf (obj));
if (result >= 0
&& test != 0
&& (unsigned)result < test->bindingCount
&& test->bindingList[result].bindFunction == getcCDKBind)
{
result = (int)(long)test->bindingList[result].bindData;
}
else if (test == 0
|| (unsigned)result >= test->bindingCount
|| test->bindingList[result].bindFunction == 0)
{
switch (result)
{
case '\r':
case '\n':
result = KEY_ENTER;
break;
case '\t':
result = KEY_TAB;
break;
case DELETE:
result = KEY_DC;
break;
case '\b': /* same as CTRL('H'), for ASCII */
result = KEY_BACKSPACE;
break;
case CDK_BEGOFLINE:
result = KEY_HOME;
break;
case CDK_ENDOFLINE:
result = KEY_END;
break;
case CDK_FORCHAR:
result = KEY_RIGHT;
break;
case CDK_BACKCHAR:
result = KEY_LEFT;
break;
case CDK_NEXT:
result = KEY_TAB;
break;
case CDK_PREV:
result = KEY_BTAB;
break;
}
}
return result;
}
/*
* Use this function rather than getcCDKObject(), since we can extend it to
* handle wide-characters.
*/
int getchCDKObject (CDKOBJS *obj, boolean *functionKey)
{
int key = getcCDKObject (obj);
*functionKey = (key >= KEY_MIN && key <= KEY_MAX);
return key;
}

572
deps/cdk-5.0-20161210/button.c vendored Normal file
View File

@ -0,0 +1,572 @@
#include <cdk_int.h>
#include "button.h"
#include <limits.h>
/*
* $Author: Aarian.P.Aleahmad $
* $Date: 2016/01/31 20:32:25 $
* $Revision: 1.38 $
*/
DeclareCDKObjects (BUTTON, Button, setCdk, Int);
/*
* This creates a button widget.
*/
CDKBUTTON *newCDKButton (CDKSCREEN *cdkscreen,
int xplace,
int yplace,
const char *text,
tButtonCallback callback,
boolean Box,
boolean shadow)
{
/* *INDENT-EQLS* */
CDKBUTTON *button = 0;
int parentWidth = getmaxx (cdkscreen->window);
int parentHeight = getmaxy (cdkscreen->window);
int boxWidth = 0;
int boxHeight;
int xpos = xplace;
int ypos = yplace;
if ((button = newCDKObject (CDKBUTTON, &my_funcs)) == 0)
return (0);
setCDKButtonBox (button, Box);
boxHeight = 1 + 2 * BorderOf (button);
/* Translate the char * to a chtype. */
button->info = char2Chtype (text, &button->infoLen, &button->infoPos);
boxWidth = MAXIMUM (boxWidth, button->infoLen) + 2 * BorderOf (button);
/* Create the string alignments. */
button->infoPos = justifyString (boxWidth - 2 * BorderOf (button),
button->infoLen, button->infoPos);
/*
* Make sure we didn't extend beyond the dimensions of the window.
*/
boxWidth = (boxWidth > parentWidth ? parentWidth : boxWidth);
boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight);
/* Rejustify the x and y positions if we need to. */
alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
/* *INDENT-EQLS* Create the button. */
ScreenOf (button) = cdkscreen;
ObjOf (button)->fn = &my_funcs;
button->parent = cdkscreen->window;
button->win = newwin (boxHeight, boxWidth, ypos, xpos);
button->shadowWin = (WINDOW *)NULL;
button->xpos = xpos;
button->ypos = ypos;
button->boxWidth = boxWidth;
button->boxHeight = boxHeight;
button->callback = callback;
button->callbackData = NULL;
ObjOf (button)->inputWindow = button->win;
ObjOf (button)->acceptsFocus = TRUE;
initExitType (button);
button->shadow = shadow;
button->highlight = A_REVERSE;
/* Is the window NULL? */
if (button->win == (WINDOW *)NULL)
{
destroyCDKObject (button);
return (0);
}
keypad (button->win, TRUE);
/* If a shadow was requested, then create the shadow window. */
if (shadow)
button->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
/* Register this baby. */
registerCDKObject (cdkscreen, vBUTTON, button);
/* Return the button pointer. */
return (button);
}
/*
* This was added for the builder.
*/
int activateCDKButton (CDKBUTTON *button, chtype *actions)
{
chtype input = 0;
boolean functionKey;
int ret;
drawCDKButton (button, ObjOf (button)->box);
if (actions == 0)
{
for (;;)
{
input = (chtype)getchCDKObject (ObjOf (button), &functionKey);
/* Inject the character into the widget. */
ret = injectCDKButton (button, input);
if (button->exitType != vEARLY_EXIT)
{
return ret;
}
}
}
else
{
int length = chlen (actions);
int x = 0;
/* Inject each character one at a time. */
for (x = 0; x < length; x++)
{
ret = injectCDKButton (button, actions[x]);
if (button->exitType != vEARLY_EXIT)
{
return ret;
}
}
}
/* Set the exit type and exit. */
setExitType (button, 0);
return -1;
}
/*
* This sets multiple attributes of the widget.
*/
void setCDKButton (CDKBUTTON *button, const char *mesg, boolean Box)
{
setCDKButtonMessage (button, mesg);
setCDKButtonBox (button, Box);
}
/*
* This sets the information within the button.
*/
void setCDKButtonMessage (CDKBUTTON *button, const char *info)
{
/* Clean out the old message. */
freeChtype (button->info);
button->infoPos = 0;
button->infoLen = 0;
/* Copy in the new message. */
button->info = char2Chtype (info, &button->infoLen, &button->infoPos);
button->infoPos = justifyString (button->boxWidth - 2 * BorderOf (button),
button->infoLen, button->infoPos);
/* Redraw the button widget. */
eraseCDKButton (button);
drawCDKButton (button, ObjOf (button)->box);
}
chtype *getCDKButtonMessage (CDKBUTTON *button)
{
return button->info;
}
/*
* This sets the box flag for the button widget.
*/
void setCDKButtonBox (CDKBUTTON *button, boolean Box)
{
ObjOf (button)->box = Box;
ObjOf (button)->borderSize = Box ? 1 : 0;
}
boolean getCDKButtonBox (CDKBUTTON *button)
{
return ObjOf (button)->box;
}
/*
* This sets the background attribute of the widget.
*/
static void _setBKattrButton (CDKOBJS *object, chtype attrib)
{
if (object != 0)
{
CDKBUTTON *widget = (CDKBUTTON *)object;
wbkgd (widget->win, attrib);
}
}
static void drawCDKButtonText (CDKBUTTON *button)
{
int boxWidth = button->boxWidth;
int i;
/* Draw in the message. */
for (i = 0; i < boxWidth - 2 * BorderOf (button); i++)
{
chtype c;
int pos = button->infoPos;
int len = button->infoLen;
if (i >= pos && (i - pos) < len)
c = button->info[i - pos];
else
c = ' ';
if (HasFocusObj (button))
{
c = button->highlight | CharOf (c);
}
(void)mvwaddch (button->win, BorderOf (button), i + BorderOf (button), c);
}
}
/*
* This draws the button widget.
*/
static void _drawCDKButton (CDKOBJS *object, boolean Box GCC_UNUSED)
{
CDKBUTTON *button = (CDKBUTTON *)object;
/* Is there a shadow? */
if (button->shadowWin != (WINDOW *)NULL)
{
drawShadow (button->shadowWin);
}
/* Box the widget if asked. */
if (ObjOf (button)->box)
{
drawObjBox (button->win, ObjOf (button));
}
drawCDKButtonText (button);
wrefresh (button->win);
}
/*
* This erases the button widget.
*/
static void _eraseCDKButton (CDKOBJS *object)
{
if (validCDKObject (object))
{
CDKBUTTON *button = (CDKBUTTON *)object;
eraseCursesWindow (button->win);
eraseCursesWindow (button->shadowWin);
}
}
/*
* This moves the button field to the given location.
*/
static void _moveCDKButton (CDKOBJS *object,
int xplace,
int yplace,
boolean relative,
boolean refresh_flag)
{
CDKBUTTON *button = (CDKBUTTON *)object;
int currentX = getbegx (button->win);
int currentY = getbegy (button->win);
int xpos = xplace;
int ypos = yplace;
int xdiff = 0;
int ydiff = 0;
/*
* If this is a relative move, then we will adjust where we want
* to move to.
*/
if (relative)
{
xpos = getbegx (button->win) + xplace;
ypos = getbegy (button->win) + yplace;
}
/* Adjust the window if we need to. */
alignxy (WindowOf (button), &xpos, &ypos, button->boxWidth,
button->boxHeight);
/* Get the difference. */
xdiff = currentX - xpos;
ydiff = currentY - ypos;
/* Move the window to the new location. */
moveCursesWindow (button->win, -xdiff, -ydiff);
moveCursesWindow (button->shadowWin, -xdiff, -ydiff);
/* Touch the windows so they 'move'. */
refreshCDKWindow (WindowOf (button));
/* Redraw the window, if they asked for it. */
if (refresh_flag)
{
drawCDKButton (button, ObjOf (button)->box);
}
}
/*
* This allows the user to use the cursor keys to adjust the
* position of the widget.
*/
void positionCDKButton (CDKBUTTON *button)
{
/* Declare some variables. */
int origX = getbegx (button->win);
int origY = getbegy (button->win);
chtype key = (chtype)0;
boolean functionKey;
/* Let them move the widget around until they hit return. */
while (key != KEY_ENTER)
{
key = (chtype)getchCDKObject (ObjOf (button), &functionKey);
if (key == KEY_UP || key == '8')
{
if (getbegy (button->win) > 0)
{
moveCDKButton (button, 0, -1, TRUE, TRUE);
}
else
{
Beep ();
}
}
else if (key == KEY_DOWN || key == '2')
{
if (getbegy (button->win) + getmaxy (button->win) <
getmaxy (WindowOf (button)) - 1)
{
moveCDKButton (button, 0, 1, TRUE, TRUE);
}
else
{
Beep ();
}
}
else if (key == KEY_LEFT || key == '4')
{
if (getbegx (button->win) > 0)
{
moveCDKButton (button, -1, 0, TRUE, TRUE);
}
else
{
Beep ();
}
}
else if (key == KEY_RIGHT || key == '6')
{
if (getbegx (button->win) + getmaxx (button->win) < getmaxx
(WindowOf (button)) - 1)
{
moveCDKButton (button, 1, 0, TRUE, TRUE);
}
else
{
Beep ();
}
}
else if (key == '7')
{
if (getbegy (button->win) > 0 && getbegx (button->win) > 0)
{
moveCDKButton (button, -1, -1, TRUE, TRUE);
}
else
{
Beep ();
}
}
else if (key == '9')
{
if (getbegx (button->win) + getmaxx (button->win) < getmaxx
(WindowOf (button)) - 1 &&
getbegy (button->win) > 0)
{
moveCDKButton (button, 1, -1, TRUE, TRUE);
}
else
{
Beep ();
}
}
else if (key == '1')
{
if (getbegx (button->win) > 0 && getbegx (button->win) +
getmaxx (button->win) < getmaxx (WindowOf (button)) - 1)
{
moveCDKButton (button, -1, 1, TRUE, TRUE);
}
else
{
Beep ();
}
}
else if (key == '3')
{
if (getbegx (button->win) + getmaxx (button->win) <
getmaxx (WindowOf (button)) - 1
&& getbegy (button->win) + getmaxy (button->win) <
getmaxy (WindowOf (button)) - 1)
{
moveCDKButton (button, 1, 1, TRUE, TRUE);
}
else
{
Beep ();
}
}
else if (key == '5')
{
moveCDKButton (button, CENTER, CENTER, FALSE, TRUE);
}
else if (key == 't')
{
moveCDKButton (button, getbegx (button->win), TOP, FALSE, TRUE);
}
else if (key == 'b')
{
moveCDKButton (button, getbegx (button->win), BOTTOM, FALSE, TRUE);
}
else if (key == 'l')
{
moveCDKButton (button, LEFT, getbegy (button->win), FALSE, TRUE);
}
else if (key == 'r')
{
moveCDKButton (button, RIGHT, getbegy (button->win), FALSE, TRUE);
}
else if (key == 'c')
{
moveCDKButton (button, CENTER, getbegy (button->win), FALSE, TRUE);
}
else if (key == 'C')
{
moveCDKButton (button, getbegx (button->win), CENTER, FALSE, TRUE);
}
else if (key == CDK_REFRESH)
{
eraseCDKScreen (ScreenOf (button));
refreshCDKScreen (ScreenOf (button));
}
else if (key == KEY_ESC)
{
moveCDKButton (button, origX, origY, FALSE, TRUE);
}
else if (key != KEY_ENTER)
{
Beep ();
}
}
}
/*
* This destroys the button object pointer.
*/
static void _destroyCDKButton (CDKOBJS *object)
{
if (object != 0)
{
CDKBUTTON *button = (CDKBUTTON *)object;
/* Free up the character pointers. */
freeChtype (button->info);
/* Free up the window pointers. */
deleteCursesWindow (button->shadowWin);
deleteCursesWindow (button->win);
/* Clean the key bindings. */
cleanCDKObjectBindings (vBUTTON, button);
/* Unregister the object. */
unregisterCDKObject (vBUTTON, button);
}
}
/*
* This injects a single character into the widget.
*/
static int _injectCDKButton (CDKOBJS *object, chtype input)
{
CDKBUTTON *widget = (CDKBUTTON *)object;
int ret = unknownInt;
bool complete = FALSE;
setExitType (widget, 0);
/* Check a predefined binding. */
if (checkCDKObjectBind (vBUTTON, widget, input) != 0)
{
checkEarlyExit (widget);
complete = TRUE;
}
else
{
switch (input)
{
case KEY_ESC:
setExitType (widget, input);
complete = TRUE;
break;
case KEY_ERROR:
setExitType (widget, input);
complete = TRUE;
break;
case KEY_ENTER:
case SPACE:
if (widget->callback)
widget->callback (widget);
setExitType (widget, KEY_ENTER);
ret = 0;
complete = TRUE;
break;
case CDK_REFRESH:
eraseCDKScreen (ScreenOf (widget));
refreshCDKScreen (ScreenOf (widget));
break;
default:
Beep ();
break;
}
}
if (!complete)
{
setExitType (widget, 0);
}
ResultOf (widget).valueInt = ret;
return (ret != unknownInt);
}
static void _focusCDKButton (CDKOBJS *object)
{
CDKBUTTON *button = (CDKBUTTON *)object;
drawCDKButtonText (button);
wrefresh (button->win);
}
static void _unfocusCDKButton (CDKOBJS *object)
{
CDKBUTTON *button = (CDKBUTTON *)object;
drawCDKButtonText (button);
wrefresh (button->win);
}
dummyRefreshData (Button)
dummySaveData (Button)

590
deps/cdk-5.0-20161210/buttonbox.c vendored Normal file
View File

@ -0,0 +1,590 @@
#include <cdk_int.h>
/*
* $Author: tom $
* $Date: 2016/11/20 18:41:25 $
* $Revision: 1.68 $
*/
DeclareCDKObjects (BUTTONBOX, Buttonbox, setCdk, Int);
/*
* This returns a CDK buttonbox widget pointer.
*/
CDKBUTTONBOX *newCDKButtonbox (CDKSCREEN *cdkscreen,
int xPos,
int yPos,
int height,
int width,
const char *title,
int rows,
int cols,
CDK_CSTRING2 buttons,
int buttonCount,
chtype highlight,
boolean Box,
boolean shadow)
{
/* *INDENT-EQLS* */
CDKBUTTONBOX *buttonbox = 0;
int parentWidth = getmaxx (cdkscreen->window);
int parentHeight = getmaxy (cdkscreen->window);
int boxWidth = 0;
int boxHeight = 0;
int maxColWidth = INT_MIN;
int colWidth = 0;
int xpos = xPos;
int ypos = yPos;
int currentButton = 0;
int x, y, junk;
if (buttonCount <= 0
|| (buttonbox = newCDKObject (CDKBUTTONBOX, &my_funcs)) == 0
|| (buttonbox->button = typeCallocN (chtype *, buttonCount + 1)) == 0
|| (buttonbox->buttonLen = typeCallocN (int, buttonCount + 1)) == 0
|| (buttonbox->buttonPos = typeCallocN (int, buttonCount + 1)) == 0
|| (buttonbox->columnWidths = typeCallocN (int, buttonCount + 1)) == 0)
{
destroyCDKObject (buttonbox);
return (0);
}
setCDKButtonboxBox (buttonbox, Box);
/* Set some default values for the widget. */
buttonbox->rowAdjust = 0;
buttonbox->colAdjust = 0;
/*
* If the height is a negative value, the height will
* be ROWS-height, otherwise, the height will be the
* given height.
*/
boxHeight = setWidgetDimension (parentHeight, height, rows + 1);
/*
* If the width is a negative value, the width will
* be COLS-width, otherwise, the width will be the
* given width.
*/
boxWidth = setWidgetDimension (parentWidth, width, 0);
boxWidth = setCdkTitle (ObjOf (buttonbox), title, boxWidth);
/* Translate the buttons char * to a chtype * */
for (x = 0; x < buttonCount; x++)
{
buttonbox->button[x] = char2Chtype (buttons[x],
&buttonbox->buttonLen[x],
&junk);
}
/* Set the button positions. */
for (x = 0; x < cols; x++)
{
maxColWidth = INT_MIN;
/* Look for the widest item in this column. */
for (y = 0; y < rows; y++)
{
if (currentButton < buttonCount)
{
maxColWidth = MAXIMUM (buttonbox->buttonLen[currentButton], maxColWidth);
currentButton++;
}
}
/* Keep the maximum column width for this column. */
buttonbox->columnWidths[x] = maxColWidth;
colWidth += maxColWidth;
}
boxWidth++;
/*
* Make sure we didn't extend beyond the dimensions of the window.
*/
boxWidth = (boxWidth > parentWidth ? parentWidth : boxWidth);
boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight);
/* Now we have to readjust the x and y positions. */
alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
/* *INDENT-EQLS* Set up the buttonbox box attributes. */
ScreenOf (buttonbox) = cdkscreen;
buttonbox->parent = cdkscreen->window;
buttonbox->win = newwin (boxHeight, boxWidth, ypos, xpos);
buttonbox->shadowWin = 0;
buttonbox->buttonCount = buttonCount;
buttonbox->currentButton = 0;
buttonbox->rows = rows;
buttonbox->cols = (buttonCount < cols ? buttonCount : cols);
buttonbox->boxHeight = boxHeight;
buttonbox->boxWidth = boxWidth;
buttonbox->highlight = highlight;
initExitType (buttonbox);
ObjOf (buttonbox)->acceptsFocus = TRUE;
ObjOf (buttonbox)->inputWindow = buttonbox->win;
buttonbox->shadow = shadow;
buttonbox->ButtonAttrib = A_NORMAL;
/* Set up the row adjustment. */
if (boxHeight - rows - TitleLinesOf (buttonbox) > 0)
{
buttonbox->rowAdjust = (int)((boxHeight
- rows
- TitleLinesOf (buttonbox)) / buttonbox->rows);
}
/* Set the col adjustment. */
if (boxWidth - colWidth > 0)
{
buttonbox->colAdjust = (int)((boxWidth - colWidth)
/ buttonbox->cols) - 1;
}
/* If we couldn't create the window, we should return a null value. */
if (buttonbox->win == 0)
{
destroyCDKObject (buttonbox);
return (0);
}
keypad (buttonbox->win, TRUE);
/* Was there a shadow? */
if (shadow)
{
buttonbox->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
}
/* Register this baby. */
registerCDKObject (cdkscreen, vBUTTONBOX, buttonbox);
/* Return the buttonbox box pointer. */
return (buttonbox);
}
/*
* This activates the widget.
*/
int activateCDKButtonbox (CDKBUTTONBOX *buttonbox, chtype *actions)
{
chtype input = 0;
boolean functionKey;
int ret;
/* Draw the buttonbox box. */
drawCDKButtonbox (buttonbox, ObjOf (buttonbox)->box);
if (actions == 0)
{
for (;;)
{
input = (chtype)getchCDKObject (ObjOf (buttonbox), &functionKey);
/* Inject the character into the widget. */
ret = injectCDKButtonbox (buttonbox, input);
if (buttonbox->exitType != vEARLY_EXIT)
{
return ret;
}
}
}
else
{
int length = chlen (actions);
int x = 0;
/* Inject each character one at a time. */
for (x = 0; x < length; x++)
{
ret = injectCDKButtonbox (buttonbox, actions[x]);
if (buttonbox->exitType != vEARLY_EXIT)
{
return ret;
}
}
}
/* Set the exit type and exit. */
setExitType (buttonbox, 0);
return -1;
}
/*
* This injects a single character into the widget.
*/
static int _injectCDKButtonbox (CDKOBJS *object, chtype input)
{
/* *INDENT-EQLS* */
CDKBUTTONBOX *widget = (CDKBUTTONBOX *)object;
int lastButton = widget->buttonCount - 1;
int ppReturn = 1;
int ret = unknownInt;
bool complete = FALSE;
/* Set the exit type. */
setExitType (widget, 0);
/* Check if there is a pre-process function to be called. */
if (PreProcessFuncOf (widget) != 0)
{
ppReturn = PreProcessFuncOf (widget) (vBUTTONBOX,
widget,
PreProcessDataOf (widget),
input);
}
/* Should we continue? */
if (ppReturn != 0)
{
/* Check for a key binding. */
if (checkCDKObjectBind (vBUTTONBOX, widget, input) != 0)
{
checkEarlyExit (widget);
complete = TRUE;
}
else
{
int firstButton = 0;
switch (input)
{
case KEY_LEFT:
case KEY_BTAB:
case KEY_BACKSPACE:
if ((widget->currentButton - widget->rows) < firstButton)
{
widget->currentButton = lastButton;
}
else
{
widget->currentButton -= widget->rows;
}
break;
case KEY_RIGHT:
case KEY_TAB:
case SPACE:
if ((widget->currentButton + widget->rows) > lastButton)
{
widget->currentButton = firstButton;
}
else
{
widget->currentButton += widget->rows;
}
break;
case KEY_UP:
if ((widget->currentButton - 1) < firstButton)
{
widget->currentButton = lastButton;
}
else
{
widget->currentButton--;
}
break;
case KEY_DOWN:
if ((widget->currentButton + 1) > lastButton)
{
widget->currentButton = firstButton;
}
else
{
widget->currentButton++;
}
break;
case CDK_REFRESH:
eraseCDKScreen (ScreenOf (widget));
refreshCDKScreen (ScreenOf (widget));
break;
case KEY_ESC:
setExitType (widget, input);
complete = TRUE;
break;
case KEY_ERROR:
setExitType (widget, input);
complete = TRUE;
break;
case KEY_ENTER:
setExitType (widget, input);
ret = widget->currentButton;
complete = TRUE;
break;
default:
break;
}
}
/* Should we call a post-process? */
if (!complete && (PostProcessFuncOf (widget) != 0))
{
PostProcessFuncOf (widget) (vBUTTONBOX,
widget,
PostProcessDataOf (widget),
input);
}
}
if (!complete)
{
drawCDKButtonboxButtons (widget);
setExitType (widget, 0);
}
ResultOf (widget).valueInt = ret;
return (ret != unknownInt);
}
/*
* This sets multiple attributes of the widget.
*/
void setCDKButtonbox (CDKBUTTONBOX *buttonbox, chtype highlight, boolean Box)
{
setCDKButtonboxHighlight (buttonbox, highlight);
setCDKButtonboxBox (buttonbox, Box);
}
/*
* This sets the highlight attribute for the buttonboxs.
*/
void setCDKButtonboxHighlight (CDKBUTTONBOX *buttonbox, chtype highlight)
{
buttonbox->highlight = highlight;
}
chtype getCDKButtonboxHighlight (CDKBUTTONBOX *buttonbox)
{
return (chtype)buttonbox->highlight;
}
/*
* This sets the box attribute of the widget.
*/
void setCDKButtonboxBox (CDKBUTTONBOX *buttonbox, boolean Box)
{
ObjOf (buttonbox)->box = Box;
ObjOf (buttonbox)->borderSize = Box ? 1 : 0;
}
boolean getCDKButtonboxBox (CDKBUTTONBOX *buttonbox)
{
return ObjOf (buttonbox)->box;
}
/*
* This sets the background attribute of the widget.
*/
static void _setBKattrButtonbox (CDKOBJS *object, chtype attrib)
{
if (object != 0)
{
CDKBUTTONBOX *widget = (CDKBUTTONBOX *)object;
wbkgd (widget->win, attrib);
}
}
/*
* This draws the buttonbox box widget.
*/
static void _drawCDKButtonbox (CDKOBJS *object, boolean Box)
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)object;
/* Is there a shadow? */
if (buttonbox->shadowWin != 0)
{
drawShadow (buttonbox->shadowWin);
}
/* Box the widget if they asked. */
if (Box)
{
drawObjBox (buttonbox->win, ObjOf (buttonbox));
}
/* Draw in the title if there is one. */
drawCdkTitle (buttonbox->win, object);
/* Draw in the buttons. */
drawCDKButtonboxButtons (buttonbox);
}
/*
* This draws the buttons on the button box widget.
*/
void drawCDKButtonboxButtons (CDKBUTTONBOX *buttonbox)
{
/* *INDENT-EQLS* */
int row;
int col = (int)(buttonbox->colAdjust / 2);
int currentButton = 0;
int x, y;
int cur_row = -1;
int cur_col = -1;
/* Draw the buttons. */
while (currentButton < buttonbox->buttonCount)
{
for (x = 0; x < buttonbox->cols; x++)
{
row = TitleLinesOf (buttonbox) + BorderOf (buttonbox);
for (y = 0; y < buttonbox->rows; y++)
{
chtype attr = buttonbox->ButtonAttrib;
if (currentButton == buttonbox->currentButton)
{
attr = buttonbox->highlight,
cur_row = row;
cur_col = col;
}
writeChtypeAttrib (buttonbox->win,
col, row,
buttonbox->button[currentButton],
attr,
HORIZONTAL, 0,
buttonbox->buttonLen[currentButton]);
row += (1 + buttonbox->rowAdjust);
currentButton++;
}
col += buttonbox->columnWidths[x] + buttonbox->colAdjust + BorderOf (buttonbox);
}
}
if (cur_row >= 0 && cur_col >= 0)
wmove (buttonbox->win, cur_row, cur_col);
wrefresh (buttonbox->win);
}
/*
* This erases the buttonbox box from the screen.
*/
static void _eraseCDKButtonbox (CDKOBJS *object)
{
if (validCDKObject (object))
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)object;
eraseCursesWindow (buttonbox->win);
eraseCursesWindow (buttonbox->shadowWin);
}
}
/*
* This moves the buttonbox box to a new screen location.
*/
static void _moveCDKButtonbox (CDKOBJS *object,
int xplace,
int yplace,
boolean relative,
boolean refresh_flag)
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)object;
/* *INDENT-EQLS* */
int currentX = getbegx (buttonbox->win);
int currentY = getbegy (buttonbox->win);
int xpos = xplace;
int ypos = yplace;
int xdiff = 0;
int ydiff = 0;
/*
* If this is a relative move, then we will adjust where we want
* to move to.
*/
if (relative)
{
xpos = getbegx (buttonbox->win) + xplace;
ypos = getbegy (buttonbox->win) + yplace;
}
/* Adjust the window if we need to. */
alignxy (WindowOf (buttonbox), &xpos, &ypos, buttonbox->boxWidth, buttonbox->boxHeight);
/* Get the difference. */
xdiff = currentX - xpos;
ydiff = currentY - ypos;
/* Move the window to the new location. */
moveCursesWindow (buttonbox->win, -xdiff, -ydiff);
moveCursesWindow (buttonbox->shadowWin, -xdiff, -ydiff);
/* Touch the windows so they 'move'. */
refreshCDKWindow (WindowOf (buttonbox));
/* Redraw the window, if they asked for it. */
if (refresh_flag)
{
drawCDKButtonbox (buttonbox, ObjOf (buttonbox)->box);
}
}
/*
* This destroys the widget and all the memory associated with it.
*/
static void _destroyCDKButtonbox (CDKOBJS *object)
{
if (object != 0)
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)object;
cleanCdkTitle (object);
CDKfreeChtypes (buttonbox->button);
freeChecked (buttonbox->buttonLen);
freeChecked (buttonbox->buttonPos);
freeChecked (buttonbox->columnWidths);
/* Delete the windows. */
deleteCursesWindow (buttonbox->shadowWin);
deleteCursesWindow (buttonbox->win);
/* Clean the key bindings. */
cleanCDKObjectBindings (vBUTTONBOX, buttonbox);
/* Unregister this object. */
unregisterCDKObject (vBUTTONBOX, buttonbox);
}
}
/*
*
*/
void setCDKButtonboxCurrentButton (CDKBUTTONBOX *buttonbox, int button)
{
if ((button >= 0) && (button < buttonbox->buttonCount))
{
buttonbox->currentButton = button;
}
}
int getCDKButtonboxCurrentButton (CDKBUTTONBOX *buttonbox)
{
return buttonbox->currentButton;
}
int getCDKButtonboxButtonCount (CDKBUTTONBOX *buttonbox)
{
return buttonbox->buttonCount;
}
static void _focusCDKButtonbox (CDKOBJS *object)
{
CDKBUTTONBOX *widget = (CDKBUTTONBOX *)object;
drawCDKButtonbox (widget, ObjOf (widget)->box);
}
static void _unfocusCDKButtonbox (CDKOBJS *object)
{
CDKBUTTONBOX *widget = (CDKBUTTONBOX *)object;
drawCDKButtonbox (widget, ObjOf (widget)->box);
}
dummyRefreshData (Buttonbox)
dummySaveData (Buttonbox)

30
deps/cdk-5.0-20161210/c++/cdkscreen.cc vendored Normal file
View File

@ -0,0 +1,30 @@
#include "cdkscreen.h"
CDKScreen::CDKScreen()
{
cdkscreen = initCDKScreen(NULL);
// Now, set up color.
initCDKColor();
}
CDKScreen::~CDKScreen()
{
destroyCDKScreen(cdkscreen);
endCDK();
}
CDKSCREEN *CDKScreen::screen(void)
{
return cdkscreen;
}
void CDKScreen::refreshscr(void)
{
refreshCDKScreen(cdkscreen);
}
void CDKScreen::erasescr(void)
{
eraseCDKScreen(cdkscreen);
}

30
deps/cdk-5.0-20161210/c++/cdkscreen.h vendored Normal file
View File

@ -0,0 +1,30 @@
#ifndef CDKSCREEN_H
#define CDK_SCREEN_H
extern "C"
{
#include <cdk.h>
}
class CDKScreen
{
// The window which curses uses.
WINDOW *cursesWin;
// The CDKSCREEN struct assigned to this object.
CDKSCREEN *cdkscreen;
public:
// Constructor.
CDKScreen();
// Deconstructor.
~CDKScreen();
// Return a pointer to the CDKScreen structure.
CDKSCREEN *screen(void);
// Refresh the screen.
// Note, this function is renamed to avoid clashing with the refresh() macro.
void refreshscr(void);
// Erase, but don't destroy, all widgets.
// Note, this function is renamed to avoid clashing with the erase() macro.
void erasescr(void);
};
#endif

1181
deps/cdk-5.0-20161210/calendar.c vendored Normal file

File diff suppressed because it is too large Load Diff

136
deps/cdk-5.0-20161210/cdk-config.in vendored Normal file
View File

@ -0,0 +1,136 @@
#!@SHELL@
# $Id: cdk-config.in,v 1.5 2015/01/04 01:45:59 tom Exp $
##############################################################################
# Copyright (c) 2007-2013,2015 Thomas E. Dickey #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
# to deal in the Software without restriction, including without limitation #
# the rights to use, copy, modify, merge, publish, distribute, distribute #
# with modifications, sublicense, and/or sell copies of the Software, and to #
# permit persons to whom the Software is furnished to do so, subject to the #
# following conditions: #
# #
# The above copyright notice and this permission notice shall be included in #
# all copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
# DEALINGS IN THE SOFTWARE. #
# #
# Except as contained in this notice, the name(s) of the above copyright #
# holders shall not be used in advertising or otherwise to promote the sale, #
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
prefix="@prefix@"
exec_prefix="@exec_prefix@"
bindir="@bindir@"
libdir="@libdir@"
datarootdir="@datarootdir@"
datadir="@datadir@"
mandir="@mandir@"
includedir="@includedir@"
THIS="@CFG_ROOTNAME@"
XHDR="@HDR_ROOTNAME@"
XLIB="@LIB_ROOTNAME@"
test $# = 0 && exec @SHELL@ $0 --error
while test $# -gt 0; do
case "$1" in
-*=*)
ARG=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
;;
*)
ARG=
;;
esac
case "$1" in
# basic configuration
--prefix=*)
prefix="$ARG"
test -z "$exec_prefix" && exec_prefix="$ARG"
;;
--prefix)
echo "$prefix"
;;
--exec-prefix=*)
exec_prefix="$ARG"
;;
--exec-prefix)
echo "$exec_prefix"
;;
# compile/link
--cflags)
INCS="-I$includedir/$XHDR"
sed -e 's,^[ ]*,,' -e 's, [ ]*, ,g' -e 's,[ ]*$,,' <<-ENDECHO
$INCS
ENDECHO
;;
--libs)
sed -e 's,^[ ]*,,' -e 's, [ ]*, ,g' -e 's,[ ]*$,,' <<-ENDECHO
-L${libdir} -l${XLIB} @LIBS@
ENDECHO
;;
# identification
--version)
echo "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@"
;;
--abi-version)
echo "@VERSION@" | sed -e 's/:/./g'
;;
# locations
--bindir)
echo "${bindir}"
;;
--datadir)
echo "${datadir}"
;;
--libdir)
echo "${libdir}"
;;
--mandir)
echo "${mandir}"
;;
# general info
--help)
cat <<ENDHELP
Usage: ${THIS}-config [options]
Options:
--prefix echos the package-prefix of ${THIS}
--prefix=ARG sets the package-prefix of ${THIS}
--exec-prefix echos the executable-prefix of ${THIS}
--exec-prefix=ARG sets the executable-prefix of ${THIS}
--cflags echos the C compiler flags needed to compile with ${THIS}
--libs echos the libraries needed to link with ${THIS}
--version echos the release+patchdate version of ${THIS}
--abi-version echos the ABI version of ${THIS}
--bindir echos the directory containing ${THIS} programs
--datadir echos the directory containing ${THIS} data
--libdir echos the directory containing ${THIS} libraries
--mandir echos the directory containing ${THIS} manpages
--help prints this message
ENDHELP
;;
--error|*)
@SHELL@ $0 --help 1>&2
exit 1
;;
esac
shift
done
# vile:shmode

1504
deps/cdk-5.0-20161210/cdk.c vendored Normal file

File diff suppressed because it is too large Load Diff

67
deps/cdk-5.0-20161210/cdk_compat.c vendored Normal file
View File

@ -0,0 +1,67 @@
/*
* $Id: cdk_compat.c,v 1.5 2005/12/28 21:43:35 tom Exp $
* These are functions that are obsolete, but provided as a porting aid.
* The obsolete functions use fixed limits, and inconsistent data handling.
*/
#include "cdk_compat.h"
/*
* This opens the current directory and reads the contents.
*/
int getDirectoryContents (char *directory, char **list, int maxListSize)
{
char **temp = 0;
int counter = CDKgetDirectoryContents (directory, &temp);
int n;
for (n = 0; n < counter && n < maxListSize; ++n)
{
list[n] = copyChar (temp[n]);
}
CDKfreeStrings (temp);
return counter;
}
/*
* This reads a file and sticks it into the char ** provided.
*/
int readFile (char *filename, char **array, int maxlines)
{
char **temp = 0;
int lines = CDKreadFile (filename, &temp);
int n;
for (n = 0; n < maxlines; ++n)
{
if (n < lines)
{
array[n] = copyChar (temp[n]);
}
else
{
array[n] = copyChar ("");
break;
}
}
CDKfreeStrings (temp);
return (lines);
}
/*
* This splits a string into X parts given the split character.
*/
int splitString (char *string, char **items, char splitChar)
{
char **temp = CDKsplitString (string, splitChar);
int chunks = 0;
for (chunks = 0; chunks < MAX_LINES && temp[chunks] != 0; ++chunks)
{
items[chunks] = copyChar (temp[chunks]);
}
CDKfreeStrings (temp);
return chunks;
}

131
deps/cdk-5.0-20161210/cdk_display.c vendored Normal file
View File

@ -0,0 +1,131 @@
#include <cdk_int.h>
/*
* $Author: tom $
* $Date: 2012/03/20 09:54:37 $
* $Revision: 1.4 $
*/
/*
* Given a character pointer, returns the equivalent display type.
*/
EDisplayType char2DisplayType (const char *string)
{
/* *INDENT-OFF* */
static const struct {
const char *name;
EDisplayType code;
} table[] = {
{ "CHAR", vCHAR },
{ "HCHAR", vHCHAR },
{ "INT", vINT },
{ "HINT", vHINT },
{ "UCHAR", vUCHAR },
{ "LCHAR", vLCHAR },
{ "UHCHAR", vUHCHAR },
{ "LHCHAR", vLHCHAR },
{ "MIXED", vMIXED },
{ "HMIXED", vHMIXED },
{ "UMIXED", vUMIXED },
{ "LMIXED", vLMIXED },
{ "UHMIXED", vUHMIXED },
{ "LHMIXED", vLHMIXED },
{ "VIEWONLY", vVIEWONLY },
{ 0, vINVALID },
};
/* *INDENT-ON* */
if (string != 0)
{
int n;
for (n = 0; table[n].name != 0; n++)
{
if (!strcmp (string, table[n].name))
return table[n].code;
}
}
return (EDisplayType) vINVALID;
}
/*
* Tell if a display type is "hidden"
*/
boolean isHiddenDisplayType (EDisplayType type)
{
boolean result = FALSE;
switch (type)
{
case vHCHAR:
case vHINT:
case vHMIXED:
case vLHCHAR:
case vLHMIXED:
case vUHCHAR:
case vUHMIXED:
result = TRUE;
break;
case vCHAR:
case vINT:
case vINVALID:
case vLCHAR:
case vLMIXED:
case vMIXED:
case vUCHAR:
case vUMIXED:
case vVIEWONLY:
result = FALSE;
break;
}
return result;
}
/*
* Given a character input, check if it is allowed by the display type,
* and return the character to apply to the display, or ERR if not.
*/
int filterByDisplayType (EDisplayType type, chtype input)
{
int result = CharOf (input);
if (!isChar (input))
{
result = ERR;
}
else if ((type == vINT ||
type == vHINT) &&
!isdigit (CharOf (result)))
{
result = ERR;
}
else if ((type == vCHAR ||
type == vUCHAR ||
type == vLCHAR ||
type == vUHCHAR ||
type == vLHCHAR) &&
isdigit (CharOf (result)))
{
result = ERR;
}
else if (type == vVIEWONLY)
{
result = ERR;
}
else if ((type == vUCHAR ||
type == vUHCHAR ||
type == vUMIXED ||
type == vUHMIXED) &&
isalpha (CharOf (result)))
{
result = toupper (result);
}
else if ((type == vLCHAR ||
type == vLHCHAR ||
type == vLMIXED ||
type == vLHMIXED) &&
isalpha (CharOf (result)))
{
result = tolower (result);
}
return result;
}

230
deps/cdk-5.0-20161210/cdk_objs.c vendored Normal file
View File

@ -0,0 +1,230 @@
#include <cdk_int.h>
/*
* Default method-functions for CDK objects.
*
* $Author: tom $
* $Date: 2016/11/20 20:07:11 $
* $Revision: 1.17 $
*/
/*
* Set the object's upper-left-corner line-drawing character.
*/
void setCdkULchar (CDKOBJS *obj, chtype ch)
{
obj->ULChar = ch;
}
/*
* Set the object's upper-right-corner line-drawing character.
*/
void setCdkURchar (CDKOBJS *obj, chtype ch)
{
obj->URChar = ch;
}
/*
* Set the object's lower-left-corner line-drawing character.
*/
void setCdkLLchar (CDKOBJS *obj, chtype ch)
{
obj->LLChar = ch;
}
/*
* Set the object's upper-right-corner line-drawing character.
*/
void setCdkLRchar (CDKOBJS *obj, chtype ch)
{
obj->LRChar = ch;
}
/*
* Set the object's horizontal line-drawing character.
*/
void setCdkHZchar (CDKOBJS *obj, chtype ch)
{
obj->HZChar = ch;
}
/*
* Set the object's vertical line-drawing character.
*/
void setCdkVTchar (CDKOBJS *obj, chtype ch)
{
obj->VTChar = ch;
}
/*
* Set the object's box-attributes.
*/
void setCdkBXattr (CDKOBJS *obj, chtype ch)
{
obj->BXAttr = ch;
}
/*
* This sets the background color of the widget.
*/
void setCDKObjectBackgroundColor (CDKOBJS *obj, const char *color)
{
chtype *holder = 0;
int junk1, junk2;
/* Make sure the color isn't null. */
if (color == 0)
{
return;
}
/* Convert the value of the environment variable to a chtype. */
holder = char2Chtype (color, &junk1, &junk2);
/* Set the widget's background color. */
SetBackAttrObj (obj, holder[0]);
/* Clean up. */
freeChtype (holder);
}
/*
* Set the widget's title.
*/
int setCdkTitle (CDKOBJS *obj, const char *title, int boxWidth)
{
if (obj != 0)
{
cleanCdkTitle (obj);
if (title != 0)
{
char **temp = 0;
int titleWidth;
int x;
int len;
int align;
/* We need to split the title on \n. */
temp = CDKsplitString (title, '\n');
obj->titleLines = (int)CDKcountStrings ((CDK_CSTRING2)temp);
obj->title = typeCallocN (chtype *, obj->titleLines + 1);
obj->titlePos = typeCallocN (int, obj->titleLines + 1);
obj->titleLen = typeCallocN (int, obj->titleLines + 1);
if (boxWidth >= 0)
{
int maxWidth = 0;
/* We need to determine the widest title line. */
for (x = 0; x < obj->titleLines; x++)
{
chtype *holder = char2Chtype (temp[x], &len, &align);
maxWidth = MAXIMUM (maxWidth, len);
freeChtype (holder);
}
boxWidth = MAXIMUM (boxWidth, maxWidth + 2 * obj->borderSize);
}
else
{
boxWidth = -(boxWidth - 1);
}
/* For each line in the title, convert from char * to chtype * */
titleWidth = boxWidth - (2 * obj->borderSize);
for (x = 0; x < obj->titleLines; x++)
{
obj->title[x] = char2Chtype (temp[x], &obj->titleLen[x],
&obj->titlePos[x]);
obj->titlePos[x] = justifyString (titleWidth, obj->titleLen[x],
obj->titlePos[x]);
}
CDKfreeStrings (temp);
}
}
return boxWidth;
}
/*
* Draw the widget's title.
*/
void drawCdkTitle (WINDOW *win, CDKOBJS *obj)
{
if (obj != 0)
{
int x;
for (x = 0; x < obj->titleLines; x++)
{
writeChtype (win,
obj->titlePos[x] + obj->borderSize,
x + obj->borderSize,
obj->title[x],
HORIZONTAL, 0,
obj->titleLen[x]);
}
}
}
/*
* Remove storage for the widget's title.
*/
void cleanCdkTitle (CDKOBJS *obj)
{
if (obj != 0)
{
CDKfreeChtypes (obj->title);
obj->title = 0;
freeAndNull (obj->titlePos);
freeAndNull (obj->titleLen);
obj->titleLines = 0;
}
}
/*
* Set data for preprocessing.
*/
void setCDKObjectPreProcess (CDKOBJS *obj, PROCESSFN fn, void *data)
{
obj->preProcessFunction = fn;
obj->preProcessData = data;
}
/*
* Set data for postprocessing.
*/
void setCDKObjectPostProcess (CDKOBJS *obj, PROCESSFN fn, void *data)
{
obj->postProcessFunction = fn;
obj->postProcessData = data;
}
/*
* Set the object's exit-type based on the input.
* The .exitType field should have been part of the CDKOBJS struct, but it
* is used too pervasively in older applications to move (yet).
*/
void setCdkExitType (CDKOBJS *obj, EExitType *type, chtype ch)
{
switch (ch)
{
case KEY_ERROR:
*type = vERROR;
break;
case KEY_ESC:
*type = vESCAPE_HIT;
break;
case KEY_TAB:
case KEY_ENTER:
*type = vNORMAL;
break;
case 0:
*type = vEARLY_EXIT;
break;
}
/* make the result available via ExitTypeOf(obj) */
obj->exitType = *type;
}

250
deps/cdk-5.0-20161210/cdk_params.c vendored Normal file
View File

@ -0,0 +1,250 @@
#include <cdk_int.h>
/*
* Useful functions for command-line parsing.
*
* $Author: tom $
* $Date: 2016/11/20 18:32:53 $
* $Revision: 1.12 $
*/
#define OPTION_ON ((char *)1)
#define OPTION_OFF ((char *)0)
static void usage (char **argv,
CDK_PARAMS * params,
const char *options)
{
int n;
const char *str;
char *base = baseName (argv[0]);
fprintf (stderr, "Usage: %s [options]\n\nOptions:\n", base);
for (n = 1; n < MAX_CDK_PARAMS; ++n)
{
if (n != ':'
&& (str = (strchr) (options, n)) != 0)
{
int value = (str[1] == ':');
fprintf (stderr, " -%c", n);
if (value)
{
fprintf (stderr, " (%s)\n",
(params->allParams[n]
? params->allParams[n]
: "not set"));
}
else
{
fprintf (stderr, " (%s)\n",
(params->allParams[n]
? "set"
: "not set"));
}
}
}
free (base);
exit (EXIT_FAILURE);
}
static int CDKparseSize (char *string, int fullSize)
{
int result;
if (strcmp (string, "FULL") == 0)
{
result = fullSize;
}
else
{
result = (int)strtol (string, (char **)0, 0);
}
return result;
}
/*
* Parse the string as one of CDK's positioning keywords, or an actual
* position.
*/
int CDKparsePosition (const char *string)
{
int result;
if (string == 0)
{
result = NONE;
}
else if (strcmp (string, "TOP") == 0)
{
result = TOP;
}
else if (strcmp (string, "BOTTOM") == 0)
{
result = BOTTOM;
}
else if (strcmp (string, "LEFT") == 0)
{
result = LEFT;
}
else if (strcmp (string, "RIGHT") == 0)
{
result = RIGHT;
}
else if (strcmp (string, "CENTER") == 0)
{
result = CENTER;
}
else
{
result = (int)strtol (string, (char **)0, 0);
}
return result;
}
/*
* Parse the given argc/argv command-line, with the options passed to
* getopt()'s 3rd parameter.
*/
void CDKparseParams (int argc,
char **argv,
CDK_PARAMS * params,
const char *options)
{
int code;
memset (params, 0, sizeof (*params));
params->Box = TRUE;
while ((code = getopt (argc, argv, options)) != EOF)
{
const char *str;
if (code == '?' || (str = (strchr) (options, code)) == 0)
{
usage (argv, params, options);
}
else
{
params->allParams[code] = OPTION_ON;
if (str[1] == ':')
{
params->allParams[code] = optarg;
}
switch (code)
{
case 'W':
params->wValue = CDKparseSize (optarg, FULL);
break;
case 'H':
params->hValue = CDKparseSize (optarg, FULL);
break;
case 'X':
params->xValue = CDKparsePosition (optarg);
break;
case 'Y':
params->yValue = CDKparsePosition (optarg);
break;
case 'N':
params->Box = FALSE;
break;
case 'S':
params->Shadow = TRUE;
break;
}
}
}
}
/*
* Retrieve a numeric option-value, default=0.
*/
int CDKparamNumber (CDK_PARAMS * params, int option)
{
return CDKparamNumber2 (params, option, 0);
}
/*
* Retrieve a numeric option-value, given default.
*/
int CDKparamNumber2 (CDK_PARAMS * params, int option, int missing)
{
return CDKparamValue (params, option, missing);
}
/*
* Retrieve the string value of an option, default=0.
*/
char *CDKparamString (CDK_PARAMS * params, int option)
{
return CDKparamString2 (params, option, 0);
}
/*
* Retrieve the string value of an option, with default for missing value.
*/
char *CDKparamString2 (CDK_PARAMS * params, int option, const char *missing)
{
char *value = ((option > 0 && option < MAX_CDK_PARAMS)
? params->allParams[option]
: 0);
if (value == 0)
value = copyChar (missing);
return value;
}
/*
* Retrieve an integer (or boolean) option value from the parsed command-line.
* (prefer: CDKparamNumber).
*/
int CDKparamValue (CDK_PARAMS * params, int option, int missing)
{
int result;
char *value = CDKparamString (params, option);
if (value == 0)
{
result = missing;
}
else if (strchr (CDK_CLI_PARAMS, option) != 0)
{
switch (option)
{
case 'H':
result = params->hValue;
break;
case 'W':
result = params->wValue;
break;
case 'X':
result = params->xValue;
break;
case 'Y':
result = params->yValue;
break;
case 'N':
result = params->Box;
break;
case 'S':
result = params->Shadow;
break;
default:
result = missing;
break;
}
}
else if (value == OPTION_ON)
{
result = 1;
}
else
{
result = (int)strtol (value, (char **)0, 0);
}
return result;
}

509
deps/cdk-5.0-20161210/cdkscreen.c vendored Normal file
View File

@ -0,0 +1,509 @@
#include <cdk_int.h>
#ifdef HAVE_SETLOCALE
#include <locale.h>
#endif
/*
* $Author: tom $
* $Date: 2016/12/04 15:41:50 $
* $Revision: 1.91 $
*/
typedef struct _all_screens
{
struct _all_screens *link;
CDKSCREEN *screen;
}
ALL_SCREENS;
static ALL_SCREENS *all_screens;
typedef struct _all_objects
{
struct _all_objects *link;
CDKOBJS *object;
}
ALL_OBJECTS;
static ALL_OBJECTS *all_objects;
static boolean validObjType (CDKOBJS *obj, EObjectType type)
{
bool valid = FALSE;
if (obj != 0 && ObjTypeOf (obj) == type)
{
switch (type)
{
case vALPHALIST:
case vBUTTON:
case vBUTTONBOX:
case vCALENDAR:
case vDIALOG:
case vDSCALE:
case vENTRY:
case vFSCALE:
case vFSELECT:
case vFSLIDER:
case vGRAPH:
case vHISTOGRAM:
case vITEMLIST:
case vLABEL:
case vMARQUEE:
case vMATRIX:
case vMENTRY:
case vMENU:
case vRADIO:
case vSCALE:
case vSCROLL:
case vSELECTION:
case vSLIDER:
case vSWINDOW:
case vTEMPLATE:
case vUSCALE:
case vUSLIDER:
case vVIEWER:
valid = TRUE;
break;
case vTRAVERSE: /* not really an object */
case vNULL:
break;
}
}
return valid;
}
/*
* Set indices so the screen and object point to each other.
*/
static void setScreenIndex (CDKSCREEN *screen, int number, CDKOBJS *obj)
{
(obj)->screenIndex = number;
(obj)->screen = screen;
screen->object[number] = obj;
}
/*
* Returns true if we have done a "new" on this object but no "destroy"
*/
bool validCDKObject (CDKOBJS *obj)
{
bool result = FALSE;
if (obj != 0)
{
ALL_OBJECTS *ptr;
for (ptr = all_objects; ptr != 0; ptr = ptr->link)
{
if (ptr->object == obj)
{
result = validObjType (obj, ObjTypeOf (obj));
break;
}
}
}
return result;
}
/*
* Create a new object beginning with a CDKOBJS struct. The whole object is
* initialized to zeroes except for special cases which have known values.
*/
void *_newCDKObject (unsigned size, const CDKFUNCS * funcs)
{
ALL_OBJECTS *item;
CDKOBJS *result = 0;
if ((item = typeCalloc (ALL_OBJECTS)) != 0)
{
if ((result = (CDKOBJS *)calloc (1, size)) != 0)
{
result->fn = funcs;
result->hasFocus = TRUE;
result->isVisible = TRUE;
item->link = all_objects;
item->object = result;
all_objects = item;
/* set default line-drawing characters */
result->ULChar = ACS_ULCORNER;
result->URChar = ACS_URCORNER;
result->LLChar = ACS_LLCORNER;
result->LRChar = ACS_LRCORNER;
result->HZChar = ACS_HLINE;
result->VTChar = ACS_VLINE;
result->BXAttr = A_NORMAL;
/* set default exit-types */
result->exitType = vNEVER_ACTIVATED;
result->earlyExit = vNEVER_ACTIVATED;
}
else
{
free (item);
}
}
return (void *)result;
}
void _destroyCDKObject (CDKOBJS *obj)
{
if (validCDKObject (obj))
{
ALL_OBJECTS *p, *q;
for (p = all_objects, q = 0; p != 0; q = p, p = p->link)
{
if (p->object == obj)
{
/* delink it first, to avoid problems with recursion */
if (q != 0)
q->link = p->link;
else
all_objects = p->link;
MethodPtr (obj, destroyObj) (obj);
free (obj);
free (p);
break;
}
}
}
}
/*
* This creates a new CDK screen.
*/
CDKSCREEN *initCDKScreen (WINDOW *window)
{
ALL_SCREENS *item;
CDKSCREEN *screen = 0;
/* initialization, for the first time */
if (all_screens == 0 || stdscr == 0 || window == 0)
{
/* Set up basic curses settings. */
#ifdef HAVE_SETLOCALE
setlocale (LC_ALL, "");
#endif
/* Initialize curses after setting the locale, since curses depends
* on having a correct locale to reflect the terminal's encoding.
*/
if (stdscr == 0 || window == 0)
{
window = initscr ();
}
noecho ();
cbreak ();
}
if ((item = typeMalloc (ALL_SCREENS)) != 0)
{
if ((screen = typeCalloc (CDKSCREEN)) != 0)
{
item->link = all_screens;
item->screen = screen;
all_screens = item;
/* Initialize the CDKSCREEN pointer. */
screen->objectCount = 0;
screen->objectLimit = 2;
screen->object = typeMallocN (CDKOBJS *, screen->objectLimit);
screen->window = window;
/* OK, we are done. */
}
else
{
free (item);
}
}
return (screen);
}
/*
* This registers a CDK object with a screen.
*/
void registerCDKObject (CDKSCREEN *screen, EObjectType cdktype, void *object)
{
CDKOBJS *obj = (CDKOBJS *)object;
if (screen->objectCount + 1 >= screen->objectLimit)
{
screen->objectLimit += 2;
screen->objectLimit *= 2;
screen->object = typeReallocN (CDKOBJS *, screen->object, screen->objectLimit);
}
if (validObjType (obj, cdktype))
{
setScreenIndex (screen, screen->objectCount++, obj);
}
}
/*
* This registers a CDK object with a screen.
*/
void reRegisterCDKObject (EObjectType cdktype, void *object)
{
CDKOBJS *obj = (CDKOBJS *)object;
registerCDKObject (obj->screen, cdktype, object);
}
/*
* This removes an object from the CDK screen.
*/
void unregisterCDKObject (EObjectType cdktype, void *object)
{
CDKOBJS *obj = (CDKOBJS *)object;
if (validObjType (obj, cdktype) && obj->screenIndex >= 0)
{
CDKSCREEN *screen = (obj)->screen;
if (screen != 0)
{
int Index = (obj)->screenIndex;
int x;
obj->screenIndex = -1;
/*
* Resequence the objects.
*/
for (x = Index; x < screen->objectCount - 1; x++)
{
setScreenIndex (screen, x, screen->object[x + 1]);
}
if (screen->objectCount <= 1)
{
/* if no more objects, remove the array */
freeAndNull (screen->object);
screen->objectCount = 0;
screen->objectLimit = 0;
}
else
{
/* Reduce the list by one object. */
screen->object[screen->objectCount--] = 0;
/*
* Update the object-focus
*/
if (screen->objectFocus == Index)
{
screen->objectFocus--;
(void)setCDKFocusNext (screen);
}
else if (screen->objectFocus > Index)
{
screen->objectFocus--;
}
}
}
}
}
#define validIndex(screen, n) ((n) >= 0 && (n) < (screen)->objectCount)
static void swapCDKIndices (CDKSCREEN *screen, int n1, int n2)
{
if (n1 != n2 && validIndex (screen, n1) && validIndex (screen, n2))
{
CDKOBJS *o1 = screen->object[n1];
CDKOBJS *o2 = screen->object[n2];
setScreenIndex (screen, n1, o2);
setScreenIndex (screen, n2, o1);
if (screen->objectFocus == n1)
screen->objectFocus = n2;
else if (screen->objectFocus == n2)
screen->objectFocus = n1;
}
}
/*
* This 'brings' a CDK object to the top of the stack.
*/
void raiseCDKObject (EObjectType cdktype, void *object)
{
CDKOBJS *obj = (CDKOBJS *)object;
if (validObjType (obj, cdktype))
{
CDKSCREEN *screen = obj->screen;
swapCDKIndices (screen, obj->screenIndex, screen->objectCount - 1);
}
}
/*
* This 'lowers' an object.
*/
void lowerCDKObject (EObjectType cdktype, void *object)
{
CDKOBJS *obj = (CDKOBJS *)object;
if (validObjType (obj, cdktype))
{
CDKSCREEN *screen = obj->screen;
swapCDKIndices (screen, obj->screenIndex, 0);
}
}
/*
* This calls refreshCDKScreen. (made consistent with widgets)
*/
void drawCDKScreen (CDKSCREEN *cdkscreen)
{
refreshCDKScreen (cdkscreen);
}
/*
* Refresh one CDK window.
* FIXME: this should be rewritten to use the panel library, so it would not
* be necessary to touch the window to ensure that it covers other windows.
*/
void refreshCDKWindow (WINDOW *win)
{
touchwin (win);
wrefresh (win);
}
/*
* This refreshes all the objects in the screen.
*/
void refreshCDKScreen (CDKSCREEN *cdkscreen)
{
int objectCount = cdkscreen->objectCount;
int x;
int focused = -1;
int visible = -1;
refreshCDKWindow (cdkscreen->window);
/* We erase all the invisible objects, then only
* draw it all back, so that the objects
* can overlap, and the visible ones will always
* be drawn after all the invisible ones are erased */
for (x = 0; x < objectCount; x++)
{
CDKOBJS *obj = cdkscreen->object[x];
if (validObjType (obj, ObjTypeOf (obj)))
{
if (obj->isVisible)
{
if (visible < 0)
visible = x;
if (obj->hasFocus && focused < 0)
focused = x;
}
else
{
obj->fn->eraseObj (obj);
}
}
}
for (x = 0; x < objectCount; x++)
{
CDKOBJS *obj = cdkscreen->object[x];
if (validObjType (obj, ObjTypeOf (obj)))
{
obj->hasFocus = (x == focused);
if (obj->isVisible)
{
obj->fn->drawObj (obj, obj->box);
}
}
}
}
/*
* This clears all the objects in the screen.
*/
void eraseCDKScreen (CDKSCREEN *cdkscreen)
{
int objectCount = cdkscreen->objectCount;
int x;
/* We just call the drawObject function. */
for (x = 0; x < objectCount; x++)
{
CDKOBJS *obj = cdkscreen->object[x];
if (validObjType (obj, ObjTypeOf (obj)))
{
obj->fn->eraseObj (obj);
}
}
/* Refresh the screen. */
wrefresh (cdkscreen->window);
}
/*
* Destroy all of the objects on a screen
*/
void destroyCDKScreenObjects (CDKSCREEN *cdkscreen)
{
int x;
for (x = 0; x < cdkscreen->objectCount; x++)
{
CDKOBJS *obj = cdkscreen->object[x];
int before = cdkscreen->objectCount;
if (validObjType (obj, ObjTypeOf (obj)))
{
MethodPtr (obj, eraseObj) (obj);
_destroyCDKObject (obj);
x -= (cdkscreen->objectCount - before);
}
}
}
/*
* This destroys a CDK screen.
*/
void destroyCDKScreen (CDKSCREEN *screen)
{
ALL_SCREENS *p, *q;
for (p = all_screens, q = 0; p != 0; q = p, p = p->link)
{
if (screen == p->screen)
{
if (q != 0)
q->link = p->link;
else
all_screens = p->link;
free (p);
free (screen);
break;
}
}
}
/*
* This is added to remain consistent.
*/
void endCDK (void)
{
/* Turn echoing back on. */
echo ();
/* Turn off cbreak. */
nocbreak ();
/* End the curses windows. */
endwin ();
#ifdef HAVE_XCURSES
XCursesExit ();
#endif
}

107
deps/cdk-5.0-20161210/cli/Makefile.in vendored Normal file
View File

@ -0,0 +1,107 @@
# $Id: Makefile.in,v 1.7 2013/07/19 23:55:03 tom Exp $
#
# Makefile for the cli directory.
#
SHELL = /bin/sh
prefix = @prefix@
exec_prefix = @exec_prefix@
srcdir = @srcdir@
VPATH = $(srcdir)
CC = @CC@
RM = rm -f
CTAGS = @CTAGS@
ETAGS = @ETAGS@
LINT = @LINT@
LINT_OPTS = @LINT_OPTS@
LIBS = -l@LIB_ROOTNAME@ @LIBS@
LIBTOOL = @LIBTOOL@ @ECHO_LT@
LIBTOOL_CLEAN = @LIB_CLEAN@
LIBTOOL_LINK = @LIB_LINK@
LINK = $(LIBTOOL_LINK)
x = @EXEEXT@
o = .@OBJEXT@
LOCAL_LIBDIR = @top_builddir@
CFLAGS = @CFLAGS@ @EXTRA_CFLAGS@
CPPFLAGS = @DEFS@ -I../include -I$(srcdir)/../include -I. @CPPFLAGS@
LDFLAGS = -L.. @LDFLAGS@ @LOCAL_LDFLAGS@
BINS = \
cdkalphalist$x \
cdkcalendar$x \
cdkdialog$x \
cdkentry$x \
cdkfselect$x \
cdkitemlist$x \
cdklabel$x \
cdkmatrix$x \
cdkmentry$x \
cdkradio$x \
cdkscale$x \
cdkscroll$x \
cdkselection$x \
cdkslider$x \
cdktemplate$x \
cdkviewer$x
CDKSRC = \
cdkalphalist.c \
cdkcalendar.c \
cdkdialog.c \
cdkentry.c \
cdkfselect.c \
cdkitemlist.c \
cdklabel.c \
cdkmatrix.c \
cdkmentry.c \
cdkradio.c \
cdkscale.c \
cdkscroll.c \
cdkselection.c \
cdkslider.c \
cdktemplate.c \
cdkviewer.c
LINKIT = @ECHO_LD@$(LINK) $(CFLAGS) $(CPPFLAGS) $? -o $@ $(LDFLAGS) $(LIBS)
all : $(BINS)
cdkalphalist$x : cdkalphalist.c ; $(LINKIT)
cdkcalendar$x : cdkcalendar.c ; $(LINKIT)
cdkdialog$x : cdkdialog.c ; $(LINKIT)
cdkentry$x : cdkentry.c ; $(LINKIT)
cdkfselect$x : cdkfselect.c ; $(LINKIT)
cdkitemlist$x : cdkitemlist.c ; $(LINKIT)
cdklabel$x : cdklabel.c ; $(LINKIT)
cdkmatrix$x : cdkmatrix.c ; $(LINKIT)
cdkmentry$x : cdkmentry.c ; $(LINKIT)
cdkradio$x : cdkradio.c ; $(LINKIT)
cdkscale$x : cdkscale.c ; $(LINKIT)
cdkscroll$x : cdkscroll.c ; $(LINKIT)
cdkselection$x : cdkselection.c ; $(LINKIT)
cdkslider$x : cdkslider.c ; $(LINKIT)
cdktemplate$x : cdktemplate.c ; $(LINKIT)
cdkviewer$x : cdkviewer.c ; $(LINKIT)
#
# Standard clean directives.
#
clean::
- $(LIBTOOL_CLEAN) $(RM) *.o core $(BINS)
distclean:: clean
$(RM) Makefile
@MAKE_LOWER_TAGS@tags :
@MAKE_LOWER_TAGS@ $(CTAGS) *.[ch] */*.[ch]
@MAKE_LOWER_TAGS@TAGS :
@MAKE_LOWER_TAGS@ $(ETAGS) *.[ch] */*.[ch]
lint: $(CDKSRC)
$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(CDKSRC)

276
deps/cdk-5.0-20161210/cli/cdkalphalist.c vendored Normal file
View File

@ -0,0 +1,276 @@
/* $Id: cdkalphalist.c,v 1.18 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef XCURSES
char *XCursesProgramName = "cdkalphalist";
#endif
/*
* Declare file local prototypes.
*/
int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
/*
* Define file local variables.
*/
static const char *FPUsage = "-l List | -f filename [-F Field Character] [-T Title] [-L Label] [-B Buttons] [-O Output File] [-X X Position] [-Y Y Position] [-H Height] [-W Width] [-N] [-S]";
/*
*
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkScreen = 0;
CDKALPHALIST *widget = 0;
CDKBUTTONBOX *buttonWidget = 0;
char *CDK_WIDGET_COLOR = 0;
char *answer = 0;
char *buttons;
char *temp = 0;
chtype *holder = 0;
chtype filler = A_NORMAL | '.';
int scrollLines = -1;
int buttonCount = 0;
int shadowHeight = 0;
FILE *fp = stderr;
char **scrollList = 0;
char **buttonList = 0;
int j1, j2;
CDK_PARAMS params;
boolean boxWidget;
boolean shadowWidget;
char *filename;
char *label;
char *list;
char *outputFile;
char *tempFiller;
char *title;
int height;
int width;
int xpos;
int ypos;
CDKparseParams (argc, argv, &params, "f:l:B:F:L:O:T:" CDK_CLI_PARAMS);
/* *INDENT-EQLS* */
xpos = CDKparamValue (&params, 'X', CENTER);
ypos = CDKparamValue (&params, 'Y', CENTER);
height = CDKparamValue (&params, 'H', -1);
width = CDKparamValue (&params, 'W', -1);
boxWidget = CDKparamValue (&params, 'N', TRUE);
shadowWidget = CDKparamValue (&params, 'S', FALSE);
filename = CDKparamString (&params, 'f');
list = CDKparamString (&params, 'l');
buttons = CDKparamString (&params, 'B');
tempFiller = CDKparamString (&params, 'F');
label = CDKparamString (&params, 'L');
outputFile = CDKparamString (&params, 'O');
title = CDKparamString (&params, 'T');
/* If the user asked for an output file, try to open it. */
if (outputFile != 0)
{
if ((fp = fopen (outputFile, "w")) == 0)
{
fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
ExitProgram (CLI_ERROR);
}
}
/* Did they provide a list of items. */
if (list == 0)
{
/* Maybe they gave a filename to use to read. */
if (filename != 0)
{
/* Read the file in. */
scrollLines = CDKreadFile (filename, &scrollList);
/* Check if there was an error. */
if (scrollLines == -1)
{
fprintf (stderr, "Error: Could not open the file '%s'.\n", filename);
ExitProgram (CLI_ERROR);
}
}
else
{
/* They didn't provide anything. */
fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
ExitProgram (CLI_ERROR);
}
}
else
{
/* Split the scroll lines up. */
scrollList = CDKsplitString (list, '\n');
scrollLines = (int)CDKcountStrings ((CDK_CSTRING2)scrollList);
}
cdkScreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Check if the user wants to set the background of the main screen. */
if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
{
holder = char2Chtype (temp, &j1, &j2);
wbkgd (cdkScreen->window, holder[0]);
wrefresh (cdkScreen->window);
freeChtype (holder);
}
/* Get the widget color background color. */
if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
{
CDK_WIDGET_COLOR = 0;
}
/* If they set the filler character, set it now. */
if (tempFiller != 0)
{
holder = char2Chtype (tempFiller, &j1, &j2);
filler = holder[0];
freeChtype (holder);
}
/* Create the widget. */
widget = newCDKAlphalist (cdkScreen, xpos, ypos,
height, width,
title, label,
(CDK_CSTRING *)scrollList, scrollLines,
filler, A_REVERSE,
boxWidget, shadowWidget);
/* Make sure we could create the widget. */
if (widget == 0)
{
CDKfreeStrings (scrollList);
destroyCDKScreen (cdkScreen);
endCDK ();
fprintf (stderr,
"Error: Could not create the alphalist. "
"Is the window too small?\n");
ExitProgram (CLI_ERROR);
}
/* Split the buttons if they supplied some. */
if (buttons != 0)
{
buttonList = CDKsplitString (buttons, '\n');
buttonCount = (int)CDKcountStrings ((CDK_CSTRING2)buttonList);
buttonWidget = newCDKButtonbox (cdkScreen,
getbegx (widget->win) + 1,
(getbegy (widget->win)
+ widget->boxHeight - 1),
1, widget->boxWidth - 3,
0, 1, buttonCount,
(CDK_CSTRING2)buttonList, buttonCount,
A_REVERSE, boxWidget, FALSE);
CDKfreeStrings (buttonList);
setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
/*
* We need to set the lower left and right
* characters of the entry field.
*/
setCDKAlphalistLLChar (widget, ACS_LTEE);
setCDKAlphalistLRChar (widget, ACS_RTEE);
/*
* Bind the Tab key in the entry field to send a
* Tab key to the button box widget.
*/
bindCDKObject (vENTRY, widget->entryField, KEY_RIGHT, widgetCB, buttonWidget);
bindCDKObject (vENTRY, widget->entryField, KEY_LEFT, widgetCB, buttonWidget);
bindCDKObject (vENTRY, widget->entryField, CDK_NEXT, widgetCB, buttonWidget);
bindCDKObject (vENTRY, widget->entryField, CDK_PREV, widgetCB, buttonWidget);
setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
drawCDKButtonbox (buttonWidget, boxWidget);
}
/*
* If the user asked for a shadow, we need to create one. Do this instead
* of using the shadow parameter because the button widget is not part of
* the main widget and if the user asks for both buttons and a shadow, we
* need to create a shadow big enough for both widgets. Create the shadow
* window using the widgets shadowWin element, so screen refreshes will draw
* them as well.
*/
if (shadowWidget == TRUE)
{
/* Determine the height of the shadow window. */
shadowHeight = (buttonWidget == 0 ?
widget->boxHeight :
widget->boxHeight + buttonWidget->boxHeight - 1);
/* Create the shadow window. */
widget->shadowWin = newwin (shadowHeight,
widget->boxWidth,
getbegy (widget->win) + 1,
getbegx (widget->win) + 1);
/* Make sure we could have created the shadow window. */
if (widget->shadowWin != 0)
{
widget->shadow = TRUE;
/*
* We force the widget and buttonWidget to be drawn so the
* buttonbox widget will be drawn when the widget is activated.
* Otherwise the shadow window will draw over the button widget.
*/
drawCDKAlphalist (widget, ObjOf (widget)->box);
eraseCDKButtonbox (buttonWidget);
drawCDKButtonbox (buttonWidget, ObjOf (buttonWidget)->box);
}
}
/* Check if the user wants to set the background of the widget. */
setCDKAlphalistBackgroundColor (widget, CDK_WIDGET_COLOR);
/* Activate the widget. */
answer = copyChar (activateCDKAlphalist (widget, 0));
/* If there were buttons, get the button selected. */
if (buttonWidget != 0)
{
destroyCDKButtonbox (buttonWidget);
}
CDKfreeStrings (scrollList);
destroyCDKAlphalist (widget);
destroyCDKScreen (cdkScreen);
endCDK ();
/* Print out the answer. */
if (answer != 0)
{
fprintf (fp, "%s\n", answer);
freeChar (answer);
}
/* Exit with the selected button. */
ExitProgram (0);
}
int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED,
void *clientData,
chtype key)
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
(void)injectCDKButtonbox (buttonbox, key);
return (TRUE);
}

252
deps/cdk-5.0-20161210/cli/cdkcalendar.c vendored Normal file
View File

@ -0,0 +1,252 @@
/* $Id: cdkcalendar.c,v 1.17 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef XCURSES
char *XCursesProgramName = "cdkcalendar";
#endif
/*
* Declare file local prototypes.
*/
static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
/*
* Define file local variables.
*/
static void getTodaysDate (int *day, int *month, int *year);
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkScreen = 0;
CDKCALENDAR *widget = 0;
CDKBUTTONBOX *buttonWidget = 0;
struct tm *dateInfo = 0;
time_t selected = 0;
chtype dayAttrib = A_NORMAL;
chtype monthAttrib = A_NORMAL;
chtype yearAttrib = A_NORMAL;
chtype highlight = A_REVERSE;
chtype *holder = 0;
char *CDK_WIDGET_COLOR = 0;
char *temp = 0;
int buttonCount = 0;
int selection = 0;
int shadowHeight = 0;
FILE *fp = stderr;
char **buttonList = 0;
int j1, j2;
CDK_PARAMS params;
boolean boxWidget;
boolean shadowWidget;
char *buttons;
char *outputFile;
char *title;
int day;
int month;
int xpos;
int year;
int ypos;
getTodaysDate (&day, &month, &year);
CDKparseParams (argc, argv, &params, "d:m:y:B:O:T:" CDK_MIN_PARAMS);
/* *INDENT-EQLS* */
xpos = CDKparamValue (&params, 'X', CENTER);
ypos = CDKparamValue (&params, 'Y', CENTER);
boxWidget = CDKparamValue (&params, 'N', TRUE);
shadowWidget = CDKparamValue (&params, 'S', FALSE);
day = CDKparamValue (&params, 'd', day);
month = CDKparamValue (&params, 'm', month);
year = CDKparamValue (&params, 'y', year);
buttons = CDKparamString (&params, 'B');
outputFile = CDKparamString (&params, 'O');
title = CDKparamString (&params, 'T');
/* If the user asked for an output file, try to open it. */
if (outputFile != 0)
{
if ((fp = fopen (outputFile, "w")) == 0)
{
fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
ExitProgram (CLI_ERROR);
}
}
cdkScreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Check if the user wants to set the background of the main screen. */
if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
{
holder = char2Chtype (temp, &j1, &j2);
wbkgd (cdkScreen->window, holder[0]);
wrefresh (cdkScreen->window);
freeChtype (holder);
}
/* Check if the user wants to set the background of the widget. */
if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
{
CDK_WIDGET_COLOR = 0;
}
/* Create the calendar width. */
widget = newCDKCalendar (cdkScreen, xpos, ypos, title,
day, month, year,
dayAttrib, monthAttrib,
yearAttrib, highlight,
boxWidget, shadowWidget);
/* Check to make sure we created the dialog box. */
if (widget == 0)
{
destroyCDKScreen (cdkScreen);
endCDK ();
fprintf (stderr,
"Error: Could not create the calendar. "
"Is the window too small?\n");
ExitProgram (CLI_ERROR);
}
/* Split the buttons if they supplied some. */
if (buttons != 0)
{
/* Split the button list up. */
buttonList = CDKsplitString (buttons, '\n');
buttonCount = (int)CDKcountStrings ((CDK_CSTRING2) buttonList);
/* We need to create a buttonbox widget. */
buttonWidget = newCDKButtonbox (cdkScreen,
getbegx (widget->win),
(getbegy (widget->win)
+ widget->boxHeight - 1),
1, widget->boxWidth - 1,
0, 1, buttonCount,
(CDK_CSTRING2) buttonList, buttonCount,
A_REVERSE, boxWidget, FALSE);
setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
/*
* We need to set the lower left and right
* characters of the widget.
*/
setCDKCalendarLLChar (widget, ACS_LTEE);
setCDKCalendarLRChar (widget, ACS_RTEE);
/*
* Bind the Tab key in the widget to send a
* Tab key to the button box widget.
*/
bindCDKObject (vCALENDAR, widget, KEY_TAB, widgetCB, buttonWidget);
bindCDKObject (vCALENDAR, widget, CDK_PREV, widgetCB, buttonWidget);
bindCDKObject (vCALENDAR, widget, CDK_NEXT, widgetCB, buttonWidget);
/* Check if the user wants to set the background of the widget. */
setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
/* Draw the button widget. */
drawCDKButtonbox (buttonWidget, boxWidget);
}
/*
* If the user asked for a shadow, we need to create one. Do this instead
* of using the shadow parameter because the button widget is not part of
* the main widget and if the user asks for both buttons and a shadow, we
* need to create a shadow big enough for both widgets. Create the shadow
* window using the widgets shadowWin element, so screen refreshes will draw
* them as well.
*/
if (shadowWidget == TRUE)
{
/* Determine the height of the shadow window. */
shadowHeight = (buttonWidget == 0 ?
widget->boxHeight :
widget->boxHeight + buttonWidget->boxHeight - 1);
/* Create the shadow window. */
widget->shadowWin = newwin (shadowHeight,
widget->boxWidth,
getbegy (widget->win) + 1,
getbegx (widget->win) + 1);
/* Make sure we could have created the shadow window. */
if (widget->shadowWin != 0)
{
widget->shadow = TRUE;
/*
* We force the widget and buttonWidget to be drawn so the
* buttonbox widget will be drawn when the widget is activated.
* Otherwise the shadow window will draw over the button widget.
*/
drawCDKCalendar (widget, ObjOf (widget)->box);
eraseCDKButtonbox (buttonWidget);
drawCDKButtonbox (buttonWidget, ObjOf (buttonWidget)->box);
}
}
/* Check if the user wants to set the background of the widget. */
setCDKCalendarBackgroundColor (widget, CDK_WIDGET_COLOR);
/* Activate the calendar widget. */
selected = activateCDKCalendar (widget, 0);
/* If there were buttons, get the button selected. */
if (buttonWidget != 0)
{
selection = buttonWidget->currentButton;
destroyCDKButtonbox (buttonWidget);
}
CDKfreeStrings (buttonList);
destroyCDKCalendar (widget);
destroyCDKScreen (cdkScreen);
endCDK ();
/* Print out the date selected. D/M/Y format. */
dateInfo = gmtime (&selected);
fprintf (fp, "%02d/%02d/%d\n",
dateInfo->tm_mday,
(dateInfo->tm_mon + 1),
(dateInfo->tm_year + 1900));
fclose (fp);
ExitProgram (selection);
}
/*
* This returns what day of the week the month starts on.
*/
static void getTodaysDate (int *day, int *month, int *year)
{
struct tm *dateInfo;
time_t clck;
/* Determine the current time and determine if we are in DST. */
time (&clck);
dateInfo = gmtime (&clck);
/* Set the pointers accordingly. */
(*day) = dateInfo->tm_mday;
(*month) = dateInfo->tm_mon + 1;
(*year) = dateInfo->tm_year + 1900;
}
static int widgetCB (EObjectType cdktype GCC_UNUSED,
void *object GCC_UNUSED,
void *clientData,
chtype key)
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
(void) injectCDKButtonbox (buttonbox, key);
return (TRUE);
}

178
deps/cdk-5.0-20161210/cli/cdkdialog.c vendored Normal file
View File

@ -0,0 +1,178 @@
/* $Id: cdkdialog.c,v 1.15 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef XCURSES
char *XCursesProgramName = "cdkdialog";
#endif
/*
* Define file local variables.
*/
static const char *FPUsage = "-m Message String | -f filename [-B Buttons] [-O Output file] [-X X Position] [-Y Y Position] [-N] [-S]";
/*
*
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkScreen = 0;
CDKDIALOG *widget = 0;
char *CDK_WIDGET_COLOR = 0;
char *button = 0;
char *temp = 0;
chtype *holder = 0;
int answer = 0;
int messageLines = -1;
int buttonCount = 0;
FILE *fp = stderr;
char **messageList = 0;
char **buttonList = 0;
int j1, j2;
CDK_PARAMS params;
boolean boxWidget;
boolean shadowWidget;
char *buttons;
char *filename;
char *outputFile;
char *message;
int xpos;
int ypos;
CDKparseParams (argc, argv, &params, "f:m:B:O:" CDK_MIN_PARAMS);
/* *INDENT-EQLS* */
xpos = CDKparamValue (&params, 'X', CENTER);
ypos = CDKparamValue (&params, 'Y', CENTER);
boxWidget = CDKparamValue (&params, 'N', TRUE);
shadowWidget = CDKparamValue (&params, 'S', FALSE);
filename = CDKparamString (&params, 'f');
message = CDKparamString (&params, 'm');
buttons = CDKparamString (&params, 'B');
outputFile = CDKparamString (&params, 'O');
/* If the user asked for an output file, try to open it. */
if (outputFile != 0)
{
if ((fp = fopen (outputFile, "w")) == 0)
{
fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
ExitProgram (CLI_ERROR);
}
}
/* Make sure we have a message to display. */
if (message == 0)
{
/* No message, maybe they provided a file to read. */
if (filename != 0)
{
/* Read the file in. */
messageLines = CDKreadFile (filename, &messageList);
/* Check if there was an error. */
if (messageLines == -1)
{
fprintf (stderr, "Error: Could not open the file %s\n", filename);
ExitProgram (CLI_ERROR);
}
}
else
{
/* No message, no file, it's an error. */
fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
ExitProgram (CLI_ERROR);
}
}
else
{
/* Split the message up. */
messageList = CDKsplitString (message, '\n');
messageLines = (int)CDKcountStrings ((CDK_CSTRING2)messageList);
}
/* Set up the buttons for the dialog box. */
if (buttons == 0)
{
buttonList = calloc(sizeof(char *), 3);
buttonList[0] = copyChar ("OK");
buttonList[1] = copyChar ("Cancel");
buttonCount = 2;
}
else
{
/* Split the button list up. */
buttonList = CDKsplitString (buttons, '\n');
buttonCount = (int)CDKcountStrings ((CDK_CSTRING2)buttonList);
}
cdkScreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Check if the user wants to set the background of the main screen. */
if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
{
holder = char2Chtype (temp, &j1, &j2);
wbkgd (cdkScreen->window, holder[0]);
wrefresh (cdkScreen->window);
freeChtype (holder);
}
/* Get the widget color background color. */
if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
{
CDK_WIDGET_COLOR = 0;
}
/* Create the dialog box. */
widget = newCDKDialog (cdkScreen, xpos, ypos,
(CDK_CSTRING2)messageList, messageLines,
(CDK_CSTRING2)buttonList, buttonCount,
A_REVERSE,
boxWidget, boxWidget, shadowWidget);
/* Check to make sure we created the dialog box. */
if (widget == 0)
{
CDKfreeStrings (messageList);
CDKfreeStrings (buttonList);
destroyCDKScreen (cdkScreen);
endCDK ();
fprintf (stderr,
"Error: Could not create the dialog box. "
"Is the window too small?\n");
ExitProgram (CLI_ERROR);
}
/* Check if the user wants to set the background of the widget. */
setCDKDialogBackgroundColor (widget, CDK_WIDGET_COLOR);
/* Activate the dialog box. */
answer = activateCDKDialog (widget, 0);
/* End CDK. */
destroyCDKDialog (widget);
destroyCDKScreen (cdkScreen);
endCDK ();
/* Print the name of the button selected. */
if (answer >= 0)
{
button = copyChar (buttonList[answer]);
fprintf (fp, "%s\n", button);
freeChar (button);
}
CDKfreeStrings (messageList);
CDKfreeStrings (buttonList);
/* Exit with the button number picked. */
ExitProgram (answer);
}

267
deps/cdk-5.0-20161210/cli/cdkentry.c vendored Normal file
View File

@ -0,0 +1,267 @@
/* $Id: cdkentry.c,v 1.16 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef XCURSES
char *XCursesProgramName = "cdkentry";
#endif
/*
* Declare file local prototypes.
*/
static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
/*
* Define file local variables.
*/
static const char *FPUsage = "-f Field Width [-d Display Type] [-F Field Character] [-i Initial Value] [-m Minimum Length] [-M Maximum Length] [-T Title] [-L Label] [-B Buttons] [-O Output file] [-X X Position] [-Y Y Position] [-N] [-S]";
/*
*
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkScreen = 0;
CDKENTRY *widget = 0;
CDKBUTTONBOX *buttonWidget = 0;
chtype *holder = 0;
chtype fieldAttr = A_NORMAL;
char *answer = 0;
char *CDK_WIDGET_COLOR = 0;
char *temp = 0;
char filler = '.';
EDisplayType dType = vMIXED;
int buttonCount = 0;
int selection = 0;
int shadowHeight = 0;
FILE *fp = stderr;
char **buttonList = 0;
int j1, j2;
CDK_PARAMS params;
boolean boxWidget;
boolean shadowWidget;
char *buttons;
char *outputFile;
char *initValue;
char *title;
char *label;
char *tempFiller;
int maxValue;
int fieldWidth;
int minValue;
int xpos;
int ypos;
CDKparseParams (argc, argv, &params, "d:f:i:m:B:F:L:M:O:T:" CDK_MIN_PARAMS);
/* *INDENT-EQLS* */
xpos = CDKparamValue (&params, 'X', CENTER);
ypos = CDKparamValue (&params, 'Y', CENTER);
boxWidget = CDKparamValue (&params, 'N', TRUE);
shadowWidget = CDKparamValue (&params, 'S', FALSE);
minValue = CDKparamValue (&params, 'm', 0);
fieldWidth = CDKparamValue (&params, 'f', 0);
maxValue = CDKparamValue (&params, 'M', 256);
initValue = CDKparamString (&params, 'i');
buttons = CDKparamString (&params, 'B');
tempFiller = CDKparamString (&params, 'F');
label = CDKparamString (&params, 'L');
outputFile = CDKparamString (&params, 'O');
title = CDKparamString (&params, 'T');
if ((temp = CDKparamString (&params, 'd')) != 0)
dType = char2DisplayType (temp);
/* Make sure all the command line parameters were provided. */
if (fieldWidth <= 0)
{
fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
ExitProgram (CLI_ERROR);
}
/* If the user asked for an output file, try to open it. */
if (outputFile != 0)
{
if ((fp = fopen (outputFile, "w")) == 0)
{
fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
ExitProgram (CLI_ERROR);
}
}
cdkScreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Check if the user wants to set the background of the main screen. */
if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
{
holder = char2Chtype (temp, &j1, &j2);
wbkgd (cdkScreen->window, holder[0]);
wrefresh (cdkScreen->window);
freeChtype (holder);
}
/* Get the widget color background color. */
if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
{
CDK_WIDGET_COLOR = 0;
}
/* If the set the filler character, set it now. */
if (tempFiller != 0)
{
holder = char2Chtype (tempFiller, &j1, &j2);
fieldAttr = A_ATTRIBUTES & holder[0];
filler = (char)holder[0];
freeChtype (holder);
}
/* Create the entry widget. */
widget = newCDKEntry (cdkScreen, xpos, ypos,
title, label,
fieldAttr,
(chtype)filler | fieldAttr,
dType, fieldWidth,
minValue, maxValue,
boxWidget, FALSE);
/* Check to make sure we created the dialog box. */
if (widget == 0)
{
/* Shut down curses and CDK. */
destroyCDKScreen (cdkScreen);
endCDK ();
fprintf (stderr,
"Error: Could not create the entry field. "
"Is the window too small?\n");
ExitProgram (CLI_ERROR);
}
/* Split the buttons if they supplied some. */
if (buttons != 0)
{
buttonList = CDKsplitString (buttons, '\n');
buttonCount = (int)CDKcountStrings ((CDK_CSTRING2)buttonList);
buttonWidget = newCDKButtonbox (cdkScreen,
getbegx (widget->win),
(getbegy (widget->win)
+ widget->boxHeight - 1),
1, widget->boxWidth - 1,
0, 1, buttonCount,
(CDK_CSTRING2)buttonList, buttonCount,
A_REVERSE, boxWidget, FALSE);
CDKfreeStrings (buttonList);
setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
/*
* We need to set the lower left and right
* characters of the entry field.
*/
setCDKEntryLLChar (widget, ACS_LTEE);
setCDKEntryLRChar (widget, ACS_RTEE);
/*
* Bind the Tab key in the entry field to send a
* Tab key to the button box widget.
*/
bindCDKObject (vENTRY, widget, KEY_TAB, widgetCB, buttonWidget);
bindCDKObject (vENTRY, widget, CDK_NEXT, widgetCB, buttonWidget);
bindCDKObject (vENTRY, widget, CDK_PREV, widgetCB, buttonWidget);
/* Check if the user wants to set the background of the widget. */
setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
/* Draw the button widget. */
drawCDKButtonbox (buttonWidget, boxWidget);
}
/*
* If the user asked for a shadow, we need to create one. Do this instead
* of using the shadow parameter because the button widget is not part of
* the main widget and if the user asks for both buttons and a shadow, we
* need to create a shadow big enough for both widgets. Create the shadow
* window using the widgets shadowWin element, so screen refreshes will draw
* them as well.
*/
if (shadowWidget == TRUE)
{
/* Determine the height of the shadow window. */
shadowHeight = (buttonWidget == 0 ?
widget->boxHeight :
widget->boxHeight + buttonWidget->boxHeight - 1);
/* Create the shadow window. */
widget->shadowWin = newwin (shadowHeight,
widget->boxWidth,
getbegy (widget->win) + 1,
getbegx (widget->win) + 1);
/* Make sure we could have created the shadow window. */
if (widget->shadowWin != 0)
{
widget->shadow = TRUE;
/*
* We force the widget and buttonWidget to be drawn so the
* buttonbox widget will be drawn when the widget is activated.
* Otherwise the shadow window will draw over the button widget.
*/
drawCDKEntry (widget, ObjOf (widget)->box);
eraseCDKButtonbox (buttonWidget);
drawCDKButtonbox (buttonWidget, ObjOf (buttonWidget)->box);
}
}
/* Check if the user wants to set the background of the widget. */
setCDKEntryBackgroundColor (widget, CDK_WIDGET_COLOR);
/* If there was an initial value, set it. */
if (initValue != 0)
{
setCDKEntryValue (widget, initValue);
}
/* Activate the widget. */
answer = copyChar (activateCDKEntry (widget, 0));
/* If there were buttons, get the button selected. */
if (buttonWidget != 0)
{
selection = buttonWidget->currentButton;
destroyCDKButtonbox (buttonWidget);
}
/* End CDK. */
destroyCDKEntry (widget);
destroyCDKScreen (cdkScreen);
endCDK ();
/* Print the value from the widget. */
if (answer != 0)
{
fprintf (fp, "%s\n", answer);
freeChar (answer);
}
fclose (fp);
/* Exit with the button number picked. */
ExitProgram (selection);
}
static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED,
void *clientData,
chtype key)
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
(void)injectCDKButtonbox (buttonbox, key);
return (TRUE);
}

238
deps/cdk-5.0-20161210/cli/cdkfselect.c vendored Normal file
View File

@ -0,0 +1,238 @@
/* $Id: cdkfselect.c,v 1.14 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef XCURSES
char *XCursesProgramName = "cdkfselect";
#endif
/*
* Declare file local prototypes.
*/
static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkScreen = 0;
CDKFSELECT *widget = 0;
CDKBUTTONBOX *buttonWidget = 0;
char *filename = 0;
char *CDK_WIDGET_COLOR = 0;
char *temp = 0;
chtype *holder = 0;
int selection = 0;
int shadowHeight = 0;
int buttonCount = 0;
FILE *fp = stderr;
char **buttonList = 0;
int j1, j2;
CDK_PARAMS params;
boolean boxWidget;
boolean shadowWidget;
char *buttons;
char *directory;
char *label;
char *outputFile;
char *title;
int height;
int width;
int xpos;
int ypos;
CDKparseParams (argc, argv, &params, "d:B:L:O:T:" CDK_CLI_PARAMS);
/* *INDENT-EQLS* */
xpos = CDKparamValue (&params, 'X', CENTER);
ypos = CDKparamValue (&params, 'Y', CENTER);
height = CDKparamValue (&params, 'H', 0);
width = CDKparamValue (&params, 'W', 0);
boxWidget = CDKparamValue (&params, 'N', TRUE);
shadowWidget = CDKparamValue (&params, 'S', FALSE);
directory = CDKparamString (&params, 'd');
buttons = CDKparamString (&params, 'B');
label = CDKparamString (&params, 'L');
outputFile = CDKparamString (&params, 'O');
title = CDKparamString (&params, 'T');
/* If the user asked for an output file, try to open it. */
if (outputFile != 0)
{
if ((fp = fopen (outputFile, "w")) == 0)
{
fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
ExitProgram (CLI_ERROR);
}
}
/* If they didn't provide a directory, use . */
if (directory == 0)
{
directory = copyChar (".");
}
/* Set the label of the file selector if it hasn't been yet. */
if (label == 0)
{
label = copyChar ("Directory: ");
}
cdkScreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Check if the user wants to set the background of the main screen. */
if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
{
holder = char2Chtype (temp, &j1, &j2);
wbkgd (cdkScreen->window, holder[0]);
wrefresh (cdkScreen->window);
freeChtype (holder);
}
/* Get the widget color background color. */
if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
{
CDK_WIDGET_COLOR = 0;
}
/* Create the file selector widget. */
widget = newCDKFselect (cdkScreen, xpos, ypos, height, width,
title, label, A_NORMAL, '.', A_REVERSE,
"", "", "", "",
boxWidget, shadowWidget);
freeChar (label);
/* Check to make sure we created the file selector. */
if (widget == 0)
{
CDKfreeStrings (buttonList);
destroyCDKScreen (cdkScreen);
endCDK ();
fprintf (stderr,
"Error: Could not create the file selector. "
"Is the window too small?\n");
ExitProgram (CLI_ERROR);
}
/* Split the buttons if they supplied some. */
if (buttons != 0)
{
buttonList = CDKsplitString (buttons, '\n');
buttonCount = (int)CDKcountStrings ((CDK_CSTRING2) buttonList);
/* We need to create a buttonbox widget. */
buttonWidget = newCDKButtonbox (cdkScreen,
getbegx (widget->win),
(getbegy (widget->win)
+ widget->boxHeight - 2),
1, widget->boxWidth - 2,
0, 1, buttonCount,
(CDK_CSTRING2) buttonList, buttonCount,
A_REVERSE, boxWidget, FALSE);
CDKfreeStrings (buttonList);
setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
/*
* We need to set the lower left and right
* characters of the widget.
*/
setCDKFselectLLChar (widget, ACS_LTEE);
setCDKFselectLRChar (widget, ACS_RTEE);
/*
* Bind the Tab key in the widget to send a
* Tab key to the button box widget.
*/
bindCDKObject (vFSELECT, widget, KEY_TAB, widgetCB, buttonWidget);
bindCDKObject (vFSELECT, widget, CDK_NEXT, widgetCB, buttonWidget);
bindCDKObject (vFSELECT, widget, CDK_PREV, widgetCB, buttonWidget);
/* Check if the user wants to set the background of the widget. */
setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
/* Draw the button widget. */
drawCDKButtonbox (buttonWidget, boxWidget);
}
/*
* If the user asked for a shadow, we need to create one. Do this instead
* of using the shadow parameter because the button widget is not part of
* the main widget and if the user asks for both buttons and a shadow, we
* need to create a shadow big enough for both widgets. Create the shadow
* window using the widgets shadowWin element, so screen refreshes will draw
* them as well.
*/
if (shadowWidget == TRUE)
{
/* Determine the height of the shadow window. */
shadowHeight = (buttonWidget == 0 ?
widget->boxHeight :
widget->boxHeight + buttonWidget->boxHeight - 1);
/* Create the shadow window. */
widget->shadowWin = newwin (shadowHeight,
widget->boxWidth,
getbegy (widget->win) + 1,
getbegx (widget->win) + 1);
/* Make sure we could have created the shadow window. */
if (widget->shadowWin != 0)
{
widget->shadow = TRUE;
/*
* We force the widget and buttonWidget to be drawn so the
* buttonbox widget will be drawn when the widget is activated.
* Otherwise the shadow window will draw over the button widget.
*/
drawCDKFselect (widget, ObjOf (widget)->box);
eraseCDKButtonbox (buttonWidget);
drawCDKButtonbox (buttonWidget, ObjOf (buttonWidget)->box);
}
}
/* Check if the user wants to set the background of the widget. */
setCDKFselectBackgroundColor (widget, CDK_WIDGET_COLOR);
/* Set the information for the file selector. */
setCDKFselectDirectory (widget, directory);
/* Activate the file selector. */
filename = copyChar (activateCDKFselect (widget, 0));
/* If there were buttons, get the button selected. */
if (buttonWidget != 0)
{
selection = buttonWidget->currentButton;
destroyCDKButtonbox (buttonWidget);
}
destroyCDKFselect (widget);
destroyCDKScreen (cdkScreen);
endCDK ();
/* Print the filename selected. */
fprintf (fp, "%s\n", filename);
freeChar (filename);
fclose (fp);
ExitProgram (selection);
}
static int widgetCB (EObjectType cdktype GCC_UNUSED,
void *object GCC_UNUSED,
void *clientData,
chtype key)
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
(void) injectCDKButtonbox (buttonbox, key);
return (TRUE);
}

271
deps/cdk-5.0-20161210/cli/cdkitemlist.c vendored Normal file
View File

@ -0,0 +1,271 @@
/* $Id: cdkitemlist.c,v 1.14 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef XCURSES
char *XCursesProgramName = "cdkitemlist";
#endif
/*
* Declare file local prototypes.
*/
static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
/*
* Define file local variables.
*/
static const char *FPUsage = "-l List | -f filename [-d Default Item] [-T Title] [-L Label] [-B Buttons] [-O Output File] [-X X Position] [-Y Y Position] [-N] [-S]";
/*
*
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkScreen = 0;
CDKITEMLIST *widget = 0;
CDKBUTTONBOX *buttonWidget = 0;
chtype *holder = 0;
char *answer = 0;
char *CDK_WIDGET_COLOR = 0;
char *temp = 0;
int ret = 0;
int buttonCount = 0;
int selection = 0;
int shadowHeight = 0;
FILE *fp = stderr;
char **itemlistList = 0;
char **buttonList = 0;
int itemlistLines, j1, j2;
CDK_PARAMS params;
boolean boxWidget;
boolean shadowWidget;
char *buttons;
char *filename;
char *label;
char *list;
char *outputFile;
char *title;
int defaultItem;
int xpos;
int ypos;
CDKparseParams (argc, argv, &params, "d:f:l:B:L:O:T:" CDK_MIN_PARAMS);
/* *INDENT-EQLS* */
xpos = CDKparamValue (&params, 'X', CENTER);
ypos = CDKparamValue (&params, 'Y', CENTER);
boxWidget = CDKparamValue (&params, 'N', TRUE);
shadowWidget = CDKparamValue (&params, 'S', FALSE);
defaultItem = CDKparamValue (&params, 'd', 0);
filename = CDKparamString (&params, 'f');
list = CDKparamString (&params, 'l');
buttons = CDKparamString (&params, 'B');
label = CDKparamString (&params, 'L');
outputFile = CDKparamString (&params, 'O');
title = CDKparamString (&params, 'T');
/* If the user asked for an output file, try to open it. */
if (outputFile != 0)
{
if ((fp = fopen (outputFile, "w")) == 0)
{
fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
ExitProgram (CLI_ERROR);
}
}
/* Did they provide a list of items. */
if (list == 0)
{
/* Maybe they gave a filename to use to read. */
if (filename != 0)
{
/* Read the file in. */
itemlistLines = CDKreadFile (filename, &itemlistList);
/* Check if there was an error. */
if (itemlistLines == -1)
{
fprintf (stderr, "Error: Could not open the file '%s'.\n", filename);
ExitProgram (CLI_ERROR);
}
}
else
{
/* They didn't provide anything. */
fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
ExitProgram (CLI_ERROR);
}
}
else
{
/* Split the itemlist lines up. */
itemlistList = CDKsplitString (list, '\n');
itemlistLines = (int)CDKcountStrings ((CDK_CSTRING2) itemlistList);
}
cdkScreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Check if the user wants to set the background of the main screen. */
if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
{
holder = char2Chtype (temp, &j1, &j2);
wbkgd (cdkScreen->window, holder[0]);
wrefresh (cdkScreen->window);
freeChtype (holder);
}
/* Get the widget color background color. */
if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
{
CDK_WIDGET_COLOR = 0;
}
/* Create the item list. */
widget = newCDKItemlist (cdkScreen, xpos, ypos,
title, label,
(CDK_CSTRING2) itemlistList, itemlistLines,
defaultItem,
boxWidget, shadowWidget);
/* Make sure we could create the widget. */
if (widget == 0)
{
CDKfreeStrings (itemlistList);
destroyCDKScreen (cdkScreen);
endCDK ();
fprintf (stderr,
"Error: Could not create the item list. "
"Is the window too small?\n");
ExitProgram (CLI_ERROR);
}
/* Split the buttons if they supplied some. */
if (buttons != 0)
{
buttonList = CDKsplitString (buttons, '\n');
buttonCount = (int)CDKcountStrings ((CDK_CSTRING2) buttonList);
/* We need to create a buttonbox widget. */
buttonWidget = newCDKButtonbox (cdkScreen,
getbegx (widget->win),
(getbegy (widget->win)
+ widget->boxHeight - 1),
1, widget->boxWidth - 1,
0, 1, buttonCount,
(CDK_CSTRING2) buttonList, buttonCount,
A_REVERSE, boxWidget, FALSE);
CDKfreeStrings (buttonList);
setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
/*
* We need to set the lower left and right
* characters of the widget.
*/
setCDKItemlistLLChar (widget, ACS_LTEE);
setCDKItemlistLRChar (widget, ACS_RTEE);
/*
* Bind the Tab key in the widget to send a
* Tab key to the button box widget.
*/
bindCDKObject (vITEMLIST, widget, KEY_TAB, widgetCB, buttonWidget);
bindCDKObject (vITEMLIST, widget, CDK_NEXT, widgetCB, buttonWidget);
bindCDKObject (vITEMLIST, widget, CDK_PREV, widgetCB, buttonWidget);
/* Check if the user wants to set the background of the widget. */
setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
/* Draw the button widget. */
drawCDKButtonbox (buttonWidget, boxWidget);
}
/*
* If the user asked for a shadow, we need to create one. Do this instead
* of using the shadow parameter because the button widget is not part of
* the main widget and if the user asks for both buttons and a shadow, we
* need to create a shadow big enough for both widgets. Create the shadow
* window using the widgets shadowWin element, so screen refreshes will draw
* them as well.
*/
if (shadowWidget == TRUE)
{
/* Determine the height of the shadow window. */
shadowHeight = (buttonWidget == 0 ?
widget->boxHeight :
widget->boxHeight + buttonWidget->boxHeight - 1);
/* Create the shadow window. */
widget->shadowWin = newwin (shadowHeight,
widget->boxWidth,
getbegy (widget->win) + 1,
getbegx (widget->win) + 1);
/* Make sure we could have created the shadow window. */
if (widget->shadowWin != 0)
{
widget->shadow = TRUE;
/*
* We force the widget and buttonWidget to be drawn so the
* buttonbox widget will be drawn when the widget is activated.
* Otherwise the shadow window will draw over the button widget.
*/
drawCDKItemlist (widget, ObjOf (widget)->box);
eraseCDKButtonbox (buttonWidget);
drawCDKButtonbox (buttonWidget, ObjOf (buttonWidget)->box);
}
}
/* Check if the user wants to set the background of the widget. */
setCDKItemlistBackgroundColor (widget, CDK_WIDGET_COLOR);
/* Activate the item list. */
ret = activateCDKItemlist (widget, 0);
/* If there were buttons, get the button selected. */
if (buttonWidget != 0)
{
selection = buttonWidget->currentButton;
destroyCDKButtonbox (buttonWidget);
}
destroyCDKItemlist (widget);
destroyCDKScreen (cdkScreen);
endCDK ();
/* Print out the answer. */
if (ret >= 0)
{
holder = char2Chtype (itemlistList[ret], &j1, &j2);
answer = chtype2Char (holder);
fprintf (fp, "%s\n", answer);
freeChar (answer);
freeChtype (holder);
}
CDKfreeStrings (itemlistList);
fclose (fp);
/* Exit with the answer. */
ExitProgram (selection);
}
static int widgetCB (EObjectType cdktype GCC_UNUSED,
void *object GCC_UNUSED,
void *clientData,
chtype key)
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
(void) injectCDKButtonbox (buttonbox, key);
return (TRUE);
}

164
deps/cdk-5.0-20161210/cli/cdklabel.c vendored Normal file
View File

@ -0,0 +1,164 @@
/* $Id: cdklabel.c,v 1.15 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef XCURSES
char *XCursesProgramName = "cdklabel";
#endif
#if !defined (HAVE_SLEEP) && defined (_WIN32) /* Mingw */
#define sleep(x) _sleep(x*1000)
#endif
/*
* Declare file local variables.
*/
static const char *FPUsage = "-m Message String | -f filename [-c Command] [-p Pause Character] [-s Sleep] [-X X Position] [-Y Y Position] [-N] [-S]";
/*
*
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkScreen = 0;
CDKLABEL *widget = 0;
char *CDK_WIDGET_COLOR = 0;
char *temp = 0;
chtype *holder = 0;
int messageLines = -1;
char **messageList = 0;
char tempCommand[1000];
int j1, j2;
CDK_PARAMS params;
boolean boxWidget;
boolean shadowWidget;
char *command;
char *filename;
char *message;
char waitChar = 0;
int sleepLength;
int xpos;
int ypos;
CDKparseParams (argc, argv, &params, "c:f:m:p:s:" CDK_MIN_PARAMS);
/* *INDENT-EQLS* */
xpos = CDKparamValue (&params, 'X', CENTER);
ypos = CDKparamValue (&params, 'Y', CENTER);
boxWidget = CDKparamValue (&params, 'N', TRUE);
shadowWidget = CDKparamValue (&params, 'S', FALSE);
sleepLength = CDKparamValue (&params, 's', 0);
command = CDKparamString (&params, 'c');
filename = CDKparamString (&params, 'f');
message = CDKparamString (&params, 'm');
if ((temp = CDKparamString (&params, 'p')) != 0)
waitChar = *temp;
/* Make sure we have a message to display. */
if (message == 0)
{
/* No message, maybe they provided a file to read. */
if (filename != 0)
{
/* Read the file in. */
messageLines = CDKreadFile (filename, &messageList);
/* Check if there was an error. */
if (messageLines == -1)
{
fprintf (stderr, "Error: Could not open the file %s\n", filename);
ExitProgram (CLI_ERROR);
}
}
else
{
/* No message, no file, it's an error. */
fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
ExitProgram (CLI_ERROR);
}
}
else
{
/* Split the message up. */
messageList = CDKsplitString (message, '\n');
messageLines = (int)CDKcountStrings ((CDK_CSTRING2) messageList);
}
cdkScreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Check if the user wants to set the background of the main screen. */
if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
{
holder = char2Chtype (temp, &j1, &j2);
wbkgd (cdkScreen->window, holder[0]);
wrefresh (cdkScreen->window);
freeChtype (holder);
}
/* Get the widget color background color. */
if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
{
CDK_WIDGET_COLOR = 0;
}
/* Create the label widget. */
widget = newCDKLabel (cdkScreen, xpos, ypos,
(CDK_CSTRING2) messageList, messageLines,
boxWidget, shadowWidget);
/* Make sure we could create the widget. */
if (widget == 0)
{
CDKfreeStrings (messageList);
destroyCDKScreen (cdkScreen);
endCDK ();
fprintf (stderr,
"Error: Could not create the label. "
"Is the window too small?\n");
ExitProgram (CLI_ERROR);
}
/* Check if the user wants to set the background of the widget. */
setCDKLabelBackgroundColor (widget, CDK_WIDGET_COLOR);
/* Draw the widget. */
drawCDKLabel (widget, boxWidget);
/* If they supplied a command, run it. */
if (command != 0)
{
const char *fmt = "(sh -c %.*s) >/dev/null 2>&1";
sprintf (tempCommand, fmt, (int)(sizeof (tempCommand) - strlen (fmt)), command);
system (tempCommand);
}
/* If they supplied a wait character, wait for the user to hit it. */
if (waitChar != 0)
{
waitCDKLabel (widget, waitChar);
}
/* If they supplied a sleep time, sleep for the given length. */
if (sleepLength > 0)
{
sleep ((unsigned)sleepLength);
}
CDKfreeStrings (messageList);
destroyCDKLabel (widget);
destroyCDKScreen (cdkScreen);
endCDK ();
/* Exit cleanly. */
ExitProgram (0);
}

386
deps/cdk-5.0-20161210/cli/cdkmatrix.c vendored Normal file
View File

@ -0,0 +1,386 @@
/* $Id: cdkmatrix.c,v 1.19 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef XCURSES
char *XCursesProgramName = "cdkmatrix";
#endif
#define MY_INFO(x,y) info[(x + 1) * cols + (y + 1)]
/*
* Declare file local prototypes.
*/
static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
/*
* Define file local variables.
*/
static const char *FPUsage = "-r Row Titles -c Column Titles -v Visible Rows -w Column Widths [-t Column Types] [-d Default Values] [-F Field Character] [-T Title] [-B Buttons] [-O Output File] [-X X Position] [-Y Y Position] [-N] [-S]";
/*
*
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkScreen = 0;
CDKMATRIX *widget = 0;
CDKBUTTONBOX *buttonWidget = 0;
chtype *holder = 0;
char *buttons = 0;
char *CDK_WIDGET_COLOR = 0;
char *temp = 0;
chtype filler = A_NORMAL | '.';
int rows = -1;
int cols = -1;
int buttonCount = 0;
int selection = 0;
int shadowHeight = 0;
FILE *fp = stderr;
char **rowTitles;
char **colTitles;
char **rowTemp = 0;
char **colTemp = 0;
char **kolTemp = 0;
char **buttonList = 0;
int *colWidths;
int *colTypes;
int count, infoLines, x, y, j1, j2;
CDK_PARAMS params;
boolean boxWidget;
boolean shadowWidget;
char *defaultValue;
char *myColTitles;
char *myColTypes;
char *myColWidths;
char *myFiller;
char *myRowTitles;
char *outputFile;
char *title;
int vrows;
int xpos;
int ypos;
CDKparseParams (argc, argv, &params, "c:d:r:t:w:v:B:F:O:T:" CDK_MIN_PARAMS);
/* *INDENT-EQLS* */
xpos = CDKparamValue (&params, 'X', CENTER);
ypos = CDKparamValue (&params, 'Y', CENTER);
boxWidget = CDKparamValue (&params, 'N', TRUE);
shadowWidget = CDKparamValue (&params, 'S', FALSE);
vrows = CDKparamValue (&params, 'v', -1);
myColTitles = CDKparamString (&params, 'c');
defaultValue = CDKparamString (&params, 'd');
myRowTitles = CDKparamString (&params, 'r');
myColTypes = CDKparamString (&params, 't');
myColWidths = CDKparamString (&params, 'w');
buttons = CDKparamString (&params, 'B');
myFiller = CDKparamString (&params, 'F');
outputFile = CDKparamString (&params, 'O');
title = CDKparamString (&params, 'T');
/* If the user asked for an output file, try to open it. */
if (outputFile != 0)
{
if ((fp = fopen (outputFile, "w")) == 0)
{
fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
ExitProgram (CLI_ERROR);
}
}
/* Make sure all the needed command line parameters were provided. */
if ((myRowTitles == 0) ||
(myColTitles == 0) ||
(myColWidths == 0) ||
(vrows == -1))
{
fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
ExitProgram (CLI_ERROR);
}
/* Convert the char * titles to a char **, offset by one */
rowTemp = CDKsplitString (myRowTitles, '\n');
rows = (int)CDKcountStrings ((CDK_CSTRING2)rowTemp);
rowTitles = (char **)calloc ((size_t) rows + 1, sizeof (char *));
for (x = 0; x < rows; x++)
{
rowTitles[x + 1] = rowTemp[x];
}
colTemp = CDKsplitString (myColTitles, '\n');
cols = (int)CDKcountStrings ((CDK_CSTRING2)colTemp);
colTitles = (char **)calloc ((size_t) cols + 1, sizeof (char *));
for (x = 0; x < cols; x++)
{
colTitles[x + 1] = colTemp[x];
}
/* Convert the column widths. */
kolTemp = CDKsplitString (myColWidths, '\n');
count = (int)CDKcountStrings ((CDK_CSTRING2)kolTemp);
colWidths = (int *)calloc ((size_t) count + 1, sizeof (int));
for (x = 0; x < count; x++)
{
colWidths[x + 1] = atoi (kolTemp[x]);
}
/* If they passed in the column types, convert them. */
if (myColTypes != 0)
{
char **ss = CDKsplitString (myColTypes, '\n');
count = (int)CDKcountStrings ((CDK_CSTRING2)ss);
colTypes = (int *)calloc ((size_t) MAXIMUM (cols, count) + 1, sizeof (int));
for (x = 0; x < count; x++)
{
colTypes[x + 1] = char2DisplayType (ss[x]);
}
CDKfreeStrings (ss);
}
else
{
/* If they didn't set default values. */
colTypes = (int *)calloc ((size_t) cols + 1, sizeof (int));
for (x = 0; x < cols; x++)
{
colTypes[x + 1] = vMIXED;
}
}
cdkScreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Check if the user wants to set the background of the main screen. */
if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
{
holder = char2Chtype (temp, &j1, &j2);
wbkgd (cdkScreen->window, holder[0]);
wrefresh (cdkScreen->window);
freeChtype (holder);
}
/* Get the widget color background color. */
if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
{
CDK_WIDGET_COLOR = 0;
}
/* If the set the filler character, set it now. */
if (myFiller != 0)
{
holder = char2Chtype (myFiller, &j1, &j2);
filler = holder[0];
freeChtype (holder);
}
/* Create the matrix widget. */
widget = newCDKMatrix (cdkScreen, xpos, ypos,
rows, cols, vrows, cols,
title, (CDK_CSTRING2)rowTitles, (CDK_CSTRING2)colTitles,
colWidths, colTypes, 1, 1,
filler, COL,
boxWidget, TRUE, shadowWidget);
free (rowTitles);
free (colTitles);
/* Make sure we could create the widget. */
if (widget == 0)
{
/* Shut down curses and CDK. */
destroyCDKScreen (cdkScreen);
endCDK ();
fprintf (stderr,
"Error: Cannot create the matrix. "
"Is the window too small?\n");
ExitProgram (CLI_ERROR);
}
/*
* If the user sent in a file of default values, read it and
* stick the values read in from the file into the matrix.
*/
if (defaultValue != 0)
{
size_t limit = (size_t) ((rows + 1) * (cols + 1));
char **info = (char **)calloc (limit, sizeof (char *));
char **lineTemp = 0;
/* Read the file. */
infoLines = CDKreadFile (defaultValue, &lineTemp);
if (infoLines > 0)
{
int *subSize = (int *)calloc ((size_t) infoLines + 1, sizeof (int));
/* For each line, split on a CTRL-V. */
for (x = 0; x < infoLines; x++)
{
char **ss = CDKsplitString (lineTemp[x], CTRL ('V'));
subSize[x + 1] = (int)CDKcountStrings ((CDK_CSTRING2)ss);
for (y = 0; y < subSize[x + 1]; y++)
{
MY_INFO (x, y) = ss[y];
}
free (ss);
}
CDKfreeStrings (lineTemp);
setCDKMatrixCells (widget, (CDK_CSTRING2)info, rows, cols, subSize);
for (x = 0; x < infoLines; x++)
{
for (y = 0; y < subSize[x + 1]; y++)
{
freeChar (MY_INFO (x, y));
}
}
free (info);
free (subSize);
}
}
/* Split the buttons if they supplied some. */
if (buttons != 0)
{
/* Split the button list up. */
buttonList = CDKsplitString (buttons, '\n');
buttonCount = (int)CDKcountStrings ((CDK_CSTRING2)buttonList);
/* We need to create a buttonbox widget. */
buttonWidget = newCDKButtonbox (cdkScreen,
getbegx (widget->win),
(getbegy (widget->win)
+ widget->boxHeight - 1),
1, widget->boxWidth - 1,
NULL, 1, buttonCount,
(CDK_CSTRING2)buttonList, buttonCount,
A_REVERSE, boxWidget, FALSE);
setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
/*
* We need to set the lower left and right
* characters of the widget.
*/
setCDKMatrixLLChar (widget, ACS_LTEE);
setCDKMatrixLRChar (widget, ACS_RTEE);
/*
* Bind the Tab key in the widget to send a
* Tab key to the button box widget.
*/
bindCDKObject (vMATRIX, widget, KEY_TAB, widgetCB, buttonWidget);
bindCDKObject (vMATRIX, widget, CDK_NEXT, widgetCB, buttonWidget);
bindCDKObject (vMATRIX, widget, CDK_PREV, widgetCB, buttonWidget);
/* Check if the user wants to set the background of the widget. */
setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
/* Draw the button widget. */
drawCDKButtonbox (buttonWidget, boxWidget);
}
/*
* If the user asked for a shadow, we need to create one. Do this instead
* of using the shadow parameter because the button widget is not part of
* the main widget and if the user asks for both buttons and a shadow, we
* need to create a shadow big enough for both widgets. Create the shadow
* window using the widgets shadowWin element, so screen refreshes will draw
* them as well.
*/
if (shadowWidget == TRUE)
{
/* Determine the height of the shadow window. */
shadowHeight = (buttonWidget == (CDKBUTTONBOX *)NULL ?
widget->boxHeight :
widget->boxHeight + buttonWidget->boxHeight - 1);
/* Create the shadow window. */
widget->shadowWin = newwin (shadowHeight,
widget->boxWidth,
getbegy (widget->win) + 1,
getbegx (widget->win) + 1);
/* Make sure we could have created the shadow window. */
if (widget->shadowWin != 0)
{
widget->shadow = TRUE;
/*
* We force the widget and buttonWidget to be drawn so the
* buttonbox widget will be drawn when the widget is activated.
* Otherwise the shadow window will draw over the button widget.
*/
drawCDKMatrix (widget, ObjOf (widget)->box);
eraseCDKButtonbox (buttonWidget);
drawCDKButtonbox (buttonWidget, ObjOf (buttonWidget)->box);
}
}
/* Check if the user wants to set the background of the widget. */
setCDKMatrixBackgroundColor (widget, CDK_WIDGET_COLOR);
/* Let them play. */
activateCDKMatrix (widget, 0);
/* Print out the matrix cells. */
if (widget->exitType == vNORMAL)
{
for (x = 0; x < widget->rows; x++)
{
for (y = 0; y < widget->cols; y++)
{
char *data = getCDKMatrixCell (widget, x, y);
if (data != 0)
{
fprintf (fp, "%s%c", data, CTRL ('V'));
}
else
{
fprintf (fp, "%c", CTRL ('V'));
}
}
fprintf (fp, "\n");
}
}
/* If there were buttons, get the button selected. */
if (buttonWidget != 0)
{
selection = buttonWidget->currentButton;
destroyCDKButtonbox (buttonWidget);
}
/* cleanup (not really needed) */
CDKfreeStrings (buttonList);
free (colTypes);
free (colWidths);
CDKfreeStrings (rowTemp);
CDKfreeStrings (colTemp);
CDKfreeStrings (kolTemp);
destroyCDKMatrix (widget);
destroyCDKScreen (cdkScreen);
endCDK ();
/* do this late, in case it was stderr */
fclose (fp);
ExitProgram (selection);
}
static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED,
void *clientData,
chtype key)
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
(void)injectCDKButtonbox (buttonbox, key);
return (TRUE);
}

270
deps/cdk-5.0-20161210/cli/cdkmentry.c vendored Normal file
View File

@ -0,0 +1,270 @@
/* $Id: cdkmentry.c,v 1.14 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef XCURSES
char *XCursesProgramName = "cdkmentry";
#endif
/*
* Declare file local prototypes.
*/
static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
/*
* Define file local variables.
*/
static const char *FPUsage = "-f Field Width -s Screen Rows -v Virtual Rows [-d Display Type] [-F Field Character] [-i Initial Value] [-m Minimum Length] [-T Title] [-L Label] [-B Buttons] [-O Output file] [-X X Position] [-Y Y Position] [-N] [-S]";
/*
*
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkScreen = 0;
CDKMENTRY *widget = 0;
CDKBUTTONBOX *buttonWidget = 0;
chtype *holder = 0;
chtype fieldAttr = 0;
char *answer = 0;
char *CDK_WIDGET_COLOR = 0;
char *temp = 0;
char filler = '.';
EDisplayType dType = vMIXED;
int buttonCount = 0;
int selection = 0;
int shadowHeight = 0;
FILE *fp = stderr;
char **buttonList = 0;
int j1, j2;
CDK_PARAMS params;
boolean boxWidget;
boolean shadowWidget;
char *buttons;
char *initValue;
char *label;
char *outputFile;
char *tempFiller;
char *title;
int fieldWidth;
int min;
int screenRows;
int virtualRows;
int xpos;
int ypos;
CDKparseParams (argc, argv, &params, "d:f:i:m:s:v:B:F:L:O:T:" CDK_MIN_PARAMS);
/* *INDENT-EQLS* */
xpos = CDKparamValue (&params, 'X', CENTER);
ypos = CDKparamValue (&params, 'Y', CENTER);
boxWidget = CDKparamValue (&params, 'N', TRUE);
shadowWidget = CDKparamValue (&params, 'S', FALSE);
fieldWidth = CDKparamValue (&params, 'f', 0);
min = CDKparamValue (&params, 'm', 0);
screenRows = CDKparamValue (&params, 's', 0);
virtualRows = CDKparamValue (&params, 'v', 0);
initValue = CDKparamString (&params, 'i');
buttons = CDKparamString (&params, 'B');
tempFiller = CDKparamString (&params, 'F');
label = CDKparamString (&params, 'L');
outputFile = CDKparamString (&params, 'O');
title = CDKparamString (&params, 'T');
if ((temp = CDKparamString (&params, 'd')) != 0)
dType = char2DisplayType (temp);
/* Make sure all the command line parameters were provided. */
if ((fieldWidth <= 0) || (screenRows <= 0) || (virtualRows <= 0))
{
fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
ExitProgram (CLI_ERROR);
}
/* If the user asked for an output file, try to open it. */
if (outputFile != 0)
{
if ((fp = fopen (outputFile, "w")) == 0)
{
fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
ExitProgram (CLI_ERROR);
}
}
cdkScreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Check if the user wants to set the background of the main screen. */
if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
{
holder = char2Chtype (temp, &j1, &j2);
wbkgd (cdkScreen->window, holder[0]);
wrefresh (cdkScreen->window);
freeChtype (holder);
}
/* Get the widget color background color. */
if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
{
CDK_WIDGET_COLOR = 0;
}
/* If the set the filler character, set it now. */
if (tempFiller != 0)
{
holder = char2Chtype (tempFiller, &j1, &j2);
fieldAttr = A_ATTRIBUTES & holder[0];
filler = (char)holder[0];
freeChtype (holder);
}
/* Create the mentry widget. */
widget = newCDKMentry (cdkScreen, xpos, ypos,
title, label,
fieldAttr,
(chtype)filler | fieldAttr,
dType, fieldWidth,
screenRows, virtualRows,
min, boxWidget, shadowWidget);
/* Check to make sure we created the dialog box. */
if (widget == 0)
{
/* Shut down curses and CDK. */
destroyCDKScreen (cdkScreen);
endCDK ();
fprintf (stderr,
"Error: Could not create the multiple line entry field. "
"Is the window too small?\n");
ExitProgram (CLI_ERROR);
}
/* Split the buttons if they supplied some. */
if (buttons != 0)
{
buttonList = CDKsplitString (buttons, '\n');
buttonCount = (int)CDKcountStrings ((CDK_CSTRING2) buttonList);
/* We need to create a buttonbox widget. */
buttonWidget = newCDKButtonbox (cdkScreen,
getbegx (widget->win),
(getbegy (widget->win)
+ widget->boxHeight - 1),
1, widget->boxWidth - 1,
NULL, 1, buttonCount,
(CDK_CSTRING2) buttonList, buttonCount,
A_REVERSE, boxWidget, FALSE);
CDKfreeStrings (buttonList);
setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
/*
* We need to set the lower left and right
* characters of the widget.
*/
setCDKMentryLLChar (widget, ACS_LTEE);
setCDKMentryLRChar (widget, ACS_RTEE);
/*
* Bind the Tab key in the widget to send a
* Tab key to the button box widget.
*/
bindCDKObject (vMENTRY, widget, KEY_TAB, widgetCB, buttonWidget);
bindCDKObject (vMENTRY, widget, CDK_NEXT, widgetCB, buttonWidget);
bindCDKObject (vMENTRY, widget, CDK_PREV, widgetCB, buttonWidget);
/* Check if the user wants to set the background of the widget. */
setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
/* Draw the button widget. */
drawCDKButtonbox (buttonWidget, boxWidget);
}
/*
* If the user asked for a shadow, we need to create one. Do this instead
* of using the shadow parameter because the button widget is not part of
* the main widget and if the user asks for both buttons and a shadow, we
* need to create a shadow big enough for both widgets. Create the shadow
* window using the widgets shadowWin element, so screen refreshes will draw
* them as well.
*/
if (shadowWidget == TRUE)
{
/* Determine the height of the shadow window. */
shadowHeight = (buttonWidget == (CDKBUTTONBOX *)NULL ?
widget->boxHeight :
widget->boxHeight + buttonWidget->boxHeight - 1);
/* Create the shadow window. */
widget->shadowWin = newwin (shadowHeight,
widget->boxWidth,
getbegy (widget->win) + 1,
getbegx (widget->win) + 1);
/* Make sure we could have created the shadow window. */
if (widget->shadowWin != 0)
{
widget->shadow = TRUE;
/*
* We force the widget and buttonWidget to be drawn so the
* buttonbox widget will be drawn when the widget is activated.
* Otherwise the shadow window will draw over the button widget.
*/
drawCDKMentry (widget, ObjOf (widget)->box);
eraseCDKButtonbox (buttonWidget);
drawCDKButtonbox (buttonWidget, ObjOf (buttonWidget)->box);
}
}
/* Check if the user wants to set the background of the widget. */
setCDKMentryBackgroundColor (widget, CDK_WIDGET_COLOR);
/* If there was an initial value, set it. */
if (initValue != 0)
{
setCDKMentryValue (widget, initValue);
}
/* Activate the widget. */
answer = copyChar (activateCDKMentry (widget, 0));
/* If there were buttons, get the button selected. */
if (buttonWidget != 0)
{
selection = buttonWidget->currentButton;
destroyCDKButtonbox (buttonWidget);
}
/* End CDK. */
destroyCDKMentry (widget);
destroyCDKScreen (cdkScreen);
endCDK ();
/* Print the value from the widget. */
if (answer != 0)
{
fprintf (fp, "%s\n", answer);
freeChar (answer);
}
fclose (fp);
/* Exit with the button number picked. */
ExitProgram (selection);
}
static int widgetCB (EObjectType cdktype GCC_UNUSED,
void *object GCC_UNUSED,
void *clientData,
chtype key)
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
(void) injectCDKButtonbox (buttonbox, key);
return (TRUE);
}

293
deps/cdk-5.0-20161210/cli/cdkradio.c vendored Normal file
View File

@ -0,0 +1,293 @@
/* $Id: cdkradio.c,v 1.13 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef XCURSES
char *XCursesProgramName = "cdkradio";
#endif
/*
* Declare file local prototypes.
*/
static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
/*
* Define file local variables.
*/
static const char *FPUsage = "-l List | -f filename [-c Choice Character] [-d Default Item] [-s Scroll Bar Position] [-n Numbers] [-i Item Index] [-T Title] [-B Buttons] [-O Output File] [-X X Position] [-Y Y Position] [-H Height] [-W Width] [-N] [-S]";
/*
*
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkScreen = 0;
CDKRADIO *widget = 0;
CDKBUTTONBOX *buttonWidget = 0;
char *buttons = 0;
char *CDK_WIDGET_COLOR = 0;
char *temp = 0;
chtype *holder = 0;
chtype *choiceChar = 0;
int answer = 0;
int spos = NONE;
int scrollLines = -1;
int buttonCount = 0;
int selection = 0;
int shadowHeight = 0;
FILE *fp = stderr;
char **buttonList = 0;
char **scrollList = 0;
int j1, j2;
CDK_PARAMS params;
boolean boxWidget;
boolean numberOutput;
boolean shadowWidget;
const char *choice;
char *filename;
char *list;
char *outputFile;
char *title;
int defaultItem;
int height;
int width;
int xpos;
int ypos;
CDKparseParams (argc, argv, &params, "l:f:s:c:d:iB:O:T:" CDK_CLI_PARAMS);
/* *INDENT-EQLS* */
xpos = CDKparamValue (&params, 'X', CENTER);
ypos = CDKparamValue (&params, 'Y', CENTER);
height = CDKparamValue (&params, 'H', 10);
width = CDKparamValue (&params, 'W', 1);
boxWidget = CDKparamValue (&params, 'N', TRUE);
shadowWidget = CDKparamValue (&params, 'S', FALSE);
defaultItem = CDKparamValue (&params, 'd', 0);
numberOutput = CDKparamValue (&params, 'i', FALSE);
filename = CDKparamString (&params, 'f');
list = CDKparamString (&params, 'l');
buttons = CDKparamString (&params, 'B');
outputFile = CDKparamString (&params, 'O');
title = CDKparamString (&params, 'T');
if ((choice = CDKparamString (&params, 'c')) == 0)
choice = "</R>X";
spos = CDKparsePosition (CDKparamString (&params, 's'));
/* If the user asked for an output file, try to open it. */
if (outputFile != 0)
{
if ((fp = fopen (outputFile, "w")) == 0)
{
fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
ExitProgram (CLI_ERROR);
}
}
/* Did they provide a list of items. */
if (list == 0)
{
/* Maybe they gave a filename to use to read. */
if (filename != 0)
{
/* Read the file in. */
scrollLines = CDKreadFile (filename, &scrollList);
/* Check if there was an error. */
if (scrollLines == -1)
{
fprintf (stderr, "Error: Could not open the file '%s'.\n", filename);
ExitProgram (CLI_ERROR);
}
}
else
{
/* They didn't provide anything. */
fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
ExitProgram (CLI_ERROR);
}
}
else
{
/* Split the scroll lines up. */
scrollList = CDKsplitString (list, '\n');
scrollLines = (int)CDKcountStrings ((CDK_CSTRING2) scrollList);
}
cdkScreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Check if the user wants to set the background of the main screen. */
if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
{
holder = char2Chtype (temp, &j1, &j2);
wbkgd (cdkScreen->window, holder[0]);
wrefresh (cdkScreen->window);
freeChtype (holder);
}
/* Get the widget color background color. */
if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
{
CDK_WIDGET_COLOR = 0;
}
/* Convert the char * choiceChar to a chtype * */
choiceChar = char2Chtype (choice, &j1, &j2);
/* Create the scrolling list. */
widget = newCDKRadio (cdkScreen, xpos, ypos, spos,
height, width, title,
(CDK_CSTRING2) scrollList, scrollLines,
choiceChar[0], defaultItem,
A_REVERSE,
boxWidget, shadowWidget);
free (choiceChar);
/* Make sure we could create the widget. */
if (widget == 0)
{
CDKfreeStrings (scrollList);
destroyCDKScreen (cdkScreen);
endCDK ();
fprintf (stderr,
"Error: Could not create the radio list. "
"Is the window too small?\n");
ExitProgram (CLI_ERROR);
}
/* Split the buttons if they supplied some. */
if (buttons != 0)
{
/* Split the button list up. */
buttonList = CDKsplitString (buttons, '\n');
buttonCount = (int)CDKcountStrings ((CDK_CSTRING2) buttonList);
/* We need to create a buttonbox widget. */
buttonWidget = newCDKButtonbox (cdkScreen,
getbegx (widget->win),
(getbegy (widget->win)
+ widget->boxHeight - 1),
1, widget->boxWidth - 1,
NULL, 1, buttonCount,
(CDK_CSTRING2) buttonList, buttonCount,
A_REVERSE, boxWidget, FALSE);
CDKfreeStrings (buttonList);
setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
/*
* We need to set the lower left and right
* characters of the widget.
*/
setCDKRadioLLChar (widget, ACS_LTEE);
setCDKRadioLRChar (widget, ACS_RTEE);
/*
* Bind the Tab key in the widget to send a
* Tab key to the button box widget.
*/
bindCDKObject (vRADIO, widget, KEY_TAB, widgetCB, buttonWidget);
bindCDKObject (vRADIO, widget, CDK_NEXT, widgetCB, buttonWidget);
bindCDKObject (vRADIO, widget, CDK_PREV, widgetCB, buttonWidget);
/* Check if the user wants to set the background of the widget. */
setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
/* Draw the button widget. */
drawCDKButtonbox (buttonWidget, boxWidget);
}
/*
* If the user asked for a shadow, we need to create one. Do this instead
* of using the shadow parameter because the button widget is not part of
* the main widget and if the user asks for both buttons and a shadow, we
* need to create a shadow big enough for both widgets. Create the shadow
* window using the widgets shadowWin element, so screen refreshes will draw
* them as well.
*/
if (shadowWidget == TRUE)
{
/* Determine the height of the shadow window. */
shadowHeight = (buttonWidget == (CDKBUTTONBOX *)NULL ?
widget->boxHeight :
widget->boxHeight + buttonWidget->boxHeight - 1);
/* Create the shadow window. */
widget->shadowWin = newwin (shadowHeight,
widget->boxWidth,
getbegy (widget->win) + 1,
getbegx (widget->win) + 1);
if (widget->shadowWin != 0)
{
widget->shadow = TRUE;
/*
* We force the widget and buttonWidget to be drawn so the
* buttonbox widget will be drawn when the widget is activated.
* Otherwise the shadow window will draw over the button widget.
*/
drawCDKRadio (widget, ObjOf (widget)->box);
eraseCDKButtonbox (buttonWidget);
drawCDKButtonbox (buttonWidget, ObjOf (buttonWidget)->box);
}
}
/* Check if the user wants to set the background of the widget. */
setCDKRadioBackgroundColor (widget, CDK_WIDGET_COLOR);
/* Activate the scrolling list. */
answer = activateCDKRadio (widget, 0);
/* If there were buttons, get the button selected. */
if (buttonWidget != 0)
{
selection = buttonWidget->currentButton;
destroyCDKButtonbox (buttonWidget);
}
/* Shut down curses. */
destroyCDKRadio (widget);
destroyCDKScreen (cdkScreen);
endCDK ();
/* Print out the answer. */
if (answer >= 0)
{
if (numberOutput == TRUE)
{
fprintf (fp, "%d\n", answer);
}
else
{
fprintf (fp, "%s\n", scrollList[answer]);
}
}
fclose (fp);
CDKfreeStrings (scrollList);
/* Exit with the button selected. */
ExitProgram (selection);
}
static int widgetCB (EObjectType cdktype GCC_UNUSED,
void *object GCC_UNUSED,
void *clientData,
chtype key)
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
(void) injectCDKButtonbox (buttonbox, key);
return (TRUE);
}

281
deps/cdk-5.0-20161210/cli/cdkscale.c vendored Normal file
View File

@ -0,0 +1,281 @@
/* $Id: cdkscale.c,v 1.14 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef XCURSES
char *XCursesProgramName = "cdkscale";
#endif
/*
* Declare file local prototypes.
*/
static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
/*
* Define file local variables.
*/
static const char *FPUsage = "-f Field Width -l Low Value -h High Value [-s Initial Value]] [-i Increment Value] [-a Accelerated Increment Value] [-T Title] [-L Label] [-B Buttons] [-O Output File] [-X X Position] [-Y Y Position] [-N] [-S]";
/*
*
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkScreen = 0;
CDKSCALE *widget = 0;
CDKBUTTONBOX *buttonWidget = 0;
char *CDK_WIDGET_COLOR = 0;
char *temp = 0;
chtype *holder = 0;
int answer = 0;
int buttonCount = 0;
int selection = 0;
int shadowHeight = 0;
FILE *fp = stderr;
char **buttonList = 0;
int tmp, j1, j2;
CDK_PARAMS params;
boolean boxWidget;
boolean shadowWidget;
char *buttons;
char *label;
char *outputFile;
char *title;
int fieldWidth;
int incrementStep;
int acceleratedStep;
int initValue;
int lowValue;
int highValue;
int xpos;
int ypos;
CDKparseParams (argc, argv, &params, "a:f:h:i:l:s:B:L:O:T:" CDK_MIN_PARAMS);
/* *INDENT-EQLS* */
xpos = CDKparamValue (&params, 'X', CENTER);
ypos = CDKparamValue (&params, 'Y', CENTER);
boxWidget = CDKparamValue (&params, 'N', TRUE);
shadowWidget = CDKparamValue (&params, 'S', FALSE);
acceleratedStep = CDKparamValue (&params, 'a', -1);
fieldWidth = CDKparamValue (&params, 'f', 0);
highValue = CDKparamValue (&params, 'h', INT_MIN);
incrementStep = CDKparamValue (&params, 'i', 1);
lowValue = CDKparamValue (&params, 'l', INT_MAX);
initValue = CDKparamValue (&params, 's', INT_MIN);
buttons = CDKparamString (&params, 'B');
label = CDKparamString (&params, 'L');
outputFile = CDKparamString (&params, 'O');
title = CDKparamString (&params, 'T');
incrementStep = abs (incrementStep);
/* Make sure all the command line parameters were provided. */
if (fieldWidth <= 0)
{
fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
ExitProgram (CLI_ERROR);
}
/* Make sure the user supplied the low/high values. */
if ((lowValue == INT_MAX) || (highValue == INT_MIN))
{
fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
ExitProgram (CLI_ERROR);
}
/* If the user asked for an output file, try to open it. */
if (outputFile != 0)
{
if ((fp = fopen (outputFile, "w")) == 0)
{
fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
ExitProgram (CLI_ERROR);
}
}
/* Make sure the low is lower than the high (and vice versa). */
if (lowValue > highValue)
{
/* *INDENT-EQLS* */
tmp = lowValue;
lowValue = highValue;
highValue = tmp;
}
/* Make sure the starting value is in range. */
if (initValue < lowValue)
{
initValue = lowValue;
}
else if (initValue > highValue)
{
initValue = highValue;
}
/* Check if the accelerated incremnt value was set. */
if (acceleratedStep <= 0)
{
acceleratedStep = (int)((highValue - lowValue) / 10);
acceleratedStep = MAXIMUM (1, acceleratedStep);
}
cdkScreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Check if the user wants to set the background of the main screen. */
if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
{
holder = char2Chtype (temp, &j1, &j2);
wbkgd (cdkScreen->window, holder[0]);
wrefresh (cdkScreen->window);
freeChtype (holder);
}
/* Get the widget color background color. */
if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
{
CDK_WIDGET_COLOR = 0;
}
/* Create the entry widget. */
widget = newCDKScale (cdkScreen, xpos, ypos,
title, label,
A_NORMAL, fieldWidth,
initValue, lowValue, highValue,
incrementStep, acceleratedStep,
boxWidget, shadowWidget);
/* Check to make sure we created the dialog box. */
if (widget == 0)
{
/* Shut down curses and CDK. */
destroyCDKScreen (cdkScreen);
endCDK ();
fprintf (stderr,
"Error: Could not create the numeric scale field. "
"Is the window too small?\n");
ExitProgram (CLI_ERROR);
}
/* Split the buttons if they supplied some. */
if (buttons != 0)
{
/* Split the button list up. */
buttonList = CDKsplitString (buttons, '\n');
buttonCount = (int)CDKcountStrings ((CDK_CSTRING2) buttonList);
/* We need to create a buttonbox widget. */
buttonWidget = newCDKButtonbox (cdkScreen,
getbegx (widget->win),
(getbegy (widget->win)
+ widget->boxHeight - 1),
1, widget->boxWidth - 1,
0, 1, buttonCount,
(CDK_CSTRING2) buttonList, buttonCount,
A_REVERSE, boxWidget, FALSE);
CDKfreeStrings (buttonList);
setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
/*
* We need to set the lower left and right
* characters of the widget.
*/
setCDKScaleLLChar (widget, ACS_LTEE);
setCDKScaleLRChar (widget, ACS_RTEE);
/*
* Bind the Tab key in the widget to send a
* Tab key to the button box widget.
*/
bindCDKObject (vSCALE, widget, KEY_TAB, widgetCB, buttonWidget);
bindCDKObject (vSCALE, widget, CDK_NEXT, widgetCB, buttonWidget);
bindCDKObject (vSCALE, widget, CDK_PREV, widgetCB, buttonWidget);
/* Check if the user wants to set the background of the widget. */
setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
/* Draw the button widget. */
drawCDKButtonbox (buttonWidget, boxWidget);
}
/*
* If the user asked for a shadow, we need to create one. Do this instead
* of using the shadow parameter because the button widget is not part of
* the main widget and if the user asks for both buttons and a shadow, we
* need to create a shadow big enough for both widgets. Create the shadow
* window using the widgets shadowWin element, so screen refreshes will draw
* them as well.
*/
if (shadowWidget == TRUE)
{
/* Determine the height of the shadow window. */
shadowHeight = (buttonWidget == 0 ?
widget->boxHeight :
widget->boxHeight + buttonWidget->boxHeight - 1);
/* Create the shadow window. */
widget->shadowWin = newwin (shadowHeight,
widget->boxWidth,
getbegy (widget->win) + 1,
getbegx (widget->win) + 1);
/* Make sure we could have created the shadow window. */
if (widget->shadowWin != 0)
{
widget->shadow = TRUE;
/*
* We force the widget and buttonWidget to be drawn so the
* buttonbox widget will be drawn when the widget is activated.
* Otherwise the shadow window will draw over the button widget.
*/
drawCDKScale (widget, ObjOf (widget)->box);
eraseCDKButtonbox (buttonWidget);
drawCDKButtonbox (buttonWidget, ObjOf (buttonWidget)->box);
}
}
/* Check if the user wants to set the background of the widget. */
setCDKScaleBackgroundColor (widget, CDK_WIDGET_COLOR);
/* Activate the widget. */
answer = activateCDKScale (widget, 0);
/* If there were buttons, get the button selected. */
if (buttonWidget != 0)
{
selection = buttonWidget->currentButton;
destroyCDKButtonbox (buttonWidget);
}
/* End CDK. */
destroyCDKScale (widget);
destroyCDKScreen (cdkScreen);
endCDK ();
/* Print the value from the widget. */
fprintf (fp, "%d\n", answer);
fclose (fp);
/* Exit with the answer. */
ExitProgram (selection);
}
static int widgetCB (EObjectType cdktype GCC_UNUSED,
void *object GCC_UNUSED,
void *clientData,
chtype key)
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
(void) injectCDKButtonbox (buttonbox, key);
return (TRUE);
}

284
deps/cdk-5.0-20161210/cli/cdkscroll.c vendored Normal file
View File

@ -0,0 +1,284 @@
/* $Id: cdkscroll.c,v 1.13 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef XCURSES
char *XCursesProgramName = "cdkscroll";
#endif
/*
* Declare file local prototypes.
*/
static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
/*
* Define file local variables.
*/
static const char *FPUsage = "-l List | -f filename [-s Scroll Bar Position] [-n Numbers] [-i Item Index] [-T Title] [-B Buttons] [-O Output File] [-X X Position] [-Y Y Position] [-H Height] [-W Width] [-N] [-S]";
/*
*
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkScreen = 0;
CDKSCROLL *widget = 0;
CDKBUTTONBOX *buttonWidget = 0;
char *CDK_WIDGET_COLOR = 0;
char *temp = 0;
chtype *holder = 0;
int answer = 0;
int spos = NONE;
int buttonCount = 0;
int selection = 0;
int scrollLines = -1;
int shadowHeight = 0;
FILE *fp = stderr;
char **scrollList = 0;
char **buttonList = 0;
int j1, j2;
CDK_PARAMS params;
boolean boxWidget;
boolean shadowWidget;
char *buttons;
char *filename;
char *list;
char *outputFile;
char *title;
int height;
int numberOutput;
int numbers;
int width;
int xpos;
int ypos;
CDKparseParams (argc, argv, &params, "f:il:ns:B:O:T:" CDK_CLI_PARAMS);
/* *INDENT-EQLS* */
xpos = CDKparamValue (&params, 'X', CENTER);
ypos = CDKparamValue (&params, 'Y', CENTER);
height = CDKparamValue (&params, 'H', 1);
width = CDKparamValue (&params, 'W', 1);
boxWidget = CDKparamValue (&params, 'N', TRUE);
shadowWidget = CDKparamValue (&params, 'S', FALSE);
numberOutput = CDKparamValue (&params, 'i', FALSE);
numbers = CDKparamValue (&params, 'n', FALSE);
filename = CDKparamString (&params, 'f');
list = CDKparamString (&params, 'l');
buttons = CDKparamString (&params, 'B');
outputFile = CDKparamString (&params, 'O');
title = CDKparamString (&params, 'T');
spos = CDKparsePosition (CDKparamString (&params, 's'));
/* If the user asked for an output file, try to open it. */
if (outputFile != 0)
{
if ((fp = fopen (outputFile, "w")) == 0)
{
fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
ExitProgram (CLI_ERROR);
}
}
/* Did they provide a list of items. */
if (list == 0)
{
/* Maybe they gave a filename to use to read. */
if (filename != 0)
{
/* Read the file in. */
scrollLines = CDKreadFile (filename, &scrollList);
/* Check if there was an error. */
if (scrollLines == -1)
{
fprintf (stderr, "Error: Could not open the file '%s'.\n", filename);
ExitProgram (CLI_ERROR);
}
}
else
{
/* They didn't provide anything. */
fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
ExitProgram (CLI_ERROR);
}
}
else
{
/* Split the scroll lines up. */
scrollList = CDKsplitString (list, '\n');
scrollLines = (int)CDKcountStrings ((CDK_CSTRING2) scrollList);
}
cdkScreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Check if the user wants to set the background of the main screen. */
if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
{
holder = char2Chtype (temp, &j1, &j2);
wbkgd (cdkScreen->window, holder[0]);
wrefresh (cdkScreen->window);
freeChtype (holder);
}
/* Get the widget color background color. */
if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
{
CDK_WIDGET_COLOR = 0;
}
/* Create the scrolling list. */
widget = newCDKScroll (cdkScreen, xpos, ypos, spos,
height, width, title,
(CDK_CSTRING2) scrollList, scrollLines,
numbers, A_REVERSE,
boxWidget, shadowWidget);
/* Make sure we could create the widget. */
if (widget == 0)
{
CDKfreeStrings (scrollList);
destroyCDKScreen (cdkScreen);
endCDK ();
fprintf (stderr,
"Error: Could not create the scrolling list. "
"Is the window too small?\n");
ExitProgram (CLI_ERROR);
}
/* Split the buttons if they supplied some. */
if (buttons != 0)
{
/* Split the button list up. */
buttonList = CDKsplitString (buttons, '\n');
buttonCount = (int)CDKcountStrings ((CDK_CSTRING2) buttonList);
/* We need to create a buttonbox widget. */
buttonWidget = newCDKButtonbox (cdkScreen,
getbegx (widget->win),
(getbegy (widget->win)
+ widget->boxHeight - 1),
1, widget->boxWidth - 1,
0, 1, buttonCount,
(CDK_CSTRING2) buttonList, buttonCount,
A_REVERSE, boxWidget, FALSE);
CDKfreeStrings (buttonList);
setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
/*
* We need to set the lower left and right
* characters of the widget.
*/
setCDKScrollLLChar (widget, ACS_LTEE);
setCDKScrollLRChar (widget, ACS_RTEE);
/*
* Bind the Tab key in the widget to send a
* Tab key to the button box widget.
*/
bindCDKObject (vSCROLL, widget, KEY_TAB, widgetCB, buttonWidget);
bindCDKObject (vSCROLL, widget, CDK_NEXT, widgetCB, buttonWidget);
bindCDKObject (vSCROLL, widget, CDK_PREV, widgetCB, buttonWidget);
/* Check if the user wants to set the background of the widget. */
setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
/* Draw the button widget. */
drawCDKButtonbox (buttonWidget, boxWidget);
}
/*
* If the user asked for a shadow, we need to create one. Do this instead
* of using the shadow parameter because the button widget is not part of
* the main widget and if the user asks for both buttons and a shadow, we
* need to create a shadow big enough for both widgets. Create the shadow
* window using the widgets shadowWin element, so screen refreshes will draw
* them as well.
*/
if (shadowWidget == TRUE)
{
/* Determine the height of the shadow window. */
shadowHeight = (buttonWidget == 0 ?
widget->boxHeight :
widget->boxHeight + buttonWidget->boxHeight - 1);
/* Create the shadow window. */
widget->shadowWin = newwin (shadowHeight,
widget->boxWidth,
getbegy (widget->win) + 1,
getbegx (widget->win) + 1);
/* Make sure we could have created the shadow window. */
if (widget->shadowWin != 0)
{
widget->shadow = TRUE;
/*
* We force the widget and buttonWidget to be drawn so the
* buttonbox widget will be drawn when the widget is activated.
* Otherwise the shadow window will draw over the button widget.
*/
drawCDKScroll (widget, ObjOf (widget)->box);
eraseCDKButtonbox (buttonWidget);
drawCDKButtonbox (buttonWidget, ObjOf (buttonWidget)->box);
}
}
/* Check if the user wants to set the background of the widget. */
setCDKScrollBackgroundColor (widget, CDK_WIDGET_COLOR);
/* Activate the scrolling list. */
answer = activateCDKScroll (widget, 0);
/* If there were buttons, get the button selected. */
if (buttonWidget != 0)
{
selection = buttonWidget->currentButton;
destroyCDKButtonbox (buttonWidget);
}
/* Shut down curses. */
destroyCDKScroll (widget);
destroyCDKScreen (cdkScreen);
endCDK ();
/* Print out the answer. */
if (answer >= 0)
{
if (numberOutput == TRUE)
{
fprintf (fp, "%d\n", answer);
}
else
{
fprintf (fp, "%s\n", scrollList[answer]);
}
}
fclose (fp);
CDKfreeStrings (scrollList);
/* Exit with the answer. */
ExitProgram (selection);
}
static int widgetCB (EObjectType cdktype GCC_UNUSED,
void *object GCC_UNUSED,
void *clientData,
chtype key)
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
(void) injectCDKButtonbox (buttonbox, key);
return (TRUE);
}

341
deps/cdk-5.0-20161210/cli/cdkselection.c vendored Normal file
View File

@ -0,0 +1,341 @@
/* $Id: cdkselection.c,v 1.15 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef XCURSES
char *XCursesProgramName = "cdkselection";
#endif
/*
* Declare file local prototypes.
*/
static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
/*
* Define file local variables.
*/
static const char *FPUsage = "-l List | -f filename [-c Choices ] [-s Selection Bar Position] [-T Title] [-B Buttons] [-O Output File] [-X X Position] [-Y Y Position] [-H Height] [-W Width] [-N] [-S]";
/*
*
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkScreen = 0;
CDKSELECTION *widget = 0;
CDKBUTTONBOX *buttonWidget = 0;
chtype *holder = 0;
char *item = 0;
char *CDK_WIDGET_COLOR = 0;
char *temp = 0;
int scrollLines = -1;
int choiceSize = -1;
int buttonCount = 0;
int selection = 0;
int shadowHeight = 0;
FILE *fp = stderr;
char **scrollList = 0;
char **choiceList = 0;
char **buttonList = 0;
char **items = 0;
int choiceValues[MAX_ITEMS];
int editModes[MAX_ITEMS];
int x, fields, j1, j2;
CDK_PARAMS params;
boolean boxWidget;
boolean shadowWidget;
char *buttons;
char *choices;
char *filename;
char *list;
char *outputFile;
char *title;
int height;
int numbers;
int spos;
int width;
int xpos;
int ypos;
CDKparseParams (argc, argv, &params, "c:f:ln:s:B:O:T:" CDK_CLI_PARAMS);
/* *INDENT-EQLS* */
xpos = CDKparamValue (&params, 'X', CENTER);
ypos = CDKparamValue (&params, 'Y', CENTER);
height = CDKparamValue (&params, 'H', 10);
width = CDKparamValue (&params, 'W', 10);
boxWidget = CDKparamValue (&params, 'N', TRUE);
shadowWidget = CDKparamValue (&params, 'S', FALSE);
choices = CDKparamString (&params, 'c');
filename = CDKparamString (&params, 'f');
list = CDKparamString (&params, 'l');
buttons = CDKparamString (&params, 'B');
outputFile = CDKparamString (&params, 'O');
title = CDKparamString (&params, 'T');
numbers = CDKparamValue (&params, 'n', FALSE);
spos = CDKparsePosition (CDKparamString (&params, 's'));
/* If the user asked for an output file, try to open it. */
if (outputFile != 0)
{
if ((fp = fopen (outputFile, "w")) == 0)
{
fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
ExitProgram (CLI_ERROR);
}
}
/* Did they provide a list of items. */
if (list == 0)
{
/* Maybe they gave a filename to use to read. */
if (filename != 0)
{
/* Read the file in. */
scrollLines = CDKreadFile (filename, &scrollList);
/* Check if there was an error. */
if (scrollLines == -1)
{
fprintf (stderr, "Error: Could not open the file '%s'.\n", filename);
ExitProgram (CLI_ERROR);
}
/*
* For each line, we will split on a CTRL-V and look for a selection
* value/edit mode. The format of the input file can be the following:
* Index value [choice value] [edit flag]
*/
for (x = 0; x < scrollLines; x++)
{
/* Split the line on CTRL-V. */
items = CDKsplitString (scrollList[x], CTRL ('V'));
fields = (int)CDKcountStrings ((CDK_CSTRING2)items);
/* Check the field count. */
if (fields == 1)
{
choiceValues[x] = 0;
editModes[x] = 0;
}
else if (fields == 2)
{
freeChar (scrollList[x]);
scrollList[x] = copyChar (items[0]);
choiceValues[x] = (int)atoi (items[1]);
editModes[x] = 0;
}
else if (fields == 3)
{
freeChar (scrollList[x]);
scrollList[x] = copyChar (items[0]);
choiceValues[x] = (int)atoi (items[1]);
editModes[x] = (int)atoi (items[2]);
}
CDKfreeStrings (items);
}
}
else
{
/* They didn't provide anything. */
fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
ExitProgram (CLI_ERROR);
}
}
else
{
/* Split the scroll lines up. */
scrollList = CDKsplitString (list, '\n');
scrollLines = (int)CDKcountStrings ((CDK_CSTRING2)scrollList);
}
/* Did they supply a chopice list. */
if (choices == 0)
{
choiceList = calloc(sizeof(char *), 3);
choiceList[0] = copyChar ("Yes ");
choiceList[1] = copyChar ("No ");
choiceSize = 2;
}
else
{
/* Split the choices up. */
choiceList = CDKsplitString (choices, '\n');
choiceSize = (int)CDKcountStrings ((CDK_CSTRING2)choiceList);
}
cdkScreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Check if the user wants to set the background of the main screen. */
if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
{
holder = char2Chtype (temp, &j1, &j2);
wbkgd (cdkScreen->window, holder[0]);
wrefresh (cdkScreen->window);
freeChtype (holder);
}
/* Get the widget color background color. */
if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
{
CDK_WIDGET_COLOR = 0;
}
/* Create the scrolling list. */
widget = newCDKSelection (cdkScreen, xpos, ypos, spos,
height, width, title,
(CDK_CSTRING2)scrollList, scrollLines,
(CDK_CSTRING2)choiceList, choiceSize,
A_REVERSE,
boxWidget, shadowWidget);
CDKfreeStrings (choiceList);
/* Make sure we could create the widget. */
if (widget == 0)
{
CDKfreeStrings (scrollList);
destroyCDKScreen (cdkScreen);
endCDK ();
fprintf (stderr,
"Error: Could not create the selection list. "
"Is the window too small?\n");
ExitProgram (CLI_ERROR);
}
/* Set up the default selection choices. */
setCDKSelectionChoices (widget, choiceValues);
/* Split the buttons if they supplied some. */
if (buttons != 0)
{
/* Split the button list up. */
buttonList = CDKsplitString (buttons, '\n');
buttonCount = (int)CDKcountStrings ((CDK_CSTRING2)buttonList);
/* We need to create a buttonbox widget. */
buttonWidget = newCDKButtonbox (cdkScreen,
getbegx (widget->win),
(getbegy (widget->win)
+ widget->boxHeight - 1),
1, widget->boxWidth - 1,
0, 1, buttonCount,
(CDK_CSTRING2)buttonList, buttonCount,
A_REVERSE, boxWidget, FALSE);
CDKfreeStrings (buttonList);
setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
/*
* We need to set the lower left and right
* characters of the widget.
*/
setCDKSelectionLLChar (widget, ACS_LTEE);
setCDKSelectionLRChar (widget, ACS_RTEE);
/*
* Bind the Tab key in the widget to send a
* Tab key to the button box widget.
*/
bindCDKObject (vSELECTION, widget, KEY_TAB, widgetCB, buttonWidget);
bindCDKObject (vSELECTION, widget, CDK_NEXT, widgetCB, buttonWidget);
bindCDKObject (vSELECTION, widget, CDK_PREV, widgetCB, buttonWidget);
/* Check if the user wants to set the background of the widget. */
setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
/* Draw the button widget. */
drawCDKButtonbox (buttonWidget, boxWidget);
}
/*
* If the user asked for a shadow, we need to create one. Do this instead
* of using the shadow parameter because the button widget is not part of
* the main widget and if the user asks for both buttons and a shadow, we
* need to create a shadow big enough for both widgets. Create the shadow
* window using the widgets shadowWin element, so screen refreshes will draw
* them as well.
*/
if (shadowWidget == TRUE)
{
/* Determine the height of the shadow window. */
shadowHeight = (buttonWidget == 0 ?
widget->boxHeight :
widget->boxHeight + buttonWidget->boxHeight - 1);
/* Create the shadow window. */
widget->shadowWin = newwin (shadowHeight,
widget->boxWidth,
getbegy (widget->win) + 1,
getbegx (widget->win) + 1);
/* Make sure we could have created the shadow window. */
if (widget->shadowWin != 0)
{
widget->shadow = TRUE;
/*
* We force the widget and buttonWidget to be drawn so the
* buttonbox widget will be drawn when the widget is activated.
* Otherwise the shadow window will draw over the button widget.
*/
drawCDKSelection (widget, ObjOf (widget)->box);
eraseCDKButtonbox (buttonWidget);
drawCDKButtonbox (buttonWidget, ObjOf (buttonWidget)->box);
}
}
/* Check if the user wants to set the background of the widget. */
setCDKSelectionBackgroundColor (widget, CDK_WIDGET_COLOR);
/* Set up the default selection modes. */
setCDKSelectionModes (widget, editModes);
/* Activate the selection list. */
activateCDKSelection (widget, 0);
/* If there were buttons, get the button selected. */
if (buttonWidget != 0)
{
selection = buttonWidget->currentButton;
destroyCDKButtonbox (buttonWidget);
}
/* Print out the answer. */
for (x = 0; x < scrollLines; x++)
{
holder = char2Chtype (scrollList[x], &j1, &j2);
item = chtype2Char (holder);
fprintf (fp, "%d %s\n", widget->selections[x], item);
freeChtype (holder);
freeChar (item);
}
CDKfreeStrings (scrollList);
/* Shut down curses. */
destroyCDKSelection (widget);
destroyCDKScreen (cdkScreen);
endCDK ();
ExitProgram (selection);
}
static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED,
void *clientData,
chtype key)
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
(void)injectCDKButtonbox (buttonbox, key);
return (TRUE);
}

290
deps/cdk-5.0-20161210/cli/cdkslider.c vendored Normal file
View File

@ -0,0 +1,290 @@
/* $Id: cdkslider.c,v 1.14 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef XCURSES
char *XCursesProgramName = "cdkslider";
#endif
/*
* Declare file local prototypes.
*/
static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
/*
* Define file local variables.
*/
static const char *FPUsage = "-f Field Width -l Low Value -h High Value [-s Initial Value]] [-i Increment Value] [-a Accelerated Increment Value] [-F Field Character] [-T Title] [-L Label] [-B Buttons] [-O Output File] [-X X Position] [-Y Y Position] [-N] [-S]";
/*
*
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkScreen = 0;
CDKSLIDER *widget = 0;
CDKBUTTONBOX *buttonWidget = 0;
char *CDK_WIDGET_COLOR = 0;
char *temp = 0;
chtype *holder = 0;
chtype fieldAttr = A_REVERSE | ' ';
int answer = 0;
int buttonCount = 0;
int selection = 0;
int shadowHeight = 0;
FILE *fp = stderr;
char **buttonList = 0;
int j1, j2, tmp;
CDK_PARAMS params;
boolean boxWidget;
boolean shadowWidget;
char *barAttribute;
char *buttons;
char *label;
char *outputFile;
char *title;
int fieldWidth;
int incrementStep;
int acceleratedStep;
int initValue;
int lowValue;
int highValue;
int xpos;
int ypos;
CDKparseParams (argc, argv, &params, "a:f:h:i:l:s:B:F:L:O:T:" CDK_MIN_PARAMS);
/* *INDENT-EQLS* */
xpos = CDKparamValue (&params, 'X', CENTER);
ypos = CDKparamValue (&params, 'Y', CENTER);
boxWidget = CDKparamValue (&params, 'N', TRUE);
shadowWidget = CDKparamValue (&params, 'S', FALSE);
acceleratedStep = CDKparamValue (&params, 'a', -1);
fieldWidth = CDKparamValue (&params, 'f', 0);
highValue = CDKparamValue (&params, 'h', INT_MIN);
incrementStep = CDKparamValue (&params, 'i', 1);
lowValue = CDKparamValue (&params, 'l', INT_MAX);
initValue = CDKparamValue (&params, 's', INT_MIN);
buttons = CDKparamString (&params, 'B');
barAttribute = CDKparamString (&params, 'F');
label = CDKparamString (&params, 'L');
outputFile = CDKparamString (&params, 'O');
title = CDKparamString (&params, 'T');
incrementStep = abs (incrementStep);
/* Make sure all the command line parameters were provided. */
if (fieldWidth <= 0)
{
fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
ExitProgram (CLI_ERROR);
}
/* Make sure the user supplied the low/high values. */
if ((lowValue == INT_MAX) || (highValue == INT_MIN))
{
fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
ExitProgram (CLI_ERROR);
}
/* If the user asked for an output file, try to open it. */
if (outputFile != 0)
{
if ((fp = fopen (outputFile, "w")) == 0)
{
fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
ExitProgram (CLI_ERROR);
}
}
/* Make sure the low is lower than the high (and vice versa). */
if (lowValue > highValue)
{
tmp = lowValue;
lowValue = highValue;
highValue = tmp;
}
/* Make sure the starting value is in range. */
if (initValue < lowValue)
{
initValue = lowValue;
}
else if (initValue > highValue)
{
initValue = highValue;
}
/* Check if the accelerated incremnt value was set. */
if (acceleratedStep <= 0)
{
acceleratedStep = (int)((highValue - lowValue) / 10);
acceleratedStep = MAXIMUM (1, acceleratedStep);
}
cdkScreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Check if the user wants to set the background of the main screen. */
if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
{
holder = char2Chtype (temp, &j1, &j2);
wbkgd (cdkScreen->window, holder[0]);
wrefresh (cdkScreen->window);
freeChtype (holder);
}
/* Get the widget color background color. */
if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
{
CDK_WIDGET_COLOR = 0;
}
/* Did the user ask to change the bar attribute? */
if (barAttribute != 0)
{
holder = char2Chtype (barAttribute, &j1, &j2);
fieldAttr = holder[0];
freeChtype (holder);
}
/* Create the entry widget. */
widget = newCDKSlider (cdkScreen, xpos, ypos,
title, label,
fieldAttr, fieldWidth,
initValue, lowValue, highValue,
incrementStep, acceleratedStep,
boxWidget, shadowWidget);
/* Check to make sure we created the dialog box. */
if (widget == 0)
{
/* Shut down curses and CDK. */
destroyCDKScreen (cdkScreen);
endCDK ();
fprintf (stderr,
"Error: Could not create the numeric slider field. "
"Is the window too small?\n");
ExitProgram (CLI_ERROR);
}
/* Split the buttons if they supplied some. */
if (buttons != 0)
{
/* Split the button list up. */
buttonList = CDKsplitString (buttons, '\n');
buttonCount = (int)CDKcountStrings ((CDK_CSTRING2) buttonList);
/* We need to create a buttonbox widget. */
buttonWidget = newCDKButtonbox (cdkScreen,
getbegx (widget->win),
(getbegy (widget->win)
+ widget->boxHeight - 1),
1, widget->boxWidth - 1,
0, 1, buttonCount,
(CDK_CSTRING2) buttonList, buttonCount,
A_REVERSE, boxWidget, FALSE);
CDKfreeStrings (buttonList);
setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
/*
* We need to set the lower left and right
* characters of the widget.
*/
setCDKSliderLLChar (widget, ACS_LTEE);
setCDKSliderLRChar (widget, ACS_RTEE);
/*
* Bind the Tab key in the widget to send a
* Tab key to the button box widget.
*/
bindCDKObject (vSLIDER, widget, KEY_TAB, widgetCB, buttonWidget);
bindCDKObject (vSLIDER, widget, CDK_NEXT, widgetCB, buttonWidget);
bindCDKObject (vSLIDER, widget, CDK_PREV, widgetCB, buttonWidget);
/* Check if the user wants to set the background of the widget. */
setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
/* Draw the button widget. */
drawCDKButtonbox (buttonWidget, boxWidget);
}
/*
* If the user asked for a shadow, we need to create one. Do this instead
* of using the shadow parameter because the button widget is not part of
* the main widget and if the user asks for both buttons and a shadow, we
* need to create a shadow big enough for both widgets. Create the shadow
* window using the widgets shadowWin element, so screen refreshes will draw
* them as well.
*/
if (shadowWidget == TRUE)
{
/* Determine the height of the shadow window. */
shadowHeight = (buttonWidget == 0 ?
widget->boxHeight :
widget->boxHeight + buttonWidget->boxHeight - 1);
/* Create the shadow window. */
widget->shadowWin = newwin (shadowHeight,
widget->boxWidth,
getbegy (widget->win) + 1,
getbegx (widget->win) + 1);
/* Make sure we could have created the shadow window. */
if (widget->shadowWin != 0)
{
widget->shadow = TRUE;
/*
* We force the widget and buttonWidget to be drawn so the
* buttonbox widget will be drawn when the widget is activated.
* Otherwise the shadow window will draw over the button widget.
*/
drawCDKSlider (widget, ObjOf (widget)->box);
eraseCDKButtonbox (buttonWidget);
drawCDKButtonbox (buttonWidget, ObjOf (buttonWidget)->box);
}
}
/* Check if the user wants to set the background of the widget. */
setCDKSliderBackgroundColor (widget, CDK_WIDGET_COLOR);
/* Activate the widget. */
answer = activateCDKSlider (widget, 0);
/* If there were buttons, get the button selected. */
if (buttonWidget != 0)
{
selection = buttonWidget->currentButton;
destroyCDKButtonbox (buttonWidget);
}
/* End CDK. */
destroyCDKSlider (widget);
destroyCDKScreen (cdkScreen);
endCDK ();
/* Print the value from the widget. */
fprintf (fp, "%d\n", answer);
fclose (fp);
/* Exit with the button selected. */
ExitProgram (selection);
}
static int widgetCB (EObjectType cdktype GCC_UNUSED,
void *object GCC_UNUSED,
void *clientData,
chtype key)
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
(void) injectCDKButtonbox (buttonbox, key);
return (TRUE);
}

264
deps/cdk-5.0-20161210/cli/cdktemplate.c vendored Normal file
View File

@ -0,0 +1,264 @@
/* $Id: cdktemplate.c,v 1.14 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef XCURSES
char *XCursesProgramName = "cdktemplate";
#endif
/*
* Declare file local prototypes.
*/
static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
/*
* Define file local variables.
*/
static const char *FPUsage = "-p Plate [-o Overlay] [-P Mix Plate] [-d Default Answer] [-m Minimum Length] [-T Title] [-L Label] [-B Buttons] [-O Output file] [-X X Position] [-Y Y Position] [-N] [-S]";
/*
*
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkScreen = 0;
CDKTEMPLATE *widget = 0;
CDKBUTTONBOX *buttonWidget = 0;
char *answer = 0;
char *tmp = 0;
char *CDK_WIDGET_COLOR = 0;
char *temp = 0;
chtype *holder = 0;
int buttonCount = 0;
int selection = 0;
int shadowHeight = 0;
FILE *fp = stderr;
char **buttonList = 0;
int j1, j2;
CDK_PARAMS params;
boolean boxWidget;
boolean mixPlate;
boolean shadowWidget;
char *buttons;
char *defaultAnswer;
char *label;
char *my_overlay;
char *outputFile;
char *plate;
char *title;
int minimum;
int xpos;
int ypos;
CDKparseParams (argc, argv, &params, "d:m:o:p:B:L:O:P:T:" CDK_MIN_PARAMS);
/* *INDENT-EQLS* */
xpos = CDKparamValue (&params, 'X', CENTER);
ypos = CDKparamValue (&params, 'Y', CENTER);
boxWidget = CDKparamValue (&params, 'N', TRUE);
shadowWidget = CDKparamValue (&params, 'S', FALSE);
minimum = CDKparamValue (&params, 'm', 0);
mixPlate = CDKparamValue (&params, 'P', FALSE);
defaultAnswer = CDKparamString (&params, 'd');
my_overlay = CDKparamString (&params, 'o');
plate = CDKparamString (&params, 'p');
buttons = CDKparamString (&params, 'B');
label = CDKparamString (&params, 'L');
outputFile = CDKparamString (&params, 'O');
title = CDKparamString (&params, 'T');
/* Make sure all the command line parameters were provided. */
if (plate == 0)
{
fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
ExitProgram (CLI_ERROR);
}
/* If the user asked for an output file, try to open it. */
if (outputFile != 0)
{
if ((fp = fopen (outputFile, "w")) == 0)
{
fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
ExitProgram (CLI_ERROR);
}
}
cdkScreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Check if the user wants to set the background of the main screen. */
if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
{
holder = char2Chtype (temp, &j1, &j2);
wbkgd (cdkScreen->window, holder[0]);
wrefresh (cdkScreen->window);
freeChtype (holder);
}
/* Get the widget color background color. */
if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
{
CDK_WIDGET_COLOR = 0;
}
/* Create the template widget. */
widget = newCDKTemplate (cdkScreen, xpos, ypos,
title, label,
plate, my_overlay,
boxWidget, shadowWidget);
/* Check to make sure we created the widget. */
if (widget == 0)
{
/* Shut down curses and CDK. */
destroyCDKScreen (cdkScreen);
endCDK ();
fprintf (stderr,
"Error: Could not create the template field. "
"Is the window too small?\n");
ExitProgram (CLI_ERROR);
}
/* Split the buttons if they supplied some. */
if (buttons != 0)
{
/* Split the button list up. */
buttonList = CDKsplitString (buttons, '\n');
buttonCount = (int)CDKcountStrings ((CDK_CSTRING2) buttonList);
/* We need to create a buttonbox widget. */
buttonWidget = newCDKButtonbox (cdkScreen,
getbegx (widget->win),
(getbegy (widget->win)
+ widget->boxHeight - 1),
1, widget->boxWidth - 1,
0, 1, buttonCount,
(CDK_CSTRING2) buttonList, buttonCount,
A_REVERSE, boxWidget, FALSE);
setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
/*
* We need to set the lower left and right
* characters of the widget.
*/
setCDKTemplateLLChar (widget, ACS_LTEE);
setCDKTemplateLRChar (widget, ACS_RTEE);
/*
* Bind the Tab key in the widget to send a
* Tab key to the button box widget.
*/
bindCDKObject (vTEMPLATE, widget, KEY_TAB, widgetCB, buttonWidget);
bindCDKObject (vTEMPLATE, widget, CDK_NEXT, widgetCB, buttonWidget);
bindCDKObject (vTEMPLATE, widget, CDK_PREV, widgetCB, buttonWidget);
/* Check if the user wants to set the background of the widget. */
setCDKButtonboxBackgroundColor (buttonWidget, CDK_WIDGET_COLOR);
/* Draw the button widget. */
drawCDKButtonbox (buttonWidget, boxWidget);
}
/*
* If the user asked for a shadow, we need to create one. Do this instead
* of using the shadow parameter because the button widget is not part of
* the main widget and if the user asks for both buttons and a shadow, we
* need to create a shadow big enough for both widgets. Create the shadow
* window using the widgets shadowWin element, so screen refreshes will draw
* them as well.
*/
if (shadowWidget == TRUE)
{
/* Determine the height of the shadow window. */
shadowHeight = (buttonWidget == 0 ?
widget->boxHeight :
widget->boxHeight + buttonWidget->boxHeight - 1);
/* Create the shadow window. */
widget->shadowWin = newwin (shadowHeight,
widget->boxWidth,
getbegy (widget->win) + 1,
getbegx (widget->win) + 1);
/* Make sure we could have created the shadow window. */
if (widget->shadowWin != 0)
{
widget->shadow = TRUE;
/*
* We force the widget and buttonWidget to be drawn so the
* buttonbox widget will be drawn when the widget is activated.
* Otherwise the shadow window will draw over the button widget.
*/
drawCDKTemplate (widget, ObjOf (widget)->box);
eraseCDKButtonbox (buttonWidget);
drawCDKButtonbox (buttonWidget, ObjOf (buttonWidget)->box);
}
}
/* Check if the user wants to set the background of the widget. */
setCDKTemplateBackgroundColor (widget, CDK_WIDGET_COLOR);
/* If a default answer were proivded, set it in the widget. */
if (defaultAnswer != 0)
{
setCDKTemplateValue (widget, defaultAnswer);
}
/* If the user asked for a minimum value, set it. */
setCDKTemplateMin (widget, minimum);
/* Activate the widget. */
tmp = activateCDKTemplate (widget, 0);
/* If the user asked for plate mixing, give it to them. */
if (mixPlate == TRUE)
{
answer = mixCDKTemplate (widget);
}
else
{
answer = copyChar (tmp);
}
/* If there were buttons, get the button selected. */
if (buttonWidget != 0)
{
selection = buttonWidget->currentButton;
destroyCDKButtonbox (buttonWidget);
}
/* End CDK. */
destroyCDKTemplate (widget);
destroyCDKScreen (cdkScreen);
endCDK ();
/* Print the value from the widget. */
if (answer != 0)
{
fprintf (fp, "%s\n", answer);
freeChar (answer);
}
fclose (fp);
/* Exit with the button number picked. */
ExitProgram (selection);
}
static int widgetCB (EObjectType cdktype GCC_UNUSED,
void *object GCC_UNUSED,
void *clientData,
chtype key)
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
(void) injectCDKButtonbox (buttonbox, key);
return (TRUE);
}

285
deps/cdk-5.0-20161210/cli/cdkviewer.c vendored Normal file
View File

@ -0,0 +1,285 @@
/* $Id: cdkviewer.c,v 1.15 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef XCURSES
char *XCursesProgramName = "cdkviewer";
#endif
/*
* Declare file local prototypes.
*/
static void saveInformation (CDKVIEWER *widget);
static int dumpViewer (CDKVIEWER *widget, char *filename);
static int widgetCB (EObjectType cdktype, void *object, void *clientData, chtype key);
/*
* Define file local variables.
*/
static const char *FPUsage = "-f filename [-i Interpret] [-l Show Line Stats] [-T Title] [-B Buttons] [-X X Position] [-Y Y Position] [-H Height] [-W Width] [-N] [-S]";
/*
*
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkScreen = 0;
CDKVIEWER *widget = 0;
char *filename = 0;
char *CDK_WIDGET_COLOR = 0;
char *temp = 0;
chtype *holder = 0;
int answer = 0;
int messageLines = -1;
int buttonCount = 0;
char **messageList = 0;
char **buttonList = 0;
char tempTitle[256];
int j1, j2;
CDK_PARAMS params;
boolean boxWidget;
boolean interpret;
boolean shadowWidget;
boolean showInfoLine;
char *buttons;
char *title;
int height;
int width;
int xpos;
int ypos;
CDKparseParams (argc, argv, &params, "f:il:B:T:" CDK_CLI_PARAMS);
/* *INDENT-EQLS* */
xpos = CDKparamValue (&params, 'X', CENTER);
ypos = CDKparamValue (&params, 'Y', CENTER);
height = CDKparamValue (&params, 'H', 20);
width = CDKparamValue (&params, 'W', 60);
boxWidget = CDKparamValue (&params, 'N', TRUE);
shadowWidget = CDKparamValue (&params, 'S', FALSE);
interpret = CDKparamValue (&params, 'i', FALSE);
showInfoLine = CDKparamValue (&params, 'l', FALSE);
filename = CDKparamString (&params, 'f');
buttons = CDKparamString (&params, 'B');
title = CDKparamString (&params, 'T');
/* Make sure they gave us a file to read. */
if (filename == 0)
{
fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
ExitProgram (CLI_ERROR);
}
/* Read the file in. */
messageLines = CDKreadFile (filename, &messageList);
/* Check if there was an error. */
if (messageLines == -1)
{
fprintf (stderr, "Error: Could not open the file %s\n", filename);
ExitProgram (CLI_ERROR);
}
/* Set up the buttons of the viewer. */
if (buttons == 0)
{
/* *INDENT-EQLS* */
buttonList = calloc(sizeof(char *), 3);
buttonList[0] = copyChar ("OK");
buttonList[1] = copyChar ("Cancel");
buttonCount = 2;
}
else
{
/* Split the button list up. */
buttonList = CDKsplitString (buttons, '\n');
buttonCount = (int)CDKcountStrings ((CDK_CSTRING2)buttonList);
}
/* Set up the title of the viewer. */
if (title == 0)
{
sprintf (tempTitle, "<C>Filename: </U>%s<!U>", filename);
title = copyChar (tempTitle);
}
cdkScreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Check if the user wants to set the background of the main screen. */
if ((temp = getenv ("CDK_SCREEN_COLOR")) != 0)
{
holder = char2Chtype (temp, &j1, &j2);
wbkgd (cdkScreen->window, holder[0]);
wrefresh (cdkScreen->window);
freeChtype (holder);
}
/* Get the widget color background color. */
if ((CDK_WIDGET_COLOR = getenv ("CDK_WIDGET_COLOR")) == 0)
{
CDK_WIDGET_COLOR = 0;
}
/* Create the viewer widget. */
widget = newCDKViewer (cdkScreen, xpos, ypos, height, width,
(CDK_CSTRING2)buttonList, buttonCount, A_REVERSE,
boxWidget, shadowWidget);
/* Check to make sure we created the file viewer. */
if (widget == 0)
{
CDKfreeStrings (messageList);
CDKfreeStrings (buttonList);
/* Shut down curses and CDK. */
destroyCDKScreen (cdkScreen);
endCDK ();
fprintf (stderr,
"Error: Could not create the file viewer. "
"Is the window too small?\n");
ExitProgram (CLI_ERROR);
}
/* Check if the user wants to set the background of the widget. */
setCDKViewerBackgroundColor (widget, CDK_WIDGET_COLOR);
/* Set a binding for saving the info. */
bindCDKObject (vVIEWER, widget, 'S', widgetCB, 0);
/* Set the information needed for the viewer. */
setCDKViewer (widget, title, (CDK_CSTRING2)messageList, messageLines,
A_REVERSE, interpret, showInfoLine, TRUE);
/* Activate the viewer. */
answer = activateCDKViewer (widget, 0);
CDKfreeStrings (messageList);
CDKfreeStrings (buttonList);
destroyCDKViewer (widget);
destroyCDKScreen (cdkScreen);
endCDK ();
/* Exit with the button number picked. */
ExitProgram (answer);
}
/*
* This function allows the user to dump the
* information from the viewer into a file.
*/
static void saveInformation (CDKVIEWER *widget)
{
/* *INDENT-EQLS* */
CDKENTRY *entry = 0;
char *filename = 0;
char temp[256];
const char *mesg[10];
int linesSaved;
/* Create the entry field to get the filename. */
entry = newCDKEntry (ScreenOf (widget), CENTER, CENTER,
"<C></B/5>Enter the filename of the save file.",
"Filename: ",
A_NORMAL, '_', vMIXED,
20, 1, 256,
TRUE, FALSE);
/* Get the filename. */
filename = activateCDKEntry (entry, 0);
/* Did they hit escape? */
if (entry->exitType == vESCAPE_HIT)
{
/* Popup a message. */
mesg[0] = "<C></B/5>Save Canceled.";
mesg[1] = "<C>Escape hit. Scrolling window information not saved.";
mesg[2] = " ";
mesg[3] = "<C>Press any key to continue.";
popupLabel (ScreenOf (widget), (CDK_CSTRING2)mesg, 4);
destroyCDKEntry (entry);
return;
}
/* Write the contents of the viewer to the file. */
linesSaved = dumpViewer (widget, filename);
/* Was the save successful? */
if (linesSaved == -1)
{
/* Nope, tell 'em. */
mesg[0] = "<C></B/16>Error";
mesg[1] = "<C>Could not save to the file.";
sprintf (temp, "<C>(%s)", filename);
mesg[2] = temp;
mesg[3] = " ";
mesg[4] = "<C>Press any key to continue.";
popupLabel (ScreenOf (widget), (CDK_CSTRING2)mesg, 5);
}
else
{
char *msg_1;
mesg[0] = "<C></B/5>Save Successful";
sprintf (temp, "<C>There were %d lines saved to the file", linesSaved);
mesg[1] = msg_1 = copyChar (temp);
sprintf (temp, "<C>(%s)", filename);
mesg[2] = temp;
mesg[3] = " ";
mesg[4] = "<C>Press any key to continue.";
popupLabel (ScreenOf (widget), (CDK_CSTRING2)mesg, 5);
freeChar (msg_1);
}
destroyCDKEntry (entry);
eraseCDKScreen (ScreenOf (widget));
drawCDKScreen (ScreenOf (widget));
}
/*
* This actually dumps the information from the viewer to a file.
*/
static int dumpViewer (CDKVIEWER *widget, char *filename)
{
/* *INDENT-EQLS* */
FILE *outputFile = 0;
char *rawLine = 0;
int listSize;
chtype **list = getCDKViewerInfo (widget, &listSize);
int x;
/* Try to open the file. */
if ((outputFile = fopen (filename, "w")) == 0)
{
return -1;
}
/* Start writing out the file. */
for (x = 0; x < listSize; x++)
{
rawLine = chtype2Char (list[x]);
fprintf (outputFile, "%s\n", rawLine);
freeChar (rawLine);
}
/* Close the file and return the number of lines written. */
fclose (outputFile);
return listSize;
}
static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object,
void *clientData GCC_UNUSED,
chtype key GCC_UNUSED)
{
CDKVIEWER *widget = (CDKVIEWER *)object;
saveInformation (widget);
return (TRUE);
}

116
deps/cdk-5.0-20161210/cli/samples/alphalist.sh vendored Executable file
View File

@ -0,0 +1,116 @@
#!/bin/sh
# $Id: alphalist.sh,v 1.7 2005/12/27 16:04:57 tom Exp $
#
# Description:
# This demonstrates the CDK command line
# interface to the alphalist widget.
#
#
# This gets the password file.
#
getPasswordFile()
{
system=$1
file=$2
#
# Depeding on the system, get the password file
# using nicat, ypcat, or just plain old /etc/passwd
#
if [ "$system" = "NIS" ]; then
niscat passwd.org_dir > $file
elif [ "$system" = "YP" ]; then
ypcat passwd > $file
else
cp /etc/passwd $file
fi
}
#
# This displays account information.
#
displayAccountInformation()
{
userAccount=$1
passwordFile=$2
#
# Get the user account information.
#
line=`grep "^${userAccount}" $passwordFile`
uid=`echo $line | cut -d: -f3`
gid=`echo $line | cut -d: -f4`
info=`echo $line | cut -d: -f5`
home=`echo $line | cut -d: -f6`
shell=`echo $line | cut -d: -f7`
#
# Create the label message information.
#
accountMessage="<C></U>Account
<C><#HL(30)>
Account: </U>${userAccount}
UID : </U>${uid}
GID : </U>${gid}
Info : </U>${info}
Home : </U>${home}
Shell : </U>${shell}
<C><#HL(30)>
<C>Hit </R>space<!R> to continue"
#
# Create the popup label.
#
${CDK_LABEL} -m "${accountMessage}" -p " "
}
#
# Create some global variables.
#
CDK_ALPHALIST="${CDK_BINDIR=..}/cdkalphalist"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
tmpPass="${TMPDIR=/tmp}/sl.$$"
output="${TMPDIR=/tmp}/alphalist.$$"
userAccounts="${TMPDIR=/tmp}/ua.$$"
#
# Create the message for the scrolling list.
#
title="<C>Pick an account
<C>you want to view."
#
# Get the password file and stick it into the temp file.
#
#getPasswordFile "YP" "$tmpPass"
#getPasswordFile "NIS" "$tmpPass"
getPasswordFile "Other" "$tmpPass"
#
# Get the user account from the password file.
#
awk 'BEGIN {FS=":"} {printf "%s\n", $1}' $tmpPass | sort > ${userAccounts}
#
# Create the scrolling list.
#
${CDK_ALPHALIST} -T "${title}" -f ${userAccounts} -H -10 -W -20 2> ${output}
selected=$?
test $selected = 255 && exit 1
answer=`sed -e 's/^[ ]*//' -e 's/[ ]*$//' ${output}`
#
# Display the account information.
#
if [ -n "$answer" ]; then
displayAccountInformation $answer $tmpPass
fi
#
# Clean up.
#
rm -f ${output} ${tmpPass} ${userAccounts}

89
deps/cdk-5.0-20161210/cli/samples/calendar.sh vendored Executable file
View File

@ -0,0 +1,89 @@
#!/bin/sh
# $Id: calendar.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
#
# Description:
# This demonstrates the CDK command line
# interface to the celendar widget.
#
#
# Create some global variables.
#
CDK_CALENDAR="${CDK_BINDIR=..}/cdkcalendar"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
date="${TMPDIR=/tmp}/cal.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"
xpos=CENTER
ypos=CENTER
#
# Get today's date.
#
day=`date +%d`
month=`date +%m`
year=`date +%Y`
#
# Chop up the command line.
#
set -- `getopt d:m:y:X:Y: $*`
if [ $? != 0 ]
then
echo $USAGE
exit 2
fi
for c in $*
do
case $c in
-d) day=$2; shift 2;;
-m) month=$2; shift 2;;
-y) year=$2; shift 2;;
-X) xpos=$2; shift 2;;
-Y) ypos=$2; shift 2;;
--) shift; break;;
esac
done
#
# Create the title and buttons.
#
title="<C><#HL(22)>
<C>Select a date
<C><#HL(22)>"
buttons=" OK
Cancel "
#
# Create the calendar widget.
#
${CDK_CALENDAR} -B "${buttons}" -d ${day} -m ${month} -y ${year} -T "${title}" -X ${xpos} -Y ${ypos} -O ${date} -S
selected=$?
test $selected = 255 && exit 1
answer=`cat ${date}`
#
# Create the message for the label widget.
#
echo "<C>You chose the following date" > ${tmp}
echo " " >> ${tmp}
echo "<C><#HL(10)>" >> ${tmp}
echo "<C>${answer}" >> ${tmp}
echo "<C><#HL(10)>" >> ${tmp}
echo " " >> ${tmp}
echo "<C>You chose button #${selected}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
#
# Create the label widget to display the information.
#
${CDK_LABEL} -f ${tmp} -p " "
#
# Clean up.
#
rm -f ${tmp} ${date}

88
deps/cdk-5.0-20161210/cli/samples/dialog.sh vendored Executable file
View File

@ -0,0 +1,88 @@
#!/bin/sh
# $Id: dialog.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
#
# Description:
# This demonstrates the CDK command line
# interface to the dialog widget.
#
#
# Create some global variables.
#
CDK_DIALOG="${CDK_BINDIR=..}/cdkdialog"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
output="${TMPDIR=/tmp}/dialog_output.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"
#
# Create the message for the scrolling list.
#
message="<C>Pick which command
<C>you wish to run."
#
# Create the button labels.
#
commands="</B>who
</B>w
</B>uptime
</B>date
</B>pwd
</B>whoami
</B>df
</B>fortune"
#
# Create the dialog box.
#
${CDK_DIALOG} -m "${message}" -B "${commands}" 2> ${output}
selection=$?
if [ "$selection" -eq 255 ]; then
exit;
fi
#
# Create the message for the label widget.
#
echo "<C>Here is the result of the command" > ${tmp}
echo " " >> ${tmp}
#
# Determine which command to run.
#
if [ "${selection}" -eq 0 ]; then
who | awk '{printf "</B>%s\n", $0}' >> ${tmp}
elif [ "${selection}" -eq 1 ]; then
w | awk '{printf "</B>%s\n", $0}' >> ${tmp}
elif [ "${selection}" -eq 2 ]; then
uptime | awk '{printf "<C></B>%s\n", $0}' >> ${tmp}
elif [ "${selection}" -eq 3 ]; then
date | awk '{printf "<C></B>%s\n", $0}' >> ${tmp}
elif [ "${selection}" -eq 4 ]; then
pwd | awk '{printf "<C></B>%s\n", $0}' >> ${tmp}
elif [ "${selection}" -eq 5 ]; then
whoami | awk '{printf "<C></B>%s\n", $0}' >> ${tmp}
elif [ "${selection}" -eq 6 ]; then
#
# We will use the label demo to do this.
#
./label.sh
rm -f ${tmp} ${output} ${fileSystemList}
exit 0;
elif [ "${selection}" -eq 7 ]; then
fortune | awk '{printf "</B>%s\n", $0}' >> ${tmp}
fi
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
#
# Create the label widget to display the information.
#
${CDK_LABEL} -f ${tmp} -p " "
#
# Clean up.
#
rm -f ${tmp} ${output} ${fileSystemList}

54
deps/cdk-5.0-20161210/cli/samples/entry.sh vendored Executable file
View File

@ -0,0 +1,54 @@
#!/bin/sh
# $Id: entry.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
#
# Description:
# This demonstrates the CDK command line
# interface to the entry widget.
#
#
# Create some global variables.
#
CDK_ENTRY="${CDK_BINDIR=..}/cdkentry"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
output="${TMPDIR=/tmp}/entry_output.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"
#
# Create the title.
#
title="<C> Type a simple string. "
buttons=" OK
Cancel "
#
# Create the entry box.
#
${CDK_ENTRY} -f 20 -T "${title}" -B "${buttons}" -F "</5>_ " -O ${output} -S
selected=$?
test $selected = 255 && exit 1
answer=`cat ${output}`
#
# Create the message for the label widget.
#
echo "<C>Here is the string you typed in" > ${tmp}
echo " " >> ${tmp}
echo "<C></R>${answer}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>You chose button #${selected}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
#
# Create the label widget to display the information.
#
${CDK_LABEL} -f ${tmp} -p " "
#
# Clean up.
#
rm -f ${tmp} ${output}

82
deps/cdk-5.0-20161210/cli/samples/fselect.sh vendored Executable file
View File

@ -0,0 +1,82 @@
#!/bin/sh
# $Id: fselect.sh,v 1.4 2005/12/27 17:56:05 tom Exp $
#
# Description:
# This demonstrates the CDK command line
# interface to the file selection widget.
#
#
# Create some global variables.
#
CDK_FSELECT="${CDK_BINDIR=..}/cdkfselect"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
directory="."
label="File: "
title="<C>Select a file"
buttons=" OK
Cancel "
xpos="CENTER"
ypos="CENTER"
width=0
height=-5
tmp="${TMPDIR=/tmp}/tmp.$$"
file="${TMPDIR=/tmp}/fs.$$"
#
# Chop up the command line.
#
set -- `getopt d:L:T:X:Y:W:H: $*`
if [ $? != 0 ]
then
echo $USAGE
exit 2
fi
for c in $*
do
case $c in
-d) directory=$2; shift 2;;
-T) title=$2; shift 2;;
-L) label=$2; shift 2;;
-X) xpos=$2; shift 2;;
-Y) ypos=$2; shift 2;;
-W) width=$2; shift 2;;
-H) height=$2; shift 2;;
--) shift; break;;
esac
done
#
# Create the CDK file selector.
#
${CDK_FSELECT} -d "${directory}" -T "${title}" -L "${label}" -X ${xpos} -Y ${ypos} -W ${width} -H ${height} -B "${buttons}" 2> ${file}
selected=$?
test $selected = 255 && exit 1
answer=`cat ${file}`
#
# Diplay the file the user selected.
#
echo "<C>You selected the following file" > ${tmp}
echo " " >> ${tmp}
echo "<C><#HL(10)>" >> ${tmp}
echo "<C></B>${answer}" >> ${tmp}
echo "<C><#HL(10)>" >> ${tmp}
echo " " >> ${tmp}
echo "<C>You chose button #${selected}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>Press </R>space<!R> to continue." >> ${tmp}
${CDK_LABEL} -f ${tmp} -p " "
#
# Clean up.
#
rm -f ${tmp} ${file}

135
deps/cdk-5.0-20161210/cli/samples/itemlist.sh vendored Executable file
View File

@ -0,0 +1,135 @@
#!/bin/sh
# $Id: itemlist.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
#
# Description:
# This demonstrates the CDK command line
# interface to the itemlist list widget.
#
#
# This gets the password file.
#
getPasswordFile()
{
system=$1
file=$2
#
# Depeding on the system, get the password file
# using nicat, ypcat, or just plain old /etc/passwd
#
if [ "$system" = "NIS" ]; then
niscat passwd.org_dir | sort > $file
elif [ "$system" = "YP" ]; then
ypcat passwd | sort > $file
else
sort /etc/passwd > $file
fi
}
#
# This displays account information.
#
displayAccountInformation()
{
userAccount=$1
passwordFile=$2
#
# Get the user account information.
#
line=`grep "^${userAccount}" $passwordFile`
uid=`echo $line | cut -d: -f3`
gid=`echo $line | cut -d: -f4`
info=`echo $line | cut -d: -f5`
home=`echo $line | cut -d: -f6`
shell=`echo $line | cut -d: -f7`
#
# Create the label message information.
#
accountMessage="<C></U>Account
<C><#HL(30)>
Account: </U>${userAccount}
UID : </U>${uid}
GID : </U>${gid}
Info : </U>${info}
Home : </U>${home}
Shell : </U>${shell}
<C><#HL(30)>
<C>Hit </R>space<!R> to continue"
#
# Create the popup label.
#
${CDK_LABEL} -m "${accountMessage}" -p " "
}
#
# Create some global variables.
#
CDK_ITEMLIST="${CDK_BINDIR=..}/cdkitemlist"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
tmpPass="${TMPDIR=/tmp}/sl.$$"
output="${TMPDIR=/tmp}/output.$$"
userAccounts="${TMPDIR=/tmp}/ua.$$"
TYPE="Other";
#
# Chop up the command line.
#
set -- `getopt nNh $*`
if [ $? != 0 ]
then
echo $USAGE
exit 2
fi
for c in $*
do
case $c in
-n) TYPE="YP"; shift;;
-N) TYPE="NIS"; shift;;
-h) echo "$0 [-n YP] [-N NIS+] [-h]"; exit 0;;
--) shift; break;;
esac
done
#
# Create the message for the item list.
#
title="<C>Pick an account you want to view."
label="Account Name "
buttons=" OK
Cancel "
#
# Get the password file and stick it into the temp file.
#
getPasswordFile "${TYPE}" "$tmpPass"
#
# Get the user account from the password file.
#
awk 'BEGIN {FS=":"} {printf "</R>%s\n", $1}' $tmpPass | sort > ${userAccounts}
#
# Create the item list.
#
${CDK_ITEMLIST} -d 3 -L "${label}" -T "${title}" -B "${buttons}" -f "${userAccounts}" 2> ${output}
selected=$?
test $selected = 255 && exit 1
answer=`cat ${output}`
#
# Display the account information.
#
displayAccountInformation $answer $tmpPass
#
# Clean up.
#
rm -f ${output} ${tmpPass} ${userAccounts}

81
deps/cdk-5.0-20161210/cli/samples/label.sh vendored Executable file
View File

@ -0,0 +1,81 @@
#!/bin/sh
# $Id: label.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
#
# Description:
# This demonstrates the CDK command line
# interface to the label widget.
#
#
# Create some global variables.
#
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
dfTmp="${TMPDIR=/tmp}/label.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"
top="${TMPDIR=/tmp}/dfTop.$$"
bottom="${TMPDIR=/tmp}/dfBottom.$$"
#
# Get the filesystem information.
#
getDiskInfo()
{
fileName=$1;
command="df"
#
# Determine the type of operating system.
#
machine=`uname -s`
if [ "$machine" = "SunOS" ]; then
level=`uname -r`
if [ "$level" -gt 4 ]; then
command="df -kl"
fi
else
if [ "$machine" = "AIX" ]; then
command="df -i"
fi
fi
#
# Run the command.
#
${command} > ${fileName}
}
#
# Get the disk information.
#
getDiskInfo ${dfTmp}
#
# Bold the first line of the df command.
#
head -1 ${dfTmp} | awk '{printf "</B>%s\n", $0}' > ${top}
tail +2 ${dfTmp} > ${bottom}
#
# Create the message for the label widget.
#
echo "<C>This is the current" > ${tmp}
echo "<C>status of your local filesystems." >> ${tmp}
echo "<C><#HL(2)>" >> ${tmp}
cat ${top} >> ${tmp}
cat ${bottom} >> ${tmp}
echo "<C><#HL(2)>" >> ${tmp}
echo "" >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
#
# Create the label widget to display the information.
#
${CDK_LABEL} -f "${tmp}" -p " " -c "ls" -S
#
# Clean up.
#
rm -f ${tmp} ${output} ${dfTmp} ${top} ${bottom}

123
deps/cdk-5.0-20161210/cli/samples/matrix.sh vendored Executable file
View File

@ -0,0 +1,123 @@
#!/bin/sh
# $Id: matrix.sh,v 1.4 2005/12/27 17:07:00 tom Exp $
#
# Description:
# This demonstrates the CDK command line
# interface to the matrix widget.
#
#
# Create some global variables.
#
CDK_MATRIX="${CDK_BINDIR=..}/cdkmatrix"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
fileSystemList="${TMPDIR=/tmp}/fsList.$$"
info="${TMPDIR=/tmp}/fsInfo.$$"
diskInfo="${TMPDIR=/tmp}/diskInfo.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"
#
# Get the filesystem information.
#
getDiskInfo()
{
fileName=$1;
command="df"
#
# Determine the type of operating system.
#
machine=`uname -s`
if [ "$machine" = "SunOS" ]; then
level=`uname -r`
if [ "$level" -gt 4 ]; then
command="df -kl"
fi
else
if [ "$machine" = "AIX" ]; then
command="df -i"
fi
fi
#
# Run the command.
#
${command} > ${fileName}
}
#
# Get the disk information.
#
getDiskInfo ${diskInfo}
#
# Create the row titles.
#
rowTitles=`tail +2 ${diskInfo} | awk '{printf "%s\n", $1}'`
#
# Create the column titles.
#
colTitles="KBytes
Used
Avail
Capacity
Mounted on"
#
# Define the matrix title.
#
title="<C></U>Current Filesystem Information"
#
# Create the data file to fill in the matrix.
#
tail +2 ${diskInfo} | awk '{printf "%s%s%s%s%s\n", $2, $3, $4, $5, $6}' > ${info}
#
# Set the widths of the columns.
#
colWidths="5
5
5
5
5"
#
# Set the cells as uneditable.
#
types="VIEWONLY
VIEWONLY
VIEWONLY
VIEWONLY
VIEWONLY"
buttons=" OK
Cancel "
#
# Start the matrix.
#
${CDK_MATRIX} -r "${rowTitles}" -c "${colTitles}" -v 3 -w "${colWidths}" -d "${info}" -t "${types}" -T "${title}" -B "${buttons}" -O"$tmp"
selected=$?
test $selected = 255 && exit 1
#
# Create the message for the label widget.
#
echo "<C>You chose button #${selected}" > ${tmp}
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
#
# Create the label widget to display the information.
#
${CDK_LABEL} -f "${tmp}" -p " "
#
# Clean up.
#
rm -f ${info} ${fileSystemList} ${tmp} ${diskInfo}

54
deps/cdk-5.0-20161210/cli/samples/mentry.sh vendored Executable file
View File

@ -0,0 +1,54 @@
#!/bin/sh
# $Id: mentry.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
#
# Description:
# This demonstrates the CDK command line
# interface to the multiple line entry widget.
#
#
# Create some global variables.
#
CDK_MENTRY="${CDK_BINDIR=..}/cdkmentry"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
output="${TMPDIR=/tmp}/mentry_output.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"
#
# Create the title.
#
title="<C>Type in a short message."
buttons=" OK
Cancel "
#
# Create the mentry box.
#
${CDK_MENTRY} -s 5 -v 10 -f 20 -T "${title}" -B "${buttons}" -F '_' -O ${output}
selected=$?
test $selected = 255 && exit 1
answer=`cat ${output}`
#
# Create the message for the label widget.
#
echo "<C>Here is the message you typed in" > ${tmp}
echo " " >> ${tmp}
echo "<C></R>${answer}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>You chose button #${selected}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
#
# Create the label widget to display the information.
#
${CDK_LABEL} -f ${tmp} -p " "
#
# Clean up.
#
rm -f ${tmp} ${output}

95
deps/cdk-5.0-20161210/cli/samples/radio.sh vendored Executable file
View File

@ -0,0 +1,95 @@
#!/bin/sh
# $Id: radio.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
#
# Description:
# This demonstrates the CDK command line
# interface to the radio widget.
#
#
# Create some global variables.
#
CDK_RADIO="${CDK_BINDIR=..}/cdkradio"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
fileSystemList="${TMPDIR=/tmp}/fsList.$$"
diskInfo="${TMPDIR=/tmp}/diskInfo.$$"
output="${TMPDIR=/tmp}/radio_output.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"
#
# Get the filesystem information.
#
getDiskInfo()
{
fileName=$1;
command="df"
#
# Determine the type of operating system.
#
machine=`uname -s`
if [ "$machine" = "SunOS" ]; then
level=`uname -r`
if [ "$level" -gt 4 ]; then
command="df -kl"
fi
else
if [ "$machine" = "AIX" ]; then
command="df -i"
fi
fi
#
# Run the command.
#
${command} > ${fileName}
}
#
# Create the title for the scrolling list.
#
title="<C>Pick a filesystem to view."
buttons=" OK
Cancel "
#
# Get a list of the local filesystems.
#
getDiskInfo ${diskInfo}
#
# Create the file system list.
#
grep "^/" ${diskInfo} | awk '{printf "%s\n", $1}' > ${fileSystemList}
#
# Create the radio list.
#
${CDK_RADIO} -T "${title}" -f "${fileSystemList}" -c "</U>*" -B "${buttons}" 2> $output
selected=$?
test $selected = 255 && exit 1
#
# The selection is now in the file $output.
#
fs=`cat ${output}`
echo "<C></R>File Statistics on the filesystem ${fs}" > ${tmp}
echo " " >> ${tmp}
grep "${fs}" ${diskInfo} | awk '{printf "</B>%s\n", $0}' >> ${tmp}
echo " " >> ${tmp}
echo "<C>You chose button #${selected}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
#
# Create the label widget to display the information.
#
${CDK_LABEL} -f ${tmp} -p " "
#
# Clean up.
#
rm -f ${tmp} ${output} ${fileSystemList} ${diskInfo}

55
deps/cdk-5.0-20161210/cli/samples/scale.sh vendored Executable file
View File

@ -0,0 +1,55 @@
#!/bin/sh
# $Id: scale.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
#
# Description:
# This demonstrates the CDK command line
# interface to the scale widget.
#
#
# Create some global variables.
#
CDK_SCALE="${CDK_BINDIR=..}/cdkscale"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
output="${TMPDIR=/tmp}/scale_output.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"
#
# Create the title.
#
title="<C>Enter a value using the cursor keys."
label="</R>Value"
buttons=" OK
Cancel "
#
# Create the scale box.
#
${CDK_SCALE} -f 20 -l 0 -h 100 -i 5 -L "${label}" -T "${title}" -B "${buttons}" -O ${output}
selected=$?
test $selected = 255 && exit 1
answer=`cat ${output}`
#
# Create the message for the label widget.
#
echo "<C>Here is the value you selected" > ${tmp}
echo " " >> ${tmp}
echo "<C></R>${answer}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>You chose button #${selected}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
#
# Create the label widget to display the information.
#
${CDK_LABEL} -f ${tmp} -p " "
#
# Clean up.
#
rm -f ${tmp} ${output}

136
deps/cdk-5.0-20161210/cli/samples/scroll.sh vendored Executable file
View File

@ -0,0 +1,136 @@
#!/bin/sh
# $Id: scroll.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
#
# Description:
# This demonstrates the CDK command line
# interface to the scrolling list widget.
#
#
# This gets the password file.
#
getPasswordFile()
{
system=$1
file=$2
#
# Depeding on the system, get the password file
# using nicat, ypcat, or just plain old /etc/passwd
#
if [ "$system" = "NIS" ]; then
niscat passwd.org_dir > $file
elif [ "$system" = "YP" ]; then
ypcat passwd > $file
else
cp /etc/passwd $file
fi
}
#
# This displays account information.
#
displayAccountInformation()
{
userAccount=$1
passwordFile=$2
#
# Get the user account information.
#
line=`grep "^${userAccount}" $passwordFile`
uid=`echo $line | cut -d: -f3`
gid=`echo $line | cut -d: -f4`
info=`echo $line | cut -d: -f5`
home=`echo $line | cut -d: -f6`
shell=`echo $line | cut -d: -f7`
#
# Create the label message information.
#
accountMessage="<C></U>Account
<C><#HL(30)>
Account: </U>${userAccount}
UID : </U>${uid}
GID : </U>${gid}
Info : </U>${info}
Home : </U>${home}
Shell : </U>${shell}
<C><#HL(30)>
<C>Hit </R>space<!R> to continue"
#
# Create the popup label.
#
${CDK_LABEL} -m "${accountMessage}" -p " "
}
#
# Create some global variables.
#
CDK_SCROLL="${CDK_BINDIR=..}/cdkscroll"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
tmpPass="${TMPDIR=/tmp}/sl.$$"
output="${TMPDIR=/tmp}/output.$$"
userAccounts="${TMPDIR=/tmp}/ua.$$"
TYPE="Other"
#
# Chop up the command line.
#
set -- `getopt nNh $*`
if [ $? != 0 ]
then
echo $USAGE
exit 2
fi
for c in $*
do
case $c in
-n) TYPE="YP"; shift;;
-N) TYPE="NIS"; shift;;
-h) echo "$0 [-n YP] [-N NIS+] [-h]"; exit 0;;
--) shift; break;;
esac
done
#
# Create the message for the scrolling list.
#
title="<C><#HL(30)>
<C>Pick an account you want to view.
<C><#HL(30)>"
buttons=" OK
Cancel "
#
# Get the password file and stick it into the temp file.
#
getPasswordFile "${TYPE}" "$tmpPass"
#
# Get the user account from the password file.
#
awk 'BEGIN {FS=":"} {printf "%s\n", $1}' $tmpPass | sort > ${userAccounts}
#
# Create the scrolling list.
#
${CDK_SCROLL} -T "${title}" -f ${userAccounts} -n -B "${buttons}" 2> ${output}
selected=$?
test $selected = 255 && exit 1
answer=`cat ${output}`
#
# Display the account information.
#
displayAccountInformation $answer $tmpPass
#
# Clean up.
#
rm -f ${output} ${tmpPass} ${userAccounts}

191
deps/cdk-5.0-20161210/cli/samples/selection.sh vendored Executable file
View File

@ -0,0 +1,191 @@
#!/bin/sh
# $Id: selection.sh,v 1.4 2005/12/27 17:56:58 tom Exp $
#
# Description:
# This demonstrates the CDK command line
# interface to the selection widget.
#
#
# This gets the password file.
#
getPasswordFile()
{
system=$1
file=$2
#
# Depending on the system, get the password file
# using nicat, ypcat, or just plain old /etc/passwd
#
if [ "$system" = "NIS" ]; then
niscat passwd.org_dir > $file
elif [ "$system" = "YP" ]; then
ypcat passwd > $file
else
cp /etc/passwd $file
fi
}
#
# This displays account information.
#
displayAccountInformation()
{
totalSelections=$1
currentSelection=$2
userAccount=$3
passwordFile=$4
#
# Get the user account information.
#
line=`grep "^${userAccount}" $passwordFile`
uid=`echo $line | cut -d: -f3`
gid=`echo $line | cut -d: -f4`
info=`echo $line | cut -d: -f5`
home=`echo $line | cut -d: -f6`
shell=`echo $line | cut -d: -f7`
#
# Create the label message information.
#
accountMessage="<C></U>Account ${currentSelection}/${totalSelections}
<C><#HL(30)>
Account: </U>${userAccount}
UID : </U>${uid}
GID : </U>${gid}
Info : </U>${info}
Home : </U>${home}
Shell : </U>${shell}
<C><#HL(30)>
<C>Hit </R>space<!R> to continue"
#
# Create the popup label.
#
${CDK_LABEL} -m "${accountMessage}" -p " "
}
#
# Define where the CDK widgets are.
#
CDK_SELECTION="${CDK_BINDIR=..}/cdkselection"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
TYPE="Other"
#
# Define the output files.
#
accountList="${TMPDIR=/tmp}/accList.$$"
userAccounts="${TMPDIR=/tmp}/userAccList.$$"
output="${TMPDIR=/tmp}/selection_output.$$"
tmpPass="${TMPDIR=/tmp}/ps.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"
#
# Chop up the command line.
#
set -- `getopt nNh $*`
if [ $? != 0 ]
then
echo $USAGE
exit 2
fi
for c in $*
do
case $c in
-n) TYPE="YP"; shift;;
-N) TYPE="NIS"; shift;;
-h) echo "$0 [-n YP] [-N NIS+] [-h]"; exit 0;;
--) shift; break;;
esac
done
#
# Create the message for the selection list.
#
title="<C>Pick a user account to view."
#
# Get the password file and stick it into the temp file.
#
getPasswordFile "${TYPE}" "$tmpPass"
#
# Create the user account list.
#
awk 'BEGIN {FS=":"} {printf "%s\n", $1}' $tmpPass | sort > ${userAccounts}
awk '{printf "<C></B>%s\n", $1}' ${userAccounts} > ${accountList}
accounts=`cat ${userAccounts}`
#
# Create the choices list.
#
choices="<C></B>No
<C></B> Yes "
buttons=" OK
Cancel "
#
# Create the selection list.
#
${CDK_SELECTION} -T "${title}" -f "${accountList}" -c "${choices}" -B "${buttons}" 2> $output
selected=$?
test $selected = 255 && exit 1
#
# Initialize the variables.
#
selection=""
value=""
#
# Count how many were selected.
#
count=`grep -c "^1" ${output}`
current=0
#
# Create the label.
#
for i in `cat ${output}`
do
#
# Since every other variable is value/selection, we
# store every other value in the correct variable.
#
if [ "$value" = "" ]; then
value="$i"
else
selection="$i"
#
# Only display the selected accounts.
#
if [ "$value" -eq 1 ]; then
#
# Increment our counter.
#
current=`expr $current + 1`
#
# Display the account information.
#
displayAccountInformation $count $current $selection $tmpPass
fi
#
# Reset the variables.
#
value=""
selection=""
fi
done
#
# Clean up.
#
rm -f ${accountList} ${userAccounts} ${output} ${tmpPass} ${tmp}

55
deps/cdk-5.0-20161210/cli/samples/slider.sh vendored Executable file
View File

@ -0,0 +1,55 @@
#!/bin/sh
# $Id: slider.sh,v 1.4 2005/12/27 15:53:06 tom Exp $
#
# Description:
# This demonstrates the CDK command line
# interface to the slider widget.
#
#
# Create some global variables.
#
CDK_SLIDER="${CDK_BINDIR=..}/cdkslider"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
output="${TMPDIR=/tmp}/slider_output.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"
#
# Create the title.
#
title="<C>Enter a value using the cursor keys"
label="Value: "
buttons=" OK
Cancel "
#
# Create the slider box.
#
${CDK_SLIDER} -f 20 -l 0 -h 100 -i 5 -L "${label}" -T "${title}" -F "</R>*" -B "${buttons}" -O ${output}
selected=$?
test $selected = 255 && exit 1
answer=`cat ${output}`
#
# Create the message for the label widget.
#
echo "<C>Here is the value you selected" > ${tmp}
echo " " >> ${tmp}
echo "<C></R>${answer}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>You chose button #${selected}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
#
# Create the label widget to display the information.
#
${CDK_LABEL} -f ${tmp} -p " "
#
# Clean up.
#
rm -f ${tmp} ${output}

55
deps/cdk-5.0-20161210/cli/samples/template.sh vendored Executable file
View File

@ -0,0 +1,55 @@
#!/bin/sh
# $Id: template.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
#
# Description:
# This demonstrates the CDK command line
# interface to the template widget.
#
#
# Create some global variables.
#
CDK_TEMPLATE="${CDK_BINDIR=..}/cdktemplate"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
output="${TMPDIR=/tmp}/template_output.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"
#
# Create the title.
#
title="<C> Type in the
<C>IP Address for this machine."
buttons=" OK
Cancel "
#
# Create the template box.
#
${CDK_TEMPLATE} -p "###.###.###.###" -o "___.___.___.___" -T "${title}" -P -B "${buttons}" 2> ${output}
selected=$?
test $selected = 255 && exit 1
answer=`cat ${output}`
#
# Create the message for the label widget.
#
echo "<C>Here is the IP you typed in" > ${tmp}
echo " " >> ${tmp}
echo "<C></R>${answer}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>You chose button #${selected}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
#
# Create the label widget to display the information.
#
${CDK_LABEL} -f ${tmp} -p " "
#
# Clean up.
#
rm -f ${tmp} ${output}

76
deps/cdk-5.0-20161210/cli/samples/viewer.sh vendored Executable file
View File

@ -0,0 +1,76 @@
#!/bin/sh
# $Id: viewer.sh,v 1.3 2005/12/27 15:53:06 tom Exp $
#
# Description:
# This demonstrates the CDK command line
# interface to the viewer widget.
#
#
# Create some global variables.
#
CDK_FSELECT="${CDK_BINDIR=..}/cdkfselect"
CDK_VIEWER="${CDK_BINDIR=..}/cdkviewer"
tmp="${TMPDIR=/tmp}/tmp.$$"
file="${TMPDIR=/tmp}/fs.$$"
directory="."
xpos=CENTER
ypos=CENTER
width="-2"
height="0"
interpret=0
#
# Chop up the command line.
#
set -- `getopt d:x:y:w:h:i $*`
if [ $? != 0 ]
then
echo $USAGE
exit 2
fi
for c in $*
do
case $c in
-d) directory=$2; shift 2;;
-x) xpos=$2; shift 2;;
-y) ypos=$2; shift 2;;
-w) width=$2; shift 2;;
-h) height=$2; shift 2;;
-i) interpret=1; shift 1;;
--) shift; break;;
esac
done
#
# Create the CDK file selector.
#
${CDK_FSELECT} -T "<C>Select a file" -d "${directory}" 2> ${file}
selected=$?
test $selected = 255 && exit 1
answer=`cat ${file}`
#
# Create the title and buttons for the viewer.
#
title="<C>CDK File Viewer Widget
<C></U>${answer}"
buttons="OK"
#
# Create the file viewer.
#
if [ "$interpret" -eq 1 ]; then
${CDK_VIEWER} -f "${answer}" -T "${title}" -B "${buttons}" -i -X ${xpos} -Y ${ypos} -H "${height}" -W "${width}"
else
${CDK_VIEWER} -f "${answer}" -T "${title}" -B "${buttons}" -X ${xpos} -Y ${ypos} -H "${height}" -W "${width}" -B "${buttons}"
fi
#
# Clean up.
#
rm -f ${tmp} ${file}

686
deps/cdk-5.0-20161210/cli/utils/adduser vendored Executable file
View File

@ -0,0 +1,686 @@
#!/bin/sh
# $Id: adduser,v 1.3 2002/07/16 22:24:53 tom Exp $
#
# Written by: Mike Glover, March 1997
# E-mail : vexus@home.com, glover@credit.erin.utoronto.ca
#
# Purpose:
# This is a graphical adduser program. The widgets are
# the CDK command line widgets provided by the CDK
# distribution. If you have any questions about CDK,
# or the command line widgets please feel free to mail
# me at one of the two above addresses.
#
#
# Copyright 2000, Mike Glover
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgment:
# This product includes software developed by Mike Glover
# and contributors.
# 4. Neither the name of Mike Glover nor the names of contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# Set the screen and widget colors.
#
CDK_WIDGET_COLOR="</5>"; export CDK_WIDGET_COLOR
CDK_SCREEN_COLOR="</1>"; export CDK_SCREEN_COLOR
#
# Set up some variables.
#
CDK_DIALOG="../cdkdialog"
CDK_ENTRY="../cdkentry"
CDK_SCROLL="../cdkscroll"
tmpFile="/tmp/tmp.$$"
tmpInfo="/tmp/adduserInfo.$$"
shellFile="/tmp/shells.$$"
ACCOUNT_SHELL=""
ACCOUNT_INFO=""
ACCOUNT_NAME=""
ACCOUNT_HOME=""
ACCOUNT_GID=""
ACCOUNT_UID=""
GROUP_NAME=""
CURRENT_FUNCTION=1;
#
# This quits the program.
#
quitProgram()
{
#
# The person has decided to quit.
#
buttons="< OK >"
message="<C></B><#HL(30)>
<C></B>Add New User Canceled
<C></B>Program exiting
<C></B><#HL(30)>"
${CDK_DIALOG} -m "${message}" -B "${buttons}" -N 2> /dev/null
exit;
}
#
# This warns the user to what is about to happen. It
# gives them a safe 'out'
#
warnUser()
{
#
# Pop up a little message telling the user what is
# about to happen.
#
message="<C></B>Adding New User
You are about to add a new user. If you do not want to
do this, move the cursor to the cancel button and hit
return. This will exit this program. Otherwise hit
return to continue."
buttons="< OK >
< Cancel >"
${CDK_DIALOG} -m "${message}" -B "${buttons}" 2> /dev/null
if [ $? -ne 0 ]; then
quitProgram;
fi
}
#
# This gets the account name from the user.
#
getAccountName()
{
#
# Keep doing this until we hit an account which does not
# already exist.
#
count=1;
while [ $count -ne 0 ]; do
#
# Get the account name from the user.
#
buttons="Next
Cancel"
label="</24/B>Account Name: "
title="<C></B>Account Name
<C>The name is the identity of the account which the
<C>user will use to access the system.
"
${CDK_ENTRY} -i "${ACCOUNT_NAME}" -f 15 -m 3 -F "</56/B>_" -T "${title}" -L "${label}" -B "${buttons}" 2> ${tmpFile}
selected=$?
ACCOUNT_NAME=`cat ${tmpFile}`
#
# Check the selected button.
#
if [ $selected -eq 0 ]; then
DIRECTION=1; export DIRECTION;
else
quitProgram;
fi
#
# Look for the account name in the password file.
#
count=`grep -c "^${ACCOUNT_NAME}" /etc/passwd`
if [ ${count} -eq 1 ]; then
buttons="< OK >"
message="<C></B>Account Found
<C>The account you provided
<C></B>${ACCOUNT_NAME}
<C>already exists in the password file. Please pick
<C>another account name."
${CDK_DIALOG} -m "${message}" -B "${buttons}" 2> /dev/null
fi
done
}
#
# This gets the account information.
#
getAccountInfo()
{
#
# Set up the entry field.
#
buttons="Next
Previous
Cancel"
label="</24/B>Personal Info: "
title="<C></B>Account Information.
Enter in </B>${ACCOUNT_NAME}<!B>'s personal information. This is usually the
account holders name, phone number, or extension. This is fairly freeform.
The only character you can not use is a colon (:). If you do all colons will
be stripped out by this process.
"
${CDK_ENTRY} -f 40 -i "${ACCOUNT_INFO}" -F "</56/B>_" -T "${title}" -L "${label}" -B "${buttons}" 2> ${tmpFile}
selected=$?
ACCOUNT_INFO=`cat ${tmpFile} | tr ':' ' '`
#
# Check the selected button.
#
if [ $selected -eq 0 ]; then
DIRECTION=1; export DIRECTION;
elif [ $selected -eq 1 ]; then
DIRECTION=-1; export DIRECTION;
return;
else
quitProgram;
fi
}
#
# This gets the account GID.
#
getAccountGID()
{
#
# Get the 'users' GID from /etc/group.
#
if [ "$ACCOUNT_GID" = "" ]; then
count=`grep -c "^users" /etc/group`
if [ $count -eq 0 ]; then
USER_GID="100";
else
USER_GID=`grep "^users" /etc/group | cut -d: -f3`
fi
else
USER_GID="$ACCOUNT_GID";
fi
#
# Keep doing this until we get a GID which exists.
#
count=0;
while [ $count -eq 0 ]; do
#
# Get the GID.
#
buttons="Next
Previous
Cancel"
label="</24/B>Account GID: "
title="<C></B>Account GID
The GID (Group IDentification) must be a number which already
exists in the /etc/group file. The default group </B>users<!B>
has been provided for you.
"
${CDK_ENTRY} -f 6 -m 1 -i "${USER_GID}" -F "</56/B>_" -T "${title}" -L "${label}" -B "${buttons}" 2> ${tmpFile}
selected=$?
ACCOUNT_GID=`cat ${tmpFile}`
#
# Check the selected button.
#
if [ $selected -eq 0 ]; then
DIRECTION=1; export DIRECTION;
elif [ $selected -eq 1 ]; then
DIRECTION=-1; export DIRECTION;
return;
else
quitProgram;
fi
#
# Look for GID in the /etc/group
#
count=`grep -c ".*:.*:${ACCOUNT_GID}:" /etc/group`
if [ ${count} -eq 0 ]; then
buttons="< OK >"
message="<C></B>Error: No Such GID
<C>The GID you provided does not exist.
<C>Please pick a GID which does exist.
"
${CDK_DIALOG} -m "${message}" -B "${buttons}" 2> /dev/null
if [ $? -ne 0 ]; then
quitProgram;
fi
else
#
# Get the group name for later.
#
GROUP_NAME=`grep ".*:.*:${ACCOUNT_GID}:" /etc/group | cut -d: -f1`
fi
done
}
#
# This gets the account UID.
#
getAccountUID()
{
#
# Try to find the next available UID.
#
if [ "$ACCOUNT_UID" = "" ]; then
nextUID=`awk 'BEGIN {FS=":"} {print $3}' /etc/passwd | sort -n | grep -v "65535" | tail -1`
nextUID=`expr $nextUID + 1`
else
nextUID="$ACCOUNT_UID"
fi
#
# Keep doing this until we get a UID which does not exist.
#
count=1;
while [ $count -ne 0 ]; do
#
# Get the UID.
#
buttons="Next
Previous
Cancel"
label="</24/B>Account UID: "
title="<C></B>Account UID
The UID (User IDentification) must be a number which does not
already exist in the /etc/passwd file. The value filled in is
the next available UID found from the password file.
"
${CDK_ENTRY} -f 6 -i "${nextUID}" -m 1 -F "</56/B>_" -T "${title}" -L "${label}" -B "${buttons}" 2> ${tmpFile}
selected=$?
ACCOUNT_UID=`cat ${tmpFile}`
#
# Check the selected button.
#
if [ $selected -eq 0 ]; then
DIRECTION=1; export DIRECTION;
elif [ $selected -eq 1 ]; then
DIRECTION=-1; export DIRECTION;
return;
else
quitProgram;
fi
#
# Look for UID in the /etc/passwd
#
count=`grep -c ".*:.*:${ACCOUNT_UID}:" /etc/passwd`
if [ ${count} -ne 0 ]; then
owner=`grep ".*:.*:${ACCOUNT_UID}:" /etc/passwd | head -1 |cut -d: -f1`
buttons="< OK >"
message="<C></B>Error: Duplicate UID
<C>The UID you provided is already owned by
<C>the account </B>$owner<!B>. Please pick a
<C>UID which does not already exist.
"
${CDK_DIALOG} -m "${message}" -B "${buttons}" 2> /dev/null
if [ $? -ne 0 ]; then
quitProgram;
fi
fi
done
}
#
# This gets the account home directory.
#
getAccountHome()
{
if [ "${ACCOUNT_HOME}" = "" ]; then
defaultHome="/home/${ACCOUNT_NAME}"
else
defaultHome="${ACCOUNT_HOME}"
fi
#
# Set up the entry field.
#
buttons="Next
Previous
Cancel"
label="</24/B>Home Directory: "
title="<C></B>Account Home Directory.
Enter in the account's home directory. If the directory
does not currently exist, it will be created in the account
creation phase of this process. A reasonable default value
for the home directory has been provided.
"
${CDK_ENTRY} -f 20 -F "</56/B>_" -i "${defaultHome}" -T "${title}" -L "${label}" -B "${buttons}" 2> ${tmpFile}
selected=$?
ACCOUNT_HOME=`cat ${tmpFile}`
#
# Check the selected button.
#
if [ $selected -eq 0 ]; then
DIRECTION=1; export DIRECTION;
elif [ $selected -eq 1 ]; then
DIRECTION=-1; export DIRECTION;
return;
else
quitProgram;
fi
}
#
# This gets the shell the user want to assign to
# the account.
#
getAccountShell()
{
count=0;
while [ "$count" -eq 0 ]; do
#
# Get the shell they want to use.
#
buttons="Next
Previous
Cancel"
title="<C>Account Shell
Pick one of the shells to use. If you want to use a
custom shell, pick </B>Custom<!B> and you will be
prompted for it's path.
"
echo "Custom" > ${shellFile}
cat /etc/shells >> ${shellFile}
${CDK_SCROLL} -H 5 -W 10 -T "${title}" -f ${shellFile} -B "${buttons}" 2> ${tmpFile}
selected=$?
ACCOUNT_SHELL=`cat ${tmpFile}`
#
# Check the selected buttons.
#
if [ $selected -eq 0 ]; then
DIRECTION=1; export DIRECTION;
count=1;
elif [ $selected -eq 1 ]; then
DIRECTION=-1; export DIRECTION;
return;
else
quitProgram;
fi
#
# Check the answer.
#
if [ "$ACCOUNT_SHELL" = "Custom" ]; then
#
# Get the shell from the user.
#
buttons="Next
Previuous
Cancel"
label="</24/B>Shell Pathname: "
title="<C></B>Custom Account Shell
Enter in the path to the custom shell. The authenticity
of the shell will not be checked here. It is assumed that
the shell will exist when the account is ready to be used.
"
${CDK_ENTRY} -f 20 -F "</56/B>_" -T "${title}" -L "${label}" -B "${buttons}" 2> ${tmpFile}
selected=$?
ACCOUNT_SHELL=`cat ${tmpFile}`
#
# Check the selected buttons.
#
if [ $selected -eq 0 ]; then
DIRECTION=1; export DIRECTION;
count=1;
elif [ $selected -eq 1 ]; then
count=0;
else
quitProgram;
fi
fi
done
}
#
# This confirms the new account information.
#
confirmAccount()
{
message="<C></B>Confirm New Account.
You are about to add an account with the following
information:
<C><#HL(30)>
Account Name : </B>$ACCOUNT_NAME
Account Info : </B>$ACCOUNT_INFO
Account Home : </B>$ACCOUNT_HOME
Account Shell: </B>$ACCOUNT_SHELL
Account UID : </B>$ACCOUNT_UID
Account GID : </B>$ACCOUNT_GID
<C><#HL(30)>
Are you sure you want to do this. Hit </R>Yes<!R> if you
want to add the account; hit </R>No<!R> if you want to
edit the information; hit </R>Cancel<!R> if you want to
abandon all information.
"
buttons="< Yes >
< No >
< Cancel >"
${CDK_DIALOG} -m "${message}" -B "${buttons}" 2> /dev/null
answer=$?
#
# Check the answer.
#
if [ "$answer" -eq 2 -o "$answer" -eq 255 ]; then
quitProgram;
fi
if [ "$answer" -eq 0 ]; then
confirm=1; export confirm;
else
confirm=0; export confirm;
fi
}
#
# Find out if the user wants to change the password
# or not.
#
changeAccountPassword()
{
buttons="< Yes >
< No >"
message="<C></B>Change Account Password Now
Since the account was added without a password, this account
can be logged in to without providing a password. Would you
like to change the account's password now?
"
${CDK_DIALOG} -m "${message}" -B "${buttons}" 2> /dev/null
answer=$?
if [ "$answer" -eq 0 ]; then
passwd $ACCOUNT_NAME
fi
}
#
# This verifies the users ability to modify the
# password file.
#
checkPermissions()
{
#
# Try to touch the passwd file.
#
touch /etc/passwd >/dev/null 2>&1
if [ $? -ne 0 ]; then
#
# Can't touch the password file. Let's tell them and go.
#
buttons="< Log Into Root Now >
< Exit >"
message="<C></B>Can Not Edit Password File
It appears that you do not have permission to edit the
password file. To add a new user to this machine you
must be logged in as root. Would you like to su to root
now or exit and log in. If you try to su now, this
program will be restarted.
"
${CDK_DIALOG} -m "${message}" -B "${buttons}" 2> /dev/null
if [ $? -eq 0 ]; then
su root -c "$0"
fi
exit;
fi
}
#
# This creates the account and copies all needed
# information.
#
createAccount()
{
if [ ! -d "$ACCOUNT_HOME" ]; then
mkdir $ACCOUNT_HOME
fi
if [ "$ACCOUNT_SHELL" = "/bin/sh" ]; then
cp /etc/profile ${ACCOUNT_HOME}/.profile
fi
if [ "$ACCOUNT_SHELL" = "/bin/bash" ]; then
cp /etc/profile ${ACCOUNT_HOME}/.profile
fi
if [ "$ACCOUNT_SHELL" = "/bin/csh" ]; then
cp /etc/csh.cshrc ${ACCOUNT_HOME}/.cshrc
cp /etc/csh.login ${ACCOUNT_HOME}/.login
fi
if [ "$ACCOUNT_SHELL" = "/bin/tcsh" ]; then
cp /etc/csh.cshrc ${ACCOUNT_HOME}/.cshrc
cp /etc/csh.login ${ACCOUNT_HOME}/.login
fi
chown -R ${ACCOUNT_NAME}.${GROUP_NAME} $ACCOUNT_HOME
}
###########################################################
#
# This is the start of the info retrieval.
#
###########################################################
#
# Set up the intermiediate functions so we can go
# backward and forward.
#
function1()
{
getAccountName;
}
function2()
{
getAccountInfo;
}
function3()
{
getAccountGID;
}
function4()
{
getAccountUID;
}
function5()
{
getAccountHome;
}
function6()
{
getAccountShell;
}
function7()
{
confirmAccount;
}
#
# Make sure the user has permission to edit the password file.
#
checkPermissions;
#
# Tell the user what they are about to do.
#
warnUser;
#
# Call the functions to get the needed info.
#
confirm=0;
NUMBER=0;
DIRECTION=1;
while [ "$confirm" -eq 0 ]; do
NUMBER=`expr $NUMBER + $DIRECTION`
if [ $NUMBER -le 0 ]; then
NUMBER = 1;
fi
CURRENT_FUNCTION="function${NUMBER}";
$CURRENT_FUNCTION;
done
#
# Add the account to the password file.
#
cp /etc/passwd /etc/passwd.old
echo "${ACCOUNT_NAME}::${ACCOUNT_UID}:${ACCOUNT_GID}:${ACCOUNT_INFO}:${ACCOUNT_HOME}:${ACCOUNT_SHELL}" >> /etc/passwd
#
# Find out if the user wants to change the password or not.
#
changeAccountPassword;
#
# Create the account and copy . files.
#
createAccount;
#
# Pop up a last little message and tell the user everything
# if OK.
#
buttons="< OK >"
message="<C></B>Account Add Complete
The account </B>${ACCOUNT_NAME}<!B> has been added to the password
file. You should be able to log in under this account
now.
"
${CDK_DIALOG} -m "${message}" -B "${buttons}" 2> /dev/null

415
deps/cdk-5.0-20161210/cli/utils/netconfig vendored Executable file
View File

@ -0,0 +1,415 @@
#!/bin/sh
# $Id: netconfig,v 1.3 2002/07/16 22:25:56 tom Exp $
#
# Written by: Mike Glover, March 1997
# E-mail : vexus@home.com, glover@credit.erin.utoronto.ca
#
# Purpose:
# This is a graphical network configuration program.
# It was inspired by the cdialog interface that Linux
# uses. The widgets are the CDK command line widgets
# provided by the CDK distribution. If you have any
# questions about CDK, or the command line widgets
# please feel free to mail me at one of the two above
# addresses.
#
#
# Copyright 2000, Mike Glover
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgment:
# This product includes software developed by Mike Glover
# and contributors.
# 4. Neither the name of Mike Glover nor the names of contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# Set up the root directory for the system files.
#
if [ "$1" = "" ]; then
ROOTDIR=""
else
ROOTDIR=$1;
fi
#
# This copies a file to it's destination and
# sets the file mode.
#
copyFile()
{
source=$1;
dest=$2;
mode=$3;
#
# If the original exists, make a copy.
#
if [ -f "${dest}" ]; then
cp ${dest} ${dest}.old
fi
mv ${source} ${dest}
chmod ${mode} ${dest}
}
#
# Set up some variables.
#
CDK_DIALOG="../cdkdialog"
CDK_ENTRY="../cdkentry"
CDK_TEMPLATE="../cdktemplate"
NETWORKS="${ROOTDIR}/etc/networks"
HOSTS="${ROOTDIR}/etc/hosts"
HOSTNAME_FILE="${ROOTDIR}/etc/HOSTNAME"
RESOLV="${ROOTDIR}/etc/resolv.conf"
INET="${ROOTDIR}/etc/rc.d/rc.inet1"
IFCONFIG="${ROOTDIR}/sbin/ifconfig"
ROUTE="${ROOTDIR}/sbin/route"
tmpFile="/tmp/tmp.$$"
#
# Define some global variables.
#
IP=""
HOST=""
DOMAIN=""
GATEWAY=""
NETMASK=""
NETWORK=""
BROADCAST=""
NAMESERVER=""
#
# Set the screen and widget colors.
#
CDK_WIDGET_COLOR="</5>"; export CDK_WIDGET_COLOR
CDK_SCREEN_COLOR="</7>"; export CDK_SCREEN_COLOR
#
#
#
exitMessage()
{
exit;
}
#
# Create the opening window.
#
intro()
{
program=`basename $0`
buttons="</R>< OK >"
message="<C></B>Network Configuration
We will now attempt to configure your mail and TCP/IP. This
process probably won't work on all possible network
configurations; but should give you a good start. You will
be able to reconfigure your network at any time by typing
in the command:
<C>${program}"
${CDK_DIALOG} -m "${message}" -B "${buttons}" -S 2> /dev/null
}
#
# Get the hostname of the machine.
#
getHostname()
{
label="</24/B>Enter Hostname: "
title="<C></B>Enter Hostname
We need to give the machine a name. We only need the base
hostname of the machine; the domain will be queried for
next.
"
${CDK_ENTRY} -i "${HOST}" -f 20 -F "</56/B>_" -T "${title}" -L "${label}" -S 2> ${tmpFile}
HOST=`cat ${tmpFile}`
}
#
# Get the domain name of the machine.
#
getDomainName()
{
label="</24/B>Enter Domain Name: "
title="<C></B>Enter Domain Name
Now enter in the domain in which this machine will
reside. Do </K>NOT<!K> supply a leading '.'
"
${CDK_ENTRY} -i "${DOMAIN}" -f 20 -F "</56/B>_" -T "${title}" -L "${label}" -S 2> ${tmpFile}
DOMAIN=`cat ${tmpFile}`
}
#
# Ask them if they plan to use loopback only.
#
loopback()
{
buttons="< Yes >
< No >"
message="<C></B>Loopback
Do you plan to only use loopback? If so then your address will
be 127.0.0.1 and most of the following questions can be skipped.
<C>Do you plan to ONLY use loopback?
"
${CDK_DIALOG} -m "${message}" -B "${buttons}" -S 2> /dev/null
answer=$?
if [ $answer -eq 0 ]; then
exitMessage;
fi
}
#
# Get the IP Address.
#
getIPAddress()
{
title="<C> </B>Enter Machine IP Address
<C>Enter the IP address you plan to assign to this machine.
"
plate="###.###.###.###"
overlay="</56/B>___.___.___.___"
${CDK_TEMPLATE} -i "${IP}" -p "${plate}" -o "${overlay}" -T "${title}" -m 10 -P -S 2> ${tmpFile}
IP=`cat ${tmpFile}`
}
#
#
#
getGatewayAddress()
{
NETWORK=`echo ${IP} | awk 'BEGIN {FS="."} {printf ("%s.%s.%s.0",$1,$2,$3)}'`
BROADCAST=`echo ${IP} | awk 'BEGIN {FS="."} {printf ("%s.%s.%s.255",$1,$2,$3)}'`
#
# Get the machine's gateway address.
#
title="<C> </B>Enter Gateway Address
Enter the address of the gateway for this machine. If you do not
know, or have one, use the IP address of this machine. The IP
address you assigned to this machine should already be filled
in. If you want to erase it press control-x to erase the field
or hit the backspace or delete key to erase portions of the field.
"
tmp=`echo ${IP} | sed 's/\.//g'`
plate="###.###.###.###"
overlay="</B/56>___.___.___.___"
${CDK_TEMPLATE} -d "${tmp}" -p "${plate}" -o "${overlay}" -T "${title}" -m 10 -P -S 2> ${tmpFile}
GATEWAY=`cat ${tmpFile}`
#
# Get the machine's netmask.
#
title="<C> </B>Enter Netmask
Enter your netmask. More often than not this value will be
255.255.255.0 A defaulted value of 255.255.255.0 is already
filled in. If you want to erase it press control-x to erase
the field or hit the backspace or delete key to erase
portions of the field.
"
plate="###.###.###.###"
overlay="</B/56>___.___.___.___"
${CDK_TEMPLATE} -d "2552552550" -p "${plate}" -o "${overlay}" -T "${title}" -m 10 -P -S 2> ${tmpFile}
NETMASK=`cat ${tmpFile}`
#
# Find out if the user will be accessing a domain name server.
#
message="<C> </B>Named Services
Will you be accessing a name server.
"
buttons="< Yes >
< No >"
${CDK_DIALOG} -m "${message}" -B "${buttons}" -S 2> /dev/null
answer=$?
#
# If they answered yes, get the IP address.
#
if [ "$answer" -eq 0 ]; then
#
# Get the machine's domain name server address.
#
title="<C> </B>Enter DNS Address
Enter the address of the domain name server (DNS) which you want to
use. The value of the DNS server has been filled in with the
gateway address you provided. If you want to erase it press
control-x to erase the field or hit the backspace or delete key
to erase portions of the field.
"
tmp=`echo ${GATEWAY} | sed 's/\.//g'`
plate="###.###.###.###"
overlay="</B/56>___.___.___.___"
${CDK_TEMPLATE} -d "${tmp}" -p "${plate}" -o "${overlay}" -T "${title}" -m 10 -P -S 2> ${tmpFile}
NAMESERVER=`cat ${tmpFile}`
fi
}
#
# Call the functions needed.
#
#########################################
# Create the hosts file.
#
cat << EOF > ${tmpFile}
#
# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server. Just add the names, addresses
# and any aliases to this file...
#
# By the way, Arnt Gulbrandsen <agulbra@nvg.unit.no> says that 127.0.0.1
# should NEVER be named with the name of the machine. It causes problems
# for some (stupid) programs, irc and reputedly talk. :^)
#
# For loopbacking.
127.0.0.1 localhost
$IP ${HOST}.${DOMAIN} ${HOST}
# End of hosts
EOF
copyFile ${tmpFile} "${HOSTS}" 644
echo "${HOST}.${DOMAIN}" > ${tmpFile}
copyFile ${tmpFile} ${HOSTNAME_FILE} 644
#########################################
# Create the resolv.conf file.
#
cat << EOF > ${tmpFile}
domain ${DOMAIN}
nameserver ${NAMESERVER}
EOF
copyFile ${tmpFile} "${RESOLV}" 644
#########################################
# Create the /etc/networks file.
#
cat << EOF > ${tmpFile}
#
# networks This file describes a number of netname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
#
loopback 127.0.0.0
localnet ${IP}
# End of networks.
EOF
copyFile ${tmpFile} "${NETWORKS}" 644
#########################################
# Create the /etc/rc.d/inet1 file.
#
cat << EOF > ${tmpFile}
#! /bin/sh
#
# rc.inet1 This shell script boots up the base INET system.
#
# Version: @(#)/etc/rc.d/rc.inet1 1.01 05/27/93
#
HOSTNAME=\`cat /etc/HOSTNAME\`
# Attach the loopback device.
${IFCONFIG} lo 127.0.0.1
${ROUTE} add -net 127.0.0.0
# IF YOU HAVE AN ETHERNET CONNECTION, use these lines below to configure the
# eth0 interface. If you're only using loopback or SLIP, don't include the
# rest of the lines in this file.
# Edit for your setup.
IPADDR="$IP" # REPLACE with YOUR IP address!
NETMASK="$NETMASK" # REPLACE with YOUR netmask!
NETWORK="$NETWORK" # REPLACE with YOUR network address!
BROADCAST="$BROADCAST" # REPLACE with YOUR broadcast address, if you
# have one. If not, leave blank and edit below.
GATEWAY="$GATEWAY" # REPLACE with YOUR gateway address!
# Uncomment the line below to configure your ethernet card.
${IFCONFIG} eth0 \${IP} broadcast \${BROADCAST} netmask \${NETMASK}
# If the line above is uncommented, the code below can also be uncommented.
# It sees if the ethernet was properly initialized, and gives the admin some
# hints about what to do if it wasn't.
if [ ! \$? = 0 ]; then
cat << END
Your ethernet card was not initialized properly. Here are some reasons why this
may have happened, and the solutions:
1. Your kernel does not contain support for your card. Including all the
network drivers in a Linux kernel can make it too large to even boot, and
sometimes including extra drivers can cause system hangs. To support your
ethernet, either edit /etc/rc.d/rc.modules to load the support at boottime,
or compile and install a kernel that contains support.
2. You don't have an ethernet card, in which case you should comment out this
section of /etc/rc.d/rc.inet1. (Unless you don't mind seeing this error...)
END
fi
# Uncomment these to set up your IP routing table.
${ROUTE} add -net \${NETWORK} netmask \${NETMASK}
${ROUTE} add default gw \${GATEWAY} metric 1
# End of rc.inet1
EOF
copyFile ${tmpFile} "${INET}" 755
#
# Spit out the 'we are done' message.
#
message="<C></B>Network Setup Complete
Your network software has now been configured. You may
rerun this program to reconfigure or you may edit the
respective system files."
buttons="< OK >"
${CDK_DIALOG} -m "${message}" -B "${buttons}" -S 2> /dev/null
#
# Clean up
#
rm -f ${tmpFile}

1462
deps/cdk-5.0-20161210/config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

1825
deps/cdk-5.0-20161210/config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

18776
deps/cdk-5.0-20161210/configure vendored Executable file

File diff suppressed because it is too large Load Diff

225
deps/cdk-5.0-20161210/configure.in vendored Normal file
View File

@ -0,0 +1,225 @@
dnl $Id: configure.in,v 1.75 2013/07/27 21:36:37 tom Exp $
dnl Process this file with autoconf to produce a configure script for CDK.
dnl ---------------------------------------------------------------------------
dnl Copyright 1999-2012,2013 Thomas E. Dickey
dnl
dnl Permission is hereby granted, free of charge, to any person obtaining a
dnl copy of this software and associated documentation files (the "Software"),
dnl to deal in the Software without restriction, including without limitation
dnl the rights to use, copy, modify, merge, publish, distribute, distribute
dnl with modifications, sublicense, and/or sell copies of the Software, and to
dnl permit persons to whom the Software is furnished to do so, subject to the
dnl following conditions:
dnl
dnl The above copyright notice and this permission notice shall be included in
dnl all copies or substantial portions of the Software.
dnl
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
dnl THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
dnl DEALINGS IN THE SOFTWARE.
dnl
dnl Except as contained in this notice, the name(s) of the above copyright
dnl holders shall not be used in advertising or otherwise to promote the sale,
dnl use or other dealings in this Software without prior written
dnl authorization.
dnl ---------------------------------------------------------------------------
AC_INIT(include/cdk.h)
AC_CONFIG_HEADER(include/cdk_config.h:include/config.hin)
CF_CHECK_CACHE
CF_VERSION_INFO(cdk)
CF_TOP_BUILDDIR(.)
dnl
dnl Checks for programs.
dnl
CF_PROG_CC
AC_PROG_CPP
AC_PROG_RANLIB
AC_PROG_INSTALL
CF_PROG_LN_S
CF_PROG_LINT
dnl needed for CF_WITH_LIBTOOL
AC_CHECK_TOOL(AR, ar, ar)
AC_PROG_MAKE_SET
CF_MAKEFLAGS
CF_MAKE_TAGS
CF_XOPEN_SOURCE
CF_DISABLE_ECHO
CF_PROG_EXT
CF_LIB_PREFIX
AC_ARG_WITH(man-section,
[ --with-man-section=XXX change manpage section (default 3)],
[MANSECT=$with_man_section],
[MANSECT=3])
case .$MANSECT in
.yes|.no)
MANSECT=3
;;
esac
MAN_TAG=`echo $MANSECT | sed -e 's/^\(.\).*/\1/'`
AC_SUBST(MAN_TAG)
AC_SUBST(MANSECT)
CF_WITH_CURSES_DIR
CF_WITH_WARNINGS
CF_PKG_CONFIG
CF_ENABLE_RPATH
CF_DISABLE_RPATH_HACK
CF_WITH_SHARED_OR_LIBTOOL(CDK,${VERSION_MAJOR}.${VERSION_MINOR},`echo "$VERSION" |sed -e 's/:/./g'`)
dnl
dnl Checks for libraries.
dnl
CF_DISABLE_LEAKS
dnl
dnl Checks for header files.
dnl
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS(\
limits.h \
unistd.h \
pwd.h \
grp.h \
)
dnl
dnl Checks for typedefs, structures, and compiler characteristics.
dnl
AC_TYPE_MODE_T
AC_STRUCT_TM
CF_CURSES_CHTYPE
CF_GETOPT_HEADER
dnl
dnl Checks for library functions.
dnl
AC_CHECK_FUNCS(\
getcwd \
mktime \
strdup \
strerror \
getlogin \
sleep \
)
CF_FUNC_LSTAT
CF_LOCALE([AC_DEFINE(HAVE_SETLOCALE,1,[Define to 1 if we have setlocale function])])
dnl Check for curses libraries last, since XCurses has dependencies which
dnl break the checks for other functions.
CF_WITH_NCURSES_ETC
CFG_ROOTNAME=cdk
HDR_ROOTNAME=cdk
LIB_ROOTNAME=cdk
case $cf_cv_screen in #(vi
ncurses) #(vi
;;
ncursesw)
LIB_ROOTNAME=cdkw
;;
pdcurses) #(vi
LIB_ROOTNAME=cdkX
;;
esac
AC_MSG_CHECKING(for XXX-config rootname)
AC_ARG_WITH(cfgname,
[ --with-cfgname=XXX override the XXX-config rootname],
[CFG_ROOTNAME=$withval])
AC_MSG_RESULT($CFG_ROOTNAME)
AC_SUBST(CFG_ROOTNAME)
AC_MSG_CHECKING(if cdk.h should be in header subdirectory)
AC_ARG_WITH(hdrname,
[ --enable-hdr-subdir install cdk.h in the header subdirectory],
[HDR_ROOTNAME=no])
AC_MSG_RESULT($HDR_SUBDIR)
AC_SUBST(HDR_SUBDIR)
if test "$HDR_SUBDIR" = yes
then
HDR_SUBDIR="#"
else
HDR_SUBDIR=
fi
AC_MSG_CHECKING(for header subdirectory)
AC_ARG_WITH(hdrname,
[ --with-hdrname=XXX override the header subdirectory],
[HDR_ROOTNAME=$withval])
AC_MSG_RESULT($HDR_ROOTNAME)
AC_SUBST(HDR_ROOTNAME)
AC_MSG_CHECKING(for library name)
AC_ARG_WITH(libname,
[ --with-libname=XXX override the library name],
[LIB_ROOTNAME=$withval])
AC_MSG_RESULT($LIB_ROOTNAME)
AC_SUBST(LIB_ROOTNAME)
AC_MSG_CHECKING(if improved const-typing should be used)
AC_ARG_ENABLE(const,
[ --enable-const use improved const-typing],
[CDK_CONST=$enableval],
[CDK_CONST=no])
AC_MSG_RESULT($CDK_CONST)
if test "$CDK_CONST" = yes
then
AC_DEFINE(CDK_CONST,const,[Define to const if improved const-typing should be used])
else
AC_DEFINE(CDK_CONST,/*nothing*/)
fi
# define these for casting convenience
AC_DEFINE(CDK_CSTRING,CDK_CONST char *,[Define to simplify casting CDK_CONST])
AC_DEFINE(CDK_CSTRING2,CDK_CONST char * CDK_CONST *,[Define to simplify casting CDK_CONST])
CF_CURSES_FUNCS(\
Xinitscr\
getbegx \
getbegy \
getmaxx \
getmaxy \
start_color \
\
)
CF_WITH_NC_ALLOC_H
CF_CURSES_SETBEGYX
CF__DEFINE_SHLIB_VARS
dnl
dnl Set pre-processor compile time variables.
dnl
AC_OUTPUT(
cdk-config
include/cdk_version.h:include/cdk_version.hin
Makefile
cli/Makefile
examples/Makefile
demos/Makefile,[
CF__ADD_SHLIB_RULES(
Makefile,
$LIB_MODEL,
[\${LIB_OBJECT}],
[\${LIBS} \${LDFLAGS}])
],[
CF__INIT_SHLIB_RULES
],sort)

53
deps/cdk-5.0-20161210/debug.c vendored Normal file
View File

@ -0,0 +1,53 @@
#include <cdk_int.h>
/*
* $Author: tom $
* $Date: 2012/03/20 21:58:33 $
* $Revision: 1.11 $
*/
FILE *CDKDEBUG;
/*
* This starts debugging for CDK.
*/
FILE *startCDKDebug (const char *filename)
{
const char *defFile = "cdkdebug.log";
/* Check if the filename is null. */
if (filename == 0)
{
filename = defFile;
}
/* Try to open the file. */
return (fopen (filename, "w"));
}
/*
* This writes a message to the debug file.
*/
void writeCDKDebugMessage (FILE * fd,
const char *filename,
const char *function,
int line, const char *message)
{
/* Print the message as long as the file pointer is not null. */
if (fd != 0)
{
fprintf (fd, "%s::%s (Line %d) %s\n", filename, function, line, message);
}
}
/*
* This turns off the debugging for CDK.
*/
void stopCDKDebug (FILE * fd)
{
if (fd != 0)
{
fclose (fd);
}
}

128
deps/cdk-5.0-20161210/demos/Makefile.in vendored Normal file
View File

@ -0,0 +1,128 @@
# $Id: Makefile.in,v 1.20 2013/07/19 23:55:03 tom Exp $
#
# Makefile for the demos directory.
#
SHELL = /bin/sh
prefix = @prefix@
exec_prefix = @exec_prefix@
srcdir = @srcdir@
VPATH = $(srcdir)
CC = @CC@
RM = rm -f
CTAGS = @CTAGS@
ETAGS = @ETAGS@
LINT = @LINT@
LINT_OPTS = @LINT_OPTS@
LIBS = -l@LIB_ROOTNAME@ @LIBS@
LIBTOOL = @LIBTOOL@ @ECHO_LT@
LIBTOOL_CLEAN = @LIB_CLEAN@
LIBTOOL_LINK = @LIB_LINK@
LINK = $(LIBTOOL_LINK)
x = @EXEEXT@
o = .@OBJEXT@
LOCAL_LIBDIR = @top_builddir@
CFLAGS = @CFLAGS@ @EXTRA_CFLAGS@
CPPFLAGS = @DEFS@ -I../include -I$(srcdir)/../include -I. @CPPFLAGS@
LDFLAGS = -L.. @LDFLAGS@ @LOCAL_LDFLAGS@
BINS = \
fileview$x \
rolodex$x \
command$x \
clock$x \
stopSign$x \
appointment$x \
vinstall$x
# this needs configure-script work:
OTHER_BINS = \
serial$x
CDKSRC = \
fileview.c \
rolodex.c \
command.c \
clock.c \
stopSign.c \
appointment.c \
vinstall.c \
serial.c
# If you have Sybase installed on your system, try making
# syb. It's a full screen interface to Sybase.
#
SYBROOT = $(SYBASE)
SYBINCDIR = -I$(SYBROOT)/include
SYBLIBDIR = -L$(SYBROOT)/devlib
SYBLIBS = -lnsl -lsybdb
all : $(BINS)
#
# Standard .c to .o compile line.
#
.c.o:
@RULE_CC@
@ECHO_CC@$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
#
# Most of the examples are built from a single .c file using the same libraries
#
LINKIT = @ECHO_LD@$(LINK) $(CFLAGS) $(CPPFLAGS) $? -o $@ $(LDFLAGS) $(LIBS)
# fileview - Basic file selector/file viewer combination.
fileview$x : fileview.o ; $(LINKIT)
# rolodex - A fairly robust rolodex.
rolodex$x : rolodex.o ; $(LINKIT)
# command - A basic command interface with command history.
command$x : command.o ; $(LINKIT)
# clock - A simple little clock.
clock$x : clock.o ; $(LINKIT)
# stopSign - A simple demo I wrote after a couple of pints. :)
stopSign$x : stopSign.o ; $(LINKIT)
# appointment - A basic appointment book/date keeper.
appointment$x : appointment.o ; $(LINKIT)
# serial - This probes the serial port.
serial$x : serial.o ; $(LINKIT)
# keycheck - This prints out the keys ASCII and Octal values.
keycheck$x : keycheck.o ; $(LINKIT)
# vinstall - CDK based installer.
vinstall$x : vinstall.o ; $(LINKIT)
#
# A Sybase interface.
#
syb$x : syb.c
$(CC) $(CFLAGS) -o $@ $? $(CPPFLAGS) $(SYBINCDIR) $(LDFLAGS) $(SYBLIBDIR) $(LIBS) $(SYBLIBS)
#
# Standard clean directives.
#
clean::
-$(LIBTOOL_CLEAN) $(RM) *.o core $(BINS) $(OTHER_BINS)
distclean:: clean
-rm -f Makefile
@MAKE_LOWER_TAGS@tags :
@MAKE_LOWER_TAGS@ $(CTAGS) *.[ch] */*.[ch]
@MAKE_LOWER_TAGS@TAGS :
@MAKE_LOWER_TAGS@ $(ETAGS) *.[ch] */*.[ch]
lint: $(CDKSRC)
$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(CDKSRC)

View File

@ -0,0 +1,524 @@
/* $Id: appointment.c,v 1.29 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "appointmentBook";
#endif
/*
* Create definitions.
*/
#define MAX_MARKERS 2000
/*
*
*/
static chtype GPAppointmentAttributes[] =
{
A_BLINK,
A_BOLD,
A_REVERSE,
A_UNDERLINE
};
/*
*
*/
typedef enum
{
vBirthday, vAnniversary, vAppointment, vOther
}
EAppointmentType;
/*
*
*/
struct AppointmentMarker
{
EAppointmentType type;
char *description;
int day;
int month;
int year;
};
/*
*
*/
struct AppointmentInfo
{
struct AppointmentMarker appointment[MAX_MARKERS];
int appointmentCount;
};
/*
* Declare local function prototypes.
*/
static BINDFN_PROTO (createCalendarMarkCB);
static BINDFN_PROTO (removeCalendarMarkCB);
static BINDFN_PROTO (displayCalendarMarkCB);
static BINDFN_PROTO (accelerateToDateCB);
void readAppointmentFile (char *filename, struct AppointmentInfo *appInfo);
void saveAppointmentFile (char *filename, struct AppointmentInfo *appInfo);
/*
* This program demonstrates the Cdk calendar widget.
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkscreen = 0;
CDKCALENDAR *calendar = 0;
const char *title = "<C></U>CDK Appointment Book\n<C><#HL(30)>\n";
char *filename = 0;
struct tm *dateInfo = 0;
time_t clck = 0;
struct AppointmentInfo appointmentInfo;
int day, month, year, x;
/*
* Get the current dates and set the default values for
* the day/month/year values for the calendar.
*/
/* *INDENT-EQLS* */
time (&clck);
dateInfo = gmtime (&clck);
day = dateInfo->tm_mday;
month = dateInfo->tm_mon + 1;
year = dateInfo->tm_year + 1900;
/* Check the command line for options. */
while (1)
{
int ret;
/* Are there any more command line options to parse. */
if ((ret = getopt (argc, argv, "d:m:y:t:f:")) == -1)
{
break;
}
switch (ret)
{
case 'd':
day = atoi (optarg);
break;
case 'm':
month = atoi (optarg);
break;
case 'y':
year = atoi (optarg);
break;
case 't':
title = copyChar (optarg);
break;
case 'f':
filename = copyChar (optarg);
break;
}
}
/* Create the appointment book filename. */
if (filename == 0)
{
char temp[1000];
char *home = getenv ("HOME");
if (home != 0)
{
sprintf (temp, "%.*s/.appointment", (int)sizeof (temp) - 20, home);
}
else
{
strcpy (temp, ".appointment");
}
filename = copyChar (temp);
}
/* Read the appointment book information. */
readAppointmentFile (filename, &appointmentInfo);
cdkscreen = initCDKScreen (NULL);
/* Start CDK Colors. */
initCDKColor ();
/* Create the calendar widget. */
calendar = newCDKCalendar (cdkscreen, CENTER, CENTER,
title, day, month, year,
A_NORMAL, A_NORMAL,
A_NORMAL, A_REVERSE,
TRUE, FALSE);
/* Is the widget null? */
if (calendar == 0)
{
/* Clean up the memory. */
destroyCDKScreen (cdkscreen);
/* End curses... */
endCDK ();
/* Spit out a message. */
printf ("Cannot create the calendar. Is the window too small?\n");
ExitProgram (EXIT_FAILURE);
}
/* Create a key binding to mark days on the calendar. */
bindCDKObject (vCALENDAR, calendar, 'm', createCalendarMarkCB, &appointmentInfo);
bindCDKObject (vCALENDAR, calendar, 'M', createCalendarMarkCB, &appointmentInfo);
bindCDKObject (vCALENDAR, calendar, 'r', removeCalendarMarkCB, &appointmentInfo);
bindCDKObject (vCALENDAR, calendar, 'R', removeCalendarMarkCB, &appointmentInfo);
bindCDKObject (vCALENDAR, calendar, '?', displayCalendarMarkCB, &appointmentInfo);
bindCDKObject (vCALENDAR, calendar, 'j', accelerateToDateCB, &appointmentInfo);
bindCDKObject (vCALENDAR, calendar, 'J', accelerateToDateCB, &appointmentInfo);
/* Set all the appointments read from the file. */
for (x = 0; x < appointmentInfo.appointmentCount; x++)
{
chtype marker = GPAppointmentAttributes[appointmentInfo.appointment[x].type];
setCDKCalendarMarker (calendar,
appointmentInfo.appointment[x].day,
appointmentInfo.appointment[x].month,
appointmentInfo.appointment[x].year,
marker);
}
/* Draw the calendar widget. */
drawCDKCalendar (calendar, ObjOf (calendar)->box);
/* Let the user play with the widget. */
activateCDKCalendar (calendar, 0);
/* Save the appointment information. */
saveAppointmentFile (filename, &appointmentInfo);
free (filename);
/* Clean up and exit. */
destroyCDKCalendar (calendar);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}
/*
* This reads a given appointment file.
*/
void readAppointmentFile (char *filename, struct AppointmentInfo *appInfo)
{
/* *INDENT-EQLS* */
int appointments = 0;
int linesRead = 0;
char **lines = 0;
int x;
/* Read the appointment file. */
linesRead = CDKreadFile (filename, &lines);
if (linesRead == -1)
{
appInfo->appointmentCount = 0;
return;
}
/* Split each line up and create an appointment. */
for (x = 0; x < linesRead; x++)
{
char **temp = CDKsplitString (lines[x], CTRL ('V'));
int segments = (int)CDKcountStrings ((CDK_CSTRING2)temp);
/*
* A valid line has 5 elements:
* Day, Month, Year, Type, Description.
*/
if (segments == 5)
{
int eType = atoi (temp[3]);
/* *INDENT-EQLS* */
appInfo->appointment[appointments].day = atoi (temp[0]);
appInfo->appointment[appointments].month = atoi (temp[1]);
appInfo->appointment[appointments].year = atoi (temp[2]);
appInfo->appointment[appointments].type = (EAppointmentType) eType;
appInfo->appointment[appointments].description = copyChar (temp[4]);
appointments++;
}
CDKfreeStrings (temp);
}
CDKfreeStrings (lines);
/* Keep the amount of appointments read. */
appInfo->appointmentCount = appointments;
}
/*
* This saves a given appointment file.
*/
void saveAppointmentFile (char *filename, struct AppointmentInfo *appInfo)
{
/* Declare local variables. */
FILE *fd;
int x;
/* Can we open the file? */
if ((fd = fopen (filename, "w")) == 0)
{
return;
}
/* Start writing. */
for (x = 0; x < appInfo->appointmentCount; x++)
{
if (appInfo->appointment[x].description != 0)
{
fprintf (fd, "%d%c%d%c%d%c%d%c%s\n",
appInfo->appointment[x].day, CTRL ('V'),
appInfo->appointment[x].month, CTRL ('V'),
appInfo->appointment[x].year, CTRL ('V'),
(int)appInfo->appointment[x].type, CTRL ('V'),
appInfo->appointment[x].description);
freeChar (appInfo->appointment[x].description);
}
}
fclose (fd);
}
/*
* This adds a marker to the calendar.
*/
static int createCalendarMarkCB (EObjectType objectType GCC_UNUSED, void *object,
void *clientData,
chtype key GCC_UNUSED)
{
/* *INDENT-EQLS* */
CDKCALENDAR *calendar = (CDKCALENDAR *)object;
CDKENTRY *entry = 0;
CDKITEMLIST *itemlist = 0;
const char *items[] =
{
"Birthday",
"Anniversary",
"Appointment",
"Other"
};
char *description = 0;
struct AppointmentInfo *appointmentInfo = (struct AppointmentInfo *)clientData;
int current = appointmentInfo->appointmentCount;
chtype marker;
int selection;
/* Create the itemlist widget. */
itemlist = newCDKItemlist (ScreenOf (calendar),
CENTER, CENTER, 0,
"Select Appointment Type: ",
(CDK_CSTRING2)items, 4, 0,
TRUE, FALSE);
/* Get the appointment tye from the user. */
selection = activateCDKItemlist (itemlist, 0);
/* They hit escape, kill the itemlist widget and leave. */
if (selection == -1)
{
destroyCDKItemlist (itemlist);
drawCDKCalendar (calendar, ObjOf (calendar)->box);
return (FALSE);
}
/* Destroy the itemlist and set the marker. */
destroyCDKItemlist (itemlist);
drawCDKCalendar (calendar, ObjOf (calendar)->box);
marker = GPAppointmentAttributes[selection];
/* Create the entry field for the description. */
entry = newCDKEntry (ScreenOf (calendar),
CENTER, CENTER,
"<C>Enter a description of the appointment.",
"Description: ",
A_NORMAL, (chtype)'.',
vMIXED, 40, 1, 512,
TRUE, FALSE);
/* Get the description. */
description = activateCDKEntry (entry, 0);
if (description == 0)
{
destroyCDKEntry (entry);
drawCDKCalendar (calendar, ObjOf (calendar)->box);
return (FALSE);
}
/* Destroy the entry and set the marker. */
description = copyChar (entry->info);
destroyCDKEntry (entry);
drawCDKCalendar (calendar, ObjOf (calendar)->box);
/* Set the marker. */
setCDKCalendarMarker (calendar,
calendar->day,
calendar->month,
calendar->year,
marker);
/* Keep the marker. */
appointmentInfo->appointment[current].day = calendar->day;
appointmentInfo->appointment[current].month = calendar->month;
appointmentInfo->appointment[current].year = calendar->year;
appointmentInfo->appointment[current].type = (EAppointmentType) selection;
appointmentInfo->appointment[current].description = description;
appointmentInfo->appointmentCount++;
/* Redraw the calendar. */
drawCDKCalendar (calendar, ObjOf (calendar)->box);
return (FALSE);
}
/*
* This removes a marker from the calendar.
*/
static int removeCalendarMarkCB (EObjectType objectType GCC_UNUSED, void
*object, void *clientData, chtype key GCC_UNUSED)
{
CDKCALENDAR *calendar = (CDKCALENDAR *)object;
struct AppointmentInfo *appointmentInfo = (struct AppointmentInfo *)clientData;
int x;
/* Look for the marker in the list. */
for (x = 0; x < appointmentInfo->appointmentCount; x++)
{
if ((appointmentInfo->appointment[x].day == calendar->day) &&
(appointmentInfo->appointment[x].month == calendar->month) &&
(appointmentInfo->appointment[x].year == calendar->year))
{
freeChar (appointmentInfo->appointment[x].description);
appointmentInfo->appointment[x].description = 0;
break;
}
}
/* Remove the marker from the calendar. */
removeCDKCalendarMarker (calendar,
calendar->day,
calendar->month,
calendar->year);
/* Redraw the calendar. */
drawCDKCalendar (calendar, ObjOf (calendar)->box);
return (FALSE);
}
/*
* This displays the marker(s) on the given day.
*/
static int displayCalendarMarkCB (EObjectType objectType GCC_UNUSED, void
*object, void *clientData, chtype key GCC_UNUSED)
{
/* *INDENT-EQLS* */
CDKCALENDAR *calendar = (CDKCALENDAR *)object;
CDKLABEL *label = 0;
struct AppointmentInfo *appointmentInfo = (struct AppointmentInfo *)clientData;
int found = 0;
int mesgLines = 0;
const char *type = 0;
char *mesg[10], temp[256];
int x;
/* Look for the marker in the list. */
for (x = 0; x < appointmentInfo->appointmentCount; x++)
{
/* Get the day month year. */
/* *INDENT-EQLS* */
int day = appointmentInfo->appointment[x].day;
int month = appointmentInfo->appointment[x].month;
int year = appointmentInfo->appointment[x].year;
/* Determine the appointment type. */
if (appointmentInfo->appointment[x].type == vBirthday)
{
type = "Birthday";
}
else if (appointmentInfo->appointment[x].type == vAnniversary)
{
type = "Anniversary";
}
else if (appointmentInfo->appointment[x].type == vAppointment)
{
type = "Appointment";
}
else
{
type = "Other";
}
/* Find the marker by the day/month/year. */
if ((day == calendar->day) &&
(month == calendar->month) &&
(year == calendar->year) &&
(appointmentInfo->appointment[x].description != 0))
{
/* Create the message for the label widget. */
sprintf (temp, "<C>Appointment Date: %02d/%02d/%d", day, month, year);
mesg[mesgLines++] = copyChar (temp);
mesg[mesgLines++] = copyChar (" ");
mesg[mesgLines++] = copyChar ("<C><#HL(35)>");
sprintf (temp, " Appointment Type: %s", type);
mesg[mesgLines++] = copyChar (temp);
mesg[mesgLines++] = copyChar (" Description :");
sprintf (temp, " %s", appointmentInfo->appointment[x].description);
mesg[mesgLines++] = copyChar (temp);
mesg[mesgLines++] = copyChar ("<C><#HL(35)>");
mesg[mesgLines++] = copyChar (" ");
mesg[mesgLines++] = copyChar ("<C>Press space to continue.");
found = 1;
break;
}
}
/* If we didn't find the marker, create a different message. */
if (found == 0)
{
sprintf (temp, "<C>There is no appointment for %02d/%02d/%d",
calendar->day, calendar->month, calendar->year);
mesg[mesgLines++] = copyChar (temp);
mesg[mesgLines++] = copyChar ("<C><#HL(30)>");
mesg[mesgLines++] = copyChar ("<C>Press space to continue.");
}
/* Create the label widget. */
label = newCDKLabel (ScreenOf (calendar), CENTER, CENTER,
(CDK_CSTRING2)mesg, mesgLines, TRUE, FALSE);
drawCDKLabel (label, ObjOf (label)->box);
waitCDKLabel (label, ' ');
destroyCDKLabel (label);
/* Clean up the memory used. */
for (x = 0; x < mesgLines; x++)
{
freeChar (mesg[x]);
}
/* Redraw the calendar widget. */
drawCDKCalendar (calendar, ObjOf (calendar)->box);
return (FALSE);
}
/*
* This allows the user to accelerate to a given date.
*/
static int accelerateToDateCB (EObjectType objectType GCC_UNUSED, void
*object GCC_UNUSED, void *clientData
GCC_UNUSED, chtype key GCC_UNUSED)
{
return (FALSE);
}

90
deps/cdk-5.0-20161210/demos/clock.c vendored Normal file
View File

@ -0,0 +1,90 @@
/* $Id: clock.c,v 1.11 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "label_ex";
#endif
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkscreen = 0;
CDKLABEL *demo = 0;
int boxLabel = 0;
const char *mesg[4];
char temp[256];
time_t clck;
int ret;
/* Parse up the command line. */
while ((ret = getopt (argc, argv, "b")) != -1)
{
switch (ret)
{
case 'b':
boxLabel = 1;
}
}
cdkscreen = initCDKScreen (NULL);
/* Start CDK Colors */
initCDKColor ();
/* Set the labels up. */
mesg[0] = "</1/B>HH:MM:SS";
/* Declare the labels. */
demo = newCDKLabel (cdkscreen, CENTER, CENTER,
(CDK_CSTRING2)mesg, 1,
boxLabel, FALSE);
/* Is the label null??? */
if (demo == 0)
{
/* Clean up the memory. */
destroyCDKScreen (cdkscreen);
/* End curses... */
endCDK ();
printf ("Cannot create the label. Is the window too small?\n");
ExitProgram (EXIT_FAILURE);
}
curs_set (0);
wtimeout (WindowOf (demo), 50);
/* Do this for-a-while... */
do
{
struct tm *currentTime;
/* Get the current time. */
time (&clck);
currentTime = localtime (&clck);
/* Put the current time in a string. */
sprintf (temp, "<C></B/29>%02d:%02d:%02d",
currentTime->tm_hour,
currentTime->tm_min,
currentTime->tm_sec);
mesg[0] = copyChar (temp);
/* Set the label contents. */
setCDKLabel (demo, (CDK_CSTRING2)mesg, 1, ObjOf (demo)->box);
/* Draw the label, and sleep. */
drawCDKLabel (demo, ObjOf (demo)->box);
napms (500);
}
while (wgetch (WindowOf (demo)) == ERR);
/* Clean up */
destroyCDKLabel (demo);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}

446
deps/cdk-5.0-20161210/demos/command.c vendored Normal file
View File

@ -0,0 +1,446 @@
/* $Id: command.c,v 1.22 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "command";
#endif
/* Define some global variables. */
#define MAXHISTORY 5000
static const char *introductionMessage[] =
{
"<C></B/16>Little Command Interface", "",
"<C>Written by Mike Glover", "",
"<C>Type </B>help<!B> to get help."};
/* This structure is used for keeping command history. */
struct history_st
{
int count;
int current;
char *command[MAXHISTORY];
};
/* Define some local prototypes. */
char *uc (char *word);
void help (CDKENTRY *entry);
static BINDFN_PROTO (historyUpCB);
static BINDFN_PROTO (historyDownCB);
static BINDFN_PROTO (viewHistoryCB);
static BINDFN_PROTO (listHistoryCB);
static BINDFN_PROTO (jumpWindowCB);
/*
* Written by: Mike Glover
* Purpose:
* This creates a very simple command interface.
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkscreen = 0;
CDKSWINDOW *commandOutput = 0;
CDKENTRY *commandEntry = 0;
chtype *convert = 0;
const char *prompt = "</B/24>Command >";
const char *title = "<C></B/5>Command Output Window";
int promptLen = 0;
int commandFieldWidth = 0;
struct history_st history;
char temp[600];
int junk;
/* Set up the history. */
history.current = 0;
history.count = 0;
/* Check the command line for options. */
while (1)
{
int ret;
/* Are there any more command line options to parse. */
if ((ret = getopt (argc, argv, "t:p:")) == -1)
{
break;
}
switch (ret)
{
case 'p':
prompt = copyChar (optarg);
break;
case 't':
title = copyChar (optarg);
break;
default:
break;
}
}
cdkscreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Create the scrolling window. */
commandOutput = newCDKSwindow (cdkscreen, CENTER, TOP, -8, -2,
title, 1000, TRUE, FALSE);
/* Convert the prompt to a chtype and determine its length. */
convert = char2Chtype (prompt, &promptLen, &junk);
commandFieldWidth = COLS - promptLen - 4;
freeChtype (convert);
/* Create the entry field. */
commandEntry = newCDKEntry (cdkscreen, CENTER, BOTTOM,
0, prompt,
A_BOLD | COLOR_PAIR (8),
COLOR_PAIR (24) | '_',
vMIXED, commandFieldWidth, 1, 512, FALSE, FALSE);
/* Create the key bindings. */
bindCDKObject (vENTRY, commandEntry, KEY_UP, historyUpCB, &history);
bindCDKObject (vENTRY, commandEntry, KEY_DOWN, historyDownCB, &history);
bindCDKObject (vENTRY, commandEntry, KEY_TAB, viewHistoryCB, commandOutput);
bindCDKObject (vENTRY, commandEntry, CTRL ('^'), listHistoryCB, &history);
bindCDKObject (vENTRY, commandEntry, CTRL ('G'), jumpWindowCB, commandOutput);
/* Draw the screen. */
refreshCDKScreen (cdkscreen);
/* Show them who wrote this and how to get help. */
popupLabel (cdkscreen, (CDK_CSTRING2)introductionMessage, 5);
eraseCDKEntry (commandEntry);
/* Do this forever. */
for (;;)
{
char *command = 0;
char *upper;
/* Get the command. */
drawCDKEntry (commandEntry, ObjOf (commandEntry)->box);
command = activateCDKEntry (commandEntry, 0);
upper = uc (command);
/* Check the output of the command. */
if (strcmp (upper, "QUIT") == 0 ||
strcmp (upper, "EXIT") == 0 ||
strcmp (upper, "Q") == 0 ||
strcmp (upper, "E") == 0 ||
commandEntry->exitType == vESCAPE_HIT)
{
/* All done. */
freeChar (upper);
while (history.count-- > 0)
free (history.command[history.count]);
destroyCDKEntry (commandEntry);
destroyCDKSwindow (commandOutput);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}
else if (strcmp (command, "clear") == 0)
{
/* Keep the history. */
history.command[history.count] = copyChar (command);
history.count++;
history.current = history.count;
cleanCDKSwindow (commandOutput);
cleanCDKEntry (commandEntry);
}
else if (strcmp (command, "history") == 0)
{
/* Display the history list. */
listHistoryCB (vENTRY, commandEntry, &history, 0);
/* Keep the history. */
history.command[history.count] = copyChar (command);
history.count++;
history.current = history.count;
}
else if (strcmp (command, "help") == 0)
{
/* Keep the history. */
history.command[history.count] = copyChar (command);
history.count++;
history.current = history.count;
/* Display the help. */
help (commandEntry);
/* Clean the entry field. */
cleanCDKEntry (commandEntry);
eraseCDKEntry (commandEntry);
}
else
{
/* Keep the history. */
history.command[history.count] = copyChar (command);
history.count++;
history.current = history.count;
/* Jump to the bottom of the scrolling window. */
jumpToLineCDKSwindow (commandOutput, BOTTOM);
/* Insert a line providing the command. */
sprintf (temp, "Command: </R>%s", command);
addCDKSwindow (commandOutput, temp, BOTTOM);
/* Run the command. */
execCDKSwindow (commandOutput, command, BOTTOM);
/* Clean out the entry field. */
cleanCDKEntry (commandEntry);
}
/* Clean up a little. */
freeChar (upper);
}
}
/*
* This is the callback for the down arrow.
*/
static int historyUpCB (EObjectType cdktype GCC_UNUSED, void *object,
void *clientData,
chtype key GCC_UNUSED)
{
CDKENTRY *entry = (CDKENTRY *)object;
struct history_st *history = (struct history_st *)clientData;
/* Make sure we don't go out of bounds. */
if (history->current == 0)
{
Beep ();
return (FALSE);
}
/* Decrement the counter. */
history->current--;
/* Display the command. */
setCDKEntryValue (entry, history->command[history->current]);
drawCDKEntry (entry, ObjOf (entry)->box);
return (FALSE);
}
/*
* This is the callback for the down arrow.
*/
static int historyDownCB (EObjectType cdktype GCC_UNUSED, void *object,
void *clientData,
chtype key GCC_UNUSED)
{
CDKENTRY *entry = (CDKENTRY *)object;
struct history_st *history = (struct history_st *)clientData;
/* Make sure we don't go out of bounds. */
if (history->current == history->count)
{
Beep ();
return (FALSE);
}
/* Increment the counter... */
history->current++;
/* If we are at the end, clear the entry field. */
if (history->current == history->count)
{
cleanCDKEntry (entry);
drawCDKEntry (entry, ObjOf (entry)->box);
return (FALSE);
}
/* Display the command. */
setCDKEntryValue (entry, history->command[history->current]);
drawCDKEntry (entry, ObjOf (entry)->box);
return (FALSE);
}
/*
* This callback allows the user to play with the scrolling window.
*/
static int viewHistoryCB (EObjectType cdktype GCC_UNUSED, void *object,
void *clientData,
chtype key GCC_UNUSED)
{
CDKSWINDOW *swindow = (CDKSWINDOW *)clientData;
CDKENTRY *entry = (CDKENTRY *)object;
/* Let them play... */
activateCDKSwindow (swindow, 0);
/* Redraw the entry field. */
drawCDKEntry (entry, ObjOf (entry)->box);
return (FALSE);
}
/*
* This callback jumps to a line in the scrolling window.
*/
static int jumpWindowCB (EObjectType cdktype GCC_UNUSED, void *object,
void *clientData,
chtype key GCC_UNUSED)
{
CDKENTRY *entry = (CDKENTRY *)object;
CDKSWINDOW *swindow = (CDKSWINDOW *)clientData;
CDKSCALE *scale = 0;
int line;
/* Ask them which line they want to jump to. */
scale = newCDKScale (ScreenOf (entry), CENTER, CENTER,
"<C>Jump To Which Line",
"Line",
A_NORMAL, 5,
0, 0, swindow->listSize, 1, 2, TRUE, FALSE);
/* Get the line. */
line = activateCDKScale (scale, 0);
/* Clean up. */
destroyCDKScale (scale);
/* Jump to the line. */
jumpToLineCDKSwindow (swindow, line);
/* Redraw the widgets. */
drawCDKEntry (entry, ObjOf (entry)->box);
return (FALSE);
}
/*
* This callback allows the user to pick from the history list from a
* scrolling list.
*/
static int listHistoryCB (EObjectType cdktype GCC_UNUSED, void *object,
void *clientData,
chtype key GCC_UNUSED)
{
CDKENTRY *entry = (CDKENTRY *)object;
struct history_st *history = (struct history_st *)clientData;
CDKSCROLL *scrollList;
int height = (history->count < 10 ? history->count + 3 : 13);
int selection;
/* No history, no list. */
if (history->count == 0)
{
/* Popup a little window telling the user there are no commands. */
const char *mesg[] =
{
"<C></B/16>No Commands Entered",
"<C>No History"
};
popupLabel (ScreenOf (entry), (CDK_CSTRING2)mesg, 2);
/* Redraw the screen. */
eraseCDKEntry (entry);
drawCDKScreen (ScreenOf (entry));
/* And leave... */
return (FALSE);
}
/* Create the scrolling list of previous commands. */
scrollList = newCDKScroll (ScreenOf (entry), CENTER, CENTER, RIGHT,
height, 20, "<C></B/29>Command History",
(CDK_CSTRING2)history->command,
history->count,
NUMBERS, A_REVERSE, TRUE, FALSE);
/* Get the command to execute. */
selection = activateCDKScroll (scrollList, 0);
destroyCDKScroll (scrollList);
/* Check the results of the selection. */
if (selection >= 0)
{
/* Get the command and stick it back in the entry field. */
setCDKEntryValue (entry, history->command[selection]);
}
/* Redraw the screen. */
eraseCDKEntry (entry);
drawCDKScreen (ScreenOf (entry));
return (FALSE);
}
/*
* This function displays help.
*/
void help (CDKENTRY *entry)
{
const char *mesg[25];
/* Create the help message. */
mesg[0] = "<C></B/29>Help";
mesg[1] = "";
mesg[2] = "</B/24>When in the command line.";
mesg[3] = "<B=history > Displays the command history.";
mesg[4] = "<B=Ctrl-^ > Displays the command history.";
mesg[5] = "<B=Up Arrow > Scrolls back one command.";
mesg[6] = "<B=Down Arrow> Scrolls forward one command.";
mesg[7] = "<B=Tab > Activates the scrolling window.";
mesg[8] = "<B=help > Displays this help window.";
mesg[9] = "";
mesg[10] = "</B/24>When in the scrolling window.";
mesg[11] = "<B=l or L > Loads a file into the window.";
mesg[12] = "<B=s or S > Saves the contents of the window to a file.";
mesg[13] = "<B=Up Arrow > Scrolls up one line.";
mesg[14] = "<B=Down Arrow> Scrolls down one line.";
mesg[15] = "<B=Page Up > Scrolls back one page.";
mesg[16] = "<B=Page Down > Scrolls forward one page.";
mesg[17] = "<B=Tab/Escape> Returns to the command line.";
mesg[18] = "";
mesg[19] = "<C> (</B/24>Refer to the scrolling window online manual for more help<!B!24>.)";
popupLabel (ScreenOf (entry), (CDK_CSTRING2)mesg, 20);
}
/*
* This converts a word to upper case.
*/
char *uc (char *word)
{
char *upper = 0;
int length = 0;
int x;
/* Make sure the word is not null. */
if (word == 0)
{
return 0;
}
length = (int)strlen (word);
/* Get the memory for the new word. */
upper = (char *)malloc (sizeof (char) * (size_t) (length + 2));
if (upper == 0)
{
return (word);
}
/* Start converting the case. */
for (x = 0; x < length; x++)
{
int ch = (unsigned char)(word[x]);
if (isalpha (ch))
{
upper[x] = (char)toupper (ch);
}
else
{
upper[x] = word[x];
}
}
upper[length] = '\0';
return upper;
}

159
deps/cdk-5.0-20161210/demos/fileview.c vendored Normal file
View File

@ -0,0 +1,159 @@
/* $Id: fileview.c,v 1.14 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "codeViewer";
#endif
/*
* This program demonstrates the file selector and the viewer widget.
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkscreen = 0;
CDKVIEWER *example = 0;
CDKFSELECT *fSelect = 0;
const char *directory = ".";
char *filename = 0;
char **info = 0;
const char *button[5];
const char *mesg[4];
char vtitle[256];
char temp[256];
int selected, lines;
/* Parse up the command line. */
while (1)
{
int ret = getopt (argc, argv, "d:f:");
if (ret == -1)
{
break;
}
switch (ret)
{
case 'd':
directory = strdup (optarg);
break;
case 'f':
filename = strdup (optarg);
break;
}
}
/* Create the viewer buttons. */
button[0] = "</5><OK><!5>";
button[1] = "</5><Cancel><!5>";
cdkscreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Get the filename. */
if (filename == 0)
{
const char *title = "<C>Pick a file.";
const char *label = "File: ";
fSelect = newCDKFselect (cdkscreen, CENTER, CENTER, 20, 65,
title, label, A_NORMAL, '_', A_REVERSE,
"</5>", "</48>", "</N>", "</N>", TRUE, FALSE);
/*
* Set the starting directory. This is not neccessary because when
* the file selector starts it uses the present directory as a default.
*/
setCDKFselect (fSelect, directory, A_NORMAL, '.', A_REVERSE,
"</5>", "</48>", "</N>", "</N>", ObjOf (fSelect)->box);
/* Activate the file selector. */
filename = copyChar (activateCDKFselect (fSelect, 0));
/* Check how the person exited from the widget. */
if (fSelect->exitType == vESCAPE_HIT)
{
/* Pop up a message for the user. */
mesg[0] = "<C>Escape hit. No file selected.";
mesg[1] = "";
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
/* Destroy the file selector. */
destroyCDKFselect (fSelect);
/* Exit CDK. */
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}
}
/* Destroy the file selector. */
destroyCDKFselect (fSelect);
/* Create the file viewer to view the file selected. */
example = newCDKViewer (cdkscreen, CENTER, CENTER, 20, -2,
(CDK_CSTRING2)button, 2,
A_REVERSE, TRUE, FALSE);
/* Could we create the viewer widget? */
if (example == 0)
{
/* Exit CDK. */
destroyCDKScreen (cdkscreen);
endCDK ();
/* Print out a message and exit. */
printf ("Cannot create viewer. Is the window too small?\n");
ExitProgram (EXIT_SUCCESS);
}
/* Open the file and read the contents. */
lines = CDKreadFile (filename, &info);
if (lines == -1)
{
printf ("Could not open %s\n", filename);
ExitProgram (EXIT_FAILURE);
}
/* Set up the viewer title, and the contents to the widget. */
sprintf (vtitle, "<C></B/22>%20s<!22!B>", filename);
setCDKViewer (example, vtitle,
(CDK_CSTRING2)info, lines,
A_REVERSE, TRUE, TRUE, TRUE);
/* Activate the viewer widget. */
selected = activateCDKViewer (example, 0);
/* Check how the person exited from the widget. */
if (example->exitType == vESCAPE_HIT)
{
mesg[0] = "<C>Escape hit. No Button selected.";
mesg[1] = "";
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
}
else if (example->exitType == vNORMAL)
{
sprintf (temp, "<C>You selected button %d", selected);
mesg[0] = temp;
mesg[1] = "";
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
}
/* Clean up. */
destroyCDKViewer (example);
destroyCDKScreen (cdkscreen);
CDKfreeStrings (info);
freeChar (filename);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}

1937
deps/cdk-5.0-20161210/demos/rolodex.c vendored Normal file

File diff suppressed because it is too large Load Diff

113
deps/cdk-5.0-20161210/demos/rolodex.h vendored Normal file
View File

@ -0,0 +1,113 @@
/* $Id: rolodex.h,v 1.10 2012/03/21 00:59:17 tom Exp $ */
#include <cdk_test.h>
#include <time.h>
#include <fcntl.h>
#include <unistd.h>
#define MAXGROUPS 100
#define GLINETYPECOUNT 9
/*
* Declare some global variables.
*/
static char *GCurrentGroup = 0;
static char *GRCFile = 0;
static char *GDBMDir = 0;
static int GGroupModified = FALSE;
static const char *GLineType[] = {
"Voice",
"Cell",
"Pager",
"First FAX",
"Second FAX",
"Third FAX",
"First Data Line",
"Second Data Line",
"Third Data Line"
};
/*
* Create some definitions.
*/
typedef enum {vUnknown = -1, vVoice = 0, vCell, vPager, vFAX1, vFAX2, vFAX3, vData1, vData2, vData3} ELineType;
/*
* Define the group record structure.
*/
struct _group_st {
char *name;
char *desc;
char *dbm;
};
typedef struct _group_st SRolodex;
/*
* Define a phone record structure;
*/
struct _record_st {
char *name;
ELineType lineType;
char *phoneNumber;
char *address;
char *city;
char *province;
char *postalCode;
char *desc;
};
typedef struct _record_st SPhoneRecord;
struct _phone_data_st {
SPhoneRecord record[MAX_ITEMS];
int recordCount;
};
typedef struct _phone_data_st SPhoneData;
/*
* Define the callback prototypes.
*/
BINDFN_PROTO(helpCB);
BINDFN_PROTO(groupInfoCB);
BINDFN_PROTO(insertPhoneEntryCB);
BINDFN_PROTO(deletePhoneEntryCB);
BINDFN_PROTO(phoneEntryHelpCB);
int entryPreProcessCB (EObjectType cdkType, void *object, void *clientData, chtype input);
/*
* These functions use/modify the rolodex RC file.
*/
int readRCFile (char *filename, SRolodex *groupInfo);
int openNewRCFile (CDKSCREEN *screen, SRolodex *groups, int groupCount);
int writeRCFile (CDKSCREEN *screen, char *file, SRolodex *groups, int count);
int writeRCFileAs (CDKSCREEN *screen, SRolodex *groups, int count);
/*
* These functions use/modify rolodex phone groups.
*/
int addRolodexGroup (CDKSCREEN *screen, SRolodex *groups, int count);
int deleteRolodexGroup (CDKSCREEN *screen, SRolodex *groups, int count);
int pickRolodexGroup (CDKSCREEN *screen, const char *title, SRolodex *groups, int count);
void useRolodexGroup (CDKSCREEN *screen, char *name, char *desc, char *dbm);
/*
* These functions display misc information about the rolodex program.
*/
void displayRolodexStats (CDKSCREEN *screen, int groupCount);
void aboutCdkRolodex (CDKSCREEN *screen);
void displayPhoneInfo (CDKSCREEN *screen, SPhoneRecord record);
/*
* These functions use/modify phone data lists.
*/
int readPhoneDataFile (char *filename, SPhoneData *record);
int savePhoneDataFile (char *filename, SPhoneData *record);
int addPhoneRecord (CDKSCREEN *screen, SPhoneData *phoneData);
int deletePhoneRecord (CDKSCREEN *screen, SPhoneData *phoneData);
int getLargePhoneRecord (CDKSCREEN *screen, SPhoneRecord *phoneRecord);
int getSmallPhoneRecord (CDKSCREEN *screen, SPhoneRecord *phoneRecord);
/*
* These functions allow us to print out phone numbers.
*/
void printGroupNumbers (CDKSCREEN *screen, SRolodex *groups, int count);
int printGroup (SRolodex groupRecord, const char *filename, char *printer);

264
deps/cdk-5.0-20161210/demos/serial.c vendored Normal file
View File

@ -0,0 +1,264 @@
/* $Id: serial.c,v 1.8 2016/12/04 15:22:16 tom Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
#include <sys/termios.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <time.h>
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "serial";
#endif
/*
* Create global definitions.
*/
#define DEFAULT_PORT "/dev/ttya"
#define DEFAULT_POLL_INTERVAL 1 /* milliseconds */
/*
* This is the working function which probes the serial port.
*/
boolean probeModem (void);
/*
* Define some global variables.
*/
CDKLABEL *label = 0;
int LLastState = 0;
int LCurrentState = 0;
extern char *optarg;
char port[256];
int LFD;
/*
*
*/
int main (int argc, char **argv)
{
CDKSCREEN *cdkScreen = 0;
int lines = 0;
char *info[256], temp[256];
struct termios termInfo;
/* Set the deault values. */
strcpy (port, DEFAULT_PORT);
/* Parse up the command line. */
while (1)
{
int ret;
if ((ret = getopt (argc, argv, "p:h")) == -1)
{
break;
}
switch (ret)
{
case 'p':
strcpy (port, optarg);
break;
case 'h':
printf
("Usage: %s [-p Port] [-i Poll Interval] [-c Poll Count] [-v] [-h]\n",
argv[0]);
ExitProgram (EXIT_SUCCESS);
break;
}
}
cdkScreen = initCDKScreen (NULL);
/* Start CDK color. */
initCDKColor ();
/*
* Set the title of the main window.
*/
sprintf (temp, "<C>Serial Port Monitor (%s)", port);
info[lines++] = copyChar (temp);
info[lines++] = copyChar ("<C><#HL(30)>");
info[lines++] = copyChar ("");
info[lines++] = copyChar ("Line Enabled : -");
info[lines++] = copyChar ("Data Terminal Ready: -");
info[lines++] = copyChar ("Carrier Detect : -");
info[lines++] = copyChar ("Request To Send : -");
info[lines++] = copyChar ("Clear To Send : -");
info[lines++] = copyChar ("Secondary Transmit : -");
info[lines++] = copyChar ("Secondary Receive : -");
info[lines++] = copyChar ("");
/* Create the label widget. */
label = newCDKLabel (cdkScreen, CENTER, CENTER, info, lines, TRUE, FALSE);
drawCDKLabel (label, TRUE);
/*
* Open the serial port read only.
*/
if ((LFD = open (port, O_RDONLY | O_NDELAY, 0)) == -1)
{
/* Create a pop-up dialog box... */
printf ("Error: Open of <%s> failed.\n", port);
ExitProgram (EXIT_FAILURE);
}
termInfo.c_cflag = CRTSCTS | CLOCAL;
if (tcgetattr (LFD, &termInfo) != 0)
{
/* Really should create a pop-up dialog box... */
printf ("Error: Could not get port attributes. Closing the port.\n");
close (LFD);
ExitProgram (EXIT_FAILURE);
}
for (;;)
{
/* Probe the modem. */
probeModem ();
/*
* Sleep for the given amount of time. We do this first so no
* weird refresh things happen.
*/
napms (DEFAULT_POLL_INTERVAL);
}
}
/*
* This probes the modem and determines if we need to update
* the display.
*/
boolean probeModem (void)
{
int lines = 0;
char *info[256], temp[256];
/* Start building the label. */
sprintf (temp, "<C>Serial Port Monitor (%s)", port);
info[lines++] = copyChar (temp);
info[lines++] = copyChar ("<C><#HL(30)>");
info[lines++] = copyChar ("");
/*
* Get the serial port info.
*/
ioctl (LFD, TIOCMGET, &LCurrentState);
/*
* If the states are different, change the display.
*/
if (LLastState != LCurrentState)
{
/*
* Check for line enabled.
*/
if (LCurrentState & TIOCM_LE)
{
info[lines++] = copyChar ("Line Enabled : <#DI>");
}
else
{
info[lines++] = copyChar ("Line Enabled : ");
}
/*
* Check for data terminal ready.
*/
if (LCurrentState & TIOCM_DTR)
{
info[lines++] = copyChar ("Data Terminal Ready: <#DI>");
}
else
{
info[lines++] = copyChar ("Data Terminal Ready: ");
}
/*
* Check for carrier detect.
*/
if (LCurrentState & TIOCM_CAR)
{
info[lines++] = copyChar ("Carrier Detect : <#DI>");
}
else
{
info[lines++] = copyChar ("Carrier Detect : ");
}
/*
* Check for request to send.
*/
if (LCurrentState & TIOCM_RTS)
{
info[lines++] = copyChar ("Request To Send : <#DI>");
}
else
{
info[lines++] = copyChar ("Request To Send : ");
}
/*
* Check for clear to send.
*/
if (LCurrentState & TIOCM_CTS)
{
info[lines++] = copyChar ("Clear To Send : <#DI>");
}
else
{
info[lines++] = copyChar ("Clear To Send : ");
}
/*
* Check for secondary transmit.
*/
if (LCurrentState & TIOCM_ST)
{
info[lines++] = copyChar ("Secondary Transmit : <#DI>");
}
else
{
info[lines++] = copyChar ("Secondary Transmit : ");
}
/*
* Check for secondary receive.
*/
if (LCurrentState & TIOCM_SR)
{
info[lines++] = copyChar ("Secondary Receive : <#DI>");
}
else
{
info[lines++] = copyChar ("Secondary Receive : ");
}
}
info[lines++] = copyChar ("");
/* Only do this if things have changed. */
if (LLastState != LCurrentState)
{
eraseCDKLabel (label);
setCDKLabel (label, info, lines, TRUE);
drawCDKLabel (label, TRUE);
}
/*
* Keep the current state.
*/
LLastState = LCurrentState;
/*
* Return False to tell X that we want this funtion to be
* run again.
*/
return FALSE;
}

83
deps/cdk-5.0-20161210/demos/stopSign.c vendored Normal file
View File

@ -0,0 +1,83 @@
/* $Id: stopSign.c,v 1.13 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "sillyness_ex";
#endif
int main (void)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkscreen = 0;
CDKLABEL *stopSign = 0;
CDKLABEL *title = 0;
const char *mesg[5];
const char *sign[4];
chtype key;
boolean functionKey;
cdkscreen = initCDKScreen (NULL);
/* Start CDK Colors. */
initCDKColor ();
/* Set the labels up. */
mesg[0] = "<C><#HL(40)>";
mesg[1] = "<C>Press </B/16>r<!B!16> for the </B/16>red light";
mesg[2] = "<C>Press </B/32>y<!B!32> for the </B/32>yellow light";
mesg[3] = "<C>Press </B/24>g<!B!24> for the </B/24>green light";
mesg[4] = "<C><#HL(40)>";
sign[0] = " <#DI> ";
sign[1] = " <#DI> ";
sign[2] = " <#DI> ";
/* Declare the labels. */
title = newCDKLabel (cdkscreen, CENTER, TOP,
(CDK_CSTRING2) mesg, 5,
FALSE, FALSE);
stopSign = newCDKLabel (cdkscreen, CENTER, CENTER,
(CDK_CSTRING2) sign, 3,
TRUE, TRUE);
/* Do this until they hit q or escape. */
for (;;)
{
drawCDKLabel (title, FALSE);
drawCDKLabel (stopSign, TRUE);
key = (chtype)getchCDKObject (ObjOf (stopSign), &functionKey);
if (key == KEY_ESC || key == 'q' || key == 'Q')
{
break;
}
else if (key == 'r' || key == 'R')
{
sign[0] = " </B/16><#DI> ";
sign[1] = " o ";
sign[2] = " o ";
}
else if (key == 'y' || key == 'Y')
{
sign[0] = " o ";
sign[1] = " </B/32><#DI> ";
sign[2] = " o ";
}
else if (key == 'g' || key == 'G')
{
sign[0] = " o ";
sign[1] = " o ";
sign[2] = " </B/24><#DI> ";
}
/* Set the contents of the label and re-draw it. */
setCDKLabel (stopSign, (CDK_CSTRING2) sign, 3, TRUE);
}
/* Clean up. */
destroyCDKLabel (title);
destroyCDKLabel (stopSign);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}

1139
deps/cdk-5.0-20161210/demos/syb.c vendored Normal file

File diff suppressed because it is too large Load Diff

508
deps/cdk-5.0-20161210/demos/vinstall.c vendored Normal file
View File

@ -0,0 +1,508 @@
/* $Id: vinstall.c,v 1.21 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "vinstall";
#endif
/*
* Written by: Mike Glover
* Purpose:
* This is a fairly basic install interface.
*/
/* Declare global types and prototypes. */
static const char *FPUsage = "-f filename [-s source directory] [-d destination directory] [-t title] [-o Output file] [-q]";
typedef enum
{
vCanNotOpenSource,
vCanNotOpenDest,
vOK
}
ECopyFile;
static ECopyFile copyFile (CDKSCREEN *cdkScreen, char *src, char *dest);
static int verifyDirectory (CDKSCREEN *screen, char *directory);
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkScreen = 0;
CDKSWINDOW *installOutput = 0;
CDKENTRY *sourceEntry = 0;
CDKENTRY *destEntry = 0;
CDKLABEL *titleWin = 0;
CDKHISTOGRAM *progressBar = 0;
char *sourcePath = 0;
char *destPath = 0;
char *sourceDir = 0;
char *destDir = 0;
char *filename = 0;
char *title = 0;
char *output = 0;
int quiet = FALSE;
int errors = 0;
int sWindowHeight = 0;
char *titleMessage[10];
char **fileList = 0;
const char *mesg[20];
char oldPath[512], newPath[512], temp[2000];
int count, ret, x;
/* Parse up the command line. */
while (1)
{
ret = getopt (argc, argv, "d:s:f:t:o:q");
if (ret == -1)
{
break;
}
switch (ret)
{
case 's':
sourcePath = strdup (optarg);
break;
case 'd':
destPath = strdup (optarg);
break;
case 'f':
filename = strdup (optarg);
break;
case 't':
title = strdup (optarg);
break;
case 'o':
output = strdup (optarg);
break;
case 'q':
quiet = TRUE;
break;
}
}
/* Make sure have everything we need. */
if (filename == 0)
{
fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
ExitProgram (EXIT_FAILURE);
}
/* Open the file list file and read it in. */
count = CDKreadFile (filename, &fileList);
if (count == 0)
{
fprintf (stderr, "%s: Input filename <%s> is empty.\n", argv[0], filename);
ExitProgram (EXIT_FAILURE);
}
/*
* Cycle through what was given to us and save it.
*/
for (x = 0; x < count; x++)
{
/* Strip white space from the line. */
stripWhiteSpace (vBOTH, fileList[x]);
}
cdkScreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Create the title label. */
titleMessage[0] = copyChar ("<C></32/B><#HL(30)>");
if (title == 0)
{
sprintf (temp, "<C></32/B>CDK Installer");
}
else
{
sprintf (temp, "<C></32/B>%.256s", title);
}
titleMessage[1] = copyChar (temp);
titleMessage[2] = copyChar ("<C></32/B><#HL(30)>");
titleWin = newCDKLabel (cdkScreen, CENTER, TOP,
(CDK_CSTRING2)titleMessage, 3,
FALSE, FALSE);
freeCharList (titleMessage, 3);
/* Allow them to change the install directory. */
if (sourcePath == 0)
{
sourceEntry = newCDKEntry (cdkScreen, CENTER, 8,
0, "Source Directory :",
A_NORMAL, '.', vMIXED,
40, 0, 256, TRUE, FALSE);
}
if (destPath == 0)
{
destEntry = newCDKEntry (cdkScreen, CENTER, 11,
0, "Destination Directory:", A_NORMAL,
'.', vMIXED, 40, 0, 256, TRUE, FALSE);
}
/* Get the source install path. */
if (sourceEntry != 0)
{
drawCDKScreen (cdkScreen);
sourceDir = copyChar (activateCDKEntry (sourceEntry, 0));
}
else
{
sourceDir = copyChar (sourcePath);
}
/* Get the destination install path. */
if (destEntry != 0)
{
drawCDKScreen (cdkScreen);
destDir = copyChar (activateCDKEntry (destEntry, 0));
}
else
{
destDir = copyChar (destPath);
}
/* Destroy the path entry fields. */
if (sourceEntry != 0)
{
destroyCDKEntry (sourceEntry);
}
if (destEntry != 0)
{
destroyCDKEntry (destEntry);
}
/*
* Verify that the source directory is valid.
*/
if (verifyDirectory (cdkScreen, sourceDir) != 0)
{
/* Clean up and leave. */
freeChar (destDir);
freeChar (sourceDir);
destroyCDKLabel (titleWin);
destroyCDKScreen (cdkScreen);
endCDK ();
ExitProgram (EXIT_FAILURE);
}
/*
* Verify that the source directory is valid.
*/
if (verifyDirectory (cdkScreen, destDir) != 0)
{
/* Clean up and leave. */
freeChar (destDir);
freeChar (sourceDir);
destroyCDKLabel (titleWin);
destroyCDKScreen (cdkScreen);
endCDK ();
ExitProgram (EXIT_FAILURE);
}
/* Create the histogram. */
progressBar = newCDKHistogram (cdkScreen, CENTER, 5,
3, 0, HORIZONTAL,
"<C></56/B>Install Progress",
TRUE, FALSE);
/* Set the top left/right characters of the histogram. */
setCDKHistogramLLChar (progressBar, ACS_LTEE);
setCDKHistogramLRChar (progressBar, ACS_RTEE);
/* Set the initial value of the histogram. */
setCDKHistogram (progressBar, vPERCENT, TOP, A_BOLD,
1, count, 1,
COLOR_PAIR (24) | A_REVERSE | ' ',
TRUE);
/* Determine the height of the scrolling window. */
if (LINES >= 16)
{
sWindowHeight = LINES - 13;
}
else
{
sWindowHeight = 3;
}
/* Create the scrolling window. */
installOutput = newCDKSwindow (cdkScreen, CENTER, BOTTOM,
sWindowHeight, 0,
"<C></56/B>Install Results",
2000, TRUE, FALSE);
/* Set the top left/right characters of the scrolling window. */
setCDKSwindowULChar (installOutput, ACS_LTEE);
setCDKSwindowURChar (installOutput, ACS_RTEE);
/* Draw the screen. */
drawCDKScreen (cdkScreen);
/* Start copying the files. */
for (x = 0; x < count; x++)
{
char **files;
int chunks;
/*
* If the 'file' list file has 2 columns, the first is
* the source filename, the second being the destination
* filename.
*/
files = CDKsplitString (fileList[x], ' ');
chunks = (int)CDKcountStrings ((CDK_CSTRING2)files);
if (chunks == 2)
{
/* Create the correct paths. */
sprintf (oldPath, "%s/%s", sourceDir, files[0]);
sprintf (newPath, "%s/%s", destDir, files[1]);
}
else
{
/* Create the correct paths. */
sprintf (oldPath, "%s/%s", sourceDir, fileList[x]);
sprintf (newPath, "%s/%s", destDir, fileList[x]);
}
CDKfreeStrings (files);
/* Copy the file from the source to the destination. */
ret = copyFile (cdkScreen, oldPath, newPath);
if (ret == vCanNotOpenSource)
{
sprintf (temp,
"</16>Error: Can not open source file \"%.256s\"<!16>", oldPath);
errors++;
}
else if (ret == vCanNotOpenDest)
{
sprintf (temp,
"</16>Error: Can not open destination file \"%.256s\"<!16>", newPath);
errors++;
}
else
{
sprintf (temp, "</24>%.256s -> %.256s", oldPath, newPath);
}
/* Add the message to the scrolling window. */
addCDKSwindow (installOutput, temp, BOTTOM);
drawCDKSwindow (installOutput, ObjOf (installOutput)->box);
/* Update the histogram. */
setCDKHistogram (progressBar, vPERCENT, TOP, A_BOLD,
1, count, x + 1,
COLOR_PAIR (24) | A_REVERSE | ' ',
TRUE);
/* Update the screen. */
drawCDKHistogram (progressBar, TRUE);
}
/*
* If there were errors, inform the user and allow them to look at the
* errors in the scrolling window.
*/
if (errors != 0)
{
/* Create the information for the dialog box. */
const char *buttons[] =
{
"Look At Errors Now",
"Save Output To A File",
"Ignore Errors"
};
mesg[0] = "<C>There were errors in the installation.";
mesg[1] = "<C>If you want, you may scroll through the";
mesg[2] = "<C>messages of the scrolling window to see";
mesg[3] = "<C>what the errors were. If you want to save";
mesg[4] = "<C>the output of the window you may press </R>s<!R>";
mesg[5] = "<C>while in the window, or you may save the output";
mesg[6] = "<C>of the install now and look at the install";
mesg[7] = "<C>history at a later date.";
/* Popup the dialog box. */
ret = popupDialog (cdkScreen,
(CDK_CSTRING2)mesg, 8,
(CDK_CSTRING2)buttons, 3);
if (ret == 0)
{
activateCDKSwindow (installOutput, 0);
}
else if (ret == 1)
{
(void)injectCDKSwindow (installOutput, 's');
}
}
else
{
/*
* If they specified the name of an output file, then save the
* results of the installation to that file.
*/
if (output != 0)
{
dumpCDKSwindow (installOutput, output);
}
else
{
/* Ask them if they want to save the output of the scrolling window. */
if (quiet == FALSE)
{
const char *buttons[] =
{
"No",
"Yes"
};
mesg[0] = "<C>Do you want to save the output of the";
mesg[1] = "<C>scrolling window to a file?";
if (popupDialog (cdkScreen,
(CDK_CSTRING2)mesg, 2,
(CDK_CSTRING2)buttons, 2) == 1)
{
(void)injectCDKSwindow (installOutput, 's');
}
}
}
}
/* Clean up. */
destroyCDKLabel (titleWin);
destroyCDKHistogram (progressBar);
destroyCDKSwindow (installOutput);
destroyCDKScreen (cdkScreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}
/*
* This copies a file from one place to another. (tried rename
* library call, but it is equivalent to mv)
*/
static ECopyFile copyFile (CDKSCREEN *cdkScreen GCC_UNUSED, char *src, char *dest)
{
char command[2000];
FILE *fd;
/* Make sure we can open the source file. */
if ((fd = fopen (src, "r")) == 0)
{
return vCanNotOpenSource;
}
fclose (fd);
/*
* Remove the destination file first, just in case it already exists.
* This allows us to check if we can write to the desintation file.
*/
sprintf (command, "rm -f %s", dest);
system (command);
/* Try to open the destination. */
if ((fd = fopen (dest, "w")) == 0)
{
return vCanNotOpenDest;
}
fclose (fd);
/*
* Copy the file. There has to be a better way to do this. I
* tried rename and link but they both have the same limitation
* as the 'mv' command that you can not move across partitions.
* Quite limiting in an install binary.
*/
sprintf (command, "rm -f %s; cp %s %s; chmod 444 %s", dest, src, dest, dest);
system (command);
return vOK;
}
/*
* This makes sure that the directory given exists. If it
* doesn't then it will make it.
* THINK
*/
static int verifyDirectory (CDKSCREEN *cdkScreen, char *directory)
{
int status = 0;
#if !defined (__MINGW32__)
mode_t dirMode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH;
#endif
struct stat fileStat;
char temp[512];
/* Stat the directory. */
if (lstat (directory, &fileStat) != 0)
{
/* The directory does not exist. */
if (errno == ENOENT)
{
const char *buttons[] =
{
"Yes",
"No"
};
const char *mesg[10];
char *error[10];
/* Create the question. */
mesg[0] = "<C>The directory ";
sprintf (temp, "<C>%.256s", directory);
mesg[1] = temp;
mesg[2] = "<C>Does not exist. Do you want to";
mesg[3] = "<C>create it?";
/* Ask them if they want to create the directory. */
if (popupDialog (cdkScreen,
(CDK_CSTRING2)mesg, 4,
(CDK_CSTRING2)buttons, 2) == 0)
{
/* Create the directory. */
#if defined (__MINGW32__)
if (mkdir (directory) != 0)
#else
if (mkdir (directory, dirMode) != 0)
#endif
{
/* Create the error message. */
error[0] = copyChar ("<C>Could not create the directory");
sprintf (temp, "<C>%.256s", directory);
error[1] = copyChar (temp);
#ifdef HAVE_STRERROR
sprintf (temp, "<C>%.256s", strerror (errno));
#else
sprintf (temp, "<C>Check the permissions and try again.");
#endif
error[2] = copyChar (temp);
/* Pop up the error message. */
popupLabel (cdkScreen, (CDK_CSTRING2)error, 3);
freeCharList (error, 3);
status = -1;
}
}
else
{
/* Create the message. */
error[0] = copyChar ("<C>Installation aborted.");
/* Pop up the error message. */
popupLabel (cdkScreen, (CDK_CSTRING2)error, 1);
freeCharList (error, 1);
status = -1;
}
}
}
return status;
}

563
deps/cdk-5.0-20161210/dialog.c vendored Normal file
View File

@ -0,0 +1,563 @@
#include <cdk_int.h>
/*
* $Author: tom $
* $Date: 2016/11/20 19:02:55 $
* $Revision: 1.102 $
*/
DeclareCDKObjects (DIALOG, Dialog, setCdk, Int);
/*
* This function creates a dialog widget.
*/
CDKDIALOG *newCDKDialog (CDKSCREEN *cdkscreen,
int xplace,
int yplace,
CDK_CSTRING2 mesg,
int rows,
CDK_CSTRING2 buttonLabel,
int buttonCount,
chtype highlight,
boolean separator,
boolean Box,
boolean shadow)
{
/* *INDENT-EQLS* */
CDKDIALOG *dialog = 0;
int boxHeight;
int boxWidth = MIN_DIALOG_WIDTH;
int maxmessagewidth = -1;
int buttonwidth = 0;
int xpos = xplace;
int ypos = yplace;
int temp = 0;
int buttonadj = 0;
int x = 0;
if (rows <= 0
|| buttonCount <= 0
|| (dialog = newCDKObject (CDKDIALOG, &my_funcs)) == 0
|| (dialog->info = typeCallocN (chtype *, rows + 1)) == 0
|| (dialog->infoLen = typeCallocN (int, rows + 1)) == 0
|| (dialog->infoPos = typeCallocN (int, rows + 1)) == 0
|| (dialog->buttonLabel = typeCallocN (chtype *, buttonCount + 1)) == 0
|| (dialog->buttonLen = typeCallocN (int, buttonCount + 1)) == 0
|| (dialog->buttonPos = typeCallocN (int, buttonCount + 1)) == 0)
{
destroyCDKObject (dialog);
return (0);
}
setCDKDialogBox (dialog, Box);
boxHeight = rows + 2 * BorderOf (dialog) + separator + 1;
/* Translate the char * message to a chtype * */
for (x = 0; x < rows; x++)
{
dialog->info[x] = char2Chtype (mesg[x],
&dialog->infoLen[x],
&dialog->infoPos[x]);
maxmessagewidth = MAXIMUM (maxmessagewidth, dialog->infoLen[x]);
}
/* Translate the button label char * to a chtype * */
for (x = 0; x < buttonCount; x++)
{
/* *INDENT-EQLS* */
dialog->buttonLabel[x] = char2Chtype (buttonLabel[x],
&dialog->buttonLen[x],
&temp);
buttonwidth += dialog->buttonLen[x] + 1;
}
buttonwidth--;
/* Determine the final dimensions of the box. */
boxWidth = MAXIMUM (boxWidth, maxmessagewidth);
boxWidth = MAXIMUM (boxWidth, buttonwidth);
boxWidth = boxWidth + 2 + 2 * BorderOf (dialog);
/* Now we have to readjust the x and y positions. */
alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
/* *INDENT-EQLS* Set up the dialog box attributes. */
ScreenOf (dialog) = cdkscreen;
dialog->parent = cdkscreen->window;
dialog->win = newwin (boxHeight, boxWidth, ypos, xpos);
dialog->shadowWin = 0;
dialog->buttonCount = buttonCount;
dialog->currentButton = 0;
dialog->messageRows = rows;
dialog->boxHeight = boxHeight;
dialog->boxWidth = boxWidth;
dialog->highlight = highlight;
dialog->separator = separator;
initExitType (dialog);
ObjOf (dialog)->acceptsFocus = TRUE;
ObjOf (dialog)->inputWindow = dialog->win;
dialog->shadow = shadow;
/* If we couldn't create the window, we should return a null value. */
if (dialog->win == 0)
{
destroyCDKObject (dialog);
return (0);
}
keypad (dialog->win, TRUE);
/* Find the button positions. */
buttonadj = ((int)((boxWidth - buttonwidth) / 2));
for (x = 0; x < buttonCount; x++)
{
dialog->buttonPos[x] = buttonadj;
buttonadj = buttonadj + dialog->buttonLen[x] + BorderOf (dialog);
}
/* Create the string alignments. */
for (x = 0; x < rows; x++)
{
dialog->infoPos[x] = justifyString (boxWidth - 2 * BorderOf (dialog),
dialog->infoLen[x],
dialog->infoPos[x]);
}
/* Was there a shadow? */
if (shadow)
{
dialog->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
}
/* Register this baby. */
registerCDKObject (cdkscreen, vDIALOG, dialog);
/* Return the dialog box pointer. */
return (dialog);
}
/*
* This lets the user select the button.
*/
int activateCDKDialog (CDKDIALOG *dialog, chtype *actions)
{
chtype input = 0;
boolean functionKey;
int ret;
/* Draw the dialog box. */
drawCDKDialog (dialog, ObjOf (dialog)->box);
/* Lets move to the first button. */
writeChtypeAttrib (dialog->win,
dialog->buttonPos[dialog->currentButton],
dialog->boxHeight - 1 - BorderOf (dialog),
dialog->buttonLabel[dialog->currentButton],
dialog->highlight,
HORIZONTAL,
0, dialog->buttonLen[dialog->currentButton]);
wrefresh (dialog->win);
if (actions == 0)
{
for (;;)
{
input = (chtype)getchCDKObject (ObjOf (dialog), &functionKey);
/* Inject the character into the widget. */
ret = injectCDKDialog (dialog, input);
if (dialog->exitType != vEARLY_EXIT)
{
return ret;
}
}
}
else
{
int length = chlen (actions);
int x = 0;
/* Inject each character one at a time. */
for (x = 0; x < length; x++)
{
ret = injectCDKDialog (dialog, actions[x]);
if (dialog->exitType != vEARLY_EXIT)
{
return ret;
}
}
}
/* Set the exit type and exit. */
setExitType (dialog, 0);
return -1;
}
/*
* This injects a single character into the dialog widget.
*/
static int _injectCDKDialog (CDKOBJS *object, chtype input)
{
/* *INDENT-EQLS* */
CDKDIALOG *widget = (CDKDIALOG *)object;
int lastButton = widget->buttonCount - 1;
int ppReturn = 1;
int ret = unknownInt;
bool complete = FALSE;
/* Set the exit type. */
setExitType (widget, 0);
/* Check if there is a pre-process function to be called. */
if (PreProcessFuncOf (widget) != 0)
{
ppReturn = PreProcessFuncOf (widget) (vDIALOG,
widget,
PreProcessDataOf (widget),
input);
}
/* Should we continue? */
if (ppReturn != 0)
{
/* Check for a key binding. */
if (checkCDKObjectBind (vDIALOG, widget, input) != 0)
{
checkEarlyExit (widget);
complete = TRUE;
}
else
{
int firstButton = 0;
switch (input)
{
case KEY_LEFT:
case KEY_BTAB:
case KEY_BACKSPACE:
if (widget->currentButton == firstButton)
{
widget->currentButton = lastButton;;
}
else
{
widget->currentButton--;
}
break;
case KEY_RIGHT:
case KEY_TAB:
case SPACE:
if (widget->currentButton == lastButton)
{
widget->currentButton = firstButton;
}
else
{
widget->currentButton++;
}
break;
case KEY_UP:
case KEY_DOWN:
Beep ();
break;
case CDK_REFRESH:
eraseCDKScreen (ScreenOf (widget));
refreshCDKScreen (ScreenOf (widget));
break;
case KEY_ESC:
setExitType (widget, input);
complete = TRUE;
break;
case KEY_ERROR:
setExitType (widget, input);
complete = TRUE;
break;
case KEY_ENTER:
setExitType (widget, input);
ret = widget->currentButton;
complete = TRUE;
break;
default:
break;
}
}
/* Should we call a post-process? */
if (!complete && (PostProcessFuncOf (widget) != 0))
{
PostProcessFuncOf (widget) (vDIALOG,
widget,
PostProcessDataOf (widget),
input);
}
}
if (!complete)
{
drawCDKDialogButtons (widget);
wrefresh (widget->win);
setExitType (widget, 0);
}
ResultOf (widget).valueInt = ret;
return (ret != unknownInt);
}
/*
* This moves the dialog field to the given location.
*/
static void _moveCDKDialog (CDKOBJS *object,
int xplace,
int yplace,
boolean relative,
boolean refresh_flag)
{
CDKDIALOG *dialog = (CDKDIALOG *)object;
/* *INDENT-EQLS* */
int currentX = getbegx (dialog->win);
int currentY = getbegy (dialog->win);
int xpos = xplace;
int ypos = yplace;
int xdiff = 0;
int ydiff = 0;
/*
* If this is a relative move, then we will adjust where we want
* to move to.
*/
if (relative)
{
xpos = getbegx (dialog->win) + xplace;
ypos = getbegy (dialog->win) + yplace;
}
/* Adjust the window if we need to. */
alignxy (WindowOf (dialog), &xpos, &ypos, dialog->boxWidth, dialog->boxHeight);
/* Get the difference. */
xdiff = currentX - xpos;
ydiff = currentY - ypos;
/* Move the window to the new location. */
moveCursesWindow (dialog->win, -xdiff, -ydiff);
moveCursesWindow (dialog->shadowWin, -xdiff, -ydiff);
/* Touch the windows so they 'move'. */
refreshCDKWindow (WindowOf (dialog));
/* Redraw the window, if they asked for it. */
if (refresh_flag)
{
drawCDKDialog (dialog, ObjOf (dialog)->box);
}
}
/*
* This function draws the dialog widget.
*/
static void _drawCDKDialog (CDKOBJS *object, boolean Box)
{
CDKDIALOG *dialog = (CDKDIALOG *)object;
int x = 0;
/* Is there a shadow? */
if (dialog->shadowWin != 0)
{
drawShadow (dialog->shadowWin);
}
/* Box the widget if they asked. */
if (Box)
{
drawObjBox (dialog->win, ObjOf (dialog));
}
/* Draw in the message. */
for (x = 0; x < dialog->messageRows; x++)
{
writeChtype (dialog->win,
dialog->infoPos[x] + BorderOf (dialog), x + BorderOf (dialog),
dialog->info[x],
HORIZONTAL, 0,
dialog->infoLen[x]);
}
/* Draw in the buttons. */
drawCDKDialogButtons (dialog);
wrefresh (dialog->win);
}
/*
* This function destroys the dialog widget.
*/
static void _destroyCDKDialog (CDKOBJS *object)
{
if (object != 0)
{
CDKDIALOG *dialog = (CDKDIALOG *)object;
CDKfreeChtypes (dialog->info);
freeChecked (dialog->infoLen);
freeChecked (dialog->infoPos);
CDKfreeChtypes (dialog->buttonLabel);
freeChecked (dialog->buttonLen);
freeChecked (dialog->buttonPos);
/* Clean up the windows. */
deleteCursesWindow (dialog->win);
deleteCursesWindow (dialog->shadowWin);
/* Clean the key bindings. */
cleanCDKObjectBindings (vDIALOG, dialog);
/* Unregister this object. */
unregisterCDKObject (vDIALOG, dialog);
}
}
/*
* This function erases the dialog widget from the screen.
*/
static void _eraseCDKDialog (CDKOBJS *object)
{
if (validCDKObject (object))
{
CDKDIALOG *dialog = (CDKDIALOG *)object;
eraseCursesWindow (dialog->win);
eraseCursesWindow (dialog->shadowWin);
}
}
/*
* This sets attributes of the dialog box.
*/
void setCDKDialog (CDKDIALOG *dialog, chtype highlight, boolean separator, boolean Box)
{
setCDKDialogHighlight (dialog, highlight);
setCDKDialogSeparator (dialog, separator);
setCDKDialogBox (dialog, Box);
}
/*
* This sets the highlight attribute for the buttons.
*/
void setCDKDialogHighlight (CDKDIALOG *dialog, chtype highlight)
{
dialog->highlight = highlight;
}
chtype getCDKDialogHighlight (CDKDIALOG *dialog)
{
return dialog->highlight;
}
/*
* This sets whether or not the dialog box will have a separator line.
*/
void setCDKDialogSeparator (CDKDIALOG *dialog, boolean separator)
{
dialog->separator = separator;
}
boolean getCDKDialogSeparator (CDKDIALOG *dialog)
{
return dialog->separator;
}
/*
* This sets the box attribute of the widget.
*/
void setCDKDialogBox (CDKDIALOG *dialog, boolean Box)
{
ObjOf (dialog)->box = Box;
ObjOf (dialog)->borderSize = Box ? 1 : 0;
}
boolean getCDKDialogBox (CDKDIALOG *dialog)
{
return ObjOf (dialog)->box;
}
/*
* This sets the background attribute of the widget.
*/
static void _setBKattrDialog (CDKOBJS *object, chtype attrib)
{
if (object != 0)
{
CDKDIALOG *widget = (CDKDIALOG *)object;
wbkgd (widget->win, attrib);
}
}
/*
* This draws the dialog buttons and the separation line.
*/
void drawCDKDialogButtons (CDKDIALOG *dialog)
{
int x;
for (x = 0; x < dialog->buttonCount; x++)
{
writeChtype (dialog->win,
dialog->buttonPos[x],
dialog->boxHeight - 1 - BorderOf (dialog),
dialog->buttonLabel[x],
HORIZONTAL, 0,
dialog->buttonLen[x]);
}
/* Draw the separation line. */
if (dialog->separator)
{
chtype boxattr = BXAttrOf (dialog);
for (x = 1; x < dialog->boxWidth - 1; x++)
{
(void)mvwaddch (dialog->win,
dialog->boxHeight - 2 - BorderOf (dialog),
x,
ACS_HLINE | boxattr);
}
(void)mvwaddch (dialog->win,
dialog->boxHeight - 2 - BorderOf (dialog),
0,
ACS_LTEE | boxattr);
(void)mvwaddch (dialog->win,
dialog->boxHeight - 2 - BorderOf (dialog),
getmaxx (dialog->win) - 1,
ACS_RTEE | boxattr);
}
writeChtypeAttrib (dialog->win,
dialog->buttonPos[dialog->currentButton],
dialog->boxHeight - 1 - BorderOf (dialog),
dialog->buttonLabel[dialog->currentButton],
dialog->highlight,
HORIZONTAL, 0,
dialog->buttonLen[dialog->currentButton]);
}
static void _focusCDKDialog (CDKOBJS *object)
{
CDKDIALOG *widget = (CDKDIALOG *)object;
drawCDKDialog (widget, ObjOf (widget)->box);
}
static void _unfocusCDKDialog (CDKOBJS *object)
{
CDKDIALOG *widget = (CDKDIALOG *)object;
drawCDKDialog (widget, ObjOf (widget)->box);
}
dummyRefreshData (Dialog)
dummySaveData (Dialog)

360
deps/cdk-5.0-20161210/draw.c vendored Normal file
View File

@ -0,0 +1,360 @@
#include <cdk_int.h>
/*
* $Author: tom $
* $Date: 2016/12/04 19:43:46 $
* $Revision: 1.62 $
*/
/*
* This sets up a basic set of color pairs. These can be redefined
* if wanted...
*/
void initCDKColor (void)
{
#ifdef HAVE_START_COLOR
if (has_colors ())
{
int color[] =
{
COLOR_WHITE, COLOR_RED, COLOR_GREEN,
COLOR_YELLOW, COLOR_BLUE, COLOR_MAGENTA,
COLOR_CYAN, COLOR_BLACK
};
int pair = 1;
int fg, bg;
int limit;
start_color ();
limit = (COLORS < MAX_COLORS) ? COLORS : MAX_COLORS;
/* Create the color pairs. */
for (fg = 0; fg < limit; fg++)
{
for (bg = 0; bg < limit; bg++)
{
init_pair ((short)pair++, (short)color[fg], (short)color[bg]);
}
}
}
#endif
}
/*
* This prints out a box around a window with attributes
*/
void boxWindow (WINDOW *window, chtype attr)
{
/* *INDENT-EQLS* */
int tlx = 0;
int tly = 0;
int brx = getmaxx (window) - 1;
int bry = getmaxy (window) - 1;
/* Draw horizontal lines. */
(void)mvwhline (window, tly, 0, ACS_HLINE | attr, getmaxx (window));
(void)mvwhline (window, bry, 0, ACS_HLINE | attr, getmaxx (window));
/* Draw vertical lines. */
(void)mvwvline (window, 0, tlx, ACS_VLINE | attr, getmaxy (window));
(void)mvwvline (window, 0, brx, ACS_VLINE | attr, getmaxy (window));
/* Draw in the corners. */
(void)mvwaddch (window, tly, tlx, ACS_ULCORNER | attr);
(void)mvwaddch (window, tly, brx, ACS_URCORNER | attr);
(void)mvwaddch (window, bry, tlx, ACS_LLCORNER | attr);
(void)mvwaddch (window, bry, brx, ACS_LRCORNER | attr);
(void)wrefresh (window);
}
/*
* This draws a box with attributes and lets the user define
* each element of the box.
*/
void attrbox (WINDOW *win,
chtype tlc,
chtype trc,
chtype blc,
chtype brc,
chtype horz,
chtype vert,
chtype attr)
{
/* *INDENT-EQLS* */
int x1 = 0;
int y1 = 0;
int y2 = getmaxy (win) - 1;
int x2 = getmaxx (win) - 1;
int count = 0;
/* Draw horizontal lines. */
if (horz != 0)
{
(void)mvwhline (win, y1, 0, horz | attr, getmaxx (win));
(void)mvwhline (win, y2, 0, horz | attr, getmaxx (win));
count++;
}
/* Draw vertical lines. */
if (vert != 0)
{
(void)mvwvline (win, 0, x1, vert | attr, getmaxy (win));
(void)mvwvline (win, 0, x2, vert | attr, getmaxy (win));
count++;
}
/* Draw in the corners. */
if (tlc != 0)
{
(void)mvwaddch (win, y1, x1, tlc | attr);
count++;
}
if (trc != 0)
{
(void)mvwaddch (win, y1, x2, trc | attr);
count++;
}
if (blc != 0)
{
(void)mvwaddch (win, y2, x1, blc | attr);
count++;
}
if (brc != 0)
{
(void)mvwaddch (win, y2, x2, brc | attr);
count++;
}
if (count != 0)
{
wrefresh (win);
}
}
/*
* Draw a box around the given window using the object's defined line-drawing
* characters.
*/
void drawObjBox (WINDOW *win, CDKOBJS *object)
{
attrbox (win,
object->ULChar,
object->URChar,
object->LLChar,
object->LRChar,
object->HZChar,
object->VTChar,
object->BXAttr);
}
/*
* This draws a line on the given window. (odd angle lines not working yet)
*/
void drawLine (WINDOW *window, int startx, int starty, int endx, int endy, chtype line)
{
/* *INDENT-EQLS* */
int xdiff = endx - startx;
int ydiff = endy - starty;
int x = 0;
int y = 0;
/* Determine if we are drawing a horizontal or vertical line. */
if (ydiff == 0)
{
if (xdiff > 0)
(void)mvwhline (window, starty, startx, line, xdiff);
}
else if (xdiff == 0)
{
if (ydiff > 0)
(void)mvwvline (window, starty, startx, line, ydiff);
}
else
{
/* We need to determine the angle of the line. */
/* *INDENT-EQLS* */
int height = xdiff;
int width = ydiff;
int xratio = (height > width ? 1 : (width / height));
int yratio = (width > height ? (width / height) : 1);
int xadj = 0;
int yadj = 0;
/* Set the vars. */
x = startx;
y = starty;
while (x != endx && y != endy)
{
/* Add the char to the window. */
(void)mvwaddch (window, y, x, line);
/* Make the x and y adjustments. */
if (xadj != xratio)
{
x = (xdiff < 0 ? x - 1 : x + 1);
xadj++;
}
else
{
xadj = 0;
}
if (yadj != yratio)
{
y = (ydiff < 0 ? y - 1 : y + 1);
yadj++;
}
else
{
yadj = 0;
}
}
}
}
/*
* This draws a shadow around a window.
*/
void drawShadow (WINDOW *shadowWin)
{
if (shadowWin != 0)
{
int x_hi = getmaxx (shadowWin) - 1;
int y_hi = getmaxy (shadowWin) - 1;
/* Draw the line on the bottom. */
(void)mvwhline (shadowWin, y_hi, 1, ACS_HLINE | A_DIM, x_hi);
/* Draw the line on the right. */
(void)mvwvline (shadowWin, 0, x_hi, ACS_VLINE | A_DIM, y_hi);
(void)mvwaddch (shadowWin, 0, x_hi, ACS_URCORNER | A_DIM);
(void)mvwaddch (shadowWin, y_hi, 0, ACS_LLCORNER | A_DIM);
(void)mvwaddch (shadowWin, y_hi, x_hi, ACS_LRCORNER | A_DIM);
wrefresh (shadowWin);
}
}
/*
* Write a string of blanks, using writeChar().
*/
void writeBlanks (WINDOW *window, int xpos, int ypos, int align, int start, int end)
{
if (start < end)
{
unsigned want = (unsigned)(end - start) + 1000;
char *blanks = (char *)malloc (want);
if (blanks != 0)
{
cleanChar (blanks, (int)(want - 1), ' ');
writeChar (window, xpos, ypos, blanks, align, start, end);
freeChar (blanks);
}
}
}
/*
* This writes out a char * string with no attributes.
*/
void writeChar (WINDOW *window,
int xpos,
int ypos,
char *string,
int align,
int start,
int end)
{
writeCharAttrib (window, xpos, ypos, string, A_NORMAL, align, start, end);
}
/*
* This writes out a char * string with attributes.
*/
void writeCharAttrib (WINDOW *window,
int xpos,
int ypos,
char *string,
chtype attr,
int align,
int start,
int end)
{
int display = end - start;
int x;
if (align == HORIZONTAL)
{
/* Draw the message on a horizontal axis. */
display = MINIMUM (display, getmaxx (window) - 1);
for (x = 0; x < display; x++)
{
(void)mvwaddch (window,
ypos,
xpos + x,
CharOf (string[x + start]) | attr);
}
}
else
{
/* Draw the message on a vertical axis. */
display = MINIMUM (display, getmaxy (window) - 1);
for (x = 0; x < display; x++)
{
(void)mvwaddch (window,
ypos + x,
xpos,
CharOf (string[x + start]) | attr);
}
}
}
/*
* This writes out a chtype * string.
*/
void writeChtype (WINDOW *window,
int xpos,
int ypos,
chtype *string,
int align,
int start,
int end)
{
writeChtypeAttrib (window, xpos, ypos, string, A_NORMAL, align, start, end);
}
/*
* This writes out a chtype * string * with the given attributes added.
*/
void writeChtypeAttrib (WINDOW *window,
int xpos,
int ypos,
chtype *string,
chtype attr,
int align,
int start,
int end)
{
/* *INDENT-EQLS* */
int diff = end - start;
int display = 0;
int x = 0;
if (align == HORIZONTAL)
{
/* Draw the message on a horizontal axis. */
display = MINIMUM (diff, getmaxx (window) - xpos);
for (x = 0; x < display; x++)
{
(void)mvwaddch (window, ypos, xpos + x, string[x + start] | attr);
}
}
else
{
/* Draw the message on a vertical axis. */
display = MINIMUM (diff, getmaxy (window) - ypos);
for (x = 0; x < display; x++)
{
(void)mvwaddch (window, ypos + x, xpos, string[x + start] | attr);
}
}
}

961
deps/cdk-5.0-20161210/entry.c vendored Normal file
View File

@ -0,0 +1,961 @@
#include <cdk_int.h>
/*
* $Author: tom $
* $Date: 2016/11/20 19:04:57 $
* $Revision: 1.224 $
*/
/*
* Declare file local prototypes.
*/
static void CDKEntryCallBack (CDKENTRY *entry, chtype character);
static void drawCDKEntryField (CDKENTRY *entry);
DeclareCDKObjects (ENTRY, Entry, setCdk, String);
/*
* This creates a pointer to an entry widget.
*/
CDKENTRY *newCDKEntry (CDKSCREEN *cdkscreen,
int xplace,
int yplace,
const char *title,
const char *label,
chtype fieldAttr,
chtype filler,
EDisplayType dispType,
int fWidth,
int min,
int max,
boolean Box,
boolean shadow)
{
/* *INDENT-EQLS* */
CDKENTRY *entry = 0;
int parentWidth = getmaxx (cdkscreen->window);
int parentHeight = getmaxy (cdkscreen->window);
int fieldWidth = fWidth;
int boxWidth = 0;
int boxHeight;
int xpos = xplace;
int ypos = yplace;
int junk = 0;
int horizontalAdjust, oldWidth;
if ((entry = newCDKObject (CDKENTRY, &my_funcs)) == 0)
return (0);
setCDKEntryBox (entry, Box);
boxHeight = (BorderOf (entry) * 2) + 1;
/*
* If the fieldWidth is a negative value, the fieldWidth will
* be COLS-fieldWidth, otherwise, the fieldWidth will be the
* given width.
*/
fieldWidth = setWidgetDimension (parentWidth, fieldWidth, 0);
boxWidth = fieldWidth + 2 * BorderOf (entry);
/* Set some basic values of the entry field. */
entry->label = 0;
entry->labelLen = 0;
entry->labelWin = 0;
/* Translate the label char *pointer to a chtype pointer. */
if (label != 0)
{
entry->label = char2Chtype (label, &entry->labelLen, &junk);
boxWidth += entry->labelLen;
}
oldWidth = boxWidth;
boxWidth = setCdkTitle (ObjOf (entry), title, boxWidth);
horizontalAdjust = (boxWidth - oldWidth) / 2;
boxHeight += TitleLinesOf (entry);
/*
* Make sure we didn't extend beyond the dimensions of the window.
*/
boxWidth = MINIMUM (boxWidth, parentWidth);
boxHeight = MINIMUM (boxHeight, parentHeight);
fieldWidth = MINIMUM (fieldWidth,
boxWidth - entry->labelLen - 2 * BorderOf (entry));
/* Rejustify the x and y positions if we need to. */
alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight);
/* Make the label window. */
entry->win = newwin (boxHeight, boxWidth, ypos, xpos);
if (entry->win == 0)
{
destroyCDKObject (entry);
return (0);
}
keypad (entry->win, TRUE);
/* Make the field window. */
entry->fieldWin = subwin (entry->win, 1, fieldWidth,
(ypos + TitleLinesOf (entry) + BorderOf (entry)),
(xpos + entry->labelLen
+ horizontalAdjust
+ BorderOf (entry)));
if (entry->fieldWin == 0)
{
destroyCDKObject (entry);
return (0);
}
keypad (entry->fieldWin, TRUE);
/* Make the label win, if we need to. */
if (label != 0)
{
entry->labelWin = subwin (entry->win, 1, entry->labelLen,
ypos + TitleLinesOf (entry) + BorderOf (entry),
xpos + horizontalAdjust + BorderOf (entry));
}
/* Make room for the info char * pointer. */
entry->info = typeMallocN (char, max + 3);
if (entry->info == 0)
{
destroyCDKObject (entry);
return (0);
}
cleanChar (entry->info, max + 3, '\0');
entry->infoWidth = max + 3;
/* *INDENT-EQLS* Set up the rest of the structure. */
ScreenOf (entry) = cdkscreen;
entry->parent = cdkscreen->window;
entry->shadowWin = 0;
entry->fieldAttr = fieldAttr;
entry->fieldWidth = fieldWidth;
entry->filler = filler;
entry->hidden = filler;
ObjOf (entry)->inputWindow = entry->fieldWin;
ObjOf (entry)->acceptsFocus = TRUE;
ReturnOf (entry) = NULL;
entry->shadow = shadow;
entry->screenCol = 0;
entry->leftChar = 0;
entry->min = min;
entry->max = max;
entry->boxWidth = boxWidth;
entry->boxHeight = boxHeight;
initExitType (entry);
entry->dispType = dispType;
entry->callbackfn = CDKEntryCallBack;
/* Do we want a shadow? */
if (shadow)
{
entry->shadowWin = newwin (
boxHeight,
boxWidth,
ypos + 1,
xpos + 1);
}
registerCDKObject (cdkscreen, vENTRY, entry);
return (entry);
}
/*
* This means you want to use the given entry field. It takes input
* from the keyboard, and when its done, it fills the entry info
* element of the structure with what was typed.
*/
char *activateCDKEntry (CDKENTRY *entry, chtype *actions)
{
chtype input = 0;
boolean functionKey;
char *ret = 0;
/* Draw the widget. */
drawCDKEntry (entry, ObjOf (entry)->box);
if (actions == 0)
{
for (;;)
{
input = (chtype)getchCDKObject (ObjOf (entry), &functionKey);
/* Inject the character into the widget. */
ret = injectCDKEntry (entry, input);
if (entry->exitType != vEARLY_EXIT)
{
return ret;
}
}
}
else
{
int length = chlen (actions);
int x;
/* Inject each character one at a time. */
for (x = 0; x < length; x++)
{
ret = injectCDKEntry (entry, actions[x]);
if (entry->exitType != vEARLY_EXIT)
{
return ret;
}
}
}
/* Make sure we return the correct info. */
if (entry->exitType == vNORMAL)
{
return entry->info;
}
else
{
return 0;
}
}
static void setPositionToEnd (CDKENTRY *entry)
{
int stringLen;
stringLen = (int)strlen (entry->info);
if (stringLen >= entry->fieldWidth)
{
if (stringLen < entry->max)
{
int charCount = entry->fieldWidth - 1;
entry->leftChar = stringLen - charCount;
entry->screenCol = charCount;
}
else
{
entry->leftChar = stringLen - entry->fieldWidth;
entry->screenCol = stringLen - 1;
}
}
else
{
entry->leftChar = 0;
entry->screenCol = stringLen;
}
}
/*
* This injects a single character into the widget.
*/
static int _injectCDKEntry (CDKOBJS *object, chtype input)
{
CDKENTRY *widget = (CDKENTRY *)object;
int ppReturn = 1;
char *ret = unknownString;
bool complete = FALSE;
/* Set the exit type. */
setExitType (widget, 0);
/* Refresh the widget field. */
drawCDKEntryField (widget);
/* Check if there is a pre-process function to be called. */
if (PreProcessFuncOf (widget) != 0)
{
ppReturn = PreProcessFuncOf (widget) (vENTRY,
widget,
PreProcessDataOf (widget),
input);
}
/* Should we continue? */
if (ppReturn != 0)
{
/* Check a predefined binding... */
if (checkCDKObjectBind (vENTRY, widget, input) != 0)
{
checkEarlyExit (widget);
complete = TRUE;
}
else
{
int infoLength = (int)strlen (widget->info);
int currPos = widget->screenCol + widget->leftChar;
switch (input)
{
case KEY_UP:
case KEY_DOWN:
Beep ();
break;
case KEY_HOME:
widget->leftChar = 0;
widget->screenCol = 0;
drawCDKEntryField (widget);
break;
case CDK_TRANSPOSE:
if (currPos >= infoLength - 1)
{
Beep ();
}
else
{
char holder = widget->info[currPos];
widget->info[currPos] = widget->info[currPos + 1];
widget->info[currPos + 1] = holder;
drawCDKEntryField (widget);
}
break;
case KEY_END:
setPositionToEnd (widget);
drawCDKEntryField (widget);
break;
case KEY_LEFT:
if (currPos <= 0)
{
Beep ();
}
else if (widget->screenCol == 0)
{
/* Scroll left. */
widget->leftChar--;
drawCDKEntryField (widget);
}
else
{
wmove (widget->fieldWin, 0, --widget->screenCol);
}
break;
case KEY_RIGHT:
if (currPos >= infoLength)
{
Beep ();
}
else if (widget->screenCol == widget->fieldWidth - 1)
{
/* Scroll to the right. */
widget->leftChar++;
drawCDKEntryField (widget);
}
else
{
/* Move right. */
wmove (widget->fieldWin, 0, ++widget->screenCol);
}
break;
case KEY_BACKSPACE:
case KEY_DC:
if (widget->dispType == vVIEWONLY)
{
Beep ();
}
else
{
bool success = FALSE;
if (input == KEY_BACKSPACE)
--currPos;
if (currPos >= 0 && infoLength > 0)
{
if (currPos < infoLength)
{
int x;
for (x = currPos; x < infoLength; x++)
{
widget->info[x] = widget->info[x + 1];
}
success = TRUE;
}
else if (input == KEY_BACKSPACE)
{
widget->info[infoLength - 1] = '\0';
success = TRUE;
}
}
if (success)
{
if (input == KEY_BACKSPACE)
{
if (widget->screenCol > 0)
widget->screenCol--;
else
widget->leftChar--;
}
drawCDKEntryField (widget);
}
else
{
Beep ();
}
}
break;
case KEY_ESC:
setExitType (widget, input);
complete = TRUE;
break;
case CDK_ERASE:
if (infoLength != 0)
{
cleanCDKEntry (widget);
drawCDKEntryField (widget);
}
break;
case CDK_CUT:
if (infoLength != 0)
{
freeChar (GPasteBuffer);
GPasteBuffer = copyChar (widget->info);
cleanCDKEntry (widget);
drawCDKEntryField (widget);
}
else
{
Beep ();
}
break;
case CDK_COPY:
if (infoLength != 0)
{
freeChar (GPasteBuffer);
GPasteBuffer = copyChar (widget->info);
}
else
{
Beep ();
}
break;
case CDK_PASTE:
if (GPasteBuffer != 0)
{
setCDKEntryValue (widget, GPasteBuffer);
drawCDKEntryField (widget);
}
else
{
Beep ();
}
break;
case KEY_TAB:
case KEY_ENTER:
if (infoLength >= widget->min)
{
setExitType (widget, input);
ret = (widget->info);
complete = TRUE;
}
else
{
Beep ();
}
break;
case KEY_ERROR:
setExitType (widget, input);
complete = TRUE;
break;
case CDK_REFRESH:
eraseCDKScreen (ScreenOf (widget));
refreshCDKScreen (ScreenOf (widget));
break;
default:
(widget->callbackfn) (widget, input);
break;
}
}
/* Should we do a post-process? */
if (!complete && (PostProcessFuncOf (widget) != 0))
{
PostProcessFuncOf (widget) (vENTRY,
widget,
PostProcessDataOf (widget),
input);
}
}
if (!complete)
setExitType (widget, 0);
ResultOf (widget).valueString = ret;
return (ret != unknownString);
}
/*
* This moves the entry field to the given location.
*/
static void _moveCDKEntry (CDKOBJS *object,
int xplace,
int yplace,
boolean relative,
boolean refresh_flag)
{
/* *INDENT-EQLS* */
CDKENTRY *entry = (CDKENTRY *)object;
int currentX = getbegx (entry->win);
int currentY = getbegy (entry->win);
int xpos = xplace;
int ypos = yplace;
int xdiff = 0;
int ydiff = 0;
/*
* If this is a relative move, then we will adjust where we want
* to move to.
*/
if (relative)
{
xpos = getbegx (entry->win) + xplace;
ypos = getbegy (entry->win) + yplace;
}
/* Adjust the window if we need to. */
alignxy (WindowOf (entry), &xpos, &ypos, entry->boxWidth, entry->boxHeight);
/* Get the difference. */
xdiff = currentX - xpos;
ydiff = currentY - ypos;
/* Move the window to the new location. */
moveCursesWindow (entry->win, -xdiff, -ydiff);
moveCursesWindow (entry->fieldWin, -xdiff, -ydiff);
moveCursesWindow (entry->labelWin, -xdiff, -ydiff);
moveCursesWindow (entry->shadowWin, -xdiff, -ydiff);
/* Touch the windows so they 'move'. */
refreshCDKWindow (WindowOf (entry));
/* Redraw the window, if they asked for it. */
if (refresh_flag)
{
drawCDKEntry (entry, ObjOf (entry)->box);
}
}
/*
* This is a generic character parser for the entry field. It is used as a
* callback function, so any personal modifications can be made by creating
* a new function and calling the activation with its name.
*/
static void CDKEntryCallBack (CDKENTRY *entry, chtype character)
{
int plainchar = filterByDisplayType (entry->dispType, character);
if (plainchar == ERR ||
((int)strlen (entry->info) >= entry->max))
{
Beep ();
}
else
{
/* Update the screen and pointer. */
if (entry->screenCol != entry->fieldWidth - 1)
{
int x;
for (x = (int)strlen (entry->info);
x > (entry->screenCol + entry->leftChar);
x--)
{
entry->info[x] = entry->info[x - 1];
}
entry->info[entry->screenCol + entry->leftChar] = (char)plainchar;
entry->screenCol++;
}
else
{
/* Update the character pointer. */
size_t temp = strlen (entry->info);
entry->info[temp] = (char)plainchar;
entry->info[temp + 1] = '\0';
/* Do not update the pointer if it's the last character */
if ((int)(temp + 1) < entry->max)
entry->leftChar++;
}
/* Update the entry field. */
drawCDKEntryField (entry);
}
}
/*
* This erases the information in the entry field
* and redraws a clean and empty entry field.
*/
void cleanCDKEntry (CDKENTRY *entry)
{
int width = entry->fieldWidth;
/* Erase the information in the character pointer. */
cleanChar (entry->info, entry->infoWidth, '\0');
/* Clean the entry screen field. */
(void)mvwhline (entry->fieldWin, 0, 0, entry->filler, width);
/* Reset some variables. */
entry->screenCol = 0;
entry->leftChar = 0;
/* Refresh the entry field. */
wrefresh (entry->fieldWin);
}
/*
* This draws the entry field.
*/
static void _drawCDKEntry (CDKOBJS *object, boolean Box)
{
CDKENTRY *entry = (CDKENTRY *)object;
/* Did we ask for a shadow? */
if (entry->shadowWin != 0)
{
drawShadow (entry->shadowWin);
}
/* Box the widget if asked. */
if (Box)
{
drawObjBox (entry->win, ObjOf (entry));
}
drawCdkTitle (entry->win, object);
wrefresh (entry->win);
/* Draw in the label to the widget. */
if (entry->labelWin != 0)
{
writeChtype (entry->labelWin, 0, 0, entry->label, HORIZONTAL, 0, entry->labelLen);
wrefresh (entry->labelWin);
}
drawCDKEntryField (entry);
}
/*
* This redraws the entry field.
*/
static void drawCDKEntryField (CDKENTRY *entry)
{
int x = 0;
/* Set background color and attributes of the entry field */
wbkgd (entry->fieldWin, entry->fieldAttr);
/* Draw in the filler characters. */
(void)mvwhline (entry->fieldWin, 0, x, entry->filler | entry->fieldAttr, entry->fieldWidth);
/* If there is information in the field. Then draw it in. */
if (entry->info != 0)
{
int infoLength = (int)strlen (entry->info);
/* Redraw the field. */
if (isHiddenDisplayType (entry->dispType))
{
for (x = entry->leftChar; x < infoLength; x++)
{
(void)mvwaddch (entry->fieldWin, 0, x - entry->leftChar,
entry->hidden | entry->fieldAttr);
}
}
else
{
for (x = entry->leftChar; x < infoLength; x++)
{
(void)mvwaddch (entry->fieldWin, 0, x - entry->leftChar,
CharOf (entry->info[x]) | entry->fieldAttr);
}
}
wmove (entry->fieldWin, 0, entry->screenCol);
}
wrefresh (entry->fieldWin);
}
/*
* This erases an entry widget from the screen.
*/
static void _eraseCDKEntry (CDKOBJS *object)
{
if (validCDKObject (object))
{
CDKENTRY *entry = (CDKENTRY *)object;
eraseCursesWindow (entry->fieldWin);
eraseCursesWindow (entry->labelWin);
eraseCursesWindow (entry->win);
eraseCursesWindow (entry->shadowWin);
}
}
/*
* This destroys an entry widget.
*/
static void _destroyCDKEntry (CDKOBJS *object)
{
if (object != 0)
{
CDKENTRY *entry = (CDKENTRY *)object;
cleanCdkTitle (object);
freeChtype (entry->label);
freeChar (entry->info);
/* Delete the windows. */
deleteCursesWindow (entry->fieldWin);
deleteCursesWindow (entry->labelWin);
deleteCursesWindow (entry->shadowWin);
deleteCursesWindow (entry->win);
/* Clean the key bindings. */
cleanCDKObjectBindings (vENTRY, entry);
/* Unregister this object. */
unregisterCDKObject (vENTRY, entry);
}
}
/*
* This sets specific attributes of the entry field.
*/
void setCDKEntry (CDKENTRY *entry,
const char *value,
int min,
int max,
boolean Box GCC_UNUSED)
{
setCDKEntryValue (entry, value);
setCDKEntryMin (entry, min);
setCDKEntryMax (entry, max);
}
/*
* This removes the old information in the entry field and keeps the
* new information given.
*/
void setCDKEntryValue (CDKENTRY *entry, const char *newValue)
{
/* If the pointer sent in is the same pointer as before, do nothing. */
if (entry->info != newValue)
{
/* Just to be sure, if lets make sure the new value isn't null. */
if (newValue == 0)
{
/* Then we want to just erase the old value. */
cleanChar (entry->info, entry->infoWidth, '\0');
/* Set the pointers back to zero. */
entry->leftChar = 0;
entry->screenCol = 0;
}
else
{
/* Determine how many characters we need to copy. */
int copychars = MINIMUM ((int)strlen (newValue), entry->max);
/* OK, erase the old value, and copy in the new value. */
cleanChar (entry->info, entry->max, '\0');
strncpy (entry->info, newValue, (unsigned)copychars);
setPositionToEnd (entry);
}
}
}
char *getCDKEntryValue (CDKENTRY *entry)
{
return entry->info;
}
/*
* This sets the maximum length of the string that will be accepted.
*/
void setCDKEntryMax (CDKENTRY *entry, int max)
{
entry->max = max;
}
int getCDKEntryMax (CDKENTRY *entry)
{
return entry->max;
}
/*
* This sets the minimum length of the string that will
* be accepted.
*/
void setCDKEntryMin (CDKENTRY *entry, int min)
{
entry->min = min;
}
int getCDKEntryMin (CDKENTRY *entry)
{
return entry->min;
}
/*
* This sets the filler character to be used in the entry field.
*/
void setCDKEntryFillerChar (CDKENTRY *entry, chtype fillerCharacter)
{
entry->filler = fillerCharacter;
}
chtype getCDKEntryFillerChar (CDKENTRY *entry)
{
return entry->filler;
}
/*
* This sets the character to use when a hidden type is used.
*/
void setCDKEntryHiddenChar (CDKENTRY *entry, chtype hiddenCharacter)
{
entry->hidden = hiddenCharacter;
}
chtype getCDKEntryHiddenChar (CDKENTRY *entry)
{
return entry->hidden;
}
/*
* This sets the widgets box attribute.
*/
void setCDKEntryBox (CDKENTRY *entry, boolean Box)
{
ObjOf (entry)->box = Box;
ObjOf (entry)->borderSize = Box ? 1 : 0;
}
boolean getCDKEntryBox (CDKENTRY *entry)
{
return ObjOf (entry)->box;
}
/*
* This sets the background attribute of the widget.
*/
static void _setBKattrEntry (CDKOBJS *object, chtype attrib)
{
if (object != 0)
{
CDKENTRY *widget = (CDKENTRY *)object;
wbkgd (widget->win, attrib);
wbkgd (widget->fieldWin, attrib);
if (widget->labelWin != 0)
{
wbkgd (widget->labelWin, attrib);
}
}
}
/*
* This sets the attribute of the entry field.
*/
void setCDKEntryHighlight (CDKENTRY *entry, chtype highlight, boolean cursor)
{
wbkgd (entry->fieldWin, highlight);
entry->fieldAttr = highlight;
curs_set (cursor);
/*
* FIXME - if (cursor) { move the cursor to this widget }
*/
}
/*
* This sets the entry field callback function.
*/
void setCDKEntryCB (CDKENTRY *entry, ENTRYCB callback)
{
entry->callbackfn = callback;
}
static void _focusCDKEntry (CDKOBJS *object)
{
CDKENTRY *entry = (CDKENTRY *)object;
wmove (entry->fieldWin, 0, entry->screenCol);
wrefresh (entry->fieldWin);
}
static void _unfocusCDKEntry (CDKOBJS *object)
{
CDKENTRY *entry = (CDKENTRY *)object;
drawCDKEntry (entry, ObjOf (entry)->box);
wrefresh (entry->fieldWin);
}
#if 0
static void _refreshDataCDKEntry (CDKOBJS *object)
{
CDKENTRY *entry = (CDKENTRY *)object;
if (ReturnOf (entry))
{
switch (DataTypeOf (entry))
{
default:
case DataTypeString:
strcpy (entry->info, (char *)ReturnOf (entry));
break;
case DataTypeInt:
sprintf (entry->info, "%d", *((int *)ReturnOf (entry)));
break;
case DataTypeFloat:
sprintf (entry->info, "%g", *((float *)ReturnOf (entry)));
break;
case DataTypeDouble:
sprintf (entry->info, "%g", *((double *)ReturnOf (entry)));
break;
}
entry->screenCol = strlen (entry->info);
drawCDKEntryField (entry);
}
}
static void _saveDataCDKEntry (CDKOBJS *object)
{
CDKENTRY *entry = (CDKENTRY *)object;
if (ReturnOf (entry))
{
switch (DataTypeOf (entry))
{
default:
case DataTypeString:
strcpy ((char *)ReturnOf (entry), entry->info);
break;
case DataTypeInt:
*((int *)ReturnOf (entry)) = atoi (entry->info);
break;
case DataTypeFloat:
*((float *)ReturnOf (entry)) = atof (entry->info);
break;
case DataTypeDouble:
*((double *)ReturnOf (entry)) = atof (entry->info);
break;
}
}
}
#else
dummyRefreshData (Entry)
dummySaveData (Entry)
#endif

View File

@ -0,0 +1,167 @@
# $Id: Makefile.in,v 1.22 2016/11/20 19:41:20 tom Exp $
#
# Makefile for the examples directory.
#
SHELL = /bin/sh
prefix = @prefix@
exec_prefix = @exec_prefix@
srcdir = @srcdir@
VPATH = $(srcdir)
CC = @CC@
RM = rm -f
CTAGS = @CTAGS@
ETAGS = @ETAGS@
LINT = @LINT@
LINT_OPTS = @LINT_OPTS@
LIBS = -l@LIB_ROOTNAME@ @LIBS@
LIBTOOL = @LIBTOOL@ @ECHO_LT@
LIBTOOL_CLEAN = @LIB_CLEAN@
LIBTOOL_LINK = @LIB_LINK@
LINK = $(LIBTOOL_LINK)
x = @EXEEXT@
o = .@OBJEXT@
LOCAL_LIBDIR = @top_builddir@
CFLAGS = @CFLAGS@ @EXTRA_CFLAGS@
CPPFLAGS = @DEFS@ -I../include -I$(srcdir)/../include -I. @CPPFLAGS@
LDFLAGS = -L.. @LDFLAGS@ @LOCAL_LDFLAGS@
BINS = \
alphalist_ex$x \
bind_ex$x \
buttonbox_ex$x \
calendar_ex$x \
cdkscreen_ex$x \
dialog_ex$x \
entry_ex$x \
fscale_ex$x \
fselect_ex$x \
fslider_ex$x \
graph_ex$x \
hello_ex$x \
histogram_ex$x \
itemlist_ex$x \
label_ex$x \
lowerCDKObject_ex$x \
marquee_ex$x \
matrix_ex$x \
mentry_ex$x \
menu_ex$x \
position_ex$x \
preprocess_ex$x \
radio1_ex$x \
radio_ex$x \
raiseCDKObject_ex$x \
scale_ex$x \
scroll_ex$x \
selection_ex$x \
slider_ex$x \
subwindow_ex$x \
swindow_ex$x \
template_ex$x \
traverse_ex$x \
uslider_ex$x \
viewer_ex$x \
viewer_ex2$x
CDKSRC = \
alphalist_ex.c \
bind_ex.c \
buttonbox_ex.c \
calendar_ex.c \
cdkscreen_ex.c \
dialog_ex.c \
entry_ex.c \
fscale_ex.c \
fselect_ex.c \
fslider_ex.c \
graph_ex.c \
hello_ex.c \
histogram_ex.c \
itemlist_ex.c \
label_ex.c \
lowerCDKObject_ex.c \
marquee_ex.c \
matrix_ex.c \
mentry_ex.c \
menu_ex.c \
position_ex.c \
preprocess_ex.c \
radio1_ex.c \
radio_ex.c \
raiseCDKObject_ex.c \
scale_ex.c \
scroll_ex.c \
selection_ex.c \
slider_ex.c \
subwindow_ex.c \
swindow_ex.c \
template_ex.c \
traverse_ex.c \
uslider_ex.c \
viewer_ex.c \
viewer_ex2.c
LINKIT = @ECHO_LD@$(LINK) $(CFLAGS) $(CPPFLAGS) $? -o $@ $(LDFLAGS) $(LIBS)
all : $(BINS)
alphalist_ex$x : alphalist_ex.c ; $(LINKIT)
bind_ex$x : bind_ex.c ; $(LINKIT)
buttonbox_ex$x : buttonbox_ex.c ; $(LINKIT)
calendar_ex$x : calendar_ex.c ; $(LINKIT)
cdkscreen_ex$x : cdkscreen_ex.c ; $(LINKIT)
dialog_ex$x : dialog_ex.c ; $(LINKIT)
entry_ex$x : entry_ex.c ; $(LINKIT)
fscale_ex$x : fscale_ex.c ; $(LINKIT)
fselect_ex$x : fselect_ex.c ; $(LINKIT)
fslider_ex$x : fslider_ex.c ; $(LINKIT)
graph_ex$x : graph_ex.c ; $(LINKIT)
hello_ex$x : hello_ex.c ; $(LINKIT)
histogram_ex$x : histogram_ex.c ; $(LINKIT)
itemlist_ex$x : itemlist_ex.c ; $(LINKIT)
label_ex$x : label_ex.c ; $(LINKIT)
lowerCDKObject_ex$x : lowerCDKObject_ex.c ; $(LINKIT)
marquee_ex$x : marquee_ex.c ; $(LINKIT)
matrix_ex$x : matrix_ex.c ; $(LINKIT)
mentry_ex$x : mentry_ex.c ; $(LINKIT)
menu_ex$x : menu_ex.c ; $(LINKIT)
position_ex$x : position_ex.c ; $(LINKIT)
preprocess_ex$x : preprocess_ex.c ; $(LINKIT)
radio1_ex$x : radio1_ex.c ; $(LINKIT)
radio_ex$x : radio_ex.c ; $(LINKIT)
raiseCDKObject_ex$x : raiseCDKObject_ex.c ; $(LINKIT)
scale_ex$x : scale_ex.c ; $(LINKIT)
scroll_ex$x : scroll_ex.c ; $(LINKIT)
selection_ex$x : selection_ex.c ; $(LINKIT)
slider_ex$x : slider_ex.c ; $(LINKIT)
subwindow_ex$x : subwindow_ex.c ; $(LINKIT)
swindow_ex$x : swindow_ex.c ; $(LINKIT)
template_ex$x : template_ex.c ; $(LINKIT)
traverse_ex$x : traverse_ex.c ; $(LINKIT)
uslider_ex$x : uslider_ex.c ; $(LINKIT)
viewer_ex$x : viewer_ex.c ; $(LINKIT)
viewer_ex2$x : viewer_ex2.c ; $(LINKIT)
#
# Standard clean directives.
#
clean::
-$(LIBTOOL_CLEAN) $(RM) *.o core $(BINS)
distclean:: clean
$(RM) Makefile
@MAKE_LOWER_TAGS@tags :
@MAKE_LOWER_TAGS@ $(CTAGS) *.[ch] */*.[ch]
@MAKE_LOWER_TAGS@TAGS :
@MAKE_LOWER_TAGS@ $(ETAGS) *.[ch] */*.[ch]
lint: $(CDKSRC)
$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(CDKSRC)

View File

@ -0,0 +1,293 @@
/* $Id: alphalist_ex.c,v 1.30 2016/12/04 15:38:55 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "alphalist_ex";
#endif
/*
* This program demonstrates the Cdk alphalist widget.
*
* Options (in addition to normal CLI parameters):
* -c create the data after the widget
*/
static CDKSCREEN *cdkscreen = 0;
static char **myUserList = 0;
static int userSize;
typedef struct
{
int deleted; /* index in current list which is deleted */
int original; /* index in myUserList[] of deleted item */
int position; /* position before delete */
int topline; /* top-line before delete */
} UNDO;
static UNDO *myUndoList;
static int undoSize;
/*
* This reads the passwd file and retrieves user information.
*/
static int getUserList (char ***list)
{
#if defined (HAVE_PWD_H)
struct passwd *ent;
#endif
int x = 0;
unsigned used = 0;
#if defined (HAVE_PWD_H)
while ((ent = getpwent ()) != 0)
{
used = CDKallocStrings (list, ent->pw_name, (unsigned)x++, used);
}
endpwent ();
#endif
return x;
}
#define CB_PARAMS EObjectType cdktype GCC_UNUSED, void* object GCC_UNUSED, void* clientdata GCC_UNUSED, chtype key GCC_UNUSED
static void fill_undo (CDKALPHALIST *widget, int deleted, char *data)
{
int top = getCDKScrollCurrentTop (widget->scrollField);
int item = getCDKAlphalistCurrentItem (widget);
int n;
myUndoList[undoSize].deleted = deleted;
myUndoList[undoSize].topline = top;
myUndoList[undoSize].original = -1;
myUndoList[undoSize].position = item;
for (n = 0; n < userSize; ++n)
{
if (!strcmp (myUserList[n], data))
{
myUndoList[undoSize].original = n;
break;
}
}
++undoSize;
}
static int do_delete (CB_PARAMS)
{
CDKALPHALIST *widget = (CDKALPHALIST *)clientdata;
int size;
char **list = getCDKAlphalistContents (widget, &size);
int result = FALSE;
if (size)
{
int save = getCDKScrollCurrentTop (widget->scrollField);
int first = getCDKAlphalistCurrentItem (widget);
int n;
fill_undo (widget, first, list[first]);
for (n = first; n < size; ++n)
list[n] = list[n + 1];
setCDKAlphalistContents (widget, (CDK_CSTRING *)list, size - 1);
setCDKScrollCurrentTop (widget->scrollField, save);
setCDKAlphalistCurrentItem (widget, first);
drawCDKAlphalist (widget, BorderOf (widget));
result = TRUE;
}
return result;
}
static int do_delete1 (CB_PARAMS)
{
CDKALPHALIST *widget = (CDKALPHALIST *)clientdata;
int size;
char **list = getCDKAlphalistContents (widget, &size);
int result = FALSE;
if (size)
{
int save = getCDKScrollCurrentTop (widget->scrollField);
int first = getCDKAlphalistCurrentItem (widget);
if (first-- > 0)
{
int n;
fill_undo (widget, first, list[first]);
for (n = first; n < size; ++n)
list[n] = list[n + 1];
setCDKAlphalistContents (widget, (CDK_CSTRING *)list, size - 1);
setCDKScrollCurrentTop (widget->scrollField, save);
setCDKAlphalistCurrentItem (widget, first);
drawCDKAlphalist (widget, BorderOf (widget));
result = TRUE;
}
}
return result;
}
static int do_help (CB_PARAMS)
{
static const char *message[] =
{
"Alpha List tests:",
"",
"F1 = help (this message)",
"F2 = delete current item",
"F3 = delete previous item",
"F4 = reload all items",
"F5 = undo deletion",
0
};
popupLabel (cdkscreen,
(CDK_CSTRING2)message,
(int)CDKcountStrings ((CDK_CSTRING2)message));
return TRUE;
}
static int do_reload (CB_PARAMS)
{
int result = FALSE;
if (userSize)
{
CDKALPHALIST *widget = (CDKALPHALIST *)clientdata;
setCDKAlphalistContents (widget, (CDK_CSTRING *)myUserList, userSize);
setCDKAlphalistCurrentItem (widget, 0);
drawCDKAlphalist (widget, BorderOf (widget));
result = TRUE;
}
return result;
}
static int do_undo (CB_PARAMS)
{
int result = FALSE;
if (undoSize > 0)
{
CDKALPHALIST *widget = (CDKALPHALIST *)clientdata;
int size;
int n;
char **oldlist = getCDKAlphalistContents (widget, &size);
char **newlist = (char **)malloc ((size_t) (++size + 1) * sizeof (char *));
--undoSize;
newlist[size] = 0;
for (n = size - 1; n > myUndoList[undoSize].deleted; --n)
{
newlist[n] = copyChar (oldlist[n - 1]);
}
newlist[n--] = copyChar (myUserList[myUndoList[undoSize].original]);
while (n >= 0)
{
newlist[n] = copyChar (oldlist[n]);
--n;
}
setCDKAlphalistContents (widget, (CDK_CSTRING *)newlist, size);
setCDKScrollCurrentTop (widget->scrollField, myUndoList[undoSize].topline);
setCDKAlphalistCurrentItem (widget, myUndoList[undoSize].position);
drawCDKAlphalist (widget, BorderOf (widget));
free (newlist);
result = TRUE;
}
return result;
}
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKALPHALIST *alphaList = 0;
const char *title = "<C></B/24>Alpha List\n<C>Title";
const char *label = "</B>Account: ";
char *word = 0;
char **userList = 0;
const char *mesg[5];
char temp[256];
CDK_PARAMS params;
CDKparseParams (argc, argv, &params, "c" CDK_CLI_PARAMS);
/* Get the user list. */
userSize = getUserList (&userList);
if (userSize <= 0)
{
fprintf (stderr, "Cannot get user list\n");
ExitProgram (EXIT_FAILURE);
}
myUserList = copyCharList ((const char **)userList);
myUndoList = (UNDO *) malloc ((size_t) userSize * sizeof (UNDO));
undoSize = 0;
cdkscreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Create the alpha list widget. */
alphaList = newCDKAlphalist (cdkscreen,
CDKparamValue (&params, 'X', CENTER),
CDKparamValue (&params, 'Y', CENTER),
CDKparamValue (&params, 'H', 0),
CDKparamValue (&params, 'W', 0),
title, label,
(CDKparamNumber (&params, 'c')
? 0
: (CDK_CSTRING *)userList),
(CDKparamNumber (&params, 'c')
? 0
: userSize),
'_', A_REVERSE,
CDKparamValue (&params, 'N', TRUE),
CDKparamValue (&params, 'S', FALSE));
if (alphaList == 0)
{
destroyCDKScreen (cdkscreen);
endCDK ();
fprintf (stderr, "Cannot create widget\n");
ExitProgram (EXIT_FAILURE);
}
bindCDKObject (vALPHALIST, alphaList, '?', do_help, NULL);
bindCDKObject (vALPHALIST, alphaList, KEY_F1, do_help, NULL);
bindCDKObject (vALPHALIST, alphaList, KEY_F2, do_delete, alphaList);
bindCDKObject (vALPHALIST, alphaList, KEY_F3, do_delete1, alphaList);
bindCDKObject (vALPHALIST, alphaList, KEY_F4, do_reload, alphaList);
bindCDKObject (vALPHALIST, alphaList, KEY_F5, do_undo, alphaList);
if (CDKparamNumber (&params, 'c'))
{
setCDKAlphalistContents (alphaList, (CDK_CSTRING *)userList, userSize);
}
/* Let them play with the alpha list. */
word = activateCDKAlphalist (alphaList, 0);
/* Determine what the user did. */
if (alphaList->exitType == vESCAPE_HIT)
{
mesg[0] = "<C>You hit escape. No word was selected.";
mesg[1] = "";
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
}
else if (alphaList->exitType == vNORMAL)
{
mesg[0] = "<C>You selected the following";
sprintf (temp, "<C>(%.*s)", (int)(sizeof (temp) - 10), word);
mesg[1] = temp;
mesg[2] = "";
mesg[3] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 4);
}
freeCharList (myUserList, (unsigned)userSize);
free (myUserList);
destroyCDKAlphalist (alphaList);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}

164
deps/cdk-5.0-20161210/examples/bind_ex.c vendored Normal file
View File

@ -0,0 +1,164 @@
/* $Id: bind_ex.c,v 1.20 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "bind_ex";
#endif
static int dialogHelpCB (EObjectType cdktype GCC_UNUSED,
void *object,
void *clientData GCC_UNUSED,
chtype key GCC_UNUSED)
{
CDKDIALOG *dialog = (CDKDIALOG *)object;
const char *mesg[5];
/* Check which button we are on. */
if (dialog->currentButton == 0)
{
mesg[0] = "<C></U>Help for </U>Who<!U>.";
mesg[1] = "<C>When this button is picked the name of the current";
mesg[2] = "<C>user is displayed on the screen in a popup window.";
popupLabel (ScreenOf (dialog), (CDK_CSTRING2) mesg, 3);
}
else if (dialog->currentButton == 1)
{
mesg[0] = "<C></U>Help for </U>Time<!U>.";
mesg[1] = "<C>When this button is picked the current time is";
mesg[2] = "<C>displayed on the screen in a popup window.";
popupLabel (ScreenOf (dialog), (CDK_CSTRING2) mesg, 3);
}
else if (dialog->currentButton == 2)
{
mesg[0] = "<C></U>Help for </U>Date<!U>.";
mesg[1] = "<C>When this button is picked the current date is";
mesg[2] = "<C>displayed on the screen in a popup window.";
popupLabel (ScreenOf (dialog), (CDK_CSTRING2) mesg, 3);
}
else if (dialog->currentButton == 3)
{
mesg[0] = "<C></U>Help for </U>Quit<!U>.";
mesg[1] = "<C>When this button is picked the dialog box is exited.";
popupLabel (ScreenOf (dialog), (CDK_CSTRING2) mesg, 2);
}
return (FALSE);
}
int main (int argc, char **argv)
{
/* *INDENT-OFF* */
CDKSCREEN *cdkscreen;
CDKDIALOG *question;
const char *buttons[40];
const char *message[40];
const char *info[5];
char *loginName = 0;
char temp[256];
int selection;
time_t clck;
struct tm *currentTime;
CDK_PARAMS params;
/* *INDENT-ON* */
CDKparseParams (argc, argv, &params, CDK_MIN_PARAMS);
cdkscreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Set up the dialog box. */
message[0] = "<C></U>Simple Command Interface";
message[1] = "Pick the command you wish to run.";
message[2] = "<C>Press </R>?<!R> for help.";
buttons[0] = "Who";
buttons[1] = "Time";
buttons[2] = "Date";
buttons[3] = "Quit";
/* Create the dialog box. */
question = newCDKDialog (cdkscreen,
CDKparamValue (&params, 'X', CENTER),
CDKparamValue (&params, 'Y', CENTER),
(CDK_CSTRING2) message, 3,
(CDK_CSTRING2) buttons, 4,
A_REVERSE,
TRUE,
CDKparamValue (&params, 'N', TRUE),
CDKparamValue (&params, 'S', FALSE));
/* Check if we got a null value back. */
if (question == (CDKDIALOG *)0)
{
destroyCDKScreen (cdkscreen);
/* End curses... */
endCDK ();
printf ("Cannot create the dialog box. ");
printf ("Is the window too small?\n");
ExitProgram (EXIT_FAILURE);
}
/* Create the key binding. */
bindCDKObject (vDIALOG, question, '?', dialogHelpCB, 0);
/* Activate the dialog box. */
selection = 0;
while (selection != 3)
{
/* Get the users button selection. */
selection = activateCDKDialog (question, (chtype *)0);
/* Check the results. */
if (selection == 0)
{
/* Get the users login name. */
info[0] = "<C> </U>Login Name<!U> ";
#if defined (HAVE_GETLOGIN)
loginName = getlogin ();
#endif
if (loginName == (char *)0)
{
strcpy (temp, "<C></R>Unknown");
}
else
{
sprintf (temp, "<C><%.*s>", (int)(sizeof (temp) - 10), loginName);
}
info[1] = temp;
popupLabel (ScreenOf (question), (CDK_CSTRING2) info, 2);
}
else if (selection == 1)
{
time (&clck);
currentTime = localtime (&clck);
sprintf (temp, "<C>%2d:%02d:%02d",
currentTime->tm_hour,
currentTime->tm_min,
currentTime->tm_sec);
info[0] = "<C> </U>Current Time<!U> ";
info[1] = temp;
popupLabel (ScreenOf (question), (CDK_CSTRING2) info, 2);
}
else if (selection == 2)
{
time (&clck);
currentTime = localtime (&clck);
sprintf (temp, "<C>%d/%02d/%02d",
currentTime->tm_mday,
currentTime->tm_mon + 1,
currentTime->tm_year % 100);
info[0] = "<C> </U>Current Date<!U> ";
info[1] = temp;
popupLabel (ScreenOf (question), (CDK_CSTRING2) info, 2);
}
}
/* Clean up. */
destroyCDKDialog (question);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}

View File

@ -0,0 +1,102 @@
/* $Id: buttonbox_ex.c,v 1.21 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "buttonbox_ex";
#endif
static BINDFN_PROTO (entryCB);
/*
* This program demonstrates the Cdk buttonbox widget.
*/
int main (void)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkscreen = 0;
CDKBUTTONBOX *buttonWidget = 0;
CDKENTRY *entry = 0;
const char *buttons[] =
{
" OK ",
" Cancel "
};
char *info = 0;
int selection;
cdkscreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Create the entry widget. */
entry = newCDKEntry (cdkscreen, CENTER, CENTER,
"<C>Enter a name", "Name ", A_NORMAL, '.', vMIXED,
40, 0, 256, TRUE, FALSE);
if (entry == 0)
{
destroyCDKScreen (cdkscreen);
endCDK ();
fprintf (stderr, "Cannot create entry-widget\n");
ExitProgram (EXIT_FAILURE);
}
/* Create the button box widget. */
buttonWidget = newCDKButtonbox (cdkscreen,
getbegx (entry->win),
getbegy (entry->win) + entry->boxHeight - 1,
1, entry->boxWidth - 1,
0, 1, 2,
(CDK_CSTRING2) buttons, 2, A_REVERSE,
TRUE, FALSE);
if (buttonWidget == 0)
{
destroyCDKScreen (cdkscreen);
endCDK ();
fprintf (stderr, "Cannot create buttonbox-widget\n");
ExitProgram (EXIT_FAILURE);
}
/* Set the lower left and right characters of the box. */
setCDKEntryLLChar (entry, ACS_LTEE);
setCDKEntryLRChar (entry, ACS_RTEE);
setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
/*
* Bind the Tab key in the entry field to send a
* Tab key to the button box widget.
*/
bindCDKObject (vENTRY, entry, KEY_TAB, entryCB, buttonWidget);
/* Activate the entry field. */
drawCDKButtonbox (buttonWidget, TRUE);
info = copyChar (activateCDKEntry (entry, 0));
selection = buttonWidget->currentButton;
/* Clean up. */
destroyCDKButtonbox (buttonWidget);
destroyCDKEntry (entry);
destroyCDKScreen (cdkscreen);
endCDK ();
printf ("You typed in (%s) and selected button (%s)\n",
(info != 0) ? info : "<null>",
buttons[selection]);
freeChar (info);
ExitProgram (EXIT_SUCCESS);
}
static int entryCB (EObjectType cdktype GCC_UNUSED,
void *object GCC_UNUSED,
void *clientData, chtype key)
{
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
(void)injectCDKButtonbox (buttonbox, key);
return (TRUE);
}

View File

@ -0,0 +1,155 @@
/* $Id: calendar_ex.c,v 1.17 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "calendar_ex";
#endif
static BINDFN_PROTO (createCalendarMarkCB);
static BINDFN_PROTO (removeCalendarMarkCB);
/*
* This program demonstrates the Cdk calendar widget.
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkscreen = 0;
CDKCALENDAR *calendar = 0;
const char *mesg[5];
char temp[256];
struct tm *dateInfo;
time_t clck, retVal;
CDK_PARAMS params;
char *title;
int day;
int month;
int year;
/*
* Get the current dates and set the default values for
* the day/month/year values for the calendar.
*/
time (&clck);
dateInfo = gmtime (&clck);
/* *INDENT-EQLS* */
CDKparseParams (argc, argv, &params, "d:m:y:t:w:" CDK_MIN_PARAMS);
day = CDKparamNumber2 (&params, 'd', dateInfo->tm_mday);
month = CDKparamNumber2 (&params, 'm', dateInfo->tm_mon + 1);
year = CDKparamNumber2 (&params, 'y', dateInfo->tm_year + 1900);
title = CDKparamString2 (&params, 't', "<C></U>CDK Calendar Widget\n<C>Demo");
cdkscreen = initCDKScreen (NULL);
/* Start CDK Colors. */
initCDKColor ();
/* Create the calendar widget. */
calendar = newCDKCalendar (cdkscreen,
CDKparamValue (&params, 'X', CENTER),
CDKparamValue (&params, 'Y', CENTER),
title, day, month, year,
COLOR_PAIR (16) | A_BOLD,
COLOR_PAIR (24) | A_BOLD,
COLOR_PAIR (32) | A_BOLD,
COLOR_PAIR (40) | A_REVERSE,
CDKparamValue (&params, 'N', TRUE),
CDKparamValue (&params, 'S', FALSE));
/* Is the widget null? */
if (calendar == 0)
{
/* Clean up the memory. */
destroyCDKScreen (cdkscreen);
/* End curses... */
endCDK ();
printf ("Cannot create the calendar. Is the window too small?\n");
ExitProgram (EXIT_FAILURE);
}
/* Create a key binding to mark days on the calendar. */
bindCDKObject (vCALENDAR, calendar, 'm', createCalendarMarkCB, calendar);
bindCDKObject (vCALENDAR, calendar, 'M', createCalendarMarkCB, calendar);
bindCDKObject (vCALENDAR, calendar, 'r', removeCalendarMarkCB, calendar);
bindCDKObject (vCALENDAR, calendar, 'R', removeCalendarMarkCB, calendar);
calendar->weekBase = CDKparamNumber (&params, 'w');
/* Draw the calendar widget. */
drawCDKCalendar (calendar, ObjOf (calendar)->box);
/* Let the user play with the widget. */
retVal = activateCDKCalendar (calendar, 0);
/* Check which day they selected. */
if (calendar->exitType == vESCAPE_HIT)
{
mesg[0] = "<C>You hit escape. No date selected.";
mesg[1] = "";
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
}
else if (calendar->exitType == vNORMAL)
{
mesg[0] = "You selected the following date";
sprintf (temp, "<C></B/16>%02d/%02d/%d (dd/mm/yyyy)",
calendar->day,
calendar->month,
calendar->year);
mesg[1] = temp;
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
}
/* Clean up and exit. */
destroyCDKCalendar (calendar);
destroyCDKScreen (cdkscreen);
endCDK ();
fflush (stdout);
printf ("Selected Time: %s\n", ctime (&retVal));
ExitProgram (EXIT_SUCCESS);
}
/*
* This adds a marker to the calendar.
*/
static int createCalendarMarkCB (EObjectType objectType GCC_UNUSED,
void *object,
void *clientData GCC_UNUSED,
chtype key GCC_UNUSED)
{
CDKCALENDAR *calendar = (CDKCALENDAR *)object;
setCDKCalendarMarker (calendar,
calendar->day,
calendar->month,
calendar->year,
COLOR_PAIR (5) | A_REVERSE);
drawCDKCalendar (calendar, ObjOf (calendar)->box);
return (FALSE);
}
/*
* This removes a marker from the calendar.
*/
static int removeCalendarMarkCB (EObjectType objectType GCC_UNUSED,
void *object,
void *clientData GCC_UNUSED,
chtype key GCC_UNUSED)
{
CDKCALENDAR *calendar = (CDKCALENDAR *)object;
removeCDKCalendarMarker (calendar,
calendar->day,
calendar->month,
calendar->year);
drawCDKCalendar (calendar, ObjOf (calendar)->box);
return (FALSE);
}

View File

@ -0,0 +1,134 @@
/* $Id: cdkscreen_ex.c,v 1.9 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
/*
* This demonstrates how to create four different Cdk
* screens and flip between them.
*/
#ifdef HAVE_XCURSES
char *XCursesProgramName = "cdkscreen_ex";
#endif
int main (void)
{
CDKSCREEN *cdkScreen1, *cdkScreen2;
CDKSCREEN *cdkScreen3, *cdkScreen4;
CDKSCREEN *cdkScreen5;
CDKLABEL *label1, *label2;
CDKLABEL *label3, *label4;
CDKDIALOG *dialog;
const char *title1Mesg[4];
const char *title2Mesg[4];
const char *title3Mesg[4];
const char *title4Mesg[4];
const char *dialogMesg[10];
const char *buttons[] =
{
"Continue",
"Exit"
};
/* Create the screens. */
cdkScreen1 = initCDKScreen (NULL);
cdkScreen2 = initCDKScreen (stdscr);
cdkScreen3 = initCDKScreen (stdscr);
cdkScreen4 = initCDKScreen (stdscr);
cdkScreen5 = initCDKScreen (stdscr);
/* Create the first screen. */
title1Mesg[0] = "<C><#HL(30)>";
title1Mesg[1] = "<C></R>This is the first screen.";
title1Mesg[2] = "<C>Hit space to go to the next screen";
title1Mesg[3] = "<C><#HL(30)>";
label1 = newCDKLabel (cdkScreen1, CENTER, TOP,
(CDK_CSTRING2)title1Mesg, 4,
FALSE, FALSE);
/* Create the second screen. */
title2Mesg[0] = "<C><#HL(30)>";
title2Mesg[1] = "<C></R>This is the second screen.";
title2Mesg[2] = "<C>Hit space to go to the next screen";
title2Mesg[3] = "<C><#HL(30)>";
label2 = newCDKLabel (cdkScreen2, RIGHT, CENTER,
(CDK_CSTRING2)title2Mesg, 4,
FALSE, FALSE);
/* Create the third screen. */
title3Mesg[0] = "<C><#HL(30)>";
title3Mesg[1] = "<C></R>This is the third screen.";
title3Mesg[2] = "<C>Hit space to go to the next screen";
title3Mesg[3] = "<C><#HL(30)>";
label3 = newCDKLabel (cdkScreen3, CENTER, BOTTOM,
(CDK_CSTRING2)title3Mesg, 4,
FALSE, FALSE);
/* Create the fourth screen. */
title4Mesg[0] = "<C><#HL(30)>";
title4Mesg[1] = "<C></R>This is the fourth screen.";
title4Mesg[2] = "<C>Hit space to go to the next screen";
title4Mesg[3] = "<C><#HL(30)>";
label4 = newCDKLabel (cdkScreen4, LEFT, CENTER,
(CDK_CSTRING2)title4Mesg, 4,
FALSE, FALSE);
/* Create the fifth screen. */
dialogMesg[0] = "<C><#HL(30)>";
dialogMesg[1] = "<C>Screen 5";
dialogMesg[2] = "<C>This is the last of 5 screens. If you want";
dialogMesg[3] = "<C>to continue press the 'Continue' button.";
dialogMesg[4] = "<C>Otherwise press the 'Exit' button";
dialogMesg[5] = "<C><#HL(30)>";
dialog = newCDKDialog (cdkScreen5, CENTER, CENTER,
(CDK_CSTRING2)dialogMesg, 6,
(CDK_CSTRING2)buttons, 2,
A_REVERSE, TRUE, TRUE, FALSE);
/* Do this for ever... (almost) */
for (;;)
{
int answer;
/* Draw the first screen. */
drawCDKScreen (cdkScreen1);
waitCDKLabel (label1, ' ');
eraseCDKScreen (cdkScreen1);
/* Draw the second screen. */
drawCDKScreen (cdkScreen2);
waitCDKLabel (label2, ' ');
eraseCDKScreen (cdkScreen2);
/* Draw the third screen. */
drawCDKScreen (cdkScreen3);
waitCDKLabel (label3, ' ');
eraseCDKScreen (cdkScreen3);
/* Draw the fourth screen. */
drawCDKScreen (cdkScreen4);
waitCDKLabel (label4, ' ');
eraseCDKScreen (cdkScreen4);
/* Draw the fourth screen. */
drawCDKScreen (cdkScreen5);
answer = activateCDKDialog (dialog, 0);
/* Check the users answer. */
if (answer == 1)
{
destroyCDKLabel (label1);
destroyCDKLabel (label2);
destroyCDKLabel (label3);
destroyCDKLabel (label4);
destroyCDKDialog (dialog);
destroyCDKScreen (cdkScreen1);
destroyCDKScreen (cdkScreen2);
destroyCDKScreen (cdkScreen3);
destroyCDKScreen (cdkScreen4);
destroyCDKScreen (cdkScreen5);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}
}
}

View File

@ -0,0 +1,89 @@
/* $Id: dialog_ex.c,v 1.14 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "dialog_ex";
#endif
/*
* This program demonstrates the Cdk dialog widget.
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkscreen = 0;
CDKDIALOG *question = 0;
const char *buttons[] =
{"</B/24>Ok", "</B16>Cancel"};
const char *message[10];
const char *mesg[3];
char temp[100];
int selection;
CDK_PARAMS params;
CDKparseParams (argc, argv, &params, CDK_MIN_PARAMS);
cdkscreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Create the message within the dialog box. */
message[0] = "<C></U>Dialog Widget Demo";
message[1] = " ";
message[2] = "<C>The dialog widget allows the programmer to create";
message[3] = "<C>a popup dialog box with buttons. The dialog box";
message[4] = "<C>can contain </B/32>colours<!B!32>, </R>character attributes<!R>";
message[5] = "<R>and even be right justified.";
message[6] = "<L>and left.";
/* Create the dialog box. */
question = newCDKDialog (cdkscreen,
CDKparamValue (&params, 'X', CENTER),
CDKparamValue (&params, 'Y', CENTER),
(CDK_CSTRING2) message, 7,
(CDK_CSTRING2) buttons, 2,
COLOR_PAIR (2) | A_REVERSE,
TRUE,
CDKparamValue (&params, 'N', TRUE),
CDKparamValue (&params, 'S', FALSE));
/* Check if we got a null value back. */
if (question == 0)
{
/* Shut down Cdk. */
destroyCDKScreen (cdkscreen);
endCDK ();
printf ("Cannot create the dialog box. Is the window too small?\n");
ExitProgram (EXIT_FAILURE);
}
/* Activate the dialog box. */
selection = activateCDKDialog (question, 0);
/* Tell them what was selected. */
if (question->exitType == vESCAPE_HIT)
{
mesg[0] = "<C>You hit escape. No button selected.";
mesg[1] = "";
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
}
else if (question->exitType == vNORMAL)
{
sprintf (temp, "<C>You selected button #%d", selection);
mesg[0] = temp;
mesg[1] = "";
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
}
/* Clean up. */
destroyCDKDialog (question);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}

View File

@ -0,0 +1,108 @@
/* $Id: entry_ex.c,v 1.17 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "entry_ex";
#endif
static BINDFN_PROTO (XXXCB);
/*
* This demonstrates the Cdk entry field widget.
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkscreen = 0;
CDKENTRY *directory = 0;
const char *title = "<C>Enter a\n<C>directory name.";
const char *label = "</U/5>Directory:<!U!5>";
char *info;
const char *mesg[10];
char temp[256];
CDK_PARAMS params;
CDKparseParams (argc, argv, &params, CDK_MIN_PARAMS);
cdkscreen = initCDKScreen (NULL);
/* Start CDK colors. */
initCDKColor ();
/* Create the entry field widget. */
directory = newCDKEntry (cdkscreen,
CDKparamValue (&params, 'X', CENTER),
CDKparamValue (&params, 'Y', CENTER),
title, label, A_NORMAL, '.', vMIXED,
40, 0, 256,
CDKparamValue (&params, 'N', TRUE),
CDKparamValue (&params, 'S', FALSE));
bindCDKObject (vENTRY, directory, '?', XXXCB, 0);
/* Is the widget null? */
if (directory == 0)
{
/* Clean up. */
destroyCDKScreen (cdkscreen);
endCDK ();
printf ("Cannot create the entry box. Is the window too small?\n");
ExitProgram (EXIT_FAILURE);
}
/* Draw the screen. */
refreshCDKScreen (cdkscreen);
/*
* Pass in whatever was given off of the command line. Notice we
* don't check if argv[1] is null or not. The function setCDKEntry
* already performs any needed checks.
*/
setCDKEntry (directory, argv[optind], 0, 256, TRUE);
/* Activate the entry field. */
info = activateCDKEntry (directory, 0);
/* Tell them what they typed. */
if (directory->exitType == vESCAPE_HIT)
{
mesg[0] = "<C>You hit escape. No information passed back.";
mesg[1] = "",
mesg[2] = "<C>Press any key to continue.";
destroyCDKEntry (directory);
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
}
else if (directory->exitType == vNORMAL)
{
mesg[0] = "<C>You typed in the following";
sprintf (temp, "<C>(%.*s)", (int)(sizeof (temp) - 10), info);
mesg[1] = temp;
mesg[2] = "";
mesg[3] = "<C>Press any key to continue.";
destroyCDKEntry (directory);
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 4);
}
else
{
destroyCDKEntry (directory);
}
/* Clean up and exit. */
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}
static int XXXCB (EObjectType cdktype GCC_UNUSED,
void *object GCC_UNUSED,
void *clientData GCC_UNUSED,
chtype key GCC_UNUSED)
{
return (TRUE);
}

View File

@ -0,0 +1,96 @@
/* $Id: fscale_ex.c,v 1.9 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "fscale_ex";
#endif
static float myFloatParam (CDK_PARAMS * params, int code, double missing)
{
char *opt = CDKparamString (params, code);
double result = missing;
if (opt != 0)
result = atof (opt);
return (float)result;
}
/*
* This program demonstrates the Cdk scale widget.
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkscreen = 0;
CDKFSCALE *scale = 0;
const char *title = "<C>Select a value";
const char *label = "</5>Current value";
char temp[256];
const char *mesg[5];
float selection;
CDK_PARAMS params;
float high;
float inc;
float low;
/* *INDENT-EQLS* */
CDKparseParams (argc, argv, &params, "h:i:l:w:" CDK_MIN_PARAMS);
high = myFloatParam (&params, 'h', 2.4);
inc = myFloatParam (&params, 'i', 0.2);
low = myFloatParam (&params, 'l', -1.2);
cdkscreen = initCDKScreen (NULL);
/* Start CDK Colors. */
initCDKColor ();
/* Create the scale. */
scale = newCDKFScale (cdkscreen,
CDKparamValue (&params, 'X', CENTER),
CDKparamValue (&params, 'Y', CENTER),
title, label, A_NORMAL,
CDKparamNumber2 (&params, 'w', 10),
low, low, high,
inc, (inc * (float)2.), 1,
CDKparamValue (&params, 'N', TRUE),
CDKparamValue (&params, 'S', FALSE));
/* Is the scale null? */
if (scale == 0)
{
/* Exit CDK. */
destroyCDKScreen (cdkscreen);
endCDK ();
printf ("Can't make the scale widget. Is the window too small?\n");
ExitProgram (EXIT_FAILURE);
}
/* Activate the scale. */
selection = activateCDKFScale (scale, 0);
/* Check the exit value of the scale widget. */
if (scale->exitType == vESCAPE_HIT)
{
mesg[0] = "<C>You hit escape. No value selected.";
mesg[1] = "";
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
}
else if (scale->exitType == vNORMAL)
{
sprintf (temp, "<C>You selected %f", selection);
mesg[0] = temp;
mesg[1] = "";
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
}
/* Clean up. */
destroyCDKFScale (scale);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}

View File

@ -0,0 +1,326 @@
/* $Id: fselect_ex.c,v 1.27 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "fselect_ex";
#endif
/*
* This program demonstrates the file selector and the viewer widget.
*/
static CDKSCREEN *cdkscreen = 0;
static char **myUserList = 0;
static int userSize;
typedef struct
{
int deleted; /* index in current list which is deleted */
int original; /* index in myUserList[] of deleted item */
int position; /* position before delete */
int topline; /* top-line before delete */
} UNDO;
static UNDO *myUndoList;
static int undoSize;
#define CB_PARAMS EObjectType cdktype GCC_UNUSED, void* object GCC_UNUSED, void* clientdata GCC_UNUSED, chtype key GCC_UNUSED
static void fill_undo (CDKFSELECT *widget, int deleted, char *data)
{
int top = getCDKScrollCurrentTop (widget->scrollField);
int item = getCDKFselectCurrentItem (widget);
int n;
myUndoList[undoSize].deleted = deleted;
myUndoList[undoSize].topline = top;
myUndoList[undoSize].original = -1;
myUndoList[undoSize].position = item;
for (n = 0; n < userSize; ++n)
{
if (!strcmp (myUserList[n], data))
{
myUndoList[undoSize].original = n;
break;
}
}
++undoSize;
}
static int do_delete (CB_PARAMS)
{
CDKFSELECT *widget = (CDKFSELECT *)clientdata;
int size;
char **list = getCDKFselectContents (widget, &size);
int result = FALSE;
if (size)
{
int save = getCDKScrollCurrentTop (widget->scrollField);
int first = getCDKFselectCurrentItem (widget);
int n;
fill_undo (widget, first, list[first]);
for (n = first; n < size; ++n)
list[n] = list[n + 1];
setCDKFselectContents (widget, (CDK_CSTRING2)list, size - 1);
setCDKScrollCurrentTop (widget->scrollField, save);
setCDKFselectCurrentItem (widget, first);
drawCDKFselect (widget, BorderOf (widget));
result = TRUE;
}
return result;
}
static int do_delete1 (CB_PARAMS)
{
CDKFSELECT *widget = (CDKFSELECT *)clientdata;
int size;
char **list = getCDKFselectContents (widget, &size);
int result = FALSE;
if (size)
{
int save = getCDKScrollCurrentTop (widget->scrollField);
int first = getCDKFselectCurrentItem (widget);
if (first-- > 0)
{
int n;
fill_undo (widget, first, list[first]);
for (n = first; n < size; ++n)
list[n] = list[n + 1];
setCDKFselectContents (widget, (CDK_CSTRING2)list, size - 1);
setCDKScrollCurrentTop (widget->scrollField, save);
setCDKFselectCurrentItem (widget, first);
drawCDKFselect (widget, BorderOf (widget));
result = TRUE;
}
}
return result;
}
static int do_help (CB_PARAMS)
{
static const char *message[] =
{
"File Selection tests:",
"",
"F1 = help (this message)",
"F2 = delete current item",
"F3 = delete previous item",
"F4 = reload all items",
"F5 = undo deletion",
0
};
popupLabel (cdkscreen,
(CDK_CSTRING2)message,
(int)CDKcountStrings ((CDK_CSTRING2)message));
return TRUE;
}
static int do_reload (CB_PARAMS)
{
int result = FALSE;
if (userSize)
{
CDKFSELECT *widget = (CDKFSELECT *)clientdata;
setCDKFselectContents (widget, (CDK_CSTRING2)myUserList, userSize);
setCDKFselectCurrentItem (widget, 0);
drawCDKFselect (widget, BorderOf (widget));
result = TRUE;
}
return result;
}
static int do_undo (CB_PARAMS)
{
int result = FALSE;
if (undoSize > 0)
{
CDKFSELECT *widget = (CDKFSELECT *)clientdata;
int size;
int n;
char **oldlist = getCDKFselectContents (widget, &size);
char **newlist = (char **)malloc ((size_t) (++size + 1) * sizeof (char *));
--undoSize;
newlist[size] = 0;
for (n = size - 1; n > myUndoList[undoSize].deleted; --n)
{
newlist[n] = copyChar (oldlist[n - 1]);
}
newlist[n--] = copyChar (myUserList[myUndoList[undoSize].original]);
while (n >= 0)
{
newlist[n] = copyChar (oldlist[n]);
--n;
}
setCDKFselectContents (widget, (CDK_CSTRING2)newlist, size);
setCDKScrollCurrentTop (widget->scrollField, myUndoList[undoSize].topline);
setCDKFselectCurrentItem (widget, myUndoList[undoSize].position);
drawCDKFselect (widget, BorderOf (widget));
free (newlist);
result = TRUE;
}
return result;
}
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKVIEWER *example = 0;
CDKFSELECT *fSelect = 0;
const char *title = "<C>Pick\n<C>A\n<C>File";
const char *label = "File: ";
char **info = 0;
const char *button[5];
const char *mesg[4];
char *filename;
char vTitle[256];
char temp[256];
int selected, lines;
CDK_PARAMS params;
char *directory;
CDKparseParams (argc, argv, &params, "d:" CDK_CLI_PARAMS);
directory = CDKparamString2 (&params, 'd', ".");
/* Create the viewer buttons. */
button[0] = "</5><OK><!5>";
button[1] = "</5><Cancel><!5>";
cdkscreen = initCDKScreen (NULL);
/* Start color. */
initCDKColor ();
/* Get the filename. */
fSelect = newCDKFselect (cdkscreen,
CDKparamValue (&params, 'X', CENTER),
CDKparamValue (&params, 'Y', CENTER),
CDKparamValue (&params, 'H', 20),
CDKparamValue (&params, 'W', 65),
title, label, A_NORMAL, '_', A_REVERSE,
"</5>", "</48>", "</N>", "</N>",
CDKparamValue (&params, 'N', TRUE),
CDKparamValue (&params, 'S', FALSE));
if (fSelect == 0)
{
destroyCDKScreen (cdkscreen);
endCDK ();
fprintf (stderr, "Cannot create widget\n");
ExitProgram (EXIT_FAILURE);
}
bindCDKObject (vFSELECT, fSelect, '?', do_help, NULL);
bindCDKObject (vFSELECT, fSelect, KEY_F1, do_help, NULL);
bindCDKObject (vFSELECT, fSelect, KEY_F2, do_delete, fSelect);
bindCDKObject (vFSELECT, fSelect, KEY_F3, do_delete1, fSelect);
bindCDKObject (vFSELECT, fSelect, KEY_F4, do_reload, fSelect);
bindCDKObject (vFSELECT, fSelect, KEY_F5, do_undo, fSelect);
/*
* Set the starting directory. This is not necessary because when
* the file selector starts it uses the present directory as a default.
*/
setCDKFselect (fSelect, directory, A_NORMAL, ' ', A_REVERSE,
"</5>", "</48>", "</N>", "</N>", ObjOf (fSelect)->box);
myUserList = copyCharList ((const char **)getCDKFselectContents (fSelect, &userSize));
myUndoList = (UNDO *) malloc ((size_t) userSize * sizeof (UNDO));
undoSize = 0;
/* Activate the file selector. */
filename = activateCDKFselect (fSelect, 0);
/* Check how the person exited from the widget. */
if (fSelect->exitType == vESCAPE_HIT)
{
/* Pop up a message for the user. */
mesg[0] = "<C>Escape hit. No file selected.";
mesg[1] = "";
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
/* Exit CDK. */
destroyCDKFselect (fSelect);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}
/* Create the file viewer to view the file selected. */
example = newCDKViewer (cdkscreen, CENTER, CENTER, 20, -2,
(CDK_CSTRING2)button, 2, A_REVERSE, TRUE, FALSE);
/* Could we create the viewer widget? */
if (example == 0)
{
/* Exit CDK. */
destroyCDKFselect (fSelect);
destroyCDKScreen (cdkscreen);
endCDK ();
printf ("Can't seem to create viewer. Is the window too small?\n");
ExitProgram (EXIT_SUCCESS);
}
/* Open the file and read the contents. */
lines = CDKreadFile (filename, &info);
if (lines == -1)
{
filename = copyChar (filename);
destroyCDKFselect (fSelect);
destroyCDKScreen (cdkscreen);
endCDK ();
printf ("Could not open \"%s\"\n", filename);
ExitProgram (EXIT_FAILURE);
}
/* Set up the viewer title, and the contents to the widget. */
sprintf (vTitle, "<C></B/21>Filename:<!21></22>%20s<!22!B>", filename);
setCDKViewer (example, vTitle,
(CDK_CSTRING2)info, lines,
A_REVERSE, TRUE, TRUE, TRUE);
CDKfreeStrings (info);
/* Destroy the file selector widget. */
destroyCDKFselect (fSelect);
/* Activate the viewer widget. */
selected = activateCDKViewer (example, 0);
/* Check how the person exited from the widget. */
if (example->exitType == vESCAPE_HIT)
{
mesg[0] = "<C>Escape hit. No Button selected.";
mesg[1] = "";
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
}
else if (example->exitType == vNORMAL)
{
sprintf (temp, "<C>You selected button %d", selected);
mesg[0] = temp;
mesg[1] = "";
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
}
/* Clean up. */
destroyCDKViewer (example);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}

View File

@ -0,0 +1,102 @@
/* $Id: fslider_ex.c,v 1.4 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "slider_ex";
#endif
/*
* This program demonstrates the Cdk slider widget.
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkscreen = 0;
CDKFSLIDER *widget = 0;
const char *title = "<C></U>Enter a value:";
const char *label = "</B>Current Value:";
char temp[256];
const char *mesg[5];
float selection;
CDK_PARAMS params;
double high;
double inc;
double low;
double scale;
int n, digits;
CDKparseParams (argc, argv, &params, "h:i:l:w:p:" CDK_MIN_PARAMS);
digits = CDKparamNumber2 (&params, 'p', 0);
scale = 1.0;
for (n = 0; n < digits; ++n)
{
scale = scale * 10.0;
}
/* *INDENT-EQLS* */
high = CDKparamNumber2 (&params, 'h', 100) / scale;
inc = CDKparamNumber2 (&params, 'i', 1) / scale;
low = CDKparamNumber2 (&params, 'l', 1) / scale;
cdkscreen = initCDKScreen (NULL);
/* Start CDK Colors. */
initCDKColor ();
/* Create the widget. */
widget = newCDKFSlider (cdkscreen,
CDKparamValue (&params, 'X', CENTER),
CDKparamValue (&params, 'Y', CENTER),
title, label,
A_REVERSE | COLOR_PAIR (29) | ' ',
CDKparamNumber2 (&params, 'w', 50),
(float)low,
(float)low,
(float)high,
(float)inc,
(float)(inc * 2),
digits,
CDKparamValue (&params, 'N', TRUE),
CDKparamValue (&params, 'S', FALSE));
/* Is the widget null? */
if (widget == 0)
{
/* Exit CDK. */
destroyCDKScreen (cdkscreen);
endCDK ();
printf ("Cannot make the widget. Is the window too small?\n");
ExitProgram (EXIT_FAILURE);
}
/* Activate the widget. */
selection = activateCDKFSlider (widget, 0);
/* Check the exit value of the widget. */
if (widget->exitType == vESCAPE_HIT)
{
mesg[0] = "<C>You hit escape. No value selected.";
mesg[1] = "";
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
}
else if (widget->exitType == vNORMAL)
{
sprintf (temp, "<C>You selected %.*f", digits, selection);
mesg[0] = temp;
mesg[1] = "";
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
}
/* Clean up. */
destroyCDKFSlider (widget);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}

View File

@ -0,0 +1,104 @@
/* $Id: graph_ex.c,v 1.15 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "graph_ex";
#endif
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkscreen = 0;
CDKGRAPH *graph = 0;
CDKLABEL *pausep = 0;
const char *title = 0;
const char *xtitle = 0;
const char *ytitle = 0;
const char *graphChars = 0;
const char *mesg[2];
int values[20];
int count;
CDK_PARAMS params;
CDKparseParams (argc, argv, &params, CDK_CLI_PARAMS); /* -N, -S unused */
cdkscreen = initCDKScreen (NULL);
/* Start CDK Colors. */
initCDKColor ();
/* Create the graph values. */
/* *INDENT-EQLS* */
values[0] = 10;
values[1] = 15;
values[2] = 20;
values[3] = 25;
values[4] = 30;
values[5] = 35;
values[6] = 40;
values[7] = 45;
values[8] = 50;
values[9] = 55;
count = 10;
title = "<C>Test Graph";
xtitle = "<C>X AXIS TITLE";
ytitle = "<C>Y AXIS TITLE";
graphChars = "0123456789";
/* Create the label values. */
mesg[0] = "Press any key when done viewing the graph.";
/* Create the graph widget. */
graph = newCDKGraph (cdkscreen,
CDKparamValue (&params, 'X', CENTER),
CDKparamValue (&params, 'Y', CENTER),
CDKparamValue (&params, 'H', 10),
CDKparamValue (&params, 'W', 20),
title, xtitle, ytitle);
/* Is the graph null? */
if (graph == 0)
{
/* Shut down CDK. */
destroyCDKScreen (cdkscreen);
endCDK ();
printf ("Cannot make the graph widget. Is the window too small?\n");
ExitProgram (EXIT_FAILURE);
}
/* Create the label widget. */
pausep = newCDKLabel (cdkscreen, CENTER, BOTTOM,
(CDK_CSTRING2) mesg, 1,
TRUE, FALSE);
if (pausep == 0)
{
/* Shut down CDK. */
destroyCDKGraph (graph);
destroyCDKScreen (cdkscreen);
endCDK ();
printf ("Cannot make the label widget. Is the window too small?\n");
ExitProgram (EXIT_FAILURE);
}
/* Set the graph values. */
setCDKGraph (graph, values, count, graphChars, FALSE, vPLOT);
/* Draw the screen. */
refreshCDKScreen (cdkscreen);
drawCDKGraph (graph, FALSE);
drawCDKLabel (pausep, TRUE);
/* Pause until the user says so... */
waitCDKLabel (pausep, 0);
/* Clean up. */
destroyCDKGraph (graph);
destroyCDKLabel (pausep);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}

View File

@ -0,0 +1,61 @@
/* $Id: hello_ex.c,v 1.12 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "hello_ex";
#endif
int main (int argc, char **argv)
{
CDKSCREEN *cdkscreen;
CDKLABEL *demo;
const char *mesg[4];
CDK_PARAMS params;
CDKparseParams (argc, argv, &params, CDK_MIN_PARAMS);
cdkscreen = initCDKScreen (NULL);
/* Start CDK Colors. */
initCDKColor ();
/* Set the labels up. */
mesg[0] = "</5><#UL><#HL(30)><#UR>";
mesg[1] = "</5><#VL(10)>Hello World!<#VL(10)>";
mesg[2] = "</5><#LL><#HL(30)><#LR>";
/* Declare the labels. */
demo = newCDKLabel (cdkscreen,
CDKparamValue (&params, 'X', CENTER),
CDKparamValue (&params, 'Y', CENTER),
(CDK_CSTRING2) mesg, 3,
CDKparamValue (&params, 'N', TRUE),
CDKparamValue (&params, 'S', TRUE));
/* Is the label null? */
if (demo == 0)
{
/* Clean up the memory. */
destroyCDKScreen (cdkscreen);
/* End curses... */
endCDK ();
printf ("Cannot create the label. Is the window too small?\n");
ExitProgram (EXIT_FAILURE);
}
setCDKLabelBackgroundAttrib (demo, COLOR_PAIR (2));
/* Draw the CDK screen. */
refreshCDKScreen (cdkscreen);
waitCDKLabel (demo, ' ');
/* Clean up. */
destroyCDKLabel (demo);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}

View File

@ -0,0 +1,144 @@
/* $Id: histogram_ex.c,v 1.12 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "histogram_ex";
#endif
#if !defined (HAVE_SLEEP) && defined (_WIN32) /* Mingw */
#define sleep(x) _sleep(x*1000)
#endif
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkscreen = 0;
CDKHISTOGRAM *volume = 0;
CDKHISTOGRAM *bass = 0;
CDKHISTOGRAM *treble = 0;
const char *volumeTitle = "<C></5>Volume<!5>";
const char *bassTitle = "<C></5>Bass <!5>";
const char *trebleTitle = "<C></5>Treble<!5>";
CDK_PARAMS params;
boolean Box;
CDKparseParams (argc, argv, &params, CDK_CLI_PARAMS);
Box = CDKparamValue (&params, 'N', TRUE);
cdkscreen = initCDKScreen (NULL);
/* Start CDK Color. */
initCDKColor ();
/* Create the histogram objects. */
volume = newCDKHistogram (cdkscreen,
CDKparamValue (&params, 'X', 10),
CDKparamValue (&params, 'Y', 10),
CDKparamValue (&params, 'H', 1),
CDKparamValue (&params, 'W', -2),
HORIZONTAL, volumeTitle,
Box,
CDKparamValue (&params, 'S', FALSE));
if (volume == 0)
{
/* Exit CDK. */
destroyCDKScreen (cdkscreen);
endCDK ();
printf ("Cannot make volume histogram. Is the window big enough??\n");
ExitProgram (EXIT_FAILURE);
}
bass = newCDKHistogram (cdkscreen,
CDKparamValue (&params, 'X', 10),
CDKparamValue (&params, 'Y', 14),
CDKparamValue (&params, 'H', 1),
CDKparamValue (&params, 'W', -2),
HORIZONTAL, bassTitle,
Box,
CDKparamValue (&params, 'S', FALSE));
if (bass == 0)
{
/* Exit CDK. */
destroyCDKHistogram (volume);
destroyCDKScreen (cdkscreen);
endCDK ();
printf ("Cannot make bass histogram. Is the window big enough??\n");
ExitProgram (EXIT_FAILURE);
}
treble = newCDKHistogram (cdkscreen,
CDKparamValue (&params, 'X', 10),
CDKparamValue (&params, 'Y', 18),
CDKparamValue (&params, 'H', 1),
CDKparamValue (&params, 'W', -2),
HORIZONTAL, trebleTitle,
Box,
CDKparamValue (&params, 'S', FALSE));
if (treble == 0)
{
/* Exit CDK. */
destroyCDKHistogram (volume);
destroyCDKHistogram (bass);
destroyCDKScreen (cdkscreen);
endCDK ();
printf ("Cannot make treble histogram. Is the window big enough??\n");
ExitProgram (EXIT_FAILURE);
}
#define BAR(a,b,c) A_BOLD, a, b, c, ' '|A_REVERSE|COLOR_PAIR(3), Box
/* Set the histogram values. */
setCDKHistogram (volume, vPERCENT, CENTER, BAR (0, 10, 6));
setCDKHistogram (bass, vPERCENT, CENTER, BAR (0, 10, 3));
setCDKHistogram (treble, vPERCENT, CENTER, BAR (0, 10, 7));
refreshCDKScreen (cdkscreen);
sleep (4);
/* Set the histogram values. */
setCDKHistogram (volume, vPERCENT, CENTER, BAR (0, 10, 8));
setCDKHistogram (bass, vPERCENT, CENTER, BAR (0, 10, 1));
setCDKHistogram (treble, vPERCENT, CENTER, BAR (0, 10, 9));
refreshCDKScreen (cdkscreen);
sleep (4);
/* Set the histogram values. */
setCDKHistogram (volume, vPERCENT, CENTER, BAR (0, 10, 10));
setCDKHistogram (bass, vPERCENT, CENTER, BAR (0, 10, 7));
setCDKHistogram (treble, vPERCENT, CENTER, BAR (0, 10, 10));
refreshCDKScreen (cdkscreen);
sleep (4);
/* Set the histogram values. */
setCDKHistogram (volume, vPERCENT, CENTER, BAR (0, 10, 1));
setCDKHistogram (bass, vPERCENT, CENTER, BAR (0, 10, 8));
setCDKHistogram (treble, vPERCENT, CENTER, BAR (0, 10, 3));
refreshCDKScreen (cdkscreen);
sleep (4);
/* Set the histogram values. */
setCDKHistogram (volume, vPERCENT, CENTER, BAR (0, 10, 3));
setCDKHistogram (bass, vPERCENT, CENTER, BAR (0, 10, 3));
setCDKHistogram (treble, vPERCENT, CENTER, BAR (0, 10, 3));
refreshCDKScreen (cdkscreen);
sleep (4);
/* Set the histogram values. */
setCDKHistogram (volume, vPERCENT, CENTER, BAR (0, 10, 10));
setCDKHistogram (bass, vPERCENT, CENTER, BAR (0, 10, 10));
setCDKHistogram (treble, vPERCENT, CENTER, BAR (0, 10, 10));
refreshCDKScreen (cdkscreen);
sleep (4);
/* Clean up. */
destroyCDKHistogram (volume);
destroyCDKHistogram (bass);
destroyCDKHistogram (treble);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}

Some files were not shown because too many files have changed in this diff Show More