Update dialog to 1.2-20130523

Level up WARNS
This commit is contained in:
Baptiste Daroussin 2013-06-17 10:28:55 +00:00
commit 2a3e3873a1
137 changed files with 10171 additions and 8505 deletions

View File

@ -1,9 +1,229 @@
-- $Id: CHANGES,v 1.360 2011/07/07 23:35:10 tom Exp $
-- $Id: CHANGES,v 1.458 2013/05/24 00:23:22 tom Exp $
-- Thomas E. Dickey <dickey@invisible-island.net>
This version of dialog was originally from a Debian snapshot. I've done this
to it:
2013/05/23
+ modify ifdef in arrows.c to work around packages which use the
wide-character ncursesw headers with the ncurses library (report
by Aleksey Cheusov).
+ correct workaround for xterm alternate-screen to work with/without
the fix made in ncurses that makes putp() always write to the
standard output (Debian #708829).
+ improve limit-checks for checklist, in case the dialog is resized
(report by Ilya A Arkhipov).
+ add --last-key option (adapted from patch by Jordi Pujol, Debian
#697607).
2013/03/15
+ update zh_TW.po, add an.po from
http://translationproject.org/latest/dialog/
2012/12/30 - release 1.2
+ improve some older changelog entries to help with HTML'izing content.
+ various fixes/improvments for scrollbar appearance.
+ add mappings for some equivalent options provided by whiptail;
add configure option --disable-whiptail to allow suppressing these.
+ add configure option --disable-Xdialog2 to allow suppressing the
newer features, i.e., for cdialog 1.2
+ add --no-items option, for consistency.
+ add --no-tags option, like Xdialog.
+ add buildlist, rangebox and treeview dialogs, like Xdialog.
+ remove obsolete workaround for ncurses 4.2 scrolling in checklist
and menubox.
+ improve dialog_helpfile() by preventing it from showing extra buttons
(suggested by xDog Walker).
+ correct logic in formbox's scroll_next() function (report by xDog
Walker).
+ fix a case with inputbox widget where preset input text is not shown
until moving the cursor within the text (report by xDog Walker).
+ handle SIGCHLD in dialog_prgbox() to eliminate defunct processes
(report by xDog Walker).
+ improve the way "hotkeys" are assigned to widget buttons by checking
if a given key has already been used in the row of buttons (Debian
#684933).
+ amend fix for --trace parsing from 2012/07/03, which sometimes
skipped a parameter (report by xDog Walker).
+ drop copismall and install files from samples, which were essentially
nonfunctional.
+ correct secondary border colors in samples/slackware.rc and
samples/whiptail.rc
+ update gl.po, add ia.po from
http://translationproject.org/latest/dialog/
+ fix various issues reported by coverity scan.
+ miscellaneous configure script fixes/updates:
+ require autoconf 2.52+patches
+ support --datarootdir option
+ check for clang compiler
+ check for tinfo library when looking for ncurses
+ add 3rd parameter to AC_DEFINE for autoheader
+ remove unused macros from aclocal.m4
+ update config.guess, config.sub
2012/07/06
+ modify samples/setup-tempfile to work with Tru64's shell.
+ modify inputmenu sample scripts to make them more portable:
+ use "id" rather than "$GROUPS", use sed to work with Solaris.
+ use sed to split-up the rename results to work with HPUX.
+ fix regression in msgbox (ArchLinux #30574)
2012/07/03
+ modify prgbox widget to work with --extra-button, etc.
+ add case values to several widgets to allow for mouse-clicks with
"--extra-button" and "--help-button" additions.
+ correct timebox widget's exit code for "--extra-button" when handing
the "enter" key.
+ modify msgbox widget to honor "--extra-button".
+ corrected processing of "--trace" option, which did not update the
index into command-line to point past its value.
+ add a check in dialog program for valid characters used in option,
e.g., to generate an error if a script attempts to add option value
using "=" rather than with whitespace.
+ add new command-line option --default-button and library function
dlg_default_button() to retrieve the value set by the option
to provide a way to set the default button directly rather than
by combining --nook, etc. (patch by Zoltan Kelemen).
+ amend include of unctrl.h to apply only to the case where curses.h
is included, to avoid conflict of ncurses' unctrl.h with a system
implementation (report by Martin Roedlach)
+ add limit-check to dlg_toupper() in non-wide curses mode to work
when non-character values such as arrow-key codes are passed to
it (patch by Zoltan Kelemen).
+ override timeout value, e.g., as set via --timeout command-line
option in pause widget because that interferes with pause's behavior
(report by Jan Spitalnik).
+ modify samples/inputmenu* to allow ":" in renamed text (report by
Andreas Stoewing).
+ modify double-quoting to make it more consistent, i.e., checklist
output is quoted only when needed. This fixes the case where
single-quotes were used whether or not needed, but also modifies
older checklist behavior for double-quoting which always added those
(Debian #663664).
+ correct exit-code used in inputmenu for "rename" button (Debian
#673041, forwarded from Ubuntu #333909, patch by Lebedev Vadim).
+ update el.po and hr.po from
http://translationproject.org/latest/dialog/
+ use checkbashisms to clean up sample scripts.
2012/02/15
+ modify menubox.c to use the same improvement as in checklist.c
+ improve auto width computation for checklist widget by using
dlg_calc_list_width as in the non-auto case (Edho Arief).
+ eliminate some bashisms in the sample scripts (Pedro Giffuni).
+ makefile fixes from FreeBSD ports (Li-Wen Hsu):
+ make --with-package option of configure script work.
+ get LIBTOOL_VERSION from configure script, needed by
${LIBTOOL_VERSION} in LIBTOOL_CREATE (LIB_CREATE in configure and
aclocal.m4)
+ update cs.po and sr.po from
http://translationproject.org/latest/dialog/
+ updated configure script macros, improving CF_XOPEN_SOURCE among
other fixes.
2011/10/20
+ fix --analyze warnings for clang versions 2.8, 2.9.
+ add configure check for lint program.
+ add check in dlg_getc() in case its window is freed as a side effect
of removing callbacks.
+ fix logic in freeing subwindows (report by xDog Walker).
+ fix a regression in logic distinguishing between inputmenu and menu
widgets (report by xDog Walker).
+ minor fixes to library manpage.
2011/10/18
+ modify header-sh.in to work around limit on sed script length on
HPUX.
+ add a special case of parameter parsing for "--trace" to the
initialization done before calling init_dialog(), to allow users to
capture the initial state of the parameter list before any options
are processed and removed. This is only done if "--trace" is the
first option, otherwise it is handled in the common options as before
(report by xDog Walker).
+ modify samples/testdata-8bit, discarding $1 from the parameter list
if it was used, so that the source'ing scripts can consistently use
"$@" to insert parameters before the widget, e.g., as an alternative
to using $DIALOGOPTS (report by xDog Walker).
+ modify treatment of function pointers in menubox.c, make
dlg_renamed_menutext() and dlg_dummy_menutext() visible to library
users (request by xDog Walker).
+ add dlg_count_real_columns(), use to modify centering for "--hline"
text to account for "\Z"s (report by xDog Walker).
+ improve check in dlg_draw_arrows2() for conflict between the window
title and up-arrow marker to take into account that the given window
may not be the top-level window of the widget.
+ change width of page up/down mouse areas in fselect panes to use the
full width of the panes rather than only the portion from the left
margin to the up/down arrow.
+ add/use dlg_draw_box2() and dlg_draw_bottom_box2() to use the
secondary borders.
+ modify rc-file read/write to accept/generate color values that refer
to previously-processed items in the color table. This reduces the
number of distinct colors that must be specified to set up a color
scheme.
+ add color table entries for secondary borders, i.e., the ones that
are normally drawn with the dialog's text-colors (Debian #641168).
+ modify fselect.c to scan the current directory if the input field
happens to be empty (Debian #640905).
+ repeated the discussion of environment variables that can override
the exit-status values in the manpage's return-codes section
(Debian #642105).
+ add an example to the manpage showing how to override the form
widget's keys used for field/button traversal (Debian #642108).
+ modify call to dlg_register_window() in formbox.c so that the editing
bindings are attached to the form sub-window rather than the
top-level dialog window. Also change the name by which the editing
bindings are bound for editbox.c, fselect.c and inputbox.c, so that
the editing and navigation bindings can be different.
+ correct logic in dlg_lookup_key() so that it matches the widget name
before using a binding from .dialogrc, allowing the inner/outer
windows of form and other editing widgets to have different bindings.
+ modify dlg_register_window() to call dlg_dump_window_keys() after
its updates, via the --trace output, to supplement the manpage
description of key bindings (Debian #642108).
+ add DLGK_FORM_PREV and DLGK_FORM_NEXT key-bindings to form.c, to
allow binding a single key to traverse both form-fields and buttons
(Debian #642108).
+ modify dlg_parse_rc() to check for error return from
dlg_parse_bindkey().
+ add function dlg_dump_window_keys(), to help with debugging widgets.
+ add CR, LF, TAB, FF and ESC to table of curses names to help make
key bindings more readable.
+ update table of dialog key-names so that helpfile and trace are
dumped properly.
+ correct dlg_dump_keys(), which was showing only the first item in
the matched binding table.
+ save/restore window current position in dlg_update_mixedgauge().
+ pass return-code from pause_for_ok() from dlg_progressbox() when
pauseopt is set, rather than only DLG_OK.
+ call setlocale() in init_dialog() rather than relying on on-demand
use within inputstr.c, since there are paths in textbox widget which
do not exercise the latter (report by xDog Walker).
+ fix some places where checks for "\Z" were done without also checking
dialog_vars.colors (report by Moray Henderson).
+ correct logic for DIALOGOPTS parsing so that the parse happens only
once unless memory leak checking is enabled (report by xDog Walker).
+ remove an incorrect free() call in dlg_free_gauge() (report by xDog
Walker).
+ modify dlg_trace_win() to log wide-characters (report by xDog Walker).
+ make traces shorter by skipping repeated ERR's, but showing the
number skipped (report by xDog Walker).
+ improve description in manpage to distinguish program box and
progress box from tailboxes (adapted from email by xDog Walker).
+ modify dlg_trace_win() so that it looks for the topmost window in a
dialog. Because subwindows share space with the top window, tracing
the latter shows the whole widget (report by xDog Walker).
+ expand tracing so that each window is traced before soliciting input,
making the ^T feature to print a window on demand partly redundant
(suggested by xDog Walker).
+ cosmetic change in dialog.h to avoid "*/*" strings from comments next
to "*" (report by xDog Walker).
+ ensure result from dlg_align_columns() has trailing null on each
string. Analysis was hindered by libc6's continuance of libc5's
early-1990s misfeature of clearing the result from malloc, noting
that libc6's documentation incorrectly claims that it does not do
this (report by xDog Walker).
2011/07/07
+ modify util.c to work better with old versions of ncurses:
+ suppress use of wchgat() before fix in 20060715 which is needed
@ -87,7 +307,7 @@ to it:
+ CF_XOPEN_SOURCE, workaround for cygwin to get ncurses' configure
script to define _XOPEN_SOURCE_EXTENDED (cygwin's features.h
doesn't do anything, so it needs a crutch).
+ updated config.guess, config.sub
+ update config.guess, config.sub
2011/03/02
+ add --prgbox and --programbox (adapted from patch by David Boyd).
@ -155,7 +375,7 @@ to it:
CF_ADD_LIBDIR for the curses-directory here, from
CF_NCURSES_CPPFLAGS and CF_NCURSES_LDFLAGS, so it will work even
with the default checking, e.g., no --with-ncurses, etc.
+ updated config.guess, config.sub
+ update config.guess, config.sub
2010/04/28
+ several improvements to configure script:
@ -250,7 +470,7 @@ to it:
libutf8 and libiconv.
+ update da.po, ru.po from
http://translationproject.org/latest/dialog/
+ updated config.guess, config.sub
+ update config.guess, config.sub
2008/08/19
+ amend changes to quoting; by default, the checklist widget quotes its
@ -333,7 +553,7 @@ to it:
ESC to be returned, quitting dialog (report by Reiner Huober).
+ add extern "C" declarations to dlg_keys.h so the corresponding
function declarations are exported to C++ as C symbols.
+ updated config.guess, config.sub
+ update config.guess, config.sub
2007/06/04
+ fix a memory leak in editbox.c
@ -395,7 +615,8 @@ to it:
+ use $(INSTALL_SCRIPT) for installing dialog-config (report by
Santiago Vila).
2007/02/27
2007/02/27 - release 1.1
+ mark as "dialog 1.1"
+ add dialog-config script, which provides applications with compile-
and link-information for using the dialog library.
+ move calls to dlg_trim_string() out of loop in dialog.c, so each
@ -436,7 +657,7 @@ to it:
CF_CURSES_LIBS, CF_INCLUDE_DIRS, CF_LARGEFILE, CF_MAKEFLAGS,
CF_PATH_SYNTAX, CF_SUBDIR_PATH, CF_SUBST, CF_WITH_DBMALLOC,
CF_WITH_DMALLOC, CF_WITH_LIBTOOL and CF_XOPEN_SOURCE.
+ updated config.guess, config.sub
+ update config.guess, config.sub
> adapted fixes from SuSE package (Werner Fink):
+ add some limit-checks in dlg_draw_shadow().
+ make shadows resizable, using new dlg_move_window() in msgbox.c
@ -628,8 +849,7 @@ to it:
+ modify tailboxbg by resetting tty modes at the point where it forks a
process to update the screen, rather than waiting until that process
exits. This improves user feedback by making it apparent that dialog
is no longer processing input after that point (Redhat Bugzilla
#142538).
is no longer processing input after that point (Redhat #142538).
+ minor updates to some .po files using Babel Fish, comparing with lynx.
+ update es.po (Santiago Vila).
+ work around bug in NetBSD 1.6 curses which seems to be confused by
@ -815,8 +1035,7 @@ to it:
before dialog is invoked (Debian #244746).
+ correct dlg_match_char() function, which was broken during rewrite
to support wide-characters (Debian #244777).
+ improved ru.po, uses UTF-8 charset (Leonid Kanter, Redhat Bugzilla
#119200).
+ improved ru.po, uses UTF-8 charset (Leonid Kanter, Redhat #119200).
+ correct position of shadow drawn for dialogs, which appeared to work
for most versions of curses (other than NetBSD) but would have been
visible for certain color schemes (discussion with Julian Coleman).
@ -1147,7 +1366,7 @@ to it:
the --stdout option does not work on HPUX but otherwise dialog works.
+ updated el.po (patch by kromJx <kromJx@crosswinds.net>).
2002/05/19
2002/05/19 - release 0.9b
+ add --no-collapse option to allow one to retain tabs and repeated
blanks in a message box (request by Roberto Simoni).
+ use DLG_EXIT_ESC constant rather than -1's in several places. This
@ -1615,15 +1834,15 @@ to it:
Santiago Vila <sanvila@ctv.es>:
1999/10/07
+ add a password dialog box.
+ add a password dialog box (Debian #45964, patch by Joey Hess).
+ implement "--defaultno" option to specify if the default for
the yes/no box is "No".
the yes/no box is "No" (Debian #46076, patch by Joey Hess).
1999/03/10
+ modify input.c to clear the input field to the right of the
given string (unclear: this seems redundant, since the
dialog is drawn in a new window).
given string, to help with screen-refresh
1998/12/08
+ check for list_height less than one in checklist.c
+ check for list_height less than one in checklist.c (Debian
#22239).
1998/10/21
+ use function wscrl() in preference to scroll() in checklist.c
and menubox.c (unclear: in ncurses, scroll() is a macro that
@ -1633,12 +1852,14 @@ to it:
that directory.
1998/09/12
+ simplify menubox.c using new functions print_arrows() and
print_items().
+ add logic to handle KEY_NPAGE and KEY_PPAGE.
+ change sample scripts to use Debian tempfile utility rather
than putting files into /tmp.
+ change sample scripts to use 'dialog' from user's path rather
than in the parent directory as in the build directory.
print_items(). add logic to handle KEY_NPAGE and KEY_PPAGE
(Debian #26326).
+ modifications to provide sample scripts (Debian #26211):
+ change sample scripts to use Debian tempfile utility rather
than putting files into /tmp.
+ change sample scripts to use 'dialog' from user's path
rather than in the parent directory as in the build
directory.
+ use the system copy of GPL rather than that in the build
directory as an example for the textbox script.
@ -1664,16 +1885,16 @@ The relevant portions of the Debian change log for the original version
1998/05/24
+ Replaced guage.c by the one in dialog 0.6z, which is known to work.
Fixes Bug #18284: unstable dialog.
Fixes Debian #18284: unstable dialog.
1997/12/16
+ dialog.c: dialog_input_result printed with "%s" format. This was
Bug #9913, fixed by Bill Mitchell, but the change was lost.
Debian #9913, fixed by Bill Mitchell, but the change was lost.
+ Pristine source, .depend is not removed in clean target. Instead, it
is made zero lenght (otherwise it would not work *without* fakeroot).
+ Added '^U' support in input box (Bug #9915, patch by joey@debian.org).
+ Wrote patch to fix core-dumping problem (Bug #13170). Sven Rudolph
is made zero length (otherwise it would not work *without* fakeroot).
+ Added '^U' support in input box (Debian #9915, patch by Joey Hess).
+ Wrote patch to fix core-dumping problem (Debian #13170). Sven Rudolph
<sr1@inf.tu-dresden.de>:
-- vile:fk=8bit

View File

@ -1 +1 @@
10:0:0 1.1 20110707
11:1:0 1.2 20130523

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
/*
* $Id: argv.c,v 1.1 2011/03/02 09:56:39 tom Exp $
* $Id: argv.c,v 1.2 2012/11/30 20:28:23 tom Exp $
*
* argv - Reusable functions for argv-parsing.
*
* Copyright 2011 Thomas E. Dickey
* Copyright 2011,2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -56,12 +56,6 @@ dlg_string_to_argv(char *blob)
}
} else if (blob[n] == '\\') {
if (quoted && !isspace(UCH(blob[n + 1]))) {
if (!inparm) {
if (pass)
result[count] = param;
++count;
inparm = TRUE;
}
if (pass) {
*param++ = blob[n];
*param++ = blob[n + 1];

View File

@ -1,9 +1,9 @@
/*
* $Id: arrows.c,v 1.36 2011/06/27 09:13:56 tom Exp $
* $Id: arrows.c,v 1.50 2013/05/24 00:05:21 tom Exp $
*
* arrows.c -- draw arrows to indicate end-of-range for lists
*
* Copyright 2000-2010,2011 Thomas E. Dickey
* Copyright 2000-2012,2013 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -79,9 +79,9 @@ dlg_draw_helpline(WINDOW *win, bool decorations)
const int *cols = dlg_index_columns(dialog_vars.help_line);
int other = decorations ? (ON_LEFT + ON_RIGHT) : 0;
int avail = (getmaxx(win) - other - 2);
int limit = dlg_limit_columns(dialog_vars.help_line, avail, 0);
int limit = dlg_count_real_columns(dialog_vars.help_line) + 2;
if (limit > 0) {
if (limit < avail) {
getyx(win, cur_y, cur_x);
other = decorations ? ON_LEFT : 0;
(void) wmove(win, bottom, other + (avail - limit) / 2);
@ -107,13 +107,14 @@ dlg_draw_arrows2(WINDOW *win,
int cur_x, cur_y;
int limit_x = getmaxx(win);
bool draw_top = TRUE;
bool is_toplevel = (wgetparent(win) == stdscr);
getyx(win, cur_y, cur_x);
/*
* If we're drawing a centered title, do not overwrite with the arrows.
*/
if (dialog_vars.title) {
if (dialog_vars.title && is_toplevel && (top - getbegy(win)) < MARGIN) {
int have = (limit_x - dlg_count_columns(dialog_vars.title)) / 2;
int need = x + 5;
if (need > have)
@ -123,11 +124,11 @@ dlg_draw_arrows2(WINDOW *win,
if (draw_top) {
(void) wmove(win, top, x);
if (top_arrow) {
wattrset(win, merge_colors(uarrow_attr, attr));
(void) wattrset(win, merge_colors(uarrow_attr, attr));
(void) add_acs(win, ACS_UARROW);
(void) waddstr(win, "(-)");
} else {
wattrset(win, attr);
(void) wattrset(win, attr);
(void) whline(win, dlg_boxchar(ACS_HLINE), ON_LEFT);
}
}
@ -135,11 +136,11 @@ dlg_draw_arrows2(WINDOW *win,
(void) wmove(win, bottom, x);
if (bottom_arrow) {
wattrset(win, merge_colors(darrow_attr, attr));
(void) wattrset(win, merge_colors(darrow_attr, borderattr));
(void) add_acs(win, ACS_DARROW);
(void) waddstr(win, "(+)");
} else {
wattrset(win, borderattr);
(void) wattrset(win, borderattr);
(void) whline(win, dlg_boxchar(ACS_HLINE), ON_LEFT);
}
mouse_mkbutton(bottom, x - 1, 6, KEY_NPAGE);
@ -147,7 +148,7 @@ dlg_draw_arrows2(WINDOW *win,
(void) wmove(win, cur_y, cur_x);
wrefresh(win);
wattrset(win, save);
(void) wattrset(win, save);
}
void
@ -166,14 +167,13 @@ dlg_draw_scrollbar(WINDOW *win,
char buffer[80];
int percent;
int len;
int oldy, oldx, maxy, maxx;
int oldy, oldx;
chtype save = dlg_get_attrs(win);
int top_arrow = (first_data != 0);
int bottom_arrow = (next_data < total_data);
getyx(win, oldy, oldx);
getmaxyx(win, maxy, maxx);
dlg_draw_helpline(win, TRUE);
if (bottom_arrow || top_arrow || dialog_state.use_scrollbar) {
@ -187,43 +187,57 @@ dlg_draw_scrollbar(WINDOW *win,
else if (percent > 100)
percent = 100;
wattrset(win, position_indicator_attr);
(void) wattrset(win, position_indicator_attr);
(void) sprintf(buffer, "%d%%", percent);
(void) wmove(win, bottom, right - 7);
(void) waddstr(win, buffer);
if ((len = dlg_count_columns(buffer)) < 4) {
wattrset(win, border_attr);
(void) wattrset(win, border_attr);
whline(win, dlg_boxchar(ACS_HLINE), 4 - len);
}
}
#define BARSIZE(num) (int) (((all_high * (num)) + all_high - 1) / total_data)
#define BARSIZE(num) (int) (0.5 + (double) ((all_high * (int) (num)) / (double) total_data))
#define ORDSIZE(num) (int) ((double) ((all_high * (int) (num)) / (double) all_diff))
if (dialog_state.use_scrollbar) {
int all_high = (bottom - top - 1);
this_data = MAX(0, this_data);
if (total_data > 0 && all_high > 0) {
int all_diff = (int) (total_data + 1);
int bar_diff = (int) (next_data + 1 - this_data);
int bar_high;
int bar_y;
bar_high = BARSIZE(next_data - this_data);
bar_high = ORDSIZE(bar_diff);
if (bar_high <= 0)
bar_high = 1;
if (bar_high < all_high) {
int bar_last = BARSIZE(next_data);
wmove(win, top + 1, right);
wattrset(win, save);
(void) wattrset(win, save);
wvline(win, ACS_VLINE | A_REVERSE, all_high);
bar_y = BARSIZE(this_data);
if (bar_y > all_high - bar_high)
bar_y = all_high - bar_high;
bar_y = ORDSIZE(this_data);
if (bar_y >= bar_last && bar_y > 0)
bar_y = bar_last - 1;
if (bar_last - bar_y > bar_high && bar_high > 1)
++bar_y;
bar_last = MIN(bar_last, all_high);
wmove(win, top + 1 + bar_y, right);
wattrset(win, position_indicator_attr);
(void) wattrset(win, position_indicator_attr);
wattron(win, A_REVERSE);
wvline(win, ACS_BLOCK, bar_high);
#if defined(WACS_BLOCK) && defined(NCURSES_VERSION) && defined(USE_WIDE_CURSES)
wvline_set(win, WACS_BLOCK, bar_last - bar_y);
#else
wvline(win, ACS_BLOCK, bar_last - bar_y);
#endif
}
}
}
@ -236,7 +250,7 @@ dlg_draw_scrollbar(WINDOW *win,
attr,
borderattr);
wattrset(win, save);
(void) wattrset(win, save);
wmove(win, oldy, oldx);
}
@ -255,6 +269,6 @@ dlg_draw_arrows(WINDOW *win,
x,
top,
bottom,
menubox_attr,
menubox_border2_attr,
menubox_border_attr);
}

1111
contrib/dialog/buildlist.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
/*
* $Id: buttons.c,v 1.86 2011/06/28 10:46:46 tom Exp $
* $Id: buttons.c,v 1.94 2012/12/30 20:51:01 tom Exp $
*
* buttons.c -- draw buttons, e.g., OK/Cancel
*
* Copyright 2000-2010,2011 Thomas E. Dickey
* Copyright 2000-2011,2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -28,7 +28,7 @@
#include <wchar.h>
#endif
#define MIN_BUTTON (dialog_state.visit_items ? -1 : 0)
#define MIN_BUTTON (-dialog_state.visit_cols)
static void
center_label(char *buffer, int longest, const char *label)
@ -86,11 +86,85 @@ string_to_char(const char **stringp)
return result;
}
static size_t
count_labels(const char **labels)
{
size_t result = 0;
if (labels != 0) {
while (*labels++ != 0) {
++result;
}
}
return result;
}
/*
* Check if the latest key should be added to the hotkey list.
*/
static int
was_hotkey(int this_key, int *used_keys, size_t next)
{
int result = FALSE;
if (next != 0) {
size_t n;
for (n = 0; n < next; ++n) {
if (used_keys[n] == this_key) {
result = TRUE;
break;
}
}
}
return result;
}
/*
* Determine the hot-keys for a set of button-labels. Normally these are
* the first uppercase character in each label. However, if more than one
* button has the same first-uppercase, then we will (attempt to) look for
* an alternate.
*
* This allocates data which must be freed by the caller.
*/
static int *
get_hotkeys(const char **labels)
{
int *result = 0;
size_t count = count_labels(labels);
size_t n;
if ((result = dlg_calloc(int, count + 1)) != 0) {
for (n = 0; n < count; ++n) {
const char *label = labels[n];
const int *indx = dlg_index_wchars(label);
int limit = dlg_count_wchars(label);
int i;
for (i = 0; i < limit; ++i) {
int first = indx[i];
int check = UCH(label[first]);
#ifdef USE_WIDE_CURSES
int last = indx[i + 1];
if ((last - first) != 1) {
const char *temp = (label + first);
check = string_to_char(&temp);
}
#endif
if (dlg_isupper(check) && !was_hotkey(check, result, n)) {
result[n] = check;
break;
}
}
}
}
return result;
}
/*
* Print a button
*/
static void
print_button(WINDOW *win, char *label, int y, int x, int selected)
print_button(WINDOW *win, char *label, int hotkey, int y, int x, int selected)
{
int i;
int state = 0;
@ -104,30 +178,27 @@ print_button(WINDOW *win, char *label, int y, int x, int selected)
: button_label_inactive_attr);
(void) wmove(win, y, x);
wattrset(win, selected
? button_active_attr
: button_inactive_attr);
(void) wattrset(win, selected
? button_active_attr
: button_inactive_attr);
(void) waddstr(win, "<");
wattrset(win, label_attr);
(void) wattrset(win, label_attr);
for (i = 0; i < limit; ++i) {
int check;
int first = indx[i];
int last = indx[i + 1];
switch (state) {
case 0:
check = UCH(label[first]);
#ifdef USE_WIDE_CURSES
if ((last - first) != 1) {
const char *temp = (label + first);
int cmp = string_to_char(&temp);
if (dlg_isupper(cmp)) {
wattrset(win, key_attr);
state = 1;
}
break;
check = string_to_char(&temp);
}
#endif
if (dlg_isupper(UCH(label[first]))) {
wattrset(win, key_attr);
if (check == hotkey) {
(void) wattrset(win, key_attr);
state = 1;
}
break;
@ -138,9 +209,9 @@ print_button(WINDOW *win, char *label, int y, int x, int selected)
}
waddnstr(win, label + first, last - first);
}
wattrset(win, selected
? button_active_attr
: button_inactive_attr);
(void) wattrset(win, selected
? button_active_attr
: button_inactive_attr);
(void) waddstr(win, ">");
(void) wmove(win, y, x + ((int) strspn(label, " ")) + 1);
}
@ -203,22 +274,27 @@ dlg_button_x_step(const char **labels, int limit, int *gap, int *margin, int *st
int length;
int unused;
int used;
int result;
if (count == 0)
return 0;
dlg_button_sizes(labels, FALSE, &longest, &length);
used = (length + (count * 2));
unused = limit - used;
*margin = 0;
if (count != 0) {
dlg_button_sizes(labels, FALSE, &longest, &length);
used = (length + (count * 2));
unused = limit - used;
if ((*gap = unused / (count + 3)) <= 0) {
if ((*gap = unused / (count + 1)) <= 0)
*gap = 1;
*margin = *gap;
if ((*gap = unused / (count + 3)) <= 0) {
if ((*gap = unused / (count + 1)) <= 0)
*gap = 1;
*margin = *gap;
} else {
*margin = *gap * 2;
}
*step = *gap + (used + count - 1) / count;
result = (*gap > 0) && (unused >= 0);
} else {
*margin = *gap * 2;
result = 0;
}
*step = *gap + (used + count - 1) / count;
return (*gap > 0) && (unused >= 0);
return result;
}
/*
@ -282,35 +358,41 @@ dlg_draw_buttons(WINDOW *win,
* Allocate a buffer big enough for any label.
*/
need = (size_t) longest;
for (n = 0; labels[n] != 0; ++n) {
need += strlen(labels[n]) + 1;
}
buffer = dlg_malloc(char, need);
assert_ptr(buffer, "dlg_draw_buttons");
if (need != 0) {
int *hotkeys = get_hotkeys(labels);
assert_ptr(hotkeys, "dlg_draw_buttons");
/*
* Draw the labels.
*/
for (n = 0; labels[n] != 0; n++) {
center_label(buffer, longest, labels[n]);
mouse_mkbutton(y, x, dlg_count_columns(buffer), n);
print_button(win, buffer, y, x,
(selected == n) || (n == 0 && selected < 0));
if (selected == n)
getyx(win, final_y, final_x);
if (vertical) {
if ((y += step) > limit)
break;
} else {
if ((x += step) > limit)
break;
for (n = 0; labels[n] != 0; ++n) {
need += strlen(labels[n]) + 1;
}
buffer = dlg_malloc(char, need);
assert_ptr(buffer, "dlg_draw_buttons");
/*
* Draw the labels.
*/
for (n = 0; labels[n] != 0; n++) {
center_label(buffer, longest, labels[n]);
mouse_mkbutton(y, x, dlg_count_columns(buffer), n);
print_button(win, buffer, hotkeys[n], y, x,
(selected == n) || (n == 0 && selected < 0));
if (selected == n)
getyx(win, final_y, final_x);
if (vertical) {
if ((y += step) > limit)
break;
} else {
if ((x += step) > limit)
break;
}
}
(void) wmove(win, final_y, final_x);
wrefresh(win);
(void) wattrset(win, save);
free(buffer);
free(hotkeys);
}
(void) wmove(win, final_y, final_x);
wrefresh(win);
free(buffer);
wattrset(win, save);
}
/*
@ -364,19 +446,27 @@ dlg_button_to_char(const char *label)
int
dlg_char_to_button(int ch, const char **labels)
{
int result = DLG_EXIT_UNKNOWN;
if (labels != 0) {
int *hotkeys = get_hotkeys(labels);
int j;
ch = (int) dlg_toupper(dlg_last_getc());
for (j = 0; labels[j] != 0; ++j) {
int cmp = dlg_button_to_char(labels[j]);
if (ch == cmp) {
dlg_flush_getc();
return j;
if (hotkeys != 0) {
for (j = 0; labels[j] != 0; ++j) {
if (ch == hotkeys[j]) {
dlg_flush_getc();
result = j;
break;
}
}
free(hotkeys);
}
}
return DLG_EXIT_UNKNOWN;
return result;
}
static const char *
@ -488,10 +578,12 @@ dlg_exit_buttoncode(int button)
const char **
dlg_ok_label(void)
{
static const char *labels[3];
static const char *labels[4];
int n = 0;
labels[n++] = my_ok_label();
if (dialog_vars.extra_button)
labels[n++] = my_extra_label();
if (dialog_vars.help_button)
labels[n++] = my_help_label();
labels[n] = 0;
@ -537,6 +629,7 @@ dlg_ok_buttoncode(int button)
} else if (dialog_vars.help_button && (button == n)) {
result = DLG_EXIT_HELP;
}
dlg_trace_msg("# dlg_ok_buttoncode(%d) = %d\n", button, result);
return result;
}
@ -575,7 +668,7 @@ dlg_prev_ok_buttonindex(int current, int extra)
/*
* Find the button-index for the "OK" or "Cancel" button, according to
* whether --defaultno is given. If --nocancel was given, we always return
* the index for "OK".
* the index for the first button (usually "OK" unless --nook was used).
*/
int
dlg_defaultno_button(void)
@ -586,6 +679,30 @@ dlg_defaultno_button(void)
while (dlg_ok_buttoncode(result) != DLG_EXIT_CANCEL)
++result;
}
dlg_trace_msg("# dlg_defaultno_button() = %d\n", result);
return result;
}
/*
* Find the button-index for a button named with --default-button. If the
* option was not specified, or if the selected button does not exist, return
* the index of the first button (usually "OK" unless --nook was used).
*/
int
dlg_default_button(void)
{
int i, n;
int result = 0;
if (dialog_vars.default_button >= 0) {
for (i = 0; (n = dlg_ok_buttoncode(i)) >= 0; i++) {
if (n == dialog_vars.default_button) {
result = i;
break;
}
}
}
dlg_trace_msg("# dlg_default_button() = %d\n", result);
return result;
}
@ -642,10 +759,14 @@ dlg_yes_buttoncode(int button)
int
dlg_next_button(const char **labels, int button)
{
if (labels[button + 1] != 0)
if (button < -1)
button = -1;
if (labels[button + 1] != 0) {
++button;
else
} else {
button = MIN_BUTTON;
}
return button;
}
@ -655,9 +776,12 @@ dlg_next_button(const char **labels, int button)
int
dlg_prev_button(const char **labels, int button)
{
if (button > MIN_BUTTON)
if (button > MIN_BUTTON) {
--button;
else {
} else {
if (button < -1)
button = -1;
while (labels[button + 1] != 0)
++button;
}

View File

@ -1,9 +1,9 @@
/*
* $Id: calendar.c,v 1.62 2011/06/29 09:47:06 tom Exp $
* $Id: calendar.c,v 1.67 2013/03/17 15:03:41 tom Exp $
*
* calendar.c -- implements the calendar box
*
* Copyright 2001-2010,2011 Thomas E. Dickey
* Copyright 2001-2012,2013 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -225,12 +225,14 @@ draw_day(BOX * data, struct tm *current)
int prev = days_in_month(current, -1);
werase(data->window);
dlg_draw_box(data->parent,
data->y - MARGIN, data->x - MARGIN,
data->height + (2 * MARGIN), data->width + (2 * MARGIN),
menubox_border_attr, menubox_attr); /* border of daybox */
dlg_draw_box2(data->parent,
data->y - MARGIN, data->x - MARGIN,
data->height + (2 * MARGIN), data->width + (2 * MARGIN),
menubox_attr,
menubox_border_attr,
menubox_border2_attr);
wattrset(data->window, menubox_attr); /* daynames headline */
(void) wattrset(data->window, menubox_attr); /* daynames headline */
for (x = 0; x < 7; x++) {
mvwprintw(data->window,
0, (x + 1) * cell_wide, "%*.*s ",
@ -246,7 +248,7 @@ draw_day(BOX * data, struct tm *current)
week = (current->tm_yday + 6 + mday - current->tm_mday) / 7;
for (y = 1; mday < last; y++) {
wattrset(data->window, menubox_attr); /* weeknumbers headline */
(void) wattrset(data->window, menubox_attr); /* weeknumbers headline */
mvwprintw(data->window,
y, 0,
"%*d ",
@ -257,9 +259,9 @@ draw_day(BOX * data, struct tm *current)
++mday;
if (wmove(data->window, y, this_x) == ERR)
continue;
wattrset(data->window, item_attr); /* not selected days */
(void) wattrset(data->window, item_attr); /* not selected days */
if (mday == day) {
wattrset(data->window, item_selected_attr); /* selected day */
(void) wattrset(data->window, item_selected_attr); /* selected day */
save_y = y;
save_x = this_x;
}
@ -294,13 +296,15 @@ draw_month(BOX * data, struct tm *current)
month = current->tm_mon + 1;
wattrset(data->parent, dialog_attr); /* Headline "Month" */
(void) wattrset(data->parent, dialog_attr); /* Headline "Month" */
(void) mvwprintw(data->parent, data->y - 2, data->x - 1, _("Month"));
dlg_draw_box(data->parent,
data->y - 1, data->x - 1,
data->height + 2, data->width + 2,
menubox_border_attr, menubox_attr); /* borders of monthbox */
wattrset(data->window, item_attr); /* color the month selection */
dlg_draw_box2(data->parent,
data->y - 1, data->x - 1,
data->height + 2, data->width + 2,
menubox_attr,
menubox_border_attr,
menubox_border2_attr);
(void) wattrset(data->window, item_attr); /* color the month selection */
mvwprintw(data->window, 0, 0, "%s", nameOfMonth(month - 1));
wmove(data->window, 0, 0);
return 0;
@ -314,13 +318,15 @@ draw_year(BOX * data, struct tm *current)
{
int year = current->tm_year + 1900;
wattrset(data->parent, dialog_attr); /* Headline "Year" */
(void) wattrset(data->parent, dialog_attr); /* Headline "Year" */
(void) mvwprintw(data->parent, data->y - 2, data->x - 1, _("Year"));
dlg_draw_box(data->parent,
data->y - 1, data->x - 1,
data->height + 2, data->width + 2,
menubox_border_attr, menubox_attr); /* borders of yearbox */
wattrset(data->window, item_attr); /* color the year selection */
dlg_draw_box2(data->parent,
data->y - 1, data->x - 1,
data->height + 2, data->width + 2,
menubox_attr,
menubox_border_attr,
menubox_border2_attr);
(void) wattrset(data->window, item_attr); /* color the year selection */
mvwprintw(data->window, 0, 0, "%4d", year);
wmove(data->window, 0, 0);
return 0;
@ -430,7 +436,7 @@ dialog_calendar(const char *title,
WINDOW *dialog;
time_t now_time = time((time_t *) 0);
struct tm current;
int state = dlg_defaultno_button();
int state = dlg_default_button();
const char **buttons = dlg_ok_labels();
char *prompt = dlg_strclone(subtitle);
int mincols = MIN_WIDE;
@ -491,11 +497,11 @@ dialog_calendar(const char *title,
dlg_register_buttons(dialog, "calendar", buttons);
/* mainbox */
dlg_draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
dlg_draw_bottom_box(dialog);
dlg_draw_box2(dialog, 0, 0, height, width, dialog_attr, border_attr, border2_attr);
dlg_draw_bottom_box2(dialog, border_attr, border2_attr, dialog_attr);
dlg_draw_title(dialog, title);
wattrset(dialog, dialog_attr); /* text mainbox */
(void) wattrset(dialog, dialog_attr); /* text mainbox */
dlg_print_autowrap(dialog, prompt, height, width);
/* compute positions of day, month and year boxes */
@ -539,6 +545,7 @@ dialog_calendar(const char *title,
return CleanupResult(DLG_EXIT_ERROR, dialog, prompt, &save_vars);
}
dlg_trace_win(dialog);
while (result == DLG_EXIT_UNKNOWN) {
BOX *obj = (state == sDAY ? &dy_box
: (state == sMONTH ? &mn_box :
@ -674,6 +681,7 @@ dialog_calendar(const char *title,
dlg_add_result(buffer);
dlg_add_separator();
dlg_add_last_key(-1);
return CleanupResult(result, dialog, prompt, &save_vars);
}

View File

@ -1,9 +1,9 @@
/*
* $Id: checklist.c,v 1.127 2011/06/29 23:04:09 tom Exp $
* $Id: checklist.c,v 1.151 2013/03/23 10:51:48 tom Exp $
*
* checklist.c -- implements the checklist box
*
* Copyright 2000-2010,2011 Thomas E. Dickey
* Copyright 2000-2012,2013 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -29,45 +29,32 @@
#include <dialog.h>
#include <dlg_keys.h>
static int list_width, check_x, item_x, checkflag;
#define MIN_HIGH (1 + (5 * MARGIN))
#define LLEN(n) ((n) * CHECKBOX_TAGS)
#define ItemData(i) &items[LLEN(i)]
#define ItemName(i) items[LLEN(i)]
#define ItemText(i) items[LLEN(i) + 1]
#define ItemStatus(i) items[LLEN(i) + 2]
#define ItemHelp(i) items[LLEN(i) + 3]
static void
print_arrows(WINDOW *win,
int box_x,
int box_y,
int scrollamt,
int choice,
int item_no,
int list_height)
{
dlg_draw_scrollbar(win,
(long) (scrollamt),
(long) (scrollamt),
(long) (scrollamt + choice),
(long) (item_no),
box_x + check_x,
box_x + list_width,
box_y,
box_y + list_height + 1,
menubox_attr,
menubox_border_attr);
}
typedef struct {
/* the outer-window */
WINDOW *dialog;
int box_y;
int box_x;
int check_x;
int item_x;
int checkflag;
int use_height;
int use_width;
/* the inner-window */
WINDOW *list;
DIALOG_LISTITEM *items;
int item_no;
const char *states;
} ALL_DATA;
/*
* Print list item. The 'selected' parameter is true if 'choice' is the
* current item. That one is colored differently from the other items.
*/
static void
print_item(WINDOW *win,
print_item(ALL_DATA * data,
WINDOW *win,
DIALOG_LISTITEM * item,
const char *states,
int choice,
@ -75,58 +62,84 @@ print_item(WINDOW *win,
{
chtype save = dlg_get_attrs(win);
int i;
chtype attr = A_NORMAL;
const int *cols;
const int *indx;
int limit;
bool both = (!dialog_vars.no_tags && !dialog_vars.no_items);
bool first = TRUE;
int climit = (getmaxx(win) - data->check_x + 1);
const char *show = (dialog_vars.no_items
? item->name
: item->text);
/* Clear 'residue' of last item */
wattrset(win, menubox_attr);
(void) wattrset(win, menubox_attr);
(void) wmove(win, choice, 0);
for (i = 0; i < list_width; i++)
for (i = 0; i < data->use_width; i++)
(void) waddch(win, ' ');
(void) wmove(win, choice, check_x);
wattrset(win, selected ? check_selected_attr : check_attr);
(void) wmove(win, choice, data->check_x);
(void) wattrset(win, selected ? check_selected_attr : check_attr);
(void) wprintw(win,
(checkflag == FLAG_CHECK) ? "[%c]" : "(%c)",
(data->checkflag == FLAG_CHECK) ? "[%c]" : "(%c)",
states[item->state]);
wattrset(win, menubox_attr);
(void) wattrset(win, menubox_attr);
(void) waddch(win, ' ');
if (strlen(item->name) != 0) {
indx = dlg_index_wchars(item->name);
wattrset(win, selected ? tag_key_selected_attr : tag_key_attr);
(void) waddnstr(win, item->name, indx[1]);
if ((int) strlen(item->name) > indx[1]) {
limit = dlg_limit_columns(item->name, (item_x - check_x - 6), 1);
if (limit > 1) {
wattrset(win, selected ? tag_selected_attr : tag_attr);
(void) waddnstr(win,
item->name + indx[1],
indx[limit] - indx[1]);
}
}
if (both) {
dlg_print_listitem(win, item->name, climit, first, selected);
first = FALSE;
}
if (strlen(item->text) != 0) {
cols = dlg_index_columns(item->text);
limit = dlg_limit_columns(item->text, (getmaxx(win) - item_x + 1), 0);
if (limit > 0) {
(void) wmove(win, choice, item_x);
wattrset(win, selected ? item_selected_attr : item_attr);
dlg_print_text(win, item->text, cols[limit], &attr);
}
}
(void) wmove(win, choice, data->item_x);
dlg_print_listitem(win, show, climit, first, selected);
if (selected) {
dlg_item_help(item->help);
}
wattrset(win, save);
(void) wattrset(win, save);
}
static void
print_list(ALL_DATA * data, int choice, int scrollamt, int max_choice)
{
int i;
int cur_y, cur_x;
getyx(data->dialog, cur_y, cur_x);
for (i = 0; i < max_choice; i++) {
print_item(data,
data->list,
&data->items[i + scrollamt],
data->states,
i, i == choice);
}
(void) wnoutrefresh(data->list);
dlg_draw_scrollbar(data->dialog,
(long) (scrollamt),
(long) (scrollamt),
(long) (scrollamt + max_choice),
(long) (data->item_no),
data->box_x + data->check_x,
data->box_x + data->use_width,
data->box_y,
data->box_y + data->use_height + 1,
menubox_border2_attr,
menubox_border_attr);
(void) wmove(data->dialog, cur_y, cur_x);
}
static bool
check_hotkey(DIALOG_LISTITEM * items, int choice)
{
bool result = FALSE;
if (dlg_match_char(dlg_last_getc(),
(dialog_vars.no_tags
? items[choice].text
: items[choice].name))) {
result = TRUE;
}
return result;
}
/*
@ -176,20 +189,25 @@ dlg_checklist(const char *title,
int old_height = height;
int old_width = width;
#endif
int i, j, key2, found, x, y, cur_x, cur_y, box_x, box_y;
ALL_DATA all;
int i, j, key2, found, x, y, cur_x, cur_y;
int key = 0, fkey;
int button = dialog_state.visit_items ? -1 : dlg_defaultno_button();
int button = dialog_state.visit_items ? -1 : dlg_default_button();
int choice = dlg_default_listitem(items);
int scrollamt = 0;
int max_choice;
int was_mouse;
int use_height;
int use_width, name_width, text_width;
int use_width, list_width, name_width, text_width;
int result = DLG_EXIT_UNKNOWN;
int num_states;
WINDOW *dialog, *list;
WINDOW *dialog;
char *prompt = dlg_strclone(cprompt);
const char **buttons = dlg_ok_labels();
const char *widget_name;
memset(&all, 0, sizeof(all));
all.items = items;
all.item_no = item_no;
dlg_does_output();
dlg_tab_correct_str(prompt);
@ -211,19 +229,25 @@ dlg_checklist(const char *title,
}
}
}
widget_name = "radiolist";
} else {
widget_name = "checklist";
}
#ifdef KEY_RESIZE
retry:
#endif
use_height = list_height;
if (use_height == 0) {
use_width = dlg_calc_list_width(item_no, items) + 10;
all.use_height = list_height;
use_width = dlg_calc_list_width(item_no, items) + 10;
use_width = MAX(26, use_width);
if (all.use_height == 0) {
/* calculate height without items (4) */
dlg_auto_size(title, prompt, &height, &width, MIN_HIGH, MAX(26, use_width));
dlg_calc_listh(&height, &use_height, item_no);
dlg_auto_size(title, prompt, &height, &width, MIN_HIGH, use_width);
dlg_calc_listh(&height, &all.use_height, item_no);
} else {
dlg_auto_size(title, prompt, &height, &width, MIN_HIGH + use_height, 26);
dlg_auto_size(title, prompt,
&height, &width,
MIN_HIGH + all.use_height, use_width);
}
dlg_button_layout(buttons, &width);
dlg_print_size(height, width);
@ -233,50 +257,53 @@ dlg_checklist(const char *title,
if (states == 0 || strlen(states) < 2)
states = " *";
num_states = (int) strlen(states);
all.states = states;
checkflag = flag;
all.checkflag = flag;
x = dlg_box_x_ordinate(width);
y = dlg_box_y_ordinate(height);
dialog = dlg_new_window(height, width, y, x);
dlg_register_window(dialog, "checklist", binding);
dlg_register_buttons(dialog, "checklist", buttons);
all.dialog = dialog;
dlg_register_window(dialog, widget_name, binding);
dlg_register_buttons(dialog, widget_name, buttons);
dlg_mouse_setbase(x, y);
dlg_draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
dlg_draw_bottom_box(dialog);
dlg_draw_box2(dialog, 0, 0, height, width, dialog_attr, border_attr, border2_attr);
dlg_draw_bottom_box2(dialog, border_attr, border2_attr, dialog_attr);
dlg_draw_title(dialog, title);
wattrset(dialog, dialog_attr);
(void) wattrset(dialog, dialog_attr);
dlg_print_autowrap(dialog, prompt, height, width);
list_width = width - 6;
all.use_width = width - 6;
getyx(dialog, cur_y, cur_x);
box_y = cur_y + 1;
box_x = (width - list_width) / 2 - 1;
all.box_y = cur_y + 1;
all.box_x = (width - all.use_width) / 2 - 1;
/*
* After displaying the prompt, we know how much space we really have.
* Limit the list to avoid overwriting the ok-button.
*/
if (use_height + MIN_HIGH > height - cur_y)
use_height = height - MIN_HIGH - cur_y;
if (use_height <= 0)
use_height = 1;
if (all.use_height + MIN_HIGH > height - cur_y)
all.use_height = height - MIN_HIGH - cur_y;
if (all.use_height <= 0)
all.use_height = 1;
max_choice = MIN(use_height, item_no);
max_choice = MIN(all.use_height, item_no);
max_choice = MAX(max_choice, 1);
/* create new window for the list */
list = dlg_sub_window(dialog, use_height, list_width,
y + box_y + 1, x + box_x + 1);
all.list = dlg_sub_window(dialog, all.use_height, all.use_width,
y + all.box_y + 1, x + all.box_x + 1);
/* draw a box around the list items */
dlg_draw_box(dialog, box_y, box_x,
use_height + 2 * MARGIN,
list_width + 2 * MARGIN,
menubox_border_attr, menubox_attr);
dlg_draw_box(dialog, all.box_y, all.box_x,
all.use_height + 2 * MARGIN,
all.use_width + 2 * MARGIN,
menubox_border_attr, menubox_border2_attr);
text_width = 0;
name_width = 0;
@ -290,47 +317,54 @@ dlg_checklist(const char *title,
* one or both of them. If the name is no wider than 1/4 of the list,
* leave it intact.
*/
use_width = (list_width - 6);
if (text_width + name_width > use_width) {
int need = (int) (0.25 * use_width);
if (name_width > need) {
int want = (int) (use_width * ((double) name_width) /
(text_width + name_width));
name_width = (want > need) ? want : need;
use_width = (all.use_width - 6);
if (dialog_vars.no_tags) {
list_width = MIN(all.use_width, text_width);
} else if (dialog_vars.no_items) {
list_width = MIN(all.use_width, name_width);
} else {
if (text_width >= 0
&& name_width >= 0
&& use_width > 0
&& text_width + name_width > use_width) {
int need = (int) (0.25 * use_width);
if (name_width > need) {
int want = (int) (use_width * ((double) name_width) /
(text_width + name_width));
name_width = (want > need) ? want : need;
}
text_width = use_width - name_width;
}
text_width = use_width - name_width;
list_width = (text_width + name_width);
}
check_x = (use_width - (text_width + name_width)) / 2;
item_x = name_width + check_x + 6;
all.check_x = (use_width - list_width) / 2;
all.item_x = ((dialog_vars.no_tags
? 0
: (dialog_vars.no_items
? 0
: (2 + name_width)))
+ all.check_x + 4);
/* ensure we are scrolled to show the current choice */
if (choice >= (max_choice + scrollamt)) {
scrollamt = choice - max_choice + 1;
scrollamt = MIN(scrollamt, max_choice + item_no - 1);
if (choice >= (max_choice + scrollamt - 1)) {
scrollamt = MAX(0, choice - max_choice + 1);
choice = max_choice - 1;
}
/* Print the list */
for (i = 0; i < max_choice; i++) {
print_item(list,
&items[i + scrollamt],
states,
i, i == choice);
}
(void) wnoutrefresh(list);
print_list(&all, choice, scrollamt, max_choice);
/* register the new window, along with its borders */
dlg_mouse_mkbigregion(box_y + 1, box_x, use_height, list_width + 2,
dlg_mouse_mkbigregion(all.box_y + 1, all.box_x,
all.use_height, all.use_width + 2,
KEY_MAX, 1, 1, 1 /* by lines */ );
print_arrows(dialog,
box_x, box_y,
scrollamt, max_choice, item_no, use_height);
dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width);
dlg_trace_win(dialog);
while (result == DLG_EXIT_UNKNOWN) {
if (button < 0) /* --visit-items */
wmove(dialog, box_y + choice + 1, box_x + check_x + 2);
wmove(dialog, all.box_y + choice + 1, all.box_x + all.check_x + 2);
key = dlg_mouse_wgetch(dialog, &fkey);
if (dlg_result_key(key, fkey, &result))
@ -344,19 +378,8 @@ dlg_checklist(const char *title,
getyx(dialog, cur_y, cur_x);
i = (key - KEY_MAX);
if (i < max_choice) {
/* De-highlight current item */
print_item(list,
&items[scrollamt + choice],
states,
choice, FALSE);
/* Highlight new item */
choice = (key - KEY_MAX);
print_item(list,
&items[scrollamt + choice],
states,
choice, TRUE);
(void) wnoutrefresh(list);
(void) wmove(dialog, cur_y, cur_x);
print_list(&all, choice, scrollamt, max_choice);
key = ' '; /* force the selected item to toggle */
} else {
@ -380,13 +403,15 @@ dlg_checklist(const char *title,
if (next >= num_states)
next = 0;
getyx(dialog, cur_y, cur_x);
if (flag == FLAG_CHECK) { /* checklist? */
getyx(dialog, cur_y, cur_x);
items[current].state = next;
print_item(list,
print_item(&all, all.list,
&items[scrollamt + choice],
states,
choice, TRUE);
(void) wnoutrefresh(all.list);
(void) wmove(dialog, cur_y, cur_x);
} else { /* radiolist */
for (i = 0; i < item_no; i++) {
if (i != current) {
@ -394,23 +419,19 @@ dlg_checklist(const char *title,
}
}
if (items[current].state) {
getyx(dialog, cur_y, cur_x);
items[current].state = next ? next : 1;
print_item(list,
print_item(&all, all.list,
&items[current],
states,
choice, TRUE);
(void) wnoutrefresh(all.list);
(void) wmove(dialog, cur_y, cur_x);
} else {
items[current].state = 1;
for (i = 0; i < max_choice; i++)
print_item(list,
&items[scrollamt + i],
states,
i, i == choice);
print_list(&all, choice, scrollamt, max_choice);
}
}
(void) wnoutrefresh(list);
(void) wmove(dialog, cur_y, cur_x);
wrefresh(dialog);
continue; /* wait for another key press */
}
@ -423,7 +444,7 @@ dlg_checklist(const char *title,
if (!fkey) {
if (button < 0 || !dialog_state.visit_items) {
for (j = scrollamt + choice + 1; j < item_no; j++) {
if (dlg_match_char(dlg_last_getc(), items[j].name)) {
if (check_hotkey(items, j)) {
found = TRUE;
i = j - scrollamt;
break;
@ -431,7 +452,7 @@ dlg_checklist(const char *title,
}
if (!found) {
for (j = 0; j <= scrollamt + choice; j++) {
if (dlg_match_char(dlg_last_getc(), items[j].name)) {
if (check_hotkey(items, j)) {
found = TRUE;
i = j - scrollamt;
break;
@ -501,82 +522,17 @@ dlg_checklist(const char *title,
if (i != choice) {
getyx(dialog, cur_y, cur_x);
if (i < 0 || i >= max_choice) {
#if defined(NCURSES_VERSION_MAJOR) && NCURSES_VERSION_MAJOR < 5
/*
* Using wscrl to assist ncurses scrolling is not needed
* in version 5.x
*/
if (i == -1) {
if (use_height > 1) {
/* De-highlight current first item */
print_item(list,
&items[scrollamt],
states,
0, FALSE);
scrollok(list, TRUE);
wscrl(list, -1);
scrollok(list, FALSE);
}
scrollamt--;
print_item(list,
&items[scrollamt],
states,
0, TRUE);
} else if (i == max_choice) {
if (use_height > 1) {
/* De-highlight current last item before scrolling up */
print_item(list,
&items[scrollamt + max_choice - 1],
states,
max_choice - 1, FALSE);
scrollok(list, TRUE);
wscrl(list, 1);
scrollok(list, FALSE);
}
scrollamt++;
print_item(list,
&items[scrollamt + max_choice - 1],
states,
max_choice - 1, TRUE);
} else
#endif
{
if (i < 0) {
scrollamt += i;
choice = 0;
} else {
choice = max_choice - 1;
scrollamt += (i - max_choice + 1);
}
for (i = 0; i < max_choice; i++) {
print_item(list,
&items[scrollamt + i],
states,
i, i == choice);
}
if (i < 0) {
scrollamt += i;
choice = 0;
} else {
choice = max_choice - 1;
scrollamt += (i - max_choice + 1);
}
(void) wnoutrefresh(list);
print_arrows(dialog,
box_x, box_y,
scrollamt, max_choice, item_no, use_height);
print_list(&all, choice, scrollamt, max_choice);
} else {
/* De-highlight current item */
print_item(list,
&items[scrollamt + choice],
states,
choice, FALSE);
/* Highlight new item */
choice = i;
print_item(list,
&items[scrollamt + choice],
states,
choice, TRUE);
(void) wnoutrefresh(list);
print_arrows(dialog,
box_x, box_y,
scrollamt, max_choice, item_no, use_height);
(void) wmove(dialog, cur_y, cur_x);
wrefresh(dialog);
print_list(&all, choice, scrollamt, max_choice);
}
}
continue; /* wait for another key press */
@ -645,7 +601,7 @@ dialog_checklist(const char *title,
int flag)
{
int result;
int i;
int i, j;
DIALOG_LISTITEM *listitems;
bool separate_output = ((flag == FLAG_CHECK)
&& (dialog_vars.separate_output));
@ -655,13 +611,15 @@ dialog_checklist(const char *title,
listitems = dlg_calloc(DIALOG_LISTITEM, (size_t) item_no + 1);
assert_ptr(listitems, "dialog_checklist");
for (i = 0; i < item_no; ++i) {
listitems[i].name = ItemName(i);
listitems[i].text = ItemText(i);
for (i = j = 0; i < item_no; ++i) {
listitems[i].name = items[j++];
listitems[i].text = (dialog_vars.no_items
? dlg_strempty()
: items[j++]);
listitems[i].state = !dlg_strcmp(items[j++], "on");
listitems[i].help = ((dialog_vars.item_help)
? ItemHelp(i)
? items[j++]
: dlg_strempty());
listitems[i].state = !dlg_strcmp(ItemStatus(i), "on");
}
dlg_align_columns(&listitems[0].text, (int) sizeof(DIALOG_LISTITEM), item_no);
@ -720,10 +678,14 @@ dialog_checklist(const char *title,
} else {
if (dlg_need_separator())
dlg_add_separator();
dlg_add_string(listitems[i].name);
if (flag == FLAG_CHECK)
dlg_add_quoted(listitems[i].name);
else
dlg_add_string(listitems[i].name);
}
}
}
dlg_add_last_key(separate_output);
}
dlg_free_columns(&listitems[0].text, (int) sizeof(DIALOG_LISTITEM), item_no);

View File

@ -1,5 +1,5 @@
/*
* $Id: columns.c,v 1.8 2011/06/28 09:26:23 tom Exp $
* $Id: columns.c,v 1.10 2011/10/20 20:53:55 tom Exp $
*
* columns.c -- implements column-alignment
*
@ -45,7 +45,7 @@ next_row(char **target, int per_row)
{
char *result = (char *) target;
result += per_row;
return (char **) result;
return (char **) (void *) result;
}
static char *
@ -148,6 +148,7 @@ dlg_align_columns(char **target, int per_row, int num_rows)
memcpy(text + offset, *value + offsets[n], (size_t) widths[n]);
offset += maxwidth[n] + 1;
}
text[realwidth] = 0;
*value = text;
}

View File

@ -2,9 +2,9 @@
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2911 Free Software Foundation, Inc.
# 2011, 2012 Free Software Foundation, Inc.
timestamp='2011-01-01'
timestamp='2012-09-25'
# 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
@ -17,9 +17,7 @@ timestamp='2011-01-01'
# 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.
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@ -57,7 +55,7 @@ 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, 2006, 2007, 2008, 2009, 2010, 2011
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
@ -145,7 +143,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
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*,
# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward
@ -202,6 +200,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "${machine}-${os}${release}"
exit ;;
*:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
exit ;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
@ -220,10 +222,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
exit ;;
alpha:OSF1:*:*)
case $UNAME_RELEASE in
*4.0)
*4.0)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
;;
*5.*)
*5.*)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
;;
esac
@ -304,7 +306,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit ;;
arm:riscos:*:*|arm:RISCOS:*:*)
arm*:riscos:*:*|arm*:RISCOS:*:*)
echo arm-unknown-riscos
exit ;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
@ -600,50 +602,50 @@ EOF
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" ;;
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
esac ;;
esac
fi
if [ "${HP_ARCH}" = "" ]; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
sed 's/^ //' << EOF >$dummy.c
#define _HPUX_SOURCE
#include <stdlib.h>
#include <unistd.h>
#define _HPUX_SOURCE
#include <stdlib.h>
#include <unistd.h>
int main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
#endif
long cpu = sysconf (_SC_CPU_VERSION);
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);
}
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
@ -792,21 +794,26 @@ EOF
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit ;;
*:FreeBSD:*:*)
case ${UNAME_MACHINE} in
pc98)
echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
UNAME_PROCESSOR=`/usr/bin/uname -p`
case ${UNAME_PROCESSOR} in
amd64)
echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
*)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
esac
exit ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
exit ;;
*:MINGW64*:*)
echo ${UNAME_MACHINE}-pc-mingw64
exit ;;
*:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
exit ;;
i*:MSYS*:*)
echo ${UNAME_MACHINE}-pc-msys
exit ;;
i*:windows32*:*)
# uname -m includes "-pc" on this system.
echo ${UNAME_MACHINE}-mingw32
@ -861,15 +868,22 @@ EOF
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit ;;
aarch64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
echo ${UNAME_MACHINE}-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 ;;
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 -q ld.so.1
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
@ -877,30 +891,39 @@ EOF
exit ;;
arm*:Linux:*:*)
eval $set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null | \
grep -q __ARM_EABI__
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
echo ${UNAME_MACHINE}-unknown-linux-gnu
else
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
else
echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
fi
fi
exit ;;
avr32*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
cris:Linux:*:*)
echo cris-axis-linux-gnu
echo ${UNAME_MACHINE}-axis-linux-gnu
exit ;;
crisv32:Linux:*:*)
echo crisv32-axis-linux-gnu
echo ${UNAME_MACHINE}-axis-linux-gnu
exit ;;
frv:Linux:*:*)
echo frv-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
hexagon:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
i*86:Linux:*:*)
LIBC=gnu
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
sed 's/^ //' << EOF >$dummy.c
#ifdef __dietlibc__
LIBC=dietlibc
#endif
@ -937,7 +960,7 @@ EOF
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;;
or32:Linux:*:*)
echo or32-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
padre:Linux:*:*)
echo sparc-unknown-linux-gnu
@ -972,13 +995,13 @@ EOF
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
tile*:Linux:*:*)
echo ${UNAME_MACHINE}-tilera-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
vax:Linux:*:*)
echo ${UNAME_MACHINE}-dec-linux-gnu
exit ;;
x86_64:Linux:*:*)
echo x86_64-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
xtensa*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
@ -1096,7 +1119,7 @@ EOF
&& { 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; } ;;
&& { echo i486-ncr-sysv4; exit; } ;;
NCR*:*:4.2:* | MPRAS*:*:4.2:*)
OS_REL='.3'
test -r /etc/.relid \
@ -1139,8 +1162,8 @@ EOF
echo ns32k-sni-sysv
fi
exit ;;
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV>
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV>
echo i586-unisys-sysv4
exit ;;
*:UNIX_System_V:4*:FTX*)
@ -1168,9 +1191,9 @@ EOF
exit ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
echo mips-nec-sysv${UNAME_RELEASE}
echo mips-nec-sysv${UNAME_RELEASE}
else
echo mips-unknown-sysv${UNAME_RELEASE}
echo mips-unknown-sysv${UNAME_RELEASE}
fi
exit ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
@ -1185,6 +1208,9 @@ EOF
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
echo i586-pc-haiku
exit ;;
x86_64:Haiku:*:*)
echo x86_64-unknown-haiku
exit ;;
SX-4:SUPER-UX:*:*)
echo sx4-nec-superux${UNAME_RELEASE}
exit ;;
@ -1215,12 +1241,12 @@ EOF
i386)
eval $set_cc_for_build
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
UNAME_PROCESSOR="x86_64"
fi
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
UNAME_PROCESSOR="x86_64"
fi
fi ;;
unknown) UNAME_PROCESSOR=powerpc ;;
esac
@ -1229,8 +1255,8 @@ EOF
*:procnto*:*:* | *:QNX:[0123456789]*:*)
UNAME_PROCESSOR=`uname -p`
if test "$UNAME_PROCESSOR" = "x86"; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
fi
echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
exit ;;
@ -1240,7 +1266,7 @@ EOF
NEO-?:NONSTOP_KERNEL:*:*)
echo neo-tandem-nsk${UNAME_RELEASE}
exit ;;
NSE-?:NONSTOP_KERNEL:*:*)
NSE-*:NONSTOP_KERNEL:*:*)
echo nse-tandem-nsk${UNAME_RELEASE}
exit ;;
NSR-?:NONSTOP_KERNEL:*:*)
@ -1309,11 +1335,11 @@ EOF
i*86:AROS:*:*)
echo ${UNAME_MACHINE}-pc-aros
exit ;;
x86_64:VMkernel:*:*)
echo ${UNAME_MACHINE}-unknown-esx
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 <<EOF
#ifdef _SEQUENT_
@ -1331,11 +1357,11 @@ main ()
#include <sys/param.h>
printf ("m68k-sony-newsos%s\n",
#ifdef NEWSOS4
"4"
"4"
#else
""
""
#endif
); exit (0);
); exit (0);
#endif
#endif

View File

@ -1,10 +1,10 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
# 2011 Free Software Foundation, Inc.
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012 Free Software Foundation, Inc.
timestamp='2011-04-01'
timestamp='2012-08-18'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@ -21,9 +21,7 @@ timestamp='2011-04-01'
# 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.
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@ -76,7 +74,7 @@ version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
@ -125,13 +123,17 @@ esac
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | \
kopensolaris*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
android-linux)
os=-linux-android
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
;;
*)
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
if [ $basic_machine != $1 ]
@ -223,6 +225,12 @@ case $os in
-isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-lynx*178)
os=-lynxos178
;;
-lynx*5)
os=-lynxos5
;;
-lynx*)
os=-lynxos
;;
@ -247,17 +255,22 @@ case $basic_machine in
# Some are omitted here because they have special meanings below.
1750a | 580 \
| a29k \
| aarch64 | aarch64_be \
| 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 | avr32 \
| be32 | be64 \
| bfin \
| c4x | clipper \
| d10v | d30v | dlx | dsp16xx \
| epiphany \
| fido | fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| hexagon \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| le32 | le64 \
| lm32 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | mcore | mep | metag \
@ -291,7 +304,7 @@ case $basic_machine in
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle \
| pyramid \
| rx \
| rl78 | rx \
| score \
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
@ -300,7 +313,7 @@ case $basic_machine in
| spu \
| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
| ubicom32 \
| v850 | v850e \
| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
| we32k \
| x86 | xc16x | xstormy16 | xtensa \
| z8k | z80)
@ -315,8 +328,7 @@ case $basic_machine in
c6x)
basic_machine=tic6x-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12 | picochip)
# Motorola 68HC11/12.
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
basic_machine=$basic_machine-unknown
os=-none
;;
@ -325,21 +337,28 @@ case $basic_machine in
ms1)
basic_machine=mt-unknown
;;
strongarm | thumb | xscale)
basic_machine=arm-unknown
;;
xgate)
basic_machine=$basic_machine-unknown
os=-none
;;
xscaleeb)
basic_machine=armeb-unknown
;;
xscaleel)
basic_machine=armel-unknown
;;
# 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
;;
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
*-*-*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
@ -348,11 +367,13 @@ case $basic_machine in
# Recognize the basic CPU types with company name.
580-* \
| a29k-* \
| aarch64-* | aarch64_be-* \
| 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-* | avr32-* \
| be32-* | be64-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* \
| clipper-* | craynv-* | cydra-* \
@ -361,8 +382,10 @@ case $basic_machine in
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| hexagon-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
| le32-* | le64-* \
| lm32-* \
| m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
@ -396,7 +419,7 @@ case $basic_machine in
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
| pyramid-* \
| romp-* | rs6000-* | rx-* \
| rl78-* | romp-* | rs6000-* | rx-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
@ -404,10 +427,11 @@ case $basic_machine in
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
| tahoe-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tile-* | tilegx-* \
| tile*-* \
| tron-* \
| ubicom32-* \
| v850-* | v850e-* | vax-* \
| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
| vax-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* \
| xstormy16-* | xtensa*-* \
@ -707,7 +731,6 @@ case $basic_machine in
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
@ -768,6 +791,10 @@ case $basic_machine in
microblaze)
basic_machine=microblaze-xilinx
;;
mingw64)
basic_machine=x86_64-pc
os=-mingw64
;;
mingw32)
basic_machine=i386-pc
os=-mingw32
@ -804,10 +831,18 @@ case $basic_machine in
ms1-*)
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
msys)
basic_machine=i386-pc
os=-msys
;;
mvs)
basic_machine=i370-ibm
os=-mvs
;;
nacl)
basic_machine=le32-unknown
os=-nacl
;;
ncr3000)
basic_machine=i486-ncr
os=-sysv4
@ -836,10 +871,10 @@ case $basic_machine in
basic_machine=v70-nec
os=-sysv
;;
next | m*-next)
next | m*-next )
basic_machine=m68k-next
case $os in
-nextstep*)
-nextstep* )
;;
-ns2*)
os=-nextstep2
@ -958,11 +993,9 @@ case $basic_machine in
pn)
basic_machine=pn-gould
;;
power)
basic_machine=power-ibm
power) basic_machine=power-ibm
;;
ppc | ppcbe)
basic_machine=powerpc-unknown
ppc | ppcbe) basic_machine=powerpc-unknown
;;
ppc-* | ppcbe-*)
basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
@ -973,11 +1006,9 @@ case $basic_machine in
ppcle-* | powerpclittle-*)
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64)
basic_machine=powerpc64-unknown
ppc64) basic_machine=powerpc64-unknown
;;
ppc64-*)
basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64le | powerpc64little | ppc64-le | powerpc64-little)
basic_machine=powerpc64le-unknown
@ -1120,13 +1151,8 @@ case $basic_machine in
basic_machine=t90-cray
os=-unicos
;;
# This must be matched before tile*.
tilegx*)
basic_machine=tilegx-unknown
os=-linux-gnu
;;
tile*)
basic_machine=tile-unknown
basic_machine=$basic_machine-unknown
os=-linux-gnu
;;
tx39)
@ -1330,15 +1356,15 @@ case $os in
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
| -openbsd* | -solidbsd* \
| -bitrig* | -openbsd* | -solidbsd* \
| -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* | -cegcc* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -linux-android* \
| -linux-newlib* | -linux-uclibc* \
| -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
| -linux-newlib* | -linux-musl* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
@ -1421,7 +1447,7 @@ case $os in
-nova*)
os=-rtmk-nova
;;
-ns2)
-ns2 )
os=-nextstep2
;;
-nsk*)
@ -1521,6 +1547,9 @@ case $basic_machine in
c4x-* | tic4x-*)
os=-coff
;;
hexagon-*)
os=-elf
;;
tic54x-*)
os=-coff
;;
@ -1548,9 +1577,6 @@ case $basic_machine in
;;
m68000-sun)
os=-sunos3
# This also exists in the configure program, but was not the
# default.
# os=-sunos4
;;
m68*-cisco)
os=-aout
@ -1618,7 +1644,7 @@ case $basic_machine in
m88k-omron*)
os=-luna
;;
*-next)
*-next )
os=-nextstep
;;
*-sequent)

4725
contrib/dialog/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
dnl $Id: configure.in,v 1.65 2011/06/27 10:42:27 tom Exp $
dnl $Id: configure.in,v 1.75 2012/12/30 22:38:00 tom Exp $
dnl Process this file with autoconf to produce a configure script.
dnl ---------------------------------------------------------------------------
dnl Copyright 1999-2010,2011 -- Thomas E. Dickey
dnl Copyright 1999-2011,2012 -- Thomas E. Dickey
dnl
dnl Permission is hereby granted, free of charge, to any person obtaining a
dnl copy of this software and associated documentation files (the
@ -27,7 +27,7 @@ dnl holders shall not be used in advertising or otherwise to promote the
dnl sale, use or other dealings in this Software without prior written
dnl authorization.
dnl ---------------------------------------------------------------------------
AC_PREREQ(2.13.20020210)
AC_PREREQ(2.52.20011201)
AC_INIT(dialog.h)
AC_CONFIG_HEADER(dlg_config.h:config.hin)
@ -39,19 +39,16 @@ AC_SUBST(DESTDIR)
dnl
dnl Checks for programs.
dnl
AC_PROG_CC
CF_PROG_CC
AC_PROG_CPP
AC_PROG_GCC_TRADITIONAL
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_INSTALL
CF_PROG_LINT
dnl needed for CF_WITH_LIBTOOL
AC_CHECK_TOOL(AR, ar, ar)
AC_ISC_POSIX
AC_C_CONST
CF_MAKEFLAGS
CF_MAKE_TAGS
CF_DISABLE_ECHO
@ -94,7 +91,7 @@ CF_ARG_MSG_ENABLE([if you want --trace option],
trace,
[ --disable-trace do not support --trace option],
[EXTRAOBJS="$EXTRAOBJS trace\$o"
AC_DEFINE(HAVE_DLG_TRACE)],,yes)
AC_DEFINE(HAVE_DLG_TRACE,1,[Define to 1 to support --trace option])],,yes)
LIBTOOL_MAKE="#"
CF_WITH_LIBTOOL
@ -135,48 +132,59 @@ CF_ARG_MSG_ENABLE([if you want config-file support],
rc-file,
[ --disable-rc-file do not include config-file support],
[EXTRAOBJS="$EXTRAOBJS rc\$o"
AC_DEFINE(HAVE_RC_FILE)],,$cf_all_widgets)
AC_DEFINE(HAVE_RC_FILE,1,[Define to 1 to include config-file support])],,$cf_all_widgets)
CF_ARG_MSG_ENABLE([if you want Xdialog-style dialogs],
Xdialog,
[ --disable-Xdialog do not include Xdialog-style dialogs],
[ --disable-Xdialog do not include Xdialog-style dialogs (1.1)],
[EXTRAOBJS="$EXTRAOBJS calendar\$o fselect\$o timebox\$o"
AC_DEFINE(HAVE_XDIALOG)],,$cf_all_widgets)
AC_DEFINE(HAVE_XDIALOG,1,[Define to 1 to include Xdialog-style dialogs])],,$cf_all_widgets)
CF_ARG_MSG_ENABLE([if you want extra Xdialog-style dialogs (1.2)],
Xdialog2,
[ --disable-Xdialog2 do not include extra Xdialog-style dialogs (1.2)],
[EXTRAOBJS="$EXTRAOBJS buildlist\$o rangebox\$o treeview\$o"
AC_DEFINE(HAVE_XDIALOG2,1,[Define to 1 to include extra Xdialog-style dialogs])],,$cf_all_widgets)
CF_ARG_MSG_ENABLE([if you want compatibility with whiptail options],
whiptail,
[ --disable-whiptail do not map extra whiptail options],
[AC_DEFINE(HAVE_WHIPTAIL,1,[Define to 1 to include extra whiptail options])],,$cf_all_widgets)
CF_ARG_MSG_ENABLE([if you want the form dialog],
form,
[ --disable-form do not include the form dialog],
[EXTRAOBJS="$EXTRAOBJS formbox\$o"
AC_DEFINE(HAVE_DLG_FORMBOX)],,$cf_all_widgets)
AC_DEFINE(HAVE_DLG_FORMBOX,1,[Define to 1 to include the form dialog])],,$cf_all_widgets)
CF_ARG_MSG_ENABLE([if you want the gauge dialog],
gauge,
[ --disable-gauge do not include the gauge dialogs],
[EXTRAOBJS="$EXTRAOBJS guage\$o pause\$o prgbox\$o progressbox\$o"
AC_DEFINE(HAVE_DLG_GAUGE)],,$cf_all_widgets)
AC_DEFINE(HAVE_DLG_GAUGE,1,[Define to 1 to include the gauge dialogs])],,$cf_all_widgets)
CF_ARG_MSG_ENABLE([if you want the tailbox dialog],
tailbox,
[ --disable-tailbox do not include the tailbox dialog],
[EXTRAOBJS="$EXTRAOBJS tailbox\$o"
AC_DEFINE(HAVE_DLG_TAILBOX)],,$cf_all_widgets)
AC_DEFINE(HAVE_DLG_TAILBOX,1,[Define to 1 to include the tailbox dialog])],,$cf_all_widgets)
CF_ARG_MSG_ENABLE([if you want the mixedform dialog],
mixedform,
[ --disable-mixedform do not include the mixedform dialog],
[EXTRAOBJS="$EXTRAOBJS mixedform\$o"
AC_DEFINE(HAVE_DLG_MIXEDFORM)],,$cf_all_widgets)
AC_DEFINE(HAVE_DLG_MIXEDFORM,1,[Define to 1 to include the mixedform dialog])],,$cf_all_widgets)
CF_ARG_MSG_ENABLE([if you want the mixedgauge dialog],
mixedgauge,
[ --disable-mixedgauge do not include the mixedgauge dialog],
[EXTRAOBJS="$EXTRAOBJS mixedgauge\$o"
AC_DEFINE(HAVE_MIXEDGAUGE)],,$cf_all_widgets)
AC_DEFINE(HAVE_MIXEDGAUGE,1,[Define to 1 to include the mixedgauge dialog])],,$cf_all_widgets)
CF_ARG_MSG_ENABLE([if you want the wide-curses features],
widec,
[ --enable-widec enable wide-curses features],
[AC_DEFINE(USE_WIDE_CURSES)],,$cf_wide_curses)
[AC_DEFINE(USE_WIDE_CURSES,1,[Define to 1 to enable wide-curses features])],,$cf_wide_curses)
AC_SUBST(EXTRAOBJS)
@ -226,19 +234,22 @@ getpary \
getparyx \
use_default_colors \
wchgat \
wcursyncup \
wget_wch \
wsyncup \
)
AC_CHECK_FUNC(start_color,[AC_DEFINE(HAVE_COLOR)])
AC_CHECK_FUNC(start_color,[AC_DEFINE(HAVE_COLOR,1,[Define to 1 if (n)curses has start_color function])])
CF_CURSES_CHTYPE
CF_CURSES_WACS_SYMBOLS
CF_CURSES_WGETPARENT
CF_FUNC_WAIT
CF_MBSTATE_T
CF_HEADERS_SH(DLG,dlg_config.h)
AC_TRY_LINK([#include <locale.h>],[setlocale(LC_ALL, "")],[AC_DEFINE(HAVE_SETLOCALE)])
AC_TRY_LINK([#include <locale.h>],[setlocale(LC_ALL, "")],[AC_DEFINE(HAVE_SETLOCALE,1,[Define to 1 if locale feature can be enabled])])
CF_DISABLE_RPATH_HACK
AC_OUTPUT(dialog-config makefile $EXTRA_OUTPUT $SUB_MAKEFILE samples/install/makefile,,,sort -u)
AC_OUTPUT(dialog-config makefile $EXTRA_OUTPUT $SUB_MAKEFILE,,,sort -u)

View File

@ -1,7 +1,7 @@
#!@SHELL@
# $Id: dialog-config.in,v 1.5 2011/01/06 09:38:03 tom Exp $
# $Id: dialog-config.in,v 1.6 2012/10/06 14:29:45 tom Exp $
##############################################################################
# Copyright (c) 2007,2011 Thomas E. Dickey #
# Copyright (c) 2007-2011,2012 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"), #
@ -30,6 +30,7 @@
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
bindir="@bindir@"
libdir="@libdir@"

View File

@ -1,6 +1,6 @@
'\" t
.\" $Id: dialog.1,v 1.133 2011/06/29 09:39:29 tom Exp $
.\" Copyright 2005-2010,2011 Thomas E. Dickey
.\" $Id: dialog.1,v 1.165 2013/03/15 09:07:30 tom Exp $
.\" Copyright 2005-2012,2013 Thomas E. Dickey
.\"
.\" This program is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU Lesser General Public License, version 2.1
@ -27,18 +27,23 @@
.ne 8
.IP
..
.de EX
.RS +10
.de Ex
.RS +7
.PP
.nf
..
.de EE
.de Ee
.fi
.RE
..
.\" Bulleted paragraph
.de bP
.IP \(bu 4
..
.
.TH \*D 1 "" "$Date: 2011/06/29 09:39:29 $"
.TH \*D 1 "" "$Date: 2013/03/15 09:07:30 $"
.SH NAME
\*p \- display dialog boxes from shell scripts
dialog \- display dialog boxes from shell scripts
.SH SYNOPSIS
\fB\*p --clear\fP
.br
@ -59,6 +64,7 @@ These types of dialog boxes are implemented
.LP
.nh
.na
.BR buildlist ", "
.BR calendar ", "
.BR checklist ", "
.BR dselect ", "
@ -80,22 +86,22 @@ These types of dialog boxes are implemented
.BR programbox ", "
.BR progressbox ", "
.BR radiolist ", "
.BR rangebox ", "
.BR tailbox ", "
.BR tailboxbg ", "
.BR textbox ", "
.BR timebox ", and "
.BR timebox ", "
.BR treeview ", and "
.BR yesno " (yes/no)."
.ad
.hy
.RE
.PP
You can put more than one dialog box into a script:
.TP 5
-
.bP
Use the "\fB--and-widget\fP" token to force \fB\*p\fP to proceed to the next
dialog unless you have pressed ESC to cancel, or
.TP 5
-
.bP
Simply add the tokens for the next dialog box, making a chain.
\*L stops chaining when the return code from a dialog is nonzero,
e.g., Cancel or No (see DIAGNOSTICS).
@ -172,39 +178,39 @@ To compare the effects, use these:
.
.ES
All three widgets visible, staircase effect, ordered 1,2,3:
.EX
\*p \
.Ex
\*p \\
--begin 2 2 --yesno "" 0 0 \\
--and-widget --begin 4 4 --yesno "" 0 0 \\
--and-widget --begin 6 6 --yesno "" 0 0
.EE
.Ee
.
.ES
Only the last widget is left visible:
.EX
\*p \
.Ex
\*p \\
--clear --begin 2 2 --yesno "" 0 0 \\
--and-widget --clear --begin 4 4 --yesno "" 0 0 \\
--and-widget --begin 6 6 --yesno "" 0 0
.EE
.Ee
.
.ES
All three widgets visible, staircase effect, ordered 3,2,1:
.EX
\*p \
.Ex
\*p \\
--keep-window --begin 2 2 --yesno "" 0 0 \\
--and-widget --keep-window --begin 4 4 --yesno "" 0 0 \\
--and-widget --begin 6 6 --yesno "" 0 0
.EE
.Ee
.
.ES
First and third widget visible, staircase effect, ordered 3,1:
.EX
\*p \
.Ex
\*p \\
--keep-window --begin 2 2 --yesno "" 0 0 \\
--and-widget --clear --begin 4 4 --yesno "" 0 0 \\
--and-widget --begin 6 6 --yesno "" 0 0
.EE
.Ee
.IP
Note, if you want to restore original console colors and send your
cursor home after the dialog program has exited, use the \fBclear\fR\ (1)
@ -237,6 +243,7 @@ occurrences of the given string, and to align the split data into columns.
.IP "\fB--cr-wrap"
Interpret embedded newlines in the dialog text as a newline on the screen.
Otherwise, \fB\*p\fR will only wrap lines where needed to fit inside the text box.
.IP
Even though you can control line breaks with this,
\fB\*L\fR will still wrap any lines that are too long for the width of the box.
Without cr-wrap, the layout of your text may be formatted to look nice
@ -270,6 +277,25 @@ If "\fB--nocancel\fP" or "\fB--visit-items\fP" are given
those options overrides this,
making the default button always "Yes" (internally the same as "OK").
.
.IP "\fB--default-button \fIstring"
Set the default (preselected) button in a widget.
By preselecting a button,
a script makes it possible for the user to simply press \fIEnter\fP
to proceed through a dialog with minimum interaction.
.IP
The option's value is the name of the button:
.IR ok ,
.IR yes ,
.IR cancel ,
.IR no ,
.IR help "\ or"
.IR extra .
.IP
Normally the first button in each widget is the default.
The first button shown is determined by the widget
together with the "\fB--nook\fP" and "\fB--nocancel\fP options.
If this option is not given, there is no default button assigned.
.
.IP "\fB--default-item \fIstring"
Set the default item in a checklist, form or menu box.
Normally the first item in the box is the default.
@ -338,13 +364,14 @@ adding a column which is displayed in the bottom line of the
screen, for the currently selected item.
.
.IP "\fB--keep-tite"
Normally \fB\*p\fP checks to see if it is running in an \fBxterm\fP,
When built with \fBncurses\fP,
\fB\*p\fP normally checks to see if it is running in an \fBxterm\fP,
and in that case tries to suppress the initialization strings that
would make it switch to the alternate screen.
Switching between the normal and alternate screens
is visually distracting in a script which runs \fB\*p\fP
several times.
Use this option to allow \fB\*p\fP to use those initialization strings.
Use this option to allow \fB\*p\fP to use those initialization strings.
.
.IP "\fB--keep-window"
Normally when \fB\*p\fR performs several \fBtailboxbg\fR widgets
@ -357,6 +384,12 @@ marked with "\fB--keep-window\fR", even if they are not \fBtailboxbg\fR widgets.
That causes them to be repainted in reverse order.
See the discussion of the "\fB--clear\fR" option for examples.
.
.IP "\fB--last-key"
At exit, report the last key which the user entered.
This is the curses key code rather than a symbol or literal character.
It can be used by scripts to distinguish between two keys which are
bound to the same action.
.
.IP "\fB--max-input \fIsize"
Limit input strings to the given size.
If not specified, the limit is 2048.
@ -373,6 +406,16 @@ Use this option to disable that feature.
Note that \fB\*p\fR will still wrap text,
subject to the "\fB--cr-wrap\fR" and "\fB--trim\fR" options.
.
.IP "\fB--no-items"
Some widgets (checklist, inputmenu, radiolist, menu) display a list
with two columns (a "tag" and "item", i.e., "description").
This option tells \fB\*p\fP to read shorter rows,
omitting the "item" part of the list.
This is occasionally useful, e.g., if the tags provide enough information.
.IP
See also \fB--no-tags\fP.
If both options are given, this one is ignored.
.
.IP "\fB--no-kill"
Tells
\fB\*p\fP
@ -401,10 +444,27 @@ literal newlines.
Suppress the "OK" button in checklist, inputbox and menu box modes.
A script can still test if the user pressed the "Enter" key to accept the data.
.
.
.IP "\fB--no-shadow"
Suppress shadows that would be drawn to the right and bottom of each dialog box.
.
.IP "\fB--no-tags"
Some widgets (checklist, inputmenu, radiolist, menu) display a list
with two columns (a "tag" and "description").
The tag is useful for scripting, but may not help the user.
The \fB--no-tags\fP option (from Xdialog) may be used to suppress the
column of tags from the display.
Unlike the \fB--no-items\fP option,
this does not affect the data which is read from the script.
.IP
Xdialog does not display the tag column for the analogous buildlist
and treeview widgets; \fB\*p\fP does the same.
.IP
Normally \fB\*p\fP allows you to quickly move to entries on the displayed list,
by matching a single character to the first character of the tag.
When the \fB--no-tags\fP option is given, \fB\*p\fP matches against
the first character of the description.
In either case, the matchable character is highlighted.
.
.IP "\fB--ok-label \fIstring"
Override the label used for "OK" buttons.
.
@ -433,6 +493,11 @@ Prints \fB\*p\fR's version to \fB\*p\fP's output.
This may be used alone, without other options.
It does not cause \fBdialog\fP to exit by itself.
.
.IP "\fB--quoted"
Normally \fB\*p\fP quotes the strings returned by checklist's
as well as the item-help text.
Use this option to quote all string results.
.
.IP "\fB--scrollbar"
For widgets holding a scrollable set of data,
draw a scrollbar on its right-margin.
@ -456,8 +521,8 @@ Draw a shadow to the right and bottom of each dialog box.
Use single-quoting as needed (and no quotes if unneeded) for the
output of checklist's as well as the item-help text.
If this option is not set, \fB\*p\fP uses double quotes around each item.
That requires occasional use of backslashes to make the output useful in
shell scripts.
In either case,
\fB\*p\fP adds backslashes to make the output useful in shell scripts.
.
.IP "\fB--size-err"
Check the resulting size of a dialog box before trying to use it,
@ -501,8 +566,11 @@ The day, month, year values in this case are for the current local time.
.IP "\fB--timeout \fIsecs"
Timeout (exit with error code)
if no user response within the given number of seconds.
This is overridden if the background "\fB--tailboxbg\fP is used.
A timeout of zero seconds is ignored.
.IP
This option is ignored by the "\fB--pause\fP" widget.
It is also overridden if the background "\fB--tailboxbg\fP" option is used
to setup multiple concurrent widgets.
.
.IP "\fB--title \fItitle"
Specifies a
@ -510,11 +578,16 @@ Specifies a
string to be displayed at the top of the dialog box.
.
.IP "\fB--trace \fIfilename"
logs the command-line parameters and
keystrokes to the given file.
logs the command-line parameters,
keystrokes and other information to the given file.
If \fBdialog\fP reads a configure file, it is logged as well.
Piped input to the \fIgauge\fP widget is logged.
Use control/T to log a picture of the current dialog window.
.PP
The \fB\*p\fR program handles some command-line parameters specially,
and removes them from the parameter list as they are processed.
For example, if the first option is \fB--trace\fP,
then that is processed (and removed) before \fB\*p\fR initializes the display.
.
.IP "\fB--trim"
eliminate leading blanks,
@ -528,7 +601,7 @@ Prints \fB\*p\fR's version to the standard output, and exits.
See also "\fB--print-version\fP".
.
.IP "\fB--visit-items"
Modify the tab-traversal of checklist, radiobox, menubox and inputmenu
Modify the tab-traversal of checklist, radiolist, menubox and inputmenu
to include the list of items as one of the states.
This is useful as a visual aid,
i.e., the cursor position helps some users.
@ -556,6 +629,44 @@ the width of the dialog box.
Other parameters depend on the box type.
.
.
.IP "\fB--buildlist \fItext height width \fR[ \fItag item status \fR] \fI..."
A \fBbuildlist\fP dialog displays two lists, side-by-side.
The list on the left shows unselected items.
The list on the right shows selected items.
As items are selected or unselected, they move between the lists.
.IP
Use a carriage return or the "OK" button to accept the current value
in the selected-window and exit.
The results are written using the order displayed in the selected-window.
.IP
The initial on/off state of each entry is specified by
.IR status "."
.IP
The dialog behaves like a \fBmenu\fP, using the \fB--visit-items\fP
to control whether the cursor is allowed to visit the lists directly.
.RS
.bP
If \fB--visit-items\fP is not given,
tab-traversal uses two states (OK/Cancel).
.bP
If \fB--visit-items\fP is given,
tab-traversal uses four states (Left/Right/OK/Cancel).
.RE
.IP
Whether or not \fB--visit--items\fP is given,
it is possible to move the highlight between the two lists using
the default "^" (left-column) and "$" (right-column) keys.
.IP
On exit, a list of the \fItag\fP
strings of those entries that are turned on
will be printed on \fB\*p\fP's output.
.IP
If the "\fB--separate-output\fP" option is not given,
the strings will be quoted as needed to make it simple for scripts to separate them.
By default, this uses double-quotes.
See the "\fB--single-quoted\fP" option, which modifies the quoting behavior.
.
.
.IP "\fB--calendar \fItext height width day month year"
A \fBcalendar\fP box displays
month, day and year in separately adjustable windows.
@ -589,8 +700,10 @@ The initial on/off state of each entry is specified by
On exit, a list of the \fItag\fP
strings of those entries that are turned on
will be printed on \fB\*p\fP's output.
.IP
If the "\fB--separate-output\fP" option is not given,
the strings will be quoted to make it simple for scripts to separate them.
the strings will be quoted as needed to make it simple for scripts to separate them.
By default, this uses double-quotes.
See the "\fB--single-quoted\fP" option, which modifies the quoting behavior.
.
.
@ -621,7 +734,7 @@ On exit, the contents of the text-entry window are written to \fB\*p\fP's output
.
.IP "\fB--editbox \fIfilepath height width\fR"
The edit-box dialog displays a copy of the file.
You may edit it using
You may edit it using
the \fIbackspace\fP, \fIdelete\fP and cursor keys
to correct typing errors.
It also recognizes pageup/pagedown.
@ -642,16 +755,13 @@ The former defines the length shown for a selected field,
while the latter defines the permissible length of the data entered in the
field.
.RS
.TP 3
-
.bP
If \fIflen\fR is zero, the corresponding field cannot be altered.
and the contents of the field determine the displayed-length.
.TP 3
-
.bP
If \fIflen\fR is negative, the corresponding field cannot be altered,
and the negated value of \fIflen\fR is used as the displayed-length.
.TP 3
-
.bP
If \fIilen\fR is zero, it is set to \fIflen\fR.
.RE
.IP
@ -847,7 +957,7 @@ On exit, no text is written to \fB\*p\fP's output.
Only an "OK" button is provided for input,
but an ESC exit status may be returned.
.
.IP "\fB\-\-pause \fItext height width seconds\fR"
.IP "\fB--pause \fItext height width seconds\fR"
A
\fBpause\fP
box displays a meter along the bottom of the box.
@ -899,7 +1009,8 @@ If only two parameters are given, this text is omitted.
.IP "\fB--programbox \fIheight width"
A \fBprogrambox\fP is very similar to a \fBprogressbox\fP.
The only difference between a \fBprogram\fP box and a \fBprogress\fP
box is that a \fBprogram\fP box displays an \fBOK\fP button.
box is that a \fBprogram\fP box displays an \fBOK\fP button
(but only after the command completes).
.IP
This dialog box is used to display the piped output of a command.
After the command completes, the user can press the \fIENTER\fP key so that
@ -913,7 +1024,16 @@ If only two parameters are given, this text is omitted.
.IP "\fB--progressbox \fItext height width"
.IP "\fB--progressbox \fIheight width"
A \fBprogressbox\fP is similar to an \fBtailbox\fP,
except that it will exit when it reaches the end of the file.
except that
.RS
.TP 3
a) rather than displaying the contents of a file,
it displays the piped output of a command and
.TP 3
b) it will exit when it reaches the end of the file
(there is no "OK" button).
.RE
.IP
If three parameters are given, it displays the text under the title,
delineated from the scrolling file's contents.
If only two parameters are given, this text is omitted.
@ -929,7 +1049,7 @@ The only difference is
that you can indicate which entry is currently selected, by setting its
.IR status " to " on "."
.IP
On exit, the name of the selected item is written to \fB\*p\fP's output.
On exit, the tag of the selected item is written to \fB\*p\fP's output.
.
.
.IP "\fB--tailbox \fIfile height width"
@ -942,6 +1062,36 @@ Only an "OK" button is provided for input,
but an ESC exit status may be returned.
.
.
.nf
.IP "\fB--rangebox \fItext height width list-height min-value max-value default-value"
.fi
Allow the user to select from a range of values, e.g., using a slider.
The dialog shows the current value as a bar (like the gauge dialog).
Tabs or arrow keys move the cursor between the buttons and the value.
When the cursor is on the value,
you can edit it by:
.RS
.TP 5
left/right cursor movement to select a digit to modify
.TP 5
+/-
characters to increment/decrement the digit by one
.TP 5
0 through 9
to set the digit to the given value
.RE
.IP
Some keys are also recognized in all cursor positions:
.RS
.TP 5
home/end
set the value to its maximum or minimum
.TP 5
pageup/pagedown
increment the value so that the slider moves by one column
.RE
.
.
.IP "\fB--tailboxbg \fIfile height width"
Display text from a file in a dialog box as a background task,
as in a "tail -f &" command.
@ -1007,6 +1157,19 @@ On exit, the result is printed in the form hour:minute:second.
The format can be overridden using the \fB--time-format\fP option.
.
.
.IP "\fB--treeview \fItext height width list-height \fR[ \fItag item status depth \fR] \fI..."
Display data organized as a tree.
Each group of data contains a tag,
the text to display for the item,
its status ("on" or "off")
and the depth of the item in the tree.
.IP
Only one item can be selected (like the \fBradiolist\fP).
The tag is not displayed.
.IP
On exit, the tag of the selected item is written to \fB\*p\fP's output.
.
.
.IP "\fB--yesno \fItext height width"
A \fByes/no\fP dialog box of
size \fIheight\fP rows by \fIwidth\fP columns will be displayed.
@ -1094,9 +1257,10 @@ can find, as stated in step 2 above.
You can override or add to key bindings in \fB\*p\fP
by adding to the configuration file.
\fB\*L\fP's \fBbindkey\fP command maps single keys to its internal coding.
.EX
.Ex
bindkey \fIwidget\fP \fIcurses_key\fP \fIdialog_key\fP
.EE
.Ee
.PP
The \fIwidget\fP name can be "*" (all widgets), or
specific widgets such as \fBtextbox\fP.
Specific widget bindings override the "*" bindings.
@ -1111,6 +1275,82 @@ Finally, it allows any single character to be escaped with a backslash.
\fB\*L\fP's internal keycode names correspond to the
\fBDLG_KEYS_ENUM\fP type in
\fBdlg_keys.h\fP, e.g., "HELP" from "DLGK_HELP".
.SS Widget Names
.PP
Some widgets (such as the formbox) have an area where fields can be edited.
Those are managed in a subwindow of the widget, and
may have separate keybindings from the main widget
because the subwindows are registered using a different name.
.TS
center tab(/) ;
l l l
l l l .
\fIWidget\fR/\fIWindow name\fR/\fISubwindow Name\fR
calendar/calendar
checklist/checklist
editbox/editbox/editbox2
form/formbox/formfield
fselect/fselect/fselect2
inputbox/inputbox/inputbox2
menu/menubox/menu
msgbox/msgbox
pause/pause
progressbox/progressbox
radiolist/radiolist
tailbox/tailbox
textbox/textbox/searchbox
timebox/timebox
yesno/yesno
.TE
.PP
Some widgets are actually other widgets,
using internal settings to modify the behavior.
Those use the same widget name as the actual widget:
.TS
center tab(/) ;
l l
l l .
\fIWidget\fR/\fIActual Widget\fR
dselect/fselect
infobox/msgbox
inputmenu/menu
mixedform/form
passwordbox/inputbox
passwordform/form
prgbox/progressbox
programbox/progressbox
tailboxbg/tailbox
.TE
.SS Built-in Bindings
This manual page does not list the key bindings for each widget,
because that detailed information can be obtained by running \fB\*p\fP.
If you have set the \fB--trace\fP option,
\fB\*p\fP writes the key-binding information for each widget
as it is registered.
.SS Example
Normally \fB\*p\fP uses different keys for navigating between the buttons
and editing part of a dialog versus navigating within the editing part.
That is, tab (and back-tab) traverse buttons
(or between buttons and the editing part),
while arrow keys traverse fields within the editing part.
Tabs are also recognized as a special case for traversing between
widgets, e.g., when using multiple tailboxbg widgets.
.PP
Some users may wish to use the same key for traversing within the
editing part as for traversing between buttons.
The form widget is written to support this sort of redefinition of
the keys, by adding a special group in <code>dlgk_keys.h</code>
for "form" (left/right/next/prev).
Here is an example binding demonstrating how to do this:
.Ex
bindkey formfield TAB form_NEXT
bindkey formbox TAB form_NEXT
bindkey formfield BTAB form_prev
bindkey formbox BTAB form_prev
.Ee
.PP
That type of redefinition would not be useful in other widgets,
e.g., calendar, due to the potentially large number of fields to traverse.
.
.\" ************************************************************************
.SH ENVIRONMENT
@ -1149,7 +1389,7 @@ error (-1),
ESC (255),
Extra (3),
Help (2),
Help with --item-help (2),
Help with \fB--item-help\fP (2),
or OK (0).
Normally shell scripts cannot distinguish between -1 and 255.
.TP 15
@ -1167,49 +1407,51 @@ of how to use the different box options and how they look.
Just take a look into the directory \fBsamples/\fP of the source.
.SH DIAGNOSTICS
Exit status is subject to being overridden by environment variables.
Normally they are:
The default values and corresponding environment variables
that can override them are:
.TP 5
0
if
.BR \*p " is exited by pressing the " Yes " or " OK
button.
button (DIALOG_OK).
.TP 5
1
if the
.BR No " or " Cancel
button is pressed.
button is pressed (DIALOG_CANCEL).
.TP 5
2
if the
.BR Help
button is pressed.
button is pressed (DIALOG_HELP).
.TP 5
3
if the
.BR Extra
button is pressed.
button is pressed (DIALOG_EXTRA).
.TP 5
4
if the
.BR Item Help
button is pressed.
.BR Help
button is pressed (DIALOG_HELP),
or the \fB--item-help\fP option is set
when the \fBHelp\fP button is pressed (DIALOG_ITEM_HELP),
.TP 5
-1
if errors occur inside \fB\*p\fP
or \fB\*p\fP is exited by pressing the \fIESC\fP key.
if errors occur inside \fB\*p\fP (DIALOG_ERROR)
or \fB\*p\fP is exited by pressing the \fIESC\fP key (DIALOG_ESC).
.
.\" ************************************************************************
.SH PORTABILITY
\fB\*L\fP works with X/Open curses.
However, some implementations have deficiencies:
.RS 3
.TP 3
-
.bP
HPUX curses (and perhaps others) do not open the terminal properly for
the \fInewterm\fP function.
This interferes with \fB\*p\fP's \fB--input-fd\fP option,
by preventing cursor-keys and similar escape sequences from being recognized.
.TP 3
-
.bP
NetBSD 5.1 curses has incomplete support for wide-characters.
\fB\*p\fP will build, but not all examples display properly.
.RE
@ -1262,15 +1504,31 @@ l l.
.RE
.PP
\fBXdialog\fP's manpage has a section discussing its compatibility with \fB\*p\fP.
There are some differences not shown in the manpage.
For example, the html documentation states
.RS
.PP
Note: former Xdialog releases used the "\n" (line feed) as a
results separator for the checklist widget; this has been
changed to "/" in Xdialog v1.5.0 so to make it compatible with
(c)dialog. In your old scripts using the Xdialog checklist, you
will then have to add the --separate-output option before the
--checklist one.
.RE
.PP
\fB\*L\fP has not used a different separator;
the difference was likely due to confusion regarding some script.
.SS WHIPTAIL
Then there is \fBwhiptail\fP.
For practical purposes, it is maintained by Debian.
Its documentation claims
For practical purposes, it is maintained by Debian
(very little work is done by its upstream developers).
Its documentation (README.whiptail) claims
.RS
.sp
.nf
whiptail(1) is a lightweight replacement for \*p(1),
to provide dialog boxes for shell scripts. It is built on the
to provide dialog boxes for shell scripts.
It is built on the
newt windowing library rather than the ncurses library, allowing
it to be smaller in embedded enviroments such as installers,
rescue disks, etc.
@ -1287,18 +1545,24 @@ The comparable number for \fB\*p\fP (counting ncurses) is 520kb.
Disregard the first paragraph.
.PP
The second paragraph is misleading, since \fBwhiptail\fP
also does not work for common options of \*p, such as the gauge box.
\fBwhiptail\fP is less compatible with \fB\*p\fP than the decade-old
original dialog 0.4 program.
also does not work for common options of \fB\*p\fP,
such as the gauge box.
\fBwhiptail\fP is less compatible with \fB\*p\fP than the
original mid-1990s dialog 0.4 program.
.PP
\fBwhiptail\fP's manpage borrows features from \fB\*p\fP, e.g.,
\fB--default-item\fP (2000),
\fB--output-fd\fP (2002),
but oddly cites only \fB\*p\fP versions up to 0.4 (1996) as a source.
but oddly cites only \fB\*p\fP versions up to 0.4 (1994) as a source.
That is, its manpage refers to features which
were borrowed from more recent versions of \fB\*p\fP, e.g.,
the \fB--gauge\fP and \fB--password\fP boxes,
as well as options such as \fB-separate-output\fP (2008).
.bP
\fB--gauge\fP (from 0.5)
.bP
\fB--passwordbox\fP (from Debian changes in 1999),
.bP
\fB--default-item\fP (from \fB\*p\fP 2000/02/22),
.bP
\fB--output-fd\fP (from \fB\*p\fP 2002/08/14).
.PP
Somewhat humorously, one may note that the \fBpopt\fP feature
(undocumented in its manpage)
of using a "--" as an escape was documented in \fB\*p\fP's manpage about
@ -1316,12 +1580,38 @@ l l
_ _
l l.
\fIOption\fR \fITreatment\fR
\fB--cancel-button\fP mapped to \fB--cancel-label\fP
\fB--fb\fP ignored
\fB--fullbutton\fP ignored
\fB--no-button\fP mapped to \fB--no-label\fP
\fB--nocancel\fP mapped to \fB--no-cancel\fP
\fB--noitem\fP ignored
\fB--noitem\fP mapped to \fB--no-items\fP
\fB--notags\fP mapped to \fB--no-tags\fP
\fB--ok-button\fP mapped to \fB--ok-label\fP
\fB--scrolltext\fP mapped to \fB--scrollbar\fP
\fB--topleft\fP mapped to \fB--begin 0 0\fP
\fB--yes-button\fP mapped to \fB--yes-label\fP
.TE
.RE
.LP
There are visual differences which are not addressed by command-line options:
.bP
\fB\*p\fP centers lists within the window.
\fBwhiptail\fP typically puts lists against the left margin.
.bP
\fBwhiptail\fP uses angle brackets ("<" and ">") for marking buttons.
\fB\*p\fP uses square brackets.
.bP
\fBwhiptail\fP marks the limits of subtitles with vertical bars.
\fB\*p\fP does not mark the limits.
.bP
\fBwhiptail\fP attempts to mark the top/bottom cells of a scrollbar
with up/down arrows.
When it cannot do this,
it fills those cells with the background color
of the scrollbar and confusing the user.
\fB\*p\fP uses the entire scrollbar space,
thereby getting better resolution.
.\" ************************************************************************
.SH BUGS
Perhaps.
@ -1340,13 +1630,11 @@ Yura Kalinichenko adapted the gauge widget as "pause".
This is a rewrite (except as needed to provide compatibility)
of the earlier version of \fB\*p 0.9a\fP,
which lists as authors:
.RS
.LP
.bP
Savio Lam - version 0.3, "dialog"
.LP
.bP
Stuart Herbert - patch for version 0.4
.LP
.bP
Marc Ewing - the gauge widget.
.LP
.bP
Pasquale De Marco "Pako" - version 0.9a, "cdialog"
.RE

View File

@ -1,5 +1,6 @@
.\" $Id: dialog.3,v 1.68 2011/06/29 09:07:36 tom Exp $
.\" Copyright 2005-2010,2011 Thomas E. Dickey
'\" t
.\" $Id: dialog.3,v 1.91 2013/03/15 09:07:30 tom Exp $
.\" Copyright 2005-2012,2013 Thomas E. Dickey
.\"
.\" This program is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU Lesser General Public License, version 2.1
@ -38,9 +39,9 @@
.de bP
.IP \(bu 4
..
.TH \*D 3 "" "$Date: 2011/06/29 09:07:36 $"
.TH \*D 3 "" "$Date: 2013/03/15 09:07:30 $"
.SH NAME
\*l \- widgets and utilities for the \*p program
dialog \- widgets and utilities for the \*p program
.SH SYNOPSIS
.B cc [ flag ... ] file ... -l\*l [ library ... ]
.br
@ -108,6 +109,11 @@ are designed for use by the calling application
while variables beginning with "\fIdlg_\fP"
are intended for lower levels, e.g., by the \fB\*l\fP library.
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_STATE.all_subwindows
This is a linked list of all subwindows created by the library.
The \fBdlg_del_window\fP function uses this
to free storage for subwindows when deleting a window.
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_STATE.all_windows
This is a linked list of all windows created by the library.
The \fBdlg_del_window\fP function uses this to locate windows which
@ -290,6 +296,9 @@ bright red.
Restore normal settings with "\\Zn".
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.column_separator
This corresponds to the command-line option "\fB--column-separator\fP".
\fB\*L\fP splits data for radio/checkboxes and menus on the
occurrences of the given string, and aligns the split data into columns.
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.cr_wrap
This corresponds to the command-line option "\fB--cr-wrap\fP".
@ -307,11 +316,16 @@ This corresponds to the command-line option "\fB--date-format\fP \fIstring\fP".
If the host provides \fBstrftime\fP, and the value is nonnull,
the calendar widget uses this to format its output.
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.default_button
This is set by the command-line option "\fB--default-button\fP.
It is used by \fBdlg_default_button\fP.
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.default_item
This corresponds to the command-line option "\fB--default-item\fP \fIstring\fP".
The given string is used as
the default item in a checklist, form or menu box.
Normally the first item in the box is the default.
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.defaultno
This corresponds to the command-line option "\fB--defaultno\fP".
If true,
@ -419,7 +433,7 @@ by echoing asterisks for each character.
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.in_helpfile
This variable is used to prevent \fBdialog_helpfile\fP from showing
anything, e.g., if F1 were pressed within a help-file display.
anything, e.g., if F1 were pressed within a help-file display.
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.item_help
This corresponds to the command-line option "\fB--item-help\fP".
@ -443,11 +457,21 @@ This is useful for keeping the window contents visible when several
widgets are run in the same process.
Note that curses will clear the screen when starting a new process.
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.last_key
This corresponds to the command-line option "\fB--last-key\fP".
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.max_input
This corresponds to the command-line option "\fB--max-input\fP \fIsize\fP".
Limit input strings to the given size.
If not specified, the limit is 2048.
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.no_items
This corresponds to the command-line option "\fB--no-items\fP".
Some widgets (checklist, inputmenu, radiolist, menu) display a list
with two columns (a "tag" and "item", i.e., "description").
This tells \fB\*p\fP to read shorter rows from data,
omitting the "list".
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.no_label
This corresponds to the command-line option "\fB--no-label\fP \fIstring\fP".
The given string overrides the label used for "No" buttons.
@ -462,6 +486,63 @@ This corresponds to the command-line option "\fB--no-nl-expand\fP".
If false, \fBdlg_trim_string\fP converts literal "\\n" substrings
in a message into newlines.
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.no_tags
This corresponds to the command-line option "\fB--no-tags\fP".
Some widgets (checklist, inputmenu, radiolist, menu) display a list
with two columns (a "tag" and "item", also known as "description").
The tag is useful for scripting, but may not help the user.
The \fB--no-tags\fP option (from Xdialog) may be used to suppress the
column of tags from the display.
.IP
Normally \fB\*p\fP allows you to quickly move to entries on the displayed list,
by matching a single character to the first character of the tag.
When the \fB--no-tags\fP option is given, \fB\*p\fP matches against
the first character of the description.
In either case, the matchable character is highlighted.
.IP
Here is a table showing how the no_tags and no_items values interact:
.TS
tab(/);
l l l l l
_ _ _ _ _
l l l c c.
Widget/Fields Shown/Fields Read/.no_items/.no_tags
buildlist/item/tag,item/0/0*
buildlist/item/tag,item/0/1
buildlist/tag/tag/1/0*
buildlist/tag/tag/1/1
checklist/tag,item/tag,item/0/0
checklist/item/tag,item/0/1
checklist/tag/tag/1/0
checklist/tag/tag/1/1
inputmenu/tag,item/tag,item/0/0
inputmenu/item/tag,item/0/1
inputmenu/tag/tag/1/0
inputmenu/tag/tag/1/1
menu/tag,item/tag,item/0/0
menu/item/tag,item/0/1
menu/tag/tag/1/0
menu/tag/tag/1/1
radiolist/tag,item/tag,item/0/0
radiolist/item/tag,item/0/1
radiolist/tag/tag/1/0
radiolist/tag/tag/1/1
treeview/item/tag,item/0/0*
treeview/item/tag,item/0/1
treeview/tag/tag/1/0*
treeview/tag/tag/1/1
_
.TE
.RS
.TP 2
*
Xdialog does not display the tag column for the analogous buildlist
and treeview widgets.
\fB\*L\fP does the same on the command-line.
However the library interface defaults to displaying the tag column.
Your application can enable or disable the tag column as needed for each widget.
.RE
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.nocancel
This corresponds to the command-line option "\fB--no-cancel\fP".
If true,
@ -477,6 +558,8 @@ Note that \fB\*p\fR will still wrap text, subject to the \fB--cr-wrap\fR
option.
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.nook
This corresponds to the command-line option "\fB--nook\fP.
\fB\*L\fP will suppress the "ok" (or "yes") button from the widget.
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.ok_label
This corresponds to the command-line option "\fB--ok-label\fP \fIstring\fP".
@ -488,6 +571,7 @@ If true,
each widget prints its size to \fB\*p\fP's output when it is invoked.
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.quoted
This corresponds to the command-line option "\fB--quoted\fP.
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.separate_output
This corresponds to the command-line option "\fB--separate-output\fP".
@ -501,8 +585,9 @@ If true,
Use single-quoting as needed (and no quotes if unneeded) for the
output of checklist's as well as the item-help text.
If this option is not set, \fB\*p\fP uses double quotes around each item.
That requires occasional use of backslashes to make the output useful in
The latter requires occasional use of backslashes to make the output useful in
shell scripts.
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.size_err
This corresponds to the command-line option "\fB--size-err\fP".
If true,
@ -543,7 +628,8 @@ trim literal newlines and repeated blanks from message text.
.\" ---------------------------------------------------------------------------
.IP \fIDIALOG_VARS.visit_items
This corresponds to the command-line option "\fB--visit-items\fP".
Modify the tab-traversal of checklist, radiobox, menubox and inputmenu
Modify the tab-traversal of the list-oriented widgets
(buildlist, checklist, radiobox, menubox, inputmenu, and treeview)
to include the list of items as one of the states.
This is useful as a visual aid,
i.e., the cursor position helps some users.
@ -572,6 +658,49 @@ the width of the dialog box.
Other parameters depend on the box type.
.
.\" ************************************************************************
.IP \fBdialog_buildlist
implements the "\fB--buildlist\fP" option.
.RS
.TP 5
.B const char * \fItitle
is the title on the top of the widget.
.TP 5
.B const char * \fIcprompt
is the prompt text shown within the widget.
.TP 5
.B int \fIheight
is the desired height of the box.
If zero, the height is adjusted to use the available screen size.
.TP 5
.B int \fIwidth
is the desired width of the box.
If zero, the height is adjusted to use the available screen size.
.TP 5
.B int \fIlist_height
is the minimum height to reserve for displaying the list.
If zero, it is computed based on the given \fIheight\fP and \fIwidth\fP.
.TP 5
.B int \fIitem_no
is the number of rows in \fIitems\fP.
.TP 5
.B char ** \fIitems
is an array of strings which is viewed either as a list of rows
.RS
\fItag item status \fR
.RE
.IP
or
.RS
\fItag item status help\fR
.RE
.IP
depending on whether \fBdialog_vars.item_help\fP is set.
.TP 5
.B int \fIorder_mode
is reserved for future enhancements
.RE
.
.\" ************************************************************************
.IP \fBdialog_calendar
implements the "\fB--calendar\fP" option.
.RS
@ -747,7 +876,7 @@ If zero, the height is based on the screen size.
.\" ************************************************************************
.IP \fBdialog_gauge
implements the "\fB--gauge\fP" option.
Alternatively, a simpler or customized gauge widget can be
Alternatively, a simpler or customized gauge widget can be
setup using
\fBdlg_allocate_gauge\fP,
\fBdlg_update_gauge\fP and
@ -918,7 +1047,8 @@ If zero, the height is based on the screen size.
.B int \fIwidth
is the desired width of the box.
If zero, the height is based on the screen size.
.IP percent
.TP 5
.B int \fIpercent
is the percentage to show in the progress bar.
.TP 5
.B int \fIitem_no
@ -1050,6 +1180,35 @@ is the desired width of the box.
If zero, the height is based on the screen size.
.RE
.\" ************************************************************************
.IP \fBdialog_rangebox
implements the "\fB--rangebox\fP" option.
.RS
.TP 5
.B const char * \fItitle
is the title on the top of the widget.
.TP 5
.B const char * \fIcprompt
is the prompt text shown within the widget.
If empty or null, no prompt is shown.
.TP 5
.B int \fIheight
is the desired height of the widget.
If zero, the height is based on the screen size.
.TP 5
.B int \fIwidth
is the desired width of the widget.
If zero, the height is based on the screen size.
.TP 5
.B int \fImin_value
is the minimum value to allow.
.TP 5
.B int \fImax_value
is the maximum value to allow.
.TP 5
.B int \fIdefault_value
is the default value, if no change is made.
.RE
.\" ************************************************************************
.IP \fBdialog_tailbox
implements the "\fB--tailbox\fP" or "\fB--tailboxbg\fP" option
depending on whether \fIbg_task\fP is set.
@ -1130,6 +1289,42 @@ If the value is negative, the current second is used.
Returns DLG_EXIT_ERROR if the value specified is greater than or equal to 60.
.RE
.\" ************************************************************************
.IP \fBdialog_treeview
implements the "\fB--treeview\fP" option.
.RS
.TP 5
.B const char * \fItitle
is the title on the top of the widget.
.TP 5
.B const char * \fIcprompt
is the prompt text shown within the widget.
.TP 5
.B int \fIheight
is the desired height of the box.
If zero, the height is based on the screen size.
.TP 5
.B int \fIwidth
is the desired width of the box.
If zero, the height is based on the screen size.
.TP 5
.B int \fIlist_height
is the minimum height to reserve for displaying the list.
If zero, it is computed based on the given \fIheight\fP and \fIwidth\fP.
.TP 5
.B int \fIitem_no
is the number of rows in \fIitems\fP.
.TP 5
.B char ** \fIitems
is the list of items, contain tag, name, and optionally help strings
(if \fBdialog_vars.item_help\fP is set).
The initial selection state for each item is also in this list.
.TP 5
.B int \fIflag
.IP flag
is either \fIFLAG_CHECK\fP, for checklists (multiple selections),
or \fIFLAG_RADIO\fP for radiolists (a single selection).
.RE
.\" ************************************************************************
.IP \fBdialog_yesno
implements the "\fB--yesno\fP" option.
.RS
@ -1191,8 +1386,36 @@ function to call when input ends, e.g., to free caller's additional data.
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_add_last_key
Report the last key entered by the user.
This implements the \fB\-\-last\-key\fP command-line option,
using \fBdialog_vars.last_key\fP.
.RS
.TP 5
.B int \fImode
controls the way the last key report is separated from other results:
.RS
.TP 5
-2
(no separator)
.TP 5
-1
(separator after the key name)
.TP 5
0
(separator is optionally before the key name)
.TP 5
1
(same as -1)
.RE
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_add_quoted
Add a quoted string to the result buffer (see \fBdlg_add_result\fP).
If no quotes are necessary, none are used.
If \fBdialog_vars.single_quoted\fR is set, single-quotes are used.
Otherwise, double-quotes are used.
.RS
.TP 5
.B char * \fIstring
@ -1201,7 +1424,7 @@ is the string to add.
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_add_result
Add a quoted string to the result buffer \fBdialog_vars.input_result\fP.
Add a string to the result buffer \fBdialog_vars.input_result\fP.
.RS
.TP 5
.B char * \fIstring
@ -1212,7 +1435,7 @@ is the string to add.
.B dlg_add_separator
Add an output-separator to the result buffer \fBdialog_vars.input_result\fP.
If \fBdialog_vars.output_separator\fP is set, use that.
Otherwise, if \fBdialog_vars.separate_output\fP is set, use newline.
Otherwise, if \fBdialog_vars.separate_output\fP is set, use newline.
If neither is set, use a space.
.\" ---------------------------------------------------------------------------
.TP 5
@ -1276,6 +1499,10 @@ is the percentage to show in the progress bar.
returns its parameter transformed to the
corresponding "+" or "-", etc. for the line-drawing characters used in \fB\*p\fP.
If the parameter is not a line-drawing or other special character such as ACS_DARROW, it returns 0.
.RS
.TP 5
.B chtype \fIch
is the parameter, usually one of the \fBACS_\fP\fIxxx\fP constants.
.RE
.\" ---------------------------------------------------------------------------
.TP 5
@ -1337,13 +1564,13 @@ is the name of the file.
.TP 5
.B int * \fIheight
is the nominal height.
If it is -1, use the screen's height after subtracting \fBdialog_vars.begin_y\fP
if \fBdialog_vars.begin_set\fP is true.
If it is -1, use the screen's height (after subtracting \fBdialog_vars.begin_y\fP
if \fBdialog_vars.begin_set\fP is true).
.TP 5
.B int \fI*width
.B int * \fIwidth
is the nominal width.
If it is -1, use the screen's width after subtracting \fBdialog_vars.begin_x\fP
if \fBdialog_vars.begin_set\fP is true.
If it is -1, use the screen's width (after subtracting \fBdialog_vars.begin_x\fP
if \fBdialog_vars.begin_set\fP is true).
.TP 5
.B int \fIboxlines
is the number of lines to reserve on the screen for drawing boxes.
@ -1360,19 +1587,15 @@ this calls \fBbeep\fP once and sets
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_boxchar
returns its parameter transformed as follows:
returns its \fBchtype\fP parameter transformed as follows:
.RS
.TP 3
.B -
.bP
if neither \fBdialog_vars.ascii_lines\fP nor \fBdialog_vars.no_lines\fP is set.
.TP 3
.B -
.bP
if \fBdialog_vars.ascii_lines\fP is set, returns the corresponding "+" or "-", etc. for the line-drawing characters used in \fB\*p\fP.
.TP 3
.B -
.bP
otherwise, if \fBdialog_vars.no_lines\fP is set, returns a space for the line-drawing characters.
.TP 3
.B -
.bP
if the parameter is not a line-drawing or other special character such as ACS_DARROW, it returns the parameter unchanged.
.RE
.\" ---------------------------------------------------------------------------
@ -1401,6 +1624,56 @@ is the height of the widget.
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_buildlist
This is an alternate interface to the \fBbuildlist\fP widget
which allows the application to read the list item states back
directly without putting them in the output buffer.
.RS
.TP 5
.B const char * \fItitle
is the title string to display at the top of the widget.
.TP 5
.B const char * \fIcprompt
is the prompt text shown within the widget.
.TP 5
.B int \fIheight
is the desired height of the box.
If zero, the height is adjusted to use the available screen size.
.TP 5
.B int \fIwidth
is the desired width of the box.
If zero, the height is adjusted to use the available screen size.
.TP 5
.B int \fIlist_height
is the minimum height to reserve for displaying the list.
If zero, it is computed based on the given \fIheight\fP and \fIwidth\fP.
.TP 5
.B int \fIitem_no
is the number of rows in \fIitems\fP.
.TP 5
.B DIALOG_LISTITEM * \fIitems
is the list of items, contain tag, name, and optionally help strings
(if \fBdialog_vars.item_help\fP is set).
The initial selection state for each item is also in this list.
.TP 5
.B const char * \fIstates
This is a list of characters to display for the given states.
Normally a buildlist provides true (1) and false (0) values,
which the widget displays as "*" and space, respectively.
An application may set this parameter to an arbitrary null-terminated string.
The widget determines the number of states from the length of this string,
and will cycle through the corresponding display characters as the user
presses the space-bar.
.TP 5
.B int \fIorder_mode
is reserved for future enhancements
.TP 5
.B int * \fIcurrent_item
The widget sets the referenced location to the index of the current display
item (cursor) when it returns.
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_button_count
Count the buttons in the list.
.RS
@ -1473,6 +1746,16 @@ abbreviation.
If the label is empty, return -1.
If no uppercase character is found, return 0.
Otherwise return the uppercase character.
.IP
Normally
.B dlg_draw_buttons
and
.B dlg_char_to_button
use the first uppercase character.
However, they keep track of all of the labels and
if the first has already been used in another label,
they will continue looking for another uppercase character.
This function does not have enough information to make that check.
.RS
.TP 5
.B const char * \fIlabel
@ -1481,8 +1764,8 @@ is the label to test.
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_calc_list_width
Calculate the minimum width for the list, assuming none of the items
are truncated.
Calculate the minimum width for the list,
assuming none of the items are truncated.
.RS
.TP 5
.B int \fIitem_no
@ -1493,6 +1776,9 @@ contains a \fIname\fP and \fItext\fP field,
e.g., for checklists or radiobox lists.
The function returns the sum of the widest columns
needed for of each of these fields.
.IP
If \fBdialog_vars.no_items\fP is set,
the \fItext\fP fields in the list are ignored.
.RE
.\" ---------------------------------------------------------------------------
.TP 5
@ -1685,6 +1971,18 @@ is the string to measure.
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_count_real_columns
Returns the number of columns used for a string,
accounting for "\\Z" sequences which can be used for
coloring the text if \fBdialog_vars.colors\fP is set.
This is not necessarily the number of bytes in a string.
.RS
.TP 5
.B const char * \fIstring
is the string to measure.
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_count_wchars
Returns the number of wide-characters in the string.
.RS
@ -1719,6 +2017,13 @@ is the window's width
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_default_button
If \fBdialog_vars.default_button\fP is positive,
return the button-index for that button code,
using \fBdlg_ok_buttoncode\fP to test indices starting with zero.
Otherwise (or if no match was found for the button code), return zero.
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_default_formitem
If \fBdialog_vars.default_item\fP is not null,
find that name by matching the \fIname\fP field in the list of form \fIitems\fP.
@ -1830,7 +2135,8 @@ is the window's border attribute.
Draw a partial box at the bottom of a window,
e.g., to surround a row of buttons.
It is designed to merge with an existing box around
the whole window, so it uses tee-elements rather than corner-elements
the whole window (see \fBdlg_draw_box\fP),
so it uses tee-elements rather than corner-elements
on the top corners of this box.
.RS
.TP 5
@ -1839,6 +2145,27 @@ is the window to update.
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_draw_bottom_box2
Draw a partial box at the bottom of a window,
e.g., to surround a row of buttons.
It is designed to merge with an existing box around
the whole window (see \fBdlg_draw_box2\fP),
so it uses tee-elements rather than corner-elements
on the top corners of this box.
.RS
.TP 5
.B WINDOW * \fIwin
is the window to update.
.B chtype \fIon_left
is used to color the upper/left edges of the box, i.e., the tee-element and
horizontal line
.B chtype \fIon_right
is used to color the right edge of the box, i.e., the tee-element
.B chtype \fIon_inside
is used to fill-color the inside of the box
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_draw_box
Draw a rectangular box with line drawing characters.
.RS
@ -1867,6 +2194,36 @@ is used to color the upper/left edges.
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_draw_box2
Draw a rectangular box with line drawing characters.
.RS
.TP 5
.B WINDOW * \fIwin
is the window to update.
.TP 5
.B int \fIy
is the top row of the box.
.TP 5
.B int \fIx
is the left column of the box.
.TP 5
.B int \fIheight
is the height of the box.
.TP 5
.B int \fIwidth
is the width of the box.
.TP 5
.B chtype \fIboxchar
is used to fill-color for the box contents.
.TP 5
.B chtype \fIborderchar
is used to color the upper/left edges.
.TP 5
.B chtype \fIborderchar2
is used to color the right/lower edges.
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_draw_buttons
Print a list of buttons at the given position.
.RS
@ -1992,6 +2349,27 @@ is the title string to display at the top of the widget.
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_dummy_menutext
This is a utility function which supports the \fB--inputmenu\fP option of
the \fB\*p\fP program.
If \fBdialog_vars.input_menu\fP is set, \fBdialog_menu\fP passes this
pointer to \fBdlg_menu\fP as the \fIrename_menutext\fP parameter.
Otherwise, it passes \fBdlg_dummy_menutext\fP.
.IP
The function should only return \fBDLG_EXIT_ERROR\fP.
.RS
.TP 5
.B DIALOG_LISTITEM * \fIitems
is the list of menu items
.TP 5
.B int \fIcurrent
is the index of the currently-selected item
.TP 5
.B char * \fInewtext
is the updated text for the menu item
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_dump_keys
Write all user-defined key-bindings to the given stream,
e.g., as part of \fBdlg_create_rc\fP.
@ -2002,6 +2380,20 @@ is the stream on which to write the bindings.
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_dump_window_keys
Write all user-defined key-bindings to the given stream,
e.g., as part of \fBdlg_create_rc\fP.
.RS
.TP 5
.B FILE * \fIfp
is the stream on which to write the bindings.
.TP 5
.B WINDOW * \fIwin
is the window for which bindings should be dumped.
If it is null, then only built-in bindings are dumped.
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_eat_argv
Remove one or more items from an argument vector.
.RS
@ -2416,6 +2808,10 @@ The widget sets the referenced location to the index of the current display
item (cursor) when it returns.
.TP 5
.B DIALOG_INPUTMENU \fIrename_menutext
If this is not \fBdlg_dummy_menutext\fP,
the widget acts like an \fIinputmenu\fP widget,
providing an extra "Rename" button,
which activates an edit feature on the selected menu item.
.RE
.\" ---------------------------------------------------------------------------
.TP 5
@ -2544,6 +2940,21 @@ is the top-row for the base
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_mouse_setcode
Sets a value used internally by \fBdlg_mouse_mkregion\fP
which is added to the \fIcode\fP parameter.
By providing different values,
e.g., multiples of \fBKEY_MAX\fP,
it is possible to support multiple "big" regions in a widget.
The \fIbuildlist\fP widget uses this feature to recognize mouse-clicks
in the left/right panes.
.RS
.TP 5
.B int \fIcode
is the value to add to \fBdlg_mouse_mkregion\fP's \fIcode\fP parameter.
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_mouse_wgetch
is a wrapper for \fBdlg_getc\fP which additionally maps mouse-clicks
(if the curses library supports those) into extended function-keys
@ -2699,6 +3110,35 @@ is the current button index
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_print_listitem
This is a helper function used for the various "list" widgets,
e.g., checklist, menu, buildlist, treeview.
Each list-widget has "tag" and "description" values for each item
which can be displayed.
If \fBdialog_vars.no_tags\fP is true,
the "tag" value is not shown.
The first character of the first value shown (tag or description)
is highlighted to indicate that the widget will match it for quick navigation.
.RS
.TP 5
.B WINDOW *\fIwin
the window in which to display the text
.TP 5
.B const char *\fItext
the value to display
.TP 5
.B int \fIclimit
the number of columns available for printing the text
.TP 5
.B bool \fIfirst
true if this is the first call (for "tag" and "description"),
and the first character of the value should be highlighted.
.TP 5
.B int \fIselected
nonzero if the text should be displayed using the "selected" colors
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_print_scrolled
This is a wrapper for \fBdlg_print_autowrap\fP which allows the user
to scroll too-long prompt text up/down.
@ -2898,11 +3338,35 @@ is the binding table
Remove a callback.
.RS
.TP 5
.B DIALOG_CALLBACK \fI* p
.B DIALOG_CALLBACK * \fIp
contains the callback information.
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_renamed_menutext
This is a utility function which supports the \fB--inputmenu\fP option of
the \fB\*p\fP program.
If \fBdialog_vars.input_menu\fP is set, \fBdialog_menu\fP passes this
pointer to \fBdlg_menu\fP as the \fIrename_menutext\fP parameter.
Otherwise, it passes \fBdlg_dummy_menutext\fP.
.IP
The function should add "RENAMED" to \fBdialog_vars.input_result\fP ,
followed by the menu item's name and the \fInewtext\fP value
(with a space separating the three items),
and return \fBDLG_EXIT_EXTRA\fP.
.RS
.TP 5
.B DIALOG_LISTITEM * \fIitems
is the list of menu items
.TP 5
.B int \fIcurrent
is the index of the currently-selected item
.TP 5
.B char * \fInewtext
is the updated text for the menu item
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_restore_vars
Restore \fB\*p\fP's variables from the given variable (see \fBdialog_save_vars\fP).
.RS
@ -2911,7 +3375,7 @@ Restore \fB\*p\fP's variables from the given variable (see \fBdialog_save_vars\f
is the variable from which to restore.
.RE
.IP
The
The
\fIDIALOG_VARS.input_length\fP and
\fIDIALOG_VARS.input_result\fP members are treated specially,
since these are used by a widget to pass data to the caller.
@ -2938,7 +3402,7 @@ store the result of the mapping in the referenced location.
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_save_vars
Save \fB\*p\fP's variables into the given variable (see \fBdialog_restore_vars\fP).
Save \fB\*p\fP's variables into the given variable (see \fBdlg_restore_vars\fP).
.RS
.TP 5
.B DIALOG_VARS * \fIsave
@ -2960,7 +3424,7 @@ is the window on which to place focus (usually a subwindow of a widget)
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_set_result
Setup a fixed-buffer for the result in \fBdialog_vars.input_result\fP
Setup a fixed-buffer for the result in \fBdialog_vars.input_result\fP
.RS
.TP 5
.B const char * \fIstring
@ -3015,10 +3479,10 @@ is the string to duplicate
compare two strings, ignoring case.
.RS
.TP 5
.B const char \fI* a
.B const char * \fIa
is one string
.TP 5
.B const char \fI* b
.B const char * \fIb
is the other string
.RE
.\" ---------------------------------------------------------------------------
@ -3072,7 +3536,7 @@ name and stores the file pointer in \fBdialog_state.trace\fP.
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_trace_chr
If \fBdialog_state.trace\fP is set,
If \fBdialog_state.trace\fP is set,
translate the parameters into a printable representation,
log it on a "chr" line.
.RS
@ -3109,10 +3573,66 @@ DLG_TRACE(("this is dialog version %s\\n", dialog_version()));
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_trace_win
If \fBdialog_state.trace\fP is set,
If \fBdialog_state.trace\fP is set,
log a printable picture of the given window.
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_treeview
This is an alternate interface to 'treeview' which allows the application
to read the list item states back directly without putting them in the
output buffer.
.RS
.TP 5
.B const char * \fItitle
is the title on the top of the widget.
.TP 5
.B const char * \fIcprompt
is the prompt text shown within the widget.
.TP 5
.B int \fIheight
is the desired height of the box.
If zero, the height is based on the screen size.
.TP 5
.B int \fIwidth
is the desired width of the box.
If zero, the height is based on the screen size.
.TP 5
.B int \fIlist_height
is the minimum height to reserve for displaying the list.
If zero, it is computed based on the given \fIheight\fP and \fIwidth\fP.
.TP 5
.B int \fIitem_no
is the number of rows in \fIitems\fP.
.TP 5
.B DIALOG_LISTITEM * \fIitems
is the list of items, contain tag, name, and optionally help strings
(if \fBdialog_vars.item_help\fP is set).
The initial selection state for each item is also in this list.
.TP 5
.B const char * \fIstates
This is a list of characters to display for the given states.
Normally a buildlist provides true (1) and false (0) values,
which the widget displays as "*" and space, respectively.
An application may set this parameter to an arbitrary null-terminated string.
The widget determines the number of states from the length of this string,
and will cycle through the corresponding display characters as the user
presses the space-bar.
.TP 5
.B int * \fIdepths
This is a list of depths of each item in the tree.
It is a separate parameter from \fIitems\fP to allow reuse of
the existing functions.
.TP 5
.B int \fIflag
is either \fIFLAG_CHECK\fP, for checklists (multiple selections),
or \fIFLAG_RADIO\fP for radiolists (a single selection).
.TP 5
.B int * \fIcurrent_item
The widget sets the referenced location to the index of the current display
item (cursor) when it returns.
.RE
.\" ---------------------------------------------------------------------------
.TP 5
.B dlg_trim_string
The \fBdialog\fP program uses this in each widget to adjust the
message string,

View File

@ -1,9 +1,9 @@
/*
* $Id: dialog.c,v 1.193 2011/06/29 09:10:56 tom Exp $
* $Id: dialog.c,v 1.230 2013/03/15 09:07:30 tom Exp $
*
* cdialog - Display simple dialog boxes from shell scripts
*
* Copyright 2000-2010,2011 Thomas E. Dickey
* Copyright 2000-2012,2013 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -48,7 +48,6 @@ typedef enum {
,o_beep
,o_beep_after
,o_begin
,o_calendar
,o_cancel_label
,o_checklist
,o_clear
@ -57,17 +56,14 @@ typedef enum {
,o_cr_wrap
,o_create_rc
,o_date_format
,o_default_button
,o_default_item
,o_defaultno
,o_dselect
,o_editbox
,o_exit_label
,o_extra_button
,o_extra_label
,o_fixed_font
,o_form
,o_fselect
,o_fullbutton
,o_gauge
,o_help
,o_help_button
@ -86,6 +82,7 @@ typedef enum {
,o_keep_colors
,o_keep_tite
,o_keep_window
,o_last_key
,o_max_input
,o_menu
,o_mixedform
@ -101,7 +98,6 @@ typedef enum {
,o_no_nl_expand
,o_no_shadow
,o_nocancel
,o_noitem
,o_nook
,o_ok_label
,o_output_fd
@ -135,7 +131,6 @@ typedef enum {
,o_tailboxbg
,o_textbox
,o_time_format
,o_timebox
,o_timeout
,o_title
,o_trim
@ -145,6 +140,26 @@ typedef enum {
,o_wmclass
,o_yes_label
,o_yesno
#ifdef HAVE_WHIPTAIL
,o_fullbutton
,o_topleft
#endif
#ifdef HAVE_XDIALOG
,o_calendar
,o_dselect
,o_editbox
,o_fselect
,o_timebox
#endif
#ifdef HAVE_XDIALOG2
,o_buildlist
,o_rangebox
,o_treeview
#endif
#if defined(HAVE_XDIALOG2) || defined(HAVE_WHIPTAIL)
,o_no_items
,o_no_tags
#endif
#ifdef HAVE_DLG_TRACE
,o_trace
#endif
@ -189,10 +204,9 @@ static const Options options[] = {
{ "aspect", o_aspect, 1, "<ratio>" },
{ "auto-placement", o_auto_placement, 1, NULL },
{ "backtitle", o_backtitle, 1, "<backtitle>" },
{ "beep", o_beep, 1, NULL },
{ "beep-after", o_beep_after, 1, NULL },
{ "beep", o_beep, 1, "" },
{ "beep-after", o_beep_after, 1, "" },
{ "begin", o_begin, 1, "<y> <x>" },
{ "calendar", o_calendar, 2, "<text> <height> <width> <day> <month> <year>" },
{ "cancel-label", o_cancel_label, 1, "<str>" },
{ "checklist", o_checklist, 2, "<text> <height> <width> <list height> <tag1> <item1> <status1>..." },
{ "clear", o_clear, 1, "" },
@ -201,18 +215,14 @@ static const Options options[] = {
{ "cr-wrap", o_cr_wrap, 1, "" },
{ "create-rc", o_create_rc, 1, NULL },
{ "date-format", o_date_format, 1, "<str>" },
{ "default-button", o_default_button, 1, "<str>" },
{ "default-item", o_default_item, 1, "<str>" },
{ "defaultno", o_defaultno, 1, "" },
{ "dselect", o_dselect, 2, "<directory> <height> <width>" },
{ "editbox", o_editbox, 2, "<file> <height> <width>" },
{ "exit-label", o_exit_label, 1, "<str>" },
{ "extra-button", o_extra_button, 1, "" },
{ "extra-label", o_extra_label, 1, "<str>" },
{ "fb", o_fullbutton, 1, NULL },
{ "fixed-font", o_fixed_font, 1, NULL },
{ "form", o_form, 2, "<text> <height> <width> <form height> <label1> <l_y1> <l_x1> <item1> <i_y1> <i_x1> <flen1> <ilen1>..." },
{ "fselect", o_fselect, 2, "<filepath> <height> <width>" },
{ "fullbutton", o_fullbutton, 1, NULL },
{ "gauge", o_gauge, 2, "<text> <height> <width> [<percent>]" },
{ "guage", o_gauge, 2, NULL },
{ "help", o_help, 4, "" },
@ -232,6 +242,7 @@ static const Options options[] = {
{ "keep-colors", o_keep_colors, 1, NULL },
{ "keep-tite", o_keep_tite, 1, "" },
{ "keep-window", o_keep_window, 1, "" },
{ "last-key", o_last_key, 1, "" },
{ "max-input", o_max_input, 1, "<n>" },
{ "menu", o_menu, 2, "<text> <height> <width> <menu height> <tag1> <item1>..." },
{ "mixedform", o_mixedform, 2, "<text> <height> <width> <form height> <label1> <l_y1> <l_x1> <item1> <i_y1> <i_x1> <flen1> <ilen1> <itype>..." },
@ -240,7 +251,7 @@ static const Options options[] = {
{ "no-cancel", o_nocancel, 1, "" },
{ "no-close", o_no_close, 1, NULL },
{ "no-collapse", o_no_collapse, 1, "" },
{ "no-cr-wrap", o_no_cr_wrap, 1, NULL },
{ "no-cr-wrap", o_no_cr_wrap, 1, "" },
{ "no-kill", o_no_kill, 1, "" },
{ "no-label", o_no_label, 1, "<str>" },
{ "no-lines", o_no_lines, 1, "" },
@ -249,7 +260,6 @@ static const Options options[] = {
{ "no-ok", o_nook, 1, "" },
{ "no-shadow", o_no_shadow, 1, "" },
{ "nocancel", o_nocancel, 1, NULL }, /* see --no-cancel */
{ "noitem", o_noitem, 1, NULL },
{ "nook", o_nook, 1, "" }, /* See no-ok */
{ "ok-label", o_ok_label, 1, "<str>" },
{ "output-fd", o_output_fd, 1, "<fd>" },
@ -283,7 +293,6 @@ static const Options options[] = {
{ "tailboxbg", o_tailboxbg, 2, "<file> <height> <width>" },
{ "textbox", o_textbox, 2, "<file> <height> <width>" },
{ "time-format", o_time_format, 1, "<str>" },
{ "timebox", o_timebox, 2, "<text> <height> <width> <hour> <minute> <second>" },
{ "timeout", o_timeout, 1, "<secs>" },
{ "title", o_title, 1, "<title>" },
{ "trim", o_trim, 1, "" },
@ -293,6 +302,34 @@ static const Options options[] = {
{ "wmclass", o_wmclass, 1, NULL },
{ "yes-label", o_yes_label, 1, "<str>" },
{ "yesno", o_yesno, 2, "<text> <height> <width>" },
#ifdef HAVE_WHIPTAIL
{ "cancel-button", o_cancel_label, 1, NULL },
{ "fb", o_fullbutton, 1, NULL },
{ "fullbutton", o_fullbutton, 1, NULL },
{ "no-button", o_no_label, 1, NULL },
{ "ok-button", o_ok_label, 1, NULL },
{ "scrolltext", o_scrollbar, 1, NULL },
{ "topleft", o_topleft, 1, NULL },
{ "yes-button", o_yes_label, 1, NULL },
#endif
#ifdef HAVE_XDIALOG
{ "calendar", o_calendar, 2, "<text> <height> <width> <day> <month> <year>" },
{ "dselect", o_dselect, 2, "<directory> <height> <width>" },
{ "editbox", o_editbox, 2, "<file> <height> <width>" },
{ "fselect", o_fselect, 2, "<filepath> <height> <width>" },
{ "timebox", o_timebox, 2, "<text> <height> <width> <hour> <minute> <second>" },
#endif
#ifdef HAVE_XDIALOG2
{ "buildlist", o_buildlist, 2, "<text> <height> <width> <tag1> <item1> <status1>..." },
{ "no-items", o_no_items, 1, "" },
{ "no-tags", o_no_tags, 1, "" },
{ "rangebox", o_rangebox, 2, "<text> <height> <width> <min-value> <max-value> <default-value>" },
{ "treeview", o_treeview, 2, "<text> <height> <width> <list-height> <tag1> <item1> <status1> <depth1>..." },
#endif
#if defined(HAVE_XDIALOG2) || defined(HAVE_WHIPTAIL)
{ "noitem", o_no_items, 1, NULL },
{ "notags", o_no_tags, 1, NULL },
#endif
#ifdef HAVE_DLG_TRACE
{ "trace", o_trace, 1, "<file>" },
#endif
@ -431,6 +468,12 @@ unescape_argv(int *argcp, char ***argvp)
dialog_argv = (*argvp);
}
#define OptionChars "\
0123456789\
-\
abcdefghijklmnopqrstuvwxyz\
"
/*
* Check if the given string from main's argv is an option.
*/
@ -449,7 +492,11 @@ isOption(const char *arg)
}
}
} else if (!strncmp(arg, "--", (size_t) 2) && isalpha(UCH(arg[2]))) {
result = TRUE;
if (strlen(arg) == strspn(arg, OptionChars)) {
result = TRUE;
} else {
dlg_exiterr("Invalid option \"%s\"", arg);
}
}
}
return result;
@ -459,17 +506,19 @@ static eOptions
lookupOption(const char *name, int pass)
{
unsigned n;
eOptions result = o_unknown;
if (isOption(name)) {
name += 2;
for (n = 0; n < sizeof(options) / sizeof(options[0]); n++) {
if ((pass & options[n].pass) != 0
&& !strcmp(name, options[n].name)) {
return options[n].code;
result = options[n].code;
break;
}
}
}
return o_unknown;
return result;
}
static void
@ -523,13 +572,17 @@ howmany_tags(char *argv[], int group)
static int
numeric_arg(char **av, int n)
{
char *last = 0;
int result = (int) strtol(av[n], &last, 10);
char msg[80];
int result = 0;
if (last == 0 || *last != 0) {
sprintf(msg, "Expected a number for token %d of %.20s", n, av[0]);
Usage(msg);
if (n < dlg_count_argv(av)) {
char msg[80];
char *last = 0;
result = (int) strtol(av[n], &last, 10);
if (last == 0 || *last != 0) {
sprintf(msg, "Expected a number for token %d of %.20s", n, av[0]);
Usage(msg);
}
}
return result;
}
@ -685,9 +738,7 @@ call_checklist(CALLARGS)
{
int tags = howmany_tags(av + 5, CHECKBOX_TAGS);
int code;
bool save_quoted = dialog_vars.quoted;
dialog_vars.quoted = !dialog_vars.separate_output;
*offset_add = 5 + tags * CHECKBOX_TAGS;
code = dialog_checklist(t,
av[1],
@ -695,7 +746,6 @@ call_checklist(CALLARGS)
numeric_arg(av, 3),
numeric_arg(av, 4),
tags, av + 5, FLAG_CHECK);
dialog_vars.quoted = save_quoted;
return code;
}
@ -792,6 +842,75 @@ call_timebox(CALLARGS)
}
#endif /* HAVE_XDIALOG */
/* dialog 1.2 widgets */
#ifdef HAVE_XDIALOG2
#define DisableNoTags() \
bool save_no_tags = dialog_vars.no_tags; \
bool save_no_items = dialog_vars.no_items; \
dialog_vars.no_tags = TRUE; \
dialog_vars.no_items = FALSE
#define RestoreNoTags() \
dialog_vars.no_tags = save_no_tags; \
dialog_vars.no_items = save_no_items
static int
call_buildlist(CALLARGS)
{
int tags = howmany_tags(av + 5, CHECKBOX_TAGS);
int result;
DisableNoTags();
*offset_add = 5 + tags * CHECKBOX_TAGS;
result = dialog_buildlist(t,
av[1],
numeric_arg(av, 2),
numeric_arg(av, 3),
numeric_arg(av, 4),
tags, av + 5,
TRUE);
RestoreNoTags();
return result;
}
static int
call_rangebox(CALLARGS)
{
int min_value;
*offset_add = arg_rest(av);
min_value = numeric_arg(av, 4);
return dialog_rangebox(t,
av[1],
numeric_arg(av, 2),
numeric_arg(av, 3),
min_value,
numeric_arg(av, 5),
(*offset_add > 6) ? numeric_arg(av, 6) : min_value);
}
static int
call_treeview(CALLARGS)
{
int tags = howmany_tags(av + 5, TREEVIEW_TAGS);
int result;
DisableNoTags();
*offset_add = arg_rest(av);
result = dialog_treeview(t,
av[1],
numeric_arg(av, 2),
numeric_arg(av, 3),
numeric_arg(av, 4),
tags, av + 5, FLAG_RADIO);
RestoreNoTags();
return result;
}
#endif /* HAVE_XDIALOG */
#ifdef HAVE_DLG_FORMBOX
static int
call_form(CALLARGS)
@ -1006,11 +1125,14 @@ static const Mode modes[] =
{o_tailboxbg, 4, 4, call_tailboxbg},
#endif
#ifdef HAVE_XDIALOG
{o_buildlist, 4, 0, call_buildlist},
{o_calendar, 4, 7, call_calendar},
{o_dselect, 4, 5, call_dselect},
{o_editbox, 4, 4, call_editbox},
{o_fselect, 4, 5, call_fselect},
{o_rangebox, 5, 7, call_rangebox},
{o_timebox, 4, 7, call_timebox},
{o_treeview, 4, 0, call_treeview},
#endif
};
/* *INDENT-ON* */
@ -1052,6 +1174,43 @@ optionValue(char **argv, int *num)
return result;
}
/* Return exit-code for a named button */
static int
button_code(const char *name)
{
/* *INDENT-OFF* */
static struct {
const char *name;
int code;
} table[] = {
{ "ok", DLG_EXIT_OK },
{ "yes", DLG_EXIT_OK },
{ "cancel", DLG_EXIT_CANCEL },
{ "no", DLG_EXIT_CANCEL },
{ "help", DLG_EXIT_HELP },
{ "extra", DLG_EXIT_EXTRA },
};
/* *INDENT-ON* */
int code = DLG_EXIT_ERROR;
size_t i;
for (i = 0; i < (sizeof(table) / sizeof(table[0])); i++) {
if (!dlg_strcmp(name, table[i].name)) {
code = table[i].code;
break;
}
}
if (code == DLG_EXIT_ERROR) {
char temp[80];
sprintf(temp, "Button name \"%.20s\" unknown", name);
Usage(temp);
}
return code;
}
/*
* Print parts of a message
*/
@ -1115,7 +1274,7 @@ Help(void)
static const char *const tbl_1[] =
{
"cdialog (ComeOn Dialog!) version %s",
"Copyright 2000-2008,2011 Thomas E. Dickey",
"Copyright 2000-2012,2013 Thomas E. Dickey",
"This is free software; see the source for copying conditions. There is NO",
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.",
"",
@ -1179,6 +1338,32 @@ Help(void)
dlg_exit(DLG_EXIT_OK);
}
#ifdef HAVE_DLG_TRACE
/*
* Only the first call to dlg_trace will open a trace file. But each time
* --trace is parsed, we show the whole parameter list as it is at that moment,
* counting discarded parameters. The only way to capture the whole parameter
* list is if --trace is the first option.
*/
static void
process_trace_option(char **argv, int *offset)
{
int j;
if (dialog_state.trace_output == 0) {
dlg_trace(optionString(argv, offset));
} else {
dlg_trace_msg("# ignore extra --trace option\n");
*offset += 1;
}
dlg_trace_msg("# Parameters:\n");
for (j = 0; argv[j] != 0; ++j) {
dlg_trace_msg("# argv[%d] = %s\n", j, argv[j]);
}
}
#endif
/*
* "Common" options apply to all widgets more/less. Most of the common options
* set values in dialog_vars, a few set dialog_state and a couple write to the
@ -1187,12 +1372,12 @@ Help(void)
static int
process_common_options(int argc, char **argv, int offset, bool output)
{
#ifdef HAVE_DLG_TRACE
int n;
#endif
bool done = FALSE;
dlg_trace_msg("# process_common_options, offset %d\n", offset);
while (offset < argc && !done) { /* Common options */
dlg_trace_msg("#\targv[%d] = %s\n", offset, argv[offset]);
switch (lookupOption(argv[offset], 1)) {
case o_title:
dialog_vars.title = optionString(argv, &offset);
@ -1250,6 +1435,11 @@ process_common_options(int argc, char **argv, int offset, bool output)
break;
case o_defaultno:
dialog_vars.defaultno = TRUE;
dialog_vars.default_button = DLG_EXIT_CANCEL;
break;
case o_default_button:
dialog_vars.default_button = button_code(optionString(argv, &offset));
dialog_vars.defaultno = dialog_vars.default_button == DLG_EXIT_CANCEL;
break;
case o_default_item:
dialog_vars.default_item = optionString(argv, &offset);
@ -1281,6 +1471,9 @@ process_common_options(int argc, char **argv, int offset, bool output)
case o_keep_window:
dialog_vars.keep_window = TRUE;
break;
case o_last_key:
dialog_vars.last_key = TRUE;
break;
case o_no_shadow:
dialog_state.use_shadow = FALSE;
break;
@ -1334,6 +1527,7 @@ process_common_options(int argc, char **argv, int offset, bool output)
break;
case o_visit_items:
dialog_state.visit_items = TRUE;
dialog_state.visit_cols = 1;
break;
case o_aspect:
dialog_state.aspect_ratio = optionValue(argv, &offset);
@ -1388,10 +1582,16 @@ process_common_options(int argc, char **argv, int offset, bool output)
dialog_state.no_mouse = TRUE;
mouse_close();
break;
case o_noitem:
#ifdef HAVE_WHIPTAIL
case o_topleft:
dialog_vars.begin_set = TRUE;
dialog_vars.begin_y = 0;
dialog_vars.begin_x = 0;
break;
case o_fullbutton:
/* ignore */
break;
#endif
/* options of Xdialog which we ignore */
case o_icon:
case o_wmclass:
@ -1416,10 +1616,15 @@ process_common_options(int argc, char **argv, int offset, bool output)
break;
#ifdef HAVE_DLG_TRACE
case o_trace:
dlg_trace(optionString(argv, &offset));
for (n = 0; argv[n] != 0; ++n) {
dlg_trace_msg("argv[%d] = %s\n", n, argv[n]);
}
process_trace_option(argv, &offset);
break;
#endif
#if defined(HAVE_XDIALOG2) || defined(HAVE_WHIPTAIL)
case o_no_items:
dialog_vars.no_items = TRUE;
break;
case o_no_tags:
dialog_vars.no_tags = TRUE;
break;
#endif
}
@ -1440,12 +1645,16 @@ init_result(char *buffer)
static char **special_argv = 0;
static int special_argc = 0;
dlg_trace_msg("# init_result\n");
/* clear everything we do not save for the next widget */
memset(&dialog_vars, 0, sizeof(dialog_vars));
dialog_vars.input_result = buffer;
dialog_vars.input_result[0] = '\0';
dialog_vars.default_button = -1;
/*
* The first time this is called, check for common options given by an
* environment variable.
@ -1458,12 +1667,20 @@ init_result(char *buffer)
special_argv = dlg_string_to_argv(env);
special_argc = dlg_count_argv(special_argv);
}
first = FALSE;
}
/*
* If we are not checking memory leaks, just do the parse of the
* environment once.
*/
if (special_argv != 0) {
process_common_options(special_argc, special_argv, 0, FALSE);
#ifdef NO_LEAKS
free(special_argv[0]);
free(special_argv);
special_argv = 0;
special_argc = 0;
first = TRUE;
#endif
}
@ -1539,10 +1756,28 @@ main(int argc, char *argv[])
case o_help:
Help();
break;
#ifdef HAVE_DLG_TRACE
case o_trace:
/*
* Process/remove the --trace option if it is the first option.
* Otherwise, process it in more/less expected order as a
* "common" option.
*/
if (base == 1) {
process_trace_option(argv, &offset);
break;
} else {
++offset;
continue;
}
#endif
default:
++offset;
continue;
}
dlg_trace_msg("# discarding %d parameters starting with argv[%d] (%s)\n",
1 + offset - base, base,
argv[base]);
for (j = base; j < argc; ++j) {
dialog_argv[j] = dialog_argv[j + 1 + (offset - base)];
if (dialog_opts != 0)
@ -1670,7 +1905,13 @@ main(int argc, char *argv[])
break;
default:
if (argv[j] != 0) {
dlg_trim_string(argv[j]);
char *argv_j = strdup(argv[j]);
if (argv_j != 0) {
dlg_trim_string(argv_j);
argv[j] = argv_j;
} else {
argv[j] = strdup("?");
}
}
break;
}
@ -1679,6 +1920,7 @@ main(int argc, char *argv[])
retval = show_result((*(modePtr->jumper)) (dialog_vars.title,
argv + offset,
&offset_add));
dlg_trace_msg("# widget returns %d\n", retval);
offset += offset_add;
if (dialog_vars.input_result != my_buffer) {

View File

@ -1,9 +1,9 @@
/*
* $Id: dialog.h,v 1.231 2011/06/29 09:51:00 tom Exp $
* $Id: dialog.h,v 1.260 2013/03/17 15:03:41 tom Exp $
*
* dialog.h -- common declarations for all dialog modules
*
* Copyright 2000-2010,2011 Thomas E. Dickey
* Copyright 2000-2012,2013 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -59,11 +59,9 @@
#include <ncurses.h>
#else
#include <curses.h>
#endif
/* most curses.h headers include this, some do not */
#if defined(HAVE_UNCTRL_H)
#include <unctrl.h>
#include <unctrl.h> /* most curses.h headers include this, some do not */
#endif
#endif
/* Solaris xpg4 renames these */
@ -97,6 +95,10 @@
#define _(s) s
#endif
#ifndef GCC_PRINTFLIKE
#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
#endif
#ifndef GCC_NORETURN
#define GCC_NORETURN /*nothing*/
#endif
@ -233,6 +235,21 @@
#define getparyx(win,y,x) (y = (win)?(win)->_pary:ERR, x = (win)?(win)->_parx:ERR)
#endif
#if !defined(HAVE_WGETPARENT) && defined(HAVE_WINDOW__PARENT)
#undef wgetparent
#define wgetparent(win) ((win) ? (win)->_parent : 0)
#endif
#if !defined(HAVE_WSYNCUP)
#undef wsyncup
#define wsyncup(win) /* nothing */
#endif
#if !defined(HAVE_WCURSYNCUP)
#undef wcursyncup
#define wcursyncup(win) /* nothing */
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -274,6 +291,12 @@ extern int dlg_getparx(WINDOW * /*win*/);
extern int dlg_getpary(WINDOW * /*win*/);
#endif
#if !(defined(HAVE_WGETPARENT) && defined(HAVE_WINDOW__PARENT))
#undef wgetparent
#define wgetparent(win) dlg_wgetparent(win)
extern WINDOW * dlg_wgetparent(WINDOW * /*win*/);
#endif
/*
* This is a list of "old" names, which should be helpful in updating
* applications that use libdialog. Starting with 2003/11/26, all exported
@ -307,6 +330,7 @@ extern int dlg_getpary(WINDOW * /*win*/);
#define mouse_mkregion(y,x,h,w,n) dlg_mouse_mkregion(y,x,h,w,n)
#define mouse_region(y,x) dlg_mouse_region(y,x)
#define mouse_setbase(x,y) dlg_mouse_setbase(x,y)
#define mouse_setcode(c) dlg_mouse_setcode(c)
#define mouse_wgetch(w,c) dlg_mouse_wgetch(w,c)
#define new_window(h,w,y,x) dlg_new_window(h,w,y,x)
#define parse_rc() dlg_parse_rc()
@ -357,6 +381,10 @@ extern int dlg_getpary(WINDOW * /*win*/);
#define form_text_attr DIALOG_ATR(31)
#define form_item_readonly_attr DIALOG_ATR(32)
#define gauge_attr DIALOG_ATR(33)
#define border2_attr DIALOG_ATR(34)
#define inputbox_border2_attr DIALOG_ATR(35)
#define searchbox_border2_attr DIALOG_ATR(36)
#define menubox_border2_attr DIALOG_ATR(37)
#define DLGK_max (KEY_MAX + 256)
@ -396,6 +424,7 @@ typedef struct {
DIALOG_CALLBACK *getc_callbacks;
DIALOG_CALLBACK *getc_redirect;
DIALOG_WINDOWS *all_windows;
DIALOG_WINDOWS *all_subwindows;
FILE *output; /* option "--output-fd fd" */
FILE *pipe_input; /* used for gauge widget */
FILE *screen_output; /* newterm(), etc. */
@ -415,6 +444,7 @@ typedef struct {
#endif
/* 1.1-20110106 */
bool no_mouse; /* option "--no-mouse" */
int visit_cols; /* option "--visit-items" */
} DIALOG_STATE;
extern DIALOG_STATE dialog_state;
@ -485,14 +515,33 @@ typedef struct {
char *help_file; /* option "--hfile" */
bool in_helpfile; /* flag to prevent recursion in --hfile */
bool no_nl_expand; /* option "--no-nl-expand" */
/* 1.1-20120701 */
int default_button; /* option "--default-button" (exit code) */
/* 1.1-20121218 */
bool no_tags; /* option "--no-tags" */
bool no_items; /* option "--no-items" */
/* 1.2-20130315 */
bool last_key; /* option "--last-key" */
} DIALOG_VARS;
#define USE_ITEM_HELP(s) (dialog_vars.item_help && (s) != 0)
#define CHECKBOX_TAGS (dialog_vars.item_help ? 4 : 3)
#define MENUBOX_TAGS (dialog_vars.item_help ? 3 : 2)
#define FORMBOX_TAGS (dialog_vars.item_help ? 9 : 8)
#define MIXEDFORM_TAGS (FORMBOX_TAGS + 1)
/*
* Some settings change the number of data items per row which dialog reads
* from a script.
*/
#define DLG__NO_ITEMS (dialog_vars.no_items ? 0 : 1)
#define DLG__ITEM_HELP (dialog_vars.item_help ? 1 : 0)
/*
* These are the total number of data items per row used for each widget type.
*/
#define CHECKBOX_TAGS (2 + DLG__ITEM_HELP + DLG__NO_ITEMS)
#define MENUBOX_TAGS (1 + DLG__ITEM_HELP + DLG__NO_ITEMS)
#define FORMBOX_TAGS (8 + DLG__ITEM_HELP)
#define MIXEDFORM_TAGS (1 + FORMBOX_TAGS)
#define MIXEDGAUGE_TAGS 2
#define TREEVIEW_TAGS (3 + DLG__ITEM_HELP + DLG__NO_ITEMS)
extern DIALOG_VARS dialog_vars;
@ -532,6 +581,7 @@ extern DIALOG_COLORS dlg_color_table[];
extern const char *dialog_version(void);
/* widgets, each in separate files */
extern int dialog_buildlist(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, char ** /*items*/, int /*order_mode*/);
extern int dialog_calendar(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*day*/, int /*month*/, int /*year*/);
extern int dialog_checklist(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, char ** /*items*/, int /*flag*/);
extern int dialog_dselect(const char * /*title*/, const char * /*path*/, int /*height*/, int /*width*/);
@ -548,9 +598,11 @@ extern int dialog_msgbox(const char * /*title*/, const char * /*cprompt*/, int /
extern int dialog_pause(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*seconds*/);
extern int dialog_prgbox(const char * /*title*/, const char * /*cprompt*/, const char * /*command*/, int /*height*/, int /*width*/, int /*pauseopt*/);
extern int dialog_progressbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/);
extern int dialog_rangebox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/, int /*min_value*/, int /*max_value*/, int /*default_value*/);
extern int dialog_tailbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/, int /*bg_task*/);
extern int dialog_textbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/);
extern int dialog_timebox(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*hour*/, int /*minute*/, int /*second*/);
extern int dialog_treeview(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, char ** /*items*/, int /*flag*/);
extern int dialog_yesno(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/);
/* some widgets have alternate entrypoints, to allow list manipulation */
@ -597,6 +649,9 @@ extern void dlg_draw_arrows2(WINDOW * /*dialog*/, int /*top_arrow*/, int /*botto
extern void dlg_draw_helpline(WINDOW * /*dialog*/, bool /*decorations*/);
extern void dlg_draw_scrollbar(WINDOW * /*dialog*/, long /* first_data */, long /* this_data */, long /* next_data */, long /* total_data */, int /* left */, int /* right */, int /*top*/, int /*bottom*/, chtype /*attr*/, chtype /*borderattr*/);
/* buildlist.c */
extern int dlg_buildlist(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, DIALOG_LISTITEM * /*items*/, const char * /*states*/, int /*order_mode*/, int * /*current_item*/);
/* buttons.c */
extern const char ** dlg_exit_label(void);
extern const char ** dlg_ok_label(void);
@ -623,7 +678,7 @@ extern void dlg_align_columns(char ** /* target */, int /* per_row */, int /* n
extern void dlg_free_columns(char ** /* target */, int /* per_row */, int /* num_rows */);
/* editbox.c */
extern int dlg_editbox(const char */*title*/, char ***/*list*/, int */*rows*/, int /*height*/, int /*width*/);
extern int dlg_editbox(const char * /*title*/, char *** /*list*/, int * /*rows*/, int /*height*/, int /*width*/);
/* formbox.c */
extern int dlg_default_formitem(DIALOG_FORMITEM * /*items*/);
@ -646,16 +701,24 @@ extern int dlg_find_index(const int * /*list*/, int /*limit*/, int /*to_find*/)
extern int dlg_limit_columns(const char * /*string*/, int /*limit*/, int /*offset*/);
extern void dlg_show_string(WINDOW * /*win*/, const char * /*string*/, int /*offset*/, chtype /*attr*/, int /*y_base*/, int /*x_base*/, int /*x_last*/, bool /*hidden*/, bool /*force*/);
/* menubox.c */
extern int dlg_dummy_menutext(DIALOG_LISTITEM * /*items*/, int /*current*/, char * /*newtext*/);
extern int dlg_renamed_menutext(DIALOG_LISTITEM * /*items*/, int /*current*/, char * /*newtext*/);
/* rc.c */
#ifdef HAVE_RC_FILE
extern int dlg_parse_rc(void);
extern void dlg_create_rc(const char * /*filename*/);
#endif
/* treeview.c */
extern int dlg_treeview(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, DIALOG_LISTITEM * /*items*/, const char * /*states*/, int * /*depths*/, int /*flag*/, int * /*current_item*/);
/* ui_getc.c */
extern int dlg_getc(WINDOW * /*win*/, int * /*fkey*/);
extern int dlg_getc_callbacks(int /*ch*/, int /*fkey*/, int * /*result*/);
extern int dlg_last_getc(void);
extern void dlg_add_last_key(int /*mode*/);
extern void dlg_add_callback(DIALOG_CALLBACK * /*p*/);
extern void dlg_add_callback_ref(DIALOG_CALLBACK ** /*p*/, DIALOG_FREEBACK /* cleanup */);
extern void dlg_flush_getc(void);
@ -673,15 +736,17 @@ extern char * dlg_strempty(void);
extern chtype dlg_asciibox(chtype /*ch*/);
extern chtype dlg_boxchar(chtype /*ch*/);
extern chtype dlg_get_attrs(WINDOW * /*win*/);
extern const char * dlg_print_line(WINDOW */*win*/, chtype */*attr*/, const char */*prompt*/, int /*lm*/, int /*rm*/, int */*x*/);
extern const char * dlg_print_line(WINDOW * /*win*/, chtype * /*attr*/, const char * /*prompt*/, int /*lm*/, int /*rm*/, int * /*x*/);
extern int dlg_box_x_ordinate(int /*width*/);
extern int dlg_box_y_ordinate(int /*height*/);
extern int dlg_calc_list_width(int /*item_no*/, DIALOG_LISTITEM * /*items*/);
extern int dlg_calc_listw(int /*item_no*/, char ** /*items*/, int /*group*/);
extern int dlg_check_scrolled(int /* key */, int /* last */, int /* page */, bool */* show */, int */* offset */);
extern int dlg_check_scrolled(int /* key */, int /* last */, int /* page */, bool * /* show */, int * /* offset */);
extern int dlg_count_real_columns(const char * /*text*/);
extern int dlg_default_item(char ** /*items*/, int /*llen*/);
extern int dlg_default_listitem(DIALOG_LISTITEM * /*items*/);
extern int dlg_defaultno_button(void);
extern int dlg_default_button(void);
extern int dlg_max_input(int /*max_len*/);
extern int dlg_print_scrolled(WINDOW * /* win */, const char * /* prompt */, int /* offset */, int /* height */, int /* width */, int /* pauseopt */);
extern void dlg_add_quoted(char * /*string*/);
@ -699,11 +764,14 @@ extern void dlg_ctl_size(int /*height*/, int /*width*/);
extern void dlg_del_window(WINDOW * /*win*/);
extern void dlg_does_output(void);
extern void dlg_draw_bottom_box(WINDOW * /*win*/);
extern void dlg_draw_bottom_box2(WINDOW * /*win*/, chtype /*on_left*/, chtype /*on_right*/, chtype /*on_inside*/);
extern void dlg_draw_box(WINDOW * /*win*/, int /*y*/, int /*x*/, int /*height*/, int /*width*/, chtype /*boxchar*/, chtype /*borderchar*/);
extern void dlg_draw_box2(WINDOW * /*win*/, int /*y*/, int /*x*/, int /*height*/, int /*width*/, chtype /*boxchar*/, chtype /*borderchar*/, chtype /*borderchar2*/);
extern void dlg_draw_title(WINDOW *win, const char *title);
extern void dlg_exit(int /*code*/) GCC_NORETURN;
extern void dlg_item_help(const char * /*txt*/);
extern void dlg_print_autowrap(WINDOW * /*win*/, const char * /*prompt*/, int /*height*/, int /*width*/);
extern void dlg_print_listitem(WINDOW * /*win*/, const char * /*text*/, int /*climit*/, bool /*first*/, int /*selected*/);
extern void dlg_print_size(int /*height*/, int /*width*/);
extern void dlg_print_text(WINDOW * /*win*/, const char * /*txt*/, int /*len*/, chtype * /*attr*/);
extern void dlg_put_backtitle(void);
@ -715,11 +783,7 @@ extern void dlg_trim_string(char * /*src*/);
extern void end_dialog(void);
extern void init_dialog(FILE * /*input*/, FILE * /*output*/);
extern void dlg_exiterr(const char *, ...) GCC_NORETURN
#if defined(__GNUC__) && !defined(printf)
__attribute__((format(printf,1,2)))
#endif
;
extern void dlg_exiterr(const char *, ...) GCC_NORETURN GCC_PRINTFLIKE(1,2);
#ifdef HAVE_COLOR
extern chtype dlg_color_pair(int /*foreground*/, int /*background*/);
@ -736,11 +800,7 @@ extern int dlg_strcmp(const char * /*a*/, const char * /*b*/);
#ifdef HAVE_DLG_TRACE
#define DLG_TRACE(params) dlg_trace_msg params
extern void dlg_trace_msg(const char *fmt, ...)
#ifdef GCC_PRINTF
__attribute__((format(printf,1,2)))
#endif
;
extern void dlg_trace_msg(const char *fmt, ...) GCC_PRINTFLIKE(1,2);
extern void dlg_trace_win(WINDOW * /*win*/);
extern void dlg_trace_chr(int /*ch*/, int /*fkey*/);
extern void dlg_trace(const char * /*fname*/);
@ -779,6 +839,7 @@ extern mseRegion * dlg_mouse_mkregion (int /*y*/, int /*x*/, int /*height*/, int
extern void dlg_mouse_free_regions (void);
extern void dlg_mouse_mkbigregion (int /*y*/, int /*x*/, int /*height*/, int /*width*/, int /*code*/, int /*step_x*/, int /*step_y*/, int /*mode*/);
extern void dlg_mouse_setbase (int /*x*/, int /*y*/);
extern void dlg_mouse_setcode (int /*code*/);
#define USE_MOUSE 1
@ -790,6 +851,7 @@ extern void dlg_mouse_setbase (int /*x*/, int /*y*/);
#define dlg_mouse_mkregion(y, x, height, width, code) /*nothing*/
#define dlg_mouse_mkbigregion(y, x, height, width, code, step_x, step_y, mode) /*nothing*/
#define dlg_mouse_setbase(x, y) /*nothing*/
#define dlg_mouse_setcode(c) /*nothing*/
#define USE_MOUSE 0

View File

@ -1,5 +1,5 @@
/*
* $Id: dlg_colors.h,v 1.16 2011/01/17 00:20:32 tom Exp $
* $Id: dlg_colors.h,v 1.17 2011/10/14 21:19:59 tom Exp $
*
* colors.h -- color attribute definitions
*
@ -56,6 +56,10 @@
#define DLGC_BG_BORDER COLOR_WHITE
#define DLGC_HL_BORDER TRUE
#define DLGC_FG_BORDER2 DLGC_FG_DIALOG
#define DLGC_BG_BORDER2 DLGC_BG_DIALOG
#define DLGC_HL_BORDER2 DLGC_HL_DIALOG
#define DLGC_FG_BUTTON_ACTIVE COLOR_WHITE
#define DLGC_BG_BUTTON_ACTIVE COLOR_BLUE
#define DLGC_HL_BUTTON_ACTIVE TRUE
@ -92,6 +96,10 @@
#define DLGC_BG_INPUTBOX_BORDER COLOR_WHITE
#define DLGC_HL_INPUTBOX_BORDER FALSE
#define DLGC_FG_INPUTBOX_BORDER2 DLGC_FG_INPUTBOX
#define DLGC_BG_INPUTBOX_BORDER2 DLGC_BG_INPUTBOX
#define DLGC_HL_INPUTBOX_BORDER2 DLGC_HL_INPUTBOX
#define DLGC_FG_SEARCHBOX COLOR_BLACK
#define DLGC_BG_SEARCHBOX COLOR_WHITE
#define DLGC_HL_SEARCHBOX FALSE
@ -104,6 +112,10 @@
#define DLGC_BG_SEARCHBOX_BORDER COLOR_WHITE
#define DLGC_HL_SEARCHBOX_BORDER TRUE
#define DLGC_FG_SEARCHBOX_BORDER2 DLGC_FG_SEARCHBOX
#define DLGC_BG_SEARCHBOX_BORDER2 DLGC_BG_SEARCHBOX
#define DLGC_HL_SEARCHBOX_BORDER2 DLGC_HL_SEARCHBOX
#define DLGC_FG_POSITION_INDICATOR COLOR_BLUE
#define DLGC_BG_POSITION_INDICATOR COLOR_WHITE
#define DLGC_HL_POSITION_INDICATOR TRUE
@ -116,6 +128,10 @@
#define DLGC_BG_MENUBOX_BORDER COLOR_WHITE
#define DLGC_HL_MENUBOX_BORDER TRUE
#define DLGC_FG_MENUBOX_BORDER2 DLGC_FG_MENUBOX
#define DLGC_BG_MENUBOX_BORDER2 DLGC_BG_MENUBOX
#define DLGC_HL_MENUBOX_BORDER2 DLGC_HL_MENUBOX
#define DLGC_FG_ITEM COLOR_BLACK
#define DLGC_BG_ITEM COLOR_WHITE
#define DLGC_HL_ITEM FALSE

View File

@ -1,9 +1,9 @@
/*
* $Id: dlg_keys.c,v 1.26 2009/02/22 16:19:51 tom Exp $
* $Id: dlg_keys.c,v 1.34 2011/10/14 00:41:08 tom Exp $
*
* dlg_keys.c -- runtime binding support for dialog
* dlg_keys.c -- runtime binding support for dialog
*
* Copyright 2006-2007,2009 Thomas E. Dickey
* Copyright 2006-2009,2011 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -34,6 +34,7 @@ LIST_BINDINGS {
DLG_KEYS_BINDING *binding; /* list of bindings */
};
#define WILDNAME "*"
static LIST_BINDINGS *all_bindings;
static const DLG_KEYS_BINDING end_keys_binding = END_KEYS_BINDING;
@ -61,6 +62,17 @@ dlg_register_window(WINDOW *win, const char *name, DLG_KEYS_BINDING * binding)
else
all_bindings = p;
}
#if defined(HAVE_DLG_TRACE) && defined(HAVE_RC_FILE)
/*
* Trace the binding information assigned to this window. For most widgets
* there is only one binding table. forms have two, so the trace will be
* longer. Since compiled-in bindings are only visible when the widget is
* registered, there is no other way to see what bindings are available,
* than by running dialog and tracing it.
*/
dlg_trace_msg("# dlg_register_window %s\n", name);
dlg_dump_window_keys(dialog_state.trace_output, win);
#endif
}
/*
@ -189,7 +201,7 @@ int
dlg_lookup_key(WINDOW *win, int curses_key, int *fkey)
{
LIST_BINDINGS *p;
int n;
DLG_KEYS_BINDING *q;
/*
* Ignore mouse clicks, since they are already encoded properly.
@ -208,19 +220,28 @@ dlg_lookup_key(WINDOW *win, int curses_key, int *fkey)
} else
#endif
if (*fkey == 0 || curses_key < KEY_MAX) {
const char *name = WILDNAME;
if (win != 0) {
for (p = all_bindings; p != 0; p = p->link) {
if (p->win == win) {
name = p->name;
break;
}
}
}
for (p = all_bindings; p != 0; p = p->link) {
if (p->win == win || p->win == 0) {
if (p->win == win || (p->win == 0 && !strcmp(p->name, name))) {
int function_key = (*fkey != 0);
for (n = 0; p->binding[n].is_function_key >= 0; ++n) {
for (q = p->binding; q->is_function_key >= 0; ++q) {
if (p->buttons
&& !function_key
&& p->binding[n].curses_key == (int) dlg_toupper(curses_key)) {
&& q->curses_key == (int) dlg_toupper(curses_key)) {
*fkey = 0;
return p->binding[n].dialog_key;
return q->dialog_key;
}
if (p->binding[n].curses_key == curses_key
&& p->binding[n].is_function_key == function_key) {
*fkey = p->binding[n].dialog_key;
if (q->curses_key == curses_key
&& q->is_function_key == function_key) {
*fkey = q->dialog_key;
return *fkey;
}
}
@ -295,10 +316,18 @@ typedef struct {
int code;
} CODENAME;
#define ASCII_NAME(name,code) { #name, code }
#define CURSES_NAME(upper) { #upper, KEY_ ## upper }
#define COUNT_CURSES sizeof(curses_names)/sizeof(curses_names[0])
static const CODENAME curses_names[] =
{
ASCII_NAME(ESC, '\033'),
ASCII_NAME(CR, '\r'),
ASCII_NAME(LF, '\n'),
ASCII_NAME(FF, '\f'),
ASCII_NAME(TAB, '\t'),
ASCII_NAME(DEL, '\177'),
CURSES_NAME(DOWN),
CURSES_NAME(UP),
CURSES_NAME(LEFT),
@ -408,6 +437,10 @@ static const CODENAME dialog_names[] =
DIALOG_NAME(FIELD_LAST),
DIALOG_NAME(FIELD_NEXT),
DIALOG_NAME(FIELD_PREV),
DIALOG_NAME(FORM_FIRST),
DIALOG_NAME(FORM_LAST),
DIALOG_NAME(FORM_NEXT),
DIALOG_NAME(FORM_PREV),
DIALOG_NAME(GRID_UP),
DIALOG_NAME(GRID_DOWN),
DIALOG_NAME(GRID_LEFT),
@ -418,7 +451,9 @@ static const CODENAME dialog_names[] =
DIALOG_NAME(ENTER),
DIALOG_NAME(BEGIN),
DIALOG_NAME(FINAL),
DIALOG_NAME(SELECT)
DIALOG_NAME(SELECT),
DIALOG_NAME(HELPFILE),
DIALOG_NAME(TRACE)
};
static char *
@ -472,9 +507,9 @@ compare_bindings(LIST_BINDINGS * a, LIST_BINDINGS * b)
if (a->win == b->win) {
if (!strcmp(a->name, b->name)) {
result = a->binding[0].curses_key - b->binding[0].curses_key;
} else if (!strcmp(b->name, "*")) {
} else if (!strcmp(b->name, WILDNAME)) {
result = -1;
} else if (!strcmp(a->name, "*")) {
} else if (!strcmp(a->name, WILDNAME)) {
result = 1;
} else {
result = dlg_strcmp(a->name, b->name);
@ -572,6 +607,7 @@ dlg_parse_bindkey(char *params)
p = skip_black(p);
if (p != widget && *p != '\0') {
*p++ = '\0';
p = skip_white(p);
q = p;
while (*p != '\0' && curses_key < 0) {
if (escaped) {
@ -613,7 +649,7 @@ dlg_parse_bindkey(char *params)
for (xx = 0; xx < COUNT_CURSES; ++xx) {
if (!dlg_strcmp(curses_names[xx].name, q)) {
curses_key = curses_names[xx].code;
is_function = TRUE;
is_function = (curses_key >= KEY_MIN);
break;
}
}
@ -700,30 +736,53 @@ dump_one_binding(FILE *fp, const char *widget, DLG_KEYS_BINDING * binding)
fputc('\n', fp);
}
/*
* Dump bindings for the given window. If it is a null, then this dumps the
* initial bindings which were loaded from the rc-file that are used as
* overall defaults.
*/
void
dlg_dump_keys(FILE *fp)
dlg_dump_window_keys(FILE *fp, WINDOW *win)
{
LIST_BINDINGS *p;
const char *last = "";
unsigned n;
unsigned count = 0;
if (fp != 0) {
LIST_BINDINGS *p;
DLG_KEYS_BINDING *q;
const char *last = "";
for (p = all_bindings; p != 0; p = p->link) {
if (p->win == 0) {
++count;
}
}
if (count != 0) {
for (p = all_bindings, n = 0; p != 0; p = p->link) {
if (p->win == 0) {
for (p = all_bindings; p != 0; p = p->link) {
if (p->win == win) {
if (dlg_strcmp(last, p->name)) {
fprintf(fp, "\n# key bindings for %s widgets\n",
!strcmp(p->name, "*") ? "all" : p->name);
!strcmp(p->name, WILDNAME) ? "all" : p->name);
last = p->name;
}
dump_one_binding(fp, p->name, p->binding);
for (q = p->binding; q->is_function_key >= 0; ++q) {
dump_one_binding(fp, p->name, q);
}
}
}
}
}
/*
* Dump all of the bindings which are not specific to a given widget, i.e.,
* the "win" member is null.
*/
void
dlg_dump_keys(FILE *fp)
{
if (fp != 0) {
LIST_BINDINGS *p;
unsigned count = 0;
for (p = all_bindings; p != 0; p = p->link) {
if (p->win == 0) {
++count;
}
}
if (count != 0) {
dlg_dump_window_keys(fp, 0);
}
}
}
#endif /* HAVE_RC_FILE */

View File

@ -1,9 +1,9 @@
/*
* $Id: dlg_keys.h,v 1.26 2011/06/21 22:09:22 tom Exp $
* $Id: dlg_keys.h,v 1.32 2012/12/21 21:54:30 tom Exp $
*
* dlg_keys.h -- runtime binding support for dialog
*
* Copyright 2005-2010,2011 Thomas E. Dickey
* Copyright 2005-2011,2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -23,6 +23,7 @@
#ifndef DLG_KEYS_H_included
#define DLG_KEYS_H_included 1
/* *INDENT-OFF* */
#include <dialog.h>
@ -31,7 +32,7 @@
#define dlg_toupper(ch) towupper((wint_t)ch)
#define dlg_isupper(ch) iswupper((wint_t)ch)
#else
#define dlg_toupper(ch) toupper(ch)
#define dlg_toupper(ch) (((ch) > 0 && (ch) <= 255) ? toupper(ch) : (ch))
#define dlg_isupper(ch) (isalpha(ch) && isupper(ch))
#endif
@ -45,7 +46,7 @@ typedef struct {
int dialog_key;
} DLG_KEYS_BINDING;
#define DLG_KEYS_DATA(dialog, curses) { curses >= KEY_MIN, curses, dialog }
#define DLG_KEYS_DATA(dialog, curses) { (curses) >= KEY_MIN, curses, dialog }
#define END_KEYS_BINDING { -1, 0, 0 }
@ -75,6 +76,11 @@ typedef enum {
DLGK_FIELD_LAST,
DLGK_FIELD_NEXT,
DLGK_FIELD_PREV,
/* moving from form-field to form-field (or buttons) */
DLGK_FORM_FIRST,
DLGK_FORM_LAST,
DLGK_FORM_NEXT,
DLGK_FORM_PREV,
/* moving within a grid */
DLGK_GRID_UP,
DLGK_GRID_DOWN,
@ -118,23 +124,35 @@ typedef enum {
DLG_KEYS_DATA( DLGK_GRID_LEFT, KEY_LEFT ), \
DLG_KEYS_DATA( DLGK_GRID_RIGHT, KEY_RIGHT )
#define SCROLL_FKEY_BINDINGS \
DLG_KEYS_DATA( DLGK_GRID_DOWN, KEY_DOWN ), \
DLG_KEYS_DATA( DLGK_GRID_UP, KEY_UP ), \
DLG_KEYS_DATA( DLGK_PAGE_FIRST, KEY_HOME ), \
DLG_KEYS_DATA( DLGK_PAGE_LAST, KEY_END ), \
DLG_KEYS_DATA( DLGK_PAGE_NEXT, KEY_NPAGE ), \
DLG_KEYS_DATA( DLGK_PAGE_PREV, KEY_PPAGE )
#define SCROLLKEY_BINDINGS \
SCROLL_FKEY_BINDINGS, \
DLG_KEYS_DATA( DLGK_GRID_DOWN, 'J' ), \
DLG_KEYS_DATA( DLGK_GRID_DOWN, 'j' ), \
DLG_KEYS_DATA( DLGK_GRID_DOWN, KEY_DOWN ), \
DLG_KEYS_DATA( DLGK_GRID_UP, 'K' ), \
DLG_KEYS_DATA( DLGK_GRID_UP, 'k' ), \
DLG_KEYS_DATA( DLGK_GRID_UP, KEY_UP ), \
DLG_KEYS_DATA( DLGK_PAGE_FIRST, 'g' ), \
DLG_KEYS_DATA( DLGK_PAGE_FIRST, KEY_HOME ), \
DLG_KEYS_DATA( DLGK_PAGE_LAST, 'G' ), \
DLG_KEYS_DATA( DLGK_PAGE_LAST, KEY_END ), \
DLG_KEYS_DATA( DLGK_PAGE_NEXT, 'F' ), \
DLG_KEYS_DATA( DLGK_PAGE_NEXT, 'f' ), \
DLG_KEYS_DATA( DLGK_PAGE_NEXT, KEY_NPAGE ), \
DLG_KEYS_DATA( DLGK_PAGE_PREV, 'B' ), \
DLG_KEYS_DATA( DLGK_PAGE_PREV, 'b' ), \
DLG_KEYS_DATA( DLGK_PAGE_PREV, KEY_PPAGE )
DLG_KEYS_DATA( DLGK_PAGE_PREV, 'b' )
#define TRAVERSE_BINDINGS \
DLG_KEYS_DATA( DLGK_ENTER, ' ' ), \
DLG_KEYS_DATA( DLGK_FIELD_NEXT, KEY_DOWN ), \
DLG_KEYS_DATA( DLGK_FIELD_NEXT, KEY_RIGHT ), \
DLG_KEYS_DATA( DLGK_FIELD_NEXT, TAB ), \
DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_UP ), \
DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_BTAB ), \
DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_LEFT )
extern int dlg_lookup_key(WINDOW * /*win*/, int /*curses_key*/, int * /*dialog_key*/);
extern int dlg_result_key(int /*dialog_key*/, int /*fkey*/, int * /*resultp*/);
@ -145,10 +163,12 @@ extern void dlg_unregister_window(WINDOW * /*win*/);
#ifdef HAVE_RC_FILE
extern int dlg_parse_bindkey(char * /*params*/);
extern void dlg_dump_keys(FILE * /*fp*/);
extern void dlg_dump_window_keys(FILE * /*fp*/, WINDOW * /*win*/);
#endif
#ifdef __cplusplus
}
#endif
/* *INDENT-ON* */
#endif /* DLG_KEYS_H_included */

View File

@ -1,9 +1,9 @@
/*
* $Id: editbox.c,v 1.55 2011/06/21 00:10:46 tom Exp $
* $Id: editbox.c,v 1.62 2013/03/17 15:03:41 tom Exp $
*
* editbox.c -- implements the edit box
*
* Copyright 2007-2010,2011 Thomas E. Dickey
* Copyright 2007-2012,2013 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -43,9 +43,10 @@ grow_list(char ***list, int *have, int want)
(*list) = dlg_realloc(char *, need, *list);
if ((*list) == 0) {
fail_list();
}
while (++last < need) {
(*list)[last] = 0;
} else {
while (++last < need) {
(*list)[last] = 0;
}
}
}
}
@ -68,45 +69,47 @@ load_list(const char *file, char ***list, int *rows)
dlg_exiterr("Not a file: %s", file);
size = (size_t) sb.st_size;
if ((blob = dlg_malloc(char, size + 1)) == 0)
fail_list();
blob[size] = '\0';
if ((blob = dlg_malloc(char, size + 1)) == 0) {
fail_list();
} else {
blob[size] = '\0';
if ((fp = fopen(file, "r")) == 0)
dlg_exiterr("Cannot open: %s", file);
size = fread(blob, sizeof(char), size, fp);
fclose(fp);
if ((fp = fopen(file, "r")) == 0)
dlg_exiterr("Cannot open: %s", file);
size = fread(blob, sizeof(char), size, fp);
fclose(fp);
for (pass = 0; pass < 2; ++pass) {
int first = TRUE;
need = 0;
for (n = 0; n < size; ++n) {
if (first && pass) {
(*list)[need] = blob + n;
first = FALSE;
}
if (blob[n] == '\n') {
first = TRUE;
++need;
if (pass)
blob[n] = '\0';
}
}
if (pass) {
if (need == 0) {
(*list)[0] = dlg_strclone("");
(*list)[1] = 0;
} else {
for (n = 0; n < need; ++n) {
(*list)[n] = dlg_strclone((*list)[n]);
for (pass = 0; pass < 2; ++pass) {
int first = TRUE;
need = 0;
for (n = 0; n < size; ++n) {
if (first && pass) {
(*list)[need] = blob + n;
first = FALSE;
}
if (blob[n] == '\n') {
first = TRUE;
++need;
if (pass)
blob[n] = '\0';
}
(*list)[need] = 0;
}
} else {
grow_list(list, rows, (int) need + 1);
if (pass) {
if (need == 0) {
(*list)[0] = dlg_strclone("");
(*list)[1] = 0;
} else {
for (n = 0; n < need; ++n) {
(*list)[n] = dlg_strclone((*list)[n]);
}
(*list)[need] = 0;
}
} else {
grow_list(list, rows, (int) need + 1);
}
}
free(blob);
}
free(blob);
}
static void
@ -344,6 +347,7 @@ dlg_editbox(const char *title,
size_t max_len = (size_t) dlg_max_input(widest_line(*list));
char *input, *buffer;
bool show_all, show_one, was_mouse;
bool first_trace = TRUE;
WINDOW *dialog;
WINDOW *editing;
DIALOG_VARS save_vars;
@ -364,8 +368,8 @@ dlg_editbox(const char *title,
retry:
#endif
show_buttons = TRUE;
state = dialog_vars.defaultno ? dlg_defaultno_button() : sTEXT;
key = fkey = 0;
state = dialog_vars.default_button >= 0 ? dlg_default_button() : sTEXT;
fkey = 0;
dlg_button_layout(buttons, &mincols);
dlg_auto_size(title, "", &height, &width, 3 * LINES / 4, mincols);
@ -381,11 +385,11 @@ dlg_editbox(const char *title,
dlg_mouse_setbase(x, y);
dlg_draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
dlg_draw_bottom_box(dialog);
dlg_draw_box2(dialog, 0, 0, height, width, dialog_attr, border_attr, border2_attr);
dlg_draw_bottom_box2(dialog, border_attr, border2_attr, dialog_attr);
dlg_draw_title(dialog, title);
wattrset(dialog, dialog_attr);
(void) wattrset(dialog, dialog_attr);
/* Draw the editing field in a box */
box_y = MARGIN + 0;
@ -398,7 +402,7 @@ dlg_editbox(const char *title,
box_x,
box_height,
box_width,
border_attr, dialog_attr);
border_attr, border2_attr);
dlg_mouse_mkbigregion(box_y + MARGIN,
box_x + MARGIN,
box_height - (2 * MARGIN),
@ -409,7 +413,7 @@ dlg_editbox(const char *title,
box_width - (2 * MARGIN),
getbegy(dialog) + box_y + 1,
getbegx(dialog) + box_x + 1);
dlg_register_window(editing, "editbox", binding2);
dlg_register_window(editing, "editbox2", binding2);
show_all = TRUE;
show_one = FALSE;
@ -444,7 +448,7 @@ dlg_editbox(const char *title,
box_x + getmaxx(editing),
box_y + 0,
box_y + getmaxy(editing) + 1,
dialog_attr,
border2_attr,
border_attr);
wmove(editing, y, x);
show_one = FALSE;
@ -476,6 +480,11 @@ dlg_editbox(const char *title,
}
}
if (first_trace) {
first_trace = FALSE;
dlg_trace_win(dialog);
}
key = dlg_mouse_wgetch((state == sTEXT) ? editing : dialog, &fkey);
if (key == ERR) {
result = DLG_EXIT_ERROR;
@ -701,6 +710,7 @@ dlg_editbox(const char *title,
dlg_add_result((*list)[n]);
dlg_add_separator();
}
dlg_add_last_key(-1);
}
free(buffer);
dlg_restore_vars(&save_vars);

View File

@ -1,9 +1,9 @@
/*
* $Id: formbox.c,v 1.73 2011/06/29 09:48:08 tom Exp $
* $Id: formbox.c,v 1.85 2013/03/17 15:03:41 tom Exp $
*
* formbox.c -- implements the form (i.e, some pairs label/editbox)
*
* Copyright 2003-2010,2011 Thomas E. Dickey
* Copyright 2003-2012,2013 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -188,6 +188,34 @@ form_limit(DIALOG_FORMITEM item[])
return limit;
}
static int
is_first_field(DIALOG_FORMITEM item[], int choice)
{
int count = 0;
while (choice >= 0) {
if (item[choice].text_flen > 0) {
++count;
}
--choice;
}
return (count == 1);
}
static int
is_last_field(DIALOG_FORMITEM item[], int choice, int item_no)
{
int count = 0;
while (choice < item_no) {
if (item[choice].text_flen > 0) {
++count;
}
++choice;
}
return (count == 1);
}
/*
* Tab to the next field.
*/
@ -259,6 +287,7 @@ tab_next(WINDOW *win,
static bool
scroll_next(WINDOW *win, DIALOG_FORMITEM item[], int stepsize, int *choice, int *scrollamt)
{
bool result = TRUE;
int old_choice = *choice;
int old_scroll = *scrollamt;
int old_row = MIN(item[old_choice].text_y, item[old_choice].name_y);
@ -270,34 +299,40 @@ scroll_next(WINDOW *win, DIALOG_FORMITEM item[], int stepsize, int *choice, int
target = old_scroll;
else
target = old_scroll + stepsize;
if (target < 0)
target = 0;
if (target < 0) {
result = FALSE;
}
} else {
int limit = form_limit(item);
if (target > limit)
target = limit;
}
for (n = 0; item[n].name != 0; ++n) {
if (item[n].text_flen > 0) {
int new_row = MIN(item[n].text_y, item[n].name_y);
if (abs(new_row - target) < abs(old_row - target)) {
old_row = new_row;
*choice = n;
}
if (target > form_limit(item)) {
result = FALSE;
}
}
if (old_choice != *choice)
print_item(win, item + old_choice, *scrollamt, FALSE);
if (result) {
for (n = 0; item[n].name != 0; ++n) {
if (item[n].text_flen > 0) {
int new_row = MIN(item[n].text_y, item[n].name_y);
if (abs(new_row - target) < abs(old_row - target)) {
old_row = new_row;
*choice = n;
}
}
}
*scrollamt = *choice;
if (*scrollamt != old_scroll) {
scrollok(win, TRUE);
wscrl(win, *scrollamt - old_scroll);
scrollok(win, FALSE);
if (old_choice != *choice)
print_item(win, item + old_choice, *scrollamt, FALSE);
*scrollamt = *choice;
if (*scrollamt != old_scroll) {
scrollok(win, TRUE);
wscrl(win, *scrollamt - old_scroll);
scrollok(win, FALSE);
}
result = (old_choice != *choice) || (old_scroll != *scrollamt);
}
return (old_choice != *choice) || (old_scroll != *scrollamt);
if (!result)
beep();
return result;
}
/*
@ -419,7 +454,7 @@ prev_valid_buttonindex(int state, int extra, bool non_editable)
DLG_KEYS_DATA( DLGK_PAGE_NEXT, KEY_NPAGE ), \
DLG_KEYS_DATA( DLGK_PAGE_PREV, KEY_PPAGE )
/*
* Display a form for fulfill a number of fields
* Display a form for entering a number of fields
*/
int
dlg_form(const char *title,
@ -454,8 +489,9 @@ dlg_form(const char *title,
int form_width;
int first = TRUE;
int first_trace = TRUE;
int chr_offset = 0;
int state = dialog_vars.defaultno ? dlg_defaultno_button() : sTEXT;
int state = dialog_vars.default_button >= 0 ? dlg_default_button() : sTEXT;
int x, y, cur_x, cur_y, box_x, box_y;
int code;
int key = 0;
@ -510,30 +546,31 @@ dlg_form(const char *title,
dialog = dlg_new_window(height, width, y, x);
dlg_register_window(dialog, "formbox", binding);
dlg_register_window(dialog, "formfield", binding2);
dlg_register_buttons(dialog, "formbox", buttons);
dlg_mouse_setbase(x, y);
dlg_draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
dlg_draw_bottom_box(dialog);
dlg_draw_box2(dialog, 0, 0, height, width, dialog_attr, border_attr, border2_attr);
dlg_draw_bottom_box2(dialog, border_attr, border2_attr, dialog_attr);
dlg_draw_title(dialog, title);
wattrset(dialog, dialog_attr);
(void) wattrset(dialog, dialog_attr);
dlg_print_autowrap(dialog, prompt, height, width);
form_width = width - 6;
getyx(dialog, cur_y, cur_x);
(void) cur_x;
box_y = cur_y + 1;
box_x = (width - form_width) / 2 - 1;
/* create new window for the form */
form = dlg_sub_window(dialog, form_height, form_width, y + box_y + 1,
x + box_x + 1);
dlg_register_window(form, "formfield", binding2);
/* draw a box around the form items */
dlg_draw_box(dialog, box_y, box_x, form_height + 2, form_width + 2,
menubox_border_attr, menubox_attr);
menubox_border_attr, menubox_border2_attr);
/* register the new window, along with its borders */
dlg_mouse_mkbigregion(getbegy(form) - getbegy(dialog),
@ -564,7 +601,7 @@ dlg_form(const char *title,
box_x + form_width,
box_y,
box_y + form_height + 1,
menubox_attr,
menubox_border2_attr,
menubox_border_attr);
scroll_changed = FALSE;
}
@ -579,6 +616,11 @@ dlg_form(const char *title,
show_buttons = FALSE;
}
if (first_trace) {
first_trace = FALSE;
dlg_trace_win(dialog);
}
if (field_changed || state == sTEXT) {
if (field_changed)
chr_offset = 0;
@ -591,10 +633,12 @@ dlg_form(const char *title,
current->text_x,
current->text_len,
is_hidden(current), first);
wsyncup(form);
wcursyncup(form);
field_changed = FALSE;
}
key = dlg_mouse_wgetch(dialog, &fkey);
key = dlg_mouse_wgetch((state == sTEXT) ? form : dialog, &fkey);
if (dlg_result_key(key, fkey, &result))
break;
@ -653,6 +697,25 @@ dlg_form(const char *title,
continue;
}
case DLGK_FORM_PREV:
if (state == sTEXT && !is_first_field(items, choice)) {
do_tab = TRUE;
move_by = -1;
break;
} else {
int old_state = state;
state = prev_valid_buttonindex(state, sTEXT, non_editable);
show_buttons = TRUE;
if (old_state >= 0 && state == sTEXT) {
new_choice = item_no - 1;
if (choice != new_choice) {
print_item(form, items + choice, scrollamt, FALSE);
choice = new_choice;
}
}
continue;
}
case DLGK_FIELD_PREV:
state = prev_valid_buttonindex(state, sTEXT, non_editable);
show_buttons = TRUE;
@ -679,6 +742,21 @@ dlg_form(const char *title,
continue;
}
case DLGK_FORM_NEXT:
if (state == sTEXT && !is_last_field(items, choice, item_no)) {
do_tab = TRUE;
move_by = 1;
break;
} else {
state = next_valid_buttonindex(state, sTEXT, non_editable);
show_buttons = TRUE;
if (state == sTEXT && choice) {
print_item(form, items + choice, scrollamt, FALSE);
choice = 0;
}
continue;
}
#ifdef KEY_RESIZE
case KEY_RESIZE:
/* reset data */
@ -895,6 +973,7 @@ dialog_form(const char *title,
dlg_add_separator();
}
}
dlg_add_last_key(-1);
}
dlg_free_formitems(listitems);

View File

@ -1,9 +1,9 @@
/*
* $Id: fselect.c,v 1.78 2011/06/29 09:48:21 tom Exp $
* $Id: fselect.c,v 1.93 2012/12/30 20:52:25 tom Exp $
*
* fselect.c -- implements the file-selector box
*
* Copyright 2000-2010,2011 Thomas E. Dickey
* Copyright 2000-2011,2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -230,11 +230,11 @@ display_list(LIST * list)
break;
(void) wmove(list->win, y, 0);
if (n == list->choice)
wattrset(list->win, item_selected_attr);
(void) wattrset(list->win, item_selected_attr);
(void) waddstr(list->win, list->data[n]);
wattrset(list->win, item_attr);
(void) wattrset(list->win, item_attr);
}
wattrset(list->win, item_attr);
(void) wattrset(list->win, item_attr);
getparyx(list->win, y, x);
@ -249,7 +249,7 @@ display_list(LIST * list)
x + getmaxx(list->win),
top,
bottom,
menubox_attr,
menubox_border2_attr,
menubox_border_attr);
(void) wmove(list->win, list->choice - list->offset, 0);
@ -270,18 +270,20 @@ fix_arrows(LIST * list)
int x;
int y;
int top;
int right;
int bottom;
if (list->win != 0) {
getparyx(list->win, y, x);
top = y - 1;
right = getmaxx(list->win);
bottom = y + getmaxy(list->win);
mouse_mkbutton(top, x, 6,
mouse_mkbutton(top, x, right,
((list->mousex == MOUSE_D)
? KEY_PREVIOUS
: KEY_PPAGE));
mouse_mkbutton(bottom, x, 6,
mouse_mkbutton(bottom, x, right,
((list->mousex == MOUSE_D)
? KEY_NEXT
: KEY_NPAGE));
@ -365,7 +367,7 @@ match(char *name, LIST * d_list, LIST * f_list, MATCH * match_list)
matches[data_len++] = f_list->data[i];
}
}
matches = dlg_realloc(char *, data_len, matches);
matches = dlg_realloc(char *, data_len + 1, matches);
match_list->data = matches;
match_list->length = (int) data_len;
}
@ -429,6 +431,8 @@ complete(char *name, LIST * d_list, LIST * f_list, char **buff_ptr)
static bool
fill_lists(char *current, char *input, LIST * d_list, LIST * f_list, int keep)
{
bool result = TRUE;
bool rescan = FALSE;
DIR *dp;
DIRENT *de;
struct stat sb;
@ -441,51 +445,69 @@ fill_lists(char *current, char *input, LIST * d_list, LIST * f_list, int keep)
if (current[n] != input[n])
break;
}
if (current[n] == input[n])
return FALSE;
if (strchr(current + n, '/') == 0
&& strchr(input + n, '/') == 0) {
return show_both_lists(input, d_list, f_list, keep);
}
strcpy(current, input);
/* refill the lists */
free_list(d_list, TRUE);
free_list(f_list, TRUE);
strcpy(path, current);
if ((leaf = strrchr(path, '/')) != 0) {
*++leaf = 0;
if (current[n] == input[n]) {
result = FALSE;
rescan = (n == 0 && d_list->length == 0);
} else if (strchr(current + n, '/') == 0
&& strchr(input + n, '/') == 0) {
result = show_both_lists(input, d_list, f_list, keep);
} else {
strcpy(path, "./");
leaf = path + strlen(path);
rescan = TRUE;
}
if ((dp = opendir(path)) != 0) {
while ((de = readdir(dp)) != 0) {
strncpy(leaf, de->d_name, NAMLEN(de))[NAMLEN(de)] = 0;
if (stat(path, &sb) == 0) {
if ((sb.st_mode & S_IFMT) == S_IFDIR)
add_to_list(d_list, leaf);
else if (f_list->win)
add_to_list(f_list, leaf);
if (rescan) {
size_t have = strlen(input);
if (have > MAX_LEN)
have = MAX_LEN;
memcpy(current, input, have);
current[have] = '\0';
/* refill the lists */
free_list(d_list, TRUE);
free_list(f_list, TRUE);
memcpy(path, current, have);
path[have] = '\0';
if ((leaf = strrchr(path, '/')) != 0) {
*++leaf = 0;
} else {
strcpy(path, "./");
leaf = path + strlen(path);
}
dlg_trace_msg("opendir '%s'\n", path);
if ((dp = opendir(path)) != 0) {
while ((de = readdir(dp)) != 0) {
strncpy(leaf, de->d_name, NAMLEN(de))[NAMLEN(de)] = 0;
if (stat(path, &sb) == 0) {
if ((sb.st_mode & S_IFMT) == S_IFDIR)
add_to_list(d_list, leaf);
else if (f_list->win)
add_to_list(f_list, leaf);
}
}
(void) closedir(dp);
/* sort the lists */
if (d_list->data != 0 && d_list->length > 1) {
qsort(d_list->data,
(size_t) d_list->length,
sizeof(d_list->data[0]),
compar);
}
if (f_list->data != 0 && f_list->length > 1) {
qsort(f_list->data,
(size_t) f_list->length,
sizeof(f_list->data[0]),
compar);
}
}
(void) closedir(dp);
/* sort the lists */
qsort(d_list->data,
(size_t) d_list->length,
sizeof(d_list->data[0]),
compar);
qsort(f_list->data,
(size_t) f_list->length,
sizeof(f_list->data[0]),
compar);
}
(void) show_both_lists(input, d_list, f_list, FALSE);
d_list->offset = d_list->choice;
f_list->offset = f_list->choice;
return TRUE;
(void) show_both_lists(input, d_list, f_list, FALSE);
d_list->offset = d_list->choice;
f_list->offset = f_list->choice;
result = TRUE;
}
return result;
}
static bool
@ -560,9 +582,10 @@ dlg_fselect(const char *title, const char *path, int height, int width, int dsel
int fkey = FALSE;
int code;
int result = DLG_EXIT_UNKNOWN;
int state = dialog_vars.defaultno ? dlg_defaultno_button() : sTEXT;
int button = state;
int state = dialog_vars.default_button >= 0 ? dlg_default_button() : sTEXT;
int button;
int first = (state == sTEXT);
int first_trace = TRUE;
char *input;
char *completed;
char current[MAX_LEN + 1];
@ -572,7 +595,7 @@ dlg_fselect(const char *title, const char *path, int height, int width, int dsel
const char **buttons = dlg_ok_labels();
const char *d_label = _("Directories");
const char *f_label = _("Files");
char *partial;
char *partial = 0;
int min_wide = MIN_WIDE;
int min_items = height ? 0 : 4;
LIST d_list, f_list;
@ -604,11 +627,11 @@ dlg_fselect(const char *title, const char *path, int height, int width, int dsel
dlg_mouse_setbase(0, 0);
dlg_draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
dlg_draw_bottom_box(dialog);
dlg_draw_box2(dialog, 0, 0, height, width, dialog_attr, border_attr, border2_attr);
dlg_draw_bottom_box2(dialog, border_attr, border2_attr, dialog_attr);
dlg_draw_title(dialog, title);
wattrset(dialog, dialog_attr);
(void) wattrset(dialog, dialog_attr);
/* Draw the input field box */
tbox_height = 1;
@ -617,20 +640,22 @@ dlg_fselect(const char *title, const char *path, int height, int width, int dsel
tbox_x = (width - tbox_width) / 2;
w_text = derwin(dialog, tbox_height, tbox_width, tbox_y, tbox_x);
if (w_text == 0)
return DLG_EXIT_ERROR;
if (w_text == 0) {
result = DLG_EXIT_ERROR;
goto finish;
}
(void) keypad(w_text, TRUE);
dlg_draw_box(dialog, tbox_y - MARGIN, tbox_x - MARGIN,
(2 * MARGIN + 1), tbox_width + (MARGIN + EXT_WIDE),
menubox_border_attr, menubox_attr);
menubox_border_attr, menubox_border2_attr);
dlg_mouse_mkbigregion(getbegy(dialog) + tbox_y - MARGIN,
getbegx(dialog) + tbox_x - MARGIN,
1 + (2 * MARGIN),
tbox_width + (MARGIN + EXT_WIDE),
MOUSE_T, 1, 1, 3 /* doesn't matter */ );
dlg_register_window(w_text, "fselect", binding2);
dlg_register_window(w_text, "fselect2", binding2);
/* Draw the directory listing box */
if (dselect)
@ -642,15 +667,17 @@ dlg_fselect(const char *title, const char *path, int height, int width, int dsel
dbox_x = tbox_x;
w_work = derwin(dialog, dbox_height, dbox_width, dbox_y, dbox_x);
if (w_work == 0)
return DLG_EXIT_ERROR;
if (w_work == 0) {
result = DLG_EXIT_ERROR;
goto finish;
}
(void) keypad(w_work, TRUE);
(void) mvwprintw(dialog, dbox_y - (MARGIN + 1), dbox_x - MARGIN, d_label);
(void) mvwaddstr(dialog, dbox_y - (MARGIN + 1), dbox_x - MARGIN, d_label);
dlg_draw_box(dialog,
dbox_y - MARGIN, dbox_x - MARGIN,
dbox_height + (MARGIN + 1), dbox_width + (MARGIN + 1),
menubox_border_attr, menubox_attr);
menubox_border_attr, menubox_border2_attr);
init_list(&d_list, dialog, w_work, MOUSE_D);
if (!dselect) {
@ -661,15 +688,17 @@ dlg_fselect(const char *title, const char *path, int height, int width, int dsel
fbox_x = tbox_x + dbox_width + (2 * MARGIN);
w_work = derwin(dialog, fbox_height, fbox_width, fbox_y, fbox_x);
if (w_work == 0)
return DLG_EXIT_ERROR;
if (w_work == 0) {
result = DLG_EXIT_ERROR;
goto finish;
}
(void) keypad(w_work, TRUE);
(void) mvwprintw(dialog, fbox_y - (MARGIN + 1), fbox_x - MARGIN, f_label);
(void) mvwaddstr(dialog, fbox_y - (MARGIN + 1), fbox_x - MARGIN, f_label);
dlg_draw_box(dialog,
fbox_y - MARGIN, fbox_x - MARGIN,
fbox_height + (MARGIN + 1), fbox_width + (MARGIN + 1),
menubox_border_attr, menubox_attr);
menubox_border_attr, menubox_border2_attr);
init_list(&f_list, dialog, w_work, MOUSE_F);
} else {
memset(&f_list, 0, sizeof(f_list));
@ -696,6 +725,12 @@ dlg_fselect(const char *title, const char *path, int height, int width, int dsel
button = (state < 0) ? 0 : state;
dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width);
}
if (first_trace) {
first_trace = FALSE;
dlg_trace_win(dialog);
}
if (state < 0) {
switch (state) {
case sTEXT:
@ -771,7 +806,10 @@ dlg_fselect(const char *title, const char *path, int height, int width, int dsel
continue;
case DLGK_SELECT:
completed = 0;
partial = 0;
if (partial != 0) {
free(partial);
partial = 0;
}
if (state == sFILES && !dselect) {
completed = data_of(&f_list);
} else if (state == sDIRS) {
@ -788,8 +826,10 @@ dlg_fselect(const char *title, const char *path, int height, int width, int dsel
offset = (int) strlen(input);
dlg_show_string(w_text, input, offset, inputbox_attr,
0, 0, tbox_width, 0, first);
if (partial != NULL)
if (partial != NULL) {
free(partial);
partial = 0;
}
continue;
} else { /* if (state < sTEXT) */
(void) beep();
@ -862,6 +902,10 @@ dlg_fselect(const char *title, const char *path, int height, int width, int dsel
dlg_mouse_free_regions();
free_list(&d_list, FALSE);
free_list(&f_list, FALSE);
finish:
if (partial != 0)
free(partial);
return result;
}

View File

@ -1,9 +1,9 @@
/*
* $Id: guage.c,v 1.60 2011/06/27 00:52:28 tom Exp $
* $Id: guage.c,v 1.65 2012/11/30 10:43:31 tom Exp $
*
* guage.c -- implements the gauge dialog
*
* Copyright 2000-2010,2011 Thomas E. Dickey
* Copyright 2000-2011,2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -94,6 +94,7 @@ read_data(char *buffer, FILE *fp)
result = 0;
} else if (fgets(buffer, MY_LEN, fp) != 0) {
DLG_TRACE(("read_data:%s", buffer));
buffer[MY_LEN] = '\0';
dlg_trim_string(buffer);
result = 1;
} else {
@ -122,27 +123,29 @@ repaint_text(MY_OBJ * obj)
if (dialog != 0 && obj->obj.input != 0) {
(void) werase(dialog);
dlg_draw_box(dialog, 0, 0, obj->height, obj->width, dialog_attr, border_attr);
dlg_draw_box2(dialog, 0, 0, obj->height, obj->width, dialog_attr,
border_attr, border2_attr);
dlg_draw_title(dialog, obj->title);
wattrset(dialog, dialog_attr);
(void) wattrset(dialog, dialog_attr);
dlg_draw_helpline(dialog, FALSE);
dlg_print_autowrap(dialog, obj->prompt, obj->height, obj->width);
dlg_draw_box(dialog,
obj->height - 4, 2 + MARGIN,
2 + MARGIN, obj->width - 2 * (2 + MARGIN),
dialog_attr,
border_attr);
dlg_draw_box2(dialog,
obj->height - 4, 2 + MARGIN,
2 + MARGIN, obj->width - 2 * (2 + MARGIN),
dialog_attr,
border_attr,
border2_attr);
/*
* Clear the area for the progress bar by filling it with spaces
* in the title-attribute, and write the percentage with that
* in the gauge-attribute, and write the percentage with that
* attribute.
*/
(void) wmove(dialog, obj->height - 3, 4);
wattrset(dialog, gauge_attr);
(void) wattrset(dialog, gauge_attr);
for (i = 0; i < (obj->width - 2 * (3 + MARGIN)); i++)
(void) waddch(dialog, ' ');
@ -156,15 +159,15 @@ repaint_text(MY_OBJ * obj)
* but requires some tweaks to reverse it.
*/
x = (obj->percent * (obj->width - 2 * (3 + MARGIN))) / 100;
if ((title_attr & A_REVERSE) != 0) {
if ((gauge_attr & A_REVERSE) != 0) {
wattroff(dialog, A_REVERSE);
} else {
wattrset(dialog, A_REVERSE);
(void) wattrset(dialog, A_REVERSE);
}
(void) wmove(dialog, obj->height - 3, 4);
for (i = 0; i < x; i++) {
chtype ch2 = winch(dialog);
if (title_attr & A_REVERSE) {
if (gauge_attr & A_REVERSE) {
ch2 &= ~A_REVERSE;
}
(void) waddch(dialog, ch2);
@ -180,7 +183,7 @@ handle_input(DIALOG_CALLBACK * cb)
MY_OBJ *obj = (MY_OBJ *) cb;
bool result;
int status;
char buf[MY_LEN];
char buf[MY_LEN + 1];
if (dialog_state.pipe_input == 0) {
status = -1;
@ -335,7 +338,6 @@ dlg_free_gauge(void *objptr)
delink(obj);
obj->obj.keep_win = FALSE;
dlg_remove_callback(&(obj->obj));
free(obj);
}
}
@ -362,6 +364,7 @@ dialog_gauge(const char *title,
dlg_add_callback_ref((DIALOG_CALLBACK **) & obj, my_cleanup);
dlg_update_gauge(obj, percent);
dlg_trace_win(obj->obj.win);
do {
ch = dlg_getc(obj->obj.win, &fkey);
#ifdef KEY_RESIZE

View File

@ -1,5 +1,5 @@
#! /bin/sh
# $Id: headers-sh.in,v 1.9 2011/01/06 09:38:25 tom Exp $
# $Id: headers-sh.in,v 1.11 2011/10/18 23:49:13 tom Exp $
##############################################################################
# Copyright (c) 2004-2007,2011 Thomas E. Dickey #
# #
@ -45,6 +45,8 @@ PKGNAME=@PACKAGE_PREFIX@
CONFIGH=@PACKAGE_CONFIG@
SUB_INC=@SUB_INC@
: ${TMPDIR:=/tmp}
TMPSED=headers.sed
DIGIT=0123456789
@ -98,9 +100,9 @@ s/ $//
:done
EOF
# pick up autoconf-style symbols used in the application's headers
for i in $REF/*.h
for name in $REF/*.h
do
sed -e 's/^[ ][ ]*#[ ][ ]*/#/' $i \
sed -e 's/^[ ][ ]*#[ ][ ]*/#/' $name \
| egrep '^#(if|ifdef|ifndef|elif)' \
| sed -f headers.tmp \
| sort -u \
@ -116,8 +118,7 @@ EOF
-e 's/^#define[ ][ ]*//' \
-e 's/[ ].*//' \
| egrep -v "^${PACKAGE}_" \
| sort -u \
| egrep -v "^${PKGNAME}_"`
| sort -u`
do
echo "s/\\<$name\\>/${PKGNAME}_$name/g" >>$TMPSED
done
@ -127,6 +128,8 @@ EOF
echo "s,#include <${pkgname}_,#include <${PACKAGE}/${pkgname}_," >>$TMPSED
fi
echo '/_FILE_OFFSET_BITS/d' >>$TMPSED
# reduce the count if possible, since some old sed's limit is 100 lines
sort -u $TMPSED >headers.tmp
mv headers.tmp $TMPSED
@ -142,13 +145,32 @@ else
SRC=$3
SHOW=`basename $SRC`
TMPSRC=${TMPDIR-/tmp}/${SHOW}$$
TMPSRC=$TMPDIR/${SHOW}-text$$
TMPEDT=$TMPDIR/${SHOW}-edit$$
TMPTMP=$TMPDIR/${SHOW}-temp$$
echo " ... $SHOW"
test -f $REF/$SRC && SRC="$REF/$SRC"
rm -f $TMPSRC
sed -f $TMPSED $SRC > $TMPSRC
cat $SRC >$TMPSRC
tmp1=1
while true
do
tmp2=`expr $tmp1 + 49`
if test $tmp1 = 1
then
sed "${tmp2}q" $TMPSED >$TMPEDT
else
sed "1,${tmp1}d; ${tmp2}q" $TMPSED >$TMPEDT
fi
test -s $TMPEDT || break
sed -f $TMPEDT $TMPSRC > $TMPTMP
mv $TMPTMP $TMPSRC
tmp1=$tmp2
done
NAME=`basename $SRC`
# Just in case someone gzip'd manpages, remove the conflicting copy.
@ -172,6 +194,6 @@ else
fi
eval $PRG $TMPSRC $DST/$NAME
rm -f $TMPSRC
rm -f $TMPEDT $TMPTMP $TMPSRC
fi
# vile:ts=4 sw=4

View File

@ -1,9 +1,9 @@
/*
* $Id: help.c,v 1.2 2011/06/25 00:27:16 tom Exp $
* $Id: help.c,v 1.3 2012/12/04 02:01:10 tom Exp $
*
* help.c -- implements the help dialog
*
* Copyright 2011 Thomas E. Dickey
* Copyright 2011,2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -33,11 +33,22 @@ dialog_helpfile(const char *title,
int width)
{
int result = DLG_EXIT_ERROR;
DIALOG_VARS save;
if (!dialog_vars.in_helpfile && file != 0 && *file != '\0') {
dlg_save_vars(&save);
dialog_vars.no_label = NULL;
dialog_vars.ok_label = NULL;
dialog_vars.help_button = FALSE;
dialog_vars.extra_button = FALSE;
dialog_vars.nook = FALSE;
dialog_vars.in_helpfile = TRUE;
result = dialog_textbox(title, file, height, width);
dialog_vars.in_helpfile = FALSE;
dlg_restore_vars(&save);
}
return (result);
}

View File

@ -1,9 +1,9 @@
/*
* $Id: inputbox.c,v 1.67 2011/06/29 09:48:34 tom Exp $
* $Id: inputbox.c,v 1.76 2012/12/03 11:46:50 tom Exp $
*
* inputbox.c -- implements the input box
*
* Copyright 2000-2010,2011 Thomas E. Dickey
* Copyright 2000-2011,2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -73,6 +73,7 @@ dialog_inputbox(const char *title, const char *cprompt, int height, int width,
int result = DLG_EXIT_UNKNOWN;
int state;
int first;
int edited;
char *input;
WINDOW *dialog;
WINDOW *editor;
@ -85,12 +86,13 @@ dialog_inputbox(const char *title, const char *cprompt, int height, int width,
/* Set up the initial value */
input = dlg_set_result(init);
edited = FALSE;
#ifdef KEY_RESIZE
retry:
#endif
show_buttons = TRUE;
state = dialog_vars.defaultno ? dlg_defaultno_button() : sTEXT;
state = dialog_vars.default_button >= 0 ? dlg_default_button() : sTEXT;
first = (state == sTEXT);
key = fkey = 0;
@ -116,27 +118,34 @@ dialog_inputbox(const char *title, const char *cprompt, int height, int width,
dlg_mouse_setbase(xorg, yorg);
dlg_draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
dlg_draw_bottom_box(dialog);
dlg_draw_box2(dialog, 0, 0, height, width, dialog_attr, border_attr, border2_attr);
dlg_draw_bottom_box2(dialog, border_attr, border2_attr, dialog_attr);
dlg_draw_title(dialog, title);
wattrset(dialog, dialog_attr);
(void) wattrset(dialog, dialog_attr);
dlg_draw_helpline(dialog, FALSE);
dlg_print_autowrap(dialog, prompt, height, width);
/* Draw the input field box */
box_width = width - 6;
getyx(dialog, y, x);
(void) x;
box_y = y + 2;
box_x = (width - box_width) / 2;
dlg_mouse_mkregion(y + 1, box_x - 1, 3, box_width + 2, 'i');
dlg_draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2,
border_attr, dialog_attr);
border_attr, border2_attr);
/* Make a window for the input-field, to associate bindings */
editor = dlg_sub_window(dialog, 1, box_width, yorg + box_y, xorg + box_x);
dlg_register_window(editor, "inputbox", binding2);
dlg_register_window(editor, "inputbox2", binding2);
if (*input != '\0') {
dlg_show_string(editor, input, chr_offset, inputbox_attr,
0, 0, box_width, password, first);
wsyncup(editor);
wcursyncup(editor);
}
while (result == DLG_EXIT_UNKNOWN) {
int edit = 0;
@ -151,6 +160,13 @@ dialog_inputbox(const char *title, const char *cprompt, int height, int width,
}
if (!first) {
if (*input != '\0' && !edited) {
dlg_show_string(editor, input, chr_offset, inputbox_attr,
0, 0, box_width, password, first);
wmove(editor, 0, chr_offset);
wsyncup(editor);
wcursyncup(editor);
}
key = dlg_mouse_wgetch((state == sTEXT) ? editor : dialog, &fkey);
if (dlg_result_key(key, fkey, &result))
break;
@ -171,9 +187,12 @@ dialog_inputbox(const char *title, const char *cprompt, int height, int width,
edit = dlg_edit_string(input, &chr_offset, key, fkey, first);
if (edit) {
dlg_show_string(dialog, input, chr_offset, inputbox_attr,
box_y, box_x, box_width, password, first);
dlg_show_string(editor, input, chr_offset, inputbox_attr,
0, 0, box_width, password, first);
wsyncup(editor);
wcursyncup(editor);
first = FALSE;
edited = TRUE;
continue;
} else if (first) {
first = FALSE;

View File

@ -1,9 +1,9 @@
/*
* $Id: inputstr.c,v 1.69 2011/01/16 21:52:35 tom Exp $
* $Id: inputstr.c,v 1.72 2012/12/30 22:11:37 tom Exp $
*
* inputstr.c -- functions for input/display of a string
*
* Copyright 2000-2010,2011 Thomas E. Dickey
* Copyright 2000-2011,2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -261,7 +261,6 @@ dlg_count_wcbytes(const char *string, size_t len)
load_cache(&cache, string);
if (!same_cache1(&cache, string, len)) {
while (len != 0) {
int part = 0;
size_t code = 0;
const char *src = cache.string;
mbstate_t state;
@ -274,7 +273,6 @@ dlg_count_wcbytes(const char *string, size_t len)
if ((int) code >= 0) {
break;
}
++part;
--len;
}
cache.i_len = len;
@ -310,13 +308,17 @@ dlg_count_wchars(const char *string)
size_t code;
wchar_t *temp = dlg_calloc(wchar_t, len + 1);
cache.string[part] = '\0';
memset(&state, 0, sizeof(state));
code = mbsrtowcs(temp, &src, (size_t) part, &state);
cache.i_len = ((int) code >= 0) ? wcslen(temp) : 0;
cache.string[part] = save;
free(temp);
save_cache(&cache, string);
if (temp != 0) {
cache.string[part] = '\0';
memset(&state, 0, sizeof(state));
code = mbsrtowcs(temp, &src, (size_t) part, &state);
cache.i_len = ((int) code >= 0) ? wcslen(temp) : 0;
cache.string[part] = save;
free(temp);
save_cache(&cache, string);
} else {
cache.i_len = 0;
}
}
result = (int) cache.i_len;
} else
@ -377,8 +379,9 @@ dlg_find_index(const int *list, int limit, int to_find)
for (result = 0; result <= limit; ++result) {
if (to_find == list[result]
|| result == limit
|| to_find < list[result + 1])
|| ((result < limit) && (to_find < list[result + 1]))) {
break;
}
}
return result;
}
@ -531,7 +534,7 @@ dlg_edit_string(char *string, int *chr_offset, int key, int fkey, bool force)
edit = force;
break;
case DLGK_GRID_LEFT:
if (*chr_offset)
if (*chr_offset && offset > 0)
*chr_offset = indx[offset - 1];
break;
case DLGK_GRID_RIGHT:
@ -700,7 +703,7 @@ dlg_show_string(WINDOW *win,
compute_edit_offset(string, chr_offset, x_last, &input_x, &scrollamt);
wattrset(win, attr);
(void) wattrset(win, attr);
(void) wmove(win, y_base, x_base);
for (i = scrollamt, k = 0; i < limit && k < x_last; ++i) {
int check = cols[i + 1] - cols[scrollamt];

View File

@ -1,7 +1,7 @@
# $Id: makefile.in,v 1.79 2011/06/25 00:27:56 tom Exp $
# $Id: makefile.in,v 1.83 2012/10/06 14:05:14 tom Exp $
# template makefile for DIALOG
##############################################################################
# Copyright (c) 1999-2010,2011 Thomas E. Dickey #
# Copyright (c) 1999-2011,2012 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"), #
@ -35,6 +35,7 @@ VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
top_builddir = .
@ -71,7 +72,8 @@ LIBS = @LIBS@ @INTLLIBS@
RANLIB = @LIB_PREP@
RM = rm -f
LINT = lint
LINT = @LINT@
LINT_OPTS = @LINT_OPTS@
CTAGS = @CTAGS@
ETAGS = @ETAGS@
@ -84,6 +86,7 @@ LIBTOOL_CREATE = @LIB_CREATE@
LIBTOOL_LINK = @LIB_LINK@
LIBTOOL_INSTALL = @LIB_INSTALL@
LIBTOOL_UNINSTALL = @LIB_UNINSTALL@
LIBTOOL_VERSION = @LIBTOOL_VERSION@
INSTALL = @INSTALL@
INSTALL_PROGRAM = $(LIBTOOL_INSTALL) @INSTALL_PROGRAM@
@ -101,7 +104,7 @@ LIB_CONFIG = @PACKAGE@-config
# The library name $(LIB) is set at configure/make time, since it is used as a
# makefile target. Ditto for $(PROG).
LIB = @LIB_PREFIX@@PACKAGE@$a
PROG = dialog$x
PROG = @PACKAGE@$x
#
# Standard .c to .o compile line.
#
@ -179,7 +182,7 @@ $(LIB) : $(LIB_OBJECT)
$(LIBTOOL_CREATE) $(LIB) $(LIB_OBJECT)
$(RANLIB) $@
dialog$x : $(LIB) dialog$o @INTLDIR_MAKE@ @INTLLIBS@
$(PROG)$x : $(LIB) dialog$o @INTLDIR_MAKE@ @INTLLIBS@
$(LINK) -o $@ dialog$o -L. -l@PACKAGE@ $(LDFLAGS) $(LIBS)
clean \
@ -249,20 +252,20 @@ install-lib :: $(LIB_DIRS) $(LIB) headers.sed
@ echo "** installing library in $(LIBDIR)"
@ $(LIBTOOL_INSTALL) $(INSTALL_DATA) $(LIB) $(LIBDIR)
@ echo "** installing headers in $(INCLUDEDIR)"
@ $(SHELL) $(srcdir)/headers-sh $(INSTALL_DATA) $(INCLUDEDIR) $(srcdir) dialog.h
@ $(SHELL) $(srcdir)/headers-sh $(INSTALL_DATA) $(INCLUDEDIR) $(srcdir) dlg_colors.h
@ $(SHELL) $(srcdir)/headers-sh $(INSTALL_DATA) $(INCLUDEDIR) $(srcdir) dlg_keys.h
@ $(SHELL) $(srcdir)/headers-sh $(INSTALL_DATA) $(INCLUDEDIR) . dlg_config.h
@ $(SHELL) headers-sh $(INSTALL_DATA) $(INCLUDEDIR) $(srcdir) dialog.h
@ $(SHELL) headers-sh $(INSTALL_DATA) $(INCLUDEDIR) $(srcdir) dlg_colors.h
@ $(SHELL) headers-sh $(INSTALL_DATA) $(INCLUDEDIR) $(srcdir) dlg_keys.h
@ $(SHELL) headers-sh $(INSTALL_DATA) $(INCLUDEDIR) . dlg_config.h
uninstall-lib :: $(BINDIR)
$(RM) $(BINDIR)/$(LIB_CONFIG)
uninstall-lib :: $(LIB_DIRS)
- $(LIBTOOL_UNINSTALL) $(RM) $(LIBDIR)/$(LIB)
@ $(SHELL) $(srcdir)/headers-sh $(RM) $(INCLUDEDIR) $(srcdir) dialog.h
@ $(SHELL) $(srcdir)/headers-sh $(RM) $(INCLUDEDIR) $(srcdir) dlg_colors.h
@ $(SHELL) $(srcdir)/headers-sh $(RM) $(INCLUDEDIR) $(srcdir) dlg_keys.h
@ $(SHELL) $(srcdir)/headers-sh $(RM) $(INCLUDEDIR) . dlg_config.h
@ $(SHELL) headers-sh $(RM) $(INCLUDEDIR) $(srcdir) dialog.h
@ $(SHELL) headers-sh $(RM) $(INCLUDEDIR) $(srcdir) dlg_colors.h
@ $(SHELL) headers-sh $(RM) $(INCLUDEDIR) $(srcdir) dlg_keys.h
@ $(SHELL) headers-sh $(RM) $(INCLUDEDIR) . dlg_config.h
install-lib :: $(MAN3DIR)
@ echo "** installing @PACKAGE@.3"
@ -276,8 +279,8 @@ install-lib :: $(MAN3DIR)
uninstall-lib ::
$(RM) $(MAN3DIR)/@PACKAGE@.3
headers.sed : $(srcdir)/headers-sh
$(SHELL) $(srcdir)/headers-sh $(INCLUDEDIR) $(srcdir)
headers.sed : headers-sh
$(SHELL) headers-sh $(INCLUDEDIR) $(srcdir)
################################################################################
TOP_DOCS = \
@ -328,4 +331,4 @@ update-po:
test -f $(PO_DIR)/makefile && cd $(PO_DIR) && $(MAKE) $@
lint:
$(LINT) $(CPPFLAGS) *.c
$(LINT) $(LINT_OPTS) $(CPPFLAGS) *.c

View File

@ -1,9 +1,9 @@
/*
* $Id: menubox.c,v 1.122 2011/06/29 09:48:46 tom Exp $
* $Id: menubox.c,v 1.145 2012/12/30 21:11:02 tom Exp $
*
* menubox.c -- implements the menu box
*
* Copyright 2000-2010,2011 Thomas E. Dickey
* Copyright 2000-2011,2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public Licens, version 2.1e
@ -27,141 +27,97 @@
#include <dialog.h>
#include <dlg_keys.h>
static int menu_width, tag_x, item_x;
typedef enum {
Unselected = 0,
Selected,
Editing
} Mode;
typedef struct {
/* the outer-window */
WINDOW *dialog;
int box_y;
int box_x;
int tag_x;
int item_x;
int menu_height;
int menu_width;
/* the inner-window */
WINDOW *menu;
DIALOG_LISTITEM *items;
int item_no;
} ALL_DATA;
#define MIN_HIGH (1 + (5 * MARGIN))
#define INPUT_ROWS 3 /* rows per inputmenu entry */
#define LLEN(n) ((n) * MENUBOX_TAGS)
#define ItemName(i) items[LLEN(i)]
#define ItemText(i) items[LLEN(i) + 1]
#define ItemHelp(i) items[LLEN(i) + 2]
#define RowHeight(i) (is_inputmenu ? ((i) * INPUT_ROWS) : ((i) * 1))
#define ItemToRow(i) (is_inputmenu ? ((i) * INPUT_ROWS + 1) : (i))
#define RowToItem(i) (is_inputmenu ? ((i) / INPUT_ROWS + 0) : (i))
static void
print_arrows(WINDOW *win,
int box_x,
int box_y,
int scrollamt,
int max_choice,
int item_no,
int menu_height)
{
dlg_draw_scrollbar(win,
scrollamt,
scrollamt,
scrollamt + max_choice,
item_no,
box_x,
box_x + menu_width,
box_y,
box_y + menu_height + 1,
menubox_attr,
menubox_border_attr);
}
/*
* Print the tag of a menu-item
*/
static void
print_tag(WINDOW *win,
DIALOG_LISTITEM * item,
int choice,
Mode selected,
bool is_inputmenu)
{
int my_x = item_x;
int my_y = ItemToRow(choice);
int tag_width = (my_x - tag_x - GUTTER);
const int *cols;
const int *indx;
int limit;
int prefix;
cols = dlg_index_columns(item->name);
indx = dlg_index_wchars(item->name);
limit = dlg_count_wchars(item->name);
prefix = (indx[1] - indx[0]);
/* highlight first char of the tag to be special */
(void) wmove(win, my_y, tag_x);
wattrset(win, selected ? tag_key_selected_attr : tag_key_attr);
if (strlen(item->name) != 0)
(void) waddnstr(win, item->name, prefix);
/* print rest of the string */
wattrset(win, selected ? tag_selected_attr : tag_attr);
if ((int) strlen(item->name) > prefix) {
limit = dlg_limit_columns(item->name, tag_width, 1);
if (limit > 0)
(void) waddnstr(win, item->name + indx[1], indx[limit] - indx[1]);
}
}
/*
* Print menu item
*/
static void
print_item(WINDOW *win,
DIALOG_LISTITEM * items,
print_item(ALL_DATA * data,
WINDOW *win,
DIALOG_LISTITEM * item,
int choice,
Mode selected,
bool is_inputmenu)
{
chtype save = dlg_get_attrs(win);
int n;
int my_width = menu_width;
int my_x = item_x;
int climit = (data->item_x - data->tag_x - GUTTER);
int my_width = data->menu_width;
int my_x = data->item_x;
int my_y = ItemToRow(choice);
chtype attr = A_NORMAL;
chtype textchar;
bool both = (!dialog_vars.no_tags && !dialog_vars.no_items);
bool first = TRUE;
chtype bordchar;
const char *show = (dialog_vars.no_items
? item->name
: item->text);
switch (selected) {
default:
case Unselected:
textchar = item_attr;
bordchar = item_attr;
break;
case Selected:
textchar = item_selected_attr;
bordchar = item_selected_attr;
break;
case Editing:
textchar = inputbox_attr;
bordchar = dialog_attr;
break;
}
/* Clear 'residue' of last item and mark current current item */
if (is_inputmenu) {
wattrset(win, (selected != Unselected) ? item_selected_attr : item_attr);
(void) wattrset(win, (selected != Unselected) ? item_selected_attr : item_attr);
for (n = my_y - 1; n < my_y + INPUT_ROWS - 1; n++) {
wmove(win, n, 0);
wprintw(win, "%*s", my_width, " ");
}
} else {
wattrset(win, menubox_attr);
(void) wattrset(win, menubox_attr);
wmove(win, my_y, 0);
wprintw(win, "%*s", my_width, " ");
}
print_tag(win, items, choice, selected, is_inputmenu);
/* highlight first char of the tag to be special */
if (both) {
(void) wmove(win, my_y, data->tag_x);
dlg_print_listitem(win, item->name, climit, first, selected);
first = FALSE;
}
/* Draw the input field box (only for inputmenu) */
(void) wmove(win, my_y, my_x);
if (is_inputmenu) {
my_width -= 1;
dlg_draw_box(win, my_y - 1, my_x, INPUT_ROWS, my_width - my_x - tag_x,
dlg_draw_box(win, my_y - 1, my_x, INPUT_ROWS, my_width - my_x - data->tag_x,
bordchar,
bordchar);
my_width -= 1;
@ -170,25 +126,24 @@ print_item(WINDOW *win,
/* print actual item */
wmove(win, my_y, my_x);
wattrset(win, textchar);
dlg_print_text(win, items->text, my_width - my_x, &attr);
dlg_print_listitem(win, show, my_width - my_x, first, selected);
if (selected) {
dlg_item_help(items->help);
dlg_item_help(item->help);
}
wattrset(win, save);
(void) wattrset(win, save);
}
/*
* Allow the user to edit the text of a menu entry.
*/
static int
input_menu_edit(WINDOW *win,
input_menu_edit(ALL_DATA * data,
DIALOG_LISTITEM * items,
int choice,
char **resultp)
{
chtype save = dlg_get_attrs(win);
chtype save = dlg_get_attrs(data->menu);
char *result;
int offset = 0;
int key = 0, fkey = 0;
@ -206,15 +161,17 @@ input_menu_edit(WINDOW *win,
result[0] = '\0';
strcpy(result, items->text);
print_item(win, items, choice, Editing, TRUE);
print_item(data, data->menu, items, choice, Editing, TRUE);
/* taken out of inputbox.c - but somewhat modified */
for (;;) {
if (!first)
key = dlg_mouse_wgetch(win, &fkey);
key = dlg_mouse_wgetch(data->menu, &fkey);
if (dlg_edit_string(result, &offset, key, fkey, first)) {
dlg_show_string(win, result, offset, inputbox_attr,
y, item_x + 1, menu_width - item_x - 3,
dlg_show_string(data->menu, result, offset, inputbox_attr,
y,
data->item_x + 1,
data->menu_width - data->item_x - 3,
FALSE, first);
first = FALSE;
} else if (key == ESC || key == TAB) {
@ -224,8 +181,8 @@ input_menu_edit(WINDOW *win,
break;
}
}
print_item(win, items, choice, Selected, TRUE);
wattrset(win, save);
print_item(data, data->menu, items, choice, Selected, TRUE);
(void) wattrset(data->menu, save);
*resultp = result;
return code;
@ -252,7 +209,7 @@ handle_button(int code, DIALOG_LISTITEM * items, int choice)
return code;
}
static int
int
dlg_renamed_menutext(DIALOG_LISTITEM * items, int current, char *newtext)
{
if (dialog_vars.input_result)
@ -264,7 +221,7 @@ dlg_renamed_menutext(DIALOG_LISTITEM * items, int current, char *newtext)
return DLG_EXIT_EXTRA;
}
static int
int
dlg_dummy_menutext(DIALOG_LISTITEM * items, int current, char *newtext)
{
(void) items;
@ -273,6 +230,63 @@ dlg_dummy_menutext(DIALOG_LISTITEM * items, int current, char *newtext)
return DLG_EXIT_ERROR;
}
static void
print_menu(ALL_DATA * data, int choice, int scrollamt, int max_choice, bool is_inputmenu)
{
int i;
for (i = 0; i < max_choice; i++) {
print_item(data,
data->menu,
&data->items[i + scrollamt],
i,
(i == choice) ? Selected : Unselected,
is_inputmenu);
}
/* Clean bottom lines */
if (is_inputmenu) {
int spare_lines, x_count;
spare_lines = data->menu_height % INPUT_ROWS;
(void) wattrset(data->menu, menubox_attr);
for (; spare_lines; spare_lines--) {
wmove(data->menu, data->menu_height - spare_lines, 0);
for (x_count = 0; x_count < data->menu_width;
x_count++) {
waddch(data->menu, ' ');
}
}
}
(void) wnoutrefresh(data->menu);
dlg_draw_scrollbar(data->dialog,
scrollamt,
scrollamt,
scrollamt + max_choice,
data->item_no,
data->box_x,
data->box_x + data->menu_width,
data->box_y,
data->box_y + data->menu_height + 1,
menubox_border2_attr,
menubox_border_attr);
}
static bool
check_hotkey(DIALOG_LISTITEM * items, int choice)
{
bool result = FALSE;
if (dlg_match_char(dlg_last_getc(),
(dialog_vars.no_tags
? items[choice].text
: items[choice].name))) {
result = TRUE;
}
return result;
}
/*
* This is an alternate interface to 'menu' which allows the application
* to read the list item states back directly without putting them in the
@ -323,19 +337,24 @@ dlg_menu(const char *title,
int old_height = height;
int old_width = width;
#endif
int i, j, x, y, cur_x, cur_y, box_x, box_y;
ALL_DATA all;
int i, j, x, y, cur_x, cur_y;
int key = 0, fkey;
int button = dialog_state.visit_items ? -1 : dlg_defaultno_button();
int button = dialog_state.visit_items ? -1 : dlg_default_button();
int choice = dlg_default_listitem(items);
int result = DLG_EXIT_UNKNOWN;
int scrollamt = 0;
int max_choice, min_width;
int max_choice;
int found;
int use_height, use_width, name_width, text_width;
int use_width, name_width, text_width, list_width;
WINDOW *dialog, *menu;
char *prompt = dlg_strclone(cprompt);
const char **buttons = dlg_ok_labels();
bool is_inputmenu = (rename_menutext == dlg_renamed_menutext);
bool is_inputmenu = ((rename_menutext != 0)
&& (rename_menutext != dlg_dummy_menutext));
all.items = items;
all.item_no = item_no;
dlg_does_output();
dlg_tab_correct_str(prompt);
@ -344,14 +363,17 @@ dlg_menu(const char *title,
retry:
#endif
use_height = menu_height;
if (use_height == 0) {
min_width = dlg_calc_list_width(item_no, items) + 10;
all.menu_height = menu_height;
use_width = dlg_calc_list_width(item_no, items) + 10;
use_width = MAX(26, use_width);
if (all.menu_height == 0) {
/* calculate height without items (4) */
dlg_auto_size(title, prompt, &height, &width, MIN_HIGH, MAX(26, min_width));
dlg_calc_listh(&height, &use_height, item_no);
dlg_auto_size(title, prompt, &height, &width, MIN_HIGH, use_width);
dlg_calc_listh(&height, &all.menu_height, item_no);
} else {
dlg_auto_size(title, prompt, &height, &width, MIN_HIGH + use_height, 26);
dlg_auto_size(title, prompt,
&height, &width,
MIN_HIGH + all.menu_height, use_width);
}
dlg_button_layout(buttons, &width);
dlg_print_size(height, width);
@ -361,48 +383,54 @@ dlg_menu(const char *title,
y = dlg_box_y_ordinate(height);
dialog = dlg_new_window(height, width, y, x);
all.dialog = dialog;
dlg_register_window(dialog, "menubox", binding);
dlg_register_buttons(dialog, "menubox", buttons);
dlg_mouse_setbase(x, y);
dlg_draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
dlg_draw_bottom_box(dialog);
dlg_draw_box2(dialog, 0, 0, height, width, dialog_attr, border_attr, border2_attr);
dlg_draw_bottom_box2(dialog, border_attr, border2_attr, dialog_attr);
dlg_draw_title(dialog, title);
wattrset(dialog, dialog_attr);
(void) wattrset(dialog, dialog_attr);
dlg_print_autowrap(dialog, prompt, height, width);
menu_width = width - 6;
all.menu_width = width - 6;
getyx(dialog, cur_y, cur_x);
box_y = cur_y + 1;
box_x = (width - menu_width) / 2 - 1;
all.box_y = cur_y + 1;
all.box_x = (width - all.menu_width) / 2 - 1;
/*
* After displaying the prompt, we know how much space we really have.
* Limit the list to avoid overwriting the ok-button.
*/
if (use_height + MIN_HIGH > height - cur_y)
use_height = height - MIN_HIGH - cur_y;
if (use_height <= 0)
use_height = 1;
if (all.menu_height + MIN_HIGH > height - cur_y)
all.menu_height = height - MIN_HIGH - cur_y;
if (all.menu_height <= 0)
all.menu_height = 1;
/* Find out maximal number of displayable items at once. */
max_choice = MIN(use_height,
max_choice = MIN(all.menu_height,
RowHeight(item_no));
if (is_inputmenu)
max_choice /= INPUT_ROWS;
/* create new window for the menu */
menu = dlg_sub_window(dialog, use_height, menu_width,
y + box_y + 1,
x + box_x + 1);
menu = dlg_sub_window(dialog, all.menu_height, all.menu_width,
y + all.box_y + 1,
x + all.box_x + 1);
all.menu = menu;
dlg_register_window(menu, "menu", binding2);
dlg_register_buttons(menu, "menu", buttons);
/* draw a box around the menu items */
dlg_draw_box(dialog, box_y, box_x, use_height + 2, menu_width + 2,
menubox_border_attr, menubox_attr);
dlg_draw_box(dialog,
all.box_y, all.box_x,
all.menu_height + 2, all.menu_width + 2,
menubox_border_attr, menubox_border2_attr);
name_width = 0;
text_width = 0;
@ -421,49 +449,58 @@ dlg_menu(const char *title,
*
* FIXME: the gutter width and name/list ratio should be configurable.
*/
use_width = (menu_width - GUTTER);
if (text_width + name_width > use_width) {
int need = (int) (0.30 * use_width);
if (name_width > need) {
int want = (int) (use_width
* ((double) name_width)
/ (text_width + name_width));
name_width = (want > need) ? want : need;
use_width = (all.menu_width - GUTTER);
if (dialog_vars.no_tags) {
list_width = MIN(use_width, text_width);
} else if (dialog_vars.no_items) {
list_width = MIN(use_width, name_width);
} else {
if (text_width >= 0
&& name_width >= 0
&& use_width > 0
&& text_width + name_width > use_width) {
int need = (int) (0.30 * use_width);
if (name_width > need) {
int want = (int) (use_width
* ((double) name_width)
/ (text_width + name_width));
name_width = (want > need) ? want : need;
}
text_width = use_width - name_width;
}
text_width = use_width - name_width;
list_width = (text_width + name_width);
}
tag_x = (is_inputmenu
? 0
: (use_width - text_width - name_width) / 2);
item_x = name_width + tag_x + GUTTER;
all.tag_x = (is_inputmenu
? 0
: (use_width - list_width) / 2);
all.item_x = ((dialog_vars.no_tags
? 0
: (dialog_vars.no_items
? 0
: (GUTTER + name_width)))
+ all.tag_x);
if (choice - scrollamt >= max_choice) {
scrollamt = choice - (max_choice - 1);
choice = max_choice - 1;
}
/* Print the menu */
for (i = 0; i < max_choice; i++) {
print_item(menu,
&items[i + scrollamt],
i,
(i == choice) ? Selected : Unselected,
is_inputmenu);
}
(void) wnoutrefresh(menu);
print_menu(&all, choice, scrollamt, max_choice, is_inputmenu);
/* register the new window, along with its borders */
dlg_mouse_mkbigregion(box_y + 1, box_x, use_height + 2, menu_width + 2,
dlg_mouse_mkbigregion(all.box_y + 1, all.box_x,
all.menu_height + 2, all.menu_width + 2,
KEY_MAX, 1, 1, 1 /* by lines */ );
print_arrows(dialog, box_x, box_y, scrollamt, max_choice, item_no, use_height);
dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width);
dlg_trace_win(dialog);
while (result == DLG_EXIT_UNKNOWN) {
if (button < 0) /* --visit-items */
wmove(dialog, box_y + ItemToRow(choice) + 1, box_x + tag_x + 1);
wmove(dialog,
all.box_y + ItemToRow(choice) + 1,
all.box_x + all.tag_x + 1);
key = dlg_mouse_wgetch(dialog, &fkey);
if (dlg_result_key(key, fkey, &result))
@ -500,7 +537,7 @@ dlg_menu(const char *title,
*/
if (button < 0 || !dialog_state.visit_items) {
for (j = scrollamt + choice + 1; j < item_no; j++) {
if (dlg_match_char(dlg_last_getc(), items[j].name)) {
if (check_hotkey(items, j)) {
found = TRUE;
i = j - scrollamt;
break;
@ -508,7 +545,7 @@ dlg_menu(const char *title,
}
if (!found) {
for (j = 0; j <= scrollamt + choice; j++) {
if (dlg_match_char(dlg_last_getc(), items[j].name)) {
if (check_hotkey(items, j)) {
found = TRUE;
i = j - scrollamt;
break;
@ -578,95 +615,17 @@ dlg_menu(const char *title,
if (i != choice) {
getyx(dialog, cur_y, cur_x);
if (i < 0 || i >= max_choice) {
#if defined(NCURSES_VERSION_MAJOR) && NCURSES_VERSION_MAJOR < 5
/*
* Using wscrl to assist ncurses scrolling is not needed
* in version 5.x
*/
if (i == -1) {
if (use_height > 1) {
/* De-highlight current first item */
print_item(menu,
&items[scrollamt],
0, Unselected, is_inputmenu);
scrollok(menu, TRUE);
wscrl(menu, -RowHeight(1));
scrollok(menu, FALSE);
}
scrollamt--;
print_item(menu,
&items[scrollamt],
0, Selected, is_inputmenu);
} else if (i == max_choice) {
if (use_height > 1) {
/* De-highlight current last item before scrolling up */
print_item(menu,
&items[scrollamt + max_choice - 1],
max_choice - 1,
Unselected,
is_inputmenu);
scrollok(menu, TRUE);
wscrl(menu, RowHeight(1));
scrollok(menu, FALSE);
}
scrollamt++;
print_item(menu,
&items[scrollamt + max_choice - 1],
max_choice - 1, TRUE,
is_inputmenu);
} else
#endif
{
if (i < 0) {
scrollamt += i;
choice = 0;
} else {
choice = max_choice - 1;
scrollamt += (i - max_choice + 1);
}
for (i = 0; i < max_choice; i++) {
print_item(menu,
&items[scrollamt + i],
i,
(i == choice) ? Selected : Unselected,
is_inputmenu);
}
if (i < 0) {
scrollamt += i;
choice = 0;
} else {
choice = max_choice - 1;
scrollamt += (i - max_choice + 1);
}
/* Clean bottom lines */
if (is_inputmenu) {
int spare_lines, x_count;
spare_lines = use_height % INPUT_ROWS;
wattrset(menu, menubox_attr);
for (; spare_lines; spare_lines--) {
wmove(menu, use_height - spare_lines, 0);
for (x_count = 0; x_count < menu_width;
x_count++) {
waddch(menu, ' ');
}
}
}
(void) wnoutrefresh(menu);
print_arrows(dialog,
box_x, box_y,
scrollamt, max_choice, item_no, use_height);
print_menu(&all, choice, scrollamt, max_choice, is_inputmenu);
} else {
/* De-highlight current item */
print_item(menu,
&items[scrollamt + choice],
choice,
Unselected,
is_inputmenu);
/* Highlight new item */
choice = i;
print_item(menu,
&items[scrollamt + choice],
choice,
Selected,
is_inputmenu);
(void) wnoutrefresh(menu);
print_arrows(dialog,
box_x, box_y,
scrollamt, max_choice, item_no, use_height);
print_menu(&all, choice, scrollamt, max_choice, is_inputmenu);
(void) wmove(dialog, cur_y, cur_x);
wrefresh(dialog);
}
@ -687,17 +646,14 @@ dlg_menu(const char *title,
FALSE, width);
break;
case DLGK_ENTER:
result = dlg_enter_buttoncode(button);
if (is_inputmenu)
result = dlg_ok_buttoncode(button);
else
result = dlg_enter_buttoncode(button);
/*
* If dlg_menu() is called from dialog_menu(), we want to
* capture the results into dialog_vars.input_result, but not
* if dlg_menu() is called directly from an application. We
* can check this by testing if rename_menutext is the function
* pointer owned by dialog_menu(). It would be nicer to have
* this logic inside dialog_menu(), but that cannot be done
* since we would lose compatibility for the results reported
* after input_menu_edit().
* capture the results into dialog_vars.input_result.
*/
if (result == DLG_EXIT_ERROR) {
result = DLG_EXIT_UNKNOWN;
@ -720,7 +676,7 @@ dlg_menu(const char *title,
if (is_inputmenu && result == DLG_EXIT_EXTRA) {
char *tmp;
if (input_menu_edit(menu,
if (input_menu_edit(&all,
&items[scrollamt + choice],
choice,
&tmp)) {
@ -732,7 +688,8 @@ dlg_menu(const char *title,
}
} else {
result = DLG_EXIT_UNKNOWN;
print_item(menu,
print_item(&all,
menu,
&items[scrollamt + choice],
choice,
Selected,
@ -789,17 +746,19 @@ dialog_menu(const char *title,
{
int result;
int choice;
int i;
int i, j;
DIALOG_LISTITEM *listitems;
listitems = dlg_calloc(DIALOG_LISTITEM, (size_t) item_no + 1);
assert_ptr(listitems, "dialog_menu");
for (i = 0; i < item_no; ++i) {
listitems[i].name = ItemName(i);
listitems[i].text = ItemText(i);
for (i = j = 0; i < item_no; ++i) {
listitems[i].name = items[j++];
listitems[i].text = (dialog_vars.no_items
? dlg_strempty()
: items[j++]);
listitems[i].help = ((dialog_vars.item_help)
? ItemHelp(i)
? items[j++]
: dlg_strempty());
}
dlg_align_columns(&listitems[0].text, sizeof(DIALOG_LISTITEM), item_no);
@ -812,7 +771,9 @@ dialog_menu(const char *title,
item_no,
listitems,
&choice,
dialog_vars.input_menu ? dlg_renamed_menutext : dlg_dummy_menutext);
(dialog_vars.input_menu
? dlg_renamed_menutext
: dlg_dummy_menutext));
dlg_free_columns(&listitems[0].text, sizeof(DIALOG_LISTITEM), item_no);
free(listitems);

View File

@ -1,9 +1,9 @@
/*
* $Id: mixedform.c,v 1.8 2010/04/28 20:54:11 tom Exp $
* $Id: mixedform.c,v 1.10 2013/03/17 15:03:41 tom Exp $
*
* formbox.c -- implements the form (i.e, some pairs label/editbox)
* mixedform.c -- implements the mixed form (i.e, typed pairs label/editbox)
*
* Copyright 2007-2008,2010 Thomas E. Dickey
* Copyright 2007-2011,2013 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -112,6 +112,7 @@ dialog_mixedform(const char *title,
dlg_add_separator();
}
}
dlg_add_last_key(-1);
}
dlg_free_formitems(listitems);

View File

@ -1,9 +1,9 @@
/*
* $Id: mixedgauge.c,v 1.24 2011/06/27 08:16:38 tom Exp $
* $Id: mixedgauge.c,v 1.30 2012/11/18 16:30:20 tom Exp $
*
* mixedgauge.c -- implements the mixedgauge dialog
*
* Copyright 2007-2010,2011 Thomas E. Dickey
* Copyright 2007-2011,2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -113,7 +113,6 @@ myprint_status(DIALOG_MIXEDGAUGE * dlg)
int y = MARGIN;
int item;
int cells = dlg->len_text - 2;
int rm = limit_x; /* right margin */
int lm = limit_x - dlg->len_text - 1;
int bm = limit_y; /* bottom margin */
int last_y = 0, last_x = 0;
@ -122,12 +121,8 @@ myprint_status(DIALOG_MIXEDGAUGE * dlg)
const char *status = "";
char *freeMe = 0;
if (win) {
rm -= (2 * MARGIN);
bm -= (2 * MARGIN);
}
if (win != 0)
getyx(win, last_y, last_x);
bm -= (2 * MARGIN);
getyx(win, last_y, last_x);
for (item = 0; item < dlg->item_no; ++item) {
chtype attr = A_NORMAL;
@ -147,7 +142,7 @@ myprint_status(DIALOG_MIXEDGAUGE * dlg)
(void) wmove(win, y, lm + (cells - (int) strlen(status)) / 2);
if (freeMe) {
(void) wmove(win, y, lm + 1);
wattrset(win, title_attr);
(void) wattrset(win, title_attr);
for (j = 0; j < cells; j++)
(void) waddch(win, ' ');
@ -157,7 +152,7 @@ myprint_status(DIALOG_MIXEDGAUGE * dlg)
if ((title_attr & A_REVERSE) != 0) {
wattroff(win, A_REVERSE);
} else {
wattrset(win, A_REVERSE);
(void) wattrset(win, A_REVERSE);
}
(void) wmove(win, y, lm + 1);
@ -181,6 +176,8 @@ myprint_status(DIALOG_MIXEDGAUGE * dlg)
(void) waddch(win, ']');
(void) wnoutrefresh(win);
}
if (win != 0)
wmove(win, last_y, last_x);
}
static void
@ -192,10 +189,10 @@ mydraw_mixed_box(WINDOW *win, int y, int x, int height, int width,
chtype attr = A_NORMAL;
const char *message = _("Overall Progress");
chtype save2 = dlg_get_attrs(win);
wattrset(win, title_attr);
(void) wattrset(win, title_attr);
(void) wmove(win, y, x + 2);
dlg_print_text(win, message, width, &attr);
wattrset(win, save2);
(void) wattrset(win, save2);
}
}
@ -223,7 +220,7 @@ dlg_update_mixedgauge(DIALOG_MIXEDGAUGE * dlg, int percent)
* attribute.
*/
(void) wmove(dlg->dialog, dlg->height - 3, 4);
wattrset(dlg->dialog, gauge_attr);
(void) wattrset(dlg->dialog, gauge_attr);
for (i = 0; i < (dlg->width - 2 * (3 + MARGIN)); i++)
(void) waddch(dlg->dialog, ' ');
@ -240,7 +237,7 @@ dlg_update_mixedgauge(DIALOG_MIXEDGAUGE * dlg, int percent)
if ((title_attr & A_REVERSE) != 0) {
wattroff(dlg->dialog, A_REVERSE);
} else {
wattrset(dlg->dialog, A_REVERSE);
(void) wattrset(dlg->dialog, A_REVERSE);
}
(void) wmove(dlg->dialog, dlg->height - 3, 4);
for (i = 0; i < x; i++) {
@ -251,6 +248,7 @@ dlg_update_mixedgauge(DIALOG_MIXEDGAUGE * dlg, int percent)
(void) waddch(dlg->dialog, ch);
}
myprint_status(dlg);
dlg_trace_win(dlg->dialog);
}
/*
@ -324,11 +322,11 @@ dlg_begin_mixedgauge(DIALOG_MIXEDGAUGE * dlg,
dlg->dialog = dlg_new_window(dlg->height, dlg->width, y, x);
(void) werase(dlg->dialog);
dlg_draw_box(dlg->dialog,
0, 0,
dlg->height,
dlg->width,
dialog_attr, border_attr);
dlg_draw_box2(dlg->dialog,
0, 0,
dlg->height,
dlg->width,
dialog_attr, border_attr, border2_attr);
dlg_draw_title(dlg->dialog, dlg->title);
dlg_draw_helpline(dlg->dialog, FALSE);
@ -340,7 +338,7 @@ dlg_begin_mixedgauge(DIALOG_MIXEDGAUGE * dlg,
dlg->width,
y + dlg->item_no + (2 * MARGIN),
x);
wattrset(dlg->caption, dialog_attr);
(void) wattrset(dlg->caption, dialog_attr);
dlg_print_autowrap(dlg->caption, dlg->prompt, dlg->height, dlg->width);
}

View File

@ -1,9 +1,9 @@
/*
* $Id: mouse.c,v 1.18 2007/02/22 21:51:38 tom Exp $
* $Id: mouse.c,v 1.20 2012/12/21 10:00:30 tom Exp $
*
* mouse.c -- mouse support for dialog
*
* Copyright 2002-2006,2007 Thomas E. Dickey
* Copyright 2002-2007,2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -26,7 +26,7 @@
#if USE_MOUSE
static int basex, basey;
static int basex, basey, basecode;
static mseRegion *regionList = NULL;
@ -51,6 +51,12 @@ dlg_mouse_setbase(int x, int y)
basey = y;
}
void
dlg_mouse_setcode(int code)
{
basecode = code;
}
void
dlg_mouse_mkbigregion(int y, int x,
int height, int width,
@ -79,7 +85,7 @@ dlg_mouse_mkregion(int y, int x, int height, int width, int code)
{
mseRegion *butPtr;
if ((butPtr = find_region_by_code(code)) == 0) {
if ((butPtr = find_region_by_code(basecode + code)) == 0) {
butPtr = dlg_malloc(mseRegion, 1);
assert_ptr(butPtr, "dlg_mouse_mkregion");
butPtr->next = regionList;
@ -93,7 +99,7 @@ dlg_mouse_mkregion(int y, int x, int height, int width, int code)
butPtr->Y = basey + y + height;
butPtr->x = basex + x;
butPtr->X = basex + x + width;
butPtr->code = code;
butPtr->code = basecode + code;
}
return butPtr;
}
@ -105,12 +111,15 @@ any_mouse_region(int y, int x, int small)
mseRegion *butPtr;
for (butPtr = regionList; butPtr; butPtr = butPtr->next) {
if (small ^ (butPtr->code >= 0))
if (small ^ (butPtr->code >= 0)) {
continue;
if (y < butPtr->y || y >= butPtr->Y)
}
if (y < butPtr->y || y >= butPtr->Y) {
continue;
if (x < butPtr->x || x >= butPtr->X)
}
if (x < butPtr->x || x >= butPtr->X) {
continue;
}
break; /* found */
}
return butPtr;

View File

@ -1,9 +1,9 @@
/*
* $Id: mousewget.c,v 1.21 2008/03/16 20:09:03 tom Exp $
* $Id: mousewget.c,v 1.22 2012/11/30 10:23:49 tom Exp $
*
* mousewget.c -- mouse/wgetch support for dialog
*
* Copyright 2000-2006,2008 Thomas E. Dickey
* Copyright 2000-2008,2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -37,7 +37,7 @@ mouse_wgetch(WINDOW *win, int *fkey, bool ignore_errs)
#if USE_MOUSE
mouse_err = FALSE;
if (fkey && (key == KEY_MOUSE)) {
if (key == KEY_MOUSE) {
MEVENT event;
mseRegion *p;

View File

@ -1,9 +1,9 @@
/*
* $Id: msgbox.c,v 1.66 2011/06/27 08:36:28 tom Exp $
* $Id: msgbox.c,v 1.75 2012/12/01 01:48:08 tom Exp $
*
* msgbox.c -- implements the message box and info box
*
* Copyright 2000-2010,2011 Thomas E. Dickey
* Copyright 2000-2011,2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -39,20 +39,14 @@ dialog_msgbox(const char *title, const char *cprompt, int height, int width,
static DLG_KEYS_BINDING binding[] = {
HELPKEY_BINDINGS,
ENTERKEY_BINDINGS,
DLG_KEYS_DATA( DLGK_ENTER, ' ' ),
TRAVERSE_BINDINGS,
SCROLLKEY_BINDINGS,
DLG_KEYS_DATA( DLGK_FIELD_NEXT, KEY_DOWN ),
DLG_KEYS_DATA( DLGK_FIELD_NEXT, KEY_RIGHT ),
DLG_KEYS_DATA( DLGK_FIELD_NEXT, TAB ),
DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_UP ),
DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_BTAB ),
DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_LEFT ),
END_KEYS_BINDING
};
/* *INDENT-ON* */
int x, y, last = 0, page;
int button = 0;
int button;
int key = 0, fkey;
int result = DLG_EXIT_UNKNOWN;
WINDOW *dialog = 0;
@ -62,10 +56,18 @@ dialog_msgbox(const char *title, const char *cprompt, int height, int width,
int check;
bool show = TRUE;
int min_width = (pauseopt == 1 ? 12 : 0);
int save_nocancel = dialog_vars.nocancel;
#ifdef KEY_RESIZE
int req_high;
int req_wide;
#endif
dialog_vars.nocancel = TRUE;
button = dlg_default_button();
#ifdef KEY_RESIZE
int req_high = height;
int req_wide = width;
req_high = height;
req_wide = width;
restart:
#endif
@ -95,13 +97,13 @@ dialog_msgbox(const char *title, const char *cprompt, int height, int width,
dlg_mouse_setbase(x, y);
dlg_draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
dlg_draw_box2(dialog, 0, 0, height, width, dialog_attr, border_attr, border2_attr);
dlg_draw_title(dialog, title);
wattrset(dialog, dialog_attr);
(void) wattrset(dialog, dialog_attr);
if (pauseopt) {
dlg_draw_bottom_box(dialog);
dlg_draw_bottom_box2(dialog, border_attr, border2_attr, dialog_attr);
mouse_mkbutton(height - 2, width / 2 - 4, 6, '\n');
dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width);
dlg_draw_helpline(dialog, FALSE);
@ -110,6 +112,7 @@ dialog_msgbox(const char *title, const char *cprompt, int height, int width,
if (show) {
last = dlg_print_scrolled(dialog, prompt, offset,
page, width, pauseopt);
dlg_trace_win(dialog);
show = FALSE;
}
key = dlg_mouse_wgetch(dialog, &fkey);
@ -117,7 +120,7 @@ dialog_msgbox(const char *title, const char *cprompt, int height, int width,
break;
if (!fkey && (check = dlg_char_to_button(key, buttons)) >= 0) {
result = check ? DLG_EXIT_HELP : DLG_EXIT_OK;
result = dlg_ok_buttoncode(check);
break;
}
@ -150,22 +153,21 @@ dialog_msgbox(const char *title, const char *cprompt, int height, int width,
FALSE, width);
break;
case DLGK_ENTER:
result = button ? DLG_EXIT_HELP : DLG_EXIT_OK;
break;
case DLGK_MOUSE(0):
result = DLG_EXIT_OK;
break;
case DLGK_MOUSE(1):
result = DLG_EXIT_HELP;
result = dlg_ok_buttoncode(button);
break;
default:
if (dlg_check_scrolled(key,
last,
page,
&show,
&offset) == 0)
break;
beep();
if (is_DLGK_MOUSE(key)) {
result = dlg_ok_buttoncode(key - M_EVENT);
if (result < 0)
result = DLG_EXIT_OK;
} else if (dlg_check_scrolled(key,
last,
page,
&show,
&offset) == 0) {
} else {
beep();
}
break;
}
} else {
@ -176,11 +178,15 @@ dialog_msgbox(const char *title, const char *cprompt, int height, int width,
dlg_print_scrolled(dialog, prompt, offset, page, width, pauseopt);
dlg_draw_helpline(dialog, FALSE);
wrefresh(dialog);
dlg_trace_win(dialog);
result = DLG_EXIT_OK;
}
dlg_del_window(dialog);
dlg_mouse_free_regions();
free(prompt);
dialog_vars.nocancel = save_nocancel;
return result;
}

View File

@ -1,3 +1,58 @@
cdialog (20130523) unstable; urgency=low
* minor fixes
-- Thomas E. Dickey <dickey@invisible-island.net> Thu, 23 May 2013 19:25:01 -0400
cdialog (20130315) unstable; urgency=low
* minor fixes
-- Thomas E. Dickey <dickey@invisible-island.net> Fri, 15 Mar 2013 04:41:20 -0400
cdialog (20121230) unstable; urgency=low
* new widgets
* coverity fixes
* configure-script updates
-- Thomas E. Dickey <dickey@invisible-island.net> Sat, 06 Oct 2012 09:19:29 -0400
cdialog (20120706) unstable; urgency=high
* fix regression in msgbox (ArchLinux #30574)
-- Thomas E. Dickey <dickey@invisible-island.net> Fri, 06 Jul 2012 12:52:46 -0400
cdialog (20120703) unstable; urgency=low
* minor fixes
* add --default-button
-- Thomas E. Dickey <dickey@invisible-island.net> Sat, 30 Jun 2012 10:41:05 -0400
cdialog (20120215) unstable; urgency=low
* minor fixes
-- Thomas E. Dickey <dickey@invisible-island.net> Wed, 15 Feb 2012 19:40:32 -0500
cdialog (20111020) unstable; urgency=high
* fix regression in menubox.c logic for inputmenu vs menu.
-- Thomas E. Dickey <dickey@invisible-island.net> Wed, 19 Oct 2011 19:17:40 -0400
cdialog (20111018) unstable; urgency=high
* improve color configurability
* misc bug-fixes.
* various improvements to tracing.
* remove an incorrect free() call in dlg_free_gauge()
* fix missing trailing null from dlg_align_columns
-- Thomas E. Dickey <dickey@invisible-island.net> Wed, 07 Sep 2011 20:04:04 -0400
cdialog (20110707) unstable; urgency=high
* fix a regression in dlg_getc() from 20110630 changes.

View File

@ -1,9 +1,9 @@
Summary: dialog - display dialog boxes from shell scripts
%define AppProgram dialog
%define AppVersion 1.1
%define AppRelease 20110707
%define AppVersion 1.2
%define AppRelease 20130523
%define ActualProg c%{AppProgram}
# $XTermId: dialog.spec,v 1.24 2011/07/07 22:10:02 tom Exp $
# $XTermId: dialog.spec,v 1.50 2013/05/24 00:13:31 tom Exp $
Name: %{ActualProg}
Version: %{AppVersion}
Release: %{AppRelease}
@ -28,6 +28,8 @@ compiled into dialog):
This package installs as "cdialog" to avoid conflict with other packages.
%prep
%define debug_package %{nil}
%setup -q -n %{AppProgram}-%{AppVersion}-%{AppRelease}
%build
@ -53,8 +55,11 @@ make
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
make install-full DESTDIR=$RPM_BUILD_ROOT
libtool --finish %{_libdir}
strip $RPM_BUILD_ROOT%{_bindir}/%{ActualProg}
chmod 755 $RPM_BUILD_ROOT%{_libdir}/lib%{ActualProg}.so.*.*.*
rm -f $RPM_BUILD_ROOT%{_libdir}/lib%{ActualProg}.la
%clean
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
@ -75,5 +80,8 @@ strip $RPM_BUILD_ROOT%{_bindir}/%{ActualProg}
%changelog
# each patch should add its ChangeLog entries here
* Tue Oct 18 2011 Thomas Dickey
- add executable permissions for shared libraries, discard ".la" file.
* Thu Dec 30 2010 Thomas Dickey
- initial version

View File

@ -1,9 +1,9 @@
/*
* $Id: pause.c,v 1.29 2011/06/29 09:48:53 tom Exp $
* $Id: pause.c,v 1.36 2012/07/03 00:01:59 tom Exp $
*
* pause.c -- implements the pause dialog
*
* Copyright 2004-2010,2011 Thomas E. Dickey
* Copyright 2004-2011,2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -55,13 +55,7 @@ dialog_pause(const char *title,
static DLG_KEYS_BINDING binding[] = {
HELPKEY_BINDINGS,
ENTERKEY_BINDINGS,
DLG_KEYS_DATA( DLGK_ENTER, ' ' ),
DLG_KEYS_DATA( DLGK_FIELD_NEXT, KEY_DOWN ),
DLG_KEYS_DATA( DLGK_FIELD_NEXT, KEY_RIGHT ),
DLG_KEYS_DATA( DLGK_FIELD_NEXT, TAB ),
DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_UP ),
DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_BTAB ),
DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_LEFT ),
TRAVERSE_BINDINGS,
END_KEYS_BINDING
};
/* *INDENT-ON* */
@ -72,21 +66,24 @@ dialog_pause(const char *title,
#endif
int i, x, y, step;
int button = 0;
int button = dlg_default_button();
int seconds_orig;
WINDOW *dialog;
const char **buttons = dlg_ok_labels();
bool have_buttons = (dlg_button_count(buttons) != 0);
bool first;
int key = 0, fkey;
int result = DLG_EXIT_UNKNOWN;
int button_high = (have_buttons ? BTN_HIGH : MARGIN);
int gauge_y;
char *prompt = dlg_strclone(cprompt);
int save_timeout = dialog_vars.timeout_secs;
curs_set(0);
dlg_tab_correct_str(prompt);
dialog_vars.timeout_secs = 0;
seconds_orig = (seconds > 0) ? seconds : 1;
#ifdef KEY_RESIZE
@ -120,21 +117,23 @@ dialog_pause(const char *title,
dlg_mouse_setbase(x, y);
nodelay(dialog, TRUE);
first = TRUE;
do {
(void) werase(dialog);
dlg_draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
dlg_draw_box2(dialog, 0, 0, height, width, dialog_attr, border_attr, border2_attr);
dlg_draw_title(dialog, title);
dlg_draw_helpline(dialog, FALSE);
wattrset(dialog, dialog_attr);
(void) wattrset(dialog, dialog_attr);
dlg_print_autowrap(dialog, prompt, height, width);
dlg_draw_box(dialog,
gauge_y, 2 + MARGIN,
2 + MARGIN, width - 2 * (2 + MARGIN),
dialog_attr,
border_attr);
dlg_draw_box2(dialog,
gauge_y, 2 + MARGIN,
2 + MARGIN, width - 2 * (2 + MARGIN),
dialog_attr,
border_attr,
border2_attr);
/*
* Clear the area for the progress bar by filling it with spaces
@ -142,7 +141,7 @@ dialog_pause(const char *title,
* attribute.
*/
(void) wmove(dialog, gauge_y + MARGIN, 4);
wattrset(dialog, title_attr);
(void) wattrset(dialog, title_attr);
for (i = 0; i < (width - 2 * (3 + MARGIN)); i++)
(void) waddch(dialog, ' ');
@ -159,7 +158,7 @@ dialog_pause(const char *title,
if ((title_attr & A_REVERSE) != 0) {
wattroff(dialog, A_REVERSE);
} else {
wattrset(dialog, A_REVERSE);
(void) wattrset(dialog, A_REVERSE);
}
(void) wmove(dialog, gauge_y + MARGIN, 4);
for (i = 0; i < x; i++) {
@ -172,10 +171,14 @@ dialog_pause(const char *title,
mouse_mkbutton(height - 2, width / 2 - 4, 6, '\n');
if (have_buttons) {
dlg_draw_bottom_box(dialog);
dlg_draw_bottom_box2(dialog, border_attr, border2_attr, dialog_attr);
dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width);
}
(void) wrefresh(dialog);
if (first) {
(void) wrefresh(dialog);
dlg_trace_win(dialog);
first = FALSE;
}
for (step = 0;
(result == DLG_EXIT_UNKNOWN) && (step < 1000);
@ -219,24 +222,25 @@ dialog_pause(const char *title,
case DLGK_ENTER:
result = dlg_enter_buttoncode(button);
break;
case DLGK_MOUSE(0):
result = DLG_EXIT_OK;
break;
case DLGK_MOUSE(1):
result = DLG_EXIT_CANCEL;
break;
case ERR:
break;
default:
if (is_DLGK_MOUSE(key)) {
result = dlg_ok_buttoncode(key - M_EVENT);
if (result < 0)
result = DLG_EXIT_OK;
}
break;
}
}
} while ((result == DLG_EXIT_UNKNOWN) && (seconds-- > 0));
nodelay(dialog, FALSE);
curs_set(1);
dlg_mouse_free_regions();
dlg_del_window(dialog);
free(prompt);
dialog_vars.timeout_secs = save_timeout;
return ((result == DLG_EXIT_UNKNOWN) ? DLG_EXIT_OK : result);
}

111
contrib/dialog/po/an.po Normal file
View File

@ -0,0 +1,111 @@
# Dialog
# Copyright 2003-2007,2008 # Thomas Dickey
# This file is distributed under the same license as the dialog package.
# Daniel Martinez <entaltoaragon@gmail.com>, 2013.
msgid ""
msgstr ""
"Project-Id-Version: dialog 1.1.20080819\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-06-18 18:26-0400\n"
"PO-Revision-Date: 2013-02-19 17:50+0100\n"
"Last-Translator: Daniel Martinez <entaltoaragon@gmail.com>\n"
"Language-Team: Aragonese <softaragones@googlegroups.com>\n"
"Language: an\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: buttons.c:385
msgid "Yes"
msgstr "Sí"
#: buttons.c:393
msgid "No"
msgstr "No"
#: buttons.c:401
msgid "OK"
msgstr "Acceptar"
#: buttons.c:409
msgid "Cancel"
msgstr "Cancelar"
#: buttons.c:417
msgid "EXIT"
msgstr "Salir"
#: buttons.c:425
msgid "Extra"
msgstr "Extra"
#: buttons.c:433
msgid "Help"
msgstr "Aduya"
#. Headline "Month"
#: calendar.c:273
msgid "Month"
msgstr "Mes"
#. Headline "Year"
#: calendar.c:293
msgid "Year"
msgstr "Anyo"
#: dialog.c:741
msgid "Rename"
msgstr "Renombrar"
#: fselect.c:550
msgid "Directories"
msgstr "Directorios"
#: fselect.c:551
msgid "Files"
msgstr "Fichers"
#: mixedgauge.c:58
msgid "Succeeded"
msgstr "Finalizau con exito"
#: mixedgauge.c:61
msgid "Failed"
msgstr "Falló"
#: mixedgauge.c:64
msgid "Passed"
msgstr "Pasau"
#: mixedgauge.c:67
msgid "Completed"
msgstr "Completau"
#: mixedgauge.c:70
msgid "Checked"
msgstr "Comprebau"
#: mixedgauge.c:73
msgid "Done"
msgstr "Feito"
#: mixedgauge.c:76
msgid "Skipped"
msgstr "Blincau"
#: mixedgauge.c:79
msgid "In Progress"
msgstr "En progreso"
#: mixedgauge.c:85
msgid "N/A"
msgstr "N/A"
#: mixedgauge.c:193
msgid "Overall Progress"
msgstr "Progreso total"
#: textbox.c:489
msgid "Search"
msgstr "Buscar"

View File

@ -1,15 +1,23 @@
# From: Martin Povolny <martin@solnet.cz>
# Czech translations for dialog package.
# Copyright (C) 2011 THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the dialog package.
#
# Martin Povolny <martin@solnet.cz>
# Marek Černocký <marek@manet.cz>, 2011.
#
msgid ""
msgstr ""
"Project-Id-Version: dialog 0.9a-20010527\n"
"Project-Id-Version: dialog 1.1.20080819\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-06-18 18:26-0400\n"
"PO-Revision-Date: 2004-12-19 20:14-0500\n"
"Last-Translator: Martin Povolny <martin@solnet.cz>\n"
"Language-Team:\n"
"PO-Revision-Date: 2011-11-25 13:18+0100\n"
"Last-Translator: Marek Černocký <marek@manet.cz>\n"
"Language-Team: Czech <translation-team-cs@lists.sourceforge.net>\n"
"Language: cs\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8-bit\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
#: buttons.c:385
msgid "Yes"
@ -21,7 +29,7 @@ msgstr "Ne"
#: buttons.c:401
msgid "OK"
msgstr "OK"
msgstr "Budiž"
#: buttons.c:409
msgid "Cancel"
@ -33,11 +41,11 @@ msgstr "Konec"
#: buttons.c:425
msgid "Extra"
msgstr ""
msgstr "Další"
#: buttons.c:433
msgid "Help"
msgstr ""
msgstr "Nápověda"
#. Headline "Month"
#: calendar.c:273
@ -51,11 +59,11 @@ msgstr "Rok"
#: dialog.c:741
msgid "Rename"
msgstr ""
msgstr "Přejmenovat"
#: fselect.c:550
msgid "Directories"
msgstr "Adresáře"
msgstr "Složky"
#: fselect.c:551
msgid "Files"
@ -63,46 +71,44 @@ msgstr "Soubory"
#: mixedgauge.c:58
msgid "Succeeded"
msgstr ""
msgstr "Úspěšné"
#: mixedgauge.c:61
#, fuzzy
msgid "Failed"
msgstr "Soubory"
msgstr "Selhalo"
#: mixedgauge.c:64
msgid "Passed"
msgstr ""
msgstr "Pozastaveno"
#: mixedgauge.c:67
msgid "Completed"
msgstr ""
msgstr "Dokončeno"
#: mixedgauge.c:70
msgid "Checked"
msgstr ""
msgstr "Zkontrolováno"
#: mixedgauge.c:73
msgid "Done"
msgstr ""
msgstr "Hotovo"
#: mixedgauge.c:76
msgid "Skipped"
msgstr ""
msgstr "Přeskočeno"
#: mixedgauge.c:79
msgid "In Progress"
msgstr ""
msgstr "Probíhá"
#: mixedgauge.c:85
msgid "N/A"
msgstr ""
msgstr "Není známo"
#: mixedgauge.c:193
msgid "Overall Progress"
msgstr ""
msgstr "Celkový průběh"
#: textbox.c:489
#, fuzzy
msgid "Search"
msgstr "Search"
msgstr "Hledat"

View File

@ -1,14 +1,20 @@
# Greek translation for dialog.
# This file is distributed under the same license as the dialog package.
# Copyright (C) 2008 Free Software Foundation, Inc.
# Savvas Radevic <vicedar@gmail.com>, 2012.
#
msgid ""
msgstr ""
"Project-Id-Version: Dialog\n"
"Project-Id-Version: dialog 1.1.20080819\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-06-18 18:26-0400\n"
"PO-Revision-Date: 2002-06-05 10:00GMT+2\n"
"Last-Translator: kromJx <kromJx@crosswinds.net>\n"
"Language-Team: <i18ngr@hellug.gr>\n"
"PO-Revision-Date: 2012-03-18 00:54+0100\n"
"Last-Translator: Savvas Radevic <vicedar@gmail.com>\n"
"Language-Team: Greek <team@lists.gnome.gr>\n"
"Language: el\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8-bit\n"
"Content-Transfer-Encoding: 8bit\n"
#: buttons.c:385
msgid "Yes"
@ -20,7 +26,7 @@ msgstr "Όχι"
#: buttons.c:401
msgid "OK"
msgstr "OK"
msgstr "Εντάξει"
#: buttons.c:409
msgid "Cancel"
@ -32,7 +38,7 @@ msgstr "Έξοδος"
#: buttons.c:425
msgid "Extra"
msgstr ""
msgstr "Πρόσθετα"
#: buttons.c:433
msgid "Help"
@ -50,7 +56,7 @@ msgstr "Έτος"
#: dialog.c:741
msgid "Rename"
msgstr ""
msgstr "Μετονομασία"
#: fselect.c:550
msgid "Directories"
@ -62,46 +68,44 @@ msgstr "Αρχεία"
#: mixedgauge.c:58
msgid "Succeeded"
msgstr ""
msgstr "Επιτυχία"
#: mixedgauge.c:61
#, fuzzy
msgid "Failed"
msgstr "Αρχεία"
msgstr "Αποτυχία"
#: mixedgauge.c:64
msgid "Passed"
msgstr ""
msgstr "Πέρασε"
#: mixedgauge.c:67
msgid "Completed"
msgstr ""
msgstr "Ολοκλήρωση"
#: mixedgauge.c:70
msgid "Checked"
msgstr ""
msgstr "Έλεγχος"
#: mixedgauge.c:73
msgid "Done"
msgstr ""
msgstr "Τέλος"
#: mixedgauge.c:76
msgid "Skipped"
msgstr ""
msgstr "Παράλειψη"
#: mixedgauge.c:79
msgid "In Progress"
msgstr ""
msgstr "Σε εξέλιξη"
#: mixedgauge.c:85
msgid "N/A"
msgstr ""
msgstr "Μη Διαθέσιμο"
#: mixedgauge.c:193
msgid "Overall Progress"
msgstr ""
msgstr "Συνολική πρόοδος"
#: textbox.c:489
#, fuzzy
msgid "Search"
msgstr "Search"
msgstr "Αναζήτηση"

View File

@ -1,68 +1,76 @@
# Galician translation of dialog
# This file is distributed under the same license as the dialog package.
# Mensaxes en galego para dialog.
# Copyright 2003-2006,2007 Thomas Dickey
# Copyright 2003-2006, 2007 Thomas Dickey
# Copyright 2012 Leandro Regueiro
#
# Diego Pérez Montes <kabute@gulo.org>, 2008
# Leandro Regueiro <leandro.regueiro@gmail.com>, 2012.
#
# Proxecto Trasno - Adaptación do software libre á lingua galega: Se desexas
# colaborar connosco, podes atopar máis información en <http://www.trasno.net>
#
msgid ""
msgstr ""
"Project-Id-Version: dialog 1.1.20070704\n"
"Project-Id-Version: dialog 1.1.20080819\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-01-16 17:57-0500\n"
"PO-Revision-Date: 2008-05-13 23:57+0100\n"
"Last-Translator: Diego Pérez Montes <kabute@gulo.org>\n"
"POT-Creation-Date: 2008-06-18 18:26-0400\n"
"PO-Revision-Date: 2012-11-10 13:53+0200\n"
"Last-Translator: Leandro Regueiro <leandro.regueiro@gmail.com>\n"
"Language-Team: Galician <proxecto@trasno.net>\n"
"Language: gl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Virtaal 0.7.0\n"
#: buttons.c:387
#: buttons.c:385
msgid "Yes"
msgstr "Sí"
msgstr "Si"
#: buttons.c:395
#: buttons.c:393
msgid "No"
msgstr "Non"
#: buttons.c:403
#: buttons.c:401
msgid "OK"
msgstr "Aceptar"
#: buttons.c:411
#: buttons.c:409
msgid "Cancel"
msgstr "Cancelar"
#: buttons.c:419
#: buttons.c:417
msgid "EXIT"
msgstr "SAÍR"
#: buttons.c:427
#: buttons.c:425
msgid "Extra"
msgstr "Suplementario"
msgstr "Extra"
#: buttons.c:435
#: buttons.c:433
msgid "Help"
msgstr "Axuda"
#. Headline "Month"
#: calendar.c:298
#: calendar.c:273
msgid "Month"
msgstr "Mes"
#. Headline "Year"
#: calendar.c:318
#: calendar.c:293
msgid "Year"
msgstr "Ano"
#: dialog.c:756
#: dialog.c:741
msgid "Rename"
msgstr "Renomear"
#: fselect.c:571
#: fselect.c:550
msgid "Directories"
msgstr "Directorios"
#: fselect.c:572
#: fselect.c:551
msgid "Files"
msgstr "Ficheiros"
@ -96,16 +104,16 @@ msgstr "Omitido"
#: mixedgauge.c:79
msgid "In Progress"
msgstr "En Progreso"
msgstr "En progreso"
#: mixedgauge.c:85
msgid "N/A"
msgstr "Non Dispoñible"
msgstr "Non dispoñíbel"
#: mixedgauge.c:193
msgid "Overall Progress"
msgstr "Progreso Total"
msgstr "Progreso total"
#: textbox.c:468
#: textbox.c:489
msgid "Search"
msgstr "Procurar"
msgstr "Buscar"

View File

@ -1,110 +1,112 @@
# Croatian translation of Dialog.
# Dialog
# Copyright 2003-2007,2008 # Thomas Dickey
# This file is distributed under the same license as the dialog package.
# Copyright (C) 2005 Thomas Dickey.
# Tomislav Krznar <tomislav.krznar@gmail.com>, 2012.
#
msgid ""
msgstr ""
"Project-Id-Version: Dialog 1.0-20050116\n"
"Project-Id-Version: dialog 1.1.20080819\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-01-16 17:57-0500\n"
"PO-Revision-Date: 2004-07-25 14:52+0200\n"
"Last-Translator: Krunoslav Gernhard <kruno@linux.hr>\n"
"POT-Creation-Date: 2008-06-18 18:26-0400\n"
"PO-Revision-Date: 2012-03-31 00:10+0200\n"
"Last-Translator: Tomislav Krznar <tomislav.krznar@gmail.com>\n"
"Language-Team: Croatian <lokalizacija@linux.hr>\n"
"Language: hr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
#: buttons.c:387
#: buttons.c:385
msgid "Yes"
msgstr "Da"
#: buttons.c:395
#: buttons.c:393
msgid "No"
msgstr "Ne"
#: buttons.c:403
#: buttons.c:401
msgid "OK"
msgstr "U redu"
#: buttons.c:411
#: buttons.c:409
msgid "Cancel"
msgstr "Otkaži"
#: buttons.c:419
#: buttons.c:417
msgid "EXIT"
msgstr ""
msgstr "IZLAZ"
#: buttons.c:427
#: buttons.c:425
msgid "Extra"
msgstr ""
msgstr "Dodatno"
#: buttons.c:435
#: buttons.c:433
msgid "Help"
msgstr ""
msgstr "Pomoć"
#. Headline "Month"
#: calendar.c:298
#: calendar.c:273
msgid "Month"
msgstr ""
msgstr "Mjesec"
#. Headline "Year"
#: calendar.c:318
#: calendar.c:293
msgid "Year"
msgstr ""
msgstr "Godina"
#: dialog.c:756
#: dialog.c:741
msgid "Rename"
msgstr ""
msgstr "Preimenuj"
#: fselect.c:571
#: fselect.c:550
msgid "Directories"
msgstr ""
msgstr "Direktoriji"
#: fselect.c:572
#: fselect.c:551
msgid "Files"
msgstr ""
msgstr "Datoteke"
#: mixedgauge.c:58
msgid "Succeeded"
msgstr ""
msgstr "Uspjeh"
#: mixedgauge.c:61
msgid "Failed"
msgstr ""
msgstr "Neuspjeh"
#: mixedgauge.c:64
msgid "Passed"
msgstr ""
msgstr "Prošlo"
#: mixedgauge.c:67
msgid "Completed"
msgstr ""
msgstr "Dovršeno"
#: mixedgauge.c:70
msgid "Checked"
msgstr ""
msgstr "Provjereno"
#: mixedgauge.c:73
msgid "Done"
msgstr ""
msgstr "Gotovo"
#: mixedgauge.c:76
msgid "Skipped"
msgstr ""
msgstr "Preskočeno"
#: mixedgauge.c:79
msgid "In Progress"
msgstr ""
msgstr "U tijeku"
#: mixedgauge.c:85
msgid "N/A"
msgstr ""
msgstr "Nedostupno"
#: mixedgauge.c:193
msgid "Overall Progress"
msgstr ""
msgstr "Ukupni napredak"
#: textbox.c:468
#: textbox.c:489
msgid "Search"
msgstr ""
msgstr "Pretraga"

111
contrib/dialog/po/ia.po Normal file
View File

@ -0,0 +1,111 @@
# Interlingua translation of Dialog
# Copyright (C) 2012 Free Software Foundation, Inc.
# This file is distributed under the same license as the dialog package.
# Nik Kalach <nik.kalach@inbox.ru>, 2012.
#
msgid ""
msgstr ""
"Project-Id-Version: dialog 1.1.20080819\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-06-18 18:26-0400\n"
"PO-Revision-Date: 2012-12-04 00:56+0400\n"
"Last-Translator: Nik Kalach <nik.kalach@inbox.ru>\n"
"Language-Team: Interlingua <translation-team-ia@lists.sourceforge.net>\n"
"Language: ia\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: buttons.c:385
msgid "Yes"
msgstr "Si"
#: buttons.c:393
msgid "No"
msgstr "No"
#: buttons.c:401
msgid "OK"
msgstr "OK"
#: buttons.c:409
msgid "Cancel"
msgstr "Annullar"
#: buttons.c:417
msgid "EXIT"
msgstr "SORTIR"
#: buttons.c:425
msgid "Extra"
msgstr "Extra"
#: buttons.c:433
msgid "Help"
msgstr "Adjuta"
#. Headline "Month"
#: calendar.c:273
msgid "Month"
msgstr "Mense"
#. Headline "Year"
#: calendar.c:293
msgid "Year"
msgstr "Anno"
#: dialog.c:741
msgid "Rename"
msgstr "Renominar"
#: fselect.c:550
msgid "Directories"
msgstr "Directorios"
#: fselect.c:551
msgid "Files"
msgstr "Files"
#: mixedgauge.c:58
msgid "Succeeded"
msgstr "Succedite"
#: mixedgauge.c:61
msgid "Failed"
msgstr "Fallite"
#: mixedgauge.c:64
msgid "Passed"
msgstr "Passate"
#: mixedgauge.c:67
msgid "Completed"
msgstr "Completate"
#: mixedgauge.c:70
msgid "Checked"
msgstr "Controlate"
#: mixedgauge.c:73
msgid "Done"
msgstr "Facite"
#: mixedgauge.c:76
msgid "Skipped"
msgstr "Saltate"
#: mixedgauge.c:79
msgid "In Progress"
msgstr "In curso"
#: mixedgauge.c:85
msgid "N/A"
msgstr "N/A"
#: mixedgauge.c:193
msgid "Overall Progress"
msgstr "Progresso general"
#: textbox.c:489
msgid "Search"
msgstr "Cerca"

View File

@ -1,18 +1,21 @@
# Serbian translation of `dialog'.
# Serbian translation of dialog.
# Copyright (C) 2005 Free Software Foundation, Inc.
# This file is distributed under the same license as the `dialog' package.
# This file is distributed under the same license as the dialog package.
# Aleksandar Jelenak <jelenak@verizon.net>, 2005.
# Мирослав Николић <miroslavnikolic@rocketmail.com>, 2011.
msgid ""
msgstr ""
"Project-Id-Version: dialog 1.0-rel20041222\n"
"Project-Id-Version: dialog-1.1.20080819\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-06-18 18:26-0400\n"
"PO-Revision-Date: 2005-08-21 12:53-0400\n"
"Last-Translator: Aleksandar Jelenak <jelenak@verizon.net>\n"
"PO-Revision-Date: 2011-12-24 21:29+0200\n"
"Last-Translator: Мирослав Николић <miroslavnikolic@rocketmail.com>\n"
"Language-Team: Serbian <gnu@prevod.org>\n"
"Language: sr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
#: buttons.c:385
msgid "Yes"
@ -66,44 +69,43 @@ msgstr "Датотеке"
#: mixedgauge.c:58
msgid "Succeeded"
msgstr ""
msgstr "Успешно"
#: mixedgauge.c:61
#, fuzzy
msgid "Failed"
msgstr "Датотеке"
msgstr "Неуспешно"
#: mixedgauge.c:64
msgid "Passed"
msgstr ""
msgstr "Прошло"
#: mixedgauge.c:67
msgid "Completed"
msgstr ""
msgstr "Завршено"
#: mixedgauge.c:70
msgid "Checked"
msgstr ""
msgstr "Проверено"
#: mixedgauge.c:73
msgid "Done"
msgstr ""
msgstr "Урађено"
#: mixedgauge.c:76
msgid "Skipped"
msgstr ""
msgstr "Прескочено"
#: mixedgauge.c:79
msgid "In Progress"
msgstr ""
msgstr "У току"
#: mixedgauge.c:85
msgid "N/A"
msgstr ""
msgstr "Н"
#: mixedgauge.c:193
msgid "Overall Progress"
msgstr ""
msgstr "Укупно напредовање"
#: textbox.c:489
msgid "Search"

View File

@ -1,15 +1,15 @@
# Traditional Chinese Messages for dialog.
# Copyright (C) 2005 Free Software Foundation, Inc.
# This file is distributed under the same license as the dialog package.
# Wei-Lun Chao <chaoweilun@gmail.com>, 2005, 2007.
# Wei-Lun Chao <bluebat@member.fsf.org>, 2005, 2007, 2013.
#
msgid ""
msgstr ""
"Project-Id-Version: dialog 1.1.20070704\n"
"Project-Id-Version: dialog 1.1.20080819\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-01-16 17:57-0500\n"
"PO-Revision-Date: 2007-12-19 23:39+0800\n"
"Last-Translator: Wei-Lun Chao <chaoweilun@gmail.com>\n"
"POT-Creation-Date: 2008-06-18 18:26-0400\n"
"PO-Revision-Date: 2013-02-12 23:39+0800\n"
"Last-Translator: Wei-Lun Chao <bluebat@member.fsf.org>\n"
"Language-Team: Chinese (traditional) <zh-l10n@linux.org.tw>\n"
"Language: zh_TW\n"
"MIME-Version: 1.0\n"
@ -17,53 +17,53 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: buttons.c:387
#: buttons.c:385
msgid "Yes"
msgstr "是"
#: buttons.c:395
#: buttons.c:393
msgid "No"
msgstr "否"
#: buttons.c:403
#: buttons.c:401
msgid "OK"
msgstr "確定"
#: buttons.c:411
#: buttons.c:409
msgid "Cancel"
msgstr "取消"
#: buttons.c:419
#: buttons.c:417
msgid "EXIT"
msgstr "離開"
#: buttons.c:427
#: buttons.c:425
msgid "Extra"
msgstr "其他"
#: buttons.c:435
#: buttons.c:433
msgid "Help"
msgstr "求助"
#. Headline "Month"
#: calendar.c:298
#: calendar.c:273
msgid "Month"
msgstr "月"
#. Headline "Year"
#: calendar.c:318
#: calendar.c:293
msgid "Year"
msgstr "年"
#: dialog.c:756
#: dialog.c:741
msgid "Rename"
msgstr "更名"
#: fselect.c:571
#: fselect.c:550
msgid "Directories"
msgstr "目錄"
#: fselect.c:572
#: fselect.c:551
msgid "Files"
msgstr "檔案"
@ -107,6 +107,6 @@ msgstr "不明"
msgid "Overall Progress"
msgstr "整體進度"
#: textbox.c:468
#: textbox.c:489
msgid "Search"
msgstr "搜尋"

View File

@ -1,9 +1,9 @@
/*
* $Id: prgbox.c,v 1.7 2011/06/30 20:44:13 tom Exp $
* $Id: prgbox.c,v 1.9 2012/12/02 23:40:30 tom Exp $
*
* prgbox.c -- implements the prg box
*
* Copyright 2011 Thomas E. Dickey
* Copyright 2011,2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -23,6 +23,12 @@
#include <dialog.h>
static void
reapchild(int sig)
{
(void) sig;
}
/*
* Open a pipe which ties stderr and stdout together.
*/
@ -31,11 +37,11 @@ dlg_popen(const char *command, const char *type)
{
FILE *result = 0;
int fd[2];
int pid;
const char *argv[4];
char *blob;
char **argv;
if ((*type == 'r' || *type != 'w') && pipe(fd) == 0) {
switch (pid = fork()) {
switch (fork()) {
case -1: /* Error. */
(void) close(fd[0]);
(void) close(fd[1]);
@ -61,11 +67,11 @@ dlg_popen(const char *command, const char *type)
* given command. Also, it needs the command to be parsed into
* tokens.
*/
argv[0] = "sh";
argv[1] = "-c";
argv[2] = command;
argv[3] = NULL;
execvp("sh", (char **)argv);
if ((blob = malloc(4 + strlen(command))) != 0) {
sprintf(blob, "-c %s", command);
argv = dlg_string_to_argv(blob);
execvp("sh", argv);
}
_exit(127);
/* NOTREACHED */
default: /* parent */
@ -96,6 +102,7 @@ dialog_prgbox(const char *title,
{
int code;
FILE *fp;
void (*oldreaper) (int) = signal(SIGCHLD, reapchild);
fp = dlg_popen(command, "r");
if (fp == NULL)
@ -104,6 +111,7 @@ dialog_prgbox(const char *title,
code = dlg_progressbox(title, cprompt, height, width, pauseopt, fp);
pclose(fp);
signal(SIGCHLD, oldreaper);
return code;
}

View File

@ -1,10 +1,10 @@
/*
* $Id: progressbox.c,v 1.13 2011/06/27 08:18:20 tom Exp $
* $Id: progressbox.c,v 1.23 2012/12/21 10:00:05 tom Exp $
*
* progressbox.c -- implements the progress box
*
* Copyright 2005 Valery Reznic
* Copyright 2006-2011 Thomas E. Dickey
* Copyright 2006-2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@ -46,7 +46,7 @@ get_line(MY_OBJ * obj)
int col = 0;
int j, tmpint, ch;
while (1) {
for (;;) {
if ((ch = getc(fp)) == EOF) {
obj->is_eof = 1;
if (col) {
@ -59,20 +59,23 @@ get_line(MY_OBJ * obj)
break;
if (ch == '\r')
break;
if (col >= MAX_LEN)
continue;
if ((ch == TAB) && (dialog_vars.tab_correct)) {
tmpint = dialog_state.tab_len
- (col % dialog_state.tab_len);
for (j = 0; j < tmpint; j++) {
if (col < MAX_LEN)
if (col < MAX_LEN) {
obj->line[col] = ' ';
++col;
++col;
} else {
break;
}
}
} else {
obj->line[col] = (char) ch;
++col;
}
if (col >= MAX_LEN)
break;
}
obj->line[col] = '\0';
@ -99,6 +102,7 @@ print_line(MY_OBJ * obj, WINDOW *win, int row, int width)
#endif
getyx(win, y, x);
(void) y;
/* Clear 'residue' of previous line */
for (i = 0; i < width - x; i++)
(void) waddch(win, ' ');
@ -111,54 +115,79 @@ pause_for_ok(WINDOW *dialog, int height, int width)
static DLG_KEYS_BINDING binding[] = {
HELPKEY_BINDINGS,
ENTERKEY_BINDINGS,
DLG_KEYS_DATA( DLGK_ENTER, ' ' ),
TRAVERSE_BINDINGS,
END_KEYS_BINDING
};
/* *INDENT-ON* */
int button = 0;
int button;
int key = 0, fkey;
int result = DLG_EXIT_UNKNOWN;
const char **buttons = dlg_ok_label();
int check;
int save_nocancel = dialog_vars.nocancel;
bool redraw = TRUE;
dialog_vars.nocancel = TRUE;
button = dlg_default_button();
dlg_register_window(dialog, "progressbox", binding);
dlg_register_buttons(dialog, "progressbox", buttons);
dlg_draw_bottom_box(dialog);
dlg_draw_bottom_box2(dialog, border_attr, border2_attr, dialog_attr);
mouse_mkbutton(height - 2, width / 2 - 4, 6, '\n');
dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width);
while (result == DLG_EXIT_UNKNOWN) {
if (redraw) {
redraw = FALSE;
if (button < 0)
button = 0;
dlg_draw_buttons(dialog,
height - 2, 0,
buttons, button,
FALSE, width);
}
key = dlg_mouse_wgetch(dialog, &fkey);
if (dlg_result_key(key, fkey, &result))
break;
if (!fkey && (check = dlg_char_to_button(key, buttons)) >= 0) {
result = check ? DLG_EXIT_HELP : DLG_EXIT_OK;
result = dlg_ok_buttoncode(check);
break;
}
if (fkey) {
switch (key) {
case DLGK_FIELD_NEXT:
button = dlg_next_button(buttons, button);
redraw = TRUE;
break;
case DLGK_FIELD_PREV:
button = dlg_prev_button(buttons, button);
redraw = TRUE;
break;
case DLGK_ENTER:
result = button ? DLG_EXIT_HELP : DLG_EXIT_OK;
break;
case DLGK_MOUSE(0):
result = DLG_EXIT_OK;
break;
case DLGK_MOUSE(1):
result = DLG_EXIT_HELP;
result = dlg_ok_buttoncode(button);
break;
default:
beep();
if (is_DLGK_MOUSE(key)) {
result = dlg_ok_buttoncode(key - M_EVENT);
if (result < 0)
result = DLG_EXIT_OK;
} else {
beep();
}
break;
}
} else {
beep();
}
}
dlg_unregister_window(dialog);
dialog_vars.nocancel = save_nocancel;
return result;
}
@ -188,16 +217,17 @@ dlg_progressbox(const char *title,
dialog = dlg_new_window(height, width, y, x);
dlg_draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
dlg_draw_box2(dialog, 0, 0, height, width, dialog_attr, border_attr, border2_attr);
dlg_draw_title(dialog, title);
dlg_draw_helpline(dialog, FALSE);
if (*prompt != '\0') {
int y2, x2;
wattrset(dialog, dialog_attr);
(void) wattrset(dialog, dialog_attr);
dlg_print_autowrap(dialog, prompt, height, width);
getyx(dialog, y2, x2);
(void) x2;
++y2;
wmove(dialog, y2, MARGIN);
for (i = 0; i < getmaxx(dialog) - 2 * MARGIN; i++)
@ -236,6 +266,7 @@ dlg_progressbox(const char *title,
print_line(obj, text, thigh - 1, width - (2 * MARGIN));
}
(void) wrefresh(text);
dlg_trace_win(dialog);
if (obj->is_eof)
break;
}
@ -254,7 +285,7 @@ dlg_progressbox(const char *title,
free(prompt);
free(obj);
return DLG_EXIT_OK;
return result;
}
/*

419
contrib/dialog/rangebox.c Normal file
View File

@ -0,0 +1,419 @@
/*
* $Id: rangebox.c,v 1.17 2013/03/17 16:02:00 tom Exp $
*
* rangebox.c -- implements the rangebox dialog
*
* Copyright 2012,2013 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
* as published by the Free Software Foundation.
*
* 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to
* Free Software Foundation, Inc.
* 51 Franklin St., Fifth Floor
* Boston, MA 02110, USA.
*/
#include <dialog.h>
#include <dlg_keys.h>
#define ONE_HIGH 1
#define MIN_HIGH (ONE_HIGH + 1 + (4 * MARGIN))
#define MIN_WIDE (10 + 2 + (2 * MARGIN))
struct _box;
typedef struct _box {
WINDOW *parent;
WINDOW *window;
int x;
int y;
int width;
int height;
int period;
int value;
} BOX;
typedef struct {
/* window in which the value and slider are drawn */
WINDOW *window;
int min_value;
int max_value;
/* position and width of the numeric field */
int value_x;
int value_len;
int value_col;
/* position and width of the slider field */
int slide_x;
int slide_y;
int slide_len;
/* current value drawn */
int current;
/* value to add to make slider move by one cell */
int slide_inc;
} VALUE;
static int
digits_of(int value)
{
char temp[80];
sprintf(temp, "%d", value);
return (int) strlen(temp);
}
static int
digit_of(VALUE * data)
{
int col = data->value_col;
int result = 1;
while (++col < data->value_len) {
result *= 10;
}
return result;
}
static bool
set_digit(VALUE * data, int chr)
{
bool result = FALSE;
char buffer[80];
long check;
char *next = 0;
sprintf(buffer, "%*d", data->value_len, data->current);
buffer[data->value_col] = (char) chr;
check = strtol(buffer, &next, 10);
if (next == 0 || *next == '\0') {
if ((check <= (long) data->max_value) &&
(check >= (long) data->min_value)) {
result = TRUE;
data->current = (int) check;
}
}
return result;
}
/*
* This is similar to the gauge code, but differs in the way the number
* is displayed, etc.
*/
static void
draw_value(VALUE * data, int value)
{
if (value != data->current) {
WINDOW *win = data->window;
int y, x;
int n;
int ranges = (data->max_value + 1 - data->min_value);
int offset = (value - data->min_value);
int scaled;
getyx(win, y, x);
if (ranges > data->slide_len) {
scaled = (offset + data->slide_inc) / data->slide_inc;
} else if (ranges < data->slide_len) {
scaled = (offset + 1) * data->slide_inc;
} else {
scaled = offset;
}
(void) wattrset(win, gauge_attr);
wmove(win, data->slide_y, data->slide_x);
for (n = 0; n < data->slide_len; ++n) {
(void) waddch(win, ' ');
}
wmove(win, data->slide_y, data->value_x);
wprintw(win, "%*d", data->value_len, value);
if ((gauge_attr & A_REVERSE) != 0) {
wattroff(win, A_REVERSE);
} else {
(void) wattrset(win, A_REVERSE);
}
wmove(win, data->slide_y, data->slide_x);
for (n = 0; n < scaled; ++n) {
chtype ch2 = winch(win);
if (gauge_attr & A_REVERSE) {
ch2 &= ~A_REVERSE;
}
(void) waddch(win, ch2);
}
(void) wattrset(win, dialog_attr);
wmove(win, y, x);
data->current = value;
dlg_trace_msg("drew %d offset %d scaled %d limit %d inc %d\n",
value,
offset,
scaled,
data->slide_len,
data->slide_inc);
dlg_trace_win(win);
}
}
/*
* Allow the user to select from a range of values, e.g., using a slider.
*/
int
dialog_rangebox(const char *title,
const char *cprompt,
int height,
int width,
int min_value,
int max_value,
int default_value)
{
/* *INDENT-OFF* */
static DLG_KEYS_BINDING binding[] = {
DLG_KEYS_DATA( DLGK_DELETE_RIGHT,KEY_DC ),
HELPKEY_BINDINGS,
ENTERKEY_BINDINGS,
DLG_KEYS_DATA( DLGK_ENTER, ' ' ),
DLG_KEYS_DATA( DLGK_FIELD_NEXT, CHR_NEXT ),
DLG_KEYS_DATA( DLGK_FIELD_NEXT, KEY_RIGHT ),
DLG_KEYS_DATA( DLGK_FIELD_NEXT, TAB ),
DLG_KEYS_DATA( DLGK_FIELD_PREV, CHR_BACKSPACE ),
DLG_KEYS_DATA( DLGK_FIELD_PREV, CHR_PREVIOUS ),
DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_BTAB ),
DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_LEFT ),
DLG_KEYS_DATA( DLGK_ITEM_FIRST, KEY_HOME),
DLG_KEYS_DATA( DLGK_ITEM_LAST, KEY_END),
DLG_KEYS_DATA( DLGK_ITEM_LAST, KEY_LL ),
DLG_KEYS_DATA( DLGK_ITEM_NEXT, '+'),
DLG_KEYS_DATA( DLGK_ITEM_NEXT, KEY_DOWN),
DLG_KEYS_DATA( DLGK_ITEM_PREV, '-' ),
DLG_KEYS_DATA( DLGK_ITEM_PREV, KEY_UP ),
DLG_KEYS_DATA( DLGK_PAGE_NEXT, KEY_NEXT),
DLG_KEYS_DATA( DLGK_PAGE_NEXT, KEY_NPAGE),
DLG_KEYS_DATA( DLGK_PAGE_PREV, KEY_PPAGE ),
DLG_KEYS_DATA( DLGK_PAGE_PREV, KEY_PREVIOUS ),
END_KEYS_BINDING
};
/* *INDENT-ON* */
#ifdef KEY_RESIZE
int old_height = height;
int old_width = width;
#endif
VALUE data;
int key = 0, key2, fkey;
int button;
int result = DLG_EXIT_UNKNOWN;
WINDOW *dialog;
int state = dlg_default_button();
const char **buttons = dlg_ok_labels();
char *prompt = dlg_strclone(cprompt);
char buffer[MAX_LEN];
int cur_value = default_value;
int usable;
int ranges;
int yorg, xorg;
if (max_value < min_value)
max_value = min_value;
if (cur_value > max_value)
cur_value = max_value;
if (cur_value < min_value)
cur_value = min_value;
dlg_does_output();
#ifdef KEY_RESIZE
retry:
#endif
dlg_auto_size(title, prompt, &height, &width, 0, 0);
height += MIN_HIGH;
if (width < MIN_WIDE)
width = MIN_WIDE;
dlg_button_layout(buttons, &width);
dlg_print_size(height, width);
dlg_ctl_size(height, width);
dialog = dlg_new_window(height, width,
yorg = dlg_box_y_ordinate(height),
xorg = dlg_box_x_ordinate(width));
data.window = dialog;
data.min_value = min_value;
data.max_value = max_value;
usable = (width - 2 - 4 * MARGIN);
ranges = max_value - min_value + 1;
/*
* Center the number after allowing for its maximum number of digits.
*/
data.value_len = digits_of(max_value);
if (digits_of(min_value) > data.value_len)
data.value_len = digits_of(min_value);
data.value_x = (usable - data.value_len) / 2 + MARGIN;
data.value_col = data.value_len - 1;
/*
* The slider is scaled, to try to use the width of the dialog.
*/
if (ranges > usable) {
data.slide_inc = (ranges + usable - 1) / usable;
data.slide_len = 1 + ranges / data.slide_inc;
} else if (ranges < usable) {
data.slide_inc = usable / ranges;
data.slide_len = ranges * data.slide_inc;
} else {
data.slide_inc = 1;
data.slide_len = usable;
}
data.slide_x = (usable - data.slide_len) / 2 + MARGIN + 2;
data.slide_y = height - 5;
data.current = cur_value - 1;
dlg_register_window(dialog, "rangebox", binding);
dlg_register_buttons(dialog, "rangebox", buttons);
dlg_draw_box2(dialog, 0, 0, height, width, dialog_attr, border_attr, border2_attr);
dlg_mouse_setbase(xorg, yorg);
dlg_mouse_mkregion(data.slide_y - 1, data.slide_x - 1, 3, usable + 2, 'i');
dlg_draw_box2(dialog,
height - 6, data.slide_x - MARGIN,
2 + MARGIN, data.slide_len + 2 * MARGIN,
dialog_attr,
border_attr,
border2_attr);
dlg_draw_bottom_box2(dialog, border_attr, border2_attr, dialog_attr);
dlg_draw_title(dialog, title);
dlg_draw_helpline(dialog, FALSE);
(void) wattrset(dialog, dialog_attr);
dlg_print_autowrap(dialog, prompt, height, width);
dlg_trace_win(dialog);
while (result == DLG_EXIT_UNKNOWN) {
draw_value(&data, cur_value);
button = (state < 0) ? 0 : state;
dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width);
if (state < 0) {
data.value_col = data.value_len + state;
wmove(dialog, data.slide_y, data.value_x + data.value_col);
}
key = dlg_mouse_wgetch(dialog, &fkey);
if (dlg_result_key(key, fkey, &result))
break;
if ((key2 = dlg_char_to_button(key, buttons)) >= 0) {
result = key2;
} else {
/* handle function-keys */
if (fkey) {
switch (key) {
case DLGK_ENTER:
result = dlg_ok_buttoncode(button);
break;
case DLGK_FIELD_PREV:
if (state < 0 && state > -data.value_len) {
--state;
} else {
state = dlg_prev_ok_buttonindex(state, -data.value_len);
}
break;
case DLGK_FIELD_NEXT:
if (state < 0) {
++state;
} else {
state = dlg_next_ok_buttonindex(state, -data.value_len);
}
break;
case DLGK_ITEM_FIRST:
cur_value = min_value;
break;
case DLGK_ITEM_LAST:
cur_value = max_value;
break;
case DLGK_ITEM_PREV:
if (state < 0) {
cur_value -= digit_of(&data);
} else {
cur_value -= 1;
}
if (cur_value < min_value)
cur_value = min_value;
break;
case DLGK_ITEM_NEXT:
if (state < 0) {
cur_value += digit_of(&data);
} else {
cur_value += 1;
}
if (cur_value > max_value)
cur_value = max_value;
break;
case DLGK_PAGE_PREV:
cur_value -= data.slide_inc;
if (cur_value < min_value)
cur_value = min_value;
break;
case DLGK_PAGE_NEXT:
cur_value += data.slide_inc;
if (cur_value > max_value)
cur_value = max_value;
break;
#ifdef KEY_RESIZE
case KEY_RESIZE:
/* reset data */
height = old_height;
width = old_width;
/* repaint */
dlg_clear();
dlg_del_window(dialog);
refresh();
dlg_mouse_free_regions();
goto retry;
#endif
case DLGK_MOUSE('i'):
state = -data.value_len;
break;
default:
if (is_DLGK_MOUSE(key)) {
result = dlg_ok_buttoncode(key - M_EVENT);
if (result < 0)
result = DLG_EXIT_OK;
}
break;
}
} else if (isdigit(key) && state < 0) {
if (set_digit(&data, key)) {
cur_value = data.current;
data.current--;
}
} else {
beep();
}
}
}
sprintf(buffer, "%d", cur_value);
dlg_add_result(buffer);
dlg_add_separator();
dlg_add_last_key(-1);
dlg_del_window(dialog);
dlg_mouse_free_regions();
free(prompt);
return result;
}

View File

@ -1,9 +1,9 @@
/*
* $Id: rc.c,v 1.47 2011/06/20 22:30:04 tom Exp $
* $Id: rc.c,v 1.51 2012/11/30 21:32:39 tom Exp $
*
* rc.c -- routines for processing the configuration file
*
* Copyright 2000-2010,2011 Thomas E. Dickey
* Copyright 2000-2011,2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@ -203,9 +203,10 @@ attr_to_str(char *str, int fg, int bg, int hl)
/*
* Extract the foreground, background and highlight values from an attribute
* represented as a string in this form:
* represented as a string in one of two forms:
*
* "(foreground,background,highlight)"
" "xxxx_color"
*/
static int
str_to_attr(char *str, int *fg, int *bg, int *hl)
@ -213,13 +214,27 @@ str_to_attr(char *str, int *fg, int *bg, int *hl)
int i = 0, get_fg = 1;
unsigned j;
char tempstr[MAX_LEN + 1], *part;
size_t have;
if (str[0] != '(' || lastch(str) != ')')
if (str[0] != '(' || lastch(str) != ')') {
if ((i = find_color(str)) >= 0) {
*fg = dlg_color_table[i].fg;
*bg = dlg_color_table[i].bg;
*hl = dlg_color_table[i].hilite;
return 0;
}
return -1; /* invalid representation */
}
/* remove the parenthesis */
strcpy(tempstr, str + 1);
lastch(tempstr) = '\0';
have = strlen(str);
if (have > MAX_LEN) {
have = MAX_LEN - 1;
} else {
have -= 2;
}
memcpy(tempstr, str + 1, have);
tempstr[have] = '\0';
/* get foreground and background */
@ -424,13 +439,29 @@ dlg_create_rc(const char *filename)
#ifdef HAVE_COLOR
for (i = 0; i < (unsigned) dlg_color_count(); ++i) {
char buffer[MAX_LEN + 1];
unsigned j;
bool repeat = FALSE;
fprintf(rc_file, "\n# %s\n", dlg_color_table[i].comment);
fprintf(rc_file, "%s = %s\n", dlg_color_table[i].name,
attr_to_str(buffer,
dlg_color_table[i].fg,
dlg_color_table[i].bg,
dlg_color_table[i].hilite));
for (j = 0; j != i; ++j) {
if (dlg_color_table[i].fg == dlg_color_table[j].fg
&& dlg_color_table[i].bg == dlg_color_table[j].bg
&& dlg_color_table[i].hilite == dlg_color_table[j].hilite) {
fprintf(rc_file, "%s = %s\n",
dlg_color_table[i].name,
dlg_color_table[j].name);
repeat = TRUE;
break;
}
}
if (!repeat) {
fprintf(rc_file, "%s = %s\n", dlg_color_table[i].name,
attr_to_str(buffer,
dlg_color_table[i].fg,
dlg_color_table[i].bg,
dlg_color_table[i].hilite));
}
}
#endif /* HAVE_COLOR */
dlg_dump_keys(rc_file);
@ -507,7 +538,10 @@ dlg_parse_rc(void)
lastch(str) = '\0';
if (begins_with(str, "bindkey", &params)) {
dlg_parse_bindkey(params);
if (!dlg_parse_bindkey(params)) {
fprintf(stderr, "\nParse error: line %d of configuration\n", l);
result = -1;
}
continue;
}
parse = parse_line(str, &var, &value); /* parse current line */

View File

@ -1,7 +1,7 @@
#! /bin/sh
# $Id: rename.sh,v 1.3 2011/01/06 10:51:02 tom Exp $
# $Id: rename.sh,v 1.4 2012/12/19 10:17:36 tom Exp $
##############################################################################
# Copyright (c) 2011 Thomas E. Dickey #
# Copyright (c) 2011,2012 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"), #
@ -54,6 +54,7 @@ sed -e "s,^\.ds p dialog\>,.ds p $BINARY," \
-e "s,^\.ds l dialog\>,.ds l $PACKAGE," \
-e "s,^\.ds L Dialog\>,.ds L $ONE_CAPS," \
-e "s,^\.ds D DIALOG\>,.ds D $ALL_CAPS," \
-e 's,^dialog \\- ,'"$PACKAGE"' \\- ,' \
<$SOURCE >source.tmp
"$@" source.tmp $TARGET
rm -f source.tmp

View File

@ -1,40 +1,7 @@
-- $Id: README,v 1.3 2007/01/11 22:52:19 tom Exp $
-- $Id: README,v 1.4 2012/12/02 18:52:52 tom Exp $
You can set the environment-variable DIALOG to whatever program you
want to check. Default is "dialog".
Use "export DIALOG=/usr/bin/dialog" for sh or "setenv DIALOG ../dialog" for csh
to test the /usr/bin/dialog program.
-- Here is the original README for the samples directory.
There is no documentation at the moment for cdialog 0.9a, but here are a
small installer (copismall) for 'points' fido-like, that uses cdialog 0.9a.
It can demonstrate some of the new features... run "copismall" paying
attention because after asking for some things, it then installs and/or
configures programs like as Inn, Ifmail, Smail to make the 'point'.
It's in Italian language only at moment, but the code is bash......
If you want look at other much professional products FREE realized with
cdialog and that use much of the other new characteristics, look for one of
the ComeOn Point Suites v1.1+. Makers are a sub-group of the ComeOn Linux
Development Team... ComeOn Linux! follows GNU philosophy.
Mail demarco_p@abramo.it to have the actual location of these Suites and
of other free ComeOn Linux! software, or if you want more info about
ComeOn Linux!
To run the "ComeOn Point Installer! v0.9a.small", type:
$ copismall
Other external samples could be:
copa - ComeOn Point Administrator! v0.8
copm - ComeOn Point Maintainer! v0.2
copi - ComeOn Point Installer! v0.9 (system-wide version of copi)
coepi - ComeOn Expert Point Installer! v1.3 (Professional)
cops - ComeOn Point Suite! v1.1
copsp - ComeOn Point Suite Professional! v1.1
coui - ComeOn UUCP Installer! v0.1 (makes dialup networks in a moment)

View File

@ -0,0 +1,20 @@
#!/bin/sh
# $Id: buildlist,v 1.2 2012/12/04 11:45:21 tom Exp $
. ./setup-vars
. ./setup-tempfile
$DIALOG --title "BUILDLIST DEMO" --backtitle "A user-built list" \
--separator "|" \
--buildlist "hello, this is a --buildlist..." 0 0 0 \
"1" "Item number 1" "on" \
"2" "Item number 2" "off" \
"3" "Item number 3" "on" \
"4" "Item number 4" "on" \
"5" "Item number 5" "off" \
"6" "Item number 6" "on" 2> $tempfile
retval=$?
. ./report-tempfile

View File

@ -0,0 +1,42 @@
#!/bin/sh
# $Id: buildlist2,v 1.6 2012/12/23 22:28:12 tom Exp $
. ./setup-vars
. ./setup-edit
count=0
ls -1 | while true
do
read filename
test -z "$filename" && break
case $filename in
*.*)
state=off
;;
*-*)
state=on
;;
*)
continue
;;
esac
case "x$DIALOGOPTS" in
*--no-items*|*--noitem*)
echo $filename $state >>$input
;;
*)
echo $count $filename $state >>$input
;;
esac
count=`expr $count + 1`
done
$DIALOG --title "BUILDLIST DEMO" --backtitle "A user-built list" \
--visit-items --scrollbar --separator "|" \
--buildlist "hello, this is a --buildlist..." 0 0 10 `cat $input` 2> $output
retval=$?
tempfile=$output
. ./report-tempfile

View File

@ -0,0 +1,44 @@
#! /bin/sh
# $Id: checklist12,v 1.3 2012/12/23 22:27:51 tom Exp $
. ./setup-vars
. ./setup-edit
case "x$DIALOGOPTS" in
*--no-items*|*--noitem*)
CUT="cut -d: -f1,3"
;;
*)
CUT="cat"
;;
esac
$CUT >$input <<-EOF
Apple:It's an apple.:off
Dog:No, that's not my dog.:ON
Orange:Yeah, that's juicy.:off
Chicken:Normally not a pet.:off
Cat:No, never put a dog and a cat together!:oN
Fish:Cats like fish.:On
Lemon:You know how it tastes.:on
EOF
cat $input | sed -e 's/^/"/' -e 's/:/" "/g' -e 's/$/"/' >$output
cat $output >$input
$DIALOG --backtitle "No Such Organization" \
--title "CHECKLIST BOX" "$@" \
--checklist "Hi, this is a checklist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
UP/DOWN arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press SPACE to toggle an option on/off. \n\n\
Which of the following are fruits?" 20 61 5 \
--file $input 2> $output
retval=$?
tempfile=$output
. ./report-tempfile

View File

@ -1,200 +0,0 @@
#!/bin/bash
# $Id: admin.funcs,v 1.2 2001/01/15 22:20:11 tom Exp $
#
# ComeOn Point Functions! v0.9.2
# - usate da vari altri moduli ComeOn Point...
#
# AUTHOR: Beppe (beppe.dem@nsm.it)
#
# This program 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Args: source_file, domain, nldir
install_nodelist() {
NODELIST="$1"
FOR_DOMAIN="$2"
NODEDIR="$3"
dialog --backtitle "$TITLE" --infobox "Installo la nodelist '$NODELIST' per il domain $FOR_DOMAIN, attendere prego..." 0 0
cp "$NODELIST" $NODEDIR/$FOR_DOMAIN.ndl
chown fnet.uucp $NODEDIR/$FOR_DOMAIN.ndl
echo "y" | su -l fnet -c "ifindex" >/dev/null
}
# Args: source, dest
add_alias() {
SOURCE=$1
DEST=$2
ALIASES=/etc/aliases
ENTRY="`grep $SOURCE: $ALIASES`"
dialog --backtitle "$TITLE" --infobox "Creo un alias per redirigere le mail per $SOURCE a $DEST ..." 0 0
if [ ! "$ENTRY" ]
then
echo "$SOURCE: $DEST" >>$ALIASES
else
OLDDEST="`echo $ENTRY | cut -f2 -d:`"
mkstemp alias
sed /"$SOURCE:"/s/"$OLDDEST"/" $DEST"/ $ALIASES >$tmp_alias
cat $tmp_alias >$ALIASES
rm $tmp_alias
fi
mkaliases >/dev/null
}
# Args: Areas_pathname, newsgroup, area_ftn, description [, expire_days]
# Returns: 1 - innd not running
# 2 - already existing newsgroup
# 3 - already existing ftn_area
create_newsgroup() {
AREAS="$1"
NEWSGROUP="$2"
AREA="$3"
DESCRIPTION="$4"
EXPIRE_DAYS="$5"
NEWSGROUPS=~news/newsgroups
EXPIRECTL=~news/expire.ctl
dialog --backtitle "$TITLE" --infobox "Creo il newsgroup $NEWSGROUP per contenere i messaggi dell'area $AREA..." 0 0
if [ ! "`ps ax | grep ~news/etc/innd`" ]
then
return 1
fi
if [ "`cut $NEWSGROUPS -f1 | cut -f1 -d\ | grep -x $NEWSGROUP`" ]
then
return 2
fi
if [ "`cut $AREAS -f1 | cut -f1 -d\ | grep -x $AREA`" ]
then
return 3
fi
su -l news -c "bin/ctlinnd newgroup $NEWSGROUP" >/dev/null
echo -e "$NEWSGROUP\t$DESCRIPTION" >> $NEWSGROUPS
echo -e "$AREA\t$NEWSGROUP\t`echo $NEWSGROUP | cut -f1 -d.`" >> $AREAS
if [ "$EXPIRE_DAYS" ]; then
echo "$NEWSGROUP:A:2:$EXPIRE_DAYS:$EXPIRE_DAYS" >> $EXPIRECTL
fi
chown news.news $NEWSGROUPS $EXPIRECTL
chmod 440 $EXPIRECTL
chown fnet.uucp $AREAS
}
# Returns: 0 if ok, 1 if (innd not running), 2 if (no that newsgroup)
# Args: Areas_pathname, newsgroup
rmgroup() {
AREAS=$1
NEWSGR=$2
NEWSGROUPS=~news/newsgroups
EXPIRE=~news/expire.ctl
dialog --backtitle "$TITLE" --infobox "Elimino il newsgroup $NEWSGR ed i messaggi in esso contenuti, attendere prego. Questa operazione potrebbe durare alcuni minuti." 0 0
if [ ! "`ps x | grep ~news/etc/innd`" ]
then
return 1
fi
if [ ! "`cut -f1 $NEWSGROUPS | cut -f1 -d\ | grep -x $NEWSGR`" ]
then
return 2
else
# Updating newsgroups file
if [ -f $NEWSGROUPS ]
then
mkstemp groups
mv $NEWSGROUPS $NEWSGROUPS~
grep -v $NEWSGR $NEWSGROUPS~ >$tmp_groups
mv $tmp_groups $NEWSGROUPS
else
:> $NEWSGROUPS
fi
chown news.news $NEWSGROUPS
# Updating Areas file
if [ -f $AREAS ]
then
mkstemp areas
mv $AREAS $AREAS~
grep -v $NEWSGR $AREAS~ >$tmp_areas
mv $tmp_areas $AREAS
else
:> $AREAS
fi
chown fnet.uucp $AREAS
# Updating expire.ctl file
if [ -f $EXPIRE ]
then
mkstemp expire
mv $EXPIRE $EXPIRE~
grep -v "$NEWSGR:" $EXPIRE~ >$tmp_expire
mv $tmp_expire $EXPIRE
else
:> $EXPIRE
fi
chown news.news $EXPIRE
chmod 444 $EXPIRE
# Remove pending articles
echo -e "\n$NEWSGR:A:0:0:0" >>$EXPIRE
su -l news -c "bin/news.daily" >/dev/null
mkstemp expire
grep -v $NEWSGR $EXPIRE >$tmp_expire
mv $tmp_expire $EXPIRE
chown news.news $EXPIRE
chmod 444 $EXPIRE
# Updating active file
su -l news -c "bin/ctlinnd rmgroup $NEWSGR" >/dev/null
fi
}
# Args: newsgroups_wildmat, days_to_keep
set_expire_time() {
NEWSGROUP="$1"
KEEPDAYS="$2"
EXPIRE=~news/expire.ctl
dialog --backtitle "$TITLE" --infobox "Imposto a $KEEPDAYS il numero di giorni di mantenimento dei messaggi del newsgroup $NEWSGROUP..." 0 0
if [ ! -f $EXPIRE ]
then
:> $EXPIRE
elif [ "`cut $EXPIRE -s -f1 -d: | grep -x $NEWSGROUP`" ]
then
mkstemp expire
grep -v "$NEWSGROUP:" $EXPIRE >$tmp_expire
mv $tmp_expire $EXPIRE
fi
echo -e "\n$NEWSGROUP:A:2:$KEEPDAYS:$KEEPDAYS" >>$EXPIRE
chown news.news $EXPIRE
chmod 444 $EXPIRE
}

View File

@ -1,338 +0,0 @@
#
# ComeOn Point Functions! v0.9.2
# - usate da vari altri moduli ComeOn Point...
#
# AUTHOR: Beppe (beppe.dem@nsm.it)
#
# This program 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
save() {
if [ -f $1 ]
then
mv $1 $1~
fi
}
# Returns $PKG_TO_REMOVE
find_incompatible_packages() {
dialog --backtitle "$TITLE" --infobox "Vediamo innanzitutto se c'e' qualche pacchetto di troppo ... ;-)" 0 0
PKG_TO_REMOVE=""
for i in sendmail smailcfg cnews
do
if [ -f /var/adm/packages/$i ]
then
PKG_TO_REMOVE="$PKG_TO_REMOVE $i"
fi
done
}
# Returns $PKG_TO_INSTALL
find_necessary_packages() {
dialog --backtitle "$TITLE" --infobox "Controlliamo se manca qualche pacchetto..." 0 0
PKG_TO_INSTALL=""
for i in tcpip mailx inn
do
if [ ! -f /var/adm/packages/$i ]
then
PKG_TO_INSTALL="$PKG_TO_INSTALL $i"
fi
done
}
# Args: user, editor
configure_trn() {
dialog --backtitle "$TITLE" --infobox "Configuro trn all'user $1..." 0 0
SHELL_USED="`basename \`cut /etc/passwd -f1,7 -d: | grep $1: | cut -f2 -d:\``"
USER_HOME="`cut /etc/passwd -f1,6 -d: | grep $1: | cut -f2 -d:`"
TRNRC="$USER_HOME/.trnrc"
case $SHELL_USED in
bash)
if [ -f $USER_HOME/.bash_profile ]
then
PROF=$USER_HOME/.bash_profile
else
PROF=$USER_HOME/.profile
fi;;
zsh)
PROF=$USER_HOME/.zprofile;;
*)
PROF=$USER_HOME/.profile;;
esac
if [ ! -f $PROF ]
then
:>$PROF
chown $1.mail $PROF
elif [ ! "`grep -x \". ~/.trnrc\" $PROF`" ]
then
echo -e "\n. ~/.trnrc" >>$PROF
fi
save $TRNRC
echo "EDITOR=\"$2\"" > $TRNRC
cat copi.trnrc >> $TRNRC
chown $1.mail $TRNRC
}
# Args: user, editor
configure_elm() {
USER=$1
EDIT=$2
dialog --backtitle "$TITLE" --infobox "Configuro elm all'user $USER..." 0 0
USER_HOME="`cut /etc/passwd -f1,6 -d: | grep $USER: | cut -f2 -d:`"
DIRRC="$USER_HOME/.elm"
ELMRC="$DIRRC/elmrc"
mkdir -p $DIRRC -m 700
chown $USER.mail $USERHOME $DIRRC
save $ELMRC
cat <<EOF >$ELMRC
#
# .elm/elmrc - options file for the ELM mail system
#
# Generated by $PKTNAME for $USER
#
# For yes/no settings with ?, ON means yes, OFF means no
# how to sort the alias list, "Name" by default
### aliassortby = Name
# name of editor to use for replies that have text
alteditor = $EDIT
# alternative addresses that I could receive mail from (usually a
# forwarding mailbox) and don't want to have listed...
### alternatives =
# should the default be to delete messages we've marked for deletion?
alwaysdelete = ON
# should the default be to keep unread messages in the incoming mailbox?
alwayskeep = ON
# should the default be to store read messages to the "received" folder?
alwaysstore = OFF
# should we use the "->" rather than the inverse video bar?
arrow = OFF
# should the message disposition questions be displayed(ON) or
# auto-answered(OFF) with the default answers when we resync or
# change folders?
ask = OFF
# would you like to be asked for Carbon-Copies information each msg?
askcc = OFF
# attribution string for replies ('%s' is the author of original message)
attribution = %s wrote:
# automatically copy message being replied to into buffer?
autocopy = ON
# threshold for bouncing copies of remote uucp messages...
# zero = disable function.
### bounceback = 0
# This is used to determine if the builtin pager should be used on some
# messages even if you would usually use an external pager program.
# There are two ways of determining whether the builtin pager should be
# used. If you want any message that is shorter than "n" lines to use the
# internal pager, set the parameter to "n". If you want the builtin
# pager to be used if the message is "m" lines shorter than the number of
# lines on your screen set the parameter to be "-m". Setting the
# parameter to zero will result in the message always being sent through
# your external pager.
### builtinlines = -3
# where to save calendar entries
#calendar = /root/calendar
# list of options that can be configured at the "o)ptions" screen
configoptions = ^_cdefsopyv_am_un
# Should elm always ask the user to confirm before it appends
# messages to any existing file?
# This is used for both folders in the user's mail directory
# and ordinary files.
confirmappend = OFF
# Should elm always ask the user to confirm before it creates
# any new files?
# This is used for both folders in the user's mail directory
# and ordinary files.
confirmcreate = OFF
# Should elm ask for confirmation before it appends a message
# to an existing file that is not a folder in the user's Mail
# directory?
# This is used for ordinary files only and does not affect
# folders in the user's mail directory.
confirmfiles = OFF
# Should elm ask for confirmation before it creates a new folder
# in the user's Mail directory?
# This is used only for folders in the user's mail directory and
# does not affect ordinary files.
confirmfolders = OFF
# save a copy of all outbound messages?
copy = ON
# name of editor for ~e command (when editor="builtin")
easyeditor = $EDIT
# what editor to use ("none" means simulate Berkeley Mail)
editor = $EDIT
# the character to use in the builtin editor for entering commands
### escape = ~
# save outbound messages by login name of sender/recipient even if the
# associated folder doesn't already exist?
### forcename = OFF
# do we want to be able to mail out AT&T Mail Forms?
### forms = OFF
# The full user name for outbound mail
### fullname = $PKTNAME User
# should we keep folders from which all messages are deleted?
### keepempty = OFF
# are we running on an HP terminal and want HOME, PREV, NEXT, etc...?
### keypad = OFF
# local ".signature" file to append to appropriate messages...
localsignature = ~/.signature
# where to save my mail to, default directory is "Mail"
maildir = ~/Mail
# should we display the three-line 'mini' menu?
menu = ON
# would you like a copy of a message you send to an alias you are on?
### metoo = OFF
# when using the page commands (+ - <NEXT> <PREV>) change the current
# message pointer...?
### movepage = OFF
# just show the names when expanding aliases?
names = OFF
# when messages are copied into the outbound buffer, don't include headers?
noheader = ON
# program to use for displaying messages ('builtin' is recommended)
### pager = builtin+
# start up by pointing to the first new message received, if possible?
### pointnew = ON
# list of delivery precedences allowed, or empty to allow anything
# precedence may be followed by optional ":priority" specification
### precedences =
# prefix sequence for indenting included message text in outgoing messages...
prefix = _:>_
# how to print a message ('%s' is the filename)
### print = /bin/cat %s | /usr/bin/lpr
# prompt for a command after the external pager exits?
### promptafter = ON
# Value by which message count is incremented while reading a new mailbox.
# Setting this value to a number larger than one will speed up the time it
# takes to read a large mailbox when using a slow terminal.
### readmsginc = 1
# where to save received messages to, default file is "=received"
receivedmail = =received
# remote ".signature" file to append to appropriate messages...
remotesignature = ~/.signature
# emulate the mailx message increment mode (only increment after
# something has been 'done' to a message, either saved or deleted,
# as opposed to simply each time something is touched)?
### resolve = ON
# save messages, incoming and outbound, by login name of sender/recipient?
savename = ON
# where to save copies of outgoing mail to, default file is "=sent"
sentmail = =sent
# The shell to use for shell escapes
shell = /bin/sh
# do we want dashes above signatures? (News 2.11 compatibility and convention)
### sigdashes = ON
# time in seconds which Elm will wait after displaying a transient message
# and before erasing it. Can be 0 or positive integer.
### sleepmsg = 2
# are we running on an HP terminal and want softkeys available too?
# (this implies "keypad=ON" too)
### softkeys = OFF
# how to sort folders, "Reverse Sent" by default
### sortby = Reverse-Sent
# Set the main prompt timeout for resynching...
### timeout = 600
# display message title when displaying pages of message?
titles = ON
# where to place temporary files, default directory is "/tmp"
### tmpdir = /tmp/
# are we good at it? 0=beginner, 1=intermediate, 2+ = expert!
userlevel = 0
# would you like to use termcap/terminfo ti/te entries?
usetite = ON
# name of editor for ~v command (when editor="builtin")
visualeditor = $EDIT
# enable the weedout list to be read?
### weed = ON
# what headers I DON'T want to see, ever.
weedout = "*end-of-user-headers*"
EOF
chmod 600 $ELMRC
chown $USER.mail $ELMRC
}

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +0,0 @@
#! /usr/bin/perl
#
# This is a utility script to manipulate Fidonet-related issues
# using Eugene Crosser's ifmail package
#
# Version 0.1
#
# (C) Michael Bravo and The Communication Tube, 1994
#
# You can do whatever you want with this script. I take no responsibility
# whatsoever in anything related to this script. If you make some useful
# additions to this, please think of sending them to me so I could partake
# of your wisdom.
#
# This script was written to help attaching and requesting files from the
# commandline, much like you do with Squish under DOS or OS/2. It is certainly
# not perfect - I used it as an exercise in Perl. It also probably lacks
# some other useful features, like ability to specify trunc/sent or kill/sent
# attributes etc etc. If you really want this or some other features
# implemented, write me at mbravo@tctube.spb.su or mbravo@octopus.spb.su
# and I will try to do what I can.
#
# Note - files don't get copied to any spool dir, so if you move attached
# files somewhere, they won't get sent.
#
# This script is supposed to read ifmail's config to determine where outbound
# directory and logfile are. The only two parameters to modify in most cases
# are below.

View File

@ -1,137 +0,0 @@
if ( getpwuid($<) ne $ifowner ) { print "You must be owner of ifmail\n"; exit 1; }
if ( (@ARGV < 3) || $ARGV[0] eq "-?" || $ARGV[0] eq "-h" ) {
&usage;
}
$ARGV[0] =~ tr/A-Z/a-z/;
$ARGV[3] =~ tr/A-Z/a-z/;
&parsecfg;
if ( $logfile ne "" ) {
open(LOG, ">>".$logfile) || die "Can't open logfile";
}
if (substr($ARGV[1], 0, 1) ne "/") {
$cwd=`pwd`;
chop $cwd;
$ARGV[1] = $cwd."/".$ARGV[1];
}
if ($ARGV[3] eq "" || $ARGV[3] eq "normal") {
$flavour = 'f';
} elsif ($ARGV[3] eq "crash") {
$flavour = 'c';
} elsif ($ARGV[3] eq "hold") {
$flavour = 'h';
} else {
print "Unknown flavour, assuming normal\n";
$flavour = 'f';
}
if ($ARGV[0] eq "send") {
&attach($ARGV[1], $ARGV[2]);
} elsif ($ARGV[0] eq "get") {
&request($ARGV[1], $ARGV[2]);
} else {
print "Unknown command, try ifman -h\n";
exit 1;
}
close(LOG);
exit 0;
#######################################################################
sub attach {
local($fspec, $address) = @_;
$floname = &resolve($address);
open(FLO, ">>".$outbound."/".$floname) || die "Can't open flo-file $outbound/$floname";
open(FIND, "find $fspec -print |") || die "Can't generate list of files";
if ( eof(FIND) ) {
print "No matching files, nothing to send\n";
exit 1;
}
while (<FIND>) {
chop;
$datestamp = `date \"+%D %T\"`;
chop $datestamp;
printf LOG "%s %s %s\n", $datestamp, $$, "ifman: sending $_ to $address";
printf FLO "%s\n", $_;
}
close(FLO);
close(FIND);
}
sub request {
local($fspec, $address) = @_;
$reqname = &resolve($address);
$reqname =~ s/\.[fch]lo/\.req/;
open(REQ, ">>".$outbound."/".$reqname) || die "Can't open req-file";
$datestamp = `date \"+%D %T\"`;
chop $datestamp;
printf LOG "%s %s %s\n", $datestamp, $$, "ifman: requesting $fspec from $address";
printf REQ "%s\n", $fspec;
close(REQ);
}
sub resolve {
local($addr) = @_;
if ( index($addr, ":") >=0 ) {
print "I cannot resolve addresses with zones!\n";
exit 1;
} elsif ( index($addr, "/") == -1 ) {
print "Not a valid address!\n";
exit 1;
}
($net, $node, $point) = split(/\/|\./, $addr);
if ( defined $point ) {
$pointdir = sprintf("%04x%04x.pnt", $net, $node);
if ( ! -e $outbound."/".$pointdir ) {
mkdir ($outbound."/".$pointdir, 0755) || die "Can't create point directory";
}
$flo = sprintf("0000%04x.%01slo", $point, $flavour);
return $pointdir."/".$flo;
} else {
$flo = sprintf("%04x%04x.%01slo", $net, $node, $flavour);
return $flo;
}
}
sub usage {
print "ifmail manager script\n";
print "usage: ifman <cmd> <filespec> <address> [flavour]\n";
print " commands: send, get\n";
print " flavours: normal, crash, hold. Default is normal.\n";
print "Only 2d addresses with points are supported - no zones!\n";
exit 1;
}
sub parsecfg {
open(CFG, $cfgfile) || die "Can't open ifmail config file";
while (<CFG>) {
chop;
if (/^#/) { next; }
if (/^outbound\s+(\S+)/) { $outbound = $1; }
if (/^logfile\s+(\S+)/) { $logfile = $1; }
}
close(CFG);
}

View File

@ -1,68 +0,0 @@
# Transport programs for mail and news, used by iftoss
sendmail /usr/lib/sendmail -f $F $T
rnews /usr/lib/news/rnews
# Unpackers, used by ifunpack.
# $F expands to archieve file name
unzip /usr/bin/unzip -oq $F
unarj /usr/bin/unarj e $F
#unarc /usr/bin/unpack $F
unzoo /usr/bin/zoo -extract $F
unlzh /usr/bin/lharc -x $F
# Packer program, used by ifpack
# $F expands to archieve file name, $P - to list of packet names
packer /usr/bin/zip $F $P
# Maximum arcmail file size, will start new arcmail file if exceeds
maxfsize 65000
# Maximum packet size, ifmail/ifnews will start new packet if exeeds.
# .out files are NOT created if nonzero specified, you must run ifpack
# to make packets out. (unimplemented)
maxpsize 65000
# cnews log file and (temporary) database for seen-bys
newslog /usr/lib/news/log
msgidbm /tmp/ifmsgids
# From this line on, values may be prefixed by a logical expression in
# round brackets. Operators are: '!', '&', '|', 'Xor'.
# Possible elements are:
# - Nodelist flags (like "CM", "MNP", "V32" etc.)
# - speed <operator> <numeric>
# where <operator> is '=', '!=', '<', '>', '<=', '>='
# - address <wildcard>
# where <wildcard> is an (possibly incomplete) fidonet address,
# e.g. "5020/*"
# - time <interval>[,<interval>,...]
# where <interval> is a day spec. with optional time spec., e.g.
# Wk2000-0900,Sat1800-0000,Sun
# - phone <prefix>
# e.g. "phone 7-095-"
# Dialing parameters
# of multiple "ModemPort", "ModemReset", "ModemDial", "ModemHangup" lines,
# first matching is used.
# of multiple "PhoneTrans", "ModemConnect", "ModemError" lines, all matching
# are used.
# In send and expect strings, following substitutions are made:
# \\ '\' character
# \r carriage return (0x0d)
# \n new line (0x0a)
# \t tab (0x09)
# \b backspace (0x08)
# \s space (0x20)
# \NNN (where N is an octal digit) - character with octal code NNN
# \d 1 second delay (send strings only)
# \p 1/4 second pause (send strings only)
# \T translated telephone no. (send strings only)
# \D untranslated telephone no. (send strings only)
# ModemPort present a blank-separated list of ports with possible speed
# extention (separated by colon); if speed is prefixed with 'L', it is
# a "locked" port speed, otherwise it is a maximum speed to be set, while
# actual speed is taken from the nodelist. If speed is omitted (or set
# to zero), previous port speed is not changed.
#ModemPort (time Any0000-0900,Sat,Sun) ttyS0
#ModemPort cua0:L38400

View File

@ -1,30 +0,0 @@
ModemHangup +++ATH\r
ModemOK OK
ModemConnect CONNECT
ModemError BUSY
ModemError NO\sCARRIER
ModemError NO\sDIAL
ModemError RING\r
ModemError ERROR
# Call options (time, address and nodelist flag dependant)
# All matching are applied in the order they are specified.
# Possible options are "[No]Call", "[No]Hold", "[No]PUA", "[No]EMSI",
# "[No]WaZOO", "[No]Freqs", "[No]Zmodem", "[No]ZedZap", "[No]Janus",
# "[No]Hydra". Here, WaZOO stands for YooHoo/2U2 handshake, not for
# the transfer scheme. FTS-0001 handshake and DietIFNA scheme cannot
# be disallowed (because they are mandatory by standart). "Hold"
# means really hold "hold" type packets and files: do not send them
# if our system initiated the session, "NoHold" means send "hold"
# packets when our system initiated the session. "NoPUA" stands for
# "No PickUp All", i.e. PUP ("Pick Up Primary"). NoCall means do not
# perform outbound call. This flag has no effect on the nodes
# explicitly specified in the command line.
# Default options are "everything allowed".
# options ((!CM) & time Any0700-0200) Nocall
#options (time Any0900-2100 & ! address 2:5020/*) Nocall
# EMSI data for this node
# From this line on values CANNOT be prefixed with logical expression
# For now, escaping of '}' and ']' unimplemented, try to avoid these
# characters please!

View File

@ -1,14 +0,0 @@
# PhoneTrans lines provide rules to change phone prefixes to make local
# or long-distance calls. In the example below, my country code is 7,
# and local dialing area is 095. From the numbers starting with "7-095-"
# the prefix is stripped and the 7-digit remainder is dialed. For
# the numbers starting with "7-" but not with "7-095-", the country prefix
# "7-" is stripped and the long-distance dialing prefix "8W" substituted.
# For the numbers not matching any of the above, international
# call is performed: international dialing prefix "8W10" is prepended
# to the unmodified 11-digit number. Generally, the syntax is:
# "PhoneTrans <what-to-strip> / <what-to-substitute-instead>"
#PhoneTrans 7-095- /
#PhoneTrans 7- / 8W
#PhoneTrans / 8W10

View File

@ -1,9 +0,0 @@
#!/bin/sh
# ver 0.7
# ifpoll, poll my boss node or the node given as argument 1
#
# i start this shell script every day by crond, but you can
# start it also by hand :) start it as the owner of ifcico.
# rasca, berlin 1993 (Rasca Gmelch, 2:2410/305.4)
#
# where "ifcico" and "ifpack" reside

View File

@ -1,107 +0,0 @@
# Packets backup directory - You have to CREATE this directory
BAK=/var/spool/ifmail/BAK
# logfile of ifcico
IFLOG=/var/log/ifmail/sysiflog
# log archive
IFLOGARC=/var/log/ifmail/TheLog
# owner of "ifcico"
IFCICO_OWNER=fnet
# how often should i try to call NODE?
MaxTry=30
# delay between outgoing calls in seconds
DELAY=10
# where to log processing - file or tty/console
INFO_TTY=/dev/console
# Lets backup the log and use a new one
if [ -e $IFLOG ]; then
echo Rearranging logs...
cat $IFLOG >> $IFLOGARC
cp /dev/null $IFLOG
fi
echo "`date \"+%b %d %T\"` ifpoll[$$]: starting" # >> $INFO_TTY
# remember me, not to run as root..
#
if [ `whoami` != "$IFCICO_OWNER" ]; then
echo "*** run $0 as the owner of ifcico ***"
echo "`date \"+%b %d %T\"` ifpoll[$$]: wrong uid (rc 2)" # >> $INFO_TTY
exit 2
fi
# argv[1] is the optional node to call
#
if [ "$1" != "" ]; then
if [ "$1" = "-?" ] || [ "$1" = "-h" ]; then
echo "usage: ifpoll [<node>]"
exit 3
else
NODE=$1
fi
fi
# let's pack the fido stuff..
#
$FIDOPATH/ifpack
# loop until ifcico could connect the node or MaxTry is encountered
#
i=1; errlv=1
while let 'i <= MaxTry' && let 'errlv != 0'
do
echo -n "`date \"+%b %d %T\"` ifpoll[$$]: $i. try ($NODE) " # >> $INFO_TTY
#
# start ifcico in master mode ..
#
$FIDOPATH/ifcico -r 1 $NODE
errlv=$?
if [ $errlv != "0" ]; then
echo "failed" # >> $INFO_TTY
if [ $i != $MaxTry ]; then
sleep $DELAY
fi
let i=i+1
else
echo "ok :)" # >> $INFO_TTY
fi
done
# if the poll was fine, unpacking..
#
if [ $errlv = "0" ]; then
echo "`date \"+%b %d %T\"` ifpoll[$$]: unpacking.. " # >> $INFO_TTY
cp -f /var/spool/ifmail/inb/*.* $BAK
$FIDOPATH/ifunpack
# add here some additional lines for processing tic files or
# incoming file-lists or simular..
else
# write me a mail about the failed poll
tail --lines=20 $IFLOG | elm -s "ifpoll: failed" $IFCICO_SYSOP >/dev/null
fi
echo "`date \"+%b %d %T\"` ifpoll[$$]: finished (rc $errlv)" # >> $INFO_TTY
# Collect some infos...
echo ""
echo "*** Outgoing File Transfer Stats: ***"
grep sent $IFLOG
echo "*** Incoming File Transfer Stats: ***"
grep received $IFLOG
echo ""
echo "---->> New mail: <<-----"
grep echomail $IFLOG
echo "---->> Personal mail: <<-----"
grep "mail from" $IFLOG
echo ""
# return the errorlevel of ifcico
exit $errlv

View File

@ -1,20 +0,0 @@
#!/usr/bin/perl
$ver = "0.4";
#
# this perl script is designed for the ifmail package by eugene grosser.
#
# request a file (first argument) from a fido-node (second argument),
# don't forget to quote if you use wildcards, e.g.:
# ifreq 'files*' 2:2410/305
# or
# ifreq 'files newfile' 2:2410/305
#
# this perl script does only add an entry to the corresponding flo-file,
# the mailer ifcico is not started!
#
# rasca, berlin 1994 (rasca@marie.physik.tu-berlin.de, 2:2410/305.4)
#
# multi-zone support added by
# Roland Rosenfeld 15.05.1994 (roland@p13.flokiste.fido.de, 2:2450/300.13)

View File

@ -1,68 +0,0 @@
# this is the base directory, where the req-files are stored and the
# default outbound
$flo_path = "/var/spool/ifmail";
$outbound = "/outb"; # don't be confused, it means "/var/spool/ifmail/outb"
# end of configuration #############################################
# main()
#
if ((@ARGV < 1) || @ARGV > 2 || $ARGV[0] eq "-?") {
&usage;
} elsif ($ARGV[1] ne "") {
$node = $ARGV[1];
}
$file = $ARGV[0];
if (! ($node =~ /\d+:\d+\/\d+/)) {
die "Wrong address: $node!!!";
}
($zone, $netnode) = split (/:/, $node);
$reqfile = sprintf("%04x%04x", split(/\//, $netnode));
if ($reqfile eq "00000000") {
print ("can't resolve the fido address \"$node\"\n");
&usage;
} else {
if ( $zone == 2 ) {
$reqfile = $flo_path . $outbound . "/" . $reqfile . ".req";
} elsif ( $zone < 7 ) {
$reqfile = $flo_path . $outbound . ".00$zone/" . $reqfile . ".req";
} else {
$outbound = "";
open (CONFIG, "< $config") || die "can't open $config";
while ($_ = <CONFIG>) {
if ( /^address.*$zone:.*\@(\w*)/ ) { $outbound = $1; }
}
if ( $outbound eq "" ) {
die "No Zone $zone found in $config";
}
$reqfile = $flo_path . "/$outbound/" . $reqfile . ".req";
}
# seperate the file names of the first argument
@files = split (/\s+/, $ARGV[0]);
# open the flofile for appending
open(FLOFILE, ">>" . $reqfile) || die "can't open $reqfile";
while (@files) {
print (FLOFILE shift(@files), "\n");
}
close(FLOFILE);
print ("--- fido request $ver ---------------------------\n");
print ("requesting \"$file\" from fido-node $node\n");
print ("--- executing ifstat .. ------------------------\n");
system("ifstat");
}
#
# subroutine "usage"
#
sub usage {
printf ("--- fido request %s -------------\n", $ver);
printf ("usage: ifreq <file> [<3-d address>]\n");
printf ("e.g. : ifreq FILES 2:2410/305\n");
exit 1;
}

View File

@ -1,79 +0,0 @@
#! /bin/sh
## $Revision: 1.1 $
## News boot script.
## =()<. @<_PATH_SHELLVARS>@>()=
. /usr/lib/news/innshellvars
## Pick ${INND} or ${INNDSTART}
WHAT=${INNDSTART}
## Set to true or false
DOINNWATCH=false
MAIL="${MAILCMD} -s 'Boot-time Usenet warning on `hostname`' ${NEWSMASTER}"
## RFLAG is set below; set FLAGS as appropriate.
RFLAG=""
FLAGS="-i0 -c0"
## Clean shutdown?
if [ -f ${SERVERPID} ] ; then
( echo 'INND: PID file exists -- unclean shutdown!' >/dev/console )
RFLAG="-r"
fi
if [ ! -f ${NEWSLIB}/.news.daily ] ; then
echo 'No .news.daily file; need to run news.daily?' | eval ${MAIL}
else
case `find ${NEWSLIB} -name .news.daily -mtime +1 -print 2>/dev/null` in
"")
;;
*)
echo 'Old .news.daily file; need to run news.daily?' | eval ${MAIL}
;;
esac
fi
## Active file recovery.
if [ ! -s ${ACTIVE} ] ; then
if [ -s ${NEWACTIVE} ] ; then
mv ${NEWACTIVE} ${ACTIVE}
else
if [ -s ${OLDACTIVE} ] ; then
cp ${OLDACTIVE} ${ACTIVE}
else
( echo 'INND: No active file!' >/dev/console )
exit 1
fi
fi
RFLAG="-r"
# You might want to rebuild the DBZ database, too:
#echo "cd ${NEWSLIB} \
# && makehistory -r \
# && mv history.n.dir history.dir \
# && mv history.n.pag history.pag" | su ${NEWSUSER}
fi
## Remove temporary batchfiles and lock files.
( cd ${BATCH} && rm -f bch* )
( cd ${LOCKS} && rm -f LOCK* )
( cd ${TEMPSOCKDIR} && rm -f ${TEMPSOCK} )
rm -f ${NEWSCONTROL} ${NNTPCONNECT} ${SERVERPID}
## Start the show.
( echo 'Starting innd.' >/dev/console )
eval ${WHAT} ${RFLAG} ${FLAGS}
# Gee, looks like lisp, doesn't it?
${DOINNWATCH} && {
echo "( ( sleep 60 ; ${INNWATCH} ) & )" | su ${NEWSUSER}
}
RMFILE=${MOST_LOGS}/expire.rm
if [ -s ${MOST_LOGS}/expire.rm ] ; then
( echo "Removing articles from pre-downtime expire run." >/dev/console )
(
echo 'System shut down during expire. Unlinking articles listed in'
echo ${RMFILE}
) | eval ${MAIL}
echo "${NEWSBIN}/expirerm ${RMFILE}" | su ${NEWSUSER} &
fi

View File

@ -1,74 +0,0 @@
#! /bin/sh
## $Revision: 1.1 $
## SH script to send UUCP batches out.
## =()<. @<_PATH_SHELLVARS>@>()=
. ~news/innshellvars
PROGNAME=`basename $0`
LOCK=${LOCKS}/LOCK.${PROGNAME}
LOG=${MOST_LOGS}/${PROGNAME}.log
MAXJOBS=200
UUXFLAGS="- -r -gd"
## Start logging.
test ! -f ${LOG} && touch ${LOG}
chmod 0660 ${LOG}
exec >>${LOG} 2>&1
echo "${PROGNAME}: [$$] begin `date`"
cd ${BATCH}
## Anyone else there?
trap 'rm -f ${LOCK} ; exit 1' 1 2 3 15
shlock -p $$ -f ${LOCK} || {
echo "${PROGNAME}: [$$] locked by [`cat ${LOCK}`]"
exit 0
}
## Who are we sending to?
if [ -n "$1" ] ; then
LIST="$*"
else
LIST=`ls /usr/spool/news/out.going|egrep "f[0-9]*.n[0-9]*$"`
fi
case ${HAVE_UUSTAT} in
DONT)
TEMP=${TMPDIR}/uuq$$
uuq -h |tr -d : >${TEMP}
;;
esac
## Do the work...
for SITE in ${LIST}; do
## See if any data is ready for host.
BATCHFILE=${SITE}.uucp
if [ -f ${SITE}.work ] ; then
cat ${SITE}.work >>${BATCHFILE}
rm -f ${SITE}.work
fi
mv ${SITE} ${SITE}.work
ctlinnd -s -t30 flush ${SITE} || continue
cat ${SITE}.work >>${BATCHFILE}
rm -f ${SITE}.work
if [ ! -s ${BATCHFILE} ] ; then
echo "${PROGNAME}: [$$] no articles for ${SITE}"
rm -f ${BATCHFILE}
continue
fi
## Get the compression flags.
echo "${PROGNAME}: [$$] begin ${SITE}"
case "${SITE}" in
phreak)
COMPRESS="compress"
;;
*)
COMPRESS="gzip"
;;
esac
time batcher \

View File

@ -1,15 +0,0 @@
${SITE} ${BATCHFILE}
echo "${PROGNAME}: [$$] end ${SITE}"
done
case ${HAVE_UUSTAT} in
DONT)
rm -f ${TEMP}
;;
esac
## Remove the lock file.
rm -f ${LOCK}
echo "${PROGNAME}: [$$] end `date`"

View File

@ -1,13 +0,0 @@
TRNINIT="-x -e -X -F\" :> \""
HIDELINE="^X-FTN"
NEWSHEADER="Newsgroups: %(%F=^\$?%C:%F)
Subject: %(%S=^\$?%\"\n\nSubject: \":%S)
%(%R=^\$?:References: %R
)Sender:
Distribution: %(%i=^\$?%\"\nDistribution: \":%D)
Organization: %o
X-Comment-To: %f\n\n"
ATTRIBUTION="%f writes:\n"
YOUSAID="In article %i \n of newsgroup %C you write about \"%s\":\n"
MAILCALL="(New Mail)"
export NEWSHEADER HIDELINE TRNINIT ATTRIBUTION MAILCALL YOUSAID EDITOR

View File

@ -1,54 +0,0 @@
#!/bin/bash
# $Id: copi.wheel,v 1.2 2001/01/15 22:26:33 tom Exp $
mkstemp size
dialog --print-maxsize 2>$tmp_size
ROWS="`cut $tmp_size -f1 -d, | cut -f2 -d:`"
COLS="`cut $tmp_size -f2 -d,`"
rm $tmp_size
# Takes an integer, multiplies it for COLS, divides for 132
scalex() {
echo $[$1*$COLS/132]
}
scaley() {
echo $[$1*$ROWS/60]
}
dialog --backtitle "$TITLE" --no-shadow \
--begin `scaley 27` `scalex 98` --infobox "pushd /var/log >/dev/null" 0 0 --and-widget \
--begin `scaley 35` `scalex 95` --infobox "mkdir -p news -m 755" 0 0 --and-widget \
--begin `scaley 45` `scalex 86` --infobox "chown news.news news" 0 0 --and-widget \
--begin `scaley 48` `scalex 78` --infobox "cd /var/log/news" 0 0 --and-widget \
--begin `scaley 51` `scalex 61` --infobox "mkdir -p OLD -m 755" 0 0 --and-widget \
--begin `scaley 52` `scalex 47` --infobox "chown news.news OLD" 0 0 --and-widget \
--begin `scaley 51` `scalex 40` --infobox "cd /var/spool" 0 0 --and-widget \
--begin `scaley 48` `scalex 25` --infobox "mkdir -p news -m 775" 0 0 --and-widget \
--begin `scaley 42` `scalex 13` --infobox "chown news.news news" 0 0 --and-widget \
--begin `scaley 35` `scalex 4` --infobox "cd /var/spool/news" 0 0 --and-widget \
--begin `scaley 27` `scalex 2` --infobox "CURMASK=`umask`" 0 0 --and-widget \
--begin `scaley 19` `scalex 4` --infobox "umask 02" 0 0 --and-widget \
--begin `scaley 11` `scalex 13` --infobox "mkdir -p out.going control junk in.coming" 0 0 --and-widget \
--begin `scaley 5` `scalex 25` --infobox "chown news.news out.going control junk in.coming" 0 0 --and-widget \
--begin `scaley 2` `scalex 37` --infobox "cd in.coming" 0 0 --and-widget \
--begin `scaley 1` `scalex 46` --infobox "mkdir -p bad tmp" 0 0 --and-widget \
--begin `scaley 2` `scalex 61` --infobox "chown news.news bad tmp" 0 0 --and-widget \
--begin `scaley 5` `scalex 76` --infobox "umask $CURMASK" 0 0 --and-widget \
--begin `scaley 11` `scalex 87` --infobox "ln -sf ~news /usr/local/lib/" 0 0 --and-widget \
--begin `scaley 18` `scalex 95` --infobox "ln -sf ~news/inews /usr/bin/" 0 0 --and-widget \
--begin `scaley 26` `scalex 97` --infobox "chmod 1777 /var/tmp" 0 0 --and-widget \
--begin `scaley 34` `scalex 95` --infobox "cd ~news" 0 0 --and-widget \
--begin `scaley 42` `scalex 87` --infobox "touch history history.dir history.pag errlog log" 0 0 --and-widget \
--begin `scaley 47` `scalex 76` --infobox "chown news.news history* log errlog" 0 0 --and-widget \
--sleep 1 --infobox "Creating spooling and logging directories and files..." 0 0 --and-widget \
--begin `scaley 51` `scalex 78` --infobox "chmod 664 history* log errlog" 0 0 --and-widget \
--begin `scaley 52` `scalex 60` --infobox "echo \"control 0000000000 0000000001 y\" > active" 0 0 --and-widget \
--begin `scaley 51` `scalex 42` --infobox "echo \"junk 0000000000 0000000001 y\" >> active" 0 0 --and-widget \
--begin `scaley 48` `scalex 26` --infobox "chown news.news active" 0 0 --and-widget \
--begin `scaley 42` `scalex 13` --infobox "echo \"control 814573260 usenet\" > active.times" 0 0 --and-widget \
--begin `scaley 35` `scalex 4` --infobox "echo \"junk 814573260 usenet\" >> active.times" 0 0 --and-widget \
--begin `scaley 27` `scalex 2` --infobox "chown news.news active.times" 0 0 --and-widget \
--begin `scaley 19` `scalex 4` --infobox ":>newsgroups" 0 0 --and-widget \
--begin `scaley 11` `scalex 12` --infobox "chown news.news newsgroups" 0 0 --and-widget \
--begin `scaley 6` `scalex 25` --infobox "popd >/dev/null" 0 0
sleep 1

View File

@ -1,101 +0,0 @@
--- ifgate/message.c.orig Mon Jul 24 15:17:47 1995
+++ ifgate/message.c Mon Jul 24 15:18:00 1995
@@ -48,12 +48,26 @@
if (!strcasecmp(msg->key,"X-UUCP-From")) return 0;
if (!strcasecmp(msg->key,"X-Body-Start")) return 0;
if (!strncasecmp(msg->key,"X-FTN-",6)) return 0;
- if (!strcasecmp(msg->key,"Path")) return isftnpath(msg->val)?0:1;
+ if (!strcasecmp(msg->key,"Path"))
+
+#ifdef LESS_RFC_KLUDGES
+ return 0;
+#else
+ return isftnpath(msg->val)?0:1;
+#endif
+
if (!strcasecmp(msg->key,"Newsgroups")) return newsmode?0:2;
if (!strcasecmp(msg->key,"Xref")) return 0;
if (!strcasecmp(msg->key,"Return-Receipt-To")) return 1;
if (!strcasecmp(msg->key,"Received")) return newsmode?0:2;
- if (!strcasecmp(msg->key,"From")) return ftnorigin?0:2;
+ if (!strcasecmp(msg->key,"From"))
+
+#ifdef LESS_RFC_KLUDGES
+ return 0;
+#else
+ return ftnorigin?0:2;
+#endif
+
if (!strcasecmp(msg->key,"To"))
{
if (newsmode) return 0;
@@ -66,7 +80,14 @@
}
if (!strcasecmp(msg->key,"Cc")) return 2;
if (!strcasecmp(msg->key,"Bcc")) return 2;
- if (!strcasecmp(msg->key,"Reply-To")) return 2;
+ if (!strcasecmp(msg->key,"Reply-To"))
+
+#ifdef LESS_RFC_KLUDGES
+ return 0;
+#else
+ return 2;
+#endif
+
if (!strcasecmp(msg->key,"Lines")) return 0;
if (!strcasecmp(msg->key,"Date")) return 0;
if (!strcasecmp(msg->key,"Subject"))
@@ -77,8 +98,22 @@
if (!strcasecmp(msg->key,"Organization")) return removeorg?0:1;
if (!strcasecmp(msg->key,"Comment-To")) return 0;
if (!strcasecmp(msg->key,"X-Comment-To")) return 0;
- if (!strcasecmp(msg->key,"Keywords")) return 2;
- if (!strcasecmp(msg->key,"Summary")) return 2;
+ if (!strcasecmp(msg->key,"Keywords"))
+
+#ifdef LESS_RFC_KLUDGES
+ return 0;
+#else
+ return 2;
+#endif
+
+ if (!strcasecmp(msg->key,"Summary"))
+
+#ifdef LESS_RFC_KLUDGES
+ return 0;
+#else
+ return 2;
+#endif
+
if (!strcasecmp(msg->key,"MIME-Version")) return removemime?0:1;
if (!strcasecmp(msg->key,"Content-Type")) return removemime?0:1;
if (!strcasecmp(msg->key,"Content-Length")) return removemime?0:1;
@@ -86,8 +121,26 @@
if (!strcasecmp(msg->key,"Content-Name")) return 2;
if (!strcasecmp(msg->key,"Content-Description")) return 2;
if (!strcasecmp(msg->key,"Message-ID")) return ftnorigin?0:1;
- if (!strcasecmp(msg->key,"References")) return removeref?0:1;
- if (!strcasecmp(msg->key,"Distribution")) return ftnorigin?0:1;
+ if (!strcasecmp(msg->key,"References"))
+
+#ifdef LESS_RFC_KLUDGES
+ return 0;
+#else
+ return removeref?0:1;
+#endif
+
+ if (!strcasecmp(msg->key,"Distribution"))
+
+#ifdef LESS_RFC_KLUDGES
+ return 0;
+#else
+ return ftnorigin?0:1;
+#endif
+
+#ifdef LESS_RFC_KLUDGES
+ if (!strcasecmp(msg->key,"NNTP-Posting-Host")) return 0;
+#endif
+
/*if (!strcasecmp(msg->key,"")) return ;*/
return 1;
}

View File

@ -1,296 +0,0 @@
#!/bin/bash
# $Id: copismall,v 1.8 2010/01/13 10:26:52 tom Exp $
#
# ComeOn Point Installer! v0.9a.small (small version for cdialog v0.9a)
# - installa il point in modo visuale e auto-detecting. Versione light.
#
# AUTHOR: Beppe (beppe.dem@nsm.it)
#
# This program 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# THIS IS NOT THE ORIGINAL VERSION!!!! This files was adequate to be
# a demo for cdialog v0.9a+. However it doesn't include all its features.
# Look for one of the free ComeOn Linux! tools to have a complete
# demo of cdialog. ComeOn Linux! follows the GNU philosophy.
# Send peacefully a mail to demarco_p@abramo.it for more info.
. ./setup-vars
#COMEONDIR=/usr/lib/ComeOn
#POINTDIR=$COMEONDIR/point
POINTDIR=`pwd`
AKASETUP=$POINTDIR/.akasetup
PNTSETUP=$POINTDIR/.pntsetup
EMSIFILE=$POINTDIR/.emsi
COPIUSER=$POINTDIR/.copi.user
COPIVER=v0.9a.small
TITLE="ComeOn Point Installer! $COPIVER -+- (c) 1996 ComeOn Linux!"
#FUNCSVER=v0.9.2
#FUNCSDIR=$POINTDIR/funcs-$FUNCSVER
FUNCSDIR=$POINTDIR/copifuncs
#COPIDIR=$POINTDIR/copi-$COPIVER
#. $COPIDIR/copishellvars
#POINTVER="v1.1" # ComeOn Point version
if [ $LOGNAME != root ]
then
$DIALOG --backtitle "$TITLE" --title "Error!" --beep --msgbox "Questo programma per funzionare correttamente deve essere avviato dall'amministratore di sistema (root)." 0 0
exit
fi
$DIALOG --backtitle "$TITLE" --title "Are you sure?" --cr-wrap --msgbox "Questo installer procedera' in modalita'
auto-detect all'installazione del point.
Premi <Enter> per iniziare o <Esc> per uscire. " 0 0
if [ $? = $DIALOG_CANCEL -o $? = $DIALOG_ESC ]; then
exit
fi
pushd $FUNCSDIR >/dev/null
. ./copi.funcs
. ./common.funcs
. ./admin.funcs
###############################################################################
find_incompatible_packages
if [ "$PKG_TO_REMOVE" ]
then
$DIALOG --backtitle "$TITLE" --beep --title "Problem detected" --msgbox "Attenzione, prima di poter continuare bisogna avviare pkgtool e rimuovere i seguenti packages: $PKG_TO_REMOVE." 0 0
exit
fi
###############################################################################
mkstemp dialog
find_necessary_packages
if [ "$PKG_TO_INSTALL" ]
then
echo -n "Attenzione, prima di poter continuare bisogna avviare setup ed installare i seguenti packages dai disk sets N (quelli del Networking): $PKG_TO_INSTALL." >$tmp_dialog
if [ "`echo $PKG_TO_INSTALL | grep tcpip`" ]
then
echo -n " Ricordarsi poi di effettuare lo shutdown per rendere effettive le modifiche." >>$tmp_dialog
fi
$DIALOG --backtitle "$TITLE" --beep --title "Problem detected" --msgbox "`cat $tmp_dialog`" 0 0
rm $tmp_dialog
exit
fi
###############################################################################
mkstemp smailp
SMAILTGZ=""
if [ ! -d /usr/lib/smail ]
then
$DIALOG --backtitle "$TITLE" --title "Smail not found" --inputbox "Bisogna installare Smail, per cui inserire il percorso completo di dove trovarne i binari compressi" 0 0 "/cdrom/sunsite/system/Mail/delivery/smail-linuxbin-3.1.29.1.tar.gz" 2>$tmp_smailp
SMAILTGZ="`cat $tmp_smailp`"
rm $tmp_smailp
while [ ! -f "$SMAILTGZ" ]
do
$DIALOG --backtitle "$TITLE" --beep --title "Archive not found" --inputbox "Percorso di file \"$SMAILTGZ\" non valido, controllarne la correttezza." 0 0 "/cdrom/sunsite/system/Mail/delivery/smail-linuxbin-3.1.29.1.tar.gz" 2>$tmp_smailp
SMAILTGZ="`cat $tmp_smailp`"
rm $tmp_smailp
done
fi
###############################################################################
mkstemp target
mkstemp asetup
mkstemp psetup
AKA=""
while [ ! "$AKA" ]
do
$DIALOG --backtitle "$TITLE" --title "Primary address" --inputbox "Inserire il proprio address principale, completo di point e di domain. Il poll sara' effettuato per default dal boss corrispondente." 0 0 "2:335/722.7@fidonet" 2>$tmp_target
AKAFTN="`cat $tmp_target`"
rm $tmp_target
fidonetpoint2int $AKAFTN
AKA="$_RETVAL"
done
echo -n "`echo $AKA | cut -f2- -d.`:" >$tmp_asetup
echo -n "`echo $AKA | cut -f1 -d. | cut -c2-`:" >$tmp_psetup
AKASFTN="$AKAFTN"
AKAS="$AKA"
while [ "$AKAFTN" ]
do
$DIALOG --backtitle "$TITLE" --title "AKAs" --inputbox "Inserire un eventuale address secondario, oppure lasciare la riga vuota per proseguire. Attenzione: nel caso si abbiano piu' indirizzi sulla stessa rete, bisognera' configurare solo uno di questi. Gli indirizzi correntemente definiti sono: $AKASFTN" 0 0 2>$tmp_target
AKAFTN="`cat $tmp_target`"
rm $tmp_target
if [ "$AKAFTN" ]
then
fidonetpoint2int $AKAFTN
AKA="$_RETVAL"
if [ "`echo $AKAS | grep \".\`echo $AKA | cut -f5 -d.\`.\"`" ]
then
$DIALOG --backtitle "$TITLE" --beep --title "Invalid address" --msgbox "Non si possono avere piu' indirizzi sullo stesso dominio (net)." 0 0
else
AKASFTN="$AKASFTN $AKAFTN"
AKAS="$AKAS $AKA"
echo -n "`echo $AKA | cut -f2- -d.`:" >>$tmp_asetup
echo -n "`echo $AKA | cut -f1 -d. | cut -c2-`:" >>$tmp_psetup
fi
fi
done
echo ":" >>$tmp_asetup
echo ":" >>$tmp_psetup
save $AKASETUP
save $PNTSETUP
mv $tmp_asetup $AKASETUP
mv $tmp_psetup $PNTSETUP
###############################################################################
mkstemp hostnm
$DIALOG --backtitle "$TITLE" --title "Hostname" --inputbox "Inserire l'hostname di questo computer qualora si abbia una rete gia' configurata, altrimenti inventarne uno fittizio da assegnare e questa macchina verra' configurata per il loopback." 0 0 "quark.comeon.org" 2>$tmp_hostnm
NEW_HOSTNAME="`cat $tmp_hostnm`"
rm $tmp_hostnm
###############################################################################
mkstemp master
$DIALOG --backtitle "$TITLE" --title "Point admin" --inputbox "Scegliere l'user principale per la gestione e l'uso del point. Se l'user non esiste, verra' creato. Se esiste, ne verranno adattate le informazioni quali nome, gruppi, etc." 0 0 "beppe" --and-widget --title "Insert SysOp's name" --inputbox "Inserire nome e cognome del gestore ed utilizzatore principale del point (il proprio nome)." 0 0 "Giuseppe De Marco" --and-widget --title "Choose editor" --inputbox "Scegliere l'editor da usare per scrivere i messaggi" 0 0 "vim" 2>$tmp_master
POST_USER="`cut $tmp_master -f1`"
POST_NAME="`cut $tmp_master -f2`"
POST_EDIT="`cut $tmp_master -f3`"
rm $tmp_master
save $COPIUSER
echo $POST_USER >$COPIUSER
###############################################################################
mkstemp expire
mkstemp origin
$DIALOG --backtitle "$TITLE" --title "Origin" --inputbox "Scegliere l'Origin del sistema" 9 60 "$POST_USER's linux box" 2>$tmp_origin
NEW_ORIGIN="`cat $tmp_origin`"
rm $tmp_origin
$DIALOG --backtitle "$TITLE" --title "News expiring" --inputbox "Decidere per quanti giorni i messaggi echomail (le news) dovranno transitare sul sistema prima di venire cancellati automaticamente da news.daily. Inserire never se si vuole che non vengano mai cancellati. Sono ammesse cifre decimali (i.e. 25.5). Notare comunque che il valore qui inserito e' quello di default, ma per ogni singola area (newsgroup) sara' possibile specificare poi un valore appropriato." 0 0 "30" 2>$tmp_expire
KEEPDAYS="`cat $tmp_expire`"
rm $tmp_expire
###############################################################################
mkstemp dialer
mkstemp ifmail
mkstemp mailvr
mkstemp passwd
IFMAILTGZ=""
IFMAILVERS=""
if [ ! -d /usr/lib/ifmail -o ! -d /etc/ifmail -o ! -d /var/log/ifmail -o ! -f /usr/lib/ifmail/ifcico ]
then
$DIALOG --backtitle "$TITLE" --title "ifmail not found" --inputbox "Inserire il percorso COMPLETO dei sorgenti compressi di ifmail che verranno decompressi in /usr/src e compilati." 0 0 "/cdrom/sunsite/system/Mail/transport/ifmail-2.8b.tar.gz" 2>$tmp_ifmail
IFMAILTGZ="`cat $tmp_ifmail`"
rm $tmp_ifmail
while [ ! -f "$IFMAILTGZ" ]
do
$DIALOG --backtitle "$TITLE" --beep --title "invalid filename" --inputbox "Percorso di file \"$IFMAILTGZ\" non valido, controllarne la correttezza." 0 0 "/cdrom/sunsite/system/Mail/transport/ifmail-2.8b.tar.gz" 2>$tmp_ifmail
IFMAILTGZ="`cat $tmp_ifmail`"
rm $tmp_ifmail
done
$DIALOG --backtitle "$TITLE" --title "ifmail version" --inputbox "Specificare la versione di ifmail" 0 0 "2.8b" 2>$tmp_mailvr
IFMAILVERS="`cat $tmp_mailvr` + ComeOn Point $POINTVER"
rm $tmp_mailvr
fi
IAKA=1
PASSW=""
AKA="`cut $AKASETUP -f$IAKA -d:`"
while [ "$AKA" ]
do
int2fido $AKA
AKAFTN="$_RETVAL"
$DIALOG --backtitle "$TITLE" --title "Password" --inputbox "Specificare la password di sessione e per i pacchetti per il nodo $AKAFTN -- attenzione che alcuni mailers accettano solo passwords da 8 caratteri in maiuscolo!!" 0 0 "MYPASSWD" 2>$tmp_passwd
PASSW="$PASSW`cat $tmp_passwd`:"
rm $tmp_passwd
IAKA=$[$IAKA+1]
AKA="`cut $AKASETUP -f$IAKA -d:`"
done
PASSW="$PASSW:"
$DIALOG --backtitle "$TITLE" \
--title "Modem speed" --inputbox "Specificare la velocita' del proprio modem (che sta su /dev/modem)" 0 0 "16800" --and-widget \
--title "System name" --inputbox "Specificare il nome del sistema per il pacchetto EMSI" 0 0 "`cat $COPIUSER`'s linux point" --and-widget \
--title "Location" --inputbox "Inserire la localita' fisica in cui risiede il sistema" 0 0 "Catanzaro, Italy - Europe" --and-widget \
--title "Phone number" --inputbox "Inserire il proprio numero di telefono in formato internazionale, cioe' completo di doppio prefisso (xx-yyy-zzzzzz)" 0 0 "39-961-31997" --and-widget \
--title "International call prefix" --inputbox "Specificare il prefisso da comporre per poter effettuare una chiamata internazionale (se ci si trova in Italia ad es. bisogna inserire 00)" 0 0 "00" --and-widget \
--title "Long-distance call prefix" --inputbox "Specificare il prefisso da comporre per poter effettuare una chiamata interurbana in ambito nazionale, che verra' sostituito al prefisso della propria nazione quando incontrato in nodelist (per l'Italia ad es. bisogna inserire 0, che sostituira' il 39)" 0 0 "0" --and-widget \
--title "Pointlist flags" --inputbox "Inserire eventuali flags stile pointlist per il pacchetto EMSI" 0 0 "MO,V32B,V42B,ZYX" --and-widget \
--title "Modem dialing" --inputbox "Inserire la stringa da inviare al modem per comporre un numero telefonico" 0 0 "ATDT" 2>$tmp_dialer
echo -en "\t$POST_NAME\t\t" >>$tmp_dialer
save $EMSIFILE
mv $tmp_dialer $EMSIFILE
###############################################################################
if [ -d /etc/smail ]
then
SMAILCFGDIR=/etc/smail
else
SMAILCFGDIR=/usr/lib/smail
fi
###############################################################################
$DIALOG --backtitle "$TITLE" --title "First step completed!" --msgbox "OK, ora ho tutte le informazioni necessarie per poter installare il point. Da qui in poi faro' tutto da solo, quindi ci si puo' tranquillamente andare a prendere un caffe'. :-)" 0 0
###############################################################################
killall sendmail 2>/dev/null
if [ $SMAILTGZ ]; then tar zxvf $SMAILTGZ -C / >/dev/null; fi
/usr/sbin/sendmail -bd -q15m
if [ ! "`ping -c1 $NEW_HOSTNAME | grep \"1 packets received\"`" ]; then
configure_loopback $NEW_HOSTNAME
fi
add_postmaster "$POST_USER" "$POST_NAME"
add_alias "$POST_NAME" "$POST_USER"
configure_trn "$POST_USER" "$POST_EDIT"
configure_elm "$POST_USER" "$POST_EDIT"
comment_nntp_in_inetdconf
set_organization "$NEW_ORIGIN"
create_innconf_newsfeeds_distrib
create_expirectl $KEEPDAYS
create_nnrpaccess
create_hostsnntp
create_dirs_and_files
install_rcnews
install_crontab_news
if [ $IFMAILTGZ ]; then
install_ifmail "$IFMAILTGZ" /usr/lib/ifmail /etc/ifmail /var/log/ifmail "$IFMAILVERS" /usr/src
fi
configure_ifmail /usr/lib/ifmail /etc/ifmail /var/log/ifmail "$PASSW"
configure_smail $SMAILCFGDIR
###############################################################################
$DIALOG --backtitle "$TITLE" \
--title "-=[ Enjoy! ]=-" --msgbox "Il point e' stato installato con successo!" 0 0 --and-widget \
--msgbox "trn (il newsreader, per leggere/scrivere gli echomail) ed elm (il mailreader, per leggere/scrivere i netmail) sono gia' stati configurati per l'user $POST_USER." 0 0
popd >/dev/null

View File

@ -1,4 +1,4 @@
# $Id: debian.rc,v 1.5 2011/01/17 00:14:53 tom Exp $
# $Id: debian.rc,v 1.7 2011/10/15 01:00:09 tom Exp $
# vile:confmode
# Run-time configuration file for dialog, matches Debian color scheme.
# (these are the default values for dialog)
@ -47,10 +47,10 @@ border_color = (WHITE,WHITE,ON)
button_active_color = (WHITE,BLUE,ON)
# Inactive button color
button_inactive_color = (BLACK,WHITE,OFF)
button_inactive_color = dialog_color
# Active button key color
button_key_active_color = (WHITE,BLUE,ON)
button_key_active_color = button_active_color
# Inactive button key color
button_key_inactive_color = (RED,WHITE,OFF)
@ -62,64 +62,64 @@ button_label_active_color = (YELLOW,BLUE,ON)
button_label_inactive_color = (BLACK,WHITE,ON)
# Input box color
inputbox_color = (BLACK,WHITE,OFF)
inputbox_color = dialog_color
# Input box border color
inputbox_border_color = (BLACK,WHITE,OFF)
inputbox_border_color = dialog_color
# Search box color
searchbox_color = (BLACK,WHITE,OFF)
searchbox_color = dialog_color
# Search box title color
searchbox_title_color = (BLUE,WHITE,ON)
searchbox_title_color = title_color
# Search box border color
searchbox_border_color = (WHITE,WHITE,ON)
searchbox_border_color = border_color
# File position indicator color
position_indicator_color = (BLUE,WHITE,ON)
position_indicator_color = title_color
# Menu box color
menubox_color = (BLACK,WHITE,OFF)
menubox_color = dialog_color
# Menu box border color
menubox_border_color = (WHITE,WHITE,ON)
menubox_border_color = border_color
# Item color
item_color = (BLACK,WHITE,OFF)
item_color = dialog_color
# Selected item color
item_selected_color = (WHITE,BLUE,ON)
item_selected_color = button_active_color
# Tag color
tag_color = (BLUE,WHITE,ON)
tag_color = title_color
# Selected tag color
tag_selected_color = (YELLOW,BLUE,ON)
tag_selected_color = button_label_active_color
# Tag key color
tag_key_color = (RED,WHITE,OFF)
tag_key_color = button_key_inactive_color
# Selected tag key color
tag_key_selected_color = (RED,BLUE,ON)
# Check box color
check_color = (BLACK,WHITE,OFF)
check_color = dialog_color
# Selected check box color
check_selected_color = (WHITE,BLUE,ON)
check_selected_color = button_active_color
# Up arrow color
uarrow_color = (GREEN,WHITE,ON)
# Down arrow color
darrow_color = (GREEN,WHITE,ON)
darrow_color = uarrow_color
# Item help-text color
itemhelp_color = (WHITE,BLACK,OFF)
# Active form text color
form_active_text_color = (WHITE,BLUE,ON)
form_active_text_color = button_active_color
# Form text color
form_text_color = (WHITE,CYAN,ON)
@ -128,4 +128,16 @@ form_text_color = (WHITE,CYAN,ON)
form_item_readonly_color = (CYAN,WHITE,ON)
# Dialog box gauge color
gauge_color = (BLUE,WHITE,ON)
gauge_color = title_color
# Dialog box border2 color
border2_color = dialog_color
# Input box border2 color
inputbox_border2_color = dialog_color
# Search box border2 color
searchbox_border2_color = dialog_color
# Menu box border2 color
menubox_border2_color = dialog_color

View File

@ -0,0 +1,3 @@
#!/bin/sh
# $Id: dft-cancel,v 1.2 2012/07/03 09:44:02 tom Exp $
DIALOGOPTS="$DIALOGOPTS --extra-button --help-button --default-button cancel" "$@"

View File

@ -0,0 +1,3 @@
#!/bin/sh
# $Id: dft-extra,v 1.2 2012/07/03 09:44:02 tom Exp $
DIALOGOPTS="$DIALOGOPTS --extra-button --help-button --default-button extra" "$@"

View File

@ -0,0 +1,3 @@
#!/bin/sh
# $Id: dft-help,v 1.2 2012/07/03 09:44:02 tom Exp $
DIALOGOPTS="$DIALOGOPTS --extra-button --help-button --default-button help" "$@"

3
contrib/dialog/samples/dft-no Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
# $Id: dft-no,v 1.2 2012/07/03 09:44:02 tom Exp $
DIALOGOPTS="$DIALOGOPTS --extra-button --help-button --defaultno" "$@"

View File

@ -1,4 +1,5 @@
# $Id: dialog.py,v 1.3 2004/09/21 00:52:15 tom Exp $
#!/usr/bin/python
# $Id: dialog.py,v 1.4 2012/06/29 09:33:18 tom Exp $
# Module: dialog.py
# Copyright (c) 2000 Robb Shecter <robb@acm.org>
# All rights reserved.

View File

@ -1,11 +0,0 @@
#!/bin/sh
# $Id: dselect,v 1.6 2010/01/13 10:20:03 tom Exp $
. ./setup-vars
exec 3>&1
RESULT=`$DIALOG --title "Please choose a directory" "$@" --dselect $HOME/ 14 48 2>&1 1>&3`
retval=$?
exec 3>&-
. ./report-string

View File

@ -1,5 +1,5 @@
#! /bin/sh
# $Id: form1,v 1.14 2010/01/13 10:53:11 tom Exp $
# $Id: form1,v 1.15 2011/10/04 23:36:53 tom Exp $
. ./setup-vars
@ -63,8 +63,8 @@ $show" 10 40
echo "Button 3 (Extra) pressed."
exit
;;
$DIALOG_ERR)
echo "ERROR!"
$DIALOG_ERROR)
echo "ERROR!$value"
exit
;;
$DIALOG_ESC)

11
contrib/dialog/samples/fselect0 Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
# $Id: fselect0,v 1.1 2011/10/14 08:32:48 tom Exp $
. ./setup-vars
exec 3>&1
RESULT=`$DIALOG --title "Please choose a file" "$@" --fselect '' 14 48 2>&1 1>&3`
retval=$?
exec 3>&-
. ./report-string

View File

@ -1,60 +1,65 @@
#! /bin/bash
# $Id: inputmenu,v 1.10 2010/01/13 10:29:22 tom Exp $
#! /bin/sh
# $Id: inputmenu,v 1.15 2012/07/06 18:11:21 tom Exp $
# 2002 - written by Tobias Rittweiler <tobrit@freebits.de>
. ./setup-vars
user="$USER" ; uid="$UID" ;
gid="$GROUPS" ; home="$HOME" ;
user="$USER"
uid=`id|sed -e 's/^uid=//' -e 's/(.*//'`
gid=`id|sed -e 's/^.*gid=//' -e 's/(.*//'`
home="$HOME"
while [ ${returncode:-99} -ne 1 -a ${returncode:-99} -ne 250 ]; do
exec 3>&1
value=$("$DIALOG" --clear --ok-label "Create" \
--backtitle "An Example for the use of --inputmenu:" "$@" \
--inputmenu "Originally I designed --inputmenu for a \
exec 3>&1
value=`$DIALOG \
--clear --ok-label "Create" \
--backtitle "An Example for the use of --inputmenu:" "$@" \
--inputmenu "Originally I designed --inputmenu for a \
configuration purpose. Here is a possible piece of a configuration program. \
" 20 50 10 \
"Username:" "$user" \
"UID:" "$uid" \
"GID:" "$gid" \
"HOME:" "$home" \
2>&1 1>&3 )
returncode=$?
exec 3>&-
case $returncode in
$DIALOG_CANCEL)
"$DIALOG" --clear --backtitle "An Example for the use of --inputmenu:" \
--yesno "Really quit?" 10 30
case $? in
$DIALOG_OK) break;;
$DIALOG_CANCEL) returncode=99;;
esac
;;
$DIALOG_OK)
"$DIALOG" --clear --backtitle "An Example for the use of --inputmenu:" \
2>&1 1>&3 `
returncode=$?
exec 3>&-
case $returncode in
$DIALOG_CANCEL)
"$DIALOG" \
--clear --backtitle "An Example for the use of --inputmenu:" \
--yesno "Really quit?" 10 30
case $? in
$DIALOG_OK) break;;
$DIALOG_CANCEL) returncode=99;;
esac
;;
$DIALOG_OK)
"$DIALOG" \
--clear --backtitle "An Example for the use of --inputmenu:" \
--msgbox "useradd \n\
-d $home \n\
-u $uid \n\
-g $gid \n\
$user" 10 40
;;
$DIALOG_EXTRA)
value="${value:8:${#value}}"
tag="${value%:*}"
item="${value#*: }"
;;
$DIALOG_EXTRA)
value=`echo "$value" | sed -e 's/^RENAMED //'`
tag=`echo "$value" | sed -e 's/:.*//'`
item=`echo "$value" | sed -e 's/^[^:]*:[ ][ ]*//'`
case "$tag" in
Username) user="$item";;
UID) uid="$item";;
GID) gid="$item";;
HOME) home="$item";;
esac
;;
case "$tag" in
Username) user="$item" ;;
UID) uid="$item" ;;
GID) gid="$item" ;;
HOME) home="$item" ;;
esac
;;
$DIALOG_ESC)
echo "ESC pressed."
break
;;
$DIALOG_ESC)
echo "ESC pressed."
break
;;
esac
esac
done

View File

@ -1,53 +1,63 @@
#! /bin/bash
# $Id: inputmenu-stdout,v 1.8 2010/01/13 10:30:14 tom Exp $
#! /bin/sh
# $Id: inputmenu-stdout,v 1.13 2012/07/06 18:11:12 tom Exp $
# 2002 - written by Tobias Rittweiler <tobrit@freebits.de>
. ./setup-vars
user="$USER" ; uid="$UID" ;
gid="$GROUPS" ; home="$HOME" ;
user="$USER"
uid=`id|sed -e 's/^uid=//' -e 's/(.*//'`
gid=`id|sed -e 's/^.*gid=//' -e 's/(.*//'`
home="$HOME"
while [ ${returncode:-99} -ne 1 -a ${returncode:-99} -ne 250 ]; do
value="$("$DIALOG" --stdout --clear --ok-label "Create" \
--backtitle "An Example for the use of --inputmenu:" "$@" \
--inputmenu "Originally I designed --inputmenu for a \
configuration purpose. Here is a possible piece of a configuration program.
" 20 50 10 "Username:" "$user" "UID:" "$uid" "GID:" "$gid" "HOME:" "$home")"
returncode=$?
case $returncode in
$DIALOG_CANCEL)
"$DIALOG" --clear --backtitle "An Example for the use of --inputmenu:" \
--yesno "Really quit?" 10 30
case $? in
$DIALOG_OK) break;;
$DIALOG_CANCEL) returncode=99;;
esac
;;
$DIALOG_OK)
"$DIALOG" --clear --backtitle "An Example for the use of --inputmenu:" \
value=`$DIALOG \
--stdout --clear --ok-label "Create" \
--backtitle "An Example for the use of --inputmenu:" "$@" \
--inputmenu "Originally I designed --inputmenu for a \
configuration purpose. Here is a possible piece of a configuration program. \
" 20 50 10 \
"Username:" "$user" \
"UID:" "$uid" \
"GID:" "$gid" \
"HOME:" "$home" \
`
returncode=$?
case $returncode in
$DIALOG_CANCEL)
"$DIALOG" \
--clear --backtitle "An Example for the use of --inputmenu:" \
--yesno "Really quit?" 10 30
case $? in
$DIALOG_OK) break;;
$DIALOG_CANCEL) returncode=99;;
esac
;;
$DIALOG_OK)
"$DIALOG" \
--clear --backtitle "An Example for the use of --inputmenu:" \
--msgbox "useradd \n\
-d $home \n\
-u $uid \n\
-g $gid \n\
$user" 10 40
;;
$DIALOG_EXTRA)
value="${value:8:${#value}}"
tag="${value%:*}"
item="${value#*: }"
;;
$DIALOG_EXTRA)
value=`echo "$value" | sed -e 's/^RENAMED //'`
tag=`echo "$value" | sed -e 's/:.*//'`
item=`echo "$value" | sed -e 's/^[^:]*:[ ][ ]*//'`
case "$tag" in
Username) user="$item";;
UID) uid="$item";;
GID) gid="$item";;
HOME) home="$item";;
esac
;;
case "$tag" in
Username) user="$item" ;;
UID) uid="$item" ;;
GID) gid="$item" ;;
HOME) home="$item" ;;
esac
;;
$DIALOG_ESC)
echo "ESC pressed."
break
;;
$DIALOG_ESC)
echo "ESC pressed."
break
;;
esac
esac
done

View File

@ -1,5 +1,5 @@
#! /bin/sh
# $Id: inputmenu1,v 1.8 2010/01/13 10:31:02 tom Exp $
# $Id: inputmenu1,v 1.9 2012/07/01 00:59:54 tom Exp $
#
# "inputmenu" rewritten into Bourne shell.
@ -58,7 +58,7 @@ exec 3>&-
;;
$DIALOG_EXTRA)
tag=`echo "$value" |sed -e 's/^RENAMED //' -e 's/:.*//'`
item=`echo "$value" |sed -e 's/^.*:[ ]*//' -e 's/[ ]*$//'`
item=`echo "$value" |sed -e 's/^[^:]*:[ ]*//' -e 's/[ ]*$//'`
case "$tag" in
Username)

View File

@ -1,5 +1,5 @@
#! /bin/sh
# $Id: inputmenu2,v 1.8 2010/01/13 10:32:04 tom Exp $
# $Id: inputmenu2,v 1.9 2012/07/01 01:00:34 tom Exp $
#
# "inputmenu1" with defaultitem, help-button.
@ -66,7 +66,7 @@ exec 3>&-
;;
$DIALOG_EXTRA)
tag=`echo "$value" |sed -e 's/^RENAMED //' -e 's/:.*/:/'`
item=`echo "$value" |sed -e 's/^.*:[ ]*//' -e 's/[ ]*$//'`
item=`echo "$value" |sed -e 's/^[^:]*:[ ]*//' -e 's/[ ]*$//'`
case "$tag" in
Username:)

View File

@ -1,5 +1,5 @@
#! /bin/sh
# $Id: inputmenu3,v 1.10 2010/01/13 10:32:51 tom Exp $
# $Id: inputmenu3,v 1.11 2012/07/01 01:00:34 tom Exp $
#
# "inputmenu1" with defaultitem, help-button and item-help.
@ -75,7 +75,7 @@ exec 3>&-
;;
$DIALOG_EXTRA)
tag=`echo "$value" |sed -e 's/^RENAMED //' -e 's/:.*/:/'`
item=`echo "$value" |sed -e 's/^.*:[ ]*//' -e 's/[ ]*$//'`
item=`echo "$value" |sed -e 's/^[^:]*:[ ]*//' -e 's/[ ]*$//'`
case "$tag" in
Username:)

View File

@ -1,5 +1,5 @@
#! /bin/sh
# $Id: inputmenu4,v 1.8 2010/01/13 10:33:35 tom Exp $
# $Id: inputmenu4,v 1.9 2012/07/01 01:00:34 tom Exp $
#
# "inputmenu1" with a different label for the extra-button
@ -59,7 +59,7 @@ exec 3>&-
;;
$DIALOG_EXTRA)
tag=`echo "$value" |sed -e 's/^RENAMED //' -e 's/:.*//'`
item=`echo "$value" |sed -e 's/^.*:[ ]*//' -e 's/[ ]*$//'`
item=`echo "$value" |sed -e 's/^[^:]*:[ ]*//' -e 's/[ ]*$//'`
case "$tag" in
Username)

View File

@ -1,28 +0,0 @@
Disk /dev/hda: 14 heads, 62 sectors, 1018 cylinders
Units = cylinders of 868 * 512 bytes
Device Boot Begin Start End Blocks Id System
/dev/hda1 1 1 3 1271 a OS/2 Boot Manager
/dev/hda2 4 4 287 123256 6 DOS 16-bit >=32M
/dev/hda3 * 288 288 649 157108 83 Linux native
/dev/hda4 650 650 1018 160146 83 Linux native
Disk /dev/sda: 64 heads, 32 sectors, 511 cylinders
Units = cylinders of 2048 * 512 bytes
Device Boot Begin Start End Blocks Id System
/dev/sda1 1 1 21 21488 82 Linux swap
/dev/sda2 22 22 511 501760 83 Linux native
Disk /dev/sdb: 64 heads, 32 sectors, 4106 cylinders
Units = cylinders of 2048 * 512 bytes
Device Boot Begin Start End Blocks Id System
/dev/sdb1 1 1 201 205808 83 Linux native
/dev/sdb2 202 202 402 205824 83 Linux native
/dev/sdb3 403 403 603 205824 83 Linux native
/dev/sdb4 604 604 4106 3587072 5 Extended
/dev/sdb5 604 604 1803 1228784 83 Linux native
/dev/sdb6 1024 1804 3003 1228784 83 Linux native
/dev/sdb7 2048 3004 4106 1129456 83 Linux native

View File

@ -1,35 +0,0 @@
# $Id: makefile.in,v 1.1 2000/10/08 17:22:53 tom Exp $
# template makefile for DIALOG sample 'install'
#
SHELL = /bin/sh
prefix = @prefix@
exec_prefix = @exec_prefix@
srcdir = @srcdir@
top_builddir = ../..
DESTDIR =
bindir = $(DESTDIR)@bindir@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@ @DEFS@ -I$(top_builddir) -I$(srcdir)/../.. -I. -I$(srcdir)
EXTRA_CFLAGS = @EXTRA_CFLAGS@
CC = @CC@
LDFLAGS = @LDFLAGS@
LIBS = -L../.. -ldialog @LIBS@
RANLIB = @RANLIB@
RM = rm -f
all: setup
setup: setup.o
$(CC) -o $@ setup.o $(LIBS)
clean:
rm -f *.o setup
test: setup
./setup

View File

@ -1,371 +0,0 @@
/* Copyright (C) 1995 Florian La Roche */
/* Who wants to help coding? I don't like doing this... */
/* You can just start setup as normal user and see how far it is coded
right now. This will do a fake installation and won't actually chnage
any data on your computer. */
/* TODO: write a good package selection code
change functions to return better error code
*/
/* Show an extra text-box with the contents of all external commands,
before they are executed. So you can abort the installation, if any
wrong commands are to be executed. (So don't format wrong partition.) */
#define VERBOSE 1
/* If defined, don't actually execute any comands and don't actually modify
any files. So you can test any possible installation without doing any
damage to your computer.
The file FDISK.TEST is used instead of real "fdisk -l" output, so that
it can be started as normal user. */
#define DEBUG_THIS 1
#include <dialog.h>
/* max length of a partition name like e.g. '/dev/hda1' */
#define MAX_DEV_NAME 25
/* max number of possible Linux/Swap/MsDos partitions */
#define MAX_PARTS 20
char *progname = NULL;
static void
error(const char *s)
{
fprintf(stderr, "%s: %s\n", progname, s);
exit(1);
}
static int
my_system(const char *s,...)
{
int ret, i;
va_list ap;
char sh[200];
va_start(ap, s);
vsprintf(sh, s, ap);
va_end(ap);
#ifdef VERBOSE
i = dialog_msgbox("I will run the following command:", sh, 10, 65, 1);
dialog_clear();
#ifdef DEBUG_THIS
return 0;
#endif
#endif
ret = system(sh);
if (!(ret >> 8))
return 0;
i = dialog_msgbox("Error-Exit on the following command:",
sh, 12, 73, 1);
dialog_clear();
return 1;
}
/* We support to install from DOS/Linux-partitions. */
enum partition_type {
MsDos,
Linux,
Swap
};
struct partition {
enum partition_type type;
char name[MAX_DEV_NAME];
int blocks;
int flag;
} partitions[MAX_PARTS];
int num_partition = 0;
int num_linux = 0;
int num_swap = 0;
int num_msdos = 0;
static int
get_line(char *line, int size, FILE * f)
{
char *ptr = line;
int c;
if (feof(f))
return -1;
while (size-- && ((c = getc(f)) != EOF) && (c != '\n'))
*ptr++ = c;
*ptr++ = '\0';
return (int) (ptr - line);
}
static void
read_partitions(void)
{
FILE *f;
char line[200];
int length;
#ifndef DEBUG_THIS
int ret = system("fdisk -l 2>/dev/null 1>/tmp/fdisk.output");
if ((ret >> 8) != 0) {
error("fdisk didn't run");
}
if ((f = fopen("/tmp/fdisk.output", "r")) == NULL)
#else
if ((f = fopen("FDISK.TEST", "r")) == NULL)
#endif
error("cannot read fdisk output");
while (num_partition <= MAX_PARTS
&& (length = get_line(line, 200, f)) >= 0) {
if (strncmp(line, "/dev/", 5) == 0) {
int n = 0;
char *s = line + 5;
char *t = partitions[num_partition].name;
strcpy(t, "/dev/");
t += 5;
while (n < MAX_DEV_NAME && *s != '\0'
&& !isspace((unsigned char) *s)) {
*t++ = *s++;
n++;
}
*t = '\0';
/* Read the size of the partition. */
t = line + 37;
while (isspace((unsigned char) *t))
t++;
partitions[num_partition].blocks = atoi(t);
if (strstr(line, "Linux native")) {
partitions[num_partition].type = Linux;
num_partition++;
num_linux++;
} else if (strstr(line, "Linux swap")) {
partitions[num_partition].type = Swap;
num_partition++;
num_swap++;
} else if (strstr(line, "DOS")) {
partitions[num_partition].type = MsDos;
num_partition++;
num_msdos++;
}
}
}
fclose(f);
#ifndef DEBUG_THIS
unlink("/tmp/fdisk.output");
#endif
}
static int
select_partition(const char *title, const char *prompt, int y, int x)
{
int i, num, ret;
char info[MAX_PARTS][40];
char *items[MAX_PARTS * 2];
int num_pa[MAX_PARTS];
num = 0;
for (i = 0; i < num_partition; i++) {
if (partitions[i].type == Linux) {
items[num * 2] = partitions[i].name;
sprintf(info[num], "Linux partition with %d blocks",
partitions[i].blocks);
items[num * 2 + 1] = info[num];
num_pa[num] = i;
num++;
}
}
ret = dialog_menu(title, prompt, y + num, x, num, num, items);
dialog_clear();
if (ret >= 0) /* item selected */
ret = num_pa[ret];
return ret;
}
static int
select_install_partition(void)
{
return select_partition("Select Install Partition",
"\\nWhere do you want to install Linux?\\n", 9, 60);
}
static int
select_source_partition(void)
{
return select_partition("Select Source Partition",
"\\nOn which partition is the source?\\n", 9, 60);
}
const char *null = ">/dev/null 2>/dev/null";
const char *install_partition = NULL;
static void
extract_packages(const char *source_path)
{
#ifndef DEBUG_THIS
FILE *f;
#endif
if (my_system("mkdir -p /install/var/installed/packages %s", null))
return;
if (my_system("cd /install; for i in /source%s/*.tgz; do "
"tar xzplvvkf $i >> var/installed/packages/base "
"2>>var/installed/packages/ERROR; done", source_path))
return;
#ifndef DEBUG_THIS
if ((f = fopen("/install/etc/fstab", "w")) == NULL) {
/* i = */ dialog_msgbox("Error", "Cannot write /etc/fstab",
12, 40, 1);
return;
}
fprintf(f, "%s / ext2 defaults 1 1\n", install_partition);
fprintf(f, "none /proc proc defaults 0 2\n");
/* XXX write swap-partitions */
fclose(f);
#endif
}
static void
install_premounted(void)
{
extract_packages("");
}
static void
install_harddisk(void)
{
const char *name;
int part, ret;
if ((part = select_source_partition()) <= -1)
return;
name = partitions[part].name;
if (my_system("mount -t ext2 %s /source %s", name, null))
return;
ret = dialog_inputbox("Path in partition",
"Please enter the directory in which the "
"source files are.", 13, 50, "", FALSE);
dialog_clear();
if (ret != 0)
return;
/* XXX strdup */
extract_packages(strdup(dialog_input_result));
if (my_system("umount /source %s", null))
return;
}
static void
install_nfs(void)
{
if (my_system("ifconfig eth0 134.96.81.36 netmask 255.255.255.224 "
"broadcast 134.96.81.63 %s", null))
return;
if (my_system("route add -net 134.96.81.32 %s", null))
return;
if (my_system("mount -t nfs 134.96.81.38:"
"/local/ftp/pub/linux/ELF.binary/tar /source %s", null))
return;
extract_packages("/base");
if (my_system("umount /source %s", null))
return;
if (my_system("ifconfig eth0 down %s", null))
return;
}
static void
main_install(void)
{
int part, ret;
const char *name;
char *items1[] =
{
"1", "Harddisk Install",
"2", "Network Install(NFS)",
"3", "Premounted on /source"
};
if (num_linux == 0) {
/* XXX */
return;
}
if ((part = select_install_partition()) <= -1)
return;
install_partition = name = partitions[part].name;
if (my_system("mke2fs %s %s", name, null))
return;
if (my_system("mount -t ext2 %s /install %s", name, null))
return;
ret = dialog_menu("Choose install medium",
"\\nPlease say from where you want to install.\\n",
12, 62, 3, 3, items1);
dialog_clear();
switch (ret) {
case 0:
install_harddisk();
break;
case 1:
install_nfs();
break;
case 2:
install_premounted();
break;
case -2: /* cancel */
case -1:
break; /* esc */
}
if (my_system("umount /install %s", null))
return;
}
int
main(int argc, char **argv)
{
int stop = 0;
int ret;
char *items1[] =
{
"1", "Display a help text",
"2", "Start an installation",
"3", "Exit to the shell"
};
progname = argv[0];
read_partitions();
if (num_linux == 0) {
printf("\n\nPlease start \"fdisk\" or \"cfdisk\" and create a"
"\nnative Linux-partition to install Linux on.\n\n");
exit(1);
}
init_dialog();
while (!stop) {
ret = dialog_menu("Linux Install Utility",
"\\nCopyright (C) 1995 Florian La Roche\\n"
"\\nPre-Alpha version, be careful, read the doc!!!"
"\\nemail: florian@jurix.jura.uni-sb.de, "
"flla@stud.uni-sb.de\\n",
15, 64, 3, 3, items1);
dialog_clear();
switch (ret) {
case 0:
ret = dialog_textbox("Help Text",
"setup.help", 20, 70);
dialog_clear();
break;
case 1:
main_install();
break;
case 2:
stop = 1;
break;
case -2: /* cancel */
case -1:
stop = 1; /* esc */
}
}
end_dialog();
printf("\nExecute \"reboot\" to restart your computer...\n");
exit(0);
}

View File

@ -1,49 +0,0 @@
At the moment, only installation from a harddisk
is supported. All commands are shown to you on
the screen before executing. This is just to make
sure that nothing bad is done to your harddisk :-)
You can also select to install from a premounted dir.
Then the "tar/base" directory must be mounted on
"/install", so that all tar-packages from the basic
stuff are in "/install/*.tgz". (So you could be able
to install via NFS...)
Good luck...,
anyone wants to help programming this tool?,
Florian La Roche
Contents:
=========
- overview about what "setup" does.
- creating a Linux-partition before starting "setup"
- about lilo
- how to use "setup", what keys are supported
What does "setup" do on my computer?
====================================
Setup will ask you for a partition on your harddisk,
where you would like to have Linux installed.
You can then choose to install this distribution from
your local harddisk or via network (NFS).
setup will install a very basic system.
At the end, you can install lilo, the Linux Loader.
Rebooting your computer with this little linux system
and then runing the setup-program on it, will give
the possibility to install more packages.
Creating a Linux-partition:
===========================
To install this Linux distribution, you need to
create an extra partition on your harddisk for
Linux.
What is lilo and how should I install it?
=========================================
Read the lilo-documentation for this...
Florian La Roche

View File

@ -1,13 +1,16 @@
#! /bin/sh
# $Id: killall,v 1.2 2004/09/17 19:56:18 tom Exp $
# $Id: killall,v 1.3 2012/06/29 09:39:19 tom Exp $
# Linux has a program that does this correctly.
. ./setup-vars
for prog in $*
do
pid=`ps -a |fgrep $prog |fgrep -v fgrep|sed -e 's/^[ ]*//' -e 's/ .*//' `
if test -n "$pid" ; then
echo killing pid=$pid, $prog
kill -1 $pid || \
kill -15 $pid || \
kill -9 $pid
kill -$SIG_HUP $pid || \
kill -$SIG_TERM $pid || \
kill -$SIG_KILL $pid
fi
done

View File

@ -0,0 +1,43 @@
#!/bin/sh
# $Id: menubox12,v 1.3 2012/12/23 22:28:26 tom Exp $
. ./setup-vars
. ./setup-edit
case "x$DIALOGOPTS" in
*--no-items*|*--noitem*)
CUT="cut -d: -f1,3"
;;
*)
CUT="cat"
;;
esac
$CUT >$input <<-EOF
Linux:The Great Unix Clone for 386/486
NetBSD:Another free Unix Clone for 386/486
OS/2:IBM OS/2
WIN NT:Microsoft Windows NT
PCDOS:IBM PC DOS
MSDOS:Microsoft DOS
EOF
cat $input | sed -e 's/^/"/' -e 's/:/" "/g' -e 's/$/"/' >$output
cat $output >$input
$DIALOG --clear --title "MENU BOX" "$@" \
--menu "Hi, this is a menu box. You can use this to \n\
present a list of choices for the user to \n\
choose. If there are more items than can fit \n\
on the screen, the menu will be scrolled. \n\
You can use the UP/DOWN arrow keys, the first \n\
letter of the choice as a hot key, or the \n\
number keys 1-9 to choose an option.\n\
Try it now!\n\n\
Choose the OS you like:" 20 51 4 \
--file $input 2> $output
retval=$?
tempfile=$output
. ./report-tempfile

View File

@ -1,6 +1,9 @@
#!/bin/sh
# $Id: prgbox,v 1.1 2011/03/02 00:10:54 tom Exp $
# $Id: prgbox,v 1.2 2012/07/02 09:46:24 tom Exp $
. ./setup-vars
$DIALOG --title "PRGBOX" "$@" --prgbox "./shortlist" 20 70
retval=$?
. ./report-button

View File

@ -1,6 +1,9 @@
#!/bin/sh
# $Id: prgbox2,v 1.1 2011/03/02 01:25:54 tom Exp $
# $Id: prgbox2,v 1.2 2012/07/02 09:46:24 tom Exp $
. ./setup-vars
$DIALOG --title "PRGBOX" "$@" --prgbox "./shortlist 3" 20 70
retval=$?
. ./report-button

11
contrib/dialog/samples/rangebox Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
# $Id: rangebox,v 1.3 2012/12/05 10:07:54 tom Exp $
. ./setup-vars
exec 3>&1
RESULT=`$DIALOG --title "RANGE BOX" --rangebox "Please set the volume..." 0 60 0 123 5 2>&1 1>&3`
retval=$?
exec 3>&-
. ./report-string

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