summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/share/dialog.subr
Commit message (Collapse)AuthorAgeFilesLines
* Introduce centralized [X]dialog(1) exit codes to `dialog.subr' and make-usedteske2013-10-091-0/+12
| | | | | | | | | | throughout the bsdconfig(8) code. While we're here, add an explicit argument to lvalue-seeking invocations of "return" that previously had no argument. Also, consolidate a single instance of double-newline and remove some comments that are no longer required (given increased readability with new exit codes). Approved by: re (glebius)
* Adjust comments to fit within 80-columns.dteske2013-07-091-4/+4
|
* Fix conditional (der should match the comment above it).dteske2013-07-091-1/+1
| | | | MFC after: 1 day
* Do two things: First, don't obscure the backtitle. Second, read ~/.dialogrcdteske2013-07-091-1/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | if it exists to determine if use_shadow is true (ON) or false (OFF). The purpose of determining the value of use_shadow is to know how many lines to subtract from the maximum height value in assuring that the backtitle is not obscured. The detriment of obscuring the backtitle is that it provides information that is not easily obtained elsewhere. That is the command-line shortcut used to access the current menu. As you navigate from one dialog to the next, invariably transparently corssing module boundaries, the backtitle represents the command-line argument used to get there. Obscuring this information with a widget that is too-tall and/or too-wide would see that data go unnoticed (leaving few other ways to get that information in the same helpful context). So despite the fact that this change reduces the standard maximum height for all widgets, there is a trap-door to prevent this calculation. If you want to utilize the full screen height on the terminal (remember, this adjustment is not made for Xdialog(1)) you can set $NO_BACKTITLE to 1 (or any non-NULL value for that matter) and this calculation will be skipped. You will be able to draw a widget that partially obscures the backtitle if-necessary. MFC after: 1 day
* Fix typos in the BSD License.dteske2013-07-071-2/+2
|
* Be consistent with other usr.sbin programs w/respect to the copyrightdteske2013-07-071-1/+1
| | | | wording ("All rights reserved."); I had the casing wrong on many instances.
* More whitespace.dteske2013-06-241-2/+2
|
* Typo and grammar fixes to comments.dteske2013-06-211-1/+1
|
* Change the f_dialog_{yesno,noyes}() function-arguments in `dialog.subr' todteske2013-06-181-6/+6
| | | | | | | | | | | accomodate an $hline value for overriding the default. This change does not effect any current modules as it turns out that not one single usage of either f_dialog_yesno() or f_dialog_noyes() relied on accepting more than a first argument (read: all occurrences quoted the first parameter; so $* was never depended upon). This will allow some custom invocations of --yesno and --noyes to roll over to these functions (for example, in `timezone/timezone').
* Change the f_dialog_msgbox() arguments in `dialog.subr' to accomodate andteske2013-06-181-3/+4
| | | | | | | | | | $hline argument for setting the --hline parameter value. This change does not effect any current modules as it turns out that not one single usage of f_dialog_msgbox() relied on accepting more than a first argument (read: all occurrences quoted the first parameter; so $* was never depended upon). This will allow some custom invocations of --msgbox to roll over to this function (for example, in `mouse/disable').
* Similar to r251236, r251242, and r251244. Introduce new function-pair todteske2013-06-041-0/+38
| | | | | | | | | | | | | | | | | dialog(1) API in dialog.subr responsible for retrieving menu-choice data (for the --menu widget). Add f_dialog_menuitem_store()/f_dialog_menuitem_fetch() for storing and retrieving the menuitem (not the tag) from a --menu widget result. The dialog --menu widget returns the `tag' from the tag/item pair of choices for a menu list. Because the menu list is often local to the function that is displaying it, the ability to dereference this into the item is not possible unless you use a global. This changes things so the function (upon successful return of dialog) dereferences the tag into the item and stores it for later retrieval using these functions. NOTE: Tags are dereferenced into items using f_dialog_menutag2item().
* Improve debugging for f_dialog_*_constrain() to print constrained ratherdteske2013-06-041-2/+15
| | | | than unconstrained values.
* Make proper use of locals in f_dialog_init().dteske2013-06-021-5/+4
|
* Improvements to whitespace and comments.dteske2013-06-021-1/+1
|
* Fix option processing from the library layer to address unexpecteddteske2013-06-021-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | behavior(s); e.g., `-Xd' versus `-dX' did not produce the same results. The libraries common.subr and dialog.subr automatically process the arguments passed to the program and enable/disable functionality without the need to process the arguments within your program. For example, if "$@" contains `-d', common.subr will see this and enable debugging regardless of whether you process "$@" yourself or not (this automatic processing can easily be disabled for custom scripts that don't want it; see the afore- mentioned scripts for additional details). NOTE: common.subr stores a copy of "$@" in $ARGV for convenient (and repeated) processing by libraries such as dialog.subr which provide such transparent functionality for the consuming script(s). However, the libraries don't know if a program wants to accept `extra' options. Flags are not really a problem, because the library can be programmed to silently ignore unknown flags. The trouble comes into play when the program wants to define an option that takes an argument. For example: bsdconfig -D logfile -X In the above example, the library uses getopts to process $ARGV and if it doesn't know that `-D' takes an argument, the option processing will prematurely terminate on `logfile' (this is standard/correct behavior for getopts but is undesired in our situation where we have partially off-loaded main argument processing). The problem is solved by allowing the program to define an extra set of options to be included in each library's handling of $ARGV. Only options that require arguments are truly necessary to be pre-specified in this new manner.
* Improve the dialog(1) API in dialog.subr by adding f_dialog_default_store()dteske2013-06-021-0/+39
| | | | | | | | | | and f_dialog_default_fetch(). Operating similar to functions introduced by SVN r251236 and r251242, these functions operate as a pair for helping track the default-item data (for the --menu, --checklist, and --radiolist widgets). This replaces the direct usage of a global to store the data with an abstract method for readability and to centralize the code.
* Similar to r251236, improve the portion of dialog(1) API in dialog.subrdteske2013-06-021-35/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | responsible for retrieving stored input (for the --inputbox and --password widgets). When we (Ron McDowell and I) developed the first version of bsdconfig, it used temporary files to store responses from dialog(1). That hasn't been true for a very long time, so the need to always execute some clean-up function is long-deprecated. The function that used to perform these clean- up routines for these widgets was f_dialog_inputstr(). We really don't need f_dialog_inputstr() for its originally designed purpose as all dialog invocations no longer require temporary files. Just as in r251236, redesign f_dialog_inputstr() in the following four ways: 1. Rename f_dialog_inputstr() to f_dialog_inputstr_fetch() 2. Introduce the new first-argument of $var_to_set to reduce forking 3. Create a corresponding f_dialog_inputstr_store() to abstract storage 4. Offload the sanitization to a new function, f_dialog_line_sanitize() It should be noted that f_dialog_line_sanitize() -- unlike its cousin from SVN r251236, f_dialog_data_sanitize() -- trims leading/trailing whitespace from the user's input. This helps prevent errors and common mistakes caused by the fact that the new cdialog implementation allows the right-arrow cursor key to go beyond the last byte of realtime input (adding whitespace at the end of the typed value). While we're centralizing the sanitization, let's rewrite f_dialog_input() while we're here to likewise reduce forking. The f_dialog_input() function now expects the first argument of $var_to_set instead of producing results on standard-out. These changes greatly improve readability and also improve performance.
* Improve portion of the dialog(1) API in dialog.subr responsible fordteske2013-06-011-18/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | retrieving stored data (for the --menu, --calendar, --timebox, --checklist, and --radiolist widgets). When we (Ron McDowell and I) developed the first version of bsdconfig, it used temporary files to store responses from dialog(1). That hasn't been true for some very long time, so the need to always store the return status of dialog(1) and then call some function to clean-up is long-deprecated. The function that used to do the clean-up was f_dialog_menutag(). We really don't need f_dialog_menutag() for its originally designed purpose, as all dialog invocations (even when in a sub-shell) do not use temporary files anymore. However, we do need to keep f_dialog_menutag() around because it still fills the need of being able to abstract the procedure for fetching stored data provided by functions that display the aforementioned widgets. In re-designing f_dialog_menutag(), four important changes are made: 1. Rename f_dialog_menutag() to f_dialog_menutag_fetch() 2. Introduce the new first-argument of $var_to_set to reduce number of forks 3. Create a corresponding f_dialog_menutag_store() to abstract the storage 4. Offload the sanitization to a new function, f_dialog_data_sanitize() NOTE: That last one is important. Not all functions need to store their data for later fetching, meanwhile every invocation of dialog should be sanitized (as we learned early-on in the i18n-effort -- underlying libraries will spit warnings to stderr for bad values of $LANG and since dialog outputs its responses to stderr, we need to sanitize every response of these warnings). These changes greatly improve readbaility and also improve performance by reducing unnecessary forking.
* Improve portion of the dialog(1) API in dialog.subr responsible fordteske2013-05-311-761/+1041
| | | | | | | | | | | | | | | | | | | | calculating widget sizes. Instead of forking a sub-shell to calculate the optimum size for a widget, use a byRef style call-out to set variables in the parent namespace. For example, instead of: size=$( f_dialog_buttonbox_size title btitle msg ) $DIALOG --title title --backtitle btitle --msgbox msg $size The new API replaces the above with the following: f_dialog_buttonbox_size height width title btitle msg $DIALOG --title title --backtitle btitle --msgbox msg $height $width This reduces the number of forks, improves performance, and makes the code more readable by revealing the argument-order for widget sizing. It also makes performing minor adjustments to the calculated values easier as you no longer have to split-out the response (which required knowledge of ordering so was counter-intuitive).
* Centralize standard getopts arguments, both for convenience and to correctdteske2013-05-141-4/+16
| | | | | | | | | a bug in which certain combinations of arguments produced unexpected results such as `-dX' (now properly produces debugging and X11), `-XS' (now properly produces X11 in secure mode), `-df-' (enables debugging when reading a script from standard-input, etc. Multi-word variations such as `-d -X', `-X -S', `-d -f-', `-d -f -', etc. also work as expected. Also tested were variations in argument order, which are now working as expected.
* New helper functions for common widgets.dteske2013-04-221-0/+136
|
* Proper fix for copy/paste error (first attempt r249756).dteske2013-04-221-2/+2
|
* Fix a copy/paste error.dteske2013-04-221-2/+2
|
* Update copyright following last commit.dteske2013-01-071-1/+1
|
* Add nonInteractive support to f_dialog_yesno/noyes().dteske2013-01-071-0/+7
|
* Comments.dteske2012-12-291-1/+4
|
* Add missing enforcement of height restriction after minor adjustment.dteske2012-12-291-0/+1
|
* Add support for running without a controlling terminal (for example, whendteske2012-12-291-8/+21
| | | | running as an rvalue to a pipe).
* Add more debugging to help with diagnosis of program-flow when needed.dteske2012-12-251-0/+7
|
* Change axiom for initialization. Including script can disable (default)dteske2012-12-211-1/+4
| | | | automatic initialization by setting appropriate variable to particular value.
* Improve the debugging abilities and clean up debug messages. In most cases,dteske2012-12-211-1/+1
| | | | | all one has to do is set the environment variable DEBUGGING to get the debug messages to appear on the console.
* Add much-needed dialog(1) --inputbox function for simplifying the process ofdteske2012-12-211-2/+48
| | | | requesting input from the user.
* Allow setting of NULL titles with f_dialog_[back]title().dteske2012-11-271-2/+2
| | | | Approved by: adrian (co-mentor) (implicit)
* Change self-initialization to occur when loaded versus the previous behaviordteske2012-11-271-34/+5
| | | | | | | | | which was to self-initialize during the first function-call. This didn't work so well because the first call was may or may-not be within a sub-shell (which prevented proper setup of the pass-thru file descriptor, resulting in dialogs that would not display). Approved by: adrian (co-mentor) (implicit)
* Whitespace.dteske2012-11-241-1/+1
| | | | Approved by: adrian (co-mentor) (implicit)
* Tighten-up displays that use a NULL prompt (e.g., networking and usermgmt).dteske2012-10-261-1/+1
| | | | Approved by: adrian (co-mentor) (implicit)
* Fix copy/paste error.dteske2012-10-261-1/+1
| | | | Approved by: adrian (co-mentor) (implicit)
* Switch from using a msgbox to display help files to a textbox instead. Thedteske2012-10-261-0/+42
| | | | | | | | | | | problem with using a msgbox was one of truncation in the case of Xdialog(1) and lack of screen real-estate (since the msgbox is not scrollable in X11 while a textbox is). The textbox renders the text much better and is more appropriate for this type of data display. Approved by: adrian (co-mentor) (implicit)
* Reverse SVN r240770 -- jilles@ made a suggestion that allowed us to redesigndteske2012-09-211-3/+3
| | | | | | | our embedded rescue environment to support /dev/null making r240770 obsolete. Reviewed by: jilles, adrian (co-mentor) Approved by: jilles, adrian (co-mentor)
* Replace redirections to /dev/null with "close file-descriptor" syntax (>&-).dteske2012-09-211-3/+3
| | | | | Reviewed by: adrian (co-mentor) Approved by: adrian (co-mentor)
* Change all invocations of dialog(1) to no-longer require temporary files.dteske2012-09-201-36/+16
| | | | | | | This allows bsdconfig to -- like bsdinstall -- operate from read-only media. Reviewed by: adrian (co-mentor) Approved by: adrian (co-mentor)
* Move major includes into /usr/share/bsdconfig for easy external access.dteske2012-09-181-0/+1443
Reviewed by: adrian (co-mentor) Approved by: adrian (co-mentor)
OpenPOWER on IntegriCloud