You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.6 KiB
Bash

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/bin/bash
#==============================================================================
# Модуль интерфейса (TUI) на основе 'dialog'
#==============================================================================
DIALOG_OPTS="--colors --backtitle 'Универсальный обработчик медиа'"
# Показать главное меню
# Принимает массив пунктов меню
ui_main_menu() {
dialog $DIALOG_OPTS --title "Главное меню" \
--menu "Выберите опцию для редактирования или действия:" 20 85 15 "${@}" 2>&1 >/dev/tty
}
# Получить путь к каталогу
# $1: Заголовок окна
# $2: Текущее значение (для старта)
# $3: Путь по умолчанию (если текущее значение пусто)
ui_get_directory() {
local title="$1"
local current_path="$2"
local default_path="$3"
local start_path="${current_path:-$default_path}"
# Убедимся, что путь заканчивается на / для dselect
[[ "$start_path" != */ ]] && start_path="$start_path/"
dialog $DIALOG_OPTS --title "$title" \
--dselect "$start_path" 10 70 2>&1 >/dev/tty
}
# Получить текстовый ввод от пользователя
# $1: Заголовок окна
# $2: Текущее значение
ui_get_input() {
local title="$1"
local current_value="$2"
dialog $DIALOG_OPTS --title "$title" \
--inputbox "Введите новое значение:" 10 70 "$current_value" 2>&1 >/dev/tty
}
# Показать информационное сообщение
# $1: Заголовок
# $2: Текст сообщения
ui_show_message() {
local title="$1"
local text="$2"
dialog $DIALOG_OPTS --title "$title" --msgbox "$text" 20 70
}
# Показать окно с выбором Да/Нет
# $1: Заголовок
# $2: Текст вопроса
ui_confirm() {
local title="$1"
local text="$2"
dialog $DIALOG_OPTS --title "$title" --yesno "$text" 10 70
return $?
}
# Показать меню выбора действия перед запуском
ui_select_action() {
dialog $DIALOG_OPTS --title "Выбор действия" \
--menu "Какую операцию выполнить с найденными файлами?" 15 70 2 \
"MERGE" "Склеить видео и аудио с помощью mkvmerge" \
"SYMLINK" "Создать символические ссылки на видеофайлы" 2>&1 >/dev/tty
}