Closed nyxnor closed 2 years ago
I had the impression that the command lines for whiptail
and dialog
are (almost?) the same. For example:
dialog --clear --backtitle "${BACKTITLE}" --title "${TITLE}" --"${DIALOG_TYPE}" "${MENU}" "$((i+8))" 80 ${i} ${SERVICE_LIST} 2>&1 >/dev/tty)"
whiptail --clear --backtitle "${BACKTITLE}" --title "${TITLE}" --"${DIALOG_TYPE}" --separate-output "${MENU}" "$((i+8))" 80 $i ${SERVICE_LIST} 3>&1 1>&2 2>&3"
Both programs know the --separate-output
option. However, I had the impression that with dialog
, it worked without; with whiptail
it is mandatory to use it, but I'm not sure about it. Also a difference is the 2>&1 >/dev/tty
vs. the 3>&1 1>&2 2>&3
- I don't know if that matters.
--separate-output
- I can include that., From dialog manual
--separate-output For certain widgets (buildlist, checklist, treeview), output result one line at a time, with no quoting. This facilitates parsing by another program.
Redirection - Yeah, I think it is the same, but it is good to unify them to a single type.
Redirection was fixed on https://github.com/nyxnor/onionservice/commit/8b040f53866cb4013eb5492cd3b79e622f32eb72
When you test whiptail (no rush), let me know if it makes a difference using --separate-output
or not.
Ok ... here are the results: Result with --separate-output:
1
2
x
Result without --separate-output:
"1" "2" "x"
I need --separate-output with the "for in do" loop. Of course, you can manipulate the result without --separate-output in so you can use it with the "for in do" loop.
This means that if I put --separate-output
on dialog for the checklist
, it becomes compatible with whiptail?
dialog
with --separate-output
gives the same result as whiptail.
dialog
without --separate-output
gives as result: 1 2 x
Ok, start supporting different dialog boxes -> whiptail and dialog. It is working with dialog but not with whiptail, I don't know why.
CHOICE_MAIN=--ok-label: unknown option
Dialog: --ok-label
Whiptail: --ok-button
Why, just why...
Edit:
case "${DIALOG_BOX}" in
dialog)
OK_FLAG="--ok-label"
NO_CANCEL_FLAG="--no-cancel"
;;
whiptail)
OK_FLAG="--ok-button"
NO_CANCEL_FLAG="--nocancel"
;;
esac
Now I see what you mean by whiptail displaying the height option strangely.
Argh... the same problem exists with --yes-button --no-button and --cancel-button
Now need to convert inside the files
case "${DIALOG_BOX}" in
dialog)
YES_FLAG="--yes-label"
NO_FLAG="--no-label"
OK_FLAG="--ok-label"
CANCEL_FLAG="--cancel-label"
NO_CANCEL_FLAG="--no-cancel"
;;
whiptail)
YES_FLAG="--yes-button"
NO_FLAG="--no-button"
OK_FLAG="--ok-button"
CANCEL_FLAG="--cancel-button"
NO_CANCEL_FLAG="--nocancel"
;;
esac
Edit: all things converted, but this is so wrong:
Another problem is that whiptail put an extra line on the text, so need to find some way to bypass that. Use spacebar to select
, see the difference.
Little wip to start accepting whiptail here https://github.com/nyxnor/onionservice/commit/8801b53e1967714e9c2f10394646ad9901c3946e Still, there is more to do to adjust every dialog box.
Best solution I found for the height it adding one when it is whiptail, but need to edit every dialog height basically to "$((current_height+WHIPTAIL_HEIGHT))"
Progress so far of testing with whiptail and dialog on:
db1f257a8579b70110ab2843842ce3363527e9f4 dd63d518f1aef0349ab4cb10d062e8509c62481c 5462753e0daceb0b9e90f7d86ebe0c0fd1b095c9
Ok. As I reviewed all the menu options with caution, I have found and fixed all the bugs that I encountered with. I tested with whiptail and dialog all options and they seem to fit.
This will be kept open for some days in the event a big bug is found.
Oh, and maybe it is good if you could test if it fits on the tiny lcd screen because I edited some heights to be "$((i+8+WHIPTAIL_HEIGHT))
. If I dont add the WHIPTAIL_HEIGHT, it is gonna be short by one line when using whiptail.
no bugs so far, closing this.
My doubt is / How can I:
@radio24 Have you encountered any problems/incompatibilities translating from
whiptail
todialog
? If no, I can make the menu also become a whiptail, else, might have to study to make them compatible in the code.