Concluo esse topico com um programa em bash orientado
a objetos, ou melhor emulado a objeto. Para mais informacao
fala direto comigo.

$ cat ClassDialog.v1.1
#$Id: ClassDialog.v1.1,v 1.1 2006/06/18 06:23:39 ivanczar Exp root $
# Class: ClassDialog

# -------------------------------------------------------------------------- #
# ----------------------------- Class: String ------------------------------ #
# -------------------------------------------------------------------------- #
String(){ obj_id=$1

   eval "$id.$obj_id.set(){
         eval \"$id.$obj_id.get(){
                echo \$*
              }\"
         eval \"$id.$obj_id.writeln(){
                  $id.$obj_id.get | tr ':' '\134'
              }\"
   }"

   eval "$id.$obj_id.append(){
         $id.$obj_id.set \$*:n\$($id.$obj_id.get)
   }"
}


Integer(){ obj_id=$1

   eval "$id.$obj_id.value(){
         eval \"$id.$obj_id(){
                echo \$*
             }\"
   }"
}


# -------------------------------------------------------------------------- #
# ----------------------------- Class: MsgBox ------------------------------ #
# -------------------------------------------------------------------------- #

InitBox(){

# -- Attribute -- #
   String title
   String text
   Integer height
   Integer width

}

MsgBox.new() { id=$1;this=$1

   InitBox # inicialize variables.

   LINE_CMD="                     \
      \$DIALOG \$OPT              \
      --title  '\$($id.title.get)'\
      --msgbox '\$($id.text.get)' \
      \$($id.height) \$($id.width)\
   "

   eval "$id.execute() {
      echo \"$LINE_CMD\" | sed \"s;[ ]\+; ;g\"
   }"
}

# -------------------------------------------------------------------------- #
# ----------------------------- Class: InfoBox ----------------------------- #
# -------------------------------------------------------------------------- #
InfoBox.new() { id=$1;this=$1

   InitBox # inicialize variables.

   LINE_CMD="                         \
      \$DIALOG \$OPT                  \
      --title   '\$($id.title.get)'   \
      --infobox '\$($id.text.writeln)'\
      \$($id.height) \$($id.width)    \
   "

   eval "$id.execute() {
      echo \"$LINE_CMD\" | sed \"s;[ ]\+; ;g\"
   }"
}

# -------------------------------------------------------------------------- #
# ---------------------------- Class: InputBox ----------------------------- #
# -------------------------------------------------------------------------- #
InputBox.new() { id=$1;this=$1

   InitBox # inicialize variables.

   LINE_CMD="                       \
      \$DIALOG \$OPT                \
      --title    '\$($id.title.get)'\
      --inputbox '\$($id.text.get)' \
      \$($id.height) \$($id.width)  \
   "

   eval "$id.execute() {
      echo \"$LINE_CMD\" | sed \"s;[ ]\+; ;g\"
   }"
}

# -------------------------------------------------------------------------- #
# --------------------------- Class: passwordbox --------------------------- #
# -------------------------------------------------------------------------- #
PasswordBox.new() { id=$1;this=$1

   InitBox # inicialize variables.

   LINE_CMD="                          \
      \$DIALOG \$OPT                   \
      --title       '\$($id.title.get)'\
      --passwordbox '\$($id.text.get)' \
      \$($id.height) \$($id.width)     \
   "

   eval "$id.execute() {
      echo \"$LINE_CMD\" | sed \"s;[ ]\+; ;g\"
   }"
}

# -------------------------------------------------------------------------- #
# ----------------------------- Class: TextBox ----------------------------- #
# -------------------------------------------------------------------------- #
TextBox.new() { id=$1;this=$1

   InitBox # inicialize variables.

   LINE_CMD="                          \
      \$DIALOG \$OPT                   \
      --title       '\$($id.title.get)'\
      --textbox     '\$($id.text.get)' \
      \$($id.height) \$($id.width)     \
   "

   eval "$id.execute() {
      echo \"$LINE_CMD\" | sed \"s;[ ]\+; ;g\"
   }"
}


# -------------------------------------------------------------------------- #
# ----------------------------- Class: TailBox ----------------------------- #
# -------------------------------------------------------------------------- #
TailBox.new() { id=$1;this=$1

   InitBox # inicialize variables.

   LINE_CMD="                          \
      \$DIALOG \$OPT                   \
      --title       '\$($id.title.get)'\
      --tailbox     '\$($id.text.get)' \
      \$($id.height) \$($id.width)     \
   "

   eval "$id.execute() {
      echo \"$LINE_CMD\" | sed \"s;[ ]\+; ;g\"
   }"
}

# -------------------------------------------------------------------------- #
# ---------------------------- Class TailBoxbg ----------------------------- #
# -------------------------------------------------------------------------- #
TailBoxBg.new() { id=$1;this=$1

   InitBox # inicialize variables.

   LINE_CMD="                          \
      \$DIALOG \$OPT                   \
      --title       '\$($id.title.get)'\
      --tailboxbg   '\$($id.text.get)' \
      \$($id.height) \$($id.width)     \
   "

   eval "$id.execute() {
      echo \"$LINE_CMD\" | sed \"s;[ ]\+; ;g\"
   }"
}

