LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-09-2012, 07:11 PM   #1
ncjeculver
LQ Newbie
 
Registered: Sep 2012
Posts: 7

Rep: Reputation: Disabled
Need "dialog --column-separator" example


I'm trying to create a multi-column menu using Dialog in a Bash script. The man page offers this syntax:

Code:
--column-separator <string>: split data for ... menus on  the occurrences of the given string
but leaves out the particulars or examples, nor have I been able to turn up any usage examples on the net. For example, is "string" wrapped in quotes? What characters are legal? And where exactly do I insert the string in my menu definitions?

Here's a menu that works:

Code:
#!/bin/bash

dialog --title " Welcome to My Menu! " \
       --menu "" 19 40 12              \
               "1" "Option One"        \
               "2" "Option Two"        \
               "3" "Option Three"      \
               "4" "Option Four"       \
2>temp
Cancelled=$?
Choice=`cat temp` ; rm temp
if [ $Cancelled -eq 0 ] 
  then echo "You selected: $Choice"
  else echo "You cancelled!"
fi
But when I try to add a column separator, for example this way:

Code:
#!/bin/bash

dialog --title " Welcome to My Menu! " \
       --column-separator "@"          \
       --menu "" 19 40 12              \
               "1" "Option One"        \
               "2" "Option Two"        \
"@"            "3" "Option Three"      \
               "4" "Option Four"       \
2>temp
Cancelled=$?
Choice=`cat temp` ; rm temp
if [ $Cancelled -eq 0 ] 
  then echo "You selected: $Choice"
  else echo "You cancelled!"
fi
It fails. The above, for example, just spits out "You cancelled!" and exits. Other attempts generally elicit syntax errors inside the --menu definition.

Can someone provide me with an example of the proper syntax for --column-separator? Thanks.

--Nathanael
 
Old 09-10-2012, 07:40 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Just by experimentation:

Code:
dialog --title " Menu! " --column-separator "|" --menu "" 19 40 12 "1" "A long option|One" "2" "Option|Two" "3" "Option|Three" "4" "Option|Four"
 
Old 09-10-2012, 09:53 AM   #3
ncjeculver
LQ Newbie
 
Registered: Sep 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thanks. I see my error now -- it doesn't do what I thought. I was looking for column breakss *between* items, not *within* items, something like this:

Code:
┌────────────── Menu! ─────────────────┐
│ ┌──────────────────────────────────┐ │
│ │1 Option One      5 Option Five   │ │
│ │2 Option Two      6 Option Six    │ │
│ │3 Option Three    7 Option Seven  │ │
│ │4 Option Four     8 Option Eight  │ │
│ └──────────────────────────────────┘ │
├──────────────────────────────────────┤
│       <  OK  >    <Cancel>           │
└──────────────────────────────────────┘
so I was trying to insert columns breaks betwen list items, not inside them.

I've actually got a menu wtih 48 items, and I was hoping to split it into four columns of twelve items each, rather than a single narrow column down the middle of the screen that needs to be scrolled.

I don't suppose there's any way to do that wth Dialog, then. Anybody?
 
Old 09-11-2012, 04:38 AM   #4
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
I don't think you can - I've see some truly monumental dialog menus (kernel config, locale selector, various Arch setup menus) and none of them have done what you describe. The man page also doesn't describe anything like that.

Of course, you could "roll your own" using ncurses and python/c, which shouldn't be too much hassle (I'd have thought)
 
Old 09-11-2012, 06:05 AM   #5
mjolnir
Member
 
Registered: Apr 2003
Posts: 815

Rep: Reputation: 99
Quote:
Originally Posted by Snark1994 View Post
Just by experimentation:

Code:
dialog --title " Menu! " --column-separator "|" --menu "" 19 40 12 "1" "A long option|One" "2" "Option|Two" "3" "Option|Three" "4" "Option|Four"
Nice. I was up way to early this morning, saw your post, installed "dialog" and it worked like a charm although I see it wasn't exactly what the OP needed. I really have no need for "dialog" but it's nice to know anyways. This also works inside of tmux.

Last edited by mjolnir; 12-08-2014 at 06:35 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
warning: /etc/hosts.deny, line 20: missing ":" separator tkmsr Linux - Security 23 01-10-2015 11:01 AM
Fedora 8 - trouble with file/"browse" dialog boxes after update... jonrpick Fedora 4 07-15-2008 01:51 PM
converting shell script from "dialog" to "xdialog" kushalkoolwal Programming 1 02-25-2008 08:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration