cdialog for win - news and FAQ

Jul 2015: clear screen on MSYS and CMD terminals

A user from Hungary (thank you Zoltan) reported this problem:

... when using --infobox it displays the box all right but then it clears the screen after exit and the displayed box is disappearing when the script reaches the next line.

After some brainstorming he found this:

... the dialog output is drawn at the beginning of the scrollback buffer and after exit it scrolls to the end so the dialog printed is not visible if it scrolls out the window.
Thus the workaround is to use "mode con lines=<window rows>" to disable the scrollback buffer. Then the output stays visible after exiting dialog.exe.
I think it explains why it may have worked in the msys shell if you had an empty scrollback buffer when testing it or had different settings in that window somehow.
Based on this finding it may be possible to improve the code to find the visible window position and use that to print the dialog instead of at the top ...

I confirm his observations: the problem doesn't show if you set buffer rows the same as screen rows in your terminal.

Note to self: a patch should be done in the future.

Feb 2015: consider alternatives

There's always someone making progress out there. A French programmer wrote:

> Date: Mon, 9 Feb 2015 21:04:48 +0100 > From: [email protected]
> To: [email protected]
> Subject: dialog --fselect

> Hi,

> first, congratulation for the good work.
> I am offering dialog as an option here:

http://tinyfiledialogs.sourceforge.net

> your portage of dialog is working, but when you use the option --fselect
> it doesn't show or let you browse the files and directories.

> I've tested this on windows 7.1

> thanks

I found that --fselect actually works, but pathnames must be Unix-style and the key controls are rather picky:

> Usage example (from MSYS or from cmd.exe): 
>
> 1) c:/.../home/andrea/dialog> dialog --fselect c:/ 12 50 2>prova.txt
>
> 2) Note I used "c:/" instead of the usual DOS-styled "c:".
>
> 3) Then I navigate through the filesystem using only arrows, TAB, space
> (= select dir or file at cursor) and "/" (= dive into a directory at
> cursor). I navigate until the full pathname is composed in the lower
> panel, then I select OK and click enter.
>
> 4) c:/.../home/andrea/dialog> cat prova.txt
> screen shows c:/eula.1028.txt (the file I selected)
>
> 5) Further troubleshooting: check that width and height aren't too big
> respect to the terminal window. For example for a 25-lines terminal I
> could use at most height=15, bigger values made dialog.exe crash.

tinyfiledialogs is a more complete solution that may use dialog.exe as a last resort, when no better widget toolkits are available on the system.

Dec 2020: some usage examples

... crafted one [example] for the single-choice menu: this one works correctly for me in Windows 10, if I put these contents in a .bat file:

> @echo off
> cls

> dialog --menu "Select chapter to read" 15 50 5 ^
>   "intro"   "Introduction to the Program" ^
>   "cmdline" "Command Line Arguments" ^
>   "web"     "More Web Resources" ^
>   "exit"    "Exit this Menu" ^
>   2>ans_stderr.txt

> cls
> set ANSWERLEV=%ERRORLEVEL%
> set /p ANSWERERR=<ans_stderr.txt
> del ans_stderr.txt

> if "%ANSWERLEV%" == "1"       goto exit_app
> if "%ANSWERLEV%" == "255"     goto exit_app

> if "%ANSWERERR%" == "intro"   goto read_intro
> if "%ANSWERERR%" == "cmdline" goto read_cmdline
> if "%ANSWERERR%" == "web"     goto read_web
> if "%ANSWERERR%" == "exit"    goto exit_app
> EXIT /B 0

> :read_intro
> echo read intro stuff here
> goto exit_app

> :read_cmdline
> echo read cmdline stuff here
> goto exit_app

> :read_web
> echo read web stuff here
> goto exit_app

> :exit_app

This one is for multiple choices:

> @echo off
> cls

> dialog --checklist "Select components" 15 50 5 ^
>   "base"     "Base Packages"        on  ^
>   "devel"    "Development Packages" off ^
>   "doc"      "Documentation"        off ^
>   "examples" "Examples"             off ^
>   2>ans_stderr.txt

> cls
> set ANSWERLEV=%ERRORLEVEL%
> set /p ANSWERERR=<ans_stderr.txt
> del ans_stderr.txt

> if "%ANSWERLEV%" == "1"       goto exit_app
> if "%ANSWERLEV%" == "255"     goto exit_app

> echo These packages will be installed: %ANSWERERR%

> :exit_app

Back to cdialog for win page