bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Display backslash-n in dialog?


From: Moray Henderson
Subject: RE: Display backslash-n in dialog?
Date: Tue, 26 Jul 2011 10:31:04 +0100

Michael D. Setzer II [mailto:address@hidden
> >     Is there a nice way to display the literal sequence `\n´ in
> dialog? I'm writing a
> >     confirmation box for deleting a set of directories from a Windows
> perspective:
> >
> >      dialog --yesno "This will delete:\n - I:\\$CHOICE\n -
> P:\\$CHOICE\nContinue?" 8 40
> >
> You didn't mention if the path would only have one subdirectory or
> might have multiple \n possibilities.
> 
> I came up with this that seems to work in some ways. The choice5
> combines all the options in one.
> Choice2 just changes the /'s to \'s to avoid the problem, but might
> confuse windows users?
> Choice3 would uses the color option to get ride to the \n issue.
> 
> 
> CHOICE="new\new"
> CHOICE2=`echo /$CHOICE |tr '\' '/'`
> CHOICE3=`echo $CHOICE2 | sed -e 's:/n://Z0n:g'`
> CHOICE4=`echo $CHOICE3 |tr '/' '\'`
> CHOICE5=`echo /$CHOICE |tr '\' '/' | sed -e 's:/n://Z0n:g' |tr '/' '\'
> `
> dialog --yesno "This will delete:\n - I:$CHOICE2\n -
> P:$CHOICE2\nContinue?" 8 40
> dialog --yesno $'This will delete:\n - I:\\ \b'"$CHOICE"$'\n - P:\\
> \b'"$CHOICE"$'\nContinue?' 8 40
> dialog --colors --yesno "This will delete:\n - I:\\\Z0$CHOICE\Z0\n -
> P:\\\Z0$CHOICE\Z0\nContinue?" 8 40
> dialog --colors --yesno "This will delete:\n - I:$CHOICE4\n -
> P:$CHOICE4\nContinue?" 8 40
> dialog --colors --yesno "This will delete:\n - I:$CHOICE5\n -
> P:$CHOICE5\nContinue?" 8 40

Excellent - I had completely missed the --colors option.  

Incidentally, without the --colors option a \Z sequence in dialog
1.0-20051107 gives some strange results:

  dialog --msgbox "Hello\\Z world" 5 20

produces

  Hello\Z wo

while with a lowercase z it gives correctly "Hello\z world".  However, your
workaround works for that issue too.

I'll check the release notes and see what other useful features the CentOS
versions are missing.  Thank you both for your advice.



Moray.
“To err is human; to purr, feline.”







reply via email to

[Prev in Thread] Current Thread [Next in Thread]