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: Michael D. Setzer II
Subject: Re: Display backslash-n in dialog?
Date: Tue, 26 Jul 2011 21:51:06 +1000

>From the man dialog Version: 1.1-20100428 from Fedora 14.

man dialog section on color

--colors
  Interpret embedded "\Z" sequences in the dialog text by the fol-
   lowing character, which tells dialog  to  set  colors  or  video
   attributes: 0 through 7 are the ANSI used in curses: black, red,
   green, yellow, blue, magenta, cyan and white respectively.  Bold
    is  set  by  'b', reset by 'B'.  Reverse is set by 'r', reset by
    'R'.  Underline is set by 'u', reset by 'U'.  The  settings  are
    cumulative,  e.g.,  "\Zb\Z1" makes the following text bold (per-
    haps bright) red.  Restore normal settings with "\Zn".

Without the --colors don't know how \Z would be handled, or what
happens with what appears after the \Z

On 26 Jul 2011 at 10:31, Moray Henderson wrote:

From:                   Moray Henderson <address@hidden
software.org>
To:                     <address@hidden>
Subject:                RE: Display backslash-n in dialog?
Date sent:              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."
>
>
>
>
>
> _______________________________________________
> Bug-ncurses mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/bug-ncurses


+----------------------------------------------------------+
  Michael D. Setzer II -  Computer Science Instructor
  Guam Community College  Computer Center
  mailto:address@hidden
  mailto:address@hidden
  http://www.guam.net/home/mikes
  Guam - Where America's Day Begins
  G4L Disk Imaging Project maintainer
  http://sourceforge.net/projects/g4l/
+----------------------------------------------------------+

http://setiathome.berkeley.edu (Original)
Number of Seti Units Returned:  19,471
Processing time:  32 years, 290 days, 12 hours, 58 minutes
(Total Hours: 287,489)

address@hidden CREDITS
SETI        11044762.090437   |   EINSTEIN     6244118.820851
ROSETTA      3419559.179626   |   ABC          7086091.917007




reply via email to

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