LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Need help or suggestions on drawing a cmd-line GUI in bash. (https://www.linuxquestions.org/questions/programming-9/need-help-or-suggestions-on-drawing-a-cmd-line-gui-in-bash-410937/)

rose_bud4201 02-02-2006 12:50 PM

Need help or suggestions on drawing a cmd-line GUI in bash.
 
I'm not sure entirely how to explain what I'm trying to do, but in a nutshell:
I have a list of text files, each containing a couple of snippets of information. I'd like to create a shell script which reads all of those files and prints them out in a coherent format, wherein the user can choose a file to edit, delete, etc...

I'm envisioning something akin to the pine interface - a box, a list of choices inside of the box, and the user can use arrow keys to choose an item and a command or two to choose what they'd like to do with it.

Most of this I can handle, although I know the final product won't be quite so slick-looking. But...how do I change what's displayed in one area without redrawing the whole screen? Like, if the user scrolls down the list of items, all I want to move is the list of items. Using up their PuTTy scrollback buffer to redisplay the entire window each time one line changes seems really inelegant.

I've seen someone do this in C ...I'd like to do this in Bash if at all possible.

Thoughts/suggestions?

xhi 02-02-2006 01:07 PM

have you checked out ncurses?

unSpawn 02-02-2006 01:18 PM

If you want to do this in only Bash then AFAIK the closest you can get to anything resembling a menu is select statements and tput for wipes. If you allow external apps check out dialog.

rose_bud4201 02-02-2006 01:20 PM

Hmm, I'd only previously heard of ncurses in the way of resolving dependancies, but from what I just gleaned from a google search, it looks promising.

Thank you, I appreciate the pointer!

gnashley 02-03-2006 12:37 AM

dialog is what you want. It uses the ncurses libs.

bigearsbilly 02-03-2006 10:35 AM

here's a silly script of mine
i usually ls into xless and cut and paste.




Code:

#!/bin/ksh

# read stdin and do $1 to the first thing on a
# received line.
# designed for pasting in X.
#
# eg: if you have a list of files you
# want to edit using gvim.
# open an xterm and type:
# wr gvim
#
# then copy and paste using X into the terminal

msg="#------------------\n# What do you want to:$* ?"
print -u2 -- $msg
while read thing rest; do

    [ "$thing" != "" ] && eval $* $thing
    print -u2 -- $msg
    sleep 1                                # we don't like fast infinite loops!

done



All times are GMT -5. The time now is 06:21 AM.