# -------------------------------------------------------------------------- #
# ------------------------------ Class: YesNo ------------------------------ #
# -------------------------------------------------------------------------- #
YesNo.new() { id=$1;this=$1

   InitBox # inicialize variables.

   LINE_CMD="                             \
      \$DIALOG \$OPT                      \
      --title       '\$($id.title.get)'   \
      --yesno       '\$($id.text.writeln)'\
      \$($id.height) \$($id.width)        \
   "

   eval "$id.execute() {
      echo \"$LINE_CMD\" | sed \"s;[ ]\+; ;g\"
   }"
}


# -------------------------------------------------------------------------- #
# ------------------------------ Class: Menu ------------------------------- #
# -------------------------------------------------------------------------- #
Menu.new() { id=$1;this=$1

   InitBox # inicialize variables.
   Integer line
   LINE_CMD="                                  \
      \$DIALOG \$OPT                           \
      --title       '\$($id.title.get)'        \
      --menu        '\$($id.text.get)'         \
      \$($id.height) \$($id.width) \$($id.line)\
      \${mLIST[*]}                             \
   "

   eval "$id.execute() {
      echo \"$LINE_CMD\" | sed \"s;[ ]\+; ;g\"
   }"
}

# -------------------------------------------------------------------------- #
# ------------------------------- RadioList -------------------------------- #
# -------------------------------------------------------------------------- #
RadioList.new() { id=$1;this=$1

   InitBox # inicialize variables.
   Integer line
   LINE_CMD="                                  \
      \$DIALOG \$OPT                           \
      --title       '\$($id.title.get)'        \
      --radiolist   '\$($id.text.get)'         \
      \$($id.height) \$($id.width) \$($id.line)\
      \${rLIST[*]}                             \
   "

   eval "$id.execute() {
      echo \"$LINE_CMD\" | sed \"s;[ ]\+; ;g\"
   }"
}

# -------------------------------------------------------------------------- #
# ---------------------------- Class: CheckList ---------------------------- #
# -------------------------------------------------------------------------- #
CheckList.new() { id=$1;this=$1

   InitBox # inicialize variables.
   Integer line
   LINE_CMD="                                  \
      \$DIALOG \$OPT                           \
      --title       '\$($id.title.get)'        \
      --checklist   '\$($id.text.get)'         \
      \$($id.height) \$($id.width) \$($id.line)\
      \${cLIST[*]}                             \
   "

   eval "$id.execute() {
      echo \"$LINE_CMD\" | sed \"s;[ ]\+; ;g\"
   }"
}

# -------------------------------------------------------------------------- #
# -----------------------------  Class: Gauge  ----------------------------- #
# -------------------------------------------------------------------------- #
Gauge.new() { id=$1;this=$1

   InitBox # inicialize variables.
   Integer progressbar
   LINE_CMD="                                         \
      \$DIALOG \$OPT                                  \
      --title       '\$($id.title.get)'               \
      --gauge       '\$($id.text.get)'                \
      \$($id.height) \$($id.width) \$($id.progressbar)\
   "

   eval "$id.execute() {
      echo \"$LINE_CMD\" | sed \"s;[ ]\+; ;g\"
   }"
}

$ cat
#!/bin/bash project-install.sh

# Universidade Federal Do Rio de Jnaneiro
# file: project-install.sh
# author: Ivan carlso Da Silva Lopes
# $Id:$

# program a gerador de janelas `wedget'
DIALOG=dialog

# load oo shell functions
. ./ClassDialog.v1.1

TITLE="2 2.1.0-beta Install A.I - CZAR                   [ REDES NEURAIS ]"
OPT="--stdout --backtitle '$TITLE'"

# size screen
rows=$(tput lines)
cols=$(tput cols)

Menu.new menu
$this.title.set    Instalador
$this.text.set     Selecione a opcao desejada:
$this.height.value 0
$this.width.value  0
$this.line.value   0
mLIST=(1 Instalar
       2 Compilar
       3 Debugar
       4 Configurar
       5 sobre
)

D_OUT=$(menu.execute| sh)
menu.execute | sh


conclusao:
...



-- 
[ ]'s
Ivan Carlos Da Silva Lopes

Engenheiro Eletronico e Computacao
UFRJ


---------------------------------------------------------------------
Esta lista não admite a abordagem de outras liguagens de programação, como 
perl, C etc. Quem insistir em não seguir esta regra será moderado sem prévio 
aviso.
---------------------------------------------------------------------
Sair da lista: [EMAIL PROTECTED]
---------------------------------------------------------------------
Esta lista é moderada de acordo com o previsto em 
http://www.listas-discussao.cjb.net
---------------------------------------------------------------------
Servidor Newsgroup da lista: news.gmane.org
Grupo: gmane.org.user-groups.programming.shell.brazil

 
Links do Yahoo! Grupos

<*> Para visitar o site do seu grupo na web, acesse:
    http://br.groups.yahoo.com/group/shell-script/

<*> Para sair deste grupo, envie um e-mail para:
    [EMAIL PROTECTED]

<*> O uso que você faz do Yahoo! Grupos está sujeito aos:
    http://br.yahoo.com/info/utos.html

 



Responder a