scripting - dialog --buildlist 选项,如何使用?

标签 scripting dialog

我一直在阅读有关使用对话框创建交互式 shell 脚本的许多用途,但我对如何使用 --buildlist 选项感到困惑。阅读手册页、搜索 google、搜索 stackoverflow,甚至阅读 Linux Journal 从 1994 年开始的一些旧文章,都无济于事。

有人能给我一个清楚的例子来说明如何正确使用它吗?

让我们想象一个包含 5 个文件的目录,您要从中选择要复制到另一个目录的文件。谁能举个例子?

谢谢!

最佳答案

考虑以下几点:

dialog --buildlist "Select a directory" 20 50 5 \
  f1 "Directory One" off \
  f2 "Directory Two" on \
  f3 "Directory Three" on

这会显示类似的东西

     ┌────────────────────────────────────────────────┐
     │ Select a directory                             │
     │ ┌─────────────────────┐ ┌────^(-)─────────────┐│
     │ │Directory One        │ │Directory Two        ││
     │ │                     │ │Directory Three      ││
     │ │                     │ │                     ││
     │ │                     │ │                     ││
     │ │                     │ │                     ││
     │ └─────────────────────┘ └─────────────100%────┘│
     │                                                │
     │                                                │
     │                                                │
     │                                                │
     │                                                │
     │                                                │
     │                                                │
     │                                                │
     ├────────────────────────────────────────────────┤
     │           <OK>          <Cancel>               │
     └────────────────────────────────────────────────┘

框宽 50 个字符,高 20 行;每列显示 5 个项目。 off/on 分别确定项目是从左列还是右列开始。

控件:

  • ^ 选择左列
  • $ 选择正确的列
  • 使用箭头键上下移动所选列
  • 使用空格键将所选项目移动到另一列
  • 使用 Tab 键在确定和取消之间切换。如果您使用 --visit-items 选项,则可以使用 Tab 键循环浏览列表和按钮。
  • 按回车键选择“确定”或“取消”。

如果您选择“确定”,与右列中每个项目关联的标签(f1f2 等)将打印到标准错误。

关于scripting - dialog --buildlist 选项,如何使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44445741/

相关文章:

powershell - 使用 powershell 删除 .csv 文件中的最后一行

linux - 如何在脚本中执行 grep?

android - 我应该使用 Dialog 还是 DialogPreference 来制作专门的首选项对话框?

dialog - CKEditor 3 对话框定位

linux - 如何在linux下正确使用sed

linux - 如何删除空格后的每个字符?

java - 网格布局和对话框 : How to align items correctly

javascript - iPhone Javascript 确认对话框错误

android - getSupportFragmentManager 不在 DialogFragment 上编译