cdk-5.0-20060507/0000755000175100001440000000000010427502123011533 5ustar tomuserscdk-5.0-20060507/CHANGES0000644000175100001440000015131210427243354012541 0ustar tomusersCdk Version Change List Copyright Mike Glover, 1995, 1996, 1997, 1998, 1999 Modifications copyright Thomas E. Dickey 1999-2005, 2006 ------------------------------------------------------------------------------- This file outlines all of the changes/additions from one release to another. 2006/05/07 + reduce the number of calls on touchwin(), which is used mainly for cleanup after moving a window. + improve focus in alphalist.c and fselect.c to ensure that the dependent scroll widget highlights data after losing focus to the entry widget (report by Harry Brueckner). + add getCDKScrollCurrentItem(), setCDKScrollCurrentItem(), getCDKScrollCurrentTop() and setCDKScrollCurrentTop(). + add getCDKFselectCurrentItem(), setCDKFselectCurrentItem(), use these in fselect_ex.c to illustrate how to modify list displayed by the fselect widget. + add getCDKAlphalistCurrentItem(), setCDKAlphalistCurrentItem(), use these in alphalist_ex.c to illustrate how to modify list displayed by the alphalist widget. + add copyCharList(), copyChtypeList(), lenCharList(), lenChtypeList(). + fix misformatted cdk_display manpage, which did not show vINT and some other data properly (report by Dominik Douville-Belanger). + split-out cdk_display.c to eliminate repeated logic in entry.c, matrix.c and mentry.c, and implement hidden fields for the matrix widget. + correct box-height for marquee widget. The box parameter was previously ignored; this correction will make some applications no longer show a box (report by Michael White). + modify logic for KEY_DC and KEY_BACKSPACE so the former only deletes the current character, and the latter only deletes the previous, rather than equating them. This affects alphalist, entry, mentry, template (request by Harry Brueckner). + suppress conversion of control characters in getcCDKObject() if the character is bound to another. This was last changed in 2004/8/24 (report by Harry Brueckner). + add check in adjustAlphalistCB() in case the list is empty (report by Harry Brueckner). 2006/02/20 + correct makefile dependency so $(MAN_DIR) and $(INCLUDE_DIR) are created before headers.sed and manpage.sed, since headers.sh relies on the existence of the destination directory (reports by Marek Lipovean, Marcelo Goes, also Gentoo #123374). 2005/12/30 + add some redundant pointer checks, e.g., to entry.c, to avoid core dump if one tries building Cdk with NetBSD curses (see lib/32417). + split up traverseCDKScreen() to allow customized flavors of that to be written in a calling application using the pieces: traverseCDKOnce(), setCDKFocusFirst() (request by Jorgen Lundman). + restore assignment of selectedItem in setCDKRadioCurrentItem() which was dropped in 2005/04/24 (report by Fu Steve X). + modify refreshCDKScreen() to ensure that only one widget will have focus, i.e., the first which currently has focus, or if none, then the first visible one (report by Fu Steve X). + use cleanCDKTemplate() consistently in the template widget, ensuring that the editing position is updated, and that the proper length is used when clearing memory (report by Fu Steve X). + modify calendar, radio, scroll, selection widgets so the cursor is shown at the beginning of the selected item's row for better accessibility (report by Fu Steve X). + add null-pointer check in setCDKViewerInfo() in case caller gives too-large value for list size (report by Jorgen Lundman). + improve traverseCDKScreen() by updating curobj from the getCDKFocusCurrent() function (patch by Jorgen Lundman). + add setCDKFocusCurrent() (patch by Jorgen Lundman). + add configure script option allowing manpage section to be changed from "3" to other values such as "3CDK", e.g., for Debian. + modify getCDKRadioItems(), getCDKScrollItems() and getCDKSelectionItems() to return just the list-size if the list pointer is null. + correct highlighting of selected line in CDKSelection window when the window is scrolled left/right (patch by Jorgen Lundman). + various manpage fixes (report by Jorgen Lundman). + change manpages to use ".XX" macro to indicate aliases, to make the manpage more readable. + eliminate duplication between cdk_util.3 and cdk_misc.3 manpages (dialogs belong in the former, for instance). + modify alphalist, itemlist, radio, selection and swindow to allow creating a widget with an empty list (request by Harry Brueckner). + modify mentry.c case for KEY_RIGHT so one can move the cursor past the end of the string to add new text (report by Harry Brueckner). + modify cdk_params.c to use strtol() rather than atoi() to allow command-line parameters such as -h 0xffff for the slider examples. + modify gen-slider.c to use sprintf/strlen to obtain length of formatted integer types since intlen() does not give correct result for maximum value of unsigned type. Modify increment/decrement logic to take into account unsigned types (report by Keith J Outwater). + modify cli examples to exit with 255 when reporting an error rather than a -1 which is generally not portable. + fix several memory leaks exposed by valgrind in the example programs. + add configure --disable-leaks option to look for ncurses' debug function _nc_free_and_exit(), using that to help with memory leak checking. This uses a new header which will not be installed, since it is used only for testing in the build tree. > patches by Phuah Yee Keat: + add an IsVisibleObj attribute to all CDK objects so the caller can set some object to be invisible, and calling refreshCDKScreen after that won't display it again, it enables one to dynamically show or hide a particular widget based on user actions. Note: this changes alignments in many of the structs from 5.0, requiring an ABI bump. + improve string length-computation in entry.c, allowing a 1-char field, and also allowing movement past end of text with KEY_END. + add setCDKRadioSelectedItem() and getCDKRadioSelectedItem(). + fix some memory leaks by adding cleanCDKObjBindings() into all of the _destroyXXX() functions, modify cleanCDKObjBindings() to free and null (obj)->bindingList. + fix makefile for installing manpages when building outside of the source directory (patch by Mike Castle). + remove obsolete lsm file + review/correct some functions listed in manpages but not implemented, and the reverse (report by Rajat Das). + add setCDKMatrixCB() (report by 'zam). + update configure script (mostly fixes related to CF_XOPEN_SOURCE). + update config.guess, config.sub 2005/04/24 - T.E.Dickey + bump major version to 5 (overdue). + add built-in bindings for '<' and '>' to KEY_HOME and KEY_END for radio.c, scroll.c, selection.c, swindow.c and viewer.c (patch by Thorsten Glaser). + add manpages for some of the non-widget utilities: cdk_compat.3, cdk_objs.3, cdk_params.3 and cdk_util.3 + correct drawCDKTitle, which did not account for border-size in vertical position of titles. + change addCDKScrollPosition() to not set the current item to the beginning of the list. + add insertCDKScrollPosition(), to allow insertions before the current item. + add a check in scroll.c to prevent overflow if the list is empty. + modify deleteCDKScrollItem() to ensure the current item is on a valid position after the deletion. + modify setCDKScrollPosition() to avoid scrolling if the target is already on the screen. + make similar simplifications to radio.c and selection.c as in scroll.c + simplify and make consistent bookkeeping in scroll.c using new utility functions. As a result, addCDKScrollItem() and deleteCDKScrollItem() update the size of the scrollbar toggle (report by Fu Steve X). + improve resequence function from 2005/03/23 by preserving attributes in the target chtype array. + modify scroll_ex.c, binding 'a', 'i' and 'd' to add, insert and delete lines respectively (adapted from example by Fu Steve X). + modify makefile so that cdk_config.h (which is generated by the configure script) is not removed by "make clean". + modify makefile to work around limitation of Solaris make program which was confused by a header dependency in a "::" line (report by Fu Steve X). + modify makefile and scripts for configure --srcdir (adapted from patch by Mike Castle). 2005/03/23 - T.E.Dickey + modify deleteCDKScrollItem() to resequence numbers (request by Fu Steve X). + cleanup memory allocation in scroll.c, make addCDKScrollItem reallocate the scroll widget's arrays (report by Fu Steve X). 2005/03/08 - T.E.Dickey + correct logic of deleteCDKScrollItem(), which did not preserve the final null-pointer at the end of the list (report by Fu Steve X). + add isCDKOBjectBind() to simply check if the given object/key combination is bound, rather than invoke the bound function. + modify binding.c so that all of the functions share the same logic for mapping the given object to the bindable object, e.g., the entry widget for alphalist and fselect composite widgets. In particular, checkCDKObjectBind() and getcCDKObject() did not use the same binding data. + correct initialization of traverseCDKScreen(), which required two tab keypresses to make the first traversal (report by Fu Steve X). + update configure script checks for _XOPEN_SOURCE, etc. + updated config.guess and config.sub + correct prototype shown in manpage for setCDKScroll() (report by Stefan Heimann). + correct equivalent expressions in setCDKRadioItems() and setCDKSelectionItems(). + correct expression in setCDKScrollItems() which caused the updated window to shrink by 2 lines (report by Stefan Heimann). 2004/12/24 - T.E.Dickey ======================================== + correct expression in CDKCalendarField from 2004/08/31 changes, which caused it to show only 6 days/week, broken by a fix for demos/appointment (reports/patches by Ryan Flannery and Greg Martin). 2004/11/07 - T.E.Dickey ======================================== + correct top-level Makefile.in to remove libtool's auxiliary files in the "make clean" rule. + amend simplification of writeCharAttrib(), ensuring that attributes passed in the chtype-string are not ignored (report by Benoit Bidoggia). 2004/10/04 - T.E.Dickey ======================================== + correct logic of writeBlanks(), which did not check for malloc failure and made an unnecessary call to freeChar(). + simplify draw.c a little by using writeCharAttrib() and writeChtypeAttrib() to implement writeChar() and writeChtype(). + revert 2002/07/27 change that used waddchnstr() in writeChtype(), since it does not render control characters (report by Mike Leib). + fix an infinite loop in viewer.c when displaying control characters such as form-feed. 2004/08/31 - T.E.Dickey ======================================== + add a simple compatibility header (cdk_compat.h), which can be put in an application's include-path when compiling old applications against new/old Cdk. + update libtool ABI to 2.0.0 since several items are added to CDKOBJS, as well as cleanup of slider- and scale-header templates. + add check for ANSI compiler, needed for example with HPUX 10.20. + ifdef'd out nonfunctional saveData and refreshData methods of entry and itemlist widgets. + moved functions for setting background color or attribute into CDKOBJS. + moved pre- and post-processing data into CDKOBJS, changing the functions that set those per-widget into macros using cdk_objs.c + modify scale and slider widgets to allow the user to directly modify the value by typing over it (request by Keith Outwater). + add slider widgets for types float, unsigned. + add scale widgets for types double, unsigned. + add script gen-scale.sh, and templates (e.g., gen-scale.c, gen-scale.h) to allow easy generation of scale and slider widgets of various types. Use this to replace the existing CDKSCALE, CDKFSCALE, CDKSLIDER widgets (discussion with Keith Outwater). + adapt fix from dialog for porting getmaxx(), etc., to systems such as HPUX which do not provide these legacy definitions. + remove duplicate vinstall.c from examples directory. + modify install scripting to translate generated names in cdk_config.h to add "CDK_" prefix to most, reducing name-pollution. These names are used to allow applications to compile against the Cdk header files, but are otherwise of no general interest. In particular, "PACKAGE" is no longer conflicting (report by Phuah Yee Keat). + add earlyExit member to CDKOBJS, using this to implement a method for applications to specify whether the widget's exitType should be modified after calling checkCDKObjectBind(), and what value (discussion with Bernhard Walle, comparing with NetBSD variation). + correct logic in calendar widget for decrementing day- and month-values. + modify treatment of exitType field so it is only set to vESCAPE_HIT if an escape character was received. Hide most of the internal details of exitType, making it available as an object value (but retaining the widget field to ease upgrading old applications). + implement shadow option for newCDKMarquee(). + rewrite activateCDKMarquee(), eliminating an infinite-loop bug found in traverse_ex.c, as well as making it work properly with and without box-outline. + modify deleteCursesWindow() to call eraseCursesWindow(), so that deleting an object will also erase it, following the various manpages comment about removing the object from the screen (report by Mukovoz I.S.). + correct positionCDKObject() for CDKSCREEN's which do not happen to be the same size/shape as stdscr. + change layout of menus to account for parent window's origin since subwin() since uses absolute screen position (report by "Anna" w/o a return address). + correct off-by-one in positionCDKObject() which prevented user from reaching the right- and bottom-margins. + fix a few limits on sprintf's involving strings. + eliminate fixed array limit MAX_OBJECT in CDKSCREEN. + use CTRL() macro consistently in preference to CONTROL(). + remove delwin(stdscr) from example programs since it is both unneeded and nonportable. + use EXIT_SUCCESS and EXIT_FAILURE consistently in example programs. + remove all KEY_xxx symbols which are in X/Open curses from curdefs.h + remove all ACS_xxx symbols from curdefs.h + remove all A_xxx symbols from curdefs.h + add/use isChar() and CharOf() macros to get rid of A_CHARTEXT usage. + fix menus to allow them to scroll if there are too many entries to fit on the screen. + collect most uses of touchwin/refresh into new function refreshCDKWindow(). + clear background of menu windows, in case they are drawn over another widget. + correct length of title in menu if more than one is placed on the right side of the screen. + add getcCDKBind() function, to which keys can be bound for simple translation of the inputs via getcCDKObject(). Use this in examples/traverse_ex.c to bind F1 to menu. + eliminate mapChtype() function, since it could conflict with curses' definitions. Use the given key value instead, since it is always positive. + use KEY_MAX in preference to MAX_BINDINGS symbol. + eliminate internal use of literal backspace, DEL, tab, newline and carriage-return constants, etc., by mapping them to KEY_BACKSPACE, KEY_DC, KEY_ENTER, etc., in getcCDKObject(). + modify examples and demos to read input using getcCDKObject(), to solve problems with stdscr refresh overwriting the widgets. + modify matrix.c and menu.c to read input using getcCDKObject(), like all of the other widgets. + rewrote examples/traverse_ex.c to use menus to select the left, center and right widgets used for demonstrating traversal. + modify traversal to update object focus properly if a menu action removes or moves the object associated with the focus. + cleanup menu in traverse.c if escape character is used to cancel it. + move curs_set() calls out of focus/unfocus functions, into traverse.c + remove the SIGBUS/SIGSEGV handler, since it is redundant. + updated configure script (CF_ADD_CFLAGS, CF_CHECK_CACHE, CF_GCC_WARNINGS, CF_NCURSES_LIBS, CF_PROG_EXT, CF_WITH_DBMALLOC, CF_WITH_DMALLOC, CF_WITH_LIBTOOL, CF_WITH_WARNINGS, CF_X_ATHENA, CF_X_TOOLKIT). + updated config.guess, config.sub > patches by ewigg (Ed Wigg?) for fselect.c: + add a range check to ensure that filename completion at the end of the list does not reference past the end of the list. + correct the value returned from filename completion (fixes in 2002/07/27 mistook an assignment that removed the last character of the result - it is actually used to trim the "/", "@" or similar character from the displayed filename). + remove an unnecessary if statement. > patches by Phuah Yee Keat: + enable focus in mentry.c, radio.c + implement unfocus in entry.c + implement focus/unfocus in mentry.c, template.c + add setCDKRadioCurrentItem() and getCDKRadioCurrentItem(). + improve entry.c: When the user types until the last character, do not shift the cursor to one character beyond the end of the maximum value allowed in the field, that will create an extra '.' that will give the user an impression that he can still enter more characters, when he actually can't. + fix two core dumps with Solaris curses in scroll.c: + On solaris curses, just pressing the "down" key on a scroll list will coredump, on certain sizes of the scroll list. On my fullscreen test, it will coredump on any number of items unless if the number of items is a multiple of 5. I assume that it's because that under certain conditions, the togglePos actually exceeds the boundary at the end of the scroll bar. Does not happen in ncurses. + On solaris curses, press 'G' will coredump. Does not happen in ncurses. + make wording in COPYING consistent with other fixes from 1999/05/15 (report by Ahmad Attia). 2003/12/10 - T.E.Dickey ======================================== + bump version to 4.9.11 (corresponding source from Mike Glover added install.sh to tarball; no other source changes were made). + rename "install.sh" to "install-sh" to work around bugs in certain make-programs. + allocate marker[] array in calendar dynamically. Reduce corresponding array limits to reasonable values. + add getCDKCalendarMarker() + correct seconds in calendar's return value. + eliminate fixed array limits from dialog widget. + eliminate fixed array limits from label widget. + eliminate fixed array limits from selection widget. + eliminate fixed array limits from viewer widget. + eliminate fixed array limits from buttonbox widget. + eliminate fixed array limits from matrix widget. Passing around 1000x1000 arrays was inefficient, and caused core dumps in the Perl binding for this widget. + correct one of the attrbox() calls in drawCDKMatrixCell(), which used a left-tee where a right-tee was needed (report by William L Davis). + add setCDKMatrixCells(), redefining setCDKMatrix() as a macro to call it. + add cleanCDKMatrixCell(). + correct position for right-aligned menus, which was off by one from 2003/11/30 changes (report/patch by William L Davis). 2003/12/01 - T.E.Dickey ======================================== + correct logic in char2Chtype() for <#UL>, <#UR> and <#LR>, broken in 1999/06/05 (report by William L Davis). 2003/11/30 - T.E.Dickey ======================================== + remove borderSize parameter from alignxy(). + modify all widgets to account for borderSize consistently, allowing one to display a widget that uses the full screen size (report by Phuah Yee Keat ). + add cdk_params.c, use this to simplify cli programs and add getopt processing systematically to the demos and examples. + correct an off-by-one in baseName() that would return the slash character in the result. + add setCDKCalendarMonthsNames() and setCDKCalendarDaysNames (patch by Stanislaw Bierowka ). + split-out several files from draw.c since they are wrappers for widgets rather than drawing functions. Doing this reduces the executable size: get_index.c, get_string.c, popup_dialog.c, popup_label.c, select_file.c, view_file.c and view_info.c + eliminate static MAX_LINES limit from graph-widget values. + eliminate static MAX_LINES limit from widget titles. + updated configure script, improved checks for curses functions. + updated config.guess, config.sub 2003/11/24 - T.E.Dickey ======================================== + display a "processing..." message in setCDKViewerInfo while building the internal data structures (request by Mike Leib). + modify viewer widget to compute the total number of lines to display, making it independent of the listSize parameter. + modify viewer widget to accept a negative listSize parameter, making it count the length of list[], ending with a null. + modify viewer_ex, adding -f, -i and -l options. The -f option bypasses the fselect widget, specifying the filename directly. The -i option tells whether to interpret embedded markup, and the -l option tells viewer_ex to load the file using an embedded link. 2003/11/19 - T.E.Dickey ======================================== + modify searches in viewer widget to allow for overlapping partial matches, e.g., if the pattern is "00A", it will find the match in a line consisting of "000A". Also corrected logic to matches can extend to the end of a line. + add 'N' to viewer to implement reverse search. + modify ':' command in viewer to start with current line number rather than 0. Also adjust the size of the scale widget to allow for very large line numbers, e.g., more than 5 digits. + remove an obsolete limit-check in viewer widget that limited view to 4996 lines, fix a few off-by-one indices. 2003/11/18 - T.E.Dickey ======================================== + correct viewer widget, making it interpret tabs and non-printing characters for the non-interpreted file viewer case. The curses library cannot display control characters in chtype's. + add cleanCDKViewer(). + rename a few .itemCount members to .listSize for consistency. + eliminate static list-size limit MAX_LINES from swindow, viewer widgets. Renamed .info, .infoPos, .infoLen to .list, .listPos and .listLen members to be consistent with other widgets. 2003/11/16 - T.E.Dickey ======================================== + suppress "." from fselect listing, since it was not useful. + eliminate static list-size limit MAX_ITEMS from alphalist, fselect itemlist, radio, scroll and selection widgets (request by Mike Leib). + change functions that set line-drawing characters to macros, mapping those to method calls in CDKOBJS. + add setCDKEntryBox(). + add setCDKMarqueeBox() and getCDKMarqueeBox(). + add setCDKMatrixBox() and getCDKMatrixBox(). + adjust some title lines to be offset by the borderSize rather than a hardcoded "1" (report by Max Mikhanosha). + strip trailing newlines from text read via pipe in execCDKSwindow(), lost in original cleanup (report by Max Mikhanosha ). 2003/04/18 - T.E.Dickey ================================================= + for variants built with ncursesw and pdcurses, name the libraries "-lcdkw" and "-lcdkX" respectively. + add a missing assignment to store the result in _injectCDKFScale() (report by Barry Davis ). + fix missing definition of mvwhline(), mvwvline() in pdcurses. + add a .c.i rule in top-level makefile + fix uninstall rule, was missing a line-continuation. + fix several prototypes in manpages which did not match header files (reported by Lucas Gonze ). + fix a few compiler warnings, e.g., by parentheses in drawCDKEntryField() and drawCDKMatrixCell(). + updates to configure script macros + add --with-ncursesw option. + add --with-XawPlus option. + add --with-curses-dir option. + modify CF_DISABLE_ECHO to make libtool quiet also. + use AC_PROG_PATH to find libtool; show the version which is found. + change sed delimiter to '%' to accommodate AFS. + improve/correct CF_HEADER_PATH, CF_LIBRARY_PATH to cover special cases of ncurses/ncursesw configurations. + change ordering of options in CF_ADD_CFLAGS, CF_ADD_CPPFLAGS, CF_INCLUDE_DIRS. + workaround gcc 3.x defects in CF_ADD_INCDIR. 2002/08/09 - T.E.Dickey ================================================= + fix entry, matrix, template, viewer widgets to display 8-bit input characters (reported by Bernhard Walle ). + modify manpage install to create links for each function name listed in the NAME section. + correct cursor location in dialog's radio-box, which was left on the separator line (reported by Peter Farley ) 2002/07/27 - T.E.Dickey ================================================= + several changes to make destroyCDKScreenObjects() and destroyCDKScreen() actually work (needed for perlcdk): + record all objects and screens created/destroyed, in cdkscreen.c + reimplement destroyCDKObject() by a function _destroyCDKObject(), which first does an erase for the given object, then calls the destroy method, and finally frees the object. + add a check in each erase-method to ensure that the object is still valid. + add check in setCDKGraphValues() to ensure that X and Y scales are nonzero, since they are used as denominators. This makes perlcdk's graph example work. + add configure check for curses feature which would allow one to move a subwindow, or (in the case of NetBSD curses) at least compile. + add configure check and fallback for addchnstr() to accommodate NetBSD's partial implementation of curses. + move version information to VERSION file. + add --with-libtool configure option + make most wgetch() calls use the object's inputWindow via the getcCDKObject() function. + improve type-checking and array-limits in cdkscreen.c + remove cdktype member from CDKSCREEN since it is redundant. + eliminate several fixed-buffers with new function writeBlanks(). + interpret home/end keys in entry widget. + warn about special keys such as insert which are not recognized in alphalist, entry, matrix, mentry, template (it was using the low 8 bits of those, inserting that). + rewrote/simplified dirName(). + rewrote/simplified baseName(). + eliminate fixed-size buffers in fselect.c + correct a couple of places where fselect.c freed constant memory. + correct an unterminated string in fselect.c tilde-expansion, and use $HOME if no account name is given. + simplified several functions using mvhline(), mvvline() and mvaddchnstr(). + add vFSCALE as a valid object type in cdkscreen.c + modify moveCursesWindow(), which did not work with ncurses after 2000/9/15 changes to use mvwin() in preference to directly modifying the _begx/_begy members of WINDOW. That made position_ex not work. The change was originally for NetBSD's curses implementation which does not move derived windows properly anyway. + simplify calls to moveCursesWindow() by moving null-pointer check inside that function. + change tab-expansion in char2Chtype() to expand based on the current length of the string rather than always to 8 columns. + correct limit-checks in stripWhiteSpace() + interpret back-tab in buttonbox.c and dialog.c inject-methods for symmetry with tab. + corrected return-values of button, matrix, scale widgets to match documentation as well as to conform with other widgets. + reorganized inject methods (which may return data of different types) to return the actual data in an area of the widget, and defined macros to preserve source-compatibility. + rewrote initCDKColor() to check if color is available before trying to initialize it, and to use the terminal's actual number of colors in making color pairs. + use 2-digit fields in bind_ex.c for time, date. + modify matrix.c to add borderSize before the column titles, to match the change to box layout. + modify matrix_ex.c to consistently center row-titles. Some were centered, some were right- and some left-justified. The change to justifyString() produced an odd effect. + add functions CDKVersion() chtype2String(). > patches by Tim Moloney: + added a setCDKxxxBackgroundAttrib() function to all the widgets. This function takes a chtype. The setCDKxxxBackgroundColor() still exists and converts from a character string to a chtype, but it now calls the new function to eliminate duplicate code. + fix minor bugs in marquee_ex and radio1_ex. + fix an off-by-one error in the dialog widget when it is not drawing its box. The buttons were displayed one line too high. + add object type to each widget. + correct _drawCDKEntry(), which did not account for whether a box was used when computing layout. + change moveCDKButton() from a function to a macro using moveCDKObject(). + add functions popupLabelAttrib() setCDKButtonboxButtonAttrib() setCDKEntryHighlight() > integrated/adapted changes by Grant Edwards: + make the destroy function in each widget a method in CDKOBJS. + make the inject function in each widget a method in CDKOBJS. (this was incomplete, and did not provide for different return-types) + add focus, unfocus, refreshData, saveData methods and supporting data to CDKOBJS (not all widgets implement these methods). See entry.c, itemlist.c, selection.c for example. + store a borderSize value in CDKOBJS for each widget, which is used to reserve space for a box/border around each widget if the Box parameter is true when creating the widget. Several related changes also made, including modifying the alignxy() interface to add a borderSize parameter. + modify justifyString() to not subtract 1 on each side, since that is generally assumed to be done to compensate for boxes drawn around the text. + change drawCDKItemlistField() to add a highlight parameter. + change the label window to a subwin() in entry.c + hide cursor while in popupLabel() function. + simplified scroll.c, a little. + add files button.c examples/radio1_ex.c examples/traverse_ex.c + added functions: destroyCDKScreenObjects() getCDKSelectionCurrent() setCDKSelectionCurrent() getCDKScrollCurrent() setCDKScrollCurrent() destroyCDKScreenObjects() cmpStrChstr() chstrncpy() + removed these functions: setCDKEntryBox() 2002/04/30 - T.E.Dickey ================================================= + correct parsing of in char2Chtype() where "xx" contains digits (patch by Robert R Landon ). + updated cdk.spec for RPM (patch by Vladimir Kondratiev ). + introduce CDKINCLUDES ifdef's so that any of the header files may be included separately. Previously only could be included due to interdependencies among the headers. + add some #undef's to cdk.h in case curses.h includes term.h producing a symbol conflict (reported by Kenneth Pronovici ). + miscellaneous updates to configure script, including workarounds for incompatibilies in autoconf 2.5x. 2002/02/25 - T.E.Dickey ================================================= + add cdk_process manpage. + remove redundant description of bindCDKObject() from several manpages. + add rcs identifiers to header files. + add ifdef's in each header file for C++, to make the C externs link properly without requiring the application to declare them (reported in comp.unix.programmer newsgroup by ). + correct typo in template.c introduced in 2000/01/16 substitutions to use macro isPlateChar() which made templates not work with interspersed punctuation (reported by jiny ). 2001/12/30 - T.E.Dickey ================================================= + remove some redundant wrefresh() calls in various widgets. + correct an uninitialized pointer in cli/cdkalphalist.c + modify cli/samples/alphalist.sh to check for non-empty return from the selection rather than hang attempting to find that account. + remove -B option from cli/samples/alphalist.sh since it should have a value, but does not. + corrected some display-limits in writeChtype() and writeChtypeAttrib(). + modify CDKreadFile() to trim newlines from file as read, making it more like the original readFile(). This is needed to prevent the trailing newlines loaded into label widgets from clearing the rest of the line when they are drawn. + add floatized-scale widget (Lutz Mueller ). + modify headers.sh script to remove gzip'd versions of the manpages just in case some were previously installed that way, i.e., by hand. The gzip'd version would be found instead of the new install. (prompted by a report by Ron Poulton ). + correct typo in uninstall rule for manpages which made "make installCDKHeaderFiles" remove the manpages after installing. 2001/04/21 - T.E.Dickey ================================================= + add an uninstall rule. + move the installed documentation to /usr/local/doc/cdk (it does not belong in /usr/local/include/cdk). + modify install rules so that references to header files such as cdk.h are transformed to , which matches the actual install location (reports by Pawel Gajda , Carlos Alberto Pereira Gomes and Ron Poulton , who found that Cdk's menu.h conflicts with ncurses' menu.h when building the Perl interface). + correct cli examples' callbacks, which did not return a value. + update config.guess and config.sub + modify CF_CURSES_LIBS to allow build with SunOS 4.x 5lib curses. + split out CF_CURSES_CPPFLAGS from CF_CURSES_LIBS to allow an interim check if the curses implementation is really ncurses. + modify some configure script macros to work when the curses header file is not , e.g., . + modify configure script macros to avoid using changequote(), which is broken in the current autoconf alpha versions, e.g., 2.49d. + change configure script macros to use $CPPFLAGS consistently for preprocessor options, and $CFLAG for other compiler flags. + modify several configure script macros which checked for $GCC, to ensure it is not actually the compiler name versus an existence check. 2001/01/06 - T.E.Dickey ================================================= + reverted part of 1999/6/5 change, allowing callback functions to return a value. Note that this makes PROCESSFN and BINDFN use the same prototype (report by Ian Eure ). + SCO OpenServer does not define S_IFSOCK 2000/09/23 - T.E.Dickey ================================================= + change literal 48's in calendar.c to '0'. + eliminate nonprinting/nonspace characters using macro CTRL(). + integrated new examples into makefiles. + use raiseCDKObject_ex.c and lowerCDKObject_ex.c to debug/fix the raiseCDKObject() and lowerCDKObject() functions which shared the same defect in 4.9.9 (the code did not properly update two objects, but modified screenIndex of one twice). + modified cli programs to work with CDKreadFile(), CDKsplitString() and CDKcountStrings() since readFile() and splitString() are not provided in this version. > reviewed/integrated changes from Mike Glover's 4.9.10 (August 2000): + add examples/raiseCDKObject_ex.c, examples/lowerCDKObject_ex.c + add cli subdirectory + modify itemlist.c to make labels one cell wider. + did not use changes to cdkscreen.c (see 1999/5/15). + did not use casts to unsigned char, since those are incorrect (they are casting chtype's which are wider than a char). 2000/09/15 - T.E.Dickey ================================================= + add/use configure check for some curses functions/macros which use internals of the WINDOW struct, which is opaque on NetBSD (patch by Simon Burge ). + update autoconf scripts (config.guess, config.sub, macros CF_CURSES_LIBS, CF_UPPER, CF_X_ATHENA) to my 20000819 autoconf patch. + revised man-pages: reorder so that functions are listed alphabetically within the NAME, SYNOPSIS, DESCRIPTION sections, the prototypes shown only in the SYNOPSIS section (and formatted for readability), remove excess wording and convert as needed to use tbl. 2000/08/28 - T.E.Dickey ================================================= + add cdk_position.3 man page. + rename cdk_cdk.3 to cdk.3 2000/08/20 - T.E.Dickey ================================================= + remove obsolete comments from manpages telling users to define NCURSES for that library. The configure script creates cdk_config.h, which has settings as needed. 2000/08/20 - T.E.Dickey ================================================= + fix some array-overruns in viewer.c if it happens to load a binary file. + fix symbol conflict with newkey in waitCDKLabel(), as well as keycode truncation in that function. 2000/06/28 - T.E.Dickey ================================================= + add RPM spec-file (Wai-Sun Chia ). + add Linux-specific makefile rule for generating a shared library (patch by Pawel Gajda ). + eliminate fixed-length lists assumed in getDirectoryContents() using new function CDKgetDirectoryContents(). + eliminate fixed-length lists assumed in readFile() using new function CDKreadFile(). + remove unused substring(). + use qsort-wrapper sortList() instead of quickSort(). + change configure.in to avoid having configure script check for X libraries as a side-effect of adding tests for PDCurses. + updates to configure script macros: CF_CURSES_FUNCS, CF_FIND_LIBRARY, CF_HEADER_PATH, CF_LIBRARY_PATH, CF_NCURSES_LIBS and CF_XOPEN_CURSES + updated config.guess, config.sub 2000/04/09 - T.E.Dickey ========================================== + modify newwin() call in subwindow_ex.c to account for actual screen size rather than assuming 25 lines (reported by Gary Funck ). + add CF_X_ATHENA and CF_X_TOOLKIT configure macros for --with-pdcurses option, needed if the Xcurses or dependent libraries are static rather than shared. + correct typo in configure check for HPUX 11.x (reported by Bjorn Helgaas ). 2000/02/18 - T.E.Dickey ========================================== + add case for HPUX 11.x use of cur_colr library (reported by Bjorn Helgaas ). + add configure option --with-pdcurses, to link with the X11 version of PDCurses. + eliminate quoted includes, in favor of bracketed form. + ifdef'd limits.h, moving that into cdk.h with a fallback definition for INT_MIN and INT_MAX. + minor fixes for building with SunOS 5lib version: configure check for getopt variables, correction to demos/Makefile.in 2000/01/17 - T.E.Dickey ========================================== + add lib-prefix and executable suffix checks to configure script for port to OS/2 EMX. + add configure check for lstat(). 2000/01/16 - T.E.Dickey ========================================== + drop dependency on usleep(), using napms() which is standard with SVr4 curses. + rewrote mode2Char(), making it table-driven and splitting out mode2Filetype() to make porting simpler, by putting ifdef's for S_ISSOCK in one place only. + use new freeCharList() to reduce clutter. + eliminate casts of NULL, to reduce clutter. + change several uses of control characters in source to use CONTROL() macro. + correct format of date shown in bind_ex.c + correct nonstandard getcwd() usage in fselect.c + change demo and example makefiles to not strip executables. + modify demo/Makefile.in to work around Solaris' make program which does not process ".c" rule as desired. 2000/01/08 - T.E.Dickey ========================================== + fix compiler warnings with Solaris cc. 1999/12/19 - T.E.Dickey ========================================== + update email and url for Mike Glover based on 4.9.9 version dated 1999/7/29. 1999/06/26 - T.E.Dickey ========================================== + add configure options --with-dbmalloc and --with-dmalloc to simplify testing with those libraries. + correct error in rewrite of char2Chtype which broke repeat-counts. 1999/06/05 - T.E.Dickey ========================================== + correct reference to uninitialized memory in bindCDKObject() + add/use BINDFN_PROTO macro to simplify maintenance of Perl extension, corrected corresponding functions to be typed void. + shorten/simplify mapChtype by making it table-driven. + shorten/simplify char2DisplayType by making it table-driven. + replace splitString() by CDKsplitString() and CDKcountStrings() to eliminate buffer-limits. + simplify char2Chtype, eliminate fixed-buffer limits. + prevent recursion in segvTrap. 1999/05/29 - T.E.Dickey ========================================== + remove bindFunction and bindData arrays from individual widgets + make draw, erase, move methods accessed only via the CDKFUNCS table in each widget. + add move method for menu.c + split-out positionCDKObject function from widget code. 1999/05/23 - T.E.Dickey ========================================== + remove WIN_WIDTH and related macros, use the more common getmaxx, and similar macros. Provide fallback definitions for those. + replace log10() call in intlen with simple recursion. + add getendx() and getendy() macros. + add moveCursesWindow(). + generate include/cdk_config.h, to simplify ifdef'ing for gcc features, and to reduce clutter in the makefiles. + add functions ceilCDK() and floorCDK() to eliminate dependency on the math library + simplified, corrected upper-limit checks in alignxy(). + change bindings to be dynamically allocated, part of the CDKOBJS structure. + correct overlap between title and percentage in drawCDKViewerInfo() 1999/05/15 - T.E.Dickey ========================================== + revised configure script, using autoconf macros which I've written for other programs to check for ncurses configuration. + corrected language of copyrights - Mike Glover's intent to retain copyright of CDK is not served by putting a 1990 copyright attributed to UC Berkeley. + except for unused parameters, fix gcc compiler warnings. + change prototypes to not use parameter names, since this causes namespace pollution. + make functions that do not have public prototypes static. + add missing exit() call in fileview.c, after endCDK() call. + move delwin() calls before endCDK() call in a few other examples. + correct apparent bug in widgets which process a binding (such as KEY_DOWN, in the alphalist and fileview.c demos). They set the exitType to vESCAPE_HIT rather than the expected vEARLY_EXIT. + ifdef'd out some debug code in scroll_ex.c + correct a loop limit freeing mesg[] array in selection_ex.c + move common object data into new struct CDKOBJS, making cdkscreen.c much simpler and extensible. + change erase and draw functions (called from cdkscreen.c) to object pointers, so only widgets used are linked, making example programs half as big. 4.9.7 -> 4.9.8 (December 1998) ========================================== * Changed the way key bindings worked. If the key binding exited with a non-zero value then the widget would exit like the user pressed the escape key. This provides more control over key binding callbacks. Now the bind prototype is: int function (EObjectType cdktype, void *object, void *clientData, chtype key); * Reversed the order of this file. The most recent first. 4.9.6 -> 4.9.7 (December 1998) ========================================== * Went from static Makefiles to autoconf and configure. (finally) 4.9.2 -> 4.9.6 ========================================== * Once again, it's a complete mystery. 4.9.1 -> 4.9.2 ========================================== * Changed the activateCDKViewer funtion to be more compliant with the rest of the activateCDKXXX functions. 4.9.0 -> 4.9.1 ========================================== * Added the functions setCDKXXXULChar/URChar/LLChar/LRChar, setCDKXXXVerticalChar, setCDKHorizontalChar, and setCDKXXXBoxAttribute to each of the widgets but the menu widget. These functions allow the programmer to define the corner characters of the widget as well as the vertical, horizontal, and attributes of the box. * Added the function setCDKXXXBackgroundColor. This sets the background color of the widget's window. * Added makefile for the SGI * Created the buttonbox widget. * Added in Ctrl-N and Ctrl-P to switch between buttons on the dialog box and viewer. * Added the functions setCDKRadioItems and setCDKSelectionItems. * Added the functions setCDKRadioTitle, setCDKSelectionTitle, setCDKScrollTitle. 4.8.3 -> 4.9.0 ========================================== * Added a parameter to the setCDKViewer function to turn on/off the line X of Y in the top left corner. * Removed the eraseCDKXXX in each of the drawCDKXXX functions. This results in a quicker refresh and less overhead when using the widgets. This should make things A LOT faster. (I suppose it's about time I had complete faith in curses optimized screen refreshing. :) ) The side effect is that you might have to change some programs to force an eraseCDKXXX/drawCDKXXX when you think the screen is garbled. * Added a little bit of logic in char2Chtype when a terminal cannot display color, bold will be used instead. * Cleaned up the way filename completion works in the file selector. You may now type in a path and hit tab and that directory tree will be loaded. * Added the ability to use the ~ character to refer to a users home directory, in the file selector. (like csh variants) * Changed the setCDKXXX functions. Made many different setCDKXXX functions, one for each item being set. This reduces the overhead of all the setCDKXXX functions. * Drastically changed cdk.h. Split the widget definitions and functions into their own header files. This makes it easier to expand CDK. * Added the ability to have multiple line titles on most of the widgets. * Added the functions setCDKSelectionChoice/getCDKSelectionChoice to set/get a single choice value from a selection list. * Added the functions setCDKSelectionModes/getCDKSelectionModes to set/get the ability to set some items in the selection list as editable/uneditable. * Added makefile for the DEC Alpha (I forget who sent me this, if you want recognition, mail me again) * Created a 'visual install' using some of the widgets. Try it. (type in make vinstall once the library has been made) * Added the ability to set the width of the widget respective to the screen size. If you pass in a negative value, the widget will adjust to the width of the window the widget sits in minus the given value. If zero is given, then the widget will be the full width of the window. This removes the need to know how wide the window is when the widget is created. * Changed the demos and examples makefiles. I was making things too difficult. It's simpler and easier to compile these directories. * Re-Purified the code. (no leaks, no UMR's, no problem... :) ) * Quantified the code a bit for those who complained about the performance. It has been sped up; I just hope it's enough for some of you speed freaks. :) * Added the functions get/setCDKTemplateMin. This allows you to set the minimum number of characters to type in before the widget will accept the typed in value. * Changed the documentation to reflect all the changes. 4.8.1 -> 4.8.2 -> 4.8.3 ========================================== * It's a complete mystery. 4.8.0 -> 4.8.1 ========================================== * Changed the bind prototype function from void function (EObjectType cdktype, void *object, void *clientData); to void function (EObjectType cdktype, void *object, void *clientData, chtype key); * Added scroll bars to the scrolling list, the selection list, and the radio list. * Modified the template widget so the new character takes on the color/attributes of the plate widget. * Added the function classes moveCDKXXX and positionCDKXXX. * Changed the structure of the makefile and created a single makefile for each platform to compile on. * Added support for the delete character KEY_DC. 4.7.0 -> 4.8.0 ========================================== * Fixed bugs documented by Miguel Marques (miguel@apex.cos.yorku.ca) in the entry and mentry widgets. The bug displays itself when you use vHINT or vINT display types. The vHINT actually showed the numbers being typed in (which goes against the hidden element of this display type) and in certain cases vINT allowed non-alpha characters to be entered. * Added compile support for Free BSD. * Cleaned up the behavior of the entry field. * Cleaned up the behavior of the scrolling list. * Cleaned up the behavior of the radio list. * Cleaned up the behavior of the selection list. * Changed (improved) the behavior of the file selector widget. * Made the activateCDKFselect behave like the other widgets. * Added injectCDKFselect function. * Added the calendar widget. * Added the slider widget. * Added the alphalist widget on the request of Luigi Rizzo. (luigi@ien.unipi.it) * Fixed a bug with addCDKScrollItem. * Fixed segmentation fault in the rolodex demo. * Changed the macros MAX, MIN, and DIFF to MAXIMUM, MINIMUM, and DIFFERENCE respectively to avoid conflicts. * Fixed errors with the alphalist and fselect widgets. * Added the link format comand for the file viewer. This allows users to 'hyper-link' text files. * Removed the use of CTRL-N. * Added the ability to load/save with the scrolling window. * Added filename completion to the file selector. * Cleaned up massive changes and errors in the documentation. * Added 'emacs-like' field editing capabilities to the entry and mentry widgets. 4.6.1 -> 4.7.0 ========================================== * Added injectCDKXXX class of functions. This allows you to inject a single character into the widget. * Changed the activateCDKXXX to take an array of chtype to send in a set of predefined characters. This is very useful for performing automated tests of your programs. * Added functions setCDKXXXPreProcess and setCDKXXXPosProcess to perform actions before and after a character has been hit. * Made the use of CTRL-N consistent. * Fixed manual page errors. * Added the ability to cut text from the entry, mentry, and template widgets. (uses a global buffer) * Added the ability to copy text from the entry, mentry, and template widgets. (uses a global buffer) * Added the ability to paste text into the entry, mentry, and template widgets. (uses a global buffer) * Added the use of the escape key to exit a widget early. * Added the functions addCDKScroll/deleteCDKScroll to insert and delete items in an active scrolling list. * Added a parameter to the menu to specify where the menu windows were to be drawn. (top or bottom) * Added execCDKSwindow to the swindow function list. This allows the user to 'spawn' a command and direct the output to the scrolling window. 4.6.0 -> 4.6.1 ========================================== * Removed the callback function parameter from the entry, mentry, matrix, and template widgets. Added in a function setCDKXXXCB. The XXX is the name of the widget. * Changed the viewer widget functions around. Moved activateCDKViewer to setCDKViewer. Moved manageCDKViewer to activateCDKViewer and removed the old setCDKViewer. * Added in special drawing characters. * Added in indent format to indent lines. 4.6.0 (January 1996) ========================================== * First pulic release of Cdk. 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 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. cdk-5.0-20060507/COPYING0000644000175100001440000001151010221256715012571 0ustar tomusersModifications copyright Thomas Dickey 1999, 2000, 2001, 2002, 2003, 2004, 2005 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. */ cdk-5.0-20060507/EXPANDING0000644000175100001440000000640307027305044013003 0ustar tomusersCdk 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 cdk-5.0-20060507/INSTALL0000644000175100001440000000371207520545106012577 0ustar tomusersCdk 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 cdk-5.0-20060507/Makefile.in0000644000175100001440000003217510421020455013605 0ustar tomusers# $Id: Makefile.in,v 1.74 2006/04/17 23:13:49 tom Exp $ # # Copyright 2001-2005,2006 Thomas 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) LIB_ROOTNAME = @LIB_ROOTNAME@ LIB_SUFFIX = @LIB_SUFFIX@ VERSION_MAJOR = @VERSION_MAJOR@ VERSION_MINOR = @VERSION_MINOR@ VERSION = $(VERSION_MAJOR).$(VERSION_MINOR) CDKLIB = @LIB_PREFIX@@LIB_ROOTNAME@$(LIB_SUFFIX) CDKSHLIB = @LIB_PREFIX@@LIB_ROOTNAME@.so.$(VERSION) SONAME = @LIB_PREFIX@@LIB_ROOTNAME@.so.$(VERSION_MAJOR) prefix = @prefix@ exec_prefix = @exec_prefix@ srcdir = @srcdir@ VPATH = $(srcdir) x = @EXEEXT@ o = .@OBJEXT@ a = @LIB_SUFFIX@ DESTDIR = includedir = $(DESTDIR)@includedir@ libdir = $(DESTDIR)@libdir@ mandir = $(DESTDIR)@mandir@ DOCUMENT_DIR = @prefix@/doc/cdk INCLUDE_DIR = $(includedir)/cdk LIB_DIR = $(libdir) MAN_DIR = $(mandir)/man@MAN_DIR@ MANSECT = @MANSECT@ CC = @CC@ CPP = @CPP@ AR = @AR@ RANLIB = @LIB_PREP@ RM = rm -f LIBS = @LIBS@ CFLAGS = @CFLAGS@ @EXTRA_CFLAGS@ CPPFLAGS = @DEFS@ -I./include -I$(srcdir)/include @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBTOOL = @LIBTOOL@ @ECHO_LT@ LIBTOOL_CLEAN = @LIB_CLEAN@ LIBTOOL_COMPILE = @LIB_COMPILE@ LIBTOOL_CREATE = @LIB_CREATE@ LIBTOOL_LINK = @LIB_LINK@ LIBTOOL_INSTALL = @LIB_INSTALL@ LIBTOOL_UNINSTALL = @LIB_UNINSTALL@ 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 .os .i DEFAULT = $(CDKLIB) default :: $(DEFAULT) # # 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_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 \ 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 \ 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 :: $(DEFAULT) $(CDKLIB) :: $(OBJECTS) @echo creating $@; $(LIBTOOL_CREATE) $@ $(LIB_OBJECT) @$(RANLIB) $@ cdkshlib $(CDKSHLIB) :: $(CDKSHOBJS) gcc -shared -Wl,-soname=$(SONAME) $(LDFLAGS) -o $(CDKSHLIB) $(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 :: $(INCLUDE_DIR) 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. # install \ installCDKHeaderFiles :: $(INCLUDE_DIR) headers.sed $(MY_HDR) @echo "Installing CDK header files in $(INCLUDE_DIR)..." $(SHELL) $(srcdir)/headers.sh -x "$(INSTALL_DATA)" -d $(INCLUDE_DIR) -s $(srcdir) $(MY_HDR) @for i in $(CDKHDR); do \ $(SHELL) $(srcdir)/headers.sh -x "$(INSTALL_DATA)" -d $(INCLUDE_DIR) -s $(srcdir) include/$$i; \ done uninstall \ uninstallCDKHeaderFiles :: @echo "Uninstalling CDK header files from $(INCLUDE_DIR)..." @- for i in $(MY_HDR); do \ $(RM) $(INCLUDE_DIR)/`basename $$i`; \ done @- for i in $(CDKHDR); do \ $(RM) $(INCLUDE_DIR)/$$i; \ done # # This installs the CDK library. # install \ installCDKLibrary :: $(LIB_DIR) $(CDKLIB) @echo "Installing CDK library" @$(INSTALL_LIB) $(CDKLIB) $(LIB_DIR)/$(CDKLIB) uninstall \ uninstallCDKLibrary :: @echo "Uninstalling CDK library" @- $(UNINSTALL_LIB) $(LIB_DIR)/$(CDKLIB) # # This installs the CDK shared library. The rules are for an RPM spec, and # not of general interest. # installCDKSHLibrary :: $(LIB_DIR) $(CDKSHLIB) @echo "Installing CDK library" @echo " $(INSTALL_DATA) $(CDKSHLIB) $(LIB_DIR)" @$(INSTALL_DATA) $(CDKSHLIB) $(LIB_DIR) @echo " ln -sf $(CDKSHLIB) $(LIB_DIR)/@LIB_PREFIX@@LIB_ROOTNAME@.so" @ln -sf $(CDKSHLIB) $(LIB_DIR)/@LIB_PREFIX@@LIB_ROOTNAME@.so uninstall \ uninstallCDKSHLibrary :: @- $(RM) $(LIB_DIR)/@LIB_PREFIX@@LIB_ROOTNAME@.so @- $(RM) $(LIB_DIR)/$(CDKSHLIB) headers.sed : $(srcdir)/headers.sh $(SHELL) $(srcdir)/headers.sh -p CDK -c include/cdk_config.h -d $(INCLUDE_DIR) -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] # # Clean up after ourselves... # clean :: @- $(RM) -r autom4te.cache - $(LIBTOOL_CLEAN) $(RM) $(LIB_OBJECT) $(CDKLIB) - $(RM) *.i *.os $(CDKSHLIB) - $(RM) headers.sed manpage.sed core tags *~ $(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 @- $(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.i: @RULE_CC@ @ECHO_CC@$(CPP) $(CPPFLAGS) -E -C $< >$@ .c.os: @RULE_CC@ @ECHO_CC@$(CC) $(CFLAGS) $(CPPFLAGS) -c -fPIC $< -o $@ man \ $(DOCUMENT_DIR) \ $(INCLUDE_DIR) \ $(LIB_DIR) \ $(MAN_DIR) : ; $(srcdir)/mkdirs.sh $@ # # 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) >$@ cdk-5.0-20060507/NOTES0000644000175100001440000000441106750146556012370 0ustar tomusersCdk 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 cdk-5.0-20060507/README0000644000175100001440000001711610427500171012422 0ustar tomusers-- $Id: README,v 1.6 2006/05/07 23:19:21 tom Exp $ ------------------------------------------------------------------------------- Copyright Thomas Dickey 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 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. cdk-5.0-20060507/TODO0000644000175100001440000000456407027305146012244 0ustar tomusersCdk 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 cdk-5.0-20060507/VERSION0000644000175100001440000000002310427466351012612 0ustar tomusers4:0:3 5.0 20060507 cdk-5.0-20060507/aclocal.m40000644000175100001440000022516410354066375013422 0ustar tomusersdnl $Id: aclocal.m4,v 1.31 2005/12/26 22:21:49 tom Exp $ dnl macros used for CDK configure script dnl -- T.E.Dickey dnl --------------------------------------------------------------------------- dnl --------------------------------------------------------------------------- dnl CF_AC_PREREQ version: 2 updated: 1997/09/06 13:24:56 dnl ------------ dnl Conditionally generate script according to whether we're using the release dnl version of autoconf, or a patched version (using the ternary component as dnl the patch-version). define(CF_AC_PREREQ, [CF_PREREQ_COMPARE( AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])), [$1], [$2], [$3])])dnl dnl --------------------------------------------------------------------------- dnl CF_ADD_CFLAGS version: 7 updated: 2004/04/25 17:48:30 dnl ------------- dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS dnl The second parameter if given makes this macro verbose. dnl dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS, dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily dnl confused by the quotes (which require backslashes to keep them usable). AC_DEFUN([CF_ADD_CFLAGS], [ cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in $1 do case $cf_fix_cppflags in no) case $cf_add_cflags in #(vi -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi case $cf_add_cflags in -D*) cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'` test "${cf_add_cflags}" != "${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test $cf_fix_cppflags = yes ; then cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" continue elif test "${cf_tst_cflags}" = "\"'" ; then cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" continue fi ;; esac case "$CPPFLAGS" in *$cf_add_cflags) #(vi ;; *) #(vi cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" ;; esac ;; *) cf_new_cflags="$cf_new_cflags $cf_add_cflags" ;; esac ;; yes) cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'` test "${cf_add_cflags}" != "${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then ifelse($2,,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)]) CFLAGS="$CFLAGS $cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then ifelse($2,,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)]) CPPFLAGS="$cf_new_cppflags $CPPFLAGS" fi if test -n "$cf_new_extra_cppflags" ; then ifelse($2,,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)]) EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" fi AC_SUBST(EXTRA_CPPFLAGS) ])dnl dnl --------------------------------------------------------------------------- dnl CF_ADD_INCDIR version: 4 updated: 2002/12/21 14:25:52 dnl ------------- dnl Add an include-directory to $CPPFLAGS. Don't add /usr/include, since it's dnl redundant. We don't normally need to add -I/usr/local/include for gcc, dnl but old versions (and some misinstalled ones) need that. To make things dnl worse, gcc 3.x gives error messages if -I/usr/local/include is added to dnl the include-path). AC_DEFUN([CF_ADD_INCDIR], [ for cf_add_incdir in $1 do while true do case $cf_add_incdir in /usr/include) # (vi ;; /usr/local/include) # (vi if test "$GCC" = yes then cf_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$cf_add_incdir" AC_TRY_COMPILE([#include ], [printf("Hello")], [], [CPPFLAGS="$cf_save_CPPFLAGS"]) fi ;; *) # (vi CPPFLAGS="$CPPFLAGS -I$cf_add_incdir" ;; esac cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'` test "$cf_top_incdir" = "$cf_add_incdir" && break cf_add_incdir="$cf_top_incdir" done done ])dnl dnl --------------------------------------------------------------------------- dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34 dnl ---------------- dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES' dnl in the sharutils 4.2 distribution. AC_DEFUN([CF_ANSI_CC_CHECK], [ AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[ cf_cv_ansi_cc=no cf_save_CFLAGS="$CFLAGS" cf_save_CPPFLAGS="$CPPFLAGS" # Don't try gcc -ansi; that turns off useful extensions and # breaks some systems' header files. # AIX -qlanglvl=ansi # Ultrix and OSF/1 -std1 # HP-UX -Aa -D_HPUX_SOURCE # SVR4 -Xc # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes) for cf_arg in "-DCC_HAS_PROTOS" \ "" \ -qlanglvl=ansi \ -std1 \ -Ae \ "-Aa -D_HPUX_SOURCE" \ -Xc do CF_ADD_CFLAGS($cf_arg) AC_TRY_COMPILE( [ #ifndef CC_HAS_PROTOS #if !defined(__STDC__) || (__STDC__ != 1) choke me #endif #endif ],[ int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);};], [cf_cv_ansi_cc="$cf_arg"; break]) done CFLAGS="$cf_save_CFLAGS" CPPFLAGS="$cf_save_CPPFLAGS" ]) if test "$cf_cv_ansi_cc" != "no"; then if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then CF_ADD_CFLAGS($cf_cv_ansi_cc) else AC_DEFINE(CC_HAS_PROTOS) fi fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_ANSI_CC_REQD version: 3 updated: 1997/09/06 13:40:44 dnl --------------- dnl For programs that must use an ANSI compiler, obtain compiler options that dnl will make it recognize prototypes. We'll do preprocessor checks in other dnl macros, since tools such as unproto can fake prototypes, but only part of dnl the preprocessor. AC_DEFUN([CF_ANSI_CC_REQD], [AC_REQUIRE([CF_ANSI_CC_CHECK]) if test "$cf_cv_ansi_cc" = "no"; then AC_ERROR( [Your compiler does not appear to recognize prototypes. You have the following choices: a. adjust your compiler options b. get an up-to-date compiler c. use a wrapper such as unproto]) fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31 dnl -------------- dnl Allow user to disable a normally-on option. AC_DEFUN([CF_ARG_DISABLE], [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl dnl --------------------------------------------------------------------------- dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31 dnl ------------- dnl Allow user to enable a normally-off option. AC_DEFUN([CF_ARG_ENABLE], [CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl dnl --------------------------------------------------------------------------- dnl CF_ARG_OPTION version: 3 updated: 1997/10/18 14:42:41 dnl ------------- dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus dnl values. dnl dnl Parameters: dnl $1 = option name dnl $2 = help-string dnl $3 = action to perform if option is not default dnl $4 = action if perform if option is default dnl $5 = default option value (either 'yes' or 'no') AC_DEFUN([CF_ARG_OPTION], [AC_ARG_ENABLE($1,[$2],[test "$enableval" != ifelse($5,no,yes,no) && enableval=ifelse($5,no,no,yes) if test "$enableval" != "$5" ; then ifelse($3,,[ :]dnl ,[ $3]) ifelse($4,,,[ else $4]) fi],[enableval=$5 ifelse($4,,,[ $4 ])dnl ])])dnl dnl --------------------------------------------------------------------------- dnl CF_CHECK_CACHE version: 10 updated: 2004/05/23 13:03:31 dnl -------------- dnl Check if we're accidentally using a cache from a different machine. dnl Derive the system name, as a check for reusing the autoconf cache. dnl dnl If we've packaged config.guess and config.sub, run that (since it does a dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM dnl which is useful in cross-compiles. dnl dnl Note: we would use $ac_config_sub, but that is one of the places where dnl autoconf 2.5x broke compatibility with autoconf 2.13 AC_DEFUN([CF_CHECK_CACHE], [ if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then ifelse([$1],,[AC_CANONICAL_HOST],[$1]) system_name="$host_os" else system_name="`(uname -s -r) 2>/dev/null`" if test -z "$system_name" ; then system_name="`(hostname) 2>/dev/null`" fi fi test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name") AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"]) test -z "$system_name" && system_name="$cf_cv_system_name" test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name) if test ".$system_name" != ".$cf_cv_system_name" ; then AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)) AC_ERROR("Please remove config.cache and try again.") fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_CHECK_CFLAGS version: 2 updated: 2001/12/30 19:09:58 dnl --------------- dnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from dnl a build-configuration such as imake. These have the pitfall that they dnl often contain compiler-specific options which we cannot use, mixed with dnl preprocessor options that we usually can. AC_DEFUN([CF_CHECK_CFLAGS], [ CF_VERBOSE(checking additions to CFLAGS) cf_check_cflags="$CFLAGS" cf_check_cppflags="$CPPFLAGS" CF_ADD_CFLAGS($1,yes) if test "$cf_check_cflags" != "$CFLAGS" ; then AC_TRY_LINK([#include ],[printf("Hello world");],, [CF_VERBOSE(test-compile failed. Undoing change to \$CFLAGS) if test "$cf_check_cppflags" != "$CPPFLAGS" ; then CF_VERBOSE(but keeping change to \$CPPFLAGS) fi CFLAGS="$cf_check_flags"]) fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_CURSES_CHTYPE version: 6 updated: 2003/11/06 19:59:57 dnl ---------------- dnl Test if curses defines 'chtype' (usually a 'long' type for SysV curses). AC_DEFUN([CF_CURSES_CHTYPE], [ AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl AC_CACHE_CHECK(for chtype typedef,cf_cv_chtype_decl,[ AC_TRY_COMPILE([#include <${cf_cv_ncurses_header-curses.h}>], [chtype foo], [cf_cv_chtype_decl=yes], [cf_cv_chtype_decl=no])]) if test $cf_cv_chtype_decl = yes ; then AC_DEFINE(HAVE_TYPE_CHTYPE) AC_CACHE_CHECK(if chtype is scalar or struct,cf_cv_chtype_type,[ AC_TRY_COMPILE([#include <${cf_cv_ncurses_header-curses.h}>], [chtype foo; long x = foo], [cf_cv_chtype_type=scalar], [cf_cv_chtype_type=struct])]) if test $cf_cv_chtype_type = scalar ; then AC_DEFINE(TYPE_CHTYPE_IS_SCALAR) fi fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_CURSES_CPPFLAGS version: 7 updated: 2003/06/06 00:48:41 dnl ------------------ dnl Look for the curses headers. AC_DEFUN([CF_CURSES_CPPFLAGS],[ AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[ cf_cv_curses_incdir=no case $host_os in #(vi hpux10.*|hpux11.*) #(vi test -d /usr/include/curses_colr && \ cf_cv_curses_incdir="-I/usr/include/curses_colr" ;; sunos3*|sunos4*) test -d /usr/5lib && \ test -d /usr/5include && \ cf_cv_curses_incdir="-I/usr/5include" ;; esac ]) test "$cf_cv_curses_incdir" != no && CPPFLAGS="$cf_cv_curses_incdir $CPPFLAGS" AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[ cf_cv_ncurses_header=none for cf_header in \ curses.h \ ncurses.h \ ncurses/curses.h \ ncurses/ncurses.h do AC_TRY_COMPILE([#include <${cf_header}>], [initscr(); tgoto("?", 0,0)], [cf_cv_ncurses_header=$cf_header; break],[]) done ]) if test "$cf_cv_ncurses_header" = none ; then AC_MSG_ERROR(No curses header-files found) fi # cheat, to get the right #define's for HAVE_NCURSES_H, etc. AC_CHECK_HEADERS($cf_cv_ncurses_header) ])dnl dnl --------------------------------------------------------------------------- dnl CF_CURSES_FUNCS version: 12 updated: 2003/11/06 19:59:57 dnl --------------- dnl Curses-functions are a little complicated, since a lot of them are macros. AC_DEFUN([CF_CURSES_FUNCS], [ AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl AC_REQUIRE([CF_XOPEN_CURSES]) AC_REQUIRE([CF_CURSES_TERM_H]) for cf_func in $1 do CF_UPPER(cf_tr_func,$cf_func) AC_MSG_CHECKING(for ${cf_func}) CF_MSG_LOG(${cf_func}) AC_CACHE_VAL(cf_cv_func_$cf_func,[ eval cf_result='$ac_cv_func_'$cf_func if test ".$cf_result" != ".no"; then AC_TRY_LINK([ #ifdef HAVE_XCURSES #include char * XCursesProgramName = "test"; #else #include <${cf_cv_ncurses_header-curses.h}> #if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H) #include #else #if defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H) #include #else #ifdef HAVE_TERM_H #include #endif #endif #endif #endif], [ #ifndef ${cf_func} long foo = (long)(&${cf_func}); exit(foo == 0); #endif ], [cf_result=yes], [cf_result=no]) fi eval 'cf_cv_func_'$cf_func'=$cf_result' ]) # use the computed/retrieved cache-value: eval 'cf_result=$cf_cv_func_'$cf_func AC_MSG_RESULT($cf_result) if test $cf_result != no; then AC_DEFINE_UNQUOTED(HAVE_${cf_tr_func}) fi done ])dnl dnl --------------------------------------------------------------------------- dnl CF_CURSES_LIBS version: 23 updated: 2003/11/06 19:59:57 dnl -------------- dnl Look for the curses libraries. Older curses implementations may require dnl termcap/termlib to be linked as well. Call CF_CURSES_CPPFLAGS first. AC_DEFUN([CF_CURSES_LIBS],[ AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl AC_MSG_CHECKING(if we have identified curses libraries) AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>], [initscr(); tgoto("?", 0,0)], cf_result=yes, cf_result=no) AC_MSG_RESULT($cf_result) if test "$cf_result" = no ; then case $host_os in #(vi freebsd*) #(vi AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"]) ;; hpux10.*|hpux11.*) #(vi AC_CHECK_LIB(cur_colr,initscr,[ LIBS="-lcur_colr $LIBS" ac_cv_func_initscr=yes ],[ AC_CHECK_LIB(Hcurses,initscr,[ # HP's header uses __HP_CURSES, but user claims _HP_CURSES. LIBS="-lHcurses $LIBS" CPPFLAGS="-D__HP_CURSES -D_HP_CURSES $CPPFLAGS" ac_cv_func_initscr=yes ])]) ;; linux*) # Suse Linux does not follow /usr/lib convention LIBS="$LIBS -L/lib" ;; sunos3*|sunos4*) test -d /usr/5lib && \ LIBS="$LIBS -L/usr/5lib -lcurses -ltermcap" ac_cv_func_initscr=yes ;; esac if test ".$ac_cv_func_initscr" != .yes ; then cf_save_LIBS="$LIBS" cf_term_lib="" cf_curs_lib="" if test ".${cf_cv_ncurses_version-no}" != .no then cf_check_list="ncurses curses cursesX" else cf_check_list="cursesX curses ncurses" fi # Check for library containing tgoto. Do this before curses library # because it may be needed to link the test-case for initscr. AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[ for cf_term_lib in $cf_check_list termcap termlib unknown do AC_CHECK_LIB($cf_term_lib,tgoto,[break]) done ]) # Check for library containing initscr test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS" for cf_curs_lib in $cf_check_list xcurses jcurses unknown do AC_CHECK_LIB($cf_curs_lib,initscr,[break]) done test $cf_curs_lib = unknown && AC_ERROR(no curses library found) LIBS="-l$cf_curs_lib $cf_save_LIBS" if test "$cf_term_lib" = unknown ; then AC_MSG_CHECKING(if we can link with $cf_curs_lib library) AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>], [initscr()], [cf_result=yes], [cf_result=no]) AC_MSG_RESULT($cf_result) test $cf_result = no && AC_ERROR(Cannot link curses library) elif test "$cf_curs_lib" = "$cf_term_lib" ; then : elif test "$cf_term_lib" != predefined ; then AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries) AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>], [initscr(); tgoto((char *)0, 0, 0);], [cf_result=no], [ LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS" AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>], [initscr()], [cf_result=yes], [cf_result=error]) ]) AC_MSG_RESULT($cf_result) fi fi fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_CURSES_SETBEGYX version: 1 updated: 2002/07/22 22:38:19 dnl ------------------ dnl See if we can define a function to set a window's beginning y/x coordinates. AC_DEFUN([CF_CURSES_SETBEGYX],[ AC_MSG_CHECKING(how to define setbegyx) cf_result=ERR for cf_check in \ '((win)->_begy = (y), (win)->_begx = (x), OK)' do AC_TRY_COMPILE([ #include <${cf_cv_ncurses_header-curses.h}> ],[ WINDOW *win = 0; #define setbegyx(win,y,x) $cf_check setbegyx(win, 2, 3); ],[cf_result=$cf_check; break]) done AC_MSG_RESULT("$cf_result") AC_DEFINE_UNQUOTED(setbegyx(win,y,x),$cf_result) ])dnl dnl --------------------------------------------------------------------------- dnl CF_CURSES_TERM_H version: 6 updated: 2003/11/06 19:59:57 dnl ---------------- dnl SVr4 curses should have term.h as well (where it puts the definitions of dnl the low-level interface). This may not be true in old/broken implementations, dnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4 dnl running with Solaris 2.5.1). AC_DEFUN([CF_CURSES_TERM_H], [ AC_CACHE_CHECK(for term.h, cf_cv_term_header,[ AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl # If we found , look for , but always look # for if we do not find the variant. for cf_header in \ `echo ${cf_cv_ncurses_header-curses.h} | sed -e 's%/.*%/%'`term.h \ term.h do AC_TRY_COMPILE([ #include <${cf_cv_ncurses_header-curses.h}> #include <${cf_header}>], [WINDOW *x], [cf_cv_term_header=$cf_header break], [cf_cv_term_header=no]) done ]) case $cf_cv_term_header in #(vi term.h) #(vi AC_DEFINE(HAVE_TERM_H) ;; ncurses/term.h) AC_DEFINE(HAVE_NCURSES_TERM_H) ;; ncursesw/term.h) AC_DEFINE(HAVE_NCURSESW_TERM_H) ;; esac ])dnl dnl --------------------------------------------------------------------------- dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52 dnl ---------- dnl "dirname" is not portable, so we fake it with a shell script. AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl dnl --------------------------------------------------------------------------- dnl CF_DISABLE_ECHO version: 10 updated: 2003/04/17 22:27:11 dnl --------------- dnl You can always use "make -n" to see the actual options, but it's hard to dnl pick out/analyze warning messages when the compile-line is long. dnl dnl Sets: dnl ECHO_LT - symbol to control if libtool is verbose dnl ECHO_LD - symbol to prefix "cc -o" lines dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o) dnl SHOW_CC - symbol to put before explicit "cc -c" lines dnl ECHO_CC - symbol to put before any "cc" line dnl AC_DEFUN([CF_DISABLE_ECHO],[ AC_MSG_CHECKING(if you want to see long compiling messages) CF_ARG_DISABLE(echo, [ --disable-echo display "compiling" commands], [ ECHO_LT='--silent' ECHO_LD='@echo linking [$]@;' RULE_CC=' @echo compiling [$]<' SHOW_CC=' @echo compiling [$]@' ECHO_CC='@' ],[ ECHO_LT='' ECHO_LD='' RULE_CC='# compiling' SHOW_CC='# compiling' ECHO_CC='' ]) AC_MSG_RESULT($enableval) AC_SUBST(ECHO_LT) AC_SUBST(ECHO_LD) AC_SUBST(RULE_CC) AC_SUBST(SHOW_CC) AC_SUBST(ECHO_CC) ])dnl dnl --------------------------------------------------------------------------- dnl CF_FIND_LIBRARY version: 8 updated: 2004/11/23 20:14:58 dnl --------------- dnl Look for a non-standard library, given parameters for AC_TRY_LINK. We dnl prefer a standard location, and use -L options only if we do not find the dnl library in the standard library location(s). dnl $1 = library name dnl $2 = library class, usually the same as library name dnl $3 = includes dnl $4 = code fragment to compile/link dnl $5 = corresponding function-name dnl $6 = flag, nonnull if failure should not cause an error-exit dnl dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had dnl to use a -L option. AC_DEFUN([CF_FIND_LIBRARY], [ eval 'cf_cv_have_lib_'$1'=no' cf_libdir="" AC_CHECK_FUNC($5, eval 'cf_cv_have_lib_'$1'=yes',[ cf_save_LIBS="$LIBS" AC_MSG_CHECKING(for $5 in -l$1) LIBS="-l$1 $LIBS" AC_TRY_LINK([$3],[$4], [AC_MSG_RESULT(yes) eval 'cf_cv_have_lib_'$1'=yes' ], [AC_MSG_RESULT(no) CF_LIBRARY_PATH(cf_search,$2) for cf_libdir in $cf_search do AC_MSG_CHECKING(for -l$1 in $cf_libdir) LIBS="-L$cf_libdir -l$1 $cf_save_LIBS" AC_TRY_LINK([$3],[$4], [AC_MSG_RESULT(yes) eval 'cf_cv_have_lib_'$1'=yes' break], [AC_MSG_RESULT(no) LIBS="$cf_save_LIBS"]) done ]) ]) eval 'cf_found_library=[$]cf_cv_have_lib_'$1 ifelse($6,,[ if test $cf_found_library = no ; then AC_ERROR(Cannot link $1 library) fi ]) ])dnl dnl --------------------------------------------------------------------------- dnl CF_FUNC_LSTAT version: 2 updated: 1997/09/07 13:00:21 dnl ------------- dnl A conventional existence-check for 'lstat' won't work with the Linux dnl version of gcc 2.7.0, since the symbol is defined only within dnl as an inline function. dnl dnl So much for portability. AC_DEFUN([CF_FUNC_LSTAT], [ AC_MSG_CHECKING(for lstat) AC_CACHE_VAL(ac_cv_func_lstat,[ AC_TRY_LINK([ #include #include ], [lstat(".", (struct stat *)0)], [ac_cv_func_lstat=yes], [ac_cv_func_lstat=no]) ]) AC_MSG_RESULT($ac_cv_func_lstat ) if test $ac_cv_func_lstat = yes; then AC_DEFINE(HAVE_LSTAT) fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_GCC_ATTRIBUTES version: 10 updated: 2005/05/28 13:16:28 dnl ----------------- dnl Test for availability of useful gcc __attribute__ directives to quiet dnl compiler warnings. Though useful, not all are supported -- and contrary dnl to documentation, unrecognized directives cause older compilers to barf. AC_DEFUN([CF_GCC_ATTRIBUTES], [ if test "$GCC" = yes then cat > conftest.i < conftest.$ac_ext <&AC_FD_CC case $cf_attribute in scanf|printf) cat >conftest.h <conftest.h <>confdefs.h fi done else fgrep define conftest.i >>confdefs.h fi rm -rf conftest* fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_GCC_VERSION version: 4 updated: 2005/08/27 09:53:42 dnl -------------- dnl Find version of gcc AC_DEFUN([CF_GCC_VERSION],[ AC_REQUIRE([AC_PROG_CC]) GCC_VERSION=none if test "$GCC" = yes ; then AC_MSG_CHECKING(version of $CC) GCC_VERSION="`${CC} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`" test -z "$GCC_VERSION" && GCC_VERSION=unknown AC_MSG_RESULT($GCC_VERSION) fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_GCC_WARNINGS version: 20 updated: 2005/08/06 18:37:29 dnl --------------- dnl Check if the compiler supports useful warning options. There's a few that dnl we don't use, simply because they're too noisy: dnl dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x) dnl -Wredundant-decls (system headers make this too noisy) dnl -Wtraditional (combines too many unrelated messages, only a few useful) dnl -Wwrite-strings (too noisy, but should review occasionally). This dnl is enabled for ncurses using "--enable-const". dnl -pedantic dnl dnl Parameter: dnl $1 is an optional list of gcc warning flags that a particular dnl application might want to use, e.g., "no-unused" for dnl -Wno-unused dnl Special: dnl If $with_ext_const is "yes", add a check for -Wwrite-strings dnl AC_DEFUN([CF_GCC_WARNINGS], [ AC_REQUIRE([CF_GCC_VERSION]) CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS) cat > conftest.$ac_ext <], [int x = optind; char *y = optarg], [cf_cv_getopt_header=$cf_header break]) done ]) case $cf_cv_getopt_header in #(vi getopt.h) #(vi AC_DEFINE(HAVE_GETOPT_H) AC_DEFINE(HAVE_GETOPT_HEADER) ;; stdlib.h) #(vi AC_DEFINE(HAVE_STDLIB_H) AC_DEFINE(HAVE_GETOPT_HEADER) ;; esac ])dnl dnl --------------------------------------------------------------------------- dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07 dnl ------------- dnl Check if we must define _GNU_SOURCE to get a reasonable value for dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect dnl (or misfeature) of glibc2, which breaks portability of many applications, dnl since it is interwoven with GNU extensions. dnl dnl Well, yes we could work around it... AC_DEFUN([CF_GNU_SOURCE], [ AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[ AC_TRY_COMPILE([#include ],[ #ifndef _XOPEN_SOURCE make an error #endif], [cf_cv_gnu_source=no], [cf_save="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" AC_TRY_COMPILE([#include ],[ #ifdef _XOPEN_SOURCE make an error #endif], [cf_cv_gnu_source=no], [cf_cv_gnu_source=yes]) CPPFLAGS="$cf_save" ]) ]) test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" ])dnl dnl --------------------------------------------------------------------------- dnl CF_HEADER_PATH version: 8 updated: 2002/11/10 14:46:59 dnl -------------- dnl Construct a search-list for a nonstandard header-file AC_DEFUN([CF_HEADER_PATH], [CF_SUBDIR_PATH($1,$2,include) test "$includedir" != NONE && \ test "$includedir" != "/usr/include" && \ test -d "$includedir" && { test -d $includedir && $1="[$]$1 $includedir" test -d $includedir/$2 && $1="[$]$1 $includedir/$2" } test "$oldincludedir" != NONE && \ test "$oldincludedir" != "/usr/include" && \ test -d "$oldincludedir" && { test -d $oldincludedir && $1="[$]$1 $oldincludedir" test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2" } ])dnl dnl --------------------------------------------------------------------------- dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23 dnl --------------- dnl Insert text into the help-message, for readability, from AC_ARG_WITH. AC_DEFUN([CF_HELP_MESSAGE], [AC_DIVERT_HELP([$1])dnl ])dnl dnl --------------------------------------------------------------------------- dnl CF_INCLUDE_DIRS version: 4 updated: 2002/12/01 00:12:15 dnl --------------- dnl Construct the list of include-options according to whether we're building dnl in the source directory or using '--srcdir=DIR' option. If we're building dnl with gcc, don't append the includedir if it happens to be /usr/include, dnl since that usually breaks gcc's shadow-includes. AC_DEFUN([CF_INCLUDE_DIRS], [ CPPFLAGS="-I. -I../include $CPPFLAGS" if test "$srcdir" != "."; then CPPFLAGS="-I\$(srcdir)/../include $CPPFLAGS" fi if test "$GCC" != yes; then CPPFLAGS="$CPPFLAGS -I\$(includedir)" elif test "$includedir" != "/usr/include"; then if test "$includedir" = '${prefix}/include' ; then if test $prefix != /usr ; then CPPFLAGS="$CPPFLAGS -I\$(includedir)" fi else CPPFLAGS="$CPPFLAGS -I\$(includedir)" fi fi AC_SUBST(CPPFLAGS) ])dnl dnl --------------------------------------------------------------------------- dnl CF_INCLUDE_PATH version: 4 updated: 2001/04/15 21:21:45 dnl --------------- dnl Adds to the include-path dnl dnl Autoconf 1.11 should have provided a way to add include path options to dnl the cpp-tests. dnl AC_DEFUN([CF_INCLUDE_PATH], [ for cf_path in $1 do cf_result="no" AC_MSG_CHECKING(for directory $cf_path) if test -d $cf_path then INCLUDES="$INCLUDES -I$cf_path" ac_cpp="${ac_cpp} -I$cf_path" CFLAGS="$CFLAGS -I$cf_path" cf_result="yes" case $cf_path in /usr/include|/usr/include/*) ;; *) CF_DIRNAME(cf_temp,$cf_path) case $cf_temp in */include) INCLUDES="$INCLUDES -I$cf_temp" ac_cpp="${ac_cpp} -I$cf_temp" CFLAGS="$CFLAGS -I$cf_temp" ;; esac esac fi AC_MSG_RESULT($cf_result) done ])dnl dnl --------------------------------------------------------------------------- dnl CF_INTEL_COMPILER version: 3 updated: 2005/08/06 18:37:29 dnl ----------------- dnl Check if the given compiler is really the Intel compiler for Linux. It dnl tries to imitate gcc, but does not return an error when it finds a mismatch dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK. dnl dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from dnl the wrappers for gcc and g++ warnings. dnl dnl $1 = GCC (default) or GXX dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS dnl $3 = CFLAGS (default) or CXXFLAGS AC_DEFUN([CF_INTEL_COMPILER],[ ifelse($2,,INTEL_COMPILER,[$2])=no if test "$ifelse($1,,[$1],GCC)" = yes ; then case $host_os in linux*|gnu*) AC_MSG_CHECKING(if this is really Intel ifelse($1,GXX,C++,C) compiler) cf_save_CFLAGS="$ifelse($3,,CFLAGS,[$3])" ifelse($3,,CFLAGS,[$3])="$ifelse($3,,CFLAGS,[$3]) -no-gcc" AC_TRY_COMPILE([],[ #ifdef __INTEL_COMPILER #else make an error #endif ],[ifelse($2,,INTEL_COMPILER,[$2])=yes cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc" ],[]) ifelse($3,,CFLAGS,[$3])="$cf_save_CFLAGS" AC_MSG_RESULT($ifelse($2,,INTEL_COMPILER,[$2])) ;; esac fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_LIBRARY_PATH version: 7 updated: 2002/11/10 14:46:59 dnl --------------- dnl Construct a search-list for a nonstandard library-file AC_DEFUN([CF_LIBRARY_PATH], [CF_SUBDIR_PATH($1,$2,lib)])dnl dnl --------------------------------------------------------------------------- dnl CF_LIB_PREFIX version: 7 updated: 2001/01/12 01:23:48 dnl ------------- dnl Compute the library-prefix for the given host system dnl $1 = variable to set AC_DEFUN([CF_LIB_PREFIX], [ case $cf_cv_system_name in OS/2*) LIB_PREFIX='' ;; os2*) LIB_PREFIX='' ;; *) LIB_PREFIX='lib' ;; esac ifelse($1,,,[$1=$LIB_PREFIX]) AC_SUBST(LIB_PREFIX) ])dnl dnl --------------------------------------------------------------------------- dnl CF_LOCALE version: 4 updated: 2003/02/16 08:16:04 dnl --------- dnl Check if we have setlocale() and its header, dnl The optional parameter $1 tells what to do if we do have locale support. AC_DEFUN([CF_LOCALE], [ AC_MSG_CHECKING(for setlocale()) AC_CACHE_VAL(cf_cv_locale,[ AC_TRY_LINK([#include ], [setlocale(LC_ALL, "")], [cf_cv_locale=yes], [cf_cv_locale=no]) ]) AC_MSG_RESULT($cf_cv_locale) test $cf_cv_locale = yes && { ifelse($1,,AC_DEFINE(LOCALE),[$1]) } ])dnl dnl --------------------------------------------------------------------------- dnl CF_MAKEFLAGS version: 9 updated: 2001/12/30 18:17:27 dnl ------------ dnl Some 'make' programs support $(MAKEFLAGS), some $(MFLAGS), to pass 'make' dnl options to lower-levels. It's very useful for "make -n" -- if we have it. dnl (GNU 'make' does both, something POSIX 'make', which happens to make the dnl $(MAKEFLAGS) variable incompatible because it adds the assignments :-) AC_DEFUN([CF_MAKEFLAGS], [ AC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[ cf_cv_makeflags='' for cf_option in '-$(MAKEFLAGS)' '$(MFLAGS)' do cat >cf_makeflags.tmp </dev/null` case "$cf_result" in .*k) cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null` case "$cf_result" in .*CC=*) cf_cv_makeflags= ;; *) cf_cv_makeflags=$cf_option ;; esac break ;; *) echo no match "$cf_result" ;; esac done rm -f cf_makeflags.tmp ]) AC_SUBST(cf_cv_makeflags) ])dnl dnl --------------------------------------------------------------------------- dnl CF_MAKE_TAGS version: 2 updated: 2000/10/04 09:18:40 dnl ------------ dnl Generate tags/TAGS targets for makefiles. Do not generate TAGS if we have dnl a monocase filesystem. AC_DEFUN([CF_MAKE_TAGS],[ AC_REQUIRE([CF_MIXEDCASE_FILENAMES]) AC_CHECK_PROG(MAKE_LOWER_TAGS, ctags, yes, no) if test "$cf_cv_mixedcase" = yes ; then AC_CHECK_PROG(MAKE_UPPER_TAGS, etags, yes, no) else MAKE_UPPER_TAGS=no fi if test "$MAKE_UPPER_TAGS" = yes ; then MAKE_UPPER_TAGS= else MAKE_UPPER_TAGS="#" fi AC_SUBST(MAKE_UPPER_TAGS) if test "$MAKE_LOWER_TAGS" = yes ; then MAKE_LOWER_TAGS= else MAKE_LOWER_TAGS="#" fi AC_SUBST(MAKE_LOWER_TAGS) ])dnl dnl --------------------------------------------------------------------------- dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55 dnl ---------------------- dnl Check if the file-system supports mixed-case filenames. If we're able to dnl create a lowercase name and see it as uppercase, it doesn't support that. AC_DEFUN([CF_MIXEDCASE_FILENAMES], [ AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[ if test "$cross_compiling" = yes ; then case $target_alias in #(vi *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi cf_cv_mixedcase=no ;; *) cf_cv_mixedcase=yes ;; esac else rm -f conftest CONFTEST echo test >conftest if test -f CONFTEST ; then cf_cv_mixedcase=no else cf_cv_mixedcase=yes fi rm -f conftest CONFTEST fi ]) test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES) ])dnl dnl --------------------------------------------------------------------------- dnl CF_MSG_LOG version: 3 updated: 1997/09/07 14:05:52 dnl ---------- dnl Write a debug message to config.log, along with the line number in the dnl configure script. AC_DEFUN([CF_MSG_LOG],[ echo "(line __oline__) testing $* ..." 1>&AC_FD_CC ])dnl dnl --------------------------------------------------------------------------- dnl CF_NCURSES_CC_CHECK version: 3 updated: 2003/01/12 18:59:28 dnl ------------------- dnl Check if we can compile with ncurses' header file dnl $1 is the cache variable to set dnl $2 is the header-file to include dnl $3 is the root name (ncurses or ncursesw) AC_DEFUN([CF_NCURSES_CC_CHECK],[ AC_TRY_COMPILE([ ]ifelse($3,ncursesw,[ #define _XOPEN_SOURCE_EXTENDED #undef HAVE_LIBUTF8_H /* in case we used CF_UTF8_LIB */ #define HAVE_LIBUTF8_H /* to force ncurses' header file to use cchar_t */ ])[ #include <$2>],[ #ifdef NCURSES_VERSION ]ifelse($3,ncursesw,[ #ifndef WACS_BSSB make an error #endif ])[ printf("%s\n", NCURSES_VERSION); #else #ifdef __NCURSES_H printf("old\n"); #else make an error #endif #endif ] ,[$1=$cf_header] ,[$1=no]) ])dnl dnl --------------------------------------------------------------------------- dnl CF_NCURSES_CPPFLAGS version: 17 updated: 2003/11/06 19:59:57 dnl ------------------- dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting dnl the CPPFLAGS variable so we can include its header. dnl dnl The header files may be installed as either curses.h, or ncurses.h (would dnl be obsolete, except that some packagers prefer this name to distinguish it dnl from a "native" curses implementation). If not installed for overwrite, dnl the curses.h file would be in an ncurses subdirectory (e.g., dnl /usr/include/ncurses), but someone may have installed overwriting the dnl vendor's curses. Only very old versions (pre-1.9.2d, the first autoconf'd dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in dnl the header. dnl dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header dnl is already in the include-path, don't even bother with this, since we cannot dnl easily determine which file it is. In this case, it has to be . dnl dnl The optional parameter gives the root name of the library, in case it is dnl not installed as the default curses library. That is how the dnl wide-character version of ncurses is installed. AC_DEFUN([CF_NCURSES_CPPFLAGS], [AC_REQUIRE([CF_WITH_CURSES_DIR]) AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl cf_ncuhdr_root=ifelse($1,,ncurses,$1) test -n "$cf_cv_curses_dir" && \ test "$cf_cv_curses_dir" != "no" && \ CPPFLAGS="-I$cf_cv_curses_dir/include -I$cf_cv_curses_dir/include/$cf_ncuhdr_root $CPPFLAGS" AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[ cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h" ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h" for cf_header in $cf_header_list do CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1) test "$cf_cv_ncurses_h" != no && break done ]) if test "$cf_cv_ncurses_h" != no ; then cf_cv_ncurses_header=$cf_cv_ncurses_h else AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[ test -n "$verbose" && echo CF_HEADER_PATH(cf_search,$cf_ncuhdr_root) test -n "$verbose" && echo search path $cf_search cf_save2_CPPFLAGS="$CPPFLAGS" for cf_incdir in $cf_search do CF_ADD_INCDIR($cf_incdir) for cf_header in \ ncurses.h \ curses.h do CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1) if test "$cf_cv_ncurses_h2" != no ; then cf_cv_ncurses_h2=$cf_incdir/$cf_header test -n "$verbose" && echo $ac_n " ... found $ac_c" 1>&AC_FD_MSG break fi test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG done CPPFLAGS="$cf_save2_CPPFLAGS" test "$cf_cv_ncurses_h2" != no && break done test "$cf_cv_ncurses_h2" = no && AC_ERROR(not found) ]) CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2) cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2` if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header fi CF_ADD_INCDIR($cf_1st_incdir) fi AC_DEFINE(NCURSES) case $cf_cv_ncurses_header in # (vi *ncurses.h) AC_DEFINE(HAVE_NCURSES_H) ;; esac case $cf_cv_ncurses_header in # (vi ncurses/curses.h|ncurses/ncurses.h) AC_DEFINE(HAVE_NCURSES_NCURSES_H) ;; ncursesw/curses.h|ncursesw/ncurses.h) AC_DEFINE(HAVE_NCURSESW_NCURSES_H) ;; esac CF_NCURSES_VERSION ])dnl dnl --------------------------------------------------------------------------- dnl CF_NCURSES_LIBS version: 12 updated: 2004/04/27 16:26:05 dnl --------------- dnl Look for the ncurses library. This is a little complicated on Linux, dnl because it may be linked with the gpm (general purpose mouse) library. dnl Some distributions have gpm linked with (bsd) curses, which makes it dnl unusable with ncurses. However, we don't want to link with gpm unless dnl ncurses has a dependency, since gpm is normally set up as a shared library, dnl and the linker will record a dependency. dnl dnl The optional parameter gives the root name of the library, in case it is dnl not installed as the default curses library. That is how the dnl wide-character version of ncurses is installed. AC_DEFUN([CF_NCURSES_LIBS], [AC_REQUIRE([CF_NCURSES_CPPFLAGS]) cf_nculib_root=ifelse($1,,ncurses,$1) # This works, except for the special case where we find gpm, but # ncurses is in a nonstandard location via $LIBS, and we really want # to link gpm. cf_ncurses_LIBS="" cf_ncurses_SAVE="$LIBS" AC_CHECK_LIB(gpm,Gpm_Open, [AC_CHECK_LIB(gpm,initscr, [LIBS="$cf_ncurses_SAVE"], [cf_ncurses_LIBS="-lgpm"])]) case $host_os in #(vi freebsd*) # This is only necessary if you are linking against an obsolete # version of ncurses (but it should do no harm, since it's static). if test "$cf_nculib_root" = ncurses ; then AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"]) fi ;; esac LIBS="$cf_ncurses_LIBS $LIBS" if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" ) then LIBS="-L$cf_cv_curses_dir/lib -l$cf_nculib_root $LIBS" else CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root, [#include <${cf_cv_ncurses_header-curses.h}>], [initscr()], initscr) fi if test -n "$cf_ncurses_LIBS" ; then AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS) cf_ncurses_SAVE="$LIBS" for p in $cf_ncurses_LIBS ; do q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"` if test "$q" != "$LIBS" ; then LIBS="$q" fi done AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>], [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) LIBS="$cf_ncurses_SAVE"]) fi CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root) AC_DEFINE_UNQUOTED($cf_nculib_ROOT) ])dnl dnl --------------------------------------------------------------------------- dnl CF_NCURSES_VERSION version: 11 updated: 2003/11/06 19:59:57 dnl ------------------ dnl Check for the version of ncurses, to aid in reporting bugs, etc. dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS. We don't use dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi. AC_DEFUN([CF_NCURSES_VERSION], [ AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[ cf_cv_ncurses_version=no cf_tempfile=out$$ rm -f $cf_tempfile AC_TRY_RUN([ #include <${cf_cv_ncurses_header-curses.h}> #include int main() { FILE *fp = fopen("$cf_tempfile", "w"); #ifdef NCURSES_VERSION # ifdef NCURSES_VERSION_PATCH fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH); # else fprintf(fp, "%s\n", NCURSES_VERSION); # endif #else # ifdef __NCURSES_H fprintf(fp, "old\n"); # else make an error # endif #endif exit(0); }],[ cf_cv_ncurses_version=`cat $cf_tempfile`],,[ # This will not work if the preprocessor splits the line after the # Autoconf token. The 'unproto' program does that. cat > conftest.$ac_ext < #undef Autoconf #ifdef NCURSES_VERSION Autoconf NCURSES_VERSION #else #ifdef __NCURSES_H Autoconf "old" #endif ; #endif EOF cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out" AC_TRY_EVAL(cf_try) if test -f conftest.out ; then cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'` test -n "$cf_out" && cf_cv_ncurses_version="$cf_out" rm -f conftest.out fi ]) rm -f $cf_tempfile ]) test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES) ])dnl dnl --------------------------------------------------------------------------- dnl CF_PATH_SYNTAX version: 9 updated: 2002/09/17 23:03:38 dnl -------------- dnl Check the argument to see that it looks like a pathname. Rewrite it if it dnl begins with one of the prefix/exec_prefix variables, and then again if the dnl result begins with 'NONE'. This is necessary to work around autoconf's dnl delayed evaluation of those symbols. AC_DEFUN([CF_PATH_SYNTAX],[ case ".[$]$1" in #(vi .\[$]\(*\)*|.\'*\'*) #(vi ;; ..|./*|.\\*) #(vi ;; .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX ;; .\[$]{*prefix}*) #(vi eval $1="[$]$1" case ".[$]$1" in #(vi .NONE/*) $1=`echo [$]$1 | sed -e s%NONE%$ac_default_prefix%` ;; esac ;; #(vi .NONE/*) $1=`echo [$]$1 | sed -e s%NONE%$ac_default_prefix%` ;; *) ifelse($2,,[AC_ERROR([expected a pathname, not \"[$]$1\"])],$2) ;; esac ])dnl dnl --------------------------------------------------------------------------- dnl CF_PDCURSES_X11 version: 6 updated: 2002/10/27 18:21:42 dnl --------------- dnl Configure for PDCurses' X11 library AC_DEFUN([CF_PDCURSES_X11],[ AC_REQUIRE([CF_X_ATHENA]) LDFLAGS="$LDFLAGS $X_LIBS" CF_CHECK_CFLAGS($X_CFLAGS) AC_CHECK_LIB(X11,XOpenDisplay, [LIBS="-lX11 $LIBS"],, [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS]) AC_CACHE_CHECK(for XCurses library,cf_cv_lib_XCurses,[ LIBS="-lXCurses $LIBS" AC_TRY_LINK([ #include char *XCursesProgramName = "test"; ],[XCursesExit();], [cf_cv_lib_XCurses=yes], [cf_cv_lib_XCurses=no]) ]) if test $cf_cv_lib_XCurses = yes ; then AC_DEFINE(UNIX) AC_DEFINE(XCURSES) AC_DEFINE(HAVE_XCURSES) else AC_ERROR(Cannot link with XCurses) fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_POSIX_C_SOURCE version: 6 updated: 2005/07/14 20:25:10 dnl ----------------- dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed. dnl dnl POSIX.1-1990 _POSIX_SOURCE dnl POSIX.1-1990 and _POSIX_SOURCE and dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2 dnl Bindings Option dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L dnl X/Open 2000 _POSIX_C_SOURCE=200112L dnl dnl Parameters: dnl $1 is the nominal value for _POSIX_C_SOURCE AC_DEFUN([CF_POSIX_C_SOURCE], [ cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1) cf_save_CFLAGS="$CFLAGS" cf_save_CPPFLAGS="$CPPFLAGS" CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE) CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE) AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[ CF_MSG_LOG(if the symbol is already defined go no further) AC_TRY_COMPILE([#include ],[ #ifndef _POSIX_C_SOURCE make an error #endif], [cf_cv_posix_c_source=no], [cf_want_posix_source=no case .$cf_POSIX_C_SOURCE in #(vi .[[12]]??*) #(vi cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE" ;; .2) #(vi cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE" cf_want_posix_source=yes ;; .*) cf_want_posix_source=yes ;; esac if test "$cf_want_posix_source" = yes ; then AC_TRY_COMPILE([#include ],[ #ifdef _POSIX_SOURCE make an error #endif],[], cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE") fi CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE) CFLAGS="$cf_trim_CFLAGS" CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source" CF_MSG_LOG(if the second compile does not leave our definition intact error) AC_TRY_COMPILE([#include ],[ #ifndef _POSIX_C_SOURCE make an error #endif],, [cf_cv_posix_c_source=no]) CFLAGS="$cf_save_CFLAGS" CPPFLAGS="$cf_save_CPPFLAGS" ]) ]) if test "$cf_cv_posix_c_source" != no ; then CFLAGS="$cf_trim_CFLAGS" CPPFLAGS="$cf_trim_CPPFLAGS" if test "$cf_cv_cc_u_d_options" = yes ; then cf_temp_posix_c_source=`echo "$cf_cv_posix_c_source" | \ sed -e 's/-D/-U/g' -e 's/=[[^ ]]*//g'` CPPFLAGS="$CPPFLAGS $cf_temp_posix_c_source" fi CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source" fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30 dnl -------------- dnl Check if C (preprocessor) -U and -D options are processed in the order dnl given rather than by type of option. Some compilers insist on apply all dnl of the -U options after all of the -D options. Others allow mixing them, dnl and may predefine symbols that conflict with those we define. AC_DEFUN([CF_PROG_CC_U_D], [ AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[ cf_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS" AC_TRY_COMPILE([],[ #ifndef U_D_OPTIONS make an undefined-error #endif #ifdef D_U_OPTIONS make a defined-error #endif ],[ cf_cv_cc_u_d_options=yes],[ cf_cv_cc_u_d_options=no]) CPPFLAGS="$cf_save_CPPFLAGS" ]) ])dnl dnl --------------------------------------------------------------------------- dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18 dnl ----------- dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX. AC_DEFUN([CF_PROG_EXT], [ AC_REQUIRE([CF_CHECK_CACHE]) case $cf_cv_system_name in os2*) CFLAGS="$CFLAGS -Zmt" CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__" CXXFLAGS="$CXXFLAGS -Zmt" # autoconf's macro sets -Zexe and suffix both, which conflict:w LDFLAGS="$LDFLAGS -Zmt -Zcrtdll" ac_cv_exeext=.exe ;; esac AC_EXEEXT AC_OBJEXT PROG_EXT="$EXEEXT" AC_SUBST(PROG_EXT) test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT") ])dnl dnl --------------------------------------------------------------------------- dnl CF_REMOVE_DEFINE version: 2 updated: 2005/07/09 16:12:18 dnl ---------------- dnl Remove all -U and -D options that refer to the given symbol from a list dnl of C compiler options. This works around the problem that not all dnl compilers process -U and -D options from left-to-right, so a -U option dnl cannot be used to cancel the effect of a preceding -D option. dnl dnl $1 = target (which could be the same as the source variable) dnl $2 = source (including '$') dnl $3 = symbol to remove define([CF_REMOVE_DEFINE], [ # remove $3 symbol from $2 $1=`echo "$2" | \ sed -e 's/-[[UD]]$3\(=[[^ ]]*\)\?[[ ]]/ /g' \ -e 's/-[[UD]]$3\(=[[^ ]]*\)\?[$]//g'` ])dnl dnl --------------------------------------------------------------------------- dnl CF_SUBDIR_PATH version: 3 updated: 2002/12/29 18:30:46 dnl -------------- dnl Construct a search-list for a nonstandard header/lib-file dnl $1 = the variable to return as result dnl $2 = the package name dnl $3 = the subdirectory, e.g., bin, include or lib AC_DEFUN([CF_SUBDIR_PATH], [$1="" test -d [$]HOME && { test -n "$verbose" && echo " ... testing $3-directories under [$]HOME" test -d [$]HOME/$3 && $1="[$]$1 [$]HOME/$3" test -d [$]HOME/$3/$2 && $1="[$]$1 [$]HOME/$3/$2" test -d [$]HOME/$3/$2/$3 && $1="[$]$1 [$]HOME/$3/$2/$3" } # For other stuff under the home directory, it should be sufficient to put # a symbolic link for $HOME/$2 to the actual package location: test -d [$]HOME/$2 && { test -n "$verbose" && echo " ... testing $3-directories under [$]HOME/$2" test -d [$]HOME/$2/$3 && $1="[$]$1 [$]HOME/$2/$3" test -d [$]HOME/$2/$3/$2 && $1="[$]$1 [$]HOME/$2/$3/$2" } test "$prefix" != /usr/local && \ test -d /usr/local && { test -n "$verbose" && echo " ... testing $3-directories under /usr/local" test -d /usr/local/$3 && $1="[$]$1 /usr/local/$3" test -d /usr/local/$3/$2 && $1="[$]$1 /usr/local/$3/$2" test -d /usr/local/$3/$2/$3 && $1="[$]$1 /usr/local/$3/$2/$3" test -d /usr/local/$2/$3 && $1="[$]$1 /usr/local/$2/$3" test -d /usr/local/$2/$3/$2 && $1="[$]$1 /usr/local/$2/$3/$2" } test "$prefix" != NONE && \ test -d $prefix && { test -n "$verbose" && echo " ... testing $3-directories under $prefix" test -d $prefix/$3 && $1="[$]$1 $prefix/$3" test -d $prefix/$3/$2 && $1="[$]$1 $prefix/$3/$2" test -d $prefix/$3/$2/$3 && $1="[$]$1 $prefix/$3/$2/$3" test -d $prefix/$2/$3 && $1="[$]$1 $prefix/$2/$3" test -d $prefix/$2/$3/$2 && $1="[$]$1 $prefix/$2/$3/$2" } test "$prefix" != /opt && \ test -d /opt && { test -n "$verbose" && echo " ... testing $3-directories under /opt" test -d /opt/$3 && $1="[$]$1 /opt/$3" test -d /opt/$3/$2 && $1="[$]$1 /opt/$3/$2" test -d /opt/$3/$2/$3 && $1="[$]$1 /opt/$3/$2/$3" test -d /opt/$2/$3 && $1="[$]$1 /opt/$2/$3" test -d /opt/$2/$3/$2 && $1="[$]$1 /opt/$2/$3/$2" } test "$prefix" != /usr && \ test -d /usr && { test -n "$verbose" && echo " ... testing $3-directories under /usr" test -d /usr/$3 && $1="[$]$1 /usr/$3" test -d /usr/$3/$2 && $1="[$]$1 /usr/$3/$2" test -d /usr/$3/$2/$3 && $1="[$]$1 /usr/$3/$2/$3" test -d /usr/$2/$3 && $1="[$]$1 /usr/$2/$3" } ])dnl dnl --------------------------------------------------------------------------- dnl CF_SUBST version: 2 updated: 1997/09/06 23:41:28 dnl -------- dnl Shorthand macro for substituting things that the user may override dnl with an environment variable. dnl dnl $1 = long/descriptive name dnl $2 = environment variable dnl $3 = default value AC_DEFUN([CF_SUBST], [AC_CACHE_VAL(cf_cv_subst_$2,[ AC_MSG_CHECKING(for $1 (symbol $2)) test -z "[$]$2" && $2=$3 AC_MSG_RESULT([$]$2) AC_SUBST($2) cf_cv_subst_$2=[$]$2]) $2=${cf_cv_subst_$2} ])dnl dnl --------------------------------------------------------------------------- dnl CF_SYSTYPE version: 3 updated: 2001/02/03 00:14:59 dnl ---------- dnl Derive the system-type (our main clue to the method of building shared dnl libraries). AC_DEFUN([CF_SYSTYPE], [ AC_MSG_CHECKING(for system type) AC_CACHE_VAL(cf_cv_systype,[ AC_ARG_WITH(system-type, [ --with-system-type=XXX test: override derived host system-type], [cf_cv_systype=$withval], [ cf_cv_systype="`(uname -s || hostname || echo unknown) 2>/dev/null |sed -e s'/[[:\/.-]]/_/'g | sed 1q`" if test -z "$cf_cv_systype"; then cf_cv_systype=unknown;fi ])]) AC_MSG_RESULT($cf_cv_systype) ])dnl dnl --------------------------------------------------------------------------- dnl CF_SYS_NAME version: 2 updated: 1997/08/28 23:57:55 dnl ----------- dnl Derive the system name, as a check for reusing the autoconf cache AC_DEFUN([CF_SYS_NAME], [ SYS_NAME=`(uname -s -r || uname -a || hostname) 2>/dev/null | sed 1q` test -z "$SYS_NAME" && SYS_NAME=unknown AC_DEFINE_UNQUOTED(SYS_NAME,"$SYS_NAME") AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$SYS_NAME"]) if test ".$SYS_NAME" != ".$cf_cv_system_name" ; then AC_MSG_RESULT("Cached system name does not agree with actual") AC_ERROR("Please remove config.cache and try again.") fi]) dnl --------------------------------------------------------------------------- dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59 dnl -------- dnl Make an uppercase version of a variable dnl $1=uppercase($2) AC_DEFUN([CF_UPPER], [ $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` ])dnl dnl --------------------------------------------------------------------------- dnl CF_UTF8_LIB version: 4 updated: 2003/03/01 18:36:42 dnl ----------- dnl Check for multibyte support, and if not found, utf8 compatibility library AC_DEFUN([CF_UTF8_LIB], [ AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[ cf_save_LIBS="$LIBS" AC_TRY_LINK([ #include ],[putwc(0,0);], [cf_cv_utf8_lib=yes], [LIBS="-lutf8 $LIBS" AC_TRY_LINK([ #include ],[putwc(0,0);], [cf_cv_utf8_lib=add-on], [cf_cv_utf8_lib=no]) LIBS="$cf_save_LIBS" ])]) # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between # ncurses/ncursesw: if test "$cf_cv_utf8_lib" = "add-on" ; then AC_DEFINE(HAVE_LIBUTF8_H) LIBS="-lutf8 $LIBS" fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_VERBOSE version: 2 updated: 1997/09/05 10:45:14 dnl ---------- dnl Use AC_VERBOSE w/o the warnings AC_DEFUN([CF_VERBOSE], [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG ])dnl dnl --------------------------------------------------------------------------- dnl CF_VERSION_INFO version: 3 updated: 2003/11/22 12:22:45 dnl --------------- dnl Define several useful symbols derived from the VERSION file. A separate dnl file is preferred to embedding the version numbers in various scripts. dnl (automake is a textbook-example of why the latter is a bad idea, but there dnl are others). dnl dnl The file contents are: dnl libtool-version release-version patch-version dnl or dnl release-version dnl where dnl libtool-version (see ?) consists of 3 integers separated by '.' dnl release-version consists of a major version and minor version dnl separated by '.', optionally followed by a patch-version dnl separated by '-'. The minor version need not be an dnl integer (but it is preferred). dnl patch-version is an integer in the form yyyymmdd, so ifdef's and dnl scripts can easily compare versions. dnl dnl If libtool is used, the first form is required, since CF_WITH_LIBTOOL dnl simply extracts the first field using 'cut -f1'. AC_DEFUN([CF_VERSION_INFO], [ if test -f $srcdir/VERSION ; then AC_MSG_CHECKING(for package version) # if there are not enough fields, cut returns the last one... cf_field1=`sed -e '2,$d' $srcdir/VERSION|cut -f1` cf_field2=`sed -e '2,$d' $srcdir/VERSION|cut -f2` cf_field3=`sed -e '2,$d' $srcdir/VERSION|cut -f3` # this is how CF_BUNDLED_INTL uses $VERSION: VERSION="$cf_field1" VERSION_MAJOR=`echo "$cf_field2" | sed -e 's/\..*//'` test -z "$VERSION_MAJOR" && AC_MSG_ERROR(missing major-version) VERSION_MINOR=`echo "$cf_field2" | sed -e 's/^[[^.]]*\.//' -e 's/-.*//'` test -z "$VERSION_MINOR" && AC_MSG_ERROR(missing minor-version) AC_MSG_RESULT(${VERSION_MAJOR}.${VERSION_MINOR}) AC_MSG_CHECKING(for package patch date) VERSION_PATCH=`echo "$cf_field3" | sed -e 's/^[[^-]]*-//'` case .$VERSION_PATCH in .) AC_MSG_ERROR(missing patch-date $VERSION_PATCH) ;; .[[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]]) ;; *) AC_MSG_ERROR(illegal patch-date $VERSION_PATCH) ;; esac AC_MSG_RESULT($VERSION_PATCH) else AC_MSG_ERROR(did not find $srcdir/VERSION) fi # show the actual data that we have for versions: CF_VERBOSE(VERSION $VERSION) CF_VERBOSE(VERSION_MAJOR $VERSION_MAJOR) CF_VERBOSE(VERSION_MINOR $VERSION_MINOR) CF_VERBOSE(VERSION_PATCH $VERSION_PATCH) AC_SUBST(VERSION) AC_SUBST(VERSION_MAJOR) AC_SUBST(VERSION_MINOR) AC_SUBST(VERSION_PATCH) dnl if a package name is given, define its corresponding version info. We dnl need the package name to ensure that the defined symbols are unique. ifelse($1,,,[ PACKAGE=$1 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE") AC_SUBST(PACKAGE) CF_UPPER(cf_PACKAGE,$PACKAGE) AC_DEFINE_UNQUOTED(${cf_PACKAGE}_VERSION,"${VERSION_MAJOR}.${VERSION_MINOR}") AC_DEFINE_UNQUOTED(${cf_PACKAGE}_PATCHDATE,${VERSION_PATCH}) ]) ])dnl dnl --------------------------------------------------------------------------- dnl CF_WITH_CURSES_DIR version: 2 updated: 2002/11/10 14:46:59 dnl ------------------ dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses dnl libraries. AC_DEFUN([CF_WITH_CURSES_DIR],[ AC_ARG_WITH(curses-dir, [ --with-curses-dir=DIR directory in which (n)curses is installed], [CF_PATH_SYNTAX(withval) cf_cv_curses_dir=$withval], [cf_cv_curses_dir=no]) ])dnl dnl --------------------------------------------------------------------------- dnl CF_WITH_DBMALLOC version: 4 updated: 2004/02/28 05:49:27 dnl ---------------- dnl Configure-option for dbmalloc. The optional parameter is used to override dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests. AC_DEFUN([CF_WITH_DBMALLOC],[ AC_MSG_CHECKING(if you want to link with dbmalloc for testing) AC_ARG_WITH(dbmalloc, [ --with-dbmalloc use Conor Cahill's dbmalloc library], [with_dbmalloc=$withval], [with_dbmalloc=no]) AC_MSG_RESULT($with_dbmalloc) if test "$with_dbmalloc" = yes ; then AC_CHECK_HEADER(dbmalloc.h, [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse($1,,[],[,$1]))]) fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_WITH_DMALLOC version: 4 updated: 2004/02/28 05:49:27 dnl --------------- dnl Configure-option for dmalloc. The optional parameter is used to override dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests. AC_DEFUN([CF_WITH_DMALLOC],[ AC_MSG_CHECKING(if you want to link with dmalloc for testing) AC_ARG_WITH(dmalloc, [ --with-dmalloc use Gray Watson's dmalloc library], [with_dmalloc=$withval], [with_dmalloc=no]) AC_MSG_RESULT($with_dmalloc) if test "$with_dmalloc" = yes ; then AC_CHECK_HEADER(dmalloc.h, [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse($1,,[],[,$1]))]) fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_WITH_LIBTOOL version: 9 updated: 2004/01/16 14:55:37 dnl --------------- dnl Provide a configure option to incorporate libtool. Define several useful dnl symbols for the makefile rules. dnl dnl The reference to AC_PROG_LIBTOOL does not normally work, since it uses dnl macros from libtool.m4 which is in the aclocal directory of automake. dnl Following is a simple script which turns on the AC_PROG_LIBTOOL macro. dnl But that still does not work properly since the macro is expanded outside dnl the CF_WITH_LIBTOOL macro: dnl dnl #!/bin/sh dnl ACLOCAL=`aclocal --print-ac-dir` dnl if test -z "$ACLOCAL" ; then dnl echo cannot find aclocal directory dnl exit 1 dnl elif test ! -f $ACLOCAL/libtool.m4 ; then dnl echo cannot find libtool.m4 file dnl exit 1 dnl fi dnl dnl LOCAL=aclocal.m4 dnl ORIG=aclocal.m4.orig dnl dnl trap "mv $ORIG $LOCAL" 0 1 2 5 15 dnl rm -f $ORIG dnl mv $LOCAL $ORIG dnl dnl # sed the LIBTOOL= assignment to omit the current directory? dnl sed -e 's/^LIBTOOL=.*/LIBTOOL=${LIBTOOL-libtool}/' $ACLOCAL/libtool.m4 >>$LOCAL dnl cat $ORIG >>$LOCAL dnl dnl autoconf-257 $* dnl AC_DEFUN([CF_WITH_LIBTOOL], [ ifdef([AC_PROG_LIBTOOL],,[ LIBTOOL= ]) # common library maintenance symbols that are convenient for libtool scripts: LIB_CREATE='$(AR) -cr' LIB_OBJECT='$(OBJECTS)' LIB_SUFFIX=.a LIB_PREP="$RANLIB" # symbols used to prop libtool up to enable it to determine what it should be # doing: LIB_CLEAN= LIB_COMPILE= LIB_LINK= LIB_INSTALL= LIB_UNINSTALL= AC_MSG_CHECKING(if you want to build libraries with libtool) AC_ARG_WITH(libtool, [ --with-libtool generate libraries with libtool], [with_libtool=$withval], [with_libtool=no]) AC_MSG_RESULT($with_libtool) if test "$with_libtool" != "no"; then ifdef([AC_PROG_LIBTOOL],[ # missing_content_AC_PROG_LIBTOOL{{ AC_PROG_LIBTOOL # missing_content_AC_PROG_LIBTOOL}} ],[ if test "$with_libtool" != "yes" ; then CF_PATH_SYNTAX(with_libtool) LIBTOOL=$with_libtool else AC_PATH_PROG(LIBTOOL,libtool) fi if test -z "$LIBTOOL" ; then AC_MSG_ERROR(Cannot find libtool) fi ])dnl LIB_CREATE='$(LIBTOOL) --mode=link $(CC) -rpath $(DESTDIR)$(libdir) -version-info `cut -f1 $(srcdir)/VERSION` -o' LIB_OBJECT='$(OBJECTS:.o=.lo)' LIB_SUFFIX=.la LIB_CLEAN='$(LIBTOOL) --mode=clean' LIB_COMPILE='$(LIBTOOL) --mode=compile' LIB_LINK='$(LIBTOOL) --mode=link' LIB_INSTALL='$(LIBTOOL) --mode=install' LIB_UNINSTALL='$(LIBTOOL) --mode=uninstall' LIB_PREP=: # Show the version of libtool AC_MSG_CHECKING(version of libtool) # Save the version in a cache variable - this is not entirely a good # thing, but the version string from libtool is very ugly, and for # bug reports it might be useful to have the original string. cf_cv_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '2,$d' -e 's/([[^)]]*)//g' -e 's/^[[^1-9]]*//' -e 's/[[^0-9.]].*//'` AC_MSG_RESULT($cf_cv_libtool_version) if test -z "$cf_cv_libtool_version" ; then AC_MSG_ERROR(This is not libtool) fi # special hack to add --tag option for C++ compiler case $cf_cv_libtool_version in 1.[[5-9]]*|[[2-9]]*) LIBTOOL_CXX="$LIBTOOL --tag=CXX" ;; *) LIBTOOL_CXX="$LIBTOOL" ;; esac else LIBTOOL="" LIBTOOL_CXX="" fi test -z "$LIBTOOL" && ECHO_LT= AC_SUBST(LIBTOOL) AC_SUBST(LIBTOOL_CXX) AC_SUBST(LIB_CREATE) AC_SUBST(LIB_OBJECT) AC_SUBST(LIB_SUFFIX) AC_SUBST(LIB_PREP) AC_SUBST(LIB_CLEAN) AC_SUBST(LIB_COMPILE) AC_SUBST(LIB_LINK) AC_SUBST(LIB_INSTALL) AC_SUBST(LIB_UNINSTALL) ])dnl dnl --------------------------------------------------------------------------- dnl CF_WITH_NC_ALLOC_H version: 2 updated: 2005/12/26 17:09:34 dnl ------------------ dnl Applications that use ncurses can provide better leak-checking if they dnl call ncurses' functions to free its memory on exit. That is normally not dnl configured (--disable-leaks), but is useful in a debugging library. dnl dnl Use this after checking for ncurses/ncursesw libraries. AC_DEFUN([CF_WITH_NC_ALLOC_H], [ case $LIBS in #(vi *ncurses*) AC_MSG_CHECKING(if you want to check for memory leaks) cf_disable_leaks=no AC_ARG_ENABLE(leaks, [ --disable-leaks test: suppress permanent memory-leaks], [test "$enableval" = no && cf_disable_leaks=yes]) AC_MSG_RESULT($cf_disable_leaks) if test "$cf_disable_leaks" = yes ; then AC_DEFINE(NO_LEAKS) AC_CHECK_HEADERS(nc_alloc.h) AC_CHECK_FUNCS(_nc_free_and_exit) fi ;; esac ])dnl dnl --------------------------------------------------------------------------- dnl CF_WITH_WARNINGS version: 5 updated: 2004/07/23 14:40:34 dnl ---------------- dnl Combine the checks for gcc features into a configure-script option dnl dnl Parameters: dnl $1 - see CF_GCC_WARNINGS AC_DEFUN([CF_WITH_WARNINGS], [ if ( test "$GCC" = yes || test "$GXX" = yes ) then AC_MSG_CHECKING(if you want to check for gcc warnings) AC_ARG_WITH(warnings, [ --with-warnings test: turn on gcc warnings], [cf_opt_with_warnings=$withval], [cf_opt_with_warnings=no]) AC_MSG_RESULT($cf_opt_with_warnings) if test "$cf_opt_with_warnings" != no ; then CF_GCC_ATTRIBUTES CF_GCC_WARNINGS([$1]) fi fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_XOPEN_CURSES version: 8 updated: 2003/11/07 19:47:46 dnl --------------- dnl Test if we should define X/Open source for curses, needed on Digital Unix dnl 4.x, to see the extended functions, but breaks on IRIX 6.x. dnl dnl The getbegyx() check is needed for HPUX, which omits legacy macros such dnl as getbegy(). The latter is better design, but the former is standard. AC_DEFUN([CF_XOPEN_CURSES], [ AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl AC_CACHE_CHECK(if we must define _XOPEN_SOURCE_EXTENDED,cf_cv_need_xopen_extension,[ AC_TRY_LINK([ #include #include <${cf_cv_ncurses_header-curses.h}>],[ long x = winnstr(stdscr, "", 0); int x1, y1; getbegyx(stdscr, y1, x1)], [cf_cv_need_xopen_extension=no], [AC_TRY_LINK([ #define _XOPEN_SOURCE_EXTENDED #include #include <${cf_cv_ncurses_header-curses.h}>],[ long x = winnstr(stdscr, "", 0); int x1, y1; getbegyx(stdscr, y1, x1)], [cf_cv_need_xopen_extension=yes], [cf_cv_need_xopen_extension=unknown])])]) test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED" ])dnl dnl --------------------------------------------------------------------------- dnl CF_XOPEN_SOURCE version: 23 updated: 2005/10/15 16:39:05 dnl --------------- dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions, dnl or adapt to the vendor's definitions to get equivalent functionality. dnl dnl Parameters: dnl $1 is the nominal value for _XOPEN_SOURCE dnl $2 is the nominal value for _POSIX_C_SOURCE AC_DEFUN([CF_XOPEN_SOURCE],[ AC_REQUIRE([CF_PROG_CC_U_D]) cf_XOPEN_SOURCE=ifelse($1,,500,$1) cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2) case $host_os in #(vi aix[[45]]*) #(vi CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE" ;; freebsd*) #(vi # 5.x headers associate # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L cf_POSIX_C_SOURCE=200112L cf_XOPEN_SOURCE=600 CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" ;; hpux*) #(vi CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE" ;; irix[[56]].*) #(vi CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE" ;; linux*|gnu*) #(vi CF_GNU_SOURCE ;; mirbsd*) #(vi # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks ;; netbsd*) #(vi # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw ;; openbsd*) #(vi # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw ;; osf[[45]]*) #(vi CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE" ;; nto-qnx*) #(vi CPPFLAGS="$CPPFLAGS -D_QNX_SOURCE" ;; sco*) #(vi # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer ;; solaris*) #(vi CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__" ;; *) AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[ AC_TRY_COMPILE([#include ],[ #ifndef _XOPEN_SOURCE make an error #endif], [cf_cv_xopen_source=no], [cf_save="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" AC_TRY_COMPILE([#include ],[ #ifdef _XOPEN_SOURCE make an error #endif], [cf_cv_xopen_source=no], [cf_cv_xopen_source=$cf_XOPEN_SOURCE]) CPPFLAGS="$cf_save" ]) ]) if test "$cf_cv_xopen_source" != no ; then CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE) CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE) test "$cf_cv_cc_u_d_options" = yes && \ CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE" CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_cv_xopen_source" fi CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE) ;; esac ]) dnl --------------------------------------------------------------------------- dnl CF_X_ATHENA version: 12 updated: 2004/06/15 21:14:41 dnl ----------- dnl Check for Xaw (Athena) libraries dnl dnl Sets $cf_x_athena according to the flavor of Xaw which is used. AC_DEFUN([CF_X_ATHENA], [AC_REQUIRE([CF_X_TOOLKIT]) cf_x_athena=${cf_x_athena-Xaw} AC_MSG_CHECKING(if you want to link with Xaw 3d library) withval= AC_ARG_WITH(Xaw3d, [ --with-Xaw3d link with Xaw 3d library]) if test "$withval" = yes ; then cf_x_athena=Xaw3d AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi AC_MSG_CHECKING(if you want to link with neXT Athena library) withval= AC_ARG_WITH(neXtaw, [ --with-neXtaw link with neXT Athena library]) if test "$withval" = yes ; then cf_x_athena=neXtaw AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi AC_MSG_CHECKING(if you want to link with Athena-Plus library) withval= AC_ARG_WITH(XawPlus, [ --with-XawPlus link with Athena-Plus library]) if test "$withval" = yes ; then cf_x_athena=XawPlus AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi AC_CHECK_LIB(Xext,XextCreateExtension, [LIBS="-lXext $LIBS"]) cf_x_athena_lib="" CF_X_ATHENA_CPPFLAGS($cf_x_athena) CF_X_ATHENA_LIBS($cf_x_athena) ])dnl dnl --------------------------------------------------------------------------- dnl CF_X_ATHENA_CPPFLAGS version: 2 updated: 2002/10/09 20:00:37 dnl -------------------- dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw. AC_DEFUN([CF_X_ATHENA_CPPFLAGS], [ cf_x_athena_root=ifelse($1,,Xaw,$1) cf_x_athena_include="" for cf_path in default \ /usr/contrib/X11R6 \ /usr/contrib/X11R5 \ /usr/lib/X11R5 \ /usr/local do if test -z "$cf_x_athena_include" ; then cf_save="$CPPFLAGS" cf_test=X11/$cf_x_athena_root/SimpleMenu.h if test $cf_path != default ; then CPPFLAGS="-I$cf_path/include $cf_save" AC_MSG_CHECKING(for $cf_test in $cf_path) else AC_MSG_CHECKING(for $cf_test) fi AC_TRY_COMPILE([ #include #include <$cf_test>],[], [cf_result=yes], [cf_result=no]) AC_MSG_RESULT($cf_result) if test "$cf_result" = yes ; then cf_x_athena_include=$cf_path break else CPPFLAGS="$cf_save" fi fi done if test -z "$cf_x_athena_include" ; then AC_MSG_WARN( [Unable to successfully find Athena header files with test program]) elif test "$cf_x_athena_include" != default ; then CPPFLAGS="$CPPFLAGS -I$cf_x_athena_include" fi ]) dnl --------------------------------------------------------------------------- dnl CF_X_ATHENA_LIBS version: 3 updated: 2003/02/16 15:24:54 dnl ---------------- dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw. AC_DEFUN([CF_X_ATHENA_LIBS], [AC_REQUIRE([CF_X_TOOLKIT]) cf_x_athena_root=ifelse($1,,Xaw,$1) cf_x_athena_lib="" for cf_path in default \ /usr/contrib/X11R6 \ /usr/contrib/X11R5 \ /usr/lib/X11R5 \ /usr/local do for cf_lib in \ "-l$cf_x_athena_root -lXmu" \ "-l$cf_x_athena_root -lXpm -lXmu" \ "-l${cf_x_athena_root}_s -lXmu_s" do if test -z "$cf_x_athena_lib" ; then cf_save="$LIBS" cf_test=XawSimpleMenuAddGlobalActions if test $cf_path != default ; then LIBS="-L$cf_path/lib $cf_lib $LIBS" AC_MSG_CHECKING(for $cf_lib in $cf_path) else LIBS="$cf_lib $LIBS" AC_MSG_CHECKING(for $cf_test in $cf_lib) fi cf_SAVE="$LIBS" LIBS="$X_PRE_LIBS $LIBS $X_EXTRA_LIBS" AC_TRY_LINK([],[$cf_test()], [cf_result=yes], [cf_result=no]) AC_MSG_RESULT($cf_result) if test "$cf_result" = yes ; then cf_x_athena_lib="$cf_lib" LIBS="$cf_SAVE" break else LIBS="$cf_save" fi fi done done if test -z "$cf_x_athena_lib" ; then AC_ERROR( [Unable to successfully link Athena library (-l$cf_x_athena_root) with test program]) fi CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena) AC_DEFINE_UNQUOTED($cf_x_athena_LIBS) ]) dnl --------------------------------------------------------------------------- dnl CF_X_TOOLKIT version: 10 updated: 2004/04/25 15:37:17 dnl ------------ dnl Check for X Toolkit libraries dnl AC_DEFUN([CF_X_TOOLKIT], [ AC_REQUIRE([AC_PATH_XTRA]) AC_REQUIRE([CF_CHECK_CACHE]) # SYSTEM_NAME=`echo "$cf_cv_system_name"|tr ' ' -` cf_have_X_LIBS=no LDFLAGS="$X_LIBS $LDFLAGS" CF_CHECK_CFLAGS($X_CFLAGS) AC_CHECK_FUNC(XOpenDisplay,,[ AC_CHECK_LIB(X11,XOpenDisplay, [LIBS="-lX11 $LIBS"],, [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])]) AC_CHECK_FUNC(XtAppInitialize,,[ AC_CHECK_LIB(Xt, XtAppInitialize, [AC_DEFINE(HAVE_LIBXT) cf_have_X_LIBS=Xt LIBS="-lXt $X_PRE_LIBS $LIBS"],, [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])]) if test $cf_have_X_LIBS = no ; then AC_WARN( [Unable to successfully link X Toolkit library (-lXt) with test program. You will have to check and add the proper libraries by hand to makefile.]) fi ])dnl cdk-5.0-20060507/alphalist.c0000644000175100001440000005557410426355262013711 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/04 10:42:58 $ * $Revision: 1.102 $ */ /* * Declare file local prototypes. */ static BINDFN_PROTO (adjustAlphalistCB); static BINDFN_PROTO (completeWordCB); static int preProcessEntryField (EObjectType cdktype, void *object, void *clientData, chtype input); static int createList (CDKALPHALIST *alphalist, char **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, char *title, char *label, char **list, int listSize, chtype fillerChar, chtype highlight, boolean Box, boolean shadow) { CDKALPHALIST *alphalist = 0; chtype *chtypeLabel = 0; int parentWidth = getmaxx (cdkscreen->window); int parentHeight = getmaxy (cdkscreen->window); int boxWidth = width; int boxHeight = height; int xpos = xplace; int ypos = yplace; int tempWidth = 0; int tempHeight = 0; int labelLen = 0; int x, junk2; static const struct { int from; int to; } bindings[] = { { CDK_BACKCHAR, KEY_PPAGE }, { CDK_FORCHAR, KEY_NPAGE }, }; 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) { 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); /* 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, 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, 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; 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); 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 = unknownString; /* 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, char **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, char **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, 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) { CDKALPHALIST *alphalist = (CDKALPHALIST *)clientData; CDKSCROLL *scrollp = alphalist->scrollField; CDKENTRY *entry = alphalist->entryField; char *current = 0; if (scrollp->listSize > 0) { /* 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) { 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 = malloc (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 (alphalist->list, alphalist->listSize, pattern)) >= 0) { 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, ((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) { CDKALPHALIST *alphalist = (CDKALPHALIST *)clientData; CDKENTRY *entry = (CDKENTRY*)alphalist->entryField; CDKSCROLL *scrollp = 0; int currentIndex = 0; int wordLength = 0; int selected = -1; int altCount = 0; int height = 0; int match = 0; int Index = 0; int ret = 0; int x = 0; char **altWords = 0; unsigned used = 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 (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, wordLength); if (ret == 0) { currentIndex = Index; altCount = 0; height = 0; match = 0; selected = -1; /* Start looking for alternate words. */ /* FIXME: bsearch would be more suitable */ while ((currentIndex < alphalist->listSize) && (strncmp (alphalist->list[currentIndex], entry->info, wordLength) == 0)) { used = CDKallocStrings (&altWords, alphalist->list[currentIndex++], 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, "Possible Matches.", 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, char **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) cdk-5.0-20060507/binding.c0000644000175100001440000001210510415271441013313 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/04/06 19:59:29 $ * $Revision: 1.54 $ * * 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 = (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; } cdk-5.0-20060507/button.c0000644000175100001440000003041310426516001013212 0ustar tomusers#include #include "button.h" #include /* * $Author: tom $ * $Date: 2006/05/05 00:27:45 $ * $Revision: 1.32 $ */ DeclareCDKObjects (BUTTON, Button, setCdk, Int); /* * This creates a button widget. */ CDKBUTTON *newCDKButton (CDKSCREEN * cdkscreen, int xplace, int yplace, char *text, tButtonCallback callback, boolean Box, boolean shadow) { /* Maintain the button information. */ 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); /* 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; ObjOf (button)->inputWindow = button->win; ObjOf (button)->acceptsFocus = TRUE; initExitType(button); button->shadow = shadow; /* 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 = 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, char *mesg, boolean Box) { setCDKButtonMessage (button, mesg); setCDKButtonBox (button, Box); } /* * This sets the information within the button. */ void setCDKButtonMessage (CDKBUTTON * button, 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 = A_REVERSE | CharOf(c); } 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 = 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 *button = (CDKBUTTON *) object; int ret = unknownInt; bool complete = FALSE; setExitType(button, 0); /* Check a predefined binding. */ if (checkCDKObjectBind (vBUTTON, button, input) != 0) { checkEarlyExit(button); complete = TRUE; } else { switch (input) { case KEY_ESC : setExitType(button, input); complete = TRUE; break; case KEY_ENTER: case SPACE: if (button->callback) button->callback (button); setExitType(button, KEY_ENTER); ret = 0; complete = TRUE; break; case CDK_REFRESH: eraseCDKScreen (ScreenOf (button)); refreshCDKScreen (ScreenOf (button)); break; default: Beep (); break; } } if (!complete) { setExitType(button, 0); } ResultOf(button).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) cdk-5.0-20060507/buttonbox.c0000644000175100001440000003253510426516001013732 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:27:45 $ * $Revision: 1.62 $ */ DeclareCDKObjects(BUTTONBOX, Buttonbox, setCdk, Int); /* * This returns a CDK buttonbox widget pointer. */ CDKBUTTONBOX *newCDKButtonbox (CDKSCREEN *cdkscreen, int xPos, int yPos, int height, int width, char *title, int rows, int cols, char **buttons, int buttonCount, chtype highlight, boolean Box, boolean shadow) { 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); /* 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 = 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) { CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)object; int firstButton = 0; int lastButton = buttonbox->buttonCount - 1; int ppReturn = 1; int ret = unknownInt; bool complete = FALSE; /* Set the exit type. */ setExitType(buttonbox, 0); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf(buttonbox) != 0) { ppReturn = PreProcessFuncOf(buttonbox) (vBUTTONBOX, buttonbox, PreProcessDataOf(buttonbox), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check for a key binding. */ if (checkCDKObjectBind (vBUTTONBOX, buttonbox, input) != 0) { checkEarlyExit(buttonbox); complete = TRUE; } else { switch (input) { case KEY_LEFT : case KEY_BTAB : case KEY_BACKSPACE : if ((buttonbox->currentButton-buttonbox->rows) < firstButton) { buttonbox->currentButton = lastButton; } else { buttonbox->currentButton -= buttonbox->rows; } break; case KEY_RIGHT : case KEY_TAB : case SPACE : if ((buttonbox->currentButton + buttonbox->rows) > lastButton) { buttonbox->currentButton = firstButton; } else { buttonbox->currentButton += buttonbox->rows; } break; case KEY_UP : if ((buttonbox->currentButton-1) < firstButton) { buttonbox->currentButton = lastButton; } else { buttonbox->currentButton--; } break; case KEY_DOWN : if ((buttonbox->currentButton + 1) > lastButton) { buttonbox->currentButton = firstButton; } else { buttonbox->currentButton++; } break; case CDK_REFRESH : eraseCDKScreen (ScreenOf(buttonbox)); refreshCDKScreen (ScreenOf(buttonbox)); break; case KEY_ESC : setExitType(buttonbox, input); complete = TRUE; break; case KEY_ENTER : setExitType(buttonbox, input); ret = buttonbox->currentButton; complete = TRUE; break; default : break; } } /* Should we call a post-process? */ if (!complete && (PostProcessFuncOf(buttonbox) != 0)) { PostProcessFuncOf(buttonbox) (vBUTTONBOX, buttonbox, PostProcessDataOf(buttonbox), input); } } if (!complete) { drawCDKButtonboxButtons (buttonbox); setExitType(buttonbox, 0); } ResultOf(buttonbox).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) { int row = TitleLinesOf(buttonbox) + 1; 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; 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) cdk-5.0-20060507/c++/0000755000175100001440000000000010427502123012103 5ustar tomuserscdk-5.0-20060507/c++/cdkscreen.cc0000644000175100001440000000065606701155515014373 0ustar tomusers#include "cdkscreen.h" CDKScreen::CDKScreen() { cursesWin = initscr(); cdkscreen = initCDKScreen(cursesWin); // 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); } cdk-5.0-20060507/c++/cdkscreen.h0000644000175100001440000000123206701304651014221 0ustar tomusers#ifndef CDKSCREEN_H #define CDK_SCREEN_H extern "C" { #include } 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 cdk-5.0-20060507/calendar.c0000644000175100001440000006345610426516001013465 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:27:45 $ * $Revision: 1.84 $ */ #define YEAR2INDEX(year) (((year) >= 1900) ? ((year) - 1900) : (year)) /* * Declare file local variables. */ static char *monthsOfTheYear[] = { "NULL", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; static int daysOfTheMonth[] = { -1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; /* * Declare file local prototypes. */ static int getMonthLength (int year, int month); static int getMonthStartWeekday (int year, int month); static time_t getCurrentTime (CDKCALENDAR *calendar); static void verifyCalendarDate (CDKCALENDAR *calendar); static void incrementCalendarDay (CDKCALENDAR *calendar, int adjust); static void decrementCalendarDay (CDKCALENDAR *calendar, int adjust); static void incrementCalendarMonth (CDKCALENDAR *calendar, int adjust); static void decrementCalendarMonth (CDKCALENDAR *calendar, int adjust); static void incrementCalendarYear (CDKCALENDAR *calendar, int adjust); static void decrementCalendarYear (CDKCALENDAR *calendar, int adjust); static void drawCDKCalendarField (CDKCALENDAR *calendar); DeclareCDKObjects(CALENDAR, Calendar, setCdk, Int); /* * This creates a calendar widget. */ CDKCALENDAR *newCDKCalendar(CDKSCREEN *cdkscreen, int xplace, int yplace, char *title, int day, int month, int year, chtype dayAttrib, chtype monthAttrib, chtype yearAttrib, chtype highlight, boolean Box, boolean shadow) { /* Maintain the calendar information. */ CDKCALENDAR *calendar = 0; int parentWidth = getmaxx(cdkscreen->window); int parentHeight = getmaxy(cdkscreen->window); int boxWidth = 24; int boxHeight = 11; int xpos = xplace; int ypos = yplace; int x; struct tm *dateInfo; time_t clck; char *dayname = "Su Mo Tu We Th Fr Sa"; static const struct { int from; int to; } bindings[] = { { 'T', KEY_HOME }, { 't', KEY_HOME }, { 'n', KEY_NPAGE }, { CDK_FORCHAR, KEY_NPAGE }, { 'p', KEY_PPAGE }, { CDK_BACKCHAR, KEY_PPAGE }, }; if ((calendar = newCDKObject(CDKCALENDAR, &my_funcs)) == 0) return (0); setCDKCalendarBox (calendar, Box); boxWidth = setCdkTitle(ObjOf(calendar), title, boxWidth); boxHeight += TitleLinesOf(calendar); /* * 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); /* Create the calendar window. */ calendar->win = newwin (boxHeight, boxWidth, ypos, xpos); /* Is the window null? */ if (calendar->win == 0) { destroyCDKObject (calendar); return (0); } keypad (calendar->win, TRUE); /* Set some variables. */ calendar->xOffset = (boxWidth - 20) / 2; calendar->fieldWidth = boxWidth - 2 * (1 + BorderOf(calendar)); /* Set months and days names */ for (x=0; x < MAX_MONTHS; x++) { calendar->MonthName[x] = copyChar(monthsOfTheYear[x]); } calendar->DayName = copyChar(dayname); /* Set the rest of the widget values. */ ScreenOf(calendar) = cdkscreen; calendar->parent = cdkscreen->window; calendar->shadowWin = 0; calendar->xpos = xpos; calendar->ypos = ypos; calendar->boxWidth = boxWidth; calendar->boxHeight = boxHeight; calendar->day = day; calendar->month = month; calendar->year = year; calendar->dayAttrib = dayAttrib; calendar->monthAttrib = monthAttrib; calendar->yearAttrib = yearAttrib; calendar->highlight = highlight; calendar->width = boxWidth; initExitType(calendar); ObjOf(calendar)->acceptsFocus = TRUE; ObjOf(calendar)->inputWindow = calendar->win; calendar->shadow = shadow; calendar->labelWin = subwin (calendar->win, 1, calendar->fieldWidth, ypos + TitleLinesOf(calendar) + 1, xpos + 1 + BorderOf(calendar)); if (calendar->labelWin == 0) { destroyCDKObject (calendar); return (0); } calendar->fieldWin = subwin (calendar->win, 7, 20, ypos + TitleLinesOf(calendar) + 3, xpos + calendar->xOffset); if (calendar->fieldWin == 0) { destroyCDKObject (calendar); return (0); } setCDKCalendarBox (calendar, Box); calendar->marker = typeCallocN(chtype, CALENDAR_LIMIT); if (calendar->marker == 0) { destroyCDKObject (calendar); return (0); } /* If the day/month/year values were 0, then use today's date. */ if ((calendar->day == 0) && (calendar->month == 0) && (calendar->year == 0)) { time (&clck); dateInfo = localtime (&clck); calendar->day = dateInfo->tm_mday; calendar->month = dateInfo->tm_mon + 1; calendar->year = dateInfo->tm_year + 1900; } /* Verify the dates provided. */ verifyCalendarDate (calendar); /* Determine which day the month starts on. */ calendar->weekDay = getMonthStartWeekday (calendar->year, calendar->month); /* If a shadow was requested, then create the shadow window. */ if (shadow) { calendar->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1); } /* Setup the key bindings. */ for (x = 0; x < (int) SIZEOF(bindings); ++x) bindCDKObject (vCALENDAR, calendar, bindings[x].from, getcCDKBind, (void *)(long)bindings[x].to); registerCDKObject (cdkscreen, vCALENDAR, calendar); return (calendar); } /* * This function lets the user play with this widget. */ time_t activateCDKCalendar (CDKCALENDAR *calendar, chtype *actions) { chtype input = 0; boolean functionKey; time_t ret = -1; /* Draw the widget. */ drawCDKCalendar (calendar, ObjOf(calendar)->box); if (actions == 0) { for (;;) { input = getchCDKObject (ObjOf(calendar), &functionKey); /* Inject the character into the widget. */ ret = injectCDKCalendar (calendar, input); if (calendar->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 = injectCDKCalendar (calendar, actions[x]); if (calendar->exitType != vEARLY_EXIT) { return ret; } } } return ret; } /* * This injects a single character into the widget. */ static int _injectCDKCalendar (CDKOBJS *object, chtype input) { CDKCALENDAR *calendar = (CDKCALENDAR *)object; /* Declare local variables. */ int ppReturn = 1; int ret = unknownInt; bool complete = FALSE; /* Set the exit type. */ setExitType(calendar, 0); /* Refresh the calendar field. */ drawCDKCalendarField (calendar); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf(calendar) != 0) { /* Call the pre-process function. */ ppReturn = PreProcessFuncOf(calendar) (vCALENDAR, calendar, PreProcessDataOf(calendar), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check a predefined binding. */ if (checkCDKObjectBind (vCALENDAR, calendar, input) != 0) { checkEarlyExit(calendar); complete = TRUE; } else { switch (input) { case KEY_UP : decrementCalendarDay (calendar, 7); break; case KEY_DOWN : incrementCalendarDay (calendar, 7); break; case KEY_LEFT : decrementCalendarDay (calendar, 1); break; case KEY_RIGHT : incrementCalendarDay (calendar, 1); break; case KEY_NPAGE : incrementCalendarMonth (calendar, 1); break; case 'N' : incrementCalendarMonth (calendar, 6); break; case KEY_PPAGE : decrementCalendarMonth (calendar, 1); break; case 'P' : decrementCalendarMonth (calendar, 6); break; case '-' : decrementCalendarYear (calendar, 1); break; case '+' : incrementCalendarYear (calendar, 1); break; case KEY_HOME: setCDKCalendarDate (calendar, -1, -1, -1); break; case KEY_ESC : setExitType(calendar, input); complete = TRUE; break; case KEY_TAB : case KEY_ENTER : setExitType(calendar, input); ret = getCurrentTime (calendar); complete = TRUE; break; case CDK_REFRESH : eraseCDKScreen (ScreenOf(calendar)); refreshCDKScreen (ScreenOf(calendar)); break; } } /* Should we do a post-process? */ if (!complete && (PostProcessFuncOf(calendar) != 0)) { PostProcessFuncOf(calendar) (vCALENDAR, calendar, PostProcessDataOf(calendar), input); } } if (!complete) { setExitType(calendar, 0); } ResultOf(calendar).valueInt = ret; return (ret != unknownInt); } /* * This moves the calendar field to the given location. */ static void _moveCDKCalendar (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDKCALENDAR *calendar = (CDKCALENDAR *)object; /* Declare local variables. */ int currentX = getbegx(calendar->win); int currentY = getbegy(calendar->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(calendar->win) + xplace; ypos = getbegy(calendar->win) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf(calendar), &xpos, &ypos, calendar->boxWidth, calendar->boxHeight); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the window to the new location. */ moveCursesWindow(calendar->win, -xdiff, -ydiff); moveCursesWindow(calendar->fieldWin, -xdiff, -ydiff); moveCursesWindow(calendar->labelWin, -xdiff, -ydiff); moveCursesWindow(calendar->shadowWin, -xdiff, -ydiff); /* Touch the windows so they 'move'. */ refreshCDKWindow (WindowOf(calendar)); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDKCalendar (calendar, ObjOf(calendar)->box); } } /* * This draws the calendar widget. */ static void _drawCDKCalendar (CDKOBJS *object, boolean Box) { CDKCALENDAR *calendar = (CDKCALENDAR *)object; int headerLen = (int)strlen (calendar->DayName); /* Is there a shadow? */ if (calendar->shadowWin != 0) { drawShadow (calendar->shadowWin); } /* Box the widget if asked. */ if (Box) { drawObjBox (calendar->win, ObjOf(calendar)); } drawCdkTitle (calendar->win, object); /* Draw in the day-of-the-week header. */ writeChar (calendar->win, calendar->xOffset, TitleLinesOf(calendar) + 2, calendar->DayName, HORIZONTAL, 0, headerLen); wrefresh (calendar->win); drawCDKCalendarField (calendar); } /* * This draws the month field. */ static void drawCDKCalendarField (CDKCALENDAR *calendar) { /* Declare local variables. */ char *monthName = calendar->MonthName[calendar->month]; int monthLength = getMonthLength (calendar->year, calendar->month); int yearIndex = YEAR2INDEX(calendar->year); int yearLen = 0; int day = 1; int x, y; int save_y = -1, save_x = -1; char temp[10]; for (x = 1; x <= 6; x++) { for (y = (x == 1) ? calendar->weekDay : 0; y < 7; y++) { if (day <= monthLength) { int ypos = y * 3; int xpos = x; chtype marker = calendar->dayAttrib; sprintf(temp, "%02d", day); if (calendar->day == day) { marker = calendar->highlight; save_y = xpos + getbegy(calendar->fieldWin) - getbegy(InputWindowOf(calendar)); save_x = 1; } else { marker |= getCDKCalendarMarker(calendar, day, calendar->month, yearIndex); } writeCharAttrib (calendar->fieldWin, ypos, xpos, temp, marker, HORIZONTAL, 0, 2); } day++; } } wrefresh (calendar->fieldWin); /* Draw the month in. */ if (calendar->labelWin != 0) { sprintf (temp, "%s %d,", monthName, calendar->day); writeChar (calendar->labelWin, 0, 0, temp, HORIZONTAL, 0, strlen(temp)); wclrtoeol (calendar->labelWin); /* Draw the year in. */ sprintf (temp, "%d", calendar->year); yearLen = (int)strlen (temp); writeChar (calendar->labelWin, calendar->fieldWidth - yearLen, 0, temp, HORIZONTAL, 0, yearLen); wmove (calendar->labelWin, 0, 0); wrefresh (calendar->labelWin); } else if (save_y >= 0) { wmove (InputWindowOf(calendar), save_y, save_x); wrefresh (InputWindowOf(calendar)); } } /* * This sets multiple attributes of the widget. */ void setCDKCalendar (CDKCALENDAR *calendar, int day, int month, int year, chtype dayAttrib, chtype monthAttrib, chtype yearAttrib, chtype highlight, boolean Box) { setCDKCalendarDate (calendar, day, month, year); setCDKCalendarDayAttribute (calendar, dayAttrib); setCDKCalendarMonthAttribute (calendar, monthAttrib); setCDKCalendarYearAttribute (calendar, yearAttrib); setCDKCalendarHighlight (calendar, highlight); setCDKCalendarBox (calendar, Box); } /* * This sets the date and some attributes. */ void setCDKCalendarDate (CDKCALENDAR *calendar, int day, int month, int year) { /* Declare local variables. */ struct tm *dateInfo; time_t clck; /* * Get the current dates and set the default values for * the day/month/year values for the calendar. */ time (&clck); dateInfo = localtime (&clck); /* Set the date elements if we need too. */ calendar->day = (day == -1 ? dateInfo->tm_mday : day); calendar->month = (month == -1 ? dateInfo->tm_mon + 1 : month); calendar->year = (year == -1 ? dateInfo->tm_year + 1900 : year); /* Verify the date information. */ verifyCalendarDate (calendar); /* Get the start of the current month. */ calendar->weekDay = getMonthStartWeekday (calendar->year, calendar->month); } /* * This returns the current date on the calendar. */ void getCDKCalendarDate (CDKCALENDAR *calendar, int *day, int *month, int *year) { (*day) = calendar->day; (*month) = calendar->month; (*year) = calendar->year; } /* * This sets the attribute of the days in the calendar. */ void setCDKCalendarDayAttribute (CDKCALENDAR *calendar, chtype attribute) { calendar->dayAttrib = attribute; } chtype getCDKCalendarDayAttribute (CDKCALENDAR *calendar) { return calendar->dayAttrib; } /* * This sets the attribute of the month names in the calendar. */ void setCDKCalendarMonthAttribute (CDKCALENDAR *calendar, chtype attribute) { calendar->monthAttrib = attribute; } chtype getCDKCalendarMonthAttribute (CDKCALENDAR *calendar) { return calendar->monthAttrib; } /* * This sets the attribute of the year in the calendar. */ void setCDKCalendarYearAttribute (CDKCALENDAR *calendar, chtype attribute) { calendar->yearAttrib = attribute; } chtype getCDKCalendarYearAttribute (CDKCALENDAR *calendar) { return calendar->yearAttrib; } /* * This sets the attribute of the highlight box. */ void setCDKCalendarHighlight (CDKCALENDAR *calendar, chtype highlight) { calendar->highlight = highlight; } chtype getCDKCalendarHighlight (CDKCALENDAR *calendar) { return calendar->highlight; } /* * This sets the box attibute of the widget. */ void setCDKCalendarBox (CDKCALENDAR *calendar, boolean Box) { ObjOf(calendar)->box = Box; ObjOf(calendar)->borderSize = Box ? 1 : 0; } boolean getCDKCalendarBox (CDKCALENDAR *calendar) { return ObjOf(calendar)->box; } /* * This sets the background attribute of the widget. */ static void _setBKattrCalendar (CDKOBJS *object, chtype attrib) { if (object != 0) { CDKCALENDAR *widget = (CDKCALENDAR *) object; wbkgd (widget->win, attrib); wbkgd (widget->fieldWin, attrib); if (widget->labelWin != 0) { wbkgd (widget->labelWin, attrib); } } } /* * This erases the calendar widget. */ static void _eraseCDKCalendar (CDKOBJS *object) { if (validCDKObject (object)) { CDKCALENDAR *calendar = (CDKCALENDAR *)object; eraseCursesWindow (calendar->labelWin); eraseCursesWindow (calendar->fieldWin); eraseCursesWindow (calendar->win); eraseCursesWindow (calendar->shadowWin); } } /* * This destroys the calendar object pointer. */ static void _destroyCDKCalendar (CDKOBJS *object) { if (object != 0) { CDKCALENDAR *calendar = (CDKCALENDAR *)object; int x; cleanCdkTitle (object); freeChar(calendar->DayName); for (x=0; x < MAX_MONTHS; x++) { freeChar(calendar->MonthName[x]); } freeChecked(calendar->marker); /* Free up the window pointers. */ deleteCursesWindow (calendar->labelWin); deleteCursesWindow (calendar->fieldWin); deleteCursesWindow (calendar->shadowWin); deleteCursesWindow (calendar->win); /* Clean the key bindings. */ cleanCDKObjectBindings (vCALENDAR, calendar); /* Unregister the object. */ unregisterCDKObject (vCALENDAR, calendar); } } /* * This sets a marker on the calendar. */ void setCDKCalendarMarker (CDKCALENDAR *calendar, int day, int month, int year, chtype marker) { int yearIndex = YEAR2INDEX(year); chtype oldmarker = getCDKCalendarMarker(calendar, day, month, year); /* Check to see if a marker has not already been set. */ if (oldmarker != 0) { CALENDAR_CELL(calendar,day,month,yearIndex) = oldmarker | A_BLINK; } else { CALENDAR_CELL(calendar,day,month,yearIndex) = marker; } } chtype getCDKCalendarMarker (CDKCALENDAR *calendar, int day, int month, int year) { int result = 0; year = YEAR2INDEX(year); if (calendar->marker != 0) result = CALENDAR_CELL(calendar, day, month, year); return result; } /* * This sets a marker on the calendar. */ void removeCDKCalendarMarker (CDKCALENDAR *calendar, int day, int month, int year) { int yearIndex = YEAR2INDEX(year); CALENDAR_CELL(calendar,day,month,yearIndex) = 0; } /* * This function sets the month name. */ void setCDKCalendarMonthsNames (CDKCALENDAR *calendar, char **months) { int x; for (x=1; x < MAX_MONTHS; x++) { freeChar(calendar->MonthName[x]); calendar->MonthName[x] = copyChar(months[x]); } } /* * This function sets the days name. */ void setCDKCalendarDaysNames (CDKCALENDAR *calendar, char *days) { freeChar(calendar->DayName); calendar->DayName = copyChar(days); } /* * This makes sure that the dates provided exist. */ static void verifyCalendarDate (CDKCALENDAR *calendar) { int monthLength; /* Make sure the given year is not less than 1900. */ if (calendar->year < 1900) { calendar->year = 1900; } /* Make sure the month is within range. */ if (calendar->month > 12) { calendar->month = 12; } if (calendar->month < 1) { calendar->month = 1; } /* Make sure the day given is within range of the month. */ monthLength = getMonthLength (calendar->year, calendar->month); if (calendar->day < 1) { calendar->day = 1; } if (calendar->day > monthLength) { calendar->day = monthLength; } } /* * This returns what day of the week the month starts on. */ static int getMonthStartWeekday (int year, int month) { struct tm Date; /* Set the tm structure correctly. */ Date.tm_sec = 0; Date.tm_min = 0; Date.tm_hour = 10; Date.tm_mday = 1; Date.tm_mon = month - 1; Date.tm_year = YEAR2INDEX(year); Date.tm_isdst = 1; /* Call the mktime function to fill in the holes. */ if (mktime (&Date) == (time_t)-1) { return 0; } return Date.tm_wday; } /* * This function returns a 1 if it's a leap year and 0 if it's not. */ static int isLeapYear (int year) { if (year % 4 == 0 || year % 4 == 0) { return 1; } return 0; } /* * This increments the current day by the given value. */ static void incrementCalendarDay (CDKCALENDAR *calendar, int adjust) { int monthLength = getMonthLength (calendar->year, calendar->month); /* Make sure we adjust the day correctly. */ if (adjust + calendar->day > monthLength) { /* Have to increment the month by one. */ calendar->day = calendar->day + adjust - monthLength; incrementCalendarMonth (calendar, 1); } else { calendar->day += adjust; drawCDKCalendarField (calendar); } } /* * This decrments the current day by the given value. */ static void decrementCalendarDay (CDKCALENDAR *calendar, int adjust) { int monthLength; /* Make sure we adjust the day correctly. */ if (calendar->day - adjust < 1) { /* Set the day according to the length of the month. */ if (calendar->month == 1) { /* Make sure we aren't going past the year limit. */ if (calendar->year == 1900) { char *mesg[] = {"Error", "Can not go past the year 1900"}; Beep(); popupLabel (ScreenOf(calendar), mesg, 2); return; } monthLength = getMonthLength (calendar->year - 1, 12); } else { monthLength = getMonthLength (calendar->year, calendar->month - 1); } calendar->day = monthLength - (adjust - calendar->day); /* Have to decrement the month by one. */ decrementCalendarMonth (calendar, 1); } else { calendar->day -= adjust; drawCDKCalendarField (calendar); } } /* * This increments the current month by the given value. */ static void incrementCalendarMonth (CDKCALENDAR *calendar, int adjust) { int monthLength; /* Are we at the end of the year. */ if (calendar->month + adjust > 12) { calendar->month = (calendar->month + adjust) - 12; calendar->year++; } else { calendar->month += adjust; } /* Get the length of the current month. */ monthLength = getMonthLength (calendar->year, calendar->month); if (calendar->day > monthLength) { calendar->day = monthLength; } /* Get the start of the current month. */ calendar->weekDay = getMonthStartWeekday (calendar->year, calendar->month); /* Redraw the calendar. */ eraseCDKCalendar (calendar); drawCDKCalendar (calendar, ObjOf(calendar)->box); } /* * This decrements the current month by the given value. */ static void decrementCalendarMonth (CDKCALENDAR *calendar, int adjust) { int monthLength; /* Are we at the end of the year. */ if (calendar->month <= adjust) { if (calendar->year == 1900) { char *mesg[] = {"Error", "Can not go past the year 1900"}; Beep(); popupLabel (ScreenOf(calendar), mesg, 2); return; } else { calendar->month = 13 - adjust; calendar->year--; } } else { calendar->month -= adjust; } /* Get the length of the current month. */ monthLength = getMonthLength (calendar->year, calendar->month); if (calendar->day > monthLength) { calendar->day = monthLength; } /* Get the start of the current month. */ calendar->weekDay = getMonthStartWeekday (calendar->year, calendar->month); /* Redraw the calendar. */ eraseCDKCalendar (calendar); drawCDKCalendar (calendar, ObjOf(calendar)->box); } /* * This increments the current year by the given value. */ static void incrementCalendarYear (CDKCALENDAR *calendar, int adjust) { /* Increment the year. */ calendar->year += adjust; /* If we are in Feb make sure we don't trip into voidness. */ if (calendar->month == 2) { int monthLength = getMonthLength (calendar->year, calendar->month); if (calendar->day > monthLength) { calendar->day = monthLength; } } /* Get the start of the current month. */ calendar->weekDay = getMonthStartWeekday (calendar->year, calendar->month); /* Redraw the calendar. */ eraseCDKCalendar (calendar); drawCDKCalendar (calendar, ObjOf(calendar)->box); } /* * This decrements the current year by the given value. */ static void decrementCalendarYear (CDKCALENDAR *calendar, int adjust) { /* Make sure we don't go out of bounds. */ if (calendar->year - adjust < 1900) { char *mesg[] = {"Error", "Can not go past the year 1900"}; Beep(); popupLabel (ScreenOf(calendar), mesg, 2); return; } /* Decrement the year. */ calendar->year -= adjust; /* If we are in Feb make sure we don't trip into voidness. */ if (calendar->month == 2) { int monthLength = getMonthLength (calendar->year, calendar->month); if (calendar->day > monthLength) { calendar->day = monthLength; } } /* Get the start of the current month. */ calendar->weekDay = getMonthStartWeekday (calendar->year, calendar->month); /* Redraw the calendar. */ eraseCDKCalendar (calendar); drawCDKCalendar (calendar, ObjOf(calendar)->box); } /* * This returns the length of the current month. */ static int getMonthLength (int year, int month) { int monthLength = daysOfTheMonth[month]; if (month == 2) { monthLength += isLeapYear (year); } return monthLength; } /* * This returns what day of the week the month starts on. */ static time_t getCurrentTime (CDKCALENDAR *calendar) { struct tm Date, *dateInfo; time_t clck; /* Determine the current time and determine if we are in DST. */ time (&clck); dateInfo = localtime (&clck); /* Set the tm structure correctly. */ Date.tm_sec = 0; Date.tm_min = 0; Date.tm_hour = 0; Date.tm_mday = calendar->day; Date.tm_mon = calendar->month - 1; Date.tm_year = YEAR2INDEX(calendar->year); Date.tm_isdst = dateInfo->tm_isdst; /* Call the mktime function to fill in the holes. */ return mktime (&Date); } static void _focusCDKCalendar(CDKOBJS *object) { CDKCALENDAR *widget = (CDKCALENDAR *)object; drawCDKFScale (widget, ObjOf(widget)->box); } static void _unfocusCDKCalendar(CDKOBJS *object) { CDKCALENDAR *widget = (CDKCALENDAR *)object; drawCDKFScale (widget, ObjOf(widget)->box); } dummyRefreshData(Calendar) dummySaveData(Calendar) cdk-5.0-20060507/cdk.c0000644000175100001440000007023610422541726012457 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/04/23 00:01:26 $ * $Revision: 1.204 $ */ #define L_MARKER '<' #define R_MARKER '>' char *GPasteBuffer = 0; /* * This beeps then flushes the stdout stream. */ void Beep (void) { beep (); fflush (stdout); } /* * This sets a string to the given character. */ void cleanChar (char *s, int len, char character) { if (s != 0) { int x; for (x = 0; x < len; x++) { s[x] = character; } s[--x] = '\0'; } } void cleanChtype (chtype *s, int len, chtype character) { if (s != 0) { int x; for (x = 0; x < len; x++) { s[x] = character; } s[--x] = '\0'; } } /* * This takes an x and y position and realigns the values iff they sent in * values like CENTER, LEFT, RIGHT, ... */ void alignxy (WINDOW *window, int *xpos, int *ypos, int boxWidth, int boxHeight) { int first, gap, last; first = getbegx (window); last = getmaxx (window); if ((gap = (last - boxWidth)) < 0) gap = 0; last = first + gap; switch (*xpos) { case LEFT: (*xpos) = first; break; case RIGHT: (*xpos) = first + gap; break; case CENTER: (*xpos) = first + (gap / 2); break; default: if ((*xpos) > last) (*xpos) = last; else if ((*xpos) < first) (*xpos) = first; break; } first = getbegy (window); last = getmaxy (window); if ((gap = (last - boxHeight)) < 0) gap = 0; last = first + gap; switch (*ypos) { case TOP: (*ypos) = first; break; case BOTTOM: (*ypos) = first + gap; break; case CENTER: (*ypos) = first + (gap / 2); break; default: if ((*ypos) > last) { (*ypos) = last; } else if ((*ypos) < first) { (*ypos) = first; } break; } } /* * This takes a string, a field width and a justification type * and returns the adjustment to make, to fill * the justification requirement. */ int justifyString (int boxWidth, int mesgLength, int justify) { /* * Make sure the message isn't longer than the width. * If it is, return 0. */ if (mesgLength >= boxWidth) return (0); /* Try to justify the message. */ if (justify == LEFT) return (0); if (justify == RIGHT) return boxWidth - mesgLength; if (justify == CENTER) return ((int)((boxWidth - mesgLength) / 2)); return (justify); } /* * This frees a string if it is not null. This is a safety * measure. Some compilers let you free a null string. I * don't like that idea. */ void freeChar (char *string) { freeChecked (string); } void freeChtype (chtype *string) { freeChecked (string); } /* * Corresponding list freeing (does not free the list pointer). */ void freeCharList (char **list, unsigned size) { if (list != 0) { while (size-- != 0) { freeChar (list[size]); list[size] = 0; } } } void freeChtypeList (chtype **list, unsigned size) { if (list != 0) { while (size-- != 0) { freeChtype (list[size]); list[size] = 0; } } } /* * This performs a safe copy of a string. This means it adds the null * terminator on the end of the string, like strdup(). */ char *copyChar (char *original) { char *newstring = 0; if (original != 0) { if ((newstring = typeMallocN (char, strlen (original) + 1)) != 0) strcpy (newstring, original); } return (newstring); } chtype *copyChtype (chtype *original) { chtype *newstring = 0; if (original != 0) { int len = chlen (original); int x; if ((newstring = typeMallocN (chtype, len + 4)) != 0) { for (x = 0; x < len; x++) { newstring[x] = original[x]; } newstring[len] = '\0'; newstring[len + 1] = '\0'; } else { newstring = original; } } return (newstring); } /* * Copy the given lists. */ char **copyCharList (char **list) { unsigned size = lenCharList (list) + 1; char **result = typeMallocN (char *, size); if (result != 0) { unsigned n; for (n = 0; n < size; ++n) result[n] = copyChar (list[n]); } return result; } chtype **copyChtypeList (chtype **list) { unsigned size = lenChtypeList (list) + 1; chtype **result = typeMallocN (chtype *, size); if (result != 0) { while (size-- != 0) { freeChtype (list[size]); list[size] = 0; } } return result; } /* * Return the length of the given lists. */ int lenCharList (char **list) { int result = 0; if (list != 0) { while (*list++ != 0) ++result; } return result; } int lenChtypeList (chtype **list) { int result = 0; if (list != 0) { while (*list++ != 0) ++result; } return result; } /* * This reads a file and sticks it into the char *** provided. */ int CDKreadFile (char *filename, char ***array) { FILE *fd; char temp[BUFSIZ]; unsigned lines = 0; unsigned used = 0; /* Can we open the file? */ if ((fd = fopen (filename, "r")) == 0) { return (-1); } while ((fgets (temp, sizeof (temp), fd) != 0)) { size_t len = strlen (temp); if (len != 0 && temp[len - 1] == '\n') temp[--len] = '\0'; used = CDKallocStrings (array, temp, lines++, used); } fclose (fd); return (lines); } #define DigitOf(c) ((c)-'0') static int encodeAttribute (char *string, int from, chtype *mask) { int pair = 0; *mask = 0; switch (string[from + 1]) { case 'B': *mask = A_BOLD; break; case 'D': *mask = A_DIM; break; case 'K': *mask = A_BLINK; break; case 'R': *mask = A_REVERSE; break; case 'S': *mask = A_STANDOUT; break; case 'U': *mask = A_UNDERLINE; break; } if (*mask != 0) { from++; } else if (isdigit (CharOf (string[from + 1])) && isdigit (CharOf (string[from + 2]))) { #ifdef HAVE_START_COLOR pair = DigitOf (string[from + 1]) * 10 + DigitOf (string[from + 2]); *mask = COLOR_PAIR (pair); #else *mask = A_BOLD; #endif from += 2; } else if (isdigit (CharOf (string[from + 1]))) { #ifdef HAVE_START_COLOR pair = DigitOf (string[from + 1]); *mask = COLOR_PAIR (pair); #else *mask = A_BOLD; #endif from++; } return from; } /* * The reverse of encodeAttribute() * Well almost. If attributes such as bold and underline are combined in * the same string, we do not necessarily reconstruct them in the same order. * Also, alignment markers and tabs are lost. */ static unsigned decodeAttribute (char *string, unsigned from, chtype oldattr, chtype newattr) { /* *INDENT-OFF* */ static const struct { int code; chtype mask; } table[] = { { 'B', A_BOLD }, { 'D', A_DIM }, { 'K', A_BLINK }, { 'R', A_REVERSE }, { 'S', A_STANDOUT }, { 'U', A_UNDERLINE }, }; /* *INDENT-ON* */ char temp[80]; char *result = (string != 0) ? string : temp; char *base = result; chtype tmpattr = oldattr & A_ATTRIBUTES; newattr &= A_ATTRIBUTES; if (tmpattr != newattr) { while (tmpattr != newattr) { unsigned n; bool found = FALSE; for (n = 0; n < sizeof (table) / sizeof (table[0]); ++n) { if ((table[n].mask & tmpattr) != (table[n].mask & newattr)) { found = TRUE; *result++ = L_MARKER; if (table[n].mask & tmpattr) { *result++ = '!'; tmpattr &= ~(table[n].mask); } else { *result++ = '/'; tmpattr |= (table[n].mask); } *result++ = table[n].code; break; } } #ifdef HAVE_START_COLOR if ((tmpattr & A_COLOR) != (newattr & A_COLOR)) { int oldpair = PAIR_NUMBER (tmpattr); int newpair = PAIR_NUMBER (newattr); if (!found) { found = TRUE; *result++ = L_MARKER; } if (newpair == 0) { *result++ = '!'; sprintf (result, "%d", oldpair); } else { *result++ = '/'; sprintf (result, "%d", newpair); } result += strlen (result); tmpattr &= ~A_COLOR; newattr &= ~A_COLOR; } #endif if (found) *result++ = R_MARKER; else break; } } return from + (result - base); } /* * This function takes a character string, full of format markers * and translates them into a chtype * array. This is better suited * to curses, because curses uses chtype almost exclusively */ chtype *char2Chtype (char *string, int *to, int *align) { chtype *result = 0; chtype attrib; chtype lastChar; chtype mask; int adjust; int from; int insideMarker; int len; int pass; int start; int used; int x; (*to) = 0; *align = LEFT; if (string != 0 && *string != 0) { len = (int)strlen (string); used = 0; /* * We make two passes because we may have indents and tabs to expand, and * do not know in advance how large the result will be. */ for (pass = 0; pass < 2; pass++) { if (pass != 0) { if ((result = typeMallocN (chtype, used + 2)) == 0) { used = 0; break; } } adjust = 0; attrib = A_NORMAL; lastChar = 0; start = 0; used = 0; x = 3; /* Look for an alignment marker. */ if (*string == L_MARKER) { if (string[1] == 'C' && string[2] == R_MARKER) { (*align) = CENTER; start = 3; } else if (string[1] == 'R' && string[2] == R_MARKER) { (*align) = RIGHT; start = 3; } else if (string[1] == 'L' && string[2] == R_MARKER) { start = 3; } else if (string[1] == 'B' && string[2] == '=') { /* Set the item index value in the string. */ if (result != 0) { result[0] = ' '; result[1] = ' '; result[2] = ' '; } /* Pull out the bullet marker. */ while (string[x] != R_MARKER && string[x] != 0) { if (result != 0) result[x] = string[x] | A_BOLD; x++; } adjust = 1; /* Set the alignment variables. */ start = x; used = x; } else if (string[1] == 'I' && string[2] == '=') { from = 2; x = 0; while (string[++from] != R_MARKER && string[from] != 0) { if (isdigit (CharOf (string[from]))) { adjust = (adjust * 10) + DigitOf (string[from]); x++; } } start = x + 4; } } while (adjust-- > 0) { if (result != 0) result[used] = ' '; used++; } /* Set the format marker boolean to false. */ insideMarker = FALSE; /* Start parsing the character string. */ for (from = start; from < len; from++) { /* Are we inside a format marker? */ if (!insideMarker) { if (string[from] == L_MARKER && (string[from + 1] == '/' || string[from + 1] == '!' || string[from + 1] == '#')) { insideMarker = TRUE; } else if (string[from] == '\\' && string[from + 1] == L_MARKER) { from++; if (result != 0) result[used] = CharOf (string[from]) | attrib; used++; from++; } else if (string[from] == '\t') { do { if (result != 0) result[used] = ' '; used++; } while (used & 7); } else { if (result != 0) result[used] = CharOf (string[from]) | attrib; used++; } } else { switch (string[from]) { case R_MARKER: insideMarker = 0; break; case '#': { lastChar = 0; switch (string[from + 2]) { case 'L': switch (string[from + 1]) { case 'L': lastChar = ACS_LLCORNER; break; case 'U': lastChar = ACS_ULCORNER; break; case 'H': lastChar = ACS_HLINE; break; case 'V': lastChar = ACS_VLINE; break; case 'P': lastChar = ACS_PLUS; break; } break; case 'R': switch (string[from + 1]) { case 'L': lastChar = ACS_LRCORNER; break; case 'U': lastChar = ACS_URCORNER; break; } break; case 'T': switch (string[from + 1]) { case 'T': lastChar = ACS_TTEE; break; case 'R': lastChar = ACS_RTEE; break; case 'L': lastChar = ACS_LTEE; break; case 'B': lastChar = ACS_BTEE; break; } break; case 'A': switch (string[from + 1]) { case 'L': lastChar = ACS_LARROW; break; case 'R': lastChar = ACS_RARROW; break; case 'U': lastChar = ACS_UARROW; break; case 'D': lastChar = ACS_DARROW; break; } break; default: if (string[from + 1] == 'D' && string[from + 2] == 'I') lastChar = ACS_DIAMOND; else if (string[from + 1] == 'C' && string[from + 2] == 'B') lastChar = ACS_CKBOARD; else if (string[from + 1] == 'D' && string[from + 2] == 'G') lastChar = ACS_DEGREE; else if (string[from + 1] == 'P' && string[from + 2] == 'M') lastChar = ACS_PLMINUS; else if (string[from + 1] == 'B' && string[from + 2] == 'U') lastChar = ACS_BULLET; else if (string[from + 1] == 'S' && string[from + 2] == '1') lastChar = ACS_S1; else if (string[from + 1] == 'S' && string[from + 2] == '9') lastChar = ACS_S9; } if (lastChar != 0) { adjust = 1; from += 2; if (string[from + 1] == '(') /* Check for a possible numeric modifier. */ { from++; adjust = 0; while (string[++from] != ')' && string[from] != 0) { if (isdigit (CharOf (string[from]))) { adjust = (adjust * 10) + DigitOf (string[from]); } } } } for (x = 0; x < adjust; x++) { if (result != 0) result[used] = lastChar | attrib; used++; } break; } case '/': from = encodeAttribute (string, from, &mask); attrib = attrib | mask; break; case '!': from = encodeAttribute (string, from, &mask); attrib = attrib & ~mask; break; } } } if (result != 0) { result[used] = 0; result[used + 1] = 0; } /* * If there are no characters, put the attribute into the * the first character of the array. */ if (used == 0 && result != 0) { result[0] = attrib; } } *to = used; } else { /* * Try always to return something; otherwise lists of chtype strings * would get a spurious null pointer whenever there is a blank line, * and CDKfreeChtypes() would fail to free the whole list. */ result = typeCallocN (chtype, 1); } return result; } /* * This determines the length of a chtype string */ int chlen (chtype *string) { int result = 0; if (string != 0) { while (string[result] != 0) result++; } return (result); } /* * Compare a regular string to a chtype string */ int cmpStrChstr (char *str, chtype *chstr) { int r = 0; if (!str && !chstr) return 0; if (!str) return 1; if (!chstr) return -1; while (!r && *str && *chstr) { r = *str - CharOf (*chstr); ++str; ++chstr; } if (r) return r; else if (!*str) return -1; else if (!*chstr) return 1; return 0; } void chstrncpy (char *dest, chtype *src, int maxcount) { int i = 0; while (i < maxcount && *src) *dest++ = CharOf (*src++); *dest = '\0'; } /* * This returns a pointer to char * of a chtype * * Formatting codes are omitted. */ char *chtype2Char (chtype *string) { char *newstring = 0; if (string != 0) { int len = chlen (string); int x; if ((newstring = typeMallocN (char, len + 1)) != 0) { for (x = 0; x < len; x++) { newstring[x] = (char)CharOf (string[x]); } newstring[len] = '\0'; } } return (newstring); } /* * This returns a pointer to char * of a chtype * * Formatting codes are embedded. */ char *chtype2String (chtype *string) { char *newstring = 0; if (string != 0) { int pass; int len = chlen (string); for (pass = 0; pass < 2; ++pass) { int x; unsigned need = 0; for (x = 0; x < len; ++x) { need = decodeAttribute (newstring, need, (x > 0) ? string[x - 1] : 0, string[x]); if (newstring != 0) newstring[need] = CharOf (string[x]); ++need; } if (pass) newstring[need] = 0; ++need; if (!pass) { if ((newstring = typeMallocN (char, need)) == 0) break; } } } return (newstring); } static int comparSort (const void *a, const void *b) { return strcmp (*(const char *const *)a, (*(const char *const *)b)); } void sortList (char **list, int length) { if (length > 1) qsort (list, (unsigned)length, sizeof (list[0]), comparSort); } /* * This strips white space from the given string. */ void stripWhiteSpace (EStripType stripType, char *string) { /* Declare local variables. */ unsigned stringLength = 0; unsigned alphaChar = 0; unsigned x; /* Make sure the string is not null. */ if (string != 0 && (stringLength = strlen (string)) != 0) { /* Strip leading whitespace */ if (stripType == vFRONT || stripType == vBOTH) { /* Find the first non-whitespace character. */ while (string[alphaChar] == ' ' || string[alphaChar] == '\t') { alphaChar++; } for (x = alphaChar; x <= stringLength; ++x) string[x - alphaChar] = string[x]; } /* Strip trailing whitespace */ if (stripType == vBACK || stripType == vBOTH) { stringLength = strlen (string); while (stringLength-- != 0 && (string[stringLength] == ' ' || string[stringLength] == '\t')) { string[stringLength] = '\0'; } } } } static unsigned countChar (char *string, int separator) { unsigned result = 0; int ch; while ((ch = *string++) != 0) { if (ch == separator) result++; } return result; } /* * Split a string into a list of strings. */ char **CDKsplitString (char *string, int separator) { char **result = 0; char *first; char *temp; unsigned item; unsigned need; if (string != 0 && *string != 0) { need = countChar (string, separator) + 2; if ((result = typeMallocN (char *, need)) != 0) { item = 0; first = string; for (;;) { while (*string != 0 && *string != separator) string++; need = string - first; if ((temp = typeMallocN (char, need + 1)) == 0) break; memcpy (temp, first, need); temp[need] = 0; result[item++] = temp; if (*string++ == 0) break; first = string; } result[item] = 0; } } return result; } /* * Add a new string to a list. Keep a null pointer on the end so we can use * CDKfreeStrings() to deallocate the whole list. */ unsigned CDKallocStrings (char ***list, char *item, unsigned length, unsigned used) { unsigned need = 1; while (need < length + 2) need *= 2; if (need > used) { used = need; if (*list == 0) { *list = typeMallocN (char *, used); } else { *list = typeReallocN (char *, *list, used); } } (*list)[length++] = copyChar (item); (*list)[length] = 0; return used; } /* * Count the number of items in a list of strings. */ unsigned CDKcountStrings (char **list) { unsigned result = 0; if (list != 0) { while (*list++ != 0) result++; } return result; } /* * Free a list of strings, terminated by a null pointer. */ void CDKfreeStrings (char **list) { if (list != 0) { void *base = (void *)list; while (*list != 0) free (*list++); free (base); } } /* * Free a list of chtype-strings, terminated by a null pointer. */ void CDKfreeChtypes (chtype **list) { if (list != 0) { void *base = (void *)list; while (*list != 0) { freeChtype (*list++); } free (base); } } int mode2Filetype (mode_t mode) { /* *INDENT-OFF* */ static const struct { mode_t mode; char code; } table[] = { #ifdef S_IFBLK { S_IFBLK, 'b' }, /* Block device */ #endif { S_IFCHR, 'c' }, /* Character device */ { S_IFDIR, 'd' }, /* Directory */ { S_IFREG, '-' }, /* Regular file */ #ifdef S_IFLNK { S_IFLNK, 'l' }, /* Socket */ #endif #ifdef S_IFSOCK { S_IFSOCK, '@' }, /* Socket */ #endif { S_IFIFO, '&' }, /* Pipe */ }; /* *INDENT-ON* */ int filetype = '?'; unsigned n; for (n = 0; n < sizeof (table) / sizeof (table[0]); n++) { if ((mode & S_IFMT) == table[n].mode) { filetype = table[n].code; break; } } return filetype; } /* * This function takes a mode_t type and creates a string represntation * of the permission mode. */ int mode2Char (char *string, mode_t mode) { /* *INDENT-OFF* */ static struct { mode_t mask; unsigned col; char flag; } table[] = { { S_IRUSR, 1, 'r' }, { S_IWUSR, 2, 'w' }, { S_IXUSR, 3, 'x' }, { S_IRGRP, 4, 'r' }, { S_IWGRP, 5, 'w' }, { S_IXGRP, 6, 'x' }, { S_IROTH, 7, 'r' }, { S_IWOTH, 8, 'w' }, { S_IXOTH, 9, 'x' }, { S_ISUID, 3, 's' }, { S_ISGID, 6, 's' }, #ifdef S_ISVTX { S_ISVTX, 9, 't' }, #endif }; /* *INDENT-ON* */ /* Declare local variables. */ int permissions = 0; int filetype = mode2Filetype (mode); unsigned n; /* Clean the string. */ cleanChar (string, 11, '-'); string[11] = '\0'; if (filetype == '?') return -1; for (n = 0; n < sizeof (table) / sizeof (table[0]); n++) { if ((mode & table[n].mask) != 0) { string[table[n].col] = table[n].flag; permissions |= table[n].mask; } } /* Check for unusual permissions. */ if (((mode & S_IXUSR) == 0) && ((mode & S_IXGRP) == 0) && ((mode & S_IXOTH) == 0) && (mode & S_ISUID) != 0) { string[3] = 'S'; } return permissions; } /* * This returns the length of the integer. */ int intlen (int value) { if (value < 0) return 1 + intlen (-value); else if (value >= 10) return 1 + intlen (value / 10); return 1; } /* * This opens the current directory and reads the contents. */ int CDKgetDirectoryContents (char *directory, char ***list) { /* Declare local variables. */ struct dirent *dirStruct; int counter = 0; DIR *dp; unsigned used = 0; /* Open the directory. */ dp = opendir (directory); /* Could we open the directory? */ if (dp == 0) { return -1; } /* Read the directory. */ while ((dirStruct = readdir (dp)) != 0) { if (strcmp (dirStruct->d_name, ".")) used = CDKallocStrings (list, dirStruct->d_name, counter++, used); } /* Close the directory. */ closedir (dp); /* Sort the info. */ sortList (*list, counter); /* Return the number of files in the directory. */ return counter; } /* * This looks for a subset of a word in the given list. */ int searchList (char **list, int listSize, char *pattern) { /* Declare local variables. */ unsigned len; int Index = -1; int x, ret; /* Make sure the pattern isn't null. */ if (pattern != 0) { len = strlen (pattern); /* Cycle through the list looking for the word. */ for (x = 0; x < listSize; x++) { /* Do a string compare. */ ret = strncmp (list[x], pattern, len); /* * If 'ret' is less than 0, then the current word is alphabetically * less than the provided word. At this point we will set the index * to the current position. If 'ret' is greater than 0, then the * current word is alphabetically greater than the given word. We * should return with index, which might contain the last best match. * If they are equal, then we've found it. */ if (ret < 0) { Index = ret; } else { if (ret == 0) Index = x; break; } } } return Index; } /* * This function checks to see if a link has been requested. */ int checkForLink (char *line, char *filename) { int len = 0; int fPos = 0; int x = 3; /* Make sure the line isn't null. */ if (line == 0) { return -1; } len = (int)strlen (line); /* Strip out the filename. */ if (line[0] == L_MARKER && line[1] == 'F' && line[2] == '=') { /* Strip out the filename. */ while (x < len) { if (line[x] == R_MARKER) { break; } if (fPos < CDK_PATHMAX) filename[fPos++] = line[x]; ++x; } } filename[fPos] = '\0'; return (fPos != 0); } /* * Returns the filename portion of the given pathname, i.e., after the last * slash. */ char *baseName (char *pathname) { char *base = 0; unsigned pathLen; unsigned x; if (pathname != 0 && *pathname != '\0' && (base = copyChar (pathname)) != 0) { if ((pathLen = strlen (pathname)) != 0) { for (x = pathLen - 1; x != 0; --x) { /* Find the last '/' in the pathname. */ if (pathname[x] == '/') { strcpy (base, pathname + x + 1); break; } } } } return base; } /* * Returns the directory for the given pathname, i.e., the part before the * last slash. */ char *dirName (char *pathname) { char *dir = 0; unsigned pathLen; unsigned x; /* Check if the string is null. */ if (pathname != 0 && (dir = copyChar (pathname)) != 0 && (pathLen = strlen (pathname)) != 0) { x = pathLen; while ((dir[x] != '/') && (x > 0)) { dir[x--] = '\0'; } } return dir; } /* * If the dimension is a negative value, the dimension will be the full * height/width of the parent window - the value of the dimension. Otherwise, * the dimension will be the given value. */ int setWidgetDimension (int parentDim, int proposedDim, int adjustment) { int dimension = 0; /* If the user passed in FULL, return the parent's size. */ if ((proposedDim == FULL) || (proposedDim == 0)) { dimension = parentDim; } else { /* If they gave a positive value, return it. */ if (proposedDim >= 0) { if (proposedDim >= parentDim) dimension = parentDim; else dimension = (proposedDim + adjustment); } else { /* * If they gave a negative value, then return the * dimension of the parent plus the value given. */ dimension = parentDim + proposedDim; /* Just to make sure. */ if (dimension < 0) dimension = parentDim; } } return dimension; } /* * This safely erases a given window. */ void eraseCursesWindow (WINDOW *window) { if (window != 0) { werase (window); wrefresh (window); } } /* * This safely deletes a given window. */ void deleteCursesWindow (WINDOW *window) { if (window != 0) { eraseCursesWindow (window); delwin (window); } } /* * This moves a given window (if we're able to set the window's beginning). * We do not use mvwin(), because it does (usually) not move subwindows. */ void moveCursesWindow (WINDOW *window, int xdiff, int ydiff) { if (window != 0) { int xpos, ypos; getbegyx (window, ypos, xpos); if (setbegyx (window, ypos, xpos) != ERR) { xpos += xdiff; ypos += ydiff; werase (window); (void)setbegyx (window, ypos, xpos); } else { Beep (); } } } /* * Return an integer like 'floor()', which returns a double. */ int floorCDK (double value) { int result = (int)value; if (result > value) /* e.g., value < 0.0 and value is not an integer */ result--; return result; } /* * Return an integer like 'ceil()', which returns a double. */ int ceilCDK (double value) { return -floorCDK (-value); } /* * Compatibility for different versions of curses. */ #if !(defined(HAVE_GETBEGX) && defined(HAVE_GETBEGY)) int getbegx (WINDOW *win) { int y, x; getbegyx (win, y, x); return x; } int getbegy (WINDOW *win) { int y, x; getbegyx (win, y, x); return y; } #endif #if !(defined(HAVE_GETMAXX) && defined(HAVE_GETMAXY)) int getmaxx (WINDOW *win) { int y, x; getmaxyx (win, y, x); return x; } int getmaxy (WINDOW *win) { int y, x; getmaxyx (win, y, x); return y; } #endif cdk-5.0-20060507/cdk.spec0000644000175100001440000000202310355113016013144 0ustar tomusers# $Id: cdk.spec,v 1.15 2005/12/30 02:06:06 tom Exp $ # Note that this is NOT a relocatable package %define ver 5.0 %define subver 20051230 %define rel 1 %define prefix /usr Summary: A Curses Development Library (ncurses-based widgets) Name: cdk Version: %ver Release: %rel Copyright: BSD Group: Applications/Libraries Source: ftp://invisible-island.com/cdk/cdk.tar.gz BuildRoot: /tmp/cdk-%{ver}-root Packager: Squidster Requires: ncurses %description A Curses Development Library (ncurses-based widgets) %changelog %prep %setup -n %{name}-%{ver}-%{subver} %build CFLAGS="${RPM_OPT_FLAGS}" CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%prefix make DOCUMENT_DIR=/usr/share/doc/cdk %install rm -rf $RPM_BUILD_ROOT make DESTDIR=$RPM_BUILD_ROOT DOCUMENT_DIR=$RPM_BUILD_ROOT/usr/share/doc/cdk install %clean rm -rf $RPM_BUILD_ROOT %post %postun %files %defattr(-, root, root) %doc BUGS EXPANDING NOTES TODO COPYING INSTALL README %{prefix}/include/cdk/*.h %{prefix}/lib/lib*.a %{prefix}/man/man3/* cdk-5.0-20060507/cdk_compat.c0000644000175100001440000000263210354603407014014 0ustar tomusers/* * $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; } cdk-5.0-20060507/cdk_display.c0000644000175100001440000000501210421026557014171 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/04/18 00:06:07 $ * $Revision: 1.3 $ */ /* * Given a character pointer, returns the equivalent display type. */ EDisplayType char2DisplayType (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; } cdk-5.0-20060507/cdk_objs.c0000644000175100001440000001062010230035572013455 0ustar tomusers#include /* * Default method-functions for CDK objects. * * $Author: tom $ * $Date: 2005/04/15 22:08:58 $ * $Revision: 1.12 $ */ /* * 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, 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, char *title, int boxWidth) { if (obj != 0) { cleanCdkTitle (obj); if (title != 0) { chtype *holder; char **temp = 0; int titleWidth; int x; int len; int align; int maxWidth = 0; /* We need to split the title on \n. */ temp = CDKsplitString (title, '\n'); obj->titleLines = CDKcountStrings (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) { /* We need to determine the widest title line. */ for (x = 0; x < obj->titleLines; x++) { 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_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; } cdk-5.0-20060507/cdk_params.c0000644000175100001440000001063710354315576014027 0ustar tomusers#include /* * Useful functions for command-line parsing. * * $Author: tom $ * $Date: 2005/12/27 19:52:30 $ * $Revision: 1.6 $ */ #define OPTION_ON ((char *)1) #define OPTION_OFF ((char *)0) static void usage (char **argv, CDK_PARAMS * params, char *options) { int n; char *str; fprintf (stderr, "Usage: %s [options]\n\nOptions:\n", baseName (argv[0])); 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")); } } } exit (EXIT_FAILURE); } static int CDKparseSize (char *string, int fullSize) { int result; if (strcmp (string, "FULL") == 0) { result = fullSize; } else { result = strtol (string, (char **)0, 0); } return result; } /* * Parse the string as one of CDK's positioning keywords, or an actual * position. */ int CDKparsePosition (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 = 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, char *options) { int code; char *str; memset (params, 0, sizeof (*params)); params->Box = TRUE; while ((code = getopt (argc, argv, options)) != EOF) { 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, char *missing) { char *value = ((option > 0 && option < MAX_CDK_PARAMS) ? params->allParams[option] : 0); if (value == 0) value = 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 = strtol (value, (char **)0, 0); } return result; } cdk-5.0-20060507/cdkscreen.c0000644000175100001440000002330610355046105013647 0ustar tomusers#include #ifdef HAVE_SETLOCALE #include #endif /* * $Author: tom $ * $Date: 2005/12/29 20:51:17 $ * $Revision: 1.87 $ */ 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) { ALL_OBJECTS *p, *q; if (validCDKObject (obj)) { 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) { /* Set up basic curses settings. */ #ifdef HAVE_SETLOCALE setlocale (LC_ALL, ""); #endif 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 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; int Index, x; if (screen != 0) { Index = (obj)->screenIndex; 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); } } } /* * Exactly one widget should have focus, and it should be visible. */ if (focused < 0) focused = visible; 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 } cdk-5.0-20060507/cli/0000755000175100001440000000000010427502123012302 5ustar tomuserscdk-5.0-20060507/cli/samples/0000755000175100001440000000000010427502123013746 5ustar tomuserscdk-5.0-20060507/cli/samples/dialog.sh0000755000175100001440000000350710354261542015557 0ustar tomusers#!/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="Pick which command you wish to run." # # Create the button labels. # commands="who w uptime date pwd whoami df 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 "Here is the result of the command" > ${tmp} echo " " >> ${tmp} # # Determine which command to run. # if [ "${selection}" -eq 0 ]; then who | awk '{printf "%s\n", $0}' >> ${tmp} elif [ "${selection}" -eq 1 ]; then w | awk '{printf "%s\n", $0}' >> ${tmp} elif [ "${selection}" -eq 2 ]; then uptime | awk '{printf "%s\n", $0}' >> ${tmp} elif [ "${selection}" -eq 3 ]; then date | awk '{printf "%s\n", $0}' >> ${tmp} elif [ "${selection}" -eq 4 ]; then pwd | awk '{printf "%s\n", $0}' >> ${tmp} elif [ "${selection}" -eq 5 ]; then whoami | awk '{printf "%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 "%s\n", $0}' >> ${tmp} fi echo " " >> ${tmp} echo "Hit space to continue." >> ${tmp} # # Create the label widget to display the information. # ${CDK_LABEL} -f ${tmp} -p " " # # Clean up. # rm -f ${tmp} ${output} ${fileSystemList} cdk-5.0-20060507/cli/samples/fselect.sh0000755000175100001440000000300710354300065015732 0ustar tomusers#!/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="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 "You selected the following file" > ${tmp} echo " " >> ${tmp} echo "<#HL(10)>" >> ${tmp} echo "${answer}" >> ${tmp} echo "<#HL(10)>" >> ${tmp} echo " " >> ${tmp} echo "You chose button #${selected}" >> ${tmp} echo " " >> ${tmp} echo "Press space to continue." >> ${tmp} ${CDK_LABEL} -f ${tmp} -p " " # # Clean up. # rm -f ${tmp} ${file} cdk-5.0-20060507/cli/samples/itemlist.sh0000755000175100001440000000476010354261542016154 0ustar tomusers#!/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="Account <#HL(30)> Account: ${userAccount} UID : ${uid} GID : ${gid} Info : ${info} Home : ${home} Shell : ${shell} <#HL(30)> Hit space 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="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 "%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} cdk-5.0-20060507/cli/samples/label.sh0000755000175100001440000000267710354261542015406 0ustar tomusers#!/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 "%s\n", $0}' > ${top} tail +2 ${dfTmp} > ${bottom} # # Create the message for the label widget. # echo "This is the current" > ${tmp} echo "status of your local filesystems." >> ${tmp} echo "<#HL(2)>" >> ${tmp} cat ${top} >> ${tmp} cat ${bottom} >> ${tmp} echo "<#HL(2)>" >> ${tmp} echo "" >> ${tmp} echo "Hit space 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} cdk-5.0-20060507/cli/samples/entry.sh0000755000175100001440000000177210354261542015463 0ustar tomusers#!/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=" Type a simple string. " buttons=" OK Cancel " # # Create the entry box. # ${CDK_ENTRY} -f 20 -T "${title}" -B "${buttons}" -F "_ " -O ${output} -S selected=$? test $selected = 255 && exit 1 answer=`cat ${output}` # # Create the message for the label widget. # echo "Here is the string you typed in" > ${tmp} echo " " >> ${tmp} echo "${answer}" >> ${tmp} echo " " >> ${tmp} echo "You chose button #${selected}" >> ${tmp} echo " " >> ${tmp} echo "Hit space to continue." >> ${tmp} # # Create the label widget to display the information. # ${CDK_LABEL} -f ${tmp} -p " " # # Clean up. # rm -f ${tmp} ${output} cdk-5.0-20060507/cli/samples/mentry.sh0000755000175100001440000000202110354261542015624 0ustar tomusers#!/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="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 "Here is the message you typed in" > ${tmp} echo " " >> ${tmp} echo "${answer}" >> ${tmp} echo " " >> ${tmp} echo "You chose button #${selected}" >> ${tmp} echo " " >> ${tmp} echo "Hit space to continue." >> ${tmp} # # Create the label widget to display the information. # ${CDK_LABEL} -f ${tmp} -p " " # # Clean up. # rm -f ${tmp} ${output} cdk-5.0-20060507/cli/samples/scale.sh0000755000175100001440000000204610354261542015404 0ustar tomusers#!/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="Enter a value using the cursor keys." label="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 "Here is the value you selected" > ${tmp} echo " " >> ${tmp} echo "${answer}" >> ${tmp} echo " " >> ${tmp} echo "You chose button #${selected}" >> ${tmp} echo " " >> ${tmp} echo "Hit space to continue." >> ${tmp} # # Create the label widget to display the information. # ${CDK_LABEL} -f ${tmp} -p " " # # Clean up. # rm -f ${tmp} ${output} cdk-5.0-20060507/cli/samples/scroll.sh0000755000175100001440000000471610354261542015621 0ustar tomusers#!/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="Account <#HL(30)> Account: ${userAccount} UID : ${uid} GID : ${gid} Info : ${info} Home : ${home} Shell : ${shell} <#HL(30)> Hit space 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="<#HL(30)> Pick an account you want to view. <#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} cdk-5.0-20060507/cli/samples/template.sh0000755000175100001440000000212510354261542016126 0ustar tomusers#!/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=" Type in the 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 "Here is the IP you typed in" > ${tmp} echo " " >> ${tmp} echo "${answer}" >> ${tmp} echo " " >> ${tmp} echo "You chose button #${selected}" >> ${tmp} echo " " >> ${tmp} echo "Hit space to continue." >> ${tmp} # # Create the label widget to display the information. # ${CDK_LABEL} -f ${tmp} -p " " # # Clean up. # rm -f ${tmp} ${output} cdk-5.0-20060507/cli/samples/slider.sh0000755000175100001440000000206410354261542015577 0ustar tomusers#!/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="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 "*" -B "${buttons}" -O ${output} selected=$? test $selected = 255 && exit 1 answer=`cat ${output}` # # Create the message for the label widget. # echo "Here is the value you selected" > ${tmp} echo " " >> ${tmp} echo "${answer}" >> ${tmp} echo " " >> ${tmp} echo "You chose button #${selected}" >> ${tmp} echo " " >> ${tmp} echo "Hit space to continue." >> ${tmp} # # Create the label widget to display the information. # ${CDK_LABEL} -f ${tmp} -p " " # # Clean up. # rm -f ${tmp} ${output} cdk-5.0-20060507/cli/samples/viewer.sh0000755000175100001440000000263210354261542015617 0ustar tomusers#!/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 "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="CDK File Viewer Widget ${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} cdk-5.0-20060507/cli/samples/radio.sh0000755000175100001440000000343710354261542015420 0ustar tomusers#!/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="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 "*" -B "${buttons}" 2> $output selected=$? test $selected = 255 && exit 1 # # The selection is now in the file $output. # fs=`cat ${output}` echo "File Statistics on the filesystem ${fs}" > ${tmp} echo " " >> ${tmp} grep "${fs}" ${diskInfo} | awk '{printf "%s\n", $0}' >> ${tmp} echo " " >> ${tmp} echo "You chose button #${selected}" >> ${tmp} echo " " >> ${tmp} echo "Hit space to continue." >> ${tmp} # # Create the label widget to display the information. # ${CDK_LABEL} -f ${tmp} -p " " # # Clean up. # rm -f ${tmp} ${output} ${fileSystemList} ${diskInfo} cdk-5.0-20060507/cli/samples/alphalist.sh0000755000175100001440000000435410354263051016277 0ustar tomusers#!/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="Account <#HL(30)> Account: ${userAccount} UID : ${uid} GID : ${gid} Info : ${info} Home : ${home} Shell : ${shell} <#HL(30)> Hit space 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="Pick an account 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} cdk-5.0-20060507/cli/samples/selection.sh0000755000175100001440000000676610354300152016306 0ustar tomusers#!/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="Account ${currentSelection}/${totalSelections} <#HL(30)> Account: ${userAccount} UID : ${uid} GID : ${gid} Info : ${info} Home : ${home} Shell : ${shell} <#HL(30)> Hit space 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="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 "%s\n", $1}' ${userAccounts} > ${accountList} accounts=`cat ${userAccounts}` # # Create the choices list. # choices="No 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} cdk-5.0-20060507/cli/samples/matrix.sh0000755000175100001440000000373410354272264015631 0ustar tomusers#!/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="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 "You chose button #${selected}" > ${tmp} echo " " >> ${tmp} echo "Hit space to continue." >> ${tmp} # # Create the label widget to display the information. # ${CDK_LABEL} -f "${tmp}" -p " " # # Clean up. # rm -f ${info} ${fileSystemList} ${tmp} ${diskInfo} cdk-5.0-20060507/cli/samples/calendar.sh0000755000175100001440000000305210354261542016064 0ustar tomusers#!/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="<#HL(22)> Select a date <#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 "You chose the following date" > ${tmp} echo " " >> ${tmp} echo "<#HL(10)>" >> ${tmp} echo "${answer}" >> ${tmp} echo "<#HL(10)>" >> ${tmp} echo " " >> ${tmp} echo "You chose button #${selected}" >> ${tmp} echo " " >> ${tmp} echo "Hit space to continue." >> ${tmp} # # Create the label widget to display the information. # ${CDK_LABEL} -f ${tmp} -p " " # # Clean up. # rm -f ${tmp} ${date} cdk-5.0-20060507/cli/utils/0000755000175100001440000000000010427502123013442 5ustar tomuserscdk-5.0-20060507/cli/utils/adduser0000755000175100001440000004000107515116465015030 0ustar tomusers#!/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=""; export CDK_WIDGET_COLOR CDK_SCREEN_COLOR=""; 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="<#HL(30)> Add New User Canceled Program exiting <#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="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="Account Name: " title="Account Name The name is the identity of the account which the user will use to access the system. " ${CDK_ENTRY} -i "${ACCOUNT_NAME}" -f 15 -m 3 -F "_" -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="Account Found The account you provided ${ACCOUNT_NAME} already exists in the password file. Please pick 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="Personal Info: " title="Account Information. Enter in ${ACCOUNT_NAME}'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 "_" -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="Account GID: " title="Account GID The GID (Group IDentification) must be a number which already exists in the /etc/group file. The default group users has been provided for you. " ${CDK_ENTRY} -f 6 -m 1 -i "${USER_GID}" -F "_" -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="Error: No Such GID The GID you provided does not exist. 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="Account UID: " title="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 "_" -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="Error: Duplicate UID The UID you provided is already owned by the account $owner. Please pick a 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="Home Directory: " title="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 "_" -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="Account Shell Pick one of the shells to use. If you want to use a custom shell, pick Custom 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="Shell Pathname: " title="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 "_" -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="Confirm New Account. You are about to add an account with the following information: <#HL(30)> Account Name : $ACCOUNT_NAME Account Info : $ACCOUNT_INFO Account Home : $ACCOUNT_HOME Account Shell: $ACCOUNT_SHELL Account UID : $ACCOUNT_UID Account GID : $ACCOUNT_GID <#HL(30)> Are you sure you want to do this. Hit Yes if you want to add the account; hit No if you want to edit the information; hit Cancel 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="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="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="Account Add Complete The account ${ACCOUNT_NAME} 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 cdk-5.0-20060507/cli/utils/netconfig0000755000175100001440000002640507515116564015371 0ustar tomusers#!/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=""; export CDK_WIDGET_COLOR CDK_SCREEN_COLOR=""; export CDK_SCREEN_COLOR # # # exitMessage() { exit; } # # Create the opening window. # intro() { program=`basename $0` buttons="< OK >" message="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: ${program}" ${CDK_DIALOG} -m "${message}" -B "${buttons}" -S 2> /dev/null } # # Get the hostname of the machine. # getHostname() { label="Enter Hostname: " title="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 "_" -T "${title}" -L "${label}" -S 2> ${tmpFile} HOST=`cat ${tmpFile}` } # # Get the domain name of the machine. # getDomainName() { label="Enter Domain Name: " title="Enter Domain Name Now enter in the domain in which this machine will reside. Do NOT supply a leading '.' " ${CDK_ENTRY} -i "${DOMAIN}" -f 20 -F "_" -T "${title}" -L "${label}" -S 2> ${tmpFile} DOMAIN=`cat ${tmpFile}` } # # Ask them if they plan to use loopback only. # loopback() { buttons="< Yes > < No >" message="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. 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=" Enter Machine IP Address Enter the IP address you plan to assign to this machine. " plate="###.###.###.###" overlay="___.___.___.___" ${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=" 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="___.___.___.___" ${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=" 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="___.___.___.___" ${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=" 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=" 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="___.___.___.___" ${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 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="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} cdk-5.0-20060507/cli/Makefile.in0000644000175100001440000000314707761364035014373 0ustar tomusers# $Id: Makefile.in,v 1.4 2003/11/27 12:03:41 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 LIBS = -l@LIB_ROOTNAME@ @LIBS@ LIBTOOL = @LIBTOOL@ @ECHO_LT@ LIBTOOL_CLEAN = @LIB_CLEAN@ LIBTOOL_LINK = @LIB_LINK@ LINK = $(LIBTOOL_LINK) $(CC) x = @EXEEXT@ o = .@OBJEXT@ CFLAGS = @CFLAGS@ @EXTRA_CFLAGS@ CPPFLAGS = @DEFS@ -I../include -I$(srcdir)/../include -I. @CPPFLAGS@ LDFLAGS = -L.. @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 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 cdk-5.0-20060507/cli/cdklabel.c0000644000175100001440000000767010354263212014223 0ustar tomusers/* $Id: cdklabel.c,v 1.10 2005/12/27 16:06:34 tom Exp $ */ #include #ifdef XCURSES char *XCursesProgramName="cdklabel"; #endif /* * Declare file local variables. */ static 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) { /* Declare variables. */ CDKSCREEN *cdkScreen = 0; CDKLABEL *widget = 0; WINDOW *cursesWindow = 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, ¶ms, "c:f:m:p:s:" "X:Y:NS"); xpos = CDKparamValue(¶ms, 'X', CENTER); ypos = CDKparamValue(¶ms, 'Y', CENTER); boxWidget = CDKparamValue(¶ms, 'N', TRUE); shadowWidget = CDKparamValue(¶ms, 'S', FALSE); sleepLength = CDKparamValue(¶ms, 's', 0); command = CDKparamString(¶ms, 'c'); filename = CDKparamString(¶ms, 'f'); message = CDKparamString(¶ms, 'm'); if ((temp = CDKparamString(¶ms, '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 = CDKcountStrings (messageList); } /* Set up CDK. */ cursesWindow = initscr(); cdkScreen = initCDKScreen (cursesWindow); /* 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, 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) { 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 (sleepLength); } CDKfreeStrings (messageList); destroyCDKLabel (widget); destroyCDKScreen (cdkScreen); endCDK(); /* Exit cleanly. */ ExitProgram (0); } cdk-5.0-20060507/cli/cdkcalendar.c0000644000175100001440000001606010354263635014717 0ustar tomusers/* $Id: cdkcalendar.c,v 1.11 2005/12/27 16:11:09 tom Exp $ */ #include #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) { /* Declare variables. */ CDKSCREEN *cdkScreen = 0; CDKCALENDAR *widget = 0; CDKBUTTONBOX *buttonWidget = 0; WINDOW *cursesWindow = 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, ¶ms, "d:m:y:B:O:T:X:Y:NS"); xpos = CDKparamValue(¶ms, 'X', CENTER); ypos = CDKparamValue(¶ms, 'Y', CENTER); boxWidget = CDKparamValue(¶ms, 'N', TRUE); shadowWidget = CDKparamValue(¶ms, 'S', FALSE); day = CDKparamValue(¶ms, 'd', day); month = CDKparamValue(¶ms, 'm', month); year = CDKparamValue(¶ms, 'y', year); buttons = CDKparamString(¶ms, 'B'); outputFile = CDKparamString(¶ms, 'O'); title = CDKparamString(¶ms, '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); } } /* Set up CDK. */ cursesWindow = initscr(); cdkScreen = initCDKScreen (cursesWindow); /* 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 = CDKcountStrings (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, 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 = localtime (&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 = localtime (&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; injectCDKButtonbox (buttonbox, key); return (TRUE); } cdk-5.0-20060507/cli/cdkfselect.c0000644000175100001440000001524510354277502014575 0ustar tomusers/* $Id: cdkfselect.c,v 1.10 2005/12/27 17:52:02 tom Exp $ */ #include #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) { /* Declare variables. */ CDKSCREEN *cdkScreen = 0; CDKFSELECT *widget = 0; CDKBUTTONBOX *buttonWidget = 0; WINDOW *cursesWindow = 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, ¶ms, "d:B:L:O:T:" CDK_CLI_PARAMS); xpos = CDKparamValue(¶ms, 'X', CENTER); ypos = CDKparamValue(¶ms, 'Y', CENTER); height = CDKparamValue(¶ms, 'H', 0); width = CDKparamValue(¶ms, 'W', 0); boxWidget = CDKparamValue(¶ms, 'N', TRUE); shadowWidget = CDKparamValue(¶ms, 'S', FALSE); directory = CDKparamString(¶ms, 'd'); buttons = CDKparamString(¶ms, 'B'); label = CDKparamString(¶ms, 'L'); outputFile = CDKparamString(¶ms, 'O'); title = CDKparamString(¶ms, '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: "); } /* Set up CDK. */ cursesWindow = initscr(); cdkScreen = initCDKScreen (cursesWindow); /* 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 = CDKcountStrings (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, 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; injectCDKButtonbox (buttonbox, key); return (TRUE); } cdk-5.0-20060507/cli/cdkitemlist.c0000644000175100001440000001675010354266602015003 0ustar tomusers/* $Id: cdkitemlist.c,v 1.9 2005/12/27 16:36:18 tom Exp $ */ #include #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 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) { /* Declare variables. */ CDKSCREEN *cdkScreen = 0; CDKITEMLIST *widget = 0; CDKBUTTONBOX *buttonWidget = 0; WINDOW *cursesWindow = 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, ¶ms, "d:f:l:B:L:O:T:" "X:Y:NS"); xpos = CDKparamValue(¶ms, 'X', CENTER); ypos = CDKparamValue(¶ms, 'Y', CENTER); boxWidget = CDKparamValue(¶ms, 'N', TRUE); shadowWidget = CDKparamValue(¶ms, 'S', FALSE); defaultItem = CDKparamValue(¶ms, 'd', 0); filename = CDKparamString(¶ms, 'f'); list = CDKparamString(¶ms, 'l'); buttons = CDKparamString(¶ms, 'B'); label = CDKparamString(¶ms, 'L'); outputFile = CDKparamString(¶ms, 'O'); title = CDKparamString(¶ms, '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 = CDKcountStrings (itemlistList); } /* Start curses. */ cursesWindow = initscr(); /* Create the CDK screen. */ cdkScreen = initCDKScreen (cursesWindow); /* 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, 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 = CDKcountStrings (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, 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; injectCDKButtonbox (buttonbox, key); return (TRUE); } cdk-5.0-20060507/cli/cdkmatrix.c0000644000175100001440000002465210354270731014453 0ustar tomusers/* $Id: cdkmatrix.c,v 1.13 2005/12/27 16:54:49 tom Exp $ */ #include #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 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) { /* Declare variables. */ CDKSCREEN *cdkScreen = 0; CDKMATRIX *widget = 0; CDKBUTTONBOX *buttonWidget = 0; WINDOW *cursesWindow = 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, ¶ms, "c:d:r:t:w:v:B:F:O:T:" "X:Y:NS"); xpos = CDKparamValue(¶ms, 'X', CENTER); ypos = CDKparamValue(¶ms, 'Y', CENTER); boxWidget = CDKparamValue(¶ms, 'N', TRUE); shadowWidget = CDKparamValue(¶ms, 'S', FALSE); vrows = CDKparamValue(¶ms, 'v', -1); myColTitles = CDKparamString(¶ms, 'c'); defaultValue = CDKparamString(¶ms, 'd'); myRowTitles = CDKparamString(¶ms, 'r'); myColTypes = CDKparamString(¶ms, 't'); myColWidths = CDKparamString(¶ms, 'w'); buttons = CDKparamString(¶ms, 'B'); myFiller = CDKparamString(¶ms, 'F'); outputFile = CDKparamString(¶ms, 'O'); title = CDKparamString(¶ms, '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 = CDKcountStrings (rowTemp); rowTitles = (char **) calloc (rows + 1, sizeof(char *)); for (x=0; x < rows; x++) { rowTitles[x+1] = rowTemp[x]; } colTemp = CDKsplitString (myColTitles, '\n'); cols = CDKcountStrings (colTemp); colTitles = (char **) calloc (cols + 1, sizeof(char *)); for (x=0; x < cols; x++) { colTitles[x+1] = colTemp[x]; } /* Convert the column widths. */ kolTemp = CDKsplitString (myColWidths, '\n'); count = CDKcountStrings (kolTemp); colWidths = (int *) calloc (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 = CDKcountStrings (ss); colTypes = (int *) calloc (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 (cols + 1, sizeof(int)); for (x=0; x < cols; x++) { colTypes[x+1] = vMIXED; } } /* Start curses. */ cursesWindow = initscr(); /* Create the CDK screen. */ cdkScreen = initCDKScreen (cursesWindow); /* 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, rowTitles, 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: Could not 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) { int limit = (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(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] = CDKcountStrings (ss); for (y=0; y < subSize[x+1]; y++) { MY_INFO(x, y) = ss[y]; } free (ss); } CDKfreeStrings (lineTemp); setCDKMatrixCells (widget, 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 = CDKcountStrings (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, 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; injectCDKButtonbox (buttonbox, key); return (TRUE); } cdk-5.0-20060507/cli/cdkradio.c0000644000175100001440000002003710354272173014240 0ustar tomusers/* $Id: cdkradio.c,v 1.9 2005/12/27 17:06:03 tom Exp $ */ #include #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 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) { /* Declare variables. */ CDKSCREEN *cdkScreen = 0; CDKRADIO *widget = 0; CDKBUTTONBOX *buttonWidget = 0; WINDOW *cursesWindow = 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; char *choice; char *filename; char *list; char *outputFile; char *title; int defaultItem; int height; int width; int xpos; int ypos; CDKparseParams(argc, argv, ¶ms, "l:f:s:c:d:iB:O:T:" CDK_CLI_PARAMS); xpos = CDKparamValue(¶ms, 'X', CENTER); ypos = CDKparamValue(¶ms, 'Y', CENTER); height = CDKparamValue(¶ms, 'H', 10); width = CDKparamValue(¶ms, 'W', 1); boxWidget = CDKparamValue(¶ms, 'N', TRUE); shadowWidget = CDKparamValue(¶ms, 'S', FALSE); defaultItem = CDKparamValue(¶ms, 'd', 0); numberOutput = CDKparamValue(¶ms, 'i', FALSE); filename = CDKparamString(¶ms, 'f'); list = CDKparamString(¶ms, 'l'); buttons = CDKparamString(¶ms, 'B'); outputFile = CDKparamString(¶ms, 'O'); title = CDKparamString(¶ms, 'T'); if ((choice = CDKparamString(¶ms, 'c')) == 0) choice = "X"; spos = CDKparsePosition(CDKparamString(¶ms, '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 = CDKcountStrings (scrollList); } /* Start curses. */ cursesWindow = initscr(); /* Create the CDK screen. */ cdkScreen = initCDKScreen (cursesWindow); /* 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, 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 = CDKcountStrings (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, 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; injectCDKButtonbox (buttonbox, key); return (TRUE); } cdk-5.0-20060507/cli/cdkslider.c0000644000175100001440000002042510354277040014423 0ustar tomusers/* $Id: cdkslider.c,v 1.9 2005/12/27 17:47:12 tom Exp $ */ #include #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 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) { /* Declare variables. */ CDKSCREEN *cdkScreen = 0; CDKSLIDER *widget = 0; CDKBUTTONBOX *buttonWidget = 0; WINDOW *cursesWindow = 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, ¶ms, "a:f:h:i:l:s:B:F:L:O:T:" "X:Y:NS"); xpos = CDKparamValue(¶ms, 'X', CENTER); ypos = CDKparamValue(¶ms, 'Y', CENTER); boxWidget = CDKparamValue(¶ms, 'N', TRUE); shadowWidget = CDKparamValue(¶ms, 'S', FALSE); acceleratedStep = CDKparamValue(¶ms, 'a', -1); fieldWidth = CDKparamValue(¶ms, 'f', 0); highValue = CDKparamValue(¶ms, 'h', INT_MIN); incrementStep = CDKparamValue(¶ms, 'i', 1); lowValue = CDKparamValue(¶ms, 'l', INT_MAX); initValue = CDKparamValue(¶ms, 's', INT_MIN); buttons = CDKparamString(¶ms, 'B'); barAttribute = CDKparamString(¶ms, 'F'); label = CDKparamString(¶ms, 'L'); outputFile = CDKparamString(¶ms, 'O'); title = CDKparamString(¶ms, '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); } /* Set up CDK. */ cursesWindow = initscr(); cdkScreen = initCDKScreen (cursesWindow); /* 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 = CDKcountStrings (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, 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; injectCDKButtonbox (buttonbox, key); return (TRUE); } cdk-5.0-20060507/cli/cdkviewer.c0000644000175100001440000001661110354277727014460 0ustar tomusers/* $Id: cdkviewer.c,v 1.10 2005/12/27 17:54:31 tom Exp $ */ #include #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 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) { /* Declare variables. */ CDKSCREEN *cdkScreen = 0; CDKVIEWER *widget = 0; WINDOW *cursesWindow = 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, ¶ms, "f:il:B:T:" CDK_CLI_PARAMS); xpos = CDKparamValue(¶ms, 'X', CENTER); ypos = CDKparamValue(¶ms, 'Y', CENTER); height = CDKparamValue(¶ms, 'H', 20); width = CDKparamValue(¶ms, 'W', 60); boxWidget = CDKparamValue(¶ms, 'N', TRUE); shadowWidget = CDKparamValue(¶ms, 'S', FALSE); interpret = CDKparamValue(¶ms, 'i', FALSE); showInfoLine = CDKparamValue(¶ms, 'l', FALSE); filename = CDKparamString(¶ms, 'f'); buttons = CDKparamString(¶ms, 'B'); title = CDKparamString(¶ms, '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) { buttonList[0] = copyChar ("OK"); buttonList[1] = copyChar ("Cancel"); buttonCount = 2; } else { /* Split the button list up. */ buttonList = CDKsplitString (buttons, '\n'); buttonCount = CDKcountStrings (buttonList); } /* Set up the title of the viewer. */ if (title == 0) { sprintf (tempTitle, "Filename: %s", filename); title = copyChar (tempTitle); } /* Set up CDK. */ cursesWindow = initscr(); cdkScreen = initCDKScreen (cursesWindow); /* 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, 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, 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) { /* Declare local variables. */ CDKENTRY *entry = 0; char *filename = 0; char temp[256], *mesg[10]; int linesSaved; /* Create the entry field to get the filename. */ entry = newCDKEntry (ScreenOf(widget), CENTER, CENTER, "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] = "Save Canceled."; mesg[1] = "Escape hit. Scrolling window information not saved."; mesg[2] = " "; mesg[3] = "Press any key to continue."; popupLabel (ScreenOf(widget), 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] = "Error"; mesg[1] = "Could not save to the file."; sprintf (temp, "(%s)", filename); mesg[2] = copyChar (temp); mesg[3] = " "; mesg[4] = "Press any key to continue."; popupLabel (ScreenOf(widget), mesg, 5); freeChar (mesg[2]); } else { mesg[0] = "Save Successful"; sprintf (temp, "There were %d lines saved to the file", linesSaved); mesg[1] = copyChar (temp); sprintf (temp, "(%s)", filename); mesg[2] = copyChar (temp); mesg[3] = " "; mesg[4] = "Press any key to continue."; popupLabel (ScreenOf(widget), mesg, 5); freeChar (mesg[1]); freeChar (mesg[2]); } 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) { /* Declare local variables. */ 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); } cdk-5.0-20060507/cli/cdkscroll.c0000644000175100001440000001746510354275026014453 0ustar tomusers/* $Id: cdkscroll.c,v 1.9 2005/12/27 17:29:58 tom Exp $ */ #include #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 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) { /* Declare variables. */ CDKSCREEN *cdkScreen = 0; CDKSCROLL *widget = 0; CDKBUTTONBOX *buttonWidget = 0; WINDOW *cursesWindow = 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, ¶ms, "f:il:ns:B:O:T:" CDK_CLI_PARAMS); xpos = CDKparamValue(¶ms, 'X', CENTER); ypos = CDKparamValue(¶ms, 'Y', CENTER); height = CDKparamValue(¶ms, 'H', 1); width = CDKparamValue(¶ms, 'W', 1); boxWidget = CDKparamValue(¶ms, 'N', TRUE); shadowWidget = CDKparamValue(¶ms, 'S', FALSE); numberOutput = CDKparamValue(¶ms, 'i', FALSE); numbers = CDKparamValue(¶ms, 'n', FALSE); filename = CDKparamString(¶ms, 'f'); list = CDKparamString(¶ms, 'l'); buttons = CDKparamString(¶ms, 'B'); outputFile = CDKparamString(¶ms, 'O'); title = CDKparamString(¶ms, 'T'); spos = CDKparsePosition(CDKparamString(¶ms, '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 = CDKcountStrings (scrollList); } /* Start curses. */ cursesWindow = initscr(); /* Create the CDK screen. */ cdkScreen = initCDKScreen (cursesWindow); /* 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, 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 = CDKcountStrings (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, 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; injectCDKButtonbox (buttonbox, key); return (TRUE); } cdk-5.0-20060507/cli/cdkscale.c0000644000175100001440000001765310354274545014250 0ustar tomusers/* $Id: cdkscale.c,v 1.9 2005/12/27 17:27:01 tom Exp $ */ #include #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 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) { /* Declare variables. */ CDKSCREEN *cdkScreen = 0; CDKSCALE *widget = 0; CDKBUTTONBOX *buttonWidget = 0; WINDOW *cursesWindow = 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, ¶ms, "a:f:h:i:l:s:B:L:O:T:" "X:Y:NS"); xpos = CDKparamValue(¶ms, 'X', CENTER); ypos = CDKparamValue(¶ms, 'Y', CENTER); boxWidget = CDKparamValue(¶ms, 'N', TRUE); shadowWidget = CDKparamValue(¶ms, 'S', FALSE); acceleratedStep = CDKparamValue(¶ms, 'a', -1); fieldWidth = CDKparamValue(¶ms, 'f', 0); highValue = CDKparamValue(¶ms, 'h', INT_MIN); incrementStep = CDKparamValue(¶ms, 'i', 1); lowValue = CDKparamValue(¶ms, 'l', INT_MAX); initValue = CDKparamValue(¶ms, 's', INT_MIN); buttons = CDKparamString(¶ms, 'B'); label = CDKparamString(¶ms, 'L'); outputFile = CDKparamString(¶ms, 'O'); title = CDKparamString(¶ms, '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); } /* Set up CDK. */ cursesWindow = initscr(); cdkScreen = initCDKScreen (cursesWindow); /* 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 = CDKcountStrings (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, 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; injectCDKButtonbox (buttonbox, key); return (TRUE); } cdk-5.0-20060507/cli/cdkdialog.c0000644000175100001440000001057610354264246014412 0ustar tomusers/* $Id: cdkdialog.c,v 1.9 2005/12/27 16:15:34 tom Exp $ */ #include #ifdef XCURSES char *XCursesProgramName="cdkdialog"; #endif /* * Define file local variables. */ static 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) { /* Declare variables. */ CDKSCREEN *cdkScreen = 0; CDKDIALOG *widget = 0; WINDOW *cursesWindow = 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, ¶ms, "f:m:B:O:" "X:Y:NS"); xpos = CDKparamValue(¶ms, 'X', CENTER); ypos = CDKparamValue(¶ms, 'Y', CENTER); boxWidget = CDKparamValue(¶ms, 'N', TRUE); shadowWidget = CDKparamValue(¶ms, 'S', FALSE); filename = CDKparamString(¶ms, 'f'); message = CDKparamString(¶ms, 'm'); buttons = CDKparamString(¶ms, 'B'); outputFile = CDKparamString(¶ms, '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 = CDKcountStrings (messageList); } /* Set up the buttons for the dialog box. */ if (buttons == 0) { buttonList[0] = copyChar ("OK"); buttonList[1] = copyChar ("Cancel"); buttonCount = 2; } else { /* Split the button list up. */ buttonList = CDKsplitString (buttons, '\n'); buttonCount = CDKcountStrings (buttonList); } /* Set up CDK. */ cursesWindow = initscr(); cdkScreen = initCDKScreen (cursesWindow); /* 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, messageList, messageLines, 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); } cdk-5.0-20060507/cli/cdkalphalist.c0000644000175100001440000001731010354274460015124 0ustar tomusers/* $Id: cdkalphalist.c,v 1.12 2005/12/27 17:26:08 tom Exp $ */ #include #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 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) { /* Declare variables. */ CDKSCREEN *cdkScreen = 0; CDKALPHALIST *widget = 0; CDKBUTTONBOX *buttonWidget = 0; WINDOW *cursesWindow = 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 selection = 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, ¶ms, "f:l:B:F:L:O:T:" CDK_CLI_PARAMS); xpos = CDKparamValue(¶ms, 'X', CENTER); ypos = CDKparamValue(¶ms, 'Y', CENTER); height = CDKparamValue(¶ms, 'H', -1); width = CDKparamValue(¶ms, 'W', -1); boxWidget = CDKparamValue(¶ms, 'N', TRUE); shadowWidget = CDKparamValue(¶ms, 'S', FALSE); filename = CDKparamString(¶ms, 'f'); list = CDKparamString(¶ms, 'l'); buttons = CDKparamString(¶ms, 'B'); tempFiller = CDKparamString(¶ms, 'F'); label = CDKparamString(¶ms, 'L'); outputFile = CDKparamString(¶ms, 'O'); title = CDKparamString(¶ms, '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 = CDKcountStrings (scrollList); } /* Start curses. */ cursesWindow = initscr(); /* Create the CDK screen. */ cdkScreen = initCDKScreen (cursesWindow); /* 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, 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 = CDKcountStrings (buttonList); buttonWidget = newCDKButtonbox (cdkScreen, getbegx (widget->win) + 1, getbegy (widget->win) + widget->boxHeight - 1, 1, widget->boxWidth - 3, 0, 1, buttonCount, 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) { selection = buttonWidget->currentButton; 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; injectCDKButtonbox (buttonbox, key); return (TRUE); } cdk-5.0-20060507/cli/cdkmentry.c0000644000175100001440000001727510354271135014467 0ustar tomusers/* $Id: cdkmentry.c,v 1.9 2005/12/27 16:57:01 tom Exp $ */ #include #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 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) { /* Declare variables. */ CDKSCREEN *cdkScreen = 0; CDKMENTRY *widget = 0; CDKBUTTONBOX *buttonWidget = 0; WINDOW *cursesWindow = 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, ¶ms, "d:f:i:m:s:v:B:F:L:O:T:" "X:Y:NS"); xpos = CDKparamValue(¶ms, 'X', CENTER); ypos = CDKparamValue(¶ms, 'Y', CENTER); boxWidget = CDKparamValue(¶ms, 'N', TRUE); shadowWidget = CDKparamValue(¶ms, 'S', FALSE); fieldWidth = CDKparamValue(¶ms, 'f', 0); min = CDKparamValue(¶ms, 'm', 0); screenRows = CDKparamValue(¶ms, 's', 0); virtualRows = CDKparamValue(¶ms, 'v', 0); initValue = CDKparamString(¶ms, 'i'); buttons = CDKparamString(¶ms, 'B'); tempFiller = CDKparamString(¶ms, 'F'); label = CDKparamString(¶ms, 'L'); outputFile = CDKparamString(¶ms, 'O'); title = CDKparamString(¶ms, 'T'); if ((temp = CDKparamString(¶ms, '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); } } /* Set up CDK. */ cursesWindow = initscr(); cdkScreen = initCDKScreen (cursesWindow); /* 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 = (chtype)holder[0]; freeChtype (holder); } /* Create the mentry widget. */ widget = newCDKMentry (cdkScreen, xpos, ypos, title, label, fieldAttr, 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 = CDKcountStrings (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, 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; injectCDKButtonbox (buttonbox, key); return (TRUE); } cdk-5.0-20060507/cli/cdkentry.c0000644000175100001440000001703110354264616014306 0ustar tomusers/* $Id: cdkentry.c,v 1.10 2005/12/27 16:19:26 tom Exp $ */ #include #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 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) { /* Declare variables. */ CDKSCREEN *cdkScreen = 0; CDKENTRY *widget = 0; CDKBUTTONBOX *buttonWidget = 0; WINDOW *cursesWindow = 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 *filename; char *outputFile; char *initValue; char *title; char *label; char *tempFiller; int maxValue; int fieldWidth; int minValue; int xpos; int ypos; CDKparseParams(argc, argv, ¶ms, "d:f:i:m:B:F:L:M:O:T:" "X:Y:NS"); xpos = CDKparamValue(¶ms, 'X', CENTER); ypos = CDKparamValue(¶ms, 'Y', CENTER); boxWidget = CDKparamValue(¶ms, 'N', TRUE); shadowWidget = CDKparamValue(¶ms, 'S', FALSE); minValue = CDKparamValue(¶ms, 'm', 0); fieldWidth = CDKparamValue(¶ms, 'f', 0); maxValue = CDKparamValue(¶ms, 'M', 256); filename = CDKparamString(¶ms, 'f'); initValue = CDKparamString(¶ms, 'i'); buttons = CDKparamString(¶ms, 'B'); tempFiller = CDKparamString(¶ms, 'F'); label = CDKparamString(¶ms, 'L'); outputFile = CDKparamString(¶ms, 'O'); title = CDKparamString(¶ms, 'T'); if ((temp = CDKparamString(¶ms, '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); } } /* Set up CDK. */ cursesWindow = initscr(); cdkScreen = initCDKScreen (cursesWindow); /* 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 = (chtype)holder[0]; freeChtype (holder); } /* Create the entry widget. */ widget = newCDKEntry (cdkScreen, xpos, ypos, title, label, fieldAttr, 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 = CDKcountStrings (buttonList); buttonWidget = newCDKButtonbox (cdkScreen, getbegx (widget->win), getbegy (widget->win) + widget->boxHeight - 1, 1, widget->boxWidth - 1, 0, 1, buttonCount, 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; injectCDKButtonbox (buttonbox, key); return (TRUE); } cdk-5.0-20060507/cli/cdktemplate.c0000644000175100001440000001662210354277254014767 0ustar tomusers/* $Id: cdktemplate.c,v 1.9 2005/12/27 17:49:32 tom Exp $ */ #include #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 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) { /* Declare variables. */ CDKSCREEN *cdkScreen = 0; CDKTEMPLATE *widget = 0; CDKBUTTONBOX *buttonWidget = 0; WINDOW *cursesWindow = 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, ¶ms, "d:m:o:p:B:L:O:P:T:" "X:Y:NS"); xpos = CDKparamValue(¶ms, 'X', CENTER); ypos = CDKparamValue(¶ms, 'Y', CENTER); boxWidget = CDKparamValue(¶ms, 'N', TRUE); shadowWidget = CDKparamValue(¶ms, 'S', FALSE); minimum = CDKparamValue(¶ms, 'm', 0); mixPlate = CDKparamValue(¶ms, 'P', FALSE); defaultAnswer = CDKparamString(¶ms, 'd'); my_overlay = CDKparamString(¶ms, 'o'); plate = CDKparamString(¶ms, 'p'); buttons = CDKparamString(¶ms, 'B'); label = CDKparamString(¶ms, 'L'); outputFile = CDKparamString(¶ms, 'O'); title = CDKparamString(¶ms, '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); } } /* Set up CDK. */ cursesWindow = initscr(); cdkScreen = initCDKScreen (cursesWindow); /* 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 = CDKcountStrings (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, 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; injectCDKButtonbox (buttonbox, key); return (TRUE); } cdk-5.0-20060507/cli/cdkselection.c0000644000175100001440000002263210354276661015140 0ustar tomusers/* $Id: cdkselection.c,v 1.9 2005/12/27 17:45:21 tom Exp $ */ #include #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 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) { /* Declare variables. */ CDKSCREEN *cdkScreen = 0; CDKSELECTION *widget = 0; CDKBUTTONBOX *buttonWidget = 0; WINDOW *cursesWindow = 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, ¶ms, "c:f:ln:s:B:O:T:" CDK_CLI_PARAMS); xpos = CDKparamValue(¶ms, 'X', CENTER); ypos = CDKparamValue(¶ms, 'Y', CENTER); height = CDKparamValue(¶ms, 'H', 10); width = CDKparamValue(¶ms, 'W', 10); boxWidget = CDKparamValue(¶ms, 'N', TRUE); shadowWidget = CDKparamValue(¶ms, 'S', FALSE); choices = CDKparamString(¶ms, 'c'); filename = CDKparamString(¶ms, 'f'); list = CDKparamString(¶ms, 'l'); buttons = CDKparamString(¶ms, 'B'); outputFile = CDKparamString(¶ms, 'O'); title = CDKparamString(¶ms, 'T'); numbers = CDKparamValue(¶ms, 'n', FALSE); spos = CDKparsePosition(CDKparamString(¶ms, '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 = CDKcountStrings (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 = CDKcountStrings (scrollList); } /* Did they supply a chopice list. */ if (choices == 0) { choiceList[0] = copyChar ("Yes "); choiceList[1] = copyChar ("No "); choiceSize = 2; } else { /* Split the choices up. */ choiceList = CDKsplitString (choices, '\n'); choiceSize = CDKcountStrings (choiceList); } /* Start curses. */ cursesWindow = initscr(); /* Create the CDK screen. */ cdkScreen = initCDKScreen (cursesWindow); /* 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, scrollList, scrollLines, 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 = CDKcountStrings (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, 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; injectCDKButtonbox (buttonbox, key); return (TRUE); } cdk-5.0-20060507/config.guess0000755000175100001440000012461110335343062014063 0ustar tomusers#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. timestamp='2005-11-11' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner . # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerppc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep __LP64__ >/dev/null then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; x86:Interix*:[345]*) echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' exit ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) echo frv-unknown-linux-gnu exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips #undef mipsel #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mipsel #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips64 #undef mips64el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mips64el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips64 #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo or32-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. # Set LC_ALL=C to ensure ld outputs messages in English. ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 LIBC=gnu # else LIBC=gnulibc1 # endif # else LIBC=gnulibc1 # endif #else #ifdef __INTEL_COMPILER LIBC=gnu #else LIBC=gnuaout #endif #endif #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` test x"${LIBC}" != x && { echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit } test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: cdk-5.0-20060507/config.sub0000755000175100001440000007621510335735120013534 0ustar tomusers#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. timestamp='2005-11-13' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64vr | mips64vrel \ | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | ms1 \ | msp430 \ | ns16k | ns32k \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b \ | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | v850 | v850e \ | we32k \ | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; m32c) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64vr-* | mips64vrel-* \ | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | ms1-* \ | msp430-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ | xstormy16-* | xtensa-* \ | ymp-* \ | z8k-*) ;; m32c-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; c90) basic_machine=c90-cray os=-unicos ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16c) basic_machine=cr16c-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tic55x | c55x*) basic_machine=tic55x-unknown os=-coff ;; tic6x | c6x*) basic_machine=tic6x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | haiku*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: cdk-5.0-20060507/configure0000755000175100001440000067121010354612224013454 0ustar tomusers#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated automatically using autoconf version 2.13.20030927 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # Defaults: ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: # Initialize some variables set by options. # The variables have the same names as the options, with # dashes changed to underlines. build=NONE cache_file=./config.cache exec_prefix=NONE host=NONE no_create= nonopt=NONE no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= target=NONE verbose= x_includes=NONE x_libraries=NONE bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi case "$ac_option" in -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) ac_optarg= ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case "$ac_option" in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir="$ac_optarg" ;; -build | --build | --buil | --bui | --bu) ac_prev=build ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build="$ac_optarg" ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file="$ac_optarg" ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir="$ac_optarg" ;; -disable-* | --disable-*) ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` eval "enable_${ac_feature}=no" ;; -enable-* | --enable-*) ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "enable_${ac_feature}='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix="$ac_optarg" ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he) # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat << EOF Usage: configure [options] [host] Options: [defaults in brackets after descriptions] Configuration: --cache-file=FILE cache test results in FILE --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [same as prefix] --bindir=DIR user executables in DIR [EPREFIX/bin] --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] --libexecdir=DIR program executables in DIR [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data in DIR [PREFIX/share] --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data in DIR [PREFIX/com] --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] --libdir=DIR object code libraries in DIR [EPREFIX/lib] --includedir=DIR C header files in DIR [PREFIX/include] --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] --infodir=DIR info documentation in DIR [PREFIX/info] --mandir=DIR man documentation in DIR [PREFIX/man] --srcdir=DIR find the sources in DIR [configure dir or ..] --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names EOF cat << EOF Host type: --build=BUILD configure for building on BUILD [BUILD=HOST] --host=HOST configure for HOST [guessed] --target=TARGET configure for TARGET [TARGET=HOST] Features and packages: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR EOF cat <<\EOF --enable and --with options recognized: --disable-echo display "compiling" commands --with-man-section=XXX change manpage section (default 3) --with-curses-dir=DIR directory in which (n)curses is installed --with-warnings test: turn on gcc warnings --with-libtool generate libraries with libtool --with-dbmalloc use Conor Cahill's dbmalloc library --with-dmalloc use Gray Watson's dmalloc library --with-ncurses compile/link with ncurses library --with-ncursesw compile/line with wide-character ncurses --with-pdcurses compile/link with pdcurses X11 library --with-x use the X Window System --with-Xaw3d link with Xaw 3d library --with-neXtaw link with neXT Athena library EOF cat <<\EOF --with-XawPlus link with Athena-Plus library --disable-leaks test: suppress permanent memory-leaks EOF exit 0 ;; -host | --host | --hos | --ho) ac_prev=host ;; -host=* | --host=* | --hos=* | --ho=*) host="$ac_optarg" ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir="$ac_optarg" ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir="$ac_optarg" ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir="$ac_optarg" ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir="$ac_optarg" ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir="$ac_optarg" ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir="$ac_optarg" ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir="$ac_optarg" ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix="$ac_optarg" ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix="$ac_optarg" ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix="$ac_optarg" ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name="$ac_optarg" ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir="$ac_optarg" ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir="$ac_optarg" ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site="$ac_optarg" ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir="$ac_optarg" ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir="$ac_optarg" ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target="$ac_optarg" ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers) echo "configure generated by autoconf version 2.13.20030927" exit 0 ;; -with-* | --with-*) ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "with_${ac_package}='$ac_optarg'" ;; -without-* | --without-*) ac_package=`echo $ac_option|sed -e 's/-*without-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` eval "with_${ac_package}=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes="$ac_optarg" ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries="$ac_optarg" ;; -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } ;; *) if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then echo "configure: warning: $ac_option: invalid host type" 1>&2 fi if test "x$nonopt" != xNONE; then { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } fi nonopt="$ac_option" ;; esac done if test -n "$ac_prev"; then { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } fi trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 # File descriptor usage: # 0 standard input # 1 file creation # 2 errors and warnings # 3 some systems may open it to /dev/tty # 4 used on the Kubota Titan # 6 checking for... messages and results # 5 compiler messages saved in config.log if test "$silent" = yes; then exec 6>/dev/null else exec 6>&1 fi exec 5>./config.log echo "\ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. " 1>&5 # Strip out --no-create and --no-recursion so they do not pile up. # Also quote any args containing shell metacharacters. ac_configure_args= for ac_arg do case "$ac_arg" in -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) ac_configure_args="$ac_configure_args '$ac_arg'" ;; *) ac_configure_args="$ac_configure_args $ac_arg" ;; esac done # NLS nuisances. # Only set these to C if already set. These must not be set unconditionally # because not all systems understand e.g. LANG=C (notably SCO). # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! # Non-C LC_CTYPE values break the ctype check. if test "${LANG+set}" = set; then LANG=C; export LANG; fi if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo > confdefs.h # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. ac_unique_file=include/cdk.h # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_prog=$0 ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } else { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } fi fi srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then echo "loading site script $ac_site_file" . "$ac_site_file" fi done if test -r "$cache_file"; then echo "loading cache $cache_file" . $cache_file else echo "creating cache $cache_file" > $cache_file fi ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross ac_exeext= ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then ac_n= ac_c=' ' ac_t=' ' else ac_n=-n ac_c= ac_t= fi else ac_n= ac_c='\c' ac_t= fi # If we find X, set shell vars x_includes and x_libraries to the # paths, otherwise set no_x=yes. # Uses ac_ vars as temps to allow command line to override cache and checks. # --without-x overrides everything else, but does not touch the cache. echo $ac_n "checking for X""... $ac_c" 1>&6 echo "configure:546: checking for X" >&5 # Check whether --with-x or --without-x was given. if test "${with_x+set}" = set; then withval="$with_x" : fi # $have_x is `yes', `no', `disabled', or empty when we do not yet know. if test "x$with_x" = xno; then # The user explicitly disabled X. have_x=disabled else if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then # Both variables are already set. have_x=yes else if eval "test \"`echo '$''{'ac_cv_have_x'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # One or both of the vars are not set, and there is no cached value. ac_x_includes=NO ac_x_libraries=NO rm -fr conftestdir if mkdir conftestdir; then cd conftestdir # Make sure to not put "make" in the Imakefile rules, since we grep it out. cat > Imakefile <<'EOF' acfindx: @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"' EOF if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then # GNU make sometimes prints "make[1]: Entering...", which would confuse us. eval `${MAKE-make} acfindx 2>/dev/null | grep -v make` # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. for ac_extension in a so sl; do if test ! -f $ac_im_usrlibdir/libX11.$ac_extension && test -f $ac_im_libdir/libX11.$ac_extension; then ac_im_usrlibdir=$ac_im_libdir; break fi done # Screen out bogus values from the imake configuration. They are # bogus both because they are the default anyway, and because # using them would break gcc on systems where it needs fixed includes. case "$ac_im_incroot" in /usr/include) ;; *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;; esac case "$ac_im_usrlibdir" in /usr/lib | /lib) ;; *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;; esac fi cd .. rm -fr conftestdir fi if test "$ac_x_includes" = NO; then # Guess where to find include files, by looking for this one X11 .h file. test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h # First, try using that file with no special directory specified. cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:614: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* # We can compile using X headers with no special include directory. ac_x_includes= else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Look for the header file in a standard set of common directories. # Check X11 before X11Rn because it is often a symlink to the current release. for ac_dir in \ /usr/X11/include \ /usr/X11R6/include \ /usr/X11R5/include \ /usr/X11R4/include \ \ /usr/include/X11 \ /usr/include/X11R6 \ /usr/include/X11R5 \ /usr/include/X11R4 \ \ /usr/local/X11/include \ /usr/local/X11R6/include \ /usr/local/X11R5/include \ /usr/local/X11R4/include \ \ /usr/local/include/X11 \ /usr/local/include/X11R6 \ /usr/local/include/X11R5 \ /usr/local/include/X11R4 \ \ /usr/X386/include \ /usr/x386/include \ /usr/XFree86/include/X11 \ \ /usr/include \ /usr/local/include \ /usr/unsupported/include \ /usr/athena/include \ /usr/local/x11r5/include \ /usr/lpp/Xamples/include \ \ /usr/openwin/include \ /usr/openwin/share/include \ ; \ do if test -r "$ac_dir/$x_direct_test_include"; then ac_x_includes=$ac_dir break fi done fi rm -f conftest* fi # $ac_x_includes = NO if test "$ac_x_libraries" = NO; then # Check for the libraries. test -z "$x_direct_test_library" && x_direct_test_library=Xt test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS="$LIBS" LIBS="-l$x_direct_test_library $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* LIBS="$ac_save_LIBS" # We can link X programs with no special library path. ac_x_libraries= else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* LIBS="$ac_save_LIBS" # First see if replacing the include by lib works. # Check X11 before X11Rn because it is often a symlink to the current release. for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \ /usr/X11/lib \ /usr/X11R6/lib \ /usr/X11R5/lib \ /usr/X11R4/lib \ \ /usr/lib/X11 \ /usr/lib/X11R6 \ /usr/lib/X11R5 \ /usr/lib/X11R4 \ \ /usr/local/X11/lib \ /usr/local/X11R6/lib \ /usr/local/X11R5/lib \ /usr/local/X11R4/lib \ \ /usr/local/lib/X11 \ /usr/local/lib/X11R6 \ /usr/local/lib/X11R5 \ /usr/local/lib/X11R4 \ \ /usr/X386/lib \ /usr/x386/lib \ /usr/XFree86/lib/X11 \ \ /usr/lib \ /usr/local/lib \ /usr/unsupported/lib \ /usr/athena/lib \ /usr/local/x11r5/lib \ /usr/lpp/Xamples/lib \ /lib/usr/lib/X11 \ \ /usr/openwin/lib \ /usr/openwin/share/lib \ ; \ do for ac_extension in a so sl; do if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then ac_x_libraries=$ac_dir break 2 fi done done fi rm -f conftest* fi # $ac_x_libraries = NO if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then # Didn't find X anywhere. Cache the known absence of X. ac_cv_have_x="have_x=no" else # Record where we found X for the cache. ac_cv_have_x="have_x=yes \ ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries" fi fi fi eval "$ac_cv_have_x" fi # $with_x != no if test "$have_x" != yes; then echo "$ac_t""$have_x" 1>&6 no_x=yes else # If each of the values was on the command line, it overrides each guess. test "x$x_includes" = xNONE && x_includes=$ac_x_includes test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries # Update the cache value to reflect the command line values. ac_cv_have_x="have_x=yes \ ac_x_includes=$x_includes ac_x_libraries=$x_libraries" echo "$ac_t""libraries $x_libraries, headers $x_includes" 1>&6 fi ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f $ac_dir/install.sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break fi done if test -z "$ac_aux_dir"; then { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } fi ac_config_guess=$ac_aux_dir/config.guess ac_config_sub=$ac_aux_dir/config.sub ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then # Make sure we can run config.sub. if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 echo "configure:807: checking host system type" >&5 host_alias=$host case "$host_alias" in NONE) case $nonopt in NONE) if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } fi ;; *) host_alias=$nonopt ;; esac ;; esac host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 system_name="$host_os" else system_name="`(uname -s -r) 2>/dev/null`" if test -z "$system_name" ; then system_name="`(hostname) 2>/dev/null`" fi fi test -n "$system_name" && cat >> confdefs.h <&6 else cf_cv_system_name="$system_name" fi test -z "$system_name" && system_name="$cf_cv_system_name" test -n "$cf_cv_system_name" && echo "$ac_t""Configuring for $cf_cv_system_name" 1>&6 if test ".$system_name" != ".$cf_cv_system_name" ; then echo "$ac_t""Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" 1>&6 { echo "configure: error: "Please remove config.cache and try again."" 1>&2; exit 1; } fi if test -f $srcdir/VERSION ; then echo $ac_n "checking for package version""... $ac_c" 1>&6 echo "configure:856: checking for package version" >&5 # if there are not enough fields, cut returns the last one... cf_field1=`sed -e '2,$d' $srcdir/VERSION|cut -f1` cf_field2=`sed -e '2,$d' $srcdir/VERSION|cut -f2` cf_field3=`sed -e '2,$d' $srcdir/VERSION|cut -f3` # this is how CF_BUNDLED_INTL uses $VERSION: VERSION="$cf_field1" VERSION_MAJOR=`echo "$cf_field2" | sed -e 's/\..*//'` test -z "$VERSION_MAJOR" && { echo "configure: error: missing major-version" 1>&2; exit 1; } VERSION_MINOR=`echo "$cf_field2" | sed -e 's/^[^.]*\.//' -e 's/-.*//'` test -z "$VERSION_MINOR" && { echo "configure: error: missing minor-version" 1>&2; exit 1; } echo "$ac_t""${VERSION_MAJOR}.${VERSION_MINOR}" 1>&6 echo $ac_n "checking for package patch date""... $ac_c" 1>&6 echo "configure:875: checking for package patch date" >&5 VERSION_PATCH=`echo "$cf_field3" | sed -e 's/^[^-]*-//'` case .$VERSION_PATCH in .) { echo "configure: error: missing patch-date $VERSION_PATCH" 1>&2; exit 1; } ;; .[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]) ;; *) { echo "configure: error: illegal patch-date $VERSION_PATCH" 1>&2; exit 1; } ;; esac echo "$ac_t""$VERSION_PATCH" 1>&6 else { echo "configure: error: did not find $srcdir/VERSION" 1>&2; exit 1; } fi # show the actual data that we have for versions: test -n "$verbose" && echo " VERSION $VERSION" 1>&6 test -n "$verbose" && echo " VERSION_MAJOR $VERSION_MAJOR" 1>&6 test -n "$verbose" && echo " VERSION_MINOR $VERSION_MINOR" 1>&6 test -n "$verbose" && echo " VERSION_PATCH $VERSION_PATCH" 1>&6 PACKAGE=cdk cat >> confdefs.h <> confdefs.h <> confdefs.h <&6 echo "configure:931: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:961: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" break fi done IFS="$ac_save_ifs" if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# -gt 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift set dummy "$ac_dir/$ac_word" "$@" shift ac_cv_prog_CC="$@" fi fi fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then case "`uname -s`" in *win32* | *WIN32*) # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:1012: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="cl" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi ;; esac fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 echo "configure:1044: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF #line 1055 "configure" #include "confdefs.h" main(){return(0);} EOF if { (eval echo configure:1060: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then ac_cv_prog_cc_cross=no else ac_cv_prog_cc_cross=yes fi else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_prog_cc_works=no fi rm -fr conftest* ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 echo "configure:1086: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 echo "configure:1091: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no fi fi echo "$ac_t""$ac_cv_prog_gcc" 1>&6 if test $ac_cv_prog_gcc = yes; then GCC=yes else GCC= fi ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 echo "configure:1119: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then ac_cv_prog_cc_g=yes else ac_cv_prog_cc_g=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 echo "configure:1151: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # This must be in double quotes, not single quotes, because CPP may get # substituted into the Makefile and "${CC-cc}" will confuse make. CPP="${CC-cc} -E" # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1172: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1189: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1206: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP=/lib/cpp fi rm -f conftest* fi rm -f conftest* fi rm -f conftest* ac_cv_prog_CPP="$CPP" fi CPP="$ac_cv_prog_CPP" else ac_cv_prog_CPP="$CPP" fi echo "$ac_t""$CPP" 1>&6 if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 echo "configure:1232: checking whether ${CC-cc} needs -traditional" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_pattern="Autoconf.*'x'" cat > conftest.$ac_ext < Autoconf TIOCGETP EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "$ac_pattern" >/dev/null 2>&1; then rm -rf conftest* ac_cv_prog_gcc_traditional=yes else rm -rf conftest* ac_cv_prog_gcc_traditional=no fi rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext < Autoconf TCGETA EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "$ac_pattern" >/dev/null 2>&1; then rm -rf conftest* ac_cv_prog_gcc_traditional=yes fi rm -f conftest* fi fi echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6 if test $ac_cv_prog_gcc_traditional = yes; then CC="$CC -traditional" fi fi # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:1280: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_RANLIB="ranlib" break fi done IFS="$ac_save_ifs" test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" fi fi RANLIB="$ac_cv_prog_RANLIB" if test -n "$RANLIB"; then echo "$ac_t""$RANLIB" 1>&6 else echo "$ac_t""no" 1>&6 fi # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 echo "configure:1319: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 fi fi done ;; esac done IFS="$ac_save_IFS" fi if test "${ac_cv_path_install+set}" = set; then INSTALL="$ac_cv_path_install" else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL="$ac_install_sh" fi fi echo "$ac_t""$INSTALL" 1>&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking build system type""... $ac_c" 1>&6 echo "configure:1373: checking build system type" >&5 build_alias=$build case "$build_alias" in NONE) case $nonopt in NONE) build_alias=$host_alias ;; *) build_alias=$nonopt ;; esac ;; esac build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$build" 1>&6 if test $host != $build; then ac_tool_prefix=${host_alias}- else ac_tool_prefix= fi # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:1399: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_AR="${ac_tool_prefix}ar" break fi done IFS="$ac_save_ifs" fi fi AR="$ac_cv_prog_AR" if test -n "$AR"; then echo "$ac_t""$AR" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$ac_cv_prog_AR"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:1431: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_AR="ar" break fi done IFS="$ac_save_ifs" test -z "$ac_cv_prog_AR" && ac_cv_prog_AR="ar" fi fi AR="$ac_cv_prog_AR" if test -n "$AR"; then echo "$ac_t""$AR" 1>&6 else echo "$ac_t""no" 1>&6 fi else AR="ar" fi fi echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 echo "configure:1465: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftestmake <<\EOF all: @echo 'ac_maketemp="${MAKE}"' EOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` if test -n "$ac_maketemp"; then eval ac_cv_prog_make_${ac_make}_set=yes else eval ac_cv_prog_make_${ac_make}_set=no fi rm -f conftestmake fi if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then echo "$ac_t""yes" 1>&6 SET_MAKE= else echo "$ac_t""no" 1>&6 SET_MAKE="MAKE=${MAKE-make}" fi echo $ac_n "checking for makeflags variable""... $ac_c" 1>&6 echo "configure:1493: checking for makeflags variable" >&5 if eval "test \"`echo '$''{'cf_cv_makeflags'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cf_cv_makeflags='' for cf_option in '-$(MAKEFLAGS)' '$(MFLAGS)' do cat >cf_makeflags.tmp </dev/null` case "$cf_result" in .*k) cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null` case "$cf_result" in .*CC=*) cf_cv_makeflags= ;; *) cf_cv_makeflags=$cf_option ;; esac break ;; *) echo no match "$cf_result" ;; esac done rm -f cf_makeflags.tmp fi echo "$ac_t""$cf_cv_makeflags" 1>&6 echo $ac_n "checking if filesystem supports mixed-case filenames""... $ac_c" 1>&6 echo "configure:1532: checking if filesystem supports mixed-case filenames" >&5 if eval "test \"`echo '$''{'cf_cv_mixedcase'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes ; then case $target_alias in #(vi *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi cf_cv_mixedcase=no ;; *) cf_cv_mixedcase=yes ;; esac else rm -f conftest CONFTEST echo test >conftest if test -f CONFTEST ; then cf_cv_mixedcase=no else cf_cv_mixedcase=yes fi rm -f conftest CONFTEST fi fi echo "$ac_t""$cf_cv_mixedcase" 1>&6 test "$cf_cv_mixedcase" = yes && cat >> confdefs.h <<\EOF #define MIXEDCASE_FILENAMES 1 EOF # Extract the first word of "ctags", so it can be a program name with args. set dummy ctags; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:1570: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_MAKE_LOWER_TAGS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$MAKE_LOWER_TAGS"; then ac_cv_prog_MAKE_LOWER_TAGS="$MAKE_LOWER_TAGS" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_MAKE_LOWER_TAGS="yes" break fi done IFS="$ac_save_ifs" test -z "$ac_cv_prog_MAKE_LOWER_TAGS" && ac_cv_prog_MAKE_LOWER_TAGS="no" fi fi MAKE_LOWER_TAGS="$ac_cv_prog_MAKE_LOWER_TAGS" if test -n "$MAKE_LOWER_TAGS"; then echo "$ac_t""$MAKE_LOWER_TAGS" 1>&6 else echo "$ac_t""no" 1>&6 fi if test "$cf_cv_mixedcase" = yes ; then # Extract the first word of "etags", so it can be a program name with args. set dummy etags; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:1602: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_MAKE_UPPER_TAGS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$MAKE_UPPER_TAGS"; then ac_cv_prog_MAKE_UPPER_TAGS="$MAKE_UPPER_TAGS" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_MAKE_UPPER_TAGS="yes" break fi done IFS="$ac_save_ifs" test -z "$ac_cv_prog_MAKE_UPPER_TAGS" && ac_cv_prog_MAKE_UPPER_TAGS="no" fi fi MAKE_UPPER_TAGS="$ac_cv_prog_MAKE_UPPER_TAGS" if test -n "$MAKE_UPPER_TAGS"; then echo "$ac_t""$MAKE_UPPER_TAGS" 1>&6 else echo "$ac_t""no" 1>&6 fi else MAKE_UPPER_TAGS=no fi if test "$MAKE_UPPER_TAGS" = yes ; then MAKE_UPPER_TAGS= else MAKE_UPPER_TAGS="#" fi if test "$MAKE_LOWER_TAGS" = yes ; then MAKE_LOWER_TAGS= else MAKE_LOWER_TAGS="#" fi echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6 echo "configure:1650: checking for ${CC-cc} option to accept ANSI C" >&5 if eval "test \"`echo '$''{'cf_cv_ansi_cc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cf_cv_ansi_cc=no cf_save_CFLAGS="$CFLAGS" cf_save_CPPFLAGS="$CPPFLAGS" # Don't try gcc -ansi; that turns off useful extensions and # breaks some systems' header files. # AIX -qlanglvl=ansi # Ultrix and OSF/1 -std1 # HP-UX -Aa -D_HPUX_SOURCE # SVR4 -Xc # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes) for cf_arg in "-DCC_HAS_PROTOS" \ "" \ -qlanglvl=ansi \ -std1 \ -Ae \ "-Aa -D_HPUX_SOURCE" \ -Xc do cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in $cf_arg do case $cf_fix_cppflags in no) case $cf_add_cflags in #(vi -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi case $cf_add_cflags in -D*) cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'` test "${cf_add_cflags}" != "${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test $cf_fix_cppflags = yes ; then cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" continue elif test "${cf_tst_cflags}" = "\"'" ; then cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" continue fi ;; esac case "$CPPFLAGS" in *$cf_add_cflags) #(vi ;; *) #(vi cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" ;; esac ;; *) cf_new_cflags="$cf_new_cflags $cf_add_cflags" ;; esac ;; yes) cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` test "${cf_add_cflags}" != "${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then CFLAGS="$CFLAGS $cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then CPPFLAGS="$cf_new_cppflags $CPPFLAGS" fi if test -n "$cf_new_extra_cppflags" ; then EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" fi cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_ansi_cc="$cf_arg"; break else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* done CFLAGS="$cf_save_CFLAGS" CPPFLAGS="$cf_save_CPPFLAGS" fi echo "$ac_t""$cf_cv_ansi_cc" 1>&6 if test "$cf_cv_ansi_cc" != "no"; then if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in $cf_cv_ansi_cc do case $cf_fix_cppflags in no) case $cf_add_cflags in #(vi -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi case $cf_add_cflags in -D*) cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'` test "${cf_add_cflags}" != "${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test $cf_fix_cppflags = yes ; then cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" continue elif test "${cf_tst_cflags}" = "\"'" ; then cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" continue fi ;; esac case "$CPPFLAGS" in *$cf_add_cflags) #(vi ;; *) #(vi cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" ;; esac ;; *) cf_new_cflags="$cf_new_cflags $cf_add_cflags" ;; esac ;; yes) cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` test "${cf_add_cflags}" != "${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then CFLAGS="$CFLAGS $cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then CPPFLAGS="$cf_new_cppflags $CPPFLAGS" fi if test -n "$cf_new_extra_cppflags" ; then EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" fi else cat >> confdefs.h <<\EOF #define CC_HAS_PROTOS 1 EOF fi fi if test "$cf_cv_ansi_cc" = "no"; then { echo "configure: error: Your compiler does not appear to recognize prototypes. You have the following choices: a. adjust your compiler options b. get an up-to-date compiler c. use a wrapper such as unproto" 1>&2; exit 1; } fi echo $ac_n "checking for working const""... $ac_c" 1>&6 echo "configure:1870: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; } ; return 0; } EOF if { (eval echo configure:1924: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_c_const=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_c_const" 1>&6 if test $ac_cv_c_const = no; then cat >> confdefs.h <<\EOF #define const EOF fi echo $ac_n "checking if $CC -U and -D options work together""... $ac_c" 1>&6 echo "configure:1946: checking if $CC -U and -D options work together" >&5 if eval "test \"`echo '$''{'cf_cv_cc_u_d_options'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cf_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS" cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_cc_u_d_options=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_cv_cc_u_d_options=no fi rm -f conftest* CPPFLAGS="$cf_save_CPPFLAGS" fi echo "$ac_t""$cf_cv_cc_u_d_options" 1>&6 cf_XOPEN_SOURCE=500 cf_POSIX_C_SOURCE=199506L case $host_os in #(vi aix[45]*) #(vi CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE" ;; freebsd*) #(vi # 5.x headers associate # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L cf_POSIX_C_SOURCE=200112L cf_XOPEN_SOURCE=600 CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" ;; hpux*) #(vi CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE" ;; irix[56].*) #(vi CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE" ;; linux*|gnu*) #(vi echo $ac_n "checking if we must define _GNU_SOURCE""... $ac_c" 1>&6 echo "configure:2014: checking if we must define _GNU_SOURCE" >&5 if eval "test \"`echo '$''{'cf_cv_gnu_source'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { #ifndef _XOPEN_SOURCE make an error #endif ; return 0; } EOF if { (eval echo configure:2030: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_gnu_source=no else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_save="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" cat > conftest.$ac_ext < int main() { #ifdef _XOPEN_SOURCE make an error #endif ; return 0; } EOF if { (eval echo configure:2050: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_gnu_source=no else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_cv_gnu_source=yes fi rm -f conftest* CPPFLAGS="$cf_save" fi rm -f conftest* fi echo "$ac_t""$cf_cv_gnu_source" 1>&6 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" ;; mirbsd*) #(vi # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks ;; netbsd*) #(vi # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw ;; openbsd*) #(vi # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw ;; osf[45]*) #(vi CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE" ;; nto-qnx*) #(vi CPPFLAGS="$CPPFLAGS -D_QNX_SOURCE" ;; sco*) #(vi # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer ;; solaris*) #(vi CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__" ;; *) echo $ac_n "checking if we should define _XOPEN_SOURCE""... $ac_c" 1>&6 echo "configure:2094: checking if we should define _XOPEN_SOURCE" >&5 if eval "test \"`echo '$''{'cf_cv_xopen_source'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { #ifndef _XOPEN_SOURCE make an error #endif ; return 0; } EOF if { (eval echo configure:2110: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_xopen_source=no else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_save="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" cat > conftest.$ac_ext < int main() { #ifdef _XOPEN_SOURCE make an error #endif ; return 0; } EOF if { (eval echo configure:2130: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_xopen_source=no else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_cv_xopen_source=$cf_XOPEN_SOURCE fi rm -f conftest* CPPFLAGS="$cf_save" fi rm -f conftest* fi echo "$ac_t""$cf_cv_xopen_source" 1>&6 if test "$cf_cv_xopen_source" != no ; then # remove _XOPEN_SOURCE symbol from $CFLAGS CFLAGS=`echo "$CFLAGS" | \ sed -e 's/-[UD]_XOPEN_SOURCE\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]_XOPEN_SOURCE\(=[^ ]*\)\?$//g'` # remove _XOPEN_SOURCE symbol from $CPPFLAGS CPPFLAGS=`echo "$CPPFLAGS" | \ sed -e 's/-[UD]_XOPEN_SOURCE\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]_XOPEN_SOURCE\(=[^ ]*\)\?$//g'` test "$cf_cv_cc_u_d_options" = yes && \ CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE" CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_cv_xopen_source" fi cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE cf_save_CFLAGS="$CFLAGS" cf_save_CPPFLAGS="$CPPFLAGS" # remove _POSIX_C_SOURCE symbol from $cf_save_CFLAGS cf_trim_CFLAGS=`echo "$cf_save_CFLAGS" | \ sed -e 's/-[UD]_POSIX_C_SOURCE\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]_POSIX_C_SOURCE\(=[^ ]*\)\?$//g'` # remove _POSIX_C_SOURCE symbol from $cf_save_CPPFLAGS cf_trim_CPPFLAGS=`echo "$cf_save_CPPFLAGS" | \ sed -e 's/-[UD]_POSIX_C_SOURCE\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]_POSIX_C_SOURCE\(=[^ ]*\)\?$//g'` echo $ac_n "checking if we should define _POSIX_C_SOURCE""... $ac_c" 1>&6 echo "configure:2185: checking if we should define _POSIX_C_SOURCE" >&5 if eval "test \"`echo '$''{'cf_cv_posix_c_source'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo "(line 2191) testing if the symbol is already defined go no further ..." 1>&5 cat > conftest.$ac_ext < int main() { #ifndef _POSIX_C_SOURCE make an error #endif ; return 0; } EOF if { (eval echo configure:2204: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_posix_c_source=no else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_want_posix_source=no case .$cf_POSIX_C_SOURCE in #(vi .[12]??*) #(vi cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE" ;; .2) #(vi cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE" cf_want_posix_source=yes ;; .*) cf_want_posix_source=yes ;; esac if test "$cf_want_posix_source" = yes ; then cat > conftest.$ac_ext < int main() { #ifdef _POSIX_SOURCE make an error #endif ; return 0; } EOF if { (eval echo configure:2236: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE" fi rm -f conftest* fi echo "(line 2247) testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 CFLAGS="$cf_trim_CFLAGS" CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source" echo "(line 2252) testing if the second compile does not leave our definition intact error ..." 1>&5 cat > conftest.$ac_ext < int main() { #ifndef _POSIX_C_SOURCE make an error #endif ; return 0; } EOF if { (eval echo configure:2265: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_cv_posix_c_source=no fi rm -f conftest* CFLAGS="$cf_save_CFLAGS" CPPFLAGS="$cf_save_CPPFLAGS" fi rm -f conftest* fi echo "$ac_t""$cf_cv_posix_c_source" 1>&6 if test "$cf_cv_posix_c_source" != no ; then CFLAGS="$cf_trim_CFLAGS" CPPFLAGS="$cf_trim_CPPFLAGS" if test "$cf_cv_cc_u_d_options" = yes ; then cf_temp_posix_c_source=`echo "$cf_cv_posix_c_source" | \ sed -e 's/-D/-U/g' -e 's/=[^ ]*//g'` CPPFLAGS="$CPPFLAGS $cf_temp_posix_c_source" fi CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source" fi ;; esac echo $ac_n "checking if you want to see long compiling messages""... $ac_c" 1>&6 echo "configure:2302: checking if you want to see long compiling messages" >&5 # Check whether --enable-echo or --disable-echo was given. if test "${enable_echo+set}" = set; then enableval="$enable_echo" test "$enableval" != no && enableval=yes if test "$enableval" != "yes" ; then ECHO_LT='--silent' ECHO_LD='@echo linking $@;' RULE_CC=' @echo compiling $<' SHOW_CC=' @echo compiling $@' ECHO_CC='@' else ECHO_LT='' ECHO_LD='' RULE_CC='# compiling' SHOW_CC='# compiling' ECHO_CC='' fi else enableval=yes ECHO_LT='' ECHO_LD='' RULE_CC='# compiling' SHOW_CC='# compiling' ECHO_CC='' fi echo "$ac_t""$enableval" 1>&6 echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 echo "configure:2345: checking for Cygwin environment" >&5 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_cygwin=no fi rm -f conftest* rm -f conftest* fi echo "$ac_t""$ac_cv_cygwin" 1>&6 CYGWIN= test "$ac_cv_cygwin" = yes && CYGWIN=yes echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 echo "configure:2378: checking for mingw32 environment" >&5 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_mingw32=no fi rm -f conftest* rm -f conftest* fi echo "$ac_t""$ac_cv_mingw32" 1>&6 MINGW32= test "$ac_cv_mingw32" = yes && MINGW32=yes case $cf_cv_system_name in os2*) CFLAGS="$CFLAGS -Zmt" CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__" CXXFLAGS="$CXXFLAGS -Zmt" # autoconf's macro sets -Zexe and suffix both, which conflict:w LDFLAGS="$LDFLAGS -Zmt -Zcrtdll" ac_cv_exeext=.exe ;; esac echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 echo "configure:2422: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$CYGWIN" = yes || test "$MINGW32" = yes; then ac_cv_exeext=.exe else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= if { (eval echo configure:2432: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.o | *.obj) ;; *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;; esac done else { echo "configure: error: installation or configuration problem: compiler cannot create executables." 1>&2; exit 1; } fi rm -f conftest* test x"${ac_cv_exeext}" = x && ac_cv_exeext=no fi fi EXEEXT="" test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext} echo "$ac_t""${ac_cv_exeext}" 1>&6 ac_exeext=$EXEEXT echo $ac_n "checking for object suffix""... $ac_c" 1>&6 echo "configure:2453: checking for object suffix" >&5 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftest* echo 'int i = 1;' > conftest.$ac_ext if { (eval echo configure:2459: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then for ac_file in conftest.*; do case $ac_file in *.c) ;; *) ac_cv_objext=`echo $ac_file | sed -e s/conftest.//` ;; esac done else { echo "configure: error: installation or configuration problem; compiler does not work" 1>&2; exit 1; } fi rm -f conftest* fi echo "$ac_t""$ac_cv_objext" 1>&6 OBJEXT=$ac_cv_objext ac_objext=$ac_cv_objext PROG_EXT="$EXEEXT" test -n "$PROG_EXT" && cat >> confdefs.h <&2; exit 1; } ;; esac cf_cv_curses_dir=$withval else cf_cv_curses_dir=no fi GCC_VERSION=none if test "$GCC" = yes ; then echo $ac_n "checking version of $CC""... $ac_c" 1>&6 echo "configure:2552: checking version of $CC" >&5 GCC_VERSION="`${CC} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`" test -z "$GCC_VERSION" && GCC_VERSION=unknown echo "$ac_t""$GCC_VERSION" 1>&6 fi if ( test "$GCC" = yes || test "$GXX" = yes ) then echo $ac_n "checking if you want to check for gcc warnings""... $ac_c" 1>&6 echo "configure:2562: checking if you want to check for gcc warnings" >&5 # Check whether --with-warnings or --without-warnings was given. if test "${with_warnings+set}" = set; then withval="$with_warnings" cf_opt_with_warnings=$withval else cf_opt_with_warnings=no fi echo "$ac_t""$cf_opt_with_warnings" 1>&6 if test "$cf_opt_with_warnings" != no ; then if test "$GCC" = yes then cat > conftest.i <&6 echo "configure:2594: checking for $CC __attribute__ directives" >&5 cat > conftest.$ac_ext <&5 case $cf_attribute in scanf|printf) cat >conftest.h <conftest.h <&5; (eval $ac_compile) 2>&5; }; then test -n "$verbose" && echo "$ac_t""... $cf_attribute" 1>&6 cat conftest.h >>confdefs.h fi done else fgrep define conftest.i >>confdefs.h fi rm -rf conftest* fi INTEL_COMPILER=no if test "$GCC" = yes ; then case $host_os in linux*|gnu*) echo $ac_n "checking if this is really Intel C compiler""... $ac_c" 1>&6 echo "configure:2654: checking if this is really Intel C compiler" >&5 cf_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -no-gcc" cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* INTEL_COMPILER=yes cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* CFLAGS="$cf_save_CFLAGS" echo "$ac_t""$INTEL_COMPILER" 1>&6 ;; esac fi cat > conftest.$ac_ext <&6 echo "configure:2707: checking for $CC warning options" >&5 cf_save_CFLAGS="$CFLAGS" EXTRA_CFLAGS="-Wall" for cf_opt in \ wd1419 \ wd1682 \ wd1683 \ wd1684 \ wd193 \ wd279 \ wd593 \ wd810 \ wd869 \ wd981 do CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt" if { (eval echo configure:2723: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then test -n "$verbose" && echo "$ac_t""... -$cf_opt" 1>&6 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt" fi done CFLAGS="$cf_save_CFLAGS" elif test "$GCC" = yes then echo "checking for $CC warning options" 1>&6 echo "configure:2733: checking for $CC warning options" >&5 cf_save_CFLAGS="$CFLAGS" EXTRA_CFLAGS="-W -Wall" cf_warn_CONST="" test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings" for cf_opt in \ Wbad-function-cast \ Wcast-align \ Wcast-qual \ Winline \ Wmissing-declarations \ Wmissing-prototypes \ Wnested-externs \ Wpointer-arith \ Wshadow \ Wstrict-prototypes \ Wundef $cf_warn_CONST do CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt" if { (eval echo configure:2752: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then test -n "$verbose" && echo "$ac_t""... -$cf_opt" 1>&6 case $cf_opt in #(vi Wcast-qual) #(vi CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES" ;; Winline) #(vi case $GCC_VERSION in 3.3*) test -n "$verbose" && echo " feature is broken in gcc $GCC_VERSION" 1>&6 continue;; esac ;; esac EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt" fi done CFLAGS="$cf_save_CFLAGS" fi rm -f conftest* fi fi LIBTOOL= # common library maintenance symbols that are convenient for libtool scripts: LIB_CREATE='$(AR) -cr' LIB_OBJECT='$(OBJECTS)' LIB_SUFFIX=.a LIB_PREP="$RANLIB" # symbols used to prop libtool up to enable it to determine what it should be # doing: LIB_CLEAN= LIB_COMPILE= LIB_LINK= LIB_INSTALL= LIB_UNINSTALL= echo $ac_n "checking if you want to build libraries with libtool""... $ac_c" 1>&6 echo "configure:2798: checking if you want to build libraries with libtool" >&5 # Check whether --with-libtool or --without-libtool was given. if test "${with_libtool+set}" = set; then withval="$with_libtool" with_libtool=$withval else with_libtool=no fi echo "$ac_t""$with_libtool" 1>&6 if test "$with_libtool" != "no"; then if test "$with_libtool" != "yes" ; then case ".$with_libtool" in #(vi .\$\(*\)*|.\'*\'*) #(vi ;; ..|./*|.\\*) #(vi ;; .[a-zA-Z]:[\\/]*) #(vi OS/2 EMX ;; .\${*prefix}*) #(vi eval with_libtool="$with_libtool" case ".$with_libtool" in #(vi .NONE/*) with_libtool=`echo $with_libtool | sed -e s%NONE%$ac_default_prefix%` ;; esac ;; #(vi .NONE/*) with_libtool=`echo $with_libtool | sed -e s%NONE%$ac_default_prefix%` ;; *) { echo "configure: error: expected a pathname, not \"$with_libtool\"" 1>&2; exit 1; } ;; esac LIBTOOL=$with_libtool else # Extract the first word of "libtool", so it can be a program name with args. set dummy libtool; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:2841: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_LIBTOOL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else case "$LIBTOOL" in /*) ac_cv_path_LIBTOOL="$LIBTOOL" # Let the user override the test with a path. ;; ?:/*) ac_cv_path_LIBTOOL="$LIBTOOL" # Let the user override the test with a dos path. ;; *) IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_path_LIBTOOL="$ac_dir/$ac_word" break fi done IFS="$ac_save_ifs" ;; esac fi LIBTOOL="$ac_cv_path_LIBTOOL" if test -n "$LIBTOOL"; then echo "$ac_t""$LIBTOOL" 1>&6 else echo "$ac_t""no" 1>&6 fi fi if test -z "$LIBTOOL" ; then { echo "configure: error: Cannot find libtool" 1>&2; exit 1; } fi LIB_CREATE='$(LIBTOOL) --mode=link $(CC) -rpath $(DESTDIR)$(libdir) -version-info `cut -f1 $(srcdir)/VERSION` -o' LIB_OBJECT='$(OBJECTS:.o=.lo)' LIB_SUFFIX=.la LIB_CLEAN='$(LIBTOOL) --mode=clean' LIB_COMPILE='$(LIBTOOL) --mode=compile' LIB_LINK='$(LIBTOOL) --mode=link' LIB_INSTALL='$(LIBTOOL) --mode=install' LIB_UNINSTALL='$(LIBTOOL) --mode=uninstall' LIB_PREP=: # Show the version of libtool echo $ac_n "checking version of libtool""... $ac_c" 1>&6 echo "configure:2889: checking version of libtool" >&5 # Save the version in a cache variable - this is not entirely a good # thing, but the version string from libtool is very ugly, and for # bug reports it might be useful to have the original string. cf_cv_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '2,$d' -e 's/([^)]*)//g' -e 's/^[^1-9]*//' -e 's/[^0-9.].*//'` echo "$ac_t""$cf_cv_libtool_version" 1>&6 if test -z "$cf_cv_libtool_version" ; then { echo "configure: error: This is not libtool" 1>&2; exit 1; } fi # special hack to add --tag option for C++ compiler case $cf_cv_libtool_version in 1.[5-9]*|[2-9]*) LIBTOOL_CXX="$LIBTOOL --tag=CXX" ;; *) LIBTOOL_CXX="$LIBTOOL" ;; esac else LIBTOOL="" LIBTOOL_CXX="" fi test -z "$LIBTOOL" && ECHO_LT= if test "$with_libtool" = "yes" ; then OBJEXT="lo" fi echo $ac_n "checking if you want to link with dbmalloc for testing""... $ac_c" 1>&6 echo "configure:2938: checking if you want to link with dbmalloc for testing" >&5 # Check whether --with-dbmalloc or --without-dbmalloc was given. if test "${with_dbmalloc+set}" = set; then withval="$with_dbmalloc" with_dbmalloc=$withval else with_dbmalloc=no fi echo "$ac_t""$with_dbmalloc" 1>&6 if test "$with_dbmalloc" = yes ; then ac_safe=`echo "dbmalloc.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for dbmalloc.h""... $ac_c" 1>&6 echo "configure:2952: checking for dbmalloc.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:2962: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 echo $ac_n "checking for debug_malloc in -ldbmalloc""... $ac_c" 1>&6 echo "configure:2979: checking for debug_malloc in -ldbmalloc" >&5 ac_lib_var=`echo dbmalloc'_'debug_malloc | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-ldbmalloc $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo dbmalloc | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 fi else echo "$ac_t""no" 1>&6 fi fi echo $ac_n "checking if you want to link with dmalloc for testing""... $ac_c" 1>&6 echo "configure:3033: checking if you want to link with dmalloc for testing" >&5 # Check whether --with-dmalloc or --without-dmalloc was given. if test "${with_dmalloc+set}" = set; then withval="$with_dmalloc" with_dmalloc=$withval else with_dmalloc=no fi echo "$ac_t""$with_dmalloc" 1>&6 if test "$with_dmalloc" = yes ; then ac_safe=`echo "dmalloc.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for dmalloc.h""... $ac_c" 1>&6 echo "configure:3047: checking for dmalloc.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:3057: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 echo $ac_n "checking for dmalloc_debug in -ldmalloc""... $ac_c" 1>&6 echo "configure:3074: checking for dmalloc_debug in -ldmalloc" >&5 ac_lib_var=`echo dmalloc'_'dmalloc_debug | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-ldmalloc $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo dmalloc | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 fi else echo "$ac_t""no" 1>&6 fi fi ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 echo "configure:3132: checking for $ac_hdr that defines DIR" >&5 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_hdr> int main() { DIR *dirp = 0; ; return 0; } EOF if { (eval echo configure:3145: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "ac_cv_header_dirent_$ac_safe=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_dirent_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 echo "configure:3170: checking for opendir in -ldir" >&5 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-ldir $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="$LIBS -ldir" else echo "$ac_t""no" 1>&6 fi else echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 echo "configure:3211: checking for opendir in -lx" >&5 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lx $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="$LIBS -lx" else echo "$ac_t""no" 1>&6 fi fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 echo "configure:3253: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include #include #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:3266: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* ac_cv_header_stdc=yes else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "memchr" >/dev/null 2>&1; then : else rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "free" >/dev/null 2>&1; then : else rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF if { (eval echo configure:3333: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* ac_cv_header_stdc=no fi rm -fr conftest* fi fi fi echo "$ac_t""$ac_cv_header_stdc" 1>&6 if test $ac_cv_header_stdc = yes; then cat >> confdefs.h <<\EOF #define STDC_HEADERS 1 EOF fi for ac_hdr in \ limits.h \ unistd.h \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:3363: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:3373: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done echo $ac_n "checking for mode_t""... $ac_c" 1>&6 echo "configure:3401: checking for mode_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS #include #include #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "(^|[^a-zA-Z_0-9])mode_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then rm -rf conftest* ac_cv_type_mode_t=yes else rm -rf conftest* ac_cv_type_mode_t=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_type_mode_t" 1>&6 if test $ac_cv_type_mode_t = no; then cat >> confdefs.h <<\EOF #define mode_t int EOF fi echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 echo "configure:3434: checking whether struct tm is in sys/time.h or time.h" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include int main() { struct tm *tp; tp->tm_sec; ; return 0; } EOF if { (eval echo configure:3447: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm=time.h else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_struct_tm=sys/time.h fi rm -f conftest* fi echo "$ac_t""$ac_cv_struct_tm" 1>&6 if test $ac_cv_struct_tm = sys/time.h; then cat >> confdefs.h <<\EOF #define TM_IN_SYS_TIME 1 EOF fi echo $ac_n "checking for extra include directories""... $ac_c" 1>&6 echo "configure:3470: checking for extra include directories" >&5 if eval "test \"`echo '$''{'cf_cv_curses_incdir'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cf_cv_curses_incdir=no case $host_os in #(vi hpux10.*|hpux11.*) #(vi test -d /usr/include/curses_colr && \ cf_cv_curses_incdir="-I/usr/include/curses_colr" ;; sunos3*|sunos4*) test -d /usr/5lib && \ test -d /usr/5include && \ cf_cv_curses_incdir="-I/usr/5include" ;; esac fi echo "$ac_t""$cf_cv_curses_incdir" 1>&6 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$cf_cv_curses_incdir $CPPFLAGS" echo $ac_n "checking if we have identified curses headers""... $ac_c" 1>&6 echo "configure:3494: checking if we have identified curses headers" >&5 if eval "test \"`echo '$''{'cf_cv_ncurses_header'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cf_cv_ncurses_header=none for cf_header in \ curses.h \ ncurses.h \ ncurses/curses.h \ ncurses/ncurses.h do cat > conftest.$ac_ext < int main() { initscr(); tgoto("?", 0,0) ; return 0; } EOF if { (eval echo configure:3514: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_ncurses_header=$cf_header; break else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* done fi echo "$ac_t""$cf_cv_ncurses_header" 1>&6 if test "$cf_cv_ncurses_header" = none ; then { echo "configure: error: No curses header-files found" 1>&2; exit 1; } fi # cheat, to get the right #define's for HAVE_NCURSES_H, etc. for ac_hdr in $cf_cv_ncurses_header do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:3537: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:3547: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done echo $ac_n "checking for chtype typedef""... $ac_c" 1>&6 echo "configure:3577: checking for chtype typedef" >&5 if eval "test \"`echo '$''{'cf_cv_chtype_decl'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { chtype foo ; return 0; } EOF if { (eval echo configure:3590: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_chtype_decl=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_cv_chtype_decl=no fi rm -f conftest* fi echo "$ac_t""$cf_cv_chtype_decl" 1>&6 if test $cf_cv_chtype_decl = yes ; then cat >> confdefs.h <<\EOF #define HAVE_TYPE_CHTYPE 1 EOF echo $ac_n "checking if chtype is scalar or struct""... $ac_c" 1>&6 echo "configure:3609: checking if chtype is scalar or struct" >&5 if eval "test \"`echo '$''{'cf_cv_chtype_type'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { chtype foo; long x = foo ; return 0; } EOF if { (eval echo configure:3622: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_chtype_type=scalar else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_cv_chtype_type=struct fi rm -f conftest* fi echo "$ac_t""$cf_cv_chtype_type" 1>&6 if test $cf_cv_chtype_type = scalar ; then cat >> confdefs.h <<\EOF #define TYPE_CHTYPE_IS_SCALAR 1 EOF fi fi echo $ac_n "checking for header declaring getopt variables""... $ac_c" 1>&6 echo "configure:3645: checking for header declaring getopt variables" >&5 if eval "test \"`echo '$''{'cf_cv_getopt_header'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cf_cv_getopt_header=none for cf_header in stdio.h stdlib.h getopt.h do cat > conftest.$ac_ext < int main() { int x = optind; char *y = optarg ; return 0; } EOF if { (eval echo configure:3662: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_getopt_header=$cf_header break else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* done fi echo "$ac_t""$cf_cv_getopt_header" 1>&6 case $cf_cv_getopt_header in #(vi getopt.h) #(vi cat >> confdefs.h <<\EOF #define HAVE_GETOPT_H 1 EOF cat >> confdefs.h <<\EOF #define HAVE_GETOPT_HEADER 1 EOF ;; stdlib.h) #(vi cat >> confdefs.h <<\EOF #define HAVE_STDLIB_H 1 EOF cat >> confdefs.h <<\EOF #define HAVE_GETOPT_HEADER 1 EOF ;; esac for ac_func in \ getcwd \ mktime \ strdup \ strerror \ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:3708: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:3736: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 fi done echo $ac_n "checking for lstat""... $ac_c" 1>&6 echo "configure:3763: checking for lstat" >&5 if eval "test \"`echo '$''{'ac_cv_func_lstat'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include int main() { lstat(".", (struct stat *)0) ; return 0; } EOF if { (eval echo configure:3778: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_lstat=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_func_lstat=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_func_lstat " 1>&6 if test $ac_cv_func_lstat = yes; then cat >> confdefs.h <<\EOF #define HAVE_LSTAT 1 EOF fi echo $ac_n "checking for setlocale()""... $ac_c" 1>&6 echo "configure:3801: checking for setlocale()" >&5 if eval "test \"`echo '$''{'cf_cv_locale'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { setlocale(LC_ALL, "") ; return 0; } EOF if { (eval echo configure:3814: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cf_cv_locale=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_cv_locale=no fi rm -f conftest* fi echo "$ac_t""$cf_cv_locale" 1>&6 test $cf_cv_locale = yes && { cat >> confdefs.h <<\EOF #define HAVE_SETLOCALE 1 EOF } use_library=curses # Check whether --with-ncurses or --without-ncurses was given. if test "${with_ncurses+set}" = set; then withval="$with_ncurses" use_library=ncurses else # Check whether --with-ncursesw or --without-ncursesw was given. if test "${with_ncursesw+set}" = set; then withval="$with_ncursesw" use_library=ncursesw else # Check whether --with-pdcurses or --without-pdcurses was given. if test "${with_pdcurses+set}" = set; then withval="$with_pdcurses" use_library=pdcurses fi fi fi LIB_ROOTNAME=cdk case $use_library in #(vi ncurses) #(vi cf_ncuhdr_root=ncurses test -n "$cf_cv_curses_dir" && \ test "$cf_cv_curses_dir" != "no" && \ CPPFLAGS="-I$cf_cv_curses_dir/include -I$cf_cv_curses_dir/include/$cf_ncuhdr_root $CPPFLAGS" echo $ac_n "checking for $cf_ncuhdr_root header in include-path""... $ac_c" 1>&6 echo "configure:3873: checking for $cf_ncuhdr_root header in include-path" >&5 if eval "test \"`echo '$''{'cf_cv_ncurses_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h" ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h" for cf_header in $cf_header_list do cat > conftest.$ac_ext < int main() { #ifdef NCURSES_VERSION printf("%s\n", NCURSES_VERSION); #else #ifdef __NCURSES_H printf("old\n"); #else make an error #endif #endif ; return 0; } EOF if { (eval echo configure:3905: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_ncurses_h=$cf_header else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_cv_ncurses_h=no fi rm -f conftest* test "$cf_cv_ncurses_h" != no && break done fi echo "$ac_t""$cf_cv_ncurses_h" 1>&6 if test "$cf_cv_ncurses_h" != no ; then cf_cv_ncurses_header=$cf_cv_ncurses_h else echo $ac_n "checking for $cf_ncuhdr_root include-path""... $ac_c" 1>&6 echo "configure:3928: checking for $cf_ncuhdr_root include-path" >&5 if eval "test \"`echo '$''{'cf_cv_ncurses_h2'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else test -n "$verbose" && echo cf_search="" test -d $HOME && { test -n "$verbose" && echo " ... testing include-directories under $HOME" test -d $HOME/include && cf_search="$cf_search $HOME/include" test -d $HOME/include/$cf_ncuhdr_root && cf_search="$cf_search $HOME/include/$cf_ncuhdr_root" test -d $HOME/include/$cf_ncuhdr_root/include && cf_search="$cf_search $HOME/include/$cf_ncuhdr_root/include" } # For other stuff under the home directory, it should be sufficient to put # a symbolic link for $HOME/$cf_ncuhdr_root to the actual package location: test -d $HOME/$cf_ncuhdr_root && { test -n "$verbose" && echo " ... testing include-directories under $HOME/$cf_ncuhdr_root" test -d $HOME/$cf_ncuhdr_root/include && cf_search="$cf_search $HOME/$cf_ncuhdr_root/include" test -d $HOME/$cf_ncuhdr_root/include/$cf_ncuhdr_root && cf_search="$cf_search $HOME/$cf_ncuhdr_root/include/$cf_ncuhdr_root" } test "$prefix" != /usr/local && \ test -d /usr/local && { test -n "$verbose" && echo " ... testing include-directories under /usr/local" test -d /usr/local/include && cf_search="$cf_search /usr/local/include" test -d /usr/local/include/$cf_ncuhdr_root && cf_search="$cf_search /usr/local/include/$cf_ncuhdr_root" test -d /usr/local/include/$cf_ncuhdr_root/include && cf_search="$cf_search /usr/local/include/$cf_ncuhdr_root/include" test -d /usr/local/$cf_ncuhdr_root/include && cf_search="$cf_search /usr/local/$cf_ncuhdr_root/include" test -d /usr/local/$cf_ncuhdr_root/include/$cf_ncuhdr_root && cf_search="$cf_search /usr/local/$cf_ncuhdr_root/include/$cf_ncuhdr_root" } test "$prefix" != NONE && \ test -d $prefix && { test -n "$verbose" && echo " ... testing include-directories under $prefix" test -d $prefix/include && cf_search="$cf_search $prefix/include" test -d $prefix/include/$cf_ncuhdr_root && cf_search="$cf_search $prefix/include/$cf_ncuhdr_root" test -d $prefix/include/$cf_ncuhdr_root/include && cf_search="$cf_search $prefix/include/$cf_ncuhdr_root/include" test -d $prefix/$cf_ncuhdr_root/include && cf_search="$cf_search $prefix/$cf_ncuhdr_root/include" test -d $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root && cf_search="$cf_search $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root" } test "$prefix" != /opt && \ test -d /opt && { test -n "$verbose" && echo " ... testing include-directories under /opt" test -d /opt/include && cf_search="$cf_search /opt/include" test -d /opt/include/$cf_ncuhdr_root && cf_search="$cf_search /opt/include/$cf_ncuhdr_root" test -d /opt/include/$cf_ncuhdr_root/include && cf_search="$cf_search /opt/include/$cf_ncuhdr_root/include" test -d /opt/$cf_ncuhdr_root/include && cf_search="$cf_search /opt/$cf_ncuhdr_root/include" test -d /opt/$cf_ncuhdr_root/include/$cf_ncuhdr_root && cf_search="$cf_search /opt/$cf_ncuhdr_root/include/$cf_ncuhdr_root" } test "$prefix" != /usr && \ test -d /usr && { test -n "$verbose" && echo " ... testing include-directories under /usr" test -d /usr/include && cf_search="$cf_search /usr/include" test -d /usr/include/$cf_ncuhdr_root && cf_search="$cf_search /usr/include/$cf_ncuhdr_root" test -d /usr/include/$cf_ncuhdr_root/include && cf_search="$cf_search /usr/include/$cf_ncuhdr_root/include" test -d /usr/$cf_ncuhdr_root/include && cf_search="$cf_search /usr/$cf_ncuhdr_root/include" } test "$includedir" != NONE && \ test "$includedir" != "/usr/include" && \ test -d "$includedir" && { test -d $includedir && cf_search="$cf_search $includedir" test -d $includedir/$cf_ncuhdr_root && cf_search="$cf_search $includedir/$cf_ncuhdr_root" } test "$oldincludedir" != NONE && \ test "$oldincludedir" != "/usr/include" && \ test -d "$oldincludedir" && { test -d $oldincludedir && cf_search="$cf_search $oldincludedir" test -d $oldincludedir/$cf_ncuhdr_root && cf_search="$cf_search $oldincludedir/$cf_ncuhdr_root" } test -n "$verbose" && echo search path $cf_search cf_save2_CPPFLAGS="$CPPFLAGS" for cf_incdir in $cf_search do for cf_add_incdir in $cf_incdir do while true do case $cf_add_incdir in /usr/include) # (vi ;; /usr/local/include) # (vi if test "$GCC" = yes then cf_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$cf_add_incdir" cat > conftest.$ac_ext < int main() { printf("Hello") ; return 0; } EOF if { (eval echo configure:4030: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPPFLAGS="$cf_save_CPPFLAGS" fi rm -f conftest* fi ;; *) # (vi CPPFLAGS="$CPPFLAGS -I$cf_add_incdir" ;; esac cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'` test "$cf_top_incdir" = "$cf_add_incdir" && break cf_add_incdir="$cf_top_incdir" done done for cf_header in \ ncurses.h \ curses.h do cat > conftest.$ac_ext < int main() { #ifdef NCURSES_VERSION printf("%s\n", NCURSES_VERSION); #else #ifdef __NCURSES_H printf("old\n"); #else make an error #endif #endif ; return 0; } EOF if { (eval echo configure:4078: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_ncurses_h2=$cf_header else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_cv_ncurses_h2=no fi rm -f conftest* if test "$cf_cv_ncurses_h2" != no ; then cf_cv_ncurses_h2=$cf_incdir/$cf_header test -n "$verbose" && echo $ac_n " ... found $ac_c" 1>&6 break fi test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&6 done CPPFLAGS="$cf_save2_CPPFLAGS" test "$cf_cv_ncurses_h2" != no && break done test "$cf_cv_ncurses_h2" = no && { echo "configure: error: not found" 1>&2; exit 1; } fi echo "$ac_t""$cf_cv_ncurses_h2" 1>&6 cf_1st_incdir=`echo $cf_cv_ncurses_h2 | sed -e 's%/[^/]*$%%'` cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2` if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header fi for cf_add_incdir in $cf_1st_incdir do while true do case $cf_add_incdir in /usr/include) # (vi ;; /usr/local/include) # (vi if test "$GCC" = yes then cf_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$cf_add_incdir" cat > conftest.$ac_ext < int main() { printf("Hello") ; return 0; } EOF if { (eval echo configure:4132: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPPFLAGS="$cf_save_CPPFLAGS" fi rm -f conftest* fi ;; *) # (vi CPPFLAGS="$CPPFLAGS -I$cf_add_incdir" ;; esac cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'` test "$cf_top_incdir" = "$cf_add_incdir" && break cf_add_incdir="$cf_top_incdir" done done fi cat >> confdefs.h <<\EOF #define NCURSES 1 EOF case $cf_cv_ncurses_header in # (vi *ncurses.h) cat >> confdefs.h <<\EOF #define HAVE_NCURSES_H 1 EOF ;; esac case $cf_cv_ncurses_header in # (vi ncurses/curses.h|ncurses/ncurses.h) cat >> confdefs.h <<\EOF #define HAVE_NCURSES_NCURSES_H 1 EOF ;; ncursesw/curses.h|ncursesw/ncurses.h) cat >> confdefs.h <<\EOF #define HAVE_NCURSESW_NCURSES_H 1 EOF ;; esac echo $ac_n "checking for ncurses version""... $ac_c" 1>&6 echo "configure:4187: checking for ncurses version" >&5 if eval "test \"`echo '$''{'cf_cv_ncurses_version'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cf_cv_ncurses_version=no cf_tempfile=out$$ rm -f $cf_tempfile if test "$cross_compiling" = yes; then # This will not work if the preprocessor splits the line after the # Autoconf token. The 'unproto' program does that. cat > conftest.$ac_ext < #undef Autoconf #ifdef NCURSES_VERSION Autoconf NCURSES_VERSION #else #ifdef __NCURSES_H Autoconf "old" #endif ; #endif EOF cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out" { (eval echo configure:4213: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; } if test -f conftest.out ; then cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'` test -n "$cf_out" && cf_cv_ncurses_version="$cf_out" rm -f conftest.out fi else cat > conftest.$ac_ext < #include int main() { FILE *fp = fopen("$cf_tempfile", "w"); #ifdef NCURSES_VERSION # ifdef NCURSES_VERSION_PATCH fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH); # else fprintf(fp, "%s\n", NCURSES_VERSION); # endif #else # ifdef __NCURSES_H fprintf(fp, "old\n"); # else make an error # endif #endif exit(0); } EOF if { (eval echo configure:4246: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then cf_cv_ncurses_version=`cat $cf_tempfile` else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -fr conftest* fi rm -f $cf_tempfile fi echo "$ac_t""$cf_cv_ncurses_version" 1>&6 test "$cf_cv_ncurses_version" = no || cat >> confdefs.h <<\EOF #define NCURSES 1 EOF cf_nculib_root=ncurses # This works, except for the special case where we find gpm, but # ncurses is in a nonstandard location via $LIBS, and we really want # to link gpm. cf_ncurses_LIBS="" cf_ncurses_SAVE="$LIBS" echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6 echo "configure:4277: checking for Gpm_Open in -lgpm" >&5 ac_lib_var=`echo gpm'_'Gpm_Open | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lgpm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 echo $ac_n "checking for initscr in -lgpm""... $ac_c" 1>&6 echo "configure:4312: checking for initscr in -lgpm" >&5 ac_lib_var=`echo gpm'_'initscr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lgpm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="$cf_ncurses_SAVE" else echo "$ac_t""no" 1>&6 cf_ncurses_LIBS="-lgpm" fi else echo "$ac_t""no" 1>&6 fi case $host_os in #(vi freebsd*) # This is only necessary if you are linking against an obsolete # version of ncurses (but it should do no harm, since it's static). if test "$cf_nculib_root" = ncurses ; then echo $ac_n "checking for tgoto in -lmytinfo""... $ac_c" 1>&6 echo "configure:4363: checking for tgoto in -lmytinfo" >&5 ac_lib_var=`echo mytinfo'_'tgoto | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lmytinfo $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS" else echo "$ac_t""no" 1>&6 fi fi ;; esac LIBS="$cf_ncurses_LIBS $LIBS" if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" ) then LIBS="-L$cf_cv_curses_dir/lib -l$cf_nculib_root $LIBS" else eval 'cf_cv_have_lib_'$cf_nculib_root'=no' cf_libdir="" echo $ac_n "checking for initscr""... $ac_c" 1>&6 echo "configure:4416: checking for initscr" >&5 if eval "test \"`echo '$''{'ac_cv_func_initscr'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char initscr(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_initscr) || defined (__stub___initscr) choke me #else initscr(); #endif ; return 0; } EOF if { (eval echo configure:4444: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_initscr=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_initscr=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'initscr`\" = yes"; then echo "$ac_t""yes" 1>&6 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes' else echo "$ac_t""no" 1>&6 cf_save_LIBS="$LIBS" echo $ac_n "checking for initscr in -l$cf_nculib_root""... $ac_c" 1>&6 echo "configure:4464: checking for initscr in -l$cf_nculib_root" >&5 LIBS="-l$cf_nculib_root $LIBS" cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:4474: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes' else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* echo "$ac_t""no" 1>&6 cf_search="" test -d $HOME && { test -n "$verbose" && echo " ... testing lib-directories under $HOME" test -d $HOME/lib && cf_search="$cf_search $HOME/lib" test -d $HOME/lib/$cf_nculib_root && cf_search="$cf_search $HOME/lib/$cf_nculib_root" test -d $HOME/lib/$cf_nculib_root/lib && cf_search="$cf_search $HOME/lib/$cf_nculib_root/lib" } # For other stuff under the home directory, it should be sufficient to put # a symbolic link for $HOME/$cf_nculib_root to the actual package location: test -d $HOME/$cf_nculib_root && { test -n "$verbose" && echo " ... testing lib-directories under $HOME/$cf_nculib_root" test -d $HOME/$cf_nculib_root/lib && cf_search="$cf_search $HOME/$cf_nculib_root/lib" test -d $HOME/$cf_nculib_root/lib/$cf_nculib_root && cf_search="$cf_search $HOME/$cf_nculib_root/lib/$cf_nculib_root" } test "$prefix" != /usr/local && \ test -d /usr/local && { test -n "$verbose" && echo " ... testing lib-directories under /usr/local" test -d /usr/local/lib && cf_search="$cf_search /usr/local/lib" test -d /usr/local/lib/$cf_nculib_root && cf_search="$cf_search /usr/local/lib/$cf_nculib_root" test -d /usr/local/lib/$cf_nculib_root/lib && cf_search="$cf_search /usr/local/lib/$cf_nculib_root/lib" test -d /usr/local/$cf_nculib_root/lib && cf_search="$cf_search /usr/local/$cf_nculib_root/lib" test -d /usr/local/$cf_nculib_root/lib/$cf_nculib_root && cf_search="$cf_search /usr/local/$cf_nculib_root/lib/$cf_nculib_root" } test "$prefix" != NONE && \ test -d $prefix && { test -n "$verbose" && echo " ... testing lib-directories under $prefix" test -d $prefix/lib && cf_search="$cf_search $prefix/lib" test -d $prefix/lib/$cf_nculib_root && cf_search="$cf_search $prefix/lib/$cf_nculib_root" test -d $prefix/lib/$cf_nculib_root/lib && cf_search="$cf_search $prefix/lib/$cf_nculib_root/lib" test -d $prefix/$cf_nculib_root/lib && cf_search="$cf_search $prefix/$cf_nculib_root/lib" test -d $prefix/$cf_nculib_root/lib/$cf_nculib_root && cf_search="$cf_search $prefix/$cf_nculib_root/lib/$cf_nculib_root" } test "$prefix" != /opt && \ test -d /opt && { test -n "$verbose" && echo " ... testing lib-directories under /opt" test -d /opt/lib && cf_search="$cf_search /opt/lib" test -d /opt/lib/$cf_nculib_root && cf_search="$cf_search /opt/lib/$cf_nculib_root" test -d /opt/lib/$cf_nculib_root/lib && cf_search="$cf_search /opt/lib/$cf_nculib_root/lib" test -d /opt/$cf_nculib_root/lib && cf_search="$cf_search /opt/$cf_nculib_root/lib" test -d /opt/$cf_nculib_root/lib/$cf_nculib_root && cf_search="$cf_search /opt/$cf_nculib_root/lib/$cf_nculib_root" } test "$prefix" != /usr && \ test -d /usr && { test -n "$verbose" && echo " ... testing lib-directories under /usr" test -d /usr/lib && cf_search="$cf_search /usr/lib" test -d /usr/lib/$cf_nculib_root && cf_search="$cf_search /usr/lib/$cf_nculib_root" test -d /usr/lib/$cf_nculib_root/lib && cf_search="$cf_search /usr/lib/$cf_nculib_root/lib" test -d /usr/$cf_nculib_root/lib && cf_search="$cf_search /usr/$cf_nculib_root/lib" } for cf_libdir in $cf_search do echo $ac_n "checking for -l$cf_nculib_root in $cf_libdir""... $ac_c" 1>&6 echo "configure:4543: checking for -l$cf_nculib_root in $cf_libdir" >&5 LIBS="-L$cf_libdir -l$cf_nculib_root $cf_save_LIBS" cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:4553: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes' break else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* echo "$ac_t""no" 1>&6 LIBS="$cf_save_LIBS" fi rm -f conftest* done fi rm -f conftest* fi eval 'cf_found_library=$cf_cv_have_lib_'$cf_nculib_root if test $cf_found_library = no ; then { echo "configure: error: Cannot link $cf_nculib_root library" 1>&2; exit 1; } fi fi if test -n "$cf_ncurses_LIBS" ; then echo $ac_n "checking if we can link $cf_nculib_root without $cf_ncurses_LIBS""... $ac_c" 1>&6 echo "configure:4584: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5 cf_ncurses_SAVE="$LIBS" for p in $cf_ncurses_LIBS ; do q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"` if test "$q" != "$LIBS" ; then LIBS="$q" fi done cat > conftest.$ac_ext < int main() { initscr(); mousemask(0,0); tgoto((char *)0, 0, 0); ; return 0; } EOF if { (eval echo configure:4600: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* echo "$ac_t""no" 1>&6 LIBS="$cf_ncurses_SAVE" fi rm -f conftest* fi cf_nculib_ROOT=`echo "HAVE_LIB$cf_nculib_root" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` cat >> confdefs.h <&6 echo "configure:4625: checking for multibyte character support" >&5 if eval "test \"`echo '$''{'cf_cv_utf8_lib'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cf_save_LIBS="$LIBS" cat > conftest.$ac_ext < int main() { putwc(0,0); ; return 0; } EOF if { (eval echo configure:4640: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cf_cv_utf8_lib=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* LIBS="-lutf8 $LIBS" cat > conftest.$ac_ext < int main() { putwc(0,0); ; return 0; } EOF if { (eval echo configure:4657: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cf_cv_utf8_lib=add-on else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_cv_utf8_lib=no fi rm -f conftest* LIBS="$cf_save_LIBS" fi rm -f conftest* fi echo "$ac_t""$cf_cv_utf8_lib" 1>&6 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between # ncurses/ncursesw: if test "$cf_cv_utf8_lib" = "add-on" ; then cat >> confdefs.h <<\EOF #define HAVE_LIBUTF8_H 1 EOF LIBS="-lutf8 $LIBS" fi cf_ncuhdr_root=ncursesw test -n "$cf_cv_curses_dir" && \ test "$cf_cv_curses_dir" != "no" && \ CPPFLAGS="-I$cf_cv_curses_dir/include -I$cf_cv_curses_dir/include/$cf_ncuhdr_root $CPPFLAGS" echo $ac_n "checking for $cf_ncuhdr_root header in include-path""... $ac_c" 1>&6 echo "configure:4694: checking for $cf_ncuhdr_root header in include-path" >&5 if eval "test \"`echo '$''{'cf_cv_ncurses_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h" ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h" for cf_header in $cf_header_list do cat > conftest.$ac_ext < int main() { #ifdef NCURSES_VERSION #ifndef WACS_BSSB make an error #endif printf("%s\n", NCURSES_VERSION); #else #ifdef __NCURSES_H printf("old\n"); #else make an error #endif #endif ; return 0; } EOF if { (eval echo configure:4734: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_ncurses_h=$cf_header else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_cv_ncurses_h=no fi rm -f conftest* test "$cf_cv_ncurses_h" != no && break done fi echo "$ac_t""$cf_cv_ncurses_h" 1>&6 if test "$cf_cv_ncurses_h" != no ; then cf_cv_ncurses_header=$cf_cv_ncurses_h else echo $ac_n "checking for $cf_ncuhdr_root include-path""... $ac_c" 1>&6 echo "configure:4757: checking for $cf_ncuhdr_root include-path" >&5 if eval "test \"`echo '$''{'cf_cv_ncurses_h2'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else test -n "$verbose" && echo cf_search="" test -d $HOME && { test -n "$verbose" && echo " ... testing include-directories under $HOME" test -d $HOME/include && cf_search="$cf_search $HOME/include" test -d $HOME/include/$cf_ncuhdr_root && cf_search="$cf_search $HOME/include/$cf_ncuhdr_root" test -d $HOME/include/$cf_ncuhdr_root/include && cf_search="$cf_search $HOME/include/$cf_ncuhdr_root/include" } # For other stuff under the home directory, it should be sufficient to put # a symbolic link for $HOME/$cf_ncuhdr_root to the actual package location: test -d $HOME/$cf_ncuhdr_root && { test -n "$verbose" && echo " ... testing include-directories under $HOME/$cf_ncuhdr_root" test -d $HOME/$cf_ncuhdr_root/include && cf_search="$cf_search $HOME/$cf_ncuhdr_root/include" test -d $HOME/$cf_ncuhdr_root/include/$cf_ncuhdr_root && cf_search="$cf_search $HOME/$cf_ncuhdr_root/include/$cf_ncuhdr_root" } test "$prefix" != /usr/local && \ test -d /usr/local && { test -n "$verbose" && echo " ... testing include-directories under /usr/local" test -d /usr/local/include && cf_search="$cf_search /usr/local/include" test -d /usr/local/include/$cf_ncuhdr_root && cf_search="$cf_search /usr/local/include/$cf_ncuhdr_root" test -d /usr/local/include/$cf_ncuhdr_root/include && cf_search="$cf_search /usr/local/include/$cf_ncuhdr_root/include" test -d /usr/local/$cf_ncuhdr_root/include && cf_search="$cf_search /usr/local/$cf_ncuhdr_root/include" test -d /usr/local/$cf_ncuhdr_root/include/$cf_ncuhdr_root && cf_search="$cf_search /usr/local/$cf_ncuhdr_root/include/$cf_ncuhdr_root" } test "$prefix" != NONE && \ test -d $prefix && { test -n "$verbose" && echo " ... testing include-directories under $prefix" test -d $prefix/include && cf_search="$cf_search $prefix/include" test -d $prefix/include/$cf_ncuhdr_root && cf_search="$cf_search $prefix/include/$cf_ncuhdr_root" test -d $prefix/include/$cf_ncuhdr_root/include && cf_search="$cf_search $prefix/include/$cf_ncuhdr_root/include" test -d $prefix/$cf_ncuhdr_root/include && cf_search="$cf_search $prefix/$cf_ncuhdr_root/include" test -d $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root && cf_search="$cf_search $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root" } test "$prefix" != /opt && \ test -d /opt && { test -n "$verbose" && echo " ... testing include-directories under /opt" test -d /opt/include && cf_search="$cf_search /opt/include" test -d /opt/include/$cf_ncuhdr_root && cf_search="$cf_search /opt/include/$cf_ncuhdr_root" test -d /opt/include/$cf_ncuhdr_root/include && cf_search="$cf_search /opt/include/$cf_ncuhdr_root/include" test -d /opt/$cf_ncuhdr_root/include && cf_search="$cf_search /opt/$cf_ncuhdr_root/include" test -d /opt/$cf_ncuhdr_root/include/$cf_ncuhdr_root && cf_search="$cf_search /opt/$cf_ncuhdr_root/include/$cf_ncuhdr_root" } test "$prefix" != /usr && \ test -d /usr && { test -n "$verbose" && echo " ... testing include-directories under /usr" test -d /usr/include && cf_search="$cf_search /usr/include" test -d /usr/include/$cf_ncuhdr_root && cf_search="$cf_search /usr/include/$cf_ncuhdr_root" test -d /usr/include/$cf_ncuhdr_root/include && cf_search="$cf_search /usr/include/$cf_ncuhdr_root/include" test -d /usr/$cf_ncuhdr_root/include && cf_search="$cf_search /usr/$cf_ncuhdr_root/include" } test "$includedir" != NONE && \ test "$includedir" != "/usr/include" && \ test -d "$includedir" && { test -d $includedir && cf_search="$cf_search $includedir" test -d $includedir/$cf_ncuhdr_root && cf_search="$cf_search $includedir/$cf_ncuhdr_root" } test "$oldincludedir" != NONE && \ test "$oldincludedir" != "/usr/include" && \ test -d "$oldincludedir" && { test -d $oldincludedir && cf_search="$cf_search $oldincludedir" test -d $oldincludedir/$cf_ncuhdr_root && cf_search="$cf_search $oldincludedir/$cf_ncuhdr_root" } test -n "$verbose" && echo search path $cf_search cf_save2_CPPFLAGS="$CPPFLAGS" for cf_incdir in $cf_search do for cf_add_incdir in $cf_incdir do while true do case $cf_add_incdir in /usr/include) # (vi ;; /usr/local/include) # (vi if test "$GCC" = yes then cf_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$cf_add_incdir" cat > conftest.$ac_ext < int main() { printf("Hello") ; return 0; } EOF if { (eval echo configure:4859: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPPFLAGS="$cf_save_CPPFLAGS" fi rm -f conftest* fi ;; *) # (vi CPPFLAGS="$CPPFLAGS -I$cf_add_incdir" ;; esac cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'` test "$cf_top_incdir" = "$cf_add_incdir" && break cf_add_incdir="$cf_top_incdir" done done for cf_header in \ ncurses.h \ curses.h do cat > conftest.$ac_ext < int main() { #ifdef NCURSES_VERSION #ifndef WACS_BSSB make an error #endif printf("%s\n", NCURSES_VERSION); #else #ifdef __NCURSES_H printf("old\n"); #else make an error #endif #endif ; return 0; } EOF if { (eval echo configure:4915: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_ncurses_h2=$cf_header else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_cv_ncurses_h2=no fi rm -f conftest* if test "$cf_cv_ncurses_h2" != no ; then cf_cv_ncurses_h2=$cf_incdir/$cf_header test -n "$verbose" && echo $ac_n " ... found $ac_c" 1>&6 break fi test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&6 done CPPFLAGS="$cf_save2_CPPFLAGS" test "$cf_cv_ncurses_h2" != no && break done test "$cf_cv_ncurses_h2" = no && { echo "configure: error: not found" 1>&2; exit 1; } fi echo "$ac_t""$cf_cv_ncurses_h2" 1>&6 cf_1st_incdir=`echo $cf_cv_ncurses_h2 | sed -e 's%/[^/]*$%%'` cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2` if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header fi for cf_add_incdir in $cf_1st_incdir do while true do case $cf_add_incdir in /usr/include) # (vi ;; /usr/local/include) # (vi if test "$GCC" = yes then cf_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$cf_add_incdir" cat > conftest.$ac_ext < int main() { printf("Hello") ; return 0; } EOF if { (eval echo configure:4969: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPPFLAGS="$cf_save_CPPFLAGS" fi rm -f conftest* fi ;; *) # (vi CPPFLAGS="$CPPFLAGS -I$cf_add_incdir" ;; esac cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'` test "$cf_top_incdir" = "$cf_add_incdir" && break cf_add_incdir="$cf_top_incdir" done done fi cat >> confdefs.h <<\EOF #define NCURSES 1 EOF case $cf_cv_ncurses_header in # (vi *ncurses.h) cat >> confdefs.h <<\EOF #define HAVE_NCURSES_H 1 EOF ;; esac case $cf_cv_ncurses_header in # (vi ncurses/curses.h|ncurses/ncurses.h) cat >> confdefs.h <<\EOF #define HAVE_NCURSES_NCURSES_H 1 EOF ;; ncursesw/curses.h|ncursesw/ncurses.h) cat >> confdefs.h <<\EOF #define HAVE_NCURSESW_NCURSES_H 1 EOF ;; esac echo $ac_n "checking for ncurses version""... $ac_c" 1>&6 echo "configure:5024: checking for ncurses version" >&5 if eval "test \"`echo '$''{'cf_cv_ncurses_version'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cf_cv_ncurses_version=no cf_tempfile=out$$ rm -f $cf_tempfile if test "$cross_compiling" = yes; then # This will not work if the preprocessor splits the line after the # Autoconf token. The 'unproto' program does that. cat > conftest.$ac_ext < #undef Autoconf #ifdef NCURSES_VERSION Autoconf NCURSES_VERSION #else #ifdef __NCURSES_H Autoconf "old" #endif ; #endif EOF cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out" { (eval echo configure:5050: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; } if test -f conftest.out ; then cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'` test -n "$cf_out" && cf_cv_ncurses_version="$cf_out" rm -f conftest.out fi else cat > conftest.$ac_ext < #include int main() { FILE *fp = fopen("$cf_tempfile", "w"); #ifdef NCURSES_VERSION # ifdef NCURSES_VERSION_PATCH fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH); # else fprintf(fp, "%s\n", NCURSES_VERSION); # endif #else # ifdef __NCURSES_H fprintf(fp, "old\n"); # else make an error # endif #endif exit(0); } EOF if { (eval echo configure:5083: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then cf_cv_ncurses_version=`cat $cf_tempfile` else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -fr conftest* fi rm -f $cf_tempfile fi echo "$ac_t""$cf_cv_ncurses_version" 1>&6 test "$cf_cv_ncurses_version" = no || cat >> confdefs.h <<\EOF #define NCURSES 1 EOF cf_nculib_root=ncursesw # This works, except for the special case where we find gpm, but # ncurses is in a nonstandard location via $LIBS, and we really want # to link gpm. cf_ncurses_LIBS="" cf_ncurses_SAVE="$LIBS" echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6 echo "configure:5114: checking for Gpm_Open in -lgpm" >&5 ac_lib_var=`echo gpm'_'Gpm_Open | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lgpm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 echo $ac_n "checking for initscr in -lgpm""... $ac_c" 1>&6 echo "configure:5149: checking for initscr in -lgpm" >&5 ac_lib_var=`echo gpm'_'initscr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lgpm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="$cf_ncurses_SAVE" else echo "$ac_t""no" 1>&6 cf_ncurses_LIBS="-lgpm" fi else echo "$ac_t""no" 1>&6 fi case $host_os in #(vi freebsd*) # This is only necessary if you are linking against an obsolete # version of ncurses (but it should do no harm, since it's static). if test "$cf_nculib_root" = ncurses ; then echo $ac_n "checking for tgoto in -lmytinfo""... $ac_c" 1>&6 echo "configure:5200: checking for tgoto in -lmytinfo" >&5 ac_lib_var=`echo mytinfo'_'tgoto | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lmytinfo $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS" else echo "$ac_t""no" 1>&6 fi fi ;; esac LIBS="$cf_ncurses_LIBS $LIBS" if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" ) then LIBS="-L$cf_cv_curses_dir/lib -l$cf_nculib_root $LIBS" else eval 'cf_cv_have_lib_'$cf_nculib_root'=no' cf_libdir="" echo $ac_n "checking for initscr""... $ac_c" 1>&6 echo "configure:5253: checking for initscr" >&5 if eval "test \"`echo '$''{'ac_cv_func_initscr'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char initscr(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_initscr) || defined (__stub___initscr) choke me #else initscr(); #endif ; return 0; } EOF if { (eval echo configure:5281: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_initscr=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_initscr=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'initscr`\" = yes"; then echo "$ac_t""yes" 1>&6 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes' else echo "$ac_t""no" 1>&6 cf_save_LIBS="$LIBS" echo $ac_n "checking for initscr in -l$cf_nculib_root""... $ac_c" 1>&6 echo "configure:5301: checking for initscr in -l$cf_nculib_root" >&5 LIBS="-l$cf_nculib_root $LIBS" cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:5311: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes' else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* echo "$ac_t""no" 1>&6 cf_search="" test -d $HOME && { test -n "$verbose" && echo " ... testing lib-directories under $HOME" test -d $HOME/lib && cf_search="$cf_search $HOME/lib" test -d $HOME/lib/$cf_nculib_root && cf_search="$cf_search $HOME/lib/$cf_nculib_root" test -d $HOME/lib/$cf_nculib_root/lib && cf_search="$cf_search $HOME/lib/$cf_nculib_root/lib" } # For other stuff under the home directory, it should be sufficient to put # a symbolic link for $HOME/$cf_nculib_root to the actual package location: test -d $HOME/$cf_nculib_root && { test -n "$verbose" && echo " ... testing lib-directories under $HOME/$cf_nculib_root" test -d $HOME/$cf_nculib_root/lib && cf_search="$cf_search $HOME/$cf_nculib_root/lib" test -d $HOME/$cf_nculib_root/lib/$cf_nculib_root && cf_search="$cf_search $HOME/$cf_nculib_root/lib/$cf_nculib_root" } test "$prefix" != /usr/local && \ test -d /usr/local && { test -n "$verbose" && echo " ... testing lib-directories under /usr/local" test -d /usr/local/lib && cf_search="$cf_search /usr/local/lib" test -d /usr/local/lib/$cf_nculib_root && cf_search="$cf_search /usr/local/lib/$cf_nculib_root" test -d /usr/local/lib/$cf_nculib_root/lib && cf_search="$cf_search /usr/local/lib/$cf_nculib_root/lib" test -d /usr/local/$cf_nculib_root/lib && cf_search="$cf_search /usr/local/$cf_nculib_root/lib" test -d /usr/local/$cf_nculib_root/lib/$cf_nculib_root && cf_search="$cf_search /usr/local/$cf_nculib_root/lib/$cf_nculib_root" } test "$prefix" != NONE && \ test -d $prefix && { test -n "$verbose" && echo " ... testing lib-directories under $prefix" test -d $prefix/lib && cf_search="$cf_search $prefix/lib" test -d $prefix/lib/$cf_nculib_root && cf_search="$cf_search $prefix/lib/$cf_nculib_root" test -d $prefix/lib/$cf_nculib_root/lib && cf_search="$cf_search $prefix/lib/$cf_nculib_root/lib" test -d $prefix/$cf_nculib_root/lib && cf_search="$cf_search $prefix/$cf_nculib_root/lib" test -d $prefix/$cf_nculib_root/lib/$cf_nculib_root && cf_search="$cf_search $prefix/$cf_nculib_root/lib/$cf_nculib_root" } test "$prefix" != /opt && \ test -d /opt && { test -n "$verbose" && echo " ... testing lib-directories under /opt" test -d /opt/lib && cf_search="$cf_search /opt/lib" test -d /opt/lib/$cf_nculib_root && cf_search="$cf_search /opt/lib/$cf_nculib_root" test -d /opt/lib/$cf_nculib_root/lib && cf_search="$cf_search /opt/lib/$cf_nculib_root/lib" test -d /opt/$cf_nculib_root/lib && cf_search="$cf_search /opt/$cf_nculib_root/lib" test -d /opt/$cf_nculib_root/lib/$cf_nculib_root && cf_search="$cf_search /opt/$cf_nculib_root/lib/$cf_nculib_root" } test "$prefix" != /usr && \ test -d /usr && { test -n "$verbose" && echo " ... testing lib-directories under /usr" test -d /usr/lib && cf_search="$cf_search /usr/lib" test -d /usr/lib/$cf_nculib_root && cf_search="$cf_search /usr/lib/$cf_nculib_root" test -d /usr/lib/$cf_nculib_root/lib && cf_search="$cf_search /usr/lib/$cf_nculib_root/lib" test -d /usr/$cf_nculib_root/lib && cf_search="$cf_search /usr/$cf_nculib_root/lib" } for cf_libdir in $cf_search do echo $ac_n "checking for -l$cf_nculib_root in $cf_libdir""... $ac_c" 1>&6 echo "configure:5380: checking for -l$cf_nculib_root in $cf_libdir" >&5 LIBS="-L$cf_libdir -l$cf_nculib_root $cf_save_LIBS" cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:5390: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes' break else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* echo "$ac_t""no" 1>&6 LIBS="$cf_save_LIBS" fi rm -f conftest* done fi rm -f conftest* fi eval 'cf_found_library=$cf_cv_have_lib_'$cf_nculib_root if test $cf_found_library = no ; then { echo "configure: error: Cannot link $cf_nculib_root library" 1>&2; exit 1; } fi fi if test -n "$cf_ncurses_LIBS" ; then echo $ac_n "checking if we can link $cf_nculib_root without $cf_ncurses_LIBS""... $ac_c" 1>&6 echo "configure:5421: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5 cf_ncurses_SAVE="$LIBS" for p in $cf_ncurses_LIBS ; do q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"` if test "$q" != "$LIBS" ; then LIBS="$q" fi done cat > conftest.$ac_ext < int main() { initscr(); mousemask(0,0); tgoto((char *)0, 0, 0); ; return 0; } EOF if { (eval echo configure:5437: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* echo "$ac_t""no" 1>&6 LIBS="$cf_ncurses_SAVE" fi rm -f conftest* fi cf_nculib_ROOT=`echo "HAVE_LIB$cf_nculib_root" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` cat >> confdefs.h <> confdefs.h <<\EOF #define X_DISPLAY_MISSING 1 EOF X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS= else if test -n "$x_includes"; then X_CFLAGS="$X_CFLAGS -I$x_includes" fi # It would also be nice to do this for all -L options, not just this one. if test -n "$x_libraries"; then X_LIBS="$X_LIBS -L$x_libraries" # For Solaris; some versions of Sun CC require a space after -R and # others require no space. Words are not sufficient . . . . case "`(uname -sr) 2>/dev/null`" in "SunOS 5"*) echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6 echo "configure:5481: checking whether -R must be followed by a space" >&5 ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_R_nospace=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_R_nospace=no fi rm -f conftest* if test $ac_R_nospace = yes; then echo "$ac_t""no" 1>&6 X_LIBS="$X_LIBS -R$x_libraries" else LIBS="$ac_xsave_LIBS -R $x_libraries" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_R_space=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_R_space=no fi rm -f conftest* if test $ac_R_space = yes; then echo "$ac_t""yes" 1>&6 X_LIBS="$X_LIBS -R $x_libraries" else echo "$ac_t""neither works" 1>&6 fi fi LIBS="$ac_xsave_LIBS" esac fi # Check for system-dependent libraries X programs must link with. # Do this before checking for the system-independent R6 libraries # (-lICE), since we may need -lsocket or whatever for X linking. if test "$ISC" = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet" else # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X # libraries were built with DECnet support. And karl@cs.umb.edu says # the Alpha needs dnet_stub (dnet does not exist). echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6 echo "configure:5546: checking for dnet_ntoa in -ldnet" >&5 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-ldnet $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" else echo "$ac_t""no" 1>&6 fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6 echo "configure:5587: checking for dnet_ntoa in -ldnet_stub" >&5 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-ldnet_stub $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" else echo "$ac_t""no" 1>&6 fi fi # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, # to get the SysV transport functions. # chad@anasazi.com says the Pyramis MIS-ES running DC/OSx (SVR4) # needs -lnsl. # The nsl library prevents programs from opening the X display # on Irix 5.2, according to dickey@clark.net. echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 echo "configure:5635: checking for gethostbyname" >&5 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char gethostbyname(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_gethostbyname) || defined (__stub___gethostbyname) choke me #else gethostbyname(); #endif ; return 0; } EOF if { (eval echo configure:5663: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gethostbyname=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_gethostbyname=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 fi if test $ac_cv_func_gethostbyname = no; then echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 echo "configure:5684: checking for gethostbyname in -lnsl" >&5 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" else echo "$ac_t""no" 1>&6 fi fi # lieder@skyler.mavd.honeywell.com says without -lsocket, # socket/setsockopt and other routines are undefined under SCO ODT # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary # on later versions), says simon@lia.di.epfl.ch: it contains # gethostby* variants that don't use the nameserver (or something). # -lsocket must be given before -lnsl if both are needed. # We assume that if connect needs -lnsl, so does gethostbyname. echo $ac_n "checking for connect""... $ac_c" 1>&6 echo "configure:5733: checking for connect" >&5 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char connect(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_connect) || defined (__stub___connect) choke me #else connect(); #endif ; return 0; } EOF if { (eval echo configure:5761: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_connect=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_connect=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'connect`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 fi if test $ac_cv_func_connect = no; then echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6 echo "configure:5782: checking for connect in -lsocket" >&5 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lsocket $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" else echo "$ac_t""no" 1>&6 fi fi # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX. echo $ac_n "checking for remove""... $ac_c" 1>&6 echo "configure:5825: checking for remove" >&5 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char remove(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_remove) || defined (__stub___remove) choke me #else remove(); #endif ; return 0; } EOF if { (eval echo configure:5853: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_remove=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_remove=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'remove`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 fi if test $ac_cv_func_remove = no; then echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6 echo "configure:5874: checking for remove in -lposix" >&5 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lposix $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" else echo "$ac_t""no" 1>&6 fi fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. echo $ac_n "checking for shmat""... $ac_c" 1>&6 echo "configure:5917: checking for shmat" >&5 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char shmat(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_shmat) || defined (__stub___shmat) choke me #else shmat(); #endif ; return 0; } EOF if { (eval echo configure:5945: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_shmat=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_shmat=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'shmat`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 fi if test $ac_cv_func_shmat = no; then echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6 echo "configure:5966: checking for shmat in -lipc" >&5 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lipc $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" else echo "$ac_t""no" 1>&6 fi fi fi # Check for libraries that X11R6 Xt/Xaw programs need. ac_save_LDFLAGS="$LDFLAGS" test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries" # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to # check for ICE first), but we must link in the order -lSM -lICE or # we get undefined symbols. So assume we have SM if we have ICE. # These have to be linked with before -lX11, unlike the other # libraries we check for below, so use a different variable. # --interran@uluru.Stanford.EDU, kb@cs.umb.edu. echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6 echo "configure:6018: checking for IceConnectionNumber in -lICE" >&5 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lICE $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" else echo "$ac_t""no" 1>&6 fi LDFLAGS="$ac_save_LDFLAGS" fi # SYSTEM_NAME=`echo "$cf_cv_system_name"|tr ' ' -` cf_have_X_LIBS=no LDFLAGS="$X_LIBS $LDFLAGS" test -n "$verbose" && echo " checking additions to CFLAGS" 1>&6 cf_check_cflags="$CFLAGS" cf_check_cppflags="$CPPFLAGS" cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in $X_CFLAGS do case $cf_fix_cppflags in no) case $cf_add_cflags in #(vi -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi case $cf_add_cflags in -D*) cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'` test "${cf_add_cflags}" != "${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test $cf_fix_cppflags = yes ; then cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" continue elif test "${cf_tst_cflags}" = "\"'" ; then cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" continue fi ;; esac case "$CPPFLAGS" in *$cf_add_cflags) #(vi ;; *) #(vi cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" ;; esac ;; *) cf_new_cflags="$cf_new_cflags $cf_add_cflags" ;; esac ;; yes) cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` test "${cf_add_cflags}" != "${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then test -n "$verbose" && echo " add to \$CFLAGS $cf_new_cflags" 1>&6 CFLAGS="$CFLAGS $cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then test -n "$verbose" && echo " add to \$CPPFLAGS $cf_new_cppflags" 1>&6 CPPFLAGS="$cf_new_cppflags $CPPFLAGS" fi if test -n "$cf_new_extra_cppflags" ; then test -n "$verbose" && echo " add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6 EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" fi if test "$cf_check_cflags" != "$CFLAGS" ; then cat > conftest.$ac_ext < int main() { printf("Hello world"); ; return 0; } EOF if { (eval echo configure:6159: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* test -n "$verbose" && echo " test-compile failed. Undoing change to \$CFLAGS" 1>&6 if test "$cf_check_cppflags" != "$CPPFLAGS" ; then test -n "$verbose" && echo " but keeping change to \$CPPFLAGS" 1>&6 fi CFLAGS="$cf_check_flags" fi rm -f conftest* fi echo $ac_n "checking for XOpenDisplay""... $ac_c" 1>&6 echo "configure:6178: checking for XOpenDisplay" >&5 if eval "test \"`echo '$''{'ac_cv_func_XOpenDisplay'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char XOpenDisplay(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_XOpenDisplay) || defined (__stub___XOpenDisplay) choke me #else XOpenDisplay(); #endif ; return 0; } EOF if { (eval echo configure:6206: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_XOpenDisplay=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_XOpenDisplay=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'XOpenDisplay`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 echo $ac_n "checking for XOpenDisplay in -lX11""... $ac_c" 1>&6 echo "configure:6225: checking for XOpenDisplay in -lX11" >&5 ac_lib_var=`echo X11'_'XOpenDisplay | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lX11 $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="-lX11 $LIBS" else echo "$ac_t""no" 1>&6 fi fi echo $ac_n "checking for XtAppInitialize""... $ac_c" 1>&6 echo "configure:6268: checking for XtAppInitialize" >&5 if eval "test \"`echo '$''{'ac_cv_func_XtAppInitialize'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char XtAppInitialize(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_XtAppInitialize) || defined (__stub___XtAppInitialize) choke me #else XtAppInitialize(); #endif ; return 0; } EOF if { (eval echo configure:6296: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_XtAppInitialize=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_XtAppInitialize=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'XtAppInitialize`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 echo $ac_n "checking for XtAppInitialize in -lXt""... $ac_c" 1>&6 echo "configure:6315: checking for XtAppInitialize in -lXt" >&5 ac_lib_var=`echo Xt'_'XtAppInitialize | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF #define HAVE_LIBXT 1 EOF cf_have_X_LIBS=Xt LIBS="-lXt $X_PRE_LIBS $LIBS" else echo "$ac_t""no" 1>&6 fi fi if test $cf_have_X_LIBS = no ; then echo "configure: warning: Unable to successfully link X Toolkit library (-lXt) with test program. You will have to check and add the proper libraries by hand to makefile." 1>&2 fi cf_x_athena=${cf_x_athena-Xaw} echo $ac_n "checking if you want to link with Xaw 3d library""... $ac_c" 1>&6 echo "configure:6372: checking if you want to link with Xaw 3d library" >&5 withval= # Check whether --with-Xaw3d or --without-Xaw3d was given. if test "${with_Xaw3d+set}" = set; then withval="$with_Xaw3d" : fi if test "$withval" = yes ; then cf_x_athena=Xaw3d echo "$ac_t""yes" 1>&6 else echo "$ac_t""no" 1>&6 fi echo $ac_n "checking if you want to link with neXT Athena library""... $ac_c" 1>&6 echo "configure:6389: checking if you want to link with neXT Athena library" >&5 withval= # Check whether --with-neXtaw or --without-neXtaw was given. if test "${with_neXtaw+set}" = set; then withval="$with_neXtaw" : fi if test "$withval" = yes ; then cf_x_athena=neXtaw echo "$ac_t""yes" 1>&6 else echo "$ac_t""no" 1>&6 fi echo $ac_n "checking if you want to link with Athena-Plus library""... $ac_c" 1>&6 echo "configure:6406: checking if you want to link with Athena-Plus library" >&5 withval= # Check whether --with-XawPlus or --without-XawPlus was given. if test "${with_XawPlus+set}" = set; then withval="$with_XawPlus" : fi if test "$withval" = yes ; then cf_x_athena=XawPlus echo "$ac_t""yes" 1>&6 else echo "$ac_t""no" 1>&6 fi echo $ac_n "checking for XextCreateExtension in -lXext""... $ac_c" 1>&6 echo "configure:6423: checking for XextCreateExtension in -lXext" >&5 ac_lib_var=`echo Xext'_'XextCreateExtension | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lXext $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="-lXext $LIBS" else echo "$ac_t""no" 1>&6 fi cf_x_athena_lib="" cf_x_athena_root=$cf_x_athena cf_x_athena_include="" for cf_path in default \ /usr/contrib/X11R6 \ /usr/contrib/X11R5 \ /usr/lib/X11R5 \ /usr/local do if test -z "$cf_x_athena_include" ; then cf_save="$CPPFLAGS" cf_test=X11/$cf_x_athena_root/SimpleMenu.h if test $cf_path != default ; then CPPFLAGS="-I$cf_path/include $cf_save" echo $ac_n "checking for $cf_test in $cf_path""... $ac_c" 1>&6 echo "configure:6481: checking for $cf_test in $cf_path" >&5 else echo $ac_n "checking for $cf_test""... $ac_c" 1>&6 echo "configure:6484: checking for $cf_test" >&5 fi cat > conftest.$ac_ext < #include <$cf_test> int main() { ; return 0; } EOF if { (eval echo configure:6496: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_result=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_result=no fi rm -f conftest* echo "$ac_t""$cf_result" 1>&6 if test "$cf_result" = yes ; then cf_x_athena_include=$cf_path break else CPPFLAGS="$cf_save" fi fi done if test -z "$cf_x_athena_include" ; then echo "configure: warning: Unable to successfully find Athena header files with test program" 1>&2 elif test "$cf_x_athena_include" != default ; then CPPFLAGS="$CPPFLAGS -I$cf_x_athena_include" fi cf_x_athena_root=$cf_x_athena cf_x_athena_lib="" for cf_path in default \ /usr/contrib/X11R6 \ /usr/contrib/X11R5 \ /usr/lib/X11R5 \ /usr/local do for cf_lib in \ "-l$cf_x_athena_root -lXmu" \ "-l$cf_x_athena_root -lXpm -lXmu" \ "-l${cf_x_athena_root}_s -lXmu_s" do if test -z "$cf_x_athena_lib" ; then cf_save="$LIBS" cf_test=XawSimpleMenuAddGlobalActions if test $cf_path != default ; then LIBS="-L$cf_path/lib $cf_lib $LIBS" echo $ac_n "checking for $cf_lib in $cf_path""... $ac_c" 1>&6 echo "configure:6543: checking for $cf_lib in $cf_path" >&5 else LIBS="$cf_lib $LIBS" echo $ac_n "checking for $cf_test in $cf_lib""... $ac_c" 1>&6 echo "configure:6547: checking for $cf_test in $cf_lib" >&5 fi cf_SAVE="$LIBS" LIBS="$X_PRE_LIBS $LIBS $X_EXTRA_LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cf_result=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_result=no fi rm -f conftest* echo "$ac_t""$cf_result" 1>&6 if test "$cf_result" = yes ; then cf_x_athena_lib="$cf_lib" LIBS="$cf_SAVE" break else LIBS="$cf_save" fi fi done done if test -z "$cf_x_athena_lib" ; then { echo "configure: error: Unable to successfully link Athena library (-l$cf_x_athena_root) with test program" 1>&2; exit 1; } fi cf_x_athena_LIBS=`echo "HAVE_LIB_$cf_x_athena" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` cat >> confdefs.h <&6 cf_check_cflags="$CFLAGS" cf_check_cppflags="$CPPFLAGS" cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in $X_CFLAGS do case $cf_fix_cppflags in no) case $cf_add_cflags in #(vi -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi case $cf_add_cflags in -D*) cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'` test "${cf_add_cflags}" != "${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test $cf_fix_cppflags = yes ; then cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" continue elif test "${cf_tst_cflags}" = "\"'" ; then cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" continue fi ;; esac case "$CPPFLAGS" in *$cf_add_cflags) #(vi ;; *) #(vi cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" ;; esac ;; *) cf_new_cflags="$cf_new_cflags $cf_add_cflags" ;; esac ;; yes) cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` test "${cf_add_cflags}" != "${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then test -n "$verbose" && echo " add to \$CFLAGS $cf_new_cflags" 1>&6 CFLAGS="$CFLAGS $cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then test -n "$verbose" && echo " add to \$CPPFLAGS $cf_new_cppflags" 1>&6 CPPFLAGS="$cf_new_cppflags $CPPFLAGS" fi if test -n "$cf_new_extra_cppflags" ; then test -n "$verbose" && echo " add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6 EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" fi if test "$cf_check_cflags" != "$CFLAGS" ; then cat > conftest.$ac_ext < int main() { printf("Hello world"); ; return 0; } EOF if { (eval echo configure:6686: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* test -n "$verbose" && echo " test-compile failed. Undoing change to \$CFLAGS" 1>&6 if test "$cf_check_cppflags" != "$CPPFLAGS" ; then test -n "$verbose" && echo " but keeping change to \$CPPFLAGS" 1>&6 fi CFLAGS="$cf_check_flags" fi rm -f conftest* fi echo $ac_n "checking for XOpenDisplay in -lX11""... $ac_c" 1>&6 echo "configure:6704: checking for XOpenDisplay in -lX11" >&5 ac_lib_var=`echo X11'_'XOpenDisplay | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lX11 $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="-lX11 $LIBS" else echo "$ac_t""no" 1>&6 fi echo $ac_n "checking for XCurses library""... $ac_c" 1>&6 echo "configure:6744: checking for XCurses library" >&5 if eval "test \"`echo '$''{'cf_cv_lib_XCurses'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else LIBS="-lXCurses $LIBS" cat > conftest.$ac_ext < char *XCursesProgramName = "test"; int main() { XCursesExit(); ; return 0; } EOF if { (eval echo configure:6761: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cf_cv_lib_XCurses=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_cv_lib_XCurses=no fi rm -f conftest* fi echo "$ac_t""$cf_cv_lib_XCurses" 1>&6 if test $cf_cv_lib_XCurses = yes ; then cat >> confdefs.h <<\EOF #define UNIX 1 EOF cat >> confdefs.h <<\EOF #define XCURSES 1 EOF cat >> confdefs.h <<\EOF #define HAVE_XCURSES 1 EOF else { echo "configure: error: Cannot link with XCurses" 1>&2; exit 1; } fi LIB_ROOTNAME=cdkX ;; *) echo $ac_n "checking for extra include directories""... $ac_c" 1>&6 echo "configure:6798: checking for extra include directories" >&5 if eval "test \"`echo '$''{'cf_cv_curses_incdir'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cf_cv_curses_incdir=no case $host_os in #(vi hpux10.*|hpux11.*) #(vi test -d /usr/include/curses_colr && \ cf_cv_curses_incdir="-I/usr/include/curses_colr" ;; sunos3*|sunos4*) test -d /usr/5lib && \ test -d /usr/5include && \ cf_cv_curses_incdir="-I/usr/5include" ;; esac fi echo "$ac_t""$cf_cv_curses_incdir" 1>&6 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$cf_cv_curses_incdir $CPPFLAGS" echo $ac_n "checking if we have identified curses headers""... $ac_c" 1>&6 echo "configure:6822: checking if we have identified curses headers" >&5 if eval "test \"`echo '$''{'cf_cv_ncurses_header'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cf_cv_ncurses_header=none for cf_header in \ curses.h \ ncurses.h \ ncurses/curses.h \ ncurses/ncurses.h do cat > conftest.$ac_ext < int main() { initscr(); tgoto("?", 0,0) ; return 0; } EOF if { (eval echo configure:6842: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_ncurses_header=$cf_header; break else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* done fi echo "$ac_t""$cf_cv_ncurses_header" 1>&6 if test "$cf_cv_ncurses_header" = none ; then { echo "configure: error: No curses header-files found" 1>&2; exit 1; } fi # cheat, to get the right #define's for HAVE_NCURSES_H, etc. for ac_hdr in $cf_cv_ncurses_header do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:6865: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:6875: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done echo $ac_n "checking for ncurses version""... $ac_c" 1>&6 echo "configure:6905: checking for ncurses version" >&5 if eval "test \"`echo '$''{'cf_cv_ncurses_version'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cf_cv_ncurses_version=no cf_tempfile=out$$ rm -f $cf_tempfile if test "$cross_compiling" = yes; then # This will not work if the preprocessor splits the line after the # Autoconf token. The 'unproto' program does that. cat > conftest.$ac_ext < #undef Autoconf #ifdef NCURSES_VERSION Autoconf NCURSES_VERSION #else #ifdef __NCURSES_H Autoconf "old" #endif ; #endif EOF cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out" { (eval echo configure:6931: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; } if test -f conftest.out ; then cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'` test -n "$cf_out" && cf_cv_ncurses_version="$cf_out" rm -f conftest.out fi else cat > conftest.$ac_ext < #include int main() { FILE *fp = fopen("$cf_tempfile", "w"); #ifdef NCURSES_VERSION # ifdef NCURSES_VERSION_PATCH fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH); # else fprintf(fp, "%s\n", NCURSES_VERSION); # endif #else # ifdef __NCURSES_H fprintf(fp, "old\n"); # else make an error # endif #endif exit(0); } EOF if { (eval echo configure:6964: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then cf_cv_ncurses_version=`cat $cf_tempfile` else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -fr conftest* fi rm -f $cf_tempfile fi echo "$ac_t""$cf_cv_ncurses_version" 1>&6 test "$cf_cv_ncurses_version" = no || cat >> confdefs.h <<\EOF #define NCURSES 1 EOF echo $ac_n "checking if we have identified curses libraries""... $ac_c" 1>&6 echo "configure:6988: checking if we have identified curses libraries" >&5 cat > conftest.$ac_ext < int main() { initscr(); tgoto("?", 0,0) ; return 0; } EOF if { (eval echo configure:6997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cf_result=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_result=no fi rm -f conftest* echo "$ac_t""$cf_result" 1>&6 if test "$cf_result" = no ; then case $host_os in #(vi freebsd*) #(vi echo $ac_n "checking for tgoto in -lmytinfo""... $ac_c" 1>&6 echo "configure:7013: checking for tgoto in -lmytinfo" >&5 ac_lib_var=`echo mytinfo'_'tgoto | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lmytinfo $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="-lmytinfo $LIBS" else echo "$ac_t""no" 1>&6 fi ;; hpux10.*|hpux11.*) #(vi echo $ac_n "checking for initscr in -lcur_colr""... $ac_c" 1>&6 echo "configure:7055: checking for initscr in -lcur_colr" >&5 ac_lib_var=`echo cur_colr'_'initscr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lcur_colr $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="-lcur_colr $LIBS" ac_cv_func_initscr=yes else echo "$ac_t""no" 1>&6 echo $ac_n "checking for initscr in -lHcurses""... $ac_c" 1>&6 echo "configure:7097: checking for initscr in -lHcurses" >&5 ac_lib_var=`echo Hcurses'_'initscr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lHcurses $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 # HP's header uses __HP_CURSES, but user claims _HP_CURSES. LIBS="-lHcurses $LIBS" CPPFLAGS="-D__HP_CURSES -D_HP_CURSES $CPPFLAGS" ac_cv_func_initscr=yes else echo "$ac_t""no" 1>&6 fi fi ;; linux*) # Suse Linux does not follow /usr/lib convention LIBS="$LIBS -L/lib" ;; sunos3*|sunos4*) test -d /usr/5lib && \ LIBS="$LIBS -L/usr/5lib -lcurses -ltermcap" ac_cv_func_initscr=yes ;; esac if test ".$ac_cv_func_initscr" != .yes ; then cf_save_LIBS="$LIBS" cf_term_lib="" cf_curs_lib="" if test ".${cf_cv_ncurses_version-no}" != .no then cf_check_list="ncurses curses cursesX" else cf_check_list="cursesX curses ncurses" fi # Check for library containing tgoto. Do this before curses library # because it may be needed to link the test-case for initscr. echo $ac_n "checking for tgoto""... $ac_c" 1>&6 echo "configure:7169: checking for tgoto" >&5 if eval "test \"`echo '$''{'ac_cv_func_tgoto'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char tgoto(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_tgoto) || defined (__stub___tgoto) choke me #else tgoto(); #endif ; return 0; } EOF if { (eval echo configure:7197: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_tgoto=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_tgoto=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'tgoto`\" = yes"; then echo "$ac_t""yes" 1>&6 cf_term_lib=predefined else echo "$ac_t""no" 1>&6 for cf_term_lib in $cf_check_list termcap termlib unknown do echo $ac_n "checking for tgoto in -l$cf_term_lib""... $ac_c" 1>&6 echo "configure:7218: checking for tgoto in -l$cf_term_lib" >&5 ac_lib_var=`echo $cf_term_lib'_'tgoto | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-l$cf_term_lib $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 break else echo "$ac_t""no" 1>&6 fi done fi # Check for library containing initscr test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS" for cf_curs_lib in $cf_check_list xcurses jcurses unknown do echo $ac_n "checking for initscr in -l$cf_curs_lib""... $ac_c" 1>&6 echo "configure:7267: checking for initscr in -l$cf_curs_lib" >&5 ac_lib_var=`echo $cf_curs_lib'_'initscr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-l$cf_curs_lib $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 break else echo "$ac_t""no" 1>&6 fi done test $cf_curs_lib = unknown && { echo "configure: error: no curses library found" 1>&2; exit 1; } LIBS="-l$cf_curs_lib $cf_save_LIBS" if test "$cf_term_lib" = unknown ; then echo $ac_n "checking if we can link with $cf_curs_lib library""... $ac_c" 1>&6 echo "configure:7312: checking if we can link with $cf_curs_lib library" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:7321: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cf_result=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_result=no fi rm -f conftest* echo "$ac_t""$cf_result" 1>&6 test $cf_result = no && { echo "configure: error: Cannot link curses library" 1>&2; exit 1; } elif test "$cf_curs_lib" = "$cf_term_lib" ; then : elif test "$cf_term_lib" != predefined ; then echo $ac_n "checking if we need both $cf_curs_lib and $cf_term_lib libraries""... $ac_c" 1>&6 echo "configure:7337: checking if we need both $cf_curs_lib and $cf_term_lib libraries" >&5 cat > conftest.$ac_ext < int main() { initscr(); tgoto((char *)0, 0, 0); ; return 0; } EOF if { (eval echo configure:7346: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cf_result=no else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS" cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:7363: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cf_result=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_result=error fi rm -f conftest* fi rm -f conftest* echo "$ac_t""$cf_result" 1>&6 fi fi fi ;; esac echo $ac_n "checking if we must define _XOPEN_SOURCE_EXTENDED""... $ac_c" 1>&6 echo "configure:7388: checking if we must define _XOPEN_SOURCE_EXTENDED" >&5 if eval "test \"`echo '$''{'cf_cv_need_xopen_extension'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <${cf_cv_ncurses_header-curses.h}> int main() { long x = winnstr(stdscr, "", 0); int x1, y1; getbegyx(stdscr, y1, x1) ; return 0; } EOF if { (eval echo configure:7406: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cf_cv_need_xopen_extension=no else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cat > conftest.$ac_ext < #include <${cf_cv_ncurses_header-curses.h}> int main() { long x = winnstr(stdscr, "", 0); int x1, y1; getbegyx(stdscr, y1, x1) ; return 0; } EOF if { (eval echo configure:7427: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cf_cv_need_xopen_extension=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_cv_need_xopen_extension=unknown fi rm -f conftest* fi rm -f conftest* fi echo "$ac_t""$cf_cv_need_xopen_extension" 1>&6 test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED" echo $ac_n "checking for term.h""... $ac_c" 1>&6 echo "configure:7446: checking for term.h" >&5 if eval "test \"`echo '$''{'cf_cv_term_header'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # If we found , look for , but always look # for if we do not find the variant. for cf_header in \ `echo ${cf_cv_ncurses_header-curses.h} | sed -e 's%/.*%/%'`term.h \ term.h do cat > conftest.$ac_ext < #include <${cf_header}> int main() { WINDOW *x ; return 0; } EOF if { (eval echo configure:7468: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_term_header=$cf_header break else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_cv_term_header=no fi rm -f conftest* done fi echo "$ac_t""$cf_cv_term_header" 1>&6 case $cf_cv_term_header in #(vi term.h) #(vi cat >> confdefs.h <<\EOF #define HAVE_TERM_H 1 EOF ;; ncurses/term.h) cat >> confdefs.h <<\EOF #define HAVE_NCURSES_TERM_H 1 EOF ;; ncursesw/term.h) cat >> confdefs.h <<\EOF #define HAVE_NCURSESW_TERM_H 1 EOF ;; esac for cf_func in \ Xinitscr\ getbegx \ getbegy \ getmaxx \ getmaxy \ start_color \ \ do cf_tr_func=`echo "$cf_func" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` echo $ac_n "checking for ${cf_func}""... $ac_c" 1>&6 echo "configure:7523: checking for ${cf_func}" >&5 echo "(line 7525) testing ${cf_func} ..." 1>&5 if eval "test \"`echo '$''{'cf_cv_func_$cf_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else eval cf_result='$ac_cv_func_'$cf_func if test ".$cf_result" != ".no"; then cat > conftest.$ac_ext < char * XCursesProgramName = "test"; #else #include <${cf_cv_ncurses_header-curses.h}> #if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H) #include #else #if defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H) #include #else #ifdef HAVE_TERM_H #include #endif #endif #endif #endif int main() { #ifndef ${cf_func} long foo = (long)(&${cf_func}); exit(foo == 0); #endif ; return 0; } EOF if { (eval echo configure:7563: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cf_result=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cf_result=no fi rm -f conftest* fi eval 'cf_cv_func_'$cf_func'=$cf_result' fi # use the computed/retrieved cache-value: eval 'cf_result=$cf_cv_func_'$cf_func echo "$ac_t""$cf_result" 1>&6 if test $cf_result != no; then cat >> confdefs.h <&6 echo "configure:7595: checking if you want to check for memory leaks" >&5 cf_disable_leaks=no # Check whether --enable-leaks or --disable-leaks was given. if test "${enable_leaks+set}" = set; then enableval="$enable_leaks" test "$enableval" = no && cf_disable_leaks=yes fi echo "$ac_t""$cf_disable_leaks" 1>&6 if test "$cf_disable_leaks" = yes ; then cat >> confdefs.h <<\EOF #define NO_LEAKS 1 EOF for ac_hdr in nc_alloc.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:7615: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:7625: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done for ac_func in _nc_free_and_exit do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:7654: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:7682: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 fi done fi ;; esac echo $ac_n "checking how to define setbegyx""... $ac_c" 1>&6 echo "configure:7712: checking how to define setbegyx" >&5 cf_result=ERR for cf_check in \ '((win)->_begy = (y), (win)->_begx = (x), OK)' do cat > conftest.$ac_ext < int main() { WINDOW *win = 0; #define setbegyx(win,y,x) $cf_check setbegyx(win, 2, 3); ; return 0; } EOF if { (eval echo configure:7731: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_result=$cf_check; break else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* done echo "$ac_t"""$cf_result"" 1>&6 cat >> confdefs.h < confcache <<\EOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs. It is not useful on other systems. # If it contains results you don't want to keep, you may remove or edit it. # # By default, configure uses ./config.cache as the cache file, # creating it if it does not exist already. You can give configure # the --cache-file=FILE option to use a different cache file; that is # what configure does when it calls configure scripts in # subdirectories, so they share the cache. # Giving --cache-file=/dev/null disables caching, for debugging configure. # config.status only pays attention to the cache file if you give it the # --recheck option to rerun configure. # EOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). sed -n \ -e "s/'/'\\\\''/g" \ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' ;; esac >> confcache if cmp -s $cache_file confcache; then : else if test -w $cache_file; then echo "updating cache $cache_file" cat confcache > $cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Any assignment to VPATH causes Sun make to only execute # the first set of double-colon rules, so remove it if not needed. # If there is a colon in the path, we need to keep it. if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' fi trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 DEFS=-DHAVE_CONFIG_H # Without the "./", some shells look in PATH for config.status. : ${CONFIG_STATUS=./config.status} echo creating $CONFIG_STATUS rm -f $CONFIG_STATUS cat > $CONFIG_STATUS </dev/null | sed 1q`: # # $0 $ac_configure_args # # Compiler output produced by configure, useful for debugging # configure, is in ./config.log if it exists. ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" for ac_option do case "\$ac_option" in -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) echo "$CONFIG_STATUS generated by autoconf version 2.13.20030927" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; *) echo "\$ac_cs_usage"; exit 1 ;; esac done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" trap 'rm -fr `echo "include/cdk_version.h:include/cdk_version.hin Makefile cli/Makefile examples/Makefile demos/Makefile include/cdk_config.h:include/config.hin" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF $ac_vpsub $extrasub s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g s%@exec_prefix@%$exec_prefix%g s%@prefix@%$prefix%g s%@program_transform_name@%$program_transform_name%g s%@bindir@%$bindir%g s%@sbindir@%$sbindir%g s%@libexecdir@%$libexecdir%g s%@datadir@%$datadir%g s%@sysconfdir@%$sysconfdir%g s%@sharedstatedir@%$sharedstatedir%g s%@localstatedir@%$localstatedir%g s%@libdir@%$libdir%g s%@includedir@%$includedir%g s%@oldincludedir@%$oldincludedir%g s%@infodir@%$infodir%g s%@mandir@%$mandir%g s%@host@%$host%g s%@host_alias@%$host_alias%g s%@host_cpu@%$host_cpu%g s%@host_vendor@%$host_vendor%g s%@host_os@%$host_os%g s%@VERSION@%$VERSION%g s%@VERSION_MAJOR@%$VERSION_MAJOR%g s%@VERSION_MINOR@%$VERSION_MINOR%g s%@VERSION_PATCH@%$VERSION_PATCH%g s%@PACKAGE@%$PACKAGE%g s%@CC@%$CC%g s%@CPP@%$CPP%g s%@RANLIB@%$RANLIB%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@build@%$build%g s%@build_alias@%$build_alias%g s%@build_cpu@%$build_cpu%g s%@build_vendor@%$build_vendor%g s%@build_os@%$build_os%g s%@AR@%$AR%g s%@SET_MAKE@%$SET_MAKE%g s%@cf_cv_makeflags@%$cf_cv_makeflags%g s%@MAKE_LOWER_TAGS@%$MAKE_LOWER_TAGS%g s%@MAKE_UPPER_TAGS@%$MAKE_UPPER_TAGS%g s%@EXTRA_CPPFLAGS@%$EXTRA_CPPFLAGS%g s%@ECHO_LT@%$ECHO_LT%g s%@ECHO_LD@%$ECHO_LD%g s%@RULE_CC@%$RULE_CC%g s%@SHOW_CC@%$SHOW_CC%g s%@ECHO_CC@%$ECHO_CC%g s%@EXEEXT@%$EXEEXT%g s%@OBJEXT@%$OBJEXT%g s%@PROG_EXT@%$PROG_EXT%g s%@LIB_PREFIX@%$LIB_PREFIX%g s%@MAN_DIR@%$MAN_DIR%g s%@MANSECT@%$MANSECT%g s%@EXTRA_CFLAGS@%$EXTRA_CFLAGS%g s%@LIBTOOL@%$LIBTOOL%g s%@LIBTOOL_CXX@%$LIBTOOL_CXX%g s%@LIB_CREATE@%$LIB_CREATE%g s%@LIB_OBJECT@%$LIB_OBJECT%g s%@LIB_SUFFIX@%$LIB_SUFFIX%g s%@LIB_PREP@%$LIB_PREP%g s%@LIB_CLEAN@%$LIB_CLEAN%g s%@LIB_COMPILE@%$LIB_COMPILE%g s%@LIB_LINK@%$LIB_LINK%g s%@LIB_INSTALL@%$LIB_INSTALL%g s%@LIB_UNINSTALL@%$LIB_UNINSTALL%g s%@X_CFLAGS@%$X_CFLAGS%g s%@X_PRE_LIBS@%$X_PRE_LIBS%g s%@X_LIBS@%$X_LIBS%g s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g s%@LIB_ROOTNAME@%$LIB_ROOTNAME%g CEOF EOF cat >> $CONFIG_STATUS <<\EOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. ac_file=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_cmds # Line after last line for current file. ac_more_lines=: ac_sed_cmds="" while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file else sed "${ac_end}q" conftest.subs > conftest.s$ac_file fi if test ! -s conftest.s$ac_file; then ac_more_lines=false rm -f conftest.s$ac_file else if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f conftest.s$ac_file" else ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" fi ac_file=`expr $ac_file + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_cmds` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" # A "../" for each directory in $ac_dir_suffix. ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` else ac_dir_suffix= ac_dots= fi case "$ac_given_srcdir" in .) srcdir=. if test -z "$ac_dots"; then top_srcdir=. else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; *) # Relative path. srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" top_srcdir="$ac_dots$ac_given_srcdir" ;; esac case "$ac_given_INSTALL" in [/$]*) INSTALL="$ac_given_INSTALL" ;; *) INSTALL="$ac_dots$ac_given_INSTALL" ;; esac echo creating "$ac_file" rm -f "$ac_file" configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." case "$ac_file" in *Makefile*) ac_comsub="1i\\ # $configure_input" ;; *) ac_comsub= ;; esac ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` sed -e "$ac_comsub s%@configure_input@%$configure_input%g s%@srcdir@%$srcdir%g s%@top_srcdir@%$top_srcdir%g s%@INSTALL@%$INSTALL%g " $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file fi; done rm -f conftest.s* # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' ac_dC='\3' ac_dD='%g' # ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='\([ ]\)%\1#\2define\3' ac_uC=' ' ac_uD='\4%g' # ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_eB='$%\1#\2define\3' ac_eC=' ' ac_eD='%g' if test "${CONFIG_HEADERS+set}" != set; then EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF fi for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac echo creating $ac_file rm -f conftest.frag conftest.in conftest.out ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` cat $ac_file_inputs > conftest.in EOF # Transform confdefs.h into a list of #define's. We won't use it as a sed # script, but as data to insert where we see @DEFS@. We expect AC_SAVE_DEFS to # be either 'cat' or 'sort'. sort confdefs.h >conftest.vals # Break up conftest.vals because some shells have a limit on # the size of here documents, and old seds have small limits too. rm -f conftest.tail echo ' rm -f conftest.frag' >> $CONFIG_STATUS while : do ac_lines=`grep -c . conftest.vals` # grep -c gives empty output for an empty file on some AIX systems. if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi # Write chunks of a limited-size here document to conftest.frag. echo ' cat >> conftest.frag <> $CONFIG_STATUS sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS echo 'CEOF' >> $CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail rm -f conftest.vals mv conftest.tail conftest.vals done rm -f conftest.vals # Run sed to substitute the contents of conftest.frag into conftest.in at the # marker @DEFS@. echo ' cat >> conftest.edit < conftest.out rm -f conftest.in mv conftest.out conftest.in rm -f conftest.edit conftest.frag ' >> $CONFIG_STATUS cat >> $CONFIG_STATUS <<\EOF rm -f conftest.frag conftest.h echo "/* $ac_file. Generated automatically by configure. */" > conftest.h cat conftest.in >> conftest.h rm -f conftest.in if cmp -s $ac_file conftest.h 2>/dev/null; then echo "$ac_file is unchanged" rm -f conftest.h else # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" fi rm -f $ac_file mv conftest.h $ac_file fi fi; done EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF # Extra commands, if any exit 0 EOF chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 cdk-5.0-20060507/configure.in0000644000175100001440000000477510354612211014060 0ustar tomusersdnl $Id: configure.in,v 1.44 2005/12/28 22:41:13 tom Exp $ dnl Process this file with autoconf to produce a configure script for CDK. dnl AC_INIT(include/cdk.h) AC_CONFIG_HEADER(include/cdk_config.h:include/config.hin) CF_CHECK_CACHE CF_VERSION_INFO(cdk) dnl dnl Checks for programs. dnl AC_PROG_CC AC_PROG_CPP AC_PROG_GCC_TRADITIONAL AC_PROG_RANLIB AC_PROG_INSTALL dnl needed for CF_WITH_LIBTOOL AC_CHECK_TOOL(AR, ar, ar) AC_PROG_MAKE_SET CF_MAKEFLAGS CF_MAKE_TAGS CF_ANSI_CC_REQD AC_C_CONST 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_DIR=`echo $MANSECT | sed -e 's/^\(.\).*/\1/'` AC_SUBST(MAN_DIR) AC_SUBST(MANSECT) CF_WITH_CURSES_DIR CF_WITH_WARNINGS CF_WITH_LIBTOOL if test "$with_libtool" = "yes" ; then OBJEXT="lo" fi dnl dnl Checks for libraries. dnl CF_WITH_DBMALLOC CF_WITH_DMALLOC dnl dnl Checks for header files. dnl AC_HEADER_DIRENT AC_HEADER_STDC AC_CHECK_HEADERS(\ limits.h \ unistd.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 \ ) CF_FUNC_LSTAT CF_LOCALE([AC_DEFINE(HAVE_SETLOCALE)]) dnl Check for curses libraries last, since XCurses has dependencies which dnl break the checks for other functions. use_library=curses AC_ARG_WITH(ncurses, [ --with-ncurses compile/link with ncurses library], [use_library=ncurses],[ AC_ARG_WITH(ncursesw, [ --with-ncursesw compile/line with wide-character ncurses], [use_library=ncursesw],[ AC_ARG_WITH(pdcurses, [ --with-pdcurses compile/link with pdcurses X11 library], [use_library=pdcurses])])]) LIB_ROOTNAME=cdk case $use_library in #(vi ncurses) #(vi CF_NCURSES_CPPFLAGS CF_NCURSES_LIBS ;; ncursesw) CF_UTF8_LIB CF_NCURSES_CPPFLAGS(ncursesw) CF_NCURSES_LIBS(ncursesw) LIB_ROOTNAME=cdkw ;; pdcurses) #(vi CF_PDCURSES_X11 LIB_ROOTNAME=cdkX ;; *) CF_CURSES_CPPFLAGS CF_NCURSES_VERSION CF_CURSES_LIBS ;; esac AC_SUBST(LIB_ROOTNAME) CF_CURSES_FUNCS(\ Xinitscr\ getbegx \ getbegy \ getmaxx \ getmaxy \ start_color \ \ ) CF_WITH_NC_ALLOC_H CF_CURSES_SETBEGYX dnl dnl Set pre-processor compile time variables. dnl AC_OUTPUT( include/cdk_version.h:include/cdk_version.hin Makefile cli/Makefile examples/Makefile demos/Makefile,,,sort) cdk-5.0-20060507/debug.c0000644000175100001440000000152707755763475013027 0ustar tomusers#include /* * $Author: tom $ * $Date: 2003/11/16 21:08:13 $ * $Revision: 1.10 $ */ FILE *CDKDEBUG; /* * This starts debugging for CDK. */ FILE *startCDKDebug (char *filename) { 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, char *filename, char *function, int line, 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); } } cdk-5.0-20060507/demos/0000755000175100001440000000000010427502123012642 5ustar tomuserscdk-5.0-20060507/demos/Makefile.in0000644000175100001440000000434107761364047014733 0ustar tomusers# $Id: Makefile.in,v 1.15 2003/11/27 12:03:51 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 LIBS = -l@LIB_ROOTNAME@ @LIBS@ LIBTOOL = @LIBTOOL@ @ECHO_LT@ LIBTOOL_CLEAN = @LIB_CLEAN@ LIBTOOL_LINK = @LIB_LINK@ LINK = $(LIBTOOL_LINK) $(CC) x = @EXEEXT@ o = .@OBJEXT@ CFLAGS = @CFLAGS@ @EXTRA_CFLAGS@ CPPFLAGS = @DEFS@ -I../include -I$(srcdir)/../include -I. @CPPFLAGS@ LDFLAGS = -L.. @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 # # 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 cdk-5.0-20060507/demos/syb.c0000644000175100001440000007104410354232466013622 0ustar tomusers/* $Id: syb.c,v 1.12 2005/12/27 12:36:06 tom Exp $ */ #include #include #include #ifdef HAVE_XCURSES char *XCursesProgramName="syb"; #endif #define MAXWIDTH 5000 #define MAXHISTORY 1000 /* * This structure is used for keeping command history. */ struct history_st { unsigned used; int count; int current; char **cmd_history; }; /* * Define some global variables. */ char *GPUsage = "[-p Command Prompt] [-U User] [-P Password] [-S Server] [-h help]"; char *GPCurrentDatabase = 0; extern char *dberrstr; /* * Because the error/message callback do not allow you to pass in * data of your own, we have to make the screen pointer global. :( */ CDKSCREEN *GPCdkScreen = 0; /* * Define function prototypes. */ DBPROCESS *loginToSybase (CDKSCREEN *screen, char *login, char *password); DBPROCESS *sybaseLogin (CDKSCREEN *screen, char *login, char *password, int attempts); char *assembleTitle (DBPROCESS *dbProcess); char *assembleRow (DBPROCESS *dbProcess); char *uc (char *word); int getColWidth (DBPROCESS *dbProcess, int col); void runIsqlCommand (CDKSCREEN *cdkscreen, CDKSWINDOW *swindow, DBPROCESS *process); void useDatabase (CDKSWINDOW *swindow, DBPROCESS *dbProc, char *command); void intro (CDKSCREEN *screen); void help (CDKENTRY *entry); void loadHistory (struct history_st *history); void saveHistory (struct history_st *history, int count); /* * Define callback prototypes. */ BINDFN_PROTO(viewHistoryCB); BINDFN_PROTO(swindowHelpCB); BINDFN_PROTO(historyUpCB); BINDFN_PROTO(historyDownCB); BINDFN_PROTO(listHistoryCB); /* * Define Sybase error/message callbacks. This is required by DBLib. */ int err_handler (DBPROCESS *dbProcess, DBINT mesgNumber, int mesgState, int severity, char *mesgText); int msg_handler (DBPROCESS *dbProcess, DBINT mesgNumber, int mesgState, int severity, char *mesgText); /* * Written by: Mike Glover * Purpose: * This creates a very simple interface to Sybase. */ int main (int argc, char **argv) { /* Declare variables. */ CDKSWINDOW *commandOutput = 0; CDKENTRY *commandEntry = 0; DBPROCESS *dbProcess = 0; WINDOW *cursesWin = 0; char *dsquery = 0; char *command = 0; char *prompt = 0; char *upper = 0; char *login = 0; char *password = 0; char *server = 0; int count = 0; int width = 0; int ret = 0; struct history_st history; char *mesg[5], temp[1000]; /* Set up the history. */ GPCurrentDatabase = copyChar ("master"); history.used = 0; history.current = 0; history.count = 0; /* Check the command line for options. */ while (1) { /* Are there any more command line options to parse. */ if ((ret = getopt (argc, argv, "p:U:P:S:h")) == -1) { break; } switch (ret) { case 'p': prompt = copyChar (optarg); break; case 'U': login = copyChar (optarg); break; case 'P': password = copyChar (optarg); break; case 'S': server = copyChar (optarg); break; case 'h': printf ("Usage: %s %s\n", argv[0], GPUsage); ExitProgram (EXIT_SUCCESS); break; } } /* Set up the command prompt. */ if (prompt == 0) { if (server == 0) { if ((dsquery = getenv ("DSQUERY")) != 0) { sprintf (temp, "[%s] Command >", dsquery); prompt = copyChar (temp); } else { prompt = copyChar ("Command >"); } } else { sprintf (temp, "[%s] Command >", server); prompt = copyChar (temp); } } /* Set up CDK. */ cursesWin = initscr(); GPCdkScreen = initCDKScreen (cursesWin); /* Start color. */ initCDKColor(); /* Initialize DB-Library. */ if (dbinit() == FAIL) { mesg[0] = "Fatal Error"; mesg[1] = "Could not connect to the Sybase database."; popupLabel (GPCdkScreen, mesg, 2); ExitProgram (EXIT_FAILURE); } /* Load the history. */ loadHistory (&history); /* Create the scrolling window. */ commandOutput = newCDKSwindow (GPCdkScreen, CENTER, TOP, -8, -2, "Command Output Window", MAXWIDTH, TRUE, FALSE); /* Create the entry field. */ width = COLS - strlen (prompt) - 1; commandEntry = newCDKEntry (GPCdkScreen, CENTER, BOTTOM, 0, prompt, A_BOLD|COLOR_PAIR(8), COLOR_PAIR(24)|'_', vMIXED, width, 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, CTRL('^'), &listHistoryCB, &history); bindCDKObject (vENTRY, commandEntry, KEY_TAB, &viewHistoryCB, commandOutput); bindCDKObject (vSWINDOW, commandOutput, '?', swindowHelpCB, commandEntry); /* Draw the screen. */ refreshCDKScreen (GPCdkScreen); /* Display the introduction window. */ intro (GPCdkScreen); /* Make them login first. */ dbProcess = sybaseLogin (GPCdkScreen, login, password, 3); if (dbProcess == 0) { destroyCDKScreen (GPCdkScreen); endCDK (); ExitProgram (EXIT_FAILURE); } /* Do this forever. */ for (;;) { /* Get the command. */ command = activateCDKEntry (commandEntry, 0); /* Strip off leading and trailing white space. */ stripWhiteSpace (vBOTH, command); /* Upper case the command. */ 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) { /* Save the history. */ saveHistory (&history, 100); /* Exit. */ dbclose (dbProcess); dbexit(); /* All done. */ destroyCDKEntry (commandEntry); destroyCDKSwindow (commandOutput); freeChar (upper); endCDK(); ExitProgram (EXIT_SUCCESS); } else if (strcmp (command, "login") == 0) { DBPROCESS *newLogin = sybaseLogin (GPCdkScreen, 0, 0, 3); if (newLogin == 0) { addCDKSwindow (commandOutput, "Login Error: Could not switch to new user.", BOTTOM); } else { /* Close the old connection. */ dbclose (dbProcess); dbProcess = newLogin; /* Add a message to the scrolling window. */ addCDKSwindow (commandOutput, "Logged into database as new user.", BOTTOM); count = 0; } } else if (strcmp (command, "logout") == 0) { /* Close the old connection. */ dbclose (dbProcess); dbProcess = 0; /* Add a message to the scrolling window. */ addCDKSwindow (commandOutput, "Logged out.", BOTTOM); count = 0; } else if (strcmp (command, "clear") == 0) { /* Clear the scrolling window. */ cleanCDKSwindow (commandOutput); } else if (strcmp (command, "history") == 0) { listHistoryCB (vENTRY, (void *)commandEntry, (void *)&history, 0); } else if (strcmp (command, "tables") == 0) { /* Check if we are logged in. */ if (dbProcess == 0) { addCDKSwindow (commandOutput, "You must login first.", BOTTOM); } else { sprintf (command, "select * from sysobjects where type = 'U'"); /* Put the command into the ISQL buffer. */ dbcmd (dbProcess, command); /* Put the command into the scrolling window. */ sprintf (temp, "%d> %s", count+1, command); addCDKSwindow (commandOutput, temp, BOTTOM); /* Increment the counter. */ count++; } } else if (strcmp (command, "help") == 0) { /* Display the help. */ help(commandEntry); } else if (command[0] == 'u' && command[1] == 's' && command[2] == 'e' && command[3] == ' ') { /* They want to use a database. */ useDatabase (commandOutput, dbProcess, command); count = 0; } else if (strcmp (command, "go") == 0) { /* Check if we are logged in. */ if (dbProcess == 0) { addCDKSwindow (commandOutput, "You must login first.", BOTTOM); } else { /* Put the command into the scrolling window. */ sprintf (temp, "%d> %s", count+1, command); addCDKSwindow (commandOutput, temp, BOTTOM); count = 0; /* Run the command. */ runIsqlCommand (GPCdkScreen, commandOutput, dbProcess); } } else { /* Check if we are logged in. */ if (dbProcess == 0) { addCDKSwindow (commandOutput, "You must login first.", BOTTOM); } else { /* Put the command into the ISQL buffer. */ dbcmd (dbProcess, command); /* Put the command into the scrolling window. */ sprintf (temp, "%d> %s", count+1, command); addCDKSwindow (commandOutput, temp, BOTTOM); /* Increment the counter. */ count++; } } /* Keep the history. */ history.used = CDKallocStrings(&(history.cmd_history), command, history.count++, history.used); history.current = history.count; /* Clear the entry field. */ cleanCDKEntry (commandEntry); /* Free up the memory used by the upper pointer. */ freeChar (upper); } } /* * This lets a person 'use' a database. */ void useDatabase (CDKSWINDOW *swindow, DBPROCESS *dbProc, char *command) { char *database = 0; char temp[256]; char **words; int wordCount, x; /* Split the command line up and get the database name. */ words = CDKsplitString (command, ' '); wordCount = CDKcountStrings (words); /* Look for the name. */ for (x=1; x < wordCount; x++) { if (strlen (words[x]) != 0) { database = copyChar (words[x]); } } CDKfreeStrings(words); /* Try to actually use the database. */ if (dbuse(dbProc, database) == FAIL) { /* We aren't allowed to use that database. */ sprintf (temp, "Command: %s", command); addCDKSwindow (swindow, temp, BOTTOM); addCDKSwindow (swindow, "Error You are not allowed to use that database.", BOTTOM); return; } /* Set the global database name. */ if (database == 0) { /* Put a syntax error in the scrolling window. */ sprintf (temp, "Command: %s", command); addCDKSwindow (swindow, temp, BOTTOM); addCDKSwindow (swindow, "Error Syntax Error", BOTTOM); return; } /* Clear out the old database name and set the new one. */ freeChar (GPCurrentDatabase); GPCurrentDatabase = database; /* Add a message into the scrolling window. */ sprintf (temp, "Command: %s", command); addCDKSwindow (swindow, temp, BOTTOM); sprintf (temp, "Default Database set to %s", GPCurrentDatabase); addCDKSwindow (swindow, temp, BOTTOM); } /* * This does the requisite checking for failed login attempts. */ DBPROCESS *sybaseLogin (CDKSCREEN *screen, char *accountName, char *accountPassword, int attemptCount) { DBPROCESS *dbProcess = 0; char *login = accountName; char *password = accountPassword; int count = 0; int lines = 0; char *mesg[5]; /* Give them X attempts, then kick them out. */ while (count < attemptCount) { /* Try to login. */ dbProcess = loginToSybase (GPCdkScreen, login, password); /* * If the dbprocess is null the account/password * pair does not exist. */ if (dbProcess == 0) { /* * If the login and account names were provided, * set them to null and allow the user to enter * the name and password by hand. */ login = 0; password = 0; /* Spit out the login error message. */ lines = 0; mesg[lines++] = "Login Error"; mesg[lines++] = " "; mesg[lines++] = "The login/password pair does not exist."; mesg[lines++] = " "; mesg[lines++] = "Please try again."; popupLabel (GPCdkScreen, mesg, lines); eraseCDKScreen (GPCdkScreen); refreshCDKScreen (GPCdkScreen); count++; } else { break; } } /* Did we expire the login attempts? */ if (count > attemptCount-1) { lines = 0; mesg[lines++] = "Login Error"; mesg[lines++] = " "; mesg[lines++] = "Too many attempyts to login."; mesg[lines++] = "Exiting."; popupLabel (GPCdkScreen, mesg, lines); return 0; } return dbProcess; } /* * Let the user login. */ DBPROCESS *loginToSybase (CDKSCREEN *screen, char *accountName, char *accountPassword) { CDKENTRY *loginEntry = 0; CDKENTRY *passwordEntry = 0; LOGINREC *dbLogin = 0; char *hostAccount = 0; char *login = accountName; char *password = accountPassword; char *mesg[10], temp[256]; /* Draw the screen. */ refreshCDKScreen (screen); /* Define the login entry field. */ if (login == 0) { loginEntry = newCDKEntry (screen, CENTER, CENTER, "\nSybase Login\n", "Account Name: ", A_BOLD|COLOR_PAIR(8), COLOR_PAIR(24)|'_', vMIXED, 20, 1, 20, TRUE, FALSE); /* Use the current account name as the default answer. */ hostAccount = getlogin(); setCDKEntryValue (loginEntry, hostAccount); /* Get the login. */ while (1) { /* Redraw the screen. */ eraseCDKScreen (ScreenOf(loginEntry)); refreshCDKScreen (ScreenOf(loginEntry)); /* Get the login to the sybase account. */ login = copyChar (activateCDKEntry (loginEntry, 0)); /* Check if they hit escape. */ if (loginEntry->exitType == vESCAPE_HIT) { mesg[0] = "Error"; mesg[1] = "A user name must be provided."; popupLabel (screen, mesg, 2); } else { break; } } /* Destroy the widget. */ destroyCDKEntry (loginEntry); } /* Get the password if we need too. */ if (password == 0) { sprintf (temp, "\n%s's Password\n", login); passwordEntry = newCDKEntry (screen, CENTER, CENTER, temp, "Account Password: ", A_BOLD|COLOR_PAIR(8), COLOR_PAIR(24)|'_', vHMIXED, 20, 0, 20, TRUE, FALSE); setCDKEntryHiddenChar (passwordEntry, '*'); /* Get the password. (the account may not have a password.) */ password = copyChar (activateCDKEntry (passwordEntry, 0)); if ((passwordEntry->exitType == vESCAPE_HIT) || (strlen(password) == 0)) { password = ""; } /* Destroy the widget. */ destroyCDKEntry (passwordEntry); } /* * Try to connect to the database and get a LOGINREC structre. */ if ((dbLogin = dblogin()) == 0) { mesg[0] = "Fatal Error"; mesg[1] = "Could not connect to the Sybase database."; popupLabel (screen, mesg, 2); refreshCDKScreen (screen); ExitProgram (EXIT_FAILURE); } /* * Set the login and password and try to login to the database. */ DBSETLUSER (dbLogin, login); DBSETLPWD (dbLogin, password); DBSETLAPP (dbLogin, "cdk_syb"); /* Create a dbprocess structure to communicate with the database. */ return dbopen (dbLogin, 0); } /* * This actually runs the command. */ void runIsqlCommand (CDKSCREEN *screen, CDKSWINDOW *swindow, DBPROCESS *dbProcess) { /* Declare local variables. */ RETCODE returnCode; int rowCount; /* Add in a output seperation line. */ addCDKSwindow (swindow, "<#HL(5)> Start of Output <#HL(5)>", BOTTOM); /* Run the command. */ dbsqlexec (dbProcess); /* Check the return code of the commands. */ while ((returnCode = dbresults (dbProcess)) != NO_MORE_RESULTS) { if (returnCode == FAIL) { /* Oops, the command bombed. */ addCDKSwindow (swindow, "Command failed.", BOTTOM); } else { if (!(DBCMDROW (dbProcess))) { /* The command could not return any rows. */ addCDKSwindow (swindow, "Command could not return rows.", BOTTOM); } else { /* * The command returned some rows, print out the title. */ char *row = assembleTitle (dbProcess); addCDKSwindow (swindow, row, BOTTOM); freeChar (row); /* For each row returned, assemble the info. */ rowCount = 0; while (dbnextrow (dbProcess) != NO_MORE_ROWS) { row = assembleRow (dbProcess); addCDKSwindow (swindow, row, BOTTOM); freeChar (row); } } } } /* Add in a output seperation line. */ addCDKSwindow (swindow, "<#HL(5)> End of Output <#HL(5)>", BOTTOM); addCDKSwindow (swindow, "", BOTTOM); /* Can the query... */ dbcanquery (dbProcess); } /* * This creates a single line from the column widths and values. */ char *assembleTitle (DBPROCESS *dbProc) { char *colName = 0; int colWidth = 0; int colNameLen = 0; int colCount = dbnumcols (dbProc); int x = 0; char temp[MAXWIDTH]; char row[MAXWIDTH]; /* Clean the row out. */ memset (row, '\0', MAXWIDTH); /* Start assembling the row. */ for (x=1; x <= colCount; x++) { colName = dbcolname (dbProc, x); colWidth = getColWidth (dbProc, x); colNameLen = strlen (colName); /* If we need to pad, then pad. */ if (colNameLen < colWidth) { /* Create a string the same length as the col width. */ memset (temp, '\0', MAXWIDTH); memset (temp, ' ', (colWidth-colNameLen)); /* Copy the name. */ sprintf (row, "%s %s%s", row, colName, temp); } else { /* Copy the name. */ sprintf (row, "%s %s", row, colName); } } return copyChar (row); } /* * This assembles a single row. */ char *assembleRow (DBPROCESS *dbProcess) { char *dataValue = 0; int colCount = dbnumcols (dbProcess); int columnType = 0; int colWidth = 0; int valueLen = 0; char value[MAXWIDTH]; char temp[MAXWIDTH]; char row[MAXWIDTH]; char format[20]; int x; /* Clean out the row. */ memset (row, '\0', MAXWIDTH); /* Start assembling the row. */ for (x=1; x <= colCount; x++) { columnType = (int)dbcoltype (dbProcess, x); colWidth = (int)getColWidth (dbProcess, x); valueLen = (int)dbdatlen (dbProcess, x); /* Check the column type. */ if (columnType == SYBINT1) { DBINT object_id = *((DBINT *)dbdata(dbProcess, x)); sprintf (format, "%%-%dd", colWidth); sprintf (value, format, (int)object_id); } else if (columnType == SYBINT2) { DBINT object_id = *((DBINT *)dbdata(dbProcess, x)); sprintf (format, "%%-%dd", colWidth); sprintf (value, format, (int)object_id); } else if (columnType == SYBINT4) { DBINT object_id = *((DBINT *)dbdata(dbProcess, x)); sprintf (format, "%%-%dd", colWidth); sprintf (value, format, (int)object_id); } else if (columnType == SYBREAL) { DBREAL object_id = *((DBREAL *)dbdata(dbProcess, x)); sprintf (format, "%%-%d.2f", colWidth); sprintf (value, format, object_id); } else if (columnType == SYBFLT8) { DBFLT8 object_id = *((DBFLT8 *)dbdata(dbProcess, x)); sprintf (format, "%%-%d.2f", colWidth); sprintf (value, format, object_id); } else { if (valueLen <= 0) { strcpy (value, " "); } else { memset (value, '\0', MAXWIDTH); dataValue = (DBCHAR *)dbdata (dbProcess, x); strncpy (value, dataValue, valueLen); } } /* If we need to pad, then pad. */ if (valueLen < colWidth) { /* Copy the value into the string. */ memset (temp, '\0', MAXWIDTH); memset (temp, ' ', (colWidth-valueLen)); sprintf (row, "%s %s%s", row, value, temp); } else { sprintf (row, "%s %s", row, value); } } return copyChar (row); } /* * This function returns the correct width of a column, taking * into account the width of the title, the width of the data * element. */ int getColWidth (DBPROCESS *dbProcess, int col) { char *colName = dbcolname (dbProcess, col); int colNameLen = strlen(colName); int colWidth = dbcollen (dbProcess, col); int columnType = (int)dbcoltype (dbProcess, col); /* If the colType is int/real/float adjust accordingly. */ if (columnType == SYBINT1 || columnType == SYBINT2 || columnType == SYBINT4) { colWidth = 5; } else if (columnType == SYBREAL || columnType == SYBFLT8) { colWidth = 8; } /* Is the name of the column wider than the col width? */ if (colNameLen >= colWidth) { return (colNameLen+1); } return colWidth; } /* * This callback allows the user to play with the scrolling window. */ int viewHistoryCB (EObjectType cdktype, void *object, void *clientData, chtype key) { CDKSWINDOW *swindow = (CDKSWINDOW *)clientData; CDKENTRY *entry = (CDKENTRY *)object; /* Let them play... */ activateCDKSwindow (swindow, 0); /* Redraw the entry field. */ drawCDKEntry (entry, ObjOf(entry)->box); return (TRUE); } /* * This displays a little introduction screen. */ void intro (CDKSCREEN *screen) { int lines = 0; char *mesg[10]; /* Create the message. */ mesg[lines++] = ""; mesg[lines++] = "Sybase Command Interface"; mesg[lines++] = "Written by Mike Glover"; mesg[lines++] = ""; mesg[lines++] = "Type help to get help."; /* Display the message. */ popupLabel (screen, mesg, lines); } /* * This function displays help. */ void help (CDKENTRY *entry) { int lines = 0; char *mesg[25]; /* Create the help message. */ mesg[lines++] = "Help"; mesg[lines++] = ""; mesg[lines++] = "When in the command line."; mesg[lines++] = " Scrolls back one command."; mesg[lines++] = " Scrolls forward one command."; mesg[lines++] = " Activates the scrolling window."; mesg[lines++] = " Displays this help window."; mesg[lines++] = ""; mesg[lines++] = "When in the scrolling window."; mesg[lines++] = " Loads a file into the window."; mesg[lines++] = " Saves the contents of the window to a file."; mesg[lines++] = " Scrolls up one line."; mesg[lines++] = " Scrolls down one line."; mesg[lines++] = " Scrolls back one page."; mesg[lines++] = " Scrolls forward one page."; mesg[lines++] = " Returns to the command line."; mesg[lines++] = " Displays this help window."; mesg[lines++] = ""; mesg[lines++] = " (Refer to the scrolling window online manual for more help.)"; /* Pop up the help message. */ popupLabel (ScreenOf(entry), mesg, lines); } /* * This converts a word to upper case. */ char *uc (char *word) { int length = strlen (word); char *upper = (char *)malloc (sizeof (char *) * (length+2)); int x; /* Start converting the case. */ for (x=0; x < length; x++) { int ch = (unsigned char)(word[x]); if (isalpha (ch)) { upper[x] = toupper(ch); } else { upper[x] = word[x]; } } upper[length] = '\0'; return upper; } /* * The following two functions are the error and message handler callbacks. * which will be called by Sybase when and error occurs. */ int err_handler (DBPROCESS *dbProcess, DBINT mesgNumber, int mesgState, int severity, char *mesgText) { /* Declare local variables. */ char *mesg[10], temp[256]; int errorCount = 0; /* Check if the process is dead. */ if ((dbProcess == 0) || (DBDEAD(dbProcess))) { mesg[0] = "Database Process Error"; mesg[1] = "The database process seems to have died."; mesg[2] = "Try logging in again with the login command"; popupLabel (GPCdkScreen, mesg, 3); return INT_EXIT; } else { mesg[0] = "DB-Library Error"; sprintf (temp, "%s", dberrstr); mesg[1] = copyChar (temp); errorCount = 2; } /* Display the message if we have an error. */ if (errorCount > 0) { popupLabel (GPCdkScreen, mesg, --errorCount); } /* Clean up. */ if (errorCount == 2) { freeChar (mesg[1]); } return (1); } int mesg_handler (DBPROCESS *dbProcess, DBINT mesgNumber, int mesgState, int severity, char *mesgText) { /* Declare local variables. */ char *mesg[10], temp[256]; /* Create the message. */ mesg[0] = "SQL Server Message"; sprintf (temp, "Message Number %ld", mesgNumber); mesg[1] = copyChar (temp); sprintf (temp, "State %d", mesgState); mesg[2] = copyChar (temp); sprintf (temp, "Severity %d", severity); mesg[3] = copyChar (temp); sprintf (temp, "Message %s", mesgText); mesg[4] = copyChar (temp); popupLabel (GPCdkScreen, mesg, 5); /* Clean up. */ freeChar (mesg[1]); freeChar (mesg[2]); freeChar (mesg[3]); freeChar (mesg[4]); return (1); } /* * This is for the scrolling window help callback. */ int swindowHelpCB (EObjectType cdktype, void *object, void *clientData, chtype key) { CDKENTRY *entry = (CDKENTRY *)clientData; help(entry); return (TRUE); } /* * This is the callback for the down arrow. */ int historyUpCB (EObjectType cdktype, void *object, void *clientData, chtype key) { 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 (TRUE); } /* Decrement the counter. */ history->current--; /* Display the command. */ setCDKEntryValue (entry, history->cmd_history[history->current]); drawCDKEntry (entry, ObjOf(entry)->box); return (TRUE); } /* * This is the callback for the down arrow. */ int historyDownCB (EObjectType cdktype, void *object, void *clientData, chtype key) { 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 (TRUE); } /* 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 (TRUE); } /* Display the command. */ setCDKEntryValue (entry, history->cmd_history[history->current]); drawCDKEntry (entry, ObjOf(entry)->box); return (TRUE); } /* * This callback allows the user to pick from the history list from a * scrolling list. */ int listHistoryCB (EObjectType cdktype, void *object, void *clientData, chtype key) { CDKSCROLL *scrollList = 0; CDKENTRY *entry = (CDKENTRY *)object; struct history_st *history = (struct history_st *) clientData; 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. */ char *mesg[] = {"No Commands Entered", "No History"}; popupLabel (ScreenOf(entry), mesg, 2); /* Redraw the screen. */ eraseCDKEntry (entry); drawCDKScreen (ScreenOf(entry)); /* And leave... */ return (TRUE); } /* Create the scrolling list of previous commands. */ scrollList = newCDKScroll (ScreenOf(entry), CENTER, CENTER, RIGHT, height, -10, "Command History", history->cmd_history, 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->cmd_history[selection]); } /* Redraw the screen. */ eraseCDKEntry (entry); drawCDKScreen (ScreenOf(entry)); return (TRUE); } /* * This loads the history into the editor from the RC file. */ void loadHistory (struct history_st *history) { char *home = 0; char filename[1000]; /* Create the RC filename. */ if ((home = getenv ("HOME")) == 0) { home = "."; } sprintf (filename, "%s/.sybrc", home); /* Set some variables. */ history->current = 0; history->count = 0; /* Read the file. */ if ((history->count = CDKreadFile (filename, &(history->cmd_history))) != -1) { history->current = history->count; } return; } /* * This saves the history into RC file. */ void saveHistory (struct history_st *history, int count) { FILE *fd = 0; char *home = 0; char filename[1000]; int x; /* Create the RC filename. */ if ((home = getenv ("HOME")) == 0) { home = "."; } sprintf (filename, "%s/.sybrc", home); /* Open the file for writing. */ if ((fd = fopen (filename, "w")) == 0) { return; } /* Start saving the history. */ for (x=0; x < history->count; x++) { fprintf (fd, "%s\n", history->cmd_history[x]); } fclose (fd); return; } cdk-5.0-20060507/demos/vinstall.c0000644000175100001440000002764510354232466014671 0ustar tomusers/* $Id: vinstall.c,v 1.13 2005/12/27 12:36:06 tom Exp $ */ #include #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 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) { /* Declare variables. */ WINDOW *cursesWin = 0; 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], **fileList = 0, *mesg[20]; char oldPath[512], newPath[512], temp[2000]; char **files; int count, chunks, 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]); } /* Set up CDK. */ cursesWin = initscr(); cdkScreen = initCDKScreen (cursesWin); /* Start color. */ initCDKColor(); /* Create the title label. */ titleMessage[0] = "<#HL(30)>"; if (title == 0) { sprintf (temp, "CDK Installer"); } else { sprintf (temp, "%.256s", title); } titleMessage[1] = copyChar (temp); titleMessage[2] = "<#HL(30)>"; titleWin = newCDKLabel (cdkScreen, CENTER, TOP, titleMessage, 3, FALSE, FALSE); freeChar (titleMessage[1]); /* 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, "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, "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++) { /* * 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 = CDKcountStrings (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, "Error: Can not open source file \"%.256s\"", oldPath); errors++; } else if (ret == vCanNotOpenDest) { sprintf (temp, "Error: Can not open destination file \"%.256s\"", newPath); errors++; } else { sprintf (temp, "%.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. */ char *buttons[] = {"Look At Errors Now", "Save Output To A File", "Ignore Errors"}; mesg[0] = "There were errors in the installation."; mesg[1] = "If you want, you may scroll through the"; mesg[2] = "messages of the scrolling window to see"; mesg[3] = "what the errors were. If you want to save"; mesg[4] = "the output of the window you may press s"; mesg[5] = "while in the window, or you may save the output"; mesg[6] = "of the install now and look at the install"; mesg[7] = "history at a later date."; /* Popup the dialog box. */ ret = popupDialog (cdkScreen, mesg, 8, buttons, 3); if (ret == 0) { activateCDKSwindow (installOutput, 0); } else if (ret == 1) { 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) { char *buttons[] = {"No", "Yes"}; mesg[0] = "Do you want to save the output of the"; mesg[1] = "scrolling window to a file?"; if (popupDialog (cdkScreen, mesg, 2, buttons, 2) == 1) { 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) { char *buttons[] = {"Yes", "No"}; int status = 0; mode_t dirMode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH; struct stat fileStat; char *mesg[10]; char *error[10]; char temp[512]; /* Stat the directory. */ if (lstat (directory, &fileStat) != 0) { /* The directory does not exist. */ if (errno == ENOENT) { /* Create the question. */ mesg[0] = "The directory "; sprintf (temp, "%.256s", directory); mesg[1] = copyChar (temp); mesg[2] = "Does not exist. Do you want to"; mesg[3] = "create it?"; /* Ask them if they want to create the directory. */ if (popupDialog (cdkScreen, mesg, 4, buttons, 2) == 0) { /* Create the directory. */ if (mkdir (directory, dirMode) != 0) { /* Create the error message. */ error[0] = "Could not create the directory"; sprintf (temp, "%.256s", directory); error[1] = copyChar (temp); #ifdef HAVE_STRERROR sprintf (temp, "%.256s", strerror (errno)); #else sprintf (temp, "Check the permissions and try again."); #endif error[2] = copyChar (temp); /* Pop up the error message. */ popupLabel (cdkScreen, error, 3); /* Clean up and set the error status. */ freeChar (error[1]); freeChar (error[2]); status = -1; } } else { /* Create the message. */ error[0] = "Installation aborted."; /* Pop up the error message. */ popupLabel (cdkScreen, error, 1); /* Set the exit status. */ status = -1; } /* Clean up. */ freeChar (mesg[1]); } } return status; } cdk-5.0-20060507/demos/rolodex.h0000644000175100001440000000573010354232314014475 0ustar tomusers/* $Id: rolodex.h,v 1.9 2005/12/27 12:34:20 tom Exp $ */ #include #include #include #include #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 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, 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, char *filename, char *printer); cdk-5.0-20060507/demos/fileview.c0000644000175100001440000000762510354302072014632 0ustar tomusers/* $Id: fileview.c,v 1.10 2005/12/27 18:13:14 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName="codeViewer"; #endif /* * This program demonstrates the file selector and the viewer widget. */ int main (int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKVIEWER *example = 0; CDKFSELECT *fSelect = 0; WINDOW *cursesWin = 0; char *title = "Pick a file."; char *label = "File: "; char *directory = "."; char *filename = 0; char **info = 0; char *button[5], vtitle[256], *mesg[4], temp[256]; int selected, lines, ret; /* Parse up the command line. */ while (1) { 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] = ""; button[1] = ""; /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start color. */ initCDKColor(); /* Get the filename. */ if (filename == 0) { fSelect = newCDKFselect (cdkscreen, CENTER, CENTER, 20, 65, title, label, A_NORMAL, '_', A_REVERSE, "", "", "", "", 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, "", "", "", "", 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] = "Escape hit. No file selected."; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, 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, 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 ("Oops. 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) { printf ("Could not open %s\n", filename); ExitProgram (EXIT_FAILURE); } /* Set up the viewer title, and the contents to the widget. */ sprintf (vtitle, "%20s", filename); setCDKViewer (example, vtitle, 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] = "Escape hit. No Button selected."; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (example->exitType == vNORMAL) { sprintf (temp, "You selected button %d", selected); mesg[0] = copyChar (temp); mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); free (mesg[0]); } /* Clean up. */ destroyCDKViewer (example); destroyCDKScreen (cdkscreen); CDKfreeStrings (info); freeChar (filename); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/demos/serial.c0000644000175100001440000001320410354232466014276 0ustar tomusers/* $Id: serial.c,v 1.6 2005/12/27 12:36:06 tom Exp $ */ #include #include #include #include #include #include #include #include #include #include #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; WINDOW *cursesWin = 0; int lines = 0; char *info[256], temp[256]; struct termios termInfo; int ret; /* Set the deault values. */ strcpy (port, DEFAULT_PORT); /* Parse up the command line. */ while (1) { 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; } } /* * Create the CDK screen. */ cursesWin = initscr(); cdkScreen = initCDKScreen (cursesWin); /* Start CDK color. */ initCDKColor(); /* * Set the title of the main window. */ sprintf (temp, "Serial Port Monitor (%s)", port); info[lines++] = copyChar (temp); info[lines++] = copyChar ("<#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, "Serial Port Monitor (%s)", port); info[lines++] = copyChar (temp); info[lines++] = copyChar ("<#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; } cdk-5.0-20060507/demos/clock.c0000644000175100001440000000371210354301426014106 0ustar tomusers/* $Id: clock.c,v 1.8 2005/12/27 18:08:22 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName="label_ex"; #endif int main (int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKLABEL *demo = 0; WINDOW *cursesWin = 0; int boxLabel = 0; char *mesg[4], temp[256]; struct tm *currentTime; time_t clck; int ret; /* Parse up the command line. */ while ((ret = getopt (argc, argv, "b")) != -1) { switch (ret) { case 'b' : boxLabel = 1; } } /* Set up CDK */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Colors */ initCDKColor(); /* Set the labels up. */ mesg[0] = "HH:MM:SS"; /* Declare the labels. */ demo = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 1, boxLabel, FALSE); /* Is the label null??? */ if (demo == 0) { /* Clean up the memory. */ destroyCDKScreen (cdkscreen); /* End curses... */ endCDK(); /* Spit out a message. */ printf ("Oops. Can't seem to 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 { /* Get the current time. */ time(&clck); currentTime = localtime (&clck); /* Put the current time in a string. */ sprintf (temp, "%02d:%02d:%02d", currentTime->tm_hour, currentTime->tm_min, currentTime->tm_sec); mesg[0] = copyChar (temp); /* Set the label contents. */ setCDKLabel (demo, mesg, 1, ObjOf(demo)->box); /* Clean up the memory used. */ freeChar (mesg[0]); /* 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); } cdk-5.0-20060507/demos/command.c0000644000175100001440000002622510354301752014437 0ustar tomusers/* $Id: command.c,v 1.16 2005/12/27 18:11:54 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName="command"; #endif /* Define some global variables. */ #define MAXHISTORY 5000 static char *introductionMessage[] = { "Little Command Interface", "", "Written by Mike Glover", "", "Type help 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) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKSWINDOW *commandOutput = 0; CDKENTRY *commandEntry = 0; WINDOW *cursesWin = 0; chtype *convert = 0; char *command = 0; char *upper = 0; char *prompt = "Command >"; char *title = "Command Output Window"; int promptLen = 0; int commandFieldWidth = 0; struct history_st history; char temp[600]; int ret, junk; /* Set up the history. */ history.current = 0; history.count = 0; /* Check the command line for options. */ while (1) { /* 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; } } /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* 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, introductionMessage, 5); eraseCDKEntry (commandEntry); /* Do this forever. */ for (;;) { /* 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: %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, "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. */ char *mesg[] = {"No Commands Entered", "No History"}; popupLabel (ScreenOf(entry), 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, "Command History", 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) { char *mesg[25]; /* Create the help message. */ mesg[0] = "Help"; mesg[1] = ""; mesg[2] = "When in the command line."; mesg[3] = " Displays the command history."; mesg[4] = " Displays the command history."; mesg[5] = " Scrolls back one command."; mesg[6] = " Scrolls forward one command."; mesg[7] = " Activates the scrolling window."; mesg[8] = " Displays this help window."; mesg[9] = ""; mesg[10] = "When in the scrolling window."; mesg[11] = " Loads a file into the window."; mesg[12] = " Saves the contents of the window to a file."; mesg[13] = " Scrolls up one line."; mesg[14] = " Scrolls down one line."; mesg[15] = " Scrolls back one page."; mesg[16] = " Scrolls forward one page."; mesg[17] = " Returns to the command line."; mesg[18] = ""; mesg[19] = " (Refer to the scrolling window online manual for more help.)"; popupLabel (ScreenOf(entry), 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 = strlen (word); /* Get the memory for the new word. */ upper = (char *)malloc (sizeof (char *) * (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] = toupper(ch); } else { upper[x] = word[x]; } } upper[length] = '\0'; return upper; } cdk-5.0-20060507/demos/stopSign.c0000644000175100001440000000400010355076265014623 0ustar tomusers/* $Id: stopSign.c,v 1.9 2005/12/30 00:17:57 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName="sillyness_ex"; #endif int main(void) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKLABEL *stopSign = 0; CDKLABEL *title = 0; WINDOW *cursesWin = 0; int currentLight = 0; char *mesg[5], *sign[4]; chtype key; boolean functionKey; /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Colors. */ initCDKColor(); /* Set the labels up. */ mesg[0] = "<#HL(40)>"; mesg[1] = "Press r for the red light"; mesg[2] = "Press y for the yellow light"; mesg[3] = "Press g for the green light"; mesg[4] = "<#HL(40)>"; sign[0] = " <#DI> "; sign[1] = " <#DI> "; sign[2] = " <#DI> "; /* Declare the labels. */ title = newCDKLabel (cdkscreen, CENTER, TOP, mesg, 5, FALSE, FALSE); stopSign = newCDKLabel (cdkscreen, CENTER, CENTER, sign, 3, TRUE, TRUE); /* Do this until they hit q or escape. */ for (;;) { drawCDKLabel (title, FALSE); drawCDKLabel (stopSign, TRUE); key = getchCDKObject (ObjOf(stopSign), &functionKey); if (key == KEY_ESC || key == 'q' || key == 'Q') { break; } else if (key == 'r' || key == 'R') { sign[0] = " <#DI> "; sign[1] = " o "; sign[2] = " o "; currentLight = 0; } else if (key == 'y' || key == 'Y') { sign[0] = " o "; sign[1] = " <#DI> "; sign[2] = " o "; currentLight = 1; } else if (key == 'g' || key == 'G') { sign[0] = " o "; sign[1] = " o "; sign[2] = " <#DI> "; currentLight = 2; } /* Set the contents of the label and re-draw it. */ setCDKLabel (stopSign, sign, 3, TRUE); } /* Clean up. */ destroyCDKLabel (title); destroyCDKLabel (stopSign); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/demos/rolodex.c0000644000175100001440000014563610355351160014504 0ustar tomusers/* $Id: rolodex.c,v 1.20 2005/12/31 00:36:00 tom Exp $ */ #include "rolodex.h" #ifdef HAVE_XCURSES char *XCursesProgramName="rolodex"; #endif /* * This is the main part of the loop. */ int main(void) { /* Declare variables. */ CDKSCREEN *cdkscreen; CDKMENU *rolodexMenu; CDKLABEL *rolodexTitle; SRolodex groupList[MAXGROUPS]; WINDOW *cursesWin; char *menulist[MAX_MENU_ITEMS][MAX_SUB_ITEMS], *title[5]; char *home, temp[256], *mesg[15]; int subMenuSize[10], menuLocations[10], selection; int group, ret, x; int groupCount = 0; /* Set up CDK */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK color. */ initCDKColor(); /* Create the menu lists. */ menulist[0][0] = "File";menulist[1][0] = "Groups"; menulist[0][1] = "Open ";menulist[1][1] = "New "; menulist[0][2] = "Save ";menulist[1][2] = "Open "; menulist[0][3] = "Save As";menulist[1][3] = "Delete"; menulist[0][4] = "Quit "; menulist[2][0] = "Print";menulist[3][0] = "Help"; menulist[2][1] = "Print Groups";menulist[3][1] = "About Rolodex "; menulist[3][2] = "Rolodex Statistics"; /* Set up the sub-menu sizes and their locations. */ subMenuSize[0] = 5;menuLocations[0] = LEFT; subMenuSize[1] = 4;menuLocations[1] = LEFT; subMenuSize[2] = 2;menuLocations[2] = LEFT; subMenuSize[3] = 3;menuLocations[3] = RIGHT; /* Create the menu. */ rolodexMenu = newCDKMenu (cdkscreen, menulist, 4, subMenuSize, menuLocations, TOP, A_BOLD|A_UNDERLINE, A_REVERSE); /* Create the title. */ title[0]= "Cdk Rolodex"; title[1]= "Written by Mike Glover"; rolodexTitle = newCDKLabel (cdkscreen, CENTER, CENTER, title, 2, FALSE, FALSE); /* Define the help key binding. */ bindCDKObject (vMENU, rolodexMenu, '?', helpCB, 0); /* Draw the CDK screen. */ refreshCDKScreen (cdkscreen); /* Check the value of the HOME env var. */ home = getenv ("HOME"); if (home != 0) { /* Make sure the $HOME/.rolodex directory exists. */ sprintf (temp, "%s/.rolodex", home); /* Set the value of the global rolodex DBM directory. */ GDBMDir = copyChar (temp); /* Set the value of the global RC filename. */ sprintf (temp, "%s/.rolorc", home); GRCFile = copyChar (temp); } else { /* Set the value of the global rolodex DBM directory. */ GDBMDir = copyChar (".rolodex"); /* Set the value of the global RC filename. */ GRCFile = copyChar (".rolorc"); } /* Make the rolodex directory. */ mkdir (GDBMDir, 0755); /* Open the rolodex RC file. */ groupCount = readRCFile (GRCFile, groupList); /* Check the value of groupCount. */ if (groupCount < 0) { /* The RC file seems to be corrupt. */ sprintf (temp, "The RC file (%s) seems to be corrupt.", GRCFile); mesg[0] = copyChar (temp); mesg[1] = "No rolodex groups were loaded."; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); freeChar (mesg[0]); groupCount = 0; } else if (groupCount == 0) { mesg[0] = "Empty rolodex RC file. No groups loaded."; mesg[1] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 2); } else { if (groupCount == 1) { sprintf (temp, "There was 1 group loaded from the RC file."); } else { sprintf (temp, "There were %d groups loaded from the RC file.", groupCount); } mesg[0] = copyChar (temp); mesg[1] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 2); freeChar (mesg[0]); } /* Loop until we are done. */ for (;;) { /* Activate the menu */ selection= activateCDKMenu (rolodexMenu, 0); /* Check the return value of the selection. */ if (selection == 0) { /* Open the rolodex RC file. */ groupCount = openNewRCFile (cdkscreen, groupList, groupCount); } else if (selection == 1) { /* Write out the RC file. */ ret = writeRCFile (cdkscreen, GRCFile, groupList, groupCount); /* Reset the saved flag if the rc file saved ok. */ if (ret != 0) { GGroupModified = 0; } } else if (selection == 2) { /* Save as. */ ret = writeRCFileAs (cdkscreen, groupList, groupCount); /* Reset the saved flag if the rc file saved ok. */ if (ret != 0) { GGroupModified = 0; } } else if (selection == 3) { /* Has anything changed??? */ if (GGroupModified != 0) { /* Write out the RC file. */ writeRCFile (cdkscreen, GRCFile, groupList, groupCount); } /* Remove the CDK widget pointers. */ destroyCDKMenu (rolodexMenu); destroyCDKLabel (rolodexTitle); destroyCDKScreen (cdkscreen); /* Free up other pointers. */ freeChar (GCurrentGroup); freeChar (GRCFile); freeChar (GDBMDir); /* Clean up the group information. */ for (x=0; x < groupCount; x++) { freeChar (groupList[x].name); freeChar (groupList[x].desc); freeChar (groupList[x].dbm); } /* Shutdown CDK. */ endCDK(); /* Exit cleanly. */ ExitProgram (EXIT_SUCCESS); } else if (selection == 100) { /* Add a new group to the list. */ groupCount = addRolodexGroup (cdkscreen, groupList, groupCount); } else if (selection == 101) { /* If there are no groups, ask them if they want to create a new one. */ if (groupCount == 0) { char *buttons[] = {"", ""}; mesg[0] = "There are no groups defined."; mesg[1] = "Do you want to define a new group?"; /* Add the group if they said yes. */ if (popupDialog (cdkscreen, mesg, 2, buttons, 2) == 0) { groupCount = addRolodexGroup (cdkscreen, groupList, groupCount); } } else { /* Get the number of the group to open. */ group = pickRolodexGroup (cdkscreen, "Open Rolodex Group", groupList, groupCount); /* Make sure a group was picked. */ if (group >= 0) { /* Set the global variable GCurrentGroup */ freeChar (GCurrentGroup); GCurrentGroup = copyChar (groupList[group].name); /* Try to open the DBM file and read the contents. */ useRolodexGroup (cdkscreen, groupList[group].name, groupList[group].desc, groupList[group].dbm); } } } else if (selection == 102) { /* Delete the group chosen. */ groupCount = deleteRolodexGroup (cdkscreen, groupList, groupCount); } else if (selection == 200) { /* Print Phone Number Group. */ printGroupNumbers (cdkscreen, groupList, groupCount); } else if (selection == 300) { /* About Rolodex. */ aboutCdkRolodex(cdkscreen); } else if (selection == 301) { displayRolodexStats (ScreenOf(rolodexMenu), groupCount); } } } /* * This writes out the new RC file. */ int writeRCFile (CDKSCREEN *screen, char *filename, SRolodex *groupList, int groupCount) { /* Declare local variables. */ char *mesg[5], temp[256]; time_t clck; FILE *fd; int x; /* Can we open the file? */ if ((fd = fopen (filename, "w")) == 0) { /* Pop up a message. */ sprintf (temp, "The file <%s> could not be opened.", filename); mesg[0] = copyChar (temp); #ifdef HAVE_STRERROR sprintf (temp, "%s", strerror(errno)); #else sprintf (temp, "Unknown reason."); #endif mesg[1] = copyChar (temp); mesg[2] = "Press any key to continue."; popupLabel (screen, mesg, 3); freeChar (mesg[0]); freeChar (mesg[1]); return (0); } /* Get the current time. */ time(&clck); /* Put some comments at the top of the header. */ fprintf (fd, "#\n"); fprintf (fd, "# This file was automatically generated on %s", ctime(&clck)); fprintf (fd, "#\n"); /* Start writing the RC file. */ for (x=0; x < groupCount; x++) { fprintf (fd, "%s%c%s%c%s\n", groupList[x].name, CTRL('V'), groupList[x].desc, CTRL('V'), groupList[x].dbm); } fclose (fd); /* Pop up a message stating that it has been saved. */ if (groupCount == 1) { sprintf (temp, "There was 1 group saved to file"); mesg[0] = copyChar (temp); } else { sprintf (temp, "There were %d groups saved to file", groupCount); mesg[0] = copyChar (temp); } sprintf (temp, "%s", filename); mesg[1] = copyChar (temp); mesg[2] = "Press any key to continue."; popupLabel (screen, mesg, 3); freeChar (mesg[0]); freeChar (mesg[1]); return (1); } /* * This allows the user to pick a DBM file to open. */ int pickRolodexGroup (CDKSCREEN *screen, char *title, SRolodex *groupList, int groupCount) { /* Declare local variables. */ CDKSCROLL *roloList = 0; int height = groupCount; char *mesg[MAXGROUPS], temp[256]; int selection, x; /* Determine the height of the scrolling list. */ if (groupCount > 5) { height = 5; } height += 3; /* Copy the names of the scrolling list into an array. */ for (x=0; x < groupCount; x++) { sprintf (temp, "%s", groupList[x].name); mesg[x] = copyChar (temp); } /* Create the scrolling list. */ roloList = newCDKScroll (screen, CENTER, CENTER, NONE, height, 50, title, mesg, groupCount, NONUMBERS, A_REVERSE, TRUE, FALSE); /* Create a callback to the scrolling list. */ bindCDKObject (vSCROLL, roloList, '?', groupInfoCB, groupList); /* Activate the scrolling list. */ selection = activateCDKScroll (roloList, 0); /* Destroy the scrolling list. */ destroyCDKScroll (roloList); for (x=0; x < groupCount; x++) { freeChar (mesg[x]); } /* Return the item selected. */ return selection; } /* * This allows the user to add a rolo group to the list. */ int addRolodexGroup (CDKSCREEN *screen, SRolodex *groupList, int groupCount) { /* Declare local variables. */ CDKENTRY *newName= 0; CDKENTRY *newDesc= 0; char *mesg[4], *desc, *newGroupName, temp[256]; int x; /* Create the name widget. */ newName = newCDKEntry (screen, CENTER, 8, "New Group Name", " Name: ", A_NORMAL, '_', vMIXED, 20, 2, 256, TRUE, FALSE); /* Get the name. */ newGroupName = activateCDKEntry (newName, 0); /* Make sure they didn't hit escape. */ if (newName->exitType == vESCAPE_HIT) { mesg[0] = "Add Group Canceled."; destroyCDKEntry (newName); popupLabel (screen, mesg, 1); return groupCount; } /* Make sure that group name does not already exist. */ for (x=0; x < groupCount; x++) { if (strcmp (newGroupName, groupList[x].name) == 0) { sprintf (temp, "Sorry the group (%s) already exists.", newGroupName); mesg[0] = copyChar (temp); popupLabel (screen, mesg, 1); freeChar (mesg[0]); destroyCDKEntry (newName); return groupCount; } } /* Keep the name. */ groupList[groupCount].name = copyChar (newGroupName); /* Create the description widget. */ newDesc = newCDKEntry (screen, CENTER, 13, "Group Description", "Descriprion: ", A_NORMAL, '_', vMIXED, 20, 2, 256, TRUE, FALSE); /* Get the description. */ desc = activateCDKEntry (newDesc, 0); /* Check if they hit escape or not. */ if (newDesc->exitType == vESCAPE_HIT) { groupList[groupCount].desc = copyChar ("No Description Provided."); } else { groupList[groupCount].desc = copyChar (desc); } /* Create the DBM filename. */ sprintf (temp, "%s/%s.phl", GDBMDir, groupList[groupCount].name); groupList[groupCount].dbm = copyChar (temp); /* Inrement the group count. */ groupCount++; GGroupModified = 1; /* Destroy the widgets. */ destroyCDKEntry (newName); destroyCDKEntry (newDesc); return groupCount; } /* * This displays rolodex information. */ void displayRolodexStats (CDKSCREEN *screen, int groupCount) { /* Declare local variables. */ char *mesg[6], temp[256]; /* Create the information to display. */ sprintf (temp, "Rolodex Statistics"); mesg[0] = copyChar (temp); sprintf (temp, "Read Command Filename %s", GRCFile); mesg[1] = copyChar (temp); sprintf (temp, "Group Count %d", groupCount); mesg[2] = copyChar (temp); /* Display the message. */ popupLabel (screen, mesg, 3); /* Clean up. */ freeChar (mesg[0]); freeChar (mesg[1]); freeChar (mesg[2]); } /* * This function gets a new rc filename and saves the contents of the * groups under that name. */ int writeRCFileAs (CDKSCREEN *screen, SRolodex *groupList, int groupCount) { /* Declare local variables. */ CDKENTRY *newRCFile; char *newFilename; int ret; /* Create the entry field. */ newRCFile = newCDKEntry (screen, CENTER, CENTER, "Save As", "Filename: ", A_NORMAL, '_', vMIXED, 20, 2, 256, TRUE, FALSE); /* Add a pre-process function so no spaces are introduced. */ setCDKEntryPreProcess (newRCFile, entryPreProcessCB, 0); /* Get the filename. */ newFilename = activateCDKEntry (newRCFile, 0); /* Check if they hit escape or not. */ if (newRCFile->exitType == vESCAPE_HIT) { destroyCDKEntry (newRCFile); return 1; } /* Call the function to save the RC file. */ ret = writeRCFile (screen, newFilename, groupList, groupCount); /* Reset the saved flag if the rc file saved ok. */ if (ret != 0) { /* Change the default filename. */ freeChar (GRCFile); GRCFile = copyChar (newFilename); GGroupModified = 0; } /* Clean up. */ destroyCDKEntry (newRCFile); return 1; } /* * This opens a new RC file. */ int openNewRCFile (CDKSCREEN *screen, SRolodex *groupList, int groupCount) { /* Declare local variables. */ CDKFSELECT *fileSelector; char *filename, *mesg[10], temp[256]; int x; /* Get the filename. */ fileSelector = newCDKFselect (screen, CENTER, CENTER, 20, 55, "Open RC File", "Filename: ", A_NORMAL, '.', A_REVERSE, "", "", "", "", TRUE, FALSE); /* Activate the file selector. */ filename = activateCDKFselect (fileSelector, 0); /* Check if the file selector left early. */ if (fileSelector->exitType == vESCAPE_HIT) { destroyCDKFselect (fileSelector); mesg[0] = "Open New RC File Aborted."; popupLabel (screen, mesg, 1); return groupCount; } /* Clean out the old information. */ for (x=0; x < groupCount; x++) { freeChar (groupList[x].name); freeChar (groupList[x].desc); freeChar (groupList[x].dbm); } /* Open the RC file. */ groupCount = readRCFile (filename, groupList); /* Check the return value. */ if (groupCount < 0) { /* This file does not appear to be a rolodex file. */ mesg[0] = "The file"; sprintf (temp, "(%s)", filename); mesg[1] = copyChar (temp); mesg[2] = "does not seem to be a rolodex RC file."; mesg[3] = "Press any key to continue."; popupLabel (screen, mesg, 4); freeChar (mesg[1]); groupCount = 0; } /* Clean up. */ destroyCDKFselect (fileSelector); return groupCount; } /* * This reads the users rc file. */ int readRCFile (char *filename, SRolodex *groupList) { /* Declare variables. */ int groupsFound = 0; int errorsFound = 0; char **lines = 0; char **items; int linesRead, chunks, x; /* Open the file and start reading. */ linesRead = CDKreadFile (filename, &lines); /* Check the number of lines read. */ if (linesRead == 0) { return (0); } /* * Cycle through what was given to us and save it. */ for (x=0; x < linesRead; x++) { /* Strip white space from the line. */ stripWhiteSpace (vBOTH, lines[x]); /* Only split lines which do not start with a # */ if (strlen (lines[x]) != 0 && lines[x][0] != '#') { items = CDKsplitString (lines[x], CTRL('V')); chunks = CDKcountStrings (items); /* Only take the ones which fit the format. */ if (chunks == 3) { /* Clean off the name and DB name. */ stripWhiteSpace (vBOTH, items[0]); stripWhiteSpace (vBOTH, items[1]); stripWhiteSpace (vBOTH, items[2]); /* Set the group name and DB name. */ groupList[groupsFound].name = items[0]; groupList[groupsFound].desc = items[1]; groupList[groupsFound].dbm = items[2]; groupsFound++; free(items); } else { CDKfreeStrings(items); errorsFound++; } } } /* Clean up. */ CDKfreeStrings(lines); /* Check the number of groups to the number of errors. */ if (errorsFound > 0 && groupsFound == 0) { /* This does NOT look like the rolodex RC file. */ return -1; } return groupsFound; } /* * This function allows the user to add/delete/modify/save the * contents of a rolodex group. */ void useRolodexGroup (CDKSCREEN *screen, char *groupName, char *groupDesc GCC_UNUSED, char *groupDBM) { /* Declare local variables. */ CDKSCROLL *nameList= 0; CDKLABEL *helpWindow = 0; SPhoneData phoneData; SPhoneRecord *phoneRecord; char *Index[MAX_ITEMS], *title[3], *mesg[3], temp[256]; int phoneCount, selection, height, x; /* Set up the help window at the bottom of the screen. */ title[0] = "<#HL(30)>"; title[1] = "Press ? to get detailed help."; title[2] = "<#HL(30)>"; helpWindow= newCDKLabel (screen, CENTER, BOTTOM, title, 3, FALSE, FALSE); drawCDKLabel (helpWindow, FALSE); /* Open the DBM file and read in the contents of the file */ phoneCount = readPhoneDataFile (groupDBM, &phoneData); phoneData.recordCount = phoneCount; /* Check the number of entries returned. */ if (phoneCount == 0) { /* * They tried to open an empty group, maybe they want to * add a new entry to this number. */ char *buttons[] = {"", ""}; mesg[0] = "There were no entries in this group."; mesg[1] = "Do you want to add a new listng?"; if (popupDialog (screen, mesg, 2, buttons, 2) == 1) { destroyCDKLabel (helpWindow); return; } /* Get the information for a new number. */ if (addPhoneRecord (screen, &phoneData) != 0) { return; } } else if (phoneCount < 0) { mesg[0] = "Could not open the database for this group."; popupLabel (screen, mesg, 1); destroyCDKLabel (helpWindow); return; } /* Set up the data needed for the scrolling list. */ for (x=0; x < phoneData.recordCount; x++) { phoneRecord = &phoneData.record[x]; sprintf (temp, "%s (%s)", phoneRecord->name, GLineType[phoneRecord->lineType]); Index[x] = copyChar (temp); } sprintf (temp, "Listing of Group %s", groupName); height = (phoneData.recordCount > 5 ? 8 : phoneData.recordCount+3); /* Create the scrolling list. */ nameList = newCDKScroll (screen, CENTER, CENTER, RIGHT, height, 50, temp, Index, phoneData.recordCount, NUMBERS, A_REVERSE, TRUE, FALSE); /* Clean up. */ for (x=0; x < phoneData.recordCount; x++) { freeChar (Index[x]); } /* Create key bindings. */ bindCDKObject (vSCROLL, nameList, 'i', insertPhoneEntryCB, &phoneData); bindCDKObject (vSCROLL, nameList, 'd', deletePhoneEntryCB, &phoneData); bindCDKObject (vSCROLL, nameList, KEY_DC, deletePhoneEntryCB, &phoneData); bindCDKObject (vSCROLL, nameList, '?', phoneEntryHelpCB, 0); /* Let them play. */ selection = 0; while (selection >= 0) { /* Get the information they want to view. */ selection = activateCDKScroll (nameList, 0); /* Display the information. */ if (selection >= 0) { /* Display the information. */ displayPhoneInfo (screen, phoneData.record[selection]); } } /* Save the rolodex information to file. */ if (savePhoneDataFile (groupDBM, &phoneData) == 0) { /* Something happened. */ mesg[0] = "Could not save phone data to data file."; mesg[1] = "All changes have been lost."; popupLabel (screen, mesg, 2); } /* Clean up. */ for (x=0; x < phoneData.recordCount; x++) { freeChar (phoneData.record[x].name); freeChar (phoneData.record[x].phoneNumber); freeChar (phoneData.record[x].address); freeChar (phoneData.record[x].city); freeChar (phoneData.record[x].province); freeChar (phoneData.record[x].postalCode); freeChar (phoneData.record[x].desc); } destroyCDKScroll (nameList); destroyCDKLabel (helpWindow); } /* * This opens a phone data file and returns the number of elements read. */ int readPhoneDataFile (char *dataFile, SPhoneData *phoneData) { /* Declare variables. */ char **lines = 0; char **items; int linesRead = 0; int chunks= 0; int linesFound = 0; int x; /* Open the file and start reading. */ linesRead = CDKreadFile (dataFile, &lines); /* Check the number of lines read. */ if (linesRead <= 0) { return (0); } /* * Cycle through what was given to us and save it. */ for (x=0; x < linesRead; x++) { if (lines[x][0] != '#') { /* Split the string. */ items = CDKsplitString (lines[x], CTRL('V')); chunks = CDKcountStrings (items); /* Copy the chunks. */ if (chunks == 8) { phoneData->record[linesFound].name = items[0]; phoneData->record[linesFound].lineType = atoi (items[1]); phoneData->record[linesFound].phoneNumber = items[2]; phoneData->record[linesFound].address = items[3]; phoneData->record[linesFound].city = items[4]; phoneData->record[linesFound].province = items[5]; phoneData->record[linesFound].postalCode = items[6]; phoneData->record[linesFound].desc = items[7]; freeChar (items[1]); free (items); linesFound++; } else { /* Bad line in the file; recover the memory. */ CDKfreeStrings(items); } } } /* Clean up. */ CDKfreeStrings(lines); /* Keep the record count and return. */ phoneData->recordCount = linesFound; return linesFound; } /* * This opens a phone data file and returns the number of elements read. */ int savePhoneDataFile (char *filename, SPhoneData *phoneData) { /* Declare variables. */ SPhoneRecord *phoneRecord; time_t clck; FILE *fd; int x; /* Can we open the file? */ if ((fd = fopen (filename, "w")) == 0) { return 0; } /* Get the current time. */ time(&clck); /* Add the header to the file. */ fprintf (fd, "#\n"); fprintf (fd, "# This file was automatically saved on %s", ctime(&clck)); fprintf (fd, "# There should be %d phone numbers in this file.\n", phoneData->recordCount); fprintf (fd, "#\n"); /* Cycle through the data and start writing it to the file. */ for (x=0; x < phoneData->recordCount; x++) { /* Get a pointer to the object. */ phoneRecord = &phoneData->record[x]; /* Check the phone type. */ if (phoneRecord->lineType == vCell || phoneRecord->lineType == vPager) { fprintf (fd, "%s%c%d%c%s%c-%c-%c-%c-%c%s\n", phoneRecord->name, CTRL('V'), phoneRecord->lineType, CTRL('V'), phoneRecord->phoneNumber, CTRL('V'), CTRL('V'), CTRL('V'), CTRL('V'), CTRL('V'), phoneRecord->desc); } else { fprintf (fd, "%s%c%d%c%s%c%s%c%s%c%s%c%s%c%s\n", phoneRecord->name, CTRL('V'), phoneRecord->lineType, CTRL('V'), phoneRecord->phoneNumber, CTRL('V'), phoneRecord->address, CTRL('V'), phoneRecord->city, CTRL('V'), phoneRecord->province, CTRL('V'), phoneRecord->postalCode, CTRL('V'), phoneRecord->desc); } } fclose (fd); return 1; } /* * This displays the information about the phone record. */ void displayPhoneInfo (CDKSCREEN *screen, SPhoneRecord record) { /* Declare local variables. */ char *mesg[10], temp[256]; /* Check the type of line it is. */ if (record.lineType == vVoice || record.lineType == vData1 || record.lineType == vData2 || record.lineType == vData3 || record.lineType == vFAX1 || record.lineType == vFAX2 || record.lineType == vFAX3) { /* Create the information to display. */ sprintf (temp, "%s Phone Record", GLineType[record.lineType]); mesg[0] = copyChar (temp); sprintf (temp, "Name %s", record.name); mesg[1] = copyChar (temp); sprintf (temp, "Phone Number%s", record.phoneNumber); mesg[2] = copyChar (temp); sprintf (temp, "Address %s", record.address); mesg[3] = copyChar (temp); sprintf (temp, "City %s", record.city); mesg[4] = copyChar (temp); sprintf (temp, "Province %s", record.province); mesg[5] = copyChar (temp); sprintf (temp, "Postal Code %s", record.postalCode); mesg[6] = copyChar (temp); sprintf (temp, "Comment %s", record.desc); mesg[7] = copyChar (temp); /* Pop the information up on the screen. */ popupLabel (screen, mesg, 8); /* Clean up. */ freeChar (mesg[0]); freeChar (mesg[1]); freeChar (mesg[2]); freeChar (mesg[3]); freeChar (mesg[4]); freeChar (mesg[5]); freeChar (mesg[6]); freeChar (mesg[7]); } else if (record.lineType == vPager || record.lineType == vCell) { /* Create the information to display. */ sprintf (temp, "%s Phone Record", GLineType[record.lineType]); mesg[0] = copyChar (temp); sprintf (temp, "Name %s", record.name); mesg[1] = copyChar (temp); sprintf (temp, "Phone Number%s", record.phoneNumber); mesg[2] = copyChar (temp); sprintf (temp, "Comment %s", record.desc); mesg[3] = copyChar (temp); /* Pop the information up on the screen. */ popupLabel (screen, mesg, 4); /* Clean up. */ freeChar (mesg[0]); freeChar (mesg[1]); freeChar (mesg[2]); freeChar (mesg[3]); } else { mesg[0] = "Error Unknown Phone Line Type"; mesg[1] = "Can not display information."; popupLabel (screen, mesg, 2); } } /* * This function displays a little pop up window discussing this demo. */ void aboutCdkRolodex (CDKSCREEN *screen) { char *mesg[15]; mesg[0] = "About Cdk Rolodex"; mesg[1] = " "; mesg[2] = "This demo was written to demonstrate the widgets"; mesg[3] = "available with the Cdk library. Not all of the"; mesg[4] = "Cdk widgets are used, but most of them have been."; mesg[5] = "I hope this little demonstration helps give you an"; mesg[6] = "understanding of what the Cdk library offers."; mesg[7] = " "; mesg[8] = "Have fun with it."; mesg[9] = " "; mesg[10] = "ttfn,"; mesg[11] = "Mike"; mesg[12] = "<#HL(35)>"; mesg[13] = "March 1996"; popupLabel (screen, mesg, 14); } /* * This deletes a rolodex group. */ int deleteRolodexGroup (CDKSCREEN *screen, SRolodex *groupList, int groupCount) { /* Declare local variables. */ char *mesg[10], *buttons[5], temp[256]; int selection, choice, x; /* If there are no groups, pop up a message telling them. */ if (groupCount == 0) { mesg[0] = "Error"; mesg[1] = "There as no groups defined."; popupLabel (screen, mesg, 2); /* Return the current group count. */ return groupCount; } /* Get the number of the group to delete. */ selection = pickRolodexGroup (screen, "Delete Which Rolodex Group?", groupList, groupCount); /* Check the results. */ if (selection < 0) { mesg[0] = " Delete Canceled "; mesg[1] = "No Group Deleted"; popupLabel (screen, mesg, 2); return groupCount; } /* Let's make sure they want to delete the group. */ mesg[0] = "Confirm Delete"; mesg[1] = "Are you sure you want to delete the group"; sprintf (temp, "%s?", groupList[selection].name); mesg[2] = copyChar (temp); buttons[0] = ""; buttons[1] = ""; choice = popupDialog (screen, mesg, 3, buttons, 2); freeChar (mesg[2]); /* Check the results of the confirmation. */ if (choice == 0) { mesg[0] = " Delete Canceled "; mesg[1] = "No Group Deleted"; popupLabel (screen, mesg, 2); return groupCount; } /* We need to delete the group file first. */ unlink (groupList[selection].dbm); /* OK, lets delete the group. */ freeChar (groupList[selection].name); freeChar (groupList[selection].desc); freeChar (groupList[selection].dbm); for (x=selection; x < groupCount-1; x++) { groupList[x].name = groupList[x+1].name; groupList[x].desc = groupList[x+1].desc; groupList[x].dbm = groupList[x+1].dbm; } groupCount--; GGroupModified = 1; /* Clean up. */ return groupCount; } /* * This function gets information about a new phone number. */ int addPhoneRecord (CDKSCREEN *screen, SPhoneData *phoneData) { /* Declare local variables. */ CDKLABEL *title; CDKITEMLIST *itemList; SPhoneRecord *phoneRecord; char *titleMesg[3], *types[GLINETYPECOUNT], temp[256]; int ret, x; /* Get the phone record pointer. */ phoneRecord = &phoneData->record[phoneData->recordCount]; /* Create a title label to display. */ titleMesg[0] = "Add New Phone Record"; title = newCDKLabel (screen, CENTER, TOP, titleMesg, 1, FALSE, FALSE); drawCDKLabel (title, FALSE); /* Create the phone line type list. */ for (x=0; x < GLINETYPECOUNT; x++) { sprintf (temp, "%s", GLineType[x]); types[x] = copyChar (temp); } /* Get the phone line type. */ itemList = newCDKItemlist (screen, CENTER, CENTER, "What Type Of Line Is It?", "Type: ", types, GLINETYPECOUNT, 0, TRUE, FALSE); phoneRecord->lineType = activateCDKItemlist (itemList, 0); destroyCDKItemlist (itemList); /* Clean up. */ for (x=0; x < GLINETYPECOUNT; x++) { freeChar (types[x]); } /* Check the return code of the line type question. */ if (phoneRecord->lineType == -1) { phoneRecord->lineType = (ELineType) 0; return 1; } else if (phoneRecord->lineType == vPager || phoneRecord->lineType == vCell) { ret = getSmallPhoneRecord (screen, phoneRecord); } else { ret = getLargePhoneRecord (screen, phoneRecord); } /* Check the return value from the getXXXPhoneRecord function.*/ if (ret == 0) { phoneData->recordCount++; } /* Clean up. */ destroyCDKLabel (title); /* Return the new phone list count. */ return ret; } /* * This gets a phone record with all of the details. */ int getLargePhoneRecord (CDKSCREEN *screen, SPhoneRecord *phoneRecord) { /* Declare local variables. */ CDKENTRY *nameEntry, *addressEntry, *cityEntry; CDKENTRY *provEntry, *postalEntry, *descEntry; CDKTEMPLATE *phoneTemplate; char *buttons[5], *mesg[15]; int ret; /* Define the widgets. */ nameEntry = newCDKEntry (screen, LEFT, 5, 0, "Name: ", A_NORMAL, '_', vMIXED, 20, 2, 256, TRUE, FALSE); addressEntry = newCDKEntry (screen, RIGHT, 5, 0, "Address: ", A_NORMAL, '_', vMIXED, 40, 2, 256, TRUE, FALSE); cityEntry = newCDKEntry (screen, LEFT, 8, 0, "City: ", A_NORMAL, '_', vMIXED, 20, 2, 256, TRUE, FALSE); provEntry = newCDKEntry (screen, 29, 8, 0, "Province: ", A_NORMAL, '_', vMIXED, 15, 2, 256, TRUE, FALSE); postalEntry = newCDKEntry (screen, RIGHT, 8, 0, "Postal Code: ", A_NORMAL, '_', vUMIXED, 8, 2, 256, TRUE, FALSE); phoneTemplate = newCDKTemplate (screen, LEFT, 11, 0, "Number: ", "(###) ###-####", "(___) ___-____", TRUE, FALSE); descEntry = newCDKEntry (screen, RIGHT, 11, 0, "Description: ", A_NORMAL, '_', vMIXED, 20, 2, 256, TRUE, FALSE); /* Get the phone information. */ for (;;) { /* Draw the widgets on the screen. */ drawCDKEntry (nameEntry, ObjOf(nameEntry)->box); drawCDKEntry (addressEntry, ObjOf(addressEntry)->box); drawCDKEntry (cityEntry, ObjOf(cityEntry)->box); drawCDKEntry (provEntry, ObjOf(provEntry)->box); drawCDKEntry (postalEntry, ObjOf(postalEntry)->box); drawCDKTemplate (phoneTemplate, ObjOf(phoneTemplate)->box); drawCDKEntry (descEntry, ObjOf(descEntry)->box); /* Activate the entries to get the information. */ phoneRecord->name = copyChar (activateCDKEntry (nameEntry, 0)); phoneRecord->address = copyChar (activateCDKEntry (addressEntry, 0)); phoneRecord->city = copyChar (activateCDKEntry (cityEntry, 0)); phoneRecord->province = copyChar (activateCDKEntry (provEntry, 0)); phoneRecord->postalCode = copyChar (activateCDKEntry (postalEntry, 0)); activateCDKTemplate (phoneTemplate, 0); phoneRecord->phoneNumber = mixCDKTemplate (phoneTemplate); phoneRecord->desc = copyChar (activateCDKEntry (descEntry, 0)); /* Determine if the user wants to submit the info. */ mesg[0] = "Confirm New Phone Entry"; mesg[1] = "Do you want to add this phone number?"; buttons[0] = ""; buttons[1] = ""; buttons[2] = ""; ret = popupDialog (screen, mesg, 2, buttons, 3); /* Check the response of the popup dialog box. */ if (ret == 0) { /* The user wants to submit the information. */ destroyCDKEntry (nameEntry); destroyCDKEntry (addressEntry); destroyCDKEntry (cityEntry); destroyCDKEntry (provEntry); destroyCDKEntry (postalEntry); destroyCDKEntry (descEntry); destroyCDKTemplate (phoneTemplate); return ret; } else if (ret == 1) { /* The user does not want to submit the information. */ freeChar (phoneRecord->name); freeChar (phoneRecord->address); freeChar (phoneRecord->city); freeChar (phoneRecord->province); freeChar (phoneRecord->postalCode); freeChar (phoneRecord->phoneNumber); freeChar (phoneRecord->desc); destroyCDKEntry (nameEntry); destroyCDKEntry (addressEntry); destroyCDKEntry (cityEntry); destroyCDKEntry (provEntry); destroyCDKEntry (postalEntry); destroyCDKEntry (descEntry); destroyCDKTemplate (phoneTemplate); return ret; } else { /* The user wants to edit the information again. */ freeChar (phoneRecord->name); freeChar (phoneRecord->address); freeChar (phoneRecord->city); freeChar (phoneRecord->province); freeChar (phoneRecord->postalCode); freeChar (phoneRecord->phoneNumber); freeChar (phoneRecord->desc); } } } /* * This gets a small phone record. */ int getSmallPhoneRecord (CDKSCREEN *screen, SPhoneRecord *phoneRecord) { /* Declare local variables. */ CDKENTRY *nameEntry, *descEntry; CDKTEMPLATE *phoneTemplate; char *buttons[5], *mesg[15]; int ret; /* Define the widgets. */ nameEntry = newCDKEntry (screen, CENTER, 8, 0, "Name: ", A_NORMAL, '_', vMIXED, 20, 2, 256, TRUE, FALSE); phoneTemplate = newCDKTemplate (screen, CENTER, 11, 0, "Number: ", "(###) ###-####", "(___) ___-____", TRUE, FALSE); descEntry = newCDKEntry (screen, CENTER, 14, 0, "Description: ", A_NORMAL, '_', vMIXED, 20, 2, 256, TRUE, FALSE); /* Get the phone information. */ for (;;) { /* Draw the widgets on the screen. */ drawCDKEntry (nameEntry, ObjOf(nameEntry)->box); drawCDKTemplate (phoneTemplate, ObjOf(phoneTemplate)->box); drawCDKEntry (descEntry, ObjOf(descEntry)->box); /* Activate the entries to get the information. */ phoneRecord->name = copyChar (activateCDKEntry (nameEntry, 0)); activateCDKTemplate (phoneTemplate, 0); phoneRecord->phoneNumber = mixCDKTemplate (phoneTemplate); phoneRecord->desc = copyChar (activateCDKEntry (descEntry, 0)); phoneRecord->address = copyChar ("-"); phoneRecord->city = copyChar ("-"); phoneRecord->province = copyChar ("-"); phoneRecord->postalCode = copyChar ("-"); /* Determine if the user wants to submit the info. */ mesg[0] = "Confirm New Phone Entry"; mesg[1] = "Do you want to add this phone number?"; buttons[0] = ""; buttons[1] = ""; buttons[2] = ""; ret = popupDialog (screen, mesg, 2, buttons, 3); /* Check the response of the popup dialog box. */ if (ret == 0) { /* The user wants to submit the information. */ destroyCDKEntry (nameEntry); destroyCDKEntry (descEntry); destroyCDKTemplate (phoneTemplate); return ret; } else if (ret == 1) { /* The user does not want to submit the information. */ freeChar (phoneRecord->name); freeChar (phoneRecord->phoneNumber); freeChar (phoneRecord->desc); freeChar (phoneRecord->address); freeChar (phoneRecord->city); freeChar (phoneRecord->province); freeChar (phoneRecord->postalCode); destroyCDKEntry (nameEntry); destroyCDKEntry (descEntry); destroyCDKTemplate (phoneTemplate); return ret; } else { /* The user wants to edit the information again. */ freeChar (phoneRecord->name); freeChar (phoneRecord->phoneNumber); freeChar (phoneRecord->desc); freeChar (phoneRecord->address); freeChar (phoneRecord->city); freeChar (phoneRecord->province); freeChar (phoneRecord->postalCode); } } } /* * This prints a groups phone numbers. */ void printGroupNumbers (CDKSCREEN *screen, SRolodex *groupList, int groupCount) { /* Declare local variables. */ CDKSELECTION *selectionList; CDKENTRY *entry; CDKLABEL *title; char *itemList[MAX_ITEMS], *mesg[10], temp[256]; char *choices[] = {"Print to Printer ", "Print to File", "Don't Print"}; char *filename = 0; char *printer = 0; char *defaultPrinter = 0; int height = groupCount; int x; /* Create the group list. */ for (x=0; x < groupCount; x++) { itemList[x] = copyChar (groupList[x].name); } /* Set the height of the selection list. */ if (groupCount > 5) { height = 5; } height += 3; /* Create the selection list. */ selectionList = newCDKSelection (screen, CENTER, CENTER, RIGHT, height, 40, "Select Which Groups To Print", itemList, groupCount, choices, 3, A_REVERSE, TRUE, FALSE); /* Activate the selection list. */ if (activateCDKSelection (selectionList, 0) == -1) { /* Tell the user they exited early. */ destroyCDKSelection (selectionList); mesg[0] = "Print Canceled."; popupLabel (screen, mesg, 1); /* Clean up. */ for (x=0; x < groupCount; x++) { freeChar (itemList[x]); } return; } eraseCDKSelection (selectionList); /* Determine which groups we want to print. */ for (x=0; x < groupCount; x++) { if (selectionList->selections[x] == 0) { /* Create a title. */ sprintf (temp, "Printing Group [%s] to Printer", groupList[x].name); mesg[0] = copyChar (temp); title = newCDKLabel (screen, CENTER, TOP, mesg, 1, FALSE, FALSE); drawCDKLabel (title, FALSE); freeChar (mesg[0]); /* Get the printer name to print to. */ entry = newCDKEntry (screen, CENTER, 8, 0, "Printer Name: ", A_NORMAL, '_', vMIXED, 20, 2, 256, TRUE, FALSE); /* Set the printer name to the default printer. */ defaultPrinter = getenv("PRINTER"); setCDKEntry (entry, defaultPrinter, 2, 256, TRUE); printer = copyChar (activateCDKEntry (entry, 0)); destroyCDKEntry (entry); /* Print the group. */ if (printGroup (groupList[x], "/tmp/rolodex.tmp", printer) == 0) { /* The group could not be printed. */ sprintf (temp, "Sorry the group '%s' could not be printed.", groupList[x].name); mesg[0] = strdup (temp); popupLabel (screen, mesg, 1); freeChar (mesg[0]); } /* Clean up. */ destroyCDKLabel (title); freeChar (printer); unlink ("/tmp/rolodex.tmp"); } else if (selectionList->selections[x] == 1) { /* Create a title. */ sprintf (temp, "Printing Group [%s] to File", groupList[x].name); mesg[0] = copyChar (temp); title = newCDKLabel (screen, CENTER, TOP, mesg, 1, FALSE, FALSE); drawCDKLabel (title, FALSE); freeChar (mesg[0]); /* Get the filename to print to. */ entry = newCDKEntry (screen, CENTER, 8, 0, "Filename: ", A_NORMAL, '_', vMIXED, 20, 2, 256, TRUE, FALSE); filename = copyChar (activateCDKEntry (entry, 0)); destroyCDKEntry (entry); /* Print the group. */ if (printGroup (groupList[x], filename, printer) == 0) { /* The group could not be printed. */ sprintf (temp, "Sorry the group '%s' could not be printed.", groupList[x].name); mesg[0] = strdup (temp); popupLabel (screen, mesg, 1); freeChar (mesg[0]); } /* Clean up. */ destroyCDKLabel (title); freeChar (filename); } } /* Clean up. */ destroyCDKSelection (selectionList); for (x=0; x < groupCount; x++) { freeChar (itemList[x]); } } /* * This actually prints the phone record. */ int printGroup (SRolodex groupRecord, char *filename, char *printer) { /* Declare local variables. */ uid_t uid = getuid(); char tempFilename[256], command[256]; SPhoneData phoneData; SPhoneRecord *phoneRecord; int phoneCount, x; FILE *fd; /* Read the data file. */ phoneCount = readPhoneDataFile (groupRecord.dbm, &phoneData); /* Create the temporary filename. */ if (filename != 0) { sprintf (tempFilename, "%s", filename); } else { sprintf (tempFilename, "/tmp/rolodex.%d", (int)uid); } /* Open the file. */ if ((fd = fopen (tempFilename, "a+")) == 0) { /* Clean up. */ for (x=0; x < phoneCount; x++) { freeChar (phoneData.record[x].name); freeChar (phoneData.record[x].phoneNumber); freeChar (phoneData.record[x].address); freeChar (phoneData.record[x].city); freeChar (phoneData.record[x].province); freeChar (phoneData.record[x].postalCode); freeChar (phoneData.record[x].desc); } return 0; } /* Start writing the group information to the temp file. */ fprintf (fd, "Group Name: %40s\n", groupRecord.name); fprintf (fd, "==============================================================================\n"); for (x=0; x < phoneCount; x++) { phoneRecord = &phoneData.record[x]; fprintf (fd, "Name : %s\n", phoneRecord->name); fprintf (fd, "Phone Number: %s (%s)\n", phoneRecord->phoneNumber, GLineType[phoneRecord->lineType]); if (phoneRecord->lineType != vPager && phoneRecord->lineType != vCell) { fprintf (fd, "Address : %-20s, %-20s\n", phoneRecord->address, phoneRecord->city); fprintf (fd, " : %-10s, %-10s\n", phoneRecord->province, phoneRecord->postalCode); } fprintf (fd, "Description : %-30s\n", phoneRecord->desc); fprintf (fd, "------------------------------------------------------------------------------\n"); } /* Determine if the information is going to a file or printer. */ if (printer != 0) { /* Print the file to the given printer. */ sprintf (command, "lpr -P%s %s", printer, tempFilename); system (command); /* We have to unlkink the temp file. */ unlink (tempFilename); } /* Clean up some memory. */ for (x=0; x < phoneCount; x++) { freeChar (phoneData.record[x].name); freeChar (phoneData.record[x].phoneNumber); freeChar (phoneData.record[x].address); freeChar (phoneData.record[x].city); freeChar (phoneData.record[x].province); freeChar (phoneData.record[x].postalCode); freeChar (phoneData.record[x].desc); } /* Close the filename. */ fclose (fd); return 1; } /* **************************************************************** * Start of callback functions. **************************************************************** */ int entryPreProcessCB (EObjectType cdkType GCC_UNUSED, void *object GCC_UNUSED, void *clientData GCC_UNUSED, chtype input) { if (input == ' ') { Beep(); return 0; } return 1; } /* * This allows the user to insert a new phone entry into the database. */ int insertPhoneEntryCB (EObjectType cdkType GCC_UNUSED, void *object, void *clientData, chtype key GCC_UNUSED) { /* Declare local variables. */ CDKSCROLL *scrollp= (CDKSCROLL *)object; SPhoneData *phoneData= (SPhoneData *)clientData; SPhoneRecord *phoneRecord= &phoneData->record[phoneData->recordCount]; char temp[256]; /* Make the scrolling list disappear. */ eraseCDKScroll (scrollp); /* Call the function which gets phone record information. */ if (addPhoneRecord (ScreenOf(scrollp), phoneData) == 0) { sprintf (temp, "%s (%s)", phoneRecord->name, GLineType[phoneRecord->lineType]); addCDKScrollItem (scrollp, temp); } /* Redraw the scrolling list. */ drawCDKScroll (scrollp, ObjOf(scrollp)->box); return (FALSE); } /* * This allows the user to delete a phone entry from the database. */ int deletePhoneEntryCB (EObjectType cdkType GCC_UNUSED, void *object, void *clientData, chtype key GCC_UNUSED) { /* Declare local variables. */ CDKSCROLL *scrollp = (CDKSCROLL *)object; SPhoneData *phoneData = (SPhoneData *)clientData; char *mesg[3], temp[256], *hold; char *buttons[] = {"", ""}; int position = scrollp->currentItem; int x; /* Make the scrolling list disappear. */ eraseCDKScroll (scrollp); /* Check the number of entries left in the list. */ if (scrollp->listSize == 0) { mesg[0] = "There are no more numbers to delete."; popupLabel (ScreenOf(scrollp), mesg, 1); return (FALSE); } /* Ask the user if they really want to delete the listing. */ mesg[0] = "Do you really want to delete the phone entry"; hold = chtype2Char (scrollp->item[scrollp->currentItem]); sprintf (temp, "%s", hold); freeChar (hold); mesg[1] = copyChar (temp); if (popupDialog (ScreenOf(scrollp), mesg, 2, buttons, 2) == 1) { /* Remove the item from the phone data record. */ for (x=position; x < phoneData->recordCount-1; x++) { phoneData->record[x].name = phoneData->record[x+1].name; phoneData->record[x].lineType = phoneData->record[x+1].lineType; phoneData->record[x].phoneNumber = phoneData->record[x+1].phoneNumber; phoneData->record[x].address = phoneData->record[x+1].address; phoneData->record[x].city = phoneData->record[x+1].city; phoneData->record[x].province = phoneData->record[x+1].province; phoneData->record[x].postalCode = phoneData->record[x+1].postalCode; phoneData->record[x].desc = phoneData->record[x+1].desc; } phoneData->recordCount--; /* Nuke the entry. */ deleteCDKScrollItem (scrollp, position); } freeChar (mesg[1]); /* Redraw the scrolling list. */ drawCDKScroll (scrollp, ObjOf(scrollp)->box); return (FALSE); } /* * This function provides help for the phone list editor. */ int phoneEntryHelpCB (EObjectType cdkType GCC_UNUSED, void *object, void *clientData GCC_UNUSED, chtype key GCC_UNUSED) { /* Declare local variables. */ CDKSCROLL *scrollp = (CDKSCROLL *)object; char *mesg[10], temp[100]; /* Create the help title. */ sprintf (temp, "Rolodex Phone Editor"); mesg[0] = copyChar (temp); sprintf (temp, " Inserts a new phone entry."); mesg[1] = copyChar (temp); sprintf (temp, " Deletes the currently selected phone entry."); mesg[2] = copyChar (temp); sprintf (temp, " Exits the scrolling list."); mesg[3] = copyChar (temp); sprintf (temp, " Pops up this help window."); mesg[4] = copyChar (temp); /* Pop up the message. */ popupLabel (ScreenOf(scrollp), mesg, 5); /* Clean up. */ freeChar (mesg[0]); freeChar (mesg[1]); freeChar (mesg[2]); freeChar (mesg[3]); freeChar (mesg[4]); return (FALSE); } /* * This is a callback to the menu widget. It allows the user to * ask for help about any sub-menu item. */ int helpCB (EObjectType cdkType GCC_UNUSED, void *object, void *clientData GCC_UNUSED, chtype key GCC_UNUSED) { /* Declare local variables. */ CDKMENU *menu= (CDKMENU *)object; int menuList= menu->currentTitle; int submenuList= menu->currentSubtitle; int selection= ((menuList * 100) + submenuList); char *mesg[20], *name, temp[100]; /* Create the help title. */ name = chtype2Char (menu->sublist[menuList][submenuList]); stripWhiteSpace (vBOTH, name); sprintf (temp, "Help %s", name); mesg[0] = copyChar (temp); freeChar (name); /* Set the default value for the message. */ mesg[1] = "No help defined for this menu."; /* Given the current menu item, create a message. */ if (selection == 0) { mesg[1] = "This reads a new rolodex RC file."; } else if (selection == 1) { mesg[1] = "This saves the current group information in the default RC file."; } else if (selection == 2) { mesg[1] = "This saves the current group information in a new RC file."; } else if (selection == 3) { mesg[1] = "This exits this program."; } else if (selection == 100) { mesg[1] = "This creates a new rolodex group."; } else if (selection == 101) { mesg[1] = "This opens a rolodex group."; } else if (selection == 102) { mesg[1] = "This deletes a rolodex group."; } else if (selection == 200) { mesg[1] = "This prints out selected groups phone numbers."; } else if (selection == 300) { mesg[1] = "This gives a little history on this program."; } else if (selection == 301) { mesg[1] = "This provides information about the rolodex."; } /* Pop up the message. */ popupLabel (ScreenOf(menu), mesg, 2); freeChar (mesg[0]); /* Redraw the submenu window. */ drawCDKMenuSubwin (menu); return (FALSE); } /* * This is a callback to the group list scrolling list. */ int groupInfoCB (EObjectType cdkType GCC_UNUSED, void *object, void *clientData, chtype key GCC_UNUSED) { /* Declare local variables. */ CDKSCROLL *scrollp= (CDKSCROLL *)object; SRolodex *groupList= (SRolodex *)clientData; int selection= scrollp->currentItem; char *mesg[5], temp[100]; /* Create the message to be displayed. */ mesg[0] = "Detailed Group Information."; sprintf (temp, "Group Name %s", groupList[selection].name); mesg[1] = copyChar (temp); sprintf (temp, "Group Description %s", groupList[selection].desc); mesg[2] = copyChar (temp); sprintf (temp, "Group Database File %s", groupList[selection].dbm); mesg[3] = copyChar (temp); /* Display the message. */ popupLabel (ScreenOf(scrollp), mesg, 4); freeChar (mesg[1]); freeChar (mesg[2]); freeChar (mesg[3]); /* Redraw the scrolling list. */ drawCDKScroll (scrollp, ObjOf(scrollp)->box); return (FALSE); } cdk-5.0-20060507/demos/appointment.c0000644000175100001440000003240510355313072015353 0ustar tomusers/* $Id: appointment.c,v 1.19 2005/12/30 20:19:06 tom Exp $ */ #include #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) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKCALENDAR *calendar = 0; WINDOW *cursesWin = 0; char *title = "CDK Appointment Book\n<#HL(30)>\n"; char *filename = 0; struct tm *dateInfo = 0; time_t clck = 0; time_t retVal = 0; struct AppointmentInfo appointmentInfo; int day, month, year, ret, x; char temp[1000]; /* * Get the current dates and set the default values for * the day/month/year values for the calendar. */ time (&clck); dateInfo = localtime (&clck); day = dateInfo->tm_mday; month = dateInfo->tm_mon + 1; year = dateInfo->tm_year + 1900; /* Check the command line for options. */ while (1) { /* 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 *home = getenv ("HOME"); if (home != 0) { sprintf (temp, "%s/.appointment", home); } else { strcat (temp, ".appointment"); } filename = copyChar (temp); } /* Read the appointment book information. */ readAppointmentFile (filename, &appointmentInfo); /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* 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 ("Oops. Can't seem to 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. */ retVal = 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) { /* Declare local variables. */ int appointments = 0; int linesRead = 0; int segments = 0; char **lines = 0; char **temp; 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++) { temp = CDKsplitString (lines[x], CTRL('V')); segments = CDKcountStrings (temp); /* * A valid line has 5 elements: * Day, Month, Year, Type, Description. */ if (segments == 5) { 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) atoi (temp[3]); 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'), 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) { CDKCALENDAR *calendar = (CDKCALENDAR *)object; CDKENTRY *entry = 0; CDKITEMLIST *itemlist = 0; 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: ", 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, "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) { CDKCALENDAR *calendar = (CDKCALENDAR *)object; CDKLABEL *label = 0; struct AppointmentInfo *appointmentInfo = (struct AppointmentInfo *)clientData; int found = 0; int day = 0; int month = 0; int year = 0; int mesgLines = 0; 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. */ day = appointmentInfo->appointment[x].day; month = appointmentInfo->appointment[x].month; 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, "Appointment Date: %02d/%02d/%d", day, month, year); mesg[mesgLines++] = copyChar (temp); mesg[mesgLines++] = copyChar (" "); mesg[mesgLines++] = copyChar ("<#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 ("<#HL(35)>"); mesg[mesgLines++] = copyChar (" "); mesg[mesgLines++] = copyChar ("Press space to continue."); found = 1; break; } } /* If we didn't find the marker, create a different message. */ if (found == 0) { sprintf (temp, "There is no appointment for %02d/%02d/%d", calendar->day, calendar->month, calendar->year); mesg[mesgLines++] = copyChar (temp); mesg[mesgLines++] = copyChar ("<#HL(30)>"); mesg[mesgLines++] = copyChar ("Press space to continue."); } /* Create the label widget. */ label = newCDKLabel (ScreenOf(calendar), CENTER, CENTER, 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); } cdk-5.0-20060507/dialog.c0000644000175100001440000003033710426516000013142 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:27:44 $ * $Revision: 1.95 $ */ DeclareCDKObjects(DIALOG, Dialog, setCdk, Int); /* * This function creates a dialog widget. */ CDKDIALOG *newCDKDialog (CDKSCREEN *cdkscreen, int xplace, int yplace, char **mesg, int rows, char **buttonLabel, int buttonCount, chtype highlight, boolean separator, boolean Box, boolean shadow) { 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++) { 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); /* 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 = 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) { CDKDIALOG *dialog = (CDKDIALOG *)object; int firstButton = 0; int lastButton = dialog->buttonCount - 1; int ppReturn = 1; int ret = unknownInt; bool complete = FALSE; /* Set the exit type. */ setExitType(dialog, 0); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf(dialog) != 0) { ppReturn = PreProcessFuncOf(dialog) (vDIALOG, dialog, PreProcessDataOf(dialog), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check for a key binding. */ if (checkCDKObjectBind (vDIALOG, dialog, input) != 0) { checkEarlyExit(dialog); complete = TRUE; } else { switch (input) { case KEY_LEFT : case KEY_BTAB : case KEY_BACKSPACE : if (dialog->currentButton == firstButton) { dialog->currentButton = lastButton;; } else { dialog->currentButton--; } break; case KEY_RIGHT : case KEY_TAB : case SPACE : if (dialog->currentButton == lastButton) { dialog->currentButton = firstButton; } else { dialog->currentButton++; } break; case KEY_UP : case KEY_DOWN : Beep(); break; case CDK_REFRESH : eraseCDKScreen (ScreenOf(dialog)); refreshCDKScreen (ScreenOf(dialog)); break; case KEY_ESC : setExitType(dialog, input); complete = TRUE; break; case KEY_ENTER : setExitType(dialog, input); ret = dialog->currentButton; complete = TRUE; break; default : break; } } /* Should we call a post-process? */ if (!complete && (PostProcessFuncOf(dialog) != 0)) { PostProcessFuncOf(dialog) (vDIALOG, dialog, PostProcessDataOf(dialog), input); } } if (!complete) { drawCDKDialogButtons (dialog); wrefresh (dialog->win); setExitType(dialog, 0); } ResultOf(dialog).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; 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++) { mvwaddch (dialog->win, dialog->boxHeight - 2 - BorderOf(dialog), x, ACS_HLINE | boxattr); } mvwaddch (dialog->win, dialog->boxHeight - 2 - BorderOf(dialog), 0, ACS_LTEE | boxattr); 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) cdk-5.0-20060507/draw.c0000644000175100001440000001615410143530627012650 0ustar tomusers#include /* * $Author: tom $ * $Date: 2004/11/07 23:36:55 $ * $Revision: 1.58 $ */ /* * This sets up a basic set of color pairs. These can be redefined * if wanted... */ void initCDKColor (void) { #ifdef HAVE_START_COLOR 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; if (has_colors()) { start_color(); limit = (COLORS < 8) ? COLORS : 8; /* Create the color pairs. */ for (fg=0; fg < limit; fg++) { for (bg=0; bg < limit; bg++) { init_pair (pair++, color[fg], color[bg]); } } } #endif } /* * This prints out a box around a window with attributes */ void boxWindow (WINDOW *window, chtype attr) { /* Set some variables. */ int tlx = 0; int tly = 0; int brx = getmaxx(window) - 1; int bry = getmaxy(window) - 1; /* Draw horizontal lines. */ mvwhline(window, tly, 0, ACS_HLINE | attr, getmaxx(window)); mvwhline(window, bry, 0, ACS_HLINE | attr, getmaxx(window)); /* Draw vertical lines. */ mvwvline(window, 0, tlx, ACS_VLINE | attr, getmaxy(window)); mvwvline(window, 0, brx, ACS_VLINE | attr, getmaxy(window)); /* Draw in the corners. */ mvwaddch (window, tly, tlx, ACS_ULCORNER | attr); mvwaddch (window, tly, brx, ACS_URCORNER | attr); mvwaddch (window, bry, tlx, ACS_LLCORNER | attr); mvwaddch (window, bry, brx, ACS_LRCORNER | attr); 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) { /* Set the coordinates. */ 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) { mvwhline(win, y1, 0, horz | attr, getmaxx(win)); mvwhline(win, y2, 0, horz | attr, getmaxx(win)); count++; } /* Draw vertical lines. */ if (vert != 0) { mvwvline(win, 0, x1, vert | attr, getmaxy(win)); mvwvline(win, 0, x2, vert | attr, getmaxy(win)); count++; } /* Draw in the corners. */ if (tlc != 0) { mvwaddch (win, y1, x1, tlc | attr); count++; } if (trc != 0) { mvwaddch (win, y1, x2, trc | attr); count++; } if (blc != 0) { mvwaddch (win, y2, x1, blc | attr); count++; } if (brc != 0) { 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) { /* De=clare some local vars. */ 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) mvwhline (window, starty, startx, line, xdiff); } else if (xdiff == 0) { if (ydiff > 0) mvwvline (window, starty, startx, line, ydiff); } else { /* We need to determine the angle of the line. */ 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. */ 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. */ mvwhline(shadowWin, y_hi, 1, ACS_HLINE | A_DIM, x_hi); /* Draw the line on the right. */ mvwvline(shadowWin, 0, x_hi, ACS_VLINE | A_DIM, y_hi); mvwaddch (shadowWin, 0, x_hi, ACS_URCORNER | A_DIM); mvwaddch (shadowWin, y_hi, 0, ACS_LLCORNER | A_DIM); 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 = (end - start) + 1000; char *blanks = (char *)malloc (want); if (blanks != 0) { cleanChar (blanks, 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++) { 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++) { 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) { 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++) { 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++) { mvwaddch (window, ypos+x, xpos, string[x+start] | attr); } } } cdk-5.0-20060507/entry.c0000644000175100001440000005103510426515520013050 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:24:48 $ * $Revision: 1.214 $ */ /* * 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, char *title, char *label, chtype fieldAttr, chtype filler, EDisplayType dispType, int fWidth, int min, int max, boolean Box, boolean shadow) { 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 = subwin (cdkscreen->window, 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; /* 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 = subwin (cdkscreen->window, 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 = 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; int charCount; stringLen = (int)strlen (entry->info); if (stringLen >= entry->fieldWidth) { if (stringLen < entry->max) { 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 *entry = (CDKENTRY *)object; int ppReturn = 1; int x; char holder; char *ret = unknownString; bool complete = FALSE; /* Set the exit type. */ setExitType (entry, 0); /* Refresh the entry field. */ drawCDKEntryField (entry); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf (entry) != 0) { ppReturn = PreProcessFuncOf (entry) (vENTRY, entry, PreProcessDataOf (entry), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check a predefined binding... */ if (checkCDKObjectBind (vENTRY, entry, input) != 0) { checkEarlyExit (entry); complete = TRUE; } else { int infoLength = (int)strlen (entry->info); int currPos = entry->screenCol + entry->leftChar; switch (input) { case KEY_UP: case KEY_DOWN: Beep (); break; case KEY_HOME: entry->leftChar = 0; entry->screenCol = 0; drawCDKEntryField (entry); break; case CDK_TRANSPOSE: if (currPos >= infoLength - 1) { Beep (); } else { holder = entry->info[currPos]; entry->info[currPos] = entry->info[currPos + 1]; entry->info[currPos + 1] = holder; drawCDKEntryField (entry); } break; case KEY_END: setPositionToEnd (entry); drawCDKEntryField (entry); break; case KEY_LEFT: if (currPos <= 0) { Beep (); } else if (entry->screenCol == 0) { /* Scroll left. */ entry->leftChar--; drawCDKEntryField (entry); } else { wmove (entry->fieldWin, 0, --entry->screenCol); } break; case KEY_RIGHT: if (currPos >= infoLength) { Beep (); } else if (entry->screenCol == entry->fieldWidth - 1) { /* Scroll to the right. */ entry->leftChar++; drawCDKEntryField (entry); } else { /* Move right. */ wmove (entry->fieldWin, 0, ++entry->screenCol); } break; case KEY_BACKSPACE: case KEY_DC: if (entry->dispType == vVIEWONLY) { Beep (); } else { bool success = FALSE; if (input == KEY_BACKSPACE) --currPos; if (currPos >= 0 && infoLength > 0) { if (currPos < infoLength) { for (x = currPos; x < infoLength; x++) { entry->info[x] = entry->info[x + 1]; } success = TRUE; } else if (input == KEY_BACKSPACE) { entry->info[infoLength - 1] = '\0'; success = TRUE; } } if (success) { if (input == KEY_BACKSPACE) { if (entry->screenCol > 0) entry->screenCol--; else entry->leftChar--; } drawCDKEntryField (entry); } else { Beep (); } } break; case KEY_ESC: setExitType (entry, input); complete = TRUE; break; case CDK_ERASE: if (infoLength != 0) { cleanCDKEntry (entry); drawCDKEntryField (entry); } break; case CDK_CUT: if (infoLength != 0) { freeChar (GPasteBuffer); GPasteBuffer = copyChar (entry->info); cleanCDKEntry (entry); drawCDKEntryField (entry); } else { Beep (); } break; case CDK_COPY: if (infoLength != 0) { freeChar (GPasteBuffer); GPasteBuffer = copyChar (entry->info); } else { Beep (); } break; case CDK_PASTE: if (GPasteBuffer != 0) { setCDKEntryValue (entry, GPasteBuffer); drawCDKEntryField (entry); } else { Beep (); } break; case KEY_TAB: case KEY_ENTER: if (infoLength >= entry->min) { setExitType (entry, input); ret = (entry->info); complete = TRUE; } else { Beep (); } break; case CDK_REFRESH: eraseCDKScreen (ScreenOf (entry)); refreshCDKScreen (ScreenOf (entry)); break; default: (entry->callbackfn) (entry, input); break; } } /* Should we do a post-process? */ if (!complete && (PostProcessFuncOf (entry) != 0)) { PostProcessFuncOf (entry) (vENTRY, entry, PostProcessDataOf (entry), input); } } if (!complete) setExitType (entry, 0); ResultOf (entry).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) { 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); unsigned temp; 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] = plainchar; entry->screenCol++; } else { /* Update the character pointer. */ temp = strlen (entry->info); entry->info[temp] = 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. */ 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 infoLength = 0; int x = 0; /* Draw in the filler characters. */ mvwhline (entry->fieldWin, 0, x, entry->filler, entry->fieldWidth); /* If there is information in the field. Then draw it in. */ if (entry->info != 0) { infoLength = (int)strlen (entry->info); /* Redraw the field. */ if (isHiddenDisplayType (entry->dispType)) { for (x = entry->leftChar; x < infoLength; x++) { mvwaddch (entry->fieldWin, 0, x - entry->leftChar, entry->hidden); } } else { for (x = entry->leftChar; x < infoLength; x++) { 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, 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, char *newValue) { int copychars = 0; /* 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. */ 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 cdk-5.0-20060507/examples/0000755000175100001440000000000010427502123013351 5ustar tomuserscdk-5.0-20060507/examples/configure.in0000644000175100001440000000071406633404650015676 0ustar tomusersdnl dnl Process this file with autoconf to produce a configure script. dnl AC_INIT(CDKDemo) dnl dnl Checks for programs. dnl AC_PROG_CC dnl dnl Put -Wall on compile line if we are using gcc or g++ dnl if test "$ac_cv_prog_CC" = "gcc"; then CFLAGS="$CFLAGS -Wall" fi if test "$ac_cv_prog_CC" = "g++"; then CFLAGS="$CFLAGS -Wall" fi dnl dnl Checks for libraries. dnl dnl -lncurses -lm -lcdk -L.. AC_CHECK_LIB(ncurses, start_color) AC_OUTPUT(Makefile) cdk-5.0-20060507/examples/matrix_ex.c0000644000175100001440000000623610354064363015534 0ustar tomusers/* $Id: matrix_ex.c,v 1.14 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "matrix_ex"; #endif /* * This program demonstrates the Cdk matrix widget. */ int main (int argc, char **argv) { /* Declare local variables. */ CDKSCREEN *cdkscreen = 0; CDKMATRIX *courseList = 0; WINDOW *cursesWin = 0; char *title = 0; int rows = 8; int cols = 5; int vrows = 3; int vcols = 5; char *coltitle[10], *rowtitle[10], *mesg[10]; int colwidth[10], colvalue[10]; CDK_PARAMS params; CDKparseParams (argc, argv, ¶ms, CDK_MIN_PARAMS); /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Colors. */ initCDKColor(); /* Create the horizontal and vertical matrix labels. */ #define set_col(n, width, string) \ coltitle[n] = string; colwidth[n] = width ; colvalue[n] = vUMIXED set_col(1, 7, "Course"); set_col(2, 7, "Lec 1"); set_col(3, 7, "Lec 2"); set_col(4, 7, "Lec 3"); set_col(5, 1, "Flag"); #define set_row(n, string) \ rowtitle[n] = "" string set_row(1, "Course 1"); set_row(2, "Course 2"); set_row(3, "Course 3"); set_row(4, "Course 4"); set_row(5, "Course 5"); set_row(6, "Course 6"); set_row(7, "Course 7"); set_row(8, "Course 8"); /* Create the title. */ title = "This is the CDK\nmatrix widget.\n<#LT><#HL(30)><#RT>"; /* Create the matrix object. */ courseList = newCDKMatrix (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), rows, cols, vrows, vcols, title, rowtitle, coltitle, colwidth, colvalue, -1, -1, '.', COL, TRUE, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', TRUE)); /* Check to see if the matrix is null. */ if (courseList == 0) { /* Clean up. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a little message. */ printf ("Oops. Can't seem to create the matrix widget. Is the window too small ?\n"); ExitProgram (EXIT_FAILURE); } /* Activate the matrix. */ activateCDKMatrix (courseList, 0); /* Check if the user hit escape or not. */ if (courseList->exitType == vESCAPE_HIT) { mesg[0] = "You hit escape. No information passed back."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (courseList->exitType == vNORMAL) { char temp[80]; sprintf(temp, "Current cell (%d,%d)", courseList->crow, courseList->ccol); mesg[0] = "You exited the matrix normally."; mesg[1] = temp; mesg[2] = "To get the contents of the matrix cell, you can"; mesg[3] = "use getCDKMatrixCell():"; mesg[4] = getCDKMatrixCell(courseList, courseList->crow, courseList->ccol); mesg[5] = ""; mesg[6] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 7); } /* Clean up. */ destroyCDKMatrix (courseList); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/swindow_ex.c0000644000175100001440000000633510354064363015722 0ustar tomusers/* $Id: swindow_ex.c,v 1.11 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "swindow_ex"; #endif /* * Demonstrate a scrolling-window. */ int main (int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKSWINDOW *swindow = 0; WINDOW *cursesWin = 0; char *title = "Error Log"; char *mesg[5]; CDK_PARAMS params; CDKparseParams(argc, argv, ¶ms, CDK_CLI_PARAMS); /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK colors. */ initCDKColor(); /* Create the scrolling window. */ swindow = newCDKSwindow (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), CDKparamValue(¶ms, 'H', 6), CDKparamValue(¶ms, 'W', 65), title, 100, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); /* Is the window null. */ if (swindow == 0) { /* Exit CDK. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a message and exit. */ printf ("Oops. Can not seem to create the scrolling window. Is the window too small??\n"); ExitProgram (EXIT_FAILURE); } /* Draw the scrolling window. */ drawCDKSwindow (swindow, ObjOf(swindow)->box); /* Load up the scrolling window. */ addCDKSwindow (swindow, "TOP: This is the first line.", BOTTOM); addCDKSwindow (swindow, "Sleeping for 1 second.", BOTTOM); sleep (1); addCDKSwindow (swindow, "1: This is another line.", BOTTOM); addCDKSwindow (swindow, "Sleeping for 1 second.", BOTTOM); sleep (1); addCDKSwindow (swindow, "2: This is another line.", BOTTOM); addCDKSwindow (swindow, "Sleeping for 1 second.", BOTTOM); sleep (1); addCDKSwindow (swindow, "3: This is another line.", BOTTOM); addCDKSwindow (swindow, "Sleeping for 1 second.", BOTTOM); sleep (1); addCDKSwindow (swindow, "4: This is another line.", BOTTOM); addCDKSwindow (swindow, "Sleeping for 1 second.", BOTTOM); sleep (1); addCDKSwindow (swindow, "5: This is another line.", BOTTOM); addCDKSwindow (swindow, "Sleeping for 1 second.", BOTTOM); sleep (1); addCDKSwindow (swindow, "6: This is another line.", BOTTOM); addCDKSwindow (swindow, "Sleeping for 1 second.", BOTTOM); sleep (1); addCDKSwindow (swindow, "Done. You can now play.", BOTTOM); addCDKSwindow (swindow, "This is being added to the top.", TOP); /* Activate the scrolling window. */ activateCDKSwindow (swindow, 0); /* Check how the user exited this widget. */ if (swindow->exitType == vESCAPE_HIT) { mesg[0] = "You hit escape to leave this widget."; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (swindow->exitType == vNORMAL) { mesg[0] = "You hit return to exit this widget."; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } /* Clean up. */ destroyCDKSwindow (swindow); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/histogram_ex.c0000644000175100001440000001054010354064363016216 0ustar tomusers/* $Id: histogram_ex.c,v 1.9 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "histogram_ex"; #endif int main(int argc, char **argv) { /* Declare vars. */ CDKSCREEN *cdkscreen = 0; CDKHISTOGRAM *volume = 0; CDKHISTOGRAM *bass = 0; CDKHISTOGRAM *treble = 0; WINDOW *cursesWin = 0; char *volumeTitle = "Volume"; char *bassTitle = "Bass "; char *trebleTitle = "Treble"; CDK_PARAMS params; boolean Box; CDKparseParams(argc, argv, ¶ms, CDK_CLI_PARAMS); Box = CDKparamValue(¶ms, 'N', TRUE); /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Color. */ initCDKColor(); /* Create the histogram objects. */ volume = newCDKHistogram (cdkscreen, CDKparamValue(¶ms, 'X', 10), CDKparamValue(¶ms, 'Y', 10), CDKparamValue(¶ms, 'H', 1), CDKparamValue(¶ms, 'W', -2), HORIZONTAL, volumeTitle, Box, CDKparamValue(¶ms, 'S', FALSE)); if (volume == 0) { /* Exit CDK. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a message and exit. */ printf ("Oops. Can not make volume histogram. Is the window big enough??\n"); ExitProgram (EXIT_FAILURE); } bass = newCDKHistogram (cdkscreen, CDKparamValue(¶ms, 'X', 10), CDKparamValue(¶ms, 'Y', 14), CDKparamValue(¶ms, 'H', 1), CDKparamValue(¶ms, 'W', -2), HORIZONTAL, bassTitle, Box, CDKparamValue(¶ms, 'S', FALSE)); if (bass == 0) { /* Exit CDK. */ destroyCDKHistogram (volume); destroyCDKScreen (cdkscreen); endCDK(); /* Print out a message and exit. */ printf ("Oops. Can not make bass histogram. Is the window big enough??\n"); ExitProgram (EXIT_FAILURE); } treble = newCDKHistogram (cdkscreen, CDKparamValue(¶ms, 'X', 10), CDKparamValue(¶ms, 'Y', 18), CDKparamValue(¶ms, 'H', 1), CDKparamValue(¶ms, 'W', -2), HORIZONTAL, trebleTitle, Box, CDKparamValue(¶ms, 'S', FALSE)); if (treble == 0) { /* Exit CDK. */ destroyCDKHistogram (volume); destroyCDKHistogram (bass); destroyCDKScreen (cdkscreen); endCDK(); /* Print out a message and exit. */ printf ("Oops. Can not 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); } cdk-5.0-20060507/examples/calendar_ex.c0000644000175100001440000001022410354064363015771 0ustar tomusers/* $Id: calendar_ex.c,v 1.13 2005/12/26 22:04:35 tom Exp $ */ #include #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) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKCALENDAR *calendar = 0; WINDOW *cursesWin = 0; char *mesg[5], 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 = localtime (&clck); CDKparseParams(argc, argv, ¶ms, "d:m:y:t:" CDK_MIN_PARAMS); day = CDKparamNumber2(¶ms, 'd', dateInfo->tm_mday); month = CDKparamNumber2(¶ms, 'm', dateInfo->tm_mon + 1); year = CDKparamNumber2(¶ms, 'y', dateInfo->tm_year + 1900); title = CDKparamString2(¶ms, 't', "CDK Calendar Widget\nDemo"); /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Colors. */ initCDKColor(); /* Create the calendar widget. */ calendar = newCDKCalendar (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, '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(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); /* Is the widget null? */ if (calendar == 0) { /* Clean up the memory. */ destroyCDKScreen (cdkscreen); /* End curses... */ endCDK(); /* Spit out a message. */ printf ("Oops. Can't seem to 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); /* 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] = "You hit escape. No date selected."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (calendar->exitType == vNORMAL) { mesg[0] = "You selected the following date"; sprintf (temp, "%02d/%02d/%d (dd/mm/yyyy)", calendar->day, calendar->month, calendar->year); mesg[1] = copyChar (temp); mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); freeChar (mesg[1]); } /* 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); } cdk-5.0-20060507/examples/hello_ex.c0000644000175100001440000000277110354064363015333 0ustar tomusers/* $Id: hello_ex.c,v 1.9 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "hello_ex"; #endif int main(int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen; CDKLABEL *demo; WINDOW *cursesWin; char *mesg[4]; CDK_PARAMS params; CDKparseParams(argc, argv, ¶ms, CDK_MIN_PARAMS); /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Colors. */ initCDKColor(); /* Set the labels up. */ mesg[0] = "<#UL><#HL(30)><#UR>"; mesg[1] = "<#VL(10)>Hello World!<#VL(10)>"; mesg[2] = "<#LL><#HL(30)><#LR>"; /* Declare the labels. */ demo = newCDKLabel (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), mesg, 3, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', TRUE)); setCDKLabelBackgroundAttrib (demo, COLOR_PAIR(2)); /* Is the label null? */ if (demo == 0) { /* Clean up the memory. */ destroyCDKScreen (cdkscreen); /* End curses... */ endCDK(); /* Spit out a message. */ printf ("Oops. Can't seem to create the label. Is the window too small?\n"); ExitProgram (EXIT_FAILURE); } /* Draw the CDK screen. */ refreshCDKScreen (cdkscreen); waitCDKLabel (demo, ' '); /* Clean up. */ destroyCDKLabel (demo); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/mentry_ex.c0000644000175100001440000000346010354064363015542 0ustar tomusers/* $Id: mentry_ex.c,v 1.9 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "mentry_ex"; #endif int main (int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKMENTRY *widget = 0; WINDOW *cursesWin = 0; char *info = 0; char *label = "Message"; char *title = "Enter a message."; CDK_PARAMS params; CDKparseParams (argc, argv, ¶ms, "w:h:l:" CDK_MIN_PARAMS); /* Set up CDK. */ cursesWin = initscr (); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Colors. */ initCDKColor (); /* Set up the multi-line entry field. */ widget = newCDKMentry (cdkscreen, CDKparamValue (¶ms, 'X', CENTER), CDKparamValue (¶ms, 'Y', CENTER), title, label, A_BOLD, '.', vMIXED, CDKparamValue (¶ms, 'w', 20), CDKparamValue (¶ms, 'h', 5), CDKparamValue (¶ms, 'l', 20), 0, CDKparamValue (¶ms, 'N', TRUE), CDKparamValue (¶ms, 'S', FALSE)); /* Is the object null? */ if (widget == 0) { /* Shut down CDK. */ destroyCDKScreen (cdkscreen); endCDK (); /* Print out a message. */ printf ("Oops. Can not create CDK object. Is the window too small?\n"); ExitProgram (EXIT_FAILURE); } /* Draw the CDK screen. */ refreshCDKScreen (cdkscreen); /* Set what ever was given from the command line. */ setCDKMentry (widget, argv[optind], 0, TRUE); /* Activate this thing. */ activateCDKMentry (widget, 0); info = strdup (widget->info); /* Clean up. */ destroyCDKMentry (widget); destroyCDKScreen (cdkscreen); endCDK (); /* Spit out the results. */ printf ("\n\n\n"); printf ("Your message was : <%s>\n", info); free (info); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/fscale_ex.c0000644000175100001440000000462610354064363015466 0ustar tomusers/* $Id: fscale_ex.c,v 1.6 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "fscale_ex"; #endif static float myFloatParam (CDK_PARAMS *params, int code, float missing) { char *opt = CDKparamString (params, code); float result = missing; if (opt != 0) result = atof(opt); return result; } /* * This program demonstrates the Cdk scale widget. */ int main (int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKFSCALE *scale = 0; WINDOW *cursesWin = 0; char *title = "Select a value"; char *label = "Current value"; char temp[256], *mesg[5]; float selection; CDK_PARAMS params; float high; float inc; float low; CDKparseParams(argc, argv, ¶ms, "h:i:l:w:" CDK_MIN_PARAMS); high = myFloatParam(¶ms, 'h', 2.4); inc = myFloatParam(¶ms, 'i', 0.2); low = myFloatParam(¶ms, 'l', -1.2); /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Colors. */ initCDKColor(); /* Create the scale. */ scale = newCDKFScale (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), title, label, A_NORMAL, CDKparamNumber2(¶ms, 'w', 10), low, low, high, inc, (inc*2.), 1, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); /* Is the scale null? */ if (scale == 0) { /* Exit CDK. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a message. */ printf ("Oops. 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] = "You hit escape. No value selected."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (scale->exitType == vNORMAL) { sprintf (temp, "You selected %f", selection); mesg[0] = copyChar (temp); mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); freeChar (mesg[0]); } /* Clean up. */ destroyCDKFScale (scale); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/dialog_ex.c0000644000175100001440000000463410354064363015467 0ustar tomusers/* $Id: dialog_ex.c,v 1.12 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "dialog_ex"; #endif /* * This program demonstrates the Cdk dialog widget. */ int main(int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKDIALOG *question = 0; WINDOW *cursesWin = 0; char *buttons[] = {"Ok", "Cancel"}; char *message[10], *mesg[3], temp[100]; int selection; CDK_PARAMS params; CDKparseParams(argc, argv, ¶ms, CDK_MIN_PARAMS); /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start color. */ initCDKColor(); /* Create the message within the dialog box. */ message[0] = "Dialog Widget Demo"; message[1] = " "; message[2] = "The dialog widget allows the programmer to create"; message[3] = "a popup dialog box with buttons. The dialog box"; message[4] = "can contain colours, character attributes"; message[5] = "and even be right justified."; message[6] = "and left."; /* Create the dialog box. */ question = newCDKDialog (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), message, 7, buttons, 2, COLOR_PAIR(2)|A_REVERSE, TRUE, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); /* Check if we got a null value back. */ if (question == 0) { /* Shut down Cdk. */ destroyCDKScreen (cdkscreen); endCDK(); /* Spit out a message. */ printf ("Oops. Can't seem to 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] = "You hit escape. No button selected."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (question->exitType == vNORMAL) { sprintf (temp, "You selected button #%d", selection); mesg[0] = temp; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } /* Clean up. */ destroyCDKDialog (question); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/position_ex.c0000644000175100001440000000441310354064363016067 0ustar tomusers/* $Id: position_ex.c,v 1.13 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "position_ex"; #endif /* * This demonstrates the positioning of a Cdk entry field widget. */ int main(int argc, char **argv) { /* Declare local variables.*/ CDKSCREEN *cdkscreen = 0; CDKENTRY *directory = 0; WINDOW *cursesWin = 0; char *label = "Directory: "; char *info = 0; char *mesg[10]; char temp[256]; CDK_PARAMS params; CDKparseParams(argc, argv, ¶ms, "w:" CDK_MIN_PARAMS); /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK colors. */ initCDKColor(); /* Create the entry field widget. */ directory = newCDKEntry (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), 0, label, A_NORMAL, '.', vMIXED, CDKparamValue(¶ms, 'w', 40), 0, 256, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); /* Is the widget null? */ if (directory == 0) { /* Clean up. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a little message. */ printf ("Oops. Can't seem to create the entry box. Is the window too small?\n"); ExitProgram (EXIT_FAILURE); } /* Let the user move the widget around the window. */ drawCDKEntry (directory, ObjOf(directory)->box); positionCDKEntry (directory); /* Activate the entry field. */ info = activateCDKEntry (directory, 0); /* Tell them what they typed. */ if (directory->exitType == vESCAPE_HIT) { mesg[0] = "You hit escape. No information passed back."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (directory->exitType == vNORMAL) { mesg[0] = "You typed in the following"; sprintf (temp, "(%.*s)", (int)(sizeof(temp) - 20), info); mesg[1] = copyChar (temp); mesg[2] = ""; mesg[3] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 4); freeChar (mesg[1]); } /* Clean up and exit. */ destroyCDKEntry (directory); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/cdkscreen_ex.c0000644000175100001440000000735410354064363016173 0ustar tomusers/* $Id: cdkscreen_ex.c,v 1.6 2005/12/26 22:04:35 tom Exp $ */ #include /* * This demonstrates how to create four different Cdk * screens and flip between them. */ #ifdef HAVE_XCURSES char *XCursesProgramName = "cdkscreen_ex"; #endif int main (void) { /* Declare vars. */ WINDOW *cursesWindow; CDKSCREEN *cdkScreen1, *cdkScreen2; CDKSCREEN *cdkScreen3, *cdkScreen4; CDKSCREEN *cdkScreen5; CDKLABEL *label1, *label2; CDKLABEL *label3, *label4; CDKDIALOG *dialog; char *title1Mesg[4], *title2Mesg[4]; char *title3Mesg[4], *title4Mesg[4]; char *dialogMesg[10]; char *buttons[] = {"Continue", "Exit"}; int answer; /* Create the curses window. */ cursesWindow = initscr(); /* Create the two screens. */ cdkScreen1 = initCDKScreen (cursesWindow); cdkScreen2 = initCDKScreen (cursesWindow); cdkScreen3 = initCDKScreen (cursesWindow); cdkScreen4 = initCDKScreen (cursesWindow); cdkScreen5 = initCDKScreen (cursesWindow); /* Create the first screen. */ title1Mesg[0] = "<#HL(30)>"; title1Mesg[1] = "This is the first screen."; title1Mesg[2] = "Hit space to go to the next screen"; title1Mesg[3] = "<#HL(30)>"; label1 = newCDKLabel (cdkScreen1, CENTER, TOP, title1Mesg, 4, FALSE, FALSE); /* Create the second screen. */ title2Mesg[0] = "<#HL(30)>"; title2Mesg[1] = "This is the second screen."; title2Mesg[2] = "Hit space to go to the next screen"; title2Mesg[3] = "<#HL(30)>"; label2 = newCDKLabel (cdkScreen2, RIGHT, CENTER, title2Mesg, 4, FALSE, FALSE); /* Create the third screen. */ title3Mesg[0] = "<#HL(30)>"; title3Mesg[1] = "This is the third screen."; title3Mesg[2] = "Hit space to go to the next screen"; title3Mesg[3] = "<#HL(30)>"; label3 = newCDKLabel (cdkScreen3, CENTER, BOTTOM, title3Mesg, 4, FALSE, FALSE); /* Create the fourth screen. */ title4Mesg[0] = "<#HL(30)>"; title4Mesg[1] = "This is the fourth screen."; title4Mesg[2] = "Hit space to go to the next screen"; title4Mesg[3] = "<#HL(30)>"; label4 = newCDKLabel (cdkScreen4, LEFT, CENTER, title4Mesg, 4, FALSE, FALSE); /* Create the fifth screen. */ dialogMesg[0] = "<#HL(30)>"; dialogMesg[1] = "Screen 5"; dialogMesg[2] = "This is the last of 5 screens. If you want"; dialogMesg[3] = "to continue press the 'Continue' button."; dialogMesg[4] = "Otherwise press the 'Exit' button"; dialogMesg[5] = "<#HL(30)>"; dialog = newCDKDialog (cdkScreen5, CENTER, CENTER, dialogMesg, 6, buttons, 2, A_REVERSE, TRUE, TRUE, FALSE); /* Do this for ever... (almost) */ for (;;) { /* 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); } } } cdk-5.0-20060507/examples/entry_ex.c0000644000175100001440000000533010354064363015363 0ustar tomusers/* $Id: entry_ex.c,v 1.15 2005/12/26 22:04:35 tom Exp $ */ #include #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) { /* Declare local variables. */ CDKSCREEN *cdkscreen = 0; CDKENTRY *directory = 0; WINDOW *cursesWin = 0; char *title = "Enter a\ndirectory name."; char *label = "Directory:"; char *info, *mesg[10], temp[256]; CDK_PARAMS params; CDKparseParams(argc, argv, ¶ms, CDK_MIN_PARAMS); /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK colors. */ initCDKColor(); /* Create the entry field widget. */ directory = newCDKEntry (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), title, label, A_NORMAL, '.', vMIXED, 40, 0, 256, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); bindCDKObject (vENTRY, directory, '?', XXXCB, 0); /* Is the widget null? */ if (directory == 0) { /* Clean up. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a little message. */ printf ("Oops. Can't seem to 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] = "You hit escape. No information passed back."; mesg[1] = "", mesg[2] = "Press any key to continue."; destroyCDKEntry (directory); popupLabel (cdkscreen, mesg, 3); } else if (directory->exitType == vNORMAL) { mesg[0] = "You typed in the following"; sprintf (temp, "(%.*s)", (int)(sizeof(temp) - 10), info); mesg[1] = copyChar (temp); mesg[2] = ""; mesg[3] = "Press any key to continue."; destroyCDKEntry (directory); popupLabel (cdkscreen, mesg, 4); freeChar (mesg[1]); } 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); } cdk-5.0-20060507/examples/graph_ex.c0000644000175100001440000000522310354064363015324 0ustar tomusers/* $Id: graph_ex.c,v 1.12 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "graph_ex"; #endif int main(int argc, char **argv) { /* Declare vars. */ CDKSCREEN *cdkscreen = 0; CDKGRAPH *graph = 0; CDKLABEL *pausep = 0; WINDOW *cursesWin = 0; char *title = 0; char *xtitle = 0; char *ytitle = 0; char *graphChars = 0; char *mesg[2]; int values[20], colors[20]; int count; CDK_PARAMS params; CDKparseParams(argc, argv, ¶ms, CDK_CLI_PARAMS); /* -N, -S unused */ /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Colors. */ initCDKColor(); /* Create the graph values. */ values[0] = 10; colors[0] = 5; values[1] = 15; colors[1] = 5; values[2] = 20; colors[2] = 5; values[3] = 25; colors[3] = 5; values[4] = 30; colors[4] = 5; values[5] = 35; colors[5] = 5; values[6] = 40; colors[6] = 5; values[7] = 45; colors[7] = 5; values[8] = 50; colors[8] = 5; values[9] = 55; colors[9] = 5; count = 10; title = "Test Graph"; xtitle = "X AXIS TITLE"; ytitle = "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(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), CDKparamValue(¶ms, 'H', 10), CDKparamValue(¶ms, 'W', 20), title, xtitle, ytitle); /* Is the graph null? */ if (graph == 0) { /* Shut down CDK. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a message and exit. */ printf ("Oops. Can not make the graph widget. Is the window too small?\n"); ExitProgram (EXIT_FAILURE); } /* Create the label widget. */ pausep = newCDKLabel (cdkscreen, CENTER, BOTTOM, mesg, 1, TRUE, FALSE); if (pausep == 0) { /* Shut down CDK. */ destroyCDKGraph (graph); destroyCDKScreen (cdkscreen); endCDK(); /* Print out a message and exit. */ printf ("Oops. Can not 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); } cdk-5.0-20060507/examples/preprocess_ex.c0000644000175100001440000000530110354064363016405 0ustar tomusers/* $Id: preprocess_ex.c,v 1.17 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "preprocess_ex"; #endif static BINDFN_PROTO(entryPreProcessCB); /* * This demonstrates the Cdk preprocess feature. */ int main (void) { /* Declare local variables. */ CDKSCREEN *cdkscreen = 0; CDKENTRY *widget = 0; WINDOW *cursesWin = 0; char *title = "Type in anything you want\nbut the dreaded letter G!"; char *info, *mesg[10], temp[256]; /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK colors. */ initCDKColor(); /* Create the entry field widget. */ widget = newCDKEntry (cdkscreen, CENTER, CENTER, title, 0, A_NORMAL, '.', vMIXED, 40, 0, 256, TRUE, FALSE); /* Is the widget null? */ if (widget == 0) { /* Clean up. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a little message. */ printf ("Oops. Can't seem to create the entry box. Is the window too small?\n"); ExitProgram (EXIT_FAILURE); } setCDKEntryPreProcess (widget, entryPreProcessCB, 0); /* Activate the entry field. */ info = activateCDKEntry (widget, 0); /* Tell them what they typed. */ if (widget->exitType == vESCAPE_HIT) { mesg[0] = "You hit escape. No information passed back."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (widget->exitType == vNORMAL) { mesg[0] = "You typed in the following"; sprintf (temp, "(%.*s)", (int)(sizeof(temp) - 20), info); mesg[1] = copyChar (temp); mesg[2] = ""; mesg[3] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 4); freeChar (mesg[1]); } /* Clean up and exit. */ destroyCDKEntry (widget); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } static int entryPreProcessCB (EObjectType cdkType GCC_UNUSED, void *object, void *clientData GCC_UNUSED, chtype input) { CDKENTRY *entry = (CDKENTRY *)object; CDKDIALOG *widget = 0; char *buttons[] = {"OK"}; int buttonCount = 1; int lines = 0; char *mesg[5]; /* Check the input. */ if ((input == 'g') || (input == 'G')) { mesg[lines++] = "<#HL(30)>"; mesg[lines++] = "I told you NOT to type G"; mesg[lines++] = "<#HL(30)>"; widget = newCDKDialog (ScreenOf(entry), CENTER, CENTER, mesg, lines, buttons, buttonCount, A_REVERSE, FALSE, TRUE, FALSE); activateCDKDialog (widget, 0); destroyCDKDialog (widget); drawCDKEntry (entry, ObjOf(entry)->box); return 0; } return 1; } cdk-5.0-20060507/examples/marquee_ex.c0000644000175100001440000001054710354064363015667 0ustar tomusers/* $Id: marquee_ex.c,v 1.9 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "marquee_ex"; #endif static char startAttr[100]; static char endAttr[100]; /* * This spits out help about this demo program. */ static void help (char *programName) { char *USAGE = "[-m Message] [-R repeat value] [-d delay value] [-b|r|u|k] [-h]"; printf ("Usage: %s %s\n", programName, USAGE); printf (" -m Message - Sets the message to display in the marquee\n"); printf (" If no message is provided, one will be created.\n"); printf (" -R Repeat - Tells the marquee how many time to repeat the message.\n"); printf (" A value of -1 tells the marquee to repeat the message forever.\n"); printf (" -d Delay - Sets the number of milli seconds to delay beyween repeats.\n"); printf (" -b - Tells the marquee to display the message with the bold attribute.\n"); printf (" -r - Tells the marquee to display the message with a revered attribute.\n"); printf (" -u - Tells the marquee to display the message with an underline attribute.\n"); printf (" -k - Tells the marquee to display the message with the blinking attribute.\n"); } static void myParseAttr(CDK_PARAMS *params, int lower, int upper) { if (CDKparamString(params, lower) != 0) { char starting[3]; char ending[3]; if (startAttr[0] == '\0') { startAttr[0] = '<'; endAttr[0] = '<'; } sprintf (starting, "/%c", upper); sprintf (ending, "!%c", upper); strcat (startAttr, starting); strcat (endAttr, ending); } } int main (int argc, char **argv) { /* Declare vars. */ CDKSCREEN *cdkscreen; CDKMARQUEE *scrollMessage; WINDOW *cursesWin; char message[1024]; char *currentTime; time_t clck; CDK_PARAMS params; char *mesg; int delay; int repeat; CDKparseParams (argc, argv, ¶ms, "brkud:R:m:hw:" CDK_MIN_PARAMS); myParseAttr(¶ms, 'b', 'B'); myParseAttr(¶ms, 'r', 'R'); myParseAttr(¶ms, 'k', 'K'); myParseAttr(¶ms, 'u', 'U'); repeat = CDKparamNumber2 (¶ms, 'R', 3); delay = CDKparamNumber2 (¶ms, 'd', 5); mesg = CDKparamString (¶ms, 'm'); if (CDKparamString(¶ms, 'h') != 0) help (argv[0]); /* Clean up the strings. */ cleanChar (message, sizeof(message), '\0'); cleanChar (startAttr, sizeof(startAttr), '\0'); cleanChar (endAttr, sizeof(endAttr), '\0'); /* Put the end of the attributes if they asked for then. */ if (startAttr[0] == '<') { strcat (startAttr, ">"); strcat (endAttr, ">"); } /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); curs_set(0); /* Start CDK Colors. */ initCDKColor(); /* Create the marquee. */ scrollMessage = newCDKMarquee (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', TOP), CDKparamValue(¶ms, 'w', 30), CDKparamValue(¶ms, 'N', FALSE), CDKparamValue(¶ms, 'S', TRUE)); /* Check if the marquee is null. */ if (scrollMessage == 0) { /* Exit Cdk. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a message. */ printf ("Oops. Can't seem to create the marquee window. Is the window too small?\n"); ExitProgram (EXIT_FAILURE); } /* Draw the CDK screen. */ refreshCDKScreen (cdkscreen); /* Create the marquee message. */ if (mesg == 0) { /* Get the current time and chop off the newline. */ time (&clck); currentTime = ctime (&clck); currentTime[strlen(currentTime)-1] = 0; if (startAttr[0] != '\0') { currentTime[strlen(currentTime)-1] = '\0'; sprintf (message, "%s%s%s (This Space For Rent) ", startAttr, currentTime, endAttr); } else { sprintf (message, "%s (This Space For Rent) ", currentTime); } } else { if (startAttr[0] != '\0') { sprintf (message, "%s%s%s ", startAttr, mesg, endAttr); } else { sprintf (message, "%s ", mesg); } } /* Run the marquee. */ activateCDKMarquee (scrollMessage, message, delay, repeat, TRUE); /* Clean up. */ destroyCDKMarquee (scrollMessage); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/label_ex.c0000644000175100001440000000322510354064363015302 0ustar tomusers/* $Id: label_ex.c,v 1.9 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "label_ex"; #endif int main(int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen; CDKLABEL *demo; WINDOW *cursesWin; char *mesg[10]; CDK_PARAMS params; CDKparseParams(argc, argv, ¶ms, CDK_MIN_PARAMS); /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Colors. */ initCDKColor(); /* Set the labels up. */ mesg[0] = "This line should have a yellow foreground and a blue background."; mesg[1] = "This line should have a white foreground and a blue background."; mesg[2] = "This line should have a yellow foreground and a red background."; mesg[3] = "This line should be set to whatever the screen default is."; /* Declare the labels. */ demo = newCDKLabel (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), mesg, 4, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', TRUE)); /* Is the label null? */ if (demo == 0) { /* Clean up the memory. */ destroyCDKScreen (cdkscreen); /* End curses... */ endCDK(); /* Spit out a message. */ printf ("Oops. Can't seem to create the label. Is the window too small?\n"); ExitProgram (EXIT_FAILURE); } /* Draw the CDK screen. */ refreshCDKScreen (cdkscreen); waitCDKLabel (demo, ' '); /* Clean up. */ destroyCDKLabel (demo); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/lowerCDKObject_ex.c0000644000175100001440000000537610354064363017035 0ustar tomusers/* $Id: lowerCDKObject_ex.c,v 1.7 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "lowerCDKObject_ex"; #endif int main (int argc, char **argv) { char ch; char *mesg[1]; char *mesg1[10]; char *mesg2[10]; WINDOW *cursesWin; CDKSCREEN *cdkscreen; CDKLABEL *label1, *label2, *instruct; CDK_PARAMS params; CDKparseParams (argc, argv, ¶ms, CDK_MIN_PARAMS); /* Set up CDK. */ cursesWin = initscr (); cdkscreen = initCDKScreen (cursesWin); mesg1[0] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[1] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[2] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[3] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[4] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[5] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[6] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[7] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[8] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[9] = "label1 label1 label1 label1 label1 label1 label1"; label1 = newCDKLabel (cdkscreen, 8, 5, mesg1, 10, TRUE, FALSE); mesg2[0] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[1] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[2] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[3] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[4] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[5] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[6] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[7] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[8] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[9] = "label2 label2 label2 label2 label2 label2 label2"; label2 = newCDKLabel (cdkscreen, 14, 9, mesg2, 10, TRUE, FALSE); mesg[0] = "1 - lower label1, 2 - lower label2, q - quit"; instruct = newCDKLabel (cdkscreen, CDKparamValue (¶ms, 'X', CENTER), CDKparamValue (¶ms, 'Y', BOTTOM), mesg, 1, CDKparamValue (¶ms, 'N', FALSE), CDKparamValue (¶ms, 'S', FALSE)); refreshCDKScreen (cdkscreen); while ((ch = getch ()) != 'q') { switch (ch) { case '1': lowerCDKObject (vLABEL, label1); break; case '2': lowerCDKObject (vLABEL, label2); break; default: continue; } refreshCDKScreen (cdkscreen); } /* Clean up. */ destroyCDKLabel (label1); destroyCDKLabel (label2); destroyCDKLabel (instruct); destroyCDKScreen (cdkscreen); endCDK (); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/raiseCDKObject_ex.c0000644000175100001440000001272410354064363017003 0ustar tomusers/* $Id: raiseCDKObject_ex.c,v 1.8 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "raiseCDKObject_ex"; #endif #define MY_LABEL(p) ObjOf(p)->screenIndex | 0x30 | A_UNDERLINE | A_BOLD int main(int argc, char **argv) { char ch; char *mesg[1]; char *mesg1[10]; char *mesg2[10]; char *mesg3[10]; char *mesg4[10]; WINDOW *cursesWin; CDKSCREEN *cdkscreen; CDKLABEL *label1, *label2, *label3, *label4, *instruct; CDK_PARAMS params; CDKparseParams(argc, argv, ¶ms, CDK_MIN_PARAMS); /* Set up CDK. */ cursesWin = initscr (); cdkscreen = initCDKScreen (cursesWin); mesg1[0] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[1] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[2] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[3] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[4] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[5] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[6] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[7] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[8] = "label1 label1 label1 label1 label1 label1 label1"; mesg1[9] = "label1 label1 label1 label1 label1 label1 label1"; label1 = newCDKLabel (cdkscreen, 10, 4, mesg1, 10, TRUE, FALSE); setCDKLabelULChar (label1, '1' | A_BOLD); mesg2[0] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[1] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[2] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[3] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[4] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[5] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[6] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[7] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[8] = "label2 label2 label2 label2 label2 label2 label2"; mesg2[9] = "label2 label2 label2 label2 label2 label2 label2"; label2 = newCDKLabel (cdkscreen, 8, 8, mesg2, 10, TRUE, FALSE); setCDKLabelULChar (label2, '2' | A_BOLD); mesg3[0] = "label3 label3 label3 label3 label3 label3 label3"; mesg3[1] = "label3 label3 label3 label3 label3 label3 label3"; mesg3[2] = "label3 label3 label3 label3 label3 label3 label3"; mesg3[3] = "label3 label3 label3 label3 label3 label3 label3"; mesg3[4] = "label3 label3 label3 label3 label3 label3 label3"; mesg3[5] = "label3 label3 label3 label3 label3 label3 label3"; mesg3[6] = "label3 label3 label3 label3 label3 label3 label3"; mesg3[7] = "label3 label3 label3 label3 label3 label3 label3"; mesg3[8] = "label3 label3 label3 label3 label3 label3 label3"; mesg3[9] = "label3 label3 label3 label3 label3 label3 label3"; label3 = newCDKLabel (cdkscreen, 6, 12, mesg3, 10, TRUE, FALSE); setCDKLabelULChar (label3, '3' | A_BOLD); mesg4[0] = "label4 label4 label4 label4 label4 label4 label4"; mesg4[1] = "label4 label4 label4 label4 label4 label4 label4"; mesg4[2] = "label4 label4 label4 label4 label4 label4 label4"; mesg4[3] = "label4 label4 label4 label4 label4 label4 label4"; mesg4[4] = "label4 label4 label4 label4 label4 label4 label4"; mesg4[5] = "label4 label4 label4 label4 label4 label4 label4"; mesg4[6] = "label4 label4 label4 label4 label4 label4 label4"; mesg4[7] = "label4 label4 label4 label4 label4 label4 label4"; mesg4[8] = "label4 label4 label4 label4 label4 label4 label4"; mesg4[9] = "label4 label4 label4 label4 label4 label4 label4"; label4 = newCDKLabel (cdkscreen, 4, 16, mesg4, 10, TRUE, FALSE); setCDKLabelULChar (label4, '4' | A_BOLD); mesg[0] = "# - raise label#, r - redraw, q - quit"; instruct = newCDKLabel (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', BOTTOM), mesg, 1, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); setCDKLabelULChar (instruct, ' ' | A_NORMAL); setCDKLabelURChar (instruct, ' ' | A_NORMAL); setCDKLabelLLChar (instruct, ' ' | A_NORMAL); setCDKLabelVerticalChar (instruct, ' ' | A_NORMAL); setCDKLabelHorizontalChar (instruct, ' ' | A_NORMAL); setCDKLabelLRChar (label1, MY_LABEL (label1)); setCDKLabelLRChar (label2, MY_LABEL (label2)); setCDKLabelLRChar (label3, MY_LABEL (label3)); setCDKLabelLRChar (label4, MY_LABEL (label4)); setCDKLabelLRChar (instruct, MY_LABEL (instruct)); refreshCDKScreen (cdkscreen); while ((ch = getch ()) != 'q') { switch (ch) { case '1': raiseCDKObject (vLABEL, label1); break; case '2': raiseCDKObject (vLABEL, label2); break; case '3': raiseCDKObject (vLABEL, label3); break; case '4': raiseCDKObject (vLABEL, label4); break; case 'r': refreshCDKScreen (cdkscreen); break; default: continue; } setCDKLabelLRChar (label1, MY_LABEL (label1)); setCDKLabelLRChar (label2, MY_LABEL (label2)); setCDKLabelLRChar (label3, MY_LABEL (label3)); setCDKLabelLRChar (label4, MY_LABEL (label4)); setCDKLabelLRChar (instruct, MY_LABEL (instruct)); refreshCDKScreen (cdkscreen); } /* Clean up. */ destroyCDKLabel (label1); destroyCDKLabel (label2); destroyCDKLabel (label3); destroyCDKLabel (label4); destroyCDKLabel (instruct); destroyCDKScreen (cdkscreen); endCDK (); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/scale_ex.c0000644000175100001440000000425410354064363015315 0ustar tomusers/* $Id: scale_ex.c,v 1.9 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "scale_ex"; #endif /* * This program demonstrates the Cdk scale widget. */ int main (int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKSCALE *widget = 0; WINDOW *cursesWin = 0; char *title = "Select a value"; char *label = "Current value"; char temp[256], *mesg[5]; int selection; CDK_PARAMS params; int high; int inc; int low; CDKparseParams(argc, argv, ¶ms, "h:i:l:w:" CDK_MIN_PARAMS); high = CDKparamNumber2(¶ms, 'h', 100); inc = CDKparamNumber2(¶ms, 'i', 1); low = CDKparamNumber2(¶ms, 'l', 0); /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Colors. */ initCDKColor(); /* Create the widget. */ widget = newCDKScale (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), title, label, A_NORMAL, CDKparamNumber2(¶ms, 'w', 5), low, low, high, inc, (inc*2), CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); /* Is the widget null? */ if (widget == 0) { /* Exit CDK. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a message. */ printf ("Oops. Can't make the widget. Is the window too small?\n"); ExitProgram (EXIT_FAILURE); } /* Activate the widget. */ selection = activateCDKScale (widget, 0); /* Check the exit value of the widget. */ if (widget->exitType == vESCAPE_HIT) { mesg[0] = "You hit escape. No value selected."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (widget->exitType == vNORMAL) { sprintf (temp, "You selected %d", selection); mesg[0] = copyChar (temp); mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); freeChar (mesg[0]); } /* Clean up. */ destroyCDKScale (widget); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/slider_ex.c0000644000175100001440000000434310354064363015507 0ustar tomusers/* $Id: slider_ex.c,v 1.9 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "slider_ex"; #endif /* * This program demonstrates the Cdk slider widget. */ int main (int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKSLIDER *widget = 0; WINDOW *cursesWin = 0; char *title = "Enter a value:"; char *label = "Current Value:"; char temp[256], *mesg[5]; int selection; CDK_PARAMS params; int high; int inc; int low; CDKparseParams(argc, argv, ¶ms, "h:i:l:w:" CDK_MIN_PARAMS); high = CDKparamNumber2(¶ms, 'h', 100); inc = CDKparamNumber2(¶ms, 'i', 1); low = CDKparamNumber2(¶ms, 'l', 1); /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Colors. */ initCDKColor(); /* Create the widget. */ widget = newCDKSlider (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), title, label, A_REVERSE | COLOR_PAIR (29) | ' ', CDKparamNumber2(¶ms, 'w', 50), low, low, high, inc, (inc*2), CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); /* Is the widget null? */ if (widget == 0) { /* Exit CDK. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a message. */ printf ("Oops. Can't make the widget. Is the window too small?\n"); ExitProgram (EXIT_FAILURE); } /* Activate the widget. */ selection = activateCDKSlider (widget, 0); /* Check the exit value of the widget. */ if (widget->exitType == vESCAPE_HIT) { mesg[0] = "You hit escape. No value selected."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (widget->exitType == vNORMAL) { sprintf (temp, "You selected %d", selection); mesg[0] = copyChar (temp); mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); freeChar (mesg[0]); } /* Clean up.*/ destroyCDKSlider (widget); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/menu_ex.c0000644000175100001440000000757310354064363015201 0ustar tomusers/* $Id: menu_ex.c,v 1.11 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "menu_ex"; #endif static int displayCallback (EObjectType cdktype, void *object, void *clientData, chtype input); static char *menulist[MAX_MENU_ITEMS][MAX_SUB_ITEMS]; static char *menuInfo[3][4] = { {"", "This saves the current info.", "This exits the program.", ""}, {"", "This cuts text", "This copies text", "This pastes text"}, {"", "Help for editing", "Help for file management", "Info about the program"}}; /* * This program demonstratres the Cdk menu widget. */ int main (void) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKLABEL *infoBox = 0; CDKMENU*menu = 0; WINDOW*cursesWin = 0; int submenusize[3], menuloc[4]; char *mesg[5], temp[256]; int selection; /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK color. */ initCDKColor(); /* Set up the menu. */ menulist[0][0] = "File" ; menulist[1][0] = "Edit"; menulist[2][0] = "Help"; menulist[0][1] = "Save" ; menulist[1][1] = "Cut "; menulist[2][1] = "On Edit "; menulist[0][2] = "Exit" ; menulist[1][2] = "Copy"; menulist[2][2] = "On File "; menulist[1][3] = "Paste"; menulist[2][3] = "About..."; submenusize[0] = 3; menuloc[0] = LEFT; submenusize[1] = 4; menuloc[1] = LEFT; submenusize[2] = 4; menuloc[2] = RIGHT; /* Create the label window. */ mesg[0] = " "; mesg[1] = " "; mesg[2] = " "; mesg[3] = " "; infoBox = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 4, TRUE, TRUE); /* Create the menu. */ menu = newCDKMenu (cdkscreen, menulist, 3, submenusize, menuloc, TOP, A_UNDERLINE, A_REVERSE); /* Create the post process function. */ setCDKMenuPostProcess (menu, displayCallback, infoBox); /* Draw the CDK screen. */ refreshCDKScreen (cdkscreen); /* Activate the menu. */ selection = activateCDKMenu (menu, 0); /* Determine how the user exited from the widget. */ if (menu->exitType == vEARLY_EXIT) { mesg[0] = "You hit escape. No menu item was selected."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (menu->exitType == vNORMAL) { sprintf (temp, "You selected menu #%d, submenu #%d", selection/100, selection%100); mesg[0] = copyChar (temp); mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); freeChar (mesg[0]); } /* Clean up. */ destroyCDKMenu (menu); destroyCDKLabel (infoBox); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } /* * This gets called after every movement. */ static int displayCallback (EObjectType cdktype GCC_UNUSED, void *object, void *clientData, chtype input GCC_UNUSED) { CDKMENU *menu = (CDKMENU *)object; CDKLABEL *infoBox = (CDKLABEL *)clientData; char *mesg[10]; char temp[256]; /* Recreate the label message. */ sprintf (temp, "Title: %.*s", (int)(sizeof(temp) - 20), menulist[menu->currentTitle][0]); mesg[0] = strdup (temp); sprintf (temp, "Sub-Title: %.*s", (int)(sizeof(temp) - 20), menulist[menu->currentTitle][menu->currentSubtitle+1]); mesg[1] = strdup (temp); mesg[2] = ""; sprintf (temp, "%.*s", (int)(sizeof(temp) - 20), menuInfo[menu->currentTitle][menu->currentSubtitle+1]); mesg[3] = strdup (temp); /* Set the message of the label. */ setCDKLabel (infoBox, mesg, 4, TRUE); drawCDKLabel (infoBox, TRUE); /* Clean up. */ freeChar (mesg[0]); freeChar (mesg[1]); freeChar (mesg[3]); return 0; } cdk-5.0-20060507/examples/radio1_ex.c0000644000175100001440000000442610354064363015406 0ustar tomusers/* $Id: radio1_ex.c,v 1.10 2005/12/26 22:04:35 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "radio_ex"; #endif /* * This program demonstrates the Cdk radio widget. */ int main(int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = (CDKSCREEN *) NULL; CDKRADIO *radio = (CDKRADIO *) NULL; WINDOW *cursesWin = (WINDOW *) NULL; char *item[5] = {"Choice A", "Choice B", "Choice C"}; char *mesg[5], temp[100]; int selection; CDK_PARAMS params; CDKparseParams(argc, argv, ¶ms, "s:t:" CDK_CLI_PARAMS); /* Set up CDK. */ cursesWin = initscr (); cdkscreen = initCDKScreen (cursesWin); /* Set up CDK Colors. */ initCDKColor (); /* Create the radio list. */ radio = newCDKRadio (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), CDKparsePosition(CDKparamString2(¶ms, 's', "NONE")), CDKparamValue(¶ms, 'H', 5), CDKparamValue(¶ms, 'W', 20), CDKparamString(¶ms, 't'), item, 3, '#' | A_REVERSE, 1, A_REVERSE, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); /* Check if the radio list is NULL. */ if (radio == (CDKRADIO *) NULL) { /* Exit CDK. */ destroyCDKScreen (cdkscreen); endCDK (); /* Print out a message and exit. */ printf ("Oops. Can't seem to create the radio widget. "); printf ("Is the window too small??\n"); ExitProgram (EXIT_FAILURE); } /* Activate the radio list. */ selection = activateCDKRadio (radio, (chtype *) NULL); /* Check the exit status of the widget. */ if (radio->exitType == vESCAPE_HIT) { mesg[0] = "You hit escape. No item selected."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (radio->exitType == vNORMAL) { mesg[0] = "You selected the filename"; sprintf (temp, "%.*s", (int)(sizeof(temp) - 20), item[selection]); mesg[1] = copyChar (temp); mesg[2] = ""; mesg[3] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 4); freeChar (mesg[1]); } destroyCDKRadio (radio); destroyCDKScreen (cdkscreen); endCDK (); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/subwindow_ex.c0000644000175100001440000000401110354110422016222 0ustar tomusers/* $Id: subwindow_ex.c,v 1.10 2005/12/27 00:55:46 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "subwindow_ex"; #endif /* * This demo displays the ability to put widgets within a curses subwindow. */ int main (int argc, char **argv) { /* Declare vars. */ CDKSCREEN *cdkscreen; CDKSCROLL *dowList; CDKLABEL *title; WINDOW *mainWindow, *subWindow; char *dow[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; char *mesg[5]; int pick; CDK_PARAMS params; CDKparseParams(argc, argv, ¶ms, "s:" CDK_CLI_PARAMS); /* Start curses. */ mainWindow = initscr(); curs_set(0); /* Create a basic window. */ subWindow = newwin (LINES-5, COLS-10, 2, 5); /* Start Cdk. */ cdkscreen = initCDKScreen (subWindow); /* Box our window. */ box (subWindow, ACS_VLINE, ACS_HLINE); wrefresh (subWindow); /* Create a basic scrolling list inside the window. */ dowList = newCDKScroll (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), CDKparsePosition(CDKparamString2(¶ms, 's', "RIGHT")), CDKparamValue(¶ms, 'H', 10), CDKparamValue(¶ms, 'W', 15), "Pick a Day", dow, 7, NONUMBERS, A_REVERSE, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); /* Put a title within the window. */ mesg[0] = "<#HL(30)>"; mesg[1] = "This is a Cdk scrolling list"; mesg[2] = "inside a curses window."; mesg[3] = "<#HL(30)>"; title = newCDKLabel (cdkscreen, CENTER, 0, mesg, 4, FALSE, FALSE); /* Refresh the screen. */ refreshCDKScreen (cdkscreen); /* Let the user play. */ pick = activateCDKScroll (dowList, 0); /* Clean up. */ destroyCDKScroll (dowList); destroyCDKLabel (title); eraseCursesWindow (subWindow); destroyCDKScreen (cdkscreen); endCDK(); /* Tell them what they picked. */ printf ("You picked %s\n", dow[pick]); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/bind_ex.c0000644000175100001440000001070710354064363015142 0ustar tomusers/* $Id: bind_ex.c,v 1.16 2005/12/26 22:04:35 tom Exp $ */ #include #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; char *mesg[5]; /* Check which button we are on. */ if (dialog->currentButton == 0) { mesg[0] = "Help for Who."; mesg[1] = "When this button is picked the name of the current"; mesg[2] = "user is displayed on the screen in a popup window."; popupLabel (ScreenOf (dialog), mesg, 3); } else if (dialog->currentButton == 1) { mesg[0] = "Help for Time."; mesg[1] = "When this button is picked the current time is"; mesg[2] = "displayed on the screen in a popup window."; popupLabel (ScreenOf (dialog), mesg, 3); } else if (dialog->currentButton == 2) { mesg[0] = "Help for Date."; mesg[1] = "When this button is picked the current date is"; mesg[2] = "displayed on the screen in a popup window."; popupLabel (ScreenOf (dialog), mesg, 3); } else if (dialog->currentButton == 3) { mesg[0] = "Help for Quit."; mesg[1] = "When this button is picked the dialog box is exited."; popupLabel (ScreenOf (dialog), mesg, 2); } return (FALSE); } int main(int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen; CDKDIALOG *question; WINDOW *cursesWin; char *buttons[40]; char *message[40]; char *info[5]; char *loginName; char temp[256]; int selection; time_t clck; struct tm *currentTime; CDK_PARAMS params; CDKparseParams(argc, argv, ¶ms, CDK_MIN_PARAMS); /* Set up CDK. */ cursesWin = initscr (); cdkscreen = initCDKScreen (cursesWin); /* Start color. */ initCDKColor (); /* Set up the dialog box. */ message[0] = "Simple Command Interface"; message[1] = "Pick the command you wish to run."; message[2] = "Press ? for help."; buttons[0] = "Who"; buttons[1] = "Time"; buttons[2] = "Date"; buttons[3] = "Quit"; /* Create the dialog box. */ question = newCDKDialog (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), message, 3, buttons, 4, A_REVERSE, TRUE, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); /* Check if we got a null value back. */ if (question == (CDKDIALOG *) 0) { destroyCDKScreen (cdkscreen); /* End curses... */ endCDK (); /* Spit out a message. */ printf ("Oops. Can't seem to 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] = " Login Name "; loginName = getlogin (); if (loginName == (char *)0) { strcpy (temp, "Unknown"); } else { sprintf (temp, "<%.*s>", (int)(sizeof(temp) - 10), loginName); } info[1] = copyChar (temp); popupLabel (ScreenOf (question), info, 2); freeChar (info[1]); } else if (selection == 1) { /* Print out the time. */ time (&clck); currentTime = localtime (&clck); sprintf (temp, "%2d:%02d:%02d", currentTime->tm_hour, currentTime->tm_min, currentTime->tm_sec); info[0] = " Current Time "; info[1] = copyChar (temp); popupLabel (ScreenOf (question), info, 2); freeChar (info[1]); } else if (selection == 2) { /* Print out the date. */ time (&clck); currentTime = localtime (&clck); sprintf (temp, "%d/%02d/%02d", currentTime->tm_mday, currentTime->tm_mon + 1, currentTime->tm_year % 100); info[0] = " Current Date "; info[1] = copyChar (temp); popupLabel (ScreenOf (question), info, 2); freeChar (info[1]); } } /* Clean up. */ destroyCDKDialog (question); destroyCDKScreen (cdkscreen); endCDK (); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/Makefile.in0000644000175100001440000000545010354353133015426 0ustar tomusers# $Id: Makefile.in,v 1.18 2005/12/28 00:03:39 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 LIBS = -l@LIB_ROOTNAME@ @LIBS@ LIBTOOL = @LIBTOOL@ @ECHO_LT@ LIBTOOL_CLEAN = @LIB_CLEAN@ LIBTOOL_LINK = @LIB_LINK@ LINK = $(LIBTOOL_LINK) $(CC) x = @EXEEXT@ o = .@OBJEXT@ CFLAGS = @CFLAGS@ @EXTRA_CFLAGS@ CPPFLAGS = @DEFS@ -I../include -I$(srcdir)/../include -I. @CPPFLAGS@ LDFLAGS = -L.. @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 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 cdk-5.0-20060507/examples/viewer_ex.c0000644000175100001440000001177510355201160015522 0ustar tomusers/* $Id: viewer_ex.c,v 1.19 2005/12/30 09:48:32 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "viewer_ex"; #endif /* * This program demonstrates the file selector and the viewer widget. */ int main (int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKVIEWER *example = 0; CDKFSELECT *fSelect = 0; WINDOW *cursesWin = 0; char *title = "Pick\nA\nFile"; char *label = "File: "; char **info = 0; char *button[5]; char vTitle[256]; char *mesg[4]; char temp[256]; int selected, lines; CDK_PARAMS params; char *filename; /* specify filename, bypassing fselect */ char *directory; /* specify starting directory for fselect */ int interp_it; /* interpret embedded markup */ int link_it; /* load file via embedded link */ CDKparseParams(argc, argv, ¶ms, "f:d:il" CDK_CLI_PARAMS); filename = CDKparamString (¶ms, 'f'); directory = CDKparamString2 (¶ms, 'd', "."); interp_it = CDKparamNumber2 (¶ms, 'i', FALSE); link_it = CDKparamNumber2 (¶ms, 'l', FALSE); /* Create the viewer buttons. */ button[0] = ""; button[1] = ""; /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start color. */ initCDKColor(); /* Get the filename. */ if (filename == 0) { fSelect = newCDKFselect (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), CDKparamValue(¶ms, 'H', 20), CDKparamValue(¶ms, 'W', 65), title, label, A_NORMAL, '_', A_REVERSE, "", "", "", "", CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); if (fSelect == 0) { destroyCDKScreen (cdkscreen); endCDK(); fprintf(stderr, "Cannot create fselect-widget\n"); ExitProgram (EXIT_FAILURE); } /* * 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, "", "", "", "", ObjOf(fSelect)->box); /* 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] = "Escape hit. No file selected."; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); /* Exit CDK. */ destroyCDKFselect (fSelect); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } } /* Create the file viewer to view the file selected.*/ example = newCDKViewer (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), CDKparamValue(¶ms, 'H', 20), CDKparamValue(¶ms, 'W', -2), button, 2, A_REVERSE, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); /* Could we create the viewer widget? */ if (example == 0) { /* Exit CDK. */ destroyCDKFselect (fSelect); destroyCDKScreen (cdkscreen); endCDK(); /* Print out a message and exit. */ printf ("Oops. Can't seem to create viewer. Is the window too small?\n"); ExitProgram (EXIT_SUCCESS); } if (link_it) { info = (char **) calloc(2, sizeof(char *)); info[0] = (char *) malloc(5 + strlen(filename)); sprintf (info[0], "", filename); lines = -1; interp_it = TRUE; } else { setCDKViewer (example, "reading...", 0, 0, A_REVERSE, TRUE, TRUE, TRUE); /* Open the file and read the contents. */ lines = CDKreadFile (filename, &info); if (lines == -1) { endCDK(); printf ("Could not open \"%s\"\n", filename); ExitProgram (EXIT_FAILURE); } } /* Set up the viewer title, and the contents to the widget. */ sprintf (vTitle, "Filename:%20s", filename); setCDKViewer (example, vTitle, info, lines, A_REVERSE, interp_it, 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] = "Escape hit. No Button selected."; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (example->exitType == vNORMAL) { sprintf (temp, "You selected button %d", selected); mesg[0] = temp; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } /* Clean up. */ destroyCDKViewer (example); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/template_ex.c0000644000175100001440000000470710354110663016037 0ustar tomusers/* $Id: template_ex.c,v 1.11 2005/12/27 00:58:27 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "template_ex"; #endif /* * This program demonstrates the Cdk template widget. */ int main (int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKTEMPLATE *phoneNumber = 0; WINDOW *cursesWin = 0; char *title = "Title"; char *label = "Phone Number:"; char *Overlay = "(___) ___-____"; char *plate = "(###) ###-####"; char *info, *mixed, temp[256], *mesg[5]; CDK_PARAMS params; CDKparseParams(argc, argv, ¶ms, CDK_MIN_PARAMS); /* Set up CDK*/ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Colors. */ initCDKColor(); /* Declare the template. */ phoneNumber = newCDKTemplate (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), title, label, plate, Overlay, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); /* Is the template pointer null? */ if (phoneNumber == 0) { /* Exit CDK. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a message and exit. */ printf ("Oops. Can;'t seem to create template. Is the window too small?"); ExitProgram (EXIT_FAILURE); } /* Activate the template. */ info = activateCDKTemplate (phoneNumber, 0); /* Tell them what they typed. */ if (phoneNumber->exitType == vESCAPE_HIT) { mesg[0] = "You hit escape. No information typed in."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (phoneNumber->exitType == vNORMAL) { /* Mix the plate and the number. */ mixed = mixCDKTemplate (phoneNumber); /* Create the message to display. */ sprintf (temp, "Phone Number with out plate mixing : %.*s", (int)(sizeof(temp) - 50), info); mesg[0] = copyChar (temp); sprintf (temp, "Phone Number with the plate mixed in: %.*s", (int)(sizeof(temp) - 50), mixed); mesg[1] = copyChar (temp); mesg[2] = ""; mesg[3] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 4); freeChar (mesg[0]); freeChar (mesg[1]); freeChar (mixed); } /* Clean up. */ destroyCDKTemplate (phoneNumber); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/fslider_ex.c0000644000175100001440000000470710354311415015652 0ustar tomusers/* $Id: fslider_ex.c,v 1.1 2005/12/27 19:16:29 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "slider_ex"; #endif /* * This program demonstrates the Cdk slider widget. */ int main (int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKFSLIDER *widget = 0; WINDOW *cursesWin = 0; char *title = "Enter a value:"; char *label = "Current Value:"; char temp[256], *mesg[5]; float selection; CDK_PARAMS params; float high; float inc; float low; float scale; int n, digits; CDKparseParams(argc, argv, ¶ms, "h:i:l:w:p:" CDK_MIN_PARAMS); digits = CDKparamNumber2(¶ms, 'p', 0); scale = 1.0; for (n = 0; n < digits; ++n) { scale = scale * 10.0; } high = CDKparamNumber2(¶ms, 'h', 100) / scale; inc = CDKparamNumber2(¶ms, 'i', 1) / scale; low = CDKparamNumber2(¶ms, 'l', 1) / scale; /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Colors. */ initCDKColor(); /* Create the widget. */ widget = newCDKFSlider (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), title, label, A_REVERSE | COLOR_PAIR (29) | ' ', CDKparamNumber2(¶ms, 'w', 50), low, low, high, inc, (inc*2), digits, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); /* Is the widget null? */ if (widget == 0) { /* Exit CDK. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a message. */ printf ("Oops. Can't 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] = "You hit escape. No value selected."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (widget->exitType == vNORMAL) { sprintf (temp, "You selected %.*f", digits, selection); mesg[0] = copyChar (temp); mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); freeChar (mesg[0]); } /* Clean up.*/ destroyCDKFSlider (widget); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/uslider_ex.c0000644000175100001440000000447310354315137015676 0ustar tomusers/* $Id: uslider_ex.c,v 1.2 2005/12/27 19:47:43 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "uslider_ex"; #endif /* * This program demonstrates the Cdk unsigned-slider widget. */ int main (int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKUSLIDER *widget = 0; WINDOW *cursesWin = 0; char title[256]; char *label = "Current Value:"; char temp[256], *mesg[5]; unsigned selection; CDK_PARAMS params; unsigned high; unsigned inc; unsigned low; CDKparseParams(argc, argv, ¶ms, "h:i:l:w:" CDK_MIN_PARAMS); high = CDKparamNumber2(¶ms, 'h', 100); inc = CDKparamNumber2(¶ms, 'i', 1); low = CDKparamNumber2(¶ms, 'l', 1); sprintf(title, "Enter a value:\nLow %#x\nHigh %#x", low, high); /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Colors. */ initCDKColor(); /* Create the widget. */ widget = newCDKUSlider (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), title, label, A_REVERSE | COLOR_PAIR (29) | ' ', CDKparamNumber2(¶ms, 'w', 50), low, low, high, inc, (inc*2), CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); /* Is the widget null? */ if (widget == 0) { /* Exit CDK. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a message. */ printf ("Oops. Can't make the widget. Is the window too small?\n"); ExitProgram (EXIT_FAILURE); } /* Activate the widget. */ selection = activateCDKUSlider (widget, 0); /* Check the exit value of the widget. */ if (widget->exitType == vESCAPE_HIT) { mesg[0] = "You hit escape. No value selected."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (widget->exitType == vNORMAL) { sprintf (temp, "You selected %u", selection); mesg[0] = copyChar (temp); mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); freeChar (mesg[0]); } /* Clean up.*/ destroyCDKUSlider (widget); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/scroll_ex.c0000644000175100001440000001063210354371014015513 0ustar tomusers/* $Id: scroll_ex.c,v 1.22 2005/12/28 02:01:48 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "scroll_ex"; #endif static char *newLabel (char *prefix) { static int count; static char result[80]; sprintf (result, "%s%d", prefix, ++count); return result; } static int addItemCB (EObjectType cdktype GCC_UNUSED, void *object, void *clientData GCC_UNUSED, chtype input GCC_UNUSED) { CDKSCROLL *s = (CDKSCROLL *)object; addCDKScrollItem (s, newLabel ("add")); refreshCDKScreen (ScreenOf (s)); return (TRUE); } static int insItemCB (EObjectType cdktype GCC_UNUSED, void *object, void *clientData GCC_UNUSED, chtype input GCC_UNUSED) { CDKSCROLL *s = (CDKSCROLL *)object; insertCDKScrollItem (s, newLabel ("insert")); refreshCDKScreen (ScreenOf (s)); return (TRUE); } static int delItemCB (EObjectType cdktype GCC_UNUSED, void *object, void *clientData GCC_UNUSED, chtype input GCC_UNUSED) { CDKSCROLL *s = (CDKSCROLL *)object; deleteCDKScrollItem (s, getCDKScrollCurrent (s)); refreshCDKScreen (ScreenOf (s)); return (TRUE); } /* * This program demonstrates the Cdk scrolling list widget. * * Options (in addition to normal CLI parameters): * -c create the data after the widget * -s SPOS location for the scrollbar * -t TEXT title for the widget */ int main (int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKSCROLL *scrollList = 0; WINDOW *cursesWin = 0; char *title = "Pick a file"; char **item = 0; char *mesg[5], temp[256]; int selection, count; CDK_PARAMS params; CDKparseParams (argc, argv, ¶ms, "cs:t:" CDK_CLI_PARAMS); /* Set up CDK. */ cursesWin = initscr (); cdkscreen = initCDKScreen (cursesWin); /* Set up CDK Colors. */ initCDKColor (); /* Use the current diretory list to fill the radio list. */ count = CDKgetDirectoryContents (".", &item); /* Create the scrolling list. */ scrollList = newCDKScroll (cdkscreen, CDKparamValue (¶ms, 'X', CENTER), CDKparamValue (¶ms, 'Y', CENTER), CDKparsePosition(CDKparamString2(¶ms, 's', "RIGHT")), CDKparamValue (¶ms, 'H', 10), CDKparamValue (¶ms, 'W', 50), CDKparamString2(¶ms, 't', title), CDKparamNumber(¶ms, 'c') ? 0 : item, CDKparamNumber(¶ms, 'c') ? 0 : count, TRUE, A_REVERSE, CDKparamValue (¶ms, 'N', TRUE), CDKparamValue (¶ms, 'S', FALSE)); /* Is the scrolling list null? */ if (scrollList == 0) { /* Exit CDK. */ destroyCDKScreen (cdkscreen); endCDK (); /* Print out a message and exit. */ printf ("Oops. Could not make scrolling list. Is the window too small?\n"); ExitProgram (EXIT_FAILURE); } if (CDKparamNumber(¶ms, 'c')) { setCDKScrollItems (scrollList, item, count, TRUE); } #if 0 drawCDKScroll (scrollList, 1); setCDKScrollPosition (scrollList, 10); drawCDKScroll (scrollList, 1); sleep (3); setCDKScrollPosition (scrollList, 20); drawCDKScroll (scrollList, 1); sleep (3); setCDKScrollPosition (scrollList, 30); drawCDKScroll (scrollList, 1); sleep (3); setCDKScrollPosition (scrollList, 70); drawCDKScroll (scrollList, 1); sleep (3); #endif bindCDKObject (vSCROLL, scrollList, 'a', addItemCB, NULL); bindCDKObject (vSCROLL, scrollList, 'i', insItemCB, NULL); bindCDKObject (vSCROLL, scrollList, 'd', delItemCB, NULL); /* Activate the scrolling list. */ selection = activateCDKScroll (scrollList, 0); /* Determine how the widget was exited. */ if (scrollList->exitType == vESCAPE_HIT) { mesg[0] = "You hit escape. No file selected."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (scrollList->exitType == vNORMAL) { char *theItem = chtype2Char (scrollList->item[selection]); mesg[0] = "You selected the following file"; sprintf (temp, "%.*s", (int)(sizeof (temp) - 20), theItem); mesg[1] = temp; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); freeChar (theItem); } /* Clean up. */ CDKfreeStrings (item); destroyCDKScroll (scrollList); destroyCDKScreen (cdkscreen); endCDK (); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/itemlist_ex.c0000644000175100001440000000603010354356320016047 0ustar tomusers/* $Id: itemlist_ex.c,v 1.13 2005/12/28 00:31:12 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "itemlist_ex"; #endif #define MONTHS 12 /* * This program demonstrates the Cdk itemlist widget. * * Options (in addition to minimal CLI parameters): * -c create the data after the widget */ int main(int argc, char **argv) { /* Declare local variables. */ CDKSCREEN *cdkscreen = 0; CDKITEMLIST *monthlist = 0; WINDOW *cursesWin = 0; char *title = "Pick A Month"; char *label = "Month:"; char *info[MONTHS], temp[256], *mesg[10]; int choice, startMonth; struct tm *dateInfo; time_t clck; CDK_PARAMS params; CDKparseParams(argc, argv, ¶ms, "c" CDK_MIN_PARAMS); /* * Get the current date and set the default month to the * current month. */ time (&clck); dateInfo = localtime (&clck); startMonth = dateInfo->tm_mon; /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK colors. */ initCDKColor(); /* Create the choice list. */ info[0] = "January"; info[1] = "February"; info[2] = "March"; info[3] = "April"; info[4] = "May"; info[5] = "June"; info[6] = "July"; info[7] = "August"; info[8] = "September"; info[9] = "October"; info[10] = "November"; info[11] = "December"; /* Create the itemlist widget. */ monthlist = newCDKItemlist (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), title, label, CDKparamNumber(¶ms, 'c') ? 0 : info, CDKparamNumber(¶ms, 'c') ? 0 : MONTHS, startMonth, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); /* Is the widget null? */ if (monthlist == 0) { /* Clean up. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a little message. */ printf ("Oops. Can't seem to create the itemlist box. Is the window too small?\n"); ExitProgram (EXIT_FAILURE); } if (CDKparamNumber(¶ms, 'c')) { setCDKItemlistValues (monthlist, info, MONTHS, 0); } /* Activate the widget. */ choice = activateCDKItemlist (monthlist, 0); /* Check how they exited from the widget. */ if (monthlist->exitType == vESCAPE_HIT) { mesg[0] = "You hit escape. No item selected."; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (ScreenOf(monthlist), mesg, 3); } else if (monthlist->exitType == vNORMAL) { sprintf (temp, "You selected the %dth item which is", choice); mesg[0] = copyChar (temp); mesg[1] = info[choice]; mesg[2] = ""; mesg[3] = "Press any key to continue."; popupLabel (ScreenOf(monthlist), mesg, 4); freeChar (mesg[0]); } /* Clean up. */ destroyCDKItemlist (monthlist); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/radio_ex.c0000644000175100001440000000670310354366701015326 0ustar tomusers/* $Id: radio_ex.c,v 1.16 2005/12/28 01:43:29 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "radio_ex"; #endif /* * This program demonstrates the Cdk radio widget. * * Options (in addition to normal CLI parameters): * -c create the data after the widget * -s SPOS location for the scrollbar * -t TEXT title for the widget * */ int main(int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKRADIO *radio = 0; WINDOW *cursesWin = 0; char *title = "Select a filename"; char **item = 0; char *mesg[5], temp[256]; int selection, count; CDK_PARAMS params; CDKparseParams(argc, argv, ¶ms, "cs:t:" CDK_CLI_PARAMS); /* Use the current diretory list to fill the radio list. */ count = CDKgetDirectoryContents (".", &item); if (count <= 0) { fprintf(stderr, "Cannot get directory list\n"); ExitProgram (EXIT_FAILURE); } /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Set up CDK Colors. */ initCDKColor(); /* Create the radio list. */ radio = newCDKRadio (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), CDKparsePosition(CDKparamString2(¶ms, 's', "RIGHT")), CDKparamValue(¶ms, 'H', 10), CDKparamValue(¶ms, 'W', 40), CDKparamString2(¶ms, 't', title), CDKparamNumber(¶ms, 'c') ? 0 : item, CDKparamNumber(¶ms, 'c') ? 0 : count, '#'|A_REVERSE, 1, A_REVERSE, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); /* Check if the radio list is null. */ if (radio == 0) { /* Exit CDK. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a message and exit. */ printf ("Oops. Can't seem to create the radio widget. Is the window too small??\n"); ExitProgram (EXIT_FAILURE); } if (CDKparamNumber(¶ms, 'c')) { setCDKRadioItems (radio, item, count); } /* loop until user selects a file, or cancels */ for (;;) { /* Activate the radio list. */ selection = activateCDKRadio (radio, 0); /* Check the exit status of the widget. */ if (radio->exitType == vESCAPE_HIT) { mesg[0] = "You hit escape. No item selected."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); break; } else if (radio->exitType == vNORMAL) { struct stat sb; if (stat(item[selection], &sb) == 0 && (sb.st_mode & S_IFMT) == S_IFDIR) { char **nitem = 0; mesg[0] = "You selected a directory"; sprintf (temp, "%.*s", (int)(sizeof(temp) - 20), item[selection]); mesg[1] = temp; mesg[2] = ""; mesg[3] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 4); if ((count = CDKgetDirectoryContents (item[selection], &nitem)) > 0) { CDKfreeStrings(item); item = nitem; chdir(item[selection]); setCDKRadioItems (radio, item, count); } } else { mesg[0] = "You selected the filename"; sprintf (temp, "%.*s", (int)(sizeof(temp) - 20), item[selection]); mesg[1] = temp; mesg[2] = ""; mesg[3] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 4); break; } } } /* Clean up. */ CDKfreeStrings (item); destroyCDKRadio (radio); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/selection_ex.c0000644000175100001440000000605010354367172016213 0ustar tomusers/* $Id: selection_ex.c,v 1.15 2005/12/28 01:46:34 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "selection_ex"; #endif /* * This program demonstrates the Cdk selection widget. * * Options (in addition to normal CLI parameters): * -c create the data after the widget * -s SPOS location for the scrollbar * -t TEXT title for the widget * */ int main (int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKSELECTION *selection = 0; WINDOW *cursesWin = 0; char *title = "Pick one or more accounts."; char *choices[] = {" ", "-->"}; char **item = 0; char temp[256], *mesg[200]; struct passwd *ent; unsigned x, y; unsigned used = 0; unsigned count = 0; CDK_PARAMS params; CDKparseParams(argc, argv, ¶ms, "cs:t:" CDK_CLI_PARAMS); /* Use the account names to create a list. */ count = 0; while ((ent = getpwent ()) != 0) { used = CDKallocStrings(&item, ent->pw_name, count++, used); } endpwent(); count--; /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Set up CDK Colors. */ initCDKColor(); /* Create the selection list. */ selection = newCDKSelection (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), CDKparsePosition(CDKparamString2(¶ms, 's', "RIGHT")), CDKparamValue(¶ms, 'H', 10), CDKparamValue(¶ms, 'W', 50), CDKparamString2(¶ms, 't', title), CDKparamNumber(¶ms, 'c') ? 0 : item, CDKparamNumber(¶ms, 'c') ? 0 : count, choices, 2, A_REVERSE, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); /* Is the selection list null? */ if (selection == 0) { /* Exit CDK. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a message and exit. */ printf ("Oops. Can;t seem to create the selection list. Is the window too small?\n"); ExitProgram (EXIT_FAILURE); } if (CDKparamNumber(¶ms, 'c')) { setCDKSelectionItems (selection, item, count); } /* Activate the selection list. */ activateCDKSelection (selection, 0); /* Check the exit status of the widget. */ if (selection->exitType == vESCAPE_HIT) { mesg[0] = "You hit escape. No items selected."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (selection->exitType == vNORMAL) { mesg[0] = "Here are the accounts you selected."; y = 1; for (x=0; x < count; x++) { if (selection->selections[x] == 1) { sprintf (temp, "%.*s", (int)(sizeof(temp) - 20), item[x]); mesg[y++] = copyChar (temp); } } popupLabel (cdkscreen, mesg, y); /* Clean up. */ for (x=1; x < y; x++) { freeChar (mesg[x]); } } /* Clean up. */ CDKfreeStrings (item); destroyCDKSelection (selection); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/traverse_ex.c0000644000175100001440000004115510355064042016055 0ustar tomusers/* $Id: traverse_ex.c,v 1.21 2005/12/29 22:50:10 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "entry_ex"; #endif #define NumElements(a) ((sizeof a)/(sizeof a[0])) #define MY_MAX 3 static CDKOBJS *all_objects[MY_MAX]; static char *yes_no[] = { "Yes", "NO" }; static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; static char *choices[] = { "[ ]", "[*]" }; /* * Exercise all widgets except * CDKMENU * CDKTRAVERSE * The names in parentheses do not accept input, so they will never have * focus for traversal. The names with leading "*" have some limitation * that makes them not useful in traversal. */ /* *INDENT-OFF* */ static const struct { char *name; EObjectType type; } menu_table[] = { { "(CDKGRAPH)", vGRAPH }, /* no traversal (not active) */ { "(CDKHISTOGRAM)", vHISTOGRAM }, /* no traversal (not active) */ { "(CDKLABEL)", vLABEL }, /* no traversal (not active) */ { "(CDKMARQUEE)", vMARQUEE }, /* hangs (leaves trash) */ { "*CDKVIEWER", vVIEWER }, /* traversal out-only on OK */ { "CDKALPHALIST", vALPHALIST }, { "CDKBUTTON", vBUTTON }, { "CDKBUTTONBOX", vBUTTONBOX }, { "CDKCALENDAR", vCALENDAR }, { "CDKDIALOG", vDIALOG }, { "CDKDSCALE", vDSCALE }, { "CDKENTRY", vENTRY }, { "CDKFSCALE", vFSCALE }, { "CDKFSELECT", vFSELECT }, { "CDKFSLIDER", vFSLIDER }, { "CDKITEMLIST", vITEMLIST }, { "CDKMATRIX", vMATRIX }, { "CDKMENTRY", vMENTRY }, { "CDKRADIO", vRADIO }, { "CDKSCALE", vSCALE }, { "CDKSCROLL", vSCROLL }, { "CDKSELECTION", vSELECTION }, { "CDKSLIDER", vSLIDER }, { "CDKSWINDOW", vSWINDOW }, { "CDKTEMPLATE", vTEMPLATE }, { "CDKUSCALE", vUSCALE }, { "CDKUSLIDER", vUSLIDER }, }; /* *INDENT-ON* */ static CDKOBJS *make_alphalist (CDKSCREEN *cdkscreen, int x, int y) { CDKALPHALIST *widget = newCDKAlphalist (cdkscreen, x, y, 10, 15, "AlphaList", "->", months, NumElements (months), '_', A_REVERSE, TRUE, FALSE); return ObjPtr (widget); } static CDKOBJS *make_button (CDKSCREEN *cdkscreen, int x, int y) { CDKBUTTON *widget = newCDKButton (cdkscreen, x, y, "A Button!", NULL, TRUE, FALSE); return ObjPtr (widget); } static CDKOBJS *make_buttonbox (CDKSCREEN *cdkscreen, int x, int y) { CDKBUTTONBOX *widget = newCDKButtonbox (cdkscreen, x, y, 10, 16, "ButtonBox", 6, 2, months, NumElements (months), A_REVERSE, TRUE, FALSE); return ObjPtr (widget); } static CDKOBJS *make_calendar (CDKSCREEN *cdkscreen, int x, int y) { CDKCALENDAR *widget = newCDKCalendar (cdkscreen, x, y, "Calendar", 25, 1, 2000, COLOR_PAIR (16) | A_BOLD, COLOR_PAIR (24) | A_BOLD, COLOR_PAIR (32) | A_BOLD, COLOR_PAIR (40) | A_REVERSE, TRUE, FALSE); return ObjPtr (widget); } static CDKOBJS *make_dialog (CDKSCREEN *cdkscreen, int x, int y) { static char *message[] = { "This is a simple dialog box" ,"Is it simple enough?" }; CDKDIALOG *widget = newCDKDialog (cdkscreen, x, y, message, NumElements (message), yes_no, NumElements (yes_no), COLOR_PAIR (2) | A_REVERSE, TRUE, TRUE, FALSE); return ObjPtr (widget); } static CDKOBJS *make_dscale (CDKSCREEN *cdkscreen, int x, int y) { CDKDSCALE *widget = newCDKDScale (cdkscreen, x, y, "DScale", "Value", A_NORMAL, 15, 0.0, 0.0, 100.0, 1.0, (1.0 * 2.), 1, TRUE, FALSE); return ObjPtr (widget); } static CDKOBJS *make_entry (CDKSCREEN *cdkscreen, int x, int y) { CDKENTRY *widget = newCDKEntry (cdkscreen, x, y, NULL, "Entry: ", A_NORMAL, '.', vMIXED, 40, 0, 256, TRUE, FALSE); return ObjPtr (widget); } static CDKOBJS *make_fscale (CDKSCREEN *cdkscreen, int x, int y) { CDKFSCALE *widget = newCDKFScale (cdkscreen, x, y, "FScale", "Value", A_NORMAL, 15, 0.0, 0.0, 100.0, 1.0, (1.0 * 2.), 1, TRUE, FALSE); return ObjPtr (widget); } static CDKOBJS *make_fslider (CDKSCREEN *cdkscreen, int x, int y) { float low = -32; float high = 64; float inc = 0.1; CDKFSLIDER *widget = newCDKFSlider (cdkscreen, x, y, "FSlider", "Label", A_REVERSE | COLOR_PAIR (29) | ' ', 20, low, low, high, inc, (inc * 2), 3, TRUE, FALSE); /* selection = activateCDKSlider (widget, 0); */ return ObjPtr (widget); } static CDKOBJS *make_fselect (CDKSCREEN *cdkscreen, int x, int y) { CDKFSELECT *widget = newCDKFselect (cdkscreen, x, y, 15, 25, "FSelect", "->", A_NORMAL, '_', A_REVERSE, "", "", "", "", TRUE, FALSE); return ObjPtr (widget); } static CDKOBJS *make_graph (CDKSCREEN *cdkscreen, int x, int y) { static int values[] = {10, 15, 20, 25, 30, 35, 40, 45, 50, 55}; static char *graphChars = "0123456789"; CDKGRAPH *widget = newCDKGraph (cdkscreen, x, y, 10, 25, "title", "X-axis", "Y-axis"); setCDKGraph (widget, values, NumElements (values), graphChars, TRUE, vPLOT); return ObjPtr (widget); } static CDKOBJS *make_histogram (CDKSCREEN *cdkscreen, int x, int y) { CDKHISTOGRAM *widget = newCDKHistogram (cdkscreen, x, y, 1, 20, HORIZONTAL, "Histogram", TRUE, FALSE); setCDKHistogram (widget, vPERCENT, CENTER, A_BOLD, 0, 10, 6, ' ' | A_REVERSE, TRUE); return ObjPtr (widget); } static CDKOBJS *make_itemlist (CDKSCREEN *cdkscreen, int x, int y) { CDKITEMLIST *widget = newCDKItemlist (cdkscreen, x, y, NULL, "Month ", months, NumElements (months), 1, TRUE, FALSE); return ObjPtr (widget); } static CDKOBJS *make_label (CDKSCREEN *cdkscreen, int x, int y) { static char *message[] = { "This is a simple label." ,"Is it simple enough?" }; CDKLABEL *widget = newCDKLabel (cdkscreen, x, y, message, NumElements (message), TRUE, TRUE); return ObjPtr (widget); } static CDKOBJS *make_marquee (CDKSCREEN *cdkscreen, int x, int y) { CDKMARQUEE *widget = newCDKMarquee (cdkscreen, x, y, 30, TRUE, TRUE); activateCDKMarquee (widget, "This is a message", 5, 3, TRUE); destroyCDKMarquee (widget); return 0; } static CDKOBJS *make_matrix (CDKSCREEN *cdkscreen, int x, int y) { #define NUMROWS 8 #define NUMCOLS 5 CDKMATRIX *widget; char *coltitle[NUMCOLS + 1]; char *rowtitle[NUMROWS + 1]; char temp[80]; int cols = NUMCOLS; int colwidth[NUMCOLS + 1]; int coltypes[NUMCOLS + 1]; int maxwidth = 0; int n; int rows = NUMROWS; int vcols = 3; int vrows = 3; for (n = 0; n <= NUMROWS; ++n) { sprintf (temp, "row%d", n); rowtitle[n] = copyChar (temp); } for (n = 0; n <= NUMCOLS; ++n) { sprintf (temp, "col%d", n); coltitle[n] = copyChar (temp); colwidth[n] = strlen (temp); coltypes[n] = vUCHAR; if (colwidth[n] > maxwidth) maxwidth = colwidth[n]; } widget = newCDKMatrix (cdkscreen, x, y, rows, cols, vrows, vcols, "Matrix", rowtitle, coltitle, colwidth, coltypes, -1, -1, '.', COL, TRUE, TRUE, FALSE); return ObjPtr (widget); } static CDKOBJS *make_mentry (CDKSCREEN *cdkscreen, int x, int y) { CDKMENTRY *widget = newCDKMentry (cdkscreen, x, y, "MEntry", "Label", A_BOLD, '.', vMIXED, 20, 5, 20, 0, TRUE, FALSE); return ObjPtr (widget); } static CDKOBJS *make_radio (CDKSCREEN *cdkscreen, int x, int y) { CDKRADIO *widget = newCDKRadio (cdkscreen, x, y, RIGHT, 10, 20, "Radio", months, NumElements (months), '#' | A_REVERSE, 1, A_REVERSE, TRUE, FALSE); return ObjPtr (widget); } static CDKOBJS *make_scale (CDKSCREEN *cdkscreen, int x, int y) { int low = 2; int high = 25; int inc = 1; CDKSCALE *widget = newCDKScale (cdkscreen, x, y, "Scale", "Label", A_NORMAL, 5, low, low, high, inc, (inc * 2), TRUE, FALSE); return ObjPtr (widget); } static CDKOBJS *make_scroll (CDKSCREEN *cdkscreen, int x, int y) { CDKSCROLL *widget = newCDKScroll (cdkscreen, x, y, RIGHT, 10, 20, "Scroll", months, NumElements (months), TRUE, A_REVERSE, TRUE, FALSE); return ObjPtr (widget); } static CDKOBJS *make_slider (CDKSCREEN *cdkscreen, int x, int y) { int low = 2; int high = 25; int inc = 1; CDKSLIDER *widget = newCDKSlider (cdkscreen, x, y, "Slider", "Label", A_REVERSE | COLOR_PAIR (29) | ' ', 20, low, low, high, inc, (inc * 2), TRUE, FALSE); /* selection = activateCDKSlider (widget, 0); */ return ObjPtr (widget); } static CDKOBJS *make_selection (CDKSCREEN *cdkscreen, int x, int y) { CDKSELECTION *widget = newCDKSelection (cdkscreen, x, y, NONE, 8, 20, "Selection", months, NumElements (months), choices, NumElements (choices), A_REVERSE, TRUE, FALSE); return ObjPtr (widget); } static CDKOBJS *make_swindow (CDKSCREEN *cdkscreen, int x, int y) { CDKSWINDOW *widget = newCDKSwindow (cdkscreen, x, y, 6, 25, "SWindow", 100, TRUE, FALSE); int n; for (n = 0; n < 30; ++n) { char temp[80]; sprintf (temp, "Line %d", n); addCDKSwindow (widget, temp, BOTTOM); } activateCDKSwindow (widget, 0); return ObjPtr (widget); } static CDKOBJS *make_template (CDKSCREEN *cdkscreen, int x, int y) { char *Overlay = "(___) ___-____"; char *plate = "(###) ###-####"; CDKTEMPLATE *widget = newCDKTemplate (cdkscreen, x, y, "Template", "Label", plate, Overlay, TRUE, FALSE); activateCDKTemplate (widget, 0); return ObjPtr (widget); } static CDKOBJS *make_uscale (CDKSCREEN *cdkscreen, int x, int y) { int low = 0; int high = 65535; int inc = 1; CDKUSCALE *widget = newCDKUScale (cdkscreen, x, y, "UScale", "Label", A_NORMAL, 5, low, low, high, inc, (inc * 32), TRUE, FALSE); return ObjPtr (widget); } static CDKOBJS *make_uslider (CDKSCREEN *cdkscreen, int x, int y) { int low = 0; int high = 65535; int inc = 1; CDKUSLIDER *widget = newCDKUSlider (cdkscreen, x, y, "USlider", "Label", A_REVERSE | COLOR_PAIR (29) | ' ', 20, low, low, high, inc, (inc * 32), TRUE, FALSE); /* selection = activateCDKSlider (widget, 0); */ return ObjPtr (widget); } static CDKOBJS *make_viewer (CDKSCREEN *cdkscreen, int x, int y) { static char *button[1] = {"Ok"}; CDKVIEWER *widget = newCDKViewer (cdkscreen, x, y, 10, 20, button, 1, A_REVERSE, TRUE, FALSE); setCDKViewer (widget, "Viewer", months, NumElements (months), A_REVERSE, FALSE, TRUE, TRUE); activateCDKViewer (widget, 0); return ObjPtr (widget); } static void rebind_esc (CDKOBJS *obj) { bindCDKObject (ObjTypeOf (obj), obj, KEY_F (1), getcCDKBind, (void *)KEY_ESC); } static void make_any (CDKSCREEN *cdkscreen, int menu, EObjectType type) { CDKOBJS *(*func) (CDKSCREEN *, int, int) = 0; CDKOBJS *prior = 0; int x; int y; /* setup positions, staggered a little */ switch (menu) { case 0: x = LEFT; y = 2; break; case 1: x = CENTER; y = 4; break; case 2: x = RIGHT; y = 6; break; default: beep (); return; } /* find the function to make a widget of the given type */ switch (type) { case vALPHALIST: func = make_alphalist; break; case vBUTTON: func = make_button; break; case vBUTTONBOX: func = make_buttonbox; break; case vCALENDAR: func = make_calendar; break; case vDIALOG: func = make_dialog; break; case vDSCALE: func = make_dscale; break; case vENTRY: func = make_entry; break; case vFSCALE: func = make_fscale; break; case vFSELECT: func = make_fselect; break; case vFSLIDER: func = make_fslider; break; case vGRAPH: func = make_graph; break; case vHISTOGRAM: func = make_histogram; break; case vITEMLIST: func = make_itemlist; break; case vLABEL: func = make_label; break; case vMARQUEE: func = make_marquee; break; case vMATRIX: func = make_matrix; break; case vMENTRY: func = make_mentry; break; case vRADIO: func = make_radio; break; case vSCALE: func = make_scale; break; case vSCROLL: func = make_scroll; break; case vSELECTION: func = make_selection; break; case vSLIDER: func = make_slider; break; case vSWINDOW: func = make_swindow; break; case vTEMPLATE: func = make_template; break; case vUSCALE: func = make_uscale; break; case vUSLIDER: func = make_uslider; break; case vVIEWER: func = make_viewer; break; case vMENU: case vTRAVERSE: case vNULL: if (type > 0) beep (); return; } /* erase the old widget */ if ((prior = all_objects[menu]) != 0) { EraseObj (prior); _destroyCDKObject (prior); all_objects[menu] = 0; } /* create the new widget */ if (func != 0) { CDKOBJS *widget = func (cdkscreen, x, y); if (widget != 0) { all_objects[menu] = widget; rebind_esc (widget); } else flash (); } else { beep (); } } /* * Whenever we get a menu selection, create the selected widget. */ static int preHandler (EObjectType cdktype GCC_UNUSED, void *object, void *clientData GCC_UNUSED, chtype input GCC_UNUSED) { int mp, sp; CDKSCREEN *screen; WINDOW *window; switch (input) { case KEY_ENTER: getCDKMenuCurrentItem ((CDKMENU *)object, &mp, &sp); screen = ScreenOf ((CDKMENU *)object); window = screen->window; mvwprintw (window, getmaxy (window) - 1, 0, "selection %d/%d", mp, sp); clrtoeol (); refresh (); if (sp >= 0 && sp < (int)NumElements (menu_table)) make_any (screen, mp, menu_table[sp].type); break; } return 1; } /* * This demonstrates the Cdk widget-traversal. */ int main (int argc GCC_UNUSED, char **argv GCC_UNUSED) { unsigned j, k; /* Declare local variables. */ CDKSCREEN *cdkscreen = NULL; CDKMENU *menu = NULL; WINDOW *cursesWin = NULL; char *mesg[3]; static char *menulist[MAX_MENU_ITEMS][MAX_SUB_ITEMS] = { {"Left"}, {"Center"}, {"Right"}, }; static int submenusize[] = { NumElements (menu_table) + 1, NumElements (menu_table) + 1, NumElements (menu_table) + 1 }; static int menuloc[] = {LEFT, LEFT, RIGHT}; for (j = 0; j < MY_MAX; ++j) { for (k = 0; k < NumElements (menu_table); ++k) { menulist[j][k + 1] = menu_table[k].name; } } /* Set up CDK. */ cursesWin = initscr (); cdkscreen = initCDKScreen (cursesWin); /* Start CDK colors. */ initCDKColor (); menu = newCDKMenu (cdkscreen, menulist, MY_MAX, submenusize, menuloc, TOP, A_UNDERLINE, A_REVERSE); if (menu == 0) { destroyCDKScreen (cdkscreen); endCDK (); printf ("? Cannot create menus\n"); ExitProgram (EXIT_FAILURE); } rebind_esc (ObjOf (menu)); setCDKMenuPreProcess (menu, preHandler, 0); /* setup the initial display */ make_any (cdkscreen, 0, vENTRY); #if MY_MAX > 1 make_any (cdkscreen, 1, vITEMLIST); #if MY_MAX > 2 make_any (cdkscreen, 2, vSELECTION); #endif #endif /* Draw the screen. */ refreshCDKScreen (cdkscreen); /* Traverse the screen */ traverseCDKScreen (cdkscreen); mesg[0] = "Done"; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); /* Clean up and exit. */ for (j = 0; j < MY_MAX; ++j) { if (all_objects[j] != 0) _destroyCDKObject (all_objects[j]); } destroyCDKMenu (menu); destroyCDKScreen (cdkscreen); endCDK (); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/buttonbox_ex.c0000644000175100001440000000503110355201370016234 0ustar tomusers/* $Id: buttonbox_ex.c,v 1.18 2005/12/30 09:50:48 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "buttonbox_ex"; #endif static BINDFN_PROTO (entryCB); /* * This program demonstrates the Cdk buttonbox widget. */ int main (void) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKBUTTONBOX *buttonWidget = 0; CDKENTRY *entry = 0; WINDOW *cursesWin = 0; char *buttons[] = {" OK ", " Cancel "}; char *info = 0; int selection; /* Set up CDK. */ cursesWin = initscr (); cdkscreen = initCDKScreen (cursesWin); /* Start color. */ initCDKColor (); /* Create the entry widget. */ entry = newCDKEntry (cdkscreen, CENTER, CENTER, "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, 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 (); /* Spit out some info. */ printf ("You typed in (%s) and selected button (%s)\n", (info != 0) ? info : "", 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; injectCDKButtonbox (buttonbox, key); return (TRUE); } cdk-5.0-20060507/examples/viewer_ex2.c0000644000175100001440000000632010355201224015573 0ustar tomusers/* $Id: viewer_ex2.c,v 1.5 2005/12/30 09:49:08 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "viewer_ex"; #endif /* * This program demonstrates the viewFile() function. */ int main (int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = 0; CDKFSELECT *fSelect = 0; WINDOW *cursesWin = 0; char *title = "Pick\nA\nFile"; char *label = "File: "; char *button[5]; char vTitle[256]; char *mesg[4]; char temp[256]; int selected; CDK_PARAMS params; char *filename; /* specify filename, bypassing fselect */ char *directory; /* specify starting directory for fselect */ int interp_it; /* interpret embedded markup */ CDKparseParams(argc, argv, ¶ms, "f:d:i" CDK_CLI_PARAMS); filename = CDKparamString (¶ms, 'f'); directory = CDKparamString2 (¶ms, 'd', "."); interp_it = CDKparamNumber2 (¶ms, 'i', FALSE); /* Create the viewer buttons. */ button[0] = ""; button[1] = ""; /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start color. */ initCDKColor(); /* Get the filename. */ if (filename == 0) { fSelect = newCDKFselect (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), CDKparamValue(¶ms, 'H', 20), CDKparamValue(¶ms, 'W', 65), title, label, A_NORMAL, '_', A_REVERSE, "", "", "", "", CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', FALSE)); if (fSelect == 0) { destroyCDKScreen (cdkscreen); endCDK(); fprintf(stderr, "Cannot create fselect-widget\n"); ExitProgram (EXIT_FAILURE); } /* * 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, "", "", "", "", ObjOf(fSelect)->box); /* 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] = "Escape hit. No file selected."; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); /* Exit CDK. */ destroyCDKFselect (fSelect); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } } /* Set up the viewer title, and the contents to the widget. */ sprintf (vTitle, "Filename:%20s", filename); selected = viewFile (cdkscreen, vTitle, filename, button, 2); /* Destroy the file selector widget (do not need filename anymore) */ destroyCDKFselect (fSelect); /* Check how the person exited from the widget.*/ sprintf (temp, "You selected button %d", selected); mesg[0] = temp; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); /* Clean up. */ destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/fselect_ex.c0000644000175100001440000002113310427476544015657 0ustar tomusers/* $Id: fselect_ex.c,v 1.22 2006/05/07 23:06:12 tom Exp $ */ #include #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, 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, 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 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, message, CDKcountStrings (message)); return TRUE; } static int do_reload (CB_PARAMS) { int result = FALSE; if (userSize) { CDKFSELECT *widget = (CDKFSELECT *)clientdata; setCDKFselectContents (widget, 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 + 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, newlist, size); setCDKScrollCurrentTop (widget->scrollField, myUndoList[undoSize].topline); setCDKFselectCurrentItem (widget, myUndoList[undoSize].position); drawCDKFselect (widget, BorderOf (widget)); result = TRUE; } return result; } int main (int argc, char **argv) { CDKVIEWER *example = 0; CDKFSELECT *fSelect = 0; WINDOW *cursesWin = 0; char *title = "Pick\nA\nFile"; char *label = "File: "; char **info = 0; char *button[5], *filename, vTitle[256], *mesg[4], temp[256]; int selected, lines; CDK_PARAMS params; char *directory; CDKparseParams (argc, argv, ¶ms, "d:" CDK_CLI_PARAMS); directory = CDKparamString2 (¶ms, 'd', "."); /* Create the viewer buttons. */ button[0] = ""; button[1] = ""; /* Set up CDK. */ cursesWin = initscr (); cdkscreen = initCDKScreen (cursesWin); /* Start color. */ initCDKColor (); /* Get the filename. */ fSelect = newCDKFselect (cdkscreen, CDKparamValue (¶ms, 'X', CENTER), CDKparamValue (¶ms, 'Y', CENTER), CDKparamValue (¶ms, 'H', 20), CDKparamValue (¶ms, 'W', 65), title, label, A_NORMAL, '_', A_REVERSE, "", "", "", "", CDKparamValue (¶ms, 'N', TRUE), CDKparamValue (¶ms, '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, "", "", "", "", ObjOf (fSelect)->box); myUserList = copyCharList (getCDKFselectContents (fSelect, &userSize)); myUndoList = (UNDO *) malloc (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] = "Escape hit. No file selected."; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, 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, button, 2, A_REVERSE, TRUE, FALSE); /* Could we create the viewer widget? */ if (example == 0) { /* Exit CDK. */ destroyCDKFselect (fSelect); destroyCDKScreen (cdkscreen); endCDK (); /* Print out a message and exit. */ printf ("Oops. 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, "Filename:%20s", filename); setCDKViewer (example, vTitle, 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] = "Escape hit. No Button selected."; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (example->exitType == vNORMAL) { sprintf (temp, "You selected button %d", selected); mesg[0] = temp; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } /* Clean up. */ destroyCDKViewer (example); destroyCDKScreen (cdkscreen); endCDK (); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/examples/alphalist_ex.c0000644000175100001440000001647510427477626016232 0ustar tomusers/* $Id: alphalist_ex.c,v 1.22 2006/05/07 23:15:34 tom Exp $ */ #include #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) { struct passwd *ent; int x = 0; unsigned used = 0; while ((ent = getpwent ()) != 0) { used = CDKallocStrings (list, ent->pw_name, x++, used); } endpwent (); 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, 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, 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 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, message, CDKcountStrings (message)); return TRUE; } static int do_reload (CB_PARAMS) { int result = FALSE; if (userSize) { CDKALPHALIST *widget = (CDKALPHALIST *)clientdata; setCDKAlphalistContents (widget, 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 + 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, newlist, size); setCDKScrollCurrentTop (widget->scrollField, myUndoList[undoSize].topline); setCDKAlphalistCurrentItem (widget, myUndoList[undoSize].position); drawCDKAlphalist (widget, BorderOf (widget)); result = TRUE; } return result; } int main (int argc, char **argv) { CDKALPHALIST *alphaList = 0; WINDOW *cursesWin = 0; char *title = "Alpha List\nTitle"; char *label = "Account: "; char *word = 0; char **userList = 0; char *mesg[5], temp[256]; CDK_PARAMS params; CDKparseParams (argc, argv, ¶ms, "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 (userList); myUndoList = (UNDO *) malloc (userSize * sizeof (UNDO)); undoSize = 0; /* Set up CDK. */ cursesWin = initscr (); cdkscreen = initCDKScreen (cursesWin); /* Start color. */ initCDKColor (); /* Create the alpha list widget. */ alphaList = newCDKAlphalist (cdkscreen, CDKparamValue (¶ms, 'X', CENTER), CDKparamValue (¶ms, 'Y', CENTER), CDKparamValue (¶ms, 'H', 0), CDKparamValue (¶ms, 'W', 0), title, label, CDKparamNumber (¶ms, 'c') ? 0 : userList, CDKparamNumber (¶ms, 'c') ? 0 : userSize, '_', A_REVERSE, CDKparamValue (¶ms, 'N', TRUE), CDKparamValue (¶ms, '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 (¶ms, 'c')) { setCDKAlphalistContents (alphaList, 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] = "You hit escape. No word was selected."; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (alphaList->exitType == vNORMAL) { mesg[0] = "You selected the following"; sprintf (temp, "(%.*s)", (int)(sizeof (temp) - 10), word); mesg[1] = temp; mesg[2] = ""; mesg[3] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 4); } freeCharList (myUserList, userSize); free (myUserList); destroyCDKAlphalist (alphaList); destroyCDKScreen (cdkscreen); endCDK (); ExitProgram (EXIT_SUCCESS); } cdk-5.0-20060507/fselect.c0000644000175100001440000011725110427236701013341 0ustar tomusers#define TRACE #include /* * $Author: tom $ * $Date: 2006/05/07 00:22:25 $ * $Revision: 1.68 $ */ /* * Declare file local prototypes. */ static BINDFN_PROTO (completeFilenameCB); static BINDFN_PROTO (displayFileInfoCB); static BINDFN_PROTO (fselectAdjustScrollCB); static char *contentToPath (CDKFSELECT *fselect, char *content); static char *errorMessage (char *format); static char *expandTilde (char *filename); static char *format1Date (char *format, time_t value); static char *format1Number (char *format, long value); static char *format1String (char *format, char *string); static char *format3String (char *format, char *s1, char *s2, char *s3); static char *format1StrVal (char *format, char *string, int value); static char *trim1Char (char *source); static int createList (CDKFSELECT *widget, char **list, int listSize); static void setPWD (CDKFSELECT *fselect); DeclareSetXXchar (static, _setMy); DeclareCDKObjects (FSELECT, Fselect, _setMy, String); /* * This creates a file selection widget. */ CDKFSELECT *newCDKFselect (CDKSCREEN *cdkscreen, int xplace, int yplace, int height, int width, char *title, char *label, chtype fieldAttribute, chtype fillerChar, chtype highlight, char *dAttribute, char *fAttribute, char *lAttribute, char *sAttribute, boolean Box, boolean shadow) { CDKFSELECT *fselect = 0; int parentWidth = getmaxx (cdkscreen->window); int parentHeight = getmaxy (cdkscreen->window); int boxWidth = width; int boxHeight = height; int xpos = xplace; int ypos = yplace; int tempWidth = 0; int tempHeight = 0; int labelLen, junk; chtype *chtypeString; int x; static const struct { int from; int to; } bindings[] = { { CDK_BACKCHAR, KEY_PPAGE }, { CDK_FORCHAR, KEY_NPAGE }, }; if ((fselect = newCDKObject (CDKFSELECT, &my_funcs)) == 0) return (0); setCDKFselectBox (fselect, 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); /* Rejustify the x and y positions if we need to. */ alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight); /* Make sure the box isn't too small. */ boxWidth = (boxWidth < 15 ? 15 : boxWidth); boxHeight = (boxHeight < 6 ? 6 : boxHeight); /* Make the file selector window. */ fselect->win = newwin (boxHeight, boxWidth, ypos, xpos); /* Is the window null? */ if (fselect->win == 0) { destroyCDKObject (fselect); return (0); } keypad (fselect->win, TRUE); /* Set some variables. */ ScreenOf (fselect) = cdkscreen; fselect->parent = cdkscreen->window; fselect->dirAttribute = copyChar (dAttribute); fselect->fileAttribute = copyChar (fAttribute); fselect->linkAttribute = copyChar (lAttribute); fselect->sockAttribute = copyChar (sAttribute); fselect->highlight = highlight; fselect->fillerCharacter = fillerChar; fselect->fieldAttribute = fieldAttribute; fselect->boxHeight = boxHeight; fselect->boxWidth = boxWidth; fselect->fileCounter = 0; fselect->pwd = 0; initExitType (fselect); ObjOf (fselect)->inputWindow = fselect->win; fselect->shadow = shadow; fselect->shadowWin = 0; /* Get the present working directory. */ setPWD (fselect); /* Get the contents of the current directory. */ setCDKFselectDirContents (fselect); /* Create the entry field in the selector. */ chtypeString = char2Chtype (label, &labelLen, &junk); freeChtype (chtypeString); tempWidth = (isFullWidth (width) ? FULL : boxWidth - 2 - labelLen); fselect->entryField = newCDKEntry (cdkscreen, getbegx (fselect->win), getbegy (fselect->win), title, label, fieldAttribute, fillerChar, vMIXED, tempWidth, 0, 512, Box, FALSE); /* Make sure the widget was created. */ if (fselect->entryField == 0) { destroyCDKObject (fselect); return (0); } /* Set the lower left/right characters of the entry field. */ setCDKEntryLLChar (fselect->entryField, ACS_LTEE); setCDKEntryLRChar (fselect->entryField, ACS_RTEE); /* Define the callbacks for the entry field. */ bindCDKObject (vENTRY, fselect->entryField, KEY_UP, fselectAdjustScrollCB, fselect); bindCDKObject (vENTRY, fselect->entryField, KEY_PPAGE, fselectAdjustScrollCB, fselect); bindCDKObject (vENTRY, fselect->entryField, KEY_DOWN, fselectAdjustScrollCB, fselect); bindCDKObject (vENTRY, fselect->entryField, KEY_NPAGE, fselectAdjustScrollCB, fselect); bindCDKObject (vENTRY, fselect->entryField, KEY_TAB, completeFilenameCB, fselect); bindCDKObject (vENTRY, fselect->entryField, CTRL ('^'), displayFileInfoCB, fselect); /* Put the current working directory in the entry field. */ setCDKEntryValue (fselect->entryField, fselect->pwd); /* Create the scrolling list in the selector. */ tempHeight = getmaxy (fselect->entryField->win) - BorderOf (fselect); tempWidth = (isFullWidth (width) ? FULL : boxWidth - 1); fselect->scrollField = newCDKScroll (cdkscreen, getbegx (fselect->win), getbegy (fselect->win) + tempHeight, RIGHT, boxHeight - tempHeight, tempWidth, 0, fselect->dirContents, fselect->fileCounter, NONUMBERS, fselect->highlight, Box, FALSE); /* Set the lower left/right characters of the entry field. */ setCDKScrollULChar (fselect->scrollField, ACS_LTEE); setCDKScrollURChar (fselect->scrollField, ACS_RTEE); /* Do we want a shadow? */ if (shadow) { fselect->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1); } /* Setup the key bindings. */ for (x = 0; x < (int) SIZEOF (bindings); ++x) bindCDKObject (vFSELECT, fselect, bindings[x].from, getcCDKBind, (void *)(long)bindings[x].to); registerCDKObject (cdkscreen, vFSELECT, fselect); return (fselect); } /* * This erases the file selector from the screen. */ static void _eraseCDKFselect (CDKOBJS *object) { if (validCDKObject (object)) { CDKFSELECT *fselect = (CDKFSELECT *)object; eraseCDKScroll (fselect->scrollField); eraseCDKEntry (fselect->entryField); eraseCursesWindow (fselect->win); } } /* * This moves the fselect field to the given location. */ static void _moveCDKFselect (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDKFSELECT *fselect = (CDKFSELECT *)object; int currentX = getbegx (fselect->win); int currentY = getbegy (fselect->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 (fselect->win) + xplace; ypos = getbegy (fselect->win) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf (fselect), &xpos, &ypos, fselect->boxWidth, fselect->boxHeight); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the window to the new location. */ moveCursesWindow (fselect->win, -xdiff, -ydiff); moveCursesWindow (fselect->shadowWin, -xdiff, -ydiff); /* Move the sub-widgets. */ moveCDKEntry (fselect->entryField, xplace, yplace, relative, FALSE); moveCDKScroll (fselect->scrollField, xplace, yplace, relative, FALSE); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDKFselect (fselect, ObjOf (fselect)->box); } } /* * The fselect'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 (CDKFSELECT *widget) { SaveFocus (widget); drawCDKScroll (widget->scrollField, ObjOf (widget->scrollField)->box); RestoreFocus (widget); } static void injectMyScroller (CDKFSELECT *widget, chtype key) { SaveFocus (widget); injectCDKScroll (widget->scrollField, key); RestoreFocus (widget); } /* * This draws the file selector widget. */ static void _drawCDKFselect (CDKOBJS *object, boolean Box GCC_UNUSED) { CDKFSELECT *fselect = (CDKFSELECT *)object; /* Draw in the shadow if we need to. */ if (fselect->shadowWin != 0) { drawShadow (fselect->shadowWin); } /* Draw in the entry field. */ drawCDKEntry (fselect->entryField, ObjOf (fselect->entryField)->box); /* Draw in the scroll field. */ drawMyScroller (fselect); } /* * This means you want to use the given file selector. It takes input * from the keyboard, and when it's done, it fills the entry info * element of the structure with what was typed. */ char *activateCDKFselect (CDKFSELECT *fselect, chtype *actions) { chtype input = 0; boolean functionKey; char *ret = 0; /* Draw the widget. */ drawCDKFselect (fselect, ObjOf (fselect)->box); if (actions == 0) { for (;;) { input = getchCDKObject (ObjOf (fselect->entryField), &functionKey); /* Inject the character into the widget. */ ret = injectCDKFselect (fselect, input); if (fselect->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 = injectCDKFselect (fselect, actions[x]); if (fselect->exitType != vEARLY_EXIT) { return ret; } } } /* Set the exit type and exit. */ setExitType (fselect, 0); return 0; } /* * This injects a single character into the file selector. */ static int _injectCDKFselect (CDKOBJS *object, chtype input) { CDKFSELECT *fselect = (CDKFSELECT *)object; char *filename; boolean file; char *ret = unknownString; bool complete = FALSE; /* Let the user play. */ filename = injectCDKEntry (fselect->entryField, input); /* Copy the entry field exitType to the fileselector. */ copyExitType (fselect, fselect->entryField); /* If we exited early, make sure we don't interpret it as a file. */ if (fselect->exitType == vEARLY_EXIT) { return 0; } /* Can we change into the directory? */ file = chdir (filename); chdir (fselect->pwd); /* If it's not a directory, return the filename. */ if (file != 0) { /* It's a regular file, create the full path. */ fselect->pathname = copyChar (filename); /* Return the complete pathname. */ ret = (fselect->pathname); complete = TRUE; } else { /* Set the file selector information. */ setCDKFselect (fselect, filename, fselect->fieldAttribute, fselect->fillerCharacter, fselect->highlight, fselect->dirAttribute, fselect->fileAttribute, fselect->linkAttribute, fselect->sockAttribute, ObjOf (fselect)->box); /* Redraw the scrolling list. */ drawMyScroller (fselect); } if (!complete) setExitType (fselect, 0); ResultOf (fselect).valueString = ret; return (ret != unknownString); } /* * This function sets the information inside the file selector. */ void setCDKFselect (CDKFSELECT *fselect, char *directory, chtype fieldAttrib, chtype filler, chtype highlight, char *dirAttribute, char *fileAttribute, char *linkAttribute, char *sockAttribute, boolean Box GCC_UNUSED) { CDKSCROLL *fscroll = fselect->scrollField; CDKENTRY *fentry = fselect->entryField; char *tempDir = 0; char *mesg[10]; char *newDirectory; /* Keep the info sent to us. */ fselect->fieldAttribute = fieldAttrib; fselect->fillerCharacter = filler; fselect->highlight = highlight; /* Set the attributes of the entry field/scrolling list. */ setCDKEntryFillerChar (fentry, filler); setCDKScrollHighlight (fscroll, highlight); /* Only do the directory stuff if the directory is not null. */ if (directory != 0) { /* Try to expand the directory if it starts with a ~ */ if ((tempDir = expandTilde (directory)) != 0) { newDirectory = tempDir; } else { newDirectory = copyChar (directory); } /* Change directories. */ if (chdir (newDirectory) != 0) { Beep (); /* Could not get into the directory, pop up a little message. */ mesg[0] = format1String ("Could not change into %s", newDirectory); mesg[1] = errorMessage ("%s"); mesg[2] = copyChar (" "); mesg[3] = copyChar ("Press Any Key To Continue."); /* Pop Up a message. */ popupLabel (ScreenOf (fselect), mesg, 4); /* Clean up some memory. */ freeCharList (mesg, 4); /* Get out of here. */ eraseCDKFselect (fselect); drawCDKFselect (fselect, ObjOf (fselect)->box); freeChar (newDirectory); return; } freeChar (newDirectory); } /* * If the information coming in is the same as the information * that is already there, there is no need to destroy it. */ if (fselect->pwd != directory) { setPWD (fselect); } if (fselect->fileAttribute != fileAttribute) { /* Remove the old pointer and set the new value. */ freeChar (fselect->fileAttribute); fselect->fileAttribute = copyChar (fileAttribute); } if (fselect->dirAttribute != dirAttribute) { /* Remove the old pointer and set the new value. */ freeChar (fselect->dirAttribute); fselect->dirAttribute = copyChar (dirAttribute); } if (fselect->linkAttribute != linkAttribute) { /* Remove the old pointer and set the new value. */ freeChar (fselect->linkAttribute); fselect->linkAttribute = copyChar (linkAttribute); } if (fselect->sockAttribute != sockAttribute) { /* Remove the old pointer and set the new value. */ freeChar (fselect->sockAttribute); fselect->sockAttribute = copyChar (sockAttribute); } /* Set the contents of the entry field. */ setCDKEntryValue (fentry, fselect->pwd); drawCDKEntry (fentry, ObjOf (fentry)->box); /* Get the directory contents. */ if (setCDKFselectDirContents (fselect) == 0) { Beep (); return; } /* Set the values in the scrolling list. */ setCDKScrollItems (fscroll, fselect->dirContents, fselect->fileCounter, FALSE); } /* * This creates a list of the files in the current directory. */ int setCDKFselectDirContents (CDKFSELECT *fselect) { struct stat fileStat; char **dirList = 0; char *oldItem; int fileCount; int x = 0; /* Get the directory contents. */ fileCount = CDKgetDirectoryContents (fselect->pwd, &dirList); if (fileCount <= 0) { /* We couldn't read the directory. Return. */ CDKfreeStrings (dirList); return 0; } /* Clean out the old directory list. */ CDKfreeStrings (fselect->dirContents); fselect->dirContents = dirList; fselect->fileCounter = fileCount; /* Set the properties of the files. */ for (x = 0; x < fselect->fileCounter; x++) { char *attr = ""; char *mode = "?"; /* FIXME: access() would give a more correct answer */ if (lstat (dirList[x], &fileStat) == 0) { mode = " "; if (((fileStat.st_mode & S_IXUSR) != 0) || ((fileStat.st_mode & S_IXGRP) != 0) || ((fileStat.st_mode & S_IXOTH) != 0)) { mode = "*"; } } switch (mode2Filetype (fileStat.st_mode)) { case 'l': attr = fselect->linkAttribute; mode = "@"; break; case '@': attr = fselect->sockAttribute; mode = "&"; break; case '-': attr = fselect->fileAttribute; break; case 'd': attr = fselect->dirAttribute; mode = "/"; break; default: break; } oldItem = dirList[x]; fselect->dirContents[x] = format3String ("%s%s%s", attr, dirList[x], mode); free (oldItem); } return 1; } char **getCDKFselectDirContents (CDKFSELECT *fselect, int *count) { (*count) = fselect->fileCounter; return fselect->dirContents; } /* * This sets the current directory of the file selector. */ int setCDKFselectDirectory (CDKFSELECT *fselect, char *directory) { CDKENTRY *fentry = fselect->entryField; CDKSCROLL *fscroll = fselect->scrollField; int result = 1; /* * If the directory supplied is the same as what is already * there, return. */ if (fselect->pwd != directory) { /* Try to chdir into the given directory. */ if (chdir (directory) != 0) { result = 0; } else { setPWD (fselect); /* Set the contents of the entry field. */ setCDKEntryValue (fentry, fselect->pwd); drawCDKEntry (fentry, ObjOf (fentry)->box); /* Get the directory contents. */ if (setCDKFselectDirContents (fselect) == 0) { result = 0; } else { /* Set the values in the scrolling list. */ setCDKScrollItems (fscroll, fselect->dirContents, fselect->fileCounter, FALSE); } } } return result; } char *getCDKFselectDirectory (CDKFSELECT *fselect) { return fselect->pwd; } /* * This sets the filler character of the entry field. */ void setCDKFselectFillerChar (CDKFSELECT *fselect, chtype filler) { CDKENTRY *fentry = fselect->entryField; fselect->fillerCharacter = filler; setCDKEntryFillerChar (fentry, filler); } chtype getCDKFselectFillerChar (CDKFSELECT *fselect) { return fselect->fillerCharacter; } /* * This sets the highlight bar of the scrolling list. */ void setCDKFselectHighlight (CDKFSELECT *fselect, chtype highlight) { CDKSCROLL *fscroll = (CDKSCROLL *)fselect->scrollField; fselect->highlight = highlight; setCDKScrollHighlight (fscroll, highlight); } chtype getCDKFselectHighlight (CDKFSELECT *fselect) { return fselect->highlight; } /* * This sets the attribute of the directory attribute in the * scrolling list. */ void setCDKFselectDirAttribute (CDKFSELECT *fselect, char *attribute) { /* Make sure they are not the same. */ if (fselect->dirAttribute != attribute) { freeChar (fselect->dirAttribute); fselect->dirAttribute = copyChar (attribute); setCDKFselectDirContents (fselect); } } char *getCDKFselectDirAttribute (CDKFSELECT *fselect) { return fselect->dirAttribute; } /* * This sets the attribute of the link attribute in the * scrolling list. */ void setCDKFselectLinkAttribute (CDKFSELECT *fselect, char *attribute) { /* Make sure they are not the same. */ if (fselect->linkAttribute != attribute) { freeChar (fselect->linkAttribute); fselect->linkAttribute = copyChar (attribute); setCDKFselectDirContents (fselect); } } char *getCDKFselectLinkAttribute (CDKFSELECT *fselect) { return fselect->linkAttribute; } /* * This sets the attribute of the link attribute in the * scrolling list. */ void setCDKFselectSocketAttribute (CDKFSELECT *fselect, char *attribute) { /* Make sure they are not the same. */ if (fselect->sockAttribute != attribute) { freeChar (fselect->sockAttribute); fselect->sockAttribute = copyChar (attribute); setCDKFselectDirContents (fselect); } } char *getCDKFselectSocketAttribute (CDKFSELECT *fselect) { return fselect->sockAttribute; } /* * This sets the attribute of the link attribute in the * scrolling list. */ void setCDKFselectFileAttribute (CDKFSELECT *fselect, char *attribute) { /* Make sure they are not the same. */ if (fselect->fileAttribute != attribute) { freeChar (fselect->fileAttribute); fselect->fileAttribute = copyChar (attribute); setCDKFselectDirContents (fselect); } } char *getCDKFselectFileAttribute (CDKFSELECT *fselect) { return fselect->fileAttribute; } /* * This sets the box attribute of the widget. */ void setCDKFselectBox (CDKFSELECT *fselect, boolean Box) { ObjOf (fselect)->box = Box; ObjOf (fselect)->borderSize = Box ? 1 : 0; } boolean getCDKFselectBox (CDKFSELECT *fselect) { return ObjOf (fselect)->box; } /* * This sets the contents of the widget */ void setCDKFselectContents (CDKFSELECT *widget, char **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, widget->dirContents, widget->fileCounter, NONUMBERS, scrollp->highlight, ObjOf (scrollp)->box); /* Clean out the entry field. */ setCDKFselectCurrentItem (widget, 0); cleanCDKEntry (entry); /* Redraw the widget. */ eraseCDKFselect (widget); drawCDKFselect (widget, ObjOf (widget)->box); } char **getCDKFselectContents (CDKFSELECT *widget, int *size) { (*size) = widget->fileCounter; return widget->dirContents; } /* * Get/set the current position in the scroll-widget. */ int getCDKFselectCurrentItem (CDKFSELECT *widget) { return getCDKScrollCurrent (widget->scrollField); } void setCDKFselectCurrentItem (CDKFSELECT *widget, int item) { if (widget->fileCounter != 0) { char *data; setCDKScrollCurrent (widget->scrollField, item); data = contentToPath (widget, widget->dirContents[getCDKScrollCurrentItem (widget->scrollField)]); setCDKEntryValue (widget->entryField, data); free (data); } } /* * These functions set the drawing characters of the widget. */ static void _setMyULchar (CDKOBJS *object, chtype character) { CDKFSELECT *fselect = (CDKFSELECT *)object; setCDKEntryULChar (fselect->entryField, character); } static void _setMyURchar (CDKOBJS *object, chtype character) { CDKFSELECT *fselect = (CDKFSELECT *)object; setCDKEntryURChar (fselect->entryField, character); } static void _setMyLLchar (CDKOBJS *object, chtype character) { CDKFSELECT *fselect = (CDKFSELECT *)object; setCDKScrollLLChar (fselect->scrollField, character); } static void _setMyLRchar (CDKOBJS *object, chtype character) { CDKFSELECT *fselect = (CDKFSELECT *)object; setCDKScrollLRChar (fselect->scrollField, character); } static void _setMyVTchar (CDKOBJS *object, chtype character) { CDKFSELECT *fselect = (CDKFSELECT *)object; setCDKEntryVerticalChar (fselect->entryField, character); setCDKScrollVerticalChar (fselect->scrollField, character); } static void _setMyHZchar (CDKOBJS *object, chtype character) { CDKFSELECT *fselect = (CDKFSELECT *)object; setCDKEntryHorizontalChar (fselect->entryField, character); setCDKScrollHorizontalChar (fselect->scrollField, character); } static void _setMyBXattr (CDKOBJS *object, chtype character) { CDKFSELECT *fselect = (CDKFSELECT *)object; setCDKEntryBoxAttribute (fselect->entryField, character); setCDKScrollBoxAttribute (fselect->scrollField, character); } /* * This sets the background attribute of the widget. */ static void _setBKattrFselect (CDKOBJS *object, chtype attrib) { if (object != 0) { CDKFSELECT *widget = (CDKFSELECT *)object; setCDKEntryBackgroundAttrib (widget->entryField, attrib); setCDKScrollBackgroundAttrib (widget->scrollField, attrib); } } /* * This destroys the file selector. */ static void _destroyCDKFselect (CDKOBJS *object) { if (object != 0) { CDKFSELECT *fselect = (CDKFSELECT *)object; cleanCDKObjectBindings (vFSELECT, fselect); /* Free up the character pointers. */ freeChar (fselect->pwd); freeChar (fselect->pathname); freeChar (fselect->dirAttribute); freeChar (fselect->fileAttribute); freeChar (fselect->linkAttribute); freeChar (fselect->sockAttribute); CDKfreeStrings (fselect->dirContents); /* Destroy the other Cdk objects. */ destroyCDKScroll (fselect->scrollField); destroyCDKEntry (fselect->entryField); /* Free up the window pointers. */ deleteCursesWindow (fselect->shadowWin); deleteCursesWindow (fselect->win); /* Clean the key bindings. */ /* Unregister the object. */ unregisterCDKObject (vFSELECT, fselect); } } /* ******************************** * Callback functions. ******************************** */ /* * This is a callback to the scrolling list which displays information * about the current file. (and the whole directory as well) */ static int displayFileInfoCB (EObjectType objectType GCC_UNUSED, void *object, void *clientData, chtype key GCC_UNUSED) { CDKENTRY *entry = (CDKENTRY *)object; CDKFSELECT *fselect = (CDKFSELECT *)clientData; CDKLABEL *infoLabel; struct stat fileStat; struct passwd *pwEnt; struct group *grEnt; char *filename; char *filetype; char *mesg[10]; char stringMode[15]; int intMode; boolean functionKey; /* Get the file name. */ filename = fselect->entryField->info; /* Get specific information about the files. */ lstat (filename, &fileStat); /* Determine the file type. */ switch (mode2Filetype (fileStat.st_mode)) { case 'l': filetype = "Symbolic Link"; break; case '@': filetype = "Socket"; break; case '-': filetype = "Regular File"; break; case 'd': filetype = "Directory"; break; case 'c': filetype = "Character Device"; break; case 'b': filetype = "Block Device"; break; case '&': filetype = "FIFO Device"; break; default: filetype = "Unknown"; break; } /* Get the user name and group name. */ pwEnt = getpwuid (fileStat.st_uid); grEnt = getgrgid (fileStat.st_gid); /* Convert the mode_t type to both string and int. */ intMode = mode2Char (stringMode, fileStat.st_mode); /* Create the message. */ mesg[0] = format1String ("Directory : %s", fselect->pwd); mesg[1] = format1String ("Filename : %s", filename); mesg[2] = format1StrVal ("Owner : %s (%d)", pwEnt->pw_name, (int)fileStat.st_uid); mesg[3] = format1StrVal ("Group : %s (%d)", grEnt->gr_name, (int)fileStat.st_gid); mesg[4] = format1StrVal ("Permissions: %s (%o)", stringMode, intMode); mesg[5] = format1Number ("Size : %ld bytes", (long) fileStat.st_size); mesg[6] = format1Date ("Last Access: %s", fileStat.st_atime); mesg[7] = format1Date ("Last Change: %s", fileStat.st_ctime); mesg[8] = format1String ("File Type : %s", filetype); /* Create the pop up label. */ infoLabel = newCDKLabel (entry->obj.screen, CENTER, CENTER, mesg, 9, TRUE, FALSE); drawCDKLabel (infoLabel, TRUE); getchCDKObject (ObjOf (infoLabel), &functionKey); /* Clean up some memory. */ destroyCDKLabel (infoLabel); freeCharList (mesg, 9); /* Redraw the file selector. */ drawCDKFselect (fselect, ObjOf (fselect)->box); return (TRUE); } static char *make_pathname (char *directory, char *filename) { unsigned need = strlen (filename) + 2; bool root = (strcmp (directory, "/") == 0); char *result; if (!root) need += strlen (directory); if ((result = (char *)malloc (need)) != 0) { if (root) sprintf (result, "/%s", filename); else sprintf (result, "%s/%s", directory, filename); } return result; } /* * Return the plain string that corresponds to an item in dirContents[]. */ static char *contentToPath (CDKFSELECT *fselect, char *content) { chtype *tempChtype; char *tempChar; char *result; int j, j2; tempChtype = char2Chtype (content, &j, &j2); tempChar = chtype2Char (tempChtype); trim1Char (tempChar); /* trim the 'mode' stored on the end */ /* Create the pathname. */ result = make_pathname (fselect->pwd, tempChar); /* Clean up. */ freeChtype (tempChtype); freeChar (tempChar); return result; } /* * This tries to complete the filename. */ static int completeFilenameCB (EObjectType objectType GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key GCC_UNUSED) { CDKFSELECT *fselect = (CDKFSELECT *)clientData; CDKSCROLL *scrollp = fselect->scrollField; CDKENTRY *entry = fselect->entryField; char *filename = copyChar (entry->info); char *mydirname = dirName (filename); char *newFilename = 0; unsigned filenameLen = 0; int currentIndex = 0; int matches = 0; int baseChars = 0; int secondaryMatches = 0; int isDirectory; char **list; int Index, pos, x; int difference, absoluteDifference; /* Make sure the filename is not null/empty. */ if (filename == 0 || (filenameLen = strlen (filename)) == 0) { Beep (); freeChar (filename); return (TRUE); } /* Try to expand the filename if it starts with a ~ */ if ((newFilename = expandTilde (filename)) != 0) { freeChar (filename); filename = newFilename; setCDKEntryValue (entry, filename); drawCDKEntry (entry, ObjOf (entry)->box); } /* Make sure we can change into the directory. */ isDirectory = chdir (filename); chdir (fselect->pwd); setCDKFselect (fselect, isDirectory ? mydirname : filename, fselect->fieldAttribute, fselect->fillerCharacter, fselect->highlight, fselect->dirAttribute, fselect->fileAttribute, fselect->linkAttribute, fselect->sockAttribute, ObjOf (fselect)->box); freeChar (mydirname); /* If we can, change into the directory. */ if (isDirectory) { /* * Set the entry field with the filename so the current * filename selection shows up. */ setCDKEntryValue (entry, filename); drawCDKEntry (entry, ObjOf (entry)->box); } /* Create the file list. */ if ((list = typeMallocN (char *, fselect->fileCounter)) != 0) { for (x = 0; x < fselect->fileCounter; x++) { list[x] = contentToPath (fselect, fselect->dirContents[x]); } /* Look for a unique filename match. */ Index = searchList (list, fselect->fileCounter, filename); /* If the index is less than zero, return we didn't find a match. */ if (Index < 0) { Beep (); } else { /* Move to the current item in the scrolling list. */ difference = Index - scrollp->currentItem; absoluteDifference = abs (difference); if (difference < 0) { for (x = 0; x < absoluteDifference; x++) { injectMyScroller (fselect, KEY_UP); } } else if (difference > 0) { for (x = 0; x < absoluteDifference; x++) { injectMyScroller (fselect, KEY_DOWN); } } drawMyScroller (fselect); /* Ok, we found a match, is the next item similar? */ if (Index+1 < fselect->fileCounter && 0 != list[Index+1] && 0 == strncmp (list[Index + 1], filename, filenameLen)) { currentIndex = Index; baseChars = filenameLen; matches = 0; pos = 0; /* Determine the number of files which match. */ while (currentIndex < fselect->fileCounter) { if (list[currentIndex] != 0) { if (strncmp (list[currentIndex], filename, filenameLen) == 0) { matches++; } } currentIndex++; } /* Start looking for the common base characters. */ for (;;) { secondaryMatches = 0; for (x = Index; x < Index + matches; x++) { if (list[Index][baseChars] == list[x][baseChars]) { secondaryMatches++; } } if (secondaryMatches != matches) { Beep (); break; } /* Inject the character into the entry field. */ injectCDKEntry (fselect->entryField, list[Index][baseChars]); baseChars++; } } else { /* Set the entry field with the found item. */ setCDKEntryValue (entry, list[Index]); drawCDKEntry (entry, ObjOf (entry)->box); } } freeCharList (list, fselect->fileCounter); free (list); } freeChar (filename); return (TRUE); } /* * This allows the user to delete a file. */ void deleteFileCB (EObjectType objectType GCC_UNUSED, void *object, void *clientData) { CDKSCROLL *fscroll = (CDKSCROLL *)object; CDKFSELECT *fselect = (CDKFSELECT *)clientData; char *buttons[] = {"No", "Yes"}; CDKDIALOG *question; char *mesg[10], *filename; /* Get the filename which is to be deleted. */ filename = chtype2Char (fscroll->item[fscroll->currentItem]); trim1Char (filename); /* Create the dialog message. */ mesg[0] = copyChar ("Are you sure you want to delete the file:"); mesg[1] = format1String ("\"%s\"?", filename); /* Create the dialog box. */ question = newCDKDialog (ScreenOf (fselect), CENTER, CENTER, mesg, 2, buttons, 2, A_REVERSE, TRUE, TRUE, FALSE); freeCharList (mesg, 2); /* If the said yes then try to nuke it. */ if (activateCDKDialog (question, 0) == 1) { /* If we were successful, reload the scrolling list. */ if (unlink (filename) == 0) { /* Set the file selector information. */ setCDKFselect (fselect, fselect->pwd, fselect->fieldAttribute, fselect->fillerCharacter, fselect->highlight, fselect->dirAttribute, fselect->fileAttribute, fselect->linkAttribute, fselect->sockAttribute, ObjOf (fselect)->box); } else { /* Pop up a message. */ mesg[0] = copyChar (errorMessage ("Cannot delete file: %s")); mesg[1] = copyChar (" "); mesg[2] = copyChar ("Press any key to continue."); popupLabel (ScreenOf (fselect), mesg, 3); freeCharList (mesg, 3); } } /* Clean up. */ destroyCDKDialog (question); /* Redraw the file selector. */ drawCDKFselect (fselect, ObjOf (fselect)->box); } /* * This function sets the pre-process function. */ void setCDKFselectPreProcess (CDKFSELECT *fselect, PROCESSFN callback, void *data) { setCDKEntryPreProcess (fselect->entryField, callback, data); setCDKScrollPreProcess (fselect->scrollField, callback, data); } /* * This function sets the post-process function. */ void setCDKFselectPostProcess (CDKFSELECT *fselect, PROCESSFN callback, void *data) { setCDKEntryPostProcess (fselect->entryField, callback, data); setCDKScrollPostProcess (fselect->scrollField, callback, data); } /* * Start of callback functions. */ static int fselectAdjustScrollCB (EObjectType objectType GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key) { CDKFSELECT *fselect = (CDKFSELECT *)clientData; CDKSCROLL *scrollp = (CDKSCROLL *)fselect->scrollField; CDKENTRY *entry = (CDKENTRY *)fselect->entryField; char *current; char *temp; if (scrollp->listSize > 0) { /* Move the scrolling list. */ injectMyScroller (fselect, key); /* Get the currently highlighted filename. */ current = chtype2Char (scrollp->item[scrollp->currentItem]); trim1Char (current); temp = make_pathname (fselect->pwd, current); /* Set the value in the entry field. */ setCDKEntryValue (entry, temp); drawCDKEntry (entry, ObjOf (entry)->box); freeChar (current); freeChar (temp); return (TRUE); } Beep (); return (FALSE); } /* * trim the 'mode' from a copy of a dirContents[] entry. */ static char *trim1Char (char *source) { unsigned len; if ((len = strlen (source)) != 0) source[--len] = '\0'; return source; } static char *format1Date (char *format, time_t value) { char *result; char *temp = ctime (&value); if ((result = (char *)malloc (strlen (format) + strlen (temp))) != 0) { sprintf (result, format, trim1Char (temp)); } return result; } static char *format1Number (char *format, long value) { char *result; if ((result = (char *)malloc (strlen (format) + 20)) != 0) sprintf (result, format, value); return result; } static char *format3String (char *format, char *s1, char *s2, char *s3) { char *result; if ((result = (char *)malloc (strlen (format) + strlen (s1) + strlen (s2) + strlen (s3))) != 0) sprintf (result, format, s1, s2, s3); return result; } static char *format1String (char *format, char *string) { char *result; if ((result = (char *)malloc (strlen (format) + strlen (string))) != 0) sprintf (result, format, string); return result; } static char *format1StrVal (char *format, char *string, int value) { char *result; if ((result = (char *)malloc (strlen (format) + strlen (string) + 20)) != 0) sprintf (result, format, string, value); return result; } static char *errorMessage (char *format) { char *message; #ifdef HAVE_STRERROR message = strerror (errno); #else message = "Unknown reason."; #endif return format1String (format, message); } /* * This takes a ~ type account name and returns the full pathname. */ static char *expandTilde (char *filename) { char *result = 0; char *account; char *pathname; int len; /* Make sure the filename is not null/empty, and begins with a tilde */ if ((filename != 0) && (len = strlen (filename)) != 0 && filename[0] == '~' && (account = copyChar (filename)) != 0 && (pathname = copyChar (filename)) != 0) { bool slash = FALSE; char *home; int x; int len_a = 0; int len_p = 0; struct passwd *accountInfo; /* Find the account name in the filename. */ for (x = 1; x < len; x++) { if (filename[x] == '/' && !slash) { slash = TRUE; } else if (slash) { pathname[len_p++] = filename[x]; } else { account[len_a++] = filename[x]; } } account[len_a] = '\0'; pathname[len_p] = '\0'; home = 0; if (strlen (account) != 0 && (accountInfo = getpwnam (account)) != 0) { home = accountInfo->pw_dir; } if (home == 0 || *home == '\0') home = getenv ("HOME"); if (home == 0 || *home == '\0') home = "/"; /* * Construct the full pathname. We do this because someone * may have a pathname at the end of the account name * and we want to keep it. */ result = make_pathname (home, pathname); freeChar (account); freeChar (pathname); } return result; } /* * Store the name of the current working directory. */ static void setPWD (CDKFSELECT *fselect) { char buffer[512]; freeChar (fselect->pwd); if (getcwd (buffer, sizeof (buffer)) == 0) strcpy (buffer, "."); fselect->pwd = copyChar (buffer); } static void destroyInfo (CDKFSELECT *widget) { CDKfreeStrings (widget->dirContents); widget->dirContents = 0; widget->fileCounter = 0; } static int createList (CDKFSELECT *widget, char **list, int listSize) { int status = 0; if (listSize > 0) { char **newlist = typeCallocN (char *, listSize + 1); if (newlist != 0) { int x; /* 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 (widget); widget->fileCounter = listSize; widget->dirContents = newlist; } else { CDKfreeStrings (newlist); } } } else { destroyInfo (widget); status = TRUE; } return status; } static void _focusCDKFselect (CDKOBJS *object) { CDKFSELECT *widget = (CDKFSELECT *)object; FocusObj (ObjOf (widget->entryField)); } static void _unfocusCDKFselect (CDKOBJS *object) { CDKFSELECT *widget = (CDKFSELECT *)object; UnfocusObj (ObjOf (widget->entryField)); } dummyRefreshData (Fselect) dummySaveData (Fselect) cdk-5.0-20060507/gen-scale.c0000644000175100001440000004342410426516000013542 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:27:44 $ * $Revision: 1.19 $ */ /* * Declare file local prototypes. */ static void drawCDKField (CDK *widget); DeclareCDKObjects(, , setCdk, ); /* * This function creates a widget. */ CDK *newCDK (CDKSCREEN *cdkscreen, int xplace, int yplace, char *title, char *label, chtype fieldAttr, int fieldWidth, start, low, high, inc, fastInc, #if int digits, #endif boolean Box, boolean shadow) { CDK *widget = 0; int parentWidth = getmaxx(cdkscreen->window); int parentHeight = getmaxy(cdkscreen->window); int boxHeight; int boxWidth; int horizontalAdjust, oldWidth; int xpos = xplace; int ypos = yplace; int x, junk; static const struct { int from; int to; } bindings[] = { { 'u', KEY_UP }, { 'U', KEY_PPAGE }, { CDK_BACKCHAR, KEY_PPAGE }, { CDK_FORCHAR, KEY_NPAGE }, { 'g', KEY_HOME }, { '^', KEY_HOME }, { 'G', KEY_END }, { '$', KEY_END }, }; if ((widget = newCDKObject(CDK, &my_funcs)) == 0) return (0); setCDKBox (widget, Box); boxHeight = (BorderOf(widget) * 2) + 1; boxWidth = fieldWidth + 2*BorderOf(widget); /* Set some basic values of the widget's data field. */ widget->label = 0; widget->labelLen = 0; widget->labelWin = 0; /* * 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(widget); /* Translate the label char *pointer to a chtype pointer. */ if (label != 0) { widget->label = char2Chtype (label, &widget->labelLen, &junk); boxWidth = widget->labelLen + fieldWidth + 2; } oldWidth = boxWidth; boxWidth = setCdkTitle(ObjOf(widget), title, boxWidth); horizontalAdjust = (boxWidth - oldWidth) / 2; boxHeight += TitleLinesOf(widget); /* * Make sure we didn't extend beyond the dimensions of the window. */ boxWidth = (boxWidth > parentWidth ? parentWidth : boxWidth); boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight); fieldWidth = (fieldWidth > (boxWidth - widget->labelLen - 2*BorderOf(widget)) ? (boxWidth - widget->labelLen - 2*BorderOf(widget)) : fieldWidth); /* Rejustify the x and y positions if we need to. */ alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight); /* Make the widget's window. */ widget->win = newwin (boxHeight, boxWidth, ypos, xpos); /* Is the main window null??? */ if (widget->win == 0) { destroyCDKObject(widget); return (0); } /* Create the widget's label window. */ if (widget->label != 0) { widget->labelWin = subwin (widget->win, 1, widget->labelLen, ypos + TitleLinesOf(widget) + BorderOf(widget), xpos + horizontalAdjust + BorderOf(widget)); if (widget->labelWin == 0) { destroyCDKObject(widget); return (0); } } /* Create the widget's data field window. */ widget->fieldWin = subwin (widget->win, 1, fieldWidth, ypos + TitleLinesOf(widget) + BorderOf(widget), xpos + widget->labelLen + horizontalAdjust + BorderOf(widget)); if (widget->fieldWin == 0) { destroyCDKObject(widget); return (0); } keypad (widget->fieldWin, TRUE); keypad (widget->win, TRUE); /* Create the widget's data field. */ ScreenOf(widget) = cdkscreen; widget->parent = cdkscreen->window; widget->shadowWin = 0; widget->boxWidth = boxWidth; widget->boxHeight = boxHeight; widget->fieldWidth = fieldWidth; widget->fieldAttr = (chtype)fieldAttr; widget->current = low; widget->low = low; widget->high = high; widget->current = start; widget->inc = inc; widget->fastinc = fastInc; #if widget->digits = digits; #endif initExitType(widget); ObjOf(widget)->acceptsFocus = TRUE; ObjOf(widget)->inputWindow = widget->win; widget->shadow = shadow; /* Do we want a shadow??? */ if (shadow) { widget->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1); if (widget->shadowWin == 0) { destroyCDKObject(widget); return (0); } } /* Setup the key bindings. */ for (x = 0; x < (int) SIZEOF(bindings); ++x) bindCDKObject (v, widget, bindings[x].from, getcCDKBind, (void *)(long)bindings[x].to); registerCDKObject (cdkscreen, v, widget); return (widget); } /* * This allows the person to use the widget's data field. */ activateCDK (CDK *widget, chtype *actions) { ret; /* Draw the widget. */ drawCDK (widget, ObjOf(widget)->box); if (actions == 0) { chtype input = 0; boolean functionKey; for (;;) { input = getchCDKObject (ObjOf(widget), &functionKey); /* Inject the character into the widget. */ ret = injectCDK (widget, input); if (widget->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 = injectCDK (widget, actions[x]); if (widget->exitType != vEARLY_EXIT) { return ret; } } } /* Set the exit type and return. */ setExitType(widget, 0); return unknown; } /* * Check if the value lies outside the low/high range. If so, force it in. */ static void limitCurrentValue (CDK *widget) { if (widget->current < widget->low) { widget->current = widget->low; Beep(); } else if (widget->current > widget->high) { widget->current = widget->high; Beep(); } } /* * Move the cursor to the given edit-position. */ static int moveToEditPosition(CDK *widget, int newPosition) { return wmove(widget->fieldWin, 0, widget->fieldWidth - newPosition - 1); } /* * Check if the cursor is on a valid edit-position. This must be one of * the non-blank cells in the field. */ static int validEditPosition(CDK *widget, int newPosition) { chtype ch; if (newPosition <= 0 || newPosition >= widget->fieldWidth) return FALSE; if (moveToEditPosition(widget, newPosition) == ERR) return FALSE; ch = winch(widget->fieldWin); if (CharOf(ch) != ' ') return TRUE; if (newPosition > 1) { /* don't use recursion - only one level is wanted */ if (moveToEditPosition(widget, newPosition - 1) == ERR) return FALSE; ch = winch(widget->fieldWin); return CharOf(ch) != ' '; } return FALSE; } /* * Set the edit position. Normally the cursor is one cell to the right of * the editable field. Moving it left, over the field allows the user to * modify cells by typing in replacement characters for the field's value. */ static void setEditPosition(CDK *widget, int newPosition) { if (newPosition < 0) { Beep(); } else if (newPosition == 0) { widget->fieldEdit = newPosition; } else if (validEditPosition(widget, newPosition)) { widget->fieldEdit = newPosition; } else { Beep(); } } /* * Remove the character from the string at the given column, if it is blank. * Returns true if a change was made. */ static bool removeChar(char *string, int col) { bool result = FALSE; if ((col >= 0) && (string[col] != ' ')) { while (string[col] != '\0') { string[col] = string[col + 1]; ++col; } result = TRUE; } return result; } /* * Perform an editing function for the field. */ static bool performEdit(CDK *widget, chtype input) { bool result = FALSE; bool modify = TRUE; int base = 0; int need = widget->fieldWidth; char *temp = (char *)malloc(need + 2); char test; int col = need - widget->fieldEdit - 1; #if double value; #define SCANF_FMT "%lg%c" #endif #if value; #define SCANF_FMT "%%c" #endif if (temp != 0) { wmove(widget->fieldWin, 0, base); winnstr(widget->fieldWin, temp, need); strcpy(temp + need, " "); if (isChar(input)) /* replace the char at the cursor */ { temp[col] = CharOf(input); } else if (input == KEY_BACKSPACE) /* delete the char before the cursor */ { modify = removeChar(temp, col - 1); } else if (input == KEY_DC) /* delete the char at the cursor */ { modify = removeChar(temp, col); } else { modify = FALSE; } if (modify && sscanf(temp, SCANF_FMT, &value, &test) == 2 && test == ' ' && value >= widget->low && value <= widget->high) { setCDKValue(widget, value); result = TRUE; } free(temp); } return result; } #define Decrement(value,by) if (value - by < value) value -= by #define Increment(value,by) if (value + by > value) value += by /* * This function injects a single character into the widget. */ static int _injectCDK (CDKOBJS *object, chtype input) { CDK *widget = (CDK *)object; int ppReturn = 1; ret = unknown; bool complete = FALSE; /* Set the exit type. */ setExitType(widget, 0); /* Draw the field. */ drawCDKField (widget); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf(widget) != 0) { /* Call the pre-process function. */ ppReturn = PreProcessFuncOf(widget) (v, widget, PreProcessDataOf(widget), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check for a key binding. */ if (checkCDKObjectBind(v, widget, input) != 0) { checkEarlyExit(widget); complete = TRUE; } else { switch (input) { case KEY_LEFT : setEditPosition(widget, widget->fieldEdit + 1); break; case KEY_RIGHT : setEditPosition(widget, widget->fieldEdit - 1); break; case KEY_DOWN : Decrement(widget->current, widget->inc); break; case KEY_UP : Increment(widget->current, widget->inc); break; case KEY_PPAGE : Increment(widget->current, widget->fastinc); break; case KEY_NPAGE : Decrement(widget->current, widget->fastinc); break; case KEY_HOME : widget->current = widget->low; break; case KEY_END : widget->current = widget->high; break; case KEY_TAB : case KEY_ENTER : setExitType(widget, input); ret = (widget->current); complete = TRUE; break; case KEY_ESC : setExitType(widget, input); complete = TRUE; break; case CDK_REFRESH : eraseCDKScreen (ScreenOf(widget)); refreshCDKScreen (ScreenOf(widget)); break; default : if (widget->fieldEdit) { if (!performEdit(widget, input)) Beep(); } else { /* * The cursor is not within the editable text. Interpret * input as commands. */ switch (input) { case 'd': case '-': return _injectCDK(object, KEY_DOWN); case '+': return _injectCDK(object, KEY_UP); case 'D': return _injectCDK(object, KEY_NPAGE); case '0': return _injectCDK(object, KEY_HOME); default: Beep(); break; } } break; } } limitCurrentValue(widget); /* Should we call a post-process? */ if (!complete && (PostProcessFuncOf(widget) != 0)) { PostProcessFuncOf(widget) (v, widget, PostProcessDataOf(widget), input); } } if (!complete) { drawCDKField (widget); setExitType(widget, 0); } ResultOf(widget).value = ret; return (ret != unknown); } /* * This moves the widget's data field to the given location. */ static void _moveCDK (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDK *widget = (CDK *)object; int currentX = getbegx(widget->win); int currentY = getbegy(widget->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(widget->win) + xplace; ypos = getbegy(widget->win) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf(widget), &xpos, &ypos, widget->boxWidth, widget->boxHeight); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the window to the new location. */ moveCursesWindow(widget->win, -xdiff, -ydiff); moveCursesWindow(widget->labelWin, -xdiff, -ydiff); moveCursesWindow(widget->fieldWin, -xdiff, -ydiff); moveCursesWindow(widget->shadowWin, -xdiff, -ydiff); /* Touch the windows so they 'move'. */ refreshCDKWindow (WindowOf(widget)); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDK (widget, ObjOf(widget)->box); } } /* * This function draws the widget. */ static void _drawCDK (CDKOBJS *object, boolean Box) { CDK *widget = (CDK *)object; /* Draw the shadow. */ if (widget->shadowWin != 0) { drawShadow (widget->shadowWin); } /* Box the widget if asked. */ if (Box) { drawObjBox (widget->win, ObjOf(widget)); } drawCdkTitle (widget->win, object); /* Draw the label. */ if (widget->labelWin != 0) { writeChtype (widget->labelWin, 0, 0, widget->label, HORIZONTAL, 0, widget->labelLen); wrefresh (widget->labelWin); } wrefresh (widget->win); /* Draw the field window. */ drawCDKField (widget); } /* * This draws the widget. */ static void drawCDKField (CDK *widget) { char temp[256]; werase (widget->fieldWin); /* Draw the value in the field. */ #if { char format[256]; int digits = MINIMUM(widget->digits, 30); sprintf (format, "%%.%i", digits); sprintf (temp, format, widget->current); } #endif #if sprintf (temp, "%", widget->current); #endif writeCharAttrib (widget->fieldWin, widget->fieldWidth - (int)strlen(temp) - 1, 0, temp, widget->fieldAttr, HORIZONTAL, 0, (int)strlen(temp)); moveToEditPosition(widget, widget->fieldEdit); wrefresh (widget->fieldWin); } /* * This sets the background attribute of the widget. */ static void _setBKattr (CDKOBJS *object, chtype attrib) { if (object != 0) { CDK *widget = (CDK *)object; wbkgd (widget->win, attrib); wbkgd (widget->fieldWin, attrib); if (widget->labelWin != 0) { wbkgd (widget->labelWin, attrib); } } } /* * This function destroys the widget. */ static void _destroyCDK (CDKOBJS *object) { if (object != 0) { CDK *widget = (CDK *)object; cleanCdkTitle (object); freeChtype (widget->label); /* Clean up the windows. */ deleteCursesWindow (widget->fieldWin); deleteCursesWindow (widget->labelWin); deleteCursesWindow (widget->shadowWin); deleteCursesWindow (widget->win); /* Clean the key bindings. */ cleanCDKObjectBindings (v, widget); /* Unregister this object. */ unregisterCDKObject (v, widget); } } /* * This function erases the widget from the screen. */ static void _eraseCDK (CDKOBJS *object) { if (validCDKObject (object)) { CDK *widget = (CDK *)object; eraseCursesWindow (widget->labelWin); eraseCursesWindow (widget->fieldWin); eraseCursesWindow (widget->win); eraseCursesWindow (widget->shadowWin); } } /* * This function sets the low/high/current values of the widget. */ void setCDK (CDK *widget, low, high, value, boolean Box) { setCDKLowHigh (widget, low, high); setCDKValue (widget, value); setCDKBox (widget, Box); } /* * This sets the digits. */ #if void setCDKDigits (CDK *widget, int digits) { widget->digits = MAXIMUM (0, digits); } int getCDKDigits (CDK *widget) { return widget->digits; } #endif /* * This sets the widget's value. */ void setCDKValue (CDK *widget, value) { widget->current = value; limitCurrentValue(widget); } getCDKValue (CDK *widget) { return widget->current; } /* * This function sets the low/high values of the widget. */ void setCDKLowHigh (CDK *widget, low, high) { /* Make sure the values aren't out of bounds. */ if (low <= high) { widget->low = low; widget->high = high; } else if (low > high) { widget->low = high; widget->high = low; } /* Make sure the user hasn't done something silly. */ limitCurrentValue(widget); } getCDKLowValue (CDK *widget) { return widget->low; } getCDKHighValue (CDK *widget) { return widget->high; } /* * This sets the widget's box attribute. */ void setCDKBox (CDK *widget, boolean Box) { ObjOf(widget)->box = Box; ObjOf(widget)->borderSize = Box ? 1 : 0; } boolean getCDKBox (CDK *widget) { return ObjOf(widget)->box; } static void _focusCDK(CDKOBJS *object) { CDK *widget = (CDK *)object; drawCDK (widget, ObjOf(widget)->box); } static void _unfocusCDK(CDKOBJS *object) { CDK *widget = (CDK *)object; drawCDK (widget, ObjOf(widget)->box); } dummyRefreshData() dummySaveData() cdk-5.0-20060507/gen-scale.sh0000755000175100001440000000225610354613410013736 0ustar tomusers#! /bin/sh # $Id: gen-scale.sh,v 1.6 2005/12/28 22:51:52 tom Exp $ # # This script generates source variations from scale.c for different datatypes. UPPER="$1" MIXED="$2" DTYPE="$3" CTYPE="$4" # The widget provides for setting the digits. Turn on/off the corresponding # ifdef. case $CTYPE in float|*double) float=1 print=f ;; long*long) float=0 print=ll ;; unsigned*long) float=0 print=lu ;; unsigned) float=0 print=u ;; long) float=0 print=l ;; *) float=0 print=d ;; esac if test "$print" = "d" ; then MODEL= elif test $CTYPE = double; then MODEL="d" else MODEL=$print fi if test $float = 0 ; then sed -e '/^#if /,/^#endif /d' \ -e '/^#if /d' \ -e '/^#endif /d' \ -e 's//'"$UPPER"'/g' \ -e 's//'"$MIXED"'/g' \ -e 's//'"$DTYPE"'/g' \ -e 's//'"$CTYPE"'/g' \ -e 's//'"$MODEL"'/g' \ -e 's//'"$print"'/g' \ $5 else sed -e '/^#if /,/^#endif /d' \ -e '/^#if /d' \ -e '/^#endif /d' \ -e 's//'"$UPPER"'/g' \ -e 's//'"$MIXED"'/g' \ -e 's//'"$DTYPE"'/g' \ -e 's//'"$CTYPE"'/g' \ -e 's//'"$MODEL"'/g' \ -e 's//'"$print"'/g' \ $5 fi cdk-5.0-20060507/gen-slider.c0000644000175100001440000004571710426516000013744 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:27:44 $ * $Revision: 1.19 $ */ /* * Declare file local prototypes. */ static void drawCDKField (CDK *widget); static int formattedSize (CDK *widget, value); DeclareCDKObjects(, , setCdk, ); /* * This function creates a widget. */ CDK *newCDK (CDKSCREEN *cdkscreen, int xplace, int yplace, char *title, char *label, chtype filler, int fieldWidth, start, low, high, inc, fastInc, #if int digits, #endif boolean Box, boolean shadow) { CDK *widget = 0; int parentWidth = getmaxx(cdkscreen->window); int parentHeight = getmaxy(cdkscreen->window); int boxHeight; int boxWidth = 0; int horizontalAdjust, oldWidth; int xpos = xplace; int ypos = yplace; int highValueLen; int x, junk; static const struct { int from; int to; } bindings[] = { { 'u', KEY_UP }, { 'U', KEY_PPAGE }, { CDK_BACKCHAR, KEY_PPAGE }, { CDK_FORCHAR, KEY_NPAGE }, { 'g', KEY_HOME }, { '^', KEY_HOME }, { 'G', KEY_END }, { '$', KEY_END }, }; if ((widget = newCDKObject(CDK, &my_funcs)) == 0) return (0); setCDKBox (widget, Box); boxHeight = (BorderOf(widget) * 2) + 1; /* Set some basic values of the widget's data field. */ widget->label = 0; widget->labelLen = 0; widget->labelWin = 0; #if widget->digits = digits; #endif highValueLen = formattedSize (widget, high); /* * 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); /* Translate the label char *pointer to a chtype pointer. */ if (label != 0) { widget->label = char2Chtype (label, &widget->labelLen, &junk); boxWidth = widget->labelLen + fieldWidth + highValueLen + 2 * BorderOf(widget); } else { boxWidth = fieldWidth + highValueLen + 2*BorderOf(widget); } oldWidth = boxWidth; boxWidth = setCdkTitle(ObjOf(widget), title, boxWidth); horizontalAdjust = (boxWidth - oldWidth) / 2; boxHeight += TitleLinesOf(widget); /* * Make sure we didn't extend beyond the dimensions of the window. */ boxWidth = (boxWidth > parentWidth ? parentWidth : boxWidth); boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight); fieldWidth = (fieldWidth > (boxWidth - widget->labelLen - highValueLen - 1) ? (boxWidth - widget->labelLen - highValueLen - 1) : fieldWidth); /* Rejustify the x and y positions if we need to. */ alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight); /* Make the widget's window. */ widget->win = newwin (boxHeight, boxWidth, ypos, xpos); /* Is the main window null??? */ if (widget->win == 0) { destroyCDKObject(widget); return (0); } /* Create the widget's label window. */ if (widget->label != 0) { widget->labelWin = subwin (widget->win, 1, widget->labelLen, ypos + TitleLinesOf(widget) + BorderOf(widget), xpos + horizontalAdjust + BorderOf(widget)); if (widget->labelWin == 0) { destroyCDKObject(widget); return (0); } } /* Create the widget's data field window. */ widget->fieldWin = subwin (widget->win, 1, fieldWidth + highValueLen - 1, ypos + TitleLinesOf(widget) + BorderOf(widget), xpos + widget->labelLen + horizontalAdjust + BorderOf(widget)); if (widget->fieldWin == 0) { destroyCDKObject(widget); return (0); } keypad (widget->fieldWin, TRUE); keypad (widget->win, TRUE); /* Create the widget's data field. */ ScreenOf(widget) = cdkscreen; widget->parent = cdkscreen->window; widget->shadowWin = 0; widget->boxWidth = boxWidth; widget->boxHeight = boxHeight; widget->fieldWidth = fieldWidth-1; widget->filler = filler; widget->low = low; widget->high = high; widget->current = start; widget->inc = inc; widget->fastinc = fastInc; initExitType(widget); ObjOf(widget)->acceptsFocus = TRUE; ObjOf(widget)->inputWindow = widget->win; widget->shadow = shadow; /* Set the start value. */ if (start < low) { widget->current = low; } /* Do we want a shadow??? */ if (shadow) { widget->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1); if (widget->shadowWin == 0) { destroyCDKObject(widget); return (0); } } /* Setup the key bindings. */ for (x = 0; x < (int) SIZEOF(bindings); ++x) bindCDKObject (v, widget, bindings[x].from, getcCDKBind, (void *)(long)bindings[x].to); registerCDKObject (cdkscreen, v, widget); return (widget); } /* * This allows the person to use the widget's data field. */ activateCDK (CDK *widget, chtype *actions) { ret; /* Draw the widget. */ drawCDK (widget, ObjOf(widget)->box); if (actions == 0) { chtype input = 0; boolean functionKey; for (;;) { input = getchCDKObject (ObjOf(widget), &functionKey); /* Inject the character into the widget. */ ret = injectCDK (widget, input); if (widget->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 = injectCDK (widget, actions[x]); if (widget->exitType != vEARLY_EXIT) { return ret; } } } /* Set the exit type and return. */ setExitType(widget, 0); return unknown; } /* * Check if the value lies outside the low/high range. If so, force it in. */ static void limitCurrentValue (CDK *widget) { if (widget->current < widget->low) { widget->current = widget->low; Beep(); } else if (widget->current > widget->high) { widget->current = widget->high; Beep(); } } /* * Move the cursor to the given edit-position. */ static int moveToEditPosition(CDK *widget, int newPosition) { return wmove(widget->fieldWin, 0, widget->fieldWidth + formattedSize(widget, widget->current) - newPosition); } /* * Check if the cursor is on a valid edit-position. This must be one of * the non-blank cells in the field. */ static int validEditPosition(CDK *widget, int newPosition) { chtype ch; if (newPosition <= 0 || newPosition >= widget->fieldWidth) return FALSE; if (moveToEditPosition(widget, newPosition) == ERR) return FALSE; ch = winch(widget->fieldWin); if (CharOf(ch) != ' ') return TRUE; if (newPosition > 1) { /* don't use recursion - only one level is wanted */ if (moveToEditPosition(widget, newPosition - 1) == ERR) return FALSE; ch = winch(widget->fieldWin); return CharOf(ch) != ' '; } return FALSE; } /* * Set the edit position. Normally the cursor is one cell to the right of * the editable field. Moving it left, over the field allows the user to * modify cells by typing in replacement characters for the field's value. */ static void setEditPosition(CDK *widget, int newPosition) { if (newPosition < 0) { Beep(); } else if (newPosition == 0) { widget->fieldEdit = newPosition; } else if (validEditPosition(widget, newPosition)) { widget->fieldEdit = newPosition; } else { Beep(); } } /* * Remove the character from the string at the given column, if it is blank. * Returns true if a change was made. */ static bool removeChar(char *string, int col) { bool result = FALSE; if ((col >= 0) && (string[col] != ' ')) { while (string[col] != '\0') { string[col] = string[col + 1]; ++col; } result = TRUE; } return result; } /* * Perform an editing function for the field. */ static bool performEdit(CDK *widget, chtype input) { bool result = FALSE; bool modify = TRUE; int base = widget->fieldWidth; int need = formattedSize(widget, widget->current); char *temp = (char *)malloc(need + 5); char *data = temp; char test; int col = need - widget->fieldEdit; #if double value; #define SCANF_FMT "%lg%c" #endif #if value; #define SCANF_FMT "%%c" #endif if (temp != 0) { int adj = (col < 0) ? (-col) : 0; if (adj) { memset(temp, ' ', adj); temp += adj; } wmove(widget->fieldWin, 0, base); winnstr(widget->fieldWin, temp, need); strcpy(temp + need, " "); if (isChar(input)) /* replace the char at the cursor */ { temp[col] = CharOf(input); } else if (input == KEY_BACKSPACE) /* delete the char before the cursor */ { modify = removeChar(temp, col - 1); } else if (input == KEY_DC) /* delete the char at the cursor */ { modify = removeChar(temp, col); } else { modify = FALSE; } if (modify && sscanf(temp, SCANF_FMT, &value, &test) == 2 && test == ' ' && value >= widget->low && value <= widget->high) { setCDKValue(widget, value); result = TRUE; } free(data); } return result; } #define Decrement(value,by) if (value - by < value) value -= by #define Increment(value,by) if (value + by > value) value += by /* * This function injects a single character into the widget. */ static int _injectCDK (CDKOBJS *object, chtype input) { CDK *widget = (CDK *)object; int ppReturn = 1; ret = unknown; bool complete = FALSE; /* Set the exit type. */ setExitType(widget, 0); /* Draw the field. */ drawCDKField (widget); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf(widget) != 0) { /* Call the pre-process function. */ ppReturn = PreProcessFuncOf(widget) (v, widget, PreProcessDataOf(widget), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check for a key binding. */ if (checkCDKObjectBind(v, widget, input) != 0) { checkEarlyExit(widget); complete = TRUE; } else { switch (input) { case KEY_LEFT : setEditPosition(widget, widget->fieldEdit + 1); break; case KEY_RIGHT : setEditPosition(widget, widget->fieldEdit - 1); break; case KEY_DOWN : Decrement(widget->current, widget->inc); break; case KEY_UP : Increment(widget->current, widget->inc); break; case KEY_PPAGE : Increment(widget->current, widget->fastinc); break; case KEY_NPAGE : Decrement(widget->current, widget->fastinc); break; case KEY_HOME : widget->current = widget->low; break; case KEY_END : widget->current = widget->high; break; case KEY_TAB : case KEY_ENTER : setExitType(widget, input); ret = (widget->current); complete = TRUE; break; case KEY_ESC : setExitType(widget, input); complete = TRUE; break; case CDK_REFRESH : eraseCDKScreen (ScreenOf(widget)); refreshCDKScreen (ScreenOf(widget)); break; default : if (widget->fieldEdit) { if (!performEdit(widget, input)) Beep(); } else { /* * The cursor is not within the editable text. Interpret * input as commands. */ switch (input) { case 'd': case '-': return _injectCDK(object, KEY_DOWN); case '+': return _injectCDK(object, KEY_UP); case 'D': return _injectCDK(object, KEY_NPAGE); case '0': return _injectCDK(object, KEY_HOME); default: Beep(); break; } } break; } } limitCurrentValue(widget); /* Should we call a post-process? */ if (!complete && (PostProcessFuncOf(widget) != 0)) { PostProcessFuncOf(widget) (v, widget, PostProcessDataOf(widget), input); } } if (!complete) { drawCDKField (widget); setExitType(widget, 0); } ResultOf(widget).value = ret; return (ret != unknown); } /* * This moves the widget's data field to the given location. */ static void _moveCDK (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDK *widget = (CDK *)object; int currentX = getbegx(widget->win); int currentY = getbegy(widget->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(widget->win) + xplace; ypos = getbegy(widget->win) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf(widget), &xpos, &ypos, widget->boxWidth, widget->boxHeight); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the window to the new location. */ moveCursesWindow(widget->win, -xdiff, -ydiff); moveCursesWindow(widget->labelWin, -xdiff, -ydiff); moveCursesWindow(widget->fieldWin, -xdiff, -ydiff); moveCursesWindow(widget->shadowWin, -xdiff, -ydiff); /* Touch the windows so they 'move'. */ refreshCDKWindow (WindowOf(widget)); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDK (widget, ObjOf(widget)->box); } } /* * This function draws the widget. */ static void _drawCDK (CDKOBJS *object, boolean Box) { CDK *widget = (CDK *)object; /* Draw the shadow. */ if (widget->shadowWin != 0) { drawShadow (widget->shadowWin); } /* Box the widget if asked. */ if (Box) { drawObjBox (widget->win, ObjOf(widget)); } drawCdkTitle (widget->win, object); /* Draw the label. */ if (widget->labelWin != 0) { writeChtype (widget->labelWin, 0, 0, widget->label, HORIZONTAL, 0, widget->labelLen); wrefresh (widget->labelWin); } wrefresh (widget->win); /* Draw the field window. */ drawCDKField (widget); } /* * This draws the widget. */ static void drawCDKField (CDK *widget) { int fillerCharacters, x; char temp[256]; float step = ((float)widget->fieldWidth / (float)(widget->high - widget->low)); /* Determine how many filler characters need to be drawn. */ fillerCharacters = (int)((widget->current - widget->low) * step); werase (widget->fieldWin); /* Add the character to the window. */ for (x=0; x < fillerCharacters; x++) { mvwaddch (widget->fieldWin, 0, x, widget->filler); } /* Draw the value in the field. */ #if { char format[256]; int digits = MINIMUM(widget->digits, 30); sprintf (format, "%%.%i", digits); sprintf (temp, format, widget->current); } #endif #if sprintf (temp, "%", widget->current); #endif writeCharAttrib (widget->fieldWin, widget->fieldWidth, 0, temp, A_NORMAL, HORIZONTAL, 0, (int)strlen(temp)); moveToEditPosition(widget, widget->fieldEdit); wrefresh (widget->fieldWin); } /* * This sets the background attribute of the widget. */ static void _setBKattr (CDKOBJS *object, chtype attrib) { if (object != 0) { CDK *widget = (CDK *)object; /* Set the widgets background attribute. */ wbkgd (widget->win, attrib); wbkgd (widget->fieldWin, attrib); if (widget->labelWin != 0) { wbkgd (widget->labelWin, attrib); } } } /* * This function destroys the widget. */ static void _destroyCDK (CDKOBJS *object) { if (object != 0) { CDK *widget = (CDK *)object; cleanCdkTitle (object); freeChtype (widget->label); /* Clean up the windows. */ deleteCursesWindow (widget->fieldWin); deleteCursesWindow (widget->labelWin); deleteCursesWindow (widget->shadowWin); deleteCursesWindow (widget->win); /* Clean the key bindings. */ cleanCDKObjectBindings (v, widget); /* Unregister this object. */ unregisterCDKObject (v, widget); } } /* * This function erases the widget from the screen. */ static void _eraseCDK (CDKOBJS *object) { if (validCDKObject (object)) { CDK *widget = (CDK *)object; eraseCursesWindow (widget->labelWin); eraseCursesWindow (widget->fieldWin); eraseCursesWindow (widget->win); eraseCursesWindow (widget->shadowWin); } } static int formattedSize (CDK *widget, value) { char temp[256]; #if char format[256]; int digits = MINIMUM(widget->digits, 30); sprintf (format, "%%.%i", digits); sprintf (temp, format, value); #endif #if (void) widget; sprintf (temp, "%", value); #endif return strlen (temp); } /* * This function sets the low/high/current values of the widget. */ void setCDK (CDK *widget, low, high, value, boolean Box) { setCDKLowHigh (widget, low, high); setCDKValue (widget, value); setCDKBox (widget, Box); } /* * This sets the digits. */ #if void setCDKDigits (CDK *widget, int digits) { widget->digits = MAXIMUM (0, digits); } int getCDKDigits (CDK *widget) { return widget->digits; } #endif /* * This sets the widget's value. */ void setCDKValue (CDK *widget, value) { widget->current = value; limitCurrentValue(widget); } getCDKValue (CDK *widget) { return widget->current; } /* * This function sets the low/high values of the widget. */ void setCDKLowHigh (CDK *widget, low, high) { /* Make sure the values aren't out of bounds. */ if (low <= high) { widget->low = low; widget->high = high; } else if (low > high) { widget->low = high; widget->high = low; } /* Make sure the user hasn't done something silly. */ limitCurrentValue(widget); } getCDKLowValue (CDK *widget) { return widget->low; } getCDKHighValue (CDK *widget) { return widget->high; } /* * This sets the widget's box attribute. */ void setCDKBox (CDK *widget, boolean Box) { ObjOf(widget)->box = Box; ObjOf(widget)->borderSize = Box ? 1 : 0; } boolean getCDKBox (CDK *widget) { return ObjOf(widget)->box; } static void _focusCDK(CDKOBJS *object) { CDK *widget = (CDK *)object; drawCDK (widget, ObjOf(widget)->box); } static void _unfocusCDK(CDKOBJS *object) { CDK *widget = (CDK *)object; drawCDK (widget, ObjOf(widget)->box); } dummyRefreshData() dummySaveData() cdk-5.0-20060507/get_index.c0000644000175100001440000000246407761473432013674 0ustar tomusers#include /* * $Author: tom $ * $Date: 2003/11/27 22:13:46 $ * $Revision: 1.1 $ */ /* * This returns a selected value in a list. */ int getListIndex (CDKSCREEN *screen, char *title, char **list, int listSize, boolean numbers) { CDKSCROLL *scrollp = 0; int selected = -1; int height = 10; int width = -1; int len = 0; int x; /* Determine the height of the list. */ if (listSize < 10) { height = listSize + (title == 0 ? 2 : 3); } /* Determine the width of the list. */ for (x=0; x < listSize; x++) { int temp = strlen (list[x]) + 10; width = MAXIMUM (width, temp); } if (title != 0) { len = strlen (title); } width = MAXIMUM (width, len); width += 5; /* Create the scrolling list. */ scrollp = newCDKScroll (screen, CENTER, CENTER, RIGHT, height, width, title, list, listSize, numbers, A_REVERSE, TRUE, FALSE); /* Check if we made the list. */ if (scrollp == 0) { refreshCDKScreen (screen); return -1; } /* Let the user play. */ selected = activateCDKScroll (scrollp, 0); /* Check how they exited. */ if (scrollp->exitType != vNORMAL) { selected = -1; } /* Clean up. */ destroyCDKScroll (scrollp); refreshCDKScreen (screen); return selected; } cdk-5.0-20060507/get_string.c0000644000175100001440000000151407761473410014062 0ustar tomusers#include /* * $Author: tom $ * $Date: 2003/11/27 22:13:28 $ * $Revision: 1.1 $ */ /* * This gets information from a user. */ char *getString (CDKSCREEN *screen, char *title, char *label, char *initValue) { CDKENTRY *widget = 0; char *value = 0; /* Create the widget. */ widget = newCDKEntry (screen, CENTER, CENTER, title, label, A_NORMAL, '.', vMIXED, 40, 0, 5000, TRUE, FALSE); /* Set the default value. */ setCDKEntryValue (widget, initValue); /* Get the string. */ value = activateCDKEntry (widget, 0); /* Make sure they exited normally. */ if (widget->exitType != vNORMAL) { destroyCDKEntry (widget); return 0; } /* Return a copy of the string typed in. */ value = copyChar (getCDKEntryValue (widget)); destroyCDKEntry (widget); return value; } cdk-5.0-20060507/graph.c0000644000175100001440000003145110426516000013002 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:27:44 $ * $Revision: 1.82 $ */ DeclareCDKObjects (GRAPH, Graph, setCdk, Unknown); #define TITLE_LM 3 /* * Create a graph widget. */ CDKGRAPH *newCDKGraph (CDKSCREEN *cdkscreen, int xplace, int yplace, int height, int width, char *title, char *xtitle, char *ytitle) { CDKGRAPH *widget = 0; int parentWidth = getmaxx (cdkscreen->window); int parentHeight = getmaxy (cdkscreen->window); int boxWidth = width; int boxHeight = height; int xpos = xplace; int ypos = yplace; if ((widget = newCDKObject (CDKGRAPH, &my_funcs)) == 0) return (0); setCDKGraphBox (widget, FALSE); boxHeight = setWidgetDimension (parentHeight, height, 3); boxWidth = setWidgetDimension (parentWidth, width, 0); boxWidth = setCdkTitle (ObjOf (widget), title, boxWidth); boxHeight += TitleLinesOf (widget); boxWidth = MINIMUM (boxWidth, parentWidth); boxHeight = MINIMUM (boxHeight, parentHeight); /* Rejustify the x and y positions if we need to. */ alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight); /* Create the widget pointer. */ ScreenOf (widget) = cdkscreen; widget->parent = cdkscreen->window; widget->win = newwin (boxHeight, boxWidth, ypos, xpos); widget->boxHeight = boxHeight; widget->boxWidth = boxWidth; widget->minx = 0; widget->maxx = 0; widget->xscale = 0; widget->yscale = 0; widget->count = 0; widget->displayType = vLINE; if (widget->win == 0) { destroyCDKObject (widget); return (0); } keypad (widget->win, TRUE); /* Translate the X Axis title char * to a chtype * */ if (xtitle != 0) { widget->xtitle = char2Chtype (xtitle, &widget->xtitleLen, &widget->xtitlePos); widget->xtitlePos = justifyString (widget->boxHeight, widget->xtitleLen, widget->xtitlePos); } else { widget->xtitle = char2Chtype ("X Axis", &widget->xtitleLen, &widget->xtitlePos); widget->xtitlePos = justifyString (widget->boxHeight, widget->xtitleLen, widget->xtitlePos); } /* Translate the Y Axis title char * to a chtype * */ if (ytitle != 0) { widget->ytitle = char2Chtype (ytitle, &widget->ytitleLen, &widget->ytitlePos); widget->ytitlePos = justifyString (widget->boxWidth, widget->ytitleLen, widget->ytitlePos); } else { widget->ytitle = char2Chtype ("Y Axis", &widget->ytitleLen, &widget->ytitlePos); widget->ytitlePos = justifyString (widget->boxWidth, widget->ytitleLen, widget->ytitlePos); } widget->graphChar = 0; registerCDKObject (cdkscreen, vGRAPH, widget); return (widget); } /* * This was added for the builder. */ void activateCDKGraph (CDKGRAPH *widget, chtype *actions GCC_UNUSED) { drawCDKGraph (widget, ObjOf (widget)->box); } /* * Set multiple attributes of the widget. */ int setCDKGraph (CDKGRAPH *widget, int *values, int count, char *graphChar, boolean startAtZero, EGraphDisplayType displayType) { int ret; ret = setCDKGraphValues (widget, values, count, startAtZero); setCDKGraphCharacters (widget, graphChar); setCDKGraphDisplayType (widget, displayType); return ret; } /* * Set the scale factors for the graph after we have loaded new values. */ static void setScales (CDKGRAPH *widget) { widget->xscale = ((widget->maxx - widget->minx) / MAXIMUM (1, (widget->boxHeight - TitleLinesOf (widget) - 5))); if (widget->xscale <= 0) widget->xscale = 1; widget->yscale = ((widget->boxWidth-4) / MAXIMUM (1, widget->count)); if (widget->yscale <= 0) widget->yscale = 1; } /* * Set the values of the graph. */ int setCDKGraphValues (CDKGRAPH *widget, int *values, int count, boolean startAtZero) { int min = INT_MAX; int max = INT_MIN; int x; /* Make sure everything is happy. */ if (count < 0) return (FALSE); if (widget->values != 0) { free (widget->values); widget->values = 0; widget->count = 0; } if ((widget->values = typeCallocN (int, count + 1)) == 0) return FALSE; /* Copy the X values. */ for (x = 0; x < count; x++) { /* Determine the min/max values of the graph. */ min = MINIMUM (values[x], widget->minx); max = MAXIMUM (values[x], widget->maxx); /* Copy the value. */ widget->values[x] = values[x]; } /* Keep the count and min/max values. */ widget->count = count; widget->minx = min; widget->maxx = max; /* Check the start at zero status. */ if (startAtZero) { widget->minx = 0; } setScales (widget); return (TRUE); } int *getCDKGraphValues (CDKGRAPH *widget, int *size) { (*size) = widget->count; return widget->values; } /* * Set the value of the graph at the given index. */ int setCDKGraphValue (CDKGRAPH *widget, int Index, int value, boolean startAtZero) { /* Make sure the index is within range. */ if (Index < 0 || Index >= widget->count) { return (FALSE); } /* Set the min, max, and value for the graph. */ widget->minx = MINIMUM (value, widget->minx); widget->maxx = MAXIMUM (value, widget->maxx); widget->values[Index] = value; /* Check the start at zero status. */ if (startAtZero) { widget->minx = 0; } setScales (widget); return (TRUE); } int getCDKGraphValue (CDKGRAPH *widget, int Index) { return Index >= 0 && Index < widget->count ? widget->values[Index] : 0; } /* * Set the characters of the graph widget. */ int setCDKGraphCharacters (CDKGRAPH *widget, char *characters) { chtype *newTokens = 0; int charCount, junk; newTokens = char2Chtype (characters, &charCount, &junk); if (charCount != widget->count) { freeChtype (newTokens); return (FALSE); } freeChtype (widget->graphChar); widget->graphChar = newTokens; return (TRUE); } chtype *getCDKGraphCharacters (CDKGRAPH *widget) { return widget->graphChar; } /* * Set the character of the graph widget of the given index. */ int setCDKGraphCharacter (CDKGRAPH *widget, int Index, char *character) { chtype *newTokens = 0; int charCount, junk; /* Make sure the index is within range. */ if (Index < 0 || Index > widget->count) { return (FALSE); } /* Convert the string given to us. */ newTokens = char2Chtype (character, &charCount, &junk); /* * Check if the number of characters back is the same as the number * of elements in the list. */ if (charCount != widget->count) { freeChtype (newTokens); return (FALSE); } /* Everything OK so far. Set the value of the array. */ widget->graphChar[Index] = newTokens[0]; freeChtype (newTokens); return (TRUE); } chtype getCDKGraphCharacter (CDKGRAPH *widget, int Index) { return widget->graphChar[Index]; } /* * Set the display type of the graph. */ void setCDKGraphDisplayType (CDKGRAPH *widget, EGraphDisplayType type) { widget->displayType = type; } EGraphDisplayType getCDKGraphDisplayType (CDKGRAPH *widget) { return widget->displayType; } /* * Set the background attribute of the widget. */ static void _setBKattrGraph (CDKOBJS *object, chtype attrib) { if (object != 0) { CDKGRAPH *widget = (CDKGRAPH *)object; wbkgd (widget->win, attrib); } } /* * Move the graph field to the given location. */ static void _moveCDKGraph (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDKGRAPH *widget = (CDKGRAPH *)object; int currentX = getbegx (widget->win); int currentY = getbegy (widget->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 (widget->win) + xplace; ypos = getbegy (widget->win) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf (widget), &xpos, &ypos, widget->boxWidth, widget->boxHeight); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the window to the new location. */ moveCursesWindow (widget->win, -xdiff, -ydiff); moveCursesWindow (widget->shadowWin, -xdiff, -ydiff); /* Touch the windows so they 'move'. */ refreshCDKWindow (WindowOf (widget)); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDKGraph (widget, ObjOf (widget)->box); } } /* * Set whether or not the graph will be boxed. */ void setCDKGraphBox (CDKGRAPH *widget, boolean Box) { ObjOf (widget)->box = Box; ObjOf (widget)->borderSize = Box ? 1 : 0; } boolean getCDKGraphBox (CDKGRAPH *widget) { return ObjOf (widget)->box; } /* * Draw the graph widget. */ static void _drawCDKGraph (CDKOBJS *object, boolean Box) { CDKGRAPH *widget = (CDKGRAPH *)object; int adj = 2 + (widget->xtitle == 0 ? 0 : 1); int spacing = 0; chtype attrib = ' ' | A_REVERSE; char temp[100]; int x, y, xpos, ypos, len; /* Box it if needed. */ if (Box) { drawObjBox (widget->win, ObjOf (widget)); } /* Draw in the vertical axis. */ drawLine (widget->win, 2, TitleLinesOf (widget) + 1, 2, widget->boxHeight - 3, ACS_VLINE); /* Draw in the horizontal axis. */ drawLine (widget->win, 3, widget->boxHeight-3, widget->boxWidth, widget->boxHeight - 3, ACS_HLINE); drawCdkTitle (widget->win, object); /* Draw in the X axis title. */ if (widget->xtitle != 0) { writeChtype (widget->win, 0, widget->xtitlePos, widget->xtitle, VERTICAL, 0, widget->xtitleLen); attrib = widget->xtitle[0] & A_ATTRIBUTES; } /* Draw in the X axis high value. */ sprintf (temp, "%d", widget->maxx); len = (int)strlen (temp); writeCharAttrib (widget->win, 1, TitleLinesOf (widget) + 1, temp, attrib, VERTICAL, 0, len); /* Draw in the X axis low value. */ sprintf (temp, "%d", widget->minx); len = (int)strlen (temp); writeCharAttrib (widget->win, 1, widget->boxHeight - 2 - len, temp, attrib, VERTICAL, 0, len); /* Draw in the Y axis title. */ if (widget->ytitle != 0) { writeChtype (widget->win, widget->ytitlePos, widget->boxHeight-1, widget->ytitle, HORIZONTAL, 0, widget->ytitleLen); attrib = widget->ytitle[0] & A_ATTRIBUTES; } /* Draw in the Y axis high value. */ sprintf (temp, "%d", widget->count); len = (int)strlen (temp); writeCharAttrib (widget->win, widget->boxWidth - len - adj, widget->boxHeight-2, temp, attrib, HORIZONTAL, 0, len); /* Draw in the Y axis low value. */ sprintf (temp, "0"); writeCharAttrib (widget->win, 3, widget->boxHeight - 2, temp, attrib, HORIZONTAL, 0, (int)strlen (temp)); /* If the count is zero, then there aren't any points. */ if (widget->count == 0) { wrefresh (widget->win); return; } spacing = (widget->boxWidth - TITLE_LM) / widget->count; /* Draw in the graph line/plot points. */ for (y = 0; y < widget->count; y++) { int colheight = (widget->values[y] / widget->xscale) - 1; /* Add the marker on the Y axis. */ mvwaddch (widget->win, widget->boxHeight - 3, (y + 1)*spacing + adj, ACS_TTEE); /* If this is a plot graph, all we do is draw a dot. */ if (widget->displayType == vPLOT) { xpos = widget->boxHeight - 4 - colheight; ypos = (y + 1) * spacing + adj; mvwaddch (widget->win, xpos, ypos, widget->graphChar[y]); } else { for (x = 0; x <= widget->yscale; x++) { xpos = widget->boxHeight - 3; ypos = (y + 1) * spacing + adj; drawLine (widget->win, ypos, xpos - colheight, ypos, xpos, widget->graphChar[y]); } } } /* Draw in the axis corners. */ mvwaddch (widget->win, TitleLinesOf (widget), 2, ACS_URCORNER); mvwaddch (widget->win, widget->boxHeight - 3, 2, ACS_LLCORNER); mvwaddch (widget->win, widget->boxHeight - 3, widget->boxWidth, ACS_URCORNER); /* Refresh and lets see 'er. */ wrefresh (widget->win); } /* * Destroy the graph widget. */ static void _destroyCDKGraph (CDKOBJS *object) { if (object != 0) { CDKGRAPH *widget = (CDKGRAPH *)object; cleanCdkTitle (object); freeChtype (widget->xtitle); freeChtype (widget->ytitle); freeChtype (widget->graphChar); freeChecked (widget->values); /* Clean the key bindings. */ cleanCDKObjectBindings (vGRAPH, widget); /* Unregister this object. */ unregisterCDKObject (vGRAPH, widget); /* Clean up the windows. */ deleteCursesWindow (widget->win); } } /* * Erase the graph widget from the screen. */ static void _eraseCDKGraph (CDKOBJS *object) { if (validCDKObject (object)) { CDKGRAPH *widget = (CDKGRAPH *)object; eraseCursesWindow (widget->win); } } dummyInject (Graph) dummyFocus (Graph) dummyUnfocus (Graph) dummyRefreshData (Graph) dummySaveData (Graph) cdk-5.0-20060507/headers.sh0000755000175100001440000000533110355363032013513 0ustar tomusers#! /bin/sh # $Id: headers.sh,v 1.9 2005/12/31 01:59:54 tom Exp $ # # Adjust includes for header files that reside in a subdirectory of # /usr/include, etc. # # Options: # -c CFG specify an alternate name for config.h # -d DIR target directory # -e FILE extra editing commands, e.g., for manpage references # -i create/update the headers.sed script # -p PKG specify the package name # -s DIR source directory # -t TYPE renaming for manpage-sections # -x PRG install-program (plus options, the whole value in quotes) # # Other parameters are assumed to be provided only for the install scenario. SCRIPT=headers.sed MYFILE=headers.tmp OPT_C=config.h OPT_D= OPT_E= OPT_I=n OPT_P= OPT_S= OPT_T= OPT_X=install while test $# != 0 do case $1 in -c) # CFG specify an alternate name for config.h shift OPT_C="$1" ;; -d) # DIR target directory shift OPT_D="$1" ;; -e) # FILE extra sed-commands shift OPT_E="$OPT_E -f $1" ;; -i) # create the headers.sed script if test "$OPT_I" = n then rm -f $SCRIPT fi OPT_I=y if ( test -n "$OPT_D" && test -d "$OPT_D" ) then if ( test -n "$OPT_S" && test -d "$OPT_S" ) then LEAF=`basename $OPT_D` case $OPT_D in /*/include/$LEAF) END=`basename $OPT_D` for i in $OPT_S/*.h do NAME=`basename $i` echo "s%<$NAME>%<$END/$NAME>%g" >> $SCRIPT done ;; *) echo "" >> $SCRIPT ;; esac OPT_S= if test -f $SCRIPT ; then sort -u $SCRIPT >$MYFILE rm -f $SCRIPT mv $MYFILE $SCRIPT fi fi fi if test -n "$OPT_P" then for name in ` egrep "#define[ ][ ]*[A-Z]" $OPT_C \ | sed -e 's/^#define[ ][ ]*//' \ -e 's/[ ].*//' \ | fgrep -v GCC_ \ | sort -u \ | egrep -v "^${OPT_P}_"` do echo "s%\\<$name\\>%${OPT_P}_$name%g" >>$SCRIPT done if test -f $SCRIPT ; then sort -u $SCRIPT >$MYFILE rm -f $SCRIPT mv $MYFILE $SCRIPT fi OPT_P= fi ;; -p) # PKG specify the package name shift OPT_P="$1" ;; -s) # DIR source directory shift OPT_S="$1" ;; -t) # rename suffix of target shift OPT_T="$1" ;; -x) # PRG install-program (plus options, the whole value in quotes) shift OPT_X="$1" ;; *) FILE=$1 SHOW=`basename $FILE` TMPSRC=${TMPDIR-/tmp}/${SHOW}$$ echo " ... $SHOW" test -f $OPT_S/$FILE && FILE="$OPT_S/$FILE" if test -f "$FILE" then rm -f $TMPSRC sed -f $SCRIPT $OPT_E $FILE > $TMPSRC NAME=`basename $FILE` if test -n "$OPT_T" ; then NAME=`echo "$NAME" | sed -e 's/\.[^.]*$//'`.$OPT_T fi # Just in case someone gzip'd manpages, remove the conflicting copy. test -f $OPT_D/$NAME.gz && rm -f $OPT_D/$NAME.gz eval $OPT_X $TMPSRC $OPT_D/$NAME rm -f $TMPSRC fi ;; esac shift done cdk-5.0-20060507/histogram.c0000644000175100001440000004377310426516000013710 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:27:44 $ * $Revision: 1.86 $ */ DeclareCDKObjects (HISTOGRAM, Histogram, setCdk, Unknown); /* * Create a histogram widget. */ CDKHISTOGRAM *newCDKHistogram (CDKSCREEN *cdkscreen, int xplace, int yplace, int height, int width, int orient, char *title, boolean Box, boolean shadow) { CDKHISTOGRAM *widget = 0; int parentWidth = getmaxx (cdkscreen->window); int parentHeight = getmaxy (cdkscreen->window); int boxWidth = width; int boxHeight = height; int xpos = xplace; int ypos = yplace; int oldWidth = 0; int oldHeight = 0; if ((widget = newCDKObject (CDKHISTOGRAM, &my_funcs)) == 0) return (0); setCDKHistogramBox (widget, Box); boxHeight = setWidgetDimension (parentHeight, height, 2); oldHeight = boxHeight; boxWidth = setWidgetDimension (parentWidth, width, 0); oldWidth = boxWidth; boxWidth = setCdkTitle (ObjOf (widget), title, -(boxWidth + 1)); /* Increment the height by the number of lines in the title. */ boxHeight += TitleLinesOf (widget); /* * Make sure we didn't extend beyond the dimensions of the window. */ boxWidth = (boxWidth > parentWidth ? oldWidth : boxWidth); boxHeight = (boxHeight > parentHeight ? oldHeight : boxHeight); /* Rejustify the x and y positions if we need to. */ alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight); /* Create the histogram pointer. */ ScreenOf (widget) = cdkscreen; widget->parent = cdkscreen->window; widget->win = newwin (boxHeight, boxWidth, ypos, xpos); widget->shadowWin = 0; widget->boxWidth = boxWidth; widget->boxHeight = boxHeight; widget->fieldWidth = boxWidth - 2 * BorderOf (widget); widget->fieldHeight = boxHeight - TitleLinesOf (widget) - 2 * BorderOf (widget); widget->orient = orient; widget->shadow = shadow; /* Is the window null. */ if (widget->win == 0) { destroyCDKObject (widget); return (0); } keypad (widget->win, TRUE); /* Set up some default values. */ widget->filler = '#' | A_REVERSE; widget->statsAttr = A_NORMAL; widget->statsPos = TOP; widget->viewType = vREAL; widget->high = 0; widget->low = 0; widget->value = 0; widget->lowx = 0; widget->lowy = 0; widget->highx = 0; widget->highy = 0; widget->curx = 0; widget->cury = 0; widget->lowString = 0; widget->highString = 0; widget->curString = 0; /* Do we want a shadow? */ if (shadow) { widget->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1); } registerCDKObject (cdkscreen, vHISTOGRAM, widget); return (widget); } /* * This was added for the builder. */ void activateCDKHistogram (CDKHISTOGRAM *widget, chtype *actions GCC_UNUSED) { drawCDKHistogram (widget, ObjOf (widget)->box); } /* * Set various widget attributes. */ void setCDKHistogram (CDKHISTOGRAM *widget, EHistogramDisplayType viewType, int statsPos, chtype statsAttr, int low, int high, int value, chtype filler, boolean Box) { setCDKHistogramDisplayType (widget, viewType); setCDKHistogramStatsPos (widget, statsPos); setCDKHistogramValue (widget, low, high, value); setCDKHistogramFillerChar (widget, filler); setCDKHistogramStatsAttr (widget, statsAttr); setCDKHistogramBox (widget, Box); } /* * Set the values for the widget. */ void setCDKHistogramValue (CDKHISTOGRAM *widget, int low, int high, int value) { char string[100]; int len; /* We should error check the information we have. */ widget->low = (low <= high ? low : 0); widget->high = (low <= high ? high : 0); widget->value = (low <= value && value <= high ? value : 0); /* Determine the percentage of the given value. */ widget->percent = ((widget->high == 0) ? 0 : ((float)widget->value / (float)widget->high)); /* Determine the size of the histogram bar. */ if (widget->orient == VERTICAL) { widget->barSize = (int)(widget->percent * (float)widget->fieldHeight); } else { widget->barSize = (int)(widget->percent * (float)widget->fieldWidth); } /* * We have a number of variables which determine the personality of the * histogram. We have to go through each one methodically, and set them * correctly. This section does this. */ if (widget->viewType != vNONE) { if (widget->orient == VERTICAL) { if (widget->statsPos == LEFT || widget->statsPos == BOTTOM) { /* Free the space used by the character strings. */ freeChar (widget->lowString); freeChar (widget->highString); freeChar (widget->curString); /* Set the low label attributes. */ sprintf (string, "%d", widget->low); len = (int)strlen (string); widget->lowString = copyChar (string); widget->lowx = 1; widget->lowy = widget->boxHeight - len - 1; /* Set the high label attributes. */ sprintf (string, "%d", widget->high); widget->highString = copyChar (string); widget->highx = 1; widget->highy = TitleLinesOf (widget) + 1; /* Set the current value attributes. */ if (widget->viewType == vPERCENT) { sprintf (string, "%3.1f%%", (float) (widget->percent * 100)); } else if (widget->viewType == vFRACTION) { sprintf (string, "%d/%d", widget->value, widget->high); } else { sprintf (string, "%d", widget->value); } len = (int)strlen (string); widget->curString = copyChar (string); widget->curx = 1; widget->cury = (((widget->fieldHeight - len) / 2) + TitleLinesOf (widget) + 1); } else if (widget->statsPos == CENTER) { /* Set the character strings correctly. */ freeChar (widget->lowString); freeChar (widget->highString); freeChar (widget->curString); /* Set the low label attributes. */ sprintf (string, "%d", widget->low); len = (int)strlen (string); widget->lowString = copyChar (string); widget->lowx = (widget->fieldWidth/2) + 1; widget->lowy = widget->boxHeight - len - 1; /* Set the high label attributes. */ sprintf (string, "%d", widget->high); widget->highString = copyChar (string); widget->highx = (widget->fieldWidth/2) + 1; widget->highy = TitleLinesOf (widget) + 1; /* Set the stats label attributes. */ if (widget->viewType == vPERCENT) { sprintf (string, "%3.2f%%", (float) (widget->percent * 100)); } else if (widget->viewType == vFRACTION) { sprintf (string, "%d/%d", widget->value, widget->high); } else { sprintf (string, "%d", widget->value); } len = (int)strlen (string); widget->curString = copyChar (string); widget->curx = (widget->fieldWidth/2) + 1; widget->cury = (((widget->fieldHeight - len)/2) + TitleLinesOf (widget) + 1); } else if (widget->statsPos == RIGHT || widget->statsPos == TOP) { /* Set the character strings correctly. */ freeChar (widget->lowString); freeChar (widget->highString); freeChar (widget->curString); /* Set the low label attributes. */ sprintf (string, "%d", widget->low); len = (int)strlen (string); widget->lowString = copyChar (string); widget->lowx = widget->fieldWidth; widget->lowy = widget->boxHeight - len - 1; /* Set the high label attributes. */ sprintf (string, "%d", widget->high); widget->highString = copyChar (string); widget->highx = widget->fieldWidth; widget->highy = TitleLinesOf (widget) + 1; /* Set the stats label attributes. */ if (widget->viewType == vPERCENT) { sprintf (string, "%3.2f%%", (float) (widget->percent * 100)); } else if (widget->viewType == vFRACTION) { sprintf (string, "%d/%d", widget->value, widget->high); } else { sprintf (string, "%d", widget->value); } len = (int)strlen (string); widget->curString = copyChar (string); widget->curx = widget->fieldWidth; widget->cury = (((widget->fieldHeight - len)/2) + TitleLinesOf (widget) + 1); } } else { /* Alignment is HORIZONTAL. */ if (widget->statsPos == TOP || widget->statsPos == RIGHT) { /* Set the character strings correctly. */ freeChar (widget->lowString); freeChar (widget->highString); freeChar (widget->curString); /* Set the low label attributes. */ sprintf (string, "%d", widget->low); widget->lowString = copyChar (string); widget->lowx = 1; widget->lowy = TitleLinesOf (widget) + 1; /* Set the high label attributes. */ sprintf (string, "%d", widget->high); len = (int)strlen (string); widget->highString = copyChar (string); widget->highx = widget->boxWidth - len - 1; widget->highy = TitleLinesOf (widget) + 1; /* Set the stats label attributes. */ if (widget->viewType == vPERCENT) { sprintf (string, "%3.1f%%", (float) (widget->percent * 100)); } else if (widget->viewType == vFRACTION) { sprintf (string, "%d/%d", widget->value, widget->high); } else { sprintf (string, "%d", widget->value); } len = (int)strlen (string); widget->curString = copyChar (string); widget->curx = (widget->fieldWidth - len)/2 + 1; widget->cury = TitleLinesOf (widget) + 1; } else if (widget->statsPos == CENTER) { /* Set the character strings correctly. */ freeChar (widget->lowString); freeChar (widget->highString); freeChar (widget->curString); /* Set the low label attributes. */ sprintf (string, "%d", widget->low); widget->lowString = copyChar (string); widget->lowx = 1; widget->lowy = ((widget->fieldHeight / 2) + TitleLinesOf (widget) + 1); /* Set the high label attributes. */ sprintf (string, "%d", widget->high); len = (int)strlen (string); widget->highString = copyChar (string); widget->highx = widget->boxWidth - len - 1; widget->highy = ((widget->fieldHeight / 2) + TitleLinesOf (widget) + 1); /* Set the stats label attributes. */ if (widget->viewType == vPERCENT) { sprintf (string, "%3.1f%%", (float) (widget->percent * 100)); } else if (widget->viewType == vFRACTION) { sprintf (string, "%d/%d", widget->value, widget->high); } else { sprintf (string, "%d", widget->value); } len = (int)strlen (string); widget->curString = copyChar (string); widget->curx = (widget->fieldWidth - len)/2 + 1; widget->cury = ((widget->fieldHeight / 2) + TitleLinesOf (widget) + 1); } else if (widget->statsPos == BOTTOM || widget->statsPos == LEFT) { /* Set the character strings correctly. */ freeChar (widget->lowString); freeChar (widget->highString); freeChar (widget->curString); /* Set the low label attributes. */ sprintf (string, "%d", widget->low); widget->lowString = copyChar (string); widget->lowx = 1; widget->lowy = widget->boxHeight - 2 * BorderOf (widget); /* Set the high label attributes. */ sprintf (string, "%d", widget->high); len = (int)strlen (string); widget->highString = copyChar (string); widget->highx = widget->boxWidth - len - 1; widget->highy = widget->boxHeight - 2 * BorderOf (widget); /* Set the stats label attributes. */ if (widget->viewType == vPERCENT) { sprintf (string, "%3.1f%%", (float) (widget->percent * 100)); } else if (widget->viewType == vFRACTION) { sprintf (string, "%d/%d", widget->value, widget->high); } else { sprintf (string, "%d", widget->value); } widget->curString = copyChar (string); widget->curx = (widget->fieldWidth - len)/2 + 1; widget->cury = widget->boxHeight - 2 * BorderOf (widget); } } } } int getCDKHistogramValue (CDKHISTOGRAM *widget) { return widget->value; } int getCDKHistogramLowValue (CDKHISTOGRAM *widget) { return widget->low; } int getCDKHistogramHighValue (CDKHISTOGRAM *widget) { return widget->high; } /* * Set the histogram display type. */ void setCDKHistogramDisplayType (CDKHISTOGRAM *widget, EHistogramDisplayType viewType) { widget->viewType = viewType; } EHistogramDisplayType getCDKHistogramViewType (CDKHISTOGRAM *widget) { return widget->viewType; } /* * Set the position of the statistics information. */ void setCDKHistogramStatsPos (CDKHISTOGRAM *widget, int statsPos) { widget->statsPos = statsPos; } int getCDKHistogramStatsPos (CDKHISTOGRAM *widget) { return widget->statsPos; } /* * Set the attribute of the statistics. */ void setCDKHistogramStatsAttr (CDKHISTOGRAM *widget, chtype statsAttr) { widget->statsAttr = statsAttr; } chtype getCDKHistogramStatsAttr (CDKHISTOGRAM *widget) { return widget->statsAttr; } /* * Set the character to use when drawing the widget. */ void setCDKHistogramFillerChar (CDKHISTOGRAM *widget, chtype character) { widget->filler = character; } chtype getCDKHistogramFillerChar (CDKHISTOGRAM *widget) { return widget->filler; } /* * Set the widget box attribute. */ void setCDKHistogramBox (CDKHISTOGRAM *widget, boolean Box) { ObjOf (widget)->box = Box; ObjOf (widget)->borderSize = Box ? 1 : 0; } boolean getCDKHistogramBox (CDKHISTOGRAM *widget) { return ObjOf (widget)->box; } /* * Set the background attribute of the widget. */ static void _setBKattrHistogram (CDKOBJS *object, chtype attrib) { if (object != 0) { CDKHISTOGRAM *widget = (CDKHISTOGRAM *) object; wbkgd (widget->win, attrib); } } /* * Move the histogram field to the given location. */ static void _moveCDKHistogram (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDKHISTOGRAM *widget = (CDKHISTOGRAM *)object; int currentX = getbegx (widget->win); int currentY = getbegy (widget->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 (widget->win) + xplace; ypos = getbegy (widget->win) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf (widget), &xpos, &ypos, widget->boxWidth, widget->boxHeight); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the window to the new location. */ moveCursesWindow (widget->win, -xdiff, -ydiff); moveCursesWindow (widget->shadowWin, -xdiff, -ydiff); /* Touch the windows so they 'move'. */ refreshCDKWindow (WindowOf (widget)); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDKHistogram (widget, ObjOf (widget)->box); } } /* * Draw the widget. */ static void _drawCDKHistogram (CDKOBJS *object, boolean Box) { CDKHISTOGRAM *widget = (CDKHISTOGRAM *)object; chtype battr = 0; chtype bchar = 0; chtype fattr = widget->filler & A_ATTRIBUTES; chtype fchar = CharOf (widget->filler); int histX = TitleLinesOf (widget) + 1; int histY = widget->barSize; int len, x, y; /* Erase the window. */ werase (widget->win); /* Box the widget if asked. */ if (Box) { drawObjBox (widget->win, ObjOf (widget)); } /* Do we have a shadow to draw? */ if (widget->shadowWin != 0) { drawShadow (widget->shadowWin); } drawCdkTitle (widget->win, object); /* If the user asked for labels, draw them in. */ if (widget->viewType != vNONE) { /* Draw in the low label. */ if (widget->lowString != 0) { len = (int)strlen (widget->lowString); writeCharAttrib (widget->win, widget->lowx, widget->lowy, widget->lowString, widget->statsAttr, widget->orient, 0, len); } /* Draw in the current value label. */ if (widget->curString != 0) { len = (int)strlen (widget->curString); writeCharAttrib (widget->win, widget->curx, widget->cury, widget->curString, widget->statsAttr, widget->orient, 0, len); } /* Draw in the high label. */ if (widget->highString != 0) { len = (int)strlen (widget->highString); writeCharAttrib (widget->win, widget->highx, widget->highy, widget->highString, widget->statsAttr, widget->orient, 0, len); } } if (widget->orient == VERTICAL) { histX = widget->boxHeight - widget->barSize - 1; histY = widget->fieldWidth; } /* Draw the histogram bar. */ for (x = histX; x < widget->boxHeight - 1; x++) { for (y = 1; y <= histY; y++) { battr = mvwinch (widget->win, x, y); fchar = battr & A_ATTRIBUTES; bchar = CharOf (battr); if (bchar == ' ') { mvwaddch (widget->win, x, y, widget->filler); } else { mvwaddch (widget->win, x, y, battr | fattr); } } } /* Refresh the window. */ wrefresh (widget->win); } /* * Destroy the widget. */ static void _destroyCDKHistogram (CDKOBJS *object) { if (object != 0) { CDKHISTOGRAM *widget = (CDKHISTOGRAM *)object; freeChar (widget->curString); freeChar (widget->lowString); freeChar (widget->highString); cleanCdkTitle (object); /* Clean up the windows. */ deleteCursesWindow (widget->shadowWin); deleteCursesWindow (widget->win); /* Clean the key bindings. */ cleanCDKObjectBindings (vHISTOGRAM, widget); /* Unregister this object. */ unregisterCDKObject (vHISTOGRAM, widget); } } /* * Erase the widget from the screen. */ static void _eraseCDKHistogram (CDKOBJS *object) { if (validCDKObject (object)) { CDKHISTOGRAM *widget = (CDKHISTOGRAM *)object; eraseCursesWindow (widget->win); eraseCursesWindow (widget->shadowWin); } } dummyInject (Histogram) dummyFocus (Histogram) dummyUnfocus (Histogram) dummyRefreshData (Histogram) dummySaveData (Histogram) cdk-5.0-20060507/include/0000755000175100001440000000000010427502123013156 5ustar tomuserscdk-5.0-20060507/include/template.h0000644000175100001440000001452710114467071015160 0ustar tomusers/* * $Id: template.h,v 1.23 2004/08/30 00:00:57 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKTEMPLATE_H #define CDKTEMPLATE_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 1999-2002,2003 copyright 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. */ /* * Define the CDK cdktemplate widget structure. */ typedef struct STemplate CDKTEMPLATE; typedef void (*TEMPLATECB) (CDKTEMPLATE *cdktemplate, chtype input); struct STemplate { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * shadowWin; WINDOW * labelWin; WINDOW * fieldWin; int titleAdj; chtype * label; chtype * overlay; chtype overlayAttr; char * plate; char * info; int labelLen; int overlayLen; int labelPos; int fieldWidth; int boxWidth; int boxHeight; int platePos; int plateLen; int screenPos; int infoPos; int min; chtype labelAttr; chtype fieldAttr; EExitType exitType; boolean shadow; TEMPLATECB callbackfn; }; /* * This creates a pointer to a new CDK cdktemplate widget. */ CDKTEMPLATE *newCDKTemplate ( CDKSCREEN * /* cdkscreen */, int /* xpos */, int /* ypos */, char * /* title */, char * /* label */, char * /* plate */, char * /* overlay */, boolean /* Box */, boolean /* shadow */); /* * This activates the cdktemplate widget. */ char *activateCDKTemplate ( CDKTEMPLATE * /* cdktemplate */, chtype * /* actions */); /* * This injects a single character into the widget. */ #define injectCDKTemplate(obj,input) injectCDKObject(obj,input,String) /* * This sets various attributes of the widget. */ void setCDKTemplate ( CDKTEMPLATE * /* cdktemplate */, char * /* value */, boolean /* Box */); /* * This sets the value in the cdktemplate widget. */ void setCDKTemplateValue ( CDKTEMPLATE * /* cdktemplate */, char * /* value */); char *getCDKTemplateValue ( CDKTEMPLATE * /* cdktemplate */); /* * This sets the minimum number of characters to enter. */ void setCDKTemplateMin ( CDKTEMPLATE * /* cdktemplate */, int /* min */); int getCDKTemplateMin ( CDKTEMPLATE * /* cdktemplate */); /* * This sets the box attribute of the widget. */ void setCDKTemplateBox ( CDKTEMPLATE * /* cdktemplate */, boolean /* Box */); boolean getCDKTemplateBox ( CDKTEMPLATE * /* cdktemplate */); /* * These set the drawing characters of the widget. */ #define setCDKTemplateULChar(w,c) setULCharOf(w,c) #define setCDKTemplateURChar(w,c) setURCharOf(w,c) #define setCDKTemplateLLChar(w,c) setLLCharOf(w,c) #define setCDKTemplateLRChar(w,c) setLRCharOf(w,c) #define setCDKTemplateVerticalChar(w,c) setVTCharOf(w,c) #define setCDKTemplateHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKTemplateBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKTemplateBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKTemplateBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This draws the cdktemplate on the screen. */ #define drawCDKTemplate(obj,Box) drawCDKObject(obj,Box) /* * This erases the widget from the screen. */ #define eraseCDKTemplate(obj) eraseCDKObject(obj) /* * This erases the cdktemplates contents. */ void cleanCDKTemplate ( CDKTEMPLATE * /* cdktemplate */); /* * This moves the widget to the given location on the screen. */ #define moveCDKTemplate(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This interactively positions the widget on the screen. */ #define positionCDKTemplate(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the widget and all associated memory. */ #define destroyCDKTemplate(obj) destroyCDKObject(obj) /* * This sets the main callback function. */ void setCDKTemplateCB ( CDKTEMPLATE * /* cdktemplate */, TEMPLATECB /* callback */); /* * This returns a character pointer to the contents of the cdktemplate * mixed with the plate. */ char *mixCDKTemplate ( CDKTEMPLATE * /* cdktemplate */); /* * This returns a character pointer to the cdktemplate with the plate * stripped out. */ char *unmixCDKTemplate ( CDKTEMPLATE * /* cdktemplate */, char * /* string */); /* * These set the pre/post callback functions. */ #define setCDKTemplatePreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d) #define setCDKTemplatePostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d) #ifdef __cplusplus } #endif #endif /* CDKTEMPLATE_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/mentry.h0000644000175100001440000001477210114467071014665 0ustar tomusers/* * $Id: mentry.h,v 1.22 2004/08/30 00:00:57 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKMENTRY_H #define CDKMENTRY_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 1999-2002,2003 copyright 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. */ /* * Define the CDK multiple line entry field widget. */ typedef struct SMentry CDKMENTRY; typedef void (*MENTRYCB) (CDKMENTRY *mentry, chtype character); struct SMentry { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * shadowWin; WINDOW * labelWin; WINDOW * fieldWin; int titleAdj; chtype * label; int labelLen; int labelPos; chtype fieldAttr; int fieldWidth; int boxHeight; int boxWidth; char * info; int totalWidth; int rows; int currentRow; int currentCol; int topRow; EDisplayType dispType; int min; int logicalRows; EExitType exitType; boolean shadow; chtype filler; chtype hidden; MENTRYCB callbackfn; }; /* * This creates a new CDK mentry field pointer. */ CDKMENTRY *newCDKMentry ( CDKSCREEN * /* cdkscreen */, int /* xpos */, int /* ypos */, char * /* title */, char * /* label */, chtype /* fieldAttr */, chtype /* filler */, EDisplayType /* disptype */, int /* fieldWidth */, int /* fieldrows */, int /* logicalRows */, int /* min */, boolean /* Box */, boolean /* shadow */); /* * This activates the widget. */ char *activateCDKMentry ( CDKMENTRY * /* mentry */, chtype * /* input */); /* * This injects a single character into the widget. */ #define injectCDKMentry(obj,input) injectCDKObject(obj,input,String) /* * These set specific attributes of the widget. */ void setCDKMentry ( CDKMENTRY * /* mentry */, char * /* value */, int /* min */, boolean /* Box */); /* * This sets the value of the widget. */ void setCDKMentryValue ( CDKMENTRY * /* mentry */, char * /* value */); char *getCDKMentryValue ( CDKMENTRY * /* mentry */); /* * This sets the minimum length of the value for the widget. */ void setCDKMentryMin ( CDKMENTRY * /* mentry */, int /* min */); int getCDKMentryMin ( CDKMENTRY * /* mentry */); /* * This sets the filler character to use when drawing the widget. */ void setCDKMentryFillerChar ( CDKMENTRY * /* mentry */, chtype /* filler */); chtype getCDKMentryFillerChar ( CDKMENTRY * /* mentry */); /* * This sets the character to use when a hidden character type is used. */ void setCDKMentryHiddenChar ( CDKMENTRY * /* mentry */, chtype /* character */); chtype getCDKMentryHiddenChar ( CDKMENTRY * /* mentry */); /* * This sets the box attribute of the mentry widget. */ void setCDKMentryBox ( CDKMENTRY * /* mentry */, boolean /* Box */); boolean getCDKMentryBox ( CDKMENTRY * /* mentry */); /* * These set the drawing characters of the widget. */ #define setCDKMentryULChar(w,c) setULCharOf(w,c) #define setCDKMentryURChar(w,c) setURCharOf(w,c) #define setCDKMentryLLChar(w,c) setLLCharOf(w,c) #define setCDKMentryLRChar(w,c) setLRCharOf(w,c) #define setCDKMentryVerticalChar(w,c) setVTCharOf(w,c) #define setCDKMentryHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKMentryBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKMentryBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKMentryBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This draws the widget on the screen. */ #define drawCDKMentry(obj,Box) drawCDKObject(obj,Box) /* * This erases the widget from the screen. */ #define eraseCDKMentry(obj) eraseCDKObject(obj) /* * This cleans out the information in the widget. */ void cleanCDKMentry ( CDKMENTRY * /* mentry */); /* * This moves the widget to the given location. */ #define moveCDKMentry(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This interactively moves the widget on the screen. */ #define positionCDKMentry(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the widget pointer. */ #define destroyCDKMentry(obj) destroyCDKObject(obj) /* * This draws the field of the widget. */ void drawCDKMentryField ( CDKMENTRY * /* mentry */); /* * This sets the widgets main callback. */ void setCDKMentryCB ( CDKMENTRY * /* mentry */, MENTRYCB /* callback */); /* * These set the pre/post process callback functions. */ #define setCDKMentryPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d) #define setCDKMentryPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d) #ifdef __cplusplus } #endif #endif /* CDKMENTRY_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/button.h0000644000175100001440000001164610114467071014657 0ustar tomusers/* * $Id: button.h,v 1.10 2004/08/30 00:00:57 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKBUTTON_H #define CDKBUTTON_H 1 #include "cdk.h" #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 2002,2003 copyright Thomas E. Dickey * * Copyright 1999, Grant Edwards * 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 Grant Edwards * and contributors. * 4. Neither the name of Grant Edwards, 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 GRANT EDWARDS 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 GRANT EDWARDS 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. */ /* * Declare any definitions you need to make. */ /* * Declare the CDK label structure. */ struct SButton { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * shadowWin; chtype * info; void (*callback)(struct SButton *button); int infoLen; int infoPos; int boxWidth; int boxHeight; int xpos; int ypos; int rows; EExitType exitType; boolean shadow; }; typedef struct SButton CDKBUTTON; typedef void (*tButtonCallback)(struct SButton *button); /* * This creates a new CDK button widget. */ CDKBUTTON *newCDKButton ( CDKSCREEN * /* screen */, int /* xPos */, int /* yPos */, char * /* button text */, tButtonCallback /* callback function */, boolean /* Box */, boolean /* shadow */); /* * This was added to make the builder simpler. All this will * do is call drawCDKLabel. */ int activateCDKButton ( CDKBUTTON * /* button */, chtype * /* actions */); /* * This injects a single character into the widget. */ #define injectCDKButton(obj,input) injectCDKObject(obj,input,Int) /* * This sets multiple attributes of the widget. */ void setCDKButton ( CDKBUTTON * /* button */, char * /* text */, boolean /* Box */); /* * This sets the contents of the label. */ void setCDKButtonMessage ( CDKBUTTON * /* button */, char * /* mesg */); chtype *getCDKButtonMessage ( CDKBUTTON *); /* * This sets the box attribute of the widget. */ void setCDKButtonBox ( CDKBUTTON * /* button */, boolean /* Box */); boolean getCDKButtonBox ( CDKBUTTON * /* button */); /* * This draws the label. */ #define drawCDKButton(obj,Box) drawCDKObject(obj,Box) /* * These set the drawing characters of the widget. */ #define setCDKButtonULChar(w,c) setULCharOf(w,c) #define setCDKButtonURChar(w,c) setURCharOf(w,c) #define setCDKButtonLLChar(w,c) setLLCharOf(w,c) #define setCDKButtonLRChar(w,c) setLRCharOf(w,c) #define setCDKButtonVerticalChar(w,c) setVTCharOf(w,c) #define setCDKButtonHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKButtonBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKButtonBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKButtonBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This erases the button. */ #define eraseCDKButton(obj) eraseCDKObject(obj) /* * This destroys the button and the memory used by it. */ #define destroyCDKButton(obj) destroyCDKObject(obj) /* * This moves the button to a new screen location. */ #define moveCDKButton(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This allows the user to interactively position the button. */ void positionCDKButton (CDKBUTTON *); #endif /* CDKBUTTON_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/config.hin0000644000175100001440000000034007040625663015134 0ustar tomusers/* * $Id: config.hin,v 1.2 2000/01/17 14:48:19 tom Exp $ */ #ifndef CDK_CONFIG_H #define CDK_CONFIG_H 1 @DEFS@ #if !defined(HAVE_LSTAT) && !defined(lstat) #define lstat(f,b) stat(f,b) #endif #endif /* CDK_CONFIG_H */ cdk-5.0-20060507/include/matrix.h0000644000175100001440000001770410114467071014651 0ustar tomusers/* * $Id: matrix.h,v 1.28 2004/08/30 00:00:57 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKMATRIX_H #define CDKMATRIX_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 1999-2003 copyright 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. */ /* * Declare some matrix definitions. */ #define MAX_MATRIX_ROWS 1000 #define MAX_MATRIX_COLS 1000 /* * Define the CDK matrix widget structure. */ typedef struct SMatrix CDKMATRIX; typedef void (*MATRIXCB) (CDKMATRIX *matrix, chtype input); #define CELL_LIMIT MAX_MATRIX_ROWS][MAX_MATRIX_COLS #define NEW_CDKMATRIX 1 #if NEW_CDKMATRIX #define CELL_INDEX(matrix, row,col) (((row) * ((matrix)->cols + 1)) + (col)) #else #define CELL_INDEX(matrix, row,col) (row)][(col) #endif #define MATRIX_CELL(matrix,row,col) ((matrix)->cell[CELL_INDEX(matrix, row, col)]) #define MATRIX_INFO(matrix,row,col) ((matrix)->info[CELL_INDEX(matrix, row, col)]) struct SMatrix { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * shadowWin; #if NEW_CDKMATRIX WINDOW ** cell; char ** info; #else WINDOW * cell[CELL_LIMIT]; char * info[CELL_LIMIT]; #endif int titleAdj; int rows; int cols; int vrows; int vcols; int * colwidths; int * colvalues; chtype ** coltitle; int * coltitleLen; int * coltitlePos; int maxct; chtype ** rowtitle; int * rowtitleLen; int * rowtitlePos; int maxrt; int boxHeight; int boxWidth; int rowSpace; int colSpace; int row; int col; int crow; /* current row */ int ccol; /* current column */ int trow; int lcol; int oldcrow; int oldccol; int oldvrow; int oldvcol; EExitType exitType; boolean boxCell; boolean shadow; chtype highlight; int dominant; chtype filler; MATRIXCB callbackfn; }; /* * This creates a new pointer to a matrix widget. */ CDKMATRIX *newCDKMatrix ( CDKSCREEN * /* cdkscreen */, int /* xpos */, int /* ypos */, int /* rows */, int /* cols */, int /* vrows */, int /* vcols */, char * /* title */, char ** /* rowtitles */, char ** /* coltitles */, int * /* colwidths */, int * /* coltypes */, int /* rowspace */, int /* colspace */, chtype /* filler */, int /* dominantAttrib */, boolean /* boxMatrix */, boolean /* boxCell */, boolean /* shadow */); /* * This activates the matrix. */ int activateCDKMatrix ( CDKMATRIX * /* matrix */, chtype * /* actions */); /* * This injects a single character into the matrix widget. */ #define injectCDKMatrix(obj,input) injectCDKObject(obj,input,Int) /* * This sets the contents of the matrix widget from a fixed-size 2d array. * The predefined array limits are very large. * Use setCDKMatrixCells() instead. */ #define setCDKMatrix(matrix, info, rows, subSize) \ setCDKMatrixCells(matrix, &info[0][0], rows, MAX_MATRIX_COLS, subSize) /* * This sets the contents of the matrix widget from an array defined by the * caller. It may be any size. For compatibility with setCDKMatrix(), the * info[][] array's subscripts start at 1. */ void setCDKMatrixCells ( CDKMATRIX * /* matrix */, char ** /* info */, int /* rows */, int /* cols */, int * /* subSize */); /* * This sets the value of a given cell. */ int setCDKMatrixCell ( CDKMATRIX * /* matrix */, int /* row */, int /* col */, char * /* value */); char *getCDKMatrixCell ( CDKMATRIX * /* matrix */, int /* row */, int /* col */); /* * This returns the row/col of the matrix. */ int getCDKMatrixCol ( CDKMATRIX * /* matrix */); int getCDKMatrixRow ( CDKMATRIX * /* matrix */); /* * These set the drawing characters of the widget. */ #define setCDKMatrixULChar(w,c) setULCharOf(w,c) #define setCDKMatrixURChar(w,c) setURCharOf(w,c) #define setCDKMatrixLLChar(w,c) setLLCharOf(w,c) #define setCDKMatrixLRChar(w,c) setLRCharOf(w,c) #define setCDKMatrixVerticalChar(w,c) setVTCharOf(w,c) #define setCDKMatrixHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKMatrixBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKMatrixBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKMatrixBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This draws the matrix on the screen. */ #define drawCDKMatrix(obj,Box) drawCDKObject(obj,Box) /* * This removes the matrix from the screen. */ #define eraseCDKMatrix(obj) eraseCDKObject(obj) /* * This cleans out all the cells from the matrix. */ void cleanCDKMatrix ( CDKMATRIX * /* matrix */); /* * This cleans one cell in the matrix. */ void cleanCDKMatrixCell ( CDKMATRIX * /* matrix */, int /* row */, int /* col */); /* * This sets the main callback in the matrix. */ void setCDKMatrixCB ( CDKMATRIX * /* matrix */, MATRIXCB /* callback */); /* * This moves the matrix to the given cell. */ int moveToCDKMatrixCell ( CDKMATRIX * /* matrix */, int /* newrow */, int /* newcol */); /* * This sets the box attribute of the matrix widget. */ void setCDKMatrixBox ( CDKMATRIX * /* matrix */, boolean /* Box */); boolean getCDKMatrixBox ( CDKMATRIX * /* matrix */); /* * This moves the matrix on the screen to the given location. */ #define moveCDKMatrix(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This allows the user to interactively position the matrix. */ #define positionCDKMatrix(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the matrix widget and associated memory. */ #define destroyCDKMatrix(obj) destroyCDKObject(obj) /* * This jumps to the given matrix cell. You can pass in * -1 for both the row/col if you want to interactively * pick the cell. */ int jumpToCell ( CDKMATRIX * /* matrix */, int /* row */, int /* col */); /* * These set the pre/post process callback functions. */ #define setCDKMatrixPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d) #define setCDKMatrixPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d) #ifdef __cplusplus } #endif #endif /* CDKMATRIX_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/calendar.h0000644000175100001440000001753010114467071015113 0ustar tomusers/* * $Id: calendar.h,v 1.29 2004/08/30 00:00:57 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKCALENDAR_H #define CDKCALENDAR_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 2000-2002,2003 copyright 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. */ /* * Declare some definitions needed for this widget. */ #define MAX_DAYS 32 /* maximum number of days in any month */ #define MAX_MONTHS 13 /* month[0] is unused */ #define MAX_YEARS 140 /* years [1901..2140] */ #define CALENDAR_LIMIT (MAX_DAYS * MAX_MONTHS * MAX_YEARS) #define CALENDAR_INDEX(d,m,y) ((((y) * MAX_MONTHS) + (m)) * MAX_DAYS + (d)) #define CALENDAR_CELL(c,d,m,y) ((c)->marker[CALENDAR_INDEX(d,m,y)]) /* * Define the CDK calendar widget structure. */ struct SCalendar { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * labelWin; WINDOW * fieldWin; WINDOW * shadowWin; int titleAdj; int xpos; int ypos; int height; int width; int fieldWidth; int labelLen; chtype yearAttrib; chtype monthAttrib; chtype dayAttrib; chtype highlight; chtype * marker; int day; int month; int year; int weekDay; int boxWidth; int boxHeight; int xOffset; EExitType exitType; boolean shadow; char * DayName; char * MonthName[MAX_MONTHS]; }; typedef struct SCalendar CDKCALENDAR; /* * This creates a pointer to a new calendar widget. */ CDKCALENDAR *newCDKCalendar ( CDKSCREEN * /* screen */, int /* xPos */, int /* yPos */, char * /* title */, int /* day */, int /* month */, int /* year */, chtype /* dayAttrib */, chtype /* monthAttrib */, chtype /* yearAttrib */, chtype /* highlight */, boolean /* Box */, boolean /* shadow */); /* * This activates the calendar widget. */ time_t activateCDKCalendar ( CDKCALENDAR * /* calendar */, chtype * /* actions */); /* * This injects a single character into the widget. */ #define injectCDKCalendar(obj,input) injectCDKObject(obj,input,Int) /* * This sets multiple attributes of the widget. */ void setCDKCalendar ( CDKCALENDAR * /* calendar */, int /* day */, int /* month */, int /* year */, chtype /* dayAttrib */, chtype /* monthAttrib */, chtype /* yearAttrib */, chtype /* highlight */, boolean /* Box */); /* * This sets the date of the calendar. */ void setCDKCalendarDate ( CDKCALENDAR * /* calendar */, int /* day */, int /* month */, int /* year */); void getCDKCalendarDate ( CDKCALENDAR * /* calendar */, int * /* day */, int * /* month */, int * /* year */); /* * This sets the attribute of the days in the calendar. */ void setCDKCalendarDayAttribute ( CDKCALENDAR * /* calendar */, chtype /* attribute */); chtype getCDKCalendarDayAttribute ( CDKCALENDAR * /* calendar */); /* * This sets the attribute of the month names in the calendar. */ void setCDKCalendarMonthAttribute ( CDKCALENDAR * /* calendar */, chtype /* attribute */); chtype getCDKCalendarMonthAttribute ( CDKCALENDAR * /* calendar */); /* * This sets the attribute of the year in the calendar. */ void setCDKCalendarYearAttribute ( CDKCALENDAR * /* calendar */, chtype /* attribute */); chtype getCDKCalendarYearAttribute ( CDKCALENDAR * /* calendar */); /* * This sets the attribute of the highlight bar. */ void setCDKCalendarHighlight ( CDKCALENDAR * /* calendar */, chtype /* highlight */); chtype getCDKCalendarHighlight ( CDKCALENDAR * /* calendar */); /* * This sets the box attribute of the widget. */ void setCDKCalendarBox ( CDKCALENDAR * /* calendar */, boolean /* Box */); boolean getCDKCalendarBox ( CDKCALENDAR * /* calendar */); /* * These set the drawing characters of the widget. */ #define setCDKCalendarULChar(w,c) setULCharOf(w,c) #define setCDKCalendarURChar(w,c) setURCharOf(w,c) #define setCDKCalendarLLChar(w,c) setLLCharOf(w,c) #define setCDKCalendarLRChar(w,c) setLRCharOf(w,c) #define setCDKCalendarVerticalChar(w,c) setVTCharOf(w,c) #define setCDKCalendarHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKCalendarBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKCalendarBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKCalendarBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This sets a marker on the calendar. */ void setCDKCalendarMarker ( CDKCALENDAR * /* calendar */, int /* day */, int /* month */, int /* year */, chtype /* markerChar */); /* * Return the marker set on the calendar. */ chtype getCDKCalendarMarker ( CDKCALENDAR * /* calendar */, int /* day */, int /* month */, int /* year */); /* * This removes a marker from the calendar. */ void removeCDKCalendarMarker ( CDKCALENDAR * /* calendar */, int /* day */, int /* month */, int /* year */); /* * This draws the widget on the screen. */ #define drawCDKCalendar(obj,box) drawCDKObject(obj,box) /* * This removes the widget from the screen. */ #define eraseCDKCalendar(obj) eraseCDKObject(obj) /* * This moves the widget to the given location. */ #define moveCDKCalendar(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This is an interactive method of moving the widget. */ #define positionCDKCalendar(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the calendar widget and all associated memory. */ #define destroyCDKCalendar(obj) destroyCDKObject(obj) /* * This sets the pre and post process functions. */ #define setCDKCalendarPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d) #define setCDKCalendarPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d) /* * This sets days and months names */ void setCDKCalendarMonthsNames ( CDKCALENDAR * /* calendar */, char ** /* months */); void setCDKCalendarDaysNames ( CDKCALENDAR * /* calendar */, char * /* days - 1st is Sunday */); #ifdef __cplusplus } #endif #endif /* CDKCALENDAR_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/viewer.h0000644000175100001440000001417610114467071014646 0ustar tomusers/* * $Id: viewer.h,v 1.21 2004/08/30 00:00:57 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKVIEWER_H #define CDKVIEWER_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 1999-2003 copyright 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. */ /* * Define the CDK viewer widget structure. */ struct SViewer { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * shadowWin; chtype ** button; int * buttonLen; int * buttonPos; int buttonCount; chtype buttonHighlight; chtype ** list; int * listLen; int * listPos; int titleAdj; int listSize; int boxHeight; int boxWidth; int viewSize; int currentTop; int currentButton; int leftChar; int length; int maxLeftChar; int maxTopLine; int widestLine; long characters; boolean inProgress; boolean showLineInfo; boolean interpret; EExitType exitType; boolean shadow; }; typedef struct SViewer CDKVIEWER; /* * This creates a pointer to a new CDK viewer widget. */ CDKVIEWER *newCDKViewer ( CDKSCREEN * /* cdkscreen */, int /* xpos */, int /* ypos */, int /* height */, int /* width */, char ** /* buttons */, int /* buttonCount */, chtype /* buttonHighlight */, boolean /* Box */, boolean /* shadow */); /* * This activates the viewer widget. */ int activateCDKViewer ( CDKVIEWER * /* viewer */, chtype * /* actions */); /* * This sets various attributes of the viewer widget. */ int setCDKViewer ( CDKVIEWER * /* viewer */, char * /* title */, char ** /* info */, int /* infoSize */, chtype /* buttonHighlight */, boolean /* interpret */, boolean /* showLineInfo */, boolean /* Box */); /* * This sets the contents of the viewer widget. */ int setCDKViewerInfo ( CDKVIEWER * /* viewer */, char ** /* info */, int /* infoSize */, boolean /* interpret */); chtype **getCDKViewerInfo ( CDKVIEWER * /* viewer */, int * /* size */); /* * This sets the title of the viewer widget. */ void setCDKViewerTitle ( CDKVIEWER * /* viewer */, char * /* title */); chtype **getCDKViewerTitle ( CDKVIEWER * /* viewer */); /* * This sets the highlight bar attribute. */ void setCDKViewerHighlight ( CDKVIEWER * /* viewer */, chtype /* buttonHighlight */); chtype getCDKViewerHighlight ( CDKVIEWER * /* viewer */); /* * This sets the boolean flag dictating whether a information line * will be displayed in the top left corner of the viewer. */ void setCDKViewerInfoLine ( CDKVIEWER * /* viewer */, boolean /* showLineInfo */); boolean getCDKViewerInfoLine ( CDKVIEWER * /* viewer */); /* * This sets the box attribute of the widget. */ void setCDKViewerBox ( CDKVIEWER * /* viewer */, boolean /* Box */); boolean getCDKViewerBox ( CDKVIEWER * /* viewer */); /* * These set the drawing characters of the widget. */ #define setCDKViewerULChar(w,c) setULCharOf(w,c) #define setCDKViewerURChar(w,c) setURCharOf(w,c) #define setCDKViewerLLChar(w,c) setLLCharOf(w,c) #define setCDKViewerLRChar(w,c) setLRCharOf(w,c) #define setCDKViewerVerticalChar(w,c) setVTCharOf(w,c) #define setCDKViewerHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKViewerBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKViewerBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKViewerBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This draws the viewer field on the screen. */ #define drawCDKViewer(obj,box) drawCDKObject(obj,box) /* * This erases the widget from the screen. */ #define eraseCDKViewer(obj) eraseCDKObject(obj) /* * This cleans out all of the information from the viewer. */ void cleanCDKViewer ( CDKVIEWER * /* viewer */); /* * This moves the widget to the given location. */ #define moveCDKViewer(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This is an interactive method of moving the widget. */ #define positionCDKViewer(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the widget and all the memory associated with the widget. */ #define destroyCDKViewer(obj) destroyCDKObject(obj) #ifdef __cplusplus } #endif #endif /* CDKVIEWER_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/cdk_version.hin0000644000175100001440000000065307516127074016205 0ustar tomusers/* * $Id: cdk_version.hin,v 1.1 2002/07/20 00:26:36 tom Exp $ */ #ifndef CDK_VERSION_H #define CDK_VERSION_H #ifdef __cplusplus extern "C" { #endif #define CDK_VERSION_MAJOR "@VERSION_MAJOR@" #define CDK_VERSION_MINOR "@VERSION_MINOR@" #define CDK_VERSION_PATCH "@VERSION_PATCH@" /* * Runtime to return the same version information. */ char * CDKVersion (void); #ifdef __cplusplus } #endif #endif /* CDK_VERSION_H */ cdk-5.0-20060507/include/marquee.h0000644000175100001440000001065010114467071014775 0ustar tomusers/* * $Id: marquee.h,v 1.18 2004/08/30 00:00:57 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKMARQUEE_H #define CDKMARQUEE_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 1999-2002,2003 copyright 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. */ /* * Define the CDK marquee widget structure. */ struct SMarquee { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * shadowWin; int active; int width; int boxWidth; int boxHeight; boolean shadow; }; typedef struct SMarquee CDKMARQUEE; /* * This creates a new marquee widget pointer. */ CDKMARQUEE *newCDKMarquee ( CDKSCREEN * /* cdkscreen */, int /* xpos */, int /* ypos */, int /* width */, boolean /* Box */, boolean /* shadow */); /* * This turns the marquee 'on'. */ int activateCDKMarquee ( CDKMARQUEE * /* marquee */, char * /* message */, int /* delay */, int /* repeat */, boolean /* Box */); /* * This turns 'off' the marquee. */ void deactivateCDKMarquee ( CDKMARQUEE * /* marquee */); /* * This draws the marquee on the screen. */ #define drawCDKMarquee(obj,Box) drawCDKObject(obj,Box) /* * This removes the widget from the screen. */ #define eraseCDKMarquee(obj) eraseCDKObject(obj) /* * This moves the widget to the given location. */ #define moveCDKMarquee(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This interactively positions the widget on the screen. */ #define positionCDKMarquee(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the marquee widget. */ #define destroyCDKMarquee(obj) destroyCDKObject(obj) /* * These set the drawing characters of the widget. */ #define setCDKMarqueeULChar(w,c) setULCharOf(w,c) #define setCDKMarqueeURChar(w,c) setURCharOf(w,c) #define setCDKMarqueeLLChar(w,c) setLLCharOf(w,c) #define setCDKMarqueeLRChar(w,c) setLRCharOf(w,c) #define setCDKMarqueeVerticalChar(w,c) setVTCharOf(w,c) #define setCDKMarqueeHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKMarqueeBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the box attribute of the widget. */ void setCDKMarqueeBox ( CDKMARQUEE * /* marquee */, boolean /* Box */); boolean getCDKMarqueeBox ( CDKMARQUEE * /* marquee */); /* * This sets the background color of the widget. */ #define setCDKMarqueeBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKMarqueeBackgroundAttrib(w,c) setBKAttrOf(w,c) #ifdef __cplusplus } #endif #endif /* CDKMARQUEE_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/itemlist.h0000644000175100001440000001401710114467071015171 0ustar tomusers/* * $Id: itemlist.h,v 1.23 2004/08/30 00:00:57 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKITEMLIST_H #define CDKITEMLIST_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 1999-2003 copyright 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. */ /* * Define the CDK itemlist widget structure. */ struct SItemList { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * shadowWin; WINDOW * labelWin; WINDOW * fieldWin; int titleAdj; chtype * label; int labelLen; int fieldWidth; chtype ** item; int * itemPos; int * itemLen; int listSize; int currentItem; int defaultItem; int boxWidth; int boxHeight; EExitType exitType; boolean shadow; }; typedef struct SItemList CDKITEMLIST; /* * This creates a pointer to a CDK itemlist widget. */ CDKITEMLIST *newCDKItemlist ( CDKSCREEN * /* cdkscreen */, int /* xpos */, int /* ypos */, char * /* title */, char * /* label */, char ** /* itemlist */, int /* count */, int /* defaultItem */, boolean /* Box */, boolean /* shadow */); /* * This activates the itemlist widget. */ int activateCDKItemlist ( CDKITEMLIST * /* itemlist */, chtype * /* actions */); /* * This injects a single character into the itemlist widget. */ #define injectCDKItemlist(obj,input) injectCDKObject(obj,input,Int) /* * These functions set specific elements of the itemlist widget. */ void setCDKItemlist ( CDKITEMLIST * /* itemlist */, char ** /* list */, int /* count */, int /* current */, boolean /* Box */); /* * This function sets the values of the item list widget. */ void setCDKItemlistValues ( CDKITEMLIST * /* itemlist */, char ** /* list */, int /* count */, int /* defaultItem */); chtype **getCDKItemlistValues ( CDKITEMLIST * /* itemlist */, int * /* size */); /* * This sets the default item in the list. */ void setCDKItemlistDefaultItem ( CDKITEMLIST * /* itemlist */, int /* defaultItem */); int getCDKItemlistDefaultItem ( CDKITEMLIST * /* itemlist */); /* * This returns an index to the current item in the list. */ void setCDKItemlistCurrentItem ( CDKITEMLIST * /* itemlist */, int /* currentItem */); int getCDKItemlistCurrentItem ( CDKITEMLIST * /* itemlist */); /* * This sets the box attribute of the widget. */ void setCDKItemlistBox ( CDKITEMLIST * /* itemlist */, boolean /* Box */); boolean getCDKItemlistBox ( CDKITEMLIST * /* itemlist */); /* * These set the drawing characters of the widget. */ #define setCDKItemlistULChar(w,c) setULCharOf(w,c) #define setCDKItemlistURChar(w,c) setURCharOf(w,c) #define setCDKItemlistLLChar(w,c) setLLCharOf(w,c) #define setCDKItemlistLRChar(w,c) setLRCharOf(w,c) #define setCDKItemlistVerticalChar(w,c) setVTCharOf(w,c) #define setCDKItemlistHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKItemlistBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKItemlistBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKItemlistBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This draws the itemlist widget. */ #define drawCDKItemlist(obj,Box) drawCDKObject(obj,Box) /* * This draws the itemlist field. */ void drawCDKItemlistField ( CDKITEMLIST * /* itemlist */, boolean /* highlight */); /* * This removes the widget from the screen. */ #define eraseCDKItemlist(obj) eraseCDKObject(obj) /* * This moves the widget to the given position. */ #define moveCDKItemlist(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This allows the user to interactively move the widget. */ #define positionCDKItemlist(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the widget and all the associated memory. */ #define destroyCDKItemlist(obj) destroyCDKObject(obj) /* * These functions set the pre/post process functions. */ #define setCDKItemlistPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d) #define setCDKItemlistPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d) #ifdef __cplusplus } #endif #endif /* CDKITEMLIST_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/graph.h0000644000175100001440000001355510114467071014446 0ustar tomusers/* * $Id: graph.h,v 1.21 2004/08/30 00:00:57 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKGRAPH_H #define CDKGRAPH_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 2000-2002,2003 copyright 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. */ /* * Define the CDK graph structure. */ struct SGraph { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * shadowWin; int titleAdj; chtype * graphChar; boolean shadow; int boxHeight; int boxWidth; chtype * xtitle; int xtitlePos; int xtitleLen; int * values; int count; int minx; int maxx; int xscale; int txpos; chtype * ytitle; int ytitlePos; int ytitleLen; int yscale; int typos; EGraphDisplayType displayType; }; typedef struct SGraph CDKGRAPH; /* * This creates a new CDK graph pointer. */ CDKGRAPH *newCDKGraph ( CDKSCREEN * /* cdkscreen */, int /* xpos */, int /* ypos */, int /* height */, int /* width */, char * /* title */, char * /* xtitle */, char * /* ytitle */); /* * This was added to make the builder simpler. All this will * do is call drawCDKGraph. */ void activateCDKGraph ( CDKGRAPH * /* graph */, chtype * /* actions */); /* * This sets multiple attributes of the widget. */ int setCDKGraph ( CDKGRAPH * /* graph */, int * /* values */, int /* count */, char * /* graphChar */, boolean /* startAtZero */, EGraphDisplayType /* displayType */); /* * This sets the values of the graph widget. */ int setCDKGraphValues ( CDKGRAPH * /* graph */, int * /* values */, int /* count */, boolean /* startAtZero */); int setCDKGraphValue ( CDKGRAPH * /* graph */, int /* index */, int /* value */, boolean /* startAtZero */); int *getCDKGraphValues ( CDKGRAPH * /* graph */, int * /* size */); int getCDKGraphValue ( CDKGRAPH * /* graph */, int /* index */); /* * This sets the characters of the graph widget. */ int setCDKGraphCharacters ( CDKGRAPH * /* graph */, char * /* characters */); int setCDKGraphCharacter ( CDKGRAPH * /* graph */, int /* index */, char * /* character */); chtype *getCDKGraphCharacters ( CDKGRAPH * /* graph */); chtype getCDKGraphCharacter ( CDKGRAPH * /* graph */, int /* index */); /* * This sets the display type of the graph. */ void setCDKGraphDisplayType ( CDKGRAPH * /* graph */, EGraphDisplayType /* type */); EGraphDisplayType getCDKGraphDisplayType ( CDKGRAPH * /* graph */); /* * This sets the box attribute of the widget. */ void setCDKGraphBox ( CDKGRAPH * /* graph */, boolean /* Box */); boolean getCDKGraphBox ( CDKGRAPH * /* graph */); /* * These set the drawing characters of the widget. */ #define setCDKGraphULChar(w,c) setULCharOf(w,c) #define setCDKGraphURChar(w,c) setURCharOf(w,c) #define setCDKGraphLLChar(w,c) setLLCharOf(w,c) #define setCDKGraphLRChar(w,c) setLRCharOf(w,c) #define setCDKGraphVerticalChar(w,c) setVTCharOf(w,c) #define setCDKGraphHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKGraphBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKGraphBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKGraphBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This draws the graph on the screen. */ #define drawCDKGraph(obj,Box) drawCDKObject(obj,Box) /* * This removes the graph from the screen. */ #define eraseCDKGraph(obj) eraseCDKObject(obj) /* * This moves the widget to the given location. */ #define moveCDKGraph(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This allows the user to interactively move the widget. */ #define positionCDKGraph(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the graph and all the associated memory. */ #define destroyCDKGraph(obj) destroyCDKObject(obj) #ifdef __cplusplus } #endif #endif /* CDKGRAPH_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/swindow.h0000644000175100001440000001522010114467071015026 0ustar tomusers/* * $Id: swindow.h,v 1.23 2004/08/30 00:00:57 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKSWINDOW_H #define CDKSWINDOW_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 1999-2003 copyright 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. */ /* * Define the CDK scrolling window widget structure. */ struct SSwindow { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * fieldWin; WINDOW * shadowWin; chtype ** list; int * listPos; int * listLen; int titleAdj; int listSize; int boxHeight; int boxWidth; int viewSize; int maxTopLine; int currentTop; int leftChar; int maxLeftChar; int widestLine; int saveLines; EExitType exitType; boolean shadow; }; typedef struct SSwindow CDKSWINDOW; typedef void (*SWINDOWCB) (CDKSWINDOW *swindow, chtype input); /* * This creates a new pointer to a scrolling window widget. */ CDKSWINDOW *newCDKSwindow ( CDKSCREEN * /* cdkscreen */, int /* xpos */, int /* ypos */, int /* height */, int /* width */, char * /* title */, int /* saveLines */, boolean /* Box */, boolean /* shadow */); /* * This activates the scrolling window. */ void activateCDKSwindow ( CDKSWINDOW * /* swindow */, chtype * /* actions */); /* * This injects a single character into the scrolling window. */ #define injectCDKSwindow(obj,input) injectCDKObject(obj,input,Int) /* * This executes the given command and puts the output of the * command into the scrolling window. */ int execCDKSwindow ( CDKSWINDOW * /* swindow */, char * /* command */, int /* insertPos */); /* * This dumps the contents of the scrolling window to the given filename. */ int dumpCDKSwindow ( CDKSWINDOW * /* swindow */, char * /* filename */); /* * This jumps to the given line in the window. */ void jumpToLineCDKSwindow ( CDKSWINDOW * /* swindow */, int /* line */); /* * This saves the contents of the scrolling window via an * interactive window. */ void saveCDKSwindowInformation ( CDKSWINDOW * /* swindow */); /* * This loads the window up with information from a filename * interactively provided. */ void loadCDKSwindowInformation ( CDKSWINDOW * /* swindow */); /* * These functions set the attributes of the scrolling window. */ void setCDKSwindow ( CDKSWINDOW * /* swindow */, char ** /* info */, int /* lines */, boolean /* Box */); /* * This sets the contents of the scrolling window. */ void setCDKSwindowContents ( CDKSWINDOW * /* swindow */, char ** /* info */, int /* lines */); chtype **getCDKSwindowContents ( CDKSWINDOW * /* swindow */, int * /* size */); /* * This sets the box attribute of the scrolling window. */ void setCDKSwindowBox ( CDKSWINDOW * /* swindow */, boolean /* Box */); boolean getCDKSwindowBox ( CDKSWINDOW * /* swindow */); /* * These set the drawing characters of the widget. */ #define setCDKSwindowULChar(w,c) setULCharOf(w,c) #define setCDKSwindowURChar(w,c) setURCharOf(w,c) #define setCDKSwindowLLChar(w,c) setLLCharOf(w,c) #define setCDKSwindowLRChar(w,c) setLRCharOf(w,c) #define setCDKSwindowVerticalChar(w,c) setVTCharOf(w,c) #define setCDKSwindowHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKSwindowBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKSwindowBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKSwindowBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This draws the scrolling window on the screen. */ #define drawCDKSwindow(obj,Box) drawCDKObject(obj,Box) /* * This removes the widget from the screen. */ #define eraseCDKSwindow(obj) eraseCDKObject(obj) /* * This cleans out all of the information from the window. */ void cleanCDKSwindow ( CDKSWINDOW * /* swindow */); /* * This adds a line to the window. */ void addCDKSwindow ( CDKSWINDOW * /* swindow */, char * /* info */, int /* insertPos */); /* * This trims lines from the window. */ void trimCDKSwindow ( CDKSWINDOW * /* swindow */, int /* start */, int /* finish */); /* * This moves the window to the given location. */ #define moveCDKSwindow(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This interactively positions the widget on the screen. */ #define positionCDKSwindow(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the widget and all associated memory. */ #define destroyCDKSwindow(obj) destroyCDKObject(obj) /* * These set the pre/post process callback functions. */ #define setCDKSwindowPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d) #define setCDKSwindowPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d) #ifdef __cplusplus } #endif #endif /* CDKSWINDOW_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/label.h0000644000175100001440000001171410114467071014417 0ustar tomusers/* * $Id: label.h,v 1.18 2004/08/30 00:00:57 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKLABEL_H #define CDKLABEL_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 2000-2002,2003 copyright 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. */ /* * Declare any definitions you need to make. */ #define MAX_LABEL_ROWS 300 /* unused by widgets */ /* * Declare the CDK label structure. */ struct SLabel { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * shadowWin; chtype ** info; int * infoLen; int * infoPos; int boxWidth; int boxHeight; int xpos; int ypos; int rows; boolean shadow; }; typedef struct SLabel CDKLABEL; /* * This creates a new CDK label widget. */ CDKLABEL *newCDKLabel ( CDKSCREEN * /* screen */, int /* xPos */, int /* yPos */, char ** /* mesg */, int /* rows */, boolean /* Box */, boolean /* shadow */); /* * This was added to make the builder simpler. All this will * do is call drawCDKLabel. */ void activateCDKLabel ( CDKLABEL * /* label */, chtype * /* actions */); /* * This sets multiple attributes of the widget. */ void setCDKLabel ( CDKLABEL * /* label */, char ** /* message */, int /* lines */, boolean /* Box */); /* * This sets the contents of the label. */ void setCDKLabelMessage ( CDKLABEL * /* label */, char ** /* mesg */, int /* lines */); chtype **getCDKLabelMessage ( CDKLABEL * /* label */, int * /* size */); /* * This sets the box attribute of the widget. */ void setCDKLabelBox ( CDKLABEL * /* label */, boolean /* Box */); boolean getCDKLabelBox ( CDKLABEL * /* label */); /* * This draws the label. */ #define drawCDKLabel(obj,Box) drawCDKObject(obj,Box) /* * These set the drawing characters of the widget. */ #define setCDKLabelULChar(w,c) setULCharOf(w,c) #define setCDKLabelURChar(w,c) setURCharOf(w,c) #define setCDKLabelLLChar(w,c) setLLCharOf(w,c) #define setCDKLabelLRChar(w,c) setLRCharOf(w,c) #define setCDKLabelVerticalChar(w,c) setVTCharOf(w,c) #define setCDKLabelHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKLabelBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKLabelBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKLabelBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This erases the label. */ #define eraseCDKLabel(obj) eraseCDKObject(obj) /* * This destroys the label and the memory used by it. */ #define destroyCDKLabel(obj) destroyCDKObject(obj) /* * This draws the label then waits for the user to press * the key defined by the 'key' parameter. */ char waitCDKLabel ( CDKLABEL * /* label */, char /* key */); /* * This moves the label. */ #define moveCDKLabel(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This allows the user to interactively position the label. */ #define positionCDKLabel(widget) positionCDKObject(ObjOf(widget),widget->win) #ifdef __cplusplus } #endif #endif /* CDKLABEL_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/histogram.h0000644000175100001440000001474010114467071015337 0ustar tomusers/* * $Id: histogram.h,v 1.18 2004/08/30 00:00:57 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKHISTOGRAM_H #define CDKHISTOGRAM_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 1999-2002,2003 copyright 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. */ /* * Declare the histogram structure. */ struct SHistogram { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * shadowWin; int titleAdj; char * curString; char * lowString; char * highString; chtype filler; float percent; int fieldHeight; int fieldWidth; int barSize; int orient; int statsPos; chtype statsAttr; EHistogramDisplayType viewType; int high; int low; int value; int lowx; int lowy; int curx; int cury; int highx; int highy; int boxWidth; int boxHeight; boolean shadow; }; typedef struct SHistogram CDKHISTOGRAM; /* * This returns a new pointer to a histogram pointer. */ CDKHISTOGRAM *newCDKHistogram ( CDKSCREEN * /* cdkscreen */, int /* xpos */, int /* ypos */, int /* height */, int /* width */, int /* orient */, char * /* title */, boolean /* Box */, boolean /* shadow */); /* * This was added to make the build simpler. All this will * do is call drawCDKHistogram. */ void activateCDKHistogram ( CDKHISTOGRAM * /* histogram */, chtype * /* actions */); /* * These set specific attributes of the histogram. */ void setCDKHistogram ( CDKHISTOGRAM * /* histogram */, EHistogramDisplayType /* viewtype */, int /* statsPos */, chtype /* statsAttr */, int /* low */, int /* high */, int /* value */, chtype /* filler */, boolean /* Box */); /* * This sets the low/high/current value of the histogram. */ void setCDKHistogramValue ( CDKHISTOGRAM * /* histogram */, int /* low */, int /* high */, int /* value */); int getCDKHistogramValue ( CDKHISTOGRAM * /* histogram */); int getCDKHistogramLowValue ( CDKHISTOGRAM * /* histogram */); int getCDKHistogramHighValue ( CDKHISTOGRAM * /* histogram */); /* * This sets the view type of the histogram. */ void setCDKHistogramDisplayType ( CDKHISTOGRAM * /* histogram */, EHistogramDisplayType /* viewtype */); EHistogramDisplayType getCDKHistogramViewType ( CDKHISTOGRAM * /* histogram */); /* * This returns the filler character used to draw the histogram. */ void setCDKHistogramFillerChar ( CDKHISTOGRAM * /* histogram */, chtype /* character */); chtype getCDKHistogramFillerChar ( CDKHISTOGRAM * /* histogram */); /* * This states where the statistics value is to be located on the histogram. */ void setCDKHistogramStatsPos ( CDKHISTOGRAM * /* histogram */, int /* statsPos */); int getCDKHistogramStatsPos ( CDKHISTOGRAM * /* histogram */); /* * This sets the attribute of the statistics. */ void setCDKHistogramStatsAttr ( CDKHISTOGRAM * /* histogram */, chtype /* statsAttr */); chtype getCDKHistogramStatsAttr ( CDKHISTOGRAM * /* histogram */); /* * This sets the box attribute of the widget. */ void setCDKHistogramBox ( CDKHISTOGRAM * /* histogram */, boolean /* Box */); boolean getCDKHistogramBox ( CDKHISTOGRAM * /* histogram */); /* * These set the drawing characters of the widget. */ #define setCDKHistogramULChar(w,c) setULCharOf(w,c) #define setCDKHistogramURChar(w,c) setURCharOf(w,c) #define setCDKHistogramLLChar(w,c) setLLCharOf(w,c) #define setCDKHistogramLRChar(w,c) setLRCharOf(w,c) #define setCDKHistogramVerticalChar(w,c) setVTCharOf(w,c) #define setCDKHistogramHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKHistogramBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKHistogramBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKHistogramBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This draws the widget on the screen. */ #define drawCDKHistogram(obj,Box) drawCDKObject(obj,Box) /* * This removes the widget from the screen. */ #define eraseCDKHistogram(obj) eraseCDKObject(obj) /* * This moves the widget to the given location. */ #define moveCDKHistogram(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This allows the user to interactively position the widget on the screen. */ #define positionCDKHistogram(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the histogram and all related pointers. */ #define destroyCDKHistogram(obj) destroyCDKObject(obj) #ifdef __cplusplus } #endif #endif /* CDKHISTOGRAM_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/cdk_compat.h0000644000175100001440000000621610354603611015443 0ustar tomusers/* * $Id: cdk_compat.h,v 1.2 2005/12/28 21:45:45 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDK_COMPAT_H #define CDK_COMPAT_H #ifdef __cplusplus extern "C" { #endif /* * Copyright 2004,2005 Thomas E. Dickey * 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 Thomas Dickey * and contributors. * 4. Neither the name of Thomas Dickey, 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 THOMAS DICKEY 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 THOMAS DICKEY 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. */ /* * Renaming of struct members was done for consistency. Making old/new * versions compatible with renaming is awkward (there may be inadvertant * naming collisions), but this is mainly for demonstration purposes. */ #define info list #define infoSize listSize #define itemCount listSize #define boxMatrix box /* * Include the Cdk header file, which includes everything except for this file. */ #include /* * This is defined via the new header file: */ #ifdef CDK_VERSION_PATCH /* * If we included the new Cdk header file, provide definitions for things * which have been made obsolete. */ #define MAX_LINES 5000 #define WIN_WIDTH(a) getmaxx(a) #define WIN_HEIGHT(a) getmaxy(a) #define WIN_XPOS(a) getbegx(a) #define WIN_YPOS(a) getbegy(a) extern int getDirectoryContents (char *directory, char **list, int maxListSize); extern int readFile (char *filename, char **info, int maxlines); extern int splitString (char *string, char **items, char splitChar); #else /* * Provide definitions to allow the applications using the old header to * compile using the new header's macros: */ #define ObjOf(a) (a) #define ScreenOf(a) (a) #endif /* CDK_VERSION_PATCH */ #ifdef __cplusplus } #endif #endif /* CDK_COMPAT_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/entry.h0000644000175100001440000001530310114467071014477 0ustar tomusers/* * $Id: entry.h,v 1.24 2004/08/30 00:00:57 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKENTRY_H #define CDKENTRY_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 1999-2002,2003 copyright 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. */ /* * Define the CDK entry widget structure. */ typedef struct SEntry CDKENTRY; typedef void (*ENTRYCB) (struct SEntry *entry, chtype character); struct SEntry { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * shadowWin; WINDOW * labelWin; WINDOW * fieldWin; chtype * label; int labelLen; int titleAdj; chtype fieldAttr; int fieldWidth; char * info; int infoWidth; int screenCol; int leftChar; int min; int max; int boxWidth; int boxHeight; EExitType exitType; EDisplayType dispType; boolean shadow; chtype filler; chtype hidden; ENTRYCB callbackfn; }; /* * This creates a pointer to a new CDK entry widget. */ CDKENTRY *newCDKEntry ( CDKSCREEN * /* cdkscreen */, int /* xpos */, int /* ypos */, char * /* title */, char * /* label */, chtype /* fieldAttrib */, chtype /* filler */, EDisplayType /* disptype */, int /* fieldWidth */, int /* min */, int /* max */, boolean /* Box */, boolean /* shadow */); /* * This activates the entry widget. */ char *activateCDKEntry ( CDKENTRY * /* entry */, chtype * /* actions */); /* * This injects a single character into the widget. */ #define injectCDKEntry(obj,input) injectCDKObject(obj,input,String) /* * This sets various attributes of the entry field. */ void setCDKEntry ( CDKENTRY * /* entry */, char * /* value */, int /* min */, int /* max */, boolean /* Box */); /* * This sets the value of the entry field. */ void setCDKEntryValue ( CDKENTRY * /* entry */, char * /* value */); char *getCDKEntryValue ( CDKENTRY * /* entry */); /* * This sets the maximum length of a string allowable for * the given widget. */ void setCDKEntryMax ( CDKENTRY * /* entry */, int /* max */); int getCDKEntryMax ( CDKENTRY * /* entry */); /* * This sets the minimum length of a string allowable for * the given widget. */ void setCDKEntryMin ( CDKENTRY * /* entry */, int /* min */); int getCDKEntryMin ( CDKENTRY * /* entry */); /* * This sets the filler character of the entry field. */ void setCDKEntryFillerChar ( CDKENTRY * /* entry */, chtype /* fillerCharacter */); chtype getCDKEntryFillerChar ( CDKENTRY * /* entry */); /* * This sets the character to use when a hidden type is used. */ void setCDKEntryHiddenChar ( CDKENTRY * /* entry */, chtype /* hiddenCharacter */); chtype getCDKEntryHiddenChar ( CDKENTRY * /* entry */); /* * This sets the box attribute of the widget. */ void setCDKEntryBox ( CDKENTRY * /* entry */, boolean /* Box */); boolean getCDKEntryBox ( CDKENTRY * /* entry */); /* * These set the drawing characters of the widget. */ #define setCDKEntryULChar(w,c) setULCharOf(w,c) #define setCDKEntryURChar(w,c) setURCharOf(w,c) #define setCDKEntryLLChar(w,c) setLLCharOf(w,c) #define setCDKEntryLRChar(w,c) setLRCharOf(w,c) #define setCDKEntryVerticalChar(w,c) setVTCharOf(w,c) #define setCDKEntryHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKEntryBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKEntryBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKEntryBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This sets the attribute of the entry field. */ void setCDKEntryHighlight ( CDKENTRY * /* entry */, chtype /* highlight */, boolean /* cursor */); /* * This draws the entry field. */ #define drawCDKEntry(obj,box) drawCDKObject(obj,box) /* * This erases the widget from the screen. */ #define eraseCDKEntry(obj) eraseCDKObject(obj) /* * This cleans out the value of the entry field. */ void cleanCDKEntry ( CDKENTRY * /* entry */); /* * This moves the widget to the given location. */ #define moveCDKEntry(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This is an interactive method of moving the widget. */ #define positionCDKEntry(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the widget and all the memory associated with the widget. */ #define destroyCDKEntry(obj) destroyCDKObject(obj) /* * This sets the callback to the entry fields main handler */ void setCDKEntryCB ( CDKENTRY * /* entry */, ENTRYCB /* callback */); /* * These set the callbacks to the pre and post process functions. */ #define setCDKEntryPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d) #define setCDKEntryPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d) #ifdef __cplusplus } #endif #endif /* CDKENTRY_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/gen-scale.h0000644000175100001440000001402410114467071015173 0ustar tomusers/* * $Id: gen-scale.h,v 1.7 2004/08/30 00:00:57 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDK_H #define CDK_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Copyright 2004, Thomas E. Dickey * 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 Thomas Dickey * and contributors. * 4. Neither the name of Thomas Dickey, 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 THOMAS DICKEY 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 THOMAS DICKEY 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. */ /* * Define the CDK widget structure. */ struct S { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * shadowWin; WINDOW * fieldWin; WINDOW * labelWin; int titleAdj; chtype * label; int labelLen; int boxHeight; int boxWidth; int fieldWidth; int fieldEdit; /* offset from right-margin of field */ chtype fieldAttr; low; high; inc; fastinc; current; #if int digits; #endif EExitType exitType; boolean shadow; }; typedef struct S CDK; /* * This creates a new pointer to a CDK - widget. */ CDK *newCDK ( CDKSCREEN * /* cdkscreen */, int /* xpos */, int /* ypos */, char * /* title */, char * /* label */, chtype /* fieldAttr */, int /* fieldWidth */, /* start */, /* low */, /* high */, /* inc */, /* fastInc */, #if int /* digits */, #endif boolean /* Box */, boolean /* shadow */); /* * This activates the widget. */ activateCDK ( CDK * /* widget */, chtype * /* actions */); /* * This injects a single character into the widget. */ #define injectCDK(obj,input) injectCDKObject(obj,input,) /* * This sets various attributes of the widget. */ void setCDK ( CDK * /* widget */, /* low */, /* high */, /* value */, boolean /* Box */); /* * These set/get the low and high values. */ void setCDKLowHigh ( CDK * /* widget */, /* low */, /* high */); getCDKLowValue ( CDK * /* widget */); getCDKHighValue ( CDK * /* widget */); /* * These set/get the digits. */ #if void setCDKDigits ( CDK * /* widget */, int /* digits */); int getCDKDigits ( CDK * /* widget */); #endif /* * These set/get the current value. */ void setCDKValue ( CDK * /* widget */, /* value */); getCDKValue ( CDK * /* widget */); /* * This sets the box attribute of the widget. */ void setCDKBox ( CDK * /* widget */, boolean /* Box */); boolean getCDKBox ( CDK * /* widget */); /* * These set the drawing characters of the widget. */ #define setCDKULChar(w,c) setULCharOf(w,c) #define setCDKURChar(w,c) setURCharOf(w,c) #define setCDKLLChar(w,c) setLLCharOf(w,c) #define setCDKLRChar(w,c) setLRCharOf(w,c) #define setCDKVerticalChar(w,c) setVTCharOf(w,c) #define setCDKHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This draws the widget on the screen. */ #define drawCDK(obj,Box) drawCDKObject(obj,Box) /* * This erases the widget from the screen. */ #define eraseCDK(obj) eraseCDKObject(obj) /* * This moves the widget to the given location on the screen. */ #define moveCDK(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This allows the user to interactively position the widget on the screen. */ #define positionCDK(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the widget and associated memory. */ #define destroyCDK(obj) destroyCDKObject(obj) /* * These set the pre/post process callback functions. */ #define setCDKPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d) #define setCDKPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d) #ifdef __cplusplus } #endif #endif /* CDK_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/gen-slider.h0000644000175100001440000001401310114467071015364 0ustar tomusers/* * $Id: gen-slider.h,v 1.7 2004/08/30 00:00:57 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDK_H #define CDK_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Copyright 2004, Thomas E. Dickey * 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 Thomas Dickey * and contributors. * 4. Neither the name of Thomas Dickey, 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 THOMAS DICKEY 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 THOMAS DICKEY 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. */ /* * Define the CDK widget structure. */ struct S { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * shadowWin; WINDOW * fieldWin; WINDOW * labelWin; int titleAdj; chtype * label; int labelLen; int boxHeight; int boxWidth; int fieldWidth; int fieldEdit; /* offset from right-margin of field */ chtype filler; low; high; inc; fastinc; current; #if int digits; #endif EExitType exitType; boolean shadow; }; typedef struct S CDK; /* * This creates a new pointer to a CDK - widget. */ CDK *newCDK ( CDKSCREEN * /* cdkscreen */, int /* xpos */, int /* ypos */, char * /* title */, char * /* label */, chtype /* fieldAttr */, int /* fieldWidth */, /* start */, /* low */, /* high */, /* inc */, /* fastInc */, #if int /* digits */, #endif boolean /* Box */, boolean /* shadow */); /* * This activates the widget. */ activateCDK ( CDK * /* widget */, chtype * /* actions */); /* * This injects a single character into the widget. */ #define injectCDK(obj,input) injectCDKObject(obj,input,) /* * This sets various attributes of the widget. */ void setCDK ( CDK * /* widget */, /* low */, /* high */, /* value */, boolean /* Box */); /* * These set/get the low and high values. */ void setCDKLowHigh ( CDK * /* widget */, /* low */, /* high */); getCDKLowValue ( CDK * /* widget */); getCDKHighValue ( CDK * /* widget */); /* * These set/get the digits. */ #if void setCDKDigits ( CDK * /* widget */, int /* digits */); int getCDKDigits ( CDK * /* widget */); #endif /* * These set/get the current value. */ void setCDKValue ( CDK * /* widget */, /* value */); getCDKValue ( CDK * /* widget */); /* * This sets the box attribute of the widget. */ void setCDKBox ( CDK * /* widget */, boolean /* Box */); boolean getCDKBox ( CDK * /* widget */); /* * These set the drawing characters of the widget. */ #define setCDKULChar(w,c) setULCharOf(w,c) #define setCDKURChar(w,c) setURCharOf(w,c) #define setCDKLLChar(w,c) setLLCharOf(w,c) #define setCDKLRChar(w,c) setLRCharOf(w,c) #define setCDKVerticalChar(w,c) setVTCharOf(w,c) #define setCDKHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This draws the widget on the screen. */ #define drawCDK(obj,Box) drawCDKObject(obj,Box) /* * This erases the widget from the screen. */ #define eraseCDK(obj) eraseCDKObject(obj) /* * This moves the widget to the given location on the screen. */ #define moveCDK(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This allows the user to interactively position the widget on the screen. */ #define positionCDK(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the widget and associated memory. */ #define destroyCDK(obj) destroyCDKObject(obj) /* * These set the pre/post process callback functions. */ #define setCDKPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d) #define setCDKPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d) #ifdef __cplusplus } #endif #endif /* CDK_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/cdk.h0000644000175100001440000001606410114447554014110 0ustar tomusers/* * $Id: cdk.h,v 1.34 2004/08/29 21:49:32 tom Exp $ */ #ifndef CDK_H #define CDK_H #ifdef __cplusplus extern "C" { #endif /* * Changes 2000-2003,2004 copyright 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. */ #include #include #ifdef CDK_PERL_EXT #undef instr #endif #ifdef HAVE_XCURSES #include #ifndef mvwhline #define mvwhline(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : whline(win,c,n)) #endif #ifndef mvwvline #define mvwvline(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : wvline(win,c,n)) #endif #elif defined(HAVE_NCURSESW_NCURSES_H) #include #elif defined(HAVE_NCURSES_NCURSES_H) #include #elif defined(HAVE_NCURSES_H) #include #else #include #endif #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_LIMITS_H #include #endif #ifdef HAVE_GETOPT_HEADER #ifdef HAVE_GETOPT_H #include #endif #else extern int optind; extern char * optarg; #endif /* * Definitions that we do not want if term.h does */ #ifdef buttons #undef buttons #endif #ifdef lines #undef lines #endif #ifdef newline #undef newline #endif /* * Values we normally get from limits.h (assume 32-bits) */ #ifndef INT_MIN #define INT_MIN (-INT_MAX - 1) #endif #ifndef INT_MAX #define INT_MAX 2147483647 #endif #ifndef GCC_UNUSED #define GCC_UNUSED /*nothing*/ #endif #ifdef HAVE_LIBDMALLOC #include /* Gray Watson's library */ #else #undef HAVE_LIBDMALLOC #define HAVE_LIBDMALLOC 0 #endif #ifdef HAVE_LIBDBMALLOC #include /* Conor Cahill's library */ #else #undef HAVE_LIBDBMALLOC #define HAVE_LIBDBMALLOC 0 #endif /* * This enumerated typedef lists all of the CDK widget types. */ typedef enum { vNULL = 0 ,vALPHALIST ,vBUTTON ,vBUTTONBOX ,vCALENDAR ,vDIALOG ,vDSCALE ,vENTRY ,vFSCALE ,vFSELECT ,vFSLIDER ,vGRAPH ,vHISTOGRAM ,vITEMLIST ,vLABEL ,vMARQUEE ,vMATRIX ,vMENTRY ,vMENU ,vRADIO ,vSCALE ,vSCROLL ,vSELECTION ,vSLIDER ,vSWINDOW ,vTEMPLATE ,vTRAVERSE ,vUSCALE ,vUSLIDER ,vVIEWER } EObjectType; /* * This enumerated typedef lists all the valid display types for * the entry, mentry, and template widgets. */ typedef enum { vINVALID = 0 ,vCHAR ,vHCHAR ,vINT ,vHINT ,vMIXED ,vHMIXED ,vUCHAR ,vLCHAR ,vUHCHAR ,vLHCHAR ,vUMIXED ,vLMIXED ,vUHMIXED ,vLHMIXED ,vVIEWONLY } EDisplayType; /* * This enumerated typedef lists all the display types for * the histogram widget. */ typedef enum {vNONE, vPERCENT, vFRACTION, vREAL} EHistogramDisplayType; /* * This enumerated typedef defines the display types for the graph. */ typedef enum {vPLOT, vLINE} EGraphDisplayType; /* * This enumerated typedef defines where white space is to be * stripped from in the function stripWhiteSpace. */ typedef enum {vFRONT, vBACK, vBOTH} EStripType; /* * This enumerated typedef defines the type of exits the widgets * recognize. */ typedef enum {vEARLY_EXIT, vESCAPE_HIT, vNORMAL, vNEVER_ACTIVATED} EExitType; /* * This defines a boolean type. */ typedef int boolean; /* * Declare miscellaneous defines. */ #define LEFT 9000 #define RIGHT 9001 #define CENTER 9002 #define TOP 9003 #define BOTTOM 9004 #define HORIZONTAL 9005 #define VERTICAL 9006 #define FULL 9007 #define NONE 0 #define ROW 1 #define COL 2 #define MAX_BINDINGS 300 /* unused by widgets */ #define MAX_ITEMS 2000 /* unused by widgets */ #define MAX_BUTTONS 200 /* unused by widgets */ #define MAXIMUM(a,b) ((a) > (b) ? (a) : (b)) #define MINIMUM(a,b) ((a) < (b) ? (a) : (b)) #define HALF(a) ((a) >> 1) #ifndef COLOR_PAIR #define COLOR_PAIR(a) A_NORMAL #endif #define CONTROL(c) ((c) & 0x1f) /* obsolete: use CTRL() */ /* Define the 'GLOBAL DEBUG FILEHANDLE' */ extern FILE *CDKDEBUG; /* * ========================================================= * Declare Debugging Routines. * ========================================================= */ #define START_DEBUG(a) (CDKDEBUG=startCDKDebug(a)) #define WRITE_DEBUGMESG(a,b) (writeCDKDebugMessage (CDKDEBUG,__FILE__,a,__LINE__,b)) #define END_DEBUG (stopCDKDebug(CDKDEBUG) FILE *startCDKDebug(char *filename); void writeCDKDebugMessage (FILE *fd, char *filename, char *function, int line, char *message); void stopCDKDebug (FILE *fd); /* * These header files define miscellaneous values and prototypes. */ #include #include #include #include #include #include /* * Include the CDK widget header files. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* * Generated headers: */ #include #include #include #include #include #include #include /* * Low-level object drawing */ #include #ifdef __cplusplus } #endif #endif /* CDK_H */ cdk-5.0-20060507/include/curdefs.h0000644000175100001440000001103010114737323014762 0ustar tomusers#ifndef CDKINCLUDES #ifndef CURDEF_H #define CURDEF_H #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #endif /* * $Id: curdefs.h,v 1.13 2004/08/30 23:57:07 tom Exp $ * * Changes 1999-2002,2004 copyright 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. */ /* * This header file adds some useful curses-style definitions. */ #undef CTRL #define CTRL(c) ((c)&0x1f) #undef CDK_REFRESH #define CDK_REFRESH CTRL('L') #undef CDK_PASTE #define CDK_PASTE CTRL('V') #undef CDK_COPY #define CDK_COPY CTRL('Y') #undef CDK_ERASE #define CDK_ERASE CTRL('U') #undef CDK_CUT #define CDK_CUT CTRL('X') #undef CDK_BEGOFLINE #define CDK_BEGOFLINE CTRL('A') #undef CDK_ENDOFLINE #define CDK_ENDOFLINE CTRL('E') #undef CDK_BACKCHAR #define CDK_BACKCHAR CTRL('B') #undef CDK_FORCHAR #define CDK_FORCHAR CTRL('F') #undef CDK_TRANSPOSE #define CDK_TRANSPOSE CTRL('T') #undef CDK_NEXT #define CDK_NEXT CTRL('N') #undef CDK_PREV #define CDK_PREV CTRL('P') #undef SPACE #define SPACE ' ' #undef DELETE #define DELETE '\177' /* Delete key */ #undef TAB #define TAB '\t' /* Tab key. */ #undef KEY_ESC #define KEY_ESC '\033' /* Escape Key. */ #undef KEY_RETURN #define KEY_RETURN '\012' /* Return key */ #undef KEY_TAB #define KEY_TAB '\t' /* Tab key */ #undef KEY_F1 #define KEY_F1 KEY_F(1) #undef KEY_F2 #define KEY_F2 KEY_F(2) #undef KEY_F3 #define KEY_F3 KEY_F(3) #undef KEY_F4 #define KEY_F4 KEY_F(4) #undef KEY_F5 #define KEY_F5 KEY_F(5) #undef KEY_F6 #define KEY_F6 KEY_F(6) #undef KEY_F7 #define KEY_F7 KEY_F(7) #undef KEY_F8 #define KEY_F8 KEY_F(8) #undef KEY_F9 #define KEY_F9 KEY_F(9) #undef KEY_F10 #define KEY_F10 KEY_F(10) #undef KEY_F11 #define KEY_F11 KEY_F(11) #undef KEY_F12 #define KEY_F12 KEY_F(12) /* these definitions may work for antique versions of curses */ #if !defined(HAVE_GETBEGYX) && !defined(getbegyx) #define getbegyx(win,y,x) (y = (win)?(win)->_begy:ERR, x = (win)?(win)->_begx:ERR) #endif #if !defined(HAVE_GETMAXYX) && !defined(getmaxyx) #define getmaxyx(win,y,x) (y = (win)?(win)->_maxy:ERR, x = (win)?(win)->_maxx:ERR) #endif /* these definitions may be needed for bleeding-edge curses implementations */ #if !(defined(HAVE_GETBEGX) && defined(HAVE_GETBEGY)) #undef getbegx #undef getbegy #define getbegx(win) cdk_getbegx(win) #define getbegy(win) cdk_getbegy(win) extern int cdk_getbegx(WINDOW *); extern int cdk_getbegy(WINDOW *); #endif #if !(defined(HAVE_GETMAXX) && defined(HAVE_GETMAXY)) #undef getmaxx #undef getmaxy #define getmaxx(win) cdk_getmaxx(win) #define getmaxy(win) cdk_getmaxy(win) extern int cdk_getmaxx(WINDOW *); extern int cdk_getmaxy(WINDOW *); #endif /* * Derived macros */ #define getendx(a) (getbegx(a) + getmaxx(a)) #define getendy(a) (getbegy(a) + getmaxy(a)) #endif /* CURDEF_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/draw.h0000644000175100001440000001011010130362514014254 0ustar tomusers/* * $Id: draw.h,v 1.10 2004/10/05 00:05:32 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKDRAW_H #define CDKDRAW_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 1999-2003,2004 copyright 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. */ /* * This boxes a window. */ void boxWindow ( WINDOW * /* window */, chtype /* attr */); /* * This draws a single line with the character supplied by 'character' */ void drawLine ( WINDOW * /* window */, int /* startx */, int /* starty */, int /* endx */, int /* endy */, chtype /* character */); /* * This writes a blank string segment on the given window. */ void writeBlanks ( WINDOW * /* window */, int /* xpos */, int /* ypos */, int /* align */, int /* start */, int /* end */); /* * This writes a string segment on the given window. */ void writeChar ( WINDOW * /* window */, int /* xpos */, int /* ypos */, char * /* string */, int /* align */, int /* start */, int /* end */); /* * This writes a string segment on the given window. */ void writeCharAttrib ( WINDOW * /* window */, int /* xpos */, int /* ypos */, char * /* string */, chtype /* attr */, int /* align */, int /* start */, int /* end */); /* * This writes a string segment on the given window. */ void writeChtype ( WINDOW * /* window */, int /* xpos */, int /* ypos */, chtype * /* string */, int /* align */, int /* start */, int /* end */); /* * This writes a string segment on the given window. */ void writeChtypeAttrib ( WINDOW * /* window */, int /* xpos */, int /* ypos */, chtype * /* string */, chtype /* attr */, int /* align */, int /* start */, int /* end */); /* * This boxes a window using the given characters. */ void attrbox ( WINDOW * /* window */, chtype /* tlc */, chtype /* trc */, chtype /* blc */, chtype /* brc */, chtype /* hor */, chtype /* vert */, chtype /* type */); /* * This boxes a window using the object's characters. */ void drawObjBox ( WINDOW * /* win */, CDKOBJS * /* object */); /* * This draws the shadow window of the widget. */ void drawShadow ( WINDOW * /* window */); #ifdef __cplusplus } #endif #endif /* CDKDRAW_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/binding.h0000644000175100001440000000707010213434331014743 0ustar tomusers/* * $Id: binding.h,v 1.14 2005/03/08 23:44:25 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKBINDING_H #define CDKBINDING_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #endif /* * Changes 1999-2004,2005 copyright 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. */ /* * Create definitions for the key bindings. */ /* * This is the key binding prototype, typed for use with Perl. */ #define BINDFN_PROTO(func) \ int (func) ( \ EObjectType /* cdktype */, \ void * /* object */, \ void * /* clientData */, \ chtype /* input */) typedef BINDFN_PROTO(*BINDFN); /* * Bind to this function to simply translate keys without doing anything else, * in getcCDKObject(). */ extern BINDFN_PROTO(getcCDKBind); /* * This is the prototype for the process callback functions. */ typedef int (*PROCESSFN) ( EObjectType /* cdktype */, void * /* object */, void * /* clientData */, chtype /* input */); /* * This binds the key to the event. */ void bindCDKObject ( EObjectType /* cdktype */, void * /* object */, chtype /* key */, BINDFN /* function */, void * /* data */); /* * This unbinds the key from the event. */ void unbindCDKObject ( EObjectType /* cdktype */, void * /* object */, chtype /* key */); /* * This checks if the given key has an event 'attached' to it, executes the * bound function if so. */ int checkCDKObjectBind ( EObjectType /* cdktype */, void * /* object */, chtype /* key */); /* * This checks if the given key has an event 'attached' to it. */ bool isCDKObjectBind ( EObjectType /* cdktype */, void * /* object */, chtype /* key */); /* * This cleans out all of the key bindings. */ void cleanCDKObjectBindings ( EObjectType /* cdktype */, void * /* object */); #ifdef __cplusplus } #endif #endif /* CDKBINDING_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/cdk_int.h0000644000175100001440000001652610227602155014760 0ustar tomusers/* * $Id: cdk_int.h,v 1.19 2005/04/15 00:01:49 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDK_INT_H #define CDK_INT_H #ifdef __cplusplus extern "C" { #endif #include /* * Copyright 2003-2004,2005 Thomas E. Dickey * 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 Thomas Dickey * and contributors. * 4. Neither the name of Thomas Dickey, 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 THOMAS DICKEY 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 THOMAS DICKEY 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. */ #define typeCallocN(type,n) (type*)calloc(n, sizeof(type)) #define typeCalloc(type) typeCallocN(type,1) #define typeReallocN(type,p,n) (type*)realloc(p, (n) * sizeof(type)) #define typeMallocN(type,n) (type*)malloc((n) * sizeof(type)) #define typeMalloc(type) typeMallocN(type,1) #define freeChecked(p) if ((p) != 0) free (p) #define freeAndNull(p) if ((p) != 0) { free (p); p = 0; } #define isChar(c) ((int)(c) >= 0 && (int)(c) < KEY_MIN) #define CharOf(c) ((unsigned char)(c)) #define SIZEOF(v) (sizeof(v)/sizeof((v)[0])) /* * Macros to check if caller is attempting to make the widget as high (or wide) * as the screen. */ #define isFullWidth(n) ((n) == FULL || (COLS != 0 && ((n) >= COLS))) #define isFullHeight(n) ((n) == FULL || (LINES != 0 && ((n) >= LINES))) /* * Hide details of modifying widget->exitType */ #define storeExitType(d) ObjOf(d)->exitType = (d)->exitType #define initExitType(d) storeExitType(d) = vNEVER_ACTIVATED #define setExitType(w,c) setCdkExitType(ObjOf(w), &((w)->exitType), c) #define copyExitType(d,s) storeExitType(d) = ExitTypeOf(s) /* * Use this if checkCDKObjectBind() returns true, use this function to * decide if the exitType should be set as a side-effect. */ #define checkEarlyExit(w) if (EarlyExitOf(w) != vNEVER_ACTIVATED) \ storeExitType(w) = EarlyExitOf(w) /* * Simplify case-statements for scrollers */ #define scroller_KEY_UP(w) \ if ((w)->listSize > 0) { \ if ((w)->currentItem > 0) { \ if ((w)->currentHigh == 0) { \ if ((w)->currentTop != 0) { \ (w)->currentTop--; \ (w)->currentItem--; \ } else { \ Beep(); \ } \ } else { \ (w)->currentItem--; \ (w)->currentHigh--; \ } \ } else { \ Beep(); \ } \ } else { \ Beep(); \ } #define scroller_KEY_DOWN(w) \ if ((w)->listSize > 0) { \ if ((w)->currentItem < (w)->listSize-1) { \ if ((w)->currentHigh == (w)->viewSize - 1) { \ if ((w)->currentTop < (w)->maxTopItem) { \ (w)->currentTop++; \ (w)->currentItem++; \ } else { \ Beep(); \ } \ } else { \ (w)->currentItem++; \ (w)->currentHigh++; \ } \ } else { \ Beep(); \ } \ } else { \ Beep(); \ } #define scroller_KEY_LEFT(w) \ if ((w)->listSize > 0) { \ if ((w)->leftChar == 0) { \ Beep(); \ } else { \ (w)->leftChar --; \ } \ } else { \ Beep(); \ } #define scroller_KEY_RIGHT(w) \ if ((w)->listSize > 0) { \ if ((w)->leftChar >= (w)->maxLeftChar) { \ Beep(); \ } else { \ (w)->leftChar ++; \ } \ } else { \ Beep(); \ } #define scroller_KEY_PPAGE(w) \ if ((w)->listSize > 0) { \ if ((w)->currentTop > 0) { \ if ((w)->currentTop >= ((w)->viewSize -1)) { \ (w)->currentTop -= ((w)->viewSize - 1); \ (w)->currentItem -= ((w)->viewSize - 1); \ } else { \ scroller_KEY_HOME(w); \ } \ } else { \ Beep(); \ } \ } else { \ Beep(); \ } #define scroller_KEY_NPAGE(w) \ if ((w)->listSize > 0) { \ if ((w)->currentTop < (w)->maxTopItem) { \ if (((w)->currentTop + (w)->viewSize - 1) <= (w)->maxTopItem) { \ (w)->currentTop += ((w)->viewSize - 1); \ (w)->currentItem += ((w)->viewSize - 1); \ } else { \ (w)->currentTop = (w)->maxTopItem; \ (w)->currentItem = (w)->lastItem; \ (w)->currentHigh = (w)->viewSize-1; \ } \ } else { \ Beep(); \ } \ } else { \ Beep(); \ } #define scroller_KEY_HOME(w) \ (w)->currentTop = 0; \ (w)->currentItem = 0; \ (w)->currentHigh = 0 #define scroller_KEY_END(w) \ if ((w)->maxTopItem == -1) { \ (w)->currentTop = 0; \ (w)->currentItem = (w)->lastItem - 1; \ } else { \ (w)->currentTop = (w)->maxTopItem; \ (w)->currentItem = (w)->lastItem; \ } \ (w)->currentHigh = (w)->viewSize - 1 #define scroller_SetPosition(w, item) \ if (item <= 0) { \ scroller_KEY_HOME((w)); \ } else if (item > (w)->listSize-1) { \ (w)->currentTop = (w)->maxTopItem; \ (w)->currentItem = (w)->listSize - 1; \ (w)->currentHigh = (w)->viewSize - 1; \ } else if (item >= (w)->currentTop \ && item < (w)->currentTop + (w)->viewSize) { \ (w)->currentItem = item; \ (w)->currentHigh = item - (w)->currentTop; \ } else { \ (w)->currentTop = item; \ (w)->currentItem = item; \ (w)->currentHigh = 0; \ } #define scroller_MaxViewSize(w) \ ((w)->boxHeight - (2*BorderOf(w) + TitleLinesOf(w))) #define scroller_SetViewSize(w, size) \ (w)->viewSize = maxViewSize(w); \ (w)->listSize = listSize; \ (w)->lastItem = listSize - 1; \ (w)->maxTopItem = listSize - (w)->viewSize; \ \ if (listSize < (w)->viewSize) { \ (w)->viewSize = listSize; \ (w)->maxTopItem = 0; \ } \ \ if ((w)->listSize > 0 && maxViewSize((w)) > 0) { \ (w)->step = (maxViewSize((w)) / (float)(w)->listSize); \ (w)->toggleSize = ((w)->listSize > (maxViewSize((w))) ? 1 : ceilCDK((w)->step)); \ } else { \ (w)->step = 1; \ (w)->toggleSize = 1; \ } /* * Position within the data area of a widget, accounting for border and title. */ #define SCREEN_XPOS(w,n) ((n) + BorderOf(w)) #define SCREEN_YPOS(w,n) ((n) + BorderOf(w) + TitleLinesOf(w)) /* * Miscellaneous definitions. */ #define CDK_PATHMAX 256 extern char *GPasteBuffer; #ifdef __cplusplus } #endif #endif /* CDK_INT_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/selection.h0000644000175100001440000001646310354603554015337 0ustar tomusers/* * $Id: selection.h,v 1.26 2005/12/28 21:45:16 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKSELECTION_H #define CDKSELECTION_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 1999-2003,2005 copyright 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. */ /* * Declare selection list definitions. */ #define MAX_CHOICES 100 /* unused by widgets */ /* * Define the CDK selection widget structure. */ struct SSelection { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * scrollbarWin; WINDOW * shadowWin; int titleAdj; /* unused */ chtype ** item; int * itemLen; int * itemPos; chtype ** choice; int * choicelen; int choiceCount; int maxchoicelen; int * selections; int * mode; int maxTopItem; int maxLeftChar; int leftChar; int lastItem; int currentTop; int currentHigh; int currentItem; int listSize; int scrollbarPlacement; boolean scrollbar; int toggleSize; int togglePos; float step; int boxWidth; int boxHeight; int viewSize; EExitType exitType; boolean shadow; chtype highlight; }; typedef struct SSelection CDKSELECTION; /* * This creates a new pointer to a selection widget. */ CDKSELECTION *newCDKSelection ( CDKSCREEN * /* cdkscreen */, int /* xpos */, int /* ypos */, int /* spos */, int /* height */, int /* width */, char * /* title */, char ** /* list */, int /* listSize */, char ** /* choices */, int /* choiceSize */, chtype /* highlight */, boolean /* Box */, boolean /* shadow */); /* * This activates the selection widget. */ int activateCDKSelection ( CDKSELECTION * /* selection */, chtype * /* actions */); /* * This injects a single character into the widget. */ #define injectCDKSelection(obj,input) injectCDKObject(obj,input,Int) /* * This draws the selection widget. */ #define drawCDKSelection(obj,Box) drawCDKObject(obj,Box) /* * This erases the selection widget from the screen. */ #define eraseCDKSelection(obj) eraseCDKObject(obj) /* * This moves the widget to the given location. */ #define moveCDKSelection(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This interactively moves the widget on the screen. */ #define positionCDKSelection(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the widget and all associated memory. */ #define destroyCDKSelection(obj) destroyCDKObject(obj) /* * This sets various attributes of the selection widget. */ void setCDKSelection ( CDKSELECTION * /* selection */, chtype /* highlight */, int * /* defChoices */, boolean /* Box */); /* * This sets the contents of the selection list. */ void setCDKSelectionItems ( CDKSELECTION * /* selection */, char ** /* list */, int /* listSize */); int getCDKSelectionItems ( CDKSELECTION * /* selection */, char ** /* list */); /* * */ void setCDKSelectionTitle ( CDKSELECTION * /* selection */, char * /* title */); char *getCDKSelectionTitle ( CDKSELECTION * /* selection */); /* * This sets the selection list highlight bar. */ void setCDKSelectionHighlight ( CDKSELECTION * /* selection */, chtype /* highlight */); chtype getCDKSelectionHighlight ( CDKSELECTION * /* selection */); /* * set/get the current item index */ void setCDKSelectionCurrent ( CDKSELECTION * /* selection */, int /* index */); int getCDKSelectionCurrent ( CDKSELECTION * /* selection */); /* * This sets the choices of the selection list. */ void setCDKSelectionChoices ( CDKSELECTION * /* selection */, int * /* choices */); int *getCDKSelectionChoices ( CDKSELECTION * /* selection */); void setCDKSelectionChoice ( CDKSELECTION * /* selection */, int /* index */, int /* choice */); int getCDKSelectionChoice ( CDKSELECTION * /* selection */, int /* index */); /* * This sets the modes of the items in the selection list. Currently * there are only two: editable=0 and read-only=1 */ void setCDKSelectionModes ( CDKSELECTION * /* selection */, int * /* modes */); int *getCDKSelectionModes ( CDKSELECTION * /* selection */); void setCDKSelectionMode ( CDKSELECTION * /* selection */, int /* index */, int /* mode */); int getCDKSelectionMode ( CDKSELECTION * /* selection */, int /* index */); /* * This sets the box attribute of the widget. */ void setCDKSelectionBox ( CDKSELECTION * /* selection */, boolean /* Box */); boolean getCDKSelectionBox ( CDKSELECTION * /* selection */); /* * These set the drawing characters of the widget. */ #define setCDKSelectionULChar(w,c) setULCharOf(w,c) #define setCDKSelectionURChar(w,c) setURCharOf(w,c) #define setCDKSelectionLLChar(w,c) setLLCharOf(w,c) #define setCDKSelectionLRChar(w,c) setLRCharOf(w,c) #define setCDKSelectionVerticalChar(w,c) setVTCharOf(w,c) #define setCDKSelectionHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKSelectionBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKSelectionBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKSelectionBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * These set the pre/post process callback functions. */ #define setCDKSelectionPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d) #define setCDKSelectionPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d) #ifdef __cplusplus } #endif #endif /* CDKSELECTION_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/menu.h0000644000175100001440000001214410354024727014305 0ustar tomusers/* * $Id: menu.h,v 1.21 2005/12/26 17:35:19 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKMENU_H #define CDKMENU_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 1999-2004,2005 copyright 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. */ /* * Define menu specific values. */ #define MAX_MENU_ITEMS 30 #define MAX_SUB_ITEMS 98 /* * Define the CDK menu widget structure. */ struct SMenu { CDKOBJS obj; WINDOW * parent; WINDOW * pullWin[MAX_MENU_ITEMS]; WINDOW * titleWin[MAX_MENU_ITEMS]; chtype * title[MAX_MENU_ITEMS]; int titleLen[MAX_MENU_ITEMS]; chtype * sublist[MAX_MENU_ITEMS][MAX_SUB_ITEMS]; int sublistLen[MAX_MENU_ITEMS][MAX_SUB_ITEMS]; int subsize[MAX_MENU_ITEMS]; int menuPos; int menuItems; chtype titleAttr; chtype subtitleAttr; int currentTitle; int currentSubtitle; int lastTitle; int lastSubtitle; EExitType exitType; int lastSelection; }; typedef struct SMenu CDKMENU; /* * This creates a new CDK menu widget pointer. */ CDKMENU *newCDKMenu ( CDKSCREEN * /* cdkscreen */, char * /* menulist */ [MAX_MENU_ITEMS][MAX_SUB_ITEMS], int /* menuitems */, int * /* subsize */, int * /* menuloc */, int /* menuPos */, chtype /* titleattr */, chtype /* subtitleattr */); /* * This activates the menu. */ int activateCDKMenu ( CDKMENU * /* menu */, chtype * /* actions */); /* * This injects a single character into the menu widget. */ #define injectCDKMenu(obj,input) injectCDKObject(obj,input,Int) /* * These set specific attributes of the menu. */ void setCDKMenu ( CDKMENU * /* menu */, int /* menuItem */, int /* subMenuItem */, chtype /* titleHighlight */, chtype /* subTitleHighlight */); /* * This returns the current item the menu is on. */ void setCDKMenuCurrentItem ( CDKMENU * /* menu */, int /* menuItem */, int /* subMenuItem */); void getCDKMenuCurrentItem ( CDKMENU * /* menu */, int * /* menuItem */, int * /* subMenuItem */); /* * This sets the highlight of the title. */ void setCDKMenuTitleHighlight ( CDKMENU * /* menu */, chtype /* highlight */); chtype getCDKMenuTitleHighlight ( CDKMENU * /* menu */); /* * This sets the sub-menu title highlight. */ void setCDKMenuSubTitleHighlight ( CDKMENU * /* menu */, chtype /* highlight */); chtype getCDKMenuSubTitleHighlight ( CDKMENU * /* menu */); /* * This draws the menu on the screen. */ #define drawCDKMenu(obj,box) drawCDKObject(obj,box) void drawCDKMenuSubwin ( CDKMENU * /* menu */); /* * This erases the complere menu widget from the screen. */ #define eraseCDKMenu(obj) eraseCDKObject(obj) void eraseCDKMenuSubwin ( CDKMENU * /* menu */); /* * This sets the background color of the widget. */ #define setCDKMenuBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKMenuBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This destroys the menu widget. */ #define destroyCDKMenu(obj) destroyCDKObject(obj) /* * These set the pre/post process callback functions. */ #define setCDKMenuPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d) #define setCDKMenuPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d) #ifdef __cplusplus } #endif #endif /* CDKMENU_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/radio.h0000644000175100001440000001545210354603530014437 0ustar tomusers/* * $Id: radio.h,v 1.28 2005/12/28 21:44:56 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKRADIO_H #define CDKRADIO_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 1999-2004,2005 copyright 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. */ /* * Define the CDK radio list widget structure. */ struct SRadio { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * scrollbarWin; WINDOW * shadowWin; chtype ** item; int * itemLen; int * itemPos; int titleAdj; /* unused */ chtype choiceChar; chtype leftBoxChar; chtype rightBoxChar; int maxLeftChar; int widestItem; int leftChar; int selectedItem; int currentTop; int currentItem; int currentHigh; int scrollbarPlacement; boolean scrollbar; int toggleSize; int togglePos; float step; int listSize; int lastItem; int maxTopItem; int boxWidth; int boxHeight; int viewSize; int defItem; EExitType exitType; boolean shadow; chtype highlight; }; typedef struct SRadio CDKRADIO; /* * This creates a new radio widget pointer. */ CDKRADIO *newCDKRadio ( CDKSCREEN * /* cdkscreen */, int /* xpos */, int /* ypos */, int /* spos */, int /* height */, int /* width */, char * /* title */, char ** /* mesg */, int /* items */, chtype /* choiceChar */, int /* defItem */, chtype /* highlight */, boolean /* Box */, boolean /* shadow */); /* * This activates the widget. */ int activateCDKRadio ( CDKRADIO * /* radio */, chtype * /* actions */); /* * This injects a single character into the widget. */ #define injectCDKRadio(obj,input) injectCDKObject(obj,input,Int) /* * These set various attributes of the widget. */ void setCDKRadio ( CDKRADIO * /* radio */, chtype /* highlight */, chtype /* character */, boolean /* Box */); /* * This sets the contents of the radio list. */ void setCDKRadioItems ( CDKRADIO * /* radio */, char ** /* list */, int /* listSize */); int getCDKRadioItems ( CDKRADIO * /* radio */, char ** /* list */); /* * This sets the highlight bar attribute. */ void setCDKRadioHighlight ( CDKRADIO * /* radio */, chtype /* highlight */); chtype getCDKRadioHighlight ( CDKRADIO * /* radio */); /* * This sets the 'selected' character. */ void setCDKRadioChoiceCharacter ( CDKRADIO * /* radio */, chtype /* character */); chtype getCDKRadioChoiceCharacter ( CDKRADIO * /* radio */); /* * This sets the character to draw on the left/right side of * the choice box. */ void setCDKRadioLeftBrace ( CDKRADIO * /* radio */, chtype /* character */); chtype getCDKRadioLeftBrace ( CDKRADIO * /* radio */); void setCDKRadioRightBrace ( CDKRADIO * /* radio */, chtype /* character */); chtype getCDKRadioRightBrace ( CDKRADIO * /* radio */); /* * This sets the box attribute of the widget. */ void setCDKRadioBox ( CDKRADIO * /* radio */, boolean /* Box */); boolean getCDKRadioBox ( CDKRADIO * /* radio */); /* * This sets the current high lighted item of the widget */ void setCDKRadioCurrentItem ( CDKRADIO * /* radio */, int /* current item */); int getCDKRadioCurrentItem ( CDKRADIO * /* radio */); /* * This sets the current selected item of the widget */ void setCDKRadioSelectedItem ( CDKRADIO * /* radio */, int /* current item */); int getCDKRadioSelectedItem ( CDKRADIO * /* radio */); /* * These set the drawing characters of the widget. */ #define setCDKRadioULChar(w,c) setULCharOf(w,c) #define setCDKRadioURChar(w,c) setURCharOf(w,c) #define setCDKRadioLLChar(w,c) setLLCharOf(w,c) #define setCDKRadioLRChar(w,c) setLRCharOf(w,c) #define setCDKRadioVerticalChar(w,c) setVTCharOf(w,c) #define setCDKRadioHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKRadioBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKRadioBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKRadioBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This draws the widget on the screen. */ #define drawCDKRadio(obj,Box) drawCDKObject(obj,Box) /* * This erases the widget from the screen. */ #define eraseCDKRadio(obj) eraseCDKObject(obj) /* * This moves the widget to the given screen location. */ #define moveCDKRadio(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This interactively moves the widget to a new location on the screen. */ #define positionCDKRadio(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys a widget pointer. */ #define destroyCDKRadio(obj) destroyCDKObject(obj) /* * These set the pre/post process callback functions. */ #define setCDKRadioPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d) #define setCDKRadioPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d) #ifdef __cplusplus } #endif #endif /* CDKRADIO_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/cdk_test.h0000644000175100001440000000506310354067303015140 0ustar tomusers/* * $Id: cdk_test.h,v 1.2 2005/12/26 22:29:23 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDK_TEST_H #define CDK_TEST_H #ifdef __cplusplus extern "C" { #endif #include /* * Copyright 2005 Thomas E. Dickey * 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 Thomas Dickey * and contributors. * 4. Neither the name of Thomas Dickey, 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 THOMAS DICKEY 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 THOMAS DICKEY 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. */ /* * The whole point of this header is to define ExitProgram(), which is used for * leak-checking when ncurses's _nc_free_and_exit() function is available. * Invoking that rather than 'exit()' tells ncurses to free all of the * "permanent" memory leaks, making analysis much simpler. */ #ifdef HAVE_NC_ALLOC_H #ifndef HAVE_LIBDBMALLOC #define HAVE_LIBDBMALLOC 0 #endif #ifndef HAVE_LIBDMALLOC #define HAVE_LIBDMALLOC 0 #endif #ifndef HAVE_LIBMPATROL #define HAVE_LIBMPATROL 0 #endif #include #endif #ifndef ExitProgram #define ExitProgram(code) exit(code) #endif #ifdef __cplusplus } #endif #endif /* CDK_TEST_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/cdk_params.h0000644000175100001440000001003010354245322015431 0ustar tomusers/* * $Id: cdk_params.h,v 1.6 2005/12/27 14:08:18 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDK_PARAMS_H #define CDK_PARAMS_H #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #endif /* * Copyright 2003,2005 Thomas E. Dickey * 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 Thomas Dickey * and contributors. * 4. Neither the name of Thomas Dickey, 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 THOMAS DICKEY 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 THOMAS DICKEY 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. */ #define MAX_CDK_PARAMS 256 /* * CDKparseParams() knows about these options and will decode them into * the CDK_PARAMS struct. They are the most generally useful for positioning * a widget. */ #define CDK_MIN_PARAMS "NSX:Y:" #define CDK_CLI_PARAMS "NSX:Y:H:W:" /* * Use this exit code rather than -1 for cli programs which have reported an * error. Actually EXIT_FAILURE would be better, but the shell script samples * all are written to assume that the exit code can be used to indicate a * button number, etc. */ #define CLI_ERROR 255 /* * This records the values that CDKparseParams() decodes using getopt(): */ typedef struct CDK_PARAMS { char * allParams[MAX_CDK_PARAMS]; bool Box; bool Shadow; int hValue; int wValue; int xValue; int yValue; } CDK_PARAMS; /* * 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 */, char * /* options */); /* * Parse the string as one of CDK's positioning keywords, or an actual * position. */ int CDKparsePosition ( char * /* string */); /* * Retrieve an integer (or boolean) option value from the parsed command-line. */ int CDKparamNumber ( CDK_PARAMS * /* params */, int /* option */); /* * Retrieve an optional integer (or boolean) value from the parsed command-line. */ int CDKparamNumber2 ( CDK_PARAMS * /* params */, int /* option */, int /* missing */); /* * Retrieve a string option value from the parsed command-line. */ char * CDKparamString ( CDK_PARAMS * /* params */, int /* option */); /* * Retrieve an optional string option value from the parsed command-line. */ char * CDKparamString2 ( CDK_PARAMS * /* params */, int /* option */, char * /* missing */); /* * Retrieve an integer (or boolean) option value from the parsed command-line. */ int CDKparamValue ( CDK_PARAMS * /* params */, int /* option */, int /* missing */); #ifdef __cplusplus } #endif #endif /* CDK_PARAMS_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/dialog.h0000644000175100001440000001354410354512604014601 0ustar tomusers/* * $Id: dialog.h,v 1.24 2005/12/28 13:39:16 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKDIALOG_H #define CDKDIALOG_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 1999-2002,2003 copyright 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. */ /* * Declare definitions the dialog box may need. */ #define MAX_DIALOG_ROWS 50 /* unused by widgets */ #define MAX_DIALOG_BUTTONS 25 /* unused by widgets */ #define MIN_DIALOG_WIDTH 10 /* * Define the CDK dialog structure. */ struct SDialogBox { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * shadowWin; chtype ** info; int * infoLen; int * infoPos; chtype ** buttonLabel; int * buttonLen; int * buttonPos; int messageRows; int buttonCount; int currentButton; int boxWidth; int boxHeight; EExitType exitType; boolean separator; boolean shadow; chtype highlight; }; typedef struct SDialogBox CDKDIALOG; /* * This returns a CDK dialog widget pointer. */ CDKDIALOG *newCDKDialog ( CDKSCREEN * /* cdkscreen */, int /* xPos */, int /* yPos */, char ** /* message */, int /* Rows */, char ** /* buttons */, int /* buttonCount */, chtype /* highlight */, boolean /* separator */, boolean /* Box */, boolean /* shadow */); /* * This activates the widget. */ int activateCDKDialog ( CDKDIALOG * /* dialog */, chtype * /* actions */); /* * This injects a single character into the widget. */ #define injectCDKDialog(obj,input) injectCDKObject(obj,input,Int) /* * This sets multiple attributes of the widget. */ void setCDKDialog ( CDKDIALOG * /* dialog */, chtype /* highlight */, boolean /* separator */, boolean /* Box */); /* * This sets the highlight attribute for the buttons. */ void setCDKDialogHighlight ( CDKDIALOG * /* dialog */, chtype /* highlight */); chtype getCDKDialogHighlight ( CDKDIALOG * /* dialog */); /* * This sets whether or not the dialog box will have a separator line. */ void setCDKDialogSeparator ( CDKDIALOG * /* dialog */, boolean /* separator */); boolean getCDKDialogSeparator ( CDKDIALOG * /* dialog */); /* * This sets the box attribute of the widget. */ void setCDKDialogBox ( CDKDIALOG * /* dialog */, boolean /* Box */); boolean getCDKDialogBox ( CDKDIALOG * /* dialog */); /* * These set the drawing characters of the widget. */ #define setCDKDialogULChar(w,c) setULCharOf(w,c) #define setCDKDialogURChar(w,c) setURCharOf(w,c) #define setCDKDialogLLChar(w,c) setLLCharOf(w,c) #define setCDKDialogLRChar(w,c) setLRCharOf(w,c) #define setCDKDialogVerticalChar(w,c) setVTCharOf(w,c) #define setCDKDialogHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKDialogBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKDialogBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKDialogBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This draws the dialog box widget. */ #define drawCDKDialog(obj,box) drawCDKObject(obj,box) /* * This erases the dialog box from the screen. */ #define eraseCDKDialog(obj) eraseCDKObject(obj) /* * This moves the dialog box to a new screen location. */ #define moveCDKDialog(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This allows the user to position the widget on the screen interactively. */ #define positionCDKDialog(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the widget and all the memory associated with it. */ #define destroyCDKDialog(obj) destroyCDKObject(obj) /* * This draws the dialog box buttons. */ void drawCDKDialogButtons ( CDKDIALOG * /* dialog */); /* * These set the pre/post process functions of the dialog widget. */ #define setCDKDialogPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d) #define setCDKDialogPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d) #ifdef __cplusplus } #endif #endif /* CDKDIALOG_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/buttonbox.h0000644000175100001440000001367610354506046015377 0ustar tomusers/* * $Id: buttonbox.h,v 1.26 2005/12/28 12:59:18 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKBUTTONBOX_H #define CDKBUTTONBOX_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 1999-2004,2005 copyright 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. */ /* * Define the CDK buttonbox structure. */ struct SButtonBox { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * shadowWin; int titleAdj; chtype ** button; int * buttonLen; int * buttonPos; int * columnWidths; int buttonCount; int buttonWidth; int currentButton; int rows; int cols; int colAdjust; int rowAdjust; int boxWidth; int boxHeight; chtype ButtonAttrib; EExitType exitType; boolean shadow; chtype highlight; }; typedef struct SButtonBox CDKBUTTONBOX; /* * This returns a CDK buttonbox widget pointer. */ CDKBUTTONBOX *newCDKButtonbox ( CDKSCREEN * /* cdkscreen */, int /* xPos */, int /* yPos */, int /* height */, int /* width */, char * /* title */, int /* rows */, int /* cols */, char ** /* buttons */, int /* buttonCount */, chtype /* highlight */, boolean /* Box */, boolean /* shadow */); /* * This activates the widget. */ int activateCDKButtonbox ( CDKBUTTONBOX * /* buttonbox */, chtype * /* actions */); /* * This injects a single character into the widget. */ #define injectCDKButtonbox(obj,input) injectCDKObject(obj,input,Int) /* * This sets multiple attributes of the widget. */ void setCDKButtonbox ( CDKBUTTONBOX * /* buttonbox */, chtype /* highlight */, boolean /* Box */); void setCDKButtonboxCurrentButton ( CDKBUTTONBOX * /* buttonbox */, int /* button */); int getCDKButtonboxCurrentButton ( CDKBUTTONBOX * /* buttonbox */); int getCDKButtonboxButtonCount ( CDKBUTTONBOX * /* buttonbox */); /* * This sets the highlight attribute for the buttonbox. */ void setCDKButtonboxHighlight ( CDKBUTTONBOX * /* buttonbox */, chtype /* highlight */); chtype getCDKButtonboxHighlight ( CDKBUTTONBOX * /* buttonbox */); /* * This sets the box attribute of the widget. */ void setCDKButtonboxBox ( CDKBUTTONBOX * /* buttonbox */, boolean /* Box */); boolean getCDKButtonboxBox ( CDKBUTTONBOX * /* buttonbox */); /* * These set the drawing characters of the widget. */ #define setCDKButtonboxULChar(w,c) setULCharOf(w,c) #define setCDKButtonboxURChar(w,c) setURCharOf(w,c) #define setCDKButtonboxLLChar(w,c) setLLCharOf(w,c) #define setCDKButtonboxLRChar(w,c) setLRCharOf(w,c) #define setCDKButtonboxVerticalChar(w,c) setVTCharOf(w,c) #define setCDKButtonboxHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKButtonboxBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKButtonboxBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKButtonboxBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This draws the buttonbox box widget. */ #define drawCDKButtonbox(obj,box) drawCDKObject(obj,box) void drawCDKButtonboxButtons ( CDKBUTTONBOX * /* buttonbox */); /* * This erases the buttonbox box from the screen. */ #define eraseCDKButtonbox(obj) eraseCDKObject(obj) /* * This moves the buttonbox box to a new screen location. */ #define moveCDKButtonbox(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This allows the user to position the widget on the screen interactively. */ #define positionCDKButtonbox(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the widget and all the memory associated with it. */ #define destroyCDKButtonbox(obj) destroyCDKObject(obj) /* * This redraws the buttonbox box buttonboxs. */ void redrawCDKButtonboxButtonboxs ( CDKBUTTONBOX * /* buttonbox */); /* * These set the pre/post process functions of the buttonbox widget. */ #define setCDKButtonboxPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d) #define setCDKButtonboxPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d) #ifdef __cplusplus } #endif #endif /* CDKBUTTONBOX_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/cdkscreen.h0000644000175100001440000001140710355111432015272 0ustar tomusers/* * $Id: cdkscreen.h,v 1.16 2005/12/30 01:53:30 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKSCREEN_H #define CDKSCREEN_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #endif /* * Changes 1999-2004,2005 copyright 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. */ /* * Declare and definitions needed for the widget. */ #define MAX_OBJECTS 1000 /* not used by widgets */ struct CDKOBJS; typedef enum { CDKSCREEN_NOEXIT = 0 , CDKSCREEN_EXITOK , CDKSCREEN_EXITCANCEL } EExitStatus; /* * Define the CDK screen structure. */ struct SScreen { WINDOW * window; struct CDKOBJS ** object; int objectCount; /* last-used index in object[] */ int objectLimit; /* sizeof(object[]) */ EExitStatus exitStatus; int objectFocus; /* focus index in object[] */ }; typedef struct SScreen CDKSCREEN; /* * This function creates a CDKSCREEN pointer. */ CDKSCREEN *initCDKScreen ( WINDOW * /* window */); /* * This sets which CDKSCREEN pointer will be the default screen * in the list of managed screen. */ CDKSCREEN *setDefaultCDKScreen ( int /* screenNumber */); /* * This function registers a CDK widget with a given screen. */ void registerCDKObject ( CDKSCREEN * /* screen */, EObjectType /* cdktype */, void * /* object */); /* * This unregisters a CDK widget from a screen. */ void unregisterCDKObject ( EObjectType /* cdktype */, void * /* object */); /* * This function raises a widget on a screen to the top of the widget * stack of the screen the widget is associated with. The side effect * of doing this is the widget will be on 'top' of all the other * widgets on their screens. */ void raiseCDKObject ( EObjectType /* cdktype */, void * /* object */); /* * This function lowers a widget on a screen to the bottom of the widget * stack of the screen the widget is associated with. The side effect * of doing this is that all the other widgets will be on 'top' of the * widget on their screens. */ void lowerCDKObject ( EObjectType /* cdktype */, void * /* object */); /* * This redraws a window, forcing it to the top of the stack. */ void refreshCDKWindow ( WINDOW * /* win */); /* * This redraws all the widgets associated with the given screen. */ void refreshCDKScreen ( CDKSCREEN * /* screen */); /* * This calls refreshCDKScreen. (it is here to try to be consistent * with the drawCDKXXX functions associated with the widgets) */ void drawCDKScreen ( CDKSCREEN * /* screen */); /* * This removes all the widgets from the screen. */ void eraseCDKScreen ( CDKSCREEN * /* screen */); /* * Destroy all of the widgets on a screen */ void destroyCDKScreenObjects (CDKSCREEN *cdkscreen); /* * This frees up any memory the CDKSCREEN pointer used. */ void destroyCDKScreen ( CDKSCREEN * /* screen */); /* * This shuts down curses and everything else needed to * exit cleanly. */ void endCDK(void); /* * This creates all the color pairs. */ void initCDKColor(void); #ifdef __cplusplus } #endif #endif /* CDKSCREEN_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/traverse.h0000644000175100001440000000610110355104265015165 0ustar tomusers/* * $Id: traverse.h,v 1.9 2005/12/30 01:09:09 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKTRAVERSE_H #define CDKTRAVERSE_H 1 #include "cdk.h" #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Copyright 1999-2004,2005 Thomas E. Dickey * 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 Thomas Dickey * and contributors. * 4. Neither the name of Thomas Dickey, 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 THOMAS DICKEY 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 THOMAS DICKEY 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. */ typedef boolean (*CHECK_KEYCODE)(int /* keyCode */, int /* functionKey */); extern CDKOBJS *getCDKFocusCurrent (CDKSCREEN * /* screen */); extern CDKOBJS *setCDKFocusCurrent (CDKSCREEN * /*screen */, CDKOBJS * /* obj */); extern CDKOBJS *setCDKFocusNext (CDKSCREEN * /* screen */); extern CDKOBJS *setCDKFocusPrevious (CDKSCREEN * /* screen */); extern CDKOBJS *setCDKFocusFirst (CDKSCREEN * /* screen */); extern CDKOBJS *setCDKFocusLast (CDKSCREEN * /* screen */); extern int traverseCDKScreen (CDKSCREEN * /* screen */); extern void exitCancelCDKScreen (CDKSCREEN * /* screen */); extern void exitCancelCDKScreenOf (CDKOBJS * /* obj */); extern void exitOKCDKScreen (CDKSCREEN * /* screen */); extern void exitOKCDKScreenOf (CDKOBJS * /* obj */); extern void resetCDKScreen (CDKSCREEN * /* screen */); extern void resetCDKScreenOf (CDKOBJS * /* obj */); extern void traverseCDKOnce (CDKSCREEN * /*screen */, CDKOBJS * /*curobj */, int /* keyCode */, boolean /* functionKey */, CHECK_KEYCODE /*funcMenuKey */); #endif /* CDKTRAVERSE_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/cdk_objs.h0000644000175100001440000003105510355074053015117 0ustar tomusers/* * $Id: cdk_objs.h,v 1.37 2005/12/29 23:58:35 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDK_OBJS_H #define CDK_OBJS_H #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #endif /* * Copyright 1999-2004,2005 Thomas E. Dickey * 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 Thomas Dickey * and contributors. * 4. Neither the name of Thomas Dickey, 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 THOMAS DICKEY 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 THOMAS DICKEY 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. */ typedef struct CDKBINDING { BINDFN bindFunction; void * bindData; PROCESSFN callbackfn; } CDKBINDING; struct CDKOBJS; /* * Types for CDKFUNCS.returnType */ typedef enum { DataTypeUnknown = 0 , DataTypeString , DataTypeInt , DataTypeFloat , DataTypeDouble , DataTypeUnsigned } CDKDataType; typedef union { char * valueString; int valueInt; float valueFloat; double valueDouble; unsigned valueUnsigned; } CDKDataUnion; #define unknownString (char *)0 #define unknownInt (-1) #define unknownFloat (0.0) #define unknownDouble (0.0) #define unknownUnsigned (0) /* * Methods common to all widgets. */ typedef struct CDKFUNCS { EObjectType objectType; CDKDataType returnType; void (*drawObj) (struct CDKOBJS *, boolean); void (*eraseObj) (struct CDKOBJS *); void (*moveObj) (struct CDKOBJS *, int, int, boolean, boolean); int (*injectObj) (struct CDKOBJS *, chtype); void (*focusObj) (struct CDKOBJS *); void (*unfocusObj) (struct CDKOBJS *); void (*saveDataObj) (struct CDKOBJS *); void (*refreshDataObj) (struct CDKOBJS *); void (*destroyObj) (struct CDKOBJS *); /* line-drawing */ void (*setULcharObj) (struct CDKOBJS *, chtype); void (*setURcharObj) (struct CDKOBJS *, chtype); void (*setLLcharObj) (struct CDKOBJS *, chtype); void (*setLRcharObj) (struct CDKOBJS *, chtype); void (*setVTcharObj) (struct CDKOBJS *, chtype); void (*setHZcharObj) (struct CDKOBJS *, chtype); void (*setBXattrObj) (struct CDKOBJS *, chtype); /* background attribute */ void (*setBKattrObj) (struct CDKOBJS *, chtype); } CDKFUNCS; /* The cast is needed because traverse.c wants to use CDKOBJS pointers */ #define ObjPtr(p) ((CDKOBJS*)(p)) #define MethodPtr(p,m) ((ObjPtr(p))->fn->m) /* Use these when we're certain it is a CDKOBJS pointer */ #define ObjTypeOf(p) MethodPtr(p,objectType) #define DataTypeOf(p) MethodPtr(p,returnType) #define DrawObj(p) MethodPtr(p,drawObj) (p,p->box) #define EraseObj(p) MethodPtr(p,eraseObj) (p) #define DestroyObj(p) MethodPtr(p,destroyObj) (p) #define InjectObj(p,k) MethodPtr(p,injectObj) (p,(k)) #define InputWindowObj(p) MethodPtr(p,inputWindowObj) (p) #define FocusObj(p) MethodPtr(p,focusObj) (p) #define UnfocusObj(p) MethodPtr(p,unfocusObj) (p) #define SaveDataObj(p) MethodPtr(p,saveDataObj) (p) #define RefreshDataObj(p) MethodPtr(p,refreshDataObj) (p) #define SetBackAttrObj(p,c) MethodPtr(p,setBKattrObj) (p,c) #define AcceptsFocusObj(p) (ObjPtr(p)->acceptsFocus) #define HasFocusObj(p) (ObjPtr(p)->hasFocus) #define IsVisibleObj(p) (ObjPtr(p)->isVisible) #define InputWindowOf(p) (ObjPtr(p)->inputWindow) /* * Data common to all objects (widget instances). This appears first in * each widget's struct to allow us to use generic functions in binding.c, * cdkscreen.c, position.c, etc. */ typedef struct CDKOBJS { int screenIndex; CDKSCREEN * screen; const CDKFUNCS * fn; boolean box; int borderSize; boolean acceptsFocus; boolean hasFocus; boolean isVisible; WINDOW * inputWindow; void * dataPtr; CDKDataUnion resultData; unsigned bindingCount; CDKBINDING * bindingList; /* title-drawing */ chtype ** title; int * titlePos; int * titleLen; int titleLines; /* line-drawing (see 'box') */ chtype ULChar; /* lines: upper-left */ chtype URChar; /* lines: upper-right */ chtype LLChar; /* lines: lower-left */ chtype LRChar; /* lines: lower-right */ chtype VTChar; /* lines: vertical */ chtype HZChar; /* lines: horizontal */ chtype BXAttr; /* events */ EExitType exitType; EExitType earlyExit; /* pre/post-processing */ PROCESSFN preProcessFunction; void * preProcessData; PROCESSFN postProcessFunction; void * postProcessData; } CDKOBJS; #define ObjOf(ptr) (&(ptr)->obj) #define MethodOf(ptr) (ObjOf(ptr)->fn) #define ScreenOf(ptr) (ObjOf(ptr)->screen) #define WindowOf(ptr) (ScreenOf(ptr)->window) #define BorderOf(p) (ObjOf(p)->borderSize) #define ResultOf(p) (ObjOf(p)->resultData) #define ExitTypeOf(p) (ObjOf(p)->exitType) #define EarlyExitOf(p) (ObjOf(p)->earlyExit) /* titles */ #define TitleOf(w) ObjOf(w)->title #define TitlePosOf(w) ObjOf(w)->titlePos #define TitleLenOf(w) ObjOf(w)->titleLen #define TitleLinesOf(w) ObjOf(w)->titleLines /* line-drawing characters */ #define ULCharOf(w) ObjOf(w)->ULChar #define URCharOf(w) ObjOf(w)->URChar #define LLCharOf(w) ObjOf(w)->LLChar #define LRCharOf(w) ObjOf(w)->LRChar #define VTCharOf(w) ObjOf(w)->VTChar #define HZCharOf(w) ObjOf(w)->HZChar #define BXAttrOf(w) ObjOf(w)->BXAttr #define setULCharOf(o,c) MethodOf(o)->setULcharObj(ObjOf(o),c) #define setURCharOf(o,c) MethodOf(o)->setURcharObj(ObjOf(o),c) #define setLLCharOf(o,c) MethodOf(o)->setLLcharObj(ObjOf(o),c) #define setLRCharOf(o,c) MethodOf(o)->setLRcharObj(ObjOf(o),c) #define setVTCharOf(o,c) MethodOf(o)->setVTcharObj(ObjOf(o),c) #define setHZCharOf(o,c) MethodOf(o)->setHZcharObj(ObjOf(o),c) #define setBXAttrOf(o,c) MethodOf(o)->setBXattrObj(ObjOf(o),c) #define setBKAttrOf(o,c) MethodOf(o)->setBKattrObj(ObjOf(o),c) /* pre/post-processing */ #define PreProcessFuncOf(w) (ObjOf(w)->preProcessFunction) #define PreProcessDataOf(w) (ObjOf(w)->preProcessData) #define PostProcessFuncOf(w) (ObjOf(w)->postProcessFunction) #define PostProcessDataOf(w) (ObjOf(w)->postProcessData) /* FIXME - remove this */ #define ReturnOf(p) (ObjPtr(p)->dataPtr) bool validCDKObject (CDKOBJS *); void * _newCDKObject(unsigned, const CDKFUNCS *); #define newCDKObject(type,funcs) (type *)_newCDKObject(sizeof(type),funcs) void _destroyCDKObject (CDKOBJS *); #define destroyCDKObject(o) _destroyCDKObject(ObjOf(o)) /* Use these for widgets that have an obj member which is a CDKOBJS struct */ #define drawCDKObject(o,box) MethodOf(o)->drawObj (ObjOf(o),box) #define eraseCDKObject(o) MethodOf(o)->eraseObj (ObjOf(o)) #define moveCDKObject(o,x,y,rel,ref) MethodOf(o)->moveObj (ObjOf(o),x,y,rel,ref) #define injectCDKObject(o,c,type) (MethodOf(o)->injectObj (ObjOf(o),c) ? ResultOf(o).value ## type : unknown ## type) /* functions to set line-drawing are bound to cdk_objs.c if the widget is * simple, but are built into the widget for complex widgets. */ #define DeclareSetXXchar(storage,line) \ storage void line ## ULchar(struct CDKOBJS *, chtype); \ storage void line ## URchar(struct CDKOBJS *, chtype); \ storage void line ## LLchar(struct CDKOBJS *, chtype); \ storage void line ## LRchar(struct CDKOBJS *, chtype); \ storage void line ## VTchar(struct CDKOBJS *, chtype); \ storage void line ## HZchar(struct CDKOBJS *, chtype); \ storage void line ## BXattr(struct CDKOBJS *, chtype) DeclareSetXXchar(extern,setCdk); #define DeclareCDKObjects(upper, mixed, line, type) \ static int _injectCDK ## mixed (struct CDKOBJS *, chtype); \ static void _destroyCDK ## mixed (struct CDKOBJS *); \ static void _drawCDK ## mixed (struct CDKOBJS *, boolean); \ static void _eraseCDK ## mixed (struct CDKOBJS *); \ static void _focusCDK ## mixed (struct CDKOBJS *); \ static void _moveCDK ## mixed (struct CDKOBJS *, int, int, boolean, boolean); \ static void _refreshDataCDK ## mixed (struct CDKOBJS *); \ static void _saveDataCDK ## mixed (struct CDKOBJS *); \ static void _unfocusCDK ## mixed (struct CDKOBJS *); \ static void _setBKattr ## mixed (struct CDKOBJS *, chtype); \ static const CDKFUNCS my_funcs = { \ v ## upper, \ DataType ## type, \ _drawCDK ## mixed, \ _eraseCDK ## mixed, \ _moveCDK ## mixed, \ _injectCDK ## mixed, \ _focusCDK ## mixed, \ _unfocusCDK ## mixed, \ _saveDataCDK ## mixed, \ _refreshDataCDK ## mixed, \ _destroyCDK ## mixed, \ line ## ULchar, \ line ## URchar, \ line ## LLchar, \ line ## LRchar, \ line ## VTchar, \ line ## HZchar, \ line ## BXattr, \ _setBKattr ## mixed, \ } /* * Some methods are unused. Define macros to represent dummy methods * to make it simple to maintain them. */ #define dummyInject(mixed) \ static int _injectCDK ## mixed (CDKOBJS * object GCC_UNUSED, chtype input GCC_UNUSED) \ { \ return 0; \ } #define dummyFocus(mixed) \ static void _focusCDK ## mixed (CDKOBJS * object GCC_UNUSED) \ { \ } #define dummyUnfocus(mixed) \ static void _unfocusCDK ## mixed (CDKOBJS * object GCC_UNUSED) \ { \ } #define dummySaveData(mixed) \ static void _saveDataCDK ## mixed (CDKOBJS * object GCC_UNUSED) \ { \ } #define dummyRefreshData(mixed) \ static void _refreshDataCDK ## mixed (CDKOBJS * object GCC_UNUSED) \ { \ } /* * Read keycode from object, optionally translating bindings. * Depcrecated: use getchCDKObject(). */ extern int getcCDKObject ( CDKOBJS * /* object */); /* * Read keycode from object, optionally translating bindings. Set a flag to * tell if the keycode is a function key. */ extern int getchCDKObject ( CDKOBJS * /* object */, boolean * /* functionKey */); /* * Interactively reposition an object within a window. */ extern void positionCDKObject ( CDKOBJS * /* object */, WINDOW * /* win */); /* * Pre/postprocessing. */ extern void setCDKObjectPreProcess ( CDKOBJS * /* object */, PROCESSFN /* func */, void * /* data */); extern void setCDKObjectPostProcess ( CDKOBJS * /* object */, PROCESSFN /* func */, void * /* data */); /* * Background color. */ extern void setCDKObjectBackgroundColor ( CDKOBJS * /* object */, char * /* color */); /* title-storage is implemented identically with all widgets */ extern int setCdkTitle (CDKOBJS *, char *, int); extern void drawCdkTitle (WINDOW *, CDKOBJS *); extern void cleanCdkTitle (CDKOBJS *); #define setCdkEarlyExit(p,q) EarlyExitOf(p) = q extern void setCdkExitType( CDKOBJS * /* obj */, EExitType * /* type */, chtype /* ch */); #ifdef __cplusplus } #endif #endif /* CDK_OBJS_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/cdk_util.h0000644000175100001440000002252210422453434015135 0ustar tomusers/* * $Id: cdk_util.h,v 1.28 2006/04/22 16:17:32 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKUTIL_H #define CDKUTIL_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #endif /* * Changes 1999-2005,2006 copyright 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. */ /* * This beeps at the user. The standard curses beep() does not * flush the stream, so it will only beep until a force is made. * This forces a flush after issuing the beep command. */ void Beep(void); /* * This aligns a 'box' on the given window with the height and * width given. */ void alignxy ( WINDOW * /* window */, int * /* xpos */, int * /* ypos */, int /* boxWidth */, int /* boxHeight */); /* * This takes a string, a field width and a justification type and returns the * justification adjustment to make, to fill the justification requirement. */ int justifyString ( int /* fieldWidth */, int /* mesglen */, int /* justify */); /* * This is a quick little popup label widget. */ void popupLabel ( CDKSCREEN * /* win */, char ** /* mesg */, int /* count */); /* * This is a quick little popup label widget. */ void popupLabelAttrib ( CDKSCREEN * /* win */, char ** /* mesg */, int /* count */, chtype /* attribute */); /* * This is a quick little popup dialog box. */ int popupDialog ( CDKSCREEN * /* screen */, char ** /* mesg */, int /* mesgCount */, char ** /* buttons */, int /* buttonCount */); /* * This pops up a scrolling list and returns the value selected. */ int getListIndex ( CDKSCREEN * /* screen */, char * /* title */, char ** /* list */, int /* listSize */, boolean /* numbers */); /* * This gets a simple string value from a user. */ char *getString ( CDKSCREEN * /* screen */, char * /* title */, char * /* label */, char * /* init */); /* * This allows a user to view a file. */ int viewFile ( CDKSCREEN * /* screen */, char * /* title */, char * /* filename */, char ** /* buttons */, int /* buttonCount */); /* * This allows a person to select a file. */ char *selectFile ( CDKSCREEN * /* screen */, char * /* title */); /* * This allows people to view information in an array. */ int viewInfo ( CDKSCREEN * /* screen */, char * /* title */, char ** /* info */, int /* size */, char ** /* buttons */, int /* buttonCount */, boolean /* interpret */); /* * This is a wrapper for qsort. */ void sortList ( char ** /* list */, int /* length */); /* * This reads a file, loads the contents into info and * returns the number of lines read. */ int CDKreadFile ( char * /* filename */, char *** /* info */); /* * This strips white space from the front/back of the given * string. The stripType is one of: vFRONT, vBACK, vBOTH. */ void stripWhiteSpace ( EStripType /* stripType */, char * /* string */); /* * These functions are used to manage a string which is split into parts, e.g., * a file which is read into memory. */ char **CDKsplitString( char * /* string */, int /* separator */); unsigned CDKallocStrings( char *** /* list */, char * /* item */, unsigned /* length */, unsigned /* used */); unsigned CDKcountStrings( char ** /* list */); void CDKfreeStrings( char ** /* list */); /* * Free a list of chtype-strings, terminated by a null pointer. */ void CDKfreeChtypes( chtype ** /* list */); /* * This returns the length of an integer. */ int intlen ( int /* value */); /* * This opens the given directory and reads in the contents. It stores * the results in 'list' and returns the number of elements found. */ int CDKgetDirectoryContents ( char * /* directory */, char *** /* list */); /* * This looks for the given pattern in the given list. */ int searchList ( char ** /* list */, int /* listSize */, char * /* pattern */); /* * This returns the basename of a file. */ char *baseName ( char * /* filename */); /* * This returns the directory name of a file. */ char *dirName ( char * /* filename */); /* * This frees the memory used by the given string. */ void freeChar ( char * /* string */); /* * This frees the memory used by the given string. */ void freeChtype ( chtype * /* string */); /* * This frees the memory used by the given list of strings. */ void freeCharList ( char ** /* list */, unsigned /* size */); /* * This frees the memory used by the given list of strings. */ void freeChtypeList ( chtype ** /* list */, unsigned /* size */); /* * This sets the elements of the given string to 'character' */ void cleanChar ( char * /* string */, int /* length */, char /* character */); /* * This sets the elements of the given string to 'character' */ void cleanChtype ( chtype * /* string */, int /* length */, chtype /* character */); /* * This takes a chtype pointer and returns a char pointer. */ char *chtype2Char ( chtype * /* string */); /* * This takes a chtype pointer and returns a char pointer with embedded * formatting information. */ char *chtype2String ( chtype * /* string */); /* * This takes a char pointer and returns a chtype pointer. */ chtype *char2Chtype ( char * /* string */, int * /* length */, int * /* align */); /* * Compare a char string to a chtype string */ int cmpStrChstr(char * /* str */, chtype * /* chstr */); /* * Copy from a chtype string to a char string */ void chstrncpy(char * /* dest */, chtype * /* src */, int /* maxcount */); /* * Given a character pointer, returns the equivalent display type. */ EDisplayType char2DisplayType ( char * /* string */); /* * Tell if a display type is "hidden" */ boolean isHiddenDisplayType ( EDisplayType /* type */); /* * Filter an input character according to the display type. */ int filterByDisplayType( EDisplayType /* type */, chtype /* input */); /* * Copy the given string. */ chtype *copyChtype ( chtype * /* string */); /* * Copy the given string. */ char *copyChar ( char * /* string */); /* * Copy the given list. */ char **copyCharList ( char ** /* list */); /* * Copy the given list. */ chtype **copyChtypeList ( chtype ** /* list */); /* * Return the length of the given string. */ int chlen ( chtype * /* string */); /* * Return the length of the given list. */ int lenCharList ( char ** /* list */); int lenChtypeList ( chtype ** /* list */); /* * This takes a file mode and returns the first character of the file * permissions string. */ int mode2Filetype ( mode_t /* fileMode */); /* * This takes a file mode and stores the character representation * of the mode in 'string'. This also returns the octal value * of the file mode. */ int mode2Char ( char * /* string */, mode_t /* fileMode */); /* * This looks for a link. (used by the pattern) */ int checkForLink ( char * /* line */, char * /* filename */); /* * This function help set the height/width values of a widget. */ int setWidgetDimension ( int /* parentDim */, int /* proposedDim */, int /* adjustment */); /* * This safely erases a given window. */ void eraseCursesWindow ( WINDOW * /* window */); /* * This safely deletes a given window. */ void deleteCursesWindow ( WINDOW * /* window */); /* * This moves a given window */ void moveCursesWindow ( WINDOW * /* window */, int /* xdiff */, int /* ydiff */); /* * Return an integer like 'floor()', which returns a double. */ int floorCDK(double); /* * Return an integer like 'ceil()', which returns a double. */ int ceilCDK(double); #ifdef __cplusplus } #endif #endif /* CDKUTIL_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/alphalist.h0000644000175100001440000001456010422751774015333 0ustar tomusers/* * $Id: alphalist.h,v 1.23 2006/04/23 19:22:36 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKALPHALIST_H #define CDKALPHALIST_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 1999-2005,2006 copyright 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. */ #include #include /* * Define the CDK alphalist widget structure. */ struct SAlphalist { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * shadowWin; CDKENTRY * entryField; CDKSCROLL * scrollField; char ** list; int listSize; int xpos; int ypos; int height; int width; int boxHeight; int boxWidth; chtype highlight; chtype fillerChar; boolean shadow; EExitType exitType; }; typedef struct SAlphalist CDKALPHALIST; /* * This creates a pointer to a new CDK alphalist widget. */ CDKALPHALIST *newCDKAlphalist ( CDKSCREEN * /* cdkscreen */, int /* xpos */, int /* ypos */, int /* height */, int /* width */, char * /* title */, char * /* label */, char ** /* list */, int /* listSize */, chtype /* fillerChar */, chtype /* highlight */, boolean /* Box */, boolean /* shadow */); /* * This allows the user to interact with the widget. */ char *activateCDKAlphalist ( CDKALPHALIST * /* alphalist */, chtype * /* actions */); /* * This injects a single character into the widget. */ #define injectCDKAlphalist(obj,input) injectCDKObject(obj,input,String) /* * This sets multiple attributes of the alphalist widget. */ void setCDKAlphalist ( CDKALPHALIST * /* alphalist */, char ** /* list */, int /* listSize */, chtype /* fillerChar */, chtype /* highlight */, boolean /* Box */); /* * This sets the contents of the alpha list. */ void setCDKAlphalistContents ( CDKALPHALIST * /* alphalist */, char ** /* list */, int /* listSize */); char **getCDKAlphalistContents ( CDKALPHALIST * /* alphalist */, int * /* size */); /* * Get/set the current position in the scroll-widget. */ int getCDKAlphalistCurrentItem( CDKALPHALIST * /* widget */); void setCDKAlphalistCurrentItem( CDKALPHALIST * /* widget */, int /* item */); /* * This sets the filler character of the entry field of the alphalist. */ void setCDKAlphalistFillerChar ( CDKALPHALIST * /* alphalist */, chtype /* fillerCharacter */); chtype getCDKAlphalistFillerChar ( CDKALPHALIST * /* alphalist */); /* * This sets the highlight bar attributes. */ void setCDKAlphalistHighlight ( CDKALPHALIST * /* alphalist */, chtype /* highlight */); chtype getCDKAlphalistHighlight ( CDKALPHALIST * /* alphalist */); /* * This sets the box attribute of the widget. */ void setCDKAlphalistBox ( CDKALPHALIST * /* alphalist */, boolean /* Box */); boolean getCDKAlphalistBox ( CDKALPHALIST * /* alphalist */); /* * These functions set the drawing characters of the widget. */ #define setCDKAlphalistULChar(w,c) setULCharOf(w,c) #define setCDKAlphalistURChar(w,c) setURCharOf(w,c) #define setCDKAlphalistLLChar(w,c) setLLCharOf(w,c) #define setCDKAlphalistLRChar(w,c) setLRCharOf(w,c) #define setCDKAlphalistVerticalChar(w,c) setVTCharOf(w,c) #define setCDKAlphalistHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKAlphalistBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKAlphalistBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKAlphalistBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This draws the widget on the screen. */ #define drawCDKAlphalist(obj,box) drawCDKObject(obj,box) /* * This removes the widget from the screen. */ #define eraseCDKAlphalist(obj) eraseCDKObject(obj) /* * This moves the widget to the location specified. */ #define moveCDKAlphalist(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This allows the user to interactively position the widget. */ #define positionCDKAlphalist(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the widget and all the memory associated with it. */ #define destroyCDKAlphalist(obj) destroyCDKObject(obj) /* * These functions set the pre and post process functions for the widget. */ void setCDKAlphalistPreProcess ( CDKALPHALIST * /* alphalist */, PROCESSFN /* callback */, void * /* data */); void setCDKAlphalistPostProcess ( CDKALPHALIST * /* alphalist */, PROCESSFN /* callback */, void * /* data */); #ifdef __cplusplus } #endif #endif /* CDKALPHALIST_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/scroll.h0000644000175100001440000001626310426362154014644 0ustar tomusers/* * $Id: scroll.h,v 1.30 2006/05/04 11:24:28 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKSCROLL_H #define CDKSCROLL_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #endif /* * Changes 1999-2005,2006 copyright 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. */ /* * Declare scrolling list definitions. */ #define NUMBERS TRUE #define NONUMBERS FALSE /* * Declare scrolling list definitions. */ struct SScroll { CDKOBJS obj; WINDOW *parent; WINDOW *win; WINDOW *scrollbarWin; WINDOW *listWin; WINDOW *shadowWin; int titleAdj; /* unused */ chtype ** item; /* */ int * itemPos; /* */ int * itemLen; /* */ int maxTopItem; /* */ int maxLeftChar; /* */ int leftChar; /* */ int lastItem; /* */ int currentTop; /* */ int currentItem; /* */ int currentHigh; /* */ int listSize; /* */ int boxWidth; /* */ int boxHeight; /* */ int viewSize; /* */ int scrollbarPlacement; /* UNUSED */ boolean scrollbar; /* UNUSED */ int toggleSize; /* size of scrollbar thumb/toggle */ int togglePos; /* position of scrollbar thumb/toggle */ float step; /* increment for scrollbar */ EExitType exitType; /* */ boolean shadow; /* */ boolean numbers; /* */ chtype titlehighlight; /* */ chtype highlight; /* */ }; typedef struct SScroll CDKSCROLL; /* * This creates a new CDK scrolling list pointer. */ CDKSCROLL *newCDKScroll ( CDKSCREEN * /* cdkscreen */, int /* xpos */, int /* ypos */, int /* spos */, int /* height */, int /* width */, char * /* title */, char ** /* itemList */, int /* items */, boolean /* numbers */, chtype /* highlight */, boolean /* Box */, boolean /* shadow */); /* * This activates the scrolling list. */ int activateCDKScroll ( CDKSCROLL * /* scroll */, chtype * /* actions */); /* * This injects a single character into the scrolling list. */ #define injectCDKScroll(obj,input) injectCDKObject(obj,input,Int) /* * This sets various attributes of the scrolling list. */ void setCDKScroll ( CDKSCROLL * /* scroll */, char ** /* itemList */, int /* items */, boolean /* numbers */, chtype /* highlight */, boolean /* Box */); void setCDKScrollPosition ( CDKSCROLL * /* scroll */, int /* item */); int getCDKScrollCurrent( CDKSCROLL * /* scroll */); void setCDKScrollCurrent( CDKSCROLL * /* scroll */, int /* i */); int getCDKScrollCurrentTop( CDKSCROLL * /* scroll */); void setCDKScrollCurrentTop( CDKSCROLL * /* scroll */, int /* i */); int getCDKScrollCurrentItem( CDKSCROLL * /* scroll */); void setCDKScrollCurrentItem( CDKSCROLL * /* scroll */, int /* i */); /* * This sets the contents of the scrolling list. */ void setCDKScrollItems ( CDKSCROLL * /* scroll */, char ** /* itemList */, int /* items */, boolean /* numbers */); int getCDKScrollItems ( CDKSCROLL * /* scroll */, char ** /* itemList */); /* * This sets the highlight bar of the scrolling list. */ void setCDKScrollHighlight ( CDKSCROLL * /* scroll */, chtype /* highlight */); chtype getCDKScrollHighlight ( CDKSCROLL * /* scroll */, chtype /* highlight */); /* * This sets the box attribute of the widget. */ void setCDKScrollBox ( CDKSCROLL * /* scroll */, boolean /* Box */); boolean getCDKScrollBox ( CDKSCROLL * /* scroll */); /* * These set the drawing characters of the widget. */ #define setCDKScrollULChar(w,c) setULCharOf(w,c) #define setCDKScrollURChar(w,c) setURCharOf(w,c) #define setCDKScrollLLChar(w,c) setLLCharOf(w,c) #define setCDKScrollLRChar(w,c) setLRCharOf(w,c) #define setCDKScrollVerticalChar(w,c) setVTCharOf(w,c) #define setCDKScrollHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKScrollBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKScrollBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKScrollBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This adds a single item to the end of scrolling list. */ void addCDKScrollItem ( CDKSCROLL * /* scroll */, char * /* item */); /* * This adds a single item into the scrolling list. */ void insertCDKScrollItem ( CDKSCROLL * /* scroll */, char * /* item */); /* * This deletes a single item from the scrolling list. */ void deleteCDKScrollItem ( CDKSCROLL * /* scroll */, int /* position */); /* * This draws the scrolling list on the screen. */ #define drawCDKScroll(obj,Box) drawCDKObject(obj,Box) /* * This removes the scrolling list from the screen. */ #define eraseCDKScroll(obj) eraseCDKObject(obj) /* * This moves the widget to the given location. */ #define moveCDKScroll(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This allows the user to interactively position the widget on the screen. */ #define positionCDKScroll(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the widget and all associated memory. */ #define destroyCDKScroll(obj) destroyCDKObject(obj) /* * These set the scrolling list pre/post process functions. */ #define setCDKScrollPreProcess(w,f,d) setCDKObjectPreProcess(ObjOf(w),f,d) #define setCDKScrollPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d) #ifdef __cplusplus } #endif #endif /* CDKSCROLL_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/include/fselect.h0000644000175100001440000002030510426347537014773 0ustar tomusers/* * $Id: fselect.h,v 1.23 2006/05/04 09:54:39 tom Exp $ */ #ifndef CDKINCLUDES #ifndef CDKFSELECT_H #define CDKFSELECT_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef CDK_H #define CDKINCLUDES #include #undef CDKINCLUDES #include #include #include #include #include #endif /* * Changes 1999-2003,2006 copyright 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. */ /* * Define the CDK file selector widget structure. */ struct SFileSelector { CDKOBJS obj; WINDOW * parent; WINDOW * win; WINDOW * shadowWin; CDKENTRY * entryField; CDKSCROLL * scrollField; char ** dirContents; int fileCounter; char * pwd; char * pathname; int xpos; int ypos; int boxHeight; int boxWidth; chtype fieldAttribute; chtype fillerCharacter; chtype highlight; char * dirAttribute; char * fileAttribute; char * linkAttribute; char * sockAttribute; EExitType exitType; boolean shadow; }; typedef struct SFileSelector CDKFSELECT; /* * This creates a new CDK file selector widget. */ CDKFSELECT *newCDKFselect ( CDKSCREEN * /* cdkscreen */, int /* xpos */, int /* ypos */, int /* height */, int /* width */, char * /* title */, char * /* label */, chtype /* fieldAttribute */, chtype /* fillerChar */, chtype /* highlight */, char * /* dirAttributes */, char * /* fileAttributes */, char * /* linkAttribute */, char * /* sockAttribute */, boolean /* Box */, boolean /* shadow */); /* * This activates the file selector. */ char *activateCDKFselect ( CDKFSELECT * /* fselect */, chtype * /* actions */); /* * This injects a single character into the widget. */ #define injectCDKFselect(obj,input) injectCDKObject(obj,input,String) /* * This sets various attributes of the file selector. */ void setCDKFselect ( CDKFSELECT * /* fselect */, char * /* directory */, chtype /* fieldAttrib */, chtype /* filler */, chtype /* highlight */, char * /* dirAttribute */, char * /* fileAttribute */, char * /* linkAttribute */, char * /* sockAttribute */, boolean /* Box */); /* * This sets the current directory of the file selector. */ int setCDKFselectDirectory ( CDKFSELECT * /* fselect */, char * /* directory */); char *getCDKFselectDirectory ( CDKFSELECT * /* fselect */); /* * This sets the filler character of the entry field. */ void setCDKFselectFillerChar ( CDKFSELECT * /* fselect */, chtype /* fillerCharacter */); chtype getCDKFselectFillerChar ( CDKFSELECT * /* fselect */); /* * This sets the highlight bar of the scrolling list. */ void setCDKFselectHighlight ( CDKFSELECT * /* fselect */, chtype /* highlight */); chtype getCDKFselectHighlight ( CDKFSELECT * /* fselect */); /* * These functions set the attribute of the directories, links, * files, and sockets in the scrolling list portion of the file * selector widget. */ void setCDKFselectDirAttribute ( CDKFSELECT * /* fselect */, char * /* attribute */); void setCDKFselectLinkAttribute ( CDKFSELECT * /* fselect */, char * /* attribute */); void setCDKFselectFileAttribute ( CDKFSELECT * /* fselect */, char * /* attribute */); void setCDKFselectSocketAttribute ( CDKFSELECT * /* fselect */, char * /* attribute */); /* * These functions return the attribute of the directories, links, * files, and sockets in the scrolling list portion of the file * selector widget. */ char *getCDKFselectDirAttribute ( CDKFSELECT * /* fselect */); char *getCDKFselectLinkAttribute ( CDKFSELECT * /* fselect */); char *getCDKFselectFileAttribute ( CDKFSELECT * /* fselect */); char *getCDKFselectSocketAttribute ( CDKFSELECT * /* fselect */); /* * This sets the box attribute of the widget. */ void setCDKFselectBox ( CDKFSELECT * /* fselect */, boolean /* Box */); boolean getCDKFselectBox ( CDKFSELECT * /* fselect */); /* * This sets the contents of the file selector. */ int setCDKFselectDirContents ( CDKFSELECT * /* fselect */); char **getCDKFselectDirContents ( CDKFSELECT * /* fselect */, int * /* count */); /* * This sets the contents of the file selector. */ void setCDKFselectContents ( CDKFSELECT * /* fselect */, char ** /* list */, int /* listSize */); char **getCDKFselectContents ( CDKFSELECT * /* fselect */, int * /* size */); /* * Get/set the current position in the scroll-widget. */ int getCDKFselectCurrentItem( CDKFSELECT * /* widget */); void setCDKFselectCurrentItem( CDKFSELECT * /* widget */, int /* item */); /* * These functions set the drawing characters of the widget. */ #define setCDKFselectULChar(w,c) setULCharOf(w,c) #define setCDKFselectURChar(w,c) setURCharOf(w,c) #define setCDKFselectLLChar(w,c) setLLCharOf(w,c) #define setCDKFselectLRChar(w,c) setLRCharOf(w,c) #define setCDKFselectVerticalChar(w,c) setVTCharOf(w,c) #define setCDKFselectHorizontalChar(w,c) setHZCharOf(w,c) #define setCDKFselectBoxAttribute(w,c) setBXAttrOf(w,c) /* * This sets the background color of the widget. */ #define setCDKFselectBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) /* * This sets the background attribute of the widget. */ #define setCDKFselectBackgroundAttrib(w,c) setBKAttrOf(w,c) /* * This draws the widget. */ #define drawCDKFselect(obj,Box) drawCDKObject(obj,Box) /* * This erases the widget. */ #define eraseCDKFselect(obj) eraseCDKObject(obj) /* * This moves the widget to the given location. */ #define moveCDKFselect(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) /* * This allows the user to interactively position the widget. */ #define positionCDKFselect(widget) positionCDKObject(ObjOf(widget),widget->win) /* * This destroys the widget and all the associated memory. */ #define destroyCDKFselect(obj) destroyCDKObject(obj) /* * This is a callback which allows you to delete files from within the * file selector. It is NOT an active default: it MUST be set by the * user. */ void deleteFileCB ( EObjectType /* objectType */, void * /* object */, void * /* clientData */); /* * This function sets the pre-process function. */ void setCDKFselectPreProcess ( CDKFSELECT * /* fselect */, PROCESSFN /* callback */, void * /* data */); /* * This function sets the post-process function. */ void setCDKFselectPostProcess ( CDKFSELECT * /* fselect */, PROCESSFN /* callback */, void * /* data */); #ifdef __cplusplus } #endif #endif /* CDKFSELECT_H */ #endif /* CDKINCLUDES */ cdk-5.0-20060507/install-sh0000755000175100001440000001266307314654055013564 0ustar tomusers#! /bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else : fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=$mkdirprog fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then : else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else : fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else : fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else : fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else : fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 cdk-5.0-20060507/itemlist.c0000644000175100001440000004354710426516000013544 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:27:44 $ * $Revision: 1.79 $ */ static int createList (CDKITEMLIST *itemlist, char **item, int count); static int createFieldWin (CDKITEMLIST *itemlist, int ypos, int xpos); static int maximumFieldWidth (CDKITEMLIST *itemlist); static void updateFieldWidth (CDKITEMLIST *itemlist); DeclareCDKObjects(ITEMLIST, Itemlist, setCdk, Int); /* * This creates a pointer to an itemlist widget. */ CDKITEMLIST *newCDKItemlist (CDKSCREEN *cdkscreen, int xplace, int yplace, char *title, char *label, char **item, int count, int defaultItem, boolean Box, boolean shadow) { /* Set up some variables. */ CDKITEMLIST *itemlist = 0; int parentWidth = getmaxx(cdkscreen->window); int parentHeight = getmaxy(cdkscreen->window); int boxWidth = 0; int boxHeight; int fieldWidth = 0; int xpos = xplace; int ypos = yplace; int junk; if ((itemlist = newCDKObject(CDKITEMLIST, &my_funcs)) == 0 || !createList(itemlist, item, count)) { destroyCDKObject (itemlist); return (0); } setCDKItemlistBox (itemlist, Box); boxHeight = (BorderOf(itemlist) * 2) + 1; /* Set some basic values of the itemlist. */ itemlist->label = 0; itemlist->labelLen = 0; itemlist->labelWin = 0; /* Translate the label char *pointer to a chtype pointer. */ if (label != 0) { itemlist->label = char2Chtype (label, &itemlist->labelLen, &junk); } /* * Set the box width. Allow an extra char in field width for cursor */ fieldWidth = maximumFieldWidth (itemlist) + 1; boxWidth = fieldWidth + itemlist->labelLen + 2 * BorderOf(itemlist); boxWidth = setCdkTitle(ObjOf(itemlist), title, boxWidth); boxHeight += TitleLinesOf(itemlist); /* * Make sure we didn't extend beyond the dimensions of the window. */ itemlist->boxWidth = MINIMUM(boxWidth, parentWidth); itemlist->boxHeight = MINIMUM(boxHeight, parentHeight); updateFieldWidth (itemlist); /* Rejustify the x and y positions if we need to. */ alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight); /* Make the window. */ itemlist->win = newwin(boxHeight, boxWidth, ypos, xpos); if (itemlist->win == 0) { destroyCDKObject (itemlist); return (0); } /* Make the label window if there was a label. */ if (itemlist->label != 0) { itemlist->labelWin = subwin (itemlist->win, 1, itemlist->labelLen, ypos + BorderOf(itemlist) + TitleLinesOf(itemlist), xpos + BorderOf(itemlist)); if (itemlist->labelWin == 0) { destroyCDKObject (itemlist); return (0); } } keypad (itemlist->win, TRUE); /* Make the field window */ if (!createFieldWin (itemlist, ypos + BorderOf(itemlist) + TitleLinesOf(itemlist), xpos + itemlist->labelLen + BorderOf(itemlist))) { destroyCDKObject (itemlist); return (0); } /* Set up the rest of the structure. */ ScreenOf(itemlist) = cdkscreen; itemlist->parent = cdkscreen->window; itemlist->shadowWin = 0; initExitType(itemlist); ObjOf(itemlist)->acceptsFocus = TRUE; itemlist->shadow = shadow; setCDKItemlistBox (itemlist, Box); /* Set then default item. */ if (defaultItem >= 0 && defaultItem < itemlist->listSize) { itemlist->currentItem = defaultItem; itemlist->defaultItem = defaultItem; } else { itemlist->currentItem = 0; itemlist->defaultItem = 0; } /* Do we want a shadow??? */ if (shadow) { itemlist->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1); if (itemlist->shadowWin == 0) { destroyCDKObject (itemlist); return (0); } } /* Register this baby. */ registerCDKObject (cdkscreen, vITEMLIST, itemlist); /* Return the pointer to the structure */ return (itemlist); } /* * This allows the user to play with the widget. */ int activateCDKItemlist (CDKITEMLIST *itemlist, chtype *actions) { /* Declare local variables. */ int ret = -1; /* Draw the widget. */ drawCDKItemlist (itemlist, ObjOf(itemlist)->box); drawCDKItemlistField(itemlist, TRUE); if (actions == 0) { chtype input = 0; boolean functionKey; for (;;) { input = getchCDKObject (ObjOf(itemlist), &functionKey); /* Inject the character into the widget. */ ret = injectCDKItemlist (itemlist, input); if (itemlist->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 = injectCDKItemlist (itemlist, actions[x]); if (itemlist->exitType != vEARLY_EXIT) { return ret; } } } /* Set the exit type and exit. */ setExitType(itemlist, 0); return ret; } /* * This injects a single character into the widget. */ static int _injectCDKItemlist (CDKOBJS *object, chtype input) { CDKITEMLIST *itemlist = (CDKITEMLIST *)object; /* Declare local variables. */ int ppReturn = 1; int ret = unknownInt; bool complete = FALSE; /* Set the exit type. */ setExitType(itemlist, 0); /* Draw the itemlist field. */ drawCDKItemlistField (itemlist,TRUE); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf(itemlist) != 0) { /* Call the pre-process function. */ ppReturn = PreProcessFuncOf(itemlist) (vITEMLIST, itemlist, PreProcessDataOf(itemlist), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check a predefined binding. */ if (checkCDKObjectBind (vITEMLIST, itemlist, input) != 0) { checkEarlyExit(itemlist); complete = TRUE; } else { switch (input) { case KEY_UP : case KEY_RIGHT : case SPACE : case '+' : case 'n' : if (itemlist->currentItem < itemlist->listSize - 1) { itemlist->currentItem++; } else { itemlist->currentItem = 0; } break; case KEY_DOWN : case KEY_LEFT : case '-' : case 'p' : if (itemlist->currentItem > 0) { itemlist->currentItem--; } else { itemlist->currentItem = itemlist->listSize - 1; } break; case 'd' : case 'D' : itemlist->currentItem = itemlist->defaultItem; break; case '0' : itemlist->currentItem = 0; break; case '$' : itemlist->currentItem = itemlist->listSize - 1; break; case KEY_ESC : setExitType(itemlist, input); complete = TRUE; break; case KEY_TAB : case KEY_ENTER : setExitType(itemlist, input); ret = itemlist->currentItem; complete = TRUE; break; case CDK_REFRESH : eraseCDKScreen (ScreenOf(itemlist)); refreshCDKScreen (ScreenOf(itemlist)); break; default : Beep(); break; } } /* Should we call a post-process? */ if (!complete && (PostProcessFuncOf(itemlist) != 0)) { PostProcessFuncOf(itemlist) (vITEMLIST, itemlist, PostProcessDataOf(itemlist), input); } } if (!complete) { drawCDKItemlistField (itemlist,TRUE); setExitType(itemlist, 0); } ResultOf(itemlist).valueInt = ret; return (ret != unknownInt); } /* * This moves the itemlist field to the given location. */ static void _moveCDKItemlist (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDKITEMLIST *itemlist = (CDKITEMLIST *)object; /* Declare local variables. */ int currentX = getbegx(itemlist->win); int currentY = getbegy(itemlist->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(itemlist->win) + xplace; ypos = getbegy(itemlist->win) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf(itemlist), &xpos, &ypos, itemlist->boxWidth, itemlist->boxHeight); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the window to the new location. */ moveCursesWindow(itemlist->win, -xdiff, -ydiff); moveCursesWindow(itemlist->fieldWin, -xdiff, -ydiff); moveCursesWindow(itemlist->labelWin, -xdiff, -ydiff); moveCursesWindow(itemlist->shadowWin, -xdiff, -ydiff); /* Touch the windows so they 'move'. */ refreshCDKWindow (WindowOf(itemlist)); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDKItemlist (itemlist, ObjOf(itemlist)->box); } } /* * This draws the widget on the screen. */ static void _drawCDKItemlist (CDKOBJS *object, int Box) { CDKITEMLIST *itemlist = (CDKITEMLIST *)object; /* Did we ask for a shadow? */ if (itemlist->shadowWin != 0) { drawShadow (itemlist->shadowWin); } /* Box the widget if asked. */ if (Box) { drawObjBox (itemlist->win, ObjOf(itemlist)); } drawCdkTitle (itemlist->win, object); /* Draw in the label to the widget. */ if (itemlist->labelWin != 0) { writeChtype (itemlist->labelWin, 0, 0, itemlist->label, HORIZONTAL, 0, chlen(itemlist->label)); } wrefresh (itemlist->win); /* Draw in the field. */ drawCDKItemlistField(itemlist, FALSE); } /* * This sets the background attribute of the widget. */ static void _setBKattrItemlist (CDKOBJS *object, chtype attrib) { if (object != 0) { CDKITEMLIST *widget = (CDKITEMLIST *) object; wbkgd (widget->win, attrib); wbkgd (widget->fieldWin, attrib); if (widget->labelWin != 0) { wbkgd (widget->labelWin, attrib); } } } /* * This function draws the contents of the field. */ void drawCDKItemlistField (CDKITEMLIST *itemlist, boolean highlight) { /* Declare local vars. */ int currentItem = itemlist->currentItem; int len; int x; /* Determine how much we have to draw. */ len = MINIMUM (itemlist->itemLen[currentItem], itemlist->fieldWidth); /* Erase the field window. */ werase (itemlist->fieldWin); /* Draw in the current item in the field. */ for (x=0; x < len; x++) { chtype c = itemlist->item[currentItem][x]; if (highlight) { c = CharOf(c) | A_REVERSE; } mvwaddch (itemlist->fieldWin, 0, x + itemlist->itemPos[currentItem], c); } /* Redraw the field window. */ wrefresh (itemlist->fieldWin); } /* * This function removes the widget from the screen. */ static void _eraseCDKItemlist (CDKOBJS *object) { if (validCDKObject (object)) { CDKITEMLIST *itemlist = (CDKITEMLIST *)object; eraseCursesWindow (itemlist->fieldWin); eraseCursesWindow (itemlist->labelWin); eraseCursesWindow (itemlist->win); eraseCursesWindow (itemlist->shadowWin); } } static void destroyInfo (CDKITEMLIST *widget) { widget->listSize = 0; CDKfreeChtypes (widget->item); widget->item = 0; freeAndNull (widget->itemPos); freeAndNull (widget->itemLen); } /* * This function destroys the widget and all the memory it used. */ static void _destroyCDKItemlist (CDKOBJS *object) { if (object != 0) { CDKITEMLIST *itemlist = (CDKITEMLIST *)object; cleanCdkTitle (object); freeChtype (itemlist->label); destroyInfo (itemlist); /* Delete the windows. */ deleteCursesWindow (itemlist->fieldWin); deleteCursesWindow (itemlist->labelWin); deleteCursesWindow (itemlist->shadowWin); deleteCursesWindow (itemlist->win); /* Clean the key bindings. */ cleanCDKObjectBindings (vITEMLIST, itemlist); /* Unregister this object. */ unregisterCDKObject (vITEMLIST, itemlist); } } /* * This sets multiple attributes of the widget. */ void setCDKItemlist (CDKITEMLIST *itemlist, char **list, int count, int current, boolean Box) { setCDKItemlistValues (itemlist, list, count, current); setCDKItemlistBox (itemlist, Box); } /* * This function sets the contents of the list. */ void setCDKItemlistValues (CDKITEMLIST *itemlist, char **item, int count, int defaultItem) { if (createList(itemlist, item, count)) { int oldWidth = itemlist->fieldWidth; /* Set the default item. */ if ((defaultItem >= 0) && (defaultItem < itemlist->listSize)) { itemlist->currentItem = defaultItem; itemlist->defaultItem = defaultItem; } /* * This will not resize the outer windows but can still make a usable * field width if the title made the outer window wide enough. */ updateFieldWidth (itemlist); if (itemlist->fieldWidth > oldWidth) { createFieldWin (itemlist, getbegy(itemlist->fieldWin), getbegx(itemlist->fieldWin)); } /* Draw the field. */ eraseCDKItemlist (itemlist); drawCDKItemlist (itemlist, ObjOf(itemlist)->box); } } chtype **getCDKItemlistValues (CDKITEMLIST *itemlist, int *size) { (*size) = itemlist->listSize; return itemlist->item; } /* * This sets the default/current item of the itemlist. */ void setCDKItemlistCurrentItem (CDKITEMLIST *itemlist, int currentItem) { /* Set the default item. */ if ((currentItem >= 0) && (currentItem < itemlist->listSize)) { itemlist->currentItem = currentItem; } } int getCDKItemlistCurrentItem (CDKITEMLIST *itemlist) { return itemlist->currentItem; } /* * This sets the default item in the list. */ void setCDKItemlistDefaultItem (CDKITEMLIST *itemlist, int defaultItem) { /* Make sure the item is in the correct range. */ if (defaultItem < 0) { itemlist->defaultItem = 0; } else if (defaultItem >= itemlist->listSize) { itemlist->defaultItem = itemlist->listSize - 1; } else { itemlist->defaultItem = defaultItem; } } int getCDKItemlistDefaultItem (CDKITEMLIST *itemlist) { return itemlist->defaultItem; } /* * This sets the box attribute of the itemlist widget. */ void setCDKItemlistBox (CDKITEMLIST *itemlist, boolean Box) { ObjOf(itemlist)->box = Box; ObjOf(itemlist)->borderSize = Box ? 1 : 0; } boolean getCDKItemlistBox (CDKITEMLIST *itemlist) { return ObjOf(itemlist)->box; } static void _focusCDKItemlist(CDKOBJS *object) { CDKITEMLIST *itemlist = (CDKITEMLIST *)object; drawCDKItemlistField (itemlist,TRUE); } static void _unfocusCDKItemlist(CDKOBJS *object) { CDKITEMLIST *itemlist = (CDKITEMLIST *)object; drawCDKItemlistField (itemlist,FALSE); } #if 0 static void _refreshDataCDKItemlist(CDKOBJS *object) { CDKITEMLIST *itemlist = (CDKITEMLIST *)object; if (ReturnOf(itemlist)) { switch (DataTypeOf(itemlist)) { default: case DataTypeInt: itemlist->currentItem = *((int*)ReturnOf(itemlist)); break; case DataTypeDouble: itemlist->currentItem = *((double*)ReturnOf(itemlist)); break; case DataTypeFloat: itemlist->currentItem = *((float*)ReturnOf(itemlist)); break; case DataTypeString: { int i; for (i=0; i < itemlist->listSize; ++i) if (!cmpStrChstr((char*)ReturnOf(itemlist),itemlist->item[i])) { itemlist->currentItem = i; break; } itemlist->currentItem = itemlist->defaultItem; break; } } drawCDKItemlistField(itemlist, FALSE); } } static void _saveDataCDKItemlist(CDKOBJS *object) { CDKITEMLIST *itemlist = (CDKITEMLIST *)object; if (ReturnOf(itemlist)) { switch (DataTypeOf(itemlist)) { default: case DataTypeInt: *((int*)ReturnOf(itemlist)) = itemlist->currentItem; break; case DataTypeFloat: *((float*)ReturnOf(itemlist)) = itemlist->currentItem; break; case DataTypeDouble: *((double*)ReturnOf(itemlist)) = itemlist->currentItem; break; case DataTypeString: chstrncpy((char*)ReturnOf(itemlist), itemlist->item[itemlist->currentItem], 9999); break; } } } #else dummyRefreshData(Itemlist) dummySaveData(Itemlist) #endif static int createList (CDKITEMLIST *itemlist, char **item, int count) { int status = 0; if (count > 0) { chtype **newItems = typeCallocN(chtype*, count + 1); int *newPos = typeCallocN(int, count + 1); int *newLen = typeCallocN(int, count + 1); int x; int fieldWidth = 0; if (newItems != 0 && newPos != 0 && newLen != 0) { /* Go through the list and determine the widest item. */ status = 1; for (x=0; x < count; x++) { /* Copy the item to the list. */ newItems[x] = char2Chtype (item[x], &newLen[x], &newPos[x]); if (newItems[x] == 0) { status = 0; break; } fieldWidth = MAXIMUM (fieldWidth, newLen[x]); } /* Now we need to justify the strings. */ for (x=0; x < count; x++) { newPos[x] = justifyString (fieldWidth + 1, newLen[x], newPos[x]); } } if (status) { destroyInfo (itemlist); /* Copy in the new information. */ itemlist->listSize = count; itemlist->item = newItems; itemlist->itemPos = newPos; itemlist->itemLen = newLen; } else { CDKfreeChtypes (newItems); freeChecked (newPos); freeChecked (newLen); } } else { destroyInfo (itemlist); status = TRUE; } return status; } /* Go through the list and determine the widest item. */ static int maximumFieldWidth (CDKITEMLIST *itemlist) { int x; int maxWidth = INT_MIN; for (x=0; x < itemlist->listSize; x++) { maxWidth = MAXIMUM (maxWidth, itemlist->itemLen[x]); } maxWidth = MAXIMUM (maxWidth, 0); return maxWidth; } static void updateFieldWidth (CDKITEMLIST *itemlist) { int want = maximumFieldWidth (itemlist) + 1; int have = itemlist->boxWidth - itemlist->labelLen - 2 * BorderOf(itemlist); itemlist->fieldWidth = MINIMUM(want, have); } /* Make the field window */ static int createFieldWin (CDKITEMLIST *itemlist, int ypos, int xpos) { itemlist->fieldWin = subwin (itemlist->win, 1, itemlist->fieldWidth, ypos, xpos); if (itemlist->fieldWin != 0) { keypad (itemlist->fieldWin, TRUE); ObjOf(itemlist)->inputWindow = itemlist->fieldWin; return 1; } return 0; } cdk-5.0-20060507/label.c0000644000175100001440000001671410426516000012765 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:27:44 $ * $Revision: 1.84 $ */ DeclareCDKObjects(LABEL, Label, setCdk, Unknown); /* * This creates a label widget. */ CDKLABEL *newCDKLabel(CDKSCREEN *cdkscreen, int xplace, int yplace, char **mesg, int rows, boolean Box, boolean shadow) { /* Maintain the label information. */ CDKLABEL *label = 0; int parentWidth = getmaxx(cdkscreen->window); int parentHeight = getmaxy(cdkscreen->window); int boxWidth = INT_MIN; int boxHeight; int xpos = xplace; int ypos = yplace; int x = 0; if (rows <= 0 || (label = newCDKObject(CDKLABEL, &my_funcs)) == 0 || (label->info = typeCallocN(chtype *, rows + 1)) == 0 || (label->infoLen = typeCallocN(int, rows + 1)) == 0 || (label->infoPos = typeCallocN(int, rows + 1)) == 0) { destroyCDKObject(label); return (0); } setCDKLabelBox (label, Box); boxHeight = rows + 2 * BorderOf(label); /* Determine the box width. */ for (x=0; x < rows; x++) { /* Translate the char * to a chtype. */ label->info[x] = char2Chtype (mesg[x], &label->infoLen[x], &label->infoPos[x]); boxWidth = MAXIMUM (boxWidth, label->infoLen[x]); } boxWidth += 2 * BorderOf(label); /* Create the string alignments. */ for (x=0; x < rows; x++) { label->infoPos[x] = justifyString (boxWidth - 2 * BorderOf(label), label->infoLen[x], label->infoPos[x]); } /* * 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); /* Create the label. */ ScreenOf(label) = cdkscreen; label->parent = cdkscreen->window; label->win = newwin (boxHeight, boxWidth, ypos, xpos); label->shadowWin = 0; label->xpos = xpos; label->ypos = ypos; label->rows = rows; label->boxWidth = boxWidth; label->boxHeight = boxHeight; ObjOf(label)->inputWindow = label->win; label->shadow = shadow; /* Is the window null? */ if (label->win == 0) { destroyCDKObject(label); return (0); } keypad (label->win, TRUE); /* If a shadow was requested, then create the shadow window. */ if (shadow) { label->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1); } /* Register this baby. */ registerCDKObject (cdkscreen, vLABEL, label); /* Return the label pointer. */ return (label); } /* * This was added for the builder. */ void activateCDKLabel (CDKLABEL *label, chtype *actions GCC_UNUSED) { drawCDKLabel (label, ObjOf(label)->box); } /* * This sets multiple attributes of the widget. */ void setCDKLabel (CDKLABEL *label, char **mesg, int lines, boolean Box) { setCDKLabelMessage (label, mesg, lines); setCDKLabelBox (label, Box); } /* * This sets the information within the label. */ void setCDKLabelMessage (CDKLABEL *label, char **info, int infoSize) { int x; /* Clean out the old message. */ for (x=0; x < label->rows; x++) { freeChtype (label->info[x]); label->infoPos[x] = 0; label->infoLen[x] = 0; } label->rows = (infoSize < label->rows ? infoSize : label->rows); /* Copy in the new message. */ for (x=0; x < label->rows; x++) { label->info[x] = char2Chtype (info[x], &label->infoLen[x], &label->infoPos[x]); label->infoPos[x] = justifyString (label->boxWidth - 2 * BorderOf(label), label->infoLen[x], label->infoPos[x]); } /* Redraw the label widget. */ eraseCDKLabel (label); drawCDKLabel (label, ObjOf(label)->box); } chtype **getCDKLabelMessage (CDKLABEL *label, int *size) { (*size) = label->rows; return label->info; } /* * This sets the box flag for the label widget. */ void setCDKLabelBox (CDKLABEL *label, boolean Box) { ObjOf(label)->box = Box; ObjOf(label)->borderSize = Box ? 1 : 0; } boolean getCDKLabelBox (CDKLABEL *label) { return ObjOf(label)->box; } /* * This sets the background attribute of the widget. */ static void _setBKattrLabel (CDKOBJS *object, chtype attrib) { if (object != 0) { CDKLABEL *widget = (CDKLABEL *) object; wbkgd (widget->win, attrib); } } /* * This draws the label widget. */ static void _drawCDKLabel (CDKOBJS *object, boolean Box GCC_UNUSED) { CDKLABEL *label = (CDKLABEL *)object; int x = 0; /* Is there a shadow? */ if (label->shadowWin != 0) { drawShadow (label->shadowWin); } /* Box the widget if asked. */ if (ObjOf(label)->box) { drawObjBox (label->win, ObjOf(label)); } /* Draw in the message. */ for (x=0; x < label->rows; x++) { writeChtype (label->win, label->infoPos[x] + BorderOf(label), x + BorderOf(label), label->info[x], HORIZONTAL, 0, label->infoLen[x]); } /* Refresh the window. */ wrefresh (label->win); } /* * This erases the label widget. */ static void _eraseCDKLabel (CDKOBJS *object) { if (validCDKObject (object)) { CDKLABEL *label = (CDKLABEL *)object; eraseCursesWindow (label->win); eraseCursesWindow (label->shadowWin); } } /* * This moves the label field to the given location. */ static void _moveCDKLabel (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDKLABEL *label = (CDKLABEL *)object; int currentX = getbegx(label->win); int currentY = getbegy(label->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(label->win) + xplace; ypos = getbegy(label->win) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf(label), &xpos, &ypos, label->boxWidth, label->boxHeight); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the window to the new location. */ moveCursesWindow(label->win, -xdiff, -ydiff); moveCursesWindow(label->shadowWin, -xdiff, -ydiff); /* Touch the windows so they 'move'. */ refreshCDKWindow (WindowOf(label)); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDKLabel (label, ObjOf(label)->box); } } /* * This destroys the label object pointer. */ static void _destroyCDKLabel (CDKOBJS *object) { if (object != 0) { CDKLABEL *label = (CDKLABEL *)object; CDKfreeChtypes (label->info); freeChecked (label->infoLen); freeChecked (label->infoPos); /* Free up the window pointers. */ deleteCursesWindow (label->shadowWin); deleteCursesWindow (label->win); /* Clean the key bindings. */ cleanCDKObjectBindings (vLABEL, label); /* Unregister the object. */ unregisterCDKObject (vLABEL, label); } } /* * This pauses until a user hits a key... */ char waitCDKLabel (CDKLABEL *label, char key) { boolean functionKey; /* If the key is null, we'll accept anything. */ if ( key == 0 ) { return (getchCDKObject (ObjOf(label), &functionKey)); } else { /* Only exit when a specific key is hit. */ int code; for (;;) { code = getchCDKObject(ObjOf(label), &functionKey); if (code == key) { return ( code ); } } } } dummyInject(Label) dummyFocus(Label) dummyUnfocus(Label) dummyRefreshData(Label) dummySaveData(Label) cdk-5.0-20060507/man/0000755000175100001440000000000010427502123012306 5ustar tomuserscdk-5.0-20060507/man/cdk_process.30000644000175100001440000000223510354553445014707 0ustar tomusers'\" t .\" $Id: cdk_process.3,v 1.3 2005/12/28 18:19:17 tom Exp $ .de XX .. .TH cdk_process 3 .SH NAME cdk_process \- curses widget pre/post-processing .SH SYNOPSIS Perform pre- and post-processing of data which is injected into a widget. .SH DESCRIPTION Character input is handled by each widget by its injection function. That is typically a large case-statement consisting of the actions to be taken for editing and scrolling keys. The calling application can modify the behavior of the injection function by defining either or both preprocess and postprocess functions. .PP Preprocessing is performed before doing anything with the injected keystroke. If the preprocess function returns zero, no further action is taken in the injection function. Note that the preprocess function may do more than filter out characters; it can fill in logic to coordinate different widgets. .PP Postprocessing is performed after all other actions have been done in the injection function. Like the other actions, it is performed only if the preprocess function returns a nonzero value. Unlike the preprocess function, its return value is ignored. .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3). cdk-5.0-20060507/man/cdk_histogram.30000644000175100001440000002645710354555363015243 0ustar tomusers'\" t .\" $Id: cdk_histogram.3,v 1.14 2005/12/28 18:35:31 tom Exp $ .de XX .. .TH cdk_histogram 3 .SH NAME .XX activateCDKHistogram .XX destroyCDKHistogram .XX drawCDKHistogram .XX eraseCDKHistogram .XX getCDKHistogramBox .XX getCDKHistogramFillerChar .XX getCDKHistogramHighValue .XX getCDKHistogramLowValue .XX getCDKHistogramStatsAttr .XX getCDKHistogramStatsPos .XX getCDKHistogramValue .XX getCDKHistogramViewType .XX moveCDKHistogram .XX newCDKHistogram .XX positionCDKHistogram .XX setCDKHistogram .XX setCDKHistogramBackgroundAttrib .XX setCDKHistogramBackgroundColor .XX setCDKHistogramBox .XX setCDKHistogramBoxAttribute .XX setCDKHistogramDisplayType .XX setCDKHistogramFillerChar .XX setCDKHistogramHorizontalChar .XX setCDKHistogramLLChar .XX setCDKHistogramLRChar .XX setCDKHistogramStatsAttr .XX setCDKHistogramStatsPos .XX setCDKHistogramULChar .XX setCDKHistogramURChar .XX setCDKHistogramValue .XX setCDKHistogramVerticalChar .XX setCDKHistogramViewType cdk_histogram \- curses histogram widget .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "void activateCDKHistogram (" .BI "CDKHISTOGRAM *" "histogram", .BI "chtype " "unused"); .TP 15 .B "void destroyCDKHistogram (" .BI "CDKHISTOGRAM *" "histogram"); .TP 15 .B "void drawCDKHistogram (" .BI "CDKHISTOGRAM *" "histogram", .BI "boolean " "box"); .TP 15 .B "void eraseCDKHistogram (" .BI "CDKHISTOGRAM *" "histogram"); .TP 15 .B "boolean getCDKHistogramBox (" .BI "CDKHISTOGRAM *" "histogram"); .TP 15 .B "chtype getCDKHistogramFillerChar (" .BI "CDKHISTOGRAM *" "histogram"); .TP 15 .B "int getCDKHistogramHighValue (" .BI "CDKHISTOGRAM *" "histogram"); .TP 15 .B "int getCDKHistogramLowValue (" .BI "CDKHISTOGRAM *" "histogram"); .TP 15 .B "chtype getCDKHistogramStatsAttr (" .BI "CDKHISTOGRAM *" "histogram"); .TP 15 .B "int getCDKHistogramStatsPos (" .BI "CDKHISTOGRAM *" "histogram"); .TP 15 .B "int getCDKHistogramValue (" .BI "CDKHISTOGRAM *" "histogram"); .TP 15 .B "EHistogramDisplayType getCDKHistogramViewType (" .BI "CDKHISTOGRAM *" "histogram"); .TP 15 .B "void moveCDKHistogram (" .BI "CDKHISTOGRAM *" "histogram", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKHISTOGRAM *newCDKHistogram (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "int " "height", .BI "int " "width", .BI "int " "orient", .BI "char *" "title", .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKHistogram (" .BI "CDKHISTOGRAM *" "histogram"); .TP 15 .B "void setCDKHistogram (" .BI "CDKHISTOGRAM *" "histogram", .BI "EHistogramDisplayType " "viewType", .BI "int " "statsPos", .BI "chtype " "statsAttribute", .BI "int " "lowValue", .BI "int " "highValue", .BI "int " "currentValue", .BI "chtype " "fillerCharacter", .BI "boolean " "box"); .TP 15 .B "void setCDKHistogramBackgroundAttrib (" .BI "CDKHISTOGRAM *" "histogram", .BI "chtype " "attribute"); .TP 15 .B "void setCDKHistogramBackgroundColor (" .BI "CDKHISTOGRAM *" "histogram", .BI "char * " "color"); .TP 15 .B "void setCDKHistogramBox (" .BI "CDKHISTOGRAM *" "histogram", .BI "boolean " "box"); .TP 15 .B "void setCDKHistogramBoxAttribute (" .BI "CDKHISTOGRAM *" "histogram", .BI "chtype " "character"); .TP 15 .B "void setCDKHistogramDisplayType (" .BI "CDKHISTOGRAM *" "histogram", .BI "EHistogramDisplayType " "viewtype"); .TP 15 .B "void setCDKHistogramFillerChar (" .BI "CDKHISTOGRAM *" "histogram", .BI "chtype " "fillerCharacter"); .TP 15 .B "void setCDKHistogramHorizontalChar (" .BI "CDKHISTOGRAM *" "histogram", .BI "chtype " "character"); .TP 15 .B "void setCDKHistogramLLChar (" .BI "CDKHISTOGRAM *" "histogram", .BI "chtype " "character"); .TP 15 .B "void setCDKHistogramLRChar (" .BI "CDKHISTOGRAM *" "histogram", .BI "chtype " "character"); .TP 15 .B "void setCDKHistogramStatsAttr (" .BI "CDKHISTOGRAM *" "histogram", .BI "chtype " "statsAttribute"); .TP 15 .B "void setCDKHistogramStatsPos (" .BI "CDKHISTOGRAM *" "histogram", .BI "int " "statsPosition"); .TP 15 .B "void setCDKHistogramULChar (" .BI "CDKHISTOGRAM *" "histogram", .BI "chtype " "character"); .TP 15 .B "void setCDKHistogramURChar (" .BI "CDKHISTOGRAM *" "histogram", .BI "chtype " "character"); .TP 15 .B "void setCDKHistogramValue (" .BI "CDKHISTOGRAM *" "histogram", .BI "int " "lowValue", .BI "int " "highValue", .BI "int " "currentValue"); .TP 15 .B "void setCDKHistogramVerticalChar (" .BI "CDKHISTOGRAM *" "histogram", .BI "chtype " "character"); .TP 15 .B "void setCDKHistogramViewType (" .BI "CDKHISTOGRAM *" "histogram", .BI "EHistogramDisplayType " "viewType"); .fi .SH DESCRIPTION The Cdk histogram widget creates a histogram widget. This widget can draw a vertical or horizontal histogram. The functions create or manipulate the Cdk histogram box widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKHistogram obsolete entrypoint which calls \fBdrawCDKHistogram\fP. .TP 5 .B destroyCDKHistogram removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKHistogram draws the histogram widget on the screen. If the \fBbox\fR parameter is true, the widget is drawn with a box. .TP 5 .B eraseCDKHistogram removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKHistogramBox returns true if the widget will be drawn with a box around it. .TP 5 .B getCDKHistogramFillerChar returns the character being used to draw the histogram bar. .TP 5 .B getCDKHistogramHighValue returns the high value of the histogram. .TP 5 .B getCDKHistogramLowValue returns the low value of the histogram. .TP 5 .B getCDKHistogramStatsAttr returns the attribute of the statistics of the histogram. .TP 5 .B getCDKHistogramStatsPos returns where the histogram will draw the statistics. .TP 5 .B getCDKHistogramValue returns the current value of the histogram. .TP 5 .B getCDKHistogramViewType returns the view type of the histogram widget. .TP 5 .B moveCDKHistogram moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR can be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDKHistogram creates a histogram widget and returns a pointer to it. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBtitle\fR is the string which will be displayed at the top of the widget. The title can be more than one line; just provide a carriage return character at the line break. .TP 5 \fBheight\fR and .TP 5 \fBwidth\fR control the height and width of the widget. If you provide a value of zero for either of the height or the width, the widget will be created with the full width and height of the screen. If you provide a negative value, the widget will be created the full height or width minus the value provided. .TP 5 \fBorient\fR specifies the orientation of the histogram. It is one of these pre-defined values: \fIVERTICAL\fR and \fIHORIZONTAL\fR. .TP 5 \fBlabel\fR is the string to use as the label of the histogram. .TP 5 \fBbox\fR is true if the widget should be drawn with a box around it. .TP 5 \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKHistogram allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDKHistogram lets the programmer set the specific values of the histogram widget. The parameter \fBviewType\fR specifies the type of histogram to draw. The following table lists the valid values and the results. .LP .TS center tab(/) allbox; l l lw15 lw30 . \fBDisplay_Type/Result\fR vNONE/T{ Displays no information about the current values. T} vPERCENT/T{ Displays the current value as a percentage. T} vFRACTION/T{ Displays the current value as a fraction. T} vREAL/Displays the current value. .TE .sp .TP 5 \& The \fBstatsPosition\fR parameter states where the statistics will be displayed. It accepts \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .IP The parameter \fBstatsAttribute\fR sets the attributes of the statistics. .IP The parameters \fBlowValue\fR, \fBhighValue\fR, and \fBcurrentValue\fR are the low, high, and current values respectively. .IP The \fBfiller\fR character is the character to use in the unused space in the histogram. .IP If the \fBbox\fR parameter is true, the widget is drawn with a box. .TP 5 .B setCDKHistogramBackgroundAttrib the background color attribute the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKHistogramBackgroundColor the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .TP 5 .B setCDKHistogramBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKHistogramBoxAttribute sets the attribute of the box. .TP 5 .B setCDKHistogramDisplayType sets the display type (see \fBgetCDKHistogramViewType\fP). .TP 5 .B setCDKHistogramFillerChar sets the character to use when drawing the histogram bar. .TP 5 .B setCDKHistogramHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKHistogramLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKHistogramLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKHistogramStatsAttr sets the attribute to use when drawing the histogram statistics. .TP 5 .B setCDKHistogramStatsPos sets where the statistics will be drawn on the widget. See the \fBsetCDKHistogram\fR description for more details. .TP 5 .B setCDKHistogramULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKHistogramURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKHistogramValue sets the low, high, and current value of the histogram. .TP 5 .B setCDKHistogramVerticalChar sets the vertical drawing character for the box to the given character. .TP 5 .B setCDKHistogramViewType sets the view type of the histogram. Look at the \fBsetCDKHistogram\fR description for more details. .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_position.30000644000175100001440000000357207525037426015104 0ustar tomusers'\" t .\" $Id: cdk_position.3,v 1.4 2002/08/09 22:15:50 tom Exp $ .TH cdk_position 3 .SH NAME cdk_position \- curses widget positioning key-bindings .SH SYNOPSIS Position methods for the Cdk widgets allow the user to move the widget around the screen via the cursor/keypad keys. .SH DESCRIPTION The following key bindings can be used to move the widget around the screen. .LP .TS center tab(/) box; l l lw15 lw35 . \fBKey/Action\fR = Up Arrow/T{ Moves the widget up one row. T} Down Arrow/T{ Moves the widget down one row. T} Left Arrow/T{ Moves the widget left one column T} Right Arrow/T{ Moves the widget right one column T} 1/T{ Moves the widget down one row and left one column. T} 2/T{ Moves the widget down one row. T} 3/T{ Moves the widget down one row and right one column. T} 4/T{ Moves the widget left one column T} 5/T{ Centers the widget both vertically and horizontally. T} 6/Moves the widget right one column 7/T{ Moves the widget up one row and left one column. T} 8/T{ Moves the widget up one row. T} 9/T{ Moves the widget up one row and right one column. T} t/T{ Moves the widget to the top of the screen. T} b/T{ Moves the widget to the bottom of the screen. T} l/T{ Moves the widget to the left of the screen. T} r/T{ Moves the widget to the right of the screen. T} c/T{ Centers the widget between the left and right of the window. T} C/T{ Centers the widget between the top and bottom of the window. T} Escape/Returns the widget to its original position. Return/T{ Exits the function and leaves the widgetwhere it was. T} = .TE .LP The numbers 0-9 are chosen to correspond to the numeric keypad on your terminal. Cdk does not handle the application mode keypad control sequences, since those are not defined via terminfo. To use the numeric keypad you should ensure that it is in normal (or NumLock) mode. .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_dialog.30000644000175100001440000002767310354555363014506 0ustar tomusers'\" t .\" $Id: cdk_dialog.3,v 1.18 2005/12/28 18:35:31 tom Exp $ .de XX .. .TH cdk_dialog 3 .SH NAME .XX activateCDKDialog .XX destroyCDKDialog .XX drawCDKDialog .XX drawCDKDialogButtons .XX eraseCDKDialog .XX getCDKDialog .XX getCDKDialogBox .XX getCDKDialogHighlight .XX getCDKDialogSeparator .XX injectCDKDialog .XX moveCDKDialog .XX newCDKDialog .XX positionCDKDialog .XX setCDKDialog .XX setCDKDialogBackgroundAttrib .XX setCDKDialogBackgroundColor .XX setCDKDialogBox .XX setCDKDialogBox .XX setCDKDialogBoxAttribute .XX setCDKDialogHighlight .XX setCDKDialogHorizontalChar .XX setCDKDialogLLChar .XX setCDKDialogLRChar .XX setCDKDialogPostProcess .XX setCDKDialogPreProcess .XX setCDKDialogSeparator .XX setCDKDialogULChar .XX setCDKDialogURChar .XX setCDKDialogVerticalChar cdk_dialog \- curses dialog widget .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "int activateCDKDialog (" .BI "CDKDIALOG *" "dialog", .BI "chtype * " "actions"); .TP 15 .B "void destroyCDKDialog (" .BI "CDKDIALOG *" "dialog"); .TP 15 .B "void drawCDKDialog (" .BI "CDKDIALOG *" "dialog", .BI "boolean " "box"); .TP 15 .B "void drawCDKDialogButtons (" .BI "CDKDIALOG *" "dialog"); .TP 15 .B "void eraseCDKDialog (" .BI "CDKDIALOG *" "dialog"); .TP 15 .B "boolean getCDKDialog (" .BI "CDKDIALOG *" "dialog"); .TP 15 .B "boolean getCDKDialogBox (" .BI "CDKDIALOG *" "dialog"); .TP 15 .B "chtype getCDKDialogHighlight (" .BI "CDKDIALOG *" "dialog"); .TP 15 .B "boolean getCDKDialogSeparator (" .BI "CDKDIALOG *" "dialog"); .TP 15 .B "int injectCDKDialog (" .BI "CDKDIALOG *" "dialog", .BI "chtype " "input"); .TP 15 .B "void moveCDKDialog (" .BI "CDKDIALOG *" "dialog", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKDIALOG *newCDKDialog (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "char ** " "message" , .BI "int " "rows", .BI "char ** " "buttons" , .BI "int " "buttonCount", .BI "chtype " "highlight" , .BI "boolean " "separator", .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKDialog (" .BI "CDKDIALOG *" "dialog"); .TP 15 .B "void setCDKDialogBox (" .BI "CDKDIALOG *" "dialog", .BI "boolean " "boxWidget"); .TP 15 .B "void setCDKDialog (" .BI "CDKDIALOG *" "dialog", .BI "chtype " "highlight", .BI "boolean " "separator", .BI "boolean " "box"); .TP 15 .B "void setCDKDialogBackgroundAttrib (" .BI "CDKDIALOG *" "dialog", .BI "chtype " "attribute"); .TP 15 .B "void setCDKDialogBackgroundColor (" .BI "CDKDIALOG *" "dialog", .BI "char * " "color"); .TP 15 .B "void setCDKDialogBox (" .BI "CDKDIALOG *" "dialog", .BI "boolean " "box"); .TP 15 .B "void setCDKDialogBoxAttribute (" .BI "CDKDIALOG *" "dialog", .BI "chtype " "character"); .TP 15 .B "void setCDKDialogHighlight (" .BI "CDKDIALOG *" "dialog", .BI "chtype " "highlight"); .TP 15 .B "void setCDKDialogHorizontalChar (" .BI "CDKDIALOG *" "dialog", .BI "chtype " "character"); .TP 15 .B "void setCDKDialogLLChar (" .BI "CDKDIALOG *" "dialog", .BI "chtype " "character"); .TP 15 .B "void setCDKDialogLRChar (" .BI "CDKDIALOG *" "dialog", .BI "chtype " "character"); .TP 15 .B "void setCDKDialogPostProcess (" .BI "CDKDIALOG *" "dialog", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKDialogPreProcess (" .BI "CDKDIALOG *" "dialog", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKDialogSeparator (" .BI "CDKDIALOG *" "dialog", .BI "boolean " "separator"); .TP 15 .B "void setCDKDialogULChar (" .BI "CDKDIALOG *" "dialog", .BI "chtype " "character"); .TP 15 .B "void setCDKDialogURChar (" .BI "CDKDIALOG *" "dialog", .BI "chtype " "character"); .TP 15 .B "void setCDKDialogVerticalChar (" .BI "CDKDIALOG *" "dialog", .BI "chtype " "character"); .fi .SH DESCRIPTION The Cdk dialog widget creates a dialog box with a message and a varied number of buttons to choose from. The following functions create or manipulate the Cdk dialog box widget. .PP .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKDialog activates the dialog widget and lets the user interact with the widget. The parameter \fBdialog\fR is a pointer to a non-NULL dialog widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a value from 0 to the number of buttons -1, representing the button selected. It also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. If the character entered into this widget was \fIESCAPE\fR then the widget returns a value of -1 and the widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR. .TP 5 .B destroyCDKDialog removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKDialog draws the dialog widget on the screen. If the \fBbox\fR parameter is true, the widget is drawn with a box. .TP 5 .B drawCDKDialogButtons draws the dialog buttons and the separation line. .TP 5 .B eraseCDKDialog removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKDialog returns true if the list will be drawn with a box around it. .TP 5 .B getCDKDialogBox returns true if the dialog will be drawn with a box around it. .TP 5 .B getCDKDialogHighlight returns the highlight attribute of the widget. .TP 5 .B getCDKDialogSeparator returns the state of the separator flag. .TP 5 .B injectCDKDialog injects a single character into the widget. The parameter \fBdialog\fR is a pointer to a non-NULL dialog widget. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR the function returns a value from zero to one less than the number of buttons, representing the button selected. The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns -1. The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns -1. The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .TP 5 .B moveCDKDialog moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDKDialog creates a dialog widget and returns a pointer to it. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBmessage\fR is the text to be displayed in the message region of the dialog box. .TP 5 \fBrows\fR is the number of elements in the \fBmessage\fR list. .TP 5 \fBbuttons\fR is an array containing the button labels to be displayed on the bottom of the dialog box. .TP 5 \fBbuttonCount\fR is the number of elements in the \fBbuttons\fR array. .TP 5 \fBhighlight\fR is the attribute of the currently highlighted button. .TP 5 \fBbox\fR is true if the widget should be drawn with a box around it. .TP 5 \fBseparator\fR is true if a separator line should be drawn between the message region and the buttons. .TP 5 \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKDialog allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDKDialogBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKDialog lets the programmer modify certain elements of an existing dialog widget. The parameter names correspond to the same parameter names listed in the \fBnewCDKDialog\fR function. .TP 5 .B setCDKDialogBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKDialogBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .B setCDKDialogBox sets the box attribute of the dialog widget. .TP 5 .B setCDKDialogBoxAttribute function sets the attribute of the box. .TP 5 .B setCDKDialogHighlight sets the highlight attribute of the selected button. .TP 5 .B setCDKDialogHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKDialogLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKDialogLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKDialogPreProcess allows the user to have the widget call a function after a key is hit and before the key is applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR is a pointer to \fIvoid\fR. To learn more about pre-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKDialogPostProcess allows the user to have the widget call a function after the key has been applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about post-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKDialogSeparator sets the boolean flag whether the widget will be drawn with the separator bar between the buttons and the message area. .TP 5 .B setCDKDialogULChar function sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKDialogURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKDialogVerticalChar sets the vertical drawing character for the box to the given character. .SH KEY BINDINGS When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. The following table outlines the keys and their actions for this widget. .LP .TS center tab(/) allbox; l l l l lw15 lw35 . \fBKey/Action\fR = Left Arrow/T{ Selects the button to the left of the current button. T} Right Arrow/T{ Selects the button to the right of the current button. T} Tab/T{ Selects the button to the right of the current button. T} Space/T{ Selects the button to the right of the current button. T} Return/T{ Exits the widget and returns the index of the selected button. This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Tab/T{ Exits the widget and returns the index of the selected button. This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Escape/T{ Exits the widget and returns -1. This also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR. T} Ctrl-L/Refreshes the screen. .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_process (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_marquee.30000644000175100001440000001574010354555363014676 0ustar tomusers.\" $Id: cdk_marquee.3,v 1.15 2005/12/28 18:35:31 tom Exp $ .de XX .. .TH cdk_marquee 3 .SH NAME .XX activateCDKMarquee .XX deactivateCDKMarquee .XX destroyCDKMarquee .XX drawCDKMarquee .XX eraseCDKMarquee .XX getCDKMarqueeBox .XX moveCDKMarquee .XX newCDKMarquee .XX positionCDKMarquee .XX setCDKMarqueeBackgroundAttrib .XX setCDKMarqueeBackgroundColor .XX setCDKMarqueeBox .XX setCDKMarqueeBoxAttribute .XX setCDKMarqueeHorizontalChar .XX setCDKMarqueeLLChar .XX setCDKMarqueeLRChar .XX setCDKMarqueeULChar .XX setCDKMarqueeURChar .XX setCDKMarqueeVerticalChar cdk_marquee \- curses marquee widget .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "int activateCDKMarquee (" .BI "CDKMARQUEE *" "marquee", .BI "char *" "message", .BI "int " "delay", .BI "int " "repeat", .BI "boolean " "box"); .TP 15 .B "void deactivateCDKMarquee (" .BI "CDKMARQUEE *" "marquee"); .TP 15 .B "void destroyCDKMarquee (" .BI "CDKMARQUEE *" "marquee"); .TP 15 .B "void drawCDKMarquee (" .BI "CDKMARQUEE *" "marquee", .BI "boolean " "box"); .TP 15 .B "void eraseCDKMarquee (" .BI "CDKMARQUEE *" "marquee"); .TP 15 .B "boolean getCDKMarqueeBox (" .BI "CDKMENTRY *" "mentry"); .TP 15 .B "void moveCDKMarquee (" .BI "CDKMARQUEE *" "marquee", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKMARQUEE *newCDKMarquee (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "int " "fieldWidth", .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKMarquee (" .BI "CDKMARQUEE *" "marquee"); .TP 15 .B "void setCDKMarqueeBackgroundAttrib (" .BI "CDKMARQUEE *" "marquee", .BI "chtype " "attribute"); .TP 15 .B "void setCDKMarqueeBackgroundColor (" .BI "CDKMARQUEE *" "marquee", .BI "char * " "color"); .TP 15 .B "void setCDKMarqueeBox (" .BI "CDKMENTRY *" "mentry", .BI "boolean " "boxWidget"); .TP 15 .B "void setCDKMarqueeBoxAttribute (" .BI "CDKMARQUEE *" "marquee", .BI "chtype " "character"); .TP 15 .B "void setCDKMarqueeHorizontalChar (" .BI "CDKMARQUEE *" "marquee", .BI "chtype " "character"); .TP 15 .B "void setCDKMarqueeLLChar (" .BI "CDKMARQUEE *" "marquee", .BI "chtype " "character"); .TP 15 .B "void setCDKMarqueeLRChar (" .BI "CDKMARQUEE *" "marquee", .BI "chtype " "character"); .TP 15 .B "void setCDKMarqueeULChar (" .BI "CDKMARQUEE *" "marquee", .BI "chtype " "character"); .TP 15 .B "void setCDKMarqueeURChar (" .BI "CDKMARQUEE *" "marquee", .BI "chtype " "character"); .TP 15 .B "void setCDKMarqueeVerticalChar (" .BI "CDKMARQUEE *" "marquee", .BI "chtype " "character"); .fi .LP .SH DESCRIPTION The Cdk marquee widget creates a pop-up marquee window. The following functions create or manipulate the Cdk marquee widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKMarquee activates the marquee widget. The \fBmarquee\fR parameter is a pointer to a defined marquee widget. The \fBdelay\fR parameter states how long to wait between movements. This value is highly dependent on each machine the program runs on. The \fBrepeat\fR value tells the marquee widget how many times to display the given message. The \fBbox\fR option draws the widget with or without a box. This function returns -1 if the message passed is \fINULL\fR, 0 otherwise. .TP 5 .B deactivateCDKMarquee deactivates the marquee widget. .TP 5 .B destroyCDKMarquee removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKMarquee draws the marquee widget on the screen. If the \fBbox\fR parameter is true, the widget is drawn with a box. .TP 5 .B eraseCDKMarquee removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKMarqueeBox returns true if the widget will be drawn with a box around it. .TP 5 .B moveCDKMarquee moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDKMarquee creates a marquee widget and returns a pointer to it. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBwidth\fR controls the width of the field. If you provide a value of zero for the width, the widget uses the width of the screen. If a negative value is provided, then the widget uses the width of the screen less the value provided. .TP 5 \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKMarquee allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDKMarqueeBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKMarqueeBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. For more information see \fIcdk_display (3)\fR. .TP 5 .B setCDKMarqueeBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKMarqueeBoxAttribute sets the attribute of the box. .TP 5 .B setCDKMarqueeHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKMarqueeLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKMarqueeLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKMarqueeULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKMarqueeURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKMarqueeVerticalChar sets the vertical drawing character for the box to the given character. .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_mentry.30000644000175100001440000003750510420177137014551 0ustar tomusers'\" t .\" $Id: cdk_mentry.3,v 1.24 2006/04/15 14:08:31 tom Exp $ .de XX .. .TH cdk_mentry 3 .SH NAME .XX activateCDKMentry .XX cleanCDKMentry .XX destroyCDKMentry .XX drawCDKMentry .XX drawCDKMentryField .XX eraseCDKMentry .XX getCDKMentryBox .XX getCDKMentryFillerChar .XX getCDKMentryHiddenChar .XX getCDKMentryMin .XX getCDKMentryValue .XX injectCDKMentry .XX moveCDKMentry .XX newCDKMentry .XX positionCDKMentry .XX setCDKMentry .XX setCDKMentryBackgroundAttrib .XX setCDKMentryBackgroundColor .XX setCDKMentryBox .XX setCDKMentryBoxAttribute .XX setCDKMentryCB .XX setCDKMentryFillerChar .XX setCDKMentryHiddenChar .XX setCDKMentryHorizontalChar .XX setCDKMentryLLChar .XX setCDKMentryLRChar .XX setCDKMentryMin .XX setCDKMentryPostProcess .XX setCDKMentryPreProcess .XX setCDKMentryULChar .XX setCDKMentryURChar .XX setCDKMentryValue .XX setCDKMentryVerticalChar cdk_mentry \- curses multiple line entry widget. .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "char *activateCDKMentry (" .BI "CDKMENTRY *" "mentry", .BI "chtype *" "actions"); .TP 15 .B "void cleanCDKMentry (" .BI "CDKMENTRY *" "mentry"); .TP 15 .B "void destroyCDKMentry (" .BI "CDKMENTRY *" "mentry"); .TP 15 .B "void drawCDKMentry (" .BI "CDKMENTRY *" "mentry", .BI "boolean " "box"); .TP 15 .B "void drawCDKMentryField (" .BI "CDKMENTRY *" "mentry"); .TP 15 .B "void eraseCDKMentry (" .BI "CDKMENTRY *" "mentry"); .TP 15 .B "boolean getCDKMentryBox (" .BI "CDKMENTRY *" "mentry"); .TP 15 .B "chtype getCDKMentryFillerChar (" .BI "CDKMENTRY *" "mentry"); .TP 15 .B "chtype getCDKMentryHiddenChar (" .BI "CDKMENTRY *" "mentry"); .TP 15 .B "int getCDKMentryMin (" .BI "CDKMENTRY *" "mentry"); .TP 15 .B "char *getCDKMentryValue (" .BI "CDKMENTRY *" "mentry"); .TP 15 .B "char *injectCDKMentry (" .BI "CDKMENTRY *" "mentry", .BI "chtype " "input"); .TP 15 .B "void moveCDKMentry (" .BI "CDKMENTRY *" "mentry", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKMENTRY *newCDKMentry (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "char *" "title", .BI "char *" "label", .BI "chtype " "fieldAttribute", .BI "chtype " "fillerCharacter", .BI "EDisplayType " "displayType", .BI "int " "fieldWidth", .BI "int " "fieldRows", .BI "int " "logicalRows", .BI "int " "minimumLength", .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKMentry (" .BI "CDKMENTRY *" "mentry"); .TP 15 .B "void setCDKMentry (" .BI "CDKMENTRY *" "mentry", .BI "char *" "value", .BI "int " "minimumLength", .BI "boolean " "box"); .TP 15 .B "void setCDKMentryBackgroundAttrib (" .BI "CDKMENTRY *" "mentry", .BI "chtype " "attribute"); .TP 15 .B "void setCDKMentryBackgroundColor (" .BI "CDKMENTRY *" "mentry", .BI "char * " "color"); .TP 15 .B "void setCDKMentryBox (" .BI "CDKMENTRY *" "mentry", .BI "boolean " "boxWidget"); .TP 15 .B "void setCDKMentryBoxAttribute (" .BI "CDKMENTRY *" "mentry", .BI "chtype " "character"); .TP 15 .B "void setCDKMentryCB (" .BI "CDKMENTRY *" "mentry", .BI "MENTRYCB " "callBackFunction"); .TP 15 .B "void setCDKMentryFillerChar (" .BI "CDKMENTRY *" "mentry", .BI "chtype " "filler"); .TP 15 .B "void setCDKMentryHiddenChar (" .BI "CDKMENTRY *" "mentry", .BI "chtype " "character"); .TP 15 .B "void setCDKMentryHorizontalChar (" .BI "CDKMENTRY *" "mentry", .BI "chtype " "character"); .TP 15 .B "void setCDKMentryLLChar (" .BI "CDKMENTRY *" "mentry", .BI "chtype " "character"); .TP 15 .B "void setCDKMentryLRChar (" .BI "CDKMENTRY *" "mentry", .BI "chtype " "character"); .TP 15 .B "void setCDKMentryMin (" .BI "CDKMENTRY *" "mentry", .BI "int " "maximum"); .TP 15 .B "void setCDKMentryPostProcess (" .BI "CDKMENTRY *" "mentry", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKMentryPreProcess (" .BI "CDKMENTRY *" "mentry", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKMentryULChar (" .BI "CDKMENTRY *" "mentry", .BI "chtype " "character"); .TP 15 .B "void setCDKMentryURChar (" .BI "CDKMENTRY *" "mentry", .BI "chtype " "character"); .TP 15 .B "void setCDKMentryValue (" .BI "CDKMENTRY *" "mentry", .BI "char *" "value"); .TP 15 .B "void setCDKMentryVerticalChar (" .BI "CDKMENTRY *" "mentry", .BI "chtype " "character"); .fi .SH DESCRIPTION The Cdk mentry widget creates a multiple line entry box with a label and an entry field. The following are functions which create or manipulate the Cdk mentry box widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKMentry activates the mentry widget and lets the user interact with the widget. The parameter \fBmentry\fR is a pointer to a non-NULL mentry widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a \fIchar *\fR representing the information typed into the widget and the widget data \fIexitType\fR will be set to \fIvNORMAL\fR. If the character entered was \fIESCAPE\fR then the function will return \fINULL\fR pointer and the widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP 5 .B cleanCDKMentry clears the information from the field. .TP 5 .B destroyCDKMentry removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKMentry draws the widget on the screen. If the \fBbox\fR parameter is true, the widget is drawn with a box. .TP 5 .B drawCDKMentryField redraws the multiple line entry field. .TP 5 .B eraseCDKMentry removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKMentryBox returns true if the widget will be drawn with a box around it. .TP 5 .B getCDKMentryFillerChar returns the character being used to draw unused space in the widget. .TP 5 .B getCDKMentryHiddenChar returns the character being used to draw hidden characters in the widget (obsolete). .TP 5 .B getCDKMentryMin returns the minimum length of a string the widget will allow. .TP 5 .B getCDKMentryValue returns the current value of the widget. .TP 5 .B injectCDKMentry injects a single character into the widget. The parameter \fBmentry\fR is a pointer to a non-NULL mentry. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR the function returns a \fIchar *\fR representing the information typed into the widget. The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns a \fINULL\fR pointer. The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns a \fINULL\fR pointer. The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .TP 5 .B moveCDKMentry moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDKMentry creates a mentry widget and returns a pointer to it. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBtitle\fR is the string which will be displayed at the top of the widget. The title can be more than one line; just provide a carriage return character at the line break. .TP 5 \fBlabel\fR is the string which will be displayed in the label of the mentry field. .TP 5 \fBfieldAttribute\fR is the attribute of the characters to be displayed when they are typed in. .TP 5 \fBfiller\fR is the character which is to display in an empty space in the mentry field. .TP 5 \fBdisplayType\fR tells how the mentry field will behave when a character is entered into the field. The following table outlines valid values for this field and what they mean: .LP .TS center tab(/); l l l l lw15 lw35 . \fBDisplay_Type/Meaning\fR = vCHAR/Only accepts alphabetic characters. vLCHAR/T{ Only accepts alphabetic characters. Maps the character to lower case when a character has been accepted. T} vUCHAR/T{ Only accepts alphabetic characters. Maps the character to upper case when a character has been accepted. T} vHCHAR/T{ Only accepts alphabetic characters. Displays a \fI.\fR when a character has been accepted. T} vUHCHAR/T{ Only accepts alphabetic characters. Displays a \fI.\fR and maps the character to upper case when a character has been accepted. T} vLHCHAR/T{ Only accepts alphabetic characters. Displays a \fI.\fR and maps the character to lower case when a character has been accepted. T} vINT/Only accepts numeric characters. vHINT/T{ Only accepts numeric characters. Displays a \fI.\fR when a character has been accepted. T} vMIXED/Accepts any character types. vLMIXED/T{ Accepts any character types. Maps the character to lower case when an alphabetic character has been accepted. T} vUMIXED/T{ Accepts any character types. Maps the character to upper case when an alphabetic character has been accepted. T} vHMIXED/T{ Accepts any character types. Displays a \fI.\fR when a character has been accepted. T} vLHMIXED/T{ Accepts any character types. Displays a \fI.\fR and maps the character to lower case when a character has been accepted. T} vUHMIXED/T{ Accepts any character types. Displays a \fI.\fR and maps the character to upper case when a character has been accepted. T} vVIEWONLY/Uneditable field. = .TE .TP 5 \fBfieldRows\fR and .TP 5 \fBfieldWidth\fR control the height and width of the field of the widget. If you provide a value of zero for either of the values, the field in the widget will be made as large as it can both in width and in height. If you provide a negative value, the field will be created the full height or width minus the value provided. .TP 5 \fBlogicalRows\fR is the number of rows for the mentry field. .TP 5 \fBminimumLength\fR is the number of characters which must be entered before the use can exit the mentry field. .TP 5 \fBcallBackFunction\fR allows the user to override the key processing element of the widget. .TP 5 \fBbox\fR is true if widget should be drawn with a box around it. .TP 5 \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .RE .TP 5 .B positionCDKMentry allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDKMentry lets the programmer modify certain elements of an existing entry widget. The parameter names correspond to the same parameter names listed in the \fBnewCDKMentry\fR function. .TP 5 .B setCDKMentryBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKMentryBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .TP 5 .B setCDKMentryBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKMentryBoxAttribute function sets the attribute of the box. .TP 5 .B setCDKMentryCB function allows the programmer to set a different widget input handler. The parameter \fBcallbackFunction\fR is of type \fIMENTRYCB\fR. The default function is \fICDKMentryCallBack\fR. .TP 5 .B setCDKMentryFillerChar sets the character to use when drawing unused space in the field. .TP 5 .B setCDKMentryHiddenChar sets the character to use when a hidden character type is used (obsolete). .TP 5 .B setCDKMentryHorizontalChar function sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKMentryLLChar function sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKMentryLRChar function sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKMentryMin sets the minimum length of the string that the widget will allow. .TP 5 .B setCDKMentryPostProcess allows the user to have the widget call a function after the key has been applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about post-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKMentryPreProcess allows the user to have the widget call a function after a key is hit and before the key is applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about pre-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKMentryULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKMentryURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKMentryValue sets the current value of the widget. .TP 5 .B setCDKMentryVerticalChar sets the vertical drawing character for the box to the given character. .SH KEY BINDINGS When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. The following table outlines the keys and their actions for this widget. .LP .TS center tab(/) box; l l lw(15) lw(35) . \fBKey/Action\fR = Left Arrow/Moves the cursor to the left. CTRL-B/Moves the cursor to the left. Right Arrow/Moves the cursor to the right. CTRL-F/Moves the cursor to the right. Up Arrow/Moves the cursor one row down. Down Arrow/Moves the cursor one row up. Delete/Deletes the character at the cursor. Backspace/Deletes the character before cursor, moves cursor left. CTRL-V/T{ Pastes whatever is in the paste buffer, into the widget. T} CTRL-X/T{ Cuts the contents from the widget and saves a copy in the paste buffer. T} CTRL-Y/T{ Copies the contents of the widget into the paste buffer. T} CTRL-U/T{ Erases the contents of the widget. T} CTRL-A/T{ Moves the cursor to the beginning of the entry field. T} CTRL-E/T{ Moves the cursor to the end of the entry field. T} CTRL-T/T{ Transposes the character under the cursor with the character to the right. T} Return/T{ Exits the widget and returns a \fIchar *\fR representing the information which was typed into the field. It also sets the widget data \fIexitType\fR in the widget pointer to \fIvNORMAL\fR. T} Tab/T{ Exits the widget and returns a \fIchar *\fR representing the information which was typed into the field. It also sets the widget data \fIexitType\fR in the widget pointer to \fIvNORMAL\fR. T} Escape/T{ Exits the widget and returns a \fINULL\fR pointer. It also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR. T} Ctrl-L/Refreshes the screen. .TE .fi .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_label.30000644000175100001440000001656610354555363014325 0ustar tomusers.\" $Id: cdk_label.3,v 1.14 2005/12/28 18:35:31 tom Exp $ .de XX .. .TH cdk_label 3 .SH NAME .XX activateCDKLabel .XX destroyCDKLabel .XX drawCDKLabel .XX eraseCDKLabel .XX getCDKLabelBox .XX getCDKLabelMessage .XX moveCDKLabel .XX newCDKLabel .XX positionCDKLabel .XX setCDKLabel .XX setCDKLabelBackgroundAttrib .XX setCDKLabelBackgroundColor .XX setCDKLabelBox .XX setCDKLabelBoxAttribute .XX setCDKLabelHorizontalChar .XX setCDKLabelLLChar .XX setCDKLabelLRChar .XX setCDKLabelMessage .XX setCDKLabelULChar .XX setCDKLabelURChar .XX setCDKLabelVerticalChar .XX waitCDKLabel cdk_label \- Creates a managed curses label widget. .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "void activateCDKLabel (" .BI "CDKLABEL *" "label", .BI "chtype " "unused"); .TP 15 .B "void destroyCDKLabel (" .BI "CDKLABEL *" "label"); .TP 15 .B "void drawCDKLabel (" .BI "CDKLABEL *" "label", .BI "boolean " "box"); .TP 15 .B "void eraseCDKLabel (" .BI "CDKLABEL *" "label"); .TP 15 .B "boolean getCDKLabelBox (" .BI "CDKLABEL *" "label"); .TP 15 .B "chtype **getCDKLabelMessage (" .BI "CDKLABEL *" "label" .BI "int *" "messageLines"); .TP 15 .B "void moveCDKLabel (" .BI "CDKLABEL *" "label", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKLABEL *newCDKLabel (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "char **" "message", .BI "int " "messageLines", .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKLabel (" .BI "CDKLABEL *" "label"); .TP 15 .B "void setCDKLabel (" .BI "CDKLABEL *" "label", .BI "char **" "message", .BI "int " "messageLines", .BI "boolean " "box"); .TP 15 .B "void setCDKLabelBackgroundAttrib (" .BI "CDKLABEL *" "label", .BI "chtype " "attribute"); .TP 15 .B "void setCDKLabelBackgroundColor (" .BI "CDKLABEL *" "label", .BI "char * " "color"); .TP 15 .B "void setCDKLabelBox (" .BI "CDKLABEL *" "label", .BI "boolean " "box"); .TP 15 .B "void setCDKLabelBoxAttribute (" .BI "CDKLABEL *" "label", .BI "chtype " "character"); .TP 15 .B "void setCDKLabelHorizontalChar (" .BI "CDKLABEL *" "label", .BI "chtype " "character"); .TP 15 .B "void setCDKLabelLLChar (" .BI "CDKLABEL *" "label", .BI "chtype " "character"); .TP 15 .B "void setCDKLabelLRChar (" .BI "CDKLABEL *" "label", .BI "chtype " "character"); .TP 15 .B "void setCDKLabelMessage (" .BI "CDKLABEL *" "label", .BI "char **" "message", .BI "int " "messageLines"); .TP 15 .B "void setCDKLabelULChar (" .BI "CDKLABEL *" "label", .BI "chtype " "character"); .TP 15 .B "void setCDKLabelURChar (" .BI "CDKLABEL *" "label", .BI "chtype " "character"); .TP 15 .B "void setCDKLabelVerticalChar (" .BI "CDKLABEL *" "label", .BI "chtype " "character"); .TP 15 .B "char waitCDKLabel (" .BI "CDKLABEL *" "label", .BI "char " "key"); .fi .SH DESCRIPTION The Cdk label widget creates a pop-up label window. The following functions create or manipulate the Cdk label widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKLabel obsolete entrypoint which calls \fBdrawCDKLabel\fP. .TP 5 .B destroyCDKLabel removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKLabel draws the label widget on the screen. If the \fBbox\fR parameter is true, the widget is drawn with a box. .TP 5 .B eraseCDKLabel removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKLabelBox returns true if the widget will be drawn with a box around it. .TP 5 .B getCDKLabelMessage returns the contents of the label widget. The parameter \fBmessageLines\fR points to the location which will be given the number of message-lines. .TP 5 .B moveCDKLabel moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDKLabel creates a label widget and returns a pointer to it. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBmessage\fR is the message to be displayed in the window. It may contain any of the standard Cdk display format commands. To learn more about this see \fIcdk_display (3)\fR. .TP 5 \fBrows\fR is the number of message rows that were passed in the \fBmessage\fR parameter. .TP 5 \fBbox\fR is true if widget should be drawn with a box around it. .TP 5 \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKLabel allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDKLabel allows the user to change the contents of the label widget. The parameters are the same as the \fBnewCDKLabel\fR. .TP 5 .B setCDKLabelBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKLabelBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. For more information see \fIcdk_display (3)\fR. .TP 5 .B setCDKLabelBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKLabelBoxAttribute sets the attribute of the box. .TP 5 .B setCDKLabelHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKLabelLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKLabelLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKLabelMessage This sets the contents of the label widget. .TP 5 .B setCDKLabelULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKLabelURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKLabelVerticalChar sets the vertical drawing character for the box to the given character. .TP 5 .B waitCDKLabel waits for a user to press a key. The \fBlabel\fR parameter is the pointer to a label widget, and \fBkey\fR is the key to wait for. If no specific key is desired, use \fI(char)0\fR. .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_button.30000644000175100001440000002215310354555363014546 0ustar tomusers'\" t .\" $Id: cdk_button.3,v 1.8 2005/12/28 18:35:31 tom Exp $ .de XX .. .TH cdk_button 3 .SH NAME .XX activateCDKButton .XX destroyCDKButton .XX drawCDKButton .XX eraseCDKButton .XX getCDKButtonBox .XX getCDKButtonMessage .XX injectCDKButton .XX moveCDKButton .XX newCDKButton .XX positionCDKButton .XX setCDKButton .XX setCDKButtonBackgroundAttrib .XX setCDKButtonBackgroundColor .XX setCDKButtonBox .XX setCDKButtonBoxAttribute .XX setCDKButtonHorizontalChar .XX setCDKButtonLLChar .XX setCDKButtonLRChar .XX setCDKButtonMessage .XX setCDKButtonULChar .XX setCDKButtonURChar .XX setCDKButtonVerticalChar cdk_button \- create and manage a curses button widget. .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include typedef void (*tButtonCallback)(struct SButton *button); .nf .TP 15 .B "int activateCDKButton (" .BI "CDKBUTTON *" "button", .BI "chtype * " "actions"); .TP 15 .BI "void destroyCDKButton (" .BI "CDKBUTTON *" "button"); .TP 15 .BI "void drawCDKButton (" .BI "CDKBUTTON *" "b", .BI "boolean " "box"); .TP 15 .BI "void eraseCDKButton (" .BI "CDKBUTTON *" "button"); .TP 15 .BI "boolean getCDKButtonBox (" .BI "CDKBUTTON *" "b"); .TP 15 .BI "chtype *getCDKButtonMessage (" .BI "CDKBUTTON *" "b"); .TP 15 .B "int injectCDKButtonbox (" .BI "CDKBUTTON *" "buttonbox", .BI "chtype " "input"); .TP 15 .BI "CDKBUTTON *newCDKButton(" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "char *" "message", .BI "tButtonCallback " "callback", .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .BI "void setCDKButton(" .BI "CDKBUTTON *" "b", .BI "char *" "message", .BI "boolean " "box"); .TP 15 .BI "void setCDKButtonBackgroundAttrib (" .BI "CDKBUTTON *" "b", .BI "chtype " "attribute"); .TP 15 .BI "void setCDKButtonBackgroundColor (" .BI "CDKBUTTON *" "b", .BI "char * " "color"); .TP 15 .BI "void setCDKButtonBox (" .BI "CDKBUTTON *" "button", .BI "boolean " "box"); .TP 15 .BI "void setCDKButtonBoxAttribute (" .BI "CDKBUTTON *" "b", .BI "chtype " "c"); .TP 15 .BI "void setCDKButtonHorizontalChar (" .BI "CDKBUTTON *" "b", .BI "chtype " "c"); .TP 15 .BI "void setCDKButtonLLChar (" .BI "CDKBUTTON *" "b", .BI "chtype " "c"); .TP 15 .BI "void setCDKButtonLRChar (" .BI "CDKBUTTON *" "b", .BI "chtype " "c"); .TP 15 .BI "void setCDKButtonMessage (" .BI "CDKBUTTON *" "b", .BI "char *" "message"); .TP 15 .BI "void setCDKButtonULChar (" .BI "CDKBUTTON *" "b", .BI "chtype " "c"); .TP 15 .BI "void setCDKButtonURChar (" .BI "CDKBUTTON *" "b", .BI "chtype " "c"); .TP 15 .BI "void setCDKButtonVerticalChar (" .BI "CDKBUTTON *" "b", .BI "chtype " "c"); .TP 15 .BI "void moveCDKButton(" .BI "CDKBUTTON *" "b", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .BI "void positionCDKButton (" .BI "CDKBUTTON *" "b"); .TP 15 .BI "void waitCDKButton (" .BI "CDKBUTTON *" "button", .BI "char " "key"); .fi .SH DESCRIPTION The Cdk button widget displays a message string and executes a callback when the user presses enter or space. As such, it is only useful on a screen that is being managed by some external screen traversal engine such as \fBtraverseCDKScreen()\fR. The button will be highlighted when the widget has the focus. The following functions create or manipulate the Cdk button widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKButton activates the button widget and lets the user interact with the widget. The parameter \fBbutton\fR is a pointer to a non-NULL button widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a value from 0 to the number of buttons -1, representing the button selected. It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR. If the character entered into this widget was \fIESCAPE\fR then the widget will return a value of -1 and the widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR. .TP 5 .B destroyCDKButton removes the widget from the screen and frees up any memory the object used. .TP 5 .B drawCDKButton draws the button widget on the screen. If the \fBbox\fR parameter is true, the widget is drawn with a box. .TP 5 .B eraseCDKButton removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKButtonBox returns true if the widget will be drawn with a box around it. .TP 5 .B getCDKButtonMessage returns the contents of the button widget. .TP 5 .B injectCDKButton injects a single character into the widget. The parameter \fBbutton\fR is a pointer to a non-NULL button widget. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR this function returns 0, representing the button selected. The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns -1. The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns -1. The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .TP 5 .B moveCDKButton moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDKButton creates a pointer to a buttonbox widget. Parameters: .RS .TP 5 The \fBscreen\fR parameter is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBmessage\fR is the message to display in the button window, formatted as described in \fIcdk_display\fR. .TP 5 \fBcallback\fR is an optional pointer to a callback function that will be executed when the user activates the button by pressing space or enter. .TP 5 \fBbox\fR is true if the widget should be drawn with a box around it. .TP 5 \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKButton allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDKButton lets the programmer modify certain elements of an existing buttonbox widget. The parameter names correspond to the same parameter names listed in the \fBnewCDKButton\fR function. .TP 5 .B setCDKButtonBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKButtonBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. (See \fIcdk_display\fR). .TP 5 .B setCDKButtonBox sets true if the widget will be drawn with a box around it. .TP 5 .B setCDKButtonBoxAttribute sets the attribute of the box. .TP 5 .B setCDKButtonHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKButtonLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKButtonLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKButtonMessage This sets the contents of the label widget. .TP 5 .B setCDKButtonULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKButtonURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKButtonVerticalChar sets the vertical drawing character for the box to the given character. .SH BUGS Changing the Box attribute after the widget has been created probably does not work right. None of the positioning/movement code has been tested. .SH AUTHOR Grant Edwards, Aspen Research Corporation .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_process (3), .BR cdk_screen (3), .BR cdk_traverse (3) cdk-5.0-20060507/man/cdk_graph.30000644000175100001440000002430310354555363014333 0ustar tomusers.\" $Id: cdk_graph.3,v 1.14 2005/12/28 18:35:31 tom Exp $ .de XX .. .TH cdk_graph 3 .SH NAME .XX activateCDKGraph .XX destroyCDKGraph .XX drawCDKGraph .XX eraseCDKGraph .XX getCDKGraphBox .XX getCDKGraphCharacter .XX getCDKGraphCharacters .XX getCDKGraphDisplayType .XX getCDKGraphValue .XX getCDKGraphValues .XX moveCDKGraph .XX newCDKGraph .XX positionCDKGraph .XX setCDKGraph .XX setCDKGraphBackgroundAttrib .XX setCDKGraphBackgroundColor .XX setCDKGraphBox .XX setCDKGraphBoxAttribute .XX setCDKGraphCharacter .XX setCDKGraphCharacters .XX setCDKGraphDisplayType .XX setCDKGraphHorizontalChar .XX setCDKGraphLLChar .XX setCDKGraphLRChar .XX setCDKGraphULChar .XX setCDKGraphURChar .XX setCDKGraphValue .XX setCDKGraphValues .XX setCDKGraphVerticalChar cdk_graph \- curses graph widget .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "void activateCDKGraph (" .BI "CDKGRAPH *" "graph", .BI "chtype *" "unused"); .TP 15 .B "void destroyCDKGraph (" .BI "CDKGRAPH *" "graph"); .TP 15 .B "void drawCDKGraph (" .BI "CDKGRAPH *" "graph", .BI "boolean " "box"); .TP 15 .B "void eraseCDKGraph (" .BI "CDKGRAPH *" "graph"); .TP 15 .B "boolean getCDKGraphBox (" .BI "CDKGRAPH *" "graph"); .TP 15 .B "chtype getCDKGraphCharacter (" .BI "CDKGRAPH *" "graph", .BI "int " "index"); .TP 15 .B "chtype *getCDKGraphCharacters (" .BI "CDKGRAPH *" "graph"); .TP 15 .B "EGraphDisplayType getCDKGraphDisplayType (" .BI "CDKGRAPH *" "graph"); .TP 15 .B "int getCDKGraphValue (" .BI "CDKGRAPH *" "graph", .BI "int " "index"); .TP 15 .B "int *getCDKGraphValues (" .BI "CDKGRAPH *" "graph", .BI "int *" "size"); .TP 15 .B "void moveCDKGraph (" .BI "CDKGRAPH *" "graph", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKGRAPH *newCDKGraph (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "int " "height", .BI "int " "width", .BI "char *" "title", .BI "char *" "xtitle", .BI "char *" "ytitle"); .TP 15 .B "void positionCDKGraph (" .BI "CDKGRAPH *" "graph"); .TP 15 .B "int setCDKGraph (" .BI "CDKGRAPH *" "graph", .BI "int *" "values", .BI "int " "valueCount", .BI "char *" "graphCharacters", .BI "boolean " "startAtZero", .BI "EGraphDisplayType " "displayType"); .TP 15 .B "void setCDKGraphBackgroundAttrib (" .BI "CDKGRAPH *" "graph", .BI "chtype " "attribute"); .TP 15 .B "void setCDKGraphBackgroundColor (" .BI "CDKGRAPH *" "graph", .BI "char * " "color"); .TP 15 .B "void setCDKGraphBox (" .BI "CDKGRAPH *" "graph", .BI "boolean " "box"); .TP 15 .B "void setCDKGraphBoxAttribute (" .BI "CDKGRAPH *" "graph", .BI "chtype " "character"); .TP 15 .B "int setCDKGraphCharacter (" .BI "CDKGRAPH *" "graph", .BI "int " "index", .BI "char *" "graphCharacter"); .TP 15 .B "int setCDKGraphCharacters (" .BI "CDKGRAPH *" "graph", .BI "char *" "graphCharacters"); .TP 15 .B "void setCDKGraphDisplayType (" .BI "CDKGRAPH *" "graph", .BI "EGraphDisplayType " "type"); .TP 15 .B "void setCDKGraphHorizontalChar (" .BI "CDKGRAPH *" "graph", .BI "chtype " "character"); .TP 15 .B "void setCDKGraphLLChar (" .BI "CDKGRAPH *" "graph", .BI "chtype " "character"); .TP 15 .B "void setCDKGraphLRChar (" .BI "CDKGRAPH *" "graph", .BI "chtype " "character"); .TP 15 .B "void setCDKGraphULChar (" .BI "CDKGRAPH *" "graph", .BI "chtype " "character"); .TP 15 .B "void setCDKGraphURChar (" .BI "CDKGRAPH *" "graph", .BI "chtype " "character"); .TP 15 .B "int setCDKGraphValue (" .BI "CDKGRAPH *" "graph", .BI "int " "index", .BI "int " "value", .BI "boolean " "startAtZero"); .TP 15 .B "int setCDKGraphValues (" .BI "CDKGRAPH *" "graph", .BI "int *" "values", .BI "int " "valueCount", .BI "boolean " "startAtZero"); .TP 15 .B "void setCDKGraphVerticalChar (" .BI "CDKGRAPH *" "graph", .BI "chtype " "character"); .fi .SH DESCRIPTION The Cdk graph widget creates a graph in either X/Y plot or line mode. The following functions create or manipulate the Cdk graph box widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKGraph this is an obsolete function that calls \fBdrawCDKGraph\fP. .TP 5 .B destroyCDKGraph removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKGraph draws the graph widget on the screen. The \fBbox\fR option tells whether to draw the widget with a box. .TP 5 .B eraseCDKGraph removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKGraphBox returns true if the widget will be drawn with a box around it. .TP 5 .B getCDKGraphCharacter returns the character in the graph at the given index. .TP 5 .B getCDKGraphCharacters returns all the characters currently in the graph widget. .TP 5 .B getCDKGraphDisplayType returns the current display type of the widget. .TP 5 .B getCDKGraphValue returns the value in the graph at the given index. .TP 5 .B getCDKGraphValues returns all the values currently in the graph widget. .TP 5 .B moveCDKGraph moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDKGraph creates a pointer to a graph widget. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBheight\fR and .TP 5 \fBwidth\fR control the height and width of the widget. If you provide a zero for either of the height or the width, the widget will be created with the full width and height of the screen. If you provide a negative value, the widget will be created the full height or width minus the value provided. .TP 5 \fBtitle\fR, .TP 5 \fBxtitle\fR and .TP 5 \fBytitle\fR are the graph title, the X axis title, and the Y axis title respectively. The graph title may be more than one line by providing a carriage return character at the line break. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKGraph allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDKGraph lets the programmer set the specific values of the graph widget. The parameter \fBvalues\fR is an integer array of the values to display in the widget; \fBvalueCount\fR is the number of values in the array. The parameter \fBgraphCharacters\fR is an array of the characters to use for each graph point. The parameter \fBstartAtZero\fR states whether you want the graph to start at zero or the lowest values of the X and Y axis'. The parameter \fBdisplayType\fR may be \fIvPLOT\fR, to make the graph draw the values as a plot graph, or \fIvLINE\fR to draw the values as a line graph. .TP 5 .B setCDKGraphBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKGraphBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .TP 5 .B setCDKGraphBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKGraphBoxAttribute function sets the attribute of the box. .TP 5 .B setCDKGraphCharacter lets the programmer set a specific character of the graph widget. The parameter \fBcharacter\fR is the new character, while \fBindex\fR is the index where the new character will be stored. .TP 5 .B setCDKGraphCharacters lets the programmer set the specific characters of the graph widget. The parameter \fBcharacters\fR is a char pointer array of the characters to display in the widget. .TP 5 .B setCDKGraphDisplayType allows the programmer tochange the way the graph draws itself. The parameter \fBdisplayType\fR may be \fIvPLOT\fR, to make the graph draw the values as a plot graph, or \fIvLINE\fR to draw the values as a line graph. .TP 5 .B setCDKGraphHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKGraphLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKGraphLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKGraphULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKGraphURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKGraphValue lets the programmer set a specific value of the graph widget. The parameter \fBvalue\fR is the new value, while \fBindex\fR is the index where the new value will be stored. The parameter \fBstartAtZero\fR states whether you want the graph to start at zero or the lowest values of the X and Y axis. .TP 5 .B setCDKGraphValues lets the programmer set the specific values of the graph widget. The parameter \fBvalues\fR is an integer array of the values to display in the widget; where \fBvalueCount\fR is the number of values in the array. The parameter \fBstartAtZero\fR states whether you want the graph to start at zero or the lowest values of the X and Y axis'. .TP 5 .B setCDKGraphVerticalChar sets the vertical drawing character for the box to the given character. .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_menu.30000644000175100001440000002062010354555363014174 0ustar tomusers'\" t .\" $Id: cdk_menu.3,v 1.18 2005/12/28 18:35:31 tom Exp $ .de XX .. .TH cdk_menu 3 .SH NAME .XX activateCDKMenu .XX destroyCDKMenu .XX drawCDKMenu .XX drawCDKMenuSubwin .XX eraseCDKMenu .XX eraseCDKMenuSubwin .XX getCDKMenuCurrentItem .XX getCDKMenuSubTitleHighlight .XX getCDKMenuTitleHighlight .XX injectCDKMenu .XX newCDKMenu .XX setCDKMenu .XX setCDKMenuBackgroundAttrib .XX setCDKMenuBackgroundColor .XX setCDKMenuCurrentItem .XX setCDKMenuPostProcess .XX setCDKMenuPreProcess .XX setCDKMenuSubTitleHighlight .XX setCDKMenuTitleHighlight cdk_menu \- curses menu widget .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "int activateCDKMenu (" .BI "CDKMENU *" "menu", .BI "chtype * " "actions"); .TP 15 .B "void destroyCDKMenu (" .BI "CDKMENU *" "menu"); .TP 15 .B "void drawCDKMenu (" .BI "CDKMENU *" "menu", .BI "boolean " "box"); .TP 15 .BI "void drawCDKMenuSubwin (" .BI "CDKMENU *" "menu"); .TP 15 .B "void eraseCDKMenu (" .BI "CDKMENU *" "menu"); .TP 15 .BI "void eraseCDKMenuSubwin (" .BI "CDKMENU *" "menu"); .TP 15 .B "void getCDKMenuCurrentItem (" .BI "CDKMENU *" "menu", .BI "int *" "menuItem", .BI "int *" "submenuItem"); .TP 15 .B "chtype getCDKMenuSubTitleHighlight (" .BI "CDKMENU *" "menu"); .TP 15 .B "chtype getCDKMenuTitleHighlight (" .BI "CDKMENU *" "menu"); .TP 15 .B "int injectCDKMenu (" .BI "CDKMENU *" "menu", .BI "chtype " "input"); .TP 15 .B "CDKMENU *newCDKMenu (" .BI "CDKSCREEN *" "cdkscreen", .BI "char *" "menulist"[MAX_MENU_ITEMS][MAX_SUB_ITEMS], .BI "int " "menuListLength", .BI "int *" "submenuListLength", .BI "int *" "menuLocation", .BI "int " "menuPos", .BI "chtype " "titleAttribute", .BI "chtype " "subtitleAttribute"); .TP 15 .B "void setCDKMenu (" .BI "CDKMENU *" "menu", .BI "int " "menuItem", .BI "int " "submenuItem", .BI "chtype " "titleAttribute", .BI "chtype " "subtitleAttribute"); .TP 15 .B "void setCDKMenuBackgroundAttrib (" .BI "CDKMENU *" "menu", .BI "chtype " "attribute"); .TP 15 .B "void setCDKMenuBackgroundColor (" .BI "CDKMENU *" "menu", .BI "char * " "color"); .TP 15 .B "void setCDKMenuCurrentItem (" .BI "CDKMENU *" "menu", .BI "int " "menuItem", .BI "int " "submenuItem"); .TP 15 .B "void setCDKMenuPostProcess (" .BI "CDKMENU *" "menu", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKMenuPreProcess (" .BI "CDKMENU *" "menu", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKMenuSubTitleHighlight (" .BI "CDKMENU *" "menu", .BI "chtype " "highlight"); .TP 15 .B "void setCDKMenuTitleHighlight (" .BI "CDKMENU *" "menu", .BI "chtype " "highlight"); .fi .SH DESCRIPTION The Cdk menu widget creates a pull-down menu list. The following are functions which create or manipulate the Cdk menu widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKMenu activates the menu widget and lets the user interact with the widget. The parameter \fBmenu\fR is a pointer to a non-NULL menu widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR then this then this function returns an integer which is a value of the current menu list * 100 + the sub-menu number. It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR. If the character entered into this widget was \fIESCAPE\fR then the widget will return a value of -1 and the widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR. .TP 5 .B destroyCDKMenu removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKMenu draws the menu widget on the screen. If the \fBbox\fR parameter is true, the widget is drawn with a box. .TP 5 .B drawCDKMenuSubwin draws the menu item subwindow. .TP 5 .B eraseCDKMenu removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B eraseCDKMenuSubwin erases the menu item subwindow. .TP 5 .B getCDKMenuCurrentItem returns the values \fBmenuItem\fR and \fBsubmenuItem\fR to the current menu selection. .TP 5 .B getCDKMenuSubTitleHighlight returns the highlight attribute of the sub-menu selection bar. .TP 5 .B getCDKMenuTitleHighlight returns the highlight attributes of the menu title. .TP 5 .B injectCDKMenu injects a single character into the widget. The parameter \fBmenu\fR is a pointer to a non-NULL menu widget. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR the function returns the current menu list * 100 + the sub-menu number. The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns -1. to \fIvESCAPE_HIT\fR. The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns -1. The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .TP 5 .B newCDKMenu creates a menu widget and returns a pointer to it. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBmenuList\fR is a list of the menu list titles. .TP 5 \fBmenuListLength\fR is the number of pull down menus. .TP 5 \fBsubmenuListLength\fR is the number of menu items under each menu list. .TP 5 \fBmenuLocation\fR tells where each menu is to be located. Valid values are \fILEFT\fR and \fIRIGHT\fR. .TP 5 \fBmenuPos\fR tells whether the menu is to be on the top of the screen or the bottom. Valid values are \fITOP\fR and \fIBOTTOM\fR. .TP 5 \fBtitleAttribute\fR and .TP 5 \fBsubtitleAttribute\fR are the character attributes of the title and sub-titles respectively. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B setCDKMenu lets the programmer modify certain elements of an existing menu widget. The parameters \fBmenuItem\fR and \fBsubmenuItem\fR set which menu list and sub-menu item are going to be highlighted when the widget is activated. The other parameter names correspond to the same parameter names listed in the \fBnewCDKMenu\fR function. .TP 5 .B setCDKMenuBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKMenuBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .TP 5 .B setCDKMenuCurrentItem sets the current item in the menu widget. .TP 5 .B setCDKMenuPostProcess allows the user to have the widget call a function after the key has been applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about post-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKMenuPreProcess allows the user to have the widget call a function after a key is hit and before the key is applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about pre-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKMenuSubTitleHighlight sets the highlight attribute of the sub-menu selection bar. .TP 5 .B setCDKMenuTitleHighlight sets the highlight attributes of the menu title. .SH KEY BINDINGS When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. The following table outlines the keys and their actions for this widget. .LP .TS center tab(/) allbox; l l l l lw15 lw35 . \fBKey/Action\fR Left Arrow/T{ Highlights the menu list to the left of the current menu. T} Right Arrow/T{ Highlights the menu list to the right of the current menu. T} Up Arrow/T{ Moves the current menu selection up one. T} Down Arrow/T{ Moves the current menu selection down one. T} Space/T{ Moves the current menu selection down one. T} Tab/T{ Highlights the menu list to the right of the current menu. T} Return/T{ Exits the widget and returns the index of the selected item. This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Escape/T{ Exits the widget and returns -1. This also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR. T} Ctrl-L/Refreshes the screen. .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_screen (3) cdk-5.0-20060507/man/gen-slider.30000644000175100001440000003371410354575357014455 0ustar tomusers'\" t .\" $Id: gen-slider.3,v 1.4 2005/12/28 20:51:59 tom Exp $" .de XX .. .TH cdk_slider 3 .SH NAME .XX activateCDK .XX destroyCDK .XX drawCDK .XX eraseCDK .XX getCDKBox #if .XX getCDKDigits #endif .XX getCDKHighValue .XX getCDKLowValue .XX getCDKValue .XX injectCDK .XX moveCDK .XX newCDK .XX positionCDK .XX setCDK .XX setCDKBackgroundAttrib .XX setCDKBackgroundColor .XX setCDKBox .XX setCDKBoxAttribute #if .XX setCDKDigits #endif .XX setCDKHorizontalChar .XX setCDKLLChar .XX setCDKLRChar .XX setCDKLowHigh .XX setCDKPostProcess .XX setCDKPreProcess .XX setCDKULChar .XX setCDKURChar .XX setCDKValue .XX setCDKVerticalChar cdk_slider \- curses slider widget (type ) .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "int activateCDK (" .BI "CDK *" "slider", .BI "chtype *" "actions"); .TP 15 .B "void destroyCDK (" .BI "CDK *" "slider"); .TP 15 .B "void drawCDK (" .BI "CDK *" "slider", .BI "boolean " "box"); .TP 15 .B "void eraseCDK (" .BI "CDK *" "slider"); .TP 15 .B "boolean getCDKBox (" .BI "CDK *" "slider"); #if .TP 15 .B "int getCDKDigits (" .BI "CDK *" "scale"); #endif .TP 15 .B " getCDKHighValue (" .BI "CDK *" "slider"); .TP 15 .B " getCDKLowValue (" .BI "CDK *" "slider"); .TP 15 .B " getCDKValue (" .BI "CDK *" "slider"); .TP 15 .B " injectCDK (" .BI "CDK *" "slider", .BI "chtype " "input"); .TP 15 .B "void moveCDK (" .BI "CDK *" "slider", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDK *newCDK (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "char *" "title", .BI "char *" "label", .BI "chtype " "fillerCharacter", .BI "int " "fieldWidth", .BI "int " "currentValue", .BI " " "lowValue", .BI " " "highValue", .BI " " "increment", .BI " " "fastIncrement", #if .BI "int " "digits", #endif .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDK (" .BI "CDK *" "slider"); .TP 15 .B "void setCDK (" .BI "CDK *" "slider", .BI " " "lowValue", .BI " " "highValue", .BI " " "currentValue", .BI "boolean " "box"); .TP 15 .B "void setCDKBackgroundAttrib (" .BI "CDK *" "slider", .BI "chtype " "attribute"); .TP 15 .B "void setCDKBackgroundColor (" .BI "CDK *" "slider", .BI "char * " "color"); .TP 15 .B "void setCDKBox (" .BI "CDK *" "slider", .BI "boolean " "boxWidget"); .TP 15 .B "void setCDKBoxAttribute (" .BI "CDK *" "slider", .BI "chtype " "character"); #if .TP 15 .B "void setCDKDigits (" .BI "CDK *" "scale", .BI "int " "digits"); #endif .TP 15 .B "void setCDKHorizontalChar (" .BI "CDK *" "slider", .BI "chtype " "character"); .TP 15 .B "void setCDKLLChar (" .BI "CDK *" "slider", .BI "chtype " "character"); .TP 15 .B "void setCDKLRChar (" .BI "CDK *" "slider", .BI "chtype " "character"); .TP 15 .B "void setCDKLowHigh (" .BI "CDK *" "slider", .BI " " "lowValue", .BI " " "highValue"); .TP 15 .B "void setCDKPostProcess (" .BI "CDK *" "slider", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKPreProcess (" .BI "CDK *" "slider", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKULChar (" .BI "CDK *" "slider", .BI "chtype " "character"); .TP 15 .B "void setCDKURChar (" .BI "CDK *" "slider", .BI "chtype " "character"); .TP 15 .B "void setCDKValue (" .BI "CDK *" "slider", .BI " " "value"); .TP 15 .B "void setCDKVerticalChar (" .BI "CDK *" "slider", .BI "chtype " "character"); .fi .SH DESCRIPTION The Cdk slider widget creates a visual slider box with a label and a slider field. The following are functions which create or manipulate the Cdk slider box widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDK activates the slider widget and lets the user interact with the widget. The parameter \fBslider\fR is a pointer to a non-NULL slider widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a value from the low value to the high value. It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR. If the character entered into this widget was \fIESCAPE\fR then the widget returns the unknown value (see the cdk_objs.h header file). The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP 5 .B destroyCDK removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDK draws the slider widget on the screen. If the \fBbox\fR option is true, the widget is drawn with a box. .TP 5 .B eraseCDK removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKBox returns true if the widget will be drawn with a box around it. #if .TP 5 .B getCDKDigits returns the number of digits shown after the decimal point for the box value. #endif .TP 5 .B getCDKHighValue returns the high value of the slider widget. .TP 5 .B getCDKLowValue returns the low value of the slider widget. .TP 5 .B getCDKValue returns the current value of the widget. .TP 5 .B injectCDK injects a single character into the widget. The parameter \fBslider\fR is a pointer to a non-NULL slider widget. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR the function returns a value ranging from the slider's low value to the slider's high value. The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns the unknown value (see the cdk_objs.h header file). The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns the unknown value (see the cdk_objs.h header file). The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .TP 5 .B moveCDK moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDK function creates a slider widget and returns a pointer to it.. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBtitle\fR is the string to display at the top of the widget. The title can be more than one line; just provide a carriage return character at the line break. .TP 5 \fBlabel\fR is the string to display in the label of the slider field. .TP 5 \fBfillerCharacter\fR is the character to be used to draw the slider bar in the field. .TP 5 \fBfieldWidth\fR controls the width of the widget. If you provide a value of zero the widget will be created with the full width of the screen. If you provide a negative value, the widget will be created the full width minus the value provided. .TP 5 \fBcurrentValue\fR is the value of the slider field when the widget is activated. .TP 5 \fBlowValue\fR and .TP 5 \fBhighValue\fR are the low and high values of the widget respectively. .TP 5 \fBincrement\fR is the regular increment value .TP 5 \fBfastIncrement\fR is the accelerated increment value. .TP 5 \fBbox\fR is true if the widget should be drawn with a box around it. .TP 5 \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDK allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDK lets the programmer modify certain elements of an existing slider widget. The parameter names correspond to the same parameter names listed in the \fInewCDK\fR function. .TP 5 .B setCDKBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .TP 5 .B setCDKBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKBoxAttribute function sets the attribute of the box. #if .TP 5 .B setCDKDigits sets the number of digits shown after the decimal point for the box value. #endif .TP 5 .B setCDKHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKLowHigh sets the low and high values of the widget. .TP 5 .B setCDKPostProcess allows the user to have the widget call a function after the key has been applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about post-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKPreProcess allows the user to have the widget call a function after a key is hit and before the key is applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about pre-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKValue sets the current value of the widget. .TP 5 .B setCDKVerticalChar sets the vertical drawing character for the box to the given character. .SH KEY BINDINGS When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. The following table outlines the keys and their actions for this widget. .LP .TS center tab(/) box; l l l l lw15 lw50 . \fBKey/Action\fR = Down Arrow/T{ Decrements the field by the normal decrement value. T} Up Arrow/T{ Increments the field by the normal increment value. T} u/T{ Increments the field by the normal increment value. T} Prev Page/T{ Decrements the field by the accelerated decrement value. T} U/T{ Decrements the field by the accelerated decrement value. T} Ctrl-B/T{ Decrements the field by the accelerated decrement value. T} Next Page/T{ Increments the field by the accelerated increment value. T} D/T{ Increments the field by the accelerated increment value. T} Ctrl-F/T{ Increments the field by the accelerated increment value. T} Home/Sets the value to the low value. g/Sets the value to the low value. End/Sets the value to the high value. G/Sets the value to the high value. $/Sets the value to the high value. Return/T{ Exits the widget and returns the current value. This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Tab/T{ Exits the widget and returns the current value. This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Escape/T{ Exits the widget and returns the unknown value (see the cdk_objs.h header file). This also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR. T} Ctrl-R/Refreshes the screen. .TE .LP If the cursor is not pointing to the field's value, the following key bindings apply. You may use the left/right arrows to move the cursor onto the field's value and modify it by typing characters to replace the digits and sign. .TS center tab(/) box; l l l l lw15 lw50 . \fBKey/Action\fR = Left Arrow/T{ Decrements the scale by the normal value. T} Right Arrow/Increments the scale by the normal value. = d/Decrements the scale by the normal value. D/Increments the scale by the accelerated value. -/Decrements the scale by the normal value. +/Increments the scale by the normal value. 0/Sets the scale to the low value. .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_objs.30000644000175100001440000000551410354575621014171 0ustar tomusers.\" $Id: cdk_objs.3,v 1.2 2005/12/28 20:54:41 tom Exp $ .de XX .. .TH cdk_objs 3 .SH NAME .XX cleanCdkTitle .XX drawCdkTitle .XX positionCDKObject .XX setCDKObjectBackgroundColor .XX setCDKObjectPostProcess .XX setCDKObjectPreProcess .XX setCdkExitType .XX setCdkTitle .XX validCDKObject cdk_objs \- Cdk object-support functions .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP .nf .TP 15 .B "void cleanCdkTitle (" .BI "CDKOBJS *" "obj"); .TP 15 .B "void drawCdkTitle (" .BI "WINDOW *" "window", .BI "CDKOBJS *" "object"); .TP 15 .B "void positionCDKObject (" .BI "CDKOBJS *" "object", .BI "WINDOW *" "win"); .TP 15 .B "void setCDKObjectBackgroundColor (" .BI "CDKOBJS *" "object", .BI "char *" "color"); .TP 15 .B "void setCDKObjectPostProcess (" .BI "CDKOBJS *" "object", .BI "PROCESSFN " "func", .BI "void *" "data"); .TP 15 .B "void setCDKObjectPreProcess (" .BI "CDKOBJS *" "object", .BI "PROCESSFN " "func", .BI "void *" "data"); .TP 15 .B "void setCdkExitType(" .BI "CDKOBJS *" "obj", .BI "EExitType *" "type", .BI "chtyp " "ch"); .TP 15 .B "int setCdkTitle (" .BI "CDKOBJS *" "obj", .BI "char *" "title", .BI "int " "boxWidth"); .TP 15 .B "bool validCDKObject (" .BI "CDKOBJS *" "obj"); .fi .SH DESCRIPTION Cdk is written in ANSI C, which has "no" object support. Most of the object support in Cdk is done using macros and a small number of types which hold object information: .RS 5 .TP 5 CDKFUNCS contains the function pointers for common methods of the widgets. It is separate from CDKOBJS because it is compiled into each widget's C code (see the DeclareCDKObjects() and DeclareSetXXchar() macros. The widget instances point to a single copy of CDKFUNCS for each widget. .TP 5 CDKOBJS Holds data common to all objects (widget instances). It appears first in each widget's struct to allow Cdk to use generic functions in binding.c, cdkscreen.c, position.c, etc. .RE .SH AVAILABLE FUNCTIONS The functions declared in are used in situations where the expressions are too complex for a macro. .TP 5 .B cleanCdkTitle Remove storage for the widget's title. .TP 5 .B drawCdkTitle, Draw the widget's title. .TP 5 .B positionCDKObject This allows the user to use the cursor keys to adjust the position of the widget. .TP 5 .B setCDKObjectBackgroundColor Set the background color of the widget. .TP 5 .B setCDKObjectPostProcess Set data for postprocessing. .TP 5 .B setCDKObjectPreProcess Set data for preprocessing. .TP 5 .B setCdkExitType Set the object's exit-type based on the input. The \fB.exitType\fP field should have been part of the CDKOBJS struct, but it is used too pervasively in Cdk4 applications to move. .TP 5 .B setCdkTitle Set the widget's title. .TP 5 .B validCDKObject Returns true if a "new" was done on the object but no "destroy". . .SH SEE ALSO cdk_binding (3) cdk_process (3) cdk-5.0-20060507/man/cdk_calendar.30000644000175100001440000003626310354555363015013 0ustar tomusers'\" t .\" $Id: cdk_calendar.3,v 1.22 2005/12/28 18:35:31 tom Exp $" .de XX .. .TH cdk_calendar 3 .SH NAME .XX activateCDKCalendar .XX destroyCDKCalendar .XX drawCDKCalendar .XX eraseCDKCalendar .XX getCDKCalendarBox .XX getCDKCalendarDate .XX getCDKCalendarDayAttribute .XX getCDKCalendarHighlight .XX getCDKCalendarMarker .XX getCDKCalendarMonthAttribute .XX getCDKCalendarYearAttribute .XX injectCDKCalendar .XX moveCDKCalendar .XX newCDKCalendar .XX positionCDKCalendar .XX removeCDKCalendarMarker .XX setCDKCalendar .XX setCDKCalendarBackgroundAttrib .XX setCDKCalendarBackgroundColor .XX setCDKCalendarBox .XX setCDKCalendarBoxAttribute .XX setCDKCalendarDate .XX setCDKCalendarDayAttribute .XX setCDKCalendarDaysNames .XX setCDKCalendarHighlight .XX setCDKCalendarHorizontalChar .XX setCDKCalendarLLChar .XX setCDKCalendarLRChar .XX setCDKCalendarMarker .XX setCDKCalendarMonthAttribute .XX setCDKCalendarMonthsNames .XX setCDKCalendarPostProcess .XX setCDKCalendarPreProcess .XX setCDKCalendarULChar .XX setCDKCalendarURChar .XX setCDKCalendarVerticalChar .XX setCDKCalendarYearAttribute cdk_calendar \- curses calendar widget. .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "time_t activateCDKCalendar (CDKCALENDAR *" "calendar", .BI "chtype " "*actions"); .TP 15 .B "void destroyCDKCalendar (" .BI "CDKCALENDAR *" "calendar"); .TP 15 .B "void drawCDKCalendar (CDKCALENDAR *" "calendar", .BI "boolean " "box"); .TP 15 .B "void eraseCDKCalendar (" .BI "CDKCALENDAR *" "calendar"); .TP 15 .B "boolean getCDKCalendarBox (" .BI "CDKCALENDAR *" "calendar"); .TP 15 .B "void getCDKCalendarDate (CDKCALENDAR *" "calendar", .BI "int *" "day", .BI "int *" "month", .BI "int *" "year"); .TP 15 .B "chtype getCDKCalendarDayAttribute (" .BI "CDKCALENDAR *" "calendar"); .TP 15 .B "chtype getCDKCalendarHighlight (" .BI "CDKCALENDAR *" "calendar"); .TP 15 .B "chtype getCDKCalendarMarker (" .BI "CDKCALENDAR *" "calendar", .BI "int " "day", .BI "int " "month", .BI "int " "year"); .TP 15 .B "chtype getCDKCalendarMonthAttribute (" .BI "CDKCALENDAR *" "calendar"); .TP 15 .B "chtype getCDKCalendarYearAttribute (" .BI "CDKCALENDAR *" "calendar"); .TP 15 .B "time_t injectCDKCalendar (" .BI "CDKCALENDAR *" "calendar", .BI "chtype " "input"); .TP 15 .B "void moveCDKCalendar (" .BI "CDKCALENDAR *" "calendar", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKCALENDAR *newCDKCalendar (CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "char *" "title", .BI "int " "day", .BI "int " "month", .BI "int " "year", .BI "chtype " "dayAttrib", .BI "chtype " "monthAttrib", .BI "chtype " "yearAttrib", .BI "chtype " "highlight", .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKCalendar (" .BI "CDKCALENDAR *" "calendar"); .TP 15 .B "void removeCDKCalendarMarker (" .BI "CDKCALENDAR *" "calendar", .BI "int " "day", .BI "int " "month", .BI "int " "year"); .TP 15 .B "void setCDKCalendar (" .BI "CDKCALENDAR *" "calendar", .BI "int " "day", .BI "int " "month", .BI "int " "year", .BI "chtype " "dayAttrib", .BI "chtype " "monthAttrib", .BI "chtype " "yearAttrib", .BI "chtype " "highlight", .BI "boolean " "box"); .TP 15 .B "void setCDKCalendarBackgroundAttrib (" .BI "CDKCALENDAR *" "calendar", .BI "chtype " "attribute"); .TP 15 .B "void setCDKCalendarBackgroundColor (" .BI "CDKCALENDAR *" "calendar", .BI "char * " "color"); .TP 15 .B "void setCDKCalendarBox (" .BI "CDKCALENDAR *" "calendar", .BI "boolean " "box"); .TP 15 .B setCDKCalendarBoxAttribute (" .BI "CDKCALENDAR *" "calendar", .BI "chtype " "ch"); .TP 15 .B "void setCDKCalendarDate (" .BI "CDKCALENDAR *" "calendar", .BI "int " "day", .BI "int " "month", .BI "int " "year"); .TP 15 .B "void setCDKCalendarDayAttribute (" .BI "CDKCALENDAR *" "calendar", .BI "chtype " "attribute"); .TP .B "void setCDKCalendarDaysNames (" .BI "CDKCALENDAR *" "calendar", .BI "char *" "days"); .TP 15 .B "void setCDKCalendarHighlight (" .BI "CDKCALENDAR *" "calendar", .BI "chtype " "attribute"); .TP 15 .B "void setCDKCalendarHorizontalChar (" .BI "CDKCALENDAR *" "calendar", .BI "chtype " "ch"); .TP 15 .B "void setCDKCalendarLLChar (" .BI "CDKCALENDAR *" "calendar", .BI "chtype " "ch"); .TP 15 .B "void setCDKCalendarLRChar (" .BI "CDKCALENDAR *" "calendar", .BI "chtype " "ch"); .TP 15 .B "void setCDKCalendarMarker (" .BI "CDKCALENDAR *" "calendar", .BI "int " "day", .BI "int " "month", .BI "int " "year", .BI "chtype " "marker"); .TP 15 .B "void setCDKCalendarMonthAttribute (" .BI "CDKCALENDAR *" "calendar", .BI "chtype " "attribute"); .TP .B "void setCDKCalendarMonthsNames (" .BI "CDKCALENDAR *" "calendar", .BI "char **" "months"); .TP 15 .B "void setCDKCalendarPostProcess (" .BI "CDKCALENDAR *" "calendar", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKCalendarPreProcess (" .BI "CDKCALENDAR *" "calendar", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B setCDKCalendarULChar (" .BI "CDKCALENDAR *" "calendar", .BI "chtype " "ch"); .TP 15 .B setCDKCalendarURChar (" .BI "CDKCALENDAR *" "calendar", .BI "chtype " "ch"); .TP 15 .B setCDKCalendarVerticalChar (" .BI "CDKCALENDAR *" "calendar", .BI "chtype " "ch"); .TP 15 .B "void setCDKCalendarYearAttribute (" .BI "CDKCALENDAR *" "calendar", .BI "chtype " "attribute"); .fi .SH DESCRIPTION The Cdk calendar widget creates a pop-up calendar. The calendar widget allows the user to traverse through months/years using the cursor keys. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKCalendar activates the calendar widget and lets the user interact with the widget. The \fBcalendar\fR widget is a pointer to a non-NULL calendar widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR then this function will return a type of \fItime_t\fR. The \fItime_t\fR type is used in the functions defined in the time.h header file. (see \fIlocaltime\fR or \fIctime\fR for more information). If the character entered into this widget was \fIESCAPE\fR or \fITAB\fR then this function will return a value of (time_t)-1 and the widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR. .TP 5 .B destroyCDKCalendar removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKCalendar draws the label widget on the screen. If the \fBbox\fR parameter is true, the widget is drawn with a box. .TP 5 .B eraseCDKCalendar removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKCalendarBox returns whether the widget will be drawn with a box around it. .TP 5 .B getCDKCalendarDate returns the current date the calendar is displaying. .TP 5 .B getCDKCalendarDayAttribute returns the attribute of the day attribute of the calendar. .TP 5 .B getCDKCalendarHighlight returns the attribute of the highlight bar of the scrolling list portion of the widget. .TP .B getCDKCalendarMarker returns the marker set on the calendar by \fBsetCDKCalendarMarker\fP. .TP 5 .B getCDKCalendarMonthAttribute returns the attribute of the month attribute of the calendar. .TP 5 .B getCDKCalendarYearAttribute returns the attribute of the year attribute of the calendar. .TP 5 .B injectCDKCalendar injects a single character into the widget. The parameter \fBcalendar\fR is a pointer to a non-NULL calendar widget. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR the function returns a value of type \fItime_t\fR (see \fIlocaltime\fR or \fIctime\fR for more information). The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns (time_t)-1. The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns (time_t)-1. The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .TP 5 .B moveCDKCalendar moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDKCalendar creates a calendar widget and returns a pointer to it. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBtitle\fR is the string which will be displayed at the top of the widget. The title can be more than one line; just provide a carriage return character at the line break. .TP 5 \fByear\fR, .TP 5 \fBmonth\fR and .TP 5 \fBday\fR .br set the initial date of the calendar. .TP 5 \fByearAttrib\fR, .TP 5 \fBmonthAttrib\fR and .TP 5 \fBdayAttrib\fR represent the attributes of the year, month, and day respectively. .TP 5 \fBhighlight\fR sets the highlight of the currently selected day. .TP 5 \fBbox\fR is true if the widget should be drawn with a box around it. .TP 5 \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKCalendar allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B removeCDKCalendarMarker removes a marker from the calendar. .TP 5 .B setCDKCalendar lets the programmer modify certain elements of an existing calendar widget. The \fBcalendar\fR parameter represents an existing calendar pointer. The other parameter names correspond to the same parameter names listed in the \fBnewCDKCalendar\fR function. .TP 5 .B setCDKCalendarBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKCalendarBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .TP 5 .B setCDKCalendarBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKCalendarBoxAttribute sets the attribute of the box. .TP 5 .B setCDKCalendarDate sets the calendar to the given date. If the value of the \fBday\fR, \fBmonth\fR, or \fByear\fR parameters is -1 then the current day, month, or year is used to set the date. .TP 5 .B setCDKCalendarDayAttribute sets the attribute of the day in the calendar. .TP .B setCDKCalendarDaysNames sets the names of the days of the week. The parameter is a string listing the 2-character abbreviations for the days. The default value is .RS "Su Mo Tu We Th Fr Sa" .RE .TP 5 .B setCDKCalendarHighlight sets the attribute of the highlight bar of the scrolling list portion of the widget. .TP 5 .B setCDKCalendarHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKCalendarLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKCalendarLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKCalendarMarker allows the user to set a marker which will be displayed when the month is drawn. The \fBmarker\fR parameter is the attribute to use when drawing the marker. If more than one marker is set on a single day, then the day will blink with the original marker attribute. .TP 5 .B setCDKCalendarMonthAttribute sets the attribute of the month in the calendar. .TP .B setCDKCalendarMonthsNames sets the names of the months of the year. The parameter is a 13-element array (since indexing starts with 1). The default values are the English month names, e.g., "January". .TP 5 .B setCDKCalendarPostProcess allows the user to have the widget call a function after the key has been applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about post-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKCalendarPreProcess allows the user to have the widget call a function after a key is hit and before the key is applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about pre-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKCalendarULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKCalendarURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKCalendarVerticalChar sets the vertical drawing character for the box to the given character. .TP 5 .B setCDKCalendarYearAttribute sets the attribute of the year in the calendar. .SH KEY BINDINGS When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. The following table outlines the keys and their actions for this widget. .LP .TS center tab(/) allbox; l l l l lw15 lw35 . \fBKey/Action\fR = Left Arrow/Moves the cursor to the previous day. Right Arrow/Moves the cursor to the next day. Up Arrow/Moves the cursor to the next week. Down Arrow/Moves the cursor to the previous week. t/Sets the calendar to the current date. T/Sets the calendar to the current date. n/Advances the calendar one month ahead. N/Advances the calendar six months ahead. p/Advances the calendar one month back. P/Advances the calendar six months back. -/Advances the calendar one year ahead. +/Advances the calendar one year back. Return/T{ Exits the widget and returns a value of \fItime_t\fR which represents the day selected at 1 second after midnight. This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Tab/T{ Exits the widget and returns a value of \fItime_t\fR which represents the day selected at 1 second after midnight. This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Escape/T{ Exits the widget and returns (time_)-1. This also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR. T} Ctrl-L/Refreshes the screen. .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_screen (3) cdk-5.0-20060507/man/gen-scale.30000644000175100001440000003334610354575365014262 0ustar tomusers'\" t .\" $Id: gen-scale.3,v 1.6 2005/12/28 20:52:05 tom Exp $" .de XX .. .TH cdk_scale 3 .SH NAME .XX activateCDK .XX destroyCDK .XX drawCDK .XX eraseCDK .XX getCDKBox #if .XX getCDKDigits #endif .XX getCDKHighValue .XX getCDKLowValue .XX getCDKValue .XX injectCDK .XX moveCDK .XX newCDK .XX positionCDK .XX setCDK .XX setCDKBackgroundAttrib .XX setCDKBackgroundColor .XX setCDKBox .XX setCDKBoxAttribute #if .XX setCDKDigits #endif .XX setCDKHorizontalChar .XX setCDKLLChar .XX setCDKLRChar .XX setCDKLowHigh .XX setCDKPostProcess .XX setCDKPreProcess .XX setCDKULChar .XX setCDKURChar .XX setCDKValue .XX setCDKVerticalChar cdk_scale \- curses scale widget (type ). .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B " activateCDK (" .BI "CDK *" "scale", .BI "chtype *" "actions"); .TP 15 .B "void destroyCDK (" .BI "CDK *" "scale"); .TP 15 .B "void drawCDK (" .BI "CDK *" "scale", .BI "boolean " "box"); .TP 15 .B "void eraseCDK (" .BI "CDK *" "scale"); .TP 15 .B "boolean getCDKBox (" .BI "CDK *" "scale"); #if .TP 15 .B "int getCDKDigits (" .BI "CDK *" "scale"); #endif .TP 15 .B " getCDKHighValue (" .BI "CDK *" "scale"); .TP 15 .B " getCDKLowValue (" .BI "CDK *" "scale"); .TP 15 .B " getCDKValue (" .BI "CDK *" "scale"); .TP 15 .B "int injectCDK (" .BI "CDK *" "scale", .BI "chtype " "input"); .TP 15 .B "void moveCDK (" .BI "CDK *" "scale", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDK *newCDK (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "char *" "title", .BI "char *" "label", .BI "chtype " "fieldAttribute", .BI "int " "fieldWidth", .BI " " "currentValue", .BI " " "lowValue", .BI " " "highValue", .BI " " "increment", .BI " " "fastIncrement", #if .BI "int " "digits", #endif .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDK (" .BI "CDK *" "scale"); .TP 15 .B "void setCDK (" .BI "CDK *" "scale", .BI " " "lowValue", .BI " " "highValue", .BI " " "currentValue", .BI "boolean " "box"); .TP 15 .B "void setCDKBackgroundAttrib (" .BI "CDK *" "scale", .BI "chtype " "attribute"); .TP 15 .B "void setCDKBackgroundColor (" .BI "CDK *" "scale", .BI "char * " "color"); .TP 15 .B "void setCDKBox (" .BI "CDK *" "scale", .BI "boolean " "box"); .TP 15 .B "void setCDKBoxAttribute (" .BI "CDK *" "scale", .BI "chtype " "character"); #if .TP 15 .B "void setCDKDigits (" .BI "CDK *" "scale", .BI "int " "digits"); #endif .TP 15 .B "void setCDKHorizontalChar (" .BI "CDK *" "scale", .BI "chtype " "character"); .TP 15 .B "void setCDKLLChar (" .BI "CDK *" "scale", .BI "chtype " "character"); .TP 15 .B "void setCDKLRChar (" .BI "CDK *" "scale", .BI "chtype " "character"); .TP 15 .B "void setCDKLowHigh (" .BI "CDK *" "scale", .BI " " "low", .BI " " "high"); .TP 15 .B "void setCDKPostProcess (" .BI "CDK *" "scale", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKPreProcess (" .BI "CDK *" "scale", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKULChar (" .BI "CDK *" "scale", .BI "chtype " "character"); .TP 15 .B "void setCDKURChar (" .BI "CDK *" "scale", .BI "chtype " "character"); .TP 15 .B "void setCDKValue (" .BI "CDK *" "scale", .BI " " "value"); .TP 15 .B "void setCDKVerticalChar (" .BI "CDK *" "scale", .BI "chtype " "character"); .fi .SH DESCRIPTION The Cdk scale widget creates a scale box with a label and a scale field. The following functions create or manipulate the Cdk scale box widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDK activates the scale widget and lets the user interact with the widget. The parameter \fBscale\fR is a pointer to a non-NULL scale widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a value from the low value to the high value. It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR. If the character entered into this widget was \fIESCAPE\fR then the widget will return the unknown value (see the cdk_objs.h header file). The widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR. .TP 5 .B destroyCDK removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDK draws the scale widget on the screen. If the \fBbox\fR parameter is true, the widget is drawn with a box. .TP 5 .B eraseCDK removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKBox returns whether the widget will be drawn with a box around it. #if .TP 5 .B getCDKDigits returns the number of digits shown after the decimal point for the box value. #endif .TP 5 .B getCDKHighValue returns the high value of the scale widget. .TP 5 .B getCDKLowValue returns the low value of the scale widget. .TP 5 .B getCDKValue returns the current value of the widget. .TP 5 .B injectCDK injects a single character into the widget. The parameter \fBscale\fR is a pointer to a non-NULL scale widget. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR the function returns a value ranging from the scale's low value to the scale's high value. The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns the unknown value (see the cdk_objs.h header file). The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns the unknown value (see the cdk_objs.h header file). The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .TP 5 .B moveCDK moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDK creates a pointer to a scale widget. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBtitle\fR is the string to display at the top of the widget. The title can be more than one line; just provide a carriage return character at the line break. .TP 5 \fBlabel\fR is the string to display in the label of the scale field. .TP 5 \fBfieldAttribute\fR is the attribute of the characters displayed in the field. .TP 5 \fBfieldWidth\fR controls the width of the widget. If you provide a value of zero the widget will be created with the full width of the screen. If you provide a negative value, the widget will be created the full width minus the value provided. .TP 5 \fBcurrentValue\fR is the value of the scale field when the widget is activated. .TP 5 \fBlowValue\fR and .TP 5 \fBhighValue\fR are the low and high values of the widget respectively. .TP 5 \fBincrement\fR is the regular increment value .TP 5 \fBfastIncrement\fR is the accelerated increment value. .TP 5 \fBbox\fR is true if the widget should be drawn with a box around it. .TP 5 \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDK allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDK lets the programmer modify certain elements of an existing scale widget. The parameter names correspond to the same parameter names listed in the \fInewCDK\fR function. .TP 5 .B setCDKBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .TP 5 .B setCDKBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKBoxAttribute sets the attribute of the box. #if .TP 5 .B setCDKDigits sets the number of digits shown after the decimal point for the box value. #endif .TP 5 .B setCDKHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKLowHigh sets the low and high values of the widget. .TP 5 .B setCDKPostProcess allows the user to have the widget call a function after the key has been applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about post-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKPreProcess allows the user to have the widget call a function after a key is hit and before the key is applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about pre-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKValue sets the current value of the widget. .TP 5 .B setCDKVerticalChar sets the vertical drawing character for the box to the given character. .SH KEY BINDINGS When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. The following table outlines the keys and their actions for this widget. .LP .TS center tab(/) box; l l l l lw15 lw50 . \fBKey/Action\fR = Down Arrow/T{ Decrements the scale by the normal value. T} Up Arrow/Increments the scale by the normal value. u/Increments the scale by the normal value. Prev Page/Decrements the scale by the accelerated value. U/Decrements the scale by the accelerated value. Ctrl-B/Decrements the scale by the accelerated value. Next Page/Increments the scale by the accelerated value. Ctrl-F/Increments the scale by the accelerated value. Home/Sets the scale to the low value. g/Sets the scale to the low value. ^/Sets the scale to the low value. End/Sets the scale to the high value. G/Sets the scale to the high value. $/Sets the scale to the high value. Return/T{ Exits the widget and returns the index of the selected value. This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Tab/T{ Exits the widget and returns the index of the selected value. This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Escape/T{ Exits the widget and returns the unknown value (see the cdk_objs.h header file). This also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR. T} Ctrl-R/Refreshes the screen. .TE .LP If the cursor is not pointing to the field's value, the following key bindings apply. You may use the left/right arrows to move the cursor onto the field's value and modify it by typing characters to replace the digits and sign. .TS center tab(/) box; l l l l lw15 lw50 . \fBKey/Action\fR = Left Arrow/T{ Decrements the scale by the normal value. T} Right Arrow/Increments the scale by the normal value. = d/Decrements the scale by the normal value. D/Increments the scale by the accelerated value. -/Decrements the scale by the normal value. +/Increments the scale by the normal value. 0/Sets the scale to the low value. .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_selection.30000644000175100001440000003571710354604407015224 0ustar tomusers'\" t .\" $Id: cdk_selection.3,v 1.22 2005/12/28 21:52:07 tom Exp $" .de XX .. .TH cdk_selection 3 .SH NAME .XX activateCDKSelection .XX destroyCDKSelection .XX drawCDKSelection .XX eraseCDKSelection .XX getCDKSelectionBox .XX getCDKSelectionChoice .XX getCDKSelectionChoices .XX getCDKSelectionCurrent .XX getCDKSelectionHighlight .XX getCDKSelectionItems .XX getCDKSelectionMode .XX getCDKSelectionModes .XX getCDKSelectionTitle .XX injectCDKSelection .XX moveCDKSelection .XX newCDKSelection .XX positionCDKSelection .XX setCDKSelection .XX setCDKSelectionBackgroundAttrib .XX setCDKSelectionBackgroundColor .XX setCDKSelectionBox .XX setCDKSelectionBoxAttribute .XX setCDKSelectionChoice .XX setCDKSelectionChoices .XX setCDKSelectionCurrent .XX setCDKSelectionHighlight .XX setCDKSelectionHorizontalChar .XX setCDKSelectionItems .XX setCDKSelectionLLChar .XX setCDKSelectionLRChar .XX setCDKSelectionMode .XX setCDKSelectionModes .XX setCDKSelectionPostProcess .XX setCDKSelectionPreProcess .XX setCDKSelectionTitle .XX setCDKSelectionULChar .XX setCDKSelectionURChar .XX setCDKSelectionVerticalChar cdk_selection \- curses selection list widget. .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "int activateCDKSelection (" .BI "CDKSELECTION *" "selection", .BI "chtype * " "actions"); .TP 15 .B "void destroyCDKSelection (" .BI "CDKSELECTION *" "selection"); .TP 15 .B "void drawCDKSelection (" .BI "CDKSELECTION *" "selection", .BI "boolean " "box"); .TP 15 .B "void eraseCDKSelection (" .BI "CDKSELECTION *" "selection"); .TP 15 .B "boolean getCDKSelectionBox (" .BI "CDKSELECTION *" "selection"); .TP 15 .B "int getCDKSelectionChoice (" .BI "CDKSELECTION *" "selection", .BI "int " "index"); .TP 15 .B "int *getCDKSelectionChoices (" .BI "CDKSELECTION *" "selection"); .TP 15 .B "int getCDKSelectionCurrent (" .BI "CDKSELECTION *" "selection"); .TP 15 .B "chtype getCDKSelectionHighlight (" .BI "CDKSELECTION *" "selection"); .TP 15 .B "int getCDKSelectionItems (" .BI "CDKSELECTION *" "selection", .BI "char **" "list"); .TP 15 .B "int getCDKSelectionMode (" .BI "CDKSELECTION *" "selection", .BI "int " "index"); .TP 15 .B "int *getCDKSelectionModes (" .BI "CDKSELECTION *" "selection"); .TP 15 .B "char *getCDKSelectionTitle (" .BI "CDKSELECTION *" "selection"); .TP 15 .B "int injectCDKSelection (" .BI "CDKSELECTION *" "selection", .BI "chtype " "input"); .TP 15 .B "void moveCDKSelection (" .BI "CDKSELECTION *" "selection", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKSELECTION *newCDKSelection (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "int " "spos", .BI "int " "height", .BI "int " "width", .BI "char *" "title", .BI "char **" "selectionList", .BI "int " "selectionListLength", .BI "char **" "choiceList", .BI "int " "choiceListLength", .BI "chtype " "highlight", .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKSelection (" .BI "CDKSELECTION *" "selection"); .TP 15 .B "void setCDKSelection (" .BI "CDKSELECTION *" "selection", .BI "chtype " "highlight", .BI "int *" "defChoices", .BI "boolean " "box"); .TP 15 .B "void setCDKSelectionBackgroundAttrib (" .BI "CDKSELECTION *" "selection", .BI "chtype " "attribute"); .TP 15 .B "void setCDKSelectionBackgroundColor (" .BI "CDKSELECTION *" "selection", .BI "char * " "color"); .TP 15 .B "void setCDKSelectionBox (" .BI "CDKSELECTION *" "selection", .BI "boolean " "boxWidget"); .TP 15 .B "void setCDKSelectionBoxAttribute (" .BI "CDKSELECTION *" "selection", .BI "chtype " "character"); .TP 15 .B "void setCDKSelectionChoice (" .BI "CDKSELECTION *" "selection", .BI "int " "index", .BI "int " "choice"); .TP 15 .B "void setCDKSelectionChoices (" .BI "CDKSELECTION *" "selection", .BI "int *" "choices"); .TP 15 .B "void setCDKSelectionCurrent (" .BI "CDKSELECTION *" "selection", .BI "int" "index"); .TP 15 .B "void setCDKSelectionHighlight (" .BI "CDKSELECTION *" "selection", .BI "chtype " "highlight"); .TP 15 .B "void setCDKSelectionHorizontalChar (" .BI "CDKSELECTION *" "selection", .BI "chtype " "character"); .TP 15 .B "void setCDKSelectionItems (" .BI "CDKSELECTION *" "selection", .BI "char **" "list", .BI "int " "listSize"); .TP 15 .B "void setCDKSelectionLLChar (" .BI "CDKSELECTION *" "selection", .BI "chtype " "character"); .TP 15 .B "void setCDKSelectionLRChar (" .BI "CDKSELECTION *" "selection", .BI "chtype " "character"); .TP 15 .B "void setCDKSelectionMode (" .BI "CDKSELECTION *" "selection", .BI "int " "index", .BI "int " "mode"); .TP 15 .B "void setCDKSelectionModes (" .BI "CDKSELECTION *" "selection", .BI "int *" "modes"); .TP 15 .B "void setCDKSelectionPostProcess (" .BI "CDKSELECTION *" "selection", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKSelectionPreProcess (" .BI "CDKSELECTION *" "selection", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKSelectionTitle (" .BI "CDKSELECTION *" "selection", .BI "char *" "title"); .TP 15 .B "void setCDKSelectionULChar (" .BI "CDKSELECTION *" "selection", .BI "chtype " "character"); .TP 15 .B "void setCDKSelectionURChar (" .BI "CDKSELECTION *" "selection", .BI "chtype " "character"); .TP 15 .B "void setCDKSelectionVerticalChar (" .BI "CDKSELECTION *" "selection", .BI "chtype " "character"); .fi .SH DESCRIPTION The Cdk selection widget creates a selection list. The following functions create or manipulate the Cdk selection list widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKSelection activates the selection widget and lets the user interact with the widget. The parameter \fBselection\fR is a pointer to a non-NULL selection widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR or \fITAB\fR then this function will return 1. Itm will also set the widget data \fIexitType\fR to \fIvNORMAL\fR. If the character entered into this widget was \fIESCAPE\fR then the widget will return a value of -1 and the widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR. .TP 5 .B destroyCDKSelection removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKSelection draws the selection widget on the screen. If the \fBbox\fR parameter is true, the widget is drawn with a box. .TP 5 .B eraseCDKSelection removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKSelectionBox returns true if the widget will be drawn with a box around it. .TP 5 .B getCDKSelectionChoice returns the selection choice at the given index. .TP 5 .B getCDKSelectionChoices returns an array of the current selection choices for the widget. .TP 5 .B getCDKSelectionCurrent returns the current selection index. .TP 5 .B getCDKSelectionHighlight returns the attribute of the highlight bar. .TP 5 .B getCDKSelectionItems copies the selection-list items into the caller's array and returns the number of items in the list. .TP 5 .B getCDKSelectionMode returns the selection mode at the given index. .TP 5 .B getCDKSelectionModes returns an array of the current modes for the widget. .TP 5 .B getCDKSelectionTitle returns the first line of the title of the selection widget. The caller must free the returned value. .TP 5 .B injectCDKSelection injects a single character into the widget. The parameter \fBselection\fR is a pointer to a non-NULL selection widget. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR the function returns 1. The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns -1. \fIvESCAPE_HIT\fR. The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns -1. The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .TP 5 .B moveCDKSelection moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDKSelection creates a selection widget and returns a pointer to it. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBspos\fR is where the scroll bar is to be placed. It may be one of three values: .RS .TP 5 \fILEFT\fR puts the scroll bar on the left of the scrolling list. \fIRIGHT\fR puts the scroll bar on the right side of the list, and .TP 5 \fINONE\fR does not add a scroll bar. .RE .TP 5 \fBheight\fR and .TP 5 \fBwidth\fR control the height and width of the widget. If you provide a value of zero for either of the height or the width, the widget will be created with the full width and height of the screen. If you provide a negative value, the widget will be created the full height or width minus the value provided. .TP 5 \fBtitle\fR is the string which to display at the top of the widget. The title can be more than one line; just provide a carriage return character at the line break. .TP 5 \fBselectionList\fR is the list of items to display in the selection list .TP 5 \fBselectionListLength\fR is the number of elements in the given list. .TP 5 \fBchoiceList\fR is the list of choices that will be selected when the user presses the space bar. .TP 5 \fBchoiceListLength\fR is the length of this list. .TP 5 \fBhighlight\fR specifies the display attribute of the currently selected item. .TP 5 \fBbox\fR is true if the widget should be drawn with a box around it. .TP 5 \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKSelection allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDKSelection lets the programmer modify certain elements of an existing selection widget. The parameter names correspond to the same parameter names listed in the \fBnewCDKSelection\fR function. .TP 5 .B setCDKSelectionBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKSelectionBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .TP 5 .B setCDKSelectionBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKSelectionBoxAttribute sets the attribute of the box. .TP 5 .B setCDKSelectionChoice sets the selection choice value at the given index. .TP 5 .B setCDKSelectionChoices sets the selection choice values of the widget. .TP 5 .B setCDKSelectionCurrent sets the current selection index. .TP 5 .B setCDKSelectionHighlight sets the attribute of the highlight bar. .TP 5 .B setCDKSelectionHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKSelectionItems sets the selection list items. .TP 5 .B setCDKSelectionLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKSelectionLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKSelectionMode sets the selection mode at the given index. .TP 5 .B setCDKSelectionModes sets the selection mode of the elements of the widget. There are two acceptable values for the modes: 0 which allows the user to change the selection value at the given index; and 1 which sets the element to a read-only state. .TP 5 .B setCDKSelectionPostProcess allows the user to have the widget call a function after the key has been applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about post-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKSelectionPreProcess allows the user to have the widget call a function after a key is hit and before the key is applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR is a pointer to \fIvoid\fR. To learn more about pre-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKSelectionTitle set the selection list's title. .TP 5 .B setCDKSelectionULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKSelectionURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKSelectionVerticalChar sets the vertical drawing character for the box to the given character. .SH KEY BINDINGS When the widget is activated there are several default key bindings which help the user enter or manipulate the information quickly: .LP .TS center tab(/) box; l l l l lw15 lw35 . \fBKey/Action\fR = Left Arrow/T{ Shift the whole list left one column. T} Right Arrow/T{ Shift the whole list right one column. T} Up Arrow/T{ Select the previous item in the list. T} Down Arrow/T{ Select the next item in the list. T} _ Prev Page Ctrl-B/Scroll one page backward. _ Next Page Ctrl-F/Scroll one page forward. _ 1 < g Home/Move to the first element in the list. _ > G End/Move to the last element in the list. _ $/Shift the whole list to the far right. |/Shift the whole list to the far left. _ Space/T{ Cycles to the next choice on the current item. T} Return/T{ Exit the widget and return 1. Also set the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Tab/T{ Exit the widget and return 1. Also set the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Escape/T{ Exit the widget and return -1. Also set the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR. T} Ctrl-L/Refreshes the screen. .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_buttonbox.30000644000175100001440000002762110354555363015264 0ustar tomusers'\" t .\" $Id: cdk_buttonbox.3,v 1.20 2005/12/28 18:35:31 tom Exp $ .de XX .. .TH cdk_buttonbox 3 .SH NAME .XX activateCDKButtonbox .XX destroyCDKButtonbox .XX drawCDKButtonbox .XX drawCDKButtonboxButtons .XX eraseCDKButtonbox .XX getCDKButtonboxBox .XX getCDKButtonboxButtonCount .XX getCDKButtonboxCurrentButton .XX getCDKButtonboxHighlight .XX injectCDKButtonbox .XX moveCDKButtonbox .XX newCDKButtonbox .XX positionCDKButtonbox .XX setCDKButtonbox .XX setCDKButtonboxBackgroundAttrib .XX setCDKButtonboxBackgroundColor .XX setCDKButtonboxBox .XX setCDKButtonboxBoxAttribute .XX setCDKButtonboxCurrentButton .XX setCDKButtonboxHighlight .XX setCDKButtonboxHorizontalChar .XX setCDKButtonboxLLChar .XX setCDKButtonboxLRChar .XX setCDKButtonboxPostProcess .XX setCDKButtonboxPreProcess .XX setCDKButtonboxULChar .XX setCDKButtonboxURChar .XX setCDKButtonboxVerticalChar cdk_buttonbox \- Creates a managed curses buttonbox widget. .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "int activateCDKButtonbox (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "chtype * " "actions"); .TP 15 .B "void destroyCDKButtonbox (" .BI "CDKBUTTONBOX *" "buttonbox"); .TP 15 .B "void drawCDKButtonbox (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "boolean " "box"); .TP 15 .B "void drawCDKButtonboxButtons (" .BI "CDKBUTTONBOX *" "buttonbox"); .TP 15 .B "void eraseCDKButtonbox (" .BI "CDKBUTTONBOX *" "buttonbox"); .TP 15 .B "boolean getCDKButtonboxBox (" .BI "CDKBUTTONBOX *" "buttonbox"); .TP 15 .B "int getCDKButtonboxButtonCount (" .BI "CDKBUTTONBOX *" "buttonbox"); .TP 15 .B "int getCDKButtonboxCurrentButton (" .BI "CDKBUTTONBOX *" "buttonbox"); .TP 15 .B "chtype getCDKButtonboxHighlight (" .BI "CDKBUTTONBOX *" "buttonbox"); .TP 15 .B "int injectCDKButtonbox (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "chtype " "input"); .TP 15 .B "void moveCDKButtonbox (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKBUTTONBOX *newCDKButtonbox (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "int " "height", .BI "int " "width", .BI "char * " "title" , .BI "int " "rows", .BI "int " "cols", .BI "char ** " "buttons" , .BI "int " "buttonCount", .BI "chtype " "highlight" , .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKButtonbox (" .BI "CDKBUTTONBOX *" "buttonbox"); .TP 15 .B "void setCDKButtonbox (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "chtype " "highlight", .BI "boolean " "box"); .TP 15 .B "void setCDKButtonboxBackgroundAttrib (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "chtype " "attribute"); .TP 15 .B "void setCDKButtonboxBackgroundColor (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "char * " "color"); .TP 15 .B "void setCDKButtonboxBox (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "boolean " "box"); .TP 15 .B "void setCDKButtonboxBoxAttribute (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "chtype " "character"); .TP 15 .B "void setCDKButtonboxCurrentButton (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "int " "button"); .TP 15 .B "void setCDKButtonboxHighlight (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "chtype " "highlight"); .TP 15 .B "void setCDKButtonboxHorizontalChar (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "chtype " "character"); .TP 15 .B "void setCDKButtonboxLLChar (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "chtype " "character"); .TP 15 .B "void setCDKButtonboxLRChar (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "chtype " "character"); .TP 15 .B "void setCDKButtonboxPostProcess (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKButtonboxPreProcess (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKButtonboxULChar (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "chtype " "character"); .TP 15 .B "void setCDKButtonboxURChar (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "chtype " "character"); .TP 15 .B "void setCDKButtonboxVerticalChar (" .BI "CDKBUTTONBOX *" "buttonbox", .BI "chtype " "character"); .fi .SH DESCRIPTION The Cdk buttonbox widget creates a buttonbox box with a message and a varied number of buttons to choose from. The following functions create or manipulate the Cdk buttonbox box widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKButtonbox activates the buttonbox widget and lets the user interact with the widget. The parameter \fBbuttonbox\fR is a pointer to a non-NULL buttonbox widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a value from 0 to the number of buttons -1, representing the button selected. It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR. If the character entered into this widget was \fIESCAPE\fR then the widget will return a value of -1 and the widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR. .TP 5 .B destroyCDKButtonbox removes the widget from the screen and releases any memory the object used. .TP 5 .B drawCDKButtonbox draws the buttonbox widget on the screen. If the \fBbox\fR parameter is true, the widget is drawn with a box. .TP 5 .B drawCDKButtonboxButtons draws the buttons. .TP 5 .B eraseCDKButtonbox removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKButtonboxBox returns true if the widget will be drawn with a box around it. .TP 5 .B getCDKButtonboxButtonCount returns the number of buttons in the button box. .TP 5 .B getCDKButtonboxCurrentButton returns the current button-number. .TP 5 .B getCDKButtonboxHighlight returns the highlight attribute of the widget. .TP 5 .B injectCDKButtonbox injects a single character into the widget. The parameter \fBbuttonbox\fR is a pointer to a non-NULL buttonbox widget. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR the function returns a value ranging from zero to one less than the number of buttons, representing the button selected. The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns -1. \fIvESCAPE_HIT\fR. The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns -1. The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .TP 5 .B moveCDKButtonbox moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDKButtonbox creates a pointer to a buttonbox widget. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It be an integer value or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBheight\fR and .TP 5 \fBwidth\fR control the height and width of the widget. .TP 5 \fBtitle\fR is the title of the widget. .TP 5 \fBrows\fR is the number of rows of buttons. .TP 5 \fBcols\fR sets the number of columns. .TP 5 \fBbuttons\fR is an array containing the button labels. .TP 5 \fBbuttonCount\fR is the number of elements in the \fBbuttons\fR array. .TP 5 \fBhighlight\fR is the attribute of the currently highlighted button. .TP 5 \fBbox\fR is true if the widget should be drawn with a box around it. .TP 5 \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKButtonbox allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDKButtonbox lets the programmer modify certain elements of an existing buttonbox widget. The parameter names correspond to the same parameter names listed in the \fBnewCDKButtonbox\fR function. .TP 5 .B setCDKButtonboxBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKButtonboxBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. (See \fIcdk_display\fR). .TP 5 .B setCDKButtonboxBox sets true if the widget will be drawn with a box around it. .TP 5 .B setCDKButtonboxBoxAttribute sets the attribute of the box. .TP 5 .B setCDKButtonboxCurrentButton sets the current button-number for the box. .TP 5 .B setCDKButtonboxHighlight sets the highlight attribute of the selected button. .TP 5 .B setCDKButtonboxHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKButtonboxLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKButtonboxLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKButtonboxPostProcess allows the user to have the widget call a function after the key has been applied to the widget. The parameter \fBfunction\fR is the callback function. (See \fIcdk_process\fR). .TP 5 .B setCDKButtonboxPreProcess allows the user to have the widget call a function after a key is hit and before the key is applied to the widget. The parameter \fBfunction\fR is the callback function. (See \fIcdk_process\fR). .TP 5 .B setCDKButtonboxULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKButtonboxURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKButtonboxVerticalChar sets the vertical drawing character for the box to the given character. .SH KEY BINDINGS When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. The following table outlines the keys and their actions for this widget. .LP .TS center tab(/) allbox; l l l l lw15 lw35 . \fBKey Action\fR = Left Arrow/T{ Selects the button to the left of the current button. T} Right Arrow/T{ Selects the button to the right of the current button. T} Tab/T{ Selects the button to the right of the current button. T} Space/T{ Selects the button to the right of the current button. T} Return/T{ Exits the widget and returns the index of the selected button. This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Tab/T{ Exits the widget and returns the index of the selected button. This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Escape/T{ Exits the widget and returns -1. This also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR. T} Ctrl-L/T{ Refreshes the screen. T} .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_process (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_compat.30000644000175100001440000000654510354604407014517 0ustar tomusers'\" t .\" $Id: cdk_compat.3,v 1.4 2005/12/28 21:52:07 tom Exp $ .de XX .. .TH cdk_compat 3 .SH NAME .XX getDirectoryContents .XX readFile .XX splitString cdk_compat \- Cdk4 compatibility functions .SH SYNOPSIS .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "int getDirectoryContents (" .BI "char *directory", .BI "char **list", .BI "int " "maxListSize"); .TP 15 .B "int readFile (" .BI "char *" "filename", .BI "char **" "info", .BI "int " "maxlines"); .TP 15 .B "int splitString (" .BI "char *" "string", .BI "char **" "items", .BI "char " "splitChar"); .fi .SH DESCRIPTION These functions and macros make it simpler to port applications from the older Cdk4 library to Cdk5. .PP A few functions are deprecated in Cdk5, because they rely upon the caller to know in advance the size of data which will be returned by the function. .PP Additionally, some macros are deprecated because they serve no realistic purpose: they have direct (standard) equivalents in all modern curses implementations. .PP Finally, a few macro definitions are added to iron out naming inconsistencies across the Cdk4 header files. . .SH AVAILABLE FUNCTIONS .TP 5 .B getDirectoryContents This opens the current directory and reads the contents. Use \fBCDKgetDirectoryContents()\fP in new code. .TP 5 .B readFile This reads a file and sticks it into the \fBchar\ **\fP provided. Use \fBCDKreadFile()\fP for new code. .TP 5 .B splitString This splits a string into one or more parts given the split character. Use \fBCDKsplitString()\fP for new code. . .SH EXAMPLE Start the porting process by changing the \fB#include\fP's to use .RS #include .RE .PP rather than .RS #include .RE Some adjustments of course are needed to make your compiler see the compatibility header file. A separate name was chosen so that it in turn can (by adjusting the include path) include either the old Cdk4 \fBcdk.h\fP or the new. If the old is included, you should link your program against the old library. Likewise, including the new requires that you link against the new library. .PP That is the first step: making your program compile using the compatibility header file using the old headers and library. .PP The next step is to get it to compile against the new headers and library. Most of the changes will require modifying bare references to certain pointers to wrap them with the \fBObjOf()\fP and \fBScreenOf()\fP macros. New Cdk uses these to provide functions which are easily shared among the different widget types. Your compiler should be able to tell you where the changes should be made. See the example programs which are included with Cdk as a guide. .PP That is the hard part of porting. But even for a large program, the changes can be made simply: there are not that many types of change to make. At the end of this step, you should still be able to build and run your program against the old headers and library. It is reasonably likely that you can do the same with the new headers and library. By using the same source for old/new versions of Cdk, you can test and verify that your program still works properly after these modifications. .PP Finally, unless this is a purely academic exercise, you will want to remove references to the deprecated functions and macros. . .SH SEE ALSO cdk_objs (3), cdk_util (3) cdk-5.0-20060507/man/cdk_viewer.30000644000175100001440000002726210354636130014532 0ustar tomusers'\" t .\" $Id: cdk_viewer.3,v 1.25 2005/12/29 01:31:04 tom Exp $ .de XX .. .TH cdk_viewer 3 .SH NAME .XX activateCDKViewer .XX cleanCDKViewer .XX destroyCDKViewer .XX drawCDKViewer .XX eraseCDKViewer .XX getCDKViewerBox .XX getCDKViewerHighlight .XX getCDKViewerInfo .XX getCDKViewerInfoLine .XX getCDKViewerTitle .XX moveCDKViewer .XX newCDKViewer .XX positionCDKViewer .XX setCDKViewer .XX setCDKViewerBackgroundAttrib .XX setCDKViewerBackgroundColor .XX setCDKViewerBox .XX setCDKViewerBoxAttribute .XX setCDKViewerHighlight .XX setCDKViewerHorizontalChar .XX setCDKViewerInfo .XX setCDKViewerInfoLine .XX setCDKViewerLLChar .XX setCDKViewerLRChar .XX setCDKViewerTitle .XX setCDKViewerULChar .XX setCDKViewerURChar .XX setCDKViewerVerticalChar cdk_viewer \- curses viewer list widget. .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "int activateCDKViewer (" .BI "CDKVIEWER *" "viewer"); .TP 15 .B "void cleanCDKViewer (" .BI "CDKVIEWER *" "viewer"); .TP 15 .B "void destroyCDKViewer (" .BI "CDKVIEWER *" "viewer"); .TP 15 .B "void drawCDKViewer (" .BI "CDKVIEWER *" "viewer", .BI "boolean " "box"); .TP 15 .B "void eraseCDKViewer (" .BI "CDKVIEWER *" "viewer"); .TP 15 .B "boolean getCDKViewerBox (" .BI "CDKVIEWER *" "viewer"); .TP 15 .B "chtype getCDKViewerHighlight (" .BI "CDKVIEWER *" "viewer"); .TP 15 .B "chtype **getCDKViewerInfo (" .BI "CDKVIEWER *" "viewer", .BI "char **" "itemList"); .TP 15 .B "boolean getCDKViewerInfoLine (" .BI "CDKVIEWER *" "viewer"); .TP 15 .B "chtype **getCDKViewerTitle (" .BI "CDKVIEWER *" "viewer"); .TP 15 .B "void moveCDKViewer (" .BI "CDKVIEWEE *" "viewer", .BI "int " "box", .BI "int " "box", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKVIEWER *newCDKViewer (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "int " "height", .BI "int " "width", .BI "char **" "buttonList", .BI "int " "buttonCount", .BI "chtype " "buttonHighlight", .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKViewer (" .BI "CDKVIEWER *" "viewer"); .TP 15 .B "void setCDKViewer (" .BI "CDKVIEWER *" "viewer", .BI "char *" "title", .BI "char **" "list", .BI "int " "listSize", .BI "chtype " "buttonAttribute", .BI "boolean " "interpret", .BI "boolean " "showLineInfo", .BI "boolean " "box"); .TP 15 .B "void setCDKViewerBackgroundAttrib (" .BI "CDKVIEWER *" "viewer", .BI "chtype " "attribute"); .TP 15 .B "void setCDKViewerBackgroundColor (" .BI "CDKVIEWER *" "viewer", .BI "char * " "color"); .TP 15 .B "void setCDKViewerBox (" .BI "CDKVIEWER *" "viewer", .BI "boolean " "Box"); .TP 15 .B "void setCDKViewerBoxAttribute (" .BI "CDKVIEWER *" "viewer", .BI "chtype " "character"); .TP 15 .B "void setCDKViewerHighlight (" .BI "CDKVIEWER *" "viewer", .BI "chtype " "highlight"); .TP 15 .B "void setCDKViewerHorizontalChar (" .BI "CDKVIEWER *" "viewer", .BI "chtype " "character"); .TP 15 .B "void setCDKViewerInfo (" .BI "CDKVIEWER *" "viewer", .BI "char **" "list", .BI "int " "listSize", .BI "boolean " "interpret"); .TP 15 .B "void setCDKViewerTitle (" .BI "CDKVIEWER *" "viewer", .BI "char *" "title"); .TP 15 .B "void setCDKViewerInfoLine (" .BI "CDKVIEWER *" "viewer", .BI "boolean " "showInfoLine"); .TP 15 .B "void setCDKViewerLLChar (" .BI "CDKVIEWER *" "viewer", .BI "chtype " "character"); .TP 15 .B "void setCDKViewerLRChar (" .BI "CDKVIEWER *" "viewer", .BI "chtype " "character"); .TP 15 .B "void setCDKViewerTitle (" .BI "CDKVIEWER *" "viewer", .BI "char *" "title"); .TP 15 .B "void setCDKViewerULChar (" .BI "CDKVIEWER *" "viewer", .BI "chtype " "character"); .TP 15 .B "void setCDKViewerURChar (" .BI "CDKVIEWER *" "viewer", .BI "chtype " "character"); .TP 15 .B "void setCDKViewerVerticalChar (" .BI "CDKVIEWER *" "viewer", .BI "chtype " "character"); .fi .SH DESCRIPTION The Cdk viewer widget creates a file viewer widget. This widget allows a user to interact with a file. It does \fINOT\fR allow editing, this is view only. The following are functions which create or manipulate the Cdk viewer list widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKViewer activates the viewer widget and lets the user interact with the widget. The parameter \fBviewer\fR is a pointer to a non-NULL viewer widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR then this function will return a value from 0 to the number of buttons -1, representing the button selected. It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR. If the character entered into this widget was \fIESCAPE\fR then the widget will return a value of -1 and the widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR. .TP 5 .B cleanCDKViewer clears the information from the window. .TP 5 .B destroyCDKViewer removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKViewer draws the viewer widget on the screen. If the \fBbox\fR option is true, the widget is drawn with a box. .TP 5 .B eraseCDKViewer removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKViewerBox returns true if the widget will be drawn with a box around it. .TP 5 .B getCDKViewerHighlight returns the attribute of the buttons. .TP 5 .B getCDKViewerInfo returns the contents of the viewer widget. .TP 5 .B getCDKViewerInfoLine returns true if the information line is on. .TP 5 .B getCDKViewerTitle returns the title of the widget. .TP 5 .B moveCDKViewer function moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B *newCDKViewer function creates a viewer widget and returns a pointer to it. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBheight\fR and .TP 5 \fBwidth\fR are the height and width of the viewer window. .TP 5 \fBbuttons\fR is an array of the button labels which are to be attached to the viewer on the bottom. .TP 5 \fBbuttonCount\fR is the number of buttons in \fBbuttons\fP. .TP 5 \fBbuttonHighlight\fR is the highlight attribute of the currently selected button. .TP 5 \fBbox\fR is true if the widget should be drawn with a box around it. .TP 5 \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKViewer allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDKViewer lets the programmer modify several elements of an existing viewer widget. The parameter \fBtitle\fR is the title to be displayed on the top of the viewer. .IP The parameter \fBlist\fR is the information to display, while \fBlistSize\fR states how many rows there are in the \fBlist\fR array. If \fBlistSize\fR is negative, \fBlist\fR is scanned to find its length, including files which will be included via embedded links. .IP The parameter \fBbuttonAttribute\fR states the attribute of the current highlighted button. The boolean parameter \fBinterpret\fR tells the viewer to interpret the contents of \fBlist\fR for Cdk display command. The \fBshowLineInfo\fR boolean flag tells the viewer to show to show the line number and percentage in the top left corner of the viewer window. The parameters \fBbox\fR and \fBshadow\fR are the same as in the function description of \fBnewCDKViewer\fR. .TP 5 .B setCDKViewerBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKViewerBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .TP 5 .B setCDKViewerBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKViewerBoxAttribute sets the attribute of the box. .TP 5 .B setCDKViewerHighlight sets the highlight attribute of the buttons on the widget. .TP 5 .B setCDKViewerHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKViewerInfo sets the contents of the viewer widget. See \fBsetCDKViewer\fP for parameter descriptions. .TP 5 .B setCDKViewerInfoLine turns on/off the information line in the top left hand corner of the widget. If the value of \fBshowInfoLine\fR is \fITRUE\fR, the information line will be displayed. If it is \fIFALSE\fR it won't. .TP 5 .B setCDKViewerLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKViewerLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKViewerTitle sets the title of the widget. .TP 5 .B setCDKViewerULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKViewerURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKViewerVerticalChar sets the vertical drawing character for the box to the given character. .SH KEY BINDINGS When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. The following table outlines the keys and their actions for this widget. .LP .TS center box; l l l l lw15 lw35 . \fBKey Action\fR = Left Arrow Shifts the viewport one column left. Right Arrow Shifts the viewport one column left Up Arrow Scrolls the viewport one line up. Down Arrow Scrolls the viewport one line down. _ Prev Page Ctrl-B B b Scroll one page backward. _ Next Page Ctrl-F Space F f Scroll one page forward. _ Home | Shift the whole list to the far left. _ End $ Shift the whole list to the far right. _ 1 < g Moves to the first line in the viewer. _ > G Moves to the last line in the viewer. _ L T{ Moves half the distance to the end of the viewer. T} l T{ Moves half the distance to the top of the viewer. T} _ ? Searches up for a pattern. / Searches down for a pattern. n Repeats last search. N Repeats last search, reversed direction. : Jumps to a given line. _ i Displays file statistics. s Displays file statistics. _ Tab Switches buttons. Return T{ Exit the widget and return the index of the selected button. Set the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Escape T{ Exit the widget and return -1. Set the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR. T} Ctrl-L Refreshes the screen. .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_util.30000644000175100001440000002127610354555363014215 0ustar tomusers'\" t .\" $Id: cdk_util.3,v 1.6 2005/12/28 18:35:31 tom Exp $ .de XX .. .TH cdk_util 3 .SH NAME .XX CDKgetDirectoryContents .XX CDKreadFile .XX alignxy .XX char2Chtype .XX char2DisplayType .XX checkForLink .XX chtype2String .XX deleteCursesWindow .XX eraseCursesWindow .XX getListIndex .XX getString .XX justifyString .XX mode2Filetype .XX moveCursesWindow .XX popupDialog .XX popupLabel .XX popupLabelAttrib .XX selectFile .XX setWidgetDimension .XX stripWhiteSpace .XX viewFile .XX viewInfo cdk_util \- Cdk utility functions .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "int CDKgetDirectoryContents (" .BI "char *" "directory", .BI "char ***" "list"); .TP 15 .B "int CDKreadFile (" .BI "char *" "filename", .BI "char ***" "info"); .TP 15 .B "void alignxy (" .BI "WINDOW *" "window", .BI "int *" "xpos", .BI "int *" "ypos", .BI "int " "boxWidth", .BI "int " "boxHeight"); .TP 15 .B "chtype *char2Chtype (" .BI "char *" "string", .BI "int *" "length", .BI "int *" "align"); .TP 15 .B "EDisplayType char2DisplayType (" .BI "char *" "string"); .TP 15 .B "int checkForLink (" .BI "char *" "line", .BI "char *" "filename"); .TP 15 .B "char *chtype2String ( .BI "chtype *" "string"); .TP 15 .B "void deleteCursesWindow (" .BI "WINDOW *" "window"); .TP 15 .B "void eraseCursesWindow (" .BI "WINDOW *" "window"); .TP 15 .B "int getListIndex (" .BI "CDKSCREEN *" "screen", .BI "char *" "title", .BI "char **" "list", .BI "int " "listSize", .BI "boolean " "numbers"); .TP 15 .B char *getString (" .BI "CDKSCREEN *" "screen", .BI "char *" "title", .BI "char *" "label", .BI "char *" "init"); .TP 15 .B "int justifyString (" .BI "int " "fieldWidth", .BI "int " "mesglen", .BI "int " "justify"); .TP 15 .B "int mode2Filetype (" .BI "mode_t " "fileMode"); .TP 15 .B "void moveCursesWindow (" .BI "WINDOW *" "window", .BI "int " "xdiff", .BI "int " "ydiff"); .TP 15 .B "int popupDialog (" .BI "CDKSCREEN *" "screen", .BI "char **" "mesg", .BI "int " "mesgCount", .BI "char **" "buttons", .BI "int " "buttonCount"); .TP 15 .B "void popupLabel (" .BI "CDKSCREEN *" "win", .BI "char **" "mesg", .BI "int " "count"); .TP 15 .B "void popupLabelAttrib (" .BI "CDKSCREEN *" "win", .BI "char **" "mesg", .BI "int " "count", .BI "chtype " "attribute"); .TP 15 .B "char *selectFile (" .BI "CDKSCREEN *" "screen", .BI "char *" "title"); .TP 15 .B "int setWidgetDimension (" .BI "int " "parentDim", .BI "int " "proposedDim", .BI "int " "adjustment"); .TP 15 .B "void stripWhiteSpace (" .BI "EStripType " "stripType", .BI "char *" "string"); .TP 15 .B "int viewFile (" .BI "CDKSCREEN *" "screen", .BI "char *" "title", .BI "char *" "filename", .BI "char **" "buttons", .BI "int " "buttonCount"); .TP 15 .B "int viewInfo (" .BI "CDKSCREEN *" "screen", .BI "char *" "title", .BI "char **" "info", .BI "int " "size", .BI "char **" "buttons", .BI "int " "buttonCount", .BI "boolean " "interpret"); .fi .SH DESCRIPTION These are utility functions that one may use to initialize, build or customize widgets. . .SH AVAILABLE FUNCTIONS .TP 5 .B CDKgetDirectoryContents opens and reads the contents of the given directory, filling the array \fBlist\fR with the sorted contents of the directory. If the directory cannot be opened then it returns a value of -1. .TP 5 .B CDKreadFile Read the file \fIfilename\fP, load the contents into a dynamically allocated array, storing its address via \fIinfo\fP. It returns the number of lines read if the file could be opened, -1 otherwise. .TP 5 .B alignxy Aligns a box on the given \fIwindow\fP with the height and width given. See cdk_position (3) for the interpretation of the \fIxpos\fP, \fIypos\fP, \fIboxWidth\fP and \fIboxHeight\fP, parameters. .TP 5 .B char2Chtype Translate a character \fIstring\fP with embedded format markers (e.g., "Blah Blah") to a null-terminated array of chtype's. The length of the array is stored via the \fIlength\fP parameter. The \fBalign\fR parameter contains justification information (LEFT, CENTER, RIGHT). The caller is responsible for freeing the result. .TP 5 .B char2DisplayType Lookup the given name in \fIstring\fP and return the equivalent display type. See also cdk_display (3). .TP 5 .B checkForLink Check if the given \fIline\fP is of the form .RS .RE .IP If so, extract the filename from the line, storing it in the \fIfilename\fP buffer (which must hold at least CDK_PATHMAX characters). Return nonzero if a filename is extracted. .TP 5 .B chtype2String Extract the characters and formatting information from a null-terminated array of chtype's \fIstring\fP. A dynamically allocated string is returned. .TP 5 .B deleteCursesWindow Safely delete a given window, i.e., first check if the \fIwindow\fP parameter is nonnull. .TP 5 .B eraseCursesWindow Safely erase a given window, i.e., first check if the \fIwindow\fP parameter is nonnull. .TP 5 .B getListIndex Display a scrollable list of strings in a dialog, allow the user to select one. Return the index in the list of the value selected. The \fIlist\fP parameter contains the strings to display; there are \fIlistSize\fP strings in the list. If \fInumbers\fP is true, the displayed list items will be numbered. .TP 5 .B getString pops up an entry widget with a title supplied by the value of the \fBtitle\fR parameter, a label supplied by the \fBlabel\fR parameter, and an initial value supplied by the \fBinitialValue\fR parameter. It returns a pointer to the value typed in or NULL if the widget was exited early. .TP 5 .B justifyString Given a string length \fImesglen\fP, the available field width \fIfieldWidth\fP and a justification type \fIjustify\fP, return the number of characters by which to shift the string. .TP 5 .B mode2Filetype Given a file protection mode \fIfileMode\fP, return ignoring the file-type bits, i.e., ignoring the corresponding permissions data. .TP 5 .B moveCursesWindow Move a given \fIwindow\fP by the amounts in \fIxdiff\fP and \fIydiff\fP. .TP 5 .B popupDialog creates a quick pop-up dialog box. Pass in the message in the \fBmesg\fR parameter, the size of the message in the \fBmesgCount\fR parameter, the button labels in the \fBbuttons\fR parameter and the number of buttons in the \fBbuttonCount\fR parameter. The dialog box will be centered on the screen. .TP 5 .B popupLabel creates a quick pop-up label widget. The message and the size of the message are passed in via the \fBmesg\fR and \fBcount\fR parameters respectively. The label widget waits until the user hits a character and is centered on the screen. .TP 5 .B popupLabelAttrib Display a simple dialog with a list of \fIcount\fP message strings \fImesg\fP. Use the given \fIattribute\fP for the background of the dialog. .TP 5 .B selectFile Display a file-selection dialog. Return the selected filename, or null if none is selected. The caller should free the return-value. .TP 5 .B setWidgetDimension This is a helper function used to set the height/width of a widget: .RS .TP 3 - If the proposed dimension \fIproposedDim\fP is FULL or zero, the return value will be \fIparentDim\fP. .TP 3 - If the proposed dimension \fIproposedDim\fP is positive, .RS .TP 3 - and it is larger than \fIparentDim\fP, return \fIproposedDim\fP, .TP 3 - otherwise return \fIproposedDim\fP plus \fIadjustment\fP. .RE .TP 3 - If the proposed dimension \fIproposedDim\fP is negative, the return value will be \fIparentDim\fP plus \fIproposedDim\fP. .TP 3 - Otherwise, the return value will be \fIproposedDim\fP. .RE .TP 5 .B stripWhiteSpace Strip whitespace from the front and/or back of the given \fIstring\fP. The \fIstripType\fP parameter controls the type of stripping done: vFRONT, vBACK or vBOTH. .TP 5 .B viewFile Read the file specified by \fIfilename\fP and display it in a CDKVIEWER window. The \fItitle\fP, \fIbuttons\fP and \fIbuttonCount\fP are applied to the CDKVIEWER window. The viewer shows the contents of the file supplied by the \fBfilename\fR value. The buttons on the file viewer are supplied by the \fBbuttons\fR parameter. It returns the index of the button selected, or -1 if the file does not exist or if the widget was exited early. .LP .TS center tab(/) allbox; l l l l lw15 lw35 . \fBStrip_Type/Result\fR = vFRONT/T{ This tells the function to remove all of the white space from the front of the given string. T} vBACK/T{ This tells the function to remove all of the white space from the back of the given string. T} vBOTH/T{ This tells the function to remove all of the white space from both the front and the back of the given string. T} .TE .TP 5 .B viewInfo Display the list of strings in \fIinfo\fP in a CDKVIEWER window. The number of strings is given by \fIsize\fP. The \fItitle\fP, \fIbuttons\fP and \fIbuttonCount\fP are applied to the CDKVIEWER window. . .SH SEE ALSO cdk_dialog (3), cdk_display (3), cdk_position (3), cdk_misc (3). cdk-5.0-20060507/man/cdk_params.30000644000175100001440000000430010354555363014510 0ustar tomusers'\" t .\" $Id: cdk_params.3,v 1.3 2005/12/28 18:35:31 tom Exp $ .de XX .. .TH cdk_params 3 .SH NAME .XX CDKparamNumber .XX CDKparamNumber2 .XX CDKparamString .XX CDKparamString2 .XX CDKparseParams .XX CDKparsePosition .XX CDKparamValue cdk_params \- Cdk command-line parsing .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "int CDKparamNumber (" .BI "CDK_PARAMS *" "params", .BI "int " "option"); .TP 15 .B "int CDKparamNumber2 (" .BI "CDK_PARAMS *" "params", .BI "int " "option", .BI "int " "missing"); .TP 15 .B "char * CDKparamString (" .BI "CDK_PARAMS *" "params", .BI "int " "option"); .TP 15 .B "char * CDKparamString2 (" .BI "CDK_PARAMS *" "params", .BI "int " "option", .BI "char *" "missing"); .TP 15 .B "void CDKparseParams (" .BI "int " "argc", .BI "char **" "argv", .BI "CDK_PARAMS *" "params", .BI "char *" "options"); .TP 15 .B "int CDKparsePosition (" .BI "char *" "string"); .TP 15 .B "int CDKparamValue (" .BI "CDK_PARAMS * " "params", .BI "int " "option", .BI "int " "missing"); .fi .SH DESCRIPTION These are a set of functions used to implement the command-line utilities and demonstration programs for Cdk. Rather than set the programs' options at initialization, they construct a simple database which holds the common parameters using \fBCDKparseParams()\fP. . .SH AVAILABLE FUNCTIONS .TP 5 .B CDKparamNumber Retrieves an integer (or boolean) option value from the parsed command-line. .TP 5 .B CDKparamNumber2 Retrieves an optional integer (or boolean) value from the parsed command-line. If the command line option is not present, the \fImissing\fP value is used. .TP 5 .B CDKparamString Retrieves a string option value from the parsed command-line. .TP 5 .B CDKparamString2 Retrieve an optional string option value from the parsed command-line. .TP 5 .B CDKparamValue Retrieve an integer (or boolean) option value from the parsed command-line. .TP 5 .B CDKparseParams Parse the given argc/argv command-line, with the options passed to getopt()'s 3rd parameter. .TP 5 .B CDKparsePosition Parse the string as one of CDK's positioning keywords, or an actual position. . .SH SEE ALSO cdk_position (3), getopt (3) cdk-5.0-20060507/man/cdk_itemlist.30000644000175100001440000003071510354555363015070 0ustar tomusers'\" t .\" $Id: cdk_itemlist.3,v 1.18 2005/12/28 18:35:31 tom Exp $ .de XX .. .TH cdk_itemlist 3 .SH NAME .XX activateCDKItemlist .XX destroyCDKItemlist .XX drawCDKItemlist .XX drawCDKItemlistField .XX eraseCDKItemlist .XX getCDKItemlistBox .XX getCDKItemlistCurrentItem .XX getCDKItemlistDefaultItem .XX getCDKItemlistValues .XX injectCDKItemlist .XX moveCDKItemlist .XX newCDKItemlist .XX positionCDKItemlist .XX setCDKItemlist .XX setCDKItemlistBackgroundAttrib .XX setCDKItemlistBackgroundColor .XX setCDKItemlistBox .XX setCDKItemlistBoxAttribute .XX setCDKItemlistCurrentItem .XX setCDKItemlistDefaultItem .XX setCDKItemlistHorizontalChar .XX setCDKItemlistLLChar .XX setCDKItemlistLRChar .XX setCDKItemlistPostProcess .XX setCDKItemlistPreProcess .XX setCDKItemlistULChar .XX setCDKItemlistURChar .XX setCDKItemlistValues .XX setCDKItemlistVerticalChar cdk_itemlist \- curses itemlist widget. .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "int activateCDKItemlist (" .BI "CDKITEMLIST *" "itemlist", .BI "chtype *" "actions"); .TP 15 .B "void destroyCDKItemlist (" .BI "CDKITEMLIST *" "itemlist"); .TP 15 .B "void drawCDKItemlist (" .BI "CDKITEMLIST *" "itemlist", .BI "boolean " "box"); .TP 15 .B "void drawCDKItemlistField (" .BI "CDKITEMLIST *" "itemlist", .BI "boolean " "highlight"); .TP 15 .B "void eraseCDKItemlist (" .BI "CDKITEMLIST *" "itemlist"); .TP 15 .B "boolean getCDKItemlistBox (" .BI "CDKITEMLIST *" "itemlist"); .TP 15 .B "int getCDKItemlistCurrentItem (" .BI "CDKITEMLIST *" "itemlist"); .TP 15 .B "int getCDKItemlistDefaultItem (" .BI "CDKITEMLIST *" "itemlist"); .TP 15 .B "chtype **getCDKItemlistValues (" .BI "CDKITEMLIST *" "itemlist", .BI "int *" "listSize"); .TP 15 .B "int injectCDKItemlist (" .BI "CDKITEMLIST *" "itemlist", .BI "chtype " "input"); .TP 15 .B "void moveCDKItemlist (" .BI "CDKITEMLIST *" "itemlist", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKITEMLIST *newCDKItemlist (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "char *" "title", .BI "char *" "label", .BI "char **" "itemList", .BI "int " "itemCount", .BI "int " "defaultItem", .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKItemlist (" .BI "CDKITEMLIST *" "itemlist"); .TP 15 .B "void setCDKItemlist (" .BI "CDKITEMLIST *" "itemlist", .BI "char **" "itemList", .BI "int " "itemCount", .BI "int " "currentSelection", .BI "boolean " "box"); .TP 15 .B "void setCDKItemlistBackgroundAttrib (" .BI "CDKITEMLIST *" "itemlist", .BI "chtype" "attribute"); .TP 15 .B "void setCDKItemlistBackgroundColor (" .BI "CDKITEMLIST *" "itemlist", .BI "char *" "color"); .TP 15 .B "void setCDKItemlistBox (" .BI "CDKITEMLIST *" "itemlist", .BI "boolean " "box"); .TP 15 .B "void setCDKItemlistBoxAttribute (" .BI "CDKITEMLIST *" "itemlist", .BI "chtype " "character"); .TP 15 .B "void setCDKItemlistCurrentItem (" .BI "CDKITEMLIST *" "itemlist", .BI "int " "currentItem"); .TP 15 .B "void setCDKItemlistDefaultItem (" .BI "CDKITEMLIST *" "itemlist", .BI "int " "defaultItem"); .TP 15 .B "void setCDKItemlistHorizontalChar (" .BI "CDKITEMLIST *" "itemlist", .BI "chtype " "character"); .TP 15 .B "void setCDKItemlistLLChar (" .BI "CDKITEMLIST *" "itemlist", .BI "chtype " "character"); .TP 15 .B "void setCDKItemlistLRChar (" .BI "CDKITEMLIST *" "itemlist", .BI "chtype " "character"); .TP 15 .B "void setCDKItemlistPostProcess (" .BI "CDKITEMLIST *" "itemlist", .BI "PROCESSFN " "callback", .BI "void *" "data"); .TP 15 .B "void setCDKItemlistPreProcess (" .BI "CDKITEMLIST *" "itemlist", .BI "PROCESSFN " "callback", .BI "void *" "data"); .TP 15 .B "void setCDKItemlistULChar (" .BI "CDKITEMLIST *" "itemlist", .BI "chtype " "character"); .TP 15 .B "void setCDKItemlistURChar (" .BI "CDKITEMLIST *" "itemlist", .BI "chtype " "character"); .TP 15 .B "void setCDKItemlistValues (" .BI "CDKITEMLIST *" "itemlist", .BI "char **" "itemList", .BI "int " "itemCount"); .TP 15 .B "void setCDKItemlistVerticalChar (" .BI "CDKITEMLIST *" "itemlist", .BI "chtype " "character"); .fi .SH DESCRIPTION The Cdk itemlist widget creates a widget which allows a user to select from a list of preset character strings such as the days of the week or the months of the year. The following functions create or manipulate the Cdk itemlist widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKItemlist activates the itemlist widget and lets the user interact with the widget. The parameter \fBitemlist\fR is a pointer to a non-NULL itemlist widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a value from 0 to the number of buttons -1, representing the button selected. It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR. If the character entered into this widget was \fIESCAPE\fR then the widget will return a -1 and the widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR. .TP 5 .B destroyCDKItemlist removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKItemlist draws the itemlist widget on the screen. The \fBbox\fR option is true if the widget is drawn with a box. .TP 5 .B drawCDKItemlistField draws the contents of the field. .TP 5 .B eraseCDKItemlist removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKItemlistBox returns true if the widget will be drawn with a box around it. .TP 5 .B getCDKItemlistCurrentItem returns the index of the currently displayed item in the widget. .TP 5 .B getCDKItemlistDefaultItem returns the index of the default item in the widget. .TP 5 .B getCDKItemlistValues returns the list of pointers to the items. The parameter \fBsize\fR points to a location which receives the item count. .TP 5 .B injectCDKItemlist injects a single character into the widget. The parameter \fBitemlist\fR is a pointer to a non-NULL itemlist widget. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR the function returns a value ranging from zero to one less than the number of buttons, representing the button selected. The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns -1. The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns -1. The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .TP 5 .B moveCDKItemlist moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDKItemlist creates a pointer to an itemlist widget. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBtitle\fR is the string which will be displayed at the top of the widget. The title can be more than one line; just provide a carriage return character at the line break. .TP 5 \fBlabel\fR is the string to use as the label of the itemlist field. .TP 5 \fBitemList\fR is the list of the strings which will be displayed in the widget. .TP 5 \fBitemCount\fR is the number of elements in the list. .TP 5 \fBdefaultItem\fR is the index of the default item for the list. .TP 5 \fBbox\fR is true if widget should be drawn with a box around it. .TP 5 \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKItemlist allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDKItemlist lets the programmer modify certain elements of an existing itemlist widget. The parameter names correspond to the same parameter names listed in the \fBnewCDKItemlist\fR function. .TP 5 .B setCDKItemlistBackgroundAttrib the background color attribute the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKItemlistBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .TP 5 .B setCDKItemlistBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKItemlistBoxAttribute sets the attribute of the box. .TP 5 .B setCDKItemlistCurrentItem sets the currently displayed item in the widget. .TP 5 .B setCDKItemlistDefaultItem sets the default item in the widget. .TP 5 .B setCDKItemlistHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKItemlistLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKItemlistLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKItemlistPostProcess allows the user to have the widget call a function after the key has been applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about post-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKItemlistPreProcess allows the user to have the widget call a function after a key is hit and before the key is applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about pre-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKItemlistULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKItemlistURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKItemlistValues sets the contents of the list from an array of string pointers \fBitem\fR whose final index is given by \fBcount\fR. If \fBdefaultItem\fR is in the range 0..\fBcount\fR, that sets the default item value for the list. .TP 5 .B setCDKItemlistVerticalChar sets the vertical drawing character for the box to the given character. .SH KEY BINDINGS When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. The following table outlines the keys and their actions for this widget. .LP .TS center tab(/) box; l l l l lw15 lw35 . \fBKey/Action\fR = Left Arrow Down Arrow - p/Shift the list one column to the left. _ Right Arrow Up Arrow Space + n/Shift the list one column to the right. _ d D/Display the default item. _ 0/Display the first item in the list. $/Display the last item in the list. _ Return/T{ Exit the widget and return an integer representing the current selection. Also set the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Tab/T{ Exit the widget and return an integer representing the current selection. Also set the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Escape/T{ Exit the widget and return -1. Also set the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR. T} Ctrl-L/Refreshes the screen. .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_process (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_swindow.30000644000175100001440000003422710354555363014732 0ustar tomusers'\" t .\" $Id: cdk_swindow.3,v 1.22 2005/12/28 18:35:31 tom Exp $ .de XX .. .TH cdk_swindow 3 .SH NAME .XX activateCDKSwindow .XX addCDKSwindow .XX cleanCDKSwindow .XX destroyCDKSwindow .XX drawCDKSwindow .XX dumpCDKSwindow .XX eraseCDKSwindow .XX execCDKSwindow .XX getCDKSwindowBox .XX getCDKSwindowContents .XX injectCDKSwindow .XX jumpToLineCDKSwindow .XX loadCDKSwindowInformation .XX moveCDKSwindow .XX newCDKSwindow .XX positionCDKSwindow .XX saveCDKSwindowInformation .XX setCDKSwindow .XX setCDKSwindowBackgroundAttrib .XX setCDKSwindowBackgroundColor .XX setCDKSwindowBox .XX setCDKSwindowBoxAttribute .XX setCDKSwindowContents .XX setCDKSwindowHorizontalChar .XX setCDKSwindowLLChar .XX setCDKSwindowLRChar .XX setCDKSwindowPostProcess .XX setCDKSwindowPreProcess .XX setCDKSwindowULChar .XX setCDKSwindowURChar .XX setCDKSwindowVerticalChar .XX trimCDKSwindow cdk_swindow \- a curses scrolling window widget. .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "void activateCDKSwindow (" .BI "CDKSWINDOW *" "swindow", .BI "chtype * " "actions"); .TP 15 .B "void addCDKSwindow (" .BI "CDKSWINDOW *" "swindow", .BI "char *" "info", .BI "int " "insertPosition"); .TP 15 .B "void cleanCDKSwindow (" .BI "CDKSWINDOW *" "swindow"); .TP 15 .B "int execCDKSwindow (" .BI "CDKSWINDOW *" "swindow", .BI "char * " "command", .BI "int " "insertPosition"); .TP 15 .B "void destroyCDKSwindow (" .BI "CDKSWINDOW *" "swindow"); .TP 15 .B "void drawCDKSwindow (" .BI "CDKSWINDOW *" "swindow", .BI "boolean " "box"); .TP 15 .B "void dumpCDKSwindow (" .BI "CDKSWINDOW *" "swindow", .BI "char *" "filename"); .TP 15 .B "void eraseCDKSwindow (" .BI "CDKSWINDOW *" "swindow"); .B "void execCDKSwindow (" .BI "CDKSWINDOW *" "swindow," .BI "char *" "command," .BI "int " "insertPosition);" .B "boolean getCDKSwindowBox (" .BI "CDKSWINDOW *" "swindow);" .TP 15 .B "chtype **getCDKSwindowContents (" .BI "CDKSWINDOW *" "swindow"); .TP 15 .B "int injectCDKSwindow (" .BI "CDKSWINDOW *" "swindow", .BI "chtype " "input"); .TP 15 .B "void jumpToLineCDKSwindow (" .BI "CDKSWINDOW *" "swindow", .BI "int " "line"); .TP 15 .B "void loadCDKSwindowInformation (" .BI "CDKSWINDOW *" "swindow"); .TP 15 .B "void moveCDKSwindow (" .BI "CDKSWINDOW *" "swindow", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKSWINDOW *newCDKSwindow (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "int " "height", .BI "int " "width", .BI "char *" "title", .BI "int " "saveLines", .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKSwindow (" .BI "CDKSWINDOW *" "swindow"); .TP 15 .B "void saveCDKSwindowInformation (" .BI "CDKSWINDOW *" "swindow"); .TP 15 .B "void setCDKSwindow (" .BI "CDKSWINDOW *" "swindow", .BI "char **" "info", .BI "int " "lines", .BI "boolean " "box"); .TP 15 .B "void setCDKSwindowBackgroundAttrib (" .BI "CDKSWINDOW *" "swindow", .BI "chtype " "attribute"); .TP 15 .B "void setCDKSwindowBackgroundColor (" .BI "CDKSWINDOW *" "swindow", .BI "char * " "color"); .B "void setCDKSwindowBox (" .BI "CDKSWINDOW *" "swindow," .BI "boolean " "boxWidget);" .TP 15 .B "void setCDKSwindowBoxAttribute (" .BI "CDKSWINDOW *" "swindow", .BI "chtype " "character"); .TP 15 .B "void setCDKSwindowContents (" .BI "CDKSWINDOW *" "swindow", .BI "char **" "info", .BI "int " "lines"); .TP 15 .B "void setCDKSwindowHorizontalChar (" .BI "CDKSWINDOW *" "swindow", .BI "chtype " "character"); .TP 15 .B "void setCDKSwindowLLChar (" .BI "CDKSWINDOW *" "swindow", .BI "chtype " "character"); .TP 15 .B "void setCDKSwindowLRChar (" .BI "CDKSWINDOW *" "swindow", .BI "chtype " "character"); .TP 15 .B "void setCDKSwindowPostProcess (" .BI "CDKSWINDOW *" "swindow", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKSwindowPreProcess (" .BI "CDKSWINDOW *" "swindow", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKSwindowULChar (" .BI "CDKSWINDOW *" "swindow", .BI "chtype " "character"); .TP 15 .B "void setCDKSwindowURChar (" .BI "CDKSWINDOW *" "swindow", .BI "chtype " "character"); .TP 15 .B "void setCDKSwindowVerticalChar (" .BI "CDKSWINDOW *" "swindow", .BI "chtype " "character"); .TP 15 .B "void trimCDKSwindow (" .BI "CDKSWINDOW *" "swindow", .BI "int " "start", .BI "int " "finish"); .fi .SH DESCRIPTION The Cdk scrolling window (swindow) widget can be used to display messages. The following functions create or manipulate the Cdk swindow box widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKSwindow function activates the swindow widget and lets the user interact with the widget. The parameter \fBswindow\fR is a pointer to a non-NULL swindow widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR or \fITAB\fR then this function will return 1. It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR. If the character entered into this widget was \fIESCAPE\fR then the widget will return a value of -1 and the widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR. .TP 5 .B addCDKSwindow adds information to a scrolling window. The information is supplied by the \fBinfo\fR parameter. The information is immediately added to the scrolling window. The position of the new information is governed by the value of the parameter \fBinsertPosition\fR. This parameter may be two values: \fITOP\fR or \fIBOTTOM\fR. .TP 5 .B cleanCDKSwindow clears the information from the window. .TP 5 .B destroyCDKSwindow removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKSwindow draws the swindow widget on the screen. If the \fBbox\fR parameter is true, the widget is drawn with a box. .TP 5 .B dumpCDKSwindow saves the contents of the scrolling window into the file specified by the \fBfilename\fR parameter. It returns -1 on failure, and the number of lines saved if the dump was successful. .TP 5 .B eraseCDKSwindow removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B execCDKSwindow allows the user to execute a shell command and have the output of the shell command direct itself to the scrolling window. The \fBcommand\fR parameter is the command to execute. The \fBinsertPosition\fR parameter tells where the output will be inserted within the scrolling window. .TP 5 .B getCDKSwindowBox returns true if the widget will be drawn with a box around it. .TP 5 .B getCDKSwindowContents returns the contents of the scrolling window. The parameter \fBlines\fR will be set to the number of lines returned. .TP 5 .B injectCDKSwindow injects a single character into the widget. The parameter \fBswindow\fR is a pointer to a non-NULL swindow widget. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR the function returns 1. The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns -1. The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns -1. The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .TP 5 .B jumpToLineCDKSwindow moves the scrolling window to the given line. The parameter \fBline\fR may be an integer or one of the two predefined values \fITOP\fR and \fIBOTTOM\fR. .TP 5 .B loadCDKSwindowInformation allows the user to load the contents of a file into the scrolling window. This function is interactive, and will ask for a filename. .TP 5 .B moveCDKSwindow moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDKSwindow creates a swindow widget and returns a pointer to it. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBheight\fR and .TP 5 \fBwidth\fR control the height and width of the widget. If you provide a value of zero for either of the height or the width, the widget will be created with the full width and height of the screen. If you provide a negative value, the widget will be created the full height or width minus the value provided. .TP 5 \fBtitle\fR is the string to display at the top of the widget. The title can be more than one line; just provide a carriage return character at the line break. .TP 5 \fBsaveLines\fR is the number of lines to save before throwing information away. .TP 5 \fBbox\fR is true if the widget should be drawn with a box around it. .TP 5 The \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKSwindow allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B saveCDKSwindowInformation allows the user to save the contents of the scrolling window into a file. This function is interactive, and will ask for a filename. .TP 5 .B setCDKSwindow lets the programmer modify certain elements of an existing swindow widget. The parameter \fBinfo\fR is a \fIchar **\fR of the information to set in the scrolling window; \fBlines\fR is the number of lines being added. The other parameter names correspond to the same parameter names listed in the \fBnewCDKSwindow\fR function. .TP 5 .B setCDKSwindowBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKSwindowBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .TP 5 .B setCDKSwindowBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKSwindowBoxAttribute sets the attribute of the box. .TP 5 .B setCDKSwindowContents lets the programmer modify certain elements of an existing swindow widget. The parameter \fBinfo\fR is a \fIchar **\fR of the information to set in the scrolling window; \fBlines\fR is the number of lines being added. .TP 5 .B setCDKSwindowHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKSwindowLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKSwindowLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKSwindowPostProcess allows the user to have the widget call a function after the key has been applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about post-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKSwindowPreProcess allows the user to have the widget call a function after a key is hit and before the key is applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about pre-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKSwindowULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKSwindowURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKSwindowVerticalChar sets the vertical drawing character for the box to the given character. .TP 5 .B trimCDKSwindow removes information from a scrolling window. The parameters \fBstart\fR and \fBend\fR state where to start cutting from and where to stop. The first element in the scrolling window starts at index 0. .SH KEY BINDINGS When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. The following table outlines the keys and their actions for this widget. .LP .TS center tab(/) box; l l lw(15) lw(45) . \fBKey/Action\fR = Left Arrow/Scrolls the window left one column. Right Arrow/Scrolls the window right one column. Up Arrow/Scrolls the window up one row. Down Arrow/Scrolls the window down one row. _ Prev Page Ctrl-B b B/Scroll the window backward one page. _ Next Page Ctrl-F Space f F/Scroll the window forward one page. _ Home |/Scroll the list to the left margin. _ End $/Scroll the list to the right margin. _ 1 < g/Move to the top of the scrolling window. > G/Move to the bottom of the scrolling window. _ l L/Load a file into the scrolling window. _ s S/T{ Save the contents of the scrolling window into a file. T} _ Return/T{ Set the widget's \fIexitType\fR to \fIvNORMAL\fR, exit the widget and return 1. T} Tab/T{ Set the widget's \fIexitType\fR to \fIvNORMAL\fR, exit the widget and return 1. T} Escape/T{ Set the widget's \fIexitType\fR to \fIvESCAPE_HIT\fR, exit the widget and return -1. T} Ctrl-L/Refreshes the screen. = .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_fselect.30000644000175100001440000004053410427243221014647 0ustar tomusers'\" t .\" $Id: cdk_fselect.3,v 1.24 2006/05/07 01:00:01 tom Exp $ .de XX .. .TH cdk_fselect 3 .SH NAME .XX activateCDKFselect .XX deleteFileCB .XX destroyCDKFselect .XX drawCDKFselect .XX eraseCDKFselect .XX getCDKFselectBox .XX getCDKFselectContents .XX getCDKFselectCurrentItem .XX getCDKFselectDirAttribute .XX getCDKFselectDirContents .XX getCDKFselectDirectory .XX getCDKFselectFileAttribute .XX getCDKFselectFillerChar .XX getCDKFselectHighlight .XX getCDKFselectLinkAttribute .XX getCDKFselectSocketAttribute .XX injectCDKFselect .XX moveCDKFselect .XX newCDKFselect .XX positionCDKFselect .XX setCDKFselect .XX setCDKFselectBackgroundAttrib .XX setCDKFselectBackgroundColor .XX setCDKFselectBox .XX setCDKFselectBoxAttribute .XX setCDKFselectContents .XX setCDKFselectCurrentItem .XX setCDKFselectDirAttribute .XX setCDKFselectDirContents .XX setCDKFselectDirectory .XX setCDKFselectFileAttribute .XX setCDKFselectFillerChar .XX setCDKFselectHighlight .XX setCDKFselectHorizontalChar .XX setCDKFselectLLChar .XX setCDKFselectLRChar .XX setCDKFselectLinkAttribute .XX setCDKFselectSocketAttribute .XX setCDKFselectULChar .XX setCDKFselectURChar .XX setCDKFselectVerticalChar cdk_fselect \- curses file selector widget. .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "char *activateCDKFselect (" .BI "CDKFSELECT *" "fselect", .BI "chtype *" "actions"); .TP 15 .B "void deleteFileCB (" .BI "EObjectType " "objectType", .BI "void *" "object", .BI "void *" "clientData"); .TP 15 .B "void destroyCDKFselect (" .BI "CDKFSELECT *" "fselect"); .TP 15 .B "void drawCDKFselect (" .BI "CDKFSELECT *" "fselect", .BI "boolean " "box"); .TP 15 .B "void eraseCDKFselect (" .BI "CDKFSELECT *" "fselect"); .TP 15 .B "boolean getCDKFselectBox (" .BI "CDKFSELECT *" "fselect"); .TP 15 .B "char **getCDKFselectContents (" .BI "CDKFSELECT *" "widget", .BI "int *" "size"); .TP 15 .B "int getCDKFselectCurrentItem (" .BI "CDKFSELECT *" "widget"); .TP 15 .B "char *getCDKFselectDirAttribute (" .BI "CDKFSELECT *" "fselect"); .TP 15 .B "char **getCDKFselectDirContents (" .BI "CDKFSELECT *" "fselect", .BI "int *" "count"); .TP 15 .B "char *getCDKFselectDirectory (" .BI "CDKFSELECT *" "fselect"); .TP 15 .B "char *getCDKFselectFileAttribute (" .BI "CDKFSELECT *" "fselect"); .TP 15 .B "chtype getCDKFselectFillerChar (" .BI "CDKFSELECT *" "fselect"); .TP 15 .B "chtype getCDKFselectHighlight (" .BI "CDKFSELECT *" "fselect"); .TP 15 .B "char *getCDKFselectLinkAttribute (" .BI "CDKFSELECT *" "fselect"); .TP 15 .B "char *getCDKFselectSocketAttribute (" .BI "CDKFSELECT *" "fselect"); .TP 15 .B "char *injectCDKFselect (" .BI "CDKFSELECT *" "fselect", .BI "chtype " "input"); .TP 15 .B "void moveCDKFselect (" .BI "CDKFSELECT *" "fselect", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKFSELECT *newCDKFselect (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "int " "height", .BI "int " "width", .BI "char *" "title", .BI "char *" "label", .BI "chtype " "fieldAttribute", .BI "chtype " "fillerCharacter", .BI "chtype " "highlight", .BI "char *" "dirAttribute", .BI "char *" "fileAttribute", .BI "char *" "linkAttribute", .BI "char *" "sockAttribute", .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKFselect (" .BI "CDKFSELECT *" "fselect"); .TP 15 .B "void setCDKFselect (" .BI "CDKFSELECT *" "fselect", .BI "char *" "directory", .BI "chtype " "fieldAttribute", .BI "chtype " "fillerCharacter", .BI "chtype " "highlight", .BI "char *" "dirAttribute", .BI "char *" "fileAttribute", .BI "char *" "linkAttribute", .BI "char *" "sockAttribute", .BI "boolean " "box"); .TP 15 .B "void setCDKFselectBackgroundAttrib (" .BI "CDKFSELECT *" "fselect", .BI "chtype " "attribute"); .TP 15 .B "void setCDKFselectBackgroundColor (" .BI "CDKFSELECT *" "fselect", .BI "char * " "color"); .TP 15 .B "void setCDKFselectBox (" .BI "CDKFSELECT *" "fselect", .BI "boolean " "box"); .TP 15 .B "void setCDKFselectBoxAttribute (" .BI "CDKFSELECT *" "fselect", .BI "chtype " "character"); .TP 15 .B "void setCDKFselectContents (" .BI "CDKFSELECT *" "widget", .BI "char **" "list", .BI "int " "listSize"); .TP 15 .B "void setCDKFselectCurrentItem (" .BI "CDKFSELECT *" "widget", .BI "int " "item"); .TP 15 .B "void setCDKFselectDirAttribute (" .BI "CDKFSELECT *" "fselect", .BI "char *" "attribute"); .TP 15 .B "int setCDKFselectDirContents (" .BI "CDKFSELECT *" "fselect"); .TP 15 .B "int setCDKFselectDirectory (" .BI "CDKFSELECT *" "fselect", .BI "char *" "directory"); .TP 15 .B "void setCDKFselectFileAttribute (" .BI "CDKFSELECT *" "fselect", .BI "char *" "attribute"); .TP 15 .B "void setCDKFselectFillerChar (" .BI "CDKFSELECT *" "fselect", .BI "chtype " "filler"); .TP 15 .B "void setCDKFselectHighlight (" .BI "CDKFSELECT *" "fselect", .BI "chtype " "highlight"); .TP 15 .B "void setCDKFselectHorizontalChar (" .BI "CDKFSELECT *" "fselect", .BI "chtype " "character"); .TP 15 .B "void setCDKFselectLLChar (" .BI "CDKFSELECT *" "fselect", .BI "chtype " "character"); .TP 15 .B "void setCDKFselectLRChar (" .BI "CDKFSELECT *" "fselect", .BI "chtype " "character"); .TP 15 .B "void setCDKFselectLinkAttribute (" .BI "CDKFSELECT *" "fselect", .BI "char *" "attribute"); .TP 15 .B "void setCDKFselectSocketAttribute (" .BI "CDKFSELECT *" "fselect", .BI "char *" "attribute"); .TP 15 .B "void setCDKFselectULChar (" .BI "CDKFSELECT *" "fselect", .BI "chtype " "character"); .TP 15 .B "void setCDKFselectURChar (" .BI "CDKFSELECT *" "fselect", .BI "chtype " "character"); .TP 15 .B "void setCDKFselectVerticalChar (" .BI "CDKFSELECT *" "fselect", .BI "chtype " "character"); .fi .SH DESCRIPTION The Cdk file selector widget creates a widget which allows a user to interact with the Unix file system. This widget allows the user to traverse the file system and even delete files. (See \fINOTES\fR below for more information) .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKFselect activates the file selector widget and lets the user interact with the widget. The parameter \fBfselect\fR is a pointer to a non-NULL file selector widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a \fIchar *\fR representing the information typed into the widget and the widget data \fIexitType\fR will be set to \fIvNORMAL\fR. If the character entered was \fIESCAPE\fR then the function will return \fINULL\fR pointer and the widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. void deleteFileCB (EObjectType objectType GCC_UNUSED, void *object, void *clientData) .TP 5 .B deleteFileCB Prompts the user to confirm, and deletes the current item in the file-list. .TP 5 .B destroyCDKFselect removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKFselect draws the fselect widget on the screen. If the \fBbox\fR option is true, the widget is drawn with a box. .TP 5 .B eraseCDKFselect removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKFselectBox returns true if the widget will be drawn with a box around it. .TP 5 .B getCDKFselectContents returns the directory-contents (which are formatted), and sets the number of entries via the \fIsize\fP parameter. .TP 5 .B getCDKFselectCurrentItem returns the current position in the scroll-widget. .TP 5 .B getCDKFselectDirAttribute returns the attribute that directories are drawn with in the scrolling region of the widget. .TP .B getCDKFselectDirContents returns the list of files and the corresponding count as a side-effect. If no files are found, this function returns zero, otherwise one. .TP 5 .B getCDKFselectDirectory returns the current directory of the widget. .TP 5 .B getCDKFselectFileAttribute returns the attribute that plain files are drawn with in the scrolling region of the widget. .TP 5 .B getCDKFselectFillerChar returns the character being used as the filler character in the entry field portion of the widget. .TP 5 .B getCDKFselectHighlight returns the attribute of the highlight bar of the scrolling list portion of the widget. .TP 5 .B getCDKFselectLinkAttribute returns the attribute that symbolic links are drawn with in the scrolling region of the widget. .TP 5 .B getCDKFselectSocketAttribute returns the attribute that sockets are drawn with in the scrolling region of the widget. .TP 5 .B injectCDKFselect injects a single character into the widget. The parameter \fBfselect\fR is a pointer to a non-NULL file selector widget. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR the function returns a \fIchar *\fR representing the information typed into the widget. The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns a \fINULL\fR pointer. The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns a \fINULL\fR pointer. The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .TP 5 .B moveCDKFselect moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDKFselect creates an fselect widget and returns a pointer to it. Parameters: .RS .TP 5 The \fBscreen\fR parameter is the screen you wish this widget to be placed in. .TP 5 The parameter \fBxpos\fR controls the placement of the object along the horizontal axis. This parameter may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer value or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBheight\fR and .TP 5 \fBwidth\fR control the height and width of the widget. If you provide a value of zero for either of the height or the width, the widget will be created with the full width and height of the screen. If you provide a negative value, the widget will be created the full height or width minus the value provided. .TP 5 \fBtitle\fR is the string which will be displayed at the top of the widget. The title can be more than one line; just provide a carriage return character at the line break. .TP 5 \fBlabel\fR is the text to use as the label of the file selector. .TP 5 \fBfieldAttribute\fR is the attribute of the entry field at the top of the widget; .TP 5 \fBfillerCharacter\fR is the filler character for the entry field. .TP 5 \fBhighlight\fR is the highlight attribute on the scrolling list. .TP 5 \fBdirAttribute\fR, .TP 5 \fBfileAttribute\fR, .TP 5 \fBlinkAttribute\fR and .TP 5 \fBsockAttribute\fR are the attributes of directories, files, links, and sockets found in the directory list. .TP 5 \fBbox\fR is true if the widget should be drawn with a box around it. .TP 5 \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKFselect allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDKFselect lets the programmer modify certain elements of an existing fselect widget. The parameter names correspond to the same parameter names listed in the \fBnewCDKFselect\fR function. .TP 5 .B setCDKFselectBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKFselectBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .TP 5 .B setCDKFselectBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKFselectBoxAttribute sets the attribute of the box. .TP 5 .B setCDKFselectContents sets the contents of the widget. .TP 5 .B setCDKFselectCurrentItem set the current position in the scroll-widget. .TP 5 .B setCDKFselectDirAttribute sets the attribute that directories will be drawn with in the scrolling region of the widget. .B .B setCDKFselectDirContents This creates a list of the files in the current directory. See \fBgetCDKFselectDirContents\FP. .TP 5 .B setCDKFselectDirectory sets the current directory of the widget. .TP 5 .B setCDKFselectFileAttribute sets the attribute that plain files will be drawn with in the scrolling region of the widget. .TP 5 .B setCDKFselectFillerChar sets the character to use when drawing the entry field portion of the widget. .TP 5 .B setCDKFselectHighlight sets the attribute of the highlight bar of the scrolling list portion of the widget. .TP 5 .B setCDKFselectHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKFselectLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKFselectLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKFselectLinkAttribute sets the attribute that symbolic links will be drawn with in the scrolling region of the widget. .TP 5 .B setCDKFselectSocketAttribute sets the attribute that sockets will be drawn with in the scrolling region of the widget. .TP 5 .B setCDKFselectULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKFselectURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKFselectVerticalChar sets the vertical drawing character for the box to the given character. .SH KEY BINDINGS When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. Since this widget is built from both the scrolling list widget and the entry field widget, the key bindings are the same for the respective fields. The extra key bindings are listed below. .LP .TS center tab(/) allbox; l l l l lw15 lw35 . \fBKey/Action\fR = CTRL-^/Displays statistics about the current filename. Tab/Tries to complete the current filename. Up Arrow/Scrolls the scrolling list up one line. Down Arrow/Scrolls the scrolling list down one line. Page Up/Scrolls the scrolling list up one page. CTRL-B/Scrolls the scrolling list up one page. Page Down/T{ Scrolls the scrolling list down one page. T} CTRL-F/T{ Scrolls the scrolling list down one page. T} Return/T{ Returns the filename in the entry field of the file selector. It also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Escape/T{ Exits the widget and returns a \fINULL\fR pointer. It also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR. T} .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_screen (3) .SH NOTES .PP This widget is created from the scrolling list widget and the entry field widget. This is a good example on how to build your own widgets using the base widgets provided in this distribution. In order for you to delete files using the file selector, you must add the following call into your program. (the character X is the character you wish to use to tell the file selector you want to delete a file.) .RS 5 \fBbindCDKObject (vSCROLL, fselect->filelist, X, deleteFile, fselect);\fR .RE where \fBfselect\fR is a pointer to the object. This was originally turned on, but I thought it better to put the control of file deletion on an 'as-need' basis. cdk-5.0-20060507/man/cdk_radio.30000644000175100001440000003441010354604407014322 0ustar tomusers'\" t .\" $Id: cdk_radio.3,v 1.28 2005/12/28 21:52:07 tom Exp $ .de XX .. .TH cdk_radio 3 .SH NAME .XX activateCDKRadio .XX destroyCDKRadio .XX drawCDKRadio .XX eraseCDKRadio .XX getCDKRadioBox .XX getCDKRadioChoiceCharacter .XX getCDKRadioCurrentItem .XX getCDKRadioHighlight .XX getCDKRadioItems .XX getCDKRadioLeftBrace .XX getCDKRadioRightBrace .XX getCDKRadioSelectedItem .XX injectCDKRadio .XX moveCDKRadio .XX newCDKRadio .XX positionCDKRadio .XX setCDKRadio .XX setCDKRadioBackgroundAttrib .XX setCDKRadioBackgroundColor .XX setCDKRadioBox .XX setCDKRadioBoxAttribute .XX setCDKRadioChoiceCharacter .XX setCDKRadioCurrentItem .XX setCDKRadioHighlight .XX setCDKRadioHorizontalChar .XX setCDKRadioItems .XX setCDKRadioLLChar .XX setCDKRadioLRChar .XX setCDKRadioLeftBrace .XX setCDKRadioPostProcess .XX setCDKRadioPreProcess .XX setCDKRadioRightBrace .XX setCDKRadioSelectedItem .XX setCDKRadioULChar .XX setCDKRadioURChar .XX setCDKRadioVerticalChar cdk_radio \- curses radio list widget. .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "int activateCDKRadio (" .BI "CDKRADIO *" "radio", .BI "chtype *" "actions"); .TP 15 .B "void destroyCDKRadio (" .BI "CDKRADIO *" "radio"); .TP 15 .B "void drawCDKRadio (" .BI "CDKRADIO *" "radio", .BI "boolean " "box"); .TP 15 .B "void eraseCDKRadio (" .BI "CDKRADIO *" "radio"); .TP 15 .B "boolean getCDKRadioBox (" .BI "CDKRADIO *" "radio"); .TP 15 .B "chtype getCDKRadioChoiceCharacter (" .BI "CDKRADIO *" "radio"); .TP 15 .B "int getCDKRadioCurrentItem (" .BI "CDKRADIO *" "radio"); .TP 15 .B "chtype getCDKRadioHighlight (" .BI "CDKRADIO *" "radio"); .TP 15 .B "int getCDKRadioItems (" .BI "CDKRADIO *" "radio", .BI "char **" "list"); .TP 15 .B "chtype getCDKRadioLeftBrace (" .BI "CDKRADIO *" "radio"); .TP 15 .B "chtype getCDKRadioRightBrace (" .BI "CDKRADIO *" "radio"); .TP 15 .B "int getCDKRadioSelectedItem (" .BI "CDKRADIO *" "radio"); .TP 15 .B "int injectCDKRadio (" .BI "CDKRADIO *" "radio", .BI "chtype " "input"); .TP 15 .B "void moveCDKRadio (" .BI "CDKRADIO *" "radio", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKRADIO *newCDKRadio (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "int " "spos", .BI "int " "height", .BI "int " "width", .BI "char *" "title", .BI "char **" "radioList", .BI "int " "radioListLength", .BI "chtype " "choiceCharacter", .BI "int " "defaultItem", .BI "chtype " "highlight", .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKRadio (" .BI "CDKRADIO *" "radio"); .TP 15 .B "void setCDKRadio (" .BI "CDKRADIO *" "radio", .BI "chtype " "highlight", .BI "chtype " "choiceCharacter", .BI "boolean " "box"); .TP 15 .B "void setCDKRadioBackgroundAttrib (" .BI "CDKRADIO *" "radio", .BI "chtype " "attribute"); .TP 15 .B "void setCDKRadioBackgroundColor (" .BI "CDKRADIO *" "radio", .BI "char * " "color"); .TP 15 .B "void setCDKRadioBox (" .BI "CDKRADIO *" "radio", .BI "boolean " "box"); .TP 15 .B "void setCDKRadioBoxAttribute (" .BI "CDKRADIO *" "radio", .BI "chtype " "character"); .TP 15 .B "void setCDKRadioChoiceCharacter (" .BI "CDKRADIO *" "radio", .BI "chtype " "character"); .TP 15 .B "void setCDKRadioCurrentItem (" .BI "CDKRADIO *" "radio", .BI "int" "index"); .TP 15 .B "void setCDKRadioHighlight (" .BI "CDKRADIO *" "radio", .BI "chtype " "highlight"); .TP 15 .B "void setCDKRadioHorizontalChar (" .BI "CDKRADIO *" "radio", .BI "chtype " "character"); .TP 15 .B "void setCDKRadioItems (" .BI "CDKRADIO *" "radio", .BI "char **" "list", .BI "int " "listSize"); .TP 15 .B "void setCDKRadioLLChar (" .BI "CDKRADIO *" "radio", .BI "chtype " "character"); .TP 15 .B "void setCDKRadioLRChar (" .BI "CDKRADIO *" "radio", .BI "chtype " "character"); .TP 15 .B "void setCDKRadioLeftBrace (" .BI "CDKRADIO *" "radio", .BI "chtype " "character"); .TP 15 .B "void setCDKRadioPostProcess (" .BI "CDKRADIO *" "radio", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKRadioPreProcess (" .BI "CDKRADIO *" "radio", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKRadioRightBrace (" .BI "CDKRADIO *" "radio", .BI "chtype " "character"); .TP 15 .B "void setCDKRadioSelectedItem (" .BI "CDKRADIO *" "radio", .BI "int " "item"); .TP 15 .B "void setCDKRadioULChar (" .BI "CDKRADIO *" "radio", .BI "chtype " "character"); .TP 15 .B "void setCDKRadioURChar (" .BI "CDKRADIO *" "radio", .BI "chtype " "character"); .TP 15 .B "void setCDKRadioVerticalChar (" .BI "CDKRADIO *" "radio", .BI "chtype " "character"); .fi .SH DESCRIPTION The Cdk radio widget creates a radio list. The following are functions which create or manipulate the Cdk radio box widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKRadio activates the radio widget and lets the user interact with the widget. The parameter \fBradio\fR is a pointer to a non-NULL radio widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a value from 0 to the number of items -1, representing the item selected. It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR. If the character entered into this widget was \fIESCAPE\fR then the widget will return a value of -1 and the widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR. .TP 5 .B destroyCDKRadio removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKRadio draws the radio widget on the screen. If the \fBbox\fR parameter is true, the widget is drawn with a box. .TP 5 .B eraseCDKRadio removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKRadioBox returns true if the widget will be drawn with a box around it. .TP 5 .B getCDKRadioChoiceCharacter returns the character being used to draw the selected element in the list. .TP 5 .B getCDKRadioCurrentItem returns the index of the current item. .TP 5 .B getCDKRadioHighlight returns the attribute of the highlight bar. .TP 5 .B getCDKRadioItems copies the radio box items into the caller's list, which must be large enough since this function does not allocate it. It returns the list size. .TP 5 .B getCDKRadioLeftBrace returns the character being used to draw the left brace of the selection box. .TP 5 .B getCDKRadioRightBrace returns the character being used to draw the right brace of the selection box. .TP 5 .B getCDKRadioSelectedItem, returns the selected item of the widget. .TP 5 .B injectCDKRadio function injects a single character into the widget. The parameter \fBradio\fR is a pointer to a non-NULL radio widget. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR the function returns a value ranging from zero to one less than the number of items, representing the items selected. The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns -1. The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns -1. The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .TP 5 .B moveCDKRadio moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDKRadio creates a radio widget and returns a pointer to it. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBspos\fR tells where the scroll bar is to be placed. This may be one of three values: .RS .TP 5 \fILEFT\fR puts the scroll bar on the left of the scrolling list. .TP 5 \fIRIGHT\fR puts the scroll bar on the right side of the list, and .TP 5 \fINONE\fR does not add a scroll bar. .RE .TP 5 \fBheight\fR and \fBwidth\fR control the height and width of the widget. If you provide a value of zero for either of the height or the width, the widget will be created with the full width and height of the screen. If you provide a negative value, the widget will be created the full height or width minus the value provided. .TP 5 \fBtitle\fR is the string which will be displayed at the top of the widget. The title can be more than one line; just provide a carriage return character at the line break. .TP 5 \fBradioList\fR is the list of items to display in the radio list. .TP 5 \fBradioListLength\fR is the number of elements in the given list. .TP 5 \fBchoiceCharacter\fR is the character to use to highlight the current selection. .TP 5 \fBhighlight\fR specifies the display attribute of the currently selected item. .TP 5 \fBdefaultItem\fR is the index in the list of the default selection. .TP 5 \fBbox\fR is true if widget should be drawn with a box around it. .TP 5 \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKRadio allows the user to move the widget around the screen via the cursor/keypad keys. See \fRcdk_position (3)\fR for key bindings. .TP 5 .B setCDKRadio lets the programmer modify certain elements of an existing radio widget. The parameter names correspond to the same parameter names listed in the \fBnewCDKRadio\fR function. .TP 5 .B setCDKRadioBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKRadioBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .TP 5 .B setCDKRadioBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKRadioBoxAttribute function sets the attribute of the box. .TP 5 .B setCDKRadioChoiceCharacter sets the character to use to draw the selected element in the list. .TP 5 .B setCDKRadioCurrentItem sets the current item by its index in the list. .TP 5 .B setCDKRadioHighlight sets the attribute of the highlight bar. .TP 5 .B setCDKRadioHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKRadioItems set the radio list items and display the result. The current item is set to the beginning of the list. .TP 5 .B setCDKRadioLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKRadioLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKRadioLeftBrace sets the character to use to draw the left brace of the selection box. .TP 5 .B setCDKRadioPostProcess allows the user to have the widget call a function after the key has been applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about post-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKRadioPreProcess allows the user to have the widget call a function after a key is hit and before the key is applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about pre-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKRadioRightBrace sets the character to use to draw the right brace of the selection box. .TP 5 .B setCDKRadioSelectedItem sets the selected item. .TP 5 .B setCDKRadioULChar function sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKRadioURChar function sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKRadioVerticalChar function sets the vertical drawing character for the box to the given character. .SH KEY BINDINGS When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. The following table outlines the keys and their actions for this widget. .LP .TS center tab(/) box; l l lw15 lw35 . \fBKey/Action\fR = Left Arrow/Shifts the whole list left one character. Right Arrow/Shifts the whole list right one character. Up Arrow/Selects the next item up in the list. Down Arrow/Selects the next item down in the list. _ Prev Page Ctrl-B/Scroll one page backward. _ Next Page Ctrl-F/Scroll one page forward. _ 1 < g Home/Move to the first element in the list. _ > G End/Move to the last element in the list. _ $/Shifts the whole list to the far right. |/Shifts the whole list to the far left. _ Space/Selects or deselects the current choice. Return/T{ Exits the widget and returns the index of the selected item. This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Tab/T{ Exit the widget and return the index of the selected item. Set the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Escape/T{ Exit the widget and return -1. Set the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR. T} Ctrl-L/Refreshes the screen. _ .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_alphalist.30000644000175100001440000003422110427243636015211 0ustar tomusers'\" t .\" $Id: cdk_alphalist.3,v 1.23 2006/05/07 01:04:30 tom Exp $" .de XX .. .TH cdk_alphalist 3 .SH NAME .XX activateCDKAlphalist .XX destroyCDKAlphalist .XX drawCDKAlphalist .XX eraseCDKAlphalist .XX getCDKAlphalistBox .XX getCDKAlphalistContents .XX getCDKAlphalistCurrentItem .XX getCDKAlphalistFillerChar .XX getCDKAlphalistHighlight .XX injectCDKAlphalist .XX moveCDKAlphalist .XX newCDKAlphalist .XX positionCDKAlphalist .XX setCDKAlphalist .XX setCDKAlphalistBackgroundAttrib .XX setCDKAlphalistBackgroundColor .XX setCDKAlphalistBox .XX setCDKAlphalistBoxAttribute .XX setCDKAlphalistContents .XX setCDKAlphalistCurrentItem .XX setCDKAlphalistFillerChar .XX setCDKAlphalistHighlight .XX setCDKAlphalistHorizontalChar .XX setCDKAlphalistLLChar .XX setCDKAlphalistLRChar .XX setCDKAlphalistPostProcess .XX setCDKAlphalistPreProcess .XX setCDKAlphalistULChar .XX setCDKAlphalistURChar .XX setCDKAlphalistVerticalChar cdk_alphalist \- curses sorted list widget. .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "char *activateCDKAlphalist (" .BI "CDKALPHALIST *" "alphalist", .BI "chtype *" "actions"); .TP 15 .B "void destroyCDKAlphalist (" .BI "CDKALPHALIST *" "alphalist"); .TP 15 .B "void drawCDKAlphalist (" .BI "CDKALPHALIST *" "alphalist", .BI "boolean " "box"); .TP 15 .B "void eraseCDKAlphalist (" .BI "CDKALPHALIST *" "alphalist"); .TP 15 .B "boolean getCDKAlphalistBox (" .BI "CDKALPHALIST *" "alphalist"); .TP 15 .B "char **getCDKAlphalistContents (" .BI "CDKALPHALIST *" "alphalist", .BI "int *" "size"); .TP 15 .B "int getCDKAlphalistCurrentItem (" .BI "CDKALPHALIST *" "widget"); .TP 15 .B "chtype getCDKAlphalistFillerChar (" .BI "CDKALPHALIST *" "alphalist"); .TP 15 .B "chtype getCDKAlphalistHighlight (" .BI "CDKALPHALIST *" "alphalist"); .TP 15 .B "char *injectCDKAlphalist (" .BI "CDKALPHALIST *" "alphalist", .BI "chtype " "input"); .TP 15 .B "void moveCDKAlphalist (" .BI "CDKALPHALIST *" "alphalist", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKALPHALIST *newCDKAlphalist (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "int " "height", .BI "int " "width", .BI "char * " "title", .BI "char * " "label", .BI "char ** " "list", .BI "int " "listSize", .BI "chtype " "fillerCharacter", .BI "chtype " "highlight", .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKAlphalist (" .BI "CDKALPHALIST *" "alphalist"); .TP 15 .B "void setCDKAlphalist (" .BI "CDKALPHALIST *" "alphalist", .BI "char ** " "list", .BI "int " "listSize", .BI "chtype " "fillerCharacter", .BI "chtype " "highlight", .BI "boolean " "box"); .TP 15 .B "void setCDKAlphalistBackgroundAttrib (" .BI "CDKALPHALIST *" "alphalist", .BI "chtype " "attribute"); .TP 15 .B "void setCDKAlphalistBackgroundColor (" .BI "CDKALPHALIST *" "alphalist", .BI "char * " "color"); .TP 15 .B "void setCDKAlphalistBox (" .BI "CDKALPHALIST *" "alphalist", .BI "boolean " "box"); .TP 15 .B "void setCDKAlphalistBoxAttribute (" .BI "CDKALPHALIST *" "alphalist", .BI "chtype " "character"); .TP 15 .B "void setCDKAlphalistContents (" .BI "CDKALPHALIST *" "alphalist", .BI "char ** " "list", .BI "int " "listSize"); .TP 15 .B "void setCDKAlphalistCurrentItem (" .BI "CDKALPHALIST *" "widget", .BI "int " "item"); .TP 15 .B "void setCDKAlphalistFillerChar (" .BI "CDKALPHALIST *" "alphalist", .BI "chtype " "fillerCharacter"); .TP 15 .B "void setCDKAlphalistHighlight (" .BI "CDKALPHALIST *" "alphalist", .BI "chtype " "highlight"); .TP 15 .B "void setCDKAlphalistHorizontalChar (" .BI "CDKALPHALIST *" "alphalist", .BI "chtype " "character"); .TP 15 .B "void setCDKAlphalistLLChar (" .BI "CDKALPHALIST *" "alphalist", .BI "chtype " "character"); .TP 15 .B "void setCDKAlphalistLRChar (" .BI "CDKALPHALIST *" "alphalist", .BI "chtype " "character"); .TP 15 .B "void setCDKAlphalistPostProcess (" .BI "CDKALPHALIST *" "alphalist", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKAlphalistPreProcess (" .BI "CDKALPHALIST *" "alphalist", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKAlphalistULChar (" .BI "CDKALPHALIST *" "alphalist", .BI "chtype " "character"); .TP 15 .B "void setCDKAlphalistURChar (" .BI "CDKALPHALIST *" "alphalist", .BI "chtype " "character"); .TP 15 .B "void setCDKAlphalistVerticalChar (" .BI "CDKALPHALIST *" "alphalist", .BI "chtype " "character"); .SH DESCRIPTION The Cdk alphalist allows a user to select from a list of alphabetically sorted words. The user can use the arrow keys to traverse through the list or type in the beginning of the word and the list will automatically adjust itself in the correct place in the scrolling list. This widget, like the file selector widget, is a compound widget of both the entry field widget and the scrolling list widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKAlphalist activates the alphalist widget and lets the user interact with the widget. The parameter \fBalphalist\fR is a pointer to a non-NULL alphalist widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR then this function will return a \fIchar *\fR of the information which was typed in the field. If the \fITAB\fR character is hit then the widget will try to complete the word in the entry field. If the widget is exited with the \fIRETURN\fR character then the widget data \fIexitType\fR will be set to \fIvNORMAL\fR. If the widget was exited with the \fIESCAPE\fR key then the widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR and the widget returns \fINULL\fR. .TP 5 .B destroyCDKAlphalist removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKAlphalist draws the alphalist widget on the screen. If the \fBbox\fR parameter is true, the widget is drawn with a box. .TP 5 .B eraseCDKAlphalist removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKAlphalistBox returns true if the widget will be drawn with a box around it. .TP 5 .B getCDKAlphalistContents returns the contents of the alphalist. .TP 5 .B getCDKAlphalistCurrentItem returns the current position in the scroll-widget. .TP 5 .B getCDKAlphalistFillerChar returns the character being used as the filler character in the entry field portion of the widget. .TP 5 .B getCDKAlphalistHighlight returns the attribute of the highlight bar of the scrolling list portion of the widget. .TP 5 .B injectCDKAlphalist injects a single character into the widget (actually the entry widget). The parameter \fBalphalist\fR is a pointer to a non-NULL alphalist widget. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR the function returns the information in the entry field. The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns a \fINULL\fR pointer. The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns a \fINULL\fR pointer. The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .TP 5 .B moveCDKAlphalist moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDKAlphalist creates a pointer to an alphalist widget. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. This parameter can take an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. This parameter may be an integer value or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBheight\fR and .TP 5 \fBwidth\fR control the height and width of the widget. If you provide a value of zero for either of the height or the width, the widget will be created with the full width and height of the screen. If you provide a negative value, the widget will be created the full height or width minus the value provided. .TP 5 \fBtitle\fR is the string which will be displayed at the top of the scrolling list. The title can be more than one line; just provide a carriage return character at the line break. .TP 5 \fBlabel\fR is the string which will be displayed in the label of the entry field. .TP 5 \fBlist\fR is the list of words which will be displayed in the scrolling list. This list does not have to be sorted, this widget automatically sorts the list (note that it modifies the caller's copy of the list to do this). .TP 5 \fBlistSize\fR tells the widget how large the word list is. .TP 5 \fBfillerCharacter\fR is the character which is to be displayed in an empty space in the entry field. .TP 5 \fBhighlight\fR is the attribute of the highlight bar in the scrolling list. .TP 5 \fBbox\fR is true if the widget should be drawn with a box around it. .TP 5 \fBshadow\fR is true to turn the shadow on around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKAlphalist allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDKAlphalist lets the programmer modify certain elements of an existing alphalist widget. The parameter names correspond to the same parameter names listed in the \fBnewCDKAlphalist\fR function. .TP 5 .B setCDKAlphalistBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKAlphalistBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .TP 5 .B setCDKAlphalistBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKAlphalistBoxAttribute sets the attribute of the box. .TP 5 .B setCDKAlphalistContents sets the contents of the alphalist widget (note that it sorts the caller's copy of the list). .TP 5 .B setCDKAlphalistCurrentItem set the current position in the scroll-widget. .TP 5 .B setCDKAlphalistFillerChar sets the character to use when drawing the entry field portion of the widget. .TP 5 .B setCDKAlphalistHighlight sets the attribute of the highlight bar of the scrolling list portion of the widget. .TP 5 .B setCDKAlphalistHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKAlphalistLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKAlphalistLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKAlphalistPostProcess allows the user to have the widget call a function after the key has been applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about post-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKAlphalistPreProcess allows the user to have the widget call a function after a key is hit and before the key is applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about pre-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKAlphalistULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKAlphalistURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKAlphalistVerticalChar sets the vertical drawing character for the box to the given character. .SH KEY BINDINGS When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. Since this widget is built from both the scrolling list widget and the entry field widget, the key bindings are the same for the respective fields. The extra key bindings are listed below. .LP .TS center tab(/) allbox; l l l l lw15 lw35 . \fBKey/Action\fR = Up Arrow/T{ Scrolls the scrolling list up one line. T} Down Arrow/T{ Scrolls the scrolling list down one line. T} Page Up/T{ Scrolls the scrolling list up one page. T} CTRL-B/T{ Scrolls the scrolling list up one page. Page Down/Scrolls the scrolling list down one page. T} CTRL-F/T{ Scrolls the scrolling list down one page. T} Tab/T{ Tries to complete the word in the entry field. If the word segment is not unique then the widget will beep and present a list of close matches. T} Return/T{ Returns the word in the entry field. It also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Escape/T{ Exits the widget and returns a \fINULL\fR pointer. It also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR. T} .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_screen (3) .SH NOTES .PP This widget is created from the scrolling list widget and the entry field widget. This is a good example on how to build your own widgets using the base widgets provided in this distribution. cdk-5.0-20060507/man/cdk_screen.30000644000175100001440000000673310354636130014510 0ustar tomusers.\" $Id: cdk_screen.3,v 1.8 2005/12/29 01:31:04 tom Exp $ .de XX .. .TH cdk_screen 3 .SH NAME .XX destroyCDKScreen .XX endCDK .XX eraseCDKScreen .XX initCDKColor .XX initCDKScreen .XX lowerCDKObject .XX raiseCDKObject .XX refreshCDKScreen .XX registerCDKObject .XX unregisterCDKObject cdk_screen \- Cdk Screen and Widget Manipulation Functions .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "void destroyCDKScreen(" .BI "CDKSCREEN *" "screen"); .TP 15 .B "void endCDK(void)"; .TP 15 .B "void eraseCDKScreen(" .BI "CDKSCREEN *" "screen"); .TP 15 .B "void initCDKColor (void)"; .TP 15 .B "CDKSCREEN *initCDKScreen (" .BI "WINDOW *" "cursesWindow"); .TP 15 .B "void lowerCDKObject(" .BI "EObjectType " "widgetType", .BI "void *" "object"); .TP 15 .B "void raiseCDKObject(" .BI "EObjectType " "widgetType", .BI "void *" "object"); .TP 15 .B "void refreshCDKScreen(" .BI "CDKSCREEN *" "screen"); .TP 15 .B "void registerCDKObject (" .BI "CDKSCREEN *" "screen", .BI "EObjectType " "widgetType", .BI "void *" "object"); .TP 15 .B "void unregisterCDKObject(" .BI "EObjectType " "widgetType", .BI "void *" "object"); .fi .SH DESCRIPTION Cdk manages all of the widgets for you. These functions perform some of the management of the widgets in a screen. .SH AVAILABLE FUNCTIONS .TP 5 .B destroyCDKScreen frees any memory allocated by the Cdk screen pointer. .TP 5 .B endCDK cleans up any memory created by starting Cdk and shuts down curses. .TP 5 .B eraseCDKScreen erases all of the widgets which are currently associated to the given screen. This does \fBNOT\fR destroy the widgets. .TP 5 .B initCDKColor starts the Cdk color capabilities. It defines 64 color pairs each of which is accessible using the COLOR_PAIR macro. If you do not have color support, this function call makes no difference. .TP 5 .B initCDKScreen takes a \fIWINDOW *\fR (\fIcursesWindow\fR) and returns a pointer to a \fICDKSCREEN *\fR. Since all of the widgets take a \fICDKSCREEN\fR pointer as a first argument, this is also one of the first calls made. This also starts curses, so no curses initialization calls have to be made when using Cdk. .TP 5 .B lowerCDKObject has the opposite effect of the \fBraiseCDKObject\fR function call. .TP 5 .B raiseCDKObject raises the widget to the top of the screen. If there are any widgets which overlap the given object when a refresh is done, calling this function has the effect of raiding the object so no other widgets obstruct it. The \fIwidgetType\fR parameter states what Cdk widget type this object is. The \fIobject\fR parameter is a void pointer to the object. .TP 5 .B refreshCDKScreen redraws all of the widgets which are currently associated to the given screen. .TP 5 .B registerCDKObject is called automatically when a widget is created. If for some reason an object does get unregistered, by calling \fBunregisterCDKObject\fR, the widget can be registered again by calling this function. The \fIwidgetType\fR parameter states what Cdk widget type this object is. The \fIobject\fR parameter is a void pointer to the object. .TP 5 .B unregisterCDKObject removes the widget from the screen. This does \fBNOT\fR destroy the object, it removes the widget from any further refreshes by the function \fBrefreshCDKScreen\fR. The \fIwidgetType\fR parameter states what Cdk widget type this object is. The \fIobject\fR parameter is a void pointer to the object. .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3) cdk-5.0-20060507/man/cdk_template.30000644000175100001440000003233010420177137015035 0ustar tomusers.\" $Id: cdk_template.3,v 1.25 2006/04/15 14:08:31 tom Exp $ .de XX .. .TH cdk_template 3 .SH NAME .XX activateCDKTemplate .XX cleanCDKTemplate .XX destroyCDKTemplate .XX drawCDKTemplate .XX eraseCDKTemplate .XX getCDKTemplateBox .XX getCDKTemplateMin .XX getCDKTemplateValue .XX injectCDKTemplate .XX mixCDKTemplate .XX newCDKTemplate .XX setCDKTemplate .XX setCDKTemplateBackgroundAttrib .XX setCDKTemplateBackgroundColor .XX setCDKTemplateBox .XX setCDKTemplateBoxAttribute .XX setCDKTemplateCB .XX setCDKTemplateHorizontalChar .XX setCDKTemplateLLChar .XX setCDKTemplateLRChar .XX setCDKTemplateMin .XX setCDKTemplatePostProcess .XX setCDKTemplatePreProcess .XX setCDKTemplateULChar .XX setCDKTemplateURChar .XX setCDKTemplateValue .XX setCDKTemplateVerticalChar .XX unmixCDKTemplate cdk_template \- a curses template widget. .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "char *activateCDKTemplate (" .BI "CDKTEMPLATE *" "template", .BI "chtype * " "actions"); .TP 15 .B "void cleanCDKTemplate (" .BI "CDKTEMPLATE *" "template"); .TP 15 .B "void destroyCDKTemplate (" .BI "CDKTEMPLATE *" "template"); .TP 15 .B "void drawCDKTemplate (" .BI "CDKTEMPLATE *" "template", .BI "boolean " "box"); .TP 15 .B "void eraseCDKTemplate (" .BI "CDKTEMPLATE *" "template"); .TP 15 .B "boolean getCDKTemplateBox (" .BI "CDKTEMPLATE *" "template"); .TP 15 .B "int getCDKTemplateMin (" .BI "CDKTEMPLATE *" "template"); .TP 15 .B "char *getCDKTemplateValue (" .BI "CDKTEMPLATE *" "template"); .TP 15 .B "char *injectCDKTemplate (" .BI "CDKTEMPLATE *" "template", .BI "chtype " "input"); .TP 15 .B "char *mixCDKTemplate (" .BI "CDKTEMPLATE *" "template"); .TP 15 .B "void moveCDKTemplate (" .BI "CDKTEMPLATE *" "template", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKTEMPLATE *newCDKTemplate (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "char *" "title", .BI "char *" "label", .BI "char *" "plate", .BI "char *" "overlay", .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKTemplate (" .BI "CDKTEMPLATE *" "template"); .TP 15 .B "void setCDKTemplate (" .BI "CDKTEMPLATE *" "template", .BI "char *" "value", .BI "boolean " "box"); .TP 15 .B "void setCDKTemplateBackgroundAttrib (" .BI "CDKTEMPLATE *" "template", .BI "chtype " "attribute"); .TP 15 .B "void setCDKTemplateBackgroundColor (" .BI "CDKTEMPLATE *" "template", .BI "char * " "color"); .TP 15 .B "void setCDKTemplateBox (" .BI "CDKTEMPLATE *" "template", .BI "boolean " "box"); .TP 15 .B "void setCDKTemplateBoxAttribute (" .BI "CDKTEMPLATE *" "template", .BI "chtype " "character"); .TP 15 .B "void setCDKTemplateCB (" .BI "CDKTEMPLATE *" "template", .BI "TEMPLATECB " "callbackFunction"); .TP 15 .B "void setCDKTemplateHorizontalChar (" .BI "CDKTEMPLATE *" "template", .BI "chtype " "character"); .TP 15 .B "void setCDKTemplateLLChar (" .BI "CDKTEMPLATE *" "template", .BI "chtype " "character"); .TP 15 .B "void setCDKTemplateLRChar (" .BI "CDKTEMPLATE *" "template", .BI "chtype " "character"); .TP 15 .B "void setCDKTemplateMin (" .BI "CDKTEMPLATE *" "template", .BI "int " "minimum"); .TP 15 .B "void setCDKTemplatePostProcess (" .BI "CDKTEMPLATE *" "template", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKTemplatePreProcess (" .BI "CDKTEMPLATE *" "template", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKTemplateULChar (" .BI "CDKTEMPLATE *" "template", .BI "chtype " "character"); .TP 15 .B "void setCDKTemplateURChar (" .BI "CDKTEMPLATE *" "template", .BI "chtype " "character"); .TP 15 .B "void setCDKTemplateValue (" .BI "CDKTEMPLATE *" "template", .BI "char *" "value"); .TP 15 .B "void setCDKTemplateVerticalChar (" .BI "CDKTEMPLATE *" "template", .BI "chtype " "character"); .TP 15 .B "char *unmixCDKTemplate (" .BI "CDKTEMPLATE *" "template", .BI "char *" "string"); .fi .SH DESCRIPTION The Cdk template widget creates a template widget which allows a user to type information into an entry field with a pre-set field format. Typical uses for this widget would be a date field or a time field. The following are functions which create or manipulate the Cdk template box widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKTemplate activates the template widget and lets the user interact with the widget. The parameter \fBtemplate\fR is a pointer to a non-NULL template widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a \fIchar\ *\fR representing the information typed into the widget and the widget data \fIexitType\fR will be set to \fIvNORMAL\fR. If the character entered was \fIESCAPE\fR then the function will return \fINULL\fR pointer and the widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP 5 .B cleanCDKTemplate clears the information from the field. .TP 5 .B destroyCDKTemplate removes the widget from the screen and frees any memory the object used. .TP 5 .B drawCDKTemplate draws the template widget on the screen. If \fBbox\fR is true, the widget is drawn with a box. .TP 5 .B eraseCDKTemplate removes the widget from the screen. This does \fBNOT\fR destroy the widget. .TP 5 .B getCDKTemplateBox returns true if the widget will be drawn with a box around it. .TP 5 .B getCDKTemplateMin returns the minimum characters that must be entered before the widget will exit. .TP 5 .B getCDKTemplateValue returns the current value of the widget. .TP 5 .B injectCDKTemplate injects a single character into the widget. The parameter \fBtemplate\fR is a pointer to a non-NULL template widget. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR the function returns a \fIchar\ *\fR representing the information typed into the widget. The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns a \fINULL\fR pointer. The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns a \fINULL\fR pointer. The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .TP 5 .B mixCDKTemplate returns a \fIchar*\fR pointer to the field value and the plate. .TP 5 .B moveCDKTemplate moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR is an integer or one of the predefined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will be repainted after the move. .TP 5 .B newCDKTemplate creates a template widget, returning a pointer to it. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBtitle\fR is the string to display at the top of the widget. The title can be more than one line; just provide a carriage return character at the line break. .TP 5 \fBlabel\fR is the string to display in the label of the template field. .TP 5 \fBplate\fR defines the character to allow at each position in the template field. This is done by creating a character plate by using special format character to tell the template widget what type of character is allowed where in the template widget. The following table lists the format types. .LP .TS center tab(/); l l l lw15 lw35 . \fBPlate_Character/Effect\fR = #/Accepts an integer. A/Accepts an alphabetic value. C/T{ Accepts an alphabetic value. Automatically converts the character to upper case. T} c/T{ Accepts an alphabetic value. Automatically converts the character to lower case. T} M/T{ Accepts alphanumeric characters. T} X/T{ Accepts alphanumeric characters. Automatically converts the character to upper case. T} x/T{ Accepts alphanumeric characters. Automatically converts the character to upper case. T} Anything else/T{ Ignored and assumed a non-editable position. T} = .TE .TP 5 \fBoverlay\fR is the overlay of the template field. If the field needs some sort of overlay, this parameter supplies this. A date field could have YY/MM/DD, the overlay parameter would display YY/MM/DD on an empty template field. .TP 5 \fBbox\fR is true if the widget should be drawn with a box around it. .TP 5 \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKTemplate allows the user to move the widget around the screen via the single keystroke commands. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDKTemplate lets the programmer modify certain elements of an existing template widget. The parameter names correspond to the same parameter names listed in the \fBnewCDKTemplate\fR function. .TP 5 .B setCDKTemplateBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKTemplateBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. For more information, see the \fIcdk_display (3)\fR. .TP 5 .B setCDKTemplateBox sets a flag, true if the widget will be drawn with a box around it. .TP 5 .B setCDKTemplateBoxAttribute sets the attribute of the box. .TP 5 .B setCDKTemplateCB allows the programmer to set a different widget input handler. The parameter \fBcallbackFunction\fR is of type \fITEMPLATECB\fR. The default input handler is \fICDKTemplateCallBack\fR. .TP 5 .B setCDKTemplateHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKTemplateLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKTemplateLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKTemplateMin sets the minimum number of characters that must be entered before the widget will exit. .TP 5 .B setCDKTemplatePostProcess allows the user to have the widget call a function after the key has been applied to the widget. To learn more about post-processing see \fIcdk_process\fR (3). .TP 5 .B setCDKTemplatePreProcess allows the user to have the widget call a function after a key is hit and before the key is applied to the widget. To learn more about preprocessing see \fIcdk_process\fR (3). .TP 5 .B setCDKTemplateULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKTemplateURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKTemplateValue sets a value in the widget. .TP 5 .B setCDKTemplateVerticalChar sets the vertical drawing character for the box to the given character. .TP 5 .B unmixCDKTemplate returns a \fIchar*\fR pointer to the field value without any plate characters. .SH KEY BINDINGS When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. The following table outlines the keys and their actions for this widget. .TS center tab(/) allbox; l l l l lw15 lw35 . \fBKey/Action\fR = Delete/T{ Deletes the character at the cursor. T} Backspace/T{ Deletes the character before cursor, moves cursor left. T} Ctrl-P/T{ Pastes whatever is in the paste buffer, into the widget. T} Ctrl-K/T{ Cuts the contents from the widget and saves a copy in the paste buffer. T} Ctrl-T/T{ Copies the contents of the widget into the paste buffer. T} Ctrl-E/T{ Erases the contents of the widget. T} Return/T{ Exits the widget and returns a \fIchar*\fR representing the information which was typed into the field. It also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Tab/T{ Exits the widget and returns a \fIchar*\fR representing the information which was typed into the field. It also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Escape/T{ Exits the widget and returns a \fINULL\fR pointer. It also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR. T} Ctrl-L/Refreshes the screen. .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_traverse.30000644000175100001440000001453510355110655015063 0ustar tomusers.\" $Id: cdk_traverse.3,v 1.7 2005/12/30 01:47:25 tom Exp $ .de XX .. .TH cdk_traverse 3 .SH NAME .XX exitCancelCDKScreen .XX exitCancelCDKScreenOf .XX exitOKCDKScreen .XX exitOKCDKScreenOf .XX getCDKFocusCurrent .XX resetCDKScreen .XX resetCDKScreenOf .XX setCDKFocusCurrent .XX setCDKFocusFirst .XX setCDKFocusLast .XX setCDKFocusNext .XX setCDKFocusPrevious .XX traverseCDKOnce .XX traverseCDKScreen cdk_traverse - functions to support keyboard traversal .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP .nf #include .LP .BI "CDKOBJS *getCDKFocusCurrent (CDKSCREEN *" "screen"); .LP .BI "CDKOBJS *setCDKFocusCurrent (CDKSCREEN *" "screen\fB, CDKOBJS *\fPobj"); .LP .BI "CDKOBJS *setCDKFocusFirst (CDKSCREEN *" "screen"); .LP .BI "CDKOBJS *setCDKFocusLast (CDKSCREEN *" "screen"); .LP .BI "CDKOBJS *setCDKFocusNext (CDKSCREEN *" "screen"); .LP .BI "CDKOBJS *setCDKFocusPrevious (CDKSCREEN *" "screen"); .LP .BI "int traverseCDKScreen (CDKSCREEN *" "screen"); .LP .BI "void exitOKCDKScreen (CDKSCREEN *" "screen"); .LP .BI "void exitCancelCDKScreen (CDKSCREEN *" "screen"); .LP .BI "void resetCDKScreen (CDKSCREEN *" "screen"); .LP .BI "void exitOKCDKScreenOf(CDKOBJS *" "obj"); .LP .BI "void exitCancelCDKScreenOf (CDKOBJS *" "obj"); .LP .BI "void resetCDKScreenOf (CDKOBJS *" "obj"); .TP 15 .BI "void traverseCDKOnce (" .BI "CDKSCREEN *\fIscreen\fP," .BI "CDKOBJS *\fIcurobj\fP," .BI "int \fIkeyCode\fP," .BI "boolean \fIfunctionKey\fP," .BI "CHECK_KEYCODE \fIfuncMenuKey\fP); .fi . .SH DESCRIPTION The functions above handle the traversal of a screen populated with various widgets. Once the screen has been created and populated with widgets, a single call to \fBtraverseCDKScreen()\fP will allow the user to move between widgets and enter data (or otherwise manipulate widgets). Other functions are provided for use as callbacks by the widgets on the screen. Finally, there are several functions which allow the caller to manipulate the state of the traversal, i.e., the object which has focus. .LP In order for widgets to be used on a screen which is to be handled by \fBtraverseCDKScreen()\fP, it must have the following methods available: .nf .ft C injectCharObj inputWindowObj focusObj unfocusObj saveDataObj refreshDataObj .ft R .fi .LP In addition, the following object properties must be properly handled: .nf .ft C acceptsFocus hasFocus inputWindow dataPtr dataType .ft R .fi .LP At the time of this writing, not all widgets have been modified to work with the screen-traversal facility. .SH AVAILABLE FUNCTIONS .B int traverseCDKScreen (CDKSCREEN *\fIscreen\fP); .RS 3 This function contains the main screen traversal engine. It does the following: .TP 4 1. Calls the refreshData method on each of the widgets to tell them to update their appearance to match the data which are referenced by their respective data pointers. .TP 4 2. Calls the focusObject method on the first widget. .TP 4 3. Repeats the following until one of the exit functions listed above has been called: .RS 4 .TP 3 * Read a keystroke from the keyboard. .TP 3 * If the keystroke is ESCAPE and a menu widget is present, activate the menu and traverse it until the user selects an entry or hits TAB. .TP 3 * If the keystroke is TAB/BACKTAB then call the unfocusObject method on the current widget, and move focus to the next/previous widget (not counting menu widgets). Call the focusObject method on the newly current widget. .TP 3 * If the keystroke is the EXIT-SAVE keystroke, then call the saveData method on each widget and return 1. .TP 3 * If the keystroke is the EXIT-CANCEL keystroke, return 0 without saving changes made by the user. .TP 3 * If the keystroke is the RESET-DATA keystroke, then call the refreshData method on each of the widgets to reset their appearance to match the data values that were present upon entry. .TP 3 * Otherwise, pass the keystroke to the current widget. .RE .RE .TP 5 .B CDKOBJS *getCDKFocusCurrent (CDKSCREEN *\fIscreen\fP); Return a pointer to the object which currently has focus in the given screen. .TP 5 .B CDKOBJS *setCDKFocusCurrent (CDKSCREEN *\fIscreen\fP, CDKOBJS *\fIobj\fP); Set the focus to the given object, if the screen contains that object. If the screen does not contain the object, return null. Otherwise, return the object. .TP 5 .B CDKOBJS *setCDKFocusFirst (CDKSCREEN *\fIscreen\fP); Set focus on the first object in the given screen. .TP 5 .B CDKOBJS *setCDKFocusLast (CDKSCREEN *\fIscreen\fP); Set focus on the last object in the given screen. .TP 5 .B CDKOBJS *setCDKFocusNext (CDKSCREEN *\fIscreen\fP); Set focus on the next object in the given screen. .TP 5 .B CDKOBJS *setCDKFocusPrevious (CDKSCREEN *\fIscreen\fP); Set focus on the previous object in the given screen. .TP 5 .B exitOKCDKScreen .RS 3 Causes the traversal engine to exit after calling the saveData method for each of the widgets. .RE .TP 5 .B exitOKCDKScreenOf .RS 3 Calls \fBexitOKCDKScreen()\fP on the screen associated with widget \fIobj\fP. This function was designed to be used as a callback routine for a button widget used as an OK button on a data-entry screen. .RE .TP 5 .B exitCancelCDKScreen .RS 3 Causes the traversal engine to exit without saving user modified data. .RE .TP 5 .B exitCancelCDKScreenOf .RS 3 Calls \fBexitCancelCDKScreen()\fP on the screen associated with widget \fIobj\fP. This function was designed to be used as a callback routine for a button widget used as a Cancel button on a data-entry screen. .RE .TP 5 .B resetCDKScreen .RS 3 Causes the traversal engine to call the refreshData method for each widget. This will cause any unsaved changes to be discarded and the widget states will be restored to their initial values. .RE .TP 5 .B resetCDKScreenOf .RS 3 Calls \fBresetCDKScreen()\fP on the screen associated with widget \fIobj\fP. This function was designed to be used as a callback routine for a button widget used as a Reset button on a data-entry screen. .RE .TP 5 .B traverseCDKOnce .RS 3 This is a utility function, one of the pieces from which you can construct a customized version of \fBtraverseCDKScreen\fP. .RE .SH BUGS Not all widgets have had the extra methods added so that they work with the screen traversal engine. .SH AUTHOR Grant Edwards, Aspen Research Corporation .br Thomas Dickey and contributors. .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_binding.30000644000175100001440000002213610355074367014647 0ustar tomusers'\" t .\" $Id: cdk_binding.3,v 1.22 2005/12/30 00:01:59 tom Exp $ .de XX .. .TH cdk_binding 3 .SH NAME .XX bindCDKObject .XX checkCDKObjectBind .XX cleanCDKObjectBindings .XX unbindCDKObject .XX getcCDKObject .XX getchCDKObject cdk_binding - \fBCurses Development Kit\fR Character Binding Capabilities. .LP .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP .nf #include .TP 15 .B "void bindCDKObject (" .BI "EObjectType " "cdkType", .BI "void *" "object", .BI "chtype " "key", .BI "BINDFN " "function", .BI "void *" "data"); .TP 15 .B "int checkCDKObjectBind (" .BI "EObjectType " "cdkType", .BI "void *" "object", .BI "chtype " "key"); .TP 15 .B "void cleanCDKObjectBindings (" .BI "EObjectType " "cdkType", .BI "void *" "object"); .TP 15 .B "bool isCDKObjectBind (" .BI "EObjectType " "cdkType", .BI "void *" "object", .BI "chtype " "key"); .TP 15 .B "void unbindCDKObject (" .BI "EObjectType " "cdkType", .BI "void *" "object", .BI "chtype " "key"); .TP 15 .B "int getcCDKObject (" .BI "CDKOBJS *" "object"); .TP 15 .B "int getchCDKObject (" .BI "CDKOBJS *" "object", .BI "boolean *" "functionKey"); .fi .SH DESCRIPTION Cdk has the ability to create user definable key bindings. This ability makes Cdk more dynamic and usable for a wide variety of tasks. The following section outlines the binding functions, their use, and their purpose. .TP 5 .B bindCDKObject creates a key binding between a specific Cdk widget (\fBobject\fR) given key (\fBkey\fR). The parameter \fBcdkType\fR is of type \fIEObjectType\fR which is one of the following values. .LP .TS center tab(/); l l l lw13 lw30 lw 30 . \fBEObjectType_Value/Corresponding_Widget/Widget_Manual_Page\fR = vALPHALIST/Alphalist Widget/cdk_alphalist (3) vBUTTON/Button Widget/cdk_button (3) vBUTTONBOX/Buttonbox Widget/cdk_buttonbox (3) vCALENDAR/Calendar Widget/cdk_calendar (3) vDIALOG/Dialog Widget/cdk_dialog (3) vDSCALE/DoubleFloat Widget/cdk_dscale (3) vENTRY/Entry Widget/cdk_entry (3) vFSCALE/Floating Scale Widget/cdk_fscale (3) vFSELECT/File Selector Widget/cdk_fselect (3) vFSLIDER/Floating Slider Widget/cdk_fslider (3) vGRAPH/Graph Widget/cdk_graph (3) vHISTOGRAM/Histogram Widget/cdk_histogram (3) vITEMLIST/Item List Widget/cdk_itemlist (3) vLABEL/Label Widget/cdk_label (3) vMARQUEE/Marquee Widget/cdk_marquee (3) vMATRIX/Matrix Widget/cdk_matrix (3) vMENTRY/Multiple Line Entry Widget/cdk_mentry (3) vMENU/Menu Widget/cdk_menu (3) vRADIO/Radio List Widget/cdk_radio (3) vSCALE/Integer Scale Widget/cdk_scale (3) vSCROLL/Scrolling List Widget/cdk_scroll (3) vSELECTION/Selection List Widget/cdk_selection (3) vSLIDER/Slider Widget/cdk_slider (3) vSWINDOW/Scrolling Window Widget/cdk_swindow (3) vTEMPLATE/Template Entry Widget/cdk_template (3) vUSCALE/Unsigned Scale Widget/cdk_uscale (3) vUSLIDER/Unsigned Slider Widget/cdk_uslider (3) vVIEWER/Viewer Widget/cdk_viewer (3) = .TE .RS 3 The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. The parameter \fBkey\fR is the key hit which triggered this callback. .RE .TP 5 .B checkCDKObjectBind check to see if a binding for the given \fBkey\fP exists. If it does, Cdk runs the associated command and returns its value, normally TRUE. If no binding exists, return FALSE. .IP The widgets which accept input, e.g., via "inject" methods, use this to check if the injected character is bound to a function. If that returns TRUE, the widget may update its \fIexitType\fP value: if \fIearlyExit\fP value is set (not equal to vNEVER_ACTIVATED), the widget sets \fIexitType\fP to that value. .TP 5 .B cleanCDKObjectBindings removes all user defined key bindings from the given widget. .TP 5 .B isCDKObjectBind check to see if a binding for the given \fBkey\fP exists. If it does return TRUE. If no binding exists, return FALSE. .TP 5 .B unbindCDKObject removes a specific binding to an object. The parameter are the same as for \fBbindCDKObject\fR. .TP 5 .B getcCDKObject reads a keycode from the given widget. This is depcrecated: use \fBgetchCDKObject\fP. .TP 5 .B getchCDKObject reads a keycode from the given widget. It sets a flag to indicate if the result is a function key. If the keycode has been bound to the special function \fBgetcCDKBind\fP, then it will be translated to the value which was given for the binding data. Otherwise, a few special cases are performed: .TS center tab(/) allbox; l l l l lw35 lw35 . \fBKey/Result\fR = CTRL-A/KEY_HOME CTRL-B/KEY_LEFT CTRL-E/KEY_END CTRL-F/KEY_RIGHT CTRL-N/tab CTRL-P/KEY_BTAB DEL/KEY_DC backspace/KEY_BACKSPACE carriage return/KEY_ENTER newline/KEY_ENTER .TE .PP All of the widgets use \fBgetchCDKObject\fP internally for consistency. .SH EXAMPLE To help demonstrate how to use the key bindings I will demonstrate a simple dialog box widget with help for each button. The following code segment creates a dialog box and a callback function named \fIdialogHelpCB\fR. .LP .nf .ce \fI________________________________________\fR .LP .ta 9 17 25 33 41 #include #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; char *mesg[5]; /* Check which button we are on. */ if (dialog->currentButton == 0) { mesg[0] = "Help for Who."; mesg[1] = "When this button is picked the name of the current"; mesg[2] = "user is displayed on the screen in a popup window."; popupLabel (ScreenOf(dialog), mesg, 3); } else if (dialog->currentButton == 1) { mesg[0] = "Help for Time."; mesg[1] = "When this button is picked the current time is"; mesg[2] = "displayed on the screen in a popup window."; popupLabel (ScreenOf(dialog), mesg, 3); } else if (dialog->currentButton == 2) { mesg[0] = "Help for Date."; mesg[1] = "When this button is picked the current date is"; mesg[2] = "displayed on the screen in a popup window."; popupLabel (ScreenOf(dialog), mesg, 3); } else if (dialog->currentButton == 3) { mesg[0] = "Help for Quit."; mesg[1] = "When this button is picked the dialog box is exited."; popupLabel (ScreenOf(dialog), mesg, 2); } return (FALSE); } int main (void) { /* Declare variables. */ CDKSCREEN *cdkscreen; CDKDIALOG *question; WINDOW *cursesWin; char *buttons[40]; char *message[40], *info[5], *loginName; char temp[256]; int selection; time_t clck; struct tm *currentTime; /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start color. */ initCDKColor(); /* Set up the dialog box. */ message[0] = "Simple Command Interface"; message[1] = "Pick the command you wish to run."; message[2] = "Press ? for help."; buttons[0] = "Who"; buttons[1] = "Time"; buttons[2] = "Date"; buttons[3] = "Quit"; /* Create the dialog box. */ question = newCDKDialog (cdkscreen, CENTER, CENTER, message, 3, buttons, 4, A_REVERSE, TRUE, TRUE, FALSE); /* Check if we got a null value back. */ if (question == (CDKDIALOG *)0) { destroyCDKScreen (cdkscreen); /* End curses... */ endCDK(); /* Spit out a message. */ printf ("Oops. Can't seem to create the dialog box. Is the window too small?\\n"); exit (1); } /* 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] = " Login Name "; loginName = getlogin(); if (loginName == (char *)0) { strcpy (temp, "Unknown"); } else { sprintf (temp, "<%s>", loginName); } info[1] = copyChar (temp); popupLabel (ScreenOf(question), info, 2); freeChar (info[1]); } else if (selection == 1) { /* Print out the time. */ time(&clck); currentTime = localtime(&clck); sprintf (temp, "%d:%d:%d", currentTime->tm_hour, currentTime->tm_min, currentTime->tm_sec); info[0] = " Current Time "; info[1] = copyChar (temp); popupLabel (ScreenOf(question), info, 2); freeChar (info[1]); } else if (selection == 2) { /* Print out the date. */ time(&clck); currentTime = localtime(&clck); sprintf (temp, "%d/%d/%02d", currentTime->tm_mday, currentTime->tm_mon, currentTime->tm_year % 100); info[0] = " Current Date "; info[1] = copyChar (temp); popupLabel (ScreenOf(question), info, 2); freeChar (info[1]); } } /* Clean up. */ destroyCDKDialog (question); destroyCDKScreen (cdkscreen); delwin (cursesWin); endCDK(); exit (0); } .fi .ce \fI________________________________________\fR .SH SEE ALSO .BR cdk (3), .BR cdk_display (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk.30000644000175100001440000001172710355326535013156 0ustar tomusers'\" t .\" $Id: cdk.3,v 1.12 2005/12/30 21:57:49 tom Exp $ .de It .br .ie \\n(.$>=3 .ne \\$3 .el .ne 3 .IP "\\$1" \\$2 .. .TH Cdk 3 .SH NAME cdk - \fBCurses Development Kit\fR .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .LP Cdk provides functions to use a large number of predefined curses widgets. To use the Cdk widgets the header file \fIcdk.h\fR must be included in the source. .LP The widgets available from Cdk are listed below. .LP .TS center tab(/); l l l l . \fBWidget Type/Manual Page Name\fR = Alphalist/cdk_alphalist (3) Button/cdk_button (3) Buttonbox/cdk_buttonbox (3) Calendar/cdk_calendar (3) Dialog/cdk_dialog (3) DoubleFloat Scale/cdk_dscale (3) Entry Field/cdk_entry (3) File Selector/cdk_fselect (3) File Viewer/cdk_viewer (3) Floating Scale/cdk_fscale (3) Floating Slider/cdk_fslider (3) Graph/cdk_graph (3) Histogram/cdk_histogram (3) Integer Scale/cdk_scale (3) Integer Slider/cdk_slider (3) Item List/cdk_itemlist (3) Label/cdk_label (3) Marquee/cdk_marquee (3) Matrix/cdk_matrix (3) Multiple Line Entry Field/cdk_mentry (3) Pulldown Menu/cdk_menu (3) Radio List/cdk_radio (3) Scrolling List/cdk_scroll (3) Scrolling Selection List/cdk_selection (3) Scrolling Window/cdk_swindow (3) Template/cdk_template (3) Unsigned Scale/cdk_uscale (3) Unsigned Slider/cdk_uslider (3) .TE .LP The rest of the manual pages describe supporting functions: .LP .TS center tab(/); l l l l lw18 lw35 . \fBManual Page Name/Description\fR = cdk_binding (3)/T{ Outlines how to create user definable key bindings. T} cdk_display (3)/T{ Shows how to add special display attributes, colors, and justification into a widget. T} cdk_draw (3)/T{ Outlines functions used for drawing text and lines. T} cdk_screen (3)/T{ Demonstrates the use of screens within Cdk. T} cdk_misc (3)/T{ Outlines miscellaneous functions provided with the Cdk library. T} cdk_process (3)/T{ Demonstrates the use of the pre- and post-process function class. T} .TE .SH DESCRIPTION Cdk is a library of functions which allow a programmer to quickly create a full screen interactive program with ease. The Cdk widgets support the following features: .It "\(bu Ncurses library." 5 Instead of using the standard curses library, Cdk can take advantage of the colors that Ncurses provides. To learn how to take advantage of Cdk's color capabilities, see \fIcdk_display (3)\fR. .PP .It "\(bu Key Bindings." 5 Individual keys can be overridden with a callback. The callback is set up using the \fBbindCDKObject\fR function. To learn more about this see \fIcdk_binding (3)\fR. .PP .It "\(bu Pre and Post Processing." 5 Certain widgets allow the user to trap a character before and after the character has been applied to the widget. This allows programmers to `filter' character input. To learn more about this see \fIcdk_process (3)\fR. .PP .It "\(bu Self Test Widgets." 5 With the use of the inject function class and the activate function, programmers can have the widgets test themselves. This allows the programmer to perform automated tests on a final program. .PP .It "\(bu Special Display Formats" 5 There are special character format commands that can be inserted into any string in Cdk and the contents will get mapped to a \fIchtype\fR (see the curses manual page) with character attributes. This allows the programmer to insert format types on each character if they wish. .PP .It "\(bu The Ability To Build Predefined Screens" 5 Widgets can be associated to any given screen. If there is more than one screen defined, then Cdk has the ability to "flip" from one screen to another with ease. See the \fIcdk_screen\fR manual page for more details. .PP .SH STANDARD WIDGET BEHAVIOR All of the widgets have a member of the structure called \fIexitType\fR. This member states how the widget exited. There are three values in which to check for, they are as follows: .LP .TS center tab(/) allbox; l l l l lw15 lw35 . \fBValue/Meaning\fR = vNORMAL/T{ This means the widget exited normally. This value is set when the widget is given the characters TAB or RETURN. T} vEARLY_EXIT/T{ This means the widget exited early. This value is set when characters such as TAB or RETURN are injected into the widget via the injectCDKXXX function and the character injected does not exit the widget. T} vESCAPE_HIT/T{ This value states the user hit ESCAPE to leave the widget. T} vNEVER_ACTIVATED/T{ This is the initial state of the value. This means that the widget has not been activated. T} .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_draw (3), .BR cdk_misc (3), .BR cdk_process (3), .BR cdk_screen (3) . .SH NOTES .PP The header file \fI\fR automatically includes the header files \fI\fR, \fI\fR, \fI\fR, \fI\fR, \fI\fR, \fI\fR, \fI\fR, \fI\fR, \fI\fR, \fI\fR, \fI\fR, and \fI\fR. The \fI\fR header file includes \fI\fR and \fI\fR. cdk-5.0-20060507/man/cdk_draw.30000644000175100001440000001203510355334234014157 0ustar tomusers.\" $Id: cdk_draw.3,v 1.3 2005/12/30 22:45:48 tom Exp $ .de XX .. .TH cdk_draw 3 .XX boxWindow .XX attrbox .XX drawObjBox .XX drawLine .XX drawShadow .XX writeBlanks .XX writeChar .XX writeCharAttrib .XX writeChtype .XX writeChtypeAttrib .SH NAME cdk_draw \- Cdk Drawing Functions .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "void boxWindow (" .BI "WINDOW *" "window", .BI "chtype " "attr"); .TP 15 .B "void attrbox (" .BI "WINDOW *" "win", .BI "chtype " "tlc", .BI "chtype " "trc", .BI "chtype " "blc", .BI "chtype " "brc", .BI "chtype " "horz", .BI "chtype " "vert", .BI "chtype " "attr"); .TP 15 .B "void drawObjBox (" .BI "WINDOW *" "win", .BI "CDKOBJS *" "object"); .TP 15 .B "void drawLine (" .BI "WINDOW *" "window", .BI "int " "startx", .BI "int " "starty", .BI "int " "endx", .BI "int " "endy", .BI "chtype " "line"); .TP 15 .B "void drawShadow (" .BI "WINDOW *" "shadowWin"); .TP 15 .B "void writeBlanks (" .BI "WINDOW *" "window", .BI "int " "xpos", .BI "int " "ypos", .BI "int " "align", .BI "int " "start", .BI "int " "end"); .TP 15 .B "void writeChar (" .BI "WINDOW *" "window", .BI "int " "xpos", .BI "int " "ypos", .BI "char *" "string", .BI "int " "align", .BI "int " "start", .BI "int " "end"); .TP 15 .B "void writeCharAttrib (" .BI "WINDOW *" "window", .BI "int " "xpos", .BI "int " "ypos", .BI "char *" "string", .BI "chtype " "attr", .BI "int " "align", .BI "int " "start", .BI "int " "end"); .TP 15 .B "void writeChtype (" .BI "WINDOW *" "window", .BI "int " "xpos", .BI "int " "ypos", .BI "chtype *" "string", .BI "int " "align", .BI "int " "start", .BI "int " "end"); .TP 15 .B "void writeChtypeAttrib (" .BI "WINDOW *" "window", .BI "int " "xpos", .BI "int " "ypos", .BI "chtype *" "string", .BI "chtype " "attr", .BI "int " "align", .BI "int " "start", .BI "int " "end"); .fi .SH DESCRIPTION These functions perform useful drawing and attribute operations. .SH AVAILABLE FUNCTIONS .TP 5 .B boxWindow draw a box with on the window \fIwin\fP. Like \fBattrbox\fP, this function ORs \fIattr\fP with each character as it draws the box. .TP 5 .B attrbox draw a box with on the window \fIwin\fP letting the caller define each element of the box. .IP The parameters \fItlc\fP, \fItrc\fP, \fIblc\fP, \fIbrc\fP are used for the top-left, top-right, bottom-left and bottom-right corners respectively. The parameters \fIhorz\fP and \fIvert\fP are used for the horizontal and vertical sides of the box. Any of these parameters may be zero. In that case, the function skips the corresponding element of the box. .IP The function ORs \fIattr\fP with each character as it draws the box. .TP 5 .B drawObjBox Draw a box around the given window \fIwin\fP using the \fIobject\fP's defined line-drawing characters. .TP 5 .B drawLine draw a line on the given window. .IP The parameters \fIstarty\fP, \fIstartx\fP are the starting coordinates. The parameters \fIendy\fP, \fIendx\fP are the ending coordinates. The function writes the data in \fIline\fP to each coordinate in that range including the start/end coordinates. .IP The function handles lines other than vertical or horizontal, but normally it is used for that, e.g., with \fIline\fP set to \fBACS_HLINE\fP or \fBACS_VLINE\fP. .TP 5 .B drawShadow draw a shadow on the right and bottom edges of a window. .TP 5 .B writeBlanks write a string of blanks, using \fBwriteChar\fP. The parameters are passed to \fBwriteChar\fP as is. There is no corresponding \fBwriteBlanksAttrib\fP function. .TP 5 .B writeChar writes out a \fBchar\ *\fP string without adding attributes. The parameters are passed to \fBwriteCharAttrib\fP as is. .TP 5 .B writeCharAttrib writes out a \fBchar\ *\fP string with the given attributes added. The string is written to the given \fIwindow\fP, using its relative screen coordinates \fIypos\fP and \fIxpos\fP. Compare with \fBwriteChtypeAttrib\fP, which writes a \fBchtype\ *\fP string. .IP The function ORs the attribute \fIattr\fP with each item from the string. For instance, it may be \fBA_BOLD\fP. The \fIalign\fP parameter controls whether it is written horizontally (\fBHORIZONTAL\fP) or vertically (\fBVERTICAL\fP). .IP Finally, only a subset of the string is written, i.e., from indices \fIstart\fP to \fIend\fP. .TP 5 .B writeChtype writes out a \fBchtype\ *\fP string without adding attributes. The parameters are passed to \fBwriteChtypeAttrib\fP as is. .TP 5 .B writeChtypeAttrib writes out a \fIchtype\ *\fP string with the given attributes added. The string is written to the given \fIwindow\fP, using its relative screen coordinates \fIypos\fP and \fIxpos\fP. You would normally construct the string from a \fIchar\ *\fP string using \fBchar2Chtype\fP (3). .IP The function ORs the attribute \fIattr\fP with each item from the string. For instance, it may be \fBA_BOLD\fP. The \fIalign\fP parameter controls whether it is written horizontally (\fBHORIZONTAL\fP) or vertically (\fBVERTICAL\fP). .IP Finally, only a subset of the string is written, i.e., from indices \fIstart\fP to \fIend\fP. . .SH SEE ALSO .BR cdk (3), .BR cdk_util (3) cdk-5.0-20060507/man/cdk_entry.30000644000175100001440000003441410420177021014360 0ustar tomusers'\" t .\" $Id: cdk_entry.3,v 1.23 2006/04/15 14:07:13 tom Exp $ .de XX .. .TH cdk_entry 3 .SH NAME .XX activateCDKEntry .XX cleanCDKEntry .XX destroyCDKEntry .XX drawCDKEntry .XX eraseCDKEntry .XX getCDKEntryBox .XX getCDKEntryFillerChar .XX getCDKEntryHiddenChar .XX getCDKEntryMax .XX getCDKEntryMin .XX getCDKEntryValue .XX injectCDKEntry .XX moveCDKEntry .XX newCDKEntry .XX positionCDKEntry .XX setCDKEntry .XX setCDKEntryBackgroundAttrib .XX setCDKEntryBackgroundColor .XX setCDKEntryBox .XX setCDKEntryBoxAttribute .XX setCDKEntryCB .XX setCDKEntryFillerChar .XX setCDKEntryHiddenChar .XX setCDKEntryHighlight .XX setCDKEntryHorizontalChar .XX setCDKEntryLLChar .XX setCDKEntryLRChar .XX setCDKEntryMax .XX setCDKEntryMin .XX setCDKEntryPostProcess .XX setCDKEntryPreProcess .XX setCDKEntryULChar .XX setCDKEntryURChar .XX setCDKEntryValue .XX setCDKEntryVerticalChar cdk_entry \- curses text-entry widget. .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "char *activateCDKEntry (" .BI "CDKENTRY *" "entry", .BI "chtype *" "actions"); .TP 15 .B "void cleanCDKEntry (" .BI "CDKENTRY *" "entry"); .TP 15 .B "void destroyCDKEntry (" .BI "CDKENTRY *" "entry"); .TP 15 .B "void drawCDKEntry (" .BI "CDKENTRY *" "entry", .BI "boolean " "box"); .TP 15 .B "void eraseCDKEntry (" .BI "CDKENTRY *" "entry"); .TP 15 .B "boolean getCDKEntryBox (" .BI "CDKENTRY *" "entry"); .TP 15 .B "chtype getCDKEntryFillerChar (" .BI "CDKENTRY *" "entry"); .TP 15 .B "chtype getCDKEntryHiddenChar (" .BI "CDKENTRY *" "entry"); .TP 15 .B "int getCDKEntryMax (" .BI "CDKENTRY *" "entry"); .TP 15 .B "int getCDKEntryMin (" .BI "CDKENTRY *" "entry"); .TP 15 .B "char *getCDKEntryValue (" .BI "CDKENTRY *" "entry"); .TP 15 .B "int injectCDKEntry (" .BI "CDKENTRY *" "entry", .BI "chtype " "input"); .TP 15 .B "void moveCDKEntry (" .BI "CDKENTRY *" "entry", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKENTRY *newCDKEntry (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "char *" "title", .BI "char *" "label", .BI "chtype " "fieldAttribute", .BI "chtype " "fillerCharacter", .BI "EDisplayType " "displayType", .BI "int " "fieldWidth", .BI "int " "minimumLength", .BI "int " "maximumLength", .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKEntry (" .BI "CDKENTRY *" "entry"); .TP 15 .B "void setCDKEntry (" .BI "CDKENTRY *" "entry", .BI "char *" "value", .BI "int " "minimumLength", .BI "int " "maximumLength", .BI "boolean " "box"); .TP 15 .B "void setCDKEntryBackgroundAttrib (" .BI "CDKENTRY *" "entry", .BI "chtype " "attribute"); .TP 15 .B "void setCDKEntryBackgroundColor (" .BI "CDKENTRY *" "entry", .BI "char * " "color"); .TP 15 .B "void setCDKEntryBox (" .BI "CDKENTRY *" "entry", .BI "boolean " "box"); .TP 15 .B "void setCDKEntryBoxAttribute (" .BI "CDKENTRY *" "entry", .BI "chtype " "character"); .TP 15 .B "void setCDKEntryCB (" .BI "CDKENTRY *" "entry", .BI "ENTRYCB " "callBackFunction"); .TP 15 .B "void setCDKEntryFillerChar (" .BI "CDKENTRY *" "entry", .BI "chtype " "character"); .TP 15 .B "void setCDKEntryHiddenChar (" .BI "CDKENTRY *" "entry", .BI "chtype " "character"); .TP 15 .B "void setCDKEntryHighlight (" .BI "CDKENTRY *" "entry", .BI "chtype " "highlight", .BI "boolean " "cursor"); .TP 15 .B "void setCDKEntryHorizontalChar (" .BI "CDKENTRY *" "entry", .BI "chtype " "character"); .TP 15 .B "void setCDKEntryLLChar (" .BI "CDKENTRY *" "entry", .BI "chtype " "character"); .TP 15 .B "void setCDKEntryLRChar (" .BI "CDKENTRY *" "entry", .BI "chtype " "character"); .TP 15 .B "void setCDKEntryMax (" .BI "CDKENTRY *" "entry", .BI "int " "maximum"); .TP 15 .B "void setCDKEntryMin (" .BI "CDKENTRY *" "entry", .BI "int " "minimum"); .TP 15 .B "void setCDKEntryPostProcess (" .BI "CDKENTRY *" "entry", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKEntryPreProcess (" .BI "CDKENTRY *" "entry", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKEntryULChar (" .BI "CDKENTRY *" "entry", .BI "chtype " "character"); .TP 15 .B "void setCDKEntryURChar (" .BI "CDKENTRY *" "entry", .BI "chtype " "character"); .TP 15 .B "void setCDKEntryValue (" .BI "CDKENTRY *" "entry", .BI "char *" "value"); .TP 15 .B "void setCDKEntryVerticalChar (" .BI "CDKENTRY *" "entry", .BI "chtype " "character"); .fi .SH DESCRIPTION The Cdk entry widget creates a text-entry box with a label and an entry field. The following functions create or manipulate the Cdk entry box widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKEntry activates the entry widget and lets the user interact with the widget. The parameter \fBentry\fR is a pointer to a non-NULL entry widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a \fIchar *\fR representing the information typed into the widget and the widget data \fIexitType\fR will be set to \fIvNORMAL\fR. If the character entered was \fIESCAPE\fR then the function will return \fINULL\fR pointer and the widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP 5 .B cleanCDKEntry clears the information from the field. .TP 5 .B destroyCDKEntry removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKEntry draws the entry widget on the screen. If the \fBbox\fR parameter is true, the widget is drawn with a box. .TP 5 .B eraseCDKEntry removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKEntryBox returns true if the widget will be drawn with a box around it. .TP 5 .B getCDKEntryFillerChar returns the character being used to draw unused space in the widget. .TP 5 .B getCDKEntryHiddenChar returns the character being used to draw the hidden character type. .TP 5 .B getCDKEntryMax returns the maximum length of a string the widget will allow. .TP 5 .B getCDKEntryMin returns the minimum length of a string the widget will allow. .TP 5 .B getCDKEntryValue returns the current value of the widget. .TP 5 .B injectCDKEntry injects a single character into the widget. The parameter \fBentry\fR is a pointer to a non-NULL entry widget. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR the function returns a \fIchar *\fR representing the information typed into the widget. The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns a \fINULL\fR pointer. The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns a \fINULL\fR pointer. The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .TP 5 .B moveCDKEntry moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDKEntry creates a pointer to an entry widget. Parameters: .RS .TP 5 The \fBscreen\fR parameter is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBtitle\fR is the string which will be displayed at the top of the widget. The title can be more than one line; just provide a carriage return character at the line break. .TP 5 \fBlabel\fR is the string which will be displayed in the label of the entry field. .TP 5 \fBfieldAttribute\fR is the attribute of the characters which are typed in. .TP 5 \fBfiller\fR is the character which is to be displayed in an empty space in the entry field. .TP 5 \fBdisplayType\fR tells how the entry field will behave when a character is entered into the field. See \fBcdk_display (3)\fR for valid values for this field. .TP 5 \fBfieldWidth\fR denotes the width of the field. If a value of zero is provided, the field will be made as wide as possible on the screen. If a negative value is given, then the field width will be the maximum width minus the value provided. .TP 5 \fBminimumLength\fR controls the number of characters which must be entered before the user can exit the entry field. .TP 5 \fBmaximumLength\fR sets the maximum number of characters that can be entered. .TP 5 \fBbox\fR is true if the widget should be drawn with a box around it. .TP 5 \fBshadow\fR turns the shadow on around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKEntry allows the user to move the widget around the screen via the cursor/keypad keys. The following key bindings can be used to move the widget around the screen. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDKEntry lets the programmer modify certain elements of an existing entry widget. The \fBvalue\fR parameter sets the value of the contents of the entry field. The other parameter names correspond to the same parameter names listed in the \fBnewCDKEntry\fR function. .TP 5 .B setCDKEntryBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKEntryBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .TP 5 .B setCDKEntryBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKEntryBoxAttribute function sets the attribute of the box. .TP 5 .B setCDKEntryCB allows the programmer to set a different widget input handler. The parameter \fBcallbackFunction\fR is of type \fIENTRYCB\fR. The default function is \fICDKEntryCallBack\fR. .TP 5 .B setCDKEntryFillerChar sets the character to use when drawing unused space in the field. .TP 5 .B setCDKEntryHiddenChar sets the character to use when using a hidden character type. .TP 5 .B setCDKEntryHighlight sets the attribute of the entry field. .TP 5 .B setCDKEntryHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKEntryLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKEntryLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKEntryMax sets the maximum length of the string that the widget will allow. .TP 5 .B setCDKEntryMin sets the minimum length of the string that the widget will allow. .TP 5 .B setCDKEntryPostProcess allows the user to have the widget call a function after the key has been applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about post-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKEntryPreProcess allows the user to have the widget call a function after a key is hit and before the key is applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about pre-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKEntryULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKEntryURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKEntryValue sets the current value of the widget. .TP 5 .B setCDKEntryVerticalChar sets the vertical drawing character for the box to the given character. .SH KEY BINDINGS When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. The following table outlines the keys and their actions for this widget. .LP .TS center tab(/); l l lw15 lw35 . \fBKey/Action\fR = Left Arrow/Moves the cursor to the left. CTRL-B/Moves the cursor to the left. Right Arrow/Moves the cursor to the right. CTRL-F/Moves the cursor to the right. Delete/Deletes the character at the cursor. Backspace/Deletes the character before cursor, moves cursor left. CTRL-V/T{ Pastes whatever is in the paste buffer, into the widget. T} CTRL-X/T{ Cuts the contents from the widget and saves a copy in the paste buffer. T} CTRL-Y/T{ Copies the contents of the widget into the paste buffer. T} CTRL-U/Erases the contents of the widget. CTRL-A/T{ Moves the cursor to the beginning of the entry field. T} CTRL-E/T{ Moves the cursor to the end of the entry field. T} CTRL-T/T{ Transposes the character under the cursor with the character to the right. T} Return/T{ Exits the widget and returns a \fIchar *\fR representing the information which was typed into the field. It also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Tab/T{ Exits the widget and returns a \fIchar *\fR representing the information which was typed into the field. It also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Escape/T{ Exits the widget and returns a \fINULL\fR pointer. It also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR. T} Ctrl-L/Refreshes the screen. = .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_process (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_matrix.30000644000175100001440000003633410420177330014531 0ustar tomusers'\" t .\" $Id: cdk_matrix.3,v 1.24 2006/04/15 14:10:32 tom Exp $ .de XX .. .TH cdk_matrix 3 .SH NAME .XX activateCDKMatrix .XX cleanCDKMatrix .XX cleanCDKMatrixCell .XX destroyCDKMatrix .XX drawCDKMatrix .XX eraseCDKMatrix .XX getCDKMatrixBox .XX getCDKMatrixCell .XX getCDKMatrixCol .XX getCDKMatrixRow .XX injectCDKMatrix .XX jumpToCell .XX moveToCDKMatrixCell .XX newCDKMatrix .XX setCDKMatrix .XX setCDKMatrixBackgroundAttrib .XX setCDKMatrixBackgroundColor .XX setCDKMatrixBox .XX setCDKMatrixBoxAttribute .XX setCDKMatrixCB .XX setCDKMatrixCell .XX setCDKMatrixCells .XX setCDKMatrixHorizontalChar .XX setCDKMatrixLLChar .XX setCDKMatrixLRChar .XX setCDKMatrixPostProcess .XX setCDKMatrixPreProcess .XX setCDKMatrixULChar .XX setCDKMatrixURChar .XX setCDKMatrixVerticalChar cdk_matrix \- curses matrix widget. .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "int activateCDKMatrix (" .BI "CDKMATRIX *" "matrix", .BI "chtype * " "actions"); .TP 15 .B "void cleanCDKMatrix (" .BI "CDKMATRIX *" "matrix"); .TP .B "void cleanCDKMatrixCell (" .BI "CDKMATRIX *" "matrix", .BI "int " "row", .BI "int " "col"); .TP 15 .B "void destroyCDKMatrix (" .BI "CDKMATRIX *" "matrix"); .TP 15 .B "void drawCDKMatrix (" .BI "CDKMATRIX *" "matrix", .BI "boolean " "box"); .TP 15 .B "void eraseCDKMatrix (" .BI "CDKMATRIX *" "matrix"); .TP 15 .B "boolean getCDKMatrixBox (" .BI "CDKMENTRY *" "matrix"); .TP 15 .B "char * getCDKMatrixCell (" .BI "CDKMATRIX *" "matrix", .BI "int " "row", .BI "int " "col"); .TP 15 .B "int getCDKMatrixCol (" .BI "CDKMENTRY *" "matrix"); .TP 15 .B "int getCDKMatrixRow (" .BI "CDKMENTRY *" "matrix"); .TP 15 .B "int injectCDKMatrix (" .BI "CDKMATRIX *" "matrix", .BI "chtype " "input"); .TP 15 .B "int jumpToCell (" .BI "CDKMATRIX *" "matrix", .BI "int " "row", .BI "int " "col"); .TP 15 .B "void moveCDKMatrix (" .BI "CDKMATRIX *" "matrix", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "int moveToCDKMatrixCell (" .BI "CDKMATRIX *" "matrix", .BI "int " "row", .BI "int " "col"); .TP 15 .B "CDKMATRIX *newCDKMatrix (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "int " "screenRows", .BI "int " "screenCols", .BI "int " "actualRows", .BI "int " "actualCols", .BI "char *" "title", .BI "char **" "rowTitles", .BI "char **" "colTitles", .BI "int *" "columnWidths", .BI "int *" "columnTypes", .BI "int " "rowSpace", .BI "int " "colSpace", .BI "chtype " "filler", .BI "int " "dominantAttribute", .BI "boolean " "boxMatrix", .BI "boolean " "boxCell", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKMatrix (" .BI "CDKMATRIX *" "matrix"); .TP 15 .B "void setCDKMatrix (" .BI "CDKMATRIX *" "matrix", .BI "char *" "info"[MAX_MATRIX_ROWS][MAX_MATRIX_COLS], .BI "int " "rows", .BI "int *" "columnLengths"); .TP 15 .B "void setCDKMatrixBackgroundAttrib (" .BI "CDKMATRIX *" "matrix", .BI "chtype " "attribute"); .TP 15 .B "void setCDKMatrixBackgroundColor (" .BI "CDKMATRIX *" "matrix", .BI "char * " "color"); .TP 15 .B "void setCDKMatrixBox (" .BI "CDKMENTRY *" "matrix", .BI "boolean " "boxWidget"); .TP 15 .B "void setCDKMatrixBoxAttribute (" .BI "CDKMATRIX *" "matrix", .BI "chtype " "character"); .TP 15 .B "void setCDKMatrixCB (" .BI "CDKMATRIX *" "matrix", .BI "MATRIXCB " "callbackFunction"); .TP 15 .B "int setCDKMatrixCell (" .BI "CDKMATRIX *" "matrix", .BI "int " "row", .BI "int " "col", .BI "char *" "value"); .B "void setCDKMatrixCells (" .BI "CDKMATRIX *" "matrix", .BI "char **" "info", .BI "int " "rows", .BI "int " "cols", .BI "int *" "columnLengths"); .TP 15 .B "void setCDKMatrixHorizontalChar (" .BI "CDKMATRIX *" "matrix", .BI "chtype " "character"); .TP 15 .B "void setCDKMatrixLLChar (" .BI "CDKMATRIX *" "matrix", .BI "chtype " "character"); .TP 15 .B "void setCDKMatrixLRChar (" .BI "CDKMATRIX *" "matrix", .BI "chtype " "character"); .TP 15 .B "void setCDKMatrixPostProcess (" .BI "CDKMATRIX *" "matrix", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKMatrixPreProcess (" .BI "CDKMATRIX *" "matrix", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKMatrixULChar (" .BI "CDKMATRIX *" "matrix", .BI "chtype " "character"); .TP 15 .B "void setCDKMatrixURChar (" .BI "CDKMATRIX *" "matrix", .BI "chtype " "character"); .TP 15 .B "void setCDKMatrixVerticalChar (" .BI "CDKMATRIX *" "matrix", .BI "chtype " "character"); .fi .SH DESCRIPTION The Cdk matrix widget creates a matrix widget. The following are functions which create or manipulate the Cdk matrix box widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKMatrix activates the matrix widget and lets the user interact with the widget. The parameter \fBmatrix\fR is a pointer to a non-NULL matrix widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR then this function will return 1. It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR. If the character entered into this widget was \fIESCAPE\fR then the widget will return a value of -1 and the widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR. The matrix cell contents can be retrieved by using the \fBinfo\fR array of the matrix widget. .TP 5 .B cleanCDKMatrix clears the information from all cells of the matrix. .TP .B cleanCDKMatrixCell clears the information from the specified cell of the matrix. .TP 5 .B destroyCDKMatrix removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKMatrix draws the matrix widget on the screen. If the \fBbox\fR parameter is true, the widget is drawn with a box. .TP 5 .B eraseCDKMatrix removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKMatrixBox returns true if the widget will be drawn with a box around it. .TP 5 .B getCDKMatrixCell returns the contents of the cell located by the \fBrow\fR and \fBcol\fR pair. .TP 5 .B getCDKMatrixCol returns the current column index. .TP 5 .B getCDKMatrixRow returns the current row index. .TP 5 .B injectCDKMatrix injects a single character into the widget. The parameter \fBmatrix\fR is a pointer to a non-NULL matrix widget. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR the function returns 1. The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns -1. The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns -1. The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .IP The matrix cell contents can be retrieved by using the \fBinfo\fR array of the matrix widget. .TP 5 .B jumpToCell provides an interactive method of moving to a cell. It pops up a scale widget and asks which cell the user wants to go to. Then it performs the jump. .TP 5 .B moveCDKMatrix moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B moveToCDKMatrixCell jumps to the given cells dictated by the parameters \fBrow\fR and \fBcol\fR. It returns a value of \fITRUE\fR or \fIFALSE\fR depending if the move was successful. .TP 5 .B newCDKMatrix creates a matrix widget and returns a pointer to it. Parameters: .RS .TP 5 \fBscreen\fR is the screen you wish this widget to be placed in. .TP 5 \fBxpos\fR controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. It may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBscreenRows\fR and .TP 5 \fBscreenCols\fR are the number of rows and columns to be displayed on the screen respectively. .TP 5 \fBactualRows\fR and .TP 5 \fBactualCols\fR are the number of actual rows and columns the matrix has. .TP 5 \fBtitle\fR is the string which will be displayed at the top of the widget. The title can be more than one line; just provide a carriage return character at the line break. .TP 5 \fBrowTitles\fR and .TP 5 \fBcolTitles\fR are the titles along the row and columns respectively. .TP 5 \fBcolumnWidths\fR is an array of integers stating how wide the individual columns are to be. .TP 5 \fBcolumnTypes\fR is an array of integers which correspond to the individual column display types. The values of the array should be assigned a value of type \fIEDisplayType\fR. See \fBcdk_display (3)\fR for legal values of \fIEDisplayType\fR. .TP 5 \fBrowSpace\fR and .TP 5 \fBcolSpace\fR dictate how much white space is to be between rows and columns respectively. .TP 5 \fBfiller\fR is the character to use in empty space within a cell. .TP 5 \fBdominantAttribute\fR states which (the rows or the columns) will have the dominant character attributes. This is stated when a cell has both a row attribute and a column attribute. If the value of the parameter \fBdominantAttribute\fR is set to \fBROW\fR then the attribute of the row will be displayed. If it is set to \fBCOL\fR then the column's attributes will be displayed instead. .TP 5 \fBboxMatrix\fR is true if the widget should be drawn with a box around it. .TP 5 \fBboxCell\fR is true if the individual cells should have boxes drawn around them. .TP 5 \fBshadow\fR turns the shadow on or off around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKMatrix allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDKMatrix lets the programmer modify certain elements of an existing matrix widget. The parameter \fBinfo\fR is an array of \fIchar *\fR which contains the cell information. The parameter \fBrows\fR has the number of rows the parameter \fBinfo\fR contains, while \fBcolumnLengths\fR has the lengths of the individual columns in \fBinfo\fR. .IP Do not use this function. It is obsolete, provided only for compatibility with older versions of CDK. Use \fBsetCDKMatrixCells\fP. .TP 5 .B setCDKMatrixBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKMatrixBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .TP 5 .B setCDKMatrixBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKMatrixBoxAttribute sets the attribute of the box. .TP 5 .B setCDKMatrixCB allows the programmer to set a different widget input handler. The parameter \fBcallbackFunction\fR is of type \fIMATRIXCB\fR. The default function is \fICDKMatrixCallBack\fR. .TP 5 .B setCDKMatrixCell sets the contents of the cell located by the \fBrow\fR and \fBcol\fR pair. The value of the cell will be set to \fBvalue\fR. .TP .B setCDKMatrixCells, lets the programmer initialize elements of an existing matrix widget. The parameter \fBinfo\fR is an array of \fIchar *\fR which contains the cell information. The parameter \fBrows\fR has the number of rows The parameter \fBcols\fR has the number of columns the parameter \fBinfo\fR contains, while \fBcolumnLengths\fR has the lengths of the individual columns in \fBinfo\fR. .TP 5 .B setCDKMatrixHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKMatrixLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKMatrixLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKMatrixPostProcess allows the user to have the widget call a function after the key has been applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about post-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKMatrixPreProcess allows the user to have the widget call a function after a key is hit and before the key is applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about pre-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKMatrixULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKMatrixURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKMatrixVerticalChar sets the vertical drawing character for the box to the given character. .SH KEY BINDINGS When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. The following table outlines the keys and their actions for this widget. .TS center tab(/) box; l l l l lw15 lw35 . \fBKey/Action\fR = Left Arrow/Moves one cell to the left. Right Arrow/Moves the cell to the right. Tab/Moves the cell to the right. Up Arrow/Moves one cell up. Down Arrow/Moves one cell down. Next Page/Moves one page forward. Ctrl-F/Moves one page forward. Prev Page/Moves one page backward. Ctrl-B/Moves one page backward. Ctrl-G/T{ Calls the function \fBjumpToCell\fR and requests which cell the user wishes to jump to. T} Ctrl-P/T{ Pastes whatever is in the paste buffer, into the current cell. T} Ctrl-K/T{ Cuts the contents from the current cell and saves a copy in the paste buffer. T} Ctrl-T/T{ Copies the contents of the current cell into the paste buffer. T} Ctrl-E/Erases the contents of the current cell. Delete/T{ Deletes the character before the cursor, moves cursor left. There is no function to delete the character at the cursor since there are no functions for moving the cursor within the edited text. T} Backspace/T{ Deletes the character before cursor, moves cursor left. T} Ctrl-H/Deletes the character before the cursor. Return/T{ Exits the widget and returns 1. This also sets the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Escape/T{ Exits the widget and returns -1. This also sets the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR. T} Ctrl-L/Refreshes the screen. .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_display.30000644000175100001440000002513610420670656014701 0ustar tomusers'\" t .\" $Id: cdk_display.3,v 1.11 2006/04/17 10:45:02 tom Exp $ .de It .br .ie \\n(.$>=3 .ne \\$3 .el .ne 3 .IP "\\$1" \\$2 .. .TH cdk_display 3 .SH NAME cdk_display - \fBCurses Development Kit\fR Display Capabilities. .SH SYNOPSIS Cdk has a number of pre-defined display types. The following are outlined in this manual page: .It "\(bu How To Use Colors" 5 .It "\(bu How To Use Different Character Attributes" 5 .It "\(bu How To Justify Strings" 5 .It "\(bu How To Use Special Drawing Characters" 5 .It "\(bu Edit/Display Type Codes (EDisplayType)" 5 .SH DESCRIPTION Cdk has special formatting commands which can be included in any string which add highlights, justification, or even colors to a basic string. These attributes, once set, remain in effect until changed explicitly, or until the end of the string. .LP This manual page outlines and demonstrates how they work. . .SS How To Use Colors Cdk has the capability to display colors in almost every string type displayed in a Cdk widget. To turn on colors, the function \fBinitCDKColor\fR has to be called. When this function is called 64 color pairs are created. Normally the color pairs are accessed via the COLOR_PAIR macro. You can still do this, but creating a string with multiple colors gets terribly difficult. That is why the color commands were created. .LP The color settings are stored directly in the string. When the widget is created or activated, the string is converted to take advantage of any color commands in the string. To turn on a color pair insert into the string; where \fIXX\fR is a numeric value from 0 to 64. Color pair 0 is the standard default color pair for the screen. To turn off a color pair use the format command where \fIXX\fR is a numeric value from 0 to 64. .LP The following example demonstrates the use of the color commands. .ne 10 .sp 1 .nf .ce \fI----------------------------------------\fR #include void main() { CDKSCREEN *cdkscreen; CDKLABEL *demo; WINDOW *screen; char *mesg[4]; /* Initialize the Cdk screen. */ screen = initscr(); cdkscreen = initCDKScreen (screen); /* Set the labels up. */ mesg[0] = "This line should have a yellow foreground and a blue background."; mesg[1] = "This line should have a white foreground and a blue background."; mesg[2] = "This line should have a yellow foreground and a red background."; mesg[3] = "This line should be set to whatever the screen default is."; /* Declare the labels. */ demo = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 4, TRUE, TRUE); /* Draw the label */ drawCDKLabel (demo, TRUE); waitCDKLabel (demo, ' '); /* Clean up */ destroyCDKLabel (demo); destroyCDKScreen (cdkscreen); endCDK(); exit (0); } .fi .ce \fI----------------------------------------\fR .PP . .SS How To Use Different Character Attributes Cdk also provides attribute commands which allow different character attributes to be displayed in a Cdk widget. To use a character attribute the format command is \fI\fR where \fIX\fR is one of several command characters. To turn a attribute off use the command \fI\fR. The following table outlines the command characters: .LP .TS center tab(/) box; l l l l lw15 lw35 . \fBCommand Character/Character Attribute\fR = B/Bold U/Underline K/Blink R/Reverse S/Standout D/Dim N/Normal .TE .LP The following example demonstrates the use of character display attributes. .ne 10 .sp 2 .nf .ce \fI----------------------------------------\fR #include void main() { CDKSCREEN *cdkscreen; CDKLABEL *demo; WINDOW *screen; char *mesg[4]; /* Initialize the Cdk screen. */ screen = initscr(); cdkscreen = initCDKScreen (screen); /* Set the labels up. */ mesg[0] = "Bold text yellow foreground / blue background."; mesg[1] = "Underlined text white foreground / blue background."; mesg[2] = "Blinking text yellow foreground / red background."; mesg[3] = "This line uses the screen default colors."; /* Declare the labels. */ demo = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 4, TRUE, TRUE); /* Draw the label */ drawCDKLabel (demo, TRUE); waitCDKLabel (demo, ' '); /* Clean up */ destroyCDKLabel (demo); destroyCDKScreen (cdkscreen); endCDK(); exit (0); } .ce \fI----------------------------------------\fR .fi .LP Note that color commands and format commands can be mixed inside the same format marker. The above example underlines the label marker, which also sets color pair number 2. . .SS How To Justify Strings Justification commands can left justify, right justify, or center a string of text. To use a justification format in a string the command is used. The following table lists the format commands: .LP .TS center tab(/) box; l l l l lw15 lw35 . \fBCommand/Action.\fR = /Left Justified. Default if not stated. /Centered text. /Right justified. /Indent the line X characters. /Bullet. X is the bullet string to use. /T{ Links in a file where X is the filename. This works only with the viewer widget. T} .TE The following example demonstrates how to use the justification commands in a Cdk widget. .ce \fI----------------------------------------\fR .nf #include void main() { CDKSCREEN *cdkscreen; CDKLABEL *demo; WINDOW *screen; char *mesg[4]; /* Initialize the Cdk screen. */ screen = initscr(); cdkscreen = initCDKScreen (screen); /* Set the labels up. */ mesg[0] = "This line should have a yellow foreground and a blue background."; mesg[1] = "This line should have a white foreground and a blue background."; mesg[2] = "This is a bullet."; mesg[3] = "This is indented 10 characters."; mesg[4] = "This line should be set to whatever the screen default is."; /* Declare the labels. */ demo = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 5, TRUE, TRUE); /* Draw the label */ drawCDKLabel (demo, TRUE); waitCDKLabel (demo, ' '); /* Clean up */ destroyCDKLabel (demo); destroyCDKScreen (cdkscreen); endCDK(); exit (0); } .fi .ce \fI----------------------------------------\fR .PP The bullet format command can take either a single character or a string. The bullet in the above example would look like .RS 3 \fI+\fR This is a bullet. .RE but if we were to use the following command instead .RS 3 This is a bullet. .RE it would look like .RS 3 \fI***\fR This is a bullet. .RE .PP A format command must be at the beginning of the string. . .SS How To Use Special Drawing Characters Cdk has a set of special drawing characters which can be inserted into any ASCII file. In order to use a special character the format command <#XXX> is used. The following table lists all of the special character commands available. .TS center tab(/) box; l l l l lw15 lw35 . \fBSpecial_Character/Character\fR = <#UL>/Upper Left Corner <#UR>/Upper Right Corner <#LL>/Lower Left Corner <#LR>/Lower Right Corner = <#LT>/Left Tee <#RT>/Right Tee <#TT>/Top Tee <#BT>/Bottom Tee = <#HL>/Horizontal Line <#VL>/Vertical Line = <#PL>/Plus Sign <#PM>/Plus or Minus Sign <#DG>/Degree Sign <#CB>/Checker Board <#DI>/Diamond <#BU>/Bullet <#S1>/Scan line 1 <#S9>/Scan line 9 = <#LA>/Left Arrow <#RA>/Right Arrow <#TA>/Top Arrow <#BA>/Bottom Arrow .TE .LP The character formats can be repeated using an optional numeric repeat value. To repeat a character add the repeat count within parentheses to the end of the character format. The following example draws 10 horizontal-line characters: .LP <#HL(10)> .LP The following example draws a box within a label window: .ce \fI----------------------------------------\fR .nf #include "cdk.h" void main() { /* Declare variables. */ CDKSCREEN *cdkscreen; CDKLABEL *demo; WINDOW *cursesWin; char *mesg[4]; /* Set up CDK */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Colors */ initCDKColor(); /* Set the labels up. */ mesg[0] = "<#UL><#HL(25)><#UR>"; mesg[1] = "<#VL>This text should be boxed.<#VL>"; mesg[2] = "<#LL><#HL(25)><#LR>"; mesg[3] = "While this is not."; /* Declare the labels. */ demo = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 4, TRUE, TRUE); /* Is the label NULL??? */ if (demo == (CDKLABEL *)NULL) { /* Clean up the memory. */ destroyCDKScreen (cdkscreen); /* End curses... */ endCDK(); /* Spit out a message. */ printf ("Oops. Can't seem to create the label. Is the window too small?\\n"); exit (1); } /* Draw the CDK screen. */ refreshCDKScreen (cdkscreen); waitCDKLabel (demo, ' '); /* Clean up */ destroyCDKLabel (demo); destroyCDKScreen (cdkscreen); delwin (cursesWin); endCDK(); exit (0); } .fi .ce \fI----------------------------------------\fR .LP Notice that drawn text can also be justified. .LP . .SS Edit/Display Type Codes (EDisplayType) .TS center tab(/) box; l l l l lw15 lw45 . \fBDisplay_Type/Result\fR = vCHAR/Only accepts alphabetic characters. vLCHAR/T{ Only accepts alphabetic characters. Maps the character to lower case when a character has been accepted. T} vUCHAR/T{ Only accepts alphabetic characters. Maps the character to upper case when a character has been accepted. T} vHCHAR/T{ Only accepts alphabetic characters. Displays a period (\fI.\fR) when a character has been accepted. T} vUHCHAR/T{ Only accepts alphabetic characters. Displays a period (\fI.\fR) and maps the character to upper case when a character has been accepted. T} vLHCHAR/T{ Only accepts alphabetic characters. Displays a period (\fI.\fR) and maps the character to lower case when a character has been accepted. T} vINT/T{ Only accepts numeric characters. T} vHINT/T{ Only accepts numeric characters. Displays a period (\fI.\fR) when a character has been accepted. T} vMIXED/Accepts any character types. vLMIXED/T{ Accepts any character types. Maps the character to lower case when an alphabetic character has been accepted. T} vUMIXED/T{ Accepts any character types. Maps the character to upper case when an alphabetic character has been accepted. T} vHMIXED/T{ Accepts any character types. Displays a period (\fI.\fR) when a character has been accepted. T} vLHMIXED/T{ Accepts any character types. Displays a period (\fI.\fR) and maps the character to lower case when a character has been accepted. T} vUHMIXED/T{ Accepts any character types. Displays a period (\fI.\fR) and maps the character to upper case when a character has been accepted. T} vVIEWONLY/Uneditable field. .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_screen (3) cdk-5.0-20060507/man/cdk_misc.30000644000175100001440000001613510427244345014165 0ustar tomusers'\" t .\" $Id: cdk_misc.3,v 1.16 2006/05/07 01:09:57 tom Exp $ .de XX .. .TH cdk_misc 3 .SH NAME .XX Beep .XX CDKallocStrings .XX CDKcountStrings .XX CDKfreeChtypes .XX CDKfreeStrings .XX CDKsplitString .XX baseName .XX ceilCDK .XX chlen .XX chstrncpy .XX chtype2Char .XX cleanChar .XX cleanChtype .XX cmpStrChstr .XX copyChar .XX copyCharList .XX copyChtype .XX copyChtypeList .XX dirName .XX floorCDK .XX freeChar .XX freeCharList .XX freeChtype .XX freeChtypeList .XX intlen .XX lenCharList .XX lenChtypeList .XX mode2Char .XX searchList .XX sortList cdk_misc - \fBCurses Development Kit\fR Miscellaneous Routines .LP .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "void Beep(void); .TP 15 .B "unsigned CDKallocStrings(" .BI "char ***" "list"/, .BI "char *" "item"/, .BI "unsigned " "length"/, .BI "unsigned " "used"/); .TP 15 .B "unsigned CDKcountStrings (" .BI "char **\fIlist"); .TP 15 .B "void CDKfreeChtypes(" .BI "chtype **" "list"); .TP 15 .B "void CDKfreeStrings (" .BI "char **" "list"); .TP 15 .B "char ** CDKsplitString (" .BI "char *" "string", .BI "int " "splitChar); .TP 15 .B "char * baseName (" .BI "char *" "string"); .TP 15 .B "int ceilCDK(" .BI "double" "value"); .TP 15 .B "int chlen (" .BI "chtype *" "string"); .TP 15 .B "void chstrncpy( .BI "char *" "dest", .BI "chtype *" "src", .BI "int " "maxcount"); .TP 15 .BI "char *chtype2Char (" .BI "chtype *" "string"); .TP 15 .B "void cleanChar (" .BI "char *" "string", .BI "int " "length", .BI "char " "character"); .TP 15 .B "void cleanChtype (" .BI "chtype *" "string", .BI "int " "length", .BI "chtype " "character"); .TP 15 .B "int cmpStrChstr(" .BI "char *" "str", .BI "chtype *" "chstr"); .TP 15 .B "char *copyChar (" .BI "char *" "string"); .TP 15 .B "char **copyCharList (" .BI "char **" "list"); .TP 15 .B "chtype *copyChtype (" .BI "chtype *" "string"); .TP 15 .B "chtype **copyChtypeList (" .BI "chtype **" "list"); .TP 15 .B "char *dirName (" .BI "char *" "filename"); .TP 15 .B "int floorCDK(" .BI "double " "value"); .TP 15 .B "void freeChar (" .BI "char *" "string"); .TP 15 .B "void freeCharList (" .BI "char **" "list", .BI "unsigned " "size"); .TP 15 .B "void freeChtype (" .BI "chtype *" "string"); .TP 15 .B void freeChtypeList (" .BI "chtype **" "list", .BI "unsigned " "size"); .TP 15 .B "int intlen (" .BI "int " "value"); .TP 15 .B "int lenCharList (" .BI "char **" "list"); .TP 15 .B "int lenChtypeList (" .BI "chtype **" "list"); .TP 15 .B "int mode2Char (" .BI "char *" "string", .BI "mode_t " "fileMode"); .TP 15 .B "int searchList (" .BI "char **" "list", .BI "int " "listSize", .BI "char *" "pattern"); .TP 15 .B "void sortList (" .BI "char **" "list", .BI "int " "length"); .fi .SH DESCRIPTION These are miscellaneous functions which may be useful with the Cdk widget set. .SH AVAILABLE FUNCTIONS .TP 5 .B Beep makes an audible beep. The standard curses beep() does not flush the stream, so it will only beep until a force is made. This forces a flush after issuing the beep command. .TP 5 .B CDKallocStrings Add a new string \fIitem\fP to a \fIlist\fP. Keep a null pointer on the end so one may use \fBCDKfreeStrings()\fP to deallocate the whole list. The caller is responsible for updating the \fIlength\fP of the list. The return value is the updated number of chars \fIused\fP. .TP 5 .B CDKcountStrings Count the number of items in a null-terminated \fIlist\fP of character strings. Return the count. .TP 5 .B CDKfreeChtypes Free a \fIlist\fP of chtype-strings which is terminated by a null pointer. .TP 5 .B CDKfreeStrings Free a \fIlist\fP of character strings which is terminated by a null pointer. Also free \fIlist\fR itself. .TP 5 .B CDKsplitString split the \fIstring\fP at each occurrence of \fIseparator\fP, returning a pointer to a dynamically allocated array of the pieces. The original \fIstring\fP is unmodified. The caller is responsible for freeing the result. .TP 5 .B baseName returns a pointer to the first character of the filename in the given pathname. The result should be freed by the caller. .TP 5 .B ceilCDK Return an integer like the math library \fBceil()\fP, which returns a double. .TP 5 .B chlen returns the length of the (null-terminated) \fIstring\fP of chtype's. .TP 5 .B chstrncpy Extract the characters from a null-terminated array of chtype's \fIsrc\fP. The size of the destination \fIdest\fP is given in \fImaxcount\fP. .TP 5 .B chtype2Char Extract the characters from a null-terminated array of chtype's \fIstring\fP. A dynamically allocated string is returned. The caller is responsible for freeing the result. .TP 5 .B cleanChar is analogous to \fImemset\fR. Set the characters in \fIstring\fP to the given \fIcharacter\fP. The length of \fIstring\fP is given by \fIlength\fP. character which will be written. .TP 5 .B cleanChtype is analogous to \fImemset\fR. Set the chtype's in \fIstring\fP to the given \fIcharacter\fP. The length of \fIstring\fP is given by \fIlength\fP. .TP 5 .B cmpStrChstr Compare a char string \fIstr\fP to a chtype string \fIchstr\fP. Return -1, 0 or 1 according to whether \fIstr\fP is less than, equal to to greater than \fIchstr\fP. .TP 5 .B copyChar copies the string passed in. Unlike \fIstrdup\fR this checks to see if the string is NULL before copying. .TP 5 .B copyCharList copies the given list. .TP 5 .B copyChtype function copies the string passed in, analogous to \fBcopyChar\fR, but for chtype strings. .TP 5 .B copyChtypeList copies the given list. .TP 5 .B dirName Returns the directory for the given \fIfilename\fP, i.e., the part before the * last slash. The return value should be freed by the caller. .TP 5 .B floorCDK Return an integer like the math function floor(), which returns a double. .TP 5 .B freeChar is a wrapper for \fIfree\fR. It checks to see if the string is NULL before trying to free the string. .TP 5 .B freeCharList Free the memory used by the given \fIlist\fP of strings. The number of strings to free is given by \fIsize\fP. .TP 5 .B freeChtype is a wrapper for \fIfree\fR, like \fIfreeChar\fR. .TP 5 .B freeChtypeList Free the memory used by the given \fIlist\fP of chtype strings. The number of strings to free is given by \fIsize\fP. .TP 5 .B intlen returns the length of an integer, i.e., the number of characters needed to represent it. .TP 5 .B lenCharList returns the length of the given list. .TP 5 .B lenChtypeList returns the length of the given list. .TP 5 .B mode2Char Given a file protection mode \fIfileMode\fP, store a printable version of the permissions in \fIstring\fP, formatted as if by "ls -l"). Return the corresponding permissions data, i.e., ignoring the file-type bits. .TP 5 .B searchList Search the given \fIlist\fP of \fIlistSize\fP strings for a subset of a word \fIpattern\fP in the given list. Return the index in the list if it is found, or -1 if not found. .TP 5 .B sortList performs a quick sort of the given list. This is a wrapper for qsort, used to sort the \fIlist\fP of strings. The number of strings in \fIlist\fP is given by \fIlength\fP. The list is sorted alphabetically in increasing order. .SH SEE ALSO .BR cdk (3), .BR cdk_screen (3), .BR cdk_display (3), .BR cdk_binding (3), .BR cdk_util (3) cdk-5.0-20060507/man/cdk_scroll.30000644000175100001440000003532610427242006014523 0ustar tomusers'\" t .\" $Id: cdk_scroll.3,v 1.26 2006/05/07 00:49:10 tom Exp $" .de XX .. .TH cdk_scroll 3 .SH NAME .XX activateCDKScroll .XX addCDKScrollItem .XX deleteCDKScrollItem .XX destroyCDKScroll .XX drawCDKScroll .XX eraseCDKScroll .XX getCDKScrollBox .XX getCDKScrollCurrent .XX getCDKScrollCurrentItem .XX getCDKScrollCurrentTop .XX getCDKScrollHighlight .XX getCDKScrollItems .XX injectCDKScroll .XX insertCDKScrollItem .XX moveCDKScroll .XX newCDKScroll .XX positionCDKScroll .XX setCDKScroll .XX setCDKScrollBackgroundAttrib .XX setCDKScrollBackgroundColor .XX setCDKScrollBox .XX setCDKScrollBoxAttribute .XX setCDKScrollCurrent .XX setCDKScrollCurrentItem .XX setCDKScrollCurrentTop .XX setCDKScrollHighlight .XX setCDKScrollHorizontalChar .XX setCDKScrollItems .XX setCDKScrollLLChar .XX setCDKScrollLRChar .XX setCDKScrollPosition .XX setCDKScrollPostProcess .XX setCDKScrollPreProcess .XX setCDKScrollULChar .XX setCDKScrollURChar .XX setCDKScrollVerticalChar cdk_scroll \- curses scrolling list widget. .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lcdk .RI "[ " "library" " \|.\|.\|. ]" .LP #include .nf .TP 15 .B "int activateCDKScroll (" .BI "CDKSCROLL *" "scroll", .BI "chtype * " "actions"); .TP 15 .B "void addCDKScrollItem (" .BI "CDKSCROLL *" "scroll", .BI "char *" "item"); .TP 15 .B "void deleteCDKScrollItem (" .BI "CDKSCROLL *" "scroll", .BI "int " "position"); .TP 15 .B "void destroyCDKScroll (" .BI "CDKSCROLL *" "scroll"); .TP 15 .B "void drawCDKScroll (" .BI "CDKSCROLL *" "scroll", .BI "boolean " "box"); .TP 15 .B "void eraseCDKScroll (" .BI "CDKSCROLL *" "scroll"); .TP 15 .B "boolean getCDKScrollBox (" .BI "CDKSCROLL *" "scroll"); .TP 15 .B "int getCDKScrollCurrent(" .BI "CDKSCROLL *" "scroll"); .TP 15 .B "int getCDKScrollCurrentItem (" .BI "CDKSCROLL *" "widget"); .TP 15 .B "chtype getCDKScrollHighlight (" .BI "CDKSCROLL *" "scroll", .BI "chtype " "highlight"); .TP 15 .B "int getCDKScrollCurrentTop (" .BI "CDKSCROLL *" "widget"); .TP 15 .B "int getCDKScrollItems (" .BI "CDKSCROLL *" "scroll", .BI "char **" "itemList"); .TP 15 .B "int injectCDKScroll (" .BI "CDKSCROLL *" "scroll", .BI "chtype " "input"); .TP 15 .B void insertCDKScrollItem ( .BI "CDKSCROLL *" "scroll", .BI "char *" "item"); .TP 15 .B "void moveCDKScroll (" .BI "CDKSCROLL *" "scroll", .BI "int " "xpos", .BI "int " "ypos", .BI "boolean " "relative", .BI "boolean " "refresh"); .TP 15 .B "CDKSCROLL *newCDKScroll (" .BI "CDKSCREEN *" "cdkscreen", .BI "int " "xpos", .BI "int " "ypos", .BI "int " "spos", .BI "int " "height", .BI "int " "width", .BI "char *" "title", .BI "char **" "itemList", .BI "int " "items", .BI "boolean " "numbers", .BI "chtype " "highlight", .BI "boolean " "box", .BI "boolean " "shadow"); .TP 15 .B "void positionCDKScroll (" .BI "CDKSCROLL *" "scroll"); .TP 15 .B "void setCDKScroll (" .BI "CDKSCROLL *" "scroll", .BI "char **" "itemList", .BI "int " "items", .BI "boolean " "numbers", .BI "chtype " "highlight", .BI "boolean " "box"); .TP 15 .B "void setCDKScrollBackgroundAttrib (" .BI "CDKSCROLL *" "scroll", .BI "chtype " "attribute"); .TP 15 .B "void setCDKScrollBackgroundColor (" .BI "CDKSCROLL *" "scroll", .BI "char * " "color"); .TP 15 .B "void setCDKScrollBox (" .BI "CDKSCROLL *" "scroll", .BI "boolean " "box"); .TP 15 .B "void setCDKScrollBoxAttribute (" .BI "CDKSCROLL *" "scroll", .BI "chtype " "character"); .TP 15 .B "void setCDKScrollCurrent( .BI "CDKSCROLL *" "scroll", .BI "int" "item"); .TP 15 .B "void setCDKScrollCurrentItem (" .BI "CDKSCROLL *" "widget", .BI "int" "item"); .TP 15 .B "int getCDKScrollCurrentTop (" .BI "CDKSCROLL *" "widget"); .TP 15 .B "void setCDKScrollHighlight (" .BI "CDKSCROLL *" "scroll", .BI "chtype " "highlight"); .TP 15 .B "void setCDKScrollHorizontalChar (" .BI "CDKSCROLL *" "scroll", .BI "chtype " "character"); .TP 15 .B "void setCDKScrollItems (" .BI "CDKSCROLL *" "scroll", .BI "char **" "itemList", .BI "int " "listSize", .BI "boolean " "numbers"); .TP 15 .B "void setCDKScrollLLChar (" .BI "CDKSCROLL *" "scroll", .BI "chtype " "character"); .TP 15 .B "void setCDKScrollLRChar (" .BI "CDKSCROLL *" "scroll", .BI "chtype " "character"); .TP 15 .B "void setCDKScrollPosition (" .BI "CDKSCROLL *" "scroll", .BI "int" "item"); .TP 15 .B "void setCDKScrollPostProcess (" .BI "CDKSCROLL *" "scroll", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKScrollPreProcess (" .BI "CDKSCROLL *" "scroll", .BI "PROCESSFN " "callback", .BI "void * " "data"); .TP 15 .B "void setCDKScrollULChar (" .BI "CDKSCROLL *" "scroll", .BI "chtype " "character"); .TP 15 .B "void setCDKScrollURChar (" .BI "CDKSCROLL *" "scroll", .BI "chtype " "character"); .TP 15 .B "void setCDKScrollVerticalChar (" .BI "CDKSCROLL *" "scroll", .BI "chtype " "character"); .fi .SH DESCRIPTION The Cdk scroll widget creates a scrolling list. The following are functions which create or manipulate the Cdk scrolling list widget. .SH AVAILABLE FUNCTIONS .TP 5 .B activateCDKScroll activates the scroll widget and lets the user interact with the widget. The parameter \fBscroll\fR points to a non-NULL scroll widget. If the \fBactions\fR parameter is passed with a non-NULL value, the characters in the array will be injected into the widget. To activate the widget interactively pass in a \fINULL\fR pointer for \fBactions\fR. If the character entered into this widget is \fIRETURN\fR or \fITAB\fR then this function will return a value from 0 to the number of items-1, representing the item selected. It will also set the widget data \fIexitType\fR to \fIvNORMAL\fR. If the character entered into this widget was \fIESCAPE\fR then the widget will return a value of -1 and the widget data \fIexitType\fR will be set to \fIvESCAPE_HIT\fR. .TP 5 .B addCDKScrollItem allows the user to add an item into an existing scrolling list. The \fBscroll\fR parameter points to the scrolling list to add the item to. The parameter \fBitem\fR is a \fIchar *\fR representing the new item to add. The item is always added to the end of the list. .TP 5 .B deleteCDKScrollItem allows the user to add an item into an existing scrolling list. The \fBscroll\fR parameter points to the scrolling list to add the item to. The parameter \fBf2position\fR is an \fIint\fR which specifies which element to remove. .TP 5 .B destroyCDKScroll removes the widget from the screen and frees memory the object used. .TP 5 .B drawCDKScroll draws the scroll widget on the screen. If the \fBbox\fR option is true, the widget is drawn with a box. .TP 5 .B eraseCDKScroll removes the widget from the screen. This does \fINOT\fR destroy the widget. .TP 5 .B getCDKScrollBox returns true if the widget will be drawn with a box around it. .TP 5 .B getCDKScrollCurrent returns the current item's index. .TP 5 .B getCDKScrollCurrentItem returns the current item number in the scroller. .TP 5 .B getCDKScrollHighlight returns the attribute of the highlight bar. .TP 5 .B getCDKScrollCurrentTop returns the top line of the scroller, counting from zero. .TP 5 .B getCDKScrollItems fills the parameter \fBitemList\fR with the contents of the scrolling list. It returns the number of elements in the scrolling list. .TP 5 .B injectCDKScroll injects a single character into the widget. The parameter \fBscroll\fR points to a non-NULL scroll widget. The parameter \fBcharacter\fR is the character to inject into the widget. The return value and side-effect (setting the widget data \fIexitType\fP) depend upon the injected character: .RS .TP \fIRETURN\fP or \fITAB\fR the function returns a value ranging from zero to one less than the number of items, representing the item selected. The widget data \fIexitType\fR is set to \fIvNORMAL\fR. .TP \fIESCAPE\fP the function returns -1. The widget data \fIexitType\fR is set to \fIvESCAPE_HIT\fR. .TP Otherwise unless modified by preprocessing, postprocessing or key bindings, the function returns -1. The widget data \fIexitType\fR is set to \fIvEARLY_EXIT\fR. .RE .TP 5 .B insertCDKScrollItem allows the user to add an item into an existing scrolling list. The \fBscroll\fR parameter points to the scrolling list to add the item to. The parameter \fBitem\fR is a \fIchar *\fR representing the new item to add. The item is always added before the current item in the list. .TP 5 .B moveCDKScroll moves the given widget to the given position. The parameters \fBxpos\fR and \fBypos\fR are the new position of the widget. The parameter \fBxpos\fR may be an integer or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. The parameter \fBypos\fR may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. The parameter \fBrelative\fR states whether the \fBxpos\fR/\fBypos\fR pair is a relative move or an absolute move. For example, if \fBxpos\fR = 1 and \fBypos\fR = 2 and \fBrelative\fR = \fBTRUE\fR, then the widget would move one row down and two columns right. If the value of \fBrelative\fR was \fBFALSE\fR then the widget would move to the position (1,2). Do not use the values \fITOP\fR, \fIBOTTOM\fR, \fILEFT\fR, \fIRIGHT\fR, or \fICENTER\fR when \fBrelative\fR = \fITRUE\fR. (weird things may happen). The final parameter \fBrefresh\fR is a boolean value which states whether the widget will get refreshed after the move. .TP 5 .B newCDKScroll creates a scroll widget and returns a pointer to it. Parameters: .RS .TP 5 \fBscreen\fR parameter is the screen you wish this widget to be placed in. The parameter \fBxpos\fR controls the placement of the object along the horizontal axis. This parameter may be an integer or one of the pre-defined values \fILEFT\fR, \fIRIGHT\fR, and \fICENTER\fR. .TP 5 \fBypos\fR controls the placement of the object along the vertical axis. This parameter may be an integer value or one of the pre-defined values \fITOP\fR, \fIBOTTOM\fR, and \fICENTER\fR. .TP 5 \fBspos\fR is where the scroll bar is to be placed. This may be one of three values: .RS .TP 5 \fILEFT\fR, which puts the scroll bar on the left of the scrolling list. .TP 5 \fIRIGHT\fR which puts the scroll bar on the right side of the list, and .TP 5 \fINONE\fR which does not add a scroll bar. .RE .TP 5 \fBheight\fR and .TP 5 \fBwidth\fR control the height and width of the widget. If you provide a value of zero for either of the height or the width, the widget will be created with the full width and height of the screen. If you provide a negative value, the widget will be created the full height or width minus the value provided. .TP 5 \fBtitle\fR is the string which will be displayed at the top of the widget. The title can be more than one line; just provide a carriage return character at the line break. .TP 5 \fBitemList\fR is the list of items to be displayed in the scrolling list. .TP 5 \fBitems\fR is the number of elements in the given list. .TP 5 \fBnumbers\fR is true if you want the items in the list to have a number attached to the front of the list items. .TP 5 \fBhighlight\fR specifies the display attribute of the currently selected item. .TP 5 \fBbox\fR is true if the widget should be drawn with a box around it. .TP 5 \fBshadow\fR is true to turn the shadow on around this widget. .RE .IP If the widget could not be created then a \fINULL\fR pointer is returned. .TP 5 .B positionCDKScroll allows the user to move the widget around the screen via the cursor/keypad keys. See \fBcdk_position (3)\fR for key bindings. .TP 5 .B setCDKScroll lets the programmer modify certain elements of an existing scroll widget. The parameter names correspond to the same parameter names listed in the \fBnewCDKScroll\fR function. .TP 5 .B setCDKScrollBackgroundAttrib sets the background attribute of the widget. The parameter \fBattribute\fR is a curses attribute, e.g., A_BOLD. .TP 5 .B setCDKScrollBackgroundColor sets the background color of the widget. The parameter \fBcolor\fR is in the format of the Cdk format strings. See \fBcdk_display (3)\fR. .TP 5 .B setCDKScrollBox sets whether the widget will be drawn with a box around it. .TP 5 .B setCDKScrollBoxAttribute sets the attribute of the box. .TP 5 .B setCDKScrollCurrent sets the index for the current item. .TP 5 .B setCDKScrollCurrentItem set the current item number in the scroller. .TP 5 .B setCDKScrollCurrentTop set the top line number of the scroller. .TP 5 .B setCDKScrollHighlight sets the attribute of the highlight bar. .TP 5 .B setCDKScrollHorizontalChar sets the horizontal drawing character for the box to the given character. .TP 5 .B setCDKScrollItems sets the contents of the scrolling list. .TP 5 .B setCDKScrollLLChar sets the lower left hand corner of the widget's box to the given character. .TP 5 .B setCDKScrollLRChar sets the lower right hand corner of the widget's box to the given character. .TP 5 .B setCDKScrollPosition sets the current item in the widget to the given position. .TP 5 .B setCDKScrollPostProcess allows the user to have the widget call a function after the key has been applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about post-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKScrollPreProcess allows the user to have the widget call a function after a key is hit and before the key is applied to the widget. The parameter \fBfunction\fR is the callback function. The parameter \fBdata\fR points to data passed to the callback function. To learn more about pre-processing see \fIcdk_process (3)\fR. .TP 5 .B setCDKScrollULChar sets the upper left hand corner of the widget's box to the given character. .TP 5 .B setCDKScrollURChar sets the upper right hand corner of the widget's box to the given character. .TP 5 .B setCDKScrollVerticalChar sets the vertical drawing character for the box to the given character. .SH KEY BINDINGS When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. The following table outlines the keys and their actions for this widget. .LP .TS center tab(/) box; l l l l lw15 lw35 . \fBKey/Action\fR = Left Arrow/Shift the list left one column. Right Arrow/Shift the list right one column. Up Arrow/Select the previous item in the list. Down Arrow/Select the next item in the list. _ Prev Page Ctrl-B/Scroll one page backward. Next Page Ctrl-F/Scroll one page forward. _ 1 < g Home/Move to the first element in the list. _ > G End/Move to the last element in the list. _ $/Shift the list to the far right. |/Shift the list to the far left. _ Return/T{ Exit the widget and return the index of the selected item. Also set the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Tab/T{ Exit the widget and return the index of the selected item. Also set the widget data \fIexitType\fR to \fIvNORMAL\fR. T} Escape/T{ Exit the widget and return -1. Also set the widget data \fIexitType\fR to \fIvESCAPE_HIT\fR. T} Ctrl-L/Refreshes the screen. .TE .SH SEE ALSO .BR cdk (3), .BR cdk_binding (3), .BR cdk_display (3), .BR cdk_position (3), .BR cdk_screen (3) cdk-5.0-20060507/manlinks.sed0000644000175100001440000000546710355360042014062 0ustar tomusers# $Id: manlinks.sed,v 1.6 2005/12/31 01:34:26 tom Exp $ ############################################################################## # Copyright 2000-2002,2005 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. # ############################################################################## # Given a manpage (nroff) as input, writes a list of the names that are # listed in the "NAME" section, i.e., the names that we would like to use # as aliases for the manpage -T.Dickey /^'\\"/d /\.\\"/d /^\.br/d /^\.sp/d /^\.It/d s/^\.XX[ ]\+\([^ ]\+\).*$/\1,/ s/\\f.//g s/[:,]/ /g s/^[ ][ ]*// s/[ ][ ]*$// s/[ ][ ]*/ /g s/\.SH[ ][ ]*/.SH_(/ # /^\.SH_(NAME/,/^\.SH_(SYNOPSIS/{ s/\\-.*/ -/ / -/{ s/ -.*// s/ /\ /g } /^-/{ d } s/ /\ /g s/^\.XX// } /^\.SH_(SYNOPSIS/,/^\.SH_(DESCRIPTION/{ /^\.TS/,/^\.TE/{ d } /^#/d /^[^(]*$/d s/^\([^ (]* [^ (]* [*]*\)//g s/^\([^ (]* [*]*\)//g s/\.SH_(/.SH_/ s/(.*// s/\.SH_/.SH_(/ } /^\.SH_(DESCRIPTION/,${ d } /^\./d /^$/d cdk-5.0-20060507/manlinks.sh0000755000175100001440000000637110354626050013722 0ustar tomusers#! /bin/sh # $Id: manlinks.sh,v 1.5 2005/12/29 00:22:00 tom Exp $ # install/uninstall aliases for one or more manpages, # # Copyright 2002,2005 Thomas Dickey # 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 Thomas Dickey # and contributors. # 4. Neither the name of Thomas Dickey, 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 THOMAS DICKEY 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 THOMAS DICKEY 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. CDPATH= verb=$1 shift srcdir=$1 shift mandir=$1 shift mansect=$1 shift parent=`pwd` script=$srcdir/manlinks.sed for source in $* ; do case $source in #(vi *.orig|*.rej) ;; #(vi *.[0-9]*) cd $parent section=`expr "$source" : '.*\.\([0-9]\)[xm]*'`; aliases= inalias=$source test ! -f $inalias && inalias="$srcdir/$inalias" if test ! -f $inalias ; then echo " .. skipped $source" continue fi aliases=`sed -f $script $inalias | sort -u` suffix=`basename $source | sed -e 's/^[^.]*//'` cd $mandir || exit 1 if test $verb = installing ; then test -n "$aliases" && ( if test "$suffix" = ".$mansect" ; then target=`basename $source` else target=`basename $source $suffix`.$mansect suffix=".$mansect" fi for cf_alias in $aliases do cf_doit=no if test -f $cf_alias${suffix} ; then if ( cmp -s $target $cf_alias${suffix} ) then : else cf_doit=yes fi else cf_doit=yes fi if test $cf_doit = yes ; then echo " ... alias $cf_alias${suffix}" rm -f $cf_alias${suffix} if (ln -s $target $cf_alias${suffix}) ; then : else echo ".so $target" > $cf_alias${suffix} fi fi done ) elif test $verb = removing ; then suffix=".$mansect" test -n "$aliases" && ( for cf_alias in $aliases do echo " ... alias $cf_alias${suffix}" rm -f $cf_alias${suffix} done ) fi ;; esac done exit 0 cdk-5.0-20060507/marquee.c0000644000175100001440000001675110426516000013346 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:27:44 $ * $Revision: 1.77 $ */ DeclareCDKObjects (MARQUEE, Marquee, setCdk, Unknown); /* * This creates a marquee widget. */ CDKMARQUEE *newCDKMarquee (CDKSCREEN *cdkscreen, int xplace, int yplace, int width, boolean Box, boolean shadow) { CDKMARQUEE *widget = 0; int parentWidth = getmaxx (cdkscreen->window); int xpos = xplace; int ypos = yplace; int boxHeight; int boxWidth; if ((widget = newCDKObject (CDKMARQUEE, &my_funcs)) == 0) return (0); setCDKMarqueeBox (widget, Box); boxWidth = setWidgetDimension (parentWidth, width, 0); boxHeight = (BorderOf (widget) * 2) + 1; /* Rejustify the x and y positions if we need to. */ alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight); /* Create the widget pointer. */ ScreenOf (widget) = cdkscreen; widget->parent = cdkscreen->window; widget->win = newwin (boxHeight, boxWidth, ypos, xpos); widget->boxHeight = boxHeight; widget->boxWidth = boxWidth; widget->shadowWin = 0; widget->active = TRUE; widget->width = width; widget->shadow = shadow; /* Is the window null??? */ if (widget->win == 0) { destroyCDKObject (widget); return (0); } /* Do we want a shadow? */ if (shadow) { widget->shadowWin = subwin (cdkscreen->window, boxHeight, boxWidth, ypos + 1, xpos + 1); } keypad (widget->win, TRUE); registerCDKObject (cdkscreen, vMARQUEE, widget); return (widget); } /* * This activates the widget. */ int activateCDKMarquee (CDKMARQUEE *widget, char *mesg, int delay, int repeat, boolean Box) { chtype *message; int mesgLength = 0; int startPos = 0; int firstChar = 0; int lastChar = 1; int repeatCount = 0; int viewSize = 0; int viewLimit; int padding; int x, y, junk, oldcurs; bool firstTime = TRUE; /* Make sure the message has some content. */ if (mesg == 0 || *mesg == '\0') { return (-1); } /* Keep the box info, setting BorderOf () */ setCDKMarqueeBox (widget, Box); padding = (mesg[strlen (mesg) - 1] == ' ') ? 0 : 1; /* Translate the char * to a chtype * */ message = char2Chtype (mesg, &mesgLength, &junk); /* Draw in the widget. */ drawCDKMarquee (widget, ObjOf (widget)->box); viewLimit = widget->width - (2 * BorderOf (widget)); /* Start doing the marquee thing... */ oldcurs = curs_set (0); while (widget->active) { if (firstTime) { firstChar = 0; lastChar = 1; viewSize = lastChar - firstChar; startPos = widget->width - viewSize - BorderOf (widget); firstTime = FALSE; } /* Draw in the characters. */ y = firstChar; for (x = startPos; x < (startPos + viewSize); x++) { chtype ch = (y < mesgLength) ? message[y] : ' '; mvwaddch (widget->win, BorderOf (widget), x, ch); y++; } wrefresh (widget->win); /* Set my variables. */ if (mesgLength < viewLimit) { if (lastChar < (mesgLength + padding)) { lastChar++; viewSize++; startPos = widget->width - viewSize - BorderOf (widget); } else if (startPos > BorderOf (widget)) { /* This means the whole string is visible. */ startPos--; viewSize = mesgLength + padding; } else { /* We have to start chopping the viewSize */ startPos = BorderOf (widget); firstChar++; viewSize--; } } else { if (startPos > BorderOf (widget)) { lastChar++; viewSize++; startPos--; } else if (lastChar < (mesgLength + padding)) { firstChar++; lastChar++; startPos = BorderOf (widget); viewSize = viewLimit; } else { startPos = BorderOf (widget); firstChar++; viewSize--; } } /* OK, lets check if we have to start over. */ if (viewSize <= 0 && firstChar == mesgLength + padding) { /* Check if we repeat a specified number, or loop indefinitely. */ if ((repeat > 0) && (++repeatCount >= repeat)) { break; } /* Time to start over. */ mvwaddch (widget->win, BorderOf (widget), BorderOf (widget), ' '); wrefresh (widget->win); firstTime = TRUE; } /* Now sleep */ napms (delay * 10); } if (oldcurs < 0) oldcurs = 1; curs_set (oldcurs); freeChtype (message); return (0); } /* * This de-activates a marquee widget. */ void deactivateCDKMarquee (CDKMARQUEE *widget) { widget->active = FALSE; } /* * This moves the marquee field to the given location. */ static void _moveCDKMarquee (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDKMARQUEE *widget = (CDKMARQUEE *)object; int currentX = getbegx (widget->win); int currentY = getbegy (widget->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 (widget->win) + xplace; ypos = getbegy (widget->win) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf (widget), &xpos, &ypos, widget->boxWidth, widget->boxHeight); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the window to the new location. */ moveCursesWindow (widget->win, -xdiff, -ydiff); moveCursesWindow (widget->shadowWin, -xdiff, -ydiff); /* Touch the windows so they 'move'. */ refreshCDKWindow (WindowOf (widget)); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDKMarquee (widget, ObjOf (widget)->box); } } /* * This draws the marquee widget on the screen. */ static void _drawCDKMarquee (CDKOBJS *object, boolean Box) { CDKMARQUEE *widget = (CDKMARQUEE *)object; /* Keep the box information. */ ObjOf (widget)->box = Box; /* Do we need to draw a shadow??? */ if (widget->shadowWin != 0) { drawShadow (widget->shadowWin); } /* Box it if needed. */ if (Box) { drawObjBox (widget->win, ObjOf (widget)); } /* Refresh the window. */ wrefresh (widget->win); } /* * This destroys the widget. */ static void _destroyCDKMarquee (CDKOBJS *object) { if (object != 0) { CDKMARQUEE *widget = (CDKMARQUEE *)object; /* Clean up the windows. */ deleteCursesWindow (widget->shadowWin); deleteCursesWindow (widget->win); /* Clean the key bindings. */ cleanCDKObjectBindings (vMARQUEE, widget); /* Unregister this object. */ unregisterCDKObject (vMARQUEE, widget); } } /* * This erases the widget. */ static void _eraseCDKMarquee (CDKOBJS *object) { if (validCDKObject (object)) { CDKMARQUEE *widget = (CDKMARQUEE *)object; eraseCursesWindow (widget->win); eraseCursesWindow (widget->shadowWin); } } /* * This sets the widgets box attribute. */ void setCDKMarqueeBox (CDKMARQUEE *widget, boolean Box) { ObjOf (widget)->box = Box; ObjOf (widget)->borderSize = Box ? 1 : 0; } boolean getCDKMarqueeBox (CDKMARQUEE *widget) { return ObjOf (widget)->box; } /* * This sets the background attribute of the widget. */ static void _setBKattrMarquee (CDKOBJS *object, chtype attrib) { if (object != 0) { CDKMARQUEE *widget = (CDKMARQUEE *)object; wbkgd (widget->win, attrib); } } dummyInject (Marquee) dummyFocus (Marquee) dummyUnfocus (Marquee) dummyRefreshData (Marquee) dummySaveData (Marquee) cdk-5.0-20060507/matrix.c0000644000175100001440000012334610426516000013212 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:27:44 $ * $Revision: 1.179 $ */ /* * Declare file local prototypes. */ static void highlightCDKMatrixCell (CDKMATRIX *matrix); static void CDKMatrixCallBack (CDKMATRIX *matrix, chtype input); static void drawCDKMatrixCell (CDKMATRIX *matrix, int srow, int scol, int vrow, int vcol, chtype attr, boolean Box); static void redrawTitles (CDKMATRIX *matrix, int row, int col); DeclareCDKObjects (MATRIX, Matrix, setCdk, Int); /* * This function creates the matrix widget. */ CDKMATRIX *newCDKMatrix (CDKSCREEN *cdkscreen, int xplace, int yplace, int rows, int cols, int vrows, int vcols, char *title, char **rowtitles, char **coltitles, int *colwidths, int *colvalues, int rspace, int cspace, chtype filler, int dominant, boolean Box, boolean boxCell, boolean shadow) { CDKMATRIX *matrix = 0; int parentWidth = getmaxx (cdkscreen->window); int parentHeight = getmaxy (cdkscreen->window); int boxHeight = 0; int boxWidth = 0; int xpos = xplace; int ypos = yplace; int maxWidth; int maxRowTitleWidth = 0; int rowSpace = MAXIMUM (0, rspace); int colSpace = MAXIMUM (0, cspace); int begx = 0; int begy = 0; int cellWidth = 0; char **temp = 0; int x, y; static const struct { int from; int to; } bindings[] = { { CDK_FORCHAR, KEY_NPAGE }, { CDK_BACKCHAR, KEY_PPAGE }, }; if ((matrix = newCDKObject (CDKMATRIX, &my_funcs)) == 0) { return (0); } setCDKMatrixBox (matrix, Box); /* Make sure that the number of rows/cols/vrows/vcols is not zero. */ if (rows <= 0 || cols <= 0 || vrows <= 0 || vcols <= 0) { destroyCDKObject (matrix); return (0); } #if NEW_CDKMATRIX matrix->cell = typeCallocN (WINDOW *, (rows + 1) * (cols + 1)); matrix->info = typeCallocN (char *, (rows + 1) * (cols + 1)); #endif /* * Make sure the number of virtual cells is not larger than * the physical size. */ vrows = (vrows > rows ? rows : vrows); vcols = (vcols > cols ? cols : vcols); /* * Set these early, since they are used in matrix index computations. */ matrix->rows = rows; matrix->cols = cols; matrix->colwidths = typeCallocN (int, cols + 1); matrix->colvalues = typeCallocN (int, cols + 1); matrix->coltitle = typeCallocN (chtype *, cols + 1); matrix->coltitleLen = typeCallocN (int, cols + 1); matrix->coltitlePos = typeCallocN (int, cols + 1); matrix->rowtitle = typeCallocN (chtype *, rows + 1); matrix->rowtitleLen = typeCallocN (int, rows + 1); matrix->rowtitlePos = typeCallocN (int, rows + 1); /* * Count the number of lines in the title (see setCdkTitle). */ temp = CDKsplitString (title, '\n'); TitleLinesOf (matrix) = CDKcountStrings (temp); CDKfreeStrings (temp); /* Determine the height of the box. */ if (vrows == 1) { boxHeight = 6 + TitleLinesOf (matrix); } else { if (rowSpace == 0) { boxHeight = (6 + TitleLinesOf (matrix) + ((vrows - 1) * 2)); } else { boxHeight = (3 + TitleLinesOf (matrix) + (vrows * 3) + ((vrows - 1) * (rowSpace - 1))); } } /* Determine the maximum row title width */ for (x = 1; x <= rows; x++) { matrix->rowtitle[x] = char2Chtype (rowtitles[x], &matrix->rowtitleLen[x], &matrix->rowtitlePos[x]); maxRowTitleWidth = MAXIMUM (maxRowTitleWidth, matrix->rowtitleLen[x]); } matrix->maxrt = maxRowTitleWidth + 2; /* We need to rejustify the row title cell info. */ for (x = 1; x <= rows; x++) { matrix->rowtitlePos[x] = justifyString (matrix->maxrt, matrix->rowtitleLen[x], matrix->rowtitlePos[x]); } /* Determine the width of the matrix. */ maxWidth = 2 + matrix->maxrt; for (x = 1; x <= vcols; x++) { maxWidth += colwidths[x] + 2 + colSpace; } maxWidth -= (colSpace - 1); boxWidth = MAXIMUM (maxWidth, boxWidth); boxWidth = setCdkTitle (ObjOf (matrix), title, boxWidth); /* * Make sure the dimensions of the window didn't * extend beyond the dimensions of the parent 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); /* Make the pop-up window. */ matrix->win = newwin (boxHeight, boxWidth, ypos, xpos); if (matrix->win == 0) { destroyCDKObject (matrix); return (0); } /* Make the subwindows in the pop-up. */ begx = xpos; begy = ypos + 1 + TitleLinesOf (matrix); /* Make the 'empty' 0x0 cell. */ MATRIX_CELL (matrix, 0, 0) = subwin (matrix->win, 3, matrix->maxrt, begy, begx); begx += matrix->maxrt + 1; /* Make the column titles. */ for (x = 1; x <= vcols; x++) { cellWidth = colwidths[x] + 3; MATRIX_CELL (matrix, 0, x) = subwin (matrix->win, 1, cellWidth, begy, begx); if (MATRIX_CELL (matrix, 0, x) == 0) { destroyCDKObject (matrix); return (0); } begx += cellWidth + colSpace - 1; } begy++; /* Make the main cell body */ for (x = 1; x <= vrows; x++) { /* Make the row titles */ MATRIX_CELL (matrix, x, 0) = subwin (matrix->win, 3, matrix->maxrt, begy, xpos + 1); if (MATRIX_CELL (matrix, x, 0) == 0) { destroyCDKObject (matrix); return (0); } /* Set the start of the x position. */ begx = xpos + matrix->maxrt + 1; /* Make the cells */ for (y = 1; y <= vcols; y++) { cellWidth = colwidths[y] + 3; MATRIX_CELL (matrix, x, y) = subwin (matrix->win, 3, cellWidth, begy, begx); if (MATRIX_CELL (matrix, x, y) == 0) { destroyCDKObject (matrix); return (0); } begx += cellWidth + colSpace - 1; keypad (MATRIX_CELL (matrix, x, y), TRUE); } begy += rowSpace + 2; } keypad (matrix->win, TRUE); /* Copy the titles into the structure. */ for (x = 1; x <= cols; x++) { matrix->coltitle[x] = char2Chtype (coltitles[x], &matrix->coltitleLen[x], &matrix->coltitlePos[x]); matrix->coltitlePos[x] = (BorderOf (matrix) + justifyString (colwidths[x], matrix->coltitleLen[x], matrix->coltitlePos[x])); matrix->colwidths[x] = colwidths[x]; } /* Keep the rest of the info. */ ScreenOf (matrix) = cdkscreen; ObjOf (matrix)->acceptsFocus = TRUE; ObjOf (matrix)->inputWindow = matrix->win; matrix->parent = cdkscreen->window; matrix->vrows = vrows; matrix->vcols = vcols; matrix->boxWidth = boxWidth; matrix->boxHeight = boxHeight; matrix->rowSpace = rowSpace; matrix->colSpace = colSpace; matrix->filler = filler; matrix->dominant = dominant; matrix->row = 1; matrix->col = 1; matrix->crow = 1; matrix->ccol = 1; matrix->trow = 1; matrix->lcol = 1; matrix->oldcrow = 1; matrix->oldccol = 1; matrix->oldvrow = 1; matrix->oldvcol = 1; initExitType (matrix); matrix->boxCell = boxCell; matrix->shadow = shadow; matrix->highlight = A_REVERSE; matrix->callbackfn = CDKMatrixCallBack; /* Make room for the cell information. */ for (x = 1; x <= rows; x++) { for (y = 1; y <= cols; y++) { MATRIX_INFO (matrix, x, y) = typeCallocN (char, (colwidths[y] + 1)); matrix->colvalues[y] = colvalues[y]; matrix->colwidths[y] = colwidths[y]; } } /* Do we want a shadow??? */ if (shadow) { matrix->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1); } /* Setup the key bindings. */ for (x = 0; x < (int)SIZEOF (bindings); ++x) bindCDKObject (vMATRIX, matrix, bindings[x].from, getcCDKBind, (void *)(long)bindings[x].to); /* Register this baby. */ registerCDKObject (cdkscreen, vMATRIX, matrix); /* Return the matrix pointer */ return (matrix); } /* * This activates the matrix. */ int activateCDKMatrix (CDKMATRIX *matrix, chtype *actions) { int ret; /* Draw the matrix */ drawCDKMatrix (matrix, ObjOf (matrix)->box); if (actions == 0) { chtype input = 0; boolean functionKey; for (;;) { ObjOf (matrix)->inputWindow = MATRIX_CELL (matrix, matrix->crow, matrix->ccol); keypad (ObjOf (matrix)->inputWindow, TRUE); input = getchCDKObject (ObjOf (matrix), &functionKey); /* Inject the character into the widget. */ ret = injectCDKMatrix (matrix, input); if (matrix->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 = injectCDKMatrix (matrix, actions[x]); if (matrix->exitType != vEARLY_EXIT) { return ret; } } } /* Set the exit type and exit. */ setExitType (matrix, 0); return -1; } /* * This injects a single character into the matrix widget. */ static int _injectCDKMatrix (CDKOBJS *object, chtype input) { CDKMATRIX *matrix = (CDKMATRIX *)object; int refreshCells = FALSE; int movedCell = FALSE; int charcount = (int)strlen (MATRIX_INFO (matrix, matrix->row, matrix->col)); int ppReturn = 1; int x, y, infolen; int ret = unknownInt; bool complete = FALSE; /* Set the exit type. */ setExitType (matrix, 0); /* Move the cursor to the correct position within the cell. */ if (matrix->colwidths[matrix->ccol] == 1) { wmove (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), 1, 1); } else { wmove (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), 1, (int)strlen (MATRIX_INFO (matrix, matrix->row, matrix->col)) + 1); } /* Put the focus on the current cell */ attrbox (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER, ACS_HLINE, ACS_VLINE, A_BOLD); wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol)); highlightCDKMatrixCell (matrix); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf (matrix) != 0) { /* Call the pre-process function. */ ppReturn = PreProcessFuncOf (matrix) (vMATRIX, matrix, PreProcessDataOf (matrix), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check the key bindings. */ if (checkCDKObjectBind (vMATRIX, matrix, input) != 0) { checkEarlyExit (matrix); complete = TRUE; } else { switch (input) { case CDK_TRANSPOSE: break; case KEY_HOME: break; case KEY_END: break; case KEY_BACKSPACE: case KEY_DC: if (matrix->colvalues[matrix->col] == vVIEWONLY || charcount <= 0) { Beep (); } else { charcount--; mvwdelch (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), 1, charcount + 1); mvwinsch (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), 1, charcount + 1, matrix->filler); wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol)); MATRIX_INFO (matrix, matrix->row, matrix->col)[charcount] = '\0'; } break; case KEY_RIGHT: case KEY_TAB: if (matrix->ccol != matrix->vcols) { /* We are moving to the right... */ matrix->col++; matrix->ccol++; movedCell = TRUE; } else { /* We have to shift the columns to the right. */ if (matrix->col != matrix->cols) { matrix->lcol++; matrix->col++; /* Redraw the column titles. */ if (matrix->rows > matrix->vrows) { redrawTitles (matrix, FALSE, TRUE); } refreshCells = TRUE; movedCell = TRUE; } else { /* We are at the far right column, we need */ /* shift down one row, if we can. */ if (matrix->row == matrix->rows) { Beep (); } else { /* Set up the columns info. */ matrix->col = 1; matrix->lcol = 1; matrix->ccol = 1; /* Shift the rows... */ if (matrix->crow != matrix->vrows) { matrix->row++; matrix->crow++; } else { matrix->row++; matrix->trow++; } redrawTitles (matrix, TRUE, TRUE); refreshCells = TRUE; movedCell = TRUE; } } } break; case KEY_LEFT: case KEY_BTAB: if (matrix->ccol != 1) { /* We are moving to the left... */ matrix->col--; matrix->ccol--; movedCell = TRUE; } else { /* Are we at the far left??? */ if (matrix->lcol != 1) { matrix->lcol--; matrix->col--; /* Redraw the column titles. */ if (matrix->cols > matrix->vcols) { redrawTitles (matrix, FALSE, TRUE); } refreshCells = TRUE; movedCell = TRUE; } else { /* Shift up one line if we can... */ if (matrix->row == 1) { Beep (); } else { /* Set up the columns info. */ matrix->col = matrix->cols; matrix->lcol = matrix->cols - matrix->vcols + 1; matrix->ccol = matrix->vcols; /* Shift the rows... */ if (matrix->crow != 1) { matrix->row--; matrix->crow--; } else { matrix->row--; matrix->trow--; } redrawTitles (matrix, TRUE, TRUE); refreshCells = TRUE; movedCell = TRUE; } } } break; case KEY_UP: if (matrix->crow != 1) { matrix->row--; matrix->crow--; movedCell = TRUE; } else { if (matrix->trow != 1) { matrix->trow--; matrix->row--; /* Redraw the row titles. */ if (matrix->rows > matrix->vrows) { redrawTitles (matrix, TRUE, FALSE); } refreshCells = TRUE; movedCell = TRUE; } else { Beep (); } } break; case KEY_DOWN: if (matrix->crow != matrix->vrows) { matrix->row++; matrix->crow++; movedCell = TRUE; } else { if ((matrix->trow + matrix->vrows - 1) != matrix->rows) { matrix->trow++; matrix->row++; /* Redraw the titles. */ if (matrix->rows > matrix->vrows) { redrawTitles (matrix, TRUE, FALSE); } refreshCells = TRUE; movedCell = TRUE; } else { Beep (); } } break; case KEY_NPAGE: if (matrix->rows > matrix->vrows) { if ((matrix->trow + ((matrix->vrows - 1) * 2)) <= matrix->rows) { matrix->trow += matrix->vrows - 1; matrix->row += matrix->vrows - 1; redrawTitles (matrix, TRUE, FALSE); refreshCells = TRUE; movedCell = TRUE; } else { Beep (); } } else { Beep (); } break; case KEY_PPAGE: if (matrix->rows > matrix->vrows) { if ((matrix->trow - ((matrix->vrows - 1) * 2)) >= 1) { matrix->trow -= matrix->vrows - 1; matrix->row -= matrix->vrows - 1; redrawTitles (matrix, TRUE, FALSE); refreshCells = TRUE; movedCell = TRUE; } else { Beep (); } } else { Beep (); } break; case CTRL ('G'): jumpToCell (matrix, -1, -1); drawCDKMatrix (matrix, ObjOf (matrix)->box); break; case CDK_PASTE: if (GPasteBuffer == 0 || (int)strlen (GPasteBuffer) > matrix->colwidths[matrix->ccol]) { Beep (); } else { strcpy (MATRIX_INFO (matrix, matrix->trow + matrix->crow - 1, matrix->lcol + matrix->ccol - 1), GPasteBuffer); drawCDKMatrixCell (matrix, matrix->crow, matrix->ccol, matrix->row, matrix->col, A_NORMAL, matrix->boxCell); } break; case CDK_COPY: freeChar (GPasteBuffer); GPasteBuffer = copyChar (MATRIX_INFO (matrix, matrix->trow + matrix->crow - 1, matrix->lcol + matrix->ccol - 1)); break; case CDK_CUT: freeChar (GPasteBuffer); GPasteBuffer = copyChar (MATRIX_INFO (matrix, matrix->trow + matrix->crow - 1, matrix->lcol + matrix->ccol - 1)); cleanCDKMatrixCell (matrix, matrix->trow + matrix->crow - 1, matrix->lcol + matrix->ccol - 1); drawCDKMatrixCell (matrix, matrix->crow, matrix->ccol, matrix->row, matrix->col, A_NORMAL, matrix->boxCell); break; case CDK_ERASE: cleanCDKMatrixCell (matrix, matrix->trow + matrix->crow - 1, matrix->lcol + matrix->ccol - 1); drawCDKMatrixCell (matrix, matrix->crow, matrix->ccol, matrix->row, matrix->col, A_NORMAL, matrix->boxCell); break; case KEY_ENTER: if (!matrix->boxCell) { attrbox (MATRIX_CELL (matrix, matrix->oldcrow, matrix->oldccol), ' ', ' ', ' ', ' ', ' ', ' ', A_NORMAL); } else { drawCDKMatrixCell (matrix, matrix->oldcrow, matrix->oldccol, matrix->oldvrow, matrix->oldvcol, A_NORMAL, matrix->boxCell); } wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol)); setExitType (matrix, input); ret = 1; complete = TRUE; break; case KEY_ESC: if (!matrix->boxCell) { attrbox (MATRIX_CELL (matrix, matrix->oldcrow, matrix->oldccol), ' ', ' ', ' ', ' ', ' ', ' ', A_NORMAL); } else { drawCDKMatrixCell (matrix, matrix->oldcrow, matrix->oldccol, matrix->oldvrow, matrix->oldvcol, A_NORMAL, matrix->boxCell); } wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol)); setExitType (matrix, input); complete = TRUE; break; case CDK_REFRESH: eraseCDKScreen (ScreenOf (matrix)); refreshCDKScreen (ScreenOf (matrix)); break; default: (matrix->callbackfn) (matrix, input); break; } } if (!complete) { /* Did we change cells? */ if (movedCell) { /* un-highlight the old box */ if (!matrix->boxCell) { attrbox (MATRIX_CELL (matrix, matrix->oldcrow, matrix->oldccol), ' ', ' ', ' ', ' ', ' ', ' ', A_NORMAL); } else { drawCDKMatrixCell (matrix, matrix->oldcrow, matrix->oldccol, matrix->oldvrow, matrix->oldvcol, 0, matrix->boxCell); } wrefresh (MATRIX_CELL (matrix, matrix->oldcrow, matrix->oldccol)); /* Highlight the new cell. */ attrbox (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER, ACS_HLINE, ACS_VLINE, A_BOLD); wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol)); highlightCDKMatrixCell (matrix); } /* Redraw each cell. */ if (refreshCells) { /* Fill in the cells. */ for (x = 1; x <= matrix->vrows; x++) { for (y = 1; y <= matrix->vcols; y++) { drawCDKMatrixCell (matrix, x, y, matrix->trow + x - 1, matrix->lcol + y - 1, 0, matrix->boxCell); } } /* Highlight the current cell. */ attrbox (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER, ACS_HLINE, ACS_VLINE, A_BOLD); wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol)); highlightCDKMatrixCell (matrix); } /* Move to the correct position in the cell. */ if (refreshCells || movedCell) { if (matrix->colwidths[matrix->ccol] == 1) { wmove (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), 1, 1); } else { infolen = (int)strlen (MATRIX_INFO (matrix, matrix->trow + matrix->crow - 1, matrix->lcol + matrix->ccol - 1)); wmove (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), 1, infolen + 1); } wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol)); } /* Should we call a post-process? */ if (PostProcessFuncOf (matrix) != 0) { PostProcessFuncOf (matrix) (vMATRIX, matrix, PostProcessDataOf (matrix), input); } } } if (!complete) { /* Set the variables we need. */ matrix->oldcrow = matrix->crow; matrix->oldccol = matrix->ccol; matrix->oldvrow = matrix->row; matrix->oldvcol = matrix->col; /* Set the exit type and exit. */ setExitType (matrix, 0); } ResultOf (matrix).valueInt = ret; return (ret != unknownInt); } /* * This allows the programmer to define their own key mappings. */ static void CDKMatrixCallBack (CDKMATRIX *matrix, chtype input) { EDisplayType disptype = (EDisplayType) matrix->colvalues[matrix->col]; int plainchar = filterByDisplayType (disptype, input); int charcount = (int)strlen (MATRIX_INFO (matrix, matrix->row, matrix->col)); if (plainchar == ERR) { Beep (); } else if (charcount == matrix->colwidths[matrix->col]) { Beep (); } else { /* Update the screen. */ wmove (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), 1, (int)strlen (MATRIX_INFO (matrix, matrix->row, matrix->col)) + 1); waddch (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), ((isHiddenDisplayType (disptype)) ? (int)matrix->filler : plainchar)); wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol)); /* Update the character pointer. */ MATRIX_INFO (matrix, matrix->row, matrix->col)[charcount++] = plainchar; MATRIX_INFO (matrix, matrix->row, matrix->col)[charcount] = '\0'; } } /* * Highlight the new field. */ static void highlightCDKMatrixCell (CDKMATRIX *matrix) { EDisplayType disptype = (EDisplayType) matrix->colvalues[matrix->col]; chtype highlight = matrix->highlight; int x = 0; int infolen = (int)strlen (MATRIX_INFO (matrix, matrix->row, matrix->col)); /* * Given the dominance of the colors/attributes, we need to set the * current cell attribute. */ if (matrix->dominant == ROW) { highlight = matrix->rowtitle[matrix->crow][0] & A_ATTRIBUTES; } else if (matrix->dominant == COL) { highlight = matrix->coltitle[matrix->ccol][0] & A_ATTRIBUTES; } /* If the column is only one char. */ for (x = 1; x <= matrix->colwidths[matrix->ccol]; x++) { chtype ch = (((x <= infolen) && !isHiddenDisplayType (disptype)) ? CharOf (MATRIX_INFO (matrix, matrix->row, matrix->col)[x - 1]) : matrix->filler); mvwaddch (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), 1, x, ch | highlight); } wmove (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), 1, infolen + 1); wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol)); } /* * This moves the matrix field to the given location. */ static void _moveCDKMatrix (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDKMATRIX *matrix = (CDKMATRIX *)object; int currentX = getbegx (matrix->win); int currentY = getbegy (matrix->win); int xpos = xplace; int ypos = yplace; int xdiff = 0; int ydiff = 0; int x, y; /* * If this is a relative move, then we will adjust where we want * to move to. */ if (relative) { xpos = getbegx (matrix->win) + xplace; ypos = getbegy (matrix->win) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf (matrix), &xpos, &ypos, matrix->boxWidth, matrix->boxHeight); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the window to the new location. */ moveCursesWindow (matrix->win, -xdiff, -ydiff); for (x = 0; x <= matrix->vrows; x++) { for (y = 0; y <= matrix->vcols; y++) { moveCursesWindow (MATRIX_CELL (matrix, x, y), -xdiff, -ydiff); } } moveCursesWindow (matrix->shadowWin, -xdiff, -ydiff); /* Touch the windows so they 'move'. */ refreshCDKWindow (WindowOf (matrix)); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDKMatrix (matrix, ObjOf (matrix)->box); } } /* * This draws a cell within a matrix. */ static void drawCDKMatrixCell (CDKMATRIX *matrix, int row, int col, int vrow, int vcol, chtype attr, boolean Box) { WINDOW *cell = MATRIX_CELL (matrix, row, col); EDisplayType disptype = (EDisplayType) matrix->colvalues[matrix->col]; chtype highlight = matrix->filler & A_ATTRIBUTES; int rows = matrix->vrows; int cols = matrix->vcols; int infolen = (int)strlen (MATRIX_INFO (matrix, vrow, vcol)); int x; /* * Given the dominance of the colors/attributes, we need to set the * current cell attribute. */ if (matrix->dominant == ROW) { highlight = matrix->rowtitle[row][0] & A_ATTRIBUTES; } else if (matrix->dominant == COL) { highlight = matrix->coltitle[col][0] & A_ATTRIBUTES; } /* Draw in the cell info. */ for (x = 1; x <= matrix->colwidths[col]; x++) { chtype ch = (((x <= infolen) && !isHiddenDisplayType (disptype)) ? (CharOf (MATRIX_INFO (matrix, vrow, vcol)[x - 1]) | highlight) : matrix->filler); mvwaddch (cell, 1, x, ch | highlight); } wmove (cell, 1, infolen + 1); wrefresh (cell); /* Only draw the box iff the user asked for a box. */ if (!Box) { return; } /* * If the value of the column spacing is greater than 0 then these * are independent boxes. */ if (matrix->colSpace != 0 && matrix->rowSpace != 0) { attrbox (cell, ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER, ACS_HLINE, ACS_VLINE, attr); return; } if (matrix->colSpace != 0 && matrix->rowSpace == 0) { if (row == 1) { attrbox (cell, ACS_ULCORNER, ACS_URCORNER, ACS_LTEE, ACS_RTEE, ACS_HLINE, ACS_VLINE, attr); return; } else if (row > 1 && row < rows) { attrbox (cell, ACS_LTEE, ACS_RTEE, ACS_LTEE, ACS_RTEE, ACS_HLINE, ACS_VLINE, attr); return; } else if (row == rows) { attrbox (cell, ACS_LTEE, ACS_RTEE, ACS_LLCORNER, ACS_LRCORNER, ACS_HLINE, ACS_VLINE, attr); return; } } if (matrix->colSpace == 0 && matrix->rowSpace != 0) { if (col == 1) { attrbox (cell, ACS_ULCORNER, ACS_TTEE, ACS_LLCORNER, ACS_BTEE, ACS_HLINE, ACS_VLINE, attr); return; } else if (col > 1 && col < cols) { attrbox (cell, ACS_TTEE, ACS_TTEE, ACS_BTEE, ACS_BTEE, ACS_HLINE, ACS_VLINE, attr); return; } else if (col == cols) { attrbox (cell, ACS_TTEE, ACS_URCORNER, ACS_BTEE, ACS_LRCORNER, ACS_HLINE, ACS_VLINE, attr); return; } } /* Start drawing the matrix. */ if (row == 1) { if (col == 1) { /* Draw the top left corner */ attrbox (cell, ACS_ULCORNER, ACS_TTEE, ACS_LTEE, ACS_PLUS, ACS_HLINE, ACS_VLINE, attr); } else if (col > 1 && col < cols) { /* Draw the top middle box */ attrbox (cell, ACS_TTEE, ACS_TTEE, ACS_PLUS, ACS_PLUS, ACS_HLINE, ACS_VLINE, attr); } else if (col == cols) { /* Draw the top right corner */ attrbox (cell, ACS_TTEE, ACS_URCORNER, ACS_PLUS, ACS_RTEE, ACS_HLINE, ACS_VLINE, attr); } } else if (row > 1 && row < rows) { if (col == 1) { /* Draw the middle left box */ attrbox (cell, ACS_LTEE, ACS_PLUS, ACS_LTEE, ACS_PLUS, ACS_HLINE, ACS_VLINE, attr); } else if (col > 1 && col < cols) { /* Draw the middle box */ attrbox (cell, ACS_PLUS, ACS_PLUS, ACS_PLUS, ACS_PLUS, ACS_HLINE, ACS_VLINE, attr); } else if (col == cols) { /* Draw the middle right box */ attrbox (cell, ACS_PLUS, ACS_RTEE, ACS_PLUS, ACS_RTEE, ACS_HLINE, ACS_VLINE, attr); } } else if (row == rows) { if (col == 1) { /* Draw the bottom left corner */ attrbox (cell, ACS_LTEE, ACS_PLUS, ACS_LLCORNER, ACS_BTEE, ACS_HLINE, ACS_VLINE, attr); } else if (col > 1 && col < cols) { /* Draw the bottom middle box */ attrbox (cell, ACS_PLUS, ACS_PLUS, ACS_BTEE, ACS_BTEE, ACS_HLINE, ACS_VLINE, attr); } else if (col == cols) { /* Draw the bottom right corner */ attrbox (cell, ACS_PLUS, ACS_RTEE, ACS_BTEE, ACS_LRCORNER, ACS_HLINE, ACS_VLINE, attr); } } /* Highlight the current cell. */ attrbox (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER, ACS_HLINE, ACS_VLINE, A_BOLD); wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol)); highlightCDKMatrixCell (matrix); } /* * This function draws the matrix widget. */ static void _drawCDKMatrix (CDKOBJS *object, boolean Box) { CDKMATRIX *matrix = (CDKMATRIX *)object; int x, y; /* Did we ask for a shadow??? */ if (matrix->shadowWin != 0) { drawShadow (matrix->shadowWin); } /* Should we box the matrix??? */ if (Box) { drawObjBox (matrix->win, ObjOf (matrix)); } drawCdkTitle (matrix->win, object); wrefresh (matrix->win); /* Draw in the column titles. */ for (x = 1; x <= matrix->vcols; x++) { writeChtype (MATRIX_CELL (matrix, 0, x), matrix->coltitlePos[matrix->lcol + x - 1], 0, matrix->coltitle[matrix->lcol + x - 1], HORIZONTAL, 0, matrix->coltitleLen[matrix->lcol + x - 1]); wrefresh (MATRIX_CELL (matrix, 0, x)); } /* Fill in the rest of the matrix. */ for (x = 1; x <= matrix->vrows; x++) { /* Draw in the row titles */ writeChtype (MATRIX_CELL (matrix, x, 0), matrix->rowtitlePos[matrix->trow + x - 1], 1, matrix->rowtitle[matrix->trow + x - 1], HORIZONTAL, 0, matrix->rowtitleLen[matrix->trow + x - 1]); wrefresh (MATRIX_CELL (matrix, x, 0)); /* Draw in the cells.. */ for (y = 1; y <= matrix->vcols; y++) { drawCDKMatrixCell (matrix, x, y, matrix->trow + x - 1, matrix->lcol + y - 1, A_NORMAL, matrix->boxCell); } } /* Highlight the current cell. */ attrbox (MATRIX_CELL (matrix, matrix->crow, matrix->ccol), ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER, ACS_HLINE, ACS_VLINE, A_BOLD); wrefresh (MATRIX_CELL (matrix, matrix->crow, matrix->ccol)); highlightCDKMatrixCell (matrix); } /* * This function destroys the matrix widget. */ static void _destroyCDKMatrix (CDKOBJS *object) { if (object != 0) { CDKMATRIX *matrix = (CDKMATRIX *)object; int x = 0; int y = 0; cleanCdkTitle (object); /* Clear out the col titles. */ for (x = 1; x <= matrix->cols; x++) { freeChtype (matrix->coltitle[x]); } /* Clear out the row titles. */ for (x = 1; x <= matrix->rows; x++) { freeChtype (matrix->rowtitle[x]); } /* Clear out the matrix cells. */ for (x = 1; x <= matrix->rows; x++) { for (y = 1; y <= matrix->cols; y++) { freeChar (MATRIX_INFO (matrix, x, y)); } } /* Clear the matrix windows. */ deleteCursesWindow (MATRIX_CELL (matrix, 0, 0)); for (x = 1; x <= matrix->vrows; x++) { deleteCursesWindow (MATRIX_CELL (matrix, x, 0)); } for (x = 1; x <= matrix->vcols; x++) { deleteCursesWindow (MATRIX_CELL (matrix, 0, x)); } for (x = 1; x <= matrix->vrows; x++) { for (y = 1; y <= matrix->vcols; y++) { deleteCursesWindow (MATRIX_CELL (matrix, x, y)); } } #if NEW_CDKMATRIX freeChecked (matrix->cell); freeChecked (matrix->info); #endif freeChecked (matrix->colwidths); freeChecked (matrix->colvalues); freeChecked (matrix->coltitle); freeChecked (matrix->coltitleLen); freeChecked (matrix->coltitlePos); freeChecked (matrix->rowtitle); freeChecked (matrix->rowtitleLen); freeChecked (matrix->rowtitlePos); deleteCursesWindow (matrix->shadowWin); deleteCursesWindow (matrix->win); /* Clean the key bindings. */ cleanCDKObjectBindings (vMATRIX, matrix); /* Unregister this object. */ unregisterCDKObject (vMATRIX, matrix); } } /* * This function erases the matrix widget from the screen. */ static void _eraseCDKMatrix (CDKOBJS *object) { if (validCDKObject (object)) { CDKMATRIX *matrix = (CDKMATRIX *)object; int x = 0; int y = 0; /* Clear the matrix cells. */ eraseCursesWindow (MATRIX_CELL (matrix, 0, 0)); for (x = 1; x <= matrix->vrows; x++) { eraseCursesWindow (MATRIX_CELL (matrix, x, 0)); } for (x = 1; x <= matrix->vcols; x++) { eraseCursesWindow (MATRIX_CELL (matrix, 0, x)); } for (x = 1; x <= matrix->vrows; x++) { for (y = 1; y <= matrix->vcols; y++) { eraseCursesWindow (MATRIX_CELL (matrix, x, y)); } } eraseCursesWindow (matrix->shadowWin); eraseCursesWindow (matrix->win); } } /* * Set the callback-function. */ void setCDKMatrixCB (CDKMATRIX *widget, MATRIXCB callback) { widget->callbackfn = callback; } /* * This function sets the values of the matrix widget. */ void setCDKMatrixCells (CDKMATRIX *matrix, char **info, int rows, int maxcols, int *subSize) { int x = 0; int y = 0; if (rows > matrix->rows) rows = matrix->rows; /* Copy in the new info. */ for (x = 1; x <= rows; x++) { for (y = 1; y <= matrix->cols; y++) { if (x <= rows && y <= subSize[x]) { char *source = info[(x * maxcols) + y]; /* Copy in the new information. */ if (source != 0) { char *target = MATRIX_INFO (matrix, x, y); if (target == 0) /* this should not happen... */ { target = typeCallocN (char, matrix->colwidths[y] + 1); MATRIX_INFO (matrix, x, y) = target; } strncpy (MATRIX_INFO (matrix, x, y), source, matrix->colwidths[y]); } } else cleanCDKMatrixCell (matrix, x, y); } } } /* * This sets the widget's box attribute. */ void setCDKMatrixBox (CDKMATRIX *matrix, boolean Box) { ObjOf (matrix)->box = Box; ObjOf (matrix)->borderSize = Box ? 1 : 0; } boolean getCDKMatrixBox (CDKMATRIX *matrix) { return ObjOf (matrix)->box; } /* * This cleans out the information cells in the matrix widget. */ void cleanCDKMatrix (CDKMATRIX *matrix) { int x = 0; int y = 0; for (x = 1; x <= matrix->rows; x++) { for (y = 1; y <= matrix->cols; y++) { cleanCDKMatrixCell (matrix, x, y); } } } /* * This cleans one cell in the matrix widget. */ void cleanCDKMatrixCell (CDKMATRIX *matrix, int row, int col) { if (row > 0 && row <= matrix->rows && col > 0 && col <= matrix->cols) cleanChar (MATRIX_INFO (matrix, row, col), matrix->colwidths[col], '\0'); } /* * This allows us to hyper-warp to a cell. */ int jumpToCell (CDKMATRIX *matrix, int row, int col) { CDKSCALE *scale = 0; int newRow = row; int newCol = col; /* * Only create the row scale if needed. */ if ((row == -1) || (row > matrix->rows)) { /* Create the row scale widget. */ scale = newCDKScale (ScreenOf (matrix), CENTER, CENTER, "Jump to which row.", "Row: ", A_NORMAL, 5, 1, 1, matrix->rows, 1, 1, TRUE, FALSE); /* Activate the scale and get the row. */ newRow = activateCDKScale (scale, 0); destroyCDKScale (scale); } /* * Only create the column scale if needed. */ if ((col == -1) || (col > matrix->cols)) { /* Create the column scale widget. */ scale = newCDKScale (ScreenOf (matrix), CENTER, CENTER, "Jump to which column", "Col: ", A_NORMAL, 5, 1, 1, matrix->cols, 1, 1, TRUE, FALSE); /* Activate the scale and get the column. */ newCol = activateCDKScale (scale, 0); destroyCDKScale (scale); } /* Hyper-warp.... */ if (newRow != matrix->row || newCol != matrix->col) { return (moveToCDKMatrixCell (matrix, newRow, newCol)); } else { return 1; } } /* * This allows us to move to a given cell. */ int moveToCDKMatrixCell (CDKMATRIX *matrix, int newrow, int newcol) { int rowShift = newrow - matrix->row; int colShift = newcol - matrix->col; /* Make sure we arent asking to move out of the matrix. */ if (newrow > matrix->rows || newcol > matrix->cols || newrow <= 0 || newcol <= 0) { return 0; } /* Did we move up/down???? */ if (rowShift > 0) { /* We are moving down. */ if (matrix->vrows == matrix->cols) { matrix->trow = 1; matrix->crow = newrow; matrix->row = newrow; } else { if ((rowShift + matrix->vrows) < matrix->rows) { /* Just shift down by rowShift... */ matrix->trow += rowShift; matrix->crow = 1; matrix->row += rowShift; } else { /* We need to munge with the values... */ matrix->trow = matrix->rows - matrix->vrows + 1; matrix->crow = ((rowShift + matrix->vrows) - matrix->rows) + 1; matrix->row = newrow; } } } else if (rowShift < 0) { /* We are moving up. */ if (matrix->vrows == matrix->rows) { matrix->trow = 1; matrix->row = newrow; matrix->crow = newrow; } else { if ((rowShift + matrix->vrows) > 1) { /* Just shift up by rowShift... */ matrix->trow += rowShift; matrix->row += rowShift; matrix->crow = 1; } else { /* We need to munge with the values... */ matrix->trow = 1; matrix->crow = 1; matrix->row = 1; } } } /* Did we move left/right ???? */ if (colShift > 0) { /* We are moving right. */ if (matrix->vcols == matrix->cols) { matrix->lcol = 1; matrix->ccol = newcol; matrix->col = newcol; } else { if ((colShift + matrix->vcols) < matrix->cols) { matrix->lcol += colShift; matrix->ccol = 1; matrix->col += colShift; } else { /* We need to munge with the values... */ matrix->lcol = matrix->cols - matrix->vcols + 1; matrix->ccol = ((colShift + matrix->vcols) - matrix->cols) + 1; matrix->col = newcol; } } } else if (colShift < 0) { /* We are moving left. */ if (matrix->vcols == matrix->cols) { matrix->lcol = 1; matrix->col = newcol; matrix->ccol = newcol; } else { if ((colShift + matrix->vcols) > 1) { /* Just shift left by colShift... */ matrix->lcol += colShift; matrix->col += colShift; matrix->ccol = 1; } else { matrix->lcol = 1; matrix->col = 1; matrix->ccol = 1; } } } /* Keep the 'old' values around for redrawing sake. */ matrix->oldcrow = matrix->crow; matrix->oldccol = matrix->ccol; matrix->oldvrow = matrix->row; matrix->oldvcol = matrix->col; /* Lets ... */ return 1; } /* * This redraws the titles indicated... */ static void redrawTitles (CDKMATRIX *matrix, int rowTitles, int colTitles) { int x = 0; /* Redraw the row titles. */ if (rowTitles) { for (x = 1; x <= matrix->vrows; x++) { werase (MATRIX_CELL (matrix, x, 0)); writeChtype (MATRIX_CELL (matrix, x, 0), matrix->rowtitlePos[matrix->trow + x - 1], 1, matrix->rowtitle[matrix->trow + x - 1], HORIZONTAL, 0, matrix->rowtitleLen[matrix->trow + x - 1]); wrefresh (MATRIX_CELL (matrix, x, 0)); } } /* Redraw the column titles. */ if (colTitles) { for (x = 1; x <= matrix->vcols; x++) { werase (MATRIX_CELL (matrix, 0, x)); writeChtype (MATRIX_CELL (matrix, 0, x), matrix->coltitlePos[matrix->lcol + x - 1], 0, matrix->coltitle[matrix->lcol + x - 1], HORIZONTAL, 0, matrix->coltitleLen[matrix->lcol + x - 1]); wrefresh (MATRIX_CELL (matrix, 0, x)); } } } /* * This sets the value of a matrix cell. */ int setCDKMatrixCell (CDKMATRIX *matrix, int row, int col, char *value) { /* Make sure the row/col combination is within the matrix. */ if (row > matrix->rows || col > matrix->cols || row <= 0 || col <= 0) { return -1; } cleanCDKMatrixCell (matrix, row, col); strncpy (MATRIX_INFO (matrix, row, col), value, matrix->colwidths[col]); return 1; } /* * This gets the value of a matrix cell. */ char *getCDKMatrixCell (CDKMATRIX *matrix, int row, int col) { /* Make sure the row/col combination is within the matrix. */ if (row > matrix->rows || col > matrix->cols || row <= 0 || col <= 0) { return 0; } return MATRIX_INFO (matrix, row, col); } /* * This returns the current row/col cell. */ int getCDKMatrixCol (CDKMATRIX *matrix) { return matrix->col; } int getCDKMatrixRow (CDKMATRIX *matrix) { return matrix->row; } /* * This sets the background attribute of the widget. */ static void _setBKattrMatrix (CDKOBJS *object, chtype attrib) { if (object != 0) { CDKMATRIX *widget = (CDKMATRIX *)object; int x, y; wbkgd (widget->win, attrib); for (x = 0; x <= widget->vrows; x++) { for (y = 0; y <= widget->vcols; y++) { wbkgd (MATRIX_CELL (widget, x, y), attrib); } } } } static void _focusCDKMatrix (CDKOBJS *object) { CDKMATRIX *widget = (CDKMATRIX *)object; drawCDKMatrix (widget, ObjOf (widget)->box); } static void _unfocusCDKMatrix (CDKOBJS *object) { CDKMATRIX *widget = (CDKMATRIX *)object; drawCDKMatrix (widget, ObjOf (widget)->box); } dummyRefreshData (Matrix) dummySaveData (Matrix) cdk-5.0-20060507/mentry.c0000644000175100001440000005360710426516000013226 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:27:44 $ * $Revision: 1.160 $ */ /* * Declare file local prototypes. */ static void CDKMentryCallBack (CDKMENTRY *mentry, chtype character); DeclareCDKObjects (MENTRY, Mentry, setCdk, String); /* * This creates a pointer to a multiple line entry widget. */ CDKMENTRY *newCDKMentry (CDKSCREEN *cdkscreen, int xplace, int yplace, char *title, char *label, chtype fieldAttr, chtype filler, EDisplayType dispType, int fWidth, int fRows, int logicalRows, int min, boolean Box, boolean shadow) { CDKMENTRY *mentry = 0; int parentWidth = getmaxx (cdkscreen->window); int parentHeight = getmaxy (cdkscreen->window); int fieldWidth = fWidth; int fieldRows = fRows; int boxWidth = 0; int boxHeight = 0; int horizontalAdjust, oldWidth; int xpos = xplace; int ypos = yplace; int junk; if ((mentry = newCDKObject (CDKMENTRY, &my_funcs)) == 0) return (0); setCDKMentryBox (mentry, Box); /* * 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); /* * If the fieldRows is a negative value, the fieldRows will * be ROWS-fieldRows, otherwise, the fieldRows will be the * given height. */ fieldRows = setWidgetDimension (parentWidth, fieldRows, 0); boxHeight = fieldRows + 2; /* Set some basic values of the mentry field. */ mentry->label = 0; mentry->labelLen = 0; mentry->labelWin = 0; /* We need to translate the char * label to a chtype * */ if (label != 0) { mentry->label = char2Chtype (label, &mentry->labelLen, &junk); } boxWidth = mentry->labelLen + fieldWidth + 2; oldWidth = boxWidth; boxWidth = setCdkTitle (ObjOf (mentry), title, boxWidth); horizontalAdjust = (boxWidth - oldWidth) / 2; boxHeight += TitleLinesOf (mentry); /* * Make sure we didn't extend beyond the parent window. */ boxWidth = (boxWidth > parentWidth ? parentWidth : boxWidth); boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight); fieldWidth = (fieldWidth > (boxWidth - mentry->labelLen - 2) ? (boxWidth - mentry->labelLen - 2) : fieldWidth); fieldRows = (fieldRows > (boxHeight - TitleLinesOf (mentry) - 2) ? (boxHeight - TitleLinesOf (mentry) - 2) : fieldRows); /* Rejustify the x and y positions if we need to. */ alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight); /* Make the label window. */ mentry->win = newwin (boxHeight, boxWidth, ypos, xpos); /* Is the window null??? */ if (mentry->win == 0) { destroyCDKObject (mentry); return (0); } /* Create the label window. */ if (mentry->label != 0) { mentry->labelWin = subwin (mentry->win, fieldRows, mentry->labelLen + 2, ypos + TitleLinesOf (mentry) + 1, xpos + horizontalAdjust + 1); } /* Make the field window. */ mentry->fieldWin = subwin (mentry->win, fieldRows, fieldWidth, ypos + TitleLinesOf (mentry) + 1, xpos + mentry->labelLen + horizontalAdjust + 1); /* Turn on the keypad. */ keypad (mentry->fieldWin, TRUE); keypad (mentry->win, TRUE); /* Set up the rest of the structure. */ mentry->parent = cdkscreen->window; mentry->totalWidth = (fieldWidth*logicalRows) + 1; /* Create the info char * pointer. */ mentry->info = typeMallocN (char, mentry->totalWidth + 3); cleanChar (mentry->info, mentry->totalWidth + 3, '\0'); /* Set up the rest of the widget information. */ ScreenOf (mentry) = cdkscreen; mentry->shadowWin = 0; mentry->fieldAttr = fieldAttr; mentry->fieldWidth = fieldWidth; mentry->rows = fieldRows; mentry->boxHeight = boxHeight; mentry->boxWidth = boxWidth; mentry->filler = filler; mentry->hidden = filler; ObjOf (mentry)->inputWindow = mentry->win; ObjOf (mentry)->acceptsFocus = TRUE; mentry->currentRow = 0; mentry->currentCol = 0; mentry->topRow = 0; mentry->shadow = shadow; mentry->dispType = dispType; mentry->min = min; mentry->logicalRows = logicalRows; initExitType (mentry); mentry->callbackfn = CDKMentryCallBack; /* Do we need to create a shadow. */ if (shadow) { mentry->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1); } /* Register this baby. */ registerCDKObject (cdkscreen, vMENTRY, mentry); /* Return the pointer to the structure. */ return (mentry); } /* * This actually manages the mentry widget... */ char *activateCDKMentry (CDKMENTRY *mentry, chtype *actions) { chtype input = 0; boolean functionKey; char *ret = 0; /* Draw the mentry widget. */ drawCDKMentry (mentry, ObjOf (mentry)->box); if (actions == 0) { for (;;) { input = getchCDKObject (ObjOf (mentry), &functionKey); /* Inject this character into the widget. */ ret = injectCDKMentry (mentry, input); if (mentry->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 = injectCDKMentry (mentry, actions[x]); if (mentry->exitType != vEARLY_EXIT) { return ret; } } } /* Set the exit type and exit. */ setExitType (mentry, 0); return 0; } static bool setTopRow (CDKMENTRY *widget, int row) { if (widget->topRow != row) { widget->topRow = row; return TRUE; } return FALSE; } static bool setCurPos (CDKMENTRY *widget, int row, int col) { if (widget->currentRow != row || widget->currentCol != col) { widget->currentRow = row; widget->currentCol = col; return TRUE; } return FALSE; } static bool handle_KEY_LEFT (CDKMENTRY *mentry, bool *moved, bool *redraw) { bool result = TRUE; if (mentry->currentCol != 0) { *moved = setCurPos (mentry, mentry->currentRow, mentry->currentCol - 1); } else if (mentry->currentRow == 0) { if (mentry->topRow != 0) { *moved = setCurPos (mentry, mentry->currentRow, mentry->fieldWidth - 1); *redraw = setTopRow (mentry, mentry->topRow - 1); } } else { *moved = setCurPos (mentry, mentry->currentRow - 1, mentry->fieldWidth - 1); } if (!*moved && !*redraw) { Beep (); result = FALSE; } return result; } static int getCursorPos (CDKMENTRY *mentry) { return (((mentry->currentRow + mentry->topRow) * mentry->fieldWidth) + mentry->currentCol); } /* * This injects a character into the widget. */ static int _injectCDKMentry (CDKOBJS *object, chtype input) { CDKMENTRY *mentry = (CDKMENTRY *)object; int cursorPos = getCursorPos (mentry); int ppReturn = 1; int x, fieldCharacters; char holder; char *ret = unknownString; bool complete = FALSE; /* Set the exit type. */ setExitType (mentry, 0); /* Refresh the field. */ drawCDKMentryField (mentry); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf (mentry) != 0) { /* Call the pre-process function. */ ppReturn = PreProcessFuncOf (mentry) (vMENTRY, mentry, PreProcessDataOf (mentry), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check for a key binding... */ if (checkCDKObjectBind (vMENTRY, mentry, input) != 0) { checkEarlyExit (mentry); complete = TRUE; } else { bool moved = FALSE; bool redraw = FALSE; int infoLength = (int)strlen (mentry->info); switch (input) { case KEY_HOME: moved = setCurPos (mentry, 0, 0); redraw = setTopRow (mentry, 0); break; case KEY_END: fieldCharacters = mentry->rows * mentry->fieldWidth; if (infoLength < fieldCharacters) { redraw = setTopRow (mentry, 0); moved = setCurPos (mentry, infoLength / mentry->fieldWidth, infoLength % mentry->fieldWidth); } else { redraw = setTopRow (mentry, (infoLength / mentry->fieldWidth) - mentry->rows + 1); moved = setCurPos (mentry, mentry->rows - 1, infoLength % mentry->fieldWidth); } break; case KEY_LEFT: handle_KEY_LEFT (mentry, &moved, &redraw); break; case KEY_RIGHT: if (mentry->currentCol < (mentry->fieldWidth - 1)) { if ((getCursorPos (mentry) + 1) <= infoLength) { moved = setCurPos (mentry, mentry->currentRow, mentry->currentCol + 1); } } else if (mentry->currentRow == mentry->rows - 1) { if ((mentry->topRow + mentry->currentRow + 1) <= mentry->logicalRows) { moved = setCurPos (mentry, mentry->currentRow, 0); redraw = setTopRow (mentry, mentry->topRow + 1); } } else { moved = setCurPos (mentry, mentry->currentRow + 1, 0); } if (!moved && !redraw) Beep (); break; case KEY_DOWN: if (mentry->currentRow != (mentry->rows - 1)) { if ((getCursorPos (mentry) + mentry->fieldWidth + 1) <= infoLength) { moved = setCurPos (mentry, mentry->currentRow + 1, mentry->currentCol); } } else if (mentry->topRow < mentry->logicalRows - mentry->rows) { if (((mentry->topRow + mentry->currentRow + 1) * mentry->fieldWidth) <= infoLength) { redraw = setTopRow (mentry, mentry->topRow + 1); } } if (!moved && !redraw) Beep (); break; case KEY_UP: if (mentry->currentRow != 0) { moved = setCurPos (mentry, mentry->currentRow - 1, mentry->currentCol); } else if (mentry->topRow != 0) { redraw = setTopRow (mentry, mentry->topRow - 1); } if (!moved && !redraw) Beep (); break; case KEY_BACKSPACE: case KEY_DC: if (mentry->dispType == vVIEWONLY) { Beep (); } else if (infoLength == 0) { Beep (); } else if (input == KEY_DC || handle_KEY_LEFT (mentry, &moved, &redraw)) { cursorPos = getCursorPos (mentry); if (mentry->info[cursorPos] != '\0') { for (x = cursorPos; x < infoLength; x++) { mentry->info[x] = mentry->info[x + 1]; } mentry->info[--infoLength] = '\0'; drawCDKMentryField (mentry); } else { Beep (); } } break; case CDK_TRANSPOSE: if (cursorPos >= infoLength - 1) { Beep (); } else { holder = mentry->info[cursorPos]; mentry->info[cursorPos] = mentry->info[cursorPos + 1]; mentry->info[cursorPos + 1] = holder; drawCDKMentryField (mentry); } break; case CDK_ERASE: if (infoLength != 0) { cleanCDKMentry (mentry); drawCDKMentryField (mentry); } break; case CDK_CUT: if (infoLength == 0) { Beep (); } else { freeChar (GPasteBuffer); GPasteBuffer = copyChar (mentry->info); cleanCDKMentry (mentry); drawCDKMentryField (mentry); } break; case CDK_COPY: if (infoLength == 0) { Beep (); } else { freeChar (GPasteBuffer); GPasteBuffer = copyChar (mentry->info); } break; case CDK_PASTE: if (GPasteBuffer == 0) { Beep (); } else { setCDKMentryValue (mentry, GPasteBuffer); drawCDKMentry (mentry, ObjOf (mentry)->box); } break; case KEY_TAB: case KEY_ENTER: if (infoLength < mentry->min + 1) { Beep (); } else { setExitType (mentry, input); ret = (mentry->info); complete = TRUE; } break; case KEY_ESC: setExitType (mentry, input); complete = TRUE; break; case CDK_REFRESH: eraseCDKScreen (ScreenOf (mentry)); refreshCDKScreen (ScreenOf (mentry)); break; default: if (mentry->dispType == vVIEWONLY || infoLength >= mentry->totalWidth) { Beep (); } else { (mentry->callbackfn) (mentry, input); } break; } if (redraw) { drawCDKMentryField (mentry); } else if (moved) { wmove (mentry->fieldWin, mentry->currentRow, mentry->currentCol); wrefresh (mentry->fieldWin); } } /* Should we do a post-process? */ if (!complete && (PostProcessFuncOf (mentry) != 0)) { PostProcessFuncOf (mentry) (vMENTRY, mentry, PostProcessDataOf (mentry), input); } } if (!complete) { setExitType (mentry, 0); } ResultOf (mentry).valueString = ret; return (ret != unknownString); } /* * This moves the mentry field to the given location. */ static void _moveCDKMentry (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDKMENTRY *mentry = (CDKMENTRY *)object; int currentX = getbegx (mentry->win); int currentY = getbegy (mentry->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 (mentry->win) + xplace; ypos = getbegy (mentry->win) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf (mentry), &xpos, &ypos, mentry->boxWidth, mentry->boxHeight); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the window to the new location. */ moveCursesWindow (mentry->win, -xdiff, -ydiff); moveCursesWindow (mentry->fieldWin, -xdiff, -ydiff); moveCursesWindow (mentry->labelWin, -xdiff, -ydiff); moveCursesWindow (mentry->shadowWin, -xdiff, -ydiff); /* Touch the windows so they 'move'. */ refreshCDKWindow (WindowOf (mentry)); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDKMentry (mentry, ObjOf (mentry)->box); } } /* * This function redraws the multiple line entry field. */ void drawCDKMentryField (CDKMENTRY *mentry) { int currchar = (mentry->fieldWidth * mentry->topRow); int length = 0; int lastpos = 0; int x, y; /* Check the value of info. */ if (mentry->info == 0) { return; } drawCdkTitle (mentry->win, ObjOf (mentry)); wrefresh (mentry->win); /* The information isn't null, redraw the field. */ length = (int)strlen (mentry->info); lastpos = ((chtype)mentry->info[length] == (chtype)mentry->filler ? length - 1 : length); /* Start redrawing the fields. */ for (x = 0; x < mentry->rows; x++) { for (y = 0; y < mentry->fieldWidth; y++) { if (currchar < lastpos) { if (isHiddenDisplayType (mentry->dispType)) { mvwaddch (mentry->fieldWin, x, y, mentry->filler); } else { mvwaddch (mentry->fieldWin, x, y, CharOf (mentry->info[currchar++]) | mentry->fieldAttr); } } else { mvwaddch (mentry->fieldWin, x, y, mentry->filler); } } } /* Refresh the screen. */ wmove (mentry->fieldWin, mentry->currentRow, mentry->currentCol); wrefresh (mentry->fieldWin); } /* * This is a generic character parser for the mentry field. It is used as a * callback function, so any personal modifications can be made by creating * a new function and calling that one the mentry activation. */ static void CDKMentryCallBack (CDKMENTRY *mentry, chtype character) { int cursorPos = getCursorPos (mentry); int infoLength = (int)strlen (mentry->info); char newchar = filterByDisplayType (mentry->dispType, character); int x; if (newchar == ERR) { Beep (); } else { for (x = infoLength + 1; x > cursorPos; x--) { mentry->info[x] = mentry->info[x - 1]; } mentry->info[cursorPos] = newchar; mentry->currentCol++; drawCDKMentryField (mentry); /* Have we gone out of bounds. */ if (mentry->currentCol >= mentry->fieldWidth) { /* Update the row and col values. */ mentry->currentCol = 0; mentry->currentRow++; /* * If we have gone outside of the visual boundaries, we * need to scroll the window. */ if (mentry->currentRow == mentry->rows) { /* We have to redraw the screen. */ mentry->currentRow--; mentry->topRow++; drawCDKMentryField (mentry); } wmove (mentry->fieldWin, mentry->currentRow, mentry->currentCol); wrefresh (mentry->fieldWin); } } } /* * This function draws the multiple line entry field. */ static void _drawCDKMentry (CDKOBJS *object, boolean Box) { CDKMENTRY *mentry = (CDKMENTRY *)object; /* Box the widget if asked. */ if (Box) { drawObjBox (mentry->win, ObjOf (mentry)); wrefresh (mentry->win); } /* Do we need to draw in the shadow??? */ if (mentry->shadowWin != 0) { drawShadow (mentry->shadowWin); } /* Draw in the label to the widget. */ if (mentry->labelWin != 0) { writeChtype (mentry->labelWin, 0, 0, mentry->label, HORIZONTAL, 0, mentry->labelLen); wrefresh (mentry->labelWin); } /* Draw the mentry field. */ drawCDKMentryField (mentry); } /* * This sets the background attribute of the widget. */ static void _setBKattrMentry (CDKOBJS *object, chtype attrib) { if (object != 0) { CDKMENTRY *widget = (CDKMENTRY *)object; wbkgd (widget->win, attrib); wbkgd (widget->fieldWin, attrib); if (widget->labelWin != 0) { wbkgd (widget->labelWin, attrib); } } } /* * This function erases the multiple line entry field from the screen. */ static void _eraseCDKMentry (CDKOBJS *object) { if (validCDKObject (object)) { CDKMENTRY *mentry = (CDKMENTRY *)object; eraseCursesWindow (mentry->fieldWin); eraseCursesWindow (mentry->labelWin); eraseCursesWindow (mentry->win); eraseCursesWindow (mentry->shadowWin); } } /* * This function destroys a multiple line entry field widget. */ static void _destroyCDKMentry (CDKOBJS *object) { if (object != 0) { CDKMENTRY *mentry = (CDKMENTRY *)object; cleanCdkTitle (object); freeChtype (mentry->label); freeChar (mentry->info); /* Clean up the windows. */ deleteCursesWindow (mentry->fieldWin); deleteCursesWindow (mentry->labelWin); deleteCursesWindow (mentry->shadowWin); deleteCursesWindow (mentry->win); /* Clean the key bindings. */ cleanCDKObjectBindings (vMENTRY, mentry); /* Unregister this object. */ unregisterCDKObject (vMENTRY, mentry); } } /* * This sets multiple attributes of the widget. */ void setCDKMentry (CDKMENTRY *mentry, char *value, int min, boolean Box) { setCDKMentryValue (mentry, value); setCDKMentryMin (mentry, min); setCDKMentryBox (mentry, Box); } /* * This removes the old information in the entry field and keeps the * new information given. */ void setCDKMentryValue (CDKMENTRY *mentry, char *newValue) { int fieldCharacters = mentry->rows * mentry->fieldWidth; int len = 0; int copychars = 0; int rowsUsed; /* 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 (mentry->info, mentry->totalWidth, '\0'); return; } /* Determine how many characters we need to copy. */ len = (int)strlen (newValue); copychars = (len < mentry->totalWidth ? len : mentry->totalWidth); /* OK, erase the old value, and copy in the new value. */ cleanChar (mentry->info, mentry->totalWidth, '\0'); strncpy (mentry->info, newValue, copychars); /* Set the cursor/row info. */ if (len < fieldCharacters) { mentry->topRow = 0; mentry->currentRow = len / mentry->fieldWidth; mentry->currentCol = len % mentry->fieldWidth; } else { rowsUsed = len / mentry->fieldWidth; mentry->topRow = rowsUsed - mentry->rows + 1; mentry->currentRow = mentry->rows - 1; mentry->currentCol = len % mentry->fieldWidth; } /* Redraw the widget. */ drawCDKMentryField (mentry); } char *getCDKMentryValue (CDKMENTRY *mentry) { return mentry->info; } /* * This sets the filler character to use when drawing the widget. */ void setCDKMentryFillerChar (CDKMENTRY *mentry, chtype filler) { mentry->filler = filler; } chtype getCDKMentryFillerChar (CDKMENTRY *mentry) { return mentry->filler; } /* * This sets the character to use when a hidden character type is used. */ void setCDKMentryHiddenChar (CDKMENTRY *mentry, chtype character) { mentry->hidden = character; } chtype getCDKMentryHiddenChar (CDKMENTRY *mentry) { return mentry->hidden; } /* * This sets the minimum length of the widget. */ void setCDKMentryMin (CDKMENTRY *mentry, int min) { mentry->min = min; } int getCDKMentryMin (CDKMENTRY *mentry) { return mentry->min; } /* * This sets the widgets box attribute. */ void setCDKMentryBox (CDKMENTRY *mentry, boolean Box) { ObjOf (mentry)->box = Box; ObjOf (mentry)->borderSize = Box ? 1 : 0; } boolean getCDKMentryBox (CDKMENTRY *mentry) { return ObjOf (mentry)->box; } /* * This erases the information in the multiple line entry widget. */ void cleanCDKMentry (CDKMENTRY *mentry) { cleanChar (mentry->info, mentry->totalWidth, '\0'); mentry->currentRow = 0; mentry->currentCol = 0; mentry->topRow = 0; } /* * This sets the callback function. */ void setCDKMentryCB (CDKMENTRY *mentry, MENTRYCB callback) { mentry->callbackfn = callback; } static void _focusCDKMentry (CDKOBJS *object) { CDKMENTRY *mentry = (CDKMENTRY *)object; wmove (mentry->fieldWin, 0, mentry->currentCol); wrefresh (mentry->fieldWin); } static void _unfocusCDKMentry (CDKOBJS *object) { CDKMENTRY *mentry = (CDKMENTRY *)object; wrefresh (mentry->fieldWin); } dummyRefreshData (Mentry) dummySaveData (Mentry) cdk-5.0-20060507/menu.c0000644000175100001440000003450410426516000012647 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:27:44 $ * $Revision: 1.98 $ */ #define TITLELINES 1 /* * Declare file local prototypes. */ static void cleanUpMenu (CDKMENU *menu); DeclareCDKObjects (MENU, Menu, setCdk, Int); /* * This creates a new menu widget. */ CDKMENU *newCDKMenu (CDKSCREEN *cdkscreen, char *menulist[MAX_MENU_ITEMS][MAX_SUB_ITEMS], int menuItems, int *subsize, int *menuLocation, int menuPos, chtype titleAttr, chtype subtitleAttr) { CDKMENU *menu = 0; int rightcount = menuItems - 1; int rightloc = getmaxx (cdkscreen->window); int leftloc = 0; int x, y, max, junk; int xpos = getbegx (cdkscreen->window); int ypos = getbegy (cdkscreen->window); int ymax = getmaxy (cdkscreen->window); if ((menu = newCDKObject (CDKMENU, &my_funcs)) == 0) return (0); /* Start making a copy of the information. */ ScreenOf (menu) = cdkscreen; ObjOf (menu)->box = FALSE; ObjOf (menu)->acceptsFocus = FALSE; rightcount = menuItems-1; menu->parent = cdkscreen->window; menu->menuItems = menuItems; menu->titleAttr = titleAttr; menu->subtitleAttr = subtitleAttr; menu->currentTitle = 0; menu->currentSubtitle = 0; menu->lastSelection = -1; menu->menuPos = menuPos; initExitType (menu); /* Create the pull down menus. */ for (x = 0; x < menuItems; x++) { int x1 = (menuLocation[x] == LEFT) ? x : rightcount--; int x2; int y1 = (menuPos == BOTTOM) ? (ymax - 1) : 0; int y2 = (menuPos == BOTTOM) ? (ymax - subsize[x] - 2) : TITLELINES; int high = subsize[x] + TITLELINES; /* * Limit the menu height to fit on the screen. */ if (high + y2 > ymax) { high = ymax - TITLELINES; } max = -1; for (y = TITLELINES; y < subsize[x]; y++) { int y0 = y - TITLELINES; menu->sublist[x1][y0] = char2Chtype (menulist[x][y], &menu->sublistLen[x1][y0], &junk); max = MAXIMUM (max, menu->sublistLen[x1][y0]); } if (menuLocation[x] == LEFT) { x2 = leftloc; } else { x2 = (rightloc -= max + 2); } menu->title[x1] = char2Chtype (menulist[x][0], &menu->titleLen[x1], &junk); menu->subsize[x1] = subsize[x] - TITLELINES; menu->titleWin[x1] = subwin (cdkscreen->window, TITLELINES, menu->titleLen[x1]+2, ypos + y1, xpos + x2); menu->pullWin[x1] = subwin (cdkscreen->window, high, max+2, ypos + y2, xpos + x2); if (menu->titleWin[x1] == 0 || menu->pullWin[x1] == 0) { destroyCDKMenu (menu); return (0); } leftloc += menu->titleLen[x] + 1; keypad (menu->titleWin[x1], TRUE); keypad (menu->pullWin[x1], TRUE); } ObjOf (menu)->inputWindow = menu->titleWin[menu->currentTitle]; /* Register this baby. */ registerCDKObject (cdkscreen, vMENU, menu); /* Return the menu object. */ return (menu); } /* * This activates the CDK Menu. */ int activateCDKMenu (CDKMENU *menu, chtype *actions) { chtype input; boolean functionKey; int ret; /* Draw in the screen. */ refreshCDKScreen (ScreenOf (menu)); /* Display the menu titles. */ drawCDKMenu (menu, ObjOf (menu)->box); /* Highlight the current title and window. */ drawCDKMenuSubwin (menu); /* If the input string is null, this is an interactive activate. */ if (actions == 0) { ObjOf (menu)->inputWindow = menu->titleWin[menu->currentTitle]; /* Start taking input from the keyboard. */ for (;;) { input = getchCDKObject (ObjOf (menu), &functionKey); /* Inject the character into the widget. */ ret = injectCDKMenu (menu, input); if (menu->exitType != vEARLY_EXIT) { return ret; } } } else { int count = chlen (actions); int x = 0; for (x = 0; x < count; x++) { ret = injectCDKMenu (menu, actions[x]); if (menu->exitType != vEARLY_EXIT) { return ret; } } } /* Set the exit type and return. */ setExitType (menu, 0); return -1; } /* * The "%" operator is simpler but does not handle negative values. */ static int wrapped (int within, int limit) { if (within < 0) within = limit - 1; else if (within >= limit) within = 0; return within; } static void drawTitle (CDKMENU *menu, int item) { writeChtype (menu->titleWin[item], 0, 0, menu->title[item], HORIZONTAL, 0, menu->titleLen[item]); } static void drawItem (CDKMENU *menu, int item, int offset) { writeChtype (menu->pullWin[menu->currentTitle], 1, item + TITLELINES - offset, menu->sublist[menu->currentTitle][item], HORIZONTAL, 0, menu->sublistLen[menu->currentTitle][item]); } /* Highlight the current sub-menu item. */ static void selectItem (CDKMENU *menu, int item, int offset) { writeChtypeAttrib (menu->pullWin[menu->currentTitle], 1, item + TITLELINES - offset, menu->sublist[menu->currentTitle][item], menu->subtitleAttr, HORIZONTAL, 0, menu->sublistLen[menu->currentTitle][item]); } static void withinSubmenu (CDKMENU *menu, int step) { int next = wrapped (menu->currentSubtitle + step, menu->subsize[menu->currentTitle]); if (next != menu->currentSubtitle) { CDKSCREEN *screen = ScreenOf (menu); int ymax = getmaxy (screen->window); if ((1 + getbegy (menu->pullWin[menu->currentTitle]) + menu->subsize[menu->currentTitle]) >= ymax) { menu->currentSubtitle = next; drawCDKMenuSubwin (menu); } else { /* Erase the old subtitle. */ drawItem (menu, menu->currentSubtitle, 0); /* Set the values. */ menu->currentSubtitle = next; /* Draw the new sub-title. */ selectItem (menu, menu->currentSubtitle, 0); wrefresh (menu->pullWin[menu->currentTitle]); } ObjOf (menu)->inputWindow = menu->titleWin[menu->currentTitle]; } } static void acrossSubmenus (CDKMENU *menu, int step) { int next = wrapped (menu->currentTitle + step, menu->menuItems); if (next != menu->currentTitle) { /* Erase the menu sub-window. */ eraseCDKMenuSubwin (menu); refreshCDKScreen (ScreenOf (menu)); /* Set the values. */ menu->currentTitle = next; menu->currentSubtitle = 0; /* Draw the new menu sub-window. */ drawCDKMenuSubwin (menu); ObjOf (menu)->inputWindow = menu->titleWin[menu->currentTitle]; } } /* * Inject a character into the menu widget. */ static int _injectCDKMenu (CDKOBJS *object, chtype input) { CDKMENU *menu = (CDKMENU *)object; int ppReturn = 1; int ret = unknownInt; bool complete = FALSE; /* Set the exit type. */ setExitType (menu, 0); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf (menu) != 0) { /* Call the pre-process function. */ ppReturn = PreProcessFuncOf (menu) (vMENU, menu, PreProcessDataOf (menu), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check for key bindings. */ if (checkCDKObjectBind (vMENU, menu, input) != 0) { checkEarlyExit (menu); complete = TRUE; } else { switch (input) { case KEY_LEFT: acrossSubmenus (menu, -1); break; case KEY_RIGHT: case KEY_TAB: acrossSubmenus (menu, 1); break; case KEY_UP: withinSubmenu (menu, -1); break; case KEY_DOWN: case SPACE: withinSubmenu (menu, 1); break; case KEY_ENTER: cleanUpMenu (menu); setExitType (menu, input); menu->lastSelection = ((menu->currentTitle * 100) + menu->currentSubtitle); ret = menu->lastSelection; complete = TRUE; break; case KEY_ESC: cleanUpMenu (menu); setExitType (menu, input); menu->lastSelection = -1; ret = menu->lastSelection; complete = TRUE; break; case CDK_REFRESH: eraseCDKScreen (ScreenOf (menu)); refreshCDKScreen (ScreenOf (menu)); break; } } /* Should we call a post-process? */ if (!complete && (PostProcessFuncOf (menu) != 0)) { PostProcessFuncOf (menu) (vMENU, menu, PostProcessDataOf (menu), input); } } if (!complete) { setExitType (menu, 0); } ResultOf (menu).valueInt = ret; return (ret != unknownInt); } /* * Draw a menu item subwindow. */ void drawCDKMenuSubwin (CDKMENU *menu) { int x; int high = getmaxy (menu->pullWin[menu->currentTitle]) - 2; int x0 = 0; int x1 = menu->subsize[menu->currentTitle]; if (x1 > high) x1 = high; if (menu->currentSubtitle >= x1) { x0 = (menu->currentSubtitle - x1) + 1; x1 += x0; } /* Box the window. */ werase (menu->pullWin[menu->currentTitle]); box (menu->pullWin[menu->currentTitle], ACS_VLINE, ACS_HLINE); if (menu->menuPos == BOTTOM) { mvwaddch (menu->pullWin[menu->currentTitle], menu->subsize[menu->currentTitle] + 1, 0, ACS_LTEE); } else { mvwaddch (menu->pullWin[menu->currentTitle], 0, 0, ACS_LTEE); } /* Draw the items. */ for (x = x0; x < x1; x++) { drawItem (menu, x, x0); } selectItem (menu, menu->currentSubtitle, x0); wrefresh (menu->pullWin[menu->currentTitle]); /* Highlight the title. */ writeChtypeAttrib (menu->titleWin[menu->currentTitle], 0, 0, menu->title[menu->currentTitle], menu->titleAttr, HORIZONTAL, 0, menu->titleLen[menu->currentTitle]); wrefresh (menu->titleWin[menu->currentTitle]); } /* * Erase a menu item subwindow. */ void eraseCDKMenuSubwin (CDKMENU *menu) { eraseCursesWindow (menu->pullWin[menu->currentTitle]); /* Redraw the sub-menu title. */ drawTitle (menu, menu->currentTitle); wrefresh (menu->titleWin[menu->currentTitle]); } /* * Draw the menu. */ static void _drawCDKMenu (CDKOBJS *object, boolean Box GCC_UNUSED) { CDKMENU *menu = (CDKMENU *)object; int x; /* Draw in the menu titles. */ for (x = 0; x < menu->menuItems; x++) { drawTitle (menu, x); wrefresh (menu->titleWin[x]); } } /* * Move the menu to the given location. */ static void _moveCDKMenu (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDKMENU *menu = (CDKMENU *)object; int currentX = getbegx (WindowOf (menu)); int currentY = getbegy (WindowOf (menu)); int xpos = xplace; int ypos = yplace; int xdiff = 0; int ydiff = 0; int x; /* * If this is a relative move, then we will adjust where we want * to move to. */ if (relative) { xpos = getbegx (WindowOf (menu)) + xplace; ypos = getbegy (WindowOf (menu)) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf (menu), &xpos, &ypos, getmaxx (WindowOf (menu)), getmaxy (WindowOf (menu))); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the windows to the new location. */ moveCursesWindow (WindowOf (menu), -xdiff, -ydiff); for (x = 0; x < menu->menuItems; x++) { moveCursesWindow (menu->titleWin[x], -xdiff, -ydiff); } /* Touch the windows so they 'move'. */ refreshCDKWindow (WindowOf (menu)); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDKMenu (menu, ObjOf (menu)->box); } } /* * Set the background attribute of the widget. */ static void _setBKattrMenu (CDKOBJS *object, chtype attrib) { if (object != 0) { CDKMENU *widget = (CDKMENU *)object; int x; for (x = 0; x < widget->menuItems; x++) { wbkgd (widget->titleWin[x], attrib); wbkgd (widget->pullWin[x], attrib); } } } /* * Destroy a menu widget. */ static void _destroyCDKMenu (CDKOBJS *object) { if (object != 0) { CDKMENU *menu = (CDKMENU *)object; int x, y; /* Clean up both the winodws and the char pointers. */ for (x = 0; x < menu->menuItems; x++) { /* Clean the windows. */ deleteCursesWindow (menu->titleWin[x]); deleteCursesWindow (menu->pullWin[x]); /* Delete the character pointers. */ freeChtype (menu->title[x]); for (y = 0; y < menu->subsize[x]; y++) { freeChtype (menu->sublist[x][y]); } } /* Clean the key bindings. */ cleanCDKObjectBindings (vMENU, menu); /* Unregister this object. */ unregisterCDKObject (vMENU, menu); } } /* * Erase the menu widget from the screen. */ static void _eraseCDKMenu (CDKOBJS *object) { if (validCDKObject (object)) { CDKMENU *menu = (CDKMENU *)object; int x = 0; for (x = 0; x < menu->menuItems; x++) { werase (menu->titleWin[x]); wrefresh (menu->titleWin[x]); werase (menu->pullWin[x]); wrefresh (menu->pullWin[x]); } } } /* * Set multiple features of the menu. */ void setCDKMenu (CDKMENU *menu, int menuItem, int subMenuItem, chtype titleHighlight, chtype subTitleHighlight) { setCDKMenuCurrentItem (menu, menuItem, subMenuItem); setCDKMenuTitleHighlight (menu, titleHighlight); setCDKMenuSubTitleHighlight (menu, subTitleHighlight); } /* * Set the current menu item to highlight. */ void setCDKMenuCurrentItem (CDKMENU *menu, int menuitem, int submenuitem) { menu->currentTitle = wrapped (menuitem, menu->menuItems); menu->currentSubtitle = wrapped (submenuitem, menu->subsize[menu->currentTitle]); } void getCDKMenuCurrentItem (CDKMENU *menu, int *menuItem, int *subMenuItem) { (*menuItem) = menu->currentTitle; (*subMenuItem) = menu->currentSubtitle; } /* * Set the attribute of the menu titles. */ void setCDKMenuTitleHighlight (CDKMENU *menu, chtype highlight) { menu->titleAttr = highlight; } chtype getCDKMenuTitleHighlight (CDKMENU *menu) { return menu->titleAttr; } /* * Set the attribute of the sub-title. */ void setCDKMenuSubTitleHighlight (CDKMENU *menu, chtype highlight) { menu->subtitleAttr = highlight; } chtype getCDKMenuSubTitleHighlight (CDKMENU *menu) { return menu->subtitleAttr; } /* * Exit the menu. */ static void cleanUpMenu (CDKMENU *menu) { /* Erase the sub-menu. */ eraseCDKMenuSubwin (menu); wrefresh (menu->pullWin[menu->currentTitle]); /* Refresh the screen. */ refreshCDKScreen (ScreenOf (menu)); } static void _focusCDKMenu (CDKOBJS *object) { CDKMENU *menu = (CDKMENU *)object; drawCDKMenuSubwin (menu); ObjOf (menu)->inputWindow = menu->titleWin[menu->currentTitle]; } dummyUnfocus (Menu) dummyRefreshData (Menu) dummySaveData (Menu) cdk-5.0-20060507/mkdirs.sh0000755000175100001440000000150607507401011013364 0ustar tomusers#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Last modified: 1994-03-25 # Public domain # errstatus=0 umask 022 for file in ${1+"$@"} ; do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d in ${1+"$@"} ; do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" 1>&2 case "$pathcomp" in [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]: ) ;; # DOSISH systems * ) mkdir "$pathcomp" || errstatus=$? ;; esac fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here cdk-5.0-20060507/popup_dialog.c0000644000175100001440000000145207761473651014407 0ustar tomusers#include /* * $Author: tom $ * $Date: 2003/11/27 22:16:09 $ * $Revision: 1.1 $ */ /* * This pops up a dialog box. */ int popupDialog (CDKSCREEN *screen, char **mesg, int mesgCount, char **buttons, int buttonCount) { /* Declare local variables. */ CDKDIALOG *popup = 0; int choice; /* Create the dialog box. */ popup = newCDKDialog (screen, CENTER, CENTER, mesg, mesgCount, buttons, buttonCount, A_REVERSE, TRUE, TRUE, FALSE); /* Activate the dialog box */ drawCDKDialog (popup, TRUE); /* Get the choice. */ choice = activateCDKDialog (popup, 0); /* Destroy the dialog box. */ destroyCDKDialog (popup); /* Clean the screen. */ eraseCDKScreen (screen); refreshCDKScreen (screen); /* Return the choice. */ return choice; } cdk-5.0-20060507/popup_label.c0000644000175100001440000000263510355076265014224 0ustar tomusers#include /* * $Author: tom $ * $Date: 2005/12/30 00:17:57 $ * $Revision: 1.2 $ */ /* * This pops up a message. */ void popupLabel (CDKSCREEN *screen, char **mesg, int count) { CDKLABEL *popup = 0; int oldCursState; boolean functionKey; /* Create the label. */ popup = newCDKLabel (screen, CENTER, CENTER, mesg, count, TRUE, FALSE); oldCursState = curs_set(0); /* Draw it on the screen. */ drawCDKLabel (popup, TRUE); /* Wait for some input. */ keypad (popup->win, TRUE); getchCDKObject (ObjOf(popup), &functionKey); /* Kill it. */ destroyCDKLabel (popup); /* Clean the screen. */ curs_set(oldCursState); eraseCDKScreen (screen); refreshCDKScreen (screen); } /* * This pops up a message. */ void popupLabelAttrib (CDKSCREEN *screen, char **mesg, int count, chtype attrib) { CDKLABEL *popup = 0; int oldCursState; boolean functionKey; /* Create the label. */ popup = newCDKLabel (screen, CENTER, CENTER, mesg, count, TRUE, FALSE); setCDKLabelBackgroundAttrib(popup, attrib); oldCursState = curs_set(0); /* Draw it on the screen. */ drawCDKLabel (popup, TRUE); /* Wait for some input. */ keypad (popup->win, TRUE); getchCDKObject (ObjOf(popup), &functionKey); /* Kill it. */ destroyCDKLabel (popup); /* Clean the screen. */ curs_set(oldCursState); eraseCDKScreen (screen); refreshCDKScreen (screen); } cdk-5.0-20060507/position.c0000644000175100001440000000537710355077404013570 0ustar tomusers#include /* * $Author: tom $ * $Date: 2005/12/30 00:27:48 $ * $Revision: 1.11 $ */ #undef ObjOf #define ObjOf(ptr) (ptr) /* * This allows the user to use the cursor keys to adjust the * position of the widget. */ void positionCDKObject (CDKOBJS *obj, WINDOW *win) { CDKSCREEN *screen = ScreenOf(obj); WINDOW *parent = screen->window; int origX = getbegx(win); int origY = getbegy(win); int begX = getbegx(parent); int begY = getbegy(parent); int endX = begX + getmaxx(WindowOf(obj)); int endY = begY + getmaxy(WindowOf(obj)); chtype key; boolean functionKey; /* Let them move the widget around until they hit return. */ while ((key = getchCDKObject(obj, &functionKey)) != KEY_ENTER) { switch (key) { case KEY_UP: case '8': if (getbegy(win) > begY) { moveCDKObject (obj, 0, -1, TRUE, TRUE); } else { Beep(); } break; case KEY_DOWN: case '2': if (getendy(win) < endY) { moveCDKObject (obj, 0, 1, TRUE, TRUE); } else { Beep(); } break; case KEY_LEFT: case '4': if (getbegx(win) > begX) { moveCDKObject (obj, -1, 0, TRUE, TRUE); } else { Beep(); } break; case KEY_RIGHT: case '6': if (getendx(win) < endX) { moveCDKObject (obj, 1, 0, TRUE, TRUE); } else { Beep(); } break; case '7': if (getbegy(win) > begY && getbegx(win) > begX) { moveCDKObject (obj, -1, -1, TRUE, TRUE); } else { Beep(); } break; case '9': if (getendx(win) < endX && getbegy(win) > begY) { moveCDKObject (obj, 1, -1, TRUE, TRUE); } else { Beep(); } break; case '1': if (getbegx(win) > begX && getendy(win) < endY) { moveCDKObject (obj, -1, 1, TRUE, TRUE); } else { Beep(); } break; case '3': if (getendx(win) < endX && getendy(win) < endY) { moveCDKObject (obj, 1, 1, TRUE, TRUE); } else { Beep(); } break; case '5': moveCDKObject (obj, CENTER, CENTER, FALSE, TRUE); break; case 't': moveCDKObject (obj, getbegx(win), TOP, FALSE, TRUE); break; case 'b': moveCDKObject (obj, getbegx(win), BOTTOM, FALSE, TRUE); break; case 'l': moveCDKObject (obj, LEFT, getbegy(win), FALSE, TRUE); break; case 'r': moveCDKObject (obj, RIGHT, getbegy(win), FALSE, TRUE); break; case 'c': moveCDKObject (obj, CENTER, getbegy(win), FALSE, TRUE); break; case 'C': moveCDKObject (obj, getbegx(win), CENTER, FALSE, TRUE); break; case CDK_REFRESH: eraseCDKScreen (ScreenOf(obj)); refreshCDKScreen (ScreenOf(obj)); break; case KEY_ESC: moveCDKObject (obj, origX, origY, FALSE, TRUE); break; default: Beep(); break; } } } cdk-5.0-20060507/radio.c0000644000175100001440000004401210355077556013017 0ustar tomusers#include /* * $Author: tom $ * $Date: 2005/12/30 00:29:34 $ * $Revision: 1.130 $ */ /* * Declare file local prototypes. */ static int createList (CDKRADIO *radio, char **list, int listSize, int width); static void drawCDKRadioList (CDKRADIO *radio, boolean Box); static void setViewSize(CDKRADIO *scrollp, int listSize); static int maxViewSize(CDKRADIO *scrollp); /* Determine how many characters we can shift to the right */ /* before all the items have been scrolled off the screen. */ #define AvailableWidth(w) ((w)->boxWidth - 2*BorderOf(w) - 3) #define updateViewWidth(w, widest) \ (w)->maxLeftChar = (((w)->boxWidth > widest) \ ? 0 \ : (widest - AvailableWidth(w))) #define WidestItem(w) ((w)->maxLeftChar + AvailableWidth(w)) #define SCREENPOS(w,n) (w)->itemPos[n] - (w)->leftChar + scrollbarAdj + BorderOf(w) DeclareCDKObjects(RADIO, Radio, setCdk, Int); /* * This function creates the radio widget. */ CDKRADIO *newCDKRadio (CDKSCREEN *cdkscreen, int xplace, int yplace, int splace, int height, int width, char *title, char **list, int listSize, chtype choiceChar, int defItem, chtype highlight, boolean Box, boolean shadow) { CDKRADIO *radio = 0; int parentWidth = getmaxx(cdkscreen->window); int parentHeight = getmaxy(cdkscreen->window); int boxWidth = width; int boxHeight = height; int xpos = xplace; int ypos = yplace; int widestItem = 0; int j; static const struct { int from; int to; } bindings[] = { { CDK_BACKCHAR, KEY_PPAGE }, { CDK_FORCHAR, KEY_NPAGE }, { 'g', KEY_HOME }, { '1', KEY_HOME }, { 'G', KEY_END }, { '<', KEY_HOME }, { '>', KEY_END }, }; if ((radio = newCDKObject(CDKRADIO, &my_funcs)) == 0) { return (0); } setCDKRadioBox (radio, 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, 5); boxWidth = setCdkTitle(ObjOf(radio), title, boxWidth); /* Set the box height. */ if (TitleLinesOf(radio) > boxHeight) { boxHeight = TitleLinesOf(radio) + MINIMUM(listSize, 8) + 2 * BorderOf(radio); } /* Adjust the box width if there is a scroll bar. */ if (splace == LEFT || splace == RIGHT) { boxWidth++; radio->scrollbar = TRUE; } else { radio->scrollbar = FALSE; } /* * Make sure we didn't extend beyond the dimensions of the window. */ radio->boxWidth = MINIMUM(boxWidth, parentWidth); radio->boxHeight = MINIMUM(boxHeight, parentHeight); setViewSize(radio, listSize); /* Each item in the needs to be converted to chtype * */ widestItem = createList(radio, list, listSize, radio->boxWidth); if (widestItem > 0) { updateViewWidth(radio, widestItem); } else if (listSize) { destroyCDKObject(radio); return (0); } /* Rejustify the x and y positions if we need to. */ alignxy (cdkscreen->window, &xpos, &ypos, radio->boxWidth, radio->boxHeight); /* Make the radio window */ radio->win = newwin (radio->boxHeight, radio->boxWidth, ypos, xpos); /* Is the window null??? */ if (radio->win == 0) { destroyCDKObject(radio); return (0); } /* Turn on the keypad. */ keypad (radio->win, TRUE); /* Create the scrollbar window. */ if (splace == RIGHT) { radio->scrollbarWin = subwin (radio->win, maxViewSize(radio), 1, SCREEN_YPOS(radio, ypos), xpos + radio->boxWidth - BorderOf(radio) - 1); } else if (splace == LEFT) { radio->scrollbarWin = subwin (radio->win, maxViewSize(radio), 1, SCREEN_YPOS(radio, ypos), SCREEN_XPOS(radio, xpos)); } else { radio->scrollbarWin = 0; } /* Set the rest of the variables */ ScreenOf(radio) = cdkscreen; radio->parent = cdkscreen->window; radio->scrollbarPlacement = splace; radio->widestItem = widestItem; radio->leftChar = 0; radio->selectedItem = 0; radio->highlight = highlight; radio->choiceChar = choiceChar; radio->leftBoxChar = (chtype)'['; radio->rightBoxChar = (chtype)']'; radio->defItem = defItem; initExitType(radio); ObjOf(radio)->inputWindow = radio->win; ObjOf(radio)->acceptsFocus = TRUE; radio->shadow = shadow; setCDKRadioCurrentItem(radio, 0); /* Do we need to create the shadow??? */ if (shadow) { radio->shadowWin = newwin (boxHeight, boxWidth + 1, ypos + 1, xpos + 1); } /* Setup the key bindings. */ for (j = 0; j < (int) SIZEOF(bindings); ++j) bindCDKObject (vRADIO, radio, bindings[j].from, getcCDKBind, (void *)(long)bindings[j].to); /* Register this baby. */ registerCDKObject (cdkscreen, vRADIO, radio); /* Return the radio list */ return (radio); } /* * Put the cursor on the currently-selected item. */ static void fixCursorPosition (CDKRADIO *widget) { int scrollbarAdj = (widget->scrollbarPlacement == LEFT) ? 1 : 0; int ypos = SCREEN_YPOS(widget, widget->currentItem - widget->currentTop); int xpos = SCREEN_XPOS(widget, 0) + scrollbarAdj; wmove(InputWindowOf(widget), ypos, xpos); wrefresh(InputWindowOf(widget)); } /* * This actually manages the radio widget. */ int activateCDKRadio (CDKRADIO *radio, chtype *actions) { /* Draw the radio list. */ drawCDKRadio (radio, ObjOf(radio)->box); if (actions == 0) { chtype input; boolean functionKey; int ret; for (;;) { fixCursorPosition (radio); input = getchCDKObject (ObjOf(radio), &functionKey); /* Inject the character into the widget. */ ret = injectCDKRadio (radio, input); if (radio->exitType != vEARLY_EXIT) { return ret; } } } else { int length = chlen (actions); int j, ret; /* Inject each character one at a time. */ for (j=0; j < length; j++) { ret = injectCDKRadio (radio, actions[j]); if (radio->exitType != vEARLY_EXIT) { return ret; } } } /* Set the exit type and return. */ setExitType(radio, 0); return -1; } /* * This injects a single character into the widget. */ static int _injectCDKRadio (CDKOBJS *object, chtype input) { CDKRADIO *radio = (CDKRADIO *)object; int ppReturn = 1; int ret = unknownInt; bool complete = FALSE; /* Set the exit type. */ setExitType(radio, 0); /* Draw the radio list */ drawCDKRadioList (radio, ObjOf(radio)->box); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf(radio) != 0) { /* Call the pre-process function. */ ppReturn = PreProcessFuncOf(radio) (vRADIO, radio, PreProcessDataOf(radio), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check for a predefined key binding. */ if (checkCDKObjectBind (vRADIO, radio, input) != 0) { checkEarlyExit(radio); complete = TRUE; } else { switch (input) { case KEY_UP : scroller_KEY_UP(radio); break; case KEY_DOWN : scroller_KEY_DOWN(radio); break; case KEY_RIGHT : scroller_KEY_RIGHT(radio); break; case KEY_LEFT : scroller_KEY_LEFT(radio); break; case KEY_PPAGE : scroller_KEY_PPAGE(radio); break; case KEY_NPAGE : scroller_KEY_NPAGE(radio); break; case KEY_HOME : scroller_KEY_HOME(radio); break; case KEY_END : scroller_KEY_END(radio); break; case '$' : radio->leftChar = radio->maxLeftChar; break; case '|' : radio->leftChar = 0; break; case SPACE : radio->selectedItem = radio->currentItem; break; case KEY_ESC : setExitType(radio, input); ret = -1; complete = TRUE; break; case KEY_TAB : case KEY_ENTER : setExitType(radio, input); ret = radio->selectedItem; complete = TRUE; break; case CDK_REFRESH : eraseCDKScreen (ScreenOf(radio)); refreshCDKScreen (ScreenOf(radio)); break; default : break; } } /* Should we call a post-process? */ if (!complete && (PostProcessFuncOf(radio) != 0)) { PostProcessFuncOf(radio) (vRADIO, radio, PostProcessDataOf(radio), input); } } if (!complete) { drawCDKRadioList (radio, ObjOf(radio)->box); setExitType(radio, 0); } fixCursorPosition (radio); ResultOf(radio).valueInt = ret; return (ret != unknownInt); } /* * This moves the radio field to the given location. */ static void _moveCDKRadio (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDKRADIO *radio = (CDKRADIO *)object; int currentX = getbegx(radio->win); int currentY = getbegy(radio->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(radio->win) + xplace; ypos = getbegy(radio->win) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf(radio), &xpos, &ypos, radio->boxWidth, radio->boxHeight); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the window to the new location. */ moveCursesWindow(radio->win, -xdiff, -ydiff); moveCursesWindow(radio->scrollbarWin, -xdiff, -ydiff); moveCursesWindow(radio->shadowWin, -xdiff, -ydiff); /* Touch the windows so they 'move'. */ refreshCDKWindow (WindowOf(radio)); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDKRadio (radio, ObjOf(radio)->box); } } static int maxViewSize(CDKRADIO *widget) { return scroller_MaxViewSize(widget); } /* * Set variables that depend upon the list-size. */ static void setViewSize(CDKRADIO *widget, int listSize) { scroller_SetViewSize(widget, listSize); } /* * This function draws the radio widget. */ static void _drawCDKRadio (CDKOBJS *object, boolean Box GCC_UNUSED) { CDKRADIO *radio = (CDKRADIO *)object; /* Do we need to draw in the shadow??? */ if (radio->shadowWin != 0) { drawShadow (radio->shadowWin); } drawCdkTitle (radio->win, object); /* Draw in the radio list. */ drawCDKRadioList (radio, ObjOf(radio)->box); } /* * This redraws the radio list. */ static void drawCDKRadioList (CDKRADIO *radio, boolean Box) { int scrollbarAdj = (radio->scrollbarPlacement == LEFT) ? 1 : 0; int screenPos = 0; int j; int xpos, ypos; /* draw the list */ for (j=0; j < radio->viewSize; j++) { xpos = SCREEN_XPOS(radio, 0); ypos = SCREEN_YPOS(radio, j); screenPos = SCREENPOS(radio, j + radio->currentTop); /* Draw the empty string. */ writeBlanks (radio->win, xpos, ypos, HORIZONTAL, 0, radio->boxWidth - BorderOf(radio)); /* Draw the line. */ writeChtype (radio->win, (screenPos >= 0) ? screenPos : 1, ypos, radio->item[j + radio->currentTop], HORIZONTAL, (screenPos >= 0) ? 0 : (1 - screenPos), radio->itemLen[j + radio->currentTop]); /* Draw the selected choice... */ xpos += scrollbarAdj; mvwaddch (radio->win, ypos, xpos++, radio->leftBoxChar); mvwaddch (radio->win, ypos, xpos++, ((j + radio->currentTop) == radio->selectedItem) ? radio->choiceChar : ' '); mvwaddch (radio->win, ypos, xpos++, radio->rightBoxChar); } /* Highlight the current item. */ if (ObjPtr(radio)->hasFocus) { screenPos = SCREENPOS(radio, radio->currentItem); ypos = SCREEN_YPOS(radio, radio->currentHigh); writeChtypeAttrib (radio->win, (screenPos >= 0) ? screenPos : (1 + scrollbarAdj), ypos, radio->item[radio->currentItem], radio->highlight, HORIZONTAL, (screenPos >= 0) ? 0 : (1 - screenPos), radio->itemLen[radio->currentItem]); } if (radio->scrollbar) { radio->togglePos = floorCDK(radio->currentItem * radio->step); radio->togglePos = MINIMUM(radio->togglePos, getmaxy(radio->scrollbarWin) - 1); mvwvline (radio->scrollbarWin, 0, 0, ACS_CKBOARD, getmaxy(radio->scrollbarWin)); mvwvline (radio->scrollbarWin, radio->togglePos, 0, ' ' | A_REVERSE, radio->toggleSize); } /* Box it if needed. */ if (Box) { drawObjBox (radio->win, ObjOf(radio)); } fixCursorPosition (radio); } /* * This sets the background attribute of the widget. */ static void _setBKattrRadio (CDKOBJS *object, chtype attrib) { if (object != 0) { CDKRADIO *widget = (CDKRADIO *) object; wbkgd (widget->win, attrib); if (widget->scrollbarWin != 0) { wbkgd (widget->scrollbarWin, attrib); } } } static void destroyInfo(CDKRADIO *widget) { CDKfreeChtypes (widget->item); widget->item = 0; freeAndNull (widget->itemLen); freeAndNull (widget->itemPos); } /* * This function destroys the radio widget. */ static void _destroyCDKRadio (CDKOBJS *object) { if (object != 0) { CDKRADIO *radio = (CDKRADIO *)object; cleanCdkTitle (object); destroyInfo (radio); /* Clean up the windows. */ deleteCursesWindow (radio->scrollbarWin); deleteCursesWindow (radio->shadowWin); deleteCursesWindow (radio->win); /* Clean the key bindings. */ cleanCDKObjectBindings (vRADIO, radio); /* Unregister this object. */ unregisterCDKObject (vRADIO, radio); } } /* * This function erases the radio widget. */ static void _eraseCDKRadio (CDKOBJS *object) { if (validCDKObject (object)) { CDKRADIO *radio = (CDKRADIO *)object; eraseCursesWindow (radio->win); eraseCursesWindow (radio->shadowWin); } } /* * This set various attributes of the radio list. */ void setCDKRadio (CDKRADIO *radio, chtype highlight, chtype choiceChar, int Box) { setCDKRadioHighlight (radio, highlight); setCDKRadioChoiceCharacter (radio, choiceChar); setCDKRadioBox (radio, Box); } /* * This sets the radio list items. */ void setCDKRadioItems (CDKRADIO *radio, char **list, int listSize) { int widestItem = -1; int j = 0; widestItem = createList(radio, list, listSize, radio->boxWidth); if (widestItem <= 0) return; /* Clean up the display. */ for (j=0; j < radio->viewSize ; j++) { writeBlanks (radio->win, SCREEN_XPOS(radio, 0), SCREEN_YPOS(radio, j), HORIZONTAL, 0, radio->boxWidth - BorderOf(radio)); } setViewSize(radio, listSize); setCDKRadioCurrentItem(radio, 0); radio->leftChar = 0; radio->selectedItem = 0; updateViewWidth(radio, widestItem); } int getCDKRadioItems (CDKRADIO *radio, char **list) { int j; if (list != 0) { for (j=0; j < radio->listSize; j++) { list[j] = chtype2Char (radio->item[j]); } } return radio->listSize; } /* * This sets the highlight bar of the radio list. */ void setCDKRadioHighlight (CDKRADIO *radio, chtype highlight) { radio->highlight = highlight; } chtype getCDKRadioHighlight (CDKRADIO *radio) { return radio->highlight; } /* * This sets the character to use when selecting an item in the list. */ void setCDKRadioChoiceCharacter (CDKRADIO *radio, chtype character) { radio->choiceChar = character; } chtype getCDKRadioChoiceCharacter (CDKRADIO *radio) { return radio->choiceChar; } /* * This sets the character to use to draw the left side of the * choice box on the list. */ void setCDKRadioLeftBrace (CDKRADIO *radio, chtype character) { radio->leftBoxChar = character; } chtype getCDKRadioLeftBrace (CDKRADIO *radio) { return radio->leftBoxChar; } /* * This sets the character to use to draw the right side of the * choice box on the list. */ void setCDKRadioRightBrace (CDKRADIO *radio, chtype character) { radio->rightBoxChar = character; } chtype getCDKRadioRightBrace (CDKRADIO *radio) { return radio->rightBoxChar; } /* * This sets the box attribute of the widget. */ void setCDKRadioBox (CDKRADIO *radio, boolean Box) { ObjOf(radio)->box = Box; ObjOf(radio)->borderSize = Box ? 1 : 0; } boolean getCDKRadioBox (CDKRADIO *radio) { return ObjOf(radio)->box; } /* * This sets the current high lighted item of the widget */ void setCDKRadioCurrentItem (CDKRADIO *radio, int item) { scroller_SetPosition(radio, item); radio->selectedItem = item; } int getCDKRadioCurrentItem (CDKRADIO *radio) { return radio->currentItem; } /* * This sets the selected item of the widget */ void setCDKRadioSelectedItem (CDKRADIO *radio, int item) { radio->selectedItem = item; } int getCDKRadioSelectedItem (CDKRADIO *radio) { return radio->selectedItem; } static void _focusCDKRadio(CDKOBJS *object) { CDKRADIO *radio = (CDKRADIO *)object; drawCDKRadioList (radio, ObjOf(radio)->box); } static void _unfocusCDKRadio(CDKOBJS *object) { CDKRADIO *radio = (CDKRADIO *)object; drawCDKRadioList (radio, ObjOf(radio)->box); } static int createList (CDKRADIO *radio, char **list, int listSize, int boxWidth) { int status = 0; int widestItem = 0; if (listSize > 0) { chtype **newList = typeCallocN(chtype *, listSize + 1); int *newLen = typeCallocN(int, listSize + 1); int *newPos = typeCallocN(int, listSize + 1); int j; if (newList != 0 && newLen != 0 && newPos != 0) { /* Each item in the needs to be converted to chtype * */ status = 1; boxWidth -= (2 + BorderOf(radio)); for (j=0; j < listSize; j++) { newList[j] = char2Chtype (list[j], &newLen[j], &newPos[j]); if (newList[j] == 0) { status = 0; break; } newPos[j] = justifyString (boxWidth, newLen[j], newPos[j]) + 3; widestItem = MAXIMUM(widestItem, newLen[j]); } if (status) { destroyInfo (radio); radio->item = newList; radio->itemLen = newLen; radio->itemPos = newPos; } else { CDKfreeChtypes (newList); freeChecked (newLen); freeChecked (newPos); } } } else { destroyInfo (radio); } return status ? widestItem : 0; } dummyRefreshData(Radio) dummySaveData(Radio) cdk-5.0-20060507/scroll.c0000644000175100001440000005766110426515530013221 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:24:56 $ * $Revision: 1.146 $ */ /* * Declare file local prototypes. */ static void drawCDKScrollList (CDKSCROLL *scrollp, boolean Box); static int createCDKScrollItemList (CDKSCROLL *scrollp, boolean numbers, char **list, int listSize); static void fixCursorPosition (CDKSCROLL *widget); static void setViewSize (CDKSCROLL *scrollp, int listSize); static int maxViewSize (CDKSCROLL *scrollp); #define NUMBER_FMT "%4d. %s" #define NUMBER_LEN(s) (8 + strlen (s)) /* Determine how many characters we can shift to the right */ /* before all the items have been scrolled off the screen. */ #define AvailableWidth(w) ((w)->boxWidth - 2 * BorderOf (w)) #define updateViewWidth(w, widest) \ (w)->maxLeftChar = (((w)->boxWidth > widest) \ ? 0 \ : (widest - AvailableWidth (w))) #define WidestItem(w) ((w)->maxLeftChar + AvailableWidth (w)) #define SCREENPOS(w,n) (w)->itemPos[n] - (w)->leftChar /* + scrollbarAdj + BorderOf(w) */ DeclareCDKObjects (SCROLL, Scroll, setCdk, Int); /* * This function creates a new scrolling list widget. */ CDKSCROLL *newCDKScroll (CDKSCREEN *cdkscreen, int xplace, int yplace, int splace, int height, int width, char *title, char **list, int listSize, boolean numbers, chtype highlight, boolean Box, boolean shadow) { CDKSCROLL *scrollp = 0; int parentWidth = getmaxx (cdkscreen->window); int parentHeight = getmaxy (cdkscreen->window); int boxWidth = width; int boxHeight = height; int xpos = xplace; int ypos = yplace; int scrollAdjust = 0; int x; /* *INDENT-OFF* */ static const struct { int from; int to; } bindings[] = { { CDK_BACKCHAR, KEY_PPAGE }, { CDK_FORCHAR, KEY_NPAGE }, { 'g', KEY_HOME }, { '1', KEY_HOME }, { 'G', KEY_END }, { '<', KEY_HOME }, { '>', KEY_END }, }; /* *INDENT-ON* */ if ((scrollp = newCDKObject (CDKSCROLL, &my_funcs)) == 0) { destroyCDKObject (scrollp); return (0); } setCDKScrollBox (scrollp, 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); boxWidth = setCdkTitle (ObjOf (scrollp), title, boxWidth); /* Set the box height. */ if (TitleLinesOf (scrollp) > boxHeight) { boxHeight = (TitleLinesOf (scrollp) + MINIMUM (listSize, 8) + 2 * BorderOf (scrollp)); } /* Adjust the box width if there is a scrollp bar. */ if ((splace == LEFT) || (splace == RIGHT)) { scrollp->scrollbar = TRUE; boxWidth += 1; } else { scrollp->scrollbar = FALSE; } /* * Make sure we didn't extend beyond the dimensions of the window. */ scrollp->boxWidth = (boxWidth > parentWidth ? (parentWidth - scrollAdjust) : boxWidth); scrollp->boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight); setViewSize (scrollp, listSize); /* Rejustify the x and y positions if we need to. */ alignxy (cdkscreen->window, &xpos, &ypos, scrollp->boxWidth, scrollp->boxHeight); /* Make the scrolling window */ scrollp->win = newwin (scrollp->boxHeight, scrollp->boxWidth, ypos, xpos); /* Is the scrolling window null?? */ if (scrollp->win == 0) { destroyCDKObject (scrollp); return (0); } /* Turn the keypad on for the window. */ keypad (scrollp->win, TRUE); /* Create the scrollbar window. */ if (splace == RIGHT) { scrollp->scrollbarWin = subwin (scrollp->win, maxViewSize (scrollp), 1, SCREEN_YPOS (scrollp, ypos), xpos + scrollp->boxWidth - BorderOf (scrollp) - 1); } else if (splace == LEFT) { scrollp->scrollbarWin = subwin (scrollp->win, maxViewSize (scrollp), 1, SCREEN_YPOS (scrollp, ypos), SCREEN_XPOS (scrollp, xpos)); } else { scrollp->scrollbarWin = 0; } /* create the list window */ scrollp->listWin = subwin (scrollp->win, maxViewSize (scrollp), scrollp->boxWidth - 2 * BorderOf (scrollp) - scrollAdjust, SCREEN_YPOS (scrollp, ypos), SCREEN_XPOS (scrollp, xpos) + (splace == LEFT ? 1 : 0)); /* Set the rest of the variables */ ScreenOf (scrollp) = cdkscreen; scrollp->parent = cdkscreen->window; scrollp->shadowWin = 0; scrollp->scrollbarPlacement = splace; scrollp->maxLeftChar = 0; scrollp->leftChar = 0; scrollp->highlight = highlight; initExitType (scrollp); ObjOf (scrollp)->acceptsFocus = TRUE; ObjOf (scrollp)->inputWindow = scrollp->win; scrollp->shadow = shadow; setCDKScrollPosition (scrollp, 0); /* Create the scrolling list item list and needed variables. */ if (createCDKScrollItemList (scrollp, numbers, list, listSize) <= 0) { destroyCDKObject (scrollp); return (0); } /* Do we need to create a shadow? */ if (shadow) { scrollp->shadowWin = newwin (scrollp->boxHeight, boxWidth, ypos + 1, xpos + 1); } /* Setup the key bindings. */ for (x = 0; x < (int) SIZEOF (bindings); ++x) bindCDKObject (vSCROLL, scrollp, bindings[x].from, getcCDKBind, (void *)(long)bindings[x].to); registerCDKObject (cdkscreen, vSCROLL, scrollp); /* Return the scrolling list */ return scrollp; } /* * Put the cursor on the currently-selected item's row. */ static void fixCursorPosition (CDKSCROLL *widget) { int scrollbarAdj = (widget->scrollbarPlacement == LEFT) ? 1 : 0; int ypos = SCREEN_YPOS (widget, widget->currentItem - widget->currentTop); int xpos = SCREEN_XPOS (widget, 0) + scrollbarAdj; wmove (InputWindowOf (widget), ypos, xpos); wrefresh (InputWindowOf (widget)); } /* * This actually does all the 'real' work of managing the scrolling list. */ int activateCDKScroll (CDKSCROLL *scrollp, chtype *actions) { /* Draw the scrolling list */ drawCDKScroll (scrollp, ObjOf (scrollp)->box); if (actions == 0) { chtype input; boolean functionKey; int ret; for (;;) { fixCursorPosition (scrollp); input = getchCDKObject (ObjOf (scrollp), &functionKey); /* Inject the character into the widget. */ ret = injectCDKScroll (scrollp, input); if (scrollp->exitType != vEARLY_EXIT) { return ret; } } } else { int length = chlen (actions); int i = 0; int ret; /* Inject each character one at a time. */ for (i = 0; i < length; i++) { ret = injectCDKScroll (scrollp, actions[i]); if (scrollp->exitType != vEARLY_EXIT) return ret; } } /* Set the exit type for the widget and return. */ setExitType (scrollp, 0); return -1; } /* * This injects a single character into the widget. */ static int _injectCDKScroll (CDKOBJS *object, chtype input) { CDKSCROLL *scrollp = (CDKSCROLL *)object; int ppReturn = 1; int ret = unknownInt; bool complete = FALSE; /* Set the exit type for the widget. */ setExitType (scrollp, 0); /* Draw the scrolling list */ drawCDKScrollList (scrollp, ObjOf (scrollp)->box); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf (scrollp) != 0) { /* Call the pre-process function. */ ppReturn = PreProcessFuncOf (scrollp) (vSCROLL, scrollp, PreProcessDataOf (scrollp), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check for a predefined key binding. */ if (checkCDKObjectBind (vSCROLL, scrollp, input) != 0) { checkEarlyExit (scrollp); complete = TRUE; } else { switch (input) { case KEY_UP: scroller_KEY_UP (scrollp); break; case KEY_DOWN: scroller_KEY_DOWN (scrollp); break; case KEY_RIGHT: scroller_KEY_RIGHT (scrollp); break; case KEY_LEFT: scroller_KEY_LEFT (scrollp); break; case KEY_PPAGE: scroller_KEY_PPAGE (scrollp); break; case KEY_NPAGE: scroller_KEY_NPAGE (scrollp); break; case KEY_HOME: scroller_KEY_HOME (scrollp); break; case KEY_END: scroller_KEY_END (scrollp); break; case '$': scrollp->leftChar = scrollp->maxLeftChar; break; case '|': scrollp->leftChar = 0; break; case KEY_ESC: setExitType (scrollp, input); complete = TRUE; break; case CDK_REFRESH: eraseCDKScreen (ScreenOf (scrollp)); refreshCDKScreen (ScreenOf (scrollp)); break; case KEY_TAB: case KEY_ENTER: setExitType (scrollp, input); ret = scrollp->currentItem; complete = TRUE; break; default: break; } } /* Should we call a post-process? */ if (!complete && (PostProcessFuncOf (scrollp) != 0)) { PostProcessFuncOf (scrollp) (vSCROLL, scrollp, PostProcessDataOf (scrollp), input); } } if (!complete) { drawCDKScrollList (scrollp, ObjOf (scrollp)->box); setExitType (scrollp, 0); } fixCursorPosition (scrollp); ResultOf (scrollp).valueInt = ret; return (ret != unknownInt); } /* * This allows the user to accelerate to a position in the scrolling list. */ void setCDKScrollPosition (CDKSCROLL *scrollp, int item) { scroller_SetPosition (scrollp, item); } /* obsolete (because the name is inconsistent) */ int getCDKScrollCurrent (CDKSCROLL *scrollp) { return scrollp->currentItem; } void setCDKScrollCurrent (CDKSCROLL *scrollp, int item) { scroller_SetPosition (scrollp, item); } /* * Get/Set the current item number of the scroller. */ int getCDKScrollCurrentItem (CDKSCROLL *widget) { return widget->currentItem; } void setCDKScrollCurrentItem (CDKSCROLL *widget, int item) { scroller_SetPosition (widget, item); } /* * Get/Set the top line of the scroller. */ int getCDKScrollCurrentTop (CDKSCROLL *widget) { return widget->currentTop; } void setCDKScrollCurrentTop (CDKSCROLL *widget, int item) { if (item < 0) item = 0; else if (item > widget->maxTopItem) item = widget->maxTopItem; widget->currentTop = item; scroller_SetPosition (widget, item); } /* * This moves the scroll field to the given location. */ static void _moveCDKScroll (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDKSCROLL *scrollp = (CDKSCROLL *)object; int currentX = getbegx (scrollp->win); int currentY = getbegy (scrollp->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 (scrollp->win) + xplace; ypos = getbegy (scrollp->win) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf (scrollp), &xpos, &ypos, scrollp->boxWidth, scrollp->boxHeight); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the window to the new location. */ moveCursesWindow (scrollp->win, -xdiff, -ydiff); moveCursesWindow (scrollp->listWin, -xdiff, -ydiff); moveCursesWindow (scrollp->shadowWin, -xdiff, -ydiff); moveCursesWindow (scrollp->scrollbarWin, -xdiff, -ydiff); /* Touch the windows so they 'move'. */ refreshCDKWindow (WindowOf (scrollp)); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDKScroll (scrollp, ObjOf (scrollp)->box); } } /* * This function draws the scrolling list widget. */ static void _drawCDKScroll (CDKOBJS *object, boolean Box) { CDKSCROLL *scrollp = (CDKSCROLL *)object; /* Draw in the shadow if we need to. */ if (scrollp->shadowWin != 0) drawShadow (scrollp->shadowWin); drawCdkTitle (scrollp->win, object); /* Draw in the scolling list items. */ drawCDKScrollList (scrollp, Box); } static void drawCDKScrollCurrent (CDKSCROLL *s) { /* Rehighlight the current menu item. */ int screenPos = s->itemPos[s->currentItem] - s->leftChar; chtype highlight = HasFocusObj (s) ? s->highlight : A_NORMAL; writeChtypeAttrib (s->listWin, (screenPos >= 0) ? screenPos : 0, s->currentHigh, s->item[s->currentItem], highlight, HORIZONTAL, (screenPos >= 0) ? 0 : (1 - screenPos), s->itemLen[s->currentItem]); } static int maxViewSize (CDKSCROLL *scrollp) { return scroller_MaxViewSize (scrollp); } /* * Set variables that depend upon the list-size. */ static void setViewSize (CDKSCROLL *scrollp, int listSize) { scroller_SetViewSize (scrollp, listSize); } #undef SCREEN_YPOS /* because listWin is separate */ #define SCREEN_YPOS(w,n) (n) /* * This redraws the scrolling list. */ static void drawCDKScrollList (CDKSCROLL *scrollp, boolean Box) { int j; /* If the list is empty, don't draw anything. */ if (scrollp->listSize > 0) { /* Redraw the list */ for (j = 0; j < scrollp->viewSize; j++) { int k = j + scrollp->currentTop; writeBlanks (scrollp->listWin, 0, j, HORIZONTAL, 0, scrollp->boxWidth - 2 * BorderOf (scrollp)); /* Draw the elements in the scrolling list. */ if (k < scrollp->listSize) { int screenPos = SCREENPOS (scrollp, j + scrollp->currentTop); int ypos = SCREEN_YPOS (scrollp, j); /* Write in the correct line. */ writeChtype (scrollp->listWin, (screenPos >= 0) ? screenPos : 1, ypos, scrollp->item[k], HORIZONTAL, (screenPos >= 0) ? 0 : (1 - screenPos), scrollp->itemLen[k]); } } drawCDKScrollCurrent (scrollp); /* Determine where the toggle is supposed to be. */ if (scrollp->scrollbarWin != 0) { scrollp->togglePos = floorCDK (scrollp->currentItem * scrollp->step); /* Make sure the toggle button doesn't go out of bounds. */ if (scrollp->togglePos >= getmaxy (scrollp->scrollbarWin)) scrollp->togglePos = getmaxy (scrollp->scrollbarWin) - 1; /* Draw the scrollbar. */ mvwvline (scrollp->scrollbarWin, 0, 0, ACS_CKBOARD, getmaxy (scrollp->scrollbarWin)); mvwvline (scrollp->scrollbarWin, scrollp->togglePos, 0, ' ' | A_REVERSE, scrollp->toggleSize); } } /* Box it if needed. */ if (Box) { drawObjBox (scrollp->win, ObjOf (scrollp)); } /* Refresh the window. */ wrefresh (scrollp->win); } /* * This sets the background attribute of the widget. */ static void _setBKattrScroll (CDKOBJS *object, chtype attrib) { if (object != 0) { CDKSCROLL *widget = (CDKSCROLL *)object; wbkgd (widget->win, attrib); wbkgd (widget->listWin, attrib); if (widget->scrollbarWin != 0) { wbkgd (widget->scrollbarWin, attrib); } } } /* * This function destroys */ static void _destroyCDKScroll (CDKOBJS *object) { if (object != 0) { CDKSCROLL *scrollp = (CDKSCROLL *)object; cleanCdkTitle (object); CDKfreeChtypes (scrollp->item); freeChecked (scrollp->itemPos); freeChecked (scrollp->itemLen); /* Clean up the windows. */ deleteCursesWindow (scrollp->scrollbarWin); deleteCursesWindow (scrollp->shadowWin); deleteCursesWindow (scrollp->listWin); deleteCursesWindow (scrollp->win); /* Clean the key bindings. */ cleanCDKObjectBindings (vSCROLL, scrollp); /* Unregister this object. */ unregisterCDKObject (vSCROLL, scrollp); } } /* * This function erases the scrolling list from the screen. */ static void _eraseCDKScroll (CDKOBJS *object) { if (validCDKObject (object)) { CDKSCROLL *scrollp = (CDKSCROLL *)object; eraseCursesWindow (scrollp->win); eraseCursesWindow (scrollp->shadowWin); } } static boolean allocListArrays (CDKSCROLL *scrollp, int oldSize, int newSize) { boolean result; int n; int nchunk = ((newSize + 1) | 31) + 1; chtype ** newList = typeCallocN (chtype *, nchunk); int * newLen = typeCallocN (int, nchunk); int * newPos = typeCallocN (int, nchunk); if (newList != 0 && newLen != 0 && newPos != 0) { for (n = 0; n < oldSize; ++n) { newList[n] = scrollp->item[n]; newLen[n] = scrollp->itemLen[n]; newPos[n] = scrollp->itemPos[n]; } if (oldSize == 0) { CDKfreeChtypes (scrollp->item); freeChecked (scrollp->itemPos); freeChecked (scrollp->itemLen); } scrollp->item = newList; scrollp->itemLen = newLen; scrollp->itemPos = newPos; result = TRUE; } else { freeChecked (newList); freeChecked (newLen); freeChecked (newPos); result = FALSE; } return result; } static boolean allocListItem (CDKSCROLL *scrollp, int which, char **work, unsigned *used, int number, char *value) { if (number > 0) { unsigned need = NUMBER_LEN (value); if (need > *used) { *used = ((need + 2) * 2); if (*work == 0) { if ((*work = (char *)malloc (*used)) == 0) return FALSE; } else { if ((*work = (char *)realloc (*work, *used)) == 0) return FALSE; } } sprintf (*work, NUMBER_FMT, number, value); value = *work; } if ((scrollp->item[which] = char2Chtype (value, &(scrollp->itemLen[which]), &(scrollp->itemPos[which]))) == 0) return FALSE; scrollp->itemPos[which] = justifyString (scrollp->boxWidth, scrollp->itemLen[which], scrollp->itemPos[which]); return TRUE; } /* * This function creates the scrolling list information and sets up the needed * variables for the scrolling list to work correctly. */ static int createCDKScrollItemList (CDKSCROLL *scrollp, boolean numbers, char **list, int listSize) { int status = 0; if (listSize > 0) { int widestItem = 0; int x = 0; unsigned have = 0; char *temp = 0; if (allocListArrays (scrollp, 0, listSize)) { /* Create the items in the scrolling list. */ status = 1; for (x = 0; x < listSize; x++) { if (!allocListItem (scrollp, x, &temp, &have, numbers ? (x + 1) : 0, list[x])) { status = 0; break; } widestItem = MAXIMUM (scrollp->itemLen[x], widestItem); } freeChecked (temp); if (status) { updateViewWidth (scrollp, widestItem); /* Keep the boolean flag 'numbers' */ scrollp->numbers = numbers; } } } else { status = 1; /* null list is ok - for a while */ } return status; } /* * This sets certain attributes of the scrolling list. */ void setCDKScroll (CDKSCROLL *scrollp, char **list, int listSize, boolean numbers, chtype highlight, boolean Box) { setCDKScrollItems (scrollp, list, listSize, numbers); setCDKScrollHighlight (scrollp, highlight); setCDKScrollBox (scrollp, Box); } /* * This sets the scrolling list items. */ void setCDKScrollItems (CDKSCROLL *scrollp, char **list, int listSize, boolean numbers) { int x = 0; if (createCDKScrollItemList (scrollp, numbers, list, listSize) <= 0) return; /* Clean up the display. */ for (x = 0; x < scrollp->viewSize; x++) { writeBlanks (scrollp->win, 1, SCREEN_YPOS (scrollp, x), HORIZONTAL, 0, scrollp->boxWidth - 2); } setViewSize (scrollp, listSize); setCDKScrollPosition (scrollp, 0); scrollp->leftChar = 0; } int getCDKScrollItems (CDKSCROLL *scrollp, char **list) { int x; if (list != 0) { for (x = 0; x < scrollp->listSize; x++) { list[x] = chtype2Char (scrollp->item[x]); } } return scrollp->listSize; } /* * This sets the highlight of the scrolling list. */ void setCDKScrollHighlight (CDKSCROLL *scrollp, chtype highlight) { scrollp->highlight = highlight; } chtype getCDKScrollHighlight (CDKSCROLL *scrollp, chtype highlight GCC_UNUSED) { return scrollp->highlight; } /* * This sets the box attribute of the scrolling list. */ void setCDKScrollBox (CDKSCROLL *scrollp, boolean Box) { ObjOf (scrollp)->box = Box; ObjOf (scrollp)->borderSize = Box ? 1 : 0; } boolean getCDKScrollBox (CDKSCROLL *scrollp) { return ObjOf (scrollp)->box; } /* * Resequence the numbers after a insertion/deletion. */ static void resequence (CDKSCROLL *scrollp) { if (scrollp->numbers) { int j, k; for (j = 0; j < scrollp->listSize; ++j) { char source[80]; chtype *target = scrollp->item[j]; sprintf (source, NUMBER_FMT, j + 1, ""); for (k = 0; source[k] != 0; ++k) { /* handle deletions that change the length of number */ if (source[k] == '.' && CharOf (target[k]) != '.') { int k2 = k; while ((target[k2] = target[k2 + 1]) != 0) ++k2; scrollp->itemLen[j] -= 1; } target[k] &= A_ATTRIBUTES; target[k] |= source[k]; } } } } static boolean insertListItem (CDKSCROLL *scrollp, int item) { int x; for (x = scrollp->listSize; x > item; --x) { scrollp->item[x] = scrollp->item[x - 1]; scrollp->itemLen[x] = scrollp->itemLen[x - 1]; scrollp->itemPos[x] = scrollp->itemPos[x - 1]; } return TRUE; } /* * This adds a single item to a scrolling list, at the end of the list. */ void addCDKScrollItem (CDKSCROLL *scrollp, char *item) { int itemNumber = scrollp->listSize; int widestItem = WidestItem (scrollp); char *temp = 0; unsigned have = 0; if (allocListArrays (scrollp, scrollp->listSize, scrollp->listSize + 1) && allocListItem (scrollp, itemNumber, &temp, &have, scrollp->numbers ? (itemNumber + 1) : 0, item)) { /* Determine the size of the widest item. */ widestItem = MAXIMUM (scrollp->itemLen[itemNumber], widestItem); updateViewWidth (scrollp, widestItem); setViewSize (scrollp, scrollp->listSize + 1); } freeChecked (temp); } /* * This adds a single item to a scrolling list, before the current item. */ void insertCDKScrollItem (CDKSCROLL *scrollp, char *item) { int widestItem = WidestItem (scrollp); char *temp = 0; unsigned have = 0; if (allocListArrays (scrollp, scrollp->listSize, scrollp->listSize + 1) && insertListItem (scrollp, scrollp->currentItem) && allocListItem (scrollp, scrollp->currentItem, &temp, &have, scrollp->numbers ? (scrollp->currentItem + 1) : 0, item)) { /* Determine the size of the widest item. */ widestItem = MAXIMUM (scrollp->itemLen[scrollp->currentItem], widestItem); updateViewWidth (scrollp, widestItem); setViewSize (scrollp, scrollp->listSize + 1); resequence (scrollp); } freeChecked (temp); } /* * This removes a single item from a scrolling list. */ void deleteCDKScrollItem (CDKSCROLL *scrollp, int position) { int x; if (position >= 0 && position < scrollp->listSize) { freeChtype (scrollp->item[position]); /* Adjust the list. */ for (x = position; x < scrollp->listSize; x++) { scrollp->item[x] = scrollp->item[x + 1]; scrollp->itemLen[x] = scrollp->itemLen[x + 1]; scrollp->itemPos[x] = scrollp->itemPos[x + 1]; } setViewSize (scrollp, scrollp->listSize - 1); if (scrollp->listSize > 0) resequence (scrollp); if (scrollp->listSize < maxViewSize (scrollp)) werase (scrollp->win); /* force the next redraw to be complete */ /* do this to update the view size, etc. */ setCDKScrollPosition (scrollp, scrollp->currentItem); } } static void _focusCDKScroll (CDKOBJS *object) { CDKSCROLL *scrollp = (CDKSCROLL *)object; drawCDKScrollCurrent (scrollp); wrefresh (scrollp->listWin); } static void _unfocusCDKScroll (CDKOBJS *object) { CDKSCROLL *scrollp = (CDKSCROLL *)object; drawCDKScrollCurrent (scrollp); wrefresh (scrollp->listWin); } dummyRefreshData (Scroll) dummySaveData (Scroll) cdk-5.0-20060507/select_file.c0000644000175100001440000000156007761472356014204 0ustar tomusers#include /* * $Author: tom $ * $Date: 2003/11/27 22:04:30 $ * $Revision: 1.1 $ */ /* * This allows a person to select a file. */ char *selectFile (CDKSCREEN *screen, char *title) { CDKFSELECT *fselect = 0; char *filename = 0; char *holder = 0; /* Create the file selector. */ fselect = newCDKFselect (screen, CENTER, CENTER, -4, -20, title, "File: ", A_NORMAL, '_', A_REVERSE, "", "", "", "", TRUE, FALSE); /* Let the user play. */ holder = activateCDKFselect (fselect, 0); /* Check the way the user exited the selector. */ if (fselect->exitType != vNORMAL) { destroyCDKFselect (fselect); refreshCDKScreen (screen); return (0); } /* Otherwise... */ filename = copyChar (holder); destroyCDKFselect (fselect); refreshCDKScreen (screen); return (filename); } cdk-5.0-20060507/selection.c0000644000175100001440000005461310355077556013716 0ustar tomusers#include /* * $Author: tom $ * $Date: 2005/12/30 00:29:34 $ * $Revision: 1.143 $ */ /* * Declare file local prototypes. */ static int createList(CDKSELECTION *selection, char **list, int listSize); static void drawCDKSelectionList (CDKSELECTION *selection, boolean Box); static void setViewSize(CDKSELECTION *scrollp, int listSize); static int maxViewSize(CDKSELECTION *scrollp); /* Determine how many characters we can shift to the right */ /* before all the items have been scrolled off the screen. */ #define AvailableWidth(w) ((w)->boxWidth - 2*BorderOf(w) - (w)->maxchoicelen) #define updateViewWidth(w, widest) \ (w)->maxLeftChar = (((w)->boxWidth > widest) \ ? 0 \ : (widest - AvailableWidth(w))) #define WidestItem(w) ((w)->maxLeftChar + AvailableWidth(w)) #define SCREENPOS(w,n) (w)->itemPos[n] - (w)->leftChar + scrollbarAdj /* + BorderOf(w) */ DeclareCDKObjects(SELECTION, Selection, setCdk, Int); /* * This function creates a selection widget. */ CDKSELECTION *newCDKSelection (CDKSCREEN *cdkscreen, int xplace, int yplace, int splace, int height, int width, char *title, char **list, int listSize, char **choices, int choiceCount, chtype highlight, boolean Box, boolean shadow) { CDKSELECTION *selection = 0; int widestItem = -1; int parentWidth = getmaxx(cdkscreen->window); int parentHeight = getmaxy(cdkscreen->window); int boxWidth = width; int boxHeight = height; int xpos = xplace; int ypos = yplace; int j = 0; int junk2; static const struct { int from; int to; } bindings[] = { { CDK_BACKCHAR, KEY_PPAGE }, { CDK_FORCHAR, KEY_NPAGE }, { 'g', KEY_HOME }, { '1', KEY_HOME }, { 'G', KEY_END }, { '<', KEY_HOME }, { '>', KEY_END }, }; if (choiceCount <= 0 || (selection = newCDKObject(CDKSELECTION, &my_funcs)) == 0 || (selection->choice = typeCallocN(chtype *, choiceCount + 1)) == 0 || (selection->choicelen = typeCallocN(int, choiceCount + 1)) == 0) { destroyCDKObject(selection); return (0); } setCDKSelectionBox (selection, 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); boxWidth = setCdkTitle(ObjOf(selection), title, boxWidth); /* Set the box height. */ if (TitleLinesOf(selection) > boxHeight) { boxHeight = TitleLinesOf(selection) + MINIMUM(listSize, 8) + 2 * BorderOf(selection); } selection->maxchoicelen = 0; /* Adjust the box width if there is a scroll bar. */ if (splace == LEFT || splace == RIGHT) { boxWidth++; selection->scrollbar = TRUE; } else { selection->scrollbar = FALSE; } /* * Make sure we didn't extend beyond the dimensions of the window. */ selection->boxWidth = (boxWidth > parentWidth ? parentWidth : boxWidth); selection->boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight); setViewSize(selection, listSize); /* Rejustify the x and y positions if we need to. */ alignxy (cdkscreen->window, &xpos, &ypos, selection->boxWidth, selection->boxHeight); /* Make the selection window */ selection->win = newwin (selection->boxHeight, selection->boxWidth, ypos, xpos); /* Is the window null?? */ if (selection->win == 0) { destroyCDKObject(selection); return (0); } /* Turn the keypad on for this window. */ keypad (selection->win, TRUE); /* Create the scrollbar window. */ if (splace == RIGHT) { selection->scrollbarWin = subwin (selection->win, maxViewSize(selection), 1, SCREEN_YPOS(selection, ypos), xpos + selection->boxWidth - BorderOf(selection) - 1); } else if (splace == LEFT) { selection->scrollbarWin = subwin (selection->win, maxViewSize(selection), 1, SCREEN_YPOS(selection, ypos), SCREEN_XPOS(selection, xpos)); } else { selection->scrollbarWin = 0; } /* Set the rest of the variables */ ScreenOf(selection) = cdkscreen; selection->parent = cdkscreen->window; selection->scrollbarPlacement = splace; selection->maxLeftChar = 0; selection->leftChar = 0; selection->highlight = highlight; selection->choiceCount = choiceCount; initExitType(selection); ObjOf(selection)->acceptsFocus = TRUE; ObjOf(selection)->inputWindow = selection->win; selection->shadow = shadow; setCDKSelectionCurrent (selection, 0); /* Each choice has to be converted from char * to chtype * */ for (j = 0; j < choiceCount; j++) { selection->choice[j] = char2Chtype (choices[j], &selection->choicelen[j], &junk2); selection->maxchoicelen = MAXIMUM (selection->maxchoicelen, selection->choicelen[j]); } /* Each item in the needs to be converted to chtype * */ widestItem = createList(selection, list, listSize); if (widestItem > 0) { updateViewWidth(selection, widestItem); } else if (listSize) { destroyCDKObject(selection); return (0); } /* Do we need to create a shadow. */ if (shadow) { selection->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1); } /* Setup the key bindings. */ for (j = 0; j < (int) SIZEOF(bindings); ++j) bindCDKObject (vSELECTION, selection, bindings[j].from, getcCDKBind, (void *)(long)bindings[j].to); /* Register this baby. */ registerCDKObject (cdkscreen, vSELECTION, selection); /* Return the selection list */ return (selection); } /* * Put the cursor on the currently-selected item. */ static void fixCursorPosition (CDKSELECTION *selection) { int scrollbarAdj = (selection->scrollbarPlacement == LEFT) ? 1 : 0; int ypos = SCREEN_YPOS(selection, selection->currentItem - selection->currentTop); int xpos = SCREEN_XPOS(selection, 0) + scrollbarAdj; wmove(InputWindowOf(selection), ypos, xpos); wrefresh(InputWindowOf(selection)); } /* * This actually manages the selection widget... */ int activateCDKSelection (CDKSELECTION *selection, chtype *actions) { /* Draw the selection list */ drawCDKSelection (selection, ObjOf(selection)->box); if (actions == 0) { chtype input; boolean functionKey; int ret; for (;;) { fixCursorPosition (selection); input = getchCDKObject (ObjOf(selection), &functionKey); /* Inject the character into the widget. */ ret = injectCDKSelection (selection, input); if (selection->exitType != vEARLY_EXIT) { return ret; } } } else { int length = chlen (actions); int j = 0; int ret; /* Inject each character one at a time. */ for (j = 0; j < length; j++) { ret = injectCDKSelection (selection, actions[j]); if (selection->exitType != vEARLY_EXIT) { return ret; } } } /* Set the exit type and return. */ setExitType(selection, 0); return 0; } /* * This injects a single character into the widget. */ static int _injectCDKSelection (CDKOBJS *object, chtype input) { CDKSELECTION *selection = (CDKSELECTION *)object; int ppReturn = 1; int ret = unknownInt; bool complete = FALSE; /* Set the exit type. */ setExitType(selection, 0); /* Draw the selection list */ drawCDKSelectionList (selection, ObjOf(selection)->box); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf(selection) != 0) { /* Call the pre-process function. */ ppReturn = PreProcessFuncOf(selection) (vSELECTION, selection, PreProcessDataOf(selection), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check for a predefined binding. */ if (checkCDKObjectBind (vSELECTION, selection, input) != 0) { checkEarlyExit(selection); complete = TRUE; } else { switch (input) { case KEY_UP : scroller_KEY_UP(selection); break; case KEY_DOWN : scroller_KEY_DOWN(selection); break; case KEY_RIGHT : scroller_KEY_RIGHT(selection); break; case KEY_LEFT : scroller_KEY_LEFT(selection); break; case KEY_PPAGE : scroller_KEY_PPAGE(selection); break; case KEY_NPAGE : scroller_KEY_NPAGE(selection); break; case KEY_HOME : scroller_KEY_HOME(selection); break; case KEY_END : scroller_KEY_END(selection); break; case '$' : selection->leftChar = selection->maxLeftChar; break; case '|' : selection->leftChar = 0; break; case SPACE : if (selection->mode[selection->currentItem] == 0) { if (selection->selections[selection->currentItem] == selection->choiceCount - 1) { selection->selections[selection->currentItem] = 0; } else { selection->selections[selection->currentItem]++; } } else { Beep(); } break; case KEY_ESC : setExitType(selection, input); complete = TRUE; break; case KEY_TAB : case KEY_ENTER : setExitType(selection, input); ret = 1; complete = TRUE; break; case CDK_REFRESH : eraseCDKScreen (ScreenOf(selection)); refreshCDKScreen (ScreenOf(selection)); break; default : break; } } /* Should we call a post-process? */ if (!complete && (PostProcessFuncOf(selection) != 0)) { PostProcessFuncOf(selection) (vSELECTION, selection, PostProcessDataOf(selection), input); } } if (!complete) { drawCDKSelectionList (selection, ObjOf(selection)->box); setExitType(selection, 0); } ResultOf(selection).valueInt = ret; fixCursorPosition (selection); return (ret != unknownInt); } /* * This moves the selection field to the given location. */ static void _moveCDKSelection (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDKSELECTION *selection = (CDKSELECTION *)object; int currentX = getbegx(selection->win); int currentY = getbegy(selection->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(selection->win) + xplace; ypos = getbegy(selection->win) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf(selection), &xpos, &ypos, selection->boxWidth, selection->boxHeight); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the window to the new location. */ moveCursesWindow(selection->win, -xdiff, -ydiff); moveCursesWindow(selection->scrollbarWin, -xdiff, -ydiff); moveCursesWindow(selection->shadowWin, -xdiff, -ydiff); /* Touch the windows so they 'move'. */ refreshCDKWindow (WindowOf(selection)); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDKSelection (selection, ObjOf(selection)->box); } } /* * This function draws the selection list. */ static void _drawCDKSelection (CDKOBJS *object, boolean Box) { CDKSELECTION *selection = (CDKSELECTION *)object; /* Draw in the shadow if we need to. */ if (selection->shadowWin != 0) { drawShadow (selection->shadowWin); } drawCdkTitle (selection->win, object); /* Redraw the list */ drawCDKSelectionList (selection, Box); } static int maxViewSize(CDKSELECTION *widget) { return scroller_MaxViewSize(widget); } /* * Set variables that depend upon the list-size. */ static void setViewSize(CDKSELECTION *widget, int listSize) { scroller_SetViewSize(widget, listSize); } /* * This function draws the selection list window. */ static void drawCDKSelectionList (CDKSELECTION *selection, boolean Box GCC_UNUSED) { int scrollbarAdj = (selection->scrollbarPlacement == LEFT) ? 1 : 0; int screenPos = 0; int xpos, ypos; int j; int selItem = -1; /* If there is to be a highlight, assign it now */ if (ObjOf(selection)->hasFocus) selItem = selection->currentItem; /* draw the list... */ for (j = 0; j < selection->viewSize; j++) { screenPos = SCREENPOS(selection, j + selection->currentTop); ypos = SCREEN_YPOS(selection, j); xpos = SCREEN_XPOS(selection, 0); /* Draw the empty line. */ writeBlanks (selection->win, xpos, ypos, HORIZONTAL, 0, getmaxx(selection->win)); /* Draw the selection item. */ writeChtypeAttrib (selection->win, (screenPos >= 0) ? screenPos : 1, ypos, selection->item[j + selection->currentTop], ((j + selection->currentTop == selItem) ? selection->highlight : A_NORMAL), HORIZONTAL, (screenPos >= 0) ? 0 : (1 - screenPos), selection->itemLen[j + selection->currentTop]); /* Draw the choice value. */ writeChtype (selection->win, xpos + scrollbarAdj, ypos, selection->choice[selection->selections[j + selection->currentTop]], HORIZONTAL, 0, selection->choicelen[selection->selections[j + selection->currentTop]]); } /* Determine where the toggle is supposed to be. */ if (selection->scrollbar) { selection->togglePos = floorCDK(selection->currentItem * selection->step); selection->togglePos = MINIMUM(selection->togglePos, getmaxy(selection->scrollbarWin) - 1); mvwvline (selection->scrollbarWin, 0, 0, ACS_CKBOARD, getmaxy(selection->scrollbarWin)); mvwvline (selection->scrollbarWin, selection->togglePos, 0, ' ' | A_REVERSE, selection->toggleSize); } /* Box it if needed */ if (ObjOf(selection)->box) { drawObjBox (selection->win, ObjOf(selection)); } fixCursorPosition (selection); } /* * This sets the background attribute of the widget. */ static void _setBKattrSelection (CDKOBJS *object, chtype attrib) { if (object != 0) { CDKSELECTION *widget = (CDKSELECTION *) object; wbkgd (widget->win, attrib); if (widget->scrollbarWin != 0) { wbkgd (widget->scrollbarWin, attrib); } } } static void destroyInfo (CDKSELECTION *widget) { CDKfreeChtypes (widget->item); widget->item = 0; freeAndNull (widget->itemPos); freeAndNull (widget->itemLen); freeAndNull (widget->selections); freeAndNull (widget->mode); } /* * This function destroys the selection list. */ static void _destroyCDKSelection (CDKOBJS *object) { if (object != 0) { CDKSELECTION *selection = (CDKSELECTION *)object; cleanCdkTitle (object); CDKfreeChtypes (selection->choice); freeChecked (selection->choicelen); destroyInfo (selection); /* Clean up the windows. */ deleteCursesWindow (selection->scrollbarWin); deleteCursesWindow (selection->shadowWin); deleteCursesWindow (selection->win); /* Clean the key bindings. */ cleanCDKObjectBindings (vSELECTION, selection); /* Unregister this object. */ unregisterCDKObject (vSELECTION, selection); } } /* * This function erases the selection list from the screen. */ static void _eraseCDKSelection (CDKOBJS *object) { if (validCDKObject (object)) { CDKSELECTION *selection = (CDKSELECTION *)object; eraseCursesWindow (selection->win); eraseCursesWindow (selection->shadowWin); } } /* * This function sets a couple of the selection list attributes. */ void setCDKSelection (CDKSELECTION *selection, chtype highlight, int * choices, boolean Box) { setCDKSelectionChoices (selection, choices); setCDKSelectionHighlight(selection, highlight); setCDKSelectionBox (selection, Box); } /* * This sets the selection list items. */ void setCDKSelectionItems (CDKSELECTION *selection, char **list, int listSize) { int widestItem = -1; int j = 0; widestItem = createList(selection, list, listSize); if (widestItem <= 0) return; /* Clean up the display. */ for (j = 0; j < selection->viewSize ; j++) { writeBlanks (selection->win, SCREEN_XPOS(selection, 0), SCREEN_YPOS(selection, j), HORIZONTAL, 0, getmaxx(selection->win)); } setViewSize(selection, listSize); setCDKSelectionCurrent (selection, 0); updateViewWidth(selection, widestItem); } int getCDKSelectionItems (CDKSELECTION *selection, char **list) { int j; if (list != 0) { for (j = 0; j < selection->listSize; j++) { list[j] = chtype2Char (selection->item[j]); } } return selection->listSize; } /* * */ void setCDKSelectionTitle (CDKSELECTION *selection, char *title) { /* Make sure the title isn't null. */ if (title == 0) { return; } (void) setCdkTitle(ObjOf(selection), title, - (selection->boxWidth + 1)); setViewSize(selection, selection->listSize); } char *getCDKSelectionTitle (CDKSELECTION *selection GCC_UNUSED) { return chtype2Char(*TitleOf(selection)); } /* * This sets the highlight bar. */ void setCDKSelectionHighlight (CDKSELECTION *selection, chtype highlight) { selection->highlight = highlight; } chtype getCDKSelectionHighlight (CDKSELECTION *selection) { return selection->highlight; } /* * This sets the default choices for the selection list. */ void setCDKSelectionChoices (CDKSELECTION *selection, int * choices) { int j; /* Set the choice values in the selection list. */ for (j = 0; j < selection->listSize; j++) { if (choices[j] < 0) { selection->selections[j] = 0; } else if (choices[j] > selection->choiceCount) { selection->selections[j] = selection->choiceCount - 1; } else { selection->selections[j] = choices[j]; } } } int *getCDKSelectionChoices (CDKSELECTION *selection) { return selection->selections; } /* * This sets a single item's choice value. */ void setCDKSelectionChoice (CDKSELECTION *selection, int Index, int choice) { int correctChoice = choice; int correctIndex = Index; /* Verify that the choice value is in range. */ if (choice < 0) { correctChoice = 0; } else if (choice > selection->choiceCount) { correctChoice = selection->choiceCount - 1; } /* Make sure the index isn't out of range. */ if (Index < 0) { Index = 0; } else if (Index > selection->listSize) { Index = selection->listSize - 1; } /* Set the choice value. */ selection->selections[correctIndex] = correctChoice; } int getCDKSelectionChoice (CDKSELECTION *selection, int Index) { /* Make sure the index isn't out of range. */ if (Index < 0) { return selection->selections[0]; } else if (Index > selection->listSize) { return selection->selections[selection->listSize - 1]; } else { return selection->selections[Index]; } } /* * This sets the modes of the items in the selection list. Currently * there are only two: editable=0 and read-only=1 */ void setCDKSelectionModes (CDKSELECTION *selection, int * modes) { int j; /* Make sure the widget pointer is not null. */ if (selection == 0) { return; } /* Set the modes. */ for (j = 0; j < selection->listSize; j++) { selection->mode[j] = modes[j]; } } int *getCDKSelectionModes (CDKSELECTION *selection) { return selection->mode; } /* * This sets a single mode of an item in the selection list. */ void setCDKSelectionMode (CDKSELECTION *selection, int Index, int mode) { /* Make sure the widget pointer is not null. */ if (selection == 0) { return; } /* Make sure the index isn't out of range. */ if (Index < 0) { selection->mode[0] = mode; } else if (Index > selection->listSize) { selection->mode[selection->listSize - 1] = mode; } else { selection->mode[Index] = mode; } } int getCDKSelectionMode (CDKSELECTION *selection, int Index) { /* Make sure the index isn't out of range. */ if (Index < 0) { return selection->mode[0]; } else if (Index > selection->listSize) { return selection->mode[selection->listSize - 1]; } else { return selection->mode[Index]; } } /* * This sets the box attribute of the widget. */ void setCDKSelectionBox (CDKSELECTION *selection, boolean Box) { ObjOf(selection)->box = Box; ObjOf(selection)->borderSize = Box ? 1 : 0; } boolean getCDKSelectionBox (CDKSELECTION *selection) { return ObjOf(selection)->box; } /* * set/get the current item index */ void setCDKSelectionCurrent (CDKSELECTION *selection, int item) { scroller_SetPosition(selection, item); } int getCDKSelectionCurrent (CDKSELECTION *selection) { return selection->currentItem; } /* * methods for generic type methods */ static void _focusCDKSelection(CDKOBJS *object) { CDKSELECTION *selection = (CDKSELECTION *)object; drawCDKSelectionList (selection, ObjOf(selection)->box); } static void _unfocusCDKSelection(CDKOBJS *object) { CDKSELECTION *selection = (CDKSELECTION *)object; drawCDKSelectionList (selection, ObjOf(selection)->box); } static int createList(CDKSELECTION *selection, char **list, int listSize) { int status = 0; int widestItem = 0; int j; if (listSize > 0) { chtype ** newList = typeCallocN(chtype *, listSize + 1); int * newLen = typeCallocN(int, listSize + 1); int * newPos = typeCallocN(int, listSize + 1); int * newSel = typeCallocN(int, listSize + 1); int * newMode = typeCallocN(int, listSize + 1); if (newList != 0 && newLen != 0 && newPos != 0 && newSel != 0 && newMode != 0) { int boxWidth = AvailableWidth(selection); int adjust = selection->maxchoicelen + BorderOf(selection); status = 1; for (j = 0; j < listSize; j++) { newList[j] = char2Chtype (list[j], &newLen[j], &newPos[j]); if (newList[j] == 0) { status = 0; break; } newPos[j] = justifyString (boxWidth, newLen[j], newPos[j]) + adjust; widestItem = MAXIMUM (widestItem, newLen[j]); } if (status) { destroyInfo (selection); selection->item = newList; selection->itemPos = newPos; selection->itemLen = newLen; selection->selections = newSel; selection->mode = newMode; } else { CDKfreeChtypes (newList); freeChecked (newPos); freeChecked (newLen); freeChecked (newSel); freeChecked (newMode); } } } else { destroyInfo (selection); } return status ? widestItem : 0; } dummyRefreshData(Selection) dummySaveData(Selection) cdk-5.0-20060507/swindow.c0000644000175100001440000006356110426516514013414 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:33:16 $ * $Revision: 1.114 $ */ /* * Declare file local prototypes. */ static int createList(CDKSWINDOW *swindow, int listSize); static void drawCDKSwindowList (CDKSWINDOW *swindow, boolean Box); DeclareCDKObjects(SWINDOW, Swindow, setCdk, Int); /* * This function creates a scrolling window widget. */ CDKSWINDOW *newCDKSwindow (CDKSCREEN *cdkscreen, int xplace, int yplace, int height, int width, char *title, int saveLines, boolean Box, boolean shadow) { CDKSWINDOW *swindow = 0; int parentWidth = getmaxx(cdkscreen->window); int parentHeight = getmaxy(cdkscreen->window); int boxWidth = width; int boxHeight = height; int xpos = xplace; int ypos = yplace; int x; static const struct { int from; int to; } bindings[] = { { CDK_BACKCHAR, KEY_PPAGE }, { 'b', KEY_PPAGE }, { 'B', KEY_PPAGE }, { CDK_FORCHAR, KEY_NPAGE }, { SPACE, KEY_NPAGE }, { 'f', KEY_NPAGE }, { 'F', KEY_NPAGE }, { '|', KEY_HOME }, { '$', KEY_END }, }; if ((swindow = newCDKObject(CDKSWINDOW, &my_funcs)) == 0) return (0); setCDKSwindowBox (swindow, 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); boxWidth = setCdkTitle(ObjOf(swindow), title, boxWidth); /* Set the box height. */ boxHeight += TitleLinesOf(swindow) + 1; /* * Make sure we didn't extend beyond the dimensions of the window. */ boxWidth = (boxWidth > parentWidth ? parentWidth : boxWidth); boxHeight = (boxHeight > parentHeight ? parentHeight : boxHeight); /* Set the rest of the variables. */ swindow->titleAdj = TitleLinesOf(swindow) + 1; /* Rejustify the x and y positions if we need to. */ alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight); /* Make the scrolling window */ swindow->win = newwin (boxHeight, boxWidth, ypos, xpos); if (swindow->win == 0) { destroyCDKObject(swindow); return (0); } keypad (swindow->win, TRUE); /* Make the field window. */ swindow->fieldWin = subwin (swindow->win, (boxHeight-TitleLinesOf(swindow)-2), boxWidth - 2, ypos + TitleLinesOf(swindow) + 1, xpos + 1); keypad (swindow->fieldWin, TRUE); /* Set the rest of the variables */ ScreenOf(swindow) = cdkscreen; swindow->parent = cdkscreen->window; swindow->shadowWin = 0; swindow->boxHeight = boxHeight; swindow->boxWidth = boxWidth; swindow->viewSize = boxHeight-TitleLinesOf(swindow)-2; swindow->currentTop = 0; swindow->maxTopLine = 0; swindow->leftChar = 0; swindow->maxLeftChar = 0; swindow->listSize = 0; swindow->widestLine = -1; swindow->saveLines = saveLines; initExitType(swindow); ObjOf(swindow)->acceptsFocus = TRUE; ObjOf(swindow)->inputWindow = swindow->win; swindow->shadow = shadow; if (!createList(swindow, saveLines)) { destroyCDKObject(swindow); return (0); } /* Do we need to create a shadow??? */ if (shadow) { swindow->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1); } /* Clean the key bindings. */ for (x = 0; x < (int) SIZEOF(bindings); ++x) bindCDKObject (vSWINDOW, swindow, bindings[x].from, getcCDKBind, (void *)(long)bindings[x].to); /* Register this baby. */ registerCDKObject (cdkscreen, vSWINDOW, swindow); /* Return the scrolling window */ return (swindow); } /* * This sets the lines and the box attribute of the scrolling window. */ void setCDKSwindow (CDKSWINDOW *swindow, char **list, int lines, boolean Box) { setCDKSwindowContents (swindow, list, lines); setCDKSwindowBox (swindow, Box); } static void setupLine (CDKSWINDOW *swindow, char *list, int x) { swindow->list[x] = char2Chtype (list, &swindow->listLen[x], &swindow->listPos[x]); swindow->listPos[x] = justifyString (swindow->boxWidth, swindow->listLen[x], swindow->listPos[x]); swindow->widestLine = MAXIMUM (swindow->widestLine, swindow->listLen[x]); } /* * This sets all the lines inside the scrolling window. */ void setCDKSwindowContents (CDKSWINDOW *swindow, char **list, int listSize) { int x = 0; /* First lets clean all the lines in the window. */ cleanCDKSwindow(swindow); createList(swindow, listSize); /* Now lets set all the lines inside the window. */ for (x=0; x < listSize; x++) { setupLine(swindow, list[x], x); } /* Set some of the more important members of the scrolling window. */ swindow->listSize = listSize; swindow->maxTopLine = swindow->listSize - swindow->viewSize; swindow->maxTopLine = (swindow->maxTopLine < 0 ? 0 : swindow->maxTopLine); swindow->maxLeftChar = swindow->widestLine - (swindow->boxWidth - 2); swindow->currentTop = 0; swindow->leftChar = 0; } chtype **getCDKSwindowContents (CDKSWINDOW *swindow, int *size) { (*size) = swindow->listSize; return swindow->list; } /* * This sets the box attribute for the widget. */ void setCDKSwindowBox (CDKSWINDOW *swindow, boolean Box) { ObjOf(swindow)->box = Box; ObjOf(swindow)->borderSize = Box ? 1 : 0; } boolean getCDKSwindowBox (CDKSWINDOW *swindow) { return ObjOf(swindow)->box; } static void freeLine (CDKSWINDOW *swindow, int x) { if (x < swindow->listSize) { freeChtype (swindow->list[x]); swindow->list[x] = 0; } } /* * This adds a line to the scrolling window. */ void addCDKSwindow (CDKSWINDOW *swindow, char *list, int insertPos) { int x = 0; /* * If we are at the maximum number of save lines. Erase * the first position and bump everything up one spot. */ if (swindow->listSize == swindow->saveLines) { /* Free up the memory. */ freeLine (swindow, 0); /* Bump everything up one spot. */ for (x=0; x < swindow->listSize; x++) { swindow->list[x] = swindow->list[x + 1]; swindow->listPos[x] = swindow->listPos[x + 1]; swindow->listLen[x] = swindow->listLen[x + 1]; } /* Clean out the last position. */ swindow->list[swindow->listSize] = 0; swindow->listLen[swindow->listSize] = 0; swindow->listPos[swindow->listSize] = 0; swindow->listSize--; } /* Determine where the line is being added. */ if (insertPos == TOP) { /* We need to 'bump' everything down one line... */ for (x = swindow->listSize; x > 0; x--) { /* Copy in the new row. */ swindow->list[x] = swindow->list[x - 1]; swindow->listPos[x] = swindow->listPos[x - 1]; swindow->listLen[x] = swindow->listLen[x - 1]; } /* Add it into the scrolling window. */ setupLine(swindow, list, 0); /* Set some variables. */ swindow->currentTop = 0; if (swindow->listSize < swindow->saveLines) { swindow->listSize++; } /* Set the maximum top line. */ swindow->maxTopLine = swindow->listSize - swindow->viewSize; swindow->maxTopLine = (swindow->maxTopLine < 0 ? 0 : swindow->maxTopLine); swindow->maxLeftChar = swindow->widestLine - (swindow->boxWidth - 2); } else { /* Add to the bottom. */ setupLine(swindow, list, swindow->listSize); swindow->maxLeftChar = swindow->widestLine - (swindow->boxWidth - 2); /* Increment the item count and zero out the next row. */ if (swindow->listSize < swindow->saveLines) { swindow->listSize++; freeLine (swindow, swindow->listSize); } /* Set the maximum top line. */ if (swindow->listSize <= swindow->viewSize) { swindow->maxTopLine = 0; swindow->currentTop = 0; } else { swindow->maxTopLine = (swindow->listSize - swindow->viewSize); swindow->currentTop = swindow->maxTopLine; } } /* Draw in the list. */ drawCDKSwindowList (swindow, ObjOf(swindow)->box); } /* * This jumps to a given line. */ void jumpToLineCDKSwindow (CDKSWINDOW *swindow, int line) { /* * Make sure the line is in bounds. */ if (line == BOTTOM || line >= swindow->listSize) { /* We are moving to the last page. */ swindow->currentTop = swindow->listSize - swindow->viewSize; } else if (line == TOP || line <= 0) { /* We are moving to the top of the page. */ swindow->currentTop = 0; } else { /* We are moving in the middle somewhere. */ if ((swindow->viewSize + line) < swindow->listSize) { swindow->currentTop = line; } else { swindow->currentTop = swindow->listSize - swindow->viewSize; } } /* A little sanity check to make we don't something silly. */ if (swindow->currentTop < 0) { swindow->currentTop = 0; } /* Redraw the window. */ drawCDKSwindow (swindow, ObjOf(swindow)->box); } /* * This removes all the lines inside the scrolling window. */ void cleanCDKSwindow (CDKSWINDOW *swindow) { int x; /* Clean up the memory used ... */ for (x=0; x < swindow->listSize; x++) { freeLine (swindow, x); } /* Reset some variables. */ swindow->listSize = 0; swindow->maxLeftChar = 0; swindow->widestLine = 0; swindow->currentTop = 0; swindow->maxTopLine = 0; /* Redraw the window. */ drawCDKSwindow (swindow, ObjOf(swindow)->box); } /* * This trims lines from the scrolling window. */ void trimCDKSwindow (CDKSWINDOW *swindow, int begin, int end) { int start, finish, x; /* Check the value of begin. */ if (begin < 0) { start = 0; } else if (begin >= swindow->listSize) { start = swindow->listSize-1; } else { start = begin; } /* Check the value of end. */ if (end < 0) { finish = 0; } else if (end >= swindow->listSize) { finish = swindow->listSize-1; } else { finish = end; } /* Make sure the start is lower than the end. */ if (start > finish) { return; } /* Start nuking elements from the window. */ for (x=start; x <=finish; x++) { freeLine (swindow, x); if (x < swindow->listSize-1) { swindow->list[x] = copyChtype (swindow->list[x + 1]); swindow->listPos[x] = swindow->listPos[x + 1]; swindow->listLen[x] = swindow->listLen[x + 1]; } } /* Adjust the item count correctly. */ swindow->listSize = swindow->listSize - (end - begin) - 1; /* Redraw the window. */ drawCDKSwindow (swindow, ObjOf(swindow)->box); } /* * This allows the user to play inside the scrolling window. */ void activateCDKSwindow (CDKSWINDOW *swindow, chtype *actions) { /* Draw the scrolling list */ drawCDKSwindow (swindow, ObjOf(swindow)->box); if (actions == 0) { chtype input; boolean functionKey; int ret; for (;;) { input = getchCDKObject (ObjOf(swindow), &functionKey); /* Inject the character into the widget. */ ret = injectCDKSwindow (swindow, input); if (swindow->exitType != vEARLY_EXIT) { return; } } } else { int length = chlen (actions); int x = 0; int ret; /* Inject each character one at a time. */ for (x=0; x < length; x++) { ret = injectCDKSwindow (swindow, actions[x]); if (swindow->exitType != vEARLY_EXIT) { return; } } } /* Set the exit type and return. */ setExitType(swindow, 0); return; } /* * This injects a single character into the widget. */ static int _injectCDKSwindow (CDKOBJS *object, chtype input) { CDKSWINDOW *swindow = (CDKSWINDOW *)object; int ppReturn = 1; int ret = unknownInt; bool complete = FALSE; /* Set the exit type. */ setExitType(swindow, 0); /* Draw the window.... */ drawCDKSwindow (swindow, ObjOf(swindow)->box); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf(swindow) != 0) { /* Call the pre-process function. */ ppReturn = PreProcessFuncOf(swindow) (vSWINDOW, swindow, PreProcessDataOf(swindow), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check for a key binding. */ if (checkCDKObjectBind (vSWINDOW, swindow, input) != 0) { checkEarlyExit(swindow); complete = TRUE; } else { switch (input) { case KEY_UP : if (swindow->currentTop > 0) { swindow->currentTop--; } else { Beep(); } break; case KEY_DOWN : if (swindow->currentTop >= 0 && swindow->currentTop < swindow->maxTopLine) { swindow->currentTop++; } else { Beep(); } break; case KEY_RIGHT : if (swindow->leftChar < swindow->maxLeftChar) { swindow->leftChar ++; } else { Beep(); } break; case KEY_LEFT : if (swindow->leftChar > 0) { swindow->leftChar--; } else { Beep(); } break; case KEY_PPAGE : if (swindow->currentTop != 0) { if (swindow->currentTop >= swindow->viewSize) { swindow->currentTop = swindow->currentTop - (swindow->viewSize - 1); } else { swindow->currentTop = 0; } } else { Beep(); } break; case KEY_NPAGE : if (swindow->currentTop != swindow->maxTopLine) { if ((swindow->currentTop + swindow->viewSize) < swindow->maxTopLine) { swindow->currentTop = swindow->currentTop + (swindow->viewSize - 1); } else { swindow->currentTop = swindow->maxTopLine; } } else { Beep(); } break; case KEY_HOME : swindow->leftChar = 0; break; case KEY_END : swindow->leftChar = swindow->maxLeftChar + 1; break; case 'g' : case '1' : case '<' : swindow->currentTop = 0; break; case 'G' : case '>' : swindow->currentTop = swindow->maxTopLine; break; case 'l' : case 'L' : loadCDKSwindowInformation (swindow); break; case 's' : case 'S' : saveCDKSwindowInformation (swindow); break; case KEY_TAB : case KEY_ENTER : setExitType(swindow, input); ret = 1; complete = TRUE; break; case KEY_ESC : setExitType(swindow, input); complete = TRUE; break; case CDK_REFRESH : eraseCDKScreen (ScreenOf(swindow)); refreshCDKScreen (ScreenOf(swindow)); break; default : break; } } /* Should we call a post-process? */ if (!complete && (PostProcessFuncOf(swindow) != 0)) { PostProcessFuncOf(swindow) (vSWINDOW, swindow, PostProcessDataOf(swindow), input); } } if (!complete) { drawCDKSwindowList (swindow, ObjOf(swindow)->box); setExitType(swindow, 0); } ResultOf(swindow).valueInt = ret; return (ret != unknownInt); } /* * This moves the swindow field to the given location. */ static void _moveCDKSwindow (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDKSWINDOW *swindow = (CDKSWINDOW *)object; int currentX = getbegx(swindow->win); int currentY = getbegy(swindow->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(swindow->win) + xplace; ypos = getbegy(swindow->win) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf(swindow), &xpos, &ypos, swindow->boxWidth, swindow->boxHeight); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the window to the new location. */ moveCursesWindow(swindow->win, -xdiff, -ydiff); moveCursesWindow(swindow->shadowWin, -xdiff, -ydiff); /* Touch the windows so they 'move'. */ refreshCDKWindow (WindowOf(swindow)); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDKSwindow (swindow, ObjOf(swindow)->box); } } /* * This function draws the swindow window widget. */ static void _drawCDKSwindow (CDKOBJS *object, boolean Box) { CDKSWINDOW *swindow = (CDKSWINDOW *)object; /* Do we need to draw in the shadow. */ if (swindow->shadowWin != 0) { drawShadow (swindow->shadowWin); } /* Box the widget if needed */ if (Box) { drawObjBox (swindow->win, ObjOf(swindow)); } drawCdkTitle (swindow->win, object); wrefresh (swindow->win); /* Draw in the list. */ drawCDKSwindowList (swindow, Box); } /* * This draws in the contents of the scrolling window. */ static void drawCDKSwindowList (CDKSWINDOW *swindow, boolean Box GCC_UNUSED) { int lastLine, screenPos, x; /* Determine the last line to draw. */ if (swindow->listSize < swindow->viewSize) { lastLine = swindow->listSize; } else { lastLine = swindow->viewSize; } /* Erase the scrolling window. */ werase (swindow->fieldWin); /* Start drawing in each line. */ for (x=0; x < lastLine; x++) { screenPos = swindow->listPos[x + swindow->currentTop]-swindow->leftChar; /* Write in the correct line. */ if (screenPos >= 0) { writeChtype (swindow->fieldWin, screenPos, x, swindow->list[x + swindow->currentTop], HORIZONTAL, 0, swindow->listLen[x + swindow->currentTop]); } else { writeChtype (swindow->fieldWin, 0, x, swindow->list[x + swindow->currentTop], HORIZONTAL, swindow->leftChar - swindow->listPos[x + swindow->currentTop], swindow->listLen[x + swindow->currentTop]); } } wrefresh (swindow->fieldWin); } /* * This sets the background attribute of the widget. */ static void _setBKattrSwindow (CDKOBJS *object, chtype attrib) { if (object != 0) { CDKSWINDOW *widget = (CDKSWINDOW *) object; wbkgd (widget->win, attrib); wbkgd (widget->fieldWin, attrib); } } /* * Free any storage associated with the info-list. */ static void destroyInfo(CDKSWINDOW *swindow) { CDKfreeChtypes (swindow->list); freeChecked (swindow->listPos); freeChecked (swindow->listLen); swindow->list = 0; swindow->listPos = 0; swindow->listLen = 0; } /* * This function destroys the scrolling window widget. */ static void _destroyCDKSwindow (CDKOBJS *object) { if (object != 0) { CDKSWINDOW *swindow = (CDKSWINDOW *)object; destroyInfo(swindow); cleanCdkTitle (object); /* Delete the windows. */ deleteCursesWindow (swindow->shadowWin); deleteCursesWindow (swindow->fieldWin); deleteCursesWindow (swindow->win); /* Clean the key bindings. */ cleanCDKObjectBindings (vSWINDOW, swindow); /* Unregister this object. */ unregisterCDKObject (vSWINDOW, swindow); } } /* * This function erases the scrolling window widget. */ static void _eraseCDKSwindow (CDKOBJS *object) { if (validCDKObject (object)) { CDKSWINDOW *swindow = (CDKSWINDOW *)object; eraseCursesWindow (swindow->win); eraseCursesWindow (swindow->shadowWin); } } /* * This exec's a command and redirects the output to the scrolling window. */ int execCDKSwindow (CDKSWINDOW *swindow, char *command, int insertPos) { FILE *ps; char temp[BUFSIZ]; int count = -1; endwin(); /* Try to open the command. */ if ((ps = popen (command, "r")) != 0) { /* Start reading. */ while (fgets (temp, sizeof(temp), ps) != 0) { size_t len = strlen(temp); if (len != 0 && temp[len-1] == '\n') temp[--len] = '\0'; /* Add the line to the scrolling window. */ addCDKSwindow (swindow, temp, insertPos); count++; } /* Close the pipe. */ pclose (ps); } return count; } static void showMessage2(CDKSWINDOW *swindow, char *msg, char *msg2, char *filename) { char *mesg[10]; char *temp = (char *)malloc(80 + strlen(filename)); int n = 0; mesg[n++] = copyChar (msg); mesg[n++] = copyChar (msg2); sprintf (temp, "(%s)", filename); mesg[n++] = copyChar (temp); mesg[n++] = copyChar (" "); mesg[n++] = copyChar ("Press any key to continue."); popupLabel (ScreenOf(swindow), mesg, n); freeCharList (mesg, n); free (temp); } /* * This function allows the user to dump the information from the * scrolling window to a file. */ void saveCDKSwindowInformation (CDKSWINDOW *swindow) { CDKENTRY *entry = 0; char *filename = 0; char temp[256], *mesg[10]; int linesSaved; /* Create the entry field to get the filename. */ entry = newCDKEntry (ScreenOf(swindow), CENTER, CENTER, "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] = "Save Canceled."; mesg[1] = "Escape hit. Scrolling window information not saved."; mesg[2] = " "; mesg[3] = "Press any key to continue."; popupLabel (ScreenOf(swindow), mesg, 4); /* Clean up and exit. */ destroyCDKEntry (entry); return; } /* Write the contents of the scrolling window to the file. */ linesSaved = dumpCDKSwindow (swindow, filename); /* Was the save successful? */ if (linesSaved == -1) { /* Nope, tell 'em. */ showMessage2(swindow, "Error", "Could not save to the file.", filename); } else { /* Yep, let them know how many lines were saved. */ sprintf (temp, "There were %d lines saved to the file", linesSaved); showMessage2(swindow, "Save Successful", temp, filename); } /* Clean up and exit. */ destroyCDKEntry (entry); eraseCDKScreen (ScreenOf(swindow)); drawCDKScreen (ScreenOf(swindow)); } /* * This function allows the user to load new information into the scrolling * window. */ void loadCDKSwindowInformation (CDKSWINDOW *swindow) { CDKFSELECT *fselect = 0; CDKDIALOG *dialog = 0; char *filename = 0; char *mesg[15], *button[5], **fileInfo = 0; int lines, answer; /* Create the file selector to choose the file. */ fselect = newCDKFselect (ScreenOf(swindow), CENTER, CENTER, 20, 55, "Load Which File", "Filename", A_NORMAL, '.', A_REVERSE, "", "", "", "", TRUE, FALSE); /* Get the filename to load. */ filename = activateCDKFselect (fselect, 0); /* Make sure they selected a file. */ if (fselect->exitType == vESCAPE_HIT) { /* Popup a message. */ mesg[0] = "Load Canceled."; mesg[1] = " "; mesg[2] = "Press any key to continue."; popupLabel (ScreenOf(swindow), mesg, 3); /* Clean up and exit. */ destroyCDKFselect (fselect); return; } /* Copy the filename and destroy the file selector. */ filename = copyChar (fselect->pathname); destroyCDKFselect (fselect); /* * Maye we should check before nuking all the information * in the scrolling window... */ if (swindow->listSize > 0) { /* Create the dialog message. */ mesg[0] = "Save Information First"; mesg[1] = "There is information in the scrolling window."; mesg[2] = "Do you want to save it to a file first?"; button[0] = "(Yes)"; button[1] = "(No)"; /* Create the dialog widget. */ dialog = newCDKDialog (ScreenOf(swindow), CENTER, CENTER, mesg, 3, button, 2, COLOR_PAIR(2)|A_REVERSE, TRUE, TRUE, FALSE); /* Activate the widget. */ answer = activateCDKDialog (dialog, 0); destroyCDKDialog (dialog); /* Check the answer. */ if (answer == -1 || answer == 0) { /* Save the information. */ saveCDKSwindowInformation (swindow); } } /* Open the file and read it in. */ lines = CDKreadFile (filename, &fileInfo); if (lines == -1) { /* The file read didn't work. */ showMessage2(swindow, "Error", "Could not read the file", filename); freeChar (filename); return; } /* Clean out the scrolling window. */ cleanCDKSwindow (swindow); /* Set the new information in the scrolling window. */ setCDKSwindow (swindow, fileInfo, lines, ObjOf(swindow)->box); /* Clean up. */ CDKfreeStrings (fileInfo); freeChar (filename); } /* * This actually dumps the information from the scrolling window to a * file. */ int dumpCDKSwindow (CDKSWINDOW *swindow, char *filename) { FILE *outputFile = 0; char *rawLine = 0; int x; /* Try to open the file. */ if ((outputFile = fopen (filename, "w")) == 0) { return -1; } /* Start writing out the file. */ for (x=0; x < swindow->listSize; x++) { rawLine = chtype2Char (swindow->list[x]); fprintf (outputFile, "%s\n", rawLine); freeChar (rawLine); } /* Close the file and return the number of lines written. */ fclose (outputFile); return swindow->listSize; } static void _focusCDKSwindow(CDKOBJS *object) { CDKSWINDOW *widget = (CDKSWINDOW *)object; drawCDKSwindow (widget, ObjOf(widget)->box); } static void _unfocusCDKSwindow(CDKOBJS *object) { CDKSWINDOW *widget = (CDKSWINDOW *)object; drawCDKSwindow (widget, ObjOf(widget)->box); } static int createList(CDKSWINDOW *swindow, int listSize) { int status = 0; if (listSize <= 0) { destroyInfo(swindow); status = 1; } else { chtype **newList = typeCallocN(chtype *, listSize + 1); int *newPos = typeCallocN(int, listSize + 1); int *newLen = typeCallocN(int, listSize + 1); if (newList != 0 && newPos != 0 && newLen != 0) { status = 1; destroyInfo(swindow); swindow->list = newList; swindow->listPos = newPos; swindow->listLen = newLen; } if (!status) { CDKfreeChtypes (newList); freeChecked (newPos); freeChecked (newLen); } } return status; } dummyRefreshData(Swindow) dummySaveData(Swindow) cdk-5.0-20060507/template.c0000644000175100001440000005017310426516000013516 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:27:44 $ * $Revision: 1.130 $ */ /* * Declare file local prototypes. */ static void CDKTemplateCallBack (CDKTEMPLATE *widget, chtype input); static void drawCDKTemplateField (CDKTEMPLATE *widget); static void adjustCDKTemplateCursor (CDKTEMPLATE *widget, int direction); #define isPlateChar(c) ((c) != 0 && strchr ("#ACcMXz", c) != 0) DeclareCDKObjects (TEMPLATE, Template, setCdk, String); /* * This creates a cdktemplate widget. */ CDKTEMPLATE *newCDKTemplate (CDKSCREEN *cdkscreen, int xplace, int yplace, char *title, char *label, char *plate, char *Overlay, boolean Box, boolean shadow) { CDKTEMPLATE *cdktemplate = 0; int parentWidth = getmaxx (cdkscreen->window); int parentHeight = getmaxy (cdkscreen->window); int boxWidth = 0; int boxHeight = Box ? 3 : 1; int xpos = xplace; int ypos = yplace; int horizontalAdjust, oldWidth; int fieldWidth = 0; int plateLen = 0; int junk = 0; if (plate == 0 || (cdktemplate = newCDKObject (CDKTEMPLATE, &my_funcs)) == 0) return (0); setCDKTemplateBox (cdktemplate, Box); fieldWidth = (int)strlen (plate) + 2 * BorderOf (cdktemplate); /* Set some basic values of the cdktemplate field. */ cdktemplate->label = 0; cdktemplate->labelLen = 0; cdktemplate->labelWin = 0; /* Translate the char * label to a chtype * */ if (label != 0) { cdktemplate->label = char2Chtype (label, &cdktemplate->labelLen, &junk); } /* Translate the char * Overlay to a chtype * */ if (Overlay != 0) { cdktemplate->overlay = char2Chtype (Overlay, &cdktemplate->overlayLen, &junk); cdktemplate->fieldAttr = cdktemplate->overlay[0] & A_ATTRIBUTES; } else { cdktemplate->overlay = 0; cdktemplate->overlayLen = 0; cdktemplate->fieldAttr = A_NORMAL; } /* Set the box width. */ boxWidth = fieldWidth + cdktemplate->labelLen + 2 * BorderOf (cdktemplate); oldWidth = boxWidth; boxWidth = setCdkTitle (ObjOf (cdktemplate), title, boxWidth); horizontalAdjust = (boxWidth - oldWidth) / 2; boxHeight += TitleLinesOf (cdktemplate); /* * Make sure we didn't extend beyond the dimensions of the window. */ boxWidth = MINIMUM (boxWidth, parentWidth); boxHeight = MINIMUM (boxHeight, parentHeight); fieldWidth = MINIMUM (fieldWidth, boxWidth - cdktemplate->labelLen - 2 * BorderOf (cdktemplate)); /* Rejustify the x and y positions if we need to. */ alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight); /* Make the cdktemplate window */ cdktemplate->win = newwin (boxHeight, boxWidth, ypos, xpos); /* Is the cdktemplate window null?? */ if (cdktemplate->win == 0) { destroyCDKObject (cdktemplate); return (0); } keypad (cdktemplate->win, TRUE); /* Make the label window. */ if (cdktemplate->label != 0) { cdktemplate->labelWin = subwin (cdktemplate->win, 1, cdktemplate->labelLen, (ypos + TitleLinesOf (cdktemplate) + BorderOf (cdktemplate)), (xpos + horizontalAdjust + BorderOf (cdktemplate))); } /* Make the field window. */ cdktemplate->fieldWin = subwin (cdktemplate->win, 1, fieldWidth, (ypos + TitleLinesOf (cdktemplate) + BorderOf (cdktemplate)), (xpos + cdktemplate->labelLen + horizontalAdjust + BorderOf (cdktemplate))); keypad (cdktemplate->fieldWin, TRUE); /* Set up the info field. */ cdktemplate->plateLen = (int)strlen (plate); cdktemplate->info = typeCallocN (char, cdktemplate->plateLen + 2); if (cdktemplate->info == 0) { destroyCDKObject (cdktemplate); return (0); } /* Copy the plate to the cdktemplate. */ plateLen = strlen (plate); cdktemplate->plate = typeMallocN (char, plateLen + 3); if (cdktemplate->plate == 0) { destroyCDKObject (cdktemplate); return (0); } strcpy (cdktemplate->plate, plate); /* Set up the rest of the structure */ ScreenOf (cdktemplate) = cdkscreen; cdktemplate->parent = cdkscreen->window; cdktemplate->shadowWin = 0; cdktemplate->fieldWidth = fieldWidth; cdktemplate->boxHeight = boxHeight; cdktemplate->boxWidth = boxWidth; cdktemplate->platePos = 0; cdktemplate->screenPos = 0; cdktemplate->infoPos = 0; initExitType (cdktemplate); cdktemplate->min = 0; ObjOf (cdktemplate)->inputWindow = cdktemplate->win; ObjOf (cdktemplate)->acceptsFocus = TRUE; cdktemplate->shadow = shadow; cdktemplate->callbackfn = CDKTemplateCallBack; /* Do we need to create a shadow??? */ if (shadow) { cdktemplate->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1); } registerCDKObject (cdkscreen, vTEMPLATE, cdktemplate); return cdktemplate; } /* * This actually manages the cdktemplate widget... */ char *activateCDKTemplate (CDKTEMPLATE *cdktemplate, chtype *actions) { chtype input = 0; boolean functionKey; char *ret = 0; /* Draw the object. */ drawCDKTemplate (cdktemplate, ObjOf (cdktemplate)->box); if (actions == 0) { for (;;) { input = getchCDKObject (ObjOf (cdktemplate), &functionKey); /* Inject the character into the widget. */ ret = injectCDKTemplate (cdktemplate, input); if (cdktemplate->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 = injectCDKTemplate (cdktemplate, actions[x]); if (cdktemplate->exitType != vEARLY_EXIT) { return ret; } } } /* Set the exit type and return. */ setExitType (cdktemplate, 0); return ret; } /* * This injects a character into the widget. */ static int _injectCDKTemplate (CDKOBJS *object, chtype input) { CDKTEMPLATE *cdktemplate = (CDKTEMPLATE *)object; int ppReturn = 1; int length, x; char *ret = unknownString; bool complete = FALSE; /* Set the exit type and return. */ setExitType (cdktemplate, 0); /* Move the cursor. */ drawCDKTemplateField (cdktemplate); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf (cdktemplate) != 0) { ppReturn = PreProcessFuncOf (cdktemplate) (vTEMPLATE, cdktemplate, PreProcessDataOf (cdktemplate), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check a predefined binding... */ if (checkCDKObjectBind (vTEMPLATE, cdktemplate, input) != 0) { checkEarlyExit (cdktemplate); complete = TRUE; } else { switch (input) { case CDK_ERASE: if (strlen (cdktemplate->info) != 0) { cleanCDKTemplate (cdktemplate); drawCDKTemplateField (cdktemplate); } break; case CDK_CUT: if ((int)strlen (cdktemplate->info) != 0) { freeChar (GPasteBuffer); GPasteBuffer = copyChar (cdktemplate->info); cleanCDKTemplate (cdktemplate); drawCDKTemplateField (cdktemplate); } else { Beep (); } break; case CDK_COPY: if ((int)strlen (cdktemplate->info) != 0) { freeChar (GPasteBuffer); GPasteBuffer = copyChar (cdktemplate->info); } else { Beep (); } break; case CDK_PASTE: if (GPasteBuffer != 0) { cleanCDKTemplate (cdktemplate); /* Start inserting each character one at a time. */ length = (int)strlen (GPasteBuffer); for (x = 0; x < length; x++) { (cdktemplate->callbackfn) (cdktemplate, GPasteBuffer[x]); } drawCDKTemplateField (cdktemplate); } else { Beep (); } break; case KEY_TAB: case KEY_ENTER: if ((int)strlen (cdktemplate->info) < (int)cdktemplate->min) { Beep (); } else { setExitType (cdktemplate, input); ret = cdktemplate->info; complete = TRUE; } break; case KEY_ESC: setExitType (cdktemplate, input); complete = TRUE; break; case CDK_REFRESH: eraseCDKScreen (ScreenOf (cdktemplate)); refreshCDKScreen (ScreenOf (cdktemplate)); break; default: (cdktemplate->callbackfn) (cdktemplate, input); break; } } /* Should we call a post-process? */ if (!complete && (PostProcessFuncOf (cdktemplate) != 0)) { PostProcessFuncOf (cdktemplate) (vTEMPLATE, cdktemplate, PostProcessDataOf (cdktemplate), input); } } if (!complete) { setExitType (cdktemplate, 0); } ResultOf (cdktemplate).valueString = ret; return (ret != unknownString); } /* * Return true if the given string matches the template (may be incomplete). */ static boolean validTemplate (CDKTEMPLATE *cdktemplate, char *input) { int pp, ip; const char *plate = cdktemplate->plate; for (pp = 0, ip = 0; input[ip] != '\0' && plate[pp] != '\0'; ++ip, ++pp) { int newchar = input[ip]; while (plate[pp] != '\0' && !isPlateChar (plate[pp])) { ++pp; } if (plate[pp] == 0) { return FALSE; } /* check if the input matches the plate */ if (isdigit (CharOf (newchar)) && (plate[pp] == 'A' || plate[pp] == 'C' || plate[pp] == 'c')) { return FALSE; } if (!isdigit (CharOf (newchar)) && plate[pp] == '#') { return FALSE; } /* Do we need to convert the case??? */ if (plate[pp] == 'C' || plate[pp] == 'X') { newchar = toupper (newchar); } else if (plate[pp] == 'c' || plate[pp] == 'x') { newchar = tolower (newchar); } input[ip] = (char)newchar; } return TRUE; } /* * This is the standard callback proc for the cdktemplate. */ static void CDKTemplateCallBack (CDKTEMPLATE *cdktemplate, chtype input) { boolean failed = FALSE; boolean change = FALSE; boolean moveby = FALSE; int amount = 0; unsigned mark = cdktemplate->infoPos; unsigned have = strlen (cdktemplate->info); if (input == KEY_LEFT) { if (mark != 0) { moveby = TRUE; amount = -1; } else { failed = TRUE; } } else if (input == KEY_RIGHT) { if (cdktemplate->info[mark] != '\0') { moveby = TRUE; amount = 1; } else { failed = TRUE; } } else { char *test = malloc (have + 2); if (test != 0) { strcpy (test, cdktemplate->info); if (input == KEY_BACKSPACE) { if (mark != 0) { strcpy (test + mark - 1, cdktemplate->info + mark); change = TRUE; amount = -1; } else { failed = TRUE; } } else if (input == KEY_DC) { if (test[mark] != '\0') { strcpy (test + mark, cdktemplate->info + mark + 1); change = TRUE; amount = 0; } else { failed = TRUE; } } else if (isChar (input) && cdktemplate->platePos < cdktemplate->fieldWidth) { test[mark] = CharOf (input); strcpy (test + mark + 1, cdktemplate->info + mark); change = TRUE; amount = 1; } else { failed = TRUE; } if (change) { if (validTemplate (cdktemplate, test)) { strcpy (cdktemplate->info, test); drawCDKTemplateField (cdktemplate); } else { failed = TRUE; } } free (test); } } if (failed) { Beep (); } else if (change || moveby) { cdktemplate->infoPos += amount; cdktemplate->platePos += amount; cdktemplate->screenPos += amount; adjustCDKTemplateCursor (cdktemplate, amount); } } /* * Return a mixture of the plate-overlay and field-info. */ char *mixCDKTemplate (CDKTEMPLATE *cdktemplate) { char *mixedString = 0; int platePos = 0; int infoPos = 0; if (cdktemplate->info != 0 && cdktemplate->info[0] != '\0') { mixedString = typeCallocN (char, cdktemplate->plateLen + 3); if (mixedString != 0) { while (platePos < cdktemplate->plateLen) { mixedString[platePos] = (isPlateChar (cdktemplate->plate[platePos]) ? cdktemplate->info[infoPos++] : cdktemplate->plate[platePos]); platePos++; } } } return mixedString; } /* * Return the field-info from the mixed string. */ char *unmixCDKTemplate (CDKTEMPLATE *cdktemplate, char *info) { int x = 0; int pos = 0; int infolen = (int)strlen (info); char *unmixedString = typeCallocN (char, infolen + 2); if (unmixedString != 0) { while (pos < infolen) { if (isPlateChar (cdktemplate->plate[pos])) { unmixedString[x++] = info[pos++]; } else { pos++; } } } return unmixedString; } /* * Move the cdktemplate field to the given location. */ static void _moveCDKTemplate (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDKTEMPLATE *cdktemplate = (CDKTEMPLATE *)object; int currentX = getbegx (cdktemplate->win); int currentY = getbegy (cdktemplate->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 (cdktemplate->win) + xplace; ypos = getbegy (cdktemplate->win) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf (cdktemplate), &xpos, &ypos, cdktemplate->boxWidth, cdktemplate->boxHeight); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the window to the new location. */ moveCursesWindow (cdktemplate->win, -xdiff, -ydiff); moveCursesWindow (cdktemplate->labelWin, -xdiff, -ydiff); moveCursesWindow (cdktemplate->fieldWin, -xdiff, -ydiff); moveCursesWindow (cdktemplate->shadowWin, -xdiff, -ydiff); /* Touch the windows so they 'move'. */ refreshCDKWindow (WindowOf (cdktemplate)); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDKTemplate (cdktemplate, ObjOf (cdktemplate)->box); } } /* * Draw the template widget. */ static void _drawCDKTemplate (CDKOBJS *object, boolean Box) { CDKTEMPLATE *cdktemplate = (CDKTEMPLATE *)object; /* Do we need to draw the shadow. */ if (cdktemplate->shadowWin != 0) { drawShadow (cdktemplate->shadowWin); } /* Box it if needed */ if (Box) { drawObjBox (cdktemplate->win, ObjOf (cdktemplate)); } drawCdkTitle (cdktemplate->win, object); wrefresh (cdktemplate->win); drawCDKTemplateField (cdktemplate); } /* * Draw the cdktemplate field. */ static void drawCDKTemplateField (CDKTEMPLATE *cdktemplate) { chtype fieldColor = 0; int infolen = (int)strlen (cdktemplate->info); int x = 0; /* Draw in the label and the cdktemplate object. */ if (cdktemplate->labelWin != 0) { writeChtype (cdktemplate->labelWin, 0, 0, cdktemplate->label, HORIZONTAL, 0, cdktemplate->labelLen); wrefresh (cdktemplate->labelWin); } /* Draw in the cdktemplate... */ if (cdktemplate->overlay != 0) { writeChtype (cdktemplate->fieldWin, 0, 0, cdktemplate->overlay, HORIZONTAL, 0, cdktemplate->overlayLen); } /* Adjust the cursor. */ if (infolen != 0) { int pos = 0; for (x = 0; x < cdktemplate->fieldWidth; x++) { if (isPlateChar (cdktemplate->plate[x]) && pos < infolen) { fieldColor = cdktemplate->overlay[x] & A_ATTRIBUTES; mvwaddch (cdktemplate->fieldWin, 0, x, CharOf (cdktemplate->info[pos++]) | fieldColor); } } wmove (cdktemplate->fieldWin, 0, cdktemplate->screenPos); } else { adjustCDKTemplateCursor (cdktemplate, +1); } wrefresh (cdktemplate->fieldWin); } /* * Adjust the cursor for the cdktemplate. */ static void adjustCDKTemplateCursor (CDKTEMPLATE *cdktemplate, int direction) { while (!isPlateChar (cdktemplate->plate[cdktemplate->platePos]) && cdktemplate->platePos < cdktemplate->fieldWidth) { cdktemplate->platePos += direction; cdktemplate->screenPos += direction; } wmove (cdktemplate->fieldWin, 0, cdktemplate->screenPos); wrefresh (cdktemplate->fieldWin); } /* * Set the background attribute of the widget. */ static void _setBKattrTemplate (CDKOBJS *object, chtype attrib) { if (object != 0) { CDKTEMPLATE *widget = (CDKTEMPLATE *)object; wbkgd (widget->win, attrib); wbkgd (widget->fieldWin, attrib); if (widget->labelWin != 0) { wbkgd (widget->labelWin, attrib); } } } /* * Destroy this widget. */ static void _destroyCDKTemplate (CDKOBJS *object) { if (object != 0) { CDKTEMPLATE *cdktemplate = (CDKTEMPLATE *)object; cleanCdkTitle (object); freeChtype (cdktemplate->label); freeChtype (cdktemplate->overlay); freeChar (cdktemplate->plate); freeChar (cdktemplate->info); /* Delete the windows. */ deleteCursesWindow (cdktemplate->fieldWin); deleteCursesWindow (cdktemplate->labelWin); deleteCursesWindow (cdktemplate->shadowWin); deleteCursesWindow (cdktemplate->win); /* Clean the key bindings. */ cleanCDKObjectBindings (vTEMPLATE, cdktemplate); unregisterCDKObject (vTEMPLATE, cdktemplate); } } /* * Erase the widget. */ static void _eraseCDKTemplate (CDKOBJS *object) { if (validCDKObject (object)) { CDKTEMPLATE *cdktemplate = (CDKTEMPLATE *)object; eraseCursesWindow (cdktemplate->fieldWin); eraseCursesWindow (cdktemplate->labelWin); eraseCursesWindow (cdktemplate->win); eraseCursesWindow (cdktemplate->shadowWin); } } /* * Set the value given to the cdktemplate. */ void setCDKTemplate (CDKTEMPLATE *cdktemplate, char *newValue, boolean Box) { setCDKTemplateValue (cdktemplate, newValue); setCDKTemplateBox (cdktemplate, Box); } /* * Set the value given to the cdktemplate. */ void setCDKTemplateValue (CDKTEMPLATE *cdktemplate, char *newValue) { int len = 0; int copychars = 0; int x; /* Just to be sure, if let's make sure the new value isn't null. */ if (newValue == 0) { cleanCDKTemplate (cdktemplate); return; } /* Determine how many characters we need to copy. */ len = (int)strlen (newValue); copychars = MINIMUM (len, cdktemplate->fieldWidth); /* OK, erase the old value, and copy in the new value. */ cdktemplate->info[0] = '\0'; strncpy (cdktemplate->info, newValue, copychars); /* Use the function which handles the input of the characters. */ for (x = 0; x < len; x++) { (cdktemplate->callbackfn) (cdktemplate, (chtype)newValue[x]); } } char *getCDKTemplateValue (CDKTEMPLATE *cdktemplate) { return cdktemplate->info; } /* * Set the minimum number of characters to enter into the widget. */ void setCDKTemplateMin (CDKTEMPLATE *cdktemplate, int min) { if (min >= 0) { cdktemplate->min = min; } } int getCDKTemplateMin (CDKTEMPLATE *cdktemplate) { return cdktemplate->min; } /* * Set the box attribute of the cdktemplate widget. */ void setCDKTemplateBox (CDKTEMPLATE *cdktemplate, boolean Box) { ObjOf (cdktemplate)->box = Box; ObjOf (cdktemplate)->borderSize = Box ? 1 : 0; } boolean getCDKTemplateBox (CDKTEMPLATE *cdktemplate) { return ObjOf (cdktemplate)->box; } /* * Erase the information in the cdktemplate widget. */ void cleanCDKTemplate (CDKTEMPLATE *cdktemplate) { cdktemplate->info[0] = '\0'; cdktemplate->screenPos = 0; cdktemplate->infoPos = 0; cdktemplate->platePos = 0; } /* * Set the callback function for the widget. */ void setCDKTemplateCB (CDKTEMPLATE *cdktemplate, TEMPLATECB callback) { cdktemplate->callbackfn = callback; } static void _focusCDKTemplate (CDKOBJS *object) { CDKTEMPLATE *widget = (CDKTEMPLATE *)object; drawCDKTemplate (widget, ObjOf (widget)->box); } static void _unfocusCDKTemplate (CDKOBJS *object) { CDKTEMPLATE *widget = (CDKTEMPLATE *)object; drawCDKTemplate (widget, ObjOf (widget)->box); } dummyRefreshData (Template) dummySaveData (Template) cdk-5.0-20060507/traverse.c0000644000175100001440000001544310355107105013542 0ustar tomusers#include /* * $Author: tom $ * $Date: 2005/12/30 01:32:53 $ * $Revision: 1.21 $ */ #define limitFocusIndex(screen, value) \ (((value) >= (screen)->objectCount || (value) < 0) \ ? 0 \ : (value)) static int getFocusIndex (CDKSCREEN *screen) { int result = limitFocusIndex (screen, screen->objectFocus); return result; } static void setFocusIndex (CDKSCREEN *screen, int value) { screen->objectFocus = limitFocusIndex (screen, value); } static void unsetFocus (CDKOBJS *obj) { curs_set (0); if (obj != 0) { HasFocusObj (obj) = FALSE; UnfocusObj (obj); } } static void setFocus (CDKOBJS *obj) { if (obj != 0) { HasFocusObj (obj) = TRUE; FocusObj (obj); } curs_set (1); } static CDKOBJS *switchFocus (CDKOBJS *newobj, CDKOBJS *oldobj) { if (oldobj != newobj) { unsetFocus (oldobj); setFocus (newobj); } return newobj; } static boolean checkMenuKey (int keyCode, int functionKey) { int result = FALSE; result = (keyCode == KEY_ESC && !functionKey); return result; } static CDKOBJS *handleMenu (CDKSCREEN *screen, CDKOBJS *menu, CDKOBJS *oldobj) { bool done = FALSE; CDKOBJS *newobj; switchFocus (menu, oldobj); while (!done) { boolean functionKey; int key = getchCDKObject (menu, &functionKey); switch (key) { case KEY_TAB: done = TRUE; break; case KEY_ESC: /* cleanup the menu */ injectCDKMenu ((CDKMENU *)menu, key); done = TRUE; break; default: done = (injectCDKMenu ((CDKMENU *)menu, key) >= 0); break; } } if ((newobj = getCDKFocusCurrent (screen)) == 0) newobj = setCDKFocusNext (screen); return switchFocus (newobj, menu); } /* * Save data in widgets on a screen */ static void saveDataCDKScreen (CDKSCREEN *screen) { int i; for (i = 0; i < screen->objectCount; ++i) SaveDataObj (screen->object[i]); } /* * Refresh data in widgets on a screen */ static void refreshDataCDKScreen (CDKSCREEN *screen) { int i; for (i = 0; i < screen->objectCount; ++i) RefreshDataObj (screen->object[i]); } /* * ====================================================================== * Public Interface */ void resetCDKScreen (CDKSCREEN *screen) { refreshDataCDKScreen (screen); } void exitOKCDKScreen (CDKSCREEN *screen) { screen->exitStatus = CDKSCREEN_EXITOK; } void exitCancelCDKScreen (CDKSCREEN *screen) { screen->exitStatus = CDKSCREEN_EXITCANCEL; } void exitOKCDKScreenOf (CDKOBJS *obj) { exitOKCDKScreen (obj->screen); } void exitCancelCDKScreenOf (CDKOBJS *obj) { exitCancelCDKScreen (obj->screen); } void resetCDKScreenOf (CDKOBJS *obj) { resetCDKScreen (obj->screen); } /* * Returns the object on which the focus lies. */ CDKOBJS *getCDKFocusCurrent (CDKSCREEN *screen) { CDKOBJS *result = 0; int n = screen->objectFocus; if (n >= 0 && n < screen->objectCount) result = screen->object[n]; return result; } /* * Set focus to the next object, returning it. */ CDKOBJS *setCDKFocusNext (CDKSCREEN *screen) { CDKOBJS *result = 0; CDKOBJS *curobj; int n = getFocusIndex (screen); int first = n; for (;;) { if (++n >= screen->objectCount) n = 0; curobj = screen->object[n]; if (curobj != 0 && AcceptsFocusObj (curobj)) { result = curobj; break; } else { if (n == first) { break; } } } setFocusIndex (screen, (result != 0) ? n : -1); return result; } /* * Set focus to the previous object, returning it. */ CDKOBJS *setCDKFocusPrevious (CDKSCREEN *screen) { CDKOBJS *result = 0; CDKOBJS *curobj; int n = getFocusIndex (screen); int first = n; for (;;) { if (--n < 0) n = screen->objectCount - 1; curobj = screen->object[n]; if (curobj != 0 && AcceptsFocusObj (curobj)) { result = curobj; break; } else if (n == first) { break; } } setFocusIndex (screen, (result != 0) ? n : -1); return result; } /* * Set focus to a specific object, returning it. * If the object cannot be found, return null. */ CDKOBJS *setCDKFocusCurrent (CDKSCREEN *screen, CDKOBJS *newobj) { CDKOBJS *result = 0; CDKOBJS *curobj; int n = getFocusIndex (screen); int first = n; for (;;) { if (++n >= screen->objectCount) n = 0; curobj = screen->object[n]; if (curobj == newobj) { result = curobj; break; } else if (n == first) { break; } } setFocusIndex (screen, (result != 0) ? n : -1); return result; } /* * Set focus to the first object in the screen. */ CDKOBJS *setCDKFocusFirst (CDKSCREEN *screen) { setFocusIndex (screen, screen->objectCount - 1); return switchFocus (setCDKFocusNext (screen), 0); } /* * Set focus to the last object in the screen. */ CDKOBJS *setCDKFocusLast (CDKSCREEN *screen) { setFocusIndex (screen, 0); return switchFocus (setCDKFocusPrevious (screen), 0); } void traverseCDKOnce (CDKSCREEN *screen, CDKOBJS *curobj, int keyCode, boolean functionKey, CHECK_KEYCODE funcMenuKey) { switch (keyCode) { case KEY_BTAB: switchFocus (setCDKFocusPrevious (screen), curobj); break; case KEY_TAB: switchFocus (setCDKFocusNext (screen), curobj); break; case KEY_F (10): /* save data and exit */ exitOKCDKScreen (screen); break; case CTRL ('X'): exitCancelCDKScreen (screen); break; case CTRL ('R'): /* reset data to defaults */ resetCDKScreen (screen); setFocus (curobj); break; case CDK_REFRESH: /* redraw screen */ refreshCDKScreen (screen); setFocus (curobj); break; default: /* not everyone wants menus, so we make them optional here */ if (funcMenuKey != 0 && funcMenuKey (keyCode, functionKey)) { /* find and enable drop down menu */ int j; for (j = 0; j < screen->objectCount; ++j) if (ObjTypeOf (screen->object[j]) == vMENU) { handleMenu (screen, screen->object[j], curobj); break; } } else { InjectObj (curobj, keyCode); } break; } } /* * Traverse the widgets on a screen. */ int traverseCDKScreen (CDKSCREEN *screen) { int result = 0; CDKOBJS *curobj = setCDKFocusFirst (screen); if (curobj != 0) { refreshDataCDKScreen (screen); screen->exitStatus = CDKSCREEN_NOEXIT; while (((curobj = getCDKFocusCurrent (screen)) != 0) && (screen->exitStatus == CDKSCREEN_NOEXIT)) { int key; boolean function; key = getchCDKObject (curobj, &function); traverseCDKOnce (screen, curobj, key, function, checkMenuKey); } if (screen->exitStatus == CDKSCREEN_EXITOK) { saveDataCDKScreen (screen); result = 1; } } return result; } cdk-5.0-20060507/version.c0000644000175100001440000000030607516127473013403 0ustar tomusers#include /* * $Author: tom $ * $Date: 2002/07/20 00:30:51 $ * $Revision: 1.1 $ */ char * CDKVersion(void) { return CDK_VERSION_MAJOR "." CDK_VERSION_MINOR " - " CDK_VERSION_PATCH; } cdk-5.0-20060507/view_file.c0000644000175100001440000000120610354111550013646 0ustar tomusers#include /* * $Author: tom $ * $Date: 2005/12/27 01:05:44 $ * $Revision: 1.3 $ */ /* * This allows the user to view a file. */ int viewFile (CDKSCREEN *screen, char *title, char *filename, char **buttons, int buttonCount) { int result; int lines = 0; char **info = 0; /* Open the file and read the contents. */ lines = CDKreadFile (filename, &info); /* If we couldn't read the file, return an error. */ if (lines == -1) { result = lines; } else { result = viewInfo(screen, title, info, lines, buttons, buttonCount, TRUE); CDKfreeStrings (info); } return result; } cdk-5.0-20060507/view_info.c0000644000175100001440000000172007761472447013712 0ustar tomusers#include /* * $Author: tom $ * $Date: 2003/11/27 22:05:27 $ * $Revision: 1.1 $ */ /* * This allows the user to view information. */ int viewInfo (CDKSCREEN *screen, char *title, char **info, int count, char **buttons, int buttonCount, boolean interpret) { CDKVIEWER *viewer = 0; int selected = -1; /* Create the file viewer to view the file selected.*/ viewer = newCDKViewer (screen, CENTER, CENTER, -6, -16, buttons, buttonCount, A_REVERSE, TRUE, TRUE); /* Set up the viewer title, and the contents to the widget. */ setCDKViewer (viewer, title, info, count, A_REVERSE, interpret, TRUE, TRUE); /* Activate the viewer widget. */ selected = activateCDKViewer (viewer, 0); /* Make sure they exited normally. */ if (viewer->exitType != vNORMAL) { destroyCDKViewer (viewer); return (-1); } /* Clean up and return the button index selected. */ destroyCDKViewer (viewer); return selected; } cdk-5.0-20060507/viewer.c0000644000175100001440000007117110426516000013205 0ustar tomusers#include /* * $Author: tom $ * $Date: 2006/05/05 00:27:44 $ * $Revision: 1.156 $ */ /* * Declare some local definitions. */ #define DOWN 0 #define UP 1 /* * Declare file local prototypes. */ static int createList (CDKVIEWER *swindow, int listSize); static int searchForWord (CDKVIEWER *viewer, char *pattern, int direction); static int jumpToLine (CDKVIEWER *viewer); static void popUpLabel (CDKVIEWER *viewer, char **mesg); static void getAndStorePattern (CDKSCREEN *screen); static void drawCDKViewerButtons (CDKVIEWER *viewer); static void drawCDKViewerInfo (CDKVIEWER *viewer); /* * Declare file local variables. */ static char * SearchPattern = 0; static int SearchDirection = DOWN; DeclareCDKObjects (VIEWER, Viewer, setCdk, Unknown); /* * This function creates a new viewer object. */ CDKVIEWER *newCDKViewer (CDKSCREEN *cdkscreen, int xplace, int yplace, int height, int width, char **buttons, int buttonCount, chtype buttonHighlight, boolean Box, boolean shadow) { CDKVIEWER *viewer = 0; int parentWidth = getmaxx (cdkscreen->window); int parentHeight = getmaxy (cdkscreen->window); int boxWidth = width; int boxHeight = height; int xpos = xplace; int ypos = yplace; int buttonWidth = 0; int buttonAdj = 0; int buttonPos = 1; int x = 0; /* *INDENT-OFF* */ static const struct { int from; int to; } bindings[] = { { CDK_BACKCHAR, KEY_PPAGE }, { 'b', KEY_PPAGE }, { 'B', KEY_PPAGE }, { CDK_FORCHAR, KEY_NPAGE }, { SPACE, KEY_NPAGE }, { 'f', KEY_NPAGE }, { 'F', KEY_NPAGE }, { '|', KEY_HOME }, { '$', KEY_END }, }; /* *INDENT-ON* */ if ((viewer = newCDKObject (CDKVIEWER, &my_funcs)) == 0) return (0); setCDKViewerBox (viewer, Box); boxHeight = setWidgetDimension (parentHeight, height, 0); boxWidth = setWidgetDimension (parentWidth, width, 0); /* Rejustify the x and y positions if we need to. */ alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight); /* Make the viewer window. */ viewer->win = newwin (boxHeight, boxWidth, ypos, xpos); if (viewer->win == 0) { destroyCDKObject (viewer); return (0); } /* Turn the keypad on for the viewer. */ keypad (viewer->win, TRUE); /* Create the buttons. */ viewer->buttonCount = buttonCount; if (buttonCount > 0) { if ((viewer->button = typeCallocN (chtype *, buttonCount + 1)) == 0 || (viewer->buttonLen = typeCallocN (int, buttonCount + 1)) == 0 || (viewer->buttonPos = typeCallocN (int, buttonCount + 1)) == 0) { destroyCDKObject (viewer); return (0); } for (x=0; x < buttonCount; x++) { viewer->button[x] = char2Chtype (buttons[x], &viewer->buttonLen[x], &buttonAdj); buttonWidth += viewer->buttonLen[x] + 1; } buttonAdj = (int)((boxWidth-buttonWidth)/ (buttonCount +1)); buttonPos = 1 + buttonAdj; for (x=0; x < buttonCount; x++) { viewer->buttonPos[x] = buttonPos; buttonPos += buttonAdj + viewer->buttonLen[x]; } } /* Set the rest of the variables */ ScreenOf (viewer) = cdkscreen; viewer->parent = cdkscreen->window; viewer->shadowWin = 0; viewer->buttonHighlight = buttonHighlight; viewer->boxHeight = boxHeight; viewer->boxWidth = boxWidth - 2; viewer->viewSize = height - 2; ObjOf (viewer)->inputWindow = viewer->win; initExitType (viewer); viewer->shadow = shadow; viewer->currentButton = 0; viewer->currentTop = 0; viewer->length = 0; viewer->leftChar = 0; viewer->maxLeftChar = 0; viewer->maxTopLine = 0; viewer->characters = 0; viewer->listSize = -1; viewer->showLineInfo = 1; viewer->exitType = vEARLY_EXIT; /* Do we need to create a shadow??? */ if (shadow) { viewer->shadowWin = newwin (boxHeight, boxWidth + 1, ypos + 1, xpos + 1); if (viewer->shadowWin == 0) { destroyCDKObject (viewer); return (0); } } /* Setup the key bindings. */ for (x = 0; x < (int)SIZEOF (bindings); ++x) bindCDKObject (vVIEWER, viewer, bindings[x].from, getcCDKBind, (void *)(long)bindings[x].to); registerCDKObject (cdkscreen, vVIEWER, viewer); return (viewer); } /* * This function sets various attributes of the widget. */ int setCDKViewer (CDKVIEWER *viewer, char *title, char **list, int listSize, chtype buttonHighlight, boolean attrInterp, boolean showLineInfo, boolean Box) { setCDKViewerTitle (viewer, title); setCDKViewerHighlight (viewer, buttonHighlight); setCDKViewerInfoLine (viewer, showLineInfo); setCDKViewerBox (viewer, Box); return setCDKViewerInfo (viewer, list, listSize, attrInterp); } /* * This sets the title of the viewer. (A null title is allowed. * It just means that the viewer will not have a title when drawn.) */ void setCDKViewerTitle (CDKVIEWER *viewer, char *title) { (void) setCdkTitle (ObjOf (viewer), title, - (viewer->boxWidth + 1)); viewer->titleAdj = TitleLinesOf (viewer); /* Need to set viewer->viewSize. */ viewer->viewSize = viewer->boxHeight - (TitleLinesOf (viewer) + 1) - 2; } chtype **getCDKViewerTitle (CDKVIEWER *viewer) { return TitleOf (viewer); } static void setupLine (CDKVIEWER *viewer, boolean interpret, char *list, int x) { /* Did they ask for attribute interpretation? */ if (interpret) { viewer->list[x] = char2Chtype (list, &viewer->listLen[x], &viewer->listPos[x]); viewer->listPos[x] = justifyString (viewer->boxWidth, viewer->listLen[x], viewer->listPos[x]); } else { int len = (int)strlen (list); int pass; int y; chtype *t = 0; /* * We must convert tabs and other nonprinting characters. The curses * library normally does this, but we are bypassing it by writing * chtype's directly. */ for (pass = 0; pass < 2; ++pass) { len = 0; for (y = 0; list[y] != '\0'; ++y) { if (list[y] == '\t') { do { if (pass) t[len] = ' '; ++len; } while (len & 7); } else if (isprint (CharOf (list[y]))) { if (pass) t[len] = CharOf (list[y]); ++len; } else { const char *s = unctrl (list[y]); while (*s != 0) { if (pass) t[len] = CharOf (*s); ++len; ++s; } } } if (!pass) { viewer->list[x] = t = typeCallocN (chtype, len + 3); if (t == 0) { len = 0; break; } } } viewer->listLen[x] = len; viewer->listPos[x] = 0; } viewer->widestLine = MAXIMUM (viewer->widestLine, viewer->listLen[x]); } static void freeLine (CDKVIEWER *viewer, int x) { if (x < viewer->listSize) { freeChtype (viewer->list[x]); viewer->list[x] = 0; } } /* * This function sets the contents of the viewer. */ int setCDKViewerInfo (CDKVIEWER *viewer, char **list, int listSize, boolean interpret) { char filename[CDK_PATHMAX + 2]; int currentLine = 0; int x = 0; int viewerSize = listSize; /* * If the list-size is negative, count the length of the null-terminated * list of strings. */ if (listSize < 0) { listSize = CDKcountStrings (list); } /* compute the size of the resulting display */ viewerSize = listSize; if (list != 0 && interpret) { for (x = 0; x < listSize; ++x) { if (list[x] == 0) { viewerSize = x; /* oops - caller gave the wrong length */ break; } if (checkForLink (list[x], filename) == 1) { char **fileContents = 0; int fileLen = CDKreadFile (filename, &fileContents); if (fileLen >= 0) viewerSize += (fileLen - 1); CDKfreeStrings (fileContents); } } } /* Clean out the old viewer info. (if there is any) */ viewer->inProgress = TRUE; cleanCDKViewer (viewer); createList (viewer, viewerSize); /* Keep some semi-permanent info. */ viewer->interpret = interpret; /* Copy the information given. */ for (x = currentLine = 0; x < listSize && currentLine < viewerSize; x++) { if (list[x] == 0) { viewer->list[currentLine] = 0; viewer->listLen[currentLine] = 0; viewer->listPos[currentLine] = 0; currentLine++; } else { /* Check if we have a file link in this line. */ if (checkForLink (list[x], filename) == 1) { /* We have a link, open the file. */ char **fileContents = 0; int fileLen = 0; int fileLine = 0; /* Open the file and put it into the viewer. */ fileLen = CDKreadFile (filename, &fileContents); if (fileLen == -1) { #ifdef HAVE_START_COLOR #define FOPEN_FMT "Link Failed: Could not open the file %s" #else #define FOPEN_FMT "Link Failed: Could not open the file %s" #endif char *temp = (char *)malloc (80 + strlen (filename)); sprintf (temp, FOPEN_FMT, filename); setupLine (viewer, TRUE, temp, currentLine++); free (temp); } else { /* For each line read, copy it into the viewer. */ fileLen = MINIMUM (fileLen, (viewerSize - currentLine)); for (fileLine = 0; fileLine < fileLen; fileLine++) { if (currentLine >= viewerSize) break; setupLine (viewer, FALSE, fileContents[fileLine], currentLine); viewer->characters += viewer->listLen[currentLine]; currentLine++; } CDKfreeStrings (fileContents); } } else if (currentLine < viewerSize) { setupLine (viewer, viewer->interpret, list[x], currentLine); viewer->characters += viewer->listLen[currentLine]; currentLine++; } } } /* * Determine how many characters we can shift to the right * before all the items have been viewer off the screen. */ if (viewer->widestLine > viewer->boxWidth) { viewer->maxLeftChar = (viewer->widestLine - viewer->boxWidth) + 1; } else { viewer->maxLeftChar = 0; } /* Set up the needed vars for the viewer list. */ viewer->inProgress = FALSE; viewer->listSize = viewerSize; if (viewer->listSize <= viewer->viewSize) { viewer->maxTopLine = 0; } else { viewer->maxTopLine = viewer->listSize - 1; } return viewer->listSize; } chtype **getCDKViewerInfo (CDKVIEWER *viewer, int *size) { (*size) = viewer->listSize; return viewer->list; } /* * This function sets the highlight type of the buttons. */ void setCDKViewerHighlight (CDKVIEWER *viewer, chtype buttonHighlight) { viewer->buttonHighlight = buttonHighlight; } chtype getCDKViewerHighlight (CDKVIEWER *viewer) { return viewer->buttonHighlight; } /* * This sets whether or not you want to set the viewer info line. */ void setCDKViewerInfoLine (CDKVIEWER *viewer, boolean showLineInfo) { viewer->showLineInfo = showLineInfo; } boolean getCDKViewerInfoLine (CDKVIEWER *viewer) { return viewer->showLineInfo; } /* * This sets the widgets box attribute. */ void setCDKViewerBox (CDKVIEWER *viewer, boolean Box) { ObjOf (viewer)->box = Box; ObjOf (viewer)->borderSize = Box ? 1 : 0; } boolean getCDKViewerBox (CDKVIEWER *viewer) { return ObjOf (viewer)->box; } /* * This removes all the lines inside the scrolling window. */ void cleanCDKViewer (CDKVIEWER *viewer) { int x; /* Clean up the memory used ... */ for (x = 0; x < viewer->listSize; x++) { freeLine (viewer, x); } /* Reset some variables. */ viewer->listSize = 0; viewer->maxLeftChar = 0; viewer->widestLine = 0; viewer->currentTop = 0; viewer->maxTopLine = 0; /* Redraw the window. */ drawCDKViewer (viewer, ObjOf (viewer)->box); } static void PatternNotFound (CDKVIEWER *viewer, char *pattern) { char *tempInfo[2]; char *temp = (char *)malloc (80 + strlen (pattern)); tempInfo[0] = temp; tempInfo[1] = 0; sprintf (temp, "Pattern '%s' not found.", pattern); popUpLabel (viewer, tempInfo); free (temp); } /* * This function actually controls the viewer... */ int activateCDKViewer (CDKVIEWER *viewer, chtype *actions GCC_UNUSED) { char *fileInfo[10]; char *tempInfo[2], temp[500]; chtype input; boolean functionKey; int x, REFRESH; /* Create the information about the file stats. */ sprintf (temp, " File Statistics "); fileInfo[0] = copyChar (temp); sprintf (temp, " "); fileInfo[1] = copyChar (temp); sprintf (temp, "Character Count: %-4ld ", viewer->characters); fileInfo[2] = copyChar (temp); sprintf (temp, "Line Count : %-4d ", viewer->listSize); fileInfo[3] = copyChar (temp); sprintf (temp, " "); fileInfo[4] = copyChar (temp); sprintf (temp, "Press Any Key To Continue."); fileInfo[5] = copyChar (temp); fileInfo[6] = 0; tempInfo[0] = temp; tempInfo[1] = 0; /* Set the current button. */ viewer->currentButton = 0; /* Draw the viewer list. */ drawCDKViewer (viewer, ObjOf (viewer)->box); /* Do this until KEY_ENTER is hit. */ for (;;) { /* Reset the refresh flag. */ REFRESH = FALSE; input = getchCDKObject (ObjOf (viewer), &functionKey); if (!checkCDKObjectBind (vVIEWER, viewer, input)) { switch (input) { case KEY_TAB: if (viewer->buttonCount > 1) { if (viewer->currentButton == (viewer->buttonCount - 1)) { viewer->currentButton = 0; } else { viewer->currentButton++; } /* Redraw the buttons. */ drawCDKViewerButtons (viewer); } break; case CDK_PREV: if (viewer->buttonCount > 1) { if (viewer->currentButton == 0) { viewer->currentButton = viewer->buttonCount - 1; } else { viewer->currentButton--; } /* Redraw the buttons. */ drawCDKViewerButtons (viewer); } break; case KEY_UP: if (viewer->currentTop > 0) { viewer->currentTop--; REFRESH = TRUE; } else { Beep (); } break; case KEY_DOWN: if (viewer->currentTop < viewer->maxTopLine) { viewer->currentTop++; REFRESH = TRUE; } else { Beep (); } break; case KEY_RIGHT: if (viewer->leftChar < viewer->maxLeftChar) { viewer->leftChar++; REFRESH = TRUE; } else { Beep (); } break; case KEY_LEFT: if (viewer->leftChar > 0) { viewer->leftChar--; REFRESH = TRUE; } else { Beep (); } break; case KEY_PPAGE: if (viewer->currentTop > 0) { if ((viewer->currentTop - (viewer->viewSize-1)) > 0) { viewer->currentTop = (viewer->currentTop - (viewer->viewSize - 1)); } else { viewer->currentTop = 0; } REFRESH = TRUE; } else { Beep (); } break; case KEY_NPAGE: if (viewer->currentTop < viewer->maxTopLine) { if ((viewer->currentTop + viewer->viewSize) < viewer->maxTopLine) { viewer->currentTop = viewer->currentTop + (viewer->viewSize - 1); } else { viewer->currentTop = viewer->maxTopLine; } REFRESH = TRUE; } else { Beep (); } break; case KEY_HOME: viewer->leftChar = 0; REFRESH = TRUE; break; case KEY_END: viewer->leftChar = viewer->maxLeftChar; REFRESH = TRUE; break; case 'g': case '1': case '<': viewer->currentTop = 0; REFRESH = TRUE; break; case 'G': case '>': viewer->currentTop = viewer->maxTopLine; REFRESH = TRUE; break; case 'L': x = (int)((viewer->listSize + viewer->currentTop) / 2); if (x < viewer->maxTopLine) { viewer->currentTop = x; REFRESH = TRUE; } else { Beep (); } break; case 'l': x = (int)(viewer->currentTop / 2); if (x >= 0) { viewer->currentTop = x; REFRESH = TRUE; } else { Beep (); } break; case '?': SearchDirection = UP; getAndStorePattern (ScreenOf (viewer)); if (!searchForWord (viewer, SearchPattern, SearchDirection)) { PatternNotFound (viewer, SearchPattern); } REFRESH = TRUE; break; case '/': SearchDirection = DOWN; getAndStorePattern (ScreenOf (viewer)); if (! searchForWord (viewer, SearchPattern, SearchDirection)) { PatternNotFound (viewer, SearchPattern); } REFRESH = TRUE; break; case 'N': case 'n': if (SearchPattern == 0) { sprintf (temp, "There is no pattern in the buffer."); popUpLabel (viewer, tempInfo); } else if (!searchForWord (viewer, SearchPattern, ((input == 'n') ? SearchDirection : !SearchDirection))) { PatternNotFound (viewer, SearchPattern); } REFRESH = TRUE; break; case ':': viewer->currentTop = jumpToLine (viewer); REFRESH = TRUE; break; case 'i': case 's': case 'S': popUpLabel (viewer, fileInfo); REFRESH = TRUE; break; case KEY_ESC: freeCharList (fileInfo, 6); setExitType (viewer, input); return -1; case KEY_ENTER: freeCharList (fileInfo, 6); setExitType (viewer, input); return viewer->currentButton; case CDK_REFRESH: eraseCDKScreen (ScreenOf (viewer)); refreshCDKScreen (ScreenOf (viewer)); break; default: Beep (); break; } } /* Do we need to redraw the screen??? */ if (REFRESH) { drawCDKViewerInfo (viewer); } } } /* * This searches the document looking for the given word. */ static void getAndStorePattern (CDKSCREEN *screen) { CDKENTRY *getPattern = 0; char *temp = 0; char *list = 0; /* Check the direction. */ if (SearchDirection == UP) { temp = "Search Up : "; } else { temp = "Search Down: "; } /* Pop up the entry field. */ getPattern = newCDKEntry (screen, CENTER, CENTER, 0, temp, COLOR_PAIR (5)|A_BOLD, '.'|COLOR_PAIR (5)|A_BOLD, vMIXED, 10, 0, 256, TRUE, FALSE); /* Is there an old search pattern? */ if (SearchPattern != 0) { setCDKEntry (getPattern, SearchPattern, getPattern->min, getPattern->max, ObjOf (getPattern)->box); } freeChar (SearchPattern); /* Activate this baby. */ list = activateCDKEntry (getPattern, 0); /* Save the list. */ if ((list != 0) || (strlen (list) != 0)) { SearchPattern = copyChar (list); } /* Clean up. */ destroyCDKEntry (getPattern); } /* * This searches for a line containing the word and realigns the value on the * screen. */ static int searchForWord (CDKVIEWER *viewer, char *pattern, int direction) { int x, y, pos, len, plen; int found = 0; /* If the pattern is empty then return. */ if (pattern != 0 && (plen = strlen (pattern)) != 0) { if (direction == DOWN) { /* Start looking from 'here' down. */ for (x = viewer->currentTop + 1; !found && (x < viewer->listSize); x++) { len = chlen (viewer->list[x]); for (y = pos = 0; y < len; y++) { int plainChar = CharOf (viewer->list[x][y]); if (CharOf (pattern[pos]) != plainChar) { y -= pos; pos = 0; } else if (++pos == plen) { viewer->currentTop = (x < viewer->maxTopLine ? x : viewer->maxTopLine); viewer->leftChar = (y < viewer->boxWidth ? 0 : viewer->maxLeftChar); found = 1; break; } } } } else { /* Start looking from 'here' up. */ for (x = viewer->currentTop - 1; !found && (x >= 0); x--) { len = chlen (viewer->list[x]); for (y = pos = 0; y < len; y++) { int plainChar = CharOf (viewer->list[x][y]); if (CharOf (pattern[pos]) != plainChar) { y -= pos; pos = 0; } else if (++pos == plen) { viewer->currentTop = x; viewer->leftChar = (y < viewer->boxWidth ? 0 : viewer->maxLeftChar); found = 1; break; } } } } } return (found); } /* * This allows us to 'jump' to a given line in the file. */ static int jumpToLine (CDKVIEWER *viewer) { int line = 0; CDKSCALE * newline = newCDKScale (ScreenOf (viewer), CENTER, CENTER, "Jump To Line", "Line :", A_BOLD, intlen (viewer->listSize) + 1, viewer->currentTop + 1, 0, viewer->maxTopLine + 1, 1, 10, TRUE, TRUE); line = activateCDKScale (newline, 0); destroyCDKScale (newline); return ((line-1)); } /* * This pops a little message up on the screen. */ static void popUpLabel (CDKVIEWER *viewer, char **mesg) { CDKLABEL *label; boolean functionKey; /* Set up variables. */ label = newCDKLabel (ScreenOf (viewer), CENTER, CENTER, mesg, CDKcountStrings (mesg), TRUE, FALSE); /* Draw the label and wait. */ drawCDKLabel (label, TRUE); getchCDKObject (ObjOf (label), &functionKey); /* Clean up. */ destroyCDKLabel (label); } /* * This moves the viewer field to the given location. */ static void _moveCDKViewer (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag) { CDKVIEWER *viewer = (CDKVIEWER *)object; int currentX = getbegx (viewer->win); int currentY = getbegy (viewer->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 (viewer->win) + xplace; ypos = getbegy (viewer->win) + yplace; } /* Adjust the window if we need to. */ alignxy (WindowOf (viewer), &xpos, &ypos, viewer->boxWidth, viewer->boxHeight); /* Get the difference. */ xdiff = currentX - xpos; ydiff = currentY - ypos; /* Move the window to the new location. */ moveCursesWindow (viewer->win, -xdiff, -ydiff); moveCursesWindow (viewer->shadowWin, -xdiff, -ydiff); /* Touch the windows so they 'move'. */ refreshCDKWindow (WindowOf (viewer)); /* Redraw the window, if they asked for it. */ if (refresh_flag) { drawCDKViewer (viewer, ObjOf (viewer)->box); } } /* * This function draws the viewer widget. */ static void _drawCDKViewer (CDKOBJS *object, boolean Box) { CDKVIEWER *viewer = (CDKVIEWER *)object; /* Do we need to draw in the shadow??? */ if (viewer->shadowWin != 0) { drawShadow (viewer->shadowWin); } /* Box it if it was asked for. */ if (Box) { drawObjBox (viewer->win, ObjOf (viewer)); wrefresh (viewer->win); } /* Draw the info in the viewer. */ drawCDKViewerInfo (viewer); } /* * This redraws the viewer buttons. */ static void drawCDKViewerButtons (CDKVIEWER *viewer) { chtype character; int x; /* No buttons, no drawing. */ if (viewer->buttonCount == 0) { return; } /* Redraw the buttons. */ for (x = 0; x < viewer->buttonCount; x++) { writeChtype (viewer->win, viewer->buttonPos[x], viewer->boxHeight - 2, viewer->button[x], HORIZONTAL, 0, viewer->buttonLen[x]); } /* Highlight the current button. */ for (x=0; x < viewer->buttonLen[viewer->currentButton]; x++) { /* Strip the character of any extra attributes. */ character = CharOf (viewer->button[viewer->currentButton][x]); /* Add the character into the window. */ mvwaddch (viewer->win, viewer->boxHeight - 2, viewer->buttonPos[viewer->currentButton] + x, character | viewer->buttonHighlight); } /* Refresh the window. */ wrefresh (viewer->win); } /* * This sets the background attribute of the widget. */ static void _setBKattrViewer (CDKOBJS *object, chtype attrib) { if (object != 0) { CDKVIEWER *widget = (CDKVIEWER *)object; wbkgd (widget->win, attrib); } } /* * Free any storage associated with the info-list. */ static void destroyInfo (CDKVIEWER *viewer) { CDKfreeChtypes (viewer->list); freeChecked (viewer->listPos); freeChecked (viewer->listLen); viewer->list = 0; viewer->listPos = 0; viewer->listLen = 0; } /* * This function destroys the viewer widget. */ static void _destroyCDKViewer (CDKOBJS *object) { if (object != 0) { CDKVIEWER *viewer = (CDKVIEWER *)object; destroyInfo (viewer); cleanCdkTitle (object); CDKfreeChtypes (viewer->button); freeChecked (viewer->buttonLen); freeChecked (viewer->buttonPos); /* Clean up the windows. */ deleteCursesWindow (viewer->shadowWin); deleteCursesWindow (viewer->win); /* Clean the key bindings. */ cleanCDKObjectBindings (vVIEWER, viewer); /* Unregister this object. */ unregisterCDKObject (vVIEWER, viewer); } } /* * This function erases the viewer widget from the screen. */ static void _eraseCDKViewer (CDKOBJS *object) { if (validCDKObject (object)) { CDKVIEWER *viewer = (CDKVIEWER *)object; eraseCursesWindow (viewer->win); eraseCursesWindow (viewer->shadowWin); } } /* * This draws the viewer info lines. */ static void drawCDKViewerInfo (CDKVIEWER *viewer) { int listAdjust = 0; int lastLine = 0; char temp[256]; int x; /* Clear the window. */ werase (viewer->win); drawCdkTitle (viewer->win, ObjOf (viewer)); /* Draw in the current line at the top. */ if (viewer->showLineInfo == TRUE) { /* Set up the info line and draw it. */ if (viewer->inProgress) { strcpy (temp, "processing..."); } else if (viewer->listSize != 0) { sprintf (temp, "%d/%d %2.0f%%", (viewer->currentTop + 1), viewer->listSize, ((float)(viewer->currentTop + 1) / (float)viewer->listSize) * 100); } else { sprintf (temp, "%d/%d %2.0f%%", 0, 0, 0.0); } /* * The listAdjust variable tells us if we have to shift down one line * because the person asked for the line X of Y line at the top of the * screen. We only want to set this to 1 if they asked for the info line * and there is no title, or if the two items overlap. */ if (TitleLinesOf (viewer) == 0 || TitlePosOf (viewer)[0] < ((int)strlen (temp) + 2)) { listAdjust = 1; } writeChar (viewer->win, 1, (listAdjust ? TitleLinesOf (viewer) : 0) + 1, temp, HORIZONTAL, 0, (int)strlen (temp)); } /* Determine the last line to draw. */ lastLine = ((viewer->listSize <= viewer->viewSize) ? viewer->listSize : viewer->viewSize); lastLine -= listAdjust; /* Redraw the list. */ for (x = 0; x < lastLine; x++) { if (viewer->currentTop + x < viewer->listSize) { int screenPos = viewer->listPos[viewer->currentTop + x] + 1 - viewer->leftChar; writeChtype (viewer->win, ((screenPos >= 0) ? screenPos : 1), x + TitleLinesOf (viewer) + listAdjust + 1, viewer->list[x + viewer->currentTop], HORIZONTAL, ((screenPos >= 0) ? 0 : (viewer->leftChar - viewer->listPos[viewer->currentTop + x])), viewer->listLen[x + viewer->currentTop]); } } /* Box it if we have to. */ if (ObjOf (viewer)->box) { drawObjBox (viewer->win, ObjOf (viewer)); wrefresh (viewer->win); } /* Draw the separation line. */ if (viewer->buttonCount > 0) { chtype boxattr = BXAttrOf (viewer); for (x=1; x <= viewer->boxWidth; x++) { mvwaddch (viewer->win, viewer->boxHeight-3, x, HZCharOf (viewer) | boxattr); } mvwaddch (viewer->win, viewer->boxHeight-3, 0, ACS_LTEE | boxattr); mvwaddch (viewer->win, viewer->boxHeight-3, getmaxx (viewer->win) - 1, ACS_RTEE | boxattr); } /* Draw the buttons. This will call refresh on the viewer win. */ drawCDKViewerButtons (viewer); } /* * The listSize may be negative, to assign no definite limit. */ static int createList (CDKVIEWER *swindow, int listSize) { int status = 0; if (listSize <= 0) { destroyInfo (swindow); } else { chtype **newList = typeCallocN (chtype *, listSize + 1); int *newPos = typeCallocN (int, listSize + 1); int *newLen = typeCallocN (int, listSize + 1); if (newList != 0 && newPos != 0 && newLen != 0) { status = 1; destroyInfo (swindow); swindow->list = newList; swindow->listPos = newPos; swindow->listLen = newLen; } if (!status) { CDKfreeChtypes (newList); freeChecked (newPos); freeChecked (newLen); } } return status; } dummyInject (Viewer) dummyFocus (Viewer) dummyUnfocus (Viewer) dummyRefreshData (Viewer) dummySaveData (Viewer